Skip to content

Commit

Permalink
Tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
algesten committed Oct 21, 2024
1 parent e6317d2 commit c2abb25
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
10 changes: 8 additions & 2 deletions src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
}
Expand Down
7 changes: 4 additions & 3 deletions src/streams/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -362,7 +361,7 @@ impl StreamTx {
&mut self,
now: Instant,
exts: &ExtensionMap,
twcc: &mut u64,
twcc: Option<&mut u64>,
params: &[PayloadParams],
buf: &mut Vec<u8>,
) -> Option<PacketReceipt> {
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit c2abb25

Please sign in to comment.