Get Audio Session Id from Google Meet

淺唱寂寞╮ 提交于 2020-12-23 13:50:20

问题


I am playing with DynamicsProcessing. I want to process the audio from an external application. I just require the audioSessionId for that. I have no problems with Play Music, for example. I have used a BroadCastReceiver listening the android.media.action.OPEN_AUDIO_EFFECT_CONTROL_SESSION and everything works like a charm.

<receiver android:name=".framework.AudioSessionReceiver">
    <intent-filter>
        <action android:name="android.media.action.OPEN_AUDIO_EFFECT_CONTROL_SESSION"/>
    </intent-filter>
</receiver>
class AudioSessionReceiver : BroadcastReceiver() {

    override fun onReceive(context: Context?, intent: Intent?) {
        intent?.let {
            val audioSessionId = intent.getIntExtra(Equalizer.EXTRA_AUDIO_SESSION, -1)
            val packageName = intent.getStringExtra(Equalizer.EXTRA_PACKAGE_NAME)
            KLog.i("audioSessionId: $audioSessionId")
            KLog.i("packageName: $packageName")
        } ?: KLog.w("Intent is null")
    }
}

The challenge is when I want to do the same with Google Meet. I do not know how to get the session id from the app. But I know it is possible because I can see it directly if I look for it on Logcat:

WebRtcAudioTrackExternal: [623:191] [21746] AudioTrack: session ID: 7649, channels: 1, sample rate: 48000, max gain: 1.0

And I have checked it works if I pass the session ID (audioSessionId) manually.

How can I do it from the app?

Thank you so much!! :-)


回答1:


It can be obtained from the audioSessionId of the active AudioRecord because it is created just after the AudioTrack creation and the numbers go from 8 to 8.

val audioManager = (context.getSystemService(Context.AUDIO_SERVICE) as AudioManager)
return audioManager.activeRecordingConfigurations[0].clientAudioSessionId - 8

I have checked it doing a video conference with Google Meet and equalize the voice from the other person. ;-)

https://github.com/soygabimoreno/AudioClean



来源:https://stackoverflow.com/questions/62907692/get-audio-session-id-from-google-meet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!