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