diff --git a/src/mod/applications/mod_conference/conference_api.c b/src/mod/applications/mod_conference/conference_api.c index 93ca89baa9..72422436fc 100644 --- a/src/mod/applications/mod_conference/conference_api.c +++ b/src/mod/applications/mod_conference/conference_api.c @@ -103,7 +103,8 @@ api_command_t conference_api_sub_commands[] = { {"vid-write-png", (void_fn_t) & conference_api_sub_write_png, CONF_API_SUB_ARGS_SPLIT, "vid-write-png", ""}, {"vid-fps", (void_fn_t) & conference_api_sub_vid_fps, CONF_API_SUB_ARGS_SPLIT, "vid-fps", ""}, {"vid-bgimg", (void_fn_t) & conference_api_sub_canvas_bgimg, CONF_API_SUB_ARGS_SPLIT, "vid-bgimg", " | clear []"}, - {"vid-bandwidth", (void_fn_t) & conference_api_sub_vid_bandwidth, CONF_API_SUB_ARGS_SPLIT, "vid-bandwidth", ""} + {"vid-bandwidth", (void_fn_t) & conference_api_sub_vid_bandwidth, CONF_API_SUB_ARGS_SPLIT, "vid-bandwidth", ""}, + {"vid-personal", (void_fn_t) & conference_api_sub_vid_personal, CONF_API_SUB_ARGS_SPLIT, "vid-personal", "[on|off]"} }; switch_status_t conference_api_sub_pause_play(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv) @@ -1000,6 +1001,29 @@ switch_status_t conference_api_sub_volume_out(conference_member_t *member, switc return SWITCH_STATUS_SUCCESS; } +switch_status_t conference_api_sub_vid_personal(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv) +{ + int on = 0; + + if (!conference->canvases[0]) { + stream->write_function(stream, "-ERR conference is not in mixing mode\n"); + return SWITCH_STATUS_SUCCESS; + } + + if (argv[2]) { + on = switch_true(argv[2]); + if (on) { + conference_utils_set_flag(conference, CFLAG_PERSONAL_CANVAS); + } else { + conference_utils_clear_flag(conference, CFLAG_PERSONAL_CANVAS); + } + } + + stream->write_function(stream, "+OK personal is %s\n", on ? "on" : "off"); + + return SWITCH_STATUS_SUCCESS; +} + switch_status_t conference_api_sub_vid_bandwidth(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv) { uint32_t i; diff --git a/src/mod/applications/mod_conference/conference_member.c b/src/mod/applications/mod_conference/conference_member.c index 36344a815d..9f3fd8a89f 100644 --- a/src/mod/applications/mod_conference/conference_member.c +++ b/src/mod/applications/mod_conference/conference_member.c @@ -708,15 +708,6 @@ switch_status_t conference_member_add(conference_obj_t *conference, conference_m switch_queue_create(&member->dtmf_queue, 100, member->pool); - if (conference_utils_test_flag(conference, CFLAG_PERSONAL_CANVAS)) { - video_layout_t *vlayout = NULL; - - if ((vlayout = conference_video_get_layout(conference, conference->video_layout_name, conference->video_layout_group))) { - conference_video_init_canvas(conference, vlayout, &member->canvas); - conference_video_init_canvas_layers(conference, member->canvas, vlayout); - } - } - conference->members = member; conference_utils_member_set_flag_locked(member, MFLAG_INTREE); switch_mutex_unlock(conference->member_mutex); diff --git a/src/mod/applications/mod_conference/conference_utils.c b/src/mod/applications/mod_conference/conference_utils.c index b28fedf6d3..274b499e44 100644 --- a/src/mod/applications/mod_conference/conference_utils.c +++ b/src/mod/applications/mod_conference/conference_utils.c @@ -193,6 +193,8 @@ void conference_utils_set_cflags(const char *flags, conference_flag_t *f) f[CFLAG_VIDEO_BRIDGE_FIRST_TWO] = 1; } else if (!strcasecmp(argv[i], "video-required-for-canvas")) { f[CFLAG_VIDEO_REQUIRED_FOR_CANVAS] = 1; + } else if (!strcasecmp(argv[i], "video-mute-exit-canvas")) { + f[CFLAG_VIDEO_MUTE_EXIT_CANVAS] = 1; } else if (!strcasecmp(argv[i], "manage-inbound-video-bitrate")) { f[CFLAG_MANAGE_INBOUND_VIDEO_BITRATE] = 1; } else if (!strcasecmp(argv[i], "video-muxing-personal-canvas")) { diff --git a/src/mod/applications/mod_conference/conference_video.c b/src/mod/applications/mod_conference/conference_video.c index 45ca7c41c7..8bcc57ef0b 100644 --- a/src/mod/applications/mod_conference/conference_video.c +++ b/src/mod/applications/mod_conference/conference_video.c @@ -649,6 +649,7 @@ void conference_video_detach_video_layer(conference_member_t *member) member->avatar_patched = 0; conference_video_check_used_layers(canvas); canvas->send_keyframe = 1; + member->managed_kps = 0; if (conference_utils_test_flag(member->conference, CFLAG_JSON_STATUS)) { conference_member_update_status_field(member); @@ -876,7 +877,6 @@ void conference_video_layer_set_banner(conference_member_t *member, mcu_layer_t void conference_video_reset_video_bitrate_counters(conference_member_t *member) { - member->managed_kps = 0; member->blackouts = 0; member->good_img = 0; member->blanks = 0; @@ -893,6 +893,11 @@ switch_status_t conference_video_attach_video_layer(conference_member_t *member, channel = switch_core_session_get_channel(member->session); + if (conference_utils_test_flag(member->conference, CFLAG_VIDEO_MUTE_EXIT_CANVAS) && + !conference_utils_member_test_flag(member, MFLAG_CAN_BE_SEEN)) { + return SWITCH_STATUS_FALSE; + } + if (!switch_channel_test_flag(channel, CF_VIDEO_READY) && !member->avatar_png_img) { return SWITCH_STATUS_FALSE; @@ -972,6 +977,7 @@ switch_status_t conference_video_attach_video_layer(conference_member_t *member, switch_img_fill(canvas->img, layer->x_pos, layer->y_pos, layer->screen_w, layer->screen_h, &canvas->letterbox_bgcolor); conference_video_reset_video_bitrate_counters(member); + member->managed_kps = 0; if (conference_utils_test_flag(member->conference, CFLAG_JSON_STATUS)) { conference_member_update_status_field(member); @@ -1724,6 +1730,11 @@ switch_status_t conference_video_find_layer(conference_obj_t *conference, mcu_ca mcu_layer_t *layer = NULL; int i; + if (conference_utils_test_flag(conference, CFLAG_VIDEO_MUTE_EXIT_CANVAS) && + !conference_utils_member_test_flag(member, MFLAG_CAN_BE_SEEN)) { + return SWITCH_STATUS_FALSE; + } + switch_mutex_lock(canvas->mutex); for (i = 0; i < canvas->total_layers; i++) { @@ -2044,6 +2055,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr int last_file_count = 0; int layout_applied = 0; int files_playing = 0; + int last_personal = conference_utils_test_flag(conference, CFLAG_PERSONAL_CANVAS) ? 1 : 0; canvas->video_timer_reset = 1; @@ -2057,9 +2069,9 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr int file_count = 0, check_async_file = 0, check_file = 0; switch_image_t *async_file_img = NULL, *normal_file_img = NULL, *file_imgs[2] = { 0 }; switch_frame_t file_frame = { 0 }; - int j = 0; - - if (!conference_utils_test_flag(conference, CFLAG_PERSONAL_CANVAS)) { + int j = 0, personal = conference_utils_test_flag(conference, CFLAG_PERSONAL_CANVAS) ? 1 : 0; + + if (!personal) { switch_mutex_lock(canvas->mutex); if (canvas->new_vlayout) { conference_video_init_canvas_layers(conference, canvas, NULL); @@ -2083,6 +2095,17 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr now = switch_micro_time_now(); + if (last_personal != personal) { + do_refresh = 100; + count_changed = 1; + if ((last_personal = personal)) { + switch_mutex_lock(conference->member_mutex); + conference->new_personal_vlayout = canvas->vlayout; + switch_mutex_unlock(conference->member_mutex); + } + conference_utils_set_flag(conference, CFLAG_REFRESH_LAYOUT); + } + if (members_with_video != conference->members_with_video) { do_refresh = 100; count_changed = 1; @@ -2092,15 +2115,19 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr count_changed = 1; } - if (count_changed && !conference_utils_test_flag(conference, CFLAG_PERSONAL_CANVAS)) { + if (count_changed && !personal) { layout_group_t *lg = NULL; video_layout_t *vlayout = NULL; int canvas_count = 0; - + switch_mutex_lock(conference->member_mutex); for (imember = conference->members; imember; imember = imember->next) { + int no_muted = conference_utils_test_flag(imember->conference, CFLAG_VIDEO_MUTE_EXIT_CANVAS); + int no_av = conference_utils_test_flag(imember->conference, CFLAG_VIDEO_REQUIRED_FOR_CANVAS); + int seen = conference_utils_member_test_flag(imember, MFLAG_CAN_BE_SEEN); + if (imember->channel && switch_channel_ready(imember->channel) && switch_channel_test_flag(imember->channel, CF_VIDEO_READY) && - conference_utils_member_test_flag(imember, MFLAG_RUNNING) + conference_utils_member_test_flag(imember, MFLAG_RUNNING) && (!no_muted || seen) && (!no_av || imember->avatar_png_img) && imember->canvas_id == canvas->canvas_id && imember->video_media_flow != SWITCH_MEDIA_FLOW_SENDONLY) { canvas_count++; } @@ -2174,7 +2201,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr int i; if (!imember->session || (!switch_channel_test_flag(imember->channel, CF_VIDEO_READY) && !imember->avatar_png_img) || - conference_utils_test_flag(conference, CFLAG_PERSONAL_CANVAS) || switch_core_session_read_lock(imember->session) != SWITCH_STATUS_SUCCESS) { + personal || switch_core_session_read_lock(imember->session) != SWITCH_STATUS_SUCCESS) { continue; } @@ -2233,6 +2260,21 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr continue; } + if (conference_utils_test_flag(imember->conference, CFLAG_VIDEO_MUTE_EXIT_CANVAS) && + !conference_utils_member_test_flag(imember, MFLAG_CAN_BE_SEEN) && imember->video_layer_id > -1) { + conference_video_detach_video_layer(imember); + switch_img_free(&imember->video_mute_img); + + if (imember->id == imember->conference->video_floor_holder) { + conference_video_set_floor_holder(conference, NULL, SWITCH_FALSE); + } else if (imember->id == imember->conference->last_video_floor_holder) { + conference->last_video_floor_holder = 0; + } + + switch_core_session_rwunlock(imember->session); + continue; + } + //VIDFLOOR if (canvas->layout_floor_id > -1 && imember->id == conference->video_floor_holder && imember->video_layer_id != canvas->layout_floor_id) { @@ -2249,8 +2291,6 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr continue; } - - switch_mutex_lock(canvas->mutex); //printf("MEMBER %d layer_id %d canvas: %d/%d\n", imember->id, imember->video_layer_id, @@ -2299,7 +2339,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr // switch_img_free(&layer->cur_img); //} - if (conference_utils_member_test_flag(imember, MFLAG_CAN_BE_SEEN)) { + if (conference_utils_member_test_flag(imember, MFLAG_CAN_BE_SEEN) || switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_SENDONLY || conference_utils_test_flag(imember->conference, CFLAG_VIDEO_MUTE_EXIT_CANVAS)) { layer->mute_patched = 0; } else { switch_image_t *tmp; @@ -2369,7 +2409,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr switch_mutex_unlock(conference->member_mutex); - if (conference_utils_test_flag(conference, CFLAG_PERSONAL_CANVAS)) { + if (personal) { layout_group_t *lg = NULL; video_layout_t *vlayout = NULL; conference_member_t *omember; @@ -2397,6 +2437,13 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr conference_video_init_canvas_layers(conference, imember->canvas, conference->new_personal_vlayout); layout_applied++; } + + if (!imember->canvas) { + if ((vlayout = conference_video_get_layout(conference, conference->video_layout_name, conference->video_layout_group))) { + conference_video_init_canvas(conference, vlayout, &imember->canvas); + conference_video_init_canvas_layers(conference, imember->canvas, vlayout); + } + } if (switch_channel_test_flag(imember->channel, CF_VIDEO_REFRESH_REQ)) { switch_channel_clear_flag(imember->channel, CF_VIDEO_REFRESH_REQ); diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index 4ba5a23f51..ff5e57b348 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -279,7 +279,7 @@ void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, void *ob } } - if (switch_channel_ready(channel) && switch_channel_test_flag(channel, CF_VIDEO) && imember->video_media_flow != SWITCH_MEDIA_FLOW_SENDONLY) { + if (switch_channel_ready(channel) && switch_channel_test_flag(channel, CF_VIDEO_READY) && imember->video_media_flow != SWITCH_MEDIA_FLOW_SENDONLY && (!conference_utils_test_flag(conference, CFLAG_VIDEO_MUTE_EXIT_CANVAS) || conference_utils_member_test_flag(imember, MFLAG_CAN_BE_SEEN))) { members_with_video++; } diff --git a/src/mod/applications/mod_conference/mod_conference.h b/src/mod/applications/mod_conference/mod_conference.h index 7c9793686b..9f0473b30e 100644 --- a/src/mod/applications/mod_conference/mod_conference.h +++ b/src/mod/applications/mod_conference/mod_conference.h @@ -246,6 +246,7 @@ typedef enum { CFLAG_VIDEO_REQUIRED_FOR_CANVAS, CFLAG_PERSONAL_CANVAS, CFLAG_REFRESH_LAYOUT, + CFLAG_VIDEO_MUTE_EXIT_CANVAS, ///////////////////////////////// CFLAG_MAX } conference_flag_t; @@ -1088,6 +1089,7 @@ switch_status_t conference_api_sub_transfer(conference_obj_t *conference, switch switch_status_t conference_api_sub_record(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv); switch_status_t conference_api_sub_norecord(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv); switch_status_t conference_api_sub_vid_bandwidth(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv); +switch_status_t conference_api_sub_vid_personal(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv); switch_status_t conference_api_dispatch(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv, const char *cmdline, int argn); switch_status_t conference_api_sub_syntax(char **syntax); switch_status_t conference_api_main_real(const char *cmd, switch_core_session_t *session, switch_stream_handle_t *stream); diff --git a/src/mod/applications/mod_http_cache/mod_http_cache.c b/src/mod/applications/mod_http_cache/mod_http_cache.c index 60ed37dd25..30e588a102 100644 --- a/src/mod/applications/mod_http_cache/mod_http_cache.c +++ b/src/mod/applications/mod_http_cache/mod_http_cache.c @@ -675,7 +675,7 @@ static char *url_cache_get(url_cache_t *cache, http_profile_t *profile, switch_c switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Failed to download URL %s\n", url); cache->errors++; } - } else if (!u) { + } else if (!u || (u->status == CACHED_URL_RX_IN_PROGRESS && !download)) { filename = DOWNLOAD_NEEDED; } else { /* Wait until file is downloaded */ diff --git a/src/switch_channel.c b/src/switch_channel.c index a62a39a388..1b8f1e894e 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -1858,7 +1858,7 @@ SWITCH_DECLARE(void) switch_channel_set_flag_value(switch_channel_t *channel, sw switch_core_session_start_video_thread(channel->session); } - if (flag == CF_VIDEO_DECODED_READ) { + if (flag == CF_VIDEO_DECODED_READ && channel->flags[CF_VIDEO]) { switch_core_session_request_video_refresh(channel->session); if (!switch_core_session_in_video_thread(channel->session)) { switch_channel_wait_for_flag(channel, CF_VIDEO_READY, SWITCH_TRUE, 10000, NULL);