Skip to content

After update_from_remote_description the get_codecs_by_kind only returns the negotiated codec #762

@mkm85

Description

@mkm85

I have a use case where I first negotiate a video transceiver with one codecs and after some time I add another video transceiver with another codec.

After the first transceiver is added and negotiated the media engine limits the codecs available for future transceivers to just the codec which has already been negotiated.

The transceivers are created and added like this.

let transceiver = pc.add_transceiver_from_track(...
transceiver.set_codec_preferences(... // calls media_engine.get_codecs_by_kind

Below is a simple test which shows the underlying problem. (media_engine_test.rs)

async fn test_multi_codec_negotiation_get_codecs_by_kind() -> Result<()> {
    const OFFER_SDP: &str = "v=0
o=- 781500112831855234 6 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE 0 1 2 3
a=extmap-allow-mixed
a=msid-semantic: WMS be0216be-f3d8-40ca-a624-379edf70f1c9
m=application 53555 UDP/DTLS/SCTP webrtc-datachannel
a=mid:0
a=sctp-port:5000
a=max-message-size:262144
m=video 9 UDP/TLS/RTP/SAVPF 98
a=mid:1
a=sendonly
a=msid:be0216be-f3d8-40ca-a624-379edf70f1c9 3d032b3b-ffe5-48ec-b783-21375668d1c3
a=rtcp-mux
a=rtcp-rsize
a=rtpmap:98 VP9/90000
a=rtcp-fb:98 goog-remb
a=rtcp-fb:98 transport-cc
a=rtcp-fb:98 ccm fir
a=rtcp-fb:98 nack
a=rtcp-fb:98 nack pli
a=fmtp:98 profile-id=0
a=rid:q send
a=rid:h send
a=simulcast:send q;h
";
    let must_parse = |raw: &str| -> Result<SessionDescription> {
        let mut reader = Cursor::new(raw.as_bytes());
        Ok(SessionDescription::unmarshal(&mut reader)?)
    };

    // "Multi codec negotiation enabled"
    {
        let mut m = MediaEngine::default();
        m.set_multi_codec_negotiation(true);
        m.register_default_codecs()?;
        let all_codecs_count = m.get_codecs_by_kind(RTPCodecType::Video);
        m.update_from_remote_description(&must_parse(OFFER_SDP)?)
            .await?;
        let codecs_count_after_update = m.get_codecs_by_kind(RTPCodecType::Video);
        assert_eq!(all_codecs_count.len(), codecs_count_after_update.len());
    }

    Ok(())
}

I think get_codecs_by_kind should ignore negotiated_video_codecs if multi codec negotiation is enabled.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions