@@ -134,11 +134,12 @@ Cleans built objects and binaries, `meson` and `ninja` installed in local prefix
### `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
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
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
REMB RTCP is generated locally based on the remote bitrate estimation.
## 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.
-*NOTE:* Yes, the JS `xxxxx.yyyyyClosed()` produces **public** JS event `xxxxx.on('yyyyyclose')`, but that's not internal stuff.
- 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.
## JS worker.close()
* Public API.
* Kills the mediasoup-worker process (if not already died) via signal.
* Iterates all JS Routers and calls `router.workerClosed()`.
- Public API.
- Kills the mediasoup-worker process (if not already died) via signal.
- Iterates all JS Routers and calls `router.workerClosed()`.
## mediasoup-worker process dies unexpectely
* The JS Worker emits public JS `worker.on('died')`.
* Iterates all JS Routers and calls `router.workerClosed()`.
- The JS Worker emits public JS `worker.on('died')`.
- Iterates all JS Routers and calls `router.workerClosed()`.
## C++ Worker::Close()
* Called when the mediasoup-worker process is killed.
* Iterates all C++ Routers and calls `delete router`.
- Called when the mediasoup-worker process is killed.
- Iterates all C++ Routers and calls `delete router`.
## JS router.workerClosed()
* Private API.
* Emits public JS `router.on('workerclose')`.
- Private API.
- Emits public JS `router.on('workerclose')`.
## JS router.close()
* Public API.
* Sends channel request `WORKER_CLOSE_ROUTER`:
- Public API.
- Sends channel request `WORKER_CLOSE_ROUTER`:
- Processed by the C++ Worker.
- It removes the C++ Router from its map.
- It calls C++ `delete router`.
* Iterates all JS Transports and calls `transport.routerClosed()`.
* Emits private JS `router.on('@close')` (so the JS Worker cleans its map).
- Iterates all JS Transports and calls `transport.routerClosed()`.
- Emits private JS `router.on('@close')` (so the JS Worker cleans its map).
## C++ ~Router() destructor
* Iterates all C++ Transports and calls `delete transport`.
- Iterates all C++ Transports and calls `delete transport`.
## JS transport.routerClosed()
* Private API.
* Iterates all JS Producers and calls `producer.transportClosed()`.
* Iterates all JS Consumers and calls `consumer.transportClosed()`.
* Emits public JS `transport.on('routerclose')`.
- Private API.
- Iterates all JS Producers and calls `producer.transportClosed()`.
- Iterates all JS Consumers and calls `consumer.transportClosed()`.
- Emits public JS `transport.on('routerclose')`.
## JS transport.close()
* Public API.
* Sends channel request `ROUTER_CLOSE_TRANSPORT`.
- Public API.
- 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.
- It calls C++ `delete transport`.
* 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).
* Iterates all JS Consumers and calls `consumer.transportClosed()`.
* Emits private JS `transport.on('@close')` (so the JS Router cleans its map).
- 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).
- Iterates all JS Consumers and calls `consumer.transportClosed()`.
- Emits private JS `transport.on('@close')` (so the JS Router cleans its map).
## C++ ~Transport() destructor
* Iterates all C++ Producers and calls `delete producer`.
* Iterates all C++ Consumer and calls `delete consumer`.
- Iterates all C++ Producers and calls `delete producer`.
- Iterates all C++ Consumer and calls `delete consumer`.
## C++ Transport::Close()
* Iterates all C++ Producers. For each Producer:
- Iterates all C++ Producers. For each Producer:
- 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 `delete producer`.
* It clears its map of C++ Producers.
* Iterates all C++ Consumer. For each Consumer:
- It clears its map of C++ Producers.
- Iterates all C++ Consumer. For each Consumer:
- Removes it from its map of Consumers.
- Call its `listener->OnTransportConsumerClosed(this, consumer)` (so the C++ Router cleans its maps).
- 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()`).
+ 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.
+ This won't happen since the JS `Consumer` has removed its channel notifications within its `transportClosed()` method.
- 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.
- 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.
## 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()`.
* Deletes the entry in `mapProducerConsumers` with key `producer`.
* Deletes the entry in `mapProducers` with key `producer->id`.
- Deletes the entry in `mapProducerConsumers` with key `producer`.
- Deletes the entry in `mapProducers` with key `producer->id`.
## C++ Router::OnTransportConsumerClosed(transport, consumer)
* 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.
* Deletes the entry in `mapConsumerProducer` with key `consumer`.
- 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.
- Deletes the entry in `mapConsumerProducer` with key `consumer`.
## JS producer.transportClosed()
* Private API.
* Emits public JS `producer.on('transportclose')`.
- Private API.
- 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 `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
* Destroys its stuff.
- Destroys its stuff.
## JS consumer.transportClosed()
* Private API.
* Emits public JS `consumer.on('transportclose')`.
- Private API.
- Emits public JS `consumer.on('transportclose')`.