FS-9144 #resolve [Implement video-mute-exit-canvas and recording in personal-canvas mode.]

This commit is contained in:
Anthony Minessale 2016-05-20 11:12:08 -05:00 committed by Michael Jerris
parent 3910dab95a
commit 718142bb12
3 changed files with 77 additions and 59 deletions

View File

@ -1079,10 +1079,6 @@ switch_status_t conference_api_sub_vid_personal(conference_obj_t *conference, sw
if (argv[2]) { if (argv[2]) {
on = switch_true(argv[2]); on = switch_true(argv[2]);
if (on) { if (on) {
if (conference->record_count > 0) {
stream->write_function(stream, "-ERR conference is recording, not enabling vid-personal.\n");
return SWITCH_STATUS_SUCCESS;
}
conference_utils_set_flag(conference, CFLAG_PERSONAL_CANVAS); conference_utils_set_flag(conference, CFLAG_PERSONAL_CANVAS);
} else { } else {
conference_utils_clear_flag(conference, CFLAG_PERSONAL_CANVAS); conference_utils_clear_flag(conference, CFLAG_PERSONAL_CANVAS);
@ -2515,11 +2511,6 @@ switch_status_t conference_api_sub_record(conference_obj_t *conference, switch_s
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
if (conference_utils_test_flag(conference, CFLAG_PERSONAL_CANVAS)) {
stream->write_function(stream, "-ERR Personal Canvas enabled, recording not permitted.\n");
return SWITCH_STATUS_SUCCESS;
}
if (argv[3]) { if (argv[3]) {
if (argv[3]) { if (argv[3]) {

View File

@ -65,11 +65,6 @@ void conference_record_launch_thread(conference_obj_t *conference, char *path, i
return; return;
} }
if (conference_utils_test_flag(conference, CFLAG_PERSONAL_CANVAS)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Personal Canvas enabled, recording not permitted.\n");
return;
}
rec->conference = conference; rec->conference = conference;
rec->path = switch_core_strdup(pool, path); rec->path = switch_core_strdup(pool, path);
rec->pool = pool; rec->pool = pool;
@ -235,9 +230,10 @@ void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *thread, v
flags = SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT; flags = SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT;
if (conference_utils_test_flag(conference, CFLAG_TRANSCODE_VIDEO)) { if (conference_utils_test_flag(conference, CFLAG_TRANSCODE_VIDEO)) {
char *orig_path = rec->path;
flags |= SWITCH_FILE_FLAG_VIDEO; flags |= SWITCH_FILE_FLAG_VIDEO;
if (canvas) { if (canvas) {
char *orig_path = rec->path;
rec->path = switch_core_sprintf(rec->pool, "{channels=%d,samplerate=%d,vw=%d,vh=%d,fps=%0.2f}%s", rec->path = switch_core_sprintf(rec->pool, "{channels=%d,samplerate=%d,vw=%d,vh=%d,fps=%0.2f}%s",
conference->channels, conference->channels,
conference->rate, conference->rate,
@ -245,9 +241,18 @@ void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *thread, v
canvas->height, canvas->height,
conference->video_fps.fps, conference->video_fps.fps,
orig_path); orig_path);
} else {
rec->path = switch_core_sprintf(rec->pool, "{channels=%d,samplerate=%d,vw=%d,vh=%d,fps=%0.2f}%s",
conference->channels,
conference->rate,
conference->canvas_width,
conference->canvas_height,
conference->video_fps.fps,
orig_path);
} }
} }
if (switch_core_file_open(&member->rec->fh, rec->path, (uint8_t) conference->channels, conference->rate, flags, rec->pool) != SWITCH_STATUS_SUCCESS) { if (switch_core_file_open(&member->rec->fh, rec->path, (uint8_t) conference->channels, conference->rate, flags, rec->pool) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening File [%s]\n", rec->path); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening File [%s]\n", rec->path);
@ -390,6 +395,7 @@ void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *thread, v
switch_mutex_unlock(conference->mutex); switch_mutex_unlock(conference->mutex);
switch_core_file_close(&member->rec->fh); switch_core_file_close(&member->rec->fh);
} }
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Recording of %s Stopped\n", rec->path); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Recording of %s Stopped\n", rec->path);
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) { if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
conference_event_add_data(conference, event); conference_event_add_data(conference, event);

View File

@ -1613,8 +1613,8 @@ void conference_video_check_recording(conference_obj_t *conference, mcu_canvas_t
if (!imember->rec) { if (!imember->rec) {
continue; continue;
} }
if (canvas && imember->canvas_id != canvas->canvas_id) { if (!conference_utils_test_flag(conference, CFLAG_PERSONAL_CANVAS) && canvas && imember->canvas_id != canvas->canvas_id) {
continue; continue;
} }
@ -2123,16 +2123,18 @@ static void personal_attach(mcu_layer_t *layer, conference_member_t *member)
conference_api_sub_position(member, NULL, layer->geometry.audio_position); conference_api_sub_position(member, NULL, layer->geometry.audio_position);
} }
var = NULL; if (member->channel) {
if (member->video_banner_text || var = NULL;
(var = switch_channel_get_variable_dup(member->channel, "video_banner_text", SWITCH_FALSE, -1))) { if (member->video_banner_text ||
conference_video_layer_set_banner(member, layer, var); (var = switch_channel_get_variable_dup(member->channel, "video_banner_text", SWITCH_FALSE, -1))) {
} conference_video_layer_set_banner(member, layer, var);
}
var = NULL;
if (member->video_logo || var = NULL;
(var = switch_channel_get_variable_dup(member->channel, "video_logo_path", SWITCH_FALSE, -1))) { if (member->video_logo ||
conference_video_layer_set_logo(member, layer, var); (var = switch_channel_get_variable_dup(member->channel, "video_logo_path", SWITCH_FALSE, -1))) {
conference_video_layer_set_logo(member, layer, var);
}
} }
} }
@ -2163,6 +2165,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
int layout_applied = 0; int layout_applied = 0;
int files_playing = 0; int files_playing = 0;
int last_personal = conference_utils_test_flag(conference, CFLAG_PERSONAL_CANVAS) ? 1 : 0; int last_personal = conference_utils_test_flag(conference, CFLAG_PERSONAL_CANVAS) ? 1 : 0;
int last_video_count = 0;
canvas->video_timer_reset = 1; canvas->video_timer_reset = 1;
canvas->video_layout_group = conference->video_layout_group; canvas->video_layout_group = conference->video_layout_group;
@ -2230,11 +2233,12 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
} }
if (video_count != canvas->video_count) {
if (video_count != canvas->video_count || video_count != last_video_count) {
count_changed = 1; count_changed = 1;
} }
canvas->video_count = video_count; canvas->video_count = last_video_count = video_count;
switch_mutex_unlock(conference->member_mutex); switch_mutex_unlock(conference->member_mutex);
switch_core_timer_next(&canvas->timer); switch_core_timer_next(&canvas->timer);
@ -2562,7 +2566,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
layout_group_t *lg = NULL; layout_group_t *lg = NULL;
video_layout_t *vlayout = NULL; video_layout_t *vlayout = NULL;
conference_member_t *omember; conference_member_t *omember;
if (video_key_freq && (now - last_key_time) > video_key_freq) { if (video_key_freq && (now - last_key_time) > video_key_freq) {
send_keyframe = SWITCH_TRUE; send_keyframe = SWITCH_TRUE;
last_key_time = now; last_key_time = now;
@ -2571,9 +2575,10 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
switch_mutex_lock(conference->member_mutex); switch_mutex_lock(conference->member_mutex);
for (imember = conference->members; imember; imember = imember->next) { for (imember = conference->members; imember; imember = imember->next) {
if (!imember->session || !switch_channel_test_flag(imember->channel, CF_VIDEO_READY) || if (!imember->rec &&
switch_core_session_read_lock(imember->session) != SWITCH_STATUS_SUCCESS) { (!imember->session || !switch_channel_test_flag(imember->channel, CF_VIDEO_READY) ||
switch_core_session_read_lock(imember->session) != SWITCH_STATUS_SUCCESS)) {
continue; continue;
} }
@ -2591,13 +2596,13 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
layout_applied++; layout_applied++;
} }
if (switch_channel_test_flag(imember->channel, CF_VIDEO_REFRESH_REQ)) { if (imember->channel && switch_channel_test_flag(imember->channel, CF_VIDEO_REFRESH_REQ)) {
switch_channel_clear_flag(imember->channel, CF_VIDEO_REFRESH_REQ); switch_channel_clear_flag(imember->channel, CF_VIDEO_REFRESH_REQ);
send_keyframe = SWITCH_TRUE; send_keyframe = SWITCH_TRUE;
} }
if (count_changed) { if (count_changed) {
int total = conference->members_with_video; int total = last_video_count;
int kps; int kps;
switch_vid_params_t vid_params = { 0 }; switch_vid_params_t vid_params = { 0 };
@ -2605,7 +2610,10 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
total += conference->members_with_avatar; total += conference->members_with_avatar;
} }
if (switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_SENDONLY) { if (total > 0 &&
(!conference_utils_test_flag(imember->conference, CFLAG_VIDEO_MUTE_EXIT_CANVAS) ||
conference_utils_member_test_flag(imember, MFLAG_CAN_BE_SEEN)) &&
imember->session && switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_SENDONLY) {
total--; total--;
} }
@ -2621,7 +2629,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
} }
} }
if (!switch_channel_test_flag(imember->channel, CF_VIDEO_BITRATE_UNMANAGABLE) && if (imember->channel && !switch_channel_test_flag(imember->channel, CF_VIDEO_BITRATE_UNMANAGABLE) &&
conference_utils_test_flag(conference, CFLAG_MANAGE_INBOUND_VIDEO_BITRATE)) { conference_utils_test_flag(conference, CFLAG_MANAGE_INBOUND_VIDEO_BITRATE)) {
switch_core_media_get_vid_params(imember->session, &vid_params); switch_core_media_get_vid_params(imember->session, &vid_params);
kps = switch_calc_bitrate(vid_params.width, vid_params.height, conference->video_quality, (int)(imember->conference->video_fps.fps)); kps = switch_calc_bitrate(vid_params.width, vid_params.height, conference->video_quality, (int)(imember->conference->video_fps.fps));
@ -2629,11 +2637,13 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
} }
} }
if (switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_SENDONLY) { if (imember->session && switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_SENDONLY) {
conference_video_pop_next_image(imember, &imember->pcanvas_img); conference_video_pop_next_image(imember, &imember->pcanvas_img);
} }
switch_core_session_rwunlock(imember->session); if (imember->session) {
switch_core_session_rwunlock(imember->session);
}
} }
if (conference->new_personal_vlayout && layout_applied) { if (conference->new_personal_vlayout && layout_applied) {
@ -2671,9 +2681,10 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
int i = 0; int i = 0;
mcu_layer_t *floor_layer = NULL; mcu_layer_t *floor_layer = NULL;
if (!imember->session || !switch_channel_test_flag(imember->channel, CF_VIDEO) || !imember->canvas || if (!imember->rec &&
(switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_SENDONLY) || (!imember->session || !switch_channel_test_flag(imember->channel, CF_VIDEO) || !imember->canvas ||
(switch_core_session_read_lock(imember->session) != SWITCH_STATUS_SUCCESS)) { (switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_SENDONLY) ||
(switch_core_session_read_lock(imember->session) != SWITCH_STATUS_SUCCESS))) {
continue; continue;
} }
@ -2762,7 +2773,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
if (layer) { if (layer) {
if (conference_utils_member_test_flag(omember, MFLAG_CAN_BE_SEEN)) { if (conference_utils_member_test_flag(omember, MFLAG_CAN_BE_SEEN)) {
layer->mute_patched = 0; layer->mute_patched = 0;
} else { } else if (!conference_utils_test_flag(imember->conference, CFLAG_VIDEO_MUTE_EXIT_CANVAS)) {
if (!layer->mute_patched) { if (!layer->mute_patched) {
switch_image_t *tmp; switch_image_t *tmp;
conference_video_scale_and_patch(layer, omember->video_mute_img ? omember->video_mute_img : omember->pcanvas_img, SWITCH_FALSE); conference_video_scale_and_patch(layer, omember->video_mute_img ? omember->video_mute_img : omember->pcanvas_img, SWITCH_FALSE);
@ -2795,7 +2806,9 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
} }
} }
switch_core_session_rwunlock(imember->session); if (imember->session) {
switch_core_session_rwunlock(imember->session);
}
} }
if (files_playing && !file_count) { if (files_playing && !file_count) {
@ -2807,33 +2820,41 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
for (imember = conference->members; imember; imember = imember->next) { for (imember = conference->members; imember; imember = imember->next) {
switch_frame_t *dupframe; switch_frame_t *dupframe;
if (!imember->session || !switch_channel_test_flag(imember->channel, CF_VIDEO_READY) || if (!imember->rec &&
switch_core_session_read_lock(imember->session) != SWITCH_STATUS_SUCCESS) { (!imember->session || !switch_channel_test_flag(imember->channel, CF_VIDEO_READY) ||
switch_core_session_read_lock(imember->session) != SWITCH_STATUS_SUCCESS)) {
continue; continue;
} }
if (need_refresh) { if (need_refresh && imember->session) {
switch_core_session_request_video_refresh(imember->session); switch_core_session_request_video_refresh(imember->session);
} }
if (send_keyframe) { if (send_keyframe && imember->session) {
switch_core_media_gen_key_frame(imember->session); switch_core_media_gen_key_frame(imember->session);
} }
switch_set_flag(&write_frame, SFF_RAW_RTP);
write_frame.img = imember->canvas->img; write_frame.img = imember->canvas->img;
write_frame.packet = packet;
write_frame.data = ((uint8_t *)packet) + 12; if (imember->rec) {
write_frame.datalen = 0; switch_core_file_write_video(&imember->rec->fh, &write_frame);
write_frame.buflen = SWITCH_RTP_MAX_BUF_LEN - 12; } else {
write_frame.packetlen = 0; switch_set_flag(&write_frame, SFF_RAW_RTP);
write_frame.packet = packet;
write_frame.data = ((uint8_t *)packet) + 12;
write_frame.datalen = 0;
write_frame.buflen = SWITCH_RTP_MAX_BUF_LEN - 12;
write_frame.packetlen = 0;
if (switch_frame_buffer_dup(imember->fb, &write_frame, &dupframe) == SWITCH_STATUS_SUCCESS) { if (switch_frame_buffer_dup(imember->fb, &write_frame, &dupframe) == SWITCH_STATUS_SUCCESS) {
switch_queue_push(imember->mux_out_queue, dupframe); switch_queue_push(imember->mux_out_queue, dupframe);
dupframe = NULL; dupframe = NULL;
}
} }
switch_core_session_rwunlock(imember->session); if (imember->session) {
switch_core_session_rwunlock(imember->session);
}
} }
switch_mutex_unlock(conference->member_mutex); switch_mutex_unlock(conference->member_mutex);