From 64617b75e603ecf15554ea59384d086c8b0219e9 Mon Sep 17 00:00:00 2001 From: Bernard Aboba Date: Tue, 18 Apr 2017 10:54:00 -0700 Subject: [PATCH 1/3] RTP matching rules Yet another attempt to fix Issues https://github.com/w3c/ortc/issues/368, https://github.com/w3c/ortc/issues/546, https://github.com/w3c/ortc/issues/547 --- index.html | 79 +++++++++++++++++++++++++++++------------------------- 1 file changed, 42 insertions(+), 37 deletions(-) diff --git a/index.html b/index.html index 2785c9c..44c81ce 100644 --- a/index.html +++ b/index.html @@ -4409,44 +4409,49 @@

RTP matching rules

is called, and are removed when receiver.stop() is called. If receiver.receive(parameters) is called again, all entries referencing receiver are removed prior to adding new entries.

-

muxId table:

+

+

Table construction

+

As noted in [[!BUNDLE]] Section 10.2, to prepare for demultiplexing RTP/RTCP + packets to the correct RTCRtpReceiver the following steps + MUST be followed:

    -
  1. If parameters.muxId is set, - muxId_table[parameters.muxId] is set to receiver.
  2. -
  3. If muxId_table[muxId] is already set to a value other than - receiver, then receiver.receive() will be rejected with - InvalidParameters.
  4. -
-

SSRC table:

-
    -
  1. Set ssrc_table[parameters.encodings[i].ssrc] - to receiver for each entry where - parameters.encodings[i].ssrc is set, for values of - i from 0 to encodings.length-1.
  2. -
  3. Set ssrc_table[parameters.encodings[i].rtx.ssrc] - to receiver for each entry where - parameters.encodings[i].rtx.ssrc is set, for values of - i from 0 to encodings.length-1.
  4. -
  5. Set ssrc_table[parameters.encodings[i].fec.ssrc] - to receiver for each entry where - parameters.encodings[i].fec.ssrc is set, for values of - i from 0 to encodings.length-1.
  6. -
  7. If ssrc_table[ssrc] is already set to a value other - than receiver, then receiver.receive() will be rejected - with InvalidParameters.
  8. -
-

payload type table:

-

    -
  1. If parameters.muxId is set, abort these steps.
  2. -
  3. If parameters.encodings[i].ssrc is unset for all - values of i from 0 to encodings.length-1, then add - entries to pt_table by setting - pt_table[parameters.codecs[j].payloadType] to - receiver, for values of j from 0 to codecs.length-1.
  4. -
  5. If pt_table[pt] is already set to a value other than - receiver then receiver.receive() will be rejected with - InvalidParameters.
  6. -
+
    muxId table construction +
  1. If parameters.muxId is set, + muxId_table[parameters.muxId] is set to receiver.
  2. +
  3. If muxId_table[muxId] is already set to a value other than + receiver, then receiver.receive() will be rejected with + InvalidParameters.
  4. +
+
    SSRC table construction +
  1. Set ssrc_table[parameters.encodings[i].ssrc] + to receiver for each entry where + parameters.encodings[i].ssrc is set, for values of + i from 0 to encodings.length-1.
  2. +
  3. Set ssrc_table[parameters.encodings[i].rtx.ssrc] + to receiver for each entry where + parameters.encodings[i].rtx.ssrc is set, for values of + i from 0 to encodings.length-1.
  4. +
  5. Set ssrc_table[parameters.encodings[i].fec.ssrc] + to receiver for each entry where + parameters.encodings[i].fec.ssrc is set, for values of + i from 0 to encodings.length-1.
  6. +
  7. If ssrc_table[ssrc] is already set to a value other + than receiver, then receiver.receive() will be rejected + with InvalidParameters.
  8. +
+
    payload type table construction +
  1. If parameters.muxId is set, abort these steps.
  2. +
  3. If parameters.encodings[i].ssrc is unset for all + values of i from 0 to encodings.length-1, then add + entries to pt_table by setting + pt_table[parameters.codecs[j].payloadType] to + receiver, for values of j from 0 to codecs.length-1.
  4. +
  5. If pt_table[pt] is already set to a value other than + receiver then receiver.receive() will be rejected with + InvalidParameters.
  6. +
+ +

RTP packet handling

When an RTP packet arrives, the implementation determines the From 1a1427c90c3f1196a592a70d9029cded5de26d5f Mon Sep 17 00:00:00 2001 From: Bernard Aboba Date: Tue, 18 Apr 2017 11:00:13 -0700 Subject: [PATCH 2/3] Align PT table construction with BUNDLE algorithm --- index.html | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/index.html b/index.html index 44c81ce..2a91c47 100644 --- a/index.html +++ b/index.html @@ -4415,14 +4415,14 @@

Table construction

packets to the correct RTCRtpReceiver the following steps MUST be followed:

    -
      muxId table construction +
        muxId table construction
      • If parameters.muxId is set, muxId_table[parameters.muxId] is set to receiver.
      • If muxId_table[muxId] is already set to a value other than receiver, then receiver.receive() will be rejected with InvalidParameters.
      • -
    -
      SSRC table construction + +
        SSRC table construction
      • Set ssrc_table[parameters.encodings[i].ssrc] to receiver for each entry where parameters.encodings[i].ssrc is set, for values of @@ -4438,18 +4438,13 @@

        Table construction

      • If ssrc_table[ssrc] is already set to a value other than receiver, then receiver.receive() will be rejected with InvalidParameters.
      • -
    -
      payload type table construction -
    1. If parameters.muxId is set, abort these steps.
    2. -
    3. If parameters.encodings[i].ssrc is unset for all - values of i from 0 to encodings.length-1, then add - entries to pt_table by setting - pt_table[parameters.codecs[j].payloadType] to + +
        payload type table construction +
      • Set pt_table[parameters.codecs[j].payloadType] to receiver, for values of j from 0 to codecs.length-1.
      • If pt_table[pt] is already set to a value other than - receiver then receiver.receive() will be rejected with - InvalidParameters.
      • -
    + receiver then set pt_table[pt] to null. +
From 3bae28d3043b2287ebb11340d2432e0ad2c7ef86 Mon Sep 17 00:00:00 2001 From: Bernard Aboba Date: Tue, 18 Apr 2017 14:57:37 -0700 Subject: [PATCH 3/3] RTP routing rule update --- index.html | 91 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 48 insertions(+), 43 deletions(-) diff --git a/index.html b/index.html index 2a91c47..4a9008b 100644 --- a/index.html +++ b/index.html @@ -4398,8 +4398,16 @@

RTP matching rules

the packet to, based on the values of the SSRC and payload type fields in the RTP header, as well as the value of the MID RTP header extension, if present.

+

Applications can implement RTP stacks in different ways. Within Sections + 8.3.1, 8.3.2 and 13.4, algorithms are provided that are based on + the RTP/RTCP packet routing behavior described in [[!BUNDLE]] Section 10.2. + However, this material is not meant to prescribe exactly how the RTP + stack is implemented. Implementations MAY use any algorithms that + achieves equivalent results to those described in [[!BUNDLE]] Section 10.2.

+
+

Table maintenance

The RTCRtpListener maintains three tables in order to - facilitate matching: the ssrc_table which maps SSRC values to + facilitate RTP packet routing: the ssrc_table which maps SSRC values to RTCRtpReceiver objects; the muxId_table which maps values of the MID header extension to RTCRtpReceiver objects and the pt_table which maps payload type values to @@ -4409,24 +4417,22 @@

RTP matching rules

is called, and are removed when receiver.stop() is called. If receiver.receive(parameters) is called again, all entries referencing receiver are removed prior to adding new entries.

-
-

Table construction

-

As noted in [[!BUNDLE]] Section 10.2, to prepare for demultiplexing RTP/RTCP - packets to the correct RTCRtpReceiver the following steps - MUST be followed:

-
    -
      muxId table construction +

      To prepare for demultiplexing RTP packets to the correct + RTCRtpReceiver the following steps MUST be followed:

      + muxId table construction +
      1. If parameters.muxId is set, muxId_table[parameters.muxId] is set to receiver.
      2. If muxId_table[muxId] is already set to a value other than receiver, then receiver.receive() will be rejected with InvalidParameters.
      3. -
    -
      SSRC table construction +
+ SSRC table construction +
  1. Set ssrc_table[parameters.encodings[i].ssrc] to receiver for each entry where parameters.encodings[i].ssrc is set, for values of - i from 0 to encodings.length-1.
  2. + i from 0 to encodings.length-1.
  3. Set ssrc_table[parameters.encodings[i].rtx.ssrc] to receiver for each entry where parameters.encodings[i].rtx.ssrc is set, for values of @@ -4436,48 +4442,47 @@

    Table construction

    parameters.encodings[i].fec.ssrc is set, for values of i from 0 to encodings.length-1.
  4. If ssrc_table[ssrc] is already set to a value other - than receiver, then receiver.receive() will be rejected + than receiver, then receiver.receive() will be rejected with InvalidParameters.
  5. - -
      payload type table construction +
+ Payload Type table construction +
  1. Set pt_table[parameters.codecs[j].payloadType] to receiver, for values of j from 0 to codecs.length-1.
  2. If pt_table[pt] is already set to a value other than receiver then set pt_table[pt] to null.
  3. - -
+

RTP packet handling

-

When an RTP packet arrives, the implementation determines the - RTCRtpReceiver rtp_receiver to send it to as - follows: -

    -
  1. If packet.muxId is set: If - muxId_table[packet.muxId] is unset, fire the - unhandledrtp event, else set rtp_receiver to - muxId_table[packet.muxId] and check whether the value of - packet.pt is equal to one of the values of +

    For each RTP packet received, the following steps MUST be followed + to route the RTP packet packet to the correct + RTCRtpReceiver rtp_receiver. + Note that the phrase "deliver a packet to rtp_receiver' + means to further process the packet as would normally happen with RTP/RTCP, + including firing the unhandledrtp event if the packet's + payload type does not match any payload type configured for + rtp_receiver. This is determined by checking whether + packet.pt is equal to any of the values of parameters.codecs[j].payloadtype for the RTCRtpReceiver object rtp_receiver, where - j varies from 0 to codecs.length-1. If so, set - ssrc_table[packet.ssrc] to rtp_receiver and route - the packet to rtp_receiver. If packet.pt does not match, fire - the unhandledrtp event.

  2. -
  3. Else if ssrc_table[packet.ssrc] is set: set - rtp_receiver to ssrc_table[packet.ssrc] - and check whether the value of packet.pt is equal to one of the - values of parameters.codecs[j].payloadtype - for rtp_receiver, where j varies from 0 to - codecs.length-1. If so, route the packet to rtp_receiver. - If packet.pt does not match, fire the unhandledrtp event.
  4. -
  5. Else if pt_table[packet.pt] is set: set - rtp_receiver to pt_table[packet.pt], set - ssrc_table[packet.ssrc] to rtp_receiver - and route the packet to rtp_receiver.
  6. -
  7. Else if no matches are found in the ssrc_table, - muxId_table or pt_table, fire the - unhandledrtp event.
  8. + j varies from 0 to codecs.length-1. +
      +
    1. If packet.muxId is set and + muxId_table[packet.muxId] is unset, fire the + unhandledrtp event and stop.
    2. +
    3. If packet.muxId is set and the packet's extended + sequence number is greater than that of the last MID update, as discussed + in [[RFC7941]] Section 4.2.6, set ssrc_table[packet.ssrc] + to muxId_table[packet.muxId].
    4. +
    5. If ssrc_table[packet.ssrc] is set, set + rtp_receiver to ssrc_table[packet.ssrc] and + deliver the packet to rtp_receiver.
    6. +
    7. If pt_table[packet.pt] is set, set + rtp_receiver and ssrc_table[packet.ssrc] + to pt_table[packet.pt] and deliver the packet + to rtp_receiver.
    8. +
    9. Otherwise, fire the unhandledrtp event.