]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add api_on_answer var
authorAnthony Minessale <anthony.minessale@gmail.com>
Fri, 23 Oct 2009 15:01:34 +0000 (15:01 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Fri, 23 Oct 2009 15:01:34 +0000 (15:01 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15207 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_types.h
src/switch_channel.c

index 3312ebd497f553f330b600fdb3bac603275be5cc..70eed55e22c8886c9e4b658263dddd7ecacacbd7 100644 (file)
@@ -125,6 +125,7 @@ SWITCH_BEGIN_EXTERN_C
 #define SWITCH_CURRENT_APPLICATION_VARIABLE "current_application"
 #define SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE "proto_specific_hangup_cause"
 #define SWITCH_CHANNEL_EXECUTE_ON_ANSWER_VARIABLE "execute_on_answer"
+#define SWITCH_CHANNEL_API_ON_ANSWER_VARIABLE "api_on_answer"
 #define SWITCH_CHANNEL_EXECUTE_ON_RING_VARIABLE "execute_on_ring"
 #define SWITCH_CALL_TIMEOUT_VARIABLE "call_timeout"
 #define SWITCH_HOLDING_UUID_VARIABLE "holding_uuid"
index 1e2af783d4727a6e6b53226392fe22eaa491d8df..9f071854046ad8daa4b50e11cadc019ead34cea9 100644 (file)
@@ -2143,6 +2143,23 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_answered(switch_chan
                }
        }
 
+       if ((var = switch_channel_get_variable(channel, SWITCH_CHANNEL_API_ON_ANSWER_VARIABLE)) && !switch_strlen_zero(var)) {
+               switch_stream_handle_t stream = { 0 };
+               char *arg = NULL;
+
+               app = switch_core_session_strdup(channel->session, var);
+               if ((arg = strchr(app, ' '))) {
+                       *arg++ = '\0';
+               }
+
+               SWITCH_STANDARD_STREAM(stream);
+               switch_api_execute(app, arg, NULL, &stream);
+
+               switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "%s api on answer: %s(%s)\n%s\n", 
+                                                 channel->name, app, switch_str_nil(arg), (char *)stream.data);
+               free(stream.data);
+       }
+
        switch_channel_audio_sync(channel);
 
        return SWITCH_STATUS_SUCCESS;