]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-7500: fix seg and clean up keyframe code
authorAnthony Minessale <anthm@freeswitch.org>
Fri, 21 Nov 2014 23:59:13 +0000 (18:59 -0500)
committerMichael Jerris <mike@jerris.com>
Thu, 28 May 2015 17:46:48 +0000 (12:46 -0500)
src/switch_core_media.c
src/switch_core_session.c

index 76d53470f6e809df61d8ba5bfe3fc9354a38b719..94d6eae804cfaa6fd2b06fdcee95d2127f11beea 100644 (file)
@@ -9517,8 +9517,17 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_codec_control(switch_core_sess
                codec = &engine->write_codec;
        }
 
-       if (cmd == SCC_VIDEO_REFRESH && mtype == SWITCH_MEDIA_TYPE_VIDEO) {
-               switch_core_session_refresh_video(session);
+       if (mtype == SWITCH_MEDIA_TYPE_VIDEO) {
+               if (!switch_channel_test_flag(session->channel, CF_VIDEO)) {
+                       return SWITCH_STATUS_FALSE;
+               }
+               
+               if (cmd == SCC_VIDEO_REFRESH) {
+                       switch_core_session_message_t msg = { 0 };
+                       msg.from = __FILE__;
+                       msg.message_id = SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ;
+                       switch_core_session_receive_message(session, &msg);
+               }
        }
 
        if (codec) {
@@ -9564,6 +9573,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_video_frame(switch_cor
        switch_media_handle_t *smh;
        switch_image_t *img = frame->img;
        switch_status_t encode_status;
+       switch_frame_t write_frame = {0};
 
        switch_assert(session);
 
@@ -9575,6 +9585,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_video_frame(switch_cor
                return SWITCH_STATUS_FALSE;
        }
 
+       if (!codec) {
+               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s has no video codec\n", switch_core_session_get_name(session));
+               return SWITCH_STATUS_FALSE;
+       }
+
        if (switch_channel_test_flag(session->channel, CF_VIDEO_PAUSE)) {
                return SWITCH_STATUS_SUCCESS;
        }
@@ -9598,6 +9613,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_video_frame(switch_cor
                return raw_write_video(session, frame, flags, stream_id);
        }
 
+       write_frame = *frame;
+       frame = &write_frame;
+
        if (!switch_test_flag(frame, SFF_USE_VIDEO_TIMESTAMP)) {
 
                if (!(timer = switch_core_media_get_timer(session, SWITCH_MEDIA_TYPE_VIDEO))) {
index e7a4fe369da9e9fbd466be5280f659545c1ac64c..f39f8899bc2e14d5d611ed17111c0afb17abaa9a 100644 (file)
@@ -3059,6 +3059,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_refresh_video(switch_core_se
                msg.from = __FILE__;
                msg.message_id = SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ;
                switch_core_session_receive_message(session, &msg);
+               switch_core_media_gen_key_frame(session);
                return SWITCH_STATUS_SUCCESS;
        }