提交 f39c9e00 authored 作者: Anthony Minessale's avatar Anthony Minessale

FS-8909 FS-8914

上级 f7c6241f
......@@ -1932,7 +1932,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_close(_In_ switch_file_handle_t
SWITCH_DECLARE(switch_status_t) switch_core_file_command(switch_file_handle_t *fh, switch_file_command_t command);
SWITCH_DECLARE(switch_status_t) switch_core_file_truncate(switch_file_handle_t *fh, int64_t offset);
SWITCH_DECLARE(switch_bool_t) switch_core_file_has_video(switch_file_handle_t *fh);
SWITCH_DECLARE(switch_bool_t) switch_core_file_has_video(switch_file_handle_t *fh, switch_bool_t CHECK_OPEN);
///\}
......
......@@ -1491,6 +1491,7 @@ typedef enum {
CF_VIDEO_BITRATE_UNMANAGABLE,
CF_VIDEO_ECHO,
CF_VIDEO_BLANK,
CF_VIDEO_WRITING,
CF_SLA_INTERCEPT,
CF_VIDEO_BREAK,
CF_AUDIO_PAUSE,
......
......@@ -91,7 +91,7 @@ switch_status_t conference_file_close(conference_obj_t *conference, conference_f
conference_al_close(node->al);
}
#endif
if (conference->playing_video_file && switch_core_file_has_video(&node->fh) && conference->canvases[0] && node->canvas_id > -1) {
if (conference->playing_video_file && switch_core_file_has_video(&node->fh, SWITCH_FALSE) && conference->canvases[0] && node->canvas_id > -1) {
if (conference->canvases[node->canvas_id]->timer.timer_interface) {
conference->canvases[node->canvas_id]->timer.interval = conference->video_fps.ms;
conference->canvases[node->canvas_id]->timer.samples = conference->video_fps.samples;
......
......@@ -1586,7 +1586,7 @@ void conference_video_check_recording(conference_obj_t *conference, mcu_canvas_t
continue;
}
if (switch_test_flag((&imember->rec->fh), SWITCH_FILE_OPEN) && switch_core_file_has_video(&imember->rec->fh)) {
if (switch_test_flag((&imember->rec->fh), SWITCH_FILE_OPEN) && switch_core_file_has_video(&imember->rec->fh, SWITCH_TRUE)) {
switch_core_file_write_video(&imember->rec->fh, frame);
}
}
......@@ -1696,7 +1696,7 @@ void conference_video_patch_fnode(mcu_canvas_t *canvas, conference_file_node_t *
void conference_video_fnode_check(conference_file_node_t *fnode, int canvas_id) {
mcu_canvas_t *canvas = NULL;
if (switch_core_file_has_video(&fnode->fh) && switch_core_file_read_video(&fnode->fh, NULL, SVR_CHECK) == SWITCH_STATUS_BREAK) {
if (switch_core_file_has_video(&fnode->fh, SWITCH_TRUE) && switch_core_file_read_video(&fnode->fh, NULL, SVR_CHECK) == SWITCH_STATUS_BREAK) {
int full_screen = 0;
char *res_id = NULL;
......@@ -2220,13 +2220,13 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
do_refresh = 100;
}
if (conference->async_fnode && switch_core_file_has_video(&conference->async_fnode->fh)) {
if (conference->async_fnode && switch_core_file_has_video(&conference->async_fnode->fh, SWITCH_TRUE)) {
check_async_file = 1;
file_count++;
files_playing = 1;
}
if (conference->fnode && switch_core_file_has_video(&conference->fnode->fh)) {
if (conference->fnode && switch_core_file_has_video(&conference->fnode->fh, SWITCH_TRUE)) {
check_file = 1;
file_count++;
files_playing = 1;
......
......@@ -358,7 +358,7 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
switch_buffer_zero(audio_buffer);
if (switch_core_file_has_video(&fh)) {
if (switch_core_file_has_video(&fh, SWITCH_FALSE)) {
flush_video_queue(source->video_q);
}
......@@ -425,7 +425,7 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
}
}
if (title && (source->cover_art || switch_core_file_has_video(&fh))) {
if (title && (source->cover_art || switch_core_file_has_video(&fh, SWITCH_TRUE))) {
const char *format = "#cccccc:#333333:FreeSans.ttf:3%:";
if (artist) {
......@@ -466,7 +466,7 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
}
if (switch_core_file_has_video(&source->chime_fh)) {
if (switch_core_file_has_video(&source->chime_fh, SWITCH_FALSE)) {
flush_video_queue(source->video_q);
}
......@@ -479,7 +479,7 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
retry:
source->has_video = switch_core_file_has_video(use_fh) || source->cover_art || source->banner_txt;
source->has_video = switch_core_file_has_video(use_fh, SWITCH_TRUE) || source->cover_art || source->banner_txt;
is_open = switch_test_flag(use_fh, SWITCH_FILE_OPEN);
......@@ -503,10 +503,10 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
if (is_open) {
int svr = 0;
if (switch_core_has_video() && switch_core_file_has_video(use_fh)) {
if (switch_core_has_video() && switch_core_file_has_video(use_fh, SWITCH_TRUE)) {
switch_frame_t vid_frame = { 0 };
if (use_fh == &source->chime_fh && switch_core_file_has_video(&fh)) {
if (use_fh == &source->chime_fh && switch_core_file_has_video(&fh, SWITCH_TRUE)) {
if (switch_core_file_read_video(&fh, &vid_frame, svr) == SWITCH_STATUS_SUCCESS) {
switch_img_free(&vid_frame.img);
}
......@@ -599,14 +599,6 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
switch_mutex_lock(cp->audio_mutex);
if (switch_test_flag(cp->handle, SWITCH_FILE_OPEN)) {
if (source->has_video && !switch_test_flag(cp->handle, SWITCH_FILE_FLAG_VIDEO)) {
switch_set_flag_locked(cp->handle, SWITCH_FILE_FLAG_VIDEO);
} else {
if (switch_test_flag(cp->handle, SWITCH_FILE_FLAG_VIDEO)) {
switch_clear_flag_locked(cp->handle, SWITCH_FILE_FLAG_VIDEO);
}
}
if (switch_test_flag(cp->handle, SWITCH_FILE_CALLBACK)) {
switch_mutex_unlock(cp->audio_mutex);
continue;
......@@ -992,7 +984,7 @@ static switch_status_t local_stream_file_read_video(switch_file_handle_t *handle
return SWITCH_STATUS_FALSE;
}
while (switch_queue_size(context->video_q) < 5) {
while (!(flags & SVR_BLOCK) && switch_queue_size(context->video_q) < 5) {
return SWITCH_STATUS_BREAK;
}
......@@ -1094,6 +1086,16 @@ static switch_status_t local_stream_file_read(switch_file_handle_t *handle, void
*len = 0;
return SWITCH_STATUS_FALSE;
}
if (context->source->has_video) {
if (!switch_test_flag(handle, SWITCH_FILE_FLAG_VIDEO)) {
switch_set_flag_locked(handle, SWITCH_FILE_FLAG_VIDEO);
}
} else {
if (switch_test_flag(handle, SWITCH_FILE_FLAG_VIDEO)) {
switch_clear_flag_locked(handle, SWITCH_FILE_FLAG_VIDEO);
}
}
switch_mutex_lock(context->audio_mutex);
need = *len * 2 * context->source->channels;
......
......@@ -495,9 +495,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_read(switch_file_handle_t *fh,
return status;
}
SWITCH_DECLARE(switch_bool_t) switch_core_file_has_video(switch_file_handle_t *fh)
SWITCH_DECLARE(switch_bool_t) switch_core_file_has_video(switch_file_handle_t *fh, switch_bool_t check_open)
{
return (switch_test_flag(fh, SWITCH_FILE_OPEN) && switch_test_flag(fh, SWITCH_FILE_FLAG_VIDEO)) ? SWITCH_TRUE : SWITCH_FALSE;
return ((!check_open || switch_test_flag(fh, SWITCH_FILE_OPEN)) && switch_test_flag(fh, SWITCH_FILE_FLAG_VIDEO)) ? SWITCH_TRUE : SWITCH_FALSE;
}
SWITCH_DECLARE(switch_status_t) switch_core_file_write(switch_file_handle_t *fh, void *data, switch_size_t *len)
......
......@@ -2667,8 +2667,6 @@ static void switch_core_session_parse_codec_settings(switch_core_session_t *sess
system_bw = switch_parse_bandwidth_string(bwv);
printf("%d %d\n", engine->sdp_bw, system_bw);
if (engine->sdp_bw && engine->sdp_bw <= system_bw) {
engine->codec_settings.video.bandwidth = engine->sdp_bw;
} else {
......@@ -5008,6 +5006,7 @@ static void *SWITCH_THREAD_FUNC video_write_thread(switch_thread_t *thread, void
int buflen = SWITCH_RTP_MAX_BUF_LEN;
switch_timer_t timer = { 0 };
int fps;
switch_video_read_flag_t read_flags = SVR_FLUSH|SVR_BLOCK;
if (switch_core_session_read_lock(session) != SWITCH_STATUS_SUCCESS) {
return NULL;
......@@ -5017,6 +5016,8 @@ static void *SWITCH_THREAD_FUNC video_write_thread(switch_thread_t *thread, void
return NULL;
}
switch_channel_set_flag(session->channel, CF_VIDEO_WRITING);
v_engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO];
......@@ -5054,7 +5055,7 @@ static void *SWITCH_THREAD_FUNC video_write_thread(switch_thread_t *thread, void
}
if (smh->video_write_fh && !switch_test_flag(smh->video_write_fh, SWITCH_FILE_FLAG_VIDEO_EOF)) {
wstatus = switch_core_file_read_video(smh->video_write_fh, &fr, SVR_BLOCK);
wstatus = switch_core_file_read_video(smh->video_write_fh, &fr, read_flags);
if (wstatus == SWITCH_STATUS_SUCCESS) {
switch_core_session_write_video_frame(session, &fr, SWITCH_IO_FLAG_NONE, SVR_FLUSH);
......@@ -5070,6 +5071,7 @@ static void *SWITCH_THREAD_FUNC video_write_thread(switch_thread_t *thread, void
switch_core_session_rwunlock(session);
switch_channel_clear_flag(session->channel, CF_VIDEO_WRITING);
smh->video_write_thread_running = 0;
return NULL;
......@@ -5135,11 +5137,15 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_set_video_file(switch_core_ses
switch_assert(session);
if (!switch_channel_test_flag(session->channel, CF_VIDEO)) {
if (!(smh = session->media_handle)) {
return SWITCH_STATUS_FALSE;
}
if (!(smh = session->media_handle)) {
if (!smh->video_read_fh && !smh->video_read_fh && !switch_channel_test_flag(session->channel, CF_VIDEO)) {
return SWITCH_STATUS_FALSE;
}
if (fh && !switch_core_file_has_video(fh, SWITCH_TRUE)) {
return SWITCH_STATUS_FALSE;
}
......@@ -5181,9 +5187,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_set_video_file(switch_core_ses
} else {
switch_mutex_lock(v_engine->mh.file_write_mutex);
if (fh && smh->video_write_fh) {
//switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "File is already open\n");
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "File is already open\n");
smh->video_write_fh = fh;
switch_mutex_unlock(v_engine->mh.file_write_mutex);
return SWITCH_STATUS_SUCCESS;
......@@ -5199,7 +5204,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_set_video_file(switch_core_ses
if (fh) {
switch_threadattr_t *thd_attr = NULL;
switch_threadattr_create(&thd_attr, switch_core_session_get_pool(session));
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
smh->video_write_thread_running = 1;
......@@ -5208,6 +5213,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_set_video_file(switch_core_ses
if (!fh && smh->video_write_thread) {
switch_status_t st;
if (smh->video_write_thread_running > 0) {
smh->video_write_thread_running = -1;
}
......@@ -5385,7 +5391,8 @@ static void *SWITCH_THREAD_FUNC video_helper_thread(switch_thread_t *thread, voi
switch_core_media_gen_key_frame(session);
}
send_blank = 1;
if (switch_channel_test_flag(channel, CF_VIDEO_READY)) {
switch_mutex_lock(mh->file_read_mutex);
if (smh->video_read_fh && switch_test_flag(smh->video_read_fh, SWITCH_FILE_OPEN) && read_frame->img) {
......@@ -5393,10 +5400,24 @@ static void *SWITCH_THREAD_FUNC video_helper_thread(switch_thread_t *thread, voi
send_blank = 0;
}
switch_mutex_unlock(mh->file_read_mutex);
} else if (switch_channel_test_flag(channel, CF_VIDEO_DECODED_READ) || v_engine->smode == SWITCH_MEDIA_FLOW_SENDONLY) {
send_blank = 1;
//} else if (switch_channel_test_flag(channel, CF_VIDEO_DECODED_READ) || v_engine->smode == SWITCH_MEDIA_FLOW_SENDONLY) {
//send_blank = 1;
}
if (switch_channel_test_flag(channel, CF_VIDEO_WRITING) || session->video_read_callback) {
send_blank = 0;
}
if (send_blank) {
if (read_frame && (switch_channel_test_flag(channel, CF_VIDEO_ECHO))) {
switch_core_session_write_video_frame(session, read_frame, SWITCH_IO_FLAG_NONE, 0);
} else if (blank_img) {
fr.img = blank_img;
switch_yield(10000);
switch_core_session_write_video_frame(session, &fr, SWITCH_IO_FLAG_FORCE, 0);
}
}
#if 0
if (blank_img && (send_blank || switch_channel_test_flag(channel, CF_VIDEO_BLANK)) && !session->video_read_callback) {
fr.img = blank_img;
switch_yield(10000);
......@@ -5404,6 +5425,8 @@ static void *SWITCH_THREAD_FUNC video_helper_thread(switch_thread_t *thread, voi
} else if (read_frame && (switch_channel_test_flag(channel, CF_VIDEO_ECHO))) {
switch_core_session_write_video_frame(session, read_frame, SWITCH_IO_FLAG_NONE, 0);
}
#endif
}
switch_img_free(&blank_img);
......
......@@ -1139,7 +1139,7 @@ static void *SWITCH_THREAD_FUNC recording_thread(switch_thread_t *thread, void *
data = switch_core_session_alloc(session, SWITCH_RECOMMENDED_BUFFER_SIZE);
while(switch_test_flag(rh->fh, SWITCH_FILE_OPEN)) {
if (switch_core_file_has_video(rh->fh)) {
if (switch_core_file_has_video(rh->fh, SWITCH_TRUE)) {
switch_core_session_get_read_impl(session, &read_impl);
if (read_impl.decoded_bytes_per_packet > 0 && read_impl.decoded_bytes_per_packet <= SWITCH_RECOMMENDED_BUFFER_SIZE) {
bsize = read_impl.decoded_bytes_per_packet;
......@@ -1352,7 +1352,7 @@ static switch_bool_t record_callback(switch_media_bug_t *bug, void *user_data, s
}
//if (switch_core_file_has_video(rh->fh)) {
//if (switch_core_file_has_video(rh->fh, SWITCH_TRUE)) {
//switch_core_media_set_video_file(session, NULL, SWITCH_RW_READ);
//switch_channel_clear_flag_recursive(session->channel, CF_VIDEO_DECODED_READ);
//}
......@@ -2551,7 +2551,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t
return SWITCH_STATUS_GENERR;
}
if (switch_core_file_has_video(fh)) {
if (switch_core_file_has_video(fh, SWITCH_TRUE)) {
//switch_core_media_set_video_file(session, fh, SWITCH_RW_READ);
//switch_channel_set_flag_recursive(session->channel, CF_VIDEO_DECODED_READ);
......
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论