mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
RTC: Add timer for connection
This commit is contained in:
parent
d90d42e7bf
commit
3a13d8c380
2 changed files with 17 additions and 1 deletions
|
@ -1589,6 +1589,7 @@ SrsRtcConnection::SrsRtcConnection(SrsRtcServer* s, SrsContextId context_id)
|
||||||
encrypt = true;
|
encrypt = true;
|
||||||
cid = context_id;
|
cid = context_id;
|
||||||
stat_ = new SrsRtcConnectionStatistic();
|
stat_ = new SrsRtcConnectionStatistic();
|
||||||
|
timer_ = new SrsHourGlass(this, 1000 * SRS_UTIME_MILLISECONDS);
|
||||||
|
|
||||||
source_ = NULL;
|
source_ = NULL;
|
||||||
publisher_ = NULL;
|
publisher_ = NULL;
|
||||||
|
@ -1609,6 +1610,7 @@ SrsRtcConnection::SrsRtcConnection(SrsRtcServer* s, SrsContextId context_id)
|
||||||
|
|
||||||
SrsRtcConnection::~SrsRtcConnection()
|
SrsRtcConnection::~SrsRtcConnection()
|
||||||
{
|
{
|
||||||
|
srs_freep(timer_);
|
||||||
srs_freep(player_);
|
srs_freep(player_);
|
||||||
srs_freep(publisher_);
|
srs_freep(publisher_);
|
||||||
srs_freep(transport_);
|
srs_freep(transport_);
|
||||||
|
@ -1812,6 +1814,10 @@ srs_error_t SrsRtcConnection::initialize(SrsRtcStream* source, SrsRequest* r, bo
|
||||||
return srs_error_wrap(err, "init");
|
return srs_error_wrap(err, "init");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((err = timer_->start()) != srs_success) {
|
||||||
|
return srs_error_wrap(err, "start timer");
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: FIXME: Support reload.
|
// TODO: FIXME: Support reload.
|
||||||
session_timeout = _srs_config->get_rtc_stun_timeout(req->vhost);
|
session_timeout = _srs_config->get_rtc_stun_timeout(req->vhost);
|
||||||
last_stun_time = srs_get_system_time();
|
last_stun_time = srs_get_system_time();
|
||||||
|
@ -1988,6 +1994,12 @@ void SrsRtcConnection::update_sendonly_socket(SrsUdpMuxSocket* skt)
|
||||||
sendonly_skt = addr_cache;
|
sendonly_skt = addr_cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
srs_error_t SrsRtcConnection::notify(int type, srs_utime_t interval, srs_utime_t tick)
|
||||||
|
{
|
||||||
|
srs_error_t err = srs_success;
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
void SrsRtcConnection::check_send_nacks(SrsRtpNackForReceiver* nack, uint32_t ssrc, uint32_t& sent_nacks)
|
void SrsRtcConnection::check_send_nacks(SrsRtpNackForReceiver* nack, uint32_t ssrc, uint32_t& sent_nacks)
|
||||||
{
|
{
|
||||||
// If DTLS is not OK, drop all messages.
|
// If DTLS is not OK, drop all messages.
|
||||||
|
|
|
@ -309,7 +309,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
// A RTC Peer Connection, SDP level object.
|
// A RTC Peer Connection, SDP level object.
|
||||||
class SrsRtcConnection
|
class SrsRtcConnection : virtual public ISrsHourGlass
|
||||||
{
|
{
|
||||||
friend class SrsSecurityTransport;
|
friend class SrsSecurityTransport;
|
||||||
friend class SrsRtcPlayStream;
|
friend class SrsRtcPlayStream;
|
||||||
|
@ -324,6 +324,7 @@ private:
|
||||||
SrsRtcPlayStream* player_;
|
SrsRtcPlayStream* player_;
|
||||||
SrsRtcPublishStream* publisher_;
|
SrsRtcPublishStream* publisher_;
|
||||||
bool is_publisher_;
|
bool is_publisher_;
|
||||||
|
SrsHourGlass* timer_;
|
||||||
private:
|
private:
|
||||||
// The local:remote username, such as m5x0n128:jvOm where local name is m5x0n128.
|
// The local:remote username, such as m5x0n128:jvOm where local name is m5x0n128.
|
||||||
std::string username_;
|
std::string username_;
|
||||||
|
@ -394,6 +395,9 @@ public:
|
||||||
srs_error_t start_publish();
|
srs_error_t start_publish();
|
||||||
bool is_stun_timeout();
|
bool is_stun_timeout();
|
||||||
void update_sendonly_socket(SrsUdpMuxSocket* skt);
|
void update_sendonly_socket(SrsUdpMuxSocket* skt);
|
||||||
|
// interface ISrsHourGlass
|
||||||
|
public:
|
||||||
|
virtual srs_error_t notify(int type, srs_utime_t interval, srs_utime_t tick);
|
||||||
public:
|
public:
|
||||||
// send rtcp
|
// send rtcp
|
||||||
void check_send_nacks(SrsRtpNackForReceiver* nack, uint32_t ssrc, uint32_t& sent_nacks);
|
void check_send_nacks(SrsRtpNackForReceiver* nack, uint32_t ssrc, uint32_t& sent_nacks);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue