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

RtpReceiver.receive(): remove unsupported RTCP feedback mechanisms and RTP header extensions.

上级 e24194ae
...@@ -43,6 +43,8 @@ These codecs have the same fields as the room codecs, with some variations: ...@@ -43,6 +43,8 @@ These codecs have the same fields as the room codecs, with some variations:
After that, C++ `Room::onPeerCapabilities(capabilities)` is called. This method removes peer's codecs not supported by the room, removes the unsupported RTCP feedback mechanisms from the supported codecs, and removes RTP header extensions and FEC mechanisms not supported by mediasoup. After that, C++ `Room::onPeerCapabilities(capabilities)` is called. This method removes peer's codecs not supported by the room, removes the unsupported RTCP feedback mechanisms from the supported codecs, and removes RTP header extensions and FEC mechanisms not supported by mediasoup.
This is, peer's capabilities are a subset of the mediasoup capabilities and the room capabilities.
## Creating a RtpReceiver ## Creating a RtpReceiver
...@@ -60,6 +62,12 @@ These codecs have the same fields as the peer's capabilities codecs above, with ...@@ -60,6 +62,12 @@ These codecs have the same fields as the peer's capabilities codecs above, with
* `kind` is ignored. * `kind` is ignored.
*TODO:* Currently, if `receive()` is called ith a codec that is not supported by the room or not present in the peer's given capabilities, it fails. Not sure what should be the proper behavior here.
Unsupported RTCP feedback mechanisms and RTP header extensions not supported by mediasoup or by the peer itself are removed.
Effective RTP parameters are returned to the `receive()` promise.
After that, C++ `RtpReceiver::FillRtpParameters()` is called. This method does nothing right now. After that, C++ `RtpReceiver::FillRtpParameters()` is called. This method does nothing right now.
*TODO:* C++ `RtpReceiver::FillRtpParameters()` should: *TODO:* C++ `RtpReceiver::FillRtpParameters()` should:
......
...@@ -163,6 +163,39 @@ namespace RTC ...@@ -163,6 +163,39 @@ namespace RTC
std::vector<RtcpFeedback> rtcpFeedback; std::vector<RtcpFeedback> rtcpFeedback;
}; };
class RtpHeaderExtension
{
public:
explicit RtpHeaderExtension(Json::Value& data);
Json::Value toJson();
public:
Media::Kind kind = Media::Kind::ALL;
std::string uri;
uint16_t preferredId = 0;
bool preferredEncrypt = false;
};
class RtpCapabilities
{
public:
RtpCapabilities() {};
RtpCapabilities(Json::Value& data, RTC::Scope scope);
Json::Value toJson();
void RemoveUnsupportedHeaderExtensions(std::vector<RtpHeaderExtension>& supportedHeaderExtensions);
void RemoveUnsupportedFecMechanisms(std::vector<std::string>& supportedFecMechanisms);
private:
void ValidateCodecs(RTC::Scope scope);
public:
std::vector<RtpCodecParameters> codecs;
std::vector<RtpHeaderExtension> headerExtensions;
std::vector<std::string> fecMechanisms;
};
class RtpFecParameters class RtpFecParameters
{ {
public: public:
...@@ -247,6 +280,7 @@ namespace RTC ...@@ -247,6 +280,7 @@ namespace RTC
explicit RtpParameters(const RtpParameters* RtpParameters); explicit RtpParameters(const RtpParameters* RtpParameters);
Json::Value toJson(); Json::Value toJson();
void RemoveUnsupportedHeaderExtensions(std::vector<RtpHeaderExtension>& supportedHeaderExtensions);
private: private:
void ValidateCodecs(); void ValidateCodecs();
...@@ -261,39 +295,6 @@ namespace RTC ...@@ -261,39 +295,6 @@ namespace RTC
bool hasRtcp = false; bool hasRtcp = false;
Json::Value userParameters; Json::Value userParameters;
}; };
class RtpHeaderExtension
{
public:
explicit RtpHeaderExtension(Json::Value& data);
Json::Value toJson();
public:
Media::Kind kind = Media::Kind::ALL;
std::string uri;
uint16_t preferredId = 0;
bool preferredEncrypt = false;
};
class RtpCapabilities
{
public:
RtpCapabilities() {};
RtpCapabilities(Json::Value& data, RTC::Scope scope);
Json::Value toJson();
void RemoveUnsupportedHeaderExtensions(std::vector<RtpHeaderExtension>& supportedHeaderExtensions);
void RemoveUnsupportedFecMechanisms(std::vector<std::string>& supportedFecMechanisms);
private:
void ValidateCodecs(RTC::Scope scope);
public:
std::vector<RtpCodecParameters> codecs;
std::vector<RtpHeaderExtension> headerExtensions;
std::vector<std::string> fecMechanisms;
};
} }
#endif #endif
...@@ -679,8 +679,7 @@ namespace RTC ...@@ -679,8 +679,7 @@ namespace RTC
auto rtpParameters = rtpReceiver->GetParameters(); auto rtpParameters = rtpReceiver->GetParameters();
// Given codecs must be a subset of the capability codecs of the peer. // Given codecs must be a subset of the capability codecs of the peer.
for (auto& codec : rtpParameters->codecs)
for (auto codec : rtpParameters->codecs)
{ {
auto it = this->capabilities.codecs.begin(); auto it = this->capabilities.codecs.begin();
...@@ -689,8 +688,13 @@ namespace RTC ...@@ -689,8 +688,13 @@ namespace RTC
auto& codecCapability = *it; auto& codecCapability = *it;
if (codecCapability.Matches(codec, true)) if (codecCapability.Matches(codec, true))
{
// Once matched, remove the unsupported RTCP feedback from the given codec.
codec.RemoveUnsupportedRtcpFeedback(codecCapability.rtcpFeedback);
break; break;
} }
}
if (it == this->capabilities.codecs.end()) if (it == this->capabilities.codecs.end())
{ {
MS_THROW_ERROR("no matching peer codec capability found [payloadType:%" PRIu8 ", mime:%s]", MS_THROW_ERROR("no matching peer codec capability found [payloadType:%" PRIu8 ", mime:%s]",
...@@ -698,6 +702,9 @@ namespace RTC ...@@ -698,6 +702,9 @@ namespace RTC
} }
} }
// Remove unsupported header extensions.
rtpParameters->RemoveUnsupportedHeaderExtensions(this->capabilities.headerExtensions);
auto transport = rtpReceiver->GetTransport(); auto transport = rtpReceiver->GetTransport();
// NOTE: This may throw. // NOTE: This may throw.
......
...@@ -103,11 +103,11 @@ namespace RTC ...@@ -103,11 +103,11 @@ namespace RTC
return json; return json;
} }
void RtpCapabilities::RemoveUnsupportedHeaderExtensions(std::vector<RtpHeaderExtension>& supportedHeaderExtensions) void RtpCapabilities::RemoveUnsupportedHeaderExtensions(std::vector<RTC::RtpHeaderExtension>& supportedHeaderExtensions)
{ {
MS_TRACE(); MS_TRACE();
std::vector<RtpHeaderExtension> updatedHeaderExtensions; std::vector<RTC::RtpHeaderExtension> updatedHeaderExtensions;
for (auto& headerExtension : this->headerExtensions) for (auto& headerExtension : this->headerExtensions)
{ {
......
...@@ -225,11 +225,11 @@ namespace RTC ...@@ -225,11 +225,11 @@ namespace RTC
return true; return true;
} }
void RtpCodecParameters::RemoveUnsupportedRtcpFeedback(std::vector<RtcpFeedback>& supportedRtcpFeedback) void RtpCodecParameters::RemoveUnsupportedRtcpFeedback(std::vector<RTC::RtcpFeedback>& supportedRtcpFeedback)
{ {
MS_TRACE(); MS_TRACE();
std::vector<RtcpFeedback> updatedRtcpFeedback; std::vector<RTC::RtcpFeedback> updatedRtcpFeedback;
for (auto& rtcpFeedbackItem : this->rtcpFeedback) for (auto& rtcpFeedbackItem : this->rtcpFeedback)
{ {
......
...@@ -158,6 +158,28 @@ namespace RTC ...@@ -158,6 +158,28 @@ namespace RTC
return json; return json;
} }
void RtpParameters::RemoveUnsupportedHeaderExtensions(std::vector<RtpHeaderExtension>& supportedHeaderExtensions)
{
MS_TRACE();
std::vector<RTC::RtpHeaderExtensionParameters> updatedHeaderExtensions;
for (auto& headerExtension : this->headerExtensions)
{
for (auto& supportedHeaderExtension : supportedHeaderExtensions)
{
if (headerExtension.uri == supportedHeaderExtension.uri)
{
updatedHeaderExtensions.push_back(headerExtension);
break;
}
}
}
this->headerExtensions = updatedHeaderExtensions;
}
inline inline
void RtpParameters::ValidateCodecs() void RtpParameters::ValidateCodecs()
{ {
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论