This documentation describes how RTCP packets are processed in *mediasoup*.
This documentation describes how RTCP packets are processed in mediasoup.
Being a SFU, some received RTCP packets are locally consumed and others are ignored.
This document also describes which RTCP packets are locally generated by *mediasoup*.
This document also describes which RTCP packets are locally generated by mediasoup.
*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 room. Ie: 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).
In order to get the best media quality from the remote RTP senders, *mediasoup* focuses on generating locally the reception information (RR), so the remote RTP senders can adjust their transmission rate according to it.
### Sender Reports
*mediasoup* locally generates the Sender Reports of the streams it sends.
mediasoup locally generates the Sender Reports of the streams it sends and processes the Sender Reports is receives from producer endpoints.
### Receiver Reports
*mediasoup* locally generates the Receiver Reports of the streams it receives. At the same time, it consumes the Receiver Reports from every remote RTP receivers.
mediasoup locally generates the Receiver Reports of the streams it receives and consumes the Receiver Reports from every remote RTP receivers.
The combination of Sender and Receiver Reports are used to determine the quality of each link. Information that is available at the JavaScript API level in order to determine the quality of each participant in the room.
The combination of Sender and Receiver Reports are used to determine the quality of each link. Information that is available at the JavaScript API level in order to determine the quality of each participant in the router.
### SDES
...
...
@@ -34,15 +33,15 @@ This information is ignored.
### XR
The same logic should be applied as to Receiver Reports.
Currently not implemented (ignored). The same logic should be applied as to Receiver Reports.
## RTP Feedback
### NACK
Received NACK requests are locally consumed. The solicited RTP packets are re-sent to the remote RTP receiver sending the request.
Received NACK requests are locally consumed. The solicited RTP packets are re-sent to the remote RTP receiver that requested them.
*mediasoup* locally generate NACK requests for remote senders.
mediasoup locally generate NACK requests for remote senders.
### TMMBR / TMMBN
...
...
@@ -79,7 +78,7 @@ This information is ignored.
### TLLEI
This information is ignored. In future it could be useful to acknowledge remote RTP receivers when *mediasoup* generates **NACK** request in order to avoid them sending them, which could generate the so called "feedback storm" or "NACK storm".
This information is ignored. In future it could be useful to acknowledge remote RTP receivers when mediasoup generates NACK request in order to avoid them sending them, which could generate the so called "feedback storm" or "NACK storm".
```
RFC 6642:
...
...
@@ -95,11 +94,11 @@ This information is ignored.
### PAUSE-RESUME
This information is ignored.
This information is ignored (and not even implemented in any RTP/WebRTC endpoint).
### Transport-wide Congestion Control (TCC)
This information is ignored.
Planned for v3.
## PS Feedback
...
...
@@ -107,7 +106,7 @@ This information is ignored.
This information is locally consumed and generates a PLI request to the corresponding RTP sender.
Also it is locally sent when required. Ie: a new participant joins the conference for a fast rendering by the rest of participants.
Also it is locally sent when required. This is: a new participant joins the conference for a fast rendering by the rest of participants.
### SLI
...
...
@@ -147,7 +146,7 @@ This information is ignored except for the REMB messages, which is locally consu
### REMB
This information is locally consumed.
This information is locally consumed to perform sender side bandwidth estimation.
REMB RTCP is generated locally based on the remote bitrate estimation.
The command produces this SDP output, which represents the **remote** SDP:
```
v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
c=IN IP4 1.2.3.4
t=0 0
a=tool:libavformat 58.20.100
m=audio 1234 RTP/AVP 111
b=AS:128
a=rtpmap:111 opus/48000/2
a=fmtp:111 sprop-stereo=1
```
Commandline options and URL query parameters mean (some of them):
*`-ssrc 666`: Send RTP packets with SSRC 666 (great!).
*`-payload_type 111`: Use 111 as payload type (great!).
*`rtp://1.2.3.4:1234`: Send RTP to IP 1.2.3.4 and port 1234.
*`?rtcpport=1234`: Send RTCP to port 1.2.3.4 (it works, great!).
*`?localrtpport=10000`: Use 10000 as RTP source port (great!).
*`?localrtcpport=10001`: Use 10001 as RTCP source port (it cannot be 10000, sad).
Notes:
*`ffmpeg` can send RTP and RTCP to the same port, which is great, but it cannot listen for RTP and RTCP in the same local port. So we must disable `rtcp-mux` in the `PlainRtpTransport` and send RTP and RTCP to different destination ports.
## Using ffmpeg to send audio to mediasoup
Let's assume that we want to read an mp3 file (located in the server) and send it to the SFU. In mediasoup v3 it would be something as follows:
* Decide which IP, RTP port and RTCP port we are gonna use in `ffmpeg`:
- IP: 127.0.0.1
- RTP port: 2000
- RTCP port: 2001
* Decide which codec, SSRC and PT (payload type) we are gonna send:
- Codec: Opus
- SSRC: 12345678
- PT: 100
* Create a `PlainRtpTransport` in mediasoup:
```js
consttransport=awaitrouter.createPlainTransport(
{
ip:'127.0.0.1',
rtcpMux:false
});
// Read transport local RTP and RTCP ports.
constrtpPort=transport.tuple.localPort;// => For example 3301.
constrtcpPort=transport.rtcpTuple.localPort;// => For example 4502.
// Provide ffmpeg IP/ports.
awaittransport.connect(
{
ip:'127.0.0.1',
port:2000,
rtcpPort:2001
});
```
* Create a `Producer` in such a transport:
```js
constproducer=awaittransport.produce(
{
rtpParameters:
{
codecs:
[
{
name:'opus',
mimeType:'audio/opus',
clockRate:48000,
payloadType:100,
channels:2,
rtcpFeedback:[],
parameters:
{
useinbandfec:1// NOTE: Not sure if ffmpeg allows this for Opus.
}
}
],
encodings:
[
{ssrc:12345678}
]
}
});
```
* Tell `ffmpeg` to send the audio file with the parameters defined above:
**NOTE:** The above JS code (`router.createPlainTransport()` and `transport.produce()`) could be included into an HTTP API server running in the same Node.js in which mediasoup runs. So the ffmpeg "client" could be easily wrapped into a Shell script that calls some `curl` commands followed by the `ffmpeg` command with the retrieved parameters.
## TODO
* What about sending a mp4 file with both audio and video? Can `ffmpeg` be told to send the audio track and the video track to different IPs and ports with separate SSRC and PT values in the commandline, etc?