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

Include doc/ folder in Prettier

上级 83a456ed
......@@ -3,7 +3,6 @@
/.cache
/art
/coverage
/doc
/node/lib
/node/src/fbs
/rust
......
......@@ -3,7 +3,6 @@
/.cache
/art
/coverage
/doc
/node/lib
/node/src/fbs
/rust
......
......@@ -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:
```bash
cd worker
invoke update-wrap-file openssl
MESON_ARGS="--reconfigure" invoke setup
```
### `invoke mediasoup-worker`
......
# Charts
## Broadcasting
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.
Scenario:
* 1 peer producing audio and video tracks.
* N spy peers receiving them.
- 1 peer producing audio and video tracks.
- N spy peers receiving them.
#### Bandwidth out (Mbps) / number of viewers
......
# Consumer
## RTP sequence number handling
------------------------------------------------
---
INIT:
* rtpLastSeq: 1000
* rtpPreviousBaseSeq: 0
* rtpBaseSeq: 0
- rtpLastSeq: 1000
- rtpPreviousBaseSeq: 0
- rtpBaseSeq: 0
------------------------------------------------
---
packet (SYNC):
* seq: 3000
* rtpPreviousBaseSeq: 1000
* rtpBaseSeq: 3000
- seq: 3000
- rtpPreviousBaseSeq: 1000
- rtpBaseSeq: 3000
out:
* rtpLastSeq: 3000 - 3000 + 1000 + 1 = 1001
------------------------------------------------
- rtpLastSeq: 3000 - 3000 + 1000 + 1 = 1001
---
packet:
* seq: 3001
- seq: 3001
out:
* rtpLastSeq: 3001 - 3000 + 1000 + 1 = 1002
------------------------------------------------
- rtpLastSeq: 3001 - 3000 + 1000 + 1 = 1002
---
packet:
* seq: 3003
- seq: 3003
out:
* rtpLastSeq: 3003 - 3000 + 1000 + 1 = 1004
------------------------------------------------
- rtpLastSeq: 3003 - 3000 + 1000 + 1 = 1004
---
packet (SYNC):
* seq: 4050
- rtpPreviousBaseSeq: 1004
- rtpBaseSeq: 4050
- seq: 4050
* rtpPreviousBaseSeq: 1004
* rtpBaseSeq: 4050
out:
* rtpLastSeq: 4050 - 4050 + 1004 + 1 = 1005
------------------------------------------------
- rtpLastSeq: 4050 - 4050 + 1004 + 1 = 1005
---
packet:
* seq: 4051
- seq: 4051
out:
* rtpLastSeq: 4051 - 4050 + 1004 + 1 = 1006
------------------------------------------------
- rtpLastSeq: 4051 - 4050 + 1004 + 1 = 1006
---
packet (DROP):
* seq: 4052
- seq: 4052
if (seq > rtpLastSeq)
* rtpBaseSeq++: 4051
------------------------------------------------
- rtpBaseSeq++: 4051
---
packet:
* seq: 4053
- seq: 4053
out:
* rtpLastSeq: 4053 - 4051 + 1004 + 1 = 1007
------------------------------------------------
- rtpLastSeq: 4053 - 4051 + 1004 + 1 = 1007
---
probation packet:
* rtpLastSeq++ = 1008
- rtpLastSeq++ = 1008
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.
------------------------------------------------
---
packet:
* seq: 4054
- seq: 4054
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
## Related documentation
* [libFuzzer documentation](http://llvm.org/docs/LibFuzzer.html)
* [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/)
* [OSS-Fuzz](https://github.com/google/oss-fuzz) - Continuous fuzzing of open source software ("fuzz for me")
- [libFuzzer documentation](http://llvm.org/docs/LibFuzzer.html)
- [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/)
- [OSS-Fuzz](https://github.com/google/oss-fuzz) - Continuous fuzzing of open source software ("fuzz for me")
## Corpus files
......@@ -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:
* `-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:
* `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:
* `MS_FUZZ_STUN=1`: Do STUN fuzzing.
* `MS_FUZZ_RTP=1`: Do RTP fuzzing.
* `MS_FUZZ_RTCP=1`: Do RTCP fuzzing.
* `MS_FUZZ_UTILS=1`: Do C++ utils fuzzing.
* If none of them is given, then **all** fuzzers are enabled.
- `MS_FUZZ_STUN=1`: Do STUN fuzzing.
- `MS_FUZZ_RTP=1`: Do RTP fuzzing.
- `MS_FUZZ_RTCP=1`: Do RTCP fuzzing.
- `MS_FUZZ_UTILS=1`: Do C++ utils fuzzing.
- 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).
## Usage examples
* Detect memory leaks and just fuzz STUN:
- Detect memory leaks and just fuzz STUN:
```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
```
* Detect memory leaks and just fuzz RTP:
- Detect memory leaks and just fuzz RTP:
```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
```
* Detect memory leaks and just fuzz RTCP:
- Detect memory leaks and just fuzz RTCP:
```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
```
* Detect memory leaks and just fuzz mediasoup-worker C++ utils:
- Detect memory leaks and just fuzz mediasoup-worker C++ utils:
```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
```
* Detect memory leaks and fuzz everything with log level "warn":
- Detect memory leaks and fuzz everything with log level "warn":
```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
```
* Verify that a specific crash is fixed:
- Verify that a specific crash is fixed:
```bash
LSAN_OPTIONS=verbosity=1:log_threads=1 ./out/Release/mediasoup-worker-fuzzer fuzzer/reports/crash-f39771f7a03c0e7e539d4e52f48f7adad8976404
......
......@@ -2,9 +2,8 @@
**NOTE:** Internal documentation for developing purposes. Get the mediasoup public documentation at [mediasoup.org](https://mediasoup.org).
* [Building](Building.md)
* [Fuzzer](Fuzzer.md)
* [RTCP](RTCP.md)
* [Consumer](Consumer.md)
* [Charts](Charts.md)
- [Building](Building.md)
- [Fuzzer](Fuzzer.md)
- [RTCP](RTCP.md)
- [Consumer](Consumer.md)
- [Charts](Charts.md)
......@@ -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
### Generic RTCP
| | SR | RR | SDES | BYE | APP |
| --------- | -- | -- | ---- | --- | --- |
| Consumer | G | C | | | |
| Producer | C | G | C | I | I |
| | SR | RR | SDES | BYE | APP |
| -------- | --- | --- | ---- | --- | --- |
| Consumer | G | C | | | |
| Producer | C | G | C | I | I |
### RTP Feedback RTCP
| | NACK | TMMBR | TMMBN | TLLEI | ECN-FB | PAUSE-RESUME | TCC |
| --------- | ---- | ----- | ----- | ----- | ------ | ------------ | --- |
| Consumer | C | I | I | I | I | I | |
| Producer | G | | I | I | | | |
| | NACK | TMMBR | TMMBN | TLLEI | ECN-FB | PAUSE-RESUME | TCC |
| -------- | ---- | ----- | ----- | ----- | ------ | ------------ | --- |
| Consumer | C | I | I | I | I | I | |
| Producer | G | | I | I | | | |
## PS Feedback RTCP
| | PLI | SLI | RPSI | FIR | TSTR | TSTN | VBCM | PSLI | AFB | REMB |
| --------- | --- | --- | ---- | --- | ---- | ---- | ---- | ---- | --- | ---- |
| Consumer | C | I | I | C | I | | I | | I | C |
| Producer | G | | | | | I | | I | | |
| Transport | | | | | | | | | | G |
| Consumer | C | I | I | C | I | | I | | I | C |
| Producer | G | | | | | I | | I | | |
| Transport | | | | | | | | | | G |
( ): Does not apply.
......
......@@ -2,147 +2,147 @@
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.
- *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')`.
## JS producer.close()
* Public API.
* Sends channel request `TRANSPORT_CLOSE_PRODUCER`.
- Public API.
- 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).
- 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')`.
## JS consumer.close()
* Public API.
* Sends channel request `TRANSPORT_CLOSE_CONSUMER`.
- Public API.
- 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).
- 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
* Destroys its stuff.
- Destroys its stuff.
## C++ Consumer::ProducerClosed()
* Called from the C++ Router within the `Router::OnTransportProducerClosed()` listener.
* Send a channel notification `producerclose` to the JS Consumer.
- Called from the C++ Router within the `Router::OnTransportProducerClosed()` listener.
- 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 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,
- notifies the Router via `listener->OnTransportConsumerClosed()`), and
- deletes the Consumer.
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论