pub struct PeerDriver { /* private fields */ }Expand description
Drives an RTCPeerConnection over sockets of its own (see the module documentation).
Implementations§
Source§impl PeerDriver
impl PeerDriver
Sourcepub fn new(pc: RTCPeerConnection, config: PeerDriverConfig) -> Self
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).
Sourcepub fn with_runtime(
runtime: Arc<dyn Runtime>,
pc: RTCPeerConnection,
config: PeerDriverConfig,
) -> Self
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).
Sourcepub fn target_latency(&self) -> RTCConfigurationTargetLatency
pub fn target_latency(&self) -> RTCConfigurationTargetLatency
The connection’s targetLatency (webrtc-extensions section 16), which the driver, as
what sets up the network link, reads: “lowest” asks it to optimise latency, with “a
technique like network slicing” (ETSI TS 128 530) where one is available. None is: the
socket interfaces the driver uses on Linux, macOS, Windows and the BSDs expose no
network slice or latency class to a process (on Android a slice is requested through
ConnectivityManager, outside any socket). The driver’s sockets are therefore the same
under both values; DSCP marking (RFC 8837) is the engine’s per flow either way.
Sourcepub fn pc(&self) -> &RTCPeerConnection
pub fn pc(&self) -> &RTCPeerConnection
The peer connection.
Sourcepub fn pc_mut(&mut self) -> &mut RTCPeerConnection
pub fn pc_mut(&mut self) -> &mut RTCPeerConnection
Sourcepub fn local_addresses(&self) -> Vec<SocketAddr>
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.
Sourcepub fn unsent_datagrams(&self) -> u64
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.
Sourcepub fn mdns_datagrams_sent(&self) -> u64
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.
Sourcepub fn mdns_datagrams_received(&self) -> u64
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).
Sourcepub fn mdns_send_failures(&self) -> u64
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.
Sourcepub fn mdns_bind_failures(&self) -> u64
pub fn mdns_bind_failures(&self) -> u64
How many times an mDNS socket could not be bound or joined.
Sourcepub fn mdns_datagrams_dropped(&self) -> u64
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).
Sourcepub fn mdns_available(&self, ipv6: bool) -> bool
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).
Sourcepub fn poll_driver_event(&mut self) -> Option<PeerDriverEvent>
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).
Sourcepub fn unmarked_sockets(&self) -> u64
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).
Sourcepub fn sent_by_traffic_class(&self) -> &BTreeMap<u8, u64>
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).
Sourcepub fn socket_traffic_class(&self, local: SocketAddr) -> Option<Result<u32>>
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.
Sourcepub fn poll_event(&mut self) -> Option<RTCPeerConnectionEvent>
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.
Sourcepub fn flush(&mut self) -> Result<()>
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.
Sourcepub async fn shutdown(&mut self, linger: Duration) -> Result<()>
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; and the deletion of
each of the engine’s TURN allocations over UDP, a Refresh of LIFETIME 0, RFC 8656
section 8), waiting up to linger for the mDNS budget to let the goodbyes go and for
the TURN releases to be answered (the closed connection retransmits them, RFC 8489
section 6.2.1, and reads their answers from the driver’s sockets:
OnTurnAllocationReleased for each, in poll_event), then closes
every socket of the driver, which leaves the mDNS groups. A server whose allocation is
deleted at once accepts a new one from the same address and port at once (RFC 8656
section 7.2: a live allocation on a 5-tuple refuses another with 437). An application
that ends on a signal (SIGTERM, SIGINT) calls this from its handler. 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.
Sourcepub fn set_user_consent(&mut self, consent: bool)
pub fn set_user_consent(&mut self, consent: bool)
Gives the user’s consent to Mode 1 (every interface, RFC 8828 section 5.2), or takes it
back (AddressSelection::user_consent): from the next gathering on (an ICE restart’s;
the interface monitor does not restart ICE for it). Without an address selection it
changes nothing.
Sourcepub fn network_changed(&mut self)
pub fn network_changed(&mut self)
The application learnt that the network may have changed (an operating system
notification: wake, link up, address change): the driver reads the interfaces now, as
the monitor does (PeerDriverConfig::interface_check_interval), and tells the
connection (RTCPeerConnection::network_changed) even when the addresses are the same.
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.
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.
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 PeerDriverwhere
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 + Send + Sync>: Send,
Arc<dyn Fn(SocketAddr, AddressDirection, AddressPurpose) -> bool + Send + Sync>: Send,
Arc<PacingGroup>: Send,
Arc<Mutex<Bucket>>: Send,
Arc<dyn Fn(isize) -> String + Send + Sync>: Send,
Arc<RootCertStore>: Send,
Arc<dyn ServerCertVerifier>: Send,
BoxRaw<dyn Interceptor<Time = Instant, Wout = TransportMessage<AttributedPacket>, Rout = TransportMessage<AttributedPacket>, Eout = (), Error = Error>>: 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> + Send + Sync>: 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 + Send + Sync>: 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 Fn(&str) -> bool + Send + Sync>: Send,
Arc<dyn Fn(IpAddr) -> bool + Send + Sync>: Send,
Arc<dyn AsyncUdpSocket>: Send,
BoxRaw<dyn JoinHandle>: Send,
Arc<Channel<Received>>: Send,
Arc<Atomic<u64>>: Send,
RawTable<(RTCTransportId, ())>: Send,
NodeRef<Owned, u8, u64, LeafOrInternal>: Send,
BoxRaw<(u8, u64)>: Send,
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.