From db7b27317ade42b7bcc2afc5b910a0986742dd41 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 21 Apr 2017 16:15:53 -0500 Subject: [PATCH] FS-10259: [freeswitch-core,mod_commands,mod_conference] Allow uuid_video_bitrate to supersede bitrate control from the conference #resolve --- .../applications/mod_commands/mod_commands.c | 22 ++++++++++++++++++- src/switch_jitterbuffer.c | 4 ++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index 29febefc53..77d4120d56 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -4202,6 +4202,10 @@ SWITCH_STANDARD_API(uuid_video_refresh_function) return SWITCH_STATUS_SUCCESS; } +typedef enum { + BITRATE_INUSE = (1 << 0) +} uuid_video_bitrate_enum_t; + #define VIDEO_BITRATE_SYNTAX " " SWITCH_STANDARD_API(uuid_video_bitrate_function) { @@ -4219,13 +4223,29 @@ SWITCH_STANDARD_API(uuid_video_bitrate_function) switch_core_session_t *lsession = NULL; if ((lsession = switch_core_session_locate(argv[0]))) { - int kps = switch_parse_bandwidth_string(argv[1]); + int kps; switch_core_session_message_t msg = { 0 }; + switch_channel_t *channel = switch_core_session_get_channel(lsession); + + if (argv[1] && !strcasecmp(argv[1], "clear")) { + if (switch_channel_test_app_flag_key("uuid_video_bitrate", channel, BITRATE_INUSE)) { + switch_channel_clear_flag_recursive(channel, CF_VIDEO_BITRATE_UNMANAGABLE); + switch_channel_clear_app_flag_key("uuid_video_bitrate", channel, BITRATE_INUSE); + } + } + + + kps = switch_parse_bandwidth_string(argv[1]); msg.message_id = SWITCH_MESSAGE_INDICATE_BITRATE_REQ; msg.numeric_arg = kps * 1024; msg.from = __FILE__; + if (!switch_channel_test_app_flag_key("uuid_video_bitrate", channel, BITRATE_INUSE)) { + switch_channel_set_app_flag_key("uuid_video_bitrate", channel, BITRATE_INUSE); + switch_channel_set_flag_recursive(channel, CF_VIDEO_BITRATE_UNMANAGABLE); + } + switch_core_session_receive_message(lsession, &msg); switch_core_session_video_reinit(lsession); switch_channel_video_sync(switch_core_session_get_channel(lsession)); diff --git a/src/switch_jitterbuffer.c b/src/switch_jitterbuffer.c index 9e37a5f99a..bc927fd916 100644 --- a/src/switch_jitterbuffer.c +++ b/src/switch_jitterbuffer.c @@ -1325,7 +1325,7 @@ SWITCH_DECLARE(switch_status_t) switch_jb_get_packet(switch_jb_t *jb, switch_rtp if (switch_channel_test_flag(jb->channel, CF_VIDEO_BITRATE_UNMANAGABLE) && jb->frame_len == jb->min_frame_len) { jb_debug(jb, 2, "%s", "Allow BITRATE changes\n"); - switch_channel_clear_flag(jb->channel, CF_VIDEO_BITRATE_UNMANAGABLE); + switch_channel_clear_flag_recursive(jb->channel, CF_VIDEO_BITRATE_UNMANAGABLE); jb->bitrate_control = 0; if (jb->session) { switch_core_session_request_video_refresh(jb->session); @@ -1342,7 +1342,7 @@ SWITCH_DECLARE(switch_status_t) switch_jb_get_packet(switch_jb_t *jb, switch_rtp jb_debug(jb, 2, "Force BITRATE to %d\n", jb->bitrate_control); switch_core_session_receive_message(jb->session, &msg); - switch_channel_set_flag(jb->channel, CF_VIDEO_BITRATE_UNMANAGABLE); + switch_channel_set_flag_recursive(jb->channel, CF_VIDEO_BITRATE_UNMANAGABLE); if (jb->session) { switch_core_session_request_video_refresh(jb->session); }