1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-15 04:42:04 +00:00

RTC: Pithy print the address change

This commit is contained in:
winlin 2020-07-27 12:28:15 +08:00
parent a035d312f9
commit 5f7d1e2c5b
4 changed files with 20 additions and 8 deletions

View file

@ -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);

View file

@ -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,

View file

@ -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;
}

View file

@ -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();