提交 01075b1b authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

Include doc/ folder in Prettier

上级 83a456ed
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
/.cache /.cache
/art /art
/coverage /coverage
/doc
/node/lib /node/lib
/node/src/fbs /node/src/fbs
/rust /rust
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
/.cache /.cache
/art /art
/coverage /coverage
/doc
/node/lib /node/lib
/node/src/fbs /node/src/fbs
/rust /rust
......
...@@ -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:
```bash ```bash
cd worker cd worker
invoke update-wrap-file openssl invoke update-wrap-file openssl
MESON_ARGS="--reconfigure" invoke setup
``` ```
### `invoke mediasoup-worker` ### `invoke mediasoup-worker`
......
# Charts # Charts
## Broadcasting ## Broadcasting
mediasoup **v2** (a room uses a single media worker subprocess by design, so a single CPU). mediasoup **v2** (a room uses a single media worker subprocess by design, so a single CPU).
...@@ -9,9 +8,8 @@ Charts provided by [CoSMo](https://www.cosmosoftware.io) team. ...@@ -9,9 +8,8 @@ Charts provided by [CoSMo](https://www.cosmosoftware.io) team.
Scenario: Scenario:
* 1 peer producing audio and video tracks. - 1 peer producing audio and video tracks.
* N spy peers receiving them. - N spy peers receiving them.
#### Bandwidth out (Mbps) / number of viewers #### Bandwidth out (Mbps) / number of viewers
......
# Consumer # Consumer
## RTP sequence number handling ## RTP sequence number handling
------------------------------------------------ ---
INIT: INIT:
* rtpLastSeq: 1000 - rtpLastSeq: 1000
* rtpPreviousBaseSeq: 0 - rtpPreviousBaseSeq: 0
* rtpBaseSeq: 0 - rtpBaseSeq: 0
------------------------------------------------ ---
packet (SYNC): packet (SYNC):
* seq: 3000
* rtpPreviousBaseSeq: 1000 - seq: 3000
* rtpBaseSeq: 3000 - rtpPreviousBaseSeq: 1000
- rtpBaseSeq: 3000
out: out:
* rtpLastSeq: 3000 - 3000 + 1000 + 1 = 1001
------------------------------------------------ - rtpLastSeq: 3000 - 3000 + 1000 + 1 = 1001
---
packet: packet:
* seq: 3001
- seq: 3001
out: out:
* rtpLastSeq: 3001 - 3000 + 1000 + 1 = 1002
------------------------------------------------ - rtpLastSeq: 3001 - 3000 + 1000 + 1 = 1002
---
packet: packet:
* seq: 3003
- seq: 3003
out: out:
* rtpLastSeq: 3003 - 3000 + 1000 + 1 = 1004
------------------------------------------------ - rtpLastSeq: 3003 - 3000 + 1000 + 1 = 1004
---
packet (SYNC): packet (SYNC):
* seq: 4050
- rtpPreviousBaseSeq: 1004 - seq: 4050
- rtpBaseSeq: 4050
* rtpPreviousBaseSeq: 1004
* rtpBaseSeq: 4050
out: out:
* rtpLastSeq: 4050 - 4050 + 1004 + 1 = 1005
------------------------------------------------ - rtpLastSeq: 4050 - 4050 + 1004 + 1 = 1005
---
packet: packet:
* seq: 4051
- seq: 4051
out: out:
* rtpLastSeq: 4051 - 4050 + 1004 + 1 = 1006
------------------------------------------------ - rtpLastSeq: 4051 - 4050 + 1004 + 1 = 1006
---
packet (DROP): packet (DROP):
* seq: 4052
- seq: 4052
if (seq > rtpLastSeq) if (seq > rtpLastSeq)
* rtpBaseSeq++: 4051
------------------------------------------------ - rtpBaseSeq++: 4051
---
packet: packet:
* seq: 4053
- seq: 4053
out: out:
* rtpLastSeq: 4053 - 4051 + 1004 + 1 = 1007
------------------------------------------------ - rtpLastSeq: 4053 - 4051 + 1004 + 1 = 1007
---
probation packet: probation packet:
* rtpLastSeq++ = 1008
- rtpLastSeq++ = 1008
out: out:
* rtpLastSeq: 1008
* rtpBaseSeq--: 4050 - rtpLastSeq: 1008
- rtpBaseSeq--: 4050
NOTE: probation packets should just be sent (assuming same RTP timestamp) **after** a video packet with `marker` bit set to 1. NOTE: probation packets should just be sent (assuming same RTP timestamp) **after** a video packet with `marker` bit set to 1.
------------------------------------------------ ---
packet: packet:
* seq: 4054
- seq: 4054
out: out:
* rtpLastSeq: 4054 - 4050 + 1004 + 1 = 1009
- rtpLastSeq: 4054 - 4050 + 1004 + 1 = 1009
...@@ -6,10 +6,10 @@ Once we have built the `mediasoup-worker-fuzzer` target in a Linux environment w ...@@ -6,10 +6,10 @@ Once we have built the `mediasoup-worker-fuzzer` target in a Linux environment w
## Related documentation ## Related documentation
* [libFuzzer documentation](http://llvm.org/docs/LibFuzzer.html) - [libFuzzer documentation](http://llvm.org/docs/LibFuzzer.html)
* [libFuzzer Tutorial](https://github.com/google/fuzzer-test-suite/blob/master/tutorial/libFuzzerTutorial.md) - [libFuzzer Tutorial](https://github.com/google/fuzzer-test-suite/blob/master/tutorial/libFuzzerTutorial.md)
* [webrtcH4cKS ~ Lets get better at fuzzing in 2019](https://webrtchacks.com/lets-get-better-at-fuzzing-in-2019-heres-how/) - [webrtcH4cKS ~ Lets get better at fuzzing in 2019](https://webrtchacks.com/lets-get-better-at-fuzzing-in-2019-heres-how/)
* [OSS-Fuzz](https://github.com/google/oss-fuzz) - Continuous fuzzing of open source software ("fuzz for me") - [OSS-Fuzz](https://github.com/google/oss-fuzz) - Continuous fuzzing of open source software ("fuzz for me")
## Corpus files ## Corpus files
...@@ -31,55 +31,55 @@ The `fuzzer/reports` directory should be used to store those new crash reports. ...@@ -31,55 +31,55 @@ The `fuzzer/reports` directory should be used to store those new crash reports.
It's recommended to (also) pass the following options to the fuzzer: It's recommended to (also) pass the following options to the fuzzer:
* `-max_len=1400`: We don't need much more input size. - `-max_len=1400`: We don't need much more input size.
For memory leak detection enable the following environment variable: For memory leak detection enable the following environment variable:
* `LSAN_OPTIONS=verbosity=1:log_threads=1` - `LSAN_OPTIONS=verbosity=1:log_threads=1`
The mediasoup-worker fuzzer reads some custom environment variables to decide which kind of fuzzing perform: The mediasoup-worker fuzzer reads some custom environment variables to decide which kind of fuzzing perform:
* `MS_FUZZ_STUN=1`: Do STUN fuzzing. - `MS_FUZZ_STUN=1`: Do STUN fuzzing.
* `MS_FUZZ_RTP=1`: Do RTP fuzzing. - `MS_FUZZ_RTP=1`: Do RTP fuzzing.
* `MS_FUZZ_RTCP=1`: Do RTCP fuzzing. - `MS_FUZZ_RTCP=1`: Do RTCP fuzzing.
* `MS_FUZZ_UTILS=1`: Do C++ utils fuzzing. - `MS_FUZZ_UTILS=1`: Do C++ utils fuzzing.
* If none of them is given, then **all** fuzzers are enabled. - If none of them is given, then **all** fuzzers are enabled.
The log level can also be set by setting the `MS_FUZZ_LOG_LEVEL` environment variable to "debug", "warn" or "error" (it is "none" if unset). The log level can also be set by setting the `MS_FUZZ_LOG_LEVEL` environment variable to "debug", "warn" or "error" (it is "none" if unset).
## Usage examples ## Usage examples
* Detect memory leaks and just fuzz STUN: - Detect memory leaks and just fuzz STUN:
```bash ```bash
MS_FUZZ_STUN=1 LSAN_OPTIONS=verbosity=1:log_threads=1 ./out/Release/mediasoup-worker-fuzzer -artifact_prefix=fuzzer/reports/ -max_len=1400 fuzzer/new-corpus deps/webrtc-fuzzer-corpora/corpora/stun-corpus MS_FUZZ_STUN=1 LSAN_OPTIONS=verbosity=1:log_threads=1 ./out/Release/mediasoup-worker-fuzzer -artifact_prefix=fuzzer/reports/ -max_len=1400 fuzzer/new-corpus deps/webrtc-fuzzer-corpora/corpora/stun-corpus
``` ```
* Detect memory leaks and just fuzz RTP: - Detect memory leaks and just fuzz RTP:
```bash ```bash
MS_FUZZ_RTP=1 LSAN_OPTIONS=verbosity=1:log_threads=1 ./out/Release/mediasoup-worker-fuzzer -artifact_prefix=fuzzer/reports/ -max_len=1400 fuzzer/new-corpus deps/webrtc-fuzzer-corpora/corpora/rtp-corpus MS_FUZZ_RTP=1 LSAN_OPTIONS=verbosity=1:log_threads=1 ./out/Release/mediasoup-worker-fuzzer -artifact_prefix=fuzzer/reports/ -max_len=1400 fuzzer/new-corpus deps/webrtc-fuzzer-corpora/corpora/rtp-corpus
``` ```
* Detect memory leaks and just fuzz RTCP: - Detect memory leaks and just fuzz RTCP:
```bash ```bash
MS_FUZZ_RTCP=1 LSAN_OPTIONS=verbosity=1:log_threads=1 ./out/Release/mediasoup-worker-fuzzer -artifact_prefix=fuzzer/reports/ -max_len=1400 fuzzer/new-corpus deps/webrtc-fuzzer-corpora/corpora/rtcp-corpus MS_FUZZ_RTCP=1 LSAN_OPTIONS=verbosity=1:log_threads=1 ./out/Release/mediasoup-worker-fuzzer -artifact_prefix=fuzzer/reports/ -max_len=1400 fuzzer/new-corpus deps/webrtc-fuzzer-corpora/corpora/rtcp-corpus
``` ```
* Detect memory leaks and just fuzz mediasoup-worker C++ utils: - Detect memory leaks and just fuzz mediasoup-worker C++ utils:
```bash ```bash
MS_FUZZ_UTILS=1 LSAN_OPTIONS=verbosity=1:log_threads=1 ./out/Release/mediasoup-worker-fuzzer -artifact_prefix=fuzzer/reports/ -max_len=2000 fuzzer/new-corpus MS_FUZZ_UTILS=1 LSAN_OPTIONS=verbosity=1:log_threads=1 ./out/Release/mediasoup-worker-fuzzer -artifact_prefix=fuzzer/reports/ -max_len=2000 fuzzer/new-corpus
``` ```
* Detect memory leaks and fuzz everything with log level "warn": - Detect memory leaks and fuzz everything with log level "warn":
```bash ```bash
MS_FUZZ_LOG_LEVEL=warn LSAN_OPTIONS=verbosity=1:log_threads=1 ./out/Release/mediasoup-worker-fuzzer -artifact_prefix=fuzzer/reports/ -max_len=1400 fuzzer/new-corpus deps/webrtc-fuzzer-corpora/corpora/stun-corpus deps/webrtc-fuzzer-corpora/corpora/rtp-corpus deps/webrtc-fuzzer-corpora/corpora/rtcp-corpus MS_FUZZ_LOG_LEVEL=warn LSAN_OPTIONS=verbosity=1:log_threads=1 ./out/Release/mediasoup-worker-fuzzer -artifact_prefix=fuzzer/reports/ -max_len=1400 fuzzer/new-corpus deps/webrtc-fuzzer-corpora/corpora/stun-corpus deps/webrtc-fuzzer-corpora/corpora/rtp-corpus deps/webrtc-fuzzer-corpora/corpora/rtcp-corpus
``` ```
* Verify that a specific crash is fixed: - Verify that a specific crash is fixed:
```bash ```bash
LSAN_OPTIONS=verbosity=1:log_threads=1 ./out/Release/mediasoup-worker-fuzzer fuzzer/reports/crash-f39771f7a03c0e7e539d4e52f48f7adad8976404 LSAN_OPTIONS=verbosity=1:log_threads=1 ./out/Release/mediasoup-worker-fuzzer fuzzer/reports/crash-f39771f7a03c0e7e539d4e52f48f7adad8976404
......
...@@ -2,9 +2,8 @@ ...@@ -2,9 +2,8 @@
**NOTE:** Internal documentation for developing purposes. Get the mediasoup public documentation at [mediasoup.org](https://mediasoup.org). **NOTE:** Internal documentation for developing purposes. Get the mediasoup public documentation at [mediasoup.org](https://mediasoup.org).
* [Building](Building.md) - [Building](Building.md)
* [Fuzzer](Fuzzer.md) - [Fuzzer](Fuzzer.md)
* [RTCP](RTCP.md) - [RTCP](RTCP.md)
* [Consumer](Consumer.md) - [Consumer](Consumer.md)
* [Charts](Charts.md) - [Charts](Charts.md)
...@@ -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,20 +149,19 @@ This information is locally consumed to perform sender side bandwidth estimation ...@@ -150,20 +149,19 @@ 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
### Generic RTCP ### Generic RTCP
| | SR | RR | SDES | BYE | APP | | | SR | RR | SDES | BYE | APP |
| --------- | -- | -- | ---- | --- | --- | | -------- | --- | --- | ---- | --- | --- |
| Consumer | G | C | | | | | Consumer | G | C | | | |
| Producer | C | G | C | I | I | | Producer | C | G | C | I | I |
### RTP Feedback RTCP ### RTP Feedback RTCP
| | NACK | TMMBR | TMMBN | TLLEI | ECN-FB | PAUSE-RESUME | TCC | | | NACK | TMMBR | TMMBN | TLLEI | ECN-FB | PAUSE-RESUME | TCC |
| --------- | ---- | ----- | ----- | ----- | ------ | ------------ | --- | | -------- | ---- | ----- | ----- | ----- | ------ | ------------ | --- |
| Consumer | C | I | I | I | I | I | | | Consumer | C | I | I | I | I | I | |
| Producer | G | | I | I | | | | | Producer | G | | I | I | | | |
...@@ -175,7 +173,6 @@ REMB RTCP is generated locally based on the remote bitrate estimation. ...@@ -175,7 +173,6 @@ REMB RTCP is generated locally based on the remote bitrate estimation.
| Producer | G | | | | | I | | I | | | | Producer | G | | | | | I | | I | | |
| Transport | | | | | | | | | | G | | Transport | | | | | | | | | | G |
( ): Does not apply. ( ): Does not apply.
(I): Ignore. (I): Ignore.
......
...@@ -2,147 +2,147 @@ ...@@ -2,147 +2,147 @@
Some considerations: Some considerations:
* 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')`.
## JS producer.close() ## JS producer.close()
* Public API. - Public API.
* Sends channel request `TRANSPORT_CLOSE_PRODUCER`. - Sends channel request `TRANSPORT_CLOSE_PRODUCER`.
- Processed by the C++ Transport. - Processed by the C++ Transport.
- Removes it from its map of Producers. - Removes it from its map of Producers.
- Calls its `listener->OnTransportProducerClosed(this, producer)` (so the C++ Router cleans its maps and calls `consumer->ProducerClose()` on its associated Consumers). - Calls its `listener->OnTransportProducerClosed(this, producer)` (so the C++ Router cleans its maps and calls `consumer->ProducerClose()` on its associated Consumers).
- 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')`.
## JS consumer.close() ## JS consumer.close()
* Public API. - Public API.
* Sends channel request `TRANSPORT_CLOSE_CONSUMER`. - Sends channel request `TRANSPORT_CLOSE_CONSUMER`.
- Processed by the C++ Transport. - Processed by the C++ Transport.
- Removes it from its map of Consumers. - Removes it from its map of Consumers.
- Calls its `listener->OnTransportConsumerClosed(this, consumer)` (so the C++ Router cleans its maps). - Calls its `listener->OnTransportConsumerClosed(this, consumer)` (so the C++ Router cleans its maps).
- Calls `delete consumer`. - Calls `delete consumer`.
* Emits private JS `consumer.on('@close')` (so the JS Transport cleans its map). - Emits private JS `consumer.on('@close')` (so the JS Transport cleans its map).
## C++ ~Consumer() destructor ## C++ ~Consumer() destructor
* Destroys its stuff. - Destroys its stuff.
## C++ Consumer::ProducerClosed() ## C++ Consumer::ProducerClosed()
* Called from the C++ Router within the `Router::OnTransportProducerClosed()` listener. - Called from the C++ Router within the `Router::OnTransportProducerClosed()` listener.
* Send a channel notification `producerclose` to the JS Consumer. - Send a channel notification `producerclose` to the JS Consumer.
- The JS Consumer emits private JS `consumer.on('@produceclose')` (so the JS Transport cleans its map). - The JS Consumer emits private JS `consumer.on('@produceclose')` (so the JS Transport cleans its map).
- The JS Consumer emits public JS `consumer.on('produceclose')`. - The JS Consumer emits public JS `consumer.on('produceclose')`.
* Notifies its C++ Transport via `listener->onConsumerProducerClosed()` which: - Notifies its C++ Transport via `listener->onConsumerProducerClosed()` which:
- cleans its map of Consumers, - cleans its map of Consumers,
- notifies the Router via `listener->OnTransportConsumerClosed()`), and - notifies the Router via `listener->OnTransportConsumerClosed()`), and
- deletes the Consumer. - deletes the Consumer.
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论