Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document new changes/additions in mediasoup v3 done within flatbuffers branch #50

Merged
merged 6 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 88 additions & 3 deletions _includes/documentation/v3/mediasoup/api/DataConsumer.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,16 @@ Field | Type | Description | Required | Default
`ordered` | Boolean | Just if consuming over SCTP. Whether data messages must be received in order. If `true` the messages will be sent reliably. | No | The value in the data producer (if it's of type 'sctp') or `true` (if it's of type 'direct').
`maxPacketLifeTime` | Number | Just if consuming over SCTP. When `ordered` is `false`, it indicates the time (in milliseconds) after which a SCTP packet will stop being retransmitted. | No | The value in the data producer (if it's of type 'sctp') or unset (if it's of type 'direct').
`maxRetransmits` | Number | Just if consuming over SCTP. When `ordered` is `false`, it indicates the maximum number of times a packet will be retransmitted. | No | The value in the data producer (if it's of type 'sctp') or unset (if it's of type 'direct').
`paused` | Boolean | Whether the data consumer must start in paused mode. | No | `false`
`subchannels` | Array<Number> | Subchannels (unsigned 16 bit integers) this data consumer initially subscribes to. | No |
`appData` | [AppData](#AppData) | Custom application data. | No | `{ }`

</div>

<div markdown="1" class="note">
`subchannels` are only used in case this data consumer receives messages from a data producer created on a direct transport that specifies subchannel(s) when calling [dataProducer.send()](#dataProducer-send).
</div>

</section>


Expand Down Expand Up @@ -105,6 +111,31 @@ The data consumer sub-protocol.

> `@type` String , read only

#### dataConsumer.paused
{: #dataConsumer-paused .code}

Whether the data consumer is paused.

> `@type` Boolean, read only

#### dataConsumer.dataProducerPaused
{: #dataConsumer-dataProducerPaused .code}

Whether the associated data producer is paused.

> `@type` Boolean, read only

#### dataConsumer.subchannels
{: #dataConsumer-subchannels .code}

Subchannels (unsigned 16 bit integers) this data consumer is currently subscribed to.

> `@type` Array&lt;Number&gt;, read only

<div markdown="1" class="note">
`subchannels` are only used in case this data consumer receives messages from a data producer created on a direct transport that specifies subchannel(s) when calling [dataProducer.send()](#dataProducer-send).
</div>

#### dataConsumer.appData
{: #dataConsumer-appData .code}

Expand Down Expand Up @@ -181,7 +212,8 @@ Whenever the underlaying SCTP association buffered bytes drop to this value, [bu
Sends direct messages from the Node.js process.

<div markdown="1" class="note">
Just available in data consumers of type "SCTP".
- Just available in data consumers of type "SCTP".
- If the data cannot be sent due to the underlying SCTP send buffer being full, the method will fail with an Error instance which `message` equals `sctpsendbufferfull`.
</div>

<div markdown="1" class="table-wrapper L3">
Expand All @@ -201,12 +233,45 @@ dataConsumer.send(stringMessage);
dataConsumer.send(binaryMessage);
```

<div markdown="1" class="note">
If the data cannot be sent due to the underlying SCTP send buffer being full, the method will fail with an Error instance which `message` equals `sctpsendbufferfull`.
> `@async`

#### dataConsumer.pause()
{: #dataConsumer-pause .code}

Pauses the data consumer (no messages are sent to the consuming endpoint).

> `@async`

#### dataConsumer.resume()
{: #dataConsumer-resume .code}

Resumes the data consumer (messages are sent again to the consuming endpoint).

> `@async`

#### dataConsumer.setSubchannels(subchannels)
{: #dataConsumer-setSubchannels .code}

Update subchannels this data consumer is subscribed to.

<div markdown="1" class="table-wrapper L3">

Argument | Type | Description | Required | Default
--------- | ------- | ----------- | -------- | ----------
`subchannels` | Array&lt;Number&gt; | Subchannels (unsigned 16 bit integers) this data consumer is subscribed to. | Yes |

</div>

> `@async`

<div markdown="1" class="note">
`subchannels` are only used in case this data consumer receives messages from a data producer created on a direct transport that specifies subchannel(s) when calling [dataProducer.send()](#dataProducer-send).
</div>

```javascript
dataConsumer.setSubchannels([ 1, 4 ]);
```

</section>


Expand Down Expand Up @@ -239,6 +304,16 @@ dataConsumer.on("dataproducerclose", () =>
});
```

#### dataConsumer.on("dataproducerpause", fn())
{: #dataConsumer-on-dataproducerpause .code}

Emitted when the associated data producer is paused.

#### dataConsumer.on("dataproducerresume", fn())
{: #dataConsumer-on-dataproducerresume .code}

Emitted when the associated data producer is resumed.

#### dataConsumer.on("message", fn(message, ppid))
{: #dataConsumer-on-message .code}

Expand Down Expand Up @@ -306,4 +381,14 @@ See the [Observer API](#observer-api) section below.

Emitted when the data consumer is closed for whatever reason.

#### dataConsumer.observer.on("pause", fn())
{: #dataConsumer-observer-on-pause .code}

Emitted when the data consumer is paused.

#### dataConsumer.observer.on("resume", fn())
{: #dataConsumer-observer-on-resume .code}

Emitted when the data consumer is resumed.

</section>
48 changes: 43 additions & 5 deletions _includes/documentation/v3/mediasoup/api/DataProducer.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Field | Type | Description | Required | Default
`sctpStreamParameters` | [SctpStreamParameters](/documentation/v3/mediasoup/sctp-parameters/#SctpStreamParameters) | SCTP parameters defining how the endpoint is sending the data. Required if SCTP/DataChannel is used. Must not be given if the data producer is created on a `DirectTransport`. | No |
`label` | String | A label which can be used to distinguish this DataChannel from others. | No |
`protocol` | String | Name of the sub-protocol used by this DataChannel. | No |
`paused` | Boolean | Whether the data producer must start in paused mode. | No | `false`
`appData` | [AppData](#AppData) | Custom application data. | No | `{ }`

</div>
Expand Down Expand Up @@ -97,6 +98,13 @@ The data producer sub-protocol.

> `@type` String , read only

#### dataProducer.paused
{: #dataProducer-paused .code}

Whether the data producer is paused.

> `@type` Boolean, read only

#### dataProducer.appData
{: #dataProducer-appData .code}

Expand Down Expand Up @@ -137,24 +145,26 @@ Returns current statistics of the data producer.
Check the [RTC Statistics](/documentation/v3/mediasoup/rtc-statistics/) section for more details.
</div>

#### dataProducer.send(message, ppid)
#### dataProducer.send(message, ppid, subchannels, requiredSubchannel)
{: #dataProducer-send .code}

Sends direct messages from the Node.js process.

<div markdown="1" class="note">
Just available in direct transports, this is, those created via `router.createDirectTransport()`.
</div>

<div markdown="1" class="table-wrapper L3">

Argument | Type | Description | Required | Default
--------- | ------- | ----------- | -------- | ----------
`message` | String\|Buffer | Message to be sent (can be binary by using a Node.js Buffer). | Yes |
`ppid` | Number | Mimics the [SCTP Payload Protocol Identifier](https://www.iana.org/assignments/sctp-parameters/sctp-parameters.xhtml#sctp-parameters-25). In most cases it must not be set. | No | 51 (`WebRTC String`) if `message` is a String and 53 (`WebRTC Binary`) if it's a Buffer.
`subchannels` | Array&lt;Number&gt; | Only data consumers subscribed to at least one of these subchannels (unsigned 16 bit integers) will receive the message. | No |
`requiredSubchannel` | Number | Only data consumers subscribed to this subchannel (unsigned 16 bit integer) will receive the message. | No |

</div>

<div markdown="1" class="note">
Just available in direct transports, this is, those created via `router.createDirectTransport()`.
</div>

```javascript
const stringMessage = "hello";
const binaryMessage = Buffer.from([ 1, 2, 3, 4 ]);
Expand All @@ -163,6 +173,24 @@ dataProducer.send(stringMessage);
dataProducer.send(binaryMessage);
```

```javascript
dataProducer.send("bye", /*ppid*/ undefined, /*subchannels*/ [ 24 ]);
```

#### dataProducer.pause()
{: #dataProducer-pause .code}

Pauses the data producer (no messages are sent to its associated data consumers). Triggers a ["dataproducerpause"](#dataConsumer-on-dataproducerpause) event in all its associated data consumers.

> `@async`

#### dataProducer.resume()
{: #dataProducer-resume .code}

Resumes the data producer (messages are sent again to its associated data consumers). Triggers a ["dataproducerresume"](#dataConsumer-on-dataproducerresume) event in all its associated data consumers.

> `@async`

</section>


Expand Down Expand Up @@ -200,4 +228,14 @@ See the [Observer API](#observer-api) section below.

Emitted when the producer is closed for whatever reason.

#### dataProducer.observer.on("pause", fn())
{: #dataProducer-observer-on-pause .code}

Emitted when the data producer is paused.

#### dataProducer.observer.on("resume", fn())
{: #dataProducer-observer-on-resume .code}

Emitted when the data producer is resumed.

</section>
5 changes: 5 additions & 0 deletions _includes/documentation/v3/mediasoup/api/PipeTransport.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ When calling [consume()](#transport-consume) on a pipe transport, all RTP stream

Field | Type | Description | Required | Default
------------- | ------- | ------------- | -------- | ---------
`listenInfo` | [TransportListenInfo](#TransportListenInfo)| Listening information. | Yes |
`listenIp` | [TransportListenIp](#TransportListenIp)\|String| Listening IP address. | Yes |
`port` | Number | Fixed port to listen on instead of selecting automatically from Worker's port range. | No |
`enableSctp` | Boolean | Create a SCTP association. | No | `false`
Expand All @@ -38,6 +39,10 @@ Field | Type | Description | Required | Default

</div>

<div markdown="1" class="note">
* `listenIp` and `port` are **DEPRECATED**. Use `listenInfo` instead.
</div>

</section>


Expand Down
4 changes: 4 additions & 0 deletions _includes/documentation/v3/mediasoup/api/PlainTransport.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ A plain transport represents a network path through which RTP, RTCP (optionally

Field | Type | Description | Required | Default
------------- | ------- | ------------- | -------- | ---------
`listenInfo` | [TransportListenInfo](#TransportListenInfo)| Listening information. | Yes |
`rtcpListenInfo` | [TransportListenInfo](#TransportListenInfo)| RTCP listening information. If not given and `rtcpPort` is not `false`, RTCP will use same listening info than RTP. | No |
`listenIp` | [TransportListenIp](#TransportListenIp)\|String| Listening IP address. | Yes |
`port` | Number | Fixed port to listen on instead of selecting automatically from Worker's port range. | No |
`rtcpMux` | Boolean | Use RTCP-mux (RTP and RTCP in the same port). | No | `true`
Expand All @@ -37,6 +39,8 @@ Field | Type | Description | Required | Default
</div>

<div markdown="1" class="note">
* `listenIp` and `port` are **DEPRECATED**. Use `listenInfo` instead.
* `rtcpPort` is **DEPRECATED**. Use `rtcpListenInfo` instead to setup different listening information for RTCP.
* Note that `comedia` mode just makes sense when the remote endpoint is gonna produce RTP on this plain transport. Otherwise, if the remote endpoint does not send any RTP (or SCTP) packet to mediasoup, there is no way to detect its remote RTP IP and port, so the endpoint won't receive any packet from mediasoup.
* In other words, do not use `comedia` mode if the remote endpoint is not going to produce RTP but just consume it. In those cases, do not set `comedia` flag and call [connect()](#plainTransport-connect) with the IP and port(s) of the remote endpoint.
</div>
Expand Down
2 changes: 0 additions & 2 deletions _includes/documentation/v3/mediasoup/api/Producer.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,13 @@ Check the [RTC Statistics](/documentation/v3/mediasoup/rtc-statistics/) section

Pauses the producer (no RTP is sent to its associated consumers). Triggers a ["producerpause"](#consumer-on-producerpause) event in all its associated consumers.


> `@async`

#### producer.resume()
{: #producer-resume .code}

Resumes the producer (RTP is sent again to its associated consumers). Triggers a ["producerresume"](#consumer-on-producerresume) event in all its associated consumers.


> `@async`

#### producer.enableTraceEvent(types)
Expand Down
31 changes: 22 additions & 9 deletions _includes/documentation/v3/mediasoup/api/Router.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Field | Type | Description | Required | Default
`producerId` | String | Producer id. | No |
`dataProducerId` | String | Data producer id. | No |
`router` | [Router](#Router) | Destination router to pipe the given producer. | Yes |
`listenInfo` | [TransportListenInfo](#TransportListenInfo)| Listening information to connect both routers in the same host. | No | `{ protocol: "udp", ip: "127.0.0.1" }`
`listenIp` | String | IP to connect both routers in the same host. | No | "127.0.0.1"
`enableSctp` | Boolean | Create a SCTP association. | No | `true`
`numSctpStreams` | [NumSctpStreams](#NumSctpStreams) | SCTP streams number. | No |
Expand All @@ -53,6 +54,7 @@ Field | Type | Description | Required | Default
</div>

<div markdown="1" class="note">
* `listenIp` is **DEPRECATED**. Use `listenInfo` instead.
* Only one of `producerId` and `dataProducerId` must be provided.
* SCTP arguments will only apply the first time the underlying transports are created.
</div>
Expand Down Expand Up @@ -167,12 +169,23 @@ TypeScript argument | Type | Description | Required | Default
```javascript
const transport = await router.createWebRtcTransport(
{
// Use webRtcServer or listenIps
webRtcServer : webRtcServer
listenIps : [ { ip: "192.168.0.111", announcedIp: "88.12.10.41" } ],
enableUdp : true,
enableTcp : true,
preferUdp : true
enableTcp : false
});
```

```javascript
const transport = await router.createWebRtcTransport(
{
listenInfos :
[
{
protocol : "udp",
ip : "192.168.0.111",
announcedIp : "88.12.10.41"
}
]
});
```

Expand Down Expand Up @@ -205,9 +218,9 @@ TypeScript argument | Type | Description | Required | Default
```javascript
const transport = await router.createPlainTransport(
{
listenIp : "a1:22:aA::08",
rtcpMux : true,
comedia : true
listenInfo : { protocol: "udp", ip: "a1:22:aA::08" },
rtcpMux : true,
comedia : true
});
```

Expand Down Expand Up @@ -240,7 +253,7 @@ TypeScript argument | Type | Description | Required | Default
```javascript
const transport = await router.createPipeTransport(
{
listenIp : "192.168.1.33"
listenInfo : { protocol: "udp", ip: "192.168.1.33" },
});
```

Expand Down Expand Up @@ -274,7 +287,7 @@ TypeScript argument | Type | Description | Required | Default
const transport = await router.createDirectTransport();
```

#### router.pipeToRouter({ producerId, dataProducerId, router, listenIp })
#### router.pipeToRouter(options)
{: #router-pipeToRouter .code}

Pipes the given media or data producer into another router in the same host. It creates an underlying [PipeTransport](#PipeTransport) (if not previously created) that interconnects both routers.
Expand Down
25 changes: 24 additions & 1 deletion _includes/documentation/v3/mediasoup/api/Transport.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,28 @@ mediasoup implements the following transport classes:

<section markdown="1">

#### TransportListenInfo
{: #TransportListenInfo .code}

<div markdown="1" class="table-wrapper L3">

Field | Type | Description | Required | Default
------------- | ------- | ------------- | -------- | ---------
`protocol` | String | Protocol ("udp" / "tcp"). | Yes |
`ip` | String | Listening IPv4 or IPv6. | Yes |
`announcedIp` | String | Announced IPv4 or IPv6 (useful when running mediasoup behind NAT with private IP). | No |
`port` | Number | Listening port. | No | If not given, a random available port from the Worker's port range will be used.
`sendBufferSize` | Number | Send buffer size (in bytes). | No |
`recvBufferSize` | Number | Receive buffer size (in bytes). | No |

</div>

<div markdown="1" class="note">
If you use "0.0.0.0" or "::" as `ip` value, then you need to also provide `announcedIp`.
</div>

<section markdown="1">

#### TransportListenIp
{: #TransportListenIp .code}

Expand All @@ -35,7 +57,8 @@ Field | Type | Description | Required | Default
</div>

<div markdown="1" class="note">
If you use "0.0.0.0" or "::" as `ip` value, then you need to also provide `announcedIp`.
* **DEPRECATED:** Use [TransportListenInfo](#TransportListenInfo) instead.
* If you use "0.0.0.0" or "::" as `ip` value, then you need to also provide `announcedIp`.
</div>

#### TransportTuple
Expand Down
Loading