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

Consider intermediate profiles

上级 375c1498
...@@ -62,7 +62,7 @@ namespace RTC ...@@ -62,7 +62,7 @@ namespace RTC
void FillSupportedCodecPayloadTypes(); void FillSupportedCodecPayloadTypes();
void CreateRtpStream(RTC::RtpEncodingParameters& encoding); void CreateRtpStream(RTC::RtpEncodingParameters& encoding);
void RetransmitRtpPacket(RTC::RtpPacket* packet); void RetransmitRtpPacket(RTC::RtpPacket* packet);
void RecalculateEffectiveProfile(); void RecalculateTargetProfile();
void SetEffectiveProfile(RTC::RtpEncodingParameters::Profile profile); void SetEffectiveProfile(RTC::RtpEncodingParameters::Profile profile);
/* Pure virtual methods inherited from RTC::RtpStream::Listener. */ /* Pure virtual methods inherited from RTC::RtpStream::Listener. */
...@@ -105,6 +105,7 @@ namespace RTC ...@@ -105,6 +105,7 @@ namespace RTC
// RTP profiles. // RTP profiles.
std::set<RTC::RtpEncodingParameters::Profile> profiles; std::set<RTC::RtpEncodingParameters::Profile> profiles;
RTC::RtpEncodingParameters::Profile preferredProfile{ RTC::RtpEncodingParameters::Profile::DEFAULT }; RTC::RtpEncodingParameters::Profile preferredProfile{ RTC::RtpEncodingParameters::Profile::DEFAULT };
RTC::RtpEncodingParameters::Profile targetProfile{ RTC::RtpEncodingParameters::Profile::DEFAULT };
RTC::RtpEncodingParameters::Profile effectiveProfile{ RTC::RtpEncodingParameters::Profile::DEFAULT }; RTC::RtpEncodingParameters::Profile effectiveProfile{ RTC::RtpEncodingParameters::Profile::DEFAULT };
}; };
......
...@@ -241,7 +241,7 @@ namespace RTC ...@@ -241,7 +241,7 @@ namespace RTC
rtp, "profile added [profile:%s]", RTC::RtpEncodingParameters::profile2String[profile].c_str()); rtp, "profile added [profile:%s]", RTC::RtpEncodingParameters::profile2String[profile].c_str());
; ;
RecalculateEffectiveProfile(); RecalculateTargetProfile();
} }
void Consumer::RemoveProfile(const RTC::RtpEncodingParameters::Profile profile) void Consumer::RemoveProfile(const RTC::RtpEncodingParameters::Profile profile)
...@@ -262,7 +262,7 @@ namespace RTC ...@@ -262,7 +262,7 @@ namespace RTC
RTC::RtpEncodingParameters::profile2String[profile].c_str()); RTC::RtpEncodingParameters::profile2String[profile].c_str());
; ;
RecalculateEffectiveProfile(); RecalculateTargetProfile();
} }
void Consumer::SetPreferredProfile(const RTC::RtpEncodingParameters::Profile profile) void Consumer::SetPreferredProfile(const RTC::RtpEncodingParameters::Profile profile)
...@@ -280,7 +280,7 @@ namespace RTC ...@@ -280,7 +280,7 @@ namespace RTC
RTC::RtpEncodingParameters::profile2String[profile].c_str()); RTC::RtpEncodingParameters::profile2String[profile].c_str());
; ;
RecalculateEffectiveProfile(); RecalculateTargetProfile();
} }
/** /**
...@@ -335,19 +335,32 @@ namespace RTC ...@@ -335,19 +335,32 @@ namespace RTC
// Check whether this is the key frame we are waiting for in order to update the effective // Check whether this is the key frame we are waiting for in order to update the effective
// profile. // profile.
if ( if (this->effectiveProfile != this->targetProfile && profile == this->targetProfile)
this->effectiveProfile != this->preferredProfile && profile == this->preferredProfile &&
Codecs::isKeyFrame(this->rtpStream->GetMymeType(), packet))
{ {
MS_DEBUG_TAG(rtp, "changing effective profile after receiving a key frame"); bool isKeyFrame = false;
this->syncRequired = true; if (Codecs::isKnown(this->rtpStream->GetMymeType()) &&
this->rtpStream->ClearRetransmissionBuffer(); Codecs::isKeyFrame(this->rtpStream->GetMymeType(), packet))
{
isKeyFrame = true;
MS_DEBUG_TAG(rtp, "key frame received [profile:%s]",
RTC::RtpEncodingParameters::profile2String[profile].c_str());
}
// Send this packet twice. if (!Codecs::isKnown(this->rtpStream->GetMymeType()) || isKeyFrame )
retransmissionNeeded = true; {
SetEffectiveProfile(this->targetProfile);
// Send this packet twice.
retransmissionNeeded = true;
// Resynchronize the stream.
this->syncRequired = true;
SetEffectiveProfile(this->preferredProfile); // Calculate the new target profile.
RecalculateTargetProfile();
}
} }
// If the packet belongs to different profile than the one being sent, drop it. // If the packet belongs to different profile than the one being sent, drop it.
...@@ -368,6 +381,7 @@ namespace RTC ...@@ -368,6 +381,7 @@ namespace RTC
this->maxRecvExtendedSeqNum = packet->GetExtendedSequenceNumber(); this->maxRecvExtendedSeqNum = packet->GetExtendedSequenceNumber();
this->maxRecvSeqNum = packet->GetSequenceNumber(); this->maxRecvSeqNum = packet->GetSequenceNumber();
this->rtpStream->ClearRetransmissionBuffer();
this->syncRequired = false; this->syncRequired = false;
MS_DEBUG_TAG( MS_DEBUG_TAG(
...@@ -634,8 +648,10 @@ namespace RTC ...@@ -634,8 +648,10 @@ namespace RTC
delete rtxPacket; delete rtxPacket;
} }
void Consumer::RecalculateEffectiveProfile() void Consumer::RecalculateTargetProfile()
{ {
MS_TRACE();
RTC::RtpEncodingParameters::Profile newProfile; RTC::RtpEncodingParameters::Profile newProfile;
// If there are no profiles, select none or default, depending on whether this // If there are no profiles, select none or default, depending on whether this
...@@ -672,41 +688,27 @@ namespace RTC ...@@ -672,41 +688,27 @@ namespace RTC
} }
} }
if (newProfile == this->effectiveProfile) this->targetProfile = newProfile;
if (this->targetProfile == this->effectiveProfile)
return; return;
MS_DEBUG_TAG(
rtp,
"target profile set [profile:%s]",
RTC::RtpEncodingParameters::profile2String[this->targetProfile].c_str());
;
if (IsEnabled() && !IsPaused()) if (IsEnabled() && !IsPaused())
{ {
/*
* - This is the first time we are setting the effective profile.
* - The current effective profile is no longer available.
* - We don't handle the key frames for the used codec.
*/
if (
this->effectiveProfile == RTC::RtpEncodingParameters::Profile::DEFAULT ||
this->profiles.find(this->effectiveProfile) == this->profiles.end() ||
!RTC::Codecs::isKnown(this->rtpStream->GetMymeType()))
{
this->syncRequired = true;
this->rtpStream->ClearRetransmissionBuffer();
SetEffectiveProfile(newProfile);
}
// Otherwise set the effective profile upon reception of a key frame.
else
{
}
RequestFullFrame(); RequestFullFrame();
} }
else
{
SetEffectiveProfile(newProfile);
}
} }
void Consumer::SetEffectiveProfile(RTC::RtpEncodingParameters::Profile profile) void Consumer::SetEffectiveProfile(RTC::RtpEncodingParameters::Profile profile)
{ {
MS_TRACE();
static const Json::StaticString JsonStringProfile{ "profile" }; static const Json::StaticString JsonStringProfile{ "profile" };
Json::Value eventData(Json::objectValue); Json::Value eventData(Json::objectValue);
...@@ -715,7 +717,7 @@ namespace RTC ...@@ -715,7 +717,7 @@ namespace RTC
MS_DEBUG_TAG( MS_DEBUG_TAG(
rtp, rtp,
"new effective profile: %s", "effective profile set [profile:%s]",
RTC::RtpEncodingParameters::profile2String[this->effectiveProfile].c_str()); RTC::RtpEncodingParameters::profile2String[this->effectiveProfile].c_str());
; ;
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论