From ea0c010e1395d92be1326684f87b205f037c0738 Mon Sep 17 00:00:00 2001 From: Jan-Ivar Bruaroey Date: Wed, 27 Jul 2022 18:51:56 -0400 Subject: [PATCH 1/9] Don't let offers to receive simulcast overwrite existing [[SendEncodings]] --- webrtc.html | 52 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 12 deletions(-) diff --git a/webrtc.html b/webrtc.html index a83c41ba2..388a7e99d 100644 --- a/webrtc.html +++ b/webrtc.html @@ -2330,24 +2330,24 @@

each of the simulcast layers, populating the {{RTCRtpCodingParameters/rid}} member according to the corresponding rid value, and - let sendEncodings be the list + let receiveEncodings be the list containing the created dictionaries. - Otherwise, let sendEncodings be an + Otherwise, let receiveEncodings be an empty list.

  • Let supportedEncodings be the maximum number of encodings that the implementation can support. If the length of - sendEncodings is greater than + receiveEncodings is greater than supportedEncodings, truncate - sendEncodings so that its length is + receiveEncodings so that its length is supportedEncodings.
  • -
  • If sendEncodings is non-empty, set +
  • If receiveEncodings is non-empty, set each encoding's {{RTCRtpEncodingParameters/scaleResolutionDownBy}} - to 2^(length of sendEncodings - + to 2^(length of receiveEncodings - encoding index - 1).
  • @@ -2364,12 +2364,40 @@

    If a suitable transceiver was found (transceiver is set) and - sendEncodings is non-empty, set - transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[SendEncodings]]}} - to sendEncodings, and set - transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[LastReturnedParameters]]}} - to null. + receiveEncodings is non-empty, run + the following steps:

    +
      +
    1. +

      + If + transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[SendEncodings]]}} + is non-empty, then for each encoding, + encoding, in + transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[SendEncodings]]}}, + copy all of encoding's members + and their values to the encoding with the + same {{RTCRtpCodingParameters/rid}} in + receiveEncodings, if there is one. +

      +

      + Set + transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[SendEncodings]]}} + to receiveEncodings, and set + transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[LastReturnedParameters]]}} + to null. +

      + If this step produces a net change in an + existing non-empty + transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[SendEncodings]]}}, + then the process of applying + description fails. This + specification does not allow remotely + initiated RID renegotiation. +
      +

      +
    2. +

  • @@ -2384,7 +2412,7 @@

    [= Create an RTCRtpSender =], sender, from the [= media description =] using - sendEncodings. + receiveEncodings.

  • Date: Tue, 2 Aug 2022 17:17:28 -0400 Subject: [PATCH 2/9] s/receiveEncodings/proposedSendEncodings/ --- webrtc.html | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/webrtc.html b/webrtc.html index 388a7e99d..44e246207 100644 --- a/webrtc.html +++ b/webrtc.html @@ -2330,24 +2330,24 @@

    each of the simulcast layers, populating the {{RTCRtpCodingParameters/rid}} member according to the corresponding rid value, and - let receiveEncodings be the list - containing the created dictionaries. - Otherwise, let receiveEncodings be an - empty list. + let proposedSendEncodings be the + list containing the created dictionaries. + Otherwise, let proposedSendEncodings + be an empty list.

  • Let supportedEncodings be the maximum number of encodings that the implementation can support. If the length of - receiveEncodings is greater than + proposedSendEncodings is greater than supportedEncodings, truncate - receiveEncodings so that its length is + proposedSendEncodings so that its length is supportedEncodings.
  • -
  • If receiveEncodings is non-empty, set - each encoding's +
  • If proposedSendEncodings is non-empty, + set each encoding's {{RTCRtpEncodingParameters/scaleResolutionDownBy}} - to 2^(length of receiveEncodings - + to 2^(length of proposedSendEncodings - encoding index - 1).
  • @@ -2364,8 +2364,8 @@

    If a suitable transceiver was found (transceiver is set) and - receiveEncodings is non-empty, run - the following steps: + proposedSendEncodings is non-empty, + run the following steps:

    1. @@ -2378,12 +2378,13 @@

      copy all of encoding's members and their values to the encoding with the same {{RTCRtpCodingParameters/rid}} in - receiveEncodings, if there is one. + proposedSendEncodings, if there + is one.

      Set transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[SendEncodings]]}} - to receiveEncodings, and set + to proposedSendEncodings, and set transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[LastReturnedParameters]]}} to null.

      @@ -2412,7 +2413,7 @@

      [= Create an RTCRtpSender =], sender, from the [= media description =] using - receiveEncodings. + proposedSendEncodings.

    2. Date: Wed, 3 Aug 2022 14:59:33 -0400 Subject: [PATCH 3/9] rebased Spell out failure criteria earlier in 4.5. --- webrtc.html | 76 +++++++++++++++++++++-------------------------------- 1 file changed, 30 insertions(+), 46 deletions(-) diff --git a/webrtc.html b/webrtc.html index 44e246207..072869e48 100644 --- a/webrtc.html +++ b/webrtc.html @@ -1758,21 +1758,30 @@

    3. If remote is true, and - description is of type {{RTCSdpType/"offer"}} - and contains a request to receive simulcast, and applying - description leads to modifying a - transceiver transceiver, and - transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[SendEncodings]]}} - is non-empty, and not equal to the encodings that would - result from processing description, the - process of applying description fails. This - specification does not allow remotely initiated RID - renegotiation. + description is of type + {{RTCSdpType/"offer"}}, then for each + [= media description =] requesting to receive simulcast + that already has an existing {{RTCRtpTransceiver}} object, + transceiver, associated with it, as described in + [[!RFC8829]], + if the rid values specified in the simulcast attribute (up + to the maximum number the implementation supports) differ + in name, order or number from the ones previously used to + populate + transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[SendEncodings]]}}, + then [= description fails | fail =] the process of + applying description. +

      + This specification does not allow remotely initiated RID + renegotiation. +

    4. - If the process to apply description fails for + If the process to apply + description fails for any reason, then the user agent MUST queue a task that runs the following steps:

      @@ -2322,7 +2331,8 @@

    5. If the description is of type - {{RTCSdpType/"offer"}} and contains a request + {{RTCSdpType/"offer"}} and the + [= media description =] contains a request to receive simulcast, use the order of the rid values specified in the simulcast attribute to create an @@ -2363,42 +2373,16 @@

    6. If a suitable transceiver was found - (transceiver is set) and + (transceiver is set), proposedSendEncodings is non-empty, - run the following steps: + and + transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[SendEncodings]]}} + is empty, then set + transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[SendEncodings]]}} + to proposedSendEncodings, and set + transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[LastReturnedParameters]]}} + to null.

      -
        -
      1. -

        - If - transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[SendEncodings]]}} - is non-empty, then for each encoding, - encoding, in - transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[SendEncodings]]}}, - copy all of encoding's members - and their values to the encoding with the - same {{RTCRtpCodingParameters/rid}} in - proposedSendEncodings, if there - is one. -

        -

        - Set - transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[SendEncodings]]}} - to proposedSendEncodings, and set - transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[LastReturnedParameters]]}} - to null. -

        - If this step produces a net change in an - existing non-empty - transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[SendEncodings]]}}, - then the process of applying - description fails. This - specification does not allow remotely - initiated RID renegotiation. -
        -

        -
      2. -
    7. From e671a7c0ff7b22b96dd694aa045798b6e4dafd78 Mon Sep 17 00:00:00 2001 From: Jan-Ivar Bruaroey Date: Thu, 4 Aug 2022 15:39:07 -0400 Subject: [PATCH 4/9] fix duplicate id --- webrtc.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webrtc.html b/webrtc.html index 072869e48..8e9e14760 100644 --- a/webrtc.html +++ b/webrtc.html @@ -1780,7 +1780,7 @@

    8. If the process to apply + id="fail-description">process to apply description fails for any reason, then the user agent MUST queue a task that runs the following steps: From b33b27244800402320e70440c03ad0b385c70e91 Mon Sep 17 00:00:00 2001 From: Jan-Ivar Bruaroey Date: Thu, 29 Sep 2022 20:25:21 -0400 Subject: [PATCH 5/9] Only fail over rid mismatch on first encoding and truncate past that. --- webrtc.html | 83 ++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 70 insertions(+), 13 deletions(-) diff --git a/webrtc.html b/webrtc.html index 8e9e14760..6fcb0e36c 100644 --- a/webrtc.html +++ b/webrtc.html @@ -1764,14 +1764,18 @@

      that already has an existing {{RTCRtpTransceiver}} object, transceiver, associated with it, as described in [[!RFC8829]], - if the rid values specified in the simulcast attribute (up - to the maximum number the implementation supports) differ - in name, order or number from the ones previously used to - populate - transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[SendEncodings]]}}, + if the first encoding in + transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[SendEncodings]]}} + [=map/contains=] a {{RTCRtpCodingParameters/rid}} member, and its + value does not match the first rid in the simulcast attribute, then [= description fails | fail =] the process of applying description.
      + A change in the number of rid values is tolerated in + remote offers as long as the first rid matches the rid + of the first encoding that was previously negotiated. + Mismatched or out-of-order rids result in layer reduction, + and layer expansion is prevented in user agent answers. This specification does not allow remotely initiated RID renegotiation.
      @@ -2373,16 +2377,69 @@

    9. If a suitable transceiver was found - (transceiver is set), + (transceiver is set), and proposedSendEncodings is non-empty, - and - transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[SendEncodings]]}} - is empty, then set - transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[SendEncodings]]}} - to proposedSendEncodings, and set - transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[LastReturnedParameters]]}} - to null. + run the following steps:

      +
        +
      1. +

        + If the length of + transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[SendEncodings]]}} + is `1`, and the lone encoding + [=map/contains=] no + {{RTCRtpCodingParameters/rid}} member, set + transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[SendEncodings]]}} + to proposedSendEncodings. +

        +
      2. +
      3. +

        + Assert: The first encoding of + transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[SendEncodings]]}} + and the first encoding of + proposedSendEncodings both + [=map/contain=] a + {{RTCRtpCodingParameters/rid}} member, and + their values match. +

        +
      4. +
      5. +

        + Set the length of + proposedSendEncodings to the lesser + of its own length and the length of + transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[SendEncodings]]}}. +

        +
      6. +
      7. +

        + Reduce the length of + proposedSendEncodings until all + encodings in it [=map/contain=] only + {{RTCRtpCodingParameters/rid}} member + values that match the + {{RTCRtpCodingParameters/rid}} member + value of the same-position encoding in + transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[SendEncodings]]}}. +

        +
      8. +
      9. +

        + Set the length of + transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[SendEncodings]]}} + to the length of + proposedSendEncodings. +

        +
      10. +
      11. +

        + Set + transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[LastReturnedParameters]]}} + to null. +

        +
      12. +
    10. From df59f7526a5f6a7327bfa712aae93d14a8b14f4e Mon Sep 17 00:00:00 2001 From: Jan-Ivar Bruaroey Date: Thu, 6 Oct 2022 09:24:24 -0400 Subject: [PATCH 6/9] or there are no rid values --- webrtc.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webrtc.html b/webrtc.html index 6fcb0e36c..4ec8b76fe 100644 --- a/webrtc.html +++ b/webrtc.html @@ -1773,7 +1773,8 @@

      A change in the number of rid values is tolerated in remote offers as long as the first rid matches the rid - of the first encoding that was previously negotiated. + of the first encoding that was previously negotiated, or + there are no rid values. Mismatched or out-of-order rids result in layer reduction, and layer expansion is prevented in user agent answers. This specification does not allow remotely initiated RID From b77b88c358715489f141a5e2252e4e96d1e7a812 Mon Sep 17 00:00:00 2001 From: Jan-Ivar Bruaroey Date: Thu, 13 Oct 2022 08:41:29 -0400 Subject: [PATCH 7/9] Allow remote offer rid pruning of encodings through its answer. --- webrtc.html | 70 ++++++++++------------------------------------------- 1 file changed, 13 insertions(+), 57 deletions(-) diff --git a/webrtc.html b/webrtc.html index 4ec8b76fe..7f90d6dfd 100644 --- a/webrtc.html +++ b/webrtc.html @@ -1764,18 +1764,18 @@

      that already has an existing {{RTCRtpTransceiver}} object, transceiver, associated with it, as described in [[!RFC8829]], - if the first encoding in + if none of the encodings in transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[SendEncodings]]}} - [=map/contains=] a {{RTCRtpCodingParameters/rid}} member, and its - value does not match the first rid in the simulcast attribute, - then [= description fails | fail =] the process of - applying description. + [=map/contain=] a {{RTCRtpCodingParameters/rid}} member + whose value matches any of the rids in the simulcast + attribute, then [= description fails | fail =] the + process of applying description.
      - A change in the number of rid values is tolerated in - remote offers as long as the first rid matches the rid - of the first encoding that was previously negotiated, or - there are no rid values. - Mismatched or out-of-order rids result in layer reduction, + A change in rids values is tolerated in remote offers to + receive simulcast as long as at least one rid matches a + rid in the encodings that were previously negotiated, or + the offer is to no longer receive simulcast. + Mismatched or out-of-order rids result in layer removal, and layer expansion is prevented in user agent answers. This specification does not allow remotely initiated RID renegotiation. @@ -2391,51 +2391,7 @@

      [=map/contains=] no {{RTCRtpCodingParameters/rid}} member, set transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[SendEncodings]]}} - to proposedSendEncodings. -

      -

    11. -
    12. -

      - Assert: The first encoding of - transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[SendEncodings]]}} - and the first encoding of - proposedSendEncodings both - [=map/contain=] a - {{RTCRtpCodingParameters/rid}} member, and - their values match. -

      -
    13. -
    14. -

      - Set the length of - proposedSendEncodings to the lesser - of its own length and the length of - transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[SendEncodings]]}}. -

      -
    15. -
    16. -

      - Reduce the length of - proposedSendEncodings until all - encodings in it [=map/contain=] only - {{RTCRtpCodingParameters/rid}} member - values that match the - {{RTCRtpCodingParameters/rid}} member - value of the same-position encoding in - transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[SendEncodings]]}}. -

      -
    17. -
    18. -

      - Set the length of - transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[SendEncodings]]}} - to the length of - proposedSendEncodings. -

      -
    19. -
    20. -

      - Set + to proposedSendEncodings, and set transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[LastReturnedParameters]]}} to null.

      @@ -2511,9 +2467,9 @@

    21. - If description rejects any of + If description is missing any of the offered layers, then remove the - dictionaries that correspond to rejected + dictionaries that correspond to the missing layers from transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[SendEncodings]]}}.

      From d427dc9939503679087af01c4acf6a6582a70c0d Mon Sep 17 00:00:00 2001 From: Jan-Ivar Bruaroey Date: Thu, 13 Oct 2022 08:45:24 -0400 Subject: [PATCH 8/9] ...but do not reorder them --- webrtc.html | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/webrtc.html b/webrtc.html index 7f90d6dfd..426001353 100644 --- a/webrtc.html +++ b/webrtc.html @@ -2468,10 +2468,11 @@

    22. If description is missing any of - the offered layers, then remove the - dictionaries that correspond to the missing - layers from - transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[SendEncodings]]}}. + the previously negototiated layers, then + remove the dictionaries that correspond to + the missing layers from + transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[SendEncodings]]}}, but do not reorder + them.

    23. From 561937b0b35ba4901c10dcdbacc7cf122c2f4939 Mon Sep 17 00:00:00 2001 From: Jan-Ivar Bruaroey Date: Thu, 13 Oct 2022 08:49:03 -0400 Subject: [PATCH 9/9] remove "but do not reorder them" again to avoid confusion over whether non-tail removal is ok --- webrtc.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/webrtc.html b/webrtc.html index 426001353..fc0644551 100644 --- a/webrtc.html +++ b/webrtc.html @@ -2471,8 +2471,7 @@

      the previously negototiated layers, then remove the dictionaries that correspond to the missing layers from - transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[SendEncodings]]}}, but do not reorder - them. + transceiver.{{RTCRtpTransceiver/[[Sender]]}}.{{RTCRtpSender/[[SendEncodings]]}}.