FS-7499 FS-7513 try to avoid storm of refreshes in heavy usage

This commit is contained in:
Anthony Minessale 2015-05-05 15:48:59 -05:00 committed by Michael Jerris
parent dc4c38dab5
commit 02cac73d37
2 changed files with 32 additions and 17 deletions

View File

@ -1666,9 +1666,9 @@ static void write_canvas_image_to_codec_group(conference_obj_t *conference, code
continue;
}
if (need_refresh) {
switch_core_session_request_video_refresh(imember->session);
}
//if (need_refresh) {
// switch_core_session_request_video_refresh(imember->session);
//}
//switch_core_session_write_encoded_video_frame(imember->session, frame, 0, 0);
switch_set_flag(frame, SFF_ENCODED);
@ -1754,9 +1754,11 @@ static void *SWITCH_THREAD_FUNC conference_video_muxing_write_thread_run(switch_
switch_core_media_gen_key_frame(member->session);
switch_core_session_request_video_refresh(member->session);
}
loops++;
loops++;
frame = (switch_frame_t *) pop;
if (switch_test_flag(frame, SFF_ENCODED)) {
switch_core_session_write_encoded_video_frame(member->session, frame, 0, 0);
} else {
@ -1874,6 +1876,7 @@ static void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread
switch_image_t *write_img = NULL, *file_img = NULL;
uint32_t timestamp = 0, avatar_layers = 0;
video_layout_t *vlayout = get_layout(conference);
switch_time_t last_refresh_req = 0;
if (!vlayout) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot find layout\n");
@ -1948,9 +1951,13 @@ static void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread
if (switch_test_flag(conference, CFLAG_MINIMIZE_VIDEO_ENCODING) && switch_channel_test_flag(imember->channel, CF_VIDEO)) {
if (switch_channel_test_flag(imember->channel, CF_VIDEO_REFRESH_REQ)) {
switch_channel_clear_flag(imember->channel, CF_VIDEO_REFRESH_REQ);
need_refresh = SWITCH_TRUE;
if (!last_refresh_req || (now - last_refresh_req) > 1000) {
need_refresh = SWITCH_TRUE;
last_refresh_req = now;
}
}
if (imember->video_codec_index < 0 && (check_codec = switch_core_session_get_video_write_codec(imember->session))) {
for (i = 0; write_codecs[i] && switch_core_codec_ready(&write_codecs[i]->codec) && i < MAX_MUX_CODECS; i++) {
if (check_codec->implementation->codec_id == write_codecs[i]->codec.implementation->codec_id) {
@ -2021,6 +2028,11 @@ static void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread
if (flushed && imember->blanks) {
switch_img_free(&imember->avatar_png_img);
if (layer) {
layer->is_avatar = 0;
}
imember->blanks = 0;
switch_core_session_request_video_refresh(imember->session);
switch_channel_video_sync(imember->channel);

View File

@ -1295,21 +1295,24 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
#if 1
case SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ:
{
//const char *pl = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<media_control>\n<vc_primitive>\n<to_encoder>\n<picture_fast_update>\n</picture_fast_update>\n</to_encoder>\n</vc_primitive>\n</media_control>";
const char *pl = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<media_control><vc_primitive><to_encoder><picture_fast_update /></to_encoder></vc_primitive></media_control>\n";
time_t now = switch_epoch_time_now(NULL);
const char *ua = switch_channel_get_variable(tech_pvt->channel, "sip_user_agent");
if (ua && switch_stristr("polycom", ua)) {
if (!tech_pvt->last_vid_info || (now - tech_pvt->last_vid_info) > 1) {
//const char *pl = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<media_control>\n<vc_primitive>\n<to_encoder>\n<picture_fast_update>\n</picture_fast_update>\n</to_encoder>\n</vc_primitive>\n</media_control>";
const char *pl = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<media_control><vc_primitive><to_encoder><picture_fast_update /></to_encoder></vc_primitive></media_control>\n";
time_t now = switch_epoch_time_now(NULL);
tech_pvt->last_vid_info = now;
if (!zstr(msg->string_arg)) {
pl = msg->string_arg;
if (!tech_pvt->last_vid_info || (now - tech_pvt->last_vid_info) > 1) {
tech_pvt->last_vid_info = now;
if (!zstr(msg->string_arg)) {
pl = msg->string_arg;
}
nua_info(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("application/media_control+xml"), SIPTAG_PAYLOAD_STR(pl), TAG_END());
}
nua_info(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("application/media_control+xml"), SIPTAG_PAYLOAD_STR(pl), TAG_END());
}
}
break;
#endif