diff --git a/trunk/src/kernel/srs_kernel_file.hpp b/trunk/src/kernel/srs_kernel_file.hpp index 53d71613bd..bf34035f98 100644 --- a/trunk/src/kernel/srs_kernel_file.hpp +++ b/trunk/src/kernel/srs_kernel_file.hpp @@ -41,7 +41,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. /** * file writer, to write to file. */ -class SrsFileWriter : public ISrsBufferWriter +class SrsFileWriter : public ISrsWriter { private: std::string path; @@ -85,7 +85,7 @@ class SrsFileWriter : public ISrsBufferWriter /** * file reader, to read from file. */ -class SrsFileReader : public ISrsBufferReader +class SrsFileReader : public ISrsReader { private: std::string path; diff --git a/trunk/src/kernel/srs_kernel_io.cpp b/trunk/src/kernel/srs_kernel_io.cpp index d7c364a690..5b604e79cc 100644 --- a/trunk/src/kernel/srs_kernel_io.cpp +++ b/trunk/src/kernel/srs_kernel_io.cpp @@ -23,19 +23,35 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include -ISrsBufferReader::ISrsBufferReader() +ISrsReader::ISrsReader() { } -ISrsBufferReader::~ISrsBufferReader() +ISrsReader::~ISrsReader() { } -ISrsBufferWriter::ISrsBufferWriter() +ISrsStreamWriter::ISrsStreamWriter() { } -ISrsBufferWriter::~ISrsBufferWriter() +ISrsStreamWriter::~ISrsStreamWriter() +{ +} + +ISrsVectorWriter::ISrsVectorWriter() +{ +} + +ISrsVectorWriter::~ISrsVectorWriter() +{ +} + +ISrsWriter::ISrsWriter() +{ +} + +ISrsWriter::~ISrsWriter() { } diff --git a/trunk/src/kernel/srs_kernel_io.hpp b/trunk/src/kernel/srs_kernel_io.hpp index 743ffdc3e1..9bf9dd8381 100644 --- a/trunk/src/kernel/srs_kernel_io.hpp +++ b/trunk/src/kernel/srs_kernel_io.hpp @@ -36,33 +36,42 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #endif /** - * the reader for the buffer to read from whatever channel. + * The reader to read data from channel. */ -class ISrsBufferReader +class ISrsReader { public: - ISrsBufferReader(); - virtual ~ISrsBufferReader(); - // for protocol/amf0/msg-codec + ISrsReader(); + virtual ~ISrsReader(); public: virtual int read(void* buf, size_t size, ssize_t* nread) = 0; }; /** - * the writer for the buffer to write to whatever channel. + * The writer to write stream data to channel. */ -class ISrsBufferWriter +class ISrsStreamWriter { public: - ISrsBufferWriter(); - virtual ~ISrsBufferWriter(); - // for protocol + ISrsStreamWriter(); + virtual ~ISrsStreamWriter(); public: /** * write bytes over writer. * @nwrite the actual written bytes. NULL to ignore. */ virtual int write(void* buf, size_t size, ssize_t* nwrite) = 0; +}; + +/** + * The vector writer to write vector(iovc) to channel. + */ +class ISrsVectorWriter +{ +public: + ISrsVectorWriter(); + virtual ~ISrsVectorWriter(); +public: /** * write iov over writer. * @nwrite the actual written bytes. NULL to ignore. @@ -70,5 +79,15 @@ class ISrsBufferWriter virtual int writev(const iovec *iov, int iov_size, ssize_t* nwrite) = 0; }; +/** + * The generally writer, stream and vector writer. + */ +class ISrsWriter : virtual public ISrsStreamWriter, virtual public ISrsVectorWriter +{ +public: + ISrsWriter(); + virtual ~ISrsWriter(); +}; + #endif diff --git a/trunk/src/libs/srs_lib_simple_socket.cpp b/trunk/src/libs/srs_lib_simple_socket.cpp index bd5d7fa944..1308389d4e 100644 --- a/trunk/src/libs/srs_lib_simple_socket.cpp +++ b/trunk/src/libs/srs_lib_simple_socket.cpp @@ -341,7 +341,7 @@ int SimpleSocketStream::connect(const char* server_ip, int port) return srs_hijack_io_connect(io, server_ip, port); } -// ISrsBufferReader +// ISrsReader int SimpleSocketStream::read(void* buf, size_t size, ssize_t* nread) { srs_assert(io); diff --git a/trunk/src/libs/srs_lib_simple_socket.hpp b/trunk/src/libs/srs_lib_simple_socket.hpp index 0ba31d1b8c..96a42b9fda 100644 --- a/trunk/src/libs/srs_lib_simple_socket.hpp +++ b/trunk/src/libs/srs_lib_simple_socket.hpp @@ -53,7 +53,7 @@ class SimpleSocketStream : public ISrsProtocolReaderWriter virtual srs_hijack_io_t hijack_io(); virtual int create_socket(srs_rtmp_t owner); virtual int connect(const char* server, int port); -// ISrsBufferReader +// ISrsReader public: virtual int read(void* buf, size_t size, ssize_t* nread); // ISrsProtocolReader diff --git a/trunk/src/protocol/srs_protocol_io.hpp b/trunk/src/protocol/srs_protocol_io.hpp index d7e43657df..8939061b1e 100644 --- a/trunk/src/protocol/srs_protocol_io.hpp +++ b/trunk/src/protocol/srs_protocol_io.hpp @@ -34,15 +34,20 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. /** * the system io reader/writer architecture: -+---------------+ +--------------------+ +---------------+ -| IBufferReader | | IStatistic | | IBufferWriter | -+---------------+ +--------------------+ +---------------+ -| + read() | | + get_recv_bytes() | | + write() | -+------+--------+ | + get_send_bytes() | | + writev() | - / \ +---+--------------+-+ +-------+-------+ - | / \ / \ / \ - | | | | -+------+------------------+-+ +-----+----------------+--+ + +---------------+ +---------------+ + | IStreamWriter | | IVectorWriter | + +---------------+ +---------------+ + | + write() | | + writev() | + +-------------+-+ ++--------------+ ++----------+ +--------------------+ /\ /\ +| IReader | | IStatistic | \ / ++----------+ +--------------------+ V +| + read() | | + get_recv_bytes() | +------+----+ ++------+---+ | + get_send_bytes() | | IWriter | + / \ +---+--------------+-+ +-------+---+ + | / \ / \ / \ + | | | | ++------+-------------+------+ ++---------------------+--+ | IProtocolReader | | IProtocolWriter | +---------------------------+ +-------------------------+ | + readfully() | | + set_send_timeout() | @@ -80,7 +85,7 @@ class ISrsProtocolStatistic /** * the reader for the protocol to read from whatever channel. */ -class ISrsProtocolReader : public virtual ISrsBufferReader, public virtual ISrsProtocolStatistic +class ISrsProtocolReader : public virtual ISrsReader, public virtual ISrsProtocolStatistic { public: ISrsProtocolReader(); @@ -108,7 +113,7 @@ class ISrsProtocolReader : public virtual ISrsBufferReader, public virtual ISrsP /** * the writer for the protocol to write to whatever channel. */ -class ISrsProtocolWriter : public virtual ISrsBufferWriter, public virtual ISrsProtocolStatistic +class ISrsProtocolWriter : public virtual ISrsWriter, public virtual ISrsProtocolStatistic { public: ISrsProtocolWriter(); diff --git a/trunk/src/protocol/srs_protocol_stream.cpp b/trunk/src/protocol/srs_protocol_stream.cpp index c41e96ba1b..de0887804f 100755 --- a/trunk/src/protocol/srs_protocol_stream.cpp +++ b/trunk/src/protocol/srs_protocol_stream.cpp @@ -131,7 +131,7 @@ void SrsFastStream::skip(int size) p += size; } -int SrsFastStream::grow(ISrsBufferReader* reader, int required_size) +int SrsFastStream::grow(ISrsReader* reader, int required_size) { int ret = ERROR_SUCCESS; diff --git a/trunk/src/protocol/srs_protocol_stream.hpp b/trunk/src/protocol/srs_protocol_stream.hpp index 235269b668..30979dfe93 100644 --- a/trunk/src/protocol/srs_protocol_stream.hpp +++ b/trunk/src/protocol/srs_protocol_stream.hpp @@ -60,7 +60,7 @@ class IMergeReadHandler * the buffer provices bytes cache for protocol. generally, * protocol recv data from socket, put into buffer, decode to RTMP message. * Usage: -* ISrsBufferReader* r = ......; +* ISrsReader* r = ......; * SrsFastStream* fb = ......; * fb->grow(r, 1024); * char* header = fb->read_slice(100); @@ -138,7 +138,7 @@ class SrsFastStream * @return an int error code, error if required_size negative. * @remark, we actually maybe read more than required_size, maybe 4k for example. */ - virtual int grow(ISrsBufferReader* reader, int required_size); + virtual int grow(ISrsReader* reader, int required_size); public: #ifdef SRS_PERF_MERGED_READ /** diff --git a/trunk/src/utest/srs_utest_kernel.hpp b/trunk/src/utest/srs_utest_kernel.hpp index 494bfb6d16..85d89186fa 100644 --- a/trunk/src/utest/srs_utest_kernel.hpp +++ b/trunk/src/utest/srs_utest_kernel.hpp @@ -33,7 +33,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include -class MockBufferReader: public ISrsBufferReader +class MockBufferReader: public ISrsReader { private: std::string str;