Unverified 提交 11f45ffd authored 作者: Nazar Mokrynskyi's avatar Nazar Mokrynskyi 提交者: GitHub

Merge pull request #889 from nazar-pc/refactor-internal

Refactor internal
...@@ -30,7 +30,7 @@ Some considerations: ...@@ -30,7 +30,7 @@ Some considerations:
## JS router.close() ## JS router.close()
* Public API. * Public API.
* Sends channel request `ROUTER_CLOSE`: * Sends channel request `WORKER_CLOSE_ROUTER`:
- Processed by the C++ Worker. - Processed by the C++ Worker.
- It removes the C++ Router from its map. - It removes the C++ Router from its map.
- It calls C++ `delete router`. - It calls C++ `delete router`.
...@@ -51,7 +51,7 @@ Some considerations: ...@@ -51,7 +51,7 @@ Some considerations:
## JS transport.close() ## JS transport.close()
* Public API. * Public API.
* Sends channel request `TRANSPORT_CLOSE`. * Sends channel request `ROUTER_CLOSE_TRANSPORT`.
- Processed by the C++ Router. - Processed by the C++ Router.
- It calls C++ `transport->Close()` (so the C++ Transport will notify the C++ Router about closed Producers and Consumers in that Transport). - It calls C++ `transport->Close()` (so the C++ Transport will notify the C++ Router about closed Producers and Consumers in that Transport).
- It removes the C++ Transport from its map. - It removes the C++ Transport from its map.
...@@ -106,7 +106,7 @@ Some considerations: ...@@ -106,7 +106,7 @@ Some considerations:
## JS producer.close() ## JS producer.close()
* Public API. * Public API.
* Sends channel request `PRODUCER_CLOSE`. * Sends channel request `TRANSPORT_CLOSE_PRODUCER`.
- Processed by the C++ Transport. - Processed by the C++ Transport.
- Removes it from its map of Producers. - Removes it from its map of Producers.
- Calls its `listener->OnTransportProducerClosed(this, producer)` (so the C++ Router cleans its maps and calls `consumer->ProducerClose()` on its associated Consumers). - Calls its `listener->OnTransportProducerClosed(this, producer)` (so the C++ Router cleans its maps and calls `consumer->ProducerClose()` on its associated Consumers).
...@@ -125,7 +125,7 @@ Some considerations: ...@@ -125,7 +125,7 @@ Some considerations:
## JS consumer.close() ## JS consumer.close()
* Public API. * Public API.
* Sends channel request `CONSUMER_CLOSE`. * Sends channel request `TRANSPORT_CLOSE_CONSUMER`.
- Processed by the C++ Transport. - Processed by the C++ Transport.
- Removes it from its map of Consumers. - Removes it from its map of Consumers.
- Calls its `listener->OnTransportConsumerClosed(this, consumer)` (so the C++ Router cleans its maps). - Calls its `listener->OnTransportConsumerClosed(this, consumer)` (so the C++ Router cleans its maps).
......
...@@ -16,7 +16,7 @@ export declare class Channel extends EnhancedEventEmitter { ...@@ -16,7 +16,7 @@ export declare class Channel extends EnhancedEventEmitter {
/** /**
* @private * @private
*/ */
request(method: string, internal?: object, data?: any): Promise<any>; request(method: string, handlerId?: string, data?: any): Promise<any>;
private processMessage; private processMessage;
} }
//# sourceMappingURL=Channel.d.ts.map //# sourceMappingURL=Channel.d.ts.map
\ No newline at end of file
{"version":3,"file":"Channel.d.ts","sourceRoot":"","sources":["../src/Channel.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAmB9D,qBAAa,OAAQ,SAAQ,oBAAoB;;IAoBhD;;OAEG;gBAEF,EACC,cAAc,EACd,cAAc,EACd,GAAG,EACH,EACD;QACC,cAAc,EAAE,GAAG,CAAC;QACpB,cAAc,EAAE,GAAG,CAAC;QACpB,GAAG,EAAE,MAAM,CAAC;KACZ;IAiIF;;OAEG;IACH,KAAK,IAAI,IAAI;IAmCb;;OAEG;IACG,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAqD1E,OAAO,CAAC,cAAc;CA+DtB"} {"version":3,"file":"Channel.d.ts","sourceRoot":"","sources":["../src/Channel.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAmB9D,qBAAa,OAAQ,SAAQ,oBAAoB;;IAoBhD;;OAEG;gBAEF,EACC,cAAc,EACd,cAAc,EACd,GAAG,EACH,EACD;QACC,cAAc,EAAE,GAAG,CAAC;QACpB,cAAc,EAAE,GAAG,CAAC;QACpB,GAAG,EAAE,MAAM,CAAC;KACZ;IAiIF;;OAEG;IACH,KAAK,IAAI,IAAI;IAmCb;;OAEG;IACG,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAqD3E,OAAO,CAAC,cAAc;CA+DtB"}
\ No newline at end of file \ No newline at end of file
...@@ -138,13 +138,13 @@ class Channel extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -138,13 +138,13 @@ class Channel extends EnhancedEventEmitter_1.EnhancedEventEmitter {
/** /**
* @private * @private
*/ */
async request(method, internal, data) { async request(method, handlerId, data) {
this.#nextId < 4294967295 ? ++this.#nextId : (this.#nextId = 1); this.#nextId < 4294967295 ? ++this.#nextId : (this.#nextId = 1);
const id = this.#nextId; const id = this.#nextId;
logger.debug('request() [method:%s, id:%s]', method, id); logger.debug('request() [method:%s, id:%s]', method, id);
if (this.#closed) if (this.#closed)
throw new errors_1.InvalidStateError('Channel closed'); throw new errors_1.InvalidStateError('Channel closed');
const request = { id, method, internal, data }; const request = { id, method, handlerId, data };
const payload = JSON.stringify(request); const payload = JSON.stringify(request);
if (Buffer.byteLength(payload) > MESSAGE_MAX_LEN) if (Buffer.byteLength(payload) > MESSAGE_MAX_LEN)
throw new Error('Channel request too big'); throw new Error('Channel request too big');
......
{"version":3,"file":"Consumer.d.ts","sourceRoot":"","sources":["../src/Consumer.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EACN,SAAS,EACT,eAAe,EACf,aAAa,EACb,MAAM,iBAAiB,CA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AAO,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAGrC;IAED;;OAEG;IACH,IAAI,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAG3C;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,oBAAoB,CAAC,sBAAsB,CAAC,CAG3D;IAED;;;OAGG;IACH,IAAI,iBAAiB,IAAI,OAAO,CAG/B;IAED;;OAEG;IACH,KAAK,IAAI,IAAI;IAwBb;;;;OAIG;IACH,eAAe,IAAI,IAAI;IAmBvB;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC;IAO1B;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,KAAK,CAAC,YAAY,GAAG,YAAY,CAAC,CAAC;IAO7D;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAe5B;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAe7B;;OAEG;IACG,kBAAkB,CACvB,EACC,YAAY,EACZ,aAAa,EACb,EAAE,cAAc,GACf,OAAO,CAAC,IAAI,CAAC;IAYhB;;OAEG;IACG,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAYlD;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAYpC;;OAEG;IACG,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAOtC;;OAEG;IACG,gBAAgB,CAAC,KAAK,GAAE,sBAAsB,EAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAU3E,OAAO,CAAC,yBAAyB;CAsIjC"}
\ No newline at end of file \ No newline at end of file
...@@ -156,7 +156,8 @@ class Consumer extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -156,7 +156,8 @@ class Consumer extends EnhancedEventEmitter_1.EnhancedEventEmitter {
// Remove notification subscriptions. // Remove notification subscriptions.
this.#channel.removeAllListeners(this.#internal.consumerId); this.#channel.removeAllListeners(this.#internal.consumerId);
this.#payloadChannel.removeAllListeners(this.#internal.consumerId); this.#payloadChannel.removeAllListeners(this.#internal.consumerId);
this.#channel.request('consumer.close', this.#internal) const reqData = { consumerId: this.#internal.consumerId };
this.#channel.request('transport.closeConsumer', this.#internal.transportId, reqData)
.catch(() => { }); .catch(() => { });
this.emit('@close'); this.emit('@close');
// Emit observer event. // Emit observer event.
...@@ -184,14 +185,14 @@ class Consumer extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -184,14 +185,14 @@ class Consumer extends EnhancedEventEmitter_1.EnhancedEventEmitter {
*/ */
async dump() { async dump() {
logger.debug('dump()'); logger.debug('dump()');
return this.#channel.request('consumer.dump', this.#internal); return this.#channel.request('consumer.dump', this.#internal.consumerId);
} }
/** /**
* Get Consumer stats. * Get Consumer stats.
*/ */
async getStats() { async getStats() {
logger.debug('getStats()'); logger.debug('getStats()');
return this.#channel.request('consumer.getStats', this.#internal); return this.#channel.request('consumer.getStats', this.#internal.consumerId);
} }
/** /**
* Pause the Consumer. * Pause the Consumer.
...@@ -199,7 +200,7 @@ class Consumer extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -199,7 +200,7 @@ class Consumer extends EnhancedEventEmitter_1.EnhancedEventEmitter {
async pause() { async pause() {
logger.debug('pause()'); logger.debug('pause()');
const wasPaused = this.#paused || this.#producerPaused; const wasPaused = this.#paused || this.#producerPaused;
await this.#channel.request('consumer.pause', this.#internal); await this.#channel.request('consumer.pause', this.#internal.consumerId);
this.#paused = true; this.#paused = true;
// Emit observer event. // Emit observer event.
if (!wasPaused) if (!wasPaused)
...@@ -211,7 +212,7 @@ class Consumer extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -211,7 +212,7 @@ class Consumer extends EnhancedEventEmitter_1.EnhancedEventEmitter {
async resume() { async resume() {
logger.debug('resume()'); logger.debug('resume()');
const wasPaused = this.#paused || this.#producerPaused; const wasPaused = this.#paused || this.#producerPaused;
await this.#channel.request('consumer.resume', this.#internal); await this.#channel.request('consumer.resume', this.#internal.consumerId);
this.#paused = false; this.#paused = false;
// Emit observer event. // Emit observer event.
if (wasPaused && !this.#producerPaused) if (wasPaused && !this.#producerPaused)
...@@ -223,7 +224,7 @@ class Consumer extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -223,7 +224,7 @@ class Consumer extends EnhancedEventEmitter_1.EnhancedEventEmitter {
async setPreferredLayers({ spatialLayer, temporalLayer }) { async setPreferredLayers({ spatialLayer, temporalLayer }) {
logger.debug('setPreferredLayers()'); logger.debug('setPreferredLayers()');
const reqData = { spatialLayer, temporalLayer }; const reqData = { spatialLayer, temporalLayer };
const data = await this.#channel.request('consumer.setPreferredLayers', this.#internal, reqData); const data = await this.#channel.request('consumer.setPreferredLayers', this.#internal.consumerId, reqData);
this.#preferredLayers = data || undefined; this.#preferredLayers = data || undefined;
} }
/** /**
...@@ -232,7 +233,7 @@ class Consumer extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -232,7 +233,7 @@ class Consumer extends EnhancedEventEmitter_1.EnhancedEventEmitter {
async setPriority(priority) { async setPriority(priority) {
logger.debug('setPriority()'); logger.debug('setPriority()');
const reqData = { priority }; const reqData = { priority };
const data = await this.#channel.request('consumer.setPriority', this.#internal, reqData); const data = await this.#channel.request('consumer.setPriority', this.#internal.consumerId, reqData);
this.#priority = data.priority; this.#priority = data.priority;
} }
/** /**
...@@ -241,7 +242,7 @@ class Consumer extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -241,7 +242,7 @@ class Consumer extends EnhancedEventEmitter_1.EnhancedEventEmitter {
async unsetPriority() { async unsetPriority() {
logger.debug('unsetPriority()'); logger.debug('unsetPriority()');
const reqData = { priority: 1 }; const reqData = { priority: 1 };
const data = await this.#channel.request('consumer.setPriority', this.#internal, reqData); const data = await this.#channel.request('consumer.setPriority', this.#internal.consumerId, reqData);
this.#priority = data.priority; this.#priority = data.priority;
} }
/** /**
...@@ -249,7 +250,7 @@ class Consumer extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -249,7 +250,7 @@ class Consumer extends EnhancedEventEmitter_1.EnhancedEventEmitter {
*/ */
async requestKeyFrame() { async requestKeyFrame() {
logger.debug('requestKeyFrame()'); logger.debug('requestKeyFrame()');
await this.#channel.request('consumer.requestKeyFrame', this.#internal); await this.#channel.request('consumer.requestKeyFrame', this.#internal.consumerId);
} }
/** /**
* Enable 'trace' event. * Enable 'trace' event.
...@@ -257,7 +258,7 @@ class Consumer extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -257,7 +258,7 @@ class Consumer extends EnhancedEventEmitter_1.EnhancedEventEmitter {
async enableTraceEvent(types = []) { async enableTraceEvent(types = []) {
logger.debug('enableTraceEvent()'); logger.debug('enableTraceEvent()');
const reqData = { types }; const reqData = { types };
await this.#channel.request('consumer.enableTraceEvent', this.#internal, reqData); await this.#channel.request('consumer.enableTraceEvent', this.#internal.consumerId, reqData);
} }
handleWorkerNotifications() { handleWorkerNotifications() {
this.#channel.on(this.#internal.consumerId, (event, data) => { this.#channel.on(this.#internal.consumerId, (event, data) => {
......
{"version":3,"file":"DataConsumer.d.ts","sourceRoot":"","sources":["../src/DataConsumer.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,oBAAY,mBAAmB,GAC/B;IACC;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,OAAO,CAAC,E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nhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -103,7 +103,8 @@ class DataConsumer extends EnhancedEventEmitter_1.EnhancedEventEmitter {
// Remove notification subscriptions. // Remove notification subscriptions.
this.#channel.removeAllListeners(this.#internal.dataConsumerId); this.#channel.removeAllListeners(this.#internal.dataConsumerId);
this.#payloadChannel.removeAllListeners(this.#internal.dataConsumerId); this.#payloadChannel.removeAllListeners(this.#internal.dataConsumerId);
this.#channel.request('dataConsumer.close', this.#internal) const reqData = { dataConsumerId: this.#internal.dataConsumerId };
this.#channel.request('transport.closeDataConsumer', this.#internal.transportId, reqData)
.catch(() => { }); .catch(() => { });
this.emit('@close'); this.emit('@close');
// Emit observer event. // Emit observer event.
...@@ -131,14 +132,14 @@ class DataConsumer extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -131,14 +132,14 @@ class DataConsumer extends EnhancedEventEmitter_1.EnhancedEventEmitter {
*/ */
async dump() { async dump() {
logger.debug('dump()'); logger.debug('dump()');
return this.#channel.request('dataConsumer.dump', this.#internal); return this.#channel.request('dataConsumer.dump', this.#internal.dataConsumerId);
} }
/** /**
* Get DataConsumer stats. * Get DataConsumer stats.
*/ */
async getStats() { async getStats() {
logger.debug('getStats()'); logger.debug('getStats()');
return this.#channel.request('dataConsumer.getStats', this.#internal); return this.#channel.request('dataConsumer.getStats', this.#internal.dataConsumerId);
} }
/** /**
* Set buffered amount low threshold. * Set buffered amount low threshold.
...@@ -146,7 +147,7 @@ class DataConsumer extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -146,7 +147,7 @@ class DataConsumer extends EnhancedEventEmitter_1.EnhancedEventEmitter {
async setBufferedAmountLowThreshold(threshold) { async setBufferedAmountLowThreshold(threshold) {
logger.debug('setBufferedAmountLowThreshold() [threshold:%s]', threshold); logger.debug('setBufferedAmountLowThreshold() [threshold:%s]', threshold);
const reqData = { threshold }; const reqData = { threshold };
await this.#channel.request('dataConsumer.setBufferedAmountLowThreshold', this.#internal, reqData); await this.#channel.request('dataConsumer.setBufferedAmountLowThreshold', this.#internal.dataConsumerId, reqData);
} }
/** /**
* Send data. * Send data.
...@@ -181,14 +182,14 @@ class DataConsumer extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -181,14 +182,14 @@ class DataConsumer extends EnhancedEventEmitter_1.EnhancedEventEmitter {
else if (ppid === 57) else if (ppid === 57)
message = Buffer.alloc(1); message = Buffer.alloc(1);
const requestData = { ppid }; const requestData = { ppid };
await this.#payloadChannel.request('dataConsumer.send', this.#internal, requestData, message); await this.#payloadChannel.request('dataConsumer.send', this.#internal.dataConsumerId, requestData, message);
} }
/** /**
* Get buffered amount size. * Get buffered amount size.
*/ */
async getBufferedAmount() { async getBufferedAmount() {
logger.debug('getBufferedAmount()'); logger.debug('getBufferedAmount()');
const { bufferedAmount } = await this.#channel.request('dataConsumer.getBufferedAmount', this.#internal); const { bufferedAmount } = await this.#channel.request('dataConsumer.getBufferedAmount', this.#internal.dataConsumerId);
return bufferedAmount; return bufferedAmount;
} }
handleWorkerNotifications() { handleWorkerNotifications() {
......
{"version":3,"file":"DataProducer.d.ts","sourceRoot":"","sources":["../src/DataProducer.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,oBAAY,mBAAmB,GAC/B;IACC;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IAEZ;;;OAGG;IACH,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAE5C;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAA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e,IAAI,IAAI;IAmBvB;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC;IAO1B;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAO7C;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI;IA0CnD,OAAO,CAAC,yBAAyB;CAIjC"}
\ No newline at end of file \ No newline at end of file
...@@ -97,7 +97,8 @@ class DataProducer extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -97,7 +97,8 @@ class DataProducer extends EnhancedEventEmitter_1.EnhancedEventEmitter {
// Remove notification subscriptions. // Remove notification subscriptions.
this.#channel.removeAllListeners(this.#internal.dataProducerId); this.#channel.removeAllListeners(this.#internal.dataProducerId);
this.#payloadChannel.removeAllListeners(this.#internal.dataProducerId); this.#payloadChannel.removeAllListeners(this.#internal.dataProducerId);
this.#channel.request('dataProducer.close', this.#internal) const reqData = { dataProducerId: this.#internal.dataProducerId };
this.#channel.request('transport.closeDataProducer', this.#internal.transportId, reqData)
.catch(() => { }); .catch(() => { });
this.emit('@close'); this.emit('@close');
// Emit observer event. // Emit observer event.
...@@ -125,14 +126,14 @@ class DataProducer extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -125,14 +126,14 @@ class DataProducer extends EnhancedEventEmitter_1.EnhancedEventEmitter {
*/ */
async dump() { async dump() {
logger.debug('dump()'); logger.debug('dump()');
return this.#channel.request('dataProducer.dump', this.#internal); return this.#channel.request('dataProducer.dump', this.#internal.dataProducerId);
} }
/** /**
* Get DataProducer stats. * Get DataProducer stats.
*/ */
async getStats() { async getStats() {
logger.debug('getStats()'); logger.debug('getStats()');
return this.#channel.request('dataProducer.getStats', this.#internal); return this.#channel.request('dataProducer.getStats', this.#internal.dataProducerId);
} }
/** /**
* Send data (just valid for DataProducers created on a DirectTransport). * Send data (just valid for DataProducers created on a DirectTransport).
...@@ -167,7 +168,7 @@ class DataProducer extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -167,7 +168,7 @@ class DataProducer extends EnhancedEventEmitter_1.EnhancedEventEmitter {
else if (ppid === 57) else if (ppid === 57)
message = Buffer.alloc(1); message = Buffer.alloc(1);
const notifData = { ppid }; const notifData = { ppid };
this.#payloadChannel.notify('dataProducer.send', this.#internal, notifData, message); this.#payloadChannel.notify('dataProducer.send', this.#internal.dataProducerId, notifData, message);
} }
handleWorkerNotifications() { handleWorkerNotifications() {
// No need to subscribe to any event. // No need to subscribe to any event.
......
...@@ -48,7 +48,7 @@ class DirectTransport extends Transport_1.Transport { ...@@ -48,7 +48,7 @@ class DirectTransport extends Transport_1.Transport {
*/ */
async getStats() { async getStats() {
logger.debug('getStats()'); logger.debug('getStats()');
return this.channel.request('transport.getStats', this.internal); return this.channel.request('transport.getStats', this.internal.transportId);
} }
/** /**
* NO-OP method in DirectTransport. * NO-OP method in DirectTransport.
...@@ -79,7 +79,7 @@ class DirectTransport extends Transport_1.Transport { ...@@ -79,7 +79,7 @@ class DirectTransport extends Transport_1.Transport {
if (!Buffer.isBuffer(rtcpPacket)) { if (!Buffer.isBuffer(rtcpPacket)) {
throw new TypeError('rtcpPacket must be a Buffer'); throw new TypeError('rtcpPacket must be a Buffer');
} }
this.payloadChannel.notify('transport.sendRtcp', this.internal, undefined, rtcpPacket); this.payloadChannel.notify('transport.sendRtcp', this.internal.transportId, undefined, rtcpPacket);
} }
handleWorkerNotifications() { handleWorkerNotifications() {
this.channel.on(this.internal.transportId, (event, data) => { this.channel.on(this.internal.transportId, (event, data) => {
......
...@@ -16,11 +16,11 @@ export declare class PayloadChannel extends EnhancedEventEmitter { ...@@ -16,11 +16,11 @@ export declare class PayloadChannel extends EnhancedEventEmitter {
/** /**
* @private * @private
*/ */
notify(event: string, internal: object, data: any | undefined, payload: string | Buffer): void; notify(event: string, handlerId: string, data: any | undefined, payload: string | Buffer): void;
/** /**
* @private * @private
*/ */
request(method: string, internal: object, data: any, payload: string | Buffer): Promise<any>; request(method: string, handlerId: string, data: any, payload: string | Buffer): Promise<any>;
private processData; private processData;
} }
//# sourceMappingURL=PayloadChannel.d.ts.map //# sourceMappingURL=PayloadChannel.d.ts.map
\ No newline at end of file
{"version":3,"file":"PayloadChannel.d.ts","sourceRoot":"","sources":["../src/PayloadChannel.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAmB9D,qBAAa,cAAe,SAAQ,oBAAoB;;IAuBvD;;OAEG;gBAEF,EACC,cAAc,EACd,cAAc,EACd,EACD;QACC,cAAc,EAAE,GAAG,CAAC;QACpB,cAAc,EAAE,GAAG,CAAC;KACpB;IAsFF;;OAEG;IACH,KAAK,IAAI,IAAI;IA6Bb;;OAEG;IACH,MAAM,CACL,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,GAAG,GAAG,SAAS,EACrB,OAAO,EAAE,MAAM,GAAG,MAAM,GACtB,IAAI;IA2CP;;OAEG;IACG,OAAO,CACZ,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,GAAG,EACT,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAyDxC,OAAO,CAAC,WAAW;CA8FnB"} {"version":3,"file":"PayloadChannel.d.ts","sourceRoot":"","sources":["../src/PayloadChannel.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAmB9D,qBAAa,cAAe,SAAQ,oBAAoB;;IAuBvD;;OAEG;gBAEF,EACC,cAAc,EACd,cAAc,EACd,EACD;QACC,cAAc,EAAE,GAAG,CAAC;QACpB,cAAc,EAAE,GAAG,CAAC;KACpB;IAsFF;;OAEG;IACH,KAAK,IAAI,IAAI;IA6Bb;;OAEG;IACH,MAAM,CACL,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,GAAG,GAAG,SAAS,EACrB,OAAO,EAAE,MAAM,GAAG,MAAM,GACtB,IAAI;IA2CP;;OAEG;IACG,OAAO,CACZ,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,GAAG,EACT,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAyDxC,OAAO,CAAC,WAAW;CA8FnB"}
\ No newline at end of file \ No newline at end of file
...@@ -82,7 +82,7 @@ class PayloadChannel extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -82,7 +82,7 @@ class PayloadChannel extends EnhancedEventEmitter_1.EnhancedEventEmitter {
return; return;
logger.debug('close()'); logger.debug('close()');
this.#closed = true; this.#closed = true;
// Remove event listeners but leave a fake 'error' hander to avoid // Remove event listeners but leave a fake 'error' handler to avoid
// propagation. // propagation.
this.#consumerSocket.removeAllListeners('end'); this.#consumerSocket.removeAllListeners('end');
this.#consumerSocket.removeAllListeners('error'); this.#consumerSocket.removeAllListeners('error');
...@@ -105,11 +105,11 @@ class PayloadChannel extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -105,11 +105,11 @@ class PayloadChannel extends EnhancedEventEmitter_1.EnhancedEventEmitter {
/** /**
* @private * @private
*/ */
notify(event, internal, data, payload) { notify(event, handlerId, data, payload) {
logger.debug('notify() [event:%s]', event); logger.debug('notify() [event:%s]', event);
if (this.#closed) if (this.#closed)
throw new errors_1.InvalidStateError('PayloadChannel closed'); throw new errors_1.InvalidStateError('PayloadChannel closed');
const notification = JSON.stringify({ event, internal, data }); const notification = JSON.stringify({ event, handlerId, data });
if (Buffer.byteLength(notification) > MESSAGE_MAX_LEN) if (Buffer.byteLength(notification) > MESSAGE_MAX_LEN)
throw new Error('PayloadChannel notification too big'); throw new Error('PayloadChannel notification too big');
else if (Buffer.byteLength(payload) > MESSAGE_MAX_LEN) else if (Buffer.byteLength(payload) > MESSAGE_MAX_LEN)
...@@ -136,13 +136,13 @@ class PayloadChannel extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -136,13 +136,13 @@ class PayloadChannel extends EnhancedEventEmitter_1.EnhancedEventEmitter {
/** /**
* @private * @private
*/ */
async request(method, internal, data, payload) { async request(method, handlerId, data, payload) {
this.#nextId < 4294967295 ? ++this.#nextId : (this.#nextId = 1); this.#nextId < 4294967295 ? ++this.#nextId : (this.#nextId = 1);
const id = this.#nextId; const id = this.#nextId;
logger.debug('request() [method:%s, id:%s]', method, id); logger.debug('request() [method:%s, id:%s]', method, id);
if (this.#closed) if (this.#closed)
throw new errors_1.InvalidStateError('Channel closed'); throw new errors_1.InvalidStateError('Channel closed');
const request = JSON.stringify({ id, method, internal, data }); const request = JSON.stringify({ id, method, handlerId, data });
if (Buffer.byteLength(request) > MESSAGE_MAX_LEN) if (Buffer.byteLength(request) > MESSAGE_MAX_LEN)
throw new Error('Channel request too big'); throw new Error('Channel request too big');
else if (Buffer.byteLength(payload) > MESSAGE_MAX_LEN) else if (Buffer.byteLength(payload) > MESSAGE_MAX_LEN)
......
{"version":3,"file":"PipeTransport.d.ts","sourceRoot":"","sources":["../src/PipeTransport.ts"],"names":[],"mappings":"AAGA,OAAO,EACN,SAAS,EACT,iBAAiB,EACjB,cAAc,EAEd,eAAe,EACf,uBAAuB,EACvB,SAAS,EACT,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,oBAAY,oBAAoB,GAChC;IACC;;OAEG;IACH,QAAQ,EAAE,iBAAiB,GAAG,MAAM,CAAC;IAErC;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,cAAc,CAAC,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EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,mBAAmB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAgE9E,OAAO,CAAC,yBAAyB;CAuCjC"}
\ No newline at end of file \ No newline at end of file
...@@ -83,7 +83,7 @@ class PipeTransport extends Transport_1.Transport { ...@@ -83,7 +83,7 @@ class PipeTransport extends Transport_1.Transport {
*/ */
async getStats() { async getStats() {
logger.debug('getStats()'); logger.debug('getStats()');
return this.channel.request('transport.getStats', this.internal); return this.channel.request('transport.getStats', this.internal.transportId);
} }
/** /**
* Provide the PipeTransport remote parameters. * Provide the PipeTransport remote parameters.
...@@ -93,7 +93,7 @@ class PipeTransport extends Transport_1.Transport { ...@@ -93,7 +93,7 @@ class PipeTransport extends Transport_1.Transport {
async connect({ ip, port, srtpParameters }) { async connect({ ip, port, srtpParameters }) {
logger.debug('connect()'); logger.debug('connect()');
const reqData = { ip, port, srtpParameters }; const reqData = { ip, port, srtpParameters };
const data = await this.channel.request('transport.connect', this.internal, reqData); const data = await this.channel.request('transport.connect', this.internal.transportId, reqData);
// Update data. // Update data.
this.#data.tuple = data.tuple; this.#data.tuple = data.tuple;
} }
...@@ -113,15 +113,15 @@ class PipeTransport extends Transport_1.Transport { ...@@ -113,15 +113,15 @@ class PipeTransport extends Transport_1.Transport {
throw Error(`Producer with id "${producerId}" not found`); throw Error(`Producer with id "${producerId}" not found`);
// This may throw. // This may throw.
const rtpParameters = ortc.getPipeConsumerRtpParameters(producer.consumableRtpParameters, this.#data.rtx); const rtpParameters = ortc.getPipeConsumerRtpParameters(producer.consumableRtpParameters, this.#data.rtx);
const internal = { ...this.internal, consumerId: (0, uuid_1.v4)() };
const reqData = { const reqData = {
consumerId: (0, uuid_1.v4)(),
producerId, producerId,
kind: producer.kind, kind: producer.kind,
rtpParameters, rtpParameters,
type: 'pipe', type: 'pipe',
consumableRtpEncodings: producer.consumableRtpParameters.encodings consumableRtpEncodings: producer.consumableRtpParameters.encodings
}; };
const status = await this.channel.request('transport.consume', internal, reqData); const status = await this.channel.request('transport.consume', this.internal.transportId, reqData);
const data = { const data = {
producerId, producerId,
kind: producer.kind, kind: producer.kind,
...@@ -129,7 +129,10 @@ class PipeTransport extends Transport_1.Transport { ...@@ -129,7 +129,10 @@ class PipeTransport extends Transport_1.Transport {
type: 'pipe' type: 'pipe'
}; };
const consumer = new Consumer_1.Consumer({ const consumer = new Consumer_1.Consumer({
internal, internal: {
...this.internal,
consumerId: reqData.consumerId
},
data, data,
channel: this.channel, channel: this.channel,
payloadChannel: this.payloadChannel, payloadChannel: this.payloadChannel,
......
...@@ -88,7 +88,7 @@ class PlainTransport extends Transport_1.Transport { ...@@ -88,7 +88,7 @@ class PlainTransport extends Transport_1.Transport {
*/ */
async getStats() { async getStats() {
logger.debug('getStats()'); logger.debug('getStats()');
return this.channel.request('transport.getStats', this.internal); return this.channel.request('transport.getStats', this.internal.transportId);
} }
/** /**
* Provide the PlainTransport remote parameters. * Provide the PlainTransport remote parameters.
...@@ -98,7 +98,7 @@ class PlainTransport extends Transport_1.Transport { ...@@ -98,7 +98,7 @@ class PlainTransport extends Transport_1.Transport {
async connect({ ip, port, rtcpPort, srtpParameters }) { async connect({ ip, port, rtcpPort, srtpParameters }) {
logger.debug('connect()'); logger.debug('connect()');
const reqData = { ip, port, rtcpPort, srtpParameters }; const reqData = { ip, port, rtcpPort, srtpParameters };
const data = await this.channel.request('transport.connect', this.internal, reqData); const data = await this.channel.request('transport.connect', this.internal.transportId, reqData);
// Update data. // Update data.
if (data.tuple) if (data.tuple)
this.#data.tuple = data.tuple; this.#data.tuple = data.tuple;
......
{"version":3,"file":"Producer.d.ts","sourceRoot":"","sources":["../src/Producer.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EAA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aAAa,EAAE,CAG3B;IAED;;OAEG;IACH,IAAI,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAGrC;IAED;;OAEG;IACH,IAAI,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAG3C;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,oBAAoB,CAAC,sBAAsB,CAAC,CAG3D;IAED;;;OAGG;IACH,IAAI,iBAAiB,IAAI,OAAO,CAG/B;IAED;;OAEG;IACH,KAAK,IAAI,IAAI;IAwBb;;;;OAIG;IACH,eAAe,IAAI,IAAI;IAmBvB;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC;IAO1B;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;IAOzC;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAe5B;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAe7B;;OAEG;IACG,gBAAgB,CAAC,KAAK,GAAE,sBAAsB,EAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAU3E;;OAEG;IACH,IAAI,CAAC,SAAS,EAAE,MAAM;IAWtB,OAAO,CAAC,yBAAyB;CAmDjC"}
\ No newline at end of file \ No newline at end of file
...@@ -123,7 +123,8 @@ class Producer extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -123,7 +123,8 @@ class Producer extends EnhancedEventEmitter_1.EnhancedEventEmitter {
// Remove notification subscriptions. // Remove notification subscriptions.
this.#channel.removeAllListeners(this.#internal.producerId); this.#channel.removeAllListeners(this.#internal.producerId);
this.#payloadChannel.removeAllListeners(this.#internal.producerId); this.#payloadChannel.removeAllListeners(this.#internal.producerId);
this.#channel.request('producer.close', this.#internal) const reqData = { producerId: this.#internal.producerId };
this.#channel.request('transport.closeProducer', this.#internal.transportId, reqData)
.catch(() => { }); .catch(() => { });
this.emit('@close'); this.emit('@close');
// Emit observer event. // Emit observer event.
...@@ -151,14 +152,14 @@ class Producer extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -151,14 +152,14 @@ class Producer extends EnhancedEventEmitter_1.EnhancedEventEmitter {
*/ */
async dump() { async dump() {
logger.debug('dump()'); logger.debug('dump()');
return this.#channel.request('producer.dump', this.#internal); return this.#channel.request('producer.dump', this.#internal.producerId);
} }
/** /**
* Get Producer stats. * Get Producer stats.
*/ */
async getStats() { async getStats() {
logger.debug('getStats()'); logger.debug('getStats()');
return this.#channel.request('producer.getStats', this.#internal); return this.#channel.request('producer.getStats', this.#internal.producerId);
} }
/** /**
* Pause the Producer. * Pause the Producer.
...@@ -166,7 +167,7 @@ class Producer extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -166,7 +167,7 @@ class Producer extends EnhancedEventEmitter_1.EnhancedEventEmitter {
async pause() { async pause() {
logger.debug('pause()'); logger.debug('pause()');
const wasPaused = this.#paused; const wasPaused = this.#paused;
await this.#channel.request('producer.pause', this.#internal); await this.#channel.request('producer.pause', this.#internal.producerId);
this.#paused = true; this.#paused = true;
// Emit observer event. // Emit observer event.
if (!wasPaused) if (!wasPaused)
...@@ -178,7 +179,7 @@ class Producer extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -178,7 +179,7 @@ class Producer extends EnhancedEventEmitter_1.EnhancedEventEmitter {
async resume() { async resume() {
logger.debug('resume()'); logger.debug('resume()');
const wasPaused = this.#paused; const wasPaused = this.#paused;
await this.#channel.request('producer.resume', this.#internal); await this.#channel.request('producer.resume', this.#internal.producerId);
this.#paused = false; this.#paused = false;
// Emit observer event. // Emit observer event.
if (wasPaused) if (wasPaused)
...@@ -190,7 +191,7 @@ class Producer extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -190,7 +191,7 @@ class Producer extends EnhancedEventEmitter_1.EnhancedEventEmitter {
async enableTraceEvent(types = []) { async enableTraceEvent(types = []) {
logger.debug('enableTraceEvent()'); logger.debug('enableTraceEvent()');
const reqData = { types }; const reqData = { types };
await this.#channel.request('producer.enableTraceEvent', this.#internal, reqData); await this.#channel.request('producer.enableTraceEvent', this.#internal.producerId, reqData);
} }
/** /**
* Send RTP packet (just valid for Producers created on a DirectTransport). * Send RTP packet (just valid for Producers created on a DirectTransport).
...@@ -199,7 +200,7 @@ class Producer extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -199,7 +200,7 @@ class Producer extends EnhancedEventEmitter_1.EnhancedEventEmitter {
if (!Buffer.isBuffer(rtpPacket)) { if (!Buffer.isBuffer(rtpPacket)) {
throw new TypeError('rtpPacket must be a Buffer'); throw new TypeError('rtpPacket must be a Buffer');
} }
this.#payloadChannel.notify('producer.send', this.#internal, undefined, rtpPacket); this.#payloadChannel.notify('producer.send', this.#internal.producerId, undefined, rtpPacket);
} }
handleWorkerNotifications() { handleWorkerNotifications() {
this.#channel.on(this.#internal.producerId, (event, data) => { this.#channel.on(this.#internal.producerId, (event, data) => {
......
{"version":3,"file":"Router.d.ts","sourceRoot":"","sources":["../src/Router.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAG9D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY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C,OAAO;CAuBV"}
\ No newline at end of file \ No newline at end of file
...@@ -102,7 +102,8 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -102,7 +102,8 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter {
return; return;
logger.debug('close()'); logger.debug('close()');
this.#closed = true; this.#closed = true;
this.#channel.request('router.close', this.#internal) const reqData = { routerId: this.#internal.routerId };
this.#channel.request('worker.closeRouter', undefined, reqData)
.catch(() => { }); .catch(() => { });
// Close every Transport. // Close every Transport.
for (const transport of this.#transports.values()) { for (const transport of this.#transports.values()) {
...@@ -155,7 +156,7 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -155,7 +156,7 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter {
*/ */
async dump() { async dump() {
logger.debug('dump()'); logger.debug('dump()');
return this.#channel.request('router.dump', this.#internal); return this.#channel.request('router.dump', this.#internal.routerId);
} }
/** /**
* Create a WebRtcTransport. * Create a WebRtcTransport.
...@@ -182,11 +183,8 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -182,11 +183,8 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter {
} }
}); });
} }
const internal = {
...this.#internal,
transportId: (0, uuid_1.v4)()
};
const reqData = { const reqData = {
transportId: (0, uuid_1.v4)(),
webRtcServerId: webRtcServer ? webRtcServer.id : undefined, webRtcServerId: webRtcServer ? webRtcServer.id : undefined,
listenIps, listenIps,
port, port,
...@@ -202,10 +200,13 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -202,10 +200,13 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter {
isDataChannel: true isDataChannel: true
}; };
const data = webRtcServer const data = webRtcServer
? await this.#channel.request('router.createWebRtcTransportWithServer', internal, reqData) ? await this.#channel.request('router.createWebRtcTransportWithServer', this.#internal.routerId, reqData)
: await this.#channel.request('router.createWebRtcTransport', internal, reqData); : await this.#channel.request('router.createWebRtcTransport', this.#internal.routerId, reqData);
const transport = new WebRtcTransport_1.WebRtcTransport({ const transport = new WebRtcTransport_1.WebRtcTransport({
internal, internal: {
...this.#internal,
transportId: reqData.transportId
},
data, data,
channel: this.#channel, channel: this.#channel,
payloadChannel: this.#payloadChannel, payloadChannel: this.#payloadChannel,
...@@ -249,8 +250,8 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -249,8 +250,8 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter {
else { else {
throw new TypeError('wrong listenIp'); throw new TypeError('wrong listenIp');
} }
const internal = { ...this.#internal, transportId: (0, uuid_1.v4)() };
const reqData = { const reqData = {
transportId: (0, uuid_1.v4)(),
listenIp, listenIp,
port, port,
rtcpMux, rtcpMux,
...@@ -263,9 +264,12 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -263,9 +264,12 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter {
enableSrtp, enableSrtp,
srtpCryptoSuite srtpCryptoSuite
}; };
const data = await this.#channel.request('router.createPlainTransport', internal, reqData); const data = await this.#channel.request('router.createPlainTransport', this.#internal.routerId, reqData);
const transport = new PlainTransport_1.PlainTransport({ const transport = new PlainTransport_1.PlainTransport({
internal, internal: {
...this.#internal,
transportId: reqData.transportId
},
data, data,
channel: this.#channel, channel: this.#channel,
payloadChannel: this.#payloadChannel, payloadChannel: this.#payloadChannel,
...@@ -307,8 +311,8 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -307,8 +311,8 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter {
else { else {
throw new TypeError('wrong listenIp'); throw new TypeError('wrong listenIp');
} }
const internal = { ...this.#internal, transportId: (0, uuid_1.v4)() };
const reqData = { const reqData = {
transportId: (0, uuid_1.v4)(),
listenIp, listenIp,
port, port,
enableSctp, enableSctp,
...@@ -319,9 +323,12 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -319,9 +323,12 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter {
enableRtx, enableRtx,
enableSrtp enableSrtp
}; };
const data = await this.#channel.request('router.createPipeTransport', internal, reqData); const data = await this.#channel.request('router.createPipeTransport', this.#internal.routerId, reqData);
const transport = new PipeTransport_1.PipeTransport({ const transport = new PipeTransport_1.PipeTransport({
internal, internal: {
...this.#internal,
transportId: reqData.transportId
},
data, data,
channel: this.#channel, channel: this.#channel,
payloadChannel: this.#payloadChannel, payloadChannel: this.#payloadChannel,
...@@ -348,11 +355,17 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -348,11 +355,17 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter {
maxMessageSize: 262144 maxMessageSize: 262144
}) { }) {
logger.debug('createDirectTransport()'); logger.debug('createDirectTransport()');
const internal = { ...this.#internal, transportId: (0, uuid_1.v4)() }; const reqData = {
const reqData = { direct: true, maxMessageSize }; transportId: (0, uuid_1.v4)(),
const data = await this.#channel.request('router.createDirectTransport', internal, reqData); direct: true,
maxMessageSize
};
const data = await this.#channel.request('router.createDirectTransport', this.#internal.routerId, reqData);
const transport = new DirectTransport_1.DirectTransport({ const transport = new DirectTransport_1.DirectTransport({
internal, internal: {
...this.#internal,
transportId: reqData.transportId
},
data, data,
channel: this.#channel, channel: this.#channel,
payloadChannel: this.#payloadChannel, payloadChannel: this.#payloadChannel,
...@@ -564,11 +577,16 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -564,11 +577,16 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter {
logger.debug('createActiveSpeakerObserver()'); logger.debug('createActiveSpeakerObserver()');
if (appData && typeof appData !== 'object') if (appData && typeof appData !== 'object')
throw new TypeError('if given, appData must be an object'); throw new TypeError('if given, appData must be an object');
const internal = { ...this.#internal, rtpObserverId: (0, uuid_1.v4)() }; const reqData = {
const reqData = { interval }; rtpObserverId: (0, uuid_1.v4)(),
await this.#channel.request('router.createActiveSpeakerObserver', internal, reqData); interval
};
await this.#channel.request('router.createActiveSpeakerObserver', this.#internal.routerId, reqData);
const activeSpeakerObserver = new ActiveSpeakerObserver_1.ActiveSpeakerObserver({ const activeSpeakerObserver = new ActiveSpeakerObserver_1.ActiveSpeakerObserver({
internal, internal: {
...this.#internal,
rtpObserverId: reqData.rtpObserverId
},
channel: this.#channel, channel: this.#channel,
payloadChannel: this.#payloadChannel, payloadChannel: this.#payloadChannel,
appData, appData,
...@@ -589,11 +607,18 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -589,11 +607,18 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter {
logger.debug('createAudioLevelObserver()'); logger.debug('createAudioLevelObserver()');
if (appData && typeof appData !== 'object') if (appData && typeof appData !== 'object')
throw new TypeError('if given, appData must be an object'); throw new TypeError('if given, appData must be an object');
const internal = { ...this.#internal, rtpObserverId: (0, uuid_1.v4)() }; const reqData = {
const reqData = { maxEntries, threshold, interval }; rtpObserverId: (0, uuid_1.v4)(),
await this.#channel.request('router.createAudioLevelObserver', internal, reqData); maxEntries,
threshold,
interval
};
await this.#channel.request('router.createAudioLevelObserver', this.#internal.routerId, reqData);
const audioLevelObserver = new AudioLevelObserver_1.AudioLevelObserver({ const audioLevelObserver = new AudioLevelObserver_1.AudioLevelObserver({
internal, internal: {
...this.#internal,
rtpObserverId: reqData.rtpObserverId
},
channel: this.#channel, channel: this.#channel,
payloadChannel: this.#payloadChannel, payloadChannel: this.#payloadChannel,
appData, appData,
......
{"version":3,"file":"RtpObserver.d.ts","sourceRoot":"","sources":["../src/RtpObserver.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;A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IAAI,IAAI;IAwBb;;;;OAIG;IACH,YAAY,IAAI,IAAI;IAmBpB;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAe5B;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAe7B;;OAEG;IACG,WAAW,CAAC,EAAE,UAAU,EAAE,EAAE,mCAAmC,GAAG,OAAO,CAAC,IAAI,CAAC;IAarF;;OAEG;IACG,cAAc,CAAC,EAAE,UAAU,EAAE,EAAE,mCAAmC,GAAG,OAAO,CAAC,IAAI,CAAC;CAYxF"}
\ No newline at end of file \ No newline at end of file
...@@ -81,7 +81,8 @@ class RtpObserver extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -81,7 +81,8 @@ class RtpObserver extends EnhancedEventEmitter_1.EnhancedEventEmitter {
// Remove notification subscriptions. // Remove notification subscriptions.
this.channel.removeAllListeners(this.internal.rtpObserverId); this.channel.removeAllListeners(this.internal.rtpObserverId);
this.payloadChannel.removeAllListeners(this.internal.rtpObserverId); this.payloadChannel.removeAllListeners(this.internal.rtpObserverId);
this.channel.request('rtpObserver.close', this.internal) const reqData = { rtpObserverId: this.internal.rtpObserverId };
this.channel.request('router.closeRtpObserver', this.internal.routerId, reqData)
.catch(() => { }); .catch(() => { });
this.emit('@close'); this.emit('@close');
// Emit observer event. // Emit observer event.
...@@ -110,7 +111,7 @@ class RtpObserver extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -110,7 +111,7 @@ class RtpObserver extends EnhancedEventEmitter_1.EnhancedEventEmitter {
async pause() { async pause() {
logger.debug('pause()'); logger.debug('pause()');
const wasPaused = this.#paused; const wasPaused = this.#paused;
await this.channel.request('rtpObserver.pause', this.internal); await this.channel.request('rtpObserver.pause', this.internal.rtpObserverId);
this.#paused = true; this.#paused = true;
// Emit observer event. // Emit observer event.
if (!wasPaused) if (!wasPaused)
...@@ -122,7 +123,7 @@ class RtpObserver extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -122,7 +123,7 @@ class RtpObserver extends EnhancedEventEmitter_1.EnhancedEventEmitter {
async resume() { async resume() {
logger.debug('resume()'); logger.debug('resume()');
const wasPaused = this.#paused; const wasPaused = this.#paused;
await this.channel.request('rtpObserver.resume', this.internal); await this.channel.request('rtpObserver.resume', this.internal.rtpObserverId);
this.#paused = false; this.#paused = false;
// Emit observer event. // Emit observer event.
if (wasPaused) if (wasPaused)
...@@ -135,7 +136,7 @@ class RtpObserver extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -135,7 +136,7 @@ class RtpObserver extends EnhancedEventEmitter_1.EnhancedEventEmitter {
logger.debug('addProducer()'); logger.debug('addProducer()');
const producer = this.getProducerById(producerId); const producer = this.getProducerById(producerId);
const reqData = { producerId }; const reqData = { producerId };
await this.channel.request('rtpObserver.addProducer', this.internal, reqData); await this.channel.request('rtpObserver.addProducer', this.internal.rtpObserverId, reqData);
// Emit observer event. // Emit observer event.
this.#observer.safeEmit('addproducer', producer); this.#observer.safeEmit('addproducer', producer);
} }
...@@ -146,7 +147,7 @@ class RtpObserver extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -146,7 +147,7 @@ class RtpObserver extends EnhancedEventEmitter_1.EnhancedEventEmitter {
logger.debug('removeProducer()'); logger.debug('removeProducer()');
const producer = this.getProducerById(producerId); const producer = this.getProducerById(producerId);
const reqData = { producerId }; const reqData = { producerId };
await this.channel.request('rtpObserver.removeProducer', this.internal, reqData); await this.channel.request('rtpObserver.removeProducer', this.internal.rtpObserverId, reqData);
// Emit observer event. // Emit observer event.
this.#observer.safeEmit('removeproducer', producer); this.#observer.safeEmit('removeproducer', producer);
} }
......
{"version":3,"file":"Transport.d.ts","sourceRoot":"","sources":["../src/Transport.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAG9D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAA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;;OAEG;IACG,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU3D;;OAEG;IACG,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU3D;;OAEG;IACG,OAAO,CACZ,EACC,EAAc,EACd,IAAI,EACJ,aAAa,EACb,MAAc,EACd,oBAAoB,EACpB,OAAO,EACP,EAAE,eAAe,GAChB,OAAO,CAAC,QAAQ,CAAC;IAyGpB;;;;OAIG;IACG,OAAO,CACZ,EACC,UAAU,EACV,eAAe,EACf,MAAc,EACd,GAAG,EACH,eAAe,EACf,SAAiB,EACjB,IAAY,EACZ,OAAO,EACP,EAAE,eAAe,GAChB,OAAO,CAAC,QAAQ,CAAC;IAgGpB;;OAEG;IACG,WAAW,CAChB,EACC,EAAc,EACd,oBAAoB,EACpB,KAAU,EACV,QAAa,EACb,OAAO,EACP,GAAE,mBAAwB,GACzB,OAAO,CAAC,YAAY,CAAC;IAuExB;;OAEG;IACG,WAAW,CAChB,EACC,cAAc,EACd,OAAO,EACP,iBAAiB,EACjB,cAAc,EACd,OAAO,EACP,EAAE,mBAAmB,GACpB,OAAO,CAAC,YAAY,CAAC;IA4GxB;;OAEG;IACG,gBAAgB,CAAC,KAAK,GAAE,uBAAuB,EAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAU5E,OAAO,CAAC,mBAAmB;CA+B3B"}
\ No newline at end of file \ No newline at end of file
...@@ -112,7 +112,8 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -112,7 +112,8 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter {
// Remove notification subscriptions. // Remove notification subscriptions.
this.channel.removeAllListeners(this.internal.transportId); this.channel.removeAllListeners(this.internal.transportId);
this.payloadChannel.removeAllListeners(this.internal.transportId); this.payloadChannel.removeAllListeners(this.internal.transportId);
this.channel.request('transport.close', this.internal) const reqData = { transportId: this.internal.transportId };
this.channel.request('router.closeTransport', this.internal.routerId, reqData)
.catch(() => { }); .catch(() => { });
// Close every Producer. // Close every Producer.
for (const producer of this.#producers.values()) { for (const producer of this.#producers.values()) {
...@@ -235,7 +236,7 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -235,7 +236,7 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter {
*/ */
async dump() { async dump() {
logger.debug('dump()'); logger.debug('dump()');
return this.channel.request('transport.dump', this.internal); return this.channel.request('transport.dump', this.internal.transportId);
} }
/** /**
* Get Transport stats. * Get Transport stats.
...@@ -262,7 +263,7 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -262,7 +263,7 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter {
async setMaxIncomingBitrate(bitrate) { async setMaxIncomingBitrate(bitrate) {
logger.debug('setMaxIncomingBitrate() [bitrate:%s]', bitrate); logger.debug('setMaxIncomingBitrate() [bitrate:%s]', bitrate);
const reqData = { bitrate }; const reqData = { bitrate };
await this.channel.request('transport.setMaxIncomingBitrate', this.internal, reqData); await this.channel.request('transport.setMaxIncomingBitrate', this.internal.transportId, reqData);
} }
/** /**
* Set maximum outgoing bitrate for sending media. * Set maximum outgoing bitrate for sending media.
...@@ -270,7 +271,7 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -270,7 +271,7 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter {
async setMaxOutgoingBitrate(bitrate) { async setMaxOutgoingBitrate(bitrate) {
logger.debug('setMaxOutgoingBitrate() [bitrate:%s]', bitrate); logger.debug('setMaxOutgoingBitrate() [bitrate:%s]', bitrate);
const reqData = { bitrate }; const reqData = { bitrate };
await this.channel.request('transport.setMaxOutgoingBitrate', this.internal, reqData); await this.channel.request('transport.setMaxOutgoingBitrate', this.internal.transportId, reqData);
} }
/** /**
* Create a Producer. * Create a Producer.
...@@ -313,9 +314,15 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -313,9 +314,15 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter {
const rtpMapping = ortc.getProducerRtpParametersMapping(rtpParameters, routerRtpCapabilities); const rtpMapping = ortc.getProducerRtpParametersMapping(rtpParameters, routerRtpCapabilities);
// This may throw. // This may throw.
const consumableRtpParameters = ortc.getConsumableRtpParameters(kind, rtpParameters, routerRtpCapabilities, rtpMapping); const consumableRtpParameters = ortc.getConsumableRtpParameters(kind, rtpParameters, routerRtpCapabilities, rtpMapping);
const internal = { ...this.internal, producerId: id || (0, uuid_1.v4)() }; const reqData = {
const reqData = { kind, rtpParameters, rtpMapping, keyFrameRequestDelay, paused }; producerId: id || (0, uuid_1.v4)(),
const status = await this.channel.request('transport.produce', internal, reqData); kind,
rtpParameters,
rtpMapping,
keyFrameRequestDelay,
paused
};
const status = await this.channel.request('transport.produce', this.internal.transportId, reqData);
const data = { const data = {
kind, kind,
rtpParameters, rtpParameters,
...@@ -323,7 +330,10 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -323,7 +330,10 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter {
consumableRtpParameters consumableRtpParameters
}; };
const producer = new Producer_1.Producer({ const producer = new Producer_1.Producer({
internal, internal: {
...this.internal,
producerId: reqData.producerId
},
data, data,
channel: this.channel, channel: this.channel,
payloadChannel: this.payloadChannel, payloadChannel: this.payloadChannel,
...@@ -374,8 +384,8 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -374,8 +384,8 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter {
} }
} }
} }
const internal = { ...this.internal, consumerId: (0, uuid_1.v4)() };
const reqData = { const reqData = {
consumerId: (0, uuid_1.v4)(),
producerId, producerId,
kind: producer.kind, kind: producer.kind,
rtpParameters, rtpParameters,
...@@ -385,7 +395,7 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -385,7 +395,7 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter {
preferredLayers, preferredLayers,
ignoreDtx ignoreDtx
}; };
const status = await this.channel.request('transport.consume', internal, reqData); const status = await this.channel.request('transport.consume', this.internal.transportId, reqData);
const data = { const data = {
producerId, producerId,
kind: producer.kind, kind: producer.kind,
...@@ -393,7 +403,10 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -393,7 +403,10 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter {
type: pipe ? 'pipe' : producer.type type: pipe ? 'pipe' : producer.type
}; };
const consumer = new Consumer_1.Consumer({ const consumer = new Consumer_1.Consumer({
internal, internal: {
...this.internal,
consumerId: reqData.consumerId
},
data, data,
channel: this.channel, channel: this.channel,
payloadChannel: this.payloadChannel, payloadChannel: this.payloadChannel,
...@@ -433,16 +446,19 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -433,16 +446,19 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter {
logger.warn('produceData() | sctpStreamParameters are ignored when producing data on a DirectTransport'); logger.warn('produceData() | sctpStreamParameters are ignored when producing data on a DirectTransport');
} }
} }
const internal = { ...this.internal, dataProducerId: id || (0, uuid_1.v4)() };
const reqData = { const reqData = {
dataProducerId: id || (0, uuid_1.v4)(),
type, type,
sctpStreamParameters, sctpStreamParameters,
label, label,
protocol protocol
}; };
const data = await this.channel.request('transport.produceData', internal, reqData); const data = await this.channel.request('transport.produceData', this.internal.transportId, reqData);
const dataProducer = new DataProducer_1.DataProducer({ const dataProducer = new DataProducer_1.DataProducer({
internal, internal: {
...this.internal,
dataProducerId: reqData.dataProducerId
},
data, data,
channel: this.channel, channel: this.channel,
payloadChannel: this.payloadChannel, payloadChannel: this.payloadChannel,
...@@ -501,17 +517,20 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -501,17 +517,20 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter {
} }
} }
const { label, protocol } = dataProducer; const { label, protocol } = dataProducer;
const internal = { ...this.internal, dataConsumerId: (0, uuid_1.v4)() };
const reqData = { const reqData = {
dataConsumerId: (0, uuid_1.v4)(),
dataProducerId, dataProducerId,
type, type,
sctpStreamParameters, sctpStreamParameters,
label, label,
protocol protocol
}; };
const data = await this.channel.request('transport.consumeData', internal, reqData); const data = await this.channel.request('transport.consumeData', this.internal.transportId, reqData);
const dataConsumer = new DataConsumer_1.DataConsumer({ const dataConsumer = new DataConsumer_1.DataConsumer({
internal, internal: {
...this.internal,
dataConsumerId: reqData.dataConsumerId
},
data, data,
channel: this.channel, channel: this.channel,
payloadChannel: this.payloadChannel, payloadChannel: this.payloadChannel,
...@@ -538,12 +557,12 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -538,12 +557,12 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter {
async enableTraceEvent(types = []) { async enableTraceEvent(types = []) {
logger.debug('pause()'); logger.debug('pause()');
const reqData = { types }; const reqData = { types };
await this.channel.request('transport.enableTraceEvent', this.internal, reqData); await this.channel.request('transport.enableTraceEvent', this.internal.transportId, reqData);
} }
getNextSctpStreamId() { getNextSctpStreamId() {
if (!this.#data.sctpParameters || if (!this.#data.sctpParameters ||
typeof this.#data.sctpParameters.MIS !== 'number') { typeof this.#data.sctpParameters.MIS !== 'number') {
throw new TypeError('missing data.sctpParameters.MIS'); throw new TypeError('missing sctpParameters.MIS');
} }
const numStreams = this.#data.sctpParameters.MIS; const numStreams = this.#data.sctpParameters.MIS;
if (!this.#sctpStreamIds) if (!this.#sctpStreamIds)
......
{"version":3,"file":"WebRtcServer.d.ts","sourceRoot":"","sources":["../src/WebRtcServer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAA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5C,CAAA;AAID,qBAAa,YAAa,SAAQ,oBAAoB,CAAC,kBAAkB,CAAC;;IAuBzE;;OAEG;gBAEF,EACC,QAAQ,EACR,OAAO,EACP,OAAO,EACP,EACD;QACC,QAAQ,EAAE,GAAG,CAAC;QACd,OAAO,EAAE,OAAO,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAClC;IAYF;;OAEG;IACH,IAAI,EAAE,IAAI,MAAM,CAGf;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,OAAO,CAGpB;IAED;;OAEG;IACH,IAAI,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAGrC;IAED;;OAEG;IACH,IAAI,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAG3C;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,oBAAoB,CAAC,0BAA0B,CAAC,CAG/D;IAED;;;OAGG;IACH,IAAI,0BAA0B,IAAI,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAG7D;IAED;;OAEG;IACH,KAAK,IAAI,IAAI;IA8Bb;;;;OAIG;IACH,YAAY,IAAI,IAAI;IAmBpB;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC;IAO1B;;OAEG;IACH,qBAAqB,CAAC,eAAe,EAAE,eAAe,GAAG,IAAI;CAe7D"}
\ No newline at end of file \ No newline at end of file
...@@ -72,7 +72,8 @@ class WebRtcServer extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -72,7 +72,8 @@ class WebRtcServer extends EnhancedEventEmitter_1.EnhancedEventEmitter {
return; return;
logger.debug('close()'); logger.debug('close()');
this.#closed = true; this.#closed = true;
this.#channel.request('webRtcServer.close', this.#internal) const reqData = { webRtcServerId: this.#internal.webRtcServerId };
this.#channel.request('worker.closeWebRtcServer', undefined, reqData)
.catch(() => { }); .catch(() => { });
// Close every WebRtcTransport. // Close every WebRtcTransport.
for (const webRtcTransport of this.#webRtcTransports.values()) { for (const webRtcTransport of this.#webRtcTransports.values()) {
...@@ -107,7 +108,7 @@ class WebRtcServer extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -107,7 +108,7 @@ class WebRtcServer extends EnhancedEventEmitter_1.EnhancedEventEmitter {
*/ */
async dump() { async dump() {
logger.debug('dump()'); logger.debug('dump()');
return this.#channel.request('webRtcServer.dump', this.#internal); return this.#channel.request('webRtcServer.dump', this.#internal.webRtcServerId);
} }
/** /**
* @private * @private
......
...@@ -142,7 +142,7 @@ class WebRtcTransport extends Transport_1.Transport { ...@@ -142,7 +142,7 @@ class WebRtcTransport extends Transport_1.Transport {
*/ */
async getStats() { async getStats() {
logger.debug('getStats()'); logger.debug('getStats()');
return this.channel.request('transport.getStats', this.internal); return this.channel.request('transport.getStats', this.internal.transportId);
} }
/** /**
* Provide the WebRtcTransport remote parameters. * Provide the WebRtcTransport remote parameters.
...@@ -152,7 +152,7 @@ class WebRtcTransport extends Transport_1.Transport { ...@@ -152,7 +152,7 @@ class WebRtcTransport extends Transport_1.Transport {
async connect({ dtlsParameters }) { async connect({ dtlsParameters }) {
logger.debug('connect()'); logger.debug('connect()');
const reqData = { dtlsParameters }; const reqData = { dtlsParameters };
const data = await this.channel.request('transport.connect', this.internal, reqData); const data = await this.channel.request('transport.connect', this.internal.transportId, reqData);
// Update data. // Update data.
this.#data.dtlsParameters.role = data.dtlsLocalRole; this.#data.dtlsParameters.role = data.dtlsLocalRole;
} }
...@@ -161,7 +161,7 @@ class WebRtcTransport extends Transport_1.Transport { ...@@ -161,7 +161,7 @@ class WebRtcTransport extends Transport_1.Transport {
*/ */
async restartIce() { async restartIce() {
logger.debug('restartIce()'); logger.debug('restartIce()');
const data = await this.channel.request('transport.restartIce', this.internal); const data = await this.channel.request('transport.restartIce', this.internal.transportId);
const { iceParameters } = data; const { iceParameters } = data;
this.#data.iceParameters = iceParameters; this.#data.iceParameters = iceParameters;
return iceParameters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AAmB,CAAC;IAOtD;;OAEG;IACG,cAAc,CACnB,EACC,QAAQ,EACR,OAAO,EACP,GAAE,wBAA6B,GAC9B,OAAO,CAAC,IAAI,CAAC;IAShB;;OAEG;IACG,kBAAkB,CACvB,EACC,WAAW,EACX,OAAO,EACP,EAAE,mBAAmB,GAAG,OAAO,CAAC,YAAY,CAAC;IA8B/C;;OAEG;IACG,YAAY,CACjB,EACC,WAAW,EACX,OAAO,EACP,GAAE,aAAkB,GAAG,OAAO,CAAC,MAAM,CAAC;IAmCxC,OAAO,CAAC,UAAU;CAmClB"}
\ No newline at end of file \ No newline at end of file
...@@ -283,11 +283,13 @@ class Worker extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -283,11 +283,13 @@ class Worker extends EnhancedEventEmitter_1.EnhancedEventEmitter {
logger.debug('createWebRtcServer()'); logger.debug('createWebRtcServer()');
if (appData && typeof appData !== 'object') if (appData && typeof appData !== 'object')
throw new TypeError('if given, appData must be an object'); throw new TypeError('if given, appData must be an object');
const internal = { webRtcServerId: (0, uuid_1.v4)() }; const reqData = {
const reqData = { listenInfos }; webRtcServerId: (0, uuid_1.v4)(),
await this.#channel.request('worker.createWebRtcServer', internal, reqData); listenInfos
};
await this.#channel.request('worker.createWebRtcServer', undefined, reqData);
const webRtcServer = new WebRtcServer_1.WebRtcServer({ const webRtcServer = new WebRtcServer_1.WebRtcServer({
internal, internal: { webRtcServerId: reqData.webRtcServerId },
channel: this.#channel, channel: this.#channel,
appData appData
}); });
...@@ -306,11 +308,13 @@ class Worker extends EnhancedEventEmitter_1.EnhancedEventEmitter { ...@@ -306,11 +308,13 @@ class Worker extends EnhancedEventEmitter_1.EnhancedEventEmitter {
throw new TypeError('if given, appData must be an object'); throw new TypeError('if given, appData must be an object');
// This may throw. // This may throw.
const rtpCapabilities = ortc.generateRouterRtpCapabilities(mediaCodecs); const rtpCapabilities = ortc.generateRouterRtpCapabilities(mediaCodecs);
const internal = { routerId: (0, uuid_1.v4)() }; const reqData = { routerId: (0, uuid_1.v4)() };
await this.#channel.request('worker.createRouter', internal); await this.#channel.request('worker.createRouter', undefined, reqData);
const data = { rtpCapabilities }; const data = { rtpCapabilities };
const router = new Router_1.Router({ const router = new Router_1.Router({
internal, internal: {
routerId: reqData.routerId
},
data, data,
channel: this.#channel, channel: this.#channel,
payloadChannel: this.#payloadChannel, payloadChannel: this.#payloadChannel,
......
...@@ -223,7 +223,7 @@ export class Channel extends EnhancedEventEmitter ...@@ -223,7 +223,7 @@ export class Channel extends EnhancedEventEmitter
/** /**
* @private * @private
*/ */
async request(method: string, internal?: object, data?: any): Promise<any> async request(method: string, handlerId?: string, data?: any): Promise<any>
{ {
this.#nextId < 4294967295 ? ++this.#nextId : (this.#nextId = 1); this.#nextId < 4294967295 ? ++this.#nextId : (this.#nextId = 1);
...@@ -234,7 +234,7 @@ export class Channel extends EnhancedEventEmitter ...@@ -234,7 +234,7 @@ export class Channel extends EnhancedEventEmitter
if (this.#closed) if (this.#closed)
throw new InvalidStateError('Channel closed'); throw new InvalidStateError('Channel closed');
const request = { id, method, internal, data }; const request = { id, method, handlerId, data };
const payload = JSON.stringify(request); const payload = JSON.stringify(request);
if (Buffer.byteLength(payload) > MESSAGE_MAX_LEN) if (Buffer.byteLength(payload) > MESSAGE_MAX_LEN)
......
...@@ -428,7 +428,9 @@ export class Consumer extends EnhancedEventEmitter<ConsumerEvents> ...@@ -428,7 +428,9 @@ export class Consumer extends EnhancedEventEmitter<ConsumerEvents>
this.#channel.removeAllListeners(this.#internal.consumerId); this.#channel.removeAllListeners(this.#internal.consumerId);
this.#payloadChannel.removeAllListeners(this.#internal.consumerId); this.#payloadChannel.removeAllListeners(this.#internal.consumerId);
this.#channel.request('consumer.close', this.#internal) const reqData = { consumerId: this.#internal.consumerId };
this.#channel.request('transport.closeConsumer', this.#internal.transportId, reqData)
.catch(() => {}); .catch(() => {});
this.emit('@close'); this.emit('@close');
...@@ -468,7 +470,7 @@ export class Consumer extends EnhancedEventEmitter<ConsumerEvents> ...@@ -468,7 +470,7 @@ export class Consumer extends EnhancedEventEmitter<ConsumerEvents>
{ {
logger.debug('dump()'); logger.debug('dump()');
return this.#channel.request('consumer.dump', this.#internal); return this.#channel.request('consumer.dump', this.#internal.consumerId);
} }
/** /**
...@@ -478,7 +480,7 @@ export class Consumer extends EnhancedEventEmitter<ConsumerEvents> ...@@ -478,7 +480,7 @@ export class Consumer extends EnhancedEventEmitter<ConsumerEvents>
{ {
logger.debug('getStats()'); logger.debug('getStats()');
return this.#channel.request('consumer.getStats', this.#internal); return this.#channel.request('consumer.getStats', this.#internal.consumerId);
} }
/** /**
...@@ -490,7 +492,7 @@ export class Consumer extends EnhancedEventEmitter<ConsumerEvents> ...@@ -490,7 +492,7 @@ export class Consumer extends EnhancedEventEmitter<ConsumerEvents>
const wasPaused = this.#paused || this.#producerPaused; const wasPaused = this.#paused || this.#producerPaused;
await this.#channel.request('consumer.pause', this.#internal); await this.#channel.request('consumer.pause', this.#internal.consumerId);
this.#paused = true; this.#paused = true;
...@@ -508,7 +510,7 @@ export class Consumer extends EnhancedEventEmitter<ConsumerEvents> ...@@ -508,7 +510,7 @@ export class Consumer extends EnhancedEventEmitter<ConsumerEvents>
const wasPaused = this.#paused || this.#producerPaused; const wasPaused = this.#paused || this.#producerPaused;
await this.#channel.request('consumer.resume', this.#internal); await this.#channel.request('consumer.resume', this.#internal.consumerId);
this.#paused = false; this.#paused = false;
...@@ -532,7 +534,7 @@ export class Consumer extends EnhancedEventEmitter<ConsumerEvents> ...@@ -532,7 +534,7 @@ export class Consumer extends EnhancedEventEmitter<ConsumerEvents>
const reqData = { spatialLayer, temporalLayer }; const reqData = { spatialLayer, temporalLayer };
const data = await this.#channel.request( const data = await this.#channel.request(
'consumer.setPreferredLayers', this.#internal, reqData); 'consumer.setPreferredLayers', this.#internal.consumerId, reqData);
this.#preferredLayers = data || undefined; this.#preferredLayers = data || undefined;
} }
...@@ -547,7 +549,7 @@ export class Consumer extends EnhancedEventEmitter<ConsumerEvents> ...@@ -547,7 +549,7 @@ export class Consumer extends EnhancedEventEmitter<ConsumerEvents>
const reqData = { priority }; const reqData = { priority };
const data = await this.#channel.request( const data = await this.#channel.request(
'consumer.setPriority', this.#internal, reqData); 'consumer.setPriority', this.#internal.consumerId, reqData);
this.#priority = data.priority; this.#priority = data.priority;
} }
...@@ -562,7 +564,7 @@ export class Consumer extends EnhancedEventEmitter<ConsumerEvents> ...@@ -562,7 +564,7 @@ export class Consumer extends EnhancedEventEmitter<ConsumerEvents>
const reqData = { priority: 1 }; const reqData = { priority: 1 };
const data = await this.#channel.request( const data = await this.#channel.request(
'consumer.setPriority', this.#internal, reqData); 'consumer.setPriority', this.#internal.consumerId, reqData);
this.#priority = data.priority; this.#priority = data.priority;
} }
...@@ -574,7 +576,7 @@ export class Consumer extends EnhancedEventEmitter<ConsumerEvents> ...@@ -574,7 +576,7 @@ export class Consumer extends EnhancedEventEmitter<ConsumerEvents>
{ {
logger.debug('requestKeyFrame()'); logger.debug('requestKeyFrame()');
await this.#channel.request('consumer.requestKeyFrame', this.#internal); await this.#channel.request('consumer.requestKeyFrame', this.#internal.consumerId);
} }
/** /**
...@@ -587,7 +589,7 @@ export class Consumer extends EnhancedEventEmitter<ConsumerEvents> ...@@ -587,7 +589,7 @@ export class Consumer extends EnhancedEventEmitter<ConsumerEvents>
const reqData = { types }; const reqData = { types };
await this.#channel.request( await this.#channel.request(
'consumer.enableTraceEvent', this.#internal, reqData); 'consumer.enableTraceEvent', this.#internal.consumerId, reqData);
} }
private handleWorkerNotifications(): void private handleWorkerNotifications(): void
......
...@@ -240,7 +240,9 @@ export class DataConsumer extends EnhancedEventEmitter<DataConsumerEvents> ...@@ -240,7 +240,9 @@ export class DataConsumer extends EnhancedEventEmitter<DataConsumerEvents>
this.#channel.removeAllListeners(this.#internal.dataConsumerId); this.#channel.removeAllListeners(this.#internal.dataConsumerId);
this.#payloadChannel.removeAllListeners(this.#internal.dataConsumerId); this.#payloadChannel.removeAllListeners(this.#internal.dataConsumerId);
this.#channel.request('dataConsumer.close', this.#internal) const reqData = { dataConsumerId: this.#internal.dataConsumerId };
this.#channel.request('transport.closeDataConsumer', this.#internal.transportId, reqData)
.catch(() => {}); .catch(() => {});
this.emit('@close'); this.emit('@close');
...@@ -280,7 +282,7 @@ export class DataConsumer extends EnhancedEventEmitter<DataConsumerEvents> ...@@ -280,7 +282,7 @@ export class DataConsumer extends EnhancedEventEmitter<DataConsumerEvents>
{ {
logger.debug('dump()'); logger.debug('dump()');
return this.#channel.request('dataConsumer.dump', this.#internal); return this.#channel.request('dataConsumer.dump', this.#internal.dataConsumerId);
} }
/** /**
...@@ -290,7 +292,7 @@ export class DataConsumer extends EnhancedEventEmitter<DataConsumerEvents> ...@@ -290,7 +292,7 @@ export class DataConsumer extends EnhancedEventEmitter<DataConsumerEvents>
{ {
logger.debug('getStats()'); logger.debug('getStats()');
return this.#channel.request('dataConsumer.getStats', this.#internal); return this.#channel.request('dataConsumer.getStats', this.#internal.dataConsumerId);
} }
/** /**
...@@ -303,7 +305,7 @@ export class DataConsumer extends EnhancedEventEmitter<DataConsumerEvents> ...@@ -303,7 +305,7 @@ export class DataConsumer extends EnhancedEventEmitter<DataConsumerEvents>
const reqData = { threshold }; const reqData = { threshold };
await this.#channel.request( await this.#channel.request(
'dataConsumer.setBufferedAmountLowThreshold', this.#internal, reqData); 'dataConsumer.setBufferedAmountLowThreshold', this.#internal.dataConsumerId, reqData);
} }
/** /**
...@@ -348,7 +350,7 @@ export class DataConsumer extends EnhancedEventEmitter<DataConsumerEvents> ...@@ -348,7 +350,7 @@ export class DataConsumer extends EnhancedEventEmitter<DataConsumerEvents>
const requestData = { ppid }; const requestData = { ppid };
await this.#payloadChannel.request( await this.#payloadChannel.request(
'dataConsumer.send', this.#internal, requestData, message); 'dataConsumer.send', this.#internal.dataConsumerId, requestData, message);
} }
/** /**
...@@ -359,7 +361,7 @@ export class DataConsumer extends EnhancedEventEmitter<DataConsumerEvents> ...@@ -359,7 +361,7 @@ export class DataConsumer extends EnhancedEventEmitter<DataConsumerEvents>
logger.debug('getBufferedAmount()'); logger.debug('getBufferedAmount()');
const { bufferedAmount } = const { bufferedAmount } =
await this.#channel.request('dataConsumer.getBufferedAmount', this.#internal); await this.#channel.request('dataConsumer.getBufferedAmount', this.#internal.dataConsumerId);
return bufferedAmount; return bufferedAmount;
} }
......
...@@ -217,7 +217,9 @@ export class DataProducer extends EnhancedEventEmitter<DataProducerEvents> ...@@ -217,7 +217,9 @@ export class DataProducer extends EnhancedEventEmitter<DataProducerEvents>
this.#channel.removeAllListeners(this.#internal.dataProducerId); this.#channel.removeAllListeners(this.#internal.dataProducerId);
this.#payloadChannel.removeAllListeners(this.#internal.dataProducerId); this.#payloadChannel.removeAllListeners(this.#internal.dataProducerId);
this.#channel.request('dataProducer.close', this.#internal) const reqData = { dataProducerId: this.#internal.dataProducerId };
this.#channel.request('transport.closeDataProducer', this.#internal.transportId, reqData)
.catch(() => {}); .catch(() => {});
this.emit('@close'); this.emit('@close');
...@@ -257,7 +259,7 @@ export class DataProducer extends EnhancedEventEmitter<DataProducerEvents> ...@@ -257,7 +259,7 @@ export class DataProducer extends EnhancedEventEmitter<DataProducerEvents>
{ {
logger.debug('dump()'); logger.debug('dump()');
return this.#channel.request('dataProducer.dump', this.#internal); return this.#channel.request('dataProducer.dump', this.#internal.dataProducerId);
} }
/** /**
...@@ -267,7 +269,7 @@ export class DataProducer extends EnhancedEventEmitter<DataProducerEvents> ...@@ -267,7 +269,7 @@ export class DataProducer extends EnhancedEventEmitter<DataProducerEvents>
{ {
logger.debug('getStats()'); logger.debug('getStats()');
return this.#channel.request('dataProducer.getStats', this.#internal); return this.#channel.request('dataProducer.getStats', this.#internal.dataProducerId);
} }
/** /**
...@@ -312,7 +314,7 @@ export class DataProducer extends EnhancedEventEmitter<DataProducerEvents> ...@@ -312,7 +314,7 @@ export class DataProducer extends EnhancedEventEmitter<DataProducerEvents>
const notifData = { ppid }; const notifData = { ppid };
this.#payloadChannel.notify( this.#payloadChannel.notify(
'dataProducer.send', this.#internal, notifData, message); 'dataProducer.send', this.#internal.dataProducerId, notifData, message);
} }
private handleWorkerNotifications(): void private handleWorkerNotifications(): void
......
...@@ -115,7 +115,7 @@ export class DirectTransport extends ...@@ -115,7 +115,7 @@ export class DirectTransport extends
{ {
logger.debug('getStats()'); logger.debug('getStats()');
return this.channel.request('transport.getStats', this.internal); return this.channel.request('transport.getStats', this.internal.transportId);
} }
/** /**
...@@ -159,7 +159,7 @@ export class DirectTransport extends ...@@ -159,7 +159,7 @@ export class DirectTransport extends
} }
this.payloadChannel.notify( this.payloadChannel.notify(
'transport.sendRtcp', this.internal, undefined, rtcpPacket); 'transport.sendRtcp', this.internal.transportId, undefined, rtcpPacket);
} }
private handleWorkerNotifications(): void private handleWorkerNotifications(): void
......
...@@ -152,7 +152,7 @@ export class PayloadChannel extends EnhancedEventEmitter ...@@ -152,7 +152,7 @@ export class PayloadChannel extends EnhancedEventEmitter
this.#closed = true; this.#closed = true;
// Remove event listeners but leave a fake 'error' hander to avoid // Remove event listeners but leave a fake 'error' handler to avoid
// propagation. // propagation.
this.#consumerSocket.removeAllListeners('end'); this.#consumerSocket.removeAllListeners('end');
this.#consumerSocket.removeAllListeners('error'); this.#consumerSocket.removeAllListeners('error');
...@@ -177,7 +177,7 @@ export class PayloadChannel extends EnhancedEventEmitter ...@@ -177,7 +177,7 @@ export class PayloadChannel extends EnhancedEventEmitter
*/ */
notify( notify(
event: string, event: string,
internal: object, handlerId: string,
data: any | undefined, data: any | undefined,
payload: string | Buffer payload: string | Buffer
): void ): void
...@@ -187,7 +187,7 @@ export class PayloadChannel extends EnhancedEventEmitter ...@@ -187,7 +187,7 @@ export class PayloadChannel extends EnhancedEventEmitter
if (this.#closed) if (this.#closed)
throw new InvalidStateError('PayloadChannel closed'); throw new InvalidStateError('PayloadChannel closed');
const notification = JSON.stringify({ event, internal, data }); const notification = JSON.stringify({ event, handlerId, data });
if (Buffer.byteLength(notification) > MESSAGE_MAX_LEN) if (Buffer.byteLength(notification) > MESSAGE_MAX_LEN)
throw new Error('PayloadChannel notification too big'); throw new Error('PayloadChannel notification too big');
...@@ -228,7 +228,7 @@ export class PayloadChannel extends EnhancedEventEmitter ...@@ -228,7 +228,7 @@ export class PayloadChannel extends EnhancedEventEmitter
*/ */
async request( async request(
method: string, method: string,
internal: object, handlerId: string,
data: any, data: any,
payload: string | Buffer): Promise<any> payload: string | Buffer): Promise<any>
{ {
...@@ -241,7 +241,7 @@ export class PayloadChannel extends EnhancedEventEmitter ...@@ -241,7 +241,7 @@ export class PayloadChannel extends EnhancedEventEmitter
if (this.#closed) if (this.#closed)
throw new InvalidStateError('Channel closed'); throw new InvalidStateError('Channel closed');
const request = JSON.stringify({ id, method, internal, data }); const request = JSON.stringify({ id, method, handlerId, data });
if (Buffer.byteLength(request) > MESSAGE_MAX_LEN) if (Buffer.byteLength(request) > MESSAGE_MAX_LEN)
throw new Error('Channel request too big'); throw new Error('Channel request too big');
......
...@@ -232,7 +232,7 @@ export class PipeTransport ...@@ -232,7 +232,7 @@ export class PipeTransport
{ {
logger.debug('getStats()'); logger.debug('getStats()');
return this.channel.request('transport.getStats', this.internal); return this.channel.request('transport.getStats', this.internal.transportId);
} }
/** /**
...@@ -258,7 +258,7 @@ export class PipeTransport ...@@ -258,7 +258,7 @@ export class PipeTransport
const reqData = { ip, port, srtpParameters }; const reqData = { ip, port, srtpParameters };
const data = const data =
await this.channel.request('transport.connect', this.internal, reqData); await this.channel.request('transport.connect', this.internal.transportId, reqData);
// Update data. // Update data.
this.#data.tuple = data.tuple; this.#data.tuple = data.tuple;
...@@ -287,9 +287,9 @@ export class PipeTransport ...@@ -287,9 +287,9 @@ export class PipeTransport
const rtpParameters = ortc.getPipeConsumerRtpParameters( const rtpParameters = ortc.getPipeConsumerRtpParameters(
producer.consumableRtpParameters, this.#data.rtx); producer.consumableRtpParameters, this.#data.rtx);
const internal = { ...this.internal, consumerId: uuidv4() };
const reqData = const reqData =
{ {
consumerId : uuidv4(),
producerId, producerId,
kind : producer.kind, kind : producer.kind,
rtpParameters, rtpParameters,
...@@ -298,7 +298,7 @@ export class PipeTransport ...@@ -298,7 +298,7 @@ export class PipeTransport
}; };
const status = const status =
await this.channel.request('transport.consume', internal, reqData); await this.channel.request('transport.consume', this.internal.transportId, reqData);
const data = const data =
{ {
...@@ -310,7 +310,11 @@ export class PipeTransport ...@@ -310,7 +310,11 @@ export class PipeTransport
const consumer = new Consumer( const consumer = new Consumer(
{ {
internal, internal :
{
...this.internal,
consumerId : reqData.consumerId
},
data, data,
channel : this.channel, channel : this.channel,
payloadChannel : this.payloadChannel, payloadChannel : this.payloadChannel,
......
...@@ -256,7 +256,7 @@ export class PlainTransport extends ...@@ -256,7 +256,7 @@ export class PlainTransport extends
{ {
logger.debug('getStats()'); logger.debug('getStats()');
return this.channel.request('transport.getStats', this.internal); return this.channel.request('transport.getStats', this.internal.transportId);
} }
/** /**
...@@ -284,7 +284,7 @@ export class PlainTransport extends ...@@ -284,7 +284,7 @@ export class PlainTransport extends
const reqData = { ip, port, rtcpPort, srtpParameters }; const reqData = { ip, port, rtcpPort, srtpParameters };
const data = const data =
await this.channel.request('transport.connect', this.internal, reqData); await this.channel.request('transport.connect', this.internal.transportId, reqData);
// Update data. // Update data.
if (data.tuple) if (data.tuple)
......
...@@ -353,7 +353,9 @@ export class Producer extends EnhancedEventEmitter<ProducerEvents> ...@@ -353,7 +353,9 @@ export class Producer extends EnhancedEventEmitter<ProducerEvents>
this.#channel.removeAllListeners(this.#internal.producerId); this.#channel.removeAllListeners(this.#internal.producerId);
this.#payloadChannel.removeAllListeners(this.#internal.producerId); this.#payloadChannel.removeAllListeners(this.#internal.producerId);
this.#channel.request('producer.close', this.#internal) const reqData = { producerId: this.#internal.producerId };
this.#channel.request('transport.closeProducer', this.#internal.transportId, reqData)
.catch(() => {}); .catch(() => {});
this.emit('@close'); this.emit('@close');
...@@ -393,7 +395,7 @@ export class Producer extends EnhancedEventEmitter<ProducerEvents> ...@@ -393,7 +395,7 @@ export class Producer extends EnhancedEventEmitter<ProducerEvents>
{ {
logger.debug('dump()'); logger.debug('dump()');
return this.#channel.request('producer.dump', this.#internal); return this.#channel.request('producer.dump', this.#internal.producerId);
} }
/** /**
...@@ -403,7 +405,7 @@ export class Producer extends EnhancedEventEmitter<ProducerEvents> ...@@ -403,7 +405,7 @@ export class Producer extends EnhancedEventEmitter<ProducerEvents>
{ {
logger.debug('getStats()'); logger.debug('getStats()');
return this.#channel.request('producer.getStats', this.#internal); return this.#channel.request('producer.getStats', this.#internal.producerId);
} }
/** /**
...@@ -415,7 +417,7 @@ export class Producer extends EnhancedEventEmitter<ProducerEvents> ...@@ -415,7 +417,7 @@ export class Producer extends EnhancedEventEmitter<ProducerEvents>
const wasPaused = this.#paused; const wasPaused = this.#paused;
await this.#channel.request('producer.pause', this.#internal); await this.#channel.request('producer.pause', this.#internal.producerId);
this.#paused = true; this.#paused = true;
...@@ -433,7 +435,7 @@ export class Producer extends EnhancedEventEmitter<ProducerEvents> ...@@ -433,7 +435,7 @@ export class Producer extends EnhancedEventEmitter<ProducerEvents>
const wasPaused = this.#paused; const wasPaused = this.#paused;
await this.#channel.request('producer.resume', this.#internal); await this.#channel.request('producer.resume', this.#internal.producerId);
this.#paused = false; this.#paused = false;
...@@ -452,7 +454,7 @@ export class Producer extends EnhancedEventEmitter<ProducerEvents> ...@@ -452,7 +454,7 @@ export class Producer extends EnhancedEventEmitter<ProducerEvents>
const reqData = { types }; const reqData = { types };
await this.#channel.request( await this.#channel.request(
'producer.enableTraceEvent', this.#internal, reqData); 'producer.enableTraceEvent', this.#internal.producerId, reqData);
} }
/** /**
...@@ -466,7 +468,7 @@ export class Producer extends EnhancedEventEmitter<ProducerEvents> ...@@ -466,7 +468,7 @@ export class Producer extends EnhancedEventEmitter<ProducerEvents>
} }
this.#payloadChannel.notify( this.#payloadChannel.notify(
'producer.send', this.#internal, undefined, rtpPacket); 'producer.send', this.#internal.producerId, undefined, rtpPacket);
} }
private handleWorkerNotifications(): void private handleWorkerNotifications(): void
......
...@@ -266,7 +266,9 @@ export class Router extends EnhancedEventEmitter<RouterEvents> ...@@ -266,7 +266,9 @@ export class Router extends EnhancedEventEmitter<RouterEvents>
this.#closed = true; this.#closed = true;
this.#channel.request('router.close', this.#internal) const reqData = { routerId: this.#internal.routerId };
this.#channel.request('worker.closeRouter', undefined, reqData)
.catch(() => {}); .catch(() => {});
// Close every Transport. // Close every Transport.
...@@ -342,7 +344,7 @@ export class Router extends EnhancedEventEmitter<RouterEvents> ...@@ -342,7 +344,7 @@ export class Router extends EnhancedEventEmitter<RouterEvents>
{ {
logger.debug('dump()'); logger.debug('dump()');
return this.#channel.request('router.dump', this.#internal); return this.#channel.request('router.dump', this.#internal.routerId);
} }
/** /**
...@@ -395,14 +397,9 @@ export class Router extends EnhancedEventEmitter<RouterEvents> ...@@ -395,14 +397,9 @@ export class Router extends EnhancedEventEmitter<RouterEvents>
}); });
} }
const internal =
{
...this.#internal,
transportId : uuidv4()
};
const reqData = const reqData =
{ {
transportId : uuidv4(),
webRtcServerId : webRtcServer ? webRtcServer.id : undefined, webRtcServerId : webRtcServer ? webRtcServer.id : undefined,
listenIps, listenIps,
port, port,
...@@ -419,12 +416,16 @@ export class Router extends EnhancedEventEmitter<RouterEvents> ...@@ -419,12 +416,16 @@ export class Router extends EnhancedEventEmitter<RouterEvents>
}; };
const data = webRtcServer const data = webRtcServer
? await this.#channel.request('router.createWebRtcTransportWithServer', internal, reqData) ? await this.#channel.request('router.createWebRtcTransportWithServer', this.#internal.routerId, reqData)
: await this.#channel.request('router.createWebRtcTransport', internal, reqData); : await this.#channel.request('router.createWebRtcTransport', this.#internal.routerId, reqData);
const transport = new WebRtcTransport( const transport = new WebRtcTransport(
{ {
internal, internal :
{
...this.#internal,
transportId : reqData.transportId
},
data, data,
channel : this.#channel, channel : this.#channel,
payloadChannel : this.#payloadChannel, payloadChannel : this.#payloadChannel,
...@@ -502,8 +503,9 @@ export class Router extends EnhancedEventEmitter<RouterEvents> ...@@ -502,8 +503,9 @@ export class Router extends EnhancedEventEmitter<RouterEvents>
throw new TypeError('wrong listenIp'); throw new TypeError('wrong listenIp');
} }
const internal = { ...this.#internal, transportId: uuidv4() }; const reqData =
const reqData = { {
transportId : uuidv4(),
listenIp, listenIp,
port, port,
rtcpMux, rtcpMux,
...@@ -518,11 +520,15 @@ export class Router extends EnhancedEventEmitter<RouterEvents> ...@@ -518,11 +520,15 @@ export class Router extends EnhancedEventEmitter<RouterEvents>
}; };
const data = const data =
await this.#channel.request('router.createPlainTransport', internal, reqData); await this.#channel.request('router.createPlainTransport', this.#internal.routerId, reqData);
const transport = new PlainTransport( const transport = new PlainTransport(
{ {
internal, internal :
{
...this.#internal,
transportId : reqData.transportId
},
data, data,
channel : this.#channel, channel : this.#channel,
payloadChannel : this.#payloadChannel, payloadChannel : this.#payloadChannel,
...@@ -595,8 +601,9 @@ export class Router extends EnhancedEventEmitter<RouterEvents> ...@@ -595,8 +601,9 @@ export class Router extends EnhancedEventEmitter<RouterEvents>
throw new TypeError('wrong listenIp'); throw new TypeError('wrong listenIp');
} }
const internal = { ...this.#internal, transportId: uuidv4() }; const reqData =
const reqData = { {
transportId : uuidv4(),
listenIp, listenIp,
port, port,
enableSctp, enableSctp,
...@@ -609,11 +616,15 @@ export class Router extends EnhancedEventEmitter<RouterEvents> ...@@ -609,11 +616,15 @@ export class Router extends EnhancedEventEmitter<RouterEvents>
}; };
const data = const data =
await this.#channel.request('router.createPipeTransport', internal, reqData); await this.#channel.request('router.createPipeTransport', this.#internal.routerId, reqData);
const transport = new PipeTransport( const transport = new PipeTransport(
{ {
internal, internal :
{
...this.#internal,
transportId : reqData.transportId
},
data, data,
channel : this.#channel, channel : this.#channel,
payloadChannel : this.#payloadChannel, payloadChannel : this.#payloadChannel,
...@@ -660,15 +671,23 @@ export class Router extends EnhancedEventEmitter<RouterEvents> ...@@ -660,15 +671,23 @@ export class Router extends EnhancedEventEmitter<RouterEvents>
{ {
logger.debug('createDirectTransport()'); logger.debug('createDirectTransport()');
const internal = { ...this.#internal, transportId: uuidv4() }; const reqData =
const reqData = { direct: true, maxMessageSize }; {
transportId : uuidv4(),
direct : true,
maxMessageSize
};
const data = const data =
await this.#channel.request('router.createDirectTransport', internal, reqData); await this.#channel.request('router.createDirectTransport', this.#internal.routerId, reqData);
const transport = new DirectTransport( const transport = new DirectTransport(
{ {
internal, internal :
{
...this.#internal,
transportId : reqData.transportId
},
data, data,
channel : this.#channel, channel : this.#channel,
payloadChannel : this.#payloadChannel, payloadChannel : this.#payloadChannel,
...@@ -1004,14 +1023,21 @@ export class Router extends EnhancedEventEmitter<RouterEvents> ...@@ -1004,14 +1023,21 @@ export class Router extends EnhancedEventEmitter<RouterEvents>
if (appData && typeof appData !== 'object') if (appData && typeof appData !== 'object')
throw new TypeError('if given, appData must be an object'); throw new TypeError('if given, appData must be an object');
const internal = { ...this.#internal, rtpObserverId: uuidv4() }; const reqData =
const reqData = { interval }; {
rtpObserverId : uuidv4(),
interval
};
await this.#channel.request('router.createActiveSpeakerObserver', internal, reqData); await this.#channel.request('router.createActiveSpeakerObserver', this.#internal.routerId, reqData);
const activeSpeakerObserver = new ActiveSpeakerObserver( const activeSpeakerObserver = new ActiveSpeakerObserver(
{ {
internal, internal :
{
...this.#internal,
rtpObserverId : reqData.rtpObserverId
},
channel : this.#channel, channel : this.#channel,
payloadChannel : this.#payloadChannel, payloadChannel : this.#payloadChannel,
appData, appData,
...@@ -1049,14 +1075,23 @@ export class Router extends EnhancedEventEmitter<RouterEvents> ...@@ -1049,14 +1075,23 @@ export class Router extends EnhancedEventEmitter<RouterEvents>
if (appData && typeof appData !== 'object') if (appData && typeof appData !== 'object')
throw new TypeError('if given, appData must be an object'); throw new TypeError('if given, appData must be an object');
const internal = { ...this.#internal, rtpObserverId: uuidv4() }; const reqData =
const reqData = { maxEntries, threshold, interval }; {
rtpObserverId : uuidv4(),
maxEntries,
threshold,
interval
};
await this.#channel.request('router.createAudioLevelObserver', internal, reqData); await this.#channel.request('router.createAudioLevelObserver', this.#internal.routerId, reqData);
const audioLevelObserver = new AudioLevelObserver( const audioLevelObserver = new AudioLevelObserver(
{ {
internal, internal :
{
...this.#internal,
rtpObserverId : reqData.rtpObserverId
},
channel : this.#channel, channel : this.#channel,
payloadChannel : this.#payloadChannel, payloadChannel : this.#payloadChannel,
appData, appData,
......
...@@ -157,7 +157,9 @@ export class RtpObserver<E extends RtpObserverEvents = RtpObserverEvents> ...@@ -157,7 +157,9 @@ export class RtpObserver<E extends RtpObserverEvents = RtpObserverEvents>
this.channel.removeAllListeners(this.internal.rtpObserverId); this.channel.removeAllListeners(this.internal.rtpObserverId);
this.payloadChannel.removeAllListeners(this.internal.rtpObserverId); this.payloadChannel.removeAllListeners(this.internal.rtpObserverId);
this.channel.request('rtpObserver.close', this.internal) const reqData = { rtpObserverId: this.internal.rtpObserverId };
this.channel.request('router.closeRtpObserver', this.internal.routerId, reqData)
.catch(() => {}); .catch(() => {});
this.emit('@close'); this.emit('@close');
...@@ -199,7 +201,7 @@ export class RtpObserver<E extends RtpObserverEvents = RtpObserverEvents> ...@@ -199,7 +201,7 @@ export class RtpObserver<E extends RtpObserverEvents = RtpObserverEvents>
const wasPaused = this.#paused; const wasPaused = this.#paused;
await this.channel.request('rtpObserver.pause', this.internal); await this.channel.request('rtpObserver.pause', this.internal.rtpObserverId);
this.#paused = true; this.#paused = true;
...@@ -217,7 +219,7 @@ export class RtpObserver<E extends RtpObserverEvents = RtpObserverEvents> ...@@ -217,7 +219,7 @@ export class RtpObserver<E extends RtpObserverEvents = RtpObserverEvents>
const wasPaused = this.#paused; const wasPaused = this.#paused;
await this.channel.request('rtpObserver.resume', this.internal); await this.channel.request('rtpObserver.resume', this.internal.rtpObserverId);
this.#paused = false; this.#paused = false;
...@@ -236,7 +238,7 @@ export class RtpObserver<E extends RtpObserverEvents = RtpObserverEvents> ...@@ -236,7 +238,7 @@ export class RtpObserver<E extends RtpObserverEvents = RtpObserverEvents>
const producer = this.getProducerById(producerId); const producer = this.getProducerById(producerId);
const reqData = { producerId }; const reqData = { producerId };
await this.channel.request('rtpObserver.addProducer', this.internal, reqData); await this.channel.request('rtpObserver.addProducer', this.internal.rtpObserverId, reqData);
// Emit observer event. // Emit observer event.
this.#observer.safeEmit('addproducer', producer); this.#observer.safeEmit('addproducer', producer);
...@@ -252,7 +254,7 @@ export class RtpObserver<E extends RtpObserverEvents = RtpObserverEvents> ...@@ -252,7 +254,7 @@ export class RtpObserver<E extends RtpObserverEvents = RtpObserverEvents>
const producer = this.getProducerById(producerId); const producer = this.getProducerById(producerId);
const reqData = { producerId }; const reqData = { producerId };
await this.channel.request('rtpObserver.removeProducer', this.internal, reqData); await this.channel.request('rtpObserver.removeProducer', this.internal.rtpObserverId, reqData);
// Emit observer event. // Emit observer event.
this.#observer.safeEmit('removeproducer', producer); this.#observer.safeEmit('removeproducer', producer);
......
...@@ -279,7 +279,9 @@ export class Transport<Events extends TransportEvents = TransportEvents, ...@@ -279,7 +279,9 @@ export class Transport<Events extends TransportEvents = TransportEvents,
this.channel.removeAllListeners(this.internal.transportId); this.channel.removeAllListeners(this.internal.transportId);
this.payloadChannel.removeAllListeners(this.internal.transportId); this.payloadChannel.removeAllListeners(this.internal.transportId);
this.channel.request('transport.close', this.internal) const reqData = { transportId: this.internal.transportId };
this.channel.request('router.closeTransport', this.internal.routerId, reqData)
.catch(() => {}); .catch(() => {});
// Close every Producer. // Close every Producer.
...@@ -452,7 +454,7 @@ export class Transport<Events extends TransportEvents = TransportEvents, ...@@ -452,7 +454,7 @@ export class Transport<Events extends TransportEvents = TransportEvents,
{ {
logger.debug('dump()'); logger.debug('dump()');
return this.channel.request('transport.dump', this.internal); return this.channel.request('transport.dump', this.internal.transportId);
} }
/** /**
...@@ -488,7 +490,7 @@ export class Transport<Events extends TransportEvents = TransportEvents, ...@@ -488,7 +490,7 @@ export class Transport<Events extends TransportEvents = TransportEvents,
const reqData = { bitrate }; const reqData = { bitrate };
await this.channel.request( await this.channel.request(
'transport.setMaxIncomingBitrate', this.internal, reqData); 'transport.setMaxIncomingBitrate', this.internal.transportId, reqData);
} }
/** /**
...@@ -501,7 +503,7 @@ export class Transport<Events extends TransportEvents = TransportEvents, ...@@ -501,7 +503,7 @@ export class Transport<Events extends TransportEvents = TransportEvents,
const reqData = { bitrate }; const reqData = { bitrate };
await this.channel.request( await this.channel.request(
'transport.setMaxOutgoingBitrate', this.internal, reqData); 'transport.setMaxOutgoingBitrate', this.internal.transportId, reqData);
} }
/** /**
...@@ -572,11 +574,18 @@ export class Transport<Events extends TransportEvents = TransportEvents, ...@@ -572,11 +574,18 @@ export class Transport<Events extends TransportEvents = TransportEvents,
const consumableRtpParameters = ortc.getConsumableRtpParameters( const consumableRtpParameters = ortc.getConsumableRtpParameters(
kind, rtpParameters, routerRtpCapabilities, rtpMapping); kind, rtpParameters, routerRtpCapabilities, rtpMapping);
const internal = { ...this.internal, producerId: id || uuidv4() }; const reqData =
const reqData = { kind, rtpParameters, rtpMapping, keyFrameRequestDelay, paused }; {
producerId : id || uuidv4(),
kind,
rtpParameters,
rtpMapping,
keyFrameRequestDelay,
paused
};
const status = const status =
await this.channel.request('transport.produce', internal, reqData); await this.channel.request('transport.produce', this.internal.transportId, reqData);
const data = const data =
{ {
...@@ -588,7 +597,11 @@ export class Transport<Events extends TransportEvents = TransportEvents, ...@@ -588,7 +597,11 @@ export class Transport<Events extends TransportEvents = TransportEvents,
const producer = new Producer( const producer = new Producer(
{ {
internal, internal :
{
...this.internal,
producerId : reqData.producerId
},
data, data,
channel : this.channel, channel : this.channel,
payloadChannel : this.payloadChannel, payloadChannel : this.payloadChannel,
...@@ -672,9 +685,9 @@ export class Transport<Events extends TransportEvents = TransportEvents, ...@@ -672,9 +685,9 @@ export class Transport<Events extends TransportEvents = TransportEvents,
} }
} }
const internal = { ...this.internal, consumerId: uuidv4() };
const reqData = const reqData =
{ {
consumerId : uuidv4(),
producerId, producerId,
kind : producer.kind, kind : producer.kind,
rtpParameters, rtpParameters,
...@@ -686,7 +699,7 @@ export class Transport<Events extends TransportEvents = TransportEvents, ...@@ -686,7 +699,7 @@ export class Transport<Events extends TransportEvents = TransportEvents,
}; };
const status = const status =
await this.channel.request('transport.consume', internal, reqData); await this.channel.request('transport.consume', this.internal.transportId, reqData);
const data = const data =
{ {
...@@ -698,7 +711,11 @@ export class Transport<Events extends TransportEvents = TransportEvents, ...@@ -698,7 +711,11 @@ export class Transport<Events extends TransportEvents = TransportEvents,
const consumer = new Consumer( const consumer = new Consumer(
{ {
internal, internal :
{
...this.internal,
consumerId : reqData.consumerId
},
data, data,
channel : this.channel, channel : this.channel,
payloadChannel : this.payloadChannel, payloadChannel : this.payloadChannel,
...@@ -761,9 +778,9 @@ export class Transport<Events extends TransportEvents = TransportEvents, ...@@ -761,9 +778,9 @@ export class Transport<Events extends TransportEvents = TransportEvents,
} }
} }
const internal = { ...this.internal, dataProducerId: id || uuidv4() };
const reqData = const reqData =
{ {
dataProducerId : id || uuidv4(),
type, type,
sctpStreamParameters, sctpStreamParameters,
label, label,
...@@ -771,11 +788,15 @@ export class Transport<Events extends TransportEvents = TransportEvents, ...@@ -771,11 +788,15 @@ export class Transport<Events extends TransportEvents = TransportEvents,
}; };
const data = const data =
await this.channel.request('transport.produceData', internal, reqData); await this.channel.request('transport.produceData', this.internal.transportId, reqData);
const dataProducer = new DataProducer( const dataProducer = new DataProducer(
{ {
internal, internal :
{
...this.internal,
dataProducerId : reqData.dataProducerId
},
data, data,
channel : this.channel, channel : this.channel,
payloadChannel : this.payloadChannel, payloadChannel : this.payloadChannel,
...@@ -868,9 +889,9 @@ export class Transport<Events extends TransportEvents = TransportEvents, ...@@ -868,9 +889,9 @@ export class Transport<Events extends TransportEvents = TransportEvents,
const { label, protocol } = dataProducer; const { label, protocol } = dataProducer;
const internal = { ...this.internal, dataConsumerId: uuidv4() };
const reqData = const reqData =
{ {
dataConsumerId : uuidv4(),
dataProducerId, dataProducerId,
type, type,
sctpStreamParameters, sctpStreamParameters,
...@@ -879,11 +900,15 @@ export class Transport<Events extends TransportEvents = TransportEvents, ...@@ -879,11 +900,15 @@ export class Transport<Events extends TransportEvents = TransportEvents,
}; };
const data = const data =
await this.channel.request('transport.consumeData', internal, reqData); await this.channel.request('transport.consumeData', this.internal.transportId, reqData);
const dataConsumer = new DataConsumer( const dataConsumer = new DataConsumer(
{ {
internal, internal :
{
...this.internal,
dataConsumerId : reqData.dataConsumerId
},
data, data,
channel : this.channel, channel : this.channel,
payloadChannel : this.payloadChannel, payloadChannel : this.payloadChannel,
...@@ -922,7 +947,7 @@ export class Transport<Events extends TransportEvents = TransportEvents, ...@@ -922,7 +947,7 @@ export class Transport<Events extends TransportEvents = TransportEvents,
const reqData = { types }; const reqData = { types };
await this.channel.request( await this.channel.request(
'transport.enableTraceEvent', this.internal, reqData); 'transport.enableTraceEvent', this.internal.transportId, reqData);
} }
private getNextSctpStreamId(): number private getNextSctpStreamId(): number
...@@ -932,7 +957,7 @@ export class Transport<Events extends TransportEvents = TransportEvents, ...@@ -932,7 +957,7 @@ export class Transport<Events extends TransportEvents = TransportEvents,
typeof this.#data.sctpParameters.MIS !== 'number' typeof this.#data.sctpParameters.MIS !== 'number'
) )
{ {
throw new TypeError('missing data.sctpParameters.MIS'); throw new TypeError('missing sctpParameters.MIS');
} }
const numStreams = this.#data.sctpParameters.MIS; const numStreams = this.#data.sctpParameters.MIS;
......
...@@ -166,7 +166,9 @@ export class WebRtcServer extends EnhancedEventEmitter<WebRtcServerEvents> ...@@ -166,7 +166,9 @@ export class WebRtcServer extends EnhancedEventEmitter<WebRtcServerEvents>
this.#closed = true; this.#closed = true;
this.#channel.request('webRtcServer.close', this.#internal) const reqData = { webRtcServerId: this.#internal.webRtcServerId };
this.#channel.request('worker.closeWebRtcServer', undefined, reqData)
.catch(() => {}); .catch(() => {});
// Close every WebRtcTransport. // Close every WebRtcTransport.
...@@ -216,7 +218,7 @@ export class WebRtcServer extends EnhancedEventEmitter<WebRtcServerEvents> ...@@ -216,7 +218,7 @@ export class WebRtcServer extends EnhancedEventEmitter<WebRtcServerEvents>
{ {
logger.debug('dump()'); logger.debug('dump()');
return this.#channel.request('webRtcServer.dump', this.#internal); return this.#channel.request('webRtcServer.dump', this.#internal.webRtcServerId);
} }
/** /**
......
...@@ -383,7 +383,7 @@ export class WebRtcTransport extends ...@@ -383,7 +383,7 @@ export class WebRtcTransport extends
{ {
logger.debug('getStats()'); logger.debug('getStats()');
return this.channel.request('transport.getStats', this.internal); return this.channel.request('transport.getStats', this.internal.transportId);
} }
/** /**
...@@ -398,7 +398,7 @@ export class WebRtcTransport extends ...@@ -398,7 +398,7 @@ export class WebRtcTransport extends
const reqData = { dtlsParameters }; const reqData = { dtlsParameters };
const data = const data =
await this.channel.request('transport.connect', this.internal, reqData); await this.channel.request('transport.connect', this.internal.transportId, reqData);
// Update data. // Update data.
this.#data.dtlsParameters.role = data.dtlsLocalRole; this.#data.dtlsParameters.role = data.dtlsLocalRole;
...@@ -412,7 +412,7 @@ export class WebRtcTransport extends ...@@ -412,7 +412,7 @@ export class WebRtcTransport extends
logger.debug('restartIce()'); logger.debug('restartIce()');
const data = const data =
await this.channel.request('transport.restartIce', this.internal); await this.channel.request('transport.restartIce', this.internal.transportId);
const { iceParameters } = data; const { iceParameters } = data;
......
...@@ -593,15 +593,18 @@ export class Worker extends EnhancedEventEmitter<WorkerEvents> ...@@ -593,15 +593,18 @@ export class Worker extends EnhancedEventEmitter<WorkerEvents>
if (appData && typeof appData !== 'object') if (appData && typeof appData !== 'object')
throw new TypeError('if given, appData must be an object'); throw new TypeError('if given, appData must be an object');
const internal = { webRtcServerId: uuidv4() }; const reqData =
const reqData = { listenInfos }; {
webRtcServerId : uuidv4(),
listenInfos
};
await this.#channel.request('worker.createWebRtcServer', internal, reqData); await this.#channel.request('worker.createWebRtcServer', undefined, reqData);
const webRtcServer = new WebRtcServer( const webRtcServer = new WebRtcServer(
{ {
internal, internal : { webRtcServerId: reqData.webRtcServerId },
channel : this.#channel, channel : this.#channel,
appData appData
}); });
...@@ -631,14 +634,17 @@ export class Worker extends EnhancedEventEmitter<WorkerEvents> ...@@ -631,14 +634,17 @@ export class Worker extends EnhancedEventEmitter<WorkerEvents>
// This may throw. // This may throw.
const rtpCapabilities = ortc.generateRouterRtpCapabilities(mediaCodecs); const rtpCapabilities = ortc.generateRouterRtpCapabilities(mediaCodecs);
const internal = { routerId: uuidv4() }; const reqData = { routerId: uuidv4() };
await this.#channel.request('worker.createRouter', internal); await this.#channel.request('worker.createRouter', undefined, reqData);
const data = { rtpCapabilities }; const data = { rtpCapabilities };
const router = new Router( const router = new Router(
{ {
internal, internal :
{
routerId : reqData.routerId
},
data, data,
channel : this.#channel, channel : this.#channel,
payloadChannel : this.#payloadChannel, payloadChannel : this.#payloadChannel,
......
...@@ -5,7 +5,8 @@ const { createWorker } = mediasoup; ...@@ -5,7 +5,8 @@ const { createWorker } = mediasoup;
expect.extend({ toBeType }); expect.extend({ toBeType });
let worker; let worker1;
let worker2;
let router1; let router1;
let router2; let router2;
let transport1; let transport1;
...@@ -190,9 +191,10 @@ const consumerDeviceCapabilities = ...@@ -190,9 +191,10 @@ const consumerDeviceCapabilities =
beforeAll(async () => beforeAll(async () =>
{ {
worker = await createWorker(); worker1 = await createWorker();
router1 = await worker.createRouter({ mediaCodecs }); worker2 = await createWorker();
router2 = await worker.createRouter({ mediaCodecs }); router1 = await worker1.createRouter({ mediaCodecs });
router2 = await worker2.createRouter({ mediaCodecs });
transport1 = await router1.createWebRtcTransport( transport1 = await router1.createWebRtcTransport(
{ {
listenIps : [ '127.0.0.1' ], listenIps : [ '127.0.0.1' ],
...@@ -211,7 +213,11 @@ beforeAll(async () => ...@@ -211,7 +213,11 @@ beforeAll(async () =>
await videoProducer.pause(); await videoProducer.pause();
}); });
afterAll(() => worker.close()); afterAll(() =>
{
worker1.close();
worker2.close();
});
test('router.pipeToRouter() succeeds with audio', async () => test('router.pipeToRouter() succeeds with audio', async () =>
{ {
...@@ -890,8 +896,8 @@ test('dataProducer.close() is transmitted to pipe DataConsumer', async () => ...@@ -890,8 +896,8 @@ test('dataProducer.close() is transmitted to pipe DataConsumer', async () =>
test('router.pipeToRouter() called twice generates a single PipeTransport pair', async () => test('router.pipeToRouter() called twice generates a single PipeTransport pair', async () =>
{ {
const routerA = await worker.createRouter({ mediaCodecs }); const routerA = await worker1.createRouter({ mediaCodecs });
const routerB = await worker.createRouter({ mediaCodecs }); const routerB = await worker2.createRouter({ mediaCodecs });
const transportA1 = await routerA.createWebRtcTransport({ listenIps: [ '127.0.0.1' ] }); const transportA1 = await routerA.createWebRtcTransport({ listenIps: [ '127.0.0.1' ] });
const transportA2 = await routerA.createWebRtcTransport({ listenIps: [ '127.0.0.1' ] }); const transportA2 = await routerA.createWebRtcTransport({ listenIps: [ '127.0.0.1' ] });
const audioProducerA1 = await transportA1.produce(audioProducerParameters); const audioProducerA1 = await transportA1.produce(audioProducerParameters);
...@@ -936,8 +942,8 @@ test('router.pipeToRouter() called in two Routers passing one to each other as a ...@@ -936,8 +942,8 @@ test('router.pipeToRouter() called in two Routers passing one to each other as a
router1.close(); router1.close();
router2.close(); router2.close();
const routerA = await worker.createRouter({ mediaCodecs }); const routerA = await worker1.createRouter({ mediaCodecs });
const routerB = await worker.createRouter({ mediaCodecs }); const routerB = await worker2.createRouter({ mediaCodecs });
const transportA = await routerA.createWebRtcTransport({ listenIps: [ '127.0.0.1' ] }); const transportA = await routerA.createWebRtcTransport({ listenIps: [ '127.0.0.1' ] });
const transportB = await routerB.createWebRtcTransport({ listenIps: [ '127.0.0.1' ] }); const transportB = await routerB.createWebRtcTransport({ listenIps: [ '127.0.0.1' ] });
const audioProducerA = await transportA.produce(audioProducerParameters); const audioProducerA = await transportA.produce(audioProducerParameters);
......
差异被折叠。
...@@ -31,14 +31,13 @@ use crate::data_producer::{ ...@@ -31,14 +31,13 @@ use crate::data_producer::{
use crate::data_structures::{AppData, ListenIp}; use crate::data_structures::{AppData, ListenIp};
use crate::direct_transport::{DirectTransport, DirectTransportOptions}; use crate::direct_transport::{DirectTransport, DirectTransportOptions};
use crate::messages::{ use crate::messages::{
RouterCloseRequest, RouterCreateActiveSpeakerObserverData, RouterCloseRequest, RouterCloseRequestData, RouterCreateActiveSpeakerObserverData,
RouterCreateActiveSpeakerObserverRequest, RouterCreateAudioLevelObserverData, RouterCreateActiveSpeakerObserverRequest, RouterCreateAudioLevelObserverData,
RouterCreateAudioLevelObserverRequest, RouterCreateDirectTransportData, RouterCreateAudioLevelObserverRequest, RouterCreateDirectTransportData,
RouterCreateDirectTransportRequest, RouterCreatePipeTransportData, RouterCreateDirectTransportRequest, RouterCreatePipeTransportData,
RouterCreatePipeTransportRequest, RouterCreatePlainTransportData, RouterCreatePipeTransportRequest, RouterCreatePlainTransportData,
RouterCreatePlainTransportRequest, RouterCreateWebrtcTransportData, RouterCreatePlainTransportRequest, RouterCreateWebrtcTransportData,
RouterCreateWebrtcTransportRequest, RouterDumpRequest, RouterInternal, RtpObserverInternal, RouterCreateWebrtcTransportRequest, RouterDumpRequest,
TransportInternal,
}; };
use crate::pipe_transport::{ use crate::pipe_transport::{
PipeTransport, PipeTransportOptions, PipeTransportRemoteParameters, WeakPipeTransport, PipeTransport, PipeTransportOptions, PipeTransportRemoteParameters, WeakPipeTransport,
...@@ -399,7 +398,7 @@ impl Inner { ...@@ -399,7 +398,7 @@ impl Inner {
{ {
let channel = self.channel.clone(); let channel = self.channel.clone();
let request = RouterCloseRequest { let request = RouterCloseRequest {
internal: RouterInternal { router_id: self.id }, data: RouterCloseRequestData { router_id: self.id },
}; };
self.executor self.executor
.spawn(async move { .spawn(async move {
...@@ -537,9 +536,7 @@ impl Router { ...@@ -537,9 +536,7 @@ impl Router {
self.inner self.inner
.channel .channel
.request(RouterDumpRequest { .request(RouterDumpRequest {
internal: RouterInternal { handler_id: self.inner.id,
router_id: self.inner.id,
},
}) })
.await .await
} }
...@@ -570,11 +567,11 @@ impl Router { ...@@ -570,11 +567,11 @@ impl Router {
self.inner self.inner
.channel .channel
.request(RouterCreateDirectTransportRequest { .request(RouterCreateDirectTransportRequest {
internal: TransportInternal { handler_id: self.inner.id,
router_id: self.inner.id, data: RouterCreateDirectTransportData::from_options(
transport_id, transport_id,
}, &direct_transport_options,
data: RouterCreateDirectTransportData::from_options(&direct_transport_options), ),
}) })
.await?; .await?;
...@@ -631,11 +628,11 @@ impl Router { ...@@ -631,11 +628,11 @@ impl Router {
.inner .inner
.channel .channel
.request(RouterCreateWebrtcTransportRequest { .request(RouterCreateWebrtcTransportRequest {
internal: TransportInternal { handler_id: self.inner.id,
router_id: self.inner.id, data: RouterCreateWebrtcTransportData::from_options(
transport_id, transport_id,
}, &webrtc_transport_options,
data: RouterCreateWebrtcTransportData::from_options(&webrtc_transport_options), ),
}) })
.await?; .await?;
...@@ -695,11 +692,11 @@ impl Router { ...@@ -695,11 +692,11 @@ impl Router {
.inner .inner
.channel .channel
.request(RouterCreatePipeTransportRequest { .request(RouterCreatePipeTransportRequest {
internal: TransportInternal { handler_id: self.inner.id,
router_id: self.inner.id, data: RouterCreatePipeTransportData::from_options(
transport_id, transport_id,
}, &pipe_transport_options,
data: RouterCreatePipeTransportData::from_options(&pipe_transport_options), ),
}) })
.await?; .await?;
...@@ -755,11 +752,11 @@ impl Router { ...@@ -755,11 +752,11 @@ impl Router {
.inner .inner
.channel .channel
.request(RouterCreatePlainTransportRequest { .request(RouterCreatePlainTransportRequest {
internal: TransportInternal { handler_id: self.inner.id,
router_id: self.inner.id, data: RouterCreatePlainTransportData::from_options(
transport_id, transport_id,
}, &plain_transport_options,
data: RouterCreatePlainTransportData::from_options(&plain_transport_options), ),
}) })
.await?; .await?;
...@@ -820,11 +817,9 @@ impl Router { ...@@ -820,11 +817,9 @@ impl Router {
self.inner self.inner
.channel .channel
.request(RouterCreateAudioLevelObserverRequest { .request(RouterCreateAudioLevelObserverRequest {
internal: RtpObserverInternal { handler_id: self.inner.id,
router_id: self.inner.id,
rtp_observer_id,
},
data: RouterCreateAudioLevelObserverData::from_options( data: RouterCreateAudioLevelObserverData::from_options(
rtp_observer_id,
&audio_level_observer_options, &audio_level_observer_options,
), ),
}) })
...@@ -880,11 +875,9 @@ impl Router { ...@@ -880,11 +875,9 @@ impl Router {
self.inner self.inner
.channel .channel
.request(RouterCreateActiveSpeakerObserverRequest { .request(RouterCreateActiveSpeakerObserverRequest {
internal: RtpObserverInternal { handler_id: self.inner.id,
router_id: self.inner.id,
rtp_observer_id,
},
data: RouterCreateActiveSpeakerObserverData::from_options( data: RouterCreateActiveSpeakerObserverData::from_options(
rtp_observer_id,
&active_speaker_observer_options, &active_speaker_observer_options,
), ),
}) })
......
...@@ -4,7 +4,7 @@ mod tests; ...@@ -4,7 +4,7 @@ mod tests;
use crate::data_structures::AppData; use crate::data_structures::AppData;
use crate::messages::{ use crate::messages::{
RtpObserverAddProducerRequest, RtpObserverAddRemoveProducerRequestData, RtpObserverAddProducerRequest, RtpObserverAddRemoveProducerRequestData,
RtpObserverCloseRequest, RtpObserverInternal, RtpObserverPauseRequest, RtpObserverCloseRequest, RtpObserverCloseRequestData, RtpObserverPauseRequest,
RtpObserverRemoveProducerRequest, RtpObserverResumeRequest, RtpObserverRemoveProducerRequest, RtpObserverResumeRequest,
}; };
use crate::producer::{Producer, ProducerId}; use crate::producer::{Producer, ProducerId};
...@@ -109,8 +109,8 @@ impl Inner { ...@@ -109,8 +109,8 @@ impl Inner {
if close_request { if close_request {
let channel = self.channel.clone(); let channel = self.channel.clone();
let request = RtpObserverCloseRequest { let request = RtpObserverCloseRequest {
internal: RtpObserverInternal { handler_id: self.router.id(),
router_id: self.router.id(), data: RtpObserverCloseRequestData {
rtp_observer_id: self.id, rtp_observer_id: self.id,
}, },
}; };
...@@ -179,7 +179,7 @@ impl RtpObserver for ActiveSpeakerObserver { ...@@ -179,7 +179,7 @@ impl RtpObserver for ActiveSpeakerObserver {
self.inner self.inner
.channel .channel
.request(RtpObserverPauseRequest { .request(RtpObserverPauseRequest {
internal: self.get_internal(), handler_id: self.id(),
}) })
.await?; .await?;
...@@ -198,7 +198,7 @@ impl RtpObserver for ActiveSpeakerObserver { ...@@ -198,7 +198,7 @@ impl RtpObserver for ActiveSpeakerObserver {
self.inner self.inner
.channel .channel
.request(RtpObserverResumeRequest { .request(RtpObserverResumeRequest {
internal: self.get_internal(), handler_id: self.id(),
}) })
.await?; .await?;
...@@ -224,7 +224,7 @@ impl RtpObserver for ActiveSpeakerObserver { ...@@ -224,7 +224,7 @@ impl RtpObserver for ActiveSpeakerObserver {
self.inner self.inner
.channel .channel
.request(RtpObserverAddProducerRequest { .request(RtpObserverAddProducerRequest {
internal: self.get_internal(), handler_id: self.id(),
data: RtpObserverAddRemoveProducerRequestData { producer_id }, data: RtpObserverAddRemoveProducerRequestData { producer_id },
}) })
.await?; .await?;
...@@ -244,7 +244,7 @@ impl RtpObserver for ActiveSpeakerObserver { ...@@ -244,7 +244,7 @@ impl RtpObserver for ActiveSpeakerObserver {
self.inner self.inner
.channel .channel
.request(RtpObserverRemoveProducerRequest { .request(RtpObserverRemoveProducerRequest {
internal: self.get_internal(), handler_id: self.id(),
data: RtpObserverAddRemoveProducerRequestData { producer_id }, data: RtpObserverAddRemoveProducerRequestData { producer_id },
}) })
.await?; .await?;
...@@ -381,13 +381,6 @@ impl ActiveSpeakerObserver { ...@@ -381,13 +381,6 @@ impl ActiveSpeakerObserver {
inner: Arc::downgrade(&self.inner), inner: Arc::downgrade(&self.inner),
} }
} }
fn get_internal(&self) -> RtpObserverInternal {
RtpObserverInternal {
router_id: self.inner.router.id(),
rtp_observer_id: self.inner.id,
}
}
} }
/// [`WeakActiveSpeakerObserver`] doesn't own active speaker observer instance on mediasoup-worker /// [`WeakActiveSpeakerObserver`] doesn't own active speaker observer instance on mediasoup-worker
......
...@@ -4,7 +4,7 @@ mod tests; ...@@ -4,7 +4,7 @@ mod tests;
use crate::data_structures::AppData; use crate::data_structures::AppData;
use crate::messages::{ use crate::messages::{
RtpObserverAddProducerRequest, RtpObserverAddRemoveProducerRequestData, RtpObserverAddProducerRequest, RtpObserverAddRemoveProducerRequestData,
RtpObserverCloseRequest, RtpObserverInternal, RtpObserverPauseRequest, RtpObserverCloseRequest, RtpObserverCloseRequestData, RtpObserverPauseRequest,
RtpObserverRemoveProducerRequest, RtpObserverResumeRequest, RtpObserverRemoveProducerRequest, RtpObserverResumeRequest,
}; };
use crate::producer::{Producer, ProducerId}; use crate::producer::{Producer, ProducerId};
...@@ -120,8 +120,8 @@ impl Inner { ...@@ -120,8 +120,8 @@ impl Inner {
if close_request { if close_request {
let channel = self.channel.clone(); let channel = self.channel.clone();
let request = RtpObserverCloseRequest { let request = RtpObserverCloseRequest {
internal: RtpObserverInternal { handler_id: self.router.id(),
router_id: self.router.id(), data: RtpObserverCloseRequestData {
rtp_observer_id: self.id, rtp_observer_id: self.id,
}, },
}; };
...@@ -190,7 +190,7 @@ impl RtpObserver for AudioLevelObserver { ...@@ -190,7 +190,7 @@ impl RtpObserver for AudioLevelObserver {
self.inner self.inner
.channel .channel
.request(RtpObserverPauseRequest { .request(RtpObserverPauseRequest {
internal: self.get_internal(), handler_id: self.id(),
}) })
.await?; .await?;
...@@ -209,7 +209,7 @@ impl RtpObserver for AudioLevelObserver { ...@@ -209,7 +209,7 @@ impl RtpObserver for AudioLevelObserver {
self.inner self.inner
.channel .channel
.request(RtpObserverResumeRequest { .request(RtpObserverResumeRequest {
internal: self.get_internal(), handler_id: self.id(),
}) })
.await?; .await?;
...@@ -235,7 +235,7 @@ impl RtpObserver for AudioLevelObserver { ...@@ -235,7 +235,7 @@ impl RtpObserver for AudioLevelObserver {
self.inner self.inner
.channel .channel
.request(RtpObserverAddProducerRequest { .request(RtpObserverAddProducerRequest {
internal: self.get_internal(), handler_id: self.id(),
data: RtpObserverAddRemoveProducerRequestData { producer_id }, data: RtpObserverAddRemoveProducerRequestData { producer_id },
}) })
.await?; .await?;
...@@ -255,7 +255,7 @@ impl RtpObserver for AudioLevelObserver { ...@@ -255,7 +255,7 @@ impl RtpObserver for AudioLevelObserver {
self.inner self.inner
.channel .channel
.request(RtpObserverRemoveProducerRequest { .request(RtpObserverRemoveProducerRequest {
internal: self.get_internal(), handler_id: self.id(),
data: RtpObserverAddRemoveProducerRequestData { producer_id }, data: RtpObserverAddRemoveProducerRequestData { producer_id },
}) })
.await?; .await?;
...@@ -405,13 +405,6 @@ impl AudioLevelObserver { ...@@ -405,13 +405,6 @@ impl AudioLevelObserver {
inner: Arc::downgrade(&self.inner), inner: Arc::downgrade(&self.inner),
} }
} }
fn get_internal(&self) -> RtpObserverInternal {
RtpObserverInternal {
router_id: self.inner.router.id(),
rtp_observer_id: self.inner.id,
}
}
} }
/// [`WeakAudioLevelObserver`] doesn't own audio level observer instance on mediasoup-worker and /// [`WeakAudioLevelObserver`] doesn't own audio level observer instance on mediasoup-worker and
......
...@@ -3,8 +3,8 @@ mod tests; ...@@ -3,8 +3,8 @@ mod tests;
use crate::data_structures::{AppData, RtpPacketTraceInfo, SsrcTraceInfo, TraceEventDirection}; use crate::data_structures::{AppData, RtpPacketTraceInfo, SsrcTraceInfo, TraceEventDirection};
use crate::messages::{ use crate::messages::{
ConsumerCloseRequest, ConsumerDumpRequest, ConsumerEnableTraceEventData, ConsumerCloseRequest, ConsumerCloseRequestData, ConsumerDumpRequest,
ConsumerEnableTraceEventRequest, ConsumerGetStatsRequest, ConsumerInternal, ConsumerEnableTraceEventData, ConsumerEnableTraceEventRequest, ConsumerGetStatsRequest,
ConsumerPauseRequest, ConsumerRequestKeyFrameRequest, ConsumerResumeRequest, ConsumerPauseRequest, ConsumerRequestKeyFrameRequest, ConsumerResumeRequest,
ConsumerSetPreferredLayersRequest, ConsumerSetPriorityData, ConsumerSetPriorityRequest, ConsumerSetPreferredLayersRequest, ConsumerSetPriorityData, ConsumerSetPriorityRequest,
}; };
...@@ -405,9 +405,8 @@ impl Inner { ...@@ -405,9 +405,8 @@ impl Inner {
if close_request { if close_request {
let channel = self.channel.clone(); let channel = self.channel.clone();
let request = ConsumerCloseRequest { let request = ConsumerCloseRequest {
internal: ConsumerInternal { handler_id: self.transport.id(),
router_id: self.transport.router().id(), data: ConsumerCloseRequestData {
transport_id: self.transport.id(),
consumer_id: self.id, consumer_id: self.id,
}, },
}; };
...@@ -717,7 +716,7 @@ impl Consumer { ...@@ -717,7 +716,7 @@ impl Consumer {
self.inner self.inner
.channel .channel
.request(ConsumerDumpRequest { .request(ConsumerDumpRequest {
internal: self.get_internal(), handler_id: self.id(),
}) })
.await .await
} }
...@@ -732,7 +731,7 @@ impl Consumer { ...@@ -732,7 +731,7 @@ impl Consumer {
self.inner self.inner
.channel .channel
.request(ConsumerGetStatsRequest { .request(ConsumerGetStatsRequest {
internal: self.get_internal(), handler_id: self.id(),
}) })
.await .await
} }
...@@ -744,7 +743,7 @@ impl Consumer { ...@@ -744,7 +743,7 @@ impl Consumer {
self.inner self.inner
.channel .channel
.request(ConsumerPauseRequest { .request(ConsumerPauseRequest {
internal: self.get_internal(), handler_id: self.id(),
}) })
.await?; .await?;
...@@ -766,7 +765,7 @@ impl Consumer { ...@@ -766,7 +765,7 @@ impl Consumer {
self.inner self.inner
.channel .channel
.request(ConsumerResumeRequest { .request(ConsumerResumeRequest {
internal: self.get_internal(), handler_id: self.id(),
}) })
.await?; .await?;
...@@ -793,7 +792,7 @@ impl Consumer { ...@@ -793,7 +792,7 @@ impl Consumer {
.inner .inner
.channel .channel
.request(ConsumerSetPreferredLayersRequest { .request(ConsumerSetPreferredLayersRequest {
internal: self.get_internal(), handler_id: self.id(),
data: consumer_layers, data: consumer_layers,
}) })
.await?; .await?;
...@@ -813,7 +812,7 @@ impl Consumer { ...@@ -813,7 +812,7 @@ impl Consumer {
.inner .inner
.channel .channel
.request(ConsumerSetPriorityRequest { .request(ConsumerSetPriorityRequest {
internal: self.get_internal(), handler_id: self.id(),
data: ConsumerSetPriorityData { priority }, data: ConsumerSetPriorityData { priority },
}) })
.await?; .await?;
...@@ -833,7 +832,7 @@ impl Consumer { ...@@ -833,7 +832,7 @@ impl Consumer {
.inner .inner
.channel .channel
.request(ConsumerSetPriorityRequest { .request(ConsumerSetPriorityRequest {
internal: self.get_internal(), handler_id: self.id(),
data: ConsumerSetPriorityData { priority }, data: ConsumerSetPriorityData { priority },
}) })
.await?; .await?;
...@@ -850,7 +849,7 @@ impl Consumer { ...@@ -850,7 +849,7 @@ impl Consumer {
self.inner self.inner
.channel .channel
.request(ConsumerRequestKeyFrameRequest { .request(ConsumerRequestKeyFrameRequest {
internal: self.get_internal(), handler_id: self.id(),
}) })
.await .await
} }
...@@ -865,7 +864,7 @@ impl Consumer { ...@@ -865,7 +864,7 @@ impl Consumer {
self.inner self.inner
.channel .channel
.request(ConsumerEnableTraceEventRequest { .request(ConsumerEnableTraceEventRequest {
internal: self.get_internal(), handler_id: self.id(),
data: ConsumerEnableTraceEventData { types }, data: ConsumerEnableTraceEventData { types },
}) })
.await .await
...@@ -973,14 +972,6 @@ impl Consumer { ...@@ -973,14 +972,6 @@ impl Consumer {
inner: Arc::downgrade(&self.inner), inner: Arc::downgrade(&self.inner),
} }
} }
fn get_internal(&self) -> ConsumerInternal {
ConsumerInternal {
router_id: self.inner.transport.router().id(),
transport_id: self.inner.transport.id(),
consumer_id: self.inner.id,
}
}
} }
/// [`WeakConsumer`] doesn't own consumer instance on mediasoup-worker and will not prevent one from /// [`WeakConsumer`] doesn't own consumer instance on mediasoup-worker and will not prevent one from
......
...@@ -4,8 +4,8 @@ mod tests; ...@@ -4,8 +4,8 @@ mod tests;
use crate::data_producer::{DataProducer, DataProducerId, WeakDataProducer}; use crate::data_producer::{DataProducer, DataProducerId, WeakDataProducer};
use crate::data_structures::{AppData, WebRtcMessage}; use crate::data_structures::{AppData, WebRtcMessage};
use crate::messages::{ use crate::messages::{
DataConsumerCloseRequest, DataConsumerDumpRequest, DataConsumerGetBufferedAmountRequest, DataConsumerCloseRequest, DataConsumerCloseRequestData, DataConsumerDumpRequest,
DataConsumerGetStatsRequest, DataConsumerInternal, DataConsumerSendRequest, DataConsumerGetBufferedAmountRequest, DataConsumerGetStatsRequest, DataConsumerSendRequest,
DataConsumerSendRequestData, DataConsumerSetBufferedAmountLowThresholdData, DataConsumerSendRequestData, DataConsumerSetBufferedAmountLowThresholdData,
DataConsumerSetBufferedAmountLowThresholdRequest, DataConsumerSetBufferedAmountLowThresholdRequest,
}; };
...@@ -232,9 +232,8 @@ impl Inner { ...@@ -232,9 +232,8 @@ impl Inner {
if close_request { if close_request {
let channel = self.channel.clone(); let channel = self.channel.clone();
let request = DataConsumerCloseRequest { let request = DataConsumerCloseRequest {
internal: DataConsumerInternal { handler_id: self.transport.id(),
router_id: self.transport.router().id(), data: DataConsumerCloseRequestData {
transport_id: self.transport.id(),
data_consumer_id: self.id, data_consumer_id: self.id,
}, },
}; };
...@@ -533,7 +532,7 @@ impl DataConsumer { ...@@ -533,7 +532,7 @@ impl DataConsumer {
self.inner() self.inner()
.channel .channel
.request(DataConsumerDumpRequest { .request(DataConsumerDumpRequest {
internal: self.get_internal(), handler_id: self.id(),
}) })
.await .await
} }
...@@ -548,7 +547,7 @@ impl DataConsumer { ...@@ -548,7 +547,7 @@ impl DataConsumer {
self.inner() self.inner()
.channel .channel
.request(DataConsumerGetStatsRequest { .request(DataConsumerGetStatsRequest {
internal: self.get_internal(), handler_id: self.id(),
}) })
.await .await
} }
...@@ -567,7 +566,7 @@ impl DataConsumer { ...@@ -567,7 +566,7 @@ impl DataConsumer {
.inner() .inner()
.channel .channel
.request(DataConsumerGetBufferedAmountRequest { .request(DataConsumerGetBufferedAmountRequest {
internal: self.get_internal(), handler_id: self.id(),
}) })
.await?; .await?;
...@@ -588,7 +587,7 @@ impl DataConsumer { ...@@ -588,7 +587,7 @@ impl DataConsumer {
self.inner() self.inner()
.channel .channel
.request(DataConsumerSetBufferedAmountLowThresholdRequest { .request(DataConsumerSetBufferedAmountLowThresholdRequest {
internal: self.get_internal(), handler_id: self.id(),
data: DataConsumerSetBufferedAmountLowThresholdData { threshold }, data: DataConsumerSetBufferedAmountLowThresholdData { threshold },
}) })
.await .await
...@@ -675,14 +674,6 @@ impl DataConsumer { ...@@ -675,14 +674,6 @@ impl DataConsumer {
DataConsumer::Direct(data_consumer) => &data_consumer.inner, DataConsumer::Direct(data_consumer) => &data_consumer.inner,
} }
} }
fn get_internal(&self) -> DataConsumerInternal {
DataConsumerInternal {
router_id: self.inner().transport.router().id(),
transport_id: self.inner().transport.id(),
data_consumer_id: self.inner().id,
}
}
} }
impl DirectDataConsumer { impl DirectDataConsumer {
...@@ -694,11 +685,7 @@ impl DirectDataConsumer { ...@@ -694,11 +685,7 @@ impl DirectDataConsumer {
.payload_channel .payload_channel
.request( .request(
DataConsumerSendRequest { DataConsumerSendRequest {
internal: DataConsumerInternal { handler_id: self.inner.id,
router_id: self.inner.transport.router().id(),
transport_id: self.inner.transport.id(),
data_consumer_id: self.inner.id,
},
data: DataConsumerSendRequestData { ppid }, data: DataConsumerSendRequestData { ppid },
}, },
payload.into_owned(), payload.into_owned(),
......
...@@ -3,8 +3,8 @@ mod tests; ...@@ -3,8 +3,8 @@ mod tests;
use crate::data_structures::{AppData, WebRtcMessage}; use crate::data_structures::{AppData, WebRtcMessage};
use crate::messages::{ use crate::messages::{
DataProducerCloseRequest, DataProducerDumpRequest, DataProducerGetStatsRequest, DataProducerCloseRequest, DataProducerCloseRequestData, DataProducerDumpRequest,
DataProducerInternal, DataProducerSendData, DataProducerSendNotification, DataProducerGetStatsRequest, DataProducerSendData, DataProducerSendNotification,
}; };
use crate::sctp_parameters::SctpStreamParameters; use crate::sctp_parameters::SctpStreamParameters;
use crate::transport::Transport; use crate::transport::Transport;
...@@ -163,9 +163,8 @@ impl Inner { ...@@ -163,9 +163,8 @@ impl Inner {
if close_request { if close_request {
let channel = self.channel.clone(); let channel = self.channel.clone();
let request = DataProducerCloseRequest { let request = DataProducerCloseRequest {
internal: DataProducerInternal { handler_id: self.transport.id(),
router_id: self.transport.router().id(), data: DataProducerCloseRequestData {
transport_id: self.transport.id(),
data_producer_id: self.id, data_producer_id: self.id,
}, },
}; };
...@@ -374,7 +373,7 @@ impl DataProducer { ...@@ -374,7 +373,7 @@ impl DataProducer {
self.inner() self.inner()
.channel .channel
.request(DataProducerDumpRequest { .request(DataProducerDumpRequest {
internal: self.get_internal(), handler_id: self.id(),
}) })
.await .await
} }
...@@ -389,7 +388,7 @@ impl DataProducer { ...@@ -389,7 +388,7 @@ impl DataProducer {
self.inner() self.inner()
.channel .channel
.request(DataProducerGetStatsRequest { .request(DataProducerGetStatsRequest {
internal: self.get_internal(), handler_id: self.id(),
}) })
.await .await
} }
...@@ -433,14 +432,6 @@ impl DataProducer { ...@@ -433,14 +432,6 @@ impl DataProducer {
DataProducer::Direct(data_producer) => &data_producer.inner, DataProducer::Direct(data_producer) => &data_producer.inner,
} }
} }
fn get_internal(&self) -> DataProducerInternal {
DataProducerInternal {
router_id: self.inner().transport.router().id(),
transport_id: self.inner().transport.id(),
data_producer_id: self.inner().id,
}
}
} }
impl DirectDataProducer { impl DirectDataProducer {
...@@ -450,11 +441,7 @@ impl DirectDataProducer { ...@@ -450,11 +441,7 @@ impl DirectDataProducer {
self.inner.payload_channel.notify( self.inner.payload_channel.notify(
DataProducerSendNotification { DataProducerSendNotification {
internal: DataProducerInternal { handler_id: self.inner.id,
router_id: self.inner.transport.router().id(),
transport_id: self.inner.transport.id(),
data_producer_id: self.inner.id,
},
data: DataProducerSendData { ppid }, data: DataProducerSendData { ppid },
}, },
payload.into_owned(), payload.into_owned(),
......
...@@ -5,7 +5,9 @@ use crate::consumer::{Consumer, ConsumerId, ConsumerOptions}; ...@@ -5,7 +5,9 @@ use crate::consumer::{Consumer, ConsumerId, ConsumerOptions};
use crate::data_consumer::{DataConsumer, DataConsumerId, DataConsumerOptions, DataConsumerType}; use crate::data_consumer::{DataConsumer, DataConsumerId, DataConsumerOptions, DataConsumerType};
use crate::data_producer::{DataProducer, DataProducerId, DataProducerOptions, DataProducerType}; use crate::data_producer::{DataProducer, DataProducerId, DataProducerOptions, DataProducerType};
use crate::data_structures::{AppData, SctpState}; use crate::data_structures::{AppData, SctpState};
use crate::messages::{TransportCloseRequest, TransportInternal, TransportSendRtcpNotification}; use crate::messages::{
TransportCloseRequest, TransportCloseRequestData, TransportSendRtcpNotification,
};
use crate::producer::{Producer, ProducerId, ProducerOptions}; use crate::producer::{Producer, ProducerId, ProducerOptions};
use crate::router::transport::{TransportImpl, TransportType}; use crate::router::transport::{TransportImpl, TransportType};
use crate::router::Router; use crate::router::Router;
...@@ -170,8 +172,8 @@ impl Inner { ...@@ -170,8 +172,8 @@ impl Inner {
if close_request { if close_request {
let channel = self.channel.clone(); let channel = self.channel.clone();
let request = TransportCloseRequest { let request = TransportCloseRequest {
internal: TransportInternal { handler_id: self.router.id(),
router_id: self.router.id(), data: TransportCloseRequestData {
transport_id: self.id, transport_id: self.id,
}, },
}; };
...@@ -518,7 +520,7 @@ impl DirectTransport { ...@@ -518,7 +520,7 @@ impl DirectTransport {
pub fn send_rtcp(&self, rtcp_packet: Vec<u8>) -> Result<(), NotificationError> { pub fn send_rtcp(&self, rtcp_packet: Vec<u8>) -> Result<(), NotificationError> {
self.inner.payload_channel.notify( self.inner.payload_channel.notify(
TransportSendRtcpNotification { TransportSendRtcpNotification {
internal: self.get_internal(), handler_id: self.id(),
}, },
rtcp_packet, rtcp_packet,
) )
...@@ -536,13 +538,6 @@ impl DirectTransport { ...@@ -536,13 +538,6 @@ impl DirectTransport {
inner: Arc::downgrade(&self.inner), inner: Arc::downgrade(&self.inner),
} }
} }
fn get_internal(&self) -> TransportInternal {
TransportInternal {
router_id: self.router().id(),
transport_id: self.id(),
}
}
} }
/// [`WeakDirectTransport`] doesn't own direct transport instance on mediasoup-worker and will not /// [`WeakDirectTransport`] doesn't own direct transport instance on mediasoup-worker and will not
......
...@@ -6,8 +6,8 @@ use crate::data_consumer::{DataConsumer, DataConsumerId, DataConsumerOptions, Da ...@@ -6,8 +6,8 @@ use crate::data_consumer::{DataConsumer, DataConsumerId, DataConsumerOptions, Da
use crate::data_producer::{DataProducer, DataProducerId, DataProducerOptions, DataProducerType}; use crate::data_producer::{DataProducer, DataProducerId, DataProducerOptions, DataProducerType};
use crate::data_structures::{AppData, ListenIp, SctpState, TransportTuple}; use crate::data_structures::{AppData, ListenIp, SctpState, TransportTuple};
use crate::messages::{ use crate::messages::{
PipeTransportData, TransportCloseRequest, TransportConnectPipeRequest, PipeTransportData, TransportCloseRequest, TransportCloseRequestData,
TransportConnectRequestPipeData, TransportInternal, TransportConnectPipeRequest, TransportConnectRequestPipeData,
}; };
use crate::producer::{Producer, ProducerId, ProducerOptions}; use crate::producer::{Producer, ProducerId, ProducerOptions};
use crate::router::transport::{TransportImpl, TransportType}; use crate::router::transport::{TransportImpl, TransportType};
...@@ -221,8 +221,8 @@ impl Inner { ...@@ -221,8 +221,8 @@ impl Inner {
if close_request { if close_request {
let channel = self.channel.clone(); let channel = self.channel.clone();
let request = TransportCloseRequest { let request = TransportCloseRequest {
internal: TransportInternal { handler_id: self.router.id(),
router_id: self.router.id(), data: TransportCloseRequestData {
transport_id: self.id, transport_id: self.id,
}, },
}; };
...@@ -559,7 +559,7 @@ impl PipeTransport { ...@@ -559,7 +559,7 @@ impl PipeTransport {
.inner .inner
.channel .channel
.request(TransportConnectPipeRequest { .request(TransportConnectPipeRequest {
internal: self.get_internal(), handler_id: self.id(),
data: TransportConnectRequestPipeData { data: TransportConnectRequestPipeData {
ip: remote_parameters.ip, ip: remote_parameters.ip,
port: remote_parameters.port, port: remote_parameters.port,
...@@ -641,13 +641,6 @@ impl PipeTransport { ...@@ -641,13 +641,6 @@ impl PipeTransport {
inner: Arc::downgrade(&self.inner), inner: Arc::downgrade(&self.inner),
} }
} }
fn get_internal(&self) -> TransportInternal {
TransportInternal {
router_id: self.router().id(),
transport_id: self.id(),
}
}
} }
/// [`WeakPipeTransport`] doesn't own pipe transport instance on mediasoup-worker and will not /// [`WeakPipeTransport`] doesn't own pipe transport instance on mediasoup-worker and will not
......
...@@ -75,17 +75,22 @@ async fn init() -> (Router, Router, WebRtcTransport, WebRtcTransport) { ...@@ -75,17 +75,22 @@ async fn init() -> (Router, Router, WebRtcTransport, WebRtcTransport) {
let worker_manager = WorkerManager::new(); let worker_manager = WorkerManager::new();
let worker = worker_manager let worker1 = worker_manager
.create_worker(WorkerSettings::default()) .create_worker(WorkerSettings::default())
.await .await
.expect("Failed to create worker"); .expect("Failed to create worker");
let router1 = worker let worker2 = worker_manager
.create_worker(WorkerSettings::default())
.await
.expect("Failed to create worker");
let router1 = worker1
.create_router(RouterOptions::new(media_codecs())) .create_router(RouterOptions::new(media_codecs()))
.await .await
.expect("Failed to create router"); .expect("Failed to create router");
let router2 = worker let router2 = worker2
.create_router(RouterOptions::new(media_codecs())) .create_router(RouterOptions::new(media_codecs()))
.await .await
.expect("Failed to create router"); .expect("Failed to create router");
......
...@@ -6,8 +6,8 @@ use crate::data_consumer::{DataConsumer, DataConsumerId, DataConsumerOptions, Da ...@@ -6,8 +6,8 @@ use crate::data_consumer::{DataConsumer, DataConsumerId, DataConsumerOptions, Da
use crate::data_producer::{DataProducer, DataProducerId, DataProducerOptions, DataProducerType}; use crate::data_producer::{DataProducer, DataProducerId, DataProducerOptions, DataProducerType};
use crate::data_structures::{AppData, ListenIp, SctpState, TransportTuple}; use crate::data_structures::{AppData, ListenIp, SctpState, TransportTuple};
use crate::messages::{ use crate::messages::{
PlainTransportData, TransportCloseRequest, TransportConnectPlainRequest, PlainTransportData, TransportCloseRequest, TransportCloseRequestData,
TransportConnectRequestPlainData, TransportInternal, TransportConnectPlainRequest, TransportConnectRequestPlainData,
}; };
use crate::producer::{Producer, ProducerId, ProducerOptions}; use crate::producer::{Producer, ProducerId, ProducerOptions};
use crate::router::transport::{TransportImpl, TransportType}; use crate::router::transport::{TransportImpl, TransportType};
...@@ -258,8 +258,8 @@ impl Inner { ...@@ -258,8 +258,8 @@ impl Inner {
if close_request { if close_request {
let channel = self.channel.clone(); let channel = self.channel.clone();
let request = TransportCloseRequest { let request = TransportCloseRequest {
internal: TransportInternal { handler_id: self.router.id(),
router_id: self.router.id(), data: TransportCloseRequestData {
transport_id: self.id, transport_id: self.id,
}, },
}; };
...@@ -694,7 +694,7 @@ impl PlainTransport { ...@@ -694,7 +694,7 @@ impl PlainTransport {
.inner .inner
.channel .channel
.request(TransportConnectPlainRequest { .request(TransportConnectPlainRequest {
internal: self.get_internal(), handler_id: self.inner.id,
data: TransportConnectRequestPlainData { data: TransportConnectRequestPlainData {
ip: remote_parameters.ip, ip: remote_parameters.ip,
port: remote_parameters.port, port: remote_parameters.port,
...@@ -816,13 +816,6 @@ impl PlainTransport { ...@@ -816,13 +816,6 @@ impl PlainTransport {
inner: Arc::downgrade(&self.inner), inner: Arc::downgrade(&self.inner),
} }
} }
fn get_internal(&self) -> TransportInternal {
TransportInternal {
router_id: self.router().id(),
transport_id: self.id(),
}
}
} }
/// [`WeakPlainTransport`] doesn't own pipe transport instance on mediasoup-worker and will not /// [`WeakPlainTransport`] doesn't own pipe transport instance on mediasoup-worker and will not
......
...@@ -4,8 +4,8 @@ mod tests; ...@@ -4,8 +4,8 @@ mod tests;
use crate::consumer::RtpStreamParams; use crate::consumer::RtpStreamParams;
use crate::data_structures::{AppData, RtpPacketTraceInfo, SsrcTraceInfo, TraceEventDirection}; use crate::data_structures::{AppData, RtpPacketTraceInfo, SsrcTraceInfo, TraceEventDirection};
use crate::messages::{ use crate::messages::{
ProducerCloseRequest, ProducerDumpRequest, ProducerEnableTraceEventData, ProducerCloseRequest, ProducerCloseRequestData, ProducerDumpRequest,
ProducerEnableTraceEventRequest, ProducerGetStatsRequest, ProducerInternal, ProducerEnableTraceEventData, ProducerEnableTraceEventRequest, ProducerGetStatsRequest,
ProducerPauseRequest, ProducerResumeRequest, ProducerSendNotification, ProducerPauseRequest, ProducerResumeRequest, ProducerSendNotification,
}; };
pub use crate::ortc::RtpMapping; pub use crate::ortc::RtpMapping;
...@@ -328,9 +328,8 @@ impl Inner { ...@@ -328,9 +328,8 @@ impl Inner {
if close_request { if close_request {
let channel = self.channel.clone(); let channel = self.channel.clone();
let request = ProducerCloseRequest { let request = ProducerCloseRequest {
internal: ProducerInternal { handler_id: self.transport.id(),
router_id: self.transport.router().id(), data: ProducerCloseRequestData {
transport_id: self.transport.id(),
producer_id: self.id, producer_id: self.id,
}, },
}; };
...@@ -590,7 +589,7 @@ impl Producer { ...@@ -590,7 +589,7 @@ impl Producer {
self.inner() self.inner()
.channel .channel
.request(ProducerDumpRequest { .request(ProducerDumpRequest {
internal: self.get_internal(), handler_id: self.id(),
}) })
.await .await
} }
...@@ -605,7 +604,7 @@ impl Producer { ...@@ -605,7 +604,7 @@ impl Producer {
self.inner() self.inner()
.channel .channel
.request(ProducerGetStatsRequest { .request(ProducerGetStatsRequest {
internal: self.get_internal(), handler_id: self.id(),
}) })
.await .await
} }
...@@ -619,7 +618,7 @@ impl Producer { ...@@ -619,7 +618,7 @@ impl Producer {
self.inner() self.inner()
.channel .channel
.request(ProducerPauseRequest { .request(ProducerPauseRequest {
internal: self.get_internal(), handler_id: self.id(),
}) })
.await?; .await?;
...@@ -641,7 +640,7 @@ impl Producer { ...@@ -641,7 +640,7 @@ impl Producer {
self.inner() self.inner()
.channel .channel
.request(ProducerResumeRequest { .request(ProducerResumeRequest {
internal: self.get_internal(), handler_id: self.id(),
}) })
.await?; .await?;
...@@ -664,7 +663,7 @@ impl Producer { ...@@ -664,7 +663,7 @@ impl Producer {
self.inner() self.inner()
.channel .channel
.request(ProducerEnableTraceEventRequest { .request(ProducerEnableTraceEventRequest {
internal: self.get_internal(), handler_id: self.id(),
data: ProducerEnableTraceEventData { types }, data: ProducerEnableTraceEventData { types },
}) })
.await .await
...@@ -756,14 +755,6 @@ impl Producer { ...@@ -756,14 +755,6 @@ impl Producer {
Producer::Direct(producer) => &producer.inner, Producer::Direct(producer) => &producer.inner,
} }
} }
fn get_internal(&self) -> ProducerInternal {
ProducerInternal {
router_id: self.inner().transport.router().id(),
transport_id: self.inner().transport.id(),
producer_id: self.inner().id,
}
}
} }
impl DirectProducer { impl DirectProducer {
...@@ -771,11 +762,7 @@ impl DirectProducer { ...@@ -771,11 +762,7 @@ impl DirectProducer {
pub fn send(&self, rtp_packet: Vec<u8>) -> Result<(), NotificationError> { pub fn send(&self, rtp_packet: Vec<u8>) -> Result<(), NotificationError> {
self.inner.payload_channel.notify( self.inner.payload_channel.notify(
ProducerSendNotification { ProducerSendNotification {
internal: ProducerInternal { handler_id: self.inner.id,
router_id: self.inner.transport.router().id(),
transport_id: self.inner.transport.id(),
producer_id: self.inner.id,
},
}, },
rtp_packet, rtp_packet,
) )
......
...@@ -3,14 +3,12 @@ use crate::data_consumer::{DataConsumer, DataConsumerId, DataConsumerOptions, Da ...@@ -3,14 +3,12 @@ use crate::data_consumer::{DataConsumer, DataConsumerId, DataConsumerOptions, Da
use crate::data_producer::{DataProducer, DataProducerId, DataProducerOptions, DataProducerType}; use crate::data_producer::{DataProducer, DataProducerId, DataProducerOptions, DataProducerType};
use crate::data_structures::{AppData, BweTraceInfo, RtpPacketTraceInfo, TraceEventDirection}; use crate::data_structures::{AppData, BweTraceInfo, RtpPacketTraceInfo, TraceEventDirection};
use crate::messages::{ use crate::messages::{
ConsumerInternal, DataConsumerInternal, DataProducerInternal, ProducerInternal,
TransportConsumeData, TransportConsumeDataData, TransportConsumeDataRequest, TransportConsumeData, TransportConsumeDataData, TransportConsumeDataRequest,
TransportConsumeRequest, TransportDumpRequest, TransportEnableTraceEventData, TransportConsumeRequest, TransportDumpRequest, TransportEnableTraceEventData,
TransportEnableTraceEventRequest, TransportGetStatsRequest, TransportInternal, TransportEnableTraceEventRequest, TransportGetStatsRequest, TransportProduceData,
TransportProduceData, TransportProduceDataData, TransportProduceDataRequest, TransportProduceDataData, TransportProduceDataRequest, TransportProduceRequest,
TransportProduceRequest, TransportSetMaxIncomingBitrateData, TransportSetMaxIncomingBitrateData, TransportSetMaxIncomingBitrateRequest,
TransportSetMaxIncomingBitrateRequest, TransportSetMaxOutgoingBitrateData, TransportSetMaxOutgoingBitrateData, TransportSetMaxOutgoingBitrateRequest,
TransportSetMaxOutgoingBitrateRequest,
}; };
pub use crate::ortc::{ pub use crate::ortc::{
ConsumerRtpParametersError, RtpCapabilitiesError, RtpParametersError, RtpParametersMappingError, ConsumerRtpParametersError, RtpCapabilitiesError, RtpParametersError, RtpParametersMappingError,
...@@ -369,10 +367,7 @@ pub(super) trait TransportImpl: TransportGeneric { ...@@ -369,10 +367,7 @@ pub(super) trait TransportImpl: TransportGeneric {
async fn dump_impl(&self) -> Result<Value, RequestError> { async fn dump_impl(&self) -> Result<Value, RequestError> {
self.channel() self.channel()
.request(TransportDumpRequest { .request(TransportDumpRequest {
internal: TransportInternal { handler_id: self.id(),
router_id: self.router().id(),
transport_id: self.id(),
},
}) })
.await .await
} }
...@@ -380,10 +375,7 @@ pub(super) trait TransportImpl: TransportGeneric { ...@@ -380,10 +375,7 @@ pub(super) trait TransportImpl: TransportGeneric {
async fn get_stats_impl(&self) -> Result<Value, RequestError> { async fn get_stats_impl(&self) -> Result<Value, RequestError> {
self.channel() self.channel()
.request(TransportGetStatsRequest { .request(TransportGetStatsRequest {
internal: TransportInternal { handler_id: self.id(),
router_id: self.router().id(),
transport_id: self.id(),
},
}) })
.await .await
} }
...@@ -391,10 +383,7 @@ pub(super) trait TransportImpl: TransportGeneric { ...@@ -391,10 +383,7 @@ pub(super) trait TransportImpl: TransportGeneric {
async fn set_max_incoming_bitrate_impl(&self, bitrate: u32) -> Result<(), RequestError> { async fn set_max_incoming_bitrate_impl(&self, bitrate: u32) -> Result<(), RequestError> {
self.channel() self.channel()
.request(TransportSetMaxIncomingBitrateRequest { .request(TransportSetMaxIncomingBitrateRequest {
internal: TransportInternal { handler_id: self.id(),
router_id: self.router().id(),
transport_id: self.id(),
},
data: TransportSetMaxIncomingBitrateData { bitrate }, data: TransportSetMaxIncomingBitrateData { bitrate },
}) })
.await .await
...@@ -403,10 +392,7 @@ pub(super) trait TransportImpl: TransportGeneric { ...@@ -403,10 +392,7 @@ pub(super) trait TransportImpl: TransportGeneric {
async fn set_max_outgoing_bitrate_impl(&self, bitrate: u32) -> Result<(), RequestError> { async fn set_max_outgoing_bitrate_impl(&self, bitrate: u32) -> Result<(), RequestError> {
self.channel() self.channel()
.request(TransportSetMaxOutgoingBitrateRequest { .request(TransportSetMaxOutgoingBitrateRequest {
internal: TransportInternal { handler_id: self.id(),
router_id: self.router().id(),
transport_id: self.id(),
},
data: TransportSetMaxOutgoingBitrateData { bitrate }, data: TransportSetMaxOutgoingBitrateData { bitrate },
}) })
.await .await
...@@ -418,10 +404,7 @@ pub(super) trait TransportImpl: TransportGeneric { ...@@ -418,10 +404,7 @@ pub(super) trait TransportImpl: TransportGeneric {
) -> Result<(), RequestError> { ) -> Result<(), RequestError> {
self.channel() self.channel()
.request(TransportEnableTraceEventRequest { .request(TransportEnableTraceEventRequest {
internal: TransportInternal { handler_id: self.id(),
router_id: self.router().id(),
transport_id: self.id(),
},
data: TransportEnableTraceEventData { types }, data: TransportEnableTraceEventData { types },
}) })
.await .await
...@@ -496,12 +479,9 @@ pub(super) trait TransportImpl: TransportGeneric { ...@@ -496,12 +479,9 @@ pub(super) trait TransportImpl: TransportGeneric {
let response = self let response = self
.channel() .channel()
.request(TransportProduceRequest { .request(TransportProduceRequest {
internal: ProducerInternal { handler_id: self.id(),
router_id: self.router().id(),
transport_id: self.id(),
producer_id,
},
data: TransportProduceData { data: TransportProduceData {
producer_id,
kind, kind,
rtp_parameters: rtp_parameters.clone(), rtp_parameters: rtp_parameters.clone(),
rtp_mapping, rtp_mapping,
...@@ -594,12 +574,9 @@ pub(super) trait TransportImpl: TransportGeneric { ...@@ -594,12 +574,9 @@ pub(super) trait TransportImpl: TransportGeneric {
let response = self let response = self
.channel() .channel()
.request(TransportConsumeRequest { .request(TransportConsumeRequest {
internal: ConsumerInternal { handler_id: self.id(),
router_id: self.router().id(),
transport_id: self.id(),
consumer_id,
},
data: TransportConsumeData { data: TransportConsumeData {
consumer_id,
producer_id: producer.id(), producer_id: producer.id(),
kind: producer.kind(), kind: producer.kind(),
rtp_parameters: rtp_parameters.clone(), rtp_parameters: rtp_parameters.clone(),
...@@ -675,12 +652,9 @@ pub(super) trait TransportImpl: TransportGeneric { ...@@ -675,12 +652,9 @@ pub(super) trait TransportImpl: TransportGeneric {
let response = self let response = self
.channel() .channel()
.request(TransportProduceDataRequest { .request(TransportProduceDataRequest {
internal: DataProducerInternal { handler_id: self.id(),
router_id: self.router().id(),
transport_id: self.id(),
data_producer_id,
},
data: TransportProduceDataData { data: TransportProduceDataData {
data_producer_id,
r#type, r#type,
sctp_stream_parameters, sctp_stream_parameters,
label, label,
...@@ -763,12 +737,9 @@ pub(super) trait TransportImpl: TransportGeneric { ...@@ -763,12 +737,9 @@ pub(super) trait TransportImpl: TransportGeneric {
let response = self let response = self
.channel() .channel()
.request(TransportConsumeDataRequest { .request(TransportConsumeDataRequest {
internal: DataConsumerInternal { handler_id: self.id(),
router_id: self.router().id(),
transport_id: self.id(),
data_consumer_id,
},
data: TransportConsumeDataData { data: TransportConsumeDataData {
data_consumer_id,
data_producer_id: data_producer.id(), data_producer_id: data_producer.id(),
r#type, r#type,
sctp_stream_parameters, sctp_stream_parameters,
......
...@@ -9,8 +9,8 @@ use crate::data_structures::{ ...@@ -9,8 +9,8 @@ use crate::data_structures::{
SctpState, TransportTuple, SctpState, TransportTuple,
}; };
use crate::messages::{ use crate::messages::{
TransportCloseRequest, TransportConnectRequestWebRtcData, TransportConnectWebRtcRequest, TransportCloseRequest, TransportCloseRequestData, TransportConnectRequestWebRtcData,
TransportInternal, TransportRestartIceRequest, WebRtcTransportData, TransportConnectWebRtcRequest, TransportRestartIceRequest, WebRtcTransportData,
}; };
use crate::producer::{Producer, ProducerId, ProducerOptions}; use crate::producer::{Producer, ProducerId, ProducerOptions};
use crate::router::transport::{TransportImpl, TransportType}; use crate::router::transport::{TransportImpl, TransportType};
...@@ -345,8 +345,8 @@ impl Inner { ...@@ -345,8 +345,8 @@ impl Inner {
if close_request { if close_request {
let channel = self.channel.clone(); let channel = self.channel.clone();
let request = TransportCloseRequest { let request = TransportCloseRequest {
internal: TransportInternal { handler_id: self.router.id(),
router_id: self.router.id(), data: TransportCloseRequestData {
transport_id: self.id, transport_id: self.id,
}, },
}; };
...@@ -763,7 +763,7 @@ impl WebRtcTransport { ...@@ -763,7 +763,7 @@ impl WebRtcTransport {
.inner .inner
.channel .channel
.request(TransportConnectWebRtcRequest { .request(TransportConnectWebRtcRequest {
internal: self.get_internal(), handler_id: self.id(),
data: TransportConnectRequestWebRtcData { data: TransportConnectRequestWebRtcData {
dtls_parameters: remote_parameters.dtls_parameters, dtls_parameters: remote_parameters.dtls_parameters,
}, },
...@@ -870,7 +870,7 @@ impl WebRtcTransport { ...@@ -870,7 +870,7 @@ impl WebRtcTransport {
.inner .inner
.channel .channel
.request(TransportRestartIceRequest { .request(TransportRestartIceRequest {
internal: self.get_internal(), handler_id: self.id(),
}) })
.await?; .await?;
...@@ -937,13 +937,6 @@ impl WebRtcTransport { ...@@ -937,13 +937,6 @@ impl WebRtcTransport {
inner: Arc::downgrade(&self.inner), inner: Arc::downgrade(&self.inner),
} }
} }
fn get_internal(&self) -> TransportInternal {
TransportInternal {
router_id: self.router().id(),
transport_id: self.id(),
}
}
} }
/// [`WeakWebRtcTransport`] doesn't own [`WebRtcTransport`] instance on mediasoup-worker and will /// [`WeakWebRtcTransport`] doesn't own [`WebRtcTransport`] instance on mediasoup-worker and will
......
...@@ -11,7 +11,9 @@ ...@@ -11,7 +11,9 @@
mod tests; mod tests;
use crate::data_structures::{AppData, ListenIp, Protocol}; use crate::data_structures::{AppData, ListenIp, Protocol};
use crate::messages::{WebRtcServerCloseRequest, WebRtcServerDumpRequest, WebRtcServerInternal}; use crate::messages::{
WebRtcServerCloseRequest, WebRtcServerCloseRequestData, WebRtcServerDumpRequest,
};
use crate::transport::TransportId; use crate::transport::TransportId;
use crate::uuid_based_wrapper_type; use crate::uuid_based_wrapper_type;
use crate::webrtc_transport::WebRtcTransport; use crate::webrtc_transport::WebRtcTransport;
...@@ -185,7 +187,7 @@ impl Inner { ...@@ -185,7 +187,7 @@ impl Inner {
{ {
let channel = self.channel.clone(); let channel = self.channel.clone();
let request = WebRtcServerCloseRequest { let request = WebRtcServerCloseRequest {
internal: WebRtcServerInternal { data: WebRtcServerCloseRequestData {
webrtc_server_id: self.id, webrtc_server_id: self.id,
}, },
}; };
...@@ -294,9 +296,7 @@ impl WebRtcServer { ...@@ -294,9 +296,7 @@ impl WebRtcServer {
self.inner self.inner
.channel .channel
.request(WebRtcServerDumpRequest { .request(WebRtcServerDumpRequest {
internal: WebRtcServerInternal { handler_id: self.id(),
webrtc_server_id: self.inner.id,
},
}) })
.await .await
} }
......
...@@ -8,7 +8,7 @@ mod utils; ...@@ -8,7 +8,7 @@ mod utils;
use crate::data_structures::AppData; use crate::data_structures::AppData;
use crate::messages::{ use crate::messages::{
RouterInternal, WebRtcServerInternal, WorkerCloseRequest, WorkerCreateRouterRequest, WorkerCloseRequest, WorkerCreateRouterRequest, WorkerCreateRouterRequestData,
WorkerCreateWebRtcServerData, WorkerCreateWebRtcServerRequest, WorkerDumpRequest, WorkerCreateWebRtcServerData, WorkerCreateWebRtcServerRequest, WorkerDumpRequest,
WorkerUpdateSettingsRequest, WorkerUpdateSettingsRequest,
}; };
...@@ -628,7 +628,6 @@ impl Worker { ...@@ -628,7 +628,6 @@ impl Worker {
} = webrtc_server_options; } = webrtc_server_options;
let webrtc_server_id = WebRtcServerId::new(); let webrtc_server_id = WebRtcServerId::new();
let internal = WebRtcServerInternal { webrtc_server_id };
let _buffer_guard = self let _buffer_guard = self
.inner .inner
...@@ -638,8 +637,10 @@ impl Worker { ...@@ -638,8 +637,10 @@ impl Worker {
self.inner self.inner
.channel .channel
.request(WorkerCreateWebRtcServerRequest { .request(WorkerCreateWebRtcServerRequest {
internal, data: WorkerCreateWebRtcServerData {
data: WorkerCreateWebRtcServerData { listen_infos }, webrtc_server_id,
listen_infos,
},
}) })
.await .await
.map_err(CreateWebRtcServerError::Request)?; .map_err(CreateWebRtcServerError::Request)?;
...@@ -678,13 +679,14 @@ impl Worker { ...@@ -678,13 +679,14 @@ impl Worker {
.map_err(CreateRouterError::FailedRtpCapabilitiesGeneration)?; .map_err(CreateRouterError::FailedRtpCapabilitiesGeneration)?;
let router_id = RouterId::new(); let router_id = RouterId::new();
let internal = RouterInternal { router_id };
let _buffer_guard = self.inner.channel.buffer_messages_for(router_id.into()); let _buffer_guard = self.inner.channel.buffer_messages_for(router_id.into());
self.inner self.inner
.channel .channel
.request(WorkerCreateRouterRequest { internal }) .request(WorkerCreateRouterRequest {
data: WorkerCreateRouterRequestData { router_id },
})
.await .await
.map_err(CreateRouterError::Request)?; .map_err(CreateRouterError::Request)?;
......
...@@ -214,7 +214,14 @@ fn consumer_device_capabilities() -> RtpCapabilities { ...@@ -214,7 +214,14 @@ fn consumer_device_capabilities() -> RtpCapabilities {
} }
} }
async fn init() -> (Worker, Router, Router, WebRtcTransport, WebRtcTransport) { async fn init() -> (
Worker,
Worker,
Router,
Router,
WebRtcTransport,
WebRtcTransport,
) {
{ {
let mut builder = env_logger::builder(); let mut builder = env_logger::builder();
if env::var(env_logger::DEFAULT_FILTER_ENV).is_err() { if env::var(env_logger::DEFAULT_FILTER_ENV).is_err() {
...@@ -225,17 +232,22 @@ async fn init() -> (Worker, Router, Router, WebRtcTransport, WebRtcTransport) { ...@@ -225,17 +232,22 @@ async fn init() -> (Worker, Router, Router, WebRtcTransport, WebRtcTransport) {
let worker_manager = WorkerManager::new(); let worker_manager = WorkerManager::new();
let worker = worker_manager let worker1 = worker_manager
.create_worker(WorkerSettings::default()) .create_worker(WorkerSettings::default())
.await .await
.expect("Failed to create worker"); .expect("Failed to create worker");
let router1 = worker let worker2 = worker_manager
.create_worker(WorkerSettings::default())
.await
.expect("Failed to create worker");
let router1 = worker1
.create_router(RouterOptions::new(media_codecs())) .create_router(RouterOptions::new(media_codecs()))
.await .await
.expect("Failed to create router"); .expect("Failed to create router");
let router2 = worker let router2 = worker2
.create_router(RouterOptions::new(media_codecs())) .create_router(RouterOptions::new(media_codecs()))
.await .await
.expect("Failed to create router"); .expect("Failed to create router");
...@@ -256,13 +268,13 @@ async fn init() -> (Worker, Router, Router, WebRtcTransport, WebRtcTransport) { ...@@ -256,13 +268,13 @@ async fn init() -> (Worker, Router, Router, WebRtcTransport, WebRtcTransport) {
.await .await
.expect("Failed to create transport2"); .expect("Failed to create transport2");
(worker, router1, router2, transport_1, transport_2) (worker1, worker2, router1, router2, transport_1, transport_2)
} }
#[test] #[test]
fn pipe_to_router_succeeds_with_audio() { fn pipe_to_router_succeeds_with_audio() {
future::block_on(async move { future::block_on(async move {
let (_worker, router1, router2, transport1, _transport2) = init().await; let (_worker1, _worker2, router1, router2, transport1, _transport2) = init().await;
let audio_producer = transport1 let audio_producer = transport1
.produce(audio_producer_options()) .produce(audio_producer_options())
...@@ -383,7 +395,7 @@ fn pipe_to_router_succeeds_with_audio() { ...@@ -383,7 +395,7 @@ fn pipe_to_router_succeeds_with_audio() {
#[test] #[test]
fn pipe_to_router_succeeds_with_video() { fn pipe_to_router_succeeds_with_video() {
future::block_on(async move { future::block_on(async move {
let (_worker, router1, router2, transport1, _transport2) = init().await; let (_worker1, _worker2, router1, router2, transport1, _transport2) = init().await;
let audio_producer = transport1 let audio_producer = transport1
.produce(audio_producer_options()) .produce(audio_producer_options())
...@@ -543,7 +555,7 @@ fn pipe_to_router_succeeds_with_video() { ...@@ -543,7 +555,7 @@ fn pipe_to_router_succeeds_with_video() {
#[test] #[test]
fn weak() { fn weak() {
future::block_on(async move { future::block_on(async move {
let (_worker, router1, _router2, _transport1, _transport2) = init().await; let (_worker1, _worker2, router1, _router2, _transport1, _transport2) = init().await;
let pipe_transport = router1 let pipe_transport = router1
.create_pipe_transport({ .create_pipe_transport({
...@@ -571,7 +583,7 @@ fn weak() { ...@@ -571,7 +583,7 @@ fn weak() {
#[test] #[test]
fn create_with_fixed_port_succeeds() { fn create_with_fixed_port_succeeds() {
future::block_on(async move { future::block_on(async move {
let (_worker, router1, _router2, _transport1, _transport2) = init().await; let (_worker1, _worker2, router1, _router2, _transport1, _transport2) = init().await;
let port = pick_unused_port().unwrap(); let port = pick_unused_port().unwrap();
...@@ -595,7 +607,7 @@ fn create_with_fixed_port_succeeds() { ...@@ -595,7 +607,7 @@ fn create_with_fixed_port_succeeds() {
#[test] #[test]
fn create_with_enable_rtx_succeeds() { fn create_with_enable_rtx_succeeds() {
future::block_on(async move { future::block_on(async move {
let (_worker, router1, _router2, transport1, _transport2) = init().await; let (_worker1, _worker2, router1, _router2, transport1, _transport2) = init().await;
let pipe_transport = router1 let pipe_transport = router1
.create_pipe_transport({ .create_pipe_transport({
...@@ -703,7 +715,7 @@ fn create_with_enable_rtx_succeeds() { ...@@ -703,7 +715,7 @@ fn create_with_enable_rtx_succeeds() {
#[test] #[test]
fn create_with_enable_srtp_succeeds() { fn create_with_enable_srtp_succeeds() {
future::block_on(async move { future::block_on(async move {
let (_worker, router1, _router2, _transport1, _transport2) = init().await; let (_worker1, _worker2, router1, _router2, _transport1, _transport2) = init().await;
let pipe_transport = router1 let pipe_transport = router1
.create_pipe_transport({ .create_pipe_transport({
...@@ -755,7 +767,7 @@ fn create_with_enable_srtp_succeeds() { ...@@ -755,7 +767,7 @@ fn create_with_enable_srtp_succeeds() {
#[test] #[test]
fn create_with_invalid_srtp_parameters_fails() { fn create_with_invalid_srtp_parameters_fails() {
future::block_on(async move { future::block_on(async move {
let (_worker, router1, _router2, _transport1, _transport2) = init().await; let (_worker1, _worker2, router1, _router2, _transport1, _transport2) = init().await;
let pipe_transport = router1 let pipe_transport = router1
.create_pipe_transport(PipeTransportOptions::new(ListenIp { .create_pipe_transport(PipeTransportOptions::new(ListenIp {
...@@ -786,7 +798,7 @@ fn create_with_invalid_srtp_parameters_fails() { ...@@ -786,7 +798,7 @@ fn create_with_invalid_srtp_parameters_fails() {
#[test] #[test]
fn consume_for_pipe_producer_succeeds() { fn consume_for_pipe_producer_succeeds() {
future::block_on(async move { future::block_on(async move {
let (_worker, router1, router2, transport1, transport2) = init().await; let (_worker1, _worker2, router1, router2, transport1, transport2) = init().await;
let video_producer = transport1 let video_producer = transport1
.produce(video_producer_options()) .produce(video_producer_options())
...@@ -876,7 +888,7 @@ fn consume_for_pipe_producer_succeeds() { ...@@ -876,7 +888,7 @@ fn consume_for_pipe_producer_succeeds() {
#[test] #[test]
fn producer_pause_resume_are_transmitted_to_pipe_consumer() { fn producer_pause_resume_are_transmitted_to_pipe_consumer() {
future::block_on(async move { future::block_on(async move {
let (_worker, router1, router2, transport1, transport2) = init().await; let (_worker1, _worker2, router1, router2, transport1, transport2) = init().await;
let video_producer = transport1 let video_producer = transport1
.produce(video_producer_options()) .produce(video_producer_options())
...@@ -956,7 +968,7 @@ fn producer_pause_resume_are_transmitted_to_pipe_consumer() { ...@@ -956,7 +968,7 @@ fn producer_pause_resume_are_transmitted_to_pipe_consumer() {
#[test] #[test]
fn pipe_to_router_succeeds_with_data() { fn pipe_to_router_succeeds_with_data() {
future::block_on(async move { future::block_on(async move {
let (_worker, router1, router2, transport1, _transport2) = init().await; let (_worker1, _worker2, router1, router2, transport1, _transport2) = init().await;
let data_producer = transport1 let data_producer = transport1
.produce_data(data_producer_options()) .produce_data(data_producer_options())
...@@ -1028,7 +1040,7 @@ fn pipe_to_router_succeeds_with_data() { ...@@ -1028,7 +1040,7 @@ fn pipe_to_router_succeeds_with_data() {
#[test] #[test]
fn data_consume_for_pipe_data_producer_succeeds() { fn data_consume_for_pipe_data_producer_succeeds() {
future::block_on(async move { future::block_on(async move {
let (_worker, router1, router2, transport1, transport2) = init().await; let (_worker1, _worker2, router1, router2, transport1, transport2) = init().await;
let data_producer = transport1 let data_producer = transport1
.produce_data(data_producer_options()) .produce_data(data_producer_options())
...@@ -1067,14 +1079,14 @@ fn data_consume_for_pipe_data_producer_succeeds() { ...@@ -1067,14 +1079,14 @@ fn data_consume_for_pipe_data_producer_succeeds() {
#[test] #[test]
fn pipe_to_router_called_twice_generates_single_pair() { fn pipe_to_router_called_twice_generates_single_pair() {
future::block_on(async move { future::block_on(async move {
let (worker, _router1, _router2, _transport1, _transport2) = init().await; let (worker1, worker2, _router1, _router2, _transport1, _transport2) = init().await;
let router_a = worker let router_a = worker1
.create_router(RouterOptions::new(media_codecs())) .create_router(RouterOptions::new(media_codecs()))
.await .await
.expect("Failed to create router"); .expect("Failed to create router");
let router_b = worker let router_b = worker2
.create_router(RouterOptions::new(media_codecs())) .create_router(RouterOptions::new(media_codecs()))
.await .await
.expect("Failed to create router"); .expect("Failed to create router");
......
...@@ -355,7 +355,12 @@ fn smoke() { ...@@ -355,7 +355,12 @@ fn smoke() {
.unwrap() .unwrap()
); );
let router2 = worker let worker2 = worker_manager
.create_worker(WorkerSettings::default())
.await
.unwrap();
let router2 = worker2
.create_router(RouterOptions::new(vec![RtpCodecCapability::Audio { .create_router(RouterOptions::new(vec![RtpCodecCapability::Audio {
mime_type: MimeTypeAudio::Opus, mime_type: MimeTypeAudio::Opus,
preferred_payload_type: None, preferred_payload_type: None,
......
...@@ -25,18 +25,19 @@ namespace Channel ...@@ -25,18 +25,19 @@ namespace Channel
WORKER_UPDATE_SETTINGS, WORKER_UPDATE_SETTINGS,
WORKER_CREATE_WEBRTC_SERVER, WORKER_CREATE_WEBRTC_SERVER,
WORKER_CREATE_ROUTER, WORKER_CREATE_ROUTER,
WEBRTC_SERVER_CLOSE, WORKER_WEBRTC_SERVER_CLOSE,
WEBRTC_SERVER_DUMP, WEBRTC_SERVER_DUMP,
ROUTER_CLOSE, WORKER_CLOSE_ROUTER,
ROUTER_DUMP, ROUTER_DUMP,
ROUTER_CREATE_WEBRTC_TRANSPORT, ROUTER_CREATE_WEBRTC_TRANSPORT,
ROUTER_CREATE_WEBRTC_TRANSPORT_WITH_SERVER, ROUTER_CREATE_WEBRTC_TRANSPORT_WITH_SERVER,
ROUTER_CREATE_PLAIN_TRANSPORT, ROUTER_CREATE_PLAIN_TRANSPORT,
ROUTER_CREATE_PIPE_TRANSPORT, ROUTER_CREATE_PIPE_TRANSPORT,
ROUTER_CREATE_DIRECT_TRANSPORT, ROUTER_CREATE_DIRECT_TRANSPORT,
ROUTER_CLOSE_TRANSPORT,
ROUTER_CREATE_ACTIVE_SPEAKER_OBSERVER, ROUTER_CREATE_ACTIVE_SPEAKER_OBSERVER,
ROUTER_CREATE_AUDIO_LEVEL_OBSERVER, ROUTER_CREATE_AUDIO_LEVEL_OBSERVER,
TRANSPORT_CLOSE, ROUTER_CLOSE_RTP_OBSERVER,
TRANSPORT_DUMP, TRANSPORT_DUMP,
TRANSPORT_GET_STATS, TRANSPORT_GET_STATS,
TRANSPORT_CONNECT, TRANSPORT_CONNECT,
...@@ -48,13 +49,13 @@ namespace Channel ...@@ -48,13 +49,13 @@ namespace Channel
TRANSPORT_PRODUCE_DATA, TRANSPORT_PRODUCE_DATA,
TRANSPORT_CONSUME_DATA, TRANSPORT_CONSUME_DATA,
TRANSPORT_ENABLE_TRACE_EVENT, TRANSPORT_ENABLE_TRACE_EVENT,
PRODUCER_CLOSE, TRANSPORT_CLOSE_PRODUCER,
PRODUCER_DUMP, PRODUCER_DUMP,
PRODUCER_GET_STATS, PRODUCER_GET_STATS,
PRODUCER_PAUSE, PRODUCER_PAUSE,
PRODUCER_RESUME, PRODUCER_RESUME,
PRODUCER_ENABLE_TRACE_EVENT, PRODUCER_ENABLE_TRACE_EVENT,
CONSUMER_CLOSE, TRANSPORT_CLOSE_CONSUMER,
CONSUMER_DUMP, CONSUMER_DUMP,
CONSUMER_GET_STATS, CONSUMER_GET_STATS,
CONSUMER_PAUSE, CONSUMER_PAUSE,
...@@ -63,15 +64,14 @@ namespace Channel ...@@ -63,15 +64,14 @@ namespace Channel
CONSUMER_SET_PRIORITY, CONSUMER_SET_PRIORITY,
CONSUMER_REQUEST_KEY_FRAME, CONSUMER_REQUEST_KEY_FRAME,
CONSUMER_ENABLE_TRACE_EVENT, CONSUMER_ENABLE_TRACE_EVENT,
DATA_PRODUCER_CLOSE, TRANSPORT_CLOSE_DATA_PRODUCER,
DATA_PRODUCER_DUMP, DATA_PRODUCER_DUMP,
DATA_PRODUCER_GET_STATS, DATA_PRODUCER_GET_STATS,
DATA_CONSUMER_CLOSE, TRANSPORT_CLOSE_DATA_CONSUMER,
DATA_CONSUMER_DUMP, DATA_CONSUMER_DUMP,
DATA_CONSUMER_GET_STATS, DATA_CONSUMER_GET_STATS,
DATA_CONSUMER_GET_BUFFERED_AMOUNT, DATA_CONSUMER_GET_BUFFERED_AMOUNT,
DATA_CONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD, DATA_CONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD,
RTP_OBSERVER_CLOSE,
RTP_OBSERVER_PAUSE, RTP_OBSERVER_PAUSE,
RTP_OBSERVER_RESUME, RTP_OBSERVER_RESUME,
RTP_OBSERVER_ADD_PRODUCER, RTP_OBSERVER_ADD_PRODUCER,
...@@ -96,7 +96,7 @@ namespace Channel ...@@ -96,7 +96,7 @@ namespace Channel
uint32_t id{ 0u }; uint32_t id{ 0u };
std::string method; std::string method;
MethodId methodId; MethodId methodId;
json internal; std::string handlerId;
json data; json data;
// Others. // Others.
bool replied{ false }; bool replied{ false };
......
...@@ -37,7 +37,7 @@ namespace PayloadChannel ...@@ -37,7 +37,7 @@ namespace PayloadChannel
// Passed by argument. // Passed by argument.
std::string event; std::string event;
EventId eventId; EventId eventId;
json internal; std::string handlerId;
json data; json data;
const uint8_t* payload{ nullptr }; const uint8_t* payload{ nullptr };
size_t payloadLen{ 0u }; size_t payloadLen{ 0u };
......
...@@ -45,7 +45,7 @@ namespace PayloadChannel ...@@ -45,7 +45,7 @@ namespace PayloadChannel
uint32_t id{ 0u }; uint32_t id{ 0u };
std::string method; std::string method;
MethodId methodId; MethodId methodId;
json internal; std::string handlerId;
json data; json data;
const uint8_t* payload{ nullptr }; const uint8_t* payload{ nullptr };
size_t payloadLen{ 0u }; size_t payloadLen{ 0u };
......
...@@ -25,9 +25,7 @@ namespace RTC ...@@ -25,9 +25,7 @@ namespace RTC
{ {
class Router : public RTC::Transport::Listener, class Router : public RTC::Transport::Listener,
public RTC::RtpObserver::Listener, public RTC::RtpObserver::Listener,
public Channel::ChannelSocket::RequestHandler, public Channel::ChannelSocket::RequestHandler
public PayloadChannel::PayloadChannelSocket::RequestHandler,
public PayloadChannel::PayloadChannelSocket::NotificationHandler
{ {
public: public:
class Listener class Listener
...@@ -36,6 +34,15 @@ namespace RTC ...@@ -36,6 +34,15 @@ namespace RTC
virtual ~Listener() = default; virtual ~Listener() = default;
public: public:
virtual void OnChannelRequestHandlerAdded(
const std::string& id, Channel::ChannelSocket::RequestHandler* handler) = 0;
virtual void OnChannelRequestHandlerRemoved(const std::string& id) = 0;
virtual void OnPayloadChannelRequestHandlerAdded(
const std::string& id, PayloadChannel::PayloadChannelSocket::RequestHandler* handler) = 0;
virtual void OnPayloadChannelRequestHandlerRemoved(const std::string& id) = 0;
virtual void OnPayloadChannelNotificationHandlerAdded(
const std::string& id, PayloadChannel::PayloadChannelSocket::NotificationHandler* handler) = 0;
virtual void OnPayloadChannelNotificationHandlerRemoved(const std::string& id) = 0;
virtual RTC::WebRtcServer* OnRouterNeedWebRtcServer( virtual RTC::WebRtcServer* OnRouterNeedWebRtcServer(
RTC::Router* router, std::string& webRtcServerId) = 0; RTC::Router* router, std::string& webRtcServerId) = 0;
}; };
...@@ -51,20 +58,11 @@ namespace RTC ...@@ -51,20 +58,11 @@ namespace RTC
public: public:
void HandleRequest(Channel::ChannelRequest* request) override; void HandleRequest(Channel::ChannelRequest* request) override;
/* Methods inherited from PayloadChannel::PayloadChannelSocket::RequestHandler. */
public:
void HandleRequest(PayloadChannel::PayloadChannelRequest* request) override;
/* Methods inherited from PayloadChannel::PayloadChannelSocket::NotificationHandler. */
public:
void HandleNotification(PayloadChannel::Notification* notification) override;
private: private:
void SetNewTransportIdFromInternal(json& internal, std::string& transportId) const; void SetNewTransportIdFromData(json& data, std::string& transportId) const;
RTC::Transport* GetTransportFromInternal(json& internal) const; RTC::Transport* GetTransportFromData(json& data) const;
void SetNewRtpObserverIdFromInternal(json& internal, std::string& rtpObserverId) const; void SetNewRtpObserverIdFromData(json& data, std::string& rtpObserverId) const;
RTC::RtpObserver* GetRtpObserverFromInternal(json& internal) const; RTC::RtpObserver* GetRtpObserverFromData(json& data) const;
RTC::Producer* GetProducerFromData(json& data) const;
/* Pure virtual methods inherited from RTC::Transport::Listener. */ /* Pure virtual methods inherited from RTC::Transport::Listener. */
public: public:
......
...@@ -156,16 +156,16 @@ namespace RTC ...@@ -156,16 +156,16 @@ namespace RTC
void ReceiveRtpPacket(RTC::RtpPacket* packet); void ReceiveRtpPacket(RTC::RtpPacket* packet);
void ReceiveRtcpPacket(RTC::RTCP::Packet* packet); void ReceiveRtcpPacket(RTC::RTCP::Packet* packet);
void ReceiveSctpData(const uint8_t* data, size_t len); void ReceiveSctpData(const uint8_t* data, size_t len);
void SetNewProducerIdFromInternal(json& internal, std::string& producerId) const; void SetNewProducerIdFromData(json& data, std::string& producerId) const;
RTC::Producer* GetProducerFromInternal(json& internal) const; RTC::Producer* GetProducerFromData(json& data) const;
void SetNewConsumerIdFromInternal(json& internal, std::string& consumerId) const; void SetNewConsumerIdFromData(json& data, std::string& consumerId) const;
RTC::Consumer* GetConsumerFromInternal(json& internal) const; RTC::Consumer* GetConsumerFromData(json& data) const;
RTC::Consumer* GetConsumerByMediaSsrc(uint32_t ssrc) const; RTC::Consumer* GetConsumerByMediaSsrc(uint32_t ssrc) const;
RTC::Consumer* GetConsumerByRtxSsrc(uint32_t ssrc) const; RTC::Consumer* GetConsumerByRtxSsrc(uint32_t ssrc) const;
void SetNewDataProducerIdFromInternal(json& internal, std::string& dataProducerId) const; void SetNewDataProducerIdFromData(json& data, std::string& dataProducerId) const;
RTC::DataProducer* GetDataProducerFromInternal(json& internal) const; RTC::DataProducer* GetDataProducerFromData(json& data) const;
void SetNewDataConsumerIdFromInternal(json& internal, std::string& dataConsumerId) const; void SetNewDataConsumerIdFromData(json& data, std::string& dataConsumerId) const;
RTC::DataConsumer* GetDataConsumerFromInternal(json& internal) const; RTC::DataConsumer* GetDataConsumerFromData(json& data) const;
private: private:
virtual bool IsConnected() const = 0; virtual bool IsConnected() const = 0;
......
...@@ -29,10 +29,10 @@ private: ...@@ -29,10 +29,10 @@ private:
void Close(); void Close();
void FillJson(json& jsonObject) const; void FillJson(json& jsonObject) const;
void FillJsonResourceUsage(json& jsonObject) const; void FillJsonResourceUsage(json& jsonObject) const;
void SetNewWebRtcServerIdFromInternal(json& internal, std::string& webRtcServerId) const; void SetNewWebRtcServerIdFromData(json& data, std::string& webRtcServerId) const;
RTC::WebRtcServer* GetWebRtcServerFromInternal(json& internal) const; RTC::WebRtcServer* GetWebRtcServerFromData(json& data) const;
void SetNewRouterIdFromInternal(json& internal, std::string& routerId) const; void SetNewRouterIdFromData(json& data, std::string& routerId) const;
RTC::Router* GetRouterFromInternal(json& internal) const; RTC::Router* GetRouterFromData(json& data) const;
/* Methods inherited from Channel::ChannelSocket::RequestHandler. */ /* Methods inherited from Channel::ChannelSocket::RequestHandler. */
public: public:
...@@ -60,6 +60,16 @@ public: ...@@ -60,6 +60,16 @@ public:
/* Pure virtual methods inherited from RTC::Router::Listener. */ /* Pure virtual methods inherited from RTC::Router::Listener. */
public: public:
void OnChannelRequestHandlerAdded(
const std::string& id, Channel::ChannelSocket::RequestHandler* handler) override;
void OnChannelRequestHandlerRemoved(const std::string& id) override;
void OnPayloadChannelRequestHandlerAdded(
const std::string& id, PayloadChannel::PayloadChannelSocket::RequestHandler* handler) override;
void OnPayloadChannelRequestHandlerRemoved(const std::string& id) override;
void OnPayloadChannelNotificationHandlerAdded(
const std::string& id,
PayloadChannel::PayloadChannelSocket::NotificationHandler* handler) override;
void OnPayloadChannelNotificationHandlerRemoved(const std::string& id) override;
RTC::WebRtcServer* OnRouterNeedWebRtcServer(RTC::Router* router, std::string& webRtcServerId) override; RTC::WebRtcServer* OnRouterNeedWebRtcServer(RTC::Router* router, std::string& webRtcServerId) override;
private: private:
...@@ -70,6 +80,11 @@ private: ...@@ -70,6 +80,11 @@ private:
SignalsHandler* signalsHandler{ nullptr }; SignalsHandler* signalsHandler{ nullptr };
absl::flat_hash_map<std::string, RTC::WebRtcServer*> mapWebRtcServers; absl::flat_hash_map<std::string, RTC::WebRtcServer*> mapWebRtcServers;
absl::flat_hash_map<std::string, RTC::Router*> mapRouters; absl::flat_hash_map<std::string, RTC::Router*> mapRouters;
absl::flat_hash_map<std::string, Channel::ChannelSocket::RequestHandler*> mapChannelRequestHandlers;
absl::flat_hash_map<std::string, PayloadChannel::PayloadChannelSocket::RequestHandler*>
mapPayloadChannelRequestHandlers;
absl::flat_hash_map<std::string, PayloadChannel::PayloadChannelSocket::NotificationHandler*>
mapPayloadChannelNotificationHandlers;
// Others. // Others.
bool closed{ false }; bool closed{ false };
}; };
......
...@@ -19,18 +19,19 @@ namespace Channel ...@@ -19,18 +19,19 @@ namespace Channel
{ "worker.updateSettings", ChannelRequest::MethodId::WORKER_UPDATE_SETTINGS }, { "worker.updateSettings", ChannelRequest::MethodId::WORKER_UPDATE_SETTINGS },
{ "worker.createWebRtcServer", ChannelRequest::MethodId::WORKER_CREATE_WEBRTC_SERVER }, { "worker.createWebRtcServer", ChannelRequest::MethodId::WORKER_CREATE_WEBRTC_SERVER },
{ "worker.createRouter", ChannelRequest::MethodId::WORKER_CREATE_ROUTER }, { "worker.createRouter", ChannelRequest::MethodId::WORKER_CREATE_ROUTER },
{ "webRtcServer.close", ChannelRequest::MethodId::WEBRTC_SERVER_CLOSE }, { "worker.closeWebRtcServer", ChannelRequest::MethodId::WORKER_WEBRTC_SERVER_CLOSE },
{ "webRtcServer.dump", ChannelRequest::MethodId::WEBRTC_SERVER_DUMP }, { "webRtcServer.dump", ChannelRequest::MethodId::WEBRTC_SERVER_DUMP },
{ "router.close", ChannelRequest::MethodId::ROUTER_CLOSE }, { "worker.closeRouter", ChannelRequest::MethodId::WORKER_CLOSE_ROUTER },
{ "router.dump", ChannelRequest::MethodId::ROUTER_DUMP }, { "router.dump", ChannelRequest::MethodId::ROUTER_DUMP },
{ "router.createWebRtcTransport", ChannelRequest::MethodId::ROUTER_CREATE_WEBRTC_TRANSPORT }, { "router.createWebRtcTransport", ChannelRequest::MethodId::ROUTER_CREATE_WEBRTC_TRANSPORT },
{ "router.createWebRtcTransportWithServer", ChannelRequest::MethodId::ROUTER_CREATE_WEBRTC_TRANSPORT_WITH_SERVER }, { "router.createWebRtcTransportWithServer", ChannelRequest::MethodId::ROUTER_CREATE_WEBRTC_TRANSPORT_WITH_SERVER },
{ "router.createPlainTransport", ChannelRequest::MethodId::ROUTER_CREATE_PLAIN_TRANSPORT }, { "router.createPlainTransport", ChannelRequest::MethodId::ROUTER_CREATE_PLAIN_TRANSPORT },
{ "router.createPipeTransport", ChannelRequest::MethodId::ROUTER_CREATE_PIPE_TRANSPORT }, { "router.createPipeTransport", ChannelRequest::MethodId::ROUTER_CREATE_PIPE_TRANSPORT },
{ "router.createDirectTransport", ChannelRequest::MethodId::ROUTER_CREATE_DIRECT_TRANSPORT }, { "router.createDirectTransport", ChannelRequest::MethodId::ROUTER_CREATE_DIRECT_TRANSPORT },
{ "router.closeTransport", ChannelRequest::MethodId::ROUTER_CLOSE_TRANSPORT },
{ "router.createActiveSpeakerObserver", ChannelRequest::MethodId::ROUTER_CREATE_ACTIVE_SPEAKER_OBSERVER }, { "router.createActiveSpeakerObserver", ChannelRequest::MethodId::ROUTER_CREATE_ACTIVE_SPEAKER_OBSERVER },
{ "router.createAudioLevelObserver", ChannelRequest::MethodId::ROUTER_CREATE_AUDIO_LEVEL_OBSERVER }, { "router.createAudioLevelObserver", ChannelRequest::MethodId::ROUTER_CREATE_AUDIO_LEVEL_OBSERVER },
{ "transport.close", ChannelRequest::MethodId::TRANSPORT_CLOSE }, { "router.closeRtpObserver", ChannelRequest::MethodId::ROUTER_CLOSE_RTP_OBSERVER },
{ "transport.dump", ChannelRequest::MethodId::TRANSPORT_DUMP }, { "transport.dump", ChannelRequest::MethodId::TRANSPORT_DUMP },
{ "transport.getStats", ChannelRequest::MethodId::TRANSPORT_GET_STATS }, { "transport.getStats", ChannelRequest::MethodId::TRANSPORT_GET_STATS },
{ "transport.connect", ChannelRequest::MethodId::TRANSPORT_CONNECT }, { "transport.connect", ChannelRequest::MethodId::TRANSPORT_CONNECT },
...@@ -42,13 +43,15 @@ namespace Channel ...@@ -42,13 +43,15 @@ namespace Channel
{ "transport.produceData", ChannelRequest::MethodId::TRANSPORT_PRODUCE_DATA }, { "transport.produceData", ChannelRequest::MethodId::TRANSPORT_PRODUCE_DATA },
{ "transport.consumeData", ChannelRequest::MethodId::TRANSPORT_CONSUME_DATA }, { "transport.consumeData", ChannelRequest::MethodId::TRANSPORT_CONSUME_DATA },
{ "transport.enableTraceEvent", ChannelRequest::MethodId::TRANSPORT_ENABLE_TRACE_EVENT }, { "transport.enableTraceEvent", ChannelRequest::MethodId::TRANSPORT_ENABLE_TRACE_EVENT },
{ "producer.close", ChannelRequest::MethodId::PRODUCER_CLOSE }, { "transport.closeProducer", ChannelRequest::MethodId::TRANSPORT_CLOSE_PRODUCER },
{ "transport.closeConsumer", ChannelRequest::MethodId::TRANSPORT_CLOSE_CONSUMER },
{ "transport.closeDataProducer", ChannelRequest::MethodId::TRANSPORT_CLOSE_DATA_PRODUCER },
{ "transport.closeDataConsumer", ChannelRequest::MethodId::TRANSPORT_CLOSE_DATA_CONSUMER },
{ "producer.dump", ChannelRequest::MethodId::PRODUCER_DUMP }, { "producer.dump", ChannelRequest::MethodId::PRODUCER_DUMP },
{ "producer.getStats", ChannelRequest::MethodId::PRODUCER_GET_STATS }, { "producer.getStats", ChannelRequest::MethodId::PRODUCER_GET_STATS },
{ "producer.pause", ChannelRequest::MethodId::PRODUCER_PAUSE }, { "producer.pause", ChannelRequest::MethodId::PRODUCER_PAUSE },
{ "producer.resume" , ChannelRequest::MethodId::PRODUCER_RESUME }, { "producer.resume" , ChannelRequest::MethodId::PRODUCER_RESUME },
{ "producer.enableTraceEvent", ChannelRequest::MethodId::PRODUCER_ENABLE_TRACE_EVENT }, { "producer.enableTraceEvent", ChannelRequest::MethodId::PRODUCER_ENABLE_TRACE_EVENT },
{ "consumer.close", ChannelRequest::MethodId::CONSUMER_CLOSE },
{ "consumer.dump", ChannelRequest::MethodId::CONSUMER_DUMP }, { "consumer.dump", ChannelRequest::MethodId::CONSUMER_DUMP },
{ "consumer.getStats", ChannelRequest::MethodId::CONSUMER_GET_STATS }, { "consumer.getStats", ChannelRequest::MethodId::CONSUMER_GET_STATS },
{ "consumer.pause", ChannelRequest::MethodId::CONSUMER_PAUSE }, { "consumer.pause", ChannelRequest::MethodId::CONSUMER_PAUSE },
...@@ -57,15 +60,12 @@ namespace Channel ...@@ -57,15 +60,12 @@ namespace Channel
{ "consumer.setPriority", ChannelRequest::MethodId::CONSUMER_SET_PRIORITY }, { "consumer.setPriority", ChannelRequest::MethodId::CONSUMER_SET_PRIORITY },
{ "consumer.requestKeyFrame", ChannelRequest::MethodId::CONSUMER_REQUEST_KEY_FRAME }, { "consumer.requestKeyFrame", ChannelRequest::MethodId::CONSUMER_REQUEST_KEY_FRAME },
{ "consumer.enableTraceEvent", ChannelRequest::MethodId::CONSUMER_ENABLE_TRACE_EVENT }, { "consumer.enableTraceEvent", ChannelRequest::MethodId::CONSUMER_ENABLE_TRACE_EVENT },
{ "dataProducer.close", ChannelRequest::MethodId::DATA_PRODUCER_CLOSE },
{ "dataProducer.dump", ChannelRequest::MethodId::DATA_PRODUCER_DUMP }, { "dataProducer.dump", ChannelRequest::MethodId::DATA_PRODUCER_DUMP },
{ "dataProducer.getStats", ChannelRequest::MethodId::DATA_PRODUCER_GET_STATS }, { "dataProducer.getStats", ChannelRequest::MethodId::DATA_PRODUCER_GET_STATS },
{ "dataConsumer.close", ChannelRequest::MethodId::DATA_CONSUMER_CLOSE },
{ "dataConsumer.dump", ChannelRequest::MethodId::DATA_CONSUMER_DUMP }, { "dataConsumer.dump", ChannelRequest::MethodId::DATA_CONSUMER_DUMP },
{ "dataConsumer.getStats", ChannelRequest::MethodId::DATA_CONSUMER_GET_STATS }, { "dataConsumer.getStats", ChannelRequest::MethodId::DATA_CONSUMER_GET_STATS },
{ "dataConsumer.getBufferedAmount", ChannelRequest::MethodId::DATA_CONSUMER_GET_BUFFERED_AMOUNT }, { "dataConsumer.getBufferedAmount", ChannelRequest::MethodId::DATA_CONSUMER_GET_BUFFERED_AMOUNT },
{ "dataConsumer.setBufferedAmountLowThreshold", ChannelRequest::MethodId::DATA_CONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD }, { "dataConsumer.setBufferedAmountLowThreshold", ChannelRequest::MethodId::DATA_CONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD },
{ "rtpObserver.close", ChannelRequest::MethodId::RTP_OBSERVER_CLOSE },
{ "rtpObserver.pause", ChannelRequest::MethodId::RTP_OBSERVER_PAUSE }, { "rtpObserver.pause", ChannelRequest::MethodId::RTP_OBSERVER_PAUSE },
{ "rtpObserver.resume", ChannelRequest::MethodId::RTP_OBSERVER_RESUME }, { "rtpObserver.resume", ChannelRequest::MethodId::RTP_OBSERVER_RESUME },
{ "rtpObserver.addProducer", ChannelRequest::MethodId::RTP_OBSERVER_ADD_PRODUCER }, { "rtpObserver.addProducer", ChannelRequest::MethodId::RTP_OBSERVER_ADD_PRODUCER },
...@@ -105,12 +105,10 @@ namespace Channel ...@@ -105,12 +105,10 @@ namespace Channel
this->methodId = methodIdIt->second; this->methodId = methodIdIt->second;
auto jsonInternalIt = jsonRequest.find("internal"); auto jsonHandlerIdIt = jsonRequest.find("handlerId");
if (jsonInternalIt != jsonRequest.end() && jsonInternalIt->is_object()) if (jsonHandlerIdIt != jsonRequest.end() && jsonHandlerIdIt->is_string())
this->internal = *jsonInternalIt; this->handlerId = *jsonHandlerIdIt;
else
this->internal = json::object();
auto jsonDataIt = jsonRequest.find("data"); auto jsonDataIt = jsonRequest.find("data");
......
...@@ -60,12 +60,10 @@ namespace PayloadChannel ...@@ -60,12 +60,10 @@ namespace PayloadChannel
this->eventId = eventIdIt->second; this->eventId = eventIdIt->second;
auto jsonInternalIt = jsonNotification.find("internal"); auto jsonHandlerIdIt = jsonNotification.find("handlerId");
if (jsonInternalIt != jsonNotification.end() && jsonInternalIt->is_object()) if (jsonHandlerIdIt != jsonNotification.end() && jsonHandlerIdIt->is_string())
this->internal = *jsonInternalIt; this->handlerId = *jsonHandlerIdIt;
else
this->internal = json::object();
auto jsonDataIt = jsonNotification.find("data"); auto jsonDataIt = jsonNotification.find("data");
......
...@@ -69,12 +69,10 @@ namespace PayloadChannel ...@@ -69,12 +69,10 @@ namespace PayloadChannel
this->methodId = methodIdIt->second; this->methodId = methodIdIt->second;
auto jsonInternalIt = jsonRequest.find("internal"); auto jsonHandlerIdIt = jsonRequest.find("handlerId");
if (jsonInternalIt != jsonRequest.end() && jsonInternalIt->is_object()) if (jsonHandlerIdIt != jsonRequest.end() && jsonHandlerIdIt->is_object())
this->internal = *jsonInternalIt; this->handlerId = *jsonHandlerIdIt;
else
this->internal = json::object();
auto jsonDataIt = jsonRequest.find("data"); auto jsonDataIt = jsonRequest.find("data");
......
...@@ -87,26 +87,6 @@ namespace RTC ...@@ -87,26 +87,6 @@ namespace RTC
break; break;
} }
case PayloadChannel::Notification::EventId::PRODUCER_SEND:
{
// This may throw.
RTC::Producer* producer = GetProducerFromInternal(notification->internal);
producer->HandleNotification(notification);
break;
}
case PayloadChannel::Notification::EventId::DATA_PRODUCER_SEND:
{
// This may throw.
RTC::DataProducer* dataProducer = GetDataProducerFromInternal(notification->internal);
dataProducer->HandleNotification(notification);
break;
}
default: default:
{ {
// Pass it to the parent class. // Pass it to the parent class.
......
差异被折叠。
...@@ -90,6 +90,11 @@ void Worker::Close() ...@@ -90,6 +90,11 @@ void Worker::Close()
// Close the PayloadChannel. // Close the PayloadChannel.
this->payloadChannel->Close(); this->payloadChannel->Close();
// Clear all request and notification handlers.
this->mapChannelRequestHandlers.clear();
this->mapPayloadChannelRequestHandlers.clear();
this->mapPayloadChannelNotificationHandlers.clear();
} }
void Worker::FillJson(json& jsonObject) const void Worker::FillJson(json& jsonObject) const
...@@ -185,14 +190,14 @@ void Worker::FillJsonResourceUsage(json& jsonObject) const ...@@ -185,14 +190,14 @@ void Worker::FillJsonResourceUsage(json& jsonObject) const
jsonObject["ru_nivcsw"] = uvRusage.ru_nivcsw; jsonObject["ru_nivcsw"] = uvRusage.ru_nivcsw;
} }
void Worker::SetNewWebRtcServerIdFromInternal(json& internal, std::string& webRtcServerId) const void Worker::SetNewWebRtcServerIdFromData(json& data, std::string& webRtcServerId) const
{ {
MS_TRACE(); MS_TRACE();
auto jsonWebRtcServerIdIt = internal.find("webRtcServerId"); auto jsonWebRtcServerIdIt = data.find("webRtcServerId");
if (jsonWebRtcServerIdIt == internal.end() || !jsonWebRtcServerIdIt->is_string()) if (jsonWebRtcServerIdIt == data.end() || !jsonWebRtcServerIdIt->is_string())
MS_THROW_ERROR("missing internal.webRtcServerId"); MS_THROW_ERROR("missing webRtcServerId");
webRtcServerId.assign(jsonWebRtcServerIdIt->get<std::string>()); webRtcServerId.assign(jsonWebRtcServerIdIt->get<std::string>());
...@@ -200,14 +205,14 @@ void Worker::SetNewWebRtcServerIdFromInternal(json& internal, std::string& webRt ...@@ -200,14 +205,14 @@ void Worker::SetNewWebRtcServerIdFromInternal(json& internal, std::string& webRt
MS_THROW_ERROR("a WebRtcServer with same webRtcServerId already exists"); MS_THROW_ERROR("a WebRtcServer with same webRtcServerId already exists");
} }
RTC::WebRtcServer* Worker::GetWebRtcServerFromInternal(json& internal) const RTC::WebRtcServer* Worker::GetWebRtcServerFromData(json& data) const
{ {
MS_TRACE(); MS_TRACE();
auto jsonWebRtcServerIdIt = internal.find("webRtcServerId"); auto jsonWebRtcServerIdIt = data.find("webRtcServerId");
if (jsonWebRtcServerIdIt == internal.end() || !jsonWebRtcServerIdIt->is_string()) if (jsonWebRtcServerIdIt == data.end() || !jsonWebRtcServerIdIt->is_string())
MS_THROW_ERROR("missing internal.webRtcServerId"); MS_THROW_ERROR("missing handlerId.webRtcServerId");
auto it = this->mapWebRtcServers.find(jsonWebRtcServerIdIt->get<std::string>()); auto it = this->mapWebRtcServers.find(jsonWebRtcServerIdIt->get<std::string>());
...@@ -219,14 +224,14 @@ RTC::WebRtcServer* Worker::GetWebRtcServerFromInternal(json& internal) const ...@@ -219,14 +224,14 @@ RTC::WebRtcServer* Worker::GetWebRtcServerFromInternal(json& internal) const
return webRtcServer; return webRtcServer;
} }
void Worker::SetNewRouterIdFromInternal(json& internal, std::string& routerId) const void Worker::SetNewRouterIdFromData(json& data, std::string& routerId) const
{ {
MS_TRACE(); MS_TRACE();
auto jsonRouterIdIt = internal.find("routerId"); auto jsonRouterIdIt = data.find("routerId");
if (jsonRouterIdIt == internal.end() || !jsonRouterIdIt->is_string()) if (jsonRouterIdIt == data.end() || !jsonRouterIdIt->is_string())
MS_THROW_ERROR("missing internal.routerId"); MS_THROW_ERROR("missing routerId");
routerId.assign(jsonRouterIdIt->get<std::string>()); routerId.assign(jsonRouterIdIt->get<std::string>());
...@@ -234,14 +239,14 @@ void Worker::SetNewRouterIdFromInternal(json& internal, std::string& routerId) c ...@@ -234,14 +239,14 @@ void Worker::SetNewRouterIdFromInternal(json& internal, std::string& routerId) c
MS_THROW_ERROR("a Router with same routerId already exists"); MS_THROW_ERROR("a Router with same routerId already exists");
} }
RTC::Router* Worker::GetRouterFromInternal(json& internal) const RTC::Router* Worker::GetRouterFromData(json& data) const
{ {
MS_TRACE(); MS_TRACE();
auto jsonRouterIdIt = internal.find("routerId"); auto jsonRouterIdIt = data.find("routerId");
if (jsonRouterIdIt == internal.end() || !jsonRouterIdIt->is_string()) if (jsonRouterIdIt == data.end() || !jsonRouterIdIt->is_string())
MS_THROW_ERROR("missing internal.routerId"); MS_THROW_ERROR("missing routerId");
auto it = this->mapRouters.find(jsonRouterIdIt->get<std::string>()); auto it = this->mapRouters.find(jsonRouterIdIt->get<std::string>());
...@@ -309,11 +314,12 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) ...@@ -309,11 +314,12 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request)
{ {
std::string webRtcServerId; std::string webRtcServerId;
SetNewWebRtcServerIdFromInternal(request->internal, webRtcServerId); SetNewWebRtcServerIdFromData(request->data, webRtcServerId);
auto* webRtcServer = new RTC::WebRtcServer(webRtcServerId, request->data); auto* webRtcServer = new RTC::WebRtcServer(webRtcServerId, request->data);
this->mapWebRtcServers[webRtcServerId] = webRtcServer; this->mapWebRtcServers[webRtcServerId] = webRtcServer;
this->OnChannelRequestHandlerAdded(webRtcServerId, webRtcServer);
MS_DEBUG_DEV("WebRtcServer created [webRtcServerId:%s]", webRtcServerId.c_str()); MS_DEBUG_DEV("WebRtcServer created [webRtcServerId:%s]", webRtcServerId.c_str());
...@@ -331,13 +337,13 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) ...@@ -331,13 +337,13 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request)
break; break;
} }
case Channel::ChannelRequest::MethodId::WEBRTC_SERVER_CLOSE: case Channel::ChannelRequest::MethodId::WORKER_WEBRTC_SERVER_CLOSE:
{ {
RTC::WebRtcServer* webRtcServer{ nullptr }; RTC::WebRtcServer* webRtcServer{ nullptr };
try try
{ {
webRtcServer = GetWebRtcServerFromInternal(request->internal); webRtcServer = GetWebRtcServerFromData(request->data);
} }
catch (const MediaSoupError& error) catch (const MediaSoupError& error)
{ {
...@@ -346,6 +352,7 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) ...@@ -346,6 +352,7 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request)
// Remove it from the map and delete it. // Remove it from the map and delete it.
this->mapWebRtcServers.erase(webRtcServer->id); this->mapWebRtcServers.erase(webRtcServer->id);
this->OnChannelRequestHandlerRemoved(webRtcServer->id);
delete webRtcServer; delete webRtcServer;
MS_DEBUG_DEV("WebRtcServer closed [id:%s]", webRtcServer->id.c_str()); MS_DEBUG_DEV("WebRtcServer closed [id:%s]", webRtcServer->id.c_str());
...@@ -355,31 +362,13 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) ...@@ -355,31 +362,13 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request)
break; break;
} }
case Channel::ChannelRequest::MethodId::WEBRTC_SERVER_DUMP:
{
RTC::WebRtcServer* webRtcServer{ nullptr };
try
{
webRtcServer = GetWebRtcServerFromInternal(request->internal);
webRtcServer->HandleRequest(request);
}
catch (const MediaSoupError& error)
{
MS_THROW_ERROR("%s [method:%s]", error.what(), request->method.c_str());
}
break;
}
case Channel::ChannelRequest::MethodId::WORKER_CREATE_ROUTER: case Channel::ChannelRequest::MethodId::WORKER_CREATE_ROUTER:
{ {
std::string routerId; std::string routerId;
try try
{ {
SetNewRouterIdFromInternal(request->internal, routerId); SetNewRouterIdFromData(request->data, routerId);
} }
catch (const MediaSoupError& error) catch (const MediaSoupError& error)
{ {
...@@ -389,6 +378,7 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) ...@@ -389,6 +378,7 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request)
auto* router = new RTC::Router(routerId, this); auto* router = new RTC::Router(routerId, this);
this->mapRouters[routerId] = router; this->mapRouters[routerId] = router;
this->OnChannelRequestHandlerAdded(routerId, router);
MS_DEBUG_DEV("Router created [routerId:%s]", routerId.c_str()); MS_DEBUG_DEV("Router created [routerId:%s]", routerId.c_str());
...@@ -397,13 +387,13 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) ...@@ -397,13 +387,13 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request)
break; break;
} }
case Channel::ChannelRequest::MethodId::ROUTER_CLOSE: case Channel::ChannelRequest::MethodId::WORKER_CLOSE_ROUTER:
{ {
RTC::Router* router{ nullptr }; RTC::Router* router{ nullptr };
try try
{ {
router = GetRouterFromInternal(request->internal); router = GetRouterFromData(request->data);
} }
catch (const MediaSoupError& error) catch (const MediaSoupError& error)
{ {
...@@ -412,6 +402,7 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) ...@@ -412,6 +402,7 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request)
// Remove it from the map and delete it. // Remove it from the map and delete it.
this->mapRouters.erase(router->id); this->mapRouters.erase(router->id);
this->OnChannelRequestHandlerRemoved(router->id);
delete router; delete router;
MS_DEBUG_DEV("Router closed [id:%s]", router->id.c_str()); MS_DEBUG_DEV("Router closed [id:%s]", router->id.c_str());
...@@ -426,9 +417,12 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) ...@@ -426,9 +417,12 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request)
{ {
try try
{ {
RTC::Router* router = GetRouterFromInternal(request->internal); auto it = this->mapChannelRequestHandlers.find(request->handlerId);
router->HandleRequest(request); if (it == this->mapChannelRequestHandlers.end())
MS_THROW_ERROR("Channel handler with ID %s not found", request->handlerId.c_str());
it->second->HandleRequest(request);
} }
catch (const MediaSoupTypeError& error) catch (const MediaSoupTypeError& error)
{ {
...@@ -466,9 +460,12 @@ inline void Worker::HandleNotification(PayloadChannel::Notification* notificatio ...@@ -466,9 +460,12 @@ inline void Worker::HandleNotification(PayloadChannel::Notification* notificatio
try try
{ {
RTC::Router* router = GetRouterFromInternal(notification->internal); auto it = this->mapPayloadChannelNotificationHandlers.find(notification->handlerId);
if (it == this->mapPayloadChannelNotificationHandlers.end())
MS_THROW_ERROR("Notification handler with ID %s not found", notification->handlerId.c_str());
router->HandleNotification(notification); it->second->HandleNotification(notification);
} }
catch (const MediaSoupTypeError& error) catch (const MediaSoupTypeError& error)
{ {
...@@ -491,9 +488,12 @@ inline void Worker::HandleRequest(PayloadChannel::PayloadChannelRequest* request ...@@ -491,9 +488,12 @@ inline void Worker::HandleRequest(PayloadChannel::PayloadChannelRequest* request
try try
{ {
RTC::Router* router = GetRouterFromInternal(request->internal); auto it = this->mapPayloadChannelRequestHandlers.find(request->handlerId);
router->HandleRequest(request); if (it == this->mapPayloadChannelRequestHandlers.end())
MS_THROW_ERROR("Payload channel handler with ID %s not found", request->handlerId.c_str());
it->second->HandleRequest(request);
} }
catch (const MediaSoupTypeError& error) catch (const MediaSoupTypeError& error)
{ {
...@@ -559,6 +559,45 @@ inline void Worker::OnSignal(SignalsHandler* /*signalsHandler*/, int signum) ...@@ -559,6 +559,45 @@ inline void Worker::OnSignal(SignalsHandler* /*signalsHandler*/, int signum)
} }
} }
inline void Worker::OnChannelRequestHandlerAdded(
const std::string& id, Channel::ChannelSocket::RequestHandler* handler)
{
if (this->mapChannelRequestHandlers.find(id) != this->mapChannelRequestHandlers.end())
MS_THROW_ERROR("Channel request handler with ID %s already exists", id.c_str());
this->mapChannelRequestHandlers[id] = handler;
}
inline void Worker::OnChannelRequestHandlerRemoved(const std::string& id)
{
this->mapChannelRequestHandlers.erase(id);
}
inline void Worker::OnPayloadChannelRequestHandlerAdded(
const std::string& id, PayloadChannel::PayloadChannelSocket::RequestHandler* handler)
{
if (this->mapPayloadChannelRequestHandlers.find(id) != this->mapPayloadChannelRequestHandlers.end())
MS_THROW_ERROR("Payload channel request handler with ID %s already exists", id.c_str());
this->mapPayloadChannelRequestHandlers[id] = handler;
}
inline void Worker::OnPayloadChannelRequestHandlerRemoved(const std::string& id)
{
this->mapPayloadChannelRequestHandlers.erase(id);
}
inline void Worker::OnPayloadChannelNotificationHandlerAdded(
const std::string& id, PayloadChannel::PayloadChannelSocket::NotificationHandler* handler)
{
if (
this->mapPayloadChannelNotificationHandlers.find(id) !=
this->mapPayloadChannelNotificationHandlers.end())
MS_THROW_ERROR("Payload channel notification handler with ID %s already exists", id.c_str());
this->mapPayloadChannelNotificationHandlers[id] = handler;
}
inline void Worker::OnPayloadChannelNotificationHandlerRemoved(const std::string& id)
{
this->mapPayloadChannelNotificationHandlers.erase(id);
}
inline RTC::WebRtcServer* Worker::OnRouterNeedWebRtcServer( inline RTC::WebRtcServer* Worker::OnRouterNeedWebRtcServer(
RTC::Router* /*router*/, std::string& webRtcServerId) RTC::Router* /*router*/, std::string& webRtcServerId)
{ {
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论