Skip to content

Commit

Permalink
Documentation fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
algesten committed Feb 26, 2023
1 parent d960217 commit 9c848da
Show file tree
Hide file tree
Showing 18 changed files with 48 additions and 29 deletions.
1 change: 1 addition & 0 deletions packet/src/buffer_rx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ struct Entry {
}

impl RtpMeta {
#[doc(hidden)]
pub fn new(received: Instant, time: MediaTime, seq_no: SeqNo, header: RtpHeader) -> Self {
RtpMeta {
received,
Expand Down
5 changes: 5 additions & 0 deletions rtp/src/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -695,11 +695,16 @@ impl fmt::Debug for Extensions {
}
}

/// How the video is rotated.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum VideoOrientation {
/// Not rotated.
Deg0 = 0,
/// 90 degress clockwise.
Deg90 = 3,
/// Upside down.
Deg180 = 2,
/// 90 degrees counter clockwise.
Deg270 = 1,
}

Expand Down
8 changes: 8 additions & 0 deletions rtp/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use crate::ext::{ExtensionValues, Extensions};
use crate::{Pt, SeqNo, Ssrc};

/// Parsed header from an RTP packet.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct RtpHeader {
pub version: u8,
Expand All @@ -20,6 +21,7 @@ pub struct RtpHeader {
}

impl RtpHeader {
#[doc(hidden)]
pub fn write_to(&self, buf: &mut [u8], exts: &Extensions) -> usize {
buf[0] = 0b10_0_0_0000
| if self.has_padding { 1 << 5 } else { 0 }
Expand Down Expand Up @@ -51,6 +53,7 @@ impl RtpHeader {
16 + ext_len
}

#[doc(hidden)]
pub fn pad_packet(
buf: &mut [u8],
header_len: usize,
Expand All @@ -76,6 +79,7 @@ impl RtpHeader {
pad
}

#[doc(hidden)]
pub fn parse(buf: &[u8], exts: &Extensions) -> Option<RtpHeader> {
let orig_len = buf.len();
if buf.len() < 12 {
Expand Down Expand Up @@ -182,25 +186,29 @@ impl RtpHeader {
}

/// For RTX the original sequence number is inserted before the RTP payload.
#[doc(hidden)]
pub fn read_original_sequence_number(buf: &[u8], seq_no: &mut u16) -> usize {
*seq_no = u16::from_be_bytes([buf[0], buf[1]]);
2
}

/// For RTX the original sequence number is inserted before the RTP payload.
#[doc(hidden)]
pub fn write_original_sequence_number(buf: &mut [u8], seq_no: SeqNo) -> usize {
let seq_u16 = (*seq_no) as u16;
buf[0..2].copy_from_slice(&seq_u16.to_be_bytes());
2
}

#[doc(hidden)]
pub fn is_rtx_null_packet(buf: &[u8]) -> bool {
buf[0..10] == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
}

/// Sequencer number of this RTP header given the previous number.
///
/// The logic detects wrap-arounds of the 16-bit RTP sequence number.
#[doc(hidden)]
pub fn sequence_number(&self, previous: Option<SeqNo>) -> SeqNo {
let e_seq = extend_seq(previous.map(|v| *v), self.sequence_number);
e_seq.into()
Expand Down
4 changes: 2 additions & 2 deletions str0m/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ serde = "1"
#
dtls = { path = "../dtls", package = "str0m-dtls", version = "0.0.1" }
ice = { path = "../ice", package = "str0m-ice", version = "0.0.1" }
net_ = { package = "str0m-net", path = "../net", version = "0.0.1" }
rtp = { path = "../rtp", package = "str0m-rtp", version = "0.0.1" }
net_ = { path = "../net", package = "str0m-net", pversion = "0.0.1" }
rtp_ = { path = "../rtp", package = "str0m-rtp", version = "0.0.1" }
sdp = { path = "../sdp", package = "str0m-sdp", version = "0.0.1" }
packet = { path = "../packet", package = "str0m-packet", version = "0.0.1" }
sctp = { path = "../sctp", package = "str0m-sctp", version = "0.0.1" }
Expand Down
2 changes: 1 addition & 1 deletion str0m/src/change.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::ops::Deref;

use net_::Id;
use rtp::{ChannelId, Direction, Extensions, Mid, Ssrc};
use rtp_::{ChannelId, Direction, Extensions, Mid, Ssrc};
use sctp::{DcepOpen, ReliabilityType};
use sdp::{MediaLine, Msid, Offer};

Expand Down
2 changes: 1 addition & 1 deletion str0m/src/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use std::fmt;

pub use rtp::ChannelId;
pub use rtp_::ChannelId;

use crate::{Rtc, RtcError};

Expand Down
6 changes: 3 additions & 3 deletions str0m/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ use dtls::{Dtls, DtlsEvent, Fingerprint};
use ice::IceAgent;
use ice::IceAgentEvent;
use net_::DatagramRecv;
use rtp::InstantExt;
use rtp_::{InstantExt, Ssrc};
use sctp::{RtcSctp, SctpEvent};
use sdp::{Sdp, Setup};
use stats::{MediaEgressStats, MediaIngressStats, PeerStats, Stats, StatsEvent};
Expand All @@ -88,7 +88,7 @@ pub mod error {
pub use ice::IceError;
pub use net_::NetError;
pub use packet::PacketError;
pub use rtp::RtpError;
pub use rtp_::RtpError;
pub use sctp::{ProtoError, SctpError};
pub use sdp::SdpError;
}
Expand All @@ -99,7 +99,7 @@ use channel::{Channel, ChannelData, ChannelId};
pub mod media;
use media::{CodecConfig, Direction, KeyframeRequest, Media};
use media::{KeyframeRequestKind, MediaChanged, MediaData};
use media::{MLine, MediaAdded, Mid, Pt, Rid, Ssrc};
use media::{MLine, MediaAdded, Mid, Pt, Rid};

mod change;
pub use change::ChangeSet;
Expand Down
2 changes: 1 addition & 1 deletion str0m/src/media/app.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use rtp::Mid;
use rtp_::Mid;
use sdp::MediaLine;

/// m=application m-line. There can only be one of these in the SDP.
Expand Down
2 changes: 1 addition & 1 deletion str0m/src/media/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::collections::HashMap;

use sdp::{CodecSpec, PayloadParams as SdpPayloadParams};

use rtp::Pt;
use rtp_::Pt;
use sdp::{Codec, FormatParams};

use super::MediaKind;
Expand Down
4 changes: 2 additions & 2 deletions str0m/src/media/event.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::time::Instant;

pub use packet::RtpMeta;
pub use rtp::{Direction, ExtensionValues, MediaTime, Mid, Pt, Rid, Ssrc};
use packet::RtpMeta;
use rtp_::{Direction, ExtensionValues, MediaTime, Mid, Pt, Rid};
pub use sdp::{Codec, FormatParams};

use sdp::Simulcast as SdpSimulcast;
Expand Down
8 changes: 4 additions & 4 deletions str0m/src/media/mline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ use std::time::{Duration, Instant};

use net_::{Id, DATAGRAM_MTU};
use packet::{DepacketizingBuffer, Packetized, PacketizedMeta, PacketizingBuffer};
use rtp::{Extensions, Fir, FirEntry, NackEntry, Pli, Rtcp};
use rtp::{RtcpFb, RtpHeader, SdesType};
use rtp::{SeqNo, SRTP_BLOCK_SIZE, SRTP_OVERHEAD};
use rtp_::{Extensions, Fir, FirEntry, NackEntry, Pli, Rtcp};
use rtp_::{RtcpFb, RtpHeader, SdesType};
use rtp_::{SeqNo, SRTP_BLOCK_SIZE, SRTP_OVERHEAD};

pub use packet::RtpMeta;
pub use rtp::{Direction, ExtensionValues, MediaTime, Mid, Pt, Rid, Ssrc};
pub use rtp_::{Direction, ExtensionValues, MediaTime, Mid, Pt, Rid, Ssrc};
pub use sdp::{Codec, FormatParams};

use sdp::{MediaLine, MediaType, Msid, Simulcast as SdpSimulcast};
Expand Down
11 changes: 8 additions & 3 deletions str0m/src/media/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

use std::time::Instant;

use rtp::VideoOrientation;
pub use rtp_::VideoOrientation;

pub use packet::RtpMeta;
pub use rtp::{Direction, ExtensionValues, MediaTime, Mid, Pt, Rid, Ssrc};
pub use rtp_::{Direction, ExtensionValues, MediaTime, Mid, Pt, Rid};
pub use sdp::{Codec, FormatParams};

use crate::{Rtc, RtcError};
Expand All @@ -28,6 +27,12 @@ mod register;
mod mline;
pub(crate) use mline::{MLine, Source};

/// Half internal structures regarding RTP level.
pub mod rtp {
pub use packet::RtpMeta;
pub use rtp_::{ExtensionValues, RtpHeader, SeqNo, Ssrc};
}

/// Audio or video media. An m-line in the SDP.
///
/// Instances of [`Media`] are obtained via [`Rtc::media()`][crate::Rtc::media()]. The instance
Expand Down
2 changes: 1 addition & 1 deletion str0m/src/media/receiver.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::time::Instant;

use rtp::{
use rtp_::{
DlrrItem, ExtendedReport, InstantExt, MediaTime, Mid, Nack, ReceiverReport, ReportBlock,
ReportList, Rid, Rrtr, RtpHeader, SenderInfo, SeqNo, Ssrc,
};
Expand Down
2 changes: 1 addition & 1 deletion str0m/src/media/register.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::time::Instant;

use rtp::{Nack, NackEntry, ReceptionReport, ReportList, SeqNo};
use rtp_::{Nack, NackEntry, ReceptionReport, ReportList, SeqNo};

const MAX_DROPOUT: u64 = 3000;
const MAX_MISORDER: u64 = 100;
Expand Down
6 changes: 3 additions & 3 deletions str0m/src/media/sender.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use std::time::Instant;

use rtp::{
use rtp_::{
extend_seq, Descriptions, InstantExt, MediaTime, Mid, ReceptionReport, ReportList, Rid, Sdes,
SdesType, SenderInfo,
};
use rtp::{SenderReport, SeqNo, Ssrc};
use rtp_::{SenderReport, SeqNo, Ssrc};

use crate::{
stats::{MediaEgressStats, StatsSnapshot},
Expand Down Expand Up @@ -218,7 +218,7 @@ impl SenderSource {
}
}

pub fn update_clocks(&mut self, rtp_time: rtp::MediaTime, wallclock: Instant) {
pub fn update_clocks(&mut self, rtp_time: MediaTime, wallclock: Instant) {
self.rtp_and_wallclock = Some((rtp_time, wallclock));
}
}
Expand Down
8 changes: 4 additions & 4 deletions str0m/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use std::time::{Duration, Instant};
use dtls::KeyingMaterial;
use net_::{DatagramSend, DATAGRAM_MTU, DATAGRAM_MTU_WARN};
use packet::RtpMeta;
use rtp::SRTCP_OVERHEAD;
use rtp::{extend_seq, RtpHeader, SessionId, TwccRecvRegister, TwccSendRegister};
use rtp::{Extensions, MediaTime, Mid, Rtcp, RtcpFb};
use rtp::{SrtpContext, SrtpKey, Ssrc};
use rtp_::SRTCP_OVERHEAD;
use rtp_::{extend_seq, RtpHeader, SessionId, TwccRecvRegister, TwccSendRegister};
use rtp_::{Extensions, MediaTime, Mid, Rtcp, RtcpFb};
use rtp_::{SrtpContext, SrtpKey, Ssrc};

use crate::media::{App, CodecConfig, MediaAdded, MediaChanged, Source};
use crate::session_sdp::AsMediaLine;
Expand Down
2 changes: 1 addition & 1 deletion str0m/src/session_sdp.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use dtls::Fingerprint;
use ice::{Candidate, IceCreds};
use rtp::{Extension, Mid};
use rtp_::{Extension, Mid};
use sdp::{Answer, MediaAttribute, MediaLine, MediaType, SimulcastGroups, SimulcastOption};
use sdp::{Offer, Proto, Sdp, SessionAttribute, Setup};

Expand Down
2 changes: 1 addition & 1 deletion str0m/src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{
};

use crate::Mid;
use rtp::Rid;
use rtp_::Rid;

pub(crate) struct Stats {
last_now: Instant,
Expand Down

0 comments on commit 9c848da

Please sign in to comment.