pub struct Peer { /* private fields */ }
Expand description
A Peer represents an A2DP peer which may be connected to this device. Only one A2DP peer should exist for each Bluetooth peer.
Implementations§
Source§impl Peer
impl Peer
Sourcepub fn create(
id: PeerId,
peer: Peer,
streams: Streams,
permits: Option<Permits>,
profile: ProfileProxy,
metrics: MetricsLogger,
) -> Self
pub fn create( id: PeerId, peer: Peer, streams: Streams, permits: Option<Permits>, profile: ProfileProxy, metrics: MetricsLogger, ) -> Self
Make a new Peer which is connected to the peer id
using the AVDTP peer
.
The streams
are the local endpoints available to the peer.
profile
will be used to initiate connections for Media Transport.
The permits
, if provided, will acquire a permit before starting streams on this peer.
If metrics
is included, metrics for codec availability will be reported.
This also starts a task on the executor to handle incoming events from the peer.
pub fn set_descriptor( &self, descriptor: ProfileDescriptor, ) -> Option<ProfileDescriptor>
Sourcepub fn receive_channel(&self, channel: Channel) -> Result<()>
pub fn receive_channel(&self, channel: Channel) -> Result<()>
Receive a channel from the peer that was initiated remotely. This function should be called whenever the peer associated with this opens an L2CAP channel. If this completes opening a stream, streams that are suspended will be scheduled to start.
Sourcepub fn avdtp(&self) -> Peer
pub fn avdtp(&self) -> Peer
Return a handle to the AVDTP peer, to use as initiator of commands.
Sourcepub fn remote_endpoints(&self) -> Option<Vec<StreamEndpoint>>
pub fn remote_endpoints(&self) -> Option<Vec<StreamEndpoint>>
Returns the stream endpoints discovered by this peer.
Sourcepub fn collect_capabilities(
&self,
) -> impl Future<Output = Result<Vec<StreamEndpoint>>>
pub fn collect_capabilities( &self, ) -> impl Future<Output = Result<Vec<StreamEndpoint>>>
Perform Discovery and Collect Capabilities to enumerate the endpoints and capabilities of the connected peer. Returns a future which performs the work and resolves to a vector of peer stream endpoints.
Sourcepub fn stream_start(
&self,
remote_id: StreamEndpointId,
capabilities: Vec<ServiceCapability>,
) -> impl Future<Output = Result<()>>
pub fn stream_start( &self, remote_id: StreamEndpointId, capabilities: Vec<ServiceCapability>, ) -> impl Future<Output = Result<()>>
Open and start a media transport stream, connecting a compatible local stream to the remote
stream remote_id
, configuring it with the capabilities
provided.
Returns a future which should be awaited on.
The future returns Ok(()) if successfully started, and an appropriate error otherwise.
Sourcepub fn streaming_active(&self) -> bool
pub fn streaming_active(&self) -> bool
Query whether any streams are currently started or scheduled to start.
Sourcepub fn stream_suspend(
&self,
local_id: StreamEndpointId,
) -> impl Future<Output = Result<()>>
pub fn stream_suspend( &self, local_id: StreamEndpointId, ) -> impl Future<Output = Result<()>>
Suspend a media transport stream local_id
.
It’s possible that the stream is not active - a suspend will be attempted, but an
error from the command will be returned.
Returns the result of the suspend command.
Sourcepub fn closed(&self) -> ClosedPeer ⓘ
pub fn closed(&self) -> ClosedPeer ⓘ
Returns a future that will complete when the peer disconnects.