async fn build(inspect: &mut ManagedNode) -> Result<Streams, Error> {
        let mut s = Streams::new();
        // TODO(BT-533): detect codecs, add streams for each codec
        // SBC is required
        if let Err(e) = player::Player::new(
            DEFAULT_SESSION_ID,
            AUDIO_ENCODING_SBC.to_string(),
            DEFAULT_SAMPLE_RATE,
        )
        .await
        {
            fx_log_warn!("Can't play required SBC audio: {}", e);
            return Err(e);
        }
        let sbc_media_codec_info = SbcCodecInfo::new(
            SbcSamplingFrequency::MANDATORY_SNK,
            SbcChannelMode::MANDATORY_SNK,
            SbcBlockCount::MANDATORY_SNK,
            SbcSubBands::MANDATORY_SNK,
            SbcAllocation::MANDATORY_SNK,
            SbcCodecInfo::BITPOOL_MIN,
            SbcCodecInfo::BITPOOL_MAX,
        )?;
        fx_log_info!("Supported codec parameters: {:?}.", sbc_media_codec_info);

        let sbc_stream = avdtp::StreamEndpoint::new(
            SBC_SEID,
            avdtp::MediaType::Audio,
            avdtp::EndpointType::Sink,
            vec![
                avdtp::ServiceCapability::MediaTransport,
                avdtp::ServiceCapability::MediaCodec {
                    media_type: avdtp::MediaType::Audio,
                    codec_type: avdtp::MediaCodecType::AUDIO_SBC,
                    codec_extra: sbc_media_codec_info.to_bytes(),
                },
            ],
        )?;
        s.insert(sbc_stream, AUDIO_ENCODING_SBC.to_string());

        let aac_media_codec_info = AACMediaCodecInfo::new(
            AACObjectType::MANDATORY_SNK,
            AACSamplingFrequency::MANDATORY_SNK,
            AACChannels::MANDATORY_SNK,
            AACVariableBitRate::MANDATORY_SNK,
            0, // 0 = Unknown constant bitrate support (A2DP Sec. 4.5.2.4)
        )?;
        fx_log_info!("Supported codec parameters: {:?}.", aac_media_codec_info);

        let aac_stream = avdtp::StreamEndpoint::new(
            AAC_SEID,
            avdtp::MediaType::Audio,
            avdtp::EndpointType::Sink,
            vec![
                avdtp::ServiceCapability::MediaTransport,
                avdtp::ServiceCapability::MediaCodec {
                    media_type: avdtp::MediaType::Audio,
                    codec_type: avdtp::MediaCodecType::AUDIO_AAC,
                    codec_extra: aac_media_codec_info.to_bytes(),
                },
            ],
        )?;
        s.insert(aac_stream, AUDIO_ENCODING_AACLATM.to_string());

        s.construct_inspect_data(inspect);
        Ok(s)
    }
/// Builds a set of endpoints from the available codecs.
Builds a set of endpoints from the available codecs.
Builds a set of endpoints from the available codecs .
async fn build(inspect: &mut ManagedNode) -> Result<Streams, Error> {
        let mut s = Streams::new();
        // TODO(BT-533): detect codecs, add streams for each codec
        // SBC is required
        if let Err(e) = player::Player::new(
            DEFAULT_SESSION_ID,
            AUDIO_ENCODING_SBC.to_string(),
            DEFAULT_SAMPLE_RATE,
        )
        .await
        {
            fx_log_warn!("Can't play required SBC audio: {}", e);
            return Err(e);
        }
        let sbc_media_codec_info = SbcCodecInfo::new(
            SbcSamplingFrequency::MANDATORY_SNK,
            SbcChannelMode::MANDATORY_SNK,
            SbcBlockCount::MANDATORY_SNK,
            SbcSubBands::MANDATORY_SNK,
            SbcAllocation::MANDATORY_SNK,
            SbcCodecInfo::BITPOOL_MIN,
            SbcCodecInfo::BITPOOL_MAX,
        )?;
        fx_log_info!("Supported codec parameters: {:?}.", sbc_media_codec_info);
        let sbc_stream = avdtp::StreamEndpoint::new(
            SBC_SEID,
            avdtp::MediaType::Audio,
            avdtp::EndpointType::Sink,
            vec![
                avdtp::ServiceCapability::MediaTransport,
                avdtp::ServiceCapability::MediaCodec {
                    media_type: avdtp::MediaType::Audio,
                    codec_type: avdtp::MediaCodecType::AUDIO_SBC,
                    codec_extra: sbc_media_codec_info.to_bytes(),
                },
            ],
        )?;
        s.insert(sbc_stream, AUDIO_ENCODING_SBC.to_string());
        let aac_media_codec_info = AACMediaCodecInfo::new(
            AACObjectType::MANDATORY_SNK,
            AACSamplingFrequency::MANDATORY_SNK,
            AACChannels::MANDATORY_SNK,
            AACVariableBitRate::MANDATORY_SNK,
            0, // 0 = Unknown constant bitrate support (A2DP Sec. 4.5.2.4)
        )?;
        fx_log_info!("Supported codec parameters: {:?}.", aac_media_codec_info);
        let aac_stream = avdtp::StreamEndpoint::new(
            AAC_SEID,
            avdtp::MediaType::Audio,
            avdtp::EndpointType::Sink,
            vec![
                avdtp::ServiceCapability::MediaTransport,
                avdtp::ServiceCapability::MediaCodec {
                    media_type: avdtp::MediaType::Audio,
                    codec_type: avdtp::MediaCodecType::AUDIO_AAC,
                    codec_extra: aac_media_codec_info.to_bytes(),
                },
            ],
        )?;
        s.insert(aac_stream, AUDIO_ENCODING_AACLATM.to_string());
        s.construct_inspect_data(inspect);
        Ok(s)
    }
async fn build ( inspect : & mut ManagedNode ) -> Result < Streams , Error > { let mut s = Streams :: new ( ) ; // TODO(BT-533): detect codecs, add streams for each codec // SBC is required if let Err ( e ) = player :: Player :: new ( DEFAULT_SESSION_ID , AUDIO_ENCODING_SBC . to_string ( ) , DEFAULT_SAMPLE_RATE , ) . await { fx_log_warn ! ( " " e ) ; return Err ( e ) ; } let sbc_media_codec_info = SbcCodecInfo :: new ( SbcSamplingFrequency :: MANDATORY_SNK , SbcChannelMode :: MANDATORY_SNK , SbcBlockCount :: MANDATORY_SNK , SbcSubBands :: MANDATORY_SNK , SbcAllocation :: MANDATORY_SNK , SbcCodecInfo :: BITPOOL_MIN , SbcCodecInfo :: BITPOOL_MAX , ) ? ; fx_log_info ! ( " " sbc_media_codec_info ) ; let sbc_stream = avdtp :: StreamEndpoint :: new ( SBC_SEID , avdtp :: MediaType :: Audio , avdtp :: EndpointType :: Sink , vec ! [ avdtp ServiceCapability MediaTransport avdtp ServiceCapability MediaCodec { media_type avdtp MediaType Audio codec_type avdtp MediaCodecType AUDIO_SBC codec_extra sbc_media_codec_info to_bytes ( ) } ] , ) ? ; s . insert ( sbc_stream , AUDIO_ENCODING_SBC . to_string ( ) ) ; let aac_media_codec_info = AACMediaCodecInfo :: new ( AACObjectType :: MANDATORY_SNK , AACSamplingFrequency :: MANDATORY_SNK , AACChannels :: MANDATORY_SNK , AACVariableBitRate :: MANDATORY_SNK , 0 , // 0 = Unknown constant bitrate support (A2DP Sec. 4.5.2.4) ) ? ; fx_log_info ! ( " " aac_media_codec_info ) ; let aac_stream = avdtp :: StreamEndpoint :: new ( AAC_SEID , avdtp :: MediaType :: Audio , avdtp :: EndpointType :: Sink , vec ! [ avdtp ServiceCapability MediaTransport avdtp ServiceCapability MediaCodec { media_type avdtp MediaType Audio codec_type avdtp MediaCodecType AUDIO_AAC codec_extra aac_media_codec_info to_bytes ( ) } ] , ) ? ; s . insert ( aac_stream , AUDIO_ENCODING_AACLATM . to_string ( ) ) ; s . construct_inspect_data ( inspect ) ; Ok ( s ) }
Builds a set of endpoints from the available codecs.
Builds a set of endpoints from the available codecs .
inspect
&mut ManagedNode