当 pjmedia_conf_connect_port 在 pjsip 中执行 SIGABRT 时,录音通话崩溃
Crash in recording call, when pjmedia_conf_connect_port executed SIGABRT in pjsip
早些时候我使用 pjsip 2.7.1 时它工作正常。通话录音很完美。但现在我已经安装了 pjsip 2.9。它在 pjmedia_conf_connect_port 崩溃。 SIGABRT 因为 pjsua_var.mconf。我不知道它是什么时候在 pjsip 中分配的。请解释并帮助解决这个问题。
提前致谢
我试图在录制之前创建一个媒体会议。但它最终没有音频。
+(void)startRecordingForCalleeId:(NSString *)calleeId andCallId:(int)callid
{
NSLog(@"start recording...........");
Recording *sipRecording = [[SPCoreDataManager sharedManager]createBlankSipRecordingForCalleeId:calleeId];
NSString *filePath = [[SPFileManager sharedManager] pathForFile:sipRecording.fileName];
SPAppDelegate *appDelegate = (SPAppDelegate *)[[UIApplication sharedApplication] delegate];
appDelegate.objectID = sipRecording.objectID;
pj_str_t fileName = pj_str([filePath UTF8String]);
status = pjsua_recorder_create(&fileName, 0, NULL, -1, 0, &recorder_id);
NSLog(@"status issss-->%d",status);
[[NSUserDefaults standardUserDefaults] setInteger:recorder_id forKey:@"recording_id"];
[[NSUserDefaults standardUserDefaults] synchronize];
NSLog(@"recordder id id--->%d",recorder_id);
NSLog(@"recording is for start recording is--->%d",app_config.rec_id);
//status = pjsua_recorder_create(&fileName, 0, NULL, -1, 0, &app_config.rec_id);
if (status != PJ_SUCCESS)
{
pjsua_perror(__FILE__, "error dll_startAudioCapture from pjsua_recorder_create", status);
}
else
{
//app_config.rec_port = pjsua_recorder_get_conf_port(app_config.rec_id);
app_config.rec_port = pjsua_recorder_get_conf_port(recorder_id);
PJ_LOG(5, (__FILE__, "dll_startAudioCapture recId=%d confPort=%d", app_config.rec_id, app_config.rec_port));
pjmedia_conf_connect_port(pjsua_var.mconf, callid,app_config.rec_port, 0);//working for the 1st call
pjsua_call_get_info(callid, &call_info); //callid
pjsua_state state = pjsua_get_state();
if (state == PJSUA_STATE_NULL){
return;
}
pjmedia_conf_connect_port(pjsua_var.mconf, call_info.conf_slot,app_config.rec_port, 0); //working for the 1st call
pjsua_conf_connect(call_info.conf_slot, app_config.rec_port);
pjsua_conf_connect(0, app_config.rec_port);
if (status != PJ_SUCCESS)
{
pjsua_perror(__FILE__, "error dll_startAudioCapture edia_conf_connect_port snd->recport", status);
}
if (status != PJ_SUCCESS)
{
//pjsua_perror(THIS_FILE, @"error dll_startAudioCapture pjmedia_conf_connect_port caller->recport", status);
}
//boost callTaker's and caller audio levels as configured
if ((status = pjmedia_conf_adjust_rx_level(pjsua_var.mconf, pjsua_var.recorder[app_config.rec_id].slot,0)) == PJ_SUCCESS)
{
// PJ_LOG(5, (THIS_FILE, "dll_startAudioCapture pjmedia_conf_adjust_rx_level by %d", g_audCapClientBoost));
}
else
{
pjsua_perror(__FILE__, "Error dll_startAudioCapture pjmedia_conf_adjust_rx_level", status);
}
if ((status = pjmedia_conf_adjust_tx_level(pjsua_var.mconf,pjsua_var.recorder[app_config.rec_id].slot,0)) == PJ_SUCCESS)
{
// PJ_LOG(5, (THIS_FILE, "dll_startAudioCapture pjmedia_conf_adjust_tx_level by %d", g_audCapServerBoost));
}
else
{
pjsua_perror(__FILE__, "Error dll_startAudioCapture pjmedia_conf_adjust_tx_level", status);
}
hasRecordingStarted = 1;
}
}
请帮忙
if (ci.media_status == PJSUA_CALL_MEDIA_ACTIVE) {
userCall.hasConnected = true
pjsua_conf_connect(ci.conf_slot, 0)
pjsua_conf_connect(0, ci.conf_slot)
if recorderPortId != PJSUA_INVALID_ID.rawValue {
pjsua_conf_connect(ci.conf_slot, recorderPortId)
}
}
我们应该在连接声音端口后连接conf端口。即使您在创建记录器后连接端口,也请在此处连接它。您将获得清晰的录音。
我将我的 android Pjsip 调用重新编码代码供您参考,它可能会对您有所帮助。
public void record(String recordingCallerNumber) {
CallInfo ci;
try {
ci = currentCall.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 ||
cmi.getStatus() ==
pjsua_call_media_status.PJSUA_CALL_MEDIA_REMOTE_HOLD)) {
// connect ports
try {
File root = Environment.getExternalStorageDirectory();
File mainFolder = new File(root.getAbsolutePath() + File.separator + "call_record");
if (!(mainFolder.exists() || mainFolder.isDirectory())) {
mainFolder.mkdirs();
mainFolder.setExecutable(true);
mainFolder.setReadable(true);
mainFolder.setWritable(true);
MediaScannerConnection.scanFile(getApplicationContext(), new String[]{mainFolder.toString()}, null, null);
}
audioMediaRecorder = new AudioMediaRecorder();
am = currentCall.getAudioMedia(i);
audioMediaRecorder.createRecorder(mainFolder.getAbsolutePath() + File.separator + recordingCallerNumber + ".wav");
am.startTransmit(audioMediaRecorder);
MyApp.ep.audDevManager().getCaptureDevMedia().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());
}
}
}
}
我在 android 中也遇到过同样的问题,在 2.6 中,如果我们在连接时开始传输而不是它处理所有情况,但在 2.9 中,我们必须在从服务器,我在确认状态后开始传输,这就完成了,代码按照 exepactaion
工作
早些时候我使用 pjsip 2.7.1 时它工作正常。通话录音很完美。但现在我已经安装了 pjsip 2.9。它在 pjmedia_conf_connect_port 崩溃。 SIGABRT 因为 pjsua_var.mconf。我不知道它是什么时候在 pjsip 中分配的。请解释并帮助解决这个问题。
提前致谢
我试图在录制之前创建一个媒体会议。但它最终没有音频。
+(void)startRecordingForCalleeId:(NSString *)calleeId andCallId:(int)callid
{
NSLog(@"start recording...........");
Recording *sipRecording = [[SPCoreDataManager sharedManager]createBlankSipRecordingForCalleeId:calleeId];
NSString *filePath = [[SPFileManager sharedManager] pathForFile:sipRecording.fileName];
SPAppDelegate *appDelegate = (SPAppDelegate *)[[UIApplication sharedApplication] delegate];
appDelegate.objectID = sipRecording.objectID;
pj_str_t fileName = pj_str([filePath UTF8String]);
status = pjsua_recorder_create(&fileName, 0, NULL, -1, 0, &recorder_id);
NSLog(@"status issss-->%d",status);
[[NSUserDefaults standardUserDefaults] setInteger:recorder_id forKey:@"recording_id"];
[[NSUserDefaults standardUserDefaults] synchronize];
NSLog(@"recordder id id--->%d",recorder_id);
NSLog(@"recording is for start recording is--->%d",app_config.rec_id);
//status = pjsua_recorder_create(&fileName, 0, NULL, -1, 0, &app_config.rec_id);
if (status != PJ_SUCCESS)
{
pjsua_perror(__FILE__, "error dll_startAudioCapture from pjsua_recorder_create", status);
}
else
{
//app_config.rec_port = pjsua_recorder_get_conf_port(app_config.rec_id);
app_config.rec_port = pjsua_recorder_get_conf_port(recorder_id);
PJ_LOG(5, (__FILE__, "dll_startAudioCapture recId=%d confPort=%d", app_config.rec_id, app_config.rec_port));
pjmedia_conf_connect_port(pjsua_var.mconf, callid,app_config.rec_port, 0);//working for the 1st call
pjsua_call_get_info(callid, &call_info); //callid
pjsua_state state = pjsua_get_state();
if (state == PJSUA_STATE_NULL){
return;
}
pjmedia_conf_connect_port(pjsua_var.mconf, call_info.conf_slot,app_config.rec_port, 0); //working for the 1st call
pjsua_conf_connect(call_info.conf_slot, app_config.rec_port);
pjsua_conf_connect(0, app_config.rec_port);
if (status != PJ_SUCCESS)
{
pjsua_perror(__FILE__, "error dll_startAudioCapture edia_conf_connect_port snd->recport", status);
}
if (status != PJ_SUCCESS)
{
//pjsua_perror(THIS_FILE, @"error dll_startAudioCapture pjmedia_conf_connect_port caller->recport", status);
}
//boost callTaker's and caller audio levels as configured
if ((status = pjmedia_conf_adjust_rx_level(pjsua_var.mconf, pjsua_var.recorder[app_config.rec_id].slot,0)) == PJ_SUCCESS)
{
// PJ_LOG(5, (THIS_FILE, "dll_startAudioCapture pjmedia_conf_adjust_rx_level by %d", g_audCapClientBoost));
}
else
{
pjsua_perror(__FILE__, "Error dll_startAudioCapture pjmedia_conf_adjust_rx_level", status);
}
if ((status = pjmedia_conf_adjust_tx_level(pjsua_var.mconf,pjsua_var.recorder[app_config.rec_id].slot,0)) == PJ_SUCCESS)
{
// PJ_LOG(5, (THIS_FILE, "dll_startAudioCapture pjmedia_conf_adjust_tx_level by %d", g_audCapServerBoost));
}
else
{
pjsua_perror(__FILE__, "Error dll_startAudioCapture pjmedia_conf_adjust_tx_level", status);
}
hasRecordingStarted = 1;
}
}
请帮忙
if (ci.media_status == PJSUA_CALL_MEDIA_ACTIVE) {
userCall.hasConnected = true
pjsua_conf_connect(ci.conf_slot, 0)
pjsua_conf_connect(0, ci.conf_slot)
if recorderPortId != PJSUA_INVALID_ID.rawValue {
pjsua_conf_connect(ci.conf_slot, recorderPortId)
}
}
我们应该在连接声音端口后连接conf端口。即使您在创建记录器后连接端口,也请在此处连接它。您将获得清晰的录音。
我将我的 android Pjsip 调用重新编码代码供您参考,它可能会对您有所帮助。
public void record(String recordingCallerNumber) {
CallInfo ci;
try {
ci = currentCall.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 ||
cmi.getStatus() ==
pjsua_call_media_status.PJSUA_CALL_MEDIA_REMOTE_HOLD)) {
// connect ports
try {
File root = Environment.getExternalStorageDirectory();
File mainFolder = new File(root.getAbsolutePath() + File.separator + "call_record");
if (!(mainFolder.exists() || mainFolder.isDirectory())) {
mainFolder.mkdirs();
mainFolder.setExecutable(true);
mainFolder.setReadable(true);
mainFolder.setWritable(true);
MediaScannerConnection.scanFile(getApplicationContext(), new String[]{mainFolder.toString()}, null, null);
}
audioMediaRecorder = new AudioMediaRecorder();
am = currentCall.getAudioMedia(i);
audioMediaRecorder.createRecorder(mainFolder.getAbsolutePath() + File.separator + recordingCallerNumber + ".wav");
am.startTransmit(audioMediaRecorder);
MyApp.ep.audDevManager().getCaptureDevMedia().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());
}
}
}
}
我在 android 中也遇到过同样的问题,在 2.6 中,如果我们在连接时开始传输而不是它处理所有情况,但在 2.9 中,我们必须在从服务器,我在确认状态后开始传输,这就完成了,代码按照 exepactaion
工作