[core] Add SMBF_FIRST flag which forces media bug to front of the list. Add 'f' flag to switch_ivr_displace_session to add displace as first operation on the media stream. (#76)
This commit is contained in:
parent
6f0ad146d2
commit
9c3f9a9a50
|
@ -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;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2018, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2019, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* 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); \
|
||||
}
|
||||
|
|
|
@ -975,6 +975,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(switch_core_session_t
|
|||
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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue