How can I catch a stream from Webview and change it to VOICE_CALL Stream with AEC?

189 Views Asked by At

I am using Agora, and it has some issues. One of them is the speaker's voice comes out to the media sound.

On the browser, it can't control the media volume, So, I created an app to handle this. In the app, I dispatch the volume up/down button to control media volume.

However, this method created howling issue. So, I'd like to send the sound to STREAM_VOICE_CALL and use AEC(Acoustic Echo Cancellation) API on Android so that the sound comes out to the right stream and it can handle the echo problem.

what I wrote,

    private fun enableVoiceCallMode() {
        with(audioManager) {
            volumeControlStream = AudioManager.STREAM_VOICE_CALL
            setStreamVolume(
                AudioManager.STREAM_VOICE_CALL,
                audioManager.getStreamVolume(AudioManager.STREAM_VOICE_CALL),
                0
            )
        }
    }

But this didn't work.

And also, I tried to apply AEC like this:

    private fun enableEchoCanceler() {
        if (AcousticEchoCanceler.isAvailable() && aec == null) {
            aec = AcousticEchoCanceler.create(audioManager.generateAudioSessionId())
            aec?.enabled = true
        } else {
            aec!!.enabled = false
            aec!!.release()
            aec = null
        }
    }

    private fun releaseEchoCanceler() {
        aec!!.enabled = false
        aec?.release()
        aec = null
    }

However, I don't know if AcousticEchoCanceler.create(audioManager.generateAudioSessionId()) is correct way or not.

please help me out.

0

There are 0 best solutions below