--- /dev/null
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2005/2006, Anthony Minessale II <anthmct@yahoo.com>
+ *
+ * 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 <anthmct@yahoo.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Anthony Minessale II <anthmct@yahoo.com>
+ *
+ *
+ * mod_rss.c -- RSS Browser
+ *
+ */
+#include <switch.h>
+
+static const char modname[] = "mod_rss";
+
+
+/* helper object */
+struct dtmf_buffer {
+ char *data;
+ char *front;
+ uint32_t len;
+ uint32_t size;
+ switch_file_handle_t fh;
+};
+
+/*
+ dtmf handler function you can hook up to be executed when a digit is dialed during playback
+ if you return anything but SWITCH_STATUS_SUCCESS the playback will stop.
+*/
+static switch_status_t on_dtmf(switch_core_session_t *session, char *dtmf, void *buf, unsigned int buflen)
+{
+
+ struct dtmf_buffer *dtb;
+ uint32_t len, slen;
+ dtb = (struct dtmf_buffer *) buf;
+ uint32_t samps = 0, pos = 0;
+
+ if (*dtmf == '#') {
+ return SWITCH_STATUS_FALSE;
+ }
+
+ len = dtb->size - dtb->len;
+ slen = strlen(dtmf);
+
+ if (slen > len) {
+ slen = len;
+ }
+
+ switch_copy_string(dtb->front, dtmf, len);
+ dtb->front += slen;
+ dtb->len += slen;
+
+ if (dtb->len == 2) {
+ if (*dtb->data == '*') {
+ printf("%s\n", dtb->data);
+ dtb->front = dtb->data;
+ dtb->len = 0;
+ *dtb->data = '\0';
+ switch(*(dtb->data+1)) {
+ case '0':
+ dtb->fh.speed = 0;
+ break;
+ case '1':
+ dtb->fh.speed++;
+ break;
+ case '2':
+ dtb->fh.speed--;
+ break;
+ case '5':
+ {
+ switch_codec_t *codec = switch_core_session_get_read_codec(session);
+ samps = 5000 * (codec->implementation->samples_per_second / 1000);
+ switch_core_file_seek(&dtb->fh, &pos, samps, SEEK_CUR);
+ }
+ break;
+ case '4':
+ {
+ int32_t lpos = 0;
+ switch_codec_t *codec = switch_core_session_get_read_codec(session);
+
+ samps = 5000 * (codec->implementation->samples_per_second / 1000);
+ lpos = (int) dtb->fh.pos - samps;
+ if (lpos < 0) {
+ lpos = 0;
+ }
+ switch_core_file_seek(&dtb->fh, &pos, lpos, SEEK_SET);
+ }
+ break;
+ case '*':
+ if (switch_test_flag(&dtb->fh, SWITCH_FILE_PAUSE)) {
+ switch_clear_flag(&dtb->fh, SWITCH_FILE_PAUSE);
+ } else {
+ switch_set_flag(&dtb->fh, SWITCH_FILE_PAUSE);
+ }
+ break;
+ }
+
+ return SWITCH_STATUS_SUCCESS;
+ }
+ return SWITCH_STATUS_BREAK;
+ }
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
+
+static void rss_function(switch_core_session_t *session, char *data)
+{
+ switch_channel_t *channel;
+ uint8_t index = 0;
+ char fname[512];
+ switch_status_t status;
+ char buf[10];
+ struct dtmf_buffer dtb;
+
+
+ dtb.data = buf;
+ dtb.front = buf;
+ dtb.len = 0;
+ dtb.size = sizeof(buf);
+
+ channel = switch_core_session_get_channel(session);
+ assert(channel != NULL);
+
+ if (switch_strlen_zero(data)) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "No Path Specified!\n");
+ return;
+ }
+
+ switch_channel_answer(channel);
+
+ while(switch_channel_ready(channel)) {
+ snprintf(fname, sizeof(fname), "%s/%.2u.raw", data, index);
+ memset(&dtb.fh, 0, sizeof(dtb.fh));
+ if ((status = switch_ivr_play_file(session, &dtb.fh, fname, NULL, on_dtmf, &dtb, sizeof(dtb))) == SWITCH_STATUS_FALSE) {
+ break;
+ }
+
+ index = atoi(buf);
+
+ /* reset for next loop */
+ *buf = '\0';
+ dtb.front = buf;
+ dtb.len = 0;
+ }
+
+
+
+}
+
+static const switch_application_interface_t rss_application_interface = {
+ /*.interface_name */ "rss",
+ /*.application_function */ rss_function,
+ NULL, NULL, NULL,
+ /*.next*/ NULL
+};
+
+
+static switch_loadable_module_interface_t rss_module_interface = {
+ /*.module_name */ modname,
+ /*.endpoint_interface */ NULL,
+ /*.timer_interface */ NULL,
+ /*.dialplan_interface */ NULL,
+ /*.codec_interface */ NULL,
+ /*.application_interface */ &rss_application_interface,
+ /*.api_interface */ NULL,
+ /*.file_interface */ NULL,
+ /*.speech_interface */ NULL,
+ /*.directory_interface */ NULL
+};
+
+
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
+{
+ /* connect my internal structure to the blank pointer passed to me */
+ *module_interface = &rss_module_interface;
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hello World!\n");
+
+ /* indicate that the module should continue to be loaded */
+ return SWITCH_STATUS_SUCCESS;
+}
+
+/*
+ Called when the system shuts down
+ SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void)
+ {
+ return SWITCH_STATUS_SUCCESS;
+ }
+*/
+
+/*
+ If it exists, this is called in it's own thread when the module-load completes
+ SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void)
+ {
+ return SWITCH_STATUS_SUCCESS;
+ }
+*/
/* -------- TYPES TABLE (BEGIN) -------- */
-#define SWIGTYPE_p_switch_core_session swig_types[0]
-static swig_type_info *swig_types[2];
-static swig_module_info swig_module = {swig_types, 1, 0, 0, 0, 0};
+#define SWIGTYPE_p_switch_core_session_t swig_types[0]
+#define SWIGTYPE_p_switch_dtmf_callback_function_t swig_types[1]
+static swig_type_info *swig_types[3];
+static swig_module_info swig_module = {swig_types, 2, 0, 0, 0, 0};
#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
SWIGEXPORT void SWIG_init (CV *cv, CPerlObj *);
#endif
+
+#include <switch.h>
+
#ifdef PERL_OBJECT
#define MAGIC_CLASS _wrap_fs_perl_var::
class _wrap_fs_perl_var : public CPerlObj {
int argvi = 0;
dXSARGS;
+ if ((items < 0) || (items > 0)) {
+ SWIG_croak("Usage: fs_core_set_globals();");
+ }
fs_core_set_globals();
int argvi = 0;
dXSARGS;
+ if ((items < 0) || (items > 0)) {
+ SWIG_croak("Usage: fs_core_destroy();");
+ }
result = (int)fs_core_destroy();
ST(argvi) = sv_newmortal();
int argvi = 0;
dXSARGS;
+ if ((items < 0) || (items > 0)) {
+ SWIG_croak("Usage: fs_loadable_module_init();");
+ }
result = (int)fs_loadable_module_init();
ST(argvi) = sv_newmortal();
int argvi = 0;
dXSARGS;
+ if ((items < 0) || (items > 0)) {
+ SWIG_croak("Usage: fs_loadable_module_shutdown();");
+ }
result = (int)fs_loadable_module_shutdown();
ST(argvi) = sv_newmortal();
int argvi = 0;
dXSARGS;
-
+ if ((items < 0) || (items > 0)) {
+ SWIG_croak("Usage: fs_console_loop();");
+ }
result = (int)fs_console_loop();
ST(argvi) = sv_newmortal();
XS(_wrap_fs_core_session_locate) {
{
char *arg1 = (char *) 0 ;
- struct switch_core_session *result;
+ switch_core_session_t *result;
int argvi = 0;
dXSARGS;
}
if (!SvOK((SV*) ST(0))) arg1 = 0;
else arg1 = (char *) SvPV(ST(0), PL_na);
- result = (struct switch_core_session *)fs_core_session_locate(arg1);
+ result = (switch_core_session_t *)fs_core_session_locate(arg1);
ST(argvi) = sv_newmortal();
- SWIG_MakePtr(ST(argvi++), (void *) result, SWIGTYPE_p_switch_core_session, 0|0);
+ SWIG_MakePtr(ST(argvi++), (void *) result, SWIGTYPE_p_switch_core_session_t, 0|0);
XSRETURN(argvi);
fail:
;
XS(_wrap_fs_channel_answer) {
{
- struct switch_core_session *arg1 = (struct switch_core_session *) 0 ;
+ switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
int argvi = 0;
dXSARGS;
SWIG_croak("Usage: fs_channel_answer(session);");
}
{
- if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session,0) < 0) {
- SWIG_croak("Type error in argument 1 of fs_channel_answer. Expected _p_switch_core_session");
+ if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t,0) < 0) {
+ SWIG_croak("Type error in argument 1 of fs_channel_answer. Expected _p_switch_core_session_t");
}
}
fs_channel_answer(arg1);
XS(_wrap_fs_channel_pre_answer) {
{
- struct switch_core_session *arg1 = (struct switch_core_session *) 0 ;
+ switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
int argvi = 0;
dXSARGS;
SWIG_croak("Usage: fs_channel_pre_answer(session);");
}
{
- if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session,0) < 0) {
- SWIG_croak("Type error in argument 1 of fs_channel_pre_answer. Expected _p_switch_core_session");
+ if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t,0) < 0) {
+ SWIG_croak("Type error in argument 1 of fs_channel_pre_answer. Expected _p_switch_core_session_t");
}
}
fs_channel_pre_answer(arg1);
XS(_wrap_fs_channel_hangup) {
{
- struct switch_core_session *arg1 = (struct switch_core_session *) 0 ;
+ switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
+ char *arg2 = (char *) 0 ;
int argvi = 0;
dXSARGS;
- if ((items < 1) || (items > 1)) {
- SWIG_croak("Usage: fs_channel_hangup(session);");
+ if ((items < 2) || (items > 2)) {
+ SWIG_croak("Usage: fs_channel_hangup(session,cause);");
}
{
- if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session,0) < 0) {
- SWIG_croak("Type error in argument 1 of fs_channel_hangup. Expected _p_switch_core_session");
+ if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t,0) < 0) {
+ SWIG_croak("Type error in argument 1 of fs_channel_hangup. Expected _p_switch_core_session_t");
}
}
- fs_channel_hangup(arg1);
+ if (!SvOK((SV*) ST(1))) arg2 = 0;
+ else arg2 = (char *) SvPV(ST(1), PL_na);
+ fs_channel_hangup(arg1,arg2);
XSRETURN(argvi);
XS(_wrap_fs_channel_set_variable) {
{
- struct switch_core_session *arg1 = (struct switch_core_session *) 0 ;
+ switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
char *arg2 = (char *) 0 ;
char *arg3 = (char *) 0 ;
int argvi = 0;
SWIG_croak("Usage: fs_channel_set_variable(session,var,val);");
}
{
- if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session,0) < 0) {
- SWIG_croak("Type error in argument 1 of fs_channel_set_variable. Expected _p_switch_core_session");
+ if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t,0) < 0) {
+ SWIG_croak("Type error in argument 1 of fs_channel_set_variable. Expected _p_switch_core_session_t");
}
}
if (!SvOK((SV*) ST(1))) arg2 = 0;
XS(_wrap_fs_channel_get_variable) {
{
- struct switch_core_session *arg1 = (struct switch_core_session *) 0 ;
+ switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
char *arg2 = (char *) 0 ;
int argvi = 0;
dXSARGS;
SWIG_croak("Usage: fs_channel_get_variable(session,var);");
}
{
- if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session,0) < 0) {
- SWIG_croak("Type error in argument 1 of fs_channel_get_variable. Expected _p_switch_core_session");
+ if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t,0) < 0) {
+ SWIG_croak("Type error in argument 1 of fs_channel_get_variable. Expected _p_switch_core_session_t");
}
}
if (!SvOK((SV*) ST(1))) arg2 = 0;
XS(_wrap_fs_channel_set_state) {
{
- struct switch_core_session *arg1 = (struct switch_core_session *) 0 ;
+ switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
char *arg2 = (char *) 0 ;
int argvi = 0;
dXSARGS;
SWIG_croak("Usage: fs_channel_set_state(session,state);");
}
{
- if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session,0) < 0) {
- SWIG_croak("Type error in argument 1 of fs_channel_set_state. Expected _p_switch_core_session");
+ if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t,0) < 0) {
+ SWIG_croak("Type error in argument 1 of fs_channel_set_state. Expected _p_switch_core_session_t");
}
}
if (!SvOK((SV*) ST(1))) arg2 = 0;
XS(_wrap_fs_ivr_play_file) {
{
- struct switch_core_session *arg1 = (struct switch_core_session *) 0 ;
+ switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
char *arg2 = (char *) 0 ;
char *arg3 = (char *) 0 ;
+ switch_dtmf_callback_function_t arg4 ;
+ void *arg5 = (void *) 0 ;
+ unsigned int arg6 ;
int result;
int argvi = 0;
dXSARGS;
- if ((items < 3) || (items > 3)) {
- SWIG_croak("Usage: fs_ivr_play_file(session,file,timer_name_in);");
+ if ((items < 6) || (items > 6)) {
+ SWIG_croak("Usage: fs_ivr_play_file(session,file,timer_name,dtmf_callback,buf,buflen);");
}
{
- if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session,0) < 0) {
- SWIG_croak("Type error in argument 1 of fs_ivr_play_file. Expected _p_switch_core_session");
+ if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_switch_core_session_t,0) < 0) {
+ SWIG_croak("Type error in argument 1 of fs_ivr_play_file. Expected _p_switch_core_session_t");
}
}
if (!SvOK((SV*) ST(1))) arg2 = 0;
else arg2 = (char *) SvPV(ST(1), PL_na);
if (!SvOK((SV*) ST(2))) arg3 = 0;
else arg3 = (char *) SvPV(ST(2), PL_na);
- result = (int)fs_ivr_play_file(arg1,arg2,arg3);
+ {
+ switch_dtmf_callback_function_t * argp;
+ if (SWIG_ConvertPtr(ST(3),(void **) &argp, SWIGTYPE_p_switch_dtmf_callback_function_t,0) < 0) {
+ SWIG_croak("Type error in argument 4 of fs_ivr_play_file. Expected _p_switch_dtmf_callback_function_t");
+ }
+ arg4 = *argp;
+ }
+ {
+ if (SWIG_ConvertPtr(ST(4), (void **) &arg5, 0,0) < 0) {
+ SWIG_croak("Type error in argument 5 of fs_ivr_play_file. Expected _p_void");
+ }
+ }
+ arg6 = (unsigned int) SvUV(ST(5));
+ result = (int)fs_ivr_play_file(arg1,arg2,arg3,arg4,arg5,arg6);
ST(argvi) = sv_newmortal();
sv_setiv(ST(argvi++), (IV) result);
/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
-static swig_type_info _swigt__p_switch_core_session = {"_p_switch_core_session", "struct switch_core_session *", 0, 0, 0};
+static swig_type_info _swigt__p_switch_core_session_t = {"_p_switch_core_session_t", "switch_core_session_t *", 0, 0, 0};
+static swig_type_info _swigt__p_switch_dtmf_callback_function_t = {"_p_switch_dtmf_callback_function_t", "switch_dtmf_callback_function_t *", 0, 0, 0};
static swig_type_info *swig_type_initial[] = {
- &_swigt__p_switch_core_session,
+ &_swigt__p_switch_core_session_t,
+ &_swigt__p_switch_dtmf_callback_function_t,
};
-static swig_cast_info _swigc__p_switch_core_session[] = { {&_swigt__p_switch_core_session, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_switch_core_session_t[] = { {&_swigt__p_switch_core_session_t, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_switch_dtmf_callback_function_t[] = { {&_swigt__p_switch_dtmf_callback_function_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info *swig_cast_initial[] = {
- _swigc__p_switch_core_session,
+ _swigc__p_switch_core_session_t,
+ _swigc__p_switch_dtmf_callback_function_t,
};