Android 通话录音 来电未录音 [英] Android Call Recording Incoming voice not getting recorded

查看:37
本文介绍了Android 通话录音 来电未录音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用自动通话记录器应用程序,我可以使用 MediaRecorder.AudioSource.VOICE_CALL 在 android 6 以下记录语音通话,从 android 6 开始,无法使用 VOICE_CALL 录制语音通话.我设法使用 MediaRecorder.AudioSource.MIC 进行录制,但这里传入的语音没有被录制,我想在正常模式下录制语音通话,而不是在扬声器开启模式下录制.请帮助我.(我试过小米红米4a(android 6),不行).

I'm working auto call recorder app, I'm able to record voice call on below android 6 using MediaRecorder.AudioSource.VOICE_CALL, From android 6 not able to record voice call using VOICE_CALL. I managed to record using MediaRecorder.AudioSource.MIC but here incoming voice not getting recorded and I want to record voice call in normal mode not in speaker on mode. Please help me on this. (I had tried on Xiomi Redmi 4a(android 6),not working).

 myRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
 myRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
 myRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
 myRecorder.setMaxDuration(60 * 60 * 1000);
 AudioManager audiomanager =
 (AudioManager)getSystemService(AUDIO_SERVICE);
 audiomanager.setMode(2);

权限没有问题.

更新:任何人都知道如何强制另一个流到 MIC 音频源.这需要原生安卓代码.请帮我解决这个问题参考这个问题了解更多关于路由音频的细节

推荐答案

需要用到ndk.以下是需要完成的功能示例.

You need to use ndk. Here are examples of the functions that need to be done.

加载 libmedia.so 和 libutils.so

Load libmedia.so and libutils.so

int load(JNIEnv *env, jobject thiz) {
    void *handleLibMedia;
    void *handleLibUtils;
    int result = -1;
    lspr func = NULL;

    pthread_t newthread = (pthread_t) thiz;

    handleLibMedia = dlopen("libmedia.so", RTLD_NOW | RTLD_GLOBAL);
    if (handleLibMedia != NULL) {
        func = dlsym(handleLibMedia, "_ZN7android11AudioSystem13setParametersEiRKNS_7String8E");
        if (func != NULL) {
            result = 0;
        }
        audioSetParameters = (lasp) func;
    } else {
        result = -1;
    }

    handleLibUtils = dlopen("libutils.so", RTLD_NOW | RTLD_GLOBAL);
    if (handleLibUtils != NULL) {
        fstr = dlsym(handleLibUtils, "_ZN7android7String8C2EPKc");
        if (fstr == NULL) {
            result = -1;
        }
    } else {
        result = -1;
    }

    cmd = CM_D;

    int resultTh = pthread_create(&newthread, NULL, taskAudioSetParam, NULL);

    return result;}

函数集参数

int setParam(jint i, jint as) {
pthread_mutex_lock(&mt);

audioSession = (int) (as + 1);

kvp = "input_source=4";
kvps = toString8(kvp);

cmd = (int) i;

pthread_cond_signal(&cnd);
pthread_mutex_unlock(&mt);

return 0;}

任务音频设置参数

void *taskAudioSetParam(void *threadid) {
    while (1) {
        pthread_mutex_lock(&mt);
        if (cmd == CM_D) {
            pthread_cond_wait(&cnd, &mt);
        } else if (audioSetParameters != NULL) {
             audioSetParameters(audioSession, kvps);
        }
        pthread_mutex_unlock(&mt);
    }
}

有一个库和一个使用示例https://github.com/ViktorDegtyarev/CallRecLib

There is a library and an example of use https://github.com/ViktorDegtyarev/CallRecLib

这篇关于Android 通话录音 来电未录音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆