|
|
|
@ -29,7 +29,7 @@
|
|
|
|
|
#include <srs_kernel_io.hpp>
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* the system io reader/writer architecture:
|
|
|
|
|
* The system io reader/writer architecture:
|
|
|
|
|
* +---------------+ +---------------+
|
|
|
|
|
* | IStreamWriter | | IVectorWriter |
|
|
|
|
|
* +---------------+ +---------------+
|
|
|
|
@ -59,22 +59,18 @@
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* get the statistic of channel.
|
|
|
|
|
* Get the statistic of channel.
|
|
|
|
|
*/
|
|
|
|
|
class ISrsProtocolStatistic
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
ISrsProtocolStatistic();
|
|
|
|
|
virtual ~ISrsProtocolStatistic();
|
|
|
|
|
// for protocol
|
|
|
|
|
// For protocol
|
|
|
|
|
public:
|
|
|
|
|
/**
|
|
|
|
|
* get the total recv bytes over underlay fd.
|
|
|
|
|
*/
|
|
|
|
|
// Get the total recv bytes over underlay fd.
|
|
|
|
|
virtual int64_t get_recv_bytes() = 0;
|
|
|
|
|
/**
|
|
|
|
|
* get the total send bytes over underlay fd.
|
|
|
|
|
*/
|
|
|
|
|
// Get the total send bytes over underlay fd.
|
|
|
|
|
virtual int64_t get_send_bytes() = 0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -88,21 +84,15 @@ public:
|
|
|
|
|
virtual ~ISrsProtocolReader();
|
|
|
|
|
// for protocol
|
|
|
|
|
public:
|
|
|
|
|
/**
|
|
|
|
|
* Set the timeout tm in ms for recv bytes from peer.
|
|
|
|
|
* @remark Use SRS_UTIME_NO_TIMEOUT to never timeout.
|
|
|
|
|
*/
|
|
|
|
|
// Set the timeout tm in ms for recv bytes from peer.
|
|
|
|
|
// @remark Use SRS_UTIME_NO_TIMEOUT to never timeout.
|
|
|
|
|
virtual void set_recv_timeout(int64_t tm) = 0;
|
|
|
|
|
/**
|
|
|
|
|
* Get the timeout in ms for recv bytes from peer.
|
|
|
|
|
*/
|
|
|
|
|
// Get the timeout in ms for recv bytes from peer.
|
|
|
|
|
virtual int64_t get_recv_timeout() = 0;
|
|
|
|
|
// for handshake.
|
|
|
|
|
// For handshake.
|
|
|
|
|
public:
|
|
|
|
|
/**
|
|
|
|
|
* read specified size bytes of data
|
|
|
|
|
* @param nread, the actually read size, NULL to ignore.
|
|
|
|
|
*/
|
|
|
|
|
// Read specified size bytes of data
|
|
|
|
|
// @param nread, the actually read size, NULL to ignore.
|
|
|
|
|
virtual srs_error_t read_fully(void* buf, size_t size, ssize_t* nread) = 0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -114,32 +104,26 @@ class ISrsProtocolWriter : virtual public ISrsWriter, virtual public ISrsProtoco
|
|
|
|
|
public:
|
|
|
|
|
ISrsProtocolWriter();
|
|
|
|
|
virtual ~ISrsProtocolWriter();
|
|
|
|
|
// for protocol
|
|
|
|
|
// For protocol
|
|
|
|
|
public:
|
|
|
|
|
/**
|
|
|
|
|
* Set the timeout tm in srs_utime_t for send bytes to peer.
|
|
|
|
|
* @remark Use SRS_UTIME_NO_TIMEOUT to never timeout.
|
|
|
|
|
*/
|
|
|
|
|
// Set the timeout tm in srs_utime_t for send bytes to peer.
|
|
|
|
|
// @remark Use SRS_UTIME_NO_TIMEOUT to never timeout.
|
|
|
|
|
virtual void set_send_timeout(srs_utime_t tm) = 0;
|
|
|
|
|
/**
|
|
|
|
|
* Get the timeout in ms for send bytes to peer.
|
|
|
|
|
*/
|
|
|
|
|
virtual int64_t get_send_timeout() = 0;
|
|
|
|
|
// Get the timeout in srs_utime_t for send bytes to peer.
|
|
|
|
|
virtual srs_utime_t get_send_timeout() = 0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* the reader and writer.
|
|
|
|
|
* The reader and writer.
|
|
|
|
|
*/
|
|
|
|
|
class ISrsProtocolReadWriter : virtual public ISrsProtocolReader, virtual public ISrsProtocolWriter
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
ISrsProtocolReadWriter();
|
|
|
|
|
virtual ~ISrsProtocolReadWriter();
|
|
|
|
|
// for protocol
|
|
|
|
|
// For protocol
|
|
|
|
|
public:
|
|
|
|
|
/**
|
|
|
|
|
* Whether the specified tm in ms is never timeout.
|
|
|
|
|
*/
|
|
|
|
|
// Whether the specified tm in ms is never timeout.
|
|
|
|
|
virtual bool is_never_timeout(int64_t tm) = 0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|