mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-23 04:31:50 +00:00
spring cleaning
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4795 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
+25
-1
@@ -11,6 +11,7 @@ BASE = $(switch_srcdir)
|
||||
OSARCH=`uname -s`
|
||||
|
||||
LIBTOOL=`if test -z "$(VERBOSE)" ; then echo $(SHELL) $(switch_builddir)/quiet_libtool ;else echo $(switch_builddir)/libtool; fi;`
|
||||
#LIBS+=> core.log || error="yes";if test -n "$(VERBOSE)" -o "$$error" = "yes";then cat core.log;fi;if test "$$error" = "yes";then exit 1;fi
|
||||
|
||||
LTINSTALL = $(LIBTOOL) --mode=install $(INSTALL)
|
||||
TOUCH_TARGET=if test -f "$@" ; then touch "$@" ; fi ;
|
||||
@@ -26,7 +27,24 @@ src/switch_buffer.c \
|
||||
src/switch_caller.c \
|
||||
src/switch_channel.c \
|
||||
src/switch_console.c \
|
||||
src/switch_core_media_bug.c \
|
||||
src/switch_core_timer.c \
|
||||
src/switch_core_asr.c \
|
||||
src/switch_core_event_hook.c \
|
||||
src/switch_core_speech.c \
|
||||
src/switch_core_memory.c \
|
||||
src/switch_core_codec.c \
|
||||
src/switch_core_file.c \
|
||||
src/switch_core_hash.c \
|
||||
src/switch_core_sqldb.c \
|
||||
src/switch_core_session.c \
|
||||
src/switch_core_directory.c \
|
||||
src/switch_core_state_machine.c \
|
||||
src/switch_core_io.c \
|
||||
src/switch_core_rwlock.c \
|
||||
src/switch_core_port_allocator.c \
|
||||
src/switch_core.c \
|
||||
src/switch_scheduler.c \
|
||||
src/switch_core_db.c\
|
||||
src/switch_loadable_module.c \
|
||||
src/switch_utils.c \
|
||||
@@ -34,6 +52,11 @@ src/switch_event.c \
|
||||
src/switch_resample.c \
|
||||
src/switch_regex.c\
|
||||
src/switch_rtp.c\
|
||||
src/switch_ivr_bridge.c \
|
||||
src/switch_ivr_originate.c \
|
||||
src/switch_ivr_async.c \
|
||||
src/switch_ivr_play_say.c \
|
||||
src/switch_ivr_menu.c \
|
||||
src/switch_ivr.c \
|
||||
src/switch_stun.c\
|
||||
src/switch_log.c\
|
||||
@@ -52,6 +75,8 @@ src/include/switch_buffer.h\
|
||||
src/include/switch_caller.h\
|
||||
src/include/switch_channel.h\
|
||||
src/include/switch_console.h\
|
||||
src/include/switch_core_event_hook.h\
|
||||
src/include/switch_scheduler.h\
|
||||
src/include/switch_core.h\
|
||||
src/include/switch_core_db.h\
|
||||
src/include/switch_event.h\
|
||||
@@ -81,7 +106,6 @@ CORE_CFLAGS += -I$(switch_srcdir)/libs/pcre
|
||||
CORE_CFLAGS += -I$(switch_srcdir)/libs/srtp/include
|
||||
CORE_CFLAGS += -I$(switch_srcdir)/libs/srtp/crypto/include
|
||||
CORE_CFLAGS += $(RESAMPLE_CFLAGS)
|
||||
CORE_CFLAGS += -I$(switch_srcdir)/libs/libteletone/src
|
||||
|
||||
CORE_LIBS = libs/apr/libapr-1.la libs/apr-util/libaprutil-1.la
|
||||
CORE_LIBS += libs/sqlite/libsqlite3.la libs/pcre/libpcre.la
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
echo -n "-brs -npsl -di0 -br -ce -d0 -cli0 -npcs -nfc1 -ut -i4 -ts4 -l120 -cs -T size_t " > ../.indent.pro
|
||||
grep typedef ../src/include/*.h | grep switch_ | grep -v "\*\|{" | sed -e s/struct// | perl -ne '@l = split; $l[2] =~ s/;//g ; print "-T $l[2] "' >> ../.indent.pro
|
||||
grep "} switch_" ../src/include/*.h | perl -ne '@l = split; $l[1] =~ s/;//g ; print " -T $l[1] "' >> ../.indent.pro
|
||||
echo -n "-brs -npsl -di0 -br -ce -d0 -cli0 -npcs -nfc1 -ut -i4 -ts4 -l160 -cs -T size_t " > ./.indent.pro
|
||||
grep typedef ./src/include/*.h | grep switch_ | grep -v "\*\|{" | sed -e s/struct// | perl -ne '@l = split; $l[2] =~ s/;//g ; print "-T $l[2] "' >> ./.indent.pro
|
||||
grep "} switch_" ./src/include/*.h | perl -ne '@l = split; $l[1] =~ s/;//g ; print " -T $l[1] "' >> ./.indent.pro
|
||||
|
||||
+2
-2
@@ -78,8 +78,8 @@ AC_SUBST(RESAMPLE_CFLAGS)
|
||||
AM_CONDITIONAL([USE_INTREE_RESAMPLE],[test "${enable_resample}" = "yes"])
|
||||
|
||||
# set defaults for use on all platforms
|
||||
SWITCH_AM_CFLAGS="-I${switch_srcdir}/src/include"
|
||||
SWITCH_AM_CXXFLAGS="-I${switch_srcdir}/src/include"
|
||||
SWITCH_AM_CFLAGS="-I${switch_srcdir}/src/include -I${switch_srcdir}/libs/libteletone/src"
|
||||
SWITCH_AM_CXXFLAGS="-I${switch_srcdir}/src/include -I${switch_srcdir}/libs/libteletone/src"
|
||||
SWITCH_AM_LDFLAGS="-lm -L/usr/local/lib"
|
||||
|
||||
#set SOLINK variable based on compiler and host
|
||||
|
||||
@@ -64,10 +64,12 @@ extern "C" {
|
||||
This module is responsible for tone detection specifics
|
||||
*/
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#ifndef TRUE
|
||||
#define TRUE (!FALSE)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Basic DTMF specs:
|
||||
*
|
||||
|
||||
@@ -90,7 +90,9 @@
|
||||
#include <switch_stun.h>
|
||||
#include <switch_log.h>
|
||||
#include <switch_xml.h>
|
||||
|
||||
#include <switch_core_event_hook.h>
|
||||
#include <switch_scheduler.h>
|
||||
#include <libteletone.h>
|
||||
|
||||
/** \mainpage FreeSWITCH
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
|
||||
+111
-116
@@ -40,25 +40,22 @@
|
||||
#define SWITCH_APR_H
|
||||
|
||||
SWITCH_BEGIN_EXTERN_C
|
||||
|
||||
/*
|
||||
The pieces of apr we allow ppl to pass around between modules we typedef into our namespace and wrap all the functions
|
||||
any other apr code should be as hidden as possible.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup switch_apr Brought To You By APR
|
||||
* @ingroup FREESWITCH
|
||||
* @{
|
||||
*/
|
||||
|
||||
*/
|
||||
/**
|
||||
* @defgroup switch_memory_pool Memory Pool Functions
|
||||
* @ingroup switch_apr
|
||||
* @{
|
||||
*/
|
||||
/** The fundamental pool type */
|
||||
typedef struct apr_pool_t switch_memory_pool_t;
|
||||
typedef struct apr_pool_t switch_memory_pool_t;
|
||||
|
||||
|
||||
/**
|
||||
@@ -81,12 +78,12 @@ SWITCH_DECLARE(void) switch_pool_clear(switch_memory_pool_t *p);
|
||||
/**
|
||||
* Structure for referencing dynamic objects
|
||||
*/
|
||||
typedef struct apr_dso_handle_t switch_dso_handle_t;
|
||||
typedef struct apr_dso_handle_t switch_dso_handle_t;
|
||||
|
||||
/**
|
||||
* Structure for referencing symbols from dynamic objects
|
||||
*/
|
||||
typedef void * switch_dso_handle_sym_t;
|
||||
typedef void *switch_dso_handle_sym_t;
|
||||
|
||||
/**
|
||||
* Load a DSO library.
|
||||
@@ -96,8 +93,8 @@ typedef void * switch_dso_handle_sym_t;
|
||||
* @bug We aught to provide an alternative to RTLD_GLOBAL, which
|
||||
* is the only supported method of loading DSOs today.
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_dso_load(switch_dso_handle_t **res_handle,
|
||||
const char *path, switch_memory_pool_t *ctx);
|
||||
SWITCH_DECLARE(switch_status_t) switch_dso_load(switch_dso_handle_t **res_handle,
|
||||
const char *path, switch_memory_pool_t *ctx);
|
||||
|
||||
/**
|
||||
* Close a DSO library.
|
||||
@@ -111,9 +108,8 @@ SWITCH_DECLARE(switch_status_t) switch_dso_unload(switch_dso_handle_t *handle);
|
||||
* @param handle handle to load the symbol from.
|
||||
* @param symname Name of the symbol to load.
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_dso_sym(switch_dso_handle_sym_t *ressym,
|
||||
switch_dso_handle_t *handle,
|
||||
const char *symname);
|
||||
SWITCH_DECLARE(switch_status_t) switch_dso_sym(switch_dso_handle_sym_t * ressym,
|
||||
switch_dso_handle_t *handle, const char *symname);
|
||||
|
||||
/**
|
||||
* Report more information when a DSO function fails.
|
||||
@@ -146,10 +142,10 @@ SWITCH_DECLARE(char *) switch_copy_string(char *dst, const char *src, switch_siz
|
||||
*/
|
||||
|
||||
/** Abstract type for hash tables. */
|
||||
typedef struct apr_hash_t switch_hash_t;
|
||||
typedef struct apr_hash_t switch_hash_t;
|
||||
|
||||
/** Abstract type for scanning hash tables. */
|
||||
typedef struct apr_hash_index_t switch_hash_index_t;
|
||||
typedef struct apr_hash_index_t switch_hash_index_t;
|
||||
|
||||
/**
|
||||
* When passing a key to switch_hashfunc_default, this value can be
|
||||
@@ -208,40 +204,40 @@ SWITCH_DECLARE(switch_memory_pool_t *) switch_hash_pool_get(switch_hash_t *ht);
|
||||
*/
|
||||
|
||||
/** number of microseconds since 00:00:00 january 1, 1970 UTC */
|
||||
typedef int64_t switch_time_t;
|
||||
typedef int64_t switch_time_t;
|
||||
|
||||
/** number of microseconds in the interval */
|
||||
typedef int64_t switch_interval_time_t;
|
||||
typedef int64_t switch_interval_time_t;
|
||||
|
||||
/**
|
||||
* a structure similar to ANSI struct tm with the following differences:
|
||||
* - tm_usec isn't an ANSI field
|
||||
* - tm_gmtoff isn't an ANSI field (it's a bsdism)
|
||||
*/
|
||||
typedef struct switch_time_exp_t {
|
||||
/** microseconds past tm_sec */
|
||||
int32_t tm_usec;
|
||||
/** (0-61) seconds past tm_min */
|
||||
int32_t tm_sec;
|
||||
/** (0-59) minutes past tm_hour */
|
||||
int32_t tm_min;
|
||||
/** (0-23) hours past midnight */
|
||||
int32_t tm_hour;
|
||||
/** (1-31) day of the month */
|
||||
int32_t tm_mday;
|
||||
/** (0-11) month of the year */
|
||||
int32_t tm_mon;
|
||||
/** year since 1900 */
|
||||
int32_t tm_year;
|
||||
/** (0-6) days since sunday */
|
||||
int32_t tm_wday;
|
||||
/** (0-365) days since jan 1 */
|
||||
int32_t tm_yday;
|
||||
/** daylight saving time */
|
||||
int32_t tm_isdst;
|
||||
/** seconds east of UTC */
|
||||
int32_t tm_gmtoff;
|
||||
} switch_time_exp_t;
|
||||
typedef struct switch_time_exp_t {
|
||||
/** microseconds past tm_sec */
|
||||
int32_t tm_usec;
|
||||
/** (0-61) seconds past tm_min */
|
||||
int32_t tm_sec;
|
||||
/** (0-59) minutes past tm_hour */
|
||||
int32_t tm_min;
|
||||
/** (0-23) hours past midnight */
|
||||
int32_t tm_hour;
|
||||
/** (1-31) day of the month */
|
||||
int32_t tm_mday;
|
||||
/** (0-11) month of the year */
|
||||
int32_t tm_mon;
|
||||
/** year since 1900 */
|
||||
int32_t tm_year;
|
||||
/** (0-6) days since sunday */
|
||||
int32_t tm_wday;
|
||||
/** (0-365) days since jan 1 */
|
||||
int32_t tm_yday;
|
||||
/** daylight saving time */
|
||||
int32_t tm_isdst;
|
||||
/** seconds east of UTC */
|
||||
int32_t tm_gmtoff;
|
||||
} switch_time_exp_t;
|
||||
|
||||
SWITCH_DECLARE(switch_time_t) switch_time_make(switch_time_t sec, int32_t usec);
|
||||
|
||||
@@ -268,9 +264,7 @@ SWITCH_DECLARE(switch_status_t) switch_time_exp_gmt_get(switch_time_t *result, s
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_strftime(char *s,
|
||||
switch_size_t *retsize,
|
||||
switch_size_t max,
|
||||
const char *format,
|
||||
switch_time_exp_t *tm);
|
||||
switch_size_t max, const char *format, switch_time_exp_t *tm);
|
||||
|
||||
/**
|
||||
* switch_rfc822_date formats dates in the RFC822
|
||||
@@ -320,7 +314,7 @@ SWITCH_DECLARE(void) switch_sleep(switch_interval_time_t t);
|
||||
*/
|
||||
|
||||
/** Opaque thread-local mutex structure */
|
||||
typedef struct apr_thread_mutex_t switch_mutex_t;
|
||||
typedef struct apr_thread_mutex_t switch_mutex_t;
|
||||
|
||||
/** Lock Flags */
|
||||
#define SWITCH_MUTEX_DEFAULT 0x0 /**< platform-optimal lock behavior */
|
||||
@@ -344,8 +338,7 @@ typedef struct apr_thread_mutex_t switch_mutex_t;
|
||||
*
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_mutex_init(switch_mutex_t **lock,
|
||||
unsigned int flags,
|
||||
switch_memory_pool_t *pool);
|
||||
unsigned int flags, switch_memory_pool_t *pool);
|
||||
|
||||
|
||||
/**
|
||||
@@ -385,10 +378,10 @@ SWITCH_DECLARE(switch_status_t) switch_mutex_trylock(switch_mutex_t *lock);
|
||||
*/
|
||||
|
||||
/** Opaque structure used for the rwlock */
|
||||
typedef struct apr_thread_rwlock_t switch_thread_rwlock_t;
|
||||
typedef struct apr_thread_rwlock_t switch_thread_rwlock_t;
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_create(switch_thread_rwlock_t **rwlock,
|
||||
switch_memory_pool_t *pool);
|
||||
switch_memory_pool_t *pool);
|
||||
SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_destroy(switch_thread_rwlock_t *rwlock);
|
||||
SWITCH_DECLARE(switch_memory_pool_t *) switch_thread_rwlock_pool_get(switch_thread_rwlock_t *rwlock);
|
||||
SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_rdlock(switch_thread_rwlock_t *rwlock);
|
||||
@@ -412,7 +405,7 @@ SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_unlock(switch_thread_rwlock
|
||||
*/
|
||||
|
||||
/** Opaque structure for thread condition variables */
|
||||
typedef struct apr_thread_cond_t switch_thread_cond_t;
|
||||
typedef struct apr_thread_cond_t switch_thread_cond_t;
|
||||
|
||||
/**
|
||||
* Create and initialize a condition variable that can be used to signal
|
||||
@@ -453,7 +446,8 @@ SWITCH_DECLARE(switch_status_t) switch_thread_cond_wait(switch_thread_cond_t *co
|
||||
* will wake up before this time, otherwise the error APR_TIMEUP
|
||||
* is returned.
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_thread_cond_timedwait(switch_thread_cond_t *cond, switch_mutex_t *mutex, switch_interval_time_t timeout);
|
||||
SWITCH_DECLARE(switch_status_t) switch_thread_cond_timedwait(switch_thread_cond_t *cond, switch_mutex_t *mutex,
|
||||
switch_interval_time_t timeout);
|
||||
|
||||
/**
|
||||
* Signals a single thread, if one exists, that is blocking on the given
|
||||
@@ -488,9 +482,10 @@ SWITCH_DECLARE(switch_status_t) switch_thread_cond_destroy(switch_thread_cond_t
|
||||
|
||||
/** we represent a UUID as a block of 16 bytes. */
|
||||
|
||||
typedef struct {
|
||||
unsigned char data[16]; /**< the actual UUID */
|
||||
} switch_uuid_t;
|
||||
typedef struct {
|
||||
unsigned char data[16];
|
||||
/**< the actual UUID */
|
||||
} switch_uuid_t;
|
||||
|
||||
/** UUIDs are formatted as: 00112233-4455-6677-8899-AABBCCDDEEFF */
|
||||
#define SWITCH_UUID_FORMATTED_LENGTH 36
|
||||
@@ -501,20 +496,20 @@ typedef struct {
|
||||
* be at least APR_UUID_FORMATTED_LENGTH + 1 bytes long to hold
|
||||
* the formatted UUID and a null terminator
|
||||
* @param uuid The UUID to format
|
||||
*/
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_uuid_format(char *buffer, const switch_uuid_t *uuid);
|
||||
|
||||
/**
|
||||
* Generate and return a (new) UUID
|
||||
* @param uuid The resulting UUID
|
||||
*/
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_uuid_get(switch_uuid_t *uuid);
|
||||
|
||||
/**
|
||||
* Parse a standard-format string into a UUID
|
||||
* @param uuid The resulting UUID
|
||||
* @param uuid_str The formatted UUID
|
||||
*/
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_uuid_parse(switch_uuid_t *uuid, const char *uuid_str);
|
||||
|
||||
/** @} */
|
||||
@@ -526,7 +521,7 @@ SWITCH_DECLARE(switch_status_t) switch_uuid_parse(switch_uuid_t *uuid, const cha
|
||||
*/
|
||||
|
||||
/** Opaque structure used for queue API */
|
||||
typedef struct apr_queue_t switch_queue_t;
|
||||
typedef struct apr_queue_t switch_queue_t;
|
||||
|
||||
/**
|
||||
* create a FIFO queue
|
||||
@@ -534,9 +529,8 @@ typedef struct apr_queue_t switch_queue_t;
|
||||
* @param queue_capacity maximum size of the queue
|
||||
* @param a pool to allocate queue from
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_queue_create(switch_queue_t **queue,
|
||||
unsigned int queue_capacity,
|
||||
switch_memory_pool_t *pool);
|
||||
SWITCH_DECLARE(switch_status_t) switch_queue_create(switch_queue_t **queue,
|
||||
unsigned int queue_capacity, switch_memory_pool_t *pool);
|
||||
|
||||
/**
|
||||
* pop/get an object from the queue, blocking if the queue is already empty
|
||||
@@ -603,17 +597,17 @@ SWITCH_DECLARE(switch_status_t) switch_queue_trypush(switch_queue_t *queue, void
|
||||
*/
|
||||
|
||||
/** Structure for referencing files. */
|
||||
typedef struct apr_file_t switch_file_t;
|
||||
typedef struct apr_file_t switch_file_t;
|
||||
|
||||
typedef int32_t switch_fileperms_t;
|
||||
typedef int switch_seek_where_t;
|
||||
typedef int32_t switch_fileperms_t;
|
||||
typedef int switch_seek_where_t;
|
||||
|
||||
/**
|
||||
* @defgroup switch_file_permissions File Permissions flags
|
||||
* @ingroup switch_file_io
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
#define SWITCH_FPROT_USETID 0x8000 /**< Set user id */
|
||||
#define SWITCH_FPROT_UREAD 0x0400 /**< Read by user */
|
||||
#define SWITCH_FPROT_UWRITE 0x0200 /**< Write by user */
|
||||
@@ -690,7 +684,8 @@ typedef int switch_seek_where_t;
|
||||
* @remark If perm is SWITCH_FPROT_OS_DEFAULT and the file is being created,
|
||||
* appropriate default permissions will be used.
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_file_open(switch_file_t **newf, const char *fname, int32_t flag, switch_fileperms_t perm, switch_memory_pool_t *pool);
|
||||
SWITCH_DECLARE(switch_status_t) switch_file_open(switch_file_t **newf, const char *fname, int32_t flag,
|
||||
switch_fileperms_t perm, switch_memory_pool_t *pool);
|
||||
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_file_seek(switch_file_t *thefile, switch_seek_where_t where, int64_t *offset);
|
||||
@@ -757,16 +752,16 @@ SWITCH_DECLARE(switch_status_t) switch_file_exists(const char *filename);
|
||||
*/
|
||||
|
||||
/** Opaque Thread structure. */
|
||||
typedef struct apr_thread_t switch_thread_t;
|
||||
typedef struct apr_thread_t switch_thread_t;
|
||||
|
||||
/** Opaque Thread attributes structure. */
|
||||
typedef struct apr_threadattr_t switch_threadattr_t;
|
||||
typedef struct apr_threadattr_t switch_threadattr_t;
|
||||
|
||||
/**
|
||||
* The prototype for any APR thread worker functions.
|
||||
* typedef void *(SWITCH_THREAD_FUNC *switch_thread_start_t)(switch_thread_t*, void*);
|
||||
*/
|
||||
typedef void *(SWITCH_THREAD_FUNC *switch_thread_start_t)(switch_thread_t*, void*);
|
||||
typedef void *(SWITCH_THREAD_FUNC * switch_thread_start_t) (switch_thread_t *, void *);
|
||||
|
||||
//APR_DECLARE(apr_status_t) apr_threadattr_stacksize_set(apr_threadattr_t *attr, switch_size_t stacksize)
|
||||
SWITCH_DECLARE(switch_status_t) switch_threadattr_stacksize_set(switch_threadattr_t *attr, switch_size_t stacksize);
|
||||
@@ -793,7 +788,9 @@ SWITCH_DECLARE(switch_status_t) switch_threadattr_detach_set(switch_threadattr_t
|
||||
* @param data Any data to be passed to the starting function
|
||||
* @param cont The pool to use
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_thread_create(switch_thread_t **new_thread, switch_threadattr_t *attr, switch_thread_start_t func, void *data, switch_memory_pool_t *cont);
|
||||
SWITCH_DECLARE(switch_status_t) switch_thread_create(switch_thread_t **new_thread, switch_threadattr_t *attr,
|
||||
switch_thread_start_t func, void *data,
|
||||
switch_memory_pool_t *cont);
|
||||
|
||||
/** @} */
|
||||
|
||||
@@ -829,16 +826,16 @@ SWITCH_DECLARE(switch_status_t) switch_thread_create(switch_thread_t **new_threa
|
||||
#endif
|
||||
|
||||
/** A structure to represent sockets */
|
||||
typedef struct apr_socket_t switch_socket_t;
|
||||
typedef struct apr_socket_t switch_socket_t;
|
||||
|
||||
/** Freeswitch's socket address type, used to ensure protocol independence */
|
||||
typedef struct apr_sockaddr_t switch_sockaddr_t;
|
||||
typedef struct apr_sockaddr_t switch_sockaddr_t;
|
||||
|
||||
typedef enum {
|
||||
SWITCH_SHUTDOWN_READ, /**< no longer allow read request */
|
||||
SWITCH_SHUTDOWN_WRITE, /**< no longer allow write requests */
|
||||
SWITCH_SHUTDOWN_READWRITE /**< no longer allow read or write requests */
|
||||
} switch_shutdown_how_e;
|
||||
typedef enum {
|
||||
SWITCH_SHUTDOWN_READ, /**< no longer allow read request */
|
||||
SWITCH_SHUTDOWN_WRITE, /**< no longer allow write requests */
|
||||
SWITCH_SHUTDOWN_READWRITE /**< no longer allow read or write requests */
|
||||
} switch_shutdown_how_e;
|
||||
|
||||
/**
|
||||
* @defgroup IP_Proto IP Protocol Definitions for use when creating sockets
|
||||
@@ -859,7 +856,8 @@ typedef enum {
|
||||
* @param protocol The protocol of the socket (e.g., SWITCH_PROTO_TCP).
|
||||
* @param pool The pool to use
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_socket_create(switch_socket_t **new_sock, int family, int type, int protocol, switch_memory_pool_t *pool);
|
||||
SWITCH_DECLARE(switch_status_t) switch_socket_create(switch_socket_t **new_sock, int family, int type,
|
||||
int protocol, switch_memory_pool_t *pool);
|
||||
|
||||
/**
|
||||
* Shutdown either reading, writing, or both sides of a socket.
|
||||
@@ -874,13 +872,13 @@ SWITCH_DECLARE(switch_status_t) switch_socket_create(switch_socket_t **new_sock,
|
||||
* @remark This does not actually close the socket descriptor, it just
|
||||
* controls which calls are still valid on the socket.
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_socket_shutdown(switch_socket_t *sock, switch_shutdown_how_e how);
|
||||
SWITCH_DECLARE(switch_status_t) switch_socket_shutdown(switch_socket_t *sock, switch_shutdown_how_e how);
|
||||
|
||||
/**
|
||||
* Close a socket.
|
||||
* @param sock The socket to close
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_socket_close(switch_socket_t *sock);
|
||||
SWITCH_DECLARE(switch_status_t) switch_socket_close(switch_socket_t *sock);
|
||||
|
||||
/**
|
||||
* Bind the socket to its associated port
|
||||
@@ -889,7 +887,7 @@ SWITCH_DECLARE(switch_status_t) switch_socket_close(switch_socket_t *sock);
|
||||
* @remark This may be where we will find out if there is any other process
|
||||
* using the selected port.
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_socket_bind(switch_socket_t *sock, switch_sockaddr_t *sa);
|
||||
SWITCH_DECLARE(switch_status_t) switch_socket_bind(switch_socket_t *sock, switch_sockaddr_t *sa);
|
||||
|
||||
/**
|
||||
* Listen to a bound socket for connections.
|
||||
@@ -898,7 +896,7 @@ SWITCH_DECLARE(switch_status_t) switch_socket_bind(switch_socket_t *sock, switch
|
||||
* listen queue. If this value is less than zero, the listen
|
||||
* queue size is set to zero.
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_socket_listen(switch_socket_t *sock, int32_t backlog);
|
||||
SWITCH_DECLARE(switch_status_t) switch_socket_listen(switch_socket_t *sock, int32_t backlog);
|
||||
|
||||
/**
|
||||
* Accept a new connection request
|
||||
@@ -908,7 +906,8 @@ SWITCH_DECLARE(switch_status_t) switch_socket_listen(switch_socket_t *sock, int3
|
||||
* @param sock The socket we are listening on.
|
||||
* @param connection_pool The pool for the new socket.
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_socket_accept(switch_socket_t **new_sock, switch_socket_t *sock, switch_memory_pool_t *pool);
|
||||
SWITCH_DECLARE(switch_status_t) switch_socket_accept(switch_socket_t **new_sock, switch_socket_t *sock,
|
||||
switch_memory_pool_t *pool);
|
||||
|
||||
/**
|
||||
* Issue a connection request to a socket either on the same machine
|
||||
@@ -916,12 +915,12 @@ SWITCH_DECLARE(switch_status_t) switch_socket_accept(switch_socket_t **new_sock,
|
||||
* @param sock The socket we wish to use for our side of the connection
|
||||
* @param sa The address of the machine we wish to connect to.
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_socket_connect(switch_socket_t *sock, switch_sockaddr_t *sa);
|
||||
SWITCH_DECLARE(switch_status_t) switch_socket_connect(switch_socket_t *sock, switch_sockaddr_t *sa);
|
||||
|
||||
SWITCH_DECLARE(uint16_t) switch_sockaddr_get_port(switch_sockaddr_t *sa);
|
||||
SWITCH_DECLARE(char *) switch_get_addr(char *buf, switch_size_t len, switch_sockaddr_t *in);
|
||||
SWITCH_DECLARE(int32_t) switch_sockaddr_get_family(switch_sockaddr_t *sa);
|
||||
SWITCH_DECLARE(switch_status_t) switch_sockaddr_ip_get(char **addr, switch_sockaddr_t *sa);
|
||||
SWITCH_DECLARE(uint16_t) switch_sockaddr_get_port(switch_sockaddr_t *sa);
|
||||
SWITCH_DECLARE(char *) switch_get_addr(char *buf, switch_size_t len, switch_sockaddr_t *in);
|
||||
SWITCH_DECLARE(int32_t) switch_sockaddr_get_family(switch_sockaddr_t *sa);
|
||||
SWITCH_DECLARE(switch_status_t) switch_sockaddr_ip_get(char **addr, switch_sockaddr_t *sa);
|
||||
|
||||
|
||||
/**
|
||||
@@ -947,7 +946,9 @@ SWITCH_DECLARE(switch_status_t) switch_sockaddr_ip_get(char **addr, switch_socka
|
||||
* </PRE>
|
||||
* @param p The pool for the apr_sockaddr_t and associated storage.
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_sockaddr_info_get(switch_sockaddr_t **sa, const char *hostname, int32_t family, switch_port_t port, int32_t flags, switch_memory_pool_t *pool);
|
||||
SWITCH_DECLARE(switch_status_t) switch_sockaddr_info_get(switch_sockaddr_t **sa, const char *hostname,
|
||||
int32_t family, switch_port_t port, int32_t flags,
|
||||
switch_memory_pool_t *pool);
|
||||
|
||||
/**
|
||||
* Send data over a network.
|
||||
@@ -966,7 +967,7 @@ SWITCH_DECLARE(switch_status_t) switch_sockaddr_info_get(switch_sockaddr_t **sa,
|
||||
* APR_EINTR is never returned.
|
||||
* </PRE>
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_socket_send(switch_socket_t *sock, const char *buf, switch_size_t *len);
|
||||
SWITCH_DECLARE(switch_status_t) switch_socket_send(switch_socket_t *sock, const char *buf, switch_size_t *len);
|
||||
|
||||
/**
|
||||
* @param sock The socket to send from
|
||||
@@ -975,7 +976,8 @@ SWITCH_DECLARE(switch_status_t) switch_socket_send(switch_socket_t *sock, const
|
||||
* @param buf The data to send
|
||||
* @param len The length of the data to send
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_socket_sendto(switch_socket_t *sock, switch_sockaddr_t *where, int32_t flags, const char *buf, switch_size_t *len);
|
||||
SWITCH_DECLARE(switch_status_t) switch_socket_sendto(switch_socket_t *sock, switch_sockaddr_t *where,
|
||||
int32_t flags, const char *buf, switch_size_t *len);
|
||||
|
||||
/**
|
||||
* @param from The apr_sockaddr_t to fill in the recipient info
|
||||
@@ -985,11 +987,9 @@ SWITCH_DECLARE(switch_status_t) switch_socket_sendto(switch_socket_t *sock, swit
|
||||
* @param len The length of the available buffer
|
||||
*
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_socket_recvfrom(switch_sockaddr_t *from,
|
||||
switch_socket_t *sock,
|
||||
int32_t flags,
|
||||
char *buf,
|
||||
size_t *len);
|
||||
SWITCH_DECLARE(switch_status_t) switch_socket_recvfrom(switch_sockaddr_t *from,
|
||||
switch_socket_t *sock,
|
||||
int32_t flags, char *buf, size_t *len);
|
||||
|
||||
|
||||
/**
|
||||
@@ -1011,7 +1011,7 @@ SWITCH_DECLARE(switch_status_t) switch_socket_recvfrom(switch_sockaddr_t *from,
|
||||
* APR_EINTR is never returned.
|
||||
* </PRE>
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_socket_recv(switch_socket_t *sock, char *buf, switch_size_t *len);
|
||||
SWITCH_DECLARE(switch_status_t) switch_socket_recv(switch_socket_t *sock, char *buf, switch_size_t *len);
|
||||
|
||||
/**
|
||||
* Setup socket options for the specified socket
|
||||
@@ -1035,7 +1035,7 @@ SWITCH_DECLARE(switch_status_t) switch_socket_recv(switch_socket_t *sock, char *
|
||||
* </PRE>
|
||||
* @param on Value for the option.
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_socket_opt_set(switch_socket_t *sock, int32_t opt, int32_t on);
|
||||
SWITCH_DECLARE(switch_status_t) switch_socket_opt_set(switch_socket_t *sock, int32_t opt, int32_t on);
|
||||
|
||||
/**
|
||||
* Setup socket timeout for the specified socket
|
||||
@@ -1048,7 +1048,7 @@ SWITCH_DECLARE(switch_status_t) switch_socket_opt_set(switch_socket_t *sock, int
|
||||
* t < 0 -- read and write calls block
|
||||
* </PRE>
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_socket_timeout_set(switch_socket_t *sock, switch_interval_time_t t);
|
||||
SWITCH_DECLARE(switch_status_t) switch_socket_timeout_set(switch_socket_t *sock, switch_interval_time_t t);
|
||||
|
||||
/**
|
||||
* Join a Multicast Group
|
||||
@@ -1059,7 +1059,8 @@ SWITCH_DECLARE(switch_status_t) switch_socket_timeout_set(switch_socket_t *sock,
|
||||
* @param source Source Address to accept transmissions from (non-NULL
|
||||
* implies Source-Specific Multicast)
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_mcast_join(switch_socket_t *sock, switch_sockaddr_t *join, switch_sockaddr_t *iface, switch_sockaddr_t *source);
|
||||
SWITCH_DECLARE(switch_status_t) switch_mcast_join(switch_socket_t *sock, switch_sockaddr_t *join,
|
||||
switch_sockaddr_t *iface, switch_sockaddr_t *source);
|
||||
|
||||
|
||||
|
||||
@@ -1071,10 +1072,10 @@ SWITCH_DECLARE(switch_status_t) switch_mcast_join(switch_socket_t *sock, switch_
|
||||
* @{
|
||||
*/
|
||||
/** Poll descriptor set. */
|
||||
typedef struct apr_pollfd_t switch_pollfd_t;
|
||||
typedef struct apr_pollfd_t switch_pollfd_t;
|
||||
|
||||
/** Opaque structure used for pollset API */
|
||||
typedef struct apr_pollset_t switch_pollset_t;
|
||||
typedef struct apr_pollset_t switch_pollset_t;
|
||||
|
||||
/**
|
||||
* Poll options
|
||||
@@ -1100,10 +1101,8 @@ typedef struct apr_pollset_t switch_pollset_t;
|
||||
* platforms; the apr_pollset_create() call will fail with
|
||||
* APR_ENOTIMPL on platforms where it is not supported.
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_pollset_create(switch_pollset_t **pollset,
|
||||
uint32_t size,
|
||||
switch_memory_pool_t *p,
|
||||
uint32_t flags);
|
||||
SWITCH_DECLARE(switch_status_t) switch_pollset_create(switch_pollset_t **pollset,
|
||||
uint32_t size, switch_memory_pool_t *p, uint32_t flags);
|
||||
|
||||
/**
|
||||
* Add a socket or file descriptor to a pollset
|
||||
@@ -1122,8 +1121,7 @@ SWITCH_DECLARE(switch_status_t) switch_pollset_create(switch_pollset_t **pollset
|
||||
* allowed for implementations where option (1) is impossible
|
||||
* or impractical.
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_pollset_add(switch_pollset_t *pollset,
|
||||
const switch_pollfd_t *descriptor);
|
||||
SWITCH_DECLARE(switch_status_t) switch_pollset_add(switch_pollset_t *pollset, const switch_pollfd_t *descriptor);
|
||||
|
||||
/**
|
||||
* Poll the sockets in the poll structure
|
||||
@@ -1138,10 +1136,8 @@ SWITCH_DECLARE(switch_status_t) switch_pollset_add(switch_pollset_t *pollset,
|
||||
* This is a blocking call, and it will not return until either a
|
||||
* socket has been signalled, or the timeout has expired.
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_poll(switch_pollfd_t *aprset,
|
||||
int32_t numsock,
|
||||
int32_t *nsds,
|
||||
switch_interval_time_t timeout);
|
||||
SWITCH_DECLARE(switch_status_t) switch_poll(switch_pollfd_t *aprset,
|
||||
int32_t numsock, int32_t *nsds, switch_interval_time_t timeout);
|
||||
|
||||
/*!
|
||||
\brief Create a set of file descriptors to poll
|
||||
@@ -1151,9 +1147,10 @@ SWITCH_DECLARE(switch_status_t) switch_poll(switch_pollfd_t *aprset,
|
||||
\param pool the memory pool to use
|
||||
\return SWITCH_STATUS_SUCCESS when successful
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_socket_create_pollfd(switch_pollfd_t **poll, switch_socket_t *sock, int16_t flags, switch_memory_pool_t *pool);
|
||||
SWITCH_DECLARE(switch_status_t) switch_socket_create_pollfd(switch_pollfd_t **poll, switch_socket_t *sock,
|
||||
int16_t flags, switch_memory_pool_t *pool);
|
||||
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -1162,10 +1159,8 @@ SWITCH_DECLARE(switch_status_t) switch_socket_create_pollfd(switch_pollfd_t **po
|
||||
/** @} */
|
||||
/** @} */
|
||||
|
||||
SWITCH_END_EXTERN_C
|
||||
|
||||
SWITCH_END_EXTERN_C
|
||||
#endif
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
|
||||
@@ -36,22 +36,20 @@
|
||||
#ifndef SWITCH_BITPACK_H
|
||||
#define SWITCH_BITPACK_H
|
||||
SWITCH_BEGIN_EXTERN_C
|
||||
|
||||
#include <switch.h>
|
||||
|
||||
#ifdef DEBUG_BITS
|
||||
static char bb[80] = "";
|
||||
static inline char *print_bits(switch_byte_t byte, char *x)
|
||||
{
|
||||
|
||||
int i,j = 0;
|
||||
x[j++] = '[';
|
||||
for (i=7;i>=0;i--) {
|
||||
x[j++] = (byte & (1 << i)) ? '1' : '0';
|
||||
}
|
||||
x[j++] = ']';
|
||||
x[j++] = '\0';
|
||||
return x;
|
||||
int i, j = 0;
|
||||
x[j++] = '[';
|
||||
for (i = 7; i >= 0; i--) {
|
||||
x[j++] = (byte & (1 << i)) ? '1' : '0';
|
||||
}
|
||||
x[j++] = ']';
|
||||
x[j++] = '\0';
|
||||
return x;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -63,8 +61,8 @@ static inline char *print_bits(switch_byte_t byte, char *x)
|
||||
\{
|
||||
*/
|
||||
|
||||
static const uint8_t SWITCH_BITPACKED_MASKS[] = {0, 1, 3, 7, 15, 31, 63, 127, 255};
|
||||
static const uint8_t SWITCH_REVERSE_BITPACKED_MASKS[] = {255, 254, 252, 248, 240, 224, 192, 128};
|
||||
static const uint8_t SWITCH_BITPACKED_MASKS[] = { 0, 1, 3, 7, 15, 31, 63, 127, 255 };
|
||||
static const uint8_t SWITCH_REVERSE_BITPACKED_MASKS[] = { 255, 254, 252, 248, 240, 224, 192, 128 };
|
||||
|
||||
/*!
|
||||
\brief Initialize a bitpack object
|
||||
@@ -74,8 +72,11 @@ static const uint8_t SWITCH_REVERSE_BITPACKED_MASKS[] = {255, 254, 252, 248, 240
|
||||
\param buflen the length of the storage buffer
|
||||
\param mode RFC3551 or AAL2 mode (curse you backwards folks)
|
||||
*/
|
||||
DoxyDefine(void switch_bitpack_init(switch_bitpack_t *pack, int32_t bitlen, switch_byte_t *buf, uint32_t buflen, switch_bitpack_mode_t mode))
|
||||
static inline int8_t switch_bitpack_init(switch_bitpack_t *pack, switch_byte_t bitlen, switch_byte_t *buf, uint32_t buflen, switch_bitpack_mode_t mode)
|
||||
DoxyDefine(void
|
||||
switch_bitpack_init(switch_bitpack_t *pack, int32_t bitlen, switch_byte_t *buf, uint32_t buflen,
|
||||
switch_bitpack_mode_t mode))
|
||||
static inline int8_t switch_bitpack_init(switch_bitpack_t *pack, switch_byte_t bitlen, switch_byte_t *buf,
|
||||
uint32_t buflen, switch_bitpack_mode_t mode)
|
||||
{
|
||||
if (!pack || (bitlen > SWITCH_BITS_PER_BYTE) || !buf || !buflen) {
|
||||
return -1;
|
||||
@@ -94,7 +95,7 @@ static inline int8_t switch_bitpack_init(switch_bitpack_t *pack, switch_byte_t b
|
||||
|
||||
static inline void pack_check_over(switch_bitpack_t *pack)
|
||||
{
|
||||
switch_byte_t this_byte = pack->this_byte;
|
||||
switch_byte_t this_byte = pack->this_byte;
|
||||
|
||||
if (pack->over) {
|
||||
pack->bits_cur = pack->over;
|
||||
@@ -117,7 +118,7 @@ static inline void pack_check_over(switch_bitpack_t *pack)
|
||||
|
||||
pack->bytes++;
|
||||
pack->over = pack->under = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -125,14 +126,14 @@ static inline void pack_check_over(switch_bitpack_t *pack)
|
||||
\param pack the pack/unpack object
|
||||
*/
|
||||
DoxyDefine(int8_t switch_bitpack_done(switch_bitpack_t *pack))
|
||||
static inline int8_t switch_bitpack_done(switch_bitpack_t *pack)
|
||||
static inline int8_t switch_bitpack_done(switch_bitpack_t *pack)
|
||||
{
|
||||
|
||||
if (pack->bits_cur && pack->bits_cur < SWITCH_BITS_PER_BYTE) {
|
||||
pack->bytes++;
|
||||
if (pack->mode == SWITCH_BITPACK_MODE_AAL2) {
|
||||
*pack->cur <<= SWITCH_BITS_PER_BYTE - pack->bits_cur;
|
||||
}
|
||||
*pack->cur <<= SWITCH_BITS_PER_BYTE - pack->bits_cur;
|
||||
}
|
||||
}
|
||||
|
||||
if (pack->over) {
|
||||
@@ -149,11 +150,11 @@ static inline int8_t switch_bitpack_done(switch_bitpack_t *pack)
|
||||
\return -1 if the buffer is full otherwise 0
|
||||
*/
|
||||
DoxyDefine(int8_t switch_bitpack_out(switch_bitpack_t *unpack, switch_byte_t in))
|
||||
static inline int8_t switch_bitpack_out(switch_bitpack_t *unpack, switch_byte_t in)
|
||||
static inline int8_t switch_bitpack_out(switch_bitpack_t *unpack, switch_byte_t in)
|
||||
{
|
||||
switch_byte_t this_byte;
|
||||
|
||||
if ((uint32_t)(unpack->cur - unpack->buf) > unpack->buflen) {
|
||||
if ((uint32_t) (unpack->cur - unpack->buf) > unpack->buflen) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -163,7 +164,7 @@ static inline int8_t switch_bitpack_out(switch_bitpack_t *unpack, switch_byte_t
|
||||
|
||||
|
||||
pack_check_over(unpack);
|
||||
while(unpack->bits_cur <= SWITCH_BITS_PER_BYTE) {
|
||||
while (unpack->bits_cur <= SWITCH_BITS_PER_BYTE) {
|
||||
switch_byte_t next = unpack->bits_cur + unpack->frame_bits;
|
||||
switch_byte_t under_in;
|
||||
switch_byte_t mask;
|
||||
@@ -220,20 +221,20 @@ static inline int8_t switch_bitpack_out(switch_bitpack_t *unpack, switch_byte_t
|
||||
\return -1 if the buffer is full otherwise 0
|
||||
*/
|
||||
DoxyDefine(int8_t switch_bitpack_in(switch_bitpack_t *pack, switch_byte_t in))
|
||||
static inline int8_t switch_bitpack_in(switch_bitpack_t *pack, switch_byte_t in)
|
||||
static inline int8_t switch_bitpack_in(switch_bitpack_t *pack, switch_byte_t in)
|
||||
{
|
||||
int next = pack->bits_cur + pack->frame_bits;
|
||||
|
||||
if ((uint32_t)(pack->cur - pack->buf) > pack->buflen) {
|
||||
if ((uint32_t) (pack->cur - pack->buf) > pack->buflen) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
pack->bits_tot += pack->frame_bits;
|
||||
|
||||
if (next > SWITCH_BITS_PER_BYTE) {
|
||||
switch_byte_t a = 0, b = 0, rem, nxt;
|
||||
rem = SWITCH_BITS_PER_BYTE - pack->bits_cur;
|
||||
nxt = pack->frame_bits - rem ;
|
||||
nxt = pack->frame_bits - rem;
|
||||
if (pack->mode == SWITCH_BITPACK_MODE_RFC3551) {
|
||||
a = in & SWITCH_BITPACKED_MASKS[rem];
|
||||
b = in >> rem;
|
||||
@@ -250,7 +251,7 @@ static inline int8_t switch_bitpack_in(switch_bitpack_t *pack, switch_byte_t in)
|
||||
pack->cur++;
|
||||
*pack->cur |= b;
|
||||
pack->bits_cur = nxt;
|
||||
|
||||
|
||||
}
|
||||
pack->bytes++;
|
||||
|
||||
@@ -259,14 +260,14 @@ static inline int8_t switch_bitpack_in(switch_bitpack_t *pack, switch_byte_t in)
|
||||
if (pack->mode == SWITCH_BITPACK_MODE_RFC3551) {
|
||||
in <<= pack->shiftby;
|
||||
*pack->cur |= in;
|
||||
pack->shiftby = (switch_byte_t)(pack->shiftby + pack->frame_bits);
|
||||
pack->shiftby = (switch_byte_t) (pack->shiftby + pack->frame_bits);
|
||||
} else {
|
||||
*pack->cur <<= pack->frame_bits;
|
||||
*pack->cur |= in;
|
||||
}
|
||||
|
||||
if (next == SWITCH_BITS_PER_BYTE) {
|
||||
pack->cur++;
|
||||
pack->cur++;
|
||||
pack->bytes++;
|
||||
pack->bits_cur = pack->shiftby = 0;
|
||||
} else {
|
||||
@@ -276,11 +277,11 @@ static inline int8_t switch_bitpack_in(switch_bitpack_t *pack, switch_byte_t in)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
///\}
|
||||
|
||||
SWITCH_END_EXTERN_C
|
||||
#endif
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
|
||||
@@ -41,7 +41,6 @@
|
||||
#include <switch.h>
|
||||
|
||||
SWITCH_BEGIN_EXTERN_C
|
||||
|
||||
/**
|
||||
* @defgroup switch_buffer Buffer Routines
|
||||
* @ingroup core1
|
||||
@@ -50,8 +49,7 @@ SWITCH_BEGIN_EXTERN_C
|
||||
* and I think it can be optimized under the hood as we go using bucket brigades and/or ring buffering techniques.
|
||||
* @{
|
||||
*/
|
||||
|
||||
struct switch_buffer;
|
||||
struct switch_buffer;
|
||||
|
||||
|
||||
/*! \brief Allocate a new switch_buffer
|
||||
@@ -60,7 +58,8 @@ struct switch_buffer;
|
||||
* \param max_len length required by the buffer
|
||||
* \return status
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_buffer_create(switch_memory_pool_t *pool, switch_buffer_t **buffer, switch_size_t max_len);
|
||||
SWITCH_DECLARE(switch_status_t) switch_buffer_create(switch_memory_pool_t *pool, switch_buffer_t **buffer,
|
||||
switch_size_t max_len);
|
||||
|
||||
/*! \brief Allocate a new dynamic switch_buffer
|
||||
* \param buffer returned pointer to the new buffer
|
||||
@@ -71,8 +70,7 @@ SWITCH_DECLARE(switch_status_t) switch_buffer_create(switch_memory_pool_t *pool,
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_buffer_create_dynamic(switch_buffer_t **buffer,
|
||||
switch_size_t blocksize,
|
||||
switch_size_t start_len,
|
||||
switch_size_t max_len);
|
||||
switch_size_t start_len, switch_size_t max_len);
|
||||
|
||||
/*! \brief Get the length of a switch_buffer_t
|
||||
* \param buffer any buffer of type switch_buffer_t
|
||||
@@ -129,9 +127,7 @@ SWITCH_DECLARE(void) switch_buffer_destroy(switch_buffer_t **buffer);
|
||||
/** @} */
|
||||
|
||||
SWITCH_END_EXTERN_C
|
||||
|
||||
#endif
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
|
||||
@@ -56,10 +56,9 @@
|
||||
#include <switch.h>
|
||||
|
||||
SWITCH_BEGIN_EXTERN_C
|
||||
|
||||
/*! \brief Call Specific Data
|
||||
*/
|
||||
struct switch_caller_profile {
|
||||
struct switch_caller_profile {
|
||||
/*! The Call's User Name */
|
||||
char *username;
|
||||
/*! The name of the dialplan */
|
||||
@@ -129,9 +128,7 @@ struct switch_caller_extension {
|
||||
\return a new extension object allocated from the session's memory pool
|
||||
*/
|
||||
SWITCH_DECLARE(switch_caller_extension_t *) switch_caller_extension_new(switch_core_session_t *session,
|
||||
char *extension_name,
|
||||
char *extension_number
|
||||
);
|
||||
char *extension_name, char *extension_number);
|
||||
|
||||
/*!
|
||||
\brief Add an application (instruction) to the given extension
|
||||
@@ -142,8 +139,7 @@ SWITCH_DECLARE(switch_caller_extension_t *) switch_caller_extension_new(switch_c
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_caller_extension_add_application(switch_core_session_t *session,
|
||||
switch_caller_extension_t *caller_extension,
|
||||
char *application_name,
|
||||
char *extra_data);
|
||||
char *application_name, char *extra_data);
|
||||
|
||||
|
||||
/*!
|
||||
@@ -188,9 +184,9 @@ SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_new(switch_memor
|
||||
\param session session associated with the profile (bound by scope)
|
||||
\param tocopy the existing profile
|
||||
*/
|
||||
|
||||
|
||||
SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_clone(switch_core_session_t *session,
|
||||
switch_caller_profile_t *tocopy);
|
||||
switch_caller_profile_t *tocopy);
|
||||
|
||||
/*!
|
||||
\brief Add headers to an existing event in regards to a specific profile
|
||||
@@ -199,14 +195,12 @@ SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_clone(switch_cor
|
||||
\param event the event to add the information to
|
||||
*/
|
||||
|
||||
SWITCH_DECLARE(void) switch_caller_profile_event_set_data(switch_caller_profile_t *caller_profile, char *prefix, switch_event_t *event);
|
||||
SWITCH_DECLARE(void) switch_caller_profile_event_set_data(switch_caller_profile_t *caller_profile, char *prefix,
|
||||
switch_event_t *event);
|
||||
|
||||
SWITCH_END_EXTERN_C
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
|
||||
@@ -40,9 +40,7 @@
|
||||
|
||||
#include <switch.h>
|
||||
|
||||
SWITCH_BEGIN_EXTERN_C
|
||||
|
||||
struct switch_channel_timetable {
|
||||
SWITCH_BEGIN_EXTERN_C struct switch_channel_timetable {
|
||||
switch_time_t created;
|
||||
switch_time_t answered;
|
||||
switch_time_t hungup;
|
||||
@@ -76,17 +74,16 @@ SWITCH_DECLARE(uint8_t) switch_channel_ready(switch_channel_t *channel);
|
||||
|
||||
|
||||
SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_state(switch_channel_t *channel,
|
||||
const char *file,
|
||||
const char *func,
|
||||
int line,
|
||||
switch_channel_state_t state);
|
||||
const char *file,
|
||||
const char *func,
|
||||
int line, switch_channel_state_t state);
|
||||
|
||||
/*!
|
||||
\brief Set the current state of a channel
|
||||
\param channel channel to set state of
|
||||
\param state new state
|
||||
\return current state of channel after application of new state
|
||||
*/
|
||||
*/
|
||||
#define switch_channel_set_state(channel, state) switch_channel_perform_set_state(channel, __FILE__, __SWITCH_FUNC__, __LINE__, state)
|
||||
|
||||
/*!
|
||||
@@ -133,9 +130,8 @@ SWITCH_DECLARE(switch_status_t) switch_channel_alloc(switch_channel_t **channel,
|
||||
\param flags the initial channel flags
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_channel_init(switch_channel_t *channel,
|
||||
switch_core_session_t *session,
|
||||
switch_channel_state_t state,
|
||||
uint32_t flags);
|
||||
switch_core_session_t *session,
|
||||
switch_channel_state_t state, uint32_t flags);
|
||||
|
||||
/*!
|
||||
\brief Fire A presence event for the channel
|
||||
@@ -156,7 +152,8 @@ SWITCH_DECLARE(void) switch_channel_uninit(switch_channel_t *channel);
|
||||
\param channel channel to assign the profile to
|
||||
\param caller_profile the profile to assign
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_channel_set_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile);
|
||||
SWITCH_DECLARE(void) switch_channel_set_caller_profile(switch_channel_t *channel,
|
||||
switch_caller_profile_t *caller_profile);
|
||||
|
||||
/*!
|
||||
\brief Retrive the given channel's caller profile
|
||||
@@ -170,7 +167,8 @@ SWITCH_DECLARE(switch_caller_profile_t *) switch_channel_get_caller_profile(swit
|
||||
\param channel channel to assign the profile to
|
||||
\param caller_profile the profile to assign
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_channel_set_originator_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile);
|
||||
SWITCH_DECLARE(void) switch_channel_set_originator_caller_profile(switch_channel_t *channel,
|
||||
switch_caller_profile_t *caller_profile);
|
||||
|
||||
/*!
|
||||
\brief Retrive the given channel's originator caller profile
|
||||
@@ -184,7 +182,8 @@ SWITCH_DECLARE(switch_caller_profile_t *) switch_channel_get_originator_caller_p
|
||||
\param channel channel to assign the profile to
|
||||
\param caller_profile the profile to assign
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_channel_set_originatee_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile);
|
||||
SWITCH_DECLARE(void) switch_channel_set_originatee_caller_profile(switch_channel_t *channel,
|
||||
switch_caller_profile_t *caller_profile);
|
||||
|
||||
/*!
|
||||
\brief Retrive the given channel's originatee caller profile
|
||||
@@ -208,7 +207,8 @@ SWITCH_DECLARE(char *) switch_channel_get_uuid(switch_channel_t *channel);
|
||||
\param value the vaule of the variable
|
||||
\returns SWITCH_STATUS_SUCCESS if successful
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_channel_set_variable(switch_channel_t *channel, const char *varname, const char *value);
|
||||
SWITCH_DECLARE(switch_status_t) switch_channel_set_variable(switch_channel_t *channel, const char *varname,
|
||||
const char *value);
|
||||
|
||||
/*!
|
||||
\brief Set a variable on a given channel, without duplicating the value from the session pool.
|
||||
@@ -217,7 +217,8 @@ SWITCH_DECLARE(switch_status_t) switch_channel_set_variable(switch_channel_t *ch
|
||||
\param value the vaule of the variable (MUST BE ALLOCATED FROM THE SESSION POOL ALREADY)
|
||||
\returns SWITCH_STATUS_SUCCESS if successful
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_nodup(switch_channel_t *channel, const char *varname, char *value);
|
||||
SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_nodup(switch_channel_t *channel, const char *varname,
|
||||
char *value);
|
||||
|
||||
/*!
|
||||
\brief Retrieve a variable from a given channel
|
||||
@@ -234,14 +235,16 @@ SWITCH_DECLARE(char *) switch_channel_get_variable(switch_channel_t *channel, ch
|
||||
* pool is NULL, then an internal, non-thread-safe iterator is used.
|
||||
* @remark Use switch_hash_next and switch_hash_this with this function to iterate all the channel variables
|
||||
*/
|
||||
SWITCH_DECLARE(switch_hash_index_t *) switch_channel_variable_first(switch_channel_t *channel, switch_memory_pool_t *pool);
|
||||
SWITCH_DECLARE(switch_hash_index_t *) switch_channel_variable_first(switch_channel_t *channel,
|
||||
switch_memory_pool_t *pool);
|
||||
|
||||
/*!
|
||||
\brief Assign a caller extension to a given channel
|
||||
\param channel channel to assign extension to
|
||||
\param caller_extension extension to assign
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_channel_set_caller_extension(switch_channel_t *channel, switch_caller_extension_t *caller_extension);
|
||||
SWITCH_DECLARE(void) switch_channel_set_caller_extension(switch_channel_t *channel,
|
||||
switch_caller_extension_t *caller_extension);
|
||||
|
||||
/*!
|
||||
\brief Retrieve caller extension from a given channel
|
||||
@@ -280,14 +283,10 @@ SWITCH_DECLARE(void) switch_channel_set_state_flag(switch_channel_t *channel, sw
|
||||
SWITCH_DECLARE(void) switch_channel_clear_flag(switch_channel_t *channel, switch_channel_flag_t flags);
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_channel_perform_answer(switch_channel_t *channel,
|
||||
const char *file,
|
||||
const char *func,
|
||||
int line);
|
||||
const char *file, const char *func, int line);
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_answered(switch_channel_t *channel,
|
||||
const char *file,
|
||||
const char *func,
|
||||
int line);
|
||||
const char *file, const char *func, int line);
|
||||
|
||||
/*!
|
||||
\brief Answer a channel (initiate/acknowledge a successful connection)
|
||||
@@ -311,9 +310,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_answered(switch_chan
|
||||
#define switch_channel_mark_pre_answered(channel) switch_channel_perform_mark_pre_answered(channel, __FILE__, __SWITCH_FUNC__, __LINE__)
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_channel_perform_ring_ready(switch_channel_t *channel,
|
||||
const char *file,
|
||||
const char *func,
|
||||
int line);
|
||||
const char *file, const char *func, int line);
|
||||
/*!
|
||||
\brief Send Ringing message to a channel
|
||||
\param channel channel to ring
|
||||
@@ -323,32 +320,26 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_ring_ready(switch_channel
|
||||
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_channel_perform_pre_answer(switch_channel_t *channel,
|
||||
const char *file,
|
||||
const char *func,
|
||||
int line);
|
||||
const char *file, const char *func, int line);
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_pre_answered(switch_channel_t *channel,
|
||||
const char *file,
|
||||
const char *func,
|
||||
int line);
|
||||
const char *file, const char *func, int line);
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_ring_ready(switch_channel_t *channel,
|
||||
const char *file,
|
||||
const char *func,
|
||||
int line);
|
||||
const char *file, const char *func, int line);
|
||||
|
||||
/*!
|
||||
\brief Indicate progress on a channel to attempt early media
|
||||
\param channel channel to pre-answer
|
||||
\return SWITCH_STATUS_SUCCESS
|
||||
*/
|
||||
*/
|
||||
#define switch_channel_pre_answer(channel) switch_channel_perform_pre_answer(channel, __FILE__, __SWITCH_FUNC__, __LINE__)
|
||||
|
||||
/*!
|
||||
\brief Indicate a channel is ready to provide ringback
|
||||
\param channel channel
|
||||
\return SWITCH_STATUS_SUCCESS
|
||||
*/
|
||||
*/
|
||||
#define switch_channel_mark_ring_ready(channel) switch_channel_perform_mark_ring_ready(channel, __FILE__, __SWITCH_FUNC__, __LINE__)
|
||||
|
||||
/*!
|
||||
@@ -357,14 +348,16 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_ring_ready(switch_ch
|
||||
\param state_handler table of state handler functions
|
||||
\return the index number/priority of the table negative value indicates failure
|
||||
*/
|
||||
SWITCH_DECLARE(int) switch_channel_add_state_handler(switch_channel_t *channel, const switch_state_handler_table_t *state_handler);
|
||||
SWITCH_DECLARE(int) switch_channel_add_state_handler(switch_channel_t *channel,
|
||||
const switch_state_handler_table_t *state_handler);
|
||||
|
||||
/*!
|
||||
\brief clear a state handler table from a given channel
|
||||
\param channel channel from which to clear the state handler table
|
||||
\param state_handler table of state handler functions
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_channel_clear_state_handler(switch_channel_t *channel, const switch_state_handler_table_t *state_handler);
|
||||
SWITCH_DECLARE(void) switch_channel_clear_state_handler(switch_channel_t *channel,
|
||||
const switch_state_handler_table_t *state_handler);
|
||||
|
||||
/*!
|
||||
\brief Retrieve an state handler tablefrom a given channel at given index level
|
||||
@@ -372,7 +365,8 @@ SWITCH_DECLARE(void) switch_channel_clear_state_handler(switch_channel_t *channe
|
||||
\param index the index of the state handler table (start from 0)
|
||||
\return given channel's state handler table at given index or NULL if requested index does not exist.
|
||||
*/
|
||||
SWITCH_DECLARE(const switch_state_handler_table_t *) switch_channel_get_state_handler(switch_channel_t *channel, int index);
|
||||
SWITCH_DECLARE(const switch_state_handler_table_t *) switch_channel_get_state_handler(switch_channel_t *channel,
|
||||
int index);
|
||||
|
||||
/*!
|
||||
\brief Set private data on channel
|
||||
@@ -407,11 +401,10 @@ SWITCH_DECLARE(switch_status_t) switch_channel_set_name(switch_channel_t *channe
|
||||
SWITCH_DECLARE(char *) switch_channel_get_name(switch_channel_t *channel);
|
||||
|
||||
|
||||
SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_hangup(switch_channel_t *channel,
|
||||
const char *file,
|
||||
const char *func,
|
||||
int line,
|
||||
switch_call_cause_t hangup_cause);
|
||||
SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_hangup(switch_channel_t *channel,
|
||||
const char *file,
|
||||
const char *func,
|
||||
int line, switch_call_cause_t hangup_cause);
|
||||
|
||||
/*!
|
||||
\brief Hangup a channel flagging it's state machine to end
|
||||
@@ -478,9 +471,7 @@ SWITCH_DECLARE(char *) switch_channel_expand_variables(switch_channel_t *channel
|
||||
/** @} */
|
||||
|
||||
SWITCH_END_EXTERN_C
|
||||
|
||||
#endif
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
|
||||
@@ -58,24 +58,22 @@
|
||||
|
||||
#include <switch.h>
|
||||
|
||||
SWITCH_BEGIN_EXTERN_C
|
||||
|
||||
typedef struct switch_config switch_config_t;
|
||||
SWITCH_BEGIN_EXTERN_C typedef struct switch_config switch_config_t;
|
||||
|
||||
/*! \brief A simple file handle representing an open configuration file **/
|
||||
struct switch_config {
|
||||
/*! FILE stream buffer to the opened file */
|
||||
FILE *file;
|
||||
FILE *file;
|
||||
/*! path to the file */
|
||||
char *path;
|
||||
char *path;
|
||||
/*! current category */
|
||||
char category[256];
|
||||
char category[256];
|
||||
/*! current section */
|
||||
char section[256];
|
||||
char section[256];
|
||||
/*! buffer of current line being read */
|
||||
char buf[1024];
|
||||
char buf[1024];
|
||||
/*! current line number in file */
|
||||
int lineno;
|
||||
int lineno;
|
||||
/*! current category number in file */
|
||||
int catno;
|
||||
/*! current section number in file */
|
||||
@@ -107,11 +105,8 @@ SWITCH_DECLARE(void) switch_config_close_file(switch_config_t *cfg);
|
||||
SWITCH_DECLARE(int) switch_config_next_pair(switch_config_t *cfg, char **var, char **val);
|
||||
|
||||
SWITCH_END_EXTERN_C
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
|
||||
@@ -51,9 +51,6 @@ SWITCH_BEGIN_EXTERN_C
|
||||
s.alloc_len = SWITCH_CMD_CHUNK_LEN;\
|
||||
s.alloc_chunk = SWITCH_CMD_CHUNK_LEN;\
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
\brief A simple comand loop that reads input from the terminal
|
||||
*/
|
||||
@@ -62,16 +59,16 @@ SWITCH_DECLARE(void) switch_console_loop(void);
|
||||
/*!
|
||||
\brief A method akin to printf that allows you to redirect output to a specific console "channel"
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_console_printf(switch_text_channel_t channel, const char *file, const char *func, int line, const char *fmt, ...) PRINTF_FUNCTION(5,6);
|
||||
SWITCH_DECLARE(void) switch_console_printf(switch_text_channel_t channel, const char *file, const char *func, int line,
|
||||
const char *fmt, ...) PRINTF_FUNCTION(5, 6);
|
||||
|
||||
/*!
|
||||
\brief A method akin to printf for dealing with api streams
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_console_stream_write(switch_stream_handle_t *handle, const char *fmt, ...) PRINTF_FUNCTION(2,3);
|
||||
SWITCH_DECLARE(switch_status_t) switch_console_stream_write(switch_stream_handle_t *handle, const char *fmt,
|
||||
...) PRINTF_FUNCTION(2, 3);
|
||||
SWITCH_END_EXTERN_C
|
||||
|
||||
#endif
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
|
||||
+129
-248
@@ -41,43 +41,41 @@
|
||||
#include <switch.h>
|
||||
|
||||
SWITCH_BEGIN_EXTERN_C
|
||||
|
||||
#define SWITCH_MAX_CORE_THREAD_SESSION_OBJS 128
|
||||
#define SWITCH_MAX_STREAMS 128
|
||||
|
||||
struct switch_core_time_duration {
|
||||
uint32_t mms;
|
||||
uint32_t ms;
|
||||
uint32_t sec;
|
||||
uint32_t min;
|
||||
uint32_t hr;
|
||||
struct switch_core_time_duration {
|
||||
uint32_t mms;
|
||||
uint32_t ms;
|
||||
uint32_t sec;
|
||||
uint32_t min;
|
||||
uint32_t hr;
|
||||
uint32_t day;
|
||||
uint32_t yr;
|
||||
};
|
||||
|
||||
/*! \brief A message object designed to allow unlike technologies to exchange data */
|
||||
struct switch_core_session_message {
|
||||
/*! uuid of the sender (for replies)*/
|
||||
/*! uuid of the sender (for replies) */
|
||||
char *from;
|
||||
/*! enumeration of the type of message */
|
||||
switch_core_session_message_types_t message_id;
|
||||
|
||||
/*! optional numeric arg*/
|
||||
/*! optional numeric arg */
|
||||
int numeric_arg;
|
||||
/*! optional string arg*/
|
||||
/*! optional string arg */
|
||||
char *string_arg;
|
||||
/*! optional string arg*/
|
||||
/*! optional string arg */
|
||||
switch_size_t string_arg_size;
|
||||
/*! optional arbitrary pointer arg */
|
||||
void *pointer_arg;
|
||||
/*! optional arbitrary pointer arg's size */
|
||||
switch_size_t pointer_arg_size;
|
||||
|
||||
/*! optional numeric reply*/
|
||||
/*! optional numeric reply */
|
||||
int numeric_reply;
|
||||
/*! optional string reply*/
|
||||
/*! optional string reply */
|
||||
char *string_reply;
|
||||
/*! optional string reply*/
|
||||
/*! optional string reply */
|
||||
switch_size_t string_reply_size;
|
||||
/*! optional arbitrary pointer reply */
|
||||
void *pointer_reply;
|
||||
@@ -96,7 +94,7 @@ struct switch_core_thread_session {
|
||||
/*! array of void pointers to pass mutiple data objects */
|
||||
void *objs[SWITCH_MAX_CORE_THREAD_SESSION_OBJS];
|
||||
/*! a pointer to a memory pool if the thread has it's own pool */
|
||||
switch_input_callback_function_t input_callback;
|
||||
switch_input_callback_function_t input_callback;
|
||||
switch_memory_pool_t *pool;
|
||||
};
|
||||
|
||||
@@ -104,16 +102,6 @@ struct switch_core_session;
|
||||
struct switch_core_runtime;
|
||||
struct switch_core_port_allocator;
|
||||
|
||||
struct switch_core_scheduler_task {
|
||||
time_t created;
|
||||
time_t runtime;
|
||||
uint32_t cmd_id;
|
||||
char *group;
|
||||
void *cmd_arg;
|
||||
uint32_t task_id;
|
||||
};
|
||||
|
||||
|
||||
/*!
|
||||
\defgroup core1 Core Library
|
||||
\ingroup FREESWITCH
|
||||
@@ -125,47 +113,6 @@ struct switch_core_scheduler_task {
|
||||
///\{
|
||||
|
||||
|
||||
///\defgroup sched1 Scheduler
|
||||
///\ingroup core1
|
||||
///\{
|
||||
|
||||
|
||||
/*!
|
||||
\brief Schedule a task in the future
|
||||
\param runtime the time in epoch seconds to execute the task.
|
||||
\param func the callback function to execute when the task is executed.
|
||||
\param desc an arbitrary description of the task.
|
||||
\param group a group id tag to link multiple tasks to a single entity.
|
||||
\param cmd_id an arbitrary index number be used in the callback.
|
||||
\param cmd_arg user data to be passed to the callback.
|
||||
\param flags flags to alter behaviour
|
||||
\return the id of the task
|
||||
*/
|
||||
SWITCH_DECLARE(uint32_t) switch_core_scheduler_add_task(time_t task_runtime,
|
||||
switch_core_scheduler_func_t func,
|
||||
char *desc,
|
||||
char *group,
|
||||
uint32_t cmd_id,
|
||||
void *cmd_arg,
|
||||
switch_scheduler_flag_t flags);
|
||||
|
||||
/*!
|
||||
\brief Delete a scheduled task
|
||||
\param task_id the id of the task
|
||||
\return SWITCH_STATUS_SUCCESS if the task was deleted.
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_scheduler_del_task_id(uint32_t task_id);
|
||||
|
||||
/*!
|
||||
\brief Delete a scheduled task based on the group name
|
||||
\param group the group name
|
||||
\return SWITCH_STATUS_SUCCESS if any tasks were deleted
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_scheduler_del_task_group(char *group);
|
||||
|
||||
|
||||
///\}
|
||||
|
||||
/*!
|
||||
\brief Add a media bug to the session
|
||||
\param session the session to add the bug to
|
||||
@@ -178,8 +125,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_scheduler_del_task_group(char *group
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(switch_core_session_t *session,
|
||||
switch_media_bug_callback_t callback,
|
||||
void *user_data,
|
||||
switch_media_bug_flag_t flags,
|
||||
switch_media_bug_t **new_bug);
|
||||
switch_media_bug_flag_t flags, switch_media_bug_t **new_bug);
|
||||
/*!
|
||||
\brief Obtain private data from a media bug
|
||||
\param bug the bug to get the data from
|
||||
@@ -208,6 +154,12 @@ SWITCH_DECLARE(void) switch_core_media_bug_set_replace_frame(switch_media_bug_t
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_media_bug_remove(switch_core_session_t *session, switch_media_bug_t **bug);
|
||||
|
||||
/*!
|
||||
\brief Close and destroy a media bug
|
||||
\param bug bug to remove
|
||||
\return SWITCH_STATUS_SUCCESS if the operation was a success
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_media_bug_close(switch_media_bug_t **bug);
|
||||
/*!
|
||||
\brief Remove all media bugs from the session
|
||||
\param session the session to remove the bugs from
|
||||
@@ -296,9 +248,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_destroy(void);
|
||||
|
||||
#ifdef SWITCH_DEBUG_RWLOCKS
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_perform_read_lock(switch_core_session_t *session,
|
||||
const char *file,
|
||||
const char *func,
|
||||
int line);
|
||||
const char *file, const char *func, int line);
|
||||
#endif
|
||||
|
||||
/*!
|
||||
@@ -315,9 +265,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_lock(switch_core_sessio
|
||||
|
||||
#ifdef SWITCH_DEBUG_RWLOCKS
|
||||
SWITCH_DECLARE(void) switch_core_session_perform_write_lock(switch_core_session_t *session,
|
||||
const char *file,
|
||||
const char *func,
|
||||
int line);
|
||||
const char *file, const char *func, int line);
|
||||
#endif
|
||||
|
||||
/*!
|
||||
@@ -332,9 +280,7 @@ SWITCH_DECLARE(void) switch_core_session_write_lock(switch_core_session_t *sessi
|
||||
|
||||
#ifdef SWITCH_DEBUG_RWLOCKS
|
||||
SWITCH_DECLARE(void) switch_core_session_perform_rwunlock(switch_core_session_t *session,
|
||||
const char *file,
|
||||
const char *func,
|
||||
int line);
|
||||
const char *file, const char *func, int line);
|
||||
#endif
|
||||
|
||||
/*!
|
||||
@@ -479,7 +425,8 @@ SWITCH_DECLARE(switch_memory_pool_t *) switch_core_session_get_pool(switch_core_
|
||||
\param pool the pool to use for the allocation (a new one will be used if NULL)
|
||||
\return the newly created session
|
||||
*/
|
||||
SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request(const switch_endpoint_interface_t *endpoint_interface, switch_memory_pool_t **pool);
|
||||
SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request(const switch_endpoint_interface_t
|
||||
*endpoint_interface, switch_memory_pool_t **pool);
|
||||
|
||||
/*!
|
||||
\brief Destroy a session and return the memory pool to the core
|
||||
@@ -500,7 +447,8 @@ SWITCH_DECLARE(uint32_t) switch_core_session_count(void);
|
||||
\param pool the pool to use
|
||||
\return the newly created session
|
||||
*/
|
||||
SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_by_name(char *endpoint_name, switch_memory_pool_t **pool);
|
||||
SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_by_name(char *endpoint_name,
|
||||
switch_memory_pool_t **pool);
|
||||
|
||||
/*!
|
||||
\brief Launch the session thread (state machine) on a given session
|
||||
@@ -535,9 +483,8 @@ SWITCH_DECLARE(char *) switch_core_get_uuid(void);
|
||||
|
||||
#ifdef SWITCH_DEBUG_RWLOCKS
|
||||
SWITCH_DECLARE(switch_core_session_t *) switch_core_session_perform_locate(char *uuid_str,
|
||||
const char *file,
|
||||
const char *func,
|
||||
int line);
|
||||
const char *file,
|
||||
const char *func, int line);
|
||||
#endif
|
||||
|
||||
/*!
|
||||
@@ -578,7 +525,8 @@ SWITCH_DECLARE(void) switch_core_session_hupall(switch_call_cause_t cause);
|
||||
\param message the switch_core_session_message_t object to send
|
||||
\return the status returned by the message handler
|
||||
*/
|
||||
SWITCH_DECLARE (switch_status_t) switch_core_session_message_send(char *uuid_str, switch_core_session_message_t *message);
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_message_send(char *uuid_str,
|
||||
switch_core_session_message_t *message);
|
||||
|
||||
/*!
|
||||
\brief Queue a message on a session
|
||||
@@ -586,7 +534,8 @@ SWITCH_DECLARE (switch_status_t) switch_core_session_message_send(char *uuid_str
|
||||
\param message the message to queue
|
||||
\return SWITCH_STATUS_SUCCESS if the message was queued
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_queue_message(switch_core_session_t *session, switch_core_session_message_t *message);
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_queue_message(switch_core_session_t *session,
|
||||
switch_core_session_message_t *message);
|
||||
|
||||
/*!
|
||||
\brief Queue an indication message on a session
|
||||
@@ -594,7 +543,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_queue_message(switch_core_se
|
||||
\param indication the indication message to queue
|
||||
\return SWITCH_STATUS_SUCCESS if the message was queued
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_queue_indication(switch_core_session_t *session, switch_core_session_message_types_t indication);
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_queue_indication(switch_core_session_t *session,
|
||||
switch_core_session_message_types_t indication);
|
||||
|
||||
/*!
|
||||
\brief DE-Queue an message on a given session
|
||||
@@ -602,7 +552,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_queue_indication(switch_core
|
||||
\param message the de-queued message
|
||||
\return the SWITCH_STATUS_SUCCESS if the message was de-queued
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_message(switch_core_session_t *session, switch_core_session_message_t **message);
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_message(switch_core_session_t *session,
|
||||
switch_core_session_message_t **message);
|
||||
|
||||
/*!
|
||||
\brief Flush a message queue on a given session
|
||||
@@ -625,7 +576,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_event_send(char *uuid_str, s
|
||||
\param event the event to receive
|
||||
\return the status returned by the handler
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_receive_event(switch_core_session_t *session, switch_event_t **event);
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_receive_event(switch_core_session_t *session,
|
||||
switch_event_t **event);
|
||||
|
||||
/*!
|
||||
\brief Retrieve private user data from a session
|
||||
@@ -671,7 +623,8 @@ SWITCH_DECLARE(int) switch_core_session_get_stream_count(switch_core_session_t *
|
||||
\param func a function to execute in the thread
|
||||
\param obj an arguement
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_core_session_launch_thread(switch_core_session_t *session, void *(*func)(switch_thread_t *, void *), void *obj);
|
||||
SWITCH_DECLARE(void) switch_core_session_launch_thread(switch_core_session_t *session,
|
||||
void *(*func) (switch_thread_t *, void *), void *obj);
|
||||
|
||||
/*!
|
||||
\brief Signal a thread using a thread session to terminate
|
||||
@@ -685,7 +638,8 @@ SWITCH_DECLARE(void) switch_core_thread_session_end(switch_core_thread_session_t
|
||||
\param stream_id which logical media channel to use
|
||||
\param thread_session the thread_session to use
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_core_service_session(switch_core_session_t *session, switch_core_thread_session_t *thread_session, int stream_id);
|
||||
SWITCH_DECLARE(void) switch_core_service_session(switch_core_session_t *session,
|
||||
switch_core_thread_session_t *thread_session, int stream_id);
|
||||
|
||||
/*!
|
||||
\brief Request an outgoing session spawned from an existing session using a desired endpoing module
|
||||
@@ -715,7 +669,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_answer_channel(switch_core_s
|
||||
\param message the message to recieve
|
||||
\return the status returned by the message handler
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_receive_message(switch_core_session_t *session, switch_core_session_message_t *message);
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_receive_message(switch_core_session_t *session,
|
||||
switch_core_session_message_t *message);
|
||||
|
||||
/*!
|
||||
\brief Queue an event on a given session
|
||||
@@ -739,7 +694,8 @@ SWITCH_DECLARE(int32_t) switch_core_session_event_count(switch_core_session_t *s
|
||||
\param event the de-queued event
|
||||
\return the SWITCH_STATUS_SUCCESS if the event was de-queued
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_event(switch_core_session_t *session, switch_event_t **event);
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_event(switch_core_session_t *session,
|
||||
switch_event_t **event);
|
||||
|
||||
/*!
|
||||
\brief Queue a private event on a given session
|
||||
@@ -747,7 +703,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_event(switch_core_se
|
||||
\param event the event to queue
|
||||
\return the status returned by the message handler
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_queue_private_event(switch_core_session_t *session, switch_event_t **event);
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_queue_private_event(switch_core_session_t *session,
|
||||
switch_event_t **event);
|
||||
|
||||
|
||||
/*!
|
||||
@@ -763,7 +720,8 @@ SWITCH_DECLARE(int32_t) switch_core_session_private_event_count(switch_core_sess
|
||||
\param event the de-queued event
|
||||
\return the SWITCH_STATUS_SUCCESS if the event was de-queued
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_private_event(switch_core_session_t *session, switch_event_t **event);
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_private_event(switch_core_session_t *session,
|
||||
switch_event_t **event);
|
||||
|
||||
|
||||
/*!
|
||||
@@ -774,7 +732,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_private_event(switch
|
||||
\param stream_id which logical media channel to use
|
||||
\return SWITCH_STATUS_SUCCESS a the frame was read
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout, int stream_id);
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_session_t *session, switch_frame_t **frame,
|
||||
int timeout, int stream_id);
|
||||
|
||||
/*!
|
||||
\brief Reset the buffers and resampler on a session
|
||||
@@ -790,14 +749,14 @@ SWITCH_DECLARE(void) switch_core_session_reset(switch_core_session_t *session);
|
||||
\param stream_id which logical media channel to use
|
||||
\return SWITCH_STATUS_SUCCESS a the frame was written
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, int stream_id);
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_session_t *session, switch_frame_t *frame,
|
||||
int timeout, int stream_id);
|
||||
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_perform_kill_channel(switch_core_session_t *session,
|
||||
const char *file,
|
||||
const char *func,
|
||||
int line,
|
||||
switch_signal_t sig);
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_perform_kill_channel(switch_core_session_t *session,
|
||||
const char *file,
|
||||
const char *func,
|
||||
int line, switch_signal_t sig);
|
||||
/*!
|
||||
\brief Send a signal to a channel
|
||||
\param session session to send signal to
|
||||
@@ -813,7 +772,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_perform_kill_channel(switch_
|
||||
\param stream_id which logical media channel to use
|
||||
\return SWITCH_STATUS_SUCCESS if data is available for read within timeframe specified
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_waitfor_read(switch_core_session_t *session, int timeout, int stream_id);
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_waitfor_read(switch_core_session_t *session, int timeout,
|
||||
int stream_id);
|
||||
|
||||
/*!
|
||||
\brief Wait for a session to be ready for output
|
||||
@@ -822,7 +782,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_waitfor_read(switch_core_ses
|
||||
\param stream_id which logical media channel to use
|
||||
\return SWITCH_STATUS_SUCCESS if the session is available for write within timeframe specified
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_waitfor_write(switch_core_session_t *session, int timeout, int stream_id);
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_waitfor_write(switch_core_session_t *session, int timeout,
|
||||
int stream_id);
|
||||
|
||||
/*!
|
||||
\brief Send DTMF to a session
|
||||
@@ -832,91 +793,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_waitfor_write(switch_core_se
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf(switch_core_session_t *session, char *dtmf);
|
||||
|
||||
/*!
|
||||
\brief Add an event hook to be executed when a session requests an outgoing extension
|
||||
\param session session to bind hook to
|
||||
\param outgoing_channel hook to bind
|
||||
\return SWITCH_STATUS_SUCCESS on suceess
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_add_event_hook_outgoing(switch_core_session_t *session, switch_outgoing_channel_hook_t outgoing_channel);
|
||||
///\}
|
||||
|
||||
///\defgroup shooks Session Hook Callbacks
|
||||
///\ingroup core1
|
||||
///\{
|
||||
/*!
|
||||
\brief Add an event hook to be executed when a session answers a channel
|
||||
\param session session to bind hook to
|
||||
\param answer_channel hook to bind
|
||||
\return SWITCH_STATUS_SUCCESS on suceess
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_add_event_hook_answer_channel(switch_core_session_t *session, switch_answer_channel_hook_t answer_channel);
|
||||
|
||||
/*!
|
||||
\brief Add an event hook to be executed when a session sends a message
|
||||
\param session session to bind hook to
|
||||
\param receive_message hook to bind
|
||||
\return SWITCH_STATUS_SUCCESS on suceess
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_add_event_hook_receive_message(switch_core_session_t *session, switch_receive_message_hook_t receive_message);
|
||||
|
||||
/*!
|
||||
\brief Add an event hook to be executed when a session reads a frame
|
||||
\param session session to bind hook to
|
||||
\param read_frame hook to bind
|
||||
\return SWITCH_STATUS_SUCCESS on suceess
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_add_event_hook_read_frame(switch_core_session_t *session, switch_read_frame_hook_t read_frame);
|
||||
|
||||
/*!
|
||||
\brief Add an event hook to be executed when a session writes a frame
|
||||
\param session session to bind hook to
|
||||
\param write_frame hook to bind
|
||||
\return SWITCH_STATUS_SUCCESS on suceess
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_add_event_hook_write_frame(switch_core_session_t *session, switch_write_frame_hook_t write_frame);
|
||||
|
||||
/*!
|
||||
\brief Add an event hook to be executed when a session kills a channel
|
||||
\param session session to bind hook to
|
||||
\param kill_channel hook to bind
|
||||
\return SWITCH_STATUS_SUCCESS on suceess
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_add_event_hook_kill_channel(switch_core_session_t *session, switch_kill_channel_hook_t kill_channel);
|
||||
|
||||
/*!
|
||||
\brief Add an event hook to be executed when a session waits for a read event
|
||||
\param session session to bind hook to
|
||||
\param waitfor_read hook to bind
|
||||
\return SWITCH_STATUS_SUCCESS on suceess
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_add_event_hook_waitfor_read(switch_core_session_t *session, switch_waitfor_read_hook_t waitfor_read);
|
||||
|
||||
/*!
|
||||
\brief Add an event hook to be executed when a session waits for a write event
|
||||
\param session session to bind hook to
|
||||
\param waitfor_write hook to bind
|
||||
\return SWITCH_STATUS_SUCCESS on suceess
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_add_event_hook_waitfor_write(switch_core_session_t *session, switch_waitfor_write_hook_t waitfor_write);
|
||||
|
||||
/*!
|
||||
\brief Add an event hook to be executed when a session sends dtmf
|
||||
\param session session to bind hook to
|
||||
\param send_dtmf hook to bind
|
||||
\return SWITCH_STATUS_SUCCESS on suceess
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_add_event_hook_send_dtmf(switch_core_session_t *session, switch_send_dtmf_hook_t send_dtmf);
|
||||
|
||||
/*!
|
||||
\brief Add an event hook to be executed when a session receives a state change signal
|
||||
\param session session to bind hook to
|
||||
\param state_change hook to bind
|
||||
\return SWITCH_STATUS_SUCCESS on suceess
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_add_event_hook_state_change(switch_core_session_t *session,
|
||||
switch_answer_channel_hook_t state_change);
|
||||
///\}
|
||||
|
||||
///\defgroup hashf Hash Functions
|
||||
///\ingroup core1
|
||||
@@ -984,7 +862,8 @@ SWITCH_DECLARE(void *) switch_core_hash_find(switch_hash_t *hash, const char *ke
|
||||
\param pool the memory pool to use for allocation
|
||||
\return
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_timer_init(switch_timer_t *timer, char *timer_name, int interval, int samples, switch_memory_pool_t *pool);
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_timer_init(switch_timer_t *timer, char *timer_name, int interval,
|
||||
int samples, switch_memory_pool_t *pool);
|
||||
|
||||
/*!
|
||||
\brief Wait for one cycle on an existing timer
|
||||
@@ -1031,14 +910,14 @@ SWITCH_DECLARE(switch_status_t) switch_core_timer_destroy(switch_timer_t *timer)
|
||||
\param pool the memory pool to use
|
||||
\return SWITCH_STATUS_SUCCESS if the handle is allocated
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_codec_init(switch_codec_t *codec,
|
||||
char *codec_name,
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_codec_init(switch_codec_t *codec,
|
||||
char *codec_name,
|
||||
char *fmtp,
|
||||
uint32_t rate,
|
||||
int ms,
|
||||
int channels,
|
||||
uint32_t rate,
|
||||
int ms,
|
||||
int channels,
|
||||
uint32_t flags,
|
||||
const switch_codec_settings_t *codec_settings,
|
||||
const switch_codec_settings_t *codec_settings,
|
||||
switch_memory_pool_t *pool);
|
||||
|
||||
/*!
|
||||
@@ -1056,14 +935,13 @@ SWITCH_DECLARE(switch_status_t) switch_core_codec_init(switch_codec_t *codec,
|
||||
\note encoded_data_len will be rewritten to the in-use size of encoded_data
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_codec_encode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *decoded_data,
|
||||
uint32_t decoded_data_len,
|
||||
uint32_t decoded_rate,
|
||||
void *encoded_data,
|
||||
uint32_t *encoded_data_len,
|
||||
uint32_t *encoded_rate,
|
||||
unsigned int *flag);
|
||||
switch_codec_t *other_codec,
|
||||
void *decoded_data,
|
||||
uint32_t decoded_data_len,
|
||||
uint32_t decoded_rate,
|
||||
void *encoded_data,
|
||||
uint32_t * encoded_data_len,
|
||||
uint32_t * encoded_rate, unsigned int *flag);
|
||||
|
||||
/*!
|
||||
\brief Decode data using a codec handle
|
||||
@@ -1080,14 +958,13 @@ SWITCH_DECLARE(switch_status_t) switch_core_codec_encode(switch_codec_t *codec,
|
||||
\note decoded_data_len will be rewritten to the in-use size of decoded_data
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_codec_decode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *encoded_data,
|
||||
uint32_t encoded_data_len,
|
||||
uint32_t encoded_rate,
|
||||
void *decoded_data,
|
||||
uint32_t *decoded_data_len,
|
||||
uint32_t *decoded_rate,
|
||||
unsigned int *flag);
|
||||
switch_codec_t *other_codec,
|
||||
void *encoded_data,
|
||||
uint32_t encoded_data_len,
|
||||
uint32_t encoded_rate,
|
||||
void *decoded_data,
|
||||
uint32_t * decoded_data_len,
|
||||
uint32_t * decoded_rate, unsigned int *flag);
|
||||
|
||||
/*!
|
||||
\brief Destroy an initalized codec handle
|
||||
@@ -1102,7 +979,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_codec_destroy(switch_codec_t *codec)
|
||||
\param codec the codec to add
|
||||
\return SWITCH_STATUS_SUCCESS if successful
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_set_read_codec(switch_core_session_t *session, switch_codec_t *codec);
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_set_read_codec(switch_core_session_t *session,
|
||||
switch_codec_t *codec);
|
||||
|
||||
/*!
|
||||
\brief Retrieve the read codec from a given session
|
||||
@@ -1117,7 +995,8 @@ SWITCH_DECLARE(switch_codec_t *) switch_core_session_get_read_codec(switch_core_
|
||||
\param codec the codec to add
|
||||
\return SWITCH_STATUS_SUCCESS if successful
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_set_write_codec(switch_core_session_t *session, switch_codec_t *codec);
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_session_set_write_codec(switch_core_session_t *session,
|
||||
switch_codec_t *codec);
|
||||
|
||||
/*!
|
||||
\brief Retrieve the write codec from a given session
|
||||
@@ -1177,12 +1056,10 @@ SWITCH_DECLARE(void) switch_core_db_test_reactive(switch_core_db_t *db, char *te
|
||||
\return SWITCH_STATUS_SUCCESS if the file is opened
|
||||
\note the loadable module used is chosen based on the file extension
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_file_open(switch_file_handle_t *fh,
|
||||
char *file_path,
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_file_open(switch_file_handle_t *fh,
|
||||
char *file_path,
|
||||
uint8_t channels,
|
||||
uint32_t rate,
|
||||
unsigned int flags,
|
||||
switch_memory_pool_t *pool);
|
||||
uint32_t rate, unsigned int flags, switch_memory_pool_t *pool);
|
||||
/*!
|
||||
\brief Read media from a file handle
|
||||
\param fh the file handle to read from (must be initilized by you memset all 0 for read, fill in channels and rate for write)
|
||||
@@ -1209,7 +1086,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_write(switch_file_handle_t *fh,
|
||||
\param whence the indicator (see traditional seek)
|
||||
\return SWITCH_STATUS_SUCCESS with cur_pos adjusted to new position
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_file_seek(switch_file_handle_t *fh, unsigned int *cur_pos, int64_t samples, int whence);
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_file_seek(switch_file_handle_t *fh, unsigned int *cur_pos, int64_t samples,
|
||||
int whence);
|
||||
|
||||
/*!
|
||||
\brief Set metadata to the desired string
|
||||
@@ -1218,7 +1096,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_seek(switch_file_handle_t *fh,
|
||||
\param string the string to add
|
||||
\return SWITCH_STATUS_SUCCESS with cur_pos adjusted to new position
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_file_set_string(switch_file_handle_t *fh, switch_audio_col_t col, const char *string);
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_file_set_string(switch_file_handle_t *fh, switch_audio_col_t col,
|
||||
const char *string);
|
||||
|
||||
/*!
|
||||
\brief get metadata of the desired string
|
||||
@@ -1227,7 +1106,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_set_string(switch_file_handle_t
|
||||
\param string pointer to the string to fetch
|
||||
\return SWITCH_STATUS_SUCCESS with cur_pos adjusted to new position
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_file_get_string(switch_file_handle_t *fh, switch_audio_col_t col, const char **string);
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_file_get_string(switch_file_handle_t *fh, switch_audio_col_t col,
|
||||
const char **string);
|
||||
|
||||
|
||||
/*!
|
||||
@@ -1251,12 +1131,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_close(switch_file_handle_t *fh)
|
||||
\param pool the pool to use (NULL for new pool)
|
||||
\return SWITCH_STATUS_SUCCESS if the handle is opened
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_speech_open(switch_speech_handle_t *sh,
|
||||
char *module_name,
|
||||
char *voice_name,
|
||||
unsigned int rate,
|
||||
switch_speech_flag_t *flags,
|
||||
switch_memory_pool_t *pool);
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_speech_open(switch_speech_handle_t *sh,
|
||||
char *module_name,
|
||||
char *voice_name,
|
||||
unsigned int rate,
|
||||
switch_speech_flag_t *flags, switch_memory_pool_t *pool);
|
||||
/*!
|
||||
\brief Feed text to the TTS module
|
||||
\param sh the speech handle to feed
|
||||
@@ -1264,7 +1143,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_speech_open(switch_speech_handle_t *
|
||||
\param flags flags in/out for fine tuning
|
||||
\return SWITCH_STATUS_SUCCESS with len adjusted to the bytes written if successful
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_speech_feed_tts(switch_speech_handle_t *sh, char *text, switch_speech_flag_t *flags);
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_speech_feed_tts(switch_speech_handle_t *sh, char *text,
|
||||
switch_speech_flag_t *flags);
|
||||
|
||||
/*!
|
||||
\brief Flush TTS audio on a given handle
|
||||
@@ -1305,11 +1185,10 @@ SWITCH_DECLARE(void) switch_core_speech_float_param_tts(switch_speech_handle_t *
|
||||
\param flags flags in/out for fine tuning
|
||||
\return SWITCH_STATUS_SUCCESS with len adjusted to the bytes written if successful
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_speech_read_tts(switch_speech_handle_t *sh,
|
||||
void *data,
|
||||
switch_size_t *datalen,
|
||||
uint32_t *rate,
|
||||
switch_speech_flag_t *flags);
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_speech_read_tts(switch_speech_handle_t *sh,
|
||||
void *data,
|
||||
switch_size_t *datalen,
|
||||
uint32_t * rate, switch_speech_flag_t *flags);
|
||||
/*!
|
||||
\brief Close an open speech handle
|
||||
\param sh the speech handle to close
|
||||
@@ -1334,9 +1213,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_asr_open(switch_asr_handle_t *ah,
|
||||
char *module_name,
|
||||
char *codec,
|
||||
int rate,
|
||||
char *dest,
|
||||
switch_asr_flag_t *flags,
|
||||
switch_memory_pool_t *pool);
|
||||
char *dest, switch_asr_flag_t *flags, switch_memory_pool_t *pool);
|
||||
|
||||
/*!
|
||||
\brief Close an asr handle
|
||||
@@ -1354,7 +1231,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_asr_close(switch_asr_handle_t *ah, s
|
||||
\param flags flags to influence behaviour
|
||||
\return SWITCH_STATUS_SUCCESS
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_asr_feed(switch_asr_handle_t *ah, void *data, unsigned int len, switch_asr_flag_t *flags);
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_asr_feed(switch_asr_handle_t *ah, void *data, unsigned int len,
|
||||
switch_asr_flag_t *flags);
|
||||
|
||||
/*!
|
||||
\brief Check an asr handle for results
|
||||
@@ -1371,7 +1249,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_asr_check_results(switch_asr_handle_
|
||||
\param flags flags to influence behaviour
|
||||
\return SWITCH_STATUS_SUCCESS
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_asr_get_results(switch_asr_handle_t *ah, char **xmlstr, switch_asr_flag_t *flags);
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_asr_get_results(switch_asr_handle_t *ah, char **xmlstr,
|
||||
switch_asr_flag_t *flags);
|
||||
|
||||
/*!
|
||||
\brief Load a grammar to an asr handle
|
||||
@@ -1420,12 +1299,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_asr_resume(switch_asr_handle_t *ah);
|
||||
\param pool the pool to use (NULL for new pool)
|
||||
\return SWITCH_STATUS_SUCCESS if the handle is opened
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_directory_open(switch_directory_handle_t *dh,
|
||||
char *module_name,
|
||||
char *source,
|
||||
char *dsn,
|
||||
char *passwd,
|
||||
switch_memory_pool_t *pool);
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_directory_open(switch_directory_handle_t *dh,
|
||||
char *module_name,
|
||||
char *source,
|
||||
char *dsn, char *passwd, switch_memory_pool_t *pool);
|
||||
|
||||
/*!
|
||||
\brief Query a directory handle
|
||||
@@ -1471,6 +1348,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_directory_close(switch_directory_han
|
||||
*/
|
||||
SWITCH_DECLARE(FILE *) switch_core_data_channel(switch_text_channel_t channel);
|
||||
|
||||
/*!
|
||||
\brief Determines if the core is ready to take calls
|
||||
\return SWITCH_TRUE or SWITCH_FALSE
|
||||
*/
|
||||
SWITCH_DECLARE(switch_bool_t) switch_core_ready(void);
|
||||
|
||||
/*!
|
||||
\brief Execute a management operation.
|
||||
\param relative_oid the relative oid of the operation.
|
||||
@@ -1481,8 +1364,7 @@ SWITCH_DECLARE(FILE *) switch_core_data_channel(switch_text_channel_t channel);
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_management_exec(char *relative_oid,
|
||||
switch_management_action_t action,
|
||||
char *data,
|
||||
switch_size_t datalen);
|
||||
char *data, switch_size_t datalen);
|
||||
|
||||
|
||||
/*!
|
||||
@@ -1522,7 +1404,7 @@ SWITCH_DECLARE(switch_time_t) switch_core_uptime(void);
|
||||
\param val the command arguement (if needed)
|
||||
\return 0 on success nonzero on error
|
||||
*/
|
||||
SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, uint32_t *val);
|
||||
SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, uint32_t * val);
|
||||
|
||||
/*!
|
||||
\brief Get the output console
|
||||
@@ -1532,7 +1414,8 @@ SWITCH_DECLARE(FILE *) switch_core_get_console(void);
|
||||
/*!
|
||||
\brief Launch a thread
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_core_launch_thread(void *(*func)(switch_thread_t *, void*), void *obj, switch_memory_pool_t *pool);
|
||||
SWITCH_DECLARE(void) switch_core_launch_thread(void *(*func) (switch_thread_t *, void *), void *obj,
|
||||
switch_memory_pool_t *pool);
|
||||
|
||||
/*!
|
||||
\brief Initiate Globals
|
||||
@@ -1553,9 +1436,7 @@ SWITCH_DECLARE(uint8_t) switch_core_session_compare(switch_core_session_t *a, sw
|
||||
*/
|
||||
|
||||
SWITCH_END_EXTERN_C
|
||||
|
||||
#endif
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
|
||||
@@ -36,28 +36,24 @@
|
||||
#define SWITCH_CORE_DB_H
|
||||
|
||||
SWITCH_BEGIN_EXTERN_C
|
||||
|
||||
/**
|
||||
* @defgroup switch_sqlite_top Brought To You By SQLite
|
||||
* @ingroup FREESWITCH
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup switch_core_db Database Routines
|
||||
* @ingroup switch_sqlite_top
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Each open database is represented by an instance of the
|
||||
* following opaque structure.
|
||||
*/
|
||||
|
||||
typedef struct sqlite3 switch_core_db_t;
|
||||
typedef struct sqlite3 switch_core_db_t;
|
||||
typedef struct sqlite3_stmt switch_core_db_stmt_t;
|
||||
|
||||
typedef int (*switch_core_db_callback_func_t)(void *pArg, int argc, char **argv, char **columnNames);
|
||||
typedef int (*switch_core_db_callback_func_t) (void *pArg, int argc, char **argv, char **columnNames);
|
||||
|
||||
/*
|
||||
** These are special value for the destructor that is passed in as the
|
||||
@@ -71,7 +67,7 @@ typedef int (*switch_core_db_callback_func_t)(void *pArg, int argc, char **argv,
|
||||
** The typedef is necessary to work around problems in certain
|
||||
** C++ compilers.
|
||||
*/
|
||||
typedef void (*switch_core_db_destructor_type_t)(void*);
|
||||
typedef void (*switch_core_db_destructor_type_t) (void *);
|
||||
#define SWITCH_CORE_DB_STATIC ((switch_core_db_destructor_type_t)0)
|
||||
#define SWITCH_CORE_DB_TRANSIENT ((switch_core_db_destructor_type_t)-1)
|
||||
|
||||
@@ -144,14 +140,14 @@ SWITCH_DECLARE(int) switch_core_db_open(const char *filename, switch_core_db_t *
|
||||
*
|
||||
* Return the value as UTF-8 text.
|
||||
*/
|
||||
SWITCH_DECLARE(const unsigned char *)switch_core_db_column_text(switch_core_db_stmt_t *stmt, int iCol);
|
||||
SWITCH_DECLARE(const unsigned char *) switch_core_db_column_text(switch_core_db_stmt_t *stmt, int iCol);
|
||||
|
||||
/**
|
||||
* The first parameter is a compiled SQL statement. This function returns
|
||||
* the column heading for the Nth column of that statement, where N is the
|
||||
* second function parameter. The string returned is UTF-8.
|
||||
*/
|
||||
SWITCH_DECLARE(const char *)switch_core_db_column_name(switch_core_db_stmt_t *stmt, int N);
|
||||
SWITCH_DECLARE(const char *) switch_core_db_column_name(switch_core_db_stmt_t *stmt, int N);
|
||||
|
||||
/**
|
||||
* Return the number of columns in the result set returned by the compiled
|
||||
@@ -168,7 +164,7 @@ SWITCH_DECLARE(int) switch_core_db_column_count(switch_core_db_stmt_t *pStmt);
|
||||
* The string "not an error" is returned when the most recent API call was
|
||||
* successful.
|
||||
*/
|
||||
SWITCH_DECLARE(const char *)switch_core_db_errmsg(switch_core_db_t *db);
|
||||
SWITCH_DECLARE(const char *) switch_core_db_errmsg(switch_core_db_t *db);
|
||||
|
||||
/**
|
||||
* A function to executes one or more statements of SQL.
|
||||
@@ -212,9 +208,7 @@ SWITCH_DECLARE(const char *)switch_core_db_errmsg(switch_core_db_t *db);
|
||||
*/
|
||||
SWITCH_DECLARE(int) switch_core_db_exec(switch_core_db_t *db,
|
||||
const char *sql,
|
||||
switch_core_db_callback_func_t callback,
|
||||
void *data,
|
||||
char **errmsg);
|
||||
switch_core_db_callback_func_t callback, void *data, char **errmsg);
|
||||
|
||||
/**
|
||||
* This function is called to delete a compiled
|
||||
@@ -256,9 +250,7 @@ SWITCH_DECLARE(int) switch_core_db_finalize(switch_core_db_stmt_t *pStmt);
|
||||
*/
|
||||
SWITCH_DECLARE(int) switch_core_db_prepare(switch_core_db_t *db,
|
||||
const char *zSql,
|
||||
int nBytes,
|
||||
switch_core_db_stmt_t **ppStmt,
|
||||
const char **pzTail);
|
||||
int nBytes, switch_core_db_stmt_t **ppStmt, const char **pzTail);
|
||||
|
||||
/**
|
||||
* After an SQL query has been compiled with a call to either
|
||||
@@ -375,7 +367,8 @@ SWITCH_DECLARE(int) switch_core_db_bind_int64(switch_core_db_stmt_t *pStmt, int
|
||||
* an switch_core_db_prepare() or sqlite3_reset(). Unbound parameterss are
|
||||
* interpreted as NULL.
|
||||
*/
|
||||
SWITCH_DECLARE(int) switch_core_db_bind_text(switch_core_db_stmt_t *pStmt, int i, const char *zData, int nData, switch_core_db_destructor_type_t xDel);
|
||||
SWITCH_DECLARE(int) switch_core_db_bind_text(switch_core_db_stmt_t *pStmt, int i, const char *zData, int nData,
|
||||
switch_core_db_destructor_type_t xDel);
|
||||
|
||||
/**
|
||||
* In the SQL strings input to switch_core_db_prepare(),
|
||||
@@ -451,14 +444,13 @@ SWITCH_DECLARE(int64_t) switch_core_db_last_insert_rowid(switch_core_db_t *db);
|
||||
*
|
||||
* The return value of this routine is the same as from switch_core_db_exec().
|
||||
*/
|
||||
SWITCH_DECLARE(int) switch_core_db_get_table(
|
||||
switch_core_db_t *db, /* An open database */
|
||||
const char *sql, /* SQL to be executed */
|
||||
char ***resultp, /* Result written to a char *[] that this points to */
|
||||
int *nrow, /* Number of result rows written here */
|
||||
int *ncolumn, /* Number of result columns written here */
|
||||
char **errmsg /* Error msg written here */
|
||||
);
|
||||
SWITCH_DECLARE(int) switch_core_db_get_table(switch_core_db_t *db, /* An open database */
|
||||
const char *sql, /* SQL to be executed */
|
||||
char ***resultp, /* Result written to a char *[] that this points to */
|
||||
int *nrow, /* Number of result rows written here */
|
||||
int *ncolumn, /* Number of result columns written here */
|
||||
char **errmsg /* Error msg written here */
|
||||
);
|
||||
|
||||
/**
|
||||
* Call this routine to free the memory that sqlite3_get_table() allocated.
|
||||
@@ -471,36 +463,36 @@ SWITCH_DECLARE(void) switch_core_db_free_table(char **result);
|
||||
SWITCH_DECLARE(void) switch_core_db_free(char *z);
|
||||
|
||||
/** Return values for switch_core_db_exec() and switch_core_db_step()*/
|
||||
#define SWITCH_CORE_DB_OK 0 /* Successful result */
|
||||
#define SWITCH_CORE_DB_OK 0 /* Successful result */
|
||||
/* beginning-of-error-codes */
|
||||
#define SWITCH_CORE_DB_ERROR 1 /* SQL error or missing database */
|
||||
#define SWITCH_CORE_DB_INTERNAL 2 /* NOT USED. Internal logic error in SQLite */
|
||||
#define SWITCH_CORE_DB_PERM 3 /* Access permission denied */
|
||||
#define SWITCH_CORE_DB_ABORT 4 /* Callback routine requested an abort */
|
||||
#define SWITCH_CORE_DB_BUSY 5 /* The database file is locked */
|
||||
#define SWITCH_CORE_DB_LOCKED 6 /* A table in the database is locked */
|
||||
#define SWITCH_CORE_DB_NOMEM 7 /* A malloc() failed */
|
||||
#define SWITCH_CORE_DB_READONLY 8 /* Attempt to write a readonly database */
|
||||
#define SWITCH_CORE_DB_INTERRUPT 9 /* Operation terminated by switch_core_db_interrupt()*/
|
||||
#define SWITCH_CORE_DB_IOERR 10 /* Some kind of disk I/O error occurred */
|
||||
#define SWITCH_CORE_DB_CORRUPT 11 /* The database disk image is malformed */
|
||||
#define SWITCH_CORE_DB_NOTFOUND 12 /* NOT USED. Table or record not found */
|
||||
#define SWITCH_CORE_DB_FULL 13 /* Insertion failed because database is full */
|
||||
#define SWITCH_CORE_DB_CANTOPEN 14 /* Unable to open the database file */
|
||||
#define SWITCH_CORE_DB_PROTOCOL 15 /* Database lock protocol error */
|
||||
#define SWITCH_CORE_DB_EMPTY 16 /* Database is empty */
|
||||
#define SWITCH_CORE_DB_SCHEMA 17 /* The database schema changed */
|
||||
#define SWITCH_CORE_DB_TOOBIG 18 /* NOT USED. Too much data for one row */
|
||||
#define SWITCH_CORE_DB_CONSTRAINT 19 /* Abort due to contraint violation */
|
||||
#define SWITCH_CORE_DB_MISMATCH 20 /* Data type mismatch */
|
||||
#define SWITCH_CORE_DB_MISUSE 21 /* Library used incorrectly */
|
||||
#define SWITCH_CORE_DB_NOLFS 22 /* Uses OS features not supported on host */
|
||||
#define SWITCH_CORE_DB_AUTH 23 /* Authorization denied */
|
||||
#define SWITCH_CORE_DB_FORMAT 24 /* Auxiliary database format error */
|
||||
#define SWITCH_CORE_DB_RANGE 25 /* 2nd parameter to switch_core_db_bind out of range */
|
||||
#define SWITCH_CORE_DB_NOTADB 26 /* File opened that is not a database file */
|
||||
#define SWITCH_CORE_DB_ROW 100 /* switch_core_db_step() has another row ready */
|
||||
#define SWITCH_CORE_DB_DONE 101 /* switch_core_db_step() has finished executing */
|
||||
#define SWITCH_CORE_DB_ERROR 1 /* SQL error or missing database */
|
||||
#define SWITCH_CORE_DB_INTERNAL 2 /* NOT USED. Internal logic error in SQLite */
|
||||
#define SWITCH_CORE_DB_PERM 3 /* Access permission denied */
|
||||
#define SWITCH_CORE_DB_ABORT 4 /* Callback routine requested an abort */
|
||||
#define SWITCH_CORE_DB_BUSY 5 /* The database file is locked */
|
||||
#define SWITCH_CORE_DB_LOCKED 6 /* A table in the database is locked */
|
||||
#define SWITCH_CORE_DB_NOMEM 7 /* A malloc() failed */
|
||||
#define SWITCH_CORE_DB_READONLY 8 /* Attempt to write a readonly database */
|
||||
#define SWITCH_CORE_DB_INTERRUPT 9 /* Operation terminated by switch_core_db_interrupt() */
|
||||
#define SWITCH_CORE_DB_IOERR 10 /* Some kind of disk I/O error occurred */
|
||||
#define SWITCH_CORE_DB_CORRUPT 11 /* The database disk image is malformed */
|
||||
#define SWITCH_CORE_DB_NOTFOUND 12 /* NOT USED. Table or record not found */
|
||||
#define SWITCH_CORE_DB_FULL 13 /* Insertion failed because database is full */
|
||||
#define SWITCH_CORE_DB_CANTOPEN 14 /* Unable to open the database file */
|
||||
#define SWITCH_CORE_DB_PROTOCOL 15 /* Database lock protocol error */
|
||||
#define SWITCH_CORE_DB_EMPTY 16 /* Database is empty */
|
||||
#define SWITCH_CORE_DB_SCHEMA 17 /* The database schema changed */
|
||||
#define SWITCH_CORE_DB_TOOBIG 18 /* NOT USED. Too much data for one row */
|
||||
#define SWITCH_CORE_DB_CONSTRAINT 19 /* Abort due to contraint violation */
|
||||
#define SWITCH_CORE_DB_MISMATCH 20 /* Data type mismatch */
|
||||
#define SWITCH_CORE_DB_MISUSE 21 /* Library used incorrectly */
|
||||
#define SWITCH_CORE_DB_NOLFS 22 /* Uses OS features not supported on host */
|
||||
#define SWITCH_CORE_DB_AUTH 23 /* Authorization denied */
|
||||
#define SWITCH_CORE_DB_FORMAT 24 /* Auxiliary database format error */
|
||||
#define SWITCH_CORE_DB_RANGE 25 /* 2nd parameter to switch_core_db_bind out of range */
|
||||
#define SWITCH_CORE_DB_NOTADB 26 /* File opened that is not a database file */
|
||||
#define SWITCH_CORE_DB_ROW 100 /* switch_core_db_step() has another row ready */
|
||||
#define SWITCH_CORE_DB_DONE 101 /* switch_core_db_step() has finished executing */
|
||||
/* end-of-error-codes */
|
||||
|
||||
|
||||
@@ -547,12 +539,10 @@ SWITCH_DECLARE(void) switch_core_db_free(char *z);
|
||||
* should always use %q instead of %s when inserting text into a string
|
||||
* literal.
|
||||
*/
|
||||
SWITCH_DECLARE(char *)switch_mprintf(const char *zFormat,...);
|
||||
SWITCH_DECLARE(char *) switch_mprintf(const char *zFormat, ...);
|
||||
|
||||
SWITCH_END_EXTERN_C
|
||||
|
||||
#endif
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
|
||||
+13
-10
@@ -61,9 +61,8 @@
|
||||
#include <switch.h>
|
||||
|
||||
SWITCH_BEGIN_EXTERN_C
|
||||
|
||||
/*! \brief An event Header */
|
||||
struct switch_event_header{
|
||||
struct switch_event_header {
|
||||
/*! the header name */
|
||||
char *name;
|
||||
/*! the header value */
|
||||
@@ -139,7 +138,8 @@ SWITCH_DECLARE(switch_status_t) switch_event_shutdown(void);
|
||||
\param subclass_name the subclass name for custom event (only valid when event_id is SWITCH_EVENT_CUSTOM)
|
||||
\return SWITCH_STATUS_SUCCESS on success
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_event_create_subclass(switch_event_t **event, switch_event_types_t event_id, const char *subclass_name);
|
||||
SWITCH_DECLARE(switch_status_t) switch_event_create_subclass(switch_event_t **event, switch_event_types_t event_id,
|
||||
const char *subclass_name);
|
||||
|
||||
/*!
|
||||
\brief Set the priority of an event
|
||||
@@ -172,7 +172,9 @@ SWITCH_DECLARE(char *) switch_event_get_body(switch_event_t *event);
|
||||
\param fmt the value of the header (varargs see standard sprintf family)
|
||||
\return SWITCH_STATUS_SUCCESS if the header was added
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_event_add_header(switch_event_t *event, switch_stack_t stack, const char *header_name, const char *fmt, ...) PRINTF_FUNCTION(4,5);
|
||||
SWITCH_DECLARE(switch_status_t) switch_event_add_header(switch_event_t *event, switch_stack_t stack,
|
||||
const char *header_name, const char *fmt,
|
||||
...) PRINTF_FUNCTION(4, 5);
|
||||
|
||||
/*!
|
||||
\brief Destroy an event
|
||||
@@ -197,7 +199,8 @@ SWITCH_DECLARE(switch_status_t) switch_event_dup(switch_event_t **event, switch_
|
||||
\param user_data optional private data to pass to the event handlers
|
||||
\return
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_event_fire_detailed(char *file, char *func, int line, switch_event_t **event, void *user_data);
|
||||
SWITCH_DECLARE(switch_status_t) switch_event_fire_detailed(char *file, char *func, int line, switch_event_t **event,
|
||||
void *user_data);
|
||||
|
||||
/*!
|
||||
\brief Bind an event callback to a specific event
|
||||
@@ -208,7 +211,8 @@ SWITCH_DECLARE(switch_status_t) switch_event_fire_detailed(char *file, char *fun
|
||||
\param user_data optional user specific data to pass whenever the callback is invoked
|
||||
\return SWITCH_STATUS_SUCCESS if the event was binded
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_event_bind(char *id, switch_event_types_t event, char *subclass_name, switch_event_callback_t callback, void *user_data);
|
||||
SWITCH_DECLARE(switch_status_t) switch_event_bind(char *id, switch_event_types_t event, char *subclass_name,
|
||||
switch_event_callback_t callback, void *user_data);
|
||||
|
||||
/*!
|
||||
\brief Render the name of an event id enumeration
|
||||
@@ -251,7 +255,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_serialize(switch_event_t *event, ch
|
||||
\return the xml object if the operation was successful
|
||||
\note the body supplied by this function will supersede an existing body the event may have
|
||||
*/
|
||||
SWITCH_DECLARE(switch_xml_t) switch_event_xmlize(switch_event_t *event, const char *fmt, ...) PRINTF_FUNCTION(2,3);
|
||||
SWITCH_DECLARE(switch_xml_t) switch_event_xmlize(switch_event_t *event, const char *fmt, ...) PRINTF_FUNCTION(2, 3);
|
||||
|
||||
/*!
|
||||
\brief Determine if the event system has been initilized
|
||||
@@ -266,7 +270,8 @@ SWITCH_DECLARE(switch_status_t) switch_event_running(void);
|
||||
\return SWITCH_STATUS_SUCCESS if the body was added to the event
|
||||
\note the body parameter can be shadowed by the switch_event_reserve_subclass_detailed function
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_event_add_body(switch_event_t *event, const char *fmt, ...) PRINTF_FUNCTION(2,3);
|
||||
SWITCH_DECLARE(switch_status_t) switch_event_add_body(switch_event_t *event, const char *fmt, ...) PRINTF_FUNCTION(2,
|
||||
3);
|
||||
|
||||
|
||||
/*!
|
||||
@@ -311,9 +316,7 @@ SWITCH_DECLARE(void) switch_event_deliver(switch_event_t **event);
|
||||
///\}
|
||||
|
||||
SWITCH_END_EXTERN_C
|
||||
|
||||
#endif
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
|
||||
@@ -39,16 +39,15 @@
|
||||
#include <switch.h>
|
||||
|
||||
SWITCH_BEGIN_EXTERN_C
|
||||
|
||||
/*! \brief An abstraction of a data frame */
|
||||
struct switch_frame {
|
||||
struct switch_frame {
|
||||
/*! a pointer to the codec information */
|
||||
switch_codec_t *codec;
|
||||
/*! the originating source of the frame */
|
||||
const char *source;
|
||||
/*! the raw packet */
|
||||
void *packet;
|
||||
/*! the size of the raw packet when applicable*/
|
||||
/*! the size of the raw packet when applicable */
|
||||
uint32_t packetlen;
|
||||
/*! the frame data */
|
||||
void *data;
|
||||
@@ -69,9 +68,7 @@ struct switch_frame {
|
||||
};
|
||||
|
||||
SWITCH_END_EXTERN_C
|
||||
|
||||
#endif
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
|
||||
+112
-114
@@ -42,7 +42,6 @@
|
||||
#include <switch.h>
|
||||
|
||||
SWITCH_BEGIN_EXTERN_C
|
||||
|
||||
/**
|
||||
* @defgroup switch_ivr IVR Library
|
||||
* @ingroup core1
|
||||
@@ -50,8 +49,6 @@ SWITCH_BEGIN_EXTERN_C
|
||||
* building blocks for a higher level IVR interface.
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\brief Generate an XML CDR report.
|
||||
\param session the session to get the data from.
|
||||
@@ -59,7 +56,7 @@ SWITCH_BEGIN_EXTERN_C
|
||||
\return SWITCH_STATUS_SUCCESS if successful
|
||||
\note on success the xml object must be freed
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_generate_xml_cdr(switch_core_session_t *session, switch_xml_t *xml_cdr);
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_generate_xml_cdr(switch_core_session_t *session, switch_xml_t * xml_cdr);
|
||||
|
||||
/*!
|
||||
\brief Parse command from an event
|
||||
@@ -89,8 +86,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session,
|
||||
\return SWITCH_STATUS_SUCCESS to keep the collection moving.
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_callback(switch_core_session_t *session,
|
||||
switch_input_args_t *args,
|
||||
uint32_t timeout);
|
||||
switch_input_args_t *args, uint32_t timeout);
|
||||
|
||||
/*!
|
||||
\brief Wait for specified number of DTMF digits, untile terminator is received or until the channel hangs up.
|
||||
@@ -108,8 +104,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_sess
|
||||
uint32_t buflen,
|
||||
uint32_t maxdigits,
|
||||
const char *terminators,
|
||||
char *terminator,
|
||||
uint32_t timeout);
|
||||
char *terminator, uint32_t timeout);
|
||||
|
||||
/*!
|
||||
\brief Engage background Speech detection on a session
|
||||
@@ -124,9 +119,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_sess
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech(switch_core_session_t *session,
|
||||
char *mod_name,
|
||||
char *grammar,
|
||||
char *path,
|
||||
char *dest,
|
||||
switch_asr_handle_t *ah);
|
||||
char *path, char *dest, switch_asr_handle_t *ah);
|
||||
|
||||
/*!
|
||||
\brief Stop background Speech detection on a session
|
||||
@@ -156,7 +149,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_resume_detect_speech(switch_core_sess
|
||||
\param path the grammar path
|
||||
\return SWITCH_STATUS_SUCCESS if all is well
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech_load_grammar(switch_core_session_t *session, char *grammar, char *path);
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech_load_grammar(switch_core_session_t *session, char *grammar,
|
||||
char *path);
|
||||
|
||||
/*!
|
||||
\brief Unload a grammar on a background speech detection handle
|
||||
@@ -173,7 +167,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech_unload_grammar(switch_c
|
||||
\param fh file handle to use (NULL for builtin one)
|
||||
\return SWITCH_STATUS_SUCCESS if all is well
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t *session, char *file, switch_file_handle_t *fh);
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t *session, char *file,
|
||||
switch_file_handle_t *fh);
|
||||
|
||||
/*!
|
||||
\brief Stop Recording a session
|
||||
@@ -198,9 +193,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_stop_inband_dtmf_session(switch_core_
|
||||
\note passing a NULL dtmf_callback nad a not NULL buf indicates to copy any dtmf to buf and stop playback.
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *session,
|
||||
switch_file_handle_t *fh,
|
||||
char *file,
|
||||
switch_input_args_t *args);
|
||||
switch_file_handle_t *fh, char *file, switch_input_args_t *args);
|
||||
|
||||
|
||||
/*!
|
||||
@@ -216,10 +209,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
|
||||
\note passing a NULL dtmf_callback nad a not NULL buf indicates to copy any dtmf to buf and stop recording.
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *session,
|
||||
switch_file_handle_t *fh,
|
||||
char *file,
|
||||
switch_input_args_t *args,
|
||||
uint32_t limit);
|
||||
switch_file_handle_t *fh,
|
||||
char *file, switch_input_args_t *args, uint32_t limit);
|
||||
|
||||
|
||||
/*!
|
||||
@@ -239,23 +230,21 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
|
||||
\note to test for digit capture failure look for \\0 in the first position of the buffer
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_play_and_get_digits(switch_core_session_t *session,
|
||||
uint32_t min_digits,
|
||||
uint32_t max_digits,
|
||||
uint32_t max_tries,
|
||||
uint32_t timeout,
|
||||
char* valid_terminators,
|
||||
char* audio_file,
|
||||
char* bad_input_audio_file,
|
||||
void* digit_buffer,
|
||||
uint32_t digit_buffer_length,
|
||||
char* digits_regex);
|
||||
uint32_t min_digits,
|
||||
uint32_t max_digits,
|
||||
uint32_t max_tries,
|
||||
uint32_t timeout,
|
||||
char *valid_terminators,
|
||||
char *audio_file,
|
||||
char *bad_input_audio_file,
|
||||
void *digit_buffer,
|
||||
uint32_t digit_buffer_length, char *digits_regex);
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text_handle(switch_core_session_t *session,
|
||||
switch_speech_handle_t *sh,
|
||||
switch_codec_t *codec,
|
||||
switch_timer_t *timer,
|
||||
char *text,
|
||||
switch_input_args_t *args);
|
||||
switch_speech_handle_t *sh,
|
||||
switch_codec_t *codec,
|
||||
switch_timer_t *timer,
|
||||
char *text, switch_input_args_t *args);
|
||||
|
||||
/*!
|
||||
\brief Speak given text with given tts engine
|
||||
@@ -269,12 +258,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text_handle(switch_core_session
|
||||
\param buflen the len of buf
|
||||
\return SWITCH_STATUS_SUCCESS if all is well
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text(switch_core_session_t *session,
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text(switch_core_session_t *session,
|
||||
char *tts_name,
|
||||
char *voice_name,
|
||||
uint32_t rate,
|
||||
char *text,
|
||||
switch_input_args_t *args);
|
||||
uint32_t rate, char *text, switch_input_args_t *args);
|
||||
|
||||
/*!
|
||||
\brief Make an outgoing call
|
||||
@@ -308,11 +295,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
|
||||
\param peer_session_data data to pass to the DTMF callback for peer_session
|
||||
\return SWITCH_STATUS_SUCCESS if all is well
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_session_t *session,
|
||||
SWITCH_DECLARE(switch_status_t) 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);
|
||||
void *session_data, void *peer_session_data);
|
||||
|
||||
/*!
|
||||
\brief Bridge Signalling from one session to another
|
||||
@@ -320,7 +306,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses
|
||||
\param peer_session the other session
|
||||
\return SWITCH_STATUS_SUCCESS if all is well
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_signal_bridge(switch_core_session_t *session, switch_core_session_t *peer_session);
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_signal_bridge(switch_core_session_t *session,
|
||||
switch_core_session_t *peer_session);
|
||||
|
||||
/*!
|
||||
\brief Transfer an existing session to another location
|
||||
@@ -329,7 +316,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_signal_bridge(switch_core_session_t *
|
||||
\param dialplan the new dialplan (OPTIONAL, may be NULL)
|
||||
\param context the new context (OPTIONAL, may be NULL)
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(switch_core_session_t *session, char *extension, char *dialplan, char *context);
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(switch_core_session_t *session, char *extension,
|
||||
char *dialplan, char *context);
|
||||
|
||||
/*!
|
||||
\brief Transfer an existing session to another location in the future
|
||||
@@ -340,7 +328,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(switch_core_session_
|
||||
\param context the new context (OPTIONAL, may be NULL)
|
||||
\return the id of the task
|
||||
*/
|
||||
SWITCH_DECLARE(uint32_t) switch_ivr_schedule_transfer(time_t runtime, char *uuid, char *extension, char *dialplan, char *context);
|
||||
SWITCH_DECLARE(uint32_t) switch_ivr_schedule_transfer(time_t runtime, char *uuid, char *extension, char *dialplan,
|
||||
char *context);
|
||||
|
||||
|
||||
/*!
|
||||
@@ -351,7 +340,8 @@ SWITCH_DECLARE(uint32_t) switch_ivr_schedule_transfer(time_t runtime, char *uuid
|
||||
\param bleg hangup up the B-Leg if possible
|
||||
\return the id of the task
|
||||
*/
|
||||
SWITCH_DECLARE(uint32_t) switch_ivr_schedule_hangup(time_t runtime, char *uuid, switch_call_cause_t cause, switch_bool_t bleg);
|
||||
SWITCH_DECLARE(uint32_t) switch_ivr_schedule_hangup(time_t runtime, char *uuid, switch_call_cause_t cause,
|
||||
switch_bool_t bleg);
|
||||
|
||||
/*!
|
||||
\brief Bridge two existing sessions
|
||||
@@ -413,7 +403,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_unhold(switch_core_session_t *session
|
||||
\param flags flags to send to the request (SMF_ECHO_BRIDGED to send the broadcast to both sides of the call)
|
||||
\return the id of the task
|
||||
*/
|
||||
SWITCH_DECLARE(uint32_t) switch_ivr_schedule_broadcast(time_t runtime, char *uuid, char *path, switch_media_flag_t flags);
|
||||
SWITCH_DECLARE(uint32_t) switch_ivr_schedule_broadcast(time_t runtime, char *uuid, char *path,
|
||||
switch_media_flag_t flags);
|
||||
|
||||
/*!
|
||||
\brief Signal the session to broadcast audio
|
||||
@@ -431,22 +422,24 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_broadcast(char *uuid, char *path, swi
|
||||
\param var the name of the variable to transfer (NULL for all)
|
||||
\return SWITCH_STATUS_SUCCESS if all is well
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_transfer_variable(switch_core_session_t *sessa, switch_core_session_t *sessb, char *var);
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_transfer_variable(switch_core_session_t *sessa, switch_core_session_t *sessb,
|
||||
char *var);
|
||||
|
||||
|
||||
/******************************************************************************************************/
|
||||
|
||||
struct switch_ivr_digit_stream_parser;
|
||||
typedef struct switch_ivr_digit_stream_parser switch_ivr_digit_stream_parser_t;
|
||||
struct switch_ivr_digit_stream;
|
||||
typedef struct switch_ivr_digit_stream switch_ivr_digit_stream_t;
|
||||
struct switch_ivr_digit_stream_parser;
|
||||
typedef struct switch_ivr_digit_stream_parser switch_ivr_digit_stream_parser_t;
|
||||
struct switch_ivr_digit_stream;
|
||||
typedef struct switch_ivr_digit_stream switch_ivr_digit_stream_t;
|
||||
/*!
|
||||
\brief Create a digit stream parser object
|
||||
\param pool the pool to use for the new hash
|
||||
\param parser a pointer to the object pointer
|
||||
\return SWITCH_STATUS_SUCCESS if all is well
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_new(switch_memory_pool_t *pool, switch_ivr_digit_stream_parser_t **parser);
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_new(switch_memory_pool_t *pool,
|
||||
switch_ivr_digit_stream_parser_t **parser);
|
||||
|
||||
/*!
|
||||
\brief Destroy a digit stream parser object
|
||||
@@ -461,7 +454,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_destroy(switch_iv
|
||||
\param stream a pointer to the stream object pointer
|
||||
\return NULL if no match found or consumer data that was associated with a given digit string when matched
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_new(switch_ivr_digit_stream_parser_t *parser, switch_ivr_digit_stream_t **stream);
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_new(switch_ivr_digit_stream_parser_t *parser,
|
||||
switch_ivr_digit_stream_t **stream);
|
||||
|
||||
/*!
|
||||
\brief Destroys a digit stream object
|
||||
@@ -477,7 +471,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_destroy(switch_ivr_digit
|
||||
\param data consumer data attached to this digit string
|
||||
\return SWITCH_STATUS_SUCCESS if all is well
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_set_event(switch_ivr_digit_stream_parser_t *parser, char *digits, void *data);
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_set_event(switch_ivr_digit_stream_parser_t *parser,
|
||||
char *digits, void *data);
|
||||
|
||||
/*!
|
||||
\brief Delete a string to action mapping
|
||||
@@ -485,7 +480,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_set_event(switch_
|
||||
\param digits the digit string to be removed from the map
|
||||
\return SWITCH_STATUS_SUCCESS if all is well
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_del_event(switch_ivr_digit_stream_parser_t *parser, char *digits);
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_del_event(switch_ivr_digit_stream_parser_t *parser,
|
||||
char *digits);
|
||||
|
||||
/*!
|
||||
\brief Feed digits collected into the stream for event match testing
|
||||
@@ -493,7 +489,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_del_event(switch_
|
||||
\param digit a digit to collect and test against the map of digit strings
|
||||
\return NULL if no match found or consumer data that was associated with a given digit string when matched
|
||||
*/
|
||||
SWITCH_DECLARE(void *) switch_ivr_digit_stream_parser_feed(switch_ivr_digit_stream_parser_t *parser, switch_ivr_digit_stream_t *stream, char digit);
|
||||
SWITCH_DECLARE(void *) switch_ivr_digit_stream_parser_feed(switch_ivr_digit_stream_parser_t *parser,
|
||||
switch_ivr_digit_stream_t *stream, char digit);
|
||||
|
||||
/*!
|
||||
\brief Reset the collected digit stream to nothing
|
||||
@@ -508,7 +505,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_reset(switch_ivr_digit_s
|
||||
\param digit the terminator digit
|
||||
\return SWITCH_STATUS_SUCCESS if all is well
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_set_terminator(switch_ivr_digit_stream_parser_t *parser, char digit);
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_set_terminator(switch_ivr_digit_stream_parser_t *parser,
|
||||
char digit);
|
||||
|
||||
|
||||
/******************************************************************************************************/
|
||||
@@ -524,28 +522,29 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_set_terminator(sw
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
SWITCH_IVR_MENU_FLAG_FALLTOMAIN = (1 << 0),
|
||||
SWITCH_IVR_MENU_FLAG_FREEPOOL = (1 << 1),
|
||||
SWITCH_IVR_MENU_FLAG_STACK = (1 << 2),
|
||||
} switch_ivr_menu_flags;
|
||||
typedef enum {
|
||||
SWITCH_IVR_MENU_FLAG_FALLTOMAIN = (1 << 0),
|
||||
SWITCH_IVR_MENU_FLAG_FREEPOOL = (1 << 1),
|
||||
SWITCH_IVR_MENU_FLAG_STACK = (1 << 2),
|
||||
} switch_ivr_menu_flags;
|
||||
/* Actions are either set in switch_ivr_menu_bind_function or returned by a callback */
|
||||
typedef enum {
|
||||
SWITCH_IVR_ACTION_DIE, /* Exit the menu. */
|
||||
SWITCH_IVR_ACTION_EXECMENU, /* Goto another menu in the stack. */
|
||||
SWITCH_IVR_ACTION_EXECAPP, /* Execute an application. */
|
||||
SWITCH_IVR_ACTION_PLAYSOUND, /* Play a sound. */
|
||||
SWITCH_IVR_ACTION_SAYTEXT, /* say text. */
|
||||
SWITCH_IVR_ACTION_SAYPHRASE, /* say a phrase macro. */
|
||||
SWITCH_IVR_ACTION_BACK, /* Go back 1 menu. */
|
||||
SWITCH_IVR_ACTION_TOMAIN, /* Go back to the top level menu. */
|
||||
SWITCH_IVR_ACTION_TRANSFER, /* Transfer caller to another ext. */
|
||||
SWITCH_IVR_ACTION_NOOP, /* No operation */
|
||||
} switch_ivr_action_t;
|
||||
struct switch_ivr_menu;
|
||||
typedef switch_ivr_action_t switch_ivr_menu_action_function_t(struct switch_ivr_menu *, char *, char *, size_t, void *);
|
||||
typedef struct switch_ivr_menu switch_ivr_menu_t;
|
||||
typedef struct switch_ivr_menu_action switch_ivr_menu_action_t;
|
||||
typedef enum {
|
||||
SWITCH_IVR_ACTION_DIE, /* Exit the menu. */
|
||||
SWITCH_IVR_ACTION_EXECMENU, /* Goto another menu in the stack. */
|
||||
SWITCH_IVR_ACTION_EXECAPP, /* Execute an application. */
|
||||
SWITCH_IVR_ACTION_PLAYSOUND, /* Play a sound. */
|
||||
SWITCH_IVR_ACTION_SAYTEXT, /* say text. */
|
||||
SWITCH_IVR_ACTION_SAYPHRASE, /* say a phrase macro. */
|
||||
SWITCH_IVR_ACTION_BACK, /* Go back 1 menu. */
|
||||
SWITCH_IVR_ACTION_TOMAIN, /* Go back to the top level menu. */
|
||||
SWITCH_IVR_ACTION_TRANSFER, /* Transfer caller to another ext. */
|
||||
SWITCH_IVR_ACTION_NOOP, /* No operation */
|
||||
} switch_ivr_action_t;
|
||||
struct switch_ivr_menu;
|
||||
typedef switch_ivr_action_t switch_ivr_menu_action_function_t(struct switch_ivr_menu *, char *, char *, size_t,
|
||||
void *);
|
||||
typedef struct switch_ivr_menu switch_ivr_menu_t;
|
||||
typedef struct switch_ivr_menu_action switch_ivr_menu_action_t;
|
||||
/******************************************************************************************************/
|
||||
|
||||
/*!
|
||||
@@ -564,19 +563,17 @@ typedef struct switch_ivr_menu_action switch_ivr_menu_action_t;
|
||||
*\param pool memory pool (NULL to create one)
|
||||
*\return SWITCH_STATUS_SUCCESS if the menu was created
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_menu_init(switch_ivr_menu_t **new_menu,
|
||||
switch_ivr_menu_t *main,
|
||||
const char *name,
|
||||
const char *greeting_sound,
|
||||
const char *short_greeting_sound,
|
||||
const char *exit_sound,
|
||||
const char *invalid_sound,
|
||||
const char *tts_engine,
|
||||
const char *tts_voice,
|
||||
const char *phrase_lang,
|
||||
int timeout,
|
||||
int max_failures,
|
||||
switch_memory_pool_t *pool);
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_menu_init(switch_ivr_menu_t **new_menu,
|
||||
switch_ivr_menu_t *main,
|
||||
const char *name,
|
||||
const char *greeting_sound,
|
||||
const char *short_greeting_sound,
|
||||
const char *exit_sound,
|
||||
const char *invalid_sound,
|
||||
const char *tts_engine,
|
||||
const char *tts_voice,
|
||||
const char *phrase_lang,
|
||||
int timeout, int max_failures, switch_memory_pool_t *pool);
|
||||
|
||||
/*!
|
||||
*\brief switch_ivr_menu_bind_action: Bind a keystroke to an action.
|
||||
@@ -586,7 +583,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_init(switch_ivr_menu_t **new_men
|
||||
*\param bind KeyStrokes to bind the action to.
|
||||
*\return SWUTCH_STATUS_SUCCESS if the action was binded
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_action(switch_ivr_menu_t *menu, switch_ivr_action_t ivr_action, const char *arg, const char *bind);
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_action(switch_ivr_menu_t *menu,
|
||||
switch_ivr_action_t ivr_action, const char *arg,
|
||||
const char *bind);
|
||||
|
||||
|
||||
/*!
|
||||
@@ -600,7 +599,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_action(switch_ivr_menu_t *m
|
||||
*\note The function returns an switch_ivr_action_t enum of what you want to do. and looks to your buffer for args.
|
||||
*\return SWUTCH_STATUS_SUCCESS if the function was binded
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_function(switch_ivr_menu_t *menu, switch_ivr_menu_action_function_t *function, const char *arg, const char *bind);
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_function(switch_ivr_menu_t *menu,
|
||||
switch_ivr_menu_action_function_t * function,
|
||||
const char *arg, const char *bind);
|
||||
|
||||
|
||||
/*!
|
||||
@@ -611,17 +612,18 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_function(switch_ivr_menu_t
|
||||
*\param obj A void pointer to an object you want to make avaliable to your callback functions that you may have binded with switch_ivr_menu_bind_function.
|
||||
*\return SWITCH_STATUS_SUCCESS if all is well
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_menu_execute(switch_core_session_t *session, switch_ivr_menu_t *stack, char *name, void *obj);
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_menu_execute(switch_core_session_t *session, switch_ivr_menu_t *stack,
|
||||
char *name, void *obj);
|
||||
|
||||
/*!
|
||||
*\brief free a stack of menu objects.
|
||||
*\param stack The top level menu you wish to destroy.
|
||||
*\return SWITCH_STATUS_SUCCESS if the object was a top level menu and it was freed
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_free(switch_ivr_menu_t *stack);
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_free(switch_ivr_menu_t *stack);
|
||||
|
||||
struct switch_ivr_menu_xml_ctx;
|
||||
typedef struct switch_ivr_menu_xml_ctx switch_ivr_menu_xml_ctx_t;
|
||||
struct switch_ivr_menu_xml_ctx;
|
||||
typedef struct switch_ivr_menu_xml_ctx switch_ivr_menu_xml_ctx_t;
|
||||
/*!
|
||||
*\brief Build a menu stack from an xml source
|
||||
*\param xml_menu_ctx The XML menu parser context previously created by switch_ivr_menu_stack_xml_init
|
||||
@@ -630,10 +632,9 @@ typedef struct switch_ivr_menu_xml_ctx switch_ivr_menu_xml_ctx_t;
|
||||
*\param xml_menu The xml Menu source of the menu to be created
|
||||
*\return SWITCH_STATUS_SUCCESS if all is well
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_build(switch_ivr_menu_xml_ctx_t *xml_menu_ctx,
|
||||
switch_ivr_menu_t **menu_stack,
|
||||
switch_xml_t xml_menus,
|
||||
switch_xml_t xml_menu);
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_build(switch_ivr_menu_xml_ctx_t *xml_menu_ctx,
|
||||
switch_ivr_menu_t **menu_stack,
|
||||
switch_xml_t xml_menus, switch_xml_t xml_menu);
|
||||
|
||||
/*!
|
||||
*\param xml_menu_ctx The XML menu parser context previously created by switch_ivr_menu_stack_xml_init
|
||||
@@ -641,28 +642,25 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_build(switch_ivr_menu_
|
||||
*\param function The menu function callback that will be executed when menu digits are bound to this name
|
||||
*\return SWITCH_STATUS_SUCCESS if all is well
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_add_custom(switch_ivr_menu_xml_ctx_t *xml_menu_ctx,
|
||||
char *name,
|
||||
switch_ivr_menu_action_function_t *function);
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_add_custom(switch_ivr_menu_xml_ctx_t *xml_menu_ctx,
|
||||
char *name,
|
||||
switch_ivr_menu_action_function_t * function);
|
||||
|
||||
/*!
|
||||
*\param xml_menu_ctx A pointer of a XML menu parser context to be created
|
||||
*\param pool memory pool (NULL to create one)
|
||||
*\return SWITCH_STATUS_SUCCESS if all is well
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_init(switch_ivr_menu_xml_ctx_t **xml_menu_ctx, switch_memory_pool_t *pool);
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_init(switch_ivr_menu_xml_ctx_t **xml_menu_ctx,
|
||||
switch_memory_pool_t *pool);
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro(switch_core_session_t *session,
|
||||
char *macro_name,
|
||||
char *data,
|
||||
char *lang,
|
||||
switch_input_args_t *args);
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro(switch_core_session_t *session,
|
||||
char *macro_name,
|
||||
char *data, char *lang, switch_input_args_t *args);
|
||||
/** @} */
|
||||
|
||||
SWITCH_END_EXTERN_C
|
||||
|
||||
SWITCH_END_EXTERN_C
|
||||
#endif
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
|
||||
@@ -44,15 +44,13 @@
|
||||
#include <switch.h>
|
||||
|
||||
SWITCH_BEGIN_EXTERN_C
|
||||
|
||||
/*!
|
||||
\defgroup mods Loadable Module Functions
|
||||
\ingroup core1
|
||||
\{
|
||||
*/
|
||||
|
||||
/*! \brief The abstraction of a loadable module */
|
||||
struct switch_loadable_module_interface {
|
||||
struct switch_loadable_module_interface {
|
||||
/*! the name of the module */
|
||||
const char *module_name;
|
||||
/*! the table of endpoints the module has implmented */
|
||||
@@ -76,7 +74,7 @@ struct switch_loadable_module_interface {
|
||||
/*! the table of chat interfaces the module has implmented */
|
||||
const switch_chat_interface_t *chat_interface;
|
||||
/*! the table of say interfaces the module has implmented */
|
||||
const switch_say_interface_t *say_interface;
|
||||
const switch_say_interface_t *say_interface;
|
||||
/*! the table of asr interfaces the module has implmented */
|
||||
const switch_asr_interface_t *asr_interface;
|
||||
/*! the table of management interfaces the module has implmented */
|
||||
@@ -125,9 +123,9 @@ SWITCH_DECLARE(switch_dialplan_interface_t *) switch_loadable_module_get_dialpla
|
||||
\note only use this function if you are making a module that in turn gateways module loading to another technology
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_loadable_module_build_dynamic(char *filename,
|
||||
switch_module_load_t switch_module_load,
|
||||
switch_module_runtime_t switch_module_runtime,
|
||||
switch_module_shutdown_t switch_module_shutdown);
|
||||
switch_module_load_t switch_module_load,
|
||||
switch_module_runtime_t switch_module_runtime,
|
||||
switch_module_shutdown_t switch_module_shutdown);
|
||||
|
||||
/*!
|
||||
\brief Retrieve the timer interface by it's registered name
|
||||
@@ -206,8 +204,8 @@ SWITCH_DECLARE(switch_management_interface_t *) switch_loadable_module_get_manag
|
||||
\param arraylen the max size in elements of the array
|
||||
\return the number of elements added to the array
|
||||
*/
|
||||
SWITCH_DECLARE(int) switch_loadable_module_get_codecs(switch_memory_pool_t *pool, const switch_codec_implementation_t **array,
|
||||
int arraylen);
|
||||
SWITCH_DECLARE(int) switch_loadable_module_get_codecs(switch_memory_pool_t *pool,
|
||||
const switch_codec_implementation_t **array, int arraylen);
|
||||
|
||||
|
||||
/*!
|
||||
@@ -230,7 +228,8 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_
|
||||
\param stream stream for output
|
||||
\return the status returned by the API call
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_api_execute(char *cmd, char *arg, switch_core_session_t *session, switch_stream_handle_t *stream);
|
||||
SWITCH_DECLARE(switch_status_t) switch_api_execute(char *cmd, char *arg, switch_core_session_t *session,
|
||||
switch_stream_handle_t *stream);
|
||||
|
||||
|
||||
|
||||
@@ -250,7 +249,8 @@ SWITCH_DECLARE(switch_status_t) switch_loadable_module_load_module(char *dir, ch
|
||||
\param filename the path to the module's dll or so file
|
||||
\return SWITCH_STATUS_SUCCESS on a successful load
|
||||
*/
|
||||
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);
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_reload(void);
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_pause(void);
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_resume(void);
|
||||
@@ -266,9 +266,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void);
|
||||
///\}
|
||||
|
||||
SWITCH_END_EXTERN_C
|
||||
|
||||
#endif
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
|
||||
@@ -41,35 +41,32 @@
|
||||
#include <switch.h>
|
||||
|
||||
SWITCH_BEGIN_EXTERN_C
|
||||
|
||||
///\defgroup log Logger Routines
|
||||
///\ingroup core1
|
||||
///\{
|
||||
|
||||
|
||||
/*! \brief Log Data
|
||||
*/
|
||||
typedef struct {
|
||||
typedef struct {
|
||||
/*! The complete log message */
|
||||
char *data;
|
||||
/*! The file where the message originated */
|
||||
/*! The file where the message originated */
|
||||
char *file;
|
||||
/*! The line number where the message originated */
|
||||
/*! The line number where the message originated */
|
||||
uint32_t line;
|
||||
/*! The function where the message originated */
|
||||
/*! The function where the message originated */
|
||||
char *func;
|
||||
/*! The log level of the message */
|
||||
/*! The log level of the message */
|
||||
switch_log_level_t level;
|
||||
/*! The time when the log line was sent */
|
||||
switch_time_t timestamp;
|
||||
/*! A pointer to where the actual content of the message starts (skipping past the preformatted portion) */
|
||||
/*! A pointer to where the actual content of the message starts (skipping past the preformatted portion) */
|
||||
char *content;
|
||||
|
||||
/* To maintain abi, only add new elements to the end of this struct and do not delete any elements */
|
||||
|
||||
} switch_log_node_t;
|
||||
|
||||
typedef switch_status_t (*switch_log_function_t)(const switch_log_node_t *node, switch_log_level_t level);
|
||||
typedef switch_status_t (*switch_log_function_t) (const switch_log_node_t *node, switch_log_level_t level);
|
||||
|
||||
|
||||
/*!
|
||||
@@ -97,7 +94,8 @@ SWITCH_DECLARE(switch_status_t) switch_log_shutdown(void);
|
||||
\param ... variable args
|
||||
\note there are channel macros to supply the first 4 parameters
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_log_printf(switch_text_channel_t channel, const char *file, const char *func, int line, switch_log_level_t level, const char *fmt, ...) PRINTF_FUNCTION(6,7);
|
||||
SWITCH_DECLARE(void) switch_log_printf(switch_text_channel_t channel, const char *file, const char *func, int line,
|
||||
switch_log_level_t level, const char *fmt, ...) PRINTF_FUNCTION(6, 7);
|
||||
|
||||
/*!
|
||||
\brief Shut down the logging engine
|
||||
@@ -121,9 +119,7 @@ SWITCH_DECLARE(switch_log_level_t) switch_log_str2level(const char *str);
|
||||
|
||||
///\}
|
||||
SWITCH_END_EXTERN_C
|
||||
|
||||
#endif
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
|
||||
@@ -42,10 +42,9 @@
|
||||
#include <switch.h>
|
||||
|
||||
SWITCH_BEGIN_EXTERN_C
|
||||
|
||||
/*! \brief A table of functions to execute at various states
|
||||
*/
|
||||
struct switch_state_handler_table {
|
||||
struct switch_state_handler_table {
|
||||
/*! executed when the state changes to init */
|
||||
switch_state_handler_t on_init;
|
||||
/*! executed when the state changes to ring */
|
||||
@@ -54,13 +53,13 @@ struct switch_state_handler_table {
|
||||
switch_state_handler_t on_execute;
|
||||
/*! executed when the state changes to hangup */
|
||||
switch_state_handler_t on_hangup;
|
||||
/*! executed when the state changes to loopback*/
|
||||
/*! executed when the state changes to loopback */
|
||||
switch_state_handler_t on_loopback;
|
||||
/*! executed when the state changes to transmit*/
|
||||
/*! executed when the state changes to transmit */
|
||||
switch_state_handler_t on_transmit;
|
||||
/*! executed when the state changes to hold*/
|
||||
/*! executed when the state changes to hold */
|
||||
switch_state_handler_t on_hold;
|
||||
/*! executed when the state changes to hibernate*/
|
||||
/*! executed when the state changes to hibernate */
|
||||
switch_state_handler_t on_hibernate;
|
||||
};
|
||||
|
||||
@@ -75,133 +74,34 @@ struct switch_stream_handle {
|
||||
switch_event_t *event;
|
||||
};
|
||||
|
||||
/*! \brief Node in which to store custom outgoing channel callback hooks */
|
||||
struct switch_io_event_hook_outgoing_channel {
|
||||
/*! the outgoing channel callback hook*/
|
||||
switch_outgoing_channel_hook_t outgoing_channel;
|
||||
struct switch_io_event_hook_outgoing_channel *next;
|
||||
};
|
||||
struct switch_io_event_hooks;
|
||||
|
||||
/*! \brief Node in which to store custom answer channel callback hooks */
|
||||
struct switch_io_event_hook_answer_channel {
|
||||
/*! the answer channel callback hook*/
|
||||
switch_answer_channel_hook_t answer_channel;
|
||||
struct switch_io_event_hook_answer_channel *next;
|
||||
};
|
||||
|
||||
/*! \brief Node in which to store custom receive message callback hooks */
|
||||
struct switch_io_event_hook_receive_message {
|
||||
/*! the answer channel callback hook*/
|
||||
switch_receive_message_hook_t receive_message;
|
||||
struct switch_io_event_hook_receive_message *next;
|
||||
};
|
||||
|
||||
/*! \brief Node in which to store custom receive message callback hooks */
|
||||
struct switch_io_event_hook_receive_event {
|
||||
/*! the answer channel callback hook*/
|
||||
switch_receive_event_hook_t receive_event;
|
||||
struct switch_io_event_hook_receive_event *next;
|
||||
};
|
||||
|
||||
/*! \brief Node in which to store custom read frame channel callback hooks */
|
||||
struct switch_io_event_hook_read_frame {
|
||||
/*! the read frame channel callback hook*/
|
||||
switch_read_frame_hook_t read_frame;
|
||||
struct switch_io_event_hook_read_frame *next;
|
||||
};
|
||||
|
||||
/*! \brief Node in which to store custom write_frame channel callback hooks */
|
||||
struct switch_io_event_hook_write_frame {
|
||||
/*! the write_frame channel callback hook*/
|
||||
switch_write_frame_hook_t write_frame;
|
||||
struct switch_io_event_hook_write_frame *next;
|
||||
};
|
||||
|
||||
/*! \brief Node in which to store custom kill channel callback hooks */
|
||||
struct switch_io_event_hook_kill_channel {
|
||||
/*! the kill channel callback hook*/
|
||||
switch_kill_channel_hook_t kill_channel;
|
||||
struct switch_io_event_hook_kill_channel *next;
|
||||
};
|
||||
|
||||
/*! \brief Node in which to store custom waitfor read channel callback hooks */
|
||||
struct switch_io_event_hook_waitfor_read {
|
||||
/*! the waitfor read channel callback hook*/
|
||||
switch_waitfor_read_hook_t waitfor_read;
|
||||
struct switch_io_event_hook_waitfor_read *next;
|
||||
};
|
||||
|
||||
/*! \brief Node in which to store custom waitfor write channel callback hooks */
|
||||
struct switch_io_event_hook_waitfor_write {
|
||||
/*! the waitfor write channel callback hook*/
|
||||
switch_waitfor_write_hook_t waitfor_write;
|
||||
struct switch_io_event_hook_waitfor_write *next;
|
||||
};
|
||||
|
||||
/*! \brief Node in which to store custom send dtmf channel callback hooks */
|
||||
struct switch_io_event_hook_send_dtmf {
|
||||
/*! the send dtmf channel callback hook*/
|
||||
switch_send_dtmf_hook_t send_dtmf;
|
||||
struct switch_io_event_hook_send_dtmf *next;
|
||||
};
|
||||
|
||||
/*! \brief Node in which to store state change callback hooks */
|
||||
struct switch_io_event_hook_state_change {
|
||||
/*! the send dtmf channel callback hook*/
|
||||
switch_state_change_hook_t state_change;
|
||||
struct switch_io_event_hook_state_change *next;
|
||||
};
|
||||
|
||||
/*! \brief A table of lists of io_event_hooks to store the event hooks associated with a session */
|
||||
struct switch_io_event_hooks {
|
||||
/*! a list of outgoing channel hooks */
|
||||
switch_io_event_hook_outgoing_channel_t *outgoing_channel;
|
||||
/*! a list of answer channel hooks */
|
||||
switch_io_event_hook_answer_channel_t *answer_channel;
|
||||
/*! a list of receive message hooks */
|
||||
switch_io_event_hook_receive_message_t *receive_message;
|
||||
/*! a list of queue message hooks */
|
||||
switch_io_event_hook_receive_event_t *receive_event;
|
||||
/*! a list of read frame hooks */
|
||||
switch_io_event_hook_read_frame_t *read_frame;
|
||||
/*! a list of write frame hooks */
|
||||
switch_io_event_hook_write_frame_t *write_frame;
|
||||
/*! a list of kill channel hooks */
|
||||
switch_io_event_hook_kill_channel_t *kill_channel;
|
||||
/*! a list of wait for read hooks */
|
||||
switch_io_event_hook_waitfor_read_t *waitfor_read;
|
||||
/*! a list of wait for write hooks */
|
||||
switch_io_event_hook_waitfor_write_t *waitfor_write;
|
||||
/*! a list of send dtmf hooks */
|
||||
switch_io_event_hook_send_dtmf_t *send_dtmf;
|
||||
/*! a list of state change hooks */
|
||||
switch_io_event_hook_state_change_t *state_change;
|
||||
};
|
||||
|
||||
/*! \brief A table of i/o routines that an endpoint interface can implement */
|
||||
struct switch_io_routines {
|
||||
/*! creates an outgoing session from given session, caller profile */
|
||||
switch_call_cause_t (*outgoing_channel)(switch_core_session_t *, switch_caller_profile_t *, switch_core_session_t **, switch_memory_pool_t **);
|
||||
switch_call_cause_t (*outgoing_channel) (switch_core_session_t *, switch_caller_profile_t *,
|
||||
switch_core_session_t **, switch_memory_pool_t **);
|
||||
/*! answers the given session's channel */
|
||||
switch_status_t (*answer_channel)(switch_core_session_t *);
|
||||
switch_status_t (*answer_channel) (switch_core_session_t *);
|
||||
/*! read a frame from a session */
|
||||
switch_status_t (*read_frame)(switch_core_session_t *, switch_frame_t **, int, switch_io_flag_t, int);
|
||||
switch_status_t (*read_frame) (switch_core_session_t *, switch_frame_t **, int, switch_io_flag_t, int);
|
||||
/*! write a frame to a session */
|
||||
switch_status_t (*write_frame)(switch_core_session_t *, switch_frame_t *, int, switch_io_flag_t, int);
|
||||
switch_status_t (*write_frame) (switch_core_session_t *, switch_frame_t *, int, switch_io_flag_t, int);
|
||||
/*! send a kill signal to the session's channel */
|
||||
switch_status_t (*kill_channel)(switch_core_session_t *, int);
|
||||
switch_status_t (*kill_channel) (switch_core_session_t *, int);
|
||||
/*! wait for the session's channel to be ready to read audio */
|
||||
switch_status_t (*waitfor_read)(switch_core_session_t *, int, int);
|
||||
switch_status_t (*waitfor_read) (switch_core_session_t *, int, int);
|
||||
/*! wait for the session's channel to be ready to write audio */
|
||||
switch_status_t (*waitfor_write)(switch_core_session_t *, int, int);
|
||||
switch_status_t (*waitfor_write) (switch_core_session_t *, int, int);
|
||||
/*! send a string of DTMF digits to a session's channel */
|
||||
switch_status_t (*send_dtmf)(switch_core_session_t *, char *);
|
||||
/*! receive a message from another session*/
|
||||
switch_status_t (*receive_message)(switch_core_session_t *, switch_core_session_message_t *);
|
||||
/*! queue a message for another session*/
|
||||
switch_status_t (*receive_event)(switch_core_session_t *, switch_event_t *);
|
||||
switch_status_t (*send_dtmf) (switch_core_session_t *, char *);
|
||||
/*! receive a message from another session */
|
||||
switch_status_t (*receive_message) (switch_core_session_t *, switch_core_session_message_t *);
|
||||
/*! queue a message for another session */
|
||||
switch_status_t (*receive_event) (switch_core_session_t *, switch_event_t *);
|
||||
/*! change a sessions channel state */
|
||||
switch_status_t (*state_change)(switch_core_session_t *);
|
||||
switch_status_t (*state_change) (switch_core_session_t *);
|
||||
};
|
||||
|
||||
/*! \brief Abstraction of an module endpoint interface
|
||||
@@ -250,15 +150,15 @@ struct switch_timer_interface {
|
||||
/*! the name of the interface */
|
||||
const char *interface_name;
|
||||
/*! function to allocate the timer */
|
||||
switch_status_t (*timer_init)(switch_timer_t *);
|
||||
switch_status_t (*timer_init) (switch_timer_t *);
|
||||
/*! function to wait for one cycle to pass */
|
||||
switch_status_t (*timer_next)(switch_timer_t *);
|
||||
switch_status_t (*timer_next) (switch_timer_t *);
|
||||
/*! function to step the timer one step */
|
||||
switch_status_t (*timer_step)(switch_timer_t *);
|
||||
switch_status_t (*timer_step) (switch_timer_t *);
|
||||
/*! function to check if the current step has expired */
|
||||
switch_status_t (*timer_check)(switch_timer_t *);
|
||||
switch_status_t (*timer_check) (switch_timer_t *);
|
||||
/*! function to deallocate the timer */
|
||||
switch_status_t (*timer_destroy)(switch_timer_t *);
|
||||
switch_status_t (*timer_destroy) (switch_timer_t *);
|
||||
const struct switch_timer_interface *next;
|
||||
};
|
||||
|
||||
@@ -276,19 +176,19 @@ struct switch_file_interface {
|
||||
/*! the name of the interface */
|
||||
const char *interface_name;
|
||||
/*! function to open the file */
|
||||
switch_status_t (*file_open)(switch_file_handle_t *, char *file_path);
|
||||
switch_status_t (*file_open) (switch_file_handle_t *, char *file_path);
|
||||
/*! function to close the file */
|
||||
switch_status_t (*file_close)(switch_file_handle_t *);
|
||||
switch_status_t (*file_close) (switch_file_handle_t *);
|
||||
/*! function to read from the file */
|
||||
switch_status_t (*file_read)(switch_file_handle_t *, void *data, switch_size_t *len);
|
||||
switch_status_t (*file_read) (switch_file_handle_t *, void *data, switch_size_t *len);
|
||||
/*! function to write from the file */
|
||||
switch_status_t (*file_write)(switch_file_handle_t *, void *data, switch_size_t *len);
|
||||
switch_status_t (*file_write) (switch_file_handle_t *, void *data, switch_size_t *len);
|
||||
/*! function to seek to a certian position in the file */
|
||||
switch_status_t (*file_seek)(switch_file_handle_t *, unsigned int *cur_pos, int64_t samples, int whence);
|
||||
switch_status_t (*file_seek) (switch_file_handle_t *, unsigned int *cur_pos, int64_t samples, int whence);
|
||||
/*! function to set meta data */
|
||||
switch_status_t (*file_set_string)(switch_file_handle_t *fh, switch_audio_col_t col, const char *string);
|
||||
switch_status_t (*file_set_string) (switch_file_handle_t *fh, switch_audio_col_t col, const char *string);
|
||||
/*! function to get meta data */
|
||||
switch_status_t (*file_get_string)(switch_file_handle_t *fh, switch_audio_col_t col, const char **string);
|
||||
switch_status_t (*file_get_string) (switch_file_handle_t *fh, switch_audio_col_t col, const char **string);
|
||||
/*! list of supported file extensions */
|
||||
char **extens;
|
||||
const struct switch_file_interface *next;
|
||||
@@ -316,7 +216,7 @@ struct switch_file_handle {
|
||||
int seekable;
|
||||
/*! the sample count of the file */
|
||||
unsigned int sample_count;
|
||||
/*! the speed of the file playback*/
|
||||
/*! the speed of the file playback */
|
||||
int speed;
|
||||
/*! the handle's memory pool */
|
||||
switch_memory_pool_t *memory_pool;
|
||||
@@ -325,8 +225,8 @@ struct switch_file_handle {
|
||||
char *handler;
|
||||
int64_t pos;
|
||||
switch_buffer_t *audio_buffer;
|
||||
uint32_t thresh;
|
||||
uint32_t silence_hits;
|
||||
uint32_t thresh;
|
||||
uint32_t silence_hits;
|
||||
};
|
||||
|
||||
/*! \brief Abstract interface to an asr module */
|
||||
@@ -334,27 +234,23 @@ struct switch_asr_interface {
|
||||
/*! the name of the interface */
|
||||
const char *interface_name;
|
||||
/*! function to open the asr interface */
|
||||
switch_status_t (*asr_open)(switch_asr_handle_t *ah,
|
||||
char *codec,
|
||||
int rate,
|
||||
char *dest,
|
||||
switch_asr_flag_t *flags);
|
||||
switch_status_t (*asr_open) (switch_asr_handle_t *ah, char *codec, int rate, char *dest, switch_asr_flag_t *flags);
|
||||
/*! function to load a grammar to the asr interface */
|
||||
switch_status_t (*asr_load_grammar)(switch_asr_handle_t *ah, char *grammar, char *path);
|
||||
switch_status_t (*asr_load_grammar) (switch_asr_handle_t *ah, char *grammar, char *path);
|
||||
/*! function to unload a grammar to the asr interface */
|
||||
switch_status_t (*asr_unload_grammar)(switch_asr_handle_t *ah, char *grammar);
|
||||
switch_status_t (*asr_unload_grammar) (switch_asr_handle_t *ah, char *grammar);
|
||||
/*! function to close the asr interface */
|
||||
switch_status_t (*asr_close)(switch_asr_handle_t *ah, switch_asr_flag_t *flags);
|
||||
/*! function to feed audio to the ASR*/
|
||||
switch_status_t (*asr_feed)(switch_asr_handle_t *ah, void *data, unsigned int len, switch_asr_flag_t *flags);
|
||||
/*! function to resume the ASR*/
|
||||
switch_status_t (*asr_resume)(switch_asr_handle_t *ah);
|
||||
/*! function to pause the ASR*/
|
||||
switch_status_t (*asr_pause)(switch_asr_handle_t *ah);
|
||||
/*! function to read results from the ASR*/
|
||||
switch_status_t (*asr_check_results)(switch_asr_handle_t *ah, switch_asr_flag_t *flags);
|
||||
/*! function to read results from the ASR*/
|
||||
switch_status_t (*asr_get_results)(switch_asr_handle_t *ah, char **xmlstr, switch_asr_flag_t *flags);
|
||||
switch_status_t (*asr_close) (switch_asr_handle_t *ah, switch_asr_flag_t *flags);
|
||||
/*! function to feed audio to the ASR */
|
||||
switch_status_t (*asr_feed) (switch_asr_handle_t *ah, void *data, unsigned int len, switch_asr_flag_t *flags);
|
||||
/*! function to resume the ASR */
|
||||
switch_status_t (*asr_resume) (switch_asr_handle_t *ah);
|
||||
/*! function to pause the ASR */
|
||||
switch_status_t (*asr_pause) (switch_asr_handle_t *ah);
|
||||
/*! function to read results from the ASR */
|
||||
switch_status_t (*asr_check_results) (switch_asr_handle_t *ah, switch_asr_flag_t *flags);
|
||||
/*! function to read results from the ASR */
|
||||
switch_status_t (*asr_get_results) (switch_asr_handle_t *ah, char **xmlstr, switch_asr_flag_t *flags);
|
||||
const struct switch_asr_interface *next;
|
||||
};
|
||||
|
||||
@@ -364,11 +260,11 @@ struct switch_asr_handle {
|
||||
const switch_asr_interface_t *asr_interface;
|
||||
/*! flags to control behaviour */
|
||||
uint32_t flags;
|
||||
/*! The Name*/
|
||||
/*! The Name */
|
||||
char *name;
|
||||
/*! The Codec*/
|
||||
/*! The Codec */
|
||||
char *codec;
|
||||
/*! The Rate*/
|
||||
/*! The Rate */
|
||||
uint32_t rate;
|
||||
char *grammar;
|
||||
/*! the handle's memory pool */
|
||||
@@ -382,24 +278,20 @@ struct switch_speech_interface {
|
||||
/*! the name of the interface */
|
||||
const char *interface_name;
|
||||
/*! function to open the speech interface */
|
||||
switch_status_t (*speech_open)(switch_speech_handle_t *sh,
|
||||
char *voice_name,
|
||||
int rate,
|
||||
switch_speech_flag_t *flags);
|
||||
switch_status_t (*speech_open) (switch_speech_handle_t *sh,
|
||||
char *voice_name, int rate, switch_speech_flag_t *flags);
|
||||
/*! function to close the speech interface */
|
||||
switch_status_t (*speech_close)(switch_speech_handle_t *, switch_speech_flag_t *flags);
|
||||
/*! function to feed audio to the ASR*/
|
||||
switch_status_t (*speech_feed_tts)(switch_speech_handle_t *sh, char *text, switch_speech_flag_t *flags);
|
||||
/*! function to read audio from the TTS*/
|
||||
switch_status_t (*speech_read_tts)(switch_speech_handle_t *sh,
|
||||
void *data,
|
||||
switch_size_t *datalen,
|
||||
uint32_t *rate,
|
||||
switch_speech_flag_t *flags);
|
||||
void (*speech_flush_tts)(switch_speech_handle_t *sh);
|
||||
void (*speech_text_param_tts)(switch_speech_handle_t *sh, char *param, char *val);
|
||||
void (*speech_numeric_param_tts)(switch_speech_handle_t *sh, char *param, int val);
|
||||
void (*speech_float_param_tts)(switch_speech_handle_t *sh, char *param, double val);
|
||||
switch_status_t (*speech_close) (switch_speech_handle_t *, switch_speech_flag_t *flags);
|
||||
/*! function to feed audio to the ASR */
|
||||
switch_status_t (*speech_feed_tts) (switch_speech_handle_t *sh, char *text, switch_speech_flag_t *flags);
|
||||
/*! function to read audio from the TTS */
|
||||
switch_status_t (*speech_read_tts) (switch_speech_handle_t *sh,
|
||||
void *data,
|
||||
switch_size_t *datalen, uint32_t * rate, switch_speech_flag_t *flags);
|
||||
void (*speech_flush_tts) (switch_speech_handle_t *sh);
|
||||
void (*speech_text_param_tts) (switch_speech_handle_t *sh, char *param, char *val);
|
||||
void (*speech_numeric_param_tts) (switch_speech_handle_t *sh, char *param, int val);
|
||||
void (*speech_float_param_tts) (switch_speech_handle_t *sh, char *param, double val);
|
||||
|
||||
const struct switch_speech_interface *next;
|
||||
};
|
||||
@@ -411,9 +303,9 @@ struct switch_speech_handle {
|
||||
const switch_speech_interface_t *speech_interface;
|
||||
/*! flags to control behaviour */
|
||||
uint32_t flags;
|
||||
/*! The Name*/
|
||||
/*! The Name */
|
||||
char *name;
|
||||
/*! The Rate*/
|
||||
/*! The Rate */
|
||||
uint32_t rate;
|
||||
uint32_t speed;
|
||||
char voice[80];
|
||||
@@ -429,7 +321,7 @@ struct switch_say_interface {
|
||||
/*! the name of the interface */
|
||||
const char *interface_name;
|
||||
/*! function to pass down to the module */
|
||||
switch_say_callback_t say_function;
|
||||
switch_say_callback_t say_function;
|
||||
const struct switch_say_interface *next;
|
||||
};
|
||||
|
||||
@@ -438,7 +330,7 @@ struct switch_chat_interface {
|
||||
/*! the name of the interface */
|
||||
const char *interface_name;
|
||||
/*! function to open the directory interface */
|
||||
switch_status_t (*chat_send)(char *proto, char *from, char *to, char *subject, char *body, char *hint);
|
||||
switch_status_t (*chat_send) (char *proto, char *from, char *to, char *subject, char *body, char *hint);
|
||||
const struct switch_chat_interface *next;
|
||||
};
|
||||
|
||||
@@ -447,7 +339,8 @@ struct switch_management_interface {
|
||||
/*! the name of the interface */
|
||||
const char *relative_oid;
|
||||
/*! function to open the directory interface */
|
||||
switch_status_t (*management_function)(char *relative_oid, switch_management_action_t action, char *data, switch_size_t datalen);
|
||||
switch_status_t (*management_function) (char *relative_oid, switch_management_action_t action, char *data,
|
||||
switch_size_t datalen);
|
||||
const struct switch_management_interface *next;
|
||||
};
|
||||
|
||||
@@ -456,16 +349,16 @@ struct switch_directory_interface {
|
||||
/*! the name of the interface */
|
||||
const char *interface_name;
|
||||
/*! function to open the directory interface */
|
||||
switch_status_t (*directory_open)(switch_directory_handle_t *dh, char *source, char *dsn, char *passwd);
|
||||
switch_status_t (*directory_open) (switch_directory_handle_t *dh, char *source, char *dsn, char *passwd);
|
||||
/*! function to close the directory interface */
|
||||
switch_status_t (*directory_close)(switch_directory_handle_t *dh);
|
||||
switch_status_t (*directory_close) (switch_directory_handle_t *dh);
|
||||
/*! function to query the directory interface */
|
||||
switch_status_t (*directory_query)(switch_directory_handle_t *dh, char *base, char *query);
|
||||
switch_status_t (*directory_query) (switch_directory_handle_t *dh, char *base, char *query);
|
||||
/*! function to advance to the next record */
|
||||
switch_status_t (*directory_next)(switch_directory_handle_t *dh);
|
||||
switch_status_t (*directory_next) (switch_directory_handle_t *dh);
|
||||
/*! function to advance to the next name/value pair in the current record */
|
||||
switch_status_t (*directory_next_pair)(switch_directory_handle_t *dh, char **var, char **val);
|
||||
|
||||
switch_status_t (*directory_next_pair) (switch_directory_handle_t *dh, char **var, char **val);
|
||||
|
||||
const struct switch_directory_interface *next;
|
||||
};
|
||||
|
||||
@@ -534,7 +427,7 @@ struct switch_codec {
|
||||
switch_codec_settings_t codec_settings;
|
||||
/*! flags to modify behaviour */
|
||||
uint32_t flags;
|
||||
/*! the handle's memory pool*/
|
||||
/*! the handle's memory pool */
|
||||
switch_memory_pool_t *memory_pool;
|
||||
/*! private data for the codec module to store handle specific info */
|
||||
void *private_info;
|
||||
@@ -569,29 +462,25 @@ struct switch_codec_implementation {
|
||||
/*! max number of frames to send in one network packet */
|
||||
int max_frames_per_packet;
|
||||
/*! function to initialize a codec handle using this implementation */
|
||||
switch_status_t (*init)(switch_codec_t *, switch_codec_flag_t, const switch_codec_settings_t *codec_settings);
|
||||
switch_status_t (*init) (switch_codec_t *, switch_codec_flag_t, const switch_codec_settings_t *codec_settings);
|
||||
/*! function to encode raw data into encoded data */
|
||||
switch_status_t (*encode)(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *decoded_data,
|
||||
uint32_t decoded_data_len,
|
||||
uint32_t decoded_rate,
|
||||
void *encoded_data,
|
||||
uint32_t *encoded_data_len,
|
||||
uint32_t *encoded_rate,
|
||||
unsigned int *flag);
|
||||
switch_status_t (*encode) (switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *decoded_data,
|
||||
uint32_t decoded_data_len,
|
||||
uint32_t decoded_rate,
|
||||
void *encoded_data,
|
||||
uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag);
|
||||
/*! function to decode encoded data into raw data */
|
||||
switch_status_t (*decode)(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *encoded_data,
|
||||
uint32_t encoded_data_len,
|
||||
uint32_t encoded_rate,
|
||||
void *decoded_data,
|
||||
uint32_t *decoded_data_len,
|
||||
uint32_t *decoded_rate,
|
||||
unsigned int *flag);
|
||||
switch_status_t (*decode) (switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *encoded_data,
|
||||
uint32_t encoded_data_len,
|
||||
uint32_t encoded_rate,
|
||||
void *decoded_data,
|
||||
uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag);
|
||||
/*! deinitalize a codec handle using this implementation */
|
||||
switch_status_t (*destroy)(switch_codec_t *);
|
||||
switch_status_t (*destroy) (switch_codec_t *);
|
||||
const struct switch_codec_implementation *next;
|
||||
};
|
||||
|
||||
@@ -635,9 +524,7 @@ struct switch_api_interface {
|
||||
};
|
||||
|
||||
SWITCH_END_EXTERN_C
|
||||
|
||||
#endif
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
|
||||
@@ -35,23 +35,17 @@
|
||||
#define SWITCH_PLATFORM_H
|
||||
|
||||
SWITCH_BEGIN_EXTERN_C
|
||||
|
||||
#ifdef __ICC
|
||||
#pragma warning (disable:810 869 981 279 1469 188)
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define SWITCH_VA_NONE "%s", ""
|
||||
#ifdef _MSC_VER
|
||||
#define __SWITCH_FUNC__ __FUNCTION__
|
||||
#else
|
||||
#define __SWITCH_FUNC__ (const char *)__func__
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
|
||||
/* disable the following warnings
|
||||
* C4100: The formal parameter is not referenced in the body of the function. The unreferenced parameter is ignored.
|
||||
* C4200: Non standard extension C zero sized array
|
||||
@@ -64,8 +58,7 @@ SWITCH_BEGIN_EXTERN_C
|
||||
* C4610: struct can never be instantiated - user defined constructor required
|
||||
*/
|
||||
#pragma warning(disable:4100 4200 4204 4706 4819 4132 4510 4512 4610 4996)
|
||||
|
||||
#if (_MSC_VER >= 1400) // VC8+
|
||||
#if (_MSC_VER >= 1400) // VC8+
|
||||
#ifndef _CRT_SECURE_NO_DEPRECATE
|
||||
#define _CRT_SECURE_NO_DEPRECATE
|
||||
#endif
|
||||
@@ -73,30 +66,27 @@ SWITCH_BEGIN_EXTERN_C
|
||||
#define _CRT_NONSTDC_NO_DEPRECATE
|
||||
#endif
|
||||
#endif // VC8+
|
||||
|
||||
#if _MSC_VER < 1300
|
||||
#ifndef __FUNCTION__
|
||||
#define __FUNCTION__ ""
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#undef inline
|
||||
#define inline __inline
|
||||
|
||||
#ifndef uint32_t
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
typedef __int8 int8_t;
|
||||
typedef __int16 int16_t;
|
||||
typedef __int32 int32_t;
|
||||
typedef __int64 int64_t;
|
||||
typedef unsigned long in_addr_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
typedef __int8 int8_t;
|
||||
typedef __int16 int16_t;
|
||||
typedef __int32 int32_t;
|
||||
typedef __int64 int64_t;
|
||||
typedef unsigned long in_addr_t;
|
||||
#endif
|
||||
typedef int pid_t;
|
||||
typedef int uid_t;
|
||||
typedef int gid_t;
|
||||
typedef int pid_t;
|
||||
typedef int uid_t;
|
||||
typedef int gid_t;
|
||||
#define PACKED
|
||||
#include <io.h>
|
||||
#define strcasecmp(s1, s2) stricmp(s1, s2)
|
||||
@@ -116,7 +106,6 @@ typedef int gid_t;
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#endif // _MSC_VER
|
||||
|
||||
#ifndef __LITTLE_ENDIAN
|
||||
#define __LITTLE_ENDIAN 1234
|
||||
#endif
|
||||
@@ -130,9 +119,7 @@ typedef int gid_t;
|
||||
#define __BYTE_ORDER __LITTLE_ENDIAN
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
#if defined(SWITCH_CORE_DECLARE_STATIC)
|
||||
#define SWITCH_DECLARE(type) type __stdcall
|
||||
#define SWITCH_DECLARE_NONSTD(type) type __cdecl
|
||||
@@ -146,7 +133,6 @@ typedef int gid_t;
|
||||
#define SWITCH_DECLARE_NONSTD(type) __declspec(dllimport) type __cdecl
|
||||
#define SWITCH_DECLARE_DATA __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#if defined(SWITCH_MOD_DECLARE_STATIC)
|
||||
#define SWITCH_MOD_DECLARE(type) type __cdecl
|
||||
#elif defined(MOD_EXPORTS)
|
||||
@@ -169,35 +155,32 @@ typedef int gid_t;
|
||||
#define SWITCH_DECLARE_DATA
|
||||
#define SWITCH_THREAD_FUNC
|
||||
#endif
|
||||
|
||||
#ifdef DOXYGEN
|
||||
#define DoxyDefine(x) x
|
||||
#else
|
||||
#define DoxyDefine(x)
|
||||
#endif
|
||||
|
||||
#if __GNUC__ >= 3
|
||||
#define PRINTF_FUNCTION(fmtstr,vars) __attribute__((format(printf,fmtstr,vars)))
|
||||
#else
|
||||
#define PRINTF_FUNCTION(fmtstr,vars)
|
||||
#endif
|
||||
|
||||
#ifdef SWITCH_INT32
|
||||
typedef SWITCH_INT32 switch_int32_t;
|
||||
typedef SWITCH_INT32 switch_int32_t;
|
||||
#else
|
||||
typedef int32_t switch_int32_t;
|
||||
typedef int32_t switch_int32_t;
|
||||
#endif
|
||||
|
||||
#ifdef SWITCH_SIZE_T
|
||||
typedef SWITCH_SIZE_T switch_size_t;
|
||||
typedef SWITCH_SIZE_T switch_size_t;
|
||||
#else
|
||||
typedef uintptr_t switch_size_t;
|
||||
typedef uintptr_t switch_size_t;
|
||||
#endif
|
||||
|
||||
#ifdef SWITCH_SSIZE_T
|
||||
typedef SWITCH_SSIZE_T switch_ssize_t;
|
||||
typedef SWITCH_SSIZE_T switch_ssize_t;
|
||||
#else
|
||||
typedef intptr_t switch_ssize_t;
|
||||
typedef intptr_t switch_ssize_t;
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
@@ -245,7 +228,6 @@ typedef intptr_t switch_ssize_t;
|
||||
#define SWITCH_TIME_T_FMT SWITCH_INT64_T_FMT
|
||||
|
||||
SWITCH_END_EXTERN_C
|
||||
|
||||
/* these includes must be outside the extern "C" block on windows or it will break compatibility with c++ modules*/
|
||||
#ifdef WIN32
|
||||
/* Has windows.h already been included? If so, our preferences don't matter,
|
||||
@@ -257,7 +239,6 @@ SWITCH_END_EXTERN_C
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#ifndef _WIN32_WINNT
|
||||
|
||||
/* Restrict the server to a subset of Windows NT 4.0 header files by default
|
||||
*/
|
||||
#define _WIN32_WINNT 0x0400
|
||||
@@ -288,19 +269,13 @@ SWITCH_END_EXTERN_C
|
||||
#endif /* !_WINDOWS_ */
|
||||
#include <process.h>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
#ifndef TRUE
|
||||
#define TRUE (!FALSE)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
|
||||
@@ -35,32 +35,28 @@
|
||||
#define SWITCH_REGEX_H
|
||||
|
||||
SWITCH_BEGIN_EXTERN_C
|
||||
|
||||
/**
|
||||
* @defgroup switch_regex
|
||||
* @ingroup FREESWITCH
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef struct real_pcre switch_regex_t;
|
||||
typedef struct real_pcre switch_regex_t;
|
||||
|
||||
SWITCH_DECLARE(switch_regex_t *) switch_regex_compile(const char *pattern,
|
||||
int options,
|
||||
const char **errorptr,
|
||||
int *erroroffset,
|
||||
const unsigned char *tables);
|
||||
int *erroroffset, const unsigned char *tables);
|
||||
|
||||
SWITCH_DECLARE(int) switch_regex_copy_substring(const char *subject,
|
||||
int *ovector,
|
||||
int stringcount,
|
||||
int stringnumber,
|
||||
char *buffer,
|
||||
int size);
|
||||
int stringcount, int stringnumber, char *buffer, int size);
|
||||
|
||||
SWITCH_DECLARE(void) switch_regex_free(void *data);
|
||||
|
||||
SWITCH_DECLARE(int) switch_regex_perform(char *field, char *expression, switch_regex_t **new_re, int *ovector, uint32_t olen);
|
||||
SWITCH_DECLARE(void) switch_perform_substitution(switch_regex_t *re, int match_count, char *data, char *field_data, char *substituted, uint32_t len, int *ovector);
|
||||
SWITCH_DECLARE(int) switch_regex_perform(char *field, char *expression, switch_regex_t **new_re, int *ovector,
|
||||
uint32_t olen);
|
||||
SWITCH_DECLARE(void) switch_perform_substitution(switch_regex_t *re, int match_count, char *data, char *field_data,
|
||||
char *substituted, uint32_t len, int *ovector);
|
||||
|
||||
/*!
|
||||
\brief Function to evaluate an expression against a string
|
||||
@@ -78,9 +74,7 @@ SWITCH_DECLARE(switch_status_t) switch_regex_match(char *target, char *expressio
|
||||
/** @} */
|
||||
|
||||
SWITCH_END_EXTERN_C
|
||||
|
||||
#endif
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
|
||||
@@ -45,15 +45,13 @@
|
||||
|
||||
#include <switch.h>
|
||||
SWITCH_BEGIN_EXTERN_C
|
||||
|
||||
/*!
|
||||
\defgroup resamp Audio Resample Functions
|
||||
\ingroup core1
|
||||
\{
|
||||
*/
|
||||
|
||||
/*! \brief An audio resampling handle */
|
||||
typedef struct {
|
||||
typedef struct {
|
||||
/*! a pointer to store the resampler object */
|
||||
void *resampler;
|
||||
/*! the rate to resample from in hz */
|
||||
@@ -87,11 +85,9 @@ typedef struct {
|
||||
\return SWITCH_STATUS_SUCCESS if the handle was created
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_resample_create(switch_audio_resampler_t **new_resampler,
|
||||
int from_rate,
|
||||
switch_size_t from_size,
|
||||
int to_rate,
|
||||
uint32_t to_size,
|
||||
switch_memory_pool_t *pool);
|
||||
int from_rate,
|
||||
switch_size_t from_size,
|
||||
int to_rate, uint32_t to_size, switch_memory_pool_t *pool);
|
||||
|
||||
/*!
|
||||
\brief Destroy an existing resampler handle
|
||||
@@ -109,7 +105,8 @@ SWITCH_DECLARE(void) switch_resample_destroy(switch_audio_resampler_t *resampler
|
||||
\param last parameter denoting the last sample is being resampled
|
||||
\return the used size of dst
|
||||
*/
|
||||
SWITCH_DECLARE(uint32_t) switch_resample_process(switch_audio_resampler_t *resampler, float *src, int srclen, float *dst, uint32_t dstlen, int last);
|
||||
SWITCH_DECLARE(uint32_t) switch_resample_process(switch_audio_resampler_t *resampler, float *src, int srclen,
|
||||
float *dst, uint32_t dstlen, int last);
|
||||
|
||||
/*!
|
||||
\brief Convert an array of floats to an array of shorts
|
||||
@@ -172,9 +169,7 @@ SWITCH_DECLARE(void) switch_change_sln_volume(int16_t *data, uint32_t samples, i
|
||||
///\}
|
||||
|
||||
SWITCH_END_EXTERN_C
|
||||
|
||||
#endif
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
|
||||
+37
-45
@@ -39,17 +39,13 @@
|
||||
#define SWITCH_RTP_H
|
||||
|
||||
SWITCH_BEGIN_EXTERN_C
|
||||
|
||||
#define SWITCH_RTP_MAX_BUF_LEN 16384
|
||||
|
||||
///\defgroup rtp RTP (RealTime Transport Protocol)
|
||||
///\ingroup core1
|
||||
///\{
|
||||
typedef void (*switch_rtp_invalid_handler_t)(switch_rtp_t *rtp_session,
|
||||
switch_socket_t *sock,
|
||||
void *data,
|
||||
switch_size_t datalen,
|
||||
switch_sockaddr_t *from_addr);
|
||||
typedef void (*switch_rtp_invalid_handler_t) (switch_rtp_t *rtp_session,
|
||||
switch_socket_t *sock,
|
||||
void *data, switch_size_t datalen, switch_sockaddr_t *from_addr);
|
||||
|
||||
/*!
|
||||
\brief Initilize the RTP System
|
||||
@@ -77,15 +73,13 @@ SWITCH_DECLARE(switch_port_t) switch_rtp_request_port(void);
|
||||
\param pool a memory pool to use for the session
|
||||
\return the new RTP session or NULL on failure
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t)switch_rtp_create(switch_rtp_t **new_rtp_session,
|
||||
switch_payload_t payload,
|
||||
uint32_t samples_per_interval,
|
||||
uint32_t ms_per_packet,
|
||||
switch_rtp_flag_t flags,
|
||||
char *crypto_key,
|
||||
char *timer_name,
|
||||
const char **err,
|
||||
switch_memory_pool_t *pool);
|
||||
SWITCH_DECLARE(switch_status_t) switch_rtp_create(switch_rtp_t **new_rtp_session,
|
||||
switch_payload_t payload,
|
||||
uint32_t samples_per_interval,
|
||||
uint32_t ms_per_packet,
|
||||
switch_rtp_flag_t flags,
|
||||
char *crypto_key,
|
||||
char *timer_name, const char **err, switch_memory_pool_t *pool);
|
||||
|
||||
|
||||
/*!
|
||||
@@ -104,18 +98,16 @@ SWITCH_DECLARE(switch_status_t)switch_rtp_create(switch_rtp_t **new_rtp_session,
|
||||
\param pool a memory pool to use for the session
|
||||
\return the new RTP session or NULL on failure
|
||||
*/
|
||||
SWITCH_DECLARE(switch_rtp_t *)switch_rtp_new(char *rx_host,
|
||||
switch_port_t rx_port,
|
||||
char *tx_host,
|
||||
switch_port_t tx_port,
|
||||
switch_payload_t payload,
|
||||
uint32_t samples_per_interval,
|
||||
uint32_t ms_per_packet,
|
||||
switch_rtp_flag_t flags,
|
||||
char *crypto_key,
|
||||
char *timer_name,
|
||||
const char **err,
|
||||
switch_memory_pool_t *pool);
|
||||
SWITCH_DECLARE(switch_rtp_t *) switch_rtp_new(char *rx_host,
|
||||
switch_port_t rx_port,
|
||||
char *tx_host,
|
||||
switch_port_t tx_port,
|
||||
switch_payload_t payload,
|
||||
uint32_t samples_per_interval,
|
||||
uint32_t ms_per_packet,
|
||||
switch_rtp_flag_t flags,
|
||||
char *crypto_key,
|
||||
char *timer_name, const char **err, switch_memory_pool_t *pool);
|
||||
|
||||
|
||||
/*!
|
||||
@@ -125,7 +117,8 @@ SWITCH_DECLARE(switch_rtp_t *)switch_rtp_new(char *rx_host,
|
||||
\param port the remote port
|
||||
\param err pointer for error messages
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_rtp_set_remote_address(switch_rtp_t *rtp_session, char *host, switch_port_t port, const char **err);
|
||||
SWITCH_DECLARE(switch_status_t) switch_rtp_set_remote_address(switch_rtp_t *rtp_session, char *host, switch_port_t port,
|
||||
const char **err);
|
||||
|
||||
/*!
|
||||
\brief Assign a local address to the RTP session
|
||||
@@ -135,7 +128,8 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_set_remote_address(switch_rtp_t *rtp_
|
||||
\param err pointer for error messages
|
||||
\note this call also binds the RTP session's socket to the new address
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_rtp_set_local_address(switch_rtp_t *rtp_session, char *host, switch_port_t port, const char **err);
|
||||
SWITCH_DECLARE(switch_status_t) switch_rtp_set_local_address(switch_rtp_t *rtp_session, char *host, switch_port_t port,
|
||||
const char **err);
|
||||
|
||||
/*!
|
||||
\brief Kill the socket on an existing RTP session
|
||||
@@ -189,14 +183,15 @@ SWITCH_DECLARE(void) switch_rtp_clear_flag(switch_rtp_t *rtp_session, switch_rtp
|
||||
\param rtp_session the RTP session to retrieve the socket from
|
||||
\return the socket from the RTP session
|
||||
*/
|
||||
SWITCH_DECLARE(switch_socket_t *)switch_rtp_get_rtp_socket(switch_rtp_t *rtp_session);
|
||||
SWITCH_DECLARE(switch_socket_t *) switch_rtp_get_rtp_socket(switch_rtp_t *rtp_session);
|
||||
|
||||
/*!
|
||||
\brief Set the default samples per interval for a given RTP session
|
||||
\param rtp_session the RTP session to set the samples per interval on
|
||||
\param samples_per_interval the new default samples per interval
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_rtp_set_default_samples_per_interval(switch_rtp_t *rtp_session, uint16_t samples_per_interval);
|
||||
SWITCH_DECLARE(void) switch_rtp_set_default_samples_per_interval(switch_rtp_t *rtp_session,
|
||||
uint16_t samples_per_interval);
|
||||
|
||||
/*!
|
||||
\brief Get the default samples per interval for a given RTP session
|
||||
@@ -237,7 +232,8 @@ SWITCH_DECLARE(void) switch_rtp_set_invald_handler(switch_rtp_t *rtp_session, sw
|
||||
\param flags flags
|
||||
\return the number of bytes read
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_rtp_read(switch_rtp_t *rtp_session, void *data, uint32_t *datalen, switch_payload_t *payload_type, switch_frame_flag_t *flags);
|
||||
SWITCH_DECLARE(switch_status_t) switch_rtp_read(switch_rtp_t *rtp_session, void *data, uint32_t * datalen,
|
||||
switch_payload_t *payload_type, switch_frame_flag_t *flags);
|
||||
|
||||
/*!
|
||||
\brief Queue RFC2833 DTMF data into an RTP Session
|
||||
@@ -282,9 +278,8 @@ SWITCH_DECLARE(switch_size_t) switch_rtp_dequeue_dtmf(switch_rtp_t *rtp_session,
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_rtp_zerocopy_read(switch_rtp_t *rtp_session,
|
||||
void **data,
|
||||
uint32_t *datalen,
|
||||
switch_payload_t *payload_type,
|
||||
switch_frame_flag_t *flags);
|
||||
uint32_t * datalen,
|
||||
switch_payload_t *payload_type, switch_frame_flag_t *flags);
|
||||
|
||||
/*!
|
||||
\brief Read data from a given RTP session without copying
|
||||
@@ -303,7 +298,8 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_zerocopy_read_frame(switch_rtp_t *rtp
|
||||
\param flags frame flags
|
||||
\return the number of bytes written
|
||||
*/
|
||||
SWITCH_DECLARE(int) switch_rtp_write(switch_rtp_t *rtp_session, void *data, uint32_t datalen, uint32_t ts, switch_frame_flag_t *flags);
|
||||
SWITCH_DECLARE(int) switch_rtp_write(switch_rtp_t *rtp_session, void *data, uint32_t datalen, uint32_t ts,
|
||||
switch_frame_flag_t *flags);
|
||||
|
||||
/*!
|
||||
\brief Enable VAD on an RTP Session
|
||||
@@ -313,7 +309,8 @@ SWITCH_DECLARE(int) switch_rtp_write(switch_rtp_t *rtp_session, void *data, uint
|
||||
\param flags flags for control
|
||||
\return SWITCH_STAUTS_SUCCESS on success
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_rtp_enable_vad(switch_rtp_t *rtp_session, switch_core_session_t *session, switch_codec_t *codec, switch_vad_flag_t flags);
|
||||
SWITCH_DECLARE(switch_status_t) switch_rtp_enable_vad(switch_rtp_t *rtp_session, switch_core_session_t *session,
|
||||
switch_codec_t *codec, switch_vad_flag_t flags);
|
||||
|
||||
/*!
|
||||
\brief Disable VAD on an RTP Session
|
||||
@@ -349,10 +346,7 @@ SWITCH_DECLARE(int) switch_rtp_write_manual(switch_rtp_t *rtp_session,
|
||||
uint16_t datalen,
|
||||
uint8_t m,
|
||||
switch_payload_t payload,
|
||||
uint32_t ts,
|
||||
uint16_t mseq,
|
||||
uint32_t ssrc,
|
||||
switch_frame_flag_t *flags);
|
||||
uint32_t ts, uint16_t mseq, uint32_t ssrc, switch_frame_flag_t *flags);
|
||||
|
||||
/*!
|
||||
\brief Retrieve the SSRC from a given RTP session
|
||||
@@ -387,16 +381,14 @@ SWITCH_DECLARE(void) switch_rtp_set_cng_pt(switch_rtp_t *rtp_session, switch_pay
|
||||
\param rtp_session the RTP session to retrieve the data from
|
||||
\return the pointer to the private data
|
||||
*/
|
||||
SWITCH_DECLARE(void *)switch_rtp_get_private(switch_rtp_t *rtp_session);
|
||||
SWITCH_DECLARE(void *) switch_rtp_get_private(switch_rtp_t *rtp_session);
|
||||
|
||||
/*!
|
||||
\}
|
||||
*/
|
||||
|
||||
SWITCH_END_EXTERN_C
|
||||
|
||||
#endif
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
|
||||
+120
-228
@@ -36,26 +36,22 @@
|
||||
#define SWITCH_SQLITE_H
|
||||
|
||||
SWITCH_BEGIN_EXTERN_C
|
||||
|
||||
#include <sqlite3.h>
|
||||
|
||||
/**
|
||||
* @defgroup switch_sqlite_top Brought To You By SQLite
|
||||
* @ingroup FREESWITCH
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup switch_sqlite Database Routines
|
||||
* @ingroup switch_sqlite_top
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Each open sqlite database is represented by an instance of the
|
||||
* following opaque structure.
|
||||
*/
|
||||
typedef sqlite3 switch_core_db_t;
|
||||
typedef sqlite3 switch_core_db_t;
|
||||
typedef sqlite3_stmt switch_core_db_stmt_t;
|
||||
/**
|
||||
* Aggregate functions use the following routine to allocate
|
||||
@@ -67,17 +63,15 @@ typedef sqlite3_stmt switch_core_db_stmt_t;
|
||||
*
|
||||
* The buffer allocated is freed automatically by SQLite.
|
||||
*/
|
||||
DoxyDefine(void *switch_core_db_aggregate_context(sqlite3_context*, int nBytes);)
|
||||
DoxyDefine(void *switch_core_db_aggregate_context(sqlite3_context *, int nBytes);)
|
||||
#define switch_core_db_aggregate_context sqlite3_aggregate_context
|
||||
|
||||
/**
|
||||
* /return the number of calls to xStep for a particular
|
||||
* aggregate function instance. The current call to xStep counts so this
|
||||
* routine always returns at least 1.
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_aggregate_count(sqlite3_context*);)
|
||||
DoxyDefine(int switch_core_db_aggregate_count(sqlite3_context *);)
|
||||
#define switch_core_db_aggregate_count sqlite3_aggregate_count
|
||||
|
||||
/**
|
||||
* In the SQL strings input to switch_core_db_prepare(),
|
||||
* one or more literals can be replace by parameters "?" or ":AAA" or
|
||||
@@ -106,9 +100,8 @@ DoxyDefine(int switch_core_db_aggregate_count(sqlite3_context*);)
|
||||
* an switch_core_db_prepare() or sqlite3_reset(). Unbound parameterss are
|
||||
* interpreted as NULL.
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));)
|
||||
DoxyDefine(int switch_core_db_bind_blob(sqlite3_stmt *, int, const void *, int n, void (*)(void *));)
|
||||
#define switch_core_db_bind_blob sqlite3_bind_blob
|
||||
|
||||
/**
|
||||
* In the SQL strings input to switch_core_db_prepare(),
|
||||
* one or more literals can be replace by parameters "?" or ":AAA" or
|
||||
@@ -129,9 +122,8 @@ DoxyDefine(int switch_core_db_bind_blob(sqlite3_stmt*, int, const void*, int n,
|
||||
* an switch_core_db_prepare() or sqlite3_reset(). Unbound parameterss are
|
||||
* interpreted as NULL.
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_bind_double(sqlite3_stmt*, int, double);)
|
||||
DoxyDefine(int switch_core_db_bind_double(sqlite3_stmt *, int, double);)
|
||||
#define switch_core_db_bind_double sqlite3_bind_double
|
||||
|
||||
/**
|
||||
* In the SQL strings input to switch_core_db_prepare(),
|
||||
* one or more literals can be replace by parameters "?" or ":AAA" or
|
||||
@@ -152,9 +144,8 @@ DoxyDefine(int switch_core_db_bind_double(sqlite3_stmt*, int, double);)
|
||||
* an switch_core_db_prepare() or sqlite3_reset(). Unbound parameterss are
|
||||
* interpreted as NULL.
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_bind_int(sqlite3_stmt*, int, int);)
|
||||
DoxyDefine(int switch_core_db_bind_int(sqlite3_stmt *, int, int);)
|
||||
#define switch_core_db_bind_int sqlite3_bind_int
|
||||
|
||||
/**
|
||||
* In the SQL strings input to switch_core_db_prepare(),
|
||||
* one or more literals can be replace by parameters "?" or ":AAA" or
|
||||
@@ -175,9 +166,8 @@ DoxyDefine(int switch_core_db_bind_int(sqlite3_stmt*, int, int);)
|
||||
* an switch_core_db_prepare() or sqlite3_reset(). Unbound parameterss are
|
||||
* interpreted as NULL.
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_bind_int64(sqlite3_stmt*, int, sqlite_int64);)
|
||||
DoxyDefine(int switch_core_db_bind_int64(sqlite3_stmt *, int, sqlite_int64);)
|
||||
#define switch_core_db_bind_int64 sqlite3_bind_int64
|
||||
|
||||
/**
|
||||
* In the SQL strings input to switch_core_db_prepare(),
|
||||
* one or more literals can be replace by parameters "?" or ":AAA" or
|
||||
@@ -198,9 +188,8 @@ DoxyDefine(int switch_core_db_bind_int64(sqlite3_stmt*, int, sqlite_int64);)
|
||||
* an switch_core_db_prepare() or sqlite3_reset(). Unbound parameterss are
|
||||
* interpreted as NULL.
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_bind_null(sqlite3_stmt*, int);)
|
||||
DoxyDefine(int switch_core_db_bind_null(sqlite3_stmt *, int);)
|
||||
#define switch_core_db_bind_null sqlite3_bind_null
|
||||
|
||||
/**
|
||||
* In the SQL strings input to switch_core_db_prepare(),
|
||||
* one or more literals can be replace by parameters "?" or ":AAA" or
|
||||
@@ -229,9 +218,8 @@ DoxyDefine(int switch_core_db_bind_null(sqlite3_stmt*, int);)
|
||||
* an switch_core_db_prepare() or sqlite3_reset(). Unbound parameterss are
|
||||
* interpreted as NULL.
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_bind_text(sqlite3_stmt*, int, const char*, int n, void(*)(void*));)
|
||||
DoxyDefine(int switch_core_db_bind_text(sqlite3_stmt *, int, const char *, int n, void (*)(void *));)
|
||||
#define switch_core_db_bind_text sqlite3_bind_text
|
||||
|
||||
/**
|
||||
* In the SQL strings input to switch_core_db_prepare(),
|
||||
* one or more literals can be replace by parameters "?" or ":AAA" or
|
||||
@@ -260,9 +248,8 @@ DoxyDefine(int switch_core_db_bind_text(sqlite3_stmt*, int, const char*, int n,
|
||||
* an switch_core_db_prepare() or sqlite3_reset(). Unbound parameterss are
|
||||
* interpreted as NULL.
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));)
|
||||
DoxyDefine(int switch_core_db_bind_text16(sqlite3_stmt *, int, const void *, int, void (*)(void *));)
|
||||
#define switch_core_db_bind_text16 sqlite3_bind_text16
|
||||
|
||||
/**
|
||||
* In the SQL strings input to switch_core_db_prepare(),
|
||||
* one or more literals can be replace by parameters "?" or ":AAA" or
|
||||
@@ -283,24 +270,21 @@ DoxyDefine(int switch_core_db_bind_text16(sqlite3_stmt*, int, const void*, int,
|
||||
* an switch_core_db_prepare() or sqlite3_reset(). Unbound parameterss are
|
||||
* interpreted as NULL.
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_bind_value(sqlite3_stmt*, int, const sqlite3_value*);)
|
||||
DoxyDefine(int switch_core_db_bind_value(sqlite3_stmt *, int, const sqlite3_value *);)
|
||||
#define switch_core_db_bind_value sqlite3_bind_value
|
||||
|
||||
/**
|
||||
* @return The number of parameters in a compiled SQL statement.
|
||||
* @remark This routine was added to support DBD::SQLite.
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_bind_parameter_count(sqlite3_stmt*);)
|
||||
DoxyDefine(int switch_core_db_bind_parameter_count(sqlite3_stmt *);)
|
||||
#define switch_core_db_bind_parameter_count sqlite3_bind_parameter_count
|
||||
|
||||
/**
|
||||
* @return the index of a parameter with the given name. If no parameter with the
|
||||
* given name is found, return 0.
|
||||
* @remark The name must match exactly.
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_bind_parameter_index(sqlite3_stmt*, const char *zName);)
|
||||
DoxyDefine(int switch_core_db_bind_parameter_index(sqlite3_stmt *, const char *zName);)
|
||||
#define switch_core_db_bind_parameter_index sqlite3_bind_parameter_index
|
||||
|
||||
/**
|
||||
* @return the name of the i-th parameter.
|
||||
* @remark Ordinary parameters "?" are
|
||||
@@ -308,9 +292,8 @@ DoxyDefine(int switch_core_db_bind_parameter_index(sqlite3_stmt*, const char *zN
|
||||
* $VVV the complete text of the parameter name is returned, including
|
||||
* the initial ":" or "$". NULL is returned if the index is out of range.
|
||||
*/
|
||||
DoxyDefine(const char *switch_core_db_bind_parameter_name(sqlite3_stmt*, int);)
|
||||
DoxyDefine(const char *switch_core_db_bind_parameter_name(sqlite3_stmt *, int);)
|
||||
#define switch_core_db_bind_parameter_name sqlite3_bind_parameter_name
|
||||
|
||||
/**
|
||||
* This routine identifies a callback function that is invoked
|
||||
* whenever an attempt is made to open a database table that is
|
||||
@@ -333,9 +316,8 @@ DoxyDefine(const char *switch_core_db_bind_parameter_name(sqlite3_stmt*, int);)
|
||||
* data structures out from under the executing query and will
|
||||
* probably result in a coredump.
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_busy_handler(switch_core_db*, int(*)(void*,int), void*);)
|
||||
DoxyDefine(int switch_core_db_busy_handler(switch_core_db *, int (*)(void *, int), void *);)
|
||||
#define switch_core_db_busy_handler sqlite3_busy_handler
|
||||
|
||||
/**
|
||||
* This routine sets a busy handler that sleeps for a while when a
|
||||
* table is locked. The handler will sleep multiple times until
|
||||
@@ -346,9 +328,8 @@ DoxyDefine(int switch_core_db_busy_handler(switch_core_db*, int(*)(void*,int), v
|
||||
* Calling this routine with an argument less than or equal to zero
|
||||
* turns off all busy handlers.
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_busy_timeout(switch_core_db*, int ms);)
|
||||
DoxyDefine(int switch_core_db_busy_timeout(switch_core_db *, int ms);)
|
||||
#define switch_core_db_busy_timeout sqlite3_busy_timeout
|
||||
|
||||
/**
|
||||
* This function returns the number of database rows that were changed
|
||||
* (or inserted or deleted) by the most recent called sqlite3_exec().
|
||||
@@ -369,9 +350,8 @@ DoxyDefine(int switch_core_db_busy_timeout(switch_core_db*, int ms);)
|
||||
* table. To get an accurate count of the number of rows deleted, use
|
||||
* "DELETE FROM table WHERE 1" instead.
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_changes(switch_core_db*);)
|
||||
DoxyDefine(int switch_core_db_changes(switch_core_db *);)
|
||||
#define switch_core_db_changes sqlite3_changes
|
||||
|
||||
/**
|
||||
* A function to close the database.
|
||||
*
|
||||
@@ -385,7 +365,6 @@ DoxyDefine(int switch_core_db_changes(switch_core_db*);)
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_close(switch_core_db *);)
|
||||
#define switch_core_db_close sqlite3_close
|
||||
|
||||
/**
|
||||
* To avoid having to register all collation sequences before a database
|
||||
* can be used, a single callback function may be registered with the
|
||||
@@ -405,13 +384,10 @@ DoxyDefine(int switch_core_db_close(switch_core_db *);)
|
||||
* The collation sequence is returned to SQLite by a collation-needed
|
||||
* callback using the sqlite3_create_collation() API, described above.
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_collation_needed(
|
||||
switch_core_db*,
|
||||
void*,
|
||||
void(*)(void*,switch_core_db*,int eTextRep,const char*)
|
||||
);)
|
||||
DoxyDefine(int switch_core_db_collation_needed(switch_core_db *,
|
||||
void *, void (*)(void *, switch_core_db *, int eTextRep, const char *)
|
||||
);)
|
||||
#define switch_core_db_collation_needed sqlite3_collation_needed
|
||||
|
||||
/**
|
||||
* The next group of routines returns information about the information
|
||||
* in a single column of the current result row of a query.
|
||||
@@ -453,9 +429,8 @@ DoxyDefine(int switch_core_db_collation_needed(
|
||||
*
|
||||
* @return the value of a BLOB.
|
||||
*/
|
||||
DoxyDefine(const void *switch_core_db_column_blob(sqlite3_stmt *stmt, int iCol);)
|
||||
DoxyDefine(const void *switch_core_db_column_blob(sqlite3_stmt * stmt, int iCol);)
|
||||
#define switch_core_db_column_blob sqlite3_column_blob
|
||||
|
||||
/**
|
||||
* The next group of routines returns information about the information
|
||||
* in a single column of the current result row of a query. In every
|
||||
@@ -497,9 +472,8 @@ DoxyDefine(const void *switch_core_db_column_blob(sqlite3_stmt *stmt, int iCol);
|
||||
* TEXT value represented as UTF-8. The "\000" terminator is included in the
|
||||
* byte count for TEXT values.
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_column_bytes(sqlite3_stmt*, int iCol);)
|
||||
DoxyDefine(int switch_core_db_column_bytes(sqlite3_stmt *, int iCol);)
|
||||
#define switch_core_db_column_bytes sqlite3_column_bytes
|
||||
|
||||
/**
|
||||
* The next group of routines returns information about the information
|
||||
* in a single column of the current result row of a query. In every
|
||||
@@ -541,9 +515,8 @@ DoxyDefine(int switch_core_db_column_bytes(sqlite3_stmt*, int iCol);)
|
||||
* TEXT value represented as UTF-16. The "\u0000" terminator is included in
|
||||
* the byte count for TEXT values.
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_column_bytes16(sqlite3_stmt*, int iCol);)
|
||||
DoxyDefine(int switch_core_db_column_bytes16(sqlite3_stmt *, int iCol);)
|
||||
#define switch_core_db_column_bytes16 sqlite3_column_bytes16
|
||||
|
||||
/**
|
||||
* The next group of routines returns information about the information
|
||||
* in a single column of the current result row of a query. In every
|
||||
@@ -583,9 +556,8 @@ DoxyDefine(int switch_core_db_column_bytes16(sqlite3_stmt*, int iCol);)
|
||||
*
|
||||
* Return a FLOAT value.
|
||||
*/
|
||||
DoxyDefine(double switch_core_db_column_double(sqlite3_stmt*, int iCol);)
|
||||
DoxyDefine(double switch_core_db_column_double(sqlite3_stmt *, int iCol);)
|
||||
#define switch_core_db_column_double sqlite3_column_double
|
||||
|
||||
/**
|
||||
* The next group of routines returns information about the information
|
||||
* in a single column of the current result row of a query. In every
|
||||
@@ -626,9 +598,8 @@ DoxyDefine(double switch_core_db_column_double(sqlite3_stmt*, int iCol);)
|
||||
* Return an INTEGER value in the host computer's native integer representation.
|
||||
* This might be either a 32- or 64-bit integer depending on the host.
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_column_int(sqlite3_stmt*, int iCol);)
|
||||
DoxyDefine(int switch_core_db_column_int(sqlite3_stmt *, int iCol);)
|
||||
#define switch_core_db_column_int sqlite3_column_int
|
||||
|
||||
/**
|
||||
* The next group of routines returns information about the information
|
||||
* in a single column of the current result row of a query. In every
|
||||
@@ -668,9 +639,8 @@ DoxyDefine(int switch_core_db_column_int(sqlite3_stmt*, int iCol);)
|
||||
*
|
||||
* Return an INTEGER value as a 64-bit signed integer.
|
||||
*/
|
||||
DoxyDefine(sqlite_int64 switch_core_db_column_int64(sqlite3_stmt*, int iCol);)
|
||||
DoxyDefine(sqlite_int64 switch_core_db_column_int64(sqlite3_stmt *, int iCol);)
|
||||
#define switch_core_db_column_int64 sqlite3_column_int64
|
||||
|
||||
/**
|
||||
* The next group of routines returns information about the information
|
||||
* in a single column of the current result row of a query. In every
|
||||
@@ -710,9 +680,8 @@ DoxyDefine(sqlite_int64 switch_core_db_column_int64(sqlite3_stmt*, int iCol);)
|
||||
*
|
||||
* Return the value as UTF-8 text.
|
||||
*/
|
||||
DoxyDefine(const unsigned char *switch_core_db_column_text(sqlite3_stmt*, int iCol);)
|
||||
DoxyDefine(const unsigned char *switch_core_db_column_text(sqlite3_stmt *, int iCol);)
|
||||
#define switch_core_db_column_text sqlite3_column_text
|
||||
|
||||
/**
|
||||
* The next group of routines returns information about the information
|
||||
* in a single column of the current result row of a query. In every
|
||||
@@ -752,9 +721,8 @@ DoxyDefine(const unsigned char *switch_core_db_column_text(sqlite3_stmt*, int iC
|
||||
*
|
||||
* Return the value as UTF-16 text.
|
||||
*/
|
||||
DoxyDefine(const void *switch_core_db_column_text16(sqlite3_stmt*, int iCol);)
|
||||
DoxyDefine(const void *switch_core_db_column_text16(sqlite3_stmt *, int iCol);)
|
||||
#define switch_core_db_column_text16 sqlite3_column_text16
|
||||
|
||||
/**
|
||||
* The next group of routines returns information about the information
|
||||
* in a single column of the current result row of a query. In every
|
||||
@@ -795,25 +763,22 @@ DoxyDefine(const void *switch_core_db_column_text16(sqlite3_stmt*, int iCol);)
|
||||
* ReturnS the datatype of the result. This is one of
|
||||
* SQLITE_INTEGER, SQLITE_FLOAT, SQLITE_TEXT, SQLITE_BLOB, or SQLITE_NULL.
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_column_type(sqlite3_stmt*, int iCol);)
|
||||
DoxyDefine(int switch_core_db_column_type(sqlite3_stmt *, int iCol);)
|
||||
#define switch_core_db_column_type sqlite3_column_type
|
||||
|
||||
/**
|
||||
* The first parameter is a compiled SQL statement. This function returns
|
||||
* the column heading for the Nth column of that statement, where N is the
|
||||
* second function parameter. The string returned is UTF-8.
|
||||
*/
|
||||
DoxyDefine(const char *switch_core_db_column_name(sqlite3_stmt*,int);)
|
||||
DoxyDefine(const char *switch_core_db_column_name(sqlite3_stmt *, int);)
|
||||
#define switch_core_db_column_name sqlite3_column_name
|
||||
|
||||
/**
|
||||
* Return the number of columns in the result set returned by the compiled
|
||||
* SQL statement. This routine returns 0 if pStmt is an SQL statement
|
||||
* that does not return data (for example an UPDATE).
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_column_count(sqlite3_stmt *pStmt);)
|
||||
DoxyDefine(int switch_core_db_column_count(sqlite3_stmt * pStmt);)
|
||||
#define switch_core_db_column_count sqlite3_column_count
|
||||
|
||||
/**
|
||||
* The first parameter is a compiled SQL statement. If this statement
|
||||
* is a SELECT statement, the Nth column of the returned result set
|
||||
@@ -834,7 +799,6 @@ DoxyDefine(int switch_core_db_column_count(sqlite3_stmt *pStmt);)
|
||||
*/
|
||||
DoxyDefine(const char *switch_core_db_column_decltype(sqlite3_stmt *, int i);)
|
||||
#define switch_core_db_column_decltype sqlite3_column_decltype
|
||||
|
||||
/**
|
||||
* The first parameter is a compiled SQL statement. If this statement
|
||||
* is a SELECT statement, the Nth column of the returned result set
|
||||
@@ -853,9 +817,8 @@ DoxyDefine(const char *switch_core_db_column_decltype(sqlite3_stmt *, int i);)
|
||||
* result column (i==1), and a NULL pointer for the first result column
|
||||
* (i==0).
|
||||
*/
|
||||
DoxyDefine(const void *switch_core_db_column_decltype16(sqlite3_stmt*,int);)
|
||||
DoxyDefine(const void *switch_core_db_column_decltype16(sqlite3_stmt *, int);)
|
||||
#define switch_core_db_column_decltype16 sqlite3_column_decltype16
|
||||
|
||||
/**
|
||||
* Register a callback function to be invoked whenever a new transaction
|
||||
* is committed. The pArg argument is passed through to the callback.
|
||||
@@ -869,9 +832,8 @@ DoxyDefine(const void *switch_core_db_column_decltype16(sqlite3_stmt*,int);)
|
||||
*
|
||||
****** THIS IS AN EXPERIMENTAL API AND IS SUBJECT TO CHANGE ******
|
||||
*/
|
||||
DoxyDefine(void *switch_core_db_commit_hook(switch_core_db*, int(*)(void*), void*);)
|
||||
DoxyDefine(void *switch_core_db_commit_hook(switch_core_db *, int (*)(void *), void *);)
|
||||
#define switch_core_db_commit_hook sqlite3_commit_hook
|
||||
|
||||
/**
|
||||
* This functions return true if the given input string comprises
|
||||
* one or more complete SQL statements. The parameter must be a nul-terminated
|
||||
@@ -883,7 +845,6 @@ DoxyDefine(void *switch_core_db_commit_hook(switch_core_db*, int(*)(void*), void
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_complete(const char *sql);)
|
||||
#define switch_core_db_complete sqlite3_complete
|
||||
|
||||
/**
|
||||
* This function is used to add new collation sequences to the
|
||||
* sqlite3 handle specified as the first argument.
|
||||
@@ -909,15 +870,12 @@ DoxyDefine(int switch_core_db_complete(const char *sql);)
|
||||
* the first string is less than, equal to, or greater than the second
|
||||
* string. i.e. (STRING1 - STRING2).
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_create_collation(
|
||||
switch_core_db*,
|
||||
const char *zName,
|
||||
int eTextRep,
|
||||
void*,
|
||||
int(*xCompare)(void*,int,const void*,int,const void*)
|
||||
);)
|
||||
DoxyDefine(int switch_core_db_create_collation(switch_core_db *,
|
||||
const char *zName,
|
||||
int eTextRep,
|
||||
void *, int (*xCompare) (void *, int, const void *, int, const void *)
|
||||
);)
|
||||
#define switch_core_db_create_collation sqlite3_create_collation
|
||||
|
||||
/**
|
||||
* The following function is used to add user functions or aggregates
|
||||
* implemented in C to the SQL langauge interpreted by SQLite. The
|
||||
@@ -951,18 +909,16 @@ DoxyDefine(int switch_core_db_create_collation(
|
||||
* xFunc and an xFinal, or an xStep but no xFinal, SQLITE_ERROR is
|
||||
* returned.
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_create_function(
|
||||
switch_core_db *,
|
||||
const char *zFunctionName,
|
||||
int nArg,
|
||||
int eTextRep,
|
||||
void*,
|
||||
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
|
||||
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
|
||||
void (*xFinal)(sqlite3_context*)
|
||||
);)
|
||||
DoxyDefine(int switch_core_db_create_function(switch_core_db *,
|
||||
const char *zFunctionName,
|
||||
int nArg,
|
||||
int eTextRep,
|
||||
void *,
|
||||
void (*xFunc) (sqlite3_context *, int, sqlite3_value **),
|
||||
void (*xStep) (sqlite3_context *, int, sqlite3_value **),
|
||||
void (*xFinal) (sqlite3_context *)
|
||||
);)
|
||||
#define switch_core_db_create_function sqlite3_create_function
|
||||
|
||||
/**
|
||||
* Return the number of values in the current row of the result set.
|
||||
*
|
||||
@@ -972,18 +928,16 @@ DoxyDefine(int switch_core_db_create_function(
|
||||
* error code, or before switch_core_db_step() has been called on a
|
||||
* compiled SQL statement, this routine returns zero.
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_data_count(sqlite3_stmt *pStmt);)
|
||||
DoxyDefine(int switch_core_db_data_count(sqlite3_stmt * pStmt);)
|
||||
#define switch_core_db_data_count sqlite3_data_count
|
||||
|
||||
/**
|
||||
* Return the sqlite3* database handle to which the prepared statement given
|
||||
* in the argument belongs. This is the same database handle that was
|
||||
* the first argument to the switch_core_db_prepare() that was used to create
|
||||
* the statement in the first place.
|
||||
*/
|
||||
DoxyDefine(switch_core_db *switch_core_db_db_handle(sqlite3_stmt*);)
|
||||
DoxyDefine(switch_core_db * switch_core_db_db_handle(sqlite3_stmt *);)
|
||||
#define switch_core_db_db_handle sqlite3_db_handle
|
||||
|
||||
/**
|
||||
** Return the error code for the most recent switch_core_db_* API call associated
|
||||
** with switch_core_db handle 'db'. SQLITE_OK is returned if the most recent
|
||||
@@ -999,9 +953,8 @@ DoxyDefine(switch_core_db *switch_core_db_db_handle(sqlite3_stmt*);)
|
||||
** code returned by this function is associated with the same error as
|
||||
** the strings returned by sqlite3_errmsg() and sqlite3_errmsg16().
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_errcode(switch_core_db *db);)
|
||||
DoxyDefine(int switch_core_db_errcode(switch_core_db * db);)
|
||||
#define switch_core_db_errcode sqlite3_errcode
|
||||
|
||||
/**
|
||||
* Return a pointer to a UTF-8 encoded string describing in english the
|
||||
* error condition for the most recent sqlite3_* API call. The returned
|
||||
@@ -1010,9 +963,8 @@ DoxyDefine(int switch_core_db_errcode(switch_core_db *db);)
|
||||
* The string "not an error" is returned when the most recent API call was
|
||||
* successful.
|
||||
*/
|
||||
DoxyDefine(const char *switch_core_db_errmsg(switch_core_db*);)
|
||||
DoxyDefine(const char *switch_core_db_errmsg(switch_core_db *);)
|
||||
#define switch_core_db_errmsg sqlite3_errmsg
|
||||
|
||||
/**
|
||||
* A function to executes one or more statements of SQL.
|
||||
*
|
||||
@@ -1053,15 +1005,13 @@ DoxyDefine(const char *switch_core_db_errmsg(switch_core_db*);)
|
||||
* behavior can be modified somewhat using the sswitch_core_db_busy_handler()
|
||||
* and switch_core_db_busy_timeout() functions below.)
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_exec(
|
||||
switch_core_db*, /* An open database */
|
||||
const char *sql, /* SQL to be executed */
|
||||
sqlite3_callback, /* Callback function */
|
||||
void *, /* 1st argument to callback function */
|
||||
char **errmsg /* Error msg written here */
|
||||
);)
|
||||
DoxyDefine(int switch_core_db_exec(switch_core_db *, /* An open database */
|
||||
const char *sql, /* SQL to be executed */
|
||||
sqlite3_callback, /* Callback function */
|
||||
void *, /* 1st argument to callback function */
|
||||
char **errmsg /* Error msg written here */
|
||||
);)
|
||||
#define switch_core_db_exec sqlite3_exec
|
||||
|
||||
/**
|
||||
* Return TRUE (non-zero) if the statement supplied as an argument needs
|
||||
* to be recompiled. A statement needs to be recompiled whenever the
|
||||
@@ -1071,9 +1021,8 @@ DoxyDefine(int switch_core_db_exec(
|
||||
* added or changed.
|
||||
*
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_expired(sqlite3_stmt*);)
|
||||
DoxyDefine(int switch_core_db_expired(sqlite3_stmt *);)
|
||||
#define switch_core_db_expired sqlite3_expired
|
||||
|
||||
/**
|
||||
* This function is called to delete a compiled
|
||||
* SQL statement obtained by a previous call to switch_core_db_prepare().
|
||||
@@ -1088,24 +1037,21 @@ DoxyDefine(int switch_core_db_expired(sqlite3_stmt*);)
|
||||
* rolled back and transactions cancelled, depending on the circumstances,
|
||||
* and the result code returned will be SQLITE_ABORT.
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_finalize(sqlite3_stmt *pStmt);)
|
||||
DoxyDefine(int switch_core_db_finalize(sqlite3_stmt * pStmt);)
|
||||
#define switch_core_db_finalize sqlite3_finalize
|
||||
|
||||
/**
|
||||
* Call this routine to free the memory that sqlite3_get_table() allocated.
|
||||
*/
|
||||
DoxyDefine(void switch_core_db_free_table(char **result);)
|
||||
#define switch_core_db_free_table sqlite3_free_table
|
||||
|
||||
/**
|
||||
* Test to see whether or not the database connection is in autocommit
|
||||
* mode. Return TRUE if it is and FALSE if not. Autocommit mode is on
|
||||
* by default. Autocommit is disabled by a BEGIN statement and reenabled
|
||||
* by the next COMMIT or ROLLBACK.
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_get_autocommit(switch_core_db*);)
|
||||
DoxyDefine(int switch_core_db_get_autocommit(switch_core_db *);)
|
||||
#define switch_core_db_get_autocommit sqlite3_get_autocommit
|
||||
|
||||
/**
|
||||
* The following function may be used by scalar user functions to
|
||||
* associate meta-data with argument values. If the same value is passed to
|
||||
@@ -1125,9 +1071,8 @@ DoxyDefine(int switch_core_db_get_autocommit(switch_core_db*);)
|
||||
* expressions that are constant at compile time. This includes literal
|
||||
* values and SQL variables.
|
||||
*/
|
||||
DoxyDefine(void *switch_core_db_get_auxdata(sqlite3_context*, int);)
|
||||
DoxyDefine(void *switch_core_db_get_auxdata(sqlite3_context *, int);)
|
||||
#define switch_core_db_get_auxdata sqlite3_get_auxdata
|
||||
|
||||
/**
|
||||
* The following function may be used by scalar user functions to
|
||||
* associate meta-data with argument values. If the same value is passed to
|
||||
@@ -1149,9 +1094,8 @@ DoxyDefine(void *switch_core_db_get_auxdata(sqlite3_context*, int);)
|
||||
* expressions that are constant at compile time. This includes literal
|
||||
* values and SQL variables.
|
||||
*/
|
||||
DoxyDefine(void switch_core_db_set_auxdata(sqlite3_context*, int, void*, void (*)(void*));)
|
||||
DoxyDefine(void switch_core_db_set_auxdata(sqlite3_context *, int, void *, void (*)(void *));)
|
||||
#define switch_core_db_set_auxdata sqlite3_set_auxdata
|
||||
|
||||
/**
|
||||
* This next routine is really just a wrapper around sqlite3_exec().
|
||||
* Instead of invoking a user-supplied callback for each row of the
|
||||
@@ -1193,16 +1137,14 @@ DoxyDefine(void switch_core_db_set_auxdata(sqlite3_context*, int, void*, void (*
|
||||
*
|
||||
* The return value of this routine is the same as from switch_core_db_exec().
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_get_table(
|
||||
switch_core_db*, /* An open database */
|
||||
const char *sql, /* SQL to be executed */
|
||||
char ***resultp, /* Result written to a char *[] that this points to */
|
||||
int *nrow, /* Number of result rows written here */
|
||||
int *ncolumn, /* Number of result columns written here */
|
||||
char **errmsg /* Error msg written here */
|
||||
);)
|
||||
DoxyDefine(int switch_core_db_get_table(switch_core_db *, /* An open database */
|
||||
const char *sql, /* SQL to be executed */
|
||||
char ***resultp, /* Result written to a char *[] that this points to */
|
||||
int *nrow, /* Number of result rows written here */
|
||||
int *ncolumn, /* Number of result columns written here */
|
||||
char **errmsg /* Error msg written here */
|
||||
);)
|
||||
#define switch_core_db_get_table sqlite3_get_table
|
||||
|
||||
/**
|
||||
* This function is called to recover from a malloc() failure that occured
|
||||
* within the SQLite library. Normally, after a single malloc() fails the
|
||||
@@ -1224,16 +1166,14 @@ DoxyDefine(int switch_core_db_get_table(
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_global_recover();)
|
||||
#define switch_core_db_global_recover sqlite3_global_recover
|
||||
|
||||
/** This function causes any pending database operation to abort and
|
||||
* return at its earliest opportunity. This routine is typically
|
||||
* called in response to a user action such as pressing "Cancel"
|
||||
* or Ctrl-C where the user wants a long query operation to halt
|
||||
* immediately.
|
||||
*/
|
||||
DoxyDefine(void switch_core_db_interrupt(switch_core_db*);)
|
||||
DoxyDefine(void switch_core_db_interrupt(switch_core_db *);)
|
||||
#define switch_core_db_interrupt sqlite3_interrupt
|
||||
|
||||
/**
|
||||
* Each entry in an SQLite table has a unique integer key. (The key is
|
||||
* the value of the INTEGER PRIMARY KEY column if there is such a column,
|
||||
@@ -1243,9 +1183,8 @@ DoxyDefine(void switch_core_db_interrupt(switch_core_db*);)
|
||||
*
|
||||
* This function is similar to the mysql_insert_id() function from MySQL.
|
||||
*/
|
||||
DoxyDefine(sqlite_int64 switch_core_db_last_insert_rowid(switch_core_db*);)
|
||||
DoxyDefine(sqlite_int64 switch_core_db_last_insert_rowid(switch_core_db *);)
|
||||
#define switch_core_db_last_insert_rowid sqlite3_last_insert_rowid
|
||||
|
||||
/**
|
||||
* Open the sqlite database file "filename". The "filename" is UTF-8
|
||||
* encoded. An sqlite3* handle is returned in *ppDb, even
|
||||
@@ -1261,12 +1200,10 @@ DoxyDefine(sqlite_int64 switch_core_db_last_insert_rowid(switch_core_db*);)
|
||||
* with the switch_core_db* handle should be released by passing it to
|
||||
* switch_core_db_close() when it is no longer required.
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_open(
|
||||
const char *filename, /* Database filename (UTF-8) */
|
||||
switch_core_db **ppDb /* OUT: SQLite db handle */
|
||||
);)
|
||||
DoxyDefine(int switch_core_db_open(const char *filename, /* Database filename (UTF-8) */
|
||||
switch_core_db ** ppDb /* OUT: SQLite db handle */
|
||||
);)
|
||||
#define switch_core_db_open sqlite3_open
|
||||
|
||||
/**
|
||||
* To execute an SQL query, it must first be compiled into a byte-code
|
||||
* program using the following routine.
|
||||
@@ -1289,15 +1226,13 @@ DoxyDefine(int switch_core_db_open(
|
||||
*
|
||||
* On success, SQLITE_OK is returned. Otherwise an error code is returned.
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_prepare(
|
||||
sqlite3 *db, /* Database handle */
|
||||
const char *zSql, /* SQL statement, UTF-8 encoded */
|
||||
int nBytes, /* Length of zSql in bytes. */
|
||||
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
|
||||
const char **pzTail /* OUT: Pointer to unused portion of zSql */
|
||||
);)
|
||||
DoxyDefine(int switch_core_db_prepare(sqlite3 * db, /* Database handle */
|
||||
const char *zSql, /* SQL statement, UTF-8 encoded */
|
||||
int nBytes, /* Length of zSql in bytes. */
|
||||
sqlite3_stmt ** ppStmt, /* OUT: Statement handle */
|
||||
const char **pzTail /* OUT: Pointer to unused portion of zSql */
|
||||
);)
|
||||
#define switch_core_db_prepare sqlite3_prepare
|
||||
|
||||
/**
|
||||
* Register a function for tracing SQL command evaluation. The function registered by
|
||||
* switch_core_db_profile() runs at the end of each SQL statement and includes
|
||||
@@ -1306,10 +1241,9 @@ DoxyDefine(int switch_core_db_prepare(
|
||||
* The sqlite3_profile() API is currently considered experimental and
|
||||
* is subject to change.
|
||||
*/
|
||||
DoxyDefine(void *switch_core_db_profile(switch_core_db*,
|
||||
void(*xProfile)(void*,const char*,sqlite_uint64), void*);)
|
||||
DoxyDefine(void *switch_core_db_profile(switch_core_db *,
|
||||
void (*xProfile) (void *, const char *, sqlite_uint64), void *);)
|
||||
#define switch_core_db_profile sqlite3_profile
|
||||
|
||||
/**
|
||||
* This routine configures a callback function - the progress callback - that
|
||||
* is invoked periodically during long running calls to switch_core_db_exec(),
|
||||
@@ -1336,9 +1270,8 @@ DoxyDefine(void *switch_core_db_profile(switch_core_db*,
|
||||
*
|
||||
****** THIS IS AN EXPERIMENTAL API AND IS SUBJECT TO CHANGE ******
|
||||
*/
|
||||
DoxyDefine(void switch_core_db_progress_handler(switch_core_db*, int, int(*)(void*), void*);)
|
||||
DoxyDefine(void switch_core_db_progress_handler(switch_core_db *, int, int (*)(void *), void *);)
|
||||
#define switch_core_db_progress_handler sqlite3_progress_handler
|
||||
|
||||
/**
|
||||
* The switch_core_db_reset() function is called to reset a compiled SQL
|
||||
* statement obtained by a previous call to switch_core_db_prepare()
|
||||
@@ -1346,93 +1279,80 @@ DoxyDefine(void switch_core_db_progress_handler(switch_core_db*, int, int(*)(voi
|
||||
* Any SQL statement variables that had values bound to them using
|
||||
* the switch_core_db_bind_*() API retain their values.
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_reset(sqlite3_stmt *pStmt);)
|
||||
DoxyDefine(int switch_core_db_reset(sqlite3_stmt * pStmt);)
|
||||
#define switch_core_db_reset sqlite3_reset
|
||||
|
||||
/**
|
||||
* User-defined functions invoke this routine in order to
|
||||
* set their return value.
|
||||
*/
|
||||
DoxyDefine(void switch_core_db_result_blob(sqlite3_context*, const void*, int, void(*)(void*));)
|
||||
DoxyDefine(void switch_core_db_result_blob(sqlite3_context *, const void *, int, void (*)(void *));)
|
||||
#define switch_core_db_result_blob sqlite3_result_blob
|
||||
|
||||
/**
|
||||
* User-defined functions invoke this routine in order to
|
||||
* set their return value.
|
||||
*/
|
||||
DoxyDefine(void switch_core_db_result_double(sqlite3_context*, double);)
|
||||
DoxyDefine(void switch_core_db_result_double(sqlite3_context *, double);)
|
||||
#define switch_core_db_result_double sqlite3_result_double
|
||||
|
||||
/**
|
||||
* User-defined functions invoke this routine in order to
|
||||
* set their return value.
|
||||
*/
|
||||
DoxyDefine(void switch_core_db_result_error(sqlite3_context*, const char*, int);)
|
||||
DoxyDefine(void switch_core_db_result_error(sqlite3_context *, const char *, int);)
|
||||
#define switch_core_db_result_error sqlite3_result_error
|
||||
|
||||
/**
|
||||
* User-defined functions invoke this routine in order to
|
||||
* set their return value.
|
||||
*/
|
||||
DoxyDefine(void switch_core_db_result_error16(sqlite3_context*, const void*, int);)
|
||||
DoxyDefine(void switch_core_db_result_error16(sqlite3_context *, const void *, int);)
|
||||
#define switch_core_db_result_error16 sqlite3_result_error16
|
||||
|
||||
/**
|
||||
* User-defined functions invoke this routine in order to
|
||||
* set their return value.
|
||||
*/
|
||||
DoxyDefine(void switch_core_db_result_int(sqlite3_context*, int);)
|
||||
DoxyDefine(void switch_core_db_result_int(sqlite3_context *, int);)
|
||||
#define switch_core_db_result_int sqlite3_result_int
|
||||
|
||||
/**
|
||||
* User-defined functions invoke this routine in order to
|
||||
* set their return value.
|
||||
*/
|
||||
DoxyDefine(void switch_core_db_result_int64(sqlite3_context*, sqlite_int64);)
|
||||
DoxyDefine(void switch_core_db_result_int64(sqlite3_context *, sqlite_int64);)
|
||||
#define switch_core_db_result_int64 sqlite3_result_int64
|
||||
|
||||
/**
|
||||
* User-defined functions invoke this routine in order to
|
||||
* set their return value.
|
||||
*/
|
||||
DoxyDefine(void switch_core_db_result_null(sqlite3_context*);)
|
||||
DoxyDefine(void switch_core_db_result_null(sqlite3_context *);)
|
||||
#define switch_core_db_result_null sqlite3_result_null
|
||||
|
||||
/**
|
||||
* User-defined functions invoke this routine in order to
|
||||
* set their return value.
|
||||
*/
|
||||
DoxyDefine(void switch_core_db_result_text(sqlite3_context*, const char*, int, void(*)(void*));)
|
||||
DoxyDefine(void switch_core_db_result_text(sqlite3_context *, const char *, int, void (*)(void *));)
|
||||
#define switch_core_db_result_text sqlite3_result_text
|
||||
|
||||
/**
|
||||
* User-defined functions invoke this routine in order to
|
||||
* set their return value.
|
||||
*/
|
||||
DoxyDefine(void switch_core_db_result_text16(sqlite3_context*, const void*, int, void(*)(void*));)
|
||||
DoxyDefine(void switch_core_db_result_text16(sqlite3_context *, const void *, int, void (*)(void *));)
|
||||
#define switch_core_db_result_text16 sqlite3_result_text16
|
||||
|
||||
/**
|
||||
* User-defined functions invoke this routine in order to
|
||||
* set their return value.
|
||||
*/
|
||||
DoxyDefine(void switch_core_db_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));)
|
||||
DoxyDefine(void switch_core_db_result_text16le(sqlite3_context *, const void *, int, void (*)(void *));)
|
||||
#define switch_core_db_result_text16le sqlite3_result_text16le
|
||||
|
||||
/**
|
||||
* User-defined functions invoke this routine in order to
|
||||
* set their return value.
|
||||
*/
|
||||
DoxyDefine(void switch_core_db_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));)
|
||||
DoxyDefine(void switch_core_db_result_text16be(sqlite3_context *, const void *, int, void (*)(void *));)
|
||||
#define switch_core_db_result_text16be sqlite3_result_text16be
|
||||
|
||||
/**
|
||||
* User-defined functions invoke this routine in order to
|
||||
* set their return value.
|
||||
*/
|
||||
DoxyDefine(void switch_core_db_result_value(sqlite3_context*, sqlite3_value*);)
|
||||
DoxyDefine(void switch_core_db_result_value(sqlite3_context *, sqlite3_value *);)
|
||||
#define switch_core_db_result_value sqlite3_result_value
|
||||
|
||||
/**
|
||||
* This routine registers a callback with the SQLite library. The
|
||||
* callback is invoked (at compile-time, not at run-time) for each
|
||||
@@ -1441,13 +1361,10 @@ DoxyDefine(void switch_core_db_result_value(sqlite3_context*, sqlite3_value*);)
|
||||
* SQL statement should be aborted with an error and SQLITE_IGNORE
|
||||
* if the column should be treated as a NULL value.
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_set_authorizer(
|
||||
switch_core_db*,
|
||||
int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
|
||||
void *pUserData
|
||||
);)
|
||||
DoxyDefine(int switch_core_db_set_authorizer(switch_core_db *,
|
||||
int (*xAuth) (void *, int, const char *, const char *, const char *,
|
||||
const char *), void *pUserData);)
|
||||
#define switch_core_db_set_authorizer sqlite3_set_authorizer
|
||||
|
||||
/**
|
||||
* After an SQL query has been compiled with a call to either
|
||||
* switch_core_db_prepare(), then this function must be
|
||||
@@ -1480,9 +1397,8 @@ DoxyDefine(int switch_core_db_set_authorizer(
|
||||
* SQLITE_DONE. Or it could be the case the the same database connection
|
||||
* is being used simulataneously by two or more threads.
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_step(sqlite3_stmt*);)
|
||||
DoxyDefine(int switch_core_db_step(sqlite3_stmt *);)
|
||||
#define switch_core_db_step sqlite3_step
|
||||
|
||||
/**
|
||||
* If the following global variable is made to point to a
|
||||
* string which is the name of a directory, then all temporary files
|
||||
@@ -1493,9 +1409,8 @@ DoxyDefine(int switch_core_db_step(sqlite3_stmt*);)
|
||||
* Once switch_core_db_open() has been called, changing this variable will invalidate
|
||||
* the current temporary database, if any.
|
||||
*/
|
||||
DoxyDefine(extern char *switch_core_db_temp_directory;)
|
||||
DoxyDefine(extern char *switch_core_db_temp_directory;)
|
||||
#define switch_core_db_temp_directory sqlite3_temp_directory
|
||||
|
||||
/**
|
||||
* This function returns the number of database rows that have been
|
||||
* modified by INSERT, UPDATE or DELETE statements since the database handle
|
||||
@@ -1512,17 +1427,15 @@ DoxyDefine(extern char *switch_core_db_temp_directory;)
|
||||
* table. To get an accurate count of the number of rows deleted, use
|
||||
* "DELETE FROM table WHERE 1" instead.
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_total_changes(switch_core_db*);)
|
||||
DoxyDefine(int switch_core_db_total_changes(switch_core_db *);)
|
||||
#define switch_core_db_total_changes sqlite3_total_changes
|
||||
|
||||
/**
|
||||
* Register a function for tracing SQL command evaluation. The function
|
||||
* registered is invoked at the first switch_core_db_step()
|
||||
* for the evaluation of an SQL statement.
|
||||
*/
|
||||
DoxyDefine(void *switch_core_db_trace(switch_core_db*, void(*xTrace)(void*,const char*), void*);)
|
||||
DoxyDefine(void *switch_core_db_trace(switch_core_db *, void (*xTrace) (void *, const char *), void *);)
|
||||
#define switch_core_db_trace sqlite3_trace
|
||||
|
||||
/**
|
||||
* Move all bindings from the first prepared statement over to the second.
|
||||
* This routine is useful, for example, if the first prepared statement
|
||||
@@ -1530,17 +1443,15 @@ DoxyDefine(void *switch_core_db_trace(switch_core_db*, void(*xTrace)(void*,const
|
||||
* the second prepared statement then all of the bindings transfered over
|
||||
* to the second statement before the first statement is finalized.
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);)
|
||||
DoxyDefine(int switch_core_db_transfer_bindings(sqlite3_stmt *, sqlite3_stmt *);)
|
||||
#define switch_core_db_transfer_bindings sqlite3_transfer_bindings
|
||||
|
||||
/**
|
||||
* The pUserData parameter to the switch_core_db_create_function()
|
||||
* routine used to register user functions is available to
|
||||
* the implementation of the function using this call.
|
||||
*/
|
||||
DoxyDefine(void *switch_core_db_user_data(sqlite3_context*);)
|
||||
DoxyDefine(void *switch_core_db_user_data(sqlite3_context *);)
|
||||
#define switch_core_db_user_data sqlite3_user_data
|
||||
|
||||
/**
|
||||
* returns information about parameters to
|
||||
* a user-defined function. Function implementations use this routines
|
||||
@@ -1549,9 +1460,8 @@ DoxyDefine(void *switch_core_db_user_data(sqlite3_context*);)
|
||||
* sqlite3_value* pointer instead of an sqlite3_stmt* and an integer
|
||||
* column number.
|
||||
*/
|
||||
DoxyDefine(const void *switch_core_db_value_blob(sqlite3_value*);)
|
||||
DoxyDefine(const void *switch_core_db_value_blob(sqlite3_value *);)
|
||||
#define switch_core_db_value_blob sqlite3_value_blob
|
||||
|
||||
/**
|
||||
* returns information about parameters to
|
||||
* a user-defined function. Function implementations use this routines
|
||||
@@ -1560,9 +1470,8 @@ DoxyDefine(const void *switch_core_db_value_blob(sqlite3_value*);)
|
||||
* sqlite3_value* pointer instead of an sqlite3_stmt* and an integer
|
||||
* column number.
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_value_bytes(sqlite3_value*);)
|
||||
DoxyDefine(int switch_core_db_value_bytes(sqlite3_value *);)
|
||||
#define switch_core_db_value_bytes sqlite3_value_bytes
|
||||
|
||||
/**
|
||||
* returns information about parameters to
|
||||
* a user-defined function. Function implementations use this routines
|
||||
@@ -1571,9 +1480,8 @@ DoxyDefine(int switch_core_db_value_bytes(sqlite3_value*);)
|
||||
* sqlite3_value* pointer instead of an sqlite3_stmt* and an integer
|
||||
* column number.
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_value_bytes16(sqlite3_value*);)
|
||||
DoxyDefine(int switch_core_db_value_bytes16(sqlite3_value *);)
|
||||
#define switch_core_db_value_bytes16 sqlite3_value_bytes16
|
||||
|
||||
/**
|
||||
* returns information about parameters to
|
||||
* a user-defined function. Function implementations use this routines
|
||||
@@ -1582,9 +1490,8 @@ DoxyDefine(int switch_core_db_value_bytes16(sqlite3_value*);)
|
||||
* sqlite3_value* pointer instead of an sqlite3_stmt* and an integer
|
||||
* column number.
|
||||
*/
|
||||
DoxyDefine(double switch_core_db_value_double(sqlite3_value*);)
|
||||
DoxyDefine(double switch_core_db_value_double(sqlite3_value *);)
|
||||
#define switch_core_db_value_double sqlite3_value_double
|
||||
|
||||
/**
|
||||
* returns information about parameters to
|
||||
* a user-defined function. Function implementations use this routines
|
||||
@@ -1593,9 +1500,8 @@ DoxyDefine(double switch_core_db_value_double(sqlite3_value*);)
|
||||
* sqlite3_value* pointer instead of an sqlite3_stmt* and an integer
|
||||
* column number.
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_value_int(sqlite3_value*);)
|
||||
DoxyDefine(int switch_core_db_value_int(sqlite3_value *);)
|
||||
#define switch_core_db_value_int sqlite3_value_int
|
||||
|
||||
/**
|
||||
* returns information about parameters to
|
||||
* a user-defined function. Function implementations use this routines
|
||||
@@ -1604,9 +1510,8 @@ DoxyDefine(int switch_core_db_value_int(sqlite3_value*);)
|
||||
* sqlite3_value* pointer instead of an sqlite3_stmt* and an integer
|
||||
* column number.
|
||||
*/
|
||||
DoxyDefine(sqlite_int64 switch_core_db_value_int64(sqlite3_value*);)
|
||||
DoxyDefine(sqlite_int64 switch_core_db_value_int64(sqlite3_value *);)
|
||||
#define switch_core_db_value_int64 sqlite3_value_int64
|
||||
|
||||
/**
|
||||
* returns information about parameters to
|
||||
* a user-defined function. Function implementations use this routines
|
||||
@@ -1615,9 +1520,8 @@ DoxyDefine(sqlite_int64 switch_core_db_value_int64(sqlite3_value*);)
|
||||
* sqlite3_value* pointer instead of an sqlite3_stmt* and an integer
|
||||
* column number.
|
||||
*/
|
||||
DoxyDefine(const unsigned char *switch_core_db_value_text(sqlite3_value*);)
|
||||
DoxyDefine(const unsigned char *switch_core_db_value_text(sqlite3_value *);)
|
||||
#define switch_core_db_value_text sqlite3_value_text
|
||||
|
||||
/**
|
||||
* returns information about parameters to
|
||||
* a user-defined function. Function implementations use this routines
|
||||
@@ -1626,9 +1530,8 @@ DoxyDefine(const unsigned char *switch_core_db_value_text(sqlite3_value*);)
|
||||
* sqlite3_value* pointer instead of an sqlite3_stmt* and an integer
|
||||
* column number.
|
||||
*/
|
||||
DoxyDefine(const void *switch_core_db_value_text16(sqlite3_value*);)
|
||||
DoxyDefine(const void *switch_core_db_value_text16(sqlite3_value *);)
|
||||
#define switch_core_db_value_text16 sqlite3_value_text16
|
||||
|
||||
/**
|
||||
* returns information about parameters to
|
||||
* a user-defined function. Function implementations use this routines
|
||||
@@ -1637,9 +1540,8 @@ DoxyDefine(const void *switch_core_db_value_text16(sqlite3_value*);)
|
||||
* sqlite3_value* pointer instead of an sqlite3_stmt* and an integer
|
||||
* column number.
|
||||
*/
|
||||
DoxyDefine(const void *switch_core_db_value_text16be(sqlite3_value*);)
|
||||
DoxyDefine(const void *switch_core_db_value_text16be(sqlite3_value *);)
|
||||
#define switch_core_db_value_text16be sqlite3_value_text16be
|
||||
|
||||
/**
|
||||
* returns information about parameters to
|
||||
* a user-defined function. Function implementations use this routines
|
||||
@@ -1648,9 +1550,8 @@ DoxyDefine(const void *switch_core_db_value_text16be(sqlite3_value*);)
|
||||
* sqlite3_value* pointer instead of an sqlite3_stmt* and an integer
|
||||
* column number.
|
||||
*/
|
||||
DoxyDefine(const void *switch_core_db_value_text16le(sqlite3_value*);)
|
||||
DoxyDefine(const void *switch_core_db_value_text16le(sqlite3_value *);)
|
||||
#define switch_core_db_value_text16le sqlite3_value_text16le
|
||||
|
||||
/**
|
||||
* returns information about parameters to
|
||||
* a user-defined function. Function implementations use this routines
|
||||
@@ -1659,10 +1560,8 @@ DoxyDefine(const void *switch_core_db_value_text16le(sqlite3_value*);)
|
||||
* sqlite3_value* pointer instead of an sqlite3_stmt* and an integer
|
||||
* column number.
|
||||
*/
|
||||
DoxyDefine(int switch_core_db_value_type(sqlite3_value*);)
|
||||
DoxyDefine(int switch_core_db_value_type(sqlite3_value *);)
|
||||
#define switch_core_db_value_type sqlite3_value_type
|
||||
|
||||
|
||||
/**
|
||||
* This routine is a variant of the "sprintf()" from the
|
||||
* standard C library. The resulting string is written into memory
|
||||
@@ -1704,10 +1603,9 @@ DoxyDefine(int switch_core_db_value_type(sqlite3_value*);)
|
||||
* should always use %q instead of %s when inserting text into a string
|
||||
* literal.
|
||||
*/
|
||||
DoxyDefine(char *switch_core_db_mprintf(const char*,...);)
|
||||
DoxyDefine(char *switch_core_db_mprintf(const char *, ...);)
|
||||
#define switch_core_db_mprintf sqlite3_mprintf
|
||||
#define switch_mprintf sqlite3_mprintf
|
||||
|
||||
/**
|
||||
* This routine is a variant of the "sprintf()" from the
|
||||
* standard C library. The resulting string is written into memory
|
||||
@@ -1749,9 +1647,8 @@ DoxyDefine(char *switch_core_db_mprintf(const char*,...);)
|
||||
* should always use %q instead of %s when inserting text into a string
|
||||
* literal.
|
||||
*/
|
||||
DoxyDefine(char *switch_core_db_vmprintf(const char*, va_list);)
|
||||
DoxyDefine(char *switch_core_db_vmprintf(const char *, va_list);)
|
||||
#define switch_core_db_vmprintf sqlite3_vmprintf
|
||||
|
||||
/**
|
||||
* This routine is a variant of the "sprintf()" from the
|
||||
* standard C library. The resulting string is written into memory
|
||||
@@ -1793,22 +1690,17 @@ DoxyDefine(char *switch_core_db_vmprintf(const char*, va_list);)
|
||||
* should always use %q instead of %s when inserting text into a string
|
||||
* literal.
|
||||
*/
|
||||
DoxyDefine(char *switch_core_db_snprintf(int,char*,const char*, ...);)
|
||||
DoxyDefine(char *switch_core_db_snprintf(int, char *, const char *, ...);)
|
||||
#define switch_core_db_snprintf sqlite3_snprintf
|
||||
|
||||
/**
|
||||
* call this routine to free memory malloced by a call to switch_core_db_mprintf, switch_core_db_vmprintf, or switch_core_db_snprintf
|
||||
*/
|
||||
DoxyDefine(void switch_core_db_free(char *z);)
|
||||
#define switch_core_db_free sqlite3_free
|
||||
|
||||
/** @} */
|
||||
/** @} */
|
||||
|
||||
SWITCH_END_EXTERN_C
|
||||
|
||||
SWITCH_END_EXTERN_C
|
||||
#endif
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
|
||||
+59
-63
@@ -38,59 +38,57 @@
|
||||
#define _SWITCH_STUN_PARSER_H
|
||||
|
||||
SWITCH_BEGIN_EXTERN_C
|
||||
|
||||
#define SWITCH_STUN_DEFAULT_PORT 3478
|
||||
#define SWITCH_STUN_PACKET_MIN_LEN 20
|
||||
|
||||
typedef enum {
|
||||
SWITCH_STUN_BINDING_REQUEST = 0x0001,
|
||||
SWITCH_STUN_BINDING_RESPONSE = 0x0101,
|
||||
SWITCH_STUN_BINDING_ERROR_RESPONSE = 0x0111,
|
||||
SWITCH_STUN_SHARED_SECRET_REQUEST = 0x0002,
|
||||
SWITCH_STUN_SHARED_SECRET_RESPONSE = 0x0102,
|
||||
SWITCH_STUN_SHARED_SECRET_ERROR_RESPONSE = 0x0112,
|
||||
SWITCH_STUN_ALLOCATE_REQUEST = 0x0003,
|
||||
SWITCH_STUN_ALLOCATE_RESPONSE = 0x0103,
|
||||
SWITCH_STUN_ALLOCATE_ERROR_RESPONSE = 0x0113,
|
||||
SWITCH_STUN_SEND_REQUEST = 0x0004,
|
||||
SWITCH_STUN_SEND_RESPONSE = 0x0104,
|
||||
SWITCH_STUN_SEND_ERROR_RESPONSE = 0x0114,
|
||||
SWITCH_STUN_DATA_INDICATION = 0x0115
|
||||
typedef enum {
|
||||
SWITCH_STUN_BINDING_REQUEST = 0x0001,
|
||||
SWITCH_STUN_BINDING_RESPONSE = 0x0101,
|
||||
SWITCH_STUN_BINDING_ERROR_RESPONSE = 0x0111,
|
||||
SWITCH_STUN_SHARED_SECRET_REQUEST = 0x0002,
|
||||
SWITCH_STUN_SHARED_SECRET_RESPONSE = 0x0102,
|
||||
SWITCH_STUN_SHARED_SECRET_ERROR_RESPONSE = 0x0112,
|
||||
SWITCH_STUN_ALLOCATE_REQUEST = 0x0003,
|
||||
SWITCH_STUN_ALLOCATE_RESPONSE = 0x0103,
|
||||
SWITCH_STUN_ALLOCATE_ERROR_RESPONSE = 0x0113,
|
||||
SWITCH_STUN_SEND_REQUEST = 0x0004,
|
||||
SWITCH_STUN_SEND_RESPONSE = 0x0104,
|
||||
SWITCH_STUN_SEND_ERROR_RESPONSE = 0x0114,
|
||||
SWITCH_STUN_DATA_INDICATION = 0x0115
|
||||
} switch_stun_message_t;
|
||||
|
||||
typedef enum {
|
||||
SWITCH_STUN_ATTR_MAPPED_ADDRESS = 0x0001, /* Address */
|
||||
SWITCH_STUN_ATTR_RESPONSE_ADDRESS = 0x0002, /* Address */
|
||||
SWITCH_STUN_ATTR_CHANGE_REQUEST = 0x0003, /* UInt32 */
|
||||
SWITCH_STUN_ATTR_SOURCE_ADDRESS = 0x0004, /* Address */
|
||||
SWITCH_STUN_ATTR_CHANGED_ADDRESS = 0x0005, /* Address */
|
||||
SWITCH_STUN_ATTR_USERNAME = 0x0006, /* ByteString, multiple of 4 bytes */
|
||||
SWITCH_STUN_ATTR_PASSWORD = 0x0007, /* ByteString, multiple of 4 bytes */
|
||||
SWITCH_STUN_ATTR_MESSAGE_INTEGRITY = 0x0008, /* ByteString, 20 bytes */
|
||||
SWITCH_STUN_ATTR_ERROR_CODE = 0x0009, /* ErrorCode */
|
||||
SWITCH_STUN_ATTR_UNKNOWN_ATTRIBUTES = 0x000a, /* UInt16List */
|
||||
SWITCH_STUN_ATTR_REFLECTED_FROM = 0x000b, /* Address */
|
||||
SWITCH_STUN_ATTR_TRANSPORT_PREFERENCES = 0x000c, /* TransportPrefs */
|
||||
SWITCH_STUN_ATTR_LIFETIME = 0x000d, /* UInt32 */
|
||||
SWITCH_STUN_ATTR_ALTERNATE_SERVER = 0x000e, /* Address */
|
||||
SWITCH_STUN_ATTR_MAGIC_COOKIE = 0x000f, /* ByteString, 4 bytes */
|
||||
SWITCH_STUN_ATTR_BANDWIDTH = 0x0010, /* UInt32 */
|
||||
SWITCH_STUN_ATTR_DESTINATION_ADDRESS = 0x0011, /* Address */
|
||||
SWITCH_STUN_ATTR_SOURCE_ADDRESS2 = 0x0012, /* Address */
|
||||
SWITCH_STUN_ATTR_DATA = 0x0013, /* ByteString */
|
||||
SWITCH_STUN_ATTR_OPTIONS = 0x8001 /* UInt32 */
|
||||
SWITCH_STUN_ATTR_MAPPED_ADDRESS = 0x0001, /* Address */
|
||||
SWITCH_STUN_ATTR_RESPONSE_ADDRESS = 0x0002, /* Address */
|
||||
SWITCH_STUN_ATTR_CHANGE_REQUEST = 0x0003, /* UInt32 */
|
||||
SWITCH_STUN_ATTR_SOURCE_ADDRESS = 0x0004, /* Address */
|
||||
SWITCH_STUN_ATTR_CHANGED_ADDRESS = 0x0005, /* Address */
|
||||
SWITCH_STUN_ATTR_USERNAME = 0x0006, /* ByteString, multiple of 4 bytes */
|
||||
SWITCH_STUN_ATTR_PASSWORD = 0x0007, /* ByteString, multiple of 4 bytes */
|
||||
SWITCH_STUN_ATTR_MESSAGE_INTEGRITY = 0x0008, /* ByteString, 20 bytes */
|
||||
SWITCH_STUN_ATTR_ERROR_CODE = 0x0009, /* ErrorCode */
|
||||
SWITCH_STUN_ATTR_UNKNOWN_ATTRIBUTES = 0x000a, /* UInt16List */
|
||||
SWITCH_STUN_ATTR_REFLECTED_FROM = 0x000b, /* Address */
|
||||
SWITCH_STUN_ATTR_TRANSPORT_PREFERENCES = 0x000c, /* TransportPrefs */
|
||||
SWITCH_STUN_ATTR_LIFETIME = 0x000d, /* UInt32 */
|
||||
SWITCH_STUN_ATTR_ALTERNATE_SERVER = 0x000e, /* Address */
|
||||
SWITCH_STUN_ATTR_MAGIC_COOKIE = 0x000f, /* ByteString, 4 bytes */
|
||||
SWITCH_STUN_ATTR_BANDWIDTH = 0x0010, /* UInt32 */
|
||||
SWITCH_STUN_ATTR_DESTINATION_ADDRESS = 0x0011, /* Address */
|
||||
SWITCH_STUN_ATTR_SOURCE_ADDRESS2 = 0x0012, /* Address */
|
||||
SWITCH_STUN_ATTR_DATA = 0x0013, /* ByteString */
|
||||
SWITCH_STUN_ATTR_OPTIONS = 0x8001 /* UInt32 */
|
||||
} switch_stun_attribute_t;
|
||||
|
||||
typedef enum {
|
||||
SWITCH_STUN_ERROR_BAD_REQUEST = 400,
|
||||
SWITCH_STUN_ERROR_UNAUTHORIZED = 401,
|
||||
SWITCH_STUN_ERROR_UNKNOWN_ATTRIBUTE = 420,
|
||||
SWITCH_STUN_ERROR_STALE_CREDENTIALS = 430,
|
||||
SWITCH_STUN_ERROR_INTEGRITY_CHECK_FAILURE = 431,
|
||||
SWITCH_STUN_ERROR_MISSING_USERNAME = 432,
|
||||
SWITCH_STUN_ERROR_USE_TLS = 433,
|
||||
SWITCH_STUN_ERROR_SERVER_ERROR = 500,
|
||||
SWITCH_STUN_ERROR_GLOBAL_FAILURE = 600
|
||||
SWITCH_STUN_ERROR_BAD_REQUEST = 400,
|
||||
SWITCH_STUN_ERROR_UNAUTHORIZED = 401,
|
||||
SWITCH_STUN_ERROR_UNKNOWN_ATTRIBUTE = 420,
|
||||
SWITCH_STUN_ERROR_STALE_CREDENTIALS = 430,
|
||||
SWITCH_STUN_ERROR_INTEGRITY_CHECK_FAILURE = 431,
|
||||
SWITCH_STUN_ERROR_MISSING_USERNAME = 432,
|
||||
SWITCH_STUN_ERROR_USE_TLS = 433,
|
||||
SWITCH_STUN_ERROR_SERVER_ERROR = 500,
|
||||
SWITCH_STUN_ERROR_GLOBAL_FAILURE = 600
|
||||
} switch_stun_error_t;
|
||||
|
||||
typedef enum {
|
||||
@@ -138,7 +136,7 @@ SWITCH_DECLARE(void) switch_stun_random_string(char *buf, uint16_t len, char *se
|
||||
\param len the length of the data
|
||||
\return a stun packet pointer to buf to use as an access point
|
||||
*/
|
||||
SWITCH_DECLARE(switch_stun_packet_t *)switch_stun_packet_parse(uint8_t *buf, uint32_t len);
|
||||
SWITCH_DECLARE(switch_stun_packet_t *) switch_stun_packet_parse(uint8_t * buf, uint32_t len);
|
||||
|
||||
/*!
|
||||
\brief Obtain a printable string form of a given value
|
||||
@@ -146,7 +144,7 @@ SWITCH_DECLARE(switch_stun_packet_t *)switch_stun_packet_parse(uint8_t *buf, uin
|
||||
\param value the value to look up
|
||||
\return a sring version of value
|
||||
*/
|
||||
SWITCH_DECLARE(const char *)switch_stun_value_to_name(int32_t type, uint32_t value);
|
||||
SWITCH_DECLARE(const char *) switch_stun_value_to_name(int32_t type, uint32_t value);
|
||||
|
||||
|
||||
/*!
|
||||
@@ -156,7 +154,8 @@ SWITCH_DECLARE(const char *)switch_stun_value_to_name(int32_t type, uint32_t val
|
||||
\param port the port
|
||||
\return true or false
|
||||
*/
|
||||
SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_get_mapped_address(switch_stun_packet_attribute_t *attribute, char *ipstr, uint16_t *port);
|
||||
SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_get_mapped_address(switch_stun_packet_attribute_t *attribute,
|
||||
char *ipstr, uint16_t * port);
|
||||
|
||||
/*!
|
||||
\brief Extract a username from a packet attribute
|
||||
@@ -165,7 +164,8 @@ SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_get_mapped_address(switch_s
|
||||
\param len the maximum size of the username buffer
|
||||
\return a pointer to the username or NULL
|
||||
*/
|
||||
SWITCH_DECLARE(char *)switch_stun_packet_attribute_get_username(switch_stun_packet_attribute_t *attribute, char *username, uint16_t len);
|
||||
SWITCH_DECLARE(char *) switch_stun_packet_attribute_get_username(switch_stun_packet_attribute_t *attribute,
|
||||
char *username, uint16_t len);
|
||||
|
||||
|
||||
/*!
|
||||
@@ -175,10 +175,8 @@ SWITCH_DECLARE(char *)switch_stun_packet_attribute_get_username(switch_stun_pack
|
||||
\param buf a pointer to data to use for the packet
|
||||
\return a pointer to a ready-to-use stun packet
|
||||
*/
|
||||
SWITCH_DECLARE(switch_stun_packet_t *)switch_stun_packet_build_header(switch_stun_message_t type,
|
||||
char *id,
|
||||
uint8_t *buf
|
||||
);
|
||||
SWITCH_DECLARE(switch_stun_packet_t *) switch_stun_packet_build_header(switch_stun_message_t type,
|
||||
char *id, uint8_t * buf);
|
||||
|
||||
/*!
|
||||
\brief Add a username packet attribute
|
||||
@@ -187,7 +185,8 @@ SWITCH_DECLARE(switch_stun_packet_t *)switch_stun_packet_build_header(switch_stu
|
||||
\param ulen the length of the username
|
||||
\return true or false
|
||||
*/
|
||||
SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_add_username(switch_stun_packet_t *packet, char *username, uint16_t ulen);
|
||||
SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_add_username(switch_stun_packet_t *packet, char *username,
|
||||
uint16_t ulen);
|
||||
|
||||
|
||||
/*!
|
||||
@@ -197,7 +196,8 @@ SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_add_username(switch_stun_pa
|
||||
\param port the port of the mapped address
|
||||
\return true or false
|
||||
*/
|
||||
SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_add_binded_address(switch_stun_packet_t *packet, char *ipstr, uint16_t port);
|
||||
SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_add_binded_address(switch_stun_packet_t *packet, char *ipstr,
|
||||
uint16_t port);
|
||||
|
||||
/*!
|
||||
\brief Perform a stun lookup
|
||||
@@ -209,12 +209,10 @@ SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_add_binded_address(switch_s
|
||||
\param pool the memory pool to use
|
||||
\return SUCCESS or FAIL
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_stun_lookup (char **ip,
|
||||
switch_port_t *port,
|
||||
char *stunip,
|
||||
switch_port_t stunport,
|
||||
char **err,
|
||||
switch_memory_pool_t *pool);
|
||||
SWITCH_DECLARE(switch_status_t) switch_stun_lookup(char **ip,
|
||||
switch_port_t *port,
|
||||
char *stunip,
|
||||
switch_port_t stunport, char **err, switch_memory_pool_t *pool);
|
||||
|
||||
|
||||
|
||||
@@ -241,9 +239,7 @@ SWITCH_DECLARE(switch_status_t) switch_stun_lookup (char **ip,
|
||||
///\}
|
||||
|
||||
SWITCH_END_EXTERN_C
|
||||
|
||||
#endif
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
|
||||
+97
-137
@@ -36,9 +36,7 @@
|
||||
|
||||
#include <switch.h>
|
||||
SWITCH_BEGIN_EXTERN_C
|
||||
|
||||
#define SWITCH_SEQ_ESC "\033["
|
||||
|
||||
/* Ansi Control character suffixes */
|
||||
#define SWITCH_SEQ_HOME_CHAR 'H'
|
||||
#define SWITCH_SEQ_HOME_CHAR_STR "H"
|
||||
@@ -48,11 +46,9 @@ SWITCH_BEGIN_EXTERN_C
|
||||
#define SWITCH_SEQ_CLEARSCR_CHAR0 '2'
|
||||
#define SWITCH_SEQ_CLEARSCR_CHAR1 'J'
|
||||
#define SWITCH_SEQ_CLEARSCR_CHAR "2J"
|
||||
|
||||
#define SWITCH_SEQ_DEFAULT_COLOR SWITCH_SEQ_ESC SWITCH_SEQ_END_COLOR /* Reset to Default fg/bg color */
|
||||
#define SWITCH_SEQ_AND_COLOR ";" /* To add multiple color definitions */
|
||||
#define SWITCH_SEQ_END_COLOR "m" /* To end color definitions */
|
||||
|
||||
#define SWITCH_SEQ_DEFAULT_COLOR SWITCH_SEQ_ESC SWITCH_SEQ_END_COLOR /* Reset to Default fg/bg color */
|
||||
#define SWITCH_SEQ_AND_COLOR ";" /* To add multiple color definitions */
|
||||
#define SWITCH_SEQ_END_COLOR "m" /* To end color definitions */
|
||||
/* Foreground colors values */
|
||||
#define SWITCH_SEQ_F_BLACK "30"
|
||||
#define SWITCH_SEQ_F_RED "31"
|
||||
@@ -62,7 +58,6 @@ SWITCH_BEGIN_EXTERN_C
|
||||
#define SWITCH_SEQ_F_MAGEN "35"
|
||||
#define SWITCH_SEQ_F_CYAN "36"
|
||||
#define SWITCH_SEQ_F_WHITE "37"
|
||||
|
||||
/* Background colors values */
|
||||
#define SWITCH_SEQ_B_BLACK "40"
|
||||
#define SWITCH_SEQ_B_RED "41"
|
||||
@@ -72,7 +67,6 @@ SWITCH_BEGIN_EXTERN_C
|
||||
#define SWITCH_SEQ_B_MAGEN "45"
|
||||
#define SWITCH_SEQ_B_CYAN "46"
|
||||
#define SWITCH_SEQ_B_WHITE "47"
|
||||
|
||||
/* Preset escape sequences - Change foreground colors only */
|
||||
#define SWITCH_SEQ_FBLACK SWITCH_SEQ_ESC SWITCH_SEQ_F_BLACK SWITCH_SEQ_END_COLOR
|
||||
#define SWITCH_SEQ_FRED SWITCH_SEQ_ESC SWITCH_SEQ_F_RED SWITCH_SEQ_END_COLOR
|
||||
@@ -82,7 +76,6 @@ SWITCH_BEGIN_EXTERN_C
|
||||
#define SWITCH_SEQ_FMAGEN SWITCH_SEQ_ESC SWITCH_SEQ_F_MAGEN SWITCH_SEQ_END_COLOR
|
||||
#define SWITCH_SEQ_FCYAN SWITCH_SEQ_ESC SWITCH_SEQ_F_CYAN SWITCH_SEQ_END_COLOR
|
||||
#define SWITCH_SEQ_FWHITE SWITCH_SEQ_ESC SWITCH_SEQ_F_WHITE SWITCH_SEQ_END_COLOR
|
||||
|
||||
#define SWITCH_SEQ_BBLACK SWITCH_SEQ_ESC SWITCH_SEQ_B_BLACK SWITCH_SEQ_END_COLOR
|
||||
#define SWITCH_SEQ_BRED SWITCH_SEQ_ESC SWITCH_SEQ_B_RED SWITCH_SEQ_END_COLOR
|
||||
#define SWITCH_SEQ_BGREEN SWITCH_SEQ_ESC SWITCH_SEQ_B_GREEN SWITCH_SEQ_END_COLOR
|
||||
@@ -91,21 +84,17 @@ SWITCH_BEGIN_EXTERN_C
|
||||
#define SWITCH_SEQ_BMAGEN SWITCH_SEQ_ESC SWITCH_SEQ_B_MAGEN SWITCH_SEQ_END_COLOR
|
||||
#define SWITCH_SEQ_BCYAN SWITCH_SEQ_ESC SWITCH_SEQ_B_CYAN SWITCH_SEQ_END_COLOR
|
||||
#define SWITCH_SEQ_BWHITE SWITCH_SEQ_ESC SWITCH_SEQ_B_WHITE SWITCH_SEQ_END_COLOR
|
||||
|
||||
/* Preset escape sequences */
|
||||
#define SWITCH_SEQ_HOME SWITCH_SEQ_ESC SWITCH_SEQ_HOME_CHAR_STR
|
||||
#define SWITCH_SEQ_CLEARLINE SWITCH_SEQ_ESC SWITCH_SEQ_CLEARLINE_CHAR_STR
|
||||
#define SWITCH_SEQ_CLEARLINEEND SWITCH_SEQ_ESC SWITCH_SEQ_CLEARLINEEND_CHAR
|
||||
#define SWITCH_SEQ_CLEARSCR SWITCH_SEQ_ESC SWITCH_SEQ_CLEARSCR_CHAR SWITCH_SEQ_HOME
|
||||
|
||||
#ifdef WIN32
|
||||
#define SWITCH_PATH_SEPARATOR "\\"
|
||||
#else
|
||||
#define SWITCH_PATH_SEPARATOR "/"
|
||||
#endif
|
||||
|
||||
#define SWITCH_URL_SEPARATOR "://"
|
||||
|
||||
#define SWITCH_ENDPOINT_DISPOSITION_VARIABLE "endpoint_disposition"
|
||||
#define SWITCH_EXPORT_VARS_VARIABLE "export_vars"
|
||||
#define SWITCH_R_SDP_VARIABLE "switch_r_sdp"
|
||||
@@ -122,11 +111,10 @@ SWITCH_BEGIN_EXTERN_C
|
||||
#define SWITCH_REMOTE_MEDIA_PORT_VARIABLE "remote_media_port"
|
||||
#define SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE "hangup_after_bridge"
|
||||
#define SWITCH_MAX_FORWARDS_VARIABLE "max_forwards"
|
||||
|
||||
#define SWITCH_SPEECH_KEY "speech"
|
||||
#define SWITCH_UUID_BRIDGE "uuid_bridge"
|
||||
#define SWITCH_BITS_PER_BYTE 8
|
||||
typedef uint8_t switch_byte_t;
|
||||
typedef uint8_t switch_byte_t;
|
||||
|
||||
typedef enum {
|
||||
SWITCH_FALSE = 0,
|
||||
@@ -137,7 +125,7 @@ typedef enum {
|
||||
SSM_NA,
|
||||
SSM_PRONOUNCED,
|
||||
SSM_ITERATED,
|
||||
SSM_COUNTED
|
||||
SSM_COUNTED
|
||||
} switch_say_method_t;
|
||||
|
||||
typedef enum {
|
||||
@@ -242,12 +230,12 @@ typedef enum {
|
||||
} switch_caller_profile_flag_t;
|
||||
|
||||
typedef enum {
|
||||
SWITCH_AUDIO_COL_STR_TITLE = 0x01,
|
||||
SWITCH_AUDIO_COL_STR_COPYRIGHT = 0x02,
|
||||
SWITCH_AUDIO_COL_STR_SOFTWARE = 0x03,
|
||||
SWITCH_AUDIO_COL_STR_ARTIST = 0x04,
|
||||
SWITCH_AUDIO_COL_STR_COMMENT = 0x05,
|
||||
SWITCH_AUDIO_COL_STR_DATE = 0x06
|
||||
SWITCH_AUDIO_COL_STR_TITLE = 0x01,
|
||||
SWITCH_AUDIO_COL_STR_COPYRIGHT = 0x02,
|
||||
SWITCH_AUDIO_COL_STR_SOFTWARE = 0x03,
|
||||
SWITCH_AUDIO_COL_STR_ARTIST = 0x04,
|
||||
SWITCH_AUDIO_COL_STR_COMMENT = 0x05,
|
||||
SWITCH_AUDIO_COL_STR_DATE = 0x06
|
||||
} switch_audio_col_t;
|
||||
|
||||
typedef enum {
|
||||
@@ -269,10 +257,10 @@ typedef enum {
|
||||
</pre>
|
||||
*/
|
||||
typedef enum {
|
||||
SWITCH_VAD_FLAG_TALKING = ( 1 << 0 ),
|
||||
SWITCH_VAD_FLAG_EVENTS_TALK = ( 1 << 1 ),
|
||||
SWITCH_VAD_FLAG_EVENTS_NOTALK = ( 1 << 2 ),
|
||||
SWITCH_VAD_FLAG_CNG = ( 1 << 3)
|
||||
SWITCH_VAD_FLAG_TALKING = (1 << 0),
|
||||
SWITCH_VAD_FLAG_EVENTS_TALK = (1 << 1),
|
||||
SWITCH_VAD_FLAG_EVENTS_NOTALK = (1 << 2),
|
||||
SWITCH_VAD_FLAG_CNG = (1 << 3)
|
||||
} switch_vad_flag_t;
|
||||
|
||||
#define SWITCH_RTP_CNG_PAYLOAD 13
|
||||
@@ -299,7 +287,7 @@ typedef enum {
|
||||
</pre>
|
||||
*/
|
||||
typedef enum {
|
||||
SWITCH_RTP_FLAG_NOBLOCK = ( 1 << 0),
|
||||
SWITCH_RTP_FLAG_NOBLOCK = (1 << 0),
|
||||
SWITCH_RTP_FLAG_IO = (1 << 1),
|
||||
SWITCH_RTP_FLAG_USE_TIMER = (1 << 2),
|
||||
SWITCH_RTP_FLAG_TIMER_RECLOCK = (1 << 3),
|
||||
@@ -308,8 +296,8 @@ typedef enum {
|
||||
SWITCH_RTP_FLAG_RAW_WRITE = (1 << 6),
|
||||
SWITCH_RTP_FLAG_GOOGLEHACK = (1 << 7),
|
||||
SWITCH_RTP_FLAG_VAD = (1 << 8),
|
||||
SWITCH_RTP_FLAG_BREAK = ( 1 << 9),
|
||||
SWITCH_RTP_FLAG_MINI = ( 1 << 10),
|
||||
SWITCH_RTP_FLAG_BREAK = (1 << 9),
|
||||
SWITCH_RTP_FLAG_MINI = (1 << 10),
|
||||
SWITCH_RTP_FLAG_DATAWAIT = (1 << 11),
|
||||
SWITCH_RTP_FLAG_BUGGY_2833 = (1 << 12),
|
||||
SWITCH_RTP_FLAG_PASS_RFC2833 = (1 << 13),
|
||||
@@ -453,7 +441,7 @@ typedef enum {
|
||||
typedef enum {
|
||||
SWITCH_LOG_CONSOLE = 8,
|
||||
SWITCH_LOG_DEBUG = 7,
|
||||
SWITCH_LOG_INFO = 6,
|
||||
SWITCH_LOG_INFO = 6,
|
||||
SWITCH_LOG_NOTICE = 5,
|
||||
SWITCH_LOG_WARNING = 4,
|
||||
SWITCH_LOG_ERROR = 3,
|
||||
@@ -512,7 +500,7 @@ typedef enum {
|
||||
CS_HOLD,
|
||||
CS_HIBERNATE,
|
||||
CS_HANGUP,
|
||||
CS_DONE
|
||||
CS_DONE
|
||||
} switch_channel_state_t;
|
||||
|
||||
|
||||
@@ -544,25 +532,25 @@ CF_RING_READY = (1 << 18) - Channel is ready to send ringback
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
CF_ANSWERED = (1 << 0),
|
||||
CF_OUTBOUND = (1 << 1),
|
||||
CF_EARLY_MEDIA = (1 << 2),
|
||||
CF_ORIGINATOR = (1 << 3),
|
||||
CF_TRANSFER = (1 << 4),
|
||||
CF_ACCEPT_CNG = (1 << 5),
|
||||
CF_LOCK_THREAD = (1 << 6),
|
||||
CF_BRIDGED = (1 << 7),
|
||||
CF_HOLD = (1 << 8),
|
||||
CF_SERVICE = (1 << 9),
|
||||
CF_TAGGED = (1 << 10),
|
||||
CF_WINNER = (1 << 11),
|
||||
CF_CONTROLLED = (1 << 12),
|
||||
CF_NOMEDIA = (1 << 13),
|
||||
CF_SUSPEND = (1 << 14),
|
||||
CF_EVENT_PARSE = (1 << 15),
|
||||
CF_REPEAT_STATE = (1 << 16),
|
||||
CF_GEN_RINGBACK = (1 << 17),
|
||||
CF_RING_READY = (1 << 18)
|
||||
CF_ANSWERED = (1 << 0),
|
||||
CF_OUTBOUND = (1 << 1),
|
||||
CF_EARLY_MEDIA = (1 << 2),
|
||||
CF_ORIGINATOR = (1 << 3),
|
||||
CF_TRANSFER = (1 << 4),
|
||||
CF_ACCEPT_CNG = (1 << 5),
|
||||
CF_LOCK_THREAD = (1 << 6),
|
||||
CF_BRIDGED = (1 << 7),
|
||||
CF_HOLD = (1 << 8),
|
||||
CF_SERVICE = (1 << 9),
|
||||
CF_TAGGED = (1 << 10),
|
||||
CF_WINNER = (1 << 11),
|
||||
CF_CONTROLLED = (1 << 12),
|
||||
CF_NOMEDIA = (1 << 13),
|
||||
CF_SUSPEND = (1 << 14),
|
||||
CF_EVENT_PARSE = (1 << 15),
|
||||
CF_REPEAT_STATE = (1 << 16),
|
||||
CF_GEN_RINGBACK = (1 << 17),
|
||||
CF_RING_READY = (1 << 18)
|
||||
} switch_channel_flag_t;
|
||||
|
||||
|
||||
@@ -600,7 +588,7 @@ typedef enum {
|
||||
SWITCH_SIG_NONE,
|
||||
SWITCH_SIG_KILL,
|
||||
SWITCH_SIG_XFER,
|
||||
SWITCH_SIG_BREAK
|
||||
SWITCH_SIG_BREAK
|
||||
} switch_signal_t;
|
||||
|
||||
/*!
|
||||
@@ -618,14 +606,14 @@ SWITCH_CODEC_FLAG_PASSTHROUGH = (1 << 7) - Passthrough only
|
||||
</pre>
|
||||
*/
|
||||
typedef enum {
|
||||
SWITCH_CODEC_FLAG_ENCODE = (1 << 0),
|
||||
SWITCH_CODEC_FLAG_DECODE = (1 << 1),
|
||||
SWITCH_CODEC_FLAG_SILENCE_START = (1 << 2),
|
||||
SWITCH_CODEC_FLAG_SILENCE_STOP = (1 << 3),
|
||||
SWITCH_CODEC_FLAG_SILENCE = (1 << 4),
|
||||
SWITCH_CODEC_FLAG_FREE_POOL = (1 << 5),
|
||||
SWITCH_CODEC_FLAG_AAL2 = (1 << 6),
|
||||
SWITCH_CODEC_FLAG_PASSTHROUGH = (1 << 7)
|
||||
SWITCH_CODEC_FLAG_ENCODE = (1 << 0),
|
||||
SWITCH_CODEC_FLAG_DECODE = (1 << 1),
|
||||
SWITCH_CODEC_FLAG_SILENCE_START = (1 << 2),
|
||||
SWITCH_CODEC_FLAG_SILENCE_STOP = (1 << 3),
|
||||
SWITCH_CODEC_FLAG_SILENCE = (1 << 4),
|
||||
SWITCH_CODEC_FLAG_FREE_POOL = (1 << 5),
|
||||
SWITCH_CODEC_FLAG_AAL2 = (1 << 6),
|
||||
SWITCH_CODEC_FLAG_PASSTHROUGH = (1 << 7)
|
||||
} switch_codec_flag_t;
|
||||
|
||||
|
||||
@@ -641,12 +629,12 @@ SWITCH_SPEECH_FLAG_PAUSE = (1 << 4) - Pause toggle for playback
|
||||
</pre>
|
||||
*/
|
||||
typedef enum {
|
||||
SWITCH_SPEECH_FLAG_NONE = 0,
|
||||
SWITCH_SPEECH_FLAG_HASTEXT = (1 << 0),
|
||||
SWITCH_SPEECH_FLAG_PEEK = (1 << 1),
|
||||
SWITCH_SPEECH_FLAG_FREE_POOL = (1 << 2),
|
||||
SWITCH_SPEECH_FLAG_BLOCKING = (1 << 3),
|
||||
SWITCH_SPEECH_FLAG_PAUSE = (1 << 4)
|
||||
SWITCH_SPEECH_FLAG_NONE = 0,
|
||||
SWITCH_SPEECH_FLAG_HASTEXT = (1 << 0),
|
||||
SWITCH_SPEECH_FLAG_PEEK = (1 << 1),
|
||||
SWITCH_SPEECH_FLAG_FREE_POOL = (1 << 2),
|
||||
SWITCH_SPEECH_FLAG_BLOCKING = (1 << 3),
|
||||
SWITCH_SPEECH_FLAG_PAUSE = (1 << 4)
|
||||
|
||||
} switch_speech_flag_t;
|
||||
|
||||
@@ -662,12 +650,12 @@ SWITCH_ASR_FLAG_AUTO_RESUME = (1 << 4) - Auto Resume
|
||||
</pre>
|
||||
*/
|
||||
typedef enum {
|
||||
SWITCH_ASR_FLAG_NONE = 0,
|
||||
SWITCH_ASR_FLAG_DATA = (1 << 0),
|
||||
SWITCH_ASR_FLAG_FREE_POOL = (1 << 1),
|
||||
SWITCH_ASR_FLAG_CLOSED = (1 << 2),
|
||||
SWITCH_ASR_FLAG_FIRE_EVENTS = (1 << 3),
|
||||
SWITCH_ASR_FLAG_AUTO_RESUME = (1 << 4)
|
||||
SWITCH_ASR_FLAG_NONE = 0,
|
||||
SWITCH_ASR_FLAG_DATA = (1 << 0),
|
||||
SWITCH_ASR_FLAG_FREE_POOL = (1 << 1),
|
||||
SWITCH_ASR_FLAG_CLOSED = (1 << 2),
|
||||
SWITCH_ASR_FLAG_FIRE_EVENTS = (1 << 3),
|
||||
SWITCH_ASR_FLAG_AUTO_RESUME = (1 << 4)
|
||||
} switch_asr_flag_t;
|
||||
|
||||
/*!
|
||||
@@ -678,7 +666,7 @@ SWITCH_DIRECTORY_FLAG_FREE_POOL = (1 << 0) - Free interface's pool on destruct
|
||||
</pre>
|
||||
*/
|
||||
typedef enum {
|
||||
SWITCH_DIRECTORY_FLAG_FREE_POOL = (1 << 0),
|
||||
SWITCH_DIRECTORY_FLAG_FREE_POOL = (1 << 0),
|
||||
|
||||
} switch_directory_flag_t;
|
||||
|
||||
@@ -708,7 +696,7 @@ SWITCH_TIMER_FLAG_FREE_POOL = (1 << 0) - Free timer's pool on destruction
|
||||
</pre>
|
||||
*/
|
||||
typedef enum {
|
||||
SWITCH_TIMER_FLAG_FREE_POOL = (1 << 0),
|
||||
SWITCH_TIMER_FLAG_FREE_POOL = (1 << 0),
|
||||
} switch_timer_flag_t;
|
||||
|
||||
|
||||
@@ -747,18 +735,18 @@ SWITCH_FILE_OPEN = (1 << 11) - File is open
|
||||
</pre>
|
||||
*/
|
||||
typedef enum {
|
||||
SWITCH_FILE_FLAG_READ = (1 << 0),
|
||||
SWITCH_FILE_FLAG_WRITE = (1 << 1),
|
||||
SWITCH_FILE_FLAG_FREE_POOL = (1 << 2),
|
||||
SWITCH_FILE_DATA_SHORT = (1 << 3),
|
||||
SWITCH_FILE_DATA_INT = (1 << 4),
|
||||
SWITCH_FILE_DATA_FLOAT = (1 << 5),
|
||||
SWITCH_FILE_DATA_DOUBLE = (1 << 6),
|
||||
SWITCH_FILE_DATA_RAW = (1 << 7),
|
||||
SWITCH_FILE_PAUSE = (1 << 8),
|
||||
SWITCH_FILE_NATIVE = (1 << 9),
|
||||
SWITCH_FILE_SEEK = (1 << 10),
|
||||
SWITCH_FILE_OPEN = (1 << 11)
|
||||
SWITCH_FILE_FLAG_READ = (1 << 0),
|
||||
SWITCH_FILE_FLAG_WRITE = (1 << 1),
|
||||
SWITCH_FILE_FLAG_FREE_POOL = (1 << 2),
|
||||
SWITCH_FILE_DATA_SHORT = (1 << 3),
|
||||
SWITCH_FILE_DATA_INT = (1 << 4),
|
||||
SWITCH_FILE_DATA_FLOAT = (1 << 5),
|
||||
SWITCH_FILE_DATA_DOUBLE = (1 << 6),
|
||||
SWITCH_FILE_DATA_RAW = (1 << 7),
|
||||
SWITCH_FILE_PAUSE = (1 << 8),
|
||||
SWITCH_FILE_NATIVE = (1 << 9),
|
||||
SWITCH_FILE_SEEK = (1 << 10),
|
||||
SWITCH_FILE_OPEN = (1 << 11)
|
||||
} switch_file_flag_t;
|
||||
|
||||
typedef enum {
|
||||
@@ -951,19 +939,8 @@ typedef struct switch_codec_implementation switch_codec_implementation_t;
|
||||
typedef struct switch_buffer switch_buffer_t;
|
||||
typedef struct switch_codec_settings switch_codec_settings_t;
|
||||
|
||||
typedef struct switch_io_event_hook_outgoing_channel switch_io_event_hook_outgoing_channel_t;
|
||||
typedef struct switch_io_event_hook_answer_channel switch_io_event_hook_answer_channel_t;
|
||||
typedef struct switch_io_event_hook_receive_message switch_io_event_hook_receive_message_t;
|
||||
typedef struct switch_io_event_hook_receive_event switch_io_event_hook_receive_event_t;
|
||||
typedef struct switch_io_event_hook_read_frame switch_io_event_hook_read_frame_t;
|
||||
typedef struct switch_io_event_hook_write_frame switch_io_event_hook_write_frame_t;
|
||||
typedef struct switch_io_event_hook_kill_channel switch_io_event_hook_kill_channel_t;
|
||||
typedef struct switch_io_event_hook_waitfor_read switch_io_event_hook_waitfor_read_t;
|
||||
typedef struct switch_io_event_hook_waitfor_write switch_io_event_hook_waitfor_write_t;
|
||||
typedef struct switch_io_event_hook_send_dtmf switch_io_event_hook_send_dtmf_t;
|
||||
typedef struct switch_io_event_hook_state_change switch_io_event_hook_state_change_t;
|
||||
|
||||
typedef struct switch_io_routines switch_io_routines_t;
|
||||
typedef struct switch_io_event_hooks switch_io_event_hooks_t;
|
||||
typedef struct switch_speech_handle switch_speech_handle_t;
|
||||
typedef struct switch_asr_handle switch_asr_handle_t;
|
||||
typedef struct switch_directory_handle switch_directory_handle_t;
|
||||
@@ -982,43 +959,30 @@ typedef struct switch_chat_interface switch_chat_interface_t;
|
||||
typedef struct switch_management_interface switch_management_interface_t;
|
||||
typedef struct switch_core_port_allocator switch_core_port_allocator_t;
|
||||
typedef struct switch_media_bug switch_media_bug_t;
|
||||
typedef switch_bool_t (*switch_media_bug_callback_t)(switch_media_bug_t *, void *, switch_abc_type_t);
|
||||
typedef void (*switch_application_function_t)(switch_core_session_t *, char *);
|
||||
typedef void (*switch_event_callback_t)(switch_event_t *);
|
||||
typedef switch_caller_extension_t *(*switch_dialplan_hunt_function_t)(switch_core_session_t *, void *);
|
||||
typedef struct switch_core_scheduler_task switch_core_scheduler_task_t;
|
||||
typedef void (*switch_core_scheduler_func_t)(switch_core_scheduler_task_t *task);
|
||||
typedef switch_status_t (*switch_state_handler_t)(switch_core_session_t *);
|
||||
typedef switch_status_t (*switch_outgoing_channel_hook_t)(switch_core_session_t *, switch_caller_profile_t *, switch_core_session_t *);
|
||||
typedef switch_status_t (*switch_answer_channel_hook_t)(switch_core_session_t *);
|
||||
typedef switch_status_t (*switch_receive_message_hook_t)(switch_core_session_t *, switch_core_session_message_t *);
|
||||
typedef switch_status_t (*switch_receive_event_hook_t)(switch_core_session_t *, switch_event_t *);
|
||||
typedef switch_status_t (*switch_read_frame_hook_t)(switch_core_session_t *, switch_frame_t **, int, switch_io_flag_t, int);
|
||||
typedef switch_status_t (*switch_write_frame_hook_t)(switch_core_session_t *, switch_frame_t *, int, switch_io_flag_t, int);
|
||||
typedef switch_status_t (*switch_kill_channel_hook_t)(switch_core_session_t *, int);
|
||||
typedef switch_status_t (*switch_waitfor_read_hook_t)(switch_core_session_t *, int, int);
|
||||
typedef switch_status_t (*switch_waitfor_write_hook_t)(switch_core_session_t *, int, int);
|
||||
typedef switch_status_t (*switch_send_dtmf_hook_t)(switch_core_session_t *, char *);
|
||||
typedef switch_status_t (*switch_state_change_hook_t)(switch_core_session_t *);
|
||||
typedef switch_bool_t (*switch_media_bug_callback_t) (switch_media_bug_t *, void *, switch_abc_type_t);
|
||||
typedef void (*switch_application_function_t) (switch_core_session_t *, char *);
|
||||
typedef void (*switch_event_callback_t) (switch_event_t *);
|
||||
typedef switch_caller_extension_t *(*switch_dialplan_hunt_function_t) (switch_core_session_t *, void *);
|
||||
typedef struct switch_scheduler_task switch_scheduler_task_t;
|
||||
typedef void (*switch_scheduler_func_t) (switch_scheduler_task_t *task);
|
||||
typedef switch_status_t (*switch_state_handler_t) (switch_core_session_t *);
|
||||
typedef struct switch_stream_handle switch_stream_handle_t;
|
||||
typedef switch_status_t (*switch_stream_handle_write_function_t)(switch_stream_handle_t *handle, const char *fmt, ...);
|
||||
typedef switch_status_t (*switch_api_function_t)(char *in, switch_core_session_t *session, switch_stream_handle_t *stream);
|
||||
typedef switch_status_t (*switch_input_callback_function_t)(switch_core_session_t *session,
|
||||
void *input,
|
||||
switch_input_type_t input_type,
|
||||
void *buf,
|
||||
unsigned int buflen);
|
||||
typedef switch_status_t (*switch_stream_handle_write_function_t) (switch_stream_handle_t *handle, const char *fmt, ...);
|
||||
typedef switch_status_t (*switch_api_function_t) (char *in, switch_core_session_t *session,
|
||||
switch_stream_handle_t *stream);
|
||||
typedef switch_status_t (*switch_input_callback_function_t) (switch_core_session_t *session, void *input,
|
||||
switch_input_type_t input_type, void *buf,
|
||||
unsigned int buflen);
|
||||
typedef struct switch_say_interface switch_say_interface_t;
|
||||
typedef struct {
|
||||
switch_input_callback_function_t input_callback;
|
||||
void *buf;
|
||||
uint32_t buflen;
|
||||
switch_input_callback_function_t input_callback;
|
||||
void *buf;
|
||||
uint32_t buflen;
|
||||
} switch_input_args_t;
|
||||
typedef switch_status_t (*switch_say_callback_t)(switch_core_session_t *session,
|
||||
char *tosay,
|
||||
switch_say_type_t type,
|
||||
switch_say_method_t method,
|
||||
switch_input_args_t *args);
|
||||
typedef switch_status_t (*switch_say_callback_t) (switch_core_session_t *session,
|
||||
char *tosay,
|
||||
switch_say_type_t type,
|
||||
switch_say_method_t method, switch_input_args_t *args);
|
||||
typedef switch_status_t (*switch_module_load_t) (switch_loadable_module_interface_t **, char *);
|
||||
typedef switch_status_t (*switch_module_reload_t) (void);
|
||||
typedef switch_status_t (*switch_module_pause_t) (void);
|
||||
@@ -1028,12 +992,10 @@ typedef switch_status_t (*switch_module_runtime_t) (void);
|
||||
typedef switch_status_t (*switch_module_shutdown_t) (void);
|
||||
typedef struct switch_xml *switch_xml_t;
|
||||
typedef struct switch_core_time_duration switch_core_time_duration_t;
|
||||
typedef switch_xml_t (*switch_xml_search_function_t)(const char *section,
|
||||
typedef switch_xml_t(*switch_xml_search_function_t) (const char *section,
|
||||
const char *tag_name,
|
||||
const char *key_name,
|
||||
const char *key_value,
|
||||
const char *params,
|
||||
void *user_data);
|
||||
const char *key_value, const char *params, void *user_data);
|
||||
|
||||
/* things we don't deserve to know about */
|
||||
/*! \brief A channel */
|
||||
@@ -1046,9 +1008,7 @@ struct switch_media_bug;
|
||||
struct switch_ivr_digit_stream_parser;
|
||||
|
||||
SWITCH_END_EXTERN_C
|
||||
|
||||
#endif
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
|
||||
@@ -41,24 +41,19 @@
|
||||
#include <switch.h>
|
||||
|
||||
SWITCH_BEGIN_EXTERN_C
|
||||
|
||||
#define switch_bytes_per_frame(rate, interval) ((uint32_t)((float)rate / (1000.0f / (float)interval)))
|
||||
|
||||
#define SWITCH_SMAX 32767
|
||||
#define SWITCH_SMIN -32768
|
||||
#define switch_normalize_to_16bit(n) if (n > SWITCH_SMAX) n = SWITCH_SMAX / 2; else if (n < SWITCH_SMIN) n = SWITCH_SMIN / 2;
|
||||
|
||||
#define switch_codec2str(codec,buf,len) snprintf(buf, len, "%s@%uk@%ui", \
|
||||
codec->implementation->iananame, \
|
||||
codec->implementation->samples_per_second, \
|
||||
codec->implementation->microseconds_per_frame / 1000)
|
||||
|
||||
#ifdef WIN32
|
||||
#define switch_is_file_path(file) (*(file +1) == ':' || *file == '/' || strstr(file, SWITCH_URL_SEPARATOR))
|
||||
#else
|
||||
#define switch_is_file_path(file) ((*file == '/') || strstr(file, SWITCH_URL_SEPARATOR))
|
||||
#endif
|
||||
|
||||
/*!
|
||||
\brief Evaluate the truthfullness of a string expression
|
||||
\param expr a string expression
|
||||
@@ -69,7 +64,6 @@ SWITCH_BEGIN_EXTERN_C
|
||||
!strcasecmp(expr, "on") ||\
|
||||
!strcasecmp(expr, "true") ||\
|
||||
atoi(expr))) ? SWITCH_TRUE : SWITCH_FALSE
|
||||
|
||||
/*!
|
||||
\brief find local ip of the box
|
||||
\param buf the buffer to write the ip adress found into
|
||||
@@ -242,7 +236,8 @@ SWITCH_DECLARE(int) switch_socket_waitfor(switch_pollfd_t *poll, int ms);
|
||||
SWITCH_DECLARE(const char *) switch_cut_path(const char *in);
|
||||
|
||||
SWITCH_DECLARE(char *) switch_string_replace(const char *string, const char *search, const char *replace);
|
||||
SWITCH_DECLARE(switch_status_t) switch_string_match(const char *string, size_t string_len, const char *search, size_t search_len);
|
||||
SWITCH_DECLARE(switch_status_t) switch_string_match(const char *string, size_t string_len, const char *search,
|
||||
size_t search_len);
|
||||
|
||||
#define SWITCH_READ_ACCEPTABLE(status) (status == SWITCH_STATUS_SUCCESS || status == SWITCH_STATUS_BREAK)
|
||||
SWITCH_DECLARE(size_t) switch_url_encode(char *url, char *buf, size_t len);
|
||||
@@ -258,9 +253,7 @@ SWITCH_DECLARE(char *) switch_url_decode(char *s);
|
||||
#endif
|
||||
|
||||
SWITCH_END_EXTERN_C
|
||||
|
||||
#endif
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
|
||||
+35
-40
@@ -62,40 +62,38 @@
|
||||
///\ingroup core1
|
||||
///\{
|
||||
SWITCH_BEGIN_EXTERN_C
|
||||
|
||||
#define SWITCH_XML_BUFSIZE 1024 // size of internal memory buffers
|
||||
|
||||
typedef enum {
|
||||
SWITCH_XML_ROOT = (1 << 0), // root
|
||||
SWITCH_XML_NAMEM = (1 << 1), // name is malloced
|
||||
SWITCH_XML_TXTM = (1 << 2), // txt is malloced
|
||||
SWITCH_XML_DUP = (1 << 3) // attribute name and value are strduped
|
||||
#define SWITCH_XML_BUFSIZE 1024 // size of internal memory buffers
|
||||
typedef enum {
|
||||
SWITCH_XML_ROOT = (1 << 0), // root
|
||||
SWITCH_XML_NAMEM = (1 << 1), // name is malloced
|
||||
SWITCH_XML_TXTM = (1 << 2), // txt is malloced
|
||||
SWITCH_XML_DUP = (1 << 3) // attribute name and value are strduped
|
||||
} switch_xml_flag_t;
|
||||
|
||||
/*! \brief A representation of an XML tree */
|
||||
struct switch_xml {
|
||||
/*! tag name */
|
||||
char *name;
|
||||
char *name;
|
||||
/*! tag attributes { name, value, name, value, ... NULL } */
|
||||
char **attr;
|
||||
char **attr;
|
||||
/*! tag character content, empty string if none */
|
||||
char *txt;
|
||||
/*! path to free on destroy*/
|
||||
char *free_path;
|
||||
char *txt;
|
||||
/*! path to free on destroy */
|
||||
char *free_path;
|
||||
/*! tag offset from start of parent tag character content */
|
||||
switch_size_t off;
|
||||
switch_size_t off;
|
||||
/*! next tag with same name in this section at this depth */
|
||||
switch_xml_t next;
|
||||
/*! next tag with different name in same section and depth*/
|
||||
switch_xml_t sibling;
|
||||
switch_xml_t next;
|
||||
/*! next tag with different name in same section and depth */
|
||||
switch_xml_t sibling;
|
||||
/*! next tag, same section and depth, in original order */
|
||||
switch_xml_t ordered;
|
||||
/*! head of sub tag list, NULL if none*/
|
||||
switch_xml_t child;
|
||||
/*! parent tag, NULL if current tag is root tag*/
|
||||
switch_xml_t parent;
|
||||
switch_xml_t ordered;
|
||||
/*! head of sub tag list, NULL if none */
|
||||
switch_xml_t child;
|
||||
/*! parent tag, NULL if current tag is root tag */
|
||||
switch_xml_t parent;
|
||||
/*! flags */
|
||||
uint32_t flags;
|
||||
uint32_t flags;
|
||||
};
|
||||
|
||||
///\brief Given a string of xml data and its length, parses it and creates an switch_xml
|
||||
@@ -118,13 +116,13 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_parse_fd(int fd);
|
||||
///\param file a file to parse
|
||||
///\return a formated xml node or NULL
|
||||
SWITCH_DECLARE(switch_xml_t) switch_xml_parse_file(const char *file);
|
||||
|
||||
|
||||
///\brief Wrapper for switch_xml_parse_str() that accepts a file stream. Reads the entire
|
||||
///\ stream into memory and then parses it. For xml files, use switch_xml_parse_file()
|
||||
///\ or switch_xml_parse_fd()
|
||||
///\param fp a FILE pointer to parse
|
||||
///\return an xml node or NULL
|
||||
SWITCH_DECLARE(switch_xml_t) switch_xml_parse_fp(FILE *fp);
|
||||
SWITCH_DECLARE(switch_xml_t) switch_xml_parse_fp(FILE * fp);
|
||||
|
||||
///\brief returns the first child tag (one level deeper) with the given name or NULL
|
||||
///\ if not found
|
||||
@@ -139,7 +137,8 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_child(switch_xml_t xml, const char *name
|
||||
///\param attrname the attribute name
|
||||
///\param value the value
|
||||
///\return an xml node or NULL
|
||||
SWITCH_DECLARE(switch_xml_t) switch_xml_find_child(switch_xml_t node, const char *childname, const char *attrname, const char *value);
|
||||
SWITCH_DECLARE(switch_xml_t) switch_xml_find_child(switch_xml_t node, const char *childname, const char *attrname,
|
||||
const char *value);
|
||||
|
||||
///\brief returns the next tag of the same name in the same section and depth or NULL
|
||||
///\ if not found
|
||||
@@ -152,7 +151,7 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_find_child(switch_xml_t node, const char
|
||||
///\param xml the xml node
|
||||
///\param idx the index
|
||||
///\return an xml node or NULL
|
||||
switch_xml_t switch_xml_idx(switch_xml_t xml, int idx);
|
||||
switch_xml_t switch_xml_idx(switch_xml_t xml, int idx);
|
||||
|
||||
///\brief returns the name of the given tag
|
||||
///\param xml the xml node
|
||||
@@ -184,7 +183,7 @@ SWITCH_DECLARE(const char *) switch_xml_attr_soft(switch_xml_t xml, const char *
|
||||
///\ Returns NULL if not found.
|
||||
///\param xml the xml node
|
||||
///\return an xml node or NULL
|
||||
SWITCH_DECLARE(switch_xml_t) switch_xml_get(switch_xml_t xml, ...);
|
||||
SWITCH_DECLARE(switch_xml_t) switch_xml_get(switch_xml_t xml,...);
|
||||
|
||||
///\brief Converts an switch_xml structure back to xml. Returns a string of xml data that
|
||||
///\ must be freed.
|
||||
@@ -203,7 +202,7 @@ SWITCH_DECLARE(const char **) switch_xml_pi(switch_xml_t xml, const char *target
|
||||
///\param xml the xml node
|
||||
///\note in the case of the root node the readlock will be lifted
|
||||
SWITCH_DECLARE(void) switch_xml_free(switch_xml_t xml);
|
||||
|
||||
|
||||
///\brief returns parser error message or empty string if none
|
||||
///\param xml the xml node
|
||||
///\return the error string or nothing
|
||||
@@ -224,7 +223,7 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_new(const char *name);
|
||||
///\param name the name of the tag
|
||||
///\param off the offset
|
||||
///\return an xml node or NULL
|
||||
switch_xml_t switch_xml_add_child(switch_xml_t xml, const char *name, switch_size_t off);
|
||||
switch_xml_t switch_xml_add_child(switch_xml_t xml, const char *name, switch_size_t off);
|
||||
|
||||
///\brief wrapper for switch_xml_add_child() that strdup()s name
|
||||
///\param xml the xml node
|
||||
@@ -237,7 +236,7 @@ switch_xml_t switch_xml_add_child(switch_xml_t xml, const char *name, switch_siz
|
||||
///\param xml the xml node
|
||||
///\param txt the text
|
||||
///\return an xml node or NULL
|
||||
switch_xml_t switch_xml_set_txt(switch_xml_t xml, const char *txt);
|
||||
switch_xml_t switch_xml_set_txt(switch_xml_t xml, const char *txt);
|
||||
|
||||
///\brief wrapper for switch_xml_set_txt() that strdup()s txt
|
||||
///\ sets the character content for the given tag and returns the tag
|
||||
@@ -316,16 +315,14 @@ SWITCH_DECLARE(switch_status_t) switch_xml_locate(const char *section,
|
||||
const char *tag_name,
|
||||
const char *key_name,
|
||||
const char *key_value,
|
||||
switch_xml_t *root,
|
||||
switch_xml_t *node,
|
||||
const char *params);
|
||||
|
||||
switch_xml_t * root, switch_xml_t * node, const char *params);
|
||||
|
||||
///\brief open a config in the core registry
|
||||
///\param file_path the name of the config section e.g. modules.conf
|
||||
///\param node a pointer to point to the node if it is found
|
||||
///\param params optional URL formatted params to pass to external gateways
|
||||
///\return the root xml node associated with the current request or NULL
|
||||
SWITCH_DECLARE(switch_xml_t) switch_xml_open_cfg(const char *file_path, switch_xml_t *node, const char *params);
|
||||
SWITCH_DECLARE(switch_xml_t) switch_xml_open_cfg(const char *file_path, switch_xml_t * node, const char *params);
|
||||
|
||||
///\brief bind a search function to an external gateway
|
||||
///\param function the search function to bind
|
||||
@@ -333,7 +330,8 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_open_cfg(const char *file_path, switch_x
|
||||
///\param user_data a pointer to private data to be used during the callback
|
||||
///\return SWITCH_STATUS_SUCCESS if successful
|
||||
///\note gateway functions will be executed in the order they were binded until a success is found else the root registry will be used
|
||||
SWITCH_DECLARE(switch_status_t) switch_xml_bind_search_function(switch_xml_search_function_t function, switch_xml_section_t sections, void *user_data);
|
||||
SWITCH_DECLARE(switch_status_t) switch_xml_bind_search_function(switch_xml_search_function_t function,
|
||||
switch_xml_section_t sections, void *user_data);
|
||||
|
||||
///\brief parse a string for a list of sections
|
||||
///\param str a | delimited list of section names
|
||||
@@ -341,11 +339,8 @@ SWITCH_DECLARE(switch_status_t) switch_xml_bind_search_function(switch_xml_searc
|
||||
SWITCH_DECLARE(switch_xml_section_t) switch_xml_parse_section_string(const char *str);
|
||||
|
||||
SWITCH_END_EXTERN_C
|
||||
|
||||
///\}
|
||||
|
||||
#endif // _SWITCH_XML_H
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
|
||||
@@ -44,11 +44,11 @@ static void audio_bridge_function(switch_core_session_t *session, char *data)
|
||||
char *var;
|
||||
uint8_t no_media_bridge = 0;
|
||||
switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
|
||||
uint8_t do_continue = 0;
|
||||
uint8_t do_continue = 0;
|
||||
|
||||
if (switch_strlen_zero(data)) {
|
||||
return;
|
||||
}
|
||||
if (switch_strlen_zero(data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
caller_channel = switch_core_session_get_channel(session);
|
||||
assert(caller_channel != NULL);
|
||||
@@ -60,43 +60,50 @@ static void audio_bridge_function(switch_core_session_t *session, char *data)
|
||||
if ((var = switch_channel_get_variable(caller_channel, "continue_on_fail"))) {
|
||||
do_continue = switch_true(var);
|
||||
}
|
||||
|
||||
if (switch_channel_test_flag(caller_channel, CF_NOMEDIA) || ((var = switch_channel_get_variable(caller_channel, "no_media")) && switch_true(var))) {
|
||||
if (!switch_channel_test_flag(caller_channel, CF_ANSWERED) && !switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA)) {
|
||||
|
||||
if (switch_channel_test_flag(caller_channel, CF_NOMEDIA)
|
||||
|| ((var = switch_channel_get_variable(caller_channel, "no_media")) && switch_true(var))) {
|
||||
if (!switch_channel_test_flag(caller_channel, CF_ANSWERED)
|
||||
&& !switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA)) {
|
||||
switch_channel_set_flag(caller_channel, CF_NOMEDIA);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Channel is already up, delaying point-to-point mode 'till both legs are up.\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
|
||||
"Channel is already up, delaying point-to-point mode 'till both legs are up.\n");
|
||||
no_media_bridge = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (switch_ivr_originate(session, &peer_session, &cause, data, timelimit, NULL, NULL, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Originate Failed. Cause: %s\n", switch_channel_cause2str(cause));
|
||||
if (!do_continue && cause != SWITCH_CAUSE_NO_ANSWER) {
|
||||
/* All Causes besides NO_ANSWER terminate the originating session unless continue_on_fail is set.
|
||||
We will pass the fail cause on when we hangup.*/
|
||||
switch_channel_hangup(caller_channel, cause);
|
||||
}
|
||||
/* Otherwise.. nobody answered. Go back to the dialplan instructions in case there was more to do. */
|
||||
if (switch_ivr_originate(session, &peer_session, &cause, data, timelimit, NULL, NULL, NULL, NULL) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Originate Failed. Cause: %s\n",
|
||||
switch_channel_cause2str(cause));
|
||||
if (!do_continue && cause != SWITCH_CAUSE_NO_ANSWER) {
|
||||
/* All Causes besides NO_ANSWER terminate the originating session unless continue_on_fail is set.
|
||||
We will pass the fail cause on when we hangup. */
|
||||
switch_channel_hangup(caller_channel, cause);
|
||||
}
|
||||
/* Otherwise.. nobody answered. Go back to the dialplan instructions in case there was more to do. */
|
||||
return;
|
||||
} else {
|
||||
if (no_media_bridge) {
|
||||
switch_channel_t *peer_channel = switch_core_session_get_channel(peer_session);
|
||||
switch_frame_t *read_frame;
|
||||
/* SIP won't let us redir media until the call has been answered #$^#%& so we will proxy any early media until they do */
|
||||
while(switch_channel_ready(caller_channel) && switch_channel_ready(peer_channel) && !switch_channel_test_flag(peer_channel, CF_ANSWERED)) {
|
||||
switch_status_t status = switch_core_session_read_frame(peer_session, &read_frame, -1, 0);
|
||||
uint8_t bad = 1;
|
||||
switch_channel_t *peer_channel = switch_core_session_get_channel(peer_session);
|
||||
switch_frame_t *read_frame;
|
||||
/* SIP won't let us redir media until the call has been answered #$^#%& so we will proxy any early media until they do */
|
||||
while (switch_channel_ready(caller_channel) && switch_channel_ready(peer_channel)
|
||||
&& !switch_channel_test_flag(peer_channel, CF_ANSWERED)) {
|
||||
switch_status_t status = switch_core_session_read_frame(peer_session, &read_frame, -1, 0);
|
||||
uint8_t bad = 1;
|
||||
|
||||
if (SWITCH_READ_ACCEPTABLE(status) && switch_core_session_write_frame(session, read_frame, -1, 0) == SWITCH_STATUS_SUCCESS) {
|
||||
bad = 0;
|
||||
}
|
||||
if (bad) {
|
||||
switch_channel_hangup(caller_channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
switch_channel_hangup(peer_channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (SWITCH_READ_ACCEPTABLE(status)
|
||||
&& switch_core_session_write_frame(session, read_frame, -1, 0) == SWITCH_STATUS_SUCCESS) {
|
||||
bad = 0;
|
||||
}
|
||||
if (bad) {
|
||||
switch_channel_hangup(caller_channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
switch_channel_hangup(peer_channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Redirecting media to point-to-point mode.\n");
|
||||
switch_ivr_nomedia(switch_core_session_get_uuid(session), SMF_FORCE);
|
||||
@@ -130,7 +137,8 @@ static const switch_loadable_module_interface_t mod_bridgecall_module_interface
|
||||
/*.application_interface */ &bridge_application_interface
|
||||
};
|
||||
|
||||
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 */
|
||||
|
||||
@@ -76,18 +76,15 @@ static switch_status_t status_function(char *cmd, switch_core_session_t *session
|
||||
stream->write_function(stream, "<h1>FreeSWITCH Status</h1>\n<b>");
|
||||
}
|
||||
|
||||
stream->write_function(stream, "UP %u year%s, %u day%s, %u hour%s, %u minute%s, %u second%s, %u millisecond%s, %u microsecond%s\n",
|
||||
duration.yr, duration.yr == 1 ? "" : "s",
|
||||
duration.day, duration.day == 1 ? "" : "s",
|
||||
duration.hr, duration.hr == 1 ? "" : "s",
|
||||
duration.min, duration.min == 1 ? "" : "s",
|
||||
duration.sec, duration.sec == 1 ? "" : "s",
|
||||
duration.ms, duration.ms == 1 ? "" : "s",
|
||||
duration.mms, duration.mms == 1 ? "" : "s"
|
||||
);
|
||||
stream->write_function(stream,
|
||||
"UP %u year%s, %u day%s, %u hour%s, %u minute%s, %u second%s, %u millisecond%s, %u microsecond%s\n",
|
||||
duration.yr, duration.yr == 1 ? "" : "s", duration.day, duration.day == 1 ? "" : "s",
|
||||
duration.hr, duration.hr == 1 ? "" : "s", duration.min, duration.min == 1 ? "" : "s",
|
||||
duration.sec, duration.sec == 1 ? "" : "s", duration.ms, duration.ms == 1 ? "" : "s",
|
||||
duration.mms, duration.mms == 1 ? "" : "s");
|
||||
|
||||
stream->write_function(stream, "%d sessions\n", switch_core_session_count());
|
||||
|
||||
|
||||
if (html) {
|
||||
stream->write_function(stream, "</b>\n");
|
||||
}
|
||||
@@ -98,8 +95,10 @@ static switch_status_t status_function(char *cmd, switch_core_session_t *session
|
||||
int r;
|
||||
refresh++;
|
||||
r = atoi(refresh);
|
||||
if (r > 0) {
|
||||
stream->write_function(stream, "<META HTTP-EQUIV=REFRESH CONTENT=\"%d; URL=/api/status?refresh=%d%s\">\n", r, r, html ? "html=1" : "");
|
||||
if (r > 0) {
|
||||
stream->write_function(stream,
|
||||
"<META HTTP-EQUIV=REFRESH CONTENT=\"%d; URL=/api/status?refresh=%d%s\">\n", r, r,
|
||||
html ? "html=1" : "");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -120,7 +119,7 @@ static switch_status_t ctl_function(char *data, switch_core_session_t *session,
|
||||
|
||||
if ((mydata = strdup(data))) {
|
||||
argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
|
||||
|
||||
if (!strcmp(argv[0], "hupall")) {
|
||||
arg = 1;
|
||||
switch_core_session_ctl(SCSC_HUPALL, &arg);
|
||||
@@ -134,19 +133,20 @@ static switch_status_t ctl_function(char *data, switch_core_session_t *session,
|
||||
arg = 0;
|
||||
switch_core_session_ctl(SCSC_SHUTDOWN, &arg);
|
||||
} else {
|
||||
stream->write_function(stream, "INVALID COMMAND [%s]\nUSAGE: fsctl [hupall|pause|resume|shutdown]\n", argv[0]);
|
||||
stream->write_function(stream, "INVALID COMMAND [%s]\nUSAGE: fsctl [hupall|pause|resume|shutdown]\n",
|
||||
argv[0]);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
stream->write_function(stream, "OK\n");
|
||||
end:
|
||||
end:
|
||||
free(mydata);
|
||||
} else {
|
||||
stream->write_function(stream, "MEM ERR\n");
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
static switch_status_t load_function(char *mod, switch_core_session_t *session, switch_stream_handle_t *stream)
|
||||
@@ -161,7 +161,8 @@ static switch_status_t load_function(char *mod, switch_core_session_t *session,
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) mod, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) mod, SWITCH_TRUE) ==
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
stream->write_function(stream, "OK\n");
|
||||
} else {
|
||||
stream->write_function(stream, "ERROR\n");
|
||||
@@ -178,11 +179,11 @@ static switch_status_t reload_function(char *args, switch_core_session_t *sessio
|
||||
if (session) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
if ((xml_root = switch_xml_open_root(1, &err))) {
|
||||
switch_xml_free(xml_root);
|
||||
}
|
||||
|
||||
|
||||
stream->write_function(stream, "OK [%s]\n", err);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
@@ -213,13 +214,13 @@ static switch_status_t kill_function(char *dest, switch_core_session_t *isession
|
||||
static switch_status_t transfer_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
|
||||
{
|
||||
switch_core_session_t *session = NULL;
|
||||
char *argv[4] = {0};
|
||||
char *argv[4] = { 0 };
|
||||
int argc = 0;
|
||||
|
||||
if (isession) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
|
||||
if (switch_strlen_zero(cmd) || argc < 2 || argc > 4) {
|
||||
@@ -229,11 +230,11 @@ static switch_status_t transfer_function(char *cmd, switch_core_session_t *isess
|
||||
char *dest = argv[1];
|
||||
char *dp = argv[2];
|
||||
char *context = argv[3];
|
||||
|
||||
|
||||
if ((session = switch_core_session_locate(uuid))) {
|
||||
|
||||
if (switch_ivr_session_transfer(session, dest, dp, context) == SWITCH_STATUS_SUCCESS) {
|
||||
stream->write_function(stream, "OK\n");
|
||||
stream->write_function(stream, "OK\n");
|
||||
} else {
|
||||
stream->write_function(stream, "ERROR\n");
|
||||
}
|
||||
@@ -249,16 +250,17 @@ static switch_status_t transfer_function(char *cmd, switch_core_session_t *isess
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t sched_transfer_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
|
||||
static switch_status_t sched_transfer_function(char *cmd, switch_core_session_t *isession,
|
||||
switch_stream_handle_t *stream)
|
||||
{
|
||||
switch_core_session_t *session = NULL;
|
||||
char *argv[6] = {0};
|
||||
char *argv[6] = { 0 };
|
||||
int argc = 0;
|
||||
|
||||
if (isession) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
|
||||
if (switch_strlen_zero(cmd) || argc < 2 || argc > 5) {
|
||||
@@ -269,9 +271,9 @@ static switch_status_t sched_transfer_function(char *cmd, switch_core_session_t
|
||||
char *dp = argv[3];
|
||||
char *context = argv[4];
|
||||
time_t when;
|
||||
|
||||
|
||||
if (*argv[0] == '+') {
|
||||
when = time (NULL) + atol(argv[0] + 1);
|
||||
when = time(NULL) + atol(argv[0] + 1);
|
||||
} else {
|
||||
when = atol(argv[0]);
|
||||
}
|
||||
@@ -291,13 +293,13 @@ static switch_status_t sched_transfer_function(char *cmd, switch_core_session_t
|
||||
static switch_status_t sched_hangup_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
|
||||
{
|
||||
switch_core_session_t *session = NULL;
|
||||
char *argv[4] = {0};
|
||||
char *argv[4] = { 0 };
|
||||
int argc = 0;
|
||||
|
||||
if (isession) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
|
||||
if (switch_strlen_zero(cmd) || argc < 1) {
|
||||
@@ -309,7 +311,7 @@ static switch_status_t sched_hangup_function(char *cmd, switch_core_session_t *i
|
||||
switch_call_cause_t cause = SWITCH_CAUSE_ALLOTTED_TIMEOUT;
|
||||
|
||||
if (*argv[0] == '+') {
|
||||
when = time (NULL) + atol(argv[0] + 1);
|
||||
when = time(NULL) + atol(argv[0] + 1);
|
||||
} else {
|
||||
when = atol(argv[0]);
|
||||
}
|
||||
@@ -333,14 +335,14 @@ static switch_status_t sched_hangup_function(char *cmd, switch_core_session_t *i
|
||||
|
||||
static switch_status_t uuid_media_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
|
||||
{
|
||||
char *argv[4] = {0};
|
||||
char *argv[4] = { 0 };
|
||||
int argc = 0;
|
||||
switch_status_t status = SWITCH_STATUS_FALSE;
|
||||
|
||||
|
||||
if (isession) {
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
|
||||
if (switch_strlen_zero(cmd) || argc < 1) {
|
||||
@@ -363,16 +365,17 @@ static switch_status_t uuid_media_function(char *cmd, switch_core_session_t *ise
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t uuid_broadcast_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
|
||||
static switch_status_t uuid_broadcast_function(char *cmd, switch_core_session_t *isession,
|
||||
switch_stream_handle_t *stream)
|
||||
{
|
||||
char *argv[4] = {0};
|
||||
char *argv[4] = { 0 };
|
||||
int argc = 0;
|
||||
switch_status_t status = SWITCH_STATUS_FALSE;
|
||||
|
||||
if (isession) {
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
|
||||
if (switch_strlen_zero(cmd) || argc < 2) {
|
||||
@@ -391,7 +394,7 @@ static switch_status_t uuid_broadcast_function(char *cmd, switch_core_session_t
|
||||
} else {
|
||||
flags |= SMF_ECHO_ALEG;
|
||||
}
|
||||
|
||||
|
||||
status = switch_ivr_broadcast(argv[0], argv[1], flags);
|
||||
stream->write_function(stream, "+OK Message Sent\n");
|
||||
}
|
||||
@@ -400,16 +403,17 @@ static switch_status_t uuid_broadcast_function(char *cmd, switch_core_session_t
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t sched_broadcast_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
|
||||
static switch_status_t sched_broadcast_function(char *cmd, switch_core_session_t *isession,
|
||||
switch_stream_handle_t *stream)
|
||||
{
|
||||
char *argv[4] = {0};
|
||||
char *argv[4] = { 0 };
|
||||
int argc = 0;
|
||||
switch_status_t status = SWITCH_STATUS_FALSE;
|
||||
|
||||
if (isession) {
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
|
||||
if (switch_strlen_zero(cmd) || argc < 3) {
|
||||
@@ -419,7 +423,7 @@ static switch_status_t sched_broadcast_function(char *cmd, switch_core_session_t
|
||||
time_t when;
|
||||
|
||||
if (*argv[0] == '+') {
|
||||
when = time (NULL) + atol(argv[0] + 1);
|
||||
when = time(NULL) + atol(argv[0] + 1);
|
||||
} else {
|
||||
when = atol(argv[0]);
|
||||
}
|
||||
@@ -435,7 +439,7 @@ static switch_status_t sched_broadcast_function(char *cmd, switch_core_session_t
|
||||
} else {
|
||||
flags |= SMF_ECHO_ALEG;
|
||||
}
|
||||
|
||||
|
||||
status = switch_ivr_schedule_broadcast(when, argv[1], argv[2], flags);
|
||||
stream->write_function(stream, "+OK Message Scheduled\n");
|
||||
}
|
||||
@@ -445,14 +449,14 @@ static switch_status_t sched_broadcast_function(char *cmd, switch_core_session_t
|
||||
|
||||
static switch_status_t uuid_hold_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
|
||||
{
|
||||
char *argv[4] = {0};
|
||||
char *argv[4] = { 0 };
|
||||
int argc = 0;
|
||||
switch_status_t status = SWITCH_STATUS_FALSE;
|
||||
|
||||
|
||||
if (isession) {
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
|
||||
if (switch_strlen_zero(cmd) || argc < 1) {
|
||||
@@ -476,13 +480,13 @@ static switch_status_t uuid_hold_function(char *cmd, switch_core_session_t *ises
|
||||
|
||||
static switch_status_t uuid_bridge_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
|
||||
{
|
||||
char *argv[4] = {0};
|
||||
char *argv[4] = { 0 };
|
||||
int argc = 0;
|
||||
|
||||
if (isession) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
|
||||
if (switch_strlen_zero(cmd) || argc != 2) {
|
||||
@@ -496,72 +500,73 @@ static switch_status_t uuid_bridge_function(char *cmd, switch_core_session_t *is
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t session_record_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
|
||||
static switch_status_t session_record_function(char *cmd, switch_core_session_t *isession,
|
||||
switch_stream_handle_t *stream)
|
||||
{
|
||||
switch_core_session_t *session = NULL;
|
||||
char *argv[4] = {0};
|
||||
char *uuid = NULL, *action = NULL, *path = NULL;
|
||||
switch_core_session_t *session = NULL;
|
||||
char *argv[4] = { 0 };
|
||||
char *uuid = NULL, *action = NULL, *path = NULL;
|
||||
int argc = 0;
|
||||
|
||||
if (isession) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
if (switch_strlen_zero(cmd)) {
|
||||
goto usage;
|
||||
}
|
||||
goto usage;
|
||||
}
|
||||
|
||||
if ((argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) != 3) {
|
||||
goto usage;
|
||||
}
|
||||
goto usage;
|
||||
}
|
||||
|
||||
uuid = argv[0];
|
||||
action = argv[1];
|
||||
path = argv[2];
|
||||
|
||||
if (!(session = switch_core_session_locate(uuid))) {
|
||||
uuid = argv[0];
|
||||
action = argv[1];
|
||||
path = argv[2];
|
||||
|
||||
if (!(session = switch_core_session_locate(uuid))) {
|
||||
stream->write_function(stream, "-Error Cannot locate session!\n");
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (switch_strlen_zero(action) || switch_strlen_zero(path)) {
|
||||
goto usage;
|
||||
}
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (!strcasecmp(action, "start")) {
|
||||
switch_ivr_record_session(session, path, NULL);
|
||||
} else if (!strcasecmp(action, "stop")) {
|
||||
switch_ivr_stop_record_session(session, path);
|
||||
} else {
|
||||
goto usage;
|
||||
}
|
||||
if (switch_strlen_zero(action) || switch_strlen_zero(path)) {
|
||||
goto usage;
|
||||
}
|
||||
|
||||
goto done;
|
||||
if (!strcasecmp(action, "start")) {
|
||||
switch_ivr_record_session(session, path, NULL);
|
||||
} else if (!strcasecmp(action, "stop")) {
|
||||
switch_ivr_stop_record_session(session, path);
|
||||
} else {
|
||||
goto usage;
|
||||
}
|
||||
|
||||
usage:
|
||||
goto done;
|
||||
|
||||
stream->write_function(stream, "USAGE: %s\n", session_record_api_interface.syntax);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
usage:
|
||||
|
||||
done:
|
||||
stream->write_function(stream, "USAGE: %s\n", session_record_api_interface.syntax);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
if (session) {
|
||||
switch_core_session_rwunlock(session);
|
||||
}
|
||||
done:
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
if (session) {
|
||||
switch_core_session_rwunlock(session);
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t pause_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
|
||||
{
|
||||
switch_core_session_t *session = NULL;
|
||||
char *argv[4] = {0};
|
||||
char *argv[4] = { 0 };
|
||||
int argc = 0;
|
||||
|
||||
if (isession) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
|
||||
if (switch_strlen_zero(cmd) || argc < 2) {
|
||||
@@ -569,7 +574,7 @@ static switch_status_t pause_function(char *cmd, switch_core_session_t *isession
|
||||
} else {
|
||||
char *uuid = argv[0];
|
||||
char *dest = argv[1];
|
||||
|
||||
|
||||
if ((session = switch_core_session_locate(uuid))) {
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
|
||||
@@ -593,7 +598,7 @@ static switch_status_t originate_function(char *cmd, switch_core_session_t *ises
|
||||
{
|
||||
switch_channel_t *caller_channel;
|
||||
switch_core_session_t *caller_session;
|
||||
char *argv[7] = {0};
|
||||
char *argv[7] = { 0 };
|
||||
int i = 0, x, argc = 0;
|
||||
char *aleg, *exten, *dp, *context, *cid_name, *cid_num;
|
||||
uint32_t timeout = 60;
|
||||
@@ -612,12 +617,12 @@ static switch_status_t originate_function(char *cmd, switch_core_session_t *ises
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
for(x = 0; x < argc; x++) {
|
||||
for (x = 0; x < argc; x++) {
|
||||
if (!strcasecmp(argv[x], "undef")) {
|
||||
argv[x] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!strcasecmp(argv[0], "machine")) {
|
||||
machine = 1;
|
||||
i++;
|
||||
@@ -629,7 +634,7 @@ static switch_status_t originate_function(char *cmd, switch_core_session_t *ises
|
||||
context = argv[i++];
|
||||
cid_name = argv[i++];
|
||||
cid_num = argv[i++];
|
||||
|
||||
|
||||
if (!dp) {
|
||||
dp = "XML";
|
||||
}
|
||||
@@ -642,20 +647,22 @@ static switch_status_t originate_function(char *cmd, switch_core_session_t *ises
|
||||
timeout = atoi(argv[6]);
|
||||
}
|
||||
|
||||
if (switch_ivr_originate(NULL, &caller_session, &cause, aleg, timeout, NULL, cid_name, cid_num, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_ivr_originate(NULL, &caller_session, &cause, aleg, timeout, NULL, cid_name, cid_num, NULL) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
if (machine) {
|
||||
stream->write_function(stream, "fail: %s\n", switch_channel_cause2str(cause));
|
||||
} else {
|
||||
stream->write_function(stream, "Cannot Create Outgoing Channel! [%s] cause: %s\n", aleg, switch_channel_cause2str(cause));
|
||||
stream->write_function(stream, "Cannot Create Outgoing Channel! [%s] cause: %s\n", aleg,
|
||||
switch_channel_cause2str(cause));
|
||||
}
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
caller_channel = switch_core_session_get_channel(caller_session);
|
||||
assert(caller_channel != NULL);
|
||||
switch_channel_clear_state_handler(caller_channel, NULL);
|
||||
|
||||
if (*exten == '&' && *(exten + 1)) {
|
||||
if (*exten == '&' && *(exten + 1)) {
|
||||
switch_caller_extension_t *extension = NULL;
|
||||
char *app_name = switch_core_session_strdup(caller_session, (exten + 1));
|
||||
char *arg = NULL, *e;
|
||||
@@ -696,7 +703,8 @@ struct holder {
|
||||
int print_title;
|
||||
};
|
||||
|
||||
static int show_callback(void *pArg, int argc, char **argv, char **columnNames){
|
||||
static int show_callback(void *pArg, int argc, char **argv, char **columnNames)
|
||||
{
|
||||
struct holder *holder = (struct holder *) pArg;
|
||||
int x;
|
||||
|
||||
@@ -706,26 +714,29 @@ static int show_callback(void *pArg, int argc, char **argv, char **columnNames){
|
||||
holder->stream->write_function(holder->stream, "\n<tr>");
|
||||
}
|
||||
|
||||
for(x = 0; x < argc; x++) {
|
||||
for (x = 0; x < argc; x++) {
|
||||
if (holder->http) {
|
||||
holder->stream->write_function(holder->stream, "<td>");
|
||||
holder->stream->write_function(holder->stream, "<b>%s</b>%s", columnNames[x], x == (argc - 1) ? "</td></tr>\n" : "</td><td>");
|
||||
holder->stream->write_function(holder->stream, "<b>%s</b>%s", columnNames[x],
|
||||
x == (argc - 1) ? "</td></tr>\n" : "</td><td>");
|
||||
} else {
|
||||
holder->stream->write_function(holder->stream, "%s%s", columnNames[x], x == (argc - 1) ? "\n" : ",");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (holder->http) {
|
||||
holder->stream->write_function(holder->stream, "<tr bgcolor=%s>", holder->count % 2 == 0 ? "eeeeee" : "ffffff");
|
||||
}
|
||||
|
||||
for(x = 0; x < argc; x++) {
|
||||
for (x = 0; x < argc; x++) {
|
||||
if (holder->http) {
|
||||
holder->stream->write_function(holder->stream, "<td>");
|
||||
holder->stream->write_function(holder->stream, "%s%s", argv[x] ? argv[x] : "", x == (argc - 1) ? "</td></tr>\n" : "</td><td>");
|
||||
holder->stream->write_function(holder->stream, "%s%s", argv[x] ? argv[x] : "",
|
||||
x == (argc - 1) ? "</td></tr>\n" : "</td><td>");
|
||||
} else {
|
||||
holder->stream->write_function(holder->stream, "%s%s", argv[x] ? argv[x] : "", x == (argc - 1) ? "\n" : ",");
|
||||
holder->stream->write_function(holder->stream, "%s%s", argv[x] ? argv[x] : "",
|
||||
x == (argc - 1) ? "\n" : ",");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -738,7 +749,7 @@ static switch_status_t show_function(char *cmd, switch_core_session_t *session,
|
||||
char sql[1024];
|
||||
char *errmsg;
|
||||
switch_core_db_t *db = switch_core_db_handle();
|
||||
struct holder holder = {0};
|
||||
struct holder holder = { 0 };
|
||||
int help = 0;
|
||||
|
||||
if (session) {
|
||||
@@ -747,7 +758,7 @@ static switch_status_t show_function(char *cmd, switch_core_session_t *session,
|
||||
|
||||
if (stream->event) {
|
||||
holder.http = switch_event_get_header(stream->event, "http-host");
|
||||
}
|
||||
}
|
||||
|
||||
holder.print_title = 1;
|
||||
|
||||
@@ -756,14 +767,14 @@ static switch_status_t show_function(char *cmd, switch_core_session_t *session,
|
||||
if (!cmd) {
|
||||
stream->write_function(stream, "USAGE: %s\n", show_api_interface.syntax);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
} else if ( !strcmp(cmd,"codec") || !strcmp(cmd,"dialplan") || !strcmp(cmd,"file") || !strcmp(cmd,"timer")) {
|
||||
sprintf (sql, "select type, name from interfaces where type = '%s'", cmd);
|
||||
} else if (!strcmp(cmd,"application") || !strcmp(cmd,"api")) {
|
||||
sprintf (sql, "select name, description, syntax from interfaces where type = '%s' and description != ''" , cmd);
|
||||
} else if ( !strcmp(cmd,"calls")) {
|
||||
sprintf (sql, "select * from calls");
|
||||
} else if ( !strcmp(cmd,"channels")) {
|
||||
sprintf (sql, "select * from channels");
|
||||
} else if (!strcmp(cmd, "codec") || !strcmp(cmd, "dialplan") || !strcmp(cmd, "file") || !strcmp(cmd, "timer")) {
|
||||
sprintf(sql, "select type, name from interfaces where type = '%s'", cmd);
|
||||
} else if (!strcmp(cmd, "application") || !strcmp(cmd, "api")) {
|
||||
sprintf(sql, "select name, description, syntax from interfaces where type = '%s' and description != ''", cmd);
|
||||
} else if (!strcmp(cmd, "calls")) {
|
||||
sprintf(sql, "select * from calls");
|
||||
} else if (!strcmp(cmd, "channels")) {
|
||||
sprintf(sql, "select * from channels");
|
||||
} else if (!strncasecmp(cmd, "help", 4)) {
|
||||
char *cmdname = NULL;
|
||||
|
||||
@@ -771,15 +782,16 @@ static switch_status_t show_function(char *cmd, switch_core_session_t *session,
|
||||
holder.print_title = 0;
|
||||
if ((cmdname = strchr(cmd, ' ')) != 0) {
|
||||
*cmdname++ = '\0';
|
||||
snprintf (sql, sizeof(sql) - 1, "select name, syntax, description from interfaces where type = 'api' and name = '%s'", cmdname);
|
||||
snprintf(sql, sizeof(sql) - 1,
|
||||
"select name, syntax, description from interfaces where type = 'api' and name = '%s'", cmdname);
|
||||
} else {
|
||||
snprintf (sql, sizeof(sql) - 1, "select name, syntax, description from interfaces where type = 'api'");
|
||||
snprintf(sql, sizeof(sql) - 1, "select name, syntax, description from interfaces where type = 'api'");
|
||||
}
|
||||
} else {
|
||||
stream->write_function(stream, "USAGE: %s\n", show_api_interface.syntax);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
holder.stream = stream;
|
||||
holder.count = 0;
|
||||
|
||||
@@ -794,7 +806,7 @@ static switch_status_t show_function(char *cmd, switch_core_session_t *session,
|
||||
}
|
||||
|
||||
if (errmsg) {
|
||||
stream->write_function(stream, "SQL ERR [%s]\n",errmsg);
|
||||
stream->write_function(stream, "SQL ERR [%s]\n", errmsg);
|
||||
switch_core_db_free(errmsg);
|
||||
errmsg = NULL;
|
||||
} else if (help) {
|
||||
@@ -811,7 +823,7 @@ static switch_status_t show_function(char *cmd, switch_core_session_t *session,
|
||||
static switch_status_t version_function(char *cmd, switch_core_session_t *session, switch_stream_handle_t *stream)
|
||||
{
|
||||
char version_string[1024];
|
||||
snprintf(version_string, sizeof(version_string) - 1, "FreeSwitch Version %s\n", SWITCH_VERSION_FULL);
|
||||
snprintf(version_string, sizeof(version_string) - 1, "FreeSwitch Version %s\n", SWITCH_VERSION_FULL);
|
||||
|
||||
stream->write_function(stream, version_string);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
@@ -822,10 +834,10 @@ static switch_status_t help_function(char *cmd, switch_core_session_t *session,
|
||||
char showcmd[1024];
|
||||
int all = 0;
|
||||
if (switch_strlen_zero(cmd)) {
|
||||
sprintf (showcmd, "help");
|
||||
sprintf(showcmd, "help");
|
||||
all = 1;
|
||||
} else {
|
||||
snprintf(showcmd, sizeof(showcmd) -1, "help %s", cmd);
|
||||
snprintf(showcmd, sizeof(showcmd) - 1, "help %s", cmd);
|
||||
}
|
||||
|
||||
if (all) {
|
||||
@@ -986,7 +998,8 @@ static switch_api_interface_t originate_api_interface = {
|
||||
/*.interface_name */ "originate",
|
||||
/*.desc */ "Originate a Call",
|
||||
/*.function */ originate_function,
|
||||
/*.syntax */ "<call url> <exten>|&<application_name>(<app_args>) [<dialplan>] [<context>] [<cid_name>] [<cid_num>] [<timeout_sec>]",
|
||||
/*.syntax */
|
||||
"<call url> <exten>|&<application_name>(<app_args>) [<dialplan>] [<context>] [<cid_name>] [<cid_num>] [<timeout_sec>]",
|
||||
/*.next */ &kill_api_interface
|
||||
};
|
||||
|
||||
@@ -1000,7 +1013,8 @@ static const switch_loadable_module_interface_t mod_commands_module_interface =
|
||||
/*.api_interface */ &originate_api_interface
|
||||
};
|
||||
|
||||
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 */
|
||||
*module_interface = &mod_commands_module_interface;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -43,7 +43,8 @@ static void detect_speech_function(switch_core_session_t *session, char *data)
|
||||
int argc;
|
||||
char *lbuf = NULL;
|
||||
|
||||
if (data && (lbuf = switch_core_session_strdup(session, data)) && (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
|
||||
if (data && (lbuf = switch_core_session_strdup(session, data))
|
||||
&& (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
|
||||
if (!strcasecmp(argv[0], "grammar") && argc >= 1) {
|
||||
switch_ivr_detect_speech_load_grammar(session, argv[1], argv[2]);
|
||||
} else if (!strcasecmp(argv[0], "nogrammar")) {
|
||||
@@ -58,16 +59,17 @@ static void detect_speech_function(switch_core_session_t *session, char *data)
|
||||
switch_ivr_detect_speech(session, argv[0], argv[1], argv[2], argv[3], NULL);
|
||||
}
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Usage: %s\n", detect_speech_application_interface.syntax);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Usage: %s\n",
|
||||
detect_speech_application_interface.syntax);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
static void ring_ready_function(switch_core_session_t *session, char *data)
|
||||
{
|
||||
switch_channel_t *channel;
|
||||
channel = switch_core_session_get_channel(session);
|
||||
assert(channel != NULL);
|
||||
assert(channel != NULL);
|
||||
switch_channel_ring_ready(channel);
|
||||
}
|
||||
|
||||
@@ -84,7 +86,7 @@ static void queue_dtmf_function(switch_core_session_t *session, char *data)
|
||||
static void transfer_function(switch_core_session_t *session, char *data)
|
||||
{
|
||||
int argc;
|
||||
char *argv[4] = {0};
|
||||
char *argv[4] = { 0 };
|
||||
char *mydata;
|
||||
|
||||
if (data && (mydata = switch_core_session_strdup(session, data))) {
|
||||
@@ -99,15 +101,15 @@ static void transfer_function(switch_core_session_t *session, char *data)
|
||||
static void sched_transfer_function(switch_core_session_t *session, char *data)
|
||||
{
|
||||
int argc;
|
||||
char *argv[4] = {0};
|
||||
char *argv[4] = { 0 };
|
||||
char *mydata;
|
||||
|
||||
|
||||
if (data && (mydata = switch_core_session_strdup(session, data))) {
|
||||
if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 2) {
|
||||
time_t when;
|
||||
|
||||
if (*argv[0] == '+') {
|
||||
when = time (NULL) + atol(argv[0] + 1);
|
||||
when = time(NULL) + atol(argv[0] + 1);
|
||||
} else {
|
||||
when = atol(argv[0]);
|
||||
}
|
||||
@@ -122,7 +124,7 @@ static void sched_transfer_function(switch_core_session_t *session, char *data)
|
||||
static void sched_hangup_function(switch_core_session_t *session, char *data)
|
||||
{
|
||||
int argc;
|
||||
char *argv[5] = {0};
|
||||
char *argv[5] = { 0 };
|
||||
char *mydata;
|
||||
|
||||
if (data && (mydata = switch_core_session_strdup(session, data))) {
|
||||
@@ -132,11 +134,11 @@ static void sched_hangup_function(switch_core_session_t *session, char *data)
|
||||
switch_bool_t bleg = SWITCH_FALSE;
|
||||
|
||||
if (*argv[0] == '+') {
|
||||
when = time (NULL) + atol(argv[0] + 1);
|
||||
when = time(NULL) + atol(argv[0] + 1);
|
||||
} else {
|
||||
when = atol(argv[0]);
|
||||
}
|
||||
|
||||
|
||||
if (argv[1]) {
|
||||
cause = switch_channel_str2cause(argv[1]);
|
||||
}
|
||||
@@ -156,20 +158,20 @@ static void sched_hangup_function(switch_core_session_t *session, char *data)
|
||||
static void sched_broadcast_function(switch_core_session_t *session, char *data)
|
||||
{
|
||||
int argc;
|
||||
char *argv[6] = {0};
|
||||
char *argv[6] = { 0 };
|
||||
char *mydata;
|
||||
|
||||
if (data && (mydata = switch_core_session_strdup(session, data))) {
|
||||
if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 2) {
|
||||
time_t when;
|
||||
switch_media_flag_t flags = SMF_NONE;
|
||||
|
||||
|
||||
if (*argv[0] == '+') {
|
||||
when = time (NULL) + atol(argv[0] + 1);
|
||||
when = time(NULL) + atol(argv[0] + 1);
|
||||
} else {
|
||||
when = atol(argv[0]);
|
||||
}
|
||||
|
||||
|
||||
if (argv[2]) {
|
||||
if (!strcmp(argv[2], "both")) {
|
||||
flags |= (SMF_ECHO_ALEG | SMF_ECHO_BLEG);
|
||||
@@ -207,26 +209,26 @@ static void eval_function(switch_core_session_t *session, char *data)
|
||||
|
||||
static void phrase_function(switch_core_session_t *session, char *data)
|
||||
{
|
||||
switch_channel_t *channel;
|
||||
char *mydata = NULL;
|
||||
switch_channel_t *channel;
|
||||
char *mydata = NULL;
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
assert(channel != NULL);
|
||||
|
||||
if ((mydata = switch_core_session_strdup(session, data))) {
|
||||
char *lang;
|
||||
char *macro = mydata;
|
||||
char *mdata = NULL;
|
||||
channel = switch_core_session_get_channel(session);
|
||||
assert(channel != NULL);
|
||||
|
||||
if ((mdata = strchr(macro, ','))) {
|
||||
*mdata++ = '\0';
|
||||
}
|
||||
if ((mydata = switch_core_session_strdup(session, data))) {
|
||||
char *lang;
|
||||
char *macro = mydata;
|
||||
char *mdata = NULL;
|
||||
|
||||
lang = switch_channel_get_variable(channel, "language");
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Execute %s(%s) lang %s\n", macro, mdata, lang);
|
||||
switch_ivr_phrase_macro(session, macro, mdata, lang, NULL);
|
||||
}
|
||||
if ((mdata = strchr(macro, ','))) {
|
||||
*mdata++ = '\0';
|
||||
}
|
||||
|
||||
lang = switch_channel_get_variable(channel, "language");
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Execute %s(%s) lang %s\n", macro, mdata, lang);
|
||||
switch_ivr_phrase_macro(session, macro, mdata, lang, NULL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -234,14 +236,14 @@ static void phrase_function(switch_core_session_t *session, char *data)
|
||||
static void hangup_function(switch_core_session_t *session, char *data)
|
||||
{
|
||||
switch_channel_t *channel;
|
||||
switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
|
||||
switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
assert(channel != NULL);
|
||||
assert(channel != NULL);
|
||||
|
||||
if (!switch_strlen_zero((char *) data)) {
|
||||
cause = switch_channel_str2cause((char *) data);
|
||||
}
|
||||
if (!switch_strlen_zero((char *) data)) {
|
||||
cause = switch_channel_str2cause((char *) data);
|
||||
}
|
||||
|
||||
switch_channel_hangup(channel, cause);
|
||||
}
|
||||
@@ -251,7 +253,7 @@ static void answer_function(switch_core_session_t *session, char *data)
|
||||
switch_channel_t *channel;
|
||||
channel = switch_core_session_get_channel(session);
|
||||
|
||||
assert(channel != NULL);
|
||||
assert(channel != NULL);
|
||||
switch_channel_answer(channel);
|
||||
}
|
||||
|
||||
@@ -260,18 +262,18 @@ static void pre_answer_function(switch_core_session_t *session, char *data)
|
||||
switch_channel_t *channel;
|
||||
channel = switch_core_session_get_channel(session);
|
||||
|
||||
assert(channel != NULL);
|
||||
assert(channel != NULL);
|
||||
switch_channel_pre_answer(channel);
|
||||
}
|
||||
|
||||
static void redirect_function(switch_core_session_t *session, char *data)
|
||||
{
|
||||
switch_core_session_message_t msg = {0};
|
||||
switch_core_session_message_t msg = { 0 };
|
||||
|
||||
/* Tell the channel to redirect */
|
||||
/* Tell the channel to redirect */
|
||||
msg.from = __FILE__;
|
||||
msg.string_arg = data;
|
||||
msg.message_id = SWITCH_MESSAGE_INDICATE_REDIRECT;
|
||||
msg.message_id = SWITCH_MESSAGE_INDICATE_REDIRECT;
|
||||
switch_core_session_receive_message(session, &msg);
|
||||
|
||||
}
|
||||
@@ -283,7 +285,7 @@ static void set_function(switch_core_session_t *session, char *data)
|
||||
char *var, *val = NULL;
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
assert(channel != NULL);
|
||||
assert(channel != NULL);
|
||||
|
||||
if (switch_strlen_zero(data)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No variable name specified.\n");
|
||||
@@ -293,11 +295,11 @@ static void set_function(switch_core_session_t *session, char *data)
|
||||
|
||||
if (val) {
|
||||
*val++ = '\0';
|
||||
if (switch_strlen_zero(val)) {
|
||||
val = NULL;
|
||||
}
|
||||
if (switch_strlen_zero(val)) {
|
||||
val = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SET [%s]=[%s]\n", var, val ? val : "UNDEF");
|
||||
switch_channel_set_variable(channel, var, val);
|
||||
}
|
||||
@@ -309,7 +311,7 @@ static void export_function(switch_core_session_t *session, char *data)
|
||||
char *exports, *new_exports = NULL, *new_exports_d = NULL, *var, *val = NULL;
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
assert(channel != NULL);
|
||||
assert(channel != NULL);
|
||||
|
||||
if (switch_strlen_zero(data)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No variable name specified.\n");
|
||||
@@ -320,11 +322,11 @@ static void export_function(switch_core_session_t *session, char *data)
|
||||
|
||||
if (val) {
|
||||
*val++ = '\0';
|
||||
if (switch_strlen_zero(val)) {
|
||||
val = NULL;
|
||||
}
|
||||
if (switch_strlen_zero(val)) {
|
||||
val = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "EXPORT [%s]=[%s]\n", var, val ? val : "UNDEF");
|
||||
switch_channel_set_variable(channel, var, val);
|
||||
|
||||
@@ -346,7 +348,7 @@ static void unset_function(switch_core_session_t *session, char *data)
|
||||
switch_channel_t *channel;
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
assert(channel != NULL);
|
||||
assert(channel != NULL);
|
||||
|
||||
if (switch_strlen_zero(data)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No variable name specified.\n");
|
||||
@@ -359,43 +361,43 @@ static void unset_function(switch_core_session_t *session, char *data)
|
||||
static void log_function(switch_core_session_t *session, char *data)
|
||||
{
|
||||
switch_channel_t *channel;
|
||||
char *level, *log_str;
|
||||
char *level, *log_str;
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
assert(channel != NULL);
|
||||
assert(channel != NULL);
|
||||
|
||||
if (data && (level = strdup(data))) {
|
||||
switch_event_types_t etype = SWITCH_LOG_DEBUG;
|
||||
|
||||
if ((log_str = strchr(level, ' '))) {
|
||||
*log_str++ = '\0';
|
||||
switch_name_event(level, &etype);
|
||||
} else {
|
||||
log_str = level;
|
||||
}
|
||||
if (data && (level = strdup(data))) {
|
||||
switch_event_types_t etype = SWITCH_LOG_DEBUG;
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, etype, "%s\n", log_str);
|
||||
switch_safe_free(level);
|
||||
}
|
||||
if ((log_str = strchr(level, ' '))) {
|
||||
*log_str++ = '\0';
|
||||
switch_name_event(level, &etype);
|
||||
} else {
|
||||
log_str = level;
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, etype, "%s\n", log_str);
|
||||
switch_safe_free(level);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void info_function(switch_core_session_t *session, char *data)
|
||||
{
|
||||
switch_channel_t *channel;
|
||||
switch_event_t *event;
|
||||
char *buf;
|
||||
switch_event_t *event;
|
||||
char *buf;
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
assert(channel != NULL);
|
||||
assert(channel != NULL);
|
||||
|
||||
if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_channel_event_set_data(channel, event);
|
||||
switch_event_serialize(event, &buf);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "CHANNEL_DATA:\n%s\n", buf);
|
||||
switch_event_destroy(&event);
|
||||
}
|
||||
|
||||
if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_channel_event_set_data(channel, event);
|
||||
switch_event_serialize(event, &buf);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "CHANNEL_DATA:\n%s\n", buf);
|
||||
switch_event_destroy(&event);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void privacy_function(switch_core_session_t *session, char *data)
|
||||
@@ -405,8 +407,8 @@ static void privacy_function(switch_core_session_t *session, char *data)
|
||||
char *arg;
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
assert(channel != NULL);
|
||||
|
||||
assert(channel != NULL);
|
||||
|
||||
caller_profile = switch_channel_get_caller_profile(channel);
|
||||
|
||||
if (switch_strlen_zero(data)) {
|
||||
@@ -416,7 +418,7 @@ static void privacy_function(switch_core_session_t *session, char *data)
|
||||
|
||||
switch_set_flag(caller_profile, SWITCH_CPF_SCREEN);
|
||||
|
||||
if(!strcasecmp(arg, "no")) {
|
||||
if (!strcasecmp(arg, "no")) {
|
||||
switch_clear_flag(caller_profile, SWITCH_CPF_HIDE_NAME);
|
||||
switch_clear_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER);
|
||||
} else if (!strcasecmp(arg, "yes")) {
|
||||
@@ -428,7 +430,8 @@ static void privacy_function(switch_core_session_t *session, char *data)
|
||||
} else if (!strcasecmp(arg, "number")) {
|
||||
switch_set_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID privacy mode specified. Use a valid mode [no|yes|name|full|number].\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
|
||||
"INVALID privacy mode specified. Use a valid mode [no|yes|name|full|number].\n");
|
||||
}
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set Privacy to %s [%d]\n", arg, caller_profile->flags);
|
||||
}
|
||||
@@ -440,7 +443,8 @@ static void strftime_function(switch_core_session_t *session, char *data)
|
||||
int argc;
|
||||
char *lbuf;
|
||||
|
||||
if (data && (lbuf = switch_core_session_strdup(session, data)) && (argc = switch_separate_string(lbuf, '=', argv, (sizeof(argv) / sizeof(argv[0])))) > 1) {
|
||||
if (data && (lbuf = switch_core_session_strdup(session, data))
|
||||
&& (argc = switch_separate_string(lbuf, '=', argv, (sizeof(argv) / sizeof(argv[0])))) > 1) {
|
||||
switch_size_t retsize;
|
||||
switch_time_exp_t tm;
|
||||
char date[80] = "";
|
||||
@@ -459,26 +463,26 @@ static void strftime_function(switch_core_session_t *session, char *data)
|
||||
|
||||
static switch_status_t strepoch_api_function(char *data, switch_core_session_t *session, switch_stream_handle_t *stream)
|
||||
{
|
||||
switch_time_t out;
|
||||
|
||||
if (switch_strlen_zero(data)) {
|
||||
out = switch_time_now();
|
||||
} else {
|
||||
out = switch_str_time(data);
|
||||
}
|
||||
switch_time_t out;
|
||||
|
||||
stream->write_function(stream, "%d", (uint32_t)((out) / (int64_t)(1000000)) );
|
||||
if (switch_strlen_zero(data)) {
|
||||
out = switch_time_now();
|
||||
} else {
|
||||
out = switch_str_time(data);
|
||||
}
|
||||
|
||||
stream->write_function(stream, "%d", (uint32_t) ((out) / (int64_t) (1000000)));
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t strftime_api_function(char *fmt, switch_core_session_t *session, switch_stream_handle_t *stream)
|
||||
{
|
||||
|
||||
|
||||
switch_size_t retsize;
|
||||
switch_time_exp_t tm;
|
||||
char date[80] = "";
|
||||
|
||||
|
||||
switch_time_exp_lt(&tm, switch_time_now());
|
||||
switch_strftime(date, &retsize, sizeof(date), fmt ? fmt : "%Y-%m-%d %T", &tm);
|
||||
stream->write_function(stream, "%s", date);
|
||||
@@ -493,14 +497,15 @@ static switch_status_t presence_api_function(char *fmt, switch_core_session_t *s
|
||||
int argc = 0;
|
||||
switch_event_types_t type = SWITCH_EVENT_PRESENCE_IN;
|
||||
|
||||
if (fmt && (lbuf = strdup(fmt)) && (argc = switch_separate_string(lbuf, '|', argv, (sizeof(argv) / sizeof(argv[0])))) > 0) {
|
||||
if (fmt && (lbuf = strdup(fmt))
|
||||
&& (argc = switch_separate_string(lbuf, '|', argv, (sizeof(argv) / sizeof(argv[0])))) > 0) {
|
||||
if (!strcasecmp(argv[0], "out")) {
|
||||
type = SWITCH_EVENT_PRESENCE_OUT;
|
||||
} else if (argc != 4) {
|
||||
stream->write_function(stream, "Invalid");
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
if (switch_event_create(&event, type) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", "dp");
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", __FILE__);
|
||||
@@ -527,9 +532,10 @@ static switch_status_t chat_api_function(char *fmt, switch_core_session_t *sessi
|
||||
char *lbuf, *argv[4];
|
||||
int argc = 0;
|
||||
|
||||
if (fmt && (lbuf = strdup(fmt)) && (argc = switch_separate_string(lbuf, '|', argv, (sizeof(argv) / sizeof(argv[0])))) == 4) {
|
||||
if (fmt && (lbuf = strdup(fmt))
|
||||
&& (argc = switch_separate_string(lbuf, '|', argv, (sizeof(argv) / sizeof(argv[0])))) == 4) {
|
||||
switch_chat_interface_t *ci;
|
||||
|
||||
|
||||
if ((ci = switch_loadable_module_get_chat_interface(argv[0]))) {
|
||||
ci->chat_send("dp", argv[1], argv[2], "", argv[3], "");
|
||||
stream->write_function(stream, "Sent");
|
||||
@@ -539,7 +545,7 @@ static switch_status_t chat_api_function(char *fmt, switch_core_session_t *sessi
|
||||
} else {
|
||||
stream->write_function(stream, "Invalid");
|
||||
}
|
||||
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -551,7 +557,7 @@ static switch_ivr_action_t menu_handler(switch_ivr_menu_t *menu, char *param, ch
|
||||
switch_ivr_action_t action = SWITCH_IVR_ACTION_NOOP;
|
||||
|
||||
if (param != NULL) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "menu_handler '%s'\n",param);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "menu_handler '%s'\n", param);
|
||||
}
|
||||
|
||||
return action;
|
||||
@@ -563,7 +569,7 @@ static void ivr_application_function(switch_core_session_t *session, char *data)
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
char *params;
|
||||
|
||||
if (channel && data && (params = switch_core_session_strdup(session,data))) {
|
||||
if (channel && data && (params = switch_core_session_strdup(session, data))) {
|
||||
switch_xml_t cxml = NULL, cfg = NULL, xml_menus = NULL, xml_menu = NULL;
|
||||
|
||||
// Open the config from the xml registry
|
||||
@@ -577,16 +583,17 @@ static void ivr_application_function(switch_core_session_t *session, char *data)
|
||||
switch_ivr_menu_t *menu_stack = NULL;
|
||||
|
||||
// build a menu tree and execute it
|
||||
if (switch_ivr_menu_stack_xml_init(&xml_ctx,NULL) == SWITCH_STATUS_SUCCESS
|
||||
if (switch_ivr_menu_stack_xml_init(&xml_ctx, NULL) == SWITCH_STATUS_SUCCESS
|
||||
#ifdef _TEST_CALLBACK_
|
||||
&& switch_ivr_menu_stack_xml_add_custom(xml_ctx, "custom", &menu_handler) == SWITCH_STATUS_SUCCESS
|
||||
&& switch_ivr_menu_stack_xml_add_custom(xml_ctx, "custom",
|
||||
&menu_handler) == SWITCH_STATUS_SUCCESS
|
||||
#endif
|
||||
&& switch_ivr_menu_stack_xml_build(xml_ctx,&menu_stack,xml_menus,xml_menu) == SWITCH_STATUS_SUCCESS)
|
||||
{
|
||||
&& switch_ivr_menu_stack_xml_build(xml_ctx, &menu_stack, xml_menus,
|
||||
xml_menu) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_xml_free(cxml);
|
||||
cxml = NULL;
|
||||
switch_channel_pre_answer(channel);
|
||||
switch_ivr_menu_execute(session,menu_stack,params,NULL);
|
||||
switch_ivr_menu_execute(session, menu_stack, params, NULL);
|
||||
switch_ivr_menu_stack_free(menu_stack);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to create menu '%s'\n", params);
|
||||
@@ -670,7 +677,7 @@ static switch_application_interface_t sched_hangup_application_interface = {
|
||||
|
||||
static const switch_application_interface_t queuedtmf_application_interface = {
|
||||
/*.interface_name */ "queue_dtmf",
|
||||
/*.application_function */ queue_dtmf_function,
|
||||
/*.application_function */ queue_dtmf_function,
|
||||
/* long_desc */ "Queue dtmf to be sent from a session",
|
||||
/* short_desc */ "Queue dtmf to be sent",
|
||||
/* syntax */ "<dtmf_data>",
|
||||
@@ -680,7 +687,7 @@ static const switch_application_interface_t queuedtmf_application_interface = {
|
||||
|
||||
static const switch_application_interface_t redirect_application_interface = {
|
||||
/*.interface_name */ "redirect",
|
||||
/*.application_function */ redirect_function,
|
||||
/*.application_function */ redirect_function,
|
||||
/* long_desc */ "Send a redirect message to a session.",
|
||||
/* short_desc */ "Send session redirect",
|
||||
/* syntax */ "<redirect_data>",
|
||||
@@ -690,7 +697,7 @@ static const switch_application_interface_t redirect_application_interface = {
|
||||
|
||||
static const switch_application_interface_t ivr_application_interface = {
|
||||
/*.interface_name */ "ivr",
|
||||
/*.application_function */ ivr_application_function,
|
||||
/*.application_function */ ivr_application_function,
|
||||
/* long_desc */ "Run an ivr menu.",
|
||||
/* short_desc */ "Run an ivr menu",
|
||||
/* syntax */ "<menu_name>",
|
||||
@@ -700,7 +707,7 @@ static const switch_application_interface_t ivr_application_interface = {
|
||||
|
||||
static const switch_application_interface_t detect_speech_application_interface = {
|
||||
/*.interface_name */ "detect_speech",
|
||||
/*.application_function */ detect_speech_function,
|
||||
/*.application_function */ detect_speech_function,
|
||||
/* long_desc */ "Detect speech on a channel.",
|
||||
/* short_desc */ "Detect speech",
|
||||
/* syntax */ "<mod_name> <gram_name> <gram_path> [<addr>] OR grammar <gram_name> [<path>] OR pause OR resume",
|
||||
@@ -777,7 +784,6 @@ static const switch_application_interface_t hangup_application_interface = {
|
||||
/* syntax */ "[<cause>]",
|
||||
/* flags */ SAF_SUPPORT_NOMEDIA,
|
||||
/*.next */ &log_application_interface
|
||||
|
||||
};
|
||||
|
||||
static const switch_application_interface_t answer_application_interface = {
|
||||
@@ -788,7 +794,6 @@ static const switch_application_interface_t answer_application_interface = {
|
||||
/* syntax */ "",
|
||||
/* flags */ SAF_SUPPORT_NOMEDIA,
|
||||
/*.next */ &hangup_application_interface
|
||||
|
||||
};
|
||||
|
||||
static const switch_application_interface_t pre_answer_application_interface = {
|
||||
@@ -799,7 +804,6 @@ static const switch_application_interface_t pre_answer_application_interface = {
|
||||
/* syntax */ "",
|
||||
/* flags */ SAF_SUPPORT_NOMEDIA,
|
||||
/*.next */ &answer_application_interface
|
||||
|
||||
};
|
||||
|
||||
static const switch_application_interface_t eval_application_interface = {
|
||||
@@ -810,7 +814,6 @@ static const switch_application_interface_t eval_application_interface = {
|
||||
/* syntax */ "",
|
||||
/* flags */ SAF_SUPPORT_NOMEDIA,
|
||||
/*.next */ &pre_answer_application_interface
|
||||
|
||||
};
|
||||
|
||||
static const switch_application_interface_t phrase_application_interface = {
|
||||
@@ -821,7 +824,6 @@ static const switch_application_interface_t phrase_application_interface = {
|
||||
/* syntax */ "<macro_name>,<data>",
|
||||
/* flags */ SAF_NONE,
|
||||
/*.next */ &eval_application_interface
|
||||
|
||||
};
|
||||
|
||||
static const switch_application_interface_t strftime_application_interface = {
|
||||
@@ -832,13 +834,13 @@ static const switch_application_interface_t strftime_application_interface = {
|
||||
/* syntax */ NULL,
|
||||
/* flags */ SAF_SUPPORT_NOMEDIA,
|
||||
/*.next */ &phrase_application_interface
|
||||
|
||||
};
|
||||
|
||||
static const switch_application_interface_t sleep_application_interface = {
|
||||
/*.interface_name */ "sleep",
|
||||
/*.application_function */ sleep_function,
|
||||
/* long_desc */ "Pause the channel for a given number of milliseconds, consuming the audio for that period of time.",
|
||||
/* long_desc */
|
||||
"Pause the channel for a given number of milliseconds, consuming the audio for that period of time.",
|
||||
/* short_desc */ "Pause a channel",
|
||||
/* syntax */ "<pausemilliseconds>",
|
||||
/* flags */ SAF_NONE,
|
||||
@@ -875,7 +877,8 @@ static const switch_loadable_module_interface_t mod_dptools_module_interface = {
|
||||
/*.api_interface */ &presence_api_interface
|
||||
};
|
||||
|
||||
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 */
|
||||
|
||||
@@ -38,7 +38,7 @@ static void echo_function(switch_core_session_t *session, char *data)
|
||||
switch_channel_t *channel;
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
assert(channel != NULL);
|
||||
assert(channel != NULL);
|
||||
|
||||
switch_channel_answer(channel);
|
||||
|
||||
@@ -67,7 +67,8 @@ static switch_loadable_module_interface_t echo_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 */
|
||||
*module_interface = &echo_module_interface;
|
||||
|
||||
@@ -48,10 +48,10 @@ struct enum_record {
|
||||
typedef struct enum_record enum_record_t;
|
||||
|
||||
struct query {
|
||||
const char *name; /* original query string */
|
||||
const char *name; /* original query string */
|
||||
char *number;
|
||||
unsigned char dn[DNS_MAXDN];
|
||||
enum dns_type qtyp; /* type of the query */
|
||||
enum dns_type qtyp; /* type of the query */
|
||||
enum_record_t *results;
|
||||
};
|
||||
typedef struct query enum_query_t;
|
||||
@@ -77,7 +77,7 @@ static struct {
|
||||
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_root, globals.root)
|
||||
|
||||
|
||||
static void add_route(char *service, char *regex, char *replace)
|
||||
static void add_route(char *service, char *regex, char *replace)
|
||||
{
|
||||
enum_route_t *route, *rp;
|
||||
|
||||
@@ -86,11 +86,11 @@ static void add_route(char *service, char *regex, char *replace)
|
||||
}
|
||||
|
||||
memset(route, 0, sizeof(*route));
|
||||
|
||||
|
||||
route->service = strdup(service);
|
||||
route->regex = strdup(regex);
|
||||
route->replace = strdup(replace);
|
||||
|
||||
|
||||
if (!globals.route_order) {
|
||||
globals.route_order = route;
|
||||
} else {
|
||||
@@ -107,8 +107,8 @@ static void add_route(char *service, char *regex, char *replace)
|
||||
static switch_status_t load_config(void)
|
||||
{
|
||||
char *cf = "enum.conf";
|
||||
switch_xml_t cfg, xml = NULL, param, settings, route, routes;
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
switch_xml_t cfg, xml = NULL, param, settings, route, routes;
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
|
||||
memset(&globals, 0, sizeof(globals));
|
||||
if (switch_core_new_memory_pool(&globals.pool) != SWITCH_STATUS_SUCCESS) {
|
||||
@@ -119,39 +119,39 @@ static switch_status_t load_config(void)
|
||||
|
||||
switch_core_hash_init(&globals.routes, globals.pool);
|
||||
|
||||
if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
goto done;
|
||||
}
|
||||
if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
goto done;
|
||||
}
|
||||
|
||||
if ((settings = switch_xml_child(cfg, "settings"))) {
|
||||
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
|
||||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||
char *val = (char *) switch_xml_attr_soft(param, "value");
|
||||
if (!strcasecmp(var, "default-root")) {
|
||||
if ((settings = switch_xml_child(cfg, "settings"))) {
|
||||
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
|
||||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||
char *val = (char *) switch_xml_attr_soft(param, "value");
|
||||
if (!strcasecmp(var, "default-root")) {
|
||||
set_global_root(val);
|
||||
} else if (!strcasecmp(var, "log-level-trace")) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (!strcasecmp(var, "log-level-trace")) {
|
||||
|
||||
if ((routes = switch_xml_child(cfg, "routes"))) {
|
||||
for (route = switch_xml_child(routes, "route"); route; route = route->next) {
|
||||
char *service = (char *) switch_xml_attr_soft(route, "service");
|
||||
char *regex = (char *) switch_xml_attr_soft(route, "regex");
|
||||
char *replace = (char *) switch_xml_attr_soft(route, "replace");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((routes = switch_xml_child(cfg, "routes"))) {
|
||||
for (route = switch_xml_child(routes, "route"); route; route = route->next) {
|
||||
char *service = (char *) switch_xml_attr_soft(route, "service");
|
||||
char *regex = (char *) switch_xml_attr_soft(route, "regex");
|
||||
char *replace = (char *) switch_xml_attr_soft(route, "replace");
|
||||
|
||||
if (service && regex && replace) {
|
||||
add_route(service, regex, replace);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Route!\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
|
||||
if (xml) {
|
||||
switch_xml_free(xml);
|
||||
@@ -168,20 +168,20 @@ static switch_status_t load_config(void)
|
||||
|
||||
static char *reverse_number(char *in, char *root)
|
||||
{
|
||||
switch_size_t len;
|
||||
char *out = NULL;
|
||||
char *y,*z;
|
||||
switch_size_t len;
|
||||
char *out = NULL;
|
||||
char *y, *z;
|
||||
|
||||
if (!(in && root)) {
|
||||
return NULL;
|
||||
}
|
||||
if (!(in && root)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
len = (strlen(in) * 2) + strlen(root) + 1;
|
||||
if ((out = malloc(len))) {
|
||||
memset(out, 0, len);
|
||||
len = (strlen(in) * 2) + strlen(root) + 1;
|
||||
if ((out = malloc(len))) {
|
||||
memset(out, 0, len);
|
||||
|
||||
z = out;
|
||||
for(y = in + (strlen(in) - 1); y; y--) {
|
||||
z = out;
|
||||
for (y = in + (strlen(in) - 1); y; y--) {
|
||||
if (*y > 47 && *y < 58) {
|
||||
*z++ = *y;
|
||||
*z++ = '.';
|
||||
@@ -189,21 +189,22 @@ static char *reverse_number(char *in, char *root)
|
||||
if (y == in) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
strcat(z, root);
|
||||
}
|
||||
}
|
||||
strcat(z, root);
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
static void dnserror(enum_query_t *q, int errnum) {
|
||||
static void dnserror(enum_query_t * q, int errnum)
|
||||
{
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "unable to lookup %s record for %s: %s\n",
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "unable to lookup %s record for %s: %s\n",
|
||||
dns_typename(q->qtyp), dns_dntosp(q->dn), dns_strerror(errnum));
|
||||
}
|
||||
|
||||
|
||||
static void add_result(enum_query_t *q, int order, int preference, char *service, char *route)
|
||||
static void add_result(enum_query_t * q, int order, int preference, char *service, char *route)
|
||||
{
|
||||
enum_record_t *new_result, *rp, *prev = NULL;
|
||||
|
||||
@@ -213,12 +214,12 @@ static void add_result(enum_query_t *q, int order, int preference, char *service
|
||||
}
|
||||
|
||||
memset(new_result, 0, sizeof(*new_result));
|
||||
|
||||
|
||||
new_result->order = order;
|
||||
new_result->preference = preference;
|
||||
new_result->service = strdup(service);
|
||||
new_result->route = strdup(route);
|
||||
|
||||
|
||||
|
||||
if (!q->results) {
|
||||
q->results = new_result;
|
||||
@@ -227,12 +228,12 @@ static void add_result(enum_query_t *q, int order, int preference, char *service
|
||||
|
||||
rp = q->results;
|
||||
|
||||
while(rp && strcmp(rp->service, new_result->service)) {
|
||||
while (rp && strcmp(rp->service, new_result->service)) {
|
||||
prev = rp;
|
||||
rp = rp->next;
|
||||
}
|
||||
|
||||
while(rp && !strcmp(rp->service, new_result->service) && new_result->order > rp->order) {
|
||||
while (rp && !strcmp(rp->service, new_result->service) && new_result->order > rp->order) {
|
||||
prev = rp;
|
||||
rp = rp->next;
|
||||
}
|
||||
@@ -241,7 +242,7 @@ static void add_result(enum_query_t *q, int order, int preference, char *service
|
||||
prev = rp;
|
||||
rp = rp->next;
|
||||
}
|
||||
|
||||
|
||||
if (prev) {
|
||||
new_result->next = rp;
|
||||
prev->next = new_result;
|
||||
@@ -252,11 +253,11 @@ static void add_result(enum_query_t *q, int order, int preference, char *service
|
||||
}
|
||||
|
||||
|
||||
static void free_results(enum_record_t **results)
|
||||
static void free_results(enum_record_t ** results)
|
||||
{
|
||||
enum_record_t *fp, *rp;
|
||||
|
||||
for(rp = *results; rp;) {
|
||||
for (rp = *results; rp;) {
|
||||
fp = rp;
|
||||
rp = rp->next;
|
||||
switch_safe_free(fp->service);
|
||||
@@ -266,7 +267,8 @@ static void free_results(enum_record_t **results)
|
||||
*results = NULL;
|
||||
}
|
||||
|
||||
static void parse_rr(const struct dns_parse *p, enum_query_t *q, struct dns_rr *rr) {
|
||||
static void parse_rr(const struct dns_parse *p, enum_query_t * q, struct dns_rr *rr)
|
||||
{
|
||||
const unsigned char *pkt = p->dnsp_pkt;
|
||||
const unsigned char *end = p->dnsp_end;
|
||||
const unsigned char *dptr = rr->dnsrr_dptr;
|
||||
@@ -282,25 +284,26 @@ static void parse_rr(const struct dns_parse *p, enum_query_t *q, struct dns_rr *
|
||||
char *regex = NULL;
|
||||
char *replace = NULL;
|
||||
int argc = 0;
|
||||
char *argv[4] = {0};
|
||||
char *argv[4] = { 0 };
|
||||
int leap;
|
||||
|
||||
switch(rr->dnsrr_typ) {
|
||||
switch (rr->dnsrr_typ) {
|
||||
|
||||
case DNS_T_NAPTR: /* prio weight port targetDN */
|
||||
case DNS_T_NAPTR: /* prio weight port targetDN */
|
||||
c = dptr;
|
||||
c += 2 + 2 + 2;
|
||||
if (dns_getdn(pkt, &c, end, dn, DNS_MAXDN) <= 0 || c != dend) goto xperr;
|
||||
if (dns_getdn(pkt, &c, end, dn, DNS_MAXDN) <= 0 || c != dend)
|
||||
goto xperr;
|
||||
c = dptr;
|
||||
|
||||
|
||||
leap = *dn;
|
||||
nme = (char *)dn+1;
|
||||
nme = (char *) dn + 1;
|
||||
|
||||
order = dns_get16(c+0);
|
||||
preference = dns_get16(c+2);
|
||||
flags = (char) dns_get16(c+4);
|
||||
order = dns_get16(c + 0);
|
||||
preference = dns_get16(c + 2);
|
||||
flags = (char) dns_get16(c + 4);
|
||||
|
||||
if ((ptr = nme+leap)) {
|
||||
if ((ptr = nme + leap)) {
|
||||
service = nme;
|
||||
*ptr++ = '\0';
|
||||
argc = switch_separate_string(ptr, '!', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
@@ -308,7 +311,7 @@ static void parse_rr(const struct dns_parse *p, enum_query_t *q, struct dns_rr *
|
||||
replace = argv[2];
|
||||
}
|
||||
|
||||
for(ptr = replace; ptr && *ptr; ptr++) {
|
||||
for (ptr = replace; ptr && *ptr; ptr++) {
|
||||
if (*ptr == '\\') {
|
||||
*ptr = '$';
|
||||
}
|
||||
@@ -326,15 +329,17 @@ static void parse_rr(const struct dns_parse *p, enum_query_t *q, struct dns_rr *
|
||||
|
||||
if ((proceed = switch_regex_perform(q->number, regex, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
|
||||
if (strchr(regex, '(')) {
|
||||
switch_perform_substitution(re, proceed, replace, q->number, substituted, sizeof(substituted), ovector);
|
||||
switch_perform_substitution(re, proceed, replace, q->number, substituted, sizeof(substituted),
|
||||
ovector);
|
||||
uri = substituted;
|
||||
} else {
|
||||
uri = replace;
|
||||
}
|
||||
|
||||
if ((route = (enum_route_t *) switch_core_hash_find(globals.routes, service))){
|
||||
if ((route = (enum_route_t *) switch_core_hash_find(globals.routes, service))) {
|
||||
switch_regex_safe_free(re);
|
||||
if ((proceed = switch_regex_perform(uri, route->regex, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
|
||||
if ((proceed =
|
||||
switch_regex_perform(uri, route->regex, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
|
||||
if (strchr(route->regex, '(')) {
|
||||
switch_perform_substitution(re, proceed, route->replace, uri, rbuf, sizeof(rbuf), ovector);
|
||||
uri = rbuf;
|
||||
@@ -343,7 +348,7 @@ static void parse_rr(const struct dns_parse *p, enum_query_t *q, struct dns_rr *
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
add_result(q, order, preference, service, uri);
|
||||
}
|
||||
|
||||
@@ -358,12 +363,13 @@ static void parse_rr(const struct dns_parse *p, enum_query_t *q, struct dns_rr *
|
||||
|
||||
return;
|
||||
|
||||
xperr:
|
||||
xperr:
|
||||
//printf("<parse error>\n");
|
||||
return;
|
||||
}
|
||||
|
||||
static void dnscb(struct dns_ctx *ctx, void *result, void *data) {
|
||||
static void dnscb(struct dns_ctx *ctx, void *result, void *data)
|
||||
{
|
||||
int r = dns_status(ctx);
|
||||
enum_query_t *q = data;
|
||||
struct dns_parse p;
|
||||
@@ -375,25 +381,25 @@ static void dnscb(struct dns_ctx *ctx, void *result, void *data) {
|
||||
dnserror(q, r);
|
||||
return;
|
||||
}
|
||||
pkt = result; end = pkt + r; cur = dns_payload(pkt);
|
||||
pkt = result;
|
||||
end = pkt + r;
|
||||
cur = dns_payload(pkt);
|
||||
dns_getdn(pkt, &cur, end, dn, sizeof(dn));
|
||||
dns_initparse(&p, NULL, pkt, cur, end);
|
||||
p.dnsp_qcls = p.dnsp_qtyp = 0;
|
||||
qdn = dn;
|
||||
nrr = 0;
|
||||
while((r = dns_nextrr(&p, &rr)) > 0) {
|
||||
if (!dns_dnequal(qdn, rr.dnsrr_dn)) continue;
|
||||
if ((qcls == DNS_C_ANY || qcls == rr.dnsrr_cls) &&
|
||||
(q->qtyp == DNS_T_ANY || q->qtyp == rr.dnsrr_typ))
|
||||
while ((r = dns_nextrr(&p, &rr)) > 0) {
|
||||
if (!dns_dnequal(qdn, rr.dnsrr_dn))
|
||||
continue;
|
||||
if ((qcls == DNS_C_ANY || qcls == rr.dnsrr_cls) && (q->qtyp == DNS_T_ANY || q->qtyp == rr.dnsrr_typ))
|
||||
++nrr;
|
||||
else if (rr.dnsrr_typ == DNS_T_CNAME && !nrr) {
|
||||
if (dns_getdn(pkt, &rr.dnsrr_dptr, end,
|
||||
p.dnsp_dnbuf, sizeof(p.dnsp_dnbuf)) <= 0 ||
|
||||
rr.dnsrr_dptr != rr.dnsrr_dend) {
|
||||
p.dnsp_dnbuf, sizeof(p.dnsp_dnbuf)) <= 0 || rr.dnsrr_dptr != rr.dnsrr_dend) {
|
||||
r = DNS_E_PROTOCOL;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
qdn = p.dnsp_dnbuf;
|
||||
}
|
||||
}
|
||||
@@ -409,28 +415,28 @@ static void dnscb(struct dns_ctx *ctx, void *result, void *data) {
|
||||
dns_rewind(&p, NULL);
|
||||
p.dnsp_qtyp = q->qtyp;
|
||||
p.dnsp_qcls = qcls;
|
||||
while(dns_nextrr(&p, &rr)) {
|
||||
while (dns_nextrr(&p, &rr)) {
|
||||
parse_rr(&p, q, &rr);
|
||||
}
|
||||
|
||||
|
||||
free(result);
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t enum_lookup(char *root, char *in, enum_record_t **results)
|
||||
static switch_status_t enum_lookup(char *root, char *in, enum_record_t ** results)
|
||||
{
|
||||
switch_status_t sstatus = SWITCH_STATUS_SUCCESS;
|
||||
switch_status_t sstatus = SWITCH_STATUS_SUCCESS;
|
||||
char *name = NULL;
|
||||
enum_query_t query = {0};
|
||||
enum_query_t query = { 0 };
|
||||
enum dns_type l_qtyp = DNS_T_NAPTR;
|
||||
int i = 0, abs = 0;
|
||||
dns_socket fd = (dns_socket)-1;
|
||||
dns_socket fd = (dns_socket) - 1;
|
||||
fd_set fds;
|
||||
struct timeval tv = {0};
|
||||
struct timeval tv = { 0 };
|
||||
time_t now = 0;
|
||||
struct dns_ctx *nctx = NULL;
|
||||
char *num, *mnum = NULL;
|
||||
|
||||
|
||||
if (*in != '+') {
|
||||
mnum = switch_mprintf("+%s", in);
|
||||
num = mnum;
|
||||
@@ -458,7 +464,7 @@ static switch_status_t enum_lookup(char *root, char *in, enum_record_t **results
|
||||
goto done;
|
||||
}
|
||||
|
||||
dns_ptodn(name, (unsigned int)strlen(name), query.dn, sizeof(query.dn), &abs);
|
||||
dns_ptodn(name, (unsigned int) strlen(name), query.dn, sizeof(query.dn), &abs);
|
||||
query.name = name;
|
||||
query.number = num;
|
||||
query.qtyp = l_qtyp;
|
||||
@@ -466,7 +472,7 @@ static switch_status_t enum_lookup(char *root, char *in, enum_record_t **results
|
||||
if (abs) {
|
||||
abs = DNS_NOSRCH;
|
||||
}
|
||||
|
||||
|
||||
if (!dns_submit_dn(nctx, query.dn, qcls, l_qtyp, abs, 0, dnscb, &query)) {
|
||||
dnserror(&query, dns_status(nctx));
|
||||
}
|
||||
@@ -474,7 +480,7 @@ static switch_status_t enum_lookup(char *root, char *in, enum_record_t **results
|
||||
FD_ZERO(&fds);
|
||||
now = 0;
|
||||
|
||||
while((i = dns_timeouts(nctx, -1, now)) > 0) {
|
||||
while ((i = dns_timeouts(nctx, -1, now)) > 0) {
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4389 4127)
|
||||
@@ -485,9 +491,10 @@ static switch_status_t enum_lookup(char *root, char *in, enum_record_t **results
|
||||
#endif
|
||||
tv.tv_sec = i;
|
||||
tv.tv_usec = 0;
|
||||
i = select((int)(fd+1), &fds, 0, 0, &tv);
|
||||
i = select((int) (fd + 1), &fds, 0, 0, &tv);
|
||||
now = time(NULL);
|
||||
if (i > 0) dns_ioevent(nctx, now);
|
||||
if (i > 0)
|
||||
dns_ioevent(nctx, now);
|
||||
}
|
||||
|
||||
if (!query.results) {
|
||||
@@ -497,17 +504,17 @@ static switch_status_t enum_lookup(char *root, char *in, enum_record_t **results
|
||||
*results = query.results;
|
||||
query.results = NULL;
|
||||
|
||||
done:
|
||||
done:
|
||||
|
||||
if (fd > -1) {
|
||||
closesocket(fd);
|
||||
fd = (dns_socket)-1;
|
||||
fd = (dns_socket) - 1;
|
||||
}
|
||||
|
||||
if (nctx) {
|
||||
dns_free(nctx);
|
||||
}
|
||||
|
||||
|
||||
switch_safe_free(name);
|
||||
switch_safe_free(mnum);
|
||||
|
||||
@@ -524,34 +531,37 @@ static switch_caller_extension_t *enum_dialplan_hunt(switch_core_session_t *sess
|
||||
enum_route_t *rtp;
|
||||
char *dp = (char *) arg;
|
||||
|
||||
assert(channel != NULL);
|
||||
assert(channel != NULL);
|
||||
|
||||
caller_profile = switch_channel_get_caller_profile(channel);
|
||||
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "ENUM Lookup on %s\n", caller_profile->destination_number);
|
||||
|
||||
if (enum_lookup(switch_strlen_zero(dp) ? globals.root : dp, caller_profile->destination_number, &results) == SWITCH_STATUS_SUCCESS) {
|
||||
if ((extension = switch_caller_extension_new(session, caller_profile->destination_number, caller_profile->destination_number)) == 0) {
|
||||
if (enum_lookup(switch_strlen_zero(dp) ? globals.root : dp, caller_profile->destination_number, &results) ==
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
if ((extension =
|
||||
switch_caller_extension_new(session, caller_profile->destination_number,
|
||||
caller_profile->destination_number)) == 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n");
|
||||
free_results(&results);
|
||||
free_results(&results);
|
||||
return NULL;
|
||||
}
|
||||
switch_channel_set_variable(channel, SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE, "true");
|
||||
|
||||
for(rtp = globals.route_order; rtp; rtp = rtp->next) {
|
||||
for(rp = results; rp; rp = rp->next) {
|
||||
|
||||
for (rtp = globals.route_order; rtp; rtp = rtp->next) {
|
||||
for (rp = results; rp; rp = rp->next) {
|
||||
if (!strcmp(rtp->service, rp->service)) {
|
||||
switch_caller_extension_add_application(session, extension, "bridge", rp->route);
|
||||
switch_caller_extension_add_application(session, extension, "bridge", rp->route);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free_results(&results);
|
||||
free_results(&results);
|
||||
}
|
||||
|
||||
if (extension) {
|
||||
switch_channel_set_state(channel, CS_EXECUTE);
|
||||
}
|
||||
switch_channel_set_state(channel, CS_EXECUTE);
|
||||
}
|
||||
|
||||
return extension;
|
||||
|
||||
@@ -560,7 +570,7 @@ static switch_caller_extension_t *enum_dialplan_hunt(switch_core_session_t *sess
|
||||
static void enum_app_function(switch_core_session_t *session, char *data)
|
||||
{
|
||||
int argc = 0;
|
||||
char *argv[4] = {0};
|
||||
char *argv[4] = { 0 };
|
||||
char *mydata = NULL;
|
||||
char *dest = NULL, *root = NULL;
|
||||
enum_record_t *results, *rp;
|
||||
@@ -575,26 +585,27 @@ static void enum_app_function(switch_core_session_t *session, char *data)
|
||||
assert(channel != NULL);
|
||||
|
||||
if (!(mydata = switch_core_session_strdup(session, data))) {
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
|
||||
if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
|
||||
dest = argv[0];
|
||||
root = argv[1] ? argv[1] : globals.root;
|
||||
root = argv[1] ? argv[1] : globals.root;
|
||||
if (enum_lookup(root, data, &results) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_hash_index_t *hi;
|
||||
void *vval;
|
||||
const void *vvar;
|
||||
|
||||
for (hi = switch_channel_variable_first(channel, switch_core_session_get_pool(session)); hi; hi = switch_hash_next(hi)) {
|
||||
for (hi = switch_channel_variable_first(channel, switch_core_session_get_pool(session)); hi;
|
||||
hi = switch_hash_next(hi)) {
|
||||
switch_hash_this(hi, &vvar, NULL, &vval);
|
||||
if (vvar && !strncmp(vvar, "enum_", 5)) {
|
||||
switch_channel_set_variable(channel, (char *) vvar, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
for(rtp = globals.route_order; rtp; rtp = rtp->next) {
|
||||
for(rp = results; rp; rp = rp->next) {
|
||||
for (rtp = globals.route_order; rtp; rtp = rtp->next) {
|
||||
for (rp = results; rp; rp = rp->next) {
|
||||
if (!strcmp(rtp->service, rp->service)) {
|
||||
snprintf(vbuf, sizeof(vbuf), "enum_route_%d", cnt++);
|
||||
switch_channel_set_variable(channel, vbuf, rp->route);
|
||||
@@ -608,19 +619,19 @@ static void enum_app_function(switch_core_session_t *session, char *data)
|
||||
}
|
||||
snprintf(vbuf, sizeof(vbuf), "%d", cnt);
|
||||
switch_channel_set_variable(channel, "enum_route_count", vbuf);
|
||||
*(rbuf+strlen(rbuf)-1) = '\0';
|
||||
*(rbuf + strlen(rbuf) - 1) = '\0';
|
||||
switch_channel_set_variable(channel, "enum_auto_route", rbuf);
|
||||
free_results(&results);
|
||||
free_results(&results);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
static switch_status_t enum_function(char *data, switch_core_session_t *session, switch_stream_handle_t *stream)
|
||||
{
|
||||
|
||||
int argc = 0;
|
||||
char *argv[4] = {0};
|
||||
char *argv[4] = { 0 };
|
||||
enum_record_t *results, *rp;
|
||||
char *mydata = NULL;
|
||||
char *dest = NULL, *root = NULL;
|
||||
@@ -639,35 +650,36 @@ static switch_status_t enum_function(char *data, switch_core_session_t *session,
|
||||
if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
|
||||
dest = argv[0];
|
||||
root = argv[1] ? argv[1] : globals.root;
|
||||
|
||||
|
||||
if (!enum_lookup(root, data, &results) == SWITCH_STATUS_SUCCESS) {
|
||||
stream->write_function(stream, "No Match!\n");
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
stream->write_function(stream,
|
||||
"\nOffered Routes:\n"
|
||||
"Order\tPref\tService \tRoute\n"
|
||||
"==============================================================================\n");
|
||||
|
||||
for(rp = results; rp; rp = rp->next) {
|
||||
for (rp = results; rp; rp = rp->next) {
|
||||
stream->write_function(stream, "%d\t%d\t%-10s\t%s\n", rp->order, rp->preference, rp->service, rp->route);
|
||||
}
|
||||
|
||||
|
||||
|
||||
stream->write_function(stream,
|
||||
"\nSupported Routes:\n"
|
||||
"Order\tPref\tService \tRoute\n"
|
||||
"==============================================================================\n");
|
||||
|
||||
for(rtp = globals.route_order; rtp; rtp = rtp->next) {
|
||||
for(rp = results; rp; rp = rp->next) {
|
||||
for (rtp = globals.route_order; rtp; rtp = rtp->next) {
|
||||
for (rp = results; rp; rp = rp->next) {
|
||||
if (!strcmp(rtp->service, rp->service)) {
|
||||
stream->write_function(stream, "%d\t%d\t%-10s\t%s\n", rp->order, rp->preference, rp->service, rp->route);
|
||||
stream->write_function(stream, "%d\t%d\t%-10s\t%s\n", rp->order, rp->preference, rp->service,
|
||||
rp->route);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
free_results(&results);
|
||||
} else {
|
||||
stream->write_function(stream, "Invalid Input!\n");
|
||||
@@ -678,14 +690,14 @@ static switch_status_t enum_function(char *data, switch_core_session_t *session,
|
||||
|
||||
|
||||
static const switch_dialplan_interface_t enum_dialplan_interface = {
|
||||
/*.interface_name = */ "enum",
|
||||
/*.hunt_function = */ enum_dialplan_hunt
|
||||
/*.next = NULL */
|
||||
/*.interface_name = */ "enum",
|
||||
/*.hunt_function = */ enum_dialplan_hunt
|
||||
/*.next = NULL */
|
||||
};
|
||||
|
||||
static const switch_application_interface_t enum_application_interface = {
|
||||
/*.interface_name */ "enum",
|
||||
/*.application_function */ enum_app_function,
|
||||
/*.application_function */ enum_app_function,
|
||||
/* long_desc */ "Perform an ENUM lookup",
|
||||
/* short_desc */ "Perform an ENUM lookup",
|
||||
/* syntax */ "<number> [<root>]",
|
||||
@@ -714,7 +726,8 @@ static switch_loadable_module_interface_t enum_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)
|
||||
{
|
||||
|
||||
if (dns_init(0) < 0) {
|
||||
@@ -729,5 +742,3 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
|
||||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -39,16 +39,17 @@ static const char modname[] = "mod_ivrtest";
|
||||
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, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
|
||||
static switch_status_t on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf,
|
||||
unsigned int buflen)
|
||||
{
|
||||
switch (itype) {
|
||||
case SWITCH_INPUT_TYPE_DTMF: {
|
||||
char *dtmf = (char *) input;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Digits %s\n", dtmf);
|
||||
|
||||
switch_copy_string((char *)buf, dtmf, buflen);
|
||||
return SWITCH_STATUS_BREAK;
|
||||
}
|
||||
case SWITCH_INPUT_TYPE_DTMF:{
|
||||
char *dtmf = (char *) input;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Digits %s\n", dtmf);
|
||||
|
||||
switch_copy_string((char *) buf, dtmf, buflen);
|
||||
return SWITCH_STATUS_BREAK;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -72,7 +73,7 @@ static void xml_function(switch_core_session_t *session, char *data)
|
||||
for (team = switch_xml_child(f1, "team"); team; team = team->next) {
|
||||
teamname = switch_xml_attr_soft(team, "name");
|
||||
for (driver = switch_xml_child(team, "driver"); driver; driver = driver->next) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
|
||||
"%s, %s: %s\n", switch_xml_child(driver, "name")->txt, teamname,
|
||||
switch_xml_child(driver, "points")->txt);
|
||||
}
|
||||
@@ -84,7 +85,7 @@ static void xml_function(switch_core_session_t *session, char *data)
|
||||
static void ivr_application_function(switch_core_session_t *session, char *data)
|
||||
{
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
char *params = switch_core_session_strdup(session,data);
|
||||
char *params = switch_core_session_strdup(session, data);
|
||||
|
||||
if (channel != NULL && params != NULL) {
|
||||
switch_ivr_menu_t *menu = NULL, *sub_menu = NULL;
|
||||
@@ -98,12 +99,7 @@ static void ivr_application_function(switch_core_session_t *session, char *data)
|
||||
"main",
|
||||
"please enter some numbers so i can figure out if I have any bugs or not",
|
||||
"enter some numbers",
|
||||
NULL,
|
||||
"I have no idea what that is",
|
||||
"cepstral",
|
||||
"david",
|
||||
NULL,
|
||||
15000, 10, NULL);
|
||||
NULL, "I have no idea what that is", "cepstral", "david", NULL, 15000, 10, NULL);
|
||||
|
||||
|
||||
status = switch_ivr_menu_init(&sub_menu,
|
||||
@@ -111,12 +107,7 @@ static void ivr_application_function(switch_core_session_t *session, char *data)
|
||||
"sub",
|
||||
"/ram/congrats.wav",
|
||||
"/ram/extension.wav",
|
||||
NULL,
|
||||
"/ram/invalid.wav",
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
15000, 10, NULL);
|
||||
NULL, "/ram/invalid.wav", NULL, NULL, NULL, 15000, 10, NULL);
|
||||
|
||||
if (status == SWITCH_STATUS_SUCCESS) {
|
||||
// build the menu
|
||||
@@ -125,10 +116,10 @@ static void ivr_application_function(switch_core_session_t *session, char *data)
|
||||
switch_ivr_menu_bind_action(menu, SWITCH_IVR_ACTION_EXECMENU, "sub", "3");
|
||||
//switch_ivr_menu_bind_action(menu, SWITCH_IVR_ACTION_PLAYSOUND, "/usr/local/freeswitch/sounds/3.wav", "3");
|
||||
|
||||
|
||||
|
||||
switch_ivr_menu_bind_action(sub_menu, SWITCH_IVR_ACTION_PLAYSOUND, "/ram/swimp.raw", "1");
|
||||
switch_ivr_menu_bind_action(sub_menu, SWITCH_IVR_ACTION_BACK, NULL, "2");
|
||||
|
||||
|
||||
|
||||
// start the menu
|
||||
status = switch_ivr_menu_execute(session, menu, "main", NULL);
|
||||
@@ -136,11 +127,11 @@ static void ivr_application_function(switch_core_session_t *session, char *data)
|
||||
// cleaup the menu
|
||||
switch_ivr_menu_stack_free(menu);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "unable to build menu %s\n",params);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "unable to build menu %s\n", params);
|
||||
}
|
||||
|
||||
|
||||
switch_ivr_play_file(session, NULL,"/ram/goodbye.wav",NULL);
|
||||
|
||||
switch_ivr_play_file(session, NULL, "/ram/goodbye.wav", NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,15 +142,13 @@ static void dirtest_function(switch_core_session_t *session, char *data)
|
||||
switch_directory_handle_t dh;
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
assert(channel != NULL);
|
||||
assert(channel != NULL);
|
||||
|
||||
|
||||
if (switch_core_directory_open(&dh,
|
||||
if (switch_core_directory_open(&dh,
|
||||
"ldap",
|
||||
"ldap.freeswitch.org",
|
||||
"cn=Manager,dc=freeswitch,dc=org",
|
||||
"test",
|
||||
NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
"cn=Manager,dc=freeswitch,dc=org", "test", NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't connect\n");
|
||||
return;
|
||||
}
|
||||
@@ -177,16 +166,17 @@ static void dirtest_function(switch_core_session_t *session, char *data)
|
||||
|
||||
}
|
||||
|
||||
static switch_status_t show_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
|
||||
static switch_status_t show_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf,
|
||||
unsigned int buflen)
|
||||
{
|
||||
|
||||
switch (itype) {
|
||||
case SWITCH_INPUT_TYPE_DTMF: {
|
||||
char *dtmf = (char *) input;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Digits %s\n", dtmf);
|
||||
case SWITCH_INPUT_TYPE_DTMF:{
|
||||
char *dtmf = (char *) input;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Digits %s\n", dtmf);
|
||||
|
||||
switch_copy_string((char *)buf, dtmf, buflen);
|
||||
}
|
||||
switch_copy_string((char *) buf, dtmf, buflen);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -203,9 +193,9 @@ static void tts_function(switch_core_session_t *session, char *data)
|
||||
char buf[10] = "";
|
||||
char *argv[3];
|
||||
int argc;
|
||||
switch_input_args_t args = {0};
|
||||
switch_input_args_t args = { 0 };
|
||||
|
||||
if(!(mydata = switch_core_session_strdup(session, (char *) data))) {
|
||||
if (!(mydata = switch_core_session_strdup(session, (char *) data))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -221,14 +211,14 @@ static void tts_function(switch_core_session_t *session, char *data)
|
||||
}
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
assert(channel != NULL);
|
||||
|
||||
switch_channel_answer(channel);
|
||||
assert(channel != NULL);
|
||||
|
||||
switch_channel_answer(channel);
|
||||
|
||||
codec = switch_core_session_get_read_codec(session);
|
||||
args.input_callback = show_dtmf;
|
||||
args.buf = buf;
|
||||
args.buflen = sizeof(buf);
|
||||
args.input_callback = show_dtmf;
|
||||
args.buf = buf;
|
||||
args.buflen = sizeof(buf);
|
||||
switch_ivr_speak_text(session, tts_name, voice_name, codec->implementation->samples_per_second, text, &args);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Done\n");
|
||||
}
|
||||
@@ -236,17 +226,17 @@ static void tts_function(switch_core_session_t *session, char *data)
|
||||
#ifdef BUGTEST
|
||||
static switch_bool_t bug_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type)
|
||||
{
|
||||
switch_frame_t *frame;
|
||||
switch_frame_t *frame;
|
||||
|
||||
switch(type) {
|
||||
switch (type) {
|
||||
case SWITCH_ABC_TYPE_WRITE_REPLACE:
|
||||
frame = switch_core_media_bug_get_replace_frame(bug);
|
||||
switch_core_media_bug_set_replace_frame(bug, frame);
|
||||
printf("W00t\n");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
frame = switch_core_media_bug_get_replace_frame(bug);
|
||||
switch_core_media_bug_set_replace_frame(bug, frame);
|
||||
printf("W00t\n");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return SWITCH_TRUE;
|
||||
}
|
||||
@@ -257,56 +247,46 @@ static void bugtest_function(switch_core_session_t *session, char *data)
|
||||
#ifdef BUGTEST
|
||||
switch_media_bug_t *bug;
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
switch_status_t status;
|
||||
switch_status_t status;
|
||||
|
||||
if ((status = switch_core_media_bug_add(session,
|
||||
bug_callback,
|
||||
NULL,
|
||||
SMBF_WRITE_REPLACE,
|
||||
&bug)) != SWITCH_STATUS_SUCCESS) {
|
||||
bug_callback, NULL, SMBF_WRITE_REPLACE, &bug)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
return;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
//switch_ivr_schedule_broadcast(time(NULL) + 10, switch_core_session_get_uuid(session), "/Users/anthm/sr8k.wav", SMF_ECHO_ALEG);
|
||||
//switch_ivr_schedule_transfer(time(NULL) + 10, switch_core_session_get_uuid(session), "2000", NULL, NULL);
|
||||
//switch_ivr_schedule_hangup(time(NULL) + 10, switch_core_session_get_uuid(session), SWITCH_CAUSE_ALLOTTED_TIMEOUT);
|
||||
|
||||
switch_ivr_play_file(session, NULL, data, NULL);
|
||||
switch_ivr_play_file(session, NULL, data, NULL);
|
||||
}
|
||||
|
||||
#if 1
|
||||
static void asrtest_function(switch_core_session_t *session, char *data)
|
||||
{
|
||||
switch_ivr_detect_speech(session,
|
||||
"lumenvox",
|
||||
"demo",
|
||||
data,
|
||||
"127.0.0.1",
|
||||
NULL);
|
||||
switch_ivr_detect_speech(session, "lumenvox", "demo", data, "127.0.0.1", NULL);
|
||||
}
|
||||
|
||||
#else
|
||||
#else
|
||||
static void asrtest_function(switch_core_session_t *session, char *data)
|
||||
{
|
||||
switch_asr_handle_t ah = {0};
|
||||
switch_asr_handle_t ah = { 0 };
|
||||
switch_asr_flag_t flags = SWITCH_ASR_FLAG_NONE;
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
char *codec_name = "L16";
|
||||
switch_codec_t codec = {0}, *read_codec;
|
||||
switch_frame_t write_frame = {0}, *write_frame_p = NULL;
|
||||
switch_codec_t codec = { 0 }, *read_codec;
|
||||
switch_frame_t write_frame = { 0 }, *write_frame_p = NULL;
|
||||
char xdata[1024] = "";
|
||||
|
||||
read_codec = switch_core_session_get_read_codec(session);
|
||||
assert(read_codec != NULL);
|
||||
|
||||
|
||||
|
||||
if (switch_core_asr_open(&ah, "lumenvox",
|
||||
read_codec->implementation->iananame,
|
||||
8000,
|
||||
"127.0.0.1",
|
||||
&flags,
|
||||
switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
|
||||
"127.0.0.1", &flags, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
|
||||
if (strcmp(ah.codec, read_codec->implementation->iananame)) {
|
||||
if (switch_core_codec_init(&codec,
|
||||
ah.codec,
|
||||
@@ -317,36 +297,39 @@ static void asrtest_function(switch_core_session_t *session, char *data)
|
||||
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
|
||||
NULL, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activated\n");
|
||||
switch_core_session_set_read_codec(session, &codec);
|
||||
switch_core_session_set_read_codec(session, &codec);
|
||||
write_frame.data = xdata;
|
||||
write_frame.buflen = sizeof(xdata);
|
||||
write_frame.codec = &codec;
|
||||
write_frame_p = &write_frame;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec Activation Failed %s@%uhz %u channels %dms\n",
|
||||
codec_name, read_codec->implementation->samples_per_second, read_codec->implementation->number_of_channels,
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
|
||||
"Codec Activation Failed %s@%uhz %u channels %dms\n", codec_name,
|
||||
read_codec->implementation->samples_per_second,
|
||||
read_codec->implementation->number_of_channels,
|
||||
read_codec->implementation->microseconds_per_frame / 1000);
|
||||
switch_core_session_reset(session);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (switch_core_asr_load_grammar(&ah, "demo", "/opt/lumenvox/engine_7.0/Lang/BuiltinGrammars/ABNFPhone.gram") != SWITCH_STATUS_SUCCESS) {
|
||||
|
||||
|
||||
if (switch_core_asr_load_grammar(&ah, "demo", "/opt/lumenvox/engine_7.0/Lang/BuiltinGrammars/ABNFPhone.gram") !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Error loading Grammar\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
while(switch_channel_ready(channel)) {
|
||||
|
||||
while (switch_channel_ready(channel)) {
|
||||
switch_frame_t *read_frame;
|
||||
switch_status_t status = switch_core_session_read_frame(session, &read_frame, -1, 0);
|
||||
char *xmlstr = NULL;
|
||||
switch_xml_t xml = NULL, result;
|
||||
|
||||
|
||||
if (!SWITCH_READ_ACCEPTABLE(status)) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (switch_test_flag(read_frame, SFF_CNG)) {
|
||||
continue;
|
||||
}
|
||||
@@ -355,7 +338,7 @@ static void asrtest_function(switch_core_session_t *session, char *data)
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Error Feeding Data\n");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (switch_core_asr_check_results(&ah, &flags) == SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_core_asr_get_results(&ah, &xmlstr, &flags) != SWITCH_STATUS_SUCCESS) {
|
||||
break;
|
||||
@@ -368,7 +351,7 @@ static void asrtest_function(switch_core_session_t *session, char *data)
|
||||
}
|
||||
switch_safe_free(xmlstr);
|
||||
}
|
||||
|
||||
|
||||
if (write_frame_p) {
|
||||
write_frame.datalen = read_frame->datalen;
|
||||
switch_core_session_write_frame(session, write_frame_p, -1, 0);
|
||||
@@ -378,7 +361,7 @@ static void asrtest_function(switch_core_session_t *session, char *data)
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
end:
|
||||
if (write_frame_p) {
|
||||
switch_core_session_set_read_codec(session, read_codec);
|
||||
switch_core_codec_destroy(&codec);
|
||||
@@ -400,9 +383,9 @@ static void ivrtest_function(switch_core_session_t *session, char *data)
|
||||
char buf[10] = "";
|
||||
char term;
|
||||
char say[128] = "";
|
||||
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
assert(channel != NULL);
|
||||
assert(channel != NULL);
|
||||
|
||||
switch_channel_answer(channel);
|
||||
|
||||
@@ -410,18 +393,19 @@ static void ivrtest_function(switch_core_session_t *session, char *data)
|
||||
|
||||
while (switch_channel_get_state(channel) == CS_EXECUTE) {
|
||||
memset(buf, 0, sizeof(buf));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Enter up to 10 digits, press # to terminate, * to hangup\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
|
||||
"Enter up to 10 digits, press # to terminate, * to hangup\n");
|
||||
|
||||
if (data) {
|
||||
switch_input_args_t args = {0};
|
||||
switch_input_args_t args = { 0 };
|
||||
/* you could have passed NULL instead of on_dtmf to get this exact behaviour (copy the digits to buf and stop playing)
|
||||
but you may want to pass the function if you have something cooler to do...
|
||||
*/
|
||||
args.input_callback = on_dtmf;
|
||||
args.buf = buf;
|
||||
args.buflen = sizeof(buf);
|
||||
*/
|
||||
args.input_callback = on_dtmf;
|
||||
args.buf = buf;
|
||||
args.buflen = sizeof(buf);
|
||||
status = switch_ivr_play_file(session, NULL, data, &args);
|
||||
|
||||
|
||||
if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
|
||||
break;
|
||||
@@ -440,7 +424,7 @@ static void ivrtest_function(switch_core_session_t *session, char *data)
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, say);
|
||||
switch_ivr_speak_text(session, "cepstral", "david", codec->implementation->samples_per_second, say, NULL);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -449,9 +433,10 @@ static switch_status_t my_on_hangup(switch_core_session_t *session)
|
||||
switch_channel_t *channel;
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
assert(channel != NULL);
|
||||
assert(channel != NULL);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "I globally hooked to [%s] on the hangup event\n", switch_channel_get_name(channel));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "I globally hooked to [%s] on the hangup event\n",
|
||||
switch_channel_get_name(channel));
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
}
|
||||
@@ -472,7 +457,7 @@ static const switch_application_interface_t bug_application_interface = {
|
||||
/*.application_function */ bugtest_function,
|
||||
NULL, NULL, NULL,
|
||||
/* flags */ SAF_NONE,
|
||||
/*.next*/ NULL
|
||||
/*.next */ NULL
|
||||
};
|
||||
|
||||
static const switch_application_interface_t ivr_application_interface = {
|
||||
@@ -480,7 +465,7 @@ static const switch_application_interface_t ivr_application_interface = {
|
||||
/*.application_function */ ivr_application_function,
|
||||
NULL, NULL, NULL,
|
||||
/* flags */ SAF_NONE,
|
||||
/*.next*/ &bug_application_interface
|
||||
/*.next */ &bug_application_interface
|
||||
};
|
||||
|
||||
static const switch_application_interface_t xml_application_interface = {
|
||||
@@ -488,7 +473,7 @@ static const switch_application_interface_t xml_application_interface = {
|
||||
/*.application_function */ xml_function,
|
||||
NULL, NULL, NULL,
|
||||
/* flags */ SAF_NONE,
|
||||
/*.next*/ &ivr_application_interface
|
||||
/*.next */ &ivr_application_interface
|
||||
};
|
||||
|
||||
static const switch_application_interface_t disast_application_interface = {
|
||||
@@ -496,7 +481,7 @@ static const switch_application_interface_t disast_application_interface = {
|
||||
/*.application_function */ disast_function,
|
||||
NULL, NULL, NULL,
|
||||
/* flags */ SAF_SUPPORT_NOMEDIA,
|
||||
/*.next*/ &xml_application_interface
|
||||
/*.next */ &xml_application_interface
|
||||
};
|
||||
|
||||
static const switch_application_interface_t tts_application_interface = {
|
||||
@@ -504,7 +489,7 @@ static const switch_application_interface_t tts_application_interface = {
|
||||
/*.application_function */ tts_function,
|
||||
NULL, NULL, NULL,
|
||||
/* flags */ SAF_NONE,
|
||||
/*.next*/ &disast_application_interface
|
||||
/*.next */ &disast_application_interface
|
||||
};
|
||||
|
||||
static const switch_application_interface_t dirtest_application_interface = {
|
||||
@@ -512,7 +497,7 @@ static const switch_application_interface_t dirtest_application_interface = {
|
||||
/*.application_function */ dirtest_function,
|
||||
NULL, NULL, NULL,
|
||||
/* flags */ SAF_SUPPORT_NOMEDIA,
|
||||
/*.next*/ &tts_application_interface
|
||||
/*.next */ &tts_application_interface
|
||||
};
|
||||
|
||||
static const switch_application_interface_t ivrtest_application_interface = {
|
||||
@@ -520,7 +505,7 @@ static const switch_application_interface_t ivrtest_application_interface = {
|
||||
/*.application_function */ ivrtest_function,
|
||||
NULL, NULL, NULL,
|
||||
/* flags */ SAF_NONE,
|
||||
/*.next*/ &dirtest_application_interface
|
||||
/*.next */ &dirtest_application_interface
|
||||
};
|
||||
|
||||
static const switch_application_interface_t asrtest_application_interface = {
|
||||
@@ -528,7 +513,7 @@ static const switch_application_interface_t asrtest_application_interface = {
|
||||
/*.application_function */ asrtest_function,
|
||||
NULL, NULL, NULL,
|
||||
/* flags */ SAF_NONE,
|
||||
/*.next*/ &ivrtest_application_interface
|
||||
/*.next */ &ivrtest_application_interface
|
||||
};
|
||||
|
||||
static const switch_loadable_module_interface_t mod_ivrtest_module_interface = {
|
||||
@@ -540,7 +525,8 @@ static const switch_loadable_module_interface_t mod_ivrtest_module_interface = {
|
||||
/*.application_interface */ &asrtest_application_interface
|
||||
};
|
||||
|
||||
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 */
|
||||
|
||||
@@ -35,13 +35,13 @@ static const char modname[] = "mod_park";
|
||||
static void park_function(switch_core_session_t *session, char *data)
|
||||
{
|
||||
switch_ivr_park(session, NULL);
|
||||
|
||||
|
||||
}
|
||||
|
||||
static const switch_application_interface_t park_application_interface = {
|
||||
/*.interface_name */ "park",
|
||||
/*.application_function */ park_function,
|
||||
NULL,NULL,NULL,
|
||||
NULL, NULL, NULL,
|
||||
/* flags */ SAF_NONE,
|
||||
NULL
|
||||
};
|
||||
@@ -59,7 +59,8 @@ static switch_loadable_module_interface_t park_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 */
|
||||
*module_interface = &park_module_interface;
|
||||
|
||||
@@ -38,24 +38,25 @@ static const char modname[] = "mod_playback";
|
||||
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, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
|
||||
static switch_status_t on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf,
|
||||
unsigned int buflen)
|
||||
{
|
||||
|
||||
|
||||
|
||||
switch (itype) {
|
||||
case SWITCH_INPUT_TYPE_DTMF: {
|
||||
char *dtmf = (char *) input;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Digits %s\n", dtmf);
|
||||
|
||||
if (*dtmf == '*') {
|
||||
return SWITCH_STATUS_BREAK;
|
||||
case SWITCH_INPUT_TYPE_DTMF:{
|
||||
char *dtmf = (char *) input;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Digits %s\n", dtmf);
|
||||
|
||||
if (*dtmf == '*') {
|
||||
return SWITCH_STATUS_BREAK;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -64,28 +65,28 @@ static void speak_function(switch_core_session_t *session, char *data)
|
||||
{
|
||||
switch_channel_t *channel;
|
||||
char buf[10];
|
||||
char *argv[4] = {0};
|
||||
char *argv[4] = { 0 };
|
||||
int argc;
|
||||
char *engine = NULL;
|
||||
char *voice = NULL;
|
||||
char *text = NULL;
|
||||
char *mydata = NULL;
|
||||
switch_codec_t *codec;
|
||||
switch_input_args_t args = {0};
|
||||
switch_input_args_t args = { 0 };
|
||||
|
||||
codec = switch_core_session_get_read_codec(session);
|
||||
assert(codec != NULL);
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
assert(channel != NULL);
|
||||
assert(channel != NULL);
|
||||
|
||||
mydata = switch_core_session_strdup(session, data);
|
||||
argc = switch_separate_string(mydata, '|', argv, sizeof(argv)/sizeof(argv[0]));
|
||||
argc = switch_separate_string(mydata, '|', argv, sizeof(argv) / sizeof(argv[0]));
|
||||
|
||||
engine = argv[0];
|
||||
voice = argv[1];
|
||||
text = argv[2];
|
||||
|
||||
|
||||
if (!(engine && voice && text)) {
|
||||
if (!engine) {
|
||||
engine = "NULL";
|
||||
@@ -102,27 +103,27 @@ static void speak_function(switch_core_session_t *session, char *data)
|
||||
|
||||
switch_channel_pre_answer(channel);
|
||||
|
||||
args.input_callback = on_dtmf;
|
||||
args.buf = buf;
|
||||
args.buflen = sizeof(buf);
|
||||
args.input_callback = on_dtmf;
|
||||
args.buf = buf;
|
||||
args.buflen = sizeof(buf);
|
||||
switch_ivr_speak_text(session, engine, voice, codec->implementation->samples_per_second, text, &args);
|
||||
|
||||
|
||||
}
|
||||
|
||||
static void playback_function(switch_core_session_t *session, char *data)
|
||||
{
|
||||
switch_channel_t *channel;
|
||||
char *file_name = NULL;
|
||||
switch_input_args_t args = {0};
|
||||
switch_input_args_t args = { 0 };
|
||||
|
||||
file_name = switch_core_session_strdup(session, data);
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
assert(channel != NULL);
|
||||
assert(channel != NULL);
|
||||
|
||||
switch_channel_pre_answer(channel);
|
||||
|
||||
args.input_callback = on_dtmf;
|
||||
args.input_callback = on_dtmf;
|
||||
switch_ivr_play_file(session, NULL, file_name, &args);
|
||||
|
||||
}
|
||||
@@ -132,21 +133,21 @@ static void record_function(switch_core_session_t *session, char *data)
|
||||
{
|
||||
switch_channel_t *channel;
|
||||
switch_status_t status;
|
||||
uint32_t limit = 0;
|
||||
char *path;
|
||||
char *p;
|
||||
switch_input_args_t args = {0};
|
||||
uint32_t limit = 0;
|
||||
char *path;
|
||||
char *p;
|
||||
switch_input_args_t args = { 0 };
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
assert(channel != NULL);
|
||||
assert(channel != NULL);
|
||||
|
||||
path = switch_core_session_strdup(session, data);
|
||||
if ((p = strchr(path, '+'))) {
|
||||
*p++ = '\0';
|
||||
limit = atoi(p);
|
||||
}
|
||||
path = switch_core_session_strdup(session, data);
|
||||
if ((p = strchr(path, '+'))) {
|
||||
*p++ = '\0';
|
||||
limit = atoi(p);
|
||||
}
|
||||
|
||||
args.input_callback = on_dtmf;
|
||||
args.input_callback = on_dtmf;
|
||||
status = switch_ivr_record_file(session, NULL, path, &args, limit);
|
||||
|
||||
if (!switch_channel_ready(channel) || (status != SWITCH_STATUS_SUCCESS && !SWITCH_STATUS_IS_BREAK(status))) {
|
||||
@@ -159,9 +160,9 @@ static void record_session_function(switch_core_session_t *session, char *data)
|
||||
{
|
||||
switch_channel_t *channel;
|
||||
channel = switch_core_session_get_channel(session);
|
||||
assert(channel != NULL);
|
||||
assert(channel != NULL);
|
||||
|
||||
switch_ivr_record_session(session, data, NULL);
|
||||
switch_ivr_record_session(session, data, NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -169,9 +170,9 @@ static void stop_record_session_function(switch_core_session_t *session, char *d
|
||||
{
|
||||
switch_channel_t *channel;
|
||||
channel = switch_core_session_get_channel(session);
|
||||
assert(channel != NULL);
|
||||
assert(channel != NULL);
|
||||
|
||||
switch_ivr_stop_record_session(session, data);
|
||||
switch_ivr_stop_record_session(session, data);
|
||||
}
|
||||
|
||||
|
||||
@@ -223,7 +224,7 @@ static const switch_application_interface_t playback_application_interface = {
|
||||
/* short_desc */ "Playback File",
|
||||
/* syntax */ "<path>",
|
||||
/* flags */ SAF_NONE,
|
||||
/*.next*/ &stop_record_session_application_interface
|
||||
/*.next */ &stop_record_session_application_interface
|
||||
};
|
||||
|
||||
static const switch_loadable_module_interface_t mod_playback_module_interface = {
|
||||
@@ -235,7 +236,8 @@ static const switch_loadable_module_interface_t mod_playback_module_interface =
|
||||
/*.application_interface */ &playback_application_interface
|
||||
};
|
||||
|
||||
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 */
|
||||
|
||||
@@ -68,9 +68,9 @@ static uint32_t match_count(char *str, uint32_t max)
|
||||
{
|
||||
char tstr[80] = "";
|
||||
uint32_t matches = 0, x = 0;
|
||||
uint32_t len = (uint32_t)strlen(str);
|
||||
uint32_t len = (uint32_t) strlen(str);
|
||||
|
||||
for (x = 0; x < max ; x++) {
|
||||
for (x = 0; x < max; x++) {
|
||||
snprintf(tstr, sizeof(tstr), "%u", x);
|
||||
if (!strncasecmp(str, tstr, len)) {
|
||||
matches++;
|
||||
@@ -85,68 +85,68 @@ static uint32_t match_count(char *str, uint32_t max)
|
||||
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, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
|
||||
|
||||
static switch_status_t on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf,
|
||||
unsigned int buflen)
|
||||
{
|
||||
switch (itype) {
|
||||
case SWITCH_INPUT_TYPE_DTMF: {
|
||||
char *dtmf = (char *) input;
|
||||
struct dtmf_buffer *dtb;
|
||||
dtb = (struct dtmf_buffer *) buf;
|
||||
|
||||
switch(*dtmf) {
|
||||
case '#':
|
||||
switch_set_flag(dtb, SFLAG_MAIN);
|
||||
return SWITCH_STATUS_BREAK;
|
||||
case '6':
|
||||
dtb->index++;
|
||||
return SWITCH_STATUS_BREAK;
|
||||
case '4':
|
||||
dtb->index--;
|
||||
return SWITCH_STATUS_BREAK;
|
||||
case '*':
|
||||
if (switch_test_flag(dtb->sh, SWITCH_SPEECH_FLAG_PAUSE)) {
|
||||
switch_clear_flag(dtb->sh, SWITCH_SPEECH_FLAG_PAUSE);
|
||||
} else {
|
||||
switch_set_flag(dtb->sh, SWITCH_SPEECH_FLAG_PAUSE);
|
||||
}
|
||||
break;
|
||||
case '5':
|
||||
switch_core_speech_text_param_tts(dtb->sh, "voice", "next");
|
||||
switch_set_flag(dtb, SFLAG_INFO);
|
||||
return SWITCH_STATUS_BREAK;
|
||||
break;
|
||||
case '9':
|
||||
switch_core_speech_text_param_tts(dtb->sh, "voice", dtb->voice);
|
||||
switch_set_flag(dtb, SFLAG_INFO);
|
||||
return SWITCH_STATUS_BREAK;
|
||||
break;
|
||||
case '2':
|
||||
if (dtb->speed < 260) {
|
||||
dtb->speed += 30;
|
||||
case SWITCH_INPUT_TYPE_DTMF:{
|
||||
char *dtmf = (char *) input;
|
||||
struct dtmf_buffer *dtb;
|
||||
dtb = (struct dtmf_buffer *) buf;
|
||||
|
||||
switch (*dtmf) {
|
||||
case '#':
|
||||
switch_set_flag(dtb, SFLAG_MAIN);
|
||||
return SWITCH_STATUS_BREAK;
|
||||
case '6':
|
||||
dtb->index++;
|
||||
return SWITCH_STATUS_BREAK;
|
||||
case '4':
|
||||
dtb->index--;
|
||||
return SWITCH_STATUS_BREAK;
|
||||
case '*':
|
||||
if (switch_test_flag(dtb->sh, SWITCH_SPEECH_FLAG_PAUSE)) {
|
||||
switch_clear_flag(dtb->sh, SWITCH_SPEECH_FLAG_PAUSE);
|
||||
} else {
|
||||
switch_set_flag(dtb->sh, SWITCH_SPEECH_FLAG_PAUSE);
|
||||
}
|
||||
break;
|
||||
case '5':
|
||||
switch_core_speech_text_param_tts(dtb->sh, "voice", "next");
|
||||
switch_set_flag(dtb, SFLAG_INFO);
|
||||
return SWITCH_STATUS_BREAK;
|
||||
break;
|
||||
case '9':
|
||||
switch_core_speech_text_param_tts(dtb->sh, "voice", dtb->voice);
|
||||
switch_set_flag(dtb, SFLAG_INFO);
|
||||
return SWITCH_STATUS_BREAK;
|
||||
break;
|
||||
case '2':
|
||||
if (dtb->speed < 260) {
|
||||
dtb->speed += 30;
|
||||
switch_core_speech_numeric_param_tts(dtb->sh, "speech/rate", dtb->speed);
|
||||
switch_set_flag(dtb, SFLAG_INFO);
|
||||
return SWITCH_STATUS_BREAK;
|
||||
}
|
||||
break;
|
||||
case '7':
|
||||
dtb->speed = TTS_MEAN_SPEED;
|
||||
switch_core_speech_numeric_param_tts(dtb->sh, "speech/rate", dtb->speed);
|
||||
switch_set_flag(dtb, SFLAG_INFO);
|
||||
return SWITCH_STATUS_BREAK;
|
||||
}
|
||||
break;
|
||||
case '7':
|
||||
dtb->speed = TTS_MEAN_SPEED;
|
||||
switch_core_speech_numeric_param_tts(dtb->sh, "speech/rate", dtb->speed);
|
||||
switch_set_flag(dtb, SFLAG_INFO);
|
||||
return SWITCH_STATUS_BREAK;
|
||||
case '8':
|
||||
if (dtb->speed > 80) {
|
||||
dtb->speed -= 30;
|
||||
switch_core_speech_numeric_param_tts(dtb->sh, "speech/rate", dtb->speed);
|
||||
switch_set_flag(dtb, SFLAG_INFO);
|
||||
case '8':
|
||||
if (dtb->speed > 80) {
|
||||
dtb->speed -= 30;
|
||||
switch_core_speech_numeric_param_tts(dtb->sh, "speech/rate", dtb->speed);
|
||||
switch_set_flag(dtb, SFLAG_INFO);
|
||||
return SWITCH_STATUS_BREAK;
|
||||
}
|
||||
break;
|
||||
case '0':
|
||||
switch_set_flag(dtb, SFLAG_INSTRUCT);
|
||||
return SWITCH_STATUS_BREAK;
|
||||
}
|
||||
break;
|
||||
case '0':
|
||||
switch_set_flag(dtb, SFLAG_INSTRUCT);
|
||||
return SWITCH_STATUS_BREAK;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -159,9 +159,9 @@ static void rss_function(switch_core_session_t *session, char *data)
|
||||
switch_channel_t *channel;
|
||||
switch_status_t status;
|
||||
const char *err = NULL;
|
||||
struct dtmf_buffer dtb = {0};
|
||||
struct dtmf_buffer dtb = { 0 };
|
||||
switch_xml_t xml = NULL, item, xchannel = NULL;
|
||||
struct rss_entry entries[TTS_MAX_ENTRIES] = {{0}};
|
||||
struct rss_entry entries[TTS_MAX_ENTRIES] = { {0} };
|
||||
uint32_t i = 0;
|
||||
char *title_txt = "", *description_txt = "", *rights_txt = "";
|
||||
switch_codec_t speech_codec, *codec = switch_core_session_get_read_codec(session);
|
||||
@@ -169,31 +169,32 @@ static void rss_function(switch_core_session_t *session, char *data)
|
||||
char *voice = TTS_DEFAULT_VOICE;
|
||||
char *timer_name = NULL;
|
||||
switch_speech_handle_t sh;
|
||||
switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
|
||||
switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
|
||||
switch_core_thread_session_t thread_session;
|
||||
uint32_t rate, interval = 20;
|
||||
int stream_id = 0;
|
||||
switch_timer_t timer = {0}, *timerp = NULL;
|
||||
switch_timer_t timer = { 0 }, *timerp = NULL;
|
||||
uint32_t last;
|
||||
char *mydata = NULL;
|
||||
char *filename = NULL;
|
||||
char *argv[3], *feed_list[TTS_MAX_ENTRIES] = {0} , *feed_names[TTS_MAX_ENTRIES] = {0};
|
||||
char *argv[3], *feed_list[TTS_MAX_ENTRIES] = { 0 }, *feed_names[TTS_MAX_ENTRIES] = {
|
||||
0};
|
||||
int argc, feed_index = 0;
|
||||
char *cf = "rss.conf";
|
||||
switch_xml_t cfg, cxml, feeds, feed;
|
||||
switch_xml_t cfg, cxml, feeds, feed;
|
||||
char buf[1024];
|
||||
int32_t jumpto = -1;
|
||||
uint32_t matches = 0;
|
||||
switch_input_args_t args = {0};
|
||||
switch_input_args_t args = { 0 };
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
assert(channel != NULL);
|
||||
assert(channel != NULL);
|
||||
|
||||
|
||||
if (!(cxml = switch_xml_open_cfg(cf, &cfg, NULL))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
|
||||
return;
|
||||
}
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((feeds = switch_xml_child(cfg, "feeds"))) {
|
||||
for (feed = switch_xml_child(feeds, "feed"); feed; feed = feed->next) {
|
||||
@@ -210,14 +211,14 @@ static void rss_function(switch_core_session_t *session, char *data)
|
||||
}
|
||||
|
||||
switch_xml_free(cxml);
|
||||
|
||||
|
||||
switch_channel_answer(channel);
|
||||
|
||||
|
||||
|
||||
if (!switch_strlen_zero(data)) {
|
||||
if ((mydata = switch_core_session_strdup(session, data))) {
|
||||
argc = switch_separate_string(mydata, ' ', argv, sizeof(argv)/sizeof(argv[0]));
|
||||
argc = switch_separate_string(mydata, ' ', argv, sizeof(argv) / sizeof(argv[0]));
|
||||
|
||||
if (argv[0]) {
|
||||
engine = argv[0];
|
||||
@@ -246,40 +247,40 @@ static void rss_function(switch_core_session_t *session, char *data)
|
||||
memset(&sh, 0, sizeof(sh));
|
||||
if (switch_core_speech_open(&sh,
|
||||
engine,
|
||||
voice,
|
||||
rate,
|
||||
&flags,
|
||||
switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
|
||||
voice, rate, &flags, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid TTS module!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (switch_core_codec_init(&speech_codec,
|
||||
"L16",
|
||||
NULL,
|
||||
(int)rate,
|
||||
(int) rate,
|
||||
interval,
|
||||
1,
|
||||
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
|
||||
NULL,
|
||||
switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
|
||||
NULL, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activated\n");
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed L16@%uhz 1 channel %dms\n", rate, interval);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed L16@%uhz 1 channel %dms\n",
|
||||
rate, interval);
|
||||
flags = 0;
|
||||
switch_core_speech_close(&sh, &flags);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (timer_name) {
|
||||
if (switch_core_timer_init(&timer, timer_name, interval, (int)(rate / 50), switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_core_timer_init
|
||||
(&timer, timer_name, interval, (int) (rate / 50),
|
||||
switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup timer failed!\n");
|
||||
switch_core_codec_destroy(&speech_codec);
|
||||
flags = 0;
|
||||
switch_core_speech_close(&sh, &flags);
|
||||
return;
|
||||
}
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "setup timer success %u bytes per %d ms!\n", (rate / 50)*2, interval);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "setup timer success %u bytes per %d ms!\n",
|
||||
(rate / 50) * 2, interval);
|
||||
|
||||
/* start a thread to absorb incoming audio */
|
||||
for (stream_id = 0; stream_id < switch_core_session_get_stream_count(session); stream_id++) {
|
||||
@@ -292,7 +293,7 @@ static void rss_function(switch_core_session_t *session, char *data)
|
||||
while (switch_channel_ready(channel)) {
|
||||
int32_t len = 0, idx = 0;
|
||||
char cmd[3];
|
||||
main_menu:
|
||||
main_menu:
|
||||
filename = NULL;
|
||||
len = idx = 0;
|
||||
*cmd = '\0';
|
||||
@@ -304,36 +305,30 @@ static void rss_function(switch_core_session_t *session, char *data)
|
||||
} else {
|
||||
switch_core_speech_flush_tts(&sh);
|
||||
#ifdef MATCH_COUNT
|
||||
snprintf(buf + len, sizeof(buf) - len,
|
||||
snprintf(buf + len, sizeof(buf) - len,
|
||||
",<break time=\"500ms\"/>Main Menu. <break time=\"600ms\"/> "
|
||||
"Select one of the following news sources, or press 0 to exit. "
|
||||
",<break time=\"600ms\"/>");
|
||||
"Select one of the following news sources, or press 0 to exit. " ",<break time=\"600ms\"/>");
|
||||
#else
|
||||
snprintf(buf + len, sizeof(buf) - len,
|
||||
snprintf(buf + len, sizeof(buf) - len,
|
||||
",<break time=\"500ms\"/>Main Menu. <break time=\"600ms\"/> "
|
||||
"Select one of the following news sources, followed by the pound key or press 0 to exit. "
|
||||
",<break time=\"600ms\"/>");
|
||||
#endif
|
||||
len = (int32_t)strlen(buf);
|
||||
len = (int32_t) strlen(buf);
|
||||
|
||||
for (idx = 0; idx < feed_index; idx++) {
|
||||
snprintf(buf + len, sizeof(buf) - len, "%d: %s. <break time=\"600ms\"/>", idx + 1, feed_names[idx]);
|
||||
len = (int32_t)strlen(buf);
|
||||
len = (int32_t) strlen(buf);
|
||||
}
|
||||
|
||||
|
||||
snprintf(buf + len, sizeof(buf) - len, "<break time=\"2000ms\"/>");
|
||||
len = (int32_t)strlen(buf);
|
||||
len = (int32_t) strlen(buf);
|
||||
|
||||
args.input_callback = NULL;
|
||||
args.buf = cmd;
|
||||
args.buflen = sizeof(cmd);
|
||||
status = switch_ivr_speak_text_handle(session,
|
||||
&sh,
|
||||
&speech_codec,
|
||||
timerp,
|
||||
buf,
|
||||
&args);
|
||||
status = switch_ivr_speak_text_handle(session, &sh, &speech_codec, timerp, buf, &args);
|
||||
if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
|
||||
goto finished;
|
||||
}
|
||||
@@ -346,31 +341,31 @@ static void rss_function(switch_core_session_t *session, char *data)
|
||||
break;
|
||||
}
|
||||
|
||||
if ((p=strchr(cmd, '#'))) {
|
||||
if ((p = strchr(cmd, '#'))) {
|
||||
*p = '\0';
|
||||
#ifdef MATCH_COUNT
|
||||
/* Hmmm... I know there are no more matches so I don't *need* them to press pound but
|
||||
I already told them to press it. Will this confuse people or not? Let's make em press
|
||||
pound unless this define is enabled for now.
|
||||
*/
|
||||
*/
|
||||
} else if (match_count(cmd, feed_index) > 1) {
|
||||
#else
|
||||
} else {
|
||||
#endif
|
||||
char term;
|
||||
char *cp;
|
||||
int blen = sizeof(cmd) - (int)strlen(cmd);
|
||||
int blen = sizeof(cmd) - (int) strlen(cmd);
|
||||
|
||||
cp = cmd + blen;
|
||||
switch_ivr_collect_digits_count(session, cp, blen, blen, "#", &term, 5000);
|
||||
}
|
||||
|
||||
|
||||
i = atoi(cmd) - 1;
|
||||
|
||||
if (i > -1 && i < feed_index) {
|
||||
filename = feed_list[i];
|
||||
} else if (matches > 1) {
|
||||
|
||||
|
||||
} else {
|
||||
args.input_callback = NULL;
|
||||
args.buf = NULL;
|
||||
@@ -378,19 +373,17 @@ static void rss_function(switch_core_session_t *session, char *data)
|
||||
status = switch_ivr_speak_text_handle(session,
|
||||
&sh,
|
||||
&speech_codec,
|
||||
timerp,
|
||||
"I'm sorry. That is an Invalid Selection. ",
|
||||
&args);
|
||||
timerp, "I'm sorry. That is an Invalid Selection. ", &args);
|
||||
if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
|
||||
goto finished;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!filename) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (!(xml = switch_xml_parse_file(filename))) {
|
||||
@@ -411,7 +404,7 @@ static void rss_function(switch_core_session_t *session, char *data)
|
||||
if ((title = switch_xml_child(xchannel, "title"))) {
|
||||
title_txt = title->txt;
|
||||
}
|
||||
|
||||
|
||||
if ((description = switch_xml_child(xchannel, "description"))) {
|
||||
description_txt = description->txt;
|
||||
}
|
||||
@@ -444,19 +437,19 @@ static void rss_function(switch_core_session_t *session, char *data)
|
||||
if ((title = switch_xml_child(item, "title"))) {
|
||||
entries[i].title_txt = title->txt;
|
||||
}
|
||||
|
||||
|
||||
if ((description = switch_xml_child(item, "description"))) {
|
||||
char *t, *e;
|
||||
entries[i].description_txt = description->txt;
|
||||
for(;;) {
|
||||
for (;;) {
|
||||
if (!(t = strchr(entries[i].description_txt, '<'))) {
|
||||
break;
|
||||
}
|
||||
if (!(e = strchr(t, '>'))) {
|
||||
break;
|
||||
}
|
||||
|
||||
memset(t, 32, ++e-t);
|
||||
|
||||
memset(t, 32, ++e - t);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -471,9 +464,8 @@ static void rss_function(switch_core_session_t *session, char *data)
|
||||
if (entries[i].description_txt && (p = strchr(entries[i].description_txt, '<'))) {
|
||||
*p = '\0';
|
||||
}
|
||||
|
||||
#ifdef _STRIP_SOME_CHARS_
|
||||
for(p = entries[i].description_txt; *p; p++) {
|
||||
for (p = entries[i].description_txt; *p; p++) {
|
||||
if (*p == '\'' || *p == '"' || *p == ':') {
|
||||
*p = ' ';
|
||||
}
|
||||
@@ -493,17 +485,13 @@ static void rss_function(switch_core_session_t *session, char *data)
|
||||
switch_strftime(date, &retsize, sizeof(date), "%I:%M %p", &tm);
|
||||
|
||||
|
||||
snprintf(buf, sizeof(buf), ",<break time=\"500ms\"/>%s. %s. %s. local time: %s, Press 0 for options, 5 to change voice, or pound to return to the main menu. ",
|
||||
snprintf(buf, sizeof(buf),
|
||||
",<break time=\"500ms\"/>%s. %s. %s. local time: %s, Press 0 for options, 5 to change voice, or pound to return to the main menu. ",
|
||||
title_txt, description_txt, rights_txt, date);
|
||||
args.input_callback = NULL;
|
||||
args.buf = cmd;
|
||||
args.buflen = sizeof(cmd);
|
||||
status = switch_ivr_speak_text_handle(session,
|
||||
&sh,
|
||||
&speech_codec,
|
||||
timerp,
|
||||
buf,
|
||||
&args);
|
||||
status = switch_ivr_speak_text_handle(session, &sh, &speech_codec, timerp, buf, &args);
|
||||
if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
|
||||
goto finished;
|
||||
}
|
||||
@@ -519,7 +507,7 @@ static void rss_function(switch_core_session_t *session, char *data)
|
||||
}
|
||||
}
|
||||
|
||||
for(last = 0; last < TTS_MAX_ENTRIES; last++) {
|
||||
for (last = 0; last < TTS_MAX_ENTRIES; last++) {
|
||||
if (!entries[last].inuse) {
|
||||
last--;
|
||||
break;
|
||||
@@ -531,8 +519,8 @@ static void rss_function(switch_core_session_t *session, char *data)
|
||||
dtb.speed = TTS_MEAN_SPEED;
|
||||
switch_set_flag(&dtb, SFLAG_INFO);
|
||||
switch_copy_string(dtb.voice, voice, sizeof(dtb.voice));
|
||||
while(entries[0].inuse && switch_channel_ready(channel)) {
|
||||
while(switch_channel_ready(channel)) {
|
||||
while (entries[0].inuse && switch_channel_ready(channel)) {
|
||||
while (switch_channel_ready(channel)) {
|
||||
uint8_t cont = 0;
|
||||
|
||||
if (dtb.index >= TTS_MAX_ENTRIES) {
|
||||
@@ -557,12 +545,8 @@ static void rss_function(switch_core_session_t *session, char *data)
|
||||
if (switch_test_flag(&dtb, SFLAG_INFO)) {
|
||||
switch_clear_flag(&dtb, SFLAG_INFO);
|
||||
snprintf(buf + len, sizeof(buf) - len,
|
||||
"%s %s. I am speaking at %u words per minute. ",
|
||||
sh.engine,
|
||||
sh.voice,
|
||||
dtb.speed
|
||||
);
|
||||
len = (uint32_t)strlen(buf);
|
||||
"%s %s. I am speaking at %u words per minute. ", sh.engine, sh.voice, dtb.speed);
|
||||
len = (uint32_t) strlen(buf);
|
||||
}
|
||||
|
||||
if (switch_test_flag(&dtb, SFLAG_INSTRUCT)) {
|
||||
@@ -577,33 +561,29 @@ static void rss_function(switch_core_session_t *session, char *data)
|
||||
"To hear these options again, press zero or press pound to return to the main menu. ");
|
||||
} else {
|
||||
snprintf(buf + len, sizeof(buf) - len, "Story %d. ", dtb.index + 1);
|
||||
len = (uint32_t)strlen(buf);
|
||||
len = (uint32_t) strlen(buf);
|
||||
|
||||
if (entries[dtb.index].subject_txt) {
|
||||
snprintf(buf + len, sizeof(buf) - len, "Subject: %s. ", entries[dtb.index].subject_txt);
|
||||
len = (uint32_t)strlen(buf);
|
||||
len = (uint32_t) strlen(buf);
|
||||
}
|
||||
|
||||
|
||||
if (entries[dtb.index].dept_txt) {
|
||||
snprintf(buf + len, sizeof(buf) - len, "From the %s department. ", entries[dtb.index].dept_txt);
|
||||
len = (uint32_t)strlen(buf);
|
||||
snprintf(buf + len, sizeof(buf) - len, "From the %s department. ",
|
||||
entries[dtb.index].dept_txt);
|
||||
len = (uint32_t) strlen(buf);
|
||||
}
|
||||
|
||||
if (entries[dtb.index].title_txt) {
|
||||
snprintf(buf + len, sizeof(buf) - len, "%s", entries[dtb.index].title_txt);
|
||||
len = (uint32_t)strlen(buf);
|
||||
len = (uint32_t) strlen(buf);
|
||||
}
|
||||
}
|
||||
switch_core_speech_flush_tts(&sh);
|
||||
args.input_callback = on_dtmf;
|
||||
args.buf = &dtb;
|
||||
args.buflen = sizeof(dtb);
|
||||
status = switch_ivr_speak_text_handle(session,
|
||||
&sh,
|
||||
&speech_codec,
|
||||
timerp,
|
||||
buf,
|
||||
&args);
|
||||
status = switch_ivr_speak_text_handle(session, &sh, &speech_codec, timerp, buf, &args);
|
||||
if (status == SWITCH_STATUS_BREAK) {
|
||||
continue;
|
||||
} else if (status != SWITCH_STATUS_SUCCESS) {
|
||||
@@ -614,7 +594,7 @@ static void rss_function(switch_core_session_t *session, char *data)
|
||||
cont = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (entries[dtb.index].description_txt) {
|
||||
args.input_callback = on_dtmf;
|
||||
args.buf = &dtb;
|
||||
@@ -622,9 +602,7 @@ static void rss_function(switch_core_session_t *session, char *data)
|
||||
status = switch_ivr_speak_text_handle(session,
|
||||
&sh,
|
||||
&speech_codec,
|
||||
timerp,
|
||||
entries[dtb.index].description_txt,
|
||||
&args);
|
||||
timerp, entries[dtb.index].description_txt, &args);
|
||||
}
|
||||
if (status == SWITCH_STATUS_BREAK) {
|
||||
continue;
|
||||
@@ -638,7 +616,7 @@ static void rss_function(switch_core_session_t *session, char *data)
|
||||
}
|
||||
}
|
||||
|
||||
finished:
|
||||
finished:
|
||||
switch_core_speech_close(&sh, &flags);
|
||||
switch_core_codec_destroy(&speech_codec);
|
||||
|
||||
@@ -659,7 +637,7 @@ static const switch_application_interface_t rss_application_interface = {
|
||||
/*.application_function */ rss_function,
|
||||
NULL, NULL, NULL,
|
||||
/* flags */ SAF_NONE,
|
||||
/*.next*/ NULL
|
||||
/*.next */ NULL
|
||||
};
|
||||
|
||||
|
||||
@@ -677,7 +655,8 @@ static switch_loadable_module_interface_t rss_module_interface = {
|
||||
};
|
||||
|
||||
|
||||
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 */
|
||||
*module_interface = &rss_module_interface;
|
||||
|
||||
@@ -47,7 +47,8 @@ static switch_loadable_module_interface_t skel_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 */
|
||||
*module_interface = &skel_module_interface;
|
||||
|
||||
@@ -69,23 +69,23 @@ typedef struct {
|
||||
|
||||
|
||||
/* This callback caches the audio in the buffer */
|
||||
static swift_result_t write_audio(swift_event *event, swift_event_t type, void *udata)
|
||||
static swift_result_t write_audio(swift_event * event, swift_event_t type, void *udata)
|
||||
{
|
||||
cepstral_t *cepstral;
|
||||
swift_event_t rv = SWIFT_SUCCESS;
|
||||
void *buf = NULL;
|
||||
int len = 0, i = 0;
|
||||
|
||||
swift_event_t rv = SWIFT_SUCCESS;
|
||||
void *buf = NULL;
|
||||
int len = 0, i = 0;
|
||||
|
||||
cepstral = udata;
|
||||
assert(cepstral != NULL);
|
||||
|
||||
|
||||
if (!cepstral->port || cepstral->done || cepstral->done_gen) {
|
||||
return SWIFT_UNKNOWN_ERROR;
|
||||
return SWIFT_UNKNOWN_ERROR;
|
||||
}
|
||||
|
||||
/* Only proceed when we have success */
|
||||
if (!SWIFT_FAILED((rv = swift_event_get_audio(event, &buf, &len)))) {
|
||||
while(!cepstral->done) {
|
||||
if (!SWIFT_FAILED((rv = swift_event_get_audio(event, &buf, &len)))) {
|
||||
while (!cepstral->done) {
|
||||
switch_mutex_lock(cepstral->audio_lock);
|
||||
if (switch_buffer_write(cepstral->audio_buffer, buf, len) > 0) {
|
||||
switch_mutex_unlock(cepstral->audio_lock);
|
||||
@@ -100,7 +100,7 @@ static swift_result_t write_audio(swift_event *event, swift_event_t type, void *
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} else {
|
||||
cepstral->done = 1;
|
||||
@@ -109,11 +109,12 @@ static swift_result_t write_audio(swift_event *event, swift_event_t type, void *
|
||||
if (cepstral->done) {
|
||||
rv = SWIFT_UNKNOWN_ERROR;
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
static switch_status_t cepstral_speech_open(switch_speech_handle_t *sh, char *voice_name, int rate, switch_speech_flag_t *flags)
|
||||
static switch_status_t cepstral_speech_open(switch_speech_handle_t *sh, char *voice_name, int rate,
|
||||
switch_speech_flag_t *flags)
|
||||
{
|
||||
cepstral_t *cepstral = switch_core_alloc(sh->memory_pool, sizeof(*cepstral));
|
||||
char srate[25];
|
||||
@@ -143,7 +144,7 @@ static switch_status_t cepstral_speech_open(switch_speech_handle_t *sh, char *vo
|
||||
goto all_done;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (voice_name && SWIFT_FAILED(swift_port_set_voice_by_name(cepstral->port, voice_name))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid voice %s!\n", voice_name);
|
||||
voice_name = NULL;
|
||||
@@ -157,7 +158,7 @@ static switch_status_t cepstral_speech_open(switch_speech_handle_t *sh, char *vo
|
||||
}
|
||||
|
||||
/* Set the voice found by find_first_voice() as the port's current voice */
|
||||
if ( SWIFT_FAILED(swift_port_set_voice(cepstral->port, cepstral->voice)) ) {
|
||||
if (SWIFT_FAILED(swift_port_set_voice(cepstral->port, cepstral->voice))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to set voice.\n");
|
||||
goto all_done;
|
||||
}
|
||||
@@ -173,8 +174,8 @@ static switch_status_t cepstral_speech_open(switch_speech_handle_t *sh, char *vo
|
||||
|
||||
sh->private_info = cepstral;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
all_done:
|
||||
|
||||
all_done:
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
@@ -185,18 +186,19 @@ static switch_status_t cepstral_speech_close(switch_speech_handle_t *sh, switch_
|
||||
assert(sh != NULL);
|
||||
cepstral = sh->private_info;
|
||||
assert(cepstral != NULL);
|
||||
|
||||
|
||||
|
||||
cepstral->done = 1;
|
||||
cepstral->done_gen = 1;
|
||||
swift_port_stop(cepstral->port, SWIFT_ASYNC_ANY, SWIFT_EVENT_NOW);
|
||||
/* Close the Swift Port and Engine */
|
||||
if (NULL != cepstral->port) swift_port_close(cepstral->port);
|
||||
if (NULL != cepstral->port)
|
||||
swift_port_close(cepstral->port);
|
||||
//if (NULL != cepstral->engine) swift_engine_close(cepstral->engine);
|
||||
|
||||
cepstral->port = NULL;
|
||||
//cepstral->engine = NULL;
|
||||
|
||||
|
||||
switch_buffer_destroy(&cepstral->audio_buffer);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
@@ -206,7 +208,7 @@ static switch_status_t cepstral_speech_feed_tts(switch_speech_handle_t *sh, char
|
||||
{
|
||||
cepstral_t *cepstral;
|
||||
const char *fp = "file:";
|
||||
int len = (int)strlen(fp);
|
||||
int len = (int) strlen(fp);
|
||||
|
||||
assert(sh != NULL);
|
||||
cepstral = sh->private_info;
|
||||
@@ -214,7 +216,7 @@ static switch_status_t cepstral_speech_feed_tts(switch_speech_handle_t *sh, char
|
||||
|
||||
cepstral->done_gen = 0;
|
||||
cepstral->done = 0;
|
||||
|
||||
|
||||
cepstral->tts_stream = NULL;
|
||||
|
||||
if (!strncasecmp(text, fp, len)) {
|
||||
@@ -222,17 +224,17 @@ static switch_status_t cepstral_speech_feed_tts(switch_speech_handle_t *sh, char
|
||||
if (switch_strlen_zero(text)) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
swift_port_speak_file(cepstral->port, text, NULL, &cepstral->tts_stream, NULL);
|
||||
swift_port_speak_file(cepstral->port, text, NULL, &cepstral->tts_stream, NULL);
|
||||
} else {
|
||||
char *to_say;
|
||||
char *to_say;
|
||||
if (switch_strlen_zero(text)) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
if ((to_say = switch_mprintf("<break time=\"500ms\"/> %s <break time=\"500ms\"/>", text))) {
|
||||
swift_port_speak_text(cepstral->port, to_say, 0, NULL, &cepstral->tts_stream, NULL);
|
||||
switch_safe_free(to_say);
|
||||
}
|
||||
if ((to_say = switch_mprintf("<break time=\"500ms\"/> %s <break time=\"500ms\"/>", text))) {
|
||||
swift_port_speak_text(cepstral->port, to_say, 0, NULL, &cepstral->tts_stream, NULL);
|
||||
switch_safe_free(to_say);
|
||||
}
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
@@ -243,10 +245,10 @@ static void cepstral_speech_flush_tts(switch_speech_handle_t *sh)
|
||||
cepstral_t *cepstral;
|
||||
|
||||
cepstral = sh->private_info;
|
||||
assert(cepstral != NULL);
|
||||
assert(cepstral != NULL);
|
||||
|
||||
cepstral->done_gen = 1;
|
||||
cepstral->done = 1;
|
||||
cepstral->done = 1;
|
||||
if (cepstral->audio_buffer) {
|
||||
switch_mutex_lock(cepstral->audio_lock);
|
||||
switch_buffer_zero(cepstral->audio_buffer);
|
||||
@@ -257,9 +259,7 @@ static void cepstral_speech_flush_tts(switch_speech_handle_t *sh)
|
||||
|
||||
static switch_status_t cepstral_speech_read_tts(switch_speech_handle_t *sh,
|
||||
void *data,
|
||||
size_t *datalen,
|
||||
uint32_t *rate,
|
||||
switch_speech_flag_t *flags)
|
||||
size_t *datalen, uint32_t * rate, switch_speech_flag_t *flags)
|
||||
{
|
||||
cepstral_t *cepstral;
|
||||
size_t desired = *datalen;
|
||||
@@ -270,7 +270,7 @@ static switch_status_t cepstral_speech_read_tts(switch_speech_handle_t *sh,
|
||||
cepstral = sh->private_info;
|
||||
assert(cepstral != NULL);
|
||||
|
||||
while(!cepstral->done) {
|
||||
while (!cepstral->done) {
|
||||
if (!cepstral->done_gen) {
|
||||
int check = swift_port_status(cepstral->port, cepstral->tts_stream);
|
||||
|
||||
@@ -282,8 +282,8 @@ static switch_status_t cepstral_speech_read_tts(switch_speech_handle_t *sh,
|
||||
switch_mutex_lock(cepstral->audio_lock);
|
||||
used = switch_buffer_inuse(cepstral->audio_buffer);
|
||||
switch_mutex_unlock(cepstral->audio_lock);
|
||||
|
||||
|
||||
|
||||
|
||||
if (!used && cepstral->done_gen) {
|
||||
|
||||
status = SWITCH_STATUS_BREAK;
|
||||
@@ -304,15 +304,15 @@ static switch_status_t cepstral_speech_read_tts(switch_speech_handle_t *sh,
|
||||
switch_yield(1000);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
/* There is enough, read it and return */
|
||||
switch_mutex_lock(cepstral->audio_lock);
|
||||
*datalen = switch_buffer_read(cepstral->audio_buffer, data, desired);
|
||||
if (padding) {
|
||||
size_t x = 0;
|
||||
unsigned char *p = data;
|
||||
|
||||
for(x = 0; x < padding; x++) {
|
||||
|
||||
for (x = 0; x < padding; x++) {
|
||||
*(p + x) = 0;
|
||||
(*datalen)++;
|
||||
}
|
||||
@@ -323,7 +323,7 @@ static switch_status_t cepstral_speech_read_tts(switch_speech_handle_t *sh,
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -338,7 +338,7 @@ static void cepstral_text_param_tts(switch_speech_handle_t *sh, char *param, cha
|
||||
char *voice_name = val;
|
||||
if (!strcasecmp(voice_name, "next")) {
|
||||
if ((cepstral->voice = swift_port_find_next_voice(cepstral->port))) {
|
||||
if ( SWIFT_FAILED(swift_port_set_voice(cepstral->port, cepstral->voice)) ) {
|
||||
if (SWIFT_FAILED(swift_port_set_voice(cepstral->port, cepstral->voice))) {
|
||||
cepstral->done = cepstral->done_gen = 1;
|
||||
return;
|
||||
}
|
||||
@@ -354,22 +354,22 @@ static void cepstral_text_param_tts(switch_speech_handle_t *sh, char *param, cha
|
||||
}
|
||||
|
||||
if (!voice_name) {
|
||||
/* Find the first voice on the system */
|
||||
if ((cepstral->voice = swift_port_find_first_voice(cepstral->port, NULL, NULL)) == NULL) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to find any voices!\n");
|
||||
/* Find the first voice on the system */
|
||||
if ((cepstral->voice = swift_port_find_first_voice(cepstral->port, NULL, NULL)) == NULL) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to find any voices!\n");
|
||||
cepstral->done = cepstral->done_gen = 1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the voice found by find_first_voice() as the port's current voice */
|
||||
if ( SWIFT_FAILED(swift_port_set_voice(cepstral->port, cepstral->voice)) ) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to set voice.\n");
|
||||
/* Set the voice found by find_first_voice() as the port's current voice */
|
||||
if (SWIFT_FAILED(swift_port_set_voice(cepstral->port, cepstral->voice))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to set voice.\n");
|
||||
cepstral->done = cepstral->done_gen = 1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
voice_name = (char *) swift_voice_get_attribute(cepstral->voice, "name");
|
||||
}
|
||||
}
|
||||
|
||||
if (voice_name) {
|
||||
switch_copy_string(sh->voice, voice_name, sizeof(sh->voice));
|
||||
@@ -405,15 +405,15 @@ static void cepstral_float_param_tts(switch_speech_handle_t *sh, char *param, do
|
||||
}
|
||||
|
||||
static const switch_speech_interface_t cepstral_speech_interface = {
|
||||
/*.interface_name*/ "cepstral",
|
||||
/*.speech_open*/ cepstral_speech_open,
|
||||
/*.speech_close*/ cepstral_speech_close,
|
||||
/*.speech_feed_tts*/ cepstral_speech_feed_tts,
|
||||
/*.speech_read_tts*/ cepstral_speech_read_tts,
|
||||
/*.speech_flush_tts*/ cepstral_speech_flush_tts,
|
||||
/*.speech_text_param_tts*/ cepstral_text_param_tts,
|
||||
/*.speech_numeric_param_tts*/ cepstral_numeric_param_tts,
|
||||
/*.speech_numeric_param_tts*/ cepstral_float_param_tts
|
||||
/*.interface_name */ "cepstral",
|
||||
/*.speech_open */ cepstral_speech_open,
|
||||
/*.speech_close */ cepstral_speech_close,
|
||||
/*.speech_feed_tts */ cepstral_speech_feed_tts,
|
||||
/*.speech_read_tts */ cepstral_speech_read_tts,
|
||||
/*.speech_flush_tts */ cepstral_speech_flush_tts,
|
||||
/*.speech_text_param_tts */ cepstral_text_param_tts,
|
||||
/*.speech_numeric_param_tts */ cepstral_numeric_param_tts,
|
||||
/*.speech_numeric_param_tts */ cepstral_float_param_tts
|
||||
};
|
||||
|
||||
static const switch_loadable_module_interface_t cepstral_module_interface = {
|
||||
@@ -433,11 +433,11 @@ switch_status_t switch_module_load(const switch_loadable_module_interface_t **mo
|
||||
{
|
||||
|
||||
/* Open the Swift TTS Engine */
|
||||
if ( SWIFT_FAILED(engine = swift_engine_open(NULL)) ) {
|
||||
if (SWIFT_FAILED(engine = swift_engine_open(NULL))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to open Swift Engine.");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = &cepstral_module_interface;
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
*
|
||||
* mod_amr.c -- GSM-AMR Codec Module
|
||||
*
|
||||
*/
|
||||
*/
|
||||
#include "switch.h"
|
||||
static const char modname[] = "mod_amr";
|
||||
|
||||
@@ -114,14 +114,14 @@ static struct {
|
||||
#endif
|
||||
|
||||
static switch_status_t switch_amr_init(switch_codec_t *codec, switch_codec_flag_t flags,
|
||||
const switch_codec_settings_t *codec_settings)
|
||||
const switch_codec_settings_t *codec_settings)
|
||||
{
|
||||
|
||||
#ifdef AMR_PASSTHROUGH
|
||||
codec->flags |= SWITCH_CODEC_FLAG_PASSTHROUGH;
|
||||
if (codec->fmtp_in) {
|
||||
codec->fmtp_out = switch_core_strdup(codec->memory_pool, codec->fmtp_in);
|
||||
}
|
||||
if (codec->fmtp_in) {
|
||||
codec->fmtp_out = switch_core_strdup(codec->memory_pool, codec->fmtp_in);
|
||||
}
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
#else
|
||||
struct amr_context *context = NULL;
|
||||
@@ -139,10 +139,10 @@ static switch_status_t switch_amr_init(switch_codec_t *codec, switch_codec_flag_
|
||||
|
||||
if (codec->fmtp_in) {
|
||||
argc = switch_separate_string(codec->fmtp_in, ';', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
for(x = 0; x < argc; x++) {
|
||||
for (x = 0; x < argc; x++) {
|
||||
char *data = argv[x];
|
||||
char *arg;
|
||||
while(*data && *data == ' ') {
|
||||
while (*data && *data == ' ') {
|
||||
data++;
|
||||
}
|
||||
if ((arg = strchr(data, '='))) {
|
||||
@@ -171,16 +171,16 @@ static switch_status_t switch_amr_init(switch_codec_t *codec, switch_codec_flag_
|
||||
} else if (!strcasecmp(data, "mode-change-period")) {
|
||||
context->change_period = atoi(arg);
|
||||
} else if (!strcasecmp(data, "ptime")) {
|
||||
context->ptime = (switch_byte_t)atoi(arg);
|
||||
context->ptime = (switch_byte_t) atoi(arg);
|
||||
} else if (!strcasecmp(data, "channels")) {
|
||||
context->channels = (switch_byte_t)atoi(arg);
|
||||
context->channels = (switch_byte_t) atoi(arg);
|
||||
} else if (!strcasecmp(data, "maxptime")) {
|
||||
context->max_ptime = (switch_byte_t)atoi(arg);
|
||||
context->max_ptime = (switch_byte_t) atoi(arg);
|
||||
} else if (!strcasecmp(data, "mode-set")) {
|
||||
int y, m_argc;
|
||||
char *m_argv[7];
|
||||
m_argc = switch_separate_string(arg, ',', m_argv, (sizeof(m_argv) / sizeof(m_argv[0])));
|
||||
for(y = 0; y < m_argc; y++) {
|
||||
for (y = 0; y < m_argc; y++) {
|
||||
context->enc_modes |= (1 << atoi(m_argv[y]));
|
||||
}
|
||||
}
|
||||
@@ -192,7 +192,7 @@ static switch_status_t switch_amr_init(switch_codec_t *codec, switch_codec_flag_
|
||||
if (context->enc_modes) {
|
||||
for (i = 7; i > -1; i++) {
|
||||
if (context->enc_modes & (1 << i)) {
|
||||
context->enc_mode = (switch_byte_t)i;
|
||||
context->enc_mode = (switch_byte_t) i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -201,10 +201,11 @@ static switch_status_t switch_amr_init(switch_codec_t *codec, switch_codec_flag_
|
||||
if (!context->enc_mode) {
|
||||
context->enc_mode = globals.default_bitrate;
|
||||
}
|
||||
|
||||
snprintf(fmtptmp, sizeof(fmtptmp), "octet-align=%d; mode-set=%d", switch_test_flag(context, AMR_OPT_OCTET_ALIGN) ? 1 : 0, context->enc_mode);
|
||||
|
||||
snprintf(fmtptmp, sizeof(fmtptmp), "octet-align=%d; mode-set=%d",
|
||||
switch_test_flag(context, AMR_OPT_OCTET_ALIGN) ? 1 : 0, context->enc_mode);
|
||||
codec->fmtp_out = switch_core_strdup(codec->memory_pool, fmtptmp);
|
||||
|
||||
|
||||
context->enc_mode = AMR_DEFAULT_BITRATE;
|
||||
context->encoder_state = NULL;
|
||||
context->decoder_state = NULL;
|
||||
@@ -224,7 +225,7 @@ static switch_status_t switch_amr_init(switch_codec_t *codec, switch_codec_flag_
|
||||
#endif
|
||||
}
|
||||
|
||||
static switch_status_t switch_amr_destroy(switch_codec_t *codec)
|
||||
static switch_status_t switch_amr_destroy(switch_codec_t *codec)
|
||||
{
|
||||
#ifndef AMR_PASSTHROUGH
|
||||
struct amr_context *context = codec->private_info;
|
||||
@@ -240,45 +241,39 @@ static switch_status_t switch_amr_destroy(switch_codec_t *codec)
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t switch_amr_encode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *decoded_data,
|
||||
|
||||
uint32_t decoded_data_len,
|
||||
uint32_t decoded_rate,
|
||||
void *encoded_data,
|
||||
|
||||
uint32_t *encoded_data_len,
|
||||
uint32_t *encoded_rate,
|
||||
unsigned int *flag)
|
||||
static switch_status_t switch_amr_encode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *decoded_data,
|
||||
uint32_t decoded_data_len,
|
||||
uint32_t decoded_rate,
|
||||
void *encoded_data,
|
||||
uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
|
||||
{
|
||||
#ifdef AMR_PASSTHROUGH
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
#else
|
||||
struct amr_context *context = codec->private_info;
|
||||
|
||||
|
||||
if (!context) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
*encoded_data_len = Encoder_Interface_Encode( context->encoder_state, context->enc_mode, (int16_t *)decoded_data, (switch_byte_t *) encoded_data, 0);
|
||||
|
||||
*encoded_data_len =
|
||||
Encoder_Interface_Encode(context->encoder_state, context->enc_mode, (int16_t *) decoded_data,
|
||||
(switch_byte_t *) encoded_data, 0);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
#endif
|
||||
}
|
||||
|
||||
static switch_status_t switch_amr_decode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *encoded_data,
|
||||
|
||||
uint32_t encoded_data_len,
|
||||
uint32_t encoded_rate,
|
||||
void *decoded_data,
|
||||
|
||||
uint32_t *decoded_data_len,
|
||||
uint32_t *decoded_rate,
|
||||
unsigned int *flag)
|
||||
static switch_status_t switch_amr_decode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *encoded_data,
|
||||
uint32_t encoded_data_len,
|
||||
uint32_t encoded_rate,
|
||||
void *decoded_data,
|
||||
uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
|
||||
{
|
||||
#ifdef AMR_PASSTHROUGH
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
|
||||
@@ -290,51 +285,51 @@ static switch_status_t switch_amr_decode(switch_codec_t *codec,
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
Decoder_Interface_Decode(context->decoder_state, (unsigned char *)encoded_data, (int16_t *)decoded_data, 0);
|
||||
Decoder_Interface_Decode(context->decoder_state, (unsigned char *) encoded_data, (int16_t *) decoded_data, 0);
|
||||
*decoded_data_len = codec->implementation->bytes_per_frame;
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Registration */
|
||||
/* Registration */
|
||||
|
||||
static const switch_codec_implementation_t amr_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 96,
|
||||
/*.iananame */ "AMR",
|
||||
static const switch_codec_implementation_t amr_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 96,
|
||||
/*.iananame */ "AMR",
|
||||
/*.fmtp */ "octet-align=0",
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.bits_per_second */ 0,
|
||||
/*.microseconds_per_frame */ 20000,
|
||||
/*.samples_per_frame */ 160,
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.bits_per_second */ 0,
|
||||
/*.microseconds_per_frame */ 20000,
|
||||
/*.samples_per_frame */ 160,
|
||||
/*.bytes_per_frame */ 320,
|
||||
/*.encoded_bytes_per_frame */ 0,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_amr_init,
|
||||
/*.encode */ switch_amr_encode,
|
||||
/*.decode */ switch_amr_decode,
|
||||
/*.destroy */ switch_amr_destroy,
|
||||
/*.encoded_bytes_per_frame */ 0,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_amr_init,
|
||||
/*.encode */ switch_amr_encode,
|
||||
/*.decode */ switch_amr_decode,
|
||||
/*.destroy */ switch_amr_destroy,
|
||||
};
|
||||
|
||||
static const switch_codec_interface_t amr_codec_interface = {
|
||||
/*.interface_name */ "GSM-AMR",
|
||||
/*.implementations */ &amr_implementation,
|
||||
static const switch_codec_interface_t amr_codec_interface = {
|
||||
/*.interface_name */ "GSM-AMR",
|
||||
/*.implementations */ &amr_implementation,
|
||||
};
|
||||
|
||||
static switch_loadable_module_interface_t amr_module_interface = {
|
||||
/*.module_name */ modname,
|
||||
/*.endpoint_interface */ NULL,
|
||||
/*.timer_interface */ NULL,
|
||||
/*.dialplan_interface */ NULL,
|
||||
/*.codec_interface */ &amr_codec_interface,
|
||||
/*.application_interface */ NULL
|
||||
static switch_loadable_module_interface_t amr_module_interface = {
|
||||
/*.module_name */ modname,
|
||||
/*.endpoint_interface */ NULL,
|
||||
/*.timer_interface */ NULL,
|
||||
/*.dialplan_interface */ NULL,
|
||||
/*.codec_interface */ &amr_codec_interface,
|
||||
/*.application_interface */ NULL
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
char *filename)
|
||||
{
|
||||
#ifndef AMR_PASSTHROUGH
|
||||
char *cf = "amr.conf";
|
||||
@@ -349,17 +344,16 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
|
||||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||
char *val = (char *) switch_xml_attr_soft(param, "value");
|
||||
if (!strcasecmp(var, "default-bitrate")) {
|
||||
globals.default_bitrate = (switch_byte_t)atoi(val);
|
||||
globals.default_bitrate = (switch_byte_t) atoi(val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = &amr_module_interface;
|
||||
|
||||
/* indicate that the module should continue to be loaded */
|
||||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ static const char modname[] = "mod_g711";
|
||||
|
||||
|
||||
static switch_status_t switch_g711u_init(switch_codec_t *codec, switch_codec_flag_t flags,
|
||||
const switch_codec_settings_t *codec_settings)
|
||||
const switch_codec_settings_t *codec_settings)
|
||||
{
|
||||
int encoding, decoding;
|
||||
|
||||
@@ -53,12 +53,12 @@ static switch_status_t switch_g711u_init(switch_codec_t *codec, switch_codec_fla
|
||||
|
||||
|
||||
static switch_status_t switch_g711u_encode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *decoded_data,
|
||||
uint32_t decoded_data_len,
|
||||
uint32_t decoded_rate,
|
||||
void *encoded_data,
|
||||
uint32_t *encoded_data_len, uint32_t *encoded_rate, unsigned int *flag)
|
||||
switch_codec_t *other_codec,
|
||||
void *decoded_data,
|
||||
uint32_t decoded_data_len,
|
||||
uint32_t decoded_rate,
|
||||
void *encoded_data,
|
||||
uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
|
||||
{
|
||||
short *dbuf;
|
||||
unsigned char *ebuf;
|
||||
@@ -77,12 +77,12 @@ static switch_status_t switch_g711u_encode(switch_codec_t *codec,
|
||||
}
|
||||
|
||||
static switch_status_t switch_g711u_decode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *encoded_data,
|
||||
uint32_t encoded_data_len,
|
||||
uint32_t encoded_rate,
|
||||
void *decoded_data,
|
||||
uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag)
|
||||
switch_codec_t *other_codec,
|
||||
void *encoded_data,
|
||||
uint32_t encoded_data_len,
|
||||
uint32_t encoded_rate,
|
||||
void *decoded_data,
|
||||
uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
|
||||
{
|
||||
short *dbuf;
|
||||
unsigned char *ebuf;
|
||||
@@ -112,7 +112,7 @@ static switch_status_t switch_g711u_destroy(switch_codec_t *codec)
|
||||
|
||||
|
||||
static switch_status_t switch_g711a_init(switch_codec_t *codec, switch_codec_flag_t flags,
|
||||
const switch_codec_settings_t *codec_settings)
|
||||
const switch_codec_settings_t *codec_settings)
|
||||
{
|
||||
int encoding, decoding;
|
||||
|
||||
@@ -128,12 +128,12 @@ static switch_status_t switch_g711a_init(switch_codec_t *codec, switch_codec_fla
|
||||
|
||||
|
||||
static switch_status_t switch_g711a_encode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *decoded_data,
|
||||
uint32_t decoded_data_len,
|
||||
uint32_t decoded_rate,
|
||||
void *encoded_data,
|
||||
uint32_t *encoded_data_len, uint32_t *encoded_rate, unsigned int *flag)
|
||||
switch_codec_t *other_codec,
|
||||
void *decoded_data,
|
||||
uint32_t decoded_data_len,
|
||||
uint32_t decoded_rate,
|
||||
void *encoded_data,
|
||||
uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
|
||||
{
|
||||
short *dbuf;
|
||||
unsigned char *ebuf;
|
||||
@@ -152,12 +152,12 @@ static switch_status_t switch_g711a_encode(switch_codec_t *codec,
|
||||
}
|
||||
|
||||
static switch_status_t switch_g711a_decode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *encoded_data,
|
||||
uint32_t encoded_data_len,
|
||||
uint32_t encoded_rate,
|
||||
void *decoded_data,
|
||||
uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag)
|
||||
switch_codec_t *other_codec,
|
||||
void *encoded_data,
|
||||
uint32_t encoded_data_len,
|
||||
uint32_t encoded_rate,
|
||||
void *decoded_data,
|
||||
uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
|
||||
{
|
||||
short *dbuf;
|
||||
unsigned char *ebuf;
|
||||
@@ -226,7 +226,7 @@ static const switch_codec_implementation_t g711u_8k_60ms_implementation = {
|
||||
/*.encode */ switch_g711u_encode,
|
||||
/*.decode */ switch_g711u_decode,
|
||||
/*.destroy */ switch_g711u_destroy,
|
||||
/*.next*/ &g711u_8k_120ms_implementation
|
||||
/*.next */ &g711u_8k_120ms_implementation
|
||||
};
|
||||
|
||||
static const switch_codec_implementation_t g711u_8k_30ms_implementation = {
|
||||
@@ -247,7 +247,7 @@ static const switch_codec_implementation_t g711u_8k_30ms_implementation = {
|
||||
/*.encode */ switch_g711u_encode,
|
||||
/*.decode */ switch_g711u_decode,
|
||||
/*.destroy */ switch_g711u_destroy,
|
||||
/*.next*/ &g711u_8k_60ms_implementation
|
||||
/*.next */ &g711u_8k_60ms_implementation
|
||||
};
|
||||
|
||||
static const switch_codec_implementation_t g711u_8k_20ms_implementation = {
|
||||
@@ -268,7 +268,7 @@ static const switch_codec_implementation_t g711u_8k_20ms_implementation = {
|
||||
/*.encode */ switch_g711u_encode,
|
||||
/*.decode */ switch_g711u_decode,
|
||||
/*.destroy */ switch_g711u_destroy,
|
||||
/*.next*/ &g711u_8k_30ms_implementation
|
||||
/*.next */ &g711u_8k_30ms_implementation
|
||||
};
|
||||
|
||||
static const switch_codec_implementation_t g711u_8k_10ms_implementation = {
|
||||
@@ -289,7 +289,7 @@ static const switch_codec_implementation_t g711u_8k_10ms_implementation = {
|
||||
/*.encode */ switch_g711u_encode,
|
||||
/*.decode */ switch_g711u_decode,
|
||||
/*.destroy */ switch_g711u_destroy,
|
||||
/*.next*/ &g711u_8k_20ms_implementation
|
||||
/*.next */ &g711u_8k_20ms_implementation
|
||||
};
|
||||
|
||||
|
||||
@@ -332,7 +332,7 @@ static const switch_codec_implementation_t g711a_8k_60ms_implementation = {
|
||||
/*.encode */ switch_g711a_encode,
|
||||
/*.decode */ switch_g711a_decode,
|
||||
/*.destroy */ switch_g711a_destroy,
|
||||
/*.next*/ &g711a_8k_120ms_implementation
|
||||
/*.next */ &g711a_8k_120ms_implementation
|
||||
};
|
||||
|
||||
static const switch_codec_implementation_t g711a_8k_30ms_implementation = {
|
||||
@@ -353,7 +353,7 @@ static const switch_codec_implementation_t g711a_8k_30ms_implementation = {
|
||||
/*.encode */ switch_g711a_encode,
|
||||
/*.decode */ switch_g711a_decode,
|
||||
/*.destroy */ switch_g711a_destroy,
|
||||
/*.next*/ &g711a_8k_60ms_implementation
|
||||
/*.next */ &g711a_8k_60ms_implementation
|
||||
};
|
||||
|
||||
static const switch_codec_implementation_t g711a_8k_20ms_implementation = {
|
||||
@@ -374,7 +374,7 @@ static const switch_codec_implementation_t g711a_8k_20ms_implementation = {
|
||||
/*.encode */ switch_g711a_encode,
|
||||
/*.decode */ switch_g711a_decode,
|
||||
/*.destroy */ switch_g711a_destroy,
|
||||
/*.next*/ &g711a_8k_30ms_implementation
|
||||
/*.next */ &g711a_8k_30ms_implementation
|
||||
};
|
||||
|
||||
static const switch_codec_implementation_t g711a_8k_10ms_implementation = {
|
||||
@@ -395,7 +395,7 @@ static const switch_codec_implementation_t g711a_8k_10ms_implementation = {
|
||||
/*.encode */ switch_g711a_encode,
|
||||
/*.decode */ switch_g711a_decode,
|
||||
/*.destroy */ switch_g711a_destroy,
|
||||
/*.next*/ &g711a_8k_20ms_implementation
|
||||
/*.next */ &g711a_8k_20ms_implementation
|
||||
};
|
||||
|
||||
|
||||
@@ -421,7 +421,8 @@ static switch_loadable_module_interface_t g711_module_interface = {
|
||||
};
|
||||
|
||||
|
||||
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 */
|
||||
*module_interface = &g711_module_interface;
|
||||
|
||||
@@ -41,7 +41,7 @@ struct g722_context {
|
||||
};
|
||||
|
||||
static switch_status_t switch_g722_init(switch_codec_t *codec, switch_codec_flag_t flags,
|
||||
const switch_codec_settings_t *codec_settings)
|
||||
const switch_codec_settings_t *codec_settings)
|
||||
{
|
||||
int encoding, decoding;
|
||||
struct g722_context *context = NULL;
|
||||
@@ -50,18 +50,18 @@ static switch_status_t switch_g722_init(switch_codec_t *codec, switch_codec_flag
|
||||
encoding = (flags & SWITCH_CODEC_FLAG_ENCODE);
|
||||
decoding = (flags & SWITCH_CODEC_FLAG_DECODE);
|
||||
|
||||
if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->memory_pool, sizeof(struct g722_context))))) {
|
||||
if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->memory_pool, sizeof(struct g722_context))))) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
} else {
|
||||
if (encoding) {
|
||||
if(codec->implementation->samples_per_second == 16000){
|
||||
if (codec->implementation->samples_per_second == 16000) {
|
||||
g722_encode_init(&context->encoder_object, 64000, G722_PACKED);
|
||||
} else {
|
||||
g722_encode_init(&context->encoder_object, 64000, G722_SAMPLE_RATE_8000);
|
||||
}
|
||||
}
|
||||
if (decoding) {
|
||||
if(codec->implementation->samples_per_second == 16000){
|
||||
if (codec->implementation->samples_per_second == 16000) {
|
||||
g722_decode_init(&context->decoder_object, 64000, G722_PACKED);
|
||||
} else {
|
||||
g722_decode_init(&context->decoder_object, 64000, G722_SAMPLE_RATE_8000);
|
||||
@@ -70,44 +70,47 @@ static switch_status_t switch_g722_init(switch_codec_t *codec, switch_codec_flag
|
||||
}
|
||||
|
||||
codec->private_info = context;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t switch_g722_encode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *decoded_data,
|
||||
uint32_t decoded_data_len,
|
||||
uint32_t decoded_rate,
|
||||
void *encoded_data,
|
||||
uint32_t *encoded_data_len, uint32_t *encoded_rate, unsigned int *flag)
|
||||
switch_codec_t *other_codec,
|
||||
void *decoded_data,
|
||||
uint32_t decoded_data_len,
|
||||
uint32_t decoded_rate,
|
||||
void *encoded_data,
|
||||
uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
|
||||
{
|
||||
struct g722_context *context = codec->private_info;
|
||||
|
||||
if (!context) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
*encoded_data_len = g722_encode(&context->encoder_object, (uint8_t *) encoded_data, (int16_t *) decoded_data, decoded_data_len / 2);
|
||||
|
||||
*encoded_data_len =
|
||||
g722_encode(&context->encoder_object, (uint8_t *) encoded_data, (int16_t *) decoded_data, decoded_data_len / 2);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t switch_g722_decode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *encoded_data,
|
||||
uint32_t encoded_data_len,
|
||||
uint32_t encoded_rate,
|
||||
void *decoded_data,
|
||||
uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag)
|
||||
switch_codec_t *other_codec,
|
||||
void *encoded_data,
|
||||
uint32_t encoded_data_len,
|
||||
uint32_t encoded_rate,
|
||||
void *decoded_data,
|
||||
uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
|
||||
{
|
||||
struct g722_context *context = codec->private_info;
|
||||
|
||||
if (!context) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
*decoded_data_len = (2 * g722_decode(&context->decoder_object, (int16_t *) decoded_data, (uint8_t *) encoded_data, encoded_data_len));
|
||||
|
||||
*decoded_data_len =
|
||||
(2 *
|
||||
g722_decode(&context->decoder_object, (int16_t *) decoded_data, (uint8_t *) encoded_data, encoded_data_len));
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -175,7 +178,8 @@ static switch_loadable_module_interface_t g722_module_interface = {
|
||||
/*.application_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 */
|
||||
*module_interface = &g722_module_interface;
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
*
|
||||
* mod_g723.c -- G723.1 Codec Module
|
||||
*
|
||||
*/
|
||||
*/
|
||||
#include "switch.h"
|
||||
|
||||
#ifndef G723_PASSTHROUGH
|
||||
@@ -61,11 +61,11 @@ struct g723_context {
|
||||
#endif
|
||||
|
||||
static switch_status_t switch_g723_init(switch_codec_t *codec, switch_codec_flag_t flags,
|
||||
const switch_codec_settings_t *codec_settings)
|
||||
const switch_codec_settings_t *codec_settings)
|
||||
{
|
||||
#ifdef G723_PASSTHROUGH
|
||||
codec->flags |= SWITCH_CODEC_FLAG_PASSTHROUGH;
|
||||
return SWITCH_STATUS_FALSE;
|
||||
return SWITCH_STATUS_FALSE;
|
||||
#else
|
||||
struct g723_context *context = NULL;
|
||||
int encoding, decoding;
|
||||
@@ -79,10 +79,10 @@ static switch_status_t switch_g723_init(switch_codec_t *codec, switch_codec_flag
|
||||
|
||||
if (encoding) {
|
||||
Init_Coder(&context->encoder_object);
|
||||
if( UseVx ) {
|
||||
if (UseVx) {
|
||||
Init_Vad(&context->encoder_object);
|
||||
Init_Cod_Cng(&context->encoder_object);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (decoding) {
|
||||
@@ -98,7 +98,7 @@ static switch_status_t switch_g723_init(switch_codec_t *codec, switch_codec_flag
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t switch_g723_destroy(switch_codec_t *codec)
|
||||
static switch_status_t switch_g723_destroy(switch_codec_t *codec)
|
||||
{
|
||||
#ifndef G723_PASSTHROUGH
|
||||
codec->private_info = NULL;
|
||||
@@ -106,17 +106,13 @@ static switch_status_t switch_g723_destroy(switch_codec_t *codec)
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t switch_g723_encode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *decoded_data,
|
||||
|
||||
uint32_t decoded_data_len,
|
||||
uint32_t decoded_rate,
|
||||
void *encoded_data,
|
||||
|
||||
uint32_t *encoded_data_len,
|
||||
uint32_t *encoded_rate,
|
||||
unsigned int *flag)
|
||||
static switch_status_t switch_g723_encode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *decoded_data,
|
||||
uint32_t decoded_data_len,
|
||||
uint32_t decoded_rate,
|
||||
void *encoded_data,
|
||||
uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
|
||||
{
|
||||
#ifdef G723_PASSTHROUGH
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
|
||||
@@ -131,28 +127,24 @@ static switch_status_t switch_g723_encode(switch_codec_t *codec,
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
for(x = 0; x < Frame; x++) {
|
||||
for (x = 0; x < Frame; x++) {
|
||||
context->cod_float_buf[x] = decoded_slin_buf[x];
|
||||
}
|
||||
|
||||
Coder(&context->encoder_object, (FLOAT *)context->cod_float_buf, ebuf);
|
||||
Coder(&context->encoder_object, (FLOAT *) context->cod_float_buf, ebuf);
|
||||
*encoded_data_len = codec->implementation->encoded_bytes_per_frame;
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
#endif
|
||||
}
|
||||
|
||||
static switch_status_t switch_g723_decode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *encoded_data,
|
||||
|
||||
uint32_t encoded_data_len,
|
||||
uint32_t encoded_rate,
|
||||
void *decoded_data,
|
||||
|
||||
uint32_t *decoded_data_len,
|
||||
uint32_t *decoded_rate,
|
||||
unsigned int *flag)
|
||||
static switch_status_t switch_g723_decode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *encoded_data,
|
||||
uint32_t encoded_data_len,
|
||||
uint32_t encoded_rate,
|
||||
void *decoded_data,
|
||||
uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
|
||||
{
|
||||
#ifdef G723_PASSTHROUGH
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
|
||||
@@ -165,10 +157,10 @@ static switch_status_t switch_g723_decode(switch_codec_t *codec,
|
||||
if (!context) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
Decod(&context->decoder_object, (FLOAT *) context->dec_float_buf, (char *) decoded_data, 0);
|
||||
|
||||
for (x=0;x<Frame;x++) {
|
||||
for (x = 0; x < Frame; x++) {
|
||||
to_slin_buf[x] = context->dec_float_buf[x];
|
||||
}
|
||||
*decoded_data_len = codec->implementation->bytes_per_frame;
|
||||
@@ -177,49 +169,49 @@ static switch_status_t switch_g723_decode(switch_codec_t *codec,
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Registration */
|
||||
/* Registration */
|
||||
|
||||
static const switch_codec_implementation_t g723_1_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 4,
|
||||
/*.iananame */ "G723",
|
||||
static const switch_codec_implementation_t g723_1_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 4,
|
||||
/*.iananame */ "G723",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.bits_per_second */ 6300,
|
||||
/*.microseconds_per_frame */ 30000,
|
||||
/*.samples_per_frame */ 240,
|
||||
/*.bytes_per_frame */ 480,
|
||||
/*.encoded_bytes_per_frame */ 24,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 4,
|
||||
/*.init */ switch_g723_init,
|
||||
/*.encode */ switch_g723_encode,
|
||||
/*.decode */ switch_g723_decode,
|
||||
/*.destroy */ switch_g723_destroy,
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.bits_per_second */ 6300,
|
||||
/*.microseconds_per_frame */ 30000,
|
||||
/*.samples_per_frame */ 240,
|
||||
/*.bytes_per_frame */ 480,
|
||||
/*.encoded_bytes_per_frame */ 24,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 4,
|
||||
/*.init */ switch_g723_init,
|
||||
/*.encode */ switch_g723_encode,
|
||||
/*.decode */ switch_g723_decode,
|
||||
/*.destroy */ switch_g723_destroy,
|
||||
};
|
||||
|
||||
static const switch_codec_interface_t g723_1_codec_interface = {
|
||||
/*.interface_name */ "g723.1 6.3k",
|
||||
/*.implementations */ &g723_1_implementation,
|
||||
static const switch_codec_interface_t g723_1_codec_interface = {
|
||||
/*.interface_name */ "g723.1 6.3k",
|
||||
/*.implementations */ &g723_1_implementation,
|
||||
};
|
||||
|
||||
static switch_loadable_module_interface_t g723_module_interface = {
|
||||
/*.module_name */ modname,
|
||||
/*.endpoint_interface */ NULL,
|
||||
/*.timer_interface */ NULL,
|
||||
/*.dialplan_interface */ NULL,
|
||||
/*.codec_interface */ &g723_1_codec_interface,
|
||||
/*.application_interface */ NULL
|
||||
static switch_loadable_module_interface_t g723_module_interface = {
|
||||
/*.module_name */ modname,
|
||||
/*.endpoint_interface */ NULL,
|
||||
/*.timer_interface */ NULL,
|
||||
/*.dialplan_interface */ NULL,
|
||||
/*.codec_interface */ &g723_1_codec_interface,
|
||||
/*.application_interface */ NULL
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
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 = &g723_module_interface;
|
||||
|
||||
/* indicate that the module should continue to be loaded */
|
||||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
+221
-226
@@ -28,15 +28,15 @@
|
||||
*
|
||||
* mod_g726.c -- G726 Codec Module
|
||||
*
|
||||
*/
|
||||
*/
|
||||
#include "switch.h"
|
||||
#include "g72x.h"
|
||||
#include "switch_bitpack.h"
|
||||
|
||||
static const char modname[] = "mod_g726";
|
||||
|
||||
typedef int (*encoder_t)(int, int, g726_state *);
|
||||
typedef int (*decoder_t)(int, int, g726_state *);
|
||||
typedef int (*encoder_t) (int, int, g726_state *);
|
||||
typedef int (*decoder_t) (int, int, g726_state *);
|
||||
|
||||
|
||||
typedef struct {
|
||||
@@ -53,7 +53,7 @@ typedef struct {
|
||||
} g726_handle_t;
|
||||
|
||||
static switch_status_t switch_g726_init(switch_codec_t *codec, switch_codec_flag_t flags,
|
||||
const switch_codec_settings_t *codec_settings)
|
||||
const switch_codec_settings_t *codec_settings)
|
||||
{
|
||||
uint32_t encoding, decoding;
|
||||
g726_handle_t *handle;
|
||||
@@ -65,8 +65,8 @@ static switch_status_t switch_g726_init(switch_codec_t *codec, switch_codec_flag
|
||||
return SWITCH_STATUS_FALSE;
|
||||
} else {
|
||||
handle->bytes = (switch_byte_t) codec->implementation->encoded_bytes_per_frame;
|
||||
|
||||
switch(handle->bytes) {
|
||||
|
||||
switch (handle->bytes) {
|
||||
case 100:
|
||||
handle->encoder = g726_40_encoder;
|
||||
handle->decoder = g726_40_decoder;
|
||||
@@ -88,22 +88,24 @@ static switch_status_t switch_g726_init(switch_codec_t *codec, switch_codec_flag
|
||||
handle->loops = 160;
|
||||
break;
|
||||
default:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "invalid Encoding Size %d!\n", codec->implementation->encoded_bytes_per_frame);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "invalid Encoding Size %d!\n",
|
||||
codec->implementation->encoded_bytes_per_frame);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
g726_init_state(&handle->context);
|
||||
codec->private_info = handle;
|
||||
handle->bits_per_frame = (switch_byte_t) (codec->implementation->bits_per_second / (codec->implementation->samples_per_second));
|
||||
handle->mode = (flags & SWITCH_CODEC_FLAG_AAL2 || strstr(codec->implementation->iananame, "AAL2"))
|
||||
handle->bits_per_frame =
|
||||
(switch_byte_t) (codec->implementation->bits_per_second / (codec->implementation->samples_per_second));
|
||||
handle->mode = (flags & SWITCH_CODEC_FLAG_AAL2 || strstr(codec->implementation->iananame, "AAL2"))
|
||||
? SWITCH_BITPACK_MODE_AAL2 : SWITCH_BITPACK_MODE_RFC3551;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t switch_g726_destroy(switch_codec_t *codec)
|
||||
static switch_status_t switch_g726_destroy(switch_codec_t *codec)
|
||||
{
|
||||
codec->private_info = NULL;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
@@ -111,17 +113,13 @@ static switch_status_t switch_g726_destroy(switch_codec_t *codec)
|
||||
|
||||
|
||||
|
||||
static switch_status_t switch_g726_encode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *decoded_data,
|
||||
|
||||
uint32_t decoded_data_len,
|
||||
uint32_t decoded_rate,
|
||||
void *encoded_data,
|
||||
|
||||
uint32_t *encoded_data_len,
|
||||
uint32_t *encoded_rate,
|
||||
unsigned int *flag)
|
||||
static switch_status_t switch_g726_encode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *decoded_data,
|
||||
uint32_t decoded_data_len,
|
||||
uint32_t decoded_rate,
|
||||
void *encoded_data,
|
||||
uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
|
||||
{
|
||||
|
||||
g726_handle_t *handle = codec->private_info;
|
||||
@@ -153,7 +151,8 @@ static switch_status_t switch_g726_encode(switch_codec_t *codec,
|
||||
if (new_len <= *encoded_data_len) {
|
||||
*encoded_data_len = new_len;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u >= %u\n", new_len, *encoded_data_len);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u >= %u\n", new_len,
|
||||
*encoded_data_len);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
}
|
||||
@@ -163,17 +162,13 @@ static switch_status_t switch_g726_encode(switch_codec_t *codec,
|
||||
|
||||
|
||||
|
||||
static switch_status_t switch_g726_decode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *encoded_data,
|
||||
|
||||
uint32_t encoded_data_len,
|
||||
uint32_t encoded_rate,
|
||||
void *decoded_data,
|
||||
|
||||
uint32_t *decoded_data_len,
|
||||
uint32_t *decoded_rate,
|
||||
unsigned int *flag)
|
||||
static switch_status_t switch_g726_decode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *encoded_data,
|
||||
uint32_t encoded_data_len,
|
||||
uint32_t encoded_rate,
|
||||
void *decoded_data,
|
||||
uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
|
||||
{
|
||||
|
||||
g726_handle_t *handle = codec->private_info;
|
||||
@@ -192,13 +187,13 @@ static switch_status_t switch_g726_decode(switch_codec_t *codec,
|
||||
for (y = 0; y < handle->loops; y++) {
|
||||
switch_bitpack_out(&handle->unpack, in[z++]);
|
||||
}
|
||||
for(y = 0; y < handle->bytes; y++) {
|
||||
for (y = 0; y < handle->bytes; y++) {
|
||||
*ddp++ = (int16_t) handle->decoder(handle->buf[y], AUDIO_ENCODING_LINEAR, context);
|
||||
new_len += 2;
|
||||
new_len += 2;
|
||||
}
|
||||
switch_bitpack_done(&handle->unpack);
|
||||
}
|
||||
|
||||
|
||||
if (new_len <= *decoded_data_len) {
|
||||
*decoded_data_len = new_len;
|
||||
} else {
|
||||
@@ -213,239 +208,239 @@ static switch_status_t switch_g726_decode(switch_codec_t *codec,
|
||||
|
||||
|
||||
|
||||
/* Registration */
|
||||
/* Registration */
|
||||
|
||||
static const switch_codec_implementation_t g726_16k_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 127,
|
||||
/*.iananame */ "G726-16",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.bits_per_second */ 16000,
|
||||
/*.microseconds_per_frame */ 20000,
|
||||
/*.samples_per_frame */ 160,
|
||||
/*.bytes_per_frame */ 320,
|
||||
/*.encoded_bytes_per_frame */ 40,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_g726_init,
|
||||
/*.encode */ switch_g726_encode,
|
||||
/*.decode */ switch_g726_decode,
|
||||
/*.destroy */ switch_g726_destroy,
|
||||
};
|
||||
|
||||
|
||||
static const switch_codec_implementation_t g726_24k_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 126,
|
||||
/*.iananame */ "G726-24",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.bits_per_second */ 24000,
|
||||
/*.microseconds_per_frame */ 20000,
|
||||
/*.samples_per_frame */ 160,
|
||||
/*.bytes_per_frame */ 320,
|
||||
/*.encoded_bytes_per_frame */ 60,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_g726_init,
|
||||
/*.encode */ switch_g726_encode,
|
||||
/*.decode */ switch_g726_decode,
|
||||
/*.destroy */ switch_g726_destroy,
|
||||
};
|
||||
|
||||
static const switch_codec_implementation_t g726_32k_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 2,
|
||||
/*.iananame */ "G726-32",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.bits_per_second */ 32000,
|
||||
/*.microseconds_per_frame */ 20000,
|
||||
/*.samples_per_frame */ 160,
|
||||
/*.bytes_per_frame */ 320,
|
||||
/*.encoded_bytes_per_frame */ 80,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_g726_init,
|
||||
/*.encode */ switch_g726_encode,
|
||||
/*.decode */ switch_g726_decode,
|
||||
/*.destroy */ switch_g726_destroy,
|
||||
};
|
||||
|
||||
static const switch_codec_implementation_t g726_40k_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 125,
|
||||
/*.iananame */ "G726-40",
|
||||
static const switch_codec_implementation_t g726_16k_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 127,
|
||||
/*.iananame */ "G726-16",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.bits_per_second */ 40000,
|
||||
/*.microseconds_per_frame */ 20000,
|
||||
/*.samples_per_frame */ 160,
|
||||
/*.bytes_per_frame */ 320,
|
||||
/*.encoded_bytes_per_frame */ 100,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_g726_init,
|
||||
/*.encode */ switch_g726_encode,
|
||||
/*.decode */ switch_g726_decode,
|
||||
/*.destroy */ switch_g726_destroy,
|
||||
/*.bits_per_second */ 16000,
|
||||
/*.microseconds_per_frame */ 20000,
|
||||
/*.samples_per_frame */ 160,
|
||||
/*.bytes_per_frame */ 320,
|
||||
/*.encoded_bytes_per_frame */ 40,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_g726_init,
|
||||
/*.encode */ switch_g726_encode,
|
||||
/*.decode */ switch_g726_decode,
|
||||
/*.destroy */ switch_g726_destroy,
|
||||
};
|
||||
|
||||
|
||||
|
||||
static const switch_codec_implementation_t aal2_g726_16k_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 124,
|
||||
/*.iananame */ "AAL2-G726-16",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.bits_per_second */ 16000,
|
||||
/*.microseconds_per_frame */ 20000,
|
||||
/*.samples_per_frame */ 160,
|
||||
/*.bytes_per_frame */ 320,
|
||||
/*.encoded_bytes_per_frame */ 40,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_g726_init,
|
||||
/*.encode */ switch_g726_encode,
|
||||
/*.decode */ switch_g726_decode,
|
||||
/*.destroy */ switch_g726_destroy,
|
||||
};
|
||||
|
||||
|
||||
static const switch_codec_implementation_t aal2_g726_24k_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 123,
|
||||
/*.iananame */ "AAL2-G726-24",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.bits_per_second */ 24000,
|
||||
/*.microseconds_per_frame */ 20000,
|
||||
/*.samples_per_frame */ 160,
|
||||
/*.bytes_per_frame */ 320,
|
||||
/*.encoded_bytes_per_frame */ 60,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_g726_init,
|
||||
/*.encode */ switch_g726_encode,
|
||||
/*.decode */ switch_g726_decode,
|
||||
/*.destroy */ switch_g726_destroy,
|
||||
};
|
||||
|
||||
static const switch_codec_implementation_t aal2_g726_32k_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 2,
|
||||
/*.iananame */ "AAL2-G726-32",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.bits_per_second */ 32000,
|
||||
/*.microseconds_per_frame */ 20000,
|
||||
/*.samples_per_frame */ 160,
|
||||
/*.bytes_per_frame */ 320,
|
||||
/*.encoded_bytes_per_frame */ 80,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_g726_init,
|
||||
/*.encode */ switch_g726_encode,
|
||||
/*.decode */ switch_g726_decode,
|
||||
/*.destroy */ switch_g726_destroy,
|
||||
};
|
||||
|
||||
static const switch_codec_implementation_t aal2_g726_40k_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 122,
|
||||
/*.iananame */ "AAL2-G726-40",
|
||||
static const switch_codec_implementation_t g726_24k_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 126,
|
||||
/*.iananame */ "G726-24",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.bits_per_second */ 40000,
|
||||
/*.microseconds_per_frame */ 20000,
|
||||
/*.samples_per_frame */ 160,
|
||||
/*.bytes_per_frame */ 320,
|
||||
/*.encoded_bytes_per_frame */ 100,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_g726_init,
|
||||
/*.encode */ switch_g726_encode,
|
||||
/*.decode */ switch_g726_decode,
|
||||
/*.destroy */ switch_g726_destroy,
|
||||
/*.bits_per_second */ 24000,
|
||||
/*.microseconds_per_frame */ 20000,
|
||||
/*.samples_per_frame */ 160,
|
||||
/*.bytes_per_frame */ 320,
|
||||
/*.encoded_bytes_per_frame */ 60,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_g726_init,
|
||||
/*.encode */ switch_g726_encode,
|
||||
/*.decode */ switch_g726_decode,
|
||||
/*.destroy */ switch_g726_destroy,
|
||||
};
|
||||
|
||||
const switch_codec_interface_t g726_16k_codec_interface = {
|
||||
/*.interface_name */ "G.726 16k",
|
||||
/*.implementations */ &g726_16k_implementation,
|
||||
static const switch_codec_implementation_t g726_32k_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 2,
|
||||
/*.iananame */ "G726-32",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.bits_per_second */ 32000,
|
||||
/*.microseconds_per_frame */ 20000,
|
||||
/*.samples_per_frame */ 160,
|
||||
/*.bytes_per_frame */ 320,
|
||||
/*.encoded_bytes_per_frame */ 80,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_g726_init,
|
||||
/*.encode */ switch_g726_encode,
|
||||
/*.decode */ switch_g726_decode,
|
||||
/*.destroy */ switch_g726_destroy,
|
||||
};
|
||||
|
||||
const switch_codec_interface_t g726_24k_codec_interface = {
|
||||
/*.interface_name */ "G.726 24k",
|
||||
/*.implementations */ &g726_24k_implementation,
|
||||
static const switch_codec_implementation_t g726_40k_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 125,
|
||||
/*.iananame */ "G726-40",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.bits_per_second */ 40000,
|
||||
/*.microseconds_per_frame */ 20000,
|
||||
/*.samples_per_frame */ 160,
|
||||
/*.bytes_per_frame */ 320,
|
||||
/*.encoded_bytes_per_frame */ 100,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_g726_init,
|
||||
/*.encode */ switch_g726_encode,
|
||||
/*.decode */ switch_g726_decode,
|
||||
/*.destroy */ switch_g726_destroy,
|
||||
};
|
||||
|
||||
|
||||
|
||||
static const switch_codec_implementation_t aal2_g726_16k_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 124,
|
||||
/*.iananame */ "AAL2-G726-16",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.bits_per_second */ 16000,
|
||||
/*.microseconds_per_frame */ 20000,
|
||||
/*.samples_per_frame */ 160,
|
||||
/*.bytes_per_frame */ 320,
|
||||
/*.encoded_bytes_per_frame */ 40,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_g726_init,
|
||||
/*.encode */ switch_g726_encode,
|
||||
/*.decode */ switch_g726_decode,
|
||||
/*.destroy */ switch_g726_destroy,
|
||||
};
|
||||
|
||||
|
||||
static const switch_codec_implementation_t aal2_g726_24k_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 123,
|
||||
/*.iananame */ "AAL2-G726-24",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.bits_per_second */ 24000,
|
||||
/*.microseconds_per_frame */ 20000,
|
||||
/*.samples_per_frame */ 160,
|
||||
/*.bytes_per_frame */ 320,
|
||||
/*.encoded_bytes_per_frame */ 60,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_g726_init,
|
||||
/*.encode */ switch_g726_encode,
|
||||
/*.decode */ switch_g726_decode,
|
||||
/*.destroy */ switch_g726_destroy,
|
||||
};
|
||||
|
||||
static const switch_codec_implementation_t aal2_g726_32k_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 2,
|
||||
/*.iananame */ "AAL2-G726-32",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.bits_per_second */ 32000,
|
||||
/*.microseconds_per_frame */ 20000,
|
||||
/*.samples_per_frame */ 160,
|
||||
/*.bytes_per_frame */ 320,
|
||||
/*.encoded_bytes_per_frame */ 80,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_g726_init,
|
||||
/*.encode */ switch_g726_encode,
|
||||
/*.decode */ switch_g726_decode,
|
||||
/*.destroy */ switch_g726_destroy,
|
||||
};
|
||||
|
||||
static const switch_codec_implementation_t aal2_g726_40k_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 122,
|
||||
/*.iananame */ "AAL2-G726-40",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.bits_per_second */ 40000,
|
||||
/*.microseconds_per_frame */ 20000,
|
||||
/*.samples_per_frame */ 160,
|
||||
/*.bytes_per_frame */ 320,
|
||||
/*.encoded_bytes_per_frame */ 100,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_g726_init,
|
||||
/*.encode */ switch_g726_encode,
|
||||
/*.decode */ switch_g726_decode,
|
||||
/*.destroy */ switch_g726_destroy,
|
||||
};
|
||||
|
||||
const switch_codec_interface_t g726_16k_codec_interface = {
|
||||
/*.interface_name */ "G.726 16k",
|
||||
/*.implementations */ &g726_16k_implementation,
|
||||
};
|
||||
|
||||
const switch_codec_interface_t g726_24k_codec_interface = {
|
||||
/*.interface_name */ "G.726 24k",
|
||||
/*.implementations */ &g726_24k_implementation,
|
||||
/*.next */ &g726_16k_codec_interface
|
||||
};
|
||||
|
||||
const switch_codec_interface_t g726_32k_codec_interface = {
|
||||
/*.interface_name */ "G.726 32k",
|
||||
/*.implementations */ &g726_32k_implementation,
|
||||
const switch_codec_interface_t g726_32k_codec_interface = {
|
||||
/*.interface_name */ "G.726 32k",
|
||||
/*.implementations */ &g726_32k_implementation,
|
||||
/*.next */ &g726_24k_codec_interface
|
||||
};
|
||||
|
||||
const switch_codec_interface_t g726_40k_codec_interface = {
|
||||
/*.interface_name */ "G.726 40k",
|
||||
/*.implementations */ &g726_40k_implementation,
|
||||
const switch_codec_interface_t g726_40k_codec_interface = {
|
||||
/*.interface_name */ "G.726 40k",
|
||||
/*.implementations */ &g726_40k_implementation,
|
||||
/*.next */ &g726_32k_codec_interface
|
||||
};
|
||||
|
||||
|
||||
|
||||
const switch_codec_interface_t aal2_g726_16k_codec_interface = {
|
||||
/*.interface_name */ "G.726 16k (aal2)",
|
||||
/*.implementations */ &aal2_g726_16k_implementation,
|
||||
const switch_codec_interface_t aal2_g726_16k_codec_interface = {
|
||||
/*.interface_name */ "G.726 16k (aal2)",
|
||||
/*.implementations */ &aal2_g726_16k_implementation,
|
||||
/*.next */ &g726_40k_codec_interface
|
||||
};
|
||||
|
||||
const switch_codec_interface_t aal2_g726_24k_codec_interface = {
|
||||
/*.interface_name */ "G.726 24k (aal2)",
|
||||
/*.implementations */ &aal2_g726_24k_implementation,
|
||||
const switch_codec_interface_t aal2_g726_24k_codec_interface = {
|
||||
/*.interface_name */ "G.726 24k (aal2)",
|
||||
/*.implementations */ &aal2_g726_24k_implementation,
|
||||
/*.next */ &aal2_g726_16k_codec_interface
|
||||
};
|
||||
|
||||
const switch_codec_interface_t aal2_g726_32k_codec_interface = {
|
||||
/*.interface_name */ "G.726 32k (aal2)",
|
||||
/*.implementations */ &aal2_g726_32k_implementation,
|
||||
const switch_codec_interface_t aal2_g726_32k_codec_interface = {
|
||||
/*.interface_name */ "G.726 32k (aal2)",
|
||||
/*.implementations */ &aal2_g726_32k_implementation,
|
||||
/*.next */ &aal2_g726_24k_codec_interface
|
||||
};
|
||||
|
||||
const switch_codec_interface_t aal2_g726_40k_codec_interface = {
|
||||
/*.interface_name */ "G.726 40k (aal2)",
|
||||
/*.implementations */ &aal2_g726_40k_implementation,
|
||||
const switch_codec_interface_t aal2_g726_40k_codec_interface = {
|
||||
/*.interface_name */ "G.726 40k (aal2)",
|
||||
/*.implementations */ &aal2_g726_40k_implementation,
|
||||
/*.next */ &aal2_g726_32k_codec_interface
|
||||
};
|
||||
|
||||
|
||||
|
||||
static switch_loadable_module_interface_t g726_module_interface = {
|
||||
/*.module_name */ modname,
|
||||
/*.endpoint_interface */ NULL,
|
||||
/*.timer_interface */ NULL,
|
||||
/*.dialplan_interface */ NULL,
|
||||
/*.codec_interface */ &aal2_g726_40k_codec_interface,
|
||||
/*.application_interface */ NULL
|
||||
static switch_loadable_module_interface_t g726_module_interface = {
|
||||
/*.module_name */ modname,
|
||||
/*.endpoint_interface */ NULL,
|
||||
/*.timer_interface */ NULL,
|
||||
/*.dialplan_interface */ NULL,
|
||||
/*.codec_interface */ &aal2_g726_40k_codec_interface,
|
||||
/*.application_interface */ NULL
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
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 = &g726_module_interface;
|
||||
|
||||
/* indicate that the module should continue to be loaded */
|
||||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
*
|
||||
* mod_g729.c -- G729 Codec Module
|
||||
*
|
||||
*/
|
||||
*/
|
||||
|
||||
static const char modname[] = "mod_g729";
|
||||
|
||||
@@ -46,15 +46,15 @@ struct g729_context {
|
||||
#endif
|
||||
|
||||
static switch_status_t switch_g729_init(switch_codec_t *codec, switch_codec_flag_t flags,
|
||||
const switch_codec_settings_t *codec_settings)
|
||||
const switch_codec_settings_t *codec_settings)
|
||||
{
|
||||
#ifdef G729_PASSTHROUGH
|
||||
codec->flags |= SWITCH_CODEC_FLAG_PASSTHROUGH;
|
||||
if (codec->fmtp_in) {
|
||||
codec->fmtp_out = switch_core_strdup(codec->memory_pool, codec->fmtp_in);
|
||||
}
|
||||
if (codec->fmtp_in) {
|
||||
codec->fmtp_out = switch_core_strdup(codec->memory_pool, codec->fmtp_in);
|
||||
}
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
#else
|
||||
#else
|
||||
struct g729_context *context = NULL;
|
||||
int encoding, decoding;
|
||||
|
||||
@@ -64,9 +64,9 @@ static switch_status_t switch_g729_init(switch_codec_t *codec, switch_codec_flag
|
||||
if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->memory_pool, sizeof(struct g729_context))))) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
} else {
|
||||
if (codec->fmtp_in) {
|
||||
codec->fmtp_out = switch_core_strdup(codec->memory_pool, codec->fmtp_in);
|
||||
}
|
||||
if (codec->fmtp_in) {
|
||||
codec->fmtp_out = switch_core_strdup(codec->memory_pool, codec->fmtp_in);
|
||||
}
|
||||
|
||||
if (encoding) {
|
||||
g729_init_coder(&context->encoder_object, 0);
|
||||
@@ -84,7 +84,7 @@ static switch_status_t switch_g729_init(switch_codec_t *codec, switch_codec_flag
|
||||
#endif
|
||||
}
|
||||
|
||||
static switch_status_t switch_g729_destroy(switch_codec_t *codec)
|
||||
static switch_status_t switch_g729_destroy(switch_codec_t *codec)
|
||||
{
|
||||
#ifndef G729_PASSTHROUGH
|
||||
codec->private_info = NULL;
|
||||
@@ -92,17 +92,13 @@ static switch_status_t switch_g729_destroy(switch_codec_t *codec)
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t switch_g729_encode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *decoded_data,
|
||||
|
||||
uint32_t decoded_data_len,
|
||||
uint32_t decoded_rate,
|
||||
void *encoded_data,
|
||||
|
||||
uint32_t *encoded_data_len,
|
||||
uint32_t *encoded_rate,
|
||||
unsigned int *flag)
|
||||
static switch_status_t switch_g729_encode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *decoded_data,
|
||||
uint32_t decoded_data_len,
|
||||
uint32_t decoded_rate,
|
||||
void *encoded_data,
|
||||
uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
|
||||
{
|
||||
#ifdef G729_PASSTHROUGH
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
|
||||
@@ -117,7 +113,7 @@ static switch_status_t switch_g729_encode(switch_codec_t *codec,
|
||||
|
||||
if (decoded_data_len % 160 == 0) {
|
||||
uint32_t new_len = 0;
|
||||
INT16 * ddp = decoded_data;
|
||||
INT16 *ddp = decoded_data;
|
||||
char *edp = encoded_data;
|
||||
int x;
|
||||
int loops = (int) decoded_data_len / 160;
|
||||
@@ -132,7 +128,8 @@ static switch_status_t switch_g729_encode(switch_codec_t *codec,
|
||||
if (new_len <= *encoded_data_len) {
|
||||
*encoded_data_len = new_len;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u >= %u\n", new_len, *encoded_data_len);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u >= %u\n", new_len,
|
||||
*encoded_data_len);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
}
|
||||
@@ -140,17 +137,13 @@ static switch_status_t switch_g729_encode(switch_codec_t *codec,
|
||||
#endif
|
||||
}
|
||||
|
||||
static switch_status_t switch_g729_decode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *encoded_data,
|
||||
|
||||
uint32_t encoded_data_len,
|
||||
uint32_t encoded_rate,
|
||||
void *decoded_data,
|
||||
|
||||
uint32_t *decoded_data_len,
|
||||
uint32_t *decoded_rate,
|
||||
unsigned int *flag)
|
||||
static switch_status_t switch_g729_decode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *encoded_data,
|
||||
uint32_t encoded_data_len,
|
||||
uint32_t encoded_rate,
|
||||
void *decoded_data,
|
||||
uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
|
||||
{
|
||||
#ifdef G729_PASSTHROUGH
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
|
||||
@@ -189,7 +182,7 @@ static switch_status_t switch_g729_decode(switch_codec_t *codec,
|
||||
uint32_t new_len = 0;
|
||||
|
||||
test = (uint8_t *) encoded_data;
|
||||
if (*test == 0 && *(test+1) == 0) {
|
||||
if (*test == 0 && *(test + 1) == 0) {
|
||||
*decoded_data_len = (encoded_data_len / divisor) * 160;
|
||||
memset(decoded_data, 0, *decoded_data_len);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
@@ -213,55 +206,56 @@ static switch_status_t switch_g729_decode(switch_codec_t *codec,
|
||||
return SWITCH_STATUS_FALSE;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "yo this frame is an odd size [%d]\n", encoded_data_len);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "yo this frame is an odd size [%d]\n",
|
||||
encoded_data_len);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Registration */
|
||||
/* Registration */
|
||||
|
||||
static const switch_codec_implementation_t g729_10ms_8k_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 18,
|
||||
/*.iananame */ "G729",
|
||||
static const switch_codec_implementation_t g729_10ms_8k_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 18,
|
||||
/*.iananame */ "G729",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.bits_per_second */ 32000,
|
||||
/*.microseconds_per_frame */ 10000,
|
||||
/*.samples_per_frame */ 80,
|
||||
/*.bytes_per_frame */ 160,
|
||||
/*.encoded_bytes_per_frame */ 10,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_g729_init,
|
||||
/*.encode */ switch_g729_encode,
|
||||
/*.decode */ switch_g729_decode,
|
||||
/*.destroy */ switch_g729_destroy,
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.bits_per_second */ 32000,
|
||||
/*.microseconds_per_frame */ 10000,
|
||||
/*.samples_per_frame */ 80,
|
||||
/*.bytes_per_frame */ 160,
|
||||
/*.encoded_bytes_per_frame */ 10,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_g729_init,
|
||||
/*.encode */ switch_g729_encode,
|
||||
/*.decode */ switch_g729_decode,
|
||||
/*.destroy */ switch_g729_destroy,
|
||||
};
|
||||
|
||||
static const switch_codec_implementation_t g729_8k_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 18,
|
||||
/*.iananame */ "G729",
|
||||
static const switch_codec_implementation_t g729_8k_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 18,
|
||||
/*.iananame */ "G729",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.bits_per_second */ 64000,
|
||||
/*.microseconds_per_frame */ 20000,
|
||||
/*.samples_per_frame */ 160,
|
||||
/*.bytes_per_frame */ 320,
|
||||
/*.encoded_bytes_per_frame */ 20,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_g729_init,
|
||||
/*.encode */ switch_g729_encode,
|
||||
/*.decode */ switch_g729_decode,
|
||||
/*.destroy */ switch_g729_destroy,
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.bits_per_second */ 64000,
|
||||
/*.microseconds_per_frame */ 20000,
|
||||
/*.samples_per_frame */ 160,
|
||||
/*.bytes_per_frame */ 320,
|
||||
/*.encoded_bytes_per_frame */ 20,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_g729_init,
|
||||
/*.encode */ switch_g729_encode,
|
||||
/*.decode */ switch_g729_decode,
|
||||
/*.destroy */ switch_g729_destroy,
|
||||
&g729_10ms_8k_implementation
|
||||
};
|
||||
|
||||
@@ -271,22 +265,22 @@ static const switch_codec_interface_t g729_codec_interface = {
|
||||
/*.next */ NULL
|
||||
};
|
||||
|
||||
static switch_loadable_module_interface_t g729_module_interface = {
|
||||
static switch_loadable_module_interface_t g729_module_interface = {
|
||||
/*.module_name */ "g729",
|
||||
/*.endpoint_interface */ NULL,
|
||||
/*.timer_interface */ NULL,
|
||||
/*.dialplan_interface */ NULL,
|
||||
/*.codec_interface */ &g729_codec_interface,
|
||||
/*.application_interface */ NULL
|
||||
/*.endpoint_interface */ NULL,
|
||||
/*.timer_interface */ NULL,
|
||||
/*.dialplan_interface */ NULL,
|
||||
/*.codec_interface */ &g729_codec_interface,
|
||||
/*.application_interface */ NULL
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
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 = &g729_module_interface;
|
||||
|
||||
/* indicate that the module should continue to be loaded */
|
||||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
*
|
||||
* mod_codec_gsm.c -- gsm Codec Module
|
||||
*
|
||||
*/
|
||||
*/
|
||||
#include "switch.h"
|
||||
#include "gsm.h"
|
||||
static const char modname[] = "mod_gsm";
|
||||
@@ -37,7 +37,7 @@ struct gsm_context {
|
||||
gsm decoder;
|
||||
};
|
||||
static switch_status_t switch_gsm_init(switch_codec_t *codec, switch_codec_flag_t flags,
|
||||
const switch_codec_settings_t *codec_settings)
|
||||
const switch_codec_settings_t *codec_settings)
|
||||
{
|
||||
struct gsm_context *context;
|
||||
int encoding, decoding;
|
||||
@@ -55,7 +55,7 @@ static switch_status_t switch_gsm_init(switch_codec_t *codec, switch_codec_flag_
|
||||
codec->private_info = context;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
static switch_status_t switch_gsm_destroy(switch_codec_t *codec)
|
||||
static switch_status_t switch_gsm_destroy(switch_codec_t *codec)
|
||||
{
|
||||
struct gsm_context *context = codec->private_info;
|
||||
int encoding = (codec->flags & SWITCH_CODEC_FLAG_ENCODE);
|
||||
@@ -68,8 +68,8 @@ static switch_status_t switch_gsm_destroy(switch_codec_t *codec)
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
static switch_status_t switch_gsm_encode(switch_codec_t *codec, switch_codec_t *other_codec, void *decoded_data,
|
||||
uint32_t decoded_data_len, uint32_t decoded_rate, void *encoded_data,
|
||||
uint32_t *encoded_data_len, uint32_t *encoded_rate, unsigned int *flag)
|
||||
uint32_t decoded_data_len, uint32_t decoded_rate, void *encoded_data,
|
||||
uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
|
||||
{
|
||||
struct gsm_context *context = codec->private_info;
|
||||
if (!context) {
|
||||
@@ -77,8 +77,8 @@ static switch_status_t switch_gsm_encode(switch_codec_t *codec, switch_codec_t *
|
||||
}
|
||||
if (decoded_data_len % 320 == 0) {
|
||||
uint32_t new_len = 0;
|
||||
gsm_signal * ddp = decoded_data;
|
||||
gsm_byte * edp = encoded_data;
|
||||
gsm_signal *ddp = decoded_data;
|
||||
gsm_byte *edp = encoded_data;
|
||||
int x;
|
||||
int loops = (int) decoded_data_len / 320;
|
||||
for (x = 0; x < loops && new_len < *encoded_data_len; x++) {
|
||||
@@ -90,15 +90,16 @@ static switch_status_t switch_gsm_encode(switch_codec_t *codec, switch_codec_t *
|
||||
if (new_len <= *encoded_data_len) {
|
||||
*encoded_data_len = new_len;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u >= %u\n", new_len, *encoded_data_len);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u >= %u\n", new_len,
|
||||
*encoded_data_len);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
}
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
static switch_status_t switch_gsm_decode(switch_codec_t *codec, switch_codec_t *other_codec, void *encoded_data,
|
||||
uint32_t encoded_data_len, uint32_t encoded_rate, void *decoded_data,
|
||||
uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag)
|
||||
uint32_t encoded_data_len, uint32_t encoded_rate, void *decoded_data,
|
||||
uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
|
||||
{
|
||||
struct gsm_context *context = codec->private_info;
|
||||
if (!context) {
|
||||
@@ -107,8 +108,8 @@ static switch_status_t switch_gsm_decode(switch_codec_t *codec, switch_codec_t *
|
||||
|
||||
if (encoded_data_len % 33 == 0) {
|
||||
int loops = (int) encoded_data_len / 33;
|
||||
gsm_byte * edp = encoded_data;
|
||||
gsm_signal * ddp = decoded_data;
|
||||
gsm_byte *edp = encoded_data;
|
||||
gsm_signal *ddp = decoded_data;
|
||||
int x;
|
||||
uint32_t new_len = 0;
|
||||
|
||||
@@ -121,57 +122,59 @@ static switch_status_t switch_gsm_decode(switch_codec_t *codec, switch_codec_t *
|
||||
if (new_len <= *decoded_data_len) {
|
||||
*decoded_data_len = new_len;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u %u\n", new_len, *decoded_data_len);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u %u\n", new_len,
|
||||
*decoded_data_len);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "yo this frame is an odd size [%u]\n", encoded_data_len);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "yo this frame is an odd size [%u]\n",
|
||||
encoded_data_len);
|
||||
}
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/* Registration */
|
||||
static const switch_codec_implementation_t gsm_8k_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 3,
|
||||
/*.iananame */ "GSM",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.bits_per_second */ 13200,
|
||||
/*.microseconds_per_frame */ 20000,
|
||||
/*.samples_per_frame */ 160,
|
||||
/*.bytes_per_frame */ 320,
|
||||
/*.encoded_bytes_per_frame */ 33,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_gsm_init,
|
||||
/*.encode */ switch_gsm_encode,
|
||||
/*.decode */ switch_gsm_decode,
|
||||
/*.destroy */ switch_gsm_destroy,
|
||||
/* Registration */
|
||||
static const switch_codec_implementation_t gsm_8k_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 3,
|
||||
/*.iananame */ "GSM",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.bits_per_second */ 13200,
|
||||
/*.microseconds_per_frame */ 20000,
|
||||
/*.samples_per_frame */ 160,
|
||||
/*.bytes_per_frame */ 320,
|
||||
/*.encoded_bytes_per_frame */ 33,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_gsm_init,
|
||||
/*.encode */ switch_gsm_encode,
|
||||
/*.decode */ switch_gsm_decode,
|
||||
/*.destroy */ switch_gsm_destroy,
|
||||
};
|
||||
static const switch_codec_interface_t gsm_codec_interface = {
|
||||
/*.interface_name */ "gsm",
|
||||
/*.implementations */ &gsm_8k_implementation,
|
||||
static const switch_codec_interface_t gsm_codec_interface = {
|
||||
/*.interface_name */ "gsm",
|
||||
/*.implementations */ &gsm_8k_implementation,
|
||||
};
|
||||
static switch_loadable_module_interface_t gsm_module_interface = {
|
||||
/*.module_name */ modname,
|
||||
/*.endpoint_interface */ NULL,
|
||||
/*.timer_interface */ NULL,
|
||||
/*.dialplan_interface */ NULL,
|
||||
/*.codec_interface */ &gsm_codec_interface,
|
||||
/*.application_interface */ NULL
|
||||
static switch_loadable_module_interface_t gsm_module_interface = {
|
||||
/*.module_name */ modname,
|
||||
/*.endpoint_interface */ NULL,
|
||||
/*.timer_interface */ NULL,
|
||||
/*.dialplan_interface */ NULL,
|
||||
/*.codec_interface */ &gsm_codec_interface,
|
||||
/*.application_interface */ NULL
|
||||
};
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
char *filename)
|
||||
{
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = &gsm_module_interface;
|
||||
|
||||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = &gsm_module_interface;
|
||||
|
||||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/* For Emacs:
|
||||
|
||||
+142
-144
@@ -28,7 +28,7 @@
|
||||
*
|
||||
* mod_ilbc.c -- ilbc Codec Module
|
||||
*
|
||||
*/
|
||||
*/
|
||||
#include "switch.h"
|
||||
#include "iLBC_encode.h"
|
||||
#include "iLBC_decode.h"
|
||||
@@ -45,11 +45,11 @@ struct ilbc_context {
|
||||
};
|
||||
|
||||
static switch_status_t switch_ilbc_init(switch_codec_t *codec, switch_codec_flag_t flags,
|
||||
const switch_codec_settings_t *codec_settings)
|
||||
const switch_codec_settings_t *codec_settings)
|
||||
{
|
||||
struct ilbc_context *context;
|
||||
int encoding, decoding;
|
||||
uint8_t ms = (uint8_t)(codec->implementation->microseconds_per_frame / 1000);
|
||||
uint8_t ms = (uint8_t) (codec->implementation->microseconds_per_frame / 1000);
|
||||
|
||||
|
||||
if (ms != 20 && ms != 30) {
|
||||
@@ -82,13 +82,13 @@ static switch_status_t switch_ilbc_init(switch_codec_t *codec, switch_codec_flag
|
||||
}
|
||||
|
||||
codec->fmtp_out = switch_core_strdup(codec->memory_pool, codec->implementation->fmtp);
|
||||
|
||||
|
||||
codec->private_info = context;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t switch_ilbc_destroy(switch_codec_t *codec)
|
||||
static switch_status_t switch_ilbc_destroy(switch_codec_t *codec)
|
||||
{
|
||||
codec->private_info = NULL;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
@@ -96,14 +96,12 @@ static switch_status_t switch_ilbc_destroy(switch_codec_t *codec)
|
||||
|
||||
|
||||
static switch_status_t switch_ilbc_encode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *decoded_data,
|
||||
uint32_t decoded_data_len,
|
||||
uint32_t decoded_rate,
|
||||
void *encoded_data,
|
||||
uint32_t *encoded_data_len,
|
||||
uint32_t *encoded_rate,
|
||||
unsigned int *flag)
|
||||
switch_codec_t *other_codec,
|
||||
void *decoded_data,
|
||||
uint32_t decoded_data_len,
|
||||
uint32_t decoded_rate,
|
||||
void *encoded_data,
|
||||
uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
|
||||
{
|
||||
struct ilbc_context *context = codec->private_info;
|
||||
|
||||
@@ -120,7 +118,7 @@ static switch_status_t switch_ilbc_encode(switch_codec_t *codec,
|
||||
float buf[240];
|
||||
|
||||
for (x = 0; x < loops && new_len < *encoded_data_len; x++) {
|
||||
for(y = 0; y < context->dbytes / sizeof(short) ; y++) {
|
||||
for (y = 0; y < context->dbytes / sizeof(short); y++) {
|
||||
buf[y] = ddp[y];
|
||||
}
|
||||
iLBC_encode(edp, buf, &context->encoder);
|
||||
@@ -131,7 +129,8 @@ static switch_status_t switch_ilbc_encode(switch_codec_t *codec,
|
||||
if (new_len <= *encoded_data_len) {
|
||||
*encoded_data_len = new_len;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u >= %u\n", new_len, *encoded_data_len);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffer overflow!!! %u >= %u\n", new_len,
|
||||
*encoded_data_len);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
}
|
||||
@@ -139,14 +138,12 @@ static switch_status_t switch_ilbc_encode(switch_codec_t *codec,
|
||||
}
|
||||
|
||||
static switch_status_t switch_ilbc_decode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *encoded_data,
|
||||
uint32_t encoded_data_len,
|
||||
uint32_t encoded_rate,
|
||||
void *decoded_data,
|
||||
uint32_t *decoded_data_len,
|
||||
uint32_t *decoded_rate,
|
||||
unsigned int *flag)
|
||||
switch_codec_t *other_codec,
|
||||
void *encoded_data,
|
||||
uint32_t encoded_data_len,
|
||||
uint32_t encoded_rate,
|
||||
void *decoded_data,
|
||||
uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
|
||||
{
|
||||
struct ilbc_context *context = codec->private_info;
|
||||
|
||||
@@ -165,8 +162,8 @@ static switch_status_t switch_ilbc_decode(switch_codec_t *codec,
|
||||
|
||||
for (x = 0; x < loops && new_len < *decoded_data_len; x++) {
|
||||
iLBC_decode(buf, edp, &context->decoder, 1);
|
||||
for(y = 0; y < context->dbytes / sizeof(short) ; y++) {
|
||||
ddp[y] = (short)buf[y];
|
||||
for (y = 0; y < context->dbytes / sizeof(short); y++) {
|
||||
ddp[y] = (short) buf[y];
|
||||
}
|
||||
ddp += context->dbytes / sizeof(short);
|
||||
edp += context->bytes;
|
||||
@@ -179,160 +176,161 @@ static switch_status_t switch_ilbc_decode(switch_codec_t *codec,
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "yo this frame is an odd size [%d]\n", encoded_data_len);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "yo this frame is an odd size [%d]\n",
|
||||
encoded_data_len);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/* Registration */
|
||||
/* Registration */
|
||||
|
||||
static const switch_codec_implementation_t ilbc_8k_30ms_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 97,
|
||||
/*.iananame */ "iLBC",
|
||||
/*.fmtp */ "mode=30",
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.bits_per_second */ NO_OF_BYTES_30MS*8*8000/BLOCKL_30MS,
|
||||
/*.microseconds_per_frame */ 30000,
|
||||
/*.samples_per_frame */ 240,
|
||||
/*.bytes_per_frame */ 480,
|
||||
/*.encoded_bytes_per_frame */ NO_OF_BYTES_30MS,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_ilbc_init,
|
||||
/*.encode */ switch_ilbc_encode,
|
||||
/*.decode */ switch_ilbc_decode,
|
||||
/*.destroy */ switch_ilbc_destroy
|
||||
static const switch_codec_implementation_t ilbc_8k_30ms_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 97,
|
||||
/*.iananame */ "iLBC",
|
||||
/*.fmtp */ "mode=30",
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.bits_per_second */ NO_OF_BYTES_30MS * 8 * 8000 / BLOCKL_30MS,
|
||||
/*.microseconds_per_frame */ 30000,
|
||||
/*.samples_per_frame */ 240,
|
||||
/*.bytes_per_frame */ 480,
|
||||
/*.encoded_bytes_per_frame */ NO_OF_BYTES_30MS,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_ilbc_init,
|
||||
/*.encode */ switch_ilbc_encode,
|
||||
/*.decode */ switch_ilbc_decode,
|
||||
/*.destroy */ switch_ilbc_destroy
|
||||
};
|
||||
|
||||
static const switch_codec_implementation_t ilbc_8k_20ms_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 97,
|
||||
/*.iananame */ "iLBC",
|
||||
/*.fmtp */ "mode=20",
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.bits_per_second */ NO_OF_BYTES_20MS*8*8000/BLOCKL_20MS,
|
||||
/*.microseconds_per_frame */ 20000,
|
||||
/*.samples_per_frame */ 160,
|
||||
/*.bytes_per_frame */ 320,
|
||||
/*.encoded_bytes_per_frame */ NO_OF_BYTES_20MS,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_ilbc_init,
|
||||
/*.encode */ switch_ilbc_encode,
|
||||
/*.decode */ switch_ilbc_decode,
|
||||
/*.destroy */ switch_ilbc_destroy,
|
||||
/*.next */ &ilbc_8k_30ms_implementation
|
||||
static const switch_codec_implementation_t ilbc_8k_20ms_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 97,
|
||||
/*.iananame */ "iLBC",
|
||||
/*.fmtp */ "mode=20",
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.bits_per_second */ NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
|
||||
/*.microseconds_per_frame */ 20000,
|
||||
/*.samples_per_frame */ 160,
|
||||
/*.bytes_per_frame */ 320,
|
||||
/*.encoded_bytes_per_frame */ NO_OF_BYTES_20MS,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_ilbc_init,
|
||||
/*.encode */ switch_ilbc_encode,
|
||||
/*.decode */ switch_ilbc_decode,
|
||||
/*.destroy */ switch_ilbc_destroy,
|
||||
/*.next */ &ilbc_8k_30ms_implementation
|
||||
};
|
||||
|
||||
|
||||
|
||||
static const switch_codec_implementation_t ilbc_102_8k_30ms_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 102,
|
||||
/*.iananame */ "iLBC",
|
||||
/*.fmtp */ "mode=30",
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.bits_per_second */ NO_OF_BYTES_30MS*8*8000/BLOCKL_30MS,
|
||||
/*.microseconds_per_frame */ 30000,
|
||||
/*.samples_per_frame */ 240,
|
||||
/*.bytes_per_frame */ 480,
|
||||
/*.encoded_bytes_per_frame */ NO_OF_BYTES_30MS,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_ilbc_init,
|
||||
/*.encode */ switch_ilbc_encode,
|
||||
/*.decode */ switch_ilbc_decode,
|
||||
/*.destroy */ switch_ilbc_destroy
|
||||
static const switch_codec_implementation_t ilbc_102_8k_30ms_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 102,
|
||||
/*.iananame */ "iLBC",
|
||||
/*.fmtp */ "mode=30",
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.bits_per_second */ NO_OF_BYTES_30MS * 8 * 8000 / BLOCKL_30MS,
|
||||
/*.microseconds_per_frame */ 30000,
|
||||
/*.samples_per_frame */ 240,
|
||||
/*.bytes_per_frame */ 480,
|
||||
/*.encoded_bytes_per_frame */ NO_OF_BYTES_30MS,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_ilbc_init,
|
||||
/*.encode */ switch_ilbc_encode,
|
||||
/*.decode */ switch_ilbc_decode,
|
||||
/*.destroy */ switch_ilbc_destroy
|
||||
};
|
||||
|
||||
static const switch_codec_implementation_t ilbc_102_8k_20ms_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 102,
|
||||
/*.iananame */ "iLBC102",
|
||||
/*.fmtp */ "mode=20",
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.bits_per_second */ NO_OF_BYTES_20MS*8*8000/BLOCKL_20MS,
|
||||
/*.microseconds_per_frame */ 20000,
|
||||
/*.samples_per_frame */ 160,
|
||||
/*.bytes_per_frame */ 320,
|
||||
/*.encoded_bytes_per_frame */ NO_OF_BYTES_20MS,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_ilbc_init,
|
||||
/*.encode */ switch_ilbc_encode,
|
||||
/*.decode */ switch_ilbc_decode,
|
||||
/*.destroy */ switch_ilbc_destroy,
|
||||
/*.next */ &ilbc_102_8k_30ms_implementation
|
||||
static const switch_codec_implementation_t ilbc_102_8k_20ms_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 102,
|
||||
/*.iananame */ "iLBC102",
|
||||
/*.fmtp */ "mode=20",
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.bits_per_second */ NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
|
||||
/*.microseconds_per_frame */ 20000,
|
||||
/*.samples_per_frame */ 160,
|
||||
/*.bytes_per_frame */ 320,
|
||||
/*.encoded_bytes_per_frame */ NO_OF_BYTES_20MS,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_ilbc_init,
|
||||
/*.encode */ switch_ilbc_encode,
|
||||
/*.decode */ switch_ilbc_decode,
|
||||
/*.destroy */ switch_ilbc_destroy,
|
||||
/*.next */ &ilbc_102_8k_30ms_implementation
|
||||
};
|
||||
|
||||
|
||||
static const switch_codec_implementation_t ilbc_8k_20ms_nonext_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 97,
|
||||
/*.iananame */ "iLBC20ms",
|
||||
/*.fmtp */ "mode=20",
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.bits_per_second */ NO_OF_BYTES_20MS*8*8000/BLOCKL_20MS,
|
||||
/*.microseconds_per_frame */ 20000,
|
||||
/*.samples_per_frame */ 160,
|
||||
/*.bytes_per_frame */ 320,
|
||||
/*.encoded_bytes_per_frame */ NO_OF_BYTES_20MS,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_ilbc_init,
|
||||
/*.encode */ switch_ilbc_encode,
|
||||
/*.decode */ switch_ilbc_decode,
|
||||
/*.destroy */ switch_ilbc_destroy
|
||||
static const switch_codec_implementation_t ilbc_8k_20ms_nonext_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 97,
|
||||
/*.iananame */ "iLBC20ms",
|
||||
/*.fmtp */ "mode=20",
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.bits_per_second */ NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
|
||||
/*.microseconds_per_frame */ 20000,
|
||||
/*.samples_per_frame */ 160,
|
||||
/*.bytes_per_frame */ 320,
|
||||
/*.encoded_bytes_per_frame */ NO_OF_BYTES_20MS,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_ilbc_init,
|
||||
/*.encode */ switch_ilbc_encode,
|
||||
/*.decode */ switch_ilbc_decode,
|
||||
/*.destroy */ switch_ilbc_destroy
|
||||
};
|
||||
|
||||
|
||||
static const switch_codec_interface_t ilbc_20ms_codec_interface = {
|
||||
/*.interface_name */ "ilbc",
|
||||
/*.implementations */ &ilbc_8k_20ms_nonext_implementation
|
||||
static const switch_codec_interface_t ilbc_20ms_codec_interface = {
|
||||
/*.interface_name */ "ilbc",
|
||||
/*.implementations */ &ilbc_8k_20ms_nonext_implementation
|
||||
};
|
||||
|
||||
static const switch_codec_interface_t ilbc_102_codec_interface = {
|
||||
/*.interface_name */ "ilbc",
|
||||
/*.implementations */ &ilbc_102_8k_20ms_implementation,
|
||||
/*.next*/ &ilbc_20ms_codec_interface
|
||||
static const switch_codec_interface_t ilbc_102_codec_interface = {
|
||||
/*.interface_name */ "ilbc",
|
||||
/*.implementations */ &ilbc_102_8k_20ms_implementation,
|
||||
/*.next */ &ilbc_20ms_codec_interface
|
||||
};
|
||||
|
||||
static const switch_codec_interface_t ilbc_codec_interface = {
|
||||
/*.interface_name */ "ilbc",
|
||||
/*.implementations */ &ilbc_8k_20ms_implementation,
|
||||
/*.next*/ &ilbc_102_codec_interface
|
||||
static const switch_codec_interface_t ilbc_codec_interface = {
|
||||
/*.interface_name */ "ilbc",
|
||||
/*.implementations */ &ilbc_8k_20ms_implementation,
|
||||
/*.next */ &ilbc_102_codec_interface
|
||||
};
|
||||
|
||||
|
||||
static switch_loadable_module_interface_t ilbc_module_interface = {
|
||||
/*.module_name */ modname,
|
||||
/*.endpoint_interface */ NULL,
|
||||
/*.timer_interface */ NULL,
|
||||
/*.dialplan_interface */ NULL,
|
||||
/*.codec_interface */ &ilbc_codec_interface,
|
||||
/*.application_interface */ NULL
|
||||
static switch_loadable_module_interface_t ilbc_module_interface = {
|
||||
/*.module_name */ modname,
|
||||
/*.endpoint_interface */ NULL,
|
||||
/*.timer_interface */ NULL,
|
||||
/*.dialplan_interface */ NULL,
|
||||
/*.codec_interface */ &ilbc_codec_interface,
|
||||
/*.application_interface */ NULL
|
||||
};
|
||||
|
||||
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
char *filename)
|
||||
{
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = &ilbc_module_interface;
|
||||
|
||||
|
||||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = &ilbc_module_interface;
|
||||
|
||||
|
||||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ static const char modname[] = "mod_l16";
|
||||
|
||||
|
||||
static switch_status_t switch_raw_init(switch_codec_t *codec, switch_codec_flag_t flags,
|
||||
const switch_codec_settings_t *codec_settings)
|
||||
const switch_codec_settings_t *codec_settings)
|
||||
{
|
||||
int encoding, decoding;
|
||||
|
||||
@@ -50,15 +50,16 @@ static switch_status_t switch_raw_init(switch_codec_t *codec, switch_codec_flag_
|
||||
}
|
||||
|
||||
static switch_status_t switch_raw_encode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *decoded_data,
|
||||
uint32_t decoded_data_len,
|
||||
uint32_t decoded_rate,
|
||||
void *encoded_data,
|
||||
uint32_t *encoded_data_len, uint32_t *encoded_rate, unsigned int *flag)
|
||||
switch_codec_t *other_codec,
|
||||
void *decoded_data,
|
||||
uint32_t decoded_data_len,
|
||||
uint32_t decoded_rate,
|
||||
void *encoded_data,
|
||||
uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
|
||||
{
|
||||
/* NOOP indicates that the audio in is already the same as the audio out, so no conversion was necessary. */
|
||||
if (codec && other_codec && codec->implementation->samples_per_second != other_codec->implementation->samples_per_second) {
|
||||
if (codec && other_codec
|
||||
&& codec->implementation->samples_per_second != other_codec->implementation->samples_per_second) {
|
||||
memcpy(encoded_data, decoded_data, decoded_data_len);
|
||||
*encoded_data_len = decoded_data_len;
|
||||
return SWITCH_STATUS_RESAMPLE;
|
||||
@@ -67,14 +68,15 @@ static switch_status_t switch_raw_encode(switch_codec_t *codec,
|
||||
}
|
||||
|
||||
static switch_status_t switch_raw_decode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *encoded_data,
|
||||
uint32_t encoded_data_len,
|
||||
uint32_t encoded_rate,
|
||||
void *decoded_data,
|
||||
uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag)
|
||||
switch_codec_t *other_codec,
|
||||
void *encoded_data,
|
||||
uint32_t encoded_data_len,
|
||||
uint32_t encoded_rate,
|
||||
void *decoded_data,
|
||||
uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
|
||||
{
|
||||
if (codec && other_codec && codec->implementation->samples_per_second != other_codec->implementation->samples_per_second) {
|
||||
if (codec && other_codec
|
||||
&& codec->implementation->samples_per_second != other_codec->implementation->samples_per_second) {
|
||||
memcpy(decoded_data, encoded_data, encoded_data_len);
|
||||
*decoded_data_len = encoded_data_len;
|
||||
return SWITCH_STATUS_RESAMPLE;
|
||||
@@ -107,7 +109,7 @@ static const switch_codec_implementation_t raw_32k_60ms_implementation = {
|
||||
/*.encode = */ switch_raw_encode,
|
||||
/*.decode = */ switch_raw_decode,
|
||||
/*.destroy = */ switch_raw_destroy
|
||||
/*.next = */
|
||||
/*.next = */
|
||||
};
|
||||
|
||||
static const switch_codec_implementation_t raw_32k_30ms_implementation = {
|
||||
@@ -298,6 +300,7 @@ static const switch_codec_implementation_t raw_16k_10ms_implementation = {
|
||||
/*.destroy = */ switch_raw_destroy,
|
||||
/*.next = */ &raw_16k_20ms_implementation
|
||||
};
|
||||
|
||||
///////////////////////////////
|
||||
|
||||
|
||||
@@ -426,7 +429,8 @@ static switch_loadable_module_interface_t raw_module_interface = {
|
||||
};
|
||||
|
||||
|
||||
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 */
|
||||
*module_interface = &raw_module_interface;
|
||||
|
||||
@@ -28,16 +28,16 @@
|
||||
*
|
||||
* mod_lpc10.c -- LPC10 Codec Module
|
||||
*
|
||||
*/
|
||||
*/
|
||||
|
||||
#include "switch.h"
|
||||
#include "lpc10.h"
|
||||
|
||||
enum {
|
||||
SamplesPerFrame = 180,
|
||||
BitsPerFrame = 54,
|
||||
BytesPerFrame = (BitsPerFrame+7)/8,
|
||||
BitsPerSecond = 2400
|
||||
BitsPerFrame = 54,
|
||||
BytesPerFrame = (BitsPerFrame + 7) / 8,
|
||||
BitsPerSecond = 2400
|
||||
};
|
||||
|
||||
#define SampleValueScale 32768.0
|
||||
@@ -52,7 +52,7 @@ struct lpc10_context {
|
||||
};
|
||||
|
||||
static switch_status_t switch_lpc10_init(switch_codec_t *codec, switch_codec_flag_t flags,
|
||||
const switch_codec_settings_t *codec_settings)
|
||||
const switch_codec_settings_t *codec_settings)
|
||||
{
|
||||
uint32_t encoding, decoding;
|
||||
struct lpc10_context *context = NULL;
|
||||
@@ -78,44 +78,40 @@ static switch_status_t switch_lpc10_init(switch_codec_t *codec, switch_codec_fla
|
||||
}
|
||||
}
|
||||
|
||||
static switch_status_t switch_lpc10_destroy(switch_codec_t *codec)
|
||||
static switch_status_t switch_lpc10_destroy(switch_codec_t *codec)
|
||||
{
|
||||
codec->private_info = NULL;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t switch_lpc10_encode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *decoded_data,
|
||||
|
||||
uint32_t decoded_data_len,
|
||||
uint32_t decoded_rate,
|
||||
void *encoded_data,
|
||||
|
||||
uint32_t *encoded_data_len,
|
||||
uint32_t *encoded_rate,
|
||||
unsigned int *flag)
|
||||
static switch_status_t switch_lpc10_encode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *decoded_data,
|
||||
uint32_t decoded_data_len,
|
||||
uint32_t decoded_rate,
|
||||
void *encoded_data,
|
||||
uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
|
||||
{
|
||||
struct lpc10_context *context = codec->private_info;
|
||||
uint8_t i;
|
||||
int32_t bits[BitsPerFrame];
|
||||
real speech[SamplesPerFrame];
|
||||
const short *sampleBuffer = (const short *)decoded_data;
|
||||
unsigned char *buffer = (unsigned char *)encoded_data;
|
||||
const short *sampleBuffer = (const short *) decoded_data;
|
||||
unsigned char *buffer = (unsigned char *) encoded_data;
|
||||
|
||||
if (!context) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
for (i = 0; i < SamplesPerFrame; i++)
|
||||
speech[i] = (real)(sampleBuffer[i]/SampleValueScale);
|
||||
speech[i] = (real) (sampleBuffer[i] / SampleValueScale);
|
||||
|
||||
lpc10_encode(speech, bits, &context->encoder_object);
|
||||
|
||||
memset(encoded_data, 0, BytesPerFrame);
|
||||
for (i = 0; i < BitsPerFrame; i++) {
|
||||
if (bits[i])
|
||||
buffer[i>>3] |= 1 << (i&7);
|
||||
buffer[i >> 3] |= 1 << (i & 7);
|
||||
}
|
||||
|
||||
*encoded_data_len = BytesPerFrame;
|
||||
@@ -123,91 +119,87 @@ static switch_status_t switch_lpc10_encode(switch_codec_t *codec,
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t switch_lpc10_decode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *encoded_data,
|
||||
|
||||
uint32_t encoded_data_len,
|
||||
uint32_t encoded_rate,
|
||||
void *decoded_data,
|
||||
|
||||
uint32_t *decoded_data_len,
|
||||
uint32_t *decoded_rate,
|
||||
unsigned int *flag)
|
||||
static switch_status_t switch_lpc10_decode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *encoded_data,
|
||||
uint32_t encoded_data_len,
|
||||
uint32_t encoded_rate,
|
||||
void *decoded_data,
|
||||
uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
|
||||
{
|
||||
struct lpc10_context *context = codec->private_info;
|
||||
int i;
|
||||
INT32 bits[BitsPerFrame];
|
||||
real speech[SamplesPerFrame];
|
||||
short *sampleBuffer = (short *)decoded_data;
|
||||
const unsigned char *buffer = (const unsigned char *)encoded_data;
|
||||
short *sampleBuffer = (short *) decoded_data;
|
||||
const unsigned char *buffer = (const unsigned char *) encoded_data;
|
||||
|
||||
if (!context) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
for (i = 0; i < BitsPerFrame; i++)
|
||||
bits[i] = (buffer[i>>3]&(1<<(i&7))) != 0;
|
||||
bits[i] = (buffer[i >> 3] & (1 << (i & 7))) != 0;
|
||||
|
||||
lpc10_decode(bits, speech, &context->decoder_object);
|
||||
|
||||
for (i = 0; i < SamplesPerFrame; i++) {
|
||||
real sample = (real)(speech[i]*SampleValueScale);
|
||||
real sample = (real) (speech[i] * SampleValueScale);
|
||||
if (sample < MinSampleValue)
|
||||
sample = MinSampleValue;
|
||||
else if (sample > MaxSampleValue)
|
||||
sample = MaxSampleValue;
|
||||
sampleBuffer[i] = (short)sample;
|
||||
sampleBuffer[i] = (short) sample;
|
||||
}
|
||||
|
||||
*decoded_data_len = SamplesPerFrame*2;
|
||||
*decoded_data_len = SamplesPerFrame * 2;
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/* Registration */
|
||||
/* Registration */
|
||||
|
||||
static const switch_codec_implementation_t lpc10_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 7,
|
||||
/*.iananame */ "LPC",
|
||||
static const switch_codec_implementation_t lpc10_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 7,
|
||||
/*.iananame */ "LPC",
|
||||
/*.fmtp */ NULL,
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.bits_per_second */ 240,
|
||||
/*.microseconds_per_frame */ 22500,
|
||||
/*.samples_per_frame */ 180,
|
||||
/*.bytes_per_frame */ 360,
|
||||
/*.encoded_bytes_per_frame */ 7,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_lpc10_init,
|
||||
/*.encode */ switch_lpc10_encode,
|
||||
/*.decode */ switch_lpc10_decode,
|
||||
/*.destroy */ switch_lpc10_destroy,
|
||||
/*.bits_per_second */ 240,
|
||||
/*.microseconds_per_frame */ 22500,
|
||||
/*.samples_per_frame */ 180,
|
||||
/*.bytes_per_frame */ 360,
|
||||
/*.encoded_bytes_per_frame */ 7,
|
||||
/*.number_of_channels */ 1,
|
||||
/*.pref_frames_per_packet */ 1,
|
||||
/*.max_frames_per_packet */ 1,
|
||||
/*.init */ switch_lpc10_init,
|
||||
/*.encode */ switch_lpc10_encode,
|
||||
/*.decode */ switch_lpc10_decode,
|
||||
/*.destroy */ switch_lpc10_destroy,
|
||||
};
|
||||
|
||||
const switch_codec_interface_t lpc10_codec_interface = {
|
||||
/*.interface_name */ "LPC-10 2.4kbps",
|
||||
/*.implementations */ &lpc10_implementation,
|
||||
const switch_codec_interface_t lpc10_codec_interface = {
|
||||
/*.interface_name */ "LPC-10 2.4kbps",
|
||||
/*.implementations */ &lpc10_implementation,
|
||||
};
|
||||
|
||||
static switch_loadable_module_interface_t lpc10_module_interface = {
|
||||
/*.module_name */ modname,
|
||||
/*.endpoint_interface */ NULL,
|
||||
/*.timer_interface */ NULL,
|
||||
/*.dialplan_interface */ NULL,
|
||||
/*.codec_interface */ &lpc10_codec_interface,
|
||||
/*.application_interface */ NULL
|
||||
static switch_loadable_module_interface_t lpc10_module_interface = {
|
||||
/*.module_name */ modname,
|
||||
/*.endpoint_interface */ NULL,
|
||||
/*.timer_interface */ NULL,
|
||||
/*.dialplan_interface */ NULL,
|
||||
/*.codec_interface */ &lpc10_codec_interface,
|
||||
/*.application_interface */ NULL
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface,
|
||||
char *filename)
|
||||
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 = &lpc10_module_interface;
|
||||
|
||||
/* indicate that the module should continue to be loaded */
|
||||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ struct speex_context {
|
||||
};
|
||||
|
||||
static switch_status_t switch_speex_init(switch_codec_t *codec, switch_codec_flag_t flags,
|
||||
const switch_codec_settings_t *codec_settings)
|
||||
const switch_codec_settings_t *codec_settings)
|
||||
{
|
||||
struct speex_context *context = NULL;
|
||||
int encoding, decoding;
|
||||
@@ -158,12 +158,12 @@ static switch_status_t switch_speex_init(switch_codec_t *codec, switch_codec_fla
|
||||
}
|
||||
|
||||
static switch_status_t switch_speex_encode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *decoded_data,
|
||||
uint32_t decoded_data_len,
|
||||
uint32_t decoded_rate,
|
||||
void *encoded_data,
|
||||
uint32_t *encoded_data_len, uint32_t *encoded_rate, unsigned int *flag)
|
||||
switch_codec_t *other_codec,
|
||||
void *decoded_data,
|
||||
uint32_t decoded_data_len,
|
||||
uint32_t decoded_rate,
|
||||
void *encoded_data,
|
||||
uint32_t * encoded_data_len, uint32_t * encoded_rate, unsigned int *flag)
|
||||
{
|
||||
struct speex_context *context = codec->private_info;
|
||||
short *buf;
|
||||
@@ -211,12 +211,12 @@ static switch_status_t switch_speex_encode(switch_codec_t *codec,
|
||||
}
|
||||
|
||||
static switch_status_t switch_speex_decode(switch_codec_t *codec,
|
||||
switch_codec_t *other_codec,
|
||||
void *encoded_data,
|
||||
uint32_t encoded_data_len,
|
||||
uint32_t encoded_rate,
|
||||
void *decoded_data,
|
||||
uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag)
|
||||
switch_codec_t *other_codec,
|
||||
void *encoded_data,
|
||||
uint32_t encoded_data_len,
|
||||
uint32_t encoded_rate,
|
||||
void *decoded_data,
|
||||
uint32_t * decoded_data_len, uint32_t * decoded_rate, unsigned int *flag)
|
||||
{
|
||||
struct speex_context *context = codec->private_info;
|
||||
short *buf;
|
||||
@@ -343,7 +343,8 @@ static switch_loadable_module_interface_t speex_module_interface = {
|
||||
/*.application_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 */
|
||||
*module_interface = &speex_module_interface;
|
||||
|
||||
@@ -46,12 +46,12 @@ static struct {
|
||||
} globals;
|
||||
|
||||
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_directory_name, globals.directory_name)
|
||||
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_host, globals.host)
|
||||
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dn, globals.dn)
|
||||
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_pass, globals.pass)
|
||||
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_base, globals.base)
|
||||
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_host, globals.host)
|
||||
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dn, globals.dn)
|
||||
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_pass, globals.pass)
|
||||
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_base, globals.base)
|
||||
|
||||
static void load_config(void)
|
||||
static void load_config(void)
|
||||
{
|
||||
char *cf = "dialplan_directory.conf";
|
||||
switch_xml_t cfg, xml, settings, param;
|
||||
@@ -100,19 +100,16 @@ static switch_caller_extension_t *directory_dialplan_hunt(switch_core_session_t
|
||||
caller_profile = switch_channel_get_caller_profile(channel);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Hello %s You Dialed %s!\n", caller_profile->caller_id_name,
|
||||
caller_profile->destination_number);
|
||||
|
||||
|
||||
if (! (globals.directory_name && globals.host && globals.dn && globals.base && globals.pass)) {
|
||||
caller_profile->destination_number);
|
||||
|
||||
|
||||
if (!(globals.directory_name && globals.host && globals.dn && globals.base && globals.pass)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (switch_core_directory_open(&dh,
|
||||
if (switch_core_directory_open(&dh,
|
||||
globals.directory_name,
|
||||
globals.host,
|
||||
globals.dn,
|
||||
globals.pass,
|
||||
NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
globals.host, globals.dn, globals.pass, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't connect\n");
|
||||
return NULL;
|
||||
}
|
||||
@@ -127,10 +124,10 @@ static switch_caller_extension_t *directory_dialplan_hunt(switch_core_session_t
|
||||
while (switch_core_directory_next(&dh) == SWITCH_STATUS_SUCCESS) {
|
||||
while (switch_core_directory_next_pair(&dh, &var, &val) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "DIRECTORY VALUE [%s]=[%s]\n", var, val);
|
||||
if(!strcasecmp(var, "callflow")) {
|
||||
if (!strcasecmp(var, "callflow")) {
|
||||
if (!extension) {
|
||||
if ((extension = switch_caller_extension_new(session, caller_profile->destination_number,
|
||||
caller_profile->destination_number)) == 0) {
|
||||
caller_profile->destination_number)) == 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n");
|
||||
goto out;
|
||||
}
|
||||
@@ -143,11 +140,11 @@ static switch_caller_extension_t *directory_dialplan_hunt(switch_core_session_t
|
||||
}
|
||||
}
|
||||
}
|
||||
out:
|
||||
|
||||
out:
|
||||
|
||||
switch_core_directory_close(&dh);
|
||||
|
||||
|
||||
|
||||
if (extension) {
|
||||
switch_channel_set_state(channel, CS_EXECUTE);
|
||||
}
|
||||
@@ -159,7 +156,7 @@ static switch_caller_extension_t *directory_dialplan_hunt(switch_core_session_t
|
||||
static const switch_dialplan_interface_t directory_dialplan_interface = {
|
||||
/*.interface_name = */ "directory",
|
||||
/*.hunt_function = */ directory_dialplan_hunt
|
||||
/*.next = NULL */
|
||||
/*.next = NULL */
|
||||
};
|
||||
|
||||
static const switch_loadable_module_interface_t directory_dialplan_module_interface = {
|
||||
@@ -171,7 +168,8 @@ static const switch_loadable_module_interface_t directory_dialplan_module_interf
|
||||
/*.application_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)
|
||||
{
|
||||
|
||||
load_config();
|
||||
|
||||
@@ -50,7 +50,7 @@ static int parse_exten(switch_core_session_t *session, switch_xml_t xexten, swit
|
||||
switch_channel_t *channel;
|
||||
char *exten_name = (char *) switch_xml_attr_soft(xexten, "name");
|
||||
int proceed = 0;
|
||||
switch_stream_handle_t stream = {0};
|
||||
switch_stream_handle_t stream = { 0 };
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
caller_profile = switch_channel_get_caller_profile(channel);
|
||||
@@ -63,7 +63,7 @@ static int parse_exten(switch_core_session_t *session, switch_xml_t xexten, swit
|
||||
switch_regex_t *re = NULL;
|
||||
int ovector[30];
|
||||
break_t do_break_i = BREAK_ON_FALSE;
|
||||
|
||||
|
||||
field = (char *) switch_xml_attr(xcond, "field");
|
||||
|
||||
expression = (char *) switch_xml_attr_soft(xcond, "expression");
|
||||
@@ -83,54 +83,58 @@ static int parse_exten(switch_core_session_t *session, switch_xml_t xexten, swit
|
||||
if (field) {
|
||||
if (*field == '$') {
|
||||
char *cmd = switch_core_session_strdup(session, field + 1);
|
||||
char *e, *arg;
|
||||
field = cmd;
|
||||
field_data = "";
|
||||
char *e, *arg;
|
||||
field = cmd;
|
||||
field_data = "";
|
||||
|
||||
if (*field == '{') {
|
||||
field++;
|
||||
if ((e = strchr(field, '}'))) {
|
||||
*e = '\0';
|
||||
field_data = switch_channel_get_variable(channel, field);
|
||||
}
|
||||
} else {
|
||||
switch_safe_free(stream.data);
|
||||
memset(&stream, 0, sizeof(stream));
|
||||
SWITCH_STANDARD_STREAM(stream);
|
||||
if (*field == '{') {
|
||||
field++;
|
||||
if ((e = strchr(field, '}'))) {
|
||||
*e = '\0';
|
||||
field_data = switch_channel_get_variable(channel, field);
|
||||
}
|
||||
} else {
|
||||
switch_safe_free(stream.data);
|
||||
memset(&stream, 0, sizeof(stream));
|
||||
SWITCH_STANDARD_STREAM(stream);
|
||||
|
||||
if ((arg = strchr(cmd, '('))) {
|
||||
*arg++ = '\0';
|
||||
if ((e = strchr(arg, ')'))) {
|
||||
*e = '\0';
|
||||
if (switch_api_execute(cmd, arg, session, &stream) == SWITCH_STATUS_SUCCESS) {
|
||||
field_data = stream.data;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ((arg = strchr(cmd, '('))) {
|
||||
*arg++ = '\0';
|
||||
if ((e = strchr(arg, ')'))) {
|
||||
*e = '\0';
|
||||
if (switch_api_execute(cmd, arg, session, &stream) == SWITCH_STATUS_SUCCESS) {
|
||||
field_data = stream.data;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
field_data = switch_caller_get_field_by_name(caller_profile, field);
|
||||
}
|
||||
if (!field_data) {
|
||||
field_data = "";
|
||||
}
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "test conditions %s(%s) =~ /%s/\n", field, field_data, expression);
|
||||
if (!(proceed = switch_regex_perform(field_data, expression, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "test conditions %s(%s) =~ /%s/\n", field,
|
||||
field_data, expression);
|
||||
if (!
|
||||
(proceed =
|
||||
switch_regex_perform(field_data, expression, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Regex mismatch\n");
|
||||
|
||||
for (xaction = switch_xml_child(xcond, "anti-action"); xaction; xaction = xaction->next) {
|
||||
char *application = (char*) switch_xml_attr_soft(xaction, "application");
|
||||
char *application = (char *) switch_xml_attr_soft(xaction, "application");
|
||||
char *data = (char *) switch_xml_attr_soft(xaction, "data");
|
||||
|
||||
if (!*extension) {
|
||||
if ((*extension =
|
||||
switch_caller_extension_new(session, exten_name, caller_profile->destination_number)) == 0) {
|
||||
switch_caller_extension_new(session, exten_name,
|
||||
caller_profile->destination_number)) == 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n");
|
||||
proceed = 0;
|
||||
goto done;
|
||||
proceed = 0;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
switch_caller_extension_add_application(session, *extension, application, data);
|
||||
}
|
||||
|
||||
@@ -145,20 +149,20 @@ static int parse_exten(switch_core_session_t *session, switch_xml_t xexten, swit
|
||||
|
||||
|
||||
for (xaction = switch_xml_child(xcond, "action"); xaction; xaction = xaction->next) {
|
||||
char *application = (char*) switch_xml_attr_soft(xaction, "application");
|
||||
char *application = (char *) switch_xml_attr_soft(xaction, "application");
|
||||
char *data = (char *) switch_xml_attr_soft(xaction, "data");
|
||||
char *substituted = NULL;
|
||||
uint32_t len = 0;
|
||||
uint32_t len = 0;
|
||||
char *app_data = NULL;
|
||||
|
||||
if (field && strchr(expression, '(')) {
|
||||
len = (uint32_t)(strlen(data) + strlen(field_data) + 10);
|
||||
if (!(substituted = malloc(len))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n");
|
||||
proceed = 0;
|
||||
goto done;
|
||||
}
|
||||
memset(substituted, 0, len);
|
||||
len = (uint32_t) (strlen(data) + strlen(field_data) + 10);
|
||||
if (!(substituted = malloc(len))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n");
|
||||
proceed = 0;
|
||||
goto done;
|
||||
}
|
||||
memset(substituted, 0, len);
|
||||
switch_perform_substitution(re, proceed, data, field_data, substituted, len, ovector);
|
||||
app_data = substituted;
|
||||
} else {
|
||||
@@ -169,15 +173,15 @@ static int parse_exten(switch_core_session_t *session, switch_xml_t xexten, swit
|
||||
if ((*extension =
|
||||
switch_caller_extension_new(session, exten_name, caller_profile->destination_number)) == 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n");
|
||||
proceed = 0;
|
||||
goto done;
|
||||
proceed = 0;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
switch_caller_extension_add_application(session, *extension, application, app_data);
|
||||
switch_safe_free(substituted);
|
||||
switch_safe_free(substituted);
|
||||
}
|
||||
|
||||
|
||||
switch_regex_safe_free(re);
|
||||
|
||||
if (do_break_i == BREAK_ON_TRUE || do_break_i == BREAK_ALWAYS) {
|
||||
@@ -185,110 +189,111 @@ static int parse_exten(switch_core_session_t *session, switch_xml_t xexten, swit
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
switch_safe_free(stream.data);
|
||||
done:
|
||||
switch_safe_free(stream.data);
|
||||
return proceed;
|
||||
}
|
||||
|
||||
static switch_status_t dialplan_xml_locate(switch_core_session_t *session,
|
||||
switch_caller_profile_t *caller_profile,
|
||||
switch_xml_t *root,
|
||||
switch_xml_t *node)
|
||||
switch_xml_t * root, switch_xml_t * node)
|
||||
{
|
||||
switch_status_t status = SWITCH_STATUS_GENERR;
|
||||
switch_channel_t *channel;
|
||||
switch_stream_handle_t stream = {0};
|
||||
switch_size_t encode_len = 1024, new_len = 0;
|
||||
char *encode_buf = NULL;
|
||||
char *prof[12] = {0}, *prof_names[12] = {0}, *e = NULL;
|
||||
switch_hash_index_t *hi;
|
||||
uint32_t x = 0;
|
||||
switch_stream_handle_t stream = { 0 };
|
||||
switch_size_t encode_len = 1024, new_len = 0;
|
||||
char *encode_buf = NULL;
|
||||
char *prof[12] = { 0 }, *prof_names[12] = {
|
||||
0}, *e = NULL;
|
||||
switch_hash_index_t *hi;
|
||||
uint32_t x = 0;
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
|
||||
SWITCH_STANDARD_STREAM(stream);
|
||||
|
||||
if (!(encode_buf = malloc(encode_len))) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
prof[0] = caller_profile->context;
|
||||
prof[1] = caller_profile->destination_number;
|
||||
prof[2] = caller_profile->caller_id_name;
|
||||
prof[3] = caller_profile->caller_id_number;
|
||||
prof[4] = caller_profile->network_addr;
|
||||
prof[5] = caller_profile->ani;
|
||||
prof[6] = caller_profile->aniii;
|
||||
prof[7] = caller_profile->rdnis;
|
||||
prof[8] = caller_profile->source;
|
||||
prof[9] = caller_profile->chan_name;
|
||||
prof[10] = caller_profile->uuid;
|
||||
SWITCH_STANDARD_STREAM(stream);
|
||||
|
||||
prof_names[0] = "context";
|
||||
prof_names[1] = "destination_number";
|
||||
prof_names[2] = "caller_id_name";
|
||||
prof_names[3] = "caller_id_number";
|
||||
prof_names[4] = "network_addr";
|
||||
prof_names[5] = "ani";
|
||||
prof_names[6] = "aniii";
|
||||
prof_names[7] = "rdnis";
|
||||
prof_names[8] = "source";
|
||||
prof_names[9] = "chan_name";
|
||||
prof_names[10] = "uuid";
|
||||
if (!(encode_buf = malloc(encode_len))) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
for (x = 0; prof[x]; x++) {
|
||||
prof[0] = caller_profile->context;
|
||||
prof[1] = caller_profile->destination_number;
|
||||
prof[2] = caller_profile->caller_id_name;
|
||||
prof[3] = caller_profile->caller_id_number;
|
||||
prof[4] = caller_profile->network_addr;
|
||||
prof[5] = caller_profile->ani;
|
||||
prof[6] = caller_profile->aniii;
|
||||
prof[7] = caller_profile->rdnis;
|
||||
prof[8] = caller_profile->source;
|
||||
prof[9] = caller_profile->chan_name;
|
||||
prof[10] = caller_profile->uuid;
|
||||
|
||||
prof_names[0] = "context";
|
||||
prof_names[1] = "destination_number";
|
||||
prof_names[2] = "caller_id_name";
|
||||
prof_names[3] = "caller_id_number";
|
||||
prof_names[4] = "network_addr";
|
||||
prof_names[5] = "ani";
|
||||
prof_names[6] = "aniii";
|
||||
prof_names[7] = "rdnis";
|
||||
prof_names[8] = "source";
|
||||
prof_names[9] = "chan_name";
|
||||
prof_names[10] = "uuid";
|
||||
|
||||
for (x = 0; prof[x]; x++) {
|
||||
if (switch_strlen_zero(prof[x])) {
|
||||
continue;
|
||||
}
|
||||
new_len = (strlen(prof[x]) * 3) + 1;
|
||||
if (encode_len < new_len) {
|
||||
char *tmp;
|
||||
|
||||
encode_len = new_len;
|
||||
new_len = (strlen(prof[x]) * 3) + 1;
|
||||
if (encode_len < new_len) {
|
||||
char *tmp;
|
||||
|
||||
if (!(tmp = realloc(encode_buf, encode_len))) {
|
||||
goto done;
|
||||
}
|
||||
encode_len = new_len;
|
||||
|
||||
encode_buf = tmp;
|
||||
}
|
||||
switch_url_encode(prof[x], encode_buf, encode_len - 1);
|
||||
stream.write_function(&stream, "%s=%s&", prof_names[x], encode_buf);
|
||||
}
|
||||
if (!(tmp = realloc(encode_buf, encode_len))) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
||||
for (hi = switch_channel_variable_first(channel, switch_core_session_get_pool(session)); hi; hi = switch_hash_next(hi)) {
|
||||
void *val;
|
||||
const void *var;
|
||||
switch_hash_this(hi, &var, NULL, &val);
|
||||
|
||||
new_len = (strlen((char *) var) * 3) + 1;
|
||||
if (encode_len < new_len) {
|
||||
char *tmp;
|
||||
|
||||
encode_len = new_len;
|
||||
|
||||
if (!(tmp = realloc(encode_buf, encode_len))) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
encode_buf = tmp;
|
||||
}
|
||||
|
||||
switch_url_encode((char *) val, encode_buf, encode_len - 1);
|
||||
stream.write_function(&stream, "%s=%s&", (char *) var, encode_buf);
|
||||
|
||||
encode_buf = tmp;
|
||||
}
|
||||
switch_url_encode(prof[x], encode_buf, encode_len - 1);
|
||||
stream.write_function(&stream, "%s=%s&", prof_names[x], encode_buf);
|
||||
}
|
||||
|
||||
e = (char *)stream.data + (strlen((char *)stream.data) - 1);
|
||||
|
||||
if (e && *e == '&') {
|
||||
*e = '\0';
|
||||
}
|
||||
|
||||
for (hi = switch_channel_variable_first(channel, switch_core_session_get_pool(session)); hi;
|
||||
hi = switch_hash_next(hi)) {
|
||||
void *val;
|
||||
const void *var;
|
||||
switch_hash_this(hi, &var, NULL, &val);
|
||||
|
||||
new_len = (strlen((char *) var) * 3) + 1;
|
||||
if (encode_len < new_len) {
|
||||
char *tmp;
|
||||
|
||||
encode_len = new_len;
|
||||
|
||||
if (!(tmp = realloc(encode_buf, encode_len))) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
encode_buf = tmp;
|
||||
}
|
||||
|
||||
switch_url_encode((char *) val, encode_buf, encode_len - 1);
|
||||
stream.write_function(&stream, "%s=%s&", (char *) var, encode_buf);
|
||||
|
||||
}
|
||||
|
||||
e = (char *) stream.data + (strlen((char *) stream.data) - 1);
|
||||
|
||||
if (e && *e == '&') {
|
||||
*e = '\0';
|
||||
}
|
||||
|
||||
status = switch_xml_locate("dialplan", NULL, NULL, NULL, root, node, stream.data);
|
||||
|
||||
done:
|
||||
done:
|
||||
switch_safe_free(stream.data);
|
||||
switch_safe_free(encode_buf);
|
||||
return status;
|
||||
@@ -300,7 +305,7 @@ static switch_caller_extension_t *dialplan_hunt(switch_core_session_t *session,
|
||||
switch_caller_extension_t *extension = NULL;
|
||||
switch_channel_t *channel;
|
||||
switch_xml_t alt_root = NULL, cfg, xml = NULL, xcontext, xexten;
|
||||
char *alt_path = (char *) arg;
|
||||
char *alt_path = (char *) arg;
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
|
||||
@@ -319,41 +324,43 @@ static switch_caller_extension_t *dialplan_hunt(switch_core_session_t *session,
|
||||
/* get our handle to the "dialplan" section of the config */
|
||||
|
||||
if (!switch_strlen_zero(alt_path)) {
|
||||
switch_xml_t conf = NULL, tag = NULL;
|
||||
if (!(alt_root = switch_xml_parse_file(alt_path))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of [%s] failed\n", alt_path);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if ((conf = switch_xml_find_child(alt_root, "section", "name", "dialplan")) &&
|
||||
switch_xml_t conf = NULL, tag = NULL;
|
||||
if (!(alt_root = switch_xml_parse_file(alt_path))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of [%s] failed\n", alt_path);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if ((conf = switch_xml_find_child(alt_root, "section", "name", "dialplan")) &&
|
||||
(tag = switch_xml_find_child(conf, "dialplan", NULL, NULL))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Getting dialplan from alternate path: %s\n", alt_path);
|
||||
xml = alt_root;
|
||||
cfg = tag;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of dialplan failed\n");
|
||||
goto done;
|
||||
}
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Getting dialplan from alternate path: %s\n",
|
||||
alt_path);
|
||||
xml = alt_root;
|
||||
cfg = tag;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of dialplan failed\n");
|
||||
goto done;
|
||||
}
|
||||
} else {
|
||||
if (dialplan_xml_locate(session, caller_profile, &xml, &cfg) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of dialplan failed\n");
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
/* get a handle to the context tag */
|
||||
}
|
||||
|
||||
/* get a handle to the context tag */
|
||||
if (!(xcontext = switch_xml_find_child(cfg, "context", "name", caller_profile->context))) {
|
||||
if (!(xcontext = switch_xml_find_child(cfg, "context", "name", "global"))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "context %s not found\n", caller_profile->context);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "context %s not found\n",
|
||||
caller_profile->context);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!(xexten = switch_xml_find_child(xcontext, "extension", "name", caller_profile->destination_number))) {
|
||||
xexten = switch_xml_child(xcontext, "extension");
|
||||
}
|
||||
|
||||
while(xexten) {
|
||||
|
||||
while (xexten) {
|
||||
int proceed = 0;
|
||||
char *cont = (char *) switch_xml_attr_soft(xexten, "continue");
|
||||
|
||||
@@ -374,7 +381,7 @@ static switch_caller_extension_t *dialplan_hunt(switch_core_session_t *session,
|
||||
switch_channel_set_state(channel, CS_EXECUTE);
|
||||
}
|
||||
|
||||
done:
|
||||
done:
|
||||
switch_xml_free(xml);
|
||||
return extension;
|
||||
}
|
||||
@@ -383,7 +390,7 @@ done:
|
||||
static const switch_dialplan_interface_t dialplan_interface = {
|
||||
/*.interface_name = */ "XML",
|
||||
/*.hunt_function = */ dialplan_hunt
|
||||
/*.next = NULL */
|
||||
/*.next = NULL */
|
||||
};
|
||||
|
||||
static const switch_loadable_module_interface_t dialplan_module_interface = {
|
||||
@@ -395,7 +402,8 @@ static const switch_loadable_module_interface_t dialplan_module_interface = {
|
||||
/*.application_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 */
|
||||
|
||||
@@ -44,10 +44,10 @@ static const char modname[] = "mod_ldap";
|
||||
|
||||
struct ldap_context {
|
||||
LDAP *ld;
|
||||
LDAPMessage* msg;
|
||||
LDAPMessage* entry;
|
||||
BerElement* ber;
|
||||
char* attr;
|
||||
LDAPMessage *msg;
|
||||
LDAPMessage *entry;
|
||||
BerElement *ber;
|
||||
char *attr;
|
||||
char *var;
|
||||
char *val;
|
||||
char **vals;
|
||||
@@ -60,14 +60,14 @@ struct ldap_context {
|
||||
static switch_status_t mod_ldap_open(switch_directory_handle_t *dh, char *source, char *dsn, char *passwd)
|
||||
{
|
||||
struct ldap_context *context;
|
||||
int auth_method = LDAP_AUTH_SIMPLE;
|
||||
int auth_method = LDAP_AUTH_SIMPLE;
|
||||
int desired_version = LDAP_VERSION3;
|
||||
|
||||
if ((context = switch_core_alloc(dh->memory_pool, sizeof(*context))) == 0) {
|
||||
return SWITCH_STATUS_MEMERR;
|
||||
}
|
||||
|
||||
if ((context->ld = ldap_init(source, LDAP_PORT)) == NULL ) {
|
||||
|
||||
if ((context->ld = ldap_init(source, LDAP_PORT)) == NULL) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
@@ -76,11 +76,11 @@ static switch_status_t mod_ldap_open(switch_directory_handle_t *dh, char *source
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
if (ldap_bind_s(context->ld, dsn, passwd, auth_method) != LDAP_SUCCESS ) {
|
||||
if (ldap_bind_s(context->ld, dsn, passwd, auth_method) != LDAP_SUCCESS) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
dh->private_info = context;
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
@@ -112,7 +112,7 @@ static switch_status_t mod_ldap_query(switch_directory_handle_t *dh, char *base,
|
||||
if (ldap_count_entries(context->ld, context->msg) <= 0) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ static switch_status_t mod_ldap_next_pair(switch_directory_handle_t *dh, char **
|
||||
*val = context->val;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
} else {
|
||||
itter:
|
||||
itter:
|
||||
if (context->attr && context->vals) {
|
||||
if ((*val = context->vals[context->vi++])) {
|
||||
*var = context->attr;
|
||||
@@ -177,7 +177,7 @@ static switch_status_t mod_ldap_next_pair(switch_directory_handle_t *dh, char **
|
||||
ldap_memfree(context->val);
|
||||
context->val = NULL;
|
||||
if (context->ber) {
|
||||
ber_free(context->ber,0);
|
||||
ber_free(context->ber, 0);
|
||||
context->ber = NULL;
|
||||
}
|
||||
context->attr = ldap_first_attribute(context->ld, context->entry, &context->ber);
|
||||
@@ -188,22 +188,23 @@ static switch_status_t mod_ldap_next_pair(switch_directory_handle_t *dh, char **
|
||||
context->attr = ldap_next_attribute(context->ld, context->entry, context->ber);
|
||||
}
|
||||
context->vitt++;
|
||||
if (context->entry && context->attr && (context->vals = ldap_get_values(context->ld, context->entry, context->attr)) != 0) {
|
||||
if (context->entry && context->attr
|
||||
&& (context->vals = ldap_get_values(context->ld, context->entry, context->attr)) != 0) {
|
||||
goto itter;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
static const switch_directory_interface_t ldap_directory_interface = {
|
||||
/*.interface_name */ "ldap",
|
||||
/*.directory_open*/ mod_ldap_open,
|
||||
/*.directory_close*/ mod_ldap_close,
|
||||
/*.directory_query*/ mod_ldap_query,
|
||||
/*.directory_next*/ mod_ldap_next,
|
||||
/*.directory_next_pair*/ mod_ldap_next_pair
|
||||
/*.interface_name */ "ldap",
|
||||
/*.directory_open */ mod_ldap_open,
|
||||
/*.directory_close */ mod_ldap_close,
|
||||
/*.directory_query */ mod_ldap_query,
|
||||
/*.directory_next */ mod_ldap_next,
|
||||
/*.directory_next_pair */ mod_ldap_next_pair
|
||||
};
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+127
-114
@@ -98,9 +98,9 @@ typedef struct private_object private_t;
|
||||
|
||||
|
||||
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, globals.dialplan)
|
||||
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_string, globals.codec_string)
|
||||
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_rates_string, globals.codec_rates_string)
|
||||
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_ip, globals.ip)
|
||||
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_string, globals.codec_string)
|
||||
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_rates_string, globals.codec_rates_string)
|
||||
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_ip, globals.ip)
|
||||
|
||||
|
||||
static char *IAXNAMES[] =
|
||||
@@ -209,9 +209,9 @@ typedef enum {
|
||||
IAX_QUERY = 2
|
||||
} iax_io_t;
|
||||
|
||||
static switch_status_t iax_set_codec(private_t *tech_pvt, struct iax_session *iax_session,
|
||||
unsigned int *format, unsigned int *cababilities, unsigned short *samprate,
|
||||
iax_io_t io)
|
||||
static switch_status_t iax_set_codec(private_t * tech_pvt, struct iax_session *iax_session,
|
||||
unsigned int *format, unsigned int *cababilities, unsigned short *samprate,
|
||||
iax_io_t io)
|
||||
{
|
||||
char *dname = NULL;
|
||||
//int rate = 8000;
|
||||
@@ -225,15 +225,16 @@ static switch_status_t iax_set_codec(private_t *tech_pvt, struct iax_session *ia
|
||||
|
||||
if (globals.codec_string) {
|
||||
if ((num_codecs = switch_loadable_module_get_codecs_sorted(codecs,
|
||||
SWITCH_MAX_CODECS,
|
||||
globals.codec_order,
|
||||
globals.codec_order_last)) <= 0) {
|
||||
SWITCH_MAX_CODECS,
|
||||
globals.codec_order,
|
||||
globals.codec_order_last)) <= 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "NO codecs?\n");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
} else
|
||||
if (((num_codecs =
|
||||
switch_loadable_module_get_codecs(switch_core_session_get_pool(tech_pvt->session), codecs, SWITCH_MAX_CODECS))) <= 0) {
|
||||
switch_loadable_module_get_codecs(switch_core_session_get_pool(tech_pvt->session), codecs,
|
||||
SWITCH_MAX_CODECS))) <= 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "NO codecs?\n");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
@@ -244,7 +245,7 @@ static switch_status_t iax_set_codec(private_t *tech_pvt, struct iax_session *ia
|
||||
unsigned int codec = iana2ast(imp->ianacode);
|
||||
if (io == IAX_QUERY && !(codec & local_cap)) {
|
||||
iax_pref_codec_add(iax_session, codec);
|
||||
}
|
||||
}
|
||||
local_cap |= codec;
|
||||
}
|
||||
}
|
||||
@@ -422,12 +423,13 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session);
|
||||
static switch_status_t channel_on_ring(switch_core_session_t *session);
|
||||
static switch_status_t channel_on_loopback(switch_core_session_t *session);
|
||||
static switch_status_t channel_on_transmit(switch_core_session_t *session);
|
||||
static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile,
|
||||
static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session,
|
||||
switch_caller_profile_t *outbound_profile,
|
||||
switch_core_session_t **new_session, switch_memory_pool_t **pool);
|
||||
static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout,
|
||||
switch_io_flag_t flags, int stream_id);
|
||||
switch_io_flag_t flags, int stream_id);
|
||||
static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
|
||||
switch_io_flag_t flags, int stream_id);
|
||||
switch_io_flag_t flags, int stream_id);
|
||||
static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
|
||||
|
||||
|
||||
@@ -443,14 +445,14 @@ static void iax_out_cb(const char *s)
|
||||
}
|
||||
}
|
||||
|
||||
static void tech_init(private_t *tech_pvt, switch_core_session_t *session)
|
||||
static void tech_init(private_t * tech_pvt, switch_core_session_t *session)
|
||||
{
|
||||
tech_pvt->read_frame.data = tech_pvt->databuf;
|
||||
tech_pvt->read_frame.buflen = sizeof(tech_pvt->databuf);
|
||||
switch_mutex_init(&tech_pvt->mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
|
||||
switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
|
||||
switch_core_session_set_private(session, tech_pvt);
|
||||
tech_pvt->session = session;
|
||||
switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
|
||||
switch_core_session_set_private(session, tech_pvt);
|
||||
tech_pvt->session = session;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -559,7 +561,7 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session)
|
||||
globals.calls = 0;
|
||||
}
|
||||
switch_mutex_unlock(globals.mutex);
|
||||
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -574,20 +576,20 @@ static switch_status_t channel_kill_channel(switch_core_session_t *session, int
|
||||
tech_pvt = switch_core_session_get_private(session);
|
||||
assert(tech_pvt != NULL);
|
||||
|
||||
switch(sig) {
|
||||
case SWITCH_SIG_KILL:
|
||||
switch_clear_flag_locked(tech_pvt, TFLAG_IO);
|
||||
switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
|
||||
//switch_thread_cond_signal(tech_pvt->cond);
|
||||
break;
|
||||
case SWITCH_SIG_BREAK:
|
||||
switch_set_flag_locked(tech_pvt, TFLAG_BREAK);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (sig) {
|
||||
case SWITCH_SIG_KILL:
|
||||
switch_clear_flag_locked(tech_pvt, TFLAG_IO);
|
||||
switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
|
||||
//switch_thread_cond_signal(tech_pvt->cond);
|
||||
break;
|
||||
case SWITCH_SIG_BREAK:
|
||||
switch_set_flag_locked(tech_pvt, TFLAG_BREAK);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -641,33 +643,33 @@ static switch_status_t channel_send_dtmf(switch_core_session_t *session, char *d
|
||||
}
|
||||
|
||||
static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout,
|
||||
switch_io_flag_t flags, int stream_id)
|
||||
switch_io_flag_t flags, int stream_id)
|
||||
{
|
||||
switch_channel_t *channel = NULL;
|
||||
private_t *tech_pvt = NULL;
|
||||
switch_time_t started = switch_time_now();
|
||||
unsigned int elapsed;
|
||||
switch_byte_t *data;
|
||||
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
assert(channel != NULL);
|
||||
|
||||
tech_pvt = switch_core_session_get_private(session);
|
||||
assert(tech_pvt != NULL);
|
||||
tech_pvt->read_frame.flags = SFF_NONE;
|
||||
*frame = NULL;
|
||||
tech_pvt->read_frame.flags = SFF_NONE;
|
||||
*frame = NULL;
|
||||
|
||||
while (switch_test_flag(tech_pvt, TFLAG_IO)) {
|
||||
|
||||
if (!switch_test_flag(tech_pvt, TFLAG_CODEC)) {
|
||||
switch_yield(1000);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!switch_test_flag(tech_pvt, TFLAG_CODEC)) {
|
||||
switch_yield(1000);
|
||||
continue;
|
||||
}
|
||||
//switch_thread_cond_wait(tech_pvt->cond, tech_pvt->mutex);
|
||||
if (switch_test_flag(tech_pvt, TFLAG_BREAK)) {
|
||||
switch_clear_flag(tech_pvt, TFLAG_BREAK);
|
||||
goto cng;
|
||||
}
|
||||
switch_clear_flag(tech_pvt, TFLAG_BREAK);
|
||||
goto cng;
|
||||
}
|
||||
|
||||
if (!switch_test_flag(tech_pvt, TFLAG_IO)) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
@@ -688,12 +690,12 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
||||
}
|
||||
|
||||
if (timeout > -1) {
|
||||
elapsed = (unsigned int)((switch_time_now() - started) / 1000);
|
||||
if (elapsed >= (unsigned int)timeout) {
|
||||
elapsed = (unsigned int) ((switch_time_now() - started) / 1000);
|
||||
if (elapsed >= (unsigned int) timeout) {
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
switch_yield(1000);
|
||||
}
|
||||
@@ -701,19 +703,19 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
||||
|
||||
return SWITCH_STATUS_FALSE;
|
||||
|
||||
cng:
|
||||
cng:
|
||||
data = (switch_byte_t *) tech_pvt->read_frame.data;
|
||||
data[0] = 65;
|
||||
data[1] = 0;
|
||||
tech_pvt->read_frame.datalen = 2;
|
||||
tech_pvt->read_frame.flags = SFF_CNG;
|
||||
*frame = &tech_pvt->read_frame;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
tech_pvt->read_frame.datalen = 2;
|
||||
tech_pvt->read_frame.flags = SFF_CNG;
|
||||
*frame = &tech_pvt->read_frame;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
|
||||
switch_io_flag_t flags, int stream_id)
|
||||
switch_io_flag_t flags, int stream_id)
|
||||
{
|
||||
switch_channel_t *channel = NULL;
|
||||
private_t *tech_pvt = NULL;
|
||||
@@ -799,7 +801,8 @@ static const switch_loadable_module_interface_t channel_module_interface = {
|
||||
/* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines
|
||||
that allocate memory or you will have 1 channel with memory allocated from another channel's pool!
|
||||
*/
|
||||
static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile,
|
||||
static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session,
|
||||
switch_caller_profile_t *outbound_profile,
|
||||
switch_core_session_t **new_session, switch_memory_pool_t **pool)
|
||||
{
|
||||
if ((*new_session = switch_core_session_request(&channel_endpoint_interface, pool)) != 0) {
|
||||
@@ -812,7 +815,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
|
||||
switch_core_session_add_stream(*new_session, NULL);
|
||||
if ((tech_pvt = (private_t *) switch_core_session_alloc(*new_session, sizeof(private_t))) != 0) {
|
||||
channel = switch_core_session_get_channel(*new_session);
|
||||
tech_init(tech_pvt, *new_session);
|
||||
tech_init(tech_pvt, *new_session);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n");
|
||||
switch_core_session_destroy(new_session);
|
||||
@@ -863,7 +866,8 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
|
||||
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) {
|
||||
@@ -871,7 +875,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
|
||||
return SWITCH_STATUS_TERM;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = &channel_module_interface;
|
||||
|
||||
@@ -943,18 +947,21 @@ static switch_status_t load_config(void)
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t tech_media(private_t *tech_pvt, struct iax_event *iaxevent)
|
||||
static switch_status_t tech_media(private_t * tech_pvt, struct iax_event *iaxevent)
|
||||
{
|
||||
unsigned int cap = iax_session_get_capability(iaxevent->session);
|
||||
unsigned int format = iaxevent->ies.format;
|
||||
unsigned int cap = iax_session_get_capability(iaxevent->session);
|
||||
unsigned int format = iaxevent->ies.format;
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
|
||||
if (!switch_test_flag(tech_pvt, TFLAG_CODEC) &&
|
||||
(status = iax_set_codec(tech_pvt, iaxevent->session, &format, &cap, &iaxevent->ies.samprate, IAX_SET)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec Error %u %u\n", iaxevent->ies.format, iaxevent->ies.capability);
|
||||
}
|
||||
|
||||
return status;
|
||||
|
||||
if (!switch_test_flag(tech_pvt, TFLAG_CODEC) &&
|
||||
(status =
|
||||
iax_set_codec(tech_pvt, iaxevent->session, &format, &cap, &iaxevent->ies.samprate,
|
||||
IAX_SET)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec Error %u %u\n", iaxevent->ies.format,
|
||||
iaxevent->ies.capability);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
|
||||
@@ -994,7 +1001,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
|
||||
/* Wait for an event. */
|
||||
if ((iaxevent = iax_get_event(0)) == NULL) {
|
||||
int waitlen = 0;
|
||||
|
||||
|
||||
if (globals.calls == 0) {
|
||||
waitlen = 10000;
|
||||
} else if (globals.calls < 10) {
|
||||
@@ -1007,12 +1014,12 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
|
||||
continue;
|
||||
} else {
|
||||
private_t *tech_pvt = NULL;
|
||||
switch_channel_t *channel = NULL;
|
||||
switch_channel_t *channel = NULL;
|
||||
|
||||
if ((tech_pvt = iax_get_private(iaxevent->session))) {
|
||||
channel = switch_core_session_get_channel(tech_pvt->session);
|
||||
}
|
||||
|
||||
if ((tech_pvt = iax_get_private(iaxevent->session))) {
|
||||
channel = switch_core_session_get_channel(tech_pvt->session);
|
||||
}
|
||||
|
||||
if (globals.debug && iaxevent->etype != IAX_EVENT_VOICE) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Event %d [%s]!\n",
|
||||
iaxevent->etype, IAXNAMES[iaxevent->etype]);
|
||||
@@ -1031,11 +1038,11 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
|
||||
break;
|
||||
case IAX_EVENT_ACCEPT:
|
||||
if (channel && !switch_channel_test_flag(channel, CF_ANSWERED)) {
|
||||
if (tech_media(tech_pvt, iaxevent) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_channel_mark_pre_answered(channel);
|
||||
} else {
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
}
|
||||
if (tech_media(tech_pvt, iaxevent) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_channel_mark_pre_answered(channel);
|
||||
} else {
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
}
|
||||
}
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Call accepted.\n");
|
||||
break;
|
||||
@@ -1052,32 +1059,34 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
|
||||
case IAX_EVENT_ANSWER:
|
||||
// the other side answered our call
|
||||
if (channel) {
|
||||
if (tech_media(tech_pvt, iaxevent) == SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_channel_test_flag(channel, CF_ANSWERED)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "WTF Mutiple Answer %s?\n", switch_channel_get_name(channel));
|
||||
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Answer %s\n", switch_channel_get_name(channel));
|
||||
switch_channel_mark_answered(channel);
|
||||
}
|
||||
} else {
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
}
|
||||
}
|
||||
if (tech_media(tech_pvt, iaxevent) == SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_channel_test_flag(channel, CF_ANSWERED)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "WTF Mutiple Answer %s?\n",
|
||||
switch_channel_get_name(channel));
|
||||
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Answer %s\n",
|
||||
switch_channel_get_name(channel));
|
||||
switch_channel_mark_answered(channel);
|
||||
}
|
||||
} else {
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IAX_EVENT_CONNECT:
|
||||
// incoming call detected
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
|
||||
"Incoming call connected %s, %s, %s %u/%u\n",
|
||||
iaxevent->ies.called_number,
|
||||
iaxevent->ies.calling_number,
|
||||
iaxevent->ies.calling_name, iaxevent->ies.format, iaxevent->ies.capability);
|
||||
"Incoming call connected %s, %s, %s %u/%u\n",
|
||||
iaxevent->ies.called_number,
|
||||
iaxevent->ies.calling_number,
|
||||
iaxevent->ies.calling_name, iaxevent->ies.format, iaxevent->ies.capability);
|
||||
|
||||
if (iaxevent) {
|
||||
switch_core_session_t *session;
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "New Inbound Channel %s!\n",
|
||||
iaxevent->ies.calling_name);
|
||||
iaxevent->ies.calling_name);
|
||||
if ((session = switch_core_session_request(&channel_endpoint_interface, NULL)) != 0) {
|
||||
private_t *tech_pvt;
|
||||
switch_channel_t *channel;
|
||||
@@ -1085,7 +1094,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
|
||||
switch_core_session_add_stream(session, NULL);
|
||||
if ((tech_pvt = (private_t *) switch_core_session_alloc(session, sizeof(private_t))) != 0) {
|
||||
channel = switch_core_session_get_channel(session);
|
||||
tech_init(tech_pvt, session);
|
||||
tech_init(tech_pvt, session);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n");
|
||||
switch_core_session_destroy(&session);
|
||||
@@ -1100,9 +1109,9 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
|
||||
iaxevent->ies.calling_number,
|
||||
iax_get_peer_ip(iaxevent->session),
|
||||
iaxevent->ies.calling_ani,
|
||||
NULL,
|
||||
NULL,
|
||||
(char *)modname,
|
||||
NULL,
|
||||
(char *) modname,
|
||||
iaxevent->ies.called_context,
|
||||
iaxevent->ies.called_number)) != 0) {
|
||||
char name[128];
|
||||
@@ -1141,11 +1150,15 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
|
||||
switch_mutex_unlock(tech_pvt->flag_mutex);
|
||||
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hangup %s\n", switch_channel_get_name(channel));
|
||||
switch_set_flag_locked(tech_pvt, TFLAG_HANGUP);
|
||||
switch_channel_hangup(channel, iaxevent->etype == IAX_EVENT_HANGUP ? SWITCH_CAUSE_NORMAL_CLEARING : SWITCH_CAUSE_FACILITY_REJECTED);
|
||||
//switch_thread_cond_signal(tech_pvt->cond);
|
||||
iaxevent->session = NULL;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hangup %s\n",
|
||||
switch_channel_get_name(channel));
|
||||
switch_set_flag_locked(tech_pvt, TFLAG_HANGUP);
|
||||
switch_channel_hangup(channel,
|
||||
iaxevent->etype ==
|
||||
IAX_EVENT_HANGUP ? SWITCH_CAUSE_NORMAL_CLEARING :
|
||||
SWITCH_CAUSE_FACILITY_REJECTED);
|
||||
//switch_thread_cond_signal(tech_pvt->cond);
|
||||
iaxevent->session = NULL;
|
||||
}
|
||||
break;
|
||||
case IAX_EVENT_CNG:
|
||||
@@ -1156,7 +1169,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
|
||||
if (tech_pvt && (tech_pvt->read_frame.datalen = iaxevent->datalen) != 0) {
|
||||
if (channel && switch_channel_get_state(channel) <= CS_HANGUP) {
|
||||
int bytes, frames;
|
||||
|
||||
|
||||
if (!switch_test_flag(tech_pvt, TFLAG_CODEC)) {
|
||||
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "audio with no codec yet!\n");
|
||||
break;
|
||||
@@ -1183,18 +1196,18 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
|
||||
break;
|
||||
case IAX_EVENT_DTMF:
|
||||
if (channel) {
|
||||
char str[2] = { (char)iaxevent->subclass };
|
||||
if (globals.debug) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s DTMF %s\n", str,
|
||||
switch_channel_get_name(channel));
|
||||
}
|
||||
switch_channel_queue_dtmf(channel, str);
|
||||
char str[2] = { (char) iaxevent->subclass };
|
||||
if (globals.debug) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s DTMF %s\n", str,
|
||||
switch_channel_get_name(channel));
|
||||
}
|
||||
switch_channel_queue_dtmf(channel, str);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Don't know what to do with IAX event %d.\n",
|
||||
iaxevent->etype);
|
||||
iaxevent->etype);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1216,7 +1229,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
|
||||
running = -1;
|
||||
|
||||
if (globals.fd) {
|
||||
/* Die Mutha $%#$@% Die Mutha $#%#$^ Die*/
|
||||
/* Die Mutha $%#$@% Die Mutha $#%#$^ Die */
|
||||
shutdown(globals.fd, 2);
|
||||
}
|
||||
iax_shutdown();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -81,17 +81,17 @@
|
||||
# define PaUtil_WriteMemoryBarrier()
|
||||
#else
|
||||
|
||||
#if defined(__APPLE__) //|| defined(__FreeBSD__)
|
||||
#if defined(__APPLE__) //|| defined(__FreeBSD__)
|
||||
# include <libkern/OSAtomic.h>
|
||||
/* Here are the memory barrier functions. Mac OS X and FreeBSD only provide
|
||||
full memory barriers, so the three types of barriers are the same. */
|
||||
/* Here are the memory barrier functions. Mac OS X and FreeBSD only provide
|
||||
full memory barriers, so the three types of barriers are the same. */
|
||||
# define PaUtil_FullMemoryBarrier() OSMemoryBarrier()
|
||||
# define PaUtil_ReadMemoryBarrier() OSMemoryBarrier()
|
||||
# define PaUtil_WriteMemoryBarrier() OSMemoryBarrier()
|
||||
#elif defined(__GNUC__)
|
||||
|
||||
/* GCC understands volatile asm and "memory" to mean it
|
||||
* should not reorder memory read/writes */
|
||||
/* GCC understands volatile asm and "memory" to mean it
|
||||
* should not reorder memory read/writes */
|
||||
# if defined( __PPC__ )
|
||||
# define PaUtil_FullMemoryBarrier() __asm__ volatile("sync":::"memory")
|
||||
# define PaUtil_ReadMemoryBarrier() __asm__ volatile("sync":::"memory")
|
||||
@@ -123,37 +123,39 @@
|
||||
* Initialize FIFO.
|
||||
* numBytes must be power of 2, returns -1 if not.
|
||||
*/
|
||||
long PaUtil_InitializeRingBuffer( PaUtilRingBuffer *rbuf, long numBytes, void *dataPtr )
|
||||
long PaUtil_InitializeRingBuffer(PaUtilRingBuffer * rbuf, long numBytes, void *dataPtr)
|
||||
{
|
||||
if( ((numBytes-1) & numBytes) != 0) return -1; /* Not Power of two. */
|
||||
rbuf->bufferSize = numBytes;
|
||||
rbuf->buffer = (char *)dataPtr;
|
||||
PaUtil_FlushRingBuffer( rbuf );
|
||||
rbuf->bigMask = (numBytes*2)-1;
|
||||
rbuf->smallMask = (numBytes)-1;
|
||||
return 0;
|
||||
if (((numBytes - 1) & numBytes) != 0)
|
||||
return -1; /* Not Power of two. */
|
||||
rbuf->bufferSize = numBytes;
|
||||
rbuf->buffer = (char *) dataPtr;
|
||||
PaUtil_FlushRingBuffer(rbuf);
|
||||
rbuf->bigMask = (numBytes * 2) - 1;
|
||||
rbuf->smallMask = (numBytes) - 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
** Return number of bytes available for reading. */
|
||||
long PaUtil_GetRingBufferReadAvailable( PaUtilRingBuffer *rbuf )
|
||||
long PaUtil_GetRingBufferReadAvailable(PaUtilRingBuffer * rbuf)
|
||||
{
|
||||
PaUtil_ReadMemoryBarrier();
|
||||
return ( (rbuf->writeIndex - rbuf->readIndex) & rbuf->bigMask );
|
||||
PaUtil_ReadMemoryBarrier();
|
||||
return ((rbuf->writeIndex - rbuf->readIndex) & rbuf->bigMask);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
** Return number of bytes available for writing. */
|
||||
long PaUtil_GetRingBufferWriteAvailable( PaUtilRingBuffer *rbuf )
|
||||
long PaUtil_GetRingBufferWriteAvailable(PaUtilRingBuffer * rbuf)
|
||||
{
|
||||
/* Since we are calling PaUtil_GetRingBufferReadAvailable, we don't need an aditional MB */
|
||||
return ( rbuf->bufferSize - PaUtil_GetRingBufferReadAvailable(rbuf));
|
||||
/* Since we are calling PaUtil_GetRingBufferReadAvailable, we don't need an aditional MB */
|
||||
return (rbuf->bufferSize - PaUtil_GetRingBufferReadAvailable(rbuf));
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
** Clear buffer. Should only be called when buffer is NOT being read. */
|
||||
void PaUtil_FlushRingBuffer( PaUtilRingBuffer *rbuf )
|
||||
void PaUtil_FlushRingBuffer(PaUtilRingBuffer * rbuf)
|
||||
{
|
||||
rbuf->writeIndex = rbuf->readIndex = 0;
|
||||
rbuf->writeIndex = rbuf->readIndex = 0;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
@@ -162,42 +164,39 @@ void PaUtil_FlushRingBuffer( PaUtilRingBuffer *rbuf )
|
||||
** If non-contiguous, size2 will be the size of second region.
|
||||
** Returns room available to be written or numBytes, whichever is smaller.
|
||||
*/
|
||||
long PaUtil_GetRingBufferWriteRegions( PaUtilRingBuffer *rbuf, long numBytes,
|
||||
void **dataPtr1, long *sizePtr1,
|
||||
void **dataPtr2, long *sizePtr2 )
|
||||
long PaUtil_GetRingBufferWriteRegions(PaUtilRingBuffer * rbuf, long numBytes,
|
||||
void **dataPtr1, long *sizePtr1, void **dataPtr2, long *sizePtr2)
|
||||
{
|
||||
long index;
|
||||
long available = PaUtil_GetRingBufferWriteAvailable( rbuf );
|
||||
if( numBytes > available ) numBytes = available;
|
||||
/* Check to see if write is not contiguous. */
|
||||
index = rbuf->writeIndex & rbuf->smallMask;
|
||||
if( (index + numBytes) > rbuf->bufferSize )
|
||||
{
|
||||
/* Write data in two blocks that wrap the buffer. */
|
||||
long firstHalf = rbuf->bufferSize - index;
|
||||
*dataPtr1 = &rbuf->buffer[index];
|
||||
*sizePtr1 = firstHalf;
|
||||
*dataPtr2 = &rbuf->buffer[0];
|
||||
*sizePtr2 = numBytes - firstHalf;
|
||||
}
|
||||
else
|
||||
{
|
||||
*dataPtr1 = &rbuf->buffer[index];
|
||||
*sizePtr1 = numBytes;
|
||||
*dataPtr2 = NULL;
|
||||
*sizePtr2 = 0;
|
||||
}
|
||||
return numBytes;
|
||||
long index;
|
||||
long available = PaUtil_GetRingBufferWriteAvailable(rbuf);
|
||||
if (numBytes > available)
|
||||
numBytes = available;
|
||||
/* Check to see if write is not contiguous. */
|
||||
index = rbuf->writeIndex & rbuf->smallMask;
|
||||
if ((index + numBytes) > rbuf->bufferSize) {
|
||||
/* Write data in two blocks that wrap the buffer. */
|
||||
long firstHalf = rbuf->bufferSize - index;
|
||||
*dataPtr1 = &rbuf->buffer[index];
|
||||
*sizePtr1 = firstHalf;
|
||||
*dataPtr2 = &rbuf->buffer[0];
|
||||
*sizePtr2 = numBytes - firstHalf;
|
||||
} else {
|
||||
*dataPtr1 = &rbuf->buffer[index];
|
||||
*sizePtr1 = numBytes;
|
||||
*dataPtr2 = NULL;
|
||||
*sizePtr2 = 0;
|
||||
}
|
||||
return numBytes;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
*/
|
||||
long PaUtil_AdvanceRingBufferWriteIndex( PaUtilRingBuffer *rbuf, long numBytes )
|
||||
long PaUtil_AdvanceRingBufferWriteIndex(PaUtilRingBuffer * rbuf, long numBytes)
|
||||
{
|
||||
/* we need to ensure that previous writes are seen before we update the write index */
|
||||
PaUtil_WriteMemoryBarrier();
|
||||
return rbuf->writeIndex = (rbuf->writeIndex + numBytes) & rbuf->bigMask;
|
||||
/* we need to ensure that previous writes are seen before we update the write index */
|
||||
PaUtil_WriteMemoryBarrier();
|
||||
return rbuf->writeIndex = (rbuf->writeIndex + numBytes) & rbuf->bigMask;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
@@ -206,81 +205,73 @@ long PaUtil_AdvanceRingBufferWriteIndex( PaUtilRingBuffer *rbuf, long numBytes )
|
||||
** If non-contiguous, size2 will be the size of second region.
|
||||
** Returns room available to be written or numBytes, whichever is smaller.
|
||||
*/
|
||||
long PaUtil_GetRingBufferReadRegions( PaUtilRingBuffer *rbuf, long numBytes,
|
||||
void **dataPtr1, long *sizePtr1,
|
||||
void **dataPtr2, long *sizePtr2 )
|
||||
long PaUtil_GetRingBufferReadRegions(PaUtilRingBuffer * rbuf, long numBytes,
|
||||
void **dataPtr1, long *sizePtr1, void **dataPtr2, long *sizePtr2)
|
||||
{
|
||||
long index;
|
||||
long available = PaUtil_GetRingBufferReadAvailable( rbuf );
|
||||
if( numBytes > available ) numBytes = available;
|
||||
/* Check to see if read is not contiguous. */
|
||||
index = rbuf->readIndex & rbuf->smallMask;
|
||||
if( (index + numBytes) > rbuf->bufferSize )
|
||||
{
|
||||
/* Write data in two blocks that wrap the buffer. */
|
||||
long firstHalf = rbuf->bufferSize - index;
|
||||
*dataPtr1 = &rbuf->buffer[index];
|
||||
*sizePtr1 = firstHalf;
|
||||
*dataPtr2 = &rbuf->buffer[0];
|
||||
*sizePtr2 = numBytes - firstHalf;
|
||||
}
|
||||
else
|
||||
{
|
||||
*dataPtr1 = &rbuf->buffer[index];
|
||||
*sizePtr1 = numBytes;
|
||||
*dataPtr2 = NULL;
|
||||
*sizePtr2 = 0;
|
||||
}
|
||||
return numBytes;
|
||||
long index;
|
||||
long available = PaUtil_GetRingBufferReadAvailable(rbuf);
|
||||
if (numBytes > available)
|
||||
numBytes = available;
|
||||
/* Check to see if read is not contiguous. */
|
||||
index = rbuf->readIndex & rbuf->smallMask;
|
||||
if ((index + numBytes) > rbuf->bufferSize) {
|
||||
/* Write data in two blocks that wrap the buffer. */
|
||||
long firstHalf = rbuf->bufferSize - index;
|
||||
*dataPtr1 = &rbuf->buffer[index];
|
||||
*sizePtr1 = firstHalf;
|
||||
*dataPtr2 = &rbuf->buffer[0];
|
||||
*sizePtr2 = numBytes - firstHalf;
|
||||
} else {
|
||||
*dataPtr1 = &rbuf->buffer[index];
|
||||
*sizePtr1 = numBytes;
|
||||
*dataPtr2 = NULL;
|
||||
*sizePtr2 = 0;
|
||||
}
|
||||
return numBytes;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
*/
|
||||
long PaUtil_AdvanceRingBufferReadIndex( PaUtilRingBuffer *rbuf, long numBytes )
|
||||
long PaUtil_AdvanceRingBufferReadIndex(PaUtilRingBuffer * rbuf, long numBytes)
|
||||
{
|
||||
/* we need to ensure that previous writes are always seen before updating the index. */
|
||||
PaUtil_WriteMemoryBarrier();
|
||||
return rbuf->readIndex = (rbuf->readIndex + numBytes) & rbuf->bigMask;
|
||||
/* we need to ensure that previous writes are always seen before updating the index. */
|
||||
PaUtil_WriteMemoryBarrier();
|
||||
return rbuf->readIndex = (rbuf->readIndex + numBytes) & rbuf->bigMask;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
** Return bytes written. */
|
||||
long PaUtil_WriteRingBuffer( PaUtilRingBuffer *rbuf, const void *data, long numBytes )
|
||||
long PaUtil_WriteRingBuffer(PaUtilRingBuffer * rbuf, const void *data, long numBytes)
|
||||
{
|
||||
long size1, size2, numWritten;
|
||||
void *data1, *data2;
|
||||
numWritten = PaUtil_GetRingBufferWriteRegions( rbuf, numBytes, &data1, &size1, &data2, &size2 );
|
||||
if( size2 > 0 )
|
||||
{
|
||||
long size1, size2, numWritten;
|
||||
void *data1, *data2;
|
||||
numWritten = PaUtil_GetRingBufferWriteRegions(rbuf, numBytes, &data1, &size1, &data2, &size2);
|
||||
if (size2 > 0) {
|
||||
|
||||
memcpy( data1, data, size1 );
|
||||
data = ((char *)data) + size1;
|
||||
memcpy( data2, data, size2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy( data1, data, size1 );
|
||||
}
|
||||
PaUtil_AdvanceRingBufferWriteIndex( rbuf, numWritten );
|
||||
return numWritten;
|
||||
memcpy(data1, data, size1);
|
||||
data = ((char *) data) + size1;
|
||||
memcpy(data2, data, size2);
|
||||
} else {
|
||||
memcpy(data1, data, size1);
|
||||
}
|
||||
PaUtil_AdvanceRingBufferWriteIndex(rbuf, numWritten);
|
||||
return numWritten;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
** Return bytes read. */
|
||||
long PaUtil_ReadRingBuffer( PaUtilRingBuffer *rbuf, void *data, long numBytes )
|
||||
long PaUtil_ReadRingBuffer(PaUtilRingBuffer * rbuf, void *data, long numBytes)
|
||||
{
|
||||
long size1, size2, numRead;
|
||||
void *data1, *data2;
|
||||
numRead = PaUtil_GetRingBufferReadRegions( rbuf, numBytes, &data1, &size1, &data2, &size2 );
|
||||
if( size2 > 0 )
|
||||
{
|
||||
memcpy( data, data1, size1 );
|
||||
data = ((char *)data) + size1;
|
||||
memcpy( data, data2, size2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy( data, data1, size1 );
|
||||
}
|
||||
PaUtil_AdvanceRingBufferReadIndex( rbuf, numRead );
|
||||
return numRead;
|
||||
long size1, size2, numRead;
|
||||
void *data1, *data2;
|
||||
numRead = PaUtil_GetRingBufferReadRegions(rbuf, numBytes, &data1, &size1, &data2, &size2);
|
||||
if (size2 > 0) {
|
||||
memcpy(data, data1, size1);
|
||||
data = ((char *) data) + size1;
|
||||
memcpy(data, data2, size2);
|
||||
} else {
|
||||
memcpy(data, data1, size1);
|
||||
}
|
||||
PaUtil_AdvanceRingBufferReadIndex(rbuf, numRead);
|
||||
return numRead;
|
||||
}
|
||||
|
||||
@@ -51,19 +51,17 @@
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef struct PaUtilRingBuffer
|
||||
{
|
||||
long bufferSize; /* Number of bytes in FIFO. Power of 2. Set by PaUtil_InitRingBuffer. */
|
||||
long writeIndex; /* Index of next writable byte. Set by PaUtil_AdvanceRingBufferWriteIndex. */
|
||||
long readIndex; /* Index of next readable byte. Set by PaUtil_AdvanceRingBufferReadIndex. */
|
||||
long bigMask; /* Used for wrapping indices with extra bit to distinguish full/empty. */
|
||||
long smallMask; /* Used for fitting indices to buffer. */
|
||||
char *buffer;
|
||||
}PaUtilRingBuffer;
|
||||
typedef struct PaUtilRingBuffer {
|
||||
long bufferSize; /* Number of bytes in FIFO. Power of 2. Set by PaUtil_InitRingBuffer. */
|
||||
long writeIndex; /* Index of next writable byte. Set by PaUtil_AdvanceRingBufferWriteIndex. */
|
||||
long readIndex; /* Index of next readable byte. Set by PaUtil_AdvanceRingBufferReadIndex. */
|
||||
long bigMask; /* Used for wrapping indices with extra bit to distinguish full/empty. */
|
||||
long smallMask; /* Used for fitting indices to buffer. */
|
||||
char *buffer;
|
||||
} PaUtilRingBuffer;
|
||||
|
||||
/** Initialize Ring Buffer.
|
||||
|
||||
@@ -76,13 +74,13 @@ typedef struct PaUtilRingBuffer
|
||||
|
||||
@return -1 if numBytes is not a power of 2, otherwise 0.
|
||||
*/
|
||||
long PaUtil_InitializeRingBuffer( PaUtilRingBuffer *rbuf, long numBytes, void *dataPtr );
|
||||
long PaUtil_InitializeRingBuffer(PaUtilRingBuffer * rbuf, long numBytes, void *dataPtr);
|
||||
|
||||
/** Clear buffer. Should only be called when buffer is NOT being read.
|
||||
|
||||
@param rbuf The ring buffer.
|
||||
*/
|
||||
void PaUtil_FlushRingBuffer( PaUtilRingBuffer *rbuf );
|
||||
void PaUtil_FlushRingBuffer(PaUtilRingBuffer * rbuf);
|
||||
|
||||
/** Retrieve the number of bytes available in the ring buffer for writing.
|
||||
|
||||
@@ -90,7 +88,7 @@ void PaUtil_FlushRingBuffer( PaUtilRingBuffer *rbuf );
|
||||
|
||||
@return The number of bytes available for writing.
|
||||
*/
|
||||
long PaUtil_GetRingBufferWriteAvailable( PaUtilRingBuffer *rbuf );
|
||||
long PaUtil_GetRingBufferWriteAvailable(PaUtilRingBuffer * rbuf);
|
||||
|
||||
/** Retrieve the number of bytes available in the ring buffer for reading.
|
||||
|
||||
@@ -98,7 +96,7 @@ long PaUtil_GetRingBufferWriteAvailable( PaUtilRingBuffer *rbuf );
|
||||
|
||||
@return The number of bytes available for reading.
|
||||
*/
|
||||
long PaUtil_GetRingBufferReadAvailable( PaUtilRingBuffer *rbuf );
|
||||
long PaUtil_GetRingBufferReadAvailable(PaUtilRingBuffer * rbuf);
|
||||
|
||||
/** Write data to the ring buffer.
|
||||
|
||||
@@ -110,7 +108,7 @@ long PaUtil_GetRingBufferReadAvailable( PaUtilRingBuffer *rbuf );
|
||||
|
||||
@return The number of bytes written.
|
||||
*/
|
||||
long PaUtil_WriteRingBuffer( PaUtilRingBuffer *rbuf, const void *data, long numBytes );
|
||||
long PaUtil_WriteRingBuffer(PaUtilRingBuffer * rbuf, const void *data, long numBytes);
|
||||
|
||||
/** Read data from the ring buffer.
|
||||
|
||||
@@ -122,7 +120,7 @@ long PaUtil_WriteRingBuffer( PaUtilRingBuffer *rbuf, const void *data, long numB
|
||||
|
||||
@return The number of bytes read.
|
||||
*/
|
||||
long PaUtil_ReadRingBuffer( PaUtilRingBuffer *rbuf, void *data, long numBytes );
|
||||
long PaUtil_ReadRingBuffer(PaUtilRingBuffer * rbuf, void *data, long numBytes);
|
||||
|
||||
/** Get address of region(s) to which we can write data.
|
||||
|
||||
@@ -144,9 +142,8 @@ long PaUtil_ReadRingBuffer( PaUtilRingBuffer *rbuf, void *data, long numBytes );
|
||||
|
||||
@return The room available to be written or numBytes, whichever is smaller.
|
||||
*/
|
||||
long PaUtil_GetRingBufferWriteRegions( PaUtilRingBuffer *rbuf, long numBytes,
|
||||
void **dataPtr1, long *sizePtr1,
|
||||
void **dataPtr2, long *sizePtr2 );
|
||||
long PaUtil_GetRingBufferWriteRegions(PaUtilRingBuffer * rbuf, long numBytes,
|
||||
void **dataPtr1, long *sizePtr1, void **dataPtr2, long *sizePtr2);
|
||||
|
||||
/** Advance the write index to the next location to be written.
|
||||
|
||||
@@ -156,7 +153,7 @@ long PaUtil_GetRingBufferWriteRegions( PaUtilRingBuffer *rbuf, long numBytes,
|
||||
|
||||
@return The new position.
|
||||
*/
|
||||
long PaUtil_AdvanceRingBufferWriteIndex( PaUtilRingBuffer *rbuf, long numBytes );
|
||||
long PaUtil_AdvanceRingBufferWriteIndex(PaUtilRingBuffer * rbuf, long numBytes);
|
||||
|
||||
/** Get address of region(s) from which we can write data.
|
||||
|
||||
@@ -178,9 +175,8 @@ long PaUtil_AdvanceRingBufferWriteIndex( PaUtilRingBuffer *rbuf, long numBytes )
|
||||
|
||||
@return The number of bytes available for reading.
|
||||
*/
|
||||
long PaUtil_GetRingBufferReadRegions( PaUtilRingBuffer *rbuf, long numBytes,
|
||||
void **dataPtr1, long *sizePtr1,
|
||||
void **dataPtr2, long *sizePtr2 );
|
||||
long PaUtil_GetRingBufferReadRegions(PaUtilRingBuffer * rbuf, long numBytes,
|
||||
void **dataPtr1, long *sizePtr1, void **dataPtr2, long *sizePtr2);
|
||||
|
||||
/** Advance the read index to the next location to be read.
|
||||
|
||||
@@ -190,9 +186,9 @@ long PaUtil_GetRingBufferReadRegions( PaUtilRingBuffer *rbuf, long numBytes,
|
||||
|
||||
@return The new position.
|
||||
*/
|
||||
long PaUtil_AdvanceRingBufferReadIndex( PaUtilRingBuffer *rbuf, long numBytes );
|
||||
long PaUtil_AdvanceRingBufferReadIndex(PaUtilRingBuffer * rbuf, long numBytes);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* PA_RINGBUFFER_H */
|
||||
#endif /* __cplusplus */
|
||||
#endif /* PA_RINGBUFFER_H */
|
||||
|
||||
@@ -59,13 +59,12 @@
|
||||
/******** Prototypes ****************************************************/
|
||||
/************************************************************************/
|
||||
|
||||
static int blockingIOCallback( const void *inputBuffer, void *outputBuffer,
|
||||
unsigned long framesPerBuffer,
|
||||
const PaStreamCallbackTimeInfo* timeInfo,
|
||||
PaStreamCallbackFlags statusFlags,
|
||||
void *userData );
|
||||
static PaError PABLIO_InitFIFO( PaUtilRingBuffer *rbuf, long numFrames, long bytesPerFrame );
|
||||
static PaError PABLIO_TermFIFO( PaUtilRingBuffer *rbuf );
|
||||
static int blockingIOCallback(const void *inputBuffer, void *outputBuffer,
|
||||
unsigned long framesPerBuffer,
|
||||
const PaStreamCallbackTimeInfo * timeInfo,
|
||||
PaStreamCallbackFlags statusFlags, void *userData);
|
||||
static PaError PABLIO_InitFIFO(PaUtilRingBuffer * rbuf, long numFrames, long bytesPerFrame);
|
||||
static PaError PABLIO_TermFIFO(PaUtilRingBuffer * rbuf);
|
||||
|
||||
/************************************************************************/
|
||||
/******** Functions *****************************************************/
|
||||
@@ -74,122 +73,120 @@ static PaError PABLIO_TermFIFO( PaUtilRingBuffer *rbuf );
|
||||
/* Called from PortAudio.
|
||||
* Read and write data only if there is room in FIFOs.
|
||||
*/
|
||||
static int blockingIOCallback( const void *inputBuffer, void *outputBuffer,
|
||||
unsigned long framesPerBuffer,
|
||||
const PaStreamCallbackTimeInfo* timeInfo,
|
||||
PaStreamCallbackFlags statusFlags,
|
||||
void *userData )
|
||||
static int blockingIOCallback(const void *inputBuffer, void *outputBuffer,
|
||||
unsigned long framesPerBuffer,
|
||||
const PaStreamCallbackTimeInfo * timeInfo,
|
||||
PaStreamCallbackFlags statusFlags, void *userData)
|
||||
{
|
||||
PABLIO_Stream *data = (PABLIO_Stream*)userData;
|
||||
long numBytes = data->bytesPerFrame * framesPerBuffer;
|
||||
PABLIO_Stream *data = (PABLIO_Stream *) userData;
|
||||
long numBytes = data->bytesPerFrame * framesPerBuffer;
|
||||
|
||||
/* This may get called with NULL inputBuffer during initial setup. */
|
||||
if( inputBuffer != NULL )
|
||||
{
|
||||
PaUtil_WriteRingBuffer( &data->inFIFO, inputBuffer, numBytes );
|
||||
}
|
||||
if( outputBuffer != NULL )
|
||||
{
|
||||
int i;
|
||||
int numRead = PaUtil_ReadRingBuffer( &data->outFIFO, outputBuffer, numBytes );
|
||||
/* Zero out remainder of buffer if we run out of data. */
|
||||
for( i=numRead; i<numBytes; i++ )
|
||||
{
|
||||
((char *)outputBuffer)[i] = 0;
|
||||
}
|
||||
}
|
||||
/* This may get called with NULL inputBuffer during initial setup. */
|
||||
if (inputBuffer != NULL) {
|
||||
PaUtil_WriteRingBuffer(&data->inFIFO, inputBuffer, numBytes);
|
||||
}
|
||||
if (outputBuffer != NULL) {
|
||||
int i;
|
||||
int numRead = PaUtil_ReadRingBuffer(&data->outFIFO, outputBuffer, numBytes);
|
||||
/* Zero out remainder of buffer if we run out of data. */
|
||||
for (i = numRead; i < numBytes; i++) {
|
||||
((char *) outputBuffer)[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Allocate buffer. */
|
||||
static PaError PABLIO_InitFIFO( PaUtilRingBuffer *rbuf, long numFrames, long bytesPerFrame )
|
||||
static PaError PABLIO_InitFIFO(PaUtilRingBuffer * rbuf, long numFrames, long bytesPerFrame)
|
||||
{
|
||||
long numBytes = numFrames * bytesPerFrame;
|
||||
char *buffer = (char *) malloc( numBytes );
|
||||
if( buffer == NULL ) return paInsufficientMemory;
|
||||
memset( buffer, 0, numBytes );
|
||||
return (PaError) PaUtil_InitializeRingBuffer( rbuf, numBytes, buffer );
|
||||
long numBytes = numFrames * bytesPerFrame;
|
||||
char *buffer = (char *) malloc(numBytes);
|
||||
if (buffer == NULL)
|
||||
return paInsufficientMemory;
|
||||
memset(buffer, 0, numBytes);
|
||||
return (PaError) PaUtil_InitializeRingBuffer(rbuf, numBytes, buffer);
|
||||
}
|
||||
|
||||
/* Free buffer. */
|
||||
static PaError PABLIO_TermFIFO( PaUtilRingBuffer *rbuf )
|
||||
static PaError PABLIO_TermFIFO(PaUtilRingBuffer * rbuf)
|
||||
{
|
||||
if( rbuf->buffer ) free( rbuf->buffer );
|
||||
rbuf->buffer = NULL;
|
||||
return paNoError;
|
||||
if (rbuf->buffer)
|
||||
free(rbuf->buffer);
|
||||
rbuf->buffer = NULL;
|
||||
return paNoError;
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
* Write data to ring buffer.
|
||||
* Will not return until all the data has been written.
|
||||
*/
|
||||
long WriteAudioStream( PABLIO_Stream *aStream, void *data, long numFrames )
|
||||
long WriteAudioStream(PABLIO_Stream * aStream, void *data, long numFrames)
|
||||
{
|
||||
long bytesWritten;
|
||||
char *p = (char *) data;
|
||||
long numBytes = aStream->bytesPerFrame * numFrames;
|
||||
while( numBytes > 0)
|
||||
{
|
||||
bytesWritten = PaUtil_WriteRingBuffer( &aStream->outFIFO, p, numBytes );
|
||||
numBytes -= bytesWritten;
|
||||
p += bytesWritten;
|
||||
if( numBytes > 0) Pa_Sleep(10);
|
||||
}
|
||||
return numFrames;
|
||||
long bytesWritten;
|
||||
char *p = (char *) data;
|
||||
long numBytes = aStream->bytesPerFrame * numFrames;
|
||||
while (numBytes > 0) {
|
||||
bytesWritten = PaUtil_WriteRingBuffer(&aStream->outFIFO, p, numBytes);
|
||||
numBytes -= bytesWritten;
|
||||
p += bytesWritten;
|
||||
if (numBytes > 0)
|
||||
Pa_Sleep(10);
|
||||
}
|
||||
return numFrames;
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
* Read data from ring buffer.
|
||||
* Will not return until all the data has been read.
|
||||
*/
|
||||
long ReadAudioStream( PABLIO_Stream *aStream, void *data, long numFrames )
|
||||
long ReadAudioStream(PABLIO_Stream * aStream, void *data, long numFrames)
|
||||
{
|
||||
long bytesRead;
|
||||
char *p = (char *) data;
|
||||
long numBytes = aStream->bytesPerFrame * numFrames;
|
||||
long bytesRead;
|
||||
char *p = (char *) data;
|
||||
long numBytes = aStream->bytesPerFrame * numFrames;
|
||||
|
||||
while( numBytes > 0)
|
||||
{
|
||||
bytesRead = PaUtil_ReadRingBuffer( &aStream->inFIFO, p, numBytes );
|
||||
numBytes -= bytesRead;
|
||||
p += bytesRead;
|
||||
if( numBytes > 0) Pa_Sleep(10);
|
||||
}
|
||||
return numFrames;
|
||||
while (numBytes > 0) {
|
||||
bytesRead = PaUtil_ReadRingBuffer(&aStream->inFIFO, p, numBytes);
|
||||
numBytes -= bytesRead;
|
||||
p += bytesRead;
|
||||
if (numBytes > 0)
|
||||
Pa_Sleep(10);
|
||||
}
|
||||
return numFrames;
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
* Return the number of frames that could be written to the stream without
|
||||
* having to wait.
|
||||
*/
|
||||
long GetAudioStreamWriteable( PABLIO_Stream *aStream )
|
||||
long GetAudioStreamWriteable(PABLIO_Stream * aStream)
|
||||
{
|
||||
int bytesEmpty = PaUtil_GetRingBufferWriteAvailable( &aStream->outFIFO );
|
||||
return bytesEmpty / aStream->bytesPerFrame;
|
||||
int bytesEmpty = PaUtil_GetRingBufferWriteAvailable(&aStream->outFIFO);
|
||||
return bytesEmpty / aStream->bytesPerFrame;
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
* Return the number of frames that are available to be read from the
|
||||
* stream without having to wait.
|
||||
*/
|
||||
long GetAudioStreamReadable( PABLIO_Stream *aStream )
|
||||
long GetAudioStreamReadable(PABLIO_Stream * aStream)
|
||||
{
|
||||
int bytesFull = PaUtil_GetRingBufferReadAvailable( &aStream->inFIFO );
|
||||
return bytesFull / aStream->bytesPerFrame;
|
||||
int bytesFull = PaUtil_GetRingBufferReadAvailable(&aStream->inFIFO);
|
||||
return bytesFull / aStream->bytesPerFrame;
|
||||
}
|
||||
|
||||
/************************************************************/
|
||||
static unsigned long RoundUpToNextPowerOf2( unsigned long n )
|
||||
static unsigned long RoundUpToNextPowerOf2(unsigned long n)
|
||||
{
|
||||
long numBits = 0;
|
||||
if( ((n-1) & n) == 0) return n; /* Already Power of two. */
|
||||
while( n > 0 )
|
||||
{
|
||||
n= n>>1;
|
||||
numBits++;
|
||||
}
|
||||
return (1<<numBits);
|
||||
long numBits = 0;
|
||||
if (((n - 1) & n) == 0)
|
||||
return n; /* Already Power of two. */
|
||||
while (n > 0) {
|
||||
n = n >> 1;
|
||||
numBits++;
|
||||
}
|
||||
return (1 << numBits);
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
@@ -197,27 +194,27 @@ static unsigned long RoundUpToNextPowerOf2( unsigned long n )
|
||||
* Allocates PABLIO_Stream structure.
|
||||
*
|
||||
*/
|
||||
PaError OpenAudioStream( PABLIO_Stream **rwblPtr,
|
||||
const PaStreamParameters *inputParameters,
|
||||
const PaStreamParameters *outputParameters,
|
||||
double sampleRate,
|
||||
PaStreamFlags streamFlags)
|
||||
PaError OpenAudioStream(PABLIO_Stream ** rwblPtr,
|
||||
const PaStreamParameters * inputParameters,
|
||||
const PaStreamParameters * outputParameters, double sampleRate, PaStreamFlags streamFlags)
|
||||
{
|
||||
long bytesPerSample;
|
||||
PaError err;
|
||||
PABLIO_Stream *aStream;
|
||||
long numFrames;
|
||||
long bytesPerSample;
|
||||
PaError err;
|
||||
PABLIO_Stream *aStream;
|
||||
long numFrames;
|
||||
long numBytes;
|
||||
int channels = 1;
|
||||
|
||||
/* Allocate PABLIO_Stream structure for caller. */
|
||||
aStream = (PABLIO_Stream *) malloc( sizeof(PABLIO_Stream) );
|
||||
if( aStream == NULL ) return paInsufficientMemory;
|
||||
memset( aStream, 0, sizeof(PABLIO_Stream) );
|
||||
/* Allocate PABLIO_Stream structure for caller. */
|
||||
aStream = (PABLIO_Stream *) malloc(sizeof(PABLIO_Stream));
|
||||
if (aStream == NULL)
|
||||
return paInsufficientMemory;
|
||||
memset(aStream, 0, sizeof(PABLIO_Stream));
|
||||
|
||||
/* Initialize PortAudio */
|
||||
err = Pa_Initialize();
|
||||
if( err != paNoError ) goto error;
|
||||
/* Initialize PortAudio */
|
||||
err = Pa_Initialize();
|
||||
if (err != paNoError)
|
||||
goto error;
|
||||
|
||||
if (inputParameters) {
|
||||
channels = inputParameters->channelCount;
|
||||
@@ -225,81 +222,79 @@ PaError OpenAudioStream( PABLIO_Stream **rwblPtr,
|
||||
channels = outputParameters->channelCount;
|
||||
}
|
||||
|
||||
numFrames = 4 * FRAMES_PER_BUFFER;
|
||||
numFrames = RoundUpToNextPowerOf2( numFrames );
|
||||
numFrames = 4 * FRAMES_PER_BUFFER;
|
||||
numFrames = RoundUpToNextPowerOf2(numFrames);
|
||||
|
||||
bytesPerSample = 2;
|
||||
aStream->samplesPerFrame = channels;
|
||||
aStream->bytesPerFrame = bytesPerSample * aStream->samplesPerFrame;
|
||||
aStream->bytesPerFrame = bytesPerSample * aStream->samplesPerFrame;
|
||||
|
||||
/* Initialize Ring Buffers */
|
||||
/* Initialize Ring Buffers */
|
||||
|
||||
if (inputParameters) {
|
||||
err = PABLIO_InitFIFO( &aStream->inFIFO, numFrames, aStream->bytesPerFrame );
|
||||
if( err != paNoError ) goto error;
|
||||
err = PABLIO_InitFIFO(&aStream->inFIFO, numFrames, aStream->bytesPerFrame);
|
||||
if (err != paNoError)
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (outputParameters) {
|
||||
err = PABLIO_InitFIFO( &aStream->outFIFO, numFrames, aStream->bytesPerFrame );
|
||||
if( err != paNoError ) goto error;
|
||||
err = PABLIO_InitFIFO(&aStream->outFIFO, numFrames, aStream->bytesPerFrame);
|
||||
if (err != paNoError)
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Make Write FIFO appear full initially. */
|
||||
numBytes = PaUtil_GetRingBufferWriteAvailable( &aStream->outFIFO );
|
||||
PaUtil_AdvanceRingBufferWriteIndex( &aStream->outFIFO, numBytes );
|
||||
|
||||
numBytes = PaUtil_GetRingBufferWriteAvailable(&aStream->outFIFO);
|
||||
PaUtil_AdvanceRingBufferWriteIndex(&aStream->outFIFO, numBytes);
|
||||
|
||||
/* Open a PortAudio stream that we will use to communicate with the underlying
|
||||
* audio drivers. */
|
||||
err = Pa_OpenStream(
|
||||
&aStream->stream,
|
||||
inputParameters,
|
||||
outputParameters,
|
||||
sampleRate,
|
||||
FRAMES_PER_BUFFER,
|
||||
streamFlags,
|
||||
blockingIOCallback,
|
||||
aStream );
|
||||
if( err != paNoError ) goto error;
|
||||
|
||||
err = Pa_StartStream( aStream->stream );
|
||||
if( err != paNoError ) goto error;
|
||||
*rwblPtr = aStream;
|
||||
return paNoError;
|
||||
/* Open a PortAudio stream that we will use to communicate with the underlying
|
||||
* audio drivers. */
|
||||
err = Pa_OpenStream(&aStream->stream,
|
||||
inputParameters,
|
||||
outputParameters, sampleRate, FRAMES_PER_BUFFER, streamFlags, blockingIOCallback, aStream);
|
||||
if (err != paNoError)
|
||||
goto error;
|
||||
|
||||
error:
|
||||
CloseAudioStream( aStream );
|
||||
*rwblPtr = NULL;
|
||||
return err;
|
||||
err = Pa_StartStream(aStream->stream);
|
||||
if (err != paNoError)
|
||||
goto error;
|
||||
*rwblPtr = aStream;
|
||||
return paNoError;
|
||||
|
||||
error:
|
||||
CloseAudioStream(aStream);
|
||||
*rwblPtr = NULL;
|
||||
return err;
|
||||
}
|
||||
|
||||
/************************************************************/
|
||||
PaError CloseAudioStream( PABLIO_Stream *aStream )
|
||||
PaError CloseAudioStream(PABLIO_Stream * aStream)
|
||||
{
|
||||
PaError err;
|
||||
int bytesEmpty;
|
||||
int byteSize = aStream->outFIFO.bufferSize;
|
||||
PaError err;
|
||||
int bytesEmpty;
|
||||
int byteSize = aStream->outFIFO.bufferSize;
|
||||
|
||||
/* If we are writing data, make sure we play everything written. */
|
||||
if( byteSize > 0 )
|
||||
{
|
||||
bytesEmpty = PaUtil_GetRingBufferWriteAvailable( &aStream->outFIFO );
|
||||
while( bytesEmpty < byteSize )
|
||||
{
|
||||
Pa_Sleep( 10 );
|
||||
bytesEmpty = PaUtil_GetRingBufferWriteAvailable( &aStream->outFIFO );
|
||||
}
|
||||
}
|
||||
/* If we are writing data, make sure we play everything written. */
|
||||
if (byteSize > 0) {
|
||||
bytesEmpty = PaUtil_GetRingBufferWriteAvailable(&aStream->outFIFO);
|
||||
while (bytesEmpty < byteSize) {
|
||||
Pa_Sleep(10);
|
||||
bytesEmpty = PaUtil_GetRingBufferWriteAvailable(&aStream->outFIFO);
|
||||
}
|
||||
}
|
||||
|
||||
err = Pa_StopStream( aStream->stream );
|
||||
if( err != paNoError ) goto error;
|
||||
err = Pa_CloseStream( aStream->stream );
|
||||
if( err != paNoError ) goto error;
|
||||
Pa_Terminate();
|
||||
err = Pa_StopStream(aStream->stream);
|
||||
if (err != paNoError)
|
||||
goto error;
|
||||
err = Pa_CloseStream(aStream->stream);
|
||||
if (err != paNoError)
|
||||
goto error;
|
||||
Pa_Terminate();
|
||||
|
||||
error:
|
||||
PABLIO_TermFIFO( &aStream->inFIFO );
|
||||
PABLIO_TermFIFO( &aStream->outFIFO );
|
||||
free( aStream );
|
||||
return err;
|
||||
error:
|
||||
PABLIO_TermFIFO(&aStream->inFIFO);
|
||||
PABLIO_TermFIFO(&aStream->outFIFO);
|
||||
free(aStream);
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -2,9 +2,8 @@
|
||||
#define _PABLIO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* $Id: pablio.h 1083 2006-08-23 07:30:49Z rossb $
|
||||
@@ -57,15 +56,13 @@ extern "C"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PaUtilRingBuffer inFIFO;
|
||||
PaUtilRingBuffer outFIFO;
|
||||
PaStream *stream;
|
||||
int bytesPerFrame;
|
||||
int samplesPerFrame;
|
||||
}
|
||||
PABLIO_Stream;
|
||||
typedef struct {
|
||||
PaUtilRingBuffer inFIFO;
|
||||
PaUtilRingBuffer outFIFO;
|
||||
PaStream *stream;
|
||||
int bytesPerFrame;
|
||||
int samplesPerFrame;
|
||||
} PABLIO_Stream;
|
||||
|
||||
/* Values for flags for OpenAudioStream(). */
|
||||
#define PABLIO_READ (1<<0)
|
||||
@@ -78,25 +75,25 @@ PABLIO_Stream;
|
||||
* Write data to ring buffer.
|
||||
* Will not return until all the data has been written.
|
||||
*/
|
||||
long WriteAudioStream( PABLIO_Stream *aStream, void *data, long numFrames );
|
||||
long WriteAudioStream(PABLIO_Stream * aStream, void *data, long numFrames);
|
||||
|
||||
/************************************************************
|
||||
* Read data from ring buffer.
|
||||
* Will not return until all the data has been read.
|
||||
*/
|
||||
long ReadAudioStream( PABLIO_Stream *aStream, void *data, long numFrames );
|
||||
long ReadAudioStream(PABLIO_Stream * aStream, void *data, long numFrames);
|
||||
|
||||
/************************************************************
|
||||
* Return the number of frames that could be written to the stream without
|
||||
* having to wait.
|
||||
*/
|
||||
long GetAudioStreamWriteable( PABLIO_Stream *aStream );
|
||||
long GetAudioStreamWriteable(PABLIO_Stream * aStream);
|
||||
|
||||
/************************************************************
|
||||
* Return the number of frames that are available to be read from the
|
||||
* stream without having to wait.
|
||||
*/
|
||||
long GetAudioStreamReadable( PABLIO_Stream *aStream );
|
||||
long GetAudioStreamReadable(PABLIO_Stream * aStream);
|
||||
|
||||
/************************************************************
|
||||
* Opens a PortAudio stream with default characteristics.
|
||||
@@ -106,15 +103,14 @@ long GetAudioStreamReadable( PABLIO_Stream *aStream );
|
||||
* PABLIO_READ, PABLIO_WRITE, or PABLIO_READ_WRITE,
|
||||
* and either PABLIO_MONO or PABLIO_STEREO
|
||||
*/
|
||||
PaError OpenAudioStream( PABLIO_Stream **rwblPtr,
|
||||
const PaStreamParameters *inputParameters,
|
||||
const PaStreamParameters *outputParameters,
|
||||
double sampleRate,
|
||||
PaStreamCallbackFlags statusFlags);
|
||||
PaError OpenAudioStream(PABLIO_Stream ** rwblPtr,
|
||||
const PaStreamParameters * inputParameters,
|
||||
const PaStreamParameters * outputParameters,
|
||||
double sampleRate, PaStreamCallbackFlags statusFlags);
|
||||
|
||||
PaError CloseAudioStream( PABLIO_Stream *aStream );
|
||||
PaError CloseAudioStream(PABLIO_Stream * aStream);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* _PABLIO_H */
|
||||
#endif /* __cplusplus */
|
||||
#endif /* _PABLIO_H */
|
||||
|
||||
+1555
-1666
File diff suppressed because it is too large
Load Diff
@@ -50,137 +50,110 @@ extern "C" {
|
||||
#ifndef __inline__
|
||||
#define __inline__ __inline
|
||||
#endif
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef __int16 int16_t;
|
||||
typedef __int32 int32_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef __int16 int16_t;
|
||||
typedef __int32 int32_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
#endif
|
||||
|
||||
#if defined(__i386__)
|
||||
/*! \brief Find the bit position of the highest set bit in a word
|
||||
\param bits The word to be searched
|
||||
\return The bit number of the highest set bit, or -1 if the word is zero. */
|
||||
static __inline__ int top_bit(unsigned int bits)
|
||||
{
|
||||
int res;
|
||||
static __inline__ int top_bit(unsigned int bits) {
|
||||
int res;
|
||||
|
||||
__asm__ __volatile__(" movl $-1,%%edx;\n"
|
||||
" bsrl %%eax,%%edx;\n"
|
||||
: "=d" (res)
|
||||
: "a" (bits));
|
||||
return res;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
__asm__ __volatile__(" movl $-1,%%edx;\n" " bsrl %%eax,%%edx;\n":"=d"(res)
|
||||
:"a" (bits));
|
||||
return res;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*//*! \brief Find the bit position of the lowest set bit in a word
|
||||
\param bits The word to be searched
|
||||
\return The bit number of the lowest set bit, or -1 if the word is zero. */
|
||||
static __inline__ int bottom_bit(unsigned int bits) {
|
||||
int res;
|
||||
|
||||
/*! \brief Find the bit position of the lowest set bit in a word
|
||||
\param bits The word to be searched
|
||||
\return The bit number of the lowest set bit, or -1 if the word is zero. */
|
||||
static __inline__ int bottom_bit(unsigned int bits)
|
||||
{
|
||||
int res;
|
||||
|
||||
__asm__ __volatile__(" movl $-1,%%edx;\n"
|
||||
" bsfl %%eax,%%edx;\n"
|
||||
: "=d" (res)
|
||||
: "a" (bits));
|
||||
return res;
|
||||
}
|
||||
__asm__ __volatile__(" movl $-1,%%edx;\n" " bsfl %%eax,%%edx;\n":"=d"(res)
|
||||
:"a" (bits));
|
||||
return res;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
#elif defined(__x86_64__)
|
||||
static __inline__ int top_bit(unsigned int bits)
|
||||
{
|
||||
int res;
|
||||
static __inline__ int top_bit(unsigned int bits) {
|
||||
int res;
|
||||
|
||||
__asm__ __volatile__(" movq $-1,%%rdx;\n"
|
||||
" bsrq %%rax,%%rdx;\n"
|
||||
: "=d" (res)
|
||||
: "a" (bits));
|
||||
return res;
|
||||
}
|
||||
__asm__ __volatile__(" movq $-1,%%rdx;\n" " bsrq %%rax,%%rdx;\n":"=d"(res)
|
||||
:"a" (bits));
|
||||
return res;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
static __inline__ int bottom_bit(unsigned int bits) {
|
||||
int res;
|
||||
|
||||
static __inline__ int bottom_bit(unsigned int bits)
|
||||
{
|
||||
int res;
|
||||
|
||||
__asm__ __volatile__(" movq $-1,%%rdx;\n"
|
||||
" bsfq %%rax,%%rdx;\n"
|
||||
: "=d" (res)
|
||||
: "a" (bits));
|
||||
return res;
|
||||
}
|
||||
__asm__ __volatile__(" movq $-1,%%rdx;\n" " bsfq %%rax,%%rdx;\n":"=d"(res)
|
||||
:"a" (bits));
|
||||
return res;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
#else
|
||||
static __inline__ int top_bit(unsigned int bits)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (bits == 0)
|
||||
return -1;
|
||||
i = 0;
|
||||
if (bits & 0xFFFF0000)
|
||||
{
|
||||
bits &= 0xFFFF0000;
|
||||
i += 16;
|
||||
}
|
||||
if (bits & 0xFF00FF00)
|
||||
{
|
||||
bits &= 0xFF00FF00;
|
||||
i += 8;
|
||||
}
|
||||
if (bits & 0xF0F0F0F0)
|
||||
{
|
||||
bits &= 0xF0F0F0F0;
|
||||
i += 4;
|
||||
}
|
||||
if (bits & 0xCCCCCCCC)
|
||||
{
|
||||
bits &= 0xCCCCCCCC;
|
||||
i += 2;
|
||||
}
|
||||
if (bits & 0xAAAAAAAA)
|
||||
{
|
||||
bits &= 0xAAAAAAAA;
|
||||
i += 1;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
static __inline__ int top_bit(unsigned int bits) {
|
||||
int i;
|
||||
|
||||
if (bits == 0)
|
||||
return -1;
|
||||
i = 0;
|
||||
if (bits & 0xFFFF0000) {
|
||||
bits &= 0xFFFF0000;
|
||||
i += 16;
|
||||
}
|
||||
if (bits & 0xFF00FF00) {
|
||||
bits &= 0xFF00FF00;
|
||||
i += 8;
|
||||
}
|
||||
if (bits & 0xF0F0F0F0) {
|
||||
bits &= 0xF0F0F0F0;
|
||||
i += 4;
|
||||
}
|
||||
if (bits & 0xCCCCCCCC) {
|
||||
bits &= 0xCCCCCCCC;
|
||||
i += 2;
|
||||
}
|
||||
if (bits & 0xAAAAAAAA) {
|
||||
bits &= 0xAAAAAAAA;
|
||||
i += 1;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
static __inline__ int bottom_bit(unsigned int bits)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (bits == 0)
|
||||
return -1;
|
||||
i = 32;
|
||||
if (bits & 0x0000FFFF)
|
||||
{
|
||||
bits &= 0x0000FFFF;
|
||||
i -= 16;
|
||||
}
|
||||
if (bits & 0x00FF00FF)
|
||||
{
|
||||
bits &= 0x00FF00FF;
|
||||
i -= 8;
|
||||
}
|
||||
if (bits & 0x0F0F0F0F)
|
||||
{
|
||||
bits &= 0x0F0F0F0F;
|
||||
i -= 4;
|
||||
}
|
||||
if (bits & 0x33333333)
|
||||
{
|
||||
bits &= 0x33333333;
|
||||
i -= 2;
|
||||
}
|
||||
if (bits & 0x55555555)
|
||||
{
|
||||
bits &= 0x55555555;
|
||||
i -= 1;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
static __inline__ int bottom_bit(unsigned int bits) {
|
||||
int i;
|
||||
|
||||
if (bits == 0)
|
||||
return -1;
|
||||
i = 32;
|
||||
if (bits & 0x0000FFFF) {
|
||||
bits &= 0x0000FFFF;
|
||||
i -= 16;
|
||||
}
|
||||
if (bits & 0x00FF00FF) {
|
||||
bits &= 0x00FF00FF;
|
||||
i -= 8;
|
||||
}
|
||||
if (bits & 0x0F0F0F0F) {
|
||||
bits &= 0x0F0F0F0F;
|
||||
i -= 4;
|
||||
}
|
||||
if (bits & 0x33333333) {
|
||||
bits &= 0x33333333;
|
||||
i -= 2;
|
||||
}
|
||||
if (bits & 0x55555555) {
|
||||
bits &= 0x55555555;
|
||||
i -= 1;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
#endif
|
||||
|
||||
@@ -194,7 +167,7 @@ static __inline__ int bottom_bit(unsigned int bits)
|
||||
* segment, but a little inline assembly can fix that on an i386, x86_64 and
|
||||
* many other modern processors.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Mu-law is basically as follows:
|
||||
*
|
||||
@@ -222,66 +195,61 @@ static __inline__ int bottom_bit(unsigned int bits)
|
||||
*/
|
||||
|
||||
//#define ULAW_ZEROTRAP /* turn on the trap as per the MIL-STD */
|
||||
#define ULAW_BIAS 0x84 /* Bias for linear code. */
|
||||
#define ULAW_BIAS 0x84 /* Bias for linear code. */
|
||||
|
||||
/*! \brief Encode a linear sample to u-law
|
||||
\param linear The sample to encode.
|
||||
\return The u-law value.
|
||||
*/
|
||||
static __inline__ uint8_t linear_to_ulaw(int linear)
|
||||
{
|
||||
uint8_t u_val;
|
||||
int mask;
|
||||
int seg;
|
||||
static __inline__ uint8_t linear_to_ulaw(int linear) {
|
||||
uint8_t u_val;
|
||||
int mask;
|
||||
int seg;
|
||||
|
||||
/* Get the sign and the magnitude of the value. */
|
||||
if (linear < 0)
|
||||
{
|
||||
linear = ULAW_BIAS - linear;
|
||||
mask = 0x7F;
|
||||
}
|
||||
else
|
||||
{
|
||||
linear = ULAW_BIAS + linear;
|
||||
mask = 0xFF;
|
||||
}
|
||||
/* Get the sign and the magnitude of the value. */
|
||||
if (linear < 0) {
|
||||
linear = ULAW_BIAS - linear;
|
||||
mask = 0x7F;
|
||||
} else {
|
||||
linear = ULAW_BIAS + linear;
|
||||
mask = 0xFF;
|
||||
}
|
||||
|
||||
seg = top_bit(linear | 0xFF) - 7;
|
||||
seg = top_bit(linear | 0xFF) - 7;
|
||||
|
||||
/*
|
||||
* Combine the sign, segment, quantization bits,
|
||||
* and complement the code word.
|
||||
*/
|
||||
if (seg >= 8)
|
||||
u_val = (uint8_t) (0x7F ^ mask);
|
||||
else
|
||||
u_val = (uint8_t) (((seg << 4) | ((linear >> (seg + 3)) & 0xF)) ^ mask);
|
||||
/*
|
||||
* Combine the sign, segment, quantization bits,
|
||||
* and complement the code word.
|
||||
*/
|
||||
if (seg >= 8)
|
||||
u_val = (uint8_t) (0x7F ^ mask);
|
||||
else
|
||||
u_val = (uint8_t) (((seg << 4) | ((linear >> (seg + 3)) & 0xF)) ^ mask);
|
||||
#ifdef ULAW_ZEROTRAP
|
||||
/* Optional ITU trap */
|
||||
if (u_val == 0)
|
||||
u_val = 0x02;
|
||||
/* Optional ITU trap */
|
||||
if (u_val == 0)
|
||||
u_val = 0x02;
|
||||
#endif
|
||||
return u_val;
|
||||
}
|
||||
return u_val;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
/*! \brief Decode an u-law sample to a linear value.
|
||||
\param ulaw The u-law sample to decode.
|
||||
\return The linear value.
|
||||
*/
|
||||
static __inline__ int16_t ulaw_to_linear(uint8_t ulaw)
|
||||
{
|
||||
int t;
|
||||
|
||||
/* Complement to obtain normal u-law value. */
|
||||
ulaw = ~ulaw;
|
||||
/*
|
||||
* Extract and bias the quantization bits. Then
|
||||
* shift up by the segment number and subtract out the bias.
|
||||
*/
|
||||
t = (((ulaw & 0x0F) << 3) + ULAW_BIAS) << (((int) ulaw & 0x70) >> 4);
|
||||
return (int16_t) ((ulaw & 0x80) ? (ULAW_BIAS - t) : (t - ULAW_BIAS));
|
||||
}
|
||||
static __inline__ int16_t ulaw_to_linear(uint8_t ulaw) {
|
||||
int t;
|
||||
|
||||
/* Complement to obtain normal u-law value. */
|
||||
ulaw = ~ulaw;
|
||||
/*
|
||||
* Extract and bias the quantization bits. Then
|
||||
* shift up by the segment number and subtract out the bias.
|
||||
*/
|
||||
t = (((ulaw & 0x0F) << 3) + ULAW_BIAS) << (((int) ulaw & 0x70) >> 4);
|
||||
return (int16_t) ((ulaw & 0x80) ? (ULAW_BIAS - t) : (t - ULAW_BIAS));
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
@@ -308,71 +276,64 @@ static __inline__ int16_t ulaw_to_linear(uint8_t ulaw)
|
||||
\param linear The sample to encode.
|
||||
\return The A-law value.
|
||||
*/
|
||||
static __inline__ uint8_t linear_to_alaw(int linear)
|
||||
{
|
||||
int mask;
|
||||
int seg;
|
||||
|
||||
if (linear >= 0)
|
||||
{
|
||||
/* Sign (bit 7) bit = 1 */
|
||||
mask = ALAW_AMI_MASK | 0x80;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Sign (bit 7) bit = 0 */
|
||||
mask = ALAW_AMI_MASK;
|
||||
linear = -linear - 8;
|
||||
}
|
||||
static __inline__ uint8_t linear_to_alaw(int linear) {
|
||||
int mask;
|
||||
int seg;
|
||||
|
||||
/* Convert the scaled magnitude to segment number. */
|
||||
seg = top_bit(linear | 0xFF) - 7;
|
||||
if (seg >= 8)
|
||||
{
|
||||
if (linear >= 0)
|
||||
{
|
||||
/* Out of range. Return maximum value. */
|
||||
return (uint8_t) (0x7F ^ mask);
|
||||
}
|
||||
/* We must be just a tiny step below zero */
|
||||
return (uint8_t) (0x00 ^ mask);
|
||||
}
|
||||
/* Combine the sign, segment, and quantization bits. */
|
||||
return (uint8_t) (((seg << 4) | ((linear >> ((seg) ? (seg + 3) : 4)) & 0x0F)) ^ mask);
|
||||
}
|
||||
if (linear >= 0) {
|
||||
/* Sign (bit 7) bit = 1 */
|
||||
mask = ALAW_AMI_MASK | 0x80;
|
||||
} else {
|
||||
/* Sign (bit 7) bit = 0 */
|
||||
mask = ALAW_AMI_MASK;
|
||||
linear = -linear - 8;
|
||||
}
|
||||
|
||||
/* Convert the scaled magnitude to segment number. */
|
||||
seg = top_bit(linear | 0xFF) - 7;
|
||||
if (seg >= 8) {
|
||||
if (linear >= 0) {
|
||||
/* Out of range. Return maximum value. */
|
||||
return (uint8_t) (0x7F ^ mask);
|
||||
}
|
||||
/* We must be just a tiny step below zero */
|
||||
return (uint8_t) (0x00 ^ mask);
|
||||
}
|
||||
/* Combine the sign, segment, and quantization bits. */
|
||||
return (uint8_t) (((seg << 4) | ((linear >> ((seg) ? (seg + 3) : 4)) & 0x0F)) ^ mask);
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
/*! \brief Decode an A-law sample to a linear value.
|
||||
\param alaw The A-law sample to decode.
|
||||
\return The linear value.
|
||||
*/
|
||||
static __inline__ int16_t alaw_to_linear(uint8_t alaw)
|
||||
{
|
||||
int i;
|
||||
int seg;
|
||||
static __inline__ int16_t alaw_to_linear(uint8_t alaw) {
|
||||
int i;
|
||||
int seg;
|
||||
|
||||
alaw ^= ALAW_AMI_MASK;
|
||||
i = ((alaw & 0x0F) << 4);
|
||||
seg = (((int) alaw & 0x70) >> 4);
|
||||
if (seg)
|
||||
i = (i + 0x108) << (seg - 1);
|
||||
else
|
||||
i += 8;
|
||||
return (int16_t) ((alaw & 0x80) ? i : -i);
|
||||
}
|
||||
alaw ^= ALAW_AMI_MASK;
|
||||
i = ((alaw & 0x0F) << 4);
|
||||
seg = (((int) alaw & 0x70) >> 4);
|
||||
if (seg)
|
||||
i = (i + 0x108) << (seg - 1);
|
||||
else
|
||||
i += 8;
|
||||
return (int16_t) ((alaw & 0x80) ? i : -i);
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
/*! \brief Transcode from A-law to u-law, using the procedure defined in G.711.
|
||||
\param alaw The A-law sample to transcode.
|
||||
\return The best matching u-law value.
|
||||
*/
|
||||
uint8_t alaw_to_ulaw(uint8_t alaw);
|
||||
uint8_t alaw_to_ulaw(uint8_t alaw);
|
||||
|
||||
/*! \brief Transcode from u-law to A-law, using the procedure defined in G.711.
|
||||
\param alaw The u-law sample to transcode.
|
||||
\return The best matching A-law value.
|
||||
*/
|
||||
uint8_t ulaw_to_alaw(uint8_t ulaw);
|
||||
uint8_t ulaw_to_alaw(uint8_t ulaw);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -34,7 +34,7 @@ typedef unsigned __int32 u_int32_t;
|
||||
#ifdef WANPIPE_TDM_API
|
||||
#include <wanpipe_tdm_api.h> //for TDMV API
|
||||
#endif
|
||||
#include <sang_status_defines.h>//return codes
|
||||
#include <sang_status_defines.h> //return codes
|
||||
#include <sang_api.h> //for IOCTL codes
|
||||
#include <sdla_te1_pmc.h> //RBS definitions
|
||||
#include <sdla_te1.h> //TE1 macros
|
||||
@@ -94,7 +94,7 @@ sng_fd_t sangoma_create_socket_by_name(char *device, char *card);
|
||||
/* Open Span/Chan devices
|
||||
* open_tdmapi_span_chan: open device based on span chan values
|
||||
* sangoma_open_tdmapi_span: open first available device on span
|
||||
*/
|
||||
*/
|
||||
|
||||
sng_fd_t sangoma_open_tdmapi_span_chan(int span, int chan);
|
||||
sng_fd_t sangoma_open_tdmapi_span(int span);
|
||||
@@ -104,67 +104,65 @@ sng_fd_t sangoma_open_tdmapi_span(int span);
|
||||
/* Device Rx/Tx functions
|
||||
* writemsg_tdm: tx header + data from separate buffers
|
||||
* readmsg_tdm: rx header + data to separate buffers
|
||||
*/
|
||||
int sangoma_writemsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen,
|
||||
void *databuf, unsigned short datalen, int flag);
|
||||
int sangoma_readmsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen,
|
||||
void *databuf, int datalen, int flag);
|
||||
*/
|
||||
int sangoma_writemsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen, void *databuf, unsigned short datalen, int flag);
|
||||
int sangoma_readmsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen, void *databuf, int datalen, int flag);
|
||||
|
||||
#define sangoma_readmsg_socket sangoma_readmsg_tdm
|
||||
#define sangoma_sendmsg_socket sangoma_writemsg_tdm
|
||||
|
||||
#ifdef WANPIPE_TDM_API
|
||||
|
||||
void sangoma_socket_close(sng_fd_t *sp);
|
||||
void sangoma_socket_close(sng_fd_t * sp);
|
||||
int sangoma_socket_waitfor(sng_fd_t fd, int timeout, int flags);
|
||||
|
||||
/* Get Full TDM API configuration per chan */
|
||||
int sangoma_get_full_cfg(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
int sangoma_get_full_cfg(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
|
||||
/* Get/Set TDM Codec per chan */
|
||||
int sangoma_tdm_set_codec(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, int codec);
|
||||
int sangoma_tdm_get_codec(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
int sangoma_tdm_set_codec(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api, int codec);
|
||||
int sangoma_tdm_get_codec(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
|
||||
/* Get/Set USR Tx/Rx Period in milliseconds */
|
||||
int sangoma_tdm_set_usr_period(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, int period);
|
||||
int sangoma_tdm_get_usr_period(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
int sangoma_tdm_set_usr_period(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api, int period);
|
||||
int sangoma_tdm_get_usr_period(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
|
||||
/* Get user MTU/MRU values in bytes */
|
||||
int sangoma_tdm_get_usr_mtu_mru(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
int sangoma_tdm_get_usr_mtu_mru(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
|
||||
/* Not supported yet */
|
||||
int sangoma_tdm_set_power_level(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, int power);
|
||||
int sangoma_tdm_get_power_level(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
int sangoma_tdm_set_power_level(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api, int power);
|
||||
int sangoma_tdm_get_power_level(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
|
||||
/* Flush buffers from current channel */
|
||||
int sangoma_tdm_flush_bufs(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
int sangoma_tdm_flush_bufs(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
|
||||
int sangoma_tdm_enable_rbs_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, int poll_in_sec);
|
||||
int sangoma_tdm_disable_rbs_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
int sangoma_tdm_enable_rbs_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api, int poll_in_sec);
|
||||
int sangoma_tdm_disable_rbs_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
|
||||
int sangoma_tdm_write_rbs(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, unsigned char rbs);
|
||||
int sangoma_tdm_write_rbs(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api, unsigned char rbs);
|
||||
|
||||
int sangoma_tdm_read_event(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
int sangoma_tdm_read_event(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
|
||||
/* DTMF Detection on Octasic chip */
|
||||
int sangoma_tdm_enable_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
int sangoma_tdm_disable_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
int sangoma_tdm_enable_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
int sangoma_tdm_disable_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
|
||||
/* DTMF Detection on A200 (SLIC) chip */
|
||||
int sangoma_tdm_enable_rm_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
int sangoma_tdm_disable_rm_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
int sangoma_tdm_enable_rm_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
int sangoma_tdm_disable_rm_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
|
||||
/* On/Off hook events on A200 (Analog) card */
|
||||
int sangoma_tdm_enable_rxhook_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
int sangoma_tdm_disable_rxhook_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
int sangoma_tdm_enable_rxhook_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
int sangoma_tdm_disable_rxhook_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
|
||||
int sangoma_tdm_get_fe_alarms(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
int sangoma_tdm_get_fe_alarms(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
|
||||
#ifndef LIBSANGOMA_GET_HWCODING
|
||||
#define LIBSANGOMA_GET_HWCODING 1
|
||||
#endif
|
||||
int sangoma_tdm_get_hw_coding(int fd, wanpipe_tdm_api_t *tdm_api);
|
||||
int sangoma_tdm_get_hw_coding(int fd, wanpipe_tdm_api_t * tdm_api);
|
||||
|
||||
#endif /* WANPIPE_TDM_API */
|
||||
#endif /* WANPIPE_TDM_API */
|
||||
|
||||
#endif
|
||||
|
||||
@@ -23,20 +23,21 @@
|
||||
static __inline int gettimeofday(struct timeval *tp, void *nothing)
|
||||
{
|
||||
#ifdef WITHOUT_MM_LIB
|
||||
SYSTEMTIME st;
|
||||
time_t tt;
|
||||
struct tm tmtm;
|
||||
/* mktime converts local to UTC */
|
||||
GetLocalTime (&st);
|
||||
tmtm.tm_sec = st.wSecond;
|
||||
tmtm.tm_min = st.wMinute;
|
||||
tmtm.tm_hour = st.wHour;
|
||||
tmtm.tm_mday = st.wDay;
|
||||
tmtm.tm_mon = st.wMonth - 1;
|
||||
tmtm.tm_year = st.wYear - 1900; tmtm.tm_isdst = -1;
|
||||
tt = mktime (&tmtm);
|
||||
tp->tv_sec = tt;
|
||||
tp->tv_usec = st.wMilliseconds * 1000;
|
||||
SYSTEMTIME st;
|
||||
time_t tt;
|
||||
struct tm tmtm;
|
||||
/* mktime converts local to UTC */
|
||||
GetLocalTime(&st);
|
||||
tmtm.tm_sec = st.wSecond;
|
||||
tmtm.tm_min = st.wMinute;
|
||||
tmtm.tm_hour = st.wHour;
|
||||
tmtm.tm_mday = st.wDay;
|
||||
tmtm.tm_mon = st.wMonth - 1;
|
||||
tmtm.tm_year = st.wYear - 1900;
|
||||
tmtm.tm_isdst = -1;
|
||||
tt = mktime(&tmtm);
|
||||
tp->tv_sec = tt;
|
||||
tp->tv_usec = st.wMilliseconds * 1000;
|
||||
#else
|
||||
/**
|
||||
** The earlier time calculations using GetLocalTime
|
||||
@@ -44,18 +45,18 @@ static __inline int gettimeofday(struct timeval *tp, void *nothing)
|
||||
** of multimedia apis offer a better time resolution
|
||||
** of 1ms.Need to link against winmm.lib for this
|
||||
**/
|
||||
unsigned long Ticks = 0;
|
||||
unsigned long Sec =0;
|
||||
unsigned long Usec = 0;
|
||||
Ticks = timeGetTime();
|
||||
unsigned long Ticks = 0;
|
||||
unsigned long Sec = 0;
|
||||
unsigned long Usec = 0;
|
||||
Ticks = timeGetTime();
|
||||
|
||||
Sec = Ticks/1000;
|
||||
Usec = (Ticks - (Sec*1000))*1000;
|
||||
tp->tv_sec = Sec;
|
||||
tp->tv_usec = Usec;
|
||||
Sec = Ticks / 1000;
|
||||
Usec = (Ticks - (Sec * 1000)) * 1000;
|
||||
tp->tv_sec = Sec;
|
||||
tp->tv_usec = Usec;
|
||||
#endif /* WITHOUT_MM_LIB */
|
||||
(void)nothing;
|
||||
return 0;
|
||||
(void) nothing;
|
||||
return 0;
|
||||
}
|
||||
#endif /* WIN32 */
|
||||
#endif /* HAVE_GETTIMEOFDAY */
|
||||
@@ -84,37 +85,37 @@ static struct sangoma_pri_event_list SANGOMA_PRI_EVENT_LIST[] = {
|
||||
|
||||
|
||||
char *sangoma_pri_event_str(sangoma_pri_event_t event_id)
|
||||
{
|
||||
{
|
||||
return SANGOMA_PRI_EVENT_LIST[event_id].name;
|
||||
}
|
||||
|
||||
static int __pri_sangoma_read(struct pri *pri, void *buf, int buflen)
|
||||
{
|
||||
unsigned char tmpbuf[sizeof(wp_tdm_api_rx_hdr_t)];
|
||||
|
||||
|
||||
|
||||
/* NOTE: This code will be different for A104
|
||||
* A104 receives data + 2byte CRC + 1 byte flag
|
||||
* A101/2 receives data only */
|
||||
|
||||
int res = sangoma_readmsg_socket((sng_fd_t)(pri->fd),
|
||||
tmpbuf, sizeof(wp_tdm_api_rx_hdr_t),
|
||||
buf, buflen,
|
||||
0);
|
||||
if (res > 0){
|
||||
* A101/2 receives data only */
|
||||
|
||||
int res = sangoma_readmsg_socket((sng_fd_t) (pri->fd),
|
||||
tmpbuf, sizeof(wp_tdm_api_rx_hdr_t),
|
||||
buf, buflen,
|
||||
0);
|
||||
if (res > 0) {
|
||||
#ifdef WANPIPE_LEGACY_A104
|
||||
/* Prior 2.3.4 release A104 API passed up
|
||||
* 3 extra bytes: 2 CRC + 1 FLAG,
|
||||
* PRI is expecting only 2 CRC bytes, thus we
|
||||
* must remove 1 flag byte */
|
||||
* 3 extra bytes: 2 CRC + 1 FLAG,
|
||||
* PRI is expecting only 2 CRC bytes, thus we
|
||||
* must remove 1 flag byte */
|
||||
res--;
|
||||
#else
|
||||
/* Add 2 byte CRC and set it to ZERO */
|
||||
memset(&((unsigned char*)buf)[res],0,2);
|
||||
res+=2;
|
||||
/* Add 2 byte CRC and set it to ZERO */
|
||||
memset(&((unsigned char *) buf)[res], 0, 2);
|
||||
res += 2;
|
||||
#endif
|
||||
}else{
|
||||
res=0;
|
||||
} else {
|
||||
res = 0;
|
||||
}
|
||||
|
||||
return res;
|
||||
@@ -126,25 +127,23 @@ static int __pri_sangoma_write(struct pri *pri, void *buf, int buflen)
|
||||
int res;
|
||||
|
||||
|
||||
memset(&tmpbuf[0],0,sizeof(wp_tdm_api_rx_hdr_t));
|
||||
memset(&tmpbuf[0], 0, sizeof(wp_tdm_api_rx_hdr_t));
|
||||
|
||||
if (buflen < 1){
|
||||
if (buflen < 1) {
|
||||
/* HDLC Frame must be greater than 2byte CRC */
|
||||
fprintf(stderr,"%s: Got short frame %i\n",__FUNCTION__,buflen);
|
||||
fprintf(stderr, "%s: Got short frame %i\n", __FUNCTION__, buflen);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* FIXME: This might cause problems with other libraries
|
||||
* We must remove 2 bytes from buflen because
|
||||
* libpri sends 2 fake CRC bytes */
|
||||
res=sangoma_sendmsg_socket((sng_fd_t)(pri->fd),
|
||||
tmpbuf, sizeof(wp_tdm_api_rx_hdr_t),
|
||||
buf, (unsigned short)buflen-2,
|
||||
0);
|
||||
if (res > 0){
|
||||
res=buflen;
|
||||
res = sangoma_sendmsg_socket((sng_fd_t) (pri->fd),
|
||||
tmpbuf, sizeof(wp_tdm_api_rx_hdr_t), buf, (unsigned short) buflen - 2, 0);
|
||||
if (res > 0) {
|
||||
res = buflen;
|
||||
}
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -155,10 +154,10 @@ int sangoma_init_pri(struct sangoma_pri *spri, int span, int dchan, int swtype,
|
||||
|
||||
memset(spri, 0, sizeof(struct sangoma_pri));
|
||||
|
||||
if((dfd = sangoma_open_tdmapi_span_chan(span, dchan)) < 0) {
|
||||
if ((dfd = sangoma_open_tdmapi_span_chan(span, dchan)) < 0) {
|
||||
fprintf(stderr, "Unable to open DCHAN %d for span %d (%s)\n", dchan, span, strerror(errno));
|
||||
} else {
|
||||
if ((spri->pri = pri_new_cb((int)dfd, node, swtype, __pri_sangoma_read, __pri_sangoma_write, NULL))){
|
||||
if ((spri->pri = pri_new_cb((int) dfd, node, swtype, __pri_sangoma_read, __pri_sangoma_write, NULL))) {
|
||||
spri->span = span;
|
||||
pri_set_debug(spri->pri, debug);
|
||||
ret = 0;
|
||||
@@ -173,10 +172,10 @@ int sangoma_init_pri(struct sangoma_pri *spri, int span, int dchan, int swtype,
|
||||
int sangoma_one_loop(struct sangoma_pri *spri)
|
||||
{
|
||||
fd_set rfds, efds;
|
||||
struct timeval now = {0,0}, *next;
|
||||
struct timeval now = { 0, 0 }, *next;
|
||||
pri_event *event;
|
||||
int sel;
|
||||
|
||||
int sel;
|
||||
|
||||
if (spri->on_loop) {
|
||||
spri->on_loop(spri);
|
||||
}
|
||||
@@ -223,10 +222,11 @@ int sangoma_one_loop(struct sangoma_pri *spri)
|
||||
if (event) {
|
||||
event_handler handler;
|
||||
/* 0 is catchall event handler */
|
||||
if ((handler = spri->eventmap[event->e] ? spri->eventmap[event->e] : spri->eventmap[0] ? spri->eventmap[0] : NULL)) {
|
||||
if ((handler =
|
||||
spri->eventmap[event->e] ? spri->eventmap[event->e] : spri->eventmap[0] ? spri->eventmap[0] : NULL)) {
|
||||
handler(spri, event->e, event);
|
||||
} else {
|
||||
fprintf(stderr,"No event handler found for event %d.\n", event->e);
|
||||
fprintf(stderr, "No event handler found for event %d.\n", event->e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,23 +237,22 @@ int sangoma_run_pri(struct sangoma_pri *spri)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
for (;;){
|
||||
ret=sangoma_one_loop(spri);
|
||||
if (ret < 0){
|
||||
for (;;) {
|
||||
ret = sangoma_one_loop(spri);
|
||||
if (ret < 0) {
|
||||
|
||||
#ifndef WIN32 //This needs to be adressed fror WIN32 still
|
||||
if (errno == EINTR){
|
||||
#ifndef WIN32 //This needs to be adressed fror WIN32 still
|
||||
if (errno == EINTR) {
|
||||
/* Igonore an interrupted system call */
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
printf("Error = %i\n",ret);
|
||||
#endif
|
||||
printf("Error = %i\n", ret);
|
||||
perror("Sangoma Run Pri: ");
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ typedef enum {
|
||||
|
||||
typedef enum {
|
||||
SANGOMA_PRI_SWITCH_UNKNOWN = PRI_SWITCH_UNKNOWN,
|
||||
SANGOMA_PRI_SWITCH_NI2 = PRI_SWITCH_NI2,
|
||||
SANGOMA_PRI_SWITCH_NI2 = PRI_SWITCH_NI2,
|
||||
SANGOMA_PRI_SWITCH_DMS100 = PRI_SWITCH_DMS100,
|
||||
SANGOMA_PRI_SWITCH_LUCENT5E = PRI_SWITCH_LUCENT5E,
|
||||
SANGOMA_PRI_SWITCH_ATT4ESS = PRI_SWITCH_ATT4ESS,
|
||||
@@ -67,8 +67,8 @@ typedef enum {
|
||||
} sangoma_pri_flag_t;
|
||||
|
||||
struct sangoma_pri;
|
||||
typedef int (*event_handler)(struct sangoma_pri *, sangoma_pri_event_t, pri_event *);
|
||||
typedef int (*loop_handler)(struct sangoma_pri *);
|
||||
typedef int (*event_handler) (struct sangoma_pri *, sangoma_pri_event_t, pri_event *);
|
||||
typedef int (*loop_handler) (struct sangoma_pri *);
|
||||
#define MAX_EVENT 18
|
||||
|
||||
struct sangoma_pri {
|
||||
@@ -77,7 +77,7 @@ struct sangoma_pri {
|
||||
int dchan;
|
||||
unsigned int flags;
|
||||
void *private_info;
|
||||
event_handler eventmap[MAX_EVENT+1];
|
||||
event_handler eventmap[MAX_EVENT + 1];
|
||||
loop_handler on_loop;
|
||||
};
|
||||
|
||||
|
||||
@@ -11,228 +11,159 @@
|
||||
#ifndef _WIN_API_COMMON_H
|
||||
#define _WIN_API_COMMON_H
|
||||
|
||||
static
|
||||
int
|
||||
tdmv_api_ioctl(
|
||||
HANDLE fd,
|
||||
wanpipe_tdm_api_cmd_t *tdm_api_cmd
|
||||
)
|
||||
static
|
||||
int tdmv_api_ioctl(HANDLE fd, wanpipe_tdm_api_cmd_t * tdm_api_cmd)
|
||||
{
|
||||
DWORD ln;
|
||||
unsigned char id = 0;
|
||||
int err = 0;
|
||||
DWORD ln;
|
||||
unsigned char id = 0;
|
||||
int err = 0;
|
||||
|
||||
wan_udp.wan_udphdr_request_reply = 0x01;
|
||||
wan_udp.wan_udphdr_id = id;
|
||||
wan_udp.wan_udphdr_return_code = WAN_UDP_TIMEOUT_CMD;
|
||||
wan_udp.wan_udphdr_id = id;
|
||||
wan_udp.wan_udphdr_return_code = WAN_UDP_TIMEOUT_CMD;
|
||||
|
||||
wan_udp.wan_udphdr_command = WAN_TDMV_API_IOCTL;
|
||||
wan_udp.wan_udphdr_data_len = sizeof(wanpipe_tdm_api_cmd_t);
|
||||
wan_udp.wan_udphdr_command = WAN_TDMV_API_IOCTL;
|
||||
wan_udp.wan_udphdr_data_len = sizeof(wanpipe_tdm_api_cmd_t);
|
||||
|
||||
//copy data from caller's buffer to driver's buffer
|
||||
memcpy( wan_udp.wan_udphdr_data,
|
||||
(void*)tdm_api_cmd,
|
||||
sizeof(wanpipe_tdm_api_cmd_t));
|
||||
memcpy(wan_udp.wan_udphdr_data, (void *) tdm_api_cmd, sizeof(wanpipe_tdm_api_cmd_t));
|
||||
|
||||
if(DeviceIoControl(
|
||||
fd,
|
||||
IoctlManagementCommand,
|
||||
(LPVOID)&wan_udp,
|
||||
sizeof(wan_udp_hdr_t),
|
||||
(LPVOID)&wan_udp,
|
||||
sizeof(wan_udp_hdr_t),
|
||||
(LPDWORD)(&ln),
|
||||
(LPOVERLAPPED)NULL
|
||||
) == FALSE){
|
||||
if (DeviceIoControl(fd,
|
||||
IoctlManagementCommand,
|
||||
(LPVOID) & wan_udp,
|
||||
sizeof(wan_udp_hdr_t),
|
||||
(LPVOID) & wan_udp, sizeof(wan_udp_hdr_t), (LPDWORD) (&ln), (LPOVERLAPPED) NULL) == FALSE) {
|
||||
//actual ioctl failed
|
||||
err = 1;
|
||||
prn(1, "Error: tdmv_api_ioctl(): DeviceIoControl failed!!\n");
|
||||
return err;
|
||||
}else{
|
||||
} else {
|
||||
err = 0;
|
||||
}
|
||||
|
||||
if(wan_udp.wan_udphdr_return_code != WAN_CMD_OK){
|
||||
if (wan_udp.wan_udphdr_return_code != WAN_CMD_OK) {
|
||||
//ioctl ok, but command failed
|
||||
prn(1, "Error: tdmv_api_ioctl(): command failed! Return code: 0x%X.\n",
|
||||
wan_udp.wan_udphdr_return_code);
|
||||
prn(1, "Error: tdmv_api_ioctl(): command failed! Return code: 0x%X.\n", wan_udp.wan_udphdr_return_code);
|
||||
return 2;
|
||||
}
|
||||
|
||||
//copy data from driver's buffer to caller's buffer
|
||||
memcpy( (void*)tdm_api_cmd,
|
||||
wan_udp.wan_udphdr_data,
|
||||
sizeof(wanpipe_tdm_api_cmd_t));
|
||||
memcpy((void *) tdm_api_cmd, wan_udp.wan_udphdr_data, sizeof(wanpipe_tdm_api_cmd_t));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
int
|
||||
wanpipe_api_ioctl(
|
||||
HANDLE fd,
|
||||
wan_cmd_api_t *api_cmd
|
||||
)
|
||||
static
|
||||
int wanpipe_api_ioctl(HANDLE fd, wan_cmd_api_t * api_cmd)
|
||||
{
|
||||
DWORD ln;
|
||||
unsigned char id = 0;
|
||||
int err = 0;
|
||||
DWORD ln;
|
||||
unsigned char id = 0;
|
||||
int err = 0;
|
||||
|
||||
wan_udp.wan_udphdr_request_reply = 0x01;
|
||||
wan_udp.wan_udphdr_id = id;
|
||||
wan_udp.wan_udphdr_return_code = WAN_UDP_TIMEOUT_CMD;
|
||||
wan_udp.wan_udphdr_id = id;
|
||||
wan_udp.wan_udphdr_return_code = WAN_UDP_TIMEOUT_CMD;
|
||||
|
||||
wan_udp.wan_udphdr_command = SIOC_WANPIPE_API;
|
||||
wan_udp.wan_udphdr_data_len = sizeof(wan_cmd_api_t);
|
||||
wan_udp.wan_udphdr_command = SIOC_WANPIPE_API;
|
||||
wan_udp.wan_udphdr_data_len = sizeof(wan_cmd_api_t);
|
||||
|
||||
//copy data from caller's buffer to driver's buffer
|
||||
memcpy( wan_udp.wan_udphdr_data,
|
||||
(void*)api_cmd,
|
||||
sizeof(wan_cmd_api_t));
|
||||
memcpy(wan_udp.wan_udphdr_data, (void *) api_cmd, sizeof(wan_cmd_api_t));
|
||||
|
||||
if(DeviceIoControl(
|
||||
fd,
|
||||
IoctlManagementCommand,
|
||||
(LPVOID)&wan_udp,
|
||||
sizeof(wan_udp_hdr_t),
|
||||
(LPVOID)&wan_udp,
|
||||
sizeof(wan_udp_hdr_t),
|
||||
(LPDWORD)(&ln),
|
||||
(LPOVERLAPPED)NULL
|
||||
) == FALSE){
|
||||
if (DeviceIoControl(fd,
|
||||
IoctlManagementCommand,
|
||||
(LPVOID) & wan_udp,
|
||||
sizeof(wan_udp_hdr_t),
|
||||
(LPVOID) & wan_udp, sizeof(wan_udp_hdr_t), (LPDWORD) (&ln), (LPOVERLAPPED) NULL) == FALSE) {
|
||||
err = 1;
|
||||
prn(1, "Error: wanpipe_api_ioctl(): DeviceIoControl failed!!\n");
|
||||
return err;
|
||||
}else{
|
||||
} else {
|
||||
err = 0;
|
||||
}
|
||||
|
||||
if(wan_udp.wan_udphdr_return_code != WAN_CMD_OK){
|
||||
prn(1, "Error: wanpipe_api_ioctl(): command failed! Return code: 0x%X.\n",
|
||||
wan_udp.wan_udphdr_return_code);
|
||||
if (wan_udp.wan_udphdr_return_code != WAN_CMD_OK) {
|
||||
prn(1, "Error: wanpipe_api_ioctl(): command failed! Return code: 0x%X.\n", wan_udp.wan_udphdr_return_code);
|
||||
return 2;
|
||||
}
|
||||
|
||||
//copy data from driver's buffer to caller's buffer
|
||||
memcpy( (void*)api_cmd,
|
||||
wan_udp.wan_udphdr_data,
|
||||
sizeof(wan_cmd_api_t));
|
||||
memcpy((void *) api_cmd, wan_udp.wan_udphdr_data, sizeof(wan_cmd_api_t));
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Blocking read command. If used after DoApiPollCommand(),
|
||||
// it will return immediatly, without blocking.
|
||||
static
|
||||
USHORT
|
||||
DoReadCommand(
|
||||
HANDLE drv,
|
||||
RX_DATA_STRUCT * pRx
|
||||
)
|
||||
static USHORT DoReadCommand(HANDLE drv, RX_DATA_STRUCT * pRx)
|
||||
{
|
||||
DWORD ln;
|
||||
|
||||
if (DeviceIoControl(
|
||||
drv,
|
||||
IoctlReadCommand,
|
||||
(LPVOID)NULL,
|
||||
0L,
|
||||
(LPVOID)pRx,
|
||||
sizeof(RX_DATA_STRUCT),
|
||||
(LPDWORD)(&ln),
|
||||
(LPOVERLAPPED)NULL
|
||||
) == FALSE){
|
||||
if (DeviceIoControl(drv,
|
||||
IoctlReadCommand,
|
||||
(LPVOID) NULL,
|
||||
0L, (LPVOID) pRx, sizeof(RX_DATA_STRUCT), (LPDWORD) (&ln), (LPOVERLAPPED) NULL) == FALSE) {
|
||||
//check messages log
|
||||
prn(1, "Error: DoReadCommand(): DeviceIoControl failed!\n");
|
||||
return 1;
|
||||
}else{
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Blocking write command. If used after DoApiPollCommand(),
|
||||
// it will return immediatly, without blocking.
|
||||
static
|
||||
UCHAR
|
||||
DoWriteCommand(
|
||||
HANDLE drv,
|
||||
TX_DATA_STRUCT * pTx
|
||||
)
|
||||
static UCHAR DoWriteCommand(HANDLE drv, TX_DATA_STRUCT * pTx)
|
||||
{
|
||||
DWORD ln;
|
||||
|
||||
if(DeviceIoControl(
|
||||
drv,
|
||||
IoctlWriteCommand,
|
||||
(LPVOID)pTx,
|
||||
(ULONG)sizeof(TX_DATA_STRUCT),
|
||||
(LPVOID)pTx,
|
||||
sizeof(TX_DATA_STRUCT),
|
||||
(LPDWORD)(&ln),
|
||||
(LPOVERLAPPED)NULL
|
||||
) == FALSE){
|
||||
if (DeviceIoControl(drv,
|
||||
IoctlWriteCommand,
|
||||
(LPVOID) pTx,
|
||||
(ULONG) sizeof(TX_DATA_STRUCT),
|
||||
(LPVOID) pTx, sizeof(TX_DATA_STRUCT), (LPDWORD) (&ln), (LPOVERLAPPED) NULL) == FALSE) {
|
||||
//check messages log
|
||||
prn(1, "Error: DoWriteCommand(): DeviceIoControl failed!\n");
|
||||
return 1;
|
||||
}else{
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Blocking API Poll command.
|
||||
static
|
||||
USHORT
|
||||
DoApiPollCommand(
|
||||
HANDLE drv,
|
||||
API_POLL_STRUCT *api_poll_ptr
|
||||
)
|
||||
static USHORT DoApiPollCommand(HANDLE drv, API_POLL_STRUCT * api_poll_ptr)
|
||||
{
|
||||
DWORD ln;
|
||||
|
||||
if (DeviceIoControl(
|
||||
drv,
|
||||
IoctlApiPoll,
|
||||
(LPVOID)NULL,
|
||||
0L,
|
||||
(LPVOID)api_poll_ptr,
|
||||
sizeof(API_POLL_STRUCT),
|
||||
(LPDWORD)(&ln),
|
||||
(LPOVERLAPPED)NULL
|
||||
) == FALSE){
|
||||
if (DeviceIoControl(drv,
|
||||
IoctlApiPoll,
|
||||
(LPVOID) NULL,
|
||||
0L,
|
||||
(LPVOID) api_poll_ptr,
|
||||
sizeof(API_POLL_STRUCT), (LPDWORD) (&ln), (LPOVERLAPPED) NULL) == FALSE) {
|
||||
//check messages log
|
||||
prn(1, "Error: DoApiPollCommand(): DeviceIoControl failed!\n");
|
||||
return 1;
|
||||
}else{
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
int
|
||||
DoManagementCommand(
|
||||
HANDLE drv,
|
||||
wan_udp_hdr_t* wan_udp
|
||||
)
|
||||
int DoManagementCommand(HANDLE drv, wan_udp_hdr_t * wan_udp)
|
||||
{
|
||||
DWORD ln;
|
||||
static unsigned char id = 0;
|
||||
static unsigned char id = 0;
|
||||
|
||||
wan_udp->wan_udphdr_request_reply = 0x01;
|
||||
wan_udp->wan_udphdr_id = id++;
|
||||
wan_udp->wan_udphdr_return_code = WAN_UDP_TIMEOUT_CMD;
|
||||
wan_udp->wan_udphdr_return_code = WAN_UDP_TIMEOUT_CMD;
|
||||
|
||||
if(DeviceIoControl(
|
||||
drv,
|
||||
IoctlManagementCommand,
|
||||
(LPVOID)wan_udp,
|
||||
sizeof(wan_udp_hdr_t),
|
||||
(LPVOID)wan_udp,
|
||||
sizeof(wan_udp_hdr_t),
|
||||
(LPDWORD)(&ln),
|
||||
(LPOVERLAPPED)NULL
|
||||
) == FALSE){
|
||||
if (DeviceIoControl(drv,
|
||||
IoctlManagementCommand,
|
||||
(LPVOID) wan_udp,
|
||||
sizeof(wan_udp_hdr_t),
|
||||
(LPVOID) wan_udp, sizeof(wan_udp_hdr_t), (LPDWORD) (&ln), (LPOVERLAPPED) NULL) == FALSE) {
|
||||
//check messages log
|
||||
prn(1, "Error: DoManagementCommand(): DeviceIoControl failed!\n");
|
||||
return 1;
|
||||
}else{
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -16,38 +16,35 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
enum e_sigboost_event_id_values
|
||||
{
|
||||
SIGBOOST_EVENT_CALL_START = 0x80, /*128*/
|
||||
SIGBOOST_EVENT_CALL_START_ACK = 0x81, /*129*/
|
||||
SIGBOOST_EVENT_CALL_START_NACK = 0x82, /*130*/
|
||||
SIGBOOST_EVENT_CALL_START_NACK_ACK = 0x83, /*131*/
|
||||
SIGBOOST_EVENT_CALL_ANSWERED = 0x84, /*132*/
|
||||
SIGBOOST_EVENT_CALL_STOPPED = 0x85, /*133*/
|
||||
SIGBOOST_EVENT_CALL_STOPPED_ACK = 0x86, /*134*/
|
||||
SIGBOOST_EVENT_SYSTEM_RESTART = 0x87, /*135*/
|
||||
SIGBOOST_EVENT_HEARTBEAT = 0x88, /*136*/
|
||||
enum e_sigboost_event_id_values {
|
||||
SIGBOOST_EVENT_CALL_START = 0x80, /*128 */
|
||||
SIGBOOST_EVENT_CALL_START_ACK = 0x81, /*129 */
|
||||
SIGBOOST_EVENT_CALL_START_NACK = 0x82, /*130 */
|
||||
SIGBOOST_EVENT_CALL_START_NACK_ACK = 0x83, /*131 */
|
||||
SIGBOOST_EVENT_CALL_ANSWERED = 0x84, /*132 */
|
||||
SIGBOOST_EVENT_CALL_STOPPED = 0x85, /*133 */
|
||||
SIGBOOST_EVENT_CALL_STOPPED_ACK = 0x86, /*134 */
|
||||
SIGBOOST_EVENT_SYSTEM_RESTART = 0x87, /*135 */
|
||||
SIGBOOST_EVENT_HEARTBEAT = 0x88, /*136 */
|
||||
};
|
||||
|
||||
enum e_sigboost_release_cause_values
|
||||
{
|
||||
SIGBOOST_RELEASE_CAUSE_UNDEFINED = 0x00,
|
||||
SIGBOOST_RELEASE_CAUSE_NORMAL = 0x90,
|
||||
SIGBOOST_RELEASE_CAUSE_BUSY = 0x91,
|
||||
SIGBOOST_RELEASE_CAUSE_CALLED_NOT_EXIST = 0x92,
|
||||
SIGBOOST_RELEASE_CAUSE_CIRCUIT_RESET = 0x93,
|
||||
SIGBOOST_RELEASE_CAUSE_NOANSWER = 0x94
|
||||
enum e_sigboost_release_cause_values {
|
||||
SIGBOOST_RELEASE_CAUSE_UNDEFINED = 0x00,
|
||||
SIGBOOST_RELEASE_CAUSE_NORMAL = 0x90,
|
||||
SIGBOOST_RELEASE_CAUSE_BUSY = 0x91,
|
||||
SIGBOOST_RELEASE_CAUSE_CALLED_NOT_EXIST = 0x92,
|
||||
SIGBOOST_RELEASE_CAUSE_CIRCUIT_RESET = 0x93,
|
||||
SIGBOOST_RELEASE_CAUSE_NOANSWER = 0x94
|
||||
};
|
||||
|
||||
enum e_sigboost_call_setup_ack_nack_cause_values
|
||||
{
|
||||
SIGBOOST_CALL_SETUP_CIRCUIT_RESET = 0x10,
|
||||
SIGBOOST_CALL_SETUP_NACK_CKT_START_TIMEOUT = 0x11,
|
||||
SIGBOOST_CALL_SETUP_NACK_ALL_CKTS_BUSY = 0x12,
|
||||
SIGBOOST_CALL_SETUP_NACK_CALLED_NUM_TOO_BIG = 0x13,
|
||||
SIGBOOST_CALL_SETUP_NACK_CALLING_NUM_TOO_BIG = 0x14,
|
||||
SIGBOOST_CALL_SETUP_NACK_CALLED_NUM_TOO_SMALL = 0x15,
|
||||
SIGBOOST_CALL_SETUP_NACK_CALLING_NUM_TOO_SMALL = 0x16,
|
||||
enum e_sigboost_call_setup_ack_nack_cause_values {
|
||||
SIGBOOST_CALL_SETUP_CIRCUIT_RESET = 0x10,
|
||||
SIGBOOST_CALL_SETUP_NACK_CKT_START_TIMEOUT = 0x11,
|
||||
SIGBOOST_CALL_SETUP_NACK_ALL_CKTS_BUSY = 0x12,
|
||||
SIGBOOST_CALL_SETUP_NACK_CALLED_NUM_TOO_BIG = 0x13,
|
||||
SIGBOOST_CALL_SETUP_NACK_CALLING_NUM_TOO_BIG = 0x14,
|
||||
SIGBOOST_CALL_SETUP_NACK_CALLED_NUM_TOO_SMALL = 0x15,
|
||||
SIGBOOST_CALL_SETUP_NACK_CALLING_NUM_TOO_SMALL = 0x16,
|
||||
};
|
||||
|
||||
#define MAX_DIALED_DIGITS 31
|
||||
@@ -61,21 +58,20 @@ enum e_sigboost_call_setup_ack_nack_cause_values
|
||||
/* 0..(MAX_PENDING_CALLS-1) is range of call_setup_id below */
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct
|
||||
{
|
||||
uint32_t event_id;
|
||||
uint32_t seqno;
|
||||
uint32_t call_setup_id;
|
||||
uint32_t trunk_group;
|
||||
uint32_t span;
|
||||
uint32_t chan;
|
||||
uint32_t called_number_digits_count;
|
||||
int8_t called_number_digits [MAX_DIALED_DIGITS + 1]; /* it's a null terminated string */
|
||||
uint32_t calling_number_digits_count; /* it's an array */
|
||||
int8_t calling_number_digits [MAX_DIALED_DIGITS + 1]; /* it's a null terminated string */
|
||||
uint32_t release_cause;
|
||||
struct timeval tv;
|
||||
uint32_t calling_number_presentation;
|
||||
typedef struct {
|
||||
uint32_t event_id;
|
||||
uint32_t seqno;
|
||||
uint32_t call_setup_id;
|
||||
uint32_t trunk_group;
|
||||
uint32_t span;
|
||||
uint32_t chan;
|
||||
uint32_t called_number_digits_count;
|
||||
int8_t called_number_digits[MAX_DIALED_DIGITS + 1]; /* it's a null terminated string */
|
||||
uint32_t calling_number_digits_count; /* it's an array */
|
||||
int8_t calling_number_digits[MAX_DIALED_DIGITS + 1]; /* it's a null terminated string */
|
||||
uint32_t release_cause;
|
||||
struct timeval tv;
|
||||
uint32_t calling_number_presentation;
|
||||
} t_sigboost;
|
||||
#pragma pack()
|
||||
|
||||
|
||||
@@ -52,23 +52,25 @@ static struct ss7boost_client_map ss7boost_client_table[] = {
|
||||
{SIGBOOST_EVENT_CALL_STOPPED_ACK, "CALL_STOPPED_ACK"},
|
||||
{SIGBOOST_EVENT_SYSTEM_RESTART, "SYSTEM_RESTART"},
|
||||
{SIGBOOST_EVENT_HEARTBEAT, "HEARTBEAT"},
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
static switch_status_t create_udp_socket(ss7boost_client_connection_t *mcon, char *local_ip, int local_port, char *ip, int port)
|
||||
static switch_status_t create_udp_socket(ss7boost_client_connection_t * mcon, char *local_ip, int local_port, char *ip,
|
||||
int port)
|
||||
{
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "connect %s:%d->%s:%d\n", local_ip, local_port, ip, port);
|
||||
|
||||
if (switch_sockaddr_info_get(&mcon->local_addr, local_ip, SWITCH_UNSPEC, local_port, 0, mcon->pool) != SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_sockaddr_info_get(&mcon->local_addr, local_ip, SWITCH_UNSPEC, local_port, 0, mcon->pool) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (switch_sockaddr_info_get(&mcon->remote_addr, ip, SWITCH_UNSPEC, port, 0, mcon->pool) != SWITCH_STATUS_SUCCESS) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
||||
if (switch_socket_create(&mcon->socket, AF_INET, SOCK_DGRAM, 0, mcon->pool) == SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_socket_bind(mcon->socket, mcon->local_addr) != SWITCH_STATUS_SUCCESS) {
|
||||
goto fail;
|
||||
@@ -77,18 +79,20 @@ static switch_status_t create_udp_socket(ss7boost_client_connection_t *mcon, cha
|
||||
goto fail;
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Created boost connection %s:%d->%s:%d\n", local_ip, local_port, ip, port);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Created boost connection %s:%d->%s:%d\n", local_ip,
|
||||
local_port, ip, port);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
fail:
|
||||
fail:
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failure creating boost connection %s:%d->%s:%d\n", local_ip, local_port, ip, port);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failure creating boost connection %s:%d->%s:%d\n", local_ip,
|
||||
local_port, ip, port);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_close(ss7boost_client_connection_t *mcon)
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_close(ss7boost_client_connection_t * mcon)
|
||||
{
|
||||
switch_socket_close(mcon->socket);
|
||||
mcon->socket = NULL;
|
||||
@@ -97,12 +101,10 @@ SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_close(ss7boost_client
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_open(ss7boost_client_connection_t *mcon,
|
||||
char *local_ip,
|
||||
int local_port,
|
||||
char *ip,
|
||||
int port,
|
||||
switch_memory_pool_t *pool)
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_open(ss7boost_client_connection_t * mcon,
|
||||
char *local_ip,
|
||||
int local_port,
|
||||
char *ip, int port, switch_memory_pool_t *pool)
|
||||
{
|
||||
memset(mcon, 0, sizeof(*mcon));
|
||||
mcon->pool = pool;
|
||||
@@ -111,32 +113,30 @@ SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_open(ss7boost_client_
|
||||
switch_mutex_init(&mcon->mutex, SWITCH_MUTEX_NESTED, mcon->pool);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
memset(mcon, 0, sizeof(*mcon));
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_read(ss7boost_client_connection_t *mcon, ss7boost_client_event_t **event)
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_read(ss7boost_client_connection_t * mcon,
|
||||
ss7boost_client_event_t ** event)
|
||||
{
|
||||
unsigned int fromlen = sizeof(struct sockaddr_in);
|
||||
switch_size_t bytes = 0;
|
||||
|
||||
bytes = sizeof(mcon->event);
|
||||
|
||||
if (switch_socket_recvfrom(mcon->local_addr, mcon->socket, 0, (void *)&mcon->event, &bytes) != SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_socket_recvfrom(mcon->local_addr, mcon->socket, 0, (void *) &mcon->event, &bytes) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
bytes = 0;
|
||||
}
|
||||
|
||||
if (bytes == sizeof(mcon->event) ||
|
||||
bytes == (sizeof(mcon->event)-sizeof(uint32_t))) {
|
||||
if (bytes == sizeof(mcon->event) || bytes == (sizeof(mcon->event) - sizeof(uint32_t))) {
|
||||
if (rxseq != mcon->event.seqno) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
|
||||
"------------------------------------------\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
|
||||
"Critical Error: Invalid Sequence Number Expect=%i Rx=%i\n",
|
||||
rxseq,mcon->event.seqno);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
|
||||
"------------------------------------------\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "------------------------------------------\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
|
||||
"Critical Error: Invalid Sequence Number Expect=%i Rx=%i\n", rxseq, mcon->event.seqno);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "------------------------------------------\n");
|
||||
}
|
||||
rxseq++;
|
||||
|
||||
@@ -147,7 +147,8 @@ SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_read(ss7boost_client_
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_write(ss7boost_client_connection_t *mcon, ss7boost_client_event_t *event)
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_write(ss7boost_client_connection_t * mcon,
|
||||
ss7boost_client_event_t * event)
|
||||
{
|
||||
int err;
|
||||
switch_size_t len;
|
||||
@@ -158,23 +159,19 @@ SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_write(ss7boost_client
|
||||
}
|
||||
|
||||
if (event->span < 0 || event->chan < 0 || event->span > 7 || event->chan > 30) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
|
||||
"------------------------------------------\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
|
||||
"Critical Error: Invalid Span=%i Chan=%i\n",
|
||||
event->span,event->chan);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
|
||||
"------------------------------------------\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "------------------------------------------\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
|
||||
"Critical Error: Invalid Span=%i Chan=%i\n", event->span, event->chan);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "------------------------------------------\n");
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
//TODO set the tv with win func
|
||||
#else
|
||||
gettimeofday(&event->tv,NULL);
|
||||
#else
|
||||
gettimeofday(&event->tv, NULL);
|
||||
#endif
|
||||
|
||||
switch_mutex_lock(mcon->mutex);
|
||||
event->seqno=txseq++;
|
||||
event->seqno = txseq++;
|
||||
len = sizeof(*event);
|
||||
if (switch_socket_sendto(mcon->socket, mcon->remote_addr, 0, (void *) event, &len) != SWITCH_STATUS_SUCCESS) {
|
||||
err = -1;
|
||||
@@ -182,7 +179,8 @@ SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_write(ss7boost_client
|
||||
switch_mutex_unlock(mcon->mutex);
|
||||
|
||||
if (len != sizeof(ss7boost_client_event_t)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Write Error: [%d][%d][%s]\n", mcon->socket, errno, strerror(errno));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Write Error: [%d][%d][%s]\n", mcon->socket, errno,
|
||||
strerror(errno));
|
||||
err = -1;
|
||||
}
|
||||
|
||||
@@ -204,42 +202,39 @@ SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_write(ss7boost_client
|
||||
"\n",
|
||||
ss7boost_client_event_id_name(event->event_id),
|
||||
event->event_id,
|
||||
event->span+1,
|
||||
event->chan+1,
|
||||
event->span + 1,
|
||||
event->chan + 1,
|
||||
(event->called_number_digits_count ? (char *) event->called_number_digits : "N/A"),
|
||||
(event->calling_number_digits_count ? (char *) event->calling_number_digits : "N/A"),
|
||||
event->release_cause,
|
||||
event->span+1,
|
||||
event->chan+1,
|
||||
event->event_id,
|
||||
event->call_setup_id,
|
||||
event->seqno
|
||||
);
|
||||
event->span + 1, event->chan + 1, event->event_id, event->call_setup_id, event->seqno);
|
||||
|
||||
|
||||
return err ? SWITCH_STATUS_FALSE : SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(void) ss7boost_client_call_init(ss7boost_client_event_t *event, char *calling, char *called, int setup_id)
|
||||
SWITCH_DECLARE(void) ss7boost_client_call_init(ss7boost_client_event_t * event, char *calling, char *called,
|
||||
int setup_id)
|
||||
{
|
||||
memset(event, 0, sizeof(ss7boost_client_event_t));
|
||||
event->event_id = SIGBOOST_EVENT_CALL_START;
|
||||
|
||||
if (calling) {
|
||||
strncpy((char*)event->calling_number_digits, calling, sizeof(event->calling_number_digits)-1);
|
||||
strncpy((char *) event->calling_number_digits, calling, sizeof(event->calling_number_digits) - 1);
|
||||
event->calling_number_digits_count = strlen(calling);
|
||||
}
|
||||
|
||||
if (called) {
|
||||
strncpy((char*)event->called_number_digits, called, sizeof(event->called_number_digits)-1);
|
||||
strncpy((char *) event->called_number_digits, called, sizeof(event->called_number_digits) - 1);
|
||||
event->called_number_digits_count = strlen(called);
|
||||
}
|
||||
|
||||
|
||||
event->call_setup_id = setup_id;
|
||||
|
||||
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(void) ss7boost_client_event_init(ss7boost_client_event_t *event, ss7boost_client_event_id_t event_id, int chan, int span)
|
||||
SWITCH_DECLARE(void) ss7boost_client_event_init(ss7boost_client_event_t * event, ss7boost_client_event_id_t event_id,
|
||||
int chan, int span)
|
||||
{
|
||||
memset(event, 0, sizeof(ss7boost_client_event_t));
|
||||
event->event_id = event_id;
|
||||
@@ -252,7 +247,7 @@ SWITCH_DECLARE(char *) ss7boost_client_event_id_name(uint32_t event_id)
|
||||
int x;
|
||||
char *ret = NULL;
|
||||
|
||||
for (x = 0 ; x < sizeof(ss7boost_client_table)/sizeof(struct ss7boost_client_map); x++) {
|
||||
for (x = 0; x < sizeof(ss7boost_client_table) / sizeof(struct ss7boost_client_map); x++) {
|
||||
if (ss7boost_client_table[x].event_id == event_id) {
|
||||
ret = ss7boost_client_table[x].name;
|
||||
break;
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
(dest)->flags |= ((src)->flags & (flagz)); \
|
||||
} while (0)
|
||||
|
||||
typedef t_sigboost ss7boost_client_event_t;
|
||||
typedef t_sigboost ss7boost_client_event_t;
|
||||
typedef uint32_t ss7boost_client_event_id_t;
|
||||
|
||||
struct ss7boost_client_connection {
|
||||
@@ -80,7 +80,7 @@ struct ss7boost_client_connection {
|
||||
ss7boost_client_event_t event;
|
||||
unsigned int flags;
|
||||
switch_mutex_t *mutex;
|
||||
switch_memory_pool_t * pool;
|
||||
switch_memory_pool_t *pool;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
@@ -89,19 +89,19 @@ typedef enum {
|
||||
|
||||
typedef struct ss7boost_client_connection ss7boost_client_connection_t;
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_close(ss7boost_client_connection_t *mcon);
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_open(ss7boost_client_connection_t *mcon,
|
||||
char *local_ip,
|
||||
int local_port,
|
||||
char *ip,
|
||||
int port,
|
||||
switch_memory_pool_t *pool);
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_read(ss7boost_client_connection_t *mcon, ss7boost_client_event_t **event);
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_write(ss7boost_client_connection_t *mcon, ss7boost_client_event_t *event);
|
||||
SWITCH_DECLARE(void) ss7boost_client_event_init(ss7boost_client_event_t *event, ss7boost_client_event_id_t event_id, int chan, int span);
|
||||
SWITCH_DECLARE(void) ss7boost_client_call_init(ss7boost_client_event_t *event, char *calling, char *called, int setup_id);
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_close(ss7boost_client_connection_t * mcon);
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_open(ss7boost_client_connection_t * mcon,
|
||||
char *local_ip,
|
||||
int local_port,
|
||||
char *ip, int port, switch_memory_pool_t *pool);
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_read(ss7boost_client_connection_t * mcon,
|
||||
ss7boost_client_event_t ** event);
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_write(ss7boost_client_connection_t * mcon,
|
||||
ss7boost_client_event_t * event);
|
||||
SWITCH_DECLARE(void) ss7boost_client_event_init(ss7boost_client_event_t * event, ss7boost_client_event_id_t event_id,
|
||||
int chan, int span);
|
||||
SWITCH_DECLARE(void) ss7boost_client_call_init(ss7boost_client_event_t * event, char *calling, char *called,
|
||||
int setup_id);
|
||||
SWITCH_DECLARE(char *) ss7boost_client_event_id_name(uint32_t event_id);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -169,12 +169,13 @@ static switch_status_t woomera_on_hangup(switch_core_session_t *session);
|
||||
static switch_status_t woomera_on_ring(switch_core_session_t *session);
|
||||
static switch_status_t woomera_on_loopback(switch_core_session_t *session);
|
||||
static switch_status_t woomera_on_transmit(switch_core_session_t *session);
|
||||
static switch_call_cause_t woomera_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile,
|
||||
static switch_call_cause_t woomera_outgoing_channel(switch_core_session_t *session,
|
||||
switch_caller_profile_t *outbound_profile,
|
||||
switch_core_session_t **new_session, switch_memory_pool_t **pool);
|
||||
static switch_status_t woomera_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout,
|
||||
switch_io_flag_t flags, int stream_id);
|
||||
switch_io_flag_t flags, int stream_id);
|
||||
static switch_status_t woomera_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
|
||||
switch_io_flag_t flags, int stream_id);
|
||||
switch_io_flag_t flags, int stream_id);
|
||||
static switch_status_t woomera_kill_channel(switch_core_session_t *session, int sig);
|
||||
static void tech_destroy(private_object * tech_pvt);
|
||||
static void woomera_printf(woomera_profile * profile, switch_socket_t *socket, char *fmt, ...);
|
||||
@@ -213,7 +214,8 @@ static switch_status_t woomera_on_init(switch_core_session_t *session)
|
||||
if (switch_core_codec_init
|
||||
(&tech_pvt->read_codec, "L16", NULL, rate, 30, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
|
||||
switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s Cannot set read codec\n", switch_channel_get_name(channel));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s Cannot set read codec\n",
|
||||
switch_channel_get_name(channel));
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
@@ -221,7 +223,8 @@ static switch_status_t woomera_on_init(switch_core_session_t *session)
|
||||
if (switch_core_codec_init
|
||||
(&tech_pvt->write_codec, "L16", NULL, rate, 30, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
|
||||
switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s Cannot set read codec\n", switch_channel_get_name(channel));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s Cannot set read codec\n",
|
||||
switch_channel_get_name(channel));
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
@@ -327,19 +330,19 @@ static switch_status_t woomera_kill_channel(switch_core_session_t *session, int
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
switch(sig) {
|
||||
case SWITCH_SIG_KILL:
|
||||
udp_socket_close(tech_pvt);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s WOOMERA KILL\n", switch_channel_get_name(channel));
|
||||
break;
|
||||
case SWITCH_SIG_BREAK:
|
||||
{
|
||||
const char p = 0;
|
||||
switch_size_t len = sizeof(p);
|
||||
switch_socket_sendto(tech_pvt->udp_socket, tech_pvt->udpwrite, 0, &p, &len);
|
||||
}
|
||||
break;
|
||||
}
|
||||
switch (sig) {
|
||||
case SWITCH_SIG_KILL:
|
||||
udp_socket_close(tech_pvt);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s WOOMERA KILL\n", switch_channel_get_name(channel));
|
||||
break;
|
||||
case SWITCH_SIG_BREAK:
|
||||
{
|
||||
const char p = 0;
|
||||
switch_size_t len = sizeof(p);
|
||||
switch_socket_sendto(tech_pvt->udp_socket, tech_pvt->udpwrite, 0, &p, &len);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
@@ -375,11 +378,11 @@ static switch_status_t woomera_waitfor_write(switch_core_session_t *session, int
|
||||
assert(tech_pvt != NULL);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
// return switch_socket_waitfor(tech_pvt->write_poll, ms);
|
||||
// return switch_socket_waitfor(tech_pvt->write_poll, ms);
|
||||
}
|
||||
|
||||
static switch_status_t woomera_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout,
|
||||
switch_io_flag_t flags, int stream_id)
|
||||
switch_io_flag_t flags, int stream_id)
|
||||
{
|
||||
switch_channel_t *channel = NULL;
|
||||
struct private_object *tech_pvt = NULL;
|
||||
@@ -404,8 +407,9 @@ static switch_status_t woomera_read_frame(switch_core_session_t *session, switch
|
||||
*frame = pframe;
|
||||
|
||||
len = sizeof(tech_pvt->databuf);
|
||||
if (switch_socket_recvfrom(tech_pvt->udpread, tech_pvt->udp_socket, 0, tech_pvt->databuf, &len) == SWITCH_STATUS_SUCCESS) {
|
||||
pframe->datalen = (uint32_t)len;
|
||||
if (switch_socket_recvfrom(tech_pvt->udpread, tech_pvt->udp_socket, 0, tech_pvt->databuf, &len) ==
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
pframe->datalen = (uint32_t) len;
|
||||
pframe->samples = (int) pframe->datalen / 2;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
@@ -414,13 +418,13 @@ static switch_status_t woomera_read_frame(switch_core_session_t *session, switch
|
||||
}
|
||||
|
||||
static switch_status_t woomera_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
|
||||
switch_io_flag_t flags, int stream_id)
|
||||
switch_io_flag_t flags, int stream_id)
|
||||
{
|
||||
switch_channel_t *channel = NULL;
|
||||
struct private_object *tech_pvt = NULL;
|
||||
switch_size_t len;
|
||||
//switch_frame_t *pframe;
|
||||
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
assert(channel != NULL);
|
||||
|
||||
@@ -430,11 +434,10 @@ static switch_status_t woomera_write_frame(switch_core_session_t *session, switc
|
||||
if (!tech_pvt->udp_socket) {
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
//pframe = &tech_pvt->frame;
|
||||
len = frame->datalen;
|
||||
if (switch_socket_sendto(tech_pvt->udp_socket, tech_pvt->udpwrite, 0, frame->data, &len) == SWITCH_STATUS_SUCCESS) {
|
||||
frame->datalen = (uint32_t)len;
|
||||
frame->datalen = (uint32_t) len;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -481,7 +484,8 @@ static const switch_loadable_module_interface_t woomera_module_interface = {
|
||||
/* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines
|
||||
that allocate memory or you will have 1 channel with memory allocated from another channel's pool!
|
||||
*/
|
||||
static switch_call_cause_t woomera_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile,
|
||||
static switch_call_cause_t woomera_outgoing_channel(switch_core_session_t *session,
|
||||
switch_caller_profile_t *outbound_profile,
|
||||
switch_core_session_t **new_session, switch_memory_pool_t **pool)
|
||||
{
|
||||
if ((*new_session = switch_core_session_request(&woomera_endpoint_interface, pool)) != 0) {
|
||||
@@ -542,7 +546,8 @@ static void tech_destroy(private_object * tech_pvt)
|
||||
WOOMERA_RECORD_SEPERATOR);
|
||||
if (woomera_message_parse
|
||||
(tech_pvt->command_channel, &wmsg, WOOMERA_HARD_TIMEOUT, tech_pvt->profile, &tech_pvt->event_queue) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "{%s} Already Disconnected\n", tech_pvt->profile->name);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "{%s} Already Disconnected\n",
|
||||
tech_pvt->profile->name);
|
||||
}
|
||||
|
||||
woomera_printf(tech_pvt->profile, tech_pvt->command_channel, "bye%s", WOOMERA_RECORD_SEPERATOR);
|
||||
@@ -570,7 +575,7 @@ static void woomera_printf(woomera_profile * profile, switch_socket_t *socket, c
|
||||
} else {
|
||||
if (profile && globals.debug) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Send Message: {%s} [%s/%d]\n%s\n%s", profile->name,
|
||||
profile->woomera_host, profile->woomera_port, WOOMERA_DEBUG_LINE, stuff);
|
||||
profile->woomera_host, profile->woomera_port, WOOMERA_DEBUG_LINE, stuff);
|
||||
}
|
||||
len = strlen(stuff);
|
||||
switch_socket_send(socket, stuff, &len);
|
||||
@@ -660,7 +665,7 @@ static int woomera_message_parse(switch_socket_t *fd, woomera_message * wmsg, in
|
||||
bytes = 0;
|
||||
while (!strstr(buf, WOOMERA_RECORD_SEPERATOR)) {
|
||||
size_t len = 1;
|
||||
switch_status_t status;
|
||||
switch_status_t status;
|
||||
|
||||
if (!profile->thread_running) {
|
||||
return -1;
|
||||
@@ -668,16 +673,16 @@ static int woomera_message_parse(switch_socket_t *fd, woomera_message * wmsg, in
|
||||
|
||||
status = switch_socket_recv(fd, ptr, &len);
|
||||
|
||||
if (status == 70007) {
|
||||
char bbuf = '\n';
|
||||
switch_size_t blen = sizeof(bbuf);
|
||||
switch_socket_send(fd, &bbuf, &blen);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (status != SWITCH_STATUS_SUCCESS) {
|
||||
return -1;
|
||||
}
|
||||
if (status == 70007) {
|
||||
char bbuf = '\n';
|
||||
switch_size_t blen = sizeof(bbuf);
|
||||
switch_socket_send(fd, &bbuf, &blen);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (status != SWITCH_STATUS_SUCCESS) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ptr++;
|
||||
bytes++;
|
||||
@@ -687,7 +692,7 @@ static int woomera_message_parse(switch_socket_t *fd, woomera_message * wmsg, in
|
||||
|
||||
if (globals.debug) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Receive Message: {%s} [%s/%d]\n%s\n%s", profile->name,
|
||||
profile->woomera_host, profile->woomera_port, WOOMERA_DEBUG_LINE, buf);
|
||||
profile->woomera_host, profile->woomera_port, WOOMERA_DEBUG_LINE, buf);
|
||||
}
|
||||
|
||||
while ((cur = next) != 0) {
|
||||
@@ -775,7 +780,8 @@ static int woomera_message_parse(switch_socket_t *fd, woomera_message * wmsg, in
|
||||
|
||||
if (event_queue && switch_test_flag(wmsg, WFLAG_EVENT)) {
|
||||
if (globals.debug) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Queue Event: {%s} [%s]\n", profile->name, wmsg->command);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Queue Event: {%s} [%s]\n", profile->name,
|
||||
wmsg->command);
|
||||
}
|
||||
/* we don't want events we want a reply so we will stash them for later */
|
||||
woomera_enqueue_event(event_queue, wmsg);
|
||||
@@ -801,7 +807,8 @@ static int connect_woomera(switch_socket_t **new_sock, woomera_profile * profile
|
||||
|
||||
switch_sockaddr_t *sa;
|
||||
|
||||
if (switch_sockaddr_info_get(&sa, profile->woomera_host, AF_INET, profile->woomera_port, 0, module_pool) != SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_sockaddr_info_get(&sa, profile->woomera_host, AF_INET, profile->woomera_port, 0, module_pool) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -809,8 +816,8 @@ static int connect_woomera(switch_socket_t **new_sock, woomera_profile * profile
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch_socket_timeout_set((*new_sock), 10000000);
|
||||
switch_socket_opt_set((*new_sock), SWITCH_SO_KEEPALIVE, 1);
|
||||
switch_socket_timeout_set((*new_sock), 10000000);
|
||||
switch_socket_opt_set((*new_sock), SWITCH_SO_KEEPALIVE, 1);
|
||||
|
||||
/*
|
||||
status = switch_socket_bind((*new_sock), sa);
|
||||
@@ -851,8 +858,8 @@ static int woomera_locate_socket(woomera_profile * profile, switch_socket_t **wo
|
||||
if (!woomera_profile_thread_running(profile, 0, 0)) {
|
||||
break;
|
||||
}
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "{%s} Cannot Reconnect to Woomera! retry in 5 seconds\n",
|
||||
profile->name);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
||||
"{%s} Cannot Reconnect to Woomera! retry in 5 seconds\n", profile->name);
|
||||
switch_sleep(WOOMERA_RECONNECT_TIME);
|
||||
}
|
||||
|
||||
@@ -861,7 +868,8 @@ static int woomera_locate_socket(woomera_profile * profile, switch_socket_t **wo
|
||||
woomera_printf(profile, *woomera_socket, "LISTEN%s", WOOMERA_RECORD_SEPERATOR);
|
||||
if (woomera_message_parse(*woomera_socket,
|
||||
&wmsg, WOOMERA_HARD_TIMEOUT, profile, &profile->event_queue) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ALERT, "{%s} HELP! Woomera is broken!\n", profile->name);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ALERT, "{%s} HELP! Woomera is broken!\n",
|
||||
profile->name);
|
||||
globals.panic = 1;
|
||||
woomera_profile_thread_running(&default_profile, 1, 0);
|
||||
switch_sleep(WOOMERA_RECONNECT_TIME);
|
||||
@@ -890,7 +898,8 @@ static int tech_create_read_socket(private_object * tech_pvt)
|
||||
tech_pvt->port = globals.next_woomera_port = WOOMERA_MIN_PORT;
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "connect %s:%d\n", tech_pvt->profile->audio_ip, tech_pvt->port);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "connect %s:%d\n", tech_pvt->profile->audio_ip,
|
||||
tech_pvt->port);
|
||||
//tech_pvt->udp_socket = create_udp_socket(tech_pvt->profile->audio_ip, tech_pvt->port, &tech_pvt->udpread, 0);
|
||||
|
||||
switch_sockaddr_info_get(&tech_pvt->udpread, tech_pvt->profile->audio_ip, SWITCH_UNSPEC, tech_pvt->port, 0, pool);
|
||||
@@ -938,7 +947,7 @@ static int tech_activate(private_object * tech_pvt)
|
||||
if (woomera_message_parse(tech_pvt->command_channel,
|
||||
&wmsg, WOOMERA_HARD_TIMEOUT, tech_pvt->profile, &tech_pvt->event_queue) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ALERT, "{%s} HELP! Woomera is broken!\n",
|
||||
tech_pvt->profile->name);
|
||||
tech_pvt->profile->name);
|
||||
switch_set_flag_locked(tech_pvt, TFLAG_ABORT);
|
||||
globals.panic = 1;
|
||||
}
|
||||
@@ -998,7 +1007,7 @@ static void *woomera_channel_thread_run(switch_thread_t *thread, void *obj)
|
||||
(tech_pvt->command_channel, &wmsg, WOOMERA_HARD_TIMEOUT, tech_pvt->profile,
|
||||
&tech_pvt->event_queue) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ALERT, "{%s} HELP! Woomera is broken!\n",
|
||||
tech_pvt->profile->name);
|
||||
tech_pvt->profile->name);
|
||||
switch_set_flag_locked(tech_pvt, TFLAG_ABORT);
|
||||
globals.panic = 1;
|
||||
continue;
|
||||
@@ -1014,7 +1023,7 @@ static void *woomera_channel_thread_run(switch_thread_t *thread, void *obj)
|
||||
(tech_pvt->command_channel, &wmsg, WOOMERA_HARD_TIMEOUT, tech_pvt->profile,
|
||||
&tech_pvt->event_queue) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ALERT, "{%s} HELP! Woomera is broken!\n",
|
||||
tech_pvt->profile->name);
|
||||
tech_pvt->profile->name);
|
||||
switch_set_flag_locked(tech_pvt, TFLAG_ABORT);
|
||||
globals.panic = 1;
|
||||
continue;
|
||||
@@ -1095,7 +1104,8 @@ static void *woomera_channel_thread_run(switch_thread_t *thread, void *obj)
|
||||
if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
|
||||
NULL,
|
||||
tech_pvt->profile->dialplan,
|
||||
cid_name, cid_num, ip, NULL, NULL, NULL, (char *)modname, NULL, exten)) != 0) {
|
||||
cid_name, cid_num, ip, NULL, NULL, NULL,
|
||||
(char *) modname, NULL, exten)) != 0) {
|
||||
char name[128];
|
||||
snprintf(name, sizeof(name), "Woomera/%s-%04x", tech_pvt->caller_profile->destination_number,
|
||||
rand() & 0xffff);
|
||||
@@ -1115,7 +1125,7 @@ static void *woomera_channel_thread_run(switch_thread_t *thread, void *obj)
|
||||
if (woomera_message_parse(tech_pvt->command_channel,
|
||||
&wmsg, WOOMERA_HARD_TIMEOUT, tech_pvt->profile, &tech_pvt->event_queue) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ALERT, "{%s} HELP! Woomera is broken!\n",
|
||||
tech_pvt->profile->name);
|
||||
tech_pvt->profile->name);
|
||||
switch_set_flag_locked(tech_pvt, TFLAG_ABORT);
|
||||
globals.panic = 1;
|
||||
continue;
|
||||
@@ -1135,7 +1145,7 @@ static void *woomera_channel_thread_run(switch_thread_t *thread, void *obj)
|
||||
if ((ptr = strchr(ip, '/')) != 0) {
|
||||
*ptr = '\0';
|
||||
ptr++;
|
||||
port = (switch_port_t)atoi(ptr);
|
||||
port = (switch_port_t) atoi(ptr);
|
||||
}
|
||||
/* Move Channel's State Machine to RING */
|
||||
switch_channel_answer(channel);
|
||||
@@ -1150,8 +1160,8 @@ static void *woomera_channel_thread_run(switch_thread_t *thread, void *obj)
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
if (globals.debug) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
|
||||
WOOMERA_DEBUG_PREFIX "{%s} Cannot resolve %s\n",
|
||||
tech_pvt->profile->name, ip);
|
||||
WOOMERA_DEBUG_PREFIX "{%s} Cannot resolve %s\n",
|
||||
tech_pvt->profile->name, ip);
|
||||
}
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_NETWORK_OUT_OF_ORDER);
|
||||
}
|
||||
@@ -1160,12 +1170,12 @@ static void *woomera_channel_thread_run(switch_thread_t *thread, void *obj)
|
||||
}
|
||||
if (globals.debug > 2) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, WOOMERA_DEBUG_PREFIX "CHECK {%s}(%d)\n",
|
||||
tech_pvt->profile->name, res);
|
||||
tech_pvt->profile->name, res);
|
||||
}
|
||||
}
|
||||
if (globals.debug > 1) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, WOOMERA_DEBUG_PREFIX "Monitor thread for %s done.\n",
|
||||
tech_pvt->profile->name);
|
||||
tech_pvt->profile->name);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -1204,7 +1214,7 @@ static void *woomera_thread_run(void *obj)
|
||||
break;
|
||||
}
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Woomera Thread Up {%s} %s/%d\n", profile->name,
|
||||
profile->woomera_host, profile->woomera_port);
|
||||
profile->woomera_host, profile->woomera_port);
|
||||
|
||||
}
|
||||
|
||||
@@ -1221,18 +1231,18 @@ static void *woomera_thread_run(void *obj)
|
||||
|
||||
if ((((res = woomera_dequeue_event(&profile->event_queue, &wmsg)) != 0) ||
|
||||
((res = woomera_message_parse(profile->woomera_socket, &wmsg,
|
||||
/* if we are not stingy with threads we can block forever */
|
||||
0, profile, NULL))) != 0)) {
|
||||
/* if we are not stingy with threads we can block forever */
|
||||
0, profile, NULL))) != 0)) {
|
||||
if (res < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ALERT, "{%s} HELP! I lost my connection to woomera!\n",
|
||||
profile->name);
|
||||
profile->name);
|
||||
woomera_socket_close(&profile->woomera_socket);
|
||||
|
||||
//global_set_flag(TFLAG_ABORT);
|
||||
globals.panic = 1;
|
||||
continue;
|
||||
|
||||
/* Can't get to the following code --Commented out for now.*/
|
||||
/* Can't get to the following code --Commented out for now. */
|
||||
/* if (profile->woomera_socket)
|
||||
if (switch_test_flag(profile, PFLAG_INBOUND)) {
|
||||
woomera_printf(profile, profile->woomera_socket, "LISTEN%s", WOOMERA_RECORD_SEPERATOR);
|
||||
@@ -1268,9 +1278,11 @@ static void *woomera_thread_run(void *obj)
|
||||
switch_core_session_add_stream(session, NULL);
|
||||
|
||||
if ((tech_pvt =
|
||||
(struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object))) != 0) {
|
||||
(struct private_object *) switch_core_session_alloc(session,
|
||||
sizeof(struct private_object))) != 0) {
|
||||
memset(tech_pvt, 0, sizeof(*tech_pvt));
|
||||
switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
|
||||
switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED,
|
||||
switch_core_session_get_pool(session));
|
||||
tech_pvt->profile = &default_profile;
|
||||
channel = switch_core_session_get_channel(session);
|
||||
switch_core_session_set_private(session, tech_pvt);
|
||||
@@ -1287,7 +1299,8 @@ static void *woomera_thread_run(void *obj)
|
||||
}
|
||||
|
||||
if (globals.debug > 2) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Main Thread {%s} Select Return %d\n", profile->name, res);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Main Thread {%s} Select Return %d\n",
|
||||
profile->name, res);
|
||||
}
|
||||
|
||||
switch_yield(100);
|
||||
@@ -1326,7 +1339,8 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
struct woomera_profile *profile = &default_profile;
|
||||
@@ -1346,7 +1360,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
|
||||
strncpy(profile->dialplan, "default", sizeof(profile->dialplan) - 1);
|
||||
strncpy(profile->audio_ip, "127.0.0.1", sizeof(profile->audio_ip) - 1);
|
||||
strncpy(profile->woomera_host, "127.0.0.1", sizeof(profile->woomera_host) - 1);
|
||||
profile->woomera_port = (switch_port_t)42420;
|
||||
profile->woomera_port = (switch_port_t) 42420;
|
||||
|
||||
if ((settings = switch_xml_child(cfg, "settings"))) {
|
||||
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
|
||||
@@ -1371,7 +1385,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
|
||||
} else if (!strcmp(var, "host")) {
|
||||
strncpy(profile->woomera_host, val, sizeof(profile->woomera_host) - 1);
|
||||
} else if (!strcmp(var, "port")) {
|
||||
profile->woomera_port = (switch_port_t)atoi(val);
|
||||
profile->woomera_port = (switch_port_t) atoi(val);
|
||||
} else if (!strcmp(var, "disabled")) {
|
||||
if (atoi(val) > 0) {
|
||||
switch_set_flag(profile, PFLAG_DISABLED);
|
||||
|
||||
@@ -46,8 +46,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
struct switch_mod_cdr_newchannel_t
|
||||
{
|
||||
struct switch_mod_cdr_newchannel_t {
|
||||
switch_core_session_t *session;
|
||||
switch_channel_t *channel;
|
||||
//switch_channel_timetable_t *timetable;
|
||||
@@ -57,7 +56,7 @@ struct switch_mod_cdr_newchannel_t
|
||||
//bool originate;
|
||||
};
|
||||
|
||||
enum switch_mod_cdr_sql_types_t { CDR_INTEGER,CDR_STRING,CDR_DECIMAL,CDR_DOUBLE,CDR_TINY };
|
||||
enum switch_mod_cdr_sql_types_t { CDR_INTEGER, CDR_STRING, CDR_DECIMAL, CDR_DOUBLE, CDR_TINY };
|
||||
|
||||
#ifdef WIN32
|
||||
#define STDCALL __stdcall
|
||||
@@ -65,54 +64,54 @@ enum switch_mod_cdr_sql_types_t { CDR_INTEGER,CDR_STRING,CDR_DECIMAL,CDR_DOUBLE,
|
||||
#define STDCALL
|
||||
#endif
|
||||
|
||||
typedef switch_status_t (STDCALL *modcdr_time_convert_t)(switch_time_exp_t*,switch_time_t);
|
||||
typedef switch_status_t (STDCALL * modcdr_time_convert_t) (switch_time_exp_t *, switch_time_t);
|
||||
|
||||
class BaseCDR {
|
||||
public:
|
||||
BaseCDR();
|
||||
virtual ~BaseCDR();
|
||||
BaseCDR(switch_mod_cdr_newchannel_t *newchannel);
|
||||
virtual void connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settings, switch_xml_t& param) = 0;
|
||||
virtual void disconnect() = 0;
|
||||
virtual bool process_record() = 0;
|
||||
virtual bool is_activated() = 0;
|
||||
virtual void tempdump_record() = 0;
|
||||
virtual void reread_tempdumped_records() = 0;
|
||||
virtual std::string get_display_name() = 0; // Get the module name
|
||||
protected:
|
||||
void parse_channel_variables_xconfig(std::string& unparsed,std::list<std::string>& chanvarslist,bool fixed);
|
||||
void parse_channel_variables_xconfig(std::string& unparsed,std::list<std::string>& chanvarslist,std::vector<switch_mod_cdr_sql_types_t>& chanvars_fixed_types); // Typically used for SQL types
|
||||
void process_channel_variables(const std::list<std::string>& stringlist,const std::list<std::string>& fixedlist,switch_channel_t *channel,bool repeat = 1); //This is used for supplemental chanvars
|
||||
void process_channel_variables(const std::list<std::string>& stringlist,switch_channel_t *channel); // This is used for fixed chanvars
|
||||
void escape_string(std::string& src);
|
||||
std::string escape_chararray(char* src);
|
||||
switch_time_t callstartdate;
|
||||
switch_time_t callanswerdate;
|
||||
switch_time_t callenddate;
|
||||
switch_time_t calltransferdate;
|
||||
switch_call_cause_t hangupcause;
|
||||
char *hangupcause_text;
|
||||
char clid[80];
|
||||
bool originated; // Did they originate this call?
|
||||
char dialplan[80];
|
||||
char myuuid[37]; // 36 + 1 to hold \0
|
||||
char destuuid[37];
|
||||
char src[80];
|
||||
char dst[80];
|
||||
char srcchannel[80];
|
||||
char dstchannel[80];
|
||||
char ani[80];
|
||||
char aniii[80];
|
||||
char network_addr[40];
|
||||
char lastapp[80];
|
||||
char lastdata[255];
|
||||
switch_time_t billusec; // Yes, you heard me, we're measuring in microseconds
|
||||
int disposition; // Currently 0 = Busy/Unanswered, 1 = Answered
|
||||
int amaflags;
|
||||
switch_core_session_t *coresession;
|
||||
std::list<std::pair<std::string,std::string> > chanvars_fixed;
|
||||
std::map<std::string,std::string> chanvars_supp;
|
||||
bool errorstate; // True if there is an error writing the log
|
||||
public:
|
||||
BaseCDR();
|
||||
virtual ~ BaseCDR();
|
||||
BaseCDR(switch_mod_cdr_newchannel_t * newchannel);
|
||||
virtual void connect(switch_xml_t & cfg, switch_xml_t & xml, switch_xml_t & settings, switch_xml_t & param) = 0;
|
||||
virtual void disconnect() = 0;
|
||||
virtual bool process_record() = 0;
|
||||
virtual bool is_activated() = 0;
|
||||
virtual void tempdump_record() = 0;
|
||||
virtual void reread_tempdumped_records() = 0;
|
||||
virtual std::string get_display_name() = 0; // Get the module name
|
||||
protected:
|
||||
void parse_channel_variables_xconfig(std::string & unparsed, std::list < std::string > &chanvarslist, bool fixed);
|
||||
void parse_channel_variables_xconfig(std::string & unparsed, std::list < std::string > &chanvarslist, std::vector < switch_mod_cdr_sql_types_t > &chanvars_fixed_types); // Typically used for SQL types
|
||||
void process_channel_variables(const std::list < std::string > &stringlist, const std::list < std::string > &fixedlist, switch_channel_t *channel, bool repeat = 1); //This is used for supplemental chanvars
|
||||
void process_channel_variables(const std::list < std::string > &stringlist, switch_channel_t *channel); // This is used for fixed chanvars
|
||||
void escape_string(std::string & src);
|
||||
std::string escape_chararray(char *src);
|
||||
switch_time_t callstartdate;
|
||||
switch_time_t callanswerdate;
|
||||
switch_time_t callenddate;
|
||||
switch_time_t calltransferdate;
|
||||
switch_call_cause_t hangupcause;
|
||||
char *hangupcause_text;
|
||||
char clid[80];
|
||||
bool originated; // Did they originate this call?
|
||||
char dialplan[80];
|
||||
char myuuid[37]; // 36 + 1 to hold \0
|
||||
char destuuid[37];
|
||||
char src[80];
|
||||
char dst[80];
|
||||
char srcchannel[80];
|
||||
char dstchannel[80];
|
||||
char ani[80];
|
||||
char aniii[80];
|
||||
char network_addr[40];
|
||||
char lastapp[80];
|
||||
char lastdata[255];
|
||||
switch_time_t billusec; // Yes, you heard me, we're measuring in microseconds
|
||||
int disposition; // Currently 0 = Busy/Unanswered, 1 = Answered
|
||||
int amaflags;
|
||||
switch_core_session_t *coresession;
|
||||
std::list < std::pair < std::string, std::string > >chanvars_fixed;
|
||||
std::map < std::string, std::string > chanvars_supp;
|
||||
bool errorstate; // True if there is an error writing the log
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -42,34 +42,32 @@
|
||||
#ifdef __cplusplus
|
||||
#include <vector>
|
||||
|
||||
template<class T> BaseCDR* basecdr_factory(switch_mod_cdr_newchannel_t *newchannel)
|
||||
template < class T > BaseCDR * basecdr_factory(switch_mod_cdr_newchannel_t * newchannel)
|
||||
{
|
||||
return new T(newchannel);
|
||||
}
|
||||
|
||||
typedef BaseCDR* (*basecdr_creator)(switch_mod_cdr_newchannel_t *newchannel);
|
||||
typedef BaseCDR *(*basecdr_creator) (switch_mod_cdr_newchannel_t * newchannel);
|
||||
|
||||
class BaseRegistry
|
||||
{
|
||||
private:
|
||||
std::vector<basecdr_creator> m_bases; // Stores all modules
|
||||
std::vector<basecdr_creator> active_bases; // Stores only active modules
|
||||
public:
|
||||
typedef std::vector<basecdr_creator>::iterator iterator;
|
||||
static BaseRegistry& get();
|
||||
void add(basecdr_creator);
|
||||
void reset_active(); // Clears the active vector for reloading of configuration.
|
||||
void add_active(iterator);
|
||||
iterator begin();
|
||||
iterator end();
|
||||
iterator active_begin();
|
||||
iterator active_end();
|
||||
class BaseRegistry {
|
||||
private:
|
||||
std::vector < basecdr_creator > m_bases; // Stores all modules
|
||||
std::vector < basecdr_creator > active_bases; // Stores only active modules
|
||||
public:
|
||||
typedef std::vector < basecdr_creator >::iterator iterator;
|
||||
static BaseRegistry & get();
|
||||
void add(basecdr_creator);
|
||||
void reset_active(); // Clears the active vector for reloading of configuration.
|
||||
void add_active(iterator);
|
||||
iterator begin();
|
||||
iterator end();
|
||||
iterator active_begin();
|
||||
iterator active_end();
|
||||
};
|
||||
|
||||
class BaseRegistration
|
||||
{
|
||||
public:
|
||||
BaseRegistration(basecdr_creator);
|
||||
class BaseRegistration {
|
||||
public:
|
||||
BaseRegistration(basecdr_creator);
|
||||
};
|
||||
|
||||
#define AUTO_REGISTER_BASECDR(basecdr) BaseRegistration _basecdr_registration_ ## basecdr(&basecdr_factory<basecdr>);
|
||||
|
||||
@@ -51,11 +51,11 @@ CDRContainer::process_records() will iterate thru the queue and commit the recor
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
class CDRContainer {
|
||||
public:
|
||||
class CDRContainer {
|
||||
public:
|
||||
CDRContainer();
|
||||
CDRContainer(switch_memory_pool_t *module_pool);
|
||||
~CDRContainer();
|
||||
~CDRContainer();
|
||||
void add_cdr(switch_core_session_t *session);
|
||||
void process_records();
|
||||
#ifdef SWITCH_QUEUE_ENHANCED
|
||||
@@ -65,21 +65,19 @@ class CDRContainer {
|
||||
#endif
|
||||
void active(switch_stream_handle_t *stream);
|
||||
void available(switch_stream_handle_t *stream);
|
||||
protected:
|
||||
private:
|
||||
switch_xml_t cfg, xml, settings, param;
|
||||
protected:
|
||||
private:
|
||||
switch_xml_t cfg, xml, settings, param;
|
||||
switch_queue_t *cdrqueue;
|
||||
std::string tempfilepath;
|
||||
std::string tempfilepath;
|
||||
char configfile[13];
|
||||
bool queue_paused;
|
||||
};
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c++
|
||||
|
||||
@@ -44,38 +44,38 @@
|
||||
#ifndef CSVCDR
|
||||
#define CSVCDR
|
||||
|
||||
class CsvCDR : public BaseCDR {
|
||||
public:
|
||||
CsvCDR();
|
||||
CsvCDR(switch_mod_cdr_newchannel_t *newchannel);
|
||||
//CsvCDR(const CsvCDR& copyFrom);
|
||||
virtual ~CsvCDR();
|
||||
virtual bool process_record();
|
||||
virtual void connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settings, switch_xml_t& param); // connect and disconnect need to be static because we're persisting connections until shutdown
|
||||
virtual void disconnect();
|
||||
virtual bool is_activated();
|
||||
virtual void tempdump_record();
|
||||
virtual void reread_tempdumped_records();
|
||||
virtual std::string get_display_name();
|
||||
class CsvCDR:public BaseCDR {
|
||||
public:
|
||||
CsvCDR();
|
||||
CsvCDR(switch_mod_cdr_newchannel_t * newchannel);
|
||||
//CsvCDR(const CsvCDR& copyFrom);
|
||||
virtual ~ CsvCDR();
|
||||
virtual bool process_record();
|
||||
virtual void connect(switch_xml_t & cfg, switch_xml_t & xml, switch_xml_t & settings, switch_xml_t & param); // connect and disconnect need to be static because we're persisting connections until shutdown
|
||||
virtual void disconnect();
|
||||
virtual bool is_activated();
|
||||
virtual void tempdump_record();
|
||||
virtual void reread_tempdumped_records();
|
||||
virtual std::string get_display_name();
|
||||
|
||||
private:
|
||||
static bool activated; // Is this module activated?
|
||||
static bool connectionstate; // What is the status of the connection?
|
||||
static bool logchanvars;
|
||||
static modcdr_time_convert_t convert_time;
|
||||
static bool repeat_fixed_in_supp; // Repeat the fixed chanvars in the supplemental?
|
||||
static std::string outputfile_path; // The directory we'll dump these into
|
||||
static std::list<std::string> chanvars_fixed_list; // Normally this would be used, but not in this class
|
||||
static std::list<std::string> chanvars_supp_list; // This will hold the list for all chanvars here
|
||||
static std::string display_name;
|
||||
char formattedcallstartdate[100];
|
||||
char formattedcallanswerdate[100];
|
||||
char formattedcalltransferdate[100];
|
||||
char formattedcallenddate[100];
|
||||
static std::ofstream outputfile;
|
||||
static std::ofstream::pos_type filesize_limit;
|
||||
void check_file_size_and_open(); // Checks the size of the file, and if it's greater than size allowed, rotates it.
|
||||
void open_file();
|
||||
private:
|
||||
static bool activated; // Is this module activated?
|
||||
static bool connectionstate; // What is the status of the connection?
|
||||
static bool logchanvars;
|
||||
static modcdr_time_convert_t convert_time;
|
||||
static bool repeat_fixed_in_supp; // Repeat the fixed chanvars in the supplemental?
|
||||
static std::string outputfile_path; // The directory we'll dump these into
|
||||
static std::list < std::string > chanvars_fixed_list; // Normally this would be used, but not in this class
|
||||
static std::list < std::string > chanvars_supp_list; // This will hold the list for all chanvars here
|
||||
static std::string display_name;
|
||||
char formattedcallstartdate[100];
|
||||
char formattedcallanswerdate[100];
|
||||
char formattedcalltransferdate[100];
|
||||
char formattedcallenddate[100];
|
||||
static std::ofstream outputfile;
|
||||
static std::ofstream::pos_type filesize_limit;
|
||||
void check_file_size_and_open(); // Checks the size of the file, and if it's greater than size allowed, rotates it.
|
||||
void open_file();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -50,37 +50,37 @@
|
||||
#ifndef CURLCDR
|
||||
#define CURLCDR
|
||||
|
||||
class CurlCDR : public BaseCDR {
|
||||
public:
|
||||
CurlCDR();
|
||||
CurlCDR(switch_mod_cdr_newchannel_t *newchannel);
|
||||
//CurlCDR(const CurlCDR& copyFrom);
|
||||
virtual ~CurlCDR();
|
||||
virtual bool process_record();
|
||||
virtual void connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settings, switch_xml_t& param); // connect and disconnect need to be static because we're persisting connections until shutdown
|
||||
virtual void disconnect();
|
||||
virtual bool is_activated();
|
||||
virtual void tempdump_record();
|
||||
virtual void reread_tempdumped_records();
|
||||
virtual std::string get_display_name();
|
||||
virtual std::string itos(int i);
|
||||
virtual std::string lltos(long long ll);
|
||||
class CurlCDR:public BaseCDR {
|
||||
public:
|
||||
CurlCDR();
|
||||
CurlCDR(switch_mod_cdr_newchannel_t * newchannel);
|
||||
//CurlCDR(const CurlCDR& copyFrom);
|
||||
virtual ~ CurlCDR();
|
||||
virtual bool process_record();
|
||||
virtual void connect(switch_xml_t & cfg, switch_xml_t & xml, switch_xml_t & settings, switch_xml_t & param); // connect and disconnect need to be static because we're persisting connections until shutdown
|
||||
virtual void disconnect();
|
||||
virtual bool is_activated();
|
||||
virtual void tempdump_record();
|
||||
virtual void reread_tempdumped_records();
|
||||
virtual std::string get_display_name();
|
||||
virtual std::string itos(int i);
|
||||
virtual std::string lltos(long long ll);
|
||||
|
||||
private:
|
||||
static bool activated; // Is this module activated?
|
||||
static bool connectionstate; // What is the status of the connection?
|
||||
static bool logchanvars;
|
||||
static modcdr_time_convert_t convert_time;
|
||||
static const char *gateway_url; // The URL to send data to
|
||||
static const char *gateway_credentials; // The credentials for http auth
|
||||
static std::list<std::string> chanvars_fixed_list; // Normally this would be used, but not in this class
|
||||
static std::list<std::string> chanvars_supp_list; // This will hold the list for all chanvars here
|
||||
static std::string display_name;
|
||||
static std::string postdata;
|
||||
char formattedcallstartdate[100];
|
||||
char formattedcallanswerdate[100];
|
||||
char formattedcalltransferdate[100];
|
||||
char formattedcallenddate[100];
|
||||
private:
|
||||
static bool activated; // Is this module activated?
|
||||
static bool connectionstate; // What is the status of the connection?
|
||||
static bool logchanvars;
|
||||
static modcdr_time_convert_t convert_time;
|
||||
static const char *gateway_url; // The URL to send data to
|
||||
static const char *gateway_credentials; // The credentials for http auth
|
||||
static std::list < std::string > chanvars_fixed_list; // Normally this would be used, but not in this class
|
||||
static std::list < std::string > chanvars_supp_list; // This will hold the list for all chanvars here
|
||||
static std::string display_name;
|
||||
static std::string postdata;
|
||||
char formattedcallstartdate[100];
|
||||
char formattedcallanswerdate[100];
|
||||
char formattedcalltransferdate[100];
|
||||
char formattedcallenddate[100];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -41,66 +41,66 @@
|
||||
#ifndef MYSQLCDR
|
||||
#define MYSQLCDR
|
||||
|
||||
class MysqlCDR : public BaseCDR {
|
||||
public:
|
||||
MysqlCDR();
|
||||
MysqlCDR(switch_mod_cdr_newchannel_t *newchannel);
|
||||
//MysqlCDR(const MysqlCDR& copyFrom);
|
||||
virtual ~MysqlCDR();
|
||||
virtual bool process_record();
|
||||
virtual void connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settings, switch_xml_t& param);
|
||||
virtual void disconnect();
|
||||
virtual bool is_activated();
|
||||
virtual void tempdump_record();
|
||||
virtual void reread_tempdumped_records();
|
||||
virtual std::string get_display_name();
|
||||
class MysqlCDR:public BaseCDR {
|
||||
public:
|
||||
MysqlCDR();
|
||||
MysqlCDR(switch_mod_cdr_newchannel_t * newchannel);
|
||||
//MysqlCDR(const MysqlCDR& copyFrom);
|
||||
virtual ~ MysqlCDR();
|
||||
virtual bool process_record();
|
||||
virtual void connect(switch_xml_t & cfg, switch_xml_t & xml, switch_xml_t & settings, switch_xml_t & param);
|
||||
virtual void disconnect();
|
||||
virtual bool is_activated();
|
||||
virtual void tempdump_record();
|
||||
virtual void reread_tempdumped_records();
|
||||
virtual std::string get_display_name();
|
||||
|
||||
private:
|
||||
static bool activated;
|
||||
static char sql_query[1024];
|
||||
static std::string tmp_sql_query; // Object must exist to bind the statement, this used for generating the sql
|
||||
static char sql_query_chanvars[100];
|
||||
static MYSQL *conn;
|
||||
static MYSQL_STMT *stmt;
|
||||
static MYSQL_STMT *stmt_chanvars;
|
||||
static bool connectionstate;
|
||||
static bool logchanvars;
|
||||
static std::list<std::string> chanvars_fixed_list;
|
||||
static std::vector<switch_mod_cdr_sql_types_t> chanvars_fixed_types;
|
||||
static std::list<std::string> chanvars_supp_list; // The supplemental list
|
||||
static bool repeat_fixed_in_supp;
|
||||
static char hostname[255];
|
||||
static char username[255];
|
||||
static char dbname[255];
|
||||
static char password[255];
|
||||
static modcdr_time_convert_t convert_time;
|
||||
static std::string display_name;
|
||||
//static fstream tmpfile;
|
||||
std::vector<MYSQL_BIND> bindme;
|
||||
//MYSQL_BIND *bindme;
|
||||
MYSQL_TIME my_callstartdate;
|
||||
MYSQL_TIME my_callanswerdate;
|
||||
MYSQL_TIME my_calltransferdate;
|
||||
MYSQL_TIME my_callenddate;
|
||||
// Why all these long unsigned int's? MySQL's prep statement API expects these to actually exist and not just be params passed to the function calls. The are to measure the length of actual data in the char* arrays.
|
||||
long unsigned int clid_length;
|
||||
long unsigned int dialplan_length;
|
||||
long unsigned int myuuid_length;
|
||||
long unsigned int destuuid_length;
|
||||
long unsigned int src_length;
|
||||
long unsigned int dst_length;
|
||||
long unsigned int srcchannel_length;
|
||||
long unsigned int dstchannel_length;
|
||||
long unsigned int ani_length;
|
||||
long unsigned int aniii_length;
|
||||
long unsigned int lastapp_length;
|
||||
long unsigned int lastdata_length;
|
||||
long unsigned int network_addr_length;
|
||||
// Now a couple internal methods
|
||||
template <typename T> void add_parameter(T& param, enum_field_types type, bool *is_null=0);
|
||||
void add_string_parameter(char* param, long unsigned int& param_length, enum_field_types type, bool* is_null=0);
|
||||
void set_mysql_time(switch_time_exp_t& param, MYSQL_TIME& destination);
|
||||
void connect_to_database();
|
||||
private:
|
||||
static bool activated;
|
||||
static char sql_query[1024];
|
||||
static std::string tmp_sql_query; // Object must exist to bind the statement, this used for generating the sql
|
||||
static char sql_query_chanvars[100];
|
||||
static MYSQL *conn;
|
||||
static MYSQL_STMT *stmt;
|
||||
static MYSQL_STMT *stmt_chanvars;
|
||||
static bool connectionstate;
|
||||
static bool logchanvars;
|
||||
static std::list < std::string > chanvars_fixed_list;
|
||||
static std::vector < switch_mod_cdr_sql_types_t > chanvars_fixed_types;
|
||||
static std::list < std::string > chanvars_supp_list; // The supplemental list
|
||||
static bool repeat_fixed_in_supp;
|
||||
static char hostname[255];
|
||||
static char username[255];
|
||||
static char dbname[255];
|
||||
static char password[255];
|
||||
static modcdr_time_convert_t convert_time;
|
||||
static std::string display_name;
|
||||
//static fstream tmpfile;
|
||||
std::vector < MYSQL_BIND > bindme;
|
||||
//MYSQL_BIND *bindme;
|
||||
MYSQL_TIME my_callstartdate;
|
||||
MYSQL_TIME my_callanswerdate;
|
||||
MYSQL_TIME my_calltransferdate;
|
||||
MYSQL_TIME my_callenddate;
|
||||
// Why all these long unsigned int's? MySQL's prep statement API expects these to actually exist and not just be params passed to the function calls. The are to measure the length of actual data in the char* arrays.
|
||||
long unsigned int clid_length;
|
||||
long unsigned int dialplan_length;
|
||||
long unsigned int myuuid_length;
|
||||
long unsigned int destuuid_length;
|
||||
long unsigned int src_length;
|
||||
long unsigned int dst_length;
|
||||
long unsigned int srcchannel_length;
|
||||
long unsigned int dstchannel_length;
|
||||
long unsigned int ani_length;
|
||||
long unsigned int aniii_length;
|
||||
long unsigned int lastapp_length;
|
||||
long unsigned int lastdata_length;
|
||||
long unsigned int network_addr_length;
|
||||
// Now a couple internal methods
|
||||
template < typename T > void add_parameter(T & param, enum_field_types type, bool * is_null = 0);
|
||||
void add_string_parameter(char *param, long unsigned int ¶m_length, enum_field_types type, bool * is_null = 0);
|
||||
void set_mysql_time(switch_time_exp_t ¶m, MYSQL_TIME & destination);
|
||||
void connect_to_database();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -52,53 +52,53 @@
|
||||
#ifndef ODBCCDR
|
||||
#define ODBCCDR
|
||||
|
||||
class OdbcCDR : public BaseCDR {
|
||||
public:
|
||||
OdbcCDR();
|
||||
OdbcCDR(switch_mod_cdr_newchannel_t *newchannel);
|
||||
//OdbcCDR(const MysqlCDR& copyFrom);
|
||||
virtual ~OdbcCDR();
|
||||
virtual bool process_record();
|
||||
virtual void connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settings, switch_xml_t& param);
|
||||
virtual void disconnect();
|
||||
virtual bool is_activated();
|
||||
virtual void tempdump_record();
|
||||
virtual void reread_tempdumped_records();
|
||||
virtual std::string get_display_name();
|
||||
class OdbcCDR:public BaseCDR {
|
||||
public:
|
||||
OdbcCDR();
|
||||
OdbcCDR(switch_mod_cdr_newchannel_t * newchannel);
|
||||
//OdbcCDR(const MysqlCDR& copyFrom);
|
||||
virtual ~ OdbcCDR();
|
||||
virtual bool process_record();
|
||||
virtual void connect(switch_xml_t & cfg, switch_xml_t & xml, switch_xml_t & settings, switch_xml_t & param);
|
||||
virtual void disconnect();
|
||||
virtual bool is_activated();
|
||||
virtual void tempdump_record();
|
||||
virtual void reread_tempdumped_records();
|
||||
virtual std::string get_display_name();
|
||||
|
||||
private:
|
||||
static bool activated;
|
||||
static char sql_query[1024];
|
||||
static modcdr_time_convert_t convert_time;
|
||||
static std::string display_name;
|
||||
static std::string tmp_sql_query; // Object must exist to bind the statement, this used for generating the sql
|
||||
static char sql_query_chanvars[355];
|
||||
static char sql_query_ping[10];
|
||||
static bool connectionstate;
|
||||
static bool logchanvars;
|
||||
static SQLHENV ODBC_env; /* global ODBC Environment */
|
||||
static SQLHDBC ODBC_con; /* global ODBC Connection Handle */
|
||||
static SQLHSTMT ODBC_stmt;
|
||||
static SQLHSTMT ODBC_stmt_chanvars;
|
||||
static SQLHSTMT ODBC_stmt_ping;
|
||||
static std::list<std::string> chanvars_fixed_list;
|
||||
static std::vector<switch_mod_cdr_sql_types_t> chanvars_fixed_types;
|
||||
static std::list<std::string> chanvars_supp_list; // The supplemental list
|
||||
static bool repeat_fixed_in_supp;
|
||||
static char dsn[255];
|
||||
static char hostname[255];
|
||||
static char username[255];
|
||||
static char dbname[255];
|
||||
static char password[255];
|
||||
static char tablename[255];
|
||||
static char tablename_chanvars[255];
|
||||
//static fstream tmpfile;
|
||||
char odbc_callstartdate[128];
|
||||
char odbc_callanswerdate[128];
|
||||
char odbc_calltransferdate[128];
|
||||
char odbc_callenddate[128];
|
||||
void disconnect_stage_1();
|
||||
void connect_to_database();
|
||||
private:
|
||||
static bool activated;
|
||||
static char sql_query[1024];
|
||||
static modcdr_time_convert_t convert_time;
|
||||
static std::string display_name;
|
||||
static std::string tmp_sql_query; // Object must exist to bind the statement, this used for generating the sql
|
||||
static char sql_query_chanvars[355];
|
||||
static char sql_query_ping[10];
|
||||
static bool connectionstate;
|
||||
static bool logchanvars;
|
||||
static SQLHENV ODBC_env; /* global ODBC Environment */
|
||||
static SQLHDBC ODBC_con; /* global ODBC Connection Handle */
|
||||
static SQLHSTMT ODBC_stmt;
|
||||
static SQLHSTMT ODBC_stmt_chanvars;
|
||||
static SQLHSTMT ODBC_stmt_ping;
|
||||
static std::list < std::string > chanvars_fixed_list;
|
||||
static std::vector < switch_mod_cdr_sql_types_t > chanvars_fixed_types;
|
||||
static std::list < std::string > chanvars_supp_list; // The supplemental list
|
||||
static bool repeat_fixed_in_supp;
|
||||
static char dsn[255];
|
||||
static char hostname[255];
|
||||
static char username[255];
|
||||
static char dbname[255];
|
||||
static char password[255];
|
||||
static char tablename[255];
|
||||
static char tablename_chanvars[255];
|
||||
//static fstream tmpfile;
|
||||
char odbc_callstartdate[128];
|
||||
char odbc_callanswerdate[128];
|
||||
char odbc_calltransferdate[128];
|
||||
char odbc_callenddate[128];
|
||||
void disconnect_stage_1();
|
||||
void connect_to_database();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -43,33 +43,33 @@
|
||||
#ifndef PDDCDR
|
||||
#define PDDMCDR
|
||||
|
||||
class PddCDR : public BaseCDR {
|
||||
public:
|
||||
PddCDR();
|
||||
PddCDR(switch_mod_cdr_newchannel_t *newchannel);
|
||||
virtual ~PddCDR();
|
||||
virtual bool process_record();
|
||||
virtual void connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settings, switch_xml_t& param); // connect and disconnect need to be static because we're persisting connections until shutdown
|
||||
virtual void disconnect();
|
||||
virtual bool is_activated();
|
||||
virtual void tempdump_record();
|
||||
virtual void reread_tempdumped_records();
|
||||
virtual std::string get_display_name();
|
||||
private:
|
||||
static bool activated; // Is this module activated?
|
||||
static bool connectionstate; // What is the status of the connection?
|
||||
static bool logchanvars;
|
||||
static modcdr_time_convert_t convert_time;
|
||||
static std::string outputfile_path; // The directory we'll dump these into
|
||||
static std::list<std::string> chanvars_fixed_list; // Normally this would be used, but not in this class
|
||||
static std::list<std::string> chanvars_supp_list; // This will hold the list for all chanvars here
|
||||
static std::string display_name;
|
||||
char formattedcallstartdate[100];
|
||||
char formattedcallanswerdate[100];
|
||||
char formattedcalltransferdate[100];
|
||||
char formattedcallenddate[100];
|
||||
std::string outputfile_name;
|
||||
std::ofstream outputfile;
|
||||
class PddCDR:public BaseCDR {
|
||||
public:
|
||||
PddCDR();
|
||||
PddCDR(switch_mod_cdr_newchannel_t * newchannel);
|
||||
virtual ~ PddCDR();
|
||||
virtual bool process_record();
|
||||
virtual void connect(switch_xml_t & cfg, switch_xml_t & xml, switch_xml_t & settings, switch_xml_t & param); // connect and disconnect need to be static because we're persisting connections until shutdown
|
||||
virtual void disconnect();
|
||||
virtual bool is_activated();
|
||||
virtual void tempdump_record();
|
||||
virtual void reread_tempdumped_records();
|
||||
virtual std::string get_display_name();
|
||||
private:
|
||||
static bool activated; // Is this module activated?
|
||||
static bool connectionstate; // What is the status of the connection?
|
||||
static bool logchanvars;
|
||||
static modcdr_time_convert_t convert_time;
|
||||
static std::string outputfile_path; // The directory we'll dump these into
|
||||
static std::list < std::string > chanvars_fixed_list; // Normally this would be used, but not in this class
|
||||
static std::list < std::string > chanvars_supp_list; // This will hold the list for all chanvars here
|
||||
static std::string display_name;
|
||||
char formattedcallstartdate[100];
|
||||
char formattedcallanswerdate[100];
|
||||
char formattedcalltransferdate[100];
|
||||
char formattedcallenddate[100];
|
||||
std::string outputfile_name;
|
||||
std::ofstream outputfile;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -39,43 +39,43 @@
|
||||
#ifndef SQLITECDR
|
||||
#define SQLITECDR
|
||||
|
||||
class SqliteCDR : public BaseCDR {
|
||||
public:
|
||||
SqliteCDR();
|
||||
SqliteCDR(switch_mod_cdr_newchannel_t *newchannel);
|
||||
//SqliteCDR(const SqliteCDR& copyFrom);
|
||||
virtual ~SqliteCDR();
|
||||
virtual bool process_record();
|
||||
virtual void connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settings, switch_xml_t& param);
|
||||
virtual void disconnect();
|
||||
virtual bool is_activated();
|
||||
virtual void tempdump_record();
|
||||
virtual void reread_tempdumped_records();
|
||||
virtual std::string get_display_name();
|
||||
class SqliteCDR:public BaseCDR {
|
||||
public:
|
||||
SqliteCDR();
|
||||
SqliteCDR(switch_mod_cdr_newchannel_t * newchannel);
|
||||
//SqliteCDR(const SqliteCDR& copyFrom);
|
||||
virtual ~ SqliteCDR();
|
||||
virtual bool process_record();
|
||||
virtual void connect(switch_xml_t & cfg, switch_xml_t & xml, switch_xml_t & settings, switch_xml_t & param);
|
||||
virtual void disconnect();
|
||||
virtual bool is_activated();
|
||||
virtual void tempdump_record();
|
||||
virtual void reread_tempdumped_records();
|
||||
virtual std::string get_display_name();
|
||||
|
||||
private:
|
||||
static bool activated;
|
||||
static char sql_query[1024];
|
||||
static std::string tmp_sql_query; // Object must exist to bind the statement, this used for generating the sql
|
||||
static char sql_query_chanvars[100];
|
||||
static std::string db_filename;
|
||||
static bool use_utc_time;
|
||||
switch_time_t sqlite_callstartdate;
|
||||
switch_time_t sqlite_callanswerdate;
|
||||
switch_time_t sqlite_calltransferdate;
|
||||
switch_time_t sqlite_callenddate;
|
||||
static switch_core_db_t *db;
|
||||
static switch_core_db_stmt_t *stmt;
|
||||
static switch_core_db_stmt_t *stmt_chanvars;
|
||||
static switch_core_db_stmt_t *stmt_begin;
|
||||
static switch_core_db_stmt_t *stmt_commit;
|
||||
static bool connectionstate;
|
||||
static bool logchanvars;
|
||||
static std::list<std::string> chanvars_fixed_list;
|
||||
static std::vector<switch_mod_cdr_sql_types_t> chanvars_fixed_types;
|
||||
static std::list<std::string> chanvars_supp_list; // The supplemental list
|
||||
static bool repeat_fixed_in_supp;
|
||||
static std::string display_name;
|
||||
private:
|
||||
static bool activated;
|
||||
static char sql_query[1024];
|
||||
static std::string tmp_sql_query; // Object must exist to bind the statement, this used for generating the sql
|
||||
static char sql_query_chanvars[100];
|
||||
static std::string db_filename;
|
||||
static bool use_utc_time;
|
||||
switch_time_t sqlite_callstartdate;
|
||||
switch_time_t sqlite_callanswerdate;
|
||||
switch_time_t sqlite_calltransferdate;
|
||||
switch_time_t sqlite_callenddate;
|
||||
static switch_core_db_t *db;
|
||||
static switch_core_db_stmt_t *stmt;
|
||||
static switch_core_db_stmt_t *stmt_chanvars;
|
||||
static switch_core_db_stmt_t *stmt_begin;
|
||||
static switch_core_db_stmt_t *stmt_commit;
|
||||
static bool connectionstate;
|
||||
static bool logchanvars;
|
||||
static std::list < std::string > chanvars_fixed_list;
|
||||
static std::vector < switch_mod_cdr_sql_types_t > chanvars_fixed_types;
|
||||
static std::list < std::string > chanvars_supp_list; // The supplemental list
|
||||
static bool repeat_fixed_in_supp;
|
||||
static std::string display_name;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -43,34 +43,34 @@
|
||||
#ifndef XMLCDR
|
||||
#define XMLCDR
|
||||
|
||||
class XmlCDR : public BaseCDR {
|
||||
public:
|
||||
XmlCDR();
|
||||
XmlCDR(switch_mod_cdr_newchannel_t *newchannel);
|
||||
virtual ~XmlCDR();
|
||||
virtual bool process_record();
|
||||
virtual void connect(switch_xml_t& cfg, switch_xml_t& xml, switch_xml_t& settings, switch_xml_t& param); // connect and disconnect need to be static because we're persisting connections until shutdown
|
||||
virtual void disconnect();
|
||||
virtual bool is_activated();
|
||||
virtual void tempdump_record();
|
||||
virtual void reread_tempdumped_records();
|
||||
virtual std::string get_display_name();
|
||||
class XmlCDR:public BaseCDR {
|
||||
public:
|
||||
XmlCDR();
|
||||
XmlCDR(switch_mod_cdr_newchannel_t * newchannel);
|
||||
virtual ~ XmlCDR();
|
||||
virtual bool process_record();
|
||||
virtual void connect(switch_xml_t & cfg, switch_xml_t & xml, switch_xml_t & settings, switch_xml_t & param); // connect and disconnect need to be static because we're persisting connections until shutdown
|
||||
virtual void disconnect();
|
||||
virtual bool is_activated();
|
||||
virtual void tempdump_record();
|
||||
virtual void reread_tempdumped_records();
|
||||
virtual std::string get_display_name();
|
||||
|
||||
private:
|
||||
static bool activated; // Is this module activated?
|
||||
static bool connectionstate; // What is the status of the connection?
|
||||
static bool logchanvars;
|
||||
static modcdr_time_convert_t convert_time;
|
||||
static std::string outputfile_path; // The directory we'll dump these into
|
||||
static std::list<std::string> chanvars_fixed_list; // Normally this would be used, but not in this class
|
||||
static std::list<std::string> chanvars_supp_list; // This will hold the list for all chanvars here
|
||||
static std::string display_name;
|
||||
char formattedcallstartdate[100];
|
||||
char formattedcallanswerdate[100];
|
||||
char formattedcalltransferdate[100];
|
||||
char formattedcallenddate[100];
|
||||
std::string outputfile_name;
|
||||
std::ofstream outputfile;
|
||||
private:
|
||||
static bool activated; // Is this module activated?
|
||||
static bool connectionstate; // What is the status of the connection?
|
||||
static bool logchanvars;
|
||||
static modcdr_time_convert_t convert_time;
|
||||
static std::string outputfile_path; // The directory we'll dump these into
|
||||
static std::list < std::string > chanvars_fixed_list; // Normally this would be used, but not in this class
|
||||
static std::list < std::string > chanvars_supp_list; // This will hold the list for all chanvars here
|
||||
static std::string display_name;
|
||||
char formattedcallstartdate[100];
|
||||
char formattedcallanswerdate[100];
|
||||
char formattedcalltransferdate[100];
|
||||
char formattedcallenddate[100];
|
||||
std::string outputfile_name;
|
||||
std::ofstream outputfile;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -46,17 +46,13 @@ static struct {
|
||||
switch_sockaddr_t *addr;
|
||||
switch_socket_t *udp_socket;
|
||||
switch_hash_t *event_hash;
|
||||
uint8_t event_list[SWITCH_EVENT_ALL+1];
|
||||
uint8_t event_list[SWITCH_EVENT_ALL + 1];
|
||||
int running;
|
||||
} globals;
|
||||
|
||||
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_address, globals.address)
|
||||
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_bindings, globals.bindings)
|
||||
|
||||
|
||||
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_bindings, globals.bindings)
|
||||
#define MULTICAST_EVENT "multicast::event"
|
||||
|
||||
|
||||
static switch_status_t load_config(void)
|
||||
{
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
@@ -80,7 +76,7 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_bindings, globals.bindings)
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass!");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
|
||||
if ((settings = switch_xml_child(cfg, "settings"))) {
|
||||
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
|
||||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||
@@ -91,7 +87,7 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_bindings, globals.bindings)
|
||||
} else if (!strcasecmp(var, "bindings")) {
|
||||
set_global_bindings(val);
|
||||
} else if (!strcasecmp(var, "port")) {
|
||||
globals.port = (switch_port_t)atoi(val);
|
||||
globals.port = (switch_port_t) atoi(val);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -100,13 +96,13 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_bindings, globals.bindings)
|
||||
|
||||
|
||||
if (globals.bindings) {
|
||||
for(cur = globals.bindings; cur; count++) {
|
||||
for (cur = globals.bindings; cur; count++) {
|
||||
switch_event_types_t type;
|
||||
|
||||
if ((next = strchr(cur, ' '))) {
|
||||
*next++ = '\0';
|
||||
}
|
||||
|
||||
|
||||
if (custom) {
|
||||
switch_core_hash_insert_dup(globals.event_hash, cur, MARKER);
|
||||
} else if (switch_name_event(cur, &type) == SWITCH_STATUS_SUCCESS) {
|
||||
@@ -143,14 +139,14 @@ static void event_handler(switch_event_t *event)
|
||||
|
||||
|
||||
if (event->subclass && !strcmp(event->subclass->name, MULTICAST_EVENT)) {
|
||||
/* ignore our own events to avoid ping pong*/
|
||||
/* ignore our own events to avoid ping pong */
|
||||
return;
|
||||
}
|
||||
|
||||
if (globals.event_list[(uint8_t)SWITCH_EVENT_ALL]) {
|
||||
if (globals.event_list[(uint8_t) SWITCH_EVENT_ALL]) {
|
||||
send = 1;
|
||||
} else if ((globals.event_list[(uint8_t)event->event_id])) {
|
||||
if (event->event_id != SWITCH_EVENT_CUSTOM ||
|
||||
} else if ((globals.event_list[(uint8_t) event->event_id])) {
|
||||
if (event->event_id != SWITCH_EVENT_CUSTOM ||
|
||||
(event->subclass && switch_core_hash_find(globals.event_hash, event->subclass->name))) {
|
||||
send = 1;
|
||||
}
|
||||
@@ -158,7 +154,7 @@ static void event_handler(switch_event_t *event)
|
||||
|
||||
if (send) {
|
||||
char *packet;
|
||||
|
||||
|
||||
switch (event->event_id) {
|
||||
case SWITCH_EVENT_LOG:
|
||||
return;
|
||||
@@ -188,7 +184,8 @@ static switch_loadable_module_interface_t event_test_module_interface = {
|
||||
};
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
memset(&globals, 0, sizeof(globals));
|
||||
@@ -199,13 +196,14 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
|
||||
}
|
||||
|
||||
switch_core_hash_init(&globals.event_hash, module_pool);
|
||||
|
||||
|
||||
if (load_config() != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Configure\n");
|
||||
return SWITCH_STATUS_TERM;
|
||||
}
|
||||
|
||||
if (switch_sockaddr_info_get(&globals.addr, globals.address, SWITCH_UNSPEC, globals.port, 0, module_pool) != SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_sockaddr_info_get(&globals.addr, globals.address, SWITCH_UNSPEC, globals.port, 0, module_pool) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find address\n");
|
||||
return SWITCH_STATUS_TERM;
|
||||
}
|
||||
@@ -214,7 +212,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Socket Error\n");
|
||||
return SWITCH_STATUS_TERM;
|
||||
}
|
||||
|
||||
|
||||
if (switch_socket_opt_set(globals.udp_socket, SWITCH_SO_REUSEADDR, 1) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Socket Option Error\n");
|
||||
switch_socket_close(globals.udp_socket);
|
||||
@@ -224,7 +222,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
|
||||
if (switch_mcast_join(globals.udp_socket, globals.addr, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Multicast Error\n");
|
||||
switch_socket_close(globals.udp_socket);
|
||||
return SWITCH_STATUS_TERM;
|
||||
return SWITCH_STATUS_TERM;
|
||||
}
|
||||
|
||||
if (switch_socket_bind(globals.udp_socket, globals.addr) != SWITCH_STATUS_SUCCESS) {
|
||||
@@ -238,7 +236,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = &event_test_module_interface;
|
||||
|
||||
|
||||
|
||||
if (switch_event_bind((char *) modname, SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
||||
@@ -258,7 +256,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
|
||||
|
||||
switch_socket_shutdown(globals.udp_socket, SWITCH_SHUTDOWN_READWRITE);
|
||||
globals.running = -1;
|
||||
while(x < 100000 && globals.running) {
|
||||
while (x < 100000 && globals.running) {
|
||||
x++;
|
||||
switch_yield(1000);
|
||||
}
|
||||
@@ -269,16 +267,16 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
|
||||
{
|
||||
switch_event_t *local_event;
|
||||
char buf[65536] = {0};
|
||||
char buf[65536] = { 0 };
|
||||
switch_sockaddr_t *addr;
|
||||
|
||||
switch_sockaddr_info_get(&addr, NULL, SWITCH_UNSPEC, 0, 0, module_pool);
|
||||
globals.running = 1;
|
||||
while(globals.running == 1) {
|
||||
while (globals.running == 1) {
|
||||
char *myaddr;
|
||||
size_t len = sizeof(buf);
|
||||
memset(buf, 0, len);
|
||||
|
||||
|
||||
switch_sockaddr_ip_get(&myaddr, globals.addr);
|
||||
|
||||
if (switch_socket_recvfrom(addr, globals.udp_socket, 0, buf, &len) == SWITCH_STATUS_SUCCESS) {
|
||||
@@ -287,25 +285,25 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
|
||||
|
||||
memcpy(&host_hash, buf, sizeof(host_hash));
|
||||
packet = buf + sizeof(host_hash);
|
||||
|
||||
|
||||
if (host_hash == globals.host_hash) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "\nEVENT %d\n--------------------------------\n%s\n", (int) len, packet);
|
||||
if (switch_event_create_subclass(&local_event, SWITCH_EVENT_CUSTOM, MULTICAST_EVENT) == SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_event_create_subclass(&local_event, SWITCH_EVENT_CUSTOM, MULTICAST_EVENT) ==
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
char *var, *val, *term = NULL, tmpname[128];
|
||||
switch_event_add_header(local_event, SWITCH_STACK_BOTTOM, "Multicast", "yes");
|
||||
var = packet;
|
||||
while(*var) {
|
||||
while (*var) {
|
||||
if ((val = strchr(var, ':')) != 0) {
|
||||
*val++ = '\0';
|
||||
while(*val == ' ') {
|
||||
while (*val == ' ') {
|
||||
val++;
|
||||
}
|
||||
if ((term = strchr(val, '\r')) != 0 || (term=strchr(val, '\n')) != 0) {
|
||||
if ((term = strchr(val, '\r')) != 0 || (term = strchr(val, '\n')) != 0) {
|
||||
*term = '\0';
|
||||
while(*term == '\r' || *term == '\n') {
|
||||
while (*term == '\r' || *term == '\n') {
|
||||
term++;
|
||||
}
|
||||
}
|
||||
@@ -315,18 +313,18 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (var && strlen(var) > 1) {
|
||||
switch_event_add_body(local_event, var);
|
||||
}
|
||||
|
||||
switch_event_fire(&local_event);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
globals.running = 0;
|
||||
return SWITCH_STATUS_TERM;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -53,13 +53,15 @@ static void event_handler(switch_event_t *event)
|
||||
dofree++;
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "\nEVENT (text version)\n--------------------------------\n%s", buf);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "\nEVENT (xml version)\n--------------------------------\n%s\n", xmlstr);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE,
|
||||
"\nEVENT (text version)\n--------------------------------\n%s", buf);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE,
|
||||
"\nEVENT (xml version)\n--------------------------------\n%s\n", xmlstr);
|
||||
break;
|
||||
}
|
||||
|
||||
switch_safe_free(buf);
|
||||
|
||||
|
||||
if (dofree) {
|
||||
if (xml) {
|
||||
switch_xml_free(xml);
|
||||
@@ -125,7 +127,8 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
|
||||
#endif
|
||||
|
||||
|
||||
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 */
|
||||
*module_interface = &event_test_module_interface;
|
||||
@@ -140,7 +143,6 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
#ifdef TORTURE_ME
|
||||
if (1) {
|
||||
int x = 0;
|
||||
|
||||
@@ -151,7 +151,7 @@ static int on_result(struct session *sess, ikspak * pak)
|
||||
{
|
||||
iks *msg, *ctag;
|
||||
|
||||
msg = iks_make_pres (IKS_SHOW_AVAILABLE, "Available");
|
||||
msg = iks_make_pres(IKS_SHOW_AVAILABLE, "Available");
|
||||
ctag = iks_insert(msg, "c");
|
||||
iks_insert_attrib(ctag, "node", "http://www.freeswitch.org/xmpp/client/caps");
|
||||
iks_insert_attrib(ctag, "ver", "1.0.0.1");
|
||||
@@ -159,7 +159,7 @@ static int on_result(struct session *sess, ikspak * pak)
|
||||
iks_insert_attrib(ctag, "xmlns", "http://jabber.org/protocol/caps");
|
||||
|
||||
iks_send(sess->parser, msg);
|
||||
iks_delete(msg);
|
||||
iks_delete(msg);
|
||||
|
||||
return IKS_FILTER_EAT;
|
||||
}
|
||||
@@ -231,16 +231,16 @@ static int on_stream(struct session *sess, int type, iks * node)
|
||||
}
|
||||
|
||||
|
||||
static int on_subscribe(void *user_data, ikspak *pak)
|
||||
static int on_subscribe(void *user_data, ikspak * pak)
|
||||
{
|
||||
char *from = iks_find_attrib(pak->x, "from");
|
||||
struct session *sess = (struct session *) user_data;
|
||||
|
||||
iks *msg = iks_make_s10n (IKS_TYPE_SUBSCRIBED, from, "mod_xmpp_event");
|
||||
iks *msg = iks_make_s10n(IKS_TYPE_SUBSCRIBED, from, "mod_xmpp_event");
|
||||
iks_send(sess->parser, msg);
|
||||
iks_delete(msg);
|
||||
|
||||
msg = iks_make_s10n (IKS_TYPE_SUBSCRIBE, from, "mod_xmpp_event");
|
||||
|
||||
msg = iks_make_s10n(IKS_TYPE_SUBSCRIBE, from, "mod_xmpp_event");
|
||||
iks_send(sess->parser, msg);
|
||||
iks_delete(msg);
|
||||
|
||||
@@ -251,7 +251,7 @@ static int on_msg(void *user_data, ikspak * pak)
|
||||
{
|
||||
char *cmd = iks_find_cdata(pak->x, "body");
|
||||
char *arg = NULL;
|
||||
switch_stream_handle_t stream = {0};
|
||||
switch_stream_handle_t stream = { 0 };
|
||||
char retbuf[2048] = "";
|
||||
char *p;
|
||||
iks *msg;
|
||||
@@ -272,12 +272,12 @@ static int on_msg(void *user_data, ikspak * pak)
|
||||
stream.write_function = switch_console_stream_write;
|
||||
switch_api_execute(cmd, arg, NULL, &stream);
|
||||
|
||||
|
||||
|
||||
msg = iks_make_msg(IKS_TYPE_NONE, globals.target_jid, retbuf);
|
||||
iks_insert_attrib(msg, "subject", "Reply");
|
||||
iks_send(globals.session.parser, msg);
|
||||
iks_delete(msg);
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -315,9 +315,7 @@ static void j_setup_filter(struct session *sess)
|
||||
IKS_RULE_SUBTYPE, IKS_TYPE_ERROR, IKS_RULE_ID, "auth", IKS_RULE_DONE);
|
||||
|
||||
iks_filter_add_rule(my_filter, on_subscribe, sess,
|
||||
IKS_RULE_TYPE, IKS_PAK_S10N,
|
||||
IKS_RULE_SUBTYPE, IKS_TYPE_SUBSCRIBE,
|
||||
IKS_RULE_DONE);
|
||||
IKS_RULE_TYPE, IKS_PAK_S10N, IKS_RULE_SUBTYPE, IKS_TYPE_SUBSCRIBE, IKS_RULE_DONE);
|
||||
|
||||
}
|
||||
|
||||
@@ -405,7 +403,8 @@ static switch_loadable_module_interface_t xmpp_event_module_interface = {
|
||||
/*.application_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 */
|
||||
*module_interface = &xmpp_event_module_interface;
|
||||
|
||||
@@ -52,55 +52,55 @@ static sw_result HOWL_API my_browser(sw_discovery discovery,
|
||||
sw_discovery_browse_status status,
|
||||
sw_uint32 interface_index,
|
||||
sw_const_string name,
|
||||
sw_const_string type,
|
||||
sw_const_string domain,
|
||||
sw_opaque_t extra) {
|
||||
sw_const_string type, sw_const_string domain, sw_opaque_t extra)
|
||||
{
|
||||
//sw_discovery_resolve_id rid;
|
||||
|
||||
switch (status) {
|
||||
case SW_DISCOVERY_BROWSE_INVALID:
|
||||
case SW_DISCOVERY_BROWSE_INVALID:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "browse reply: Invalid\n");
|
||||
}
|
||||
break;
|
||||
|
||||
case SW_DISCOVERY_BROWSE_RELEASE:
|
||||
case SW_DISCOVERY_BROWSE_RELEASE:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "browse reply: Release\n");
|
||||
}
|
||||
break;
|
||||
|
||||
case SW_DISCOVERY_BROWSE_ADD_DOMAIN:
|
||||
case SW_DISCOVERY_BROWSE_ADD_DOMAIN:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "browse reply: Add Domain\n");
|
||||
}
|
||||
break;
|
||||
|
||||
case SW_DISCOVERY_BROWSE_ADD_DEFAULT_DOMAIN:
|
||||
case SW_DISCOVERY_BROWSE_ADD_DEFAULT_DOMAIN:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "browse reply: Add Default Domain\n");
|
||||
}
|
||||
break;
|
||||
|
||||
case SW_DISCOVERY_BROWSE_REMOVE_DOMAIN:
|
||||
case SW_DISCOVERY_BROWSE_REMOVE_DOMAIN:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "browse reply: Remove Domain\n");
|
||||
}
|
||||
break;
|
||||
|
||||
case SW_DISCOVERY_BROWSE_REMOVE_SERVICE:
|
||||
case SW_DISCOVERY_BROWSE_REMOVE_SERVICE:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "browse reply: Remove Service\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "remove service: 0x%x %s %s %s\n", interface_index, name, type, domain);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "remove service: 0x%x %s %s %s\n", interface_index,
|
||||
name, type, domain);
|
||||
}
|
||||
break;
|
||||
|
||||
case SW_DISCOVERY_BROWSE_RESOLVED:
|
||||
case SW_DISCOVERY_BROWSE_RESOLVED:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "browse reply: Resolved\n");
|
||||
}
|
||||
break;
|
||||
case SW_DISCOVERY_BROWSE_ADD_SERVICE:
|
||||
case SW_DISCOVERY_BROWSE_ADD_SERVICE:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -108,17 +108,16 @@ static sw_result HOWL_API my_browser(sw_discovery discovery,
|
||||
}
|
||||
|
||||
|
||||
static sw_result HOWL_API my_service_reply(sw_discovery discovery,
|
||||
sw_discovery_oid oid,
|
||||
sw_discovery_publish_status status,
|
||||
sw_opaque extra) {
|
||||
static sw_result HOWL_API my_service_reply(sw_discovery discovery,
|
||||
sw_discovery_oid oid, sw_discovery_publish_status status, sw_opaque extra)
|
||||
{
|
||||
static sw_string status_text[] = {
|
||||
"Started",
|
||||
"Stopped",
|
||||
"Name Collision",
|
||||
"Invalid"
|
||||
};
|
||||
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "publish reply: %s\n", status_text[status]);
|
||||
return SW_OKAY;
|
||||
}
|
||||
@@ -126,7 +125,7 @@ static sw_result HOWL_API my_service_reply(sw_discovery discovery,
|
||||
|
||||
static void event_handler(switch_event_t *event)
|
||||
{
|
||||
sw_text_record text_record;
|
||||
sw_text_record text_record;
|
||||
sw_result result;
|
||||
|
||||
switch (event->event_id) {
|
||||
@@ -159,10 +158,10 @@ static void event_handler(switch_event_t *event)
|
||||
service = "_freeswitch._tcp";
|
||||
}
|
||||
if (port) {
|
||||
porti = (sw_port)atoi(port);
|
||||
porti = (sw_port) atoi(port);
|
||||
}
|
||||
|
||||
switch_mutex_lock(globals.zc_lock);
|
||||
switch_mutex_lock(globals.zc_lock);
|
||||
if ((result = sw_discovery_publish(globals.discovery,
|
||||
0,
|
||||
"freeswitch",
|
||||
@@ -172,9 +171,7 @@ static void event_handler(switch_event_t *event)
|
||||
porti,
|
||||
sw_text_record_bytes(text_record),
|
||||
sw_text_record_len(text_record),
|
||||
my_service_reply,
|
||||
NULL,
|
||||
&globals.disc_id)) != SW_OKAY) {
|
||||
my_service_reply, NULL, &globals.disc_id)) != SW_OKAY) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "publish failed: %u\n", result);
|
||||
sw_text_record_fina(text_record);
|
||||
switch_mutex_unlock(globals.zc_lock);
|
||||
@@ -183,7 +180,7 @@ static void event_handler(switch_event_t *event)
|
||||
switch_mutex_unlock(globals.zc_lock);
|
||||
sw_text_record_fina(text_record);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case SWITCH_EVENT_UNPUBLISH:
|
||||
|
||||
@@ -211,11 +208,11 @@ static switch_status_t load_config(void)
|
||||
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
|
||||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||
char *val = (char *) switch_xml_attr_soft(param, "value");
|
||||
|
||||
|
||||
if (!strcmp(var, "browse")) {
|
||||
if ((oid = switch_core_alloc(module_pool, sizeof(*oid))) != 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Bind browser to to %s\n", val);
|
||||
switch_mutex_lock(globals.zc_lock);
|
||||
switch_mutex_lock(globals.zc_lock);
|
||||
sw_discovery_browse(globals.discovery, 0, val, NULL, my_browser, NULL, oid);
|
||||
switch_mutex_unlock(globals.zc_lock);
|
||||
count++;
|
||||
@@ -223,14 +220,16 @@ static switch_status_t load_config(void)
|
||||
return SWITCH_STATUS_MEMERR;
|
||||
}
|
||||
} else if (!strcasecmp(var, "publish") && !strcasecmp(val, "yes")) {
|
||||
if (switch_event_bind((char *) modname, SWITCH_EVENT_PUBLISH, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_event_bind
|
||||
((char *) modname, SWITCH_EVENT_PUBLISH, SWITCH_EVENT_SUBCLASS_ANY, event_handler,
|
||||
NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
if (switch_event_bind((char *) modname, SWITCH_EVENT_UNPUBLISH, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
|
||||
if (switch_event_bind
|
||||
((char *) modname, SWITCH_EVENT_UNPUBLISH, SWITCH_EVENT_SUBCLASS_ANY, event_handler,
|
||||
NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
@@ -269,7 +268,8 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
memset(&globals, 0, sizeof(globals));
|
||||
@@ -289,7 +289,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
|
||||
if (load_config() != SWITCH_STATUS_SUCCESS) {
|
||||
return SWITCH_STATUS_TERM;
|
||||
}
|
||||
|
||||
|
||||
if (switch_event_reserve_subclass(MY_EVENT_PUBLISH) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass!");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
@@ -312,7 +312,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
|
||||
{
|
||||
|
||||
RUNNING = 1;
|
||||
while(RUNNING == 1) {
|
||||
while (RUNNING == 1) {
|
||||
sw_uint32 ms;
|
||||
ms = 100;
|
||||
sw_discovery_step(globals.discovery, &ms);
|
||||
|
||||
@@ -63,7 +63,8 @@ static switch_status_t native_file_file_open(switch_file_handle_t *handle, char
|
||||
flags |= SWITCH_FOPEN_READ;
|
||||
}
|
||||
|
||||
if (switch_file_open(&context->fd, path, flags, SWITCH_FPROT_UREAD|SWITCH_FPROT_UWRITE, handle->memory_pool) != SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_file_open(&context->fd, path, flags, SWITCH_FPROT_UREAD | SWITCH_FPROT_UWRITE, handle->memory_pool) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening %s\n", path);
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
@@ -78,7 +79,7 @@ static switch_status_t native_file_file_open(switch_file_handle_t *handle, char
|
||||
handle->seekable = 1;
|
||||
handle->speed = 0;
|
||||
handle->private_info = context;
|
||||
handle->flags |= SWITCH_FILE_NATIVE;
|
||||
handle->flags |= SWITCH_FILE_NATIVE;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Opening File [%s] %dhz\n", path, handle->samplerate);
|
||||
|
||||
|
||||
@@ -88,7 +89,7 @@ static switch_status_t native_file_file_open(switch_file_handle_t *handle, char
|
||||
static switch_status_t native_file_file_close(switch_file_handle_t *handle)
|
||||
{
|
||||
native_file_context *context = handle->private_info;
|
||||
|
||||
|
||||
if (context->fd) {
|
||||
switch_file_close(context->fd);
|
||||
context->fd = NULL;
|
||||
@@ -97,12 +98,13 @@ static switch_status_t native_file_file_close(switch_file_handle_t *handle)
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t native_file_file_seek(switch_file_handle_t *handle, unsigned int *cur_sample, int64_t samples, int whence)
|
||||
static switch_status_t native_file_file_seek(switch_file_handle_t *handle, unsigned int *cur_sample, int64_t samples,
|
||||
int whence)
|
||||
{
|
||||
native_file_context *context = handle->private_info;
|
||||
|
||||
|
||||
switch_file_seek(context->fd, whence, &samples);
|
||||
|
||||
|
||||
return SWITCH_STATUS_FALSE;
|
||||
|
||||
}
|
||||
@@ -121,21 +123,23 @@ static switch_status_t native_file_file_write(switch_file_handle_t *handle, void
|
||||
return switch_file_write(context->fd, data, len);
|
||||
}
|
||||
|
||||
static switch_status_t native_file_file_set_string(switch_file_handle_t *handle, switch_audio_col_t col, const char *string)
|
||||
static switch_status_t native_file_file_set_string(switch_file_handle_t *handle, switch_audio_col_t col,
|
||||
const char *string)
|
||||
{
|
||||
//native_file_context *context = handle->private_info;
|
||||
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
static switch_status_t native_file_file_get_string(switch_file_handle_t *handle, switch_audio_col_t col, const char **string)
|
||||
static switch_status_t native_file_file_get_string(switch_file_handle_t *handle, switch_audio_col_t col,
|
||||
const char **string)
|
||||
{
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
/* Registration */
|
||||
|
||||
static char *supported_formats[SWITCH_MAX_CODECS] = {0};
|
||||
static char *supported_formats[SWITCH_MAX_CODECS] = { 0 };
|
||||
|
||||
static switch_file_interface_t native_file_file_interface = {
|
||||
/*.interface_name */ modname,
|
||||
@@ -163,14 +167,15 @@ static switch_loadable_module_interface_t native_file_module_interface = {
|
||||
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
const switch_codec_implementation_t *codecs[SWITCH_MAX_CODECS];
|
||||
uint32_t num_codecs = switch_loadable_module_get_codecs(NULL, codecs, sizeof(codecs) / sizeof(codecs[0]));
|
||||
uint32_t x;
|
||||
|
||||
for (x = 0 ; x < num_codecs; x++) {
|
||||
for (x = 0; x < num_codecs; x++) {
|
||||
supported_formats[x] = codecs[x]->iananame;
|
||||
}
|
||||
|
||||
|
||||
+151
-163
@@ -9,47 +9,47 @@
|
||||
#include "mpg123.h"
|
||||
#include "mpglib.h"
|
||||
|
||||
struct parameter param = { 1 , 1 , 0 , 0 };
|
||||
struct parameter param = { 1, 1, 0, 0 };
|
||||
|
||||
int tabsel_123[2][3][16] = {
|
||||
{ {0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,},
|
||||
{0,32,48,56, 64, 80, 96,112,128,160,192,224,256,320,384,},
|
||||
{0,32,40,48, 56, 64, 80, 96,112,128,160,192,224,256,320,} },
|
||||
{{0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448,},
|
||||
{0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384,},
|
||||
{0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320,}},
|
||||
|
||||
{ {0,32,48,56,64,80,96,112,128,144,160,176,192,224,256,},
|
||||
{0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,},
|
||||
{0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,} }
|
||||
{{0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256,},
|
||||
{0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160,},
|
||||
{0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160,}}
|
||||
};
|
||||
|
||||
long freqs[9] = { 44100, 48000, 32000,
|
||||
22050, 24000, 16000 ,
|
||||
11025 , 12000 , 8000 };
|
||||
22050, 24000, 16000,
|
||||
11025, 12000, 8000
|
||||
};
|
||||
|
||||
|
||||
#if 0
|
||||
static void get_II_stuff(struct frame *fr)
|
||||
{
|
||||
static int translate[3][2][16] =
|
||||
{ { { 0,2,2,2,2,2,2,0,0,0,1,1,1,1,1,0 } ,
|
||||
{ 0,2,2,0,0,0,1,1,1,1,1,1,1,1,1,0 } } ,
|
||||
{ { 0,2,2,2,2,2,2,0,0,0,0,0,0,0,0,0 } ,
|
||||
{ 0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0 } } ,
|
||||
{ { 0,3,3,3,3,3,3,0,0,0,1,1,1,1,1,0 } ,
|
||||
{ 0,3,3,0,0,0,1,1,1,1,1,1,1,1,1,0 } } };
|
||||
static int translate[3][2][16] = { {{0, 2, 2, 2, 2, 2, 2, 0, 0, 0, 1, 1, 1, 1, 1, 0},
|
||||
{0, 2, 2, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0}},
|
||||
{{0, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
|
||||
{{0, 3, 3, 3, 3, 3, 3, 0, 0, 0, 1, 1, 1, 1, 1, 0},
|
||||
{0, 3, 3, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0}}
|
||||
};
|
||||
|
||||
int table,sblim;
|
||||
static struct al_table *tables[5] =
|
||||
{ alloc_0, alloc_1, alloc_2, alloc_3 , alloc_4 };
|
||||
static int sblims[5] = { 27 , 30 , 8, 12 , 30 };
|
||||
int table, sblim;
|
||||
static struct al_table *tables[5] = { alloc_0, alloc_1, alloc_2, alloc_3, alloc_4 };
|
||||
static int sblims[5] = { 27, 30, 8, 12, 30 };
|
||||
|
||||
if(fr->lsf)
|
||||
table = 4;
|
||||
else
|
||||
table = translate[fr->sampling_frequency][2-fr->stereo][fr->bitrate_index];
|
||||
sblim = sblims[table];
|
||||
if (fr->lsf)
|
||||
table = 4;
|
||||
else
|
||||
table = translate[fr->sampling_frequency][2 - fr->stereo][fr->bitrate_index];
|
||||
sblim = sblims[table];
|
||||
|
||||
fr->alloc = tables[table];
|
||||
fr->II_sblimit = sblim;
|
||||
fr->alloc = tables[table];
|
||||
fr->II_sblimit = sblim;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -58,15 +58,15 @@ static void get_II_stuff(struct frame *fr)
|
||||
#if 0
|
||||
int head_check(unsigned long head)
|
||||
{
|
||||
if( (head & 0xffe00000) != 0xffe00000)
|
||||
return FALSE;
|
||||
if(!((head>>17)&3))
|
||||
return FALSE;
|
||||
if( ((head>>12)&0xf) == 0xf)
|
||||
return FALSE;
|
||||
if( ((head>>10)&0x3) == 0x3 )
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
if ((head & 0xffe00000) != 0xffe00000)
|
||||
return FALSE;
|
||||
if (!((head >> 17) & 3))
|
||||
return FALSE;
|
||||
if (((head >> 12) & 0xf) == 0xf)
|
||||
return FALSE;
|
||||
if (((head >> 10) & 0x3) == 0x3)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -75,190 +75,178 @@ int head_check(unsigned long head)
|
||||
* the code a header and write the information
|
||||
* into the frame structure
|
||||
*/
|
||||
int decode_header(struct frame *fr,unsigned long newhead)
|
||||
int decode_header(struct frame *fr, unsigned long newhead)
|
||||
{
|
||||
if( newhead & (1<<20) ) {
|
||||
fr->lsf = (newhead & (1<<19)) ? 0x0 : 0x1;
|
||||
fr->mpeg25 = 0;
|
||||
}
|
||||
else {
|
||||
fr->lsf = 1;
|
||||
fr->mpeg25 = 1;
|
||||
}
|
||||
|
||||
fr->lay = 4-((newhead>>17)&3);
|
||||
if( ((newhead>>10)&0x3) == 0x3) {
|
||||
debug_printf("%d Stream error\n", __LINE__);
|
||||
return (0);
|
||||
}
|
||||
if(fr->mpeg25) {
|
||||
fr->sampling_frequency = 6 + ((newhead>>10)&0x3);
|
||||
}
|
||||
else
|
||||
fr->sampling_frequency = ((newhead>>10)&0x3) + (fr->lsf*3);
|
||||
fr->error_protection = ((newhead>>16)&0x1)^0x1;
|
||||
if (newhead & (1 << 20)) {
|
||||
fr->lsf = (newhead & (1 << 19)) ? 0x0 : 0x1;
|
||||
fr->mpeg25 = 0;
|
||||
} else {
|
||||
fr->lsf = 1;
|
||||
fr->mpeg25 = 1;
|
||||
}
|
||||
|
||||
if(fr->mpeg25) /* allow Bitrate change for 2.5 ... */
|
||||
fr->bitrate_index = ((newhead>>12)&0xf);
|
||||
fr->lay = 4 - ((newhead >> 17) & 3);
|
||||
if (((newhead >> 10) & 0x3) == 0x3) {
|
||||
debug_printf("%d Stream error\n", __LINE__);
|
||||
return (0);
|
||||
}
|
||||
if (fr->mpeg25) {
|
||||
fr->sampling_frequency = 6 + ((newhead >> 10) & 0x3);
|
||||
} else
|
||||
fr->sampling_frequency = ((newhead >> 10) & 0x3) + (fr->lsf * 3);
|
||||
fr->error_protection = ((newhead >> 16) & 0x1) ^ 0x1;
|
||||
|
||||
fr->bitrate_index = ((newhead>>12)&0xf);
|
||||
fr->padding = ((newhead>>9)&0x1);
|
||||
fr->extension = ((newhead>>8)&0x1);
|
||||
fr->mode = ((newhead>>6)&0x3);
|
||||
fr->mode_ext = ((newhead>>4)&0x3);
|
||||
fr->copyright = ((newhead>>3)&0x1);
|
||||
fr->original = ((newhead>>2)&0x1);
|
||||
fr->emphasis = newhead & 0x3;
|
||||
if (fr->mpeg25) /* allow Bitrate change for 2.5 ... */
|
||||
fr->bitrate_index = ((newhead >> 12) & 0xf);
|
||||
|
||||
fr->stereo = (fr->mode == MPG_MD_MONO) ? 1 : 2;
|
||||
fr->bitrate_index = ((newhead >> 12) & 0xf);
|
||||
fr->padding = ((newhead >> 9) & 0x1);
|
||||
fr->extension = ((newhead >> 8) & 0x1);
|
||||
fr->mode = ((newhead >> 6) & 0x3);
|
||||
fr->mode_ext = ((newhead >> 4) & 0x3);
|
||||
fr->copyright = ((newhead >> 3) & 0x1);
|
||||
fr->original = ((newhead >> 2) & 0x1);
|
||||
fr->emphasis = newhead & 0x3;
|
||||
|
||||
if(!fr->bitrate_index)
|
||||
{
|
||||
debug_printf("%d Free format not supported.\n", __LINE__);
|
||||
return (0);
|
||||
}
|
||||
fr->stereo = (fr->mode == MPG_MD_MONO) ? 1 : 2;
|
||||
|
||||
switch(fr->lay)
|
||||
{
|
||||
case 1:
|
||||
if (!fr->bitrate_index) {
|
||||
debug_printf("%d Free format not supported.\n", __LINE__);
|
||||
return (0);
|
||||
}
|
||||
|
||||
switch (fr->lay) {
|
||||
case 1:
|
||||
#if 0
|
||||
fr->do_layer = do_layer1;
|
||||
fr->jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ?
|
||||
(fr->mode_ext<<2)+4 : 32;
|
||||
fr->framesize = (long) tabsel_123[fr->lsf][0][fr->bitrate_index] * 12000;
|
||||
fr->framesize /= freqs[fr->sampling_frequency];
|
||||
fr->framesize = ((fr->framesize+fr->padding)<<2)-4;
|
||||
fr->jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ? (fr->mode_ext << 2) + 4 : 32;
|
||||
fr->framesize = (long) tabsel_123[fr->lsf][0][fr->bitrate_index] * 12000;
|
||||
fr->framesize /= freqs[fr->sampling_frequency];
|
||||
fr->framesize = ((fr->framesize + fr->padding) << 2) - 4;
|
||||
#else
|
||||
debug_printf("%d Layer 1 not supported!\n", __LINE__);
|
||||
debug_printf("%d Layer 1 not supported!\n", __LINE__);
|
||||
#endif
|
||||
break;
|
||||
case 2:
|
||||
break;
|
||||
case 2:
|
||||
#if 0
|
||||
fr->do_layer = do_layer2;
|
||||
get_II_stuff(fr);
|
||||
fr->jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ?
|
||||
(fr->mode_ext<<2)+4 : fr->II_sblimit;
|
||||
fr->framesize = (long) tabsel_123[fr->lsf][1][fr->bitrate_index] * 144000;
|
||||
fr->framesize /= freqs[fr->sampling_frequency];
|
||||
fr->framesize += fr->padding - 4;
|
||||
get_II_stuff(fr);
|
||||
fr->jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ? (fr->mode_ext << 2) + 4 : fr->II_sblimit;
|
||||
fr->framesize = (long) tabsel_123[fr->lsf][1][fr->bitrate_index] * 144000;
|
||||
fr->framesize /= freqs[fr->sampling_frequency];
|
||||
fr->framesize += fr->padding - 4;
|
||||
#else
|
||||
debug_printf("%d Layer 2 not supported!\n", __LINE__);
|
||||
debug_printf("%d Layer 2 not supported!\n", __LINE__);
|
||||
#endif
|
||||
break;
|
||||
case 3:
|
||||
break;
|
||||
case 3:
|
||||
#if 0
|
||||
fr->do_layer = do_layer3;
|
||||
if(fr->lsf)
|
||||
ssize = (fr->stereo == 1) ? 9 : 17;
|
||||
else
|
||||
ssize = (fr->stereo == 1) ? 17 : 32;
|
||||
fr->do_layer = do_layer3;
|
||||
if (fr->lsf)
|
||||
ssize = (fr->stereo == 1) ? 9 : 17;
|
||||
else
|
||||
ssize = (fr->stereo == 1) ? 17 : 32;
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
if(fr->error_protection)
|
||||
ssize += 2;
|
||||
if (fr->error_protection)
|
||||
ssize += 2;
|
||||
#endif
|
||||
fr->framesize = (long) tabsel_123[fr->lsf][2][fr->bitrate_index] * 144000;
|
||||
fr->framesize /= freqs[fr->sampling_frequency]<<(fr->lsf);
|
||||
fr->framesize = fr->framesize + fr->padding - 4;
|
||||
break;
|
||||
default:
|
||||
debug_printf("%d Sorry, unknown layer type.\n", __LINE__);
|
||||
return (0);
|
||||
}
|
||||
return 1;
|
||||
fr->framesize = (long) tabsel_123[fr->lsf][2][fr->bitrate_index] * 144000;
|
||||
fr->framesize /= freqs[fr->sampling_frequency] << (fr->lsf);
|
||||
fr->framesize = fr->framesize + fr->padding - 4;
|
||||
break;
|
||||
default:
|
||||
debug_printf("%d Sorry, unknown layer type.\n", __LINE__);
|
||||
return (0);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if 0
|
||||
void print_header(struct frame *fr)
|
||||
{
|
||||
static char *modes[4] = { "Stereo", "Joint-Stereo", "Dual-Channel", "Single-Channel" };
|
||||
static char *layers[4] = { "Unknown" , "I", "II", "III" };
|
||||
static char *layers[4] = { "Unknown", "I", "II", "III" };
|
||||
|
||||
debug_printf("MPEG %s, Layer: %s, Freq: %ld, mode: %s, modext: %d, BPF : %d\n",
|
||||
fr->mpeg25 ? "2.5" : (fr->lsf ? "2.0" : "1.0"),
|
||||
layers[fr->lay],freqs[fr->sampling_frequency],
|
||||
modes[fr->mode],fr->mode_ext,fr->framesize+4);
|
||||
debug_printf("MPEG %s, Layer: %s, Freq: %ld, mode: %s, modext: %d, BPF : %d\n",
|
||||
fr->mpeg25 ? "2.5" : (fr->lsf ? "2.0" : "1.0"),
|
||||
layers[fr->lay], freqs[fr->sampling_frequency], modes[fr->mode], fr->mode_ext, fr->framesize + 4);
|
||||
debug_printf("Channels: %d, copyright: %s, original: %s, CRC: %s, emphasis: %d.\n",
|
||||
fr->stereo,fr->copyright?"Yes":"No",
|
||||
fr->original?"Yes":"No",fr->error_protection?"Yes":"No",
|
||||
fr->emphasis);
|
||||
fr->stereo, fr->copyright ? "Yes" : "No",
|
||||
fr->original ? "Yes" : "No", fr->error_protection ? "Yes" : "No", fr->emphasis);
|
||||
debug_printf("Bitrate: %d Kbits/s, Extension value: %d\n",
|
||||
tabsel_123[fr->lsf][fr->lay-1][fr->bitrate_index],fr->extension);
|
||||
tabsel_123[fr->lsf][fr->lay - 1][fr->bitrate_index], fr->extension);
|
||||
}
|
||||
|
||||
void print_header_compact(struct frame *fr)
|
||||
{
|
||||
static char *modes[4] = { "stereo", "joint-stereo", "dual-channel", "mono" };
|
||||
static char *layers[4] = { "Unknown" , "I", "II", "III" };
|
||||
|
||||
static char *layers[4] = { "Unknown", "I", "II", "III" };
|
||||
|
||||
debug_printf("MPEG %s layer %s, %d kbit/s, %ld Hz %s\n",
|
||||
fr->mpeg25 ? "2.5" : (fr->lsf ? "2.0" : "1.0"),
|
||||
layers[fr->lay],
|
||||
tabsel_123[fr->lsf][fr->lay-1][fr->bitrate_index],
|
||||
freqs[fr->sampling_frequency], modes[fr->mode]);
|
||||
fr->mpeg25 ? "2.5" : (fr->lsf ? "2.0" : "1.0"),
|
||||
layers[fr->lay],
|
||||
tabsel_123[fr->lsf][fr->lay - 1][fr->bitrate_index], freqs[fr->sampling_frequency], modes[fr->mode]);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
unsigned int getbits(struct mpstr *mp, int number_of_bits)
|
||||
{
|
||||
unsigned long rval;
|
||||
unsigned long rval;
|
||||
|
||||
if(!number_of_bits)
|
||||
return 0;
|
||||
if (!number_of_bits)
|
||||
return 0;
|
||||
|
||||
{
|
||||
rval = (mp->worksample).wordpointer[0];
|
||||
rval <<= 8;
|
||||
rval |= (mp->worksample).wordpointer[1];
|
||||
rval <<= 8;
|
||||
rval |= (mp->worksample).wordpointer[2];
|
||||
rval <<= (mp->worksample).bitindex;
|
||||
rval &= 0xffffff;
|
||||
{
|
||||
rval = (mp->worksample).wordpointer[0];
|
||||
rval <<= 8;
|
||||
rval |= (mp->worksample).wordpointer[1];
|
||||
rval <<= 8;
|
||||
rval |= (mp->worksample).wordpointer[2];
|
||||
rval <<= (mp->worksample).bitindex;
|
||||
rval &= 0xffffff;
|
||||
|
||||
(mp->worksample).bitindex += number_of_bits;
|
||||
(mp->worksample).bitindex += number_of_bits;
|
||||
|
||||
rval >>= (24-number_of_bits);
|
||||
rval >>= (24 - number_of_bits);
|
||||
|
||||
(mp->worksample).wordpointer += ((mp->worksample).bitindex>>3);
|
||||
(mp->worksample).bitindex &= 7;
|
||||
}
|
||||
return rval;
|
||||
(mp->worksample).wordpointer += ((mp->worksample).bitindex >> 3);
|
||||
(mp->worksample).bitindex &= 7;
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
unsigned int getbits_fast(struct mpstr *mp, int number_of_bits)
|
||||
{
|
||||
unsigned long rval;
|
||||
unsigned long rval;
|
||||
|
||||
{
|
||||
rval = (mp->worksample).wordpointer[0];
|
||||
rval <<= 8;
|
||||
rval |= (mp->worksample).wordpointer[1];
|
||||
rval <<= (mp->worksample).bitindex;
|
||||
rval &= 0xffff;
|
||||
(mp->worksample).bitindex += number_of_bits;
|
||||
{
|
||||
rval = (mp->worksample).wordpointer[0];
|
||||
rval <<= 8;
|
||||
rval |= (mp->worksample).wordpointer[1];
|
||||
rval <<= (mp->worksample).bitindex;
|
||||
rval &= 0xffff;
|
||||
(mp->worksample).bitindex += number_of_bits;
|
||||
|
||||
rval >>= (16-number_of_bits);
|
||||
rval >>= (16 - number_of_bits);
|
||||
|
||||
(mp->worksample).wordpointer += ((mp->worksample).bitindex>>3);
|
||||
(mp->worksample).bitindex &= 7;
|
||||
}
|
||||
return rval;
|
||||
(mp->worksample).wordpointer += ((mp->worksample).bitindex >> 3);
|
||||
(mp->worksample).bitindex &= 7;
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
unsigned int get1bit(struct mpstr *mp)
|
||||
{
|
||||
unsigned char rval;
|
||||
unsigned char rval;
|
||||
|
||||
rval = *((mp->worksample).wordpointer) << (mp->worksample).bitindex;
|
||||
rval = *((mp->worksample).wordpointer) << (mp->worksample).bitindex;
|
||||
|
||||
(mp->worksample).bitindex++;
|
||||
(mp->worksample).wordpointer += ((mp->worksample).bitindex>>3);
|
||||
(mp->worksample).bitindex &= 7;
|
||||
(mp->worksample).bitindex++;
|
||||
(mp->worksample).wordpointer += ((mp->worksample).bitindex >> 3);
|
||||
(mp->worksample).bitindex &= 7;
|
||||
|
||||
return rval>>7;
|
||||
return rval >> 7;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -13,323 +13,322 @@
|
||||
* the call via dct64 is a trick to force GCC to use
|
||||
* (new) registers for the b1,b2 pointer to the bufs[xx] field
|
||||
*/
|
||||
void dct64(real *a,real *b,real *c);
|
||||
void dct64(real * a, real * b, real * c);
|
||||
|
||||
static void dct64_1(real *out0,real *out1,real *b1,real *b2,real *samples)
|
||||
static void dct64_1(real * out0, real * out1, real * b1, real * b2, real * samples)
|
||||
{
|
||||
{
|
||||
register real *costab = pnts[0];
|
||||
{
|
||||
register real *costab = pnts[0];
|
||||
|
||||
b1[0x00] = samples[0x00] + samples[0x1F];
|
||||
b1[0x01] = samples[0x01] + samples[0x1E];
|
||||
b1[0x1F] = (samples[0x00] - samples[0x1F]) * costab[0x0];
|
||||
b1[0x1E] = (samples[0x01] - samples[0x1E]) * costab[0x1];
|
||||
b1[0x00] = samples[0x00] + samples[0x1F];
|
||||
b1[0x01] = samples[0x01] + samples[0x1E];
|
||||
b1[0x1F] = (samples[0x00] - samples[0x1F]) * costab[0x0];
|
||||
b1[0x1E] = (samples[0x01] - samples[0x1E]) * costab[0x1];
|
||||
|
||||
b1[0x02] = samples[0x02] + samples[0x1D];
|
||||
b1[0x03] = samples[0x03] + samples[0x1C];
|
||||
b1[0x1D] = (samples[0x02] - samples[0x1D]) * costab[0x2];
|
||||
b1[0x1C] = (samples[0x03] - samples[0x1C]) * costab[0x3];
|
||||
b1[0x02] = samples[0x02] + samples[0x1D];
|
||||
b1[0x03] = samples[0x03] + samples[0x1C];
|
||||
b1[0x1D] = (samples[0x02] - samples[0x1D]) * costab[0x2];
|
||||
b1[0x1C] = (samples[0x03] - samples[0x1C]) * costab[0x3];
|
||||
|
||||
b1[0x04] = samples[0x04] + samples[0x1B];
|
||||
b1[0x05] = samples[0x05] + samples[0x1A];
|
||||
b1[0x1B] = (samples[0x04] - samples[0x1B]) * costab[0x4];
|
||||
b1[0x1A] = (samples[0x05] - samples[0x1A]) * costab[0x5];
|
||||
b1[0x04] = samples[0x04] + samples[0x1B];
|
||||
b1[0x05] = samples[0x05] + samples[0x1A];
|
||||
b1[0x1B] = (samples[0x04] - samples[0x1B]) * costab[0x4];
|
||||
b1[0x1A] = (samples[0x05] - samples[0x1A]) * costab[0x5];
|
||||
|
||||
b1[0x06] = samples[0x06] + samples[0x19];
|
||||
b1[0x07] = samples[0x07] + samples[0x18];
|
||||
b1[0x19] = (samples[0x06] - samples[0x19]) * costab[0x6];
|
||||
b1[0x18] = (samples[0x07] - samples[0x18]) * costab[0x7];
|
||||
b1[0x06] = samples[0x06] + samples[0x19];
|
||||
b1[0x07] = samples[0x07] + samples[0x18];
|
||||
b1[0x19] = (samples[0x06] - samples[0x19]) * costab[0x6];
|
||||
b1[0x18] = (samples[0x07] - samples[0x18]) * costab[0x7];
|
||||
|
||||
b1[0x08] = samples[0x08] + samples[0x17];
|
||||
b1[0x09] = samples[0x09] + samples[0x16];
|
||||
b1[0x17] = (samples[0x08] - samples[0x17]) * costab[0x8];
|
||||
b1[0x16] = (samples[0x09] - samples[0x16]) * costab[0x9];
|
||||
b1[0x08] = samples[0x08] + samples[0x17];
|
||||
b1[0x09] = samples[0x09] + samples[0x16];
|
||||
b1[0x17] = (samples[0x08] - samples[0x17]) * costab[0x8];
|
||||
b1[0x16] = (samples[0x09] - samples[0x16]) * costab[0x9];
|
||||
|
||||
b1[0x0A] = samples[0x0A] + samples[0x15];
|
||||
b1[0x0B] = samples[0x0B] + samples[0x14];
|
||||
b1[0x15] = (samples[0x0A] - samples[0x15]) * costab[0xA];
|
||||
b1[0x14] = (samples[0x0B] - samples[0x14]) * costab[0xB];
|
||||
b1[0x0A] = samples[0x0A] + samples[0x15];
|
||||
b1[0x0B] = samples[0x0B] + samples[0x14];
|
||||
b1[0x15] = (samples[0x0A] - samples[0x15]) * costab[0xA];
|
||||
b1[0x14] = (samples[0x0B] - samples[0x14]) * costab[0xB];
|
||||
|
||||
b1[0x0C] = samples[0x0C] + samples[0x13];
|
||||
b1[0x0D] = samples[0x0D] + samples[0x12];
|
||||
b1[0x13] = (samples[0x0C] - samples[0x13]) * costab[0xC];
|
||||
b1[0x12] = (samples[0x0D] - samples[0x12]) * costab[0xD];
|
||||
b1[0x0C] = samples[0x0C] + samples[0x13];
|
||||
b1[0x0D] = samples[0x0D] + samples[0x12];
|
||||
b1[0x13] = (samples[0x0C] - samples[0x13]) * costab[0xC];
|
||||
b1[0x12] = (samples[0x0D] - samples[0x12]) * costab[0xD];
|
||||
|
||||
b1[0x0E] = samples[0x0E] + samples[0x11];
|
||||
b1[0x0F] = samples[0x0F] + samples[0x10];
|
||||
b1[0x11] = (samples[0x0E] - samples[0x11]) * costab[0xE];
|
||||
b1[0x10] = (samples[0x0F] - samples[0x10]) * costab[0xF];
|
||||
b1[0x0E] = samples[0x0E] + samples[0x11];
|
||||
b1[0x0F] = samples[0x0F] + samples[0x10];
|
||||
b1[0x11] = (samples[0x0E] - samples[0x11]) * costab[0xE];
|
||||
b1[0x10] = (samples[0x0F] - samples[0x10]) * costab[0xF];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
register real *costab = pnts[1];
|
||||
{
|
||||
register real *costab = pnts[1];
|
||||
|
||||
b2[0x00] = b1[0x00] + b1[0x0F];
|
||||
b2[0x01] = b1[0x01] + b1[0x0E];
|
||||
b2[0x0F] = (b1[0x00] - b1[0x0F]) * costab[0];
|
||||
b2[0x0E] = (b1[0x01] - b1[0x0E]) * costab[1];
|
||||
b2[0x00] = b1[0x00] + b1[0x0F];
|
||||
b2[0x01] = b1[0x01] + b1[0x0E];
|
||||
b2[0x0F] = (b1[0x00] - b1[0x0F]) * costab[0];
|
||||
b2[0x0E] = (b1[0x01] - b1[0x0E]) * costab[1];
|
||||
|
||||
b2[0x02] = b1[0x02] + b1[0x0D];
|
||||
b2[0x03] = b1[0x03] + b1[0x0C];
|
||||
b2[0x0D] = (b1[0x02] - b1[0x0D]) * costab[2];
|
||||
b2[0x0C] = (b1[0x03] - b1[0x0C]) * costab[3];
|
||||
b2[0x02] = b1[0x02] + b1[0x0D];
|
||||
b2[0x03] = b1[0x03] + b1[0x0C];
|
||||
b2[0x0D] = (b1[0x02] - b1[0x0D]) * costab[2];
|
||||
b2[0x0C] = (b1[0x03] - b1[0x0C]) * costab[3];
|
||||
|
||||
b2[0x04] = b1[0x04] + b1[0x0B];
|
||||
b2[0x05] = b1[0x05] + b1[0x0A];
|
||||
b2[0x0B] = (b1[0x04] - b1[0x0B]) * costab[4];
|
||||
b2[0x0A] = (b1[0x05] - b1[0x0A]) * costab[5];
|
||||
b2[0x04] = b1[0x04] + b1[0x0B];
|
||||
b2[0x05] = b1[0x05] + b1[0x0A];
|
||||
b2[0x0B] = (b1[0x04] - b1[0x0B]) * costab[4];
|
||||
b2[0x0A] = (b1[0x05] - b1[0x0A]) * costab[5];
|
||||
|
||||
b2[0x06] = b1[0x06] + b1[0x09];
|
||||
b2[0x07] = b1[0x07] + b1[0x08];
|
||||
b2[0x09] = (b1[0x06] - b1[0x09]) * costab[6];
|
||||
b2[0x08] = (b1[0x07] - b1[0x08]) * costab[7];
|
||||
b2[0x06] = b1[0x06] + b1[0x09];
|
||||
b2[0x07] = b1[0x07] + b1[0x08];
|
||||
b2[0x09] = (b1[0x06] - b1[0x09]) * costab[6];
|
||||
b2[0x08] = (b1[0x07] - b1[0x08]) * costab[7];
|
||||
|
||||
/* */
|
||||
/* */
|
||||
|
||||
b2[0x10] = b1[0x10] + b1[0x1F];
|
||||
b2[0x11] = b1[0x11] + b1[0x1E];
|
||||
b2[0x1F] = (b1[0x1F] - b1[0x10]) * costab[0];
|
||||
b2[0x1E] = (b1[0x1E] - b1[0x11]) * costab[1];
|
||||
b2[0x10] = b1[0x10] + b1[0x1F];
|
||||
b2[0x11] = b1[0x11] + b1[0x1E];
|
||||
b2[0x1F] = (b1[0x1F] - b1[0x10]) * costab[0];
|
||||
b2[0x1E] = (b1[0x1E] - b1[0x11]) * costab[1];
|
||||
|
||||
b2[0x12] = b1[0x12] + b1[0x1D];
|
||||
b2[0x13] = b1[0x13] + b1[0x1C];
|
||||
b2[0x1D] = (b1[0x1D] - b1[0x12]) * costab[2];
|
||||
b2[0x1C] = (b1[0x1C] - b1[0x13]) * costab[3];
|
||||
b2[0x12] = b1[0x12] + b1[0x1D];
|
||||
b2[0x13] = b1[0x13] + b1[0x1C];
|
||||
b2[0x1D] = (b1[0x1D] - b1[0x12]) * costab[2];
|
||||
b2[0x1C] = (b1[0x1C] - b1[0x13]) * costab[3];
|
||||
|
||||
b2[0x14] = b1[0x14] + b1[0x1B];
|
||||
b2[0x15] = b1[0x15] + b1[0x1A];
|
||||
b2[0x1B] = (b1[0x1B] - b1[0x14]) * costab[4];
|
||||
b2[0x1A] = (b1[0x1A] - b1[0x15]) * costab[5];
|
||||
b2[0x14] = b1[0x14] + b1[0x1B];
|
||||
b2[0x15] = b1[0x15] + b1[0x1A];
|
||||
b2[0x1B] = (b1[0x1B] - b1[0x14]) * costab[4];
|
||||
b2[0x1A] = (b1[0x1A] - b1[0x15]) * costab[5];
|
||||
|
||||
b2[0x16] = b1[0x16] + b1[0x19];
|
||||
b2[0x17] = b1[0x17] + b1[0x18];
|
||||
b2[0x19] = (b1[0x19] - b1[0x16]) * costab[6];
|
||||
b2[0x18] = (b1[0x18] - b1[0x17]) * costab[7];
|
||||
}
|
||||
b2[0x16] = b1[0x16] + b1[0x19];
|
||||
b2[0x17] = b1[0x17] + b1[0x18];
|
||||
b2[0x19] = (b1[0x19] - b1[0x16]) * costab[6];
|
||||
b2[0x18] = (b1[0x18] - b1[0x17]) * costab[7];
|
||||
}
|
||||
|
||||
{
|
||||
register real *costab = pnts[2];
|
||||
{
|
||||
register real *costab = pnts[2];
|
||||
|
||||
b1[0x00] = b2[0x00] + b2[0x07];
|
||||
b1[0x07] = (b2[0x00] - b2[0x07]) * costab[0];
|
||||
b1[0x01] = b2[0x01] + b2[0x06];
|
||||
b1[0x06] = (b2[0x01] - b2[0x06]) * costab[1];
|
||||
b1[0x02] = b2[0x02] + b2[0x05];
|
||||
b1[0x05] = (b2[0x02] - b2[0x05]) * costab[2];
|
||||
b1[0x03] = b2[0x03] + b2[0x04];
|
||||
b1[0x04] = (b2[0x03] - b2[0x04]) * costab[3];
|
||||
b1[0x00] = b2[0x00] + b2[0x07];
|
||||
b1[0x07] = (b2[0x00] - b2[0x07]) * costab[0];
|
||||
b1[0x01] = b2[0x01] + b2[0x06];
|
||||
b1[0x06] = (b2[0x01] - b2[0x06]) * costab[1];
|
||||
b1[0x02] = b2[0x02] + b2[0x05];
|
||||
b1[0x05] = (b2[0x02] - b2[0x05]) * costab[2];
|
||||
b1[0x03] = b2[0x03] + b2[0x04];
|
||||
b1[0x04] = (b2[0x03] - b2[0x04]) * costab[3];
|
||||
|
||||
b1[0x08] = b2[0x08] + b2[0x0F];
|
||||
b1[0x0F] = (b2[0x0F] - b2[0x08]) * costab[0];
|
||||
b1[0x09] = b2[0x09] + b2[0x0E];
|
||||
b1[0x0E] = (b2[0x0E] - b2[0x09]) * costab[1];
|
||||
b1[0x0A] = b2[0x0A] + b2[0x0D];
|
||||
b1[0x0D] = (b2[0x0D] - b2[0x0A]) * costab[2];
|
||||
b1[0x0B] = b2[0x0B] + b2[0x0C];
|
||||
b1[0x0C] = (b2[0x0C] - b2[0x0B]) * costab[3];
|
||||
b1[0x08] = b2[0x08] + b2[0x0F];
|
||||
b1[0x0F] = (b2[0x0F] - b2[0x08]) * costab[0];
|
||||
b1[0x09] = b2[0x09] + b2[0x0E];
|
||||
b1[0x0E] = (b2[0x0E] - b2[0x09]) * costab[1];
|
||||
b1[0x0A] = b2[0x0A] + b2[0x0D];
|
||||
b1[0x0D] = (b2[0x0D] - b2[0x0A]) * costab[2];
|
||||
b1[0x0B] = b2[0x0B] + b2[0x0C];
|
||||
b1[0x0C] = (b2[0x0C] - b2[0x0B]) * costab[3];
|
||||
|
||||
b1[0x10] = b2[0x10] + b2[0x17];
|
||||
b1[0x17] = (b2[0x10] - b2[0x17]) * costab[0];
|
||||
b1[0x11] = b2[0x11] + b2[0x16];
|
||||
b1[0x16] = (b2[0x11] - b2[0x16]) * costab[1];
|
||||
b1[0x12] = b2[0x12] + b2[0x15];
|
||||
b1[0x15] = (b2[0x12] - b2[0x15]) * costab[2];
|
||||
b1[0x13] = b2[0x13] + b2[0x14];
|
||||
b1[0x14] = (b2[0x13] - b2[0x14]) * costab[3];
|
||||
b1[0x10] = b2[0x10] + b2[0x17];
|
||||
b1[0x17] = (b2[0x10] - b2[0x17]) * costab[0];
|
||||
b1[0x11] = b2[0x11] + b2[0x16];
|
||||
b1[0x16] = (b2[0x11] - b2[0x16]) * costab[1];
|
||||
b1[0x12] = b2[0x12] + b2[0x15];
|
||||
b1[0x15] = (b2[0x12] - b2[0x15]) * costab[2];
|
||||
b1[0x13] = b2[0x13] + b2[0x14];
|
||||
b1[0x14] = (b2[0x13] - b2[0x14]) * costab[3];
|
||||
|
||||
b1[0x18] = b2[0x18] + b2[0x1F];
|
||||
b1[0x1F] = (b2[0x1F] - b2[0x18]) * costab[0];
|
||||
b1[0x19] = b2[0x19] + b2[0x1E];
|
||||
b1[0x1E] = (b2[0x1E] - b2[0x19]) * costab[1];
|
||||
b1[0x1A] = b2[0x1A] + b2[0x1D];
|
||||
b1[0x1D] = (b2[0x1D] - b2[0x1A]) * costab[2];
|
||||
b1[0x1B] = b2[0x1B] + b2[0x1C];
|
||||
b1[0x1C] = (b2[0x1C] - b2[0x1B]) * costab[3];
|
||||
}
|
||||
b1[0x18] = b2[0x18] + b2[0x1F];
|
||||
b1[0x1F] = (b2[0x1F] - b2[0x18]) * costab[0];
|
||||
b1[0x19] = b2[0x19] + b2[0x1E];
|
||||
b1[0x1E] = (b2[0x1E] - b2[0x19]) * costab[1];
|
||||
b1[0x1A] = b2[0x1A] + b2[0x1D];
|
||||
b1[0x1D] = (b2[0x1D] - b2[0x1A]) * costab[2];
|
||||
b1[0x1B] = b2[0x1B] + b2[0x1C];
|
||||
b1[0x1C] = (b2[0x1C] - b2[0x1B]) * costab[3];
|
||||
}
|
||||
|
||||
{
|
||||
register real const cos0 = pnts[3][0];
|
||||
register real const cos1 = pnts[3][1];
|
||||
{
|
||||
register real const cos0 = pnts[3][0];
|
||||
register real const cos1 = pnts[3][1];
|
||||
|
||||
b2[0x00] = b1[0x00] + b1[0x03];
|
||||
b2[0x03] = (b1[0x00] - b1[0x03]) * cos0;
|
||||
b2[0x01] = b1[0x01] + b1[0x02];
|
||||
b2[0x02] = (b1[0x01] - b1[0x02]) * cos1;
|
||||
b2[0x00] = b1[0x00] + b1[0x03];
|
||||
b2[0x03] = (b1[0x00] - b1[0x03]) * cos0;
|
||||
b2[0x01] = b1[0x01] + b1[0x02];
|
||||
b2[0x02] = (b1[0x01] - b1[0x02]) * cos1;
|
||||
|
||||
b2[0x04] = b1[0x04] + b1[0x07];
|
||||
b2[0x07] = (b1[0x07] - b1[0x04]) * cos0;
|
||||
b2[0x05] = b1[0x05] + b1[0x06];
|
||||
b2[0x06] = (b1[0x06] - b1[0x05]) * cos1;
|
||||
b2[0x04] = b1[0x04] + b1[0x07];
|
||||
b2[0x07] = (b1[0x07] - b1[0x04]) * cos0;
|
||||
b2[0x05] = b1[0x05] + b1[0x06];
|
||||
b2[0x06] = (b1[0x06] - b1[0x05]) * cos1;
|
||||
|
||||
b2[0x08] = b1[0x08] + b1[0x0B];
|
||||
b2[0x0B] = (b1[0x08] - b1[0x0B]) * cos0;
|
||||
b2[0x09] = b1[0x09] + b1[0x0A];
|
||||
b2[0x0A] = (b1[0x09] - b1[0x0A]) * cos1;
|
||||
|
||||
b2[0x0C] = b1[0x0C] + b1[0x0F];
|
||||
b2[0x0F] = (b1[0x0F] - b1[0x0C]) * cos0;
|
||||
b2[0x0D] = b1[0x0D] + b1[0x0E];
|
||||
b2[0x0E] = (b1[0x0E] - b1[0x0D]) * cos1;
|
||||
b2[0x08] = b1[0x08] + b1[0x0B];
|
||||
b2[0x0B] = (b1[0x08] - b1[0x0B]) * cos0;
|
||||
b2[0x09] = b1[0x09] + b1[0x0A];
|
||||
b2[0x0A] = (b1[0x09] - b1[0x0A]) * cos1;
|
||||
|
||||
b2[0x10] = b1[0x10] + b1[0x13];
|
||||
b2[0x13] = (b1[0x10] - b1[0x13]) * cos0;
|
||||
b2[0x11] = b1[0x11] + b1[0x12];
|
||||
b2[0x12] = (b1[0x11] - b1[0x12]) * cos1;
|
||||
b2[0x0C] = b1[0x0C] + b1[0x0F];
|
||||
b2[0x0F] = (b1[0x0F] - b1[0x0C]) * cos0;
|
||||
b2[0x0D] = b1[0x0D] + b1[0x0E];
|
||||
b2[0x0E] = (b1[0x0E] - b1[0x0D]) * cos1;
|
||||
|
||||
b2[0x14] = b1[0x14] + b1[0x17];
|
||||
b2[0x17] = (b1[0x17] - b1[0x14]) * cos0;
|
||||
b2[0x15] = b1[0x15] + b1[0x16];
|
||||
b2[0x16] = (b1[0x16] - b1[0x15]) * cos1;
|
||||
b2[0x10] = b1[0x10] + b1[0x13];
|
||||
b2[0x13] = (b1[0x10] - b1[0x13]) * cos0;
|
||||
b2[0x11] = b1[0x11] + b1[0x12];
|
||||
b2[0x12] = (b1[0x11] - b1[0x12]) * cos1;
|
||||
|
||||
b2[0x18] = b1[0x18] + b1[0x1B];
|
||||
b2[0x1B] = (b1[0x18] - b1[0x1B]) * cos0;
|
||||
b2[0x19] = b1[0x19] + b1[0x1A];
|
||||
b2[0x1A] = (b1[0x19] - b1[0x1A]) * cos1;
|
||||
b2[0x14] = b1[0x14] + b1[0x17];
|
||||
b2[0x17] = (b1[0x17] - b1[0x14]) * cos0;
|
||||
b2[0x15] = b1[0x15] + b1[0x16];
|
||||
b2[0x16] = (b1[0x16] - b1[0x15]) * cos1;
|
||||
|
||||
b2[0x1C] = b1[0x1C] + b1[0x1F];
|
||||
b2[0x1F] = (b1[0x1F] - b1[0x1C]) * cos0;
|
||||
b2[0x1D] = b1[0x1D] + b1[0x1E];
|
||||
b2[0x1E] = (b1[0x1E] - b1[0x1D]) * cos1;
|
||||
}
|
||||
b2[0x18] = b1[0x18] + b1[0x1B];
|
||||
b2[0x1B] = (b1[0x18] - b1[0x1B]) * cos0;
|
||||
b2[0x19] = b1[0x19] + b1[0x1A];
|
||||
b2[0x1A] = (b1[0x19] - b1[0x1A]) * cos1;
|
||||
|
||||
{
|
||||
register real const cos0 = pnts[4][0];
|
||||
b2[0x1C] = b1[0x1C] + b1[0x1F];
|
||||
b2[0x1F] = (b1[0x1F] - b1[0x1C]) * cos0;
|
||||
b2[0x1D] = b1[0x1D] + b1[0x1E];
|
||||
b2[0x1E] = (b1[0x1E] - b1[0x1D]) * cos1;
|
||||
}
|
||||
|
||||
b1[0x00] = b2[0x00] + b2[0x01];
|
||||
b1[0x01] = (b2[0x00] - b2[0x01]) * cos0;
|
||||
b1[0x02] = b2[0x02] + b2[0x03];
|
||||
b1[0x03] = (b2[0x03] - b2[0x02]) * cos0;
|
||||
b1[0x02] += b1[0x03];
|
||||
{
|
||||
register real const cos0 = pnts[4][0];
|
||||
|
||||
b1[0x04] = b2[0x04] + b2[0x05];
|
||||
b1[0x05] = (b2[0x04] - b2[0x05]) * cos0;
|
||||
b1[0x06] = b2[0x06] + b2[0x07];
|
||||
b1[0x07] = (b2[0x07] - b2[0x06]) * cos0;
|
||||
b1[0x06] += b1[0x07];
|
||||
b1[0x04] += b1[0x06];
|
||||
b1[0x06] += b1[0x05];
|
||||
b1[0x05] += b1[0x07];
|
||||
b1[0x00] = b2[0x00] + b2[0x01];
|
||||
b1[0x01] = (b2[0x00] - b2[0x01]) * cos0;
|
||||
b1[0x02] = b2[0x02] + b2[0x03];
|
||||
b1[0x03] = (b2[0x03] - b2[0x02]) * cos0;
|
||||
b1[0x02] += b1[0x03];
|
||||
|
||||
b1[0x08] = b2[0x08] + b2[0x09];
|
||||
b1[0x09] = (b2[0x08] - b2[0x09]) * cos0;
|
||||
b1[0x0A] = b2[0x0A] + b2[0x0B];
|
||||
b1[0x0B] = (b2[0x0B] - b2[0x0A]) * cos0;
|
||||
b1[0x0A] += b1[0x0B];
|
||||
b1[0x04] = b2[0x04] + b2[0x05];
|
||||
b1[0x05] = (b2[0x04] - b2[0x05]) * cos0;
|
||||
b1[0x06] = b2[0x06] + b2[0x07];
|
||||
b1[0x07] = (b2[0x07] - b2[0x06]) * cos0;
|
||||
b1[0x06] += b1[0x07];
|
||||
b1[0x04] += b1[0x06];
|
||||
b1[0x06] += b1[0x05];
|
||||
b1[0x05] += b1[0x07];
|
||||
|
||||
b1[0x0C] = b2[0x0C] + b2[0x0D];
|
||||
b1[0x0D] = (b2[0x0C] - b2[0x0D]) * cos0;
|
||||
b1[0x0E] = b2[0x0E] + b2[0x0F];
|
||||
b1[0x0F] = (b2[0x0F] - b2[0x0E]) * cos0;
|
||||
b1[0x0E] += b1[0x0F];
|
||||
b1[0x0C] += b1[0x0E];
|
||||
b1[0x0E] += b1[0x0D];
|
||||
b1[0x0D] += b1[0x0F];
|
||||
b1[0x08] = b2[0x08] + b2[0x09];
|
||||
b1[0x09] = (b2[0x08] - b2[0x09]) * cos0;
|
||||
b1[0x0A] = b2[0x0A] + b2[0x0B];
|
||||
b1[0x0B] = (b2[0x0B] - b2[0x0A]) * cos0;
|
||||
b1[0x0A] += b1[0x0B];
|
||||
|
||||
b1[0x10] = b2[0x10] + b2[0x11];
|
||||
b1[0x11] = (b2[0x10] - b2[0x11]) * cos0;
|
||||
b1[0x12] = b2[0x12] + b2[0x13];
|
||||
b1[0x13] = (b2[0x13] - b2[0x12]) * cos0;
|
||||
b1[0x12] += b1[0x13];
|
||||
b1[0x0C] = b2[0x0C] + b2[0x0D];
|
||||
b1[0x0D] = (b2[0x0C] - b2[0x0D]) * cos0;
|
||||
b1[0x0E] = b2[0x0E] + b2[0x0F];
|
||||
b1[0x0F] = (b2[0x0F] - b2[0x0E]) * cos0;
|
||||
b1[0x0E] += b1[0x0F];
|
||||
b1[0x0C] += b1[0x0E];
|
||||
b1[0x0E] += b1[0x0D];
|
||||
b1[0x0D] += b1[0x0F];
|
||||
|
||||
b1[0x14] = b2[0x14] + b2[0x15];
|
||||
b1[0x15] = (b2[0x14] - b2[0x15]) * cos0;
|
||||
b1[0x16] = b2[0x16] + b2[0x17];
|
||||
b1[0x17] = (b2[0x17] - b2[0x16]) * cos0;
|
||||
b1[0x16] += b1[0x17];
|
||||
b1[0x14] += b1[0x16];
|
||||
b1[0x16] += b1[0x15];
|
||||
b1[0x15] += b1[0x17];
|
||||
b1[0x10] = b2[0x10] + b2[0x11];
|
||||
b1[0x11] = (b2[0x10] - b2[0x11]) * cos0;
|
||||
b1[0x12] = b2[0x12] + b2[0x13];
|
||||
b1[0x13] = (b2[0x13] - b2[0x12]) * cos0;
|
||||
b1[0x12] += b1[0x13];
|
||||
|
||||
b1[0x18] = b2[0x18] + b2[0x19];
|
||||
b1[0x19] = (b2[0x18] - b2[0x19]) * cos0;
|
||||
b1[0x1A] = b2[0x1A] + b2[0x1B];
|
||||
b1[0x1B] = (b2[0x1B] - b2[0x1A]) * cos0;
|
||||
b1[0x1A] += b1[0x1B];
|
||||
b1[0x14] = b2[0x14] + b2[0x15];
|
||||
b1[0x15] = (b2[0x14] - b2[0x15]) * cos0;
|
||||
b1[0x16] = b2[0x16] + b2[0x17];
|
||||
b1[0x17] = (b2[0x17] - b2[0x16]) * cos0;
|
||||
b1[0x16] += b1[0x17];
|
||||
b1[0x14] += b1[0x16];
|
||||
b1[0x16] += b1[0x15];
|
||||
b1[0x15] += b1[0x17];
|
||||
|
||||
b1[0x1C] = b2[0x1C] + b2[0x1D];
|
||||
b1[0x1D] = (b2[0x1C] - b2[0x1D]) * cos0;
|
||||
b1[0x1E] = b2[0x1E] + b2[0x1F];
|
||||
b1[0x1F] = (b2[0x1F] - b2[0x1E]) * cos0;
|
||||
b1[0x1E] += b1[0x1F];
|
||||
b1[0x1C] += b1[0x1E];
|
||||
b1[0x1E] += b1[0x1D];
|
||||
b1[0x1D] += b1[0x1F];
|
||||
}
|
||||
b1[0x18] = b2[0x18] + b2[0x19];
|
||||
b1[0x19] = (b2[0x18] - b2[0x19]) * cos0;
|
||||
b1[0x1A] = b2[0x1A] + b2[0x1B];
|
||||
b1[0x1B] = (b2[0x1B] - b2[0x1A]) * cos0;
|
||||
b1[0x1A] += b1[0x1B];
|
||||
|
||||
out0[0x10*16] = b1[0x00];
|
||||
out0[0x10*12] = b1[0x04];
|
||||
out0[0x10* 8] = b1[0x02];
|
||||
out0[0x10* 4] = b1[0x06];
|
||||
out0[0x10* 0] = b1[0x01];
|
||||
out1[0x10* 0] = b1[0x01];
|
||||
out1[0x10* 4] = b1[0x05];
|
||||
out1[0x10* 8] = b1[0x03];
|
||||
out1[0x10*12] = b1[0x07];
|
||||
b1[0x1C] = b2[0x1C] + b2[0x1D];
|
||||
b1[0x1D] = (b2[0x1C] - b2[0x1D]) * cos0;
|
||||
b1[0x1E] = b2[0x1E] + b2[0x1F];
|
||||
b1[0x1F] = (b2[0x1F] - b2[0x1E]) * cos0;
|
||||
b1[0x1E] += b1[0x1F];
|
||||
b1[0x1C] += b1[0x1E];
|
||||
b1[0x1E] += b1[0x1D];
|
||||
b1[0x1D] += b1[0x1F];
|
||||
}
|
||||
|
||||
out0[0x10 * 16] = b1[0x00];
|
||||
out0[0x10 * 12] = b1[0x04];
|
||||
out0[0x10 * 8] = b1[0x02];
|
||||
out0[0x10 * 4] = b1[0x06];
|
||||
out0[0x10 * 0] = b1[0x01];
|
||||
out1[0x10 * 0] = b1[0x01];
|
||||
out1[0x10 * 4] = b1[0x05];
|
||||
out1[0x10 * 8] = b1[0x03];
|
||||
out1[0x10 * 12] = b1[0x07];
|
||||
|
||||
#if 1
|
||||
out0[0x10*14] = b1[0x08] + b1[0x0C];
|
||||
out0[0x10*10] = b1[0x0C] + b1[0x0a];
|
||||
out0[0x10* 6] = b1[0x0A] + b1[0x0E];
|
||||
out0[0x10* 2] = b1[0x0E] + b1[0x09];
|
||||
out1[0x10* 2] = b1[0x09] + b1[0x0D];
|
||||
out1[0x10* 6] = b1[0x0D] + b1[0x0B];
|
||||
out1[0x10*10] = b1[0x0B] + b1[0x0F];
|
||||
out1[0x10*14] = b1[0x0F];
|
||||
out0[0x10 * 14] = b1[0x08] + b1[0x0C];
|
||||
out0[0x10 * 10] = b1[0x0C] + b1[0x0a];
|
||||
out0[0x10 * 6] = b1[0x0A] + b1[0x0E];
|
||||
out0[0x10 * 2] = b1[0x0E] + b1[0x09];
|
||||
out1[0x10 * 2] = b1[0x09] + b1[0x0D];
|
||||
out1[0x10 * 6] = b1[0x0D] + b1[0x0B];
|
||||
out1[0x10 * 10] = b1[0x0B] + b1[0x0F];
|
||||
out1[0x10 * 14] = b1[0x0F];
|
||||
#else
|
||||
b1[0x08] += b1[0x0C];
|
||||
out0[0x10*14] = b1[0x08];
|
||||
b1[0x0C] += b1[0x0a];
|
||||
out0[0x10*10] = b1[0x0C];
|
||||
b1[0x0A] += b1[0x0E];
|
||||
out0[0x10* 6] = b1[0x0A];
|
||||
b1[0x0E] += b1[0x09];
|
||||
out0[0x10* 2] = b1[0x0E];
|
||||
b1[0x09] += b1[0x0D];
|
||||
out1[0x10* 2] = b1[0x09];
|
||||
b1[0x0D] += b1[0x0B];
|
||||
out1[0x10* 6] = b1[0x0D];
|
||||
b1[0x0B] += b1[0x0F];
|
||||
out1[0x10*10] = b1[0x0B];
|
||||
out1[0x10*14] = b1[0x0F];
|
||||
b1[0x08] += b1[0x0C];
|
||||
out0[0x10 * 14] = b1[0x08];
|
||||
b1[0x0C] += b1[0x0a];
|
||||
out0[0x10 * 10] = b1[0x0C];
|
||||
b1[0x0A] += b1[0x0E];
|
||||
out0[0x10 * 6] = b1[0x0A];
|
||||
b1[0x0E] += b1[0x09];
|
||||
out0[0x10 * 2] = b1[0x0E];
|
||||
b1[0x09] += b1[0x0D];
|
||||
out1[0x10 * 2] = b1[0x09];
|
||||
b1[0x0D] += b1[0x0B];
|
||||
out1[0x10 * 6] = b1[0x0D];
|
||||
b1[0x0B] += b1[0x0F];
|
||||
out1[0x10 * 10] = b1[0x0B];
|
||||
out1[0x10 * 14] = b1[0x0F];
|
||||
#endif
|
||||
|
||||
{
|
||||
real tmp;
|
||||
tmp = b1[0x18] + b1[0x1C];
|
||||
out0[0x10*15] = tmp + b1[0x10];
|
||||
out0[0x10*13] = tmp + b1[0x14];
|
||||
tmp = b1[0x1C] + b1[0x1A];
|
||||
out0[0x10*11] = tmp + b1[0x14];
|
||||
out0[0x10* 9] = tmp + b1[0x12];
|
||||
tmp = b1[0x1A] + b1[0x1E];
|
||||
out0[0x10* 7] = tmp + b1[0x12];
|
||||
out0[0x10* 5] = tmp + b1[0x16];
|
||||
tmp = b1[0x1E] + b1[0x19];
|
||||
out0[0x10* 3] = tmp + b1[0x16];
|
||||
out0[0x10* 1] = tmp + b1[0x11];
|
||||
tmp = b1[0x19] + b1[0x1D];
|
||||
out1[0x10* 1] = tmp + b1[0x11];
|
||||
out1[0x10* 3] = tmp + b1[0x15];
|
||||
tmp = b1[0x1D] + b1[0x1B];
|
||||
out1[0x10* 5] = tmp + b1[0x15];
|
||||
out1[0x10* 7] = tmp + b1[0x13];
|
||||
tmp = b1[0x1B] + b1[0x1F];
|
||||
out1[0x10* 9] = tmp + b1[0x13];
|
||||
out1[0x10*11] = tmp + b1[0x17];
|
||||
out1[0x10*13] = b1[0x17] + b1[0x1F];
|
||||
out1[0x10*15] = b1[0x1F];
|
||||
}
|
||||
{
|
||||
real tmp;
|
||||
tmp = b1[0x18] + b1[0x1C];
|
||||
out0[0x10 * 15] = tmp + b1[0x10];
|
||||
out0[0x10 * 13] = tmp + b1[0x14];
|
||||
tmp = b1[0x1C] + b1[0x1A];
|
||||
out0[0x10 * 11] = tmp + b1[0x14];
|
||||
out0[0x10 * 9] = tmp + b1[0x12];
|
||||
tmp = b1[0x1A] + b1[0x1E];
|
||||
out0[0x10 * 7] = tmp + b1[0x12];
|
||||
out0[0x10 * 5] = tmp + b1[0x16];
|
||||
tmp = b1[0x1E] + b1[0x19];
|
||||
out0[0x10 * 3] = tmp + b1[0x16];
|
||||
out0[0x10 * 1] = tmp + b1[0x11];
|
||||
tmp = b1[0x19] + b1[0x1D];
|
||||
out1[0x10 * 1] = tmp + b1[0x11];
|
||||
out1[0x10 * 3] = tmp + b1[0x15];
|
||||
tmp = b1[0x1D] + b1[0x1B];
|
||||
out1[0x10 * 5] = tmp + b1[0x15];
|
||||
out1[0x10 * 7] = tmp + b1[0x13];
|
||||
tmp = b1[0x1B] + b1[0x1F];
|
||||
out1[0x10 * 9] = tmp + b1[0x13];
|
||||
out1[0x10 * 11] = tmp + b1[0x17];
|
||||
out1[0x10 * 13] = b1[0x17] + b1[0x1F];
|
||||
out1[0x10 * 15] = b1[0x1F];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* the call via dct64 is a trick to force GCC to use
|
||||
* (new) registers for the b1,b2 pointer to the bufs[xx] field
|
||||
*/
|
||||
void dct64(real *a,real *b,real *c)
|
||||
void dct64(real * a, real * b, real * c)
|
||||
{
|
||||
real bufs[0x40];
|
||||
dct64_1(a,b,bufs,bufs+0x20,c);
|
||||
real bufs[0x40];
|
||||
dct64_1(a, b, bufs, bufs + 0x20, c);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,129 +25,124 @@
|
||||
else if( (sum) < -32768.0) { *(samples) = -0x8000; (clip)++; } \
|
||||
else { *(samples) = sum; }
|
||||
|
||||
int synth_1to1_mono(struct mpstr *mp,real *bandPtr,unsigned char *samples,int *pnt)
|
||||
int synth_1to1_mono(struct mpstr *mp, real * bandPtr, unsigned char *samples, int *pnt)
|
||||
{
|
||||
short samples_tmp[64];
|
||||
short *tmp1 = samples_tmp;
|
||||
int i,ret;
|
||||
int pnt1 = 0;
|
||||
short samples_tmp[64];
|
||||
short *tmp1 = samples_tmp;
|
||||
int i, ret;
|
||||
int pnt1 = 0;
|
||||
|
||||
ret = synth_1to1(mp,bandPtr,0,(unsigned char *) samples_tmp,&pnt1);
|
||||
samples += *pnt;
|
||||
ret = synth_1to1(mp, bandPtr, 0, (unsigned char *) samples_tmp, &pnt1);
|
||||
samples += *pnt;
|
||||
|
||||
for(i=0;i<32;i++) {
|
||||
*( (short *) samples) = *tmp1;
|
||||
samples += 2;
|
||||
tmp1 += 2;
|
||||
}
|
||||
*pnt += 64;
|
||||
for (i = 0; i < 32; i++) {
|
||||
*((short *) samples) = *tmp1;
|
||||
samples += 2;
|
||||
tmp1 += 2;
|
||||
}
|
||||
*pnt += 64;
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int synth_1to1(struct mpstr *mp, real *bandPtr,int channel,unsigned char *out,int *pnt)
|
||||
int synth_1to1(struct mpstr *mp, real * bandPtr, int channel, unsigned char *out, int *pnt)
|
||||
{
|
||||
static const int step = 2;
|
||||
int bo;
|
||||
short *samples = (short *) (out + *pnt);
|
||||
static const int step = 2;
|
||||
int bo;
|
||||
short *samples = (short *) (out + *pnt);
|
||||
|
||||
real *b0,(*buf)[0x110];
|
||||
int clip = 0;
|
||||
int bo1;
|
||||
real *b0, (*buf)[0x110];
|
||||
int clip = 0;
|
||||
int bo1;
|
||||
|
||||
bo = mp->synth_bo;
|
||||
bo = mp->synth_bo;
|
||||
|
||||
if(!channel) {
|
||||
bo--;
|
||||
bo &= 0xf;
|
||||
buf = mp->synth_buffs[0];
|
||||
}
|
||||
else {
|
||||
samples++;
|
||||
buf = mp->synth_buffs[1];
|
||||
}
|
||||
if (!channel) {
|
||||
bo--;
|
||||
bo &= 0xf;
|
||||
buf = mp->synth_buffs[0];
|
||||
} else {
|
||||
samples++;
|
||||
buf = mp->synth_buffs[1];
|
||||
}
|
||||
|
||||
if(bo & 0x1) {
|
||||
b0 = buf[0];
|
||||
bo1 = bo;
|
||||
dct64(buf[1]+((bo+1)&0xf),buf[0]+bo,bandPtr);
|
||||
}
|
||||
else {
|
||||
b0 = buf[1];
|
||||
bo1 = bo+1;
|
||||
dct64(buf[0]+bo,buf[1]+bo+1,bandPtr);
|
||||
}
|
||||
if (bo & 0x1) {
|
||||
b0 = buf[0];
|
||||
bo1 = bo;
|
||||
dct64(buf[1] + ((bo + 1) & 0xf), buf[0] + bo, bandPtr);
|
||||
} else {
|
||||
b0 = buf[1];
|
||||
bo1 = bo + 1;
|
||||
dct64(buf[0] + bo, buf[1] + bo + 1, bandPtr);
|
||||
}
|
||||
|
||||
mp->synth_bo = bo;
|
||||
|
||||
{
|
||||
register int j;
|
||||
real *window = decwin + 16 - bo1;
|
||||
mp->synth_bo = bo;
|
||||
|
||||
for (j=16;j;j--,b0+=0x10,window+=0x20,samples+=step)
|
||||
{
|
||||
real sum;
|
||||
sum = window[0x0] * b0[0x0];
|
||||
sum -= window[0x1] * b0[0x1];
|
||||
sum += window[0x2] * b0[0x2];
|
||||
sum -= window[0x3] * b0[0x3];
|
||||
sum += window[0x4] * b0[0x4];
|
||||
sum -= window[0x5] * b0[0x5];
|
||||
sum += window[0x6] * b0[0x6];
|
||||
sum -= window[0x7] * b0[0x7];
|
||||
sum += window[0x8] * b0[0x8];
|
||||
sum -= window[0x9] * b0[0x9];
|
||||
sum += window[0xA] * b0[0xA];
|
||||
sum -= window[0xB] * b0[0xB];
|
||||
sum += window[0xC] * b0[0xC];
|
||||
sum -= window[0xD] * b0[0xD];
|
||||
sum += window[0xE] * b0[0xE];
|
||||
sum -= window[0xF] * b0[0xF];
|
||||
{
|
||||
register int j;
|
||||
real *window = decwin + 16 - bo1;
|
||||
|
||||
WRITE_SAMPLE(samples,sum,clip);
|
||||
}
|
||||
for (j = 16; j; j--, b0 += 0x10, window += 0x20, samples += step) {
|
||||
real sum;
|
||||
sum = window[0x0] * b0[0x0];
|
||||
sum -= window[0x1] * b0[0x1];
|
||||
sum += window[0x2] * b0[0x2];
|
||||
sum -= window[0x3] * b0[0x3];
|
||||
sum += window[0x4] * b0[0x4];
|
||||
sum -= window[0x5] * b0[0x5];
|
||||
sum += window[0x6] * b0[0x6];
|
||||
sum -= window[0x7] * b0[0x7];
|
||||
sum += window[0x8] * b0[0x8];
|
||||
sum -= window[0x9] * b0[0x9];
|
||||
sum += window[0xA] * b0[0xA];
|
||||
sum -= window[0xB] * b0[0xB];
|
||||
sum += window[0xC] * b0[0xC];
|
||||
sum -= window[0xD] * b0[0xD];
|
||||
sum += window[0xE] * b0[0xE];
|
||||
sum -= window[0xF] * b0[0xF];
|
||||
|
||||
{
|
||||
real sum;
|
||||
sum = window[0x0] * b0[0x0];
|
||||
sum += window[0x2] * b0[0x2];
|
||||
sum += window[0x4] * b0[0x4];
|
||||
sum += window[0x6] * b0[0x6];
|
||||
sum += window[0x8] * b0[0x8];
|
||||
sum += window[0xA] * b0[0xA];
|
||||
sum += window[0xC] * b0[0xC];
|
||||
sum += window[0xE] * b0[0xE];
|
||||
WRITE_SAMPLE(samples,sum,clip);
|
||||
b0-=0x10,window-=0x20,samples+=step;
|
||||
}
|
||||
window += bo1<<1;
|
||||
WRITE_SAMPLE(samples, sum, clip);
|
||||
}
|
||||
|
||||
for (j=15;j;j--,b0-=0x10,window-=0x20,samples+=step)
|
||||
{
|
||||
real sum;
|
||||
sum = -window[-0x1] * b0[0x0];
|
||||
sum -= window[-0x2] * b0[0x1];
|
||||
sum -= window[-0x3] * b0[0x2];
|
||||
sum -= window[-0x4] * b0[0x3];
|
||||
sum -= window[-0x5] * b0[0x4];
|
||||
sum -= window[-0x6] * b0[0x5];
|
||||
sum -= window[-0x7] * b0[0x6];
|
||||
sum -= window[-0x8] * b0[0x7];
|
||||
sum -= window[-0x9] * b0[0x8];
|
||||
sum -= window[-0xA] * b0[0x9];
|
||||
sum -= window[-0xB] * b0[0xA];
|
||||
sum -= window[-0xC] * b0[0xB];
|
||||
sum -= window[-0xD] * b0[0xC];
|
||||
sum -= window[-0xE] * b0[0xD];
|
||||
sum -= window[-0xF] * b0[0xE];
|
||||
sum -= window[-0x0] * b0[0xF];
|
||||
{
|
||||
real sum;
|
||||
sum = window[0x0] * b0[0x0];
|
||||
sum += window[0x2] * b0[0x2];
|
||||
sum += window[0x4] * b0[0x4];
|
||||
sum += window[0x6] * b0[0x6];
|
||||
sum += window[0x8] * b0[0x8];
|
||||
sum += window[0xA] * b0[0xA];
|
||||
sum += window[0xC] * b0[0xC];
|
||||
sum += window[0xE] * b0[0xE];
|
||||
WRITE_SAMPLE(samples, sum, clip);
|
||||
b0 -= 0x10, window -= 0x20, samples += step;
|
||||
}
|
||||
window += bo1 << 1;
|
||||
|
||||
WRITE_SAMPLE(samples,sum,clip);
|
||||
}
|
||||
}
|
||||
*pnt += 128;
|
||||
for (j = 15; j; j--, b0 -= 0x10, window -= 0x20, samples += step) {
|
||||
real sum;
|
||||
sum = -window[-0x1] * b0[0x0];
|
||||
sum -= window[-0x2] * b0[0x1];
|
||||
sum -= window[-0x3] * b0[0x2];
|
||||
sum -= window[-0x4] * b0[0x3];
|
||||
sum -= window[-0x5] * b0[0x4];
|
||||
sum -= window[-0x6] * b0[0x5];
|
||||
sum -= window[-0x7] * b0[0x6];
|
||||
sum -= window[-0x8] * b0[0x7];
|
||||
sum -= window[-0x9] * b0[0x8];
|
||||
sum -= window[-0xA] * b0[0x9];
|
||||
sum -= window[-0xB] * b0[0xA];
|
||||
sum -= window[-0xC] * b0[0xB];
|
||||
sum -= window[-0xD] * b0[0xC];
|
||||
sum -= window[-0xE] * b0[0xD];
|
||||
sum -= window[-0xF] * b0[0xE];
|
||||
sum -= window[-0x0] * b0[0xF];
|
||||
|
||||
return clip;
|
||||
WRITE_SAMPLE(samples, sum, clip);
|
||||
}
|
||||
}
|
||||
*pnt += 128;
|
||||
|
||||
return clip;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,198 +21,191 @@
|
||||
else { *(samples) = sum; }
|
||||
|
||||
#define NTOM_MUL (32768)
|
||||
static unsigned long ntom_val[2] = { NTOM_MUL>>1,NTOM_MUL>>1 };
|
||||
static unsigned long ntom_val[2] = { NTOM_MUL >> 1, NTOM_MUL >> 1 };
|
||||
static unsigned long ntom_step = NTOM_MUL;
|
||||
|
||||
|
||||
int synth_ntom_set_step(long m,long n)
|
||||
int synth_ntom_set_step(long m, long n)
|
||||
{
|
||||
if(param.verbose > 1)
|
||||
debug_printf("Init rate converter: %ld->%ld\n",m,n);
|
||||
if (param.verbose > 1)
|
||||
debug_printf("Init rate converter: %ld->%ld\n", m, n);
|
||||
|
||||
if(n >= 96000 || m >= 96000 || m == 0 || n == 0) {
|
||||
debug_printf("NtoM converter: %d illegal rates\n", __LINE__);
|
||||
if (n >= 96000 || m >= 96000 || m == 0 || n == 0) {
|
||||
debug_printf("NtoM converter: %d illegal rates\n", __LINE__);
|
||||
return (1);
|
||||
}
|
||||
|
||||
n *= NTOM_MUL;
|
||||
ntom_step = n / m;
|
||||
|
||||
if(ntom_step > 8*NTOM_MUL) {
|
||||
debug_printf("%d max. 1:8 conversion allowed!\n", __LINE__);
|
||||
if (ntom_step > 8 * NTOM_MUL) {
|
||||
debug_printf("%d max. 1:8 conversion allowed!\n", __LINE__);
|
||||
return (1);
|
||||
}
|
||||
|
||||
ntom_val[0] = ntom_val[1] = NTOM_MUL>>1;
|
||||
ntom_val[0] = ntom_val[1] = NTOM_MUL >> 1;
|
||||
|
||||
return (0);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int synth_ntom_mono (struct mpstr *mp, real *bandPtr,unsigned char *samples,int *pnt)
|
||||
int synth_ntom_mono(struct mpstr *mp, real * bandPtr, unsigned char *samples, int *pnt)
|
||||
{
|
||||
short samples_tmp[8*64];
|
||||
short *tmp1 = samples_tmp;
|
||||
int i,ret;
|
||||
int pnt1 = 0;
|
||||
short samples_tmp[8 * 64];
|
||||
short *tmp1 = samples_tmp;
|
||||
int i, ret;
|
||||
int pnt1 = 0;
|
||||
|
||||
ret = synth_ntom(mp, bandPtr,0,(unsigned char *) samples_tmp,&pnt1);
|
||||
samples += *pnt;
|
||||
ret = synth_ntom(mp, bandPtr, 0, (unsigned char *) samples_tmp, &pnt1);
|
||||
samples += *pnt;
|
||||
|
||||
for(i=0;i<(pnt1>>2);i++) {
|
||||
*( (short *)samples) = *tmp1;
|
||||
samples += 2;
|
||||
tmp1 += 2;
|
||||
}
|
||||
*pnt += pnt1 >> 1;
|
||||
for (i = 0; i < (pnt1 >> 2); i++) {
|
||||
*((short *) samples) = *tmp1;
|
||||
samples += 2;
|
||||
tmp1 += 2;
|
||||
}
|
||||
*pnt += pnt1 >> 1;
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int synth_ntom(struct mpstr *mp, real *bandPtr,int channel,unsigned char *out,int *pnt)
|
||||
int synth_ntom(struct mpstr *mp, real * bandPtr, int channel, unsigned char *out, int *pnt)
|
||||
{
|
||||
static const int step = 2;
|
||||
int bo;
|
||||
short *samples = (short *) (out + *pnt);
|
||||
static const int step = 2;
|
||||
int bo;
|
||||
short *samples = (short *) (out + *pnt);
|
||||
|
||||
real *b0,(*buf)[0x110];
|
||||
int clip = 0;
|
||||
int bo1;
|
||||
int ntom;
|
||||
real *b0, (*buf)[0x110];
|
||||
int clip = 0;
|
||||
int bo1;
|
||||
int ntom;
|
||||
|
||||
bo = mp->synth_bo;
|
||||
|
||||
if(!channel) {
|
||||
bo--;
|
||||
bo &= 0xf;
|
||||
buf = mp->synth_buffs[0];
|
||||
ntom = ntom_val[1] = ntom_val[0];
|
||||
}
|
||||
else {
|
||||
samples++;
|
||||
out += 2; /* to compute the right *pnt value */
|
||||
buf = mp->synth_buffs[1];
|
||||
ntom = ntom_val[1];
|
||||
}
|
||||
bo = mp->synth_bo;
|
||||
|
||||
if(bo & 0x1) {
|
||||
b0 = buf[0];
|
||||
bo1 = bo;
|
||||
dct64(buf[1]+((bo+1)&0xf),buf[0]+bo,bandPtr);
|
||||
}
|
||||
else {
|
||||
b0 = buf[1];
|
||||
bo1 = bo+1;
|
||||
dct64(buf[0]+bo,buf[1]+bo+1,bandPtr);
|
||||
}
|
||||
if (!channel) {
|
||||
bo--;
|
||||
bo &= 0xf;
|
||||
buf = mp->synth_buffs[0];
|
||||
ntom = ntom_val[1] = ntom_val[0];
|
||||
} else {
|
||||
samples++;
|
||||
out += 2; /* to compute the right *pnt value */
|
||||
buf = mp->synth_buffs[1];
|
||||
ntom = ntom_val[1];
|
||||
}
|
||||
|
||||
mp->synth_bo = bo;
|
||||
|
||||
{
|
||||
register int j;
|
||||
real *window = (mp->decwin) + 16 - bo1;
|
||||
|
||||
for (j=16;j;j--,window+=0x10)
|
||||
{
|
||||
real sum;
|
||||
if (bo & 0x1) {
|
||||
b0 = buf[0];
|
||||
bo1 = bo;
|
||||
dct64(buf[1] + ((bo + 1) & 0xf), buf[0] + bo, bandPtr);
|
||||
} else {
|
||||
b0 = buf[1];
|
||||
bo1 = bo + 1;
|
||||
dct64(buf[0] + bo, buf[1] + bo + 1, bandPtr);
|
||||
}
|
||||
|
||||
ntom += ntom_step;
|
||||
if(ntom < NTOM_MUL) {
|
||||
window += 16;
|
||||
b0 += 16;
|
||||
continue;
|
||||
}
|
||||
mp->synth_bo = bo;
|
||||
|
||||
sum = *window++ * *b0++;
|
||||
sum -= *window++ * *b0++;
|
||||
sum += *window++ * *b0++;
|
||||
sum -= *window++ * *b0++;
|
||||
sum += *window++ * *b0++;
|
||||
sum -= *window++ * *b0++;
|
||||
sum += *window++ * *b0++;
|
||||
sum -= *window++ * *b0++;
|
||||
sum += *window++ * *b0++;
|
||||
sum -= *window++ * *b0++;
|
||||
sum += *window++ * *b0++;
|
||||
sum -= *window++ * *b0++;
|
||||
sum += *window++ * *b0++;
|
||||
sum -= *window++ * *b0++;
|
||||
sum += *window++ * *b0++;
|
||||
sum -= *window++ * *b0++;
|
||||
{
|
||||
register int j;
|
||||
real *window = (mp->decwin) + 16 - bo1;
|
||||
|
||||
while(ntom >= NTOM_MUL) {
|
||||
WRITE_SAMPLE(samples,sum,clip);
|
||||
samples += step;
|
||||
ntom -= NTOM_MUL;
|
||||
}
|
||||
}
|
||||
for (j = 16; j; j--, window += 0x10) {
|
||||
real sum;
|
||||
|
||||
ntom += ntom_step;
|
||||
if(ntom >= NTOM_MUL)
|
||||
{
|
||||
real sum;
|
||||
sum = window[0x0] * b0[0x0];
|
||||
sum += window[0x2] * b0[0x2];
|
||||
sum += window[0x4] * b0[0x4];
|
||||
sum += window[0x6] * b0[0x6];
|
||||
sum += window[0x8] * b0[0x8];
|
||||
sum += window[0xA] * b0[0xA];
|
||||
sum += window[0xC] * b0[0xC];
|
||||
sum += window[0xE] * b0[0xE];
|
||||
ntom += ntom_step;
|
||||
if (ntom < NTOM_MUL) {
|
||||
window += 16;
|
||||
b0 += 16;
|
||||
continue;
|
||||
}
|
||||
|
||||
while(ntom >= NTOM_MUL) {
|
||||
WRITE_SAMPLE(samples,sum,clip);
|
||||
samples += step;
|
||||
ntom -= NTOM_MUL;
|
||||
}
|
||||
}
|
||||
sum = *window++ * *b0++;
|
||||
sum -= *window++ * *b0++;
|
||||
sum += *window++ * *b0++;
|
||||
sum -= *window++ * *b0++;
|
||||
sum += *window++ * *b0++;
|
||||
sum -= *window++ * *b0++;
|
||||
sum += *window++ * *b0++;
|
||||
sum -= *window++ * *b0++;
|
||||
sum += *window++ * *b0++;
|
||||
sum -= *window++ * *b0++;
|
||||
sum += *window++ * *b0++;
|
||||
sum -= *window++ * *b0++;
|
||||
sum += *window++ * *b0++;
|
||||
sum -= *window++ * *b0++;
|
||||
sum += *window++ * *b0++;
|
||||
sum -= *window++ * *b0++;
|
||||
|
||||
b0-=0x10,window-=0x20;
|
||||
window += bo1<<1;
|
||||
while (ntom >= NTOM_MUL) {
|
||||
WRITE_SAMPLE(samples, sum, clip);
|
||||
samples += step;
|
||||
ntom -= NTOM_MUL;
|
||||
}
|
||||
}
|
||||
|
||||
for (j=15;j;j--,b0-=0x20,window-=0x10)
|
||||
{
|
||||
real sum;
|
||||
ntom += ntom_step;
|
||||
if (ntom >= NTOM_MUL) {
|
||||
real sum;
|
||||
sum = window[0x0] * b0[0x0];
|
||||
sum += window[0x2] * b0[0x2];
|
||||
sum += window[0x4] * b0[0x4];
|
||||
sum += window[0x6] * b0[0x6];
|
||||
sum += window[0x8] * b0[0x8];
|
||||
sum += window[0xA] * b0[0xA];
|
||||
sum += window[0xC] * b0[0xC];
|
||||
sum += window[0xE] * b0[0xE];
|
||||
|
||||
ntom += ntom_step;
|
||||
if(ntom < NTOM_MUL) {
|
||||
window -= 16;
|
||||
b0 += 16;
|
||||
continue;
|
||||
}
|
||||
while (ntom >= NTOM_MUL) {
|
||||
WRITE_SAMPLE(samples, sum, clip);
|
||||
samples += step;
|
||||
ntom -= NTOM_MUL;
|
||||
}
|
||||
}
|
||||
|
||||
sum = -*(--window) * *b0++;
|
||||
sum -= *(--window) * *b0++;
|
||||
sum -= *(--window) * *b0++;
|
||||
sum -= *(--window) * *b0++;
|
||||
sum -= *(--window) * *b0++;
|
||||
sum -= *(--window) * *b0++;
|
||||
sum -= *(--window) * *b0++;
|
||||
sum -= *(--window) * *b0++;
|
||||
sum -= *(--window) * *b0++;
|
||||
sum -= *(--window) * *b0++;
|
||||
sum -= *(--window) * *b0++;
|
||||
sum -= *(--window) * *b0++;
|
||||
sum -= *(--window) * *b0++;
|
||||
sum -= *(--window) * *b0++;
|
||||
sum -= *(--window) * *b0++;
|
||||
sum -= *(--window) * *b0++;
|
||||
b0 -= 0x10, window -= 0x20;
|
||||
window += bo1 << 1;
|
||||
|
||||
while(ntom >= NTOM_MUL) {
|
||||
WRITE_SAMPLE(samples,sum,clip);
|
||||
samples += step;
|
||||
ntom -= NTOM_MUL;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (j = 15; j; j--, b0 -= 0x20, window -= 0x10) {
|
||||
real sum;
|
||||
|
||||
ntom_val[channel] = ntom;
|
||||
*pnt = ((unsigned char *) samples - out);
|
||||
ntom += ntom_step;
|
||||
if (ntom < NTOM_MUL) {
|
||||
window -= 16;
|
||||
b0 += 16;
|
||||
continue;
|
||||
}
|
||||
|
||||
return clip;
|
||||
sum = -*(--window) * *b0++;
|
||||
sum -= *(--window) * *b0++;
|
||||
sum -= *(--window) * *b0++;
|
||||
sum -= *(--window) * *b0++;
|
||||
sum -= *(--window) * *b0++;
|
||||
sum -= *(--window) * *b0++;
|
||||
sum -= *(--window) * *b0++;
|
||||
sum -= *(--window) * *b0++;
|
||||
sum -= *(--window) * *b0++;
|
||||
sum -= *(--window) * *b0++;
|
||||
sum -= *(--window) * *b0++;
|
||||
sum -= *(--window) * *b0++;
|
||||
sum -= *(--window) * *b0++;
|
||||
sum -= *(--window) * *b0++;
|
||||
sum -= *(--window) * *b0++;
|
||||
sum -= *(--window) * *b0++;
|
||||
|
||||
while (ntom >= NTOM_MUL) {
|
||||
WRITE_SAMPLE(samples, sum, clip);
|
||||
samples += step;
|
||||
ntom -= NTOM_MUL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ntom_val[channel] = ntom;
|
||||
*pnt = ((unsigned char *) samples - out);
|
||||
|
||||
return clip;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+257
-280
@@ -6,327 +6,304 @@
|
||||
* smaller tables are often the part of a bigger table
|
||||
*/
|
||||
|
||||
struct newhuff
|
||||
{
|
||||
unsigned int linbits;
|
||||
short *table;
|
||||
struct newhuff {
|
||||
unsigned int linbits;
|
||||
short *table;
|
||||
};
|
||||
|
||||
static short tab0[] =
|
||||
{
|
||||
0
|
||||
static short tab0[] = {
|
||||
0
|
||||
};
|
||||
|
||||
static short tab1[] =
|
||||
{
|
||||
-5, -3, -1, 17, 1, 16, 0
|
||||
static short tab1[] = {
|
||||
-5, -3, -1, 17, 1, 16, 0
|
||||
};
|
||||
|
||||
static short tab2[] =
|
||||
{
|
||||
-15, -11, -9, -5, -3, -1, 34, 2, 18, -1, 33, 32, 17, -1, 1,
|
||||
16, 0
|
||||
static short tab2[] = {
|
||||
-15, -11, -9, -5, -3, -1, 34, 2, 18, -1, 33, 32, 17, -1, 1,
|
||||
16, 0
|
||||
};
|
||||
|
||||
static short tab3[] =
|
||||
{
|
||||
-13, -11, -9, -5, -3, -1, 34, 2, 18, -1, 33, 32, 16, 17, -1,
|
||||
1, 0
|
||||
static short tab3[] = {
|
||||
-13, -11, -9, -5, -3, -1, 34, 2, 18, -1, 33, 32, 16, 17, -1,
|
||||
1, 0
|
||||
};
|
||||
|
||||
static short tab5[] =
|
||||
{
|
||||
-29, -25, -23, -15, -7, -5, -3, -1, 51, 35, 50, 49, -3, -1, 19,
|
||||
3, -1, 48, 34, -3, -1, 18, 33, -1, 2, 32, 17, -1, 1, 16,
|
||||
0
|
||||
static short tab5[] = {
|
||||
-29, -25, -23, -15, -7, -5, -3, -1, 51, 35, 50, 49, -3, -1, 19,
|
||||
3, -1, 48, 34, -3, -1, 18, 33, -1, 2, 32, 17, -1, 1, 16,
|
||||
0
|
||||
};
|
||||
|
||||
static short tab6[] =
|
||||
{
|
||||
-25, -19, -13, -9, -5, -3, -1, 51, 3, 35, -1, 50, 48, -1, 19,
|
||||
49, -3, -1, 34, 2, 18, -3, -1, 33, 32, 1, -1, 17, -1, 16,
|
||||
0
|
||||
static short tab6[] = {
|
||||
-25, -19, -13, -9, -5, -3, -1, 51, 3, 35, -1, 50, 48, -1, 19,
|
||||
49, -3, -1, 34, 2, 18, -3, -1, 33, 32, 1, -1, 17, -1, 16,
|
||||
0
|
||||
};
|
||||
|
||||
static short tab7[] =
|
||||
{
|
||||
-69, -65, -57, -39, -29, -17, -11, -7, -3, -1, 85, 69, -1, 84, 83,
|
||||
-1, 53, 68, -3, -1, 37, 82, 21, -5, -1, 81, -1, 5, 52, -1,
|
||||
80, -1, 67, 51, -5, -3, -1, 36, 66, 20, -1, 65, 64, -11, -7,
|
||||
-3, -1, 4, 35, -1, 50, 3, -1, 19, 49, -3, -1, 48, 34, 18,
|
||||
-5, -1, 33, -1, 2, 32, 17, -1, 1, 16, 0
|
||||
static short tab7[] = {
|
||||
-69, -65, -57, -39, -29, -17, -11, -7, -3, -1, 85, 69, -1, 84, 83,
|
||||
-1, 53, 68, -3, -1, 37, 82, 21, -5, -1, 81, -1, 5, 52, -1,
|
||||
80, -1, 67, 51, -5, -3, -1, 36, 66, 20, -1, 65, 64, -11, -7,
|
||||
-3, -1, 4, 35, -1, 50, 3, -1, 19, 49, -3, -1, 48, 34, 18,
|
||||
-5, -1, 33, -1, 2, 32, 17, -1, 1, 16, 0
|
||||
};
|
||||
|
||||
static short tab8[] =
|
||||
{
|
||||
-65, -63, -59, -45, -31, -19, -13, -7, -5, -3, -1, 85, 84, 69, 83,
|
||||
-3, -1, 53, 68, 37, -3, -1, 82, 5, 21, -5, -1, 81, -1, 52,
|
||||
67, -3, -1, 80, 51, 36, -5, -3, -1, 66, 20, 65, -3, -1, 4,
|
||||
64, -1, 35, 50, -9, -7, -3, -1, 19, 49, -1, 3, 48, 34, -1,
|
||||
2, 32, -1, 18, 33, 17, -3, -1, 1, 16, 0
|
||||
static short tab8[] = {
|
||||
-65, -63, -59, -45, -31, -19, -13, -7, -5, -3, -1, 85, 84, 69, 83,
|
||||
-3, -1, 53, 68, 37, -3, -1, 82, 5, 21, -5, -1, 81, -1, 52,
|
||||
67, -3, -1, 80, 51, 36, -5, -3, -1, 66, 20, 65, -3, -1, 4,
|
||||
64, -1, 35, 50, -9, -7, -3, -1, 19, 49, -1, 3, 48, 34, -1,
|
||||
2, 32, -1, 18, 33, 17, -3, -1, 1, 16, 0
|
||||
};
|
||||
|
||||
static short tab9[] =
|
||||
{
|
||||
-63, -53, -41, -29, -19, -11, -5, -3, -1, 85, 69, 53, -1, 83, -1,
|
||||
84, 5, -3, -1, 68, 37, -1, 82, 21, -3, -1, 81, 52, -1, 67,
|
||||
-1, 80, 4, -7, -3, -1, 36, 66, -1, 51, 64, -1, 20, 65, -5,
|
||||
-3, -1, 35, 50, 19, -1, 49, -1, 3, 48, -5, -3, -1, 34, 2,
|
||||
18, -1, 33, 32, -3, -1, 17, 1, -1, 16, 0
|
||||
static short tab9[] = {
|
||||
-63, -53, -41, -29, -19, -11, -5, -3, -1, 85, 69, 53, -1, 83, -1,
|
||||
84, 5, -3, -1, 68, 37, -1, 82, 21, -3, -1, 81, 52, -1, 67,
|
||||
-1, 80, 4, -7, -3, -1, 36, 66, -1, 51, 64, -1, 20, 65, -5,
|
||||
-3, -1, 35, 50, 19, -1, 49, -1, 3, 48, -5, -3, -1, 34, 2,
|
||||
18, -1, 33, 32, -3, -1, 17, 1, -1, 16, 0
|
||||
};
|
||||
|
||||
static short tab10[] =
|
||||
{
|
||||
-125,-121,-111, -83, -55, -35, -21, -13, -7, -3, -1, 119, 103, -1, 118,
|
||||
87, -3, -1, 117, 102, 71, -3, -1, 116, 86, -1, 101, 55, -9, -3,
|
||||
-1, 115, 70, -3, -1, 85, 84, 99, -1, 39, 114, -11, -5, -3, -1,
|
||||
100, 7, 112, -1, 98, -1, 69, 53, -5, -1, 6, -1, 83, 68, 23,
|
||||
-17, -5, -1, 113, -1, 54, 38, -5, -3, -1, 37, 82, 21, -1, 81,
|
||||
-1, 52, 67, -3, -1, 22, 97, -1, 96, -1, 5, 80, -19, -11, -7,
|
||||
-3, -1, 36, 66, -1, 51, 4, -1, 20, 65, -3, -1, 64, 35, -1,
|
||||
50, 3, -3, -1, 19, 49, -1, 48, 34, -7, -3, -1, 18, 33, -1,
|
||||
2, 32, 17, -1, 1, 16, 0
|
||||
static short tab10[] = {
|
||||
-125, -121, -111, -83, -55, -35, -21, -13, -7, -3, -1, 119, 103, -1, 118,
|
||||
87, -3, -1, 117, 102, 71, -3, -1, 116, 86, -1, 101, 55, -9, -3,
|
||||
-1, 115, 70, -3, -1, 85, 84, 99, -1, 39, 114, -11, -5, -3, -1,
|
||||
100, 7, 112, -1, 98, -1, 69, 53, -5, -1, 6, -1, 83, 68, 23,
|
||||
-17, -5, -1, 113, -1, 54, 38, -5, -3, -1, 37, 82, 21, -1, 81,
|
||||
-1, 52, 67, -3, -1, 22, 97, -1, 96, -1, 5, 80, -19, -11, -7,
|
||||
-3, -1, 36, 66, -1, 51, 4, -1, 20, 65, -3, -1, 64, 35, -1,
|
||||
50, 3, -3, -1, 19, 49, -1, 48, 34, -7, -3, -1, 18, 33, -1,
|
||||
2, 32, 17, -1, 1, 16, 0
|
||||
};
|
||||
|
||||
static short tab11[] =
|
||||
{
|
||||
-121,-113, -89, -59, -43, -27, -17, -7, -3, -1, 119, 103, -1, 118, 117,
|
||||
-3, -1, 102, 71, -1, 116, -1, 87, 85, -5, -3, -1, 86, 101, 55,
|
||||
-1, 115, 70, -9, -7, -3, -1, 69, 84, -1, 53, 83, 39, -1, 114,
|
||||
-1, 100, 7, -5, -1, 113, -1, 23, 112, -3, -1, 54, 99, -1, 96,
|
||||
-1, 68, 37, -13, -7, -5, -3, -1, 82, 5, 21, 98, -3, -1, 38,
|
||||
6, 22, -5, -1, 97, -1, 81, 52, -5, -1, 80, -1, 67, 51, -1,
|
||||
36, 66, -15, -11, -7, -3, -1, 20, 65, -1, 4, 64, -1, 35, 50,
|
||||
-1, 19, 49, -5, -3, -1, 3, 48, 34, 33, -5, -1, 18, -1, 2,
|
||||
32, 17, -3, -1, 1, 16, 0
|
||||
static short tab11[] = {
|
||||
-121, -113, -89, -59, -43, -27, -17, -7, -3, -1, 119, 103, -1, 118, 117,
|
||||
-3, -1, 102, 71, -1, 116, -1, 87, 85, -5, -3, -1, 86, 101, 55,
|
||||
-1, 115, 70, -9, -7, -3, -1, 69, 84, -1, 53, 83, 39, -1, 114,
|
||||
-1, 100, 7, -5, -1, 113, -1, 23, 112, -3, -1, 54, 99, -1, 96,
|
||||
-1, 68, 37, -13, -7, -5, -3, -1, 82, 5, 21, 98, -3, -1, 38,
|
||||
6, 22, -5, -1, 97, -1, 81, 52, -5, -1, 80, -1, 67, 51, -1,
|
||||
36, 66, -15, -11, -7, -3, -1, 20, 65, -1, 4, 64, -1, 35, 50,
|
||||
-1, 19, 49, -5, -3, -1, 3, 48, 34, 33, -5, -1, 18, -1, 2,
|
||||
32, 17, -3, -1, 1, 16, 0
|
||||
};
|
||||
|
||||
static short tab12[] =
|
||||
{
|
||||
-115, -99, -73, -45, -27, -17, -9, -5, -3, -1, 119, 103, 118, -1, 87,
|
||||
117, -3, -1, 102, 71, -1, 116, 101, -3, -1, 86, 55, -3, -1, 115,
|
||||
85, 39, -7, -3, -1, 114, 70, -1, 100, 23, -5, -1, 113, -1, 7,
|
||||
112, -1, 54, 99, -13, -9, -3, -1, 69, 84, -1, 68, -1, 6, 5,
|
||||
-1, 38, 98, -5, -1, 97, -1, 22, 96, -3, -1, 53, 83, -1, 37,
|
||||
82, -17, -7, -3, -1, 21, 81, -1, 52, 67, -5, -3, -1, 80, 4,
|
||||
36, -1, 66, 20, -3, -1, 51, 65, -1, 35, 50, -11, -7, -5, -3,
|
||||
-1, 64, 3, 48, 19, -1, 49, 34, -1, 18, 33, -7, -5, -3, -1,
|
||||
2, 32, 0, 17, -1, 1, 16
|
||||
static short tab12[] = {
|
||||
-115, -99, -73, -45, -27, -17, -9, -5, -3, -1, 119, 103, 118, -1, 87,
|
||||
117, -3, -1, 102, 71, -1, 116, 101, -3, -1, 86, 55, -3, -1, 115,
|
||||
85, 39, -7, -3, -1, 114, 70, -1, 100, 23, -5, -1, 113, -1, 7,
|
||||
112, -1, 54, 99, -13, -9, -3, -1, 69, 84, -1, 68, -1, 6, 5,
|
||||
-1, 38, 98, -5, -1, 97, -1, 22, 96, -3, -1, 53, 83, -1, 37,
|
||||
82, -17, -7, -3, -1, 21, 81, -1, 52, 67, -5, -3, -1, 80, 4,
|
||||
36, -1, 66, 20, -3, -1, 51, 65, -1, 35, 50, -11, -7, -5, -3,
|
||||
-1, 64, 3, 48, 19, -1, 49, 34, -1, 18, 33, -7, -5, -3, -1,
|
||||
2, 32, 0, 17, -1, 1, 16
|
||||
};
|
||||
|
||||
static short tab13[] =
|
||||
{
|
||||
-509,-503,-475,-405,-333,-265,-205,-153,-115, -83, -53, -35, -21, -13, -9,
|
||||
-7, -5, -3, -1, 254, 252, 253, 237, 255, -1, 239, 223, -3, -1, 238,
|
||||
207, -1, 222, 191, -9, -3, -1, 251, 206, -1, 220, -1, 175, 233, -1,
|
||||
236, 221, -9, -5, -3, -1, 250, 205, 190, -1, 235, 159, -3, -1, 249,
|
||||
234, -1, 189, 219, -17, -9, -3, -1, 143, 248, -1, 204, -1, 174, 158,
|
||||
-5, -1, 142, -1, 127, 126, 247, -5, -1, 218, -1, 173, 188, -3, -1,
|
||||
203, 246, 111, -15, -7, -3, -1, 232, 95, -1, 157, 217, -3, -1, 245,
|
||||
231, -1, 172, 187, -9, -3, -1, 79, 244, -3, -1, 202, 230, 243, -1,
|
||||
63, -1, 141, 216, -21, -9, -3, -1, 47, 242, -3, -1, 110, 156, 15,
|
||||
-5, -3, -1, 201, 94, 171, -3, -1, 125, 215, 78, -11, -5, -3, -1,
|
||||
200, 214, 62, -1, 185, -1, 155, 170, -1, 31, 241, -23, -13, -5, -1,
|
||||
240, -1, 186, 229, -3, -1, 228, 140, -1, 109, 227, -5, -1, 226, -1,
|
||||
46, 14, -1, 30, 225, -15, -7, -3, -1, 224, 93, -1, 213, 124, -3,
|
||||
-1, 199, 77, -1, 139, 184, -7, -3, -1, 212, 154, -1, 169, 108, -1,
|
||||
198, 61, -37, -21, -9, -5, -3, -1, 211, 123, 45, -1, 210, 29, -5,
|
||||
-1, 183, -1, 92, 197, -3, -1, 153, 122, 195, -7, -5, -3, -1, 167,
|
||||
151, 75, 209, -3, -1, 13, 208, -1, 138, 168, -11, -7, -3, -1, 76,
|
||||
196, -1, 107, 182, -1, 60, 44, -3, -1, 194, 91, -3, -1, 181, 137,
|
||||
28, -43, -23, -11, -5, -1, 193, -1, 152, 12, -1, 192, -1, 180, 106,
|
||||
-5, -3, -1, 166, 121, 59, -1, 179, -1, 136, 90, -11, -5, -1, 43,
|
||||
-1, 165, 105, -1, 164, -1, 120, 135, -5, -1, 148, -1, 119, 118, 178,
|
||||
-11, -3, -1, 27, 177, -3, -1, 11, 176, -1, 150, 74, -7, -3, -1,
|
||||
58, 163, -1, 89, 149, -1, 42, 162, -47, -23, -9, -3, -1, 26, 161,
|
||||
-3, -1, 10, 104, 160, -5, -3, -1, 134, 73, 147, -3, -1, 57, 88,
|
||||
-1, 133, 103, -9, -3, -1, 41, 146, -3, -1, 87, 117, 56, -5, -1,
|
||||
131, -1, 102, 71, -3, -1, 116, 86, -1, 101, 115, -11, -3, -1, 25,
|
||||
145, -3, -1, 9, 144, -1, 72, 132, -7, -5, -1, 114, -1, 70, 100,
|
||||
40, -1, 130, 24, -41, -27, -11, -5, -3, -1, 55, 39, 23, -1, 113,
|
||||
-1, 85, 7, -7, -3, -1, 112, 54, -1, 99, 69, -3, -1, 84, 38,
|
||||
-1, 98, 53, -5, -1, 129, -1, 8, 128, -3, -1, 22, 97, -1, 6,
|
||||
96, -13, -9, -5, -3, -1, 83, 68, 37, -1, 82, 5, -1, 21, 81,
|
||||
-7, -3, -1, 52, 67, -1, 80, 36, -3, -1, 66, 51, 20, -19, -11,
|
||||
-5, -1, 65, -1, 4, 64, -3, -1, 35, 50, 19, -3, -1, 49, 3,
|
||||
-1, 48, 34, -3, -1, 18, 33, -1, 2, 32, -3, -1, 17, 1, 16,
|
||||
0
|
||||
static short tab13[] = {
|
||||
-509, -503, -475, -405, -333, -265, -205, -153, -115, -83, -53, -35, -21, -13, -9,
|
||||
-7, -5, -3, -1, 254, 252, 253, 237, 255, -1, 239, 223, -3, -1, 238,
|
||||
207, -1, 222, 191, -9, -3, -1, 251, 206, -1, 220, -1, 175, 233, -1,
|
||||
236, 221, -9, -5, -3, -1, 250, 205, 190, -1, 235, 159, -3, -1, 249,
|
||||
234, -1, 189, 219, -17, -9, -3, -1, 143, 248, -1, 204, -1, 174, 158,
|
||||
-5, -1, 142, -1, 127, 126, 247, -5, -1, 218, -1, 173, 188, -3, -1,
|
||||
203, 246, 111, -15, -7, -3, -1, 232, 95, -1, 157, 217, -3, -1, 245,
|
||||
231, -1, 172, 187, -9, -3, -1, 79, 244, -3, -1, 202, 230, 243, -1,
|
||||
63, -1, 141, 216, -21, -9, -3, -1, 47, 242, -3, -1, 110, 156, 15,
|
||||
-5, -3, -1, 201, 94, 171, -3, -1, 125, 215, 78, -11, -5, -3, -1,
|
||||
200, 214, 62, -1, 185, -1, 155, 170, -1, 31, 241, -23, -13, -5, -1,
|
||||
240, -1, 186, 229, -3, -1, 228, 140, -1, 109, 227, -5, -1, 226, -1,
|
||||
46, 14, -1, 30, 225, -15, -7, -3, -1, 224, 93, -1, 213, 124, -3,
|
||||
-1, 199, 77, -1, 139, 184, -7, -3, -1, 212, 154, -1, 169, 108, -1,
|
||||
198, 61, -37, -21, -9, -5, -3, -1, 211, 123, 45, -1, 210, 29, -5,
|
||||
-1, 183, -1, 92, 197, -3, -1, 153, 122, 195, -7, -5, -3, -1, 167,
|
||||
151, 75, 209, -3, -1, 13, 208, -1, 138, 168, -11, -7, -3, -1, 76,
|
||||
196, -1, 107, 182, -1, 60, 44, -3, -1, 194, 91, -3, -1, 181, 137,
|
||||
28, -43, -23, -11, -5, -1, 193, -1, 152, 12, -1, 192, -1, 180, 106,
|
||||
-5, -3, -1, 166, 121, 59, -1, 179, -1, 136, 90, -11, -5, -1, 43,
|
||||
-1, 165, 105, -1, 164, -1, 120, 135, -5, -1, 148, -1, 119, 118, 178,
|
||||
-11, -3, -1, 27, 177, -3, -1, 11, 176, -1, 150, 74, -7, -3, -1,
|
||||
58, 163, -1, 89, 149, -1, 42, 162, -47, -23, -9, -3, -1, 26, 161,
|
||||
-3, -1, 10, 104, 160, -5, -3, -1, 134, 73, 147, -3, -1, 57, 88,
|
||||
-1, 133, 103, -9, -3, -1, 41, 146, -3, -1, 87, 117, 56, -5, -1,
|
||||
131, -1, 102, 71, -3, -1, 116, 86, -1, 101, 115, -11, -3, -1, 25,
|
||||
145, -3, -1, 9, 144, -1, 72, 132, -7, -5, -1, 114, -1, 70, 100,
|
||||
40, -1, 130, 24, -41, -27, -11, -5, -3, -1, 55, 39, 23, -1, 113,
|
||||
-1, 85, 7, -7, -3, -1, 112, 54, -1, 99, 69, -3, -1, 84, 38,
|
||||
-1, 98, 53, -5, -1, 129, -1, 8, 128, -3, -1, 22, 97, -1, 6,
|
||||
96, -13, -9, -5, -3, -1, 83, 68, 37, -1, 82, 5, -1, 21, 81,
|
||||
-7, -3, -1, 52, 67, -1, 80, 36, -3, -1, 66, 51, 20, -19, -11,
|
||||
-5, -1, 65, -1, 4, 64, -3, -1, 35, 50, 19, -3, -1, 49, 3,
|
||||
-1, 48, 34, -3, -1, 18, 33, -1, 2, 32, -3, -1, 17, 1, 16,
|
||||
0
|
||||
};
|
||||
|
||||
static short tab15[] =
|
||||
{
|
||||
-495,-445,-355,-263,-183,-115, -77, -43, -27, -13, -7, -3, -1, 255, 239,
|
||||
-1, 254, 223, -1, 238, -1, 253, 207, -7, -3, -1, 252, 222, -1, 237,
|
||||
191, -1, 251, -1, 206, 236, -7, -3, -1, 221, 175, -1, 250, 190, -3,
|
||||
-1, 235, 205, -1, 220, 159, -15, -7, -3, -1, 249, 234, -1, 189, 219,
|
||||
-3, -1, 143, 248, -1, 204, 158, -7, -3, -1, 233, 127, -1, 247, 173,
|
||||
-3, -1, 218, 188, -1, 111, -1, 174, 15, -19, -11, -3, -1, 203, 246,
|
||||
-3, -1, 142, 232, -1, 95, 157, -3, -1, 245, 126, -1, 231, 172, -9,
|
||||
-3, -1, 202, 187, -3, -1, 217, 141, 79, -3, -1, 244, 63, -1, 243,
|
||||
216, -33, -17, -9, -3, -1, 230, 47, -1, 242, -1, 110, 240, -3, -1,
|
||||
31, 241, -1, 156, 201, -7, -3, -1, 94, 171, -1, 186, 229, -3, -1,
|
||||
125, 215, -1, 78, 228, -15, -7, -3, -1, 140, 200, -1, 62, 109, -3,
|
||||
-1, 214, 227, -1, 155, 185, -7, -3, -1, 46, 170, -1, 226, 30, -5,
|
||||
-1, 225, -1, 14, 224, -1, 93, 213, -45, -25, -13, -7, -3, -1, 124,
|
||||
199, -1, 77, 139, -1, 212, -1, 184, 154, -7, -3, -1, 169, 108, -1,
|
||||
198, 61, -1, 211, 210, -9, -5, -3, -1, 45, 13, 29, -1, 123, 183,
|
||||
-5, -1, 209, -1, 92, 208, -1, 197, 138, -17, -7, -3, -1, 168, 76,
|
||||
-1, 196, 107, -5, -1, 182, -1, 153, 12, -1, 60, 195, -9, -3, -1,
|
||||
122, 167, -1, 166, -1, 192, 11, -1, 194, -1, 44, 91, -55, -29, -15,
|
||||
-7, -3, -1, 181, 28, -1, 137, 152, -3, -1, 193, 75, -1, 180, 106,
|
||||
-5, -3, -1, 59, 121, 179, -3, -1, 151, 136, -1, 43, 90, -11, -5,
|
||||
-1, 178, -1, 165, 27, -1, 177, -1, 176, 105, -7, -3, -1, 150, 74,
|
||||
-1, 164, 120, -3, -1, 135, 58, 163, -17, -7, -3, -1, 89, 149, -1,
|
||||
42, 162, -3, -1, 26, 161, -3, -1, 10, 160, 104, -7, -3, -1, 134,
|
||||
73, -1, 148, 57, -5, -1, 147, -1, 119, 9, -1, 88, 133, -53, -29,
|
||||
-13, -7, -3, -1, 41, 103, -1, 118, 146, -1, 145, -1, 25, 144, -7,
|
||||
-3, -1, 72, 132, -1, 87, 117, -3, -1, 56, 131, -1, 102, 71, -7,
|
||||
-3, -1, 40, 130, -1, 24, 129, -7, -3, -1, 116, 8, -1, 128, 86,
|
||||
-3, -1, 101, 55, -1, 115, 70, -17, -7, -3, -1, 39, 114, -1, 100,
|
||||
23, -3, -1, 85, 113, -3, -1, 7, 112, 54, -7, -3, -1, 99, 69,
|
||||
-1, 84, 38, -3, -1, 98, 22, -3, -1, 6, 96, 53, -33, -19, -9,
|
||||
-5, -1, 97, -1, 83, 68, -1, 37, 82, -3, -1, 21, 81, -3, -1,
|
||||
5, 80, 52, -7, -3, -1, 67, 36, -1, 66, 51, -1, 65, -1, 20,
|
||||
4, -9, -3, -1, 35, 50, -3, -1, 64, 3, 19, -3, -1, 49, 48,
|
||||
34, -9, -7, -3, -1, 18, 33, -1, 2, 32, 17, -3, -1, 1, 16,
|
||||
0
|
||||
static short tab15[] = {
|
||||
-495, -445, -355, -263, -183, -115, -77, -43, -27, -13, -7, -3, -1, 255, 239,
|
||||
-1, 254, 223, -1, 238, -1, 253, 207, -7, -3, -1, 252, 222, -1, 237,
|
||||
191, -1, 251, -1, 206, 236, -7, -3, -1, 221, 175, -1, 250, 190, -3,
|
||||
-1, 235, 205, -1, 220, 159, -15, -7, -3, -1, 249, 234, -1, 189, 219,
|
||||
-3, -1, 143, 248, -1, 204, 158, -7, -3, -1, 233, 127, -1, 247, 173,
|
||||
-3, -1, 218, 188, -1, 111, -1, 174, 15, -19, -11, -3, -1, 203, 246,
|
||||
-3, -1, 142, 232, -1, 95, 157, -3, -1, 245, 126, -1, 231, 172, -9,
|
||||
-3, -1, 202, 187, -3, -1, 217, 141, 79, -3, -1, 244, 63, -1, 243,
|
||||
216, -33, -17, -9, -3, -1, 230, 47, -1, 242, -1, 110, 240, -3, -1,
|
||||
31, 241, -1, 156, 201, -7, -3, -1, 94, 171, -1, 186, 229, -3, -1,
|
||||
125, 215, -1, 78, 228, -15, -7, -3, -1, 140, 200, -1, 62, 109, -3,
|
||||
-1, 214, 227, -1, 155, 185, -7, -3, -1, 46, 170, -1, 226, 30, -5,
|
||||
-1, 225, -1, 14, 224, -1, 93, 213, -45, -25, -13, -7, -3, -1, 124,
|
||||
199, -1, 77, 139, -1, 212, -1, 184, 154, -7, -3, -1, 169, 108, -1,
|
||||
198, 61, -1, 211, 210, -9, -5, -3, -1, 45, 13, 29, -1, 123, 183,
|
||||
-5, -1, 209, -1, 92, 208, -1, 197, 138, -17, -7, -3, -1, 168, 76,
|
||||
-1, 196, 107, -5, -1, 182, -1, 153, 12, -1, 60, 195, -9, -3, -1,
|
||||
122, 167, -1, 166, -1, 192, 11, -1, 194, -1, 44, 91, -55, -29, -15,
|
||||
-7, -3, -1, 181, 28, -1, 137, 152, -3, -1, 193, 75, -1, 180, 106,
|
||||
-5, -3, -1, 59, 121, 179, -3, -1, 151, 136, -1, 43, 90, -11, -5,
|
||||
-1, 178, -1, 165, 27, -1, 177, -1, 176, 105, -7, -3, -1, 150, 74,
|
||||
-1, 164, 120, -3, -1, 135, 58, 163, -17, -7, -3, -1, 89, 149, -1,
|
||||
42, 162, -3, -1, 26, 161, -3, -1, 10, 160, 104, -7, -3, -1, 134,
|
||||
73, -1, 148, 57, -5, -1, 147, -1, 119, 9, -1, 88, 133, -53, -29,
|
||||
-13, -7, -3, -1, 41, 103, -1, 118, 146, -1, 145, -1, 25, 144, -7,
|
||||
-3, -1, 72, 132, -1, 87, 117, -3, -1, 56, 131, -1, 102, 71, -7,
|
||||
-3, -1, 40, 130, -1, 24, 129, -7, -3, -1, 116, 8, -1, 128, 86,
|
||||
-3, -1, 101, 55, -1, 115, 70, -17, -7, -3, -1, 39, 114, -1, 100,
|
||||
23, -3, -1, 85, 113, -3, -1, 7, 112, 54, -7, -3, -1, 99, 69,
|
||||
-1, 84, 38, -3, -1, 98, 22, -3, -1, 6, 96, 53, -33, -19, -9,
|
||||
-5, -1, 97, -1, 83, 68, -1, 37, 82, -3, -1, 21, 81, -3, -1,
|
||||
5, 80, 52, -7, -3, -1, 67, 36, -1, 66, 51, -1, 65, -1, 20,
|
||||
4, -9, -3, -1, 35, 50, -3, -1, 64, 3, 19, -3, -1, 49, 48,
|
||||
34, -9, -7, -3, -1, 18, 33, -1, 2, 32, 17, -3, -1, 1, 16,
|
||||
0
|
||||
};
|
||||
|
||||
static short tab16[] =
|
||||
{
|
||||
-509,-503,-461,-323,-103, -37, -27, -15, -7, -3, -1, 239, 254, -1, 223,
|
||||
253, -3, -1, 207, 252, -1, 191, 251, -5, -1, 175, -1, 250, 159, -3,
|
||||
-1, 249, 248, 143, -7, -3, -1, 127, 247, -1, 111, 246, 255, -9, -5,
|
||||
-3, -1, 95, 245, 79, -1, 244, 243, -53, -1, 240, -1, 63, -29, -19,
|
||||
-13, -7, -5, -1, 206, -1, 236, 221, 222, -1, 233, -1, 234, 217, -1,
|
||||
238, -1, 237, 235, -3, -1, 190, 205, -3, -1, 220, 219, 174, -11, -5,
|
||||
-1, 204, -1, 173, 218, -3, -1, 126, 172, 202, -5, -3, -1, 201, 125,
|
||||
94, 189, 242, -93, -5, -3, -1, 47, 15, 31, -1, 241, -49, -25, -13,
|
||||
-5, -1, 158, -1, 188, 203, -3, -1, 142, 232, -1, 157, 231, -7, -3,
|
||||
-1, 187, 141, -1, 216, 110, -1, 230, 156, -13, -7, -3, -1, 171, 186,
|
||||
-1, 229, 215, -1, 78, -1, 228, 140, -3, -1, 200, 62, -1, 109, -1,
|
||||
214, 155, -19, -11, -5, -3, -1, 185, 170, 225, -1, 212, -1, 184, 169,
|
||||
-5, -1, 123, -1, 183, 208, 227, -7, -3, -1, 14, 224, -1, 93, 213,
|
||||
-3, -1, 124, 199, -1, 77, 139, -75, -45, -27, -13, -7, -3, -1, 154,
|
||||
108, -1, 198, 61, -3, -1, 92, 197, 13, -7, -3, -1, 138, 168, -1,
|
||||
153, 76, -3, -1, 182, 122, 60, -11, -5, -3, -1, 91, 137, 28, -1,
|
||||
192, -1, 152, 121, -1, 226, -1, 46, 30, -15, -7, -3, -1, 211, 45,
|
||||
-1, 210, 209, -5, -1, 59, -1, 151, 136, 29, -7, -3, -1, 196, 107,
|
||||
-1, 195, 167, -1, 44, -1, 194, 181, -23, -13, -7, -3, -1, 193, 12,
|
||||
-1, 75, 180, -3, -1, 106, 166, 179, -5, -3, -1, 90, 165, 43, -1,
|
||||
178, 27, -13, -5, -1, 177, -1, 11, 176, -3, -1, 105, 150, -1, 74,
|
||||
164, -5, -3, -1, 120, 135, 163, -3, -1, 58, 89, 42, -97, -57, -33,
|
||||
-19, -11, -5, -3, -1, 149, 104, 161, -3, -1, 134, 119, 148, -5, -3,
|
||||
-1, 73, 87, 103, 162, -5, -1, 26, -1, 10, 160, -3, -1, 57, 147,
|
||||
-1, 88, 133, -9, -3, -1, 41, 146, -3, -1, 118, 9, 25, -5, -1,
|
||||
145, -1, 144, 72, -3, -1, 132, 117, -1, 56, 131, -21, -11, -5, -3,
|
||||
-1, 102, 40, 130, -3, -1, 71, 116, 24, -3, -1, 129, 128, -3, -1,
|
||||
8, 86, 55, -9, -5, -1, 115, -1, 101, 70, -1, 39, 114, -5, -3,
|
||||
-1, 100, 85, 7, 23, -23, -13, -5, -1, 113, -1, 112, 54, -3, -1,
|
||||
99, 69, -1, 84, 38, -3, -1, 98, 22, -1, 97, -1, 6, 96, -9,
|
||||
-5, -1, 83, -1, 53, 68, -1, 37, 82, -1, 81, -1, 21, 5, -33,
|
||||
-23, -13, -7, -3, -1, 52, 67, -1, 80, 36, -3, -1, 66, 51, 20,
|
||||
-5, -1, 65, -1, 4, 64, -1, 35, 50, -3, -1, 19, 49, -3, -1,
|
||||
3, 48, 34, -3, -1, 18, 33, -1, 2, 32, -3, -1, 17, 1, 16,
|
||||
0
|
||||
static short tab16[] = {
|
||||
-509, -503, -461, -323, -103, -37, -27, -15, -7, -3, -1, 239, 254, -1, 223,
|
||||
253, -3, -1, 207, 252, -1, 191, 251, -5, -1, 175, -1, 250, 159, -3,
|
||||
-1, 249, 248, 143, -7, -3, -1, 127, 247, -1, 111, 246, 255, -9, -5,
|
||||
-3, -1, 95, 245, 79, -1, 244, 243, -53, -1, 240, -1, 63, -29, -19,
|
||||
-13, -7, -5, -1, 206, -1, 236, 221, 222, -1, 233, -1, 234, 217, -1,
|
||||
238, -1, 237, 235, -3, -1, 190, 205, -3, -1, 220, 219, 174, -11, -5,
|
||||
-1, 204, -1, 173, 218, -3, -1, 126, 172, 202, -5, -3, -1, 201, 125,
|
||||
94, 189, 242, -93, -5, -3, -1, 47, 15, 31, -1, 241, -49, -25, -13,
|
||||
-5, -1, 158, -1, 188, 203, -3, -1, 142, 232, -1, 157, 231, -7, -3,
|
||||
-1, 187, 141, -1, 216, 110, -1, 230, 156, -13, -7, -3, -1, 171, 186,
|
||||
-1, 229, 215, -1, 78, -1, 228, 140, -3, -1, 200, 62, -1, 109, -1,
|
||||
214, 155, -19, -11, -5, -3, -1, 185, 170, 225, -1, 212, -1, 184, 169,
|
||||
-5, -1, 123, -1, 183, 208, 227, -7, -3, -1, 14, 224, -1, 93, 213,
|
||||
-3, -1, 124, 199, -1, 77, 139, -75, -45, -27, -13, -7, -3, -1, 154,
|
||||
108, -1, 198, 61, -3, -1, 92, 197, 13, -7, -3, -1, 138, 168, -1,
|
||||
153, 76, -3, -1, 182, 122, 60, -11, -5, -3, -1, 91, 137, 28, -1,
|
||||
192, -1, 152, 121, -1, 226, -1, 46, 30, -15, -7, -3, -1, 211, 45,
|
||||
-1, 210, 209, -5, -1, 59, -1, 151, 136, 29, -7, -3, -1, 196, 107,
|
||||
-1, 195, 167, -1, 44, -1, 194, 181, -23, -13, -7, -3, -1, 193, 12,
|
||||
-1, 75, 180, -3, -1, 106, 166, 179, -5, -3, -1, 90, 165, 43, -1,
|
||||
178, 27, -13, -5, -1, 177, -1, 11, 176, -3, -1, 105, 150, -1, 74,
|
||||
164, -5, -3, -1, 120, 135, 163, -3, -1, 58, 89, 42, -97, -57, -33,
|
||||
-19, -11, -5, -3, -1, 149, 104, 161, -3, -1, 134, 119, 148, -5, -3,
|
||||
-1, 73, 87, 103, 162, -5, -1, 26, -1, 10, 160, -3, -1, 57, 147,
|
||||
-1, 88, 133, -9, -3, -1, 41, 146, -3, -1, 118, 9, 25, -5, -1,
|
||||
145, -1, 144, 72, -3, -1, 132, 117, -1, 56, 131, -21, -11, -5, -3,
|
||||
-1, 102, 40, 130, -3, -1, 71, 116, 24, -3, -1, 129, 128, -3, -1,
|
||||
8, 86, 55, -9, -5, -1, 115, -1, 101, 70, -1, 39, 114, -5, -3,
|
||||
-1, 100, 85, 7, 23, -23, -13, -5, -1, 113, -1, 112, 54, -3, -1,
|
||||
99, 69, -1, 84, 38, -3, -1, 98, 22, -1, 97, -1, 6, 96, -9,
|
||||
-5, -1, 83, -1, 53, 68, -1, 37, 82, -1, 81, -1, 21, 5, -33,
|
||||
-23, -13, -7, -3, -1, 52, 67, -1, 80, 36, -3, -1, 66, 51, 20,
|
||||
-5, -1, 65, -1, 4, 64, -1, 35, 50, -3, -1, 19, 49, -3, -1,
|
||||
3, 48, 34, -3, -1, 18, 33, -1, 2, 32, -3, -1, 17, 1, 16,
|
||||
0
|
||||
};
|
||||
|
||||
static short tab24[] =
|
||||
{
|
||||
-451,-117, -43, -25, -15, -7, -3, -1, 239, 254, -1, 223, 253, -3, -1,
|
||||
207, 252, -1, 191, 251, -5, -1, 250, -1, 175, 159, -1, 249, 248, -9,
|
||||
-5, -3, -1, 143, 127, 247, -1, 111, 246, -3, -1, 95, 245, -1, 79,
|
||||
244, -71, -7, -3, -1, 63, 243, -1, 47, 242, -5, -1, 241, -1, 31,
|
||||
240, -25, -9, -1, 15, -3, -1, 238, 222, -1, 237, 206, -7, -3, -1,
|
||||
236, 221, -1, 190, 235, -3, -1, 205, 220, -1, 174, 234, -15, -7, -3,
|
||||
-1, 189, 219, -1, 204, 158, -3, -1, 233, 173, -1, 218, 188, -7, -3,
|
||||
-1, 203, 142, -1, 232, 157, -3, -1, 217, 126, -1, 231, 172, 255,-235,
|
||||
-143, -77, -45, -25, -15, -7, -3, -1, 202, 187, -1, 141, 216, -5, -3,
|
||||
-1, 14, 224, 13, 230, -5, -3, -1, 110, 156, 201, -1, 94, 186, -9,
|
||||
-5, -1, 229, -1, 171, 125, -1, 215, 228, -3, -1, 140, 200, -3, -1,
|
||||
78, 46, 62, -15, -7, -3, -1, 109, 214, -1, 227, 155, -3, -1, 185,
|
||||
170, -1, 226, 30, -7, -3, -1, 225, 93, -1, 213, 124, -3, -1, 199,
|
||||
77, -1, 139, 184, -31, -15, -7, -3, -1, 212, 154, -1, 169, 108, -3,
|
||||
-1, 198, 61, -1, 211, 45, -7, -3, -1, 210, 29, -1, 123, 183, -3,
|
||||
-1, 209, 92, -1, 197, 138, -17, -7, -3, -1, 168, 153, -1, 76, 196,
|
||||
-3, -1, 107, 182, -3, -1, 208, 12, 60, -7, -3, -1, 195, 122, -1,
|
||||
167, 44, -3, -1, 194, 91, -1, 181, 28, -57, -35, -19, -7, -3, -1,
|
||||
137, 152, -1, 193, 75, -5, -3, -1, 192, 11, 59, -3, -1, 176, 10,
|
||||
26, -5, -1, 180, -1, 106, 166, -3, -1, 121, 151, -3, -1, 160, 9,
|
||||
144, -9, -3, -1, 179, 136, -3, -1, 43, 90, 178, -7, -3, -1, 165,
|
||||
27, -1, 177, 105, -1, 150, 164, -17, -9, -5, -3, -1, 74, 120, 135,
|
||||
-1, 58, 163, -3, -1, 89, 149, -1, 42, 162, -7, -3, -1, 161, 104,
|
||||
-1, 134, 119, -3, -1, 73, 148, -1, 57, 147, -63, -31, -15, -7, -3,
|
||||
-1, 88, 133, -1, 41, 103, -3, -1, 118, 146, -1, 25, 145, -7, -3,
|
||||
-1, 72, 132, -1, 87, 117, -3, -1, 56, 131, -1, 102, 40, -17, -7,
|
||||
-3, -1, 130, 24, -1, 71, 116, -5, -1, 129, -1, 8, 128, -1, 86,
|
||||
101, -7, -5, -1, 23, -1, 7, 112, 115, -3, -1, 55, 39, 114, -15,
|
||||
-7, -3, -1, 70, 100, -1, 85, 113, -3, -1, 54, 99, -1, 69, 84,
|
||||
-7, -3, -1, 38, 98, -1, 22, 97, -5, -3, -1, 6, 96, 53, -1,
|
||||
83, 68, -51, -37, -23, -15, -9, -3, -1, 37, 82, -1, 21, -1, 5,
|
||||
80, -1, 81, -1, 52, 67, -3, -1, 36, 66, -1, 51, 20, -9, -5,
|
||||
-1, 65, -1, 4, 64, -1, 35, 50, -1, 19, 49, -7, -5, -3, -1,
|
||||
3, 48, 34, 18, -1, 33, -1, 2, 32, -3, -1, 17, 1, -1, 16,
|
||||
0
|
||||
static short tab24[] = {
|
||||
-451, -117, -43, -25, -15, -7, -3, -1, 239, 254, -1, 223, 253, -3, -1,
|
||||
207, 252, -1, 191, 251, -5, -1, 250, -1, 175, 159, -1, 249, 248, -9,
|
||||
-5, -3, -1, 143, 127, 247, -1, 111, 246, -3, -1, 95, 245, -1, 79,
|
||||
244, -71, -7, -3, -1, 63, 243, -1, 47, 242, -5, -1, 241, -1, 31,
|
||||
240, -25, -9, -1, 15, -3, -1, 238, 222, -1, 237, 206, -7, -3, -1,
|
||||
236, 221, -1, 190, 235, -3, -1, 205, 220, -1, 174, 234, -15, -7, -3,
|
||||
-1, 189, 219, -1, 204, 158, -3, -1, 233, 173, -1, 218, 188, -7, -3,
|
||||
-1, 203, 142, -1, 232, 157, -3, -1, 217, 126, -1, 231, 172, 255, -235,
|
||||
-143, -77, -45, -25, -15, -7, -3, -1, 202, 187, -1, 141, 216, -5, -3,
|
||||
-1, 14, 224, 13, 230, -5, -3, -1, 110, 156, 201, -1, 94, 186, -9,
|
||||
-5, -1, 229, -1, 171, 125, -1, 215, 228, -3, -1, 140, 200, -3, -1,
|
||||
78, 46, 62, -15, -7, -3, -1, 109, 214, -1, 227, 155, -3, -1, 185,
|
||||
170, -1, 226, 30, -7, -3, -1, 225, 93, -1, 213, 124, -3, -1, 199,
|
||||
77, -1, 139, 184, -31, -15, -7, -3, -1, 212, 154, -1, 169, 108, -3,
|
||||
-1, 198, 61, -1, 211, 45, -7, -3, -1, 210, 29, -1, 123, 183, -3,
|
||||
-1, 209, 92, -1, 197, 138, -17, -7, -3, -1, 168, 153, -1, 76, 196,
|
||||
-3, -1, 107, 182, -3, -1, 208, 12, 60, -7, -3, -1, 195, 122, -1,
|
||||
167, 44, -3, -1, 194, 91, -1, 181, 28, -57, -35, -19, -7, -3, -1,
|
||||
137, 152, -1, 193, 75, -5, -3, -1, 192, 11, 59, -3, -1, 176, 10,
|
||||
26, -5, -1, 180, -1, 106, 166, -3, -1, 121, 151, -3, -1, 160, 9,
|
||||
144, -9, -3, -1, 179, 136, -3, -1, 43, 90, 178, -7, -3, -1, 165,
|
||||
27, -1, 177, 105, -1, 150, 164, -17, -9, -5, -3, -1, 74, 120, 135,
|
||||
-1, 58, 163, -3, -1, 89, 149, -1, 42, 162, -7, -3, -1, 161, 104,
|
||||
-1, 134, 119, -3, -1, 73, 148, -1, 57, 147, -63, -31, -15, -7, -3,
|
||||
-1, 88, 133, -1, 41, 103, -3, -1, 118, 146, -1, 25, 145, -7, -3,
|
||||
-1, 72, 132, -1, 87, 117, -3, -1, 56, 131, -1, 102, 40, -17, -7,
|
||||
-3, -1, 130, 24, -1, 71, 116, -5, -1, 129, -1, 8, 128, -1, 86,
|
||||
101, -7, -5, -1, 23, -1, 7, 112, 115, -3, -1, 55, 39, 114, -15,
|
||||
-7, -3, -1, 70, 100, -1, 85, 113, -3, -1, 54, 99, -1, 69, 84,
|
||||
-7, -3, -1, 38, 98, -1, 22, 97, -5, -3, -1, 6, 96, 53, -1,
|
||||
83, 68, -51, -37, -23, -15, -9, -3, -1, 37, 82, -1, 21, -1, 5,
|
||||
80, -1, 81, -1, 52, 67, -3, -1, 36, 66, -1, 51, 20, -9, -5,
|
||||
-1, 65, -1, 4, 64, -1, 35, 50, -1, 19, 49, -7, -5, -3, -1,
|
||||
3, 48, 34, 18, -1, 33, -1, 2, 32, -3, -1, 17, 1, -1, 16,
|
||||
0
|
||||
};
|
||||
|
||||
static short tab_c0[] =
|
||||
{
|
||||
-29, -21, -13, -7, -3, -1, 11, 15, -1, 13, 14, -3, -1, 7, 5,
|
||||
9, -3, -1, 6, 3, -1, 10, 12, -3, -1, 2, 1, -1, 4, 8,
|
||||
0
|
||||
static short tab_c0[] = {
|
||||
-29, -21, -13, -7, -3, -1, 11, 15, -1, 13, 14, -3, -1, 7, 5,
|
||||
9, -3, -1, 6, 3, -1, 10, 12, -3, -1, 2, 1, -1, 4, 8,
|
||||
0
|
||||
};
|
||||
|
||||
static short tab_c1[] =
|
||||
{
|
||||
-15, -7, -3, -1, 15, 14, -1, 13, 12, -3, -1, 11, 10, -1, 9,
|
||||
8, -7, -3, -1, 7, 6, -1, 5, 4, -3, -1, 3, 2, -1, 1,
|
||||
0
|
||||
static short tab_c1[] = {
|
||||
-15, -7, -3, -1, 15, 14, -1, 13, 12, -3, -1, 11, 10, -1, 9,
|
||||
8, -7, -3, -1, 7, 6, -1, 5, 4, -3, -1, 3, 2, -1, 1,
|
||||
0
|
||||
};
|
||||
|
||||
|
||||
|
||||
static struct newhuff ht[] =
|
||||
{
|
||||
{ /* 0 */ 0 , tab0 } ,
|
||||
{ /* 2 */ 0 , tab1 } ,
|
||||
{ /* 3 */ 0 , tab2 } ,
|
||||
{ /* 3 */ 0 , tab3 } ,
|
||||
{ /* 0 */ 0 , tab0 } ,
|
||||
{ /* 4 */ 0 , tab5 } ,
|
||||
{ /* 4 */ 0 , tab6 } ,
|
||||
{ /* 6 */ 0 , tab7 } ,
|
||||
{ /* 6 */ 0 , tab8 } ,
|
||||
{ /* 6 */ 0 , tab9 } ,
|
||||
{ /* 8 */ 0 , tab10 } ,
|
||||
{ /* 8 */ 0 , tab11 } ,
|
||||
{ /* 8 */ 0 , tab12 } ,
|
||||
{ /* 16 */ 0 , tab13 } ,
|
||||
{ /* 0 */ 0 , tab0 } ,
|
||||
{ /* 16 */ 0 , tab15 } ,
|
||||
static struct newhuff ht[] = {
|
||||
{ /* 0 */ 0, tab0},
|
||||
{ /* 2 */ 0, tab1},
|
||||
{ /* 3 */ 0, tab2},
|
||||
{ /* 3 */ 0, tab3},
|
||||
{ /* 0 */ 0, tab0},
|
||||
{ /* 4 */ 0, tab5},
|
||||
{ /* 4 */ 0, tab6},
|
||||
{ /* 6 */ 0, tab7},
|
||||
{ /* 6 */ 0, tab8},
|
||||
{ /* 6 */ 0, tab9},
|
||||
{ /* 8 */ 0, tab10},
|
||||
{ /* 8 */ 0, tab11},
|
||||
{ /* 8 */ 0, tab12},
|
||||
{ /* 16 */ 0, tab13},
|
||||
{ /* 0 */ 0, tab0},
|
||||
{ /* 16 */ 0, tab15},
|
||||
|
||||
{ /* 16 */ 1 , tab16 } ,
|
||||
{ /* 16 */ 2 , tab16 } ,
|
||||
{ /* 16 */ 3 , tab16 } ,
|
||||
{ /* 16 */ 4 , tab16 } ,
|
||||
{ /* 16 */ 6 , tab16 } ,
|
||||
{ /* 16 */ 8 , tab16 } ,
|
||||
{ /* 16 */ 10, tab16 } ,
|
||||
{ /* 16 */ 13, tab16 } ,
|
||||
{ /* 16 */ 4 , tab24 } ,
|
||||
{ /* 16 */ 5 , tab24 } ,
|
||||
{ /* 16 */ 6 , tab24 } ,
|
||||
{ /* 16 */ 7 , tab24 } ,
|
||||
{ /* 16 */ 8 , tab24 } ,
|
||||
{ /* 16 */ 9 , tab24 } ,
|
||||
{ /* 16 */ 11, tab24 } ,
|
||||
{ /* 16 */ 13, tab24 }
|
||||
{ /* 16 */ 1, tab16},
|
||||
{ /* 16 */ 2, tab16},
|
||||
{ /* 16 */ 3, tab16},
|
||||
{ /* 16 */ 4, tab16},
|
||||
{ /* 16 */ 6, tab16},
|
||||
{ /* 16 */ 8, tab16},
|
||||
{ /* 16 */ 10, tab16},
|
||||
{ /* 16 */ 13, tab16},
|
||||
{ /* 16 */ 4, tab24},
|
||||
{ /* 16 */ 5, tab24},
|
||||
{ /* 16 */ 6, tab24},
|
||||
{ /* 16 */ 7, tab24},
|
||||
{ /* 16 */ 8, tab24},
|
||||
{ /* 16 */ 9, tab24},
|
||||
{ /* 16 */ 11, tab24},
|
||||
{ /* 16 */ 13, tab24}
|
||||
};
|
||||
|
||||
static struct newhuff htc[] =
|
||||
{
|
||||
{ /* 1 , 1 , */ 0 , tab_c0 } ,
|
||||
{ /* 1 , 1 , */ 0 , tab_c1 }
|
||||
static struct newhuff htc[] = {
|
||||
{ /* 1 , 1 , */ 0, tab_c0},
|
||||
{ /* 1 , 1 , */ 0, tab_c1}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -9,21 +9,21 @@ void InitMP3Constants(void)
|
||||
{
|
||||
init_layer3_const();
|
||||
make_decode_tables_const();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
BOOL InitMP3(struct mpstr *mp, long outscale, int samplerate)
|
||||
BOOL InitMP3(struct mpstr *mp, long outscale, int samplerate)
|
||||
{
|
||||
/* quiet 4096 med 8192 */
|
||||
|
||||
memset(mp,0,sizeof(struct mpstr));
|
||||
memset(mp, 0, sizeof(struct mpstr));
|
||||
|
||||
mp->framesize = 0;
|
||||
mp->fsizeold = -1;
|
||||
mp->bsize = 0;
|
||||
mp->head = mp->tail = NULL;
|
||||
mp->fr.single = 3; /* force mono */
|
||||
mp->fr.single = 3; /* force mono */
|
||||
mp->bsnum = 0;
|
||||
mp->synth_bo = 1;
|
||||
mp->outsamplerate = samplerate;
|
||||
@@ -37,10 +37,10 @@ BOOL InitMP3(struct mpstr *mp, long outscale, int samplerate)
|
||||
|
||||
void ExitMP3(struct mpstr *mp)
|
||||
{
|
||||
struct buf *b,*bn;
|
||||
|
||||
struct buf *b, *bn;
|
||||
|
||||
b = mp->tail;
|
||||
while(b) {
|
||||
while (b) {
|
||||
free(b->pnt);
|
||||
bn = b->next;
|
||||
free(b);
|
||||
@@ -48,31 +48,30 @@ void ExitMP3(struct mpstr *mp)
|
||||
}
|
||||
}
|
||||
|
||||
static struct buf *addbuf(struct mpstr *mp,char *buf,int size)
|
||||
static struct buf *addbuf(struct mpstr *mp, char *buf, int size)
|
||||
{
|
||||
struct buf *nbuf;
|
||||
|
||||
nbuf = malloc( sizeof(struct buf) );
|
||||
if(!nbuf) {
|
||||
debug_printf("%d Out of memory!\n", __LINE__);
|
||||
nbuf = malloc(sizeof(struct buf));
|
||||
if (!nbuf) {
|
||||
debug_printf("%d Out of memory!\n", __LINE__);
|
||||
return NULL;
|
||||
}
|
||||
nbuf->pnt = malloc(size);
|
||||
if(!nbuf->pnt) {
|
||||
if (!nbuf->pnt) {
|
||||
free(nbuf);
|
||||
return NULL;
|
||||
}
|
||||
nbuf->size = size;
|
||||
memcpy(nbuf->pnt,buf,size);
|
||||
memcpy(nbuf->pnt, buf, size);
|
||||
nbuf->next = NULL;
|
||||
nbuf->prev = mp->head;
|
||||
nbuf->pos = 0;
|
||||
|
||||
if(!mp->tail) {
|
||||
if (!mp->tail) {
|
||||
mp->tail = nbuf;
|
||||
}
|
||||
else {
|
||||
mp->head->next = nbuf;
|
||||
} else {
|
||||
mp->head->next = nbuf;
|
||||
}
|
||||
|
||||
mp->head = nbuf;
|
||||
@@ -83,50 +82,51 @@ static struct buf *addbuf(struct mpstr *mp,char *buf,int size)
|
||||
|
||||
static void remove_buf(struct mpstr *mp)
|
||||
{
|
||||
struct buf *buf = mp->tail;
|
||||
|
||||
mp->tail = buf->next;
|
||||
if(mp->tail)
|
||||
mp->tail->prev = NULL;
|
||||
else {
|
||||
mp->tail = mp->head = NULL;
|
||||
}
|
||||
|
||||
free(buf->pnt);
|
||||
free(buf);
|
||||
struct buf *buf = mp->tail;
|
||||
|
||||
mp->tail = buf->next;
|
||||
if (mp->tail)
|
||||
mp->tail->prev = NULL;
|
||||
else {
|
||||
mp->tail = mp->head = NULL;
|
||||
}
|
||||
|
||||
free(buf->pnt);
|
||||
free(buf);
|
||||
|
||||
}
|
||||
|
||||
static int read_buf_byte(int *error, struct mpstr *mp)
|
||||
{
|
||||
unsigned int b;int pos;
|
||||
unsigned int b;
|
||||
int pos;
|
||||
|
||||
pos = mp->tail->pos;
|
||||
while(pos >= mp->tail->size) {
|
||||
while (pos >= mp->tail->size) {
|
||||
remove_buf(mp);
|
||||
pos = mp->tail->pos;
|
||||
if(!mp->tail) {
|
||||
/* We may pick up this error a few times*/
|
||||
if (!mp->tail) {
|
||||
/* We may pick up this error a few times */
|
||||
/* But things have gone pear shaped */
|
||||
debug_printf("%d Fatal Buffer error!\n", __LINE__);
|
||||
debug_printf("%d Fatal Buffer error!\n", __LINE__);
|
||||
*error = 1;
|
||||
return (0);
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
b = mp->tail->pnt[pos];
|
||||
mp->bsize--;
|
||||
mp->tail->pos++;
|
||||
|
||||
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
static int read_head(struct mpstr *mp)
|
||||
static int read_head(struct mpstr *mp)
|
||||
{
|
||||
unsigned long head;
|
||||
int error=0;
|
||||
|
||||
int error = 0;
|
||||
|
||||
|
||||
head = read_buf_byte(&error, mp);
|
||||
head <<= 8;
|
||||
@@ -138,130 +138,127 @@ static int read_head(struct mpstr *mp)
|
||||
|
||||
mp->header = head;
|
||||
|
||||
if(error){
|
||||
if (error) {
|
||||
return (1);
|
||||
}else
|
||||
} else
|
||||
return (0);
|
||||
|
||||
|
||||
}
|
||||
|
||||
static int head_check(unsigned long head)
|
||||
{
|
||||
if( (head & 0xffe00000) != 0xffe00000)
|
||||
return FALSE;
|
||||
if(!((head>>17)&3))
|
||||
return FALSE;
|
||||
if( ((head>>12)&0xf) == 0xf || ((head>>12)&0xf) == 0)
|
||||
return FALSE;
|
||||
if( ((head>>10)&0x3) == 0x3 )
|
||||
return FALSE;
|
||||
if ((head & 0xffff0000) == 0xfffe0000)
|
||||
return FALSE;
|
||||
if ((head & 0xffe00000) != 0xffe00000)
|
||||
return FALSE;
|
||||
if (!((head >> 17) & 3))
|
||||
return FALSE;
|
||||
if (((head >> 12) & 0xf) == 0xf || ((head >> 12) & 0xf) == 0)
|
||||
return FALSE;
|
||||
if (((head >> 10) & 0x3) == 0x3)
|
||||
return FALSE;
|
||||
if ((head & 0xffff0000) == 0xfffe0000)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int head_shift(struct mpstr *mp)
|
||||
{
|
||||
unsigned long head;
|
||||
int error = 0;
|
||||
|
||||
|
||||
head = mp->header;
|
||||
|
||||
|
||||
head <<= 8;
|
||||
head |= read_buf_byte(&error, mp);
|
||||
|
||||
|
||||
mp->header = head;
|
||||
|
||||
if (error){
|
||||
if (error) {
|
||||
return (1);
|
||||
}else
|
||||
} else
|
||||
return (0);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int decodeMP3(struct mpstr *mp,char *in,int isize,char *out,
|
||||
int osize,int *done)
|
||||
int decodeMP3(struct mpstr *mp, char *in, int isize, char *out, int osize, int *done)
|
||||
{
|
||||
int len;
|
||||
long n,m;
|
||||
long n, m;
|
||||
int down_sample_sblimit;
|
||||
|
||||
if(osize < 4608) {
|
||||
debug_printf("%d To less out space\n", __LINE__);
|
||||
if (osize < 4608) {
|
||||
debug_printf("%d To less out space\n", __LINE__);
|
||||
return MP3_TOOSMALL;
|
||||
}
|
||||
|
||||
if(in) {
|
||||
if(addbuf(mp,in,isize) == NULL) {
|
||||
if (in) {
|
||||
if (addbuf(mp, in, isize) == NULL) {
|
||||
return MP3_ERR;
|
||||
}
|
||||
}
|
||||
|
||||
/* First decode header */
|
||||
if(mp->framesize == 0) {
|
||||
if(mp->bsize < 4) {
|
||||
if (mp->framesize == 0) {
|
||||
if (mp->bsize < 4) {
|
||||
return MP3_NEED_MORE;
|
||||
}
|
||||
if (read_head(mp))
|
||||
return MP3_ERR;
|
||||
|
||||
if(!head_check(mp->header) ) {
|
||||
|
||||
if (!head_check(mp->header)) {
|
||||
int i;
|
||||
|
||||
debug_printf("Junk at the beginning of frame %08lx\n",mp->header);
|
||||
|
||||
debug_printf("Junk at the beginning of frame %08lx\n", mp->header);
|
||||
|
||||
/* step in byte steps through next 64K */
|
||||
for(i=0;i<65536;i++) {
|
||||
if(!mp->bsize)
|
||||
for (i = 0; i < 65536; i++) {
|
||||
if (!mp->bsize)
|
||||
return MP3_NEED_MORE;
|
||||
|
||||
if(head_shift(mp))
|
||||
|
||||
if (head_shift(mp))
|
||||
return MP3_ERR;
|
||||
|
||||
if(head_check(mp->header))
|
||||
|
||||
if (head_check(mp->header))
|
||||
break;
|
||||
}
|
||||
if(i == 65536) {
|
||||
debug_printf("%d Giving up searching valid MPEG header\n", __LINE__);
|
||||
if (i == 65536) {
|
||||
debug_printf("%d Giving up searching valid MPEG header\n", __LINE__);
|
||||
return MP3_ERR;
|
||||
}
|
||||
}
|
||||
|
||||
decode_header(&mp->fr,mp->header);
|
||||
decode_header(&mp->fr, mp->header);
|
||||
mp->framesize = mp->fr.framesize;
|
||||
|
||||
if (!mp->initmp3){
|
||||
if (!mp->initmp3) {
|
||||
mp->initmp3 = 1;
|
||||
|
||||
|
||||
n = freqs[mp->fr.sampling_frequency];
|
||||
if (mp->outsamplerate) {
|
||||
m = mp->outsamplerate;
|
||||
} else {
|
||||
m = n;
|
||||
}
|
||||
else {
|
||||
m =n;
|
||||
}
|
||||
|
||||
if (synth_ntom_set_step(n,m))
|
||||
|
||||
if (synth_ntom_set_step(n, m))
|
||||
return MP3_ERR;
|
||||
|
||||
|
||||
if(n>m) {
|
||||
|
||||
|
||||
if (n > m) {
|
||||
down_sample_sblimit = SBLIMIT * m;
|
||||
down_sample_sblimit /= n;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
down_sample_sblimit = SBLIMIT;
|
||||
}
|
||||
|
||||
|
||||
init_layer3_sample_limits(mp, down_sample_sblimit);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(mp->fr.framesize > mp->bsize)
|
||||
|
||||
if (mp->fr.framesize > mp->bsize)
|
||||
return MP3_NEED_MORE;
|
||||
|
||||
(mp->worksample).wordpointer = mp->bsspace[mp->bsnum] + 512;
|
||||
@@ -269,29 +266,28 @@ int decodeMP3(struct mpstr *mp,char *in,int isize,char *out,
|
||||
(mp->worksample).bitindex = 0;
|
||||
|
||||
len = 0;
|
||||
while(len < mp->framesize) {
|
||||
while (len < mp->framesize) {
|
||||
int nlen;
|
||||
int blen = mp->tail->size - mp->tail->pos;
|
||||
if( (mp->framesize - len) <= blen) {
|
||||
nlen = mp->framesize-len;
|
||||
if ((mp->framesize - len) <= blen) {
|
||||
nlen = mp->framesize - len;
|
||||
} else {
|
||||
nlen = blen;
|
||||
}
|
||||
else {
|
||||
nlen = blen;
|
||||
}
|
||||
memcpy((mp->worksample).wordpointer+len,mp->tail->pnt+mp->tail->pos,nlen);
|
||||
len += nlen;
|
||||
mp->tail->pos += nlen;
|
||||
memcpy((mp->worksample).wordpointer + len, mp->tail->pnt + mp->tail->pos, nlen);
|
||||
len += nlen;
|
||||
mp->tail->pos += nlen;
|
||||
mp->bsize -= nlen;
|
||||
if(mp->tail->pos == mp->tail->size) {
|
||||
remove_buf(mp);
|
||||
}
|
||||
if (mp->tail->pos == mp->tail->size) {
|
||||
remove_buf(mp);
|
||||
}
|
||||
}
|
||||
|
||||
*done = 0;
|
||||
if(mp->fr.error_protection)
|
||||
getbits(mp, 16);
|
||||
|
||||
if (do_layer3(mp,(unsigned char *) out,done))
|
||||
if (mp->fr.error_protection)
|
||||
getbits(mp, 16);
|
||||
|
||||
if (do_layer3(mp, (unsigned char *) out, done))
|
||||
return MP3_ERR;
|
||||
|
||||
mp->fsizeold = mp->framesize;
|
||||
@@ -302,19 +298,15 @@ int decodeMP3(struct mpstr *mp,char *in,int isize,char *out,
|
||||
|
||||
int set_pointer(struct mpstr *mp, long backstep)
|
||||
{
|
||||
unsigned char *bsbufold;
|
||||
if(mp->fsizeold < 0 && backstep > 0) {
|
||||
debug_printf("Can't step back %ld!\n",backstep);
|
||||
return MP3_ERR;
|
||||
}
|
||||
bsbufold = mp->bsspace[mp->bsnum] + 512;
|
||||
(mp->worksample).wordpointer -= backstep;
|
||||
if (backstep)
|
||||
memcpy((mp->worksample).wordpointer,bsbufold+mp->fsizeold-backstep,backstep);
|
||||
(mp->worksample).bitindex = 0;
|
||||
return MP3_OK;
|
||||
unsigned char *bsbufold;
|
||||
if (mp->fsizeold < 0 && backstep > 0) {
|
||||
debug_printf("Can't step back %ld!\n", backstep);
|
||||
return MP3_ERR;
|
||||
}
|
||||
bsbufold = mp->bsspace[mp->bsnum] + 512;
|
||||
(mp->worksample).wordpointer -= backstep;
|
||||
if (backstep)
|
||||
memcpy((mp->worksample).wordpointer, bsbufold + mp->fsizeold - backstep, backstep);
|
||||
(mp->worksample).bitindex = 0;
|
||||
return MP3_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+1602
-1653
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -58,69 +58,67 @@
|
||||
#define AUSHIFT (3)
|
||||
|
||||
struct frame {
|
||||
int stereo;
|
||||
int jsbound;
|
||||
int single;
|
||||
int lsf;
|
||||
int mpeg25;
|
||||
int header_change;
|
||||
int lay;
|
||||
int error_protection;
|
||||
int bitrate_index;
|
||||
int sampling_frequency;
|
||||
int padding;
|
||||
int extension;
|
||||
int mode;
|
||||
int mode_ext;
|
||||
int copyright;
|
||||
int original;
|
||||
int emphasis;
|
||||
int framesize; /* computed framesize */
|
||||
int stereo;
|
||||
int jsbound;
|
||||
int single;
|
||||
int lsf;
|
||||
int mpeg25;
|
||||
int header_change;
|
||||
int lay;
|
||||
int error_protection;
|
||||
int bitrate_index;
|
||||
int sampling_frequency;
|
||||
int padding;
|
||||
int extension;
|
||||
int mode;
|
||||
int mode_ext;
|
||||
int copyright;
|
||||
int original;
|
||||
int emphasis;
|
||||
int framesize; /* computed framesize */
|
||||
};
|
||||
|
||||
struct parameter {
|
||||
int quiet; /* shut up! */
|
||||
int tryresync; /* resync stream after error */
|
||||
int verbose; /* verbose level */
|
||||
int quiet; /* shut up! */
|
||||
int tryresync; /* resync stream after error */
|
||||
int verbose; /* verbose level */
|
||||
int checkrange;
|
||||
};
|
||||
|
||||
extern int decode_header(struct frame *fr,unsigned long newhead);
|
||||
extern int decode_header(struct frame *fr, unsigned long newhead);
|
||||
|
||||
|
||||
|
||||
struct gr_info_s {
|
||||
int scfsi;
|
||||
unsigned part2_3_length;
|
||||
unsigned big_values;
|
||||
unsigned scalefac_compress;
|
||||
unsigned block_type;
|
||||
unsigned mixed_block_flag;
|
||||
unsigned table_select[3];
|
||||
unsigned subblock_gain[3];
|
||||
unsigned maxband[3];
|
||||
unsigned maxbandl;
|
||||
unsigned maxb;
|
||||
unsigned region1start;
|
||||
unsigned region2start;
|
||||
unsigned preflag;
|
||||
unsigned scalefac_scale;
|
||||
unsigned count1table_select;
|
||||
real *full_gain[3];
|
||||
real *pow2gain;
|
||||
int scfsi;
|
||||
unsigned part2_3_length;
|
||||
unsigned big_values;
|
||||
unsigned scalefac_compress;
|
||||
unsigned block_type;
|
||||
unsigned mixed_block_flag;
|
||||
unsigned table_select[3];
|
||||
unsigned subblock_gain[3];
|
||||
unsigned maxband[3];
|
||||
unsigned maxbandl;
|
||||
unsigned maxb;
|
||||
unsigned region1start;
|
||||
unsigned region2start;
|
||||
unsigned preflag;
|
||||
unsigned scalefac_scale;
|
||||
unsigned count1table_select;
|
||||
real *full_gain[3];
|
||||
real *pow2gain;
|
||||
};
|
||||
|
||||
struct III_sideinfo
|
||||
{
|
||||
unsigned main_data_begin;
|
||||
unsigned private_bits;
|
||||
struct {
|
||||
struct gr_info_s gr[2];
|
||||
} ch[2];
|
||||
struct III_sideinfo {
|
||||
unsigned main_data_begin;
|
||||
unsigned private_bits;
|
||||
struct {
|
||||
struct gr_info_s gr[2];
|
||||
} ch[2];
|
||||
};
|
||||
|
||||
struct pcm_workingsample
|
||||
{
|
||||
struct pcm_workingsample {
|
||||
int bitindex;
|
||||
unsigned char *wordpointer;
|
||||
};
|
||||
@@ -129,4 +127,3 @@ struct pcm_workingsample
|
||||
extern long freqs[9];
|
||||
extern struct parameter param;
|
||||
extern real *pnts[5];
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
#endif
|
||||
|
||||
struct buf {
|
||||
unsigned char *pnt;
|
||||
unsigned char *pnt;
|
||||
long size;
|
||||
long pos;
|
||||
struct buf *next;
|
||||
struct buf *prev;
|
||||
struct buf *next;
|
||||
struct buf *prev;
|
||||
};
|
||||
|
||||
struct framebuf {
|
||||
@@ -20,27 +20,27 @@ struct framebuf {
|
||||
};
|
||||
|
||||
struct mpstr {
|
||||
struct buf *head,*tail;
|
||||
struct buf *head, *tail;
|
||||
int bsize;
|
||||
int framesize;
|
||||
int fsizeold;
|
||||
int fsizeold;
|
||||
struct frame fr;
|
||||
unsigned char bsspace[2][MAXFRAMESIZE+512]; /* MAXFRAMESIZE */
|
||||
real hybrid_block[2][2][SBLIMIT*SSLIMIT];
|
||||
unsigned char bsspace[2][MAXFRAMESIZE + 512]; /* MAXFRAMESIZE */
|
||||
real hybrid_block[2][2][SBLIMIT * SSLIMIT];
|
||||
int hybrid_blc[2];
|
||||
unsigned long header;
|
||||
int bsnum;
|
||||
real synth_buffs[2][2][0x110];
|
||||
int synth_bo;
|
||||
long outscale; /* volume control default value 32768 */
|
||||
long outsamplerate; /* raw output rate default same as mp3 sample rate*/
|
||||
struct pcm_workingsample worksample; /* keep the state of the working sample for threads */
|
||||
int initmp3; /* flag for first initialisation */
|
||||
int longLimit[9][23]; /*sample limits re setting volume */
|
||||
int synth_bo;
|
||||
long outscale; /* volume control default value 32768 */
|
||||
long outsamplerate; /* raw output rate default same as mp3 sample rate */
|
||||
struct pcm_workingsample worksample; /* keep the state of the working sample for threads */
|
||||
int initmp3; /* flag for first initialisation */
|
||||
int longLimit[9][23]; /*sample limits re setting volume */
|
||||
int shortLimit[9][14];
|
||||
real decwin[512+32]; /* scale table */
|
||||
|
||||
};
|
||||
real decwin[512 + 32]; /* scale table */
|
||||
|
||||
};
|
||||
|
||||
#define BOOL int
|
||||
|
||||
@@ -51,30 +51,28 @@ struct mpstr {
|
||||
|
||||
void InitMP3Constants(void);
|
||||
BOOL InitMP3(struct mpstr *mp, long outscale, int samplerate);
|
||||
int decodeMP3(struct mpstr *mp,char *inmemory,int inmemsize,
|
||||
char *outmemory,int outmemsize,int *done);
|
||||
int decodeMP3(struct mpstr *mp, char *inmemory, int inmemsize, char *outmemory, int outmemsize, int *done);
|
||||
void ExitMP3(struct mpstr *mp);
|
||||
|
||||
extern int synth_ntom_set_step(long,long);
|
||||
extern int synth_ntom(struct mpstr *mp, real *bandPtr,int channel,unsigned char *out,int *pnt);
|
||||
extern int synth_ntom_mono (struct mpstr *mp, real *bandPtr,unsigned char *samples,int *pnt);
|
||||
extern int synth_ntom_8bit (real *,int,unsigned char *,int *);
|
||||
extern int synth_ntom_mono2stereo (real *,unsigned char *,int *);
|
||||
extern int synth_ntom_8bit_mono (real *,unsigned char *,int *);
|
||||
extern int synth_ntom_8bit_mono2stereo (real *,unsigned char *,int *);
|
||||
extern int synth_ntom_set_step(long, long);
|
||||
extern int synth_ntom(struct mpstr *mp, real * bandPtr, int channel, unsigned char *out, int *pnt);
|
||||
extern int synth_ntom_mono(struct mpstr *mp, real * bandPtr, unsigned char *samples, int *pnt);
|
||||
extern int synth_ntom_8bit(real *, int, unsigned char *, int *);
|
||||
extern int synth_ntom_mono2stereo(real *, unsigned char *, int *);
|
||||
extern int synth_ntom_8bit_mono(real *, unsigned char *, int *);
|
||||
extern int synth_ntom_8bit_mono2stereo(real *, unsigned char *, int *);
|
||||
|
||||
extern void init_layer3_sample_limits(struct mpstr *mp, int down_sample_sblimit);
|
||||
extern void init_layer3_const(void);
|
||||
extern int do_layer3(struct mpstr *mp,unsigned char *,int *);
|
||||
extern int do_layer3(struct mpstr *mp, unsigned char *, int *);
|
||||
|
||||
extern void make_decode_tables_scale(struct mpstr *mp, long scaleval);
|
||||
extern void make_decode_tables_const(void);
|
||||
extern void make_conv16to8_table(int);
|
||||
|
||||
extern void dct64(real *,real *,real *);
|
||||
extern void dct64(real *, real *, real *);
|
||||
|
||||
extern unsigned int get1bit(struct mpstr *mp);
|
||||
extern unsigned int getbits(struct mpstr *mp, int);
|
||||
extern unsigned int getbits_fast(struct mpstr *mp, int);
|
||||
extern unsigned int get1bit(struct mpstr *mp);
|
||||
extern unsigned int getbits(struct mpstr *mp, int);
|
||||
extern unsigned int getbits_fast(struct mpstr *mp, int);
|
||||
extern int set_pointer(struct mpstr *mp, long backstep);
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user