Skip to content

expose audio mixing as a configurable field#850

Merged
ladvoc merged 5 commits intolivekit:mainfrom
ZywaSahaj:feat/control-audio-mixing-egress
Jan 28, 2026
Merged

expose audio mixing as a configurable field#850
ladvoc merged 5 commits intolivekit:mainfrom
ZywaSahaj:feat/control-audio-mixing-egress

Conversation

@ZywaSahaj
Copy link
Contributor

@ZywaSahaj ZywaSahaj commented Jan 27, 2026

Summary by CodeRabbit

  • New Features
    • Added audio-mixing configuration for room egress, letting you control how multiple audio streams are combined.
    • Introduced additional mixing modes (including dual-channel options) for audio-only exports; if left unspecified, a sensible default mixing mode is used.

✏️ Tip: You can customize this high-level summary in your review settings.

@CLAassistant
Copy link

CLAassistant commented Jan 27, 2026

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 27, 2026

📝 Walkthrough

Walkthrough

Introduced a new public AudioMixing enum, a From<AudioMixing> for proto::AudioMixing conversion, and added audio_mixing: AudioMixing to RoomCompositeOptions; request construction now converts options.audio_mixing into the proto enum (cast to i32) when building StartRoomCompositeEgress.

Changes

Cohort / File(s) Summary
Egress service additions
livekit-api/src/services/egress.rs
Added public enum AudioMixing { DefaultMixing, DualChannelAgent, DualChannelAlternate } with Default impl; added impl From<AudioMixing> for proto::AudioMixing; added audio_mixing: AudioMixing field to RoomCompositeOptions (doc: applies when audio_only is true); updated StartRoomCompositeEgress request to set audio mixing by converting options.audio_mixing to the proto enum and casting to i32 (removed previous Option/unwrap_or handling).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 A new enum hops into the fold,
Three mixing modes, not shy nor bold,
I map them neat to proto’s tune,
Room audio now finds its rune,
Hooray — a rabbit's tiny code stroll!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'expose audio mixing as a configurable field' directly and accurately describes the main change: adding an AudioMixing enum and audio_mixing field to make audio mixing configurable.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0919416 and 008e7d0.

📒 Files selected for processing (1)
  • livekit-api/src/services/egress.rs
🧰 Additional context used
🧬 Code graph analysis (1)
livekit-api/src/services/egress.rs (1)
livekit/src/proto.rs (16)
  • from (23-30)
  • from (34-53)
  • from (69-74)
  • from (78-86)
  • from (90-98)
  • from (102-107)
  • from (111-116)
  • from (120-126)
  • from (130-136)
  • from (140-146)
  • from (150-159)
  • from (163-178)
  • from (182-191)
  • from (195-204)
  • from (208-215)
  • from (219-229)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
  • GitHub Check: Build (x86_64-linux-android)
  • GitHub Check: Build (armv7-linux-androideabi)
  • GitHub Check: Build (aarch64-apple-darwin)
  • GitHub Check: Build (aarch64-unknown-linux-gnu)
  • GitHub Check: Build (aarch64-linux-android)
  • GitHub Check: Build (x86_64-pc-windows-msvc)
  • GitHub Check: Build (x86_64-unknown-linux-gnu)
  • GitHub Check: Build (x86_64-apple-darwin)
  • GitHub Check: Build (aarch64-pc-windows-msvc)
  • GitHub Check: Build (aarch64-apple-ios-sim)
  • GitHub Check: Build (aarch64-apple-ios)
  • GitHub Check: Test (x86_64-pc-windows-msvc)
  • GitHub Check: Test (x86_64-apple-darwin)
  • GitHub Check: Test (x86_64-unknown-linux-gnu)
🔇 Additional comments (3)
livekit-api/src/services/egress.rs (3)

20-39: LGTM — enum + conversion mapping is clear and consistent.
The variant mapping is straightforward and matches the proto names.


48-49: Public struct gained a required field — confirm semver / migration plan.
Adding audio_mixing to a public struct is a source-breaking change for consumers using struct literals without ..Default. Please confirm the semver bump and/or document the migration path (or consider a builder/#[non_exhaustive] strategy if breakage isn’t intended).


136-136: Verify backend behavior when audio_only is false.
The doc says audio_mixing only applies when audio_only is true, but the request always sends it. If the backend validates combinations, this could be rejected or misinterpreted. Please confirm with backend behavior/tests, or gate/reset to DefaultMixing when audio_only is false.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@livekit-api/src/services/egress.rs`:
- Line 115: The failing CI is due to formatting on the line setting
audio_mixing; re-run rustfmt (cargo fmt) and split or reflow the expression so
it fits style rules—for example wrap the call and cast across lines or use a
local let binding like let audio_mixing =
options.audio_mixing.unwrap_or(proto::AudioMixing::DefaultMixing) as i32; then
use audio_mixing in the struct; update the file containing the audio_mixing
assignment (references: audio_mixing, options.audio_mixing,
proto::AudioMixing::DefaultMixing) and commit the formatted change.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cc06ebb and 3984da4.

📒 Files selected for processing (1)
  • livekit-api/src/services/egress.rs
🧰 Additional context used
🪛 GitHub Actions: Rust Formatting
livekit-api/src/services/egress.rs

[error] 112-114: cargo fmt -- --check failed: formatting inconsistency detected. Expected style change in egress.rs around the audio_mixing line.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
  • GitHub Check: Test (x86_64-unknown-linux-gnu)
  • GitHub Check: Test (x86_64-pc-windows-msvc)
  • GitHub Check: Test (x86_64-apple-darwin)
  • GitHub Check: Build (aarch64-apple-ios-sim)
  • GitHub Check: Build (aarch64-linux-android)
  • GitHub Check: Build (x86_64-apple-darwin)
  • GitHub Check: Build (aarch64-apple-darwin)
  • GitHub Check: Build (armv7-linux-androideabi)
  • GitHub Check: Build (x86_64-unknown-linux-gnu)
  • GitHub Check: Build (aarch64-unknown-linux-gnu)
  • GitHub Check: Build (x86_64-linux-android)
  • GitHub Check: Build (x86_64-pc-windows-msvc)
  • GitHub Check: Build (aarch64-apple-ios)
  • GitHub Check: Build (aarch64-pc-windows-msvc)
🔇 Additional comments (1)
livekit-api/src/services/egress.rs (1)

27-28: LGTM!

The new audio_mixing field is well-documented and appropriately typed as Option<proto::AudioMixing>. The default of None combined with the unwrap_or usage ensures backward compatibility.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

@ladvoc
Copy link
Contributor

ladvoc commented Jan 28, 2026

Hi @ZywaSahaj, thank you for your PR. Please integrate with main which fixes CI builds.

@ZywaSahaj
Copy link
Contributor Author

Hi @ladvoc it's done 😄

Copy link
Contributor

@ladvoc ladvoc left a comment

Choose a reason for hiding this comment

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

Thanks, @ZywaSahaj! To stay consistent with the reset of this module, I would recommend creating a public enum type to represent AudioMixing to keep the protocol level enum as an implementation detail. This also allows implementing default so we can drop the option.

Define public wrapper:

#[derive(Clone, Copy, Debug, Default)]
pub enum AudioMixing {
    /// All users are mixed together.
    #[default]
    DefaultMixing,
    /// Agent audio in the left channel, all other audio in the right channel.
    DualChannelAgent,
    /// Each new audio track alternates between left and right channels.
    DualChannelAlternate,
}

impl Into<proto::AudioMixing> for AudioMixing {
    fn into(self) -> proto::AudioMixing {
        match self {
            AudioMixing::DefaultMixing => proto::AudioMixing::DefaultMixing,
            AudioMixing::DualChannelAgent => proto::AudioMixing::DualChannelAgent,
            AudioMixing::DualChannelAlternate => proto::AudioMixing::DualChannelAlternate,
        }
    }
}

Use into implementation to convert to protocol equivalent

// ...
audio_only: options.audio_only,
audio_mixing: Into::<proto::AudioMixing>::into(options.audio_mixing) as i32,
video_only: options.video_only, 
// ...

Use in room options without option:

#[derive(Default, Clone, Debug)]
pub struct RoomCompositeOptions {
    pub layout: String,
    pub encoding: encoding::EncodingOptions,
    pub audio_only: bool,
    pub video_only: bool,
    pub custom_base_url: String,
    /// Only applies when audio_only is true (default: DefaultMixing)
    pub audio_mixing: AudioMixing,
}

@ZywaSahaj
Copy link
Contributor Author

Yup, makes sense. fairly new to rust, thanks for the detailed code 😄

@ladvoc ladvoc self-requested a review January 28, 2026 12:26
Copy link
Contributor

@ladvoc ladvoc left a comment

Choose a reason for hiding this comment

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

Looks good! ✅

@ladvoc ladvoc merged commit 6e47737 into livekit:main Jan 28, 2026
18 checks passed
@github-actions github-actions bot mentioned this pull request Jan 28, 2026
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.

3 participants