Major Updates Still buggy

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@2629 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Brian Fertig 2006-09-10 23:19:15 +00:00
parent 89649d47d8
commit ca74ae80d9
10 changed files with 2581 additions and 823 deletions

View File

@ -0,0 +1,19 @@
MOD_PHP (c)2006 Tony M, Brian Fertig & Contributors
***8SEPT06***
Added all of the IVR features for the core.
Added Channel Variable Functions
***TODO***
Add Logging
Add other thing
Build PHP Class Framework for PHP & Freeswitch

View File

@ -10,7 +10,7 @@ PHPLDFLAGS = `$(PCFG) --ldflags` -lcrypt -lresolv -lm -ldl -lnsl -lxml2 -lz -lph
all: depends $(MODNAME).$(DYNAMIC_LIB_EXTEN) $(PHPMOD).$(DYNAMIC_LIB_EXTEN)
depends:
MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install php-5.1.6.tar.gz --prefix=$(PREFIX) --enable-embed=static --enable-static --with-pic
MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install php-5.1.6.tar.gz --prefix=$(PREFIX) --enable-embed=static --enable-static --with-pic --with-mysql --with-curl
%.o: %.c
$(CC) $(LCFLAGS) $(CFLAGS) -c $< -o $@

View File

@ -1,7 +1,17 @@
<?
include("freeswitch.php");
$session = fs_core_session_locate($uuid);
fs_channel_answer($session);
fs_ivr_play_file2($session, "/ram/sr8k.wav");
/*
This application does not fall under the MPL. Its 100% freeware
no code needs to be submitted back to us for this.
(c)2006 Brian Fertig
*/
require("classFreeswitch.php");
$fs = new fs_class_api;
$fs->fs_answer($session);
$fs->fs_play_file($session, "/ram/sr8k.wav");
?>

View File

@ -0,0 +1,166 @@
<?
/*
* 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):
*
* Brian Fertig <brian.fertig@convergencetek.com>
* IRC: docelmo
*
* php_freeswitch.c -- PHP Module Framework
*
*/
require("freeswitch.php"); // Required for freeswitch driver to be loaded
global $sessn;
class fs_class_api {
function fs_class_api() {
if($sessn = $this->fs_getsessn($uuid)){}
else{
echo "Couldnt get sessn!\n";
}
}
function fs_start() {
// only use this function if you plan to start freeswitch in your script.
fs_core_set_globals();
fs_core_init("");
fs_loadable_module_init();
fs_console_loop();
fs_core_destroy();
}
function fs_log($level_str, $msg) {
fs_console_log($level_str, $msg);
}
function fs_log_clean($msg) {
fs_console_clean($msg);
}
function fs_getsessn($uuid){
return fs_core_sessn_locate($uuid);
}
function fs_answer(){
fs_channel_answer($sessn);
}
function fs_early_media($sessn){
fs_channel_pre_answer($sessn);
}
function fs_hangup($cause){
fs_channel_hangup($sessn, $cause);
}
function fs_set_variable($var, $val){
fs_channel_set_variable($sessn, $var, $val);
}
function fs_get_variable($var){
return fs_channel_get_var($sessn, $var);
}
function fs_set_channel_state($state){
fs_channel_set_state($sessn, $state);
}
function fs_play_file($file){
return fs_ivr_play_file($sessn, $file, NULL, NULL, NULL, 0);
}
function record_file($file){
return fs_switch_ivr_record_file($sessn, NULL, $file, NULL, NULL, 0);
}
function fs_wait($ms){
return fs_switch_ivr_sleep($sessn, $ms);
}
function fs_get_dtmf_callback($len){
return fs_switch_ivr_collect_digits_callback($sessn, NULL, NULL, $len);
}
function fs_get_digit_count ($maxdigits, $terminator, $timeout){
return fs_switch_ivr_collect_digits_count($sessn, NULL, NULL, $maxdigits, NULL, $terminator, $timeout);
}
function fs_x_way($peer_sessn, $dtmf, $sessn_data, $peer_data){
return fs_switch_ivr_multi_threaded_bridge ($sessn, $peer_sessn, $dtmf, $sessn_data, $peer_data);
}
function fs_dial($data, $timelimit){
return fs_switch_ivr_originate(sessn, NULL, $data, $timelimit, NULL, NULL, NULL, NULL);
}
function fs_transfer($exten, $dialplan, $context){
return fs_switch_ivr_sessn_transfer($sessn, $exten, $dialplan, $context);
}
function fs_speak($ttsName, $voice, $text, $dtmf=NULL){
return fs_switch_ivr_speak_text($sessn, $ttsName, NULL, NULL, $dtmf, $text, NULL, 0);
}
}
?>

View File

@ -2,7 +2,7 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 1.3.21
* Version 1.3.29
*
* This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make
@ -16,7 +16,7 @@ $FREESWITCH_LOADED__ = true;
/* if our extension has not been loaded, do what we can */
if (!extension_loaded("php_freeswitch")) {
if (!dl("php_freeswitch.so")) return;
if (!dl("php_freeswitch.so")) return;
}

View File

@ -24,12 +24,17 @@
* Contributor(s):
*
* Anthony Minessale II <anthmct@yahoo.com>
*
* Brian Fertig <brian.fertig@convergencetek.com>
*
* mod_php.c -- PHP Module
*
*/
#if !defined(ZTS)
#error "ZTS Needs to be defined."
#endif
#ifndef _REENTRANT
#define _REENTRANT
#endif
@ -39,38 +44,75 @@
#endif
#include <sapi/embed/php_embed.h>
//#include "php.h"
//#include "php_variables.h"
//#include "ext/standard/info.h"
//#include "php_ini.h"
//#include "php_globals.h"
//#include "SAPI.h"
//#include "php_main.h"
//#include "php_version.h"
//#include "TSRM.h"
//#include "ext/standard/php_standard.h"
#include <switch.h>
const char modname[] = "mod_php";
static void php_function(switch_core_session_t *session, char *data)
{
char *uuid = switch_core_session_get_uuid(session);
uint32_t ulen = strlen(uuid);
uint32_t len = strlen((char *) data) + ulen + 2;
char *mydata = switch_core_session_alloc(session, len);
int argc;
int argc, retval;
char *argv[5];
char php_code[1024];
void*** tsrm_ls = NULL;
snprintf(mydata, len, "%s %s", uuid, data);
argc = switch_separate_string(mydata, ' ',
argv,
(sizeof(argv) / sizeof(argv[0])));
sprintf(php_code, "$uuid=\"%s\"; include(\"%s\");\n", argv[0], argv[1]);
php_embed_init(argc, argv, &tsrm_ls);
argc = 1; //switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
//sprintf(php_code, "$uuid=\"%s\"; include(\"%s\");\n", argv[0], argv[1]);
sprintf(php_code, "include('%s');", argv[1]);
zend_file_handle script;
script.type = ZEND_HANDLE_FP;
script.filename = data;
script.opened_path = NULL;
script.free_filename = 0;
script.handle.fp = fopen(script.filename, "rb");
//php_embed_init(argc, argv, &tsrm_ls);
if (php_request_startup(TSRMLS_C) == FAILURE) {
return;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Starting Script %s\n",data);
retval = php_execute_script(&script TSRMLS_CC);
php_request_shutdown(NULL);
return;
//PHP_EMBED_START_BLOCK(argc, argv);
zend_eval_string(php_code, NULL, "Embedded code" TSRMLS_CC);
//PHP_EMBED_END_BLOCK();
php_embed_shutdown(tsrm_ls);
//void*** tsrm_ls = NULL;
//zend_error_cb = myapp_php_error_cb;
//zend_eval_string(php_code, NULL, "MOD_PHP" TSRMLS_CC);
// zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, NULL, 1, &script);
//if (zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, NULL, 1, &script) == SUCCESS)
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "There was a problem with the file\n");
//PHP_EMBED_END_BLOCK();
// php_embed_shutdown(tsrm_ls);
//}else{
// switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "There was a problem with the file\n");
//}
}
@ -93,16 +135,21 @@ static switch_loadable_module_interface_t php_module_interface = {
/*.directory_interface */ NULL
};
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
/*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 */
// connect my internal structure to the blank pointer passed to me
*module_interface = &php_module_interface;
sapi_startup(&mod_php_sapi_module);
mod_php_sapi_module.startup(&mod_php_sapi_module);
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hello World!\n");
/* indicate that the module should continue to be loaded */
// indicate that the module should continue to be loaded
return SWITCH_STATUS_SUCCESS;
}
*/
/*
Called when the system shuts down
@ -119,3 +166,228 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
return SWITCH_STATUS_SUCCESS;
}
*/
zend_module_entry mod_php_module_entry = {
STANDARD_MODULE_HEADER,
"mod_php",
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NO_VERSION_YET,
STANDARD_MODULE_PROPERTIES
};
static int sapi_mod_php_ub_write(const char *str, unsigned int str_length TSRMLS_DC)
{ // This function partly based on code from asterisk_php
FILE *fp = fopen("mod_php.log", "a");
fwrite(str, str_length, sizeof(char), fp);
fclose(fp);
char buffer[4096];
int i, j = 0;
for(i = 0; i < str_length; i++) {
buffer[j++] = str[i];
if(str[i] == 10) { /* new line */
buffer[j] = 0;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "%s", buffer);
j = 0;
}
else if(str[i] == 0) { /* null character */
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "%s", buffer);
j = 0;
}
if(j == 4095) { /* don't overfill buffer */
buffer[j] = 0;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "%s", buffer);
j = 0;
}
}
if(j) { /* stuff left over */
buffer[j] = 0;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "%s", buffer);
}
return str_length;
}
void mod_php_error_handler(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args)
{
char *buffer;
int buffer_len;
TSRMLS_FETCH();
buffer_len = vspprintf(&buffer, PG(log_errors_max_len), format, args);
if((EG(error_reporting) & type || (type & E_CORE)) && (PG(log_errors) || PG(display_errors))) {
char *error_type_str;
switch (type) {
case E_ERROR:
case E_CORE_ERROR:
case E_COMPILE_ERROR:
case E_USER_ERROR:
error_type_str = "Fatal error";
break;
case E_WARNING:
case E_CORE_WARNING:
case E_COMPILE_WARNING:
case E_USER_WARNING:
error_type_str = "Warning";
break;
case E_PARSE:
error_type_str = "Parse error";
break;
case E_NOTICE:
case E_USER_NOTICE:
error_type_str = "Notice";
break;
default:
error_type_str = "Unknown error";
break;
}
if(PG(log_errors)) {
char *log_buffer;
#ifdef PHP_WIN32
if(type == E_CORE_ERROR || type == E_CORE_WARNING) {
MessageBox(NULL, buffer, error_type_str, MB_OK|ZEND_SERVICE_MB_STYLE);
}
#endif
spprintf(&log_buffer, 0, "PHP %s: %s in %s on line %d", error_type_str, buffer, error_filename, error_lineno);
php_log_err(log_buffer TSRMLS_CC);
efree(log_buffer);
}
if(PG(display_errors)) {
char *prepend_string = INI_STR("error_prepend_string");
char *append_string = INI_STR("error_append_string");
char *error_format = "%s\n%s: %s in %s on line %d\n%s";
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, error_format, STR_PRINT(prepend_string), error_type_str, buffer, error_filename, error_lineno,
STR_PRINT(append_string));
}
}
/* Bail out if we can't recover */
switch(type) {
case E_CORE_ERROR:
case E_ERROR:
/*case E_PARSE: the parser would return 1 (failure), we can bail out nicely */
case E_COMPILE_ERROR:
case E_USER_ERROR:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "\nPHP: %s exiting\n", error_filename);
EG(exit_status) = 255;
#if MEMORY_LIMIT
/* restore memory limit */
AG(memory_limit) = PG(memory_limit);
#endif
efree(buffer);
zend_bailout();
return;
break;
}
/* Log if necessary */
if(PG(track_errors) && EG(active_symbol_table)) {
pval *tmp;
ALLOC_ZVAL(tmp);
INIT_PZVAL(tmp);
Z_STRVAL_P(tmp) = (char *) estrndup(buffer, buffer_len);
Z_STRLEN_P(tmp) = buffer_len;
Z_TYPE_P(tmp) = IS_STRING;
zend_hash_update(EG(active_symbol_table), "php_errormsg", sizeof("php_errormsg"), (void **) & tmp, sizeof(pval *), NULL);
}
efree(buffer);
}
static int sapi_mod_php_header_handler(sapi_header_struct * sapi_header, sapi_headers_struct * sapi_headers TSRMLS_DC)
{
return 0;
}
static int sapi_mod_php_send_headers(sapi_headers_struct * sapi_headers TSRMLS_DC)
{
return SAPI_HEADER_SENT_SUCCESSFULLY;
}
static int sapi_mod_php_read_post(char *buffer, uint count_bytes TSRMLS_DC)
{
return 0;
}
static int mod_php_startup(sapi_module_struct *sapi_module)
{
if(php_module_startup(sapi_module, &mod_php_module_entry, 1) == FAILURE) {
return FAILURE;
}
return SUCCESS;
}
static void mod_php_log_message(char *message)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "%s\n", message);
}
static char *sapi_mod_php_read_cookies(TSRMLS_D)
{
return NULL;
}
static int mod_php_startup(sapi_module_struct *sapi_module);
sapi_module_struct mod_php_sapi_module = {
"mod_php", /* name */
"mod_php", /* pretty name */
mod_php_startup, /* startup */
NULL, /* shutdown */
NULL, /* activate */
NULL, /* deactivate */
sapi_mod_php_ub_write, /* unbuffered write */
NULL, /* flush */
NULL, /* get uid */
NULL, /* getenv */
php_error, /* error handler */
sapi_mod_php_header_handler, /* header handler */
sapi_mod_php_send_headers, /* send headers handler */
NULL, /* send header handler */
sapi_mod_php_read_post, /* read POST data */
sapi_mod_php_read_cookies, /* read Cookies */
NULL, /* register server variables */
mod_php_log_message, /* Log message */
NULL, /* Get request time */
NULL, /* Block interruptions */
NULL, /* Unblock interruptions */
STANDARD_SAPI_MODULE_PROPERTIES
};
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 = &php_module_interface;
sapi_startup(&mod_php_sapi_module);
mod_php_sapi_module.startup(&mod_php_sapi_module);
//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;
}

View File

@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 1.3.21
* Version 1.3.29
*
* This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make
@ -40,6 +40,10 @@ extern zend_module_entry freeswitch_module_entry;
# define PHP_FREESWITCH_API
#endif
#ifdef ZTS
#include "TSRM.h"
#endif
PHP_MINIT_FUNCTION(freeswitch);
PHP_MSHUTDOWN_FUNCTION(freeswitch);
PHP_RINIT_FUNCTION(freeswitch);
@ -52,8 +56,8 @@ ZEND_NAMED_FUNCTION(_wrap_fs_core_destroy);
ZEND_NAMED_FUNCTION(_wrap_fs_loadable_module_init);
ZEND_NAMED_FUNCTION(_wrap_fs_loadable_module_shutdown);
ZEND_NAMED_FUNCTION(_wrap_fs_console_loop);
ZEND_NAMED_FUNCTION(_wrap_fs_console_log);
ZEND_NAMED_FUNCTION(_wrap_fs_console_clean);
ZEND_NAMED_FUNCTION(_wrap_fs_consol_log);
ZEND_NAMED_FUNCTION(_wrap_fs_consol_clean);
ZEND_NAMED_FUNCTION(_wrap_fs_core_session_locate);
ZEND_NAMED_FUNCTION(_wrap_fs_channel_answer);
ZEND_NAMED_FUNCTION(_wrap_fs_channel_pre_answer);
@ -62,25 +66,14 @@ ZEND_NAMED_FUNCTION(_wrap_fs_channel_set_variable);
ZEND_NAMED_FUNCTION(_wrap_fs_channel_get_variable);
ZEND_NAMED_FUNCTION(_wrap_fs_channel_set_state);
ZEND_NAMED_FUNCTION(_wrap_fs_ivr_play_file);
ZEND_NAMED_FUNCTION(_wrap_fs_switch_ivr_record_file);
ZEND_NAMED_FUNCTION(_wrap_fs_switch_ivr_sleep);
ZEND_NAMED_FUNCTION(_wrap_fs_ivr_play_file2);
/*If you declare any globals in php_freeswitch.h uncomment this:
ZEND_BEGIN_MODULE_GLOBALS(freeswitch)
ZEND_END_MODULE_GLOBALS(freeswitch)
*/
#ifdef ZTS
#define FREESWITCH_D zend_freeswitch_globals *freeswitch_globals
#define FREESWITCH_DC , FREESWITCH_D
#define FREESWITCH_C freeswitch_globals
#define FREESWITCH_CC , FREESWITCH_C
#define FREESWITCH_SG(v) (freeswitch_globals->v)
#define FREESWITCH_FETCH() zend_freeswitch_globals *freeswitch_globals = ts_resource(freeswitch_globals_id)
#else
#define FREESWITCH_D
#define FREESWITCH_DC
#define FREESWITCH_C
#define FREESWITCH_CC
#define FREESWITCH_SG(v) (freeswitch_globals.v)
#define FREESWITCH_FETCH()
#endif
ZEND_NAMED_FUNCTION(_wrap_fs_switch_ivr_collect_digits_callback);
ZEND_NAMED_FUNCTION(_wrap_fs_switch_ivr_collect_digits_count);
ZEND_NAMED_FUNCTION(_wrap_fs_switch_ivr_originate);
ZEND_NAMED_FUNCTION(_wrap_fs_switch_ivr_session_transfer);
ZEND_NAMED_FUNCTION(_wrap_fs_switch_ivr_speak_text);
ZEND_NAMED_FUNCTION(_wrap_fs_switch_channel_get_variable);
ZEND_NAMED_FUNCTION(_wrap_fs_switch_channel_set_variable);
#endif /* PHP_FREESWITCH_H */

View File

@ -1,3 +1,34 @@
/*
* 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>
* Brian Fertig <brian.fertig@convergencetek.com>
*
* php_freeswitch.c -- PHP Module Framework
*
*/
#include <switch.h>
#ifdef __ICC
#pragma warning (disable:1418)
@ -55,14 +86,19 @@ int fs_console_loop(void)
return 0;
}
void fs_console_log(char *msg)
void fs_consol_log(char *level_str, char *msg)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, msg);
switch_log_level_t level = SWITCH_LOG_DEBUG;
if (level_str) {
level = switch_log_str2level(level_str);
}
switch_log_printf(SWITCH_CHANNEL_LOG, level, msg);
}
void fs_console_clean(char *msg)
void fs_consol_clean(char *msg)
{
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, msg);
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, msg);
}
switch_core_session_t *fs_core_session_locate(char *uuid)
@ -116,6 +152,11 @@ void fs_channel_set_state(switch_core_session_t *session, char *state)
}
}
/*
IVR Routines! You can do IVR in PHP NOW!
*/
int fs_ivr_play_file(switch_core_session_t *session,
char *file,
char *timer_name,
@ -132,6 +173,26 @@ int fs_ivr_play_file(switch_core_session_t *session,
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
}
int fs_switch_ivr_record_file(switch_core_session_t *session,
switch_file_handle_t *fh,
char *file,
switch_input_callback_function_t dtmf_callback,
void *buf,
unsigned int buflen)
{
switch_status_t status;
status = switch_ivr_record_file(session, fh, file, dtmf_callback, buf, buflen);
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
}
int fs_switch_ivr_sleep(switch_core_session_t *session,
uint32_t ms)
{
switch_status_t status;
status = switch_ivr_sleep(session, ms);
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
}
int fs_ivr_play_file2(switch_core_session_t *session,
char *file)
@ -143,3 +204,123 @@ int fs_ivr_play_file2(switch_core_session_t *session,
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
}
int fs_switch_ivr_collect_digits_callback (switch_core_session_t *session,
switch_input_callback_function_t dtmf_callback,
void *buf,
unsigned int buflen)
{
switch_status_t status;
status = switch_ivr_collect_digits_callback(session, dtmf_callback, buf, buflen);
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
}
int fs_switch_ivr_collect_digits_count (switch_core_session_t *session,
char *buf,
unsigned int buflen,
unsigned int maxdigits,
const char *terminators,
char *terminator,
unsigned int timeout)
{
switch_status_t status;
status = switch_ivr_collect_digits_count(session, buf, buflen, maxdigits, terminators, terminator, timeout);
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
}
/*int fs_switch_ivr_multi_threaded_bridge (switch_core_session_t *session,
switch_core_session_t *peer_session,
switch_input_callback_function_t dtmf_callback,
void *session_data,
void *peer_session_data)
{
switch_status_t status;
status = switch_ivr_multi_threaded_bridge(session, peer_session, dtmf_callback, session_data, peer_session_data);
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
}
*/
int fs_switch_ivr_originate (switch_core_session_t *session,
switch_core_session_t **bleg,
char * bridgeto,
uint32_t timelimit_sec)
/*const switch_state_handler_table_t *table,
char * cid_name_override,
char * cid_num_override,
switch_caller_profile_t *caller_profile_override) */
{
switch_channel_t *caller_channel;
switch_core_session_t *peer_session;
unsigned int timelimit = 60;
char *var;
caller_channel = switch_core_session_get_channel(session);
assert(caller_channel != NULL);
if ((var = switch_channel_get_variable(caller_channel, "call_timeout"))) {
timelimit = atoi(var);
}
if (switch_ivr_originate(session, &peer_session, bridgeto, timelimit, NULL, NULL, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Create Outgoing Channel!\n");
switch_channel_hangup(caller_channel, SWITCH_CAUSE_REQUESTED_CHAN_UNAVAIL);
return;
} else {
switch_ivr_multi_threaded_bridge(session, peer_session, NULL, NULL, NULL);
}
}
int fs_switch_ivr_session_transfer(switch_core_session_t *session,
char *extension,
char *dialplan,
char *context)
{
switch_status_t status;
status = switch_ivr_session_transfer(session,extension,dialplan,context);
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
}
int fs_switch_ivr_speak_text (switch_core_session_t *session,
char *tts_name,
char *voice_name,
char *timer_name,
uint32_t rate,
switch_input_callback_function_t dtmf_callback,
char *text,
void *buf,
unsigned int buflen)
{
switch_status_t status;
status = switch_ivr_speak_text(session,tts_name,voice_name,timer_name,rate,dtmf_callback,text,buf,buflen);
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
}
/*
******* CHANNEL STUFF *******
*/
char* fs_switch_channel_get_variable(switch_channel_t *channel, char *varname)
{
return switch_channel_get_variable(channel, varname);
}
int fs_switch_channel_set_variable(switch_channel_t *channel, char *varname, char *value)
{
switch_status_t status;
status = switch_channel_set_variable(channel, varname, value);
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,8 @@
<?
include("classFreeswitch.php");
include("freeswitch.php");
$fs = new fs_class_api;
fs_core_set_globals();
fs_core_init("");
fs_loadable_module_init();
fs_console_loop();
fs_core_destroy();
?>
$fs->fs_start();
?>