mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
RTC: Refine fast timer
This commit is contained in:
parent
92fc0af8f4
commit
25f17c32e9
5 changed files with 21 additions and 3 deletions
|
@ -535,6 +535,7 @@ srs_error_t SrsRtcPlayStream::start()
|
|||
}
|
||||
|
||||
// The timer for play, process TWCC in the future.
|
||||
// @see SrsRtcPlayStream::on_timer()
|
||||
_srs_hybrid->timer1s()->subscribe(this);
|
||||
|
||||
if ((err = pli_worker_->start()) != srs_success) {
|
||||
|
@ -1056,6 +1057,7 @@ srs_error_t SrsRtcPublishStream::start()
|
|||
}
|
||||
|
||||
// For publisher timer, such as TWCC and RR.
|
||||
// @see SrsRtcPublishStream::on_timer()
|
||||
_srs_hybrid->timer100ms()->subscribe(this);
|
||||
|
||||
if ((err = source->on_publish()) != srs_success) {
|
||||
|
@ -1716,6 +1718,8 @@ SrsRtcConnection::SrsRtcConnection(SrsRtcServer* s, const SrsContextId& cid)
|
|||
pp_address_change = new SrsErrorPithyPrint();
|
||||
pli_epp = new SrsErrorPithyPrint();
|
||||
|
||||
nack_enabled_ = false;
|
||||
|
||||
_srs_rtc_manager->subscribe(this);
|
||||
}
|
||||
|
||||
|
@ -1969,14 +1973,18 @@ srs_error_t SrsRtcConnection::initialize(SrsRequest* r, bool dtls, bool srtp, st
|
|||
}
|
||||
|
||||
// The RTC connection start a timer, handle nacks.
|
||||
// @see SrsRtcConnection::on_timer()
|
||||
_srs_hybrid->timer20ms()->subscribe(this);
|
||||
|
||||
// TODO: FIXME: Support reload.
|
||||
session_timeout = _srs_config->get_rtc_stun_timeout(req->vhost);
|
||||
last_stun_time = srs_get_system_time();
|
||||
|
||||
srs_trace("RTC init session, user=%s, url=%s, encrypt=%u/%u, DTLS(role=%s, version=%s), timeout=%dms", username.c_str(),
|
||||
r->get_stream_url().c_str(), dtls, srtp, cfg->dtls_role.c_str(), cfg->dtls_version.c_str(), srsu2msi(session_timeout));
|
||||
nack_enabled_ = _srs_config->get_rtc_nack_enabled(req->vhost);
|
||||
|
||||
srs_trace("RTC init session, user=%s, url=%s, encrypt=%u/%u, DTLS(role=%s, version=%s), timeout=%dms, nack=%d",
|
||||
username.c_str(), r->get_stream_url().c_str(), dtls, srtp, cfg->dtls_role.c_str(), cfg->dtls_version.c_str(),
|
||||
srsu2msi(session_timeout), nack_enabled_);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
@ -2347,6 +2355,10 @@ srs_error_t SrsRtcConnection::on_timer(srs_utime_t interval)
|
|||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
if (!nack_enabled_) {
|
||||
return err;
|
||||
}
|
||||
|
||||
++_srs_pps_conn->sugar;
|
||||
|
||||
// If circuit-breaker is enabled, disable nack.
|
||||
|
|
|
@ -454,6 +454,8 @@ private:
|
|||
SrsErrorPithyPrint* pp_address_change;
|
||||
// Pithy print for PLI request.
|
||||
SrsErrorPithyPrint* pli_epp;
|
||||
private:
|
||||
bool nack_enabled_;
|
||||
public:
|
||||
SrsRtcConnection(SrsRtcServer* s, const SrsContextId& cid);
|
||||
virtual ~SrsRtcConnection();
|
||||
|
|
|
@ -281,6 +281,7 @@ srs_error_t SrsRtcServer::initialize()
|
|||
srs_error_t err = srs_success;
|
||||
|
||||
// The RTC server start a timer, do routines of RTC server.
|
||||
// @see SrsRtcServer::on_timer()
|
||||
_srs_hybrid->timer5s()->subscribe(this);
|
||||
|
||||
// Initialize the black hole.
|
||||
|
|
|
@ -504,8 +504,10 @@ srs_error_t SrsRtcStream::on_publish()
|
|||
return srs_error_wrap(err, "bridger on publish");
|
||||
}
|
||||
|
||||
// For SrsRtcStream::on_timer()
|
||||
// The PLI interval for RTC2RTMP.
|
||||
pli_for_rtmp_ = _srs_config->get_rtc_pli_for_rtmp(req->vhost);
|
||||
|
||||
// @see SrsRtcStream::on_timer()
|
||||
_srs_hybrid->timer100ms()->subscribe(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ srs_error_t SrsCircuitBreaker::initialize()
|
|||
dying_pulse_ = _srs_config->get_dying_pulse();
|
||||
|
||||
// Update the water level for circuit breaker.
|
||||
// @see SrsCircuitBreaker::on_timer()
|
||||
_srs_hybrid->timer1s()->subscribe(this);
|
||||
|
||||
srs_trace("CircuitBreaker: enabled=%d, high=%dx%d, critical=%dx%d, dying=%dx%d", enabled_,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue