yatakabs / WhepPlayer

MIT License
1 stars 0 forks source link

Fix for the issue #1 Audio Downmixing to Mono in Chromium-based Browsers #2

Closed yatakabs closed 5 months ago

yatakabs commented 5 months ago

Fixes #1

Summary

The issue was caused by the default behavior of the WebRTC negotiation when Opus is used as the audio codec. For chromium-based browsers, opus stream information in SDP have to be set to stereo by "stereo=1" attribute. Otherwise, the browser will downmix the audio to mono by default.

This fix updated the PeerConnection setup logic to modify offer/answer SDP to include the "stereo=1" attribute for the Opus codec.

Changes

  1. Introduced updateAnswerSdpToFixStereoAudioIssue() in index.js to modify the answer SDP to include the "stereo=1" attribute for the Opus codec.
  2. Updated startWhepStream() in index.js to call updateAnswerSdpToFixStereoAudioIssue() to modify the offer and answer SDP.

Tests

Manual Tests

Automated Tests

N/A