提交 19e013e1 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

worker: Pause status check timers in RtpStream when its Consumer is paused

上级 97c7f8b7
......@@ -37,7 +37,8 @@ namespace RTC
uint8_t GetPayloadType() const;
const RTC::RtpCodecMimeType& GetMimeType() const;
float GetLossPercentage() const;
void ResetStatusCheckTimer();
void RestartStatusCheckTimer();
void StopStatusCheckTimer();
protected:
bool UpdateSeq(RTC::RtpPacket* packet);
......
......@@ -29,6 +29,7 @@ public:
void Start(uint64_t timeout, uint64_t repeat = 0);
void Stop();
void Reset();
void Restart();
bool IsActive() const;
/* Callbacks fired by UV events. */
......@@ -40,6 +41,9 @@ private:
Listener* listener{ nullptr };
// Allocated by this.
uv_timer_t* uvHandle{ nullptr };
// Others.
uint64_t timeout{ 0 };
uint64_t repeat{ 0 };
};
/* Inline methods. */
......
......@@ -164,6 +164,7 @@ namespace RTC
if (IsEnabled() && !this->sourcePaused)
{
this->rtpStream->StopStatusCheckTimer();
this->rtpStream->ClearRetransmissionBuffer();
this->rtpPacketsBeforeProbation = RtpPacketsBeforeProbation;
......@@ -188,6 +189,8 @@ namespace RTC
if (IsEnabled() && !this->sourcePaused)
{
this->rtpStream->RestartStatusCheckTimer();
// We need to sync and wait for a key frame. Otherwise the receiver will
// request lot of NACKs due to unknown RTP packets.
this->syncRequired = true;
......@@ -211,6 +214,7 @@ namespace RTC
if (IsEnabled() && !this->paused)
{
this->rtpStream->StopStatusCheckTimer();
this->rtpStream->ClearRetransmissionBuffer();
this->rtpPacketsBeforeProbation = RtpPacketsBeforeProbation;
......@@ -237,6 +241,8 @@ namespace RTC
if (IsEnabled() && !this->paused)
{
this->rtpStream->RestartStatusCheckTimer();
// We need to sync. However we don't need to request a key frame since the source
// (Producer) already requested it.
this->syncRequired = true;
......@@ -306,8 +312,9 @@ namespace RTC
this->isProbing = false;
this->probingProfile = RtpEncodingParameters::Profile::NONE;
// Reset the health check timer so this probation doesn't affect the effective profile.
this->rtpStream->ResetStatusCheckTimer();
// Restart the health check timer so this probation doesn't affect the effective
// profile.
this->rtpStream->RestartStatusCheckTimer();
return;
}
......@@ -795,7 +802,7 @@ namespace RTC
RequestKeyFrame();
// We want to be notified about this new profile's health.
this->rtpStream->ResetStatusCheckTimer();
this->rtpStream->RestartStatusCheckTimer();
MS_DEBUG_TAG(
rtp,
......@@ -1017,7 +1024,7 @@ namespace RTC
{
this->isProbing = true;
this->probingProfile = newTargetProfile;
this->rtpStream->ResetStatusCheckTimer();
this->rtpStream->RestartStatusCheckTimer();
MS_DEBUG_TAG(
rtp,
......
......@@ -146,11 +146,16 @@ namespace RTC
return this->transmissionCounter.GetRate(now);
}
void RtpStream::ResetStatusCheckTimer()
void RtpStream::RestartStatusCheckTimer()
{
// Notify about status on next check.
this->notifyStatus = true;
this->statusCheckTimer->Reset();
this->statusCheckTimer->Restart();
}
void RtpStream::StopStatusCheckTimer()
{
this->statusCheckTimer->Stop();
}
void RtpStream::InitSeq(uint16_t seq)
......
......@@ -53,6 +53,9 @@ void Timer::Start(uint64_t timeout, uint64_t repeat)
{
MS_TRACE();
this->timeout = timeout;
this->repeat = repeat;
int err;
if (uv_is_active(reinterpret_cast<uv_handle_t*>(this->uvHandle)) != 0)
......@@ -83,12 +86,25 @@ void Timer::Reset()
if (uv_is_active(reinterpret_cast<uv_handle_t*>(this->uvHandle)) == 0)
return;
auto repeat = uv_timer_get_repeat(this->uvHandle);
if (repeat == 0u)
if (this->repeat == 0u)
return;
err = uv_timer_start(this->uvHandle, static_cast<uv_timer_cb>(onTimer), repeat, repeat);
err = uv_timer_start(this->uvHandle, static_cast<uv_timer_cb>(onTimer), this->repeat, this->repeat);
if (err != 0)
MS_THROW_ERROR("uv_timer_start() failed: %s", uv_strerror(err));
}
void Timer::Restart()
{
MS_TRACE();
int err;
if (uv_is_active(reinterpret_cast<uv_handle_t*>(this->uvHandle)) != 0)
Stop();
err =
uv_timer_start(this->uvHandle, static_cast<uv_timer_cb>(onTimer), this->timeout, this->repeat);
if (err != 0)
MS_THROW_ERROR("uv_timer_start() failed: %s", uv_strerror(err));
}
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论