Call recording gives empty .wav file when using via JNI

74 views
Skip to first unread message

anand prajapati

unread,
May 11, 2017, 3:31:03 AM5/11/17
to PJSIP experts
I want to record the call in a file using the Java API. I created audio media recorder as stated in the documentation and started transmission from the call's media to the recorder's media. I have been trying it since yesterday. Still I am getting an empty file every time. I used following snippet :-

public void startRecording(String filePath) {
AudioMedia callMedia = getAudioMedia();
try {
   // disconnect previous bridges before creating new one
stopAudioMediaFlow();

mediaRecorder = new AudioMediaRecorder();
mediaRecorder.createRecorder(filePath);
callMedia.startTransmit(mediaRecorder);
} catch (Exception exc) {
Logger.error("Error in recording audio ", exc);
}
}

Any help in this issue will be highly appreciated.

anand prajapati

unread,
May 11, 2017, 4:04:02 AM5/11/17
to PJSIP experts
I forgot to stop the recorder. Following did the trick.

public void stopRecording() {
try {
AudioMedia callMedia = getAudioMedia();
if (mediaRecorder != null) {
callMedia.stopTransmit(mediaRecorder);
// close the recorder
mediaRecorder.delete();
}
mediaRecorder = null;
} catch (Exception exc) {
Logger.error("Error in stopping recording.", exc);
}
}
Reply all
Reply to author
Forward
0 new messages