From 39ccbc5d42c63e8cbb334a22bee5e9ed78ba0a5d Mon Sep 17 00:00:00 2001 From: Nazar Mokrynskyi Date: Sun, 24 Jul 2022 21:58:57 +0300 Subject: [PATCH 1/5] Store request and notification handlers in Worker's maps, this will be necessary later (piping between routers of the same worker is not allowed anymore) --- node/tests/test-PipeTransport.js | 24 +++++++---- rust/src/router/pipe_transport/tests.rs | 11 +++-- rust/tests/integration/pipe_transport.rs | 50 ++++++++++++++--------- rust/tests/integration/smoke.rs | 7 +++- worker/include/RTC/Router.hpp | 9 ++++ worker/include/Worker.hpp | 15 +++++++ worker/src/RTC/Router.cpp | 50 +++++++++++++++++++++++ worker/src/Worker.cpp | 52 ++++++++++++++++++++++++ 8 files changed, 186 insertions(+), 32 deletions(-) diff --git a/node/tests/test-PipeTransport.js b/node/tests/test-PipeTransport.js index 2a6b675075..b246c70f27 100644 --- a/node/tests/test-PipeTransport.js +++ b/node/tests/test-PipeTransport.js @@ -5,7 +5,8 @@ const { createWorker } = mediasoup; expect.extend({ toBeType }); -let worker; +let worker1; +let worker2; let router1; let router2; let transport1; @@ -190,9 +191,10 @@ const consumerDeviceCapabilities = beforeAll(async () => { - worker = await createWorker(); - router1 = await worker.createRouter({ mediaCodecs }); - router2 = await worker.createRouter({ mediaCodecs }); + worker1 = await createWorker(); + worker2 = await createWorker(); + router1 = await worker1.createRouter({ mediaCodecs }); + router2 = await worker2.createRouter({ mediaCodecs }); transport1 = await router1.createWebRtcTransport( { listenIps : [ '127.0.0.1' ], @@ -211,7 +213,11 @@ beforeAll(async () => await videoProducer.pause(); }); -afterAll(() => worker.close()); +afterAll(() => +{ + worker1.close(); + worker2.close(); +}); test('router.pipeToRouter() succeeds with audio', 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 () => { - const routerA = await worker.createRouter({ mediaCodecs }); - const routerB = await worker.createRouter({ mediaCodecs }); + const routerA = await worker1.createRouter({ mediaCodecs }); + const routerB = await worker2.createRouter({ mediaCodecs }); const transportA1 = await routerA.createWebRtcTransport({ listenIps: [ '127.0.0.1' ] }); const transportA2 = await routerA.createWebRtcTransport({ listenIps: [ '127.0.0.1' ] }); const audioProducerA1 = await transportA1.produce(audioProducerParameters); @@ -936,8 +942,8 @@ test('router.pipeToRouter() called in two Routers passing one to each other as a router1.close(); router2.close(); - const routerA = await worker.createRouter({ mediaCodecs }); - const routerB = await worker.createRouter({ mediaCodecs }); + const routerA = await worker1.createRouter({ mediaCodecs }); + const routerB = await worker2.createRouter({ mediaCodecs }); const transportA = await routerA.createWebRtcTransport({ listenIps: [ '127.0.0.1' ] }); const transportB = await routerB.createWebRtcTransport({ listenIps: [ '127.0.0.1' ] }); const audioProducerA = await transportA.produce(audioProducerParameters); diff --git a/rust/src/router/pipe_transport/tests.rs b/rust/src/router/pipe_transport/tests.rs index 9acc3640f3..67862e5bc2 100644 --- a/rust/src/router/pipe_transport/tests.rs +++ b/rust/src/router/pipe_transport/tests.rs @@ -75,17 +75,22 @@ async fn init() -> (Router, Router, WebRtcTransport, WebRtcTransport) { let worker_manager = WorkerManager::new(); - let worker = worker_manager + let worker1 = worker_manager .create_worker(WorkerSettings::default()) .await .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())) .await .expect("Failed to create router"); - let router2 = worker + let router2 = worker2 .create_router(RouterOptions::new(media_codecs())) .await .expect("Failed to create router"); diff --git a/rust/tests/integration/pipe_transport.rs b/rust/tests/integration/pipe_transport.rs index 0651aebf1c..daf1b0cab4 100644 --- a/rust/tests/integration/pipe_transport.rs +++ b/rust/tests/integration/pipe_transport.rs @@ -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(); if env::var(env_logger::DEFAULT_FILTER_ENV).is_err() { @@ -225,17 +232,22 @@ async fn init() -> (Worker, Router, Router, WebRtcTransport, WebRtcTransport) { let worker_manager = WorkerManager::new(); - let worker = worker_manager + let worker1 = worker_manager .create_worker(WorkerSettings::default()) .await .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())) .await .expect("Failed to create router"); - let router2 = worker + let router2 = worker2 .create_router(RouterOptions::new(media_codecs())) .await .expect("Failed to create router"); @@ -256,13 +268,13 @@ async fn init() -> (Worker, Router, Router, WebRtcTransport, WebRtcTransport) { .await .expect("Failed to create transport2"); - (worker, router1, router2, transport_1, transport_2) + (worker1, worker2, router1, router2, transport_1, transport_2) } #[test] fn pipe_to_router_succeeds_with_audio() { 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 .produce(audio_producer_options()) @@ -383,7 +395,7 @@ fn pipe_to_router_succeeds_with_audio() { #[test] fn pipe_to_router_succeeds_with_video() { 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 .produce(audio_producer_options()) @@ -543,7 +555,7 @@ fn pipe_to_router_succeeds_with_video() { #[test] fn weak() { 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 .create_pipe_transport({ @@ -571,7 +583,7 @@ fn weak() { #[test] fn create_with_fixed_port_succeeds() { 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(); @@ -595,7 +607,7 @@ fn create_with_fixed_port_succeeds() { #[test] fn create_with_enable_rtx_succeeds() { 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 .create_pipe_transport({ @@ -703,7 +715,7 @@ fn create_with_enable_rtx_succeeds() { #[test] fn create_with_enable_srtp_succeeds() { 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 .create_pipe_transport({ @@ -755,7 +767,7 @@ fn create_with_enable_srtp_succeeds() { #[test] fn create_with_invalid_srtp_parameters_fails() { 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 .create_pipe_transport(PipeTransportOptions::new(ListenIp { @@ -786,7 +798,7 @@ fn create_with_invalid_srtp_parameters_fails() { #[test] fn consume_for_pipe_producer_succeeds() { 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 .produce(video_producer_options()) @@ -876,7 +888,7 @@ fn consume_for_pipe_producer_succeeds() { #[test] fn producer_pause_resume_are_transmitted_to_pipe_consumer() { 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 .produce(video_producer_options()) @@ -956,7 +968,7 @@ fn producer_pause_resume_are_transmitted_to_pipe_consumer() { #[test] fn pipe_to_router_succeeds_with_data() { 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 .produce_data(data_producer_options()) @@ -1028,7 +1040,7 @@ fn pipe_to_router_succeeds_with_data() { #[test] fn data_consume_for_pipe_data_producer_succeeds() { 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 .produce_data(data_producer_options()) @@ -1067,14 +1079,14 @@ fn data_consume_for_pipe_data_producer_succeeds() { #[test] fn pipe_to_router_called_twice_generates_single_pair() { 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())) .await .expect("Failed to create router"); - let router_b = worker + let router_b = worker2 .create_router(RouterOptions::new(media_codecs())) .await .expect("Failed to create router"); diff --git a/rust/tests/integration/smoke.rs b/rust/tests/integration/smoke.rs index 9180801dbf..e6527f3671 100644 --- a/rust/tests/integration/smoke.rs +++ b/rust/tests/integration/smoke.rs @@ -355,7 +355,12 @@ fn smoke() { .unwrap() ); - let router2 = worker + let worker2 = worker_manager + .create_worker(WorkerSettings::default()) + .await + .unwrap(); + + let router2 = worker2 .create_router(RouterOptions::new(vec![RtpCodecCapability::Audio { mime_type: MimeTypeAudio::Opus, preferred_payload_type: None, diff --git a/worker/include/RTC/Router.hpp b/worker/include/RTC/Router.hpp index bcd77389b4..50e808fd97 100644 --- a/worker/include/RTC/Router.hpp +++ b/worker/include/RTC/Router.hpp @@ -36,6 +36,15 @@ namespace RTC virtual ~Listener() = default; 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( RTC::Router* router, std::string& webRtcServerId) = 0; }; diff --git a/worker/include/Worker.hpp b/worker/include/Worker.hpp index c4cde9789c..9a29d6313a 100644 --- a/worker/include/Worker.hpp +++ b/worker/include/Worker.hpp @@ -60,6 +60,16 @@ class Worker : public Channel::ChannelSocket::Listener, /* Pure virtual methods inherited from RTC::Router::Listener. */ 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; private: @@ -70,6 +80,11 @@ class Worker : public Channel::ChannelSocket::Listener, SignalsHandler* signalsHandler{ nullptr }; absl::flat_hash_map mapWebRtcServers; absl::flat_hash_map mapRouters; + absl::flat_hash_map mapChannelRequestHandlers; + absl::flat_hash_map + mapPayloadChannelRequestHandlers; + absl::flat_hash_map + mapPayloadChannelNotificationHandlers; // Others. bool closed{ false }; }; diff --git a/worker/src/RTC/Router.cpp b/worker/src/RTC/Router.cpp index 0ea696c03e..2c14b14dea 100644 --- a/worker/src/RTC/Router.cpp +++ b/worker/src/RTC/Router.cpp @@ -191,6 +191,10 @@ namespace RTC // Insert into the map. this->mapTransports[transportId] = webRtcTransport; + this->listener->OnChannelRequestHandlerAdded(transportId, webRtcTransport); + this->listener->OnPayloadChannelRequestHandlerAdded(transportId, webRtcTransport); + this->listener->OnPayloadChannelNotificationHandlerAdded(transportId, webRtcTransport); + MS_DEBUG_DEV("WebRtcTransport created [transportId:%s]", transportId.c_str()); json data = json::object(); @@ -277,6 +281,10 @@ namespace RTC // Insert into the map. this->mapTransports[transportId] = webRtcTransport; + this->listener->OnChannelRequestHandlerAdded(transportId, webRtcTransport); + this->listener->OnPayloadChannelRequestHandlerAdded(transportId, webRtcTransport); + this->listener->OnPayloadChannelNotificationHandlerAdded(transportId, webRtcTransport); + MS_DEBUG_DEV( "WebRtcTransport with WebRtcServer created [transportId:%s]", transportId.c_str()); @@ -301,6 +309,10 @@ namespace RTC // Insert into the map. this->mapTransports[transportId] = plainTransport; + this->listener->OnChannelRequestHandlerAdded(transportId, plainTransport); + this->listener->OnPayloadChannelRequestHandlerAdded(transportId, plainTransport); + this->listener->OnPayloadChannelNotificationHandlerAdded(transportId, plainTransport); + MS_DEBUG_DEV("PlainTransport created [transportId:%s]", transportId.c_str()); json data = json::object(); @@ -324,6 +336,10 @@ namespace RTC // Insert into the map. this->mapTransports[transportId] = pipeTransport; + this->listener->OnChannelRequestHandlerAdded(transportId, pipeTransport); + this->listener->OnPayloadChannelRequestHandlerAdded(transportId, pipeTransport); + this->listener->OnPayloadChannelNotificationHandlerAdded(transportId, pipeTransport); + MS_DEBUG_DEV("PipeTransport created [transportId:%s]", transportId.c_str()); json data = json::object(); @@ -347,6 +363,10 @@ namespace RTC // Insert into the map. this->mapTransports[transportId] = directTransport; + this->listener->OnChannelRequestHandlerAdded(transportId, directTransport); + this->listener->OnPayloadChannelRequestHandlerAdded(transportId, directTransport); + this->listener->OnPayloadChannelNotificationHandlerAdded(transportId, directTransport); + MS_DEBUG_DEV("DirectTransport created [transportId:%s]", transportId.c_str()); json data = json::object(); @@ -371,6 +391,8 @@ namespace RTC // Insert into the map. this->mapRtpObservers[rtpObserverId] = activeSpeakerObserver; + this->listener->OnChannelRequestHandlerAdded(rtpObserverId, activeSpeakerObserver); + MS_DEBUG_DEV("ActiveSpeakerObserver created [rtpObserverId:%s]", rtpObserverId.c_str()); request->Accept(); @@ -390,6 +412,8 @@ namespace RTC // Insert into the map. this->mapRtpObservers[rtpObserverId] = audioLevelObserver; + this->listener->OnChannelRequestHandlerAdded(rtpObserverId, audioLevelObserver); + MS_DEBUG_DEV("AudioLevelObserver created [rtpObserverId:%s]", rtpObserverId.c_str()); request->Accept(); @@ -409,6 +433,10 @@ namespace RTC // Remove it from the map. this->mapTransports.erase(transport->id); + this->listener->OnChannelRequestHandlerRemoved(transport->id); + this->listener->OnPayloadChannelRequestHandlerRemoved(transport->id); + this->listener->OnPayloadChannelNotificationHandlerRemoved(transport->id); + MS_DEBUG_DEV("Transport closed [transportId:%s]", transport->id.c_str()); // Delete it. @@ -435,6 +463,8 @@ namespace RTC rtpObservers.erase(rtpObserver); } + this->listener->OnChannelRequestHandlerRemoved(rtpObserver->id); + MS_DEBUG_DEV("RtpObserver closed [rtpObserverId:%s]", rtpObserver->id.c_str()); // Delete it. @@ -609,6 +639,9 @@ namespace RTC this->mapProducers[producer->id] = producer; this->mapProducerConsumers[producer]; this->mapProducerRtpObservers[producer]; + + this->listener->OnChannelRequestHandlerAdded(producer->id, producer); + this->listener->OnPayloadChannelNotificationHandlerAdded(producer->id, producer); } inline void Router::OnTransportProducerClosed(RTC::Transport* /*transport*/, RTC::Producer* producer) @@ -654,6 +687,9 @@ namespace RTC this->mapProducers.erase(mapProducersIt); this->mapProducerConsumers.erase(mapProducerConsumersIt); this->mapProducerRtpObservers.erase(mapProducerRtpObserversIt); + + this->listener->OnChannelRequestHandlerRemoved(producer->id); + this->listener->OnPayloadChannelNotificationHandlerRemoved(producer->id); } inline void Router::OnTransportProducerPaused(RTC::Transport* /*transport*/, RTC::Producer* producer) @@ -843,6 +879,8 @@ namespace RTC // Provide the Consumer with the scores of all streams in the Producer. consumer->ProducerRtpStreamScores(producer->GetRtpStreamScores()); + + this->listener->OnChannelRequestHandlerAdded(consumer->id, consumer); } inline void Router::OnTransportConsumerClosed(RTC::Transport* /*transport*/, RTC::Consumer* consumer) @@ -874,6 +912,8 @@ namespace RTC // Remove the Consumer from the map. this->mapConsumerProducer.erase(mapConsumerProducerIt); + + this->listener->OnChannelRequestHandlerRemoved(consumer->id); } inline void Router::OnTransportConsumerProducerClosed( @@ -926,6 +966,9 @@ namespace RTC // Insert the DataProducer in the maps. this->mapDataProducers[dataProducer->id] = dataProducer; this->mapDataProducerDataConsumers[dataProducer]; + + this->listener->OnChannelRequestHandlerAdded(dataProducer->id, dataProducer); + this->listener->OnPayloadChannelNotificationHandlerAdded(dataProducer->id, dataProducer); } inline void Router::OnTransportDataProducerClosed( @@ -962,6 +1005,9 @@ namespace RTC // Remove the DataProducer from the maps. this->mapDataProducers.erase(mapDataProducersIt); this->mapDataProducerDataConsumers.erase(mapDataProducerDataConsumersIt); + + this->listener->OnChannelRequestHandlerRemoved(dataProducer->id); + this->listener->OnPayloadChannelNotificationHandlerRemoved(dataProducer->id); } inline void Router::OnTransportDataProducerMessageReceived( @@ -1006,6 +1052,8 @@ namespace RTC dataConsumers.insert(dataConsumer); this->mapDataConsumerDataProducer[dataConsumer] = dataProducer; + + this->listener->OnChannelRequestHandlerAdded(dataConsumer->id, dataConsumer); } inline void Router::OnTransportDataConsumerClosed( @@ -1039,6 +1087,8 @@ namespace RTC // Remove the DataConsumer from the map. this->mapDataConsumerDataProducer.erase(mapDataConsumerDataProducerIt); + + this->listener->OnChannelRequestHandlerRemoved(dataConsumer->id); } inline void Router::OnTransportDataConsumerDataProducerClosed( diff --git a/worker/src/Worker.cpp b/worker/src/Worker.cpp index 96ebe3b11a..3251f784a4 100644 --- a/worker/src/Worker.cpp +++ b/worker/src/Worker.cpp @@ -90,6 +90,11 @@ void Worker::Close() // Close the PayloadChannel. this->payloadChannel->Close(); + + // Clear all request and notification handlers. + this->mapChannelRequestHandlers.clear(); + this->mapPayloadChannelRequestHandlers.clear(); + this->mapPayloadChannelNotificationHandlers.clear(); } void Worker::FillJson(json& jsonObject) const @@ -314,6 +319,7 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) auto* webRtcServer = new RTC::WebRtcServer(webRtcServerId, request->data); this->mapWebRtcServers[webRtcServerId] = webRtcServer; + this->OnChannelRequestHandlerAdded(webRtcServerId, webRtcServer); MS_DEBUG_DEV("WebRtcServer created [webRtcServerId:%s]", webRtcServerId.c_str()); @@ -346,6 +352,7 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) // Remove it from the map and delete it. this->mapWebRtcServers.erase(webRtcServer->id); + this->OnChannelRequestHandlerRemoved(webRtcServer->id); delete webRtcServer; MS_DEBUG_DEV("WebRtcServer closed [id:%s]", webRtcServer->id.c_str()); @@ -389,6 +396,9 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) auto* router = new RTC::Router(routerId, this); this->mapRouters[routerId] = router; + this->OnChannelRequestHandlerAdded(routerId, router); + this->OnPayloadChannelRequestHandlerAdded(routerId, router); + this->OnPayloadChannelNotificationHandlerAdded(routerId, router); MS_DEBUG_DEV("Router created [routerId:%s]", routerId.c_str()); @@ -412,6 +422,9 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) // Remove it from the map and delete it. this->mapRouters.erase(router->id); + this->OnChannelRequestHandlerRemoved(router->id); + this->OnPayloadChannelRequestHandlerRemoved(router->id); + this->OnPayloadChannelNotificationHandlerRemoved(router->id); delete router; MS_DEBUG_DEV("Router closed [id:%s]", router->id.c_str()); @@ -559,6 +572,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( RTC::Router* /*router*/, std::string& webRtcServerId) { From 143f33cae2a9025138b5df0371a5b04df8412721 Mon Sep 17 00:00:00 2001 From: Nazar Mokrynskyi Date: Sun, 24 Jul 2022 22:54:26 +0300 Subject: [PATCH 2/5] Refactor close methods on worker to reflect who is handling them better --- doc/closures.md | 8 ++++---- node/lib/Consumer.js | 2 +- node/lib/DataConsumer.js | 2 +- node/lib/DataProducer.js | 2 +- node/lib/Producer.js | 2 +- node/lib/Router.js | 2 +- node/lib/RtpObserver.js | 2 +- node/lib/Transport.js | 2 +- node/lib/WebRtcServer.js | 2 +- node/src/Consumer.ts | 2 +- node/src/DataConsumer.ts | 2 +- node/src/DataProducer.ts | 2 +- node/src/Producer.ts | 2 +- node/src/Router.ts | 2 +- node/src/RtpObserver.ts | 2 +- node/src/Transport.ts | 2 +- node/src/WebRtcServer.ts | 2 +- rust/src/messages.rs | 16 ++++++++-------- worker/include/Channel/ChannelRequest.hpp | 16 ++++++++-------- worker/src/Channel/ChannelRequest.cpp | 16 ++++++++-------- worker/src/RTC/Router.cpp | 4 ++-- worker/src/RTC/Transport.cpp | 8 ++++---- worker/src/Worker.cpp | 4 ++-- 23 files changed, 52 insertions(+), 52 deletions(-) diff --git a/doc/closures.md b/doc/closures.md index 0c868a8bd4..11086ae6c9 100644 --- a/doc/closures.md +++ b/doc/closures.md @@ -30,7 +30,7 @@ Some considerations: ## JS router.close() * Public API. -* Sends channel request `ROUTER_CLOSE`: +* Sends channel request `WORKER_CLOSE_ROUTER`: - Processed by the C++ Worker. - It removes the C++ Router from its map. - It calls C++ `delete router`. @@ -51,7 +51,7 @@ Some considerations: ## JS transport.close() * Public API. -* Sends channel request `TRANSPORT_CLOSE`. +* Sends channel request `ROUTER_CLOSE_TRANSPORT`. - 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 removes the C++ Transport from its map. @@ -106,7 +106,7 @@ Some considerations: ## JS producer.close() * Public API. -* Sends channel request `PRODUCER_CLOSE`. +* Sends channel request `TRANSPORT_CLOSE_PRODUCER`. - Processed by the C++ Transport. - 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). @@ -125,7 +125,7 @@ Some considerations: ## JS consumer.close() * Public API. -* Sends channel request `CONSUMER_CLOSE`. +* Sends channel request `TRANSPORT_CLOSE_CONSUMER`. - Processed by the C++ Transport. - Removes it from its map of Consumers. - Calls its `listener->OnTransportConsumerClosed(this, consumer)` (so the C++ Router cleans its maps). diff --git a/node/lib/Consumer.js b/node/lib/Consumer.js index 1731a87816..e1496f1a5a 100644 --- a/node/lib/Consumer.js +++ b/node/lib/Consumer.js @@ -156,7 +156,7 @@ class Consumer extends EnhancedEventEmitter_1.EnhancedEventEmitter { // Remove notification subscriptions. this.#channel.removeAllListeners(this.#internal.consumerId); this.#payloadChannel.removeAllListeners(this.#internal.consumerId); - this.#channel.request('consumer.close', this.#internal) + this.#channel.request('transport.closeConsumer', this.#internal) .catch(() => { }); this.emit('@close'); // Emit observer event. diff --git a/node/lib/DataConsumer.js b/node/lib/DataConsumer.js index 17bb008bcd..25f0963312 100644 --- a/node/lib/DataConsumer.js +++ b/node/lib/DataConsumer.js @@ -103,7 +103,7 @@ class DataConsumer extends EnhancedEventEmitter_1.EnhancedEventEmitter { // Remove notification subscriptions. this.#channel.removeAllListeners(this.#internal.dataConsumerId); this.#payloadChannel.removeAllListeners(this.#internal.dataConsumerId); - this.#channel.request('dataConsumer.close', this.#internal) + this.#channel.request('transport.closeDataConsumer', this.#internal) .catch(() => { }); this.emit('@close'); // Emit observer event. diff --git a/node/lib/DataProducer.js b/node/lib/DataProducer.js index 551c51d6b8..30c9dc4b71 100644 --- a/node/lib/DataProducer.js +++ b/node/lib/DataProducer.js @@ -97,7 +97,7 @@ class DataProducer extends EnhancedEventEmitter_1.EnhancedEventEmitter { // Remove notification subscriptions. this.#channel.removeAllListeners(this.#internal.dataProducerId); this.#payloadChannel.removeAllListeners(this.#internal.dataProducerId); - this.#channel.request('dataProducer.close', this.#internal) + this.#channel.request('transport.closeDataProducer', this.#internal) .catch(() => { }); this.emit('@close'); // Emit observer event. diff --git a/node/lib/Producer.js b/node/lib/Producer.js index 4369d3592a..69e3155057 100644 --- a/node/lib/Producer.js +++ b/node/lib/Producer.js @@ -123,7 +123,7 @@ class Producer extends EnhancedEventEmitter_1.EnhancedEventEmitter { // Remove notification subscriptions. this.#channel.removeAllListeners(this.#internal.producerId); this.#payloadChannel.removeAllListeners(this.#internal.producerId); - this.#channel.request('producer.close', this.#internal) + this.#channel.request('transport.closeProducer', this.#internal) .catch(() => { }); this.emit('@close'); // Emit observer event. diff --git a/node/lib/Router.js b/node/lib/Router.js index 7b90e5bf88..de13e93f20 100644 --- a/node/lib/Router.js +++ b/node/lib/Router.js @@ -102,7 +102,7 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter { return; logger.debug('close()'); this.#closed = true; - this.#channel.request('router.close', this.#internal) + this.#channel.request('worker.closeRouter', this.#internal) .catch(() => { }); // Close every Transport. for (const transport of this.#transports.values()) { diff --git a/node/lib/RtpObserver.js b/node/lib/RtpObserver.js index b0c1608c68..dc82d0ff13 100644 --- a/node/lib/RtpObserver.js +++ b/node/lib/RtpObserver.js @@ -81,7 +81,7 @@ class RtpObserver extends EnhancedEventEmitter_1.EnhancedEventEmitter { // Remove notification subscriptions. this.channel.removeAllListeners(this.internal.rtpObserverId); this.payloadChannel.removeAllListeners(this.internal.rtpObserverId); - this.channel.request('rtpObserver.close', this.internal) + this.channel.request('router.closeRtpObserver', this.internal) .catch(() => { }); this.emit('@close'); // Emit observer event. diff --git a/node/lib/Transport.js b/node/lib/Transport.js index 1e53f16d88..b0c27aa3bb 100644 --- a/node/lib/Transport.js +++ b/node/lib/Transport.js @@ -112,7 +112,7 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter { // Remove notification subscriptions. this.channel.removeAllListeners(this.internal.transportId); this.payloadChannel.removeAllListeners(this.internal.transportId); - this.channel.request('transport.close', this.internal) + this.channel.request('router.closeTransport', this.internal) .catch(() => { }); // Close every Producer. for (const producer of this.#producers.values()) { diff --git a/node/lib/WebRtcServer.js b/node/lib/WebRtcServer.js index fc860ed164..dfdc4cb9a2 100644 --- a/node/lib/WebRtcServer.js +++ b/node/lib/WebRtcServer.js @@ -72,7 +72,7 @@ class WebRtcServer extends EnhancedEventEmitter_1.EnhancedEventEmitter { return; logger.debug('close()'); this.#closed = true; - this.#channel.request('webRtcServer.close', this.#internal) + this.#channel.request('worker.closeWebRtcServer', this.#internal) .catch(() => { }); // Close every WebRtcTransport. for (const webRtcTransport of this.#webRtcTransports.values()) { diff --git a/node/src/Consumer.ts b/node/src/Consumer.ts index 18d5697946..1b17f0b5da 100644 --- a/node/src/Consumer.ts +++ b/node/src/Consumer.ts @@ -428,7 +428,7 @@ export class Consumer extends EnhancedEventEmitter this.#channel.removeAllListeners(this.#internal.consumerId); this.#payloadChannel.removeAllListeners(this.#internal.consumerId); - this.#channel.request('consumer.close', this.#internal) + this.#channel.request('transport.closeConsumer', this.#internal) .catch(() => {}); this.emit('@close'); diff --git a/node/src/DataConsumer.ts b/node/src/DataConsumer.ts index 6ca60c9282..f0075e68a7 100644 --- a/node/src/DataConsumer.ts +++ b/node/src/DataConsumer.ts @@ -240,7 +240,7 @@ export class DataConsumer extends EnhancedEventEmitter this.#channel.removeAllListeners(this.#internal.dataConsumerId); this.#payloadChannel.removeAllListeners(this.#internal.dataConsumerId); - this.#channel.request('dataConsumer.close', this.#internal) + this.#channel.request('transport.closeDataConsumer', this.#internal) .catch(() => {}); this.emit('@close'); diff --git a/node/src/DataProducer.ts b/node/src/DataProducer.ts index f84645f4dd..df82311310 100644 --- a/node/src/DataProducer.ts +++ b/node/src/DataProducer.ts @@ -217,7 +217,7 @@ export class DataProducer extends EnhancedEventEmitter this.#channel.removeAllListeners(this.#internal.dataProducerId); this.#payloadChannel.removeAllListeners(this.#internal.dataProducerId); - this.#channel.request('dataProducer.close', this.#internal) + this.#channel.request('transport.closeDataProducer', this.#internal) .catch(() => {}); this.emit('@close'); diff --git a/node/src/Producer.ts b/node/src/Producer.ts index 543be09790..ad2808b97a 100644 --- a/node/src/Producer.ts +++ b/node/src/Producer.ts @@ -353,7 +353,7 @@ export class Producer extends EnhancedEventEmitter this.#channel.removeAllListeners(this.#internal.producerId); this.#payloadChannel.removeAllListeners(this.#internal.producerId); - this.#channel.request('producer.close', this.#internal) + this.#channel.request('transport.closeProducer', this.#internal) .catch(() => {}); this.emit('@close'); diff --git a/node/src/Router.ts b/node/src/Router.ts index b7ca8cb9ce..1cba3e350e 100644 --- a/node/src/Router.ts +++ b/node/src/Router.ts @@ -266,7 +266,7 @@ export class Router extends EnhancedEventEmitter this.#closed = true; - this.#channel.request('router.close', this.#internal) + this.#channel.request('worker.closeRouter', this.#internal) .catch(() => {}); // Close every Transport. diff --git a/node/src/RtpObserver.ts b/node/src/RtpObserver.ts index 78e48ce3ad..fd54ed6495 100644 --- a/node/src/RtpObserver.ts +++ b/node/src/RtpObserver.ts @@ -157,7 +157,7 @@ export class RtpObserver this.channel.removeAllListeners(this.internal.rtpObserverId); this.payloadChannel.removeAllListeners(this.internal.rtpObserverId); - this.channel.request('rtpObserver.close', this.internal) + this.channel.request('router.closeRtpObserver', this.internal) .catch(() => {}); this.emit('@close'); diff --git a/node/src/Transport.ts b/node/src/Transport.ts index 269444419e..797b62b2ac 100644 --- a/node/src/Transport.ts +++ b/node/src/Transport.ts @@ -279,7 +279,7 @@ export class Transport {}); // Close every Producer. diff --git a/node/src/WebRtcServer.ts b/node/src/WebRtcServer.ts index 9c1ec86c92..1e300a0dad 100644 --- a/node/src/WebRtcServer.ts +++ b/node/src/WebRtcServer.ts @@ -166,7 +166,7 @@ export class WebRtcServer extends EnhancedEventEmitter this.#closed = true; - this.#channel.request('webRtcServer.close', this.#internal) + this.#channel.request('worker.closeWebRtcServer', this.#internal) .catch(() => {}); // Close every WebRtcTransport. diff --git a/rust/src/messages.rs b/rust/src/messages.rs index bdc0b15ce7..eb5ad5269d 100644 --- a/rust/src/messages.rs +++ b/rust/src/messages.rs @@ -212,7 +212,7 @@ request_response!( ); request_response!( - "webRtcServer.close", + "worker.closeWebRtcServer", WebRtcServerCloseRequest { internal: WebRtcServerInternal, }, @@ -236,7 +236,7 @@ request_response!( ); request_response!( - "router.close", + "worker.closeRouter", RouterCloseRequest { internal: RouterInternal, }, @@ -524,7 +524,7 @@ request_response!( ); request_response!( - "transport.close", + "router.closeTransport", TransportCloseRequest { internal: TransportInternal, }, @@ -772,7 +772,7 @@ impl Notification for TransportSendRtcpNotification { } request_response!( - "producer.close", + "transport.closeProducer", ProducerCloseRequest { internal: ProducerInternal, }, @@ -836,7 +836,7 @@ impl Notification for ProducerSendNotification { } request_response!( - "consumer.close", + "transport.closeConsumer", ConsumerCloseRequest { internal: ConsumerInternal, }, @@ -920,7 +920,7 @@ request_response!( ); request_response!( - "dataProducer.close", + "transport.closeDataProducer", DataProducerCloseRequest { internal: DataProducerInternal, }, @@ -963,7 +963,7 @@ impl Notification for DataProducerSendNotification { } request_response!( - "dataConsumer.close", + "transport.closeDataConsumer", DataConsumerCloseRequest { internal: DataConsumerInternal }, @@ -1026,7 +1026,7 @@ request_response!( ); request_response!( - "rtpObserver.close", + "router.closeRtpObserver", RtpObserverCloseRequest { internal: RtpObserverInternal, }, diff --git a/worker/include/Channel/ChannelRequest.hpp b/worker/include/Channel/ChannelRequest.hpp index dfb8231e2f..86d06f0c29 100644 --- a/worker/include/Channel/ChannelRequest.hpp +++ b/worker/include/Channel/ChannelRequest.hpp @@ -25,18 +25,19 @@ namespace Channel WORKER_UPDATE_SETTINGS, WORKER_CREATE_WEBRTC_SERVER, WORKER_CREATE_ROUTER, - WEBRTC_SERVER_CLOSE, + WORKER_WEBRTC_SERVER_CLOSE, WEBRTC_SERVER_DUMP, - ROUTER_CLOSE, + WORKER_CLOSE_ROUTER, ROUTER_DUMP, ROUTER_CREATE_WEBRTC_TRANSPORT, ROUTER_CREATE_WEBRTC_TRANSPORT_WITH_SERVER, ROUTER_CREATE_PLAIN_TRANSPORT, ROUTER_CREATE_PIPE_TRANSPORT, ROUTER_CREATE_DIRECT_TRANSPORT, + ROUTER_CLOSE_TRANSPORT, ROUTER_CREATE_ACTIVE_SPEAKER_OBSERVER, ROUTER_CREATE_AUDIO_LEVEL_OBSERVER, - TRANSPORT_CLOSE, + ROUTER_CLOSE_RTP_OBSERVER, TRANSPORT_DUMP, TRANSPORT_GET_STATS, TRANSPORT_CONNECT, @@ -48,13 +49,13 @@ namespace Channel TRANSPORT_PRODUCE_DATA, TRANSPORT_CONSUME_DATA, TRANSPORT_ENABLE_TRACE_EVENT, - PRODUCER_CLOSE, + TRANSPORT_CLOSE_PRODUCER, PRODUCER_DUMP, PRODUCER_GET_STATS, PRODUCER_PAUSE, PRODUCER_RESUME, PRODUCER_ENABLE_TRACE_EVENT, - CONSUMER_CLOSE, + TRANSPORT_CLOSE_CONSUMER, CONSUMER_DUMP, CONSUMER_GET_STATS, CONSUMER_PAUSE, @@ -63,15 +64,14 @@ namespace Channel CONSUMER_SET_PRIORITY, CONSUMER_REQUEST_KEY_FRAME, CONSUMER_ENABLE_TRACE_EVENT, - DATA_PRODUCER_CLOSE, + TRANSPORT_CLOSE_DATA_PRODUCER, DATA_PRODUCER_DUMP, DATA_PRODUCER_GET_STATS, - DATA_CONSUMER_CLOSE, + TRANSPORT_CLOSE_DATA_CONSUMER, DATA_CONSUMER_DUMP, DATA_CONSUMER_GET_STATS, DATA_CONSUMER_GET_BUFFERED_AMOUNT, DATA_CONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD, - RTP_OBSERVER_CLOSE, RTP_OBSERVER_PAUSE, RTP_OBSERVER_RESUME, RTP_OBSERVER_ADD_PRODUCER, diff --git a/worker/src/Channel/ChannelRequest.cpp b/worker/src/Channel/ChannelRequest.cpp index 520537e69d..fd2de2d65d 100644 --- a/worker/src/Channel/ChannelRequest.cpp +++ b/worker/src/Channel/ChannelRequest.cpp @@ -19,18 +19,19 @@ namespace Channel { "worker.updateSettings", ChannelRequest::MethodId::WORKER_UPDATE_SETTINGS }, { "worker.createWebRtcServer", ChannelRequest::MethodId::WORKER_CREATE_WEBRTC_SERVER }, { "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 }, - { "router.close", ChannelRequest::MethodId::ROUTER_CLOSE }, + { "worker.closeRouter", ChannelRequest::MethodId::WORKER_CLOSE_ROUTER }, { "router.dump", ChannelRequest::MethodId::ROUTER_DUMP }, { "router.createWebRtcTransport", ChannelRequest::MethodId::ROUTER_CREATE_WEBRTC_TRANSPORT }, { "router.createWebRtcTransportWithServer", ChannelRequest::MethodId::ROUTER_CREATE_WEBRTC_TRANSPORT_WITH_SERVER }, { "router.createPlainTransport", ChannelRequest::MethodId::ROUTER_CREATE_PLAIN_TRANSPORT }, { "router.createPipeTransport", ChannelRequest::MethodId::ROUTER_CREATE_PIPE_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.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.getStats", ChannelRequest::MethodId::TRANSPORT_GET_STATS }, { "transport.connect", ChannelRequest::MethodId::TRANSPORT_CONNECT }, @@ -42,13 +43,15 @@ namespace Channel { "transport.produceData", ChannelRequest::MethodId::TRANSPORT_PRODUCE_DATA }, { "transport.consumeData", ChannelRequest::MethodId::TRANSPORT_CONSUME_DATA }, { "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.getStats", ChannelRequest::MethodId::PRODUCER_GET_STATS }, { "producer.pause", ChannelRequest::MethodId::PRODUCER_PAUSE }, { "producer.resume" , ChannelRequest::MethodId::PRODUCER_RESUME }, { "producer.enableTraceEvent", ChannelRequest::MethodId::PRODUCER_ENABLE_TRACE_EVENT }, - { "consumer.close", ChannelRequest::MethodId::CONSUMER_CLOSE }, { "consumer.dump", ChannelRequest::MethodId::CONSUMER_DUMP }, { "consumer.getStats", ChannelRequest::MethodId::CONSUMER_GET_STATS }, { "consumer.pause", ChannelRequest::MethodId::CONSUMER_PAUSE }, @@ -57,15 +60,12 @@ namespace Channel { "consumer.setPriority", ChannelRequest::MethodId::CONSUMER_SET_PRIORITY }, { "consumer.requestKeyFrame", ChannelRequest::MethodId::CONSUMER_REQUEST_KEY_FRAME }, { "consumer.enableTraceEvent", ChannelRequest::MethodId::CONSUMER_ENABLE_TRACE_EVENT }, - { "dataProducer.close", ChannelRequest::MethodId::DATA_PRODUCER_CLOSE }, { "dataProducer.dump", ChannelRequest::MethodId::DATA_PRODUCER_DUMP }, { "dataProducer.getStats", ChannelRequest::MethodId::DATA_PRODUCER_GET_STATS }, - { "dataConsumer.close", ChannelRequest::MethodId::DATA_CONSUMER_CLOSE }, { "dataConsumer.dump", ChannelRequest::MethodId::DATA_CONSUMER_DUMP }, { "dataConsumer.getStats", ChannelRequest::MethodId::DATA_CONSUMER_GET_STATS }, { "dataConsumer.getBufferedAmount", ChannelRequest::MethodId::DATA_CONSUMER_GET_BUFFERED_AMOUNT }, { "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.resume", ChannelRequest::MethodId::RTP_OBSERVER_RESUME }, { "rtpObserver.addProducer", ChannelRequest::MethodId::RTP_OBSERVER_ADD_PRODUCER }, diff --git a/worker/src/RTC/Router.cpp b/worker/src/RTC/Router.cpp index 2c14b14dea..97463e7728 100644 --- a/worker/src/RTC/Router.cpp +++ b/worker/src/RTC/Router.cpp @@ -421,7 +421,7 @@ namespace RTC break; } - case Channel::ChannelRequest::MethodId::TRANSPORT_CLOSE: + case Channel::ChannelRequest::MethodId::ROUTER_CLOSE_TRANSPORT: { // This may throw. RTC::Transport* transport = GetTransportFromInternal(request->internal); @@ -447,7 +447,7 @@ namespace RTC break; } - case Channel::ChannelRequest::MethodId::RTP_OBSERVER_CLOSE: + case Channel::ChannelRequest::MethodId::ROUTER_CLOSE_RTP_OBSERVER: { // This may throw. RTC::RtpObserver* rtpObserver = GetRtpObserverFromInternal(request->internal); diff --git a/worker/src/RTC/Transport.cpp b/worker/src/RTC/Transport.cpp index b0c8817b6e..9594f9e178 100644 --- a/worker/src/RTC/Transport.cpp +++ b/worker/src/RTC/Transport.cpp @@ -1307,7 +1307,7 @@ namespace RTC break; } - case Channel::ChannelRequest::MethodId::PRODUCER_CLOSE: + case Channel::ChannelRequest::MethodId::TRANSPORT_CLOSE_PRODUCER: { // This may throw. RTC::Producer* producer = GetProducerFromInternal(request->internal); @@ -1342,7 +1342,7 @@ namespace RTC break; } - case Channel::ChannelRequest::MethodId::CONSUMER_CLOSE: + case Channel::ChannelRequest::MethodId::TRANSPORT_CLOSE_CONSUMER: { // This may throw. RTC::Consumer* consumer = GetConsumerFromInternal(request->internal); @@ -1414,7 +1414,7 @@ namespace RTC break; } - case Channel::ChannelRequest::MethodId::DATA_PRODUCER_CLOSE: + case Channel::ChannelRequest::MethodId::TRANSPORT_CLOSE_DATA_PRODUCER: { // This may throw. RTC::DataProducer* dataProducer = GetDataProducerFromInternal(request->internal); @@ -1447,7 +1447,7 @@ namespace RTC break; } - case Channel::ChannelRequest::MethodId::DATA_CONSUMER_CLOSE: + case Channel::ChannelRequest::MethodId::TRANSPORT_CLOSE_DATA_CONSUMER: { // This may throw. RTC::DataConsumer* dataConsumer = GetDataConsumerFromInternal(request->internal); diff --git a/worker/src/Worker.cpp b/worker/src/Worker.cpp index 3251f784a4..71e2938abf 100644 --- a/worker/src/Worker.cpp +++ b/worker/src/Worker.cpp @@ -337,7 +337,7 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) break; } - case Channel::ChannelRequest::MethodId::WEBRTC_SERVER_CLOSE: + case Channel::ChannelRequest::MethodId::WORKER_WEBRTC_SERVER_CLOSE: { RTC::WebRtcServer* webRtcServer{ nullptr }; @@ -407,7 +407,7 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) break; } - case Channel::ChannelRequest::MethodId::ROUTER_CLOSE: + case Channel::ChannelRequest::MethodId::WORKER_CLOSE_ROUTER: { RTC::Router* router{ nullptr }; From ec8687b8cb2254b13df3bf7ec06ce0081e73de0c Mon Sep 17 00:00:00 2001 From: Nazar Mokrynskyi Date: Sun, 24 Jul 2022 09:01:34 +0300 Subject: [PATCH 3/5] Refactor some of `.create` methods to take an ID of created entity in `data` field instead of `internal` --- node/lib/Router.d.ts.map | 2 +- node/lib/Router.js | 74 ++++++++++++++++++++++------------ node/lib/Worker.d.ts.map | 2 +- node/lib/Worker.js | 18 +++++---- node/src/Router.ts | 76 ++++++++++++++++++++++------------- node/src/Worker.ts | 20 +++++---- rust/src/messages.rs | 61 ++++++++++++++++++++++------ rust/src/router.rs | 43 +++++++++++--------- rust/src/worker.rs | 14 ++++--- worker/include/RTC/Router.hpp | 4 +- worker/include/Worker.hpp | 4 +- worker/src/RTC/Router.cpp | 26 ++++++------ worker/src/Worker.cpp | 20 ++++----- 13 files changed, 231 insertions(+), 133 deletions(-) diff --git a/node/lib/Router.d.ts.map b/node/lib/Router.d.ts.map index fc541551bd..e31b1e8839 100644 --- a/node/lib/Router.d.ts.map +++ b/node/lib/Router.d.ts.map @@ -1 +1 @@ -{"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,OAA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F,GACC,OAAO,CAAC,eAAe,CAAC;IA4C3B;;OAEG;IACG,YAAY,CACjB,EACC,UAAU,EACV,cAAc,EACd,MAAM,EACN,QAAsB,EACtB,UAAiB,EACjB,cAAwC,EACxC,SAAiB,EACjB,UAAkB,EAClB,EAAE,mBAAmB,GACpB,OAAO,CAAC,kBAAkB,CAAC;IA8O9B;;OAEG;IACH,oBAAoB,CACnB,oBAAoB,EAAE,MAAM,EAC5B,wBAAwB,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAClD,IAAI;IA+BP;;OAEG;IACG,2BAA2B,CAChC,EACC,QAAc,EACd,OAAO,EACP,GAAE,4BAAiC,GAClC,OAAO,CAAC,qBAAqB,CAAC;IAmCjC;;OAEG;IACG,wBAAwB,CAC7B,EACC,UAAc,EACd,SAAe,EACf,QAAe,EACf,OAAO,EACP,GAAE,yBAA8B,GAC/B,OAAO,CAAC,kBAAkB,CAAC;IAmC9B;;OAEG;IACH,UAAU,CACT,EACC,UAAU,EACV,eAAe,EACf,EACD;QACC,UAAU,EAAE,MAAM,CAAC;QACnB,eAAe,EAAE,eAAe,CAAC;KACjC,GACC,OAAO;CAuBV"} \ No newline at end of file +{"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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AAwB,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAClD,IAAI;IA+BP;;OAEG;IACG,2BAA2B,CAChC,EACC,QAAc,EACd,OAAO,EACP,GAAE,4BAAiC,GAClC,OAAO,CAAC,qBAAqB,CAAC;IAwCjC;;OAEG;IACG,wBAAwB,CAC7B,EACC,UAAc,EACd,SAAe,EACf,QAAe,EACf,OAAO,EACP,GAAE,yBAA8B,GAC/B,OAAO,CAAC,kBAAkB,CAAC;IA0C9B;;OAEG;IACH,UAAU,CACT,EACC,UAAU,EACV,eAAe,EACf,EACD;QACC,UAAU,EAAE,MAAM,CAAC;QACnB,eAAe,EAAE,eAAe,CAAC;KACjC,GACC,OAAO;CAuBV"} \ No newline at end of file diff --git a/node/lib/Router.js b/node/lib/Router.js index de13e93f20..5600508e81 100644 --- a/node/lib/Router.js +++ b/node/lib/Router.js @@ -182,11 +182,8 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter { } }); } - const internal = { - ...this.#internal, - transportId: (0, uuid_1.v4)() - }; const reqData = { + transportId: (0, uuid_1.v4)(), webRtcServerId: webRtcServer ? webRtcServer.id : undefined, listenIps, port, @@ -202,10 +199,13 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter { isDataChannel: true }; const data = webRtcServer - ? await this.#channel.request('router.createWebRtcTransportWithServer', internal, reqData) - : await this.#channel.request('router.createWebRtcTransport', internal, reqData); + ? await this.#channel.request('router.createWebRtcTransportWithServer', this.#internal, reqData) + : await this.#channel.request('router.createWebRtcTransport', this.#internal, reqData); const transport = new WebRtcTransport_1.WebRtcTransport({ - internal, + internal: { + ...this.#internal, + transportId: reqData.transportId + }, data, channel: this.#channel, payloadChannel: this.#payloadChannel, @@ -249,8 +249,8 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter { else { throw new TypeError('wrong listenIp'); } - const internal = { ...this.#internal, transportId: (0, uuid_1.v4)() }; const reqData = { + transportId: (0, uuid_1.v4)(), listenIp, port, rtcpMux, @@ -263,9 +263,12 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter { enableSrtp, srtpCryptoSuite }; - const data = await this.#channel.request('router.createPlainTransport', internal, reqData); + const data = await this.#channel.request('router.createPlainTransport', this.#internal, reqData); const transport = new PlainTransport_1.PlainTransport({ - internal, + internal: { + ...this.#internal, + transportId: reqData.transportId + }, data, channel: this.#channel, payloadChannel: this.#payloadChannel, @@ -307,8 +310,8 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter { else { throw new TypeError('wrong listenIp'); } - const internal = { ...this.#internal, transportId: (0, uuid_1.v4)() }; const reqData = { + transportId: (0, uuid_1.v4)(), listenIp, port, enableSctp, @@ -319,9 +322,12 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter { enableRtx, enableSrtp }; - const data = await this.#channel.request('router.createPipeTransport', internal, reqData); + const data = await this.#channel.request('router.createPipeTransport', this.#internal, reqData); const transport = new PipeTransport_1.PipeTransport({ - internal, + internal: { + ...this.#internal, + transportId: reqData.transportId + }, data, channel: this.#channel, payloadChannel: this.#payloadChannel, @@ -348,11 +354,17 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter { maxMessageSize: 262144 }) { logger.debug('createDirectTransport()'); - const internal = { ...this.#internal, transportId: (0, uuid_1.v4)() }; - const reqData = { direct: true, maxMessageSize }; - const data = await this.#channel.request('router.createDirectTransport', internal, reqData); + const reqData = { + transportId: (0, uuid_1.v4)(), + direct: true, + maxMessageSize + }; + const data = await this.#channel.request('router.createDirectTransport', this.#internal, reqData); const transport = new DirectTransport_1.DirectTransport({ - internal, + internal: { + ...this.#internal, + transportId: reqData.transportId + }, data, channel: this.#channel, payloadChannel: this.#payloadChannel, @@ -564,11 +576,16 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter { logger.debug('createActiveSpeakerObserver()'); if (appData && typeof appData !== 'object') throw new TypeError('if given, appData must be an object'); - const internal = { ...this.#internal, rtpObserverId: (0, uuid_1.v4)() }; - const reqData = { interval }; - await this.#channel.request('router.createActiveSpeakerObserver', internal, reqData); + const reqData = { + rtpObserverId: (0, uuid_1.v4)(), + interval + }; + await this.#channel.request('router.createActiveSpeakerObserver', this.#internal, reqData); const activeSpeakerObserver = new ActiveSpeakerObserver_1.ActiveSpeakerObserver({ - internal, + internal: { + ...this.#internal, + rtpObserverId: reqData.rtpObserverId + }, channel: this.#channel, payloadChannel: this.#payloadChannel, appData, @@ -589,11 +606,18 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter { logger.debug('createAudioLevelObserver()'); if (appData && typeof appData !== 'object') throw new TypeError('if given, appData must be an object'); - const internal = { ...this.#internal, rtpObserverId: (0, uuid_1.v4)() }; - const reqData = { maxEntries, threshold, interval }; - await this.#channel.request('router.createAudioLevelObserver', internal, reqData); + const reqData = { + rtpObserverId: (0, uuid_1.v4)(), + maxEntries, + threshold, + interval + }; + await this.#channel.request('router.createAudioLevelObserver', this.#internal, reqData); const audioLevelObserver = new AudioLevelObserver_1.AudioLevelObserver({ - internal, + internal: { + ...this.#internal, + rtpObserverId: reqData.rtpObserverId + }, channel: this.#channel, payloadChannel: this.#payloadChannel, appData, diff --git a/node/lib/Worker.d.ts.map b/node/lib/Worker.d.ts.map index 7af6162173..44e4931cb2 100644 --- a/node/lib/Worker.d.ts.map +++ b/node/lib/Worker.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"Worker.d.ts","sourceRoot":"","sources":["../src/Worker.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAI9D,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAEnE,oBAAY,cAAc,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAEjE,oBAAY,YAAY,GACpB,MAAM,GACN,KAAK,GACL,MAAM,GACN,KAAK,GACL,MAAM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EG;IACG,gBAAgB,IAAI,OAAO,CAAC,mBAAmB,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;IA4B/C;;OAEG;IACG,YAAY,CACjB,EACC,WAAW,EACX,OAAO,EACP,GAAE,aAAkB,GAAG,OAAO,CAAC,MAAM,CAAC;IAiCxC,OAAO,CAAC,UAAU;CAmClB"} \ No newline at end of file +{"version":3,"file":"Worker.d.ts","sourceRoot":"","sources":["../src/Worker.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAI9D,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAEnE,oBAAY,cAAc,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAEjE,oBAAY,YAAY,GACpB,MAAM,GACN,KAAK,GACL,MAAM,GACN,KAAK,GACL,MAAM,GACN,MAAM,GACN,KAAK,GACL,KAAK,GACL,OAAO,GACP,WAAW,GACX,KAAK,GACL,MAAM,GACN,SAAS,CAAA;AAEb,oBAAY,cAAc,GAC1B;IACC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,cAAc,CAAC;IAE1B;;;OAGG;IACH,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IAEzB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;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/Worker.js index 1aa5e85510..43f3d81a74 100644 --- a/node/lib/Worker.js +++ b/node/lib/Worker.js @@ -283,11 +283,13 @@ class Worker extends EnhancedEventEmitter_1.EnhancedEventEmitter { logger.debug('createWebRtcServer()'); if (appData && typeof appData !== 'object') throw new TypeError('if given, appData must be an object'); - const internal = { webRtcServerId: (0, uuid_1.v4)() }; - const reqData = { listenInfos }; - await this.#channel.request('worker.createWebRtcServer', internal, reqData); + const reqData = { + webRtcServerId: (0, uuid_1.v4)(), + listenInfos + }; + await this.#channel.request('worker.createWebRtcServer', {}, reqData); const webRtcServer = new WebRtcServer_1.WebRtcServer({ - internal, + internal: { webRtcServerId: reqData.webRtcServerId }, channel: this.#channel, appData }); @@ -306,11 +308,13 @@ class Worker extends EnhancedEventEmitter_1.EnhancedEventEmitter { throw new TypeError('if given, appData must be an object'); // This may throw. const rtpCapabilities = ortc.generateRouterRtpCapabilities(mediaCodecs); - const internal = { routerId: (0, uuid_1.v4)() }; - await this.#channel.request('worker.createRouter', internal); + const reqData = { routerId: (0, uuid_1.v4)() }; + await this.#channel.request('worker.createRouter', {}, reqData); const data = { rtpCapabilities }; const router = new Router_1.Router({ - internal, + internal: { + routerId: reqData.routerId + }, data, channel: this.#channel, payloadChannel: this.#payloadChannel, diff --git a/node/src/Router.ts b/node/src/Router.ts index 1cba3e350e..bdfc47ff21 100644 --- a/node/src/Router.ts +++ b/node/src/Router.ts @@ -395,14 +395,9 @@ export class Router extends EnhancedEventEmitter }); } - const internal = - { - ...this.#internal, - transportId : uuidv4() - }; - const reqData = { + transportId : uuidv4(), webRtcServerId : webRtcServer ? webRtcServer.id : undefined, listenIps, port, @@ -419,12 +414,15 @@ export class Router extends EnhancedEventEmitter }; const data = webRtcServer - ? await this.#channel.request('router.createWebRtcTransportWithServer', internal, reqData) - : await this.#channel.request('router.createWebRtcTransport', internal, reqData); + ? await this.#channel.request('router.createWebRtcTransportWithServer', this.#internal, reqData) + : await this.#channel.request('router.createWebRtcTransport', this.#internal, reqData); const transport = new WebRtcTransport( { - internal, + internal : { + ...this.#internal, + transportId : reqData.transportId + }, data, channel : this.#channel, payloadChannel : this.#payloadChannel, @@ -502,8 +500,8 @@ export class Router extends EnhancedEventEmitter throw new TypeError('wrong listenIp'); } - const internal = { ...this.#internal, transportId: uuidv4() }; const reqData = { + transportId : uuidv4(), listenIp, port, rtcpMux, @@ -518,11 +516,14 @@ export class Router extends EnhancedEventEmitter }; const data = - await this.#channel.request('router.createPlainTransport', internal, reqData); + await this.#channel.request('router.createPlainTransport', this.#internal, reqData); const transport = new PlainTransport( { - internal, + internal : { + ...this.#internal, + transportId : reqData.transportId + }, data, channel : this.#channel, payloadChannel : this.#payloadChannel, @@ -595,8 +596,8 @@ export class Router extends EnhancedEventEmitter throw new TypeError('wrong listenIp'); } - const internal = { ...this.#internal, transportId: uuidv4() }; const reqData = { + transportId : uuidv4(), listenIp, port, enableSctp, @@ -609,11 +610,14 @@ export class Router extends EnhancedEventEmitter }; const data = - await this.#channel.request('router.createPipeTransport', internal, reqData); + await this.#channel.request('router.createPipeTransport', this.#internal, reqData); const transport = new PipeTransport( { - internal, + internal : { + ...this.#internal, + transportId : reqData.transportId + }, data, channel : this.#channel, payloadChannel : this.#payloadChannel, @@ -660,15 +664,21 @@ export class Router extends EnhancedEventEmitter { logger.debug('createDirectTransport()'); - const internal = { ...this.#internal, transportId: uuidv4() }; - const reqData = { direct: true, maxMessageSize }; + const reqData = { + transportId : uuidv4(), + direct : true, + maxMessageSize + }; const data = - await this.#channel.request('router.createDirectTransport', internal, reqData); + await this.#channel.request('router.createDirectTransport', this.#internal, reqData); const transport = new DirectTransport( { - internal, + internal : { + ...this.#internal, + transportId : reqData.transportId + }, data, channel : this.#channel, payloadChannel : this.#payloadChannel, @@ -1004,14 +1014,19 @@ export class Router extends EnhancedEventEmitter if (appData && typeof appData !== 'object') throw new TypeError('if given, appData must be an object'); - const internal = { ...this.#internal, rtpObserverId: uuidv4() }; - const reqData = { interval }; + const reqData = { + rtpObserverId : uuidv4(), + interval + }; - await this.#channel.request('router.createActiveSpeakerObserver', internal, reqData); + await this.#channel.request('router.createActiveSpeakerObserver', this.#internal, reqData); const activeSpeakerObserver = new ActiveSpeakerObserver( { - internal, + internal : { + ...this.#internal, + rtpObserverId : reqData.rtpObserverId + }, channel : this.#channel, payloadChannel : this.#payloadChannel, appData, @@ -1049,14 +1064,21 @@ export class Router extends EnhancedEventEmitter if (appData && typeof appData !== 'object') throw new TypeError('if given, appData must be an object'); - const internal = { ...this.#internal, rtpObserverId: uuidv4() }; - const reqData = { maxEntries, threshold, interval }; + const reqData = { + rtpObserverId : uuidv4(), + maxEntries, + threshold, + interval + }; - await this.#channel.request('router.createAudioLevelObserver', internal, reqData); + await this.#channel.request('router.createAudioLevelObserver', this.#internal, reqData); const audioLevelObserver = new AudioLevelObserver( { - internal, + internal : { + ...this.#internal, + rtpObserverId : reqData.rtpObserverId + }, channel : this.#channel, payloadChannel : this.#payloadChannel, appData, diff --git a/node/src/Worker.ts b/node/src/Worker.ts index 2d92c91e22..4ae76b93c4 100644 --- a/node/src/Worker.ts +++ b/node/src/Worker.ts @@ -593,15 +593,17 @@ export class Worker extends EnhancedEventEmitter if (appData && typeof appData !== 'object') throw new TypeError('if given, appData must be an object'); - const internal = { webRtcServerId: uuidv4() }; - const reqData = { listenInfos }; + const reqData = { + webRtcServerId : uuidv4(), + listenInfos + }; - await this.#channel.request('worker.createWebRtcServer', internal, reqData); + await this.#channel.request('worker.createWebRtcServer', {}, reqData); const webRtcServer = new WebRtcServer( { - internal, - channel : this.#channel, + internal : { webRtcServerId: reqData.webRtcServerId }, + channel : this.#channel, appData }); @@ -631,14 +633,16 @@ export class Worker extends EnhancedEventEmitter // This may throw. 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', {}, reqData); const data = { rtpCapabilities }; const router = new Router( { - internal, + internal : { + routerId : reqData.routerId + }, data, channel : this.#channel, payloadChannel : this.#payloadChannel, diff --git a/rust/src/messages.rs b/rust/src/messages.rs index eb5ad5269d..9e34e950d7 100644 --- a/rust/src/messages.rs +++ b/rust/src/messages.rs @@ -200,13 +200,14 @@ request_response!( #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] pub(crate) struct WorkerCreateWebRtcServerData { + #[serde(rename = "webRtcServerId")] + pub(crate) webrtc_server_id: WebRtcServerId, pub(crate) listen_infos: WebRtcServerListenInfos, } request_response!( "worker.createWebRtcServer", WorkerCreateWebRtcServerRequest { - internal: WebRtcServerInternal, data: WorkerCreateWebRtcServerData, }, ); @@ -228,10 +229,16 @@ request_response!( WebRtcServerDump, ); +#[derive(Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub(crate) struct WorkerCreateRouterRequestData { + pub(crate) router_id: RouterId, +} + request_response!( "worker.createRouter", WorkerCreateRouterRequest { - internal: RouterInternal, + data: WorkerCreateRouterRequestData, }, ); @@ -255,13 +262,18 @@ request_response!( #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] pub(crate) struct RouterCreateDirectTransportData { + pub(crate) transport_id: TransportId, pub(crate) direct: bool, pub(crate) max_message_size: usize, } impl RouterCreateDirectTransportData { - pub(crate) fn from_options(direct_transport_options: &DirectTransportOptions) -> Self { + pub(crate) fn from_options( + transport_id: TransportId, + direct_transport_options: &DirectTransportOptions, + ) -> Self { Self { + transport_id, direct: true, max_message_size: direct_transport_options.max_message_size, } @@ -271,7 +283,7 @@ impl RouterCreateDirectTransportData { request_response!( "router.createDirectTransport", RouterCreateDirectTransportRequest { - internal: TransportInternal, + internal: RouterInternal, data: RouterCreateDirectTransportData, }, RouterCreateDirectTransportResponse {}, @@ -295,6 +307,7 @@ enum RouterCreateWebrtcTransportListen { #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] pub(crate) struct RouterCreateWebrtcTransportData { + transport_id: TransportId, #[serde(flatten)] listen: RouterCreateWebrtcTransportListen, enable_udp: bool, @@ -310,8 +323,12 @@ pub(crate) struct RouterCreateWebrtcTransportData { } impl RouterCreateWebrtcTransportData { - pub(crate) fn from_options(webrtc_transport_options: &WebRtcTransportOptions) -> Self { + pub(crate) fn from_options( + transport_id: TransportId, + webrtc_transport_options: &WebRtcTransportOptions, + ) -> Self { Self { + transport_id, listen: match &webrtc_transport_options.listen { WebRtcTransportListen::Individual { listen_ips, port } => { RouterCreateWebrtcTransportListen::Individual { @@ -342,7 +359,7 @@ impl RouterCreateWebrtcTransportData { #[derive(Debug, Serialize)] pub(crate) struct RouterCreateWebrtcTransportRequest { - pub(crate) internal: TransportInternal, + pub(crate) internal: RouterInternal, pub(crate) data: RouterCreateWebrtcTransportData, } @@ -377,6 +394,7 @@ impl Request for RouterCreateWebrtcTransportRequest { #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] pub(crate) struct RouterCreatePlainTransportData { + transport_id: TransportId, listen_ip: ListenIp, #[serde(skip_serializing_if = "Option::is_none")] port: Option, @@ -392,8 +410,12 @@ pub(crate) struct RouterCreatePlainTransportData { } impl RouterCreatePlainTransportData { - pub(crate) fn from_options(plain_transport_options: &PlainTransportOptions) -> Self { + pub(crate) fn from_options( + transport_id: TransportId, + plain_transport_options: &PlainTransportOptions, + ) -> Self { Self { + transport_id, listen_ip: plain_transport_options.listen_ip, port: plain_transport_options.port, rtcp_mux: plain_transport_options.rtcp_mux, @@ -412,7 +434,7 @@ impl RouterCreatePlainTransportData { request_response!( "router.createPlainTransport", RouterCreatePlainTransportRequest { - internal: TransportInternal, + internal: RouterInternal, data: RouterCreatePlainTransportData, }, PlainTransportData { @@ -430,6 +452,7 @@ request_response!( #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] pub(crate) struct RouterCreatePipeTransportData { + transport_id: TransportId, listen_ip: ListenIp, #[serde(skip_serializing_if = "Option::is_none")] port: Option, @@ -443,8 +466,12 @@ pub(crate) struct RouterCreatePipeTransportData { } impl RouterCreatePipeTransportData { - pub(crate) fn from_options(pipe_transport_options: &PipeTransportOptions) -> Self { + pub(crate) fn from_options( + transport_id: TransportId, + pipe_transport_options: &PipeTransportOptions, + ) -> Self { Self { + transport_id, listen_ip: pipe_transport_options.listen_ip, port: pipe_transport_options.port, enable_sctp: pipe_transport_options.enable_sctp, @@ -461,7 +488,7 @@ impl RouterCreatePipeTransportData { request_response!( "router.createPipeTransport", RouterCreatePipeTransportRequest { - internal: TransportInternal, + internal: RouterInternal, data: RouterCreatePipeTransportData, }, PipeTransportData { @@ -476,14 +503,19 @@ request_response!( #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] pub(crate) struct RouterCreateAudioLevelObserverData { + pub(crate) rtp_observer_id: RtpObserverId, pub(crate) max_entries: NonZeroU16, pub(crate) threshold: i8, pub(crate) interval: u16, } impl RouterCreateAudioLevelObserverData { - pub(crate) fn from_options(audio_level_observer_options: &AudioLevelObserverOptions) -> Self { + pub(crate) fn from_options( + rtp_observer_id: RtpObserverId, + audio_level_observer_options: &AudioLevelObserverOptions, + ) -> Self { Self { + rtp_observer_id, max_entries: audio_level_observer_options.max_entries, threshold: audio_level_observer_options.threshold, interval: audio_level_observer_options.interval, @@ -494,7 +526,7 @@ impl RouterCreateAudioLevelObserverData { request_response!( "router.createAudioLevelObserver", RouterCreateAudioLevelObserverRequest { - internal: RtpObserverInternal, + internal: RouterInternal, data: RouterCreateAudioLevelObserverData, }, ); @@ -502,14 +534,17 @@ request_response!( #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] pub(crate) struct RouterCreateActiveSpeakerObserverData { + pub(crate) rtp_observer_id: RtpObserverId, pub(crate) interval: u16, } impl RouterCreateActiveSpeakerObserverData { pub(crate) fn from_options( + rtp_observer_id: RtpObserverId, active_speaker_observer_options: &ActiveSpeakerObserverOptions, ) -> Self { Self { + rtp_observer_id, interval: active_speaker_observer_options.interval, } } @@ -518,7 +553,7 @@ impl RouterCreateActiveSpeakerObserverData { request_response!( "router.createActiveSpeakerObserver", RouterCreateActiveSpeakerObserverRequest { - internal: RtpObserverInternal, + internal: RouterInternal, data: RouterCreateActiveSpeakerObserverData, }, ); diff --git a/rust/src/router.rs b/rust/src/router.rs index 2e4bb1cea9..da86995d48 100644 --- a/rust/src/router.rs +++ b/rust/src/router.rs @@ -37,8 +37,7 @@ use crate::messages::{ RouterCreateDirectTransportRequest, RouterCreatePipeTransportData, RouterCreatePipeTransportRequest, RouterCreatePlainTransportData, RouterCreatePlainTransportRequest, RouterCreateWebrtcTransportData, - RouterCreateWebrtcTransportRequest, RouterDumpRequest, RouterInternal, RtpObserverInternal, - TransportInternal, + RouterCreateWebrtcTransportRequest, RouterDumpRequest, RouterInternal, }; use crate::pipe_transport::{ PipeTransport, PipeTransportOptions, PipeTransportRemoteParameters, WeakPipeTransport, @@ -570,11 +569,13 @@ impl Router { self.inner .channel .request(RouterCreateDirectTransportRequest { - internal: TransportInternal { + internal: RouterInternal { router_id: self.inner.id, - transport_id, }, - data: RouterCreateDirectTransportData::from_options(&direct_transport_options), + data: RouterCreateDirectTransportData::from_options( + transport_id, + &direct_transport_options, + ), }) .await?; @@ -631,11 +632,13 @@ impl Router { .inner .channel .request(RouterCreateWebrtcTransportRequest { - internal: TransportInternal { + internal: RouterInternal { router_id: self.inner.id, - transport_id, }, - data: RouterCreateWebrtcTransportData::from_options(&webrtc_transport_options), + data: RouterCreateWebrtcTransportData::from_options( + transport_id, + &webrtc_transport_options, + ), }) .await?; @@ -695,11 +698,13 @@ impl Router { .inner .channel .request(RouterCreatePipeTransportRequest { - internal: TransportInternal { + internal: RouterInternal { router_id: self.inner.id, - transport_id, }, - data: RouterCreatePipeTransportData::from_options(&pipe_transport_options), + data: RouterCreatePipeTransportData::from_options( + transport_id, + &pipe_transport_options, + ), }) .await?; @@ -755,11 +760,13 @@ impl Router { .inner .channel .request(RouterCreatePlainTransportRequest { - internal: TransportInternal { + internal: RouterInternal { router_id: self.inner.id, - transport_id, }, - data: RouterCreatePlainTransportData::from_options(&plain_transport_options), + data: RouterCreatePlainTransportData::from_options( + transport_id, + &plain_transport_options, + ), }) .await?; @@ -820,11 +827,11 @@ impl Router { self.inner .channel .request(RouterCreateAudioLevelObserverRequest { - internal: RtpObserverInternal { + internal: RouterInternal { router_id: self.inner.id, - rtp_observer_id, }, data: RouterCreateAudioLevelObserverData::from_options( + rtp_observer_id, &audio_level_observer_options, ), }) @@ -880,11 +887,11 @@ impl Router { self.inner .channel .request(RouterCreateActiveSpeakerObserverRequest { - internal: RtpObserverInternal { + internal: RouterInternal { router_id: self.inner.id, - rtp_observer_id, }, data: RouterCreateActiveSpeakerObserverData::from_options( + rtp_observer_id, &active_speaker_observer_options, ), }) diff --git a/rust/src/worker.rs b/rust/src/worker.rs index 9257209725..21f4843324 100644 --- a/rust/src/worker.rs +++ b/rust/src/worker.rs @@ -8,7 +8,7 @@ mod utils; use crate::data_structures::AppData; use crate::messages::{ - RouterInternal, WebRtcServerInternal, WorkerCloseRequest, WorkerCreateRouterRequest, + WorkerCloseRequest, WorkerCreateRouterRequest, WorkerCreateRouterRequestData, WorkerCreateWebRtcServerData, WorkerCreateWebRtcServerRequest, WorkerDumpRequest, WorkerUpdateSettingsRequest, }; @@ -628,7 +628,6 @@ impl Worker { } = webrtc_server_options; let webrtc_server_id = WebRtcServerId::new(); - let internal = WebRtcServerInternal { webrtc_server_id }; let _buffer_guard = self .inner @@ -638,8 +637,10 @@ impl Worker { self.inner .channel .request(WorkerCreateWebRtcServerRequest { - internal, - data: WorkerCreateWebRtcServerData { listen_infos }, + data: WorkerCreateWebRtcServerData { + webrtc_server_id, + listen_infos, + }, }) .await .map_err(CreateWebRtcServerError::Request)?; @@ -678,13 +679,14 @@ impl Worker { .map_err(CreateRouterError::FailedRtpCapabilitiesGeneration)?; let router_id = RouterId::new(); - let internal = RouterInternal { router_id }; let _buffer_guard = self.inner.channel.buffer_messages_for(router_id.into()); self.inner .channel - .request(WorkerCreateRouterRequest { internal }) + .request(WorkerCreateRouterRequest { + data: WorkerCreateRouterRequestData { router_id }, + }) .await .map_err(CreateRouterError::Request)?; diff --git a/worker/include/RTC/Router.hpp b/worker/include/RTC/Router.hpp index 50e808fd97..d136b607ce 100644 --- a/worker/include/RTC/Router.hpp +++ b/worker/include/RTC/Router.hpp @@ -69,9 +69,9 @@ namespace RTC void HandleNotification(PayloadChannel::Notification* notification) override; private: - void SetNewTransportIdFromInternal(json& internal, std::string& transportId) const; + void SetNewTransportIdFromData(json& data, std::string& transportId) const; RTC::Transport* GetTransportFromInternal(json& internal) const; - void SetNewRtpObserverIdFromInternal(json& internal, std::string& rtpObserverId) const; + void SetNewRtpObserverIdFromData(json& data, std::string& rtpObserverId) const; RTC::RtpObserver* GetRtpObserverFromInternal(json& internal) const; RTC::Producer* GetProducerFromData(json& data) const; diff --git a/worker/include/Worker.hpp b/worker/include/Worker.hpp index 9a29d6313a..0f49bcdbcf 100644 --- a/worker/include/Worker.hpp +++ b/worker/include/Worker.hpp @@ -29,9 +29,9 @@ class Worker : public Channel::ChannelSocket::Listener, void Close(); void FillJson(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; - void SetNewRouterIdFromInternal(json& internal, std::string& routerId) const; + void SetNewRouterIdFromData(json& data, std::string& routerId) const; RTC::Router* GetRouterFromInternal(json& internal) const; /* Methods inherited from Channel::ChannelSocket::RequestHandler. */ diff --git a/worker/src/RTC/Router.cpp b/worker/src/RTC/Router.cpp index 97463e7728..119eff6038 100644 --- a/worker/src/RTC/Router.cpp +++ b/worker/src/RTC/Router.cpp @@ -183,7 +183,7 @@ namespace RTC std::string transportId; // This may throw. - SetNewTransportIdFromInternal(request->internal, transportId); + SetNewTransportIdFromData(request->data, transportId); // This may throw. auto* webRtcTransport = new RTC::WebRtcTransport(transportId, this, request->data); @@ -211,7 +211,7 @@ namespace RTC std::string transportId; // This may throw. - SetNewTransportIdFromInternal(request->internal, transportId); + SetNewTransportIdFromData(request->data, transportId); auto jsonWebRtcServerIdIt = request->data.find("webRtcServerId"); @@ -302,7 +302,7 @@ namespace RTC std::string transportId; // This may throw - SetNewTransportIdFromInternal(request->internal, transportId); + SetNewTransportIdFromData(request->data, transportId); auto* plainTransport = new RTC::PlainTransport(transportId, this, request->data); @@ -329,7 +329,7 @@ namespace RTC std::string transportId; // This may throw - SetNewTransportIdFromInternal(request->internal, transportId); + SetNewTransportIdFromData(request->data, transportId); auto* pipeTransport = new RTC::PipeTransport(transportId, this, request->data); @@ -356,7 +356,7 @@ namespace RTC std::string transportId; // This may throw - SetNewTransportIdFromInternal(request->internal, transportId); + SetNewTransportIdFromData(request->data, transportId); auto* directTransport = new RTC::DirectTransport(transportId, this, request->data); @@ -383,7 +383,7 @@ namespace RTC std::string rtpObserverId; // This may throw. - SetNewRtpObserverIdFromInternal(request->internal, rtpObserverId); + SetNewRtpObserverIdFromData(request->data, rtpObserverId); auto* activeSpeakerObserver = new RTC::ActiveSpeakerObserver(rtpObserverId, this, request->data); @@ -405,7 +405,7 @@ namespace RTC std::string rtpObserverId; // This may throw - SetNewRtpObserverIdFromInternal(request->internal, rtpObserverId); + SetNewRtpObserverIdFromData(request->data, rtpObserverId); auto* audioLevelObserver = new RTC::AudioLevelObserver(rtpObserverId, this, request->data); @@ -521,13 +521,13 @@ namespace RTC transport->HandleNotification(notification); } - void Router::SetNewTransportIdFromInternal(json& internal, std::string& transportId) const + void Router::SetNewTransportIdFromData(json& data, std::string& transportId) const { MS_TRACE(); - auto jsonTransportIdIt = internal.find("transportId"); + auto jsonTransportIdIt = data.find("transportId"); - if (jsonTransportIdIt == internal.end() || !jsonTransportIdIt->is_string()) + if (jsonTransportIdIt == data.end() || !jsonTransportIdIt->is_string()) { MS_THROW_TYPE_ERROR("missing transportId"); } @@ -561,13 +561,13 @@ namespace RTC return transport; } - void Router::SetNewRtpObserverIdFromInternal(json& internal, std::string& rtpObserverId) const + void Router::SetNewRtpObserverIdFromData(json& data, std::string& rtpObserverId) const { MS_TRACE(); - auto jsonRtpObserverIdIt = internal.find("rtpObserverId"); + auto jsonRtpObserverIdIt = data.find("rtpObserverId"); - if (jsonRtpObserverIdIt == internal.end() || !jsonRtpObserverIdIt->is_string()) + if (jsonRtpObserverIdIt == data.end() || !jsonRtpObserverIdIt->is_string()) { MS_THROW_TYPE_ERROR("missing rtpObserverId"); } diff --git a/worker/src/Worker.cpp b/worker/src/Worker.cpp index 71e2938abf..0acf4a16b5 100644 --- a/worker/src/Worker.cpp +++ b/worker/src/Worker.cpp @@ -190,14 +190,14 @@ void Worker::FillJsonResourceUsage(json& jsonObject) const 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(); - auto jsonWebRtcServerIdIt = internal.find("webRtcServerId"); + auto jsonWebRtcServerIdIt = data.find("webRtcServerId"); - if (jsonWebRtcServerIdIt == internal.end() || !jsonWebRtcServerIdIt->is_string()) - MS_THROW_ERROR("missing internal.webRtcServerId"); + if (jsonWebRtcServerIdIt == data.end() || !jsonWebRtcServerIdIt->is_string()) + MS_THROW_ERROR("missing data.webRtcServerId"); webRtcServerId.assign(jsonWebRtcServerIdIt->get()); @@ -224,14 +224,14 @@ RTC::WebRtcServer* Worker::GetWebRtcServerFromInternal(json& internal) const return webRtcServer; } -void Worker::SetNewRouterIdFromInternal(json& internal, std::string& routerId) const +void Worker::SetNewRouterIdFromData(json& data, std::string& routerId) const { MS_TRACE(); - auto jsonRouterIdIt = internal.find("routerId"); + auto jsonRouterIdIt = data.find("routerId"); - if (jsonRouterIdIt == internal.end() || !jsonRouterIdIt->is_string()) - MS_THROW_ERROR("missing internal.routerId"); + if (jsonRouterIdIt == data.end() || !jsonRouterIdIt->is_string()) + MS_THROW_ERROR("missing data.routerId"); routerId.assign(jsonRouterIdIt->get()); @@ -314,7 +314,7 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) { std::string webRtcServerId; - SetNewWebRtcServerIdFromInternal(request->internal, webRtcServerId); + SetNewWebRtcServerIdFromData(request->data, webRtcServerId); auto* webRtcServer = new RTC::WebRtcServer(webRtcServerId, request->data); @@ -386,7 +386,7 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) try { - SetNewRouterIdFromInternal(request->internal, routerId); + SetNewRouterIdFromData(request->data, routerId); } catch (const MediaSoupError& error) { From 2abf54c3e3a960b858cd462c495201b8016381ab Mon Sep 17 00:00:00 2001 From: Nazar Mokrynskyi Date: Mon, 25 Jul 2022 01:55:30 +0300 Subject: [PATCH 4/5] Replace hierarchical request and notification handling with simple queries into maps, replace `.internal` with `.handlerId` --- node/lib/Channel.d.ts | 2 +- node/lib/Channel.d.ts.map | 2 +- node/lib/Channel.js | 4 +- node/lib/Consumer.d.ts.map | 2 +- node/lib/Consumer.js | 21 +- node/lib/DataConsumer.d.ts.map | 2 +- node/lib/DataConsumer.js | 13 +- node/lib/DataProducer.d.ts.map | 2 +- node/lib/DataProducer.js | 9 +- node/lib/DirectTransport.js | 4 +- node/lib/PayloadChannel.d.ts | 4 +- node/lib/PayloadChannel.d.ts.map | 2 +- node/lib/PayloadChannel.js | 10 +- node/lib/PipeTransport.d.ts.map | 2 +- node/lib/PipeTransport.js | 13 +- node/lib/PlainTransport.js | 4 +- node/lib/Producer.d.ts.map | 2 +- node/lib/Producer.js | 15 +- node/lib/Router.d.ts.map | 2 +- node/lib/Router.js | 19 +- node/lib/RtpObserver.d.ts.map | 2 +- node/lib/RtpObserver.js | 11 +- node/lib/Transport.d.ts.map | 2 +- node/lib/Transport.js | 57 +++-- node/lib/WebRtcServer.d.ts.map | 2 +- node/lib/WebRtcServer.js | 5 +- node/lib/WebRtcTransport.js | 6 +- node/lib/Worker.js | 4 +- node/src/Channel.ts | 4 +- node/src/Consumer.ts | 22 +- node/src/DataConsumer.ts | 14 +- node/src/DataProducer.ts | 10 +- node/src/DirectTransport.ts | 4 +- node/src/PayloadChannel.ts | 10 +- node/src/PipeTransport.ts | 14 +- node/src/PlainTransport.ts | 4 +- node/src/Producer.ts | 16 +- node/src/Router.ts | 74 +++--- node/src/RtpObserver.ts | 12 +- node/src/Transport.ts | 62 +++-- node/src/WebRtcServer.ts | 6 +- node/src/WebRtcTransport.ts | 6 +- node/src/Worker.ts | 4 +- rust/src/messages.rs | 236 +++++++++--------- rust/src/router.rs | 34 +-- rust/src/router/active_speaker_observer.rs | 21 +- rust/src/router/audio_level_observer.rs | 21 +- rust/src/router/consumer.rs | 35 +-- rust/src/router/data_consumer.rs | 31 +-- rust/src/router/data_producer.rs | 27 +- rust/src/router/direct_transport.rs | 17 +- rust/src/router/pipe_transport.rs | 17 +- rust/src/router/plain_transport.rs | 17 +- rust/src/router/producer.rs | 33 +-- rust/src/router/transport.rs | 63 ++--- rust/src/router/webrtc_transport.rs | 19 +- rust/src/webrtc_server.rs | 10 +- worker/include/Channel/ChannelRequest.hpp | 2 +- .../include/PayloadChannel/Notification.hpp | 2 +- .../PayloadChannel/PayloadChannelRequest.hpp | 2 +- worker/include/RTC/Router.hpp | 17 +- worker/include/RTC/Transport.hpp | 16 +- worker/include/Worker.hpp | 4 +- worker/src/Channel/ChannelRequest.cpp | 8 +- worker/src/PayloadChannel/Notification.cpp | 8 +- .../PayloadChannel/PayloadChannelRequest.cpp | 8 +- worker/src/RTC/DirectTransport.cpp | 20 -- worker/src/RTC/Router.cpp | 78 +----- worker/src/RTC/Transport.cpp | 129 +++------- worker/src/Worker.cpp | 67 ++--- 70 files changed, 602 insertions(+), 825 deletions(-) diff --git a/node/lib/Channel.d.ts b/node/lib/Channel.d.ts index 75de000502..fef3fad0a5 100644 --- a/node/lib/Channel.d.ts +++ b/node/lib/Channel.d.ts @@ -16,7 +16,7 @@ export declare class Channel extends EnhancedEventEmitter { /** * @private */ - request(method: string, internal?: object, data?: any): Promise; + request(method: string, handlerId?: string, data?: any): Promise; private processMessage; } //# sourceMappingURL=Channel.d.ts.map \ No newline at end of file diff --git a/node/lib/Channel.d.ts.map b/node/lib/Channel.d.ts.map index 6199188398..f5493d614f 100644 --- a/node/lib/Channel.d.ts.map +++ b/node/lib/Channel.d.ts.map @@ -1 +1 @@ -{"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"} \ 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,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 diff --git a/node/lib/Channel.js b/node/lib/Channel.js index 56deda13c3..f6b3fe81db 100644 --- a/node/lib/Channel.js +++ b/node/lib/Channel.js @@ -138,13 +138,13 @@ class Channel extends EnhancedEventEmitter_1.EnhancedEventEmitter { /** * @private */ - async request(method, internal, data) { + async request(method, handlerId, data) { this.#nextId < 4294967295 ? ++this.#nextId : (this.#nextId = 1); const id = this.#nextId; logger.debug('request() [method:%s, id:%s]', method, id); if (this.#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); if (Buffer.byteLength(payload) > MESSAGE_MAX_LEN) throw new Error('Channel request too big'); diff --git a/node/lib/Consumer.d.ts.map b/node/lib/Consumer.d.ts.map index 88f54a8092..fffddce864 100644 --- a/node/lib/Consumer.d.ts.map +++ b/node/lib/Consumer.d.ts.map @@ -1 +1 @@ -{"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,CAAC;AAEzB,oBAAY,eAAe,GAC3B;IACC;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,eAAe,EAAE,eAAe,CAAC;IAEjC;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,eAAe,CAAC,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,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 diff --git a/node/lib/Consumer.js b/node/lib/Consumer.js index e1496f1a5a..e3194e0f2b 100644 --- a/node/lib/Consumer.js +++ b/node/lib/Consumer.js @@ -156,7 +156,8 @@ class Consumer extends EnhancedEventEmitter_1.EnhancedEventEmitter { // Remove notification subscriptions. this.#channel.removeAllListeners(this.#internal.consumerId); this.#payloadChannel.removeAllListeners(this.#internal.consumerId); - this.#channel.request('transport.closeConsumer', this.#internal) + const reqData = { consumerId: this.#internal.consumerId }; + this.#channel.request('transport.closeConsumer', this.#internal.transportId, reqData) .catch(() => { }); this.emit('@close'); // Emit observer event. @@ -184,14 +185,14 @@ class Consumer extends EnhancedEventEmitter_1.EnhancedEventEmitter { */ async dump() { logger.debug('dump()'); - return this.#channel.request('consumer.dump', this.#internal); + return this.#channel.request('consumer.dump', this.#internal.consumerId); } /** * Get Consumer stats. */ async getStats() { logger.debug('getStats()'); - return this.#channel.request('consumer.getStats', this.#internal); + return this.#channel.request('consumer.getStats', this.#internal.consumerId); } /** * Pause the Consumer. @@ -199,7 +200,7 @@ class Consumer extends EnhancedEventEmitter_1.EnhancedEventEmitter { async pause() { logger.debug('pause()'); 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; // Emit observer event. if (!wasPaused) @@ -211,7 +212,7 @@ class Consumer extends EnhancedEventEmitter_1.EnhancedEventEmitter { async resume() { logger.debug('resume()'); 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; // Emit observer event. if (wasPaused && !this.#producerPaused) @@ -223,7 +224,7 @@ class Consumer extends EnhancedEventEmitter_1.EnhancedEventEmitter { async setPreferredLayers({ spatialLayer, temporalLayer }) { logger.debug('setPreferredLayers()'); 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; } /** @@ -232,7 +233,7 @@ class Consumer extends EnhancedEventEmitter_1.EnhancedEventEmitter { async setPriority(priority) { logger.debug('setPriority()'); 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; } /** @@ -241,7 +242,7 @@ class Consumer extends EnhancedEventEmitter_1.EnhancedEventEmitter { async unsetPriority() { logger.debug('unsetPriority()'); 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; } /** @@ -249,7 +250,7 @@ class Consumer extends EnhancedEventEmitter_1.EnhancedEventEmitter { */ async requestKeyFrame() { logger.debug('requestKeyFrame()'); - await this.#channel.request('consumer.requestKeyFrame', this.#internal); + await this.#channel.request('consumer.requestKeyFrame', this.#internal.consumerId); } /** * Enable 'trace' event. @@ -257,7 +258,7 @@ class Consumer extends EnhancedEventEmitter_1.EnhancedEventEmitter { async enableTraceEvent(types = []) { logger.debug('enableTraceEvent()'); const reqData = { types }; - await this.#channel.request('consumer.enableTraceEvent', this.#internal, reqData); + await this.#channel.request('consumer.enableTraceEvent', this.#internal.consumerId, reqData); } handleWorkerNotifications() { this.#channel.on(this.#internal.consumerId, (event, data) => { diff --git a/node/lib/DataConsumer.d.ts.map b/node/lib/DataConsumer.d.ts.map index 8b0a4ee035..529b26885f 100644 --- a/node/lib/DataConsumer.d.ts.map +++ b/node/lib/DataConsumer.d.ts.map @@ -1 +1 @@ -{"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,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC,CAAA;AAED,oBAAY,gBAAgB,GAC5B;IACC,IAAI,EAAE,MAAM,CAAC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AI,EAAE,IAAI,MAAM,CAGf;IAED;;OAEG;IACH,IAAI,cAAc,IAAI,MAAM,CAG3B;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,OAAO,CAGpB;IAED;;OAEG;IACH,IAAI,IAAI,IAAI,gBAAgB,CAG3B;IAED;;OAEG;IACH,IAAI,oBAAoB,IAAI,oBAAoB,GAAG,SAAS,CAG3D;IAED;;OAEG;IACH,IAAI,KAAK,IAAI,MAAM,CAGlB;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,MAAM,CAGrB;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;;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,gBAAgB,EAAE,CAAC;IAO7C;;OAEG;IACG,6BAA6B,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAUrE;;OAEG;IACG,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA0ClE;;OAEG;IACG,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC;IAU1C,OAAO,CAAC,yBAAyB;CA2EjC"} \ No newline at end of file diff --git a/node/lib/DataConsumer.js b/node/lib/DataConsumer.js index 25f0963312..b299cb4aaf 100644 --- a/node/lib/DataConsumer.js +++ b/node/lib/DataConsumer.js @@ -103,7 +103,8 @@ class DataConsumer extends EnhancedEventEmitter_1.EnhancedEventEmitter { // Remove notification subscriptions. this.#channel.removeAllListeners(this.#internal.dataConsumerId); this.#payloadChannel.removeAllListeners(this.#internal.dataConsumerId); - this.#channel.request('transport.closeDataConsumer', this.#internal) + const reqData = { dataConsumerId: this.#internal.dataConsumerId }; + this.#channel.request('transport.closeDataConsumer', this.#internal.transportId, reqData) .catch(() => { }); this.emit('@close'); // Emit observer event. @@ -131,14 +132,14 @@ class DataConsumer extends EnhancedEventEmitter_1.EnhancedEventEmitter { */ async dump() { logger.debug('dump()'); - return this.#channel.request('dataConsumer.dump', this.#internal); + return this.#channel.request('dataConsumer.dump', this.#internal.dataConsumerId); } /** * Get DataConsumer stats. */ async 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. @@ -146,7 +147,7 @@ class DataConsumer extends EnhancedEventEmitter_1.EnhancedEventEmitter { async setBufferedAmountLowThreshold(threshold) { logger.debug('setBufferedAmountLowThreshold() [threshold:%s]', 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. @@ -181,14 +182,14 @@ class DataConsumer extends EnhancedEventEmitter_1.EnhancedEventEmitter { else if (ppid === 57) message = Buffer.alloc(1); 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. */ async 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; } handleWorkerNotifications() { diff --git a/node/lib/DataProducer.d.ts.map b/node/lib/DataProducer.d.ts.map index c924038190..f68c0bda96 100644 --- a/node/lib/DataProducer.d.ts.map +++ b/node/lib/DataProducer.d.ts.map @@ -1 +1 @@ -{"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,OAAO,CAAC,CAAC;CAClC,CAAA;AAED,oBAAY,gBAAgB,GAC5B;IACC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;CACtB,CAAA;AAED;;GAEG;AACH,oBAAY,gBAAgB,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEjD,oBAAY,kBAAkB,GAC9B;IACC,cAAc,EAAE,EAAE,CAAC;IAEnB,QAAQ,EAAE,EAAE,CAAC;CACb,CAAA;AAED,oBAAY,0BAA0B,GACtC;IACC,KAAK,EAAE,EAAE,CAAC;CACV,CAAA;AAID,qBAAa,YAAa,SAAQ,oBAAoB,CAAC,kBAAkB,CAAC;;IAkCzE;;OAEG;gBAEF,EACC,QAAQ,EACR,IAAI,EACJ,OAAO,EACP,cAAc,EACd,OAAO,EACP,EACD;QACC,QAAQ,EAAE,GAAG,CAAC;QACd,IAAI,EAAE,GAAG,CAAC;QACV,OAAO,EAAE,OAAO,CAAC;QACjB,cAAc,EAAE,cAAc,CAAC;QAC/B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAClC;IAgBF;;OAEG;IACH,IAAI,EAAE,IAAI,MAAM,CAGf;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,OAAO,CAGpB;IAED;;OAEG;IACH,IAAI,IAAI,IAAI,gBAAgB,CAG3B;IAED;;OAEG;IACH,IAAI,oBAAoB,IAAI,oBAAoB,GAAG,SAAS,CAG3D;IAED;;OAEG;IACH,IAAI,KAAK,IAAI,MAAM,CAGlB;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,MAAM,CAGrB;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;;OAEG;IACH,KAAK,IAAI,IAAI;IAsBb;;;;OAIG;IACH,eAAe,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 +{"version":3,"file":"DataProducer.d.ts","sourceRoot":"","sources":["../src/DataProducer.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,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AO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAClC;IAgBF;;OAEG;IACH,IAAI,EAAE,IAAI,MAAM,CAGf;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,OAAO,CAGpB;IAED;;OAEG;IACH,IAAI,IAAI,IAAI,gBAAgB,CAG3B;IAED;;OAEG;IACH,IAAI,oBAAoB,IAAI,oBAAoB,GAAG,SAAS,CAG3D;IAED;;OAEG;IACH,IAAI,KAAK,IAAI,MAAM,CAGlB;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,MAAM,CAGrB;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;;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,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 diff --git a/node/lib/DataProducer.js b/node/lib/DataProducer.js index 30c9dc4b71..92109fa5da 100644 --- a/node/lib/DataProducer.js +++ b/node/lib/DataProducer.js @@ -97,7 +97,8 @@ class DataProducer extends EnhancedEventEmitter_1.EnhancedEventEmitter { // Remove notification subscriptions. this.#channel.removeAllListeners(this.#internal.dataProducerId); this.#payloadChannel.removeAllListeners(this.#internal.dataProducerId); - this.#channel.request('transport.closeDataProducer', this.#internal) + const reqData = { dataProducerId: this.#internal.dataProducerId }; + this.#channel.request('transport.closeDataProducer', this.#internal.transportId, reqData) .catch(() => { }); this.emit('@close'); // Emit observer event. @@ -125,14 +126,14 @@ class DataProducer extends EnhancedEventEmitter_1.EnhancedEventEmitter { */ async dump() { logger.debug('dump()'); - return this.#channel.request('dataProducer.dump', this.#internal); + return this.#channel.request('dataProducer.dump', this.#internal.dataProducerId); } /** * Get DataProducer stats. */ async 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). @@ -167,7 +168,7 @@ class DataProducer extends EnhancedEventEmitter_1.EnhancedEventEmitter { else if (ppid === 57) message = Buffer.alloc(1); const notifData = { ppid }; - this.#payloadChannel.notify('dataProducer.send', this.#internal, notifData, message); + this.#payloadChannel.notify('dataProducer.send', this.#internal.dataProducerId, notifData, message); } handleWorkerNotifications() { // No need to subscribe to any event. diff --git a/node/lib/DirectTransport.js b/node/lib/DirectTransport.js index 26b3145196..79d12e9b26 100644 --- a/node/lib/DirectTransport.js +++ b/node/lib/DirectTransport.js @@ -48,7 +48,7 @@ class DirectTransport extends Transport_1.Transport { */ async 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. @@ -79,7 +79,7 @@ class DirectTransport extends Transport_1.Transport { if (!Buffer.isBuffer(rtcpPacket)) { 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() { this.channel.on(this.internal.transportId, (event, data) => { diff --git a/node/lib/PayloadChannel.d.ts b/node/lib/PayloadChannel.d.ts index fefa932f24..5f1a0b0813 100644 --- a/node/lib/PayloadChannel.d.ts +++ b/node/lib/PayloadChannel.d.ts @@ -16,11 +16,11 @@ export declare class PayloadChannel extends EnhancedEventEmitter { /** * @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 */ - request(method: string, internal: object, data: any, payload: string | Buffer): Promise; + request(method: string, handlerId: string, data: any, payload: string | Buffer): Promise; private processData; } //# sourceMappingURL=PayloadChannel.d.ts.map \ No newline at end of file diff --git a/node/lib/PayloadChannel.d.ts.map b/node/lib/PayloadChannel.d.ts.map index 442422ac16..5b8227fd9d 100644 --- a/node/lib/PayloadChannel.d.ts.map +++ b/node/lib/PayloadChannel.d.ts.map @@ -1 +1 @@ -{"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"} \ 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,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 diff --git a/node/lib/PayloadChannel.js b/node/lib/PayloadChannel.js index 005d7dcc64..e62031701d 100644 --- a/node/lib/PayloadChannel.js +++ b/node/lib/PayloadChannel.js @@ -82,7 +82,7 @@ class PayloadChannel extends EnhancedEventEmitter_1.EnhancedEventEmitter { return; logger.debug('close()'); 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. this.#consumerSocket.removeAllListeners('end'); this.#consumerSocket.removeAllListeners('error'); @@ -105,11 +105,11 @@ class PayloadChannel extends EnhancedEventEmitter_1.EnhancedEventEmitter { /** * @private */ - notify(event, internal, data, payload) { + notify(event, handlerId, data, payload) { logger.debug('notify() [event:%s]', event); if (this.#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) throw new Error('PayloadChannel notification too big'); else if (Buffer.byteLength(payload) > MESSAGE_MAX_LEN) @@ -136,13 +136,13 @@ class PayloadChannel extends EnhancedEventEmitter_1.EnhancedEventEmitter { /** * @private */ - async request(method, internal, data, payload) { + async request(method, handlerId, data, payload) { this.#nextId < 4294967295 ? ++this.#nextId : (this.#nextId = 1); const id = this.#nextId; logger.debug('request() [method:%s, id:%s]', method, id); if (this.#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) throw new Error('Channel request too big'); else if (Buffer.byteLength(payload) > MESSAGE_MAX_LEN) diff --git a/node/lib/PipeTransport.d.ts.map b/node/lib/PipeTransport.d.ts.map index ab271979b9..3dc02a65e7 100644 --- a/node/lib/PipeTransport.d.ts.map +++ b/node/lib/PipeTransport.d.ts.map @@ -1 +1 @@ -{"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,EAAE,cAAc,CAAC;IAEhC;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;;;OAIG;IACH,SAAS,CAA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AC,CAAC;CAC7B,CAAA;AAID,qBAAa,aACZ,SAAQ,SAAS,CAAC,mBAAmB,EAAE,2BAA2B,CAAC;;IAYnE;;OAEG;gBACS,MAAM,EAAE,GAAG;IAoBvB;;OAEG;IACH,IAAI,KAAK,IAAI,cAAc,CAG1B;IAED;;OAEG;IACH,IAAI,cAAc,IAAI,cAAc,GAAG,SAAS,CAG/C;IAED;;OAEG;IACH,IAAI,SAAS,IAAI,SAAS,GAAG,SAAS,CAGrC;IAED;;OAEG;IACH,IAAI,cAAc,IAAI,cAAc,GAAG,SAAS,CAG/C;IAED;;;;OAIG;IACH,KAAK,IAAI,IAAI;IAWb;;;;;OAKG;IACH,YAAY,IAAI,IAAI;IAWpB;;;;OAIG;IACG,QAAQ,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAO9C;;;;OAIG;IACG,OAAO,CACZ,EACC,EAAE,EACF,IAAI,EACJ,cAAc,EACd,EACD;QACC,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,cAAc,CAAC,EAAE,cAAc,CAAC;KAChC,GACC,OAAO,CAAC,IAAI,CAAC;IAahB;;;;OAIG;IACG,OAAO,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,mBAAmB,GAAG,OAAO,CAAC,QAAQ,CAAC;IA4D9E,OAAO,CAAC,yBAAyB;CAuCjC"} \ No newline at end of file +{"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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ransport.js b/node/lib/PipeTransport.js index 38b194d752..197ec8c613 100644 --- a/node/lib/PipeTransport.js +++ b/node/lib/PipeTransport.js @@ -83,7 +83,7 @@ class PipeTransport extends Transport_1.Transport { */ async 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. @@ -93,7 +93,7 @@ class PipeTransport extends Transport_1.Transport { async connect({ ip, port, srtpParameters }) { logger.debug('connect()'); 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. this.#data.tuple = data.tuple; } @@ -113,15 +113,15 @@ class PipeTransport extends Transport_1.Transport { throw Error(`Producer with id "${producerId}" not found`); // This may throw. const rtpParameters = ortc.getPipeConsumerRtpParameters(producer.consumableRtpParameters, this.#data.rtx); - const internal = { ...this.internal, consumerId: (0, uuid_1.v4)() }; const reqData = { + consumerId: (0, uuid_1.v4)(), producerId, kind: producer.kind, rtpParameters, type: 'pipe', 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 = { producerId, kind: producer.kind, @@ -129,7 +129,10 @@ class PipeTransport extends Transport_1.Transport { type: 'pipe' }; const consumer = new Consumer_1.Consumer({ - internal, + internal: { + ...this.internal, + consumerId: reqData.consumerId + }, data, channel: this.channel, payloadChannel: this.payloadChannel, diff --git a/node/lib/PlainTransport.js b/node/lib/PlainTransport.js index ab95481966..3ad3fcf7dd 100644 --- a/node/lib/PlainTransport.js +++ b/node/lib/PlainTransport.js @@ -88,7 +88,7 @@ class PlainTransport extends Transport_1.Transport { */ async 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. @@ -98,7 +98,7 @@ class PlainTransport extends Transport_1.Transport { async connect({ ip, port, rtcpPort, srtpParameters }) { logger.debug('connect()'); 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. if (data.tuple) this.#data.tuple = data.tuple; diff --git a/node/lib/Producer.d.ts.map b/node/lib/Producer.d.ts.map index 4bdd41abfa..752e0d236e 100644 --- a/node/lib/Producer.d.ts.map +++ b/node/lib/Producer.d.ts.map @@ -1 +1 @@ -{"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,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE3D,oBAAY,eAAe,GAC3B;IACC;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,IAAI,EAAE,SAAS,CAAC;IAEhB;;OAEG;IACH,aAAa,EAAE,aAAa,CAAC;IAE7B;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;;OAGG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAE9B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC,CAAA;AAED;;GAEG;AACH,oBAAY,sBAAsB,GAAG,KAAK,GAAG,UAAU,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,CAAC;AAEjF;;GAEG;AACH,oBAAY,sBAAsB,GAClC;IACC;;OAEG;IACH,IAAI,EAAE,sBAAsB,CAAC;IAE7B;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,SAAS,EAAE,IAAI,GAAG,KAAK,CAAC;I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E,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 diff --git a/node/lib/Producer.js b/node/lib/Producer.js index 69e3155057..6a742f87ef 100644 --- a/node/lib/Producer.js +++ b/node/lib/Producer.js @@ -123,7 +123,8 @@ class Producer extends EnhancedEventEmitter_1.EnhancedEventEmitter { // Remove notification subscriptions. this.#channel.removeAllListeners(this.#internal.producerId); this.#payloadChannel.removeAllListeners(this.#internal.producerId); - this.#channel.request('transport.closeProducer', this.#internal) + const reqData = { producerId: this.#internal.producerId }; + this.#channel.request('transport.closeProducer', this.#internal.transportId, reqData) .catch(() => { }); this.emit('@close'); // Emit observer event. @@ -151,14 +152,14 @@ class Producer extends EnhancedEventEmitter_1.EnhancedEventEmitter { */ async dump() { logger.debug('dump()'); - return this.#channel.request('producer.dump', this.#internal); + return this.#channel.request('producer.dump', this.#internal.producerId); } /** * Get Producer stats. */ async getStats() { logger.debug('getStats()'); - return this.#channel.request('producer.getStats', this.#internal); + return this.#channel.request('producer.getStats', this.#internal.producerId); } /** * Pause the Producer. @@ -166,7 +167,7 @@ class Producer extends EnhancedEventEmitter_1.EnhancedEventEmitter { async pause() { logger.debug('pause()'); const wasPaused = this.#paused; - await this.#channel.request('producer.pause', this.#internal); + await this.#channel.request('producer.pause', this.#internal.producerId); this.#paused = true; // Emit observer event. if (!wasPaused) @@ -178,7 +179,7 @@ class Producer extends EnhancedEventEmitter_1.EnhancedEventEmitter { async resume() { logger.debug('resume()'); const wasPaused = this.#paused; - await this.#channel.request('producer.resume', this.#internal); + await this.#channel.request('producer.resume', this.#internal.producerId); this.#paused = false; // Emit observer event. if (wasPaused) @@ -190,7 +191,7 @@ class Producer extends EnhancedEventEmitter_1.EnhancedEventEmitter { async enableTraceEvent(types = []) { logger.debug('enableTraceEvent()'); 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). @@ -199,7 +200,7 @@ class Producer extends EnhancedEventEmitter_1.EnhancedEventEmitter { if (!Buffer.isBuffer(rtpPacket)) { 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() { this.#channel.on(this.#internal.producerId, (event, data) => { diff --git a/node/lib/Router.d.ts.map b/node/lib/Router.d.ts.map index e31b1e8839..08b3601b56 100644 --- a/node/lib/Router.d.ts.map +++ b/node/lib/Router.d.ts.map @@ -1 +1 @@ -{"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,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,E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,UAAkB,EAClB,cAAwC,EACxC,kBAA2B,EAC3B,kBAA2B,EAC3B,UAAkB,EAClB,eAA2C,EAC3C,OAAO,EACP,EAAE,qBAAqB,GACtB,OAAO,CAAC,cAAc,CAAC;IAkF1B;;OAEG;IACG,mBAAmB,CACxB,EACC,QAAQ,EACR,IAAI,EACJ,UAAkB,EAClB,cAAwC,EACxC,kBAA8B,EAC9B,kBAA8B,EAC9B,SAAiB,EACjB,UAAkB,EAClB,OAAO,EACP,EAAE,oBAAoB,GACrB,OAAO,CAAC,aAAa,CAAC;IAgFzB;;OAEG;IACG,qBAAqB,CAC1B,EACC,cAAuB,EACvB,OAAO,EACP,GAAE,sBAGF,GACC,OAAO,CAAC,eAAe,CAAC;IAmD3B;;OAEG;IACG,YAAY,CACjB,EACC,UAAU,EACV,cAAc,EACd,MAAM,EACN,QAAsB,EACtB,UAAiB,EACjB,cAAwC,EACxC,SAAiB,EACjB,UAAkB,EAClB,EAAE,mBAAmB,GACpB,OAAO,CAAC,kBAAkB,CAAC;IA8O9B;;OAEG;IACH,oBAAoB,CACnB,oBAAoB,EAAE,MAAM,EAC5B,wBAAwB,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAClD,IAAI;IA+BP;;OAEG;IACG,2BAA2B,CAChC,EACC,QAAc,EACd,OAAO,EACP,GAAE,4BAAiC,GAClC,OAAO,CAAC,qBAAqB,CAAC;IAyCjC;;OAEG;IACG,wBAAwB,CAC7B,EACC,UAAc,EACd,SAAe,EACf,QAAe,EACf,OAAO,EACP,GAAE,yBAA8B,GAC/B,OAAO,CAAC,kBAAkB,CAAC;IA2C9B;;OAEG;IACH,UAAU,CACT,EACC,UAAU,EACV,eAAe,EACf,EACD;QACC,UAAU,EAAE,MAAM,CAAC;QACnB,eAAe,EAAE,eAAe,CAAC;KACjC,GACC,OAAO;CAuBV"} \ No newline at end of file diff --git a/node/lib/Router.js b/node/lib/Router.js index 5600508e81..0b93f2e102 100644 --- a/node/lib/Router.js +++ b/node/lib/Router.js @@ -102,7 +102,8 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter { return; logger.debug('close()'); this.#closed = true; - this.#channel.request('worker.closeRouter', this.#internal) + const reqData = { routerId: this.#internal.routerId }; + this.#channel.request('worker.closeRouter', undefined, reqData) .catch(() => { }); // Close every Transport. for (const transport of this.#transports.values()) { @@ -155,7 +156,7 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter { */ async dump() { logger.debug('dump()'); - return this.#channel.request('router.dump', this.#internal); + return this.#channel.request('router.dump', this.#internal.routerId); } /** * Create a WebRtcTransport. @@ -199,8 +200,8 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter { isDataChannel: true }; const data = webRtcServer - ? await this.#channel.request('router.createWebRtcTransportWithServer', this.#internal, reqData) - : await this.#channel.request('router.createWebRtcTransport', this.#internal, reqData); + ? await this.#channel.request('router.createWebRtcTransportWithServer', this.#internal.routerId, reqData) + : await this.#channel.request('router.createWebRtcTransport', this.#internal.routerId, reqData); const transport = new WebRtcTransport_1.WebRtcTransport({ internal: { ...this.#internal, @@ -263,7 +264,7 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter { enableSrtp, srtpCryptoSuite }; - const data = await this.#channel.request('router.createPlainTransport', this.#internal, reqData); + const data = await this.#channel.request('router.createPlainTransport', this.#internal.routerId, reqData); const transport = new PlainTransport_1.PlainTransport({ internal: { ...this.#internal, @@ -322,7 +323,7 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter { enableRtx, enableSrtp }; - const data = await this.#channel.request('router.createPipeTransport', this.#internal, reqData); + const data = await this.#channel.request('router.createPipeTransport', this.#internal.routerId, reqData); const transport = new PipeTransport_1.PipeTransport({ internal: { ...this.#internal, @@ -359,7 +360,7 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter { direct: true, maxMessageSize }; - const data = await this.#channel.request('router.createDirectTransport', this.#internal, reqData); + const data = await this.#channel.request('router.createDirectTransport', this.#internal.routerId, reqData); const transport = new DirectTransport_1.DirectTransport({ internal: { ...this.#internal, @@ -580,7 +581,7 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter { rtpObserverId: (0, uuid_1.v4)(), interval }; - await this.#channel.request('router.createActiveSpeakerObserver', this.#internal, reqData); + await this.#channel.request('router.createActiveSpeakerObserver', this.#internal.routerId, reqData); const activeSpeakerObserver = new ActiveSpeakerObserver_1.ActiveSpeakerObserver({ internal: { ...this.#internal, @@ -612,7 +613,7 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter { threshold, interval }; - await this.#channel.request('router.createAudioLevelObserver', this.#internal, reqData); + await this.#channel.request('router.createAudioLevelObserver', this.#internal.routerId, reqData); const audioLevelObserver = new AudioLevelObserver_1.AudioLevelObserver({ internal: { ...this.#internal, diff --git a/node/lib/RtpObserver.d.ts.map b/node/lib/RtpObserver.d.ts.map index 2b12f13eea..ec3cc30808 100644 --- a/node/lib/RtpObserver.d.ts.map +++ b/node/lib/RtpObserver.d.ts.map @@ -1 +1 @@ -{"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;AAEtC,oBAAY,iBAAiB,GAC7B;IACC,WAAW,EAAE,EAAE,CAAC;IAEhB,QAAQ,EAAE,EAAE,CAAC;CACb,CAAA;AAED,oBAAY,yBAAyB,GACrC;IACC,KAAK,EAAE,EAAE,CAAC;IACV,KAAK,EAAE,EAAE,CAAC;IACV,MAAM,EAAE,EAAE,CAAC;IACX,WAAW,EAAE,CAAC,QAAQ,CAAC,CAAC;IACxB,cAAc,EAAE,CAAC,QAAQ,CAAC,CAAC;CAC3B,CAAA;AAID,oBAAY,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CAAmC,GAAG,OAAO,CAAC,IAAI,CAAC;CAYxF"} \ No newline at end of file diff --git a/node/lib/RtpObserver.js b/node/lib/RtpObserver.js index dc82d0ff13..38ef54b7c3 100644 --- a/node/lib/RtpObserver.js +++ b/node/lib/RtpObserver.js @@ -81,7 +81,8 @@ class RtpObserver extends EnhancedEventEmitter_1.EnhancedEventEmitter { // Remove notification subscriptions. this.channel.removeAllListeners(this.internal.rtpObserverId); this.payloadChannel.removeAllListeners(this.internal.rtpObserverId); - this.channel.request('router.closeRtpObserver', this.internal) + const reqData = { rtpObserverId: this.internal.rtpObserverId }; + this.channel.request('router.closeRtpObserver', this.internal.routerId, reqData) .catch(() => { }); this.emit('@close'); // Emit observer event. @@ -110,7 +111,7 @@ class RtpObserver extends EnhancedEventEmitter_1.EnhancedEventEmitter { async pause() { logger.debug('pause()'); const wasPaused = this.#paused; - await this.channel.request('rtpObserver.pause', this.internal); + await this.channel.request('rtpObserver.pause', this.internal.rtpObserverId); this.#paused = true; // Emit observer event. if (!wasPaused) @@ -122,7 +123,7 @@ class RtpObserver extends EnhancedEventEmitter_1.EnhancedEventEmitter { async resume() { logger.debug('resume()'); const wasPaused = this.#paused; - await this.channel.request('rtpObserver.resume', this.internal); + await this.channel.request('rtpObserver.resume', this.internal.rtpObserverId); this.#paused = false; // Emit observer event. if (wasPaused) @@ -135,7 +136,7 @@ class RtpObserver extends EnhancedEventEmitter_1.EnhancedEventEmitter { logger.debug('addProducer()'); const producer = this.getProducerById(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. this.#observer.safeEmit('addproducer', producer); } @@ -146,7 +147,7 @@ class RtpObserver extends EnhancedEventEmitter_1.EnhancedEventEmitter { logger.debug('removeProducer()'); const producer = this.getProducerById(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. this.#observer.safeEmit('removeproducer', producer); } diff --git a/node/lib/Transport.d.ts.map b/node/lib/Transport.d.ts.map index 37982ccad6..8d43ed95e1 100644 --- a/node/lib/Transport.d.ts.map +++ b/node/lib/Transport.d.ts.map @@ -1 +1 @@ -{"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,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EACN,YAAY,EACZ,mBAAmB,EAEnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,YAAY,EACZ,mBAAmB,EAEnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGlD,MAAM,WAAW,iBAAiB;IAEjC;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,oBAAY,iBAAiB,GAAG,KAAK,GAAG,KAAK,CAAC;AAE9C,MAAM,WAAW,cAAc;IAE9B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,iBAAiB,CAAC;CAC5B;AAED;;GAEG;AACH,oBAAY,uBAAuB,GAAG,WAAW,GAAG,KAAK,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW,uBAAuB;IAEvC;;OAEG;IACH,IAAI,EAAE,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CAAC,IAAI,CAAC;IAU5E,OAAO,CAAC,mBAAmB;CA+B3B"} \ No newline at end of file diff --git a/node/lib/Transport.js b/node/lib/Transport.js index b0c27aa3bb..93dcefdc89 100644 --- a/node/lib/Transport.js +++ b/node/lib/Transport.js @@ -112,7 +112,8 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter { // Remove notification subscriptions. this.channel.removeAllListeners(this.internal.transportId); this.payloadChannel.removeAllListeners(this.internal.transportId); - this.channel.request('router.closeTransport', this.internal) + const reqData = { transportId: this.internal.transportId }; + this.channel.request('router.closeTransport', this.internal.routerId, reqData) .catch(() => { }); // Close every Producer. for (const producer of this.#producers.values()) { @@ -235,7 +236,7 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter { */ async dump() { logger.debug('dump()'); - return this.channel.request('transport.dump', this.internal); + return this.channel.request('transport.dump', this.internal.transportId); } /** * Get Transport stats. @@ -262,7 +263,7 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter { async setMaxIncomingBitrate(bitrate) { logger.debug('setMaxIncomingBitrate() [bitrate:%s]', 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. @@ -270,7 +271,7 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter { async setMaxOutgoingBitrate(bitrate) { logger.debug('setMaxOutgoingBitrate() [bitrate:%s]', 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. @@ -313,9 +314,15 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter { const rtpMapping = ortc.getProducerRtpParametersMapping(rtpParameters, routerRtpCapabilities); // This may throw. const consumableRtpParameters = ortc.getConsumableRtpParameters(kind, rtpParameters, routerRtpCapabilities, rtpMapping); - const internal = { ...this.internal, producerId: id || (0, uuid_1.v4)() }; - const reqData = { kind, rtpParameters, rtpMapping, keyFrameRequestDelay, paused }; - const status = await this.channel.request('transport.produce', internal, reqData); + const reqData = { + producerId: id || (0, uuid_1.v4)(), + kind, + rtpParameters, + rtpMapping, + keyFrameRequestDelay, + paused + }; + const status = await this.channel.request('transport.produce', this.internal.transportId, reqData); const data = { kind, rtpParameters, @@ -323,7 +330,10 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter { consumableRtpParameters }; const producer = new Producer_1.Producer({ - internal, + internal: { + ...this.internal, + producerId: reqData.producerId + }, data, channel: this.channel, payloadChannel: this.payloadChannel, @@ -374,8 +384,8 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter { } } } - const internal = { ...this.internal, consumerId: (0, uuid_1.v4)() }; const reqData = { + consumerId: (0, uuid_1.v4)(), producerId, kind: producer.kind, rtpParameters, @@ -385,7 +395,7 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter { preferredLayers, 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 = { producerId, kind: producer.kind, @@ -393,7 +403,10 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter { type: pipe ? 'pipe' : producer.type }; const consumer = new Consumer_1.Consumer({ - internal, + internal: { + ...this.internal, + consumerId: reqData.consumerId + }, data, channel: this.channel, payloadChannel: this.payloadChannel, @@ -433,16 +446,19 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter { logger.warn('produceData() | sctpStreamParameters are ignored when producing data on a DirectTransport'); } } - const internal = { ...this.internal, dataProducerId: id || (0, uuid_1.v4)() }; const reqData = { + dataProducerId: id || (0, uuid_1.v4)(), type, sctpStreamParameters, label, 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({ - internal, + internal: { + ...this.internal, + dataProducerId: reqData.dataProducerId + }, data, channel: this.channel, payloadChannel: this.payloadChannel, @@ -501,17 +517,20 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter { } } const { label, protocol } = dataProducer; - const internal = { ...this.internal, dataConsumerId: (0, uuid_1.v4)() }; const reqData = { + dataConsumerId: (0, uuid_1.v4)(), dataProducerId, type, sctpStreamParameters, label, 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({ - internal, + internal: { + ...this.internal, + dataConsumerId: reqData.dataConsumerId + }, data, channel: this.channel, payloadChannel: this.payloadChannel, @@ -538,12 +557,12 @@ class Transport extends EnhancedEventEmitter_1.EnhancedEventEmitter { async enableTraceEvent(types = []) { logger.debug('pause()'); const reqData = { types }; - await this.channel.request('transport.enableTraceEvent', this.internal, reqData); + await this.channel.request('transport.enableTraceEvent', this.internal.transportId, reqData); } getNextSctpStreamId() { if (!this.#data.sctpParameters || 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; if (!this.#sctpStreamIds) diff --git a/node/lib/WebRtcServer.d.ts.map b/node/lib/WebRtcServer.d.ts.map index c57f843e32..1a8cadc9a1 100644 --- a/node/lib/WebRtcServer.d.ts.map +++ b/node/lib/WebRtcServer.d.ts.map @@ -1 +1 @@ -{"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,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,WAA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AC,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 diff --git a/node/lib/WebRtcServer.js b/node/lib/WebRtcServer.js index dfdc4cb9a2..38b0f2db5e 100644 --- a/node/lib/WebRtcServer.js +++ b/node/lib/WebRtcServer.js @@ -72,7 +72,8 @@ class WebRtcServer extends EnhancedEventEmitter_1.EnhancedEventEmitter { return; logger.debug('close()'); this.#closed = true; - this.#channel.request('worker.closeWebRtcServer', this.#internal) + const reqData = { webRtcServerId: this.#internal.webRtcServerId }; + this.#channel.request('worker.closeWebRtcServer', undefined, reqData) .catch(() => { }); // Close every WebRtcTransport. for (const webRtcTransport of this.#webRtcTransports.values()) { @@ -107,7 +108,7 @@ class WebRtcServer extends EnhancedEventEmitter_1.EnhancedEventEmitter { */ async dump() { logger.debug('dump()'); - return this.#channel.request('webRtcServer.dump', this.#internal); + return this.#channel.request('webRtcServer.dump', this.#internal.webRtcServerId); } /** * @private diff --git a/node/lib/WebRtcTransport.js b/node/lib/WebRtcTransport.js index e5ff36a7c5..545361149f 100644 --- a/node/lib/WebRtcTransport.js +++ b/node/lib/WebRtcTransport.js @@ -142,7 +142,7 @@ class WebRtcTransport extends Transport_1.Transport { */ async 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. @@ -152,7 +152,7 @@ class WebRtcTransport extends Transport_1.Transport { async connect({ dtlsParameters }) { logger.debug('connect()'); 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. this.#data.dtlsParameters.role = data.dtlsLocalRole; } @@ -161,7 +161,7 @@ class WebRtcTransport extends Transport_1.Transport { */ async 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; this.#data.iceParameters = iceParameters; return iceParameters; diff --git a/node/lib/Worker.js b/node/lib/Worker.js index 43f3d81a74..cb634ac006 100644 --- a/node/lib/Worker.js +++ b/node/lib/Worker.js @@ -287,7 +287,7 @@ class Worker extends EnhancedEventEmitter_1.EnhancedEventEmitter { webRtcServerId: (0, uuid_1.v4)(), listenInfos }; - await this.#channel.request('worker.createWebRtcServer', {}, reqData); + await this.#channel.request('worker.createWebRtcServer', undefined, reqData); const webRtcServer = new WebRtcServer_1.WebRtcServer({ internal: { webRtcServerId: reqData.webRtcServerId }, channel: this.#channel, @@ -309,7 +309,7 @@ class Worker extends EnhancedEventEmitter_1.EnhancedEventEmitter { // This may throw. const rtpCapabilities = ortc.generateRouterRtpCapabilities(mediaCodecs); const reqData = { routerId: (0, uuid_1.v4)() }; - await this.#channel.request('worker.createRouter', {}, reqData); + await this.#channel.request('worker.createRouter', undefined, reqData); const data = { rtpCapabilities }; const router = new Router_1.Router({ internal: { diff --git a/node/src/Channel.ts b/node/src/Channel.ts index b370f72e45..e06dd6f26c 100644 --- a/node/src/Channel.ts +++ b/node/src/Channel.ts @@ -223,7 +223,7 @@ export class Channel extends EnhancedEventEmitter /** * @private */ - async request(method: string, internal?: object, data?: any): Promise + async request(method: string, handlerId?: string, data?: any): Promise { this.#nextId < 4294967295 ? ++this.#nextId : (this.#nextId = 1); @@ -234,7 +234,7 @@ export class Channel extends EnhancedEventEmitter if (this.#closed) throw new InvalidStateError('Channel closed'); - const request = { id, method, internal, data }; + const request = { id, method, handlerId, data }; const payload = JSON.stringify(request); if (Buffer.byteLength(payload) > MESSAGE_MAX_LEN) diff --git a/node/src/Consumer.ts b/node/src/Consumer.ts index 1b17f0b5da..5c6540b6f0 100644 --- a/node/src/Consumer.ts +++ b/node/src/Consumer.ts @@ -428,7 +428,9 @@ export class Consumer extends EnhancedEventEmitter this.#channel.removeAllListeners(this.#internal.consumerId); this.#payloadChannel.removeAllListeners(this.#internal.consumerId); - this.#channel.request('transport.closeConsumer', this.#internal) + const reqData = { consumerId: this.#internal.consumerId }; + + this.#channel.request('transport.closeConsumer', this.#internal.transportId, reqData) .catch(() => {}); this.emit('@close'); @@ -468,7 +470,7 @@ export class Consumer extends EnhancedEventEmitter { 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 { 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 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; @@ -508,7 +510,7 @@ export class Consumer extends EnhancedEventEmitter 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; @@ -532,7 +534,7 @@ export class Consumer extends EnhancedEventEmitter const reqData = { spatialLayer, temporalLayer }; const data = await this.#channel.request( - 'consumer.setPreferredLayers', this.#internal, reqData); + 'consumer.setPreferredLayers', this.#internal.consumerId, reqData); this.#preferredLayers = data || undefined; } @@ -547,7 +549,7 @@ export class Consumer extends EnhancedEventEmitter const reqData = { priority }; const data = await this.#channel.request( - 'consumer.setPriority', this.#internal, reqData); + 'consumer.setPriority', this.#internal.consumerId, reqData); this.#priority = data.priority; } @@ -562,7 +564,7 @@ export class Consumer extends EnhancedEventEmitter const reqData = { priority: 1 }; const data = await this.#channel.request( - 'consumer.setPriority', this.#internal, reqData); + 'consumer.setPriority', this.#internal.consumerId, reqData); this.#priority = data.priority; } @@ -574,7 +576,7 @@ export class Consumer extends EnhancedEventEmitter { 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 const reqData = { types }; await this.#channel.request( - 'consumer.enableTraceEvent', this.#internal, reqData); + 'consumer.enableTraceEvent', this.#internal.consumerId, reqData); } private handleWorkerNotifications(): void diff --git a/node/src/DataConsumer.ts b/node/src/DataConsumer.ts index f0075e68a7..edb13d8618 100644 --- a/node/src/DataConsumer.ts +++ b/node/src/DataConsumer.ts @@ -240,7 +240,9 @@ export class DataConsumer extends EnhancedEventEmitter this.#channel.removeAllListeners(this.#internal.dataConsumerId); this.#payloadChannel.removeAllListeners(this.#internal.dataConsumerId); - this.#channel.request('transport.closeDataConsumer', this.#internal) + const reqData = { dataConsumerId: this.#internal.dataConsumerId }; + + this.#channel.request('transport.closeDataConsumer', this.#internal.transportId, reqData) .catch(() => {}); this.emit('@close'); @@ -280,7 +282,7 @@ export class DataConsumer extends EnhancedEventEmitter { 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 { 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 const reqData = { threshold }; await this.#channel.request( - 'dataConsumer.setBufferedAmountLowThreshold', this.#internal, reqData); + 'dataConsumer.setBufferedAmountLowThreshold', this.#internal.dataConsumerId, reqData); } /** @@ -348,7 +350,7 @@ export class DataConsumer extends EnhancedEventEmitter const requestData = { ppid }; 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 logger.debug('getBufferedAmount()'); const { bufferedAmount } = - await this.#channel.request('dataConsumer.getBufferedAmount', this.#internal); + await this.#channel.request('dataConsumer.getBufferedAmount', this.#internal.dataConsumerId); return bufferedAmount; } diff --git a/node/src/DataProducer.ts b/node/src/DataProducer.ts index df82311310..0e5497cbe9 100644 --- a/node/src/DataProducer.ts +++ b/node/src/DataProducer.ts @@ -217,7 +217,9 @@ export class DataProducer extends EnhancedEventEmitter this.#channel.removeAllListeners(this.#internal.dataProducerId); this.#payloadChannel.removeAllListeners(this.#internal.dataProducerId); - this.#channel.request('transport.closeDataProducer', this.#internal) + const reqData = { dataProducerId: this.#internal.dataProducerId }; + + this.#channel.request('transport.closeDataProducer', this.#internal.transportId, reqData) .catch(() => {}); this.emit('@close'); @@ -257,7 +259,7 @@ export class DataProducer extends EnhancedEventEmitter { 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 { 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 const notifData = { ppid }; this.#payloadChannel.notify( - 'dataProducer.send', this.#internal, notifData, message); + 'dataProducer.send', this.#internal.dataProducerId, notifData, message); } private handleWorkerNotifications(): void diff --git a/node/src/DirectTransport.ts b/node/src/DirectTransport.ts index 126ff7f10d..6be089cf9c 100644 --- a/node/src/DirectTransport.ts +++ b/node/src/DirectTransport.ts @@ -115,7 +115,7 @@ export class DirectTransport extends { 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 } this.payloadChannel.notify( - 'transport.sendRtcp', this.internal, undefined, rtcpPacket); + 'transport.sendRtcp', this.internal.transportId, undefined, rtcpPacket); } private handleWorkerNotifications(): void diff --git a/node/src/PayloadChannel.ts b/node/src/PayloadChannel.ts index 8ec3f1e400..8dfe3a900a 100644 --- a/node/src/PayloadChannel.ts +++ b/node/src/PayloadChannel.ts @@ -152,7 +152,7 @@ export class PayloadChannel extends EnhancedEventEmitter 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. this.#consumerSocket.removeAllListeners('end'); this.#consumerSocket.removeAllListeners('error'); @@ -177,7 +177,7 @@ export class PayloadChannel extends EnhancedEventEmitter */ notify( event: string, - internal: object, + handlerId: string, data: any | undefined, payload: string | Buffer ): void @@ -187,7 +187,7 @@ export class PayloadChannel extends EnhancedEventEmitter if (this.#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) throw new Error('PayloadChannel notification too big'); @@ -228,7 +228,7 @@ export class PayloadChannel extends EnhancedEventEmitter */ async request( method: string, - internal: object, + handlerId: string, data: any, payload: string | Buffer): Promise { @@ -241,7 +241,7 @@ export class PayloadChannel extends EnhancedEventEmitter if (this.#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) throw new Error('Channel request too big'); diff --git a/node/src/PipeTransport.ts b/node/src/PipeTransport.ts index 0c236fb211..5b1028dd8f 100644 --- a/node/src/PipeTransport.ts +++ b/node/src/PipeTransport.ts @@ -232,7 +232,7 @@ export class PipeTransport { 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 const reqData = { ip, port, srtpParameters }; const data = - await this.channel.request('transport.connect', this.internal, reqData); + await this.channel.request('transport.connect', this.internal.transportId, reqData); // Update data. this.#data.tuple = data.tuple; @@ -287,9 +287,9 @@ export class PipeTransport const rtpParameters = ortc.getPipeConsumerRtpParameters( producer.consumableRtpParameters, this.#data.rtx); - const internal = { ...this.internal, consumerId: uuidv4() }; const reqData = { + consumerId : uuidv4(), producerId, kind : producer.kind, rtpParameters, @@ -298,7 +298,7 @@ export class PipeTransport }; const status = - await this.channel.request('transport.consume', internal, reqData); + await this.channel.request('transport.consume', this.internal.transportId, reqData); const data = { @@ -310,7 +310,11 @@ export class PipeTransport const consumer = new Consumer( { - internal, + internal : + { + ...this.internal, + consumerId : reqData.consumerId + }, data, channel : this.channel, payloadChannel : this.payloadChannel, diff --git a/node/src/PlainTransport.ts b/node/src/PlainTransport.ts index 5cae431c90..42c2af5851 100644 --- a/node/src/PlainTransport.ts +++ b/node/src/PlainTransport.ts @@ -256,7 +256,7 @@ export class PlainTransport extends { 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 const reqData = { ip, port, rtcpPort, srtpParameters }; const data = - await this.channel.request('transport.connect', this.internal, reqData); + await this.channel.request('transport.connect', this.internal.transportId, reqData); // Update data. if (data.tuple) diff --git a/node/src/Producer.ts b/node/src/Producer.ts index ad2808b97a..cc9ab3c718 100644 --- a/node/src/Producer.ts +++ b/node/src/Producer.ts @@ -353,7 +353,9 @@ export class Producer extends EnhancedEventEmitter this.#channel.removeAllListeners(this.#internal.producerId); this.#payloadChannel.removeAllListeners(this.#internal.producerId); - this.#channel.request('transport.closeProducer', this.#internal) + const reqData = { producerId: this.#internal.producerId }; + + this.#channel.request('transport.closeProducer', this.#internal.transportId, reqData) .catch(() => {}); this.emit('@close'); @@ -393,7 +395,7 @@ export class Producer extends EnhancedEventEmitter { 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 { 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 const wasPaused = this.#paused; - await this.#channel.request('producer.pause', this.#internal); + await this.#channel.request('producer.pause', this.#internal.producerId); this.#paused = true; @@ -433,7 +435,7 @@ export class Producer extends EnhancedEventEmitter const wasPaused = this.#paused; - await this.#channel.request('producer.resume', this.#internal); + await this.#channel.request('producer.resume', this.#internal.producerId); this.#paused = false; @@ -452,7 +454,7 @@ export class Producer extends EnhancedEventEmitter const reqData = { types }; await this.#channel.request( - 'producer.enableTraceEvent', this.#internal, reqData); + 'producer.enableTraceEvent', this.#internal.producerId, reqData); } /** @@ -466,7 +468,7 @@ export class Producer extends EnhancedEventEmitter } this.#payloadChannel.notify( - 'producer.send', this.#internal, undefined, rtpPacket); + 'producer.send', this.#internal.producerId, undefined, rtpPacket); } private handleWorkerNotifications(): void diff --git a/node/src/Router.ts b/node/src/Router.ts index bdfc47ff21..47f1144387 100644 --- a/node/src/Router.ts +++ b/node/src/Router.ts @@ -266,7 +266,9 @@ export class Router extends EnhancedEventEmitter this.#closed = true; - this.#channel.request('worker.closeRouter', this.#internal) + const reqData = { routerId: this.#internal.routerId }; + + this.#channel.request('worker.closeRouter', undefined, reqData) .catch(() => {}); // Close every Transport. @@ -342,7 +344,7 @@ export class Router extends EnhancedEventEmitter { logger.debug('dump()'); - return this.#channel.request('router.dump', this.#internal); + return this.#channel.request('router.dump', this.#internal.routerId); } /** @@ -414,15 +416,16 @@ export class Router extends EnhancedEventEmitter }; const data = webRtcServer - ? await this.#channel.request('router.createWebRtcTransportWithServer', this.#internal, reqData) - : await this.#channel.request('router.createWebRtcTransport', this.#internal, reqData); + ? await this.#channel.request('router.createWebRtcTransportWithServer', this.#internal.routerId, reqData) + : await this.#channel.request('router.createWebRtcTransport', this.#internal.routerId, reqData); const transport = new WebRtcTransport( { - internal : { - ...this.#internal, - transportId : reqData.transportId - }, + internal : + { + ...this.#internal, + transportId : reqData.transportId + }, data, channel : this.#channel, payloadChannel : this.#payloadChannel, @@ -516,14 +519,15 @@ export class Router extends EnhancedEventEmitter }; const data = - await this.#channel.request('router.createPlainTransport', this.#internal, reqData); + await this.#channel.request('router.createPlainTransport', this.#internal.routerId, reqData); const transport = new PlainTransport( { - internal : { - ...this.#internal, - transportId : reqData.transportId - }, + internal : + { + ...this.#internal, + transportId : reqData.transportId + }, data, channel : this.#channel, payloadChannel : this.#payloadChannel, @@ -610,14 +614,15 @@ export class Router extends EnhancedEventEmitter }; const data = - await this.#channel.request('router.createPipeTransport', this.#internal, reqData); + await this.#channel.request('router.createPipeTransport', this.#internal.routerId, reqData); const transport = new PipeTransport( { - internal : { - ...this.#internal, - transportId : reqData.transportId - }, + internal : + { + ...this.#internal, + transportId : reqData.transportId + }, data, channel : this.#channel, payloadChannel : this.#payloadChannel, @@ -671,14 +676,15 @@ export class Router extends EnhancedEventEmitter }; const data = - await this.#channel.request('router.createDirectTransport', this.#internal, reqData); + await this.#channel.request('router.createDirectTransport', this.#internal.routerId, reqData); const transport = new DirectTransport( { - internal : { - ...this.#internal, - transportId : reqData.transportId - }, + internal : + { + ...this.#internal, + transportId : reqData.transportId + }, data, channel : this.#channel, payloadChannel : this.#payloadChannel, @@ -1019,14 +1025,15 @@ export class Router extends EnhancedEventEmitter interval }; - await this.#channel.request('router.createActiveSpeakerObserver', this.#internal, reqData); + await this.#channel.request('router.createActiveSpeakerObserver', this.#internal.routerId, reqData); const activeSpeakerObserver = new ActiveSpeakerObserver( { - internal : { - ...this.#internal, - rtpObserverId : reqData.rtpObserverId - }, + internal : + { + ...this.#internal, + rtpObserverId : reqData.rtpObserverId + }, channel : this.#channel, payloadChannel : this.#payloadChannel, appData, @@ -1071,14 +1078,15 @@ export class Router extends EnhancedEventEmitter interval }; - await this.#channel.request('router.createAudioLevelObserver', this.#internal, reqData); + await this.#channel.request('router.createAudioLevelObserver', this.#internal.routerId, reqData); const audioLevelObserver = new AudioLevelObserver( { - internal : { - ...this.#internal, - rtpObserverId : reqData.rtpObserverId - }, + internal : + { + ...this.#internal, + rtpObserverId : reqData.rtpObserverId + }, channel : this.#channel, payloadChannel : this.#payloadChannel, appData, diff --git a/node/src/RtpObserver.ts b/node/src/RtpObserver.ts index fd54ed6495..7db172b669 100644 --- a/node/src/RtpObserver.ts +++ b/node/src/RtpObserver.ts @@ -157,7 +157,9 @@ export class RtpObserver this.channel.removeAllListeners(this.internal.rtpObserverId); this.payloadChannel.removeAllListeners(this.internal.rtpObserverId); - this.channel.request('router.closeRtpObserver', this.internal) + const reqData = { rtpObserverId: this.internal.rtpObserverId }; + + this.channel.request('router.closeRtpObserver', this.internal.routerId, reqData) .catch(() => {}); this.emit('@close'); @@ -199,7 +201,7 @@ export class RtpObserver const wasPaused = this.#paused; - await this.channel.request('rtpObserver.pause', this.internal); + await this.channel.request('rtpObserver.pause', this.internal.rtpObserverId); this.#paused = true; @@ -217,7 +219,7 @@ export class RtpObserver const wasPaused = this.#paused; - await this.channel.request('rtpObserver.resume', this.internal); + await this.channel.request('rtpObserver.resume', this.internal.rtpObserverId); this.#paused = false; @@ -236,7 +238,7 @@ export class RtpObserver const producer = this.getProducerById(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. this.#observer.safeEmit('addproducer', producer); @@ -252,7 +254,7 @@ export class RtpObserver const producer = this.getProducerById(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. this.#observer.safeEmit('removeproducer', producer); diff --git a/node/src/Transport.ts b/node/src/Transport.ts index 797b62b2ac..341efefe37 100644 --- a/node/src/Transport.ts +++ b/node/src/Transport.ts @@ -279,7 +279,9 @@ export class Transport {}); // Close every Producer. @@ -452,7 +454,7 @@ export class Transport this.#closed = true; - this.#channel.request('worker.closeWebRtcServer', this.#internal) + const reqData = { webRtcServerId: this.#internal.webRtcServerId }; + + this.#channel.request('worker.closeWebRtcServer', undefined, reqData) .catch(() => {}); // Close every WebRtcTransport. @@ -216,7 +218,7 @@ export class WebRtcServer extends EnhancedEventEmitter { logger.debug('dump()'); - return this.#channel.request('webRtcServer.dump', this.#internal); + return this.#channel.request('webRtcServer.dump', this.#internal.webRtcServerId); } /** diff --git a/node/src/WebRtcTransport.ts b/node/src/WebRtcTransport.ts index 7d22190a98..aaf0f4df55 100644 --- a/node/src/WebRtcTransport.ts +++ b/node/src/WebRtcTransport.ts @@ -383,7 +383,7 @@ export class WebRtcTransport extends { 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 const reqData = { dtlsParameters }; const data = - await this.channel.request('transport.connect', this.internal, reqData); + await this.channel.request('transport.connect', this.internal.transportId, reqData); // Update data. this.#data.dtlsParameters.role = data.dtlsLocalRole; @@ -412,7 +412,7 @@ export class WebRtcTransport extends logger.debug('restartIce()'); const data = - await this.channel.request('transport.restartIce', this.internal); + await this.channel.request('transport.restartIce', this.internal.transportId); const { iceParameters } = data; diff --git a/node/src/Worker.ts b/node/src/Worker.ts index 4ae76b93c4..fbe976b363 100644 --- a/node/src/Worker.ts +++ b/node/src/Worker.ts @@ -598,7 +598,7 @@ export class Worker extends EnhancedEventEmitter listenInfos }; - await this.#channel.request('worker.createWebRtcServer', {}, reqData); + await this.#channel.request('worker.createWebRtcServer', undefined, reqData); const webRtcServer = new WebRtcServer( { @@ -635,7 +635,7 @@ export class Worker extends EnhancedEventEmitter const reqData = { routerId: uuidv4() }; - await this.#channel.request('worker.createRouter', {}, reqData); + await this.#channel.request('worker.createRouter', undefined, reqData); const data = { rtpCapabilities }; const router = new Router( diff --git a/rust/src/messages.rs b/rust/src/messages.rs index 9e34e950d7..44efafa788 100644 --- a/rust/src/messages.rs +++ b/rust/src/messages.rs @@ -34,65 +34,6 @@ use std::fmt::Debug; use std::net::IpAddr; use std::num::NonZeroU16; -#[derive(Debug, Serialize)] -#[serde(rename_all = "camelCase")] -pub(crate) struct RouterInternal { - pub(crate) router_id: RouterId, -} - -#[derive(Debug, Serialize)] -#[serde(rename_all = "camelCase")] -pub(crate) struct WebRtcServerInternal { - #[serde(rename = "webRtcServerId")] - pub(crate) webrtc_server_id: WebRtcServerId, -} - -#[derive(Debug, Serialize)] -#[serde(rename_all = "camelCase")] -pub(crate) struct TransportInternal { - pub(crate) router_id: RouterId, - pub(crate) transport_id: TransportId, -} - -#[derive(Debug, Serialize)] -#[serde(rename_all = "camelCase")] -pub(crate) struct RtpObserverInternal { - pub(crate) router_id: RouterId, - pub(crate) rtp_observer_id: RtpObserverId, -} - -#[derive(Debug, Serialize)] -#[serde(rename_all = "camelCase")] -pub(crate) struct ProducerInternal { - pub(crate) router_id: RouterId, - pub(crate) transport_id: TransportId, - pub(crate) producer_id: ProducerId, -} - -#[derive(Debug, Serialize)] -#[serde(rename_all = "camelCase")] -pub(crate) struct ConsumerInternal { - pub(crate) router_id: RouterId, - pub(crate) transport_id: TransportId, - pub(crate) consumer_id: ConsumerId, -} - -#[derive(Debug, Serialize)] -#[serde(rename_all = "camelCase")] -pub(crate) struct DataProducerInternal { - pub(crate) router_id: RouterId, - pub(crate) transport_id: TransportId, - pub(crate) data_producer_id: DataProducerId, -} - -#[derive(Debug, Serialize)] -#[serde(rename_all = "camelCase")] -pub(crate) struct DataConsumerInternal { - pub(crate) router_id: RouterId, - pub(crate) transport_id: TransportId, - pub(crate) data_consumer_id: DataConsumerId, -} - pub(crate) trait Request: Debug + Serialize { type Response: DeserializeOwned; @@ -119,6 +60,7 @@ macro_rules! request_response { $default_for_soft_error: expr $(,)? ) => { #[derive(Debug, Serialize)] + #[serde(rename_all = "camelCase")] pub(crate) struct $request_struct_name { $( pub(crate) $request_field_name: $request_field_type, )* } @@ -166,6 +108,7 @@ macro_rules! request_response { $response_struct_name: ident { $( $response_field_name: ident: $response_field_type: ty$(,)? )* }, ) => { #[derive(Debug, Serialize)] + #[serde(rename_all = "camelCase")] pub(crate) struct $request_struct_name { $( pub(crate) $request_field_name: $request_field_type, )* } @@ -212,10 +155,17 @@ request_response!( }, ); +#[derive(Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub(crate) struct WebRtcServerCloseRequestData { + #[serde(rename = "webRtcServerId")] + pub(crate) webrtc_server_id: WebRtcServerId, +} + request_response!( "worker.closeWebRtcServer", WebRtcServerCloseRequest { - internal: WebRtcServerInternal, + data: WebRtcServerCloseRequestData, }, (), Some(()), @@ -224,7 +174,7 @@ request_response!( request_response!( "webRtcServer.dump", WebRtcServerDumpRequest { - internal: WebRtcServerInternal, + handler_id: WebRtcServerId, }, WebRtcServerDump, ); @@ -242,10 +192,16 @@ request_response!( }, ); +#[derive(Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub(crate) struct RouterCloseRequestData { + pub(crate) router_id: RouterId, +} + request_response!( "worker.closeRouter", RouterCloseRequest { - internal: RouterInternal, + data: RouterCloseRequestData, }, (), Some(()), @@ -254,7 +210,7 @@ request_response!( request_response!( "router.dump", RouterDumpRequest { - internal: RouterInternal, + handler_id: RouterId, }, RouterDump, ); @@ -283,7 +239,7 @@ impl RouterCreateDirectTransportData { request_response!( "router.createDirectTransport", RouterCreateDirectTransportRequest { - internal: RouterInternal, + handler_id: RouterId, data: RouterCreateDirectTransportData, }, RouterCreateDirectTransportResponse {}, @@ -358,8 +314,9 @@ impl RouterCreateWebrtcTransportData { } #[derive(Debug, Serialize)] +#[serde(rename_all = "camelCase")] pub(crate) struct RouterCreateWebrtcTransportRequest { - pub(crate) internal: RouterInternal, + pub(crate) handler_id: RouterId, pub(crate) data: RouterCreateWebrtcTransportData, } @@ -434,7 +391,7 @@ impl RouterCreatePlainTransportData { request_response!( "router.createPlainTransport", RouterCreatePlainTransportRequest { - internal: RouterInternal, + handler_id: RouterId, data: RouterCreatePlainTransportData, }, PlainTransportData { @@ -488,7 +445,7 @@ impl RouterCreatePipeTransportData { request_response!( "router.createPipeTransport", RouterCreatePipeTransportRequest { - internal: RouterInternal, + handler_id: RouterId, data: RouterCreatePipeTransportData, }, PipeTransportData { @@ -526,7 +483,7 @@ impl RouterCreateAudioLevelObserverData { request_response!( "router.createAudioLevelObserver", RouterCreateAudioLevelObserverRequest { - internal: RouterInternal, + handler_id: RouterId, data: RouterCreateAudioLevelObserverData, }, ); @@ -553,15 +510,22 @@ impl RouterCreateActiveSpeakerObserverData { request_response!( "router.createActiveSpeakerObserver", RouterCreateActiveSpeakerObserverRequest { - internal: RouterInternal, + handler_id: RouterId, data: RouterCreateActiveSpeakerObserverData, }, ); +#[derive(Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub(crate) struct TransportCloseRequestData { + pub(crate) transport_id: TransportId, +} + request_response!( "router.closeTransport", TransportCloseRequest { - internal: TransportInternal, + handler_id: RouterId, + data: TransportCloseRequestData, }, (), Some(()), @@ -570,7 +534,7 @@ request_response!( request_response!( "transport.dump", TransportDumpRequest { - internal: TransportInternal, + handler_id: TransportId, }, Value, ); @@ -578,7 +542,7 @@ request_response!( request_response!( "transport.getStats", TransportGetStatsRequest { - internal: TransportInternal, + handler_id: TransportId, }, Value, ); @@ -592,7 +556,7 @@ pub(crate) struct TransportConnectRequestWebRtcData { request_response!( "transport.connect", TransportConnectWebRtcRequest { - internal: TransportInternal, + handler_id: TransportId, data: TransportConnectRequestWebRtcData, }, TransportConnectResponseWebRtc { @@ -612,7 +576,7 @@ pub(crate) struct TransportConnectRequestPipeData { request_response!( "transport.connect", TransportConnectPipeRequest { - internal: TransportInternal, + handler_id: TransportId, data: TransportConnectRequestPipeData, }, TransportConnectResponsePipe { @@ -636,7 +600,7 @@ pub(crate) struct TransportConnectRequestPlainData { request_response!( "transport.connect", TransportConnectPlainRequest { - internal: TransportInternal, + handler_id: TransportId, data: TransportConnectRequestPlainData, }, TransportConnectResponsePlain { @@ -655,7 +619,7 @@ pub(crate) struct TransportSetMaxIncomingBitrateData { request_response!( "transport.setMaxIncomingBitrate", TransportSetMaxIncomingBitrateRequest { - internal: TransportInternal, + handler_id: TransportId, data: TransportSetMaxIncomingBitrateData, }, ); @@ -669,7 +633,7 @@ pub(crate) struct TransportSetMaxOutgoingBitrateData { request_response!( "transport.setMaxOutgoingBitrate", TransportSetMaxOutgoingBitrateRequest { - internal: TransportInternal, + handler_id: TransportId, data: TransportSetMaxOutgoingBitrateData, }, ); @@ -677,7 +641,7 @@ request_response!( request_response!( "transport.restartIce", TransportRestartIceRequest { - internal: TransportInternal, + handler_id: TransportId, }, TransportRestartIceResponse { ice_parameters: IceParameters, @@ -687,6 +651,7 @@ request_response!( #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] pub(crate) struct TransportProduceData { + pub(crate) producer_id: ProducerId, pub(crate) kind: MediaKind, pub(crate) rtp_parameters: RtpParameters, pub(crate) rtp_mapping: RtpMapping, @@ -697,7 +662,7 @@ pub(crate) struct TransportProduceData { request_response!( "transport.produce", TransportProduceRequest { - internal: ProducerInternal, + handler_id: TransportId, data: TransportProduceData, }, TransportProduceResponse { @@ -708,6 +673,7 @@ request_response!( #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] pub(crate) struct TransportConsumeData { + pub(crate) consumer_id: ConsumerId, pub(crate) producer_id: ProducerId, pub(crate) kind: MediaKind, pub(crate) rtp_parameters: RtpParameters, @@ -721,7 +687,7 @@ pub(crate) struct TransportConsumeData { request_response!( "transport.consume", TransportConsumeRequest { - internal: ConsumerInternal, + handler_id: TransportId, data: TransportConsumeData, }, TransportConsumeResponse { @@ -735,6 +701,7 @@ request_response!( #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] pub(crate) struct TransportProduceDataData { + pub(crate) data_producer_id: DataProducerId, pub(crate) r#type: DataProducerType, #[serde(skip_serializing_if = "Option::is_none")] pub(crate) sctp_stream_parameters: Option, @@ -745,7 +712,7 @@ pub(crate) struct TransportProduceDataData { request_response!( "transport.produceData", TransportProduceDataRequest { - internal: DataProducerInternal, + handler_id: TransportId, data: TransportProduceDataData, }, TransportProduceDataResponse { @@ -759,6 +726,7 @@ request_response!( #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] pub(crate) struct TransportConsumeDataData { + pub(crate) data_consumer_id: DataConsumerId, pub(crate) data_producer_id: DataProducerId, pub(crate) r#type: DataConsumerType, #[serde(skip_serializing_if = "Option::is_none")] @@ -770,7 +738,7 @@ pub(crate) struct TransportConsumeDataData { request_response!( "transport.consumeData", TransportConsumeDataRequest { - internal: DataConsumerInternal, + handler_id: TransportId, data: TransportConsumeDataData, }, TransportConsumeDataResponse { @@ -790,14 +758,15 @@ pub(crate) struct TransportEnableTraceEventData { request_response!( "transport.enableTraceEvent", TransportEnableTraceEventRequest { - internal: TransportInternal, + handler_id: TransportId, data: TransportEnableTraceEventData, }, ); #[derive(Debug, Serialize)] +#[serde(rename_all = "camelCase")] pub(crate) struct TransportSendRtcpNotification { - pub(crate) internal: TransportInternal, + pub(crate) handler_id: TransportId, } impl Notification for TransportSendRtcpNotification { @@ -806,10 +775,17 @@ impl Notification for TransportSendRtcpNotification { } } +#[derive(Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub(crate) struct ProducerCloseRequestData { + pub(crate) producer_id: ProducerId, +} + request_response!( "transport.closeProducer", ProducerCloseRequest { - internal: ProducerInternal, + handler_id: TransportId, + data: ProducerCloseRequestData, }, (), Some(()), @@ -818,7 +794,7 @@ request_response!( request_response!( "producer.dump", ProducerDumpRequest { - internal: ProducerInternal, + handler_id: ProducerId, }, ProducerDump ); @@ -826,7 +802,7 @@ request_response!( request_response!( "producer.getStats", ProducerGetStatsRequest { - internal: ProducerInternal, + handler_id: ProducerId, }, Vec, ); @@ -834,14 +810,14 @@ request_response!( request_response!( "producer.pause", ProducerPauseRequest { - internal: ProducerInternal, + handler_id: ProducerId, }, ); request_response!( "producer.resume", ProducerResumeRequest { - internal: ProducerInternal, + handler_id: ProducerId, }, ); @@ -854,14 +830,15 @@ pub(crate) struct ProducerEnableTraceEventData { request_response!( "producer.enableTraceEvent", ProducerEnableTraceEventRequest { - internal: ProducerInternal, + handler_id: ProducerId, data: ProducerEnableTraceEventData, }, ); #[derive(Debug, Serialize)] +#[serde(rename_all = "camelCase")] pub(crate) struct ProducerSendNotification { - pub(crate) internal: ProducerInternal, + pub(crate) handler_id: ProducerId, } impl Notification for ProducerSendNotification { @@ -870,10 +847,17 @@ impl Notification for ProducerSendNotification { } } +#[derive(Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub(crate) struct ConsumerCloseRequestData { + pub(crate) consumer_id: ConsumerId, +} + request_response!( "transport.closeConsumer", ConsumerCloseRequest { - internal: ConsumerInternal, + handler_id: TransportId, + data: ConsumerCloseRequestData, }, (), Some(()), @@ -882,7 +866,7 @@ request_response!( request_response!( "consumer.dump", ConsumerDumpRequest { - internal: ConsumerInternal, + handler_id: ConsumerId, }, ConsumerDump, ); @@ -890,7 +874,7 @@ request_response!( request_response!( "consumer.getStats", ConsumerGetStatsRequest { - internal: ConsumerInternal, + handler_id: ConsumerId, }, ConsumerStats, ); @@ -898,21 +882,21 @@ request_response!( request_response!( "consumer.pause", ConsumerPauseRequest { - internal: ConsumerInternal, + handler_id: ConsumerId, }, ); request_response!( "consumer.resume", ConsumerResumeRequest { - internal: ConsumerInternal, + handler_id: ConsumerId, }, ); request_response!( "consumer.setPreferredLayers", ConsumerSetPreferredLayersRequest { - internal: ConsumerInternal, + handler_id: ConsumerId, data: ConsumerLayers, }, Option, @@ -927,7 +911,7 @@ pub(crate) struct ConsumerSetPriorityData { request_response!( "consumer.setPriority", ConsumerSetPriorityRequest { - internal: ConsumerInternal, + handler_id: ConsumerId, data: ConsumerSetPriorityData, }, ConsumerSetPriorityResponse { priority: u8 }, @@ -936,7 +920,7 @@ request_response!( request_response!( "consumer.requestKeyFrame", ConsumerRequestKeyFrameRequest { - internal: ConsumerInternal, + handler_id: ConsumerId, }, ); @@ -949,15 +933,22 @@ pub(crate) struct ConsumerEnableTraceEventData { request_response!( "consumer.enableTraceEvent", ConsumerEnableTraceEventRequest { - internal: ConsumerInternal, + handler_id: ConsumerId, data: ConsumerEnableTraceEventData, }, ); +#[derive(Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub(crate) struct DataProducerCloseRequestData { + pub(crate) data_producer_id: DataProducerId, +} + request_response!( "transport.closeDataProducer", DataProducerCloseRequest { - internal: DataProducerInternal, + handler_id: TransportId, + data: DataProducerCloseRequestData, }, (), Some(()), @@ -966,7 +957,7 @@ request_response!( request_response!( "dataProducer.dump", DataProducerDumpRequest { - internal: DataProducerInternal, + handler_id: DataProducerId, }, DataProducerDump, ); @@ -974,7 +965,7 @@ request_response!( request_response!( "dataProducer.getStats", DataProducerGetStatsRequest { - internal: DataProducerInternal, + handler_id: DataProducerId, }, Vec, ); @@ -986,8 +977,9 @@ pub(crate) struct DataProducerSendData { } #[derive(Debug, Serialize)] +#[serde(rename_all = "camelCase")] pub(crate) struct DataProducerSendNotification { - pub(crate) internal: DataProducerInternal, + pub(crate) handler_id: DataProducerId, pub(crate) data: DataProducerSendData, } @@ -997,10 +989,17 @@ impl Notification for DataProducerSendNotification { } } +#[derive(Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub(crate) struct DataConsumerCloseRequestData { + pub(crate) data_consumer_id: DataConsumerId, +} + request_response!( "transport.closeDataConsumer", DataConsumerCloseRequest { - internal: DataConsumerInternal + handler_id: TransportId, + data: DataConsumerCloseRequestData, }, (), Some(()), @@ -1009,7 +1008,7 @@ request_response!( request_response!( "dataConsumer.dump", DataConsumerDumpRequest { - internal: DataConsumerInternal, + handler_id: DataConsumerId, }, DataConsumerDump, ); @@ -1017,7 +1016,7 @@ request_response!( request_response!( "dataConsumer.getStats", DataConsumerGetStatsRequest { - internal: DataConsumerInternal, + handler_id: DataConsumerId, }, Vec, ); @@ -1025,7 +1024,7 @@ request_response!( request_response!( "dataConsumer.getBufferedAmount", DataConsumerGetBufferedAmountRequest { - internal: DataConsumerInternal, + handler_id: DataConsumerId, }, DataConsumerGetBufferedAmountResponse { buffered_amount: u32, @@ -1041,7 +1040,7 @@ pub(crate) struct DataConsumerSetBufferedAmountLowThresholdData { request_response!( "dataConsumer.setBufferedAmountLowThreshold", DataConsumerSetBufferedAmountLowThresholdRequest { - internal: DataConsumerInternal, + handler_id: DataConsumerId, data: DataConsumerSetBufferedAmountLowThresholdData, }, ); @@ -1055,15 +1054,22 @@ pub(crate) struct DataConsumerSendRequestData { request_response!( "dataConsumer.send", DataConsumerSendRequest { - internal: DataConsumerInternal, + handler_id: DataConsumerId, data: DataConsumerSendRequestData, }, ); +#[derive(Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub(crate) struct RtpObserverCloseRequestData { + pub(crate) rtp_observer_id: RtpObserverId, +} + request_response!( "router.closeRtpObserver", RtpObserverCloseRequest { - internal: RtpObserverInternal, + handler_id: RouterId, + data: RtpObserverCloseRequestData, }, (), Some(()), @@ -1072,14 +1078,14 @@ request_response!( request_response!( "rtpObserver.pause", RtpObserverPauseRequest { - internal: RtpObserverInternal, + handler_id: RtpObserverId, }, ); request_response!( "rtpObserver.resume", RtpObserverResumeRequest { - internal: RtpObserverInternal, + handler_id: RtpObserverId, }, ); @@ -1092,7 +1098,7 @@ pub(crate) struct RtpObserverAddRemoveProducerRequestData { request_response!( "rtpObserver.addProducer", RtpObserverAddProducerRequest { - internal: RtpObserverInternal, + handler_id: RtpObserverId, data: RtpObserverAddRemoveProducerRequestData, }, ); @@ -1100,7 +1106,7 @@ request_response!( request_response!( "rtpObserver.removeProducer", RtpObserverRemoveProducerRequest { - internal: RtpObserverInternal, + handler_id: RtpObserverId, data: RtpObserverAddRemoveProducerRequestData, }, ); diff --git a/rust/src/router.rs b/rust/src/router.rs index da86995d48..b1d2d3b764 100644 --- a/rust/src/router.rs +++ b/rust/src/router.rs @@ -31,13 +31,13 @@ use crate::data_producer::{ use crate::data_structures::{AppData, ListenIp}; use crate::direct_transport::{DirectTransport, DirectTransportOptions}; use crate::messages::{ - RouterCloseRequest, RouterCreateActiveSpeakerObserverData, + RouterCloseRequest, RouterCloseRequestData, RouterCreateActiveSpeakerObserverData, RouterCreateActiveSpeakerObserverRequest, RouterCreateAudioLevelObserverData, RouterCreateAudioLevelObserverRequest, RouterCreateDirectTransportData, RouterCreateDirectTransportRequest, RouterCreatePipeTransportData, RouterCreatePipeTransportRequest, RouterCreatePlainTransportData, RouterCreatePlainTransportRequest, RouterCreateWebrtcTransportData, - RouterCreateWebrtcTransportRequest, RouterDumpRequest, RouterInternal, + RouterCreateWebrtcTransportRequest, RouterDumpRequest, }; use crate::pipe_transport::{ PipeTransport, PipeTransportOptions, PipeTransportRemoteParameters, WeakPipeTransport, @@ -398,7 +398,7 @@ impl Inner { { let channel = self.channel.clone(); let request = RouterCloseRequest { - internal: RouterInternal { router_id: self.id }, + data: RouterCloseRequestData { router_id: self.id }, }; self.executor .spawn(async move { @@ -536,9 +536,7 @@ impl Router { self.inner .channel .request(RouterDumpRequest { - internal: RouterInternal { - router_id: self.inner.id, - }, + handler_id: self.inner.id, }) .await } @@ -569,9 +567,7 @@ impl Router { self.inner .channel .request(RouterCreateDirectTransportRequest { - internal: RouterInternal { - router_id: self.inner.id, - }, + handler_id: self.inner.id, data: RouterCreateDirectTransportData::from_options( transport_id, &direct_transport_options, @@ -632,9 +628,7 @@ impl Router { .inner .channel .request(RouterCreateWebrtcTransportRequest { - internal: RouterInternal { - router_id: self.inner.id, - }, + handler_id: self.inner.id, data: RouterCreateWebrtcTransportData::from_options( transport_id, &webrtc_transport_options, @@ -698,9 +692,7 @@ impl Router { .inner .channel .request(RouterCreatePipeTransportRequest { - internal: RouterInternal { - router_id: self.inner.id, - }, + handler_id: self.inner.id, data: RouterCreatePipeTransportData::from_options( transport_id, &pipe_transport_options, @@ -760,9 +752,7 @@ impl Router { .inner .channel .request(RouterCreatePlainTransportRequest { - internal: RouterInternal { - router_id: self.inner.id, - }, + handler_id: self.inner.id, data: RouterCreatePlainTransportData::from_options( transport_id, &plain_transport_options, @@ -827,9 +817,7 @@ impl Router { self.inner .channel .request(RouterCreateAudioLevelObserverRequest { - internal: RouterInternal { - router_id: self.inner.id, - }, + handler_id: self.inner.id, data: RouterCreateAudioLevelObserverData::from_options( rtp_observer_id, &audio_level_observer_options, @@ -887,9 +875,7 @@ impl Router { self.inner .channel .request(RouterCreateActiveSpeakerObserverRequest { - internal: RouterInternal { - router_id: self.inner.id, - }, + handler_id: self.inner.id, data: RouterCreateActiveSpeakerObserverData::from_options( rtp_observer_id, &active_speaker_observer_options, diff --git a/rust/src/router/active_speaker_observer.rs b/rust/src/router/active_speaker_observer.rs index ef7ea4956b..e70603507a 100644 --- a/rust/src/router/active_speaker_observer.rs +++ b/rust/src/router/active_speaker_observer.rs @@ -4,7 +4,7 @@ mod tests; use crate::data_structures::AppData; use crate::messages::{ RtpObserverAddProducerRequest, RtpObserverAddRemoveProducerRequestData, - RtpObserverCloseRequest, RtpObserverInternal, RtpObserverPauseRequest, + RtpObserverCloseRequest, RtpObserverCloseRequestData, RtpObserverPauseRequest, RtpObserverRemoveProducerRequest, RtpObserverResumeRequest, }; use crate::producer::{Producer, ProducerId}; @@ -109,8 +109,8 @@ impl Inner { if close_request { let channel = self.channel.clone(); let request = RtpObserverCloseRequest { - internal: RtpObserverInternal { - router_id: self.router.id(), + handler_id: self.router.id(), + data: RtpObserverCloseRequestData { rtp_observer_id: self.id, }, }; @@ -179,7 +179,7 @@ impl RtpObserver for ActiveSpeakerObserver { self.inner .channel .request(RtpObserverPauseRequest { - internal: self.get_internal(), + handler_id: self.id(), }) .await?; @@ -198,7 +198,7 @@ impl RtpObserver for ActiveSpeakerObserver { self.inner .channel .request(RtpObserverResumeRequest { - internal: self.get_internal(), + handler_id: self.id(), }) .await?; @@ -224,7 +224,7 @@ impl RtpObserver for ActiveSpeakerObserver { self.inner .channel .request(RtpObserverAddProducerRequest { - internal: self.get_internal(), + handler_id: self.id(), data: RtpObserverAddRemoveProducerRequestData { producer_id }, }) .await?; @@ -244,7 +244,7 @@ impl RtpObserver for ActiveSpeakerObserver { self.inner .channel .request(RtpObserverRemoveProducerRequest { - internal: self.get_internal(), + handler_id: self.id(), data: RtpObserverAddRemoveProducerRequestData { producer_id }, }) .await?; @@ -381,13 +381,6 @@ impl ActiveSpeakerObserver { 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 diff --git a/rust/src/router/audio_level_observer.rs b/rust/src/router/audio_level_observer.rs index 9f34f9bcb2..6d9093b500 100644 --- a/rust/src/router/audio_level_observer.rs +++ b/rust/src/router/audio_level_observer.rs @@ -4,7 +4,7 @@ mod tests; use crate::data_structures::AppData; use crate::messages::{ RtpObserverAddProducerRequest, RtpObserverAddRemoveProducerRequestData, - RtpObserverCloseRequest, RtpObserverInternal, RtpObserverPauseRequest, + RtpObserverCloseRequest, RtpObserverCloseRequestData, RtpObserverPauseRequest, RtpObserverRemoveProducerRequest, RtpObserverResumeRequest, }; use crate::producer::{Producer, ProducerId}; @@ -120,8 +120,8 @@ impl Inner { if close_request { let channel = self.channel.clone(); let request = RtpObserverCloseRequest { - internal: RtpObserverInternal { - router_id: self.router.id(), + handler_id: self.router.id(), + data: RtpObserverCloseRequestData { rtp_observer_id: self.id, }, }; @@ -190,7 +190,7 @@ impl RtpObserver for AudioLevelObserver { self.inner .channel .request(RtpObserverPauseRequest { - internal: self.get_internal(), + handler_id: self.id(), }) .await?; @@ -209,7 +209,7 @@ impl RtpObserver for AudioLevelObserver { self.inner .channel .request(RtpObserverResumeRequest { - internal: self.get_internal(), + handler_id: self.id(), }) .await?; @@ -235,7 +235,7 @@ impl RtpObserver for AudioLevelObserver { self.inner .channel .request(RtpObserverAddProducerRequest { - internal: self.get_internal(), + handler_id: self.id(), data: RtpObserverAddRemoveProducerRequestData { producer_id }, }) .await?; @@ -255,7 +255,7 @@ impl RtpObserver for AudioLevelObserver { self.inner .channel .request(RtpObserverRemoveProducerRequest { - internal: self.get_internal(), + handler_id: self.id(), data: RtpObserverAddRemoveProducerRequestData { producer_id }, }) .await?; @@ -405,13 +405,6 @@ impl AudioLevelObserver { 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 diff --git a/rust/src/router/consumer.rs b/rust/src/router/consumer.rs index cf11d9f9ad..fd9ef40ec8 100644 --- a/rust/src/router/consumer.rs +++ b/rust/src/router/consumer.rs @@ -3,8 +3,8 @@ mod tests; use crate::data_structures::{AppData, RtpPacketTraceInfo, SsrcTraceInfo, TraceEventDirection}; use crate::messages::{ - ConsumerCloseRequest, ConsumerDumpRequest, ConsumerEnableTraceEventData, - ConsumerEnableTraceEventRequest, ConsumerGetStatsRequest, ConsumerInternal, + ConsumerCloseRequest, ConsumerCloseRequestData, ConsumerDumpRequest, + ConsumerEnableTraceEventData, ConsumerEnableTraceEventRequest, ConsumerGetStatsRequest, ConsumerPauseRequest, ConsumerRequestKeyFrameRequest, ConsumerResumeRequest, ConsumerSetPreferredLayersRequest, ConsumerSetPriorityData, ConsumerSetPriorityRequest, }; @@ -405,9 +405,8 @@ impl Inner { if close_request { let channel = self.channel.clone(); let request = ConsumerCloseRequest { - internal: ConsumerInternal { - router_id: self.transport.router().id(), - transport_id: self.transport.id(), + handler_id: self.transport.id(), + data: ConsumerCloseRequestData { consumer_id: self.id, }, }; @@ -717,7 +716,7 @@ impl Consumer { self.inner .channel .request(ConsumerDumpRequest { - internal: self.get_internal(), + handler_id: self.id(), }) .await } @@ -732,7 +731,7 @@ impl Consumer { self.inner .channel .request(ConsumerGetStatsRequest { - internal: self.get_internal(), + handler_id: self.id(), }) .await } @@ -744,7 +743,7 @@ impl Consumer { self.inner .channel .request(ConsumerPauseRequest { - internal: self.get_internal(), + handler_id: self.id(), }) .await?; @@ -766,7 +765,7 @@ impl Consumer { self.inner .channel .request(ConsumerResumeRequest { - internal: self.get_internal(), + handler_id: self.id(), }) .await?; @@ -793,7 +792,7 @@ impl Consumer { .inner .channel .request(ConsumerSetPreferredLayersRequest { - internal: self.get_internal(), + handler_id: self.id(), data: consumer_layers, }) .await?; @@ -813,7 +812,7 @@ impl Consumer { .inner .channel .request(ConsumerSetPriorityRequest { - internal: self.get_internal(), + handler_id: self.id(), data: ConsumerSetPriorityData { priority }, }) .await?; @@ -833,7 +832,7 @@ impl Consumer { .inner .channel .request(ConsumerSetPriorityRequest { - internal: self.get_internal(), + handler_id: self.id(), data: ConsumerSetPriorityData { priority }, }) .await?; @@ -850,7 +849,7 @@ impl Consumer { self.inner .channel .request(ConsumerRequestKeyFrameRequest { - internal: self.get_internal(), + handler_id: self.id(), }) .await } @@ -865,7 +864,7 @@ impl Consumer { self.inner .channel .request(ConsumerEnableTraceEventRequest { - internal: self.get_internal(), + handler_id: self.id(), data: ConsumerEnableTraceEventData { types }, }) .await @@ -973,14 +972,6 @@ impl Consumer { 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 diff --git a/rust/src/router/data_consumer.rs b/rust/src/router/data_consumer.rs index c546e737fe..c07f8fd531 100644 --- a/rust/src/router/data_consumer.rs +++ b/rust/src/router/data_consumer.rs @@ -4,8 +4,8 @@ mod tests; use crate::data_producer::{DataProducer, DataProducerId, WeakDataProducer}; use crate::data_structures::{AppData, WebRtcMessage}; use crate::messages::{ - DataConsumerCloseRequest, DataConsumerDumpRequest, DataConsumerGetBufferedAmountRequest, - DataConsumerGetStatsRequest, DataConsumerInternal, DataConsumerSendRequest, + DataConsumerCloseRequest, DataConsumerCloseRequestData, DataConsumerDumpRequest, + DataConsumerGetBufferedAmountRequest, DataConsumerGetStatsRequest, DataConsumerSendRequest, DataConsumerSendRequestData, DataConsumerSetBufferedAmountLowThresholdData, DataConsumerSetBufferedAmountLowThresholdRequest, }; @@ -232,9 +232,8 @@ impl Inner { if close_request { let channel = self.channel.clone(); let request = DataConsumerCloseRequest { - internal: DataConsumerInternal { - router_id: self.transport.router().id(), - transport_id: self.transport.id(), + handler_id: self.transport.id(), + data: DataConsumerCloseRequestData { data_consumer_id: self.id, }, }; @@ -533,7 +532,7 @@ impl DataConsumer { self.inner() .channel .request(DataConsumerDumpRequest { - internal: self.get_internal(), + handler_id: self.id(), }) .await } @@ -548,7 +547,7 @@ impl DataConsumer { self.inner() .channel .request(DataConsumerGetStatsRequest { - internal: self.get_internal(), + handler_id: self.id(), }) .await } @@ -567,7 +566,7 @@ impl DataConsumer { .inner() .channel .request(DataConsumerGetBufferedAmountRequest { - internal: self.get_internal(), + handler_id: self.id(), }) .await?; @@ -588,7 +587,7 @@ impl DataConsumer { self.inner() .channel .request(DataConsumerSetBufferedAmountLowThresholdRequest { - internal: self.get_internal(), + handler_id: self.id(), data: DataConsumerSetBufferedAmountLowThresholdData { threshold }, }) .await @@ -675,14 +674,6 @@ impl DataConsumer { 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 { @@ -694,11 +685,7 @@ impl DirectDataConsumer { .payload_channel .request( DataConsumerSendRequest { - internal: DataConsumerInternal { - router_id: self.inner.transport.router().id(), - transport_id: self.inner.transport.id(), - data_consumer_id: self.inner.id, - }, + handler_id: self.inner.id, data: DataConsumerSendRequestData { ppid }, }, payload.into_owned(), diff --git a/rust/src/router/data_producer.rs b/rust/src/router/data_producer.rs index 00c5fc961e..7c1c33649f 100644 --- a/rust/src/router/data_producer.rs +++ b/rust/src/router/data_producer.rs @@ -3,8 +3,8 @@ mod tests; use crate::data_structures::{AppData, WebRtcMessage}; use crate::messages::{ - DataProducerCloseRequest, DataProducerDumpRequest, DataProducerGetStatsRequest, - DataProducerInternal, DataProducerSendData, DataProducerSendNotification, + DataProducerCloseRequest, DataProducerCloseRequestData, DataProducerDumpRequest, + DataProducerGetStatsRequest, DataProducerSendData, DataProducerSendNotification, }; use crate::sctp_parameters::SctpStreamParameters; use crate::transport::Transport; @@ -163,9 +163,8 @@ impl Inner { if close_request { let channel = self.channel.clone(); let request = DataProducerCloseRequest { - internal: DataProducerInternal { - router_id: self.transport.router().id(), - transport_id: self.transport.id(), + handler_id: self.transport.id(), + data: DataProducerCloseRequestData { data_producer_id: self.id, }, }; @@ -374,7 +373,7 @@ impl DataProducer { self.inner() .channel .request(DataProducerDumpRequest { - internal: self.get_internal(), + handler_id: self.id(), }) .await } @@ -389,7 +388,7 @@ impl DataProducer { self.inner() .channel .request(DataProducerGetStatsRequest { - internal: self.get_internal(), + handler_id: self.id(), }) .await } @@ -433,14 +432,6 @@ impl DataProducer { 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 { @@ -450,11 +441,7 @@ impl DirectDataProducer { self.inner.payload_channel.notify( DataProducerSendNotification { - internal: DataProducerInternal { - router_id: self.inner.transport.router().id(), - transport_id: self.inner.transport.id(), - data_producer_id: self.inner.id, - }, + handler_id: self.inner.id, data: DataProducerSendData { ppid }, }, payload.into_owned(), diff --git a/rust/src/router/direct_transport.rs b/rust/src/router/direct_transport.rs index 6a78be5deb..cea05375d9 100644 --- a/rust/src/router/direct_transport.rs +++ b/rust/src/router/direct_transport.rs @@ -5,7 +5,9 @@ use crate::consumer::{Consumer, ConsumerId, ConsumerOptions}; use crate::data_consumer::{DataConsumer, DataConsumerId, DataConsumerOptions, DataConsumerType}; use crate::data_producer::{DataProducer, DataProducerId, DataProducerOptions, DataProducerType}; 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::router::transport::{TransportImpl, TransportType}; use crate::router::Router; @@ -170,8 +172,8 @@ impl Inner { if close_request { let channel = self.channel.clone(); let request = TransportCloseRequest { - internal: TransportInternal { - router_id: self.router.id(), + handler_id: self.router.id(), + data: TransportCloseRequestData { transport_id: self.id, }, }; @@ -518,7 +520,7 @@ impl DirectTransport { pub fn send_rtcp(&self, rtcp_packet: Vec) -> Result<(), NotificationError> { self.inner.payload_channel.notify( TransportSendRtcpNotification { - internal: self.get_internal(), + handler_id: self.id(), }, rtcp_packet, ) @@ -536,13 +538,6 @@ impl DirectTransport { 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 diff --git a/rust/src/router/pipe_transport.rs b/rust/src/router/pipe_transport.rs index a890929b04..1a786415cb 100644 --- a/rust/src/router/pipe_transport.rs +++ b/rust/src/router/pipe_transport.rs @@ -6,8 +6,8 @@ use crate::data_consumer::{DataConsumer, DataConsumerId, DataConsumerOptions, Da use crate::data_producer::{DataProducer, DataProducerId, DataProducerOptions, DataProducerType}; use crate::data_structures::{AppData, ListenIp, SctpState, TransportTuple}; use crate::messages::{ - PipeTransportData, TransportCloseRequest, TransportConnectPipeRequest, - TransportConnectRequestPipeData, TransportInternal, + PipeTransportData, TransportCloseRequest, TransportCloseRequestData, + TransportConnectPipeRequest, TransportConnectRequestPipeData, }; use crate::producer::{Producer, ProducerId, ProducerOptions}; use crate::router::transport::{TransportImpl, TransportType}; @@ -221,8 +221,8 @@ impl Inner { if close_request { let channel = self.channel.clone(); let request = TransportCloseRequest { - internal: TransportInternal { - router_id: self.router.id(), + handler_id: self.router.id(), + data: TransportCloseRequestData { transport_id: self.id, }, }; @@ -559,7 +559,7 @@ impl PipeTransport { .inner .channel .request(TransportConnectPipeRequest { - internal: self.get_internal(), + handler_id: self.id(), data: TransportConnectRequestPipeData { ip: remote_parameters.ip, port: remote_parameters.port, @@ -641,13 +641,6 @@ impl PipeTransport { 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 diff --git a/rust/src/router/plain_transport.rs b/rust/src/router/plain_transport.rs index c59602430f..fed8a555f0 100644 --- a/rust/src/router/plain_transport.rs +++ b/rust/src/router/plain_transport.rs @@ -6,8 +6,8 @@ use crate::data_consumer::{DataConsumer, DataConsumerId, DataConsumerOptions, Da use crate::data_producer::{DataProducer, DataProducerId, DataProducerOptions, DataProducerType}; use crate::data_structures::{AppData, ListenIp, SctpState, TransportTuple}; use crate::messages::{ - PlainTransportData, TransportCloseRequest, TransportConnectPlainRequest, - TransportConnectRequestPlainData, TransportInternal, + PlainTransportData, TransportCloseRequest, TransportCloseRequestData, + TransportConnectPlainRequest, TransportConnectRequestPlainData, }; use crate::producer::{Producer, ProducerId, ProducerOptions}; use crate::router::transport::{TransportImpl, TransportType}; @@ -258,8 +258,8 @@ impl Inner { if close_request { let channel = self.channel.clone(); let request = TransportCloseRequest { - internal: TransportInternal { - router_id: self.router.id(), + handler_id: self.router.id(), + data: TransportCloseRequestData { transport_id: self.id, }, }; @@ -694,7 +694,7 @@ impl PlainTransport { .inner .channel .request(TransportConnectPlainRequest { - internal: self.get_internal(), + handler_id: self.inner.id, data: TransportConnectRequestPlainData { ip: remote_parameters.ip, port: remote_parameters.port, @@ -816,13 +816,6 @@ impl PlainTransport { 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 diff --git a/rust/src/router/producer.rs b/rust/src/router/producer.rs index f0d7d1aff3..62cc280387 100644 --- a/rust/src/router/producer.rs +++ b/rust/src/router/producer.rs @@ -4,8 +4,8 @@ mod tests; use crate::consumer::RtpStreamParams; use crate::data_structures::{AppData, RtpPacketTraceInfo, SsrcTraceInfo, TraceEventDirection}; use crate::messages::{ - ProducerCloseRequest, ProducerDumpRequest, ProducerEnableTraceEventData, - ProducerEnableTraceEventRequest, ProducerGetStatsRequest, ProducerInternal, + ProducerCloseRequest, ProducerCloseRequestData, ProducerDumpRequest, + ProducerEnableTraceEventData, ProducerEnableTraceEventRequest, ProducerGetStatsRequest, ProducerPauseRequest, ProducerResumeRequest, ProducerSendNotification, }; pub use crate::ortc::RtpMapping; @@ -328,9 +328,8 @@ impl Inner { if close_request { let channel = self.channel.clone(); let request = ProducerCloseRequest { - internal: ProducerInternal { - router_id: self.transport.router().id(), - transport_id: self.transport.id(), + handler_id: self.transport.id(), + data: ProducerCloseRequestData { producer_id: self.id, }, }; @@ -590,7 +589,7 @@ impl Producer { self.inner() .channel .request(ProducerDumpRequest { - internal: self.get_internal(), + handler_id: self.id(), }) .await } @@ -605,7 +604,7 @@ impl Producer { self.inner() .channel .request(ProducerGetStatsRequest { - internal: self.get_internal(), + handler_id: self.id(), }) .await } @@ -619,7 +618,7 @@ impl Producer { self.inner() .channel .request(ProducerPauseRequest { - internal: self.get_internal(), + handler_id: self.id(), }) .await?; @@ -641,7 +640,7 @@ impl Producer { self.inner() .channel .request(ProducerResumeRequest { - internal: self.get_internal(), + handler_id: self.id(), }) .await?; @@ -664,7 +663,7 @@ impl Producer { self.inner() .channel .request(ProducerEnableTraceEventRequest { - internal: self.get_internal(), + handler_id: self.id(), data: ProducerEnableTraceEventData { types }, }) .await @@ -756,14 +755,6 @@ impl Producer { 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 { @@ -771,11 +762,7 @@ impl DirectProducer { pub fn send(&self, rtp_packet: Vec) -> Result<(), NotificationError> { self.inner.payload_channel.notify( ProducerSendNotification { - internal: ProducerInternal { - router_id: self.inner.transport.router().id(), - transport_id: self.inner.transport.id(), - producer_id: self.inner.id, - }, + handler_id: self.inner.id, }, rtp_packet, ) diff --git a/rust/src/router/transport.rs b/rust/src/router/transport.rs index 1cae52b72e..44786dc296 100644 --- a/rust/src/router/transport.rs +++ b/rust/src/router/transport.rs @@ -3,14 +3,12 @@ use crate::data_consumer::{DataConsumer, DataConsumerId, DataConsumerOptions, Da use crate::data_producer::{DataProducer, DataProducerId, DataProducerOptions, DataProducerType}; use crate::data_structures::{AppData, BweTraceInfo, RtpPacketTraceInfo, TraceEventDirection}; use crate::messages::{ - ConsumerInternal, DataConsumerInternal, DataProducerInternal, ProducerInternal, TransportConsumeData, TransportConsumeDataData, TransportConsumeDataRequest, TransportConsumeRequest, TransportDumpRequest, TransportEnableTraceEventData, - TransportEnableTraceEventRequest, TransportGetStatsRequest, TransportInternal, - TransportProduceData, TransportProduceDataData, TransportProduceDataRequest, - TransportProduceRequest, TransportSetMaxIncomingBitrateData, - TransportSetMaxIncomingBitrateRequest, TransportSetMaxOutgoingBitrateData, - TransportSetMaxOutgoingBitrateRequest, + TransportEnableTraceEventRequest, TransportGetStatsRequest, TransportProduceData, + TransportProduceDataData, TransportProduceDataRequest, TransportProduceRequest, + TransportSetMaxIncomingBitrateData, TransportSetMaxIncomingBitrateRequest, + TransportSetMaxOutgoingBitrateData, TransportSetMaxOutgoingBitrateRequest, }; pub use crate::ortc::{ ConsumerRtpParametersError, RtpCapabilitiesError, RtpParametersError, RtpParametersMappingError, @@ -369,10 +367,7 @@ pub(super) trait TransportImpl: TransportGeneric { async fn dump_impl(&self) -> Result { self.channel() .request(TransportDumpRequest { - internal: TransportInternal { - router_id: self.router().id(), - transport_id: self.id(), - }, + handler_id: self.id(), }) .await } @@ -380,10 +375,7 @@ pub(super) trait TransportImpl: TransportGeneric { async fn get_stats_impl(&self) -> Result { self.channel() .request(TransportGetStatsRequest { - internal: TransportInternal { - router_id: self.router().id(), - transport_id: self.id(), - }, + handler_id: self.id(), }) .await } @@ -391,10 +383,7 @@ pub(super) trait TransportImpl: TransportGeneric { async fn set_max_incoming_bitrate_impl(&self, bitrate: u32) -> Result<(), RequestError> { self.channel() .request(TransportSetMaxIncomingBitrateRequest { - internal: TransportInternal { - router_id: self.router().id(), - transport_id: self.id(), - }, + handler_id: self.id(), data: TransportSetMaxIncomingBitrateData { bitrate }, }) .await @@ -403,10 +392,7 @@ pub(super) trait TransportImpl: TransportGeneric { async fn set_max_outgoing_bitrate_impl(&self, bitrate: u32) -> Result<(), RequestError> { self.channel() .request(TransportSetMaxOutgoingBitrateRequest { - internal: TransportInternal { - router_id: self.router().id(), - transport_id: self.id(), - }, + handler_id: self.id(), data: TransportSetMaxOutgoingBitrateData { bitrate }, }) .await @@ -418,10 +404,7 @@ pub(super) trait TransportImpl: TransportGeneric { ) -> Result<(), RequestError> { self.channel() .request(TransportEnableTraceEventRequest { - internal: TransportInternal { - router_id: self.router().id(), - transport_id: self.id(), - }, + handler_id: self.id(), data: TransportEnableTraceEventData { types }, }) .await @@ -496,12 +479,9 @@ pub(super) trait TransportImpl: TransportGeneric { let response = self .channel() .request(TransportProduceRequest { - internal: ProducerInternal { - router_id: self.router().id(), - transport_id: self.id(), - producer_id, - }, + handler_id: self.id(), data: TransportProduceData { + producer_id, kind, rtp_parameters: rtp_parameters.clone(), rtp_mapping, @@ -594,12 +574,9 @@ pub(super) trait TransportImpl: TransportGeneric { let response = self .channel() .request(TransportConsumeRequest { - internal: ConsumerInternal { - router_id: self.router().id(), - transport_id: self.id(), - consumer_id, - }, + handler_id: self.id(), data: TransportConsumeData { + consumer_id, producer_id: producer.id(), kind: producer.kind(), rtp_parameters: rtp_parameters.clone(), @@ -675,12 +652,9 @@ pub(super) trait TransportImpl: TransportGeneric { let response = self .channel() .request(TransportProduceDataRequest { - internal: DataProducerInternal { - router_id: self.router().id(), - transport_id: self.id(), - data_producer_id, - }, + handler_id: self.id(), data: TransportProduceDataData { + data_producer_id, r#type, sctp_stream_parameters, label, @@ -763,12 +737,9 @@ pub(super) trait TransportImpl: TransportGeneric { let response = self .channel() .request(TransportConsumeDataRequest { - internal: DataConsumerInternal { - router_id: self.router().id(), - transport_id: self.id(), - data_consumer_id, - }, + handler_id: self.id(), data: TransportConsumeDataData { + data_consumer_id, data_producer_id: data_producer.id(), r#type, sctp_stream_parameters, diff --git a/rust/src/router/webrtc_transport.rs b/rust/src/router/webrtc_transport.rs index 54e5627fb9..68e9bf7c49 100644 --- a/rust/src/router/webrtc_transport.rs +++ b/rust/src/router/webrtc_transport.rs @@ -9,8 +9,8 @@ use crate::data_structures::{ SctpState, TransportTuple, }; use crate::messages::{ - TransportCloseRequest, TransportConnectRequestWebRtcData, TransportConnectWebRtcRequest, - TransportInternal, TransportRestartIceRequest, WebRtcTransportData, + TransportCloseRequest, TransportCloseRequestData, TransportConnectRequestWebRtcData, + TransportConnectWebRtcRequest, TransportRestartIceRequest, WebRtcTransportData, }; use crate::producer::{Producer, ProducerId, ProducerOptions}; use crate::router::transport::{TransportImpl, TransportType}; @@ -345,8 +345,8 @@ impl Inner { if close_request { let channel = self.channel.clone(); let request = TransportCloseRequest { - internal: TransportInternal { - router_id: self.router.id(), + handler_id: self.router.id(), + data: TransportCloseRequestData { transport_id: self.id, }, }; @@ -763,7 +763,7 @@ impl WebRtcTransport { .inner .channel .request(TransportConnectWebRtcRequest { - internal: self.get_internal(), + handler_id: self.id(), data: TransportConnectRequestWebRtcData { dtls_parameters: remote_parameters.dtls_parameters, }, @@ -870,7 +870,7 @@ impl WebRtcTransport { .inner .channel .request(TransportRestartIceRequest { - internal: self.get_internal(), + handler_id: self.id(), }) .await?; @@ -937,13 +937,6 @@ impl WebRtcTransport { 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 diff --git a/rust/src/webrtc_server.rs b/rust/src/webrtc_server.rs index 435ab69dd0..8316e3f6b0 100644 --- a/rust/src/webrtc_server.rs +++ b/rust/src/webrtc_server.rs @@ -11,7 +11,9 @@ mod tests; 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::uuid_based_wrapper_type; use crate::webrtc_transport::WebRtcTransport; @@ -185,7 +187,7 @@ impl Inner { { let channel = self.channel.clone(); let request = WebRtcServerCloseRequest { - internal: WebRtcServerInternal { + data: WebRtcServerCloseRequestData { webrtc_server_id: self.id, }, }; @@ -294,9 +296,7 @@ impl WebRtcServer { self.inner .channel .request(WebRtcServerDumpRequest { - internal: WebRtcServerInternal { - webrtc_server_id: self.inner.id, - }, + handler_id: self.id(), }) .await } diff --git a/worker/include/Channel/ChannelRequest.hpp b/worker/include/Channel/ChannelRequest.hpp index 86d06f0c29..5f4cc9a5f9 100644 --- a/worker/include/Channel/ChannelRequest.hpp +++ b/worker/include/Channel/ChannelRequest.hpp @@ -96,7 +96,7 @@ namespace Channel uint32_t id{ 0u }; std::string method; MethodId methodId; - json internal; + std::string handlerId; json data; // Others. bool replied{ false }; diff --git a/worker/include/PayloadChannel/Notification.hpp b/worker/include/PayloadChannel/Notification.hpp index 585a6704e9..6109e0539b 100644 --- a/worker/include/PayloadChannel/Notification.hpp +++ b/worker/include/PayloadChannel/Notification.hpp @@ -37,7 +37,7 @@ namespace PayloadChannel // Passed by argument. std::string event; EventId eventId; - json internal; + std::string handlerId; json data; const uint8_t* payload{ nullptr }; size_t payloadLen{ 0u }; diff --git a/worker/include/PayloadChannel/PayloadChannelRequest.hpp b/worker/include/PayloadChannel/PayloadChannelRequest.hpp index c4e44ee0d6..ad628c798a 100644 --- a/worker/include/PayloadChannel/PayloadChannelRequest.hpp +++ b/worker/include/PayloadChannel/PayloadChannelRequest.hpp @@ -45,7 +45,7 @@ namespace PayloadChannel uint32_t id{ 0u }; std::string method; MethodId methodId; - json internal; + std::string handlerId; json data; const uint8_t* payload{ nullptr }; size_t payloadLen{ 0u }; diff --git a/worker/include/RTC/Router.hpp b/worker/include/RTC/Router.hpp index d136b607ce..851aad1a43 100644 --- a/worker/include/RTC/Router.hpp +++ b/worker/include/RTC/Router.hpp @@ -25,9 +25,7 @@ namespace RTC { class Router : public RTC::Transport::Listener, public RTC::RtpObserver::Listener, - public Channel::ChannelSocket::RequestHandler, - public PayloadChannel::PayloadChannelSocket::RequestHandler, - public PayloadChannel::PayloadChannelSocket::NotificationHandler + public Channel::ChannelSocket::RequestHandler { public: class Listener @@ -60,20 +58,11 @@ namespace RTC public: 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: void SetNewTransportIdFromData(json& data, std::string& transportId) const; - RTC::Transport* GetTransportFromInternal(json& internal) const; + RTC::Transport* GetTransportFromData(json& data) const; void SetNewRtpObserverIdFromData(json& data, std::string& rtpObserverId) const; - RTC::RtpObserver* GetRtpObserverFromInternal(json& internal) const; - RTC::Producer* GetProducerFromData(json& data) const; + RTC::RtpObserver* GetRtpObserverFromData(json& data) const; /* Pure virtual methods inherited from RTC::Transport::Listener. */ public: diff --git a/worker/include/RTC/Transport.hpp b/worker/include/RTC/Transport.hpp index 96ef06f574..bc4876d227 100644 --- a/worker/include/RTC/Transport.hpp +++ b/worker/include/RTC/Transport.hpp @@ -156,16 +156,16 @@ namespace RTC void ReceiveRtpPacket(RTC::RtpPacket* packet); void ReceiveRtcpPacket(RTC::RTCP::Packet* packet); void ReceiveSctpData(const uint8_t* data, size_t len); - void SetNewProducerIdFromInternal(json& internal, std::string& producerId) const; - RTC::Producer* GetProducerFromInternal(json& internal) const; - void SetNewConsumerIdFromInternal(json& internal, std::string& consumerId) const; - RTC::Consumer* GetConsumerFromInternal(json& internal) const; + void SetNewProducerIdFromData(json& data, std::string& producerId) const; + RTC::Producer* GetProducerFromData(json& data) const; + void SetNewConsumerIdFromData(json& data, std::string& consumerId) const; + RTC::Consumer* GetConsumerFromData(json& data) const; RTC::Consumer* GetConsumerByMediaSsrc(uint32_t ssrc) const; RTC::Consumer* GetConsumerByRtxSsrc(uint32_t ssrc) const; - void SetNewDataProducerIdFromInternal(json& internal, std::string& dataProducerId) const; - RTC::DataProducer* GetDataProducerFromInternal(json& internal) const; - void SetNewDataConsumerIdFromInternal(json& internal, std::string& dataConsumerId) const; - RTC::DataConsumer* GetDataConsumerFromInternal(json& internal) const; + void SetNewDataProducerIdFromData(json& data, std::string& dataProducerId) const; + RTC::DataProducer* GetDataProducerFromData(json& data) const; + void SetNewDataConsumerIdFromData(json& data, std::string& dataConsumerId) const; + RTC::DataConsumer* GetDataConsumerFromData(json& data) const; private: virtual bool IsConnected() const = 0; diff --git a/worker/include/Worker.hpp b/worker/include/Worker.hpp index 0f49bcdbcf..c3beb5f466 100644 --- a/worker/include/Worker.hpp +++ b/worker/include/Worker.hpp @@ -30,9 +30,9 @@ class Worker : public Channel::ChannelSocket::Listener, void FillJson(json& jsonObject) const; void FillJsonResourceUsage(json& jsonObject) const; void SetNewWebRtcServerIdFromData(json& data, std::string& webRtcServerId) const; - RTC::WebRtcServer* GetWebRtcServerFromInternal(json& internal) const; + RTC::WebRtcServer* GetWebRtcServerFromData(json& data) 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. */ public: diff --git a/worker/src/Channel/ChannelRequest.cpp b/worker/src/Channel/ChannelRequest.cpp index fd2de2d65d..c6fcb338b4 100644 --- a/worker/src/Channel/ChannelRequest.cpp +++ b/worker/src/Channel/ChannelRequest.cpp @@ -105,12 +105,10 @@ namespace Channel this->methodId = methodIdIt->second; - auto jsonInternalIt = jsonRequest.find("internal"); + auto jsonHandlerIdIt = jsonRequest.find("handlerId"); - if (jsonInternalIt != jsonRequest.end() && jsonInternalIt->is_object()) - this->internal = *jsonInternalIt; - else - this->internal = json::object(); + if (jsonHandlerIdIt != jsonRequest.end() && jsonHandlerIdIt->is_string()) + this->handlerId = *jsonHandlerIdIt; auto jsonDataIt = jsonRequest.find("data"); diff --git a/worker/src/PayloadChannel/Notification.cpp b/worker/src/PayloadChannel/Notification.cpp index 3f259129e3..c3ee40a170 100644 --- a/worker/src/PayloadChannel/Notification.cpp +++ b/worker/src/PayloadChannel/Notification.cpp @@ -60,12 +60,10 @@ namespace PayloadChannel this->eventId = eventIdIt->second; - auto jsonInternalIt = jsonNotification.find("internal"); + auto jsonHandlerIdIt = jsonNotification.find("handlerId"); - if (jsonInternalIt != jsonNotification.end() && jsonInternalIt->is_object()) - this->internal = *jsonInternalIt; - else - this->internal = json::object(); + if (jsonHandlerIdIt != jsonNotification.end() && jsonHandlerIdIt->is_string()) + this->handlerId = *jsonHandlerIdIt; auto jsonDataIt = jsonNotification.find("data"); diff --git a/worker/src/PayloadChannel/PayloadChannelRequest.cpp b/worker/src/PayloadChannel/PayloadChannelRequest.cpp index d53a668941..107c6a2871 100644 --- a/worker/src/PayloadChannel/PayloadChannelRequest.cpp +++ b/worker/src/PayloadChannel/PayloadChannelRequest.cpp @@ -69,12 +69,10 @@ namespace PayloadChannel this->methodId = methodIdIt->second; - auto jsonInternalIt = jsonRequest.find("internal"); + auto jsonHandlerIdIt = jsonRequest.find("handlerId"); - if (jsonInternalIt != jsonRequest.end() && jsonInternalIt->is_object()) - this->internal = *jsonInternalIt; - else - this->internal = json::object(); + if (jsonHandlerIdIt != jsonRequest.end() && jsonHandlerIdIt->is_object()) + this->handlerId = *jsonHandlerIdIt; auto jsonDataIt = jsonRequest.find("data"); diff --git a/worker/src/RTC/DirectTransport.cpp b/worker/src/RTC/DirectTransport.cpp index 56fae1a5e6..548ad4dedd 100644 --- a/worker/src/RTC/DirectTransport.cpp +++ b/worker/src/RTC/DirectTransport.cpp @@ -87,26 +87,6 @@ namespace RTC 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: { // Pass it to the parent class. diff --git a/worker/src/RTC/Router.cpp b/worker/src/RTC/Router.cpp index 119eff6038..dc35c6db48 100644 --- a/worker/src/RTC/Router.cpp +++ b/worker/src/RTC/Router.cpp @@ -424,7 +424,7 @@ namespace RTC case Channel::ChannelRequest::MethodId::ROUTER_CLOSE_TRANSPORT: { // This may throw. - RTC::Transport* transport = GetTransportFromInternal(request->internal); + RTC::Transport* transport = GetTransportFromData(request->data); // Tell the Transport to close all its Producers and Consumers so it will // notify us about their closures. @@ -450,7 +450,7 @@ namespace RTC case Channel::ChannelRequest::MethodId::ROUTER_CLOSE_RTP_OBSERVER: { // This may throw. - RTC::RtpObserver* rtpObserver = GetRtpObserverFromInternal(request->internal); + RTC::RtpObserver* rtpObserver = GetRtpObserverFromData(request->data); // Remove it from the map. this->mapRtpObservers.erase(rtpObserver->id); @@ -475,52 +475,13 @@ namespace RTC break; } - case Channel::ChannelRequest::MethodId::RTP_OBSERVER_PAUSE: - case Channel::ChannelRequest::MethodId::RTP_OBSERVER_RESUME: - case Channel::ChannelRequest::MethodId::RTP_OBSERVER_ADD_PRODUCER: - case Channel::ChannelRequest::MethodId::RTP_OBSERVER_REMOVE_PRODUCER: - { - // This may throw. - RTC::RtpObserver* rtpObserver = GetRtpObserverFromInternal(request->internal); - - rtpObserver->HandleRequest(request); - - break; - } - - // Any other request must be delivered to the corresponding Transport. default: { - // This may throw. - RTC::Transport* transport = GetTransportFromInternal(request->internal); - - transport->HandleRequest(request); - - break; + MS_THROW_ERROR("unknown method '%s'", request->method.c_str()); } } } - void Router::HandleRequest(PayloadChannel::PayloadChannelRequest* request) - { - MS_TRACE(); - - // This may throw. - RTC::Transport* transport = GetTransportFromInternal(request->internal); - - transport->HandleRequest(request); - } - - void Router::HandleNotification(PayloadChannel::Notification* notification) - { - MS_TRACE(); - - // This may throw. - RTC::Transport* transport = GetTransportFromInternal(notification->internal); - - transport->HandleNotification(notification); - } - void Router::SetNewTransportIdFromData(json& data, std::string& transportId) const { MS_TRACE(); @@ -540,13 +501,13 @@ namespace RTC } } - RTC::Transport* Router::GetTransportFromInternal(json& internal) const + RTC::Transport* Router::GetTransportFromData(json& data) const { MS_TRACE(); - auto jsonTransportIdIt = internal.find("transportId"); + auto jsonTransportIdIt = data.find("transportId"); - if (jsonTransportIdIt == internal.end() || !jsonTransportIdIt->is_string()) + if (jsonTransportIdIt == data.end() || !jsonTransportIdIt->is_string()) { MS_THROW_TYPE_ERROR("missing transportId"); } @@ -580,13 +541,13 @@ namespace RTC } } - RTC::RtpObserver* Router::GetRtpObserverFromInternal(json& internal) const + RTC::RtpObserver* Router::GetRtpObserverFromData(json& data) const { MS_TRACE(); - auto jsonRtpObserverIdIt = internal.find("rtpObserverId"); + auto jsonRtpObserverIdIt = data.find("rtpObserverId"); - if (jsonRtpObserverIdIt == internal.end() || !jsonRtpObserverIdIt->is_string()) + if (jsonRtpObserverIdIt == data.end() || !jsonRtpObserverIdIt->is_string()) { MS_THROW_TYPE_ERROR("missing rtpObserverId"); } @@ -601,27 +562,6 @@ namespace RTC return rtpObserver; } - RTC::Producer* Router::GetProducerFromData(json& data) const - { - MS_TRACE(); - - auto jsonProducerIdIt = data.find("producerId"); - - if (jsonProducerIdIt == data.end() || !jsonProducerIdIt->is_string()) - { - MS_THROW_TYPE_ERROR("missing producerId"); - } - - auto it = this->mapProducers.find(jsonProducerIdIt->get()); - - if (it == this->mapProducers.end()) - MS_THROW_ERROR("Producer not found"); - - RTC::Producer* producer = it->second; - - return producer; - } - inline void Router::OnTransportNewProducer(RTC::Transport* /*transport*/, RTC::Producer* producer) { MS_TRACE(); diff --git a/worker/src/RTC/Transport.cpp b/worker/src/RTC/Transport.cpp index 9594f9e178..9210f07ba7 100644 --- a/worker/src/RTC/Transport.cpp +++ b/worker/src/RTC/Transport.cpp @@ -672,7 +672,7 @@ namespace RTC std::string producerId; // This may throw. - SetNewProducerIdFromInternal(request->internal, producerId); + SetNewProducerIdFromData(request->data, producerId); // This may throw. auto* producer = new RTC::Producer(producerId, this, request->data); @@ -837,7 +837,7 @@ namespace RTC std::string consumerId; // This may throw. - SetNewConsumerIdFromInternal(request->internal, consumerId); + SetNewConsumerIdFromData(request->data, consumerId); // Get type. auto jsonTypeIt = request->data.find("type"); @@ -1089,7 +1089,7 @@ namespace RTC std::string dataProducerId; // This may throw. - SetNewDataProducerIdFromInternal(request->internal, dataProducerId); + SetNewDataProducerIdFromData(request->data, dataProducerId); // This may throw. auto* dataProducer = @@ -1194,7 +1194,7 @@ namespace RTC std::string dataConsumerId; // This may throw. - SetNewDataConsumerIdFromInternal(request->internal, dataConsumerId); + SetNewDataConsumerIdFromData(request->data, dataConsumerId); // This may throw. auto* dataConsumer = new RTC::DataConsumer( @@ -1310,7 +1310,7 @@ namespace RTC case Channel::ChannelRequest::MethodId::TRANSPORT_CLOSE_PRODUCER: { // This may throw. - RTC::Producer* producer = GetProducerFromInternal(request->internal); + RTC::Producer* producer = GetProducerFromData(request->data); // Remove it from the RtpListener. this->rtpListener.RemoveProducer(producer); @@ -1345,7 +1345,7 @@ namespace RTC case Channel::ChannelRequest::MethodId::TRANSPORT_CLOSE_CONSUMER: { // This may throw. - RTC::Consumer* consumer = GetConsumerFromInternal(request->internal); + RTC::Consumer* consumer = GetConsumerFromData(request->data); // Remove it from the maps. this->mapConsumers.erase(consumer->id); @@ -1383,41 +1383,10 @@ namespace RTC break; } - case Channel::ChannelRequest::MethodId::PRODUCER_DUMP: - case Channel::ChannelRequest::MethodId::PRODUCER_GET_STATS: - case Channel::ChannelRequest::MethodId::PRODUCER_PAUSE: - case Channel::ChannelRequest::MethodId::PRODUCER_RESUME: - case Channel::ChannelRequest::MethodId::PRODUCER_ENABLE_TRACE_EVENT: - { - // This may throw. - RTC::Producer* producer = GetProducerFromInternal(request->internal); - - producer->HandleRequest(request); - - break; - } - - case Channel::ChannelRequest::MethodId::CONSUMER_DUMP: - case Channel::ChannelRequest::MethodId::CONSUMER_GET_STATS: - case Channel::ChannelRequest::MethodId::CONSUMER_PAUSE: - case Channel::ChannelRequest::MethodId::CONSUMER_RESUME: - case Channel::ChannelRequest::MethodId::CONSUMER_SET_PREFERRED_LAYERS: - case Channel::ChannelRequest::MethodId::CONSUMER_SET_PRIORITY: - case Channel::ChannelRequest::MethodId::CONSUMER_REQUEST_KEY_FRAME: - case Channel::ChannelRequest::MethodId::CONSUMER_ENABLE_TRACE_EVENT: - { - // This may throw. - RTC::Consumer* consumer = GetConsumerFromInternal(request->internal); - - consumer->HandleRequest(request); - - break; - } - case Channel::ChannelRequest::MethodId::TRANSPORT_CLOSE_DATA_PRODUCER: { // This may throw. - RTC::DataProducer* dataProducer = GetDataProducerFromInternal(request->internal); + RTC::DataProducer* dataProducer = GetDataProducerFromData(request->data); if (dataProducer->GetType() == RTC::DataProducer::Type::SCTP) { @@ -1450,7 +1419,7 @@ namespace RTC case Channel::ChannelRequest::MethodId::TRANSPORT_CLOSE_DATA_CONSUMER: { // This may throw. - RTC::DataConsumer* dataConsumer = GetDataConsumerFromInternal(request->internal); + RTC::DataConsumer* dataConsumer = GetDataConsumerFromData(request->data); // Remove it from the maps. this->mapDataConsumers.erase(dataConsumer->id); @@ -1474,30 +1443,6 @@ namespace RTC break; } - case Channel::ChannelRequest::MethodId::DATA_PRODUCER_DUMP: - case Channel::ChannelRequest::MethodId::DATA_PRODUCER_GET_STATS: - { - // This may throw. - RTC::DataProducer* dataProducer = GetDataProducerFromInternal(request->internal); - - dataProducer->HandleRequest(request); - - break; - } - - case Channel::ChannelRequest::MethodId::DATA_CONSUMER_DUMP: - case Channel::ChannelRequest::MethodId::DATA_CONSUMER_GET_STATS: - case Channel::ChannelRequest::MethodId::DATA_CONSUMER_GET_BUFFERED_AMOUNT: - case Channel::ChannelRequest::MethodId::DATA_CONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD: - { - // This may throw. - RTC::DataConsumer* dataConsumer = GetDataConsumerFromInternal(request->internal); - - dataConsumer->HandleRequest(request); - - break; - } - default: { MS_THROW_ERROR("unknown method '%s'", request->method.c_str()); @@ -1511,16 +1456,6 @@ namespace RTC switch (request->methodId) { - case PayloadChannel::PayloadChannelRequest::MethodId::DATA_CONSUMER_SEND: - { - // This may throw. - RTC::DataConsumer* dataConsumer = GetDataConsumerFromInternal(request->internal); - - dataConsumer->HandleRequest(request); - - break; - } - default: { MS_THROW_ERROR("unknown method '%s'", request->method.c_str()); @@ -1716,13 +1651,13 @@ namespace RTC this->sctpAssociation->ProcessSctpData(data, len); } - void Transport::SetNewProducerIdFromInternal(json& internal, std::string& producerId) const + void Transport::SetNewProducerIdFromData(json& data, std::string& producerId) const { MS_TRACE(); - auto jsonProducerIdIt = internal.find("producerId"); + auto jsonProducerIdIt = data.find("producerId"); - if (jsonProducerIdIt == internal.end() || !jsonProducerIdIt->is_string()) + if (jsonProducerIdIt == data.end() || !jsonProducerIdIt->is_string()) { MS_THROW_TYPE_ERROR("missing producerId"); } @@ -1735,13 +1670,13 @@ namespace RTC } } - RTC::Producer* Transport::GetProducerFromInternal(json& internal) const + RTC::Producer* Transport::GetProducerFromData(json& data) const { MS_TRACE(); - auto jsonProducerIdIt = internal.find("producerId"); + auto jsonProducerIdIt = data.find("producerId"); - if (jsonProducerIdIt == internal.end() || !jsonProducerIdIt->is_string()) + if (jsonProducerIdIt == data.end() || !jsonProducerIdIt->is_string()) { MS_THROW_TYPE_ERROR("missing producerId"); } @@ -1756,13 +1691,13 @@ namespace RTC return producer; } - void Transport::SetNewConsumerIdFromInternal(json& internal, std::string& consumerId) const + void Transport::SetNewConsumerIdFromData(json& data, std::string& consumerId) const { MS_TRACE(); - auto jsonConsumerIdIt = internal.find("consumerId"); + auto jsonConsumerIdIt = data.find("consumerId"); - if (jsonConsumerIdIt == internal.end() || !jsonConsumerIdIt->is_string()) + if (jsonConsumerIdIt == data.end() || !jsonConsumerIdIt->is_string()) { MS_THROW_TYPE_ERROR("missing consumerId"); } @@ -1775,13 +1710,13 @@ namespace RTC } } - RTC::Consumer* Transport::GetConsumerFromInternal(json& internal) const + RTC::Consumer* Transport::GetConsumerFromData(json& data) const { MS_TRACE(); - auto jsonConsumerIdIt = internal.find("consumerId"); + auto jsonConsumerIdIt = data.find("consumerId"); - if (jsonConsumerIdIt == internal.end() || !jsonConsumerIdIt->is_string()) + if (jsonConsumerIdIt == data.end() || !jsonConsumerIdIt->is_string()) { MS_THROW_TYPE_ERROR("missing consumerId"); } @@ -1824,13 +1759,13 @@ namespace RTC return consumer; } - void Transport::SetNewDataProducerIdFromInternal(json& internal, std::string& dataProducerId) const + void Transport::SetNewDataProducerIdFromData(json& data, std::string& dataProducerId) const { MS_TRACE(); - auto jsonDataProducerIdIt = internal.find("dataProducerId"); + auto jsonDataProducerIdIt = data.find("dataProducerId"); - if (jsonDataProducerIdIt == internal.end() || !jsonDataProducerIdIt->is_string()) + if (jsonDataProducerIdIt == data.end() || !jsonDataProducerIdIt->is_string()) { MS_THROW_TYPE_ERROR("missing dataProducerId"); } @@ -1843,13 +1778,13 @@ namespace RTC } } - RTC::DataProducer* Transport::GetDataProducerFromInternal(json& internal) const + RTC::DataProducer* Transport::GetDataProducerFromData(json& data) const { MS_TRACE(); - auto jsonDataProducerIdIt = internal.find("dataProducerId"); + auto jsonDataProducerIdIt = data.find("dataProducerId"); - if (jsonDataProducerIdIt == internal.end() || !jsonDataProducerIdIt->is_string()) + if (jsonDataProducerIdIt == data.end() || !jsonDataProducerIdIt->is_string()) { MS_THROW_TYPE_ERROR("missing dataProducerId"); } @@ -1864,13 +1799,13 @@ namespace RTC return dataProducer; } - void Transport::SetNewDataConsumerIdFromInternal(json& internal, std::string& dataConsumerId) const + void Transport::SetNewDataConsumerIdFromData(json& data, std::string& dataConsumerId) const { MS_TRACE(); - auto jsonDataConsumerIdIt = internal.find("dataConsumerId"); + auto jsonDataConsumerIdIt = data.find("dataConsumerId"); - if (jsonDataConsumerIdIt == internal.end() || !jsonDataConsumerIdIt->is_string()) + if (jsonDataConsumerIdIt == data.end() || !jsonDataConsumerIdIt->is_string()) { MS_THROW_TYPE_ERROR("missing dataConsumerId"); } @@ -1883,13 +1818,13 @@ namespace RTC } } - RTC::DataConsumer* Transport::GetDataConsumerFromInternal(json& internal) const + RTC::DataConsumer* Transport::GetDataConsumerFromData(json& data) const { MS_TRACE(); - auto jsonDataConsumerIdIt = internal.find("dataConsumerId"); + auto jsonDataConsumerIdIt = data.find("dataConsumerId"); - if (jsonDataConsumerIdIt == internal.end() || !jsonDataConsumerIdIt->is_string()) + if (jsonDataConsumerIdIt == data.end() || !jsonDataConsumerIdIt->is_string()) { MS_THROW_TYPE_ERROR("missing dataConsumerId"); } diff --git a/worker/src/Worker.cpp b/worker/src/Worker.cpp index 0acf4a16b5..af8a591ed6 100644 --- a/worker/src/Worker.cpp +++ b/worker/src/Worker.cpp @@ -197,7 +197,7 @@ void Worker::SetNewWebRtcServerIdFromData(json& data, std::string& webRtcServerI auto jsonWebRtcServerIdIt = data.find("webRtcServerId"); if (jsonWebRtcServerIdIt == data.end() || !jsonWebRtcServerIdIt->is_string()) - MS_THROW_ERROR("missing data.webRtcServerId"); + MS_THROW_ERROR("missing webRtcServerId"); webRtcServerId.assign(jsonWebRtcServerIdIt->get()); @@ -205,14 +205,14 @@ void Worker::SetNewWebRtcServerIdFromData(json& data, std::string& webRtcServerI 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(); - auto jsonWebRtcServerIdIt = internal.find("webRtcServerId"); + auto jsonWebRtcServerIdIt = data.find("webRtcServerId"); - if (jsonWebRtcServerIdIt == internal.end() || !jsonWebRtcServerIdIt->is_string()) - MS_THROW_ERROR("missing internal.webRtcServerId"); + if (jsonWebRtcServerIdIt == data.end() || !jsonWebRtcServerIdIt->is_string()) + MS_THROW_ERROR("missing handlerId.webRtcServerId"); auto it = this->mapWebRtcServers.find(jsonWebRtcServerIdIt->get()); @@ -231,7 +231,7 @@ void Worker::SetNewRouterIdFromData(json& data, std::string& routerId) const auto jsonRouterIdIt = data.find("routerId"); if (jsonRouterIdIt == data.end() || !jsonRouterIdIt->is_string()) - MS_THROW_ERROR("missing data.routerId"); + MS_THROW_ERROR("missing routerId"); routerId.assign(jsonRouterIdIt->get()); @@ -239,14 +239,14 @@ void Worker::SetNewRouterIdFromData(json& data, std::string& routerId) const 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(); - auto jsonRouterIdIt = internal.find("routerId"); + auto jsonRouterIdIt = data.find("routerId"); - if (jsonRouterIdIt == internal.end() || !jsonRouterIdIt->is_string()) - MS_THROW_ERROR("missing internal.routerId"); + if (jsonRouterIdIt == data.end() || !jsonRouterIdIt->is_string()) + MS_THROW_ERROR("missing routerId"); auto it = this->mapRouters.find(jsonRouterIdIt->get()); @@ -343,7 +343,7 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) try { - webRtcServer = GetWebRtcServerFromInternal(request->internal); + webRtcServer = GetWebRtcServerFromData(request->data); } catch (const MediaSoupError& error) { @@ -362,24 +362,6 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) 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: { std::string routerId; @@ -397,8 +379,6 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) this->mapRouters[routerId] = router; this->OnChannelRequestHandlerAdded(routerId, router); - this->OnPayloadChannelRequestHandlerAdded(routerId, router); - this->OnPayloadChannelNotificationHandlerAdded(routerId, router); MS_DEBUG_DEV("Router created [routerId:%s]", routerId.c_str()); @@ -413,7 +393,7 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) try { - router = GetRouterFromInternal(request->internal); + router = GetRouterFromData(request->data); } catch (const MediaSoupError& error) { @@ -423,8 +403,6 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) // Remove it from the map and delete it. this->mapRouters.erase(router->id); this->OnChannelRequestHandlerRemoved(router->id); - this->OnPayloadChannelRequestHandlerRemoved(router->id); - this->OnPayloadChannelNotificationHandlerRemoved(router->id); delete router; MS_DEBUG_DEV("Router closed [id:%s]", router->id.c_str()); @@ -439,9 +417,12 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) { try { - RTC::Router* router = GetRouterFromInternal(request->internal); + auto it = this->mapChannelRequestHandlers.find(request->handlerId); + + if (it == this->mapChannelRequestHandlers.end()) + MS_THROW_ERROR("Channel handler with ID %s not found", request->handlerId.c_str()); - router->HandleRequest(request); + it->second->HandleRequest(request); } catch (const MediaSoupTypeError& error) { @@ -479,9 +460,12 @@ inline void Worker::HandleNotification(PayloadChannel::Notification* notificatio try { - RTC::Router* router = GetRouterFromInternal(notification->internal); + auto it = this->mapPayloadChannelNotificationHandlers.find(notification->handlerId); - router->HandleNotification(notification); + if (it == this->mapPayloadChannelNotificationHandlers.end()) + MS_THROW_ERROR("Notification handler with ID %s not found", notification->handlerId.c_str()); + + it->second->HandleNotification(notification); } catch (const MediaSoupTypeError& error) { @@ -504,9 +488,12 @@ inline void Worker::HandleRequest(PayloadChannel::PayloadChannelRequest* request try { - RTC::Router* router = GetRouterFromInternal(request->internal); + auto it = this->mapPayloadChannelRequestHandlers.find(request->handlerId); + + if (it == this->mapPayloadChannelRequestHandlers.end()) + MS_THROW_ERROR("Payload channel handler with ID %s not found", request->handlerId.c_str()); - router->HandleRequest(request); + it->second->HandleRequest(request); } catch (const MediaSoupTypeError& error) { From ce598a0784015950bc6b3cc403d334321d9a5e15 Mon Sep 17 00:00:00 2001 From: Nazar Mokrynskyi Date: Sun, 21 Aug 2022 23:49:33 +0300 Subject: [PATCH 5/5] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: IƱaki Baz Castillo --- node/src/PipeTransport.ts | 8 ++--- node/src/Router.ts | 63 +++++++++++++++++++++------------------ node/src/Transport.ts | 35 +++++++++++----------- node/src/Worker.ts | 6 ++-- 4 files changed, 60 insertions(+), 52 deletions(-) diff --git a/node/src/PipeTransport.ts b/node/src/PipeTransport.ts index 5b1028dd8f..aad2bee291 100644 --- a/node/src/PipeTransport.ts +++ b/node/src/PipeTransport.ts @@ -311,10 +311,10 @@ export class PipeTransport const consumer = new Consumer( { internal : - { - ...this.internal, - consumerId : reqData.consumerId - }, + { + ...this.internal, + consumerId : reqData.consumerId + }, data, channel : this.channel, payloadChannel : this.payloadChannel, diff --git a/node/src/Router.ts b/node/src/Router.ts index 47f1144387..633ea56f9a 100644 --- a/node/src/Router.ts +++ b/node/src/Router.ts @@ -422,10 +422,10 @@ export class Router extends EnhancedEventEmitter const transport = new WebRtcTransport( { internal : - { - ...this.#internal, - transportId : reqData.transportId - }, + { + ...this.#internal, + transportId : reqData.transportId + }, data, channel : this.#channel, payloadChannel : this.#payloadChannel, @@ -503,7 +503,8 @@ export class Router extends EnhancedEventEmitter throw new TypeError('wrong listenIp'); } - const reqData = { + const reqData = + { transportId : uuidv4(), listenIp, port, @@ -524,10 +525,10 @@ export class Router extends EnhancedEventEmitter const transport = new PlainTransport( { internal : - { - ...this.#internal, - transportId : reqData.transportId - }, + { + ...this.#internal, + transportId : reqData.transportId + }, data, channel : this.#channel, payloadChannel : this.#payloadChannel, @@ -600,7 +601,8 @@ export class Router extends EnhancedEventEmitter throw new TypeError('wrong listenIp'); } - const reqData = { + const reqData = + { transportId : uuidv4(), listenIp, port, @@ -619,10 +621,10 @@ export class Router extends EnhancedEventEmitter const transport = new PipeTransport( { internal : - { - ...this.#internal, - transportId : reqData.transportId - }, + { + ...this.#internal, + transportId : reqData.transportId + }, data, channel : this.#channel, payloadChannel : this.#payloadChannel, @@ -669,7 +671,8 @@ export class Router extends EnhancedEventEmitter { logger.debug('createDirectTransport()'); - const reqData = { + const reqData = + { transportId : uuidv4(), direct : true, maxMessageSize @@ -681,10 +684,10 @@ export class Router extends EnhancedEventEmitter const transport = new DirectTransport( { internal : - { - ...this.#internal, - transportId : reqData.transportId - }, + { + ...this.#internal, + transportId : reqData.transportId + }, data, channel : this.#channel, payloadChannel : this.#payloadChannel, @@ -1020,7 +1023,8 @@ export class Router extends EnhancedEventEmitter if (appData && typeof appData !== 'object') throw new TypeError('if given, appData must be an object'); - const reqData = { + const reqData = + { rtpObserverId : uuidv4(), interval }; @@ -1030,10 +1034,10 @@ export class Router extends EnhancedEventEmitter const activeSpeakerObserver = new ActiveSpeakerObserver( { internal : - { - ...this.#internal, - rtpObserverId : reqData.rtpObserverId - }, + { + ...this.#internal, + rtpObserverId : reqData.rtpObserverId + }, channel : this.#channel, payloadChannel : this.#payloadChannel, appData, @@ -1071,7 +1075,8 @@ export class Router extends EnhancedEventEmitter if (appData && typeof appData !== 'object') throw new TypeError('if given, appData must be an object'); - const reqData = { + const reqData = + { rtpObserverId : uuidv4(), maxEntries, threshold, @@ -1083,10 +1088,10 @@ export class Router extends EnhancedEventEmitter const audioLevelObserver = new AudioLevelObserver( { internal : - { - ...this.#internal, - rtpObserverId : reqData.rtpObserverId - }, + { + ...this.#internal, + rtpObserverId : reqData.rtpObserverId + }, channel : this.#channel, payloadChannel : this.#payloadChannel, appData, diff --git a/node/src/Transport.ts b/node/src/Transport.ts index 341efefe37..461eb1f4a8 100644 --- a/node/src/Transport.ts +++ b/node/src/Transport.ts @@ -574,7 +574,8 @@ export class Transport if (appData && typeof appData !== 'object') throw new TypeError('if given, appData must be an object'); - const reqData = { + const reqData = + { webRtcServerId : uuidv4(), listenInfos }; @@ -640,7 +641,8 @@ export class Worker extends EnhancedEventEmitter const data = { rtpCapabilities }; const router = new Router( { - internal : { + internal : + { routerId : reqData.routerId }, data,