mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
RTC: Pithy print the address change
This commit is contained in:
parent
a035d312f9
commit
5f7d1e2c5b
4 changed files with 20 additions and 8 deletions
|
@ -125,7 +125,11 @@ SrsErrorPithyPrint::~SrsErrorPithyPrint()
|
||||||
bool SrsErrorPithyPrint::can_print(srs_error_t err)
|
bool SrsErrorPithyPrint::can_print(srs_error_t err)
|
||||||
{
|
{
|
||||||
int error_code = srs_error_code(err);
|
int error_code = srs_error_code(err);
|
||||||
|
return can_print(error_code);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SrsErrorPithyPrint::can_print(int error_code)
|
||||||
|
{
|
||||||
bool new_stage = false;
|
bool new_stage = false;
|
||||||
SrsStageInfo* stage = stages.fetch_or_create(error_code, &new_stage);
|
SrsStageInfo* stage = stages.fetch_or_create(error_code, &new_stage);
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,8 @@ public:
|
||||||
public:
|
public:
|
||||||
// Whether specified stage is ready for print.
|
// Whether specified stage is ready for print.
|
||||||
bool can_print(srs_error_t err);
|
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,
|
// The stage is used for a collection of object to do print,
|
||||||
|
|
|
@ -1580,6 +1580,7 @@ SrsRtcConnection::SrsRtcConnection(SrsRtcServer* s, SrsContextId context_id)
|
||||||
|
|
||||||
twcc_id_ = 0;
|
twcc_id_ = 0;
|
||||||
nn_simulate_player_nack_drop = 0;
|
nn_simulate_player_nack_drop = 0;
|
||||||
|
pp_address_change = new SrsErrorPithyPrint();
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsRtcConnection::~SrsRtcConnection()
|
SrsRtcConnection::~SrsRtcConnection()
|
||||||
|
@ -1597,6 +1598,8 @@ SrsRtcConnection::~SrsRtcConnection()
|
||||||
SrsUdpMuxSocket* addr = it->second;
|
SrsUdpMuxSocket* addr = it->second;
|
||||||
srs_freep(addr);
|
srs_freep(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
srs_freep(pp_address_change);
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsSdp* SrsRtcConnection::get_local_sdp()
|
SrsSdp* SrsRtcConnection::get_local_sdp()
|
||||||
|
@ -1934,14 +1937,6 @@ void SrsRtcConnection::update_sendonly_socket(SrsUdpMuxSocket* skt)
|
||||||
return;
|
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.
|
// Find object from cache.
|
||||||
SrsUdpMuxSocket* addr_cache = NULL;
|
SrsUdpMuxSocket* addr_cache = NULL;
|
||||||
if (true) {
|
if (true) {
|
||||||
|
@ -1957,6 +1952,14 @@ void SrsRtcConnection::update_sendonly_socket(SrsUdpMuxSocket* skt)
|
||||||
server_->insert_into_id_sessions(peer_id, this);
|
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.
|
// Update the transport.
|
||||||
sendonly_skt = addr_cache;
|
sendonly_skt = addr_cache;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,7 @@ class SrsRtpRingBuffer;
|
||||||
class SrsRtcConsumer;
|
class SrsRtcConsumer;
|
||||||
class SrsRtcAudioSendTrack;
|
class SrsRtcAudioSendTrack;
|
||||||
class SrsRtcVideoSendTrack;
|
class SrsRtcVideoSendTrack;
|
||||||
|
class SrsErrorPithyPrint;
|
||||||
|
|
||||||
const uint8_t kSR = 200;
|
const uint8_t kSR = 200;
|
||||||
const uint8_t kRR = 201;
|
const uint8_t kRR = 201;
|
||||||
|
@ -347,6 +348,8 @@ private:
|
||||||
int twcc_id_;
|
int twcc_id_;
|
||||||
// Simulators.
|
// Simulators.
|
||||||
int nn_simulate_player_nack_drop;
|
int nn_simulate_player_nack_drop;
|
||||||
|
// Pithy print for address change, use port as error code.
|
||||||
|
SrsErrorPithyPrint* pp_address_change;
|
||||||
public:
|
public:
|
||||||
SrsRtcConnection(SrsRtcServer* s, SrsContextId context_id);
|
SrsRtcConnection(SrsRtcServer* s, SrsContextId context_id);
|
||||||
virtual ~SrsRtcConnection();
|
virtual ~SrsRtcConnection();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue