diff --git a/src/session.rs b/src/session.rs index a93203dc..dcbe9c6f 100644 --- a/src/session.rs +++ b/src/session.rs @@ -706,7 +706,13 @@ impl Session { let params = &self.codec_config; let exts = media.remote_extmap(); - let receipt = stream.poll_packet(now, exts, &mut self.twcc, params, buf)?; + + // TWCC might not be enabled for this m-line. Firefox do use TWCC, but not + // for audio. This is indiciated via the SDP. + let twcc_enabled = exts.id_of(Extension::TransportSequenceNumber).is_some(); + let twcc = twcc_enabled.then_some(&mut self.twcc); + + let receipt = stream.poll_packet(now, exts, twcc, params, buf)?; let PacketReceipt { header, @@ -732,7 +738,7 @@ impl Session { let protected = srtp_tx.protect_rtp(buf, &header, *seq_no); - if exts.id_of(Extension::TransportSequenceNumber).is_some() { + if twcc_enabled { self.twcc_tx_register .register_seq(twcc_seq.into(), now, payload_size); } diff --git a/src/streams/send.rs b/src/streams/send.rs index 0995a61d..19be1222 100644 --- a/src/streams/send.rs +++ b/src/streams/send.rs @@ -14,7 +14,6 @@ use crate::packet::QueuePriority; use crate::packet::QueueSnapshot; use crate::packet::QueueState; use crate::rtp_::Bitrate; -use crate::rtp_::Extension; use crate::rtp_::{extend_u16, Descriptions, ReportList, Rtcp}; use crate::rtp_::{ExtensionMap, ReceptionReport, RtpHeader}; use crate::rtp_::{ExtensionValues, Frequency, MediaTime, Mid, NackEntry}; @@ -362,7 +361,7 @@ impl StreamTx { &mut self, now: Instant, exts: &ExtensionMap, - twcc: &mut u64, + twcc: Option<&mut u64>, params: &[PayloadParams], buf: &mut Vec, ) -> Option { @@ -467,7 +466,9 @@ impl StreamTx { // These need to match `Extension::is_supported()` so we are sending what we are // declaring we support. header.ext_vals.abs_send_time = Some(now); - if exts.id_of(Extension::TransportSequenceNumber).is_some() { + + // TWCC might not be enabled for this m-line. + if let Some(twcc) = twcc { header.ext_vals.transport_cc = Some(*twcc as u16); *twcc += 1; }