Skip to content

Fix inverted AudioPublishOptions.red - #1272

Merged
hiroshihorie merged 1 commit into
mainfrom
hiroshi/fix-audio-red-inverted
Nov 2, 2026
Merged

hiroshihorie merged 1 commit into
mainfrom
hiroshi/fix-audio-red-inverted

Conversation

@hiroshihorie

@hiroshihorie hiroshihorie commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Fixes #1271

AudioPublishOptions.red was passed to AddTrackRequest.disableRed without negation. The default red: true sent disableRed: true, so RED has been off for every Flutter audio publish since 2.0.0, and red: false turned it on.

// before
disableRed: room.e2eeManager != null ? true : publishOptions.red ?? true,
// after
disableRed: room.e2eeManager != null || !(publishOptions.red ?? true),

This matches the JS (this.isE2EEEnabled || !(opts.red ?? true)) and Rust SDKs. E2EE still forces RED off.

Why it matters

The SFU decides from disableRed whether to prefer audio/red in the publisher answer. Flutter sends no audio simulcast codecs, so IsRedEnabled falls back to !disableRed. libwebrtc always offers RED after Opus, so with this fix RED gets negotiated on all platforms.

History

The inverted line came in with #453 (2024-01-23), whose goal was to disable RED under E2EE for a Firefox decryption failure. That half was right. #720 later rewrote the line above it as disableDtx: !publishOptions.dtx and left RED as is.

Behavior change

Apps that set red: false to get RED working will now get RED disabled. The changeset says so.

JS defaults RED off for stereo tracks. That does not apply here: Flutter never sends stereo or TF_STEREO, so the server answer strips stereo=1 and Flutter always publishes mono Opus. The stereo AudioEncoding presets only set a bitrate. JS also enables RED by default for mono.

Tests

test/participant/audio_publish_red_test.dart publishes a mic track through the room mocks and checks the sent AddTrackRequest for the default, red: false, and E2EE cases. The first two fail on main. To let a publish run in a unit test, MockWebSocketConnector now records sent data and MockPeerConnection.addTransceiver returns a stub transceiver instead of throwing.

Not yet checked against a real server.

The default red: true was sent as disableRed: true, so RED was off for
every audio publish since 2.0.0, and red: false turned it on. Negate the
option like disableDtx and the other SDKs do. E2EE still forces RED off.

The test publishes through the mocks and checks the AddTrackRequest, so
the mock socket now records sent data and the mock peer connection hands
out a stub transceiver.
@hiroshihorie
hiroshihorie marked this pull request as ready for review October 30, 2026 23:23

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@hiroshihorie
hiroshihorie merged commit ed87344 into main Nov 2, 2026
15 checks passed
@hiroshihorie
hiroshihorie deleted the hiroshi/fix-audio-red-inverted branch November 2, 2026 08:45
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.

[bug] AudioPublishOptions.red is inverted: the default red: true sends disableRed: true, disabling RED for every audio publish

2 participants