正在显示
2 个修改的文件
包含
29 行增加
和
18 行删除
| @@ -321,15 +321,6 @@ SrsProtocol::~SrsProtocol() | @@ -321,15 +321,6 @@ SrsProtocol::~SrsProtocol() | ||
| 321 | srs_freep(buffer); | 321 | srs_freep(buffer); |
| 322 | } | 322 | } |
| 323 | 323 | ||
| 324 | -string SrsProtocol::get_request_name(double transcationId) | ||
| 325 | -{ | ||
| 326 | - if (requests.find(transcationId) == requests.end()) { | ||
| 327 | - return ""; | ||
| 328 | - } | ||
| 329 | - | ||
| 330 | - return requests[transcationId]; | ||
| 331 | -} | ||
| 332 | - | ||
| 333 | void SrsProtocol::set_recv_timeout(int64_t timeout_us) | 324 | void SrsProtocol::set_recv_timeout(int64_t timeout_us) |
| 334 | { | 325 | { |
| 335 | return skt->set_recv_timeout(timeout_us); | 326 | return skt->set_recv_timeout(timeout_us); |
| @@ -605,12 +596,14 @@ int SrsProtocol::do_decode_message(SrsMessageHeader& header, SrsStream* stream, | @@ -605,12 +596,14 @@ int SrsProtocol::do_decode_message(SrsMessageHeader& header, SrsStream* stream, | ||
| 605 | stream->skip(1); | 596 | stream->skip(1); |
| 606 | } | 597 | } |
| 607 | 598 | ||
| 608 | - std::string request_name = get_request_name(transactionId); | ||
| 609 | - if (request_name.empty()) { | 599 | + // find the call name |
| 600 | + if (requests.find(transactionId) == requests.end()) { | ||
| 610 | ret = ERROR_RTMP_NO_REQUEST; | 601 | ret = ERROR_RTMP_NO_REQUEST; |
| 611 | srs_error("decode AMF0/AMF3 request failed. ret=%d", ret); | 602 | srs_error("decode AMF0/AMF3 request failed. ret=%d", ret); |
| 612 | return ret; | 603 | return ret; |
| 613 | } | 604 | } |
| 605 | + | ||
| 606 | + std::string request_name = requests[transactionId]; | ||
| 614 | srs_verbose("AMF0/AMF3 request parsed. request_name=%s", request_name.c_str()); | 607 | srs_verbose("AMF0/AMF3 request parsed. request_name=%s", request_name.c_str()); |
| 615 | 608 | ||
| 616 | if (request_name == RTMP_AMF0_COMMAND_CONNECT) { | 609 | if (request_name == RTMP_AMF0_COMMAND_CONNECT) { |
| @@ -124,16 +124,21 @@ public: | @@ -124,16 +124,21 @@ public: | ||
| 124 | SrsProtocol(ISrsProtocolReaderWriter* io); | 124 | SrsProtocol(ISrsProtocolReaderWriter* io); |
| 125 | virtual ~SrsProtocol(); | 125 | virtual ~SrsProtocol(); |
| 126 | public: | 126 | public: |
| 127 | - // TODO: FIXME: to private. | ||
| 128 | - std::string get_request_name(double transcationId); | ||
| 129 | /** | 127 | /** |
| 130 | - * set the timeout in us. | 128 | + * set/get the recv timeout in us. |
| 131 | * if timeout, recv/send message return ERROR_SOCKET_TIMEOUT. | 129 | * if timeout, recv/send message return ERROR_SOCKET_TIMEOUT. |
| 132 | */ | 130 | */ |
| 133 | virtual void set_recv_timeout(int64_t timeout_us); | 131 | virtual void set_recv_timeout(int64_t timeout_us); |
| 134 | virtual int64_t get_recv_timeout(); | 132 | virtual int64_t get_recv_timeout(); |
| 133 | + /** | ||
| 134 | + * set/get the send timeout in us. | ||
| 135 | + * if timeout, recv/send message return ERROR_SOCKET_TIMEOUT. | ||
| 136 | + */ | ||
| 135 | virtual void set_send_timeout(int64_t timeout_us); | 137 | virtual void set_send_timeout(int64_t timeout_us); |
| 136 | virtual int64_t get_send_timeout(); | 138 | virtual int64_t get_send_timeout(); |
| 139 | + /** | ||
| 140 | + * get recv/send bytes. | ||
| 141 | + */ | ||
| 137 | virtual int64_t get_recv_bytes(); | 142 | virtual int64_t get_recv_bytes(); |
| 138 | virtual int64_t get_send_bytes(); | 143 | virtual int64_t get_send_bytes(); |
| 139 | public: | 144 | public: |
| @@ -213,7 +218,13 @@ private: | @@ -213,7 +218,13 @@ private: | ||
| 213 | */ | 218 | */ |
| 214 | virtual int on_send_message(SrsMessage* msg, SrsPacket* packet); | 219 | virtual int on_send_message(SrsMessage* msg, SrsPacket* packet); |
| 215 | private: | 220 | private: |
| 221 | + /** | ||
| 222 | + * auto response the ack message. | ||
| 223 | + */ | ||
| 216 | virtual int response_acknowledgement_message(); | 224 | virtual int response_acknowledgement_message(); |
| 225 | + /** | ||
| 226 | + * auto response the ping message. | ||
| 227 | + */ | ||
| 217 | virtual int response_ping_message(int32_t timestamp); | 228 | virtual int response_ping_message(int32_t timestamp); |
| 218 | }; | 229 | }; |
| 219 | 230 | ||
| @@ -252,7 +263,6 @@ public: | @@ -252,7 +263,6 @@ public: | ||
| 252 | * @remark, we use 64bits for large time for jitter detect and hls. | 263 | * @remark, we use 64bits for large time for jitter detect and hls. |
| 253 | */ | 264 | */ |
| 254 | int64_t timestamp; | 265 | int64_t timestamp; |
| 255 | - | ||
| 256 | public: | 266 | public: |
| 257 | /** | 267 | /** |
| 258 | * get the perfered cid(chunk stream id) which sendout over. | 268 | * get the perfered cid(chunk stream id) which sendout over. |
| @@ -260,11 +270,10 @@ public: | @@ -260,11 +270,10 @@ public: | ||
| 260 | * for example, dispatch to all connections. | 270 | * for example, dispatch to all connections. |
| 261 | */ | 271 | */ |
| 262 | int perfer_cid; | 272 | int perfer_cid; |
| 263 | - | ||
| 264 | public: | 273 | public: |
| 265 | SrsMessageHeader(); | 274 | SrsMessageHeader(); |
| 266 | virtual ~SrsMessageHeader(); | 275 | virtual ~SrsMessageHeader(); |
| 267 | - | 276 | +public: |
| 268 | bool is_audio(); | 277 | bool is_audio(); |
| 269 | bool is_video(); | 278 | bool is_video(); |
| 270 | bool is_amf0_command(); | 279 | bool is_amf0_command(); |
| @@ -277,9 +286,18 @@ public: | @@ -277,9 +286,18 @@ public: | ||
| 277 | bool is_user_control_message(); | 286 | bool is_user_control_message(); |
| 278 | bool is_set_peer_bandwidth(); | 287 | bool is_set_peer_bandwidth(); |
| 279 | bool is_aggregate(); | 288 | bool is_aggregate(); |
| 280 | - | 289 | +public: |
| 290 | + /** | ||
| 291 | + * create a amf0 script header, set the size and stream_id. | ||
| 292 | + */ | ||
| 281 | void initialize_amf0_script(int size, int stream); | 293 | void initialize_amf0_script(int size, int stream); |
| 294 | + /** | ||
| 295 | + * create a audio header, set the size, timestamp and stream_id. | ||
| 296 | + */ | ||
| 282 | void initialize_audio(int size, u_int32_t time, int stream); | 297 | void initialize_audio(int size, u_int32_t time, int stream); |
| 298 | + /** | ||
| 299 | + * create a video header, set the size, timestamp and stream_id. | ||
| 300 | + */ | ||
| 283 | void initialize_video(int size, u_int32_t time, int stream); | 301 | void initialize_video(int size, u_int32_t time, int stream); |
| 284 | }; | 302 | }; |
| 285 | 303 |
-
请 注册 或 登录 后发表评论