add mod_rss
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1551 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
cd3e5e83c2
commit
9a43ccab24
|
@ -58,6 +58,7 @@
|
|||
|
||||
<!-- ASR /TTS -->
|
||||
<!-- <load module="mod_cepstral"/> -->
|
||||
<!-- <load module="mod_rss"/> -->
|
||||
</modules>
|
||||
</configuration>
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ applications/mod_echo
|
|||
applications/mod_ivrtest
|
||||
applications/mod_playback
|
||||
applications/mod_skel
|
||||
#applications/mod_rss
|
||||
#asr_tts/mod_cepstral
|
||||
codecs/mod_g711
|
||||
codecs/mod_ilbc
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
#!/usr/local/bin/perl
|
||||
##########################################################################
|
||||
# rss2ivr.pl -- A Script to turn an RSS feed into audio files.
|
||||
#
|
||||
# Copyright (C) 2006, Anthony Minessale
|
||||
#
|
||||
# Anthony Minessale <anthmct@yahoo.com>
|
||||
#
|
||||
# This program is free software, distributed under the terms of
|
||||
# Perl itself
|
||||
##########################################################################
|
||||
use XML::RSS;
|
||||
require LWP::UserAgent;
|
||||
################################################################################
|
||||
my $swift = "/opt/swift/bin/swift";
|
||||
################################################################################
|
||||
|
||||
my $rss = new XML::RSS;
|
||||
my $root = shift;
|
||||
my $target = shift;
|
||||
my $dir = shift;
|
||||
my $saytxt;
|
||||
my $voice = shift || "David";
|
||||
my $ua = LWP::UserAgent->new;
|
||||
$ua->timeout(10);
|
||||
|
||||
unless($root and $target and $dir) {
|
||||
die("Usage: $0 <root dir> <target url> <ivr name>\n");
|
||||
}
|
||||
|
||||
unless(-d $root) {
|
||||
mkdir($root);
|
||||
}
|
||||
|
||||
chdir($root) or die("where is $root");
|
||||
|
||||
if ($target =~ /http/) {
|
||||
my $response = $ua->get($target);
|
||||
if ($response->is_success) {
|
||||
$in = $response->content;
|
||||
} else {
|
||||
die $response->status_line;
|
||||
}
|
||||
|
||||
my $x = 1;
|
||||
|
||||
$rss->parse($in);
|
||||
system("rm -fr $$");
|
||||
mkdir($$);
|
||||
die unless(-d $$);
|
||||
chdir($$);
|
||||
open(I,">00.txt");
|
||||
print I "$dir main index.\n";
|
||||
|
||||
foreach my $item (@{$rss->{'items'}}) {
|
||||
my $xx = sprintf("%0.2d", $x);
|
||||
my $title .= "entry $xx, " . $item->{'title'} . ".\n";
|
||||
print I $title;
|
||||
my $desc = $item->{'description'};
|
||||
$desc =~ s/\<[^\>]+\>//g;
|
||||
my $content = "entry $xx.\n" . $item->{'title'} . ".\n". $desc;
|
||||
open(X,">$xx.txt");
|
||||
$content =~ s/[^\w\d\s \.\,\-\n]//smg;
|
||||
|
||||
print X $content;
|
||||
close X;
|
||||
|
||||
my $do = "$swift -p audio/deadair=2000,audio/sampling-rate=8000,audio/channels=1,audio/encoding=pcm16,audio/output-format=raw -o ${xx}.raw -f ${xx}.txt -n $voice";
|
||||
system $do;
|
||||
$x++;
|
||||
}
|
||||
|
||||
my $do = "$swift -p audio/deadair=2000,audio/sampling-rate=8000,audio/channels=1,audio/encoding=pcm16,audio/output-format=raw -o 00.raw -f 00.txt -n $voice";
|
||||
system $do;
|
||||
close(I);
|
||||
chdir("..");
|
||||
system("/bin/rm -fr $dir");
|
||||
system("/bin/mv -f $$ $dir");
|
||||
}
|
||||
|
|
@ -362,6 +362,13 @@ SWITCH_DECLARE(switch_size_t) switch_channel_dequeue_dtmf(switch_channel_t *chan
|
|||
*/
|
||||
SWITCH_DECLARE(const char *) switch_channel_state_name(switch_channel_state_t state);
|
||||
|
||||
/*!
|
||||
\brief Render the enum of the provided state name
|
||||
\param name the name of the state
|
||||
\return the enum value (numeric)
|
||||
*/
|
||||
SWITCH_DECLARE(switch_channel_state_t) switch_channel_name_state(char *name);
|
||||
|
||||
/*!
|
||||
\brief Add information about a given channel to an event object
|
||||
\param channel channel to add information about
|
||||
|
|
|
@ -231,6 +231,7 @@ typedef enum {
|
|||
SWITCH_STATUS_BREAK - A non-fatal break of an operation
|
||||
SWITCH_STATUS_SOCKERR - A socket error
|
||||
SWITCH_STATUS_MORE_DATA - Need More Data
|
||||
SWITCH_STATUS_NOTFOUND - Not Found
|
||||
</pre>
|
||||
*/
|
||||
typedef enum {
|
||||
|
@ -247,7 +248,8 @@ typedef enum {
|
|||
SWITCH_STATUS_INUSE,
|
||||
SWITCH_STATUS_BREAK,
|
||||
SWITCH_STATUS_SOCKERR,
|
||||
SWITCH_STATUS_MORE_DATA
|
||||
SWITCH_STATUS_MORE_DATA,
|
||||
SWITCH_STATUS_NOTFOUND
|
||||
} switch_status_t;
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,218 @@
|
|||
/*
|
||||
* 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;
|
||||
}
|
||||
*/
|
|
@ -23,7 +23,7 @@ depends:
|
|||
|
||||
reswig:
|
||||
rm switch_swig_wrap.c
|
||||
swig -DMULTIPLICITY -perl5 -module fs_perl switch_swig.c
|
||||
swig -lswitch_swig.i -ignoremissing -DMULTIPLICITY -perl5 -module fs_perl switch_swig.c
|
||||
|
||||
switch_swig_wrap.o: switch_swig_wrap.c
|
||||
$(CC) -w $(CFLAGS) -c $< -o $@
|
||||
|
|
|
@ -82,10 +82,10 @@ void fs_channel_pre_answer(switch_core_session_t *session)
|
|||
switch_channel_pre_answer(channel);
|
||||
}
|
||||
|
||||
void fs_channel_hangup(switch_core_session_t *session)
|
||||
void fs_channel_hangup(switch_core_session_t *session, char *cause)
|
||||
{
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
|
||||
switch_channel_hangup(channel, switch_channel_str2cause(cause));
|
||||
}
|
||||
|
||||
void fs_channel_set_variable(switch_core_session_t *session, char *var, char *val)
|
||||
|
@ -105,16 +105,17 @@ void fs_channel_set_state(switch_core_session_t *session, char *state)
|
|||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
switch_channel_state_t fs_state = switch_channel_get_state(channel);
|
||||
|
||||
if (!strcmp(state, "EXECUTE")) {
|
||||
fs_state = CS_EXECUTE;
|
||||
} else if (!strcmp(state, "TRANSMIT")) {
|
||||
fs_state = CS_TRANSMIT;
|
||||
if ((fs_state = switch_channel_name_state(state)) < CS_HANGUP) {
|
||||
switch_channel_set_state(channel, fs_state);
|
||||
}
|
||||
|
||||
switch_channel_set_state(channel, fs_state);
|
||||
}
|
||||
|
||||
int fs_ivr_play_file(switch_core_session_t *session, char *file, char *timer_name)
|
||||
int fs_ivr_play_file(switch_core_session_t *session,
|
||||
char *file,
|
||||
char *timer_name,
|
||||
switch_dtmf_callback_function_t dtmf_callback,
|
||||
void *buf,
|
||||
unsigned int buflen)
|
||||
{
|
||||
switch_status_t status;
|
||||
if (switch_strlen_zero(timer_name)) {
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
// gd.i
|
||||
%module fs_perl
|
||||
%{
|
||||
#include <switch.h>
|
||||
%}
|
||||
|
||||
// Grab the gd.h header file
|
||||
%include <switch.h>
|
||||
|
|
@ -991,9 +991,10 @@ SWIG_Perl_SetModule(swig_module_info *module) {
|
|||
|
||||
/* -------- 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)
|
||||
|
||||
|
@ -1017,6 +1018,9 @@ SWIGEXPORT void SWIG_init (pTHXo_ CV* cv);
|
|||
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 {
|
||||
|
@ -1044,6 +1048,9 @@ XS(_wrap_fs_core_set_globals) {
|
|||
int argvi = 0;
|
||||
dXSARGS;
|
||||
|
||||
if ((items < 0) || (items > 0)) {
|
||||
SWIG_croak("Usage: fs_core_set_globals();");
|
||||
}
|
||||
fs_core_set_globals();
|
||||
|
||||
|
||||
|
@ -1085,6 +1092,9 @@ XS(_wrap_fs_core_destroy) {
|
|||
int argvi = 0;
|
||||
dXSARGS;
|
||||
|
||||
if ((items < 0) || (items > 0)) {
|
||||
SWIG_croak("Usage: fs_core_destroy();");
|
||||
}
|
||||
result = (int)fs_core_destroy();
|
||||
|
||||
ST(argvi) = sv_newmortal();
|
||||
|
@ -1103,6 +1113,9 @@ XS(_wrap_fs_loadable_module_init) {
|
|||
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();
|
||||
|
@ -1121,6 +1134,9 @@ XS(_wrap_fs_loadable_module_shutdown) {
|
|||
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();
|
||||
|
@ -1139,7 +1155,9 @@ XS(_wrap_fs_console_loop) {
|
|||
int argvi = 0;
|
||||
dXSARGS;
|
||||
|
||||
|
||||
if ((items < 0) || (items > 0)) {
|
||||
SWIG_croak("Usage: fs_console_loop();");
|
||||
}
|
||||
result = (int)fs_console_loop();
|
||||
|
||||
ST(argvi) = sv_newmortal();
|
||||
|
@ -1199,7 +1217,7 @@ XS(_wrap_fs_console_clean) {
|
|||
XS(_wrap_fs_core_session_locate) {
|
||||
{
|
||||
char *arg1 = (char *) 0 ;
|
||||
struct switch_core_session *result;
|
||||
switch_core_session_t *result;
|
||||
int argvi = 0;
|
||||
dXSARGS;
|
||||
|
||||
|
@ -1208,10 +1226,10 @@ XS(_wrap_fs_core_session_locate) {
|
|||
}
|
||||
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:
|
||||
;
|
||||
|
@ -1222,7 +1240,7 @@ XS(_wrap_fs_core_session_locate) {
|
|||
|
||||
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;
|
||||
|
||||
|
@ -1230,8 +1248,8 @@ XS(_wrap_fs_channel_answer) {
|
|||
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);
|
||||
|
@ -1247,7 +1265,7 @@ XS(_wrap_fs_channel_answer) {
|
|||
|
||||
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;
|
||||
|
||||
|
@ -1255,8 +1273,8 @@ XS(_wrap_fs_channel_pre_answer) {
|
|||
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);
|
||||
|
@ -1272,19 +1290,22 @@ XS(_wrap_fs_channel_pre_answer) {
|
|||
|
||||
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);
|
||||
|
@ -1297,7 +1318,7 @@ XS(_wrap_fs_channel_hangup) {
|
|||
|
||||
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;
|
||||
|
@ -1307,8 +1328,8 @@ XS(_wrap_fs_channel_set_variable) {
|
|||
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;
|
||||
|
@ -1328,7 +1349,7 @@ XS(_wrap_fs_channel_set_variable) {
|
|||
|
||||
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;
|
||||
|
@ -1337,8 +1358,8 @@ XS(_wrap_fs_channel_get_variable) {
|
|||
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;
|
||||
|
@ -1356,7 +1377,7 @@ XS(_wrap_fs_channel_get_variable) {
|
|||
|
||||
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;
|
||||
|
@ -1365,8 +1386,8 @@ XS(_wrap_fs_channel_set_state) {
|
|||
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;
|
||||
|
@ -1384,26 +1405,42 @@ XS(_wrap_fs_channel_set_state) {
|
|||
|
||||
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);
|
||||
|
@ -1418,16 +1455,20 @@ XS(_wrap_fs_ivr_play_file) {
|
|||
|
||||
/* -------- 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,
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -370,7 +370,8 @@ static const char *state_names[] = {
|
|||
"CS_LOOPBACK",
|
||||
"CS_HOLD",
|
||||
"CS_HANGUP",
|
||||
"CS_DONE"
|
||||
"CS_DONE",
|
||||
NULL
|
||||
};
|
||||
|
||||
SWITCH_DECLARE(const char *) switch_channel_state_name(switch_channel_state_t state)
|
||||
|
@ -378,6 +379,19 @@ SWITCH_DECLARE(const char *) switch_channel_state_name(switch_channel_state_t st
|
|||
return state_names[state];
|
||||
}
|
||||
|
||||
|
||||
SWITCH_DECLARE(switch_channel_state_t) switch_channel_name_state(char *name)
|
||||
{
|
||||
uint32_t x = 0;
|
||||
for(x = 0; state_names[x]; x++) {
|
||||
if (!strcasecmp(state_names[x], name)) {
|
||||
return (switch_channel_state_t) x;
|
||||
}
|
||||
}
|
||||
|
||||
return CS_DONE;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_state(switch_channel_t *channel,
|
||||
const char *file,
|
||||
const char *func,
|
||||
|
|
|
@ -288,9 +288,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
|
|||
file,
|
||||
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT,
|
||||
switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
switch_core_session_reset(session);
|
||||
return SWITCH_STATUS_GENERR;
|
||||
return SWITCH_STATUS_NOTFOUND;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue