FS-11164: [freeswitch-core] Improve audio JB in bad conditions

This commit is contained in:
Anthony Minessale 2018-05-25 11:07:24 -05:00 committed by Muteesa Fred
parent 611e38e8cb
commit 578d914b96
3 changed files with 53 additions and 27 deletions

View File

@ -4435,6 +4435,44 @@ SWITCH_STANDARD_API(uuid_video_bitrate_function)
return SWITCH_STATUS_SUCCESS;
}
#define VIDEO_BITRATE_SYNTAX "<uuid> <bitrate>"
SWITCH_STANDARD_API(uuid_video_bandwidth_function)
{
switch_status_t status = SWITCH_STATUS_FALSE;
char *mycmd = NULL, *argv[2] = { 0 };
int argc = 0;
if (!zstr(cmd) && (mycmd = strdup(cmd))) {
argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
}
if (argc < 2) {
stream->write_function(stream, "-USAGE: %s\n", VIDEO_REFRESH_SYNTAX);
} else {
switch_core_session_t *lsession = NULL;
if ((lsession = switch_core_session_locate(argv[0]))) {
int kps;
kps = switch_parse_bandwidth_string(argv[1]);
switch_core_media_set_outgoing_bitrate(lsession, SWITCH_MEDIA_TYPE_VIDEO, kps);
status = SWITCH_STATUS_SUCCESS;
switch_core_session_rwunlock(lsession);
}
}
if (status == SWITCH_STATUS_SUCCESS) {
stream->write_function(stream, "+OK Success\n");
} else {
stream->write_function(stream, "-ERR Operation Failed\n");
}
switch_safe_free(mycmd);
return SWITCH_STATUS_SUCCESS;
}
#define CODEC_DEBUG_SYNTAX "<uuid> audio|video <level>"
SWITCH_STANDARD_API(uuid_codec_debug_function)
{
@ -7496,6 +7534,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
SWITCH_ADD_API(commands_api_interface, "uuid_send_info", "Send info to the endpoint", uuid_send_info_function, INFO_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "uuid_set_media_stats", "Set media stats", uuid_set_media_stats, UUID_MEDIA_STATS_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "uuid_video_bitrate", "Send video bitrate req.", uuid_video_bitrate_function, VIDEO_BITRATE_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "uuid_video_bandwidth", "Send video bandwidth", uuid_video_bandwidth_function, VIDEO_BITRATE_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "uuid_video_refresh", "Send video refresh.", uuid_video_refresh_function, VIDEO_REFRESH_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "uuid_outgoing_answer", "Answer outgoing channel", outgoing_answer_function, OUTGOING_ANSWER_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "uuid_limit", "Increase limit resource", uuid_limit_function, LIMIT_SYNTAX);
@ -7719,6 +7758,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
switch_console_set_complete("add uuid_dual_transfer ::console::list_uuid");
switch_console_set_complete("add uuid_video_refresh ::console::list_uuid");
switch_console_set_complete("add uuid_video_bitrate ::console::list_uuid");
switch_console_set_complete("add uuid_video_bandwidth ::console::list_uuid");
switch_console_set_complete("add uuid_xfer_zombie ::console::list_uuid");
switch_console_set_complete("add version");
switch_console_set_complete("add uuid_warning ::console::list_uuid");

View File

@ -1292,7 +1292,6 @@ SWITCH_DECLARE(switch_status_t) switch_jb_get_packet(switch_jb_t *jb, switch_rtp
switch_jb_node_t *node = NULL;
switch_status_t status;
int plc = 0;
int too_big = 0;
switch_mutex_lock(jb->mutex);
@ -1454,30 +1453,17 @@ SWITCH_DECLARE(switch_status_t) switch_jb_get_packet(switch_jb_t *jb, switch_rtp
}
switch_mutex_unlock(jb->mutex);
if (jb->type == SJB_VIDEO) {
too_big = jb->max_frame_len * 15;
} else {
too_big = (int)(jb->max_frame_len * 1.5);
}
if (jb->visible_nodes > too_big) {
//if (jb->complete_frames > jb->max_frame_len) {
//int b4 = jb->visible_nodes;
//thin_frames(jb, 2, jb->max_frame_len / 2);
//jb_debug(jb, 2, "JB TOO BIG (%d/%d), DROP SOME\n", b4, jb->visible_nodes);
//switch_jb_reset(jb);
}
//if (jb->complete_frames > jb->max_frame_len * 2) {
// jb_debug(jb, 2, "JB TOO BIG (%d), RESET\n", jb->complete_frames);
// switch_jb_reset(jb);
//}
if (jb->visible_nodes > too_big && status == SWITCH_STATUS_SUCCESS) {
//if (jb->frame_len >= jb->max_frame_len && status == SWITCH_STATUS_SUCCESS) {
//if (jb->allocated_nodes > jb->max_frame_len) {
status = SWITCH_STATUS_TIMEOUT;
if (jb->type == SJB_VIDEO) {
if (jb->complete_frames > jb->max_frame_len * 2) {
jb_debug(jb, 2, "JB TOO BIG (%d), RESET\n", jb->complete_frames);
switch_jb_reset(jb);
}
} else {
int too_big = (int)(jb->max_frame_len * 1.5);
if (jb->visible_nodes > too_big && status == SWITCH_STATUS_SUCCESS) {
status = SWITCH_STATUS_TIMEOUT;
}
}
return status;

View File

@ -414,7 +414,7 @@ static switch_status_t init_encoder(switch_codec_t *codec)
context->start_time = switch_micro_time_now();
config->g_timebase.num = 1;
config->g_timebase.den = 1000;//90000;
config->g_timebase.den = 90000;
config->g_pass = VPX_RC_ONE_PASS;
config->g_w = context->codec_settings.video.width;
config->g_h = context->codec_settings.video.height;
@ -864,8 +864,8 @@ static switch_status_t switch_vpx_encode(switch_codec_t *codec, switch_frame_t *
context->framecount++;
pts = (now - context->start_time) / 1000;
//pts = frame->timestamp;
//pts = (now - context->start_time) / 1000;
pts = frame->timestamp;
dur = context->last_ms ? (now - context->last_ms) / 1000 : pts;