Expand description
Match producer media to router capabilities, then to receiver capabilities.
Call derive_consumable_rtp_parameters
once for a publication, then
negotiate_consumer_rtp_parameters
for each receiver using that consumable stream. These functions return media
descriptions without modifying Router or doing transport I/O.
§Payload-type remapping
Here the producer uses payload types 96 and 97, while the router uses 100 and 101. Derivation resolves the repair association even though RTX appears before VP8 in the producer formats. Consumer negotiation preserves the mapped pair.
let producer = MediaStream::new(
vec![
MediaFormat::new(MediaKind::Video, CodecName::Rtx, PayloadType::new(97), VIDEO_CLOCK_RATE_HZ)
.with_parameter(fmtp::RTX_ASSOCIATION, "96"),
MediaFormat::new(MediaKind::Video, CodecName::Vp8, PayloadType::new(96), VIDEO_CLOCK_RATE_HZ)
.with_rtcp_feedback(RtcpFeedback::new(RtcpFeedbackKind::Nack, None)),
],
vec![],
vec![],
);
let router = MediaCapabilities::new(
vec![
MediaCodecCapability::new(MediaKind::Video, CodecName::Vp8, VIDEO_CLOCK_RATE_HZ)
.with_payload_type(PayloadType::new(100))
.with_rtcp_feedback(RtcpFeedback::new(RtcpFeedbackKind::Nack, None)),
MediaCodecCapability::new(MediaKind::Video, CodecName::Rtx, VIDEO_CLOCK_RATE_HZ)
.with_payload_type(PayloadType::new(101))
.with_parameter(fmtp::RTX_ASSOCIATION, "100"),
],
vec![],
);
let consumer = MediaCapabilities::new(
vec![
MediaCodecCapability::new(MediaKind::Video, CodecName::Vp8, VIDEO_CLOCK_RATE_HZ)
.with_rtcp_feedback(RtcpFeedback::new(RtcpFeedbackKind::Nack, None)),
MediaCodecCapability::new(MediaKind::Video, CodecName::Rtx, VIDEO_CLOCK_RATE_HZ)
.with_parameter(fmtp::RTX_ASSOCIATION, "100"),
],
vec![],
);
let consumable = derive_consumable_rtp_parameters(&producer, &router)?;
let negotiated = negotiate_consumer_rtp_parameters(&consumable, &consumer)?;
assert_eq!(
consumable
.formats()
.map(|format| (
format.codec_name(),
format.payload_type(),
format.rtx_associated_payload_type(),
))
.collect::<Vec<_>>(),
vec![(codec_name::VP8, 100, None), (codec_name::RTX, 101, Some(100))],
);
assert_eq!(negotiated, consumable);Enums§
- RtpNegotiation
Error - Failure raised while deriving or negotiating RTP parameters.
Functions§
- derive_
consumable_ rtp_ parameters - Derives the router-consumable media stream from producer parameters.
- negotiate_
consumer_ rtp_ parameters - Negotiates the consumer-facing stream from a consumable stream.