Merge pull request #182 from signalwire/core_fixes
[Core] Fix hard coded dtmf durations based on 8k, fix short-circuit in write timestamp calc
This commit is contained in:
commit
0c90ab01e5
|
@ -1127,6 +1127,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf_string(switch_core
|
||||||
int i, argc;
|
int i, argc;
|
||||||
char *argv[256];
|
char *argv[256];
|
||||||
int dur_total = 0;
|
int dur_total = 0;
|
||||||
|
int rate_mult = 8;
|
||||||
|
|
||||||
|
switch_codec_implementation_t write_impl = { 0 };
|
||||||
|
|
||||||
switch_assert(session != NULL);
|
switch_assert(session != NULL);
|
||||||
|
|
||||||
|
@ -1156,13 +1159,16 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf_string(switch_core
|
||||||
switch_channel_pre_answer(session->channel);
|
switch_channel_pre_answer(session->channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch_core_session_get_write_impl(session, &write_impl);
|
||||||
|
rate_mult = (write_impl.actual_samples_per_second / 1000);
|
||||||
|
|
||||||
for (i = 0; i < argc; i++) {
|
for (i = 0; i < argc; i++) {
|
||||||
dtmf.duration = switch_core_default_dtmf_duration(0);
|
dtmf.duration = switch_core_default_dtmf_duration(0);
|
||||||
dur = switch_core_default_dtmf_duration(0) / 8;
|
dur = switch_core_default_dtmf_duration(0) / rate_mult;
|
||||||
if ((p = strchr(argv[i], '@'))) {
|
if ((p = strchr(argv[i], '@'))) {
|
||||||
*p++ = '\0';
|
*p++ = '\0';
|
||||||
if ((dur = atoi(p)) > (int)switch_core_min_dtmf_duration(0) / 8) {
|
if ((dur = atoi(p)) > (int)switch_core_min_dtmf_duration(0) / rate_mult) {
|
||||||
dtmf.duration = dur * 8;
|
dtmf.duration = dur * rate_mult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1192,14 +1198,14 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf_string(switch_core
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s send dtmf\ndigit=%c ms=%u samples=%u\n",
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s send dtmf\ndigit=%c ms=%u samples=%u\n",
|
||||||
switch_channel_get_name(session->channel), dtmf.digit, dur, dtmf.duration);
|
switch_channel_get_name(session->channel), dtmf.digit, dur, dtmf.duration);
|
||||||
sent++;
|
sent++;
|
||||||
dur_total += dtmf.duration + 2000; /* account for 250ms pause */
|
dur_total += dtmf.duration + (250 * rate_mult); /* account for 250ms pause */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dur_total) {
|
if (dur_total) {
|
||||||
char tmp[32] = "";
|
char tmp[32] = "";
|
||||||
switch_snprintf(tmp, sizeof(tmp), "%d", dur_total / 8);
|
switch_snprintf(tmp, sizeof(tmp), "%d", dur_total / rate_mult);
|
||||||
switch_channel_set_variable(session->channel, "last_dtmf_duration", tmp);
|
switch_channel_set_variable(session->channel, "last_dtmf_duration", tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9039,7 +9039,6 @@ SWITCH_DECLARE(int) switch_rtp_write_frame(switch_rtp_t *rtp_session, switch_fra
|
||||||
data = frame->data;
|
data = frame->data;
|
||||||
len = frame->datalen;
|
len = frame->datalen;
|
||||||
ts = rtp_session->flags[SWITCH_RTP_FLAG_RAW_WRITE] ? (uint32_t) frame->timestamp : 0;
|
ts = rtp_session->flags[SWITCH_RTP_FLAG_RAW_WRITE] ? (uint32_t) frame->timestamp : 0;
|
||||||
if (!ts) ts = rtp_session->last_write_ts + rtp_session->samples_per_interval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue