fn insert_local_candidates_into_sdp(
    raw_sdp: &String,
    local_candidates: &Vec<IceCandidate>,
) -> Result<webrtc_sdp::SdpSession> {
    let mut session = validate_sdp(&raw_sdp)?;

    local_candidates.iter().for_each(|c| {
        let index = c.get_media_line_index() as usize;
        let mut media = session
            .media
            .get(index)
            .cloned()
            .expect("Could not find matching media for ice candidate");

        if let Ok(parsed) = moz_ice::to_moz_candidate(&c.get_candidate_str()) {
            let attribute = webrtc_sdp::attribute_type::SdpAttribute::Candidate(parsed);

            if let Ok(_) = media.add_attribute(attribute) {
                std::mem::replace(&mut session.media[index], media);
            }
        }
    });

    Ok(session)
}
/// Inserts the provided ice candidates into an sdp payload, respecting the relative media lines.
Inserts the provided ice candidates into an sdp payload, respecting the relative media lines.
Inserts the provided ice candidates into an sdp payload respecting the relative media lines .
fn insert_local_candidates_into_sdp(
    raw_sdp: &String,
    local_candidates: &Vec<IceCandidate>,
) -> Result<webrtc_sdp::SdpSession> {
    let mut session = validate_sdp(&raw_sdp)?;
    local_candidates.iter().for_each(|c| {
        let index = c.get_media_line_index() as usize;
        let mut media = session
            .media
            .get(index)
            .cloned()
            .expect("Could not find matching media for ice candidate");
        if let Ok(parsed) = moz_ice::to_moz_candidate(&c.get_candidate_str()) {
            let attribute = webrtc_sdp::attribute_type::SdpAttribute::Candidate(parsed);
            if let Ok(_) = media.add_attribute(attribute) {
                std::mem::replace(&mut session.media[index], media);
            }
        }
    });
    Ok(session)
}
fn insert_local_candidates_into_sdp ( raw_sdp : & String , local_candidates : & Vec < IceCandidate > , ) -> Result < webrtc_sdp :: SdpSession > { let mut session = validate_sdp ( & raw_sdp ) ? ; local_candidates . iter ( ) . for_each ( | c | { let index = c . get_media_line_index ( ) as usize ; let mut media = session . media . get ( index ) . cloned ( ) . expect ( " " ) ; if let Ok ( parsed ) = moz_ice :: to_moz_candidate ( & c . get_candidate_str ( ) ) { let attribute = webrtc_sdp :: attribute_type :: SdpAttribute :: Candidate ( parsed ) ; if let Ok ( _ ) = media . add_attribute ( attribute ) { std :: mem :: replace ( & mut session . media [ index ] , media ) ; } } } ) ; Ok ( session ) }
Inserts the provided ice candidates into an sdp payload, respecting the relative media lines.
Inserts the provided ice candidates into an sdp payload respecting the relative media lines .
raw_sdp
&String
local_candidates
&Vec<IceCandidate>
raw_sdp
&String
local_candidates
&Vec<IceCandidate>