Skip to content

Conversation

rainliu
Copy link
Member

@rainliu rainliu commented Sep 27, 2025

address #737

@rainliu rainliu requested a review from Copilot September 27, 2025 17:29
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for multi-codec negotiation in the WebRTC media engine to address issue #737. The change allows the media engine to negotiate multiple codecs instead of stopping after the first successful negotiation.

Key Changes:

  • Added a new negotiate_multi_codecs field to control whether multiple codecs can be negotiated
  • Modified the codec negotiation logic to continue processing when multi-codec negotiation is enabled
  • Added comprehensive test coverage for both single and multi-codec negotiation scenarios

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
webrtc/src/api/media_engine/mod.rs Added multi-codec negotiation field, getter/setter methods, and updated negotiation logic
webrtc/src/api/media_engine/media_engine_test.rs Added test cases to verify multi-codec negotiation functionality
Comments suppressed due to low confidence (1)

webrtc/src/api/media_engine/mod.rs:1

  • The methods set_multi_codec_negotiation and multi_codec_negotiation have inconsistent visibility - they are private (fn) but should likely be public (pub fn) to allow external configuration of this feature.
#[cfg(test)]

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +668 to +675
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))
Copy link
Preview

Copilot AI Sep 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The parentheses around the first condition are unnecessary and reduce readability. The logical precedence of ! and || operators makes these parentheses redundant.

Copilot uses AI. Check for mistakes.

Comment on lines +674 to +675
} else if (!self.negotiated_video.load(Ordering::SeqCst)
|| self.negotiate_multi_codecs.load(Ordering::SeqCst))
Copy link
Preview

Copilot AI Sep 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The parentheses around the first condition are unnecessary and reduce readability. The logical precedence of ! and || operators makes these parentheses redundant.

Copilot uses AI. Check for mistakes.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

// 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,
Copy link
Preview

Copilot AI Sep 27, 2025

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_codecs is not initialized in the default constructor. This could lead to undefined behavior. Consider adding initialization in the Default implementation or constructor.

Copilot uses AI. Check for mistakes.

@rainliu rainliu merged commit f1bdde7 into master Sep 27, 2025
4 checks passed
@rainliu rainliu deleted the multi-codec branch September 27, 2025 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants