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

RtpSender: remove unsupported RTP parameters (according to the peer capabilities)

上级 e60f0ac8
...@@ -435,10 +435,15 @@ namespace RTC ...@@ -435,10 +435,15 @@ namespace RTC
if (roomCodecCapability.Matches(peerCodecCapability)) if (roomCodecCapability.Matches(peerCodecCapability))
break; break;
} }
if (it2 == this->capabilities.codecs.end())
it = capabilities->codecs.erase(it); if (it2 != this->capabilities.codecs.end())
else {
it++; it++;
}
else
{
it = capabilities->codecs.erase(it);
}
} }
// TODO: Remove unsupported header extensions. // TODO: Remove unsupported header extensions.
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include "RTC/RtpSender.h" #include "RTC/RtpSender.h"
#include "MediaSoupError.h" #include "MediaSoupError.h"
#include "Logger.h" #include "Logger.h"
#include <unordered_set>
namespace RTC namespace RTC
{ {
...@@ -132,14 +133,63 @@ namespace RTC ...@@ -132,14 +133,63 @@ namespace RTC
// Clone given RTP parameters so we manage our own sender parameters. // Clone given RTP parameters so we manage our own sender parameters.
this->rtpParameters = new RTC::RtpParameters(rtpParameters); this->rtpParameters = new RTC::RtpParameters(rtpParameters);
// Remove RTP parameters not supported by this pper.
std::unordered_set<uint8_t> supportedPayloadTypes;
// Remove unsupported codecs.
for (auto it = this->rtpParameters->codecs.begin(); it != this->rtpParameters->codecs.end();)
{
auto& codec = *it;
auto it2 = this->peerCapabilities->codecs.begin();
for (; it2 != this->peerCapabilities->codecs.end(); ++it2)
{
auto& codecCapability = *it2;
if (codecCapability.Matches(codec))
break;
}
if (it2 != this->peerCapabilities->codecs.end())
{
supportedPayloadTypes.insert(codec.payloadType);
it++;
}
else
{
it = this->rtpParameters->codecs.erase(it);
}
}
// Remove unsupported encodings.
for (auto it = this->rtpParameters->encodings.begin(); it != this->rtpParameters->encodings.end();)
{
auto& encoding = *it;
if (supportedPayloadTypes.find(encoding.codecPayloadType) != supportedPayloadTypes.end())
{
it++;
}
else
{
it = this->rtpParameters->encodings.erase(it);
}
}
// TODO: Remove unsupported header extensions.
// Build the payload types map. // Build the payload types map.
SetPayloadTypesMapping(); SetPayloadTypesMapping();
// TODO: Must check new parameters and: // TODO: Must check with PTs and encodings are supported so RTP packets
// - remove unsuported capabilities, // handling is easy.
// - set this->available if at least there is a capable encoding.
// For now make it easy: // If there are no encodings set not available.
this->available = true; if (this->rtpParameters->encodings.size() > 0)
this->available = true;
else
this->available = false;
// Emit "parameterschange" if those are new parameters. // Emit "parameterschange" if those are new parameters.
if (previousRtpParameters) if (previousRtpParameters)
...@@ -227,14 +277,10 @@ namespace RTC ...@@ -227,14 +277,10 @@ namespace RTC
break; break;
} }
} }
if (it == this->peerCapabilities->codecs.end())
{ // This should not happen.
// TODO: Let's see. Theoretically unsupported codecs has been MS_ASSERT(it != this->peerCapabilities->codecs.end(),
// already removed in Send(), but it's not done yet. "no matching room codec found [payloadType:%" PRIu8 "]", codec.payloadType);
// Once done, this should be a MS_THROW.
MS_ERROR("no matching room codec found [payloadType:%" PRIu8 "]",
codec.payloadType);
}
} }
} }
} }
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论