Skip to main content

PeerDriver

Struct PeerDriver 

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

Drives an RTCPeerConnection over sockets of its own (see the module documentation).

Implementations§

Source§

impl PeerDriver

Source

pub fn new(pc: RTCPeerConnection, config: PeerDriverConfig) -> Self

A driver for pc on tokio (runtime::TokioRuntime::new: it must be used inside a tokio runtime), with no socket yet: it binds when the connection’s first local description begins gathering. Feature runtime-tokio (on by default).

Source

pub fn with_runtime( runtime: Arc<dyn Runtime>, pc: RTCPeerConnection, config: PeerDriverConfig, ) -> Self

A driver for pc on runtime, with no socket yet: it binds when the connection’s first local description begins gathering. Every time it gives the connection is the runtime’s (Runtime::now).

Source

pub fn runtime(&self) -> &Arc<dyn Runtime> ⓘ

The runtime the driver runs on.

Source

pub fn pc(&self) -> &RTCPeerConnection

The peer connection.

Source

pub fn pc_mut(&mut self) -> &mut RTCPeerConnection

The peer connection, for signalling, media and data channels. Call flush (or step) after changing it, so that what it wants to send leaves and the driver sees its events.

Source

pub fn local_addresses(&self) -> Vec<SocketAddr>

The local addresses of the UDP sockets open, the previous ones still waiting for a new pair included.

Source

pub fn unsent_datagrams(&self) -> u64

How many datagrams the connection wrote that were not sent: from a local address with no open socket (one closed already), or refused by the socket (its send buffer full: UDP drops them, as the wire would). Counted so that none is lost unseen.

Source

pub fn mdns_datagrams_sent(&self) -> u64

How many mDNS datagrams the driver sent for the connection (queries, probes, announcements, answers, goodbyes), after the budget let them go.

Source

pub fn mdns_datagrams_received(&self) -> u64

How many datagrams the driver’s mDNS sockets received and handed to the connection (its own looped back by the host included).

Source

pub fn mdns_send_failures(&self) -> u64

How many mDNS sends the system refused (to a group or an asker): a host without a multicast route, a Mac application without the Local Network permission.

Source

pub fn mdns_bind_failures(&self) -> u64

How many times an mDNS socket could not be bound or joined.

Source

pub fn mdns_datagrams_dropped(&self) -> u64

How many received mDNS datagrams were dropped because the driver was not stepped fast enough (the oldest go first; at most 256 wait).

Source

pub fn mdns_available(&self, ipv6: bool) -> bool

Whether the driver can send mDNS for a family now: its socket is bound and its sends have not been refused since (see PeerDriverEvent::MdnsUnavailable).

Source

pub fn poll_driver_event(&mut self) -> Option<PeerDriverEvent>

The next event of the driver itself (mDNS that cannot be sent, and that works again).

Source

pub fn unmarked_sockets(&self) -> u64

How many sockets the platform refused a TOS / Traffic Class on: their datagrams leave without the DSCP the engine asked for (Windows without qWAVE, an IPv6 socket where the platform has no IPV6_TCLASS; see sockets::set_traffic_class).

Source

pub fn sent_by_traffic_class(&self) -> &BTreeMap<u8, u64>

How many datagrams were sent with each TOS / Traffic Class byte set on their socket (a socket the platform refused counts under 0).

Source

pub fn socket_traffic_class(&self, local: SocketAddr) -> Option<Result<u32>>

The TOS / Traffic Class byte the operating system reports for the UDP socket bound to local (getsockopt of IP_TOS / IPV6_TCLASS): what its next datagram carries. None without such a socket.

Source

pub fn poll_event(&mut self) -> Option<RTCPeerConnectionEvent>

The next event of the connection. The driver has already done what is its to do (gathering on OnLocalCandidatesNeeded and when a transport begins gathering, closing the previous sockets on a new selected pair, ending each generation’s gathering with its end-of-candidates); the application signals the candidates of OnIceCandidateEvent to the peer, the end-of-candidates candidate included (W3C webrtc-pc 5.6.4: the peer’s transport is “failed” only once it has it, “disconnected” until then), and handles the rest. The driver tears nothing down on “failed” or “disconnected”: an application that does not relay the end-of-candidates candidate, or whose peer never sends its own, needs a timer of its own to restart or close.

Source

pub fn flush(&mut self) -> Result<()>

Hands what the connection wants to send to the sockets and the stream driver, and reacts to its events, until nothing is left.

§Errors

A socket that cannot be bound for a transport that needs one, or a candidate the connection refuses.

Source

pub async fn shutdown(&mut self, linger: Duration) -> Result<()>

Ends the connection and the driver in order: closes the connection, sends what it writes on closing (the mDNS goodbyes of its published names, RFC 6762 section 10.1: records with TTL 0, so that the link’s caches drop them at once instead of holding them for their 120 s; draft-ietf-mmusic-mdns-ice-candidates section 7.1), waiting up to linger for the mDNS budget to let them go, then closes every socket of the driver, which leaves the mDNS groups. The driver is not to be stepped afterwards.

Dropping a driver that was not shut down does what can be done without waiting (see Drop).

§Errors

As flush.

Source

pub async fn step(&mut self, wait: Duration) -> Result<()>

One round: flushes, then waits up to wait (less when a timer of the connection is due first) for a datagram, a stream input or the timer, hands it over, and flushes again.

§Errors

As flush.

Source

pub fn gather(&mut self) -> Result<()>

Host candidates for every transport section (ice_transport_sections) that has no socket of its own yet, each ended with the end of its generation.

§Errors

As flush.

Trait Implementations§

Source§

impl Drop for PeerDriver

What a driver dropped without PeerDriver::shutdown can do: an async driver on a runtime of the application’s choice cannot wait in drop (no runtime may be blocked there, and none may be running any more), so it closes the connection and sends at once, without waiting, what the connection then writes: the mDNS goodbyes the budget lets go now (the rest is lost, and the neighbours’ caches hold those names until their TTL ends), each socket’s last datagrams if the system takes them. The sockets close as the driver goes, leaving the mDNS groups. Use shutdown to have every goodbye sent.

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl !Freeze for PeerDriver

§

impl !RefUnwindSafe for PeerDriver

§

impl !Sync for PeerDriver

§

impl !Unpin for PeerDriver

§

impl !UnsafeUnpin for PeerDriver

§

impl !UnwindSafe for PeerDriver

§

impl Forget for PeerDriver

§

impl Move for PeerDriver

§

impl Send for PeerDriver
where Arc<dyn Runtime>: Send, RawVecInner: Send, &'static [u8]: Send, Arc<dyn SigningKey>: Send, RawTable<(u8, RTCRtpCodec)>: Send, RawTable<(u16, MediaEngineHeaderExtension)>: Send, Arc<dyn RTCCryptoProvider>: Send, Arc<dyn Fn(SocketAddr) -> bool + Sync + Send>: Send, Arc<dyn Fn(SocketAddr, AddressDirection, AddressPurpose) -> bool + Sync + Send>: Send, Arc<PacingGroup>: Send, Arc<Mutex<Bucket>>: Send, Arc<dyn Fn(isize) -> String + Sync + Send>: Send, Arc<RootCertStore>: Send, Arc<dyn ServerCertVerifier>: Send, BoxRaw<dyn Interceptor<Wout = TransportMessage<AttributedPacket>, Error = Error, Rout = TransportMessage<AttributedPacket>, Eout = (), Time = Instant>>: Send, BytesMut: Send, Bytes: Send, BoxRaw<dyn Packet>: Send, &'static str: Send, BoxRaw<dyn Cipher>: Send, RawTable<(u32, SrtpSsrcState)>: Send, RawTable<(u32, SrtcpSsrcState)>: Send, BoxRaw<dyn Fn() -> Box<dyn ReplayDetector> + Sync + Send>: Send, BoxRaw<RestartUndo>: Send, RawTable<(u64, Candidate)>: Send, RawTable<(IpAddr, IpAddr)>: Send, BoxRaw<Candidate>: Send, Arc<HandshakeConfig>: Send, RawTable<(SocketAddr, DTLSConn)>: Send, Arc<Atomic<bool>>: Send, BoxRaw<Endpoint>: Send, Arc<DtlsSessionGroup>: Send, Arc<()>: Send, RawTable<(u32, ())>: Send, RawTable<(String, TransportId)>: Send, RawTable<((SocketAddr, SocketAddr), Option<TransportId>)>: Send, RawTable<(u64, Option<TransportId>)>: Send, RawTable<(u32, AssociationHandle)>: Send, RawTable<((SocketAddr, u16, u16), AssociationHandle)>: Send, RawTable<(u64, u32)>: Send, BoxRaw<dyn AssociationIdGenerator>: Send, Arc<EndpointConfig>: Send, Arc<ServerConfig>: Send, Arc<CookieSigner>: Send, RawTable<(AssociationHandle, Association)>: Send, RawTable<((AssociationHandle, u16), ())>: Send, RawTable<((AssociationHandle, u16), (ReliabilityType, u32))>: Send, RawTable<(AssociationHandle, ())>: Send, RawTable<(AssociationHandle, TransportContext)>: Send, RawTable<((AssociationHandle, u16), PartialMessage)>: Send, RawTable<(AssociationHandle, usize)>: Send, RawTable<(u32, usize)>: Send, RawTable<((String, String), Instant)>: Send, RawTable<(u32, String)>: Send, RawTable<(u32, (String, String))>: Send, NodeRef<Owned, usize, f64, LeafOrInternal>: Send, BoxRaw<(usize, f64)>: Send, NodeRef<Owned, u32, SetValZST, LeafOrInternal>: Send, BoxRaw<(u32, SetValZST)>: Send, NodeRef<Owned, usize, (f64, f64), LeafOrInternal>: Send, BoxRaw<(usize, (f64, f64))>: Send, NodeRef<Owned, usize, SetValZST, LeafOrInternal>: Send, BoxRaw<(usize, SetValZST)>: Send, RawTable<(usize, FecSessionTransport)>: Send, RawTable<(usize, ())>: Send, RawTable<(u32, SentSdes)>: Send, RawTable<(u32, u16)>: Send, RawTable<(u32, HashMap<u16, Instant>)>: Send, RawTable<(u32, DeliveredWindow)>: Send, NodeRef<Owned, usize, TransportStatsAccumulator, LeafOrInternal>: Send, BoxRaw<(usize, TransportStatsAccumulator)>: Send, RawTable<(String, usize)>: Send, RawTable<(String, IceCandidatePairAccumulator)>: Send, RawTable<(String, IceCandidateAccumulator)>: Send, RawTable<(String, CertificateStatsAccumulator)>: Send, RawTable<(String, CodecStatsAccumulator)>: Send, RawTable<(usize, DataChannelStatsAccumulator)>: Send, RawTable<(u32, InboundRtpStreamAccumulator)>: Send, RawTable<(u32, OutboundRtpStreamAccumulator)>: Send, RawTable<(String, MediaSourceStatsAccumulator)>: Send, RawTable<(String, AudioPlayoutStatsAccumulator)>: Send, RawTable<(u32, u32)>: Send, RawTable<(usize, u64)>: Send, OnceLock<SystemInstant>: Send, RawTable<(usize, RTCDataChannelInternal)>: Send, RawTable<(u16, usize)>: Send, RawTable<(bool, ())>: Send, RawTable<(u32, ClockRateStreams)>: Send, RawTable<(String, ())>: Send, RawTable<(u32, (Instant, u64))>: Send, NodeRef<Owned, StreamId, Connection, LeafOrInternal>: Send, BoxRaw<(StreamId, Connection)>: Send, NodeRef<Owned, ListenerId, Listener, LeafOrInternal>: Send, BoxRaw<(ListenerId, Listener)>: Send, RawTable<(IpAddr, ())>: Send, RawTable<(SocketAddr, ())>: Send, RawTable<(StreamId, ())>: Send, RawTable<(StreamId, TransportId)>: Send, RawTable<((TransportId, SocketAddr, SocketAddr), ())>: Send, RawTable<(TransportId, ())>: Send, Arc<Login>: Send, RawTable<(TransactionId, Transaction)>: Send, RawTable<(SocketAddr, usize)>: Send, RawTable<(SocketAddr, RtoEstimator)>: Send, RawTable<(SocketAddr, RelayState)>: Send, BoxRaw<Error>: Send, Repr: Send, BoxRaw<dyn Error + Sync + Send>: Send, BoxRaw<AllocateState>: Send, Arc<Credential>: Send, RawTable<(IpAddr, Vec<(SocketAddr, Vec<u8>)>)>: Send, Arc<ClientConfig>: Send, RawTable<(TransactionId, ClientTransaction)>: Send, RawTable<((IpAddr, SocketAddr), AddressRank)>: Send, Arc<Channel<DriverInput>>: Send, EventListener: Send, RawTable<(ListenerId, Box<dyn JoinHandle>)>: Send, RawTable<(StreamId, Connection)>: Send, Arc<dyn AsyncUdpSocket>: Send, BoxRaw<dyn JoinHandle>: Send, Arc<Channel<(SocketAddr, SocketAddr, Vec<u8>)>>: Send, Arc<Atomic<u64>>: Send, RawTable<(RTCTransportId, ())>: Send, NodeRef<Owned, u8, u64, LeafOrInternal>: Send, BoxRaw<(u8, u64)>: Send,

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> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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> 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> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
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> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
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 = !

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

fn try_from(value: U) -> Result<T, !>

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<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