pub fn register_header_extension(
        &mut self,
        extension: RTCRtpHeaderExtensionCapability,
        typ: RTPCodecType,
        mut allowed_directions: Vec<RTCRtpTransceiverDirection>,
    ) -> Result<()> {
        if allowed_directions.is_empty() {
            allowed_directions = vec![
                RTCRtpTransceiverDirection::Recvonly,
                RTCRtpTransceiverDirection::Sendonly,
            ];
        }

        for direction in &allowed_directions {
            if *direction != RTCRtpTransceiverDirection::Recvonly
                && *direction != RTCRtpTransceiverDirection::Sendonly
            {
                return Err(Error::ErrRegisterHeaderExtensionInvalidDirection);
            }
        }

        let ext = {
            match self
                .header_extensions
                .iter_mut()
                .find(|ext| ext.uri == extension.uri)
            {
                Some(ext) => ext,
                None => {
                    // We have registered too many extensions
                    if self.header_extensions.len() > VALID_EXT_IDS.end as usize {
                        return Err(Error::ErrRegisterHeaderExtensionNoFreeID);
                    }
                    self.header_extensions
                        .push(MediaEngineHeaderExtension::default());

                    // Unwrap is fine because we just pushed
                    self.header_extensions.last_mut().unwrap()
                }
            }
        };

        if typ == RTPCodecType::Audio {
            ext.is_audio = true;
        } else if typ == RTPCodecType::Video {
            ext.is_video = true;
        }

        ext.uri = extension.uri;
        // TODO: This just overrides the previous allowed directions, which feels wrong
        ext.allowed_directions = allowed_directions;

        Ok(())
    }
/// register_header_extension adds a header extension to the MediaEngine
/// To determine the negotiated value use [`get_header_extension_id`] after signaling is complete
register_header_extension adds a header extension to the MediaEngine
To determine the negotiated value use [`get_header_extension_id`] after signaling is complete
register_header_extension adds a header extension to the MediaEngine To determine the negotiated value use [ ` get_header_extension_id ` ] after signaling is complete
pub fn register_header_extension(
        &mut self,
        extension: RTCRtpHeaderExtensionCapability,
        typ: RTPCodecType,
        mut allowed_directions: Vec<RTCRtpTransceiverDirection>,
    ) -> Result<()> {
        if allowed_directions.is_empty() {
            allowed_directions = vec![
                RTCRtpTransceiverDirection::Recvonly,
                RTCRtpTransceiverDirection::Sendonly,
            ];
        }
        for direction in &allowed_directions {
            if *direction != RTCRtpTransceiverDirection::Recvonly
                && *direction != RTCRtpTransceiverDirection::Sendonly
            {
                return Err(Error::ErrRegisterHeaderExtensionInvalidDirection);
            }
        }
        let ext = {
            match self
                .header_extensions
                .iter_mut()
                .find(|ext| ext.uri == extension.uri)
            {
                Some(ext) => ext,
                None => {
                    // We have registered too many extensions
                    if self.header_extensions.len() > VALID_EXT_IDS.end as usize {
                        return Err(Error::ErrRegisterHeaderExtensionNoFreeID);
                    }
                    self.header_extensions
                        .push(MediaEngineHeaderExtension::default());
                    // Unwrap is fine because we just pushed
                    self.header_extensions.last_mut().unwrap()
                }
            }
        };
        if typ == RTPCodecType::Audio {
            ext.is_audio = true;
        } else if typ == RTPCodecType::Video {
            ext.is_video = true;
        }
        ext.uri = extension.uri;
        // TODO: This just overrides the previous allowed directions, which feels wrong
        ext.allowed_directions = allowed_directions;
        Ok(())
    }
pub fn register_header_extension ( & mut self , extension : RTCRtpHeaderExtensionCapability , typ : RTPCodecType , mut allowed_directions : Vec < RTCRtpTransceiverDirection > , ) -> Result < ( ) > { if allowed_directions . is_empty ( ) { allowed_directions = vec ! [ RTCRtpTransceiverDirection Recvonly RTCRtpTransceiverDirection Sendonly ] ; } for direction in & allowed_directions { if * direction != RTCRtpTransceiverDirection :: Recvonly && * direction != RTCRtpTransceiverDirection :: Sendonly { return Err ( Error :: ErrRegisterHeaderExtensionInvalidDirection ) ; } } let ext = { match self . header_extensions . iter_mut ( ) . find ( | ext | ext . uri == extension . uri ) { Some ( ext ) => ext , None => { // We have registered too many extensions if self . header_extensions . len ( ) > VALID_EXT_IDS . end as usize { return Err ( Error :: ErrRegisterHeaderExtensionNoFreeID ) ; } self . header_extensions . push ( MediaEngineHeaderExtension :: default ( ) ) ; // Unwrap is fine because we just pushed self . header_extensions . last_mut ( ) . unwrap ( ) } } } ; if typ == RTPCodecType :: Audio { ext . is_audio = true ; } else if typ == RTPCodecType :: Video { ext . is_video = true ; } ext . uri = extension . uri ; // TODO: This just overrides the previous allowed directions, which feels wrong ext . allowed_directions = allowed_directions ; Ok ( ( ) ) }
register_header_extension adds a header extension to the MediaEngine
To determine the negotiated value use [`get_header_extension_id`] after signaling is complete
register_header_extension adds a header extension to the MediaEngine To determine the negotiated value use [ ` get_header_extension_id ` ] after signaling is complete
&mut self
extension
RTCRtpHeaderExtensionCapability
typ
RTPCodecType
allowed_directions
Vec<RTCRtpTransceiverDirection>
&mut self
extension
RTCRtpHeaderExtensionCapability
typ
RTPCodecType
allowed_directions
Vec<RTCRtpTransceiverDirection>