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

Delete stream on unhealthy

上级 f99f1f85
...@@ -89,6 +89,7 @@ namespace RTC ...@@ -89,6 +89,7 @@ namespace RTC
private: private:
void FillHeaderExtensionIds(); void FillHeaderExtensionIds();
void CreateRtpStream(RTC::RtpEncodingParameters& encoding); void CreateRtpStream(RTC::RtpEncodingParameters& encoding);
void ClearRtpStream(RTC::RtpStreamRecv* rtpStream);
void ClearRtpStreams(); void ClearRtpStreams();
void ApplyRtpMapping(RTC::RtpPacket* packet) const; void ApplyRtpMapping(RTC::RtpPacket* packet) const;
RTC::RtpEncodingParameters::Profile GetProfile(RTC::RtpStreamRecv* rtpStream, RTC::RtpPacket* packet); RTC::RtpEncodingParameters::Profile GetProfile(RTC::RtpStreamRecv* rtpStream, RTC::RtpPacket* packet);
......
...@@ -269,9 +269,7 @@ namespace RTC ...@@ -269,9 +269,7 @@ namespace RTC
for (auto& encoding : this->rtpParameters.encodings) for (auto& encoding : this->rtpParameters.encodings)
{ {
// TODO: This is not ready for RID usage (without SSRC in encodings). // TODO: This is not ready for RID usage (without SSRC in encodings).
if ( if (encoding.ssrc == ssrc)
encoding.ssrc == ssrc || (encoding.hasRtx && encoding.rtx.ssrc == ssrc) ||
(encoding.hasFec && encoding.fec.ssrc == ssrc))
{ {
CreateRtpStream(encoding); CreateRtpStream(encoding);
...@@ -494,10 +492,7 @@ namespace RTC ...@@ -494,10 +492,7 @@ namespace RTC
uint32_t ssrc = encoding.ssrc; uint32_t ssrc = encoding.ssrc;
// Don't create a RtpStreamRecv if there is already one for the same SSRC. MS_ASSERT(this->rtpStreams.find(ssrc) == this->rtpStreams.end(), "stream already exists");
// TODO: This may not work for SVC codecs.
if (this->rtpStreams.find(ssrc) != this->rtpStreams.end())
return;
// Get the codec of the stream/encoding. // Get the codec of the stream/encoding.
auto& codec = this->rtpParameters.GetCodecForEncoding(encoding); auto& codec = this->rtpParameters.GetCodecForEncoding(encoding);
...@@ -575,6 +570,45 @@ namespace RTC ...@@ -575,6 +570,45 @@ namespace RTC
} }
} }
void Producer::ClearRtpStream(RTC::RtpStreamRecv* rtpStream)
{
MS_TRACE();
auto& profiles = this->profiles[rtpStream];
// Notify about the profiles being disabled.
for (auto& profile : profiles)
{
// Don't announce default profile, but just those for simulcast/SVC.
if (profile == RTC::RtpEncodingParameters::Profile::DEFAULT)
break;
for (auto& listener : this->listeners)
{
listener->OnProducerProfileDisabled(this, profile);
}
}
this->rtpStreams.erase(rtpStream->GetSsrc());
for (auto& kv : this->mapRtxStreams)
{
auto rtxSsrc = kv.first;
auto* mediaStream = kv.second;
if (mediaStream == rtpStream)
{
this->mapRtxStreams.erase(rtxSsrc);
break;
}
}
this->profiles.erase(rtpStream);
delete rtpStream;
}
void Producer::ClearRtpStreams() void Producer::ClearRtpStreams()
{ {
MS_TRACE(); MS_TRACE();
...@@ -738,18 +772,8 @@ namespace RTC ...@@ -738,18 +772,8 @@ namespace RTC
{ {
MS_DEBUG_TAG(rtp, "stream is now unhealthy [ssrc:%" PRIu32 "]", rtpStream->GetSsrc()); MS_DEBUG_TAG(rtp, "stream is now unhealthy [ssrc:%" PRIu32 "]", rtpStream->GetSsrc());
// Notify about the profiles being disabled. // Completely destroy the stream.
for (auto& profile : profiles) ClearRtpStream(rtpStreamRecv);
{
// Don't announce default profile, but just those for simulcast/SVC.
if (profile == RTC::RtpEncodingParameters::Profile::DEFAULT)
break;
for (auto& listener : this->listeners)
{
listener->OnProducerProfileDisabled(this, profile);
}
}
} }
// The stream has transitioned to healthy. // The stream has transitioned to healthy.
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论