Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up unused code in packet #574

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/media/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,6 @@ impl Media {

pub(crate) fn do_payload(
&mut self,
now: Instant,
streams: &mut Streams,
params: &[PayloadParams],
) -> Result<(), RtcError> {
Expand All @@ -406,7 +405,7 @@ impl Media {
const MTU: usize = RTP_SIZE - RTP_SIZE % SRTP_BLOCK_SIZE;

payloader
.push_sample(now, to_payload, MTU, is_audio, stream)
.push_sample(to_payload, MTU, is_audio, stream)
.map_err(|e| RtcError::Packet(self.mid, pt, e))?;

Ok(())
Expand Down
31 changes: 13 additions & 18 deletions src/packet/buffer_rx.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
use core::panic;
use std::collections::VecDeque;
use std::fmt;
use std::ops::{Range, RangeInclusive};
use std::time::Instant;

use crate::rtp_::{ExtensionValues, MediaTime, RtpHeader, SenderInfo, SeqNo};

use super::contiguity::{self, Contiguity};
use super::contiguity::Contiguity;
use super::contiguity_vp8::Vp8Contiguity;
use super::contiguity_vp9::Vp9Contiguity;
use super::{CodecDepacketizer, CodecExtra, Depacketizer, PacketError, Vp8CodecExtra};
use super::{CodecDepacketizer, CodecExtra, Depacketizer, PacketError};

#[derive(Clone, PartialEq, Eq)]
/// Holds metadata incoming RTP data.
Expand Down Expand Up @@ -245,7 +244,7 @@ impl DepacketizingBuffer {
&mut self,
start: usize,
stop: usize,
seq: SeqNo,
_seq: SeqNo,
) -> Result<Depacketized, PacketError> {
if let Some(cached) = self.depack_cache.take() {
if cached.0 == (start..stop) {
Expand Down Expand Up @@ -359,10 +358,6 @@ impl DepacketizingBuffer {

seq.is_next(start_entry.meta.seq_no)
}

pub fn max_time(&self) -> Option<MediaTime> {
self.max_time
}
}

impl fmt::Debug for RtpMeta {
Expand Down Expand Up @@ -648,7 +643,7 @@ mod test {
};

let inputs = [
/// PID: 23860
// PID: 23860
(
821395241, // Timestamp
8685, // SeqN
Expand All @@ -659,7 +654,7 @@ mod test {
// +--------------------+
Vec::from([236, 221, 52, 80, 26, 10, 1, 1, 1, 1, 1, 1, 1, 1]), // Data
),
/// PID: 23860
// PID: 23860
(
821395241, // Timestamp
8686, // SeqN
Expand All @@ -670,7 +665,7 @@ mod test {
// +--------------------+
Vec::from([237, 221, 52, 83, 26, 10, 2, 2, 2, 2, 2, 2, 2, 2]), // Data
),
/// PID: 23861
// PID: 23861
(
821398481, // Timestamp
8687, // SeqN
Expand All @@ -681,7 +676,7 @@ mod test {
// +------------------------+
Vec::from([170, 221, 53, 16, 27, 56, 20, 0, 0, 0, 0, 0, 0, 0, 0]), // Data
),
/// PID: 23861
// PID: 23861
(
821398481, // Timestamp
8688, // SeqN
Expand All @@ -692,7 +687,7 @@ mod test {
// +--------------------+
Vec::from([160, 221, 53, 16, 27, 20, 1, 1, 1, 1, 1, 1, 1, 1]), // Data
),
/// PID: 23861
// PID: 23861
(
821398481,
8689,
Expand All @@ -703,7 +698,7 @@ mod test {
// +--------------------+
Vec::from([164, 221, 53, 16, 27, 20, 2, 2, 2, 2, 2, 2, 2, 2]), // Data
),
/// PID: 23861
// PID: 23861
(
821398481, // Timestamp
8690, // SeqN
Expand All @@ -714,7 +709,7 @@ mod test {
// +--------------------+
Vec::from([169, 221, 53, 19, 27, 20, 3, 3, 3, 3, 3, 3, 3, 3]), // Data
),
/// PID: 23861
// PID: 23861
(
821398481, // Timestamp
8691, // SeqN
Expand All @@ -725,7 +720,7 @@ mod test {
// +--------------------+
Vec::from([161, 221, 53, 19, 27, 20, 4, 4, 4, 4, 4, 4, 4, 4]), // Data
),
/// PID: 23861
// PID: 23861
(
821398481, // Timestamp
8692, // SeqN
Expand All @@ -736,7 +731,7 @@ mod test {
// +--------------------+
Vec::from([161, 221, 53, 19, 27, 20, 5, 5, 5, 5, 5, 5, 5, 5]), // Data
),
/// PID: 23861
// PID: 23861
(
821398481, // Timestamp
8693, // SeqN
Expand All @@ -747,7 +742,7 @@ mod test {
// +--------------------+
Vec::from([161, 221, 53, 19, 27, 20, 6, 6, 6, 6, 6, 6, 6, 6]), // Data
),
/// PID: 23861
// PID: 23861
(
821398481, // Timestamp
8694, // SeqN
Expand Down
2 changes: 1 addition & 1 deletion src/packet/bwe/acked_bitrate_estimator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ mod test {
estimator.update(now + Duration::from_millis(550), DataSize::bytes(271));
estimator.update(now + Duration::from_millis(558), DataSize::bytes(813));
estimator.update(now + Duration::from_millis(648), DataSize::bytes(731));
/// Will not be counted, part of next window
// Will not be counted, part of next window
estimator.update(now + Duration::from_millis(651), DataSize::bytes(900));

let estimate = estimator.current_estimate().expect(
Expand Down
1 change: 1 addition & 0 deletions src/packet/bwe/arrival_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ enum Belongs {
}

impl Belongs {
#[cfg(test)]
fn new_group(&self) -> bool {
matches!(self, Self::NewGroup)
}
Expand Down
4 changes: 2 additions & 2 deletions src/packet/bwe/rate_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl RateControl {
self.averaged_observed_bitrate.reset();
}

let since_last_update = (now - last_estimate_update);
let since_last_update = now - last_estimate_update;
assert!(since_last_update >= Duration::ZERO);
let near_convergence = self.is_near_convergence();

Expand Down Expand Up @@ -158,6 +158,7 @@ impl RateControl {
self.averaged_observed_bitrate
.update(observed_bitrate.as_f64());

#[allow(unused)]
if let Some(observed_average) = self.averaged_observed_bitrate.average {
crate::packet::bwe::macros::log_rate_control_observed_bitrate!(
observed_bitrate.as_u64(),
Expand Down Expand Up @@ -392,7 +393,6 @@ mod test {

#[test]
fn test_initial_estimate() {
let now = Instant::now();
let rate_controller = make_control(100_000);

assert_eq!(rate_controller.estimated_bitrate().as_u64(), 100_000);
Expand Down
3 changes: 2 additions & 1 deletion src/packet/bwe/trendline_estimator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ impl TrendlineEstimator {

#[derive(Debug)]
struct Timing {
#[allow(unused)]
at: Instant,
remote_recv_time_ms: f64,
smoothed_delay_ms: f64,
Expand Down Expand Up @@ -307,7 +308,7 @@ mod test {
now,
);

for i in 0..25 {
for _ in 0..25 {
estimator.add_delay_observation(
delay_variation(
10.0,
Expand Down
18 changes: 7 additions & 11 deletions src/packet/contiguity_vp8.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use super::contiguity::FrameContiguityState;
use super::Vp8CodecExtra;
use std::collections::VecDeque;

#[derive(Debug, Default)]
pub struct Vp8Contiguity {
Expand Down Expand Up @@ -52,7 +51,6 @@ impl From<FrameContiguityState> for Vp8Contiguity {

#[cfg(test)]
mod test {
use tracing_subscriber::layer;

use super::Vp8Contiguity;
const L1T3_LAYERS: &[u64] = &[0, 2, 1, 2];
Expand All @@ -63,7 +61,7 @@ mod test {
let mut contiguity = Vp8Contiguity::new();

for i in 0..100 {
let mut next = &crate::packet::Vp8CodecExtra {
let next = &crate::packet::Vp8CodecExtra {
discardable: false,
sync: true,
layer_index: L1T3_LAYERS[i as usize % 4] as u8,
Expand All @@ -89,7 +87,7 @@ mod test {
continue;
}

let mut next = &crate::packet::Vp8CodecExtra {
let next = &crate::packet::Vp8CodecExtra {
discardable: false,
sync: i % 8 == 0,
layer_index,
Expand Down Expand Up @@ -125,7 +123,7 @@ mod test {
continue;
}

let mut next = &crate::packet::Vp8CodecExtra {
let next = &crate::packet::Vp8CodecExtra {
discardable: false,
sync: i % 8 == 0,
layer_index,
Expand All @@ -134,7 +132,7 @@ mod test {
is_keyframe: false,
};

let (emit, contiguous) = contiguity.check(next, true);
let (emit, _) = contiguity.check(next, true);

assert!(emit == (next.layer_index == 0));
}
Expand All @@ -145,7 +143,7 @@ mod test {
let mut contiguity = Vp8Contiguity::new();

for i in 0..100 {
let mut next = &crate::packet::Vp8CodecExtra {
let next = &crate::packet::Vp8CodecExtra {
discardable: false,
sync: true,
layer_index: L1T2_LAYERS[i as usize % 4] as u8,
Expand All @@ -161,8 +159,6 @@ mod test {

#[test]
fn contiguous_l1t1_no_l1_contig_l0() {
const L1T3_LAYERS: &[u64] = &[0, 2, 1, 2];

let mut contiguity = Vp8Contiguity::new();

for i in 0..100 {
Expand All @@ -171,7 +167,7 @@ mod test {
continue;
}

let mut next = &crate::packet::Vp8CodecExtra {
let next = &crate::packet::Vp8CodecExtra {
discardable: false,
sync: i % 8 == 0,
layer_index,
Expand All @@ -180,7 +176,7 @@ mod test {
is_keyframe: false,
};

let (emit, contiguous) = contiguity.check(next, true);
let (emit, _) = contiguity.check(next, true);

// all layer 0 are contiguous therefore can be emitted
assert_eq!(emit, next.layer_index == 0);
Expand Down
17 changes: 7 additions & 10 deletions src/packet/contiguity_vp9.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ mod test {
use crate::packet::Vp9CodecExtra;

use super::Vp9Contiguity;
use tracing_subscriber::layer;

const L1T3_LAYERS: &[u64] = &[0, 2, 1, 2];
const L1T2_LAYERS: &[u64] = &[0, 1, 0, 1];
Expand All @@ -74,7 +73,7 @@ mod test {
let mut contiguity = Vp9Contiguity::new();

for i in 0..100 {
let mut next = get_codec_extra(i, L1T3_LAYERS[i as usize % 4] as u8, (i / 4) as u8);
let next = get_codec_extra(i, L1T3_LAYERS[i as usize % 4] as u8, (i / 4) as u8);

let res = contiguity.check(&next, true);
assert_eq!(res, (true, true), "Failure at picture {} {:?}", i, next);
Expand All @@ -93,7 +92,7 @@ mod test {
continue;
}

let mut next = get_codec_extra(i, layer_index, (i / 4) as u8);
let next = get_codec_extra(i, layer_index, (i / 4) as u8);
let (emit, contiguous) = contiguity.check(&next, true);

// all layer 0 are contiguous therefore no discontinuity
Expand Down Expand Up @@ -121,8 +120,8 @@ mod test {
continue;
}

let mut next = get_codec_extra(i, layer_index, i as u8);
let (emit, contiguous) = contiguity.check(&next, true);
let next = get_codec_extra(i, layer_index, i as u8);
let (emit, _) = contiguity.check(&next, true);

assert!(emit == (next.tid == Some(0)));
}
Expand All @@ -133,7 +132,7 @@ mod test {
let mut contiguity = Vp9Contiguity::new();

for i in 0..100 {
let mut next = get_codec_extra(i, L1T2_LAYERS[i as usize % 4] as u8, (i / 2) as u8);
let next = get_codec_extra(i, L1T2_LAYERS[i as usize % 4] as u8, (i / 2) as u8);

let res = contiguity.check(&next, true);
assert_eq!(res, (true, true), "Failure at picture {} {:?}", i, next);
Expand All @@ -142,8 +141,6 @@ mod test {

#[test]
fn contiguous_l1t1_no_l1_contig_l0() {
const L1T3_LAYERS: &[u64] = &[0, 2, 1, 2];

let mut contiguity = Vp9Contiguity::new();

for i in 0..100 {
Expand All @@ -152,8 +149,8 @@ mod test {
continue;
}

let mut next = get_codec_extra(i, layer_index, (i / 2) as u8);
let (emit, contiguous) = contiguity.check(&next, true);
let next = get_codec_extra(i, layer_index, (i / 2) as u8);
let (emit, _) = contiguity.check(&next, true);

// all layer 0 are contiguous therefore can be emitted
assert_eq!(emit, next.tid == Some(0));
Expand Down
4 changes: 2 additions & 2 deletions src/packet/g7xx.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::{MediaKind, PacketError, Packetizer};
use super::{PacketError, Packetizer};

/// Packetizes G711 RTP packets.
pub type G711Packetizer = G7xxPacketizer;
Expand Down Expand Up @@ -32,7 +32,7 @@ impl Packetizer for G7xxPacketizer {
Ok(payloads)
}

fn is_marker(&mut self, data: &[u8], previous: Option<&[u8]>, last: bool) -> bool {
fn is_marker(&mut self, _data: &[u8], _previous: Option<&[u8]>, _last: bool) -> bool {
false
}
}
Expand Down
Loading
Loading