pub trait Control: Send {
// Required methods
fn connect(&mut self, id: PeerId, supported_codecs: &[CodecId]);
fn disconnect(&mut self, id: PeerId);
fn start(
&mut self,
id: PeerId,
connection: Connection,
codec: CodecId,
) -> Result<(), Error>;
fn stop(&mut self, id: PeerId) -> Result<(), Error>;
fn take_events(&self) -> BoxStream<'static, ControlEvent>;
fn failed_request(&self, request: ControlEvent, error: Error);
}
Required Methods§
Sourcefn connect(&mut self, id: PeerId, supported_codecs: &[CodecId])
fn connect(&mut self, id: PeerId, supported_codecs: &[CodecId])
Send to indicate when connected to a peer. supported_codecs
indicates the set of codecs which are
communicated from the peer. Depending on the audio control implementation,
this may add a (stopped) media device. Audio control implementations can request audio be started
for peers that are connected.
Sourcefn disconnect(&mut self, id: PeerId)
fn disconnect(&mut self, id: PeerId)
Send to indicate that a peer has been disconnected. This shall tear down any audio path
set up for the peer and send a ControlEvent::Stopped
for each. This shall be idempotent
(calling disconnect on a disconnected PeerId does nothing)
Sourcefn start(
&mut self,
id: PeerId,
connection: Connection,
codec: CodecId,
) -> Result<(), Error>
fn start( &mut self, id: PeerId, connection: Connection, codec: CodecId, ) -> Result<(), Error>
Request to start sending audio to the peer. If the request succeeds Ok(())
will be
returned, but audio may not be started until a ControlEvent::Started
event is
produced in the events.
Sourcefn stop(&mut self, id: PeerId) -> Result<(), Error>
fn stop(&mut self, id: PeerId) -> Result<(), Error>
Request to stop the audio to a peer.
If the Audio is not started, an Err(Error::NotStarted) will be returned.
If the requests succeeds Ok(())
will be returned but audio may not be stopped until a
ControlEvent::Stopped
is produced in the events.
Sourcefn take_events(&self) -> BoxStream<'static, ControlEvent>
fn take_events(&self) -> BoxStream<'static, ControlEvent>
Get a stream of the events produced by this audio control. May panic if the event stream has already been taken.
Sourcefn failed_request(&self, request: ControlEvent, error: Error)
fn failed_request(&self, request: ControlEvent, error: Error)
Respond with failure to a request from the event stream.
request
should be the request that failed. If a request was not made by this audio
control the failure shall be ignored.