提交 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) =>
{ {
if (codec.name.toLowerCase() !== 'rtx') const matchedCapCodec = rtpCapabilities.codecs
return true; .find((capCodec) => capCodec.preferredPayloadType === codec.payloadType);
const hasRtxCodec = rtpCapabilities.codecs if (!matchedCapCodec)
.some((capCodec) => capCodec.preferredPayloadType === codec.payloadType); continue;
if (hasRtxCodec) // Reduce RTCP feedbacks.
{ codec.rtcpFeedback = matchedCapCodec.rtcpFeedback;
rtxSupported = true;
return true; consumerParams.codecs.push(codec);
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();
......
...@@ -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 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论