RTC: Refine TWCC from 200ms to 50ms

pull/2128/head
jinxue.cgh 4 years ago committed by winlin
parent ec212b7413
commit 7f081b4178

@ -38,6 +38,7 @@
#define TAG_DTLS_ALERT "DTLS_ALERT"
#define TAG_DTLS_HANG "DTLS_HANG"
#define TAG_RESOURCE_UNSUB "RESOURCE_UNSUB"
#define TAG_LARGE_TIMER "LARGE_TIMER"
// Use memory/disk cache and donot flush when write log.
// it's ok to use it without config, which will log to console, and default trace level.

@ -59,6 +59,7 @@ using namespace std;
#include <srs_protocol_utility.hpp>
#define SRS_TICKID_RTCP 0
#define SRS_TICKID_TWCC 2
ISrsRtcTransport::ISrsRtcTransport()
{
@ -908,7 +909,7 @@ srs_error_t SrsRtcPlayStream::do_request_keyframe(uint32_t ssrc, SrsContextId ci
SrsRtcPublishStream::SrsRtcPublishStream(SrsRtcConnection* session, const SrsContextId& cid)
{
timer_ = new SrsHourGlass(this, 200 * SRS_UTIME_MILLISECONDS);
timer_ = new SrsHourGlass(this, 10 * SRS_UTIME_MILLISECONDS);
cid_ = cid;
is_started = false;
@ -927,6 +928,7 @@ SrsRtcPublishStream::SrsRtcPublishStream(SrsRtcConnection* session, const SrsCon
twcc_fb_count_ = 0;
pli_worker_ = new SrsRtcPLIWorker(this);
last_time_send_twcc_ = 0;
}
SrsRtcPublishStream::~SrsRtcPublishStream()
@ -1000,6 +1002,10 @@ srs_error_t SrsRtcPublishStream::start()
return err;
}
if ((err = timer_->tick(SRS_TICKID_TWCC, 50 * SRS_UTIME_MILLISECONDS)) != srs_success) {
return srs_error_wrap(err, "twcc tick");
}
if ((err = timer_->tick(SRS_TICKID_RTCP, 200 * SRS_UTIME_MILLISECONDS)) != srs_success) {
return srs_error_wrap(err, "rtcp tick");
}
@ -1297,6 +1303,14 @@ srs_error_t SrsRtcPublishStream::send_periodic_twcc()
{
srs_error_t err = srs_success;
if (last_time_send_twcc_) {
srs_utime_t duration = srs_duration(last_time_send_twcc_, srs_get_system_time());
if (duration > 80 * SRS_UTIME_MILLISECONDS) {
srs_warn2(TAG_LARGE_TIMER, "send_twcc interval exceeded %dms > 100ms", srsu2msi(duration));
}
}
last_time_send_twcc_ = srs_get_system_time();
if (!rtcp_twcc_.need_feedback()) {
return err;
}
@ -1457,7 +1471,9 @@ srs_error_t SrsRtcPublishStream::notify(int type, srs_utime_t interval, srs_utim
srs_warn("XR err %s", srs_error_desc(err).c_str());
srs_freep(err);
}
}
if (type == SRS_TICKID_TWCC) {
// We should not depends on the received packet,
// instead we should send feedback every Nms.
if ((err = send_periodic_twcc()) != srs_success) {

@ -341,6 +341,7 @@ private:
SrsRtcpTWCC rtcp_twcc_;
SrsRtpExtensionTypes extension_types_;
bool is_started;
srs_utime_t last_time_send_twcc_;
public:
SrsRtcPublishStream(SrsRtcConnection* session, const SrsContextId& cid);
virtual ~SrsRtcPublishStream();

Loading…
Cancel
Save