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

It works. Some details (and all the RTCP) missing.

上级 d5dfd661
# TODO in mediasoup v2 (server-side)
* Revisar appData en todos los mensajes.
* When a Peer disconnect, others receive `peerClosed` and later `consumerClosed` for each Consumer associated to the closed Peer, so the client side complains ("peer not found"). We should avoid sending `consumerClosed` if its Peer left.
* Revisar que si un Producer JS empieza pausado, esté tb pausado en el worker y en el Consumer JS asociado. Y que si un Consumer JS se habilita pausado, que se entere tb el Consumer del worker.
- Y que si un Producer se pausa (y, por lo tanto, sus Consumers están "sourcePaused") al hacer `enable()` en esos Consumers se le diga al cliente que están pausados.
* Implement `consumer.sourcePause/Resume()`.
- No. This should be done in the Worker. When the Producer gets paused it should call `Router::OnProducerPaused()` so it calls `Consumer::SourcePause()` to all its Consumers, and each Consumer emits "paused/resumed".
* Revisar appData en todos los mensajes.
* Remove DEPTH stuff.
......@@ -19,9 +21,6 @@
+ I must avoid unnecesary `Promise.resolve()`.
- "The callback passed to a Promise constructor is always called synchronously, but the callbacks passed into then are always called asynchronously"
* worker: If a `Producer` is paused and a new `Peer` joins (so a new `Consumer` is generated) such a new `Consumer` does not know that its associated `Producer` is paused. When creating a `Consumer` the `Room` should check `producer->IsPaused()` and call `consumer->setSourcePaused(true)` or similar.
- NOTE: Won't happen with the new design since that's done in JS land.
* May have to react on DTLS ALERT CLOSE in the server and make it "really" close the Transport and notify the client. Bufff... I don't like this...
* Upon a `updateProducer` notification, map the new SSRCs of the `Producer` and send a PLI back to the browser (otherwise, consumers will get frozen video).
......
......@@ -159,7 +159,13 @@ class Consumer extends EnhancedEventEmitter
this._closed = true;
this.emit('@notify', 'consumerClosed', { id: this.id });
const data =
{
id : this.id,
peerName : this.peer.name
};
this.emit('@notify', 'consumerClosed', data);
this.emit('@close');
this.safeEmit('close');
......@@ -246,11 +252,10 @@ class Consumer extends EnhancedEventEmitter
else if (this.enabled)
return Promise.reject(new errors.InvalidStateError('Consumer already enabled'));
const internal = Object.assign(
const internal = Object.assign({}, this._internal,
{
transportId : transport.id
},
this._internal);
});
const data = Object.assign({ transport }, this._data);
......@@ -307,7 +312,16 @@ class Consumer extends EnhancedEventEmitter
}
if (!this._sourcePaused)
this.emit('@notify', 'consumerPaused', { id: this.id, appData });
{
const data =
{
id : this.id,
peerName : this.peer.name,
appData : appData
};
this.emit('@notify', 'consumerPaused', data);
}
this._locallyPaused = true;
......@@ -365,25 +379,6 @@ class Consumer extends EnhancedEventEmitter
this.safeEmit('pause', 'remote', appData);
}
/**
* The associated source (Producer) has been paused.
*
* @private
*
* @param {Any} [appData] - App custom data.
*/
sourcePause(appData)
{
logger.debug('sourcePause()');
if (this._closed || this._sourcePaused)
return;
this._sourcePaused = true;
// TODO
}
/**
* Resumes sending media.
*
......@@ -407,7 +402,16 @@ class Consumer extends EnhancedEventEmitter
}
if (!this._sourcePaused)
this.emit('@notify', 'consumerResumed', { id: this.id, appData });
{
const data =
{
id : this.id,
peerName : this.peer.name,
appData : appData
};
this.emit('@notify', 'consumerResumed', data);
}
this._locallyPaused = false;
......@@ -465,25 +469,6 @@ class Consumer extends EnhancedEventEmitter
this.safeEmit('resume', 'remote', appData);
}
/**
* The associated source (Producer) has been resumed.
*
* @private
*
* @param {Any} [appData] - App custom data.
*/
sourceResume(appData)
{
logger.debug('sourceResume()');
if (this._closed || !this._sourcePaused)
return;
this._sourcePaused = false;
// TODO
}
_handleWorkerNotifications()
{
// Subscribe to notifications.
......@@ -498,6 +483,52 @@ class Consumer extends EnhancedEventEmitter
break;
}
case 'sourcepaused':
{
if (this._sourcePaused)
return;
if (!this._locallyPaused)
{
const data =
{
id : this.id,
peerName : this.peer.name
};
this.emit('@notify', 'consumerPaused', data);
}
this._sourcePaused = true;
this.safeEmit('pause', 'source');
break;
}
case 'sourceresumed':
{
if (!this._sourcePaused)
return;
if (!this._locallyPaused)
{
const data =
{
id : this.id,
peerName : this.peer.name
};
this.emit('@notify', 'consumerResumed', data);
}
this._sourcePaused = false;
this.safeEmit('resume', 'source');
break;
}
default:
logger.error('ignoring unknown event "%s"', event);
}
......
......@@ -4,6 +4,7 @@ const Logger = require('./Logger');
const EnhancedEventEmitter = require('./EnhancedEventEmitter');
const utils = require('./utils');
const errors = require('./errors');
const ortc = require('./ortc');
const Transport = require('./Transport');
const Producer = require('./Producer');
const Consumer = require('./Consumer');
......@@ -406,11 +407,8 @@ class Peer extends EnhancedEventEmitter
else if (!transport)
return Promise.reject(new TypeError('Transport not found'));
// TODO: Get the RtpParameters of the associated Producer and "merge"
// them with the Peer's rtpCapabilities to produce sending rtpParameters.
const rtpParameters = {};
return consumer.enable(transport, rtpParameters);
return consumer.enable(transport)
.then(() => {});
}
default:
......@@ -575,12 +573,16 @@ class Peer extends EnhancedEventEmitter
transportId : undefined
};
const consumerRtpParameters =
ortc.getConsumerRtpParameters(
producer.consumableRtpParameters, this.rtpCapabilities);
const data =
{
kind : producer.kind,
peer : producer.peer,
transport : undefined,
rtpParameters : [], // TODO
rtpParameters : consumerRtpParameters,
source : producer
};
......@@ -669,11 +671,24 @@ class Peer extends EnhancedEventEmitter
else if (!KINDS.has(kind))
return Promise.reject(new TypeError(`unsupported kind: ${kind}`));
let rtpMapping;
let rtpMappingForWorker;
let consumableRtpParameters;
try
{
rtpMapping = this._sandbox.getProducerRtpParametersMapping(rtpParameters);
const rtpMapping =
this._sandbox.getProducerRtpParametersMapping(rtpParameters);
// NOTE: rtpMapping has two Maps, but we need to convert them into arrays
// of pairs for the worker.
rtpMappingForWorker =
{
codecPayloadTypes : Array.from(rtpMapping.mapCodecPayloadTypes),
headerExtensionIds : Array.from(rtpMapping.mapHeaderExtensionIds)
};
consumableRtpParameters =
this._sandbox.getConsumableRtpParameters(rtpParameters, rtpMapping);
}
catch (error)
{
......@@ -694,17 +709,18 @@ class Peer extends EnhancedEventEmitter
const data =
{
kind : kind,
peer : this,
transport : transport,
rtpParameters : rtpParameters
kind : kind,
peer : this,
transport : transport,
rtpParameters : rtpParameters,
consumableRtpParameters : consumableRtpParameters
};
return this._channel.request('router.createProducer', internal,
{
kind,
rtpParameters,
rtpMapping
kind : kind,
rtpParameters : rtpParameters,
rtpMapping : rtpMappingForWorker
})
.then(() =>
{
......
......@@ -28,6 +28,7 @@ class Producer extends EnhancedEventEmitter
// - .peer
// - .transport
// - .rtpParameters
// - .consumableRtpParameters
this._data = data;
// Channel instance.
......@@ -89,6 +90,11 @@ class Producer extends EnhancedEventEmitter
return this._data.rtpParameters;
}
get consumableRtpParameters()
{
return this._data.consumableRtpParameters;
}
/**
* Whether the Producer is locally paused.
*
......@@ -138,7 +144,16 @@ class Producer extends EnhancedEventEmitter
// the client-side Producer. Otherwise, if the Transport is closed the client-side
// Producer will get 'unhandled', so don't close it from here.
if (!this.transport.closed)
this.emit('@notify', 'producerClosed', { id: this.id, appData });
{
const data =
{
id : this.id,
peerName : this.peer.name,
appData : appData
};
this.emit('@notify', 'producerClosed', data);
}
this.emit('@close');
this.safeEmit('close', 'local', appData);
......@@ -278,7 +293,14 @@ class Producer extends EnhancedEventEmitter
return true;
}
this.emit('@notify', 'producerPaused', { id: this.id, appData });
const data =
{
id : this.id,
peerName : this.peer.name,
appData : appData
};
this.emit('@notify', 'producerPaused', data);
this._locallyPaused = true;
......@@ -352,7 +374,14 @@ class Producer extends EnhancedEventEmitter
return true;
}
this.emit('@notify', 'producerResumed', { id: this.id, appData });
const data =
{
id : this.id,
peerName : this.peer.name,
appData : appData
};
this.emit('@notify', 'producerResumed', data);
this._locallyPaused = false;
......
......@@ -239,10 +239,17 @@ class Room extends EnhancedEventEmitter
const sandbox =
{
// NOTE: This may throw.
getProducerRtpParametersMapping : (rtpParameters) =>
getProducerRtpParametersMapping : (producerRtpParameters) =>
{
return ortc.getProducerRtpParametersMapping(
rtpParameters, this.rtpCapabilities);
producerRtpParameters, this.rtpCapabilities);
},
// NOTE: This may throw.
getConsumableRtpParameters : (producerRtpParameters, rtpMapping) =>
{
return ortc.getConsumableRtpParameters(
producerRtpParameters, this.rtpCapabilities, rtpMapping);
}
};
......
'use strict';
const utils = require('./utils');
const supportedRtpCapabilities = require('./supportedRtpCapabilities');
const DYNAMIC_PAYLOAD_TYPES =
......@@ -155,16 +156,15 @@ exports.assertCapabilitiesSubset = function(capsA, capsB)
};
/**
* Generate an Object with RTP parameters and RTP mapping.
* Generate a mapping of codec payload types and header extension ids that maps
* the RTP parameters of a Producer and the associated values in the RTP
* capabilities of the Room.
* It may throw if invalid or non supported RTP parameters are given.
*
* @param {RTCRtpParameters} params
* @param {RTCRtpCapabilities} caps
*
* @return {Object}
*
* TODO: This method should also reduce encodings in case of simulcast/SVC
* so the resulting consumableRtpParameters are suitable for a Consumer.
*/
exports.getProducerRtpParametersMapping = function(params, caps)
{
......@@ -252,9 +252,218 @@ exports.getProducerRtpParametersMapping = function(params, caps)
}
return {
codecPayloadTypes : Array.from(mapCodecPayloadTypes),
headerExtensionIds : Array.from(mapHeaderExtensionIds)
mapCodecPayloadTypes,
mapHeaderExtensionIds
};
};
/**
* Generate RTP parameters for Consumers given the RTP parameters of a Producer
* and the RTP capabilities of the Room.
* It may throw if invalid or non supported RTP parameters are given.
*
* TODO: This method should also reduce encodings in case of simulcast/SVC
* so the resulting consumable RTP parameters are suitable for a Consumer.
* For now we assume a single encoding in the Producer RTP parameters.
*
* @param {RTCRtpParameters} params
* @param {RTCRtpCapabilities} caps
* @param {Object} rtpMapping - As generated by getProducerRtpParametersMapping().
*
* @return {RTCRtpParameters}
*/
exports.getConsumableRtpParameters = function(params, caps, rtpMapping)
{
const { mapCodecPayloadTypes, mapHeaderExtensionIds } = rtpMapping;
const consumableParams =
{
muxId : params.muxId,
codecs : [],
headerExtensions : [],
encodings : params.encodings,
rtcp : params.rtcp
};
for (const codec of params.codecs)
{
if (codec.name.toLowerCase() === 'rtx')
continue;
const consumableCodecPt = mapCodecPayloadTypes.get(codec.payloadType);
if (!consumableCodecPt)
{
throw new Error(
`codec payloadType mapping not found [name:${codec.name}]`);
}
const matchedCapCodec = caps.codecs
.find((capCodec) => capCodec.preferredPayloadType === consumableCodecPt);
if (!matchedCapCodec)
throw new Error(`capabilities codec not found [name:${codec.name}]`);
const consumableCodec =
{
name : matchedCapCodec.name,
mimeType : matchedCapCodec.mimeType,
clockRate : matchedCapCodec.clockRate,
payloadType : matchedCapCodec.preferredPayloadType,
channels : matchedCapCodec.channels,
rtcpFeedback : matchedCapCodec.rtcpFeedback,
parameters : matchedCapCodec.parameters
};
if (!consumableCodec.channels)
delete consumableCodec.channels;
consumableParams.codecs.push(consumableCodec);
const consumableCapRtxCodec = caps.codecs
.find((capRtxCodec) =>
{
return (
capRtxCodec.name.toLowerCase() === 'rtx' &&
capRtxCodec.parameters.apt === consumableCodec.payloadType
);
});
if (consumableCapRtxCodec)
{
const consumableRtxCodec =
{
name : consumableCapRtxCodec.name,
mimeType : consumableCapRtxCodec.mimeType,
clockRate : consumableCapRtxCodec.clockRate,
payloadType : consumableCapRtxCodec.preferredPayloadType,
channels : consumableCapRtxCodec.channels,
rtcpFeedback : consumableCapRtxCodec.rtcpFeedback,
parameters : consumableCapRtxCodec.parameters
};
if (!consumableRtxCodec.channels)
delete consumableRtxCodec.channels;
consumableParams.codecs.push(consumableRtxCodec);
}
}
for (const ext of params.headerExtensions)
{
const consumableExtId = mapHeaderExtensionIds.get(ext.id);
if (!consumableExtId)
{
throw new Error(
`extension header id mapping not found [uri:${ext.uri}]`);
}
const matchedCapExt = caps.headerExtensions
.find((capExt) => capExt.preferredId === consumableExtId);
if (!matchedCapExt)
throw new Error(`capabilities header extension not found [uri:${ext.uri}]`);
const consumableExt =
{
uri : matchedCapExt.uri,
id : matchedCapExt.preferredId
};
consumableParams.headerExtensions.push(consumableExt);
}
// TODO: REMOVE
// console.log('consumableParams:\n', JSON.stringify(consumableParams, null, ' '));
return consumableParams;
};
/**
* Generate RTP parameters for a specific Consumer.
*
* @param {RTCRtpParameters} consumableRtpParameters - Consumable RTP parameters.
* @param {RTCRtpCapabilities} rtpCapabilities - Peer RTP capabilities.
*
* @return {RTCRtpParameters}
*/
exports.getConsumerRtpParameters = function(consumableRtpParameters, rtpCapabilities)
{
const consumerParams =
{
muxId : consumableRtpParameters.muxId,
codecs : [],
headerExtensions : [],
encodings : [],
rtcp : consumableRtpParameters.rtcp
};
let rtxSupported = false;
for (const codec of consumableRtpParameters.codecs)
{
const matchedCapCodec = rtpCapabilities.codecs
.find((capCodec) => capCodec.preferredPayloadType === codec.payloadType);
if (!matchedCapCodec)
continue;
const consumerCodec =
{
name : matchedCapCodec.name,
mimeType : matchedCapCodec.mimeType,
clockRate : matchedCapCodec.clockRate,
payloadType : matchedCapCodec.preferredPayloadType,
channels : matchedCapCodec.channels,
rtcpFeedback : matchedCapCodec.rtcpFeedback,
parameters : matchedCapCodec.parameters
};
if (!consumerCodec.channels)
delete consumerCodec.channels;
consumerParams.codecs.push(consumerCodec);
if (consumerCodec.name.toLowerCase() === 'rtx')
rtxSupported = true;
}
for (const ext of consumableRtpParameters.headerExtensions)
{
const matchedCapExt = rtpCapabilities.headerExtensions
.find((capExt) => capExt.preferredId === ext.id);
if (!matchedCapExt)
continue;
const consumerExt =
{
uri : matchedCapExt.uri,
id : matchedCapExt.preferredId
};
consumerParams.headerExtensions.push(consumerExt);
}
const consumerEncoding =
{
ssrc : consumableRtpParameters.encodings[0].ssrc
};
if (rtxSupported)
{
consumerEncoding.rtx =
{
ssrc : utils.randomNumber()
};
}
consumerParams.encodings.push(consumerEncoding);
// TODO: REMOVE
// console.log('consumerParams:\n', JSON.stringify(consumerParams, null, ' '));
return consumerParams;
};
function assertCodecCapability(codec)
......
......@@ -40,6 +40,8 @@ namespace RTC
void AddListener(RTC::ConsumerListener* listener);
void RemoveListener(RTC::ConsumerListener* listener);
const RTC::RtpParameters& GetParameters() const;
void SetSourcePaused();
void SetSourceResumed();
void SendRtpPacket(RTC::RtpPacket* packet);
void GetRtcp(RTC::RTCP::CompoundPacket* packet, uint64_t now);
void ReceiveNack(RTC::RTCP::FeedbackRtpNackPacket* nackPacket);
......@@ -69,6 +71,7 @@ namespace RTC
// Others.
std::unordered_set<uint8_t> supportedCodecPayloadTypes;
bool paused{ false };
bool sourcePaused{ false };
// Timestamp when last RTCP was sent.
uint64_t lastRtcpSentTime{ 0 };
uint16_t maxRtcpInterval{ 0 };
......@@ -94,6 +97,24 @@ namespace RTC
return this->rtpParameters;
}
inline void Consumer::SetSourcePaused()
{
if (this->sourcePaused)
return;
this->sourcePaused = true;
this->notifier->Emit(this->consumerId, "sourcepaused");
}
inline void Consumer::SetSourceResumed()
{
if (!this->sourcePaused)
return;
this->sourcePaused = false;
this->notifier->Emit(this->consumerId, "sourceresumed");
}
inline uint32_t Consumer::GetTransmissionRate(uint64_t now)
{
return this->transmittedCounter.GetRate(now) + this->retransmittedCounter.GetRate(now);
......
......@@ -13,6 +13,8 @@ namespace RTC
{
public:
virtual void OnProducerClosed(RTC::Producer* producer) = 0;
virtual void OnProducerPaused(RTC::Producer* producer) = 0;
virtual void OnProducerResumed(RTC::Producer* producer) = 0;
virtual void OnProducerRtpPacket(RTC::Producer* producer, RTC::RtpPacket* packet) = 0;
};
} // namespace RTC
......
......@@ -66,6 +66,8 @@ namespace RTC
/* Pure virtual methods inherited from RTC::ProducerListener. */
public:
void OnProducerClosed(RTC::Producer* producer) override;
void OnProducerPaused(RTC::Producer* producer) override;
void OnProducerResumed(RTC::Producer* producer) override;
void OnProducerRtpPacket(RTC::Producer* producer, RTC::RtpPacket* packet) override;
/* Pure virtual methods inherited from RTC::ConsumerListener. */
......
......@@ -131,6 +131,8 @@ namespace RTC
/* Pure virtual methods inherited from RTC::ProducerListener. */
public:
void OnProducerClosed(RTC::Producer* producer) override;
void OnProducerPaused(RTC::Producer* producer) override;
void OnProducerResumed(RTC::Producer* producer) override;
void OnProducerRtpPacket(RTC::Producer* producer, RTC::RtpPacket* packet) override;
/* Pure virtual methods inherited from RTC::ConsumerListener. */
......
......@@ -52,7 +52,6 @@ namespace RTC
{
MS_TRACE();
// Notify the listeners.
for (auto& listener : this->listeners)
{
listener->OnConsumerClosed(this);
......
......@@ -60,7 +60,6 @@ namespace RTC
{
MS_TRACE();
// Notify the listeners.
for (auto& listener : this->listeners)
{
listener->OnProducerClosed(this);
......@@ -132,10 +131,20 @@ namespace RTC
case Channel::Request::MethodId::PRODUCER_PAUSE:
{
bool wasPaused = this->paused;
this->paused = true;
request->Accept();
if (!wasPaused)
{
for (auto& listener : this->listeners)
{
listener->OnProducerPaused(this);
}
}
break;
}
......@@ -148,7 +157,14 @@ namespace RTC
request->Accept();
if (wasPaused)
{
for (auto& listener : this->listeners)
{
listener->OnProducerResumed(this);
}
RequestFullFrame();
}
break;
}
......@@ -276,7 +292,6 @@ namespace RTC
// Apply the Producer RTP mapping before dispatching the packet to the Router.
ApplyRtpMapping(packet);
// Notify the listener.
for (auto& listener : this->listeners)
{
listener->OnProducerRtpPacket(this, packet);
......
......@@ -830,6 +830,38 @@ namespace RTC
this->mapProducerAudioLevelContainer.erase(producer);
}
void Router::OnProducerPaused(RTC::Producer* producer)
{
MS_TRACE();
MS_ASSERT(
this->mapProducerConsumers.find(producer) != this->mapProducerConsumers.end(),
"Producer not present in mapProducerConsumers");
auto& consumers = this->mapProducerConsumers[producer];
for (auto& consumer : consumers)
{
consumer->SetSourcePaused();
}
}
void Router::OnProducerResumed(RTC::Producer* producer)
{
MS_TRACE();
MS_ASSERT(
this->mapProducerConsumers.find(producer) != this->mapProducerConsumers.end(),
"Producer not present in mapProducerConsumers");
auto& consumers = this->mapProducerConsumers[producer];
for (auto& consumer : consumers)
{
consumer->SetSourceResumed();
}
}
void Router::OnProducerRtpPacket(RTC::Producer* producer, RTC::RtpPacket* packet)
{
MS_TRACE();
......@@ -871,8 +903,6 @@ namespace RTC
{
MS_TRACE();
// TODO: How to tell the Transport using this Consumer.
this->consumers.erase(consumer->consumerId);
for (auto& kv : this->mapProducerConsumers)
......
......@@ -25,7 +25,7 @@ namespace RTC
if (!data.isObject())
MS_THROW_ERROR("RtpCodecParameters is not an object");
// `mimeType` is mandatory.
// mimeType is mandatory.
if (!data[JsonStringMimeType].isString())
MS_THROW_ERROR("missing RtpCodec.mimeType");
......@@ -40,29 +40,29 @@ namespace RTC
this->payloadType = static_cast<uint8_t>(data[JsonStringPayloadType].asUInt());
// `clockRate` is mandatory.
// clockRate is mandatory.
if (!data[JsonStringClockRate].isUInt())
MS_THROW_ERROR("missing RtpCodecParameters.clockRate");
this->clockRate = uint32_t{ data[JsonStringClockRate].asUInt() };
// `maxptime` is optional.
// maxptime is optional.
if (data[JsonStringMaxptime].isUInt())
this->maxptime = uint32_t{ data[JsonStringMaxptime].asUInt() };
// `ptime` is optional.
// ptime is optional.
if (data[JsonStringPtime].isUInt())
this->ptime = uint32_t{ data[JsonStringPtime].asUInt() };
// `channels` is optional.
// channels is optional.
if (data[JsonStringNumChannels].isUInt())
this->channels = uint32_t{ data[JsonStringNumChannels].asUInt() };
// `parameters` is optional.
// parameters is optional.
if (data[JsonStringParameters].isObject())
this->parameters.Set(data[JsonStringParameters]);
// `rtcpFeedback` is optional.
// rtcpFeedback is optional.
if (data[JsonStringRtcpFeedback].isArray())
{
auto& jsonRtcpFeedback = data[JsonStringRtcpFeedback];
......@@ -96,34 +96,34 @@ namespace RTC
Json::Value json(Json::objectValue);
// Add `mimeType`.
// Add mimeType.
json[JsonStringMimeType] = this->mime.ToString();
// Add `name`.
// Add name.
json[JsonStringName] = this->mime.GetName();
// Add `payloadType`.
// Add payloadType.
json[JsonStringPayloadType] = Json::UInt{ this->payloadType };
// Add `clockRate`.
// Add clockRate.
json[JsonStringClockRate] = Json::UInt{ this->clockRate };
// Add `maxptime`.
// Add maxptime.
if (this->maxptime != 0u)
json[JsonStringMaxptime] = Json::UInt{ this->maxptime };
// Add `ptime`.
// Add ptime.
if (this->ptime != 0u)
json[JsonStringPtime] = Json::UInt{ this->ptime };
// Add `channels`.
// Add channels.
if (this->channels > 1)
json[JsonStringNumChannels] = Json::UInt{ this->channels };
// Add `parameters`.
// Add parameters.
json[JsonStringParameters] = this->parameters.ToJson();
// Add `rtcpFeedback`.
// Add rtcpFeedback.
json[JsonStringRtcpFeedback] = Json::arrayValue;
for (auto& entry : this->rtcpFeedback)
......
......@@ -27,52 +27,52 @@ namespace RTC
if (!data.isObject())
MS_THROW_ERROR("RtpEncodingParameters is not an object");
// `codecPayloadType` is optional.
// codecPayloadType is optional.
if (data[JsonStringCodecPayloadType].isUInt())
{
this->codecPayloadType = static_cast<uint8_t>(data[JsonStringCodecPayloadType].asUInt());
this->hasCodecPayloadType = true;
}
// `ssrc` is optional.
// ssrc is optional.
if (data[JsonStringSsrc].isUInt())
this->ssrc = uint32_t{ data[JsonStringSsrc].asUInt() };
// `fec` is optional.
// fec is optional.
if (data[JsonStringFec].isObject())
{
this->fec = RtpFecParameters(data[JsonStringFec]);
this->hasFec = true;
}
// `rtx` is optional.
// rtx is optional.
if (data[JsonStringRtx].isObject())
{
this->rtx = RtpRtxParameters(data[JsonStringRtx]);
this->hasRtx = true;
}
// `resolutionScale` is optional.
// resolutionScale is optional.
if (data[JsonStringResolutionScale].isDouble())
this->resolutionScale = data[JsonStringResolutionScale].asDouble();
// `framerateScale` is optional.
// framerateScale is optional.
if (data[JsonStringFramerateScale].isDouble())
this->framerateScale = data[JsonStringFramerateScale].asDouble();
// `maxFramerate` is optional.
// maxFramerate is optional.
if (data[JsonStringMaxFramerate].isUInt())
this->maxFramerate = uint32_t{ data[JsonStringMaxFramerate].asUInt() };
// `active` is optional.
// active is optional.
if (data[JsonStringActive].isBool())
this->active = data[JsonStringActive].asBool();
// `encodingId` is optional.
// encodingId is optional.
if (data[JsonStringEncodingId].isString())
this->encodingId = data[JsonStringEncodingId].asString();
// `dependencyEncodingIds` is optional.
// dependencyEncodingIds is optional.
if (data[JsonStringDependencyEncodingIds].isArray())
{
auto& jsonArray = data[JsonStringDependencyEncodingIds];
......@@ -103,38 +103,38 @@ namespace RTC
Json::Value json(Json::objectValue);
// Add `codecPayloadType`.
// Add codecPayloadType.
if (this->hasCodecPayloadType)
json[JsonStringCodecPayloadType] = Json::UInt{ this->codecPayloadType };
// Add `ssrc`.
// Add ssrc.
if (this->ssrc != 0u)
json[JsonStringSsrc] = Json::UInt{ this->ssrc };
// Add `fec`
// Add fec
if (this->hasFec)
json[JsonStringFec] = this->fec.ToJson();
// Add `rtx`
// Add rtx
if (this->hasRtx)
json[JsonStringRtx] = this->rtx.ToJson();
// Add `resolutionScale` (if different than the default value).
// Add resolutionScale (if different than the default value).
if (this->resolutionScale != 1.0)
json[JsonStringResolutionScale] = this->resolutionScale;
// Add `framerateScale` (if different than the default value).
// Add framerateScale (if different than the default value).
if (this->framerateScale != 1.0)
json[JsonStringFramerateScale] = this->framerateScale;
// Add `maxFramerate`.
// Add maxFramerate.
if (this->maxFramerate != 0u)
json[JsonStringMaxFramerate] = Json::UInt{ this->maxFramerate };
// Add `active`.
// Add active.
json[JsonStringActive] = this->active;
// Add `encodingId`.
// Add encodingId.
if (!this->encodingId.empty())
json[JsonStringEncodingId] = this->encodingId;
......
......@@ -269,7 +269,7 @@ namespace RTC
}
// 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.
for (auto& encoding : this->encodings)
{
if (!encoding.hasCodecPayloadType)
......
......@@ -1323,6 +1323,16 @@ namespace RTC
this->rtpListener.RemoveProducer(producer);
}
void Transport::OnProducerPaused(RTC::Producer* producer)
{
// Do nothing.
}
void Transport::OnProducerResumed(RTC::Producer* producer)
{
// Do nothing.
}
void Transport::OnProducerRtpPacket(RTC::Producer* producer, RTC::RtpPacket* packet)
{
// Do nothing.
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论