]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add read_frame_callback to input args in the core
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 2 Oct 2007 00:09:49 +0000 (00:09 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 2 Oct 2007 00:09:49 +0000 (00:09 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5777 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_types.h
src/switch_ivr_bridge.c
src/switch_ivr_play_say.c

index f02eaeb09c54528259feeb40533f5da2dc9171e2..9eb8fe3c821f7f454560f1494453a7a531c00407 100644 (file)
@@ -1082,11 +1082,14 @@ typedef switch_status_t (*switch_api_function_t) (const char *cmd, switch_core_s
 
 typedef switch_status_t (*switch_input_callback_function_t) (switch_core_session_t *session, void *input,
                                                                                                                         switch_input_type_t input_type, void *buf, unsigned int buflen);
+typedef switch_status_t (*switch_read_frame_callback_function_t) (switch_core_session_t *session, switch_frame_t *frame, void *user_data);
 typedef struct switch_say_interface switch_say_interface_t;
 typedef struct {
        switch_input_callback_function_t input_callback;
        void *buf;
        uint32_t buflen;
+       switch_read_frame_callback_function_t read_frame_callback;
+       void *user_data;
 } switch_input_args_t;
 typedef switch_status_t (*switch_say_callback_t) (switch_core_session_t *session,
                                                                                                  char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args);
index 53f1037d88e3ca35ac461ff2bf4a57c1b2ef6fd2..3077fafc7c8afb3d4249bc592740cd1e2292b08a 100644 (file)
@@ -119,13 +119,14 @@ static void *audio_bridge_thread(switch_thread_t * thread, void *obj)
                if (switch_channel_has_dtmf(chan_a)) {
                        char dtmf[128];
                        switch_channel_dequeue_dtmf(chan_a, dtmf, sizeof(dtmf));
-                       switch_core_session_send_dtmf(session_b, dtmf);
                        if (input_callback) {
                                if (input_callback(session_a, dtmf, SWITCH_INPUT_TYPE_DTMF, user_data, 0) != SWITCH_STATUS_SUCCESS) {
                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s ended call via DTMF\n", switch_channel_get_name(chan_a));
+                                       switch_core_session_kill_channel(session_b, SWITCH_SIG_BREAK);
                                        break;
                                }
                        }
+                       switch_core_session_send_dtmf(session_b, dtmf);
                }
 
                if (switch_core_session_dequeue_event(session_a, &event) == SWITCH_STATUS_SUCCESS) {
@@ -219,7 +220,6 @@ static void *audio_bridge_thread(switch_thread_t * thread, void *obj)
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "BRIDGE THREAD DONE [%s]\n", switch_channel_get_name(chan_a));
        switch_channel_clear_flag(chan_a, CF_BRIDGED);
        switch_core_session_rwunlock(session_b);
-
        return NULL;
 }
 
@@ -245,7 +245,7 @@ static switch_status_t audio_bridge_on_loopback(switch_core_session_t *session)
 
        if (!switch_channel_test_flag(channel, CF_TRANSFER)) {
                switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
-       }
+       } 
 
        return SWITCH_STATUS_FALSE;
 }
index 7d7fd312ab9a4f96325fb6958a8908a052779c97..dfaa1f85153b2be5b57f0e931e1c325bcab28ab3 100644 (file)
@@ -449,6 +449,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
                        break;
                }
 
+               if (args && (args->read_frame_callback)) {
+                       if (args->read_frame_callback(session, read_frame, args->user_data) != SWITCH_STATUS_SUCCESS) {
+                               break;
+                       }
+               }
+
                if (fh->thresh) {
                        int16_t *fdata = (int16_t *) read_frame->data;
                        uint32_t samples = read_frame->datalen / sizeof(*fdata);
@@ -564,6 +570,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_gentones(switch_core_session_t *sessi
                        continue;
                }
 
+               if (args && (args->read_frame_callback)) {
+                       if (args->read_frame_callback(session, read_frame, args->user_data) != SWITCH_STATUS_SUCCESS) {
+                               break;
+                       }
+               }
+
                if ((write_frame.datalen = (uint32_t) switch_buffer_read_loop(audio_buffer, write_frame.data,
                                                                                                                                          read_frame->codec->implementation->bytes_per_frame)) <= 0) {
                        break;
@@ -997,6 +1009,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
                        if (!SWITCH_READ_ACCEPTABLE(status)) {
                                break;
                        }
+
+                       if (args && (args->read_frame_callback)) {
+                               if (args->read_frame_callback(session, read_frame, args->user_data) != SWITCH_STATUS_SUCCESS) {
+                                       break;
+                               }
+                       }
                }
        }
 
@@ -1266,6 +1284,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text_handle(switch_core_session
                                if (!SWITCH_READ_ACCEPTABLE(status)) {
                                        break;
                                }
+
+                               if (args && (args->read_frame_callback)) {
+                                       if (args->read_frame_callback(session, read_frame, args->user_data) != SWITCH_STATUS_SUCCESS) {
+                                               break;
+                                       }
+                               }
                        }
                        continue;
                }
@@ -1323,6 +1347,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text_handle(switch_core_session
                        if (!SWITCH_READ_ACCEPTABLE(status)) {
                                break;
                        }
+
+                       if (args && (args->read_frame_callback)) {
+                               if (args->read_frame_callback(session, read_frame, args->user_data) != SWITCH_STATUS_SUCCESS) {
+                                       break;
+                               }
+                       }
                }
 
        }