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

Adding stuff to Producer

上级 92504600
......@@ -420,13 +420,6 @@ class Peer extends EnhancedEventEmitter
this._sandbox.adaptProducerRtpParametersToRtpCapabilities(
rtpParameters);
// console.log('------ createProducer: original rtpParameters:');
// console.log(JSON.stringify(rtpParameters, null, ' '));
// console.log('------ createProducer: new rtpParameters:');
// console.log(JSON.stringify(adaptedRtpParameters, null, ' '));
// console.log('------ rtp mapping::');
// console.log(JSON.stringify(rtpMapping, null, ' '));
return this._createProducer(id, kind, transportId)
.then((producer) =>
{
......@@ -522,6 +515,45 @@ class Peer extends EnhancedEventEmitter
break;
}
case 'closeProducer':
{
const { id, appData } = notification;
const producer = this._producers.get(id);
if (!producer)
throw new Error('Producer not found');
producer.remoteClose(appData);
break;
}
case 'pauseProducer':
{
const { id, appData } = notification;
const producer = this._producers.get(id);
if (!producer)
throw new Error('Producer not found');
producer.remotePause(appData);
break;
}
case 'resumeProducer':
{
const { id, appData } = notification;
const producer = this._producers.get(id);
if (!producer)
throw new Error('Producer not found');
producer.remoteResume(appData);
break;
}
default:
throw new Error(`unknown notification method "${method}"`);
}
......@@ -630,7 +662,7 @@ class Peer extends EnhancedEventEmitter
// Store the Producer and remove it when closed.
this._producers.set(producer.id, producer);
producer.on('@close', () => this._producers.delete(producer.id));
producer.on('@close', () =>this._producers.delete(producer.id));
producer.on('@notify', (method, data2) =>
{
......@@ -638,7 +670,11 @@ class Peer extends EnhancedEventEmitter
});
// On Transport closure close the Producer.
transport.on('close', () => producer.close());
transport.on('close', () =>
{
if (!producer.closed)
producer.close();
});
this.emit('@newproducer', producer);
this.safeEmit('newproducer', producer);
......
......@@ -230,8 +230,9 @@ class Producer extends EnhancedEventEmitter
* @private
*
* @param {Any} [appData] - App custom data.
* @param {Boolean} [notifyChannel=true] - Private.
*/
remoteClose(appData)
remoteClose(appData, notifyChannel = true)
{
logger.debug('remoteClose()');
......@@ -243,7 +244,7 @@ class Producer extends EnhancedEventEmitter
this.emit('@close');
this.safeEmit('close', 'remote', appData);
this._destroy();
this._destroy(notifyChannel);
}
_destroy(notifyChannel = true)
......
......@@ -207,8 +207,9 @@ class Transport extends EnhancedEventEmitter
* @private
*
* @param {Any} [appData] - App custom data.
* @param {Boolean} [notifyChannel=true] - Private.
*/
remoteClose(appData)
remoteClose(appData, notifyChannel = true)
{
logger.debug('remoteClose()');
......@@ -220,7 +221,7 @@ class Transport extends EnhancedEventEmitter
this.emit('@close');
this.safeEmit('close', 'remote', appData);
this._destroy();
this._destroy(notifyChannel);
}
_destroy(notifyChannel = true)
......
......@@ -404,9 +404,12 @@ namespace RTC
{
MS_TRACE();
// TODO: This happens often for first RTX packets. May be the browser sends empty
// RTX packets (for any reason). If so, we should move this to MS_DEBUG_TAG.
if (this->payloadLength < 2)
{
MS_WARN_TAG(rtx, "not enough space for a RTX header field");
return false;
}
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论