问题描述
我正在玩 DynamicsProcessing
.我想处理来自外部应用程序的音频.我只需要 audioSessionId
即可.例如,我在播放音乐上没有问题.我使用了 BroadCastReceiver
来监听 android.media.action.OPEN_AUDIO_EFFECT_CONTROL_SESSION
,并且所有内容都像一个魅力.
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")
}
}
挑战在于我想对 Google Meet 做同样的事情.我不知道如何从应用程序获取会话ID.但是我知道这是可能的,因为如果我在Logcat上寻找它,我可以直接看到它:
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
并且我已经检查了它是否可以手动传递 session ID
(audioSessionId).
And I have checked it works if I pass the session ID
(audioSessionId) manually.
如何从应用程序中完成此操作?
非常感谢!!:-)
推荐答案
可以从有效的 AudioRecord
的 audioSessionId
中获取它,因为它是在 AudioTrack
创建,数字从8到8.
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
我检查了它是否与 Google Meet 进行了视频会议,并均衡了其他人的声音.;-)
I have checked it doing a video conference with Google Meet and equalize the voice from the other person. ;-)
https://github.com/soygabimoreno/AudioClean
这篇关于从Google Meet获取音频会话ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!