提交 c6538783 authored 作者: José Luis Millán's avatar José Luis Millán

Producer: enhance mothod naming

上级 2f0935ba
...@@ -82,8 +82,9 @@ namespace RTC ...@@ -82,8 +82,9 @@ namespace RTC
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);
void AddActiveProfiles(RTC::RtpStreamRecv* rtpStream); void ActivateStreamProfiles(RTC::RtpStreamRecv* rtpStream);
void RemoveActiveProfiles(RTC::RtpStreamRecv* rtpStream); void DeactivateStreamProfiles(RTC::RtpStreamRecv* rtpStream);
bool IsStreamActive(const RTC::RtpStream* rtpStream) const;
/* Pure virtual methods inherited from RTC::RtpStreamRecv::Listener. */ /* Pure virtual methods inherited from RTC::RtpStreamRecv::Listener. */
public: public:
......
...@@ -544,7 +544,7 @@ namespace RTC ...@@ -544,7 +544,7 @@ namespace RTC
this->mapRtpStreamProfiles[rtpStream].insert(profile); this->mapRtpStreamProfiles[rtpStream].insert(profile);
// Add new profile/s into active profiles map and notify the listener. // Add new profile/s into active profiles map and notify the listener.
AddActiveProfiles(rtpStream); ActivateStreamProfiles(rtpStream);
// Request a key frame since we may have lost the first packets of this stream. // Request a key frame since we may have lost the first packets of this stream.
RequestKeyFrame(true); RequestKeyFrame(true);
...@@ -555,7 +555,7 @@ namespace RTC ...@@ -555,7 +555,7 @@ namespace RTC
MS_TRACE(); MS_TRACE();
// Remove the profiles related to this stream from active profiles map and notify the listener. // Remove the profiles related to this stream from active profiles map and notify the listener.
RemoveActiveProfiles(rtpStream); DeactivateStreamProfiles(rtpStream);
this->rtpStreams.erase(rtpStream->GetSsrc()); this->rtpStreams.erase(rtpStream->GetSsrc());
...@@ -662,7 +662,7 @@ namespace RTC ...@@ -662,7 +662,7 @@ namespace RTC
MS_THROW_ERROR("unknown RTP packet received [ssrc:%" PRIu32 "]", packet->GetSsrc()); MS_THROW_ERROR("unknown RTP packet received [ssrc:%" PRIu32 "]", packet->GetSsrc());
} }
void Producer::AddActiveProfiles(RTC::RtpStreamRecv* rtpStream) void Producer::ActivateStreamProfiles(RTC::RtpStreamRecv* rtpStream)
{ {
auto& profiles = this->mapRtpStreamProfiles[rtpStream]; auto& profiles = this->mapRtpStreamProfiles[rtpStream];
...@@ -683,7 +683,7 @@ namespace RTC ...@@ -683,7 +683,7 @@ namespace RTC
} }
} }
void Producer::RemoveActiveProfiles(RTC::RtpStreamRecv* rtpStream) void Producer::DeactivateStreamProfiles(RTC::RtpStreamRecv* rtpStream)
{ {
auto& profiles = this->mapRtpStreamProfiles[rtpStream]; auto& profiles = this->mapRtpStreamProfiles[rtpStream];
...@@ -704,6 +704,19 @@ namespace RTC ...@@ -704,6 +704,19 @@ namespace RTC
} }
} }
bool Producer::IsStreamActive(const RTC::RtpStream* rtpStream) const
{
for (auto it : this->mapActiveProfiles)
{
auto activeRtpStream = it.second;
if (activeRtpStream == rtpStream)
return true;
}
return false;
}
void Producer::OnRtpStreamRecvNackRequired( void Producer::OnRtpStreamRecvNackRequired(
RTC::RtpStreamRecv* rtpStream, const std::vector<uint16_t>& seqNumbers) RTC::RtpStreamRecv* rtpStream, const std::vector<uint16_t>& seqNumbers)
{ {
...@@ -802,27 +815,14 @@ namespace RTC ...@@ -802,27 +815,14 @@ namespace RTC
if (totalBitrate == 0) if (totalBitrate == 0)
return; return;
// Check whether the stream is already active. // Deactivate stream profiles if active.
const RtpStream* activeRtpStream = nullptr; if (IsStreamActive(rtpStream))
DeactivateStreamProfiles(rtpStreamRecv);
for (auto it : this->mapActiveProfiles)
{
activeRtpStream = it.second;
// Remove stream from the active profiles map.
if (activeRtpStream == rtpStream)
{
MS_DEBUG_TAG(rtp, "rtp inactivity detected [ssrc:%" PRIu32 "]", rtpStream->GetSsrc());
RemoveActiveProfiles(rtpStreamRecv); // Reset stream check timer on every stream whose profiles are active.
break;
}
}
// Reset stream check timer on every active stream.
for (auto it : this->mapActiveProfiles) for (auto it : this->mapActiveProfiles)
{ {
activeRtpStream = it.second; auto activeRtpStream = it.second;
auto ssrc = activeRtpStream->GetSsrc(); auto ssrc = activeRtpStream->GetSsrc();
this->rtpStreams[ssrc]->ResetStatusCheckTimer(RTC::RtpStream::StatusCheckPeriod * 2); this->rtpStreams[ssrc]->ResetStatusCheckTimer(RTC::RtpStream::StatusCheckPeriod * 2);
...@@ -839,21 +839,9 @@ namespace RTC ...@@ -839,21 +839,9 @@ namespace RTC
this->mapRtpStreamProfiles.find(rtpStreamRecv) != this->mapRtpStreamProfiles.end(), this->mapRtpStreamProfiles.find(rtpStreamRecv) != this->mapRtpStreamProfiles.end(),
"stream not present in mapRtpStreamProfiles"); "stream not present in mapRtpStreamProfiles");
// Check whether the stream is already active. if (!IsStreamActive(rtpStream))
const RtpStream* activeRtpStream = nullptr;
for (auto it : this->mapActiveProfiles)
{
activeRtpStream = it.second;
if (activeRtpStream != nullptr)
break;
}
// Add the profiles related to this stream into active profiles map and notify the listener.
if (!activeRtpStream)
{ {
AddActiveProfiles(rtpStreamRecv); ActivateStreamProfiles(rtpStreamRecv);
MS_DEBUG_TAG(rtp, "stream is now active [ssrc:%" PRIu32 "]", rtpStream->GetSsrc()); MS_DEBUG_TAG(rtp, "stream is now active [ssrc:%" PRIu32 "]", rtpStream->GetSsrc());
} }
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论