/// Open and start a media transport stream, connecting the local stream `local_id` to the
/// remote stream `remote_id`, configuring it with the MediaCodec capability.
/// Returns the MediaStream which can either be streamed from, or an error.
Open and start a media transport stream, connecting the local stream `local_id` to the
remote stream `remote_id`, configuring it with the MediaCodec capability.
Returns the MediaStream which can either be streamed from, or an error.
Open and start a media transport stream connecting the local stream ` local_id ` to the remote stream ` remote_id ` configuring it with the MediaCodec capability . Returns the MediaStream which can either be streamed from or an error .
pub fn start_stream(
        &self,
        local_id: StreamEndpointId,
        remote_id: StreamEndpointId,
        codec_params: ServiceCapability,
    ) -> impl Future<Output = avdtp::Result<()>> {
        let peer = Arc::downgrade(&self.inner);
        let lock = self.inner.lock();
        let peer_id = self.id.clone();
        let avdtp = lock.peer.clone();
        let profile = self.profile.clone();
        async move {
            fx_vlog!(
                1,
                "Connecting stream {} to remote stream {} with {:?}",
                local_id,
                remote_id,
                codec_params
            );
            let capabilities = vec![ServiceCapability::MediaTransport, codec_params];
            avdtp.set_configuration(&remote_id, &local_id, &capabilities).await?;
            avdtp.open(&remote_id).await?;
            {
                let strong = peer.upgrade().ok_or(avdtp::Error::PeerDisconnected)?;
                strong.lock().set_opening(&local_id, &remote_id, capabilities)?;
            }
            let channel = profile
                .connect(&mut peer_id.into(), PSM_AVDTP, ChannelParameters::new_empty())
                .await
                .expect("FIDL client error: {}");
            let channel = match channel {
                Err(e) => {
                    fx_log_warn!("Couldn't connect media transport {}: {:?}", peer_id, e);
                    return Err(avdtp::Error::PeerDisconnected);
                }
                Ok(channel) => channel,
            };
            if channel.socket.is_none() {
                fx_log_warn!("Couldn't connect media transport {}: no channel", peer_id);
                return Err(avdtp::Error::PeerDisconnected);
            }
            {
                let strong_peer = peer.upgrade().ok_or(avdtp::Error::PeerDisconnected)?;
                let mut strong_peer = strong_peer.lock();
                strong_peer.receive_channel(channel.socket.unwrap())?;
            }
            let to_start = &[remote_id];
            avdtp.start(to_start).await?;
            {
                // Start the media decoding task with this call to start_endpoint()).
                let strong_peer = peer.upgrade().ok_or(avdtp::Error::PeerDisconnected)?;
                let mut strong_peer = strong_peer.lock();
                strong_peer.start_endpoint(&local_id).map_err(|e| avdtp::Error::RequestInvalid(e))
            }
        }
    }
pub fn start_stream ( & self , local_id : StreamEndpointId , remote_id : StreamEndpointId , codec_params : ServiceCapability , ) -> impl Future < Output = avdtp :: Result < ( ) > > { let peer = Arc :: downgrade ( & self . inner ) ; let lock = self . inner . lock ( ) ; let peer_id = self . id . clone ( ) ; let avdtp = lock . peer . clone ( ) ; let profile = self . profile . clone ( ) ; async move { fx_vlog ! ( 1 " " local_id remote_id codec_params ) ; let capabilities = vec ! [ ServiceCapability MediaTransport codec_params ] ; avdtp . set_configuration ( & remote_id , & local_id , & capabilities ) . await ? ; avdtp . open ( & remote_id ) . await ? ; { let strong = peer . upgrade ( ) . ok_or ( avdtp :: Error :: PeerDisconnected ) ? ; strong . lock ( ) . set_opening ( & local_id , & remote_id , capabilities ) ? ; } let channel = profile . connect ( & mut peer_id . into ( ) , PSM_AVDTP , ChannelParameters :: new_empty ( ) ) . await . expect ( " " ) ; let channel = match channel { Err ( e ) => { fx_log_warn ! ( " " peer_id e ) ; return Err ( avdtp :: Error :: PeerDisconnected ) ; } Ok ( channel ) => channel , } ; if channel . socket . is_none ( ) { fx_log_warn ! ( " " peer_id ) ; return Err ( avdtp :: Error :: PeerDisconnected ) ; } { let strong_peer = peer . upgrade ( ) . ok_or ( avdtp :: Error :: PeerDisconnected ) ? ; let mut strong_peer = strong_peer . lock ( ) ; strong_peer . receive_channel ( channel . socket . unwrap ( ) ) ? ; } let to_start = & [ remote_id ] ; avdtp . start ( to_start ) . await ? ; { // Start the media decoding task with this call to start_endpoint()). let strong_peer = peer . upgrade ( ) . ok_or ( avdtp :: Error :: PeerDisconnected ) ? ; let mut strong_peer = strong_peer . lock ( ) ; strong_peer . start_endpoint ( & local_id ) . map_err ( | e | avdtp :: Error :: RequestInvalid ( e ) ) } } }
Open and start a media transport stream, connecting the local stream `local_id` to the
remote stream `remote_id`, configuring it with the MediaCodec capability.
Open and start a media transport stream connecting the local stream ` local_id ` to the remote stream ` remote_id ` configuring it with the MediaCodec capability .
&self
local_id
StreamEndpointId
remote_id
StreamEndpointId
codec_params
ServiceCapability