]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add SMBF_ONE_ONLY flag and use it on dtmf detectors
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 27 Mar 2013 22:19:40 +0000 (17:19 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Wed, 27 Mar 2013 22:19:40 +0000 (17:19 -0500)
src/include/switch_types.h
src/mod/applications/mod_spandsp/mod_spandsp_dsp.c
src/switch_core_media_bug.c
src/switch_ivr_async.c

index 9f89289d866d24c55ee7239192a9dda76a58c0ec..903d083ccb091075751578f83027653d8d5bf253 100644 (file)
@@ -1510,7 +1510,8 @@ typedef enum {
        SMBF_STEREO_SWAP = (1 << 11),
        SMBF_LOCK = (1 << 12),
        SMBF_TAP_NATIVE_READ = (1 << 13),
-       SMBF_TAP_NATIVE_WRITE = (1 << 14)
+       SMBF_TAP_NATIVE_WRITE = (1 << 14),
+       SMBF_ONE_ONLY = (1 << 15)
 } switch_media_bug_flag_enum_t;
 typedef uint32_t switch_media_bug_flag_t;
 
index 906d7787e6e6427b031ecbfd2d76db028166ab51..eec68dce91c39b1d18176155e018288bf8d52a80 100644 (file)
@@ -505,7 +505,7 @@ switch_status_t spandsp_inband_dtmf_session(switch_core_session_t *session)
        }
 
        if ((status = switch_core_media_bug_add(session, "spandsp_dtmf_detect", NULL,
-                                               inband_dtmf_callback, pvt, 0, SMBF_READ_REPLACE | SMBF_NO_PAUSE, &bug)) != SWITCH_STATUS_SUCCESS) {
+                                               inband_dtmf_callback, pvt, 0, SMBF_READ_REPLACE | SMBF_NO_PAUSE | SMBF_ONE_ONLY, &bug)) != SWITCH_STATUS_SUCCESS) {
                return status;
        }
 
index 9999c644e73a26828d9e51cd49fe9c824b86e2e8..c340b71e634ac8f8f6d771467de7b06590f6a80c 100644 (file)
@@ -411,10 +411,28 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(switch_core_session_t
        switch_media_bug_t *bug, *bp;
        switch_size_t bytes;
        switch_event_t *event;
-       int tap_only = 1;
+       int tap_only = 1, punt = 0;
 
        const char *p;
 
+       if (!zstr(function)) {
+               if ((flags & SMBF_ONE_ONLY)) {
+                       switch_thread_rwlock_wrlock(session->bug_rwlock);
+                       for (bp = session->bugs; bp; bp = bp->next) {
+                               if (!zstr(bp->function) && !strcasecmp(function, bp->function)) {
+                                       punt = 1;
+                                       break;
+                               } 
+                       }
+                       switch_thread_rwlock_unlock(session->bug_rwlock);
+               }
+       }
+       
+       if (punt) {
+               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Only one bug of this type allowed!\n");
+       }
+
+
        if (!switch_channel_media_ready(session->channel)) {
                if (switch_channel_pre_answer(session->channel) != SWITCH_STATUS_SUCCESS) {
                        return SWITCH_STATUS_FALSE;
index e2ef526af8ce3840edc657c769e3dea3a42fbb49..45d771183563149d915fc60e9a4e8344188fa0da 100644 (file)
@@ -2588,7 +2588,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_inband_dtmf_session(switch_core_sessi
        }
 
        if ((status = switch_core_media_bug_add(session, "inband_dtmf", NULL,
-                                                                                       inband_dtmf_callback, pvt, 0, SMBF_READ_REPLACE | SMBF_NO_PAUSE, &bug)) != SWITCH_STATUS_SUCCESS) {
+                                                                                       inband_dtmf_callback, pvt, 0, SMBF_READ_REPLACE | SMBF_NO_PAUSE | SMBF_ONE_ONLY, &bug)) != SWITCH_STATUS_SUCCESS) {
                return status;
        }