Reputation: 626
I am developing a sip app with internal recording. I need the both side audios to be recorder internally in mobile itself.
Read several blogs and articles regarding the same. I know the only solution is using the NDK. After a great effort, I compiled and integrated pjsip/pjsua2 into my app with which client registrations and calls are working fine. But, could not record calls. I had tried pjsua's AudioMediaRecorder but since there in no proper documentation I did not understood anything.
@Override
public void onCallMediaState(OnCallMediaStateParam prm)
{
Log.i(TAG, "onCallMediaState: ");
CallInfo ci;
try {
ci = getInfo();
} catch (Exception e) {
return;
}
CallMediaInfoVector cmiv = ci.getMedia();
for (int i = 0; i < cmiv.size(); i++) {
CallMediaInfo cmi = cmiv.get(i);
if (cmi.getType() == pjmedia_type.PJMEDIA_TYPE_AUDIO && (cmi.getStatus() == pjsua_call_media_status.PJSUA_CALL_MEDIA_ACTIVE)) {
try {
am = getAudioMedia(i);
audioMediaRecorder.createRecorder("callaudio.wav");
am.startTransmit(audioMediaRecorder);
MyApp.ep.audDevManager().getCaptureDevMedia().
startTransmit(am);
am.startTransmit(MyApp.ep.audDevManager().
getPlaybackDevMedia());
} catch (Exception e) {
System.out.println("Failed connecting media ports" +
e.getMessage());
continue;
}
}
}
MyApp.observer.notifyCallMediaState(this);
}
where is this myaudiofile.wav file saved? How can I get it?
above code produces a log like this -
pjsua_media.c ...Call 1: updating media..
pjsua_media.c .....Media stream call01:0 is destroyed
pjsua_aud.c ....Audio channel update..
strm0x953fe014 .....VAD temporarily disabled
strm0x953fe014 .....Encoder stream started
strm0x953fe014 .....Decoder stream started
pjsua_media.c ....Audio updated, stream #0: PCMA (sendrecv)
MyCall: onCallMediaState:
pjsua_aud.c ...Creating recorder myfilename.wav..
pjsua_aud.c ....Unable to open file for recording: Read-only file system [status=120030]
media.cpp ...pjsua_recorder_create(&pj_name, enc_type, NULL, -1, options, &recorderId) error: Read-only file system (status=120030) [../src/pjsua2/media.cpp:443]
Failed connecting media portsTitle: pjsua_recorder_create(&pj_name, enc_type, NULL, -1, options, &recorderId)
Code: 120030
Description: Read-only file system
Location: ../src/pjsua2/media.cpp:443
15:52:01.458
pjsua_core.c ....TX 940 bytes Response msg 200/INVITE/cseq=1 (tdta0x96976064) to UDP 218.248.233.142:5060:
Upvotes: 3
Views: 1433
Reputation: 316
You should specify an exact folder & file for where to save you recording, something like this.
File root = Environment.getExternalStorageDirectory();
// Specify a directory for your recordings
File dir = new File(root.getAbsolutePath() + File.separator + "PJSIP-Recordings");
// Ensure that the directory exists
dir.mkdirs();
audioMediaRecorder.createRecorder(dir.getAbsolutePath() + File.separator + "callaudio.wav");
This will be saved in the root folder under the folder PJSIP-Recordings (You can change this to whatever you want).
Also, make sure you request Storage Permissions.
Upvotes: 2