]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[core] Add SMBF_FIRST flag which forces media bug to front of the list. Add 'f'...
authorChris Rienzo <chris@signalwire.com>
Tue, 24 Dec 2019 04:57:23 +0000 (23:57 -0500)
committerAndrey Volk <andywolk@gmail.com>
Mon, 30 Dec 2019 23:14:31 +0000 (03:14 +0400)
src/include/switch_types.h
src/include/test/switch_test.h
src/switch_core_media_bug.c
src/switch_ivr_async.c

index d1dde740db270ff8fb4df6ff8637809e2ad48771..4cfeb4231daa54fcd2b0dfda241c0e6b7ea1a356 100644 (file)
@@ -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;
 
index ffdc06412d893bc508d95427335bb88b4f949115..4e7fcfcd8ac65e173ebe8e2c0e2342688c1af675 100644 (file)
@@ -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); \
 }
index 727d2bccbeee70ff12a4fd4daeea0c64da0dfaba..a229f611e9d7c85dbfd5c592fad18929fc88f7a9 100644 (file)
@@ -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;
index ee23ccd79cc422b87d6595ffab3ea301b7fbdc73..db1bb1e4e54f28c896550e2ed49535ab93e18fb0 100644 (file)
@@ -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) {