Trouble streaming stereo audio with native library

293 views
Skip to first unread message

James Inkster

unread,
Oct 23, 2020, 12:34:27 AM10/23/20
to discuss-webrtc
Hi,
I'm using the C++ library, and I have been working toward streaming audio (from disk) and receiving it remotely. 
I have it working fine with 1 channel audio, but cannot get it to work correctly with > 1 channel (stereo)

Background, i'm using an approach several on here seem to be using with success:

- I'm receiving audio (playback) by implementing a custom ADM, storing a pointer to the AudioTransport callback (registered by the system in RegisterAudioCallback()), and then I call ::NeedMorePlaybackData() on that callback. That triggers OnData() to get called on my custom AudioTrackSinkInterface object...
 
- I'm sending audio (recording) by for each AudioSource I instantiate a corresponding implementation of AudioSourceInterface (derived from LocalAudioSource, in my case). The library calls AddSink() on that, I hang onto that sink and call ::OnData() on it whenever I've got 10ms worth to send. I'm sending 16-bit interleaved PCM at 48k. 

As mentioned, this works when I'm sending and receiving mono audio, but not stereo.
With stereo, no matter what I do my playback callback (AudioTrackSinkInterface::OnData()) is called with number_of_channels set to 1!

I've walked through the webrtc code, following from NeedMorePlaybackData(480, 4, 2, 48k, etc) down through AudioMixer::Mix(), GetAudioFromSources(), GetAudioFrameWithInfo(), etc... however nowhere does it seem to use the 2 i pass in for 
number of channels. The '1' for number of channels that ultimately gets called on my ::OnData() callback comes from the audio_frame itself, not what I pass in...

AudioMixer::Mix() has audio_frame_for_mixing, which has 2 channels, but it seems the audio_frame pointer in my 'SourceStatus' object always has num channels set to 1. Is there a way to designate the source as stereo when I create it...?

Any suggestions/ideas on what I might be doing wrong? 

Thanks,
james

James Inkster

unread,
Oct 23, 2020, 4:48:01 PM10/23/20
to discuss-webrtc
I have now read various other threads describing problems with stereo playback, and have hacked the SDP accordingly (adding stereo=1;sprop-stereo=1)
Still no luck, though -- the AudioTrackSinkInterface::OnData() still always comes with num_channels = 1.

Any insights?
Is anyone else successfully sending (and receiving) stereo audio??

Kiran Thind

unread,
Oct 24, 2020, 7:19:43 AM10/24/20
to discuss...@googlegroups.com
Take a look at https://github.com/CoSMoSoftware/OBS-studio-webrtc/tree/m84v23.2-Clean/plugins/obs-outputs; specifically WebRTCStream.cpp and AudioDeviceModuleWrapper.cpp.

On Oct 23, 2020, at 1:48 PM, James Inkster <jamesi...@gmail.com> wrote:

I have now read various other threads describing problems with stereo playback, and have hacked the SDP accordingly (adding stereo=1;sprop-stereo=1)
--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/719c0ab3-9a57-4535-a1ba-c7f77f43e5edn%40googlegroups.com.

James Inkster

unread,
Oct 26, 2020, 8:19:55 PM10/26/20
to discuss-webrtc
Hi Kiran,

Thanks for the link. I've been looking it over today and it looks very similar to my approach.
Are you the author? Are you successfully receiving > 1 channel of audio?

I've modified both my sdp offer and answer by replacing 
a=fmtp:111 minptime=10;useinbandfec=1 
with
a=fmtp:111 minptime=10;useinbandfec=1;stereo=1;sprop-stereo=1;maxplaybackrate=48000;sprop-maxcapturerate=48000;

Thanks
Reply all
Reply to author
Forward
0 new messages