提交 35b3e9a6 authored 作者: Anthony Minessale's avatar Anthony Minessale 提交者: Mike Jerris

FS-10126: [freeswitch-core] General Video Improvements #resolve

Conflicts:
	src/include/switch_core.h
	src/include/switch_types.h
	src/mod/applications/mod_conference/conference_file.c
	src/mod/applications/mod_conference/conference_video.c
	src/mod/languages/mod_managed/managed/swig.cs
	src/switch_core_media.c
	src/switch_ivr_bridge.c
	src/switch_rtp.c
上级 3da6bd01
......@@ -1274,6 +1274,9 @@ SWITCH_DECLARE(uint32_t) switch_core_session_private_event_count(_In_ switch_cor
SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_private_event(_In_ switch_core_session_t *session, _Out_ switch_event_t **event);
SWITCH_DECLARE(switch_bool_t) switch_core_session_transcoding(switch_core_session_t *session_a, switch_core_session_t *session_b, switch_media_type_t type);
SWITCH_DECLARE(void) switch_core_session_passthru(switch_core_session_t *session, switch_media_type_t type, switch_bool_t on);
/*!
\brief Flush the private event queue of a session
\param session the session to flush
......
......@@ -207,6 +207,7 @@ struct switch_timer {
unsigned int samples;
/*! current sample count based on samples parameter */
uint32_t samplecount;
uint32_t last_samplecount;
/*! the timer interface provided from a loadable module */
switch_timer_interface_t *timer_interface;
/*! the timer's memory pool */
......
......@@ -770,8 +770,6 @@ typedef enum {
SWITCH_RTP_FLAG_MUTE,
SWITCH_RTP_FLAG_NACK,
SWITCH_RTP_FLAG_TMMBR,
SWITCH_RTP_FLAG_GEN_TS_DELTA,
SWITCH_RTP_FLAG_GEN_TS_MANUAL,
SWITCH_RTP_FLAG_DETECT_SSRC,
SWITCH_RTP_FLAG_OLD_FIR,
SWITCH_RTP_FLAG_PASSTHRU,
......@@ -905,7 +903,6 @@ typedef enum {
*/
} switch_rtp_bug_flag_t;
#ifdef _MSC_VER
......@@ -1530,6 +1527,8 @@ typedef struct switch_vid_params_s {
uint32_t width;
uint32_t height;
uint32_t fps;
uint32_t d_width;
uint32_t d_height;
} switch_vid_params_t;
......
......@@ -41,30 +41,17 @@
*/
#include <mod_conference.h>
static struct conference_fps FPS_VALS[] = {
{1.0f, 1000, 90},
{5.0f, 200, 450},
{10.0f, 100, 900},
{15.0f, 66, 1364},
{16.60f, 60, 1500},
{20.0f, 50, 4500},
{25.0f, 40, 2250},
{30.0f, 33, 2700},
{33.0f, 30, 2790},
{66.60f, 15, 6000},
{100.0f, 10, 9000},
{0,0,0}
};
int conference_video_set_fps(conference_obj_t *conference, float fps)
{
uint32_t i = 0, j = 0;
uint32_t j = 0;
for (i = 0; FPS_VALS[i].ms; i++) {
if (FPS_VALS[i].fps == fps) {
if (fps > 100) {
return 0;
}
conference->video_fps = FPS_VALS[i];
conference->video_fps.fps = fps;
conference->video_fps.ms = (int) 1000 / fps;
conference->video_fps.samples = (int) 90000 / conference->video_fps.ms;
for (j = 0; j <= conference->canvas_count; j++) {
if (conference->canvases[j]) {
......@@ -73,10 +60,6 @@ int conference_video_set_fps(conference_obj_t *conference, float fps)
}
return 1;
}
}
return 0;
}
......@@ -1312,7 +1295,7 @@ void conference_video_write_canvas_image_to_codec_group(conference_obj_t *confer
}
if (frame->timestamp) {
switch_set_flag(frame, SFF_RAW_RTP_PARSE_FRAME);
switch_set_flag(frame, SFF_RAW_RTP_PARSE_FRAME|SFF_USE_VIDEO_TIMESTAMP);
}
frame->packetlen = frame->datalen + 12;
......@@ -1342,7 +1325,9 @@ void conference_video_write_canvas_image_to_codec_group(conference_obj_t *confer
switch_core_session_request_video_refresh(imember->session);
}
if (switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_RECVONLY || switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_INACTIVE) {
if (switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_RECVONLY ||
switch_channel_test_flag(imember->channel, CF_VIDEO_WRITING) ||
switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_INACTIVE) {
switch_core_session_rwunlock(imember->session);
continue;
}
......@@ -2996,6 +2981,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
if (!imember->rec &&
(!imember->session || !switch_channel_test_flag(imember->channel, CF_VIDEO_READY) || !imember->canvas ||
switch_channel_test_flag(imember->channel, CF_VIDEO_WRITING) ||
switch_core_session_read_lock(imember->session) != SWITCH_STATUS_SUCCESS)) {
continue;
}
......@@ -3196,7 +3182,9 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
switch_core_session_request_video_refresh(imember->session);
}
if (switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_RECVONLY || switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_INACTIVE) {
if (switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_RECVONLY ||
switch_channel_test_flag(imember->channel, CF_VIDEO_WRITING) ||
switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_INACTIVE) {
switch_core_session_rwunlock(imember->session);
continue;
}
......@@ -3206,13 +3194,14 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
switch_core_media_gen_key_frame(imember->session);
}
switch_set_flag(&write_frame, SFF_RAW_RTP);
switch_set_flag(&write_frame, SFF_RAW_RTP|SFF_USE_VIDEO_TIMESTAMP|SFF_RAW_RTP_PARSE_FRAME);
write_frame.img = write_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;
write_frame.timestamp = timestamp;
//switch_core_session_write_video_frame(imember->session, &write_frame, SWITCH_IO_FLAG_NONE, 0);
......@@ -3545,7 +3534,9 @@ void *SWITCH_THREAD_FUNC conference_video_super_muxing_thread_run(switch_thread_
switch_core_session_request_video_refresh(imember->session);
}
if (switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_RECVONLY || switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_INACTIVE) {
if (switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_RECVONLY ||
switch_channel_test_flag(imember->channel, CF_VIDEO_WRITING) ||
switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_INACTIVE) {
switch_core_session_rwunlock(imember->session);
continue;
}
......
差异被折叠。
......@@ -55,6 +55,7 @@ static void video_bridge_thread(switch_core_session_t *session, void *obj)
switch_frame_t *read_frame = 0;
int set_decoded_read = 0, refresh_timer = 0;
int refresh_cnt = 300;
int pass_val = 0, last_pass_val = 0;
vh->up = 1;
......@@ -79,6 +80,16 @@ static void video_bridge_thread(switch_core_session_t *session, void *obj)
switch_codec_t *a_codec = switch_core_session_get_video_read_codec(vh->session_a);
switch_codec_t *b_codec = switch_core_session_get_video_write_codec(vh->session_b);
if (switch_core_session_transcoding(vh->session_a, vh->session_b, SWITCH_MEDIA_TYPE_VIDEO)) {
pass_val = 1;
} else {
pass_val = 2;
}
if (pass_val != last_pass_val) {
switch_core_session_passthru(session, SWITCH_MEDIA_TYPE_VIDEO, pass_val == 2 ? SWITCH_TRUE : SWITCH_FALSE);
last_pass_val = pass_val;
}
if (switch_channel_test_flag(channel, CF_VIDEO_REFRESH_REQ)) {
switch_channel_clear_flag(channel, CF_VIDEO_REFRESH_REQ);
......@@ -146,6 +157,8 @@ static void video_bridge_thread(switch_core_session_t *session, void *obj)
switch_core_session_request_video_refresh(vh->session_a);
switch_core_session_request_video_refresh(vh->session_b);
switch_core_session_passthru(vh->session_a, SWITCH_MEDIA_TYPE_VIDEO, SWITCH_FALSE);
switch_core_session_rwunlock(vh->session_a);
switch_core_session_rwunlock(vh->session_b);
......@@ -268,6 +281,7 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
switch_codec_implementation_t read_impl = { 0 };
const char *banner_file = NULL;
int played_banner = 0, banner_counter = 0;
int pass_val = 0, last_pass_val = 0;
#ifdef SWITCH_VIDEO_IN_THREADS
struct vid_helper vh = { 0 };
......@@ -398,6 +412,17 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
switch_status_t status;
switch_event_t *event;
if (switch_core_session_transcoding(session_a, session_b, SWITCH_MEDIA_TYPE_AUDIO)) {
pass_val = 1;
} else {
pass_val = 2;
}
if (pass_val != last_pass_val) {
switch_core_session_passthru(session_a, SWITCH_MEDIA_TYPE_AUDIO, pass_val == 2 ? SWITCH_TRUE : SWITCH_FALSE);
last_pass_val = pass_val;
}
if (switch_channel_test_flag(chan_a, CF_TRANSFER)) {
data->clean_exit = 1;
}
......@@ -702,6 +727,8 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
}
#endif
switch_core_session_passthru(session_a, SWITCH_MEDIA_TYPE_AUDIO, SWITCH_FALSE);
if (silence_val) {
switch_core_codec_destroy(&silence_codec);
......
......@@ -386,6 +386,14 @@ static switch_status_t timer_generic_sync(switch_timer_t *timer)
timer->tick = (elapsed / timer->interval) / 1000;
timer->samplecount = (uint32_t)(timer->tick * timer->samples);
if (timer->interval == 1 && timer->samplecount == timer->last_samplecount) {
timer->samplecount++;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Timer sync too often\n");
}
timer->last_samplecount = timer->samplecount;
return SWITCH_STATUS_SUCCESS;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论