WebRtcConnection

Struct WebRtcConnection 

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

WebRtcConnection - WebRTC P2P Connect

Implementations§

Source§

impl WebRtcConnection

Source

pub fn new( peer_id: ActrId, peer_connection: Arc<RTCPeerConnection>, event_tx: Sender<ConnectionEvent>, ) -> Self

Create WebRtcConnection from RTCPeerConnection

§Arguments
  • peer_id: Peer identity for event identification
  • peer_connection: Arc wrapped RTCPeerConnection
  • event_tx: Broadcast sender for connection events
Source

pub fn peer_id(&self) -> &ActrId

Get peer ID

Source

pub fn install_state_change_handler(&self)

Install a state-change handler on the underlying RTCPeerConnection.

This keeps connected in sync with the WebRTC connection state and proactively closes the PeerConnection and clears internal caches when entering a terminal state (Disconnected/Failed/Closed).

Source

pub async fn connect(&self) -> NetworkResult<()>

establish Connect(WebRTC Connect already alreadyvia signaling establish , this in only is mark record )

Source

pub fn subscribe_events(&self) -> Receiver<ConnectionEvent>

Subscribe to connection events

Source

pub fn is_connected(&self) -> bool

Checkwhether already Connect

Source

pub async fn close(&self) -> NetworkResult<()>

Close connection and broadcast ConnectionClosed event

Source§

impl WebRtcConnection

Source

pub async fn get_lane( &self, payload_type: PayloadType, ) -> NetworkResult<DataLane>

GetorCreate DataLane( carry Cache)

Source

pub async fn invalidate_lane(&self, payload_type: PayloadType)

Invalidate cached lane/DataChannel for given payload type.

Used when the underlying DataChannel has transitioned to Closed and needs to be recreated on next get_lane call.

Source

pub async fn add_media_track( &self, track_id: String, codec: &str, media_type: &str, ) -> NetworkResult<Arc<TrackLocalStaticRTP>>

Add media track to PeerConnection

§Arguments
  • track_id: Unique track identifier
  • codec: Codec name (e.g., “H264”, “VP8”, “opus”)
  • media_type: “video” or “audio”
§Returns

Reference to the created TrackLocalStaticRTP

§Note

Must be called BEFORE create_offer/create_answer for track to appear in SDP

Source

pub async fn get_media_track( &self, track_id: &str, ) -> Option<Arc<TrackLocalStaticRTP>>

Get existing media track by ID

Source

pub async fn next_sequence_number(&self, track_id: &str) -> Option<u16>

Get next RTP sequence number for track (atomically increments)

§Arguments
  • track_id: Track identifier
§Returns

Next sequence number (wraps at 65535)

Source

pub async fn get_ssrc(&self, track_id: &str) -> Option<u32>

Get SSRC for track

§Arguments
  • track_id: Track identifier
§Returns

SSRC value for this track

Source

pub async fn create_lane( &self, payload_type: PayloadType, ) -> NetworkResult<DataLane>

GetorCreate MediaTrack Lane( carry Cache)

§Arguments
  • _stream_id: Media stream ID

backwardaftercompatible hold Method:create_lane adjust usage get_lane

Source

pub async fn register_received_data_channel( &self, data_channel: Arc<RTCDataChannel>, payload_type: PayloadType, message_tx: UnboundedSender<(Vec<u8>, Bytes, PayloadType)>, ) -> NetworkResult<DataLane>

Register received DataChannel (for passive side)

When receiving an Offer, the passive side should register DataChannels received via on_data_channel callback instead of creating new ones.

Trait Implementations§

Source§

impl Clone for WebRtcConnection

Source§

fn clone(&self) -> WebRtcConnection

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WebRtcConnection

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more