-
-
Notifications
You must be signed in to change notification settings - Fork 449
Add support for multi codec negotiation #741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -88,6 +88,7 @@ pub struct MediaEngine { | |
| // If we have attempted to negotiate a codec type yet. | ||
| pub(crate) negotiated_video: AtomicBool, | ||
| pub(crate) negotiated_audio: AtomicBool, | ||
| pub(crate) negotiate_multi_codecs: AtomicBool, | ||
|
|
||
| pub(crate) video_codecs: Vec<RTCRtpCodecParameters>, | ||
| pub(crate) audio_codecs: Vec<RTCRtpCodecParameters>, | ||
|
|
@@ -461,6 +462,17 @@ impl MediaEngine { | |
| } | ||
| } | ||
|
|
||
| /// set_multi_codec_negotiation enables or disables the negotiation of multiple codecs. | ||
| pub(crate) fn set_multi_codec_negotiation(&self, negotiate_multi_codecs: bool) { | ||
| self.negotiate_multi_codecs | ||
| .store(negotiate_multi_codecs, Ordering::SeqCst); | ||
| } | ||
|
|
||
| /// multi_codec_negotiation returns the current state of the negotiation of multiple codecs. | ||
| pub(crate) fn multi_codec_negotiation(&self) -> bool { | ||
| self.negotiate_multi_codecs.load(Ordering::SeqCst) | ||
| } | ||
|
|
||
| pub(crate) async fn get_codec_by_payload( | ||
| &self, | ||
| payload_type: PayloadType, | ||
|
|
@@ -653,12 +665,14 @@ impl MediaEngine { | |
| desc: &SessionDescription, | ||
| ) -> Result<()> { | ||
| for media in &desc.media_descriptions { | ||
| let typ = if !self.negotiated_audio.load(Ordering::SeqCst) | ||
| let typ = if (!self.negotiated_audio.load(Ordering::SeqCst) | ||
| || self.negotiate_multi_codecs.load(Ordering::SeqCst)) | ||
| && media.media_name.media.to_lowercase() == "audio" | ||
| { | ||
| self.negotiated_audio.store(true, Ordering::SeqCst); | ||
| RTPCodecType::Audio | ||
| } else if !self.negotiated_video.load(Ordering::SeqCst) | ||
| } else if (!self.negotiated_video.load(Ordering::SeqCst) | ||
| || self.negotiate_multi_codecs.load(Ordering::SeqCst)) | ||
|
Comment on lines
+668
to
+675
|
||
| && media.media_name.media.to_lowercase() == "video" | ||
| { | ||
| self.negotiated_video.store(true, Ordering::SeqCst); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new field
negotiate_multi_codecsis not initialized in the default constructor. This could lead to undefined behavior. Consider adding initialization in theDefaultimplementation or constructor.