Skip to main content

Module rtp_negotiation

Module rtp_negotiation 

Source
Expand description

RTP capability matching between producers, routers, and consumers.

Separates negotiation into two distinct stages to keep producer codecs decoupled from consumer capabilities:

  1. Ingress Normalization: Producer formats are matched against router capabilities to produce a standardized Consumable stream.
  2. Egress Selection: Consumer capabilities are intersected with the Consumable stream to determine supported formats, RTCP feedback, and congestion control modes.
                  Producer Stream                     Router Capabilities
                         \                                   /
                          v                                 v
               +-------------------------------------------------------+
               | Stage 1: Ingress Normalization                        |
               | - Match primary codecs & assign router payload types  |
               | - Remap RTX `apt` to negotiated primary payload types |
               | - Intersect supported header extensions               |
               +-------------------------------------------------------+
                                           |
                                           v
                               Consumable MediaStream
                                           |
                                           +--------------------+
                                           |                    |
                                           v                    v
                                 Consumer 1 Capabilities    Consumer 2 Capabilities
                                           |                    |
                                           v                    v
                             +-----------------------+ +-----------------------+
                             | Stage 2: Egress Match | | Stage 2: Egress Match |
                             | - Codec intersection  | | - Codec intersection  |
                             | - RTCP feedback match | | - RTCP feedback match |
                             | - BWE policy (TWCC)   | | - BWE policy (REMB)   |
                             +-----------------------+ +-----------------------+
                                           |                    |
                                           v                    v
                               Consumer 1 Egress Stream    Consumer 2 Egress Stream

This module operates purely on the typed domain model (MediaStream, MediaFormat, HeaderExtension, StreamBinding). Rules that depend on raw SDP session structure (m-line ordering, rejected m-sections, BUNDLE extmap consistency) are outside this module and belong at the signaling edge.

EnumsΒ§

BweFeedbackPolicy πŸ”’
RtpNegotiationError
Failure raised while deriving or negotiating RTP parameters.

FunctionsΒ§

apply_bwe_feedback_policy πŸ”’
Negotiation may leave both transport-cc and goog-remb present in the raw RTCP feedback intersection. We filter here so downstream sender logic sees one coherent bandwidth-estimation mode instead of multiple competing ones.
bwe_feedback_policy πŸ”’
Selects a local forwarding policy for mutually exclusive bandwidth-estimation feedback families.
can_consume
Check whether a consumer capability set can negotiate at least one media codec.
codec_match_ignoring_payload_type πŸ”’
Returns whether two formats describe the same codec configuration, ignoring PT
critical_codec_settings_match πŸ”’
Only settings that actually affect wire compatibility are treated as hard negotiation keys here.
derive_consumable_rtp_parameters
Derives the router-consumable media stream from producer parameters.
effective_vp9_profile_id πŸ”’
find_matching_consumer_rtx_capability πŸ”’
Consumer-side RTX matching works against the already-consumable stream. At this point the stream’s apt must refer to a primary PT that survived consumer negotiation, otherwise forwarding RTX would create an orphan repair stream with no valid primary target
find_matching_media_capability πŸ”’
Media capability matching ignores payload type. PT is negotiated output state, not an identity key for codec compatibility.
find_matching_rtx_capability πŸ”’
RTX matching has one extra constraint beyond ordinary codec matching:
format_with_overrides πŸ”’
Rebuild the format from the source while applying negotiated overrides.
formats_contain_payload_type πŸ”’
formats_contain_primary_payload_type πŸ”’
h264_critical_settings_match πŸ”’
packetization-mode is a hard compatibility key. Different packetization modes describe different RTP packetization behaviour, so mismatches are not just preferences
h264_packetization_mode πŸ”’
has_generic_nack πŸ”’
intersect_feedback πŸ”’
RTCP feedback is negotiated by common support, not by union. Advertising feedback that only one side supports would let later code assume a control signal is usable when the peer never negotiated it. https://www.rfc-editor.org/rfc/rfc4585.html#section-4.2
negotiate_consumer_rtp_parameters
Negotiates the consumer-facing stream from a consumable stream.
negotiate_header_extensions πŸ”’
This is a URI-level capability intersection only.
negotiated_payload_type πŸ”’
Payload-type policy:
normalize_nack_rtx πŸ”’
normalized_channels πŸ”’
Channel count is only part of codec identity for audio. Video formats do not use RTP channel count semantics in this model, so we normalize all video channel counts away to avoid spurious mismatches.
parse_rtx_associated_payload πŸ”’
apt is not optional metadata for RTX. It is the linkage that says which primary payload type this repair stream protects. Without it, the RTX format is structurally invalid for negotiation.
vp9_critical_settings_match πŸ”’