问题描述
我正在使用自动呼叫记录器应用程序,我可以使用MediaRecorder.AudioSource.VOICE_CALL
在android 6以下录制语音呼叫,从android 6无法使用 VOICE_CALL 录制语音呼叫.我设法使用MediaRecorder.AudioSource.MIC
进行录音,但是此处未记录传入的语音,我想在普通模式下而不是在扬声器打开模式下录制语音呼叫.请帮我. (我曾尝试使用Xiomi Redmi 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音频源.这需要本机android代码.请帮助我有关路由音频的更多详细信息,请参考此问题
推荐答案
您需要使用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;}
函数setParameters
Function setParameters
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;}
任务AudioSetParameters
Task AudioSetParameters
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
这篇关于Android通话录音未录入语音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!