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

RtpParameters.cpp: add scalabilityMode

上级 96839199
...@@ -26,7 +26,7 @@ namespace RTC ...@@ -26,7 +26,7 @@ namespace RTC
public: public:
static Kind GetKind(std::string& str); static Kind GetKind(std::string& str);
static Kind GetKind(std::string&& str); static Kind GetKind(std::string&& str);
static std::string& GetString(Kind kind); static const std::string& GetString(Kind kind);
private: private:
static std::unordered_map<std::string, Kind> string2Kind; static std::unordered_map<std::string, Kind> string2Kind;
...@@ -205,6 +205,9 @@ namespace RTC ...@@ -205,6 +205,9 @@ namespace RTC
uint32_t maxBitrate{ 0 }; uint32_t maxBitrate{ 0 };
double maxFramerate{ 0 }; double maxFramerate{ 0 };
bool dtx{ false }; bool dtx{ false };
std::string scalabilityMode;
uint8_t spatialLayers{ 1 };
uint8_t temporalLayers{ 1 };
}; };
class RtpHeaderExtensionParameters class RtpHeaderExtensionParameters
...@@ -261,7 +264,6 @@ namespace RTC ...@@ -261,7 +264,6 @@ namespace RTC
public: public:
RtpParameters(){}; RtpParameters(){};
explicit RtpParameters(json& data); explicit RtpParameters(json& data);
explicit RtpParameters(const RtpParameters* rtpParameters);
void FillJson(json& jsonObject) const; void FillJson(json& jsonObject) const;
const RTC::RtpCodecParameters* GetCodecForEncoding(RtpEncodingParameters& encoding) const; const RTC::RtpCodecParameters* GetCodecForEncoding(RtpEncodingParameters& encoding) const;
......
...@@ -57,7 +57,7 @@ namespace RTC ...@@ -57,7 +57,7 @@ namespace RTC
return it->second; return it->second;
} }
std::string& Media::GetString(Media::Kind kind) const std::string& Media::GetString(Media::Kind kind)
{ {
MS_TRACE(); MS_TRACE();
......
...@@ -23,6 +23,7 @@ namespace RTC ...@@ -23,6 +23,7 @@ namespace RTC
auto jsonMaxBitrateIt = data.find("maxBitrate"); auto jsonMaxBitrateIt = data.find("maxBitrate");
auto jsonMaxFramerateIt = data.find("maxFramerate"); auto jsonMaxFramerateIt = data.find("maxFramerate");
auto jsonDtxIt = data.find("dtx"); auto jsonDtxIt = data.find("dtx");
auto jsonScalabilityModeIt = data.find("scalabilityMode");
// ssrc is optional. // ssrc is optional.
if (jsonSsrcIt != data.end() && jsonSsrcIt->is_number_unsigned()) if (jsonSsrcIt != data.end() && jsonSsrcIt->is_number_unsigned())
...@@ -58,6 +59,108 @@ namespace RTC ...@@ -58,6 +59,108 @@ namespace RTC
// dtx is optional. // dtx is optional.
if (jsonDtxIt != data.end() && jsonDtxIt->is_boolean()) if (jsonDtxIt != data.end() && jsonDtxIt->is_boolean())
this->dtx = jsonDtxIt->get<bool>(); this->dtx = jsonDtxIt->get<bool>();
// scalabilityMode is optional.
if (jsonScalabilityModeIt != data.end() && jsonScalabilityModeIt->is_string())
{
this->scalabilityMode = jsonScalabilityModeIt->get<std::string>();
if (this->scalabilityMode == "L1T2")
{
this->spatialLayers = 1;
this->temporalLayers = 2;
}
else if (this->scalabilityMode == "L1T3")
{
this->spatialLayers = 1;
this->temporalLayers = 3;
}
else if (this->scalabilityMode == "L2T1")
{
this->spatialLayers = 2;
this->temporalLayers = 1;
}
else if (this->scalabilityMode == "L2T2")
{
this->spatialLayers = 2;
this->temporalLayers = 2;
}
else if (this->scalabilityMode == "L2T3")
{
this->spatialLayers = 2;
this->temporalLayers = 3;
}
else if (this->scalabilityMode == "L3T1")
{
this->spatialLayers = 3;
this->temporalLayers = 1;
}
else if (this->scalabilityMode == "L3T2")
{
this->spatialLayers = 3;
this->temporalLayers = 2;
}
else if (this->scalabilityMode == "L3T3")
{
this->spatialLayers = 3;
this->temporalLayers = 3;
}
else if (this->scalabilityMode == "L2T1h")
{
this->spatialLayers = 2;
this->temporalLayers = 1;
}
else if (this->scalabilityMode == "L2T2h")
{
this->spatialLayers = 2;
this->temporalLayers = 2;
}
else if (this->scalabilityMode == "L2T3h")
{
this->spatialLayers = 2;
this->temporalLayers = 3;
}
else if (this->scalabilityMode == "L3T2_KEY")
{
this->spatialLayers = 3;
this->temporalLayers = 2;
}
else if (this->scalabilityMode == "L3T3_KEY")
{
this->spatialLayers = 3;
this->temporalLayers = 3;
}
else if (this->scalabilityMode == "L4T5_KEY")
{
this->spatialLayers = 4;
this->temporalLayers = 5;
}
else if (this->scalabilityMode == "L4T7_KEY")
{
this->spatialLayers = 4;
this->temporalLayers = 7;
}
else if (this->scalabilityMode == "L3T2_KEY_SHIFT")
{
this->spatialLayers = 3;
this->temporalLayers = 2;
}
else if (this->scalabilityMode == "L3T3_KEY_SHIFT")
{
this->spatialLayers = 3;
this->temporalLayers = 3;
}
else if (this->scalabilityMode == "L4T5_KEY_SHIFT")
{
this->spatialLayers = 4;
this->temporalLayers = 5;
}
else if (this->scalabilityMode == "L4T7_KEY_SHIFT")
{
this->spatialLayers = 4;
this->temporalLayers = 7;
}
}
} }
void RtpEncodingParameters::FillJson(json& jsonObject) const void RtpEncodingParameters::FillJson(json& jsonObject) const
...@@ -94,5 +197,13 @@ namespace RTC ...@@ -94,5 +197,13 @@ namespace RTC
// Add dtx. // Add dtx.
if (this->dtx) if (this->dtx)
jsonObject["dtx"] = this->dtx; jsonObject["dtx"] = this->dtx;
// Add scalabilityMode.
if (!this->scalabilityMode.empty())
{
jsonObject["scalabilityMode"] = this->scalabilityMode;
jsonObject["spatialLayers"] = this->spatialLayers;
jsonObject["temporalLayers"] = this->temporalLayers;
}
} }
} // namespace RTC } // namespace RTC
...@@ -155,14 +155,6 @@ namespace RTC ...@@ -155,14 +155,6 @@ namespace RTC
ValidateEncodings(); ValidateEncodings();
} }
RtpParameters::RtpParameters(const RtpParameters* rtpParameters)
: mid(rtpParameters->mid), codecs(rtpParameters->codecs), encodings(rtpParameters->encodings),
headerExtensions(rtpParameters->headerExtensions), rtcp(rtpParameters->rtcp),
hasRtcp(rtpParameters->hasRtcp)
{
MS_TRACE();
}
void RtpParameters::FillJson(json& jsonObject) const void RtpParameters::FillJson(json& jsonObject) const
{ {
MS_TRACE(); MS_TRACE();
...@@ -339,8 +331,17 @@ namespace RTC ...@@ -339,8 +331,17 @@ namespace RTC
// Iterate all the encodings, set the first payloadType in all of them with // Iterate all the encodings, set the first payloadType in all of them with
// codecPayloadType unset, and check that others point to a media codec. // codecPayloadType unset, and check that others point to a media codec.
//
// Also, don't allow multiple SVC spatial layers into an encoding if there
// are more than one encoding (simulcast).
for (auto& encoding : this->encodings) for (auto& encoding : this->encodings)
{ {
if (encoding.spatialLayers > 1 && this->encodings.size() > 1)
{
MS_THROW_TYPE_ERROR(
"cannot use both simulcast and encodings with multiple SVC spatial layers");
}
if (!encoding.hasCodecPayloadType) if (!encoding.hasCodecPayloadType)
{ {
encoding.codecPayloadType = firstMediaPayloadType; encoding.codecPayloadType = firstMediaPayloadType;
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论