comment and warning cleanup

This commit is contained in:
Scott Lamb 2022-01-31 13:53:40 -08:00
parent cc78d3b8a6
commit 602718eabb
4 changed files with 19 additions and 10 deletions

View File

@ -9,7 +9,6 @@ use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use std::num::NonZeroU32; use std::num::NonZeroU32;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use std::task::Poll; use std::task::Poll;
use std::time::Instant;
use std::{fmt::Debug, num::NonZeroU16, pin::Pin}; use std::{fmt::Debug, num::NonZeroU16, pin::Pin};
use self::channel_mapping::*; use self::channel_mapping::*;
@ -1741,7 +1740,6 @@ impl Session<Playing> {
local_addr: SocketAddr::new(sockets.local_ip, sockets.local_rtp_port + 1), local_addr: SocketAddr::new(sockets.local_ip, sockets.local_rtp_port + 1),
peer_addr: SocketAddr::new(sockets.remote_ip, sockets.remote_rtcp_port), peer_addr: SocketAddr::new(sockets.remote_ip, sockets.remote_rtcp_port),
received_wall: crate::WallTime::now(), received_wall: crate::WallTime::now(),
received: Instant::now(),
}); });
match r { match r {
Ok(()) => { Ok(()) => {
@ -1780,7 +1778,6 @@ impl Session<Playing> {
local_addr: SocketAddr::new(sockets.local_ip, sockets.local_rtp_port), local_addr: SocketAddr::new(sockets.local_ip, sockets.local_rtp_port),
peer_addr: SocketAddr::new(sockets.remote_ip, sockets.remote_rtp_port), peer_addr: SocketAddr::new(sockets.remote_ip, sockets.remote_rtp_port),
received_wall: crate::WallTime::now(), received_wall: crate::WallTime::now(),
received: Instant::now(),
}); });
match r { match r {
Ok(()) => { Ok(()) => {

View File

@ -50,6 +50,8 @@ struct ChannelConfig {
ncc: u16, ncc: u16,
/// A human-friendly name for the channel configuration. /// A human-friendly name for the channel configuration.
// The name is used in tests and in the Debug output. Suppress dead code warning.
#[cfg_attr(not(test), allow(dead_code))]
name: &'static str, name: &'static str,
} }
@ -425,6 +427,11 @@ pub(crate) struct Depacketizer {
state: DepacketizerState, state: DepacketizerState,
} }
/// [DepacketizerState] holding access units within a single RTP packet.
///
/// This is the state used when there are multiple access units within a packet
/// (thus the name), when there's a single access unit, and even at the
/// beginning of a fragment.
#[derive(Debug)] #[derive(Debug)]
struct Aggregate { struct Aggregate {
ctx: crate::PacketContext, ctx: crate::PacketContext,
@ -450,10 +457,11 @@ struct Aggregate {
/// The buffer, positioned at frame 0's header. /// The buffer, positioned at frame 0's header.
buf: Bytes, buf: Bytes,
/// The index in range `[0, frame_count)` of the next frame to output. /// The index in range `[0, frame_count)` of the next frame to return from `pull`.
frame_i: u16, frame_i: u16,
/// The non-zero total frames within this aggregate. /// The total non-zero total frames within this aggregate (including ones which have already
/// been returned by `pull`).
frame_count: u16, frame_count: u16,
/// The starting byte offset of `frame_i`'s data within `buf`. /// The starting byte offset of `frame_i`'s data within `buf`.
@ -465,6 +473,7 @@ struct Aggregate {
mark: bool, mark: bool,
} }
/// The received prefix of a single access unit which has been spread across multiple packets.
#[derive(Debug)] #[derive(Debug)]
struct Fragment { struct Fragment {
rtp_timestamp: u16, rtp_timestamp: u16,
@ -481,14 +490,22 @@ struct Fragment {
buf: BytesMut, buf: BytesMut,
} }
/// State of the depacketizer between calls to `push` and `pull`.
#[derive(Debug)] #[derive(Debug)]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
enum DepacketizerState { enum DepacketizerState {
/// State when there's no buffered data.
Idle { Idle {
prev_loss: u16, prev_loss: u16,
loss_since_mark: bool, loss_since_mark: bool,
}, },
/// State after a packet has been RTP packet has been received. As described at
/// [`Aggregate`], this may hold the first packet of a fragment, one packet, or multiple
/// complete packets.
Aggregated(Aggregate), Aggregated(Aggregate),
/// State when a prefix of a fragmented packet has been received.
Fragmented(Fragment), Fragmented(Fragment),
Ready(super::AudioFrame), Ready(super::AudioFrame),
} }

View File

@ -269,7 +269,6 @@ pub struct ConnectionContext {
local_addr: std::net::SocketAddr, local_addr: std::net::SocketAddr,
peer_addr: std::net::SocketAddr, peer_addr: std::net::SocketAddr,
established_wall: WallTime, established_wall: WallTime,
established: std::time::Instant,
} }
impl ConnectionContext { impl ConnectionContext {
@ -280,7 +279,6 @@ impl ConnectionContext {
local_addr: addr, local_addr: addr,
peer_addr: addr, peer_addr: addr,
established_wall: WallTime::now(), established_wall: WallTime::now(),
established: std::time::Instant::now(),
} }
} }
} }
@ -364,7 +362,6 @@ enum PacketContextInner {
local_addr: SocketAddr, local_addr: SocketAddr,
peer_addr: SocketAddr, peer_addr: SocketAddr,
received_wall: WallTime, received_wall: WallTime,
received: std::time::Instant,
}, },
Dummy, Dummy,
} }

View File

@ -34,7 +34,6 @@ impl Connection {
pub(crate) fn from_stream(stream: TcpStream) -> Result<Self, std::io::Error> { pub(crate) fn from_stream(stream: TcpStream) -> Result<Self, std::io::Error> {
let established_wall = WallTime::now(); let established_wall = WallTime::now();
let established = Instant::now();
let local_addr = stream.local_addr()?; let local_addr = stream.local_addr()?;
let peer_addr = stream.peer_addr()?; let peer_addr = stream.peer_addr()?;
Ok(Self(Framed::new( Ok(Self(Framed::new(
@ -44,7 +43,6 @@ impl Connection {
local_addr, local_addr,
peer_addr, peer_addr,
established_wall, established_wall,
established,
}, },
read_pos: 0, read_pos: 0,
}, },