diff --git a/trunk/src/app/srs_app_listener.cpp b/trunk/src/app/srs_app_listener.cpp index d55ca775e..cd847fa36 100755 --- a/trunk/src/app/srs_app_listener.cpp +++ b/trunk/src/app/srs_app_listener.cpp @@ -542,10 +542,11 @@ srs_error_t SrsUdpMuxListener::cycle() } // Use pithy print to show more smart information. if (err != srs_success) { - if (pp_pkt_handler_err->can_print(err)) { + uint32_t nn = 0; + if (pp_pkt_handler_err->can_print(err, &nn)) { // Append more information. err = srs_error_wrap(err, "size=%u, data=[%s]", skt.size(), srs_string_dumps_hex(skt.data(), skt.size(), 8).c_str()); - srs_warn("handle udp pkt, count=%u, err: %s", pp_pkt_handler_err->nn_count, srs_error_desc(err).c_str()); + srs_warn("handle udp pkt, count=%u/%u, err: %s", pp_pkt_handler_err->nn_count, nn, srs_error_desc(err).c_str()); } srs_freep(err); } diff --git a/trunk/src/app/srs_app_pithy_print.cpp b/trunk/src/app/srs_app_pithy_print.cpp index 3f5ca5fc8..3b53891b9 100644 --- a/trunk/src/app/srs_app_pithy_print.cpp +++ b/trunk/src/app/srs_app_pithy_print.cpp @@ -36,6 +36,7 @@ SrsStageInfo::SrsStageInfo(int _stage_id) stage_id = _stage_id; nb_clients = 0; age = 0; + nn_count = 0; update_print_time(); @@ -123,19 +124,25 @@ SrsErrorPithyPrint::~SrsErrorPithyPrint() { } -bool SrsErrorPithyPrint::can_print(srs_error_t err) +bool SrsErrorPithyPrint::can_print(srs_error_t err, uint32_t* pnn) { int error_code = srs_error_code(err); - return can_print(error_code); + return can_print(error_code, pnn); } -bool SrsErrorPithyPrint::can_print(int error_code) +bool SrsErrorPithyPrint::can_print(int error_code, uint32_t* pnn) { - nn_count++; - bool new_stage = false; SrsStageInfo* stage = stages.fetch_or_create(error_code, &new_stage); + // Increase the count. + stage->nn_count++; + nn_count++; + + if (pnn) { + *pnn = stage->nn_count; + } + // Always and only one client. if (new_stage) { stage->nb_clients = 1; diff --git a/trunk/src/app/srs_app_pithy_print.hpp b/trunk/src/app/srs_app_pithy_print.hpp index 970810340..c88478c0b 100644 --- a/trunk/src/app/srs_app_pithy_print.hpp +++ b/trunk/src/app/srs_app_pithy_print.hpp @@ -37,6 +37,8 @@ public: int stage_id; srs_utime_t interval; int nb_clients; + // The number of call of can_print(). + uint32_t nn_count; public: srs_utime_t age; public: @@ -79,9 +81,9 @@ public: virtual ~SrsErrorPithyPrint(); public: // Whether specified stage is ready for print. - bool can_print(srs_error_t err); + bool can_print(srs_error_t err, uint32_t* pnn = NULL); // We also support int error code. - bool can_print(int err); + bool can_print(int err, uint32_t* pnn = NULL); }; // The stage is used for a collection of object to do print, diff --git a/trunk/src/app/srs_app_rtc_conn.cpp b/trunk/src/app/srs_app_rtc_conn.cpp index cdca35c41..4c8776b8e 100644 --- a/trunk/src/app/srs_app_rtc_conn.cpp +++ b/trunk/src/app/srs_app_rtc_conn.cpp @@ -501,8 +501,9 @@ srs_error_t SrsRtcPlayStream::cycle() // Send-out all RTP packets and do cleanup if (true) { if ((err = send_packets(source, pkts, info)) != srs_success) { - if (epp->can_print(err)) { - srs_warn("play send packets=%u, nn=%u, err: %s", pkts.size(), epp->nn_count, srs_error_desc(err).c_str()); + uint32_t nn = 0; + if (epp->can_print(err, &nn)) { + srs_warn("play send packets=%u, nn=%u/%u, err: %s", pkts.size(), epp->nn_count, nn, srs_error_desc(err).c_str()); } srs_freep(err); } @@ -1986,9 +1987,12 @@ void SrsRtcConnection::update_sendonly_socket(SrsUdpMuxSocket* skt) // Show address change log. if (prev_peer_id.empty()) { srs_trace("RTC: session address init %s", peer_id.c_str()); - } else if (pp_address_change->can_print(skt->get_peer_port())) { - srs_trace("RTC: session address change %s -> %s, cached=%d, nn_change=%u, nn_address=%u", prev_peer_id.c_str(), - peer_id.c_str(), (addr_cache? 1:0), pp_address_change->nn_count, peer_addresses_.size()); + } else { + uint32_t nn = 0; + if (pp_address_change->can_print(skt->get_peer_port(), &nn)) { + srs_trace("RTC: session address change %s -> %s, cached=%d, nn_change=%u/%u, nn_address=%u", prev_peer_id.c_str(), + peer_id.c_str(), (addr_cache? 1:0), pp_address_change->nn_count, nn, peer_addresses_.size()); + } } // If no cache, build cache and setup the relations in connection.