Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2014-06-19 10:34:10 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
46c1367fe86046a8f966bbea8eca0fa80889c54b
46c1367f
1 parent
b0e4dc80
refine the protocol io reader writer arch.
隐藏空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
78 行增加
和
10 行删除
trunk/src/rtmp/srs_protocol_io.cpp
trunk/src/rtmp/srs_protocol_io.hpp
trunk/src/rtmp/srs_protocol_io.cpp
查看文件 @
46c1367
...
...
@@ -23,6 +23,22 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_protocol_io.hpp>
ISrsBufferWriter
::
ISrsBufferWriter
()
{
}
ISrsBufferWriter
::~
ISrsBufferWriter
()
{
}
ISrsProtocolStatistic
::
ISrsProtocolStatistic
()
{
}
ISrsProtocolStatistic
::~
ISrsProtocolStatistic
()
{
}
ISrsProtocolReader
::
ISrsProtocolReader
()
{
}
...
...
trunk/src/rtmp/srs_protocol_io.hpp
查看文件 @
46c1367
...
...
@@ -35,9 +35,62 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_kernel_buffer.hpp>
/**
* the system io reader/writer architecture:
+---------------+ +--------------------+ +---------------+
| IBufferReader | | IStatistic | | IBufferWriter |
+---------------+ +--------------------+ +---------------+
| + read() | | + get_recv_bytes() | | + write() |
+------+--------+ | + get_recv_bytes() | | + writev() |
/ \ +---+--------------+-+ +-------+-------+
| / \ / \ / \
| | | |
+------+------------------+-+ +-----+----------------+--+
| IProtocolReader | | IProtocolWriter |
+---------------------------+ +-------------------------+
| + readfully() | | + set_send_timeout() |
| + set_recv_timeout() | +-------+-----------------+
+------------+--------------+ / \
/ \ |
| |
+--+-----------------------------+-+
| IProtocolReaderWriter |
+----------------------------------+
| + is_never_timeout() |
+----------------------------------+
*/
/**
* the writer for the buffer to write to whatever channel.
*/
class
ISrsBufferWriter
{
public
:
ISrsBufferWriter
();
virtual
~
ISrsBufferWriter
();
// for protocol
public:
virtual
int
write
(
void
*
buf
,
size_t
size
,
ssize_t
*
nwrite
)
=
0
;
virtual
int
writev
(
const
iovec
*
iov
,
int
iov_size
,
ssize_t
*
nwrite
)
=
0
;
};
/**
* get the statistic of channel.
*/
class
ISrsProtocolStatistic
{
public
:
ISrsProtocolStatistic
();
virtual
~
ISrsProtocolStatistic
();
// for protocol
public:
virtual
int64_t
get_recv_bytes
()
=
0
;
virtual
int64_t
get_send_bytes
()
=
0
;
};
/**
* the reader for the protocol to read from whatever channel.
*/
class
ISrsProtocolReader
:
public
ISrsBufferReader
class
ISrsProtocolReader
:
public
virtual
ISrsBufferReader
,
public
virtual
ISrsProtocolStatistic
{
public
:
ISrsProtocolReader
();
...
...
@@ -46,13 +99,15 @@ public:
public:
virtual
void
set_recv_timeout
(
int64_t
timeout_us
)
=
0
;
virtual
int64_t
get_recv_timeout
()
=
0
;
virtual
int64_t
get_recv_bytes
()
=
0
;
// for handshake.
public:
virtual
int
read_fully
(
void
*
buf
,
size_t
size
,
ssize_t
*
nread
)
=
0
;
};
/**
* the writer for the protocol to write to whatever channel.
*/
class
ISrsProtocolWriter
class
ISrsProtocolWriter
:
public
virtual
ISrsBufferWriter
,
public
virtual
ISrsProtocolStatistic
{
public
:
ISrsProtocolWriter
();
...
...
@@ -61,11 +116,12 @@ public:
public:
virtual
void
set_send_timeout
(
int64_t
timeout_us
)
=
0
;
virtual
int64_t
get_send_timeout
()
=
0
;
virtual
int64_t
get_send_bytes
()
=
0
;
virtual
int
writev
(
const
iovec
*
iov
,
int
iov_size
,
ssize_t
*
nwrite
)
=
0
;
};
class
ISrsProtocolReaderWriter
:
public
ISrsProtocolReader
,
public
ISrsProtocolWriter
/**
* the reader and writer.
*/
class
ISrsProtocolReaderWriter
:
public
virtual
ISrsProtocolReader
,
public
virtual
ISrsProtocolWriter
{
public
:
ISrsProtocolReaderWriter
();
...
...
@@ -76,10 +132,6 @@ public:
* whether the specified timeout_us is never timeout.
*/
virtual
bool
is_never_timeout
(
int64_t
timeout_us
)
=
0
;
// for handshake.
public:
virtual
int
read_fully
(
void
*
buf
,
size_t
size
,
ssize_t
*
nread
)
=
0
;
virtual
int
write
(
void
*
buf
,
size_t
size
,
ssize_t
*
nwrite
)
=
0
;
};
#endif
...
...
请
注册
或
登录
后发表评论