提交 dac12439 authored 作者: Anthony Minessale's avatar Anthony Minessale

add playback_timeout_sec to core and make it useful in valet_parking

上级 6f41b446
...@@ -279,11 +279,18 @@ SWITCH_STANDARD_APP(valet_parking_function) ...@@ -279,11 +279,18 @@ SWITCH_STANDARD_APP(valet_parking_function)
args.buflen = sizeof(dbuf); args.buflen = sizeof(dbuf);
switch_mutex_unlock(lot->mutex); switch_mutex_unlock(lot->mutex);
if (!strcasecmp(music, "silence")) { if (!strcasecmp(music, "silence")) {
switch_ivr_collect_digits_callback(session, &args, 0, 0); music = "silence_stream://-1";
} else { }
switch_ivr_play_file(session, NULL, music, &args);
while(switch_channel_ready(channel)) {
switch_status_t pstatus = switch_ivr_play_file(session, NULL, music, &args);
if (pstatus == SWITCH_STATUS_BREAK || pstatus == SWITCH_STATUS_TIMEOUT) {
break;
}
} }
switch_mutex_lock(lot->mutex); switch_mutex_lock(lot->mutex);
switch_core_hash_delete(lot->hash, ext); switch_core_hash_delete(lot->hash, ext);
switch_mutex_unlock(lot->mutex); switch_mutex_unlock(lot->mutex);
......
...@@ -913,9 +913,18 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess ...@@ -913,9 +913,18 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
int argc; int argc;
int cur; int cur;
int done = 0; int done = 0;
int timeout_samples = 0;
const char *var;
switch_core_session_get_read_impl(session, &read_impl); switch_core_session_get_read_impl(session, &read_impl);
if ((var = switch_channel_get_variable(channel, "playback_timeout_sec"))) {
int tmp = atoi(var);
if (tmp > 1) {
timeout_samples = read_impl.actual_samples_per_second * tmp;
}
}
if ((play_delimiter_val = switch_channel_get_variable(channel, "playback_delimiter"))) { if ((play_delimiter_val = switch_channel_get_variable(channel, "playback_delimiter"))) {
play_delimiter = *play_delimiter_val; play_delimiter = *play_delimiter_val;
...@@ -1402,6 +1411,17 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess ...@@ -1402,6 +1411,17 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
fh->offset_pos += write_frame.samples / 2; fh->offset_pos += write_frame.samples / 2;
status = switch_core_session_write_frame(session, &write_frame, SWITCH_IO_FLAG_NONE, 0); status = switch_core_session_write_frame(session, &write_frame, SWITCH_IO_FLAG_NONE, 0);
if (timeout_samples) {
timeout_samples -= write_frame.samples;
if (timeout_samples <= 0) {
timeout_samples = 0;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "timeout reached playing file\n");
status = SWITCH_STATUS_TIMEOUT;
break;
}
}
if (status == SWITCH_STATUS_MORE_DATA) { if (status == SWITCH_STATUS_MORE_DATA) {
status = SWITCH_STATUS_SUCCESS; status = SWITCH_STATUS_SUCCESS;
continue; continue;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论