]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-8154 #resolve [Segmentation fault occurs while eavesdropping on video call]
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 29 Oct 2015 19:50:55 +0000 (14:50 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 29 Oct 2015 20:30:59 +0000 (15:30 -0500)
src/include/private/switch_core_pvt.h
src/switch_core_media_bug.c
src/switch_ivr_async.c

index 6b4699407534760025c11e6af3fc5c54ef6a8047..4204fcd0d5612d646b1c807825857c484595b6c2 100644 (file)
@@ -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;
index 3a02f2f441cfcbed83cc5aa3868ce8397d3c1474..6a2363f051c3a1d4829957d10200864b2d23d27c 100644 (file)
@@ -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) {
index 09e225aef415caeef98d3751a0b5c9dcc7147284..eaf68ec63692c35e7b72b9584a1ecd66eeef9afe 100644 (file)
@@ -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++;