]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-8983 [avmd] Enable avmd on outbound channel
authorPiotr Gregor <piotrek.gregor@gmail.com>
Mon, 28 Mar 2016 00:46:02 +0000 (01:46 +0100)
committerPiotr Gregor <piotrek.gregor@gmail.com>
Mon, 28 Mar 2016 01:51:07 +0000 (02:51 +0100)
It is possible now to do avmd on outgoing channel
which is very handy while debugging.

src/mod/applications/mod_avmd/mod_avmd.c
src/mod/applications/mod_avmd/options.h

index a50c8b6f96933cb594ef3c9c2003f1a80f828a1b..e7f56d06d0ff9b4c5f8b833d04a71dbe0eeb1b1f 100644 (file)
@@ -26,8 +26,8 @@
  * This module detects voicemail beeps using a generalized approach.
  *
  * Modifications:
- *      Piotr Gregor <piotrek.gregor@gmail.com>:
- *      FS-8808, FS-8809, FS-8810, FS-8852, FS-8853, FS-8854, FS-8855
+ *      Piotr Gregor <piotrek.gregor gmail.com>:
+ *      FS-8808, FS-8809, FS-8810, FS-8852, FS-8853, FS-8854, FS-8855, FS-8860, FS-8861
  */
 
 #include <switch.h>
@@ -225,7 +225,9 @@ static switch_bool_t avmd_callback(switch_media_bug_t * bug, void *user_data, sw
                return SWITCH_TRUE;
 
        case SWITCH_ABC_TYPE_WRITE_REPLACE:
-               break;
+               frame = switch_core_media_bug_get_write_replace_frame(bug);
+               avmd_process(avmd_session, frame);
+               return SWITCH_TRUE;
 
        default:
                break;
@@ -356,6 +358,7 @@ SWITCH_STANDARD_APP(avmd_start_function)
        switch_status_t status;
        switch_channel_t *channel;
        avmd_session_t *avmd_session;
+    switch_media_bug_flag_t flags = 0;
 
        if (session == NULL)
                return;
@@ -387,6 +390,14 @@ SWITCH_STANDARD_APP(avmd_start_function)
 
        init_avmd_session_data(avmd_session, session);
 
+#ifdef AVMD_INBOUND_CHANNEL
+    flags |= SMBF_READ_REPLACE;
+#endif
+#ifdef AVMD_OUTBOUND_CHANNEL
+    flags |= SMBF_WRITE_REPLACE;
+#endif
+    switch_assert(flags != 0);
+
        status = switch_core_media_bug_add(
                session,
                "avmd",
@@ -394,7 +405,7 @@ SWITCH_STANDARD_APP(avmd_start_function)
                avmd_callback,
                avmd_session,
                0,
-               SMBF_READ_REPLACE,
+               flags,
                &bug
                );
 
@@ -476,6 +487,7 @@ SWITCH_STANDARD_API(avmd_api_main)
        char *ccmd = NULL;
        char *uuid;
        char *command;
+    switch_core_media_flag_t flags = 0;
 
        /* No command? Display usage */
        if (zstr(cmd)) {
@@ -546,6 +558,14 @@ SWITCH_STANDARD_API(avmd_api_main)
 
        init_avmd_session_data(avmd_session, fs_session);
 
+#ifdef AVMD_INBOUND_CHANNEL
+    flags |= SMBF_READ_REPLACE;
+#endif
+#ifdef AVMD_OUTBOUND_CHANNEL
+    flags |= SMBF_WRITE_REPLACE;
+#endif
+    switch_assert(flags != 0);
+
        /* Add a media bug that allows me to intercept the
        * reading leg of the audio stream */
        status = switch_core_media_bug_add(
@@ -555,7 +575,7 @@ SWITCH_STANDARD_API(avmd_api_main)
                avmd_callback,
                avmd_session,
                0,
-               SMBF_READ_REPLACE,
+               flags,
                &bug
                );
 
@@ -704,7 +724,6 @@ static void avmd_process(avmd_session_t *session, switch_frame_t *frame)
 
                                return;
             }
-
                        //amp = 0.0;
                        //success = 0.0;
                        //error = 0.0;
index 39274a52c9e53a46d4791eee470a0771e5250a5e..33a32381d7a1c22c98fec5b718e2e1a30310c6e5 100644 (file)
@@ -6,8 +6,8 @@
  */
 
 
-#ifndef __OPTIONS_H__
-#define __OPTIONS_H__
+#ifndef __AVMD_OPTIONS_H__
+#define __AVMD_OPTIONS_H__
 
 
 /* #define AVMD_DEBUG 1 */
 /* define/undefine this to enable/disable faster computation
  * of arcus cosine - table will be created mapping floats
  * to integers and returning arc cos values given these integer
- * indexes into table */
+ * indices into table */
 /* #define AVMD_FAST_MATH */
 
 /* define/undefine this to classify avmd beep detection as valid
  * only when there is required number of consecutive elements
  * in the SMA buffer without reset */
-#define AVMD_REQUIRE_CONTINUOUS_STREAK 1
+#define AVMD_REQUIRE_CONTINUOUS_STREAK 5
 
+/* define/undefine to enable/disable avmd on incoming audio */
+#define AVMD_INBOUND_CHANNEL
 
-#endif
+/* define/undefine to enable/disable avmd on outgoing audio */
+/*#define AVMD_OUTBOUND_CHANNEL*/
+
+
+#endif /* __AVMD_OPTIONS_H__ */