diff --git a/src/include/switch_types.h b/src/include/switch_types.h index d1dde740db..4cfeb4231d 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -1894,7 +1894,8 @@ typedef enum { SMBF_SPY_VIDEO_STREAM = (1 << 22), SMBF_SPY_VIDEO_STREAM_BLEG = (1 << 23), SMBF_READ_VIDEO_PATCH = (1 << 24), - SMBF_READ_TEXT_STREAM = (1 << 25) + SMBF_READ_TEXT_STREAM = (1 << 25), + SMBF_FIRST = (1 << 26) } switch_media_bug_flag_enum_t; typedef uint32_t switch_media_bug_flag_t; diff --git a/src/include/test/switch_test.h b/src/include/test/switch_test.h index ffdc06412d..4e7fcfcd8a 100644 --- a/src/include/test/switch_test.h +++ b/src/include/test/switch_test.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2018, Anthony Minessale II + * Copyright (C) 2005-2019, Anthony Minessale II * * Version: MPL 1.1 * @@ -699,7 +699,7 @@ static switch_status_t fst_init_core_and_modload(const char *confdir, const char fst_requires(fst_core > 1); \ fst_requires_module("mod_dptools"); \ switch_channel_set_variable(fst_channel, "detect_speech_result", ""); \ - fst_requires(switch_ivr_displace_session(fst_session, input_filename, 0, "mr") == SWITCH_STATUS_SUCCESS); \ + fst_requires(switch_ivr_displace_session(fst_session, input_filename, 0, "mrf") == SWITCH_STATUS_SUCCESS); \ args = switch_core_session_sprintf(fst_session, "%s detect:%s %s", prompt_filename, recognizer, grammar); \ fst_requires(switch_core_session_execute_application(fst_session, "play_and_detect_speech", args) == SWITCH_STATUS_SUCCESS); \ fst_asr_result = switch_channel_get_variable(fst_channel, "detect_speech_result"); \ @@ -729,7 +729,7 @@ static switch_status_t fst_init_core_and_modload(const char *confdir, const char char *args = NULL; \ fst_asr_result = NULL; \ fst_requires(fst_core > 1); \ - fst_requires(switch_ivr_displace_session(fst_session, input_filename, 0, "mr") == SWITCH_STATUS_SUCCESS); \ + fst_requires(switch_ivr_displace_session(fst_session, input_filename, 0, "mrf") == SWITCH_STATUS_SUCCESS); \ switch_status_t status = switch_ivr_play_and_detect_speech(fst_session, prompt_filename, recognizer, grammar, (char **)&fst_asr_result, 0, input_args); \ fst_check(fst_asr_result != NULL); \ } diff --git a/src/switch_core_media_bug.c b/src/switch_core_media_bug.c index 727d2bccbe..a229f611e9 100644 --- a/src/switch_core_media_bug.c +++ b/src/switch_core_media_bug.c @@ -974,7 +974,13 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(switch_core_session_t session->bugs = bug; added = 1; } - + + if (!added && switch_test_flag(bug, SMBF_FIRST)) { + bug->next = session->bugs; + session->bugs = bug; + added = 1; + } + for(bp = session->bugs; bp; bp = bp->next) { if (bp->ready && !switch_test_flag(bp, SMBF_TAP_NATIVE_READ) && !switch_test_flag(bp, SMBF_TAP_NATIVE_WRITE)) { tap_only = 0; diff --git a/src/switch_ivr_async.c b/src/switch_ivr_async.c index ee23ccd79c..db1bb1e4e5 100644 --- a/src/switch_ivr_async.c +++ b/src/switch_ivr_async.c @@ -1007,6 +1007,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_displace_session(switch_core_session_ displace_helper_t *dh; const char *p; switch_bool_t hangup_on_error = SWITCH_FALSE; + switch_media_bug_flag_enum_t bug_flags = 0; switch_codec_implementation_t read_impl = { 0 }; switch_core_session_get_read_impl(session, &read_impl); @@ -1092,6 +1093,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_displace_session(switch_core_session_ dh->loop++; } + if (flags && strchr(flags, 'f')) { + bug_flags |= SMBF_FIRST; + } + if (flags && strchr(flags, 'r')) { if (strchr(flags, 'w')) { // r&w mode, both sides can hear the same file int len = dh->fh.samplerate / 10 * 2 * dh->fh.channels; // init with 100ms @@ -1101,10 +1106,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_displace_session(switch_core_session_ } status = switch_core_media_bug_add(session, "displace", file, - read_displace_callback, dh, to, SMBF_WRITE_REPLACE | SMBF_READ_REPLACE | SMBF_NO_PAUSE, &bug); + read_displace_callback, dh, to, bug_flags | SMBF_WRITE_REPLACE | SMBF_READ_REPLACE | SMBF_NO_PAUSE, &bug); } else { status = switch_core_media_bug_add(session, "displace", file, - write_displace_callback, dh, to, SMBF_WRITE_REPLACE | SMBF_READ_REPLACE | SMBF_NO_PAUSE, &bug); + write_displace_callback, dh, to, bug_flags | SMBF_WRITE_REPLACE | SMBF_READ_REPLACE | SMBF_NO_PAUSE, &bug); } if (status != SWITCH_STATUS_SUCCESS) {