mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
RTC: Set to alive when got any packet
This commit is contained in:
parent
8bf677e3c8
commit
7c682a99c9
3 changed files with 16 additions and 5 deletions
|
@ -1912,8 +1912,6 @@ srs_error_t SrsRtcConnection::on_stun(SrsUdpMuxSocket* skt, SrsStunPacket* r)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
last_stun_time = srs_get_system_time();
|
|
||||||
|
|
||||||
// We are running in the ice-lite(server) mode. If client have multi network interface,
|
// We are running in the ice-lite(server) mode. If client have multi network interface,
|
||||||
// we only choose one candidate pair which is determined by client.
|
// we only choose one candidate pair which is determined by client.
|
||||||
update_sendonly_socket(skt);
|
update_sendonly_socket(skt);
|
||||||
|
@ -2203,11 +2201,16 @@ srs_error_t SrsRtcConnection::start_publish(std::string stream_uri)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SrsRtcConnection::is_stun_timeout()
|
bool SrsRtcConnection::is_alive()
|
||||||
{
|
{
|
||||||
return last_stun_time + session_timeout < srs_get_system_time();
|
return last_stun_time + session_timeout < srs_get_system_time();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SrsRtcConnection::alive()
|
||||||
|
{
|
||||||
|
last_stun_time = srs_get_system_time();
|
||||||
|
}
|
||||||
|
|
||||||
void SrsRtcConnection::update_sendonly_socket(SrsUdpMuxSocket* skt)
|
void SrsRtcConnection::update_sendonly_socket(SrsUdpMuxSocket* skt)
|
||||||
{
|
{
|
||||||
// TODO: FIXME: Refine performance.
|
// TODO: FIXME: Refine performance.
|
||||||
|
|
|
@ -449,8 +449,10 @@ private:
|
||||||
// The address list, client may use multiple addresses.
|
// The address list, client may use multiple addresses.
|
||||||
std::map<std::string, SrsUdpMuxSocket*> peer_addresses_;
|
std::map<std::string, SrsUdpMuxSocket*> peer_addresses_;
|
||||||
private:
|
private:
|
||||||
|
// TODO: FIXME: Rename it.
|
||||||
// The timeout of session, keep alive by STUN ping pong.
|
// The timeout of session, keep alive by STUN ping pong.
|
||||||
srs_utime_t session_timeout;
|
srs_utime_t session_timeout;
|
||||||
|
// TODO: FIXME: Rename it.
|
||||||
srs_utime_t last_stun_time;
|
srs_utime_t last_stun_time;
|
||||||
private:
|
private:
|
||||||
// For each RTC session, we use a specified cid for debugging logs.
|
// For each RTC session, we use a specified cid for debugging logs.
|
||||||
|
@ -521,7 +523,8 @@ public:
|
||||||
srs_error_t on_dtls_alert(std::string type, std::string desc);
|
srs_error_t on_dtls_alert(std::string type, std::string desc);
|
||||||
srs_error_t start_play(std::string stream_uri);
|
srs_error_t start_play(std::string stream_uri);
|
||||||
srs_error_t start_publish(std::string stream_uri);
|
srs_error_t start_publish(std::string stream_uri);
|
||||||
bool is_stun_timeout();
|
bool is_alive();
|
||||||
|
void alive();
|
||||||
void update_sendonly_socket(SrsUdpMuxSocket* skt);
|
void update_sendonly_socket(SrsUdpMuxSocket* skt);
|
||||||
// interface ISrsHourGlass
|
// interface ISrsHourGlass
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -312,6 +312,11 @@ srs_error_t SrsRtcServer::on_udp_packet(SrsUdpMuxSocket* skt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When got any packet, the session is alive now.
|
||||||
|
if (session) {
|
||||||
|
session->alive();
|
||||||
|
}
|
||||||
|
|
||||||
// Notify hijack to handle the UDP packet.
|
// Notify hijack to handle the UDP packet.
|
||||||
if (hijacker) {
|
if (hijacker) {
|
||||||
bool consumed = false;
|
bool consumed = false;
|
||||||
|
@ -586,7 +591,7 @@ srs_error_t SrsRtcServer::notify(int type, srs_utime_t interval, srs_utime_t tic
|
||||||
// Check all sessions and dispose the dead sessions.
|
// Check all sessions and dispose the dead sessions.
|
||||||
for (int i = 0; i < (int)_srs_rtc_manager->size(); i++) {
|
for (int i = 0; i < (int)_srs_rtc_manager->size(); i++) {
|
||||||
SrsRtcConnection* session = dynamic_cast<SrsRtcConnection*>(_srs_rtc_manager->at(i));
|
SrsRtcConnection* session = dynamic_cast<SrsRtcConnection*>(_srs_rtc_manager->at(i));
|
||||||
if (!session || !session->is_stun_timeout() || session->disposing_) {
|
if (!session || !session->is_alive() || session->disposing_) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue