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

Add use case 3 for custom NACK/RTX #59

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 13 additions & 1 deletion api-outline.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ interface RTCRtpSendStream {
attribute EventHandler onpacketizedrtp;
sequence<RTCRtpPacket> readPacketizedRtp(long maxNumberOfPackets);

attribute EventHandler onreceivedrtcpnacks;
sequence<RTCRtpNack> readReceivedRtcpNacks(long maxNumberOfPackets);

// https://github.com/w3c/webrtc-rtptransport/issues/32
void sendRtp(RTCRtpPacket packet);
Promise<RTCRtpSendResult> sendRtp(RTCRtpPacketInit packet, RTCRtpSendOptions options);
Expand Down Expand Up @@ -152,6 +155,13 @@ enum RTCRtpUnsentReason {

dictionary RTCRtpSendOptions {
DOMHighResTimeStamp sendTime;
// Serializes the first two bytes of the RTP payload as an RTX payload
// and sends using the RTX ssrc.
bool asRtx;
}

interface RTCRtcpNack {
readonly attribute sequence<unsigned short> sequenceNumbers;
}

[Exposed=(Window,Worker), Transferable]
Expand All @@ -164,6 +174,8 @@ interface RTCRtpReceiveStream {
attribute EventHandler onreceivedrtp;
sequence<RTCRtpPacket> readReceivedRtp(long maxNumberOfPackets);

void receiveRtp(RTCRtpPacket packet)
void receiveRtp(RTCRtpPacket packet);

void sendNack(sequence<unsigned short>);
}
```
4 changes: 2 additions & 2 deletions explainer-use-case-1.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ setInterval(() => {
}, 1000);
```

## Example 13: Receive with BYOB
### Example 13: Receive with BYOB
```javascript
const [pc, videoRtpReceiver] = await setupPeerConnectionWithRtpReceiver(); // Custom
const videoRtpReceiveStream = await videoRtpReceiver.replaceReceiveStreams()[0]; // Custom
Expand All @@ -274,7 +274,7 @@ videoRtpReceiveStream.onrtpreceived = () => {
};
```

## Example 14: Packetize with BYOB
### Example 14: Packetize with BYOB
```javascript
const [pc, videoRtpSender] = await setupPeerConnectionWithRtpSender(); // Custom
const videoRtpSendStream = await videoRtpSender.replaceSendStreams()[0];
Expand Down
6 changes: 3 additions & 3 deletions explainer-use-case-2.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Applications can do custom bandwidth estimation via:

## Examples

## Example 1: Custom BWE
### Example 1: Custom BWE

```javascript
const [pc, rtpTransport] = setupPeerConnectionWithRtpTransport(); // Custom
Expand All @@ -40,7 +40,7 @@ rtpTransport.onrtpacksreceived = (rtpAcks) => {

```

## Example 2: Custom Pacing and Probing
### Example 2: Custom Pacing and Probing

```javascript
const [pc, rtpTransport] = setupPeerConnectionWithRtpTransport({customPacer: true}); // Custom
Expand All @@ -59,7 +59,7 @@ while (true) {
}
```

## Example 3: Batched pacing
### Example 3: Batched pacing
Making use of the synchronous readPacketizedRtp method to only read packets in batches
at a controlled frequency.

Expand Down
54 changes: 54 additions & 0 deletions explainer-use-case-3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Custom RTX Use Case

## Motivation

Advanced web applications wish to control NACK and RTX behavior, such as being able to control how large the RTX packet cache is, or how long packets stay in the cache.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Advanced web applications wish to control NACK and RTX behavior

It's not not true, but it's also not very accurate IMO. We want to be able to use custom NACK and RTX mechanisms and formats, not just the standardized ones.

This version of the UC3 also does not support something like FlexFEC.


## Examples

### Example: Custom RTX packet cache

```javascript
const [pc, rtpTransport, rtpSender] = setupPeerConnectionWithRtpTransport(); // Custom
const rtxPacketCache = createRtxPacketCache(); // Custom
const rtpSendStream = await rtpSender.replaceSendStreams()[0];
rtpSendStream.onpacketizedrtp = () => {
const rtpPackets = rtpSendStream.readPacketizedRtp();
for (const rtpPacket of rtpPackets) {
rtxPacketCache.cacheRtpPacket(rtpPacket);
rtpSendStream.sendRtp(rtpPacket);
}
};
// TODO: How do we disable normal NACK processing?
rtpSendStream.onreceivedrtcpnacks = () => {
const nacks = rtpSendStream.readReceivedRtcpNacks();
for (const nack of nacks) {
for (const seqnum of nack.sequenceNumbers) {
const cachedRtpPacket = rtxPacketCache.getCachedRtpPacketBySequenceNumber(seqnum);
if (cachedRtpPacket) {
rtpSendStream.sendRtp(cachedRtpPacket, {asRtx: true});
}
}
}
}
```

### Example: Custom NACK

```javascript
const [pc, rtpTransport, rtpReceiver] = setupPeerConnectionWithRtpTransport(); // Custom
const nackCalculator = createNackCalculator(); // Custom
const rtpReceiveStream = await rtpReceiver.replaceReceiveStreams()[0];
// TODO: How do we disable normal NACK sending?
rtpReceiveStream.onrtpreceived = () => {
const rtpPacket = rtpReceiveStream.readReceivedRtp();
const nackedSequenceNumbers = nackCalaculator.calculateNackedSequenceNumbers(rtpPacket);
if (nackedSequenceNumbers) {
rtpRecieveStream.sendNack(nackedSequenceNumbers);
}
}
```

### Example: Custom RTX payload

TODO
Loading