From 5c5a0fe70bc731abf3a87cf343566b5cd4ae14ec Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 4 Apr 2006 22:03:59 +0000 Subject: [PATCH] add mod_commands git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1045 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- conf/freeswitch.conf | 1 + .../applications/mod_commands/mod_commands.c | 83 +++++++ .../mod_commands/mod_commands.vcproj | 209 ++++++++++++++++++ src/mod/endpoints/mod_exosip/mod_exosip.c | 12 +- 4 files changed, 304 insertions(+), 1 deletion(-) create mode 100644 src/mod/applications/mod_commands/mod_commands.c create mode 100644 src/mod/applications/mod_commands/mod_commands.vcproj diff --git a/conf/freeswitch.conf b/conf/freeswitch.conf index 59808ed813..7fd1d4aff4 100644 --- a/conf/freeswitch.conf +++ b/conf/freeswitch.conf @@ -32,6 +32,7 @@ load => mod_bridgecall load => mod_echo ;load => mod_ivrtest load => mod_playback +load => mod_commands ; Dialplan Interfaces load => mod_dialplan_demo diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c new file mode 100644 index 0000000000..eefa93c3c7 --- /dev/null +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -0,0 +1,83 @@ +/* + * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2005/2006, Anthony Minessale II + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * Anthony Minessale II + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Anthony Minessale II + * + * + * mod_commands.c -- Raw Audio File Streaming Application Module + * + */ +#include + +static const char modname[] = "mod_commands"; + + +static switch_status kill_function(char *dest, char *out, size_t outlen) +{ + switch_core_session *session = NULL; + + if ((session = switch_core_session_locate(dest))) { + switch_channel *channel = switch_core_session_get_channel(session); + switch_core_session_kill_channel(session, SWITCH_SIG_KILL); + switch_channel_hangup(channel); + snprintf(out, outlen, "OK\n"); + } else { + snprintf(out, outlen, "No Such Channel!\n"); + } + + return SWITCH_STATUS_SUCCESS; +} + + +static struct switch_api_interface commands_api_interface = { + /*.interface_name */ "killchan", + /*.desc */ "Kill Channel", + /*.function */ kill_function, + /*.next */ NULL +}; + + +static const switch_loadable_module_interface mod_commands_module_interface = { + /*.module_name */ modname, + /*.endpoint_interface */ NULL, + /*.timer_interface */ NULL, + /*.dialplan_interface */ NULL, + /*.codec_interface */ NULL, + /*.application_interface */ NULL, + /*.api_interface */ &commands_api_interface +}; + + +SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename) +{ + + /* connect my internal structure to the blank pointer passed to me */ + *interface = &mod_commands_module_interface; + + + /* indicate that the module should continue to be loaded */ + return SWITCH_STATUS_SUCCESS; +} + diff --git a/src/mod/applications/mod_commands/mod_commands.vcproj b/src/mod/applications/mod_commands/mod_commands.vcproj new file mode 100644 index 0000000000..b2b36a2b2c --- /dev/null +++ b/src/mod/applications/mod_commands/mod_commands.vcproj @@ -0,0 +1,209 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mod/endpoints/mod_exosip/mod_exosip.c b/src/mod/endpoints/mod_exosip/mod_exosip.c index f90a538143..72fa52c554 100644 --- a/src/mod/endpoints/mod_exosip/mod_exosip.c +++ b/src/mod/endpoints/mod_exosip/mod_exosip.c @@ -126,6 +126,7 @@ struct private_object { switch_queue_t *dtmf_queue; char out_digit; switch_time_t cng_next; + switch_time_t last_read; unsigned char out_digit_packet[4]; unsigned int out_digit_sofar; unsigned int out_digit_dur; @@ -551,7 +552,14 @@ static switch_status exosip_read_frame(switch_core_session *session, switch_fram } else { assert(0); } - + + if (tech_pvt->last_read) { + elapsed = (unsigned int)((switch_time_now() - tech_pvt->last_read) / 1000); + if (elapsed > 60000) { + return SWITCH_STATUS_TIMEOUT; + } + } + if (switch_test_flag(tech_pvt, TFLAG_IO)) { if (!switch_test_flag(tech_pvt, TFLAG_RTP)) { @@ -561,6 +569,7 @@ static switch_status exosip_read_frame(switch_core_session *session, switch_fram assert(tech_pvt->rtp_session != NULL); tech_pvt->read_frame.datalen = 0; + while (!switch_test_flag(tech_pvt, TFLAG_BYE) && switch_test_flag(tech_pvt, TFLAG_IO) && tech_pvt->read_frame.datalen == 0) { now = switch_time_now(); @@ -640,6 +649,7 @@ static switch_status exosip_read_frame(switch_core_session *session, switch_fram } if (tech_pvt->read_frame.datalen > 0) { + tech_pvt->last_read = switch_time_now(); bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame; frames = (tech_pvt->read_frame.datalen / bytes); samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;