From: Anthony Minessale Date: Fri, 21 Nov 2014 23:59:13 +0000 (-0500) Subject: FS-7500: fix seg and clean up keyframe code X-Git-Tag: v1.6.2~614^2~559 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b8577d0ce94a70f30474b7244e0b5e517e135bb8;p=thirdparty%2Ffreeswitch.git FS-7500: fix seg and clean up keyframe code --- diff --git a/src/switch_core_media.c b/src/switch_core_media.c index 76d53470f6..94d6eae804 100644 --- a/src/switch_core_media.c +++ b/src/switch_core_media.c @@ -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))) { diff --git a/src/switch_core_session.c b/src/switch_core_session.c index e7a4fe369d..f39f8899bc 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -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; }