@@ -134,11 +134,12 @@ Cleans built objects and binaries, `meson` and `ninja` installed in local prefix
...
@@ -134,11 +134,12 @@ Cleans built objects and binaries, `meson` and `ninja` installed in local prefix
### `invoke update-wrap-file [subproject]`
### `invoke update-wrap-file [subproject]`
Updates the wrap file of a subproject (those in `worker/subprojects` folder) with Meson. Usage example:
Updates the wrap file of a subproject (those in `worker/subprojects` folder) with Meson. After updating it, `invoke setup` must be called by passing `MESON_ARGS="--reconfigure"` environment variable. Usage example:
@@ -8,7 +8,6 @@ This document also describes which RTCP packets are locally generated by mediaso
...
@@ -8,7 +8,6 @@ This document also describes which RTCP packets are locally generated by mediaso
mediasoup does not forward feedback information from a remote RTP receiver, which could incur in the remote sender modifying the transmition rate in a way that it would affect the reception quality for the overall participants in a router (i.e. limiting the remote RTP sender transmition rate).
mediasoup does not forward feedback information from a remote RTP receiver, which could incur in the remote sender modifying the transmition rate in a way that it would affect the reception quality for the overall participants in a router (i.e. limiting the remote RTP sender transmition rate).
### Sender Reports
### Sender Reports
mediasoup locally generates the Sender Reports of the streams it sends and processes the Sender Reports is receives from producer endpoints.
mediasoup locally generates the Sender Reports of the streams it sends and processes the Sender Reports is receives from producer endpoints.
...
@@ -150,31 +149,29 @@ This information is locally consumed to perform sender side bandwidth estimation
...
@@ -150,31 +149,29 @@ This information is locally consumed to perform sender side bandwidth estimation
REMB RTCP is generated locally based on the remote bitrate estimation.
REMB RTCP is generated locally based on the remote bitrate estimation.
## Mediasoup internal behaviour for each type of RTCP
## Mediasoup internal behaviour for each type of RTCP
* Any JS `xxxxx.yyyyyClosed()` method is equivalent to the corresponding C++ `~Xxxxx()` destructor. They both silently destroy things without generating any internal notifications/events.
- Any JS `xxxxx.yyyyyClosed()` method is equivalent to the corresponding C++ `~Xxxxx()` destructor. They both silently destroy things without generating any internal notifications/events.
-*NOTE:* Yes, the JS `xxxxx.yyyyyClosed()` produces **public** JS event `xxxxx.on('yyyyyclose')`, but that's not internal stuff.
- _NOTE:_ Yes, the JS `xxxxx.yyyyyClosed()` produces **public** JS event `xxxxx.on('yyyyyclose')`, but that's not internal stuff.
## JS worker.close()
## JS worker.close()
* Public API.
- Public API.
* Kills the mediasoup-worker process (if not already died) via signal.
- Kills the mediasoup-worker process (if not already died) via signal.
* Iterates all JS Routers and calls `router.workerClosed()`.
- Iterates all JS Routers and calls `router.workerClosed()`.
## mediasoup-worker process dies unexpectely
## mediasoup-worker process dies unexpectely
* The JS Worker emits public JS `worker.on('died')`.
- The JS Worker emits public JS `worker.on('died')`.
* Iterates all JS Routers and calls `router.workerClosed()`.
- Iterates all JS Routers and calls `router.workerClosed()`.
## C++ Worker::Close()
## C++ Worker::Close()
* Called when the mediasoup-worker process is killed.
- Called when the mediasoup-worker process is killed.
* Iterates all C++ Routers and calls `delete router`.
- Iterates all C++ Routers and calls `delete router`.
## JS router.workerClosed()
## JS router.workerClosed()
* Private API.
- Private API.
* Emits public JS `router.on('workerclose')`.
- Emits public JS `router.on('workerclose')`.
## JS router.close()
## JS router.close()
* Public API.
- Public API.
* Sends channel request `WORKER_CLOSE_ROUTER`:
- Sends channel request `WORKER_CLOSE_ROUTER`:
- Processed by the C++ Worker.
- Processed by the C++ Worker.
- It removes the C++ Router from its map.
- It removes the C++ Router from its map.
- It calls C++ `delete router`.
- It calls C++ `delete router`.
* Iterates all JS Transports and calls `transport.routerClosed()`.
- Iterates all JS Transports and calls `transport.routerClosed()`.
* Emits private JS `router.on('@close')` (so the JS Worker cleans its map).
- Emits private JS `router.on('@close')` (so the JS Worker cleans its map).
## C++ ~Router() destructor
## C++ ~Router() destructor
* Iterates all C++ Transports and calls `delete transport`.
- Iterates all C++ Transports and calls `delete transport`.
## JS transport.routerClosed()
## JS transport.routerClosed()
* Private API.
- Private API.
* Iterates all JS Producers and calls `producer.transportClosed()`.
- Iterates all JS Producers and calls `producer.transportClosed()`.
* Iterates all JS Consumers and calls `consumer.transportClosed()`.
- Iterates all JS Consumers and calls `consumer.transportClosed()`.
* Emits public JS `transport.on('routerclose')`.
- Emits public JS `transport.on('routerclose')`.
## JS transport.close()
## JS transport.close()
* Public API.
- Public API.
* Sends channel request `ROUTER_CLOSE_TRANSPORT`.
- Sends channel request `ROUTER_CLOSE_TRANSPORT`.
- Processed by the C++ Router.
- Processed by the C++ Router.
- It calls C++ `transport->Close()` (so the C++ Transport will notify the C++ Router about closed Producers and Consumers in that Transport).
- It calls C++ `transport->Close()` (so the C++ Transport will notify the C++ Router about closed Producers and Consumers in that Transport).
- It removes the C++ Transport from its map.
- It removes the C++ Transport from its map.
- It calls C++ `delete transport`.
- It calls C++ `delete transport`.
* Iterates all JS Producers and calls `producer.transportClosed()`.
- Iterates all JS Producers and calls `producer.transportClosed()`.
* For each JS Producer, the JS Transport emits private JS `transport.on('@producerclose')` (so the JS Router cleans its maps).
- For each JS Producer, the JS Transport emits private JS `transport.on('@producerclose')` (so the JS Router cleans its maps).
* Iterates all JS Consumers and calls `consumer.transportClosed()`.
- Iterates all JS Consumers and calls `consumer.transportClosed()`.
* Emits private JS `transport.on('@close')` (so the JS Router cleans its map).
- Emits private JS `transport.on('@close')` (so the JS Router cleans its map).
## C++ ~Transport() destructor
## C++ ~Transport() destructor
* Iterates all C++ Producers and calls `delete producer`.
- Iterates all C++ Producers and calls `delete producer`.
* Iterates all C++ Consumer and calls `delete consumer`.
- Iterates all C++ Consumer and calls `delete consumer`.
## C++ Transport::Close()
## C++ Transport::Close()
* Iterates all C++ Producers. For each Producer:
- Iterates all C++ Producers. For each Producer:
- Removes it from its map of Producers.
- Removes it from its map of Producers.
- Calls its `listener->OnTransportProducerClosed(this, producer)` (so the C++ Router cleans its maps and calls `consumer->ProducerClosed()` on its associated Consumers).
- Calls its `listener->OnTransportProducerClosed(this, producer)` (so the C++ Router cleans its maps and calls `consumer->ProducerClosed()` on its associated Consumers).
- Calls `delete producer`.
- Calls `delete producer`.
* It clears its map of C++ Producers.
- It clears its map of C++ Producers.
* Iterates all C++ Consumer. For each Consumer:
- Iterates all C++ Consumer. For each Consumer:
- Removes it from its map of Consumers.
- Removes it from its map of Consumers.
- Call its `listener->OnTransportConsumerClosed(this, consumer)` (so the C++ Router cleans its maps).
- Call its `listener->OnTransportConsumerClosed(this, consumer)` (so the C++ Router cleans its maps).
- Calls `delete consumer`.
- Calls `delete consumer`.
* It clears its map of C++ Consumers.
- It clears its map of C++ Consumers.
_NOTE:_ If a Transport holds a Producer and a Consumer associated to that Producer, ugly things may happen when calling `Transport::Close()`:
*NOTE:* If a Transport holds a Producer and a Consumer associated to that Producer, ugly things may happen when calling `Transport::Close()`:
- While iterating the C++ Producers as above, the C++ Consumer would be deleted (via `Consumer::ProducerClosed()`).
- While iterating the C++ Producers as above, the C++ Consumer would be deleted (via `Consumer::ProducerClosed()`).
- As far as it's properly removed from the `Transport::mapConsumers` everything would be ok when later iterating the map of Consumers.
+ As far as it's properly removed from the `Transport::mapConsumers` everything would be ok when later iterating the map of Consumers.
- Must ensure that, in this scenario, the JS event `consumer.on('producerclose')` is not called since `consumer.on('transportclose')` is supposed to happen before.
- Must ensure that, in this scenario, the JS event `consumer.on('producerclose')` is not called since `consumer.on('transportclose')` is supposed to happen before.
- This won't happen since the JS `Consumer` has removed its channel notifications within its `transportClosed()` method.
+ This won't happen since the JS `Consumer` has removed its channel notifications within its `transportClosed()` method.
## C++ Router::OnTransportProducerClosed(transport, producer)
## C++ Router::OnTransportProducerClosed(transport, producer)
* Gets the set of C++ Consumers associated to the closed Producer in its `mapProducerConsumers`. For each Consumer:
- Gets the set of C++ Consumers associated to the closed Producer in its `mapProducerConsumers`. For each Consumer:
- Calls `consumer->ProducerClosed()`.
- Calls `consumer->ProducerClosed()`.
* Deletes the entry in `mapProducerConsumers` with key `producer`.
- Deletes the entry in `mapProducerConsumers` with key `producer`.
* Deletes the entry in `mapProducers` with key `producer->id`.
- Deletes the entry in `mapProducers` with key `producer->id`.
## C++ Router::OnTransportConsumerClosed(transport, consumer)
## C++ Router::OnTransportConsumerClosed(transport, consumer)
* Get the associated C++ Producer from `mapConsumerProducer`.
- Get the associated C++ Producer from `mapConsumerProducer`.
* Remove the closed C++ Consumer from the set of Consumers in the corresponding `mapProducerConsumers` entry for the given Producer.
- Remove the closed C++ Consumer from the set of Consumers in the corresponding `mapProducerConsumers` entry for the given Producer.
* Deletes the entry in `mapConsumerProducer` with key `consumer`.
- Deletes the entry in `mapConsumerProducer` with key `consumer`.
## JS producer.transportClosed()
## JS producer.transportClosed()
* Private API.
- Private API.
* Emits public JS `producer.on('transportclose')`.
- Emits public JS `producer.on('transportclose')`.
- Calls its `listener->OnTransportProducerClosed(this, producer)` (so the C++ Router cleans its maps and calls `consumer->ProducerClose()` on its associated Consumers).
- Calls its `listener->OnTransportProducerClosed(this, producer)` (so the C++ Router cleans its maps and calls `consumer->ProducerClose()` on its associated Consumers).
- Calls `delete producer`.
- Calls `delete producer`.
* Emits private JS `producer.on('@close')` (so the JS Transport cleans its map and will also emit private JS `transport.on('@producerclose')` so the JS Router cleans its map).
- Emits private JS `producer.on('@close')` (so the JS Transport cleans its map and will also emit private JS `transport.on('@producerclose')` so the JS Router cleans its map).
## C++ ~Producer() destructor
## C++ ~Producer() destructor
* Destroys its stuff.
- Destroys its stuff.
## JS consumer.transportClosed()
## JS consumer.transportClosed()
* Private API.
- Private API.
* Emits public JS `consumer.on('transportclose')`.
- Emits public JS `consumer.on('transportclose')`.