4

I'm working on a call recorder app using MediaRecorder VOICE_CALL audio source, In some marshmallow devices it's crashing, then I changed source to MIC here incoming voice is not getting recorded. Due to this java limitation now I'm working on native android code to record voice call. I'm managed to record the audio using native-audio recorder for call recorder. Problem is in native code also it's recording one side voice only,incoming voice is not getting recorded. Then I tried the voice communication preset configuration, its not recording. Below is the preset configuration code.

const SLInterfaceID id[2] = { SL_IID_ANDROIDSIMPLEBUFFERQUEUE,SL_IID_ANDROIDCONFIGURATION};
const SLboolean req[2] = { SL_BOOLEAN_TRUE,SL_BOOLEAN_TRUE};

result = (*engineEngine)->CreateAudioRecorder(engineEngine, &recorderObject, &audioSrc,
                                              &audioSnk, 2, id, req);

SLAndroidConfigurationItf inputConfig;
result = (*recorderObject)->GetInterface(recorderObject,
                                         SL_IID_ANDROIDCONFIGURATION,
                                         &inputConfig);


if (SL_RESULT_SUCCESS == result) {
    SLuint32 presetValue =SL_ANDROID_RECORDING_PRESET_VOICE_COMMUNICATION ;
    (*inputConfig)->SetConfiguration(inputConfig,
                                     SL_ANDROID_KEY_RECORDING_PRESET,
                                     &presetValue,
                                     sizeof(SLuint32));
    __android_log_print(ANDROID_LOG_DEBUG, "LOG_TAG", "\n Native PCM Conf Success\n");

} else{
    __android_log_print(ANDROID_LOG_DEBUG, "LOG_TAG", "\n Native PCM Conf Error %d\n",result);

}

After adding preset configuration I'm getting system error when start recording the voice call :

E/AudioRecord: Could not get audio input for record source 7, sample rate 16000, format 0x1, channel mask 0x10, session 925, flags 0

E/libOpenSLES: android_audioRecorder_realize(0x559548c350) error creating AudioRecord object; status -22

W/libOpenSLES: Leaving Object::Realize (SL_RESULT_CONTENT_UNSUPPORTED)

E.Abdel
  • 1,992
  • 1
  • 13
  • 24
Bharath Kumar
  • 534
  • 1
  • 7
  • 18
  • Are you talking about https://github.com/googlesamples/android-ndk/tree/master/audio-echo this link but in my case audio file is not create with this code – Bhanu Sharma Sep 01 '17 at 07:03
  • No I used this example: https://github.com/googlesamples/android-ndk/tree/master/native-audio, and during voice call I started recorder and on buffer stored file as .pcm inside sd-card. Check this link for saving to sdcard : https://stackoverflow.com/questions/18444354/save-recorded-audio-to-file-opensl-es-android – Bharath Kumar Sep 01 '17 at 07:18
  • means it not starting automatically? I run the code there is one button start so when I call tmo any one then i go to this appp and press button start then it will start record? Is which folder it put my file? – Bhanu Sharma Sep 01 '17 at 07:20
  • You need to save buffer in sdcard, In your case it will keep the recorded file in the ram as buffer data. You need to put that native file in your call recorder app, and start recorder when call triggered. – Bharath Kumar Sep 01 '17 at 07:31
  • Have you been able to solve that ? – Paras Watts Sep 12 '17 at 04:38
  • Hi @BharathKumar I think we both are on same page, I just wanted to confirm whether you were able to fix this issue or not? – japanjot singh Oct 04 '17 at 12:12
  • @japanjotsingh No not found solution for this. – Bharath Kumar Oct 06 '17 at 04:51
  • Get involved in my project https://github.com/ViktorDegtyarev/CallRecLib Let's find a solution together! – Viktor Degtyarev Oct 19 '17 at 06:28

1 Answers1

-1

check documentation and set correct sampling rate, format and mask. Channel mask might be stereo or mono. I am not sure how you are getting status -22 error, but Realize error is very clear, as per documentation

SL_RESULT_CONTENT_UNSUPPORTED if a format is not supported (e.g. sample rate too high)

Look at NDK sample to clarify your parameter setup

Ketan
  • 1,017
  • 8
  • 17