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

Fix ortc.getConsumerRtpParameters()

上级 1369b9f5
...@@ -379,10 +379,8 @@ exports.getConsumableRtpParameters = function(params, caps, rtpMapping) ...@@ -379,10 +379,8 @@ exports.getConsumableRtpParameters = function(params, caps, rtpMapping)
/** /**
* Generate RTP parameters for a specific Consumer. * Generate RTP parameters for a specific Consumer.
* *
* NOTE: All the codecs of the consumable RTP parameters are copied verbatim * NOTE: It's up to theremote Consumer to check the codecs and decide whether it
* (all but RTX codecs in case the Peer does not support RTX). It's up to the * can enable this Consumer or not.
* remote Consumer to check the codecs and decide whether it can enable this
* Consumer or not.
* *
* @param {RTCRtpParameters} consumableRtpParameters - Consumable RTP parameters. * @param {RTCRtpParameters} consumableRtpParameters - Consumable RTP parameters.
* @param {RTCRtpCapabilities} rtpCapabilities - Peer RTP capabilities. * @param {RTCRtpCapabilities} rtpCapabilities - Peer RTP capabilities.
...@@ -400,24 +398,25 @@ exports.getConsumerRtpParameters = function(consumableRtpParameters, rtpCapabili ...@@ -400,24 +398,25 @@ exports.getConsumerRtpParameters = function(consumableRtpParameters, rtpCapabili
rtcp : consumableRtpParameters.rtcp rtcp : consumableRtpParameters.rtcp
}; };
const consumableCodecs = utils.cloneObject(consumableRtpParameters.codecs);
let rtxSupported = false; let rtxSupported = false;
consumerParams.codecs = consumableRtpParameters.codecs for (const codec of consumableCodecs)
.filter((codec) => {
{ const matchedCapCodec = rtpCapabilities.codecs
if (codec.name.toLowerCase() !== 'rtx') .find((capCodec) => capCodec.preferredPayloadType === codec.payloadType);
return true;
if (!matchedCapCodec)
continue;
const hasRtxCodec = rtpCapabilities.codecs // Reduce RTCP feedbacks.
.some((capCodec) => capCodec.preferredPayloadType === codec.payloadType); codec.rtcpFeedback = matchedCapCodec.rtcpFeedback;
if (hasRtxCodec) consumerParams.codecs.push(codec);
{
rtxSupported = true;
return true; if (!rtxSupported && codec.name.toLowerCase() === 'rtx')
} rtxSupported = true;
}); }
consumerParams.headerExtensions = consumableRtpParameters.headerExtensions consumerParams.headerExtensions = consumableRtpParameters.headerExtensions
.filter((ext) => .filter((ext) =>
......
...@@ -18,14 +18,8 @@ namespace RTC ...@@ -18,14 +18,8 @@ namespace RTC
/* Instance methods. */ /* Instance methods. */
Consumer::Consumer( Consumer::Consumer(
Channel::Notifier* notifier, Channel::Notifier* notifier, uint32_t consumerId, RTC::Media::Kind kind, uint32_t sourceProducerId)
uint32_t consumerId, : consumerId(consumerId), kind(kind), sourceProducerId(sourceProducerId), notifier(notifier)
RTC::Media::Kind kind,
uint32_t sourceProducerId)
: consumerId(consumerId),
kind(kind),
sourceProducerId(sourceProducerId),
notifier(notifier)
{ {
MS_TRACE(); MS_TRACE();
...@@ -151,7 +145,7 @@ namespace RTC ...@@ -151,7 +145,7 @@ namespace RTC
if (IsEnabled()) if (IsEnabled())
Disable(); Disable();
this->transport = transport; this->transport = transport;
this->rtpParameters = rtpParameters; this->rtpParameters = rtpParameters;
FillSupportedCodecPayloadTypes(); FillSupportedCodecPayloadTypes();
......
...@@ -455,8 +455,7 @@ namespace RTC ...@@ -455,8 +455,7 @@ namespace RTC
return; return;
} }
consumer = new RTC::Consumer( consumer = new RTC::Consumer(this->notifier, consumerId, kind, producer->producerId);
this->notifier, consumerId, kind, producer->producerId);
// If the Producer is paused tell it to the new Consumer. // If the Producer is paused tell it to the new Consumer.
if (producer->IsPaused()) if (producer->IsPaused())
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论