Audio routing on native Android?

683 views
Skip to first unread message

Matej Semančík

unread,
Jul 18, 2018, 2:28:41 AM7/18/18
to discuss-webrtc
Hi, I'm currently developing and Android app that shows multiple webcam streams using native webrtc library and I'm struggling with the way webrtc routes the audio - the audio is routed like in telephone call, which is unwanted for my use-case (the app does not behave like it has calling feature, it's more of content-streaming app). Therefore I wanted to ask, if it is currently possible to have webrtc audio routed like normal music stream? I could not find any documentation whatsoever and it seems like native webrtc for Android does not have any API for audio control (or I'm just blind :-)) (I only found WebRtcAudioManager which does not what I want). I've seen some answers around the web suggesting to enable speakerPhone in android's AudioManager, but I don't want to do that, I want music-like behavior. Thanks for any help!

Henrik Andreasson

unread,
Jul 18, 2018, 4:54:40 AM7/18/18
to discuss-webrtc
Native WebRTC for Android contains no device handling what so ever and it is all up to the client to manage those parts.

The best example of how to: select audio mode, select device, deal with BT etc. can be found in AppRTCMobile, where the things you
ask for are handled by the AppRTCAudioManager (which is not part of WebRTC, it is just an example) and not the WebRtcAudioManager.

Given the nature of WebRTC (it is a VoIP stack), it is required to use the MODE_IN_COMMUNICATION mode.
See example here. If you don't do that, error logs will be produced and the underlying audio streams (which assumes COMM),
might not work as intended. Levels might be off, volume control will not work as intended and AEC might not behave well either.

If you want to change WebRTC into not using  MODE_IN_COMMUNICATION, you can try to match the mode of the audio streams
with your mode here. It is experimental and might lead to other issues but feel free to try it out. Similar support is not added for the input side.

On Wed, Jul 18, 2018 at 8:28 AM Matej Semančík <matej.s...@gmail.com> wrote:
Hi, I'm currently developing and Android app that shows multiple webcam streams using native webrtc library and I'm struggling with the way webrtc routes the audio - the audio is routed like in telephone call, which is unwanted for my use-case (the app does not behave like it has calling feature, it's more of content-streaming app). Therefore I wanted to ask, if it is currently possible to have webrtc audio routed like normal music stream? I could not find any documentation whatsoever and it seems like native webrtc for Android does not have any API for audio control (or I'm just blind :-)) (I only found WebRtcAudioManager which does not what I want). I've seen some answers around the web suggesting to enable speakerPhone in android's AudioManager, but I don't want to do that, I want music-like behavior. Thanks for any help!

--

---
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/bb2ef021-d428-44ca-961e-9b0d011bee29%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Matej Semančík

unread,
Jul 26, 2018, 5:05:21 AM7/26/18
to discuss-webrtc
Thanks for the answer! Setting AudioTrack usage attribute did not work, so I will stick with communication mode, I guess.
Reply all
Reply to author
Forward
0 new messages