Merge pull request #574 in FS/freeswitch from bugfix/FS-8154-segmentation-fault-occurs-while-eavesdropping to master
* commit 'b40454209ba0b9b91a9ce9927cff0cc96b0c0275': FS-8154 #resolve [Segmentation fault occurs while eavesdropping on video call]
This commit is contained in:
commit
f2e5f713ee
|
@ -220,6 +220,7 @@ struct switch_media_bug {
|
|||
uint32_t record_pre_buffer_count;
|
||||
uint32_t record_pre_buffer_max;
|
||||
switch_frame_t *ping_frame;
|
||||
switch_frame_t *video_ping_frame;
|
||||
switch_frame_t *read_demux_frame;
|
||||
switch_queue_t *read_video_queue;
|
||||
switch_queue_t *write_video_queue;
|
||||
|
|
|
@ -90,7 +90,7 @@ SWITCH_DECLARE(switch_core_session_t *) switch_core_media_bug_get_session(switch
|
|||
|
||||
SWITCH_DECLARE(switch_frame_t *) switch_core_media_bug_get_video_ping_frame(switch_media_bug_t *bug)
|
||||
{
|
||||
return bug->ping_frame;
|
||||
return bug->video_ping_frame;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_frame_t *) switch_core_media_bug_get_write_replace_frame(switch_media_bug_t *bug)
|
||||
|
@ -603,17 +603,15 @@ static void *SWITCH_THREAD_FUNC video_bug_thread(switch_thread_t *thread, void *
|
|||
}
|
||||
|
||||
switch_thread_rwlock_rdlock(bug->session->bug_rwlock);
|
||||
//switch_mutex_lock(bug->read_mutex);
|
||||
frame.img = other_q ? IMG : img;
|
||||
bug->ping_frame = &frame;
|
||||
bug->video_ping_frame = &frame;
|
||||
if (bug->callback) {
|
||||
if (bug->callback(bug, bug->user_data, SWITCH_ABC_TYPE_STREAM_VIDEO_PING) == SWITCH_FALSE
|
||||
|| (bug->stop_time && bug->stop_time <= switch_epoch_time_now(NULL))) {
|
||||
ok = SWITCH_FALSE;
|
||||
}
|
||||
}
|
||||
bug->ping_frame = NULL;
|
||||
//switch_mutex_unlock(bug->read_mutex);
|
||||
bug->video_ping_frame = NULL;
|
||||
switch_thread_rwlock_unlock(bug->session->bug_rwlock);
|
||||
|
||||
if (!ok) {
|
||||
|
@ -1021,14 +1019,14 @@ SWITCH_DECLARE(uint32_t) switch_core_media_bug_patch_video(switch_core_session_t
|
|||
for (bp = orig_session->bugs; bp; bp = bp->next) {
|
||||
if (!switch_test_flag(bp, SMBF_PRUNE) && !switch_test_flag(bp, SMBF_LOCK) && !strcmp(bp->function, "patch:video")) {
|
||||
if (bp->ready && frame->img && switch_test_flag(bp, SMBF_VIDEO_PATCH)) {
|
||||
bp->ping_frame = frame;
|
||||
bp->video_ping_frame = frame;
|
||||
if (bp->callback) {
|
||||
if (bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_VIDEO_PATCH) == SWITCH_FALSE
|
||||
|| (bp->stop_time && bp->stop_time <= switch_epoch_time_now(NULL))) {
|
||||
ok = SWITCH_FALSE;
|
||||
}
|
||||
}
|
||||
bp->ping_frame = NULL;
|
||||
bp->video_ping_frame = NULL;
|
||||
}
|
||||
|
||||
if (ok == SWITCH_FALSE) {
|
||||
|
|
|
@ -1481,9 +1481,10 @@ static switch_bool_t record_callback(switch_media_bug_t *bug, void *user_data, s
|
|||
case SWITCH_ABC_TYPE_READ_VIDEO_PING:
|
||||
case SWITCH_ABC_TYPE_STREAM_VIDEO_PING:
|
||||
if (rh->fh) {
|
||||
if (!bug->ping_frame) break;
|
||||
if (!bug->video_ping_frame) break;
|
||||
|
||||
if ((len || bug->ping_frame->img) && switch_core_file_write_video(rh->fh, bug->ping_frame) != SWITCH_STATUS_SUCCESS && rh->hangup_on_error) {
|
||||
if ((len || bug->video_ping_frame->img) && switch_core_file_write_video(rh->fh, bug->video_ping_frame) != SWITCH_STATUS_SUCCESS &&
|
||||
rh->hangup_on_error) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error writing video to %s\n", rh->file);
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
|
||||
|
@ -1716,12 +1717,12 @@ static switch_bool_t eavesdrop_callback(switch_media_bug_t *bug, void *user_data
|
|||
case SWITCH_ABC_TYPE_STREAM_VIDEO_PING:
|
||||
{
|
||||
|
||||
if (!bug->ping_frame || !bug->ping_frame->img) {
|
||||
if (!bug->video_ping_frame || !bug->video_ping_frame->img) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (ep->eavesdropper && switch_core_session_read_lock(ep->eavesdropper) == SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_core_session_write_video_frame(ep->eavesdropper, bug->ping_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_core_session_write_video_frame(ep->eavesdropper, bug->video_ping_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error writing video to %s\n", switch_core_session_get_name(ep->eavesdropper));
|
||||
ep->errs++;
|
||||
|
||||
|
|
Loading…
Reference in New Issue