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

Consumer: Remove redundant profile container

上级 9fb392b0
...@@ -107,7 +107,6 @@ namespace RTC ...@@ -107,7 +107,6 @@ namespace RTC
// RTP payload descriptor encoding. // RTP payload descriptor encoding.
std::unique_ptr<RTC::Codecs::EncodingContext> encodingContext; std::unique_ptr<RTC::Codecs::EncodingContext> encodingContext;
// RTP profiles. // RTP profiles.
std::set<RTC::RtpEncodingParameters::Profile> profiles;
std::map<RTC::RtpEncodingParameters::Profile, const RTC::RtpStream*> mapProfileRtpStream; std::map<RTC::RtpEncodingParameters::Profile, const RTC::RtpStream*> mapProfileRtpStream;
RTC::RtpEncodingParameters::Profile preferredProfile{ RTC::RtpEncodingParameters::Profile::DEFAULT }; RTC::RtpEncodingParameters::Profile preferredProfile{ RTC::RtpEncodingParameters::Profile::DEFAULT };
RTC::RtpEncodingParameters::Profile sourcePreferredProfile{ RTC::RtpEncodingParameters::Profile sourcePreferredProfile{
......
...@@ -280,15 +280,14 @@ namespace RTC ...@@ -280,15 +280,14 @@ namespace RTC
{ {
MS_ASSERT(profile != RTC::RtpEncodingParameters::Profile::NONE, "invalid profile"); MS_ASSERT(profile != RTC::RtpEncodingParameters::Profile::NONE, "invalid profile");
MS_ASSERT(this->profiles.find(profile) == this->profiles.end(), "profile already exists"); MS_ASSERT(this->mapProfileRtpStream.find(profile) == this->mapProfileRtpStream.end(), "profile already exists");
MS_ASSERT( MS_ASSERT(
!(profile == RTC::RtpEncodingParameters::Profile::DEFAULT && !this->profiles.empty()), !(profile == RTC::RtpEncodingParameters::Profile::DEFAULT && !this->mapProfileRtpStream.empty()),
"default profile cannot coexist with others"); "default profile cannot coexist with others");
// Insert the new profile. // Insert the new profile.
this->mapProfileRtpStream[profile] = rtpStream; this->mapProfileRtpStream[profile] = rtpStream;
this->profiles.insert(profile);
MS_DEBUG_TAG( MS_DEBUG_TAG(
rtp, "profile added [profile:%s]", RTC::RtpEncodingParameters::profile2String[profile].c_str()); rtp, "profile added [profile:%s]", RTC::RtpEncodingParameters::profile2String[profile].c_str());
...@@ -301,22 +300,21 @@ namespace RTC ...@@ -301,22 +300,21 @@ namespace RTC
{ {
MS_ASSERT(profile != RTC::RtpEncodingParameters::Profile::NONE, "invalid profile"); MS_ASSERT(profile != RTC::RtpEncodingParameters::Profile::NONE, "invalid profile");
MS_ASSERT(this->profiles.find(profile) != this->profiles.end(), "profile not found"); MS_ASSERT(this->mapProfileRtpStream.find(profile) != this->mapProfileRtpStream.end(), "profile not found");
MS_ASSERT( MS_ASSERT(
!(profile == RTC::RtpEncodingParameters::Profile::DEFAULT && this->profiles.size() != 1), !(profile == RTC::RtpEncodingParameters::Profile::DEFAULT && this->mapProfileRtpStream.size() != 1),
"default profile cannot coexist with others"); "default profile cannot coexist with others");
// Remove the profile. // Remove the profile.
this->mapProfileRtpStream.erase(profile); this->mapProfileRtpStream.erase(profile);
this->profiles.erase(profile);
MS_DEBUG_TAG( MS_DEBUG_TAG(
rtp, rtp,
"profile removed [profile:%s]", "profile removed [profile:%s]",
RTC::RtpEncodingParameters::profile2String[profile].c_str()); RTC::RtpEncodingParameters::profile2String[profile].c_str());
if (this->profiles.empty()) if (this->mapProfileRtpStream.empty())
{ {
SetEffectiveProfile(RtpEncodingParameters::Profile::NONE); SetEffectiveProfile(RtpEncodingParameters::Profile::NONE);
RecalculateTargetProfile(); RecalculateTargetProfile();
...@@ -340,12 +338,12 @@ namespace RTC ...@@ -340,12 +338,12 @@ namespace RTC
{ {
SetEffectiveProfile(RtpEncodingParameters::Profile::NONE); SetEffectiveProfile(RtpEncodingParameters::Profile::NONE);
auto it = this->profiles.begin(); auto it = this->mapProfileRtpStream.begin();
auto newTargetProfile = *it; auto newTargetProfile = it->first;
while (++it != this->profiles.end()) while (++it != this->mapProfileRtpStream.end())
{ {
auto candidateTargetProfile = *it; auto candidateTargetProfile = it->first;
if (candidateTargetProfile < profile) if (candidateTargetProfile < profile)
newTargetProfile = candidateTargetProfile; newTargetProfile = candidateTargetProfile;
...@@ -818,14 +816,14 @@ namespace RTC ...@@ -818,14 +816,14 @@ namespace RTC
if (this->effectiveProfile == RtpEncodingParameters::Profile::DEFAULT) if (this->effectiveProfile == RtpEncodingParameters::Profile::DEFAULT)
return; return;
auto it = this->profiles.find(this->effectiveProfile); auto it = this->mapProfileRtpStream.find(this->effectiveProfile);
// This is already the lowest profile. // This is already the lowest profile.
if (it == this->profiles.begin()) if (it == this->mapProfileRtpStream.begin())
return; return;
// Downgrade the target profile. // Downgrade the target profile.
this->targetProfile = *(std::prev(it)); this->targetProfile = (std::prev(it))->first;
if (IsEnabled() && !IsPaused()) if (IsEnabled() && !IsPaused())
RequestKeyFrame(); RequestKeyFrame();
...@@ -843,7 +841,7 @@ namespace RTC ...@@ -843,7 +841,7 @@ namespace RTC
void Consumer::MayRunProbation() void Consumer::MayRunProbation()
{ {
// No simulcast or SVC. // No simulcast or SVC.
if (this->profiles.empty()) if (this->mapProfileRtpStream.empty())
return; return;
// There is an ongoing profile upgrade. Do not interfere. // There is an ongoing profile upgrade. Do not interfere.
...@@ -972,7 +970,7 @@ namespace RTC ...@@ -972,7 +970,7 @@ namespace RTC
// 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
// is single stream or simulcast/SVC. // is single stream or simulcast/SVC.
if (this->profiles.empty()) if (this->mapProfileRtpStream.empty())
{ {
MS_ASSERT( MS_ASSERT(
this->effectiveProfile == RtpEncodingParameters::Profile::NONE || this->effectiveProfile == RtpEncodingParameters::Profile::NONE ||
...@@ -988,20 +986,20 @@ namespace RTC ...@@ -988,20 +986,20 @@ namespace RTC
else if (GetPreferredProfile() == RTC::RtpEncodingParameters::Profile::DEFAULT) else if (GetPreferredProfile() == RTC::RtpEncodingParameters::Profile::DEFAULT)
{ {
newTargetProfile = this->effectiveProfile; newTargetProfile = this->effectiveProfile;
auto it = this->profiles.upper_bound(this->effectiveProfile); auto it = this->mapProfileRtpStream.upper_bound(this->effectiveProfile);
if (it != this->profiles.end()) if (it != this->mapProfileRtpStream.end())
newTargetProfile = *it; newTargetProfile = it->first;
} }
// If the preferred profile is forced, try with the closest profile to it. // If the preferred profile is forced, try with the closest profile to it.
else if (forcePreferred) else if (forcePreferred)
{ {
auto it = this->profiles.crbegin(); auto it = this->mapProfileRtpStream.crbegin();
newTargetProfile = *it; newTargetProfile = it->first;
for (; it != this->profiles.crend(); ++it) for (; it != this->mapProfileRtpStream.crend(); ++it)
{ {
auto profile = *it; auto profile = it->first;
if (profile <= GetPreferredProfile()) if (profile <= GetPreferredProfile())
{ {
...@@ -1014,10 +1012,10 @@ namespace RTC ...@@ -1014,10 +1012,10 @@ namespace RTC
else else
{ {
newTargetProfile = this->effectiveProfile; newTargetProfile = this->effectiveProfile;
auto it = this->profiles.upper_bound(this->effectiveProfile); auto it = this->mapProfileRtpStream.upper_bound(this->effectiveProfile);
if (it != this->profiles.end() && *it <= GetPreferredProfile()) if (it != this->mapProfileRtpStream.end() && it->first <= GetPreferredProfile())
newTargetProfile = *it; newTargetProfile = it->first;
} }
// Not enabled. Make this the target profile. // Not enabled. Make this the target profile.
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论