更新1:
SAMSUNG,HTC等设备必须使用JNI设置AudioManager特殊参数。对于这些设备,您必须使用AudioRecord
对象并使用MIC源。
问题:
我正在尝试录制语音通话,问题是在记录中我只能听到我的身边(MIC),而不是听到双方的声音。
正如我所看到的,我可能错过了一些配置,或者我没有正确使用它。
我有一个静态函数,可以根据配置构建MediaRecorder
对象。
private static MediaRecorder getMediaRecorderByConf(RecordConfiguration conf) {
MediaRecorder recorder = new MediaRecorder();
recorder.setAudioSource(conf.getAudioSource());
recorder.setOutputFormat(conf.getOutputFormat());
recorder.setAudioEncoder(conf.getAudioEncoder());
return recorder;
}
配置:
CONF_1(MediaRecorder.AudioSource.VOICE_COMMUNICATION, MediaRecorder.OutputFormat.AMR_NB, "amr", MediaRecorder.AudioEncoder.AMR_NB),
CONF_2(MediaRecorder.AudioSource.VOICE_CALL, MediaRecorder.OutputFormat.AMR_NB, "amr", MediaRecorder.AudioEncoder.AMR_NB),
CONF_3(MediaRecorder.AudioSource.VOICE_COMMUNICATION, MediaRecorder.OutputFormat.MPEG_4, "mp4", MediaRecorder.AudioEncoder.AAC),
CONF_4(MediaRecorder.AudioSource.VOICE_COMMUNICATION, MediaRecorder.OutputFormat.MPEG_4, "mp4", MediaRecorder.AudioEncoder.AAC),
CONF_5(MediaRecorder.AudioSource.DEFAULT, MediaRecorder.OutputFormat.DEFAULT, "amr", MediaRecorder.AudioEncoder.DEFAULT),
这是我的构造函数:
RecordConfiguration(int audioSource, int outputFormat, String fileSuffix, int audioEncoder) {
this.audioEncoder = audioEncoder;
this.outputFormat = outputFormat;
this.fileSuffix = fileSuffix;
this.audioSource = audioSource;
}