提交 401ae1a8 authored 作者: Gustavo Garcia's avatar Gustavo Garcia 提交者: Iñaki Baz Castillo

MODIFY reduce redundancy accessing nested members

上级 c7ee8f48
...@@ -196,12 +196,13 @@ namespace RTC ...@@ -196,12 +196,13 @@ namespace RTC
// Remove RTP parameters not supported by this Peer. // Remove RTP parameters not supported by this Peer.
// Remove unsupported codecs. // Remove unsupported codecs.
for (auto it = this->rtpParameters->codecs.begin(); it != this->rtpParameters->codecs.end();) auto codecs = this->rtpParameters->codecs;
for (auto it = codecs.begin(); it != this->rtpParameters->codecs.end();)
{ {
auto& codec = *it; auto& codec = *it;
auto it2 = this->peerCapabilities->codecs.begin(); auto it2 = codecs.begin();
for (; it2 != this->peerCapabilities->codecs.end(); ++it2) for (; it2 != codecs.end(); ++it2)
{ {
auto& codecCapability = *it2; auto& codecCapability = *it2;
...@@ -209,19 +210,20 @@ namespace RTC ...@@ -209,19 +210,20 @@ namespace RTC
break; break;
} }
if (it2 != this->peerCapabilities->codecs.end()) if (it2 != codecs.end())
{ {
this->supportedPayloadTypes.insert(codec.payloadType); this->supportedPayloadTypes.insert(codec.payloadType);
++it; ++it;
} }
else else
{ {
it = this->rtpParameters->codecs.erase(it); it = codecs.erase(it);
} }
} }
// Remove unsupported encodings. // Remove unsupported encodings.
for (auto it = this->rtpParameters->encodings.begin(); it != this->rtpParameters->encodings.end();) auto encodings = this->rtpParameters->encodings;
for (auto it = encodings.begin(); it != encodings.end();)
{ {
auto& encoding = *it; auto& encoding = *it;
...@@ -231,18 +233,18 @@ namespace RTC ...@@ -231,18 +233,18 @@ namespace RTC
} }
else else
{ {
it = this->rtpParameters->encodings.erase(it); it = encodings.erase(it);
} }
} }
// TODO: Temporal. To be refactored. // TODO: Temporal. To be refactored.
// Remove all the encodings but the first one. // Remove all the encodings but the first one.
if (this->rtpParameters->encodings.size() > 1) if (encodings.size() > 1)
{ {
RTC::RtpEncodingParameters encoding = this->rtpParameters->encodings[0]; RTC::RtpEncodingParameters encoding = encodings[0];
this->rtpParameters->encodings.clear(); encodings.clear();
this->rtpParameters->encodings.push_back(encoding); encodings.push_back(encoding);
} }
// Remove unsupported header extensions. // Remove unsupported header extensions.
...@@ -252,12 +254,12 @@ namespace RTC ...@@ -252,12 +254,12 @@ namespace RTC
this->rtpParameters->muxId = Utils::Crypto::GetRandomString(8); this->rtpParameters->muxId = Utils::Crypto::GetRandomString(8);
// If there are no encodings set not available. // If there are no encodings set not available.
if (this->rtpParameters->encodings.size() > 0) if (!encodings.empty())
{ {
this->available = true; this->available = true;
// NOTE: We assume a single stream/encoding when sending to remote peers. // NOTE: We assume a single stream/encoding when sending to remote peers.
auto encoding = this->rtpParameters->encodings[0]; auto encoding = encodings[0];
uint32_t ssrc = encoding.ssrc; uint32_t ssrc = encoding.ssrc;
uint32_t streamClockRate = this->rtpParameters->GetClockRateForEncoding(encoding); uint32_t streamClockRate = this->rtpParameters->GetClockRateForEncoding(encoding);
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论