winlin

add comments of io interfaces.

@@ -69,7 +69,15 @@ public: @@ -69,7 +69,15 @@ public:
69 virtual ~ISrsBufferWriter(); 69 virtual ~ISrsBufferWriter();
70 // for protocol 70 // for protocol
71 public: 71 public:
  72 + /**
  73 + * write bytes over writer.
  74 + * @nwrite the actual written bytes. NULL to ignore.
  75 + */
72 virtual int write(void* buf, size_t size, ssize_t* nwrite) = 0; 76 virtual int write(void* buf, size_t size, ssize_t* nwrite) = 0;
  77 + /**
  78 + * write iov over writer.
  79 + * @nwrite the actual written bytes. NULL to ignore.
  80 + */
73 virtual int writev(const iovec *iov, int iov_size, ssize_t* nwrite) = 0; 81 virtual int writev(const iovec *iov, int iov_size, ssize_t* nwrite) = 0;
74 }; 82 };
75 83
@@ -83,7 +91,13 @@ public: @@ -83,7 +91,13 @@ public:
83 virtual ~ISrsProtocolStatistic(); 91 virtual ~ISrsProtocolStatistic();
84 // for protocol 92 // for protocol
85 public: 93 public:
  94 + /**
  95 + * get the total recv bytes over underlay fd.
  96 + */
86 virtual int64_t get_recv_bytes() = 0; 97 virtual int64_t get_recv_bytes() = 0;
  98 + /**
  99 + * get the total send bytes over underlay fd.
  100 + */
87 virtual int64_t get_send_bytes() = 0; 101 virtual int64_t get_send_bytes() = 0;
88 }; 102 };
89 103
@@ -97,10 +111,21 @@ public: @@ -97,10 +111,21 @@ public:
97 virtual ~ISrsProtocolReader(); 111 virtual ~ISrsProtocolReader();
98 // for protocol 112 // for protocol
99 public: 113 public:
  114 + /**
  115 + * set the recv timeout in us, recv will error when timeout.
  116 + * @remark, if not set, use ST_UTIME_NO_TIMEOUT, never timeout.
  117 + */
100 virtual void set_recv_timeout(int64_t timeout_us) = 0; 118 virtual void set_recv_timeout(int64_t timeout_us) = 0;
  119 + /**
  120 + * get the recv timeout in us.
  121 + */
101 virtual int64_t get_recv_timeout() = 0; 122 virtual int64_t get_recv_timeout() = 0;
102 // for handshake. 123 // for handshake.
103 public: 124 public:
  125 + /**
  126 + * read specified size bytes of data
  127 + * @param nread, the actually read size, NULL to ignore.
  128 + */
104 virtual int read_fully(void* buf, size_t size, ssize_t* nread) = 0; 129 virtual int read_fully(void* buf, size_t size, ssize_t* nread) = 0;
105 }; 130 };
106 131
@@ -114,7 +139,14 @@ public: @@ -114,7 +139,14 @@ public:
114 virtual ~ISrsProtocolWriter(); 139 virtual ~ISrsProtocolWriter();
115 // for protocol 140 // for protocol
116 public: 141 public:
  142 + /**
  143 + * set the send timeout in us, send will error when timeout.
  144 + * @remark, if not set, use ST_UTIME_NO_TIMEOUT, never timeout.
  145 + */
117 virtual void set_send_timeout(int64_t timeout_us) = 0; 146 virtual void set_send_timeout(int64_t timeout_us) = 0;
  147 + /**
  148 + * get the send timeout in us.
  149 + */
118 virtual int64_t get_send_timeout() = 0; 150 virtual int64_t get_send_timeout() = 0;
119 }; 151 };
120 152