2

How can I get and convert the remote Audio stream data on Android? Preferably in the form of byte array buffers. I would then upload the data to some third party service to process.

I've seen something similar done on Web here and here with the help of MediaStream Recording API, where they used MediaRecorder as the media to get the buffered data from MediaStream into an array. How can I do something similar on Android?

I know that it's possible to obtain the local audio data by setting a listener that implements SamplesReadyCallback in the setSamplesReadyCallback() method when creating the local AudioDeviceModule used for capturing local audio. This method doesn't really involve WebRTC's PeerConnection, it's essentially just setting a callback listener on the local audio data. Worst case scenario, I can just retrieve the local audio data by this method and send them off to the remote side via DataChannel, but I would still like a more ideal solution that can avoid sending essentially the same data twice.

Jack
  • 5,354
  • 2
  • 29
  • 54
  • what `MediaStream`? there is no such class in android SDK... what is your input data? is it PCM audio stream? – pskink Jan 22 '19 at 08:30
  • There is. You can get it from `PeerConnection.Observer`'s `onAddStream()` method. – Jack Jan 22 '19 at 08:31
  • I'm not trying to play it. I'm trying to get its buffered data as they become available, then convert them into byte array and send them to a third party service. – Jack Jan 22 '19 at 08:33
  • ah, sorry i missed `[webrtc]` tag... – pskink Jan 22 '19 at 08:43
  • @jackz314 Did you find the solution? – nick Jan 13 '20 at 20:41
  • No. I ended up changing the code in the webrtc library and implement the feature myself because there are other features I needed not implemented in the original library – Jack Jan 14 '20 at 01:29
  • @jackz314 can you share some code snippets how you able to get remote AudioTrack bytes/buffer in android. It will help me to get a direction to start. – Pwn Aug 21 '20 at 20:43
  • @Jack I also need this code snippets how to access raw audio of remote audio track – Arsenius Apr 26 '21 at 04:04
  • Which class did you modify? – Jaswant Singh Dec 02 '21 at 16:29

0 Answers0