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->path = switch_core_strdup(pool, path);
rec->pool = pool;
flags = SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT;
if (conference_utils_test_flag(conference, CFLAG_TRANSCODE_VIDEO)) {
+ char *orig_path = rec->path;
flags |= SWITCH_FILE_FLAG_VIDEO;
+
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",
conference->channels,
conference->rate,
canvas->height,
conference->video_fps.fps,
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) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening File [%s]\n", rec->path);
switch_mutex_unlock(conference->mutex);
switch_core_file_close(&member->rec->fh);
}
+
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) {
conference_event_add_data(conference, event);
if (!imember->rec) {
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;
}
conference_api_sub_position(member, NULL, layer->geometry.audio_position);
}
- var = NULL;
- if (member->video_banner_text ||
- (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 = switch_channel_get_variable_dup(member->channel, "video_logo_path", SWITCH_FALSE, -1))) {
- conference_video_layer_set_logo(member, layer, var);
+ if (member->channel) {
+ var = NULL;
+ if (member->video_banner_text ||
+ (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 = switch_channel_get_variable_dup(member->channel, "video_logo_path", SWITCH_FALSE, -1))) {
+ conference_video_layer_set_logo(member, layer, var);
+ }
}
}
int layout_applied = 0;
int files_playing = 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_layout_group = conference->video_layout_group;
}
- if (video_count != canvas->video_count) {
+
+ if (video_count != canvas->video_count || video_count != last_video_count) {
count_changed = 1;
}
- canvas->video_count = video_count;
+ canvas->video_count = last_video_count = video_count;
switch_mutex_unlock(conference->member_mutex);
switch_core_timer_next(&canvas->timer);
layout_group_t *lg = NULL;
video_layout_t *vlayout = NULL;
conference_member_t *omember;
-
+
if (video_key_freq && (now - last_key_time) > video_key_freq) {
send_keyframe = SWITCH_TRUE;
last_key_time = now;
switch_mutex_lock(conference->member_mutex);
for (imember = conference->members; imember; imember = imember->next) {
-
- if (!imember->session || !switch_channel_test_flag(imember->channel, CF_VIDEO_READY) ||
- switch_core_session_read_lock(imember->session) != SWITCH_STATUS_SUCCESS) {
+
+ if (!imember->rec &&
+ (!imember->session || !switch_channel_test_flag(imember->channel, CF_VIDEO_READY) ||
+ switch_core_session_read_lock(imember->session) != SWITCH_STATUS_SUCCESS)) {
continue;
}
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);
send_keyframe = SWITCH_TRUE;
}
if (count_changed) {
- int total = conference->members_with_video;
+ int total = last_video_count;
int kps;
switch_vid_params_t vid_params = { 0 };
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--;
}
}
}
- 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)) {
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));
}
}
- 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);
}
- switch_core_session_rwunlock(imember->session);
+ if (imember->session) {
+ switch_core_session_rwunlock(imember->session);
+ }
}
if (conference->new_personal_vlayout && layout_applied) {
int i = 0;
mcu_layer_t *floor_layer = NULL;
- if (!imember->session || !switch_channel_test_flag(imember->channel, CF_VIDEO) || !imember->canvas ||
- (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)) {
+ if (!imember->rec &&
+ (!imember->session || !switch_channel_test_flag(imember->channel, CF_VIDEO) || !imember->canvas ||
+ (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;
}
if (layer) {
if (conference_utils_member_test_flag(omember, MFLAG_CAN_BE_SEEN)) {
layer->mute_patched = 0;
- } else {
+ } else if (!conference_utils_test_flag(imember->conference, CFLAG_VIDEO_MUTE_EXIT_CANVAS)) {
if (!layer->mute_patched) {
switch_image_t *tmp;
conference_video_scale_and_patch(layer, omember->video_mute_img ? omember->video_mute_img : omember->pcanvas_img, SWITCH_FALSE);
}
}
- switch_core_session_rwunlock(imember->session);
+ if (imember->session) {
+ switch_core_session_rwunlock(imember->session);
+ }
}
if (files_playing && !file_count) {
for (imember = conference->members; imember; imember = imember->next) {
switch_frame_t *dupframe;
- if (!imember->session || !switch_channel_test_flag(imember->channel, CF_VIDEO_READY) ||
- switch_core_session_read_lock(imember->session) != SWITCH_STATUS_SUCCESS) {
+ if (!imember->rec &&
+ (!imember->session || !switch_channel_test_flag(imember->channel, CF_VIDEO_READY) ||
+ switch_core_session_read_lock(imember->session) != SWITCH_STATUS_SUCCESS)) {
continue;
}
- if (need_refresh) {
+ if (need_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_set_flag(&write_frame, SFF_RAW_RTP);
write_frame.img = imember->canvas->img;
- 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) {
- switch_queue_push(imember->mux_out_queue, dupframe);
- dupframe = NULL;
+
+ if (imember->rec) {
+ switch_core_file_write_video(&imember->rec->fh, &write_frame);
+ } else {
+ 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) {
+ switch_queue_push(imember->mux_out_queue, dupframe);
+ dupframe = NULL;
+ }
}
- switch_core_session_rwunlock(imember->session);
+ if (imember->session) {
+ switch_core_session_rwunlock(imember->session);
+ }
}
switch_mutex_unlock(conference->member_mutex);