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
impl GapClient
Sourcepub 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>
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.
Sourcepub fn accept(
&mut self,
plaintext: &[u8],
current_epoch: u64,
codec: PayloadCodec,
) -> Result<GapAccept, GapError>
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].
Sourcepub fn sync_epoch(&mut self, epoch: u64)
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.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GapClient
impl RefUnwindSafe for GapClient
impl Send for GapClient
impl Sync for GapClient
impl Unpin for GapClient
impl UnsafeUnpin for GapClient
impl UnwindSafe for GapClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Declassify for T
impl<T> Declassify for T
type Declassified = T
fn declassify(self) -> T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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