From 45fb1725b0687ce1ab7d4bce5ff61c44bdfd6afd Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Mon, 9 May 2011 01:25:24 -0400 Subject: [PATCH] added uuid_outgoing_answer to answer outgoing channels (ie portaudio endpoints) --- .../applications/mod_commands/mod_commands.c | 29 +++++++++++++++++++ .../endpoints/mod_portaudio/mod_portaudio.c | 8 +++++ 2 files changed, 37 insertions(+) diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index a6df087cb0..4a3502b35b 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -2047,6 +2047,34 @@ SWITCH_STANDARD_API(kill_function) return SWITCH_STATUS_SUCCESS; } +#define OUTGOING_ANSWER_SYNTAX "" +SWITCH_STANDARD_API(outgoing_answer_function) +{ + switch_core_session_t *asession = NULL; + char *mycmd = NULL; + + if (zstr(cmd) || !(mycmd = strdup(cmd))) { + stream->write_function(stream, "-USAGE: %s\n", OUTGOING_ANSWER_SYNTAX); + return SWITCH_STATUS_SUCCESS; + } + + if (zstr(mycmd) || !(asession = switch_core_session_locate(mycmd))) { + stream->write_function(stream, "-ERR No Such Channel!\n"); + } else { + switch_channel_t *channel = switch_core_session_get_channel(asession); + if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) { + switch_channel_mark_answered(channel); + stream->write_function(stream, "+OK\n"); + } else { + stream->write_function(stream, "-ERR Not an outbound channel!\n"); + } + switch_core_session_rwunlock(session); + } + + switch_safe_free(mycmd); + return SWITCH_STATUS_SUCCESS; +} + #define PREPROCESS_SYNTAX "<>" SWITCH_STANDARD_API(preprocess_function) { @@ -5063,6 +5091,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load) SWITCH_ADD_API(commands_api_interface, "uuid_getvar", "uuid_getvar", uuid_getvar_function, GETVAR_SYNTAX); SWITCH_ADD_API(commands_api_interface, "uuid_hold", "hold", uuid_hold_function, HOLD_SYNTAX); SWITCH_ADD_API(commands_api_interface, "uuid_kill", "Kill Channel", kill_function, KILL_SYNTAX); + SWITCH_ADD_API(commands_api_interface, "uuid_outgoing_answer", "Answer Outgoing Channel", outgoing_answer_function, OUTGOING_ANSWER_SYNTAX); SWITCH_ADD_API(commands_api_interface, "uuid_limit_release", "Release limit resource", uuid_limit_release_function, LIMIT_RELEASE_SYNTAX); SWITCH_ADD_API(commands_api_interface, "uuid_loglevel", "set loglevel on session", uuid_loglevel, UUID_LOGLEVEL_SYNTAX); SWITCH_ADD_API(commands_api_interface, "uuid_media", "media", uuid_media_function, MEDIA_SYNTAX); diff --git a/src/mod/endpoints/mod_portaudio/mod_portaudio.c b/src/mod/endpoints/mod_portaudio/mod_portaudio.c index 643daab445..079c5af8a2 100644 --- a/src/mod/endpoints/mod_portaudio/mod_portaudio.c +++ b/src/mod/endpoints/mod_portaudio/mod_portaudio.c @@ -319,8 +319,15 @@ static switch_status_t channel_on_routing(switch_core_session_t *session) } if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND) && !switch_test_flag(tech_pvt, TFLAG_AUTO_ANSWER)) { + add_pvt(tech_pvt, PA_SLAVE); + /* endpoints do not ring (yet) */ + if (tech_pvt->audio_endpoint) { + ring_file = NULL; + goto endpoint_noring; + } + ring_file = globals.ring_file; if ((val = switch_channel_get_variable(channel, "pa_ring_file"))) { ring_file = val; @@ -349,6 +356,7 @@ static switch_status_t channel_on_routing(switch_core_session_t *session) } } } +endpoint_noring: if (switch_test_flag(tech_pvt, TFLAG_AUTO_ANSWER)) { switch_mutex_lock(globals.pvt_lock);