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

Producer/Consumer: cosmetic changes

上级 4e3c9081
...@@ -258,7 +258,7 @@ class Transport extends EnhancedEventEmitter ...@@ -258,7 +258,7 @@ class Transport extends EnhancedEventEmitter
* @param {String} [id] - Producer id (just for PipeTransports). * @param {String} [id] - Producer id (just for PipeTransports).
* @param {String} kind - 'audio'/'video'. * @param {String} kind - 'audio'/'video'.
* @param {RTCRtpParameters} rtpParameters - Remote RTP parameters. * @param {RTCRtpParameters} rtpParameters - Remote RTP parameters.
* @param {Boolean} [paused=false] - Whether the Consumer must start paused. * @param {Boolean} [paused=false] - Whether the Producer must start paused.
* @param {Object} [appData={}] - Custom app data. * @param {Object} [appData={}] - Custom app data.
* *
* @async * @async
......
...@@ -61,8 +61,11 @@ namespace RTC ...@@ -61,8 +61,11 @@ namespace RTC
RTC::SeqManager<uint32_t> rtpTimestampManager; RTC::SeqManager<uint32_t> rtpTimestampManager;
std::unique_ptr<RTC::Codecs::EncodingContext> encodingContext; std::unique_ptr<RTC::Codecs::EncodingContext> encodingContext;
int16_t preferredSpatialLayer{ -1 }; int16_t preferredSpatialLayer{ -1 };
int16_t preferredTemporalLayer{ -1 };
int16_t targetSpatialLayer{ -1 }; int16_t targetSpatialLayer{ -1 };
int16_t targetTemporalLayer{ -1 };
int16_t currentSpatialLayer{ -1 }; int16_t currentSpatialLayer{ -1 };
int16_t currentTemporalLayer{ -1 };
}; };
} // namespace RTC } // namespace RTC
......
...@@ -100,7 +100,7 @@ function get_libsrtp() ...@@ -100,7 +100,7 @@ function get_libsrtp()
function get_catch() function get_catch()
{ {
GIT_REPO="https://github.com/catchorg/Catch2.git" GIT_REPO="https://github.com/catchorg/Catch2.git"
GIT_TAG="v2.7.0" GIT_TAG="v2.7.1"
DEST="deps/catch" DEST="deps/catch"
get_dep "${GIT_REPO}" "${GIT_TAG}" "${DEST}" get_dep "${GIT_REPO}" "${GIT_TAG}" "${DEST}"
......
...@@ -274,6 +274,9 @@ namespace RTC ...@@ -274,6 +274,9 @@ namespace RTC
{ {
auto* mediaCodec = this->rtpParameters.GetCodecForEncoding(encoding); auto* mediaCodec = this->rtpParameters.GetCodecForEncoding(encoding);
MS_DEBUG_TAG(
rtp, "[ssrc:%" PRIu32 ", payloadType:%" PRIu8 "]", encoding.ssrc, mediaCodec->payloadType);
// Set stream params. // Set stream params.
RTC::RtpStream::Params params; RTC::RtpStream::Params params;
...@@ -288,7 +291,7 @@ namespace RTC ...@@ -288,7 +291,7 @@ namespace RTC
// Check in band FEC in codec parameters. // Check in band FEC in codec parameters.
if (mediaCodec->parameters.HasInteger("useinbandfec") && mediaCodec->parameters.GetInteger("useinbandfec") == 1) if (mediaCodec->parameters.HasInteger("useinbandfec") && mediaCodec->parameters.GetInteger("useinbandfec") == 1)
{ {
MS_DEBUG_TAG(rtcp, "in band FEC enabled"); MS_DEBUG_TAG(rtp, "in band FEC enabled");
params.useInBandFec = true; params.useInBandFec = true;
} }
...@@ -296,7 +299,7 @@ namespace RTC ...@@ -296,7 +299,7 @@ namespace RTC
// Check DTX in codec parameters. // Check DTX in codec parameters.
if (mediaCodec->parameters.HasInteger("usedtx") && mediaCodec->parameters.GetInteger("usedtx") == 1) if (mediaCodec->parameters.HasInteger("usedtx") && mediaCodec->parameters.GetInteger("usedtx") == 1)
{ {
MS_DEBUG_TAG(rtcp, "DTX enabled"); MS_DEBUG_TAG(rtp, "DTX enabled");
params.useDtx = true; params.useDtx = true;
} }
...@@ -304,7 +307,7 @@ namespace RTC ...@@ -304,7 +307,7 @@ namespace RTC
// Check DTX in the encoding. // Check DTX in the encoding.
if (encoding.dtx) if (encoding.dtx)
{ {
MS_DEBUG_TAG(rtcp, "DTX enabled"); MS_DEBUG_TAG(rtp, "DTX enabled");
params.useDtx = true; params.useDtx = true;
} }
...@@ -315,13 +318,13 @@ namespace RTC ...@@ -315,13 +318,13 @@ namespace RTC
if (!params.usePli && fb.type == "nack" && fb.parameter == "pli") if (!params.usePli && fb.type == "nack" && fb.parameter == "pli")
{ {
MS_DEBUG_TAG(rtcp, "PLI supported"); MS_DEBUG_2TAGS(rtp, rtcp, "PLI supported");
params.usePli = true; params.usePli = true;
} }
else if (!params.useFir && fb.type == "ccm" && fb.parameter == "fir") else if (!params.useFir && fb.type == "ccm" && fb.parameter == "fir")
{ {
MS_DEBUG_TAG(rtcp, "FIR supported"); MS_DEBUG_2TAGS(rtp, rtcp, "FIR supported");
params.useFir = true; params.useFir = true;
} }
......
...@@ -696,6 +696,13 @@ namespace RTC ...@@ -696,6 +696,13 @@ namespace RTC
auto& encoding = this->rtpParameters.encodings[encodingIdx]; auto& encoding = this->rtpParameters.encodings[encodingIdx];
auto& encodingMapping = this->rtpMapping.encodings[encodingIdx]; auto& encodingMapping = this->rtpMapping.encodings[encodingIdx];
MS_DEBUG_TAG(
rtp,
"[ssrc:%" PRIu32 ", rid:%s, payloadType:%" PRIu8 "]",
ssrc,
encoding.rid.c_str(),
mediaCodec.payloadType);
// Set stream params. // Set stream params.
RTC::RtpStream::Params params; RTC::RtpStream::Params params;
...@@ -719,7 +726,7 @@ namespace RTC ...@@ -719,7 +726,7 @@ namespace RTC
// Check DTX in codec parameters. // Check DTX in codec parameters.
if (mediaCodec.parameters.HasInteger("usedtx") && mediaCodec.parameters.GetInteger("usedtx") == 1) if (mediaCodec.parameters.HasInteger("usedtx") && mediaCodec.parameters.GetInteger("usedtx") == 1)
{ {
MS_DEBUG_TAG(rtcp, "DTX enabled"); MS_DEBUG_TAG(rtp, "DTX enabled");
params.useDtx = true; params.useDtx = true;
} }
...@@ -727,7 +734,7 @@ namespace RTC ...@@ -727,7 +734,7 @@ namespace RTC
// Check DTX in the encoding. // Check DTX in the encoding.
if (encoding.dtx) if (encoding.dtx)
{ {
MS_DEBUG_TAG(rtcp, "DTX enabled"); MS_DEBUG_TAG(rtp, "DTX enabled");
params.useDtx = true; params.useDtx = true;
} }
...@@ -736,19 +743,19 @@ namespace RTC ...@@ -736,19 +743,19 @@ namespace RTC
{ {
if (!params.useNack && fb.type == "nack" && fb.parameter == "") if (!params.useNack && fb.type == "nack" && fb.parameter == "")
{ {
MS_DEBUG_2TAGS(rtcp, rtx, "NACK supported"); MS_DEBUG_2TAGS(rtp, rtcp, "NACK supported");
params.useNack = true; params.useNack = true;
} }
else if (!params.usePli && fb.type == "nack" && fb.parameter == "pli") else if (!params.usePli && fb.type == "nack" && fb.parameter == "pli")
{ {
MS_DEBUG_TAG(rtcp, "PLI supported"); MS_DEBUG_2TAGS(rtp, rtcp, "PLI supported");
params.usePli = true; params.usePli = true;
} }
else if (!params.useFir && fb.type == "ccm" && fb.parameter == "fir") else if (!params.useFir && fb.type == "ccm" && fb.parameter == "fir")
{ {
MS_DEBUG_TAG(rtcp, "FIR supported"); MS_DEBUG_2TAGS(rtp, rtcp, "FIR supported");
params.useFir = true; params.useFir = true;
} }
......
...@@ -367,6 +367,9 @@ namespace RTC ...@@ -367,6 +367,9 @@ namespace RTC
auto& encoding = this->rtpParameters.encodings[0]; auto& encoding = this->rtpParameters.encodings[0];
auto* mediaCodec = this->rtpParameters.GetCodecForEncoding(encoding); auto* mediaCodec = this->rtpParameters.GetCodecForEncoding(encoding);
MS_DEBUG_TAG(
rtp, "[ssrc:%" PRIu32 ", payloadType:%" PRIu8 "]", encoding.ssrc, mediaCodec->payloadType);
// Set stream params. // Set stream params.
RTC::RtpStream::Params params; RTC::RtpStream::Params params;
...@@ -379,7 +382,7 @@ namespace RTC ...@@ -379,7 +382,7 @@ namespace RTC
// Check in band FEC in codec parameters. // Check in band FEC in codec parameters.
if (mediaCodec->parameters.HasInteger("useinbandfec") && mediaCodec->parameters.GetInteger("useinbandfec") == 1) if (mediaCodec->parameters.HasInteger("useinbandfec") && mediaCodec->parameters.GetInteger("useinbandfec") == 1)
{ {
MS_DEBUG_TAG(rtcp, "in band FEC enabled"); MS_DEBUG_TAG(rtp, "in band FEC enabled");
params.useInBandFec = true; params.useInBandFec = true;
} }
...@@ -387,7 +390,7 @@ namespace RTC ...@@ -387,7 +390,7 @@ namespace RTC
// Check DTX in codec parameters. // Check DTX in codec parameters.
if (mediaCodec->parameters.HasInteger("usedtx") && mediaCodec->parameters.GetInteger("usedtx") == 1) if (mediaCodec->parameters.HasInteger("usedtx") && mediaCodec->parameters.GetInteger("usedtx") == 1)
{ {
MS_DEBUG_TAG(rtcp, "DTX enabled"); MS_DEBUG_TAG(rtp, "DTX enabled");
params.useDtx = true; params.useDtx = true;
} }
...@@ -395,7 +398,7 @@ namespace RTC ...@@ -395,7 +398,7 @@ namespace RTC
// Check DTX in the encoding. // Check DTX in the encoding.
if (encoding.dtx) if (encoding.dtx)
{ {
MS_DEBUG_TAG(rtcp, "DTX enabled"); MS_DEBUG_TAG(rtp, "DTX enabled");
params.useDtx = true; params.useDtx = true;
} }
...@@ -404,19 +407,19 @@ namespace RTC ...@@ -404,19 +407,19 @@ namespace RTC
{ {
if (!params.useNack && fb.type == "nack" && fb.parameter == "") if (!params.useNack && fb.type == "nack" && fb.parameter == "")
{ {
MS_DEBUG_2TAGS(rtcp, rtx, "NACK supported"); MS_DEBUG_2TAGS(rtp, rtcp, "NACK supported");
params.useNack = true; params.useNack = true;
} }
else if (!params.usePli && fb.type == "nack" && fb.parameter == "pli") else if (!params.usePli && fb.type == "nack" && fb.parameter == "pli")
{ {
MS_DEBUG_TAG(rtcp, "PLI supported"); MS_DEBUG_2TAGS(rtp, rtcp, "PLI supported");
params.usePli = true; params.usePli = true;
} }
else if (!params.useFir && fb.type == "ccm" && fb.parameter == "fir") else if (!params.useFir && fb.type == "ccm" && fb.parameter == "fir")
{ {
MS_DEBUG_TAG(rtcp, "FIR supported"); MS_DEBUG_2TAGS(rtp, rtcp, "FIR supported");
params.useFir = true; params.useFir = true;
} }
......
...@@ -21,6 +21,14 @@ namespace RTC ...@@ -21,6 +21,14 @@ namespace RTC
if (this->consumableRtpEncodings.size() <= 1) if (this->consumableRtpEncodings.size() <= 1)
MS_THROW_TYPE_ERROR("invalid consumableRtpEncodings with size <= 1"); MS_THROW_TYPE_ERROR("invalid consumableRtpEncodings with size <= 1");
auto& encoding = this->rtpParameters.encodings[0];
// Ensure there are as many spatial layers as encodings.
if (encoding.spatialLayers != this->consumableRtpEncodings.size())
{
MS_THROW_TYPE_ERROR("encoding.spatialLayers does not match number of consumableRtpEncodings");
}
auto jsonPreferredLayersIt = data.find("preferredLayers"); auto jsonPreferredLayersIt = data.find("preferredLayers");
// Fill mapMappedSsrcSpatialLayer. // Fill mapMappedSsrcSpatialLayer.
...@@ -34,9 +42,8 @@ namespace RTC ...@@ -34,9 +42,8 @@ namespace RTC
// Set preferredLayers (if given). // Set preferredLayers (if given).
if (jsonPreferredLayersIt != data.end() && jsonPreferredLayersIt->is_object()) if (jsonPreferredLayersIt != data.end() && jsonPreferredLayersIt->is_object())
{ {
// TODO: Handle temporalLayer. auto jsonSpatialLayerIt = jsonPreferredLayersIt->find("spatialLayer");
auto jsonTemporalLayerIt = jsonPreferredLayersIt->find("temporalLayer");
auto jsonSpatialLayerIt = jsonPreferredLayersIt->find("spatialLayer");
if (jsonSpatialLayerIt == jsonPreferredLayersIt->end() || !jsonSpatialLayerIt->is_number_unsigned()) if (jsonSpatialLayerIt == jsonPreferredLayersIt->end() || !jsonSpatialLayerIt->is_number_unsigned())
{ {
...@@ -45,17 +52,23 @@ namespace RTC ...@@ -45,17 +52,23 @@ namespace RTC
this->preferredSpatialLayer = jsonSpatialLayerIt->get<int16_t>(); this->preferredSpatialLayer = jsonSpatialLayerIt->get<int16_t>();
if (this->preferredSpatialLayer >= static_cast<int16_t>(this->consumableRtpEncodings.size())) if (this->preferredSpatialLayer > encoding.spatialLayers - 1)
this->preferredSpatialLayer = encoding.spatialLayers - 1;
if (jsonTemporalLayerIt != jsonPreferredLayersIt->end() && jsonTemporalLayerIt->is_number_unsigned())
{ {
this->preferredSpatialLayer = static_cast<int16_t>(this->consumableRtpEncodings.size()) - 1; this->preferredTemporalLayer = jsonTemporalLayerIt->get<int16_t>();
if (this->preferredTemporalLayer > encoding.temporalLayers - 1)
this->preferredTemporalLayer = encoding.temporalLayers - 1;
} }
} }
else else
{ {
// Initially set preferreSpatialLayer to the maximum value. // Initially set preferreSpatialLayer and preferredTemporalLayer to the
this->preferredSpatialLayer = static_cast<int16_t>(this->consumableRtpEncodings.size()) - 1; // maximum value.
this->preferredSpatialLayer = encoding.spatialLayers - 1;
// TODO: Set initial temporal layer. this->preferredTemporalLayer = encoding.temporalLayers - 1;
} }
// Reserve space for the Producer RTP streams. // Reserve space for the Producer RTP streams.
...@@ -97,6 +110,15 @@ namespace RTC ...@@ -97,6 +110,15 @@ namespace RTC
// Add currentSpatialLayer. // Add currentSpatialLayer.
jsonObject["currentSpatialLayer"] = this->currentSpatialLayer; jsonObject["currentSpatialLayer"] = this->currentSpatialLayer;
// Add preferredTemporalLayer.
jsonObject["preferredTemporalLayer"] = this->preferredTemporalLayer;
// Add targetTemporalLayer.
jsonObject["targetTemporalLayer"] = this->targetTemporalLayer;
// Add currentTemporalLayer.
jsonObject["currentTemporalLayer"] = this->currentTemporalLayer;
} }
void SimulcastConsumer::FillJsonStats(json& jsonArray) const void SimulcastConsumer::FillJsonStats(json& jsonArray) const
...@@ -159,10 +181,8 @@ namespace RTC ...@@ -159,10 +181,8 @@ namespace RTC
auto preferredSpatialLayer = jsonSpatialLayerIt->get<int16_t>(); auto preferredSpatialLayer = jsonSpatialLayerIt->get<int16_t>();
if (preferredSpatialLayer >= static_cast<int16_t>(this->consumableRtpEncodings.size())) if (preferredSpatialLayer > this->rtpStream->GetSpatialLayers() - 1)
{ preferredSpatialLayer = this->rtpStream->GetSpatialLayers() - 1;
preferredSpatialLayer = static_cast<int16_t>(this->consumableRtpEncodings.size()) - 1;
}
if (preferredSpatialLayer == this->preferredSpatialLayer) if (preferredSpatialLayer == this->preferredSpatialLayer)
{ {
...@@ -545,6 +565,9 @@ namespace RTC ...@@ -545,6 +565,9 @@ namespace RTC
auto& encoding = this->rtpParameters.encodings[0]; auto& encoding = this->rtpParameters.encodings[0];
auto* mediaCodec = this->rtpParameters.GetCodecForEncoding(encoding); auto* mediaCodec = this->rtpParameters.GetCodecForEncoding(encoding);
MS_DEBUG_TAG(
rtp, "[ssrc:%" PRIu32 ", payloadType:%" PRIu8 "]", encoding.ssrc, mediaCodec->payloadType);
// Set stream params. // Set stream params.
RTC::RtpStream::Params params; RTC::RtpStream::Params params;
...@@ -559,7 +582,7 @@ namespace RTC ...@@ -559,7 +582,7 @@ namespace RTC
// Check in band FEC in codec parameters. // Check in band FEC in codec parameters.
if (mediaCodec->parameters.HasInteger("useinbandfec") && mediaCodec->parameters.GetInteger("useinbandfec") == 1) if (mediaCodec->parameters.HasInteger("useinbandfec") && mediaCodec->parameters.GetInteger("useinbandfec") == 1)
{ {
MS_DEBUG_TAG(rtcp, "in band FEC enabled"); MS_DEBUG_TAG(rtp, "in band FEC enabled");
params.useInBandFec = true; params.useInBandFec = true;
} }
...@@ -567,7 +590,7 @@ namespace RTC ...@@ -567,7 +590,7 @@ namespace RTC
// Check DTX in codec parameters. // Check DTX in codec parameters.
if (mediaCodec->parameters.HasInteger("usedtx") && mediaCodec->parameters.GetInteger("usedtx") == 1) if (mediaCodec->parameters.HasInteger("usedtx") && mediaCodec->parameters.GetInteger("usedtx") == 1)
{ {
MS_DEBUG_TAG(rtcp, "DTX enabled"); MS_DEBUG_TAG(rtp, "DTX enabled");
params.useDtx = true; params.useDtx = true;
} }
...@@ -575,7 +598,7 @@ namespace RTC ...@@ -575,7 +598,7 @@ namespace RTC
// Check DTX in the encoding. // Check DTX in the encoding.
if (encoding.dtx) if (encoding.dtx)
{ {
MS_DEBUG_TAG(rtcp, "DTX enabled"); MS_DEBUG_TAG(rtp, "DTX enabled");
params.useDtx = true; params.useDtx = true;
} }
...@@ -584,19 +607,19 @@ namespace RTC ...@@ -584,19 +607,19 @@ namespace RTC
{ {
if (!params.useNack && fb.type == "nack" && fb.parameter == "") if (!params.useNack && fb.type == "nack" && fb.parameter == "")
{ {
MS_DEBUG_2TAGS(rtcp, rtx, "NACK supported"); MS_DEBUG_2TAGS(rtp, rtcp, "NACK supported");
params.useNack = true; params.useNack = true;
} }
else if (!params.usePli && fb.type == "nack" && fb.parameter == "pli") else if (!params.usePli && fb.type == "nack" && fb.parameter == "pli")
{ {
MS_DEBUG_TAG(rtcp, "PLI supported"); MS_DEBUG_2TAGS(rtp, rtcp, "PLI supported");
params.usePli = true; params.usePli = true;
} }
else if (!params.useFir && fb.type == "ccm" && fb.parameter == "fir") else if (!params.useFir && fb.type == "ccm" && fb.parameter == "fir")
{ {
MS_DEBUG_TAG(rtcp, "FIR supported"); MS_DEBUG_2TAGS(rtp, rtcp, "FIR supported");
params.useFir = true; params.useFir = true;
} }
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论