WebRTC microphone issue in Android 10

313 views
Skip to first unread message

Jernej Jerin

unread,
Mar 21, 2023, 9:20:44 AM3/21/23
to discuss-webrtc

Device in question:

  • DJI RC Pro Enterprise used for controlling enterprise DJI drones
  • OS is Android 10, probably running stock Android as there's no Google Play services on the device

When establishing a WebRTC session as a master from Android 10 mobile device, the audio that should be gathered via microphone is not getting through to the viewer side. When I'm configuring transceiver on the viewer side, I do enforce both send & receive for the audio part via:

viewer.peerConnection.addTransceiver('audio', {direction: 'sendrecv'});

Also looking at chrome://webrtc-internals tab, it clearly shows (inbound-rtp stats for audio) that audio channel is open and some small amount of data is coming through:
TYM4X.png


But clearly we can spot that:

  1. Bytes received in bits/s are only around 3k, where another Android device that is using newer Android version and the microphone sound is actually coming through on the viewer side is hitting around 30k bits/s.
  2. Audio level is staying at 0 regardless how loud I speak into the microphone.

Here's also the stats from inbound-rtc in text:

inbound-rtp (kind=audio, mid=4, ssrc=3185575416, [codec]=opus (111, minptime=10;useinbandfec=1), id=IT31A3185575416) Statistics IT31A3185575416 timestamp 2/16/2023, 2:51:44 PM ssrc 3185575416 kind audio trackId DEPRECATED_TI8 transportId T31 codecId CIT31_111_minptime=10;useinbandfec=1 [codec] opus (111, minptime=10;useinbandfec=1) mediaType audio jitter 0.063 packetsLost 0 trackIdentifier efe06737-ed24-448c-bf32-d002cef9171b mid 4 packetsReceived 170 [packetsReceived/s] 13.550688631363338 packetsDiscarded 0 fecPacketsReceived 0 fecPacketsDiscarded 0 bytesReceived 5524 [bytesReceived_in_bits/s] 3523.179044154468 headerBytesReceived 4760 [headerBytesReceived_in_bits/s] 3035.354253425388 lastPacketReceivedTimestamp 1676555504833 [lastPacketReceivedTimestamp] 2/16/2023, 2:51:44 PM jitterBufferDelay 77020.8 [jitterBufferDelay/jitterBufferEmittedCount_in_ms] 0 jitterBufferTargetDelay 270316.8 jitterBufferMinimumDelay 270240 jitterBufferEmittedCount 153600 totalSamplesReceived 665760 [totalSamplesReceived/s] 48782.47907290802 concealedSamples 505242 [concealedSamples/s] 48782.47907290802 [concealedSamples/totalSamplesReceived] 1 silentConcealedSamples 482592 [silentConcealedSamples/s] 48782.47907290802 concealmentEvents 14 insertedSamplesForDeceleration 6960 [insertedSamplesForDeceleration/s] 0 removedSamplesForAcceleration 0 [removedSamplesForAcceleration/s] 0 audioLevel 0 totalAudioEnergy 0 [Audio_Level_in_RMS] 0 totalSamplesDuration 13.869999999999749 jitterBufferFlushes* 2 delayedPacketOutageSamples* 452322 relativePacketArrivalDelay* 718.31 interruptionCount* 10 totalInterruptionDuration* 9.197 remoteId ROA3185575416

We have confirmed that microphone works on this device using third party tool microphone test app or just simply doing screen recording. We've also made sure on the master side that correct mode is set and that microphone is not muted via:

audioManager.requestAudioFocus(null, AudioManager.STREAM_VOICE_CALL, AudioManager.AUDIOFOCUS_GAIN_TRANSIENT); // Start by setting MODE_IN_COMMUNICATION as default audio mode. It is // required to be in this mode when playout and/or recording starts for // best possible VoIP performance. audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION); audioManager.setMicrophoneMute(false);

Also using this method to check if microphone is available just before the start of the streaming returns True:

public static boolean getMicrophoneAvailable(Context context) { MediaRecorder recorder = new MediaRecorder(); recorder.setAudioSource(MediaRecorder.AudioSource.MIC); recorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT); recorder.setOutputFile(new File(context.getCacheDir(), "MediaUtil#micAvailTestFile").getAbsolutePath()); boolean available = true; try { recorder.prepare(); recorder.start(); } catch (Exception exception) { available = false; } recorder.release(); return available; }

The questions are therefore the following:

  • Does somehow running stock Android without Google Play services impact the usage of microphone in the WebRTC streaming session? I'm basing this assumption that Google is the main developer behind WebRTC and perhaps they've built some features around their Google Play services library
  • Given that microphone is clearly available, could I manually start the recording and started sending the audio bits via open WebRTC audio channel?
Reply all
Reply to author
Forward
0 new messages