pub(crate) async fn update_header_extension(
        &self,
        id: isize,
        extension: &str,
        typ: RTPCodecType,
    ) -> Result<()> {
        let mut negotiated_header_extensions = self.negotiated_header_extensions.lock().await;
        let mut propsed_header_extensions = self.proposed_header_extensions.lock().await;

        for local_extension in &self.header_extensions {
            if !(local_extension.uri == extension) {
                continue;
            }

            let negotiated_ext = negotiated_header_extensions
                .iter_mut()
                .find(|(_, ext)| ext.uri == extension);

            if let Some(n_ext) = negotiated_ext {
                if *n_ext.0 == id {
                    n_ext.1.is_video |= typ == RTPCodecType::Video;
                    n_ext.1.is_audio |= typ == RTPCodecType::Audio;
                } else {
                    let nid = n_ext.0;
                    log::warn!("Invalid ext id mapping in update_header_extension. {} was negotiated as {}, but was {} in call", extension, nid, id);
                }
            } else {
                // We either only have a proposal or we have neither proposal nor a negotiated id
                // Accept whatevers the peer suggests

                if let Some(prev_ext) = negotiated_header_extensions.get(&id) {
                    let prev_uri = &prev_ext.uri;
                    log::warn!("Assigning {} to {} would override previous assignment to {}, no action taken", id, extension, prev_uri);
                } else {
                    let h = MediaEngineHeaderExtension {
                        uri: extension.to_owned(),
                        is_audio: local_extension.is_audio && typ == RTPCodecType::Audio,
                        is_video: local_extension.is_video && typ == RTPCodecType::Video,
                        allowed_directions: local_extension.allowed_directions.clone(),
                    };
                    negotiated_header_extensions.insert(id, h);
                }
            }

            // Clear any proposals we had for this id
            propsed_header_extensions.remove(&id);
        }
        Ok(())
    }
/// Look up a header extension and enable if it exists
Look up a header extension and enable if it exists
Look up a header extension and enable if it exists
pub(crate) async fn update_header_extension(
        &self,
        id: isize,
        extension: &str,
        typ: RTPCodecType,
    ) -> Result<()> {
        let mut negotiated_header_extensions = self.negotiated_header_extensions.lock().await;
        let mut propsed_header_extensions = self.proposed_header_extensions.lock().await;
        for local_extension in &self.header_extensions {
            if !(local_extension.uri == extension) {
                continue;
            }
            let negotiated_ext = negotiated_header_extensions
                .iter_mut()
                .find(|(_, ext)| ext.uri == extension);
            if let Some(n_ext) = negotiated_ext {
                if *n_ext.0 == id {
                    n_ext.1.is_video |= typ == RTPCodecType::Video;
                    n_ext.1.is_audio |= typ == RTPCodecType::Audio;
                } else {
                    let nid = n_ext.0;
                    log::warn!("Invalid ext id mapping in update_header_extension. {} was negotiated as {}, but was {} in call", extension, nid, id);
                }
            } else {
                // We either only have a proposal or we have neither proposal nor a negotiated id
                // Accept whatevers the peer suggests
                if let Some(prev_ext) = negotiated_header_extensions.get(&id) {
                    let prev_uri = &prev_ext.uri;
                    log::warn!("Assigning {} to {} would override previous assignment to {}, no action taken", id, extension, prev_uri);
                } else {
                    let h = MediaEngineHeaderExtension {
                        uri: extension.to_owned(),
                        is_audio: local_extension.is_audio && typ == RTPCodecType::Audio,
                        is_video: local_extension.is_video && typ == RTPCodecType::Video,
                        allowed_directions: local_extension.allowed_directions.clone(),
                    };
                    negotiated_header_extensions.insert(id, h);
                }
            }
            // Clear any proposals we had for this id
            propsed_header_extensions.remove(&id);
        }
        Ok(())
    }
pub ( crate ) async fn update_header_extension ( & self , id : isize , extension : & str , typ : RTPCodecType , ) -> Result < ( ) > { let mut negotiated_header_extensions = self . negotiated_header_extensions . lock ( ) . await ; let mut propsed_header_extensions = self . proposed_header_extensions . lock ( ) . await ; for local_extension in & self . header_extensions { if ! ( local_extension . uri == extension ) { continue ; } let negotiated_ext = negotiated_header_extensions . iter_mut ( ) . find ( | ( _ , ext ) | ext . uri == extension ) ; if let Some ( n_ext ) = negotiated_ext { if * n_ext . 0 == id { n_ext . 1 . is_video |= typ == RTPCodecType :: Video ; n_ext . 1 . is_audio |= typ == RTPCodecType :: Audio ; } else { let nid = n_ext . 0 ; log :: warn ! ( " " extension nid id ) ; } } else { // We either only have a proposal or we have neither proposal nor a negotiated id // Accept whatevers the peer suggests if let Some ( prev_ext ) = negotiated_header_extensions . get ( & id ) { let prev_uri = & prev_ext . uri ; log :: warn ! ( " " id extension prev_uri ) ; } else { let h = MediaEngineHeaderExtension { uri : extension . to_owned ( ) , is_audio : local_extension . is_audio && typ == RTPCodecType :: Audio , is_video : local_extension . is_video && typ == RTPCodecType :: Video , allowed_directions : local_extension . allowed_directions . clone ( ) , } ; negotiated_header_extensions . insert ( id , h ) ; } } // Clear any proposals we had for this id propsed_header_extensions . remove ( & id ) ; } Ok ( ( ) ) }
Look up a header extension and enable if it exists
Look up a header extension and enable if it exists
&self
id
isize
extension
&str
typ
RTPCodecType
&self
id
isize
extension
&str
typ
RTPCodecType