RTC: Add timer for connection

pull/1895/head
winlin 5 years ago
parent d90d42e7bf
commit 3a13d8c380

@ -1589,6 +1589,7 @@ SrsRtcConnection::SrsRtcConnection(SrsRtcServer* s, SrsContextId context_id)
encrypt = true;
cid = context_id;
stat_ = new SrsRtcConnectionStatistic();
timer_ = new SrsHourGlass(this, 1000 * SRS_UTIME_MILLISECONDS);
source_ = NULL;
publisher_ = NULL;
@ -1609,6 +1610,7 @@ SrsRtcConnection::SrsRtcConnection(SrsRtcServer* s, SrsContextId context_id)
SrsRtcConnection::~SrsRtcConnection()
{
srs_freep(timer_);
srs_freep(player_);
srs_freep(publisher_);
srs_freep(transport_);
@ -1812,6 +1814,10 @@ srs_error_t SrsRtcConnection::initialize(SrsRtcStream* source, SrsRequest* r, bo
return srs_error_wrap(err, "init");
}
if ((err = timer_->start()) != srs_success) {
return srs_error_wrap(err, "start timer");
}
// TODO: FIXME: Support reload.
session_timeout = _srs_config->get_rtc_stun_timeout(req->vhost);
last_stun_time = srs_get_system_time();
@ -1988,6 +1994,12 @@ void SrsRtcConnection::update_sendonly_socket(SrsUdpMuxSocket* skt)
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)
{
// If DTLS is not OK, drop all messages.

@ -309,7 +309,7 @@ public:
};
// A RTC Peer Connection, SDP level object.
class SrsRtcConnection
class SrsRtcConnection : virtual public ISrsHourGlass
{
friend class SrsSecurityTransport;
friend class SrsRtcPlayStream;
@ -324,6 +324,7 @@ private:
SrsRtcPlayStream* player_;
SrsRtcPublishStream* publisher_;
bool is_publisher_;
SrsHourGlass* timer_;
private:
// The local:remote username, such as m5x0n128:jvOm where local name is m5x0n128.
std::string username_;
@ -394,6 +395,9 @@ public:
srs_error_t start_publish();
bool is_stun_timeout();
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:
// send rtcp
void check_send_nacks(SrsRtpNackForReceiver* nack, uint32_t ssrc, uint32_t& sent_nacks);

Loading…
Cancel
Save