mirror of
				https://github.com/ossrs/srs.git
				synced 2025-03-09 15:49:59 +00:00 
			
		
		
		
	for #742, refine the io interfaces.
This commit is contained in:
		
							parent
							
								
									eaa222f034
								
							
						
					
					
						commit
						d3bb8b6a86
					
				
					 9 changed files with 73 additions and 33 deletions
				
			
		|  | @ -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 @@ public: | |||
| /**
 | ||||
| * 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 @@ public: | |||
| /**
 | ||||
| * 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(); | ||||
|  |  | |||
|  | @ -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; | ||||
| 
 | ||||
|  |  | |||
|  | @ -60,7 +60,7 @@ public: | |||
| * 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 @@ public: | |||
|     * @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 | ||||
|     /**
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue