Merge branch 'master' into v1.4

This commit is contained in:
Ken Rice 2014-10-09 13:40:39 -05:00
commit bb506c393b
6 changed files with 33 additions and 5 deletions

View File

@ -505,6 +505,7 @@ struct sofia_gateway {
switch_bool_t ping_monitoring;
uint8_t flags[REG_FLAG_MAX];
int32_t retry_seconds;
int32_t fail_908_retry_seconds;
int32_t reg_timeout_seconds;
int32_t failure_status;
reg_state_t state;

View File

@ -3320,6 +3320,7 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag)
*context = profile->context,
*expire_seconds = "3600",
*retry_seconds = "30",
*fail_908_retry_seconds = NULL,
*timeout_seconds = "60",
*from_user = "", *from_domain = NULL, *outbound_proxy = NULL, *register_proxy = NULL, *contact_host = NULL,
*contact_params = "", *params = NULL, *register_transport = NULL,
@ -3434,6 +3435,8 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag)
context = val;
} else if (!strcmp(var, "expire-seconds")) {
expire_seconds = val;
} else if (!strcmp(var, "908-retry-seconds")) {
fail_908_retry_seconds = val;
} else if (!strcmp(var, "retry-seconds")) {
retry_seconds = val;
} else if (!strcmp(var, "timeout-seconds")) {
@ -3547,6 +3550,10 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag)
gateway->retry_seconds = atoi(retry_seconds);
if (fail_908_retry_seconds) {
gateway->fail_908_retry_seconds = atoi(fail_908_retry_seconds);
}
if (gateway->retry_seconds < 5) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid retry-seconds of %d on gateway %s, using the value of 30 instead.\n",
gateway->retry_seconds, name);

View File

@ -493,7 +493,9 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
{
int sec;
if (gateway_ptr->failure_status == 503 || gateway_ptr->failure_status == 908 || gateway_ptr->failures < 1) {
if (gateway_ptr->fail_908_retry_seconds && gateway_ptr->failure_status == 908) {
sec = gateway_ptr->fail_908_retry_seconds;
} else if (gateway_ptr->failure_status == 503 || gateway_ptr->failure_status == 908 || gateway_ptr->failures < 1) {
sec = gateway_ptr->retry_seconds;
} else {
sec = gateway_ptr->retry_seconds * gateway_ptr->failures;

View File

@ -1256,12 +1256,16 @@ static int is_match_end(pcre *compiled_regex, const char *input)
search = search_set;
}
search_input[input_size] = *search++;
result = pcre_exec(compiled_regex, NULL, search_input, input_size + 1, 0, 0,
result = pcre_exec(compiled_regex, NULL, search_input, input_size + 1, 0, PCRE_PARTIAL,
ovector, sizeof(ovector) / sizeof(ovector[0]));
if (result > 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "not match end\n");
return 0;
}
if (result == PCRE_ERROR_PARTIAL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "partial match possible - not match end\n");
return 0;
}
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "is match end\n");
return 1;

View File

@ -11,8 +11,9 @@ static const char *adhearsion_menu_grammar =
" <one-of>\n"
" <item><tag>0</tag>1</item>\n"
" <item><tag>1</tag>5</item>\n"
" <item><tag>2</tag>7</item>\n"
" <item><tag>7</tag>7</item>\n"
" <item><tag>3</tag>9</item>\n"
" <item><tag>4</tag>715</item>\n"
" </one-of>\n"
" </rule>\n"
"</grammar>\n";
@ -43,8 +44,10 @@ static void test_match_adhearsion_menu_grammar(void)
ASSERT_STRING_EQUALS("1", interpretation);
ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "6", &interpretation));
ASSERT_NULL(interpretation);
ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "7", &interpretation));
ASSERT_STRING_EQUALS("2", interpretation);
ASSERT_EQUALS(SMT_MATCH, srgs_grammar_match(grammar, "7", &interpretation));
ASSERT_STRING_EQUALS("7", interpretation);
ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "715", &interpretation));
ASSERT_STRING_EQUALS("4", interpretation);
ASSERT_EQUALS(SMT_NO_MATCH, srgs_grammar_match(grammar, "8", &interpretation));
ASSERT_NULL(interpretation);
ASSERT_EQUALS(SMT_MATCH_END, srgs_grammar_match(grammar, "9", &interpretation));

View File

@ -95,6 +95,7 @@ typedef struct switch_rtp_engine_s {
switch_codec_implementation_t write_impl;
switch_size_t last_ts;
switch_size_t last_seq;
uint32_t check_frames;
uint32_t mismatch_count;
uint32_t last_codec_ms;
@ -1743,6 +1744,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_read_frame(switch_core_session
engine->check_frames = 0;
engine->last_ts = 0;
engine->last_seq = 0;
do_cng = 1;
}
@ -1869,8 +1871,14 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_read_frame(switch_core_session
uint32_t codec_ms = (int) (engine->read_frame.timestamp -
engine->last_ts) / (engine->read_impl.samples_per_second / 1000);
if (engine->last_seq && (int) (engine->read_frame.seq - engine->last_seq) > 1) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Correcting calculated ptime value from %d to %d to compensate for %d lost packet(s)\n", codec_ms, codec_ms / (int) (engine->read_frame.seq - engine->last_seq), (int) (engine->read_frame.seq - engine->last_seq - 1));
codec_ms = codec_ms / (int) (engine->read_frame.seq - engine->last_seq);
}
if ((codec_ms % 10) != 0 || codec_ms > engine->read_impl.samples_per_packet * 10) {
engine->last_ts = 0;
engine->last_seq = 0;
goto skip;
}
@ -1918,11 +1926,13 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_read_frame(switch_core_session
}
engine->last_ts = engine->read_frame.timestamp;
engine->last_seq = engine->read_frame.seq;
} else {
engine->mismatch_count = 0;
engine->last_ts = 0;
engine->last_seq = 0;
}
}
@ -4560,6 +4570,7 @@ SWITCH_DECLARE(void) switch_core_media_reset_autofix(switch_core_session_t *sess
engine->check_frames = 0;
engine->last_ts = 0;
engine->last_seq = 0;
}