diff --git a/trunk/src/app/srs_app_pithy_print.cpp b/trunk/src/app/srs_app_pithy_print.cpp index 9494c13e9..e3f9e7e89 100644 --- a/trunk/src/app/srs_app_pithy_print.cpp +++ b/trunk/src/app/srs_app_pithy_print.cpp @@ -125,7 +125,11 @@ SrsErrorPithyPrint::~SrsErrorPithyPrint() bool SrsErrorPithyPrint::can_print(srs_error_t err) { int error_code = srs_error_code(err); + return can_print(error_code); +} +bool SrsErrorPithyPrint::can_print(int error_code) +{ bool new_stage = false; SrsStageInfo* stage = stages.fetch_or_create(error_code, &new_stage); diff --git a/trunk/src/app/srs_app_pithy_print.hpp b/trunk/src/app/srs_app_pithy_print.hpp index ac985fdb5..cabd6d7ff 100644 --- a/trunk/src/app/srs_app_pithy_print.hpp +++ b/trunk/src/app/srs_app_pithy_print.hpp @@ -77,6 +77,8 @@ public: public: // Whether specified stage is ready for print. bool can_print(srs_error_t err); + // We also support int error code. + bool can_print(int err); }; // 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 093394d2c..9291f5346 100644 --- a/trunk/src/app/srs_app_rtc_conn.cpp +++ b/trunk/src/app/srs_app_rtc_conn.cpp @@ -1580,6 +1580,7 @@ SrsRtcConnection::SrsRtcConnection(SrsRtcServer* s, SrsContextId context_id) twcc_id_ = 0; nn_simulate_player_nack_drop = 0; + pp_address_change = new SrsErrorPithyPrint(); } SrsRtcConnection::~SrsRtcConnection() @@ -1597,6 +1598,8 @@ SrsRtcConnection::~SrsRtcConnection() SrsUdpMuxSocket* addr = it->second; srs_freep(addr); } + + srs_freep(pp_address_change); } SrsSdp* SrsRtcConnection::get_local_sdp() @@ -1934,14 +1937,6 @@ void SrsRtcConnection::update_sendonly_socket(SrsUdpMuxSocket* skt) return; } - // Detect address change. - if (prev_peer_id.empty()) { - srs_trace("RTC: session address init %s", peer_id.c_str()); - } else { - srs_trace("RTC: session address changed, update %s -> %s, total %u", prev_peer_id.c_str(), - peer_id.c_str(), peer_addresses_.size()); - } - // Find object from cache. SrsUdpMuxSocket* addr_cache = NULL; if (true) { @@ -1957,6 +1952,14 @@ void SrsRtcConnection::update_sendonly_socket(SrsUdpMuxSocket* skt) server_->insert_into_id_sessions(peer_id, this); } + // Detect address change. + 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 changed, update %s -> %s, cached=%d, total=%u", prev_peer_id.c_str(), + peer_id.c_str(), (addr_cache? 1:0), peer_addresses_.size()); + } + // Update the transport. sendonly_skt = addr_cache; } diff --git a/trunk/src/app/srs_app_rtc_conn.hpp b/trunk/src/app/srs_app_rtc_conn.hpp index 6745d5bf7..0a5820dca 100644 --- a/trunk/src/app/srs_app_rtc_conn.hpp +++ b/trunk/src/app/srs_app_rtc_conn.hpp @@ -59,6 +59,7 @@ class SrsRtpRingBuffer; class SrsRtcConsumer; class SrsRtcAudioSendTrack; class SrsRtcVideoSendTrack; +class SrsErrorPithyPrint; const uint8_t kSR = 200; const uint8_t kRR = 201; @@ -347,6 +348,8 @@ private: int twcc_id_; // Simulators. int nn_simulate_player_nack_drop; + // Pithy print for address change, use port as error code. + SrsErrorPithyPrint* pp_address_change; public: SrsRtcConnection(SrsRtcServer* s, SrsContextId context_id); virtual ~SrsRtcConnection();