Using WebRTC's AEC3 on custom audio data

212 views
Skip to first unread message

Elise Monaghan

unread,
Apr 21, 2021, 9:47:53 PM4/21/21
to discuss-webrtc
I'm grabbing the raw audio output data from the WebRTC remote audio track (using the  AudioTrackSinkInterface::OnData callback), and passing this audio data to my audio engine (separate from WebRTC) to process & render. I mute the WebRTC remote audio track when doing so (since my audio engine is taking care of rendering, and I therefore don't want WebRTC outputting any audio) by calling set_enabled(false) on the remote audio track.

Because the audio track is being disabled, it outputs silence, and hence AEC3 doesn't actually do anything (obviously). Now, my question is: is it somehow possible for me to 
avail of WebRTC's AEC3 but apply it on the rendered result of my audio engine output instead? i.e. would it be possible to write my rendered audio engine audio output to the remote audio track somehow, so that it can be used as the input to the AEC3 algorithm? 

I suppose this would also mean that I wouldn't be able to disable the remote audio track anymore (since I will be writing data to it), which would mean I'd have to let WebRTC do the audio output and silence my audio engine instead (which is fine if AEC3 can work on 48kHz stereo data, which is what my audio engine currently outputs). Unless there's a way for me to have my cake and eat it too by being able to write audio data to the webrtc remote audio track, but still 'silence'/mute webrtc audio output somehow?

Hope this makes sense, any insight would be appreciated. Thanks!

Elise Monaghan

unread,
Apr 27, 2021, 10:07:14 PM4/27/21
to discuss-webrtc
Anyone? After some more inspection, it seems that perhaps the way to do this would be to create my own custom AudioProcessingModule and inject that into the CreatePeerConnectionFactory call, and have the custom APM override the ProcessReverseStream method and inject my own audio data into it... but ProcessReverseStream seems to take in both a source and destination for audio data, so I'm not sure exactly how that would work...
Reply all
Reply to author
Forward
0 new messages