正在显示
2 个修改的文件
包含
29 行增加
和
3 行删除
| @@ -229,6 +229,8 @@ SrsProtocol::SrsProtocol(ISrsProtocolReaderWriter* io) | @@ -229,6 +229,8 @@ SrsProtocol::SrsProtocol(ISrsProtocolReaderWriter* io) | ||
| 229 | 229 | ||
| 230 | warned_c0c3_cache_dry = false; | 230 | warned_c0c3_cache_dry = false; |
| 231 | auto_response_when_recv = true; | 231 | auto_response_when_recv = true; |
| 232 | + show_debug_info = true; | ||
| 233 | + in_buffer_length = 0; | ||
| 232 | 234 | ||
| 233 | cs_cache = NULL; | 235 | cs_cache = NULL; |
| 234 | if (SRS_PERF_CHUNK_STREAM_CACHE > 0) { | 236 | if (SRS_PERF_CHUNK_STREAM_CACHE > 0) { |
| @@ -896,6 +898,8 @@ int SrsProtocol::send_and_free_messages(SrsSharedPtrMessage** msgs, int nb_msgs, | @@ -896,6 +898,8 @@ int SrsProtocol::send_and_free_messages(SrsSharedPtrMessage** msgs, int nb_msgs, | ||
| 896 | return ret; | 898 | return ret; |
| 897 | } | 899 | } |
| 898 | 900 | ||
| 901 | + print_debug_info(); | ||
| 902 | + | ||
| 899 | return ret; | 903 | return ret; |
| 900 | } | 904 | } |
| 901 | 905 | ||
| @@ -1473,6 +1477,9 @@ int SrsProtocol::on_recv_message(SrsCommonMessage* msg) | @@ -1473,6 +1477,9 @@ int SrsProtocol::on_recv_message(SrsCommonMessage* msg) | ||
| 1473 | } | 1477 | } |
| 1474 | srs_verbose("decode packet from message payload success."); | 1478 | srs_verbose("decode packet from message payload success."); |
| 1475 | break; | 1479 | break; |
| 1480 | + case RTMP_MSG_VideoMessage: | ||
| 1481 | + case RTMP_MSG_AudioMessage: | ||
| 1482 | + print_debug_info(); | ||
| 1476 | default: | 1483 | default: |
| 1477 | return ret; | 1484 | return ret; |
| 1478 | } | 1485 | } |
| @@ -1508,8 +1515,7 @@ int SrsProtocol::on_recv_message(SrsCommonMessage* msg) | @@ -1508,8 +1515,7 @@ int SrsProtocol::on_recv_message(SrsCommonMessage* msg) | ||
| 1508 | if (pkt->chunk_size < SRS_CONSTS_RTMP_MIN_CHUNK_SIZE | 1515 | if (pkt->chunk_size < SRS_CONSTS_RTMP_MIN_CHUNK_SIZE |
| 1509 | || pkt->chunk_size > SRS_CONSTS_RTMP_MAX_CHUNK_SIZE) | 1516 | || pkt->chunk_size > SRS_CONSTS_RTMP_MAX_CHUNK_SIZE) |
| 1510 | { | 1517 | { |
| 1511 | - srs_warn("accept chunk size %d, but should in [%d, %d], " | ||
| 1512 | - "@see: https://github.com/ossrs/srs/issues/160", | 1518 | + srs_warn("accept chunk=%d, should in [%d, %d], please see #160", |
| 1513 | pkt->chunk_size, SRS_CONSTS_RTMP_MIN_CHUNK_SIZE, SRS_CONSTS_RTMP_MAX_CHUNK_SIZE); | 1519 | pkt->chunk_size, SRS_CONSTS_RTMP_MIN_CHUNK_SIZE, SRS_CONSTS_RTMP_MAX_CHUNK_SIZE); |
| 1514 | } | 1520 | } |
| 1515 | 1521 | ||
| @@ -1531,7 +1537,8 @@ int SrsProtocol::on_recv_message(SrsCommonMessage* msg) | @@ -1531,7 +1537,8 @@ int SrsProtocol::on_recv_message(SrsCommonMessage* msg) | ||
| 1531 | srs_assert(pkt != NULL); | 1537 | srs_assert(pkt != NULL); |
| 1532 | 1538 | ||
| 1533 | if (pkt->event_type == SrcPCUCSetBufferLength) { | 1539 | if (pkt->event_type == SrcPCUCSetBufferLength) { |
| 1534 | - srs_trace("buffer=%d, in.ack=%d, out.ack=%d, in.chunk=%d, out.chunk=%d", pkt->extra_data, | 1540 | + in_buffer_length = pkt->extra_data; |
| 1541 | + srs_info("buffer=%d, in.ack=%d, out.ack=%d, in.chunk=%d, out.chunk=%d", pkt->extra_data, | ||
| 1535 | in_ack_size.window, out_ack_size.window, in_chunk_size, out_chunk_size); | 1542 | in_ack_size.window, out_ack_size.window, in_chunk_size, out_chunk_size); |
| 1536 | } | 1543 | } |
| 1537 | if (pkt->event_type == SrcPCUCPingRequest) { | 1544 | if (pkt->event_type == SrcPCUCPingRequest) { |
| @@ -1594,6 +1601,9 @@ int SrsProtocol::on_send_packet(SrsMessageHeader* mh, SrsPacket* packet) | @@ -1594,6 +1601,9 @@ int SrsProtocol::on_send_packet(SrsMessageHeader* mh, SrsPacket* packet) | ||
| 1594 | } | 1601 | } |
| 1595 | break; | 1602 | break; |
| 1596 | } | 1603 | } |
| 1604 | + case RTMP_MSG_VideoMessage: | ||
| 1605 | + case RTMP_MSG_AudioMessage: | ||
| 1606 | + print_debug_info(); | ||
| 1597 | default: | 1607 | default: |
| 1598 | break; | 1608 | break; |
| 1599 | } | 1609 | } |
| @@ -1670,6 +1680,15 @@ int SrsProtocol::response_ping_message(int32_t timestamp) | @@ -1670,6 +1680,15 @@ int SrsProtocol::response_ping_message(int32_t timestamp) | ||
| 1670 | return ret; | 1680 | return ret; |
| 1671 | } | 1681 | } |
| 1672 | 1682 | ||
| 1683 | +void SrsProtocol::print_debug_info() | ||
| 1684 | +{ | ||
| 1685 | + if (show_debug_info) { | ||
| 1686 | + show_debug_info = false; | ||
| 1687 | + srs_trace("protocol in.buffer=%d, in.ack=%d, out.ack=%d, in.chunk=%d, out.chunk=%d", in_buffer_length, | ||
| 1688 | + in_ack_size.window, out_ack_size.window, in_chunk_size, out_chunk_size); | ||
| 1689 | + } | ||
| 1690 | +} | ||
| 1691 | + | ||
| 1673 | SrsChunkStream::SrsChunkStream(int _cid) | 1692 | SrsChunkStream::SrsChunkStream(int _cid) |
| 1674 | { | 1693 | { |
| 1675 | fmt = 0; | 1694 | fmt = 0; |
| @@ -235,6 +235,11 @@ private: | @@ -235,6 +235,11 @@ private: | ||
| 235 | AckWindowSize in_ack_size; | 235 | AckWindowSize in_ack_size; |
| 236 | // The output ack window, to require peer to response the ack. | 236 | // The output ack window, to require peer to response the ack. |
| 237 | AckWindowSize out_ack_size; | 237 | AckWindowSize out_ack_size; |
| 238 | + // The buffer length set by peer. | ||
| 239 | + int32_t in_buffer_length; | ||
| 240 | + // Whether print the protocol level debug info. | ||
| 241 | + // Generally we print the debug info when got or send first A/V packet. | ||
| 242 | + bool show_debug_info; | ||
| 238 | /** | 243 | /** |
| 239 | * whether auto response when recv messages. | 244 | * whether auto response when recv messages. |
| 240 | * default to true for it's very easy to use the protocol stack. | 245 | * default to true for it's very easy to use the protocol stack. |
| @@ -490,6 +495,8 @@ private: | @@ -490,6 +495,8 @@ private: | ||
| 490 | * auto response the ping message. | 495 | * auto response the ping message. |
| 491 | */ | 496 | */ |
| 492 | virtual int response_ping_message(int32_t timestamp); | 497 | virtual int response_ping_message(int32_t timestamp); |
| 498 | +private: | ||
| 499 | + virtual void print_debug_info(); | ||
| 493 | }; | 500 | }; |
| 494 | 501 | ||
| 495 | /** | 502 | /** |
-
请 注册 或 登录 后发表评论