Skip to main content

GapClient

Struct GapClient 

Source
pub struct GapClient { /* private fields */ }
Expand description

Stateful GAP client.

Maintains an outbound rtp_sequence counter and an inbound replay window, both keyed by media_source_id.

The client observes the current group epoch on every GapClient::send or GapClient::accept call and automatically clears its replay window when the epoch advances. Callers may also drive a reset explicitly via GapClient::reset.

Old-epoch windows are retained for timeouts::T_GAP_KEY_OVERLAP_MS (default 10 s) so that in-flight audio frames from the previous epoch can still be accepted after an epoch transition (gap_rfc §4).

Implementations§

Source§

impl GapClient

Source

pub fn new() -> Self

Creates an empty client.

Source

pub fn send<S: Sealer>( &mut self, node: &mut GroupNode, seal: &mut S, target: MemberId, media_source_id: u32, rtp_timestamp: u64, opus: Vec<u8>, codec: PayloadCodec, ) -> Result<OutboundFrame, GapError>

Sends an Opus frame. key_phase is taken from node.current_epoch. Uses the O profile (no R / A — voice is not reliable, GAP §7).

The wire rtp_sequence is clamped to the 16-bit RTP range; on overflow it wraps from 0xFFFF back to 0x0000. codec controls how the payload is encoded; use PayloadCodec::Cbor for maximum compatibility or PayloadCodec::FlatBuffers for lowest decode latency.

Source

pub fn accept( &mut self, plaintext: &[u8], current_epoch: u64, codec: PayloadCodec, ) -> Result<GapAccept, GapError>

Accepts a plaintext payload delivered by the GBP layer.

Returns GapAccept::New for fresh frames, GapAccept::Late for replays that the spec allows to drop. Returns GapError::EpochStale only when key_phase refers to an epoch that has already expired its T_overlap window; frames from epochs still within T_overlap are accepted normally (gap_rfc §4). codec must match [DeliveredPayload::codec].

Source

pub fn sync_epoch(&mut self, epoch: u64)

Synchronises the client’s view of the group epoch.

When the epoch advances, the current replay window is moved to the overlap buffer (retained for T_GAP_KEY_OVERLAP_MS) instead of being discarded, so late in-flight frames from the previous epoch are still accepted (gap_rfc §4). Expired entries are pruned on each call. Called automatically by GapClient::send and GapClient::accept.

Source

pub fn reset(&mut self)

Clears the outbound counters, the replay window, and the overlap buffer unconditionally.

Trait Implementations§

Source§

impl Default for GapClient

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Classify for T

Source§

type Classified = T

Source§

fn classify(self) -> T

Source§

impl<T> Declassify for T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V