Skip to content

Signal Opus as opus/48000/2 for mono tracks - #1

Open
thesyncim wants to merge 1 commit into
mainfrom
fix/opus-codec-channels
Open

thesyncim wants to merge 1 commit into
mainfrom
fix/opus-codec-channels

Conversation

@thesyncim

Copy link
Copy Markdown
Member

Publishing with the default TrackWriter (mono) never worked: Codec() declared opus/48000/1, but RFC 7587 signals Opus as opus/48000/2 regardless of the channels carried, and that is what the SFU and browsers negotiate. Pion couldn't bind the track (SetRemoteDescription → ErrUnsupportedCodec, logged as "a track does not support the negotiated codec"), ICE never connected, and no audio reached the call. examples/audio and examples/publish both hit it against a live call.

  • TrackWriter.Codec() always declares two channels (mono audio is a valid stream of that codec); examples/publish likewise.
  • New TestTrackWriterBindsToNegotiatedOpus: publishes the default writer over a loopback peer that negotiates Pion's default codecs and checks the track binds and audio arrives. It fails on main with ErrUnsupportedCodec.
  • TestTrackWriterCodec now expects two channels for mono.

Verified live: examples/audio (unmodified) publishes into a call and a subscriber receives and decodes the audio; before the change it logged the codec error and never connected. make ci passes.

TrackWriter.Codec declared the encoder's channel count, so the default mono
writer offered opus/48000/1. RFC 7587 signals Opus as opus/48000/2 whatever
the stream carries, and that is what the SFU and browsers negotiate, so pion
could not bind the track: SetRemoteDescription returned ErrUnsupportedCodec,
the SDK logged "a track does not support the negotiated codec", ICE never
connected, and nothing was published. examples/audio (which uses the default
writer) and examples/publish (which hard-coded one channel) both failed this
way against a live call.

The capability now always says two channels; mono audio is a valid stream of
that codec. A new loopback test publishes the default writer to a peer that
negotiates Opus with pion's default codecs and checks that the track binds and
its audio arrives; it fails without this change.
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.

1 participant