-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2015, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Mathieu Rene <mrene@avgs.ca>
*
* fs_encode.c -- Encode a native file
switch_safe_free(SWITCH_GLOBAL_dirs.log_dir);
}
-int main(int argc, char *argv[])
+int main(int argc, char *argv[])
{
int r = 1;
switch_bool_t verbose = SWITCH_FALSE;
i++;
/* Load extra modules */
if (strchr(argv[i], ',')) {
- extra_modules_count = switch_split(argv[i], ',', extra_modules);
+ extra_modules_count = switch_split(argv[i], ',', extra_modules);
} else {
extra_modules_count = 1;
extra_modules[0] = argv[i];
break;
}
}
-
+
if (argc - i < 2 || cmd_fail) {
goto usage;
}
-
+
input = argv[i++];
output = argv[i++];
if (zstr(input) || zstr(output) || !(format = strchr(output, '.'))) {
goto usage;
}
-
+
format++;
-
+
if (switch_core_init(SCF_MINIMAL, verbose, &err) != SWITCH_STATUS_SUCCESS) {
fprintf(stderr, "Cannot init core [%s]\n", err);
goto end;
}
-
+
switch_loadable_module_init(SWITCH_FALSE);
switch_loadable_module_load_module("", "CORE_PCM_MODULE", SWITCH_TRUE, &err);
switch_loadable_module_load_module("", "CORE_SPEEX_MODULE", SWITCH_TRUE, &err);
goto end;
}
}
-
+
if (switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) "mod_spandsp", SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) {
fprintf(stderr, "Cannot init mod_spandsp [%s]\n", err);
goto end;
}
-
+
if (switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) "mod_sndfile", SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) {
fprintf(stderr, "Cannot init mod_sndfile [%s]\n", err);
goto end;
}
-
+
if (switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) "mod_native_file", SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) {
fprintf(stderr, "Cannot init mod_native_file [%s]\n", err);
goto end;
fprintf(stderr, "Couldn't open %s\n", input);
goto end;
}
-
+
if (verbose) {
fprintf(stderr, "Opening file %s\n", output);
fprintf(stderr, "Couldn't initialize codec for %s@%dh@%di\n", p, rate, ptime);
goto end;
}
-
+
if (switch_core_codec_init_with_bitrate(&raw_codec, "L16", NULL, fmtp, rate, ptime, channels, bitrate, SWITCH_CODEC_FLAG_ENCODE|SWITCH_CODEC_FLAG_DECODE, NULL, pool) != SWITCH_STATUS_SUCCESS) {
fprintf(stderr, "Couldn't initialize codec for %s@%dh@%di\n", "L16", rate, ptime);
goto end;
if (switch_core_file_open(&fh_output, output, channels, codec.implementation->actual_samples_per_second, out_flags, NULL) != SWITCH_STATUS_SUCCESS) {
fprintf(stderr, "Couldn't open %s\n", output);
- goto end;
+ goto end;
}
-
+
if (switch_test_flag(&fh_input, SWITCH_FILE_NATIVE)) {
in_asis = 1;
}
switch_assert(sizeof(buf) >= len * 2);
if (verbose) {
- fprintf(stderr, "Frame size is %d\n", blocksize);
+ fprintf(stderr, "Frame size is %d\n", blocksize);
}
-
+
while (switch_core_file_read(&fh_input, buf, &len) == SWITCH_STATUS_SUCCESS) {
char encode_buf[2048];
uint32_t encoded_len = sizeof(buf);
fprintf(stderr, "Codec encoder error\n");
goto end;
}
-
+
len = encoded_len;
} else {
if (!in_asis) {
encoded_len = len;
} else if (in_asis) {
-
+
switch_core_codec_decode(&codec,
&raw_codec,
buf,
fprintf(stderr, "Write error\n");
goto end;
}
-
+
if (len != encoded_len) {
printf("Short write: wrote %"SWITCH_SIZE_T_FMT"/%d bytes\n", len, encoded_len);
}
-
+
len = blocksize;
}
-
+
r = 0;
end:
if (fh_input.file_interface) {
- switch_core_file_close(&fh_input);
+ switch_core_file_close(&fh_input);
}
if (fh_output.file_interface) {
- switch_core_file_close(&fh_output);
+ switch_core_file_close(&fh_output);
}
if (pool) {
switch_core_destroy_memory_pool(&pool);
}
-
+
fs_encode_cleanup();
//switch_core_destroy();
the first 1" instruction. A little in-line assembler fixes that, and the
conversion routines can be faster than lookup tables, in most real world usage.
A "find the first 1" instruction is available on most modern CPUs, and is a
-much underused feature.
+much underused feature.
If an assembly language method of bit searching is not available, these routines
revert to a method that can be a little slow, so the cache thrashing might not
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
switch_image_t *spy_img[2];
switch_vid_spy_fmt_t spy_fmt;
switch_thread_t *video_bug_thread;
-
+
switch_buffer_t *text_buffer;
char *text_framedata;
uint32_t text_framesize;
-
+
struct switch_media_bug *next;
};
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* switch_hashtable_private.h -- Hashtable
/*
* Copyright (c) 2002, Christopher Clark
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
- *
+ *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
* switch.h -- Main Library Header
* - OpenBSD 5.x
*
* \section depends Dependencies
- * Freeswitch makes heavy use of external libraries.
+ * Freeswitch makes heavy use of external libraries.
*
* libFreeSWITCH:
* - APR (http://apr.apache.org)
*
* mod_b64
* - Base64 codec tranfers data base64 encoded (http://www.b64codec.org)
- *
+ *
* mod_bv
* - BroadVoice16 (8kHz) and BroadVoice32 (16kHz) (https://www.broadcom.com/support/broadvoice)
*
* Directories
* mod_ldap
* - openldap (*nix only http://www.openldap.org/)
- *
+ *
* Endpoints
* mod_portaudio
* - portaudio (http://www.portaudio.com/)
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Eliot Gable <egable@gmail.com>
*
*/
/*! \file switch_apr.h
\brief APR includes header
-
+
The things powered by APR are renamed into the switch_ namespace to provide a cleaner
look to things and helps me to document what parts of APR I am using I'd like to take this
opportunity to thank APR for all the awesome stuff it does and for making my life much easier.
SWITCH_DECLARE(switch_thread_id_t) switch_thread_self(void);
-/*! \brief Compare two thread ids
+/*! \brief Compare two thread ids
* \param tid1 1st Thread ID to compare
* \param tid2 2nd Thread ID to compare
*/
*/
/**
* @defgroup switch_memory_pool Memory Pool Functions
- * @ingroup switch_apr
+ * @ingroup switch_apr
* @{
*/
/** The fundamental pool type */
/**
* Continue iterating over the entries in a hash table.
* @param ht The iteration state
- * @return a pointer to the updated iteration state. NULL if there are no more
+ * @return a pointer to the updated iteration state. NULL if there are no more
* entries.
*/
SWITCH_DECLARE(switch_hash_index_t *) switch_core_hash_next(switch_hash_index_t *ht);
* The default hash function.
* @param key pointer to the key.
* @param klen the key length.
- *
+ *
*/
SWITCH_DECLARE(unsigned int) switch_hashfunc_default(const char *key, switch_ssize_t *klen);
/**
* @defgroup switch_time Time Routines
- * @ingroup switch_apr
+ * @ingroup switch_apr
* @{
*/
* format which requires the indicated amount of storage,
* including the trailing NUL terminator.
* @param date_str String to write to.
- * @param t the time to convert
+ * @param t the time to convert
*/
SWITCH_DECLARE(switch_status_t) switch_rfc822_date(char *date_str, switch_time_t t);
SWITCH_DECLARE(switch_status_t) switch_time_exp_gmt(switch_time_exp_t *result, switch_time_t input);
/**
- * Convert time value from human readable format to a numeric apr_time_t
+ * Convert time value from human readable format to a numeric apr_time_t
* e.g. elapsed usec since epoch
* @param result the resulting imploded time
* @param input the input exploded time
/**
* Sleep for the specified number of micro-seconds.
* @param t desired amount of time to sleep.
- * @warning May sleep for longer than the specified time.
+ * @warning May sleep for longer than the specified time.
*/
SWITCH_DECLARE(void) switch_sleep(switch_interval_time_t t);
SWITCH_DECLARE(void) switch_micro_sleep(switch_interval_time_t t);
/**
* @defgroup switch_thread_cond Condition Variable Routines
- * @ingroup switch_apr
+ * @ingroup switch_apr
* @{
*/
* @param mutex the mutex that must be locked upon entering this function,
* is released while the thread is asleep, and is again acquired before
* returning from this function.
- * @param timeout The amount of time in microseconds to wait. This is
- * a maximum, not a minimum. If the condition is signaled, we
+ * @param timeout The amount of time in microseconds to wait. This is
+ * a maximum, not a minimum. If the condition is signaled, we
* will wake up before this time, otherwise the error APR_TIMEUP
* is returned.
*/
/** Opaque structure used for queue API */
typedef struct apr_queue_t switch_queue_t;
-/**
+/**
* create a FIFO queue
* @param queue The new queue
* @param queue_capacity maximum size of the queue
/**
* @defgroup switch_file_io File I/O Handling Functions
- * @ingroup switch_apr
+ * @ingroup switch_apr
* @{
*/
/**
- * @defgroup switch_file_permissions File Permissions flags
+ * @defgroup switch_file_permissions File Permissions flags
* @ingroup switch_file_io
* @{
*/
* SWITCH_FOPEN_CREATE create the file if not there
* SWITCH_FOPEN_APPEND file ptr is set to end prior to all writes
* SWITCH_FOPEN_TRUNCATE set length to zero if file exists
- * SWITCH_FOPEN_BINARY not a text file (This flag is ignored on
+ * SWITCH_FOPEN_BINARY not a text file (This flag is ignored on
* UNIX because it has no meaning)
* SWITCH_FOPEN_BUFFERED buffer the data. Default is non-buffered
* SWITCH_FOPEN_EXCL return error if APR_CREATE and file exists
* SWITCH_FOPEN_SHARELOCK Platform dependent support for higher
* level locked read/write access to support
* writes across process/machines
- * SWITCH_FOPEN_NOCLEANUP Do not register a cleanup with the pool
+ * SWITCH_FOPEN_NOCLEANUP Do not register a cleanup with the pool
* passed in on the <EM>pool</EM> argument (see below).
* The apr_os_file_t handle in apr_file_t will not
* be closed when the pool is destroyed.
* Write data to the specified file.
* @param thefile The file descriptor to write to.
* @param buf The buffer which contains the data.
- * @param nbytes On entry, the number of bytes to write; on exit, the number
+ * @param nbytes On entry, the number of bytes to write; on exit, the number
* of bytes written.
*
* @remark apr_file_write will write up to the specified number of
/**
* @defgroup switch_thread_proc Threads and Process Functions
- * @ingroup switch_apr
+ * @ingroup switch_apr
* @{
*/
/**
* Set if newly created threads should be created in detached state.
- * @param attr The threadattr to affect
+ * @param attr The threadattr to affect
* @param on Non-zero if detached threads should be created.
*/
SWITCH_DECLARE(switch_status_t) switch_threadattr_detach_set(switch_threadattr_t *attr, int32_t on);
/**
* @defgroup switch_network_io Network Routines
- * @ingroup switch_apr
+ * @ingroup switch_apr
* @{
*/
/**
* Shutdown either reading, writing, or both sides of a socket.
- * @param sock The socket to close
+ * @param sock The socket to close
* @param how How to shutdown the socket. One of:
* <PRE>
* SWITCH_SHUTDOWN_READ no longer allow read requests
* SWITCH_SHUTDOWN_WRITE no longer allow write requests
- * SWITCH_SHUTDOWN_READWRITE no longer allow read or write requests
+ * SWITCH_SHUTDOWN_READWRITE no longer allow read or write requests
* </PRE>
* @see switch_shutdown_how_e
* @remark This does not actually close the socket descriptor, it just
/**
* Close a socket.
- * @param sock The socket to close
+ * @param sock The socket to close
*/
SWITCH_DECLARE(switch_status_t) switch_socket_close(switch_socket_t *sock);
/**
* Bind the socket to its associated port
- * @param sock The socket to bind
+ * @param sock The socket to bind
* @param sa The socket address to bind to
* @remark This may be where we will find out if there is any other process
* using the selected port.
/**
* Listen to a bound socket for connections.
- * @param sock The socket to listen on
+ * @param sock The socket to listen on
* @param backlog The number of outstanding connections allowed in the sockets
* listen queue. If this value is less than zero, the listen
- * queue size is set to zero.
+ * 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_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
+ * Issue a connection request to a socket either on the same machine
* or a different one.
- * @param sock The socket we wish to use for our side of the connection
+ * @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);
* @param sa The new apr_sockaddr_t.
* @param hostname The hostname or numeric address string to resolve/parse, or
* NULL to build an address that corresponds to 0.0.0.0 or ::
- * @param family The address family to use, or SWITCH_UNSPEC if the system should
+ * @param family The address family to use, or SWITCH_UNSPEC if the system should
* decide.
* @param port The port number.
* @param flags Special processing flags:
/**
* Send data over a network.
* @param sock The socket to send the data over.
- * @param buf The buffer which contains the data to be sent.
+ * @param buf The buffer which contains the data to be sent.
* @param len On entry, the number of bytes to send; on exit, the number
* of bytes sent.
* @remark
* <PRE>
- * This functions acts like a blocking write by default. To change
+ * This functions acts like a blocking write by default. To change
* this behavior, use apr_socket_timeout_set() or the APR_SO_NONBLOCK
* socket option.
*
*/
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_send_nonblock(switch_socket_t *sock, const char *buf, switch_size_t *len);
/**
/**
* Read data from a network.
* @param sock The socket to read the data from.
- * @param buf The buffer to store the data in.
+ * @param buf The buffer to store the data in.
* @param len On entry, the number of bytes to receive; on exit, the number
* of bytes received.
* @remark
* <PRE>
- * This functions acts like a blocking read by default. To change
+ * This functions acts like a blocking read by default. To change
* this behavior, use apr_socket_timeout_set() or the APR_SO_NONBLOCK
* socket option.
* The number of bytes actually received is stored in argument 3.
* @param sock The socket to set up.
* @param opt The option we would like to configure. One of:
* <PRE>
- * APR_SO_DEBUG -- turn on debugging information
+ * APR_SO_DEBUG -- turn on debugging information
* APR_SO_KEEPALIVE -- keep connections active
* APR_SO_LINGER -- lingers on close if data is present
* APR_SO_NONBLOCK -- Turns blocking on/off for socket
* Join a Multicast Group
* @param sock The socket to join a multicast group
* @param join The address of the multicast group to join
- * @param iface Address of the interface to use. If NULL is passed, the
+ * @param iface Address of the interface to use. If NULL is passed, the
* default multicast interface will be used. (OS Dependent)
- * @param source Source Address to accept transmissions from (non-NULL
+ * @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);
/**
* Setup a pollset object
- * @param pollset The pointer in which to return the newly created object
+ * @param pollset The pointer in which to return the newly created object
* @param size The maximum number of descriptors that this pollset can hold
* @param pool The pool from which to allocate the pollset
* @param flags Optional flags to modify the operation of the pollset.
/**
* Poll the sockets in the poll structure
- * @param aprset The poll structure we will be using.
+ * @param aprset The poll structure we will be using.
* @param numsock The number of sockets we are polling
* @param nsds The number of sockets signalled.
- * @param timeout The amount of time in microseconds to wait. This is
- * a maximum, not a minimum. If a socket is signalled, we
- * will wake up before this time. A negative number means
+ * @param timeout The amount of time in microseconds to wait. This is
+ * a maximum, not a minimum. If a socket is signalled, we
+ * will wake up before this time. A negative number means
* wait until a socket is signalled.
- * @remark The number of sockets signalled is returned in the third argument.
- * This is a blocking call, and it will not return until either a
- * socket has been signalled, or the timeout has expired.
+ * @remark The number of sockets signalled is returned in the third argument.
+ * 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_socket_create_pollset(switch_pollfd_t ** poll, switch_socket_t *sock, int16_t flags, switch_memory_pool_t *pool);
SWITCH_DECLARE(switch_interval_time_t) switch_interval_time_from_timeval(struct timeval *tvp);
-
+
/*!
\brief Create a pollfd out of a socket
/**
* Get the timeout value for a pipe or manipulate the blocking state.
* @param thepipe The pipe we are getting a timeout for.
- * @param timeout The current timeout value in microseconds.
+ * @param timeout The current timeout value in microseconds.
*/
SWITCH_DECLARE(switch_status_t) switch_file_pipe_timeout_get(switch_file_t *thepipe, switch_interval_time_t *timeout);
/**
* Set the timeout value for a pipe or manipulate the blocking state.
* @param thepipe The pipe we are setting a timeout on.
- * @param timeout The timeout value in microseconds. Values < 0 mean wait
+ * @param timeout The timeout value in microseconds. Values < 0 mean wait
* forever, 0 means do not wait at all.
*/
SWITCH_DECLARE(switch_status_t) switch_file_pipe_timeout_set(switch_file_t *thepipe, switch_interval_time_t timeout);
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
/*!
- \defgroup bp1 Bitpacking
+ \defgroup bp1 Bitpacking
\ingroup core1
- \{
+ \{
*/
static const uint8_t SWITCH_BITPACKED_MASKS[] = { 0, 1, 3, 7, 15, 31, 63, 127, 255 };
\param bitlen the number of bits per packet
\param buf the buffer to use for storage
\param buflen the length of the storage buffer
- \param mode RFC3551 or AAL2 mode (curse you backwards folks)
+ \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,
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
* switch_buffer.h -- Data Buffering Code
*
*/
-/**
+/**
* @file switch_buffer.h
* @brief Data Buffering Code
* @see switch_buffer
SWITCH_DECLARE(switch_status_t) switch_buffer_set_partition_data(switch_buffer_t *buffer, void *data, switch_size_t datalen);
SWITCH_DECLARE(switch_status_t) switch_buffer_reset_partition_data(switch_buffer_t *buffer);
-/*! \brief Allocate a new switch_buffer
+/*! \brief Allocate a new switch_buffer
* \param pool Pool to allocate the buffer from
* \param buffer returned pointer to the new buffer
* \param max_len length required by the buffer
*/
SWITCH_DECLARE(switch_status_t) switch_buffer_create(_In_ switch_memory_pool_t *pool, _Out_ switch_buffer_t **buffer, _In_ switch_size_t max_len);
-/*! \brief Allocate a new dynamic switch_buffer
+/*! \brief Allocate a new dynamic switch_buffer
* \param buffer returned pointer to the new buffer
* \param blocksize length to realloc by as data is added
* \param start_len ammount of memory to reserve initially
SWITCH_DECLARE(switch_status_t) switch_buffer_trylock(_In_ switch_buffer_t *buffer);
SWITCH_DECLARE(void) switch_buffer_unlock(_In_ switch_buffer_t *buffer);
-/*! \brief Get the length of a switch_buffer_t
+/*! \brief Get the length of a switch_buffer_t
* \param buffer any buffer of type switch_buffer_t
* \return int size of the buffer.
*/
SWITCH_DECLARE(switch_size_t) switch_buffer_len(_In_ switch_buffer_t *buffer);
-/*! \brief Get the freespace of a switch_buffer_t
+/*! \brief Get the freespace of a switch_buffer_t
* \param buffer any buffer of type switch_buffer_t
* \return int freespace in the buffer.
*/
SWITCH_DECLARE(switch_size_t) switch_buffer_freespace(_In_ switch_buffer_t *buffer);
-/*! \brief Get the in use amount of a switch_buffer_t
+/*! \brief Get the in use amount of a switch_buffer_t
* \param buffer any buffer of type switch_buffer_t
* \return int ammount of buffer curently in use
*/
SWITCH_DECLARE(switch_size_t) switch_buffer_inuse(_In_ switch_buffer_t *buffer);
-/*! \brief Read data from a switch_buffer_t up to the ammount of datalen if it is available. Remove read data from buffer.
+/*! \brief Read data from a switch_buffer_t up to the ammount of datalen if it is available. Remove read data from buffer.
* \param buffer any buffer of type switch_buffer_t
* \param data pointer to the read data to be returned
* \param datalen amount of data to be returned
*/
SWITCH_DECLARE(switch_size_t) switch_buffer_read(_In_ switch_buffer_t *buffer, _In_ void *data, _In_ switch_size_t datalen);
-/*! \brief Read data from a switch_buffer_t up to the ammount of datalen if it is available, without removing read data from buffer.
+/*! \brief Read data from a switch_buffer_t up to the ammount of datalen if it is available, without removing read data from buffer.
* \param buffer any buffer of type switch_buffer_t
* \param data pointer to the read data to be returned
* \param datalen amount of data to be returned
SWITCH_DECLARE(switch_size_t) switch_buffer_peek_zerocopy(_In_ switch_buffer_t *buffer, _Out_ const void **ptr);
-/*! \brief Read data endlessly from a switch_buffer_t
+/*! \brief Read data endlessly from a switch_buffer_t
* \param buffer any buffer of type switch_buffer_t
* \param data pointer to the read data to be returned
* \param datalen amount of data to be returned
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
*
* In addition, this module implements an abstract interface for extensions and applications.
* A connected session's channel has one extension object which may have one or more applications
- * linked into a stack which will be executed in order by the session's state machine when the
+ * linked into a stack which will be executed in order by the session's state machine when the
* current state is CS_EXECUTE.
* @{
*/
\param ani ANI information
\param aniii ANI II information
\param rdnis RDNIS
- \param source the source
+ \param source the source
\param context a logical context
\param destination_number destination number
\return a new profile object allocated from the session's memory pool
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
* switch_channel.h -- Media Channel Interface
*
*/
-/**
+/**
* @file switch_channel.h
* @brief Media Channel Interface
* @see switch_channel
#define switch_channel_set_variable_partner(_channel, _var, _val) switch_channel_set_variable_partner_var_check(_channel, _var, _val, SWITCH_TRUE)
-SWITCH_DECLARE(switch_status_t) switch_channel_export_variable_var_check(switch_channel_t *channel,
- const char *varname, const char *val,
+SWITCH_DECLARE(switch_status_t) switch_channel_export_variable_var_check(switch_channel_t *channel,
+ const char *varname, const char *val,
const char *export_varname,
switch_bool_t var_check);
-SWITCH_DECLARE(void) switch_channel_process_export(switch_channel_t *channel, switch_channel_t *peer_channel,
+SWITCH_DECLARE(void) switch_channel_process_export(switch_channel_t *channel, switch_channel_t *peer_channel,
switch_event_t *var_event, const char *export_varname);
#define switch_channel_export_variable(_channel, _varname, _value, _ev) switch_channel_export_variable_var_check(_channel, _varname, _value, _ev, SWITCH_TRUE)
-SWITCH_DECLARE(switch_status_t) switch_channel_export_variable_printf(switch_channel_t *channel, const char *varname,
+SWITCH_DECLARE(switch_status_t) switch_channel_export_variable_printf(switch_channel_t *channel, const char *varname,
const char *export_varname, const char *fmt, ...);
SWITCH_DECLARE(void) switch_channel_set_scope_variables(switch_channel_t *channel, switch_event_t **event);
SWITCH_DECLARE(switch_event_header_t *) switch_channel_variable_first(switch_channel_t *channel);
/*!
- * \brief Stop iterating over channel variables.
+ * \brief Stop iterating over channel variables.
* \remark Unlocks the profile mutex initially locked in switch_channel_variable_first
*/
SWITCH_DECLARE(void) switch_channel_variable_last(switch_channel_t *channel);
/*!
\brief Test for presence of given flag on a given channel
- \param channel channel to test
+ \param channel channel to test
\param flag to test
\return TRUE if flags were present
*/
*/
#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_value(switch_channel_t *channel,
+SWITCH_DECLARE(switch_status_t) switch_channel_perform_ring_ready_value(switch_channel_t *channel,
switch_ring_ready_t rv,
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);
-SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_ring_ready_value(switch_channel_t *channel,
+SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_ring_ready_value(switch_channel_t *channel,
switch_ring_ready_t rv,
const char *file, const char *func, int line);
\return number of digits in the queue
*/
SWITCH_DECLARE(switch_size_t) switch_channel_has_dtmf(_In_ switch_channel_t *channel);
-SWITCH_DECLARE(switch_status_t) switch_channel_dtmf_lock(switch_channel_t *channel);
+SWITCH_DECLARE(switch_status_t) switch_channel_dtmf_lock(switch_channel_t *channel);
SWITCH_DECLARE(switch_status_t) switch_channel_try_dtmf_lock(switch_channel_t *channel);
-SWITCH_DECLARE(switch_status_t) switch_channel_dtmf_unlock(switch_channel_t *channel);
+SWITCH_DECLARE(switch_status_t) switch_channel_dtmf_unlock(switch_channel_t *channel);
/*!
SWITCH_DECLARE(char *) switch_channel_get_cap_string(switch_channel_t *channel);
SWITCH_DECLARE(int) switch_channel_state_change_pending(switch_channel_t *channel);
-SWITCH_DECLARE(void) switch_channel_perform_set_callstate(switch_channel_t *channel, switch_channel_callstate_t callstate,
+SWITCH_DECLARE(void) switch_channel_perform_set_callstate(switch_channel_t *channel, switch_channel_callstate_t callstate,
const char *file, const char *func, int line);
#define switch_channel_set_callstate(channel, state) switch_channel_perform_set_callstate(channel, state, __FILE__, __SWITCH_FUNC__, __LINE__)
SWITCH_DECLARE(switch_channel_callstate_t) switch_channel_get_callstate(switch_channel_t *channel);
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
* switch_config.h -- Configuration File Parser
*
*/
-/**
+/**
* @file switch_config.h
* @brief Basic Configuration File Parser
* @see config
* or expanded to tie to external handlers in the future as necessary.
* <pre>
*
- * EXAMPLE
- *
+ * EXAMPLE
+ *
* [category1]
* var1 => val1
* var2 => val2
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Luke Dashjr <luke@openmethods.com> (OpenMethods, LLC)
* Joseph Sullivan <jossulli@amazon.com>
} switch_device_node_t;
typedef struct switch_device_stats_s {
- uint32_t total;
+ uint32_t total;
uint32_t total_in;
uint32_t total_out;
uint32_t offhook;
#define MAX_FPLEN 64
#define MAX_FPSTRLEN 192
-typedef struct dtls_fp_s {
+typedef struct dtls_fp_s {
uint32_t len;
uint8_t data[MAX_FPLEN+1];
char *type;
/*!
- \defgroup core1 Core Library
+ \defgroup core1 Core Library
\ingroup FREESWITCH
- \{
+ \{
*/
///\defgroup mb1 Media Bugs
#define switch_core_session_get_name(_s) switch_channel_get_name(switch_core_session_get_channel(_s))
SWITCH_DECLARE(switch_status_t) switch_core_media_bug_pop(switch_core_session_t *orig_session, const char *function, switch_media_bug_t **pop);
-
-SWITCH_DECLARE(switch_status_t) switch_core_media_bug_exec_all(switch_core_session_t *orig_session,
+
+SWITCH_DECLARE(switch_status_t) switch_core_media_bug_exec_all(switch_core_session_t *orig_session,
const char *function, switch_media_bug_exec_cb_t cb, void *user_data);
SWITCH_DECLARE(uint32_t) switch_core_media_bug_patch_video(switch_core_session_t *orig_session, switch_frame_t *frame);
SWITCH_DECLARE(uint32_t) switch_core_media_bug_count(switch_core_session_t *orig_session, const char *function);
SWITCH_DECLARE(switch_status_t) switch_core_media_bug_enumerate(switch_core_session_t *session, switch_stream_handle_t *stream);
SWITCH_DECLARE(switch_status_t) switch_core_media_bug_transfer_recordings(switch_core_session_t *orig_session, switch_core_session_t *new_session);
-SWITCH_DECLARE(switch_status_t) switch_core_media_bug_transfer_callback(switch_core_session_t *orig_session, switch_core_session_t *new_session,
+SWITCH_DECLARE(switch_status_t) switch_core_media_bug_transfer_callback(switch_core_session_t *orig_session, switch_core_session_t *new_session,
switch_media_bug_callback_t callback, void * (*user_data_dup_func) (switch_core_session_t *, void *));
\brief Read a frame from the bug
\param bug the bug to read from
\param frame the frame to write the data to
- \return the amount of data
+ \return the amount of data
*/
SWITCH_DECLARE(switch_status_t) switch_core_media_bug_read(_In_ switch_media_bug_t *bug, _In_ switch_frame_t *frame, switch_bool_t fill);
///\defgroup ss Startup/Shutdown
///\ingroup core1
///\{
-/*!
+/*!
\brief Initilize the core
\param console optional FILE stream for output
\param flags core flags
*/
SWITCH_DECLARE(switch_status_t) switch_core_init(_In_ switch_core_flag_t flags, _In_ switch_bool_t console, _Out_ const char **err);
-/*!
+/*!
\brief Initilize the core and load modules
\param console optional FILE stream for output
\param flags core flags
*/
SWITCH_DECLARE(switch_status_t) switch_core_init_and_modload(_In_ switch_core_flag_t flags, _In_ switch_bool_t console, _Out_ const char **err);
-/*!
+/*!
\brief Set/Get Session Limit
\param new_limit new value (if > 0)
\return the current session limit
*/
SWITCH_DECLARE(uint32_t) switch_core_session_limit(_In_ uint32_t new_limit);
-/*!
+/*!
\brief Set/Get Session Rate Limit
\param new_limit new value (if > 0)
\return the current session rate limit
*/
SWITCH_DECLARE(uint32_t) switch_core_sessions_per_second(_In_ uint32_t new_limit);
-/*!
+/*!
\brief Destroy the core
\note to be called at application shutdown
*/
SWITCH_DECLARE(switch_status_t) switch_core_session_perform_read_lock(_In_ switch_core_session_t *session, const char *file, const char *func, int line);
#endif
-/*!
+/*!
\brief Acquire a read lock on the session
\param session the session to acquire from
\return success if it is safe to read from the session
int line);
#endif
-/*!
+/*!
\brief Acquire a read lock on the session
\param session the session to acquire from
\return success if it is safe to read from the session
SWITCH_DECLARE(void) switch_core_session_perform_write_lock(_In_ switch_core_session_t *session, const char *file, const char *func, int line);
#endif
-/*!
+/*!
\brief Acquire a write lock on the session
\param session the session to acquire from
*/
SWITCH_DECLARE(void) switch_core_session_perform_rwunlock(_In_ switch_core_session_t *session, const char *file, const char *func, int line);
#endif
-/*!
+/*!
\brief Unlock a read or write lock on as given session
\param session the session
*/
///\defgroup sh State Handlers
///\ingroup core1
///\{
-/*!
+/*!
\brief Add a global state handler
\param state_handler a state handler to add
\return the current index/priority of this handler
*/
SWITCH_DECLARE(void) switch_core_remove_state_handler(_In_ const switch_state_handler_table_t *state_handler);
-/*!
+/*!
\brief Access a state handler
\param index the desired index to access
\return the desired state handler table or NULL when it does not exist.
///\defgroup memp Memory Pooling/Allocation
///\ingroup core1
///\{
-/*!
+/*!
\brief Create a new sub memory pool from the core's master pool
\return SWITCH_STATUS_SUCCESS on success
*/
SWITCH_DECLARE(int) switch_core_session_sync_clock(void);
SWITCH_DECLARE(switch_status_t) switch_core_perform_destroy_memory_pool(_Inout_ switch_memory_pool_t **pool,
_In_z_ const char *file, _In_z_ const char *func, _In_ int line);
-/*!
+/*!
\brief Returns a subpool back to the main pool
\return SWITCH_STATUS_SUCCESS on success
*/
SWITCH_DECLARE(void *) switch_core_memory_pool_get_data(switch_memory_pool_t *pool, const char *key);
-/*!
+/*!
\brief Start the session's state machine
\param session the session on which to start the state machine
*/
SWITCH_DECLARE(void) switch_core_session_run(_In_ switch_core_session_t *session);
-/*!
+/*!
\brief determine if the session's state machine is running
\param session the session on which to check
*/
SWITCH_DECLARE(void *) switch_core_perform_permanent_alloc(_In_ switch_size_t memory, _In_z_ const char *file, _In_z_ const char *func, _In_ int line);
-/*!
+/*!
\brief Allocate memory from the main pool with no intention of returning it
\param _memory the number of bytes to allocate
\return a void pointer to the allocated memory
SWITCH_DECLARE(void *) switch_core_perform_alloc(_In_ switch_memory_pool_t *pool, _In_ switch_size_t memory, _In_z_ const char *file,
_In_z_ const char *func, _In_ int line);
-/*!
+/*!
\brief Allocate memory directly from a memory pool
\param _pool the memory pool to allocate from
\param _mem the number of bytes to allocate
_Ret_ SWITCH_DECLARE(void *) switch_core_perform_session_alloc(_In_ switch_core_session_t *session, _In_ switch_size_t memory, const char *file,
const char *func, int line);
-/*!
+/*!
\brief Allocate memory from a session's pool
\param _session the session to request memory from
\param _memory the amount of memory to allocate
SWITCH_DECLARE(char *) switch_core_perform_permanent_strdup(_In_z_ const char *todup, _In_z_ const char *file, _In_z_ const char *func, _In_ int line);
-/*!
+/*!
\brief Copy a string using permanent memory allocation
\param _todup the string to duplicate
\return a pointer to the newly duplicated string
SWITCH_DECLARE(char *) switch_core_perform_session_strdup(_In_ switch_core_session_t *session, _In_z_ const char *todup, _In_z_ const char *file,
_In_z_ const char *func, _In_ int line);
-/*!
+/*!
\brief Copy a string using memory allocation from a session's pool
\param _session a session to use for allocation
\param _todup the string to duplicate
SWITCH_DECLARE(char *) switch_core_perform_strdup(_In_ switch_memory_pool_t *pool, _In_z_ const char *todup, _In_z_ const char *file,
_In_z_ const char *func, _In_ int line);
-/*!
+/*!
\brief Copy a string using memory allocation from a given pool
\param _pool the pool to use for allocation
\param _todup the string to duplicate
SWITCH_DECLARE(char *) switch_core_vsprintf(switch_memory_pool_t *pool, _In_z_ _Printf_format_string_ const char *fmt, va_list ap);
#endif
-/*!
+/*!
\brief Retrieve the memory pool from a session
\param session the session to retrieve the pool from
\return the session's pool
///\defgroup sessm Session Creation / Management
///\ingroup core1
///\{
-/*!
+/*!
\brief Allocate and return a new session from the core
\param endpoint_interface the endpoint interface the session is to be based on
\param pool the pool to use for the allocation (a new one will be used if NULL)
SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_uuid(_In_ switch_endpoint_interface_t *endpoint_interface,
_In_ switch_call_direction_t direction,
switch_originate_flag_t originate_flags,
- _Inout_opt_ switch_memory_pool_t **pool,
+ _Inout_opt_ switch_memory_pool_t **pool,
_In_opt_z_ const char *use_uuid);
#define switch_core_session_request(_ep, _d, _f, _p) switch_core_session_request_uuid(_ep, _d, _f, _p, NULL)
SWITCH_DECLARE(void) switch_core_session_perform_destroy(_Inout_ switch_core_session_t **session,
_In_z_ const char *file, _In_z_ const char *func, _In_ int line);
-/*!
+/*!
\brief Destroy a session and return the memory pool to the core
\param session pointer to a pointer of the session to destroy
\return
SWITCH_DECLARE(void) switch_core_session_reporting_state(switch_core_session_t *session);
SWITCH_DECLARE(void) switch_core_session_hangup_state(switch_core_session_t *session, switch_bool_t force);
-/*!
+/*!
\brief Provide the total number of sessions
\return the total number of allocated sessions
*/
SWITCH_DECLARE(switch_size_t) switch_core_session_get_id(_In_ switch_core_session_t *session);
-/*!
+/*!
\brief Provide the current session_id
\return the total number of allocated sessions since core startup
*/
SWITCH_DECLARE(switch_size_t) switch_core_session_id(void);
SWITCH_DECLARE(switch_size_t) switch_core_session_id_dec(void);
-/*!
+/*!
\brief Allocate and return a new session from the core based on a given endpoint module name
\param endpoint_name the name of the endpoint module
\param pool the pool to use
SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_by_name(_In_z_ const char *endpoint_name,
_In_ switch_call_direction_t direction, _Inout_ switch_memory_pool_t **pool);
-/*!
+/*!
\brief Launch the session thread (state machine) on a given session
\param session the session to activate the state machine on
\return SWITCH_STATUS_SUCCESS if the thread was launched
SWITCH_DECLARE(switch_status_t) switch_thread_pool_launch_thread(switch_thread_data_t **tdp);
SWITCH_DECLARE(switch_status_t) switch_core_session_thread_pool_launch(switch_core_session_t *session);
-/*!
+/*!
\brief Retrieve a pointer to the channel object associated with a given session
\param session the session to retrieve from
\return a pointer to the channel object
*/
_Ret_ SWITCH_DECLARE(switch_channel_t *) switch_core_session_get_channel(_In_ switch_core_session_t *session);
-/*!
+/*!
\brief Signal a session's state machine thread that a state change has occured
*/
SWITCH_DECLARE(switch_mutex_t *) switch_core_session_get_mutex(switch_core_session_t *session);
SWITCH_DECLARE(switch_status_t) switch_core_session_wake_session_thread(_In_ switch_core_session_t *session);
SWITCH_DECLARE(void) switch_core_session_signal_state_change(_In_ switch_core_session_t *session);
-/*!
+/*!
\brief Retrieve the unique identifier from a session
\param session the session to retrieve the uuid from
\return a string representing the uuid
SWITCH_DECLARE(char *) switch_core_session_get_uuid(_In_ switch_core_session_t *session);
-/*!
+/*!
\brief Sets the log level for a session
- \param session the session to set the log level on
+ \param session the session to set the log level on
\return SWITCH_STATUS_SUCCESS
*/
SWITCH_DECLARE(switch_status_t) switch_core_session_set_loglevel(switch_core_session_t *session, switch_log_level_t loglevel);
-/*!
+/*!
\brief Get the log level for a session
- \param session the session to get the log level from
+ \param session the session to get the log level from
\return the log level
*/
SWITCH_DECLARE(switch_log_level_t) switch_core_session_get_loglevel(switch_core_session_t *session);
-
+
SWITCH_DECLARE(switch_jb_t *) switch_core_session_get_jb(switch_core_session_t *session, switch_media_type_t type);
SWITCH_DECLARE(void) switch_core_session_soft_lock(switch_core_session_t *session, uint32_t sec);
SWITCH_DECLARE(void) switch_core_session_soft_unlock(switch_core_session_t *session);
SWITCH_DECLARE(switch_status_t) switch_core_session_set_codec_slin(switch_core_session_t *session, switch_slin_data_t *data);
SWITCH_DECLARE(void) switch_core_session_raw_read(switch_core_session_t *session);
-/*!
+/*!
\brief Retrieve the unique identifier from the core
\return a string representing the uuid
*/
SWITCH_DECLARE(switch_core_session_t *) switch_core_session_perform_force_locate(const char *uuid_str, const char *file, const char *func, int line);
-/*!
+/*!
\brief Locate a session based on it's uuid
\param uuid_str the unique id of the session you want to find
\return the session or NULL
#define switch_core_session_locate(uuid_str) switch_core_session_perform_locate(uuid_str, __FILE__, __SWITCH_FUNC__, __LINE__)
-/*!
+/*!
\brief Locate a session based on it's uuid even if the channel is not ready
\param uuid_str the unique id of the session you want to find
\return the session or NULL
#define switch_core_session_force_locate(uuid_str) switch_core_session_perform_force_locate(uuid_str, __FILE__, __SWITCH_FUNC__, __LINE__)
-/*!
+/*!
\brief Retrieve a global variable from the core
\param varname the name of the variable
\return the value of the desired variable
SWITCH_DECLARE(char *) switch_core_get_domain(switch_bool_t dup);
-/*!
+/*!
\brief Add a global variable to the core
\param varname the name of the variable
\param value the value of the variable
SWITCH_DECLARE(void) switch_core_set_variable(_In_z_ const char *varname, _In_opt_z_ const char *value);
SWITCH_DECLARE(switch_status_t) switch_core_get_variables(switch_event_t **event);
-/*!
+/*!
\brief Conditionally add a global variable to the core
\param varname the name of the variable
\param value the value of the variable
SWITCH_DECLARE(void) switch_core_dump_variables(_In_ switch_stream_handle_t *stream);
-/*!
+/*!
\brief Hangup all sessions
\param cause the hangup cause to apply to the hungup channels
*/
SHT_ANSWERED = (1 << 1)
} switch_hup_type_t;
-/*!
+/*!
\brief Hangup all sessions which match a specific channel variable
\param var_name The variable name to look for
- \param var_val The value to look for
+ \param var_val The value to look for
\param cause the hangup cause to apply to the hungup channels
*/
SWITCH_DECLARE(uint32_t) switch_core_session_hupall_matching_var_ans(_In_ const char *var_name, _In_ const char *var_val, _In_
switch_call_cause_t cause, switch_hup_type_t type);
#define switch_core_session_hupall_matching_vars(_vs, _c) switch_core_session_hupall_matching_vars_ans(_vs, _c, SHT_UNANSWERED | SHT_ANSWERED)
-/*!
+/*!
\brief Hangup all sessions that belong to an endpoint
- \param endpoint_interface The endpoint interface
+ \param endpoint_interface The endpoint interface
\param cause the hangup cause to apply to the hungup channels
*/
SWITCH_DECLARE(void) switch_core_session_hupall_endpoint(const switch_endpoint_interface_t *endpoint_interface, switch_call_cause_t cause);
-/*!
+/*!
\brief Get the session's partner (the session its bridged to)
- \param session The session we're searching with
+ \param session The session we're searching with
\param partner [out] The session's partner, or NULL if it wasnt found
\return SWITCH_STATUS_SUCCESS or SWITCH_STATUS_FALSE if this session isn't bridged
*/
#define switch_core_session_get_partner(_session, _partner) switch_core_session_perform_get_partner(_session, _partner, __FILE__, __SWITCH_FUNC__, __LINE__)
-/*!
+/*!
\brief Send a message to another session using it's uuid
\param uuid_str the unique id of the session you want to send a message to
\param message the switch_core_session_message_t object to send
*/
SWITCH_DECLARE(switch_status_t) switch_core_session_message_send(_In_z_ const char *uuid_str, _In_ switch_core_session_message_t *message);
-/*!
+/*!
\brief Queue a message on a session
\param session the session to queue the message to
\param message the message to queue
SWITCH_DECLARE(switch_status_t) switch_core_session_queue_signal_data(switch_core_session_t *session, void *signal_data);
SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_signal_data(switch_core_session_t *session, void **signal_data);
-/*!
+/*!
\brief pass an indication message on a session
\param session the session to pass the message across
\param indication the indication message to pass
SWITCH_DECLARE(switch_status_t) switch_core_session_pass_indication(_In_ switch_core_session_t *session,
_In_ switch_core_session_message_types_t indication);
-/*!
+/*!
\brief Queue an indication message on a session
\param session the session to queue the message to
\param indication the indication message to queue
SWITCH_DECLARE(switch_status_t) switch_core_session_queue_indication(_In_ switch_core_session_t *session,
_In_ switch_core_session_message_types_t indication);
-/*!
+/*!
\brief DE-Queue an message on a given session
\param session the session to de-queue the message on
\param message the de-queued message
*/
SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_message(_In_ switch_core_session_t *session, _Out_ switch_core_session_message_t **message);
-/*!
+/*!
\brief Flush a message queue on a given session
\param session the session to de-queue the message on
\return SWITCH_STATUS_SUCCESS if the message was de-queued
*/
SWITCH_DECLARE(switch_status_t) switch_core_session_flush_message(_In_ switch_core_session_t *session);
-/*!
+/*!
\brief Queue an event on another session using its uuid
\param uuid_str the unique id of the session you want to send a message to
\param event the event to send
SWITCH_DECLARE(switch_app_log_t *) switch_core_session_get_app_log(_In_ switch_core_session_t *session);
-/*!
- \brief Execute an application on a session
+/*!
+ \brief Execute an application on a session
\param session the current session
\param application_interface the interface of the application to execute
\param arg application arguments
_In_ const switch_application_interface_t *application_interface, _In_opt_z_ const char *arg);
SWITCH_DECLARE(void) switch_core_session_video_reset(switch_core_session_t *session);
-/*!
- \brief Execute an application on a session
+/*!
+ \brief Execute an application on a session
\param session the current session
\param app the application's name
\param arg application arguments
SWITCH_DECLARE(switch_status_t) switch_core_session_get_app_flags(const char *app, int32_t *flags);
-/*!
- \brief Execute an application on a session
+/*!
+ \brief Execute an application on a session
\param session the current session
\param app the application's name
\param arg application arguments
*/
#define switch_core_session_execute_application(_a, _b, _c) switch_core_session_execute_application_get_flags(_a, _b, _c, NULL)
-/*!
+/*!
\brief Run a dialplan and execute an extension
\param session the current session
\param exten the interface of the application to execute
_In_z_ const char *exten,
_In_opt_z_ const char *dialplan, _In_opt_z_ const char *context);
-/*!
+/*!
\brief Send an event to a session translating it to it's native message format
\param session the session to receive the event
\param event the event to receive
*/
SWITCH_DECLARE(switch_status_t) switch_core_session_receive_event(_In_ switch_core_session_t *session, _Inout_ switch_event_t **event);
-/*!
+/*!
\brief Retrieve private user data from a session
\param session the session to retrieve from
\return a pointer to the private data
SWITCH_DECLARE(void *) switch_core_session_get_private_class(_In_ switch_core_session_t *session, _In_ switch_pvt_class_t index);
#define switch_core_session_get_private(_s) switch_core_session_get_private_class(_s, SWITCH_PVT_PRIMARY)
-/*!
+/*!
\brief Add private user data to a session
\param session the session to add used data to
\param private_info the used data to add
SWITCH_DECLARE(const char *) switch_core_session_get_text_buffer(switch_core_session_t *session);
-/*!
+/*!
\brief Launch a thread designed to exist within the scope of a given session
\param session a session to allocate the thread from
\param func a function to execute in the thread
SWITCH_DECLARE(void) switch_core_session_launch_thread(_In_ switch_core_session_t *session,
_In_ void *(*func) (switch_thread_t *, void *), _In_opt_ void *obj);
-/*!
+/*!
\brief Signal a thread using a thread session to terminate
\param session the session to indicate to
*/
SWITCH_DECLARE(void) switch_core_thread_session_end(_In_ switch_core_session_t *session);
-/*!
+/*!
\brief Launch a service thread on a session to drop inbound data
\param session the session the launch thread on
*/
#define switch_core_service_session(_s) switch_core_service_session_av(_s, SWITCH_TRUE, SWITCH_FALSE)
-/*!
+/*!
\brief Request an outgoing session spawned from an existing session using a desired endpoing module
\param session the originating session
\param var_event switch_event_t containing paramaters
_Inout_ switch_memory_pool_t **pool, _In_ switch_originate_flag_t flags,
switch_call_cause_t *cancel_cause);
-/*!
+/*!
\brief Receive a message on a given session
\param session the session to receive the message from
\param message the message to recieve
#define switch_core_session_receive_message(_session, _message) switch_core_session_perform_receive_message(_session, _message, \
__FILE__, __SWITCH_FUNC__, __LINE__)
-/*!
+/*!
\brief Queue an event on a given session
\param session the session to queue the message on
\param event the event to queue
SWITCH_DECLARE(switch_status_t) switch_core_session_queue_event(_In_ switch_core_session_t *session, _Inout_ switch_event_t **event);
-/*!
+/*!
\brief Indicate the number of waiting events on a session
\param session the session to check
\return the number of events
SWITCH_DECLARE(uint32_t) switch_core_session_event_count(_In_ switch_core_session_t *session);
/*
- Number of parsable messages waiting on the session.
+ Number of parsable messages waiting on the session.
*/
SWITCH_DECLARE(uint32_t) switch_core_session_messages_waiting(switch_core_session_t *session);
-/*!
+/*!
\brief DE-Queue an event on a given session
\param session the session to de-queue the message on
\param event the de-queued event
*/
SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_event(_In_ switch_core_session_t *session, _Out_ switch_event_t **event, switch_bool_t force);
-/*!
+/*!
\brief Queue a private event on a given session
\param session the session to queue the message on
\param event the event to queue
switch_bool_t priority);
-/*!
+/*!
\brief Indicate the number of waiting private events on a session
\param session the session to check
\return the number of events
*/
SWITCH_DECLARE(uint32_t) switch_core_session_private_event_count(_In_ switch_core_session_t *session);
-/*!
+/*!
\brief DE-Queue a private event on a given session
\param session the session to de-queue the message on
\param event the de-queued event
SWITCH_DECLARE(uint32_t) switch_core_session_flush_private_events(switch_core_session_t *session);
-/*!
+/*!
\brief Read a frame from a session
\param session the session to read from
\param frame a NULL pointer to a frame to aim at the newly read frame
SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(_In_ switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags,
int stream_id);
-/*!
+/*!
\brief Read a video frame from a session
\param session the session to read from
\param frame a NULL pointer to a frame to aim at the newly read frame
*/
SWITCH_DECLARE(switch_status_t) switch_core_session_read_video_frame(_In_ switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags,
int stream_id);
-/*!
+/*!
\brief Write a video frame to a session
\param session the session to write to
\param frame a pointer to a frame to write
SWITCH_DECLARE(switch_status_t) switch_core_session_write_video_frame(_In_ switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags,
int stream_id);
-SWITCH_DECLARE(switch_status_t) switch_core_session_write_encoded_video_frame(switch_core_session_t *session,
+SWITCH_DECLARE(switch_status_t) switch_core_session_write_encoded_video_frame(switch_core_session_t *session,
switch_frame_t *frame, switch_io_flag_t flags, int stream_id);
SWITCH_DECLARE(switch_status_t) switch_core_session_set_read_impl(switch_core_session_t *session, const switch_codec_implementation_t *impp);
SWITCH_DECLARE(switch_status_t) switch_core_session_set_video_read_impl(switch_core_session_t *session, const switch_codec_implementation_t *impp);
SWITCH_DECLARE(switch_status_t) switch_core_session_set_video_write_impl(switch_core_session_t *session, const switch_codec_implementation_t *impp);
-/*!
+/*!
\brief Reset the buffers and resampler on a session
\param session the session to reset
\param flush_dtmf flush all queued dtmf events too
*/
SWITCH_DECLARE(void) switch_core_session_reset(_In_ switch_core_session_t *session, switch_bool_t flush_dtmf, switch_bool_t reset_read_codec);
-/*!
+/*!
\brief Write a frame to a session
\param session the session to write to
\param frame the frame to write
*/
#define switch_core_session_kill_channel(session, sig) switch_core_session_perform_kill_channel(session, __FILE__, __SWITCH_FUNC__, __LINE__, sig)
-/*!
+/*!
\brief Send DTMF to a session
\param session session to send DTMF to
\param dtmf dtmf to send to the session
\return SWITCH_STATUS_SUCCESS if the dtmf was written
*/
SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf(_In_ switch_core_session_t *session, const switch_dtmf_t *dtmf);
-/*!
+/*!
\brief Send DTMF to a session
\param session session to send DTMF to
\param dtmf_string string to send to the session
*/
SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf_string(switch_core_session_t *session, const char *dtmf_string);
-/*!
+/*!
\brief RECV DTMF on a session
\param session session to recv DTMF from
\param dtmf string to recv from the session
///\defgroup hashf Hash Functions
///\ingroup core1
///\{
-/*!
+/*!
\brief Initialize a hash table
\param hash a NULL pointer to a hash table to aim at the new hash
\param pool the pool to use for the new hash
#define switch_core_hash_init_nocase(_hash) switch_core_hash_init_case(_hash, SWITCH_FALSE)
-/*!
+/*!
\brief Destroy an existing hash table
\param hash the hash to destroy
\return SWITCH_STATUS_SUCCESS if the hash is destroyed
*/
SWITCH_DECLARE(switch_status_t) switch_core_hash_destroy(_Inout_ switch_hash_t **hash);
-/*!
+/*!
\brief Insert data into a hash
\param hash the hash to add data to
\param key the name of the key to add the data to
#define switch_core_hash_insert(_h, _k, _d) switch_core_hash_insert_destructor(_h, _k, _d, NULL)
-/*!
+/*!
\brief Insert data into a hash
\param hash the hash to add data to
\param key the name of the key to add the data to
*/
SWITCH_DECLARE(switch_status_t) switch_core_hash_insert_locked(_In_ switch_hash_t *hash, _In_z_ const char *key, _In_opt_ const void *data,
_In_opt_ switch_mutex_t *mutex);
-/*!
+/*!
\brief Retrieve data from a given hash
\param hash the hash to retrieve from
\param key the key to retrieve
*/
SWITCH_DECLARE(switch_status_t) switch_core_hash_insert_wrlock(switch_hash_t *hash, const char *key, const void *data, switch_thread_rwlock_t *rwlock);
-/*!
+/*!
\brief Delete data from a hash based on desired key
\param hash the hash to delete from
\param key the key from which to delete the data
*/
SWITCH_DECLARE(void *) switch_core_hash_delete(_In_ switch_hash_t *hash, _In_z_ const char *key);
-/*!
+/*!
\brief Delete data from a hash based on desired key
\param hash the hash to delete from
\param key the key from which to delete the data
*/
SWITCH_DECLARE(void *) switch_core_hash_delete_locked(_In_ switch_hash_t *hash, _In_z_ const char *key, _In_opt_ switch_mutex_t *mutex);
-/*!
+/*!
\brief Delete data from a hash based on desired key
\param hash the hash to delete from
\param key the key from which to delete the data
*/
SWITCH_DECLARE(void *) switch_core_hash_delete_wrlock(_In_ switch_hash_t *hash, _In_z_ const char *key, _In_opt_ switch_thread_rwlock_t *rwlock);
-/*!
+/*!
\brief Delete data from a hash based on callback function
\param hash the hash to delete from
\param callback the function to call which returns SWITCH_TRUE to delete, SWITCH_FALSE to preserve
*/
SWITCH_DECLARE(switch_status_t) switch_core_hash_delete_multi(_In_ switch_hash_t *hash, _In_ switch_hash_delete_callback_t callback, _In_opt_ void *pData);
-/*!
+/*!
\brief Retrieve data from a given hash
\param hash the hash to retrieve from
\param key the key to retrieve
SWITCH_DECLARE(void *) switch_core_hash_find(_In_ switch_hash_t *hash, _In_z_ const char *key);
-/*!
+/*!
\brief Retrieve data from a given hash
\param hash the hash to retrieve from
\param key the key to retrieve
*/
SWITCH_DECLARE(void *) switch_core_hash_find_locked(_In_ switch_hash_t *hash, _In_z_ const char *key, _In_ switch_mutex_t *mutex);
-/*!
+/*!
\brief Retrieve data from a given hash
\param hash the hash to retrieve from
\param key the key to retrieve
\brief Gets the first element of a hashtable
\param deprecate_me [deprecated] NULL
\param hash the hashtable to use
- \return The element, or NULL if it wasn't found
+ \return The element, or NULL if it wasn't found
*/
SWITCH_DECLARE(switch_hash_index_t *) switch_core_hash_first_iter(_In_ switch_hash_t *hash, switch_hash_index_t *hi);
#define switch_core_hash_first(_h) switch_core_hash_first_iter(_h, NULL)
/*!
\brief Gets the key and value of the current hash element
- \param hi The current element
+ \param hi The current element
\param key [out] the key
\param klen [out] the key's size
- \param val [out] the value
+ \param val [out] the value
*/
SWITCH_DECLARE(void) switch_core_hash_this(_In_ switch_hash_index_t *hi, _Out_opt_ptrdiff_cap_(klen)
const void **key, _Out_opt_ switch_ssize_t *klen, _Out_ void **val);
///\defgroup timer Timer Functions
///\ingroup core1
///\{
-/*!
+/*!
\brief Request a timer handle using given time module
\param timer a timer object to allocate to
\param timer_name the name of the timer module to use
SWITCH_DECLARE(void) switch_time_calibrate_clock(void);
-/*!
+/*!
\brief Wait for one cycle on an existing timer
\param timer the timer to wait on
\return the newest sample count
*/
SWITCH_DECLARE(switch_status_t) switch_core_timer_next(switch_timer_t *timer);
-/*!
+/*!
\brief Step the timer one step
\param timer the timer to wait on
\return the newest sample count
SWITCH_DECLARE(switch_status_t) switch_core_timer_sync(switch_timer_t *timer);
-/*!
+/*!
\brief Check if the current step has been exceeded
\param timer the timer to wait on
\param step increment timer if a tick was detected
*/
SWITCH_DECLARE(switch_status_t) switch_core_timer_check(switch_timer_t *timer, switch_bool_t step);
-/*!
+/*!
\brief Destroy an allocated timer
\param timer timer to destroy
\return SWITCH_STATUS_SUCCESS after destruction
///\defgroup codecs Codec Functions
///\ingroup core1
///\{
-/*!
+/*!
\brief Initialize a codec handle
\param codec the handle to initilize
\param codec_name the name of the codec module to use
int ms,
int channels,
uint32_t bitrate,
- uint32_t flags,
- const switch_codec_settings_t *codec_settings,
+ uint32_t flags,
+ const switch_codec_settings_t *codec_settings,
switch_memory_pool_t *pool);
-
-SWITCH_DECLARE(switch_status_t) switch_core_codec_copy(switch_codec_t *codec, switch_codec_t *new_codec,
+
+SWITCH_DECLARE(switch_status_t) switch_core_codec_copy(switch_codec_t *codec, switch_codec_t *new_codec,
const switch_codec_settings_t *codec_settings, switch_memory_pool_t *pool);
SWITCH_DECLARE(switch_status_t) switch_core_codec_parse_fmtp(const char *codec_name, const char *fmtp, uint32_t rate, switch_codec_fmtp_t *codec_fmtp);
SWITCH_DECLARE(switch_status_t) switch_core_codec_reset(switch_codec_t *codec);
-/*!
+/*!
\brief Encode data using a codec handle
\param codec the codec handle to use
\param other_codec the codec handle of the last codec used
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
\param codec the codec handle to use
\param other_codec the codec handle of the last codec used
\param ret_data a void pointer to a pointer of return data
\return SWITCH_STATUS_SUCCESS if the command was received
*/
-SWITCH_DECLARE(switch_status_t) switch_core_codec_control(switch_codec_t *codec,
- switch_codec_control_command_t cmd,
+SWITCH_DECLARE(switch_status_t) switch_core_codec_control(switch_codec_t *codec,
+ switch_codec_control_command_t cmd,
switch_codec_control_type_t ctype,
void *cmd_data,
switch_codec_control_type_t atype,
*/
SWITCH_DECLARE(switch_status_t) switch_core_codec_decode_video(switch_codec_t *codec, switch_frame_t *frame);
-/*!
+/*!
\brief Destroy an initalized codec handle
\param codec the codec handle to destroy
\return SWITCH_STATUS_SUCCESS if the codec was destroyed
*/
SWITCH_DECLARE(switch_status_t) switch_core_codec_destroy(switch_codec_t *codec);
-/*!
+/*!
\brief Assign the read codec to a given session
\param session session to add the codec to
\param codec the codec to add
*/
SWITCH_DECLARE(switch_status_t) switch_core_session_set_read_codec(_In_ switch_core_session_t *session, switch_codec_t *codec);
-/*!
+/*!
\brief Assign the original read codec to a given session. This is the read codec used by an endpoint.
\param session session to add the codec to
\param codec the codec to add
SWITCH_DECLARE(switch_status_t) switch_core_session_get_video_write_impl(switch_core_session_t *session, switch_codec_implementation_t *impp);
-/*!
+/*!
\brief Retrieve the read codec from a given session
\param session session to retrieve from
\return a pointer to the codec
*/
SWITCH_DECLARE(switch_codec_t *) switch_core_session_get_read_codec(_In_ switch_core_session_t *session);
-/*!
+/*!
\brief Retrieve the effevtive read codec from a given session
\param session session to retrieve from
\return a pointer to the codec
*/
SWITCH_DECLARE(switch_codec_t *) switch_core_session_get_effective_read_codec(_In_ switch_core_session_t *session);
-/*!
+/*!
\brief Assign the write codec to a given session
\param session session to add the codec to
\param codec the codec to add
*/
SWITCH_DECLARE(switch_status_t) switch_core_session_set_write_codec(_In_ switch_core_session_t *session, switch_codec_t *codec);
-/*!
+/*!
\brief Retrieve the write codec from a given session
\param session session to retrieve from
\return a pointer to the codec
*/
SWITCH_DECLARE(switch_codec_t *) switch_core_session_get_write_codec(_In_ switch_core_session_t *session);
-/*!
+/*!
\brief Retrieve the effevtive write codec from a given session
\param session session to retrieve from
\return a pointer to the codec
*/
SWITCH_DECLARE(switch_codec_t *) switch_core_session_get_effective_write_codec(_In_ switch_core_session_t *session);
-/*!
+/*!
\brief Assign the video_read codec to a given session
\param session session to add the codec to
\param codec the codec to add
*/
SWITCH_DECLARE(switch_status_t) switch_core_session_set_video_read_codec(_In_ switch_core_session_t *session, switch_codec_t *codec);
-/*!
+/*!
\brief Retrieve the video_read codec from a given session
\param session session to retrieve from
\return a pointer to the codec
*/
SWITCH_DECLARE(switch_codec_t *) switch_core_session_get_video_read_codec(_In_ switch_core_session_t *session);
-/*!
+/*!
\brief Assign the video_write codec to a given session
\param session session to add the codec to
\param codec the codec to add
*/
SWITCH_DECLARE(switch_status_t) switch_core_session_set_video_write_codec(_In_ switch_core_session_t *session, switch_codec_t *codec);
-/*!
+/*!
\brief Retrieve the video_write codec from a given session
\param session session to retrieve from
\return a pointer to the codec
///\defgroup db Database Functions
///\ingroup core1
///\{
-/*!
+/*!
\brief Open a core db (SQLite) file
\param filename the path to the db file to open
\return the db handle
*/
SWITCH_DECLARE(switch_core_db_t *) switch_core_db_open_file(const char *filename);
-/*!
+/*!
\brief Execute a sql stmt until it is accepted
\param db the db handle
\param sql the sql to execute
-/*!
+/*!
\brief perform a test query then perform a reactive query if the first one fails
\param db the db handle
\param test_sql the test sql
_In_ uint32_t channels,
_In_ uint32_t rate, _In_ unsigned int flags, _In_opt_ switch_memory_pool_t *pool);
-/*!
+/*!
\brief Open a media file using file format modules
\param _fh a file handle to use
\param _file_path the path to the file
#define switch_core_file_open(_fh, _file_path, _channels, _rate, _flags, _pool) \
switch_core_perform_file_open(__FILE__, __SWITCH_FUNC__, __LINE__, _fh, _file_path, _channels, _rate, _flags, _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)
\param data the buffer to read the data to
*/
SWITCH_DECLARE(switch_status_t) switch_core_file_read(_In_ switch_file_handle_t *fh, void *data, switch_size_t *len);
-/*!
+/*!
\brief Write media to a file handle
\param fh the file handle to write to
\param data the buffer to write
*/
SWITCH_DECLARE(switch_status_t) switch_core_file_write(_In_ switch_file_handle_t *fh, void *data, switch_size_t *len);
-/*!
+/*!
\brief Write media to a file handle
\param fh the file handle to write to
\param data the buffer to write
*/
SWITCH_DECLARE(switch_status_t) switch_core_file_seek(_In_ switch_file_handle_t *fh, unsigned int *cur_pos, int64_t samples, int whence);
-/*!
+/*!
\brief Set metadata to the desired string
\param fh the file handle to set data to
\param col the enum of the col name
*/
SWITCH_DECLARE(switch_status_t) switch_core_file_set_string(_In_ switch_file_handle_t *fh, switch_audio_col_t col, const char *string);
-/*!
+/*!
\brief get metadata of the desired string
\param fh the file handle to get data from
\param col the enum of the col name
SWITCH_DECLARE(switch_status_t) switch_core_file_get_string(_In_ switch_file_handle_t *fh, switch_audio_col_t col, const char **string);
-/*!
+/*!
\brief Close an open file handle
\param fh the file handle to close
\return SWITCH_STATUS_SUCCESS if the file handle was closed
///\defgroup speech ASR/TTS Functions
///\ingroup core1
///\{
-/*!
+/*!
\brief Open a speech handle
\param sh a speech handle to use
\param module_name the speech module to use
const char *module_name,
const char *voice_name,
_In_ unsigned int rate,
- _In_ unsigned int interval,
+ _In_ unsigned int interval,
_In_ unsigned int channels,
switch_speech_flag_t *flags, _In_opt_ switch_memory_pool_t *pool);
-/*!
+/*!
\brief Feed text to the TTS module
\param sh the speech handle to feed
\param text the buffer to write
*/
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
\param sh the speech handle
*/
SWITCH_DECLARE(void) switch_core_speech_flush_tts(switch_speech_handle_t *sh);
-/*!
+/*!
\brief Set a text parameter on a TTS handle
\param sh the speech handle
\param param the parameter
*/
SWITCH_DECLARE(void) switch_core_speech_text_param_tts(switch_speech_handle_t *sh, char *param, const char *val);
-/*!
+/*!
\brief Set a numeric parameter on a TTS handle
\param sh the speech handle
\param param the parameter
*/
SWITCH_DECLARE(void) switch_core_speech_numeric_param_tts(switch_speech_handle_t *sh, char *param, int val);
-/*!
+/*!
\brief Set a float parameter on a TTS handle
\param sh the speech handle
\param param the parameter
*/
SWITCH_DECLARE(void) switch_core_speech_float_param_tts(switch_speech_handle_t *sh, char *param, double val);
-/*!
+/*!
\brief Read rendered audio from the TTS module
\param sh the speech handle to read
\param data the buffer to read to
\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, switch_speech_flag_t *flags);
-/*!
+/*!
\brief Close an open speech handle
\param sh the speech handle to close
\param flags flags in/out for fine tuning
SWITCH_DECLARE(switch_status_t) switch_core_speech_close(switch_speech_handle_t *sh, switch_speech_flag_t *flags);
-/*!
+/*!
\brief Open an asr handle
\param ah the asr handle to open
\param module_name the name of the asr module
///\defgroup dir Directory Service Functions
///\ingroup core1
///\{
-/*!
+/*!
\brief Open a directory handle
\param dh a directory handle to use
\param module_name the directory module to use
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
\param dh a directory handle to use
\param base the base to query against
*/
SWITCH_DECLARE(switch_status_t) switch_core_directory_query(switch_directory_handle_t *dh, char *base, char *query);
-/*!
+/*!
\brief Obtain the next record in a lookup
\param dh a directory handle to use
\return SWITCH_STATUS_SUCCESS if another record exists
*/
SWITCH_DECLARE(switch_status_t) switch_core_directory_next(switch_directory_handle_t *dh);
-/*!
+/*!
\brief Obtain the next name/value pair in the current record
\param dh a directory handle to use
\param var a pointer to pointer of the name to fill in
*/
SWITCH_DECLARE(switch_status_t) switch_core_directory_next_pair(switch_directory_handle_t *dh, char **var, char **val);
-/*!
+/*!
\brief Close an open directory handle
\param dh a directory handle to close
\return SWITCH_STATUS_SUCCESS if handle was closed
///\defgroup misc Misc
///\ingroup core1
///\{
-/*!
+/*!
\brief Retrieve a FILE stream of a given text channel name
\param channel text channel enumeration
\return a FILE stream
*/
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_running(void);
-/*!
+/*!
\brief Determines if the core is ready to take inbound calls
\return SWITCH_TRUE or SWITCH_FALSE
*/
SWITCH_DECLARE(switch_bool_t) switch_core_ready_inbound(void);
-/*!
+/*!
\brief Determines if the core is ready to place outbound calls
\return SWITCH_TRUE or SWITCH_FALSE
*/
SWITCH_DECLARE(switch_bool_t) switch_core_ready_outbound(void);
-/*!
+/*!
\brief return core flags
\return core flags
*/
SWITCH_DECLARE(switch_core_flag_t) switch_core_flags(void);
-/*!
+/*!
\brief Execute a management operation.
\param relative_oid the relative oid of the operation.
\param action the action to perform.
*/
SWITCH_DECLARE(switch_status_t) switch_core_management_exec(char *relative_oid, switch_management_action_t action, char *data, switch_size_t datalen);
-/*!
+/*!
\brief Switch on the privilege awareness for the process and request required privileges
\return 0 on success
*/
-
+
SWITCH_DECLARE(int32_t) switch_core_set_process_privileges(void);
-/*!
+/*!
\brief Set the maximum priority the process can obtain
\return 0 on success
*/
SWITCH_DECLARE(int32_t) set_realtime_priority(void);
SWITCH_DECLARE(int32_t) set_low_priority(void);
-/*!
+/*!
\brief Change user and/or group of the running process
\param user name of the user to switch to (or NULL)
\param group name of the group to switch to (or NULL)
*/
SWITCH_DECLARE(int32_t) change_user_group(const char *user, const char *group);
-/*!
+/*!
\brief Run endlessly until the system is shutdown
\param bg divert console to the background
*/
SWITCH_DECLARE(FILE *) switch_core_get_console(void);
#ifndef SWIG
-/*!
+/*!
\brief Launch a thread
*/
SWITCH_DECLARE(switch_thread_t *) switch_core_launch_thread(void *(SWITCH_THREAD_FUNC * func) (switch_thread_t *, void *),
*/
SWITCH_DECLARE(uint8_t) switch_core_session_compare(switch_core_session_t *a, switch_core_session_t *b);
/*!
- \brief Checks if a session is using a specific endpoint
+ \brief Checks if a session is using a specific endpoint
\param session the session
\param endpoint_interface interface of the endpoint to check
\return TRUE or FALSE
*/
SWITCH_DECLARE(uint8_t) switch_core_session_check_interface(switch_core_session_t *session, const switch_endpoint_interface_t *endpoint_interface);
-SWITCH_DECLARE(switch_status_t) switch_core_session_set_video_read_callback(switch_core_session_t *session,
+SWITCH_DECLARE(switch_status_t) switch_core_session_set_video_read_callback(switch_core_session_t *session,
switch_core_video_thread_callback_func_t func, void *user_data);
SWITCH_DECLARE(switch_status_t) switch_core_session_video_read_callback(switch_core_session_t *session, switch_frame_t *frame);
SWITCH_DECLARE(switch_loadable_module_interface_t *) switch_loadable_module_create_module_interface(switch_memory_pool_t *pool, const char *name);
SWITCH_DECLARE(void *) switch_loadable_module_create_interface(switch_loadable_module_interface_t *mod, switch_module_interface_name_t iname);
-/*!
+/*!
\brief Get the current epoch time in microseconds
\return the current epoch time in microseconds
*/
SWITCH_DECLARE(void) switch_core_setrlimits(void);
SWITCH_DECLARE(switch_time_t) switch_time_ref(void);
SWITCH_DECLARE(void) switch_time_sync(void);
-/*!
+/*!
\brief Get the current epoch time
- \param [out] (optional) The current epoch time
- \return The current epoch time
+ \param [out] (optional) The current epoch time
+ \return The current epoch time
*/
SWITCH_DECLARE(time_t) switch_epoch_time_now(time_t *t);
SWITCH_DECLARE(const char *) switch_lookup_timezone(const char *tz_name);
SWITCH_DECLARE(switch_cache_db_handle_type_t) switch_cache_db_get_type(switch_cache_db_handle_t *dbh);
-/*!
+/*!
\brief Returns the handle to the pool, immediately available for other
threads to use.
\param [in] The handle
*/
SWITCH_DECLARE(void) switch_cache_db_dismiss_db_handle(switch_cache_db_handle_t ** dbh);
-/*!
- \brief Returns the handle to the pool, handle is NOT available to
+/*!
+ \brief Returns the handle to the pool, handle is NOT available to
other threads until the allocating thread actually terminates.
\param [in] The handle
*/
SWITCH_DECLARE(void) switch_cache_db_release_db_handle(switch_cache_db_handle_t ** dbh);
-/*!
+/*!
\brief Gets a new cached handle from the pool, potentially creating a new connection.
The connection is bound to the thread until it (the thread) terminates unless
you dismiss rather than release.
const char *file, const char *func, int line);
#define switch_cache_db_get_db_handle(_a, _b, _c) _switch_cache_db_get_db_handle(_a, _b, _c, __FILE__, __SWITCH_FUNC__, __LINE__)
-SWITCH_DECLARE(switch_status_t) _switch_cache_db_get_db_handle_dsn(switch_cache_db_handle_t **dbh, const char *dsn,
+SWITCH_DECLARE(switch_status_t) _switch_cache_db_get_db_handle_dsn(switch_cache_db_handle_t **dbh, const char *dsn,
const char *file, const char *func, int line);
#define switch_cache_db_get_db_handle_dsn(_a, _b) _switch_cache_db_get_db_handle_dsn(_a, _b, __FILE__, __SWITCH_FUNC__, __LINE__)
-/*!
+/*!
\brief Executes the create schema sql
\param [in] dbh The handle
\param [in] sql - sql to run
\param [out] err - Error if it exists
*/
SWITCH_DECLARE(switch_status_t) switch_cache_db_create_schema(switch_cache_db_handle_t *dbh, char *sql, char **err);
-/*!
+/*!
\brief Executes the sql and returns the result as a string
\param [in] dbh The handle
\param [in] sql - sql to run
\param [out] err - Error if it exists
*/
SWITCH_DECLARE(char *) switch_cache_db_execute_sql2str(switch_cache_db_handle_t *dbh, char *sql, char *str, size_t len, char **err);
-/*!
+/*!
\brief Executes the sql
\param [in] dbh The handle
\param [in] sql - sql to run
\param [out] err - Error if it exists
*/
SWITCH_DECLARE(switch_status_t) switch_cache_db_execute_sql(switch_cache_db_handle_t *dbh, char *sql, char **err);
-/*!
+/*!
\brief Executes the sql and uses callback for row-by-row processing
\param [in] dbh The handle
\param [in] sql - sql to run
SWITCH_DECLARE(switch_status_t) switch_cache_db_execute_sql_callback(switch_cache_db_handle_t *dbh, const char *sql,
switch_core_db_callback_func_t callback, void *pdata, char **err);
-/*!
+/*!
\brief Executes the sql and uses callback for row-by-row processing
\param [in] dbh The handle
\param [in] sql - sql to run
*/
SWITCH_DECLARE(int) switch_cache_db_load_extension(switch_cache_db_handle_t *dbh, const char *extension);
-/*!
+/*!
\brief Provides some feedback as to the status of the db connection pool
\param [in] stream stream for status
*/
\param [in] metadata - generic metadata supplied by module
\param [out] err - Error if it exists
*/
-SWITCH_DECLARE(switch_status_t) switch_core_add_registration(const char *user, const char *realm, const char *token, const char *url, uint32_t expires,
+SWITCH_DECLARE(switch_status_t) switch_core_add_registration(const char *user, const char *realm, const char *token, const char *url, uint32_t expires,
const char *network_ip, const char *network_port, const char *network_proto,
const char *metadata);
/*!
SWITCH_DECLARE(switch_status_t) switch_sql_queue_manager_push(switch_sql_queue_manager_t *qm, const char *sql, uint32_t pos, switch_bool_t dup);
SWITCH_DECLARE(switch_status_t) switch_sql_queue_manager_destroy(switch_sql_queue_manager_t **qmp);
SWITCH_DECLARE(switch_status_t) switch_sql_queue_manager_init_name(const char *name,
- switch_sql_queue_manager_t **qmp,
+ switch_sql_queue_manager_t **qmp,
uint32_t numq, const char *dsn, uint32_t max_trans,
const char *pre_trans_execute,
const char *post_trans_execute,
switch_core_db_event_callback_func_t callback,
switch_core_db_err_callback_func_t err_callback,
void *pdata);
-
+
SWITCH_DECLARE(pid_t) switch_fork(void);
SWITCH_DECLARE(int) switch_core_gen_certs(const char *prefix);
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Michael Jerris <mike@jerris.com>
*
*/
/**
* @defgroup switch_core_db Database Routines
- * @ingroup switch_sqlite_top
+ * @ingroup switch_sqlite_top
* @{
*/
/**
** These are special value for the destructor that is passed in as the
** final argument to routines like switch_core_db_result_blob(). If the destructor
** argument is SWITCH_CORE_DB_STATIC, it means that the content pointer is constant
-** and will never change. It does not need to be destroyed. The
+** and will never change. It does not need to be destroyed. The
** SWITCH_CORE_DB_TRANSIENT value means that the content will likely change in
** the near future and that the db should make its own private copy of
** the content before returning.
* in a single column of the current result row of a query. In every
* case the first parameter is a pointer to the SQL statement that is being
* executed (the switch_core_db_stmt_t* that was returned from switch_core_db_prepare()) and
- * the second argument is the index of the column for which information
+ * the second argument is the index of the column for which information
* should be returned. iCol is zero-indexed. The left-most column as an
* index of 0.
*
*
* The return value is is SWITCH_CORE_DB_OK if there are no errors and
* some other return code if there is an error. The particular
- * return value depends on the type of error.
+ * return value depends on the type of error.
*
* If the query could not be executed because a database file is
* locked or busy, then this function returns SWITCH_CORE_DB_BUSY. (This
* SQL statement obtained by a previous call to switch_core_db_prepare().
* If the statement was executed successfully, or
* not executed at all, then SWITCH_CORE_DB_OK is returned. If execution of the
- * statement failed then an error code is returned.
+ * statement failed then an error code is returned.
*
* This routine can be called at any point during the execution of the
* virtual machine. If the virtual machine has not completed execution
*/
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);
-/**
+/**
* After an SQL query has been compiled with a call to either
* switch_core_db_prepare(), then this function must be
* called one or more times to execute the statement.
*
- * The return value will be either SWITCH_CORE_DB_BUSY, SWITCH_CORE_DB_DONE,
+ * The return value will be either SWITCH_CORE_DB_BUSY, SWITCH_CORE_DB_DONE,
* SWITCH_CORE_DB_ROW, SWITCH_CORE_DB_ERROR, or SWITCH_CORE_DB_MISUSE.
*
* SWITCH_CORE_DB_BUSY means that the database engine attempted to open
* successfully. switch_core_db_step() should not be called again on this virtual
* machine.
*
- * If the SQL statement being executed returns any data, then
+ * If the SQL statement being executed returns any data, then
* SWITCH_CORE_DB_ROW is returned each time a new row of data is ready
* for processing by the caller. The values may be accessed using
* the switch_core_db_column_*() functions described below. switch_core_db_step()
* is called again to retrieve the next row of data.
- *
+ *
* SWITCH_CORE_DB_ERROR means that a run-time error (such as a constraint
* violation) has occurred. switch_core_db_step() should not be called again on
* the VM. More information may be found by calling switch_core_db_errmsg().
* In every case, the first parameter is a pointer to the sqlite3_stmt
* structure returned from switch_core_db_prepare(). The second parameter is the
* index of the parameter. The first parameter as an index of 1. For
- * named parameters (":AAA" or "$VVV") you can use
+ * named parameters (":AAA" or "$VVV") you can use
* switch_core_db_bind_parameter_index() to get the correct index value given
* the parameters name. If the same named parameter occurs more than
* once, it is assigned the same index each time.
* In every case, the first parameter is a pointer to the sqlite3_stmt
* structure returned from switch_core_db_prepare(). The second parameter is the
* index of the parameter. The first parameter as an index of 1. For
- * named parameters (":AAA" or "$VVV") you can use
+ * named parameters (":AAA" or "$VVV") you can use
* switch_core_db_bind_parameter_index() to get the correct index value given
* the parameters name. If the same named parameter occurs more than
* once, it is assigned the same index each time.
* In every case, the first parameter is a pointer to the sqlite3_stmt
* structure returned from switch_core_db_prepare(). The second parameter is the
* index of the parameter. The first parameter as an index of 1. For
- * named parameters (":AAA" or "$VVV") you can use
+ * named parameters (":AAA" or "$VVV") you can use
* switch_core_db_bind_parameter_index() to get the correct index value given
* the parameters name. If the same named parameter occurs more than
* once, it is assigned the same index each time.
* In every case, the first parameter is a pointer to the sqlite3_stmt
* structure returned from switch_core_db_prepare(). The second parameter is the
* index of the parameter. The first parameter as an index of 1. For
- * named parameters (":AAA" or "$VVV") you can use
+ * named parameters (":AAA" or "$VVV") you can use
* sqlite3_bind_parameter_index() to get the correct index value given
* the parameters name. If the same named parameter occurs more than
* once, it is assigned the same index each time.
* Instead of invoking a user-supplied callback for each row of the
* result, this routine remembers each row of the result in memory
* obtained from malloc(), then returns all of the result after the
- * query has finished.
+ * query has finished.
*
* As an example, suppose the query result where this table:
*
* set to 2. In general, the number of values inserted into azResult
* will be ((*nrow) + 1)*(*ncolumn).
*
- * After the calling function has finished using the result, it should
- * pass the result data pointer to switch_core_db_free_table() in order to
- * release the memory that was malloc-ed. Because of the way the
- * malloc() happens, the calling function must not try to call
- * free() directly. Only switch_core_db_free_table() is able to release
+ * After the calling function has finished using the result, it should
+ * pass the result data pointer to switch_core_db_free_table() in order to
+ * release the memory that was malloc-ed. Because of the way the
+ * malloc() happens, the calling function must not try to call
+ * free() directly. Only switch_core_db_free_table() is able to release
* the memory properly and safely.
*
* The return value of this routine is the same as from switch_core_db_exec().
* INSERT INTO table1 VALUES('It's a happy day!');
*
* This second example is an SQL syntax error. As a general rule you
- * should always use %q instead of %s when inserting text into a string
+ * should always use %q instead of %s when inserting text into a string
* literal.
*/
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
* switch_core_event_hook.h Core Event Hooks
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
* switch_core_media.c -- Core Media
char *rtpip;
char *rtpip4;
char *rtpip6;
-
+
char *remote_ip;
int remote_port;
return "video";
default:
return "!ERR";
-
+
}
}
SWITCH_DECLARE(void) switch_media_handle_set_media_flags(switch_media_handle_t *smh, switch_core_media_flag_t flags[]);
SWITCH_DECLARE(void) switch_core_session_check_outgoing_crypto(switch_core_session_t *session);
SWITCH_DECLARE(const char *) switch_core_session_local_crypto_key(switch_core_session_t *session, switch_media_type_t type);
-SWITCH_DECLARE(int) switch_core_session_check_incoming_crypto(switch_core_session_t *session,
+SWITCH_DECLARE(int) switch_core_session_check_incoming_crypto(switch_core_session_t *session,
const char *varname,
switch_media_type_t type, const char *crypto, int crypto_tag, switch_sdp_type_t sdp_type);
SWITCH_DECLARE(void) switch_core_media_check_video_codecs(switch_core_session_t *session);
SWITCH_DECLARE(switch_status_t) switch_core_media_read_frame(switch_core_session_t *session, switch_frame_t **frame,
switch_io_flag_t flags, int stream_id, switch_media_type_t type);
-SWITCH_DECLARE(switch_status_t) switch_core_media_write_frame(switch_core_session_t *session,
+SWITCH_DECLARE(switch_status_t) switch_core_media_write_frame(switch_core_session_t *session,
switch_frame_t *frame, switch_io_flag_t flags, int stream_id, switch_media_type_t type);
SWITCH_DECLARE(int) switch_core_media_check_nat(switch_media_handle_t *smh, const char *network_ip);
SWITCH_DECLARE(void) switch_core_media_deactivate_rtp(switch_core_session_t *session);
SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_session_t *session);
SWITCH_DECLARE(switch_status_t) switch_core_media_ext_address_lookup(switch_core_session_t *session, char **ip, switch_port_t *port, const char *sourceip);
-SWITCH_DECLARE(switch_status_t) switch_core_media_process_t38_passthru(switch_core_session_t *session,
+SWITCH_DECLARE(switch_status_t) switch_core_media_process_t38_passthru(switch_core_session_t *session,
switch_core_session_t *other_session, switch_t38_options_t *t38_options);
-SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *session, switch_sdp_type_t sdp_type,
+SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *session, switch_sdp_type_t sdp_type,
const char *ip, switch_port_t port, const char *sr, int force);
SWITCH_DECLARE(void)switch_core_media_set_local_sdp(switch_core_session_t *session, const char *sdp_str, switch_bool_t dup);
SWITCH_DECLARE(void) switch_core_media_patch_sdp(switch_core_session_t *session);
switch_payload_t *recv_ptP,
char **fmtpP);
-SWITCH_DECLARE(payload_map_t *) switch_core_media_add_payload_map(switch_core_session_t *session,
+SWITCH_DECLARE(payload_map_t *) switch_core_media_add_payload_map(switch_core_session_t *session,
switch_media_type_t type,
- const char *name,
- const char *modname,
+ const char *name,
+ const char *modname,
const char *fmtp,
switch_sdp_type_t sdp_type,
- uint32_t pt,
- uint32_t rate,
+ uint32_t pt,
+ uint32_t rate,
uint32_t ptime,
uint32_t channels,
uint8_t negotiated);
SWITCH_DECLARE(char *) switch_core_media_process_sdp_filter(const char *sdp, const char *cmd_buf, switch_core_session_t *session);
-SWITCH_DECLARE(switch_status_t) switch_core_media_codec_control(switch_core_session_t *session,
+SWITCH_DECLARE(switch_status_t) switch_core_media_codec_control(switch_core_session_t *session,
switch_media_type_t mtype,
switch_io_type_t iotype,
- switch_codec_control_command_t cmd,
+ switch_codec_control_command_t cmd,
switch_codec_control_type_t ctype,
void *cmd_data,
switch_codec_control_type_t atype,
switch_codec_control_type_t *rtype,
void **ret_data);
-SWITCH_DECLARE(switch_bool_t) switch_core_media_codec_get_cap(switch_core_session_t *session,
+SWITCH_DECLARE(switch_bool_t) switch_core_media_codec_get_cap(switch_core_session_t *session,
switch_media_type_t mtype,
switch_codec_flag_t flag);
SWITCH_DECLARE(void) switch_core_session_video_reinit(switch_core_session_t *session);
SWITCH_DECLARE(switch_status_t) switch_core_media_read_lock_unlock(switch_core_session_t *session, switch_media_type_t type, switch_bool_t lock);
-#define switch_core_media_read_lock(_s, _t) switch_core_media_read_lock_unlock(_s, _t, SWITCH_TRUE)
+#define switch_core_media_read_lock(_s, _t) switch_core_media_read_lock_unlock(_s, _t, SWITCH_TRUE)
#define switch_core_media_read_unlock(_s, _t) switch_core_media_read_lock_unlock(_s, _t, SWITCH_FALSE)
SWITCH_DECLARE(void) switch_core_session_stop_media(switch_core_session_t *session);
SWITCH_DECLARE(switch_status_t) switch_core_session_wait_for_video_input_params(switch_core_session_t *session, uint32_t timeout_ms);
-SWITCH_DECLARE(switch_status_t) switch_core_session_set_text_read_callback(switch_core_session_t *session,
+SWITCH_DECLARE(switch_status_t) switch_core_session_set_text_read_callback(switch_core_session_t *session,
switch_core_text_thread_callback_func_t func, void *user_data);
SWITCH_DECLARE(switch_status_t) switch_core_session_text_read_callback(switch_core_session_t *session, switch_frame_t *frame);
SWITCH_DECLARE(switch_status_t) switch_core_session_read_text_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags,
int stream_id);
SWITCH_DECLARE(switch_status_t) switch_rtp_text_factory_create(switch_rtp_text_factory_t **tfP, switch_memory_pool_t *pool);
-SWITCH_DECLARE(switch_status_t) switch_rtp_text_factory_destroy(switch_rtp_text_factory_t **tfP);
+SWITCH_DECLARE(switch_status_t) switch_rtp_text_factory_destroy(switch_rtp_text_factory_t **tfP);
SWITCH_DECLARE(switch_status_t) switch_core_session_print(switch_core_session_t *session, const char *data);
SWITCH_DECLARE(switch_status_t) switch_core_session_printf(switch_core_session_t *session, const char *fmt, ...);
SRM_180 = 180, // Rotate 180 degrees.
SRM_270 = 270, // Rotate 270 degrees clockwise.
} switch_image_rotation_mode_t;
-
+
/*!\brief Open a descriptor, allocating storage for the underlying image
*
SWITCH_DECLARE(uint32_t) switch_img_txt_handle_render(switch_img_txt_handle_t *handle, switch_image_t *img,
int x, int y, const char *text,
const char *font_family, const char *font_color, const char *bgcolor, uint16_t font_size, double angle);
-
+
SWITCH_DECLARE(void) switch_img_patch_hole(switch_image_t *IMG, switch_image_t *img, int x, int y, switch_image_rect_t *rect);
const char *confirm_key,
const char *tts_engine,
const char *tts_voice,
- int confirm_attempts, int inter_timeout, int digit_len,
+ int confirm_attempts, int inter_timeout, int digit_len,
int timeout, int max_failures, int max_timeouts);
virtual SWITCH_DECLARE_CONSTRUCTOR ~ IVRMenu();
SWITCH_DECLARE(void) bindAction(char *action, const char *arg, const char *bind);
void *threadState; // pointer to the language specific thread state
// eg, PyThreadState *threadState
void *extra; // currently used to store a switch_file_handle_t
- char *funcargs; // extra string that will be passed to callback function
+ char *funcargs; // extra string that will be passed to callback function
} input_callback_state_t;
typedef enum {
// instead set them here first
char *xml_cdr_text;
void store_file_handle(switch_file_handle_t *fh);
- void *on_hangup; // language specific callback function, cast as void *
+ void *on_hangup; // language specific callback function, cast as void *
switch_file_handle_t *fhp;
char dtmf_buf[512];
SWITCH_DECLARE(const char *) getState();
/** \brief Record to a file
- * \param file_name
+ * \param file_name
* \param <[max_len]> maximum length of the recording in seconds
- * \param <[silence_threshold]> energy level audio must fall below
+ * \param <[silence_threshold]> energy level audio must fall below
* to be considered silence (500 is a good starting point).
* \param <[silence_secs]> seconds of silence to interrupt the record.
*/
/** \brief Originate a call to a destination
*
- * \param a_leg_session - the session where the call is originating from
- * and also the session in which _this_ session was
+ * \param a_leg_session - the session where the call is originating from
+ * and also the session in which _this_ session was
* created
* \param dest - a string representing destination, eg, sofia/mydomain.com/foo\@bar.com
* \param timeout - time to wait for call to be answered
SWITCH_DECLARE(virtual void) destroy(void);
/** \brief set a DTMF callback function
- *
+ *
* The DTMF callback function will be set and persist
* for the life of the session, and be called when a dtmf
- * is pressed by user during streamfile(), collectDigits(), and
+ * is pressed by user during streamfile(), collectDigits(), and
* certain other methods are executing.
*
*/
SWITCH_DECLARE(int) collectDigits(int abs_timeout);
SWITCH_DECLARE(int) collectDigits(int digit_timeout, int abs_timeout);
- /**
+ /**
* Collect up to maxdigits digits worth of digits
- * and store them in dtmf_buf. In the case of mod_python, the
+ * and store them in dtmf_buf. In the case of mod_python, the
* dtmf_buf parameter is configured to act as a _return_ value,
* (see mod_python.i). This does NOT call any callbacks upon
* receiving dtmf digits. For that, use collectDigits.
SWITCH_DECLARE(int) transfer(char *extension, char *dialplan = NULL, char *context = NULL);
- SWITCH_DECLARE(char *) read(int min_digits, int max_digits,
+ SWITCH_DECLARE(char *) read(int min_digits, int max_digits,
const char *prompt_audio_file, int timeout, const char *valid_terminators, int digit_timeout = 0);
/** \brief Play a file into channel and collect dtmfs
- *
+ *
* See API docs in switch_ivr.h: switch_play_and_get_digits(..)
*
- * NOTE: this does not call any dtmf callbacks set by
+ * NOTE: this does not call any dtmf callbacks set by
* setDTMFCallback(..) as it uses its own internal callback
* handler.
*/
/** \brief Play a file that resides on disk into the channel
*
* \param file - the path to the .wav/.mp3 to be played
- * \param starting_sample_count - the index of the sample to
+ * \param starting_sample_count - the index of the sample to
* start playing from
* \return an int status code indicating success or failure
*
virtual bool begin_allow_threads() = 0;
virtual bool end_allow_threads() = 0;
- /** \brief Get the uuid of this session
+ /** \brief Get the uuid of this session
* \return the uuid of this session
*/
const char *get_uuid() const {
SWITCH_DECLARE(void) switch_msleep(unsigned ms);
/** \brief bridge the audio of session_b into session_a
- *
+ *
* NOTE: the stuff regarding the dtmf callback might be completely
* wrong and has not been reviewed or tested
*/
#define switch_curl_easy_setopt curl_easy_setopt
SWITCH_END_EXTERN_C
-
+
#endif
-/*
+/*
* Cross Platform dso/dll load abstraction
* Copyright(C) 2008 Michael Jerris
*
* code prove defective in any respect, you (not the initial developer or any other contributor)
* assume the cost of any necessary servicing, repair or correction. This disclaimer of warranty
* constitutes an essential part of this license. No use of any covered code is authorized hereunder
- * except under this disclaimer.
+ * except under this disclaimer.
*
*/
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2015, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Dragos Oancea <droancea@yahoo.com>
*
* switch_estimators.h -- Estimators for Packet Loss, Jitter, RTT , etc
#ifndef SWITCH_ESTIMATORS_H
#define SWITCH_ESTIMATORS_H
-
-
+
+
#include <switch.h>
struct kalman_estimator_s {
/* initial values for the Kalman filter */
- float val_estimate_last ;
- float P_last ;
+ float val_estimate_last ;
+ float P_last ;
/* the noise in the system:
- The amount of noise in your measurements and the state-transitions
- (e.g. the standard deviation of the signal noise, and how 'wrong' your simplified model
+ The amount of noise in your measurements and the state-transitions
+ (e.g. the standard deviation of the signal noise, and how 'wrong' your simplified model
of the state-transitions are) => These are Q and R matrices */
float Q ; /* the process noise covariance matrix */
float R ; /* the measurement noise covariance matrix */
float K; /* P_temp * H^T * (H* P_temp * H^T + R)^-1 */
float P; /* the Kalman gain (calculated) */
float val_estimate; /* x_temp_est + K * (z_measured - H * x_temp_est) */
- float val_measured; /* the 'noisy' value we measured */
-};
+ float val_measured; /* the 'noisy' value we measured */
+};
struct cusum_kalman_detector_s {
/* initial values for the CUSUM Kalman filter */
float val_estimate_last;
- float val_desired_last;
+ float val_desired_last;
float P_last;
float K_last;
- float delta;
+ float delta;
float measurement_noise_e;
float variance_Re;
float measurement_noise_v;
/* for calculating variance */
float last_average;
float last_q;
- float N; /*how many samples we have so far (eg: how many RTCP we received, granted that we can calculate RTT for each one of them)*/
+ float N; /*how many samples we have so far (eg: how many RTCP we received, granted that we can calculate RTT for each one of them)*/
};
typedef struct kalman_estimator_s kalman_estimator_t;
typedef struct cusum_kalman_detector_s cusum_kalman_detector_t;
SWITCH_DECLARE(void) switch_kalman_init(kalman_estimator_t *est, float Q, float R);
-SWITCH_DECLARE(switch_bool_t) switch_kalman_cusum_init(cusum_kalman_detector_t *detect_change, float epsilon,float h);
+SWITCH_DECLARE(switch_bool_t) switch_kalman_cusum_init(cusum_kalman_detector_t *detect_change, float epsilon,float h);
SWITCH_DECLARE(switch_bool_t) switch_kalman_estimate(kalman_estimator_t * est, float measurement, int system_model);
SWITCH_DECLARE (switch_bool_t) switch_kalman_cusum_detect_change(cusum_kalman_detector_t * detector, float measurement, float rtt_avg);
SWITCH_DECLARE(switch_bool_t) switch_kalman_is_slow_link(kalman_estimator_t * est_loss, kalman_estimator_t * est_rtt);
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
*/
/*! \file switch_event.h
\brief Event System
-
+
The event system uses a backend thread and an APR threadsafe FIFO queue to accept event objects from various threads
and allow the backend to take control and deliver the events to registered callbacks.
The typical usage would be to bind to one or all of the events and use a callback function to react in various ways
(see the more_xmpp_event_handler or mod_event_test modules for examples).
- Builtin events are fired by the core at various points in the execution of the application and custom events can be
+ Builtin events are fired by the core at various points in the execution of the application and custom events can be
reserved and registered so events from an external module can be rendered and handled by an another even handler module.
If the work time to process an event in a callback is anticipated to grow beyond a very small amount of time it is recommended
- that you implement your own handler thread and FIFO queue so you can accept the events in the callback and queue them
- into your own thread rather than tie up the delivery agent. It is in the opinion of the author that such a necessity
- should be judged on a per-use basis and therefore it does not fall within the scope of this system to provide that
+ that you implement your own handler thread and FIFO queue so you can accept the events in the callback and queue them
+ into your own thread rather than tie up the delivery agent. It is in the opinion of the author that such a necessity
+ should be judged on a per-use basis and therefore it does not fall within the scope of this system to provide that
functionality at a core level.
*/
/*!
\defgroup events Eventing Engine
\ingroup core1
- \{
+ \{
*/
#ifndef SWITCH_EVENT_H
SWITCH_DECLARE(switch_status_t) switch_event_free_subclass_detailed(const char *owner, const char *subclass_name);
/*!
- \brief Render a string representation of an event suitable for printing or network transport
+ \brief Render a string representation of an event suitable for printing or network transport
\param event the event to render
\param str a string pointer to point at the allocated data
\param encode url encode the headers
SWITCH_DECLARE(switch_status_t) switch_event_channel_broadcast(const char *event_channel, cJSON **json, const char *key, switch_event_channel_id_t id);
SWITCH_DECLARE(uint32_t) switch_event_channel_unbind(const char *event_channel, switch_event_channel_func_t func);
SWITCH_DECLARE(switch_status_t) switch_event_channel_bind(const char *event_channel, switch_event_channel_func_t func, switch_event_channel_id_t *id);
-
+
typedef void (*switch_live_array_command_handler_t)(switch_live_array_t *la, const char *cmd, const char *sessid, cJSON *jla, void *user_data);
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* switch_hashtable.h -- Hashtable
* v = (struct some_value *) malloc(sizeof(struct some_value));
*
* (initialise k and v to suitable values)
- *
+ *
* if (! hashtable_insert(h,k,v) )
* { exit(-1); }
*
/* Macros may be used to define type-safe(r) hashtable access functions, with
* methods specialized to take known key and value types as parameters.
- *
+ *
* Example:
*
* Insert this at the start of your file:
/*****************************************************************************
* create_hashtable
-
+
* @name create_hashtable
* @param minsize minimum initial size of hashtable
* @param hashfunction function for hashing keys
/*****************************************************************************
* hashtable_insert
-
+
* @name hashtable_insert
* @param h the hashtable to insert into
* @param k the key - hashtable claims ownership and will free on removal
/*****************************************************************************
* hashtable_search
-
+
* @name hashtable_search
* @param h the hashtable to search
* @param k the key to search for - does not claim ownership
/*****************************************************************************
* hashtable_remove
-
+
* @name hashtable_remove
* @param h the hashtable to remove the item from
* @param k the key to search for - does not claim ownership
/*****************************************************************************
* hashtable_count
-
+
* @name hashtable_count
* @param h the hashtable
* @return the number of items stored in the hashtable
/*****************************************************************************
* hashtable_destroy
-
+
* @name hashtable_destroy
* @param h the hashtable
* @param free_values whether to call 'free' on the remaining values
unsigned char *str = (unsigned char *) ky;
uint32_t hash = 0;
int c;
-
+
while ((c = *str)) {
str++;
hash = c + (hash << 6) + (hash << 16) - hash;
unsigned char *str = (unsigned char *) ky;
uint32_t hash = 0;
int c;
-
+
while ((c = switch_tolower(*str))) {
str++;
hash = c + (hash << 6) + (hash << 16) - hash;
/*
* Copyright (c) 2002, Christopher Clark
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
- *
+ *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Neal Horman <neal at wanlink dot com>
* Bret McDanel <trixter AT 0xdecafbad dot com>
* switch_ivr.h -- IVR Library
*
*/
-/**
+/**
* @file switch_ivr.h
* @brief IVR Library
* @see switch_ivr
/**
* @defgroup switch_ivr IVR Library
* @ingroup core1
- * A group of core functions to do IVR related functions designed to be
+ * A group of core functions to do IVR related functions designed to be
* building blocks for a higher level IVR interface.
* @{
*/
\param args arguements to pass for callbacks etc
\return SWITCH_STATUS_SUCCESS if all is well
*/
-SWITCH_DECLARE(switch_status_t) switch_ivr_play_and_detect_speech(switch_core_session_t *session,
- const char *file,
+SWITCH_DECLARE(switch_status_t) switch_ivr_play_and_detect_speech(switch_core_session_t *session,
+ const char *file,
const char *mod_name,
const char *grammar,
char **result,
\param originator_uuid the uuid of the originator
\param originatee_uuid the uuid of the originator
\remark Any custom state handlers on both channels will be deleted
- \return SWITCH_STATUS_SUCCESS if all is well
+ \return SWITCH_STATUS_SUCCESS if all is well
*/
SWITCH_DECLARE(switch_status_t) switch_ivr_uuid_bridge(const char *originator_uuid, const char *originatee_uuid);
SWITCH_DECLARE(void) switch_ivr_broadcast_in_thread(switch_core_session_t *session, const char *app, int flags);
/*!
- \brief Transfer variables from one session to another
+ \brief Transfer variables from one session to another
\param sessa the original session
\param sessb the new session
\param var the name of the variable to transfer (NULL for all)
- \return SWITCH_STATUS_SUCCESS if all is well
+ \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);
\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
+ \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);
/*!
\brief Destroy a digit stream parser object
\param parser a pointer to the parser object
- \return SWITCH_STATUS_SUCCESS if all is well
+ \return SWITCH_STATUS_SUCCESS if all is well
*/
SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_destroy(switch_ivr_digit_stream_parser_t *parser);
\param parser a pointer to the parser object created by switch_ivr_digit_stream_parser_new
\param digits a string of digits to associate with an action
\param data consumer data attached to this digit string
- \return SWITCH_STATUS_SUCCESS if all is well
+ \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);
\brief Delete a string to action mapping
\param parser a pointer to the parser object created by switch_ivr_digit_stream_parser_new
\param digits the digit string to be removed from the map
- \return SWITCH_STATUS_SUCCESS if all is well
+ \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);
/*!
\brief Reset the collected digit stream to nothing
\param stream a pointer to the parser stream object created by switch_ivr_digit_stream_new
- \return SWITCH_STATUS_SUCCESS if all is well
+ \return SWITCH_STATUS_SUCCESS if all is well
*/
SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_reset(switch_ivr_digit_stream_t *stream);
\brief Set a digit string terminator
\param parser a pointer to the parser object created by switch_ivr_digit_stream_parser_new
\param digit the terminator digit
- \return SWITCH_STATUS_SUCCESS if all is well
+ \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);
* @defgroup switch_ivr_menu IVR Menu Library
* @ingroup switch_ivr
* IVR menu functions
- *
+ *
* @{
*/
uint32_t max_digits,
const char *prompt_audio_file,
const char *var_name,
- char *digit_buffer,
- switch_size_t digit_buffer_length,
- uint32_t timeout,
+ char *digit_buffer,
+ switch_size_t digit_buffer_length,
+ uint32_t timeout,
const char *valid_terminators,
uint32_t digit_timeout);
SWITCH_DECLARE(const char *) switch_ivr_dmachine_get_name(switch_ivr_dmachine_t *dmachine);
SWITCH_DECLARE(void) switch_ivr_dmachine_set_match_callback(switch_ivr_dmachine_t *dmachine, switch_ivr_dmachine_callback_t match_callback);
SWITCH_DECLARE(void) switch_ivr_dmachine_set_nonmatch_callback(switch_ivr_dmachine_t *dmachine, switch_ivr_dmachine_callback_t nonmatch_callback);
-SWITCH_DECLARE(switch_status_t) switch_ivr_dmachine_create(switch_ivr_dmachine_t **dmachine_p,
+SWITCH_DECLARE(switch_status_t) switch_ivr_dmachine_create(switch_ivr_dmachine_t **dmachine_p,
const char *name,
switch_memory_pool_t *pool,
uint32_t digit_timeout, uint32_t input_timeout,
SWITCH_DECLARE(void) switch_ivr_dmachine_destroy(switch_ivr_dmachine_t **dmachine);
-SWITCH_DECLARE(switch_status_t) switch_ivr_dmachine_bind(switch_ivr_dmachine_t *dmachine,
+SWITCH_DECLARE(switch_status_t) switch_ivr_dmachine_bind(switch_ivr_dmachine_t *dmachine,
const char *realm,
- const char *digits,
- switch_byte_t is_priority,
+ const char *digits,
+ switch_byte_t is_priority,
int32_t key,
switch_ivr_dmachine_callback_t callback,
void *user_data);
SWITCH_DECLARE(switch_status_t) switch_ivr_stop_video_write_overlay_session(switch_core_session_t *session);
-SWITCH_DECLARE(switch_status_t) switch_ivr_video_write_overlay_session(switch_core_session_t *session, const char *img_path,
+SWITCH_DECLARE(switch_status_t) switch_ivr_video_write_overlay_session(switch_core_session_t *session, const char *img_path,
switch_img_position_t pos, uint8_t alpha);
SWITCH_DECLARE(switch_status_t) switch_ivr_capture_text(switch_core_session_t *session, switch_bool_t on);
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
* switch_jitterbuffer.h -- Audio/Video Jitter Buffer
/*
Copyright (c) 2009 Dave Gamble
-
+
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
-
+
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
-
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#define cJSON_String 4
#define cJSON_Array 5
#define cJSON_Object 6
-
+
#define cJSON_IsReference 256
/* The cJSON structure: */
/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
SWITCH_DECLARE(const char *)cJSON_GetErrorPtr(void);
-
+
/* These calls create a cJSON item of the appropriate type. */
SWITCH_DECLARE(cJSON *)cJSON_CreateNull(void);
SWITCH_DECLARE(cJSON *)cJSON_CreateTrue(void);
SWITCH_DECLARE(void) cJSON_DeleteItemFromArray(cJSON *array,int which);
SWITCH_DECLARE(cJSON *)cJSON_DetachItemFromObject(cJSON *object,const char *string);
SWITCH_DECLARE(void) cJSON_DeleteItemFromObject(cJSON *object,const char *string);
-
+
/* Update array items. */
SWITCH_DECLARE(void) cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem);
SWITCH_DECLARE(void) cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Rupa Schomaker <rupa@rupa.com>
*
* switch_limit.h - Limit generic implementations
*
*/
-
+
/*!
\defgroup limit1 LIMIT code
\ingroup core1
SWITCH_BEGIN_EXTERN_C
-/*!
+/*!
\brief Initilize the LIMIT Core System
\param pool the memory pool to use for long term allocations
\note Generally called by the core_init
SWITCH_DECLARE(void) switch_limit_init(switch_memory_pool_t *pool);
/*!
- \brief Increment resource.
+ \brief Increment resource.
\param backend to use
\param realm
\param resource
SWITCH_DECLARE(switch_status_t) switch_limit_incr(const char *backend, switch_core_session_t *session, const char *realm, const char *resource, const int max, const int interval);
/*!
- \brief Release resource.
+ \brief Release resource.
\param backend to use
\param realm
\param resource
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
\brief Loadable Module Routines
This module is the gateway between external modules and the core of the application.
- it contains all the access points to the various pluggable interfaces including the codecs
+ it contains all the access points to the various pluggable interfaces including the codecs
and API modules.
*/
/*!
\defgroup mods Loadable Module Functions
\ingroup core1
- \{
+ \{
*/
/*! \brief The abstraction of a loadable module */
struct switch_loadable_module_interface {
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
typedef switch_status_t (*switch_log_function_t) (const switch_log_node_t *node, switch_log_level_t level);
-/*!
+/*!
\brief Initilize the logging engine
\param pool the memory pool to use
\note to be called at application startup by the core
*/
SWITCH_DECLARE(switch_status_t) switch_log_init(_In_ switch_memory_pool_t *pool, _In_ switch_bool_t colorize);
-/*!
+/*!
\brief Shut down the logging engine
\note to be called at application termination by the core
*/
SWITCH_DECLARE(switch_status_t) switch_log_shutdown(void);
#ifndef SWIG
-/*!
+/*!
\brief Write log data to the logging engine
\param channel the log channel to write to
\param file the current file
_In_z_ const char *func, _In_ int line,
_In_opt_z_ const char *userdata, _In_ switch_log_level_t level,
_In_z_ _Printf_format_string_ const char *fmt, ...) PRINTF_FUNCTION(7, 8);
-/*!
+/*!
\brief Write log data to the logging engine
\param channel the log channel to write to
\param file the current file
_In_opt_z_ const char *userdata, _In_ switch_log_level_t level, const char *fmt, va_list ap);
#endif
-/*!
+/*!
\brief Shut down the logging engine
\note to be called at application termination by the core
*/
SWITCH_DECLARE(switch_status_t) switch_log_bind_logger(_In_ switch_log_function_t function, _In_ switch_log_level_t level, _In_ switch_bool_t is_console);
SWITCH_DECLARE(switch_status_t) switch_log_unbind_logger(_In_ switch_log_function_t function);
-/*!
+/*!
\brief Return the name of the specified log level
\param level the level
\return the name of the log level
*/
_Ret_z_ SWITCH_DECLARE(const char *) switch_log_level2str(_In_ switch_log_level_t level);
-/*!
+/*!
\brief Return the level number of the specified log level name
\param str the name of the level
\return the log level
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Luke Dashjr <luke@openmethods.com> (OpenMethods, LLC)
*
/*! \file switch_module_interfaces.h
\brief Module Interface Definitions
- This module holds the definition of data abstractions used to implement various pluggable
+ This module holds the definition of data abstractions used to implement various pluggable
interfaces and pluggable event handlers.
*/
#include "switch_resample.h"
SWITCH_BEGIN_EXTERN_C
-/*! \brief A table of functions to execute at various states
+/*! \brief A table of functions to execute at various states
*/
typedef enum {
SWITCH_SHN_ON_INIT,
struct switch_io_event_hooks;
struct switch_say_file_handle;
-typedef switch_call_cause_t (*switch_io_outgoing_channel_t)
+typedef switch_call_cause_t (*switch_io_outgoing_channel_t)
(switch_core_session_t *, switch_event_t *, switch_caller_profile_t *, switch_core_session_t **, switch_memory_pool_t **, switch_originate_flag_t,
switch_call_cause_t *);
typedef switch_status_t (*switch_io_read_frame_t) (switch_core_session_t *, switch_frame_t **, switch_io_flag_t, int);
const char *interface_name;
/*! function to open the directory interface */
switch_status_t (*chat_send) (switch_event_t *message_event);
-
+
switch_thread_rwlock_t *rwlock;
int refs;
switch_mutex_t *reflock;
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Brian K. West <brian@freeswitch.org>
*
SWITCH_DECLARE(const char *) switch_nat_get_type(void);
-/*!
+/*!
\brief Initilize the NAT Traversal System
\param pool the memory pool to use for long term allocations
\note Generally called by the core_init
*/
SWITCH_DECLARE(void) switch_nat_init(switch_memory_pool_t *pool, switch_bool_t mapping);
-/*!
+/*!
\brief Initilize the rest of the NAT Traversal System
- \note nat_init is called prior to some other modules being loaded.
+ \note nat_init is called prior to some other modules being loaded.
This method allows us to init the rest of the NAT system.
*/
SWITCH_DECLARE(void) switch_nat_late_init(void);
\brief Maps a port through the NAT Traversal System
\param port Internal port to map
\param proto Protocol
- \param external_port [out] Mapped external port
+ \param external_port [out] Mapped external port
\param sticky make the mapping permanent
*/
SWITCH_DECLARE(switch_status_t) switch_nat_add_mapping(switch_port_t port, switch_nat_ip_proto_t proto, switch_port_t *external_port,
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
* switch_odbc.h -- ODBC
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Eliot Gable <egable@gmail.com>
*
#define DEFAULT_PGSQL_RETRIES 120
-SWITCH_BEGIN_EXTERN_C
+SWITCH_BEGIN_EXTERN_C
struct switch_pgsql_handle;
struct switch_pgsql_result;
/*!
\brief Create a new handle for the PGSQL connection.
- \param dsn The DSN of the database to connect to. See documentation for PQconnectdb() at
+ \param dsn The DSN of the database to connect to. See documentation for PQconnectdb() at
http://www.postgresql.org/docs/9.0/static/libpq-connect.html. The DSN *MUST* be
prefixed with 'pgsql;' to use the switch_cache_db* functionality. However, the DSN
passed to this function directly *MUST NOT* be prefixed with 'pgsql;'.
) /* Emacs formatting issue */
#endif
/*!
- \brief Connect to the database specified by the DSN passed to the switch_pgsql_handle_new() call which
+ \brief Connect to the database specified by the DSN passed to the switch_pgsql_handle_new() call which
initialized this handle.
\param The database handle to connect to the database.
\return Returns SWITCH_PGSQL_SUCCESS or SWITCH_PGSQL_FAIL.
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
* switch_platform.h -- Platform Specific Header
#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.
+/* 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
- * C4204: nonstandard extension used : non-constant aggregate initializer
+ * C4204: nonstandard extension used : non-constant aggregate initializer
* C4706: assignment within conditional expression
* C4819: The file contains a character that cannot be represented in the current code page
* C4132: 'object' : const object should be initialized (fires innapropriately for prototyped forward declaration of cost var)
#define NOIME
#endif
#include <windows.h>
-/*
+/*
* Add a _very_few_ declarations missing from the restricted set of headers
* (If this list becomes extensive, re-enable the required headers above!)
* winsock headers were excluded by WIN32_LEAN_AND_MEAN, so include them now
* Copyright (c) 2009, Sangoma Technologies
* Moises Silva <moy@sangoma.com>
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
- *
+ *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
struct profile_timer;
typedef struct profile_timer switch_profile_timer_t;
-/*!
+/*!
* \brief create a new profile timer
* \return profile timer structure previously created with new_profile_timer, NULL on error
*/
SWITCH_DECLARE(switch_profile_timer_t *) switch_new_profile_timer(void);
-/*!
+/*!
* \brief provides the percentage of idle system time
* \param p profile timer structure previously created with new_profile_timer
* \param pointer to store the percentage of idle time
SWITCH_DECLARE(switch_bool_t) switch_get_system_idle_time(switch_profile_timer_t *p, double *idle_percentage);
-/*!
+/*!
* \brief Deletes profile timer
*/
SWITCH_DECLARE(void) switch_delete_profile_timer(switch_profile_timer_t **p);
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Michael Jerris <mike@jerris.com>
*
* switch_regex.h -- pcre wrapper and extensions Header
*/
SWITCH_DECLARE(switch_status_t) switch_regex_match_partial(const char *target, const char *expression, int *partial_match);
-SWITCH_DECLARE(void) switch_capture_regex(switch_regex_t *re, int match_count, const char *field_data,
+SWITCH_DECLARE(void) switch_capture_regex(switch_regex_t *re, int match_count, const char *field_data,
int *ovector, const char *var, switch_cap_callback_t callback, void *user_data);
SWITCH_DECLARE_NONSTD(void) switch_regex_set_var_callback(const char *var, const char *val, void *user_data);
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
This module implements a generic interface for doing audio resampling it currently uses libresample but can be ported to
any resample library with a little effort. I decided against making this interface pluggable because there are not many
- options in terms of resample libraries so it seemed like a waste but I did opt to frontend the interface in case a better
+ options in terms of resample libraries so it seemed like a waste but I did opt to frontend the interface in case a better
way comes along some day. =D
-
+
*/
#define switch_normalize_volume(x) if (x > 4) x = 4; if (x < -4) x = -4;
#define switch_normalize_volume_granular(x) if (x > 13) x = 13; if (x < -13) x = -13;
/*!
\defgroup resamp Audio Resample Functions
\ingroup core1
- \{
+ \{
*/
/*! \brief An audio resampling handle */
typedef struct {
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
* Marcel Barbulescu <marcelbarbulescu@gmail.com>
*
*/
-/**
+/**
* @file switch_rtp.h
* @brief RTP
- *
+ *
*/
#ifndef SWITCH_RTP_H
_RTCP_PSFB_TSTR = 5, /* TSTR: Temporal-Spatial Trade-off Request RFC5104 */
_RTCP_PSFB_TSTN = 6, /* TSTN: Temporal-Spatial Trade-off Notification RFC5104 */
_RTCP_PSFB_VBCM = 7, /* VBCM: Video Back Channel Message RFC5104 */
- _RTCP_PSFB_PSLEI = 8, /* PSLEI: Payload-Specific Third-Party Loss Early Indication RFC6642*/
+ _RTCP_PSFB_PSLEI = 8, /* PSLEI: Payload-Specific Third-Party Loss Early Indication RFC6642*/
_RTCP_PSFB_AFB = 15 /* AFB Application layer FB */
} rtcp_psfb_t;
SWITCH_DECLARE(void) switch_rtp_get_random(void *buf, uint32_t len);
-/*!
+/*!
\brief Initilize the RTP System
\param pool the memory pool to use for long term allocations
\note Generally called by the core_init
*/
SWITCH_DECLARE(switch_port_t) switch_rtp_set_end_port(switch_port_t port);
-/*!
+/*!
\brief Request a new port to be used for media
\param ip the ip to request a port from
\return the new port to use
SWITCH_DECLARE(switch_status_t) switch_rtp_set_interval(switch_rtp_t *rtp_session, uint32_t ms_per_packet, uint32_t samples_per_interval);
SWITCH_DECLARE(switch_status_t) switch_rtp_change_interval(switch_rtp_t *rtp_session, uint32_t ms_per_packet, uint32_t samples_per_interval);
-/*!
+/*!
\brief create a new RTP session handle
\param new_rtp_session a poiter to aim at the new session
\param payload the IANA payload number
switch_rtp_flag_t flags[], char *timer_name, const char **err, switch_memory_pool_t *pool);
-/*!
+/*!
\brief Assign a remote address to the RTP session
\param rtp_session an RTP session to assign the remote address to
\param host the ip or fqhn of the remote address
SWITCH_DECLARE(switch_status_t) switch_rtp_udptl_mode(switch_rtp_t *rtp_session);
SWITCH_DECLARE(void) switch_rtp_reset(switch_rtp_t *rtp_session);
-/*!
+/*!
\brief Assign a local address to the RTP session
\param rtp_session an RTP session to assign the local address to
\param host the ip or fqhn of the local address
*/
SWITCH_DECLARE(switch_status_t) switch_rtp_set_local_address(switch_rtp_t *rtp_session, const char *host, switch_port_t port, const char **err);
-/*!
+/*!
\brief Kill the socket on an existing RTP session
\param rtp_session an RTP session to kill the socket of
*/
SWITCH_DECLARE(void) switch_rtp_break(switch_rtp_t *rtp_session);
SWITCH_DECLARE(void) switch_rtp_flush(switch_rtp_t *rtp_session);
-/*!
+/*!
\brief Test if an RTP session is ready
\param rtp_session an RTP session to test
\return a true value if it's ready
*/
SWITCH_DECLARE(uint8_t) switch_rtp_ready(switch_rtp_t *rtp_session);
-/*!
+/*!
\brief Destroy an RTP session
\param rtp_session an RTP session to destroy
*/
SWITCH_DECLARE(switch_status_t) switch_rtp_sync_stats(switch_rtp_t *rtp_session);
-/*!
+/*!
\brief Acvite ICE on an RTP session
\return SWITCH_STATUS_SUCCESS
*/
-SWITCH_DECLARE(switch_status_t) switch_rtp_activate_ice(switch_rtp_t *rtp_session, char *login, char *rlogin,
+SWITCH_DECLARE(switch_status_t) switch_rtp_activate_ice(switch_rtp_t *rtp_session, char *login, char *rlogin,
const char *password, const char *rpassword, ice_proto_t proto,
switch_core_media_ice_type_t type, ice_t *ice_params);
-/*!
+/*!
\brief Activate sending RTCP Sender Reports (SR's)
\param send_rate interval in milliseconds to send at
\return SWITCH_STATUS_SUCCESS
SWITCH_DECLARE(switch_status_t) switch_rtp_set_video_buffer_size(switch_rtp_t *rtp_session, uint32_t frames, uint32_t max_frames);
SWITCH_DECLARE(switch_status_t) switch_rtp_get_video_buffer_size(switch_rtp_t *rtp_session, uint32_t *min_frame_len, uint32_t *max_frame_len, uint32_t *cur_frame_len, uint32_t *highest_frame_len);
-/*!
+/*!
\brief Acvite a jitter buffer on an RTP session
\param rtp_session the rtp session
\param queue_frames the number of frames to delay
\return SWITCH_STATUS_SUCCESS
*/
-SWITCH_DECLARE(switch_status_t) switch_rtp_activate_jitter_buffer(switch_rtp_t *rtp_session,
+SWITCH_DECLARE(switch_status_t) switch_rtp_activate_jitter_buffer(switch_rtp_t *rtp_session,
uint32_t queue_frames,
uint32_t max_queue_frames,
uint32_t samples_per_packet, uint32_t samples_per_second);
*/
SWITCH_DECLARE(void) switch_rtp_clear_flag(switch_rtp_t *rtp_session, switch_rtp_flag_t flag);
-/*!
+/*!
\brief Retrieve the socket from an existing RTP session
\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(void) switch_rtp_ping(switch_rtp_t *rtp_session);
-/*!
+/*!
\brief Get the default samples per interval for a given RTP session
\param rtp_session the RTP session to get the samples per interval from
\return the default samples per interval of the RTP session
*/
SWITCH_DECLARE(uint32_t) switch_rtp_get_default_samples_per_interval(switch_rtp_t *rtp_session);
-/*!
+/*!
\brief Set the default payload number for a given RTP session
\param rtp_session the RTP session to set the payload number on
- \param payload the new default payload number
+ \param payload the new default payload number
*/
SWITCH_DECLARE(void) switch_rtp_set_default_payload(switch_rtp_t *rtp_session, switch_payload_t payload);
-/*!
+/*!
\brief Get the default payload number for a given RTP session
\param rtp_session the RTP session to get the payload number from
\return the default payload of the RTP session
SWITCH_DECLARE(uint32_t) switch_rtp_get_default_payload(switch_rtp_t *rtp_session);
-/*!
+/*!
\brief Set a callback function to execute when an invalid RTP packet is encountered
\param rtp_session the RTP session
\param on_invalid the function to set
- \return
+ \return
*/
SWITCH_DECLARE(void) switch_rtp_set_invalid_handler(switch_rtp_t *rtp_session, switch_rtp_invalid_handler_t on_invalid);
-/*!
+/*!
\brief Read data from a given RTP session
\param rtp_session the RTP session to read from
\param data the data to 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_io_flag_t io_flags);
-/*!
+/*!
\brief Queue RFC2833 DTMF data into an RTP Session
\param rtp_session the rtp session to use
\param dtmf the dtmf digits to queue
*/
SWITCH_DECLARE(switch_status_t) switch_rtp_queue_rfc2833(switch_rtp_t *rtp_session, const switch_dtmf_t *dtmf);
-/*!
+/*!
\brief Queue RFC2833 DTMF data into an RTP Session
\param rtp_session the rtp session to use
\param dtmf the dtmf digits to queue
*/
SWITCH_DECLARE(switch_size_t) switch_rtp_dequeue_dtmf(switch_rtp_t *rtp_session, switch_dtmf_t *dtmf);
-/*!
+/*!
\brief Read data from a given RTP session without copying
\param rtp_session the RTP session to read from
\param data a pointer to point directly to the RTP read buffer
void **data, uint32_t *datalen, switch_payload_t *payload_type, switch_frame_flag_t *flags,
switch_io_flag_t io_flags);
-/*!
+/*!
\brief Read data from a given RTP session without copying
\param rtp_session the RTP session to read from
\param frame a frame to populate with information
SWITCH_DECLARE(switch_status_t) switch_rtp_zerocopy_read_frame(switch_rtp_t *rtp_session, switch_frame_t *frame, switch_io_flag_t io_flags);
-/*!
+/*!
\brief Read RTCP data from a given RTP session without copying
\param rtp_session the RTP session to read from
\param frame an RTCP frame to populate with information
*/
SWITCH_DECLARE(switch_status_t) switch_rtp_disable_vad(switch_rtp_t *rtp_session);
-/*!
+/*!
\brief Write data to a given RTP session
\param rtp_session the RTP session to write to
\param frame the frame to write
*/
SWITCH_DECLARE(int) switch_rtp_write_frame(switch_rtp_t *rtp_session, switch_frame_t *frame);
-/*!
+/*!
\brief Write data with a specified payload and sequence number to a given RTP session
\param rtp_session the RTP session to write to
\param data data to write
SWITCH_DECLARE(switch_status_t) switch_rtp_write_raw(switch_rtp_t *rtp_session, void *data, switch_size_t *bytes, switch_bool_t process_encryption);
-/*!
+/*!
\brief Retrieve the SSRC from a given RTP session
\param rtp_session the RTP session to retrieve from
\return the SSRC
*/
SWITCH_DECLARE(uint32_t) switch_rtp_get_ssrc(switch_rtp_t *rtp_session);
-/*!
+/*!
\brief Associate an arbitrary data pointer with and RTP session
\param rtp_session the RTP session to assign the pointer to
\param private_data the private data to assign
*/
SWITCH_DECLARE(void) switch_rtp_set_private(switch_rtp_t *rtp_session, void *private_data);
-/*!
+/*!
\brief Set the payload type to consider RFC2833 DTMF
\param rtp_session the RTP session to modify
\param te the payload type
SWITCH_DECLARE(void) switch_rtp_set_telephony_event(switch_rtp_t *rtp_session, switch_payload_t te);
SWITCH_DECLARE(void) switch_rtp_set_telephony_recv_event(switch_rtp_t *rtp_session, switch_payload_t te);
-/*!
+/*!
\brief Set the payload type for comfort noise
\param rtp_session the RTP session to modify
\param pt the payload type
*/
SWITCH_DECLARE(void) switch_rtp_set_cng_pt(switch_rtp_t *rtp_session, switch_payload_t pt);
-/*!
+/*!
\brief Retrieve the private data from a given RTP session
\param rtp_session the RTP session to retrieve the data from
\return the pointer to the private data
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
\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
+ \param flags flags to alter behaviour
\return the id of the task
*/
SWITCH_DECLARE(uint32_t) switch_scheduler_add_task(time_t task_runtime,
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
SWITCH_STUN_ATTR_SOURCE_ADDRESS2 = 0x0012, /* Address */
SWITCH_STUN_ATTR_DATA = 0x0013, /* ByteString */
SWITCH_STUN_ATTR_OPTIONS = 0x8001, /* UInt32 */
- SWITCH_STUN_ATTR_XOR_MAPPED_ADDRESS = 0x0020, /* Address */
+ SWITCH_STUN_ATTR_XOR_MAPPED_ADDRESS = 0x0020, /* Address */
/* ice crap */
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2015, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Bret McDanel <trixter AT 0xdecafbad dot com>
* Joseph Sullivan <jossulli@amazon.com>
switch_size_t flush_packet_count;
switch_size_t largest_jb_size;
/* Jitter */
- int64_t last_proc_time;
+ int64_t last_proc_time;
int64_t jitter_n;
int64_t jitter_add;
int64_t jitter_addsq;
double mean_interval;
int loss[LOST_BURST_CAPTURE];
int last_loss;
- int recved;
+ int recved;
int last_processed_seq;
switch_size_t flaws;
switch_size_t last_flaw;
uint16_t cycle; /* Packet loss calculation, sequence number cycle of the current RTCP report interval */
uint32_t bad_seq; /* Bad SEQ found, used to detect reset on the other side */
uint16_t base_seq; /* Packet loss calculation, first sequence number received */
- uint32_t cum_lost; /* Packet loss calculation, cumulative number of packet lost */
+ uint32_t cum_lost; /* Packet loss calculation, cumulative number of packet lost */
uint32_t last_recv_lsr_local; /* RTT calculation, When receiving an SR we save our local timestamp in fraction of 65536 seconds */
uint32_t last_recv_lsr_peer; /* RTT calculation, When receiving an SR we extract the middle 32bits of the remote NTP timestamp to include it in the next SR LSR */
uint32_t init;
SWITCH_RTP_FLAG_DATAWAIT - Do not return from reads unless there is data even when non blocking
SWITCH_RTP_FLAG_BUGGY_2833 - Emulate the bug in cisco equipment to allow interop
SWITCH_RTP_FLAG_PASS_RFC2833 - Pass 2833 (ignore it)
- SWITCH_RTP_FLAG_AUTO_CNG - Generate outbound CNG frames when idle
+ SWITCH_RTP_FLAG_AUTO_CNG - Generate outbound CNG frames when idle
</pre>
*/
typedef enum {
final_duration - initial_timestamp = total_samples
However, if the duration value exceeds the space allocated (16 bits), The sender should increment
- the timestamp one unit and reset the duration to 0.
+ the timestamp one unit and reset the duration to 0.
Always sending a duration of 0 with a new timestamp should be tolerated but is rarely intentional
- and is mistakenly done by many devices.
+ and is mistakenly done by many devices.
The issue is that the Sonus expects everyone to do it this way instead of tolerating either way.
Sonus will actually ignore every packet with the same timestamp before concluding if it's DTMF.
*/
-
+
RTP_BUG_SEND_LINEAR_TIMESTAMPS = (1 << 3),
/*
Our friends at Sonus get real mad when the timestamps are not in perfect sequence even during periods of silence.
With this flag, we will only increment the timestamp when write packets even if they are eons apart.
-
+
*/
RTP_BUG_START_SEQ_AT_ZERO = (1 << 4),
/*
- Our friends at Sonus also get real mad if the sequence number does not start at 0.
+ Our friends at Sonus also get real mad if the sequence number does not start at 0.
Typically, we set this to a random starting value for your saftey.
This is a security risk you take upon yourself when you enable this flag.
*/
Our friends at Sonus are on a roll, They also get easily dumbfounded by marker bits.
This flag will never send any. Sheesh....
*/
-
+
RTP_BUG_IGNORE_DTMF_DURATION = (1 << 6),
-
+
/*
Guess Who? ... Yep, Sonus (and who know's who else) likes to interweave DTMF with the audio stream making it take
2X as long as it should and sending an incorrect duration making the DTMF very delayed.
*/
RTP_BUG_FLUSH_JB_ON_DTMF = (1 << 10),
-
+
/* FLUSH JITTERBUFFER When getting RFC2833 to reduce bleed through */
RTP_BUG_ACCEPT_ANY_PAYLOAD = (1 << 11),
- /*
+ /*
Make FS accept any payload type instead of dropping and returning CNG frame. Workaround while FS only supports a single payload per rtp session.
This can be used by endpoint modules to detect payload changes and act appropriately (ex: sofia could send a reINVITE with single codec).
This should probably be a flag, but flag enum is already full!
SWITCH_MESSAGE_REDIRECT_AUDIO - Indication to redirect audio to another location if possible
SWITCH_MESSAGE_TRANSMIT_TEXT - A text message
SWITCH_MESSAGE_INDICATE_ANSWER - indicate answer
- SWITCH_MESSAGE_INDICATE_PROGRESS - indicate progress
+ SWITCH_MESSAGE_INDICATE_PROGRESS - indicate progress
SWITCH_MESSAGE_INDICATE_BRIDGE - indicate a bridge starting
SWITCH_MESSAGE_INDICATE_UNBRIDGE - indicate a bridge ending
SWITCH_MESSAGE_INDICATE_TRANSFER - indicate a transfer is taking place
<pre>
CF_ANSWERED - Channel is answered
CF_OUTBOUND - Channel is an outbound channel
-CF_EARLY_MEDIA - Channel is ready for audio before answer
+CF_EARLY_MEDIA - Channel is ready for audio before answer
CF_ORIGINATOR - Channel is an originator
CF_TRANSFER - Channel is being transfered
CF_ACCEPT_CNG - Channel will accept CNG frames
SWITCH_SPEECH_FLAG_HASTEXT = (1 << 0) - Interface is has text to read.
SWITCH_SPEECH_FLAG_PEEK = (1 << 1) - Read data but do not erase it.
SWITCH_SPEECH_FLAG_FREE_POOL = (1 << 2) - Free interface's pool on destruction.
-SWITCH_SPEECH_FLAG_BLOCKING = (1 << 3) - Indicate that a blocking call is desired
+SWITCH_SPEECH_FLAG_BLOCKING = (1 << 3) - Indicate that a blocking call is desired
SWITCH_SPEECH_FLAG_PAUSE = (1 << 4) - Pause toggle for playback
</pre>
*/
SMBF_ANSWER_REQ - Don't record until the channel is answered
SMBF_BRIDGE_REQ - Don't record until the channel is bridged
SMBF_THREAD_LOCK - Only let the same thread who created the bug remove it.
-SMBF_PRUNE -
-SMBF_NO_PAUSE -
+SMBF_PRUNE -
+SMBF_NO_PAUSE -
SMBF_STEREO_SWAP - Record in stereo: Write Stream - left channel, Read Stream - right channel
</pre>
*/
SWITCH_EVENT_BACKGROUND_JOB - Background Job
SWITCH_EVENT_DETECTED_SPEECH - Detected Speech
SWITCH_EVENT_DETECTED_TONE - Detected Tone
- SWITCH_EVENT_PRIVATE_COMMAND - A private command event
+ SWITCH_EVENT_PRIVATE_COMMAND - A private command event
SWITCH_EVENT_HEARTBEAT - Machine is alive
SWITCH_EVENT_TRAP - Error Trap
SWITCH_EVENT_ADD_SCHEDULE - Something has been scheduled
SWITCH_IO_WRITE
} switch_io_type_t;
-typedef switch_status_t (*switch_core_codec_control_func_t) (switch_codec_t *codec,
- switch_codec_control_command_t cmd,
+typedef switch_status_t (*switch_core_codec_control_func_t) (switch_codec_t *codec,
+ switch_codec_control_command_t cmd,
switch_codec_control_type_t ctype,
void *cmd_data,
switch_codec_control_type_t atype,
void *cmd_arg,
switch_codec_control_type_t *rtype,
void **ret_data);
-
+
typedef switch_status_t (*switch_core_codec_init_func_t) (switch_codec_t *, switch_codec_flag_t, const switch_codec_settings_t *codec_settings);
typedef switch_status_t (*switch_core_codec_fmtp_parse_func_t) (const char *fmtp, switch_codec_fmtp_t *codec_fmtp);
typedef switch_status_t (*switch_say_string_callback_t) (switch_core_session_t *session,
char *tosay,
switch_say_args_t *say_args, char **rstr);
-
+
struct switch_say_file_handle;
typedef struct switch_say_file_handle switch_say_file_handle_t;
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Seven Du <dujinfang@gmail.com>
*
#include <switch.h>
#include <math.h>
-SWITCH_BEGIN_EXTERN_C
+SWITCH_BEGIN_EXTERN_C
#define SWITCH_URL_UNSAFE "\r\n #%&+:;<=>?@[\\]^`{|}\""
uint32_t x;
if (!num) return 0;
-
+
r = (num % step);
x = num - r;
-
+
if (r > step / 2) {
x += step;
}
-
+
return x;
}
-/* https://code.google.com/p/stringencoders/wiki/PerformanceAscii
+/* https://code.google.com/p/stringencoders/wiki/PerformanceAscii
http://www.azillionmonkeys.com/qed/asmexample.html
*/
static inline uint32_t switch_toupper(uint32_t eax)
return eax - ebx;
}
-/* https://code.google.com/p/stringencoders/wiki/PerformanceAscii
+/* https://code.google.com/p/stringencoders/wiki/PerformanceAscii
http://www.azillionmonkeys.com/qed/asmexample.html
*/
static inline uint32_t switch_tolower(uint32_t eax)
#ifdef FS_64BIT
-/* https://code.google.com/p/stringencoders/wiki/PerformanceAscii
+/* https://code.google.com/p/stringencoders/wiki/PerformanceAscii
http://www.azillionmonkeys.com/qed/asmexample.html
*/
static inline uint64_t switch_toupper64(uint64_t eax)
return eax - ebx;
}
-/* https://code.google.com/p/stringencoders/wiki/PerformanceAscii
+/* https://code.google.com/p/stringencoders/wiki/PerformanceAscii
http://www.azillionmonkeys.com/qed/asmexample.html
*/
static inline uint64_t switch_tolower64(uint64_t eax)
}
-#else
+#else
static inline void switch_toupper_max(char *s)
{
c++;
l--;
}
-
+
}
static inline void switch_tolower_max(char *s)
c++;
l--;
}
-
+
}
#endif
#define zset(_a, _b) if (!zstr(_b)) _a = _b
-/* find a character (find) in a string (in) and return a pointer to that point in the string where the character was found
+/* find a character (find) in a string (in) and return a pointer to that point in the string where the character was found
using the array (allowed) as allowed non-matching characters, when (allowed) is NULL, behaviour should be identical to strchr()
*/
static inline char *switch_strchr_strict(const char *in, char find, const char *allowed)
acceptable = 1;
break;
}
-
+
a++;
}
}
-
+
if (!acceptable) return NULL;
p++;
k++;
byte++;
}
-
+
if (buf[j-1] == ' ') j--;
buf[j++] = '\0';
return buf;
/*!
\brief Evaluate the truthfullness of a string expression
\param expr a string expression
- \return true or false
+ \return true or false
*/
static inline int switch_true(const char *expr)
{
/*!
\brief Evaluate the falsefullness of a string expression
\param expr a string expression
- \return true or false
+ \return true or false
*/
static inline int switch_false(const char *expr)
{
while ((q = strrchr(p, '@')))
*q = '\0';
-
+
for (i = 0; i < (int) strlen(warp); i++) {
while (p && (q = strchr(p, warp[i])))
p = q + 1;
/* KUSH GAUGE*/
if (!fps) fps = 15;
-
+
r = (int32_t)((double)(w * h * fps * (quality ? quality : 1)) * 0.07) / 1000;
if (!quality) r /= 2;
if (!strcasecmp(bwv, "auto")) {
return -1;
- }
+ }
if ((bw = (float) atof(bwv))) {
if (bw < 0) return 0;
const char hex[] = "0123456789ABCDEF";
const char *p, *e = end_of_p(s);
-
+
for(p = s; p && *p; p++) {
if (*p == '%' && e-p > 1) {
if (strchr(hex, *(p+1)) && strchr(hex, *(p+2))) {
*file_portion = NULL;
*params_portion = NULL;
-
+
while (*file == '{') {
e = switch_find_end_paren(file, '{', '}');
file = e + 1;
} else {
*file_portion = (char *)space;
}
-
+
return;
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
uint32_t refs;
};
-/*!
+/*!
* \brief Parses a string into a switch_xml_t, ensuring the memory will be freed with switch_xml_free
* \param s The string to parse
* \param dup true if you want the string to be strdup()'d automatically
*/
SWITCH_DECLARE(switch_xml_t) switch_xml_parse_str_dynamic(_In_z_ char *s, _In_ switch_bool_t dup);
-/*!
- * \brief Parses a string into a switch_xml_t
+/*!
+ * \brief Parses a string into a switch_xml_t
* \param s The string to parse
* \return the switch_xml_t or NULL if an error occured
*/
///\brief Traverses the switch_xml structure to retrieve a specific subtag. Takes a
///\ variable length list of tag names and indexes. The argument list must be
-///\ terminated by either an index of -1 or an empty string tag name. Example:
+///\ terminated by either an index of -1 or an empty string tag name. Example:
///\ title = switch_xml_get(library, "shelf", 0, "book", 2, "title", -1);
///\ This retrieves the title of the 3rd book on the 1st shelf of library.
///\ Returns NULL if not found.
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Mathieu Rene <mathieu.rene@gmail.com>
*
*
switch_bool_t changed);
/*!
- * \brief A configuration instruction read by switch_xml_config_parse
+ * \brief A configuration instruction read by switch_xml_config_parse
*/
struct switch_xml_config_item {
const char *key; /*< The key of the element, or NULL to indicate the end of the list */
const void *defaultvalue, void *data, switch_xml_config_callback_t function, const char *syntax,
const char *helptext);
-/*!
+/*!
* \brief Gets the int representation of an enum
* \param enum_options the switch_xml_config_enum_item_t array for this enum
- * \param value string value to search
+ * \param value string value to search
*/
SWITCH_DECLARE(switch_status_t) switch_xml_config_enum_str2int(switch_xml_config_enum_item_t *enum_options, const char *value, int *out);
-/*!
+/*!
* \brief Gets the string representation of an enum
* \param enum_options the switch_xml_config_enum_item_t array for this enum
- * \param value int value to search
+ * \param value int value to search
*/
SWITCH_DECLARE(const char *) switch_xml_config_enum_int2str(switch_xml_config_enum_item_t *enum_options, int value);
/*!
- * \brief Prints out an item's documentation on the console
+ * \brief Prints out an item's documentation on the console
* \param level loglevel to use
* \param item item which the doc should be printed
*/
SWITCH_DECLARE(void) switch_xml_config_item_print_doc(int level, switch_xml_config_item_t *item);
-/*!
- * \brief Parses all the xml elements, following a ruleset defined by an array of switch_xml_config_item_t
+/*!
+ * \brief Parses all the xml elements, following a ruleset defined by an array of switch_xml_config_item_t
* \param xml The first element of the list to parse
* \param reload true to skip all non-reloadable options
* \param instructions instrutions on how to parse the elements
* \brief Parses a module's settings
* \param reload true to skip all non-reloadable options
* \param file the configuration file to look for
- * \param instructions the instructions
+ * \param instructions the instructions
*/
SWITCH_DECLARE(switch_status_t) switch_xml_config_parse_module_settings(const char *file, switch_bool_t reload, switch_xml_config_item_t *instructions);
-/*!
- * \brief Parses all of an event's elements, following a ruleset defined by an array of switch_xml_config_item_t
+/*!
+ * \brief Parses all of an event's elements, following a ruleset defined by an array of switch_xml_config_item_t
* \param event The event structure containing the key and values to parse
* \param reload true to skip all non-reloadable options
* \param instructions instrutions on how to parse the elements
switch_xml_config_item_t *instructions);
/*!
- * \brief Parses a list of xml elements into an event
+ * \brief Parses a list of xml elements into an event
* \param xml First element of the xml list to parse
* \param keyname Name of the key attribute
- * \param keyvalue Name of the value attribute
+ * \param keyvalue Name of the value attribute
* \param event [out] event (if *event is NOT NULL, the headers will be appended to the existing event)
*/
SWITCH_DECLARE(switch_size_t) switch_event_import_xml(switch_xml_t xml, const char *keyname, const char *valuename, switch_event_t **event);
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Marc Olivier Chouinard <mochouinard@moctel.com>
*
*
const char *global_cf = "abstraction.conf";
-/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
+/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
* Defines a switch_loadable_module_function_table_t and a static const char[] modname
*/
SWITCH_MODULE_DEFINITION(mod_abstraction, mod_abstraction_load, mod_abstraction_shutdown, NULL);
}
switch_api_execute(destination, api_args, session, stream);
- switch_safe_free(substituted);
+ switch_safe_free(substituted);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No match for API %s (%s != %s)\n", api_name, parse, cmd);
}
switch_regex_safe_free(re);
-
+
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "API %s doesn't exist inside the xml structure. You might have forgot to reload the module after editing it\n", api_name);
}
static switch_status_t open_encoder(h264_codec_context_t *context, uint32_t width, uint32_t height)
{
int sane = 0;
-
+
if (!context->encoder) {
if (context->av_codec_id == AV_CODEC_ID_H264) {
if (context->codec_settings.video.try_hardware_encoder && (context->encoder = avcodec_find_encoder_by_name("nvenc_h264"))) {
}
context->bandwidth *= 3;
-
+
//context->encoder_ctx->bit_rate = context->bandwidth * 1024;
context->encoder_ctx->width = context->codec_settings.video.width;
context->encoder_ctx->height = context->codec_settings.video.height;
if (got_picture && decoded_len > 0) {
int width = picture->width;
int height = picture->height;
-
+
if (!context->img || (context->img->d_w != width || context->img->d_h != height)) {
switch_img_free(&context->img);
context->img = switch_img_alloc(NULL, SWITCH_IMG_FMT_I420, width, height, 1);
}
mst->st->id = fc->nb_streams - 1;
c = mst->st->codec;
-
+
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "id:%d den:%d num:%d\n", mst->st->id, mst->st->time_base.den, mst->st->time_base.num);
if (threads > 4) {
} else {
mm->fps = fps;
}
-
+
if (mm->vw && mm->vh) {
mst->width = mm->vw;
mst->height = mm->vh;
c->level = 52;
break;
}
-
+
switch (mm->vencspd) {
case SWITCH_VIDEO_ENCODE_SPEED_SLOW:
av_opt_set(c->priv_data, "preset", "veryslow", 0);
goto top;
}
} else {
-
+
size = switch_queue_size(eh->video_queue);
if (size > 5 && !eh->finalize) {
}
}
}
-
+
//switch_mutex_lock(eh->mutex);
eh->in_callback = 1;
-
- av_init_packet(&pkt);
+
+ av_init_packet(&pkt);
if (eh->video_st->frame) {
ret = av_frame_make_writable(eh->video_st->frame);
}
fill_avframe(eh->video_st->frame, img);
-
+
if (eh->finalize) {
if (delta_i && !delta_avg) {
delta_avg = (int)(double)(delta_sum / delta_i);
if (delta_tmp != last_ts) {
delta_sum += delta_tmp;
delta_i++;
-
+
if (delta_i >= 60) {
delta_avg = (int)(double)(delta_sum / delta_i);
delta_i = 0;
delta_sum = delta_avg;
}
-
+
eh->video_st->frame->pts = eh->timer->samplecount;
}
}
int offset = DFT_RECORD_OFFSET;
int fps = codec.implementation->actual_samples_per_second / samples;
int lead_frames = (offset * fps) / 1000;
-
+
for (int x = 0; x < lead_frames; x++) {
switch_buffer_write(buffer, buf, datalen);
- }
+ }
}
-
+
while (switch_channel_ready(channel)) {
status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_SINGLE_READ, 0);
*pts = vframe->pkt_pts;
avframe2img(vframe, img);
img->user_priv = pts;
-
+
#ifdef ALT_WAY
diff = sleep - (switch_time_now() - context->last_vid_push);
-
+
if (diff > 0 && diff <= sleep) {
switch_core_timer_next(&context->video_timer);
} else {
switch_core_timer_sync(&context->video_timer);
}
-#endif
+#endif
context->vid_ready = 1;
switch_queue_push(context->eh.video_queue, img);
switch_status_t status = SWITCH_STATUS_SUCCESS;
switch_set_string(file, path);
-
+
if ((ext = strrchr((char *)path, '.')) == 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Format\n");
return SWITCH_STATUS_GENERR;
switch_buffer_write(context->audio_buffer, data, datalen);
}
-
+
bytes = context->audio_st.frame->nb_samples * 2 * context->audio_st.st->codec->channels;
switch_buffer_write(context->audio_buffer, buf, bytes - inuse);
}
}
-
-
+
+
while ((inuse = switch_buffer_inuse(context->audio_buffer)) >= bytes) {
AVPacket pkt = { 0 };
int got_packet = 0;
int ret;
av_init_packet(&pkt);
-
+
if (context->audio_st.resample_ctx) { // need resample
int out_samples = avresample_get_out_samples(context->audio_st.resample_ctx, context->audio_st.frame->nb_samples);
av_frame_make_writable(context->audio_st.frame);
ret = avresample_convert(context->audio_st.resample_ctx,
context->audio_st.tmp_frame->data, 0, out_samples,
(uint8_t **)context->audio_st.frame->data, 0, context->audio_st.frame->nb_samples);
-
+
if (ret < 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error while converting %d samples, error text: %s\n",
context->audio_st.frame->nb_samples, get_error_text(ret));
context->audio_st.tmp_frame->pts = context->audio_st.next_pts;
context->audio_st.next_pts += context->audio_st.frame->nb_samples;
- ret = avcodec_encode_audio2(context->audio_st.st->codec, &pkt, context->audio_st.tmp_frame, &got_packet);
+ ret = avcodec_encode_audio2(context->audio_st.st->codec, &pkt, context->audio_st.tmp_frame, &got_packet);
} else {
av_frame_make_writable(context->audio_st.frame);
switch_buffer_read(context->audio_buffer, context->audio_st.frame->data[0], bytes);
switch(command) {
case SCFC_FLUSH_AUDIO:
- switch_mutex_lock(context->mutex);
+ switch_mutex_lock(context->mutex);
switch_buffer_zero(context->audio_buffer);
- switch_mutex_unlock(context->mutex);
+ switch_mutex_unlock(context->mutex);
break;
case SCFC_PAUSE_READ:
if (context->read_paused) {
if (size == 0) {
size_t blank = (handle->samplerate / 20) * 2 * handle->real_channels;
-
+
if (need > blank) {
need = blank;
}
if ((flags & SVR_FLUSH)) {
flush_video_queue(context->eh.video_queue, 1);
}
-
+
if ((flags & SVR_BLOCK)) {
status = switch_queue_pop(context->eh.video_queue, &pop);
} else {
return (flags & SVR_FLUSH) ? SWITCH_STATUS_BREAK : status;
}
-#else
+#else
static switch_status_t av_file_read_video(switch_file_handle_t *handle, switch_frame_t *frame, switch_video_read_flag_t flags)
{
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "picture is too late, off: %" SWITCH_INT64_T_FMT " max delta: %" SWITCH_INT64_T_FMT " queue size:%u fps:%u/%0.2f\n", (int64_t)(now - mst->next_pts), max_delta, switch_queue_size(context->eh.video_queue), context->read_fps, handle->mm.fps);
switch_img_free(&img);
//max_delta = AV_TIME_BASE;
-
+
if (switch_queue_size(context->eh.video_queue) > 0) {
// switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "WTF again\n");
goto again;
mst->next_pts = 0;
context->video_start_time = 0;
return SWITCH_STATUS_BREAK;
- }
+ }
}
if ((flags & SVR_BLOCK) || do_fl) {
return SWITCH_STATUS_BREAK;
}
}
-
+
} else {
return SWITCH_STATUS_BREAK;
}
-/*
+/*
* Contributor(s):
*
* Piotr Gregor <piotrgregor@rsyncme.org>
-/*
+/*
* Contributor(s):
*
* Eric des Courtis <eric.des.courtis@benbria.com>
float f;
} float_conv_t;
-/*
+/*
* Manipulate these parameters to change
* mapping's resolution. The sine tone
* of 1600Hz is detected even with 20
i_1 = index_from_float(1.0);
di = (i_1 - i_0)/100;
if (di == 0) di = 1;
-
+
for (; i < ACOS_TABLE_LENGTH; i += di )
{
f = float_from_index(i);
-/*
+/*
* Contributor(s):
*
* Eric des Courtis <eric.des.courtis@benbria.com>
#define AVMD_MIN_FREQUENCY (440.0)
/*! Minimum frequency as digital normalized frequency */
#define AVMD_MIN_FREQUENCY_R(r) ((2.0 * M_PI * AVMD_MIN_FREQUENCY) / (r))
-/*!
+/*!
* Maximum beep frequency in Hertz
* Note: The maximum frequency the DESA-2 algorithm can uniquely
* identify is 0.25 of the sampling rate. All the frequencies
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Detector-offset", "ERROR (TRUNCATED)");
}
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Detector-offset", buf);
-
+
res = snprintf(buf, AVMD_CHAR_BUF_LEN, "%u", idx);
if (res < 0 || res > AVMD_CHAR_BUF_LEN - 1) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(fs_s), SWITCH_LOG_ERROR, "Error, truncated [%s], [%d] attempeted!\n", buf, res);
}
/* this may be option parameter if valid */
- key = candidate_parsed[0]; /* option name */
+ key = candidate_parsed[0]; /* option name */
if (zstr(key)) { /* empty key */
return SWITCH_STATUS_NOT_INITALIZED;
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Failed to add media bug!\n");
goto end_unlock;
}
-
+
switch_mutex_lock(avmd_globals.mutex);
++avmd_globals.session_n;
switch_mutex_unlock(avmd_globals.mutex);
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
/* Proceed to read and process the received frame ...
* Note that switch_core_session_read_frame is a blocking operation, we could do reathing in another thread like the playback() app
- * does using switch_core_service_session() but OTOH that would lead to more load/cpu usage, extra threads being launched per call leg
+ * does using switch_core_service_session() but OTOH that would lead to more load/cpu usage, extra threads being launched per call leg
* and most likely reduce the overall capacity of the test system */
status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
if (!SWITCH_READ_ACCEPTABLE(status)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", BERT_EVENT_TIMEOUT);
return SWITCH_STATUS_TERM;
}
-
+
if (switch_event_reserve_subclass(BERT_EVENT_LOST_SYNC) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", BERT_EVENT_LOST_SYNC);
return SWITCH_STATUS_TERM;
}
-
-
+
+
if (switch_event_reserve_subclass(BERT_EVENT_IN_SYNC) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", BERT_EVENT_IN_SYNC);
return SWITCH_STATUS_TERM;
}
-
-
+
+
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
- SWITCH_ADD_APP(app_interface, "bert_test", "Start BERT Test", "Start BERT Test", bert_test_function, "", SAF_NONE);
+ SWITCH_ADD_APP(app_interface, "bert_test", "Start BERT Test", "Start BERT Test", bert_test_function, "", SAF_NONE);
return SWITCH_STATUS_SUCCESS;
}
switch_event_free_subclass(BERT_EVENT_TIMEOUT);
switch_event_free_subclass(BERT_EVENT_LOST_SYNC);
switch_event_free_subclass(BERT_EVENT_IN_SYNC);
-
+
return SWITCH_STATUS_UNLOAD;
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Mathieu Rene <mrene@avgs.ca>
* Raymond Chandler <intralanman@freeswitch.org>
*
switch_memory_pool_t *pool;
} globals;
-blacklist_t *blacklist_create(const char *name)
+blacklist_t *blacklist_create(const char *name)
{
switch_memory_pool_t *pool = NULL;
blacklist_t *bl = NULL;
-
+
switch_core_new_memory_pool(&pool);
bl = switch_core_alloc(pool, sizeof(*bl));
switch_assert(bl);
bl->pool = pool;
-
+
switch_core_hash_init(&bl->list);
switch_mutex_init(&bl->list_mutex, SWITCH_MUTEX_NESTED, pool);
-
+
return bl;
}
/* Load up blacklists */
switch_xml_t xml, cfg, lists, list;
switch_hash_index_t *hi = NULL;
-
+
if (!(xml = switch_xml_open_cfg("mod_blacklist.conf", &cfg, NULL))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't load configuration section\n");
return SWITCH_STATUS_FALSE;
}
-
+
switch_mutex_lock(globals.lists_mutex);
-
+
/* Destroy any active lists */
while ((hi = switch_core_hash_first_iter( globals.lists, hi))) {
const void *key;
blacklist_free((blacklist_t*)val);
switch_core_hash_delete(globals.lists, (const char*)key);
}
-
+
if ((lists = switch_xml_child(cfg, "lists"))) {
for (list = switch_xml_child(lists, "list"); list; list = list->next) {
const char *name = switch_xml_attr_soft(list, "name");
load_list(name, filename);
}
}
-
+
switch_mutex_unlock(globals.lists_mutex);
-
+
if (xml) {
switch_xml_free(xml);
xml = NULL;
char *data;
int argc;
char *argv[3];
-
+
data = strdup(cmd);
trim(data);
if (!(argc = switch_separate_string(data, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid usage\n");
goto done;
}
-
+
if (!strcasecmp(argv[0], "check")) {
blacklist_t *bl = NULL;
switch_bool_t result;
-
+
if (argc < 2 || zstr(argv[1]) || zstr(argv[2])) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Wrong syntax");
goto done;
}
-
+
switch_mutex_lock(globals.lists_mutex);
bl = switch_core_hash_find(globals.lists, argv[1]);
switch_mutex_unlock(globals.lists_mutex);
-
+
if (!bl) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown blacklist [%s]\n", argv[1]);
stream->write_function(stream, "false");
goto done;
}
-
+
switch_mutex_lock(bl->list_mutex);
result = (switch_bool_t)(intptr_t)switch_core_hash_find(bl->list, argv[2]);
stream->write_function(stream, "%s", result ? "true" : "false");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Wrong syntax");
goto done;
}
-
+
switch_mutex_lock(globals.lists_mutex);
bl = switch_core_hash_find(globals.lists, argv[1]);
switch_mutex_unlock(globals.lists_mutex);
-
+
if (!bl) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown blacklist [%s]\n", argv[1]);
stream->write_function(stream, "-ERR Unknown blacklist\n");
goto done;
}
-
+
switch_mutex_lock(bl->list_mutex);
switch_core_hash_insert(bl->list, argv[2], (void*)SWITCH_TRUE);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Added [%s] to list [%s]\n", argv[2], argv[1]);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Wrong syntax");
goto done;
}
-
+
switch_mutex_lock(globals.lists_mutex);
bl = switch_core_hash_find(globals.lists, argv[1]);
switch_mutex_unlock(globals.lists_mutex);
-
+
if (!bl) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown blacklist [%s]\n", argv[1]);
stream->write_function(stream, "-ERR Unknown blacklist\n");
goto done;
}
-
+
switch_mutex_lock(bl->list_mutex);
switch_core_hash_delete(bl->list, argv[2]);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Removed [%s] from list [%s]\n", argv[2], argv[1]);
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Saving %s to %s\n", argv[1], filename);
-
+
switch_mutex_lock(globals.lists_mutex);
if (switch_file_open(&fd, filename, SWITCH_FOPEN_WRITE | SWITCH_FOPEN_TRUNCATE | SWITCH_FOPEN_CREATE, SWITCH_FPROT_OS_DEFAULT, globals.pool)
== SWITCH_STATUS_SUCCESS) {
switch_file_printf(fd, "%s\n", (char *)var);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "adding %s to the dump file\n", (char *)var);
}
- stream->write_function(stream, "+OK\n");
+ stream->write_function(stream, "+OK\n");
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "couldn't open %s for writing\n", filename);
}
} else if (!zstr(argv[0])) {
stream->write_function(stream, "-ERR: No such command: %s (see 'blacklist help')\n", argv[0]);
}
-
+
done:
switch_safe_free(data);
return SWITCH_STATUS_SUCCESS;
//switch_application_interface_t *app_interface;
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
-
+
memset(&globals, 0, sizeof(globals));
globals.pool = pool;
<!-- <tier agent="1000@default" queue="support@default" level="1" position="1"/> -->
</tiers>
-</configuration>
+</configuration>
<!-- comment out sql to not setup a database (directory) lookup -->
<param name="sql" value="
- SELECT name||' ('||type||')' AS name
+ SELECT name||' ('||type||')' AS name
FROM phonebook p JOIN numbers n ON p.id = n.phonebook_id
- WHERE n.number='${caller_id_number}'
+ WHERE n.number='${caller_id_number}'
LIMIT 1
"/>
- <!-- comment out citystate-sql to not setup a database (city/state)
+ <!-- comment out citystate-sql to not setup a database (city/state)
lookup -->
<param name="citystate-sql" value="
SELECT ratecenter||' '||state as name
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Rupa Schomaker <rupa@rupa.com>
*
* mod_cidlookup.c -- API for querying cid->name services and local data
SWITCH_MODULE_RUNTIME_FUNCTION(mod_cidlookup_runtime);
SWITCH_MODULE_LOAD_FUNCTION(mod_cidlookup_load);
-/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
+/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
* Defines a switch_loadable_module_function_table_t and a static const char[] modname
*/
SWITCH_MODULE_DEFINITION(mod_cidlookup, mod_cidlookup_load, mod_cidlookup_shutdown, NULL);
{
switch_cache_db_handle_t *dbh = NULL;
char *dsn;
-
+
if (!zstr(globals.odbc_dsn)) {
dsn = globals.odbc_dsn;
} else {
if (switch_cache_db_get_db_handle_dsn(&dbh, dsn) != SWITCH_STATUS_SUCCESS) {
dbh = NULL;
}
-
+
return dbh;
}
switch_curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1);
switch_curl_easy_setopt(curl_handle, CURLOPT_MAXREDIRS, 10);
/*
- TIMEOUT_MS is introduced in 7.16.2, we have 7.16.0 in tree
+ TIMEOUT_MS is introduced in 7.16.2, we have 7.16.0 in tree
*/
#ifdef CURLOPT_TIMEOUT_MS
if (timeout > 0) {
query = switch_event_expand_headers(event, "http://api.whitepages.com/reverse_phone/1.0/?phone=${whitepages-cid};api_key=${whitepages-api-key}");
do_lookup_url(pool, event, &xml_s, query, NULL, NULL, 0);
-
+
if (zstr(xml_s)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No XML returned for number %s\n", num);
goto done;
}
-
+
xml = switch_xml_parse_str_dup(xml_s);
if (!xml) {
if (switch_event_create(&event, SWITCH_EVENT_CALL_UPDATE) == SWITCH_STATUS_SUCCESS) {
const char *uuid = switch_channel_get_partner_uuid(channel);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Direction", "RECV");
-
+
if (uuid) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridged-To", uuid);
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Neal Horman <neal at wanlink dot com>
*
SWITCH_MODULE_RUNTIME_FUNCTION(mod_cluechoo_runtime);
SWITCH_MODULE_LOAD_FUNCTION(mod_cluechoo_load);
-/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
+/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
* Defines a switch_loadable_module_function_table_t and a static const char[] modname
*/
SWITCH_MODULE_DEFINITION(mod_cluechoo, mod_cluechoo_load, mod_cluechoo_shutdown, NULL);
/*========================================
* sl.c:
- * Copyright 1993,1998 Toyoda Masashi
+ * Copyright 1993,1998 Toyoda Masashi
* (toyoda@is.titech.ac.jp)
* Last Modified: 1998/ 7/22
*========================================
/*========================================
* sl.h: Text data of SL version 3.01
- * Copyright 1993 Toyoda Masashi
+ * Copyright 1993 Toyoda Masashi
* (toyoda@is.titech.ac.jp)
* Last Modified: 1992/12/23
*========================================
}
}
}
-
+
if (_domain) {
tag_name = "domain";
key_name = "name";
if (argv[0]) {
uuid = argv[0];
}
-
+
if (argv[1]) {
action = argv[1];
}
switch_channel_set_variable(channel, "drop_dtmf", "false");
}
}
-
+
is_on = switch_channel_test_flag(channel, CF_DROP_DTMF);
file = switch_channel_get_variable_dup(channel, "drop_dtmf_masking_file", SWITCH_FALSE, -1);
digits = switch_channel_get_variable_dup(channel, "drop_dtmf_masking_digits", SWITCH_FALSE, -1);
- stream->write_function(stream, "+OK %s is %s DTMF. mask_file: %s mask_digits: %s\n", uuid, is_on ? "dropping" : "not dropping",
+ stream->write_function(stream, "+OK %s is %s DTMF. mask_file: %s mask_digits: %s\n", uuid, is_on ? "dropping" : "not dropping",
file ? file : "NONE",
digits ? digits : "NONE");
-
+
switch_core_session_rwunlock(tsession);
} else {
stream->write_function(stream, "-ERR No such channel %s!\n", uuid);
static void jsonify_stats(cJSON *json, const char *name, switch_rtp_stats_t *stats)
{
cJSON *jstats = cJSON_CreateObject();
- cJSON_AddItemToObject(json, name, jstats);
+ cJSON_AddItemToObject(json, name, jstats);
stats->inbound.std_deviation = sqrt(stats->inbound.variance);
add_stat(stats->rtcp.packet_count, "rtcp_packet_count");
add_stat(stats->rtcp.octet_count, "rtcp_octet_count");
-
+
}
static switch_bool_t true_enough(cJSON *json)
switch_core_session_t *tsession;
reply = cJSON_CreateObject();
- *json_reply = reply;
+ *json_reply = reply;
if (zstr(uuid)) {
cJSON_AddItemToObject(reply, "response", cJSON_CreateString("INVALID INPUT"));
goto end;
}
-
+
if ((tsession = switch_core_session_locate(uuid))) {
cJSON *jevent;
switch_rtp_stats_t *audio_stats = NULL, *video_stats = NULL;
switch_core_media_set_stats(tsession);
-
+
audio_stats = switch_core_media_get_stats(tsession, SWITCH_MEDIA_TYPE_AUDIO, switch_core_session_get_pool(tsession));
video_stats = switch_core_media_get_stats(tsession, SWITCH_MEDIA_TYPE_VIDEO, switch_core_session_get_pool(tsession));
-
+
if (audio_stats) {
jsonify_stats(reply, "audio", audio_stats);
}
-
+
if (video_stats) {
jsonify_stats(reply, "video", video_stats);
}
-
+
if (true_enough(cdata) && switch_ivr_generate_json_cdr(tsession, &jevent, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) {
cJSON_AddItemToObject(reply, "channelData", jevent);
}
switch_core_session_rwunlock(tsession);
-
+
status = SWITCH_STATUS_SUCCESS;
} else {
cJSON_AddItemToObject(reply, "response", cJSON_CreateString("Session does not exist"));
msg.message_id = SWITCH_MESSAGE_INDICATE_BITRATE_REQ;
msg.numeric_arg = kps * 1024;
msg.from = __FILE__;
-
+
switch_core_session_receive_message(lsession, &msg);
switch_core_session_video_reinit(lsession);
switch_channel_video_sync(switch_core_session_get_channel(lsession));
msg.numeric_arg = level;
msg.numeric_reply = type;
msg.from = __FILE__;
-
+
switch_core_session_receive_message(lsession, &msg);
status = SWITCH_STATUS_SUCCESS;
switch_core_session_rwunlock(lsession);
msg.string_array_arg[2] = argv[3];
msg.string_array_arg[3] = argv[4];
msg.from = __FILE__;
-
+
switch_core_session_receive_message(lsession, &msg);
status = SWITCH_STATUS_SUCCESS;
switch_core_session_rwunlock(lsession);
char *ptr = NULL;
int idx = -1;
char *vname = strdup(var_name);
-
+
if ((ptr = strchr(vname, '[')) && strchr(ptr, ']')) {
*ptr++ = '\0';
idx = atoi(ptr);
free(vname);
}
-
+
if (!var_value) {
var_value = switch_channel_get_variable(channel, var_name);
}
-
+
if (var_value != NULL) {
stream->write_function(stream, "%s", var_value);
} else {
}
#define GETCPUTIME_SYNTAX "[reset]"
-SWITCH_STANDARD_API(getcputime_function)
+SWITCH_STANDARD_API(getcputime_function)
{
static int64_t reset_ums = 0, reset_kms = 0; // Last reset times in ms
switch_cputime t = { 0 };
reply = cJSON_CreateObject();
- *json_reply = reply;
+ *json_reply = reply;
if (zstr(uuid)) {
cJSON_AddItemToObject(reply, "response", cJSON_CreateString("INVALID INPUT"));
goto end;
}
-
+
if ((tsession = switch_core_session_locate(uuid))) {
cJSON *jevent;
}
switch_core_session_rwunlock(tsession);
-
+
status = SWITCH_STATUS_SUCCESS;
} else {
cJSON_AddItemToObject(reply, "response", cJSON_CreateString("Session does not exist"));
switch_core_session_t *tsession;
reply = cJSON_CreateObject();
- *json_reply = reply;
+ *json_reply = reply;
if (!data) {
cJSON_AddItemToObject(reply, "response", cJSON_CreateString("INVALID INPUT"));
cJSON_AddItemToObject(reply, "response", cJSON_CreateString("INVALID INPUT"));
goto end;
}
-
+
if ((tsession = switch_core_session_locate(uuid))) {
if (switch_true(edata)) {
cJSON *jevent = NULL;
{
cJSON *jdata = NULL;
const char *channel;
-
+
if (!cmd) {
stream->write_function(stream, "-ERR parsing channel\n", SWITCH_VA_NONE);
return SWITCH_STATUS_SUCCESS;
}
return SWITCH_STATUS_SUCCESS;
-
+
}
SWITCH_STANDARD_JSON_API(json_api_function)
reply = cJSON_CreateObject();
SWITCH_STANDARD_STREAM(stream);
-
+
if (cmd && (status = switch_api_execute(cmd->valuestring, arg ? arg->valuestring : NULL, session, &stream)) == SWITCH_STATUS_SUCCESS) {
cJSON_AddItemToObject(reply, "message", cJSON_CreateString((char *) stream.data));
} else {
cJSON_AddItemToObject(o, "seconds", cJSON_CreateNumber(duration.sec));
cJSON_AddItemToObject(o, "milliseconds", cJSON_CreateNumber(duration.ms));
cJSON_AddItemToObject(o, "microseconds", cJSON_CreateNumber(duration.mms));
-
+
cJSON_AddItemToObject(reply, "uptime", o);
cJSON_AddItemToObject(reply, "version", cJSON_CreateString(switch_version_full_human()));
-
+
o = cJSON_CreateObject();
cJSON_AddItemToObject(reply, "sessions", o);
cJSON_AddItemToObject(oo, "max", cJSON_CreateNumber(sps));
cJSON_AddItemToObject(oo, "peak", cJSON_CreateNumber(max_sps));
cJSON_AddItemToObject(oo, "peak5Min", cJSON_CreateNumber(max_sps_fivemin));
-
+
o = cJSON_CreateObject();
cJSON_AddItemToObject(reply, "idleCPU", o);
cJSON_AddItemToObject(o, "used", cJSON_CreateNumber(switch_core_min_idle_cpu(-1.0)));
cJSON_AddItemToObject(o, "allowed", cJSON_CreateNumber(switch_core_idle_cpu()));
-
+
if (switch_core_get_stacksizes(&cur, &max) == SWITCH_STATUS_SUCCESS) {
o = cJSON_CreateObject();
cJSON_AddItemToObject(reply, "stackSizeKB", o);
cJSON_AddItemToObject(o, "current", cJSON_CreateNumber((double)(cur / 1024)));
cJSON_AddItemToObject(o, "max", cJSON_CreateNumber((double)(max / 1024)));
}
-
+
*json_reply = reply;
-
+
return SWITCH_STATUS_SUCCESS;
}
cJSON *jcmd = NULL, *format = NULL;
const char *message = "";
char *response = NULL;
-
+
if (zstr(cmd)) {
message = "No JSON supplied.";
goto err;
} else {
response = cJSON_PrintUnformatted(jcmd);
}
-
+
stream->write_function(stream, "%s\n", switch_str_nil(response));
-
+
switch_safe_free(response);
cJSON_Delete(jcmd);
-
+
return SWITCH_STATUS_SUCCESS;
err:
-<!-- http://wiki.freeswitch.org/wiki/Mod_conference -->
+<!-- http://wiki.freeswitch.org/wiki/Mod_conference -->
<!-- None of these paths are real if you want any of these options you need to really set them up -->
<configuration name="conference.conf" description="Audio Conference">
<!-- Advertise certain presence on startup . -->
<room name="3001@$${domain}" status="FreeSWITCH"/>
</advertise>
- <!-- These are the default keys that map when you do not specify a caller control group -->
- <!-- Note: none and default are reserved names for group names. Disabled if dist-dtmf member flag is set. -->
+ <!-- These are the default keys that map when you do not specify a caller control group -->
+ <!-- Note: none and default are reserved names for group names. Disabled if dist-dtmf member flag is set. -->
<caller-controls>
<group name="default">
<control action="mute" digits="0"/>
<profiles>
<!--If no profile is specified it will default to "default"-->
<profile name="default">
- <!-- Directory to drop CDR's
+ <!-- Directory to drop CDR's
'auto' means $PREFIX/logs/conference_cdr/<confernece_uuid>.cdr.xml
a non-absolute path means $PREFIX/logs/<value>/<confernece_uuid>.cdr.xml
absolute path means <value>/<confernece_uuid>.cdr.xml
-->
<!-- <param name="cdr-log-dir" value="auto"/> -->
- <!-- How to create a CDR event
+ <!-- How to create a CDR event
'content' means event body will contain CDR as XML
'file' means 'CDR-Path' header will contain a path to file created in 'cdr-log-dir'
'none' for no event
-->
<!-- <param name="cdr-event-mode" value="content"/> -->
-
+
<!-- Domain (for presence) -->
<param name="domain" value="$${domain}"/>
<!-- Sample Rate-->
if (switch_core_session_media_flow(member->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_SENDONLY) {
return SWITCH_STATUS_SUCCESS;
}
-
+
if ((layer = conference_video_get_layer_locked(member))) {
layer->clear = 1;
conference_video_release_layer(&layer);
} else {
group_name = argv[3];
}
-
+
if (!group_name) {
stream->write_function(stream, "Group name not specified.\n");
return SWITCH_STATUS_SUCCESS;
}
stream->write_function(stream, "Change to layout group [%s]\n", group_name);
-
+
if (argv[xx]) {
if ((idx = atoi(argv[xx])) > 0) {
idx--;
}
layer = conference_video_get_layer_locked(member);
-
+
if (!layer) {
goto end;
}
}
if (id == 0 && conference->canvases[0]) id = 1;
-
+
if (id > conference->canvas_count) {
id = 1;
}
}
member = conference_member_get_by_var(conference, var, val);
-
+
if (member != NULL) {
pfn(member, stream, argv[argn + 2]);
switch_thread_rwlock_unlock(member->rwlock);
static cJSON *get_canvas_info(mcu_canvas_t *canvas)
{
cJSON *obj = cJSON_CreateObject();
-
+
cJSON_AddItemToObject(obj, "canvasID", cJSON_CreateNumber(canvas->canvas_id));
cJSON_AddItemToObject(obj, "totalLayers", cJSON_CreateNumber(canvas->total_layers));
cJSON_AddItemToObject(obj, "layersUsed", cJSON_CreateNumber(canvas->layers_used));
if (canvas->vlayout) {
cJSON_AddItemToObject(obj, "layoutName", cJSON_CreateString(canvas->vlayout->name));
}
-
+
return obj;
}
}
if (member_id < 0) member_id = 0;
}
-
+
if (member_id > 0) {
conference_member_t *member;
-
+
if ((member = conference_member_get(conference, member_id))) {
mcu_canvas_t *canvas;
-
+
if ((canvas = conference_video_get_canvas_locked(member))) {
cJSON *obj;
-
+
if ((obj = get_canvas_info(canvas))) {
- cJSON_AddItemToObject(obj, "layerID", cJSON_CreateNumber(member->video_layer_id));
+ cJSON_AddItemToObject(obj, "layerID", cJSON_CreateNumber(member->video_layer_id));
cJSON_AddItemToArray(array, obj);
}
-
+
conference_video_release_canvas(&canvas);
}
-
+
switch_thread_rwlock_unlock(member->rwlock);
}
switch_mutex_unlock(conference->canvas_mutex);
}
-
+
switch_thread_rwlock_unlock(conference->rwlock);
}
-
+
addobj = array;
-
+
} else if (!strcasecmp(action, "list-videoLayouts")) {
switch_hash_index_t *hi;
void *val;
cJSON *obj = cJSON_CreateObject();
cJSON *resarray = cJSON_CreateArray();
int i;
-
+
switch_core_hash_this(hi, &vvar, NULL, &val);
vlayout = (video_layout_t *)val;
for (i = 0; i < vlayout->layers; i++) {
if (vlayout->images[i].res_id) {
cJSON_AddItemToArray(resarray, cJSON_CreateString((char *)vlayout->images[i].res_id));
}
- }
-
+ }
+
cJSON_AddItemToObject(obj, "type", cJSON_CreateString("layout"));
cJSON_AddItemToObject(obj, "name", cJSON_CreateString((char *)vvar));
cJSON_AddItemToObject(obj, "resIDS", resarray);
lg = (layout_group_t *) val;
name = switch_mprintf("group:%s", (char *)vvar);
-
+
for (vlnode = lg->layouts; vlnode; vlnode = vlnode->next) {
cJSON_AddItemToArray(grouparray, cJSON_CreateString(vlnode->vlayout->name));
}
-
+
cJSON_AddItemToObject(obj, "type", cJSON_CreateString("layoutGroup"));
cJSON_AddItemToObject(obj, "name", cJSON_CreateString(name));
cJSON_AddItemToObject(obj, "groupLayouts", grouparray);
const char *canvasstr = switch_event_get_header(fnode->fh.params, "canvas");
const char *loopsstr = switch_event_get_header(fnode->fh.params, "loops");
int canvas_id = -1;
-
+
if (loopsstr) {
fnode->loops = atoi(loopsstr);
}
member->loop_loop = 1;
-
- goto do_continue;
+
+ goto do_continue;
}
if (switch_test_flag(read_frame, SFF_CNG)) {
}
}
}
-
+
/* skip frames that are not actual media or when we are muted or silent */
if ((conference_utils_member_test_flag(member, MFLAG_TALKING) || member->energy_level == 0 || conference_utils_test_flag(member->conference, CFLAG_AUDIO_ALWAYS))
&& conference_utils_member_test_flag(member, MFLAG_CAN_SPEAK) && !conference_utils_test_flag(member->conference, CFLAG_WAIT_MOD)
if (!member->conference->la || !member->json || !member->status_field || conference_utils_member_test_flag(member, MFLAG_SECOND_SCREEN)) {
return;
}
-
+
switch_live_array_lock(member->conference->la);
if (!conference_utils_member_test_flag(member, MFLAG_CAN_SPEAK)) {
if (switch_channel_test_flag(member->channel, CF_VIDEO) || member->avatar_png_img) {
video = cJSON_CreateObject();
- if (conference_utils_member_test_flag(member, MFLAG_CAN_BE_SEEN) &&
+ if (conference_utils_member_test_flag(member, MFLAG_CAN_BE_SEEN) &&
member->video_layer_id > -1 && switch_core_session_media_flow(member->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_SENDONLY) {
cJSON_AddItemToObject(video, "visible", cJSON_CreateTrue());
} else {
switch_mutex_lock(conference->member_mutex);
for (member = conference->members; member; member = member->next) {
const char *check_var;
-
+
if (conference_utils_member_test_flag(member, MFLAG_NOCHANNEL)) {
continue;
}
switch_mutex_lock(member->audio_out_mutex);
lock_member(member);
switch_mutex_lock(conference->member_mutex);
-
+
if (member->rec) {
conference->recording_members++;
}
member->energy_level = id;
}
}
-
+
if ((var = switch_channel_get_variable_dup(member->channel, "video_initial_canvas", SWITCH_FALSE, -1))) {
uint32_t id = atoi(var) - 1;
if (id < conference->canvas_count) {
if ((var = switch_channel_get_variable_dup(member->channel, "video_initial_watching_canvas", SWITCH_FALSE, -1))) {
uint32_t id = atoi(var) - 1;
-
+
if (id == 0) {
id = conference->canvas_count;
}
-
+
if (id <= conference->canvas_count && conference->canvases[id]) {
member->watching_canvas_id = id;
}
}
-
+
conference_video_reset_member_codec_index(member);
if (has_video) {
if ((var = switch_channel_get_variable(member->channel, "rtp_video_max_bandwidth_in"))) {
member->max_bw_in = switch_parse_bandwidth_string(var);
}
-
+
if ((var = switch_channel_get_variable(member->channel, "rtp_video_max_bandwidth_out"))) {
member->max_bw_out = switch_parse_bandwidth_string(var);
}
}
}
-
+
switch_channel_set_variable_printf(channel, "conference_member_id", "%d", member->id);
switch_channel_set_variable_printf(channel, "conference_moderator", "%s", conference_utils_member_test_flag(member, MFLAG_MOD) ? "true" : "false");
switch_channel_set_variable_printf(channel, "conference_ghost", "%s", conference_utils_member_test_flag(member, MFLAG_GHOST) ? "true" : "false");
cJSON *dvars;
switch_event_t *var_event;
switch_event_header_t *hi;
-
+
member->json = cJSON_CreateArray();
cJSON_AddItemToArray(member->json, cJSON_CreateStringPrintf("%0.4d", member->id));
cJSON_AddItemToArray(member->json, cJSON_CreateString(switch_channel_get_variable(member->channel, "caller_id_number")));
for (hi = var_event->headers; hi; hi = hi->next) {
if (!strncasecmp(hi->name, "verto_dvar_", 11)) {
char *var = hi->name + 11;
-
+
if (var) {
cJSON_AddItemToObject(dvars, var, cJSON_CreateString(hi->value));
}
lock_member(member);
conference_utils_member_clear_flag(member, MFLAG_INTREE);
-
+
switch_safe_free(member->text_framedata);
member->text_framesize = 0;
if (member->text_buffer) {
member->frame_size = SWITCH_RECOMMENDED_BUFFER_SIZE;
member->frame = switch_core_alloc(member->pool, member->frame_size);
member->mux_frame = switch_core_alloc(member->pool, member->frame_size);
-
+
if (conference->canvases[0]) {
member->canvas_id = rec->canvas_id;
canvas = conference->canvases[member->canvas_id];
const char *val = NULL, *name = NULL, *bgimg = NULL;
switch_bool_t auto_3d = SWITCH_FALSE;
int border = 0;
-
+
if ((val = switch_xml_attr(x_layout, "name"))) {
name = val;
}
auto_3d = switch_true(switch_xml_attr(x_layout, "auto-3d-position"));
bgimg = switch_xml_attr(x_layout, "bgimg");
-
+
if ((val = switch_xml_attr(x_layout, "border"))) {
border = atoi(val);
if (border < 0) border = 0;
if ((val = switch_xml_attr(x_image, "x"))) {
x = atoi(val);
}
-
+
if ((val = switch_xml_attr(x_image, "y"))) {
y = atoi(val);
}
if ((val = switch_xml_attr(x_image, "floor-only"))) {
flooronly = floor = switch_true(val);
}
-
+
if ((val = switch_xml_attr(x_image, "file-only"))) {
fileonly = switch_true(val);
}
if ((val = switch_xml_attr(x_image, "audio-position"))) {
audio_position = val;
}
-
+
if ((val = switch_xml_attr(x_image, "border"))) {
border = atoi(val);
if (hscale == -1) {
hscale = scale;
}
-
+
if (!border) border = conference->video_border_size;
-
+
if (fileonly) {
floor = flooronly = 0;
}
vlayout->images[vlayout->layers].flooronly = flooronly;
vlayout->images[vlayout->layers].fileonly = fileonly;
vlayout->images[vlayout->layers].overlap = overlap;
-
-
+
+
if (res_id) {
vlayout->images[vlayout->layers].res_id = switch_core_strdup(conference->pool, res_id);
}
vlayout->images[vlayout->layers].audio_position = switch_core_strdup(conference->pool, audio_position);
}
}
-
+
vlayout->layers++;
}
layer->banner_patched = 0;
layer->refresh = 1;
-
+
}
void conference_video_reset_layer(mcu_layer_t *layer)
layer->bug_frame.img = NULL;
switch_thread_rwlock_unlock(layer->member->rwlock);
}
-
+
layer->bugged = 0;
}
if (!layer->img) {
layer->img = switch_img_alloc(NULL, SWITCH_IMG_FMT_I420, img_w, img_h, 1);
}
-
+
if (layer->banner_img && !layer->banner_patched) {
switch_img_fill(layer->canvas->img, layer->x_pos + layer->geometry.border, layer->y_pos + layer->geometry.border, layer->screen_w, layer->screen_h, &layer->canvas->letterbox_bgcolor);
switch_img_fit(&layer->banner_img, layer->screen_w, layer->screen_h, SWITCH_FIT_SIZE);
if (layer->geometry.border) {
switch_img_fill(IMG, x_pos, y_pos, img_w, img_h, &layer->canvas->border_color);
}
-
+
img_w -= (layer->geometry.border * 2);
img_h -= (layer->geometry.border * 2);
switch_img_scale(img, &layer->img, img_w, img_h);
- if (layer->img) {
+ if (layer->img) {
switch_img_patch(IMG, layer->img, x_pos + layer->geometry.border, y_pos + layer->geometry.border);
}
}
}
-
+
layer->last_img_addr = img_addr;
} else {
conference_video_release_canvas(&canvas);
}
}
-
+
return layer;
}
switch_mutex_unlock(canvas->mutex);
conference_video_release_canvas(&canvas);
-
+
*layer = NULL;
}
mcu_canvas_t *canvas = NULL;
switch_assert(canvasP);
-
+
canvas = *canvasP;
if (!canvas) return;
mcu_canvas_t *canvas = NULL;
if (member->canvas_id < 0) return;
-
+
if (!(canvas = conference_video_get_canvas_locked(member))) {
return;
}
if (member->video_layer_id < 0) {
goto end;
}
-
+
layer = &canvas->layers[member->video_layer_id];
if (layer->geometry.audio_position) {
if (conference_utils_test_flag(member->conference, CFLAG_JSON_STATUS)) {
conference_member_update_status_field(member);
}
-
+
if (canvas->bgimg) {
conference_video_set_canvas_bgimg(canvas, NULL);
}
switch_mutex_unlock(canvas->mutex);
conference_video_release_canvas(&canvas);
-
+
}
layer->idx = i;
layer->refresh = 1;
-
+
layer->screen_w = (uint32_t)(canvas->img->d_w * layer->geometry.scale / VIDEO_LAYOUT_SCALE);
layer->screen_h = (uint32_t)(canvas->img->d_h * layer->geometry.hscale / VIDEO_LAYOUT_SCALE);
if (conference->video_canvas_bgimg && !vlayout->bgimg) {
conference_video_set_canvas_bgimg(canvas, conference->video_canvas_bgimg);
}
-
+
switch_mutex_unlock(canvas->mutex);
switch_thread_rwlock_unlock(canvas->video_rwlock);
} else {
scaled = 1;
}
-
+
if (!canvas->bgimg) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot open image for bgimg\n");
return SWITCH_STATUS_FALSE;
for (vlnode = lg->layouts; vlnode; vlnode = vlnode->next) {
int x, file_layers = 0, member_count = (int)count - file_count, total = vlnode->vlayout->layers;
-
+
for (x = total; x >= 0; x--) {
if (vlnode->vlayout->images[x].fileonly) {
file_layers++;
} else {
vlayout = switch_core_hash_find(conference->layout_hash, video_layout_name);
}
-
+
return vlayout;
}
if (member->canvas_id > -1 && member->video_layer_id > -1) {
mcu_layer_t *layer = NULL;
mcu_canvas_t *canvas = NULL;
-
+
if ((canvas = conference_video_get_canvas_locked(member))) {
-
+
switch_mutex_lock(canvas->mutex);
layer = &canvas->layers[member->video_layer_id];
switch_img_free(&layer->mute_img);
if (canvas->layout_floor_id > -1) {
idx = canvas->layout_floor_id;
xlayer = &canvas->layers[idx];
-
+
if (xlayer->fnode && xlayer->fnode != fnode) {
idx = -1;
}
} else {
pop_status = switch_frame_buffer_pop(member->fb, &pop);
}
-
+
if (pop_status == SWITCH_STATUS_SUCCESS) {
mcu_layer_t *layer = NULL;
mcu_canvas_t *canvas = NULL;
if (!pop) {
break;
}
-
+
if (loops == 0 || loops == 50) {
switch_core_media_gen_key_frame(member->session);
switch_core_session_request_video_refresh(member->session);
}
loops++;
-
+
if ((switch_size_t)pop != 1) {
frame = (switch_frame_t *) pop;
if (switch_test_flag(frame, SFF_ENCODED)) {
if (!switch_test_flag(frame, SFF_ENCODED) || frame->m) {
switch_time_t now = switch_time_now();
-
+
if (last) {
int delta = (int)(now - last);
if (delta > member->conference->video_fps.ms * 5000) {
- switch_core_session_request_video_refresh(member->session);
+ switch_core_session_request_video_refresh(member->session);
}
}
last = now;
-
+
}
switch_frame_buffer_free(member->fb, &frame);
}
- canvas = NULL;
+ canvas = NULL;
layer = NULL;
patched = 0;
if (!imember->rec) {
continue;
}
-
+
if (!conference_utils_test_flag(conference, CFLAG_PERSONAL_CANVAS) && canvas && imember->canvas_id != canvas->canvas_id) {
continue;
}
canvas = conference_video_get_canvas_locked(member);
if (conference_utils_test_flag(member->conference, CFLAG_VIDEO_REQUIRED_FOR_CANVAS) &&
- (!switch_channel_test_flag(member->channel, CF_VIDEO_READY) ||
+ (!switch_channel_test_flag(member->channel, CF_VIDEO_READY) ||
(switch_core_session_media_flow(member->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_SENDONLY ||
switch_core_session_media_flow(member->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_INACTIVE))) {
-
+
if (canvas) {
conference_video_release_canvas(&canvas);
}
member->avatar_patched = 0;
- if (!force && switch_channel_test_flag(member->channel, CF_VIDEO_READY) &&
+ if (!force && switch_channel_test_flag(member->channel, CF_VIDEO_READY) &&
switch_core_session_media_flow(member->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_SENDONLY && switch_core_session_media_flow(member->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_INACTIVE) {
conference_utils_member_set_flag_locked(member, MFLAG_ACK_VIDEO);
switch_core_session_request_video_refresh(member->session);
mcu_layer_t *layer = &canvas->layers[fnode->layer_id];
switch_frame_t file_frame = { 0 };
switch_status_t status = switch_core_file_read_video(&fnode->fh, &file_frame, SVR_FLUSH);
-
+
if (status == SWITCH_STATUS_SUCCESS) {
switch_img_free(&layer->cur_img);
layer->cur_img = file_frame.img;
void conference_video_fnode_check(conference_file_node_t *fnode, int canvas_id) {
mcu_canvas_t *canvas = NULL;
-
+
if (switch_core_file_has_video(&fnode->fh, SWITCH_TRUE) && switch_core_file_read_video(&fnode->fh, NULL, SVR_CHECK) == SWITCH_STATUS_BREAK) {
int full_screen = 0;
char *res_id = NULL;
}
fnode->canvas_id = canvas_id;
}
-
+
canvas = fnode->conference->canvases[fnode->canvas_id];
if (fnode->fh.params && fnode->conference->canvas_count == 1) {
full_screen = switch_true(switch_event_get_header(fnode->fh.params, "full-screen"));
if (!layer &&
(canvas->layers_used < canvas->total_layers ||
(avatar_layers && !member->avatar_png_img) || conference_utils_member_test_flag(member, MFLAG_MOD)) &&
- (member->avatar_png_img || (switch_core_session_media_flow(member->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_SENDONLY &&
+ (member->avatar_png_img || (switch_core_session_media_flow(member->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_SENDONLY &&
switch_core_session_media_flow(member->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_INACTIVE))) {
/* find an empty layer */
//if (member->avatar_png_img && switch_channel_test_flag(member->channel, CF_VIDEO_READY) && conference_utils_member_test_flag(member, MFLAG_ACK_VIDEO)) {
// switch_img_free(&member->avatar_png_img);
//}
-
+
if (switch_channel_test_flag(member->channel, CF_VIDEO_READY)) {
do {
if (switch_queue_trypop(member->video_queue, &pop) == SWITCH_STATUS_SUCCESS && pop) {
size = switch_queue_size(member->video_queue);
} while(size > 0);
- if (conference_utils_member_test_flag(member, MFLAG_CAN_BE_SEEN) &&
- member->video_layer_id > -1 &&
+ if (conference_utils_member_test_flag(member, MFLAG_CAN_BE_SEEN) &&
+ member->video_layer_id > -1 &&
switch_core_session_media_flow(member->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_SENDONLY &&
switch_core_session_media_flow(member->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_INACTIVE
) {
switch_vid_params_t vid_params = { 0 };
-
+
switch_core_media_get_vid_params(member->session, &vid_params);
if (!vid_params.fps) {
if ((member->good_img % (int)(vid_params.fps * 10)) == 0) {
conference_video_reset_video_bitrate_counters(member);
}
-
+
if (member->auto_avatar && member->good_img > vid_params.fps * 3) {
conference_video_check_flush(member, SWITCH_TRUE);
}
if (!force && kps < member->managed_kps && member->conference->auto_kps_debounce) {
member->auto_kps_debounce_ticks = member->conference->auto_kps_debounce / member->conference->video_fps.ms;
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "%s setting bitrate debounce timer to %dms\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "%s setting bitrate debounce timer to %dms\n",
switch_channel_get_name(member->channel), member->conference->auto_kps_debounce);
member->managed_kps = kps;
member->managed_kps_set = 0;
msg.message_id = SWITCH_MESSAGE_INDICATE_BITRATE_REQ;
msg.numeric_arg = kps * 1024;
msg.from = __FILE__;
-
- switch_core_session_receive_message(member->session, &msg);
+
+ switch_core_session_receive_message(member->session, &msg);
member->managed_kps_set = 1;
member->managed_kps = kps;
conference_video_set_max_incoming_bitrate_member(imember, kps);
}
}
- switch_mutex_unlock(conference->member_mutex);
+ switch_mutex_unlock(conference->member_mutex);
}
void conference_video_set_absolute_incoming_bitrate(conference_obj_t *conference, int kps)
conference_video_set_absolute_incoming_bitrate_member(imember, kps);
}
}
- switch_mutex_unlock(conference->member_mutex);
+ switch_mutex_unlock(conference->member_mutex);
}
void conference_video_check_auto_bitrate(conference_member_t *member, mcu_layer_t *layer)
int kps = 0, kps_in = 0;
int max = 0;
int min_layer = 0, min = 0;
-
- if (!conference_utils_test_flag(member->conference, CFLAG_MANAGE_INBOUND_VIDEO_BITRATE) ||
+
+ if (!conference_utils_test_flag(member->conference, CFLAG_MANAGE_INBOUND_VIDEO_BITRATE) ||
switch_channel_test_flag(member->channel, CF_VIDEO_BITRATE_UNMANAGABLE)) {
return;
}
}
return;
}
-
+
if (vid_params.width != member->vid_params.width || vid_params.height != member->vid_params.height) {
switch_core_session_request_video_refresh(member->session);
conference_video_clear_managed_kps(member);
return;
}
- if ((kps_in = switch_calc_bitrate(vid_params.width, vid_params.height,
+ if ((kps_in = switch_calc_bitrate(vid_params.width, vid_params.height,
member->conference->video_quality, (int)(member->conference->video_fps.fps))) < 512) {
kps_in = 512;
}
min_layer = kps / 2;
min = kps_in / 2;
-
+
if (min_layer > min) min = min_layer;
-
+
if (member->conference->max_bw_in) {
max = member->conference->max_bw_in;
} else {
for (i = 0; i < canvas->total_layers; i++) {
mcu_layer_t *layer = &canvas->layers[i];
-
+
if (layer->need_patch) {
if (layer->member_id && layer->member && conference_utils_member_test_flag(layer->member, MFLAG_RUNNING) && layer->member->fb) {
switch_frame_buffer_trypush(layer->member->fb, (void *) 1);
layer->avatar_patched = 0;
switch_img_free(&layer->banner_img);
switch_img_free(&layer->logo_img);
-
+
if (layer->geometry.audio_position) {
conference_api_sub_position(member, NULL, layer->geometry.audio_position);
}
-
+
if (member->channel) {
var = NULL;
if (member->video_banner_text ||
(var = switch_channel_get_variable_dup(member->channel, "video_banner_text", SWITCH_FALSE, -1))) {
conference_video_layer_set_banner(member, layer, var);
}
-
+
var = NULL;
if (member->video_logo ||
(var = switch_channel_get_variable_dup(member->channel, "video_logo_path", SWITCH_FALSE, -1))) {
}
}
}
-
+
layer->member_id = member->id;
}
canvas->video_layout_group = conference->video_layout_group;
packet = switch_core_alloc(conference->pool, SWITCH_RTP_MAX_BUF_LEN);
-
+
while (conference_globals.running && !conference_utils_test_flag(conference, CFLAG_DESTRUCT) && conference_utils_test_flag(conference, CFLAG_VIDEO_MUXING)) {
switch_bool_t need_refresh = SWITCH_FALSE, send_keyframe = SWITCH_FALSE, need_reset = SWITCH_FALSE;
switch_time_t now;
int no_muted = conference_utils_test_flag(imember->conference, CFLAG_VIDEO_MUTE_EXIT_CANVAS);
int no_av = conference_utils_test_flag(imember->conference, CFLAG_VIDEO_REQUIRED_FOR_CANVAS);
int seen = conference_utils_member_test_flag(imember, MFLAG_CAN_BE_SEEN);
-
- if (imember->channel && switch_channel_ready(imember->channel) && switch_channel_test_flag(imember->channel, CF_VIDEO_READY) &&
+
+ if (imember->channel && switch_channel_ready(imember->channel) && switch_channel_test_flag(imember->channel, CF_VIDEO_READY) &&
!conference_utils_member_test_flag(imember, MFLAG_SECOND_SCREEN) &&
conference_utils_member_test_flag(imember, MFLAG_RUNNING) && (!no_muted || seen) && (!no_av || (no_av && !imember->avatar_png_img))
&& imember->canvas_id == canvas->canvas_id && imember->video_media_flow != SWITCH_MEDIA_FLOW_SENDONLY && imember->video_media_flow != SWITCH_MEDIA_FLOW_INACTIVE) {
video_count++;
}
-
+
}
if (members_with_avatar != conference->members_with_avatar) {
count_changed = 1;
}
-
+
if (conference_utils_test_flag(conference, CFLAG_REFRESH_LAYOUT)) {
count_changed = 1;
conference_utils_clear_flag(conference, CFLAG_REFRESH_LAYOUT);
if (count_changed && !personal) {
layout_group_t *lg = NULL;
video_layout_t *vlayout = NULL;
-
+
if (canvas->video_layout_group && (lg = switch_core_hash_find(conference->layout_group_hash, canvas->video_layout_group))) {
if ((vlayout = conference_video_find_best_layout(conference, lg, canvas->video_count, file_count)) && vlayout != canvas->vlayout) {
switch_mutex_lock(conference->member_mutex);
continue;
}
- if (conference_utils_test_flag(imember->conference, CFLAG_VIDEO_MUTE_EXIT_CANVAS) &&
+ if (conference_utils_test_flag(imember->conference, CFLAG_VIDEO_MUTE_EXIT_CANVAS) &&
!conference_utils_member_test_flag(imember, MFLAG_CAN_BE_SEEN) && imember->video_layer_id > -1) {
conference_video_detach_video_layer(imember);
switch_img_free(&imember->video_mute_img);
-
+
if (imember->id == imember->conference->video_floor_holder) {
conference_video_set_floor_holder(conference, NULL, SWITCH_FALSE);
} else if (imember->id == imember->conference->last_video_floor_holder) {
conference->last_video_floor_holder = 0;
}
-
+
switch_core_session_rwunlock(imember->session);
continue;
}
}
if (!layer->mute_patched) {
-
+
if (!imember->video_mute_img) {
conference_video_vmute_snap(imember, SWITCH_FALSE);
}
-
+
if (imember->video_mute_img || layer->mute_img) {
conference_video_clear_layer(layer);
-
- if (!layer->mute_img) {
+
+ if (!layer->mute_img) {
if (imember->video_mute_img) {
//layer->mute_img = switch_img_read_png(imember->video_mute_png, SWITCH_IMG_FMT_I420);
switch_img_copy(imember->video_mute_img, &layer->mute_img);
layout_group_t *lg = NULL;
video_layout_t *vlayout = NULL;
conference_member_t *omember;
-
+
if (video_key_freq && (now - last_key_time) > video_key_freq) {
send_keyframe = SWITCH_TRUE;
last_key_time = now;
switch_mutex_lock(conference->member_mutex);
for (imember = conference->members; imember; imember = imember->next) {
-
+
if (!imember->rec &&
(!imember->session || !switch_channel_test_flag(imember->channel, CF_VIDEO_READY) ||
switch_core_session_read_lock(imember->session) != SWITCH_STATUS_SUCCESS)) {
conference_video_init_canvas_layers(conference, imember->canvas, conference->new_personal_vlayout);
layout_applied++;
}
-
+
if (imember->channel && switch_channel_test_flag(imember->channel, CF_VIDEO_REFRESH_REQ)) {
switch_channel_clear_flag(imember->channel, CF_VIDEO_REFRESH_REQ);
send_keyframe = SWITCH_TRUE;
}
-
+
if (count_changed) {
int total = last_video_count;
int kps;
total += conference->members_with_avatar;
}
- if (total > 0 &&
- (!conference_utils_test_flag(imember->conference, CFLAG_VIDEO_MUTE_EXIT_CANVAS) ||
- conference_utils_member_test_flag(imember, MFLAG_CAN_BE_SEEN)) &&
+ if (total > 0 &&
+ (!conference_utils_test_flag(imember->conference, CFLAG_VIDEO_MUTE_EXIT_CANVAS) ||
+ conference_utils_member_test_flag(imember, MFLAG_CAN_BE_SEEN)) &&
imember->session && switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_SENDONLY &&
imember->session && switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_INACTIVE) {
-
+
total--;
}
if (conference->members_with_video == 1 && file_count) {
total = 0;
}
-
+
if (canvas->video_layout_group && (lg = switch_core_hash_find(conference->layout_group_hash, canvas->video_layout_group))) {
if ((vlayout = conference_video_find_best_layout(conference, lg, total + file_count, file_count))) {
conference_video_init_canvas_layers(conference, imember->canvas, vlayout);
}
}
-
- if (imember->channel && !switch_channel_test_flag(imember->channel, CF_VIDEO_BITRATE_UNMANAGABLE) &&
+
+ if (imember->channel && !switch_channel_test_flag(imember->channel, CF_VIDEO_BITRATE_UNMANAGABLE) &&
conference_utils_test_flag(conference, CFLAG_MANAGE_INBOUND_VIDEO_BITRATE)) {
switch_core_media_get_vid_params(imember->session, &vid_params);
kps = switch_calc_bitrate(vid_params.width, vid_params.height, conference->video_quality, (int)(imember->conference->video_fps.fps));
conference_video_set_incoming_bitrate(imember, kps, SWITCH_TRUE);
}
}
-
+
if (imember->session && switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_SENDONLY && switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_INACTIVE) {
conference_video_pop_next_image(imember, &imember->pcanvas_img);
}
}
switch_mutex_lock(conference->mutex);
-
+
if (check_async_file && conference->async_fnode) {
switch_status_t st = switch_core_file_read_video(&conference->async_fnode->fh, &file_frame, SVR_FLUSH);
-
+
if (st == SWITCH_STATUS_SUCCESS) {
if ((async_file_img = file_frame.img)) {
switch_img_free(&file_imgs[j]);
for (imember = conference->members; imember; imember = imember->next) {
int i = 0;
mcu_layer_t *floor_layer = NULL;
-
- if (!imember->rec &&
+
+ if (!imember->rec &&
(!imember->session || !switch_channel_test_flag(imember->channel, CF_VIDEO) || !imember->canvas ||
(switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_SENDONLY ||
switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_INACTIVE) ||
if (!file_count && imember->canvas->layout_floor_id > -1 && imember->conference->video_floor_holder &&
imember->id != imember->conference->video_floor_holder) {
-
+
if ((omember = conference_member_get(imember->conference, imember->conference->video_floor_holder))) {
if (conference->members_with_video + conference->members_with_avatar == 1 || imember != omember) {
layer = &imember->canvas->layers[imember->canvas->layout_floor_id];
floor_layer = layer;
layer = NULL;
}
-
+
switch_thread_rwlock_unlock(omember->rwlock);
}
}
-
+
for (omember = conference->members; omember; omember = omember->next) {
mcu_layer_t *layer = NULL;
switch_image_t *use_img = NULL;
switch_core_session_media_flow(omember->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_SENDONLY || switch_core_session_media_flow(omember->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_INACTIVE) {
continue;
}
-
+
if (conference->members_with_video + conference->members_with_avatar != 1 && imember == omember) {
continue;
}
if (file_count && (conference->members_with_video + conference->members_with_avatar == 1)) {
floor_layer = NULL;
}
-
+
if (!file_count && floor_layer && omember->id == conference->video_floor_holder) {
layer = floor_layer;
} else {
i++;
}
}
-
+
if (i < imember->canvas->total_layers) {
layer = &imember->canvas->layers[i++];
}
}
use_img = omember->pcanvas_img;
-
+
if (files_playing && layer && layer == &imember->canvas->layers[imember->canvas->layout_floor_id]) {
use_img = NULL;
}
-
+
if (layer) {
if (use_img && !omember->avatar_png_img) {
conference_video_scale_and_patch(layer, img, SWITCH_FALSE);
}
}
-
+
if (imember->session) {
switch_core_session_rwunlock(imember->session);
}
for (imember = conference->members; imember; imember = imember->next) {
switch_frame_t *dupframe;
- if (!imember->rec &&
+ if (!imember->rec &&
(!imember->session || !switch_channel_test_flag(imember->channel, CF_VIDEO_READY) || !imember->canvas ||
switch_core_session_read_lock(imember->session) != SWITCH_STATUS_SUCCESS)) {
continue;
}
write_frame.img = imember->canvas->img;
-
+
if (imember->rec) {
switch_core_file_write_video(&imember->rec->fh, &write_frame);
} else {
switch_mutex_unlock(conference->member_mutex);
} else {
-
+
if (conference->async_fnode && (conference->async_fnode->canvas_id == canvas->canvas_id || conference->async_fnode->canvas_id == -1)) {
if (conference->async_fnode->layer_id > -1) {
conference_video_patch_fnode(canvas, conference->async_fnode);
} else if (file_img) {
switch_img_free(&file_img);
}
-
+
write_frame.img = write_img;
wait_for_canvas(canvas);
-
+
if (canvas->recording) {
conference_video_check_recording(conference, canvas, &write_frame);
}
timestamp, need_refresh, send_keyframe, need_reset);
if (canvas->video_write_bandwidth) {
- switch_core_codec_control(&write_codecs[i]->codec, SCC_VIDEO_BANDWIDTH,
+ switch_core_codec_control(&write_codecs[i]->codec, SCC_VIDEO_BANDWIDTH,
SCCT_INT, &canvas->video_write_bandwidth, SCCT_NONE, NULL, NULL, NULL);
canvas->video_write_bandwidth = 0;
}
}
}
-
+
switch_mutex_lock(conference->member_mutex);
for (imember = conference->members; imember; imember = imember->next) {
switch_frame_t *dupframe;
switch_core_session_read_lock(imember->session) != SWITCH_STATUS_SUCCESS) {
continue;
}
-
+
if (need_refresh) {
switch_core_session_request_video_refresh(imember->session);
}
conference_video_write_canvas_image_to_codec_group(conference, canvas, write_codecs[i], i, timestamp, need_refresh, send_keyframe, need_reset);
if (canvas->video_write_bandwidth) {
- switch_core_codec_control(&write_codecs[i]->codec, SCC_VIDEO_BANDWIDTH,
+ switch_core_codec_control(&write_codecs[i]->codec, SCC_VIDEO_BANDWIDTH,
SCCT_INT, &canvas->video_write_bandwidth, SCCT_NONE, NULL, NULL, NULL);
canvas->video_write_bandwidth = 0;
}
continue;
}
-
+
if (!imember->session || !switch_channel_test_flag(imember->channel, CF_VIDEO_READY) ||
switch_core_session_read_lock(imember->session) != SWITCH_STATUS_SUCCESS) {
continue;
}
conference_video_release_canvas(&canvas);
}
-
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Adding video floor %s\n",
switch_channel_get_name(member->channel));
if (want_refresh) {
for (imember = conference->members; imember; imember = imember->next) {
switch_core_session_t *isession = imember->session;
-
+
if (!isession || switch_core_session_read_lock(isession) != SWITCH_STATUS_SUCCESS) {
continue;
}
-
+
if (switch_channel_test_flag(imember->channel, CF_VIDEO_READY) ) {
- switch_core_session_request_video_refresh(imember->session);
+ switch_core_session_request_video_refresh(imember->session);
}
-
+
switch_core_session_rwunlock(isession);
}
}
if (conference_utils_test_flag(member->conference, CFLAG_VIDEO_MUXING)) {
switch_image_t *img_copy = NULL;
- if (frame->img && (member->video_layer_id > -1 || member->canvas) &&
+ if (frame->img && (member->video_layer_id > -1 || member->canvas) &&
conference_utils_member_test_flag(member, MFLAG_CAN_BE_SEEN) &&
switch_queue_size(member->video_queue) < member->conference->video_fps.fps * 2 &&
!member->conference->playing_video_file) {
} else {
switch_img_copy(frame->img, &img_copy);
}
-
+
if (switch_queue_trypush(member->video_queue, img_copy) != SWITCH_STATUS_SUCCESS) {
switch_img_free(&img_copy);
}
const char *caller_id_name = switch_channel_get_variable(imember->channel, "caller_id_name");
unsigned char CR[3] = TEXT_UNICODE_LINEFEED;
-
+
switch_mutex_lock(imember->text_mutex);
framedatalen = strlen(imember->text_framedata) + strlen(caller_id_name) + 6;
switch_zmalloc(framedata, framedatalen);
-
+
switch_snprintf(framedata, framedatalen, "%s::\n%s", caller_id_name, imember->text_framedata);
memcpy(framedata + strlen(framedata), CR, sizeof(CR));
-
+
frame.data = framedata;
frame.datalen = framedatalen;
switch_core_session_write_text_frame(omember->session, &frame, 0, 0);
}
}
-
+
free(framedata);
-
+
imember->text_framedata[0] = '\0';
switch_mutex_unlock(imember->text_mutex);
if (conference_utils_member_test_flag(imember, MFLAG_RUNNING) && imember->session) {
switch_channel_t *channel = switch_core_session_get_channel(imember->session);
switch_media_flow_t video_media_flow;
-
+
if ((!floor_holder || (imember->score_iir > SCORE_IIR_SPEAKING_MAX && (floor_holder->score_iir < SCORE_IIR_SPEAKING_MIN)))) {// &&
//(!conference_utils_test_flag(conference, CFLAG_VID_FLOOR) || switch_channel_test_flag(channel, CF_VIDEO))) {
floor_holder = imember;
}
}
- if (switch_channel_ready(channel) &&
- switch_channel_test_flag(channel, CF_VIDEO_READY) &&
- imember->video_media_flow != SWITCH_MEDIA_FLOW_SENDONLY &&
- !conference_utils_member_test_flag(imember, MFLAG_SECOND_SCREEN) &&
- (!conference_utils_test_flag(conference, CFLAG_VIDEO_MUTE_EXIT_CANVAS) ||
+ if (switch_channel_ready(channel) &&
+ switch_channel_test_flag(channel, CF_VIDEO_READY) &&
+ imember->video_media_flow != SWITCH_MEDIA_FLOW_SENDONLY &&
+ !conference_utils_member_test_flag(imember, MFLAG_SECOND_SCREEN) &&
+ (!conference_utils_test_flag(conference, CFLAG_VIDEO_MUTE_EXIT_CANVAS) ||
conference_utils_member_test_flag(imember, MFLAG_CAN_BE_SEEN))) {
members_with_video++;
}
- if (switch_channel_ready(channel) &&
- switch_channel_test_flag(channel, CF_VIDEO_READY) &&
- imember->video_media_flow != SWITCH_MEDIA_FLOW_SENDONLY &&
+ if (switch_channel_ready(channel) &&
+ switch_channel_test_flag(channel, CF_VIDEO_READY) &&
+ imember->video_media_flow != SWITCH_MEDIA_FLOW_SENDONLY &&
!conference_utils_member_test_flag(imember, MFLAG_SECOND_SCREEN)) {
members_seeing_video++;
}
}
} else if (conference->fnode->type == NODE_TYPE_FILE) {
switch_core_file_read(&conference->fnode->fh, file_frame, &file_sample_len);
-
+
if (conference->fnode->fh.vol) {
switch_change_sln_volume_granular((void *)file_frame, (uint32_t)file_sample_len * conference->fnode->fh.channels,
conference->fnode->fh.vol);
if (--conference->fnode->loops < 0) {
conference->fnode->loops = -1;
}
-
+
if (conference->fnode->loops) {
uint32_t pos = 0;
switch_core_file_seek(&conference->fnode->fh, &pos, 0, SEEK_SET);
}
}
-
+
if (!conference->fnode->loops) {
conference->fnode->done++;
}
if (--conference->async_fnode->loops < 0) {
conference->async_fnode->loops = -1;
}
-
+
if (conference->async_fnode->loops) {
uint32_t pos = 0;
switch_core_file_seek(&conference->async_fnode->fh, &pos, 0, SEEK_SET);
}
}
-
+
if (!conference->async_fnode->loops) {
conference->async_fnode->done++;
}
memcpy(tmp, member->text_framedata, member->text_framesize);
switch_assert(tmp);
-
+
member->text_framesize = inuse + 1024;
-
+
free(member->text_framedata);
member->text_framedata = tmp;
}
bytes = switch_buffer_read(member->text_buffer, member->text_framedata, inuse);
- *(member->text_framedata + bytes) = '\0';
-
+ *(member->text_framedata + bytes) = '\0';
+
/*
for(p = member->text_framedata; p && *p; p++) {
if (*p > 32 && *p < 127) {
}
*/
}
-
+
switch_mutex_unlock(member->text_mutex);
return SWITCH_STATUS_SUCCESS;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "video-kps-debounce must be 0 or higher\n");
}
-
+
} else if (!strcasecmp(var, "video-mode") && !zstr(val)) {
if (!strcasecmp(val, "passthrough")) {
conference_video_mode = CONF_VIDEO_MODE_PASSTHROUGH;
if (!video_border_color) {
video_border_color = "#000000";
}
-
+
if (!video_super_canvas_bgcolor) {
video_super_canvas_bgcolor = "#068df3";
}
conference->no_video_avatar = switch_core_strdup(conference->pool, no_video_avatar);
}
-
+
conference->video_canvas_bgcolor = switch_core_strdup(conference->pool, video_canvas_bgcolor);
conference->video_border_color = switch_core_strdup(conference->pool, video_border_color);
conference->video_super_canvas_bgcolor = switch_core_strdup(conference->pool, video_super_canvas_bgcolor);
switch_live_array_set_command_handler(conference->la, conference_event_la_command_handler);
}
-
+
end:
switch_mutex_unlock(conference_globals.hash_mutex);
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Rupa Schomaker <rupa@rupa.com>
* Yossi Neiman <mishehu@freeswitch.org>
* Seven Du <dujinfang@gmail.com>
SWITCH_MODULE_RUNTIME_FUNCTION(mod_curl_runtime);
SWITCH_MODULE_LOAD_FUNCTION(mod_curl_load);
-/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
+/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
* Defines a switch_loadable_module_function_table_t and a static const char[] modname
*/
SWITCH_MODULE_DEFINITION(mod_curl, mod_curl_load, mod_curl_shutdown, NULL);
char *data = NULL;
char tmp[32], *f = NULL;
switch_curl_slist_t *header = http_data->headers;
-
+
if(!top || !headers) {
cJSON_Delete(headers);
-
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to alloc memory for cJSON structures.\n");
goto curl_json_output_end;
}
-
+
switch_snprintf(tmp, sizeof(tmp), "%ld", http_data->http_response_code);
cJSON_AddItemToObject(top, "status_code", cJSON_CreateString(tmp));
if (http_data->http_response) {
f = cJSON_PrintUnformatted(top);
data = switch_core_strdup(pool, f);
switch_safe_free(f);
-
+
curl_json_output_end:
cJSON_Delete(top); /* should free up all children */
return data;
{
register unsigned int realsize = (unsigned int) (size * nmemb);
http_sendfile_data_t *http_data = data;
-
+
if(http_data->sendfile_response_count + realsize < HTTP_SENDFILE_RESPONSE_SIZE)
{
// I'm not sure why we need the (realsize+1) here, but it truncates the data by 1 char if I don't do this
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Response page is more than %d bytes long, truncating.\n", HTTP_SENDFILE_RESPONSE_SIZE);
realsize = 0;
}
-
+
return realsize;
}
{
uint8_t count;
http_data->curl_handle = curl_easy_init();
-
+
if (!strncasecmp(http_data->url, "https", 5))
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Not verifying TLS cert for %s; connection is not secure\n", http_data->url);
curl_easy_setopt(http_data->curl_handle, CURLOPT_SSL_VERIFYPEER, 0);
curl_easy_setopt(http_data->curl_handle, CURLOPT_SSL_VERIFYHOST, 0);
}
-
- /* From the docs:
- * Optionally, you can provide data to POST using the CURLOPT_READFUNCTION and CURLOPT_READDATA
+
+ /* From the docs:
+ * Optionally, you can provide data to POST using the CURLOPT_READFUNCTION and CURLOPT_READDATA
* options but then you must make sure to not set CURLOPT_POSTFIELDS to anything but NULL
* curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDSIZE, strlen(data));
* curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDS, (void *) data);
*/
-
+
// switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Post data: %s\n", data);
-
+
curl_easy_setopt(http_data->curl_handle, CURLOPT_FOLLOWLOCATION, 1);
curl_easy_setopt(http_data->curl_handle, CURLOPT_MAXREDIRS, 15);
curl_easy_setopt(http_data->curl_handle, CURLOPT_URL, http_data->url);
curl_easy_setopt(http_data->curl_handle, CURLOPT_NOSIGNAL, 1);
curl_easy_setopt(http_data->curl_handle, CURLOPT_USERAGENT, "freeswitch-curl/1.0");
-
+
http_data->sendfile_response = switch_core_alloc(http_data->pool, sizeof(char) * HTTP_SENDFILE_RESPONSE_SIZE);
memset(http_data->sendfile_response, 0, sizeof(char) * HTTP_SENDFILE_RESPONSE_SIZE);
-
+
// Set the function where we will copy out the response body data to
curl_easy_setopt(http_data->curl_handle, CURLOPT_WRITEFUNCTION, http_sendfile_response_callback);
curl_easy_setopt(http_data->curl_handle, CURLOPT_WRITEDATA, (void *) http_data);
-
- /* Add the file to upload as a POST form field */
+
+ /* Add the file to upload as a POST form field */
curl_formadd(&http_data->formpost, &http_data->lastptr, CURLFORM_COPYNAME, http_data->filename_element_name, CURLFORM_FILE, http_data->filename_element, CURLFORM_END);
-
+
if(!zstr(http_data->extrapost_elements))
{
// Now to parse out the individual post element/value pairs
char *argv[64] = { 0 }; // Probably don't need 64 but eh does it really use that much memory?
uint32_t argc = 0;
char *temp_extrapost = switch_core_strdup(http_data->pool, http_data->extrapost_elements);
-
+
argc = switch_separate_string(temp_extrapost, '&', argv, (sizeof(argv) / sizeof(argv[0])));
-
+
for(count = 0; count < argc; count++)
{
char *argv2[4] = { 0 };
uint32_t argc2 = switch_separate_string(argv[count], '=', argv2, (sizeof(argv2) / sizeof(argv2[0])));
-
+
if(argc2 == 2) {
switch_url_decode(argv2[0]);
switch_url_decode(argv2[1]);
}
}
}
-
- /* Fill in the submit field too, even if this isn't really needed */
+
+ /* Fill in the submit field too, even if this isn't really needed */
curl_formadd(&http_data->formpost, &http_data->lastptr, CURLFORM_COPYNAME, "submit", CURLFORM_COPYCONTENTS, "or_die", CURLFORM_END);
-
- /* what URL that receives this POST */
+
+ /* what URL that receives this POST */
curl_easy_setopt(http_data->curl_handle, CURLOPT_HTTPPOST, http_data->formpost);
-
+
// This part actually fires off the curl, captures the HTTP response code, and then frees up the handle.
curl_easy_perform(http_data->curl_handle);
curl_easy_getinfo(http_data->curl_handle, CURLINFO_RESPONSE_CODE, &http_data->http_response_code);
-
+
curl_easy_cleanup(http_data->curl_handle);
-
+
// Clean up the form data from POST
curl_formfree(http_data->formpost);
}
else
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to create event to notify of failure to open file %s\n", http_data->filename_element);
}
-
+
if((switch_test_flag(http_data, CSO_STREAM) || switch_test_flag(http_data, CSO_NONE)) && http_data->stream)
http_data->stream->write_function(http_data->stream, "-Err Unable to open file %s\n", http_data->filename_element);
-
+
if(switch_test_flag(http_data, CSO_NONE) && !http_data->stream)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "curl_sendfile: Unable to open file %s\n", http_data->filename_element);
}
-
+
return retval;
}
char *code_as_string = switch_core_alloc(http_data->pool, 16);
memset(code_as_string, 0, 16);
switch_snprintf(code_as_string, 16, "%d", http_data->http_response_code);
-
+
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Command-Execution-Identifier", http_data->identifier_str);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Filename", http_data->filename_element);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "File-Access", "Success");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "REST-HTTP-Code", code_as_string);
switch_event_add_body(event, "%s", http_data->sendfile_response);
-
+
switch_event_fire(&event);
switch_event_destroy(&event);
}
else
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to create a event to report on success of curl_sendfile.\n");
}
-
+
if((switch_test_flag(http_data, CSO_STREAM) || switch_test_flag(http_data, CSO_NONE) || switch_test_flag(http_data, CSO_EVENT)) && http_data->stream)
{
if(http_data->http_response_code == 200)
http_data->stream->write_function(http_data->stream, "+200 Ok\n");
else
http_data->stream->write_function(http_data->stream, "-%d Err\n", http_data->http_response_code);
-
+
if(http_data->sendfile_response_count && switch_test_flag(http_data, CSO_STREAM))
http_data->stream->write_function(http_data->stream, "%s\n", http_data->sendfile_response);
}
-
+
if(switch_test_flag(http_data, CSO_NONE) && !http_data->stream)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Sending of file %s to url %s resulted with code %lu\n", http_data->filename_element, http_data->url, http_data->http_response_code);
}
http_sendfile_data_t *http_data = NULL;
switch_memory_pool_t *pool = switch_core_session_get_pool(session);
switch_channel_t *channel = switch_core_session_get_channel(session);
-
+
assert(channel != NULL);
-
+
http_data = switch_core_alloc(pool, sizeof(http_sendfile_data_t));
memset(http_data, 0, sizeof(http_sendfile_data_t));
-
+
http_data->pool = pool;
-
+
// Either the parameters are provided on the data="" or else they are provided as chanvars. No mixing & matching
if(!zstr(data))
{
http_data->mydata = switch_core_strdup(http_data->pool, data);
-
- if ((argc = switch_separate_string(http_data->mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))))
+
+ if ((argc = switch_separate_string(http_data->mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))))
{
uint8_t i = 0;
-
+
if (argc < 2 || argc > 5)
goto http_sendfile_app_usage;
-
+
http_data->url = switch_core_strdup(http_data->pool, argv[i++]);
-
+
switch_url_decode(argv[i]);
argc2 = switch_separate_string(argv[i++], '=', argv2, (sizeof(argv2) / sizeof(argv2[0])));
-
+
if(argc2 == 2)
{
http_data->filename_element_name = switch_core_strdup(pool, argv2[0]);
}
else
goto http_sendfile_app_usage;
-
+
if(argc > 2)
{
http_data->extrapost_elements = switch_core_strdup(pool, argv[i++]);
-
+
if(argc > 3)
{
if(!strncasecmp(argv[i++], "event", 5))
switch_set_flag(http_data, CSO_EVENT);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Setting output to event handler.\n");
}
-
+
if(argc > 4)
{
if(strncasecmp(argv[i], "uuid", 4))
{
char *send_output = (char *) switch_channel_get_variable_dup(channel, "curl_sendfile_report", SWITCH_TRUE, -1);
char *identifier = (char *) switch_channel_get_variable_dup(channel, "curl_sendfile_identifier", SWITCH_TRUE, -1);
-
+
http_data->url = (char *) switch_channel_get_variable_dup(channel, "curl_sendfile_url", SWITCH_TRUE, -1);
http_data->filename_element_name = (char *) switch_channel_get_variable_dup(channel, "curl_sendfile_filename_element", SWITCH_TRUE, -1);
http_data->filename_element = (char *) switch_channel_get_variable_dup(channel, "curl_sendfile_filename", SWITCH_TRUE, -1);
http_data->extrapost_elements = (char *) switch_channel_get_variable_dup(channel, "curl_sendfile_extrapost", SWITCH_TRUE, -1);
-
-
+
+
if(zstr(http_data->url) || zstr(http_data->filename_element) || zstr(http_data->filename_element_name))
goto http_sendfile_app_usage;
-
+
if(!zstr(send_output))
{
if(!strncasecmp(send_output, "event", 5))
switch_set_flag(http_data, CSO_NONE);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "No parameter specified for curl_sendfile_report. Setting default of 'none'.\n");
}
-
+
if(!zstr(identifier))
{
if(!strncasecmp(identifier, "uuid", 4))
http_data->identifier_str = identifier;
}
}
-
+
switch_url_decode(http_data->filename_element_name);
switch_url_decode(http_data->filename_element);
-
+
// We need to check the file now...
if(http_sendfile_test_file_open(http_data, event) != SWITCH_STATUS_SUCCESS)
goto http_sendfile_app_done;
-
+
switch_file_close(http_data->file_handle);
-
+
switch_url_decode(http_data->url);
-
+
http_sendfile_initialize_curl(http_data);
-
+
http_sendfile_success_report(http_data, event);
-
+
goto http_sendfile_app_done;
-
+
http_sendfile_app_usage:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failure: Usage: <data=\"%s\">\nOr you can set chanvars curl_senfile_url, curl_sendfile_filename_element, curl_sendfile_filename, curl_sendfile_extrapost\n", HTTP_SENDFILE_APP_SYNTAX);
-
+
http_sendfile_app_done:
if (http_data->headers)
{
switch_curl_slist_free_all(http_data->headers);
}
-
+
return;
}
http_sendfile_data_t *http_data = NULL;
switch_memory_pool_t *pool = NULL;
switch_event_t *event = NULL;
-
+
if(zstr(cmd))
{
status = SWITCH_STATUS_SUCCESS;
switch_core_new_memory_pool(&pool);
new_memory_pool = SWITCH_TRUE; // So we can properly destroy the memory pool
}
-
+
http_data = switch_core_alloc(pool, sizeof(http_sendfile_data_t));
memset(http_data, 0, sizeof(http_sendfile_data_t));
-
+
http_data->mydata = switch_core_strdup(pool, cmd);
http_data->stream = stream;
http_data->pool = pool;
-
- // stream->write_function(stream,"\ncmd is %s\nmydata is %s\n", cmd, http_data->mydata);
-
- if ((argc = switch_separate_string(http_data->mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))))
+
+ // stream->write_function(stream,"\ncmd is %s\nmydata is %s\n", cmd, http_data->mydata);
+
+ if ((argc = switch_separate_string(http_data->mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))))
{
uint8_t i = 0;
-
+
if (argc < 2 || argc > 5)
{
status = SWITCH_STATUS_SUCCESS;
goto http_sendfile_usage;
}
-
+
http_data->url = switch_core_strdup(pool, argv[i++]);
-
+
switch_url_decode(argv[i]);
argc2 = switch_separate_string(argv[i++], '=', argv2, (sizeof(argv2) / sizeof(argv2[0])));
-
+
if(argc2 == 2)
{
http_data->filename_element_name = switch_core_strdup(pool, argv2[0]);
}
else
goto http_sendfile_usage;
-
+
switch_url_decode(http_data->filename_element_name);
switch_url_decode(http_data->filename_element);
-
+
if(argc > 2)
{
http_data->extrapost_elements = switch_core_strdup(pool, argv[i++]);
-
+
if(argc > 3)
{
if(!strncasecmp(argv[i], "event", 5))
{
if(strncasecmp(argv[i], "none", 4))
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Invalid 4th parameter set for curl_sendfile. Defaulting to \"none\"\n");
-
+
switch_set_flag(http_data, CSO_NONE);
}
-
+
i++;
-
+
if(argc > 4)
http_data->identifier_str = switch_core_strdup(pool, argv[i++]);
}
}
}
-
+
// We need to check the file now...
if(http_sendfile_test_file_open(http_data, event) != SWITCH_STATUS_SUCCESS)
goto http_sendfile_done;
-
-
+
+
switch_file_close(http_data->file_handle);
-
+
switch_url_decode(http_data->url);
-
+
http_sendfile_initialize_curl(http_data);
-
+
http_sendfile_success_report(http_data, event);
-
+
status = SWITCH_STATUS_SUCCESS;
goto http_sendfile_done;
{
switch_curl_slist_free_all(http_data->headers);
}
-
+
if (new_memory_pool == SWITCH_TRUE)
{
switch_core_destroy_memory_pool(&pool);
}
-
+
return status;
}
SWITCH_ADD_API(api_interface, "curl", "curl API", curl_function, SYNTAX);
SWITCH_ADD_APP(app_interface, "curl", "Perform a http request", "Perform a http request",
curl_app_function, SYNTAX, SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
-
+
SWITCH_ADD_API(api_interface, "curl_sendfile", "curl_sendfile API", http_sendfile_function, HTTP_SENDFILE_SYNTAX);
SWITCH_ADD_APP(app_interface, "curl_sendfile", "Send a file and some optional post variables via HTTP", "Send a file and some optional post variables via HTTP",
http_sendfile_app_function, HTTP_SENDFILE_APP_SYNTAX, SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
{
switch_event_free_subclass(HTTP_SENDFILE_ACK_EVENT);
-
+
/* Cleanup dynamically allocated config settings */
return SWITCH_STATUS_SUCCESS;
}
switch_img_to_raw(frame->img, context->rawImage->imageData, context->rawImage->widthStep, SWITCH_IMG_FMT_RGB24);
detectAndDraw(context);
-
+
if (context->shape_idx && context->shape[0].w && context->last_shape[0].w) {
int max, min;
int pct;
-
+
if (context->shape[0].w > context->last_shape[0].w) {
max = context->shape[0].w;
min = context->last_shape[0].w;
}
pct = 100 - (((double)min / (double)max) * 100.0f );
-
+
if (pct > 25) {
context->detected.simo_count = 0;
memset(context->last_shape, 0, sizeof(context->last_shape[0]) * MAX_SHAPES);
flags = SMBF_VIDEO_PATCH;
}
- if ((status = switch_core_media_bug_add(rsession, function, NULL,
+ if ((status = switch_core_media_bug_add(rsession, function, NULL,
cv_bug_callback, context, 0, flags, &bug)) != SWITCH_STATUS_SUCCESS) {
stream->write_function(stream, "-ERR Failure!\n");
switch_thread_rwlock_unlock(MODULE_INTERFACE->rwlock);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MY_EVENT_VIDEO_DETECT);
return SWITCH_STATUS_TERM;
}
-
+
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
MODULE_INTERFACE = *module_interface;
{
switch_event_free_subclass(MY_EVENT_VIDEO_DETECT);
-
+
return SWITCH_STATUS_UNLOAD;
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Ken Rice <krice@freeswitch.org>
* Mathieu Rene <mathieu.rene@gmail.com>
{
switch_cache_db_handle_t *dbh = NULL;
char *dsn;
-
+
if (!zstr(globals.odbc_dsn)) {
dsn = globals.odbc_dsn;
} else {
if (switch_cache_db_get_db_handle_dsn(&dbh, dsn) != SWITCH_STATUS_SUCCESS) {
dbh = NULL;
}
-
+
return dbh;
}
cbt.len = len;
limit_execute_sql_callback(sql, sql2str_callback, &cbt);
-
+
return cbt.buf;
}
}
limit_execute_sql(sql);
switch_safe_free(sql);
-
+
return SWITCH_STATUS_SUCCESS;
}
char usagestr[128] = "";
int usage = 0;
char *sql = NULL;
-
+
sql = switch_mprintf("select count(hostname) from limit_data where realm='%q' and id='%q'", realm, resource);
limit_execute_sql2str(sql, usagestr, sizeof(usagestr));
switch_safe_free(sql);
usage = atoi(usagestr);
-
+
return usage;
}
sql = switch_mprintf("delete from limit_data where hostname='%q';", globals.hostname);
limit_execute_sql(sql);
switch_safe_free(sql);
-
+
return SWITCH_STATUS_SUCCESS;
}
char count[128] = "";
char *ret = NULL;
char *sql = NULL;
-
+
sql = switch_mprintf("select count(hostname) from limit_data where hostname='%q'", globals.hostname);
limit_execute_sql2str(sql, count, sizeof(count));
switch_safe_free(sql);
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
-
+
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Marc Olivier Chouinard <mochouinard at moctel dot com>
* Emmanuel Schmidbauer <e.schmidbauer@gmail.com>
*
{
switch_cache_db_handle_t *dbh = NULL;
char *dsn;
-
+
if (!zstr(globals.odbc_dsn)) {
dsn = globals.odbc_dsn;
} else {
if (switch_cache_db_get_db_handle_dsn(&dbh, dsn) != SWITCH_STATUS_SUCCESS) {
dbh = NULL;
}
-
+
return dbh;
}
sql = generate_sql_entry_for_user(session, ux, profile->use_number_alias);
switch_xml_free(ux);
}
-
+
} else {
sql = generate_sql_entry_for_user(session, ut, profile->use_number_alias);
}
sql = NULL;
}
}
-
+
if (++count >= 100) {
count = 0;
sql = switch_mprintf("BEGIN;%s;COMMIT;", sqlvalues);
switch_copy_string(s_param.profile, profile_name, 255);
switch_copy_string(s_param.domain, domain_name, 255);
- if (!(search_by = switch_channel_get_variable(channel, "directory_search_order"))) {
+ if (!(search_by = switch_channel_get_variable(channel, "directory_search_order"))) {
search_by = profile->search_order;
}
<?xml version="1.0" encoding="utf-8"?>
-<include>
+<include>
<extension name="test gateway distro">
<condition field="destination_number" expression="^(.*)$">
<action application="bridge" data="sofia/gateway/${distributor(test)}/$1"/>
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Neal Horman <neal at wanlink dot com>
*
SWITCH_MODULE_RUNTIME_FUNCTION(mod_distributor_runtime);
SWITCH_MODULE_LOAD_FUNCTION(mod_distributor_load);
-/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
+/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
* Defines a switch_loadable_module_function_table_t and a static const char[] modname
*/
SWITCH_MODULE_DEFINITION(mod_distributor, mod_distributor_load, mod_distributor_shutdown, NULL);
switch_zmalloc(node, sizeof(*node));
node->name = strdup(name_attr);
node->wval = tmp;
-
+
if (np) {
np->next = node;
} else {
for (;;) {
top:
-
+
if (++loops > 1000) {
break;
}
if (match) {
int i;
-
+
match->cur_weight++;
list->lastnode = match;
list->last = mx;
goto top;
}
}
-
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "Choose %s\n", match->name);
return match;
}
}
-
+
return NULL;
}
int argc = 0;
char *argv[100] = { 0 };
-
+
if ((except = strchr(myname, ' '))) {
*except++ = '\0';
argc = switch_split(except, ' ', argv);
*e++ = '\0';
if ((np = find_node(list, argv[i]))) {
int tmp = -1;
-
+
if (e) {
tmp = atoi(e);
}
}
}
}
-
+
err:
if (err) {
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2015, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Ken Rice <krice@freeswitch.org>
* Michael Murdock <mike at mmurdock dot org>
switch_channel_set_variable(channel, "last_non_matching_digits", match->match_digits);
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(use_session), SWITCH_LOG_DEBUG, "%s Digit NOT match binding [%s]\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(use_session), SWITCH_LOG_DEBUG, "%s Digit NOT match binding [%s]\n",
switch_channel_get_name(channel), match->match_digits);
if (switch_event_create_plain(&event, SWITCH_EVENT_CHANNEL_DATA) == SWITCH_STATUS_SUCCESS) {
if ((status = switch_core_session_queue_event(use_session, &event)) != SWITCH_STATUS_SUCCESS) {
switch_event_destroy(&event);
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(use_session), SWITCH_LOG_WARNING, "%s event queue failure.\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(use_session), SWITCH_LOG_WARNING, "%s event queue failure.\n",
switch_core_session_get_name(use_session));
}
}
/* send it back around and skip the dmachine */
switch_channel_queue_dtmf_string(channel, match->match_digits);
-
+
if (use_session != session) {
switch_core_session_rwunlock(use_session);
}
int x = 0;
char *flags = "";
- if (act->target == DIGIT_TARGET_PEER || act->target == DIGIT_TARGET_BOTH) {
+ if (act->target == DIGIT_TARGET_PEER || act->target == DIGIT_TARGET_BOTH) {
if (switch_core_session_get_partner(act->session, &use_session) != SWITCH_STATUS_SUCCESS) {
use_session = act->session;
}
switch_channel_set_variable(channel, "last_matching_digits", match->match_digits);
-
+
if (switch_event_create_plain(&event, SWITCH_EVENT_CHANNEL_DATA) == SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(act->session), SWITCH_LOG_DEBUG, "%s Digit match binding [%s][%s]\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(act->session), SWITCH_LOG_DEBUG, "%s Digit match binding [%s][%s]\n",
switch_channel_get_name(channel), act->string, act->value);
if (!strncasecmp(string, "exec", 4)) {
char *e;
-
+
string += 4;
if (*string == ':') {
string++;
if ((status = switch_core_session_queue_event(use_session, &event)) != SWITCH_STATUS_SUCCESS) {
switch_event_destroy(&event);
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(use_session), SWITCH_LOG_WARNING, "%s event queue failure.\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(use_session), SWITCH_LOG_WARNING, "%s event queue failure.\n",
switch_core_session_get_name(use_session));
}
}
switch_api_execute(string, act->value, NULL, &stream);
if (stream.data) {
switch_channel_set_variable(channel, "bind_digit_action_api_result", (char *)stream.data);
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(act->session), SWITCH_LOG_DEBUG, "%s Digit match binding [%s][%s] api executed, %s\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(act->session), SWITCH_LOG_DEBUG, "%s Digit match binding [%s][%s] api executed, %s\n",
switch_core_session_get_name(use_session), act->string, act->value, (char *)stream.data);
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(act->session), SWITCH_LOG_DEBUG, "%s Digit match binding [%s][%s] api executed\n",
}
switch_safe_free(stream.data);
}
-
+
if (use_session != act->session) {
switch_core_session_rwunlock(use_session);
if (!strcasecmp(target_str, "both")) {
return DIGIT_TARGET_BOTH;
}
-
+
return DIGIT_TARGET_SELF;
}
return;
}
-
+
if ((dmachine = switch_core_session_get_dmachine(session, target))) {
switch_ivr_dmachine_set_realm(dmachine, realm);
}
}
-static void bind_to_session(switch_core_session_t *session,
+static void bind_to_session(switch_core_session_t *session,
const char *arg0, const char *arg1, const char *arg2, const char *arg3,
switch_digit_action_target_t target, switch_digit_action_target_t bind_target)
{
if ((var = switch_channel_get_variable(channel, "bind_digit_digit_timeout"))) {
digit_timeout = switch_atoul(var);
}
-
+
if ((var = switch_channel_get_variable(channel, "bind_digit_input_timeout"))) {
input_timeout = switch_atoul(var);
}
-
+
switch_ivr_dmachine_create(&dmachine, "DPTOOLS", NULL, digit_timeout, input_timeout, NULL, digit_nomatch_action_callback, session);
switch_core_session_set_dmachine(session, dmachine, target);
}
-
+
act = switch_core_session_alloc(session, sizeof(*act));
act->realm = switch_core_session_strdup(session, arg0);
act->input = switch_core_session_strdup(session, arg1);
}
switch_ivr_dmachine_bind(dmachine, act->realm, act->input, is_priority, 0, digit_action_callback, act);
-
+
if ((terminators = switch_channel_get_variable(channel, "bda_terminators"))) {
switch_ivr_dmachine_set_terminators(dmachine, terminators);
}
msg.message_id = SWITCH_MESSAGE_INDICATE_KEEPALIVE;
msg.numeric_arg = seconds;
switch_core_session_receive_message(session, &msg);
-
+
switch_core_session_enable_heartbeat(session, seconds);
return;
}
switch_file_rename(argv[0], argv[1], switch_core_session_get_pool(session));
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s RENAME: %s %s\n",
switch_channel_get_name(switch_core_session_get_channel(session)), argv[0], argv[1]);
-
+
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Usage: %s\n", RENAME_SYNTAX);
}
char *argv[1] = { 0 };
int argc;
char *lbuf = NULL;
-
+
if (!zstr(data) && (lbuf = switch_core_session_strdup(session, data))
&& (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 1) {
switch_core_session_t *nsession = NULL;
switch_safe_free(e_data.uuid_list[x]);
}
e_data.total = 0;
-
+
if (switch_core_db_handle(&db) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Database Error!\n");
break;
return;
}
}
-
+
switch_channel_ring_ready(switch_core_session_get_channel(session));
}
id = switch_ivr_schedule_transfer(when, switch_core_session_get_uuid(session), argv[1], argv[2], argv[3]);
snprintf(ids, sizeof(ids), "%u", id);
- switch_channel_set_variable(switch_core_session_get_channel(session), "last_sched_id", ids);
+ switch_channel_set_variable(switch_core_session_get_channel(session), "last_sched_id", ids);
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Invalid Args\n");
}
{
switch_channel_t *channel = switch_core_session_get_channel(session);
const char *arg = (char *) data;
-
+
if (!zstr(arg)) {
if (switch_stristr("is_conference", arg)) {
switch_channel_set_flag(channel, CF_CONFERENCE);
expanded = switch_channel_expand_variables(channel, val);
}
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s %s [%s]=[%s]\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s %s [%s]=[%s]\n",
what, switch_channel_get_name(channel), var, expanded ? expanded : "UNDEF");
-
+
switch_channel_add_variable_var_check(channel, var, expanded, SWITCH_FALSE, stack);
if (expanded && expanded != val) {
arg = switch_core_session_strdup(session, arg);
argc = switch_split(arg, delim, array);
-
+
for(i = 0; i < argc; i++) {
base_set(session, array[i], SWITCH_STACK_BOTTOM);
}
-
+
} else {
base_set(session, data, SWITCH_STACK_BOTTOM);
if (!zstr(q) && (p = strchr(q, '|'))) {
*p++ = '\0';
-
+
thetime = switch_time_make(atol(q), 0);
q = p + 1;
} else {
/********************************************************************************/
/*
- dtmf handler function you can hook up to be executed when a digit is dialed during 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 bridge_on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
if (!zstr(bond)) {
switch_core_session_t *b_session;
-
+
if ((b_session = switch_core_session_locate(bond))) {
switch_channel_t *b_channel = switch_core_session_get_channel(b_session);
if (switch_channel_up(b_channel)) {
valid_terminators = "#";
}
- switch_ivr_read(session, min_digits, max_digits, prompt_audio_file, var_name, digit_buffer, sizeof(digit_buffer), timeout, valid_terminators,
+ switch_ivr_read(session, min_digits, max_digits, prompt_audio_file, var_name, digit_buffer, sizeof(digit_buffer), timeout, valid_terminators,
digit_timeout);
}
}
switch_play_and_get_digits(session, min_digits, max_digits, max_tries, timeout, valid_terminators,
- prompt_audio_file, bad_input_audio_file, var_name, digit_buffer, sizeof(digit_buffer),
+ prompt_audio_file, bad_input_audio_file, var_name, digit_buffer, sizeof(digit_buffer),
digits_regex, digit_timeout, transfer_on_failure);
}
int ovector[30] = {0};
char *lbuf;
int proceed;
-
+
if (!zstr(data) && (lbuf = switch_core_session_strdup(session, data))
&& (argc = switch_separate_string(lbuf, '|', argv, (sizeof(argv) / sizeof(argv[0])))) == 3) {
if ((proceed = switch_regex_perform(argv[1], argv[2], &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
switch_regex_safe_free(re);
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No data specified.\n");
- }
+ }
}
SWITCH_STANDARD_APP(record_function)
path = switch_core_session_strdup(session, data);
- /* Search for a space then a plus followed by only numbers at the end of the path,
+ /* Search for a space then a plus followed by only numbers at the end of the path,
if found trim any spaces to the left/right of the plus use the left side as the
path and right side as a time limit on the recording
*/
moh = switch_channel_get_hold_music(caller_channel);
}
- if (!zstr(moh) && !strcasecmp(moh, "silence")) {
+ if (!zstr(moh) && !strcasecmp(moh, "silence")) {
moh = NULL;
}
if (fail) {
int64_t wait = (int64_t)campon_sleep * 1000000;
-
+
while (stake.running && wait > 0 && switch_channel_ready(caller_channel)) {
switch_yield(100000);
wait -= 100000;
}
}
- status = switch_ivr_originate(NULL, &peer_session,
- &cause, camp_data, campon_timeout, NULL, NULL, NULL, NULL, NULL, SOF_NONE,
+ status = switch_ivr_originate(NULL, &peer_session,
+ &cause, camp_data, campon_timeout, NULL, NULL, NULL, NULL, NULL, SOF_NONE,
switch_channel_get_cause_ptr(caller_channel));
switch_event_t *event;
int count;
-
+
dup_key_name = strdup(key_name);
key_name = dup_key_name;
if ((domain_name = strchr(dup_key_name, '@'))) {
*domain_name++ = '\0';
}
-
+
if (zstr(domain_name)) {
dup_domain_name = switch_core_get_domain(SWITCH_TRUE);
domain_name = dup_domain_name;
}
-
+
if (zstr(domain_name)) {
domain_name = "cluecon.com";
}
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", dup_id);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", dup_id);
-
+
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "force-status", "Active (%d call%s)", count, count == 1 ? "" : "s");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "active");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", dup_id);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", dup_id);
-
+
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "force-status", "Idle");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "unknown");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "answer-state", "terminated");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-direction", "inbound");
switch_event_fire(&event);
- }
+ }
}
-
+
switch_safe_free(dup_domain_name);
switch_safe_free(dup_key_name);
switch_safe_free(dup_id);
-
+
}
static void pickup_pres_event_handler(switch_event_t *event)
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", PICKUP_PROTO);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", key_name);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", key_name, domain_name);
-
+
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "force-status", "Active (%d call%s)", count, count == 1 ? "" : "s");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "active");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", PICKUP_PROTO);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", key_name);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", key_name, domain_name);
-
+
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "force-status", "Idle");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "unknown");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
if ((head = switch_core_hash_find(globals.pickup_hash, key))) {
switch_core_hash_delete(globals.pickup_hash, key);
-
+
if (uuid) {
pickup_node_t *np, *lp = NULL;
} else {
head = np->next;
}
-
+
node = np;
break;
}
lp = np;
}
-
+
} else {
node = head;
head = head->next;
free(node->key);
free(node);
}
-
+
switch_mutex_unlock(globals.pickup_mutex);
if (r) pickup_send_presence(key);
switch_safe_free(dup_key);
-
+
return r;
}
return SWITCH_STATUS_FALSE;
case CS_HANGUP:
{
-
+
if (switch_channel_test_flag(channel, CF_CHANNEL_SWAP)) {
const char *key = switch_channel_get_variable(channel, "channel_swap_uuid");
switch_core_session_t *swap_session;
switch_core_session_set_private(nsession, tech_pvt);
-
+
nchannel = switch_core_session_get_channel(nsession);
switch_channel_set_cap(nchannel, CC_PROXY_MEDIA);
switch_channel_set_cap(nchannel, CC_BYPASS_MEDIA);
switch_channel_set_caller_profile(nchannel, caller_profile);
switch_channel_set_state(nchannel, CS_ROUTING);
-
+
*new_session = nsession;
if ((uuid = pickup_pop_uuid((char *)data, NULL))) {
if ((pickup_session = switch_core_session_locate(uuid))) {
switch_channel_t *pickup_channel = switch_core_session_get_channel(pickup_session);
- switch_caller_profile_t *pickup_caller_profile = switch_channel_get_caller_profile(pickup_channel),
+ switch_caller_profile_t *pickup_caller_profile = switch_channel_get_caller_profile(pickup_channel),
*caller_profile = switch_channel_get_caller_profile(channel);
const char *name, *num;
switch_event_t *event;
switch_channel_set_variable(channel, hp->name, hp->value);
}
-
+
switch_channel_set_flag(pickup_channel, CF_CHANNEL_SWAP);
switch_channel_set_variable(pickup_channel, "channel_swap_uuid", switch_core_session_get_uuid(session));
-
+
name = caller_profile->caller_id_name;
num = caller_profile->caller_id_number;
caller_profile->callee_id_name = name;
caller_profile->callee_id_number = num;
-
+
if (switch_event_create(&event, SWITCH_EVENT_CALL_UPDATE) == SWITCH_STATUS_SUCCESS) {
const char *partner_uuid = switch_channel_get_partner_uuid(channel);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Direction", "RECV");
-
+
if (partner_uuid) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridged-To", partner_uuid);
}
}
var_event = NULL;
}
-
+
if (switch_xml_locate_user_merged("id", user, domain, NULL, &x_user, params) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Can't find user [%s@%s]\n", user, domain);
cause = SWITCH_CAUSE_SUBSCRIBER_ABSENT;
switch_safe_free(d_dest);
}
}
-
+
if (new_channel && x_user) {
if ((x_params = switch_xml_child(x_user, "variables"))) {
for (x_param = switch_xml_child(x_params, "variable"); x_param; x_param = x_param->next) {
}
static switch_status_t event_chat_send(switch_event_t *message_event)
-
+
{
switch_event_t *event;
const char *to;
if (switch_event_fire(&event) == SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_SUCCESS;
}
-
+
switch_event_destroy(&event);
return SWITCH_STATUS_MEMERR;
static switch_status_t api_chat_send(switch_event_t *message_event)
{
const char *proto;
- const char *from;
+ const char *from;
const char *to;
//const char *subject;
//const char *body;
//subject = switch_event_get_header(message_event, "subject");
//body = switch_event_get_body(message_event);
type = switch_event_get_header(message_event, "type");
- hint = switch_event_get_header(message_event, "hint");
+ hint = switch_event_get_header(message_event, "hint");
if (to) {
mydata = switch_core_session_strdup(session, data);
argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
}
-
+
backend = argv[0];
/* must have at least one item */
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "USAGE: limit %s\n", LIMIT_USAGE);
return;
}
-
+
/* if this is an invalid backend, fallback to db backend */
/* TODO: remove this when we can! */
- if (switch_true(switch_channel_get_variable(channel, "switch_limit_backwards_compat_flag")) &&
+ if (switch_true(switch_channel_get_variable(channel, "switch_limit_backwards_compat_flag")) &&
!switch_loadable_module_get_limit_interface(backend)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unknown backend '%s'. To maintain backwards compatability, falling back on db backend and shifting argumens. Either update your diaplan to include the backend, fix the typo, or load the appropriate limit implementation module.\n", backend);
mydata = switch_core_session_sprintf(session, "db %s", data);
mydata = switch_core_session_strdup(session, data);
argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
}
-
+
/* backwards compat version, if we have 5, just prepend with db and reparse */
- if (switch_true(switch_channel_get_variable(channel, "switch_limit_backwards_compat_flag")) &&
+ if (switch_true(switch_channel_get_variable(channel, "switch_limit_backwards_compat_flag")) &&
argc == 5) {
mydata = switch_core_session_sprintf(session, "db %s", data);
argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
/* Only release the resource if we are still in CS_EXECUTE */
if (switch_channel_get_state(switch_core_session_get_channel(session)) == CS_EXECUTE) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "immediately releasing\n");
- switch_limit_release(backend, session, realm, id);
+ switch_limit_release(backend, session, realm, id);
}
}
}
}
if (context->file && switch_test_flag(handle, SWITCH_FILE_DATA_SHORT)) { /* TODO handle other data type flags */
- switch_size_t len;
+ switch_size_t len;
uint16_t buf[SWITCH_RECOMMENDED_BUFFER_SIZE] = { 0 };
switch_status_t stat;
switch_file_handle_t fh = { 0 };
- if ((stat = switch_core_file_open(&fh, context->file, handle->channels, handle->samplerate,
+ if ((stat = switch_core_file_open(&fh, context->file, handle->channels, handle->samplerate,
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL)) == SWITCH_STATUS_SUCCESS) {
do {
len = SWITCH_RECOMMENDED_BUFFER_SIZE / handle->channels;
}
} while (stat == SWITCH_STATUS_SUCCESS);
- switch_core_file_close(&fh);
+ switch_core_file_close(&fh);
switch_file_remove(context->file, handle->memory_pool);
} else {
context->index = -1;
return next_file(handle);
}
-
+
if (!handle->seekable) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "File is not seekable\n");
return SWITCH_STATUS_NOTIMPL;
file_string_context_t *context = handle->private_info;
file_string_audio_col_t *col_ptr = context->audio_cols;
- while (col_ptr && col != col_ptr->col) {
+ while (col_ptr && col != col_ptr->col) {
col_ptr = col_ptr->next;
}
col_ptr->next = context->audio_cols;
context->audio_cols = col_ptr;
}
-
+
return switch_core_file_set_string(&context->fh, col, string);
}
}
return switch_channel_test_app_flag_key(rf->key, channel, MUTEX_FLAG_WAIT) ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
-
+
}
static void free_node(mutex_node_t **npp)
for (np = master->list; np; np = np->next) {
if (np && !strcmp(np->uuid, uuid)) {
switch_core_event_hook_remove_state_change(session, mutex_hanguphook);
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s %s mutex %s canceled\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s %s mutex %s canceled\n",
switch_core_session_get_uuid(session),
switch_core_session_get_name(session), master->key);
}
free_node(&np);
-
+
break;
}
if (!master || !master->list) {
goto end;
}
-
+
while (master->list) {
mutex_node_t *np;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "ADVANCE POP %p\n", (void *)np);
free_node(&np);
}
-
+
if (master->list) {
switch_core_session_t *session;
if ((session = switch_core_session_locate(master->list->uuid))) {
switch_channel_t *channel = switch_core_session_get_channel(session);
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
"%s mutex %s advanced\n", switch_channel_get_name(channel), master->key);
switch_channel_set_app_flag_key(master->key, channel, MUTEX_FLAG_SET);
switch_channel_clear_app_flag_key(master->key, channel, MUTEX_FLAG_WAIT);
switch_mutex_unlock(globals.mutex_mutex);
-
+
}
static void confirm(switch_core_session_t *session, master_mutex_t *master)
if (!strcmp(master->list->uuid, switch_core_session_get_uuid(session))) {
switch_channel_clear_app_flag_key(master->key, channel, MUTEX_FLAG_SET);
switch_core_event_hook_remove_state_change(session, mutex_hanguphook);
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s %s mutex %s cleared\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s %s mutex %s cleared\n",
switch_core_session_get_uuid(session),
switch_channel_get_name(channel), master->key);
advance(master, SWITCH_TRUE);
switch_mutex_unlock(globals.mutex_mutex);
return SWITCH_FALSE;
}
-
+
if (!(master = switch_core_hash_find(globals.mutex_hash, key))) {
master = switch_core_alloc(globals.pool, sizeof(*master));
master->key = switch_core_strdup(globals.pool, key);
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "EXIST MASTER %s %p\n", key, (void *) master);
}
-
+
if (on) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "HIT ON\n");
switch_channel_clear_app_flag_key(key, channel, MUTEX_FLAG_WAIT);
switch_channel_set_private(channel, "_mutex_master", master);
switch_core_event_hook_add_state_change(session, mutex_hanguphook);
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s %s mutex %s acquired\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s %s mutex %s acquired\n",
switch_core_session_get_uuid(session),
switch_channel_get_name(channel), key);
switch_mutex_unlock(globals.mutex_mutex);
}
switch_mutex_unlock(globals.mutex_mutex);
-
+
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s mutex %s is busy, waiting...\n", switch_channel_get_name(channel), key);
if ((feedback = switch_channel_get_variable(channel, "mutex_feedback"))) {
if ((rf.exten = switch_channel_get_variable(channel, "mutex_orbit_exten"))) {
to_val = 60;
}
-
+
if ((var = switch_channel_get_variable(channel, "mutex_timeout"))) {
long tmp = atol(var);
-
+
if (tmp > 0) {
to_val = tmp;
}
}
-
+
if (to_val) {
switch_codec_implementation_t read_impl;
switch_core_session_get_read_impl(session, &read_impl);
-
+
rf.to = (1000 / (read_impl.microseconds_per_packet / 1000)) * to_val;
rf.dp = switch_channel_get_variable(channel, "mutex_orbit_dialplan");
rf.context = switch_channel_get_variable(channel, "mutex_orbit_context");
if (switch_channel_test_app_flag_key(key, channel, MUTEX_FLAG_WAIT) || !switch_channel_up(channel)) {
cancel(session, master);
} else {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s %s mutex %s acquired\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s %s mutex %s acquired\n",
switch_core_session_get_uuid(session),
switch_channel_get_name(channel), key);
switch_core_event_hook_add_state_change(session, mutex_hanguphook);
}
do_mutex(session, key, on);
-
+
}
if (switch_ivr_originate(NULL, &session, &cause, pd->dial_str, 60, NULL, NULL, NULL, NULL, pd->var_event, SOF_NONE, NULL) == SWITCH_STATUS_SUCCESS) {
switch_channel_t *channel = switch_core_session_get_channel(session);
-
+
switch_channel_set_variable(channel, "page_file", pd->path);
mypd = switch_core_session_alloc(session, sizeof(*mypd));
return NULL;
}
-static void launch_call(const char *dial_str,
- const char *path, const char *exten, const char *context, const char *dp,
+static void launch_call(const char *dial_str,
+ const char *path, const char *exten, const char *context, const char *dp,
switch_mutex_t *mutex, uint32_t *counter, switch_event_t **var_event)
{
switch_thread_data_t *td;
switch_memory_pool_t *pool;
page_data_t *pd;
-
+
switch_core_new_memory_pool(&pool);
pd = switch_core_alloc(pool, sizeof(*pd));
td->obj = pd;
switch_thread_pool_launch_thread(&td);
-
+
}
typedef struct call_monitor_s {
while (data && *data && *data == ' ') {
data++;
}
-
+
while (*data == '<') {
char *parsed = NULL;
}
while (sent < size) {
- do {
- switch_mutex_lock(mutex);
+ do {
+ switch_mutex_lock(mutex);
busy = (counter >= cm->chunk_size);
switch_mutex_unlock(mutex);
-
- if (busy) {
+
+ if (busy) {
switch_yield(100000);
- }
-
+ }
+
} while (busy);
launch_call(argv[sent++], cm->path, cm->exten, cm->context, cm->dp, mutex, &counter, &var_event);
switch_thread_data_t *td;
switch_memory_pool_t *pool;
call_monitor_t *cm;
-
+
switch_core_new_memory_pool(&pool);
cm = switch_core_alloc(pool, sizeof(*cm));
td->obj = cm;
switch_thread_pool_launch_thread(&td);
-
+
}
if ((l = switch_channel_get_variable(channel, "page_dp"))) {
dp = l;
}
-
+
l = switch_channel_get_variable(channel, "page_record_limit");
-
+
if (l) {
if (*l == '+') {
l++;
}
switch_ivr_play_file(session, NULL, beep, NULL);
-
+
switch_ivr_record_file(session, &fh, path, &args, limit);
}
if (zstr(exten)) {
exten = switch_core_session_sprintf(session, "playback:%s", path);
}
-
+
if (switch_file_exists(path, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
launch_call_monitor(path, del, pdata, chunk_size, exten, context, dp);
} else {
while (data && *data && *data == ' ') {
data++;
}
-
+
while (*data == '(') {
char *parsed = NULL;
if (!var_event) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
goto end;
- }
+ }
pdata = data;
if ((l = switch_event_get_header(var_event, "page_dp"))) {
dp = l;
}
-
+
if ((l = switch_event_get_header(var_event, "page_chunk_size"))) {
uint32_t tmp = switch_atoui(l);
oexten = switch_mprintf("playback:%s", path);
exten = oexten;
}
-
+
if (switch_file_exists(path, NULL) == SWITCH_STATUS_SUCCESS) {
launch_call_monitor(path, 0, pdata, chunk_size, exten, context, dp);
} else {
end:
-
+
switch_safe_free(odata);
switch_safe_free(oexten);
SWITCH_ADD_APP(app_interface, "blind_transfer_ack", "", "", blind_transfer_ack_function, "[true|false]", SAF_NONE);
- SWITCH_ADD_APP(app_interface, "bind_digit_action", "bind a key sequence or regex to an action",
+ SWITCH_ADD_APP(app_interface, "bind_digit_action", "bind a key sequence or regex to an action",
"bind a key sequence or regex to an action", bind_digit_action_function, BIND_DIGIT_ACTION_USAGE, SAF_SUPPORT_NOMEDIA);
- SWITCH_ADD_APP(app_interface, "capture", "capture data into a var", "capture data into a var",
+ SWITCH_ADD_APP(app_interface, "capture", "capture data into a var", "capture data into a var",
capture_function, "<varname>|<data>|<regex>", SAF_SUPPORT_NOMEDIA);
- SWITCH_ADD_APP(app_interface, "clear_digit_action", "clear all digit bindings", "",
+ SWITCH_ADD_APP(app_interface, "clear_digit_action", "clear all digit bindings", "",
clear_digit_action_function, CLEAR_DIGIT_ACTION_USAGE, SAF_SUPPORT_NOMEDIA);
- SWITCH_ADD_APP(app_interface, "digit_action_set_realm", "change binding realm", "",
+ SWITCH_ADD_APP(app_interface, "digit_action_set_realm", "change binding realm", "",
digit_action_set_realm_function, DIGIT_ACTION_SET_REALM_USAGE, SAF_SUPPORT_NOMEDIA);
SWITCH_ADD_APP(app_interface, "privacy", "Set privacy on calls", "Set caller privacy on calls.", privacy_function, "off|on|name|full|number",
SWITCH_ADD_APP(app_interface, "eval", "Do Nothing", "Do Nothing", eval_function, "", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC);
SWITCH_ADD_APP(app_interface, "set_media_stats", "Set Media Stats", "Set Media Stats", set_media_stats_function, "", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC);
SWITCH_ADD_APP(app_interface, "stop", "Do Nothing", "Do Nothing", eval_function, "", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
- SWITCH_ADD_APP(app_interface, "set_zombie_exec", "Enable Zombie Execution", "Enable Zombie Execution",
+ SWITCH_ADD_APP(app_interface, "set_zombie_exec", "Enable Zombie Execution", "Enable Zombie Execution",
zombie_function, "", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
SWITCH_ADD_APP(app_interface, "pre_answer", "Pre-Answer the call", "Pre-Answer the call for a channel.", pre_answer_function, "", SAF_SUPPORT_NOMEDIA);
SWITCH_ADD_APP(app_interface, "answer", "Answer the call", "Answer the call for a channel.", answer_function, "", SAF_SUPPORT_NOMEDIA);
SWITCH_ADD_APP(app_interface, "video_decode", "Set video decode.", "Set video decode.", video_set_decode_function, "[[on|wait]|off]",
SAF_NONE);
SWITCH_ADD_APP(app_interface, "send_info", "Send info", "Send info", send_info_function, "<info>", SAF_SUPPORT_NOMEDIA);
- SWITCH_ADD_APP(app_interface, "jitterbuffer", "Send session jitterbuffer", "Send a jitterbuffer message to a session.",
+ SWITCH_ADD_APP(app_interface, "jitterbuffer", "Send session jitterbuffer", "Send a jitterbuffer message to a session.",
jitterbuffer_function, "<jitterbuffer_data>", SAF_SUPPORT_NOMEDIA);
SWITCH_ADD_APP(app_interface, "send_display", "Send session a new display", "Send session a new display.", display_function, "<text>",
SAF_SUPPORT_NOMEDIA);
SWITCH_ADD_APP(app_interface, "loop_playback", "Playback File looply", "Playback a file to the channel looply for limted times",
loop_playback_function, "[+loops] <path>", SAF_NONE);
SWITCH_ADD_APP(app_interface, "att_xfer", "Attended Transfer", "Attended Transfer", att_xfer_function, "<channel_url>", SAF_NONE);
- SWITCH_ADD_APP(app_interface, "read", "Read Digits", "Read Digits", read_function,
+ SWITCH_ADD_APP(app_interface, "read", "Read Digits", "Read Digits", read_function,
"<min> <max> <file> <var_name> <timeout> <terminators> <digit_timeout>", SAF_NONE);
SWITCH_ADD_APP(app_interface, "play_and_get_digits", "Play and get Digits", "Play and get Digits",
- play_and_get_digits_function,
+ play_and_get_digits_function,
"\n\t<min> <max> <tries> <timeout> <terminators> <file> <invalid_file> <var_name> <regexp> [<digit_timeout>] ['<failure_ext> [failure_dp [failure_context]]']", SAF_NONE);
SWITCH_ADD_APP(app_interface, "stop_video_write_overlay", "Stop video write overlay", "Stop video write overlay", stop_video_write_overlay_session_function, "<path>", SAF_NONE);
<!-- Default Technology and profile -->
<param name="default-techprofile" value="sofia/default"/>
-
+
<!-- IP or Hostname of Default Route -->
<param name="default-gateway" value="192.168.66.6"/>
call_limit varchar(16) - contains optional call limit
tech_prefix varchar(128) - tech prefix used to build dial string (ex: sofia/default )
acctcode varchar(128) - used to set channel variable acctcode for logging into the CDRs
- destination_number varchar(16) - Number returning for the query for building the dial string. (ex: 18005551212)
+ destination_number varchar(16) - Number returning for the query for building the dial string. (ex: 18005551212)
See Documentation on the Wiki for further information -->
<!-- <param name="custom-query" value="call FS_GET_SIP_LOCATION(%s);"/> -->
</settings>
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Jay Binks <jaybinks@gmail.com>
*
globals.timeout = 5000;
globals.retries = 3;
globals.random = 0;
-
+
if ((settings = switch_xml_child(cfg, "settings"))) {
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
const char *var = switch_xml_attr_soft(param, "name");
HKEY hKey;
DWORD data_sz;
char* buf;
- RegOpenKeyEx(HKEY_LOCAL_MACHINE,
- "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters",
+ RegOpenKeyEx(HKEY_LOCAL_MACHINE,
+ "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters",
0, KEY_QUERY_VALUE, &hKey);
if (hKey) {
new_result->service = strdup(service);
new_result->route = strdup(route);
new_result->supported = supported;
-
+
if (!*results) {
*results = new_result;
char *packstr;
char *regex, *replace;
-
+
if (zstr(str)) {
if (str != NULL) {
/* In this case ldns_rr2str returned a malloc'd null terminated string */
if (zstr(service) || zstr(packstr)) {
goto end;
}
-
+
if (!zstr(argv[4])) {
order = atoi(argv[4]);
}
} else {
goto end;
}
-
+
for (p = replace; p && *p; p++) {
if (*p == '\\') {
*p = '$';
} else {
orig_uri = replace;
}
-
+
switch_mutex_lock(MUTEX);
for (route = globals.route_order; route; route = route->next) {
char *uri = orig_uri;
-
+
if (strcasecmp(service, route->service)) {
continue;
}
supported++;
add_result(results, order, preference, service, uri, supported);
-
+
}
switch_safe_free(uri_expanded);
switch_safe_free(substituted_2);
switch_regex_safe_free(re2);
}
- switch_mutex_unlock(MUTEX);
+ switch_mutex_unlock(MUTEX);
if (!supported) {
add_result(results, order, preference, service, orig_uri, 0);
end:
switch_safe_free(str);
-
+
return;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Parse Error!\n");
goto end;
}
-
+
if (!(domain = ldns_dname_new_frm_str(name))) {
goto end;
}
-
+
if (server_name) {
res = ldns_resolver_new();
switch_assert(res);
-
+
for(inameserver=0; inameserver<ENUM_MAXNAMESERVERS; inameserver++) {
if ( server_name[inameserver] != NULL ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding Nameserver [%s]\n", server_name[inameserver]);
ldns_rdf_deep_free(serv_rdf);
added_server = 1;
}
- }
+ }
}
- }
+ }
if (!added_server) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "No Nameservers specified, using host default\n");
/* create a new resolver from /etc/resolv.conf */
if ((naptr = ldns_pkt_rr_list_by_type(p, LDNS_RR_TYPE_NAPTR, LDNS_SECTION_ANSWER))) {
size_t i;
- ldns_rr_list_sort(naptr);
+ ldns_rr_list_sort(naptr);
for (i = 0; i < ldns_rr_list_rr_count(naptr); i++) {
parse_naptr(ldns_rr_list_rr(naptr, i), number, results);
end:
switch_safe_free(name);
-
+
if (domain) {
ldns_rdf_deep_free(domain);
}
switch_status_t sstatus = SWITCH_STATUS_SUCCESS;
char *mnum = NULL, *mroot = NULL, *p;
char *server[ENUM_MAXNAMESERVERS];
- int inameserver = 0;
+ int inameserver = 0;
char *argv[ ENUM_MAXNAMESERVERS ] = { 0 };
int argc;
int x = 0;
/* Empty the server array */
for(inameserver=0; inameserver<ENUM_MAXNAMESERVERS; inameserver++) {
server[inameserver] = NULL;
- }
+ }
inameserver = 0;
/* check for enum_nameserver channel var */
-
+
if (channel) {
enum_nameserver = switch_channel_get_variable(channel, "enum_nameserver");
}
root = argv[1];
if (enum_lookup(root, dest, &results, channel, session) == SWITCH_STATUS_SUCCESS) {
switch_event_t *vars;
-
+
if (switch_channel_get_variables(channel, &vars) == SWITCH_STATUS_SUCCESS) {
switch_event_header_t *hi;
for (hi = vars->headers; hi; hi = hi->next) {
switch_safe_free(globals.root);
switch_safe_free(globals.isn_root);
-
+
return SWITCH_STATUS_UNLOAD;
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
const char *codec_name = "PCMU";
int read_rate = 8000;
int need_transcode = 0;
-
+
inc_serno();
switch_core_session_get_read_impl(session, &read_impl);
goto fail;
}
-
+
while (!ready) {
status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
alert_packet->audio_header.codec = 0x00;
alert_packet->audio_header.flags = 0;
-
+
if ((var = switch_channel_get_variable(channel, "esf_multicast_write_codec"))) {
if (!strcasecmp(var, "PCMU")) {
codec_name = var;
goto fail;
}
}
-
+
if (!(rtp_port = switch_rtp_request_port(source_ip))) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "RTP Port Error\n");
alert_packet->audio_header.codec,
160,
20000, flags, "soft", &err, switch_core_session_get_pool(session));
-
+
if (!switch_rtp_ready(rtp_session)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "RTP Error\n");
goto fail;
strncpy((char *)polycom_packet->cid, caller_id_name, sizeof(polycom_packet->cid));
polycom_packet->cid_len = 13;
-
+
polycom_packet->op = 0x0F;
polycom_packet->channel = 0x1a;
polycom_packet->serno = htonl(get_serno());
ebuf = read_frame->data;
encoded_datalen = read_frame->datalen;
}
-
+
switch_rtp_write_frame(rtp_session, read_frame);
-
+
seq += 160;
-
+
alert_packet->audio_header.seq = htonl(seq);
-
+
if (last_polycom_len) {
memcpy(alert_packet->data, last_polycom_buf, last_polycom_len);
memcpy(alert_packet->data + last_polycom_len, ebuf, encoded_datalen);
} else {
memcpy(alert_packet->data, ebuf, encoded_datalen);
}
-
+
bytes = sizeof(*alert_packet) + encoded_datalen + last_polycom_len;
switch_socket_sendto(socket, polycom_addr, 0, (void *) polycom_buf, &bytes);
-
+
last_polycom_len = encoded_datalen;
memcpy((void *)last_polycom_buf, (void *)ebuf, last_polycom_len);
-
+
} else {
bytes = read_frame->packetlen;
switch_socket_sendto(socket, audio_addr, 0, read_frame->packet, &bytes);
if (socket) {
switch_socket_close(socket);
}
-
+
if (polycom_socket) {
switch_socket_close(polycom_socket);
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Marc Olivier Chouinard <mochouinard@moctel.com>
*
*
SWITCH_MODULE_RUNTIME_FUNCTION(mod_esl_runtime);
SWITCH_MODULE_LOAD_FUNCTION(mod_esl_load);
-/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
+/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
* Defines a switch_loadable_module_function_table_t and a static const char[] modname
*/
SWITCH_MODULE_DEFINITION(mod_esl, mod_esl_load, mod_esl_shutdown, NULL);
if (password && (host = strchr(password, ' '))) {
*host++ = '\0';
- }
+ }
if (host && (s_timeout = strchr(host, ' '))) {
*s_timeout++ = '\0';
*
* Written by:
* Hongli Lai <hongli@telekabel.nl>
- * tkorrovi <tkorrovi@altavista.net> on 2002/02/26.
+ * tkorrovi <tkorrovi@altavista.net> on 2002/02/26.
* Andrew Westcott <ajwestco@users.sourceforge.net>
*
* Offered for use in the public domain without any warranty.
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
* mod_expr.c -- Framework Demo Module
- <!--
+ <!--
Parking extensions... transferring calls to 5900 will park them in a queue.
-->
<extension name="park">
</condition>
</extension>
- <!--
+ <!--
Parking pickup extension. Calling 5901 will pickup the call.
-->
<extension name="unpark">
* who will be available to answer a single caller. In ringall this
* maximum is the number who will be called, in enterprise the need defines
* how many agents will be called. outbound_per_cycle_min will define
- * the minimum agents who will be called to answer a caller regardless of
+ * the minimum agents who will be called to answer a caller regardless of
* need, giving the enterprise strategy the ability to ring through more
* than one agent for one caller.
* care of invoking the handler.
*
* Within the ringall call strategy outbound_per_cycle is used to define
- * how many agents exactly are assigned to the caller. With ringall if
+ * how many agents exactly are assigned to the caller. With ringall if
* multiple callers are calling in and one is answered, because the call
* is assigned to all agents the call to the agents that is not answered
* will be lose raced and the other agents will drop the call before the
- * next one will begin to ring. When oubound_per_cycle is used in the
+ * next one will begin to ring. When oubound_per_cycle is used in the
* enterprise strategy it acts as a maximum value for how many agents
- * are rung at once on any call, the caller is not assigned to any agent
+ * are rung at once on any call, the caller is not assigned to any agent
* until the call is answered. Enterprise only rings the number of phones
* that are needed, so outbound_per_cycle as a max does not give you the
* effect of ringall. outbound_per_cycle_min defines how many agents minimum
* will be rung by an incoming caller through fifo, which can give a ringall
* effect. outbound_per_cycle and outbound_per_cycle_min both default to 1.
- *
+ *
*/
static int find_consumers(fifo_node_t *node)
{
switch_xml_set_attr_d(x_fifo, "outbound_per_cycle", tmp);
switch_snprintf(tmp, sizeof(buffer), "%u", node->outbound_per_cycle_min);
- switch_xml_set_attr_d(x_fifo, "outbound_per_cycle_min", tmp);
+ switch_xml_set_attr_d(x_fifo, "outbound_per_cycle_min", tmp);
switch_snprintf(tmp, sizeof(buffer), "%u", node->ring_timeout);
switch_xml_set_attr_d(x_fifo, "ring_timeout", tmp);
/*
* dsp_fsk_destroy
*
- * Destroys a handle, releasing any associated memory. Sets handle pointer to NULL
+ * Destroys a handle, releasing any associated memory. Sets handle pointer to NULL
* so A destroyed handle can not be used for anything after the destroy.
*/
if (handle->cellpos > 1.0) {
handle->cellpos -= 1.0;
-
+
switch (handle->state) {
case FSK_STATE_DATA:
- {
-
+ {
+
(*handle->attr.bithandler) (handle->attr.bithandler_arg, handle->current_bit);
}
break;
extern fsk_modem_definition_t fsk_modem_definitions[];
-#endif
+#endif
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
* mod_fsk -- FSK data transfer
bsp->datalen = datalen;
bsp->endian = endian;
bsp->ss = ss;
-
+
if (endian < 0) {
bsp->top = bsp->bit_index = 7;
bsp->bot = 0;
int8_t bitstream_get_bit(bitstream_t *bsp)
{
int8_t bit = -1;
-
+
if (bsp->byte_index >= bsp->datalen) {
goto done;
}
bit = (bsp->data[bsp->byte_index] >> (bsp->bit_index)) & 1;
-
+
if (bsp->bit_index == bsp->bot) {
bsp->bit_index = bsp->top;
if (bsp->ss) {
bsp->ssv = 2;
goto done;
- }
+ }
if (++bsp->byte_index > bsp->datalen) {
bit = -1;
goto done;
}
-
+
} else {
bsp->bit_index = bsp->bit_index + bsp->endian;
}
if (state->dlen) {
goto add_byte;
}
-
+
if (state->bpos == 1) {
state->blen = byte;
size_t i;
int sum = 0;
-
+
top:
if (state->checksum != 0 || state->ppos >= state->dlen - 1) {
sum += state->buf[i];
}
state->checksum = sum % 256;
- state->ppos = 2;
+ state->ppos = 2;
if (state->buf[0] != CID_TYPE_MDMF && state->buf[0] != CID_TYPE_SDMF) {
state->checksum = -1;
}
}
*data = (char *)&state->buf[state->ppos];
- state->ppos += *len;
+ state->ppos += *len;
return SWITCH_STATUS_SUCCESS;
} else if (state->buf[0] == CID_TYPE_MDMF) {
*type = state->buf[state->ppos++];
memset(buf, 0, bufsize);
state->buf = buf;
state->bufsize = bufsize;
-
+
dsp_fsk_attr_init (&fsk1200_attr);
dsp_fsk_attr_set_samplerate (&fsk1200_attr, rate);
dsp_fsk_attr_set_bytehandler (&fsk1200_attr, fsk_byte_handler, state);
size_t fsk_modulator_generate_bit(fsk_modulator_t *fsk_trans, int8_t bit, int16_t *buf, size_t buflen)
{
size_t i;
-
+
for(i = 0 ; i < buflen; i++) {
fsk_trans->bit_accum += fsk_trans->bit_factor;
if (fsk_trans->bit_accum >= FSK_MOD_FACTOR) {
uint32_t i = 0;
size_t r = 0;
int8_t bit = 0;
-
+
for (i = 0; i < fsk_trans->chan_sieze_bits; i++) {
if ((r = fsk_modulator_generate_bit(fsk_trans, bit, fsk_trans->sample_buffer, sizeof(fsk_trans->sample_buffer) / 2))) {
if (fsk_trans->write_sample_callback(fsk_trans->sample_buffer, r, fsk_trans->user_data) != SWITCH_STATUS_SUCCESS) {
}
bit = !bit;
}
-
+
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
* mod_fsk -- FSK data transfer
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
* mod_fsk.c -- FSK data transfer
SWITCH_MODULE_RUNTIME_FUNCTION(mod_fsk_runtime);
SWITCH_MODULE_LOAD_FUNCTION(mod_fsk_load);
-/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
+/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
* Defines a switch_loadable_module_function_table_t and a static const char[] modname
*/
SWITCH_MODULE_DEFINITION(mod_fsk, mod_fsk_load, mod_fsk_shutdown, NULL);
switch_buffer_t *buffer = (switch_buffer_t *) user_data;
switch_buffer_write(buffer, buf, buflen * 2);
-
+
return SWITCH_STATUS_SUCCESS;
}
switch_size_t plen = 0;
memset(&fsk_trans, 0, sizeof(fsk_trans));
-
+
time(&now);
localtime_r(&now, &tm);
strftime(time_str, sizeof(time_str), "%m%d%H%M", &tm);
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Encoding [%s][%s]\n", hp->name, hp->value);
-
+
if (!strcasecmp(name, "phone_num")) {
fsk_data_add_mdmf(&fsk_data, MDMF_PHONE_NUM, (uint8_t *)hp->value, strlen(hp->value));
} else if (!strcasecmp(name, "phone_name")) {
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_frame_t *read_frame;
switch_status_t status;
-
+
if (data) {
switch_ivr_sleep(session, 1000, SWITCH_TRUE, NULL);
switch_core_session_send_dtmf_string(session, (const char *) data);
switch_ivr_sleep(session, 1500, SWITCH_TRUE, NULL);
}
-
+
if (switch_core_session_set_codec_slin(session, &sdata) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session),
SWITCH_LOG_ERROR, "FAILURE\n");
switch_buffer_create_dynamic(&buffer, 1024, 2048, 0);
switch_channel_get_variables(channel, &event);
-
+
write_fsk_data(sdata.codec.implementation->actual_samples_per_second, -14, buffer, event, "fsk_");
while(switch_channel_ready(channel)) {
break;
}
- if ((sdata.write_frame.datalen = switch_buffer_read(buffer, sdata.write_frame.data,
+ if ((sdata.write_frame.datalen = switch_buffer_read(buffer, sdata.write_frame.data,
sdata.codec.implementation->decoded_bytes_per_packet)) <= 0) {
break;
}
-
+
if (sdata.write_frame.datalen < sdata.codec.implementation->decoded_bytes_per_packet) {
- memset((char *)sdata.write_frame.data + sdata.write_frame.datalen, 255,
+ memset((char *)sdata.write_frame.data + sdata.write_frame.datalen, 255,
sdata.codec.implementation->decoded_bytes_per_packet - sdata.write_frame.datalen);
sdata.write_frame.datalen = sdata.codec.implementation->decoded_bytes_per_packet;
}
switch_buffer_destroy(&buffer);
switch_core_codec_destroy(&sdata.codec);
switch_core_session_set_read_codec(session, NULL);
-
+
}
typedef struct {
case SWITCH_ABC_TYPE_INIT: {
switch_codec_implementation_t read_impl = { 0 };
switch_core_session_get_read_impl(pvt->session, &read_impl);
-
+
if (fsk_demod_init(&pvt->fsk_data, read_impl.actual_samples_per_second, pvt->fbuf, sizeof(pvt->fbuf))) {
return SWITCH_FALSE;
}
-
+
break;
}
case SWITCH_ABC_TYPE_CLOSE:
int total = 0;
switch_event_create_plain(&event, SWITCH_EVENT_CHANNEL_DATA);
-
+
while(fsk_data_parse(&pvt->fsk_data, &type, &sp, &mlen) == SWITCH_STATUS_SUCCESS) {
char *varname = NULL, *val, *p;
-
+
switch_copy_string(str, sp, mlen+1);
*(str+mlen) = '\0';
switch_clean_string(str);
if (varname && val) {
total++;
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_DEBUG, "%s setting FSK var [%s][%s]\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_DEBUG, "%s setting FSK var [%s][%s]\n",
switch_channel_get_name(channel), varname, val);
switch_channel_set_variable(channel, varname, val);
if (event) {
switch_event_destroy(&event);
}
}
-
+
if (total && (app_var = switch_channel_get_variable(channel, "execute_on_fsk"))) {
char *app_arg;
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_DEBUG, "%s processing execute_on_fsk [%s]\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_DEBUG, "%s processing execute_on_fsk [%s]\n",
switch_channel_get_name(channel), app_var);
if ((app_arg = strchr(app_var, ' '))) {
*app_arg++ = '\0';
}
switch_core_session_execute_application(pvt->session, app_var, app_arg);
}
-
+
pvt->skip = 10;
}
-
+
memset(rframe->data, 255, rframe->datalen);
if (type == SWITCH_ABC_TYPE_READ_REPLACE) {
}
-SWITCH_STANDARD_APP(fsk_recv_function)
+SWITCH_STANDARD_APP(fsk_recv_function)
{
fsk_detect_session(session, data);
}
-SWITCH_STANDARD_APP(fsk_display_function)
+SWITCH_STANDARD_APP(fsk_display_function)
{
/* expected to be called via 'execute_on_fsk' -- passes display update over FSK */
if (zstr(cid_name)) {
cid_name = cid_num;
}
-
+
if (zstr(cid_num)) {
return;
}
}
}
-SWITCH_STANDARD_APP(fsk_simplify_function)
+SWITCH_STANDARD_APP(fsk_simplify_function)
{
/* expected to be called via 'execute_on_fsk' -- redirects call to point-to-point and eliminates legs in the middle */
switch_channel_t *channel = switch_core_session_get_channel(session);
const char *sip_uri, *fsk_simplify_profile, *fsk_simplify_context;
char *bridgeto;
-
+
if (!(sip_uri = switch_channel_get_variable(channel, "fsk_uri"))) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "%s Missing URI field!\n", switch_channel_get_name(channel));
}
switch_channel_t *pchannel;
bridgeto = switch_core_session_sprintf(session, "bridge:sofia/%s/sip:%s", fsk_simplify_profile, sip_uri);
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s transfering to [%s]\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s transfering to [%s]\n",
switch_channel_get_name(channel), bridgeto);
-
+
if (switch_core_session_get_partner(session, &psession) == SWITCH_STATUS_SUCCESS) {
pchannel = switch_core_session_get_channel(psession);
switch_channel_set_flag(pchannel, CF_REDIRECT);
switch_channel_set_flag(pchannel, CF_TRANSFER);
}
-
+
switch_ivr_session_transfer(session, bridgeto, "inline", fsk_simplify_context);
if (psession) {
switch_ivr_session_transfer(psession, "sleep:5000", "inline", NULL);
- switch_core_session_rwunlock(psession);
+ switch_core_session_rwunlock(psession);
}
}
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Seven Du <dujinfang@gmail.com>
*
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "%s waiting for video.\n", switch_channel_get_name(channel));
count = 100;
if (!--sanity) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s timeout waiting for video.\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s timeout waiting for video.\n",
switch_channel_get_name(channel));
switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE, "Got timeout while waiting for video");
goto done;
}
}
}
-
+
if (!switch_channel_ready(channel)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "%s not ready.\n", switch_channel_get_name(channel));
switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE, "Channel not ready");
}
break;
}
-
+
if (mutex) {
switch_mutex_unlock(mutex);
}
if (terminators && !strcasecmp(terminators, "none"))
{
terminators = NULL;
- }
+ }
if (terminators && strchr(terminators, dtmf.digit)) {
}
}
}
-
+
}
switch_core_thread_session_end(session);
break;
}
}
-
+
if (read_frame) {
memset(read_frame->data, 0, read_frame->datalen);
switch_core_session_write_frame(session, read_frame, SWITCH_IO_FLAG_NONE, 0);
switch_core_session_request_video_refresh(session);
count = 1;
}
-
+
if (frame && frame->datalen > 0) {
switch_core_session_write_video_frame(session, frame, SWITCH_IO_FLAG_NONE, 0);
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Ken Rice <krice at suspicious dot org
* Mathieu Rene <mathieu.rene@gmail.com>
const char *username;
const char *password;
int port;
-
+
int interval;
-
+
esl_handle_t handle;
switch_hash_t *index;
switch_thread_rwlock_t *rwlock;
switch_memory_pool_t *pool;
-
+
switch_bool_t running;
switch_thread_t *thread;
-
+
limit_remote_state_t state;
} limit_remote_t;
if (item->total_usage == 0 && item->rate_usage == 0) {
/* Noone is using this item anymore */
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Freeing limit item: %s\n", (const char *) key);
-
+
free(item);
return SWITCH_TRUE;
}
-
+
return SWITCH_FALSE;
}
-SWITCH_HASH_DELETE_FUNC(limit_hash_remote_cleanup_callback)
+SWITCH_HASH_DELETE_FUNC(limit_hash_remote_cleanup_callback)
{
limit_hash_item_t *item = (limit_hash_item_t *) val;
switch_time_t now = (switch_time_t)(intptr_t)pData;
-
+
if (item->last_update != now) {
free(item);
return SWITCH_TRUE;
}
-
+
return SWITCH_FALSE;
}
}
switch_thread_rwlock_unlock(globals.limit_hash_rwlock);
- if (globals.limit_hash) {
+ if (globals.limit_hash) {
task->runtime = switch_epoch_time_now(NULL) + LIMIT_HASH_CLEANUP_INTERVAL;
}
}
}
switch_thread_rwlock_unlock(globals.limit_hash_rwlock);
-
+
return SWITCH_STATUS_SUCCESS;
}
hash_key = switch_mprintf("%s_%s", realm, resource);
remote_usage = get_remote_usage(hash_key);
-
+
count = remote_usage.total_usage;
*rcount = remote_usage.rate_usage;
switch_hash_index_t *hi = NULL;
int count = 0;
char *ret = NULL;
-
+
switch_thread_rwlock_rdlock(globals.limit_hash_rwlock);
-
+
for (hi = switch_core_hash_first(globals.limit_hash); hi; switch_core_hash_next(hi)) {
count++;
}
-
+
switch_thread_rwlock_unlock(globals.limit_hash_rwlock);
-
+
ret = switch_mprintf("There are %d elements being tracked.", count);
return ret;
*/
}
#define HASH_DUMP_SYNTAX "all|limit|db [<realm>]"
-SWITCH_STANDARD_API(hash_dump_function)
+SWITCH_STANDARD_API(hash_dump_function)
{
int mode;
switch_hash_index_t *hi;
char *mydata = NULL;
int realm = 0;
char *realmvalue = NULL;
-
+
if (zstr(cmd)) {
stream->write_function(stream, "Usage: "HASH_DUMP_SYNTAX"\n");
goto done;
if (argc == 2) {
realm = 1;
realmvalue = switch_mprintf("%s_", argv[1]);
- }
-
+ }
+
if (!strcmp(cmd, "all")) {
mode = 3;
} else if (!strcmp(cmd, "limit")) {
stream->write_function(stream, "Usage: "HASH_DUMP_SYNTAX"\n");
goto done;
}
-
+
if (mode & 1) {
switch_thread_rwlock_rdlock(globals.limit_hash_rwlock);
for (hi = switch_core_hash_first(globals.limit_hash); hi; hi = switch_core_hash_next(&hi)) {
switch_ssize_t keylen;
limit_hash_item_t *item;
switch_core_hash_this(hi, &key, &keylen, &val);
-
+
item = (limit_hash_item_t *)val;
stream->write_function(stream, "L/%s/%d/%d/%d/%d\n", key, item->total_usage, item->rate_usage, item->interval, item->last_check);
}
switch_thread_rwlock_unlock(globals.limit_hash_rwlock);
}
-
+
if (mode & 2) {
switch_thread_rwlock_rdlock(globals.db_hash_rwlock);
for (hi = switch_core_hash_first(globals.db_hash); hi; hi = switch_core_hash_next(&hi)) {
}
switch_thread_rwlock_unlock(globals.db_hash_rwlock);
}
-
+
done:
switch_safe_free(mydata);
switch_safe_free(realmvalue);
}
#define HASH_REMOTE_SYNTAX "list|kill [name]|rescan"
-SWITCH_STANDARD_API(hash_remote_function)
+SWITCH_STANDARD_API(hash_remote_function)
{
//int argc;
char *argv[10];
char *dup = NULL;
-
+
if (zstr(cmd)) {
stream->write_function(stream, "-ERR Usage: "HASH_REMOTE_SYNTAX"\n");
return SWITCH_STATUS_SUCCESS;
}
-
+
dup = strdup(cmd);
-
+
switch_split(dup, ' ', argv);
if (argv[0] && !strcmp(argv[0], "list")) {
switch_hash_index_t *hi;
stream->write_function(stream, "Remote connections:\nName\t\t\tState\n");
-
+
switch_thread_rwlock_rdlock(globals.remote_hash_rwlock);
for (hi = switch_core_hash_first(globals.remote_hash); hi; hi = switch_core_hash_next(&hi)) {
- void *val;
+ void *val;
const void *key;
switch_ssize_t keylen;
limit_remote_t *item;
switch_core_hash_this(hi, &key, &keylen, &val);
-
+
item = (limit_remote_t *)val;
- stream->write_function(stream, "%s\t\t\t%s\n", item->name, state_str(item->state));
+ stream->write_function(stream, "%s\t\t\t%s\n", item->name, state_str(item->state));
}
switch_thread_rwlock_unlock(globals.remote_hash_rwlock);
stream->write_function(stream, "+OK\n");
-
+
} else if (argv[0] && !strcmp(argv[0], "kill")) {
const char *name = argv[1];
limit_remote_t *remote;
switch_thread_rwlock_rdlock(globals.remote_hash_rwlock);
remote = switch_core_hash_find(globals.remote_hash, name);
switch_thread_rwlock_unlock(globals.remote_hash_rwlock);
-
+
if (remote) {
limit_remote_destroy(&remote);
switch_thread_rwlock_wrlock(globals.remote_hash_rwlock);
switch_core_hash_delete(globals.remote_hash, name);
switch_thread_rwlock_unlock(globals.remote_hash_rwlock);
-
- stream->write_function(stream, "+OK\n");
+
+ stream->write_function(stream, "+OK\n");
} else {
stream->write_function(stream, "-ERR No such remote instance %s\n", name);
}
stream->write_function(stream, "+OK\n");
} else {
stream->write_function(stream, "-ERR Usage: "HASH_REMOTE_SYNTAX"\n");
-
+
}
-
+
done:
switch_safe_free(dup);
return SWITCH_STATUS_SUCCESS;
}
-limit_remote_t *limit_remote_create(const char *name, const char *host, uint16_t port, const char *username, const char *password, int interval)
+limit_remote_t *limit_remote_create(const char *name, const char *host, uint16_t port, const char *username, const char *password, int interval)
{
limit_remote_t *r;
switch_memory_pool_t *pool;
-
+
switch_thread_rwlock_rdlock(globals.remote_hash_rwlock);
if (switch_core_hash_find(globals.remote_hash, name)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Already have a remote instance named %s\n", name);
return NULL;
}
switch_thread_rwlock_unlock(globals.remote_hash_rwlock);
-
+
if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
return NULL;
}
-
+
r = switch_core_alloc(pool, sizeof(limit_remote_t));
r->pool = pool;
r->name = switch_core_strdup(r->pool, name);
r->username = switch_core_strdup(r->pool, username);
r->password = switch_core_strdup(r->pool, password);
r->interval = interval;
-
+
switch_thread_rwlock_create(&r->rwlock, pool);
switch_core_hash_init(&r->index);
-
+
switch_thread_rwlock_rdlock(globals.remote_hash_rwlock);
switch_core_hash_insert(globals.remote_hash, name, r);
switch_thread_rwlock_unlock(globals.remote_hash_rwlock);
/* Free hashtable data */
for (hi = switch_core_hash_first((*r)->index); hi; hi = switch_core_hash_next(&hi)) {
- void *val;
+ void *val;
const void *key;
switch_ssize_t keylen;
switch_core_hash_this(hi, &key, &keylen, &val);
free(val);
}
-
+
switch_thread_rwlock_unlock((*r)->rwlock);
switch_thread_rwlock_destroy((*r)->rwlock);
-
+
switch_core_destroy_memory_pool(&((*r)->pool));
*r = NULL;
}
static limit_hash_item_t get_remote_usage(const char *key) {
limit_hash_item_t usage = { 0 };
switch_hash_index_t *hi;
-
+
switch_thread_rwlock_rdlock(globals.remote_hash_rwlock);
for (hi = switch_core_hash_first(globals.remote_hash); hi; hi = switch_core_hash_next(&hi)) {
- void *val;
+ void *val;
const void *hashkey;
switch_ssize_t keylen;
limit_remote_t *remote;
limit_hash_item_t *item;
switch_core_hash_this(hi, &hashkey, &keylen, &val);
-
+
remote = (limit_remote_t *)val;
if (remote->state != REMOTE_UP) {
continue;
}
-
+
switch_thread_rwlock_rdlock(remote->rwlock);
if ((item = switch_core_hash_find(remote->index, key))) {
usage.total_usage += item->total_usage;
}
switch_thread_rwlock_unlock(remote->rwlock);
}
-
+
switch_thread_rwlock_unlock(globals.remote_hash_rwlock);
-
+
return usage;
}
if (esl_connect_timeout(&remote->handle, remote->host, (esl_port_t)remote->port, remote->username, remote->password, 5000) == ESL_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Connected to remote FreeSWITCH (%s) at %s:%d\n",
remote->name, remote->host, remote->port);
-
+
remote->state = REMOTE_UP;
} else {
esl_disconnect(&remote->handle);
switch_time_t now = switch_epoch_time_now(NULL);
while (p && *p) {
/* We are getting the limit data as:
- L/key/usage/rate/interval/last_checked
+ L/key/usage/rate/interval/last_checked
*/
if ((p2 = strchr(p, '\n'))) {
*p2++ = '\0';
}
-
- /* Now p points at the beginning of the current line,
+
+ /* Now p points at the beginning of the current line,
p2 at the start of the next one */
if (*p == 'L') { /* Limit data */
- char *argv[5];
+ char *argv[5];
int argc = switch_split(p+2, '/', argv);
-
+
if (argc < 5) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "[%s] Protocol error: missing argument in line: %s\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "[%s] Protocol error: missing argument in line: %s\n",
remote->name, p);
} else {
limit_hash_item_t *item;
switch_thread_rwlock_unlock(remote->rwlock);
}
}
-
+
p = p2;
}
free(data);
-
+
/* Now free up anything that wasn't in this update since it means their usage is 0 */
switch_thread_rwlock_wrlock(remote->rwlock);
switch_core_hash_delete_multi(remote->index, limit_hash_remote_cleanup_callback, (void*)(intptr_t)now);
}
}
}
-
+
switch_yield(remote->interval * 1000);
}
-
+
remote->thread = NULL;
-
+
return NULL;
}
int interval = 0;
limit_remote_t *remote;
switch_threadattr_t *thd_attr = NULL;
-
+
if (reload) {
switch_thread_rwlock_rdlock(globals.remote_hash_rwlock);
if (switch_core_hash_find(globals.remote_hash, name)) {
if (!zstr(szport)) {
port = (uint16_t)atoi(szport);
}
-
+
if (!zstr(szinterval)) {
interval = atoi(szinterval);
}
-
+
remote = limit_remote_create(name, host, port, username, password, interval);
-
- remote->state = REMOTE_DOWN;
-
+
+ remote->state = REMOTE_DOWN;
+
switch_threadattr_create(&thd_attr, remote->pool);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
switch_thread_create(&remote->thread, thd_attr, limit_remote_thread, remote, remote->pool);
switch_scheduler_add_task(switch_epoch_time_now(NULL) + LIMIT_HASH_CLEANUP_INTERVAL, limit_hash_cleanup_callback, "limit_hash_cleanup", "mod_hash", 0, NULL,
SSHF_NONE);
-
+
SWITCH_ADD_APP(app_interface, "hash", "Insert into the hashtable", HASH_DESC, hash_function, HASH_USAGE, SAF_SUPPORT_NOMEDIA | SAF_ZOMBIE_EXEC)
SWITCH_ADD_API(commands_api_interface, "hash", "hash get/set", hash_api_function, "[insert|delete|select]/<realm>/<key>/<value>");
SWITCH_ADD_API(commands_api_interface, "hash_dump", "dump hash/limit_hash data (used for synchronization)", hash_dump_function, HASH_DUMP_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "hash_remote", "hash remote", hash_remote_function, HASH_REMOTE_SYNTAX);
-
+
switch_console_set_complete("add hash insert");
switch_console_set_complete("add hash delete");
switch_console_set_complete("add hash select");
-
+
switch_console_set_complete("add hash_remote list");
switch_console_set_complete("add hash_remote kill");
switch_console_set_complete("add hash_remote rescan");
-
+
do_config(SWITCH_FALSE);
/* indicate that the module should continue to be loaded */
- return SWITCH_STATUS_SUCCESS;
+ return SWITCH_STATUS_SUCCESS;
}
{
switch_hash_index_t *hi = NULL;
switch_bool_t remote_clean = SWITCH_TRUE;
-
+
switch_scheduler_del_task_group("mod_hash");
/* Kill remote connections, destroy needs a wrlock so we unlock after finding a pointer */
while(remote_clean) {
- void *val;
+ void *val;
const void *key = NULL;
switch_ssize_t keylen;
limit_remote_t *item = NULL;
-
+
switch_thread_rwlock_rdlock(globals.remote_hash_rwlock);
if ((hi = switch_core_hash_first(globals.remote_hash))) {
switch_core_hash_this(hi, &key, &keylen, &val);
item = (limit_remote_t *)val;
}
switch_thread_rwlock_unlock(globals.remote_hash_rwlock);
-
- if (!item) {
- remote_clean = SWITCH_FALSE;
+
+ if (!item) {
+ remote_clean = SWITCH_FALSE;
} else {
limit_remote_destroy(&item);
switch_thread_rwlock_wrlock(globals.remote_hash_rwlock);
switch_thread_rwlock_wrlock(globals.limit_hash_rwlock);
switch_thread_rwlock_wrlock(globals.db_hash_rwlock);
-
+
while ((hi = switch_core_hash_first_iter( globals.limit_hash, hi))) {
void *val = NULL;
const void *key;
free(val);
switch_core_hash_delete(globals.limit_hash, key);
}
-
+
while ((hi = switch_core_hash_first_iter( globals.db_hash, hi))) {
void *val = NULL;
const void *key;
}
switch_core_hash_destroy(&globals.limit_hash);
- switch_core_hash_destroy(&globals.db_hash);
+ switch_core_hash_destroy(&globals.db_hash);
switch_core_hash_destroy(&globals.remote_hash);
switch_thread_rwlock_unlock(globals.limit_hash_rwlock);
{
hiredis_profile_t *profile = NULL;
switch_memory_pool_t *pool = NULL;
-
+
switch_core_new_memory_pool(&pool);
profile = switch_core_alloc(pool, sizeof(hiredis_profile_t));
#include <mod_hiredis.h>
-switch_status_t mod_hiredis_do_config()
+switch_status_t mod_hiredis_do_config()
{
char *conf = "hiredis.conf";
switch_xml_t xml, cfg, profiles, profile, connections, connection, params, param;
}
if ( (profiles = switch_xml_child(cfg, "profiles")) != NULL) {
- for (profile = switch_xml_child(profiles, "profile"); profile; profile = profile->next) {
+ for (profile = switch_xml_child(profiles, "profile"); profile; profile = profile->next) {
hiredis_profile_t *new_profile = NULL;
uint8_t ignore_connect_fail = 0;
uint8_t ignore_error = 0;
/* Add connection to profile */
if ( (connections = switch_xml_child(profile, "connections")) != NULL) {
- for (connection = switch_xml_child(connections, "connection"); connection; connection = connection->next) {
+ for (connection = switch_xml_child(connections, "connection"); connection; connection = connection->next) {
char *host = NULL, *password = NULL;
uint32_t port = 0, timeout_ms = 0, max_connections = 0;
-
+
for (param = switch_xml_child(connection, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr_soft(param, "name");
if ( !strncmp(var, "hostname", 8) ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Profiles config is missing\n");
goto err;
}
-
+
return SWITCH_STATUS_SUCCESS;
-
+
err:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Configuration failed\n");
return SWITCH_STATUS_GENERR;
}
switch_core_hash_destroy(&(mod_hiredis_globals.profiles));
-
+
return SWITCH_STATUS_SUCCESS;
}
<permission name="set-vars" value="false">
<!-- default to "deny" or "allow" -->
<!-- type attr can be "deny" or "allow" nothing defaults to opposite of the list default so allow in this case -->
- <!--
+ <!--
<variable-list default="deny">
<variable name="caller_id_name"/>
- <variable name="hangup"/>
+ <variable name="hangup"/>
</variable-list>
-->
</permission>
<permission name="get-vars" value="false">
<!-- default to "deny" or "allow" -->
<!-- type attr can be "deny" or "allow" nothing defaults to opposite of the list default so allow in this case -->
- <!--
+ <!--
<variable-list default="deny">
<variable name="caller_id_name"/>
- <variable name="hangup"/>
+ <variable name="hangup"/>
</variable-list>
-->
</permission>
<permission name="expand-vars" value="false">
<!-- default to "deny" or "allow" -->
<!-- type attr can be "deny" or "allow" nothing defaults to opposite of the list default so allow in this case -->
- <!--
+ <!--
<variable-list default="deny">
<variable name="caller_id_name"/>
- <variable name="hangup"/>
+ <variable name="hangup"/>
</variable-list>
<api-list default="deny">
<api name="expr"/>
- <api name="lua"/>
+ <api name="lua"/>
</api-list>
-->
</permission>
<permission name="conference" value="true"/>
<permission name="conference-set-profile" value="false"/>
</permissions>
-
+
<params>
<!-- default url can be overridden by app data -->
<param name="gateway-url" value="http://www.freeswitch.org/api/index.cgi" />
-
+
<!-- set this to provide authentication credentials to the server -->
<!--<param name="gateway-credentials" value="muser:mypass"/>-->
<!--<param name="auth-scheme" value="basic"/>-->
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Raymond Chandler <intralanman@freeswitch.org>
* Seven Du <dujinfang@gmail.com>
static switch_status_t digit_action_callback(switch_ivr_dmachine_match_t *match)
{
action_binding_t *action_binding = (action_binding_t *) match->user_data;
-
+
action_binding->client->matching_action_binding = action_binding;
action_binding->match_digits = switch_core_strdup(action_binding->client->pool, match->match_digits);
action_binding_t *action_binding = (action_binding_t *) match->user_data;
action_binding->client->no_matching_action_binding = action_binding;
-
+
return SWITCH_STATUS_BREAK;
}
}
- if (client->profile->perms.get_vars &&
+ if (client->profile->perms.get_vars &&
(!client->profile->var_params.get_var_list || switch_event_check_permission_list(client->profile->var_params.get_var_list, var))) {
const char *vval = switch_channel_get_variable(client->channel, var);
if (vval) {
}
return SWITCH_STATUS_SUCCESS;
-
+
}
static switch_status_t parse_continue(const char *tag_name, client_t *client, switch_xml_t tag, const char *body)
{
-
+
return SWITCH_STATUS_SUCCESS;
}
{
const char *level = switch_xml_attr(tag, "level");
const char *clean = switch_xml_attr(tag, "clean");
-
+
if (switch_true(clean)) {
console_clean_log(level, body);
} else {
say_method = switch_xml_attr(tag, "method");
say_gender = switch_xml_attr(tag, "gender");
text = switch_xml_attr(tag, "text");
-
+
if (zstr(text)) {
if (!zstr(file)) {
text = file;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "speak: missing required attributes or text! (language) (type) (method) \n");
return SWITCH_STATUS_FALSE;
}
-
+
say = 1;
-
+
} else if (!strcasecmp(tag_name, "speak")) {
tts_engine = switch_xml_attr(tag, "engine");
tts_voice = switch_xml_attr(tag, "voice");
char *p;
SWITCH_STANDARD_STREAM(stream);
-
+
cmd = switch_mprintf("%s|name_path", id);
switch_api_execute("vm_prefs", cmd, NULL, &stream);
text = free_string;
switch_ivr_play_file(client->session, NULL, "voicemail/vm-person.wav", &nullargs);
-
+
}
switch_safe_free(resp);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid digit timeout [%s]\n", digit_timeout_);
}
}
-
+
if (input_timeout_) {
tmp = atol(input_timeout_);
if ((bind = switch_xml_child(tag, "bind"))) {
action_binding_t *action_binding;
const char *realm = "default";
-
+
input++;
top_action_binding->action = (char *) action;
top_action_binding->error_file = (char *)error_file;
- switch_ivr_dmachine_create(&dmachine, "HTTAPI", NULL, digit_timeout, 0,
+ switch_ivr_dmachine_create(&dmachine, "HTTAPI", NULL, digit_timeout, 0,
NULL, digit_nomatch_action_callback, top_action_binding);
-
+
while(bind) {
action_binding = switch_core_session_alloc(client->session, sizeof(*action_binding));
action_binding->realm = (char *) realm;
action_binding->strip = (char *) switch_xml_attr(bind, "strip");
action_binding->error_file = (char *) error_file;
action_binding->parent = top_action_binding;
-
+
switch_ivr_dmachine_bind(dmachine, action_binding->realm, action_binding->input, 0, 0, digit_action_callback, action_binding);
bind = bind->next;
}
-
+
switch_ivr_dmachine_set_realm(dmachine, realm);
if (!zstr(terminators)) {
switch_ivr_dmachine_set_terminators(dmachine, terminators);
char *result = NULL;
status = switch_ivr_play_and_detect_speech(client->session, file, sp_engine, sp_grammar, &result, input_timeout, args);
-
+
if (!zstr(result)) {
switch_event_add_header_string(client->one_time_params, SWITCH_STACK_BOTTOM, name, result);
switch_event_add_header_string(client->one_time_params, SWITCH_STACK_BOTTOM, "input_type", "detected_speech");
break;
}
} while (loops-- > 0);
-
+
if (submit) {
if (client->matching_action_binding) {
switch_event_add_header_string(client->one_time_params, SWITCH_STACK_BOTTOM, name, client->matching_action_binding->match_digits);
switch_event_add_header_string(client->one_time_params, SWITCH_STACK_BOTTOM, "input_type", "dtmf");
}
-
+
if (client->matching_action_binding->action) {
sub_action = client->matching_action_binding->action;
} else if (client->matching_action_binding->parent && client->matching_action_binding->parent->action) {
sub_action = client->matching_action_binding->parent->action;
}
}
-
+
if (!sub_action && top_action_binding && top_action_binding->action) {
sub_action = top_action_binding->action;
}
-
+
if (sub_action && client->matching_action_binding && client->matching_action_binding->match_digits) {
if (!strncasecmp(sub_action, "dial:", 5)) {
char *context = NULL;
char *dp = NULL;
-
+
if (client->profile->perms.dial.set_context) {
context = switch_core_session_strdup(client->session, sub_action + 5);
-
+
if ((dp = strchr(context, ':'))) {
*dp++ = '\0';
if (!client->profile->perms.dial.set_dp) {
switch_ivr_session_transfer(client->session, client->matching_action_binding->match_digits, dp, context);
status = SWITCH_STATUS_FALSE;
-
+
} else {
switch_event_add_header_string(client->params, SWITCH_STACK_BOTTOM, "url", sub_action);
}
}
}
-
+
if (dmachine) {
switch_ivr_dmachine_destroy(&dmachine);
}
switch_safe_free(free_string);
-
+
return status;
}
const char *profile_name = switch_xml_attr(tag, "profile");
const char *pin = switch_xml_attr(tag, "pin");
const char *flags = switch_xml_attr(tag, "flags");
-
+
if (!client->profile->perms.conference.enabled) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Permission Denied!\n");
switch_channel_hangup(client->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
static switch_status_t parse_dial(const char *tag_name, client_t *client, switch_xml_t tag, const char *body)
{
- const char *context = NULL;
+ const char *context = NULL;
const char *dp = NULL;
const char *cid_name = NULL;
const char *cid_number = NULL;
cid_number = switch_channel_get_variable(client->channel, "caller_id_number");
}
- str = switch_core_session_sprintf(client->session,
+ str = switch_core_session_sprintf(client->session,
"{origination_caller_id_name='%s',origination_caller_id_number='%s'}%s", cid_name, cid_number, body);
switch_core_session_execute_application(client->session, "bridge", str);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", switch_channel_get_variable(client->channel, "caller_id_number"));
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to", to);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "type", "text/plain");
-
+
if (body) {
switch_event_add_body(event, "%s", body);
}
if (!client->profile->perms.expand_vars) {
const char *p;
-
+
for(p = data; p && *p; p++) {
if (*p == '$') {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Expand Variables: Permission Denied!\n");
} else {
client->record.action = (char *) action;
client->record.name = (char *)name;
- client->record.file = switch_core_session_sprintf(client->session, "%s%s%s.wav",
+ client->record.file = switch_core_session_sprintf(client->session, "%s%s%s.wav",
SWITCH_GLOBAL_dirs.temp_dir, SWITCH_PATH_SEPARATOR, switch_core_session_get_uuid(client->session));
record_file = client->record.file;
}
-
+
if (limit_) {
limit = atoi(limit_);
if (limit < 0) limit = 0;
}
-
+
switch_ivr_record_session(client->session, (char *)record_file, limit, NULL);
if (zstr(file)) {
return SWITCH_STATUS_FALSE;
}
-
+
fname = switch_core_strdup(client->pool, file);
for(p = fname; p && *p; p++) {
tmp_record_path = fname;
http = 1;
} else {
- tmp_record_path = switch_core_sprintf(client->pool, "%s%s%s_%s.%s",
+ tmp_record_path = switch_core_sprintf(client->pool, "%s%s%s_%s.%s",
SWITCH_GLOBAL_dirs.temp_dir, SWITCH_PATH_SEPARATOR, uuid_str, fname, ext);
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid digit timeout [%s]\n", digit_timeout_);
}
}
-
+
if ((bind = switch_xml_child(tag, "bind"))) {
action_binding_t *action_binding;
const char *realm = "default";
-
+
top_action_binding = switch_core_session_alloc(client->session, sizeof(*action_binding));
top_action_binding->client = client;
top_action_binding->action = (char *) action;
top_action_binding->error_file = (char *)error_file;
- switch_ivr_dmachine_create(&dmachine, "HTTAPI", NULL, digit_timeout, 0,
+ switch_ivr_dmachine_create(&dmachine, "HTTAPI", NULL, digit_timeout, 0,
NULL, digit_nomatch_action_callback, top_action_binding);
-
+
while(bind) {
action_binding = switch_core_session_alloc(client->session, sizeof(*action_binding));
action_binding->realm = (char *) realm;
action_binding->action = (char *) switch_xml_attr(bind, "action");
action_binding->error_file = (char *) error_file;
action_binding->parent = top_action_binding;
-
+
switch_ivr_dmachine_bind(dmachine, action_binding->realm, action_binding->input, 0, 0, digit_action_callback, action_binding);
bind = bind->next;
}
-
+
switch_ivr_dmachine_set_realm(dmachine, realm);
if (!zstr(terminators)) {
switch_ivr_dmachine_set_terminators(dmachine, terminators);
switch_file_handle_t fh = { 0 };
fh.thresh = thresh;
fh.silence_hits = silence_hits;
-
+
status = switch_ivr_record_file(client->session, &fh, tmp_record_path, args, record_limit);
}
if (tmp_action) {
switch_event_add_header_string(client->one_time_params, SWITCH_STACK_BOTTOM, "url", tmp_action);
}
-
+
return SWITCH_STATUS_SUCCESS;
}
if ((len = switch_buffer_peek_zerocopy(client->buffer, &bdata)) && switch_buffer_len(client->buffer) > len) {
switch_xml_t xml, tag, category;
-
+
if (globals.debug) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Debugging Return Data:\n%s\n", (char *)bdata);
}
if (client->profile->perms.set_params) {
if ((category = switch_xml_child(xml, "params"))) {
tag = category->child;
-
+
while(tag) {
if (!zstr(tag->name)) {
char *val = tag->txt;
if (client->profile->perms.set_vars) {
if ((category = switch_xml_child(xml, "variables"))) {
tag = category->child;
-
+
while(tag) {
if (!zstr(tag->name)) {
char *val = tag->txt;
val = NULL;
}
- if (client->profile->perms.set_vars &&
- (!client->profile->var_params.set_var_list ||
+ if (client->profile->perms.set_vars &&
+ (!client->profile->var_params.set_var_list ||
switch_event_check_permission_list(client->profile->var_params.set_var_list, tag->name))) {
switch_channel_set_variable(client->channel, tag->name, val);
} else {
}
if ((category = switch_xml_child(xml, "work"))) {
-
+
tag = category->child;
status = SWITCH_STATUS_SUCCESS;
if (tag->txt && client->profile->perms.expand_vars) {
switch_channel_get_variables(client->channel, &templ_data);
switch_event_merge(templ_data, client->params);
- expanded = switch_event_expand_headers_check(templ_data, tag->txt,
- client->profile->var_params.expand_var_list,
+ expanded = switch_event_expand_headers_check(templ_data, tag->txt,
+ client->profile->var_params.expand_var_list,
client->profile->var_params.api_list, 0);
switch_event_destroy(&templ_data);
}
runs++;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Process Tag: [%s]\n", tag->name);
-
+
parse_common(tag->name, client, tag, expanded);
status = handler(tag->name, client, tag, expanded);
-
+
if (expanded && expanded != tag->txt) {
free(expanded);
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "No instructions found in result!\n");
status = SWITCH_STATUS_FALSE;
}
-
+
switch_xml_free(xml);
}
}
-
+
return status;
}
-
+
static size_t get_header_callback(void *ptr, size_t size, size_t nmemb, void *userdata)
{
switch_event_add_header_string(client->headers, SWITCH_STACK_BOTTOM, header, val);
}
-
+
switch_safe_free(header);
return realsize;
}
}
switch_buffer_write(client->buffer, ptr, realsize);
-
+
return realsize;
}
{
if (client && *client) {
switch_memory_pool_t *pool;
-
+
switch_event_destroy(&(*client)->headers);
switch_event_destroy(&(*client)->params);
switch_event_destroy(&(*client)->one_time_params);
switch_event_destroy(&client->one_time_params);
switch_event_create(&client->one_time_params, SWITCH_EVENT_CLONE);
client->one_time_params->flags |= EF_UNIQ_HEADERS;
-
+
switch_event_create(&client->headers, SWITCH_EVENT_CLONE);
client->pool = pool;
switch_event_create(&client->headers, SWITCH_EVENT_CLONE);
-
+
if (session) {
client->session = session;
client->channel = switch_core_session_get_channel(session);
}
-
+
client->profile = profile;
client->max_bytes = HTTAPI_MAX_API_BYTES;
if (switch_file_exists(hp->value, client->pool) == SWITCH_STATUS_SUCCESS) {
unlink(hp->value);
}
- }
+ }
}
}
}
static switch_status_t httapi_sync(client_t *client)
-
+
{
switch_CURL *curl_handle = NULL;
char *data = NULL;
FILE *fd = NULL;
char *creds, *dup_creds = NULL, *ua = NULL;
-
+
if (client->one_time_params && client->one_time_params->headers) {
save_params = client->params;
switch_event_dup(&client->params, save_params);
if (zstr(ua)) {
ua = client->profile->ua;
}
-
+
if (!(session_id = switch_event_get_header(client->params, "HTTAPI_SESSION_ID"))) {
if (client->channel && !(session_id = switch_channel_get_variable(client->channel, "HTTAPI_SESSION_ID"))) {
session_id = switch_core_session_get_uuid(client->session);
}
get_style_method = method ? strcasecmp(method, "post") : 1;
-
+
switch_event_add_header_string(client->params, SWITCH_STACK_TOP, "session_id", session_id);
dynamic_url = switch_event_expand_headers(client->params, url);
}
if (!put_file) {
- switch_curl_process_form_post_params(client->params, curl_handle, &formpost);
+ switch_curl_process_form_post_params(client->params, curl_handle, &formpost);
}
if (formpost) {
if (get_style_method) {
char *tmp = switch_mprintf("%s%c%s", dynamic_url, strchr(dynamic_url, '?') != NULL ? '&' : '?', data);
-
+
if (dynamic_url != url) {
free(dynamic_url);
}
-
+
dynamic_url = tmp;
}
}
if ((p = strstr(q, "://"))) {
*(p+3) = '\0';
}
-
+
p = switch_mprintf("%s%s", q, r);
if (p) {
free(dynamic_url);
*p = '\0';
if ((q = strchr(dup_creds, '@'))) *q = '\0';
-
+
creds = dup_creds;
-
+
p = switch_mprintf("%s%s", p, use_url);
free(dynamic_url);
dynamic_url = p;
curl_easy_setopt(curl_handle, CURLOPT_UPLOAD, 1L);
curl_easy_setopt(curl_handle, CURLOPT_READDATA, fd);
curl_easy_setopt(curl_handle, CURLOPT_READFUNCTION, put_file_read);
-
+
} else if (formpost) {
curl_easy_setopt(curl_handle, CURLOPT_HTTPPOST, formpost);
} else {
} else {
switch_curl_easy_setopt(curl_handle, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1);
}
-
+
if (client->profile->ssl_cacert_file) {
switch_curl_easy_setopt(curl_handle, CURLOPT_CAINFO, client->profile->ssl_cacert_file);
profile->perms.set_params = 1;
profile->perms.conference.enabled = 1;
profile->perms.dial.enabled = 1;
-
+
if ((tag = switch_xml_child(profile_tag, "conference"))) {
for (param = switch_xml_child(tag, "param"); param; param = param->next) {
switch_xml_t x_list, x_var;
if ((x_list = switch_xml_child(param, "variable-list"))) {
char *var = (char *) switch_xml_attr_soft(param, "default");
-
+
profile->var_params.default_allow = (var && !strcasecmp(var, "allow"));
switch_event_create(&profile->var_params.set_var_list, SWITCH_EVENT_CLONE);
profile->var_params.set_var_list->flags |= EF_UNIQ_HEADERS;
switch_xml_t x_list, x_var;
if ((x_list = switch_xml_child(param, "variable-list"))) {
char *var = (char *) switch_xml_attr_soft(param, "default");
-
+
profile->var_params.default_allow = (var && !strcasecmp(var, "allow"));
switch_event_create(&profile->var_params.get_var_list, SWITCH_EVENT_CLONE);
profile->var_params.get_var_list->flags |= EF_UNIQ_HEADERS;
profile->perms.extended_data = switch_true_byte(val);
} else if (!strcasecmp(var, "execute-apps")) {
profile->perms.execute_apps = switch_true_byte(val);
-
+
if (profile->perms.execute_apps) {
switch_xml_t x_list, x_app;
if ((x_list = switch_xml_child(param, "application-list"))) {
char *var = (char *) switch_xml_attr_soft(param, "default");
-
+
profile->dial_params.default_allow = (var && !strcasecmp(var, "allow"));
switch_event_create(&profile->dial_params.app_list, SWITCH_EVENT_CLONE);
profile->dial_params.app_list->flags |= EF_UNIQ_HEADERS;
}
}
}
-
+
} else if (!strcasecmp(var, "expand-vars")) {
profile->perms.expand_vars = switch_true_byte(val);
switch_xml_t x_list, x_var, x_api;
if ((x_list = switch_xml_child(param, "variable-list"))) {
char *var = (char *) switch_xml_attr_soft(param, "default");
-
+
profile->var_params.default_allow = (var && !strcasecmp(var, "allow"));
switch_event_create(&profile->var_params.expand_var_list, SWITCH_EVENT_CLONE);
profile->var_params.expand_var_list->flags |= EF_UNIQ_HEADERS;
if ((x_list = switch_xml_child(param, "api-list"))) {
char *api = (char *) switch_xml_attr_soft(param, "default");
-
+
profile->var_params.default_allow = (api && !strcasecmp(api, "allow"));
switch_event_create(&profile->var_params.api_list, SWITCH_EVENT_CLONE);
profile->var_params.api_list->flags |= EF_UNIQ_HEADERS;
}
switch_event_add_header_string(client->one_time_params, SWITCH_STACK_BOTTOM, "exiting", "true");
-
+
if (client->record.file) {
char *key = switch_core_sprintf(client->pool, "attach_file:%s:%s.wav", client->record.name, switch_core_session_get_uuid(session));
switch_ivr_stop_record_session(client->session, client->record.file);
switch_event_add_header_string(client->one_time_params, SWITCH_STACK_BOTTOM, "exiting", "true");
}
}
-
+
httapi_sync(client);
client_destroy(&client);
} else {
url = data;
}
-
+
if (!zstr(url) && switch_stristr("://", url)) {
if (!params) {
switch_event_create(¶ms, SWITCH_EVENT_CLONE);
if (zstr(profile_name) && !(profile_name = switch_channel_get_variable(channel, "httapi_profile"))) {
profile_name = "default";
}
-
+
if ((client = client_create(session, profile_name, ¶ms))) {
switch_channel_set_private(channel, "_HTTAPI_CLIENT_", client);
switch_channel_add_state_handler(channel, &state_handlers);
switch_safe_free(parsed);
-
+
}
static const char *find_ext(const char *in)
{
const char *p = in + (strlen(in) - 1);
-
+
while(p >= in && *p) {
if (*p == '/') return NULL;
if (*p == '.') return (p+1);
if (context->url_params) {
ext = switch_event_get_header(context->url_params, "ext");
}
-
+
if (zstr(ext)) {
ext = find_ext(url);
}
-
+
if (ext && (p = strchr(ext, '?'))) {
dext = strdup(ext);
if ((p = strchr(dext, '?'))) {
unsigned char *buffer = (unsigned char *) ptr;
client->bytes += realsize;
-
+
if (client->bytes > client->max_bytes) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Oversized file detected [%d bytes]\n", (int) client->bytes);
client->err = 1;
const char *profile_name = NULL;
int tries = 10;
- if (context->url_params) {
+ if (context->url_params) {
profile_name = switch_event_get_header(context->url_params, "profile_name");
}
if (zstr(profile_name)) {
if (globals.profile) profile_name = globals.profile->name;
}
-
+
if (zstr(profile_name)) {
profile_name = "default";
}
if (context->url_params) {
ua = switch_event_get_header(context->url_params, "user_agent");
}
-
+
if (zstr(ua)) {
ua = "mod_httapi/1.0";
}
if ((p = strstr(q, "://"))) {
*(p+3) = '\0';
}
-
+
p = switch_mprintf("%s%s", q, r);
dynamic_url = p;
free(q);
switch_curl_easy_setopt(curl_handle, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
switch_curl_easy_setopt(curl_handle, CURLOPT_USERPWD, dup_creds);
}
-
+
switch_curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, ua);
switch_curl_easy_perform(curl_handle);
switch_curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &code);
switch_curl_easy_cleanup(curl_handle);
-
+
if (client->fd > -1) {
close(client->fd);
client->fd = -1;
case 404:
status = SWITCH_STATUS_NOTFOUND;
break;
-
+
default:
status = SWITCH_STATUS_FALSE;
break;
} else if (headers && (cc = switch_event_get_header(headers, "Cache-Control"))) {
if ((p = switch_stristr("max-age=", cc))) {
p += 8;
-
+
if (!zstr(p)) {
x = atoi(p);
}
}
- switch_snprintf(write_data, sizeof(write_data),
+ switch_snprintf(write_data, sizeof(write_data),
"%" TIME_T_FMT ":%s",
switch_epoch_time_now(NULL) + ttl,
data);
-
+
status = write(fd, write_data, (int)strlen(write_data) + 1) > 0 ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
}
switch_yield(100000);
}
} while(x);
-
+
switch_core_hash_insert(globals.request_hash, context->dest_url, (void *)1);
switch_mutex_unlock(globals.request_mutex);
} else {
if (context->url_params) {
ext = switch_event_get_header(context->url_params, "ext");
}
-
+
if (zstr(ext)) {
ext = find_ext(context->cache_file);
}
unreachable = 1;
}
}
-
+
if (zstr(ext) && headers && (ct = switch_event_get_header(headers, "content-type"))) {
newext = switch_core_mime_type2ext(ct);
}
status = SWITCH_STATUS_NOTFOUND;
goto end;
}
-
+
if (!unreachable && !zstr(context->metadata)) {
metadata = switch_core_sprintf(context->pool, "%s:%s:%s:%s:%s",
url,
switch_goto_status(SWITCH_STATUS_SUCCESS, end);
}
}
-
+
switch_event_destroy(&headers);
}
switch_event_get_header_nil(headers, "content-length"),
ext
);
-
+
write_meta_file(context, metadata, headers);
-
+
if (switch_file_exists(context->cache_file, context->pool) == SWITCH_STATUS_SUCCESS) {
status = SWITCH_STATUS_SUCCESS;
}
}
switch_event_destroy(&headers);
-
+
return status;
}
context->fh.samples = handle->samples;
context->fh.samplerate = handle->samplerate;
context->fh.prefix = handle->prefix;
-
-
+
+
if (context->url_params) {
context->write.file_name = switch_event_get_header(context->url_params, "file");
context->write.profile_name = switch_event_get_header(context->url_params, "profile");
context->write.method = switch_event_get_header(context->url_params, "method");
context->write.name = switch_event_get_header(context->url_params, "name");
}
-
+
if (!context->write.file_name) {
char *p;
if ((p = strrchr(context->dest_url, '/'))) {
p++;
context->write.file_name = switch_core_strdup(context->pool, p);
- }
+ }
}
if (!context->write.file_name) {
} else {
ext = "wav";
}
-
+
if (!context->write.profile_name) context->write.profile_name = "default";
if (!context->write.method) context->write.method = !strcasecmp(ext, "cgi") ? "post" : "put";
if (!context->write.name) context->write.name = "recorded_file";
switch_uuid_str(context->write.uuid_str, sizeof(context->write.uuid_str));
-
+
context->write.file = switch_core_sprintf(context->pool, "%s%s%s_%s",
SWITCH_GLOBAL_dirs.temp_dir, SWITCH_PATH_SEPARATOR, context->write.uuid_str, context->write.file_name);
-
+
if (switch_core_file_open(&context->fh, context->write.file, handle->channels, handle->samplerate, handle->flags, NULL) != SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_GENERR;
if (status != SWITCH_STATUS_SUCCESS) {
return status;
}
-
+
if ((status = switch_core_file_open(&context->fh,
- context->cache_file,
- handle->channels,
- handle->samplerate,
+ context->cache_file,
+ handle->channels,
+ handle->samplerate,
handle->flags, NULL)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid cache file %s opening url %s Discarding file.\n", context->cache_file, path);
unlink(context->cache_file);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find suitable profile\n");
switch_event_destroy(¶ms);
}
-
+
unlink(context->write.file);
return SWITCH_STATUS_SUCCESS;
}
-
+
if (context->del_on_close) {
if (context->cache_file) {
unlink(context->cache_file);
static switch_status_t http_file_read_video(switch_file_handle_t *handle, switch_frame_t *frame, switch_video_read_flag_t flags)
{
http_file_context_t *context = handle->private_info;
-
+
return switch_core_file_read_video(&context->fh, frame, flags);
}
static switch_status_t http_file_write(switch_file_handle_t *handle, void *data, size_t *len)
{
http_file_context_t *context = handle->private_info;
-
+
return switch_core_file_write(&context->fh, data, len);
}
switch_application_interface_t *app_interface;
switch_file_interface_t *http_file_interface;
switch_file_interface_t *https_file_interface;
-
+
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
https_file_interface->file_seek = http_file_file_seek;
https_file_interface->file_read_video = http_file_read_video;
https_file_interface->file_write_video = http_file_write_video;
-
+
switch_snprintf(globals.cache_path, sizeof(globals.cache_path), "%s%shttp_file_cache", SWITCH_GLOBAL_dirs.storage_dir, SWITCH_PATH_SEPARATOR);
switch_dir_make_recursive(globals.cache_path, SWITCH_DEFAULT_DIR_PERMS, pool);
-
+
switch_core_hash_init(&globals.profile_hash);
switch_core_hash_init(&globals.request_hash);
switch_core_hash_init_case(&globals.parse_hash, SWITCH_FALSE);
if (do_config() != SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_FALSE;
}
-
+
SWITCH_ADD_API(httapi_api_interface, "httapi",
"HT-TAPI Hypertext Telephony API", httapi_api_function, HTTAPI_SYNTAX);
- SWITCH_ADD_APP(app_interface, "httapi",
- "HT-TAPI Hypertext Telephony API",
+ SWITCH_ADD_APP(app_interface, "httapi",
+ "HT-TAPI Hypertext Telephony API",
"HT-TAPI Hypertext Telephony API", httapi_function, "{<param1>=<val1>}", SAF_SUPPORT_NOMEDIA);
-
+
switch_console_set_complete("add httapi debug_on");
}
- switch_core_hash_destroy(&globals.profile_hash);
- switch_core_hash_destroy(&globals.parse_hash);
-
+ switch_core_hash_destroy(&globals.profile_hash);
+ switch_core_hash_destroy(&globals.parse_hash);
+
while (globals.hash_root) {
ptr = globals.hash_root;
switch_core_hash_destroy(&ptr->hash);
switch_curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, headers);
switch_curl_easy_setopt(curl_handle, CURLOPT_URL, full_url);
- /* we want to use our own read function so we can send a portion of the file */
+ /* we want to use our own read function so we can send a portion of the file */
switch_curl_easy_setopt(curl_handle, CURLOPT_READFUNCTION, read_callback);
switch_curl_easy_setopt(curl_handle, CURLOPT_READDATA, &block_info);
parse_url(strdup("https://my-bucket-with-dash.s3-us-west-2.amazonaws.com/greeting/file/1002/Lumino.mp3"), NULL, "s3", &bucket, &object);
ASSERT_STRING_EQUALS("my-bucket-with-dash", bucket);
ASSERT_STRING_EQUALS("greeting/file/1002/Lumino.mp3", object);
-
+
parse_url(strdup("http://quotes.s3.foo.bar.s3.amazonaws.com/greeting/file/1002/Lumino.mp3"), NULL, "s3", &bucket, &object);
ASSERT_STRING_EQUALS("quotes.s3.foo.bar", bucket);
ASSERT_STRING_EQUALS("greeting/file/1002/Lumino.mp3", object);
<include>
-
+
<X-PRE-PROCESS cmd="set" data="AT_EPENT1=0 0 0 -1 -1 0 -1 0 -1 -1 0 -1"/>
<X-PRE-PROCESS cmd="set" data="AT_EPENT2=1 1 1 -1 -1 1 -1 1 -1 -1 1 -1"/>
<X-PRE-PROCESS cmd="set" data="AT_CPENT1=0 -1 -1 0 -1 0 0 0 -1 -1 0 -1"/>
<X-PRE-PROCESS cmd="set" data="AT_CMAJ2=1 -1 1 1 -1 1 -1 1 1 -1 1 -1"/>
<X-PRE-PROCESS cmd="set" data="AT_BBLUES=1 -1 1 -1 -1 1 -1 1 1 1 -1 -1"/>
<X-PRE-PROCESS cmd="set" data="ATGPENT2=-1 1 -1 1 -1 1 -1 -1 1 -1 1 -1"/>
-
- <extension name="101">
- <condition field="destination_number" expression="^101$">
+
+ <extension name="101">
+ <condition field="destination_number" expression="^101$">
<!-- AUTOTALENT DEFAULTS -->
<!--
<action application="set"><![CDATA[ladspa_params=${AT_TUNE} ${AT_FIXED} ${AT_PULL} ${AT_EPENT2} ${AT_AMOUNT} ${AT_SMOOTH} ${AT_SHIFT} ${AT_OUTSCALE} ${AT_LFODEPTH} ${AT_LFORATE} ${AT_LFOSHAPE} ${AT_LFOSYMM} ${AT_LFOQUANT} ${AT_FCORR} ${AT_FWARP} ${AT_MIX}]]></action>
-
+
<action application="ladspa_run" data="r|autotalent||${ladspa_params}"/>
<action application="ladspa_run" data="r|tap_chorusflanger||"/>
<action application="ladspa_run" data="r|phasers_1217.so|autoPhaser|"/>
<action application="bridge" data="sofia/internal/888@conference.freeswitch.org"/>
- </condition>
- </extension>
+ </condition>
+ </extension>
</include>
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
- * mod_ladspa.c -- LADSPA
+ * mod_ladspa.c -- LADSPA
*
*/
#include <switch.h>
SWITCH_MODULE_RUNTIME_FUNCTION(mod_ladspa_runtime);
SWITCH_MODULE_LOAD_FUNCTION(mod_ladspa_load);
-/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
+/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
* Defines a switch_loadable_module_function_table_t and a static const char[] modname
*/
SWITCH_MODULE_DEFINITION(mod_ladspa, mod_ladspa_load, mod_ladspa_shutdown, NULL);
int check_range(const LADSPA_Descriptor *ldesc, int i, LADSPA_Data val)
{
- if (ldesc->PortRangeHints[i].LowerBound && ldesc->PortRangeHints[i].UpperBound &&
+ if (ldesc->PortRangeHints[i].LowerBound && ldesc->PortRangeHints[i].UpperBound &&
(val < ldesc->PortRangeHints[i].LowerBound || val > ldesc->PortRangeHints[i].UpperBound)) {
- switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, "Param %f out of bounds %f-%f\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, "Param %f out of bounds %f-%f\n",
val, ldesc->PortRangeHints[i].LowerBound, ldesc->PortRangeHints[i].UpperBound);
return 0;
}
}
int find_default(const LADSPA_Descriptor *ldesc, int i, LADSPA_Data *ptr)
-
+
{
LADSPA_Data dftval = 0;
int fail = 0;
LADSPA_PortRangeHintDescriptor port_hint = ldesc->PortRangeHints[i].HintDescriptor;
-
+
switch (port_hint & LADSPA_HINT_DEFAULT_MASK) {
case LADSPA_HINT_DEFAULT_NONE:
break;
if (LADSPA_IS_PORT_CONTROL(ldesc->PortDescriptors[i])) {
if (found) {
- switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "\n RANGE: %f-%f DEFAULT: %f\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "\n RANGE: %f-%f DEFAULT: %f\n",
ldesc->PortRangeHints[i].LowerBound, ldesc->PortRangeHints[i].UpperBound, dft);
} else {
- switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "\n RANGE: %f-%f DEFAULT: none.\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "\n RANGE: %f-%f DEFAULT: none.\n",
ldesc->PortRangeHints[i].LowerBound, ldesc->PortRangeHints[i].UpperBound);
}
}
-
+
}
switch_channel_t *channel = switch_core_session_get_channel(pvt->session);
switch (type) {
- case SWITCH_ABC_TYPE_INIT:
+ case SWITCH_ABC_TYPE_INIT:
{
switch_codec_implementation_t read_impl = { 0 };
LADSPA_PortDescriptor port_desc;
int i = 0, j = 0, k = 0, str_idx = 0;
-
+
switch_core_session_get_read_impl(pvt->session, &read_impl);
if (!(pvt->library_handle = loadLADSPAPluginLibrary(pvt->plugin_name))) {
return SWITCH_FALSE;
}
-
+
if (!(pvt->ldesc = findLADSPAPluginDescriptor(pvt->library_handle, pvt->plugin_name, pvt->label_name))) {
return SWITCH_FALSE;
}
pvt->handle = pvt->ldesc->instantiate(pvt->ldesc, read_impl.actual_samples_per_second);
dump_info(pvt->ldesc);
-
+
for (i = 0; i < pvt->ldesc->PortCount; i++) {
port_desc = pvt->ldesc->PortDescriptors[i];
-
+
if (LADSPA_IS_PORT_CONTROL(port_desc) && LADSPA_IS_PORT_INPUT(port_desc)) {
LADSPA_Data dft = 0.0f;
int found = find_default(pvt->ldesc, i, &dft);
-
+
if (found && !pvt->has_config[j]) {
pvt->config[j] = dft;
pvt->has_config[j] = 1;
if (pvt->has_config[j]) {
if (!check_range(pvt->ldesc, i, pvt->config[j])) {
pvt->config[j] = dft;
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_WARNING, "FALLING TO DEFAULT PARAM %d [%s] (%f)\n",
- j+1,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_WARNING, "FALLING TO DEFAULT PARAM %d [%s] (%f)\n",
+ j+1,
pvt->ldesc->PortNames[i],
- pvt->config[j]);
+ pvt->config[j]);
}
-
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_DEBUG, "ADDING PARAM %d [%s] (%f)\n",
- j+1,
+
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_DEBUG, "ADDING PARAM %d [%s] (%f)\n",
+ j+1,
pvt->ldesc->PortNames[i],
pvt->config[j]);
pvt->ldesc->connect_port(pvt->handle, i, &pvt->config[j++]);
if (pvt->str_idx && !zstr(pvt->str_config[str_idx])) {
if (!strcasecmp(pvt->str_config[str_idx], "none")) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_DEBUG, "CONNECT NOTHING to port: %s\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_DEBUG, "CONNECT NOTHING to port: %s\n",
pvt->ldesc->PortNames[i]
);
mapped = 1;
char *file = pvt->str_config[str_idx] + 5;
if (switch_test_flag((&pvt->fh), SWITCH_FILE_OPEN)) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session),
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session),
SWITCH_LOG_ERROR, "CAN'T CONNECT FILE [%s] File already mapped\n", file);
} else {
if (switch_core_file_open(&pvt->fh,
file,
read_impl.number_of_channels,
- read_impl.actual_samples_per_second,
+ read_impl.actual_samples_per_second,
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_ERROR, "Cannot open file: %s\n", file);
return SWITCH_FALSE;
}
-
-
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_DEBUG, "CONNECT FILE [%s] to port: %s\n",
+
+
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_DEBUG, "CONNECT FILE [%s] to port: %s\n",
file,
pvt->ldesc->PortNames[i]
);
if (!mapped) {
pvt->ldesc->connect_port(pvt->handle, i, pvt->in_buf);
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_DEBUG, "CONNECT CHANNEL AUDIO to port: %s\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_DEBUG, "CONNECT CHANNEL AUDIO to port: %s\n",
pvt->ldesc->PortNames[i]
);
}
}
break;
-
+
case SWITCH_ABC_TYPE_CLOSE:
{
if (pvt->library_handle) {
unloadLADSPAPluginLibrary(pvt->library_handle);
- }
+ }
}
break;
}
slin = rframe->data;
-
+
if (switch_channel_media_ready(channel)) {
switch_short_to_float(slin, pvt->in_buf, rframe->samples);
switch_core_session_get_read_impl(pvt->session, &read_impl);
switch_core_file_close(&pvt->fh);
-
+
if (switch_core_file_open(&pvt->fh,
file,
read_impl.number_of_channels,
- read_impl.actual_samples_per_second,
+ read_impl.actual_samples_per_second,
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_ERROR, "Cannot open file: %s\n", file);
return SWITCH_FALSE;
- }
+ }
olen = rframe->samples;
if (switch_core_file_read(&pvt->fh, abuf, &olen) != SWITCH_STATUS_SUCCESS) {
return SWITCH_FALSE;
}
}
-
+
switch_short_to_float(abuf, pvt->file_buf, olen);
}
if (zstr(flags)) {
flags = "r";
}
-
+
if (strchr(flags, 'w')) {
bflags = SMBF_WRITE_REPLACE;
}
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "FLAGS: %s PLUGIN: %s LABEL: %s PARAMS: %s\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "FLAGS: %s PLUGIN: %s LABEL: %s PARAMS: %s\n",
flags, plugin_name, label, params);
switch_core_session_get_read_impl(session, &read_impl);
} else {
pvt->plugin_name = switch_core_session_sprintf(session, "%s.so", plugin_name);
}
-
+
dparams = switch_core_session_strdup(session, params);
argc = switch_split(dparams, ' ', argv);
}
#define APP_SYNTAX "<flags>|<plugin>|<label>|<params>"
-SWITCH_STANDARD_APP(ladspa_run_function)
+SWITCH_STANDARD_APP(ladspa_run_function)
{
ladspa_parse(session, data);
}
if (!(ksession = switch_core_session_locate(uuid))) {
stream->write_function(stream, "-ERR non-existant UUID\n");
- goto done;
- }
+ goto done;
+ }
if ((action = strstr(cmd, "stop"))) {
- stop_ladspa_session(ksession);
+ stop_ladspa_session(ksession);
switch_core_session_rwunlock(ksession);
stream->write_function(stream, "+OK\n");
goto done;
stream->write_function(stream, "+OK\n");
} else {
stream->write_function(stream, "-ERR Usage %s\n", API_SYNTAX);
- }
+ }
done:
style) and a LADSPA_DescriptorFunction (from which
LADSPA_Descriptors can be acquired). */
typedef void LADSPAPluginSearchCallbackFunction
-(const char * pcFullFilename,
+(const char * pcFullFilename,
void * pvPluginHandle,
LADSPA_Descriptor_Function fDescriptorFunction);
<param name="id" value="2"/>
<param name="order_by" value="reliability,quality"/>
</profile>
-<!--
+<!--
Some samples of how to do custom SQL:
=============================================================
-<include>
+<include>
<extension name="Outbound to PSTN 11 Digits">
<condition field="destination_number" expression="^(1[2-9][0-9]{2}[2-9]{7})$">
<action application="lcr" data="$1"/>
<condition>
<action application="limit" data="db $${domain} ${sip_auth_username} ${max_calls}"/>
</condition>
- </extension>
+ </extension>
</include>
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Rupa Schomaker <rupa@rupa.com>
*
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Loading mod_limit - a shim for backwards compatability with the new limit system. This is deprecated, remove mod_limit and instead load mod_hash and mod_db!\n");
-
+
/* try to load mod_hash if it isn't loaded */
if (switch_loadable_module_exists("mod_hash") != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "mod_hash not loaded, trying to load...!\n");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to load mod_hash (%s)!\n", err);
}
}
-
+
/* try to load mod_db if it isn't loaded */
if (switch_loadable_module_exists("mod_db") != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "mod_db not loaded, trying to load...!\n");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to load mod_db (%s)!\n", err);
}
}
-
+
/* set compat flag */
switch_core_set_variable("switch_limit_backwards_compat_flag", "true");
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Rupa Schomaker <rupa@rupa.com>
*
* mod_memcache.c -- API for memcache
SWITCH_MODULE_RUNTIME_FUNCTION(mod_memcache_runtime);
SWITCH_MODULE_LOAD_FUNCTION(mod_memcache_load);
-/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
+/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
* Defines a switch_loadable_module_function_table_t and a static const char[] modname
*/
SWITCH_MODULE_DEFINITION(mod_memcache, mod_memcache_load, mod_memcache_shutdown, NULL);
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "%s waiting for video.\n", switch_channel_get_name(channel));
count = 100;
if (!--sanity) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s timeout waiting for video.\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s timeout waiting for video.\n",
switch_channel_get_name(channel));
return;
}
}
}
-
+
if (!switch_channel_ready(channel)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "%s not ready.\n", switch_channel_get_name(channel));
return;
sent = true;
}
- }
+ }
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pt->session), SWITCH_LOG_DEBUG, "Video thread ended\n");
pt->done = true;
switch_dtmf_t dtmf = {0};
pt->done = false;
switch_frame_t * read_frame;
-
+
while (!*pt->quit && switch_channel_ready(pt->channel)) {
// event processing.
// -- SEE switch_ivr_play_say.c:1231 && mod_dptools.c:1428 && mod_dptools.c:1919
break;
}
}
-
+
switch_mutex_lock(pt->mutex);
pt->frame->datalen = pt->frame->buflen;
ok = pt->vc->getAudioPacket(pt->frame->data, pt->frame->datalen, next);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Error opening file %s\n", (char *) data);
return;
}
-
+
if(!vc.isSupported())
{
char msgbuf[1024];
sprintf(msgbuf, "PLAYBACK ERROR (%s): UNSUPPORTED FORMAT OR FILE NOT HINTED.", (char*) data);
switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE, msgbuf);
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT,
"Error reading track info. Maybe this file is not hinted.\n");
throw 1;
}
vpt.vc = &vc;
switch_mutex_init(&vpt.mutex, SWITCH_MUTEX_DEFAULT, switch_core_session_get_pool(session));
vpt.quit = &done;
-
+
switch_threadattr_t * thd_attr;
switch_threadattr_create(&thd_attr, switch_core_session_get_pool(session));
switch_threadattr_detach_set(thd_attr, 1);
}
switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE, "FILE PLAYED");
- } catch(const std::exception & e)
+ } catch(const std::exception & e)
{
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "%s\n", e.what());
switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE,
The Original Code is MP4 Helper Library to the Freeswitch MP4 Module.
-The Initial Developer of the Original Code is
+The Initial Developer of the Original Code is
Paulo Rogério Panhoto <paulo@voicetechnology.com.br>.
Portions created by the Initial Developer are Copyright (C)
the Initial Developer. All Rights Reserved.
namespace MP4
{
-
+
Context::Context(const char * file, bool newFile)
{
if(newFile) create(file);
else open(file);
}
-
+
Context::~Context()
{
close();
if (fh == MP4_INVALID_FILE_HANDLE) throw Exception(file, "Open failed");
getTracks(file);
}
-
+
void Context::create(const char * file)
{
fh = MP4Create(file);
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* mod_nibblebill.c - Nibble Billing
* Purpose is to allow real-time debiting of credit or cash from a database while calls are in progress. I had the following goals:
*
- * Debit credit/cash from accounts real-time
- * Allow for billing at different rates during a single call
- * Allow for warning callers when their balance is low (via audio, in-channel)
- * Allow for disconnecting or re-routing calls when balance is depleted
- * Allow for billing to function as listed above with multiple concurrent calls
- *
+ * Debit credit/cash from accounts real-time
+ * Allow for billing at different rates during a single call
+ * Allow for warning callers when their balance is low (via audio, in-channel)
+ * Allow for disconnecting or re-routing calls when balance is depleted
+ * Allow for billing to function as listed above with multiple concurrent calls
+ *
* Thanks go to bandwidth.com for funding this work.
*
*
{
switch_cache_db_handle_t *dbh = NULL;
char *dsn;
-
+
if (!zstr(globals.odbc_dsn)) {
dsn = globals.odbc_dsn;
} else {
if (switch_cache_db_get_db_handle_dsn(&dbh, dsn) != SWITCH_STATUS_SUCCESS) {
dbh = NULL;
}
-
+
return dbh;
}
cbt->balance = atof(argv[0]);
}
}
-
+
return 0;
}
{
switch_bool_t retval = SWITCH_FALSE;
switch_cache_db_handle_t *dbh = NULL;
-
+
if (globals.odbc_dsn && (dbh = nibblebill_get_db_handle())) {
if (switch_cache_db_execute_sql_callback(dbh, sql, callback, pdata, NULL) != SWITCH_STATUS_SUCCESS) {
retval = SWITCH_FALSE;
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, "odbc-dsn") && !zstr(val)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "odbc_dsn is %s\n", val);
switch_safe_free(globals.odbc_dsn);
}
}
}
-
+
/* Set defaults for any variables still not set */
setdefaults:
} else {
sql = dsql = switch_mprintf("UPDATE %q SET %q=%q- %f WHERE %q='%q'", globals.db_table, globals.db_column_cash,
globals.db_column_cash, billamount, globals.db_column_account, billaccount);
-
+
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Doing update query\n[%s]\n", sql);
sql = globals.custom_sql_lookup;
}
} else {
- sql = dsql = switch_mprintf("SELECT %q AS nibble_balance FROM %q WHERE %q='%q'",
+ sql = dsql = switch_mprintf("SELECT %q AS nibble_balance FROM %q WHERE %q='%q'",
globals.db_column_cash, globals.db_table, globals.db_column_account, billaccount);
}
balance = pdata.balance;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Retrieved current balance for account %s (balance = %f)\n", billaccount, balance);
}
-
+
switch_safe_free(dsql);
return balance;
}
-/* This is where we actually charge the guy
+/* This is where we actually charge the guy
This can be called anytime a call is in progress or at the end of a call before the session is destroyed */
static switch_status_t do_billing(switch_core_session_t *session)
{
if (!zstr(switch_channel_get_variable(channel, "nobal_amt"))) {
nobal_amt = atof(switch_channel_get_variable(channel, "nobal_amt"));
}
-
+
if (!zstr(switch_channel_get_variable(channel, "lowbal_amt"))) {
lowbal_amt = atof(switch_channel_get_variable(channel, "lowbal_amt"));
}
-
+
if (!zstr(switch_channel_get_variable(channel, "nibble_rounding"))) {
rounding_factor = pow(10, atof(switch_channel_get_variable(channel, "nibble_rounding")));
}
billamount = (atof(billrate) / 1000000 / 60) * chargedunits - nibble_data->bill_adjustments;
/* Account for the prepaid amount */
nibble_data->lastts += chargedunits;
- } else {
+ } else {
/* Convert billrate into microseconds and multiply by # of microseconds that have passed since last *successful* bill */
billamount = (atof(billrate) / 1000000 / 60) * ((ts - nibble_data->lastts)) - nibble_data->bill_adjustments;
/* Update the last time we billed */
/* don't verify balance and transfer to nobal if we're done with call */
if (switch_channel_get_state(channel) != CS_REPORTING && switch_channel_get_state(channel) != CS_HANGUP) {
-
+
balance = get_balance(billaccount, channel);
-
+
/* See if we've achieved low balance */
if (!nibble_data->lowbal_action_executed && balance <= lowbal_amt) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Balance of %f fell below low balance amount of %f! (Account %s)\n",
static switch_status_t sched_billing(switch_core_session_t *session)
{
switch_channel_t *channel = NULL;
-
+
const char *billrate = NULL;
const char *billaccount = NULL;
-
+
if (!(channel = switch_core_session_get_channel(session))) {
return SWITCH_STATUS_SUCCESS;
}
switch_channel_t *channel = NULL;
channel = switch_core_session_get_channel(session);
-
+
/* Resume any paused billings, just in case */
/* nibblebill_resume(session); */
/* on_hibernate */ NULL,
/* on_reset */ NULL,
/* on_park */ NULL,
- /* on_reporting */ NULL,
+ /* on_reporting */ NULL,
/* on_destroy */ NULL
};
switch_event_unbind(&globals.node);
switch_core_remove_state_handler(&nibble_state_handler);
switch_odbc_handle_disconnect(globals.master_odbc);
-
+
switch_safe_free(globals.dbname);
switch_safe_free(globals.odbc_dsn);
switch_safe_free(globals.db_table);
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(oreka->session), SWITCH_LOG_DEBUG, "Oreka SIP Packet:\n%s", (const char *)udp->data);
switch_socket_sendto(globals.sip_socket, globals.sip_server_addr, 0, (void *)udp->data, &udplen);
if (udplen != udp->data_len) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(oreka->session), SWITCH_LOG_ERROR, "Failed to write SIP Packet of len %zd (wrote=%zd)",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(oreka->session), SWITCH_LOG_ERROR, "Failed to write SIP Packet of len %zd (wrote=%zd)",
udp->data_len, udplen);
}
return 0;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Allocated %s port %d for local IP %s, destination IP %s\n", type_str,
rtp_port, globals.local_ipv4_str, globals.sip_server_ipv4_str);
- rtp_stream = switch_rtp_new(globals.local_ipv4_str, rtp_port,
+ rtp_stream = switch_rtp_new(globals.local_ipv4_str, rtp_port,
globals.sip_server_ipv4_str, rtp_port,
0, /* PCMU IANA*/
codec_impl->samples_per_packet,
codec_impl->microseconds_per_packet,
flags, NULL, &err, switch_core_session_get_pool(oreka->session));
if (!rtp_stream) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create %s RTP stream at %s:%d: %s\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create %s RTP stream at %s:%d: %s\n",
type_str, globals.local_ipv4_str, rtp_port, err);
res = -1;
goto done;
}
- switch_rtp_intentional_bugs(rtp_stream, RTP_BUG_SEND_LINEAR_TIMESTAMPS);
+ switch_rtp_intentional_bugs(rtp_stream, RTP_BUG_SEND_LINEAR_TIMESTAMPS);
done:
oreka->write_rtp_port = rtp_port;
}
}
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Successfully created %s RTP stream at %s:%d at %dms@%dHz\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Successfully created %s RTP stream at %s:%d at %dms@%dHz\n",
type_str, globals.local_ipv4_str, rtp_port, codec_impl->microseconds_per_packet/1000, codec_impl->samples_per_second);
return res;
}
/* Get caller meta data */
caller_id_number = switch_caller_get_field_by_name(caller_profile, "caller_id_number");
-
+
caller_id_name = switch_caller_get_field_by_name(caller_profile, "caller_id_name");
if (zstr(caller_id_name)) {
caller_id_name = caller_id_number;
sdp.write_function(&sdp, "s=Phone Recording (%s)\r\n", type == FS_OREKA_READ ? "RX" : "TX");
sdp.write_function(&sdp, "i=FreeSWITCH Oreka Recorder (pid=%d)\r\n", globals.our_pid);
sdp.write_function(&sdp, "m=audio %d RTP/AVP 0\r\n", type == FS_OREKA_READ ? oreka->read_rtp_port : oreka->write_rtp_port);
- sdp.write_function(&sdp, "a=rtpmap:0 PCMU/%d\r\n", type == FS_OREKA_READ
+ sdp.write_function(&sdp, "a=rtpmap:0 PCMU/%d\r\n", type == FS_OREKA_READ
? oreka->read_impl.samples_per_second : oreka->write_impl.samples_per_second);
}
sip_header.write_function(&sip_header, "Max-Forwards: 70\r\n", method);
/* Subject */
- sip_header.write_function(&sip_header, "Subject: %s %s recording of %s\r\n",
+ sip_header.write_function(&sip_header, "Subject: %s %s recording of %s\r\n",
status == FS_OREKA_START ? "BEGIN": "END",
type == FS_OREKA_READ ? "RX" : "TX", caller_id_name);
uint32_t i = 0;
int16_t *linear_samples = NULL;
-
+
if (type == SWITCH_ABC_TYPE_READ_REPLACE || type == SWITCH_ABC_TYPE_WRITE_REPLACE || type == SWITCH_ABC_TYPE_READ_PING) {
int16_t *data;
switch_resample_create(&oreka->write_resampler,
read_impl.actual_samples_per_second,
8000,
- 320, SWITCH_RESAMPLE_QUALITY, 1);
+ 320, SWITCH_RESAMPLE_QUALITY, 1);
}
linear_samples = linear_frame->data;
linear_len = linear_frame->datalen;
}
-
+
memset(&pcmu_frame, 0, sizeof(pcmu_frame));
for (i = 0; i < linear_len / sizeof(int16_t); i++) {
pcmu_data[i] = linear_to_ulaw(linear_samples[i]);
} else {
flags = SMBF_READ_REPLACE | SMBF_WRITE_REPLACE | SMBF_ANSWER_REQ;
}
-
+
status = switch_core_media_bug_add(session, OREKA_BUG_NAME_READ, NULL, oreka_audio_callback, oreka, 0, flags, &bug);
-
+
if (status != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Failed to attach oreka to media stream!\n");
return;
switch_get_addr(globals.sip_server_ipv4_str, sizeof(globals.sip_server_ipv4_str), globals.sip_server_addr);
globals.our_pid = getpid();
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,
- "Loading mod_oreka, sip_server_addr=%s, sip_server_ipv4_str=%s, sip_server_port=%d, local_ipv4_str=%s\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,
+ "Loading mod_oreka, sip_server_addr=%s, sip_server_ipv4_str=%s, sip_server_port=%d, local_ipv4_str=%s\n",
globals.sip_server_addr_str, globals.sip_server_ipv4_str, globals.sip_server_port, globals.local_ipv4_str);
#if 0
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
- SWITCH_ADD_APP(app_interface, "oreka_record", "Send media to Oreka recording server", "Send media to Oreka recording server",
- oreka_start_function, "[stop]", SAF_NONE);
+ SWITCH_ADD_APP(app_interface, "oreka_record", "Send media to Oreka recording server", "Send media to Oreka recording server",
+ oreka_start_function, "[stop]", SAF_NONE);
return SWITCH_STATUS_SUCCESS;
}
int pec;
int expr;
int direction;
-
+
struct config_vsas *pNext;
};
{
char* name;
char* value;
-
+
struct config_client *pNext;
};
if (received)
rc_avpair_free(received);
-
+
if (rh)
rc_destroy(rh);
rh = NULL;
CONFIG_VSAS* GetVSAS(char* key)
{
CONFIG_VSAS* PCONFIGVSAS = CONFIGVSAS;
-
+
while(PCONFIGVSAS)
{
if (strcmp(key, PCONFIGVSAS->name) == 0)
{
return PCONFIGVSAS;
}
-
+
PCONFIGVSAS = PCONFIGVSAS->pNext;
}
-
+
return NULL;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Internal Error : VSAS is null object.\n");
return "";
}
-
+
if (VSAS->value == NULL)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Internal Error : VSAS->value is null object.\n");
return "";
}
-
+
if (VSAS->expr == 1)
{
const char* v = switch_channel_get_variable(channel, VSAS->value);
memset(msg, 0, STR_LENGTH * 10);
memset(username_realm, 0, STR_LENGTH);
-
+
send = NULL;
-
+
do
{
-
+
#if EMBENDED_CONFIG
CONFIG_CLIENT* PCONFIGCLIENT = CONFIGCLIENT;
-
+
rh = rc_new();
- if (rh == NULL)
+ if (rh == NULL)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERROR: Failed to allocate initial structure.\n");
result = ERROR_RC;
break;
}
-
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "allocate initial structure.\n");
-
+
/* Initialize the config structure */
-
+
rh = rc_config_init(rh);
if (rh == NULL)
{
result = ERROR_RC;
break;
}
-
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"initialzed configuration.\n");
-
+
while(PCONFIGCLIENT)
{
- //if (rc_add_config(rh, "auth_order", "radius", "config", 0) != 0)
+ //if (rc_add_config(rh, "auth_order", "radius", "config", 0) != 0)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "set %s := %s.\n", PCONFIGCLIENT->name, PCONFIGCLIENT->value);
- if (rc_add_config(rh, PCONFIGCLIENT->name, PCONFIGCLIENT->value, "config", 0) != 0)
+ if (rc_add_config(rh, PCONFIGCLIENT->name, PCONFIGCLIENT->value, "config", 0) != 0)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERROR: Unable to set %s := %s.\n", PCONFIGCLIENT->name, PCONFIGCLIENT->value);
-
+
result = ERROR_RC;
break;
}
-
+
PCONFIGCLIENT = PCONFIGCLIENT->pNext;
}
-
+
if (result == ERROR_RC)
break;
-
+
#else
if ((rh = rc_read_config(!rc_config_file ? RC_CONFIG_FILE : rc_config_file)) == NULL)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error loading radius config file\n");
-
+
result = ERROR_RC;
break;
}
-
+
#endif
if (rc_read_dictionary(rh, rc_conf_str(rh, "dictionary")) != 0)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error loading radius dictionary\n");
-
+
result = ERROR_RC;
break;
}
-
+
default_realm = rc_conf_str(rh, "default_realm");
if (default_realm == NULL)
{
result = ERROR_RC;
break;
}
-
+
strncpy(username_realm, username, sizeof(username_realm));
if ((strchr(username_realm, '@') == NULL) && default_realm &&
strncat(username_realm, "@", sizeof(username_realm)-strlen(username_realm)-1);
strncat(username_realm, default_realm, sizeof(username_realm)-strlen(username_realm)-1);
}
-
-
+
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
"... radius: User-Name: %s\n", username);
if (rc_avpair_add(rh, &send, PW_USER_NAME, username_realm, -1, 0)== NULL)
result = ERROR_RC;
break;
}
-
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
"... radius: User-Password: %s\n", password);
if (rc_avpair_add(rh, &send, PW_USER_PASSWORD, password, -1, 0) == NULL)
result = ERROR_RC;
break;
}
-
+
if (!called_number || strcmp(called_number, "") == 0)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
}
}
-
+
PCONFIGVSAS = CONFIGVSAS;
-
+
while(PCONFIGVSAS)
{
if (PCONFIGVSAS->direction == 1)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Handle attribute: %s\n", PCONFIGVSAS->name );
-
+
memset(value, 0, STR_LENGTH);
GetValue(channel, PCONFIGVSAS, value);
-
+
if (PCONFIGVSAS->pec != 0)
attrid = PCONFIGVSAS->id | (PCONFIGVSAS->pec << 16);
else
attrid = PCONFIGVSAS->id ;
-
+
pda = rc_dict_getattr(rh, attrid);
-
+
if (pda == NULL)
{
result = ERROR_RC;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown attribute: key:%s, not found in dictionary\n", PCONFIGVSAS->name);
- break;
+ break;
}
-
+
if (PCONFIGVSAS->pec != 0 && rc_dict_getvend(rh, PCONFIGVSAS->pec) == NULL)
{
result = ERROR_RC;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown vendor specific id: key:%s, id:%dnot found in dictionary\n", PCONFIGVSAS->name, PCONFIGVSAS->pec);
- break;
+ break;
}
-
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "... dictionary data: id:%d, vendor id:%d, attr type:%d, attr name:%s (%d)\n", PCONFIGVSAS->id, PCONFIGVSAS->pec, pda->type, pda->name, attrid);
-
+
switch(pda->type)
{
case PW_TYPE_STRING:
break;
}
break;
-
+
//case PW_TYPE_DATE:
case PW_TYPE_INTEGER:
integer = atoi(value);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "... radius: key:%s, value:%s (%d) as integer\n", PCONFIGVSAS->name, PCONFIGVSAS->value, integer);
-
-
+
+
if (rc_avpair_add(rh, &send, PCONFIGVSAS->id, &integer, -1, PCONFIGVSAS->pec) == NULL)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "An Error occured during rc_avpair_add : %s\n", PCONFIGVSAS->name);
case PW_TYPE_IPADDR:
integer = rc_get_ipaddr(value);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "... radius: key:%s, value:%s (%d) as ipaddr\n", PCONFIGVSAS->name, PCONFIGVSAS->value, integer);
-
-
+
+
if (rc_avpair_add(rh, &send, PCONFIGVSAS->id, &integer, -1, PCONFIGVSAS->pec) == NULL)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "An Error occured during rc_avpair_add : %s\n", PCONFIGVSAS->name);
result = ERROR_RC;
break;
}
- break;
-
+ break;
+
default:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown attribute type: key:%s, type %d\n", PCONFIGVSAS->name, pda->type);
break;
}
}
-
+
PCONFIGVSAS = PCONFIGVSAS->pNext;
}
-
+
if (result != ERROR_RC)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "sending radius packet ...\n" );
result = rc_auth(rh, 0, send, &received, msg);
-
-
+
+
if (result == OK_RC)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
"RADIUS Authentication OK\n");
-
+
strcpy(auth_result, "OK");
}
else
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
- " RADIUS Authentication failure (RC=%d)\n",
+ " RADIUS Authentication failure (RC=%d)\n",
result);
-
+
strcpy(auth_result, "NOK");
}
-
-
-
+
+
+
PCONFIGVSAS = CONFIGVSAS;
-
+
while(PCONFIGVSAS)
{
if (PCONFIGVSAS->direction == 0)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "\tattribute (%s) found in radius packet\n", PCONFIGVSAS->name);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "\tset variable %s := %s\n", PCONFIGVSAS->value, service_vp->strvalue);
-
+
switch_channel_set_variable(channel, PCONFIGVSAS->value, service_vp->strvalue);
}
else
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "\tNo found out attribute id: %d, pec:%d, (%s)\n", PCONFIGVSAS->id, PCONFIGVSAS->pec, PCONFIGVSAS->name );
}
}
-
+
PCONFIGVSAS = PCONFIGVSAS->pNext;
}
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "abort sending radius packet.\n" );
break;
}
-
+
} while(1 == 0);
if (result == ERROR_RC)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
- "An error occured during RADIUS Authentication(RC=%d)\n",
+ "An error occured during RADIUS Authentication(RC=%d)\n",
result);
}
-
+
free_radius_auth_value_pair(send, received, rh);
-
+
return result;
}
char* in_called_number = NULL;
char *in_username = NULL;
char *in_password = NULL;
-
+
char *out_auth_result = NULL;
/*char *out_biling_model = NULL;
char *out_credit_amount = NULL;
char *out_currency = NULL;
char *out_preffered_lang = NULL;*/
-
+
char auth_result[STR_LENGTH + 1];
- /*char biling_model[STR_LENGTH + 1];
+ /*char biling_model[STR_LENGTH + 1];
char credit_amount[STR_LENGTH + 1];
char currency[STR_LENGTH + 1];
char preffered_lang[STR_LENGTH + 1];*/
switch_channel_t *channel = switch_core_session_get_channel(session);
-
+
memset(auth_result, 0, STR_LENGTH);
- /*memset(biling_model, 0, STR_LENGTH);
+ /*memset(biling_model, 0, STR_LENGTH);
memset(credit_amount, 0, STR_LENGTH);
memset(currency, 0, STR_LENGTH);
memset(preffered_lang, 0, STR_LENGTH);*/
}
else
{
-
+
char *in_called_number_expanded = NULL;
char *in_username_expanded = NULL;
char *in_password_expanded = NULL;
in_called_number = switch_core_session_strdup(session, data);
-
+
in_username = strchr(in_called_number, ',');
if (in_username)
in_username = NULL;
}
}
-
+
in_password = strchr(in_username, ',');
if (in_password)
out_auth_result = NULL;
}
}
-
+
/*out_biling_model = strchr(out_auth_result, ',');
if (out_biling_model)
out_biling_model = NULL;
}
}
-
+
out_credit_amount = strchr(out_biling_model, ',');
if (out_credit_amount)
out_credit_amount = NULL;
}
}
-
+
out_currency = strchr(out_credit_amount, ',');
if (out_currency)
out_currency = NULL;
}
}
-
+
out_preffered_lang = strchr(out_currency, ',');
if (out_preffered_lang)
if (in_called_number)
in_called_number = extract_in_variable(in_called_number);
-
+
in_username = extract_in_variable(in_username);
in_password = extract_in_variable(in_password);
out_auth_result = extract_out_variable(out_auth_result);
if (in_called_number)
in_called_number_expanded = switch_channel_expand_variables(channel, in_called_number);
-
+
in_username_expanded = switch_channel_expand_variables(channel, in_username);
in_password_expanded = switch_channel_expand_variables(channel, in_password);
{
switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "An error occured during radius authorization.\n");
}
-
+
switch_channel_set_variable(channel, out_auth_result, auth_result);
-
+
/*switch_channel_set_variable(channel, out_biling_model, biling_model);
switch_channel_set_variable(channel, out_credit_amount, credit_amount);
switch_channel_set_variable(channel, out_currency, currency);
switch_channel_set_variable(channel, out_preffered_lang, preffered_lang);*/
-
+
if (in_called_number && in_called_number_expanded && in_called_number_expanded != in_called_number)
{
switch_safe_free(in_called_number_expanded);
}
-
+
if (in_username_expanded && in_username_expanded != in_username)
{
switch_safe_free(in_username_expanded);
switch_xml_t cfg, xml, settings, param;
switch_status_t status = SWITCH_STATUS_SUCCESS;
switch_event_t *params = NULL;
-
+
char *name;
char *id;
char *value;
char *pec;
char *expr;
char* direction;
-
+
CONFIGVSAS = NULL;
CONFIGCLIENT = NULL;
"profile_rad_auth");
//vsas
-
+
if (!(xml = switch_xml_open_cfg(cf, &cfg, params)))
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
status = SWITCH_STATUS_FALSE;
return status;
}
-
+
if ((settings = switch_xml_child(cfg, "settings")))
{
for (param = switch_xml_child(settings, "param"); param; param
{
name = (char *) switch_xml_attr_soft(param, "name");
value = (char *) switch_xml_attr_soft(param, "value");
-
+
if (strcmp(name, "radius_config") == 0)
{
if (rc_config_file == NULL)
rc_config_file = malloc(STR_LENGTH + 1);
strcpy(rc_config_file, value);
-
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "radius config: %s\n", value);
}
}
}
-
+
if ((settings = switch_xml_child(cfg, "vsas")))
{
for (param = switch_xml_child(settings, "param"); param; param
PCONFIGVSAS->pNext = malloc(sizeof(CONFIG_VSAS));
PCONFIGVSAS = PCONFIGVSAS->pNext;
}
-
+
name = (char *) switch_xml_attr_soft(param, "name");
id = (char *) switch_xml_attr_soft(param, "id");
value = (char *) switch_xml_attr_soft(param, "value");
pec = (char *) switch_xml_attr_soft(param, "pec");
expr = (char *) switch_xml_attr_soft(param, "expr");
direction = (char *) switch_xml_attr_soft(param, "direction");
-
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "config attr: %s, %s, %s, %s, %s, %s\n", name, id, value, pec, expr, direction);
-
+
PCONFIGVSAS->name = (char*) malloc(STR_LENGTH + 1);
PCONFIGVSAS->value = (char*) malloc(STR_LENGTH + 1);
-
+
strncpy(PCONFIGVSAS->name, name, STR_LENGTH);
strncpy(PCONFIGVSAS->value, value, STR_LENGTH);
PCONFIGVSAS->id = atoi(id);
PCONFIGVSAS->pNext = NULL;
}
}
-
-
+
+
if ((settings = switch_xml_child(cfg, "client")))
{
for (param = switch_xml_child(settings, "param"); param; param
PCONFIGCLIENT->pNext = malloc(sizeof(CONFIG_CLIENT));
PCONFIGCLIENT = PCONFIGCLIENT->pNext;
}
-
+
name = (char *) switch_xml_attr_soft(param, "name");
value = (char *) switch_xml_attr_soft(param, "value");
-
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "config client: %s, %s\n", name, value);
-
+
PCONFIGCLIENT->name = (char*) malloc(STR_LENGTH + 1);
PCONFIGCLIENT->value = (char*) malloc(STR_LENGTH + 1);
-
+
strncpy(PCONFIGCLIENT->name, name, STR_LENGTH);
strncpy(PCONFIGCLIENT->value, value, STR_LENGTH);
switch_application_interface_t *app_interface;
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
-
+
SWITCH_ADD_APP(app_interface, "auth_function", NULL, NULL, auth_function, "in <USERNAME>, in <PASSWORD>, out <AUTH_RESULT>, out <BILING_MODEL>, out <CREDIT_AMOUNT>, out <CURRENCY>, out <PREFFERED_LANG>", SAF_SUPPORT_NOMEDIA);
load_config();
-
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
"mod rad_auth services is loaded.\n");
return SWITCH_STATUS_TERM;
}
-SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_rad_authshutdown)
+SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_rad_authshutdown)
{
CONFIG_VSAS* PCONFIGVSAS = CONFIGVSAS;
CONFIG_CLIENT* PCONFIGCLIENT = CONFIGCLIENT;
-
+
CONFIG_VSAS* tmpVSAS = NULL;
CONFIG_CLIENT* tmpCLIENT = NULL;
-
+
while(PCONFIGVSAS)
{
if (PCONFIGVSAS->name)
free(PCONFIGVSAS->name);
PCONFIGVSAS->name = NULL;
-
+
if (PCONFIGVSAS->value)
free(PCONFIGVSAS->value);
- PCONFIGVSAS->value = NULL;
-
+ PCONFIGVSAS->value = NULL;
+
tmpVSAS = PCONFIGVSAS;
PCONFIGVSAS = PCONFIGVSAS->pNext;
-
+
free(tmpVSAS);
}
-
+
CONFIGVSAS = NULL;
-
-
+
+
while(PCONFIGCLIENT)
{
if (PCONFIGCLIENT->name)
free(PCONFIGCLIENT->name);
PCONFIGCLIENT->name = NULL;
-
+
if (PCONFIGCLIENT->value)
free(PCONFIGCLIENT->value);
- PCONFIGCLIENT->value = NULL;
-
+ PCONFIGCLIENT->value = NULL;
+
tmpCLIENT = PCONFIGCLIENT;
PCONFIGCLIENT = PCONFIGCLIENT->pNext;
-
+
free(tmpCLIENT);
}
-
+
CONFIGCLIENT = NULL;
-
+
return SWITCH_STATUS_SUCCESS;
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Neal Horman <neal at wanlink dot com>
*
char *buf;
if (switch_event_serialize(event, &buf, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) {
- random_add_entropy(rfd, buf, strlen(buf));
+ random_add_entropy(rfd, buf, strlen(buf));
free(buf);
}
{
unsigned char data[1024] = {0};
-
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s Thread starting using random_device_file %s\n", modname, random_device_file);
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s Thread starting using random_device_file %s\n", modname, random_device_file);
if ((rfd = open(random_device_file, O_RDWR)) < 0) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s Error opening random_device_file %s\n", modname, random_device_file);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s Error opening random_device_file %s\n", modname, random_device_file);
RUNNING = 0;
}
rng_read(rfd, data, 4);
-
+
while(RUNNING) {
int16_t data[64];
int i = 0;
int len = sizeof(data) / 2;
switch_generate_sln_silence(data, len, 1, 1);
- random_add_entropy(rfd, data, len);
+ random_add_entropy(rfd, data, len);
while(i < len && !data[i]) i++;
close(rfd);
}
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s Thread ending\n", modname);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s Thread ending\n", modname);
return SWITCH_STATUS_TERM;
}
int size;
} cr_buffer;
-typedef struct _cr_multibulk {
- char **bulks;
+typedef struct _cr_multibulk {
+ char **bulks;
int *idxs;
int size;
- int len;
+ int len;
} cr_multibulk;
typedef struct _cr_reply {
return 0;
}
-/* Allocate at least `size' more multibulk storage, keeping content of
+/* Allocate at least `size' more multibulk storage, keeping content of
* previously allocated memory untouched.
* Returns:
* 0 on success
* -1 on error, i.e. more memory not available */
-static int cr_morebulk(cr_multibulk *mb, int size)
+static int cr_morebulk(cr_multibulk *mb, int size)
{
char **cptr;
int *iptr;
n = (size / CR_MULTIBULK_SIZE + 1) * CR_MULTIBULK_SIZE;
total = mb->size + n;
- DEBUG("allocate %d x CR_MULTIBULK_SIZE, total %d (%lu bytes)",
+ DEBUG("allocate %d x CR_MULTIBULK_SIZE, total %d (%lu bytes)",
n, total, total * ((sizeof(char *)+sizeof(int))));
cptr = realloc(mb->bulks, total * sizeof(char *));
DEBUG("truncated, get more memory and try again");
if (cr_moremem(buf, rc - avail + 1))
return CREDIS_ERR_NOMEM;
-
+
avail = buf->size - buf->len;
rc = snprintf(buf->data + buf->len, avail, format, str);
}
return 0;
}
-/* Appends an array of strings `strv' to the end of buffer `buf', each
- * separated with a space. If `newline' is not 0 "\r\n" is added last
+/* Appends an array of strings `strv' to the end of buffer `buf', each
+ * separated with a space. If `newline' is not 0 "\r\n" is added last
* to buffer.
* Returns:
* 0 on success
return 0;
}
-/* Receives at most `size' bytes from socket `fd' to `buf'. Times out after
+/* Receives at most `size' bytes from socket `fd' to `buf'. Times out after
* `msecs' milliseconds if no data has yet arrived.
* Returns:
* >0 number of read bytes on success
else if (rc == 0)
return -2;
else
- return -1;
+ return -1;
}
-/* Sends `size' bytes from `buf' to socket `fd' and times out after `msecs'
- * milliseconds if not all data has been sent.
+/* Sends `size' bytes from `buf' to socket `fd' and times out after `msecs'
+ * milliseconds if not all data has been sent.
* Returns:
* >0 number of bytes sent; if less than `size' it means that timeout occurred
* -1 on error */
fd_set fds;
struct timeval tv;
int rc, sent=0;
-
- /* NOTE: On Linux, select() modifies timeout to reflect the amount
+
+ /* NOTE: On Linux, select() modifies timeout to reflect the amount
* of time not slept, on other systems it is likely not the same */
tv.tv_sec = msecs/1000;
tv.tv_usec = (msecs%1000)*1000;
else if (rc == 0) /* timeout */
break;
else
- return -1;
+ return -1;
}
return sent;
}
-/* Buffered read line, returns pointer to zero-terminated string
+/* Buffered read line, returns pointer to zero-terminated string
* and length of that string. `start' specifies from which byte
* to start looking for "\r\n".
* Returns:
/* do we need more data before we expect to find "\r\n"? */
if ((more = buf->idx + start + 2 - buf->len) < 0)
more = 0;
-
- while (more > 0 ||
+
+ while (more > 0 ||
(nl = cr_findnl(buf->data + buf->idx + start, buf->len - (buf->idx + start))) == NULL) {
avail = buf->size - buf->len;
if (avail < CR_BUFFER_WATERMARK || avail < more) {
}
else if (rc == 0)
return 0; /* EOF reached, connection terminated */
- else
+ else
return -1; /* error */
/* do we need more data before we expect to find "\r\n"? */
len = (int)(nl - *line);
buf->idx = (int)((nl - buf->data) + 2); /* skip "\r\n" */
- DEBUG("size=%d, len=%d, idx=%d, start=%d, line=%s",
+ DEBUG("size=%d, len=%d, idx=%d, start=%d, line=%s",
buf->size, buf->len, buf->idx, start, *line);
return len;
}
-static int cr_receivemultibulk(REDIS rhnd, char *line)
+static int cr_receivemultibulk(REDIS rhnd, char *line)
{
int bnum, blen, i, rc=0, idx;
for (i = 0; bnum > 0 && (rc = cr_readln(rhnd, 0, &line, NULL)) > 0; i++, bnum--) {
if (*(line++) != CR_BULK)
return CREDIS_ERR_PROTOCOL;
-
+
blen = atoi(line);
if (blen == -1)
rhnd->reply.multibulk.idxs[i] = -1;
rhnd->reply.multibulk.idxs[i] = idx;
}
}
-
+
if (bnum != 0) {
DEBUG("bnum != 0, bnum=%d, rc=%d", bnum, rc);
return CREDIS_ERR_PROTOCOL;
return 0;
}
-static int cr_receivebulk(REDIS rhnd, char *line)
+static int cr_receivebulk(REDIS rhnd, char *line)
{
int blen;
return CREDIS_ERR_PROTOCOL;
}
-static int cr_receiveinline(REDIS rhnd, char *line)
+static int cr_receiveinline(REDIS rhnd, char *line)
{
rhnd->reply.line = line;
return 0;
}
-static int cr_receiveint(REDIS rhnd, char *line)
+static int cr_receiveint(REDIS rhnd, char *line)
{
rhnd->reply.integer = atoi(line);
return 0;
}
-static int cr_receiveerror(REDIS rhnd, char *line)
+static int cr_receiveerror(REDIS rhnd, char *line)
{
rhnd->reply.line = line;
return CREDIS_ERR_PROTOCOL;
}
-static int cr_receivereply(REDIS rhnd, char recvtype)
+static int cr_receivereply(REDIS rhnd, char recvtype)
{
char *line, prefix=0;
if (cr_readln(rhnd, 0, &line, NULL) > 0) {
prefix = *(line++);
-
+
if (prefix != recvtype && prefix != CR_ERROR)
return CREDIS_ERR_PROTOCOL;
return cr_receivebulk(rhnd, line);
case CR_MULTIBULK:
return cr_receivemultibulk(rhnd, line);
- }
+ }
}
return CREDIS_ERR_RECV;
}
-static void cr_delete(REDIS rhnd)
+static void cr_delete(REDIS rhnd)
{
if (rhnd->reply.multibulk.bulks != NULL)
free(rhnd->reply.multibulk.bulks);
free(rhnd);
}
-REDIS cr_new(void)
+REDIS cr_new(void)
{
REDIS rhnd;
(rhnd->reply.multibulk.bulks = malloc(sizeof(char *)*CR_MULTIBULK_SIZE)) == NULL ||
(rhnd->reply.multibulk.idxs = malloc(sizeof(int)*CR_MULTIBULK_SIZE)) == NULL) {
cr_delete(rhnd);
- return NULL;
+ return NULL;
}
rhnd->buf.size = CR_BUFFER_SIZE;
{
credis_socket_t fd = CREDIS_SOCK_INVALID;
int yes = 1;
- struct sockaddr_in sa;
+ struct sockaddr_in sa;
REDIS rhnd;
int valid = 0;
rhnd->port = port;
rhnd->fd = fd;
rhnd->timeout = timeout;
-
+
return rhnd;
error:
int credis_set(REDIS rhnd, const char *key, const char *val)
{
- return cr_sendfandreceive(rhnd, CR_INLINE, "SET %s %d\r\n%s\r\n",
+ return cr_sendfandreceive(rhnd, CR_INLINE, "SET %s %d\r\n%s\r\n",
key, strlen(val), val);
}
int credis_getset(REDIS rhnd, const char *key, const char *set_val, char **get_val)
{
- int rc = cr_sendfandreceive(rhnd, CR_BULK, "GETSET %s %d\r\n%s\r\n",
+ int rc = cr_sendfandreceive(rhnd, CR_BULK, "GETSET %s %d\r\n%s\r\n",
key, strlen(set_val), set_val);
if (rc == 0)
return rc;
}
-int credis_ping(REDIS rhnd)
+int credis_ping(REDIS rhnd)
{
return cr_sendfandreceive(rhnd, CR_INLINE, "PING\r\n");
}
return cr_sendfandreceive(rhnd, CR_INLINE, "AUTH %s\r\n", password);
}
-int cr_multikeybulkcommand(REDIS rhnd, const char *cmd, int keyc,
+int cr_multikeybulkcommand(REDIS rhnd, const char *cmd, int keyc,
const char **keyv, char ***valv)
{
cr_buffer *buf = &(rhnd->buf);
return rc;
}
-int cr_multikeystorecommand(REDIS rhnd, const char *cmd, const char *destkey,
+int cr_multikeystorecommand(REDIS rhnd, const char *cmd, const char *destkey,
int keyc, const char **keyv)
{
cr_buffer *buf = &(rhnd->buf);
int credis_setnx(REDIS rhnd, const char *key, const char *val)
{
- int rc = cr_sendfandreceive(rhnd, CR_INT, "SETNX %s %d\r\n%s\r\n",
+ int rc = cr_sendfandreceive(rhnd, CR_INT, "SETNX %s %d\r\n%s\r\n",
key, strlen(val), val);
if (rc == 0)
int rc = 0;
if (incr == 1 || decr == 1)
- rc = cr_sendfandreceive(rhnd, CR_INT, "%s %s\r\n",
+ rc = cr_sendfandreceive(rhnd, CR_INT, "%s %s\r\n",
incr>0?"INCR":"DECR", key);
else if (incr > 1 || decr > 1)
- rc = cr_sendfandreceive(rhnd, CR_INT, "%s %s %d\r\n",
+ rc = cr_sendfandreceive(rhnd, CR_INT, "%s %s %d\r\n",
incr>0?"INCRBY":"DECRBY", key, incr>0?incr:decr);
if (rc == 0 && new_val != NULL)
{
int rc = cr_sendfandreceive(rhnd, CR_INLINE, "RANDOMKEY\r\n");
- if (rc == 0)
+ if (rc == 0)
*key = rhnd->reply.line;
return rc;
int credis_rename(REDIS rhnd, const char *key, const char *new_key_name)
{
- return cr_sendfandreceive(rhnd, CR_INLINE, "RENAME %s %s\r\n",
+ return cr_sendfandreceive(rhnd, CR_INLINE, "RENAME %s %s\r\n",
key, new_key_name);
}
int credis_renamenx(REDIS rhnd, const char *key, const char *new_key_name)
{
- int rc = cr_sendfandreceive(rhnd, CR_INT, "RENAMENX %s %s\r\n",
+ int rc = cr_sendfandreceive(rhnd, CR_INT, "RENAMENX %s %s\r\n",
key, new_key_name);
if (rc == 0)
{
int rc = cr_sendfandreceive(rhnd, CR_INT, "DBSIZE\r\n");
- if (rc == 0)
+ if (rc == 0)
rc = rhnd->reply.integer;
return rc;
}
int credis_expire(REDIS rhnd, const char *key, int secs)
-{
+{
int rc = cr_sendfandreceive(rhnd, CR_INT, "EXPIRE %s %d\r\n", key, secs);
if (rc == 0)
int cr_push(REDIS rhnd, int left, const char *key, const char *val)
{
- return cr_sendfandreceive(rhnd, CR_INLINE, "%s %s %d\r\n%s\r\n",
+ return cr_sendfandreceive(rhnd, CR_INLINE, "%s %s %d\r\n%s\r\n",
left==1?"LPUSH":"RPUSH", key, strlen(val), val);
}
{
int rc = cr_sendfandreceive(rhnd, CR_INT, "LLEN %s\r\n", key);
- if (rc == 0)
+ if (rc == 0)
rc = rhnd->reply.integer;
return rc;
{
int rc;
- if ((rc = cr_sendfandreceive(rhnd, CR_MULTIBULK, "LRANGE %s %d %d\r\n",
+ if ((rc = cr_sendfandreceive(rhnd, CR_MULTIBULK, "LRANGE %s %d %d\r\n",
key, start, end)) == 0) {
*valv = rhnd->reply.multibulk.bulks;
rc = rhnd->reply.multibulk.len;
int credis_ltrim(REDIS rhnd, const char *key, int start, int end)
{
- return cr_sendfandreceive(rhnd, CR_INLINE, "LTRIM %s %d %d\r\n",
+ return cr_sendfandreceive(rhnd, CR_INLINE, "LTRIM %s %d %d\r\n",
key, start, end);
}
static int cr_pop(REDIS rhnd, int left, const char *key, char **val)
{
- int rc = cr_sendfandreceive(rhnd, CR_BULK, "%s %s\r\n",
+ int rc = cr_sendfandreceive(rhnd, CR_BULK, "%s %s\r\n",
left==1?"LPOP":"RPOP", key);
if (rc == 0)
&(info->total_connections_received),
&(info->total_commands_processed),
role);
-
+
if (items != CR_NUMBER_OF_ITEMS)
return CREDIS_ERR_PROTOCOL; /* not enough input items returned */
-
+
info->role = ((role[0]=='m')?CREDIS_SERVER_MASTER:CREDIS_SERVER_SLAVE);
}
-
+
return rc;
}
static int cr_setaddrem(REDIS rhnd, const char *cmd, const char *key, const char *member)
{
- int rc = cr_sendfandreceive(rhnd, CR_INT, "%s %s %d\r\n%s\r\n",
+ int rc = cr_sendfandreceive(rhnd, CR_INT, "%s %s %d\r\n%s\r\n",
cmd, key, strlen(member), member);
if (rc == 0)
return rc;
}
-int credis_smove(REDIS rhnd, const char *sourcekey, const char *destkey,
+int credis_smove(REDIS rhnd, const char *sourcekey, const char *destkey,
const char *member)
{
- int rc = cr_sendfandreceive(rhnd, CR_INT, "SMOVE %s %s %s\r\n",
+ int rc = cr_sendfandreceive(rhnd, CR_INT, "SMOVE %s %s %s\r\n",
sourcekey, destkey, member);
if (rc == 0)
return rc;
}
-int credis_scard(REDIS rhnd, const char *key)
+int credis_scard(REDIS rhnd, const char *key)
{
int rc = cr_sendfandreceive(rhnd, CR_INT, "SCARD %s\r\n", key);
extern "C" {
#endif
-/* Functions below should map quite nicely to Redis 1.02 command set.
- * Refer to the official Redis documentation for further explanation of
+/* Functions below should map quite nicely to Redis 1.02 command set.
+ * Refer to the official Redis documentation for further explanation of
* each command. See credis examples that show how functions can be used.
- * Here is a brief example that connects to a Redis server and sets value
- * of key `fruit' to `banana':
+ * Here is a brief example that connects to a Redis server and sets value
+ * of key `fruit' to `banana':
*
* REDIS rh = credis_connect("localhost", 6789, 2000);
* credis_set(rh, "fruit", "banana");
* credis_close(rh);
*
* In general, functions return 0 on success or a negative value on
- * error. Refer to CREDIS_ERR_* codes. The return code -1 is typically
- * used when for instance a key is not found.
+ * error. Refer to CREDIS_ERR_* codes. The return code -1 is typically
+ * used when for instance a key is not found.
*
- * IMPORTANT! Memory buffers are allocated, used and managed by credis
- * internally. Subsequent calls to credis functions _will_ destroy the
- * data to which returned values reference to. If for instance the
- * returned value by a call to credis_get() is to be used later in the
- * program, a strdup() is highly recommended. However, each `REDIS'
- * handle has its own state and manages its own memory buffer
+ * IMPORTANT! Memory buffers are allocated, used and managed by credis
+ * internally. Subsequent calls to credis functions _will_ destroy the
+ * data to which returned values reference to. If for instance the
+ * returned value by a call to credis_get() is to be used later in the
+ * program, a strdup() is highly recommended. However, each `REDIS'
+ * handle has its own state and manages its own memory buffer
* independently. That means that one of two handles can be destroyed
* while the other keeps its connection and data.
- *
+ *
* TODO
- * - Currently only support for zero-terminated strings, not for storing
+ * - Currently only support for zero-terminated strings, not for storing
* abritary binary data as bulk data. Basically an API issue since it
* is partially supported internally.
* - Support for Redis >= 1.1 protocol
* Connection handling
*/
-/* setting host to NULL will use "localhost". setting port to 0 will use
+/* setting host to NULL will use "localhost". setting port to 0 will use
* default port 6379 */
REDIS credis_connect(const char *host, int port, int timeout);
int credis_ping(REDIS rhnd);
-/*
- * Commands operating on string values
+/*
+ * Commands operating on string values
*/
int credis_set(REDIS rhnd, const char *key, const char *val);
/* returns type, refer to CREDIS_TYPE_* defines */
int credis_type(REDIS rhnd, const char *key);
-/* TODO for Redis >= 1.1
+/* TODO for Redis >= 1.1
* MSET key1 value1 key2 value2 ... keyN valueN set a multiple keys to multiple values in a single atomic operation
* MSETNX key1 value1 key2 value2 ... keyN valueN set a multiple keys to multiple values in a single atomic operation if none of
- * DEL key1 key2 ... keyN remove multiple keys
+ * DEL key1 key2 ... keyN remove multiple keys
*/
/*
- * Commands operating on key space
+ * Commands operating on key space
*/
int credis_keys(REDIS rhnd, const char *pattern, char **keyv, int len);
/* returns size of db */
int credis_dbsize(REDIS rhnd);
-/* returns -1 if the timeout was not set; either due to key already has
+/* returns -1 if the timeout was not set; either due to key already has
an associated timeout or key does not exist */
int credis_expire(REDIS rhnd, const char *key, int secs);
-/* returns time to live seconds or -1 if key does not exists or does not
+/* returns time to live seconds or -1 if key does not exists or does not
* have expire set */
int credis_ttl(REDIS rhnd, const char *key);
/*
- * Commands operating on lists
+ * Commands operating on lists
*/
int credis_rpush(REDIS rhnd, const char *key, const char *element);
/* returns -1 if the key doesn't exists */
int credis_rpop(REDIS rhnd, const char *key, char **val);
-/* TODO for Redis >= 1.1
- * RPOPLPUSH srckey dstkey
+/* TODO for Redis >= 1.1
+ * RPOPLPUSH srckey dstkey
*
* TODO for Redis >= 1.3.1
* BLPOP key1 key2 ... keyN timeout
*/
/*
- * Commands operating on sets
+ * Commands operating on sets
*/
/* returns -1 if the given member was already a member of the set */
int credis_spop(REDIS rhnd, const char *key, char **member);
/* returns -1 if the member doesn't exists in the source set */
-int credis_smove(REDIS rhnd, const char *sourcekey, const char *destkey,
+int credis_smove(REDIS rhnd, const char *sourcekey, const char *destkey,
const char *member);
/* returns cardinality (number of members) or 0 if the given key doesn't exists */
*/
/*
- * Multiple databases handling commands
+ * Multiple databases handling commands
*/
int credis_select(REDIS rhnd, int index);
-/* returns -1 if the key was not moved; already present at target
+/* returns -1 if the key was not moved; already present at target
* or not found on current db */
int credis_move(REDIS rhnd, const char *key, int index);
int credis_flushall(REDIS rhnd);
/*
- * Sorting
+ * Sorting
*/
/* returns number of elements returned in vector `elementv' */
int credis_sort(REDIS rhnd, const char *query, char ***elementv);
-/*
- * Persistence control commands
+/*
+ * Persistence control commands
*/
int credis_save(REDIS rhnd);
int credis_shutdown(REDIS rhnd);
/*
- * Remote server control commands
+ * Remote server control commands
*/
int credis_info(REDIS rhnd, REDIS_INFO *info);
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- * Kevin Morizur <kmorizur@avgs.ca>
+ * Kevin Morizur <kmorizur@avgs.ca>
* Mathieu Rene <mrene@avgs.ca>
*
* mod_redis.c -- Redis limit backend
static switch_xml_config_item_t instructions[] = {
/* parameter name type reloadable pointer default value options structure */
- SWITCH_CONFIG_ITEM_STRING_STRDUP("host", CONFIG_RELOAD, &globals.host, NULL, "localhost", "Hostname for redis server"),
+ SWITCH_CONFIG_ITEM_STRING_STRDUP("host", CONFIG_RELOAD, &globals.host, NULL, "localhost", "Hostname for redis server"),
SWITCH_CONFIG_ITEM("port", SWITCH_CONFIG_INT, CONFIG_RELOADABLE, &globals.port, (void *) 6379, NULL,NULL, NULL),
SWITCH_CONFIG_ITEM("timeout", SWITCH_CONFIG_INT, CONFIG_RELOADABLE, &globals.timeout, (void *) 10000, NULL,NULL, NULL),
SWITCH_CONFIG_ITEM("ignore_connect_fail", SWITCH_CONFIG_BOOL, CONFIG_RELOADABLE, &globals.ignore_connect_fail, SWITCH_FALSE, NULL, "true|false", "Set to true in order to continue when redis is not contactable"),
switch_mutex_t *mutex;
} limit_redis_private_t;
-static switch_status_t redis_factory(REDIS *redis)
+static switch_status_t redis_factory(REDIS *redis)
{
if (!((*redis) = credis_connect(globals.host, globals.port, globals.timeout))) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't connect to redis server at %s:%d timeout:%d\n", globals.host, globals.port, globals.timeout);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't connect to redis server at %s:%d timeout:%d\n", globals.host, globals.port, globals.timeout);
return SWITCH_STATUS_FALSE;
}
return SWITCH_STATUS_SUCCESS;
char *rediskey = NULL;
char *uuid_rediskey = NULL;
uint8_t increment = 1;
- switch_status_t status = SWITCH_STATUS_SUCCESS;
+ switch_status_t status = SWITCH_STATUS_SUCCESS;
REDIS redis;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "mod_redis is deprecated and will be removed in FS 1.8. Check out mod_hiredis.\n");
switch_mutex_init(&pvt->mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
switch_channel_set_private(channel, "limit_redis", pvt);
}
-
+
if (!(switch_core_hash_find_locked(pvt->hash, rediskey, pvt->mutex))) {
switch_core_hash_insert_locked(pvt->hash, rediskey, rediskey, pvt->mutex);
}
-
+
if (increment) {
if (credis_incr(redis, rediskey, &val) != 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't increment value corresponding to %s\n", rediskey);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Couldn't decrement value corresponding to %s\n", rediskey);
switch_goto_status(SWITCH_STATUS_GENERR, end);
} else {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Usage for %s exceeds maximum rate of %d\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Usage for %s exceeds maximum rate of %d\n",
rediskey, max);
switch_goto_status(SWITCH_STATUS_FALSE, end);
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Couldn't increment value corresponding to %s\n", uuid_rediskey);
switch_goto_status(SWITCH_STATUS_FALSE, end);
}
- }
+ }
} else {
if (credis_incr(redis, uuid_rediskey, &uuid_val) != 0) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Couldn't increment value corresponding to %s\n", uuid_rediskey);
}
return status;
}
-
+
/* !\brief Releases usage of a limit_redis-controlled ressource */
SWITCH_LIMIT_RELEASE(limit_release_redis)
{
char *uuid_rediskey = NULL;
int status = SWITCH_STATUS_SUCCESS;
REDIS redis;
-
+
if (!pvt || !pvt->hash) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No hashtable for channel %s\n", switch_channel_get_name(channel));
return SWITCH_STATUS_SUCCESS;
}
-
+
if (redis_factory(&redis) != SWITCH_STATUS_SUCCESS) {
if ( globals.ignore_connect_fail ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ignore_connect_fail=true, so ignoring the fact that redis was not contactabl and continuing with the call\n" );
const void *p_key;
char *p_uuid_key = NULL;
switch_ssize_t keylen;
-
+
switch_core_hash_this(hi, &p_key, &keylen, &p_val);
-
+
if (credis_decr(redis, (const char*)p_key, &val) != 0) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Couldn't decrement value corresponding to %s\n", (char *)p_key);
switch_goto_status(SWITCH_STATUS_FALSE, end);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG10, "Limit incr redis : uuid_rediskey : %s uuid_val : %d\n",
p_uuid_key, uuid_val);*/
}
-
- } else {
+
+ } else {
rediskey = switch_core_session_sprintf(session, "%s_%s", realm, resource);
uuid_rediskey = switch_core_session_sprintf(session, "%s_%s_%s", switch_core_get_switchname(), realm, resource);
switch_core_hash_delete(pvt->hash, (const char *) rediskey);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Couldn't decrement value corresponding to %s\n", uuid_rediskey);
switch_goto_status(SWITCH_STATUS_FALSE, end);
}
-
+
/*
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Limit release redis : rediskey : %s val : %d\n", rediskey,val);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Limit incr redis : uuid_rediskey : %s uuid_val : %d\n", uuid_rediskey,uuid_val);
char *str;
REDIS redis;
int usage;
-
+
if (redis_factory(&redis) != SWITCH_STATUS_SUCCESS) {
return 0;
}
redis_key = switch_mprintf("%s_%s", realm, resource);
-
+
if (credis_get(redis, redis_key, &str) != 0){
usage = 0;
} else {
- usage = atoi(str);
+ usage = atoi(str);
}
-
+
if (redis) {
credis_close(redis);
}
-
+
switch_safe_free(redis_key);
return usage;
}
char *rediskey = switch_mprintf("%s_*", switch_core_get_switchname());
int dec = 0, val = 0, keyc;
char *uuids[2000];
-
+
if ((keyc = credis_keys(redis, rediskey, uuids, switch_arraylen(uuids))) > 0) {
int i = 0;
int hostnamelen = (int)strlen(switch_core_get_switchname())+1;
-
+
for (i = 0; i < keyc && uuids[i]; i++){
const char *key = uuids[i] + hostnamelen;
char *value;
-
+
if ((int)strlen(uuids[i]) <= hostnamelen) {
continue; /* Sanity check */
}
-
+
credis_get(redis, key, &value);
dec = atoi(value);
credis_decrby(redis, key, dec, &val);
-
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "DECR %s by %d. value is now %d\n", key, dec, val);
}
}
switch_limit_interface_t *limit_interface = NULL;
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
-
+
if (switch_xml_config_parse_module_settings("redis.conf", SWITCH_FALSE, instructions) != SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_FALSE;
}
/* If FreeSWITCH was restarted and we still have active calls, decrement them so our global count stays valid */
limit_reset_redis();
-
+
SWITCH_ADD_LIMIT(limit_interface, "redis", limit_incr_redis, limit_release_redis, limit_usage_redis, limit_reset_redis, limit_status_redis, NULL);
-
+
return SWITCH_STATUS_SUCCESS;
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Bret McDanel <trixter AT 0xdecafbad.com>
*
/*
- dtmf handler function you can hook up to be executed when a digit is dialed during 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)
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
+ /* 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) {
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Neal Horman <neal at wanlink dot com>
*
SWITCH_MODULE_RUNTIME_FUNCTION(mod_skel_runtime);
SWITCH_MODULE_LOAD_FUNCTION(mod_skel_load);
-/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
+/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
* Defines a switch_loadable_module_function_table_t and a static const char[] modname
*/
SWITCH_MODULE_DEFINITION(mod_skel, mod_skel_load, mod_skel_shutdown, NULL);
/*
if ((callback_type == CONFIG_LOG || callback_type == CONFIG_RELOAD) && changed) {
nua_set_params(((sofia_profile_t*)data->functiondata)->nua, TPTAG_LOG(value), TAG_END());
- }
+ }
*/
return SWITCH_STATUS_SUCCESS;
switch_snprintf(name, sizeof(name), "test-header-%d", x);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, name, "value-%d", x);
}
-
+
/* Nothing up my sleeve, here is the event */
{
switch_channel_t *channel = switch_core_session_get_channel(session);
- switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_CRIT,
- "%s device: %s\nState: %s Dev State: %s/%s Total:%u Offhook:%u Active:%u Held:%u Hungup:%u Dur: %u %s\n",
+ switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_CRIT,
+ "%s device: %s\nState: %s Dev State: %s/%s Total:%u Offhook:%u Active:%u Held:%u Hungup:%u Dur: %u %s\n",
switch_channel_get_name(channel),
drec->device_id,
switch_channel_callstate2str(callstate),
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Raymond Chandler <intralanman@freeswitch.org>
*
- * mod_sms.c -- Abstract SMS
+ * mod_sms.c -- Abstract SMS
*
*/
#include <switch.h>
}
}
-static void event_handler(switch_event_t *event)
+static void event_handler(switch_event_t *event)
{
const char *dest_proto = switch_event_get_header(event, "dest_proto");
const char *check_failure = switch_event_get_header(event, "Delivery-Failure");
} else { \
tzoff = NULL; \
} \
- } while(tzoff)
+ } while(tzoff)
static int parse_exten(switch_event_t *event, switch_xml_t xexten, switch_event_t **extension)
{
}
xexten = switch_xml_child(xcontext, "extension");
-
+
while (xexten) {
int proceed = 0;
const char *cont = switch_xml_attr(xexten, "continue");
to, context, exten_name, cont ? cont : "false");
proceed = parse_exten(event, xexten, &extension);
-
+
if (proceed && !switch_true(cont)) {
break;
}
forwards = 70;
} else {
forwards = atoi(var);
-
+
if (forwards) {
forwards--;
}
if ((exten = chatplan_hunt(message_event))) {
switch_event_header_t *hp;
-
+
for (hp = exten->headers; hp; hp = hp->next) {
status = switch_core_execute_chat_app(message_event, hp->name, hp->value);
if (!SWITCH_READ_ACCEPTABLE(status)) {
- status = SWITCH_STATUS_SUCCESS;
+ status = SWITCH_STATUS_SUCCESS;
break;
}
}
if ((val = strchr(var, '='))) {
*val++ = '\0';
}
-
+
if (zstr(val)) {
switch_event_del_header(message, var);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
return SWITCH_STATUS_GENERR;
}
-
+
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
SWITCH_ADD_CHAT_APP(chat_app_interface, "send", "send the message as-is", "send the message as-is", send_function, "", SCAF_NONE);
SWITCH_ADD_CHAT_APP(chat_app_interface, "fire", "fire the message", "fire the message", fire_function, "", SCAF_NONE);
SWITCH_ADD_CHAT_APP(chat_app_interface, "system", "execute a system command", "execute a sytem command", system_function, "", SCAF_NONE);
-
+
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}
switch_event_unbind_callback(event_handler);
switch_event_free_subclass(MY_EVENT_DELIVERY_REPORT);
-
+
return SWITCH_STATUS_SUCCESS;
}
fprintf(stderr, "Unable to listen on socket [%d]\n", err);
return 0;
}
-
+
sock = h2o_evloop_socket_create(profile->h2o_context.loop, fd, H2O_SOCKET_FLAG_DONT_READ);
sock->data = (void *) profile;
h2o_socket_read_start(sock, on_accept);
-
+
while ( profile->running ) {
// switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Profile[%s] event thread loop\n", profile->name);
h2o_timeout_init(profile->h2o_context.loop, &timeout, 1000); /* 1 second loop */
h2o_socket_close(sock);
return 0;
}
-
+
switch_status_t mod_sms_flowroute_profile_destroy(mod_sms_flowroute_profile_t **old_profile)
{
mod_sms_flowroute_profile_t *profile = NULL;
if ( !old_profile || !*old_profile ) {
return SWITCH_STATUS_SUCCESS;
}
-
+
profile = *old_profile;
-
+
switch_core_hash_delete(mod_sms_flowroute_globals.profile_hash, profile->name);
profile->running = 0;
switch_safe_free(profile->h2o_context.loop);
h2o_context_dispose(&(profile->h2o_context));
h2o_config_dispose(&(profile->h2o_globalconf));
-
+
switch_core_destroy_memory_pool(&(profile->pool));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Profile[%s] destroyed\n", profile->name);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Invalid request received[%.*s]", (int) request->entity.len, request->entity.base);
goto done;
}
-
+
switch_event_create(&evt, SWITCH_EVENT_MESSAGE);
- switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM, "to", cJSON_GetObjectCstr(parsed, "to"));
- switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM, "body", cJSON_GetObjectCstr(parsed, "body"));
- switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM, "from", cJSON_GetObjectCstr(parsed, "from"));
- switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM, "record_id", cJSON_GetObjectCstr(parsed, "id"));
- switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM, "context", "default");
- switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM, "proto", "sms_flowroute");
+ switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM, "to", cJSON_GetObjectCstr(parsed, "to"));
+ switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM, "body", cJSON_GetObjectCstr(parsed, "body"));
+ switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM, "from", cJSON_GetObjectCstr(parsed, "from"));
+ switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM, "record_id", cJSON_GetObjectCstr(parsed, "id"));
+ switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM, "context", "default");
+ switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM, "proto", "sms_flowroute");
switch_core_chat_send("GLOBAL_SMS", evt);
switch_event_destroy(&evt);
h2o_send(request, &body, 1, 1);
done:
-
+
cJSON_Delete(parsed);
switch_safe_free(content);
return 0;
char *access_key, char *secret_key, char *host)
{
mod_sms_flowroute_profile_t *profile = NULL;
- switch_memory_pool_t *pool = NULL;
+ switch_memory_pool_t *pool = NULL;
switch_threadattr_t *thd_attr;
char auth[256] = {0};
unsigned int auth_size = 0;
-
+
switch_core_new_memory_pool(&pool);
profile = switch_core_alloc(pool, sizeof(mod_sms_flowroute_profile_t));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Profile[%s] error processing url[%s]\n", profile->name, profile->host);
goto err;
}
-
+
h2o_config_init(&(profile->h2o_globalconf));
profile->h2o_hostconf = h2o_config_register_host(&(profile->h2o_globalconf), h2o_iovec_init(H2O_STRLIT("mod_sms_flowroute")), 2048);
profile->h2o_pathconf = h2o_config_register_path(profile->h2o_hostconf, "/", 0);
profile->h2o_handler = h2o_create_handler(profile->h2o_pathconf, sizeof(h2o_handler_t));
profile->h2o_handler->on_req = mod_sms_flowroute_profile_request_handler;
-
+
h2o_context_init(&(profile->h2o_context), h2o_evloop_create(), &(profile->h2o_globalconf));
profile->queue = h2o_multithread_create_queue(profile->h2o_context.loop);
switch_threadattr_create(&thd_attr, pool);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
switch_thread_create(&(profile->profile_thread), thd_attr, mod_sms_flowroute_profile_event_thread, (void *) profile, pool);
-
+
switch_core_hash_insert(mod_sms_flowroute_globals.profile_hash, name, (void *) profile);
*new_profile = profile;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Profile[%s] created\n", profile->name);
if ( !to ) {
to = switch_event_get_header(event, "destination_addr");
}
-
+
from = switch_event_get_header(event, "from");
if ( !from ) {
from = switch_event_get_header(event, "source_addr");
}
-
+
cJSON_AddItemToObject(body, "to", cJSON_CreateString(to));
cJSON_AddItemToObject(body, "from", cJSON_CreateString(from));
cJSON_AddItemToObject(body, "body", cJSON_CreateString((const char *) switch_event_get_body(event)));
profile->auth_b64_size, profile->auth_b64,
(int) profile->url_parsed.authority.len, profile->url_parsed.authority.base,
(int)strlen(text), text);
-
+
if ( profile->debug ) {
char *msg_txt = NULL;
switch_event_serialize(event, &msg_txt, SWITCH_FALSE);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Profile[%s] send_message resulted in failure status %d\n", profile->name, msg->status);
goto err;
}
-
+
h2o_timeout_dispose(msg->ctx.loop, msg->ctx.io_timeout);
switch_mutex_destroy(msg->mutex);
switch_safe_free(msg->req.base);
err:
if ( msg && msg->mutex ) {
switch_mutex_destroy(msg->mutex);
- }
+ }
h2o_timeout_dispose(msg->ctx.loop, msg->ctx.io_timeout);
switch_safe_free(msg->req.base);
- switch_safe_free(msg);
+ switch_safe_free(msg);
return SWITCH_STATUS_GENERR;
}
if (zstr(profile_name)) {
profile_name = "default";
}
-
+
profile = switch_core_hash_find(mod_sms_flowroute_globals.profile_hash, profile_name);
if (!profile) {
if (switch_event_create(&message, SWITCH_EVENT_MESSAGE) != SWITCH_STATUS_SUCCESS) {
return;
}
-
+
/* Copy over recognized channel vars. Then call the chat send function */
/* Cycle through all of the channel headers, and ones with 'sms_flowroute_' prefix copy over without the prefix */
for ( chan_var = switch_channel_variable_first(channel); chan_var; chan_var = chan_var->next) {
switch_event_add_header_string(message, SWITCH_STACK_BOTTOM, chan_var->name + 14, chan_var->value);
}
}
-
+
/* Unlock the channel variables */
switch_channel_variable_last(channel);
mod_sms_flowroute_chat_send_function(message, data);
if (switch_event_create(&message, SWITCH_EVENT_MESSAGE) != SWITCH_STATUS_SUCCESS) {
switch_goto_status(SWITCH_STATUS_GENERR, done);
}
-
+
switch_event_add_header_string(message, SWITCH_STACK_BOTTOM, "destination_addr", argv[1]);
switch_event_add_header_string(message, SWITCH_STACK_BOTTOM, "source_addr", argv[2]);
switch_event_set_body(message, argv[3]);
done:
switch_safe_free(cmd_dup);
return status;
-
+
}
-switch_status_t mod_sms_flowroute_do_config()
+switch_status_t mod_sms_flowroute_do_config()
{
char *conf = "sms_flowroute.conf";
switch_xml_t xml, cfg, profiles, profile, params, param;
}
if ( (profiles = switch_xml_child(cfg, "profiles")) != NULL) {
- for (profile = switch_xml_child(profiles, "profile"); profile; profile = profile->next) {
+ for (profile = switch_xml_child(profiles, "profile"); profile; profile = profile->next) {
mod_sms_flowroute_profile_t *new_profile = NULL;
int debug = 0, port = 0;
char *access_key = NULL, *secret_key = NULL, *host = NULL;
switch_xml_free(xml);
return SWITCH_STATUS_SUCCESS;
-
+
err:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Configuration failed\n");
if(xml){
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
-
+
memset(&mod_sms_flowroute_globals, 0, sizeof(mod_sms_flowroute_globals_t));
mod_sms_flowroute_globals.pool = pool;
mod_sms_flowroute_globals.debug = 0;
switch_core_hash_init(&(mod_sms_flowroute_globals.profile_hash));
-
+
if ( mod_sms_flowroute_do_config() != SWITCH_STATUS_SUCCESS ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to load due to bad configs\n");
return SWITCH_STATUS_TERM;
/* SSL_load_error_strings();
SSL_library_init();
OpenSSL_add_all_algorithms();*/
-
+
SWITCH_ADD_CHAT(mod_sms_flowroute_chat_interface, "sms_flowroute", mod_sms_flowroute_interface_chat_send);
SWITCH_ADD_API(mod_sms_flowroute_api_interface, "sms_flowroute_send", "mod_sms_flowroute send", mod_sms_flowroute_send_api, NULL);
SWITCH_ADD_API(mod_sms_flowroute_api_interface, "sms_flowroute_debug", "mod_sms_flowroute toggle debug", mod_sms_flowroute_debug_api, NULL);
- SWITCH_ADD_CHAT_APP(mod_sms_flowroute_chat_app_interface, "sms_flowroute_send", "send message to profile", "send message to profile",
+ SWITCH_ADD_CHAT_APP(mod_sms_flowroute_chat_app_interface, "sms_flowroute_send", "send message to profile", "send message to profile",
mod_sms_flowroute_chat_send_function, "", SCAF_NONE);
- SWITCH_ADD_APP(mod_sms_flowroute_app_interface, "sms_flowroute_send", NULL, NULL, mod_sms_flowroute_app_send_function,
+ SWITCH_ADD_APP(mod_sms_flowroute_app_interface, "sms_flowroute_send", NULL, NULL, mod_sms_flowroute_app_send_function,
"sms_flowroute_send", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
/* indicate that the module should continue to be loaded */
unsigned char auth_b64[512];
int auth_b64_size;
-
+
h2o_url_t url_parsed;
h2o_socketpool_t *sockpool;
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
SWITCH_MODULE_RUNTIME_FUNCTION(mod_snapshot_runtime);
SWITCH_MODULE_LOAD_FUNCTION(mod_snapshot_load);
-/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
+/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
* Defines a switch_loadable_module_function_table_t and a static const char[] modname
*/
SWITCH_MODULE_DEFINITION(mod_snapshot, mod_snapshot_load, NULL, NULL);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "%s Bug is not attached.\n", switch_channel_get_name(channel));
return SWITCH_STATUS_FALSE;
-
+
}
#define SNAP_SYNTAX "start <sec> <read|write>"
-<include>
+<include>
<extension name="snom-demo-1">
<condition field="destination_number" expression="^9000$">
<!-- <key> <light> <label> <user> <host> <profile> <action_name> <action> -->
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
* mod_snom.c -- SNOM Specific Features
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* William King <william.king@quentustech.com>
* Seven Du <dujinfang@gmail.com>
*
* mod_sonar.c -- Sonar ping timer
*
- *
+ *
*/
/*
SWITCH_MODULE_RUNTIME_FUNCTION(mod_sonar_runtime);
SWITCH_MODULE_LOAD_FUNCTION(mod_sonar_load);
-/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
+/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
* Defines a switch_loadable_module_function_table_t and a static const char[] modname
*/
SWITCH_MODULE_DEFINITION(mod_sonar, mod_sonar_load, mod_sonar_shutdown, NULL);
ph->max = MAX(ph->max, diff);
ph->min = MIN(ph->min, diff);
ph->samples[ph->received++] = diff;
-
+
return SWITCH_TRUE;
}
} else if (loops > 1024) {
loops = 1024;
}
-
+
switch_channel_answer(channel);
switch_ivr_sleep(session, 1000, SWITCH_FALSE, NULL);
switch_channel_set_private(channel, "__sonar_ping__", &ph);
- switch_ivr_tone_detect_session(session,
+ switch_ivr_tone_detect_session(session,
"soar_ping", "1004",
- "r", 0,
+ "r", 0,
1, NULL, NULL, sonar_ping_callback);
-
+
switch_ivr_sleep(session, 1000, SWITCH_FALSE, NULL);
ph.min = 999999;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Lost sonar ping\n");
}
}
-
+
switch_ivr_sleep(session, 1000, SWITCH_FALSE, NULL);
switch_ivr_stop_tone_detect_session(session);
return SWITCH_STATUS_TERM;
}
-
+
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
{
switch_event_free_subclass("sonar::ping");
-
+
return SWITCH_STATUS_SUCCESS;
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
* mod_soundtouch.cpp -- Example of writeable media bugs
n++;
} else if (strchr(argv[x], 's')) {
/*12.0f taken from soundtouch conversion to octaves*/
- sth->pitch = normalize_soundtouch_value('p', compute_pitch_from_octaves(atof(argv[x]) / 12.0f) );
+ sth->pitch = normalize_soundtouch_value('p', compute_pitch_from_octaves(atof(argv[x]) / 12.0f) );
n++;
} else if (strchr(argv[x], 't')) {
sth->tempo = normalize_soundtouch_value('t', atof(argv[x]));
n++;
} else if (strchr(argv[x], 's')) {
/*12.0f taken from soundtouch conversion to octaves*/
- sth->pitch = normalize_soundtouch_value('p', compute_pitch_from_octaves(atof(argv[x]) / 12.0f) );
+ sth->pitch = normalize_soundtouch_value('p', compute_pitch_from_octaves(atof(argv[x]) / 12.0f) );
n++;
} else if (strchr(argv[x], 't')) {
sth->tempo = normalize_soundtouch_value('t', atof(argv[x]));
switch_api_interface_t *api_interface;
/* connect my internal structure to the blank pointer passed to me */
- *module_interface = switch_loadable_module_create_module_interface(pool, modname);
+ *module_interface = switch_loadable_module_create_module_interface(pool, modname);
- SWITCH_ADD_APP(app_interface, "soundtouch", "Alter the audio stream", "Alter the audio stream pitch/rate/tempo",
+ SWITCH_ADD_APP(app_interface, "soundtouch", "Alter the audio stream", "Alter the audio stream pitch/rate/tempo",
soundtouch_start_function, "[send_leg] [hook_dtmf] [-]<X>s [-]<X>o <X>p <X>r <X>t", SAF_NONE);
SWITCH_ADD_API(api_interface, "soundtouch", "soundtouch", soundtouch_api_function, SOUNDTOUCH_API_SYNTAX);
<configuration name="spandsp.conf" description="SpanDSP config">
<modem-settings>
<!--
- total-modems set to N will create that many soft-modems.
+ total-modems set to N will create that many soft-modems.
If you use them with Hylafax you need the following for each one numbered 0..N:
1) A line like this in /etc/inittab:
}
switch_channel_set_app_flag_key("T38", channel, CF_APP_T38_POSSIBLE);
-
+
if (zstr(direction) || strcasecmp(direction, "self")) {
direction = "peer";
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", SPANDSP_EVENT_RXFAXRESULT);
return SWITCH_STATUS_TERM;
}
-
+
memset(&spandsp_globals, 0, sizeof(spandsp_globals));
spandsp_globals.pool = pool;
switch_event_free_subclass(SPANDSP_EVENT_RXFAXPAGERESULT);
switch_event_free_subclass(SPANDSP_EVENT_TXFAXRESULT);
switch_event_free_subclass(SPANDSP_EVENT_RXFAXRESULT);
-
+
mod_spandsp_fax_shutdown();
mod_spandsp_dsp_shutdown();
#if defined(MODEM_SUPPORT)
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
switch_core_session_t *session = switch_core_media_bug_get_session(bug);
switch_codec_implementation_t read_impl = { 0 };
-
+
switch (type) {
case SWITCH_ABC_TYPE_INIT: {
pvt->dtmf_detect = dtmf_rx_init(NULL, NULL, NULL);
int samples = frame->samples;
switch_core_session_get_read_impl(session, &read_impl);
-
+
if (read_impl.number_of_channels != 1 || read_impl.actual_samples_per_second != 8000) {
memcpy(data, frame->data, frame->datalen);
dp = data;
read_impl.actual_samples_per_second,
8000,
8 * (read_impl.microseconds_per_packet / 1000) * 2,
- SWITCH_RESAMPLE_QUALITY,
+ SWITCH_RESAMPLE_QUALITY,
1) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to allocate resampler\n");
return SWITCH_FALSE;
}
}
-
+
switch_resample_process(pvt->resampler, dp, (int) datalen / 2 / 1);
memcpy(dp, pvt->resampler->to, pvt->resampler->to_len * 2 * 1);
switch_channel_var_true(channel, "fax_enable_t38_insist")) {
switch_channel_set_app_flag_key("T38", channel, CF_APP_T38_POSSIBLE);
}
-
+
pvt = pvt_init(session, app_mode);
switch_channel_set_private(channel, "_fax_pvt", pvt);
spanfax_destroy(pvt);
switch_channel_clear_app_flag_key("T38", channel, CF_APP_T38_POSSIBLE);
-
+
/* restore the original codecs over the channel */
switch_core_session_set_read_codec(session, NULL);
switch_channel_set_app_flag_key("T38", channel, CF_APP_T38_POSSIBLE);
switch_channel_set_app_flag_key("T38", other_channel, CF_APP_T38_POSSIBLE);
-
+
switch_channel_set_flag(channel, CF_REDIRECT);
switch_channel_set_state(channel, CS_RESET);
switch_codec_implementation_t read_impl = { 0 };
switch_core_session_get_read_impl(session, &read_impl);
-
+
if (timeout) {
to = switch_epoch_time_now(NULL) + timeout;
}
}
switch_channel_set_app_flag_key("T38", channel, CF_APP_T38_POSSIBLE);
-
+
if (app) {
cont->app = switch_core_session_strdup(session, app);
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* Brian West <brian@freeswitch.org>
* Anthony Minessale II <anthm@freeswitch.org>
* Steve Underwood <steveu@coppice.org>
- * mod_spandsp_modem.c -- t31 Soft Modem
+ * mod_spandsp_modem.c -- t31 Soft Modem
*
*/
#endif
if (wrote != len) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to pass the full buffer onto the device file. "
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to pass the full buffer onto the device file. "
"%"SWITCH_SSIZE_T_FMT " bytes of " "%"SWITCH_SIZE_T_FMT " written: %s\n", wrote, len, strerror(errno));
if (wrote == -1) wrote = 0;
return ret;
}
-static modem_state_t modem_get_state(modem_t *modem)
+static modem_state_t modem_get_state(modem_t *modem)
{
modem_state_t state;
return state;
}
-static void _modem_set_state(modem_t *modem, modem_state_t state, const char *file, const char *func, int line)
+static void _modem_set_state(modem_t *modem, modem_state_t state, const char *file, const char *func, int line)
{
switch_mutex_lock(modem->mutex);
- switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG,"Modem %s [%s] - Changing state to %s\n", modem->devlink,
+ switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG,"Modem %s [%s] - Changing state to %s\n", modem->devlink,
modem_state2name(modem->state), modem_state2name(state));
modem->state = state;
switch_mutex_unlock(modem->mutex);
}
#define modem_set_state(_modem, _state) _modem_set_state(_modem, _state, __FILE__, __SWITCH_FUNC__, __LINE__)
-char *modem_state2name(int state)
+char *modem_state2name(int state)
{
if (state > MODEM_STATE_LAST || state < 0) {
state = MODEM_STATE_LAST;
return MODEM_STATE[state].name;
}
-int modem_close(modem_t *modem)
+int modem_close(modem_t *modem)
{
int r = 0;
switch_status_t was_running = switch_test_flag(modem, MODEM_FLAG_RUNNING);
#ifndef WIN32
snprintf(modem->devlink, sizeof(modem->devlink), "%s/FS%d", spandsp_globals.modem_directory, modem->slot);
-
+
unlink(modem->devlink);
if (symlink(modem->stty, modem->devlink)) {
}
modem->threadAbort = CreateEvent(NULL, TRUE, FALSE, NULL);
#endif
-
+
if (!(modem->t31_state = t31_init(NULL, t31_at_tx_handler, modem, t31_call_control_handler, modem, t38_tx_packet_handler, modem))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot initialize the T.31 modem\n");
modem_close(modem);
static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
-/*
- State methods they get called when the state changes to the specific state
+/*
+ State methods they get called when the state changes to the specific state
returning SWITCH_STATUS_SUCCESS tells the core to execute the standard state method next
so if you fully implement the state you can return SWITCH_STATUS_FALSE to skip it.
*/
t31_call_event(tech_pvt->modem->t31_state, AT_CALL_EVENT_ALERTING);
rt = ring_ticks;
}
-
+
switch_yield(rest);
to_ticks--;
}
-
+
if (to_ticks < 1 || modem_get_state(tech_pvt->modem) != MODEM_STATE_ANSWERED) {
t31_call_event(tech_pvt->modem->t31_state, AT_CALL_EVENT_NO_ANSWER);
switch_channel_hangup(channel, SWITCH_CAUSE_NO_ANSWER);
}
switch_channel_set_state(channel, CS_ROUTING);
-
+
return SWITCH_STATUS_SUCCESS;
}
//channel = switch_core_session_get_channel(session);
//switch_assert(channel != NULL);
-
+
if ((tech_pvt = switch_core_session_get_private(session))) {
switch_core_timer_destroy(&tech_pvt->timer);
tech_pvt->read_frame.flags = SFF_NONE;
switch_core_timer_next(&tech_pvt->timer);
-
+
do {
r = t31_tx(tech_pvt->modem->t31_state, data + samples_read, samples_wanted - samples_read);
if (r < 0) break;
if (t31_rx(tech_pvt->modem->t31_state, frame->data, frame->datalen / 2)) {
status = SWITCH_STATUS_FALSE;
}
-
+
return status;
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_ERROR, "Cannot find a modem.\n");
cause = SWITCH_CAUSE_USER_BUSY; goto fail;
}
-
+
switch_core_session_add_stream(*new_session, NULL);
if ((tech_pvt = (private_t *) switch_core_session_alloc(*new_session, sizeof(private_t))) != 0) {
char name[1024];
switch_caller_profile_t *caller_profile;
char *ani = NULL, *p, *digits = NULL;
-
+
if (!(session = switch_core_session_request(modem_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, SOF_NONE, NULL))) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Failure.\n");
goto end;
switch_core_session_add_stream(session, NULL);
channel = switch_core_session_get_channel(session);
tech_pvt = (private_t *) switch_core_session_alloc(session, sizeof(*tech_pvt));
-
+
p = switch_core_session_strdup(session, modem->digits);
if (*p == '*') {
ani = NULL;
}
}
-
+
if (zstr(digits)) {
digits = p;
}
caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
modem->devlink,
spandsp_globals.modem_dialplan,
- "FSModem",
+ "FSModem",
ani,
- NULL,
+ NULL,
ani,
- NULL,
- NULL,
- "mod_spandsp",
- spandsp_globals.modem_context,
+ NULL,
+ NULL,
+ "mod_spandsp",
+ spandsp_globals.modem_context,
digits);
caller_profile->source = switch_core_strdup(caller_profile->pool, "mod_spandsp");
{
switch_core_session_t *session = NULL;
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Control Handler op:%d state:[%s] %s\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Control Handler op:%d state:[%s] %s\n",
op, modem_state2name(modem_get_state(modem)), modem->devlink);
switch (op) {
wake_modem_thread(modem);
switch_set_string(modem->digits, num);
-
+
if (create_session(&session, modem) != SWITCH_STATUS_SUCCESS) {
t31_call_event(modem->t31_state, AT_CALL_EVENT_HANGUP);
} else {
modem_set_state(modem, MODEM_STATE_OFFHOOK);
break;
case AT_MODEM_CONTROL_ONHOOK:
- case AT_MODEM_CONTROL_HANGUP:
+ case AT_MODEM_CONTROL_HANGUP:
{
if (modem_get_state(modem) != MODEM_STATE_RINGING) {
int set_state = 1;
-
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
"Modem %s [%s] - Hanging up\n", modem->devlink, modem_state2name(modem_get_state(modem)));
switch_clear_flag(modem, MODEM_FLAG_XOFF);
if (!zstr(modem->uuid_str)) {
switch_core_session_t *session;
-
+
if ((session = switch_core_session_force_locate(modem->uuid_str))) {
switch_channel_t *channel = switch_core_session_get_channel(session);
-
+
if (switch_channel_up(channel)) {
switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
set_state = 0;
{
struct pollfd pfds[2] = { { 0 } };
int s = 0, r = 0;
-
+
pfds[0].fd = sock;
if ((flags & MODEM_POLL_READ)) {
if ((flags & MODEM_POLL_ERROR)) {
pfds[0].events |= POLLERR;
}
-
+
s = poll(pfds, 1, ms);
if (s < 0) {
if (result == 0)
{
if (GetLastError() != ERROR_IO_PENDING) {
- /* something went horribly wrong with WaitCommEvent(), so
+ /* something went horribly wrong with WaitCommEvent(), so
clear all errors and try again */
DWORD comerrors;
ClearCommError(modem->master, &comerrors, 0);
continue;
}
-#ifndef WIN32
+#ifndef WIN32
r = read(modem->master, buf, avail);
#else
o.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
return NULL;
}
-static void launch_modem_thread(modem_t *modem)
+static void launch_modem_thread(modem_t *modem)
{
switch_thread_t *thread;
switch_threadattr_t *thd_attr = NULL;
{
int max = globals.SOFT_MAX_MODEMS;
int x;
-
+
switch_mutex_lock(globals.mutex);
for (x = 0; x < max; x++) {
globals.pool = pool;
globals.SOFT_MAX_MODEMS = spandsp_globals.modem_count;
-
+
switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, pool);
modem_endpoint_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE);
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
typedef enum {
- MODEM_STATE_INIT,
- MODEM_STATE_ONHOOK,
- MODEM_STATE_OFFHOOK,
+ MODEM_STATE_INIT,
+ MODEM_STATE_ONHOOK,
+ MODEM_STATE_OFFHOOK,
MODEM_STATE_ACQUIRED,
MODEM_STATE_RINGING,
MODEM_STATE_ANSWERED,
//#define UDPTL_DEBUG
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2009, Steve Underwood <steveu@coppice.org>
*
* License.
*
* Contributor(s):
- *
+ *
* Steve Underwood <steveu@coppice.org>
*
* udptl.c -- UDPTL handling for T.38
FEC mode after sending some redundant packets, and this may then be important. */
x = (seq_no - i) & UDPTL_BUF_MASK;
if (lengths[i - 1] > 0)
- memcpy(s->rx[x].buf, bufs[i - 1], lengths[i - 1]);
+ memcpy(s->rx[x].buf, bufs[i - 1], lengths[i - 1]);
s->rx[x].buf_len = lengths[i - 1];
s->rx[x].fec_len[0] = 0;
s->rx[x].fec_span = 0;
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2009, Steve Underwood <steveu@coppice.org>
*
* License.
*
* Contributor(s):
- *
+ *
* Steve Underwood <steveu@coppice.org>
*
* udptl.h -- UDPTL handling for T.38
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Csaba Zelei <csaba.zelei@eworldcom.net>
*
- * Thanks for eWorld Com Ltd. for funding the module.
+ * Thanks for eWorld Com Ltd. for funding the module.
*
* mod_spy.c -- UserSpy Module
*
switch_core_hash_insert(globals.spy_hash, data, spy);
switch_thread_rwlock_unlock(globals.spy_hash_lock);
-
+
return SWITCH_STATUS_SUCCESS;
}
while (spy) {
if ((session = switch_core_session_locate(spy->uuid))) {
switch_channel_t *channel = switch_core_session_get_channel(session);
-
+
my_uuid = switch_event_get_header(event, "Unique-ID");
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "UserSpy retrieved uuid %s for key %s, activating eavesdrop\n", my_uuid, key);
-
+
switch_channel_set_variable(channel, "spy_uuid", my_uuid);
found++;
-
+
switch_channel_set_state(channel, CS_EXCHANGE_MEDIA);
switch_channel_set_flag(channel, CF_BREAK);
-
+
switch_core_session_rwunlock(session);
}
spy = spy->next;
if (!found) {
status = SWITCH_STATUS_FALSE;
}
-
-
+
+
done:
switch_thread_rwlock_unlock(globals.spy_hash_lock);
return status;
switch_core_session_t *peer_session = NULL;
switch_channel_t *peer_channel = NULL;
switch_event_t *peer_event = NULL;
-
+
if (!peer_uuid) {
return;
}
}
peer_channel = switch_core_session_get_channel(peer_session);
-
+
if (switch_event_create(&peer_event, SWITCH_EVENT_CHANNEL_BRIDGE) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't create bridge event for peer channel %s\n", peer_uuid);
goto end;
df2 [0] = sf_0 + sf_2;
df2 [2] = sf_0 - sf_2;
-
+
coef_index += 4;
}
while (coef_index < _length);
const flt_t b_0 = x [0] + x [2];
const flt_t b_2 = x [1] + x [3];
-
+
f [0] = b_0 + b_2;
f [2] = b_0 - b_2;
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
* mod_stress.cpp -- Detect Voice Stress
} else {
return SWITCH_FALSE;
}
-
+
sth->data = (float *) switch_core_session_alloc(sth->session, sizeof(*sth->data) * sth->frame_size);
sth->result = (float *) switch_core_session_alloc(sth->session, sizeof(*sth->result) * sth->frame_size);
sth->pow_spectrum = (float *) switch_core_session_alloc(sth->session, sizeof(*sth->pow_spectrum) * sth->frame_size);
sth->audio = (int16_t *) switch_core_session_alloc(sth->session, sizeof(*sth->audio) * sth->frame_size);
-
+
sth->fft = new FFTReal (sth->frame_size);
switch_buffer_create_dynamic(&sth->audio_buffer, sth->frame_size, sth->frame_size * 3, 0);
sth->bind = (float) sth->rate / sth->frame_size;
sth->start = (int) (8.0 / sth->bind);
sth->end = (int) (14.0 / sth->bind);
-
+
}
break;
case SWITCH_ABC_TYPE_CLOSE:
case SWITCH_ABC_TYPE_WRITE_REPLACE:
{
switch_frame_t *frame;
-
+
if (sth->read) {
frame = switch_core_media_bug_get_read_replace_frame(bug);
} else {
if (!switch_test_flag(frame, SFF_CNG)) {
switch_buffer_write(sth->audio_buffer, frame->data, frame->datalen);
}
-
+
sth->stress = 0.0;
if (switch_buffer_inuse(sth->audio_buffer) >= sth->frame_size * sizeof(int16_t)) {
bytes = switch_buffer_read(sth->audio_buffer, sth->audio, sth->frame_size * sizeof(int16_t));
samples = bytes / sizeof(int16_t);
-
+
switch_short_to_float(sth->audio, sth->data, samples);
sth->fft->do_fft(sth->result, sth->data);
sth->avg_tremor_pwr = 0.0;
sth->avg_total_pwr = 0.0;
sth->total_pwr = 0.0;
-
+
for (i = sth->start; i <= sth->end; ++i) {
sth->avg_tremor_pwr += sth->pow_spectrum[i];
}
sth->total_pwr += sth->pow_spectrum[i];
}
sth->avg_total_pwr = sth->total_pwr / samples;
-
+
if (sth->total_pwr < threshold) {
sth->tremor_ratio = 0.0;
} else {
}
sth->session = session;
-
+
if ((status = switch_core_media_bug_add(session, "stress", NULL, stress_callback, sth, 0,
sth->read ? SMBF_READ_REPLACE : SMBF_WRITE_REPLACE, &bug)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Failure!\n");
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
- SWITCH_ADD_APP(app_interface, "stress", "Analyze the stream for voice stress", "Analyze the stream for voice stress",
+ SWITCH_ADD_APP(app_interface, "stress", "Analyze the stream for voice stress", "Analyze the stream for voice stress",
stress_start_function, "[read|write|stop]", SAF_NONE);
/* indicate that the module should continue to be loaded */
goto end;
}
memset(substituted, 0, len);
-
+
switch_perform_substitution(re, proceed, rule->replace, number, substituted, len, ovector);
if ((switch_string_var_check_const(substituted) || switch_string_has_escaped_data(substituted))) {
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* William King <william.king@quentustech.com>
* Emmanuel Schmidbauer <eschmidbauer@gmail.com>
/* Prototypes */
SWITCH_MODULE_LOAD_FUNCTION(mod_valet_parking_load);
-/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
+/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
* Defines a switch_loadable_module_function_table_t and a static const char[] modname
*/
SWITCH_MODULE_DEFINITION(mod_valet_parking, mod_valet_parking_load, NULL, NULL);
switch_mutex_lock(lot->mutex);
top:
-
+
for (i_hi = switch_core_hash_first_iter( lot->hash, i_hi); i_hi; i_hi = switch_core_hash_next(&i_hi)) {
switch_core_hash_this(i_hi, &i_var, NULL, &i_val);
i_ext = (char *) i_var;
token = (valet_token_t *) i_val;
cur = (now - token->start_time);
i = atoi(token->ext);
-
+
if (cur > longest && i >= min && i <= max) {
longest = cur;
longest_ext = i;
return token;
}
-static int valet_lot_count(valet_lot_t *lot)
+static int valet_lot_count(valet_lot_t *lot)
{
switch_hash_index_t *i_hi;
const void *i_var;
continue;
}
count++;
- }
+ }
switch_mutex_unlock(lot->mutex);
return count;
switch_event_t *event;
int count;
-
+
dup_lot_name = strdup(lot_name);
lot_name = dup_lot_name;
if ((domain_name = strchr(dup_lot_name, '@'))) {
*domain_name++ = '\0';
}
-
+
if (zstr(domain_name)) {
dup_domain_name = switch_core_get_domain(SWITCH_TRUE);
domain_name = dup_domain_name;
}
-
+
if (zstr(domain_name)) {
domain_name = "cluecon.com";
}
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", lot_name);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", lot_name, domain_name);
-
+
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "force-status", "Active (%d caller%s)", count, count == 1 ? "" : "s");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "active");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", lot_name);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", lot_name, domain_name);
-
+
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "force-status", "Empty");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "unknown");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "answer-state", "terminated");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "presence-call-direction", "inbound");
switch_event_fire(&event);
- }
+ }
}
-
+
if (in) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "answer-state", "terminated");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "presence-call-direction", "inbound");
switch_event_fire(&event);
- }
+ }
}
switch_safe_free(dup_domain_name);
switch_safe_free(dup_lot_name);
-
+
}
struct read_frame_data {
rf->to = -1;
return SWITCH_STATUS_FALSE;
}
-
+
return SWITCH_STATUS_SUCCESS;
}
if (token && !token->bridged) {
switch_core_session_t *b_session;
-
+
if (token->timeout) {
const char *var = switch_channel_get_variable(channel, "valet_ticket");
-
+
if (!zstr(var)) {
if (!strcmp(var, token->uuid)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Valet ticket %s accepted.\n", var);
switch_core_session_rwunlock(b_session);
token->timeout = 0;
token->bridged = 1;
-
+
switch_ivr_uuid_bridge(token->uuid, switch_core_session_get_uuid(session));
return;
if (!strcasecmp(music, "silence")) {
music = "silence_stream://-1";
}
-
+
if ((orbit_exten = switch_channel_get_variable(channel, "valet_parking_orbit_exten"))) {
orbit_exten_str = switch_core_session_sprintf(session, "set:valet_parking_orbit_exten=%s,", orbit_exten);
}
}
if ((timeout = switch_channel_get_variable(channel, "valet_parking_timeout"))) {
- timeout_str = switch_core_session_sprintf(session, "set:valet_parking_timeout=%s,", timeout);
+ timeout_str = switch_core_session_sprintf(session, "set:valet_parking_timeout=%s,", timeout);
}
dest = switch_core_session_sprintf(session, "%s%s%s%s"
- "set:valet_ticket=%s,set:valet_hold_music='%s',sleep:1000,valet_park:%s %s",
+ "set:valet_ticket=%s,set:valet_hold_music='%s',sleep:1000,valet_park:%s %s",
timeout_str,
orbit_exten_str,
orbit_dialplan_str,
switch_core_session_t *b_session;
if ((b_session = switch_core_session_locate(uuid))) {
- token->timeout = switch_epoch_time_now(NULL) + TOKEN_FREQ;
+ token->timeout = switch_epoch_time_now(NULL) + TOKEN_FREQ;
if (play_announce) {
switch_ivr_sleep(session, 1500, SWITCH_TRUE, NULL);
switch_ivr_phrase_macro(session, "valet_announce_ext", tmp, NULL, NULL);
to_val = tmp;
}
}
-
+
if (to_val) {
switch_codec_implementation_t read_impl;
switch_core_session_get_read_impl(session, &read_impl);
-
+
rf.to = (1000 / (read_impl.microseconds_per_packet / 1000)) * to_val;
rf.dp = switch_channel_get_variable(channel, "valet_parking_orbit_dialplan");
rf.context = switch_channel_get_variable(channel, "valet_parking_orbit_context");
char *dup_to = NULL, *lot_name, *dup_lot_name = NULL, *domain_name;
valet_lot_t *lot;
int found = 0;
-
+
if (!to || strncasecmp(to, "park+", 5) || !strchr(to, '@')) {
return;
}
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "answer-state", "terminated");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "presence-call-direction", "inbound");
switch_event_fire(&event);
- }
+ }
}
} else {
switch_console_callback_match_t *matches = NULL;
switch_console_push_match(&matches, nvar);
}
}
- switch_mutex_unlock(globals.mutex);
-
+ switch_mutex_unlock(globals.mutex);
+
if (matches) {
valet_token_t *token;
-
+
for (m = matches->head; !found && m; m = m->next) {
lot = valet_find_lot(m->val, SWITCH_FALSE);
switch_mutex_lock(lot->mutex);
if ((token = (valet_token_t *) switch_core_hash_find(lot->hash, lot_name)) && !token->timeout) {
found++;
-
+
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", VALET_PROTO);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", lot_name);
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2008, Eric des Courtis <eric.des.courtis@benbria.com>
*
* Copyright (C) Benbria. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Eric des Courtis <eric.des.courtis@benbria.com>
*
* Special thanks to the following companies for their help:
* mod_vmd.c -- Voicemail Detection Module
*
* This module detects voicemail beeps at any frequency in O(1) time.
- *
+ *
*/
#include <switch.h>
/*! \brief Conversion of frequency to Hz
*
- * \f$F = \frac{f}{{2}{\pi}}\f$
+ * \f$F = \frac{f}{{2}{\pi}}\f$
*/
#define TO_HZ(f) ((F * f) / (2.0 * M_PI))
/* Number of points in discreet energy separation. */
#define P (5)
-/* Maximum signed value of int16_t
+/* Maximum signed value of int16_t
* DEPRECATED */
#define ADJUST (32768)
-/* Same as above times two
+/* Same as above times two
* DEPRECATED */
#define ADJUST_MAX (65536)
#define PRINT2(a, b) do{ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, a, b); }while(0)
*/
-/*! \brief The callback function that is called when new audio data becomes available
+/*! \brief The callback function that is called when new audio data becomes available
*
* @author Eric des Courtis
* @param bug A reference to the media bug.
return SWITCH_TRUE;
}
-/*! \brief Process and convert data to be used by the find_beep() function
+/*! \brief Process and convert data to be used by the find_beep() function
*
* @author Eric des Courtis
* @param vmd_info The session information associated with the call.
if (vmd_info->data != NULL) free(vmd_info->data);
vmd_info->data = (int16_t *)malloc(len);
if (vmd_info->data == NULL) return SWITCH_FALSE;
- }
+ }
(void)memcpy(vmd_info->data, data, len);
for(i = 2; i < frame->samples; i++){
- vmd_info->data[i] =
- 0.0947997 * data[i]
- -
- 0.0947997 * data[i - 2]
- -
- 1.4083405 * vmd_info->data[i - 1]
- +
+ vmd_info->data[i] =
+ 0.0947997 * data[i]
+ -
+ 0.0947997 * data[i - 2]
+ -
+ 1.4083405 * vmd_info->data[i - 1]
+ +
0.8104005 * vmd_info->data[i - 2];
}
*/
return SWITCH_TRUE;
}
-/*! \brief Find voicemail beep in the audio stream
+/*! \brief Find voicemail beep in the audio stream
*
* @author Eric des Courtis
* @param vmd_info The session information associated with the call.
}
}
-/*! \brief Find the median of an array of doubles
+/*! \brief Find the median of an array of doubles
*
* @param m Array of frequency samples.
* @param n Number of samples in the array.
return mingtguess;
}
-/*! \brief Convert many points for Signed L16 to relative floating point
+/*! \brief Convert many points for Signed L16 to relative floating point
*
* @author Eric des Courtis
* @param i_pts Array of P 16 bit integer audio samples.
}
/*! \brief Amplitude estimator for DESA-2
- *
+ *
* The function is defined as \f$A = \sqrt{\frac{\psi{(x)}}{\sin{\Omega^2}}}\f$
- *
+ *
* @author Eric des Courtis
* @param x An array of 5 evenly spaced audio samples \f$x_0, x_1, x_2, x_3, x_4\f$.
* @return The estimated amplitude.
return sqrt(PSI(x) / sin(freq_sq));
}
-/*! \brief The DESA-2 algorithm
+/*! \brief The DESA-2 algorithm
*
- * The function is defined as \f$f = \frac{1}{2}\arccos{\frac{{{x^2_2} -
- * {x_0}{x_4}} - {{x^2_1} -
- * {x_0}{x_2}} - {{x^2_3} -
+ * The function is defined as \f$f = \frac{1}{2}\arccos{\frac{{{x^2_2} -
+ * {x_0}{x_4}} - {{x^2_1} -
+ * {x_0}{x_2}} - {{x^2_3} -
* {x_2}{x_4}}}
* {{2}({x^2_2} - {x_1}{x_3})}}\f$
*
);
}
-/*! \brief FreeSWITCH module loading function
+/*! \brief FreeSWITCH module loading function
*
* @author Eric des Courtis
* @return Load success or failure.
/* Separate the arguments */
argc = switch_separate_string(ccmd, ' ', argv, VMD_PARAMS);
- /* If we don't have the expected number of parameters
+ /* If we don't have the expected number of parameters
* display usage */
if (argc != VMD_PARAMS) {
stream->write_function(stream, "-USAGE: %s\n", VMD_SYNTAX);
vmd_info->points[i].ampl = 0.0;
}
- /* Add a media bug that allows me to intercept the
+ /* Add a media bug that allows me to intercept the
* reading leg of the audio stream */
status = switch_core_media_bug_add(vmd_session, "vmd", NULL, vmd_callback, vmd_info, 0, SMBF_READ_REPLACE, &bug);
<!--<param name="record-copyright" value="Your Copyright"/>-->
</profile>
</profiles>
-</configuration>
+</configuration>
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Bret McDanel <trixter AT 0xdecafbad.com>
* John Wehle (john@feith.com)
switch_cache_db_handle_t *dbh = NULL;
char *dsn;
-
+
if (!zstr(profile->odbc_dsn)) {
dsn = profile->odbc_dsn;
} else {
if (switch_cache_db_get_db_handle_dsn(&dbh, dsn) != SWITCH_STATUS_SUCCESS) {
dbh = NULL;
}
-
+
return dbh;
}
}
/*!
- * \brief Sets the profile's configuration instructions
+ * \brief Sets the profile's configuration instructions
*/
vm_profile_t *profile_set_config(vm_profile_t *profile)
{
profile->config_str_pool.pool = profile->pool;
/*
- SWITCH _CONFIG_SET_ITEM(item, "key", type, flags,
+ SWITCH _CONFIG_SET_ITEM(item, "key", type, flags,
pointer, default, options, help_syntax, help_description)
*/
&profile->db_password_override, SWITCH_FALSE, NULL, NULL, NULL);
SWITCH_CONFIG_SET_ITEM(profile->config[i++], "allow-empty-password-auth", SWITCH_CONFIG_BOOL, CONFIG_RELOADABLE,
&profile->allow_empty_password_auth, SWITCH_TRUE, NULL, NULL, NULL);
- SWITCH_CONFIG_SET_ITEM(profile->config[i++], "auto-playback-recordings", SWITCH_CONFIG_BOOL, CONFIG_RELOADABLE, &profile->auto_playback_recordings, SWITCH_FALSE, NULL, NULL, NULL);
+ SWITCH_CONFIG_SET_ITEM(profile->config[i++], "auto-playback-recordings", SWITCH_CONFIG_BOOL, CONFIG_RELOADABLE, &profile->auto_playback_recordings, SWITCH_FALSE, NULL, NULL, NULL);
SWITCH_CONFIG_SET_ITEM(profile->config[i++], "send-full-vm-header", SWITCH_CONFIG_BOOL, CONFIG_RELOADABLE, &profile->send_full_vm_header, SWITCH_FALSE, NULL, NULL, NULL);
switch_assert(i < VM_PROFILE_CONFIGITEM_COUNT);
if (!cc->noexit
&& (dtmf->digit == *cc->profile->delete_file_key || dtmf->digit == *cc->profile->save_file_key
- || dtmf->digit == *cc->profile->prev_msg_key || dtmf->digit == *cc->profile->next_msg_key
+ || dtmf->digit == *cc->profile->prev_msg_key || dtmf->digit == *cc->profile->next_msg_key
|| dtmf->digit == *cc->profile->repeat_msg_key
|| dtmf->digit == *cc->profile->terminator_key || dtmf->digit == *cc->profile->skip_info_key
|| dtmf->digit == *cc->profile->forward_key)) {
msg.string_arg = cid_buf;
msg.message_id = SWITCH_MESSAGE_INDICATE_DISPLAY;
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Sending display update [%s] to %s\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Sending display update [%s] to %s\n",
cid_buf, switch_channel_get_name(channel));
switch_core_session_receive_message(session, &msg);
-
+
if (!zstr(cbt->cid_number) && (switch_true(switch_channel_get_variable(channel, "vm_announce_cid")))) {
TRY_CODE(switch_ivr_phrase_macro(session, VM_SAY_PHONE_NUMBER_MACRO, cbt->cid_number, NULL, NULL));
}
-
+
args.input_callback = cancel_on_dtmf;
-
+
switch_snprintf(key_buf, sizeof(key_buf), "%s:%s:%s:%s:%s:%s%s%s", profile->repeat_msg_key, profile->save_file_key,
profile->delete_file_key, profile->email_key, profile->callback_key,
profile->forward_key, cbt->email ? ":" : "", cbt->email ? cbt->email : "");
TRY_CODE(switch_ivr_read
(session, 0, sizeof(vm_cc), macro_buf, NULL, vm_cc, sizeof(vm_cc), profile->digit_timeout, profile->terminator_key, 0));
- cmd = switch_core_session_sprintf(session, "%s@%s@%s %s %s '%s'", vm_cc, cbt->domain, profile->name,
+ cmd = switch_core_session_sprintf(session, "%s@%s@%s %s %s '%s'", vm_cc, cbt->domain, profile->name,
new_file_path, cbt->cid_number, cbt->cid_name);
switch_event_create(&my_params, SWITCH_EVENT_REQUEST_PARAMS);
status = switch_xml_locate_user_merged("id:number-alias", vm_cc, cbt->domain, NULL, &x_user, my_params);
switch_event_destroy(&my_params);
-
+
if (status != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
"Failed to forward message - Cannot locate user %s@%s\n", vm_cc, cbt->domain);
TRY_CODE(switch_ivr_phrase_macro(session, VM_INVALID_EXTENSION_MACRO, vm_cc, NULL, NULL));
continue;
static void update_mwi(vm_profile_t *profile, const char *id, const char *domain_name, const char *myfolder, mwi_reason_t reason)
{
const char *yn = "no";
- const char *update_reason = mwi_reason2str(reason);
+ const char *update_reason = mwi_reason2str(reason);
int total_new_messages = 0;
int total_saved_messages = 0;
int total_new_urgent_messages = 0;
if (vm_auto_play && !switch_true(vm_auto_play)) {
auto_play = 0;
}
-
+
folder_args.input_callback = cancel_on_dtmf;
folder_args.buf = &global_buf;
folder_args.buflen = sizeof(global_buf);
continue;
}
}
-
+
if (auto_play && !heard_auto_new && total_new_messages + total_new_urgent_messages > 0) {
heard_auto_new = 1;
play_msg_type = MSG_NEW;
} else if (cbt.move == VM_MOVE_SAME) {
cur_message -= 1;
}
-
+
if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
break;
}
TRY_CODE(create_file(session, profile, VM_RECORD_GREETING_MACRO, file_path, &message_len, SWITCH_TRUE, NULL, NULL));
switch_file_rename(tmp_file_path, file_path, switch_core_session_get_pool(session));
-
+
sql =
switch_mprintf("update voicemail_prefs set greeting_path='%q' where username='%q' and domain='%q'", file_path, myid,
domain_name);
fail = 0;
switch_snprintf(macro, sizeof(macro), "phrase:%s:%s", VM_ENTER_PASS_MACRO, profile->terminator_key);
TRY_CODE(switch_ivr_read(session, 0, 255, macro, NULL, buf, sizeof(buf), 10000, profile->terminator_key, 0));
-
+
switch_event_create_subclass(¶ms, SWITCH_EVENT_CUSTOM, VM_EVENT_MAINT);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "VM-Action", "change-password");
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "VM-User", myid);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "VM-Domain", domain_name);
switch_channel_event_set_data(channel, params);
-
+
if (zstr(buf) && !profile->allow_empty_password_auth) {
fail = 1;
}
if (switch_xml_locate_user("id", myid, domain_name, switch_channel_get_variable(channel, "network_addr"),
&xx_domain_root, &xx_domain, &xx_user, NULL, params) == SWITCH_STATUS_SUCCESS) {
switch_xml_t x_result;
-
+
if ((x_result = switch_xml_child(xx_user, "result"))) {
if (!switch_true(switch_xml_attr_soft(x_result, "success"))) {
fail = 1;
}
}
-
+
switch_xml_free(xx_domain_root);
}
-
+
if (fail) {
/* add feedback for user - let him/her know that the password they tried to change to is not allowed */
switch_ivr_phrase_macro(session, VM_CHANGE_PASS_FAIL_MACRO, NULL, NULL, NULL);
const char *read_flags,
switch_event_t *params,
switch_memory_pool_t *pool,
- const char *caller_id_name,
- const char *caller_id_number,
- const char *forwarded_by,
+ const char *caller_id_name,
+ const char *caller_id_number,
+ const char *forwarded_by,
switch_bool_t copy, const char *use_uuid, switch_core_session_t *session)
{
char *file_path = NULL, *dir_path = NULL;
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "voicemail_account", myid);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "voicemail_domain", domain_name);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "voicemail_caller_id_number", caller_id_number);
- switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "voicemail_formatted_caller_id_number", formatted_cid_num);
+ switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "voicemail_formatted_caller_id_number", formatted_cid_num);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "voicemail_caller_id_name", caller_id_name);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "voicemail_file_path", file_path);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "voicemail_read_flags", read_flags);
if (zstr(vm_notify_email)) {
vm_notify_email = vm_email;
}
-
+
if (zstr(profile->notify_email_headers)) {
headers = switch_mprintf("From: FreeSWITCH mod_voicemail <%s@%s>\n"
"Subject: Voicemail from %s %s\nX-Priority: %d", myid, domain_name, caller_id_name, caller_id_number, priority);
char *forwarded_by = NULL;
char *read_flags = NORMAL_FLAG_STRING;
char *dup_domain = NULL;
-
+
if (zstr(data)) {
status = SWITCH_STATUS_FALSE;
goto end;
switch_xml_merge_user(ut, x_domain, group);
switch_event_create(&my_params, SWITCH_EVENT_REQUEST_PARAMS);
- status = deliver_vm(profile, ut, domain, path, 0, read_flags,
- my_params, pool, cid_name, cid_num, forwarded_by, SWITCH_TRUE,
+ status = deliver_vm(profile, ut, domain, path, 0, read_flags,
+ my_params, pool, cid_name, cid_num, forwarded_by, SWITCH_TRUE,
session ? switch_core_session_get_uuid(session) : NULL, session);
switch_event_destroy(&my_params);
}
switch_xml_merge_user(ut, x_domain, group);
switch_event_create(&my_params, SWITCH_EVENT_REQUEST_PARAMS);
- status = deliver_vm(profile, ut, domain, path, 0, read_flags,
+ status = deliver_vm(profile, ut, domain, path, 0, read_flags,
my_params, pool, cid_name, cid_num, forwarded_by, SWITCH_TRUE,
session ? switch_core_session_get_uuid(session) : NULL, session);
switch_event_destroy(&my_params);
if ((status = switch_xml_locate_user_in_domain(user, x_domain, &ut, &x_group)) == SWITCH_STATUS_SUCCESS) {
switch_xml_merge_user(ut, x_domain, x_group);
switch_event_create(&my_params, SWITCH_EVENT_REQUEST_PARAMS);
- status = deliver_vm(profile, ut, domain, path, 0, read_flags,
+ status = deliver_vm(profile, ut, domain, path, 0, read_flags,
my_params, pool, cid_name, cid_num, forwarded_by, SWITCH_TRUE,
session ? switch_core_session_get_uuid(session) : NULL, session);
switch_event_destroy(&my_params);
char sql[256];
prefs_callback_t cbt;
switch_uuid_t tmp_uuid;
- char tmp_uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
+ char tmp_uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
char *file_path = NULL;
char *dir_path = NULL;
switch_status_t status = SWITCH_STATUS_SUCCESS;
int argc;
char *argv[4];
char *mycmd;
-
+
if ((!zstr(operator_ext) && (mycmd = switch_core_session_strdup(session, operator_ext))) ||
(!zstr(profile->operator_ext) && (mycmd = switch_core_session_strdup(session, profile->operator_ext)))) {
argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
if ((profile = (vm_profile_t *) switch_core_hash_find(globals.profile_hash, domain))) {
parse_profile();
} else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
"Cound not find a profile for domain: [%s] Returning 0 messages\nWhen message-query-exact-match is enabled you must have a dedicated vm profile per distinct domain name you wish to use.\n", domain);
}
} else {
holder->stream->write_function(holder->stream, "<font face=tahoma><div class=title><b>Message from %s %s</b></div><hr noshade size=1>\n",
argv[5], argv[6]);
holder->stream->write_function(holder->stream, "Priority: %s<br>\n" "Created: %s<br>\n" "Last Heard: %s<br>\n" "Duration: %s<br>\n",
- //"<a href=%s>Delete This Message</a><br><hr noshade size=1>",
+ //"<a href=%s>Delete This Message</a><br><hr noshade size=1>",
strcmp(argv[10], URGENT_FLAG_STRING) ? "normal" : "urgent", create_date, heard, duration_str);
switch_snprintf(title_b4, sizeof(title_b4), "%s <%s> %s", argv[5], argv[6], rss_date);
{
unlink(argv[3]);
-
+
return 0;
}
}
id = strdup(cmd);
-
+
if (!id) {
stream->write_function(stream, "Allocation Error\n");
return SWITCH_STATUS_SUCCESS;
if (domain && profile_name && (profile = get_profile(profile_name))) {
-
+
if (uuid) {
sql = switch_mprintf("select username, domain, in_folder, file_path from voicemail_msgs where uuid='%q'", uuid);
} else {
sql = switch_mprintf("select username, domain, in_folder, file_path from voicemail_msgs where username='%q' and domain='%q'", id, domain);
}
-
+
vm_execute_sql_callback(profile, profile->mutex, sql, api_del_callback, profile);
switch_safe_free(sql);
-
+
if (uuid) {
sql = switch_mprintf("delete from voicemail_msgs where uuid='%q'", uuid);
} else {
vm_execute_sql(profile, sql, profile->mutex);
switch_safe_free(sql);
-
+
update_mwi(profile, id, domain, "inbox", MWI_REASON_DELETE);
-
+
stream->write_function(stream, "%s", "+OK\n");
profile_rwunlock(profile);
} else {
stream->write_function(stream, "Allocation failure\n");
return SWITCH_STATUS_SUCCESS;
}
-
+
if ((p = strchr(id, '@'))) {
*p++ = '\0';
domain = e = p;
if (mread > -1 && domain && profile_name && (profile = get_profile(profile_name))) {
-
+
if (mread) {
if (uuid) {
sql = switch_mprintf("update voicemail_msgs set read_epoch=%ld where uuid='%q'", (long) switch_epoch_time_now(NULL), uuid);
vm_execute_sql(profile, sql, profile->mutex);
switch_safe_free(sql);
-
+
update_mwi(profile, id, domain, "inbox", MWI_REASON_READ);
-
+
stream->write_function(stream, "%s", "+OK\n");
profile_rwunlock(profile);
} else {
stream->write_function(stream, "%s:%s:%s:%s:%s:%s:%s:%s:%s:%s\n", argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], argv[6], argv[7], argv[8], argv[9]);
}
-
+
return 0;
}
}
id = strdup(cmd);
-
+
if (!id) {
stream->write_function(stream, "Allocation Error\n");
return SWITCH_STATUS_SUCCESS;
if (domain && profile_name && (profile = get_profile(profile_name))) {
if (uuid) {
sql = switch_mprintf("select created_epoch, read_epoch, username, domain, in_folder, file_path, uuid, cid_name, cid_number, message_len, "
- "'%q' from voicemail_msgs where username='%q' and domain='%q' and uuid='%q'",
+ "'%q' from voicemail_msgs where username='%q' and domain='%q' and uuid='%q'",
format, id, domain, uuid);
} else {
sql = switch_mprintf("select created_epoch, read_epoch, username, domain, in_folder, file_path, uuid, cid_name, cid_number, message_len, "
- "'%q' from voicemail_msgs where username='%q' and domain='%q'",
+ "'%q' from voicemail_msgs where username='%q' and domain='%q'",
format, id, domain);
}
vm_execute_sql_callback(profile, profile->mutex, sql, api_list_callback, stream);
switch_safe_free(sql);
-
+
if (!strcasecmp(format, "xml")) {
stream->write_function(stream, "</voicemail>\n");
}
profile_rwunlock(profile);
- /* TODO If no slot requested, returned currently selected and figure out the slot number from the file name.
+ /* TODO If no slot requested, returned currently selected and figure out the slot number from the file name.
* IF slot provided, check if file exist, check if it currently selected */
if (zstr(res)) {
- stream->write_function(stream, "-ERR No greeting found\n");
+ stream->write_function(stream, "-ERR No greeting found\n");
} else {
switch_event_t *my_params = NULL;
char *ebuf = NULL;
sql = switch_mprintf("UPDATE voicemail_msgs SET flags='' WHERE username='%q' AND domain='%q' AND uuid = '%q'", id, domain, uuid);
vm_execute_sql(profile, sql, profile->mutex);
profile_rwunlock(profile);
-
+
stream->write_function(stream, "-OK\n");
done:
switch_core_destroy_memory_pool(&pool);
if (!strcasecmp(var, "vm-enabled")) {
vm_enabled = !switch_false(val);
- }
+ }
if (!strcasecmp(var, "vm-password")) {
user_xml_password = val;
- }
+ }
}
sql = switch_mprintf("SELECT password FROM voicemail_prefs WHERE username = '%q' AND domain = '%q'", id, domain);
switch_uuid_format(tmp_uuid_str, &tmp_uuid);
new_file_path = switch_core_sprintf(pool, "%s%smsg_%s.wav", SWITCH_GLOBAL_dirs.temp_dir, SWITCH_PATH_SEPARATOR, tmp_uuid_str);
-
+
if (vm_merge_media_files(test, new_file_path) != SWITCH_STATUS_SUCCESS) {
stream->write_function(stream, "-ERR Error Merging the file\n");
switch_event_destroy(&cbt.my_params);
if (zstr(profile->email_headers)) {
headers = switch_core_sprintf(pool,
"From: FreeSWITCH mod_voicemail <%s@%s>\nSubject: Voicemail from %s %s\nX-Priority: %d",
- id, domain, switch_event_get_header(cbt.my_params, "VM-Message-Caller-Name"),
+ id, domain, switch_event_get_header(cbt.my_params, "VM-Message-Caller-Name"),
switch_event_get_header(cbt.my_params, "VM-Message-Caller-Number"), priority);
} else {
headers = switch_event_expand_headers(cbt.my_params, profile->email_headers);
<key dtmf="4" action="rerecord" variable="VM-Key-ReRecord-File" />
<key dtmf="#" action="skip_instruction" />
</keys>
- </menu>
+ </menu>
<menu name="std_forward_ask_prepend">
<phrases>
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Marc Olivier Chouinard <mochouinard@moctel.com>
*
*
switch_event_merge(menu_default, menu->event_settings);
switch_event_destroy(&menu->event_settings);
}
-
+
switch_event_create(&menu->event_settings, SWITCH_EVENT_REQUEST_PARAMS);
switch_event_merge(menu->event_settings, profile->event_settings);
switch_event_merge(menu->event_settings, menu_default);
if ((x_profile = switch_xml_find_child(x_profiles, "profile", "name", profile_name))) {
if (!(profile = switch_core_session_alloc(session, sizeof(vmivr_profile_t)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Alloc Failure\n");
- goto end;
+ goto end;
}
profile->name = profile_name;
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Marc Olivier Chouinard <mochouinard@moctel.com>
*
*
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Marc Olivier Chouinard <mochouinard@moctel.com>
*
*
if (is_invalid[j])
continue;
- test[0] = loc->dtmf_stored[i];
+ test[0] = loc->dtmf_stored[i];
if (loc->dtmf_accepted[j][i] == 'N' && atoi(test) >= 2 && atoi(test) <= 9)
cMatch = SWITCH_TRUE;
if (loc->dtmf_accepted[j][i] == 'X' && atoi(test) >= 0 && atoi(test) <= 9) {
if (i == strlen(loc->dtmf_accepted[j]) - 1 && loc->dtmf_accepted[j][strlen(loc->dtmf_accepted[j])-1] == '.') {
loc->completeMatch = loc->dtmf_accepted[j];
- }
+ }
if (i == loc->dtmf_received - 1 && loc->dtmf_received == strlen(loc->dtmf_accepted[j]) && loc->dtmf_accepted[j][strlen(loc->dtmf_accepted[j])-1] != '.') {
loc->completeMatch = loc->dtmf_accepted[j];
continue;
case SWITCH_INPUT_TYPE_DTMF:
{
switch_dtmf_t *dtmf = (switch_dtmf_t *) input;
- switch_bool_t audio_was_stopped = loc->audio_stopped;
+ switch_bool_t audio_was_stopped = loc->audio_stopped;
loc->audio_stopped = SWITCH_TRUE;
if (loc->dtmf_received >= sizeof(loc->dtmf_stored)) {
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Marc Olivier Chouinard <mochouinard@moctel.com>
*
*
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Marc Olivier Chouinard <mochouinard@moctel.com>
*
*
menu.ivre_d.result = RES_FOUND;
action = action_on_new_message;
action_on_new_message_occured = SWITCH_TRUE;
-
+
} else {
ivre_playback(session, &menu.ivre_d, switch_event_get_header(menu.event_phrases, "menu_options"), NULL, menu.phrase_params, NULL, menu.ivr_entry_timeout);
}
goto done;
}
} else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "API message list return invalid result : %s(%s)\n", profile->api_msg_list, cmd);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "API message list return invalid result : %s(%s)\n", profile->api_msg_list, cmd);
goto done;
}
if (msg_undeleted) {
msg_undeleted = SWITCH_FALSE;
ivre_playback(session, &menu.ivre_d, switch_event_get_header(menu.event_phrases, "ack"), "undeleted", menu.phrase_params, NULL, 0);
- }
+ }
if (msg_saved) {
msg_saved = SWITCH_FALSE;
ivre_playback(session, &menu.ivre_d, switch_event_get_header(menu.event_phrases, "ack"), "saved", menu.phrase_params, NULL, 0);
vmivr_api_execute(session, profile->api_msg_delete, cmd);
msg_deleted = SWITCH_TRUE;
-
+
if (action_on_delete) {
action = action_on_delete;
- goto action;
+ goto action;
} else {
skip_header = skip_playback = SWITCH_TRUE;
}
- } else {
+ } else {
cmd = switch_core_session_sprintf(session, "%s %s %s %s", profile->api_profile, profile->domain, profile->id, switch_event_get_header(menu.phrase_params, "VM-Message-UUID"));
vmivr_api_execute(session, profile->api_msg_undelete, cmd);
forward_msg = SWITCH_FALSE;
} else if (!strcasecmp(action, "prepend")) { /* Prepend record msg */
vmivr_menu_t sub_menu = { "std_record_message" };
-
+
const char *tmp_filepath = NULL;
const char *record_format = NULL;
/* Initialize Menu Configs */
menu_init(profile, &sub_menu);
-
+
record_format = switch_event_get_header(sub_menu.event_settings, "Record-Format");
tmp_filepath = generate_random_file_name(session, "voicemail_ivr", record_format);
const char *rec_silence_threshold = switch_event_get_header(menu->event_settings, "Record-Silence-Threshold");
const char *rec_silence_samplerate = switch_event_get_header(menu->event_settings, "Record-Sample-Rate");
const char *rec_maximum_length = switch_event_get_header(menu->event_settings, "Record-Maximum-Length");
- const char *rec_minimum_length = switch_event_get_header(menu->event_settings, "Record-Minimum-Length");
+ const char *rec_minimum_length = switch_event_get_header(menu->event_settings, "Record-Minimum-Length");
switch_size_t record_length = 0;
/* Prepare Recording File Handle */
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Marc Olivier Chouinard <mochouinard@moctel.com>
*
*
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Marc Olivier Chouinard <mochouinard@moctel.com>
*
*
SWITCH_MODULE_RUNTIME_FUNCTION(mod_voicemail_ivr_runtime);
SWITCH_MODULE_LOAD_FUNCTION(mod_voicemail_ivr_load);
-/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
+/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
* Defines a switch_loadable_module_function_table_t and a static const char[] modname
*/
SWITCH_MODULE_DEFINITION(mod_voicemail_ivr, mod_voicemail_ivr_load, mod_voicemail_ivr_shutdown, NULL);
const char *domain = NULL;
const char *profile_name = NULL;
vmivr_profile_t *profile = NULL;
- char *argv[6] = { 0 };
+ char *argv[6] = { 0 };
char *mydata = NULL;
if (!zstr(data)) {
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Marc Olivier Chouinard <mochouinard@moctel.com>
*
*
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Marc Olivier Chouinard <mochouinard@moctel.com>
*
*
-<configuration name="cepstral.conf" description="Cepstral TTS configuration">\r
- <settings>\r
- <!--\r
- Possible encodings:\r
- * utf-8\r
- * us-ascii\r
- * iso8859-1 (default)\r
- * iso8859-15\r
- -->\r
- <param name="encoding" value="utf-8"/>\r
- </settings>\r
+<configuration name="cepstral.conf" description="Cepstral TTS configuration">
+ <settings>
+ <!--
+ Possible encodings:
+ * utf-8
+ * us-ascii
+ * iso8859-1 (default)
+ * iso8859-15
+ -->
+ <param name="encoding" value="utf-8"/>
+ </settings>
</configuration>
\ No newline at end of file
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
* mod_cepstral.c -- Cepstral Interface
- *
- * Contains some material derived from the Cepstral Swift SDK, by
- * permission. You are free to copy and modify the source under the
- * terms of FreeSWITCH itself, without additional permission from
+ *
+ * Contains some material derived from the Cepstral Swift SDK, by
+ * permission. You are free to copy and modify the source under the
+ * terms of FreeSWITCH itself, without additional permission from
* Cepstral
- *
+ *
*
*/
#ifdef __ICC
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Brian West <brian@freeswitch.org>
* Raymond Chandler <intralanman@freeswitch.org>
*
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2009, Mathieu Parent <math.parent@gmail.com>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Mathieu Parent <math.parent@gmail.com>
*
* mod_tts_commandline.c -- System command ASR TTS Interface
{
tts_commandline_t *info = (tts_commandline_t *) sh->private_info;
assert(info != NULL);
-
+
if (info->fh != NULL && info->fh->file_interface != NULL) {
switch_core_file_close(info->fh);
}
lname = zstr(name) ? "" : switch_core_strdup(pool, name);
lsession_uuid = zstr(session_uuid) ? NULL : switch_core_strdup(pool, session_uuid);
-
+
if (zstr(name)) {
lname = "";
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MY_EVENT_PROFILE_CREATE);
return SWITCH_STATUS_TERM;
}
-
+
if (switch_event_reserve_subclass(MY_EVENT_PROFILE_CLOSE) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MY_EVENT_PROFILE_CLOSE);
return SWITCH_STATUS_TERM;
}
-
+
if (switch_event_reserve_subclass(MY_EVENT_PROFILE_OPEN) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MY_EVENT_PROFILE_OPEN);
return SWITCH_STATUS_TERM;
}
-
+
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
switch_event_free_subclass(MY_EVENT_PROFILE_CREATE);
switch_event_free_subclass(MY_EVENT_PROFILE_CLOSE);
switch_event_free_subclass(MY_EVENT_PROFILE_OPEN);
-
+
synth_shutdown();
recog_shutdown();
* Copyright (c) 2016, Athonet (www.athonet.com)
* Dragos Oancea <dragos.oancea@athonet.com>
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
- *
+ *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
/* Bandwidth Efficient AMR-NB */
/* https://tools.ietf.org/html/rfc4867#page-17 */
-extern switch_bool_t switch_amr_pack_be(unsigned char *shift_buf, int n)
+extern switch_bool_t switch_amr_pack_be(unsigned char *shift_buf, int n)
{
uint8_t save_toc, ft;
save_toc = shift_buf[1];
- /* we must convert OA TOC -> BE TOC */
+ /* we must convert OA TOC -> BE TOC */
/* OA TOC
0 1 2 3 4 5 6 7
+-+-+-+-+-+-+-+-+
+-+-+-+-+-+-+
|F| FT |Q|
+-+-+-+-+-+-+
- F = 0 , FT = XXXX , Q = 1
- eg: Frame Types (FT): ftp://www.3gpp.org/tsg_sa/TSG_SA/TSGS_04/Docs/PDF/SP-99253.pdf - table 1a
+ F = 0 , FT = XXXX , Q = 1
+ eg: Frame Types (FT): ftp://www.3gpp.org/tsg_sa/TSG_SA/TSGS_04/Docs/PDF/SP-99253.pdf - table 1a
*/
ft = save_toc >> 3 ; /* drop Q, P1, P2 */
shift_buf[1] |= 1 << 7;
} else {
/* reset last bit of TOC instead of P2 */
- shift_buf[1] &= ~(1 << 7);
+ shift_buf[1] &= ~(1 << 7);
}
return SWITCH_TRUE;
}
-extern switch_bool_t switch_amr_unpack_be(unsigned char *encoded_buf, uint8_t *tmp, int encoded_len)
+extern switch_bool_t switch_amr_unpack_be(unsigned char *encoded_buf, uint8_t *tmp, int encoded_len)
{
int framesz, index, ft;
uint8_t shift_tocs[2] = {0x00, 0x00};
uint8_t *shift_buf;
- memcpy(shift_tocs, encoded_buf, 2);
+ memcpy(shift_tocs, encoded_buf, 2);
/* shift for BE */
switch_amr_array_lshift(4, shift_tocs, 2);
ft = shift_tocs[0] >> 3;
return SWITCH_TRUE;
}
-#endif
+#endif
/* For Emacs:
* Local Variables:
* Copyright (c) 2016, Athonet (www.athonet.com)
* Dragos Oancea <dragos.oancea@athonet.com>
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
- *
+ *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
#define __AMR_BE_H__
/* Bandwidth Efficient AMR */
-extern switch_bool_t switch_amr_pack_be(unsigned char *shift_buf, int n);
+extern switch_bool_t switch_amr_pack_be(unsigned char *shift_buf, int n);
extern switch_bool_t switch_amr_unpack_be(unsigned char *encoded_buf, uint8_t *tmp, int encoded_len);
-#endif
+#endif
/* For Emacs:
* Local Variables:
* Copyright (c) 2016, Athonet (www.athonet.com)
* Paolo Missiaggia <paolo.missiaggia@athonet.com>
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
- *
+ *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
buf[i] = ((buf[i] & first_byte) << lshift);
return (0);
}
-#endif
+#endif
/* For Emacs:
* Local Variables:
* Copyright (c) 2016, Athonet (www.athonet.com)
* Paolo Missiaggia <paolo.missiaggia@athonet.com>
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
- *
+ *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
*/
extern int switch_amr_array_lshift(uint8_t lshift, uint8_t *buf, int a_len);
-#endif
+#endif
/* For Emacs:
* Local Variables:
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Brian K. West <brian@freeswitch.org>
* Dragos Oancea <dragos.oancea@athonet.com>
#include "amr_be.h"
/*
* Check section 8.1 of rfc3267 for possible sdp options.
- *
- * SDP Example
- *
+ *
+ * SDP Example
+ *
* a=fmtp:97 mode-set=0,2,5,7; mode-change-period=2; mode-change-neighbor=1
*
* Class A total speech
return SWITCH_TRUE;
}
-static switch_bool_t switch_amr_info(unsigned char *encoded_buf, int encoded_data_len, int payload_format, char *print_text)
+static switch_bool_t switch_amr_info(unsigned char *encoded_buf, int encoded_data_len, int payload_format, char *print_text)
{
uint8_t *tocs;
int framesz, index, not_last_frame, q, ft;
if (!encoded_buf) {
return SWITCH_FALSE;
}
-
+
/* payload format can be OA (octed-aligned) or BE (bandwidth efficient)*/
if (payload_format) {
/* OA */
encoded_buf++; /* CMR skip */
- tocs = encoded_buf;
+ tocs = encoded_buf;
index = (tocs[0] >> 3) & 0x0f;
if (index > SWITCH_AMR_MODES) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "AMR decoder (OA): Invalid Table Of Contents (TOC): 0x%x\n", index);
return SWITCH_FALSE;
}
framesz = switch_amr_frame_sizes[index];
- not_last_frame = (tocs[0] >> 7) & 1;
- q = (tocs[0] >> 2) & 1;
+ not_last_frame = (tocs[0] >> 7) & 1;
+ q = (tocs[0] >> 2) & 1;
ft = tocs[0] >> 3 ;
ft &= ~(1 << 5); /* Frame Type*/
} else {
/* BE */
- memcpy(shift_tocs, encoded_buf, 2);
+ memcpy(shift_tocs, encoded_buf, 2);
/* shift for BE */
switch_amr_array_lshift(4, shift_tocs, 2);
- not_last_frame = (shift_tocs[0] >> 7) & 1;
- q = (shift_tocs[0] >> 2) & 1;
+ not_last_frame = (shift_tocs[0] >> 7) & 1;
+ q = (shift_tocs[0] >> 2) & 1;
ft = shift_tocs[0] >> 3 ;
ft &= ~(1 << 5); /* Frame Type */
index = (shift_tocs[0] >> 3) & 0x0f;
framesz = switch_amr_frame_sizes[index];
}
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s (%s): FT: [0x%x] Q: [0x%x] Frame flag: [%d]\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s (%s): FT: [0x%x] Q: [0x%x] Frame flag: [%d]\n",
print_text, payload_format ? "OA":"BE", ft, q, not_last_frame);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s (%s): AMR encoded voice payload sz: [%d] : | encoded_data_len: [%d]\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s (%s): AMR encoded voice payload sz: [%d] : | encoded_data_len: [%d]\n",
print_text, payload_format ? "OA":"BE", framesz, encoded_data_len);
return SWITCH_TRUE;
memset(&codec_fmtp, '\0', sizeof(struct switch_codec_fmtp));
codec_fmtp.private_info = &amr_codec_settings;
- /* "mode" may mean two different things:
- * "Octed Aligned" or "Bandwidth Efficient" encoding mode ,
+ /* "mode" may mean two different things:
+ * "Octed Aligned" or "Bandwidth Efficient" encoding mode ,
* or the actual bitrate which is set with FMTP param "mode-set". */
/* https://tools.ietf.org/html/rfc4867 */
/* bitrate = value read from config file or default mode 7 */
context->enc_mode = globals.default_bitrate;
- /* set octet-align = 0 - it must be 0 by default when there is no "octet-align" param in FMTP, per RFC :
+ /* set octet-align = 0 - it must be 0 by default when there is no "octet-align" param in FMTP, per RFC :
*
* "octet-align: Permissible values are 0 and 1. If 1, octet-aligned
* operation SHALL be used. If 0 or if not present,
if (!strcasecmp(data, "octet-align")) {
if (atoi(arg)) {
switch_set_flag(context, AMR_OPT_OCTET_ALIGN);
- }
+ }
} else if (!strcasecmp(data, "mode-change-neighbor")) {
if (atoi(arg)) {
switch_set_flag(context, AMR_OPT_MODE_CHANGE_NEIGHBOR);
context->enc_mode);
} else {
/* some UEs reject the call with 488 if mode-change-capability is not 2 */
- switch_snprintf(fmtptmp, sizeof(fmtptmp), "octet-align=%d; mode-set=%d; max-red=0; mode-change-capability=2",
+ switch_snprintf(fmtptmp, sizeof(fmtptmp), "octet-align=%d; mode-set=%d; max-red=0; mode-change-capability=2",
switch_test_flag(context, AMR_OPT_OCTET_ALIGN) ? 1 : 0, context->enc_mode);
}
codec->fmtp_out = switch_core_strdup(codec->memory_pool, fmtptmp);
return SWITCH_STATUS_FALSE;
}
- /* set CMR + TOC (F + 3 bits of FT) , 1111 = CMR: No mode request */
- *(switch_byte_t *) encoded_data = 0xf0;
+ /* set CMR + TOC (F + 3 bits of FT) , 1111 = CMR: No mode request */
+ *(switch_byte_t *) encoded_data = 0xf0;
*encoded_data_len = n;
if (switch_test_flag(context, AMR_OPT_OCTET_ALIGN)) {
- /* this function does nothing for now - the payload is already OA
+ /* this function does nothing for now - the payload is already OA
as it comes out of the encoding function */
- switch_amr_pack_oa(shift_buf, n);
+ switch_amr_pack_oa(shift_buf, n);
*encoded_data_len = n + 1;
} else {
switch_amr_pack_be(shift_buf, n);
/* mode 1 = 103 speech bits -> 104 bytes - 1 padding bit */
/* mode 5 = 159 speech bits -> 160 bytes - 1 padding bit */
if ((context->enc_mode == 5 ) || (context->enc_mode == 1) || (context->enc_mode == 0)) {
- /* modes 0,1 and 5 have only 1 padding bit and due to shifting
+ /* modes 0,1 and 5 have only 1 padding bit and due to shifting
* we may have an extra 0 byte at the end of the voice payload (bit stuffing) */
if (shift_buf[n-1] != 0x0) {
*encoded_data_len = n + 1;
#else
struct amr_context *context = codec->private_info;
unsigned char *buf = encoded_data;
- uint8_t tmp[SWITCH_AMR_OUT_MAX_SIZE];
+ uint8_t tmp[SWITCH_AMR_OUT_MAX_SIZE];
if (!context) {
return SWITCH_STATUS_FALSE;
switch_amr_info(buf, encoded_data_len, switch_test_flag(context, AMR_OPT_OCTET_ALIGN) ? 1 : 0, "AMR decoder");
}
- if (switch_test_flag(context, AMR_OPT_OCTET_ALIGN)) {
+ if (switch_test_flag(context, AMR_OPT_OCTET_ALIGN)) {
/* Octed Aligned */
if (!switch_amr_unpack_oa(buf, tmp, encoded_data_len)) {
return SWITCH_STATUS_FALSE;
}
- } else {
+ } else {
/* Bandwidth Efficient */
if (!switch_amr_unpack_be(buf, tmp, encoded_data_len)) {
return SWITCH_STATUS_FALSE;
if (!strcasecmp(cmd, "increase")) {
if (context->enc_mode < SWITCH_AMR_MODES - 1) {
int mode_step = 2; /*this is the mode, not the actual bitrate*/
- context->enc_mode = context->enc_mode + mode_step;
+ context->enc_mode = context->enc_mode + mode_step;
if (globals.debug || context->debug) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
"AMR encoder: Adjusting mode to %d (increase)\n", context->enc_mode);
}
- }
+ }
} else if (!strcasecmp(cmd, "decrease")) {
if (context->enc_mode > 0) {
int mode_step = 2; /*this is the mode, not the actual bitrate*/
- context->enc_mode = context->enc_mode - mode_step;
+ context->enc_mode = context->enc_mode - mode_step;
if (globals.debug || context->debug) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
"AMR encoder: Adjusting mode to %d (decrease)\n", context->enc_mode);
}
}
} else if (!strcasecmp(cmd, "default")) {
context->enc_mode = globals.default_bitrate;
if (globals.debug || context->debug) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
"AMR encoder: Adjusting mode to %d (default)\n", context->enc_mode);
}
} else {
/*minimum bitrate (AMR mode)*/
context->enc_mode = 0;
if (globals.debug || context->debug) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
"AMR encoder: Adjusting mode to %d (minimum)\n", context->enc_mode);
}
}
break;
default:
break;
- }
-
+ }
+
return SWITCH_STATUS_SUCCESS;
#endif
}
static char *generate_fmtp(switch_memory_pool_t *pool , int octet_align)
-{
+{
char buf[256] = { 0 };
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "octet-align=%d; ", octet_align);
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "max-red=0; mode-change-capability=2; ");
}
-#endif
+#endif
if (end_of(buf) == ' ') {
*(end_of_p(buf) - 1) = '\0';
}
stream->write_function(stream, "AMR Debug: off\n");
} else {
stream->write_function(stream, "-USAGE: %s\n", AMRWB_DEBUG_SYNTAX);
- }
+ }
}
return SWITCH_STATUS_SUCCESS;
}
-#endif
+#endif
/* Registration */
SWITCH_MODULE_LOAD_FUNCTION(mod_amr_load)
switch_console_set_complete("add amr_debug on");
switch_console_set_complete("add amr_debug off");
-#endif
+#endif
SWITCH_ADD_CODEC(codec_interface, "AMR / Octet Aligned");
320, /* number of bytes per frame decompressed */
#ifndef AMR_PASSTHROUGH
SWITCH_AMR_OUT_MAX_SIZE, /* number of bytes per frame compressed */
-#else
+#else
0, /* number of bytes per frame compressed */
-#endif
+#endif
1, /* number of channels represented */
1, /* number of frames per network packet */
switch_amr_init, /* function to initialize a codec handle using this implementation */
320, /* number of bytes per frame decompressed */
#ifndef AMR_PASSTHROUGH
SWITCH_AMR_OUT_MAX_SIZE, /* number of bytes per frame compressed */
-#else
+#else
0, /* number of bytes per frame compressed */
-#endif
+#endif
1, /* number of channels represented */
1, /* number of frames per network packet */
switch_amr_init, /* function to initialize a codec handle using this implementation */
* Copyright (c) 2016, Athonet (www.athonet.com)
* Dragos Oancea <dragos.oancea@athonet.com>
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
- *
+ *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
/* https://tools.ietf.org/html/rfc4867#page-17 */
/* this works the same as in AMR NB*/
-extern switch_bool_t switch_amrwb_pack_be(unsigned char *shift_buf, int n)
+extern switch_bool_t switch_amrwb_pack_be(unsigned char *shift_buf, int n)
{
uint8_t save_toc, ft;
save_toc = shift_buf[1];
- /* we must convert OA TOC -> BE TOC */
+ /* we must convert OA TOC -> BE TOC */
/* OA TOC
0 1 2 3 4 5 6 7
+-+-+-+-+-+-+-+-+
+-+-+-+-+-+-+
|F| FT |Q|
+-+-+-+-+-+-+
- F = 0 , FT = XXXX , Q = 1
- eg: Frame Types (FT): ftp://www.3gpp.org/tsg_sa/TSG_SA/TSGS_04/Docs/PDF/SP-99253.pdf - table 1a
+ F = 0 , FT = XXXX , Q = 1
+ eg: Frame Types (FT): ftp://www.3gpp.org/tsg_sa/TSG_SA/TSGS_04/Docs/PDF/SP-99253.pdf - table 1a
*/
ft = save_toc >> 3 ; /* drop Q, P1, P2 */
shift_buf[1] |= 1 << 7;
} else {
/* reset last bit of TOC instead of P2 */
- shift_buf[1] &= ~(1 << 7);
+ shift_buf[1] &= ~(1 << 7);
}
return SWITCH_TRUE;
}
-extern switch_bool_t switch_amrwb_unpack_be(unsigned char *encoded_buf, uint8_t *tmp, int encoded_len)
+extern switch_bool_t switch_amrwb_unpack_be(unsigned char *encoded_buf, uint8_t *tmp, int encoded_len)
{
int framesz, index, ft;
uint8_t shift_tocs[2] = {0x00, 0x00};
uint8_t *shift_buf;
- memcpy(shift_tocs, encoded_buf, 2);
+ memcpy(shift_tocs, encoded_buf, 2);
/* shift for BE */
switch_amr_array_lshift(4, shift_tocs, 2);
ft = shift_tocs[0] >> 3;
return SWITCH_TRUE;
}
-#endif
+#endif
/* For Emacs:
* Local Variables:
* Copyright (c) 2016, Athonet (www.athonet.com)
* Dragos Oancea <dragos.oancea@athonet.com>
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
- *
+ *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
#define __AMRWB_BE_H__
/* Bandwidth Efficient AMR-WB */
-extern switch_bool_t switch_amrwb_pack_be(unsigned char *shift_buf, int n);
+extern switch_bool_t switch_amrwb_pack_be(unsigned char *shift_buf, int n);
extern switch_bool_t switch_amrwb_unpack_be(unsigned char *encoded_buf, uint8_t *tmp, int encoded_len);
-#endif
+#endif
/* For Emacs:
* Local Variables:
* Copyright (c) 2016, Athonet (www.athonet.com)
* Paolo Missiaggia <paolo.missiaggia@athonet.com>
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
- *
+ *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
buf[i] = ((buf[i] & first_byte) << lshift);
return (0);
}
-#endif
+#endif
/* For Emacs:
* Local Variables:
* Copyright (c) 2016, Athonet (www.athonet.com)
* Paolo Missiaggia <paolo.missiaggia@athonet.com>
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
- *
+ *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
*/
extern int switch_amr_array_lshift(uint8_t lshift, uint8_t *buf, int a_len);
-#endif
+#endif
/* For Emacs:
* Local Variables:
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Brian K. West <brian@freeswitch.org>
* Dragos Oancea <dragos.oancea@athonet.com>
}
tmp[0] = tocs[0];
memcpy(&tmp[1], buf, framesz);
-
+
return SWITCH_TRUE;
}
return SWITCH_TRUE;
}
-static switch_bool_t switch_amrwb_info(unsigned char *encoded_buf, int encoded_data_len, int payload_format, char *print_text)
+static switch_bool_t switch_amrwb_info(unsigned char *encoded_buf, int encoded_data_len, int payload_format, char *print_text)
{
uint8_t *tocs;
int framesz, index, not_last_frame, q, ft;
if (!encoded_buf) {
return SWITCH_FALSE;
}
-
+
/* payload format can be OA (octed-aligned) or BE (bandwidth efficient)*/
if (payload_format) {
/* OA */
encoded_buf++; /* CMR skip */
- tocs = encoded_buf;
+ tocs = encoded_buf;
index = (tocs[0] >> 3) & 0x0f;
if (index > SWITCH_AMRWB_MODES) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "AMRWB decoder (OA): Invalid TOC 0x%x\n", index);
return SWITCH_FALSE;
}
framesz = switch_amrwb_frame_sizes[index];
- not_last_frame = (tocs[0] >> 7) & 1;
- q = (tocs[0] >> 2) & 1;
+ not_last_frame = (tocs[0] >> 7) & 1;
+ q = (tocs[0] >> 2) & 1;
ft = tocs[0] >> 3;
ft &= ~(1 << 5); /* Frame Type */
} else {
/* BE */
- memcpy(shift_tocs, encoded_buf, 2);
+ memcpy(shift_tocs, encoded_buf, 2);
/* shift for BE */
switch_amr_array_lshift(4, shift_tocs, 2);
- not_last_frame = (shift_tocs[0] >> 7) & 1;
- q = (shift_tocs[0] >> 2) & 1;
+ not_last_frame = (shift_tocs[0] >> 7) & 1;
+ q = (shift_tocs[0] >> 2) & 1;
ft = shift_tocs[0] >> 3;
ft &= ~(1 << 5); /* Frame Type */
index = (shift_tocs[0] >> 3) & 0x0f;
framesz = switch_amrwb_frame_sizes[index];
}
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s (%s): FT: [0x%x] Q: [0x%x] Frame flag: [%d]\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s (%s): FT: [0x%x] Q: [0x%x] Frame flag: [%d]\n",
print_text, payload_format ? "OA":"BE", ft, q, not_last_frame);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s (%s): AMRWB encoded voice payload sz: [%d] : | encoded_data_len: [%d]\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s (%s): AMRWB encoded voice payload sz: [%d] : | encoded_data_len: [%d]\n",
print_text, payload_format ? "OA":"BE", framesz, encoded_data_len);
return SWITCH_TRUE;
-}
+}
#endif
static switch_status_t switch_amrwb_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings)
return SWITCH_STATUS_FALSE;
} else {
- /* "mode" may mean two different things:
- * "Octed Aligned" or "Bandwidth Efficient" encoding mode ,
+ /* "mode" may mean two different things:
+ * "Octed Aligned" or "Bandwidth Efficient" encoding mode ,
* or the actual bitrate which is set with FMTP param "mode-set". */
/* https://tools.ietf.org/html/rfc4867 */
}
if (!globals.volte) {
- switch_snprintf(fmtptmp, sizeof(fmtptmp), "octet-align=%d; mode-set=%d",
+ switch_snprintf(fmtptmp, sizeof(fmtptmp), "octet-align=%d; mode-set=%d",
switch_test_flag(context, AMRWB_OPT_OCTET_ALIGN) ? 1 : 0, context->enc_mode);
} else {
- switch_snprintf(fmtptmp, sizeof(fmtptmp), "octet-align=%d; mode-set=%d; max-red=0; mode-change-capability=2",
+ switch_snprintf(fmtptmp, sizeof(fmtptmp), "octet-align=%d; mode-set=%d; max-red=0; mode-change-capability=2",
switch_test_flag(context, AMRWB_OPT_OCTET_ALIGN) ? 1 : 0, context->enc_mode);
}
codec->fmtp_out = switch_core_strdup(codec->memory_pool, fmtptmp);
return SWITCH_STATUS_FALSE;
}
- /* set CMR + TOC (F + 3 bits of FT), 1111 = CMR: No mode request */
+ /* set CMR + TOC (F + 3 bits of FT), 1111 = CMR: No mode request */
*(switch_byte_t *) encoded_data = 0xf0;
*encoded_data_len = n;
if (switch_test_flag(context, AMRWB_OPT_OCTET_ALIGN)) {
- switch_amrwb_pack_oa(shift_buf, n); /* the payload is OA as it
+ switch_amrwb_pack_oa(shift_buf, n); /* the payload is OA as it
comes out of the encoding function */
*encoded_data_len = n + 1;
} else {
#else
struct amrwb_context *context = codec->private_info;
unsigned char *buf = encoded_data;
- uint8_t tmp[SWITCH_AMRWB_OUT_MAX_SIZE];
+ uint8_t tmp[SWITCH_AMRWB_OUT_MAX_SIZE];
if (!context) {
return SWITCH_STATUS_FALSE;
switch_amrwb_info(buf, encoded_data_len, switch_test_flag(context, AMRWB_OPT_OCTET_ALIGN) ? 1 : 0, "AMRWB decoder");
}
- if (switch_test_flag(context, AMRWB_OPT_OCTET_ALIGN)) {
+ if (switch_test_flag(context, AMRWB_OPT_OCTET_ALIGN)) {
/* Octed Aligned */
if (!switch_amrwb_unpack_oa(buf, tmp, encoded_data_len)) {
return SWITCH_STATUS_FALSE;
}
- } else {
+ } else {
/* Bandwidth Efficient */
if (!switch_amrwb_unpack_be(buf, tmp, encoded_data_len)) {
return SWITCH_STATUS_FALSE;
if (!strcasecmp(cmd, "increase")) {
if (context->enc_mode < SWITCH_AMRWB_MODES - 1) {
int mode_step = 2; /*this is the mode, not the actual bitrate*/
- context->enc_mode = context->enc_mode + mode_step;
+ context->enc_mode = context->enc_mode + mode_step;
if (globals.debug || context->debug) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
"AMRWB encoder: Adjusting mode to %d (increase)\n", context->enc_mode);
}
- }
+ }
} else if (!strcasecmp(cmd, "decrease")) {
if (context->enc_mode > 0) {
int mode_step = 2; /*this is the mode, not the actual bitrate*/
- context->enc_mode = context->enc_mode - mode_step;
+ context->enc_mode = context->enc_mode - mode_step;
if (globals.debug || context->debug) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
"AMRWB encoder: Adjusting mode to %d (decrease)\n", context->enc_mode);
}
}
} else if (!strcasecmp(cmd, "default")) {
context->enc_mode = globals.default_bitrate;
if (globals.debug || context->debug) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
"AMRWB encoder: Adjusting mode to %d (default)\n", context->enc_mode);
}
} else {
/*minimum bitrate (AMRWB mode)*/
context->enc_mode = 0;
if (globals.debug || context->debug) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
"AMRWB encoder: Adjusting mode to %d (minimum)\n", context->enc_mode);
}
}
break;
default:
break;
- }
-
+ }
+
return SWITCH_STATUS_SUCCESS;
}
-#endif
+#endif
static char *generate_fmtp(switch_memory_pool_t *pool , int octet_align)
-{
+{
char buf[256] = { 0 };
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "octet-align=%d; ", octet_align);
switch_console_set_complete("add amrwb_debug off");
#else
#define SWITCH_AMRWB_OUT_MAX_SIZE 0
-#endif
+#endif
SWITCH_ADD_CODEC(codec_interface, "AMR-WB / Octet Aligned");
default_fmtp_oa = generate_fmtp(pool, 1);
switch_core_codec_add_implementation(pool, codec_interface,
- SWITCH_CODEC_TYPE_AUDIO, 100, "AMR-WB", default_fmtp_oa,
+ SWITCH_CODEC_TYPE_AUDIO, 100, "AMR-WB", default_fmtp_oa,
16000, 16000, 23850, 20000, 320, 640, SWITCH_AMRWB_OUT_MAX_SIZE, 1, 1,
switch_amrwb_init, switch_amrwb_encode, switch_amrwb_decode, switch_amrwb_destroy);
#ifndef AMRWB_PASSTHROUGH
codec_interface->implementations->codec_control = switch_amrwb_control;
-#endif
+#endif
SWITCH_ADD_CODEC(codec_interface, "AMR-WB / Bandwidth Efficient");
default_fmtp_be = generate_fmtp(pool, 0);
switch_core_codec_add_implementation(pool, codec_interface,
- SWITCH_CODEC_TYPE_AUDIO, 110, "AMR-WB", default_fmtp_be,
- 16000, 16000, 23850, 20000, 320, 640, SWITCH_AMRWB_OUT_MAX_SIZE, 1, 1,
+ SWITCH_CODEC_TYPE_AUDIO, 110, "AMR-WB", default_fmtp_be,
+ 16000, 16000, 23850, 20000, 320, 640, SWITCH_AMRWB_OUT_MAX_SIZE, 1, 1,
switch_amrwb_init, switch_amrwb_encode, switch_amrwb_decode, switch_amrwb_destroy);
#ifndef AMRWB_PASSTHROUGH
codec_interface->implementations->codec_control = switch_amrwb_control;
-#endif
+#endif
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Brian K. West <brian@freeswitch.org>
*
* mod_b64.c -- The B64 ultra-low delay audio codec (http://www.b64-codec.org/)
{
int r = 0;
int c;
-
+
if (*p >= min && *p <= max) {
if ((c = *p + i) <= max) {
*p = c;
p += HLEN;
encoded_data = p;
encoded_data_len -= HLEN;
-
+
rot13_buffer(encoded_data, encoded_data_len);
switch_b64_decode(encoded_data, decoded_data, *decoded_data_len);
*decoded_data_len = codec->implementation->decoded_bytes_per_packet;
switch_codec_b64_encode, /* function to encode raw data into encoded data */
switch_codec_b64_decode, /* function to decode encoded data into raw data */
switch_codec_b64_destroy); /* deinitalize a codec handle using this implementation */
-
+
bytes *= 2;
samples *= 2;
rate *= 2;
bits *= 2;
-
+
}
-
+
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Brian K. West <brian@freeswitch.org>
*
* mod_bv.c -- BroadVoice16 and BroadVoice32 audio codecs (http://www.broadcom.com/support/broadvoice/)
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
#include <switch.h>
#include <codec2.h>
-/* Uncomment to log input/output data for debugging
-#define LOG_DATA
+/* Uncomment to log input/output data for debugging
+#define LOG_DATA
#define CODEC2_DEBUG
*/
#ifdef CODEC2_DEBUG
#define codec2_assert(_x) switch_assert(_x)
#else
-#define codec2_assert(_x)
+#define codec2_assert(_x)
#endif
SWITCH_MODULE_LOAD_FUNCTION(mod_codec2_load);
int nbit; /* nr of bits per frame */
int nbyte; /* nr of bytes per frame */
int nsam; /* nr of samples per frame */
-#ifdef LOG_DATA
+#ifdef LOG_DATA
FILE *encoder_in;
FILE *encoder_out;
FILE *encoder_out_unpacked;
} else {
/* 3200 might be better for VOIP, but forcing 2400 for backwards compatibility */
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mode not supported, forcing CODEC2_MODE_2400. You can try mode 3200 too!\n");
- context->mode = CODEC2_MODE_2400;
+ context->mode = CODEC2_MODE_2400;
}
-
+
if (encoding) {
context->encoder = codec2_create(context->mode);
}
-
+
if (decoding) {
context->decoder = codec2_create(context->mode);
}
context->nbyte = (context->nbit + 7) / 8;
codec->private_info = context;
-
-#ifdef LOG_DATA
+
+#ifdef LOG_DATA
{
-
+
int c = c2_count++;
char buf[1024];
-
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Logging as /tmp/c2-%d-*\n", c);
-
+
if (encoding) {
snprintf(buf, sizeof(buf), "/tmp/c2-%d-enc-in", c);
context->encoder_in = fopen(buf, "w");
-
+
snprintf(buf, sizeof(buf), "/tmp/c2-%d-enc-out", c);
context->encoder_out = fopen(buf, "w");
-
+
snprintf(buf, sizeof(buf), "/tmp/c2-%d-enc-out-unpacked", c);
context->encoder_out_unpacked = fopen(buf, "w");
}
if (decoding) {
snprintf(buf, sizeof(buf), "/tmp/c2-%d-dec-in", c);
context->decoder_in = fopen(buf, "w");
-
+
snprintf(buf, sizeof(buf), "/tmp/c2-%d-dec-out", c);
context->decoder_out = fopen(buf, "w");
-
+
snprintf(buf, sizeof(buf), "/tmp/c2-%d-dec-out-unpacked", c);
context->decoder_in_unpacked = fopen(buf, "w");
}
unsigned int *flag)
{
struct codec2_context *context = codec->private_info;
-
+
codec2_assert(decoded_data_len == context->nsam * 2);
-
-#ifdef LOG_DATA
+
+#ifdef LOG_DATA
fwrite(decoded_data, decoded_data_len, 1, context->encoder_in);
fflush(context->encoder_in);
#endif
codec2_encode(context->encoder, encoded_data, decoded_data);
-
-#ifdef LOG_DATA
+
+#ifdef LOG_DATA
fwrite(encode_buf, sizeof(encode_buf), 1, context->encoder_out_unpacked);
fflush(context->encoder_out_unpacked);
fwrite(encoded_data, context->nbyte, 1, context->encoder_out);
fflush(context->encoder_out);
#endif
-
+
*encoded_data_len = context->nbyte;
return SWITCH_STATUS_SUCCESS;
unsigned int *flag)
{
struct codec2_context *context = codec->private_info;
-
+
codec2_assert(encoded_data_len == 8);
-
-#ifdef LOG_DATA
+
+#ifdef LOG_DATA
fwrite(encoded_data, encoded_data_len, 1, context->decoder_in);
fflush(context->decoder_in);
fwrite(bits, sizeof(bits), 1, context->decoder_in_unpacked);
fflush(context->decoder_in_unpacked);
#endif
-
+
codec2_decode(context->decoder, decoded_data, encoded_data);
-#ifdef LOG_DATA
+#ifdef LOG_DATA
fwrite(decoded_data, context->nsam, 2, context->decoder_out);
fflush(context->decoder_out);
#endif
*decoded_data_len = context->nsam * 2; /* eg: 160 samples for 3200,2400 */
-
+
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t switch_codec2_destroy(switch_codec_t *codec)
{
struct codec2_context *context = codec->private_info;
-
+
codec2_destroy(context->encoder);
codec2_destroy(context->decoder);
switch_xml_t cfg, xml = NULL, param, settings;
switch_status_t status = SWITCH_STATUS_SUCCESS;
- codec2_prefs.mode = 2400 ;
+ codec2_prefs.mode = 2400 ;
if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Opening of %s failed\n", cf);
}
}
}
-
+
if (xml) {
switch_xml_free(xml);
}
}
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
-
+
/*there is no API call to retrieve ptime per mode, so hardcoding here*/
if ((codec2_prefs.mode == 3200) ||(codec2_prefs.mode == 2400)) {
codec2_prefs.ptime = 20000;
- codec2_prefs.samples_per_frame = CODEC2_SAMPLES_PER_FRAME;
+ codec2_prefs.samples_per_frame = CODEC2_SAMPLES_PER_FRAME;
} else {
codec2_prefs.ptime = 40000;
- codec2_prefs.samples_per_frame = CODEC2_SAMPLES_PER_FRAME * 2;
+ codec2_prefs.samples_per_frame = CODEC2_SAMPLES_PER_FRAME * 2;
}
SWITCH_ADD_CODEC(codec_interface, "CODEC2 3200/2400/1400/1200bps");
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
/*
* some rules to keep in mind for G729 (the frame size may be different for G723)
- * we cannot write more than SFRAME_SIZE (320) - sizeof(struct rtp_packet) which
+ * we cannot write more than SFRAME_SIZE (320) - sizeof(struct rtp_packet) which
* seems to be 266 bytes
* if we write less than 160 bytes (1 ulaw frame which is 20 bytes of G729 bytes, a read will block forever)
* TODO: do buffering ourselves to provide just the fixed amount of samples that the card expects
static uint32_t total_decoders = 0;
static uint32_t total_decoders_usage = 0;
-/*
+/*
Zaptel/DAHDI definitions to not require the headers installed
Zaptel and DAHDI are binary compatible (at least in the transcoder interface)
*/
if (fcntl(fd, F_SETFL, fdflags)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not set non-block mode in %s transcoder FD: %s\n",
transcoder_name, strerror(errno));
- /* should we abort? this may cause channels to hangup when overruning the device
+ /* should we abort? this may cause channels to hangup when overruning the device
* see jira dahdi codec issue MODCODEC-8 (Hung Calls and Codec DAHDI G.729A 8.0k decoder error!)
* */
}
context->encoding_fd = -1;
context->decoding_fd = -1;
- /* ulaw requires 8 times more storage than g729 and 12 times more than G723, right?
+ /* ulaw requires 8 times more storage than g729 and 12 times more than G723, right?
* this can be used to calculate the target buffer when encoding and decoding
* */
context->codec_r = (codec->implementation->ianacode == CODEC_G729_IANA_CODE)
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Brian K. West <brian@freeswitch.org>
*
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Michael Jerris <mike@jerris.com>
*
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Brian K. West <brian@freeswitch.org>
*
* mod_ilbc.c -- ilbc Codec Module
{
if(index > 11)
{
- index -= 12;
+ index -= 12;
/* compute the jitter estimate as decoded on the other side */
bwest_str->send_max_delay_avg = 0.9f * bwest_str->send_max_delay_avg +
0.1f * (float)MAX_ISAC_MD;
"r"(wri), "r"(frfi_r), "r"(CFFTRND));
__asm__("smladx %0, %1, %2, %3" : "=r"(ti32) :
"r"(wri), "r"(frfi_r), "r"(CFFTRND));
-
+
#else
tr32 = WEBRTC_SPL_MUL_16_16(wr, frfi[2 * j])
- WEBRTC_SPL_MUL_16_16(wi, frfi[2 * j + 1]) + CFFTRND;
seq2Ptr = seq2 + (step_seq2 * i);
(*CrossCorrPtr) = 0;
-#ifndef _ARM_OPT_
+#ifndef _ARM_OPT_
#ifdef _WIN32
#pragma message("NOTE: default implementation is used")
#endif
WebRtcIsac_GetLpcGain(s2nr, percepFilterParams, SUBFRAMES, lpcGains,
corr, varscale);
-
+
/* Store the state of arithmetic coder before coding LPC gains */
transcodingParam.W_upper = ISACencUB_obj->bitstr_obj.W_upper;
* WebRtcIsac_AddLarMean()
*
* This is the inverse of WebRtcIsac_RemoveLarMean()
- *
+ *
* Input:
* -data : pointer to mean-removed LAR:s.
* -bandwidth : indicates if the given LAR vectors belong
* WebRtcIsac_QuantizeLpcGain()
*
* Quantize the decorrelated log-domain gains.
- *
+ *
* Input:
* -lpcGain : uncorrelated LPC gains.
*
{
max_factors = (int)nSpan;
}
- if ((int)nSpan > max_perm)
+ if ((int)nSpan > max_perm)
{
max_perm = (int)nSpan;
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
codec->private_info = context;
err = WebRtcIsac_Create(&context->ISAC_main_inst);
-
+
if (err < 0) return SWITCH_STATUS_FALSE;
return SWITCH_STATUS_FALSE;
}
}
-
-
+
+
if (WebRtcIsac_SetMaxRate(context->ISAC_main_inst, codec->implementation->bits_per_second) < 0) {
return SWITCH_STATUS_FALSE;
}
len = WebRtcIsac_Encode(context->ISAC_main_inst, in, out);
in += rise;
}
-
+
if (len < 0) {
return SWITCH_STATUS_GENERR;
}
*encoded_data_len = (uint32_t) len;
-
+
return SWITCH_STATUS_SUCCESS;
}
*decoded_data_len = 0;
return SWITCH_STATUS_GENERR;
}
-
+
*decoded_data_len = (uint32_t) len * 2;
-
+
return SWITCH_STATUS_SUCCESS;
}
struct isac_context *context = codec->private_info;
WebRtcIsac_Free(context->ISAC_main_inst);
-
+
return SWITCH_STATUS_SUCCESS;
}
SWITCH_ADD_CODEC(codec_interface, "isac"); /* 8.0kbit */
- switch_core_codec_add_implementation(pool, codec_interface,
+ switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO,
- 99,
+ 99,
"isac",
- "ibitrate=32000;maxbitrate=53400",
- 16000,
- 16000,
- 53400,
- 30000,
- 480,
- 960,
- 0,
- 1,
- 3,
- switch_isac_init,
+ "ibitrate=32000;maxbitrate=53400",
+ 16000,
+ 16000,
+ 53400,
+ 30000,
+ 480,
+ 960,
+ 0,
+ 1,
+ 3,
+ switch_isac_init,
switch_isac_encode,
switch_isac_decode,
switch_isac_destroy);
- switch_core_codec_add_implementation(pool, codec_interface,
+ switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO,
- 99,
+ 99,
"isac",
- "ibitrate=32000;maxbitrate=53400",
- 16000,
- 16000,
- 53400,
- 60000,
- 960,
- 1920,
- 0,
- 1,
- 6,
- switch_isac_init,
+ "ibitrate=32000;maxbitrate=53400",
+ 16000,
+ 16000,
+ 53400,
+ 60000,
+ 960,
+ 1920,
+ 0,
+ 1,
+ 6,
+ switch_isac_init,
switch_isac_encode,
switch_isac_decode,
switch_isac_destroy);
-
- switch_core_codec_add_implementation(pool, codec_interface,
+
+ switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO,
- 99,
+ 99,
"isac",
- "ibitrate=32000;maxbitrate=160000",
- 32000,
- 32000,
- 160000,
- 30000,
- 960,
- 1920,
- 0,
- 1,
- 6,
- switch_isac_init,
+ "ibitrate=32000;maxbitrate=160000",
+ 32000,
+ 32000,
+ 160000,
+ 30000,
+ 960,
+ 1920,
+ 0,
+ 1,
+ 6,
+ switch_isac_init,
switch_isac_encode,
switch_isac_decode,
switch_isac_destroy);
- switch_core_codec_add_implementation(pool, codec_interface,
+ switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO,
- 99,
+ 99,
"isac",
- "ibitrate=32000;maxbitrate=160000",
- 32000,
- 32000,
- 160000,
- 60000,
- 1920,
- 3840,
- 0,
- 1,
- 6,
- switch_isac_init,
+ "ibitrate=32000;maxbitrate=160000",
+ 32000,
+ 32000,
+ 160000,
+ 60000,
+ 1920,
+ 3840,
+ 0,
+ 1,
+ 6,
+ switch_isac_init,
switch_isac_encode,
switch_isac_decode,
switch_isac_destroy);
-
-
+
+
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}
// Return: Return: state + (((diff << 1) * tbl_value) >> 32)
//
// The reason to introduce this function is that, in case we can't use smlawb
-// instruction (in MUL_ACCUM_1) due to input value range, we can still use
+// instruction (in MUL_ACCUM_1) due to input value range, we can still use
// smmla to save some cycles.
static __inline WebRtc_Word32 MUL_ACCUM_2(WebRtc_Word32 tbl_value,
// WebRtc_Word16 WebRtcSpl_SatW32ToW16(...)
//
// This function saturates a 32-bit word into a 16-bit word.
-//
+//
// Input:
// - value32 : The value of a 32-bit word.
//
//
// This function multiply a 16-bit word by a 16-bit word, and accumulate this
// value to a 32-bit integer.
-//
+//
// Input:
// - a : The value of the first 16-bit word.
// - b : The value of the second 16-bit word.
/*
* spectrum_ar_model_tables.h
*
- * This file contains definitions of tables with AR coefficients,
+ * This file contains definitions of tables with AR coefficients,
* Gain coefficients and cosine tables.
*
*/
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
int FillSpecificParameters(h264_codec_context_t *context) {
int sane = 0;
SEncParamExt *param;
-
+
param = &context->encoder_params;
if (!context->codec_settings.video.width) {
/* hack for phones sending sps/pps with frame->m = 1 such as grandstream */
if ((nalu_type == 7 || nalu_type == 8) && frame->m) frame->m = SWITCH_FALSE;
-
+
if (nalu_type == 28) { // 0x1c FU-A
int start = *(data + 1) & 0x80;
int end = *(data + 1) & 0x40;
-
+
nalu_type = *(data + 1) & 0x1f;
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "WTF start:%d end:%d mark:%d\n", start, end, frame->m);
return status;
}
-static switch_status_t switch_h264_control(switch_codec_t *codec,
- switch_codec_control_command_t cmd,
+static switch_status_t switch_h264_control(switch_codec_t *codec,
+ switch_codec_control_command_t cmd,
switch_codec_control_type_t ctype,
void *cmd_data,
switch_codec_control_type_t atype,
switch(cmd) {
case SCC_VIDEO_GEN_KEYFRAME:
- context->need_key_frame = 1;
+ context->need_key_frame = 1;
break;
case SCC_VIDEO_BANDWIDTH:
{
opus_encoder_ctl(encoder_object, OPUS_SET_MAX_BANDWIDTH(OPUS_BANDWIDTH_SUPERWIDEBAND));
opus_encoder_ctl(encoder_object, OPUS_SET_SIGNAL(OPUS_AUTO));
return OPUS_BANDWIDTH_SUPERWIDEBAND;
- }
+ }
/* Audio Bandwidth: 0-20000Hz Sampling Rate: 48000Hz */
opus_encoder_ctl(encoder_object, OPUS_SET_BANDWIDTH(OPUS_AUTO));
opus_encoder_ctl(encoder_object, OPUS_SET_MAX_BANDWIDTH(OPUS_BANDWIDTH_FULLBAND));
}
-static switch_bool_t switch_opus_has_fec(const uint8_t* payload,int payload_length_bytes)
+static switch_bool_t switch_opus_has_fec(const uint8_t* payload,int payload_length_bytes)
{
/* nb_silk_frames: number of silk-frames (10 or 20 ms) in an opus frame: 0, 1, 2 or 3 */
/* computed from the 5 MSB (configuration) of the TOC byte (payload[0]) */
/* p0p1 = 1 or 2 => nb_opus_frames = 2 */
/* p0p1 = 3 => given by the 6 LSB of payload[1] */
- int nb_silk_frames, nb_opus_frames, n, i;
+ int nb_silk_frames, nb_opus_frames, n, i;
opus_int16 frame_sizes[48];
const unsigned char *frame_data[48];
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "corrupted packet (invalid size)\n");
return SWITCH_FALSE;
}
- if (payload[0] & 0x80) {
+ if (payload[0] & 0x80) {
/* this scares users and its harmless so commenting it */
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "FEC in CELT_ONLY mode ?!\n");
return SWITCH_FALSE;
}
-
+
if ((nb_opus_frames = opus_packet_parse(payload, payload_length_bytes, NULL, frame_data, frame_sizes, NULL)) <= 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "OPUS_INVALID_PACKET ! nb_opus_frames: %d\n", nb_opus_frames);
return SWITCH_FALSE;
if(nb_silk_frames == 0) {
nb_silk_frames = 1;
}
- if ((nb_silk_frames == 1) && (nb_opus_frames == 1)) {
+ if ((nb_silk_frames == 1) && (nb_opus_frames == 1)) {
for (n = 0; n <= (payload[0]&0x4) ; n++) { /* mono or stereo: 10,20 ms */
if (frame_data[0][0] & (0x80 >> ((n + 1) * (nb_silk_frames + 1) - 1))) {
return SWITCH_TRUE; /* frame has FEC */
for (i=0 ; i < nb_opus_frames; i++ ) { /* only mono Opus frames */
LBRR_flag = (frame_data[i][0] >> (7 - nb_silk_frames)) & 0x1;
if (LBRR_flag) {
- return SWITCH_TRUE; /* one of the silk frames has FEC */
+ return SWITCH_TRUE; /* one of the silk frames has FEC */
}
}
}
if (loss <= 0){
return SWITCH_STATUS_FALSE;
- }
+ }
if (fs == 8000) {
- if (loss >=25) {
+ if (loss >=25) {
return threshold_bitrates[24];
} else {
return threshold_bitrates[loss-1];
}
}
- return SWITCH_STATUS_FALSE ;
+ return SWITCH_STATUS_FALSE ;
}
static switch_status_t switch_opus_info(void * encoded_data, uint32_t len, uint32_t samples_per_second, char *print_text)
nb_channels = opus_packet_get_nb_channels(payload);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s: opus_frames [%d] samples [%d] audio bandwidth [%s] bytes [%d] FEC[%s] channels[%d]\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s: opus_frames [%d] samples [%d] audio bandwidth [%s] bytes [%d] FEC[%s] channels[%d]\n",
print_text, nb_opus_frames, nb_samples, audiobandwidth_str, len, has_fec ? "yes" : "no", nb_channels);
return SWITCH_STATUS_SUCCESS;
-}
+}
static switch_status_t switch_opus_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings)
{
}
/* https://tools.ietf.org/html/rfc7587 */
- if (opus_codec_settings.maxaveragebitrate) {
+ if (opus_codec_settings.maxaveragebitrate) {
opus_encoder_ctl(context->encoder_object, OPUS_SET_BITRATE(opus_codec_settings.maxaveragebitrate));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Opus encoder: set bitrate based on maxaveragebitrate value found in SDP or local config [%dbps]\n", opus_codec_settings.maxaveragebitrate);
} else {
opus_encoder_ctl(context->encoder_object, OPUS_SET_BANDWIDTH(OPUS_AUTO));
opus_encoder_ctl(context->encoder_object, OPUS_SET_BITRATE(bitrate_bps)); /* OPUS_AUTO */
- opus_encoder_ctl(context->encoder_object, OPUS_GET_BITRATE(&bitrate_bps)); /* return average bps for this audio bandwidth */
+ opus_encoder_ctl(context->encoder_object, OPUS_GET_BITRATE(&bitrate_bps)); /* return average bps for this audio bandwidth */
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Opus encoder: set bitrate to local settings [%dbps]\n", bitrate_bps);
}
/* Another fmtp setting from https://tools.ietf.org/html/rfc7587 - "RTP Payload Format for the Opus Speech and Audio Codec" */
if (opus_codec_settings.maxplaybackrate) {
- opus_int32 audiobandwidth;
+ opus_int32 audiobandwidth;
char audiobandwidth_str[32] = {0};
audiobandwidth = switch_opus_encoder_set_audio_bandwidth(context->encoder_object,opus_codec_settings.maxplaybackrate);
if (opus_codec_settings.useinbandfec) {
/* FEC on the encoder: start the call with a preconfigured packet loss percentage */
int fec_bitrate = opus_codec_settings.maxaveragebitrate;
- int loss_percent = opus_prefs.plpct ;
+ int loss_percent = opus_prefs.plpct ;
opus_encoder_ctl(context->encoder_object, OPUS_SET_INBAND_FEC(opus_codec_settings.useinbandfec));
opus_encoder_ctl(context->encoder_object, OPUS_SET_PACKET_LOSS_PERC(loss_percent));
- if (opus_prefs.keep_fec){
- fec_bitrate = switch_opus_get_fec_bitrate(enc_samplerate,loss_percent);
+ if (opus_prefs.keep_fec){
+ fec_bitrate = switch_opus_get_fec_bitrate(enc_samplerate,loss_percent);
/* keep a bitrate for which the encoder will always add FEC */
if (fec_bitrate != SWITCH_STATUS_FALSE) {
- opus_encoder_ctl(context->encoder_object, OPUS_SET_BITRATE(fec_bitrate));
- /* will override the maxaveragebitrate set in opus.conf.xml */
+ opus_encoder_ctl(context->encoder_object, OPUS_SET_BITRATE(fec_bitrate));
+ /* will override the maxaveragebitrate set in opus.conf.xml */
opus_codec_settings.maxaveragebitrate = fec_bitrate;
}
context->control_state.keep_fec = opus_prefs.keep_fec;
if (context->decoder_object) {
switch_core_session_t *session = codec->session;
if (session) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,"Opus decoder stats: Frames[%d] PLC[%d] FEC[%d]\n",
- context->decoder_stats.frame_counter, context->decoder_stats.plc_counter-context->decoder_stats.fec_counter, context->decoder_stats.fec_counter);
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,"Opus decoder stats: Frames[%d] PLC[%d] FEC[%d]\n",
+ context->decoder_stats.frame_counter, context->decoder_stats.plc_counter-context->decoder_stats.fec_counter, context->decoder_stats.fec_counter);
}
opus_decoder_destroy(context->decoder_object);
context->decoder_object = NULL;
frame.data = buf;
frame.buflen = sizeof(buf);
-
+
if (globals.debug || context->debug) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Missing %s %u Checking JB\n", seq ? "SEQ" : "TS", seq ? seq : ts);
}
-
+
if (switch_jb_peek_frame(jb, ts, seq, 1, &frame) == SWITCH_STATUS_SUCCESS) {
if (globals.debug || context->debug) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Lookahead frame found: %u:%u\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Lookahead frame found: %u:%u\n",
frame.timestamp, frame.seq);
}
-
+
if ((fec = switch_opus_has_fec(frame.data, frame.datalen))) {
encoded_data = frame.data;
encoded_data_len = frame.datalen;
}
-
+
if (globals.debug || context->debug) {
if (fec) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "FEC info available in packet with SEQ: %d LEN: %d\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "FEC info available in packet with SEQ: %d LEN: %d\n",
frame.seq, frame.datalen);
} else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "NO FEC info in this packet with SEQ: %d LEN: %d\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "NO FEC info in this packet with SEQ: %d LEN: %d\n",
frame.seq, frame.datalen);
}
}
}
}
}
-
+
opus_decoder_ctl(context->decoder_object, OPUS_GET_LAST_PACKET_DURATION(&last_frame_size));
if (last_frame_size) frame_size = last_frame_size;
-
+
if (globals.debug || context->debug) {
if (opus_prefs.use_jb_lookahead || context->use_jb_lookahead) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "MISSING FRAME: %s\n", fec ? "Look-ahead FEC" : "PLC");
if (globals.debug || context->debug > 1) {
int samplerate = context->dec_frame_size * 1000 / (codec->implementation->microseconds_per_packet / 1000);
switch_opus_info(encoded_data, encoded_data_len,
- samplerate ? samplerate : codec->implementation->actual_samples_per_second,
+ samplerate ? samplerate : codec->implementation->actual_samples_per_second,
!encoded_data ? "PLC correction" : fec ? "FEC correction" : "decode");
}
opus_int32 ret = 0;
opus_int32 total_len = 0;
switch_status_t status = SWITCH_STATUS_SUCCESS;
-
+
if (!context) {
switch_goto_status(SWITCH_STATUS_FALSE, end);
}
dec_ptr_buf = (int16_t *)decoded_data;
for (i = 0; i < nb_frames; i++) {
/* set inband FEC ON or OFF for the next Opus frame */
- if (i == (nb_frames - 1) && want_fec) {
- /* When FEC is enabled for Opus frame N, LBRR is stored during regular encoding of */
+ if (i == (nb_frames - 1) && want_fec) {
+ /* When FEC is enabled for Opus frame N, LBRR is stored during regular encoding of */
/* this Opus frame N, and this LBRR data will be packed with the regular encoding */
/* data of Opus frame N+1. We enable FEC on our last Opus frame which is to be packed, just */
/* to actually have it stored in the first Opus frame, that is when switch_opus_encode_repacketize() */
- /* is called again to pack the next big 80,100 or 120 ms frame. */
+ /* is called again to pack the next big 80,100 or 120 ms frame. */
toggle_fec = 1; /* FEC ON for the last frame */
}
}
}
if (opus_prefs.adjust_bitrate) {
- /* make bitrate adjust the step , but keep it as a multiple of 400 (see OpusFAQ).
+ /* make bitrate adjust the step , but keep it as a multiple of 400 (see OpusFAQ).
* usual RTCP interval is 5 seconds which is long time - the step should be bigger. */
- /* step's value should depend on packet loss too, to decrease more abrubtly
+ /* step's value should depend on packet loss too, to decrease more abrubtly
* at high packet loss. */
int base_step = 400; /*bps*/
int range = context->codec_settings.maxaveragebitrate - SWITCH_OPUS_MIN_BITRATE;
float steps = (float)((float)(range / 100) / base_step);
- int br_step = (int)(round(steps) * base_step) * plpct;
+ int br_step = (int)(round(steps) * base_step) * plpct;
if (globals.debug || context->debug) {
- switch_log_printf(SWITCH_CHANNEL_LOG,
- SWITCH_LOG_DEBUG, "Opus encoder: bitrate increase/decrease step now is: %d bps, range:%d\n", br_step, range);
+ switch_log_printf(SWITCH_CHANNEL_LOG,
+ SWITCH_LOG_DEBUG, "Opus encoder: bitrate increase/decrease step now is: %d bps, range:%d\n", br_step, range);
}
- context->control_state.increase_step = context->control_state.decrease_step = br_step;
+ context->control_state.increase_step = context->control_state.decrease_step = br_step;
}
context->old_plpct = plpct;
}
opus_int32 current_bitrate=context->control_state.current_bitrate;
if (!strcasecmp(cmd, "increase")) {
/* https://wiki.xiph.org/OpusFAQ
- "[...]Opus scales from about 6 to 512 kb/s, in increments of 0.4 kb/s (one byte with 20 ms frames).
+ "[...]Opus scales from about 6 to 512 kb/s, in increments of 0.4 kb/s (one byte with 20 ms frames).
Opus can have more than 1200 possible bitrates[...]" */
int br_step = context->control_state.increase_step?context->control_state.increase_step:400;
opus_encoder_ctl(context->encoder_object, OPUS_GET_BITRATE(¤t_bitrate));
opus_encoder_ctl(context->encoder_object, OPUS_SET_BITRATE(current_bitrate+br_step));
if ((context->control_state.keep_fec) && (current_bitrate > SWITCH_OPUS_MIN_FEC_BITRATE)) {
opus_prefs.keep_fec = 1; /* enable back FEC if it was disabled by SCC_AUDIO_ADJUST_BITRATE, we have enough network bandwidth now */
- }
+ }
if (globals.debug || context->debug) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Opus encoder: Adjusting bitrate to %d (increase)\n", current_bitrate+br_step);
}
opus_encoder_ctl(context->encoder_object, OPUS_GET_BITRATE(¤t_bitrate));
if (current_bitrate > SWITCH_OPUS_MIN_BITRATE) {
if (context->control_state.keep_fec) {
- /* no point to try to keep FEC enabled anymore,
+ /* no point to try to keep FEC enabled anymore,
* we're low on network bandwidth (that's why we ended up here) */
opus_prefs.keep_fec = 0;
}
opus_encoder_ctl(context->encoder_object, OPUS_SET_BITRATE(opus_prefs.maxaveragebitrate));
if (context->control_state.keep_fec) {
opus_prefs.keep_fec = 1; /* enable back FEC, we have enough network bandwidth now */
- }
+ }
if (globals.debug || context->debug) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Opus encoder: Adjusting bitrate to %d (configured maxaveragebitrate)\n", opus_prefs.maxaveragebitrate);
}
opus_encoder_ctl(context->encoder_object, OPUS_SET_BITRATE(SWITCH_OPUS_MIN_BITRATE));
if (context->control_state.keep_fec) {
opus_prefs.keep_fec = 0; /* do not enforce FEC anymore, we're low on network bandwidth */
- }
+ }
if (globals.debug || context->debug) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Opus encoder: Adjusting bitrate to %d (minimum)\n", SWITCH_OPUS_MIN_BITRATE);
}
switch_opus_decode, /* function to decode encoded data into raw data */
switch_opus_destroy); /* deinitalize a codec handle using this implementation */
codec_interface->implementations->codec_control = switch_opus_control;
-
+
bytes *= 2;
samples *= 2;
mss *= 2;
* Copyright (c) 2010, Sangoma Technologies
* Moises Silva <moy@sangoma.com>
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
- *
+ *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
/* it seemed we need higher PTIME than the calling parties, so we assume nobody will use higher ptime than 40 */
#define SANGOMA_DEFAULT_SAMPLING_RATE 80
-#define SANGOMA_TRANSCODE_CONFIG "sangoma_codec.conf"
+#define SANGOMA_TRANSCODE_CONFIG "sangoma_codec.conf"
/* \brief vocallos configuration */
static sngtc_init_cfg_t g_init_cfg;
/* packet counters */
unsigned long tx;
unsigned long rx;
- unsigned long ticks;
+ unsigned long ticks;
/* Lost packets */
long lastrxseqno;
switch_port_t rtp_port;
local_ip_addr.s_addr = htonl(host_ip);
-
+
switch_inet_ntop(AF_INET, &local_ip_addr, local_ip, sizeof(local_ip));
/* request a port */
switch_port_t rtp_port = p_rtp_port;
local_ip_addr.s_addr = htonl(host_ip);
-
+
switch_inet_ntop(AF_INET, &local_ip_addr, local_ip, sizeof(local_ip));
/* release the port */
/*
* We *MUST* use a new pool
- * Do not use the session pool since the session may go away while the RTP socket should linger around
- * until sangoma_transcode decides to kill it (possibly because the same RTP session is used for a different call)
+ * Do not use the session pool since the session may go away while the RTP socket should linger around
+ * until sangoma_transcode decides to kill it (possibly because the same RTP session is used for a different call)
* also do not use the module pool otherwise memory would keep growing because switch_rtp_destroy does not
* free the memory used (is assumed it'll be freed when the pool is destroyed)
*/
if (status != SWITCH_STATUS_SUCCESS) {
return -1;
}
-
+
local_ip_addr.s_addr = htonl(codec_req_leg->host_ip);
switch_inet_ntop(AF_INET, &local_ip_addr, local_ip, sizeof(local_ip));
sngtc_codec_ipv4_hex_to_str(codec_reply_leg->codec_ip, codec_ip);
iana = codec_id_to_iana(codec_req_leg->codec_id);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Creating RTP session for host (%s/%d) vocallo(%s/%d) Iana=%d CodecId=%d ms=%d idx=%lu\n",
- local_ip, rtp_port, codec_ip, codec_reply_leg->codec_udp_port, iana, codec_req_leg->codec_id,
+ local_ip, rtp_port, codec_ip, codec_reply_leg->codec_udp_port, iana, codec_req_leg->codec_id,
codec_req_leg->ms*1000, sess->sessid);
/* create the RTP socket */
- rtp_session = switch_rtp_new(local_ip, rtp_port,
- codec_ip, codec_reply_leg->codec_udp_port,
+ rtp_session = switch_rtp_new(local_ip, rtp_port,
+ codec_ip, codec_reply_leg->codec_udp_port,
iana,
sess->impl->samples_per_packet,
codec_req_leg->ms * 1000, /* microseconds per packet */
uint32_t encoding, decoding;
struct sangoma_transcoding_session *sess = NULL;
vocallo_codec_t *vcodec;
-
+
encoding = (flags & SWITCH_CODEC_FLAG_ENCODE);
decoding = (flags & SWITCH_CODEC_FLAG_DECODE);
switch_assert(sess->impl);
vcodec = get_codec_from_iana(codec->implementation->ianacode, codec->implementation->bits_per_second);
-
+
if (encoding) {
sess->encoder.request.usr_priv = sess;
sess->encoder.request.a.host_ip = g_rtpip;
- sess->encoder.request.a.codec_id = vcodec->actual_sampling_rate == 16000
+ sess->encoder.request.a.codec_id = vcodec->actual_sampling_rate == 16000
? SNGTC_CODEC_L16_2 : SNGTC_CODEC_L16_1;
sess->encoder.request.a.ms = codec->implementation->microseconds_per_packet/1000;
sess->decoder.request.a.ms = codec->implementation->microseconds_per_packet/1000;
sess->decoder.request.b.host_ip = g_rtpip;
- sess->decoder.request.b.codec_id = vcodec->actual_sampling_rate == 16000
+ sess->decoder.request.b.codec_id = vcodec->actual_sampling_rate == 16000
? SNGTC_CODEC_L16_2 : SNGTC_CODEC_L16_1;
sess->decoder.request.b.ms = codec->implementation->microseconds_per_packet/1000;
}
/* do the writing */
- memset(&linear_frame, 0, sizeof(linear_frame));
+ memset(&linear_frame, 0, sizeof(linear_frame));
linear_frame.source = __SWITCH_FUNC__;
linear_frame.data = decoded_byteswapped_data;
linear_frame.datalen = decoded_data_len;
}
if (res < i) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"Requested to write %d bytes to Sangoma encoder RTP session, but wrote %d bytes.\n", i, res);
return SWITCH_STATUS_FALSE;
}
if (encoded_frame.payload != codec->implementation->ianacode) {
if (sess->encoder.request.b.codec_id == SNGTC_CODEC_ILBC_152 || sess->encoder.request.b.codec_id == SNGTC_CODEC_ILBC_133) {
- /* since we moved to SOAP based communications, the mapping between vocallo IANA and our IANA does not work,
+ /* since we moved to SOAP based communications, the mapping between vocallo IANA and our IANA does not work,
* some codecs checks cannot be completely done, like iLBC */
if (encoded_frame.payload != IANA_ILBC_152_8000_1 && encoded_frame.payload != IANA_ILBC_133_8000_1) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Read unexpected payload %d in Sangoma encoder RTP session, expecting either %d or %d\n",
/* if there is something where we want to write, we're dropping it */
sess->encoder.rxdiscarded++;
#if 0
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Discarding encoded frame of %d bytes from RTP session %lu, windex = %d, rindex = %d\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Discarding encoded frame of %d bytes from RTP session %lu, windex = %d, rindex = %d\n",
sess->encoder.rtp_queue[sess->encoder.queue_rindex].datalen, sess->sessid, sess->encoder.queue_windex, sess->encoder.queue_rindex);
#endif
SAFE_INDEX_INC(sess->encoder.rtp_queue, sess->encoder.queue_rindex);
/* monitor the queue size */
sess->encoder.queue_size++;
if (sess->encoder.queue_size > sess->encoder.queue_max_ever) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Encoder Rx queue for RTP session %lu is now %d, windex = %d, rindex = %d\n", sess->sessid, sess->encoder.queue_size,
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Encoder Rx queue for RTP session %lu is now %d, windex = %d, rindex = %d\n", sess->sessid, sess->encoder.queue_size,
sess->encoder.queue_windex, sess->encoder.queue_rindex);
sess->encoder.queue_max_ever = sess->encoder.queue_size;
}
}
if (res < encoded_data_len) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"Requested to write %d bytes to Sangoma decoder RTP session, but wrote %d bytes.\n",
encoded_data_len, res);
return SWITCH_STATUS_FALSE;
/* if there is something where we want to write, we're dropping it */
sess->decoder.rxdiscarded++;
#if 0
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Discarding decoded frame of %d bytes from RTP session %lu, windex = %d, rindex = %d\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Discarding decoded frame of %d bytes from RTP session %lu, windex = %d, rindex = %d\n",
sess->decoder.rtp_queue[sess->decoder.queue_rindex].datalen, sess->sessid, sess->decoder.queue_windex, sess->decoder.queue_rindex);
#endif
SAFE_INDEX_INC(sess->decoder.rtp_queue, sess->decoder.queue_rindex);
/* monitor the queue size */
sess->decoder.queue_size++;
if (sess->decoder.queue_size > sess->decoder.queue_max_ever) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Encoder Rx queue for RTP session %lu is now %d, windex = %d, rindex = %d\n", sess->sessid, sess->decoder.queue_size,
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Encoder Rx queue for RTP session %lu is now %d, windex = %d, rindex = %d\n", sess->sessid, sess->decoder.queue_size,
sess->decoder.queue_windex, sess->decoder.queue_rindex);
sess->decoder.queue_max_ever = sess->decoder.queue_size;
}
static switch_status_t switch_sangoma_destroy(switch_codec_t *codec)
{
struct sangoma_transcoding_session *sess = codec->private_info;
- /* things that you may do here is closing files, sockets or other resources used during the codec session
+ /* things that you may do here is closing files, sockets or other resources used during the codec session
* no need to free memory allocated from the pool though, the owner of the pool takes care of that */
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sangoma destroy called.\n");
-
+
switch_mutex_lock(g_sessions_lock);
if (sess->encoder.txrtp) {
if (sess->decoder.txrtp) {
sngtc_free_transcoding_session(&sess->decoder.reply);
}
-
+
switch_core_hash_delete(g_sessions_hash, sess->hashkey);
memset(sess, 0, sizeof(*sess));
stream->write_function(stream, STATS_FORMAT,
- sessid_str,
+ sessid_str,
sess->impl->iananame,
- sess->encoder.txrtp ? "Yes" : "No",
+ sess->encoder.txrtp ? "Yes" : "No",
sess->decoder.txrtp ? "Yes" : "No",
encoder_tx_str,
encoder_rx_str,
if (argc < 2) {
stream->write_function(stream, "%s", SANGOMA_SYNTAX);
goto done;
- }
+ }
ret = sscanf(argv[1], "%lu", &sessid);
if (ret != 1) {
stream->write_function(stream, "%s", SANGOMA_SYNTAX);
goto done;
- }
+ }
sess = sangoma_find_session(sessid);
if (!sess) {
stream->write_function(stream, "-- Inbound Stats --\n");
stream->write_function(stream, "Rx Discarded: %lu\n", sess->encoder.rxdiscarded);
sangoma_print_stats(stream, &stats->inbound);
-
+
stats = switch_rtp_get_stats(sess->encoder.txrtp, NULL);
stream->write_function(stream, "-- Outbound Stats --\n");
if (argc < 2) {
stream->write_function(stream, "%s", SANGOMA_SYNTAX);
goto done;
- }
+ }
ret = sscanf(argv[1], "%lu", &sessid);
if (ret != 1) {
stream->write_function(stream, "%s", SANGOMA_SYNTAX);
goto done;
- }
+ }
sess = sangoma_find_session(sessid);
if (!sess) {
stream->write_function(stream, "Failed to find session %lu\n", sessid);
if (argc < 2) {
stream->write_function(stream, "%s", SANGOMA_SYNTAX);
goto done;
- }
+ }
ret = sscanf(argv[1], "%lu", &sessid);
if (ret != 1) {
stream->write_function(stream, "%s", SANGOMA_SYNTAX);
goto done;
- }
+ }
sess = sangoma_find_session(sessid);
if (!sess) {
stream->write_function(stream, "Failed to find session %lu\n", sessid);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to detect vocallo modules\n");
return SWITCH_STATUS_FALSE;
}
-
+
if (sngtc_activate_modules(&g_init_cfg, &activated)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to activate vocallo modules\n");
return SWITCH_STATUS_FALSE;
/* check if the codec is in the load list, otherwise skip it */
if (strcasecmp(g_codec_register_list, "all") && !strcasestr(g_codec_register_list, g_codec_map[c].iana_name)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Not loading codec %s because was not found in the load list\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Not loading codec %s because was not found in the load list\n",
g_codec_map[c].iana_name);
continue;
}
/* load it unless is named in the noload list */
if (strcasestr(g_codec_noregister_list, g_codec_map[c].iana_name)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Not loading codec %s because was not found in the noload list\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Not loading codec %s because was not found in the noload list\n",
g_codec_map[c].iana_name);
continue;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Registering implementations for codec %s\n", g_codec_map[c].iana_name);
- /* SWITCH_ADD_CODEC allocates a codec interface structure from the pool the core gave us and adds it to the internal interface
+ /* SWITCH_ADD_CODEC allocates a codec interface structure from the pool the core gave us and adds it to the internal interface
* list the core keeps, gets a codec id and set the given codec name to it.
* At this point there is an empty shell codec interface registered, but not yet implementations */
SWITCH_ADD_CODEC(codec_interface, g_codec_map[c].fs_name);
switch_sangoma_encode, /* function to encode slinear data into encoded data */
switch_sangoma_decode, /* function to decode encoded data into slinear data */
switch_sangoma_destroy); /* deinitalize a codec handle using this implementation */
-
+
break;
case SNGTC_CODEC_ILBC_133:
case SNGTC_CODEC_ILBC_152:
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Brian K. West <brian@freeswitch.org>
*
SWITCH_MODULE_LOAD_FUNCTION(mod_silk_load);
SWITCH_MODULE_DEFINITION(mod_silk, mod_silk_load, NULL, NULL);
-#define MAX_BYTES_PER_FRAME 250
+#define MAX_BYTES_PER_FRAME 250
#define MAX_INPUT_FRAMES 5
#define MAX_LBRR_DELAY 2
#define MAX_FRAME_LENGTH 480
-static switch_status_t switch_silk_init(switch_codec_t *codec,
- switch_codec_flag_t freeswitch_flags,
+static switch_status_t switch_silk_init(switch_codec_t *codec,
+ switch_codec_flag_t freeswitch_flags,
const switch_codec_settings_t *codec_settings)
{
struct silk_context *context = NULL;
memset(&codec_fmtp, '\0', sizeof(struct switch_codec_fmtp));
codec_fmtp.private_info = &silk_codec_settings;
switch_silk_fmtp_parse(codec->fmtp_in, &codec_fmtp);
-
+
codec->fmtp_out = switch_core_sprintf(codec->memory_pool, "useinbandfec=%s; usedtx=%s; maxaveragebitrate=%d",
silk_codec_settings.useinbandfec ? "1" : "0",
silk_codec_settings.usedtx ? "1" : "0",
if (SKP_Silk_SDK_Get_Encoder_Size(&encSizeBytes)) {
return SWITCH_STATUS_FALSE;
}
-
+
context->enc_state = switch_core_alloc(codec->memory_pool, encSizeBytes);
if (SKP_Silk_SDK_InitEncoder(context->enc_state, &context->encoder_object)) {
return SWITCH_STATUS_FALSE;
}
-
+
context->encoder_object.API_sampleRate = codec->implementation->actual_samples_per_second;
context->encoder_object.maxInternalSampleRate = codec->implementation->actual_samples_per_second;
if (decoding) {
switch_set_flag(codec, SWITCH_CODEC_FLAG_HAS_PLC);
-
+
if (SKP_Silk_SDK_Get_Decoder_Size(&decSizeBytes)) {
return SWITCH_STATUS_FALSE;
}
switch (ret) {
case SKP_SILK_NO_ERROR: message = "No errors";
break;
- case SKP_SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES:
+ case SKP_SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES:
message = "Input length is not multiplum of 10 ms, or length is longer than the packet length";
break;
- case SKP_SILK_ENC_FS_NOT_SUPPORTED:
+ case SKP_SILK_ENC_FS_NOT_SUPPORTED:
message = "Sampling frequency not 8000 , 12000, 16000 or 24000 Hertz";
break;
case SKP_SILK_ENC_PACKET_SIZE_NOT_SUPPORTED:
message ="Packet size not 20, 40 , 60 , 80 or 100 ms ";
- break;
- case SKP_SILK_ENC_PAYLOAD_BUF_TOO_SHORT:
+ break;
+ case SKP_SILK_ENC_PAYLOAD_BUF_TOO_SHORT:
message = "Allocated payload buffer too short";
break;
- case SKP_SILK_ENC_INVALID_LOSS_RATE:
+ case SKP_SILK_ENC_INVALID_LOSS_RATE:
message = " Loss rate not between 0 and 100 % ";
break;
case SKP_SILK_ENC_INVALID_COMPLEXITY_SETTING:
message = "Complexity setting not valid, use 0 ,1 or 2";
break;
- case SKP_SILK_ENC_INVALID_INBAND_FEC_SETTING:
+ case SKP_SILK_ENC_INVALID_INBAND_FEC_SETTING:
message = "Inband FEC setting not valid, use 0 or 1 ";
break;
case SKP_SILK_ENC_INVALID_DTX_SETTING:
case SKP_SILK_DEC_INVALID_SAMPLING_FREQUENCY:
message = "Output sampling frequency lower than internal decoded sampling frequency";
break;
- case SKP_SILK_DEC_PAYLOAD_TOO_LARGE:
+ case SKP_SILK_DEC_PAYLOAD_TOO_LARGE:
message = "Payload size exceeded the maximum allowed 1024 bytes";
break;
case SKP_SILK_DEC_PAYLOAD_ERROR :
struct silk_context *context = codec->private_info;
SKP_int16 ret;
SKP_int16 pktsz = (SKP_int16)context->encoder_object.packetSize;
- SKP_int16 nBytes = MAX_BYTES_PER_FRAME * MAX_INPUT_FRAMES;
+ SKP_int16 nBytes = MAX_BYTES_PER_FRAME * MAX_INPUT_FRAMES;
SKP_int16 *lindata = (SKP_int16 *)decoded_data;
SKP_int16 samples = (SKP_int16)(decoded_data_len /sizeof(SKP_int16));
*encoded_data_len = 0;
pktsz,
encoded_data,
&nBytes);
-
+
if (ret) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SKP_Silk_Encode returned %d!\n", ret);
printSilkError(ret);
uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag)
{
struct silk_context *context = codec->private_info;
- SKP_int16 ret, len;
+ SKP_int16 ret, len;
int16_t *target = decoded_data;
switch_core_session_t *session = codec->session;
switch_jb_t *jb = NULL;
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Brian K. West <brian@freeswitch.org>
* Steve Underwood <steveu@coppice.org>
*
* mod_siren.c -- ITU-T G.722.1 (Siren7) and ITU-T G.722.1 Annex C (Siren14) licensed from Polycom(R)
*
- * Using mod_siren in a commercial product will require you to acquire a patent
+ * Using mod_siren in a commercial product will require you to acquire a patent
* license directly from Polycom(R) for your company.
*
* http://www.polycom.com/usa/en/company/about_us/technology/siren_g7221/siren_g7221.html
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
*/
/*
- * Other source of reference for module building:
+ * Other source of reference for module building:
* src/mod/applications/mod_skel/mod_skel.c
* http://files.freeswitch.org/cluecon_2009/presentations/Silva_FreeSWITCH_Modules_For_Asterisk_Devs.ppt
* You can load this codec with this command:
static switch_status_t switch_skel_destroy(switch_codec_t *codec)
{
- /* things that you may do here is closing files, sockets or other resources used during the codec session
+ /* things that you may do here is closing files, sockets or other resources used during the codec session
* no need to free memory allocated from the pool though, the owner of the pool takes care of that */
struct skel_context *context = codec->private_info;
context->encodes = 0;
return SWITCH_STATUS_SUCCESS;
}
-/* A standard API registered by the this codec module, APIs can be executed from CLI, mod_event_socket, or many other interfaces
+/* A standard API registered by the this codec module, APIs can be executed from CLI, mod_event_socket, or many other interfaces
* any information or actions you want to publish for users on demand is typically exposed through an API */
SWITCH_STANDARD_API(skel_sayhi)
/* static switch_status_t skel_sayhi(const char *cmd, switch_core_session_t *session, switch_stream_handle_t *stream) */
/* the codec interface that will be registered with the core */
switch_codec_interface_t *codec_interface;
- /* the API interface, only needed if you wish to register APIs
+ /* the API interface, only needed if you wish to register APIs
* (like commands exposed through CLI, mod_event_socket or any other FS interface capable of executing APIs) */
switch_api_interface_t *api_interface;
- /* The core gives us a blank module interface pointer and a pool of memory, we allocate memory from that pool to create our module interface
+ /* The core gives us a blank module interface pointer and a pool of memory, we allocate memory from that pool to create our module interface
* and set the pointer to that chunk of allocated memory */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
- /* SWITCH_ADD_CODEC allocates a codec interface structure from the pool the core gave us and adds it to the internal interface list the core keeps,
+ /* SWITCH_ADD_CODEC allocates a codec interface structure from the pool the core gave us and adds it to the internal interface list the core keeps,
* gets a codec id and set the given codec name to it.
* At this point there is an empty shell codec interface registered, but not yet implementations */
SWITCH_ADD_CODEC(codec_interface, "SKEL 8.0k"); /* 8.0kbit */
- /* Now add as many codec implementations as needed, typically this is done inside a for loop where the packetization size is
+ /* Now add as many codec implementations as needed, typically this is done inside a for loop where the packetization size is
* incremented (10ms, 20ms, 30ms etc) as needed */
switch_core_codec_add_implementation(pool, codec_interface, /* the codec interface we allocated and we want to register with the core */
SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
* mod_dialplan_asterisk.c -- Asterisk extensions.conf style dialplan parser.
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
} else { \
tzoff = NULL; \
} \
- } while(tzoff)
+ } while(tzoff)
-static int parse_exten(switch_core_session_t *session, switch_caller_profile_t *caller_profile, switch_xml_t xexten,
+static int parse_exten(switch_core_session_t *session, switch_caller_profile_t *caller_profile, switch_xml_t xexten,
switch_caller_extension_t **extension, const char *exten_name, int recur)
{
switch_xml_t xcond, xaction, xexpression, xregex;
switch_snprintf(nbuf, sizeof(nbuf), "%s_recur_%d", exten_name, recur);
exten_name = nbuf;
-
+
space[j++] = '|';
for (i = 0; i < recur; i++) {
}
}
}
-
+
if ((req_nesta = switch_xml_attr(xexten, "require-nested"))) {
req_nest = switch_true(req_nesta);
}
if ( switch_core_test_flag(SCF_DIALPLAN_TIMESTAMPS) ) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
"%sDialplan: Processing recursive conditions level:%d [%s] require-nested=%s\n", space,
recur, exten_name, req_nest ? "TRUE" : "FALSE");
} else {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG,
"%sDialplan: Processing recursive conditions level:%d [%s] require-nested=%s\n", space,
recur, exten_name, req_nest ? "TRUE" : "FALSE");
}
do_break_a = NULL;
}
}
-
+
if (time_match == 1) {
if ( switch_core_test_flag(SCF_DIALPLAN_TIMESTAMPS) ) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
}
proceed = 0;
}
-
-
+
+
if ((regex_rule = (char *) switch_xml_attr(xcond, "regex"))) {
int all = !strcasecmp(regex_rule, "all");
int xor = !strcasecmp(regex_rule, "xor");
int regex_time_match;
check_tz();
regex_time_match = switch_xml_std_datetime_check(xregex, tzoff ? &offset : NULL, tzname_);
-
+
if (regex_time_match == 1) {
if ( switch_core_test_flag(SCF_DIALPLAN_TIMESTAMPS) ) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
} else {
expression = (char *) switch_xml_attr_soft(xregex, "expression");
}
-
+
if ((expression_expanded = switch_channel_expand_variables(channel, expression)) == expression) {
expression_expanded = NULL;
} else {
expression = expression_expanded;
}
-
+
total++;
-
+
field = (char *) switch_xml_attr(xregex, "field");
-
+
if (field) {
if (strchr(field, '$')) {
if ((field_expanded = switch_channel_expand_variables(channel, field)) == field) {
if (!field_data) {
field_data = "";
}
-
+
if ((proceed = switch_regex_perform(field_data, expression, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
if ( switch_core_test_flag(SCF_DIALPLAN_TIMESTAMPS) ) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
fail++;
if (all) break;
}
-
+
if (field && strchr(expression, '(')) {
char var[256];
switch_snprintf(var, sizeof(var), "DP_REGEX_MATCH_%d", total);
switch_channel_set_variable(channel, var, NULL);
switch_capture_regex(re, proceed, field_data, ovector, var, switch_regex_set_var_callback, session);
-
+
switch_safe_free(save_expression);
switch_safe_free(save_field_data);
switch_regex_safe_free(save_re);
-
+
save_expression = strdup(expression);
save_field_data = strdup(field_data);
save_re = re;
save_proceed = proceed;
-
+
re = NULL;
}
}
} else {
if ((all && !fail) || (!all && pass)) {
- anti_action = SWITCH_FALSE;
+ anti_action = SWITCH_FALSE;
}
}
} else {
expression = expression_expanded;
}
-
+
if (field) {
if (strchr(field, '$')) {
if ((field_expanded = switch_channel_expand_variables(channel, field)) == field) {
if (save_re) {
re = save_re;
save_re = NULL;
-
+
expression = expression_expanded = save_expression;
save_expression = NULL;
field_data = field_expanded = save_field_data;
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
-/*
- State methods they get called when the state changes to the specific state
+/*
+ State methods they get called when the state changes to the specific state
returning SWITCH_STATUS_SUCCESS tells the core to execute the standard state method next
so if you fully implement the state you can return SWITCH_STATUS_FALSE to skip it.
*/
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
unsigned int ssrc;
char local_user[17];
- char local_pass[17];
+ char local_pass[17];
char *remote_user;
char *remote_pass;
int ptime;
switch_codec_t read_codec;
switch_codec_t write_codec;
-
+
switch_frame_t read_frame;
-
+
uint32_t codec_rate;
char *codec_name;
-
+
switch_payload_t codec_num;
switch_payload_t r_codec_num;
-
+
char *stun_ip;
uint16_t stun_port;
-
+
switch_rtp_t *rtp_session;
ldl_transport_type_t type;
char *local_crypto_key;
char *remote_crypto_key;
-
+
ldl_crypto_data_t *local_crypto_data;
-
+
} mdl_transport_t;
const switch_codec_implementation_t *codecs[SWITCH_MAX_CODECS];
unsigned int num_codecs;
- mdl_transport_t transports[LDL_TPORT_MAX+1];
+ mdl_transport_t transports[LDL_TPORT_MAX+1];
ldl_session_t *dlsession;
{
switch_cache_db_handle_t *dbh = NULL;
char *dsn;
-
+
if (!zstr(profile->odbc_dsn)) {
dsn = profile->odbc_dsn;
} else {
if (switch_cache_db_get_db_handle_dsn(&dbh, dsn) != SWITCH_STATUS_SUCCESS) {
dbh = NULL;
}
-
+
return dbh;
}
char *user = NULL, *host, *f_user = NULL, *ffrom = NULL, *f_host = NULL, *f_resource = NULL;
mdl_profile_t *profile = NULL;
const char *proto;
- const char *from;
- const char *from_full;
- const char *to_full;
+ const char *from;
+ const char *from_full;
+ const char *to_full;
const char *to;
const char *body;
const char *hint;
profile_name = switch_event_get_header(message_event, "ldl_profile");
switch_assert(proto != NULL);
-
+
if (from && (f_user = strdup(from))) {
if ((f_host = strchr(f_user, '@'))) {
*f_host++ = '\0';
from = hint;
} else {
char *p;
-
+
if (!(profile->user_flags & LDL_FLAG_COMPONENT)) {
from = ffrom = strdup(profile->login);
} else {
from = ffrom = switch_mprintf("%s+%s", proto, from);
}
-
+
if ((p = strchr(from, '/'))) {
*p = '\0';
}
codec_order_last = globals.codec_order_last;
codec_order_p = globals.codec_order;
}
-
+
if (codec_string) {
if ((tech_pvt->num_codecs = switch_loadable_module_get_codecs_sorted(tech_pvt->codecs, NULL,
SWITCH_MAX_CODECS, codec_order_p, codec_order_last)) <= 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "NO codecs?\n");
return 0;
}
-
+
} else if (((tech_pvt->num_codecs = switch_loadable_module_get_codecs(tech_pvt->codecs, SWITCH_MAX_CODECS))) <= 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "NO codecs?\n");
return 0;
}
-switch_status_t mdl_build_crypto(struct private_object *tech_pvt, ldl_transport_type_t ttype,
+switch_status_t mdl_build_crypto(struct private_object *tech_pvt, ldl_transport_type_t ttype,
int index, switch_rtp_crypto_key_type_t type, switch_rtp_crypto_direction_t direction)
{
unsigned char b64_key[512] = "";
}
-static switch_status_t mdl_add_crypto(struct private_object *tech_pvt,
+static switch_status_t mdl_add_crypto(struct private_object *tech_pvt,
ldl_transport_type_t ttype, const char *key_str, switch_rtp_crypto_direction_t direction)
{
unsigned char key[SWITCH_RTP_MAX_CRYPTO_LEN];
memcpy(tech_pvt->transports[ttype].remote_raw_key, key, SWITCH_RTP_KEY_LEN);
}
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_NOTICE,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_NOTICE,
"%s Setting %s crypto key\n", ldl_transport_type_str(ttype), switch_core_session_get_name(tech_pvt->session));
tech_pvt->transports[ttype].has_crypto++;
-
+
return SWITCH_STATUS_SUCCESS;
}
}
-static void try_secure(struct private_object *tech_pvt, ldl_transport_type_t ttype)
+static void try_secure(struct private_object *tech_pvt, ldl_transport_type_t ttype)
{
if (!switch_test_flag(tech_pvt, TFLAG_SECURE)) {
if (tech_pvt->transports[ttype].crypto_type) {
- switch_rtp_add_crypto_key(tech_pvt->transports[ttype].rtp_session,
- SWITCH_RTP_CRYPTO_SEND, 1, tech_pvt->transports[ttype].crypto_type,
+ switch_rtp_add_crypto_key(tech_pvt->transports[ttype].rtp_session,
+ SWITCH_RTP_CRYPTO_SEND, 1, tech_pvt->transports[ttype].crypto_type,
tech_pvt->transports[ttype].local_raw_key, SWITCH_RTP_KEY_LEN);
-
- switch_rtp_add_crypto_key(tech_pvt->transports[ttype].rtp_session,
- SWITCH_RTP_CRYPTO_RECV, tech_pvt->transports[ttype].crypto_tag,
- tech_pvt->transports[ttype].crypto_type,
+
+ switch_rtp_add_crypto_key(tech_pvt->transports[ttype].rtp_session,
+ SWITCH_RTP_CRYPTO_RECV, tech_pvt->transports[ttype].crypto_tag,
+ tech_pvt->transports[ttype].crypto_type,
tech_pvt->transports[ttype].remote_raw_key, SWITCH_RTP_KEY_LEN);
-
+
switch_channel_set_variable(tech_pvt->channel, "jingle_secure_audio_confirmed", "true");
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_NOTICE,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_NOTICE,
"%s %s crypto confirmed\n", ldl_transport_type_str(ttype), switch_core_session_get_name(tech_pvt->session));
}
tech_pvt->transports[LDL_TPORT_RTP].write_codec.session = tech_pvt->session;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Set Write Codec to %s@%d\n",
tech_pvt->transports[LDL_TPORT_RTP].codec_name, (int) tech_pvt->transports[LDL_TPORT_RTP].write_codec.implementation->samples_per_second);
-
+
switch_core_session_set_read_codec(tech_pvt->session, &tech_pvt->transports[LDL_TPORT_RTP].read_codec);
switch_core_session_set_write_codec(tech_pvt->session, &tech_pvt->transports[LDL_TPORT_RTP].write_codec);
}
}
if (tech_pvt->transports[LDL_TPORT_RTP].adv_local_port != tech_pvt->transports[LDL_TPORT_RTP].local_port) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "SETUP AUDIO RTP %s:%d(%d) -> %s:%d codec: %s(%d) %dh %di\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "SETUP AUDIO RTP %s:%d(%d) -> %s:%d codec: %s(%d) %dh %di\n",
tech_pvt->profile->ip,
- tech_pvt->transports[LDL_TPORT_RTP].local_port,
- tech_pvt->transports[LDL_TPORT_RTP].adv_local_port,
- tech_pvt->transports[LDL_TPORT_RTP].remote_ip,
+ tech_pvt->transports[LDL_TPORT_RTP].local_port,
+ tech_pvt->transports[LDL_TPORT_RTP].adv_local_port,
+ tech_pvt->transports[LDL_TPORT_RTP].remote_ip,
tech_pvt->transports[LDL_TPORT_RTP].remote_port,
tech_pvt->transports[LDL_TPORT_RTP].read_codec.implementation->iananame,
tech_pvt->transports[LDL_TPORT_RTP].read_codec.implementation->ianacode,
tech_pvt->transports[LDL_TPORT_RTP].read_codec.implementation->samples_per_packet,
tech_pvt->transports[LDL_TPORT_RTP].read_codec.implementation->microseconds_per_packet
-
+
);
} else {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "SETUP AUDIO RTP %s:%d -> %s:%d codec: %s(%d) %dh %di\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "SETUP AUDIO RTP %s:%d -> %s:%d codec: %s(%d) %dh %di\n",
tech_pvt->profile->ip,
- tech_pvt->transports[LDL_TPORT_RTP].local_port,
- tech_pvt->transports[LDL_TPORT_RTP].remote_ip,
+ tech_pvt->transports[LDL_TPORT_RTP].local_port,
+ tech_pvt->transports[LDL_TPORT_RTP].remote_ip,
tech_pvt->transports[LDL_TPORT_RTP].remote_port,
tech_pvt->transports[LDL_TPORT_RTP].read_codec.implementation->iananame,
tech_pvt->transports[LDL_TPORT_RTP].read_codec.implementation->ianacode,
if (tech_pvt->transports[LDL_TPORT_RTCP].remote_port) {
- switch_rtp_activate_rtcp(tech_pvt->transports[LDL_TPORT_RTP].rtp_session, MDL_RTCP_DUR,
+ switch_rtp_activate_rtcp(tech_pvt->transports[LDL_TPORT_RTP].rtp_session, MDL_RTCP_DUR,
tech_pvt->transports[LDL_TPORT_RTCP].remote_port, SWITCH_FALSE);
}
try_secure(tech_pvt, LDL_TPORT_RTP);
- switch_rtp_activate_ice(tech_pvt->transports[LDL_TPORT_RTP].rtp_session,
- tech_pvt->transports[LDL_TPORT_RTP].remote_user,
+ switch_rtp_activate_ice(tech_pvt->transports[LDL_TPORT_RTP].rtp_session,
+ tech_pvt->transports[LDL_TPORT_RTP].remote_user,
tech_pvt->transports[LDL_TPORT_RTP].local_user,
- tech_pvt->transports[LDL_TPORT_RTP].remote_pass, NULL,
+ tech_pvt->transports[LDL_TPORT_RTP].remote_pass, NULL,
IPR_RTP,
ICE_GOOGLE_JINGLE, 0);
-
+
if ((vad_in && inb) || (vad_out && !inb)) {
if (switch_rtp_enable_vad(tech_pvt->transports[LDL_TPORT_RTP].rtp_session, tech_pvt->session, &tech_pvt->transports[LDL_TPORT_RTP].read_codec, SWITCH_VAD_FLAG_TALKING) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "VAD ERROR %s\n", err);
}
//switch_rtp_set_cng_pt(tech_pvt->transports[LDL_TPORT_RTP].rtp_session, 13);
switch_rtp_set_telephony_event(tech_pvt->transports[LDL_TPORT_RTP].rtp_session, 101);
-
+
if (tech_pvt->transports[LDL_TPORT_RTCP].remote_port) {
- switch_rtp_activate_ice(tech_pvt->transports[LDL_TPORT_RTP].rtp_session,
- tech_pvt->transports[LDL_TPORT_RTCP].remote_user,
+ switch_rtp_activate_ice(tech_pvt->transports[LDL_TPORT_RTP].rtp_session,
+ tech_pvt->transports[LDL_TPORT_RTCP].remote_user,
tech_pvt->transports[LDL_TPORT_RTCP].local_user,
- tech_pvt->transports[LDL_TPORT_RTCP].remote_pass,
+ tech_pvt->transports[LDL_TPORT_RTCP].remote_pass,
NULL, IPR_RTCP,
ICE_GOOGLE_JINGLE, 0);
-
+
}
-
+
}
switch_rtp_flag_t flags[SWITCH_RTP_FLAG_INVALID] = {0};
int r = 1, locked = 0;
-
+
if (switch_rtp_ready(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].rtp_session)) {
r = 1; goto end;
}
if (zstr(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].codec_name)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "No valid video_rtp codecs received!\n");
- r = 0; goto end;
+ r = 0; goto end;
}
if (switch_core_codec_ready(&tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_codec)) {
if (tech_pvt->transports[LDL_TPORT_VIDEO_RTP].adv_local_port != tech_pvt->transports[LDL_TPORT_VIDEO_RTP].local_port) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "SETUP VIDEO RTP %s:%d(%d) -> %s:%d codec: %s(%d) %dh %di\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "SETUP VIDEO RTP %s:%d(%d) -> %s:%d codec: %s(%d) %dh %di\n",
tech_pvt->profile->ip,
- tech_pvt->transports[LDL_TPORT_VIDEO_RTP].local_port,
- tech_pvt->transports[LDL_TPORT_VIDEO_RTP].adv_local_port,
- tech_pvt->transports[LDL_TPORT_VIDEO_RTP].remote_ip,
+ tech_pvt->transports[LDL_TPORT_VIDEO_RTP].local_port,
+ tech_pvt->transports[LDL_TPORT_VIDEO_RTP].adv_local_port,
+ tech_pvt->transports[LDL_TPORT_VIDEO_RTP].remote_ip,
tech_pvt->transports[LDL_TPORT_VIDEO_RTP].remote_port,
tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_codec.implementation->iananame,
tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_codec.implementation->ianacode,
tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_codec.implementation->samples_per_packet,
tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_codec.implementation->microseconds_per_packet
-
+
);
} else {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "SETUP VIDEO RTP %s:%d -> %s:%d codec: %s(%d) %dh %di\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "SETUP VIDEO RTP %s:%d -> %s:%d codec: %s(%d) %dh %di\n",
tech_pvt->profile->ip,
- tech_pvt->transports[LDL_TPORT_VIDEO_RTP].local_port,
- tech_pvt->transports[LDL_TPORT_VIDEO_RTP].remote_ip,
+ tech_pvt->transports[LDL_TPORT_VIDEO_RTP].local_port,
+ tech_pvt->transports[LDL_TPORT_VIDEO_RTP].remote_ip,
tech_pvt->transports[LDL_TPORT_VIDEO_RTP].remote_port,
tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_codec.implementation->iananame,
tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_codec.implementation->ianacode,
switch_rtp_set_ssrc(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].rtp_session, tech_pvt->transports[LDL_TPORT_VIDEO_RTP].ssrc);
if (tech_pvt->transports[LDL_TPORT_VIDEO_RTCP].remote_port) {
- switch_rtp_activate_rtcp(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].rtp_session, MDL_RTCP_DUR,
+ switch_rtp_activate_rtcp(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].rtp_session, MDL_RTCP_DUR,
tech_pvt->transports[LDL_TPORT_VIDEO_RTCP].remote_port, SWITCH_FALSE);
}
try_secure(tech_pvt, LDL_TPORT_VIDEO_RTP);
- switch_rtp_activate_ice(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].rtp_session,
- tech_pvt->transports[LDL_TPORT_VIDEO_RTP].remote_user,
+ switch_rtp_activate_ice(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].rtp_session,
+ tech_pvt->transports[LDL_TPORT_VIDEO_RTP].remote_user,
tech_pvt->transports[LDL_TPORT_VIDEO_RTP].local_user,
NULL, NULL, IPR_RTP, ICE_GOOGLE_JINGLE, 0);//tech_pvt->transports[LDL_TPORT_VIDEO_RTP].remote_pass);
switch_channel_set_flag(channel, CF_VIDEO);
switch_set_flag(tech_pvt, TFLAG_VIDEO_RTP_READY);
//switch_rtp_set_default_payload(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].rtp_session, tech_pvt->transports[LDL_TPORT_VIDEO_RTP].codec_num);
//switch_rtp_set_recv_pt(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].rtp_session, tech_pvt->transports[LDL_TPORT_VIDEO_RTP].codec_num);
-
+
if (tech_pvt->transports[LDL_TPORT_VIDEO_RTCP].remote_port) {
-
- switch_rtp_activate_ice(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].rtp_session,
- tech_pvt->transports[LDL_TPORT_VIDEO_RTCP].remote_user,
+
+ switch_rtp_activate_ice(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].rtp_session,
+ tech_pvt->transports[LDL_TPORT_VIDEO_RTCP].remote_user,
tech_pvt->transports[LDL_TPORT_VIDEO_RTCP].local_user,
NULL, NULL, IPR_RTCP, ICE_GOOGLE_JINGLE, 0);//tech_pvt->transports[LDL_TPORT_VIDEO_RTCP].remote_pass);
}
-
+
}
end:
switch_channel_t *channel = switch_core_session_get_channel(tech_pvt->session);
char *advip = tech_pvt->profile->extip ? tech_pvt->profile->extip : tech_pvt->profile->ip;
char *err = NULL, *address = NULL;
-
+
if (!force && tech_pvt->transports[ttype].ready) {
return 0;
}
cand->password = tech_pvt->transports[ttype].local_pass;
cand->pref = 1;
cand->protocol = "udp";
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG,
"Send %s Candidate %s:%d [%s]\n", ldl_transport_type_str(ttype), cand->address, cand->port,
cand->username);
-
+
tech_pvt->transports[ttype].ready = 1;
-
+
return 1;
}
}
}
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Accepted %u of %u rtp candidates.\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Accepted %u of %u rtp candidates.\n",
tech_pvt->transports[LDL_TPORT_RTP].accepted, tech_pvt->transports[LDL_TPORT_RTP].total);
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Accepted %u of %u rtcp candidates.\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Accepted %u of %u rtcp candidates.\n",
tech_pvt->transports[LDL_TPORT_RTCP].accepted, tech_pvt->transports[LDL_TPORT_RTCP].total);
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Accepted %u of %u video_rtp candidates\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Accepted %u of %u video_rtp candidates\n",
tech_pvt->transports[LDL_TPORT_VIDEO_RTP].accepted, tech_pvt->transports[LDL_TPORT_VIDEO_RTP].total);
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Accepted %u of %u video_rctp candidates\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Accepted %u of %u video_rctp candidates\n",
tech_pvt->transports[LDL_TPORT_VIDEO_RTCP].accepted, tech_pvt->transports[LDL_TPORT_VIDEO_RTCP].total);
dft_video = idx;
}
}
-
+
if (dft_audio == -1 && dft_video == -1) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "Cannot find a codec.\n");
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "Cannot find a codec.\n");
return;
}
payloads[1].width = 600;
payloads[1].height = 400;
payloads[1].framerate = 30;
-
+
idx++;
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Don't have video codec.\n");
tech_pvt->desc_id = ldl_session_describe(tech_pvt->dlsession, payloads, idx,
switch_test_flag(tech_pvt, TFLAG_OUTBOUND) ? LDL_DESCRIPTION_INITIATE : LDL_DESCRIPTION_ACCEPT,
- &tech_pvt->transports[LDL_TPORT_RTP].ssrc, &tech_pvt->transports[LDL_TPORT_VIDEO_RTP].ssrc,
- tech_pvt->transports[LDL_TPORT_RTP].local_crypto_data,
+ &tech_pvt->transports[LDL_TPORT_RTP].ssrc, &tech_pvt->transports[LDL_TPORT_VIDEO_RTP].ssrc,
+ tech_pvt->transports[LDL_TPORT_RTP].local_crypto_data,
tech_pvt->transports[LDL_TPORT_VIDEO_RTP].local_crypto_data);
if (switch_rtp_ready(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].rtp_session)) {
switch_rtp_ping(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].rtp_session);
- }
+ }
switch_yield(20000);
}
}
ret = SWITCH_STATUS_SUCCESS;
- switch_channel_audio_sync(channel);
+ switch_channel_audio_sync(channel);
goto done;
return ret;
}
-/*
- State methods they get called when the state changes to the specific state
+/*
+ State methods they get called when the state changes to the specific state
returning SWITCH_STATUS_SUCCESS tells the core to execute the standard state method next
so if you fully implement the state you can return SWITCH_STATUS_FALSE to skip it.
*/
if (tech_pvt->profile) {
switch_thread_rwlock_unlock(tech_pvt->profile->rwlock);
-
+
if (tech_pvt->profile->purge) {
mdl_profile_t *profile = tech_pvt->profile;
if (switch_core_hash_delete(globals.profile_hash, profile->name)) {
ldl_session_terminate(tech_pvt->dlsession);
switch_set_flag_locked(tech_pvt, TFLAG_TERM);
}
-
+
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s CHANNEL HANGUP\n", switch_channel_get_name(channel));
if (switch_test_flag(tech_pvt, TFLAG_IO)) {
//switch_status_t status;
-
+
switch_assert(tech_pvt->transports[LDL_TPORT_RTP].rtp_session != NULL);
tech_pvt->transports[LDL_TPORT_RTP].read_frame.datalen = 0;
tech_pvt = (struct private_object *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
-
+
if (!switch_test_flag(tech_pvt, TFLAG_IO)) {
return SWITCH_STATUS_GENERR;
}
return SWITCH_STATUS_GENERR;
}
}
-
+
tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_frame.datalen = 0;
-
+
while (switch_test_flag(tech_pvt, TFLAG_IO) && tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_frame.datalen == 0) {
tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_frame.flags = SFF_NONE;
switch_rtp_zerocopy_read_frame(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].rtp_session, &tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_frame, flags);
}
*frame = &tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_frame;
-
+
return SWITCH_STATUS_SUCCESS;
}
}
} else {
switch_console_push_match(&my_matches, profile->name);
- }
+ }
}
if (my_matches) {
(new_profile->user_flags == profile->user_flags) && (new_profile->acl_count == profile->acl_count)
) {
uint32_t i;
-
+
if (!(((!new_profile->odbc_dsn && !profile->odbc_dsn) ||
- (new_profile->odbc_dsn && profile->odbc_dsn && !strcasecmp(new_profile->odbc_dsn, profile->odbc_dsn)))
+ (new_profile->odbc_dsn && profile->odbc_dsn && !strcasecmp(new_profile->odbc_dsn, profile->odbc_dsn)))
)) {
return SWITCH_FALSE;
}
-
+
for (i = 0; i < new_profile->acl_count; i++) {
if (strcasecmp(new_profile->acl[i], profile->acl[i]) != 0) {
switch_safe_free(xmlstr);
}
-static ldl_status parse_candidates(ldl_session_t *dlsession, switch_core_session_t *session, ldl_transport_type_t ttype, const char *subject)
+static ldl_status parse_candidates(ldl_session_t *dlsession, switch_core_session_t *session, ldl_transport_type_t ttype, const char *subject)
{
-
+
ldl_candidate_t *candidates;
unsigned int len = 0;
unsigned int x, choice = 0, ok = 0;
}
for (y = 0; y < tech_pvt->profile->acl_count; y++) {
-
+
if (switch_check_network_list_ip(candidates[x].address, tech_pvt->profile->acl[y])) {
choice = x;
ok = 1;
}
-
+
if (ok) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "candidate %s:%d PASS ACL %s\n",
candidates[x].address, candidates[x].port, tech_pvt->profile->acl[y]);
}
} else {
for (x = 0; x < len; x++) {
-
+
if (tech_pvt->profile->lanaddr) {
lanaddr = strncasecmp(candidates[x].address, tech_pvt->profile->lanaddr, strlen(tech_pvt->profile->lanaddr)) ? 0 : 1;
}
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s candidates %s:%d\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s candidates %s:%d\n",
ldl_transport_type_str(ttype), candidates[x].address,
candidates[x].port);
end_candidates:
-
+
if (ok) {
ldl_payload_t payloads[5];
char *key;
if (tech_pvt->transports[ttype].accepted) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Already Accepted [%s:%d]\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Already Accepted [%s:%d]\n",
tech_pvt->transports[ttype].remote_ip, tech_pvt->transports[ttype].remote_port);
//goto end;
}
//goto end;
}
-
+
memset(payloads, 0, sizeof(payloads));
tech_pvt->transports[ttype].accepted++;
tech_pvt->transports[ttype].crypto_type = 0;
}
}
-
+
if (!switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
switch_set_flag_locked(tech_pvt, TFLAG_TRANSPORT_ACCEPT);
//ldl_session_accept_candidate(dlsession, &candidates[choice]);
}
-static ldl_status parse_payloads_type(ldl_session_t *dlsession, switch_core_session_t *session,
+static ldl_status parse_payloads_type(ldl_session_t *dlsession, switch_core_session_t *session,
ldl_transport_type_t ttype, ldl_payload_t *payloads, unsigned int len)
{
struct private_object *tech_pvt = NULL;
unsigned int x, y;
int match = 0;
- tech_pvt = switch_core_session_get_private(session);
+ tech_pvt = switch_core_session_get_private(session);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%u payloads\n", len);
for (x = 0; x < len; x++) {
for (y = 0; y < tech_pvt->num_codecs; y++) {
char *name = tech_pvt->codecs[y]->iananame;
- if ((ttype == LDL_TPORT_VIDEO_RTP && tech_pvt->codecs[y]->codec_type != SWITCH_CODEC_TYPE_VIDEO) ||
+ if ((ttype == LDL_TPORT_VIDEO_RTP && tech_pvt->codecs[y]->codec_type != SWITCH_CODEC_TYPE_VIDEO) ||
(ttype == LDL_TPORT_RTP && tech_pvt->codecs[y]->codec_type != SWITCH_CODEC_TYPE_AUDIO)) {
continue;
}
} else {
match = (payloads[x].id == tech_pvt->codecs[y]->ianacode) ? 1 : 0;
}
-
+
if (match && payloads[x].rate == tech_pvt->codecs[y]->samples_per_second) {
tech_pvt->transports[ttype].codec_index = y;
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Choosing %s Payload index %u %s %u\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Choosing %s Payload index %u %s %u\n",
ldl_transport_type_str(ttype),
y,
payloads[x].name, payloads[x].id);
tech_pvt = switch_core_session_get_private(session);
-
+
if ((status = parse_payloads_type(dlsession, session, LDL_TPORT_RTP, payloads, len)) == LDL_STATUS_SUCCESS) {
match++;
}
return status;
}
-
+
static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsession, ldl_signal_t dl_signal, char *to, char *from, char *subject,
char *msg)
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "hint", hint);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_full", hint);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "ldl_profile", profile->name);
-
+
if (msg) {
switch_event_add_body(event, "%s", msg);
}
} else {
abort();
}
-
+
switch_safe_free(from_user);
if (!zstr(msg)) {
if (strcasecmp(proto, MDL_CHAT_PROTO)) { /* yes no ! on purpose */
switch_core_chat_send(proto, event);
}
-
+
switch_core_chat_send("GLOBAL", event);
}
if (switch_stristr("voice.google.com", from)) {
char *id = switch_core_session_strdup(session, from);
char *p;
-
+
if ((p = strchr(id, '@'))) {
*p++ = '\0';
cid_name = "Google Voice";
cid_num = id;
}
-
+
ldl_session_set_gateway(dlsession);
-
+
do_candidates(tech_pvt, 1);
}
switch_safe_free(tmp);
}
-
+
if (!tech_pvt->caller_profile) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
"Creating an identity for %s %s <%s> %s\n", ldl_session_get_id(dlsession), cid_name, cid_num, exten);
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Creating a session for %s\n", ldl_session_get_id(dlsession));
ldl_session_set_private(dlsession, session);
-
+
switch_channel_set_name(channel, "DingaLing/new");
switch_channel_set_state(channel, CS_INIT);
if (switch_core_session_thread_launch(session) != SWITCH_STATUS_SUCCESS) {
if (dl_signal) {
ldl_payload_t *payloads;
unsigned int len = 0;
-
+
if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
if (msg && !strcasecmp(msg, "accept")) {
switch_set_flag_locked(tech_pvt, TFLAG_ANSWER);
status = LDL_STATUS_SUCCESS;
status = parse_candidates(dlsession, session, LDL_TPORT_RTP, subject);
- status = parse_candidates(dlsession, session, LDL_TPORT_VIDEO_RTP, subject);
+ status = parse_candidates(dlsession, session, LDL_TPORT_VIDEO_RTP, subject);
status = parse_candidates(dlsession, session, LDL_TPORT_RTCP, subject);
- status = parse_candidates(dlsession, session, LDL_TPORT_VIDEO_RTCP, subject);
+ status = parse_candidates(dlsession, session, LDL_TPORT_VIDEO_RTCP, subject);
}
break;
#endif //WIN32
-/*!
+/*!
* \brief structure for storing the results of AT commands, in an array of AT_MESG_MAX_LINES * AT_MESG_MAX_LENGTH chars
*/
struct s_result {
} else if (option_debug) {
DEBUGA_GSMOPEN("|%s| +CNUM: Subscriber number = %s, Type = %d\n", GSMOPEN_P_LOG, tech_pvt->line_array.result[i], number, type);
}
-
+
/* Copy only the first number listed if there are more then one */
if (tech_pvt->requesting_subscriber_number && !strlen(tech_pvt->subscriber_number))
strncpy(tech_pvt->subscriber_number, number, sizeof(tech_pvt->subscriber_number));
//identifying dcs alphabet according to GSM 03.38 Cell Broadcast Data Coding Scheme
//CBDataCodingScheme should be used here, but it appears to be buggy (ucs2 messages are not recognized)
- int alphabet = DCS_RESERVED_ALPHABET;
- if (dcs == 0x11) {
+ int alphabet = DCS_RESERVED_ALPHABET;
+ if (dcs == 0x11) {
alphabet = DCS_SIXTEEN_BIT_ALPHABET;
} else if ((dcs & 0xF0) <= 0x30){
alphabet = DCS_DEFAULT_ALPHABET;
ERRORA("USSD data coding scheme not supported=%d\n", GSMOPEN_P_LOG, dcs);
}
- NOTICA("USSD received: status=%d, message='%s', dcs='%d'\n",
+ NOTICA("USSD received: status=%d, message='%s', dcs='%d'\n",
GSMOPEN_P_LOG, tech_pvt->ussd_status, tech_pvt->ussd_message, dcs);
ussd_incoming(tech_pvt);
#if 0
char letsee[1024];
memset(letsee, '\0', sizeof(letsee));
-
+
DEBUGA_GSMOPEN("about to letsee\n", GSMOPEN_P_LOG);
try {
sprintf(letsee, "|%s|\n", sms->toString().c_str());
return -1;
}
DEBUGA_GSMOPEN("after letsee\n", GSMOPEN_P_LOG);
-
+
DEBUGA_GSMOPEN("SMS=\n%s\n", GSMOPEN_P_LOG, letsee);
#endif //0
memset(content2, '\0', sizeof(content2));
memset(at_command, '\0', sizeof(at_command));
tech_pvt->ussd_received = 0;
- if (tech_pvt->ussd_request_encoding == USSD_ENCODING_PLAIN
+ if (tech_pvt->ussd_request_encoding == USSD_ENCODING_PLAIN
||tech_pvt->ussd_request_encoding == USSD_ENCODING_AUTO) {
snprintf(at_command, sizeof(at_command), "AT+CUSD=1,\"%s\",15", ussd_enc.c_str());
res = gsmopen_serial_write_AT_ack(tech_pvt, at_command);
snprintf(at_command, sizeof(at_command), "AT+CUSD=1,\"%s\",15", ussd_hex.c_str());
res = gsmopen_serial_write_AT_ack(tech_pvt, at_command);
} else if (tech_pvt->ussd_request_encoding == USSD_ENCODING_HEX_8BIT) {
- string ussd_h8 = bufToHex((const unsigned char*)ussd_enc.c_str(), ussd_enc.length());
+ string ussd_h8 = bufToHex((const unsigned char*)ussd_enc.c_str(), ussd_enc.length());
snprintf(at_command, sizeof(at_command), "AT+CUSD=1,\"%s\",15", ussd_h8.c_str());
res = gsmopen_serial_write_AT_ack(tech_pvt, at_command);
} else if (tech_pvt->ussd_request_encoding == USSD_ENCODING_UCS2) {
*matches = my_matches;
status = SWITCH_STATUS_SUCCESS;
}
-
+
return status;
}
//int controldevice_audio_speed = 115200; //FIXME TODO
uint32_t controldevprotocol = PROTOCOL_AT; //FIXME TODO
const char *gsmopen_serial_sync_period = "300"; //FIXME TODO
- const char *imei = "";
+ const char *imei = "";
const char *imsi = "";
tech_pvt = NULL;
globals.GSMOPEN_INTERFACES[interface_id].gsmopen_serial_sync_period = atoi(gsmopen_serial_sync_period);
globals.GSMOPEN_INTERFACES[interface_id].ussd_request_encoding =
- strcasecmp(ussd_request_encoding, "plain") == 0 ? USSD_ENCODING_PLAIN :
- strcasecmp(ussd_request_encoding, "hex7") == 0 ? USSD_ENCODING_HEX_7BIT :
- strcasecmp(ussd_request_encoding, "hex8") == 0 ? USSD_ENCODING_HEX_8BIT :
+ strcasecmp(ussd_request_encoding, "plain") == 0 ? USSD_ENCODING_PLAIN :
+ strcasecmp(ussd_request_encoding, "hex7") == 0 ? USSD_ENCODING_HEX_7BIT :
+ strcasecmp(ussd_request_encoding, "hex8") == 0 ? USSD_ENCODING_HEX_8BIT :
strcasecmp(ussd_request_encoding, "ucs2") == 0 ? USSD_ENCODING_UCS2 : USSD_ENCODING_AUTO;
globals.GSMOPEN_INTERFACES[interface_id].ussd_response_encoding =
- strcasecmp(ussd_response_encoding, "plain") == 0 ? USSD_ENCODING_PLAIN :
- strcasecmp(ussd_response_encoding, "hex7") == 0 ? USSD_ENCODING_HEX_7BIT :
- strcasecmp(ussd_response_encoding, "hex8") == 0 ? USSD_ENCODING_HEX_8BIT :
+ strcasecmp(ussd_response_encoding, "plain") == 0 ? USSD_ENCODING_PLAIN :
+ strcasecmp(ussd_response_encoding, "hex7") == 0 ? USSD_ENCODING_HEX_7BIT :
+ strcasecmp(ussd_response_encoding, "hex8") == 0 ? USSD_ENCODING_HEX_8BIT :
strcasecmp(ussd_response_encoding, "ucs2") == 0 ? USSD_ENCODING_UCS2 : USSD_ENCODING_AUTO;
globals.GSMOPEN_INTERFACES[interface_id].controldevice_speed = controldevice_speed; //FIXME
switch_mutex_unlock(globals.mutex);
return tech_pvt;
}
- }
+ }
}
switch_mutex_unlock(globals.mutex);
stream->write_function(stream, "ERROR, usage: %s", USSD_SYNTAX);
goto end;
}
-
+
if (argc >= 3 && strcasecmp(argv[2], "nowait")==0) {
waittime = 0;
}
stream->write_function(stream, "ERROR: no response received\n");
} else {
stream->write_function(stream, "Status: %d%s\n", tech_pvt->ussd_status,
- tech_pvt->ussd_status == 0 ? " - completed" :
- tech_pvt->ussd_status == 1 ? " - action required" :
+ tech_pvt->ussd_status == 0 ? " - completed" :
+ tech_pvt->ussd_status == 1 ? " - action required" :
tech_pvt->ussd_status == 2 ? " - error" : "");
- if (strlen(tech_pvt->ussd_message) != 0)
+ if (strlen(tech_pvt->ussd_message) != 0)
stream->write_function(stream, "Text: %s\n", tech_pvt->ussd_message);
}
}
-/*
+/*
* H323 endpoint interface for Freeswitch Modular Media Switching Software Library /
* Soft-Switch Application
*
*
* Contributor(s):
* Jan Willamowius.
- *
- *
- *
+ *
+ *
+ *
*
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
#else
timeval timeout;
timeout.tv_sec = sec;
- timeout.tv_usec = 0;
+ timeout.tv_usec = 0;
select(0, NULL, NULL, NULL, &timeout);
#endif
}
*pptr() = (char)c;
bufSize++;
}
-
+
if (bufSize != 0) {
char *bufPtr = pbase();
char *bufEndPtr = NULL;
bufPtr[bufSize] = '\0';
int line = 0;
char *p;
-
+
char *file = NULL;
switch_log_level_t level;
-
+
switch (strtoul(bufPtr, &file, 10)) {
case 1 :
level = SWITCH_LOG_INFO;
if (file) {
while (isspace(*file)) file++;
-
+
if (file && (bufPtr = strchr(file, '(')) && (bufEndPtr = strchr(bufPtr, ')'))) {
char *e;
}
}
}
-
+
switch_text_channel_t tchannel = SWITCH_CHANNEL_ID_LOG;
if (!bufPtr) {
switch_log_printf(tchannel, file, func, line, NULL, level, fmt, bufPtr);
}
-
+
}
return 0;
case H245_AudioCapability::e_gsmFullRate:
case H245_AudioCapability::e_gsmHalfRate:
case H245_AudioCapability::e_gsmEnhancedFullRate:
- return "GSM";
+ return "GSM";
}
return "L16";
}
bool FSProcess::Initialise(switch_loadable_module_interface_t *iface)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "======>FSProcess::Initialise [%p]\n", this);
-
+
m_h323endpoint = new FSH323EndPoint();
return m_h323endpoint != NULL && m_h323endpoint->Initialise(iface);
}
m_freeswitch->interface_name = modulename;
m_freeswitch->io_routines = &h323fs_io_routines;
m_freeswitch->state_handler = &h323fs_event_handlers;
-
+
PString codec = ((const char *)mod_h323_globals.codec_string);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Config capability %s \n", (const char *)codec);
- if (!codec.IsEmpty()) {
+ if (!codec.IsEmpty()) {
const char** f = h323_formats;
- for (; *f; f += 2) {
+ for (; *f; f += 2) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Find capability %s to %s\n",f[1], (const char *)codec);
if (codec.Find(f[1]) != P_MAX_INDEX) {
PString tmp = f[0];
AddAllCapabilities(0, 0, tmp);
num = GetCapabilities().GetSize() - init;
}
- if (num)
+ if (num)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "H.323 added %d capabilities '%s' \n",num,(const char *)tmp);
else
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "H323 failed to add capability '%s' \n",(const char *)tmp);
-
- }
+
+ }
}
}
-
+
if (m_fax_old_asn) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "--->fax_old_asn\n");
SetT38_IFP_PRE();
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "--->fax_asn\n");
SetCapability(0, 0, new FSH323_T38Capability(OpalT38_IFP_COR));
}
-
+
AddAllUserInputCapabilities(0, 1);
-
+
DisableFastStart(!m_faststart);
DisableH245Tunneling(!m_h245tunneling);
DisableH245inSetup(!m_h245insetup);
DisableDetectInBandDTMF(!m_dtmfinband);
if (!m_endpointname.IsEmpty())
SetLocalUserName(m_endpointname);
-
+
if (m_listeners.empty()) {
StartListener("");
} else {
m_thread->SetAutoDelete();
m_thread->Resume();
}
-
+
return TRUE;
}
switch_status_t status = SWITCH_STATUS_SUCCESS;
switch_memory_pool_t *pool = NULL;
-
+
if ((status = switch_core_new_memory_pool(&pool)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
return status;
m_ai = atoi(val);
} else if (!strcasecmp(var, "fax-old-asn")) {
m_fax_old_asn = switch_true(val);
- }
+ }
}
}
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323EndPoint::FSH323EndPoint [%p]\n",this);
terminalType = e_GatewayAndMC;
-}
+}
FSH323EndPoint::~FSH323EndPoint()
{
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------> SWITCH_CALL_DIRECTION_INBOUND\n");
}
-
- switch_core_session_t *fsSession = switch_core_session_request(GetSwitchInterface(),
+
+ switch_core_session_t *fsSession = switch_core_session_request(GetSwitchInterface(),
(switch_caller_profile_t *)userData ? SWITCH_CALL_DIRECTION_OUTBOUND : SWITCH_CALL_DIRECTION_INBOUND, SOF_NONE, NULL);
if (fsSession == NULL)
return NULL;
-
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------> fsSession = %p\n",fsSession);
switch_channel_t *fsChannel = switch_core_session_get_channel(fsSession);
switch_core_session_destroy(&fsSession);
return NULL;
}
-
+
return new FSH323Connection(*this, transport, callReference, (switch_caller_profile_t *)userData, fsSession, fsChannel);
}
if (m_stop_gk) {
m_stop_gk = false;
return;
- }
+ }
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Wait next go connect gatekeeper %d\n",retry);
h_timer(retry);
if (m_stop_gk) {
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Started gatekeeper: %s\n",
- (const char *)GetGatekeeper()->GetName());
+ (const char *)GetGatekeeper()->GetName());
m_thread = NULL;
}
if (m_thread) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Stop gatekeeper thread\n");
m_stop_gk = true;
-
+
while (m_stop_gk){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Wait stop gatekeeper thread\n");
h_timer(2);
tech_pvt->me = this;
tech_pvt->active_connection = true;
switch_core_session_set_private(m_fsSession, tech_pvt);
-
+
switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(m_fsSession));
switch_mutex_init(&tech_pvt->h323_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(m_fsSession));
switch_mutex_init(&tech_pvt->h323_io_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(m_fsSession));
-
+
if (outbound_profile != NULL) {
SetLocalPartyName(outbound_profile->caller_id_number);
SetDisplayName(outbound_profile->caller_id_name);
switch_channel_set_state(m_fsChannel, CS_INIT);
}
-}
+}
FSH323Connection::~FSH323Connection()
{
} else if (m_RTPlocalPort) {
switch_rtp_release_port((const char *)m_RTPlocalIP.AsString(), m_RTPlocalPort);
}
-
+
tech_pvt->me = NULL;
tech_pvt->active_connection = false;
// switch_mutex_unlock(tech_pvt->h323_mutex);
// switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_unlock\n");
switch_safe_free(tech_pvt->token);
-}
+}
void FSH323Connection::AttachSignalChannel(const PString & token,
H323Transport * channel,
if (!mod_h323_globals.codec_string)
return false;
-
+
bool nocodecs = true;
bool changed = false;
if (fastStartChannels[idx].GetCapability() == localCapabilities[i]) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,"Removing fast start channel %s '%s' (%s)\n",GetDirections[fastStartChannels[idx].GetDirection()],(const char*)fname,(const char*)format);
fastStartChannels.RemoveAt(idx--);
- }
+ }
}
localCapabilities.Remove(fname);
i--;
if (nocodecs) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No codecs remaining for H323 connection [%p]\n",this);
changed = false;
- ClearCall(EndedByCapabilityExchange);
+ ClearCall(EndedByCapabilityExchange);
}
return changed;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::decodeCapability [%p]\n",this);
PString fname((const char *)capability.GetFormatName());
-
+
if (fname.Find("{sw}") == (fname.GetLength() - 4))
fname = fname.Mid(0,fname.GetLength()-4);
if (fname.Find("{hw}") == (fname.GetLength() - 4))
fname = fname.Mid(0,fname.GetLength()-4);
-
+
OpalMediaFormat oformat(fname, false);
int pload = oformat.GetPayloadType();
const char *format = 0;
break;
}
}
-
+
if (format) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,"capability '%s' format '%s' %d\n",(const char*)fname,format,pload);
if (capabName)
const H323SignalPDU &setupPDU, H323SignalPDU &connectPDU)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OnAnswerCall caller = %s [%p]\n",(const char*)caller,this);
-
+
if (m_fsSession == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session request failed.\n");
return H323Connection::AnswerCallDenied;
else {
PString callnam;
if (q931.GetCalledPartyNumber(callnam)) {
- called=(const char *)callnam;
+ called=(const char *)callnam;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,"Called-Party-Number = %s\n",(const char*)called);
}
}
-
+
PIPSocket::Address remote_network_addr;
GetSignallingChannel()->GetRemoteAddress().GetIpAddress(remote_network_addr);
-
+
switch_caller_profile_t *caller_profile = switch_caller_profile_new(switch_core_session_get_pool(m_fsSession),
NULL,
/** username */
H323Channel* FSH323Connection::CreateRealTimeLogicalChannel(const H323Capability& capability,H323Channel::Directions dir,unsigned sessionID,const H245_H2250LogicalChannelParameters* param, RTP_QOS * rtpqos)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::CreateRealTimeLogicalChannel [%p]\n",this);
-
+
H323TransportAddress m_h323transportadd = GetSignallingChannel()->GetLocalAddress();
m_h323transportadd.GetIpAddress(m_RTPlocalIP);
if (!m_RTPlocalPort) {
PBoolean FSH323Connection::OnCreateLogicalChannel(const H323Capability& capability, H323Channel::Directions dir, unsigned& errorCode)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OnCreateLogicalChannel ('%s',%s) [%p]\n",(const char *)capability.GetFormatName(),GetDirections[dir],this);
-
+
return H323Connection::OnCreateLogicalChannel(capability,dir,errorCode);
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_session_unlock_codec_write [%p]\n",m_fsSession);
}
tech_pvt->me = NULL;
- switch_channel_hangup(switch_core_session_get_channel(m_fsSession),(switch_call_cause_t)pdu.GetQ931().GetCause());
+ switch_channel_hangup(switch_core_session_get_channel(m_fsSession),(switch_call_cause_t)pdu.GetQ931().GetCause());
return H323Connection::OnReceivedReleaseComplete(pdu);
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"---------> after callProceedingPDU.BuildCallProceeding connectionState = %s [%p]\n",ConnectionStatesNames[connectionState],this);
if (connectionState == ShuttingDownConnection){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"---------> connectionState = ShuttingDownConnection [%p]\n",this);
- return false;
+ return false;
}
if (SendFastStartAcknowledge(callProceeding.m_fastStart)) {
return false;
}
- return true;
+ return true;
}
bool FSH323Connection::OnReceivedCallProceeding(const H323SignalPDU & pdu)
bool FSH323Connection::OnSendCallProceeding(H323SignalPDU & callProceedingPDU)
{
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OnSendCallProceeding fastStartState = %s [%p]\n",FastStartStateNames[fastStartState],this);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OnSendCallProceeding fastStartState = %s [%p]\n",FastStartStateNames[fastStartState],this);
return false;
// return true;
bool FSH323Connection::OnSendReleaseComplete(H323SignalPDU & pdu)
{
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OnSendReleaseComplete cause = %u\n",(switch_call_cause_t)pdu.GetQ931().GetCause());
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OnSendReleaseComplete cause = %u\n",(switch_call_cause_t)pdu.GetQ931().GetCause());
switch_channel_hangup(m_fsChannel, (switch_call_cause_t) pdu.GetQ931().GetCause());
return H323Connection::OnSendReleaseComplete(pdu);
return false;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>END H323Connection::OnReceivedCapabilitySet [%p]\n",this);
-
+
for (int i = 0; i < remoteCapabilities.GetSize(); ++i) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"----> Capabilities = %s\n",(const char*)(remoteCapabilities[i].GetFormatName()));
}
-
+
H323Capability * cap = remoteCapabilities.FindCapability(H323Capability::e_Audio);
if (cap == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"----> Capabilities is NULL \n");
return false;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"----> Capabilities not NULL \n");
-
- return connectionState != ShuttingDownConnection;
+
+ return connectionState != ShuttingDownConnection;
}
bool FSH323Connection::OnAlerting(const H323SignalPDU &alertingPDU, const PString &user)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>PFSH323Connection::OnAlerting user = %s [%p]\n",(const char *)user,this);
unsigned pi;
switch_channel_mark_ring_ready(m_fsChannel);
-
+
if (!alertingPDU.GetQ931().GetProgressIndicator(pi))
pi = 0;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"----------->OnAlerting PI = %u\n",pi);
void FSH323Connection::AnsweringCall(AnswerCallResponse response)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::AnsweringCall [%p]\n",this);
-
+
switch (response) {
case AnswerCallDeferredWithMedia:{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"Answering call: %s\n",GetAnswerCallResponse[response]);
}
fac.IncludeOptionalField(H225_Facility_UUIE::e_h245Address);
controlChannel->SetUpTransportPDU(fac.m_h245Address, TRUE);
- }
+ }
else
sendPDU = FALSE;
}
-*/
- const char *vpi = switch_channel_get_variable(m_fsChannel, "progress-indication");
+*/
+ const char *vpi = switch_channel_get_variable(m_fsChannel, "progress-indication");
unsigned pi = 8;
if (vpi){
- pi = atoi(vpi);
+ pi = atoi(vpi);
}
else pi = m_endpoint->m_pi;
if ((pi< 1) || (pi > 8)||(pi == 7)) pi = 8;
Unlock();
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->UnLock\n");
return;
- }
+ }
case AnswerCallPending :{
if (alertingPDU != NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->Lock\n");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->Lock ok\n");
// send Q931 Alerting PDU
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,"Sending Alerting PDU\n");
-
- const char *vai = switch_channel_get_variable(m_fsChannel, "alerting-indication");
+
+ const char *vai = switch_channel_get_variable(m_fsChannel, "alerting-indication");
unsigned ai = 0;
if (vai){
- ai = atoi(vai);
+ ai = atoi(vai);
}
else ai = m_endpoint->m_ai;
if ((ai< 0) || (ai > 8)||(ai == 7)) ai = 8;
if (ai > 0)
(*alertingPDU).GetQ931().SetProgressIndicator(ai);
-
+
HandleTunnelPDU(alertingPDU);
WriteSignalPDU(*alertingPDU);
alertingTime = PTime();
}
}
default :H323Connection::AnsweringCall(response);
- }
+ }
}
void FSH323Connection::OnEstablished()
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>PFSH323Connection::OnEstablished [%p]\n",this);
- if(m_startRTP)
+ if(m_startRTP)
switch_channel_mark_answered(m_fsChannel);
else
m_ChannelAnswer = true;
if (m_active_channel_fax)
RequestModeChangeT38("T.38\nT.38");
- else
+ else
m_active_channel_fax = true;
}
PBoolean FSH323Connection::OnRequestModeChange(const H245_RequestMode & pdu,
for (PINDEX i = 0; i < newMode.GetSize(); i++) {
H323Capability * capability = localCapabilities.FindCapability(newMode[i]);
if (PAssertNULL(capability) != NULL) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"Open channel after mode change: %s\n",(const char*)(capability->GetFormatName()));
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"Open channel after mode change: %s\n",(const char*)(capability->GetFormatName()));
if (capability->GetMainType() == H323Capability::e_Data){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"capability->GetMainType() = H323Capability::e_Data\n");
H245_DataMode & type = newMode[i].m_type;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"switch_core_session_alloc t38_options\n");
}
t38_options->T38VendorInfo = "0 0 0";
-
+
t38_options->T38FaxVersion = (uint16_t)profile.m_version;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"T38FaxVersion:%lu\n",(unsigned long)profile.m_version);
t38_options->T38MaxBitRate = type.m_bitRate*100;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"T38MaxBitRate:%d\n",t38_options->T38MaxBitRate);
- if (profile.m_fillBitRemoval)
+ if (profile.m_fillBitRemoval)
t38_options->T38FaxFillBitRemoval = SWITCH_TRUE;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"T38FaxFillBitRemoval:%d\n",(int)profile.m_fillBitRemoval);
if (profile.m_transcodingMMR)
t38_options->T38FaxTranscodingMMR = SWITCH_TRUE;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"T38FaxTranscodingMMR:%d\n",(int)profile.m_transcodingMMR);
- if (profile.m_transcodingJBIG)
+ if (profile.m_transcodingJBIG)
t38_options->T38FaxTranscodingJBIG = SWITCH_TRUE;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"T38FaxTranscodingJBIG:%d\n",(int)profile.m_transcodingJBIG);
if (profile.m_t38FaxRateManagement.GetTag() == H245_T38FaxRateManagement::e_transferredTCF)
else
t38_options->T38FaxUdpEC = "t38UDPRedundancy";
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"T38FaxUdpEC:%s\n",t38_options->T38FaxUdpEC);
- const char *uuid = switch_channel_get_partner_uuid(m_fsChannel);
+ const char *uuid = switch_channel_get_partner_uuid(m_fsChannel);
if (uuid != NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"uuid:%s\n",uuid);
-
+
switch_core_session_t *session = switch_core_session_locate(switch_channel_get_partner_uuid(m_fsChannel));
if (session) {
switch_channel_t * channel = switch_core_session_get_channel(session);
switch_core_session_rwunlock(session);
}else{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "no session\n");
- }
-
-
+ }
+
+
switch_core_session_message_t msg = { 0 };
int insist = 0;
const char *v;
if ((v = switch_channel_get_variable(m_fsChannel, "fax_enable_t38_insist"))) {
insist = switch_true(v);
- }
+ }
msg.from = switch_channel_get_name(m_fsChannel);
msg.message_id = SWITCH_MESSAGE_INDICATE_REQUEST_IMAGE_MEDIA;
msg.numeric_arg = insist;
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"uuid:%s\n",switch_channel_get_uuid(switch_core_session_get_channel(switch_channel_get_session(m_fsChannel))));
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"uuid:%s\n",switch_channel_get_uuid(switch_core_session_get_channel(switch_channel_get_session(m_fsChannel))));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"uuid:%s\n",uuid);
switch_core_session_message_send(uuid,&msg);
} else {
}
}
}
- }
+ }
}
H323Connection::OnModeChanged(newMode);
}
bool FSH323Connection::OnSendSignalSetup(H323SignalPDU & setupPDU)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>PFSH323Connection::OnSendSignalSetup [%p]\n",this);
- setupPDU.GetQ931().SetBearerCapabilities(Q931::TransferSpeech, 1);
+ setupPDU.GetQ931().SetBearerCapabilities(Q931::TransferSpeech, 1);
return true;
}
switch_status_t FSH323Connection::on_execute()
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::on_execute [%p]\n",this);
-
+
return SWITCH_STATUS_SUCCESS;
}
switch_status_t FSH323Connection::on_routing()
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::on_routing [%p]\n",this);
-
+
return SWITCH_STATUS_SUCCESS;
}
if (!tech_pvt) {
return SWITCH_STATUS_FALSE;
}
-
+
switch (sig) {
case SWITCH_SIG_BREAK:
if (switch_rtp_ready(tech_pvt->rtp_session)) {
case SWITCH_SIG_KILL:
default:
m_rxAudioOpened.Signal();
- m_txAudioOpened.Signal();
+ m_txAudioOpened.Signal();
if (switch_rtp_ready(tech_pvt->rtp_session)) {
if ((m_rtp_resetting == 1)) {
switch_core_session_unlock_codec_read(m_fsSession);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_unlock\n");
AnsweringCall(AnswerCallPending);
AnsweringCall(AnswerCallDeferredWithMedia);
-
+
if (m_txChannel && m_rxChannel){
if (!switch_channel_test_flag(m_fsChannel, CF_EARLY_MEDIA)) {
switch_channel_mark_pre_answered(m_fsChannel);
}
- } else {
+ } else {
m_callOnPreAnswer = true;
if (fastStartState == FastStartDisabled){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"-------------------->m_txAudioOpened.Wait START [%p]\n",this);
}
AnsweringCall(H323Connection::AnswerCallNow);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"Media started on connection [%p]\n",this);
-
+
if (m_txChannel && m_rxChannel){
if (!switch_channel_test_flag(m_fsChannel, CF_EARLY_MEDIA)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"-------------------->switch_channel_mark_answered(m_fsChannel) [%p]\n",this);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"-------------------->switch_channel_mark_answered(m_fsChannel) [%p]\n",this);
switch_channel_mark_answered(m_fsChannel);
}
} else{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_unlock\n");
if (m_active_channel_fax)
RequestModeChangeT38("T.38\nT.38");
- else
+ else
m_active_channel_fax = true;
break;
}
}
default:{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"Received message id = %d [%p]\n", msg->message_id,this);
- }
+ }
}
return SWITCH_STATUS_SUCCESS;
switch_status_t FSH323Connection::on_exchange_media()
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::on_exchange_media [%p]\n",this);
-
+
return SWITCH_STATUS_SUCCESS;
}
switch_status_t FSH323Connection::on_soft_execute()
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::on_soft_execute [%p]\n",this);
-
+
return SWITCH_STATUS_SUCCESS;
}
switch_set_flag_locked(tech_pvt, TFLAG_READING);
if (!switch_channel_ready(m_fsChannel)) {
- switch_clear_flag_locked(tech_pvt, TFLAG_READING);
+ switch_clear_flag_locked(tech_pvt, TFLAG_READING);
#ifdef DEBUG_RTP_PACKETS
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::read_audio_frame END\n");
#endif
#ifdef DEBUG_RTP_PACKETS
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::read_audio_frame END\n\n");
#endif
- return status;
+ return status;
}
// PTRACE(4, "mod_h323\t--------->\n source = "<<tech_pvt->read_frame.source<< "\n packetlen = "<<tech_pvt->read_frame.packetlen<<"\n datalen = "<<tech_pvt->read_frame.datalen<<"\n samples = "<<tech_pvt->read_frame.samples<<"\n rate = "<<tech_pvt->read_frame.rate<<"\n payload = "<<(int)tech_pvt->read_frame.payload<<"\n timestamp = "<<tech_pvt->read_frame.timestamp<<"\n seq = "<<tech_pvt->read_frame.seq<<"\n ssrc = "<<tech_pvt->read_frame.ssrc);
switch_mutex_unlock(tech_pvt->h323_io_mutex);
switch_clear_flag_locked(tech_pvt, TFLAG_READING);
-
+
*frame = &tech_pvt->read_frame;
#ifdef DEBUG_RTP_PACKETS
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::read_audio_frame END\n\n");
#ifdef DEBUG_RTP_PACKETS
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::write_audio_frame [%p]\n",this);
#endif
-
+
/*switch_channel_t *channel = NULL;
h323_private_t *tech_pvt = NULL;
switch_status_t status = SWITCH_STATUS_SUCCESS;
-
+
channel = switch_core_session_get_channel(m_fsSession);
assert(channel != NULL);
switch_status_t status = SWITCH_STATUS_SUCCESS;
h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_get_private(m_fsSession);
switch_assert(tech_pvt != NULL);
-
+
if (!switch_channel_ready(m_fsChannel)) {
#ifdef DEBUG_RTP_PACKETS
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::write_audio_frame END\n\n");
#endif
return SWITCH_STATUS_FALSE;
}
-
+
while (!(tech_pvt->read_codec.implementation && switch_rtp_ready(tech_pvt->rtp_session))) {
if (switch_channel_ready(m_fsChannel)) {
switch_yield(10000);
return SWITCH_STATUS_GENERR;
}
}
-
+
if (!switch_core_codec_ready(&tech_pvt->read_codec) || !tech_pvt->read_codec.implementation) {
#ifdef DEBUG_RTP_PACKETS
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::write_audio_frame END\n\n");
}
switch_set_flag_locked(tech_pvt, TFLAG_WRITING);
-
+
if (switch_rtp_write_frame(tech_pvt->rtp_session, frame) < 0) {
status = SWITCH_STATUS_GENERR;
}
-
+
switch_clear_flag_locked(tech_pvt, TFLAG_WRITING);
#ifdef DEBUG_RTP_PACKETS
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::write_audio_frame END\n\n");
FSH323_ExternalRTPChannel::FSH323_ExternalRTPChannel(FSH323Connection& connection,
const H323Capability& capability,
- Directions direction,
+ Directions direction,
unsigned sessionID,
- const PIPSocket::Address& ip,
+ const PIPSocket::Address& ip,
WORD dataPort)
: H323_ExternalRTPChannel(connection, capability, direction, sessionID,ip,dataPort)
, m_conn(&connection)
, m_RTPlocalPort(dataPort)
, m_sessionID(sessionID)
, m_rtp_resetting(0)
-{
+{
m_RTPlocalIP = (const char *)ip.AsString();
SetExternalAddress(H323TransportAddress(ip, dataPort), H323TransportAddress(ip, dataPort+1));
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323_ExternalRTPChannel::FSH323_ExternalRTPChannel sessionID = %d :%s addr = %s:%d [%p]\n",sessionID,GetDirections[GetDirection()],(const char*)m_RTPlocalIP,m_RTPlocalPort,this);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323_ExternalRTPChannel::FSH323_ExternalRTPChannel sessionID = %d :%s addr = %s:%d [%p]\n",sessionID,GetDirections[GetDirection()],(const char*)m_RTPlocalIP,m_RTPlocalPort,this);
m_fsChannel = switch_core_session_get_channel(m_fsSession);
//SetExternalAddress(H323TransportAddress(localIpAddress, m_RTPlocalPort), H323TransportAddress(localIpAddress, m_RTPlocalPort+1));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------->capability.GetPayloadType() return = %s\n",((capability.GetPayloadType() <= RTP_DataFrame::LastKnownPayloadType)?PayloadTypesNames[capability.GetPayloadType()]:"[pt=128]"));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------->capability.GetFormatName() return = %s\n",(const char*)(capability.GetFormatName()));
-
+
PString fname((const char *)capability.GetFormatName());
-
+
if (fname.Find("{sw}") == (fname.GetLength() - 4))
fname = fname.Mid(0,fname.GetLength()-4);
if (fname.Find("{hw}") == (fname.GetLength() - 4))
fname = fname.Mid(0,fname.GetLength()-4);
-
+
OpalMediaFormat format(fname, FALSE);
m_format = &format;
payloadCode = (BYTE)format.GetPayloadType();
FSH323_ExternalRTPChannel::~FSH323_ExternalRTPChannel()
{
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323_ExternalRTPChannel::~FSH323_ExternalRTPChannel %s [%p]\n",GetDirections[GetDirection()],this);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323_ExternalRTPChannel::~FSH323_ExternalRTPChannel %s [%p]\n",GetDirections[GetDirection()],this);
if (m_rtp_resetting) {
switch_core_session_unlock_codec_read(m_fsSession);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_session_unlock_codec_read [%p]\n",m_fsSession);
switch_core_session_unlock_codec_write(m_fsSession);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_session_unlock_codec_write [%p]\n",m_fsSession);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_session_unlock_codec_write [%p]\n",m_fsSession);
}
}
char * timer_name = NULL;
const char *var;
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->m_sessionID = %d m_active_sessionID = %d\n",sessionID,m_conn->m_active_sessionID);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->m_sessionID = %d m_active_sessionID = %d\n",sessionID,m_conn->m_active_sessionID);
if (!(m_conn && H323_ExternalRTPChannel::Start())) {
switch_mutex_unlock(tech_pvt->h323_mutex);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_unlock\n");
return false;
}
-
+
if ((tech_pvt->me == NULL) || ((tech_pvt->me != NULL) && tech_pvt->me->m_channel_hangup)) {
switch_mutex_unlock(tech_pvt->h323_mutex);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_unlock\n");
return false;
}
-
+
if ((m_conn->m_active_sessionID != 0) && (m_conn->m_active_sessionID != sessionID)) {
if (switch_core_codec_ready(&tech_pvt->read_codec) || switch_core_codec_ready(&tech_pvt->write_codec)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------->Changing Codec to %s\n",(const char*)GetH245CodecName(m_capability));
}
default:break;
}
-
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------->GetFrameSize() return = %u\n",(unsigned)m_format->GetFrameSize());
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------->GetFrameTime() return = %u\n",m_format->GetFrameTime());
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------->payloadCode = %d\n",(int)payloadCode);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------->m_codec_ms return = %u\n",m_codec_ms);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------->m_capability->GetFormatName() return = %s\n",(const char*)(m_capability->GetFormatName()));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------->GetH245CodecName() return = %s\n",(const char*)GetH245CodecName(m_capability));
-
+
if (GetDirection() == IsReceiver) {
codec = isAudio ? &tech_pvt->read_codec : &tech_pvt->vid_read_codec;
//m_switchTimer = isAudio ? &tech_pvt->read_timer : &tech_pvt->vid_read_timer;
//m_switchTimer = isAudio ? &tech_pvt->read_timer : &tech_pvt->vid_read_timer;
}
}
-
+
tech_pvt->read_frame.codec = &tech_pvt->read_codec; /* Set codec here - no need to set it every time a frame is read */
if (switch_core_codec_init(codec, GetH245CodecName(m_capability), NULL, NULL, // FMTP
8000, m_codec_ms, 1, // Channels
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, // Settings
switch_core_session_get_pool(m_fsSession)) != SWITCH_STATUS_SUCCESS) {
-
+
if (switch_core_codec_init(codec, GetH245CodecName(m_capability), NULL, NULL, // FMTP
8000, 0, 1, // Channels
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, // Settings
if (GetDirection() == IsReceiver) {
//m_readFrame.rate = tech_pvt->read_codec.implementation->actual_samples_per_second;
-
+
if (isAudio) {
switch_core_session_set_read_codec(m_fsSession, codec);
/*if (switch_core_timer_init(m_switchTimer,
codec->implementation->microseconds_per_packet / 1000,
codec->implementation->samples_per_packet,
switch_core_session_get_pool(m_fsSession)) != SWITCH_STATUS_SUCCESS) {
-
+
switch_core_codec_destroy(codec);
codec = NULL;
switch_mutex_unlock(tech_pvt->h323_mutex);
return false;
}
switch_channel_set_variable(m_fsChannel,"timer_name","soft");*/
- }
+ }
} else {
switch_core_session_set_video_write_codec(m_fsSession, codec);
switch_channel_set_flag(m_fsChannel, CF_VIDEO);
}
}
-
+
// PTRACE(4, "mod_h323\tSet " << ((GetDirection() == IsReceiver)? " read" : " write") << ' '
// << m_capability->GetMainType() << " codec to << " << m_capability << " for connection " << *this);
-
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"Set %s %s codec to %s for connection [%p]\n",((GetDirection() == IsReceiver)? " read" : " write")
,GetMainTypes[m_capability->GetMainType()],(const char*)m_capability->GetFormatName(),this);
-
+
PIPSocket::Address remoteIpAddress;
- GetRemoteAddress(remoteIpAddress,m_RTPremotePort);
+ GetRemoteAddress(remoteIpAddress,m_RTPremotePort);
m_RTPremoteIP = (const char *)remoteIpAddress.AsString();
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------->tech_pvt->rtp_session = [%p]\n",tech_pvt->rtp_session);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------->samples_per_packet = %lu\n", codec->implementation->samples_per_packet);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------->actual_samples_per_second = %lu\n", codec->implementation->actual_samples_per_second);
-
+
bool ch_port = false;
if (tech_pvt->rtp_session != NULL){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------->old remote port = %d new remote port = %d\n",switch_rtp_get_remote_port(tech_pvt->rtp_session),m_RTPremotePort);
if ((switch_rtp_get_remote_port(tech_pvt->rtp_session) != m_RTPremotePort) && (GetDirection() != IsReceiver) && (m_conn->m_rtp_resetting == 1)){
ch_port = true;
m_conn->m_startRTP = false;
-
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_session_lock_codec_read [%p]\n",m_fsSession);
- switch_core_session_lock_codec_read(m_fsSession);
+ switch_core_session_lock_codec_read(m_fsSession);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_io_mutex_lock\n");
switch_mutex_lock(tech_pvt->h323_io_mutex);
switch_clear_flag_locked(tech_pvt, TFLAG_IO);
switch_rtp_destroy(&tech_pvt->rtp_session);
}
}
-
- if ((!m_conn->m_startRTP)) {
+
+ if ((!m_conn->m_startRTP)) {
flags[SWITCH_RTP_FLAG_DATAWAIT] = (switch_rtp_flag_t)1;
flags[SWITCH_RTP_FLAG_RAW_WRITE] = (switch_rtp_flag_t)1;
(const char *)m_RTPremoteIP,
m_RTPremotePort,
(switch_payload_t)payloadCode,
- codec->implementation->samples_per_packet,
+ codec->implementation->samples_per_packet,
codec->implementation->microseconds_per_packet,
flags, timer_name, &err,
switch_core_session_get_pool(m_fsSession));
switch_channel_set_flag(m_fsChannel, CF_FS_RTP);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "AUDIO RTP REPORTS ERROR: [%s]\n", switch_str_nil(err));
- switch_channel_hangup(m_fsChannel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+ switch_channel_hangup(m_fsChannel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
switch_mutex_unlock(tech_pvt->h323_mutex);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_unlock\n");
return SWITCH_STATUS_FALSE;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->External RTP address %s:%u\n",(const char*)m_RTPremoteIP,m_RTPremotePort);
-
+
if (GetDirection() == IsReceiver) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_io_mutex_lock\n");
switch_mutex_lock(tech_pvt->h323_io_mutex);
switch_mutex_unlock(tech_pvt->h323_io_mutex);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_io_mutex_unlock\n");
}
-
+
if (m_conn->m_rtp_resetting) {
if (GetDirection() == IsReceiver) {
switch_core_session_unlock_codec_read(m_fsSession);
switch_core_session_unlock_codec_write(m_fsSession);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_session_unlock_codec_write [%p]\n",m_fsSession);
if (m_conn->m_callOnPreAnswer) {
- switch_core_session_unlock_codec_read(m_fsSession);
+ switch_core_session_unlock_codec_read(m_fsSession);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_session_unlock_codec_read [%p]\n",m_fsSession);
}
}
}
-
+
if (GetDirection() == IsReceiver)
m_conn->m_rxAudioOpened.Signal();
else
- m_conn->m_txAudioOpened.Signal();
-
+ m_conn->m_txAudioOpened.Signal();
+
if (m_conn->m_ChannelAnswer && m_conn->m_rxChannel && m_conn->m_txChannel)
switch_channel_mark_answered(m_fsChannel);
-
+
if ((m_conn->m_ChannelProgress && m_conn->m_rxChannel)||(m_conn->m_callOnPreAnswer && m_conn->m_txChannel))
switch_channel_mark_pre_answered(m_fsChannel);
if (m_capability->GetMainType() == H323Capability::e_Data && m_conn->m_rxChannel && m_conn->m_txChannel) {
- const char *uuid = switch_channel_get_partner_uuid(m_fsChannel);
+ const char *uuid = switch_channel_get_partner_uuid(m_fsChannel);
if (uuid != NULL){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------------->switch_rtp_udptl_mode\n");
switch_rtp_udptl_mode(tech_pvt->rtp_session);
PBoolean FSH323_ExternalRTPChannel::OnReceivedPDU(const H245_H2250LogicalChannelParameters& param, unsigned& errorCode)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323_ExternalRTPChannel::OnReceivedPDU [%p]\n",this);
-
+
if (!H323_ExternalRTPChannel::OnReceivedPDU(param,errorCode))
return true;
PIPSocket::Address remoteIpAddress;
FSH323Connection * FSH323EndPoint::FSMakeCall(const PString & dest, void *userData)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323EndPoint::FSMakeCall DST NUMBER = %s [%p]\n",(const char*)dest,this);
-
+
FSH323Connection * connection;
PString token;
H323Transport *transport = NULL;
-
+
if (listeners.GetSize() > 0) {
H323TransportAddress taddr = listeners[0].GetTransportAddress();
PIPSocket::Address addr;
WORD port;
- if (taddr.GetIpAndPort(addr, port)) {
+ if (taddr.GetIpAndPort(addr, port)) {
if (addr) {
transport = new H323TransportTCP(*this, addr,false);
- if (!transport)
+ if (!transport)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"----> Unable to create transport for outgoing call\n");
}
} else
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"----> Unable to get address and port\n");
}
-
+
if (!(connection = (FSH323Connection *)H323EndPoint::MakeCall(dest, token, userData))) {
return NULL;
}
switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>create_outgoing_channel DST NUMBER = %s\n",outbound_profile->destination_number);
-
+
FSH323Connection * connection;
if (h323_process == NULL) {
return SWITCH_CAUSE_CRASH;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>on_destroy\n");
h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_get_private(session);
-
+
if (tech_pvt) {
if (tech_pvt->read_codec.implementation) {
switch_core_codec_destroy(&tech_pvt->read_codec);
FSH323Connection *me = tech_pvt->me;
FSH323EndPoint & ep = h323_process->GetH323EndPoint();
tech_pvt->me = NULL;
-
+
if (me) {
if (me->m_rtp_resetting == 1) {
switch_core_session_unlock_codec_read(session);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"-----> () = %d\n",trylock);
if (trylock == 1) {
const PString currentToken(tech_pvt->token);
- FSH323Connection *connection = (FSH323Connection *)me->GetEndPoint()->FindConnectionWithLock(currentToken);
+ FSH323Connection *connection = (FSH323Connection *)me->GetEndPoint()->FindConnectionWithLock(currentToken);
if (connection) {
connection->Unlock();
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"-----> connection->UnLock()\n");
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "H323 connection was cleared successfully\n");
-
+
return SWITCH_STATUS_SUCCESS;
}
-/*
+/*
* H323 endpoint interface for Freeswitch Modular Media Switching Software Library /
* Soft-Switch Application
*
* License.
*
* Contributor(s):
- *
- *
- *
+ *
+ *
+ *
*
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
"ExtendVideo",
"GenericControl",
"ConferenceControl",
- "NumMainTypes"
+ "NumMainTypes"
};
extern void SetT38_IFP_PRE();
class OpalMediaFormat;
class H245_T38FaxProfile;
-class OpalT38Protocol;
+class OpalT38Protocol;
extern const OpalMediaFormat & GetOpalT38_IFP_COR();
extern const OpalMediaFormat & GetOpalT38_IFP_PRE();
switch_status_t name(type1 name1, type2 name2, type3 name3)
class FSH323EndPoint;
-class FSProcess:public PLibraryProcess {
+class FSProcess:public PLibraryProcess {
PCLASSINFO(FSProcess, PLibraryProcess);
public:
switch_endpoint_interface_t *GetSwitchInterface() const {
return m_freeswitch;
- }
+ }
FSH323Connection *FSMakeCall(const PString & dest, void *userData);
list < FSListener > m_listeners;
int m_ai;
const H245_MultiplexCapability * muxCap, H245_TerminalCapabilitySetReject & reject);
switch_core_session_t *GetSession() const {
return m_fsSession;
- }
+ }
FSH323EndPoint* GetEndPoint() const{
return m_endpoint;
}
virtual void OnUserInputTone(char, unsigned, unsigned, unsigned);
virtual void OnUserInputString(const PString & value);
void CleanUpOnCall();
-
+
DECLARE_CALLBACK0(on_init);
DECLARE_CALLBACK0(on_routing);
DECLARE_CALLBACK0(on_execute);
public:
BaseG7231Capab(const char *fname, bool annexA = true)
: H323AudioCapability(7, 4), m_name(fname), m_aa(annexA) {
- }
+ }
virtual PObject *Clone() const {
return new BaseG7231Capab(*this);
- }
+ }
virtual unsigned GetSubType() const {
return H245_AudioCapability::e_g7231;
- }
+ }
virtual PString GetFormatName() const {
return m_name;
- }
+ }
virtual H323Codec *CreateCodec(H323Codec::Direction direction) const {
return 0;
- }
+ }
virtual Comparison Compare(const PObject & obj) const {
Comparison res = H323AudioCapability::Compare(obj);
if (res != EqualTo)
if (m_aa && !aa)
return GreaterThan;
return EqualTo;
- }
+ }
virtual bool OnSendingPDU(H245_AudioCapability & pdu, unsigned packetSize) const {
pdu.SetTag(GetSubType());
H245_AudioCapability_g7231 & g7231 = pdu;
public:
BaseG729Capab(const char *fname, unsigned type = H245_AudioCapability::e_g729)
: H323AudioCapability(24, 6), m_name(fname), m_type(type) {
- }
+ }
virtual PObject *Clone() const
{
return new BaseG729Capab(*this);
}
virtual H323Codec *CreateCodec(H323Codec::Direction direction) const {
return 0;
- }
+ }
protected:
const char *m_name;
unsigned m_type;
BaseGSM0610Cap(const char *fname, unsigned type = H245_AudioCapability::e_gsmFullRate)
: H323AudioCapability(24, 2), m_name(fname), m_type(type), m_comfortNoise(0), m_scrambled(0) {
- }
+ }
virtual PObject *Clone() const {
return new BaseGSM0610Cap(*this);
}
virtual PObject * Clone() const {
return new FSH323_T38Capability(*this);
}
- virtual PString GetFormatName() const {
- return mediaFormat;
+ virtual PString GetFormatName() const {
+ return mediaFormat;
}
virtual H323Channel * CreateChannel(
H323Connection & connection,
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Endpoint 1.0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-->
-
+
<channels>
<!-- Section for main configurations about channels. -->
<!--
Enable/disable sending DTMFs out-band as a way to pass detected DTMFs to
-FreeSWITCH. Needed if FreeSWITCH generates digits for us in bridge application
+FreeSWITCH. Needed if FreeSWITCH generates digits for us in bridge application
or is being used for IVR ("URA", in pt_BR).
(default = yes)
-->
<!--
-Defines the incoming context for calls on Passive Record boards (KPR). Some
+Defines the incoming context for calls on Passive Record boards (KPR). Some
wildcards are accepted, and described in the bottom of this file.
(default = khomp-DD-CC)
Set the low level tracing. DO NOT USE THIS UNLESS YOU WERE ADVISED TO DO SO.
Possible values (to set more than one, separate the values with comma):
-k3l - Enable the low level tracing of board's API.
+k3l - Enable the low level tracing of board's API.
If you are using 'kserver', this option will take no effect. For
- the k3l tracing to proceed, you will need to (re)start kserver
+ the k3l tracing to proceed, you will need to (re)start kserver
with 'debug' option. E.g. '#> kserver start -debug'.
rdsi - Enable ISDN low level debugging.
r2 - Enable r2 protocol low level debugging.
-->
<!--
-Enables/disables the use of sharp (#) as an end-of-number digit on FXS
+Enables/disables the use of sharp (#) as an end-of-number digit on FXS
channels for instant dialing. This does not affect special numbers which
-start on sharp, like #8 or #1.
-(default = yes)
+start on sharp, like #8 or #1.
+(default = yes)
<param name="fxs-sharp-dial" value="yes" />
-->
<!--
This is the delay time to really disconnect a channel after the disconnect
-event arrive. If a connect event comes up in this interval, then the
+event arrive. If a connect event comes up in this interval, then the
disconnection is ignored and the call keeps going on. Values in ms.
(default = 0)
-->
<!--
-When there is a request to indicate busy for an incoming KFXO call, the
+When there is a request to indicate busy for an incoming KFXO call, the
ringing channel is taken off hook and then placed on hook, so it now goes
to answered state and we can send audio throught the line.
-If the off/on hook time interval is too short, the PSTN may ignore it, and
+If the off/on hook time interval is too short, the PSTN may ignore it, and
keep the line in a ringing state. If it is too long, the call may be charged.
The option below defines the delay between the line being answered and being
disconnected, in miliseconds (from 50ms to 90000ms).
<param name="pstn" value="b0l0 + b1c38"/>
<param name="pstn" value="b0l0 + b1c38:from-pstn"/>
-You may define your own groups. In the example above, the group
+You may define your own groups. In the example above, the group
called pstn can be used in the bridge string as <action application="brigde" data="Khomp/Gpstn/..." />
or <action application="brigde" data="Khomp/Gpstn/..." />. As a result, the allocation string will be
replaced with the one associated with the group "pstn". This is the same
*
* Khomp development team
* Geovani Ricardo Wiedenhoft <grw.freeswitch (at) gmail.com>
- * Leonardo Lang <lang.freeswitch (at) gmail.com>
+ * Leonardo Lang <lang.freeswitch (at) gmail.com>
* Eduardo Nunes <eduardonunesp (at) gmail.com>
* Joao Mesquita <mesquita (at) khomp.com.br>
* Raul Fragoso <raulfragoso (at) gmail.com>
/**
\mainpage Khomp board Endpoint Module
-
+
\section Introduction
This module has been developed to make a nice, affordable brazilian board
called Khomp (http://www.khomp.com.br) compatible with FreeSWITCH.
LOG(ERROR, D("cr (Session is NULL)"));
return SWITCH_STATUS_FALSE;
}
-
+
tech_pvt = static_cast<Board::KhompPvt*>(switch_core_session_get_private(session));
if(!tech_pvt)
{
LOG(ERROR, D("cr (pvt is NULL)"));
return SWITCH_STATUS_FALSE;
}
-
+
DBG(FUNC, PVT_FMT(tech_pvt->target(), "c"));
try
- {
+ {
ScopedPvtLock lock(tech_pvt);
if(tech_pvt->freeState())
LOG(ERROR, D("cr (session is null)"))
return SWITCH_STATUS_FALSE;
}
-
+
Board::KhompPvt *tech_pvt = NULL;
tech_pvt = static_cast<Board::KhompPvt*>(switch_core_session_get_private(session));
switch_core_session_set_private(session, NULL);
tech_pvt->destroyAll();
-
+
DBG(FUNC, PVT_FMT(tech_pvt->target(), "r"));
return SWITCH_STATUS_SUCCESS;
}
while(true);
-
+
DBG(FUNC, PVT_FMT(tech_pvt->target(), "r (unable to lock!)"));
return SWITCH_STATUS_FALSE;
DBG(FUNC, D("r (session is null)"))
return SWITCH_STATUS_FALSE;
}
-/*
+/*
Board::KhompPvt *tech_pvt = NULL;
tech_pvt = static_cast<Board::KhompPvt*>(switch_core_session_get_private(session));
DBG(FUNC, D("r (pvt is null)"))
return SWITCH_STATUS_FALSE;
}
-
+
try
- {
+ {
ScopedPvtLock lock(tech_pvt);
*/
switch_core_session_set_private(session, NULL);
switch_status_t khompKill(switch_core_session_t *session, int sig)
{
- //DBG(FUNC,FMT("CHANNEL KILL, kill = %d") % sig)
+ //DBG(FUNC,FMT("CHANNEL KILL, kill = %d") % sig)
Board::KhompPvt *tech_pvt = NULL;
tech_pvt = static_cast<Board::KhompPvt*>(switch_core_session_get_private(session));
return SWITCH_STATUS_FALSE;
}
- switch (sig)
+ switch (sig)
{
case SWITCH_SIG_NONE:
DBG(FUNC, PVT_FMT(tech_pvt->target(), "CHANNEL KILL, NONE!"));
LOG(ERROR, D("pvt is NULL"));
return SWITCH_STATUS_FALSE;
}
-
+
DBG(FUNC, PVT_FMT(tech_pvt->target(), "c (%c)") % dtmf->digit);
try
}
if(tech_pvt->call()->_cadence != Board::KhompPvt::PLAY_VM_TONE)
- {
+ {
tech_pvt->stopCadence();
- }
+ }
}
if (!tech_pvt->_writer_frames.give((const char *)frame->data, (size_t)frame->datalen))
}
tech_pvt = static_cast<Board::KhompPvt*>(switch_core_session_get_private(session));
-
+
if(!tech_pvt)
{
LOG(ERROR, D("pvt is NULL"));
switch_status_t khompReceiveMessage(switch_core_session_t *session, switch_core_session_message_t *msg)
{
Board::KhompPvt *tech_pvt;
-
+
if(!session)
{
LOG(ERROR, D("session is NULL"));
LOG(ERROR, D("pvt is NULL"));
return SWITCH_STATUS_FALSE;
}
-
+
switch (msg->message_id) {
case SWITCH_MESSAGE_REDIRECT_AUDIO:
- DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_REDIRECT_AUDIO"));
+ DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_REDIRECT_AUDIO"));
break;
case SWITCH_MESSAGE_TRANSMIT_TEXT:
- DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_TRANSMIT_TEXT"));
+ DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_TRANSMIT_TEXT"));
break;
case SWITCH_MESSAGE_INDICATE_ANSWER:
- DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_ANSWER"));
+ DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_ANSWER"));
return khompAnswer(session);
break;
case SWITCH_MESSAGE_INDICATE_PROGRESS:
- DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_PROGRESS"));
+ DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_PROGRESS"));
tech_pvt->indicateProgress();
break;
case SWITCH_MESSAGE_INDICATE_BRIDGE:
- DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_BRIDGE"));
+ DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_BRIDGE"));
break;
case SWITCH_MESSAGE_INDICATE_UNBRIDGE:
- DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_UNBRIDGE"));
+ DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_UNBRIDGE"));
break;
case SWITCH_MESSAGE_INDICATE_TRANSFER:
- DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_TRANSFER"));
+ DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_TRANSFER"));
break;
case SWITCH_MESSAGE_INDICATE_RINGING:
- DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_RINGING"));
+ DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_RINGING"));
tech_pvt->indicateRinging();
break;
case SWITCH_MESSAGE_INDICATE_MEDIA:
- DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_MEDIA"));
+ DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_MEDIA"));
break;
case SWITCH_MESSAGE_INDICATE_NOMEDIA:
- DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_NOMEDIA"));
+ DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_NOMEDIA"));
break;
case SWITCH_MESSAGE_INDICATE_HOLD:
- DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_HOLD"));
+ DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_HOLD"));
break;
case SWITCH_MESSAGE_INDICATE_UNHOLD:
- DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_UNHOLD"));
+ DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_UNHOLD"));
break;
case SWITCH_MESSAGE_INDICATE_REDIRECT:
- DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_REDIRECT"));
+ DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_REDIRECT"));
break;
case SWITCH_MESSAGE_INDICATE_RESPOND:
- DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_RESPOND"));
+ DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_RESPOND"));
break;
case SWITCH_MESSAGE_INDICATE_BROADCAST:
- DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_BROADCAST"));
+ DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_BROADCAST"));
break;
case SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT:
- DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT"));
+ DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT"));
break;
case SWITCH_MESSAGE_INDICATE_DEFLECT:
- DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_DEFLECT"));
+ DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_DEFLECT"));
break;
case SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ:
- DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ"));
+ DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ"));
break;
case SWITCH_MESSAGE_INDICATE_DISPLAY:
- DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_DISPLAY"));
+ DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_DISPLAY"));
break;
case SWITCH_MESSAGE_INDICATE_TRANSCODING_NECESSARY:
- DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_TRANSCODING_NECESSARY"));
+ DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_TRANSCODING_NECESSARY"));
break;
case SWITCH_MESSAGE_INDICATE_AUDIO_SYNC:
- DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_AUDIO_SYNC"));
+ DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_AUDIO_SYNC"));
break;
case SWITCH_MESSAGE_INDICATE_REQUEST_IMAGE_MEDIA:
- DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_REQUEST_IMAGE_MEDIA"));
+ DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_REQUEST_IMAGE_MEDIA"));
break;
case SWITCH_MESSAGE_INDICATE_UUID_CHANGE:
- DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_UUID_CHANGE"));
+ DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_UUID_CHANGE"));
break;
case SWITCH_MESSAGE_INDICATE_SIMPLIFY:
- DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_SIMPLIFY"));
+ DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_SIMPLIFY"));
break;
case SWITCH_MESSAGE_INDICATE_DEBUG_MEDIA:
DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_DEBUG_MEDIA"));
break;
case SWITCH_MESSAGE_INDICATE_PROXY_MEDIA:
- DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_PROXY_MEDIA"));
+ DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_PROXY_MEDIA"));
break;
case SWITCH_MESSAGE_INDICATE_APPLICATION_EXEC:
- DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_APPLICATION_EXEC"));
+ DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_APPLICATION_EXEC"));
break;
case SWITCH_MESSAGE_INDICATE_APPLICATION_EXEC_COMPLETE:
- DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_APPLICATION_EXEC_COMPLETE"));
+ DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INDICATE_APPLICATION_EXEC_COMPLETE"));
break;
case SWITCH_MESSAGE_INVALID:
- DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INVALID"));
+ DBG(FUNC, PVT_FMT(tech_pvt->_target, "SWITCH_MESSAGE_INVALID"));
break;
default:
- DBG(FUNC, PVT_FMT(tech_pvt->_target, "unknown message received [%d].") % msg->message_id % (msg->from ? msg->from : 0));
+ DBG(FUNC, PVT_FMT(tech_pvt->_target, "unknown message received [%d].") % msg->message_id % (msg->from ? msg->from : 0));
break;
}
Board::KhompPvt *tech_pvt;
int cause = (int)SWITCH_CAUSE_NONE;
-
+
try
{
ScopedAllocLock alloc_lock;
{
tech_pvt->cleanup(Board::KhompPvt::CLN_HARD);
LOG(ERROR, PVT_FMT(tech_pvt->target(), "Initilization Error!"));
- return SWITCH_CAUSE_UNALLOCATED_NUMBER;
+ return SWITCH_CAUSE_UNALLOCATED_NUMBER;
}
tech_pvt->owner((session ? session : tech_pvt->session()));
}
alloc_lock.unlock();
-
+
tech_pvt->getSpecialVariables();
tech_pvt->setVolume();
-
+
if(tech_pvt->makeCall() != ksSuccess)
{
*new_session = NULL;
LOG(ERROR, D("pvt is NULL"));
return SWITCH_STATUS_FALSE;
}
-
- DBG(FUNC, PVT_FMT(tech_pvt->target(), "Receive Event id[%d] name[%s] body=[%s]") % event->event_id % event->headers->name % body);
+
+ DBG(FUNC, PVT_FMT(tech_pvt->target(), "Receive Event id[%d] name[%s] body=[%s]") % event->event_id % event->headers->name % body);
if (!body) {
body = (char *)"";
/* A simple idea of app */
SWITCH_STANDARD_APP(klogFunction)
{
- if (zstr(data))
+ if (zstr(data))
{
LOG(ERROR, D("No data specified"));
- }
- else
+ }
+ else
{
LOG(MESSAGE, FMT("KLOG: %s") % std::string(data));
}
return;
}
- if (zstr(data))
+ if (zstr(data))
{
LOG(ERROR, FMT("No %s specified") % variable);
return;
- }
+ }
if(strcasecmp(data, "on") && strcasecmp(data, "off"))
{
LOG(ERROR, D("Session is NULL"));
return;
}
-
+
Board::KhompPvt *tech_pvt = static_cast<Board::KhompPvt*>(switch_core_session_get_private(session));
if(!tech_pvt)
LOG(ERROR, D("Session is NULL"));
return;
}
-
+
Board::KhompPvt *tech_pvt = static_cast<Board::KhompPvt*>(switch_core_session_get_private(session));
LOG(ERROR, D("Session is NULL"));
return;
}
-
+
Board::KhompPvt *tech_pvt = static_cast<Board::KhompPvt*>(switch_core_session_get_private(session));
LOG(ERROR, D("pvt is NULL"));
return;
}
-
+
DBG(FUNC, PVT_FMT(tech_pvt->target(), "Application KReceiveFax"));
tech_pvt->application(FAX_RECEIVE, session, data);
LOG(ERROR, D("Session is NULL"));
return;
}
-
- if (zstr(data))
+
+ if (zstr(data))
{
LOG(ERROR, D("No number specified"));
return;
- }
+ }
Board::KhompPvt *tech_pvt = static_cast<Board::KhompPvt*>(switch_core_session_get_private(session));
DBG(FUNC, D("pvt is NULL"));
return;
}
-
+
DBG(FUNC, PVT_FMT(tech_pvt->target(), "Application KUserTransfer"));
tech_pvt->application(USER_TRANSFER, session, data);
return;
}
- if (zstr(data))
+ if (zstr(data))
{
LOG(ERROR, D("No KSetVolume specified"));
return;
- }
+ }
switch_channel_t *c = switch_core_session_get_channel(session);
ScopedPvtLock lock(tech_pvt);
alloc_lock.unlock();
-
+
tech_pvt->application(SMS_SEND, session, data);
}
}
if (zstr(data))
- {
+ {
LOG(ERROR, D("invalid number of arguments"));
return;
- }
+ }
int dev = -1;
int obj = -1;
std::string num("0");
if (params.size() == 3)
- {
+ {
dev = Strings::tolong(params[0]);
obj = Strings::tolong(params[1]);
num = params[2];
/* just check for validity */
(void)Strings::tolong(params[2]);
- }
+ }
else
{
LOG(ERROR, D("Invalid number of arguments!"));
return SWITCH_STATUS_FALSE;
}
- /* Two bodies can not occupy the same space at the same time */
+ /* Two bodies can not occupy the same space at the same time */
if(switch_loadable_module_exists("mod_kommuter") == SWITCH_STATUS_SUCCESS)
- {
+ {
LOG(ERROR, D("Kommuter module for FreeSWITCH is already loaded."));
return SWITCH_STATUS_FALSE;
- }
+ }
//TODO: must put the autorevision variable here
LOG(MESSAGE, "loading Khomp module");
Globals::khomp_sms_endpoint_interface->interface_name = "khomp_SMS";
Globals::khomp_sms_endpoint_interface->io_routines = &khomp_sms_io_routines;
Globals::khomp_sms_endpoint_interface->state_handler = &khomp_sms_state_handlers;
-
+
Globals::khomp_pr_endpoint_interface = static_cast<switch_endpoint_interface_t*>(switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE));
Globals::khomp_pr_endpoint_interface->interface_name = "khomp_PR";
Globals::khomp_pr_endpoint_interface->io_routines = &khomp_pr_io_routines;
/* Register cli commands */
Cli::registerCommands(apiKhomp,module_interface);
-
+
ESL::registerEvents();
/* Add applications */
SWITCH_ADD_APP(Globals::khomp_app_inteface, "KAutoGainControl", "KAutoGainControl", "KAutoGainControl", kautoGainControlFunction, "on|off", SAF_SUPPORT_NOMEDIA);
SWITCH_ADD_APP(Globals::khomp_app_inteface, "KSetVolume", "KSetVolume", "KSetVolume", ksetVolumeFunction, "value|value", SAF_SUPPORT_NOMEDIA);
SWITCH_ADD_APP(Globals::khomp_app_inteface, "KR2SendCondition", "KR2SendCondition", "KR2SendCondition", kr2SendConditionFunction, "value|value", SAF_SUPPORT_NOMEDIA);
-
+
SWITCH_ADD_APP(Globals::khomp_app_inteface, "KAdjustForFax", "KAdjustForFax", "KAdjustForFax", kadjustForFaxFunction, "", SAF_SUPPORT_NOMEDIA);
SWITCH_ADD_APP(Globals::khomp_app_inteface, "KSendFax", "KSendFax", "KSendFax", ksendFaxFunction, "<infilename>[:<infilename2>[:...]][|<faxid>]", SAF_SUPPORT_NOMEDIA);
SWITCH_ADD_APP(Globals::khomp_app_inteface, "KReceiveFax", "KReceiveFax", "KReceiveFax", kreceiveFaxFunction, "<outfilename>[|<faxid>]", SAF_SUPPORT_NOMEDIA);
-
+
SWITCH_ADD_APP(Globals::khomp_app_inteface, "KUserTransfer", "KUserTransfer", "KUserTransfer", kUserTransferFunction, "number", SAF_SUPPORT_NOMEDIA);
-
+
SWITCH_ADD_APP(Globals::khomp_app_inteface, "KSendSMS", "KSendSMS", "KSendSMS", kSendSMSFunction, "resource|destination|message", SAF_SUPPORT_NOMEDIA);
SWITCH_ADD_APP(Globals::khomp_app_inteface, "KSelectSimCard", "KSelectSimCard", "KSelectSimCard", kSelectSimCardFunction, "<board>|<channel>|<sim_card>", SAF_SUPPORT_NOMEDIA);
Board::kommuter.stop();
Cli::unregisterCommands();
-
+
ESL::unregisterEvents();
Board::finalizeHandlers();
Board::finalize();
-
+
DBG(FUNC, "Successfully Unloaded mod_khomp")
K::Logger::stop();
{
try
{
-
+
//If NULL get throws K3LAPITraits::invalid_channel exception.
Board::KhompPvt * pvt = Board::get(deviceid, objectid);
DBG(STRM, PVT_FMT(pvt->target(), "Stream not enabled, skipping write..."));
return;
}
-
+
/* will be used below for CM_ADD_STREAM_BUFFER */
struct
{
size_t size;
}
write_packet = { (const byte *)0, 0 };
-
+
/* push audio from the write buffer */
switch_frame_t * fr = pvt->_writer_frames.pick();
KHOMP generic endpoint/channel library.
Copyright (C) 2007-2010 Khomp Ind. & Com.
- The contents of this file are subject to the Mozilla Public License
- Version 1.1 (the "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
+ The contents of this file are subject to the Mozilla Public License
+ Version 1.1 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
case the provisions of "LGPL License" are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
- the LGPL License and not to allow others to use your version of this file
- under the MPL, indicate your decision by deleting the provisions above and
- replace them with the notice and other provisions required by the LGPL
- License. If you do not delete the provisions above, a recipient may use your
+ the LGPL License and not to allow others to use your version of this file
+ under the MPL, indicate your decision by deleting the provisions above and
+ replace them with the notice and other provisions required by the LGPL
+ License. If you do not delete the provisions above, a recipient may use your
version of this file under either the MPL or the LGPL License.
The LGPL header follows below:
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with this library; if not, write to the Free Software Foundation,
+ along with this library; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*******************************************************************************/
{
/* Don't worry, let the man work */
DBG(FUNC, PVT_FMT(_pvt->target(),"Channel is now being adjusted for fax!"));
-
+
try
{
ScopedPvtLock lock(_pvt);
ScopedPvtLock lock(_pvt);
std::string id;
-
+
if(fax_args.size() == 2)
{
id = fax_args[1];
if(!_pvt->call()->_flags.check(Kflags::REALLY_CONNECTED) && !_pvt->loopWhileFlagTimed(Kflags::REALLY_CONNECTED, timeout, false))
return false;
-
+
if(!startFaxTX(orig_addr))
{
LOG(ERROR, PVT_FMT(_pvt->target(), "r (unable to start send fax)"));
% fax_files[i].c_str());
}
}
-
+
_fax_cond.reset();
lock.unlock();
_fax_cond.wait();
-
+
switch_channel_set_variable(channel, "KFaxSent", ((_fax_result == kfaxrEndOfTransmission) ? "yes" : "no"));
switch_channel_set_variable(channel, "KFaxResult", (Verbose::faxResult((KFaxResult)_fax_result).c_str()));
LOG(ERROR, PVT_FMT(_pvt->target(), "r (unable to start receive fax)"));
return false;
}
-
+
_fax_cond.reset();
lock.unlock();
LOG(ERROR, PVT_FMT(_pvt->target(), "r (%s)") % err._msg.c_str());
return false;
}
-
+
DBG(FUNC, PVT_FMT(_pvt->target(), "r"));
return true;
if(!caller_profile)
{
- _pvt->destroy(session);
+ _pvt->destroy(session);
LOG(ERROR, PVT_FMT(_pvt->target(), "r (Cannot create caller profile)"));
return false;
}
switch_channel_set_name(channel, name.c_str());
switch_channel_set_caller_profile(channel, caller_profile);
-
+
//DBG(FUNC, PVT_FMT(_pvt->target(), "Connect inbound SMS channel %s") % name.c_str());
switch_channel_set_state(channel, CS_INIT);
_owners.push_front(session);
}
-
+
return true;
}
DBG(FUNC, PVT_FMT(_pvt->target(), "(SMS) c"));
volatile bool finished = false;
- volatile KGsmCallCause result = kgccNone;
+ volatile KGsmCallCause result = kgccNone;
try
{
conf = true;
}
- // get options/values
-
+ // get options/values
+
_send_sms._dest = dest;
_send_sms._conf = conf;
_send_sms._body = sms_args[2];
if(status)
_cond.signal();
-
+
while (!finished)
{
usleep(200000);
{
LOG(ERROR, PVT_FMT(_pvt->target(), "unable to receive SMS from '%s', something wrong!") % _got_sms._from);
LOG(ERROR, PVT_FMT(_pvt->target(), "disabling SMS processing to prevent messages from being lost."));
-
+
_can_receive = false;
}
}
}
-
+
if(_can_receive)
{
/* stats update! */
statistics<SMSStatistics>()->incrementBroadcast();
}
}
-
+
/* reset data stuff */
_got_sms.clear();
}
int SMS::smsThread(void * sms_ptr)
{
SMS * sms = static_cast < SMS * > (sms_ptr);
-
+
Board::KhompPvt * pvt = static_cast < Board::KhompPvt * > (sms->_pvt);
DBG(THRD, PVT_FMT(pvt->target(), "c"));
{
sms->_result = kgccInvalidMessage;
}
-
+
pvt->call()->_flags.clear(Kflags::SMS_DOING_UPLOAD);
if (request_sms._cause)
KHOMP generic endpoint/channel library.
Copyright (C) 2007-2010 Khomp Ind. & Com.
- The contents of this file are subject to the Mozilla Public License
- Version 1.1 (the "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
+ The contents of this file are subject to the Mozilla Public License
+ Version 1.1 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
case the provisions of "LGPL License" are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
- the LGPL License and not to allow others to use your version of this file
- under the MPL, indicate your decision by deleting the provisions above and
- replace them with the notice and other provisions required by the LGPL
- License. If you do not delete the provisions above, a recipient may use your
+ the LGPL License and not to allow others to use your version of this file
+ under the MPL, indicate your decision by deleting the provisions above and
+ replace them with the notice and other provisions required by the LGPL
+ License. If you do not delete the provisions above, a recipient may use your
version of this file under either the MPL or the LGPL License.
The LGPL header follows below:
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with this library; if not, write to the Free Software Foundation,
+ along with this library; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*******************************************************************************/
/* khomp show channels */
if(ARG_CMP(1, "channels"))
return EXEC_CLI_CMD(Cli::KhompShowChannels);
-
+
/* khomp show links */
if(ARG_CMP(1, "links"))
return EXEC_CLI_CMD(Cli::KhompShowLinks);
if(ARG_CMP(1, "statistics"))
return EXEC_CLI_CMD(Cli::KhompClearStatistics);
}
-
+
/* khomp dump */
else if(ARG_CMP(0, "dump"))
{
if(ARG_CMP(1, "config"))
return EXEC_CLI_CMD(Cli::KhompDumpConfig);
}
-
+
/* khomp reset */
else if(ARG_CMP(0, "reset"))
{
return EXEC_CLI_CMD(Cli::KhompResetLinks);
}
-
+
/* khomp sms */
else if(ARG_CMP(0, "sms"))
{
if(ARG_CMP(1, "raw"))
return EXEC_CLI_CMD(Cli::KhompSendRawCommand);
}
-
+
/* khomp select */
else if(ARG_CMP(0, "select"))
{
{
if(ARG_CMP(1, "on") || ARG_CMP(1, "off"))
return EXEC_CLI_CMD(Cli::KhompKommuterOnOff);
-
+
if(ARG_CMP(1, "count"))
return EXEC_CLI_CMD(Cli::KhompKommuterCount);
}
-
+
/* if everything fails, i'm here to support */
printKhompUsage();
-
+
return false;
}
Cli::OutputType output_type = Cli::VERBOSE;
if(ARG_CMP(1, "concise")) output_type = Cli::CONCISE;
- if(ARG_CMP(1, "xml"))
+ if(ARG_CMP(1, "xml"))
{
output_type = Cli::XML;
createRoot("summary");
}
-
+
class_type classe = ( !_on_cli_term ? C_MESSAGE : C_CLI );
K3L_API_CONFIG apiCfg;
{
/* summary/k3lapi */
switch_xml_t xk3lapi = switch_xml_add_child_d(root, "k3lapi",0);
-
+
/* summary/k3lapi/version */
switch_xml_t xk3l_version = switch_xml_add_child_d(xk3lapi,"version", 0);
switch_xml_set_attr_d(xk3l_version,"major",STR(FMT("%d") % apiCfg.MajorVersion));
{
if (output_type == Cli::VERBOSE)
K::Logger::Logg2(classe,stream, " ------------------------------------------------------------------");
-
+
if (output_type == Cli::XML)
{
printXMLOutput(stream);
/* boards/board/general */
switch_xml_t xgeneral = switch_xml_add_child_d(xdev,"general",0);
-
+
/* boards/board/general/type */
switch_xml_t xtype = switch_xml_add_child_d(xgeneral,"type",0);
switch_xml_set_txt_d(xtype,tipo.c_str());
/* boards/board/hardware/dsps */
switch_xml_t xdsps = switch_xml_add_child_d(xhardware,"dsps",0);
-
+
/* boards/board/hardware/dsps/dsp (0) */
switch_xml_t xdsp0 = switch_xml_add_child_d(xdsps,"dsp",0);
switch_xml_set_attr_d(xdsp0,"id","0");
/* boards/board/general */
switch_xml_t xgeneral = switch_xml_add_child_d(xdev,"general",0);
-
+
/* boards/board/general/type */
switch_xml_t xtype = switch_xml_add_child_d(xgeneral,"type",0);
switch_xml_set_txt_d(xtype,tipo.c_str());
/* boards/hardware */
switch_xml_t xhardware = switch_xml_add_child_d(xdev,"hardware",0);
-
+
/* boards/board/hardware/dsps */
switch_xml_t xdsps = switch_xml_add_child_d(xhardware,"dsps",0);
/* boards/board/general */
switch_xml_t xgeneral = switch_xml_add_child_d(xdev,"general",0);
-
+
/* boards/board/general/type */
switch_xml_t xtype = switch_xml_add_child_d(xgeneral,"type",0);
switch_xml_set_txt_d(xtype,tipo.c_str());
K::Logger::Logg2(classe, stream, FMT("| * DSP: %s - %s%s|")
% dspCfg.DspVersion % dspCfg.FwVersion
% std::string(std::max<int>(55 - size, 0), ' '));
-
+
} break;
case Cli::CONCISE:
/* boards/board/general */
switch_xml_t xgeneral = switch_xml_add_child_d(xdev,"general",0);
-
+
/* boards/board/general/type */
switch_xml_t xtype = switch_xml_add_child_d(xgeneral,"type",0);
switch_xml_set_txt_d(xtype,tipo.c_str());
/* boards/board/hardware */
switch_xml_t xhardware = switch_xml_add_child_d(xdev,"hardware",0);
-
+
/* boards/board/hardware/dsps */
switch_xml_t xdsps = switch_xml_add_child_d(xhardware,"dsps",0);
if (output_type == Cli::VERBOSE)
K::Logger::Logg2(classe,stream, " ------------------------------------------------------------------");
-
+
if (output_type == Cli::XML)
{
printXMLOutput(stream);
return false;
}
- int device = argv[2] ? atoi(argv[2]) : -1;
- int object = argv[3] ? atoi(argv[3]) : -1;
+ int device = argv[2] ? atoi(argv[2]) : -1;
+ int object = argv[3] ? atoi(argv[3]) : -1;
int d = -1;
int o = -1;
if (device != -1)
- {
+ {
d = device;
if (!Globals::k3lapi.valid_device(d))
- {
+ {
K::Logger::Logg2(C_CLI, stream, FMT("ERROR: No such device %d!") % d);
return false;
- }
- }
+ }
+ }
if (object != -1)
- {
+ {
o = object;
if (!Globals::k3lapi.valid_channel(d,o))
- {
+ {
K::Logger::Logg2(C_CLI, stream, FMT("ERROR: No such chanel %d for device %d!") % o % d);
return false;
- }
- }
+ }
+ }
/* keep the channels reponse */
std::string buffer("");
try
{
/**/ if (d != -1 && o != -1)
- {
+ {
showCalls(d,o,buffer);
- }
+ }
else if (d != -1 && o == -1)
- {
- for (unsigned int i = 0; i < Globals::k3lapi.channel_count(d); i++)
- {
+ {
+ for (unsigned int i = 0; i < Globals::k3lapi.channel_count(d); i++)
+ {
buffer += " ------------------------------------------------------------------------\n";
showCalls(d,i,buffer);
- }
- }
+ }
+ }
else if (d == -1 && o == -1)
- {
- for (unsigned int i = 0; i < Globals::k3lapi.device_count(); i++)
- {
+ {
+ for (unsigned int i = 0; i < Globals::k3lapi.device_count(); i++)
+ {
buffer += " ------------------------------------------------------------------------\n";
for (unsigned int j = 0; j < Globals::k3lapi.channel_count(i); j++)
{
showCalls(i,j,buffer);
}
- }
+ }
}
}
catch(K3LAPITraits::invalid_channel & err)
catch (ScopedLockFailed & err)
{
K::Logger::Logg2(C_CLI,stream,FMT("error: channel %d at device %d could not be locked: %s!")
- % channel
+ % channel
% device
% err._msg.c_str());
}
}
switch (argc)
- {
+ {
case 3:
- {
+ {
if (!ARG_CMP(2, "all"))
- {
+ {
K::Logger::Logg2(C_CLI, stream, "usage: khomp channels disconnect < all | <boardid> < all | <channelid> > >");
return false;
- }
+ }
K::Logger::Logg2(C_CLI, stream, "NOTICE: Disconnecting all channels on all boards!");
for (unsigned int dev = 0; dev < Globals::k3lapi.device_count(); dev++)
- {
+ {
for (unsigned int chan = 0; chan < Globals::k3lapi.channel_count(dev); chan++)
forceDisconnect(dev,chan);
- }
+ }
break;
- }
+ }
case 4:
- {
+ {
unsigned int dev = atoi(argv[2]);
if (ARG_CMP(3, "all"))
- {
+ {
K::Logger::Logg2(C_CLI, stream, FMT("NOTICE: Disconnecting all channels on board %d!") % dev);
for (unsigned int chan = 0; chan < Globals::k3lapi.channel_count(dev); chan++)
forceDisconnect(dev,chan);
- }
+ }
unsigned int channel = atoi(argv[3]);
if (dev >= Globals::k3lapi.device_count())
- {
+ {
K::Logger::Logg2(C_CLI, stream, FMT("ERROR: No such device: %d!") % dev);
return false;
- }
+ }
+
-
K::Logger::Logg2(C_CLI, stream, FMT("NOTICE: Disconnecting channel %d on board %d!") % channel % dev);
forceDisconnect(dev,channel);
break;
- }
+ }
default:
break;
- }
+ }
return true;
}
bool Cli::_KhompChannelsUnblock::execute(int argc, char *argv[])
{
if (argc != 4 && argc != 3)
- {
+ {
printUsage(stream);
return false;
- }
+ }
switch (argc)
- {
+ {
case 3:
- {
+ {
K::Logger::Logg2(C_CLI, stream, "NOTICE: Unblocking all channels on all devices!");
for (unsigned int dev = 0; dev < Globals::k3lapi.device_count(); dev++)
- {
+ {
for (unsigned int chan = 0; chan < Globals::k3lapi.channel_count(dev); chan++)
- {
+ {
try
{
Globals::k3lapi.command(dev,chan,CM_UNLOCK_INCOMING);
catch(K3LAPI::failed_command &e)
{
if (K::Logger::Logg.classe(C_WARNING).enabled())
- {
+ {
LOG(WARNING, FMT("Command '%s' has failed with error '%s'.")
% Verbose::commandName(e.code) % Verbose::status((KLibraryStatus)e.rc));
- }
+ }
return false;
}
- }
- }
+ }
+ }
break;
- }
+ }
case 4:
- {
+ {
int dev = atoi (argv[2]);
if ( !SAFE_strcasecmp(argv[3], "all") )
- {
+ {
if (!Globals::k3lapi.valid_device( dev ))
- {
+ {
K::Logger::Logg2(C_CLI, stream, FMT("ERROR: Unable to find device: %d!") % dev );
return false;
- }
+ }
K::Logger::Logg2(C_CLI, stream, FMT("NOTICE: Unblocking all channels on device %d!") % dev);
- for (unsigned int i = 0; i < Globals::k3lapi.channel_count(dev); i++)
+ for (unsigned int i = 0; i < Globals::k3lapi.channel_count(dev); i++)
{
try
{
catch(K3LAPI::failed_command &e)
{
if (K::Logger::Logg.classe(C_WARNING).enabled())
- {
+ {
LOG(WARNING, FMT("Command '%s' has failed with error '%s'.")
% Verbose::commandName(e.code) % Verbose::status((KLibraryStatus)e.rc));
- }
+ }
return false;
}
}
- }
- else
- {
+ }
+ else
+ {
int obj = atoi (argv[3]);
if (!Globals::k3lapi.valid_channel(dev, obj))
- {
+ {
K::Logger::Logg2(C_CLI, stream, FMT("ERROR: No such channel %d at device %d!") % obj % dev);
return false;
- }
+ }
K::Logger::Logg2(C_CLI, stream, FMT("NOTICE: Unblocking channel %d on device %d!") % obj % dev);
catch(K3LAPI::failed_command &e)
{
if (K::Logger::Logg.classe(C_WARNING).enabled())
- {
+ {
LOG(WARNING, FMT("Command '%s' has failed with error '%s'.")
% Verbose::commandName(e.code) % Verbose::status((KLibraryStatus)e.rc));
- }
+ }
return false;
}
- }
+ }
break;
- }
+ }
default:
break;
- }
-
+ }
+
return true;
}
{
K::Logger::Logg2(C_CLI, stream, FMT("ERROR: Unable to find channel %d on device %d!") % err.object % err.device );
}
- }
+ }
}
void Cli::_KhompShowStatistics::cliDetailedStatistics(unsigned int device, unsigned int channel, OutputType output_type)
bool Cli::_KhompShowStatistics::execute(int argc, char *argv[])
{
- if (argc < 2 || argc > 5)
+ if (argc < 2 || argc > 5)
{
printUsage(stream);
return false;
unsigned int dev = UINT_MAX;
unsigned int obj = UINT_MAX;
- int detailed = 0, verbose = 0, as_xml = 0;
+ int detailed = 0, verbose = 0, as_xml = 0;
OutputType output_type = Cli::VERBOSE;
- detailed = ((argc > 2) && (!strcasecmp(argv[2], "detailed")) ? 1 : 0 );
- verbose = ((argc > 2) && (!strcasecmp(argv[2], "verbose")) ? 1 : 0 );
- as_xml = ((argc > 2) && (!strcasecmp(argv[2], "xml")) ? 1 : 0 );
+ detailed = ((argc > 2) && (!strcasecmp(argv[2], "detailed")) ? 1 : 0 );
+ verbose = ((argc > 2) && (!strcasecmp(argv[2], "verbose")) ? 1 : 0 );
+ as_xml = ((argc > 2) && (!strcasecmp(argv[2], "xml")) ? 1 : 0 );
- try
- {
+ try
+ {
if(argc > (2+detailed+verbose+as_xml))
{
dev = Strings::tolong(argv[2+detailed+verbose+as_xml]);
if (!Globals::k3lapi.valid_device(dev))
- {
+ {
K::Logger::Logg2(C_CLI, stream, "ERROR: No such device!");
return false;
- }
+ }
}
if (argc > (3+detailed+verbose+as_xml))
- {
+ {
std::string object(argv[3+detailed+verbose+as_xml]);
obj = Strings::tolong(object);
if (!Globals::k3lapi.valid_channel(dev, obj))
- {
+ {
K::Logger::Logg2(C_CLI, stream, FMT("ERROR: Unable to find channel %d on device %d!") % obj % dev );
return false;
- }
+ }
}
- }
+ }
catch (Strings::invalid_value e)
- {
+ {
K::Logger::Logg2(C_CLI, stream, "ERROR: Invalid numeric value!");
return false;
}
if(detailed) output_type = Cli::DETAILED;
- if(as_xml)
+ if(as_xml)
{
createRoot("statistics");
output_type = Cli::XML;
}
-
+
std::string header;
header.append( " ------------------------------------------------------------------------------------\n");
header.append( "|----------------------------- Khomp Endpoint Statistics ----------------------------|\n");
ScopedPvtLock lock(pvt);
std::string tmp_call = Globals::k3lutil.callStatus(
- pvt->target().device,
- pvt->target().object,
+ pvt->target().device,
+ pvt->target().object,
(output_type == Cli::CONCISE ? Verbose::EXACT : Verbose::HUMAN));
std::string tmp_chan = Globals::k3lutil.channelStatus(
- pvt->target().device,
- pvt->target().object,
+ pvt->target().device,
+ pvt->target().object,
(output_type == Cli::CONCISE ? Verbose::EXACT : Verbose::HUMAN));
case Cli::VERBOSE:
{
if (pvt->getSignaling() == ksigGSM)
- {
+ {
K3L_GSM_CHANNEL_STATUS gsmStatus;
if (k3lGetDeviceStatus(device, channel + ksoGsmChannel, &gsmStatus, sizeof(gsmStatus)) != ksSuccess)
std::string tmp_antenna_level;
- for (unsigned int i = 0; i < sign_size; i++)
- tmp_antenna_level += '*';
+ for (unsigned int i = 0; i < sign_size; i++)
+ tmp_antenna_level += '*';
- for (unsigned int i = sign_size; i < full_size; i++)
- tmp_antenna_level += ' ';
+ for (unsigned int i = sign_size; i < full_size; i++)
+ tmp_antenna_level += ' ';
tmp_chan += " (";
tmp_chan += (strlen(gsmStatus.OperName) != 0 ? gsmStatus.OperName : "...");
- tmp_chan += ")";
+ tmp_chan += ")";
K::Logger::Logg2(C_CLI, stream, FMT("| %d,%02d | %8s | %8s | %-23s | %02d%% |%s|")
% device % channel % pvt->getStateString() % tmp_call % tmp_chan
% sign_numb % tmp_antenna_level);
- }
- else
- {
+ }
+ else
+ {
K::Logger::Logg2(C_CLI, stream, FMT("| %d,%02d | %8s | %8s | %-40s |")
% device % channel % pvt->getStateString() % tmp_call % tmp_chan);
- }
+ }
} break;
- case Cli::CONCISE:
+ case Cli::CONCISE:
{
std::string state = pvt->getStateString();
if (pvt->getSignaling() == ksigGSM)
- {
+ {
K3L_GSM_CHANNEL_STATUS gsmStatus;
if (k3lGetDeviceStatus(device, channel + ksoGsmChannel, &gsmStatus, sizeof(gsmStatus)) != ksSuccess)
K::Logger::Logg2(C_CLI, stream, FMT("B%02dC%02d:%s:%s:%s:%d%%:%s")
% device % channel % state % tmp_call % tmp_chan
% sign_numb % gsm_registry);
- }
- else
- {
+ }
+ else
+ {
K::Logger::Logg2(C_CLI, stream, FMT("B%02dC%02d:%s:%s:%s")
% device % channel % state % tmp_call % tmp_chan);
- }
+ }
} break;
/* device/channel/fs_state */
switch_xml_t xstate = switch_xml_add_child_d(xchannel,"fs_state",0);
switch_xml_set_txt_d(xstate, pvt->getStateString().c_str());
-
+
/* device/channel/call */
switch_xml_t xcall = switch_xml_add_child_d(xchannel,"call",0);
switch_xml_set_txt_d(xcall, tmp_call.c_str());
switch_xml_set_txt_d(xstatus, tmp_chan.c_str());
if (pvt->getSignaling() == ksigGSM)
- {
+ {
K3L_GSM_CHANNEL_STATUS gsmStatus;
if (k3lGetDeviceStatus(device, channel + ksoGsmChannel, &gsmStatus, sizeof(gsmStatus)) != ksSuccess)
/* device/channel/registry */
switch_xml_t xgsm_registry = switch_xml_add_child_d(xchannel, "registry", 9);
switch_xml_set_txt_d(xgsm_registry, gsm_registry.c_str());
- }
-
+ }
+
} break;
default:
- /* do nothing */
+ /* do nothing */
break;
}
- }
+ }
catch (K3LAPITraits::invalid_channel & err)
{
K::Logger::Logg2(C_CLI, stream, FMT("ERROR: Unable to find channel %d on device %d!") % err.object % err.device );
}
catch (...)
- {
+ {
K::Logger::Logg2(C_CLI, stream, "ERROR: Unexpected error..., skipping");
- }
+ }
}
void Cli::_KhompShowChannels::showChannels(unsigned int device, OutputType output_type)
OutputType output_type = Cli::VERBOSE;
bool onlyShowOneChannel = false;
- unsigned int channelToShow = 0;
+ unsigned int channelToShow = 0;
if (argc > 5)
{
return false;
}
- concise = ( ((argc == 3) || (argc == 4) || (argc == 5) ) && (ARG_CMP(2, "concise")) ? 1 : 0 );
- verbose = ( ((argc == 3) || (argc == 4) || (argc == 5) ) && (ARG_CMP(2, "verbose")) ? 1 : 0 );
- as_xml = ( ((argc == 3) || (argc == 4) || (argc == 5) ) && (ARG_CMP(2, "xml")) ? 1 : 0 );
+ concise = ( ((argc == 3) || (argc == 4) || (argc == 5) ) && (ARG_CMP(2, "concise")) ? 1 : 0 );
+ verbose = ( ((argc == 3) || (argc == 4) || (argc == 5) ) && (ARG_CMP(2, "verbose")) ? 1 : 0 );
+ as_xml = ( ((argc == 3) || (argc == 4) || (argc == 5) ) && (ARG_CMP(2, "xml")) ? 1 : 0 );
if (argc >= (3 + concise + verbose + as_xml))
- {
+ {
dev = atoi (argv[2 + concise + verbose + as_xml]);
if (!Globals::k3lapi.valid_device(dev))
- {
+ {
K::Logger::Logg2(C_CLI, stream, "ERROR: no such device!");
return false;
- }
-
+ }
+
if (argc == ( 4 + concise + verbose + as_xml))
{
onlyShowOneChannel = true;
channelToShow = atoi (argv[3 + concise + verbose + as_xml]);
- }
- }
+ }
+ }
if (concise == 0 && as_xml == 0)
- {
+ {
K::Logger::Logg2(C_CLI, stream, " -----------------------------------------------------------------------");
K::Logger::Logg2(C_CLI, stream, "|-------------------- Khomp Channels and Connections -------------------|");
K::Logger::Logg2(C_CLI, stream, "|-----------------------------------------------------------------------|");
K::Logger::Logg2(C_CLI, stream, "| hw |freeSWITCH| call | channel |");
K::Logger::Logg2(C_CLI, stream, "| id | status | status | status |");
K::Logger::Logg2(C_CLI, stream, " -----------------------------------------------------------------------");
- }
+ }
if (concise != 0) output_type = Cli::CONCISE;
- if (as_xml != 0)
+ if (as_xml != 0)
{
output_type = Cli::XML;
}
if ( onlyShowOneChannel )
- {
+ {
if ( channelToShow < Globals::k3lapi.channel_count(dev) )
- {
+ {
if(output_type == Cli::XML)
{
/* channels/device */
}
showChannel (dev, channelToShow, output_type);
- }
- else
- {
+ }
+ else
+ {
K::Logger::Logg2(C_CLI, stream, "ERROR: no such channel!");
- }
- }
+ }
+ }
else if (dev == UINT_MAX)
- {
+ {
for (dev = 0; dev < Globals::k3lapi.device_count(); dev++)
{
showChannels(dev, output_type);
}
- }
- else
- {
+ }
+ else
+ {
showChannels ( dev, output_type);
}
std::string res;
- try
- {
+ try
+ {
const K3L_LINK_CONFIG & conf = Globals::k3lapi.link_config(dev, obj);
-
+
res = Globals::k3lutil.linkStatus(dev, obj, fmt);
if (conf.ReceivingClock & 0x01)
res += (fmt == Verbose::EXACT ? ",sync" : " (sync)");
- }
- catch (K3LAPITraits::invalid_target & e)
- {
+ }
+ catch (K3LAPITraits::invalid_target & e)
+ {
res = "<error>";
- }
+ }
- return res;
+ return res;
}
void Cli::_KhompShowLinks::showLinks(unsigned int device, OutputType output_type)
case 1:
{
std::string str_link0 = getLinkStatus(device, 0, (output_type == Cli::CONCISE ? Verbose::EXACT : Verbose::HUMAN));
-
+
switch(output_type)
{
case Cli::VERBOSE:
/* device */
xdev = switch_xml_add_child_d(root,"device",0);
switch_xml_set_attr_d(xdev,"id",STR(FMT("%d") % device));
-
+
/* device/links */
switch_xml_t xlinks = switch_xml_add_child_d(xdev,"links",0);
/* device */
xdev = switch_xml_add_child_d(root,"device",0);
switch_xml_set_attr_d(xdev,"id",STR(FMT("%d") % device));
-
+
/* device/links */
switch_xml_t xlinks = switch_xml_add_child_d(xdev,"links",0);
/* device */
xdev = switch_xml_add_child_d(root,"device",0);
switch_xml_set_attr_d(xdev,"id",STR(FMT("%d") % device));
-
+
/* device/errors */
switch_xml_t xerrors = switch_xml_add_child_d(xdev,"errors",0);
- /* device/errors/link (0) */
+ /* device/errors/link (0) */
switch_xml_t xlinks0 = switch_xml_add_child_d(xerrors,"link",0);
switch_xml_set_attr_d(xlinks0,"id","0");
switch_xml_set_txt_d(xnumber0,STR(FMT("%d") % i->second));
}
- /* device/errors/link (1) */
+ /* device/errors/link (1) */
switch_xml_t xlinks1 = switch_xml_add_child_d(xerrors,"link",0);
switch_xml_set_attr_d(xlinks1,"id","1");
/* device */
xdev = switch_xml_add_child_d(root,"device",0);
switch_xml_set_attr_d(xdev,"id",STR(FMT("%d") % device));
-
+
/* device/errors */
switch_xml_t xerrors = switch_xml_add_child_d(xdev,"errors",0);
- /* device/errors/link (0) */
+ /* device/errors/link (0) */
switch_xml_t xlinks0 = switch_xml_add_child_d(xerrors,"link",0);
switch_xml_set_attr_d(xlinks0,"id","0");
K::Logger::Logg2(C_CLI, stream, " ------------------------------------------------------------------------");
}
- if (as_xml)
+ if (as_xml)
{
printXMLOutput(stream);
clearRoot();
}
catch(K3LAPI::failed_command & e)
{
- K::Logger::Logg2(C_CLI, stream,
- FMT("ERROR: Command has failed with error '%s'")
+ K::Logger::Logg2(C_CLI, stream,
+ FMT("ERROR: Command has failed with error '%s'")
% Verbose::status((KLibraryStatus)e.rc).c_str());
}
}
}
unsigned int dev = UINT_MAX;
- unsigned int obj = UINT_MAX;
+ unsigned int obj = UINT_MAX;
if(argc > 2)
{
if (!Globals::k3lapi.valid_device(dev))
{
- K::Logger::Logg2(C_CLI, stream,
+ K::Logger::Logg2(C_CLI, stream,
FMT("ERROR: no such device %d!") % dev);
return false;
}
if(!Globals::k3lapi.valid_link(dev, obj))
{
- K::Logger::Logg2(C_CLI, stream,
+ K::Logger::Logg2(C_CLI, stream,
FMT("ERROR: No such link %d on device %d!") % obj % dev);
return false;
}
if(dev == UINT_MAX)
{
- K::Logger::Logg2(C_CLI, stream,
+ K::Logger::Logg2(C_CLI, stream,
"NOTICE: Reseting error count of all links...");
for (unsigned int d = 0; d < Globals::k3lapi.device_count(); d++)
{
if (obj == UINT_MAX)
{
- K::Logger::Logg2(C_CLI, stream,
+ K::Logger::Logg2(C_CLI, stream,
FMT("NOTICE: Reseting error count of all links on device %d...")
% dev);
unsigned int link_count = Globals::k3lutil.physicalLinkCount(dev, true);
}
else
{
- K::Logger::Logg2(C_CLI, stream,
- FMT("NOTICE: Reseting error count of link %d on device %d...")
+ K::Logger::Logg2(C_CLI, stream,
+ FMT("NOTICE: Reseting error count of link %d on device %d...")
% obj % dev);
clearLink(dev, obj);
{
unsigned int dev = UINT_MAX;
- unsigned int obj = UINT_MAX;
+ unsigned int obj = UINT_MAX;
if(argc > 2)
{
if (!Globals::k3lapi.valid_device(dev))
{
- K::Logger::Logg2(C_CLI, stream,
+ K::Logger::Logg2(C_CLI, stream,
FMT("ERROR: no such device %d!") % dev);
return false;
}
if(!Globals::k3lapi.valid_channel(dev, obj))
{
- K::Logger::Logg2(C_CLI, stream,
+ K::Logger::Logg2(C_CLI, stream,
FMT("ERROR: No such channel %d on device %d!") % obj % dev);
return false;
}
for (unsigned int d = 0; d < Globals::k3lapi.device_count(); d++)
{
- for (unsigned int o = 0; o < Globals::k3lapi.channel_count(d); o++)
+ for (unsigned int o = 0; o < Globals::k3lapi.channel_count(d); o++)
Board::get(d, o)->clearStatistics();
}
}
if (obj == UINT_MAX)
{
K::Logger::Logg2(C_CLI, stream, FMT("NOTICE: Reseting statistics of all channels from board %d...") % dev);
-
- for (unsigned int o = 0; o < Globals::k3lapi.channel_count(dev); o++)
+
+ for (unsigned int o = 0; o < Globals::k3lapi.channel_count(dev); o++)
Board::get(dev, o)->clearStatistics();
}
else
bool Cli::_KhompDumpConfig::execute(int argc, char *argv[])
{
- if (argc != 2)
+ if (argc != 2)
{
printUsage(stream);
return false;
for (Config::StringSet::const_iterator itr = opts.begin(); itr != opts.end(); ++itr)
{ try
{
- if(removeUnavaible((*itr))) continue;
+ if(removeUnavaible((*itr))) continue;
K::Logger::Logg2(C_CLI, stream, FMT("| %-24s => %42s |")
% (*itr) % Globals::options.get(&(Opt::_options), (*itr)));
}
{
K::Logger::Logg(C_ERROR, FMT("%s (%s)") % e.what() % (*itr));
}
- }
+ }
K::Logger::Logg2(C_CLI, stream, " ------------------------------------------------------------------------");
}
catch(K3LAPI::failed_command & e)
{
- K::Logger::Logg2(C_CLI, stream,
- FMT("ERROR: Command has failed with error '%s'")
+ K::Logger::Logg2(C_CLI, stream,
+ FMT("ERROR: Command has failed with error '%s'")
% Verbose::status((KLibraryStatus)e.rc).c_str());
}
}
}
unsigned int dev = UINT_MAX;
- unsigned int obj = UINT_MAX;
+ unsigned int obj = UINT_MAX;
if(argc > 2)
{
if (!Globals::k3lapi.valid_device(dev))
{
- K::Logger::Logg2(C_CLI, stream,
+ K::Logger::Logg2(C_CLI, stream,
FMT("ERROR: no such device %d!") % dev);
return false;
}
if(!Globals::k3lapi.valid_link(dev, obj))
{
- K::Logger::Logg2(C_CLI, stream,
+ K::Logger::Logg2(C_CLI, stream,
FMT("ERROR: No such link %d on device %d!") % obj % dev);
return false;
}
if(dev == UINT_MAX)
{
- K::Logger::Logg2(C_CLI, stream,
+ K::Logger::Logg2(C_CLI, stream,
"NOTICE: Reseting all links...");
for (unsigned int d = 0; d < Globals::k3lapi.device_count(); d++)
{
if (obj == UINT_MAX)
{
- K::Logger::Logg2(C_CLI, stream,
+ K::Logger::Logg2(C_CLI, stream,
FMT("NOTICE: Reseting all links on device %d...")
% dev);
unsigned int link_count = Globals::k3lutil.physicalLinkCount(dev, true);
}
else
{
- K::Logger::Logg2(C_CLI, stream,
- FMT("NOTICE: Reseting link %d on device %d...")
+ K::Logger::Logg2(C_CLI, stream,
+ FMT("NOTICE: Reseting link %d on device %d...")
% obj % dev);
resetLink(dev, obj);
}
return false;
}
-
+
K::Logger::Logg2(C_CLI, stream, "Message sent successfully!");
return true;
unsigned int total_args = argc - 2; /* remove "khomp log console" */
if (extra == "no")
- {
+ {
invert = true;
--total_args;
- }
+ }
else if (extra == "just")
- {
+ {
unique = true;
--total_args;
- }
+ }
unsigned int first_args = argc - total_args;
std::string options;
- for (unsigned int i = first_args; i < (unsigned int)argc; i++)
- {
+ for (unsigned int i = first_args; i < (unsigned int)argc; i++)
+ {
options += argv[i];
- options += ",";
- }
+ options += ",";
+ }
K::Logger::processLogConsole(stream, options, invert, unique);
return true;
if (!m2.empty()) K::Logger::Logg2(C_CLI, stream, FMT("Enabled log-on-disk messages: %s.") % m2.merge(", "));
else /* ----- */ K::Logger::Logg2(C_CLI, stream, "There are no log-on-disk messages enabled.");
-
+
if (Globals::flag_trace_rdsi) K::Logger::Logg2(C_CLI, stream, "The ISDN (RDSI) low-level tracing is enabled.");
K::Logger::Logg2(C_CLI, stream, " ");
}
if (!K::Logger::rotate())
- {
+ {
return false;
- }
+ }
return true;
}
if (str_on == argv[3]) value = true;
else if (str_off == argv[3]) value = false;
- else
- {
+ else
+ {
K::Logger::Logg2(C_CLI, stream, "ERROR: Please use 'on' or 'off' to enable or disable.");
return false;
- }
+ }
K::Logger::Logg2(C_CLI, stream, FMT("NOTICE: %sbling k3l debug messages.") % (value ? "Ena" : "Disa"));
K::LogConfig::set(logfile, "K3L", "Fax", value);
if (K::LogConfig::commit(logfile))
- {
+ {
try
{
Globals::k3lapi.command(-1, -1, CM_LOG_UPDATE);
{
LOG(ERROR,"Error while send command CM_LOG_UPDATE");
}
- }
+ }
return true;
}
bool Cli::_KhompGet::execute(int argc, char *argv[])
{
- if (argc < 2)
+ if (argc < 2)
{
printUsage(stream);
return false;
std::string arg(argv[1]);
- try
- {
+ try
+ {
std::string res = Globals::options.get(&Opt::_options, (const char*) argv[1]);
K::Logger::Logg2(C_CLI, stream, FMT("Result for command %s is %s.") % std::string(argv[1]) % res);
- }catch(Config::Failure &e){
+ }catch(Config::Failure &e){
K::Logger::Logg2(C_CLI, stream, e.what());
- }
+ }
return true;
}
bool Cli::_KhompSet::execute(int argc, char *argv[])
{
- if (argc < 3)
+ if (argc < 3)
{
printUsage(stream);
return false;
std::string args;
- const unsigned int first = 2;
+ const unsigned int first = 2;
- for (unsigned int i = first; i < (unsigned int)argc; i++)
- {
+ for (unsigned int i = first; i < (unsigned int)argc; i++)
+ {
if (i != first) { args += " "; }
args += argv[i];
- }
+ }
- try
- {
+ try
+ {
Globals::options.process(&Opt::_options, (const char *) argv[1], (const char *) args.c_str());
const Config::Options::Messages msgs = Globals::options.commit(&Opt::_options, (const char *)argv[1]);
- for (Config::Options::Messages::const_iterator i = msgs.begin(); i != msgs.end(); ++i)
+ for (Config::Options::Messages::const_iterator i = msgs.begin(); i != msgs.end(); ++i)
{
K::Logger::Logg2(C_ERROR, stream, FMT("%s.") % (*i));
}
K::Logger::Logg2(C_CLI, stream, FMT("Setting %s for value %s") % argv[1] % argv[2]);
- }
+ }
catch (Config::Failure &e)
- {
+ {
K::Logger::Logg2(C_ERROR,stream, FMT("config processing error: %s.") % e.what());
- }
+ }
return true;
}
catch(K3LAPI::failed_command &e)
{
if (K::Logger::Logg.classe(C_WARNING).enabled())
- {
+ {
LOG(WARNING, FMT("Command '%s' has failed with error '%s'.")
% Verbose::commandName(e.code) % Verbose::status((KLibraryStatus)e.rc));
- }
+ }
return false;
}
bool Cli::_KhompSendRawCommand::execute(int argc, char *argv[])
{
- if (argc < 6)
+ if (argc < 6)
{
printUsage(stream);
return false;
unsigned int dev = atoi (argv[3]);
if (dev >= Globals::k3lapi.device_count())
- {
+ {
K::Logger::Logg2(C_CLI, stream, FMT("ERROR: No such device: %d!") % dev);
return false;
- }
+ }
unsigned int dsp = atoi (argv[4]);
if (dsp >= 2)
- {
+ {
K::Logger::Logg2(C_CLI, stream, FMT("ERROR: Invalid DSP number: %d!") % dsp);
return false;
- }
+ }
const unsigned int base = 5;
char commands[(argc - base)];
- for (int i = base, j = 0; i < argc; i++, j++)
- {
+ for (int i = base, j = 0; i < argc; i++, j++)
+ {
if (sscanf(argv[i], "%hhx", &(commands[j])) != 1)
- {
+ {
K::Logger::Logg2(C_CLI, stream, FMT("ERROR: Invalid hexadecimal sequence: '%s'!") % argv[i]);
return false;
- }
- }
+ }
+ }
try
{
catch(K3LAPI::failed_raw_command &e)
{
if (K::Logger::Logg.classe(C_WARNING).enabled())
- {
+ {
LOG(WARNING, FMT("(dev=%d,dsp=%d): Raw command '%s' has failed with error '%s'.")
- % e.dev
- % e.dsp
- % Strings::hexadecimal(std::string((char*) commands,(argc - base)))
+ % e.dev
+ % e.dsp
+ % Strings::hexadecimal(std::string((char*) commands,(argc - base)))
% Verbose::status((KLibraryStatus)e.rc));
- }
+ }
return false;
}
- return true;
+ return true;
}
bool Cli::_KhompSelectSim::execute(int argc, char *argv[])
if (!Globals::k3lapi.valid_device(dev))
{
- K::Logger::Logg2(C_CLI, stream,
+ K::Logger::Logg2(C_CLI, stream,
FMT("ERROR: no such device %d!") % dev);
return false;
}
if(!Board::get(dev, obj)->application(SELECT_SIM_CARD, NULL, num_str.c_str()))
{
- K::Logger::Logg2(C_CLI, stream, "ERROR: Unable to select sim card");
+ K::Logger::Logg2(C_CLI, stream, "ERROR: Unable to select sim card");
return false;
}
}
}
catch(...)
{
- K::Logger::Logg2(C_CLI, stream, "ERROR: Unable to select sim card");
+ K::Logger::Logg2(C_CLI, stream, "ERROR: Unable to select sim card");
return false;
}
case -1: K::Logger::Logg2(C_CLI, stream, "ERROR: libkwd.so required for kommuter could not be found." ); return false;
case 0: K::Logger::Logg2(C_CLI, stream, "ERROR: none Kommuter was found on the system." ); return false;
}
-
+
if (Opt::_options._kommuter_activation() == "auto")
{
K::Logger::Logg2(C_CLI, stream, "ERROR: Kommuter is set to be started automatically by kommuter-activation configuration.");
return false;
}
-
+
bool on_off = ARG_CMP(1, "on") ? true : false;
int ret = 0;
switch(e.rc)
{
case ksInvalidParams:
- K::Logger::Logg2(C_CLI,stream,FMT("ERROR: invalid timeout '%d' for Kommuter device '%d' timeout. Mininum is 0, maximum is 255.")
+ K::Logger::Logg2(C_CLI,stream,FMT("ERROR: invalid timeout '%d' for Kommuter device '%d' timeout. Mininum is 0, maximum is 255.")
% timeout % kommuter);
break;
default:
K::Logger::Logg2(C_CLI,stream,FMT("ERROR: could not start the kommuter device number '%d'.") % kommuter);
break;
}
- }
+ }
catch(...)
{
K::Logger::Logg2(C_CLI, stream, FMT("ERROR: could not start the Kommuter device number '%d'.") % kommuter);
{
DBG(FUNC, D("kommuter watchdog timer not created because timeout is 0."));
return false;
- }
-
+ }
+
if (start_timer)
- {
+ {
if (!Globals::global_timer)
- {
+ {
K::Logger::Logg2(C_CLI, stream , "Error creating the timer for kommuter.");
return true;
- }
+ }
else if (Board::kommuter._kwtd_timer_on)
- {
+ {
Globals::global_timer->restart( Board::kommuter._kwtd_timer_index, true );
DBG(FUNC, D("kommuter watchdog timer restarted."));
}
Board::kommuter._kwtd_timer_on = true;
DBG(FUNC, D("kommuter watchdog timer created and started."));
}
- }
- }
- else
- {
+ }
+ }
+ else
+ {
K::Logger::Logg2(C_CLI, stream, "NOTICE: Deactivating Kommuters.");
if (Board::kommuter._kwtd_timer_on)
- {
+ {
Globals::global_timer->del( Board::kommuter._kwtd_timer_index);
Board::kommuter._kwtd_timer_on = false;
- }
+ }
for(int kommuter = 0; kommuter < Board::kommuter._kommuter_count; kommuter++)
- {
+ {
try
{
Globals::k3lapi.command(-1, kommuter, CM_STOP_WATCHDOG);
catch(K3LAPI::failed_command & e)
{
K::Logger::Logg2(C_CLI,stream,FMT("ERROR: Kommuter device '%d' was not initialized.") % kommuter);
- }
+ }
catch(...)
{
K::Logger::Logg2(C_CLI, stream,FMT("ERROR: could not disable kommuter device '%d' for some unknow reason.") % kommuter);
}
- }
+ }
}
return false;
if(Board::kommuter._kommuter_count == -1)
{
- K::Logger::Logg2(C_CLI, stream,
+ K::Logger::Logg2(C_CLI, stream,
"ERROR: libkwd.so required for kommuter could not be found." );
return false;
}
- K::Logger::Logg2(C_CLI, stream,
- FMT("Kommuter devices detected = [%d]")
+ K::Logger::Logg2(C_CLI, stream,
+ FMT("Kommuter devices detected = [%d]")
% Board::kommuter._kommuter_count);
return true;
KHOMP generic endpoint/channel library.
Copyright (C) 2007-2010 Khomp Ind. & Com.
- The contents of this file are subject to the Mozilla Public License
- Version 1.1 (the "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
+ The contents of this file are subject to the Mozilla Public License
+ Version 1.1 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
case the provisions of "LGPL License" are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
- the LGPL License and not to allow others to use your version of this file
- under the MPL, indicate your decision by deleting the provisions above and
- replace them with the notice and other provisions required by the LGPL
- License. If you do not delete the provisions above, a recipient may use your
+ the LGPL License and not to allow others to use your version of this file
+ under the MPL, indicate your decision by deleting the provisions above and
+ replace them with the notice and other provisions required by the LGPL
+ License. If you do not delete the provisions above, a recipient may use your
version of this file under either the MPL or the LGPL License.
The LGPL header follows below:
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with this library; if not, write to the Free Software Foundation,
+ along with this library; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*******************************************************************************/
KHOMP generic endpoint/channel library.
Copyright (C) 2007-2010 Khomp Ind. & Com.
- The contents of this file are subject to the Mozilla Public License
- Version 1.1 (the "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
+ The contents of this file are subject to the Mozilla Public License
+ Version 1.1 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
case the provisions of "LGPL License" are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
- the LGPL License and not to allow others to use your version of this file
- under the MPL, indicate your decision by deleting the provisions above and
- replace them with the notice and other provisions required by the LGPL
- License. If you do not delete the provisions above, a recipient may use your
+ the LGPL License and not to allow others to use your version of this file
+ under the MPL, indicate your decision by deleting the provisions above and
+ replace them with the notice and other provisions required by the LGPL
+ License. If you do not delete the provisions above, a recipient may use your
version of this file under either the MPL or the LGPL License.
The LGPL header follows below:
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with this library; if not, write to the Free Software Foundation,
+ along with this library; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*******************************************************************************/
KHOMP generic endpoint/channel library.
Copyright (C) 2007-2010 Khomp Ind. & Com.
- The contents of this file are subject to the Mozilla Public License
- Version 1.1 (the "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
+ The contents of this file are subject to the Mozilla Public License
+ Version 1.1 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
case the provisions of "LGPL License" are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
- the LGPL License and not to allow others to use your version of this file
- under the MPL, indicate your decision by deleting the provisions above and
- replace them with the notice and other provisions required by the LGPL
- License. If you do not delete the provisions above, a recipient may use your
+ the LGPL License and not to allow others to use your version of this file
+ under the MPL, indicate your decision by deleting the provisions above and
+ replace them with the notice and other provisions required by the LGPL
+ License. If you do not delete the provisions above, a recipient may use your
version of this file under either the MPL or the LGPL License.
The LGPL header follows below:
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with this library; if not, write to the Free Software Foundation,
+ along with this library; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*******************************************************************************/
_session(NULL),
_caller_profile(NULL),
_reader_frames(&_read_codec),
- _writer_frames(&_write_codec)
-{
+ _writer_frames(&_write_codec)
+{
_read_codec.implementation = NULL;
_write_codec.implementation = NULL;
bool Board::initializeK3L(void)
{
- LOG(MESSAGE, "starting K3L API ...");
+ LOG(MESSAGE, "starting K3L API ...");
/* Start the API and connect to KServer */
k3lSetGlobalParam (klpResetFwOnStartup, 1);
return false;
}
- LOG(MESSAGE, "the K3L API have been started!");
-
+ LOG(MESSAGE, "the K3L API have been started!");
+
return true;
}
LOG(ERROR, "K3L not stopped");
return false;
}
- LOG(MESSAGE, "K3L stopped..");
+ LOG(MESSAGE, "K3L stopped..");
return true;
}
k3lRegisterEventHandler( khompEventCallback );
k3lRegisterAudioListener( NULL, khompAudioListener );
- LOG(MESSAGE, "K3l event and audio handlers registered.");
+ LOG(MESSAGE, "K3l event and audio handlers registered.");
return true;
}
it_dev != _boards.end();
it_dev++)
{
- Board * device = *it_dev;
+ Board * device = *it_dev;
// stop event handler for device
ChanEventHandler * evt_handler = device->_event_handler;
evt_handler->fifo()->_shutdown = true;
/* wait every thread to finalize */
sleep(1);
- LOG(MESSAGE, "K3l event and audio handlers unregistered.");
+ LOG(MESSAGE, "K3l event and audio handlers unregistered.");
return true;
for (unsigned dev = 0; dev < Globals::k3lapi.device_count(); dev++)
{
- LOG(MESSAGE,FMT("loading device %d..." ) % dev);
+ LOG(MESSAGE,FMT("loading device %d..." ) % dev);
switch(Globals::k3lapi.device_type(dev))
{
break;
default:
_boards.push_back(new Board(dev));
- LOG(ERROR,FMT("device type %d unknown" ) % Globals::k3lapi.device_type(dev));
+ LOG(ERROR,FMT("device type %d unknown" ) % Globals::k3lapi.device_type(dev));
break;
}
-
+
_boards.back()->initializeChannels();
}
}
void Board::initializeChannels(void)
{
- LOG(MESSAGE, "loading channels ...");
+ LOG(MESSAGE, "loading channels ...");
for (unsigned obj = 0; obj < Globals::k3lapi.channel_count(_device_id); obj++)
{
DBG(FUNC, FMT("signaling %d unknown") % Globals::k3lapi.channel_config(_device_id, obj).Signaling);
break;
}
-
+
_channels.push_back(pvt);
pvt->cleanup();
void Board::finalizeBoards(void)
{
- LOG(MESSAGE, "finalizing boards ...");
+ LOG(MESSAGE, "finalizing boards ...");
for (VectorBoard::iterator it_dev = _boards.begin();
it_dev != _boards.end();
void Board::finalizeChannels()
{
- LOG(MESSAGE, "finalizing channels ...");
+ LOG(MESSAGE, "finalizing channels ...");
for (VectorChannel::iterator it_obj = _channels.begin();
it_obj != _channels.end();
it_obj++)
if (_pvt->call()->statistics()->_total_idle_time > 0)
{
occupation_rate = 100 * (
- _pvt->call()->statistics()->_total_time_incoming +
+ _pvt->call()->statistics()->_total_time_incoming +
_pvt->call()->statistics()->_total_time_outgoing
) / (
- _pvt->call()->statistics()->_total_idle_time +
- _pvt->call()->statistics()->_total_time_incoming +
+ _pvt->call()->statistics()->_total_idle_time +
+ _pvt->call()->statistics()->_total_time_incoming +
_pvt->call()->statistics()->_total_time_outgoing);
}
strBuffer.append(STG(FMT("Occupation rate: \t\t%0.2f%%\n") % occupation_rate));
- if (call_incoming > 0)
- {
+ if (call_incoming > 0)
+ {
std::string str_calls_incoming_mean = timeToString ( (time_t) (_pvt->call()->statistics()->_total_time_incoming / call_incoming) );
strBuffer.append(STG(FMT("Mean duration time of incoming calls: %s\n") % str_calls_incoming_mean));
- }
+ }
- if (call_outgoing > 0)
- {
+ if (call_outgoing > 0)
+ {
std::string str_calls_outgoing_mean = timeToString ( (time_t) (_pvt->call()->statistics()->_total_time_outgoing / call_outgoing) );
strBuffer.append(STG(FMT("Mean duration time of outgoing calls: %s\n") % str_calls_outgoing_mean));
- }
+ }
return strBuffer;
}
if (_pvt->call()->statistics()->_total_idle_time > 0)
{
occupation_rate = 100 * (
- _pvt->call()->statistics()->_total_time_incoming +
+ _pvt->call()->statistics()->_total_time_incoming +
_pvt->call()->statistics()->_total_time_outgoing
) / (
- _pvt->call()->statistics()->_total_idle_time +
- _pvt->call()->statistics()->_total_time_incoming +
+ _pvt->call()->statistics()->_total_idle_time +
+ _pvt->call()->statistics()->_total_time_incoming +
_pvt->call()->statistics()->_total_time_outgoing);
}
switch_xml_t xoccupation = switch_xml_add_child_d(xrates,"oucpation",0);
switch_xml_set_txt_d(xoccupation,STR(FMT("%d") % occupation_rate));
- if (call_incoming > 0)
- {
+ if (call_incoming > 0)
+ {
std::string str_calls_incoming_mean = timeToString ( (time_t) (_pvt->call()->statistics()->_total_time_incoming / call_incoming) );
switch_xml_t xmean_in = switch_xml_add_child_d(xrates,"incoming",0);
switch_xml_set_txt_d(xmean_in,str_calls_incoming_mean.c_str());
- }
+ }
- if (call_outgoing > 0)
- {
+ if (call_outgoing > 0)
+ {
std::string str_calls_outgoing_mean = timeToString ( (time_t) (_pvt->call()->statistics()->_total_time_outgoing / call_outgoing) );
switch_xml_t xmean_out = switch_xml_add_child_d(xrates,"outgoing",0);
switch_xml_set_txt_d(xmean_out,str_calls_outgoing_mean.c_str());
- }
+ }
return xrates;
}
std::string Board::KhompPvt::PvtStatistics::getDetailed()
-{
+{
/* skip inactive channels */
//if (_pvt->getSignaling() == ksigInactive) return "";
/* buffer our data to return at the end */
std::string strBuffer;
-
+
strBuffer.append(_pvt->call()->statistics()->getDetailed());
/* this values come from kserver */
strBuffer.append(STG(FMT("Number of calls failed: \t%d\n") % call_fails));
strBuffer.append(getDetailedRates());
-
+
return strBuffer;
}
return xch;
}
-std::string Board::KhompPvt::PvtStatistics::getRow()
+std::string Board::KhompPvt::PvtStatistics::getRow()
{
/* skip inactive channels */
//if (_pvt->getSignaling() == ksigInactive) return "";
time_t action_time;
time (&action_time);
-
+
action_time -= _pvt->call()->statistics()->_base_time;
uint32 calls_incoming = Globals::k3lapi.channel_stats(
_pvt->target().device, _pvt->target().object, kcsiOutbound);
uint32 call_fails = Globals::k3lapi.channel_stats(
_pvt->target().device, _pvt->target().object, kcsiOutFailed);
-
+
std::string string_time = " n/a ";
std::string call_type = " none ";
call_type = "outgoing";
if (_pvt->owner())
- {
+ {
string_time = timeToString(action_time);
- }
+ }
return STG(FMT("| %d,%02d | %8d | %8d | %8d | %7d | %10s | %8s | %8s |")
- % _pvt->target().device
- % _pvt->target().object
- % calls_incoming
- % calls_outgoing
+ % _pvt->target().device
+ % _pvt->target().object
+ % calls_incoming
+ % calls_outgoing
% _pvt->call()->statistics()->_channel_fails
- % call_fails
- % _pvt->getStateString()
- % call_type
+ % call_fails
+ % _pvt->getStateString()
+ % call_type
% string_time);
}
{
time_t action_time;
time (&action_time);
-
+
action_time -= _pvt->call()->statistics()->_base_time;
uint32 calls_incoming = Globals::k3lapi.channel_stats(
_pvt->target().device, _pvt->target().object, kcsiOutbound);
uint32 call_fails = Globals::k3lapi.channel_stats(
_pvt->target().device, _pvt->target().object, kcsiOutFailed);
-
+
std::string string_time = " n/a ";
std::string call_type = " none ";
call_type = "outgoing";
if (_pvt->owner())
- {
+ {
string_time = timeToString(action_time);
- }
+ }
/* device/channel */
switch_xml_t xchn = switch_xml_new("channel");
{
#if SWITCH_LESS_THAN(1,0,6)
session(switch_core_session_request(Globals::khomp_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, NULL));
-#else
+#else
session(switch_core_session_request(Globals::khomp_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, SOF_NONE, NULL));
-#endif
+#endif
}
else
{
{
/* Create a new session on outgoing call */
call()->_flags.set(Kflags::IS_OUTGOING);
-#if SWITCH_LESS_THAN(1,0,6)
+#if SWITCH_LESS_THAN(1,0,6)
session(switch_core_session_request(Globals::khomp_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, pool));
#else
session(switch_core_session_request(Globals::khomp_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, SOF_NONE, pool));
try
{
switch_channel_t *channel = getFSChannel();
-
+
if(call()->_flags.check(Kflags::IS_INCOMING))
{
std::string exten("s");
return SWITCH_STATUS_FALSE;
}
- switch(MatchExtension::findExtension(exten, context, contexts, _call->_dest_addr, _call->_orig_addr))
+ switch(MatchExtension::findExtension(exten, context, contexts, _call->_dest_addr, _call->_orig_addr))
{
case MatchExtension::MATCH_NONE:
destroy();
owner(NULL);
LOG(ERROR, PVT_FMT(_target, "r (unable to find exten/context on incoming call %s/%s)")
% _call->_dest_addr % (contexts.size() >= 1 ? contexts[0] : "default"));
- return SWITCH_STATUS_FALSE;
+ return SWITCH_STATUS_FALSE;
default:
DBG(FUNC, PVT_FMT(_target, "our: dialplan '%s', context '%s', exten '%s'") % Opt::_options._dialplan() % context % exten);
break;
exten = call()->_dest_addr;
DBG(FUNC, PVT_FMT(target(), "already found our: dialplan '%s', context '%s', exten '%s'") % Opt::_options._dialplan() % call()->_incoming_context % exten);
}
-
+
_caller_profile = switch_caller_profile_new(switch_core_session_get_pool(_session),
"Khomp", //username
Opt::_options._dialplan().c_str(), //dialplan
{
destroy();
owner(NULL);
- DBG(FUNC, PVT_FMT(target(), "r (%s)") % err._msg.c_str());
+ DBG(FUNC, PVT_FMT(target(), "r (%s)") % err._msg.c_str());
return SWITCH_STATUS_FALSE;
}
DBG(FUNC, PVT_FMT(target(), "r"));
return SWITCH_STATUS_SUCCESS;
}
-
+
int Board::KhompPvt::makeCall(std::string params)
{
DBG(FUNC, PVT_FMT(target(), "Dialing to %s from %s")
/* Lets make the call! */
std::string full_params;
-
+
if(!_call->_dest_addr.empty())
full_params += STG(FMT(" dest_addr=\"%s\"")
% _call->_dest_addr);
}
else
{
- DBG(FUNC, PVT_FMT(target(), "r (already playing something: %d)")
+ DBG(FUNC, PVT_FMT(target(), "r (already playing something: %d)")
% call()->_indication);
return false;
}
setHangupCause(cause, false);
call()->_indication = INDICA_BUSY;
-
+
DBG(FUNC, PVT_FMT(target(), "r"));
return true;
{
if(!_session)
return;
-
+
tmp_session = _session;
}
else
{
tmp_session = s;
-
+
}
switch_core_session_destroy(&tmp_session);
switch_core_session_set_private(_session, NULL);
_session = NULL;
}
-
+
owner(NULL);
if(_caller_profile)
_reader_frames.clear();
_writer_frames.clear();
-
+
call()->_flags.clear(Kflags::CONNECTED);
-
+
//call()->_flags.clear(Kflags::BRIDGED);
-
+
call()->_flags.clear(Kflags::DROP_COLLECT);
-
+
call()->_flags.clear(Kflags::OUT_OF_BAND_DTMFS);
call()->_flags.clear(Kflags::WAIT_SEND_DTMF);
-
+
call()->_flags.clear(Kflags::GEN_PBX_RING);
call()->_flags.clear(Kflags::GEN_CO_RING);
{
LOG(ERROR, PVT_FMT(_target, "Unable to get device: %d!") % err.device);
}
-
+
call()->_idx_pbx_ring.reset();
call()->_idx_co_ring.reset();
setVolume("input" , Opt::_options._input_volume());
if(call()->_output_volume >= -10 && call()->_output_volume <= 10)
- setVolume("output", Opt::_options._output_volume());
+ setVolume("output", Opt::_options._output_volume());
return _call->clear();
case CLN_SOFT:
if(call()->_cadence != PLAY_FASTBUSY)
- {
+ {
/* pára cadências e limpa estado das flags */
stopCadence();
}
DBG(FUNC, "c");
for (unsigned int dev = 0; dev < Globals::k3lapi.device_count(); dev++)
- {
+ {
for (unsigned int obj = 0; obj < Globals::k3lapi.channel_count(dev); obj++)
{
try
{
DBG(FUNC, OBJ_FMT(dev, obj, "Channel not found"));
}
- }
- }
-
+ }
+ }
+
DBG(FUNC, "r");
}
-bool Board::KhompPvt::startCadence(CadencesType type)
+bool Board::KhompPvt::startCadence(CadencesType type)
{
DBG(FUNC, PVT_FMT(target(), "c"));
if (tone != "")
- {
+ {
call()->_cadence = type;
CadencesMapType::iterator i = Opt::_cadences.find(tone);
std::string cmd_params;
if (i != Opt::_cadences.end())
- {
+ {
CadenceType cadence = (*i).second;
if (cadence.ring == 0 && cadence.ring_s == 0)
- {
+ {
cmd_params = "cadence_times=\"continuous\" mixer_track=1";
- }
+ }
else if (cadence.ring_ext == 0 && cadence.ring_ext_s == 0)
- {
+ {
cmd_params = STG(FMT("cadence_times=\"%d,%d\" mixer_track=1")
% cadence.ring % cadence.ring_s);
- }
- else
- {
+ }
+ else
+ {
cmd_params = STG(FMT("cadence_times=\"%d,%d,%d,%d\" mixer_track=1")
% cadence.ring % cadence.ring_s % cadence.ring_ext % cadence.ring_ext_s);
- }
+ }
command(KHOMP_LOG,CM_START_CADENCE,cmd_params.c_str());
}
{
LOG(ERROR, PVT_FMT(target(), "ERROR sending mixer command!"));
return false;
- }
+ }
return true;
}
{
LOG(ERROR, PVT_FMT(target(), "ERROR sending mixer command!"));
return false;
- }
+ }
return true;
}
}
DBG(FUNC, PVT_FMT(target(), "sending dtmf (%s)") % digit);
-
+
call()->_flags.set(Kflags::WAIT_SEND_DTMF);
return command(KHOMP_LOG, CM_DIAL_DTMF, digit.c_str());
typedef std::string S;
switch (state)
- {
+ {
case CS_NEW: return S("new");
case CS_INIT: return S("init");
case CS_ROUTING: return S("routing");
case CS_NONE: return S("none");
default:
return STG(FMT("none (%d)") % state);
- }
+ }
}
catch(Board::KhompPvt::InvalidSwitchChannel & err)
{
if (enable) call()->_flags.set(Kflags::OUT_OF_BAND_DTMFS);
else call()->_flags.clear(Kflags::OUT_OF_BAND_DTMFS);
- DBG(FUNC, PVT_FMT(_target, "flag OUT_OF_BAND_DTMFS is : %s") %
+ DBG(FUNC, PVT_FMT(_target, "flag OUT_OF_BAND_DTMFS is : %s") %
(call()->_flags.check(Kflags::OUT_OF_BAND_DTMFS) ? "true" : "false"));
-
+
return true;
}
{
DBG(FUNC, PVT_FMT(pvt->target(), "Generating pbx ring"));
- try
- {
+ try
+ {
ScopedPvtLock lock(pvt);
if (!pvt->call()->_flags.check(Kflags::GEN_PBX_RING))
return;
pvt->startCadence(PLAY_RINGBACK);
- }
+ }
catch (...)
{
LOG(ERROR, PVT_FMT(pvt->target(), "unable to lock!"));
{
DBG(FUNC, PVT_FMT(pvt->target(), "Generating co ring"));
- try
- {
+ try
+ {
ScopedPvtLock lock(pvt);
if (!pvt->call()->_flags.check(Kflags::GEN_CO_RING))
return;
pvt->startCadence(PLAY_RINGBACK);
- }
+ }
catch (...)
{
LOG(ERROR, PVT_FMT(pvt->target(), "unable to lock the pvt !"));
- }
+ }
}
int Board::KhompPvt::getActiveChannel(bool invalid_as_not_found)
// NEEDS LOCK !?
std::vector< TriState > confvalues;
-
+
// temporary!
const char * tmp_var = NULL;
freeFSGlobalVar(&tmp_var);
- try
+ try
{
// get local filter configuration value
tmp_var = switch_channel_get_variable(getFSChannel(), "KDropCollectCall");
}
catch(Board::KhompPvt::InvalidSwitchChannel & err)
{
- LOG(ERROR, PVT_FMT(_target, "Cannot obtain the channel variable: %s") % err._msg.c_str());
+ LOG(ERROR, PVT_FMT(_target, "Cannot obtain the channel variable: %s") % err._msg.c_str());
}
// store last state assigned
setHangupCause(SWITCH_CAUSE_REQUESTED_CHAN_UNAVAIL);
cleanup(CLN_FAIL);
reportFailToReceive(fail_code);
-
+
LOG(ERROR, PVT_FMT(target(), "r (Initilization Error on start!)"));
return false;
}
bool Board::KhompPvt::onDisconnect(K3L_EVENT *e)
{
- DBG(FUNC, PVT_FMT(_target, "c"));
+ DBG(FUNC, PVT_FMT(_target, "c"));
/*
try
}
*/
- DBG(FUNC, PVT_FMT(_target, "r"));
+ DBG(FUNC, PVT_FMT(_target, "r"));
return true;
}
{
if(call()->_flags.check(Kflags::GEN_PBX_RING))
{
- DBG(FUNC, PVT_FMT(_target, "PBX ringback being disabled..."));
+ DBG(FUNC, PVT_FMT(_target, "PBX ringback being disabled..."));
ScopedPvtLock lock(this);
call()->_flags.clear(Kflags::GEN_PBX_RING);
Board::board(_target.device)->_timers.del(call()->_idx_pbx_ring);
if(call()->_cadence != PLAY_VM_TONE)
- {
+ {
stopCadence();
}
if (!call()->_flags.check(Kflags::CONNECTED))
{
obtainRX(Opt::_options._suppression_delay());
-
+
//Marcar para o Freeswitch que jah tem audio passando
if (call()->_flags.check(Kflags::IS_OUTGOING))
switch_channel_mark_pre_answered(getFSChannel());
}
}
-
+
if (!call()->_is_progress_sent && call()->_flags.check(Kflags::HAS_CALL_FAIL))
{
ScopedPvtLock lock(this);
- DBG(FUNC, PVT_FMT(_target, "Audio status progress"));
+ DBG(FUNC, PVT_FMT(_target, "Audio status progress"));
call()->_is_progress_sent = true;
//Sinaliza para o Freeswitch PROGRESS
- DBG(FUNC, PVT_FMT(_target, "Pre answer"));
+ DBG(FUNC, PVT_FMT(_target, "Pre answer"));
//pvt->signal_state(AST_CONTROL_PROGRESS);
switch_channel_pre_answer(getFSChannel());
bool Board::KhompPvt::onCollectCall(K3L_EVENT *e)
{
- try
- {
+ try
+ {
ScopedPvtLock lock(this);
- //TODO: AMI ?
+ //TODO: AMI ?
//K::internal::ami_event(pvt, EVENT_FLAG_CALL, "CollectCall",
// STG(FMT("Channel: Khomp/B%dC%d\r\n") % pvt->boardid % pvt->objectid));
if (Opt::_options._drop_collect_call() || _call->_flags.check(Kflags::DROP_COLLECT))
- {
+ {
/* disconnect! */
//TODO: SCE_HIDE !?
command(KHOMP_LOG,CM_DISCONNECT);
// command(KHOMP_LOG,CM_DISCONNECT,SCE_HIDE);
- }
- }
+ }
+ }
catch (ScopedLockFailed & err)
{
LOG(ERROR, PVT_FMT(_target, "unable to lock %s!") % err._msg.c_str() );
{
if(!call()->_flags.check(Kflags::IS_INCOMING) && !call()->_flags.check(Kflags::IS_OUTGOING))
{
- DBG(FUNC, PVT_FMT(_target, "Channel already disconnected"));
+ DBG(FUNC, PVT_FMT(_target, "Channel already disconnected"));
return false;
}
if(call()->_cadence != PLAY_VM_TONE)
- {
+ {
stopCadence();
}
-
+
if (call()->_indication != INDICA_NONE)
{
call()->_indication = INDICA_NONE;
/* Sinalizar para o Freeswitch o atendimento */
- DBG(FUNC, PVT_FMT(_target, "Call will be answered."));
+ DBG(FUNC, PVT_FMT(_target, "Call will be answered."));
if(call()->_flags.check(Kflags::IS_INCOMING))
{
switch_channel_answer(getFSChannel());
- }
+ }
else if(call()->_flags.check(Kflags::IS_OUTGOING))
{
switch_channel_mark_answered(getFSChannel());
try
{
ScopedPvtLock lock(this);
-
+
return setupConnection();
}
catch (ScopedLockFailed & err)
LOG(ERROR, PVT_FMT(_target, "r (unable to get device: %d!)") % err.device);
return false;
}
-
+
DBG(FUNC, PVT_FMT(_target, "r"));
return true;
bool Board::KhompPvt::onCallSuccess(K3L_EVENT *e)
{
- DBG(FUNC, PVT_FMT(_target, "c"));
-
+ DBG(FUNC, PVT_FMT(_target, "c"));
+
try
{
ScopedPvtLock lock(this);
ScopedPvtLock lock(this);
call()->_flags.set(Kflags::HAS_CALL_FAIL);
-
+
//TODO: Notificar o Freeswitch: call fail
cleanup(CLN_SOFT);
LOG(ERROR, PVT_FMT(_target, "r (unable to lock %s!)") % err._msg.c_str() );
return false;
}
-
+
DBG(FUNC, PVT_FMT(_target, "r"));
return true;
bool Board::KhompPvt::onNoAnswer(K3L_EVENT *e)
{
/* TODO: Destroy sessions and channels */
- DBG(FUNC, PVT_FMT(_target, "No one answered the call."));
+ DBG(FUNC, PVT_FMT(_target, "No one answered the call."));
- // TODO: Set channel variable if we get this event
- // TODO: Fire an event so ESL can get it?
- // Call Analyser has to be enabled on k3lconfig
- DBG(FUNC, PVT_FMT(_target, "Detected: \"%s\"") % Verbose::callStartInfo((KCallStartInfo)e->AddInfo).c_str());
+ // TODO: Set channel variable if we get this event
+ // TODO: Fire an event so ESL can get it?
+ // Call Analyser has to be enabled on k3lconfig
+ DBG(FUNC, PVT_FMT(_target, "Detected: \"%s\"") % Verbose::callStartInfo((KCallStartInfo)e->AddInfo).c_str());
- // Fire a custom event about this
+ // Fire a custom event about this
/* MUST USE THE NEW EVENT SYSTEM
switch_event_t * event;
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, KHOMP_EVENT_MAINT) == SWITCH_STATUS_SUCCESS)
ScopedPvtLock lock(this);
if (call()->_flags.check(Kflags::IS_INCOMING) || call()->_flags.check(Kflags::IS_OUTGOING)) /* is a valid call? */
- {
+ {
char digit = (char) e->AddInfo;
- //TODO: WTHeck ?
+ //TODO: WTHeck ?
//if (!call()->_flags.check(Kflags::OUT_OF_BAND_DTMFS) && !call()->_flags.check(Kflags::BRIDGED))
if (!call()->_flags.check(Kflags::OUT_OF_BAND_DTMFS))
- {
+ {
/* we do not queue dtmfs as we do not need to resend them */
DBG(FUNC, PVT_FMT(_target, "r (not queueing dtmf, not needed.)"));
return true;
- }
+ }
if (Opt::_options._ignore_letter_dtmfs())
- {
+ {
switch (e->AddInfo)
- {
- case 'A': case 'a':
- case 'B': case 'b':
- case 'C': case 'c':
- case 'D': case 'd':
+ {
+ case 'A': case 'a':
+ case 'B': case 'b':
+ case 'C': case 'c':
+ case 'D': case 'd':
DBG(FUNC, PVT_FMT(_target, "r (not queueing dtmf, letter digit ignored!)"));
return true;
default:
break;
- }
+ }
}
-
+
signalDTMF(e->AddInfo);
}
}
{
if(!call()->_queued_digits_buffer.empty())
{
- DBG(FUNC, PVT_FMT(target(), "sending dtmf (%s)")
+ DBG(FUNC, PVT_FMT(target(), "sending dtmf (%s)")
% call()->_queued_digits_buffer);
- command(KHOMP_LOG, CM_DIAL_DTMF,
+ command(KHOMP_LOG, CM_DIAL_DTMF,
call()->_queued_digits_buffer.c_str());
/* clear the buffer that has been send */
}
else
{
- DBG(FUNC, PVT_FMT(target(),
+ DBG(FUNC, PVT_FMT(target(),
"finished sending some digits, cleaning up!"));
call()->_flags.clear(Kflags::WAIT_SEND_DTMF);
}
- }
+ }
}
catch (ScopedLockFailed & err)
{
LOG(ERROR, PVT_FMT(_target, "r (unable to lock %s!)") % err._msg.c_str() );
return false;
}
-
+
DBG(FUNC, PVT_FMT(_target, "r"));
return true;
case EV_CHANNEL_FAIL:
ret = onChannelRelease(e);
break;
-
+
case EV_NEW_CALL:
ret = onNewCall(e);
break;
case EV_DISCONNECT:
ret = onDisconnect(e);
break;
-
+
case EV_AUDIO_STATUS:
ret = onAudioStatus(e);
break;
bool Board::KhompPvt::indicateProgress()
{
- DBG(FUNC, PVT_FMT(_target, "c"));
-
+ DBG(FUNC, PVT_FMT(_target, "c"));
+
int ret = false;
try
LOG(ERROR, PVT_FMT(_target, "r (unable to lock %s!)") % err._msg.c_str() );
return false;
}
-
+
DBG(FUNC, PVT_FMT(_target, "r"));
return ret;
bool Board::KhompPvt::indicateRinging()
{
- DBG(FUNC, PVT_FMT(_target, "c"));
+ DBG(FUNC, PVT_FMT(_target, "c"));
bool ret = false;
try
/* already playing! */
if (call()->_indication != INDICA_NONE)
- {
- DBG(FUNC, PVT_FMT(_target, "r (already playing something: %d)")
+ {
+ DBG(FUNC, PVT_FMT(_target, "r (already playing something: %d)")
% call()->_indication);
return false;
- }
+ }
// any collect calls ?
setCollectCall();
bool send_ringback = true;
if (!call()->_flags.check(Kflags::CONNECTED))
- {
+ {
int ringback_value = RingbackDefs::RB_SEND_DEFAULT;
bool do_drop_call = Opt::_options._drop_collect_call()
DBG(FUNC, PVT_FMT(_target, "ringback value adjusted to refuse collect call: %d") % ringback_value);
}
- // send ringback too?
+ // send ringback too?
send_ringback = sendPreAudio(ringback_value);
if (!send_ringback)
{
- // warn the developer which may be debugging some "i do not have ringback!" issue.
+ // warn the developer which may be debugging some "i do not have ringback!" issue.
DBG(FUNC, PVT_FMT(_target, " not sending pre connection audio"));
}
}
if (send_ringback)
- {
+ {
call()->_flags.set(Kflags::GEN_CO_RING);
call()->_idx_co_ring = Board::board(_target.device)->_timers.add(Opt::_options._ringback_co_delay(), &Board::KhompPvt::coRingGen,this);
/* start stream if it is not already */
startStream();
- ret = true;
- }
+ ret = true;
+ }
}
catch (ScopedLockFailed & err)
return false;
}
-
+
DBG(FUNC, PVT_FMT(_target, "r"));
return ret;
}
if (call()->_flags.check(Kflags::IS_INCOMING))
{
- DBG(FUNC, PVT_FMT(_target, "disconnecting incoming channel"));
+ DBG(FUNC, PVT_FMT(_target, "disconnecting incoming channel"));
//disconnected = command(KHOMP_LOG, CM_DISCONNECT);
}
{
if(call()->_cleanup_upon_hangup)
{
- DBG(FUNC, PVT_FMT(_target, "disconnecting not allocated outgoing channel..."));
+ DBG(FUNC, PVT_FMT(_target, "disconnecting not allocated outgoing channel..."));
disconnected = command(KHOMP_LOG, CM_DISCONNECT);
cleanup(KhompPvt::CLN_HARD);
}
else
{
- DBG(FUNC, PVT_FMT(_target, "disconnecting outgoing channel..."));
+ DBG(FUNC, PVT_FMT(_target, "disconnecting outgoing channel..."));
disconnected = command(KHOMP_LOG, CM_DISCONNECT);
}
stopStream();
stopListen();
-
+
}
catch (ScopedLockFailed & err)
{
LOG(ERROR, PVT_FMT(_target, "r (unable to lock %s!)") % err._msg.c_str() );
return false;
}
-
+
DBG(FUNC, PVT_FMT(_target, "r"));
return true;
case CommandRequest::ACTION:
break;
-
+
default:
ret = false;
}
-
+
DBG(STRM, PVT_FMT(target(), "r"));
return ret;
}
{
if(!board(devid)->eventHandler(evt.obj(), evt.event()))
{
- LOG(ERROR, D("(d=%d) Error on event (%d) \"%s\"")
- % devid
+ LOG(ERROR, D("(d=%d) Error on event (%d) \"%s\"")
+ % devid
% evt.event()->Code
% Globals::verbose.event(evt.obj(), evt.event()));
}
}
catch (K3LAPITraits::invalid_device & invalid)
{
- LOG(ERROR, D("invalid device on event '%s'")
+ LOG(ERROR, D("invalid device on event '%s'")
% Verbose::eventName(evt.event()->Code).c_str());
}
extern "C" int32 Kstdcall khompEventCallback(int32 obj, K3L_EVENT * e)
{
//if (K::Logger::Logg.classe(C_EVENT).enabled())
- // std::string msg = Globals::verbose.event (obj, e) + ".";
+ // std::string msg = Globals::verbose.event (obj, e) + ".";
LOGC(EVENT, FMT("%s.") % Globals::verbose.event(obj, e));
switch(e->Code)
{
- case EV_WATCHDOG_COUNT:
+ case EV_WATCHDOG_COUNT:
Board::kommuter.initialize(e);
break;
case EV_HARDWARE_FAIL:
KHOMP generic endpoint/channel library.
Copyright (C) 2007-2010 Khomp Ind. & Com.
- The contents of this file are subject to the Mozilla Public License
- Version 1.1 (the "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
+ The contents of this file are subject to the Mozilla Public License
+ Version 1.1 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
case the provisions of "LGPL License" are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
- the LGPL License and not to allow others to use your version of this file
- under the MPL, indicate your decision by deleting the provisions above and
- replace them with the notice and other provisions required by the LGPL
- License. If you do not delete the provisions above, a recipient may use your
+ the LGPL License and not to allow others to use your version of this file
+ under the MPL, indicate your decision by deleting the provisions above and
+ replace them with the notice and other provisions required by the LGPL
+ License. If you do not delete the provisions above, a recipient may use your
version of this file under either the MPL or the LGPL License.
The LGPL header follows below:
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with this library; if not, write to the Free Software Foundation,
+ along with this library; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*******************************************************************************/
/* we always have audio */
call()->_flags.set(Kflags::HAS_PRE_AUDIO);
-
+
if(callFXO()->_call_info_drop == 0 && !callFXO()->_call_info_report)
{
command(KHOMP_LOG, CM_DISABLE_CALL_ANSWER_INFO);
callFXO()->_flags.set(Kflags::CALL_WAIT_SEIZE);
if (!command(KHOMP_LOG, CM_SEIZE, call()->_orig_addr.c_str()))
- return ksFail;
+ return ksFail;
int timeout = 150;
callFXO()->_flags.set(Kflags::WAIT_SEND_DTMF);
if (!command(KHOMP_LOG, CM_DIAL_DTMF, callFXO()->_pre_digits.c_str()))
- return ksFail;
-
+ return ksFail;
+
if(!loopWhileFlagTimed(Kflags::WAIT_SEND_DTMF, timeout))
return ksFail;
/* we want the audio as soon as dialing ends */
callFXO()->_flags.set(Kflags::EARLY_RINGBACK);
-
+
if (!command(KHOMP_LOG, CM_DIAL_DTMF, call()->_dest_addr.c_str()))
return ksFail;
}
bool BoardFXO::KhompPvtFXO::onNewCall(K3L_EVENT *e)
{
DBG(FUNC,PVT_FMT(_target,"(FXO) c"));
-
+
bool ret = true;
try
}
command(KHOMP_LOG, CM_ENABLE_CALL_ANSWER_INFO);
-
+
ret = KhompPvt::onChannelRelease(e);
}
catch(ScopedLockFailed & err)
LOG(ERROR, PVT_FMT(target(), "(FXO) r (unable to lock %s!)") % err._msg.c_str() );
return false;
}
-
- DBG(FUNC, PVT_FMT(_target, "(FXO) r"));
+
+ DBG(FUNC, PVT_FMT(_target, "(FXO) r"));
return ret;
}
LOG(ERROR, PVT_FMT(target(), "(FXO) r (%s)") % err._msg.c_str() );
return false;
}
-
+
DBG(FUNC, PVT_FMT(_target, "(FXO) r"));
return ret;
bool BoardFXO::KhompPvtFXO::onCallFail(K3L_EVENT *e)
{
- bool ret = true;
+ bool ret = true;
try
{
ScopedPvtLock lock(this);
DBG(STRM, PVT_FMT(_target, "Fax detected"));
/* hadn't we did this already? */
- bool already_detected = call()->_flags.check(Kflags::FAX_DETECTED);
+ bool already_detected = call()->_flags.check(Kflags::FAX_DETECTED);
time_t time_was = call()->_call_statistics->_base_time;
time_t time_now = time(NULL);
bool detection_timeout = (time_now > (time_was + (time_t) (Opt::_options._fax_adjustment_timeout())));
-
+
BEGIN_CONTEXT
{
ScopedPvtLock lock(this);
if (callFXO()->_flags.check(Kflags::WAIT_SEND_DTMF) ||
callFXO()->_flags.check(Kflags::CALL_WAIT_SEIZE))
{
- /* waiting digit or seize means DEADLOCK if we try to
+ /* waiting digit or seize means DEADLOCK if we try to
* queue something below. */
DBG(FUNC, PVT_FMT(_target, "not queueing dtmf, waiting stuff!"));
return true;
{
if (callFXO()->_call_info_report)
{
- //TODO: HOW WE TREAT THAT
- // make the channel export this
+ //TODO: HOW WE TREAT THAT
+ // make the channel export this
setAnswerInfo(info_code);
}
bool BoardFXO::KhompPvtFXO::autoGainControl(bool enable)
{
bool ret = KhompPvt::autoGainControl(enable);
-
+
/* enable this AGC also, can be very useful */
ret &= command(KHOMP_LOG, (enable ? CM_ENABLE_PLAYER_AGC : CM_DISABLE_PLAYER_AGC));
return ret;
DBG(FUNC, PVT_FMT(_target,"signaled unknown call answer info '%d', using 'Unknown'...") % answer_info);
value = "Unknown";
}
-
+
DBG(FUNC,PVT_FMT(_target,"KCallAnswerInfo: %s") % value);
try
{
/* already connected or sent signaling... */
mixer(KHOMP_LOG, 1, kmsGenerator, kmtBusy);
-
+
if(!call()->_flags.check(Kflags::CONNECTED) && !sent_signaling)
{
- /* we are talking about branches, not trunks */
+ /* we are talking about branches, not trunks */
command(KHOMP_LOG, CM_CONNECT);
callFXO()->_busy_disconnect = Board::board(_target.device)->_timers.add(Opt::_options._fxo_busy_disconnection(), &BoardFXO::KhompPvtFXO::busyDisconnect, this);
}
}
DBG(FUNC,PVT_FMT(_target, "(FXO) r"));
- return true;
+ return true;
}
void BoardFXO::KhompPvtFXO::busyDisconnect(Board::KhompPvt * pvt)
{
DBG(FUNC, PVT_FMT(pvt->target(), "Disconnecting FXO"));
- try
- {
+ try
+ {
ScopedPvtLock lock(pvt);
pvt->command(KHOMP_LOG, CM_DISCONNECT);
- }
+ }
catch (...)
{
LOG(ERROR, PVT_FMT(pvt->target(), "unable to lock the pvt !"));
- }
+ }
}
void BoardFXO::KhompPvtFXO::reportFailToReceive(int fail_code)
KHOMP generic endpoint/channel library.
Copyright (C) 2007-2010 Khomp Ind. & Com.
- The contents of this file are subject to the Mozilla Public License
- Version 1.1 (the "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
+ The contents of this file are subject to the Mozilla Public License
+ Version 1.1 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
case the provisions of "LGPL License" are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
- the LGPL License and not to allow others to use your version of this file
- under the MPL, indicate your decision by deleting the provisions above and
- replace them with the notice and other provisions required by the LGPL
- License. If you do not delete the provisions above, a recipient may use your
+ the LGPL License and not to allow others to use your version of this file
+ under the MPL, indicate your decision by deleting the provisions above and
+ replace them with the notice and other provisions required by the LGPL
+ License. If you do not delete the provisions above, a recipient may use your
version of this file under either the MPL or the LGPL License.
The LGPL header follows below:
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with this library; if not, write to the Free Software Foundation,
+ along with this library; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*******************************************************************************/
call()->_flags.clear(Kflags::HAS_PRE_AUDIO);
command(KHOMP_LOG, CM_ENABLE_CALL_ANSWER_INFO);
-
+
ret = KhompPvt::onChannelRelease(e);
}
catch(ScopedLockFailed & err)
LOG(ERROR, PVT_FMT(target(), "(GSM) r (unable to lock %s!)") % err._msg.c_str() );
return false;
}
-
- DBG(FUNC, PVT_FMT(_target, "(GSM) r"));
+
+ DBG(FUNC, PVT_FMT(_target, "(GSM) r"));
return ret;
}
LOG(ERROR, PVT_FMT(target(), "(GSM) r (%s)") % err._msg.c_str() );
return false;
}
-
+
DBG(FUNC, PVT_FMT(_target, "(GSM) r"));
return ret;
DBG(FUNC, PVT_FMT(_target,"signaled unknown call answer info '%d', using 'Unknown'...") % answer_info);
value = "Unknown";
}
-
+
DBG(FUNC,PVT_FMT(_target,"KCallAnswerInfo: %s") % value);
try
{
if (callGSM()->_call_info_report)
{
- //TODO: HOW WE TREAT THAT
- // make the channel export this
+ //TODO: HOW WE TREAT THAT
+ // make the channel export this
setAnswerInfo(info_code);
}
try
{
ScopedPvtLock lock(this);
-
+
}
catch (ScopedLockFailed & err)
bool BoardGSM::KhompPvtGSM::onNewCall(K3L_EVENT *e)
{
DBG(FUNC,PVT_FMT(_target,"(GSM) c"));
-
+
try
{
ScopedPvtLock lock(this);
- bool ret = KhompPvtGSM::onNewCall(e);
+ bool ret = KhompPvtGSM::onNewCall(e);
}
catch(ScopedLockFailed & err)
bool BoardGSM::KhompPvtGSM::onCallFail(K3L_EVENT *e)
{
- bool ret = true;
+ bool ret = true;
try
{
ScopedPvtLock lock(this);
int BoardGSM::KhompPvtGSM::makeCall(std::string params)
{
DBG(FUNC,PVT_FMT(_target, "(GSM) c"));
-
+
if(callGSM()->_call_info_drop == 0 && !callGSM()->_call_info_report)
{
command(KHOMP_LOG, CM_DISABLE_CALL_ANSWER_INFO);
int owner_nr = 0;
- command(KHOMP_LOG, CM_DISCONNECT,
+ command(KHOMP_LOG, CM_DISCONNECT,
STG(FMT("gsm_call_ref=%d") % (int)owner_nr).c_str());
}
DBG(FUNC,PVT_FMT(_target, "(GSM) r"));
-
- return true;
+
+ return true;
}
void BoardGSM::KhompPvtGSM::reportFailToReceive(int fail_code)
{
int switch_cause = SWITCH_CAUSE_USER_BUSY;
- if (fail <= 127)
+ if (fail <= 127)
switch_cause = fail;
- else
+ else
switch_cause = SWITCH_CAUSE_INTERWORKING;
return switch_cause;
{
int k3l_fail = -1; // default
- if (cause <= 127)
+ if (cause <= 127)
k3l_fail = cause;
else
- k3l_fail = kgccInterworking;
+ k3l_fail = kgccInterworking;
return k3l_fail;
}
}
if (!extra_context.empty())
- {
+ {
if (!_group_context.empty())
- {
+ {
std::string pvt_context(_group_context);
- pvt_context += "-";
+ pvt_context += "-";
pvt_context += extra_context;
contexts.push_back(pvt_context);
- }
+ }
if (!Opt::_options._context_gsm_call().empty())
- {
+ {
std::string context(Opt::_options._context_gsm_call());
- context += "-";
+ context += "-";
context += extra_context;
contexts.push_back(_group_context);
}
if (!Opt::_options._context2_gsm_call().empty())
- {
+ {
std::string context(Opt::_options._context2_gsm_call());
- context += "-";
+ context += "-";
context += extra_context;
contexts.push_back(_group_context);
- }
- }
+ }
+ }
contexts.push_back(Opt::_options._context_gsm_call());
contexts.push_back(Opt::_options._context2_gsm_call());
- for (MatchExtension::ContextListType::iterator i = contexts.begin(); i != contexts.end(); i++)
+ for (MatchExtension::ContextListType::iterator i = contexts.begin(); i != contexts.end(); i++)
replaceTemplate((*i), "CC", _target.object);
bool ret = Board::KhompPvt::validContexts(contexts,extra_context);
KHOMP generic endpoint/channel library.
Copyright (C) 2007-2010 Khomp Ind. & Com.
- The contents of this file are subject to the Mozilla Public License
- Version 1.1 (the "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
+ The contents of this file are subject to the Mozilla Public License
+ Version 1.1 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
case the provisions of "LGPL License" are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
- the LGPL License and not to allow others to use your version of this file
- under the MPL, indicate your decision by deleting the provisions above and
- replace them with the notice and other provisions required by the LGPL
- License. If you do not delete the provisions above, a recipient may use your
+ the LGPL License and not to allow others to use your version of this file
+ under the MPL, indicate your decision by deleting the provisions above and
+ replace them with the notice and other provisions required by the LGPL
+ License. If you do not delete the provisions above, a recipient may use your
version of this file under either the MPL or the LGPL License.
The LGPL header follows below:
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with this library; if not, write to the Free Software Foundation,
+ along with this library; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*******************************************************************************/
return false;
}
- DBG(FUNC, PVT_FMT(_target, "(E1) r"));
+ DBG(FUNC, PVT_FMT(_target, "(E1) r"));
return ret;
}
if (call()->_pre_answer)
{
- dtmfSuppression(Opt::_options._out_of_band_dtmfs()&& !call()->_flags.check(Kflags::FAX_DETECTED));
+ dtmfSuppression(Opt::_options._out_of_band_dtmfs()&& !call()->_flags.check(Kflags::FAX_DETECTED));
startListen();
startStream();
LOG(ERROR, PVT_FMT(_target, "(E1) r (unable to get device: %d!)") % err.device);
return false;
}
-
+
DBG(FUNC, PVT_FMT(_target, "(E1) r"));
return ret;
DBG(STRM, PVT_FMT(_target, "Fax detected"));
/* hadn't we did this already? */
- bool already_detected = call()->_flags.check(Kflags::FAX_DETECTED);
+ bool already_detected = call()->_flags.check(Kflags::FAX_DETECTED);
time_t time_was = call()->_call_statistics->_base_time;
time_t time_now = time(NULL);
bool detection_timeout = (time_now > (time_was + (time_t) (Opt::_options._fax_adjustment_timeout())));
-
+
DBG(STRM, PVT_FMT(_target, "is set? (%s) timeout? (%s)")
% (already_detected ? "true" : "false") % (detection_timeout ? "true" : "false"));
break;
if (callE1()->_call_info_drop != 0 || callE1()->_call_info_report)
- {
+ {
/* we did not detected fax yet, send answer info! */
setAnswerInfo(Board::KhompPvt::CI_FAX);
if (callE1()->_call_info_drop & Board::KhompPvt::CI_FAX)
- {
+ {
/* fastest way to force a disconnection */
command(KHOMP_LOG,CM_DISCONNECT);//,SCE_HIDE);
- }
+ }
}
if (Opt::_options._auto_fax_adjustment())
}
bool ret = KhompPvt::onAudioStatus(e);
-
+
DBG(STRM, PVT_FMT(_target, "(E1) r"));
return ret;
bool BoardE1::KhompPvtE1::onCallAnswerInfo(K3L_EVENT *e)
{
DBG(FUNC, PVT_FMT(_target, "(E1) c"));
- try
- {
+ try
+ {
ScopedPvtLock lock(this);
int info_code = -1;
switch (e->AddInfo)
- {
+ {
case kcsiCellPhoneMessageBox:
info_code = CI_MESSAGE_BOX;
break;
default:
DBG(FUNC, PVT_FMT(_target, "got an unknown call answer info '%d', ignoring...") % e->AddInfo);
break;
- }
+ }
if (info_code != -1)
- {
+ {
if (callE1()->_call_info_report)
- {
- //TODO: HOW WE TREAT THAT
- // make the channel export this
+ {
+ //TODO: HOW WE TREAT THAT
+ // make the channel export this
setAnswerInfo(info_code);
- }
+ }
if (callE1()->_call_info_drop & info_code)
- {
- // fastest way to force a disconnection
+ {
+ // fastest way to force a disconnection
//K::util::sendCmd(pvt->boardid, pvt->objectid, CM_DISCONNECT, true, false);
command(KHOMP_LOG,CM_DISCONNECT/*,SCE_HIDE ?*/);
- }
- }
- }
+ }
+ }
+ }
catch (ScopedLockFailed & err)
{
LOG(ERROR, PVT_FMT(_target, "(E1) r (unable to lock %s!)") % err._msg.c_str() );
if(Opt::_options._disconnect_delay()== 0)
{
DBG(FUNC, PVT_FMT(_target, "queueing disconnecting outgoing channel!"));
- command(KHOMP_LOG, CM_DISCONNECT);
+ command(KHOMP_LOG, CM_DISCONNECT);
}
else
{
}
else
{
- /* in the case of a disconnect confirm is needed and a call
+ /* in the case of a disconnect confirm is needed and a call
was not started e.g. just after a ev_seizure_start */
command(KHOMP_LOG, CM_DISCONNECT);
}
-
+
ret = KhompPvt::onDisconnect(e);
}
{
DBG(FUNC,PVT_FMT(pvt->target(), "Delayed disconnect"));
- try
- {
+ try
+ {
ScopedPvtLock lock(pvt);
DBG(FUNC, PVT_FMT(pvt->target(), "queueing disconnecting outgoing channel after delaying!"));
pvt->command(KHOMP_LOG,CM_DISCONNECT);
pvt->cleanup(CLN_HARD);
- }
+ }
catch (...)
{
LOG(ERROR, PVT_FMT(pvt->target(), "r (unable to lock the pvt !)"));
- }
+ }
}
bool BoardE1::onLinkStatus(K3L_EVENT *e)
{
KUserInformationEx * info = (KUserInformationEx *) (((char*)e) + sizeof(K3L_EVENT));
callISDN()->_uui_descriptor = (long int) info->ProtocolDescriptor;
-
+
/* clean string */
callISDN()->_uui_information.clear();
if (info->UserInfoLength)
- {
+ {
/* append to a clean string */
- for (unsigned int i = 0; i < info->UserInfoLength; ++i)
+ for (unsigned int i = 0; i < info->UserInfoLength; ++i)
callISDN()->_uui_information += STG(FMT("%02hhx") % ((unsigned char) info->UserInfo[i]));
- }
+ }
}
else
{
KUserInformation * info = (KUserInformation *) (((char*)e) + sizeof(K3L_EVENT));
callISDN()->_uui_descriptor = info->ProtocolDescriptor;
-
+
/* clean string */
callISDN()->_uui_information.clear();
if (info->UserInfoLength)
- {
- for (unsigned int i = 0; i < info->UserInfoLength; ++i)
+ {
+ for (unsigned int i = 0; i < info->UserInfoLength; ++i)
callISDN()->_uui_information += STG(FMT("%02hhx") % ((unsigned char) info->UserInfo[i]));
- }
+ }
}
return true;
bool BoardE1::KhompPvtISDN::onNewCall(K3L_EVENT *e)
{
- DBG(FUNC,PVT_FMT(_target, "(ISDN) c"));
+ DBG(FUNC,PVT_FMT(_target, "(ISDN) c"));
bool isdn_reverse_charge = false;
std::string isdn_reverse_charge_str;
bool ret;
-
+
try
{
- callISDN()->_isdn_orig_type_of_number = Globals::k3lapi.get_param(e, "isdn_orig_type_of_number");
- callISDN()->_isdn_orig_numbering_plan = Globals::k3lapi.get_param(e, "isdn_orig_numbering_plan");
- callISDN()->_isdn_dest_type_of_number = Globals::k3lapi.get_param(e, "isdn_dest_type_of_number");
- callISDN()->_isdn_dest_numbering_plan = Globals::k3lapi.get_param(e, "isdn_dest_numbering_plan");
- callISDN()->_isdn_orig_presentation = Globals::k3lapi.get_param(e, "isdn_orig_presentation");
+ callISDN()->_isdn_orig_type_of_number = Globals::k3lapi.get_param(e, "isdn_orig_type_of_number");
+ callISDN()->_isdn_orig_numbering_plan = Globals::k3lapi.get_param(e, "isdn_orig_numbering_plan");
+ callISDN()->_isdn_dest_type_of_number = Globals::k3lapi.get_param(e, "isdn_dest_type_of_number");
+ callISDN()->_isdn_dest_numbering_plan = Globals::k3lapi.get_param(e, "isdn_dest_numbering_plan");
+ callISDN()->_isdn_orig_presentation = Globals::k3lapi.get_param(e, "isdn_orig_presentation");
isdn_reverse_charge_str = Globals::k3lapi.get_param(e, "isdn_reverse_charge");
isdn_reverse_charge = Strings::toboolean(isdn_reverse_charge_str);
}
{
bool pvt_locked = true;
bool is_ok = false;
-
+
DBG(FUNC, PVT_FMT(_target, "Session has not been destroyed yet, waiting for khompDestroy"));
for(unsigned int sleeps = 0; sleeps < 20; sleeps++)
}
pvt_locked = true;
-
+
if(!session())
{
is_ok = true;
}
if(isdn_reverse_charge)
- {
+ {
call()->_collect_call = true;
}
- ret = KhompPvtE1::onNewCall(e);
+ ret = KhompPvtE1::onNewCall(e);
}
catch(ScopedLockFailed & err)
{
return false;
}
- DBG(FUNC, PVT_FMT(_target, "(ISDN) r"));
+ DBG(FUNC, PVT_FMT(_target, "(ISDN) r"));
return ret;
}
return false;
- DBG(FUNC,PVT_FMT(_target, "doing the ISDN pre_connect"));
+ DBG(FUNC,PVT_FMT(_target, "doing the ISDN pre_connect"));
if (call()->_flags.check(Kflags::HAS_PRE_AUDIO))
{
}
bool ret = KhompPvtE1::sendDtmf(callISDN()->_digits_buffer);
-
+
callISDN()->_digits_buffer.clear();
return ret;
else
{
LOG(ERROR, PVT_FMT(target(), "Fail on make call"));
- }
+ }
return ret;
}
}
DBG(FUNC,PVT_FMT(_target, "(E1) r"));
-
- return true;
+
+ return true;
}
void BoardE1::KhompPvtE1::setAnswerInfo(int answer_info)
const char * value = answerInfoToString(answer_info);
if (value == NULL)
- {
+ {
DBG(FUNC, PVT_FMT(_target, "signaled unknown call answer info '%d', using 'Unknown'...") % answer_info);
value = "Unknown";
- }
-
+ }
+
DBG(FUNC,PVT_FMT(_target, "KCallAnswerInfo: %s") % value);
try
}
catch(Board::KhompPvt::InvalidSwitchChannel & err)
{
- LOG(ERROR,PVT_FMT(_target, "%s") % err._msg.c_str());
+ LOG(ERROR,PVT_FMT(_target, "%s") % err._msg.c_str());
}
}
Board::board(_target.device)->_timers.del(callE1()->_idx_disconnect);
bool fax_detected = callE1()->_flags.check(Kflags::FAX_DETECTED) || (callE1()->_var_fax_adjust == T_TRUE);
-
+
bool res_out_of_band_dtmf = (call()->_var_dtmf_state == T_UNKNOWN || fax_detected ?
Opt::_options._suppression_delay()&& Opt::_options._out_of_band_dtmfs()&& !fax_detected : (call()->_var_dtmf_state == T_TRUE));
-
+
bool res_echo_cancellator = (call()->_var_echo_state == T_UNKNOWN || fax_detected ?
Opt::_options._echo_canceller()&& !fax_detected : (call()->_var_echo_state == T_TRUE));
{
obtainRX(res_out_of_band_dtmf);
- /* esvazia buffers de leitura/escrita */
+ /* esvazia buffers de leitura/escrita */
cleanupBuffers();
if (!call()->_flags.check(Kflags::KEEP_DTMF_SUPPRESSION))
startStream();
- DBG(FUNC, PVT_FMT(_target, "(E1) Audio callbacks initialized successfully"));
+ DBG(FUNC, PVT_FMT(_target, "(E1) Audio callbacks initialized successfully"));
}
return Board::KhompPvt::setupConnection();
contexts.push_back(Opt::_options._context_digital());
- for (MatchExtension::ContextListType::iterator i = contexts.begin(); i != contexts.end(); i++)
- {
+ for (MatchExtension::ContextListType::iterator i = contexts.begin(); i != contexts.end(); i++)
+ {
replaceTemplate((*i), "LL", ((_target.object)/30));
replaceTemplate((*i), "CCC", _target.object);
}
int BoardE1::KhompPvtISDN::makeCall(std::string params)
{
- DBG(FUNC,PVT_FMT(_target, "(ISDN) c"));
+ DBG(FUNC,PVT_FMT(_target, "(ISDN) c"));
CallISDN * call = callISDN();
if(call->_uui_descriptor != -1)
{
- DBG(FUNC,PVT_FMT(_target, "got userinfo"));
+ DBG(FUNC,PVT_FMT(_target, "got userinfo"));
/* grab this information first, avoiding latter side-effects */
const bool info_extd = call->_uui_extended;
const size_t info_size = std::min<size_t>(call->_uui_information.size(), (info_extd ? KMAX_USER_USER_EX_LEN : KMAX_USER_USER_LEN) << 1) >> 1;
bool res = true;
-
+
if(info_extd)
{
KUserInformationEx info;
info.UserInfoLength = info_size;
for (unsigned int pos = 0u, index = 0u; pos < info_size; index+=2, ++pos)
- info.UserInfo[pos] = (unsigned char)Strings::toulong(info_data.substr(index,2), 16);
+ info.UserInfo[pos] = (unsigned char)Strings::toulong(info_data.substr(index,2), 16);
if (!command(KHOMP_LOG, CM_USER_INFORMATION_EX, (const char *) &info))
{
- LOG(ERROR,PVT_FMT(_target, "UUI could not be sent before dialing!"));
+ LOG(ERROR,PVT_FMT(_target, "UUI could not be sent before dialing!"));
}
- }
+ }
else
{
KUserInformation info;
info.UserInfoLength = info_size;
for (unsigned int pos = 0u, index = 0u; pos < info_size; index+=2, ++pos)
- info.UserInfo[pos] = (unsigned char)Strings::toulong(info_data.substr(index,2), 16);
+ info.UserInfo[pos] = (unsigned char)Strings::toulong(info_data.substr(index,2), 16);
if (!command(KHOMP_LOG, CM_USER_INFORMATION, (const char *) &info))
{
- LOG(ERROR,PVT_FMT(_target, "UUI could not be sent before dialing!"));
+ LOG(ERROR,PVT_FMT(_target, "UUI could not be sent before dialing!"));
}
}
- call->_uui_extended = false;
+ call->_uui_extended = false;
call->_uui_descriptor = -1;
call->_uui_information.clear();
}
- if (!callISDN()->_isdn_orig_type_of_number.empty())
+ if (!callISDN()->_isdn_orig_type_of_number.empty())
{
- params += "isdn_orig_type_of_number=\"";
- params += callISDN()->_isdn_orig_type_of_number;
- params += "\" ";
+ params += "isdn_orig_type_of_number=\"";
+ params += callISDN()->_isdn_orig_type_of_number;
+ params += "\" ";
}
- if (!callISDN()->_isdn_dest_type_of_number.empty())
- {
- params += "isdn_dest_type_of_number=\"";
- params += callISDN()->_isdn_dest_type_of_number;
- params += "\" ";
+ if (!callISDN()->_isdn_dest_type_of_number.empty())
+ {
+ params += "isdn_dest_type_of_number=\"";
+ params += callISDN()->_isdn_dest_type_of_number;
+ params += "\" ";
}
- if (!callISDN()->_isdn_orig_numbering_plan.empty())
- {
- params += "isdn_orig_numbering_plan=\"";
- params += callISDN()->_isdn_orig_numbering_plan;
- params += "\" ";
+ if (!callISDN()->_isdn_orig_numbering_plan.empty())
+ {
+ params += "isdn_orig_numbering_plan=\"";
+ params += callISDN()->_isdn_orig_numbering_plan;
+ params += "\" ";
}
- if (!callISDN()->_isdn_dest_numbering_plan.empty())
- {
- params += "isdn_dest_numbering_plan=\"";
- params += callISDN()->_isdn_dest_numbering_plan;
- params += "\" ";
+ if (!callISDN()->_isdn_dest_numbering_plan.empty())
+ {
+ params += "isdn_dest_numbering_plan=\"";
+ params += callISDN()->_isdn_dest_numbering_plan;
+ params += "\" ";
}
if (!callISDN()->_isdn_orig_presentation.empty())
- {
- params += "isdn_orig_presentation=\"";
- params += callISDN()->_isdn_orig_presentation;
- params += "\" ";
+ {
+ params += "isdn_orig_presentation=\"";
+ params += callISDN()->_isdn_orig_presentation;
+ params += "\" ";
}
int ret = KhompPvtE1::makeCall(params);
call->_cleanup_upon_hangup = (ret == ksInvalidParams || ret == ksBusy);
-
- DBG(FUNC,PVT_FMT(_target, "(ISDN) r"));
+
+ DBG(FUNC,PVT_FMT(_target, "(ISDN) r"));
return ret;
}
if(fail_code != -1)
{
- DBG(FUNC,PVT_FMT(_target, "sending a 'unknown number' message/audio"));
+ DBG(FUNC,PVT_FMT(_target, "sending a 'unknown number' message/audio"));
if(sendRingBackStatus(fail_code) == RingbackDefs::RBST_UNSUPPORTED)
{
int BoardE1::KhompPvtR2::makeCall(std::string params)
{
- DBG(FUNC,PVT_FMT(_target, "(R2) c"));
+ DBG(FUNC,PVT_FMT(_target, "(R2) c"));
if (callR2()->_r2_category != -1)
params += STG(FMT(" r2_categ_a=\"%ld\"")
int ret = KhompPvtE1::makeCall(params);
call()->_cleanup_upon_hangup = (ret == ksInvalidParams);
-
- DBG(FUNC,PVT_FMT(_target, "(R2) r"));
+
+ DBG(FUNC,PVT_FMT(_target, "(R2) r"));
return ret;
}
// do we have to send ringback? yes we need !!!
if(do_send_ring)
- {
+ {
call()->_flags.clear(Kflags::NEEDS_RINGBACK_CMD);
//TODO: callFailFromCause ??
command(KHOMP_LOG, CM_CONNECT);
}
- if(!do_send_ring && has_drop_collect_call)
+ if(!do_send_ring && has_drop_collect_call)
{
usleep(75000);
stopStream();
if (call()->_indication == INDICA_NONE)
- {
+ {
call()->_indication = INDICA_BUSY;
mixer(KHOMP_LOG, 1, kmsGenerator, kmtBusy);
- }
+ }
DBG(FUNC, PVT_FMT(_target,"forcing disconnect for collect call"));
forceDisconnect();
}
else
{
- DBG(FUNC,PVT_FMT(_target, "disconnecting outgoing channel..."));
+ DBG(FUNC,PVT_FMT(_target, "disconnecting outgoing channel..."));
disconnected = command(KHOMP_LOG, CM_DISCONNECT);
}
{
int switch_cause = SWITCH_CAUSE_USER_BUSY;
- if (fail <= 127)
+ if (fail <= 127)
switch_cause = fail;
- else
+ else
switch_cause = SWITCH_CAUSE_INTERWORKING;
return switch_cause;
if (Opt::_options._r2_strict_behaviour()&& fail_code != -1)
{
- DBG(FUNC,PVT_FMT(_target, "sending a 'unknown number' message/audio"));
+ DBG(FUNC,PVT_FMT(_target, "sending a 'unknown number' message/audio"));
if(sendRingBackStatus(fail_code) == RingbackDefs::RBST_UNSUPPORTED)
{
{
int k3l_fail = -1; // default
- try
- {
+ try
+ {
bool handled = false;
switch (_r2_country)
- {
+ {
case Verbose::R2_COUNTRY_ARG:
switch (cause)
- {
+ {
case SWITCH_CAUSE_UNALLOCATED_NUMBER:
case SWITCH_CAUSE_NO_ROUTE_TRANSIT_NET:
case SWITCH_CAUSE_NO_ROUTE_DESTINATION:
default:
k3l_fail = kgbArLineOutOfOrder;
break;
- }
+ }
handled = true;
break;
case Verbose::R2_COUNTRY_BRA:
switch (cause)
- {
+ {
case SWITCH_CAUSE_UNALLOCATED_NUMBER:
case SWITCH_CAUSE_NO_ROUTE_TRANSIT_NET:
case SWITCH_CAUSE_NO_ROUTE_DESTINATION:
break;
}
-
+
if (!handled)
throw std::runtime_error("");
}
{
int k3l_fail = -1; // default
- if (cause <= 127)
+ if (cause <= 127)
k3l_fail = cause;
- else
+ else
k3l_fail = kq931cInterworking;
return k3l_fail;
RingbackDefs::RingbackStType BoardE1::KhompPvtR2::sendRingBackStatus(int rb_value)
{
- DBG(FUNC,PVT_FMT(_target, "(p=%p) this is the r2 ringback procedure") % this);
+ DBG(FUNC,PVT_FMT(_target, "(p=%p) this is the r2 ringback procedure") % this);
std::string cause = (rb_value == -1 ? "" : STG(FMT("r2_cond_b=\"%d\"") % rb_value));
return (command(KHOMP_LOG, CM_RINGBACK, cause.c_str()) ?
bool BoardE1::KhompPvtR2::sendPreAudio(int rb_value)
{
- DBG(FUNC,PVT_FMT(_target, "must send R2 preaudio ?"));
+ DBG(FUNC,PVT_FMT(_target, "must send R2 preaudio ?"));
if(!KhompPvtE1::sendPreAudio(rb_value))
return false;
- DBG(FUNC,PVT_FMT(_target, "doing the R2 pre_connect wait..."));
+ DBG(FUNC,PVT_FMT(_target, "doing the R2 pre_connect wait..."));
/* wait some ms, just to be sure the command has been sent. */
usleep(Opt::_options._r2_preconnect_wait()* 1000);
void BoardE1::KhompPvtR2::numberDialTimer(Board::KhompPvt * pvt)
{
- try
- {
+ try
+ {
ScopedPvtLock lock(pvt);
if (!pvt->call()->_flags.check(Kflags::NUMBER_DIAL_ONGOING) ||
pvt->call()->_flags.check(Kflags::NUMBER_DIAL_FINISHD))
- {
+ {
return;
- }
+ }
pvt->call()->_flags.set(Kflags::NUMBER_DIAL_FINISHD);
static_cast<BoardE1::KhompPvtR2*>(pvt)->callR2()->_incoming_exten.clear();
pvt->command(KHOMP_LOG, CM_END_OF_NUMBER);
- }
+ }
catch (...)
- {
+ {
// TODO: log something.
- }
+ }
}
bool BoardE1::KhompPvtR2::indicateRinging()
{
- DBG(FUNC, PVT_FMT(_target, "(R2) c"));
+ DBG(FUNC, PVT_FMT(_target, "(R2) c"));
bool ret = false;
try
/* already playing! */
if (call()->_indication != INDICA_NONE)
- {
+ {
DBG(FUNC, PVT_FMT(_target, "(R2) r (already playing something: %d)") % call()->_indication);
return false;
- }
+ }
// any collect calls ?
setCollectCall();
bool send_ringback = true;
if (!call()->_flags.check(Kflags::CONNECTED))
- {
+ {
int ringback_value = RingbackDefs::RB_SEND_DEFAULT;
bool do_drop_call = Opt::_options._drop_collect_call()
const char *condition_string = getFSChannelVar("KR2SendCondition");
- try
- {
+ try
+ {
if (condition_string)
- {
+ {
ringback_value = Strings::toulong(condition_string);
DBG(FUNC, PVT_FMT(_target, "KR2SendCondition adjusted ringback value to %d") % ringback_value);
- }
- }
+ }
+ }
catch (Strings::invalid_value e)
- {
+ {
LOG(ERROR, PVT_FMT(_target, "invalid value '%s', adjusted in KR2SendCondition: not a valid number.")
% condition_string);
- }
+ }
if (Opt::_options._r2_strict_behaviour())
{
}
if (send_ringback)
- {
+ {
DBG(FUNC, PVT_FMT(_target, "Send ringback!"));
call()->_flags.set(Kflags::GEN_CO_RING);
/* start stream if it is not already */
startStream();
- ret = true;
- }
+ ret = true;
+ }
}
catch (ScopedLockFailed & err)
LOG(ERROR, PVT_FMT(_target, "(R2) r (unable to get device: %d!)") % err.device);
return false;
}
-
+
DBG(FUNC, PVT_FMT(_target, "(R2) r"));
return ret;
}
bool BoardE1::KhompPvtR2::onNewCall(K3L_EVENT *e)
{
- DBG(FUNC,PVT_FMT(_target, "(R2) c"));
+ DBG(FUNC,PVT_FMT(_target, "(R2) c"));
std::string r2_categ_a;
if (status == ksSuccess && !r2_categ_a.empty())
{
- try
- {
- callR2()->_r2_category = Strings::toulong(r2_categ_a);
+ try
+ {
+ callR2()->_r2_category = Strings::toulong(r2_categ_a);
}
- catch (Strings::invalid_value e)
- {
- /* do nothing */
+ catch (Strings::invalid_value e)
+ {
+ /* do nothing */
};
/* channel will know if is a collect call or not */
DBG(FUNC,PVT_FMT(_target, "Setting DROP_COLLECT flag"));
}
- freeFSGlobalVar(&drop_str);
+ freeFSGlobalVar(&drop_str);
// keeping the hardcore mode
if (do_drop_collect && call()->_collect_call)
}
else
{
- // send ringback too!
+ // send ringback too!
sendPreAudio(RingbackDefs::RB_SEND_DEFAULT);
startStream();
}
return false;
}
- DBG(FUNC,PVT_FMT(_target, "(R2) r"));
+ DBG(FUNC,PVT_FMT(_target, "(R2) r"));
return true;
}
}
catch(Board::KhompPvt::InvalidSwitchChannel & err)
{
- LOG(ERROR,PVT_FMT(_target, "%s") % err._msg.c_str());
+ LOG(ERROR,PVT_FMT(_target, "%s") % err._msg.c_str());
return false;
}
{
DBG(FUNC, PVT_FMT(_target, "(digit=%d) c") % e->AddInfo);
- try
- {
+ try
+ {
ScopedPvtLock lock(this);
if (call()->_flags.check(Kflags::NUMBER_DIAL_FINISHD))
return false;
if (!call()->_flags.check(Kflags::NUMBER_DIAL_ONGOING))
- {
+ {
DBG(FUNC, PVT_FMT(_target, "incoming number start..."));
call()->_flags.set(Kflags::NUMBER_DIAL_ONGOING);
callR2()->_idx_number_dial = Board::board(_target.device)->_timers.add(4000,
&BoardE1::KhompPvtR2::numberDialTimer, this, TM_VAL_CALL);
- }
- else
- {
+ }
+ else
+ {
Board::board(_target.device)->_timers.restart(callR2()->_idx_number_dial);
- }
+ }
callR2()->_incoming_exten += e->AddInfo;
std::string tmp_orig("");
switch (MatchExtension::findExtension(tmp_exten, tmp_context, contexts, callR2()->_incoming_exten,tmp_orig, false, false))
- {
+ {
case MatchExtension::MATCH_EXACT:
case MatchExtension::MATCH_NONE:
call()->_flags.set(Kflags::NUMBER_DIAL_FINISHD);
DBG(FUNC, "didn't match exact extension, waiting...");
// cannot say anything exact about the number, do nothing...
break;
- }
- }
+ }
+ }
catch (ScopedLockFailed & err)
- {
+ {
LOG(ERROR, PVT_FMT(target(), "unable to lock %s!") % err._msg.c_str() );
return false;
- }
+ }
catch (K3LAPITraits::invalid_device & err)
{
LOG(ERROR, PVT_FMT(_target, "unable to get device: %d!") % err.device);
parseBranchOptions(it3->second);
}
- //TODO: Implementar o setVolume para levar em consideracao que o
+ //TODO: Implementar o setVolume para levar em consideracao que o
// padrao pode ser o da FXS
if (_input_volume != Opt::_options._input_volume())
setVolume("input", _input_volume);
try
{
ScopedPvtLock lock(this);
-
+
/* we always have audio */
call()->_flags.set(Kflags::HAS_PRE_AUDIO);
if (justAlloc(true) != SWITCH_STATUS_SUCCESS)
{
int fail_code = callFailFromCause(SWITCH_CAUSE_UNALLOCATED_NUMBER);
- setHangupCause(SWITCH_CAUSE_UNALLOCATED_NUMBER);
+ setHangupCause(SWITCH_CAUSE_UNALLOCATED_NUMBER);
cleanup(CLN_FAIL);
reportFailToReceive(fail_code);
LOG(ERROR,PVT_FMT(_target, "(FXS) r (Initilization Error on alloc!)"));
LOG(ERROR,PVT_FMT(_target, "(FXS) r (unable to lock %s!)") % err._msg.c_str() );
return false;
}
-
+
DBG(FUNC, PVT_FMT(_target, "(FXS) r"));
return ret;
if (call()->_pre_answer)
{
- dtmfSuppression(Opt::_options._out_of_band_dtmfs());
+ dtmfSuppression(Opt::_options._out_of_band_dtmfs());
startListen();
startStream();
call()->_flags.set(Kflags::GEN_PBX_RING);
call()->_idx_pbx_ring = Board::board(_target.device)->_timers.add(
Opt::_options._ringback_pbx_delay(),
- &Board::KhompPvt::pbxRingGen,
- this,
+ &Board::KhompPvt::pbxRingGen,
+ this,
TM_VAL_CALL);
}
LOG(ERROR, PVT_FMT(target(), "(FXS) r (%s)") % err._msg.c_str() );
return false;
}
-
+
DBG(FUNC, PVT_FMT(_target, "(FXS) r"));
return ret;
try
{
ScopedPvtLock lock(pvt);
-
+
KhompPvtFXS * pvt_fxs = static_cast<BoardE1::KhompPvtFXS*>(pvt);
- if(!pvt_fxs->callFXS()->_flags.check(Kflags::FXS_DIAL_ONGOING)
+ if(!pvt_fxs->callFXS()->_flags.check(Kflags::FXS_DIAL_ONGOING)
|| pvt_fxs->callFXS()->_flags.check(Kflags::FXS_DIAL_FINISHD))
return;
if(pvt_fxs->callFXS()->_flash_transfer.empty())
{
DBG(FUNC, PVT_FMT(pvt->target(), "r (Number is empty)"));
-
+
if(!pvt_fxs->stopTransfer())
{
pvt_fxs->cleanup(KhompPvt::CLN_HARD);
return;
}
- // begin context adjusting + processing
+ // begin context adjusting + processing
MatchExtension::ContextListType contexts;
pvt_fxs->validContexts(contexts);
case MatchExtension::MATCH_NONE:
{
DBG(FUNC, PVT_FMT(pvt_fxs->target(), "match none!"));
-
+
if(!pvt_fxs->stopTransfer())
{
pvt_fxs->cleanup(KhompPvt::CLN_HARD);
LOG(ERROR, PVT_FMT(pvt->target(), "r (unable to lock %s!)") % err._msg.c_str());
return;
}
-
+
DBG(FUNC, PVT_FMT(pvt->target(), "r"));
}
/*
if(!callFXS()->_uuid_other_session.empty() && session())
{
-
+
//switch_core_session_t *hold_session;
- //if ((hold_session = switch_core_session_locate(callFXS()->_uuid_other_session.c_str())))
+ //if ((hold_session = switch_core_session_locate(callFXS()->_uuid_other_session.c_str())))
//{
// switch_channel_t * hold = switch_core_session_get_channel(hold_session);
// switch_channel_stop_broadcast(hold);
// switch_channel_wait_for_flag(hold, CF_BROADCAST, SWITCH_FALSE, 5000, NULL);
// switch_core_session_rwunlock(hold_session);
//}
-
+
try
{
- // get other side of the bridge
+ // get other side of the bridge
switch_core_session_t * peer_session = getFSLockedPartnerSession();
unlockPartner(peer_session);
DBG(FUNC, PVT_FMT(target(), "bridge with the new session"));
DBG(FUNC, PVT_FMT(_target, "(FXS) r"));
return ret;
-
+
}
/*
bool BoardE1::KhompPvtFXS::startTransfer()
{
stream = "silence";
}
-
+
unlockPartner(peer_session);
DBG(FUNC, PVT_FMT(target(), "stream=%s") % stream);
if (stream && strcasecmp(stream, "silence"))
{
- // Freeswitch not get/put frames
+ // Freeswitch not get/put frames
//switch_channel_set_flag(channel, CF_HOLD);
switch_ivr_broadcast(getUUID(peer_session), stream, SMF_ECHO_ALEG | SMF_LOOP);
}
callFXS()->_flags.set(Kflags::FXS_FLASH_TRANSFER);
-
+
startCadence(PLAY_PBX_TONE);
- callFXS()->_idx_transfer = Board::board(_target.device)->_timers.add(Opt::_options._fxs_digit_timeout()* 1000, &BoardE1::KhompPvtFXS::transferTimer, this, TM_VAL_CALL);
+ callFXS()->_idx_transfer = Board::board(_target.device)->_timers.add(Opt::_options._fxs_digit_timeout()* 1000, &BoardE1::KhompPvtFXS::transferTimer, this, TM_VAL_CALL);
}
catch(Board::KhompPvt::InvalidSwitchChannel & err)
DBG(FUNC, PVT_FMT(target(), "c"));
callFXS()->_flags.clear(Kflags::FXS_FLASH_TRANSFER);
-
+
callFXS()->_flash_transfer.clear();
stopCadence();
try
{
- // get other side of the bridge
+ // get other side of the bridge
switch_core_session_t * peer_session = getFSLockedPartnerSession();
switch_channel_t * peer_channel = getFSChannel(peer_session);
DBG(FUNC, D("state change=%d") % state);
- if (state == CS_PARK)
+ if (state == CS_PARK)
{
switch_core_event_hook_remove_state_change(session, xferHook);
BoardE1::KhompPvtFXS * pvt = static_cast<BoardE1::KhompPvtFXS*>(switch_core_session_get_private(session));
-
+
if(!pvt)
{
DBG(FUNC, D("pvt is NULL"));
}
catch(ScopedLockFailed & err)
{
- LOG(ERROR, PVT_FMT(pvt->target(), "unable to lock: %s!") % err._msg.c_str());
+ LOG(ERROR, PVT_FMT(pvt->target(), "unable to lock: %s!") % err._msg.c_str());
return SWITCH_STATUS_FALSE;
}
catch(Board::KhompPvt::InvalidSwitchChannel & err)
{
- LOG(ERROR, PVT_FMT(pvt->target(), "%s!") % err._msg.c_str());
+ LOG(ERROR, PVT_FMT(pvt->target(), "%s!") % err._msg.c_str());
return SWITCH_STATUS_FALSE;
}
}
- else if (state == CS_HANGUP)
+ else if (state == CS_HANGUP)
{
switch_core_event_hook_remove_state_change(session, xferHook);
//}
//catch(ScopedLockFailed & err)
//{
- // LOG(ERROR, PVT_FMT(pvt->target(), "unable to lock: %s!") % err._msg.c_str());
+ // LOG(ERROR, PVT_FMT(pvt->target(), "unable to lock: %s!") % err._msg.c_str());
//}
}
try
{
- // get other side of the bridge
+ // get other side of the bridge
switch_core_session_t * peer_session = getFSLockedPartnerSession();
switch_channel_t * peer_channel = getFSChannel(peer_session);
else
{
DBG(FUNC, PVT_FMT(target(), "first transfer"));
- callFXS()->_uuid_other_session = getUUID(peer_session);
+ callFXS()->_uuid_other_session = getUUID(peer_session);
const char *stream = NULL;
if (!(stream = switch_channel_get_hold_music(peer_channel)))
else
{
switch_ivr_session_transfer(peer_session, "endless_playback:local_stream://moh,park", "inline", NULL);
- //switch_ivr_session_transfer(peer_session, "park", "inline", NULL);
+ //switch_ivr_session_transfer(peer_session, "park", "inline", NULL);
}
}
call()->_flags.set(Kflags::GEN_CO_RING);
startCadence(PLAY_RINGBACK);
-
+
//try
//{
// call()->_idx_co_ring = Board::board(_target.device)->_timers.add(Opt::_options._ringback_co_delay(), &Board::KhompPvt::coRingGen,this);
//{
// LOG(ERROR, PVT_FMT(_target, "unable to get device: %d!") % err.device);
//}
-
+
}
}
catch(Board::KhompPvt::InvalidSwitchChannel & err)
{
ScopedPvtLock lock(this);
- if (call()->_flags.check(Kflags::IS_INCOMING) &&
+ if (call()->_flags.check(Kflags::IS_INCOMING) &&
callFXS()->_flags.check(Kflags::FXS_OFFHOOK) &&
!callFXS()->_flags.check(Kflags::FXS_DIAL_FINISHD))
{
DBG(FUNC, PVT_FMT(target(), "match none!"));
std::string invalid = "i";
-
+
Board::board(_target.device)->_timers.del(callFXS()->_idx_dial);
switch (MatchExtension::findExtension(tmp_exten, tmp_context, contexts, invalid, call()->_orig_addr, true, false))
}
callFXS()->_flash_transfer += e->AddInfo;
-
+
// begin context adjusting + processing
MatchExtension::ContextListType contexts;
std::string tmp_exten;
std::string tmp_context;
-
+
switch (MatchExtension::findExtension(tmp_exten, tmp_context, contexts, callFXS()->_flash_transfer, call()->_orig_addr, false, false))
{
case MatchExtension::MATCH_EXACT:
LOG(ERROR, PVT_FMT(_target, "(FXS) r (unable to get device: %d!)") % err.device);
return false;
}
-
+
DBG(FUNC, PVT_FMT(_target, "(FXS) r"));
return ret;
LOG(ERROR, PVT_FMT(_target, "(FXS) r (unable to lock %s!)") % err._msg.c_str() );
return false;
}
-
+
DBG(FUNC, PVT_FMT(_target, "(FXS) r"));
return ret;
LOG(ERROR, PVT_FMT(_target, "(FXS) r (unable to lock %s!)") % err._msg.c_str() );
return false;
}
-
+
DBG(FUNC, PVT_FMT(_target, "(FXS) r"));
return true;
/* we always have audio */
call()->_flags.set(Kflags::HAS_PRE_AUDIO);
-
+
if (Opt::_options._fxs_bina()&& !call()->_orig_addr.empty())
{
/* Sending Bina DTMF*/
bool BoardE1::KhompPvtFXS::doChannelAnswer(CommandRequest &cmd)
{
DBG(FUNC, PVT_FMT(_target, "(FXS) c"));
-
+
bool ret = true;
try
bool BoardE1::KhompPvtFXS::doChannelHangup(CommandRequest &cmd)
{
DBG(FUNC, PVT_FMT(_target, "(FXS) c"));
-
+
bool ret = true;
bool answered = true;
try
{
ScopedPvtLock lock(this);
-
+
/*
if(!callFXS()->_uuid_other_session.empty())
{
DBG(FUNC,PVT_FMT(_target, "unable to transfer"));
-
+
switch_core_session_t *hold_session;
- if ((hold_session = switch_core_session_locate(callFXS()->_uuid_other_session.c_str())))
+ if ((hold_session = switch_core_session_locate(callFXS()->_uuid_other_session.c_str())))
{
switch_channel_t *hold_channel = switch_core_session_get_channel(hold_session);
switch_core_session_rwunlock(hold_session);
switch_channel_hangup(hold_channel, (switch_call_cause_t)call()->_hangup_cause);
//switch_channel_hangup(hold_channel, SWITCH_CAUSE_ATTENDED_TRANSFER);
}
- callFXS()->_uuid_other_session.clear();
+ callFXS()->_uuid_other_session.clear();
}
*/
}
else
{
- DBG(FUNC,PVT_FMT(_target, "disconnecting outgoing channel..."));
+ DBG(FUNC,PVT_FMT(_target, "disconnecting outgoing channel..."));
disconnected = command(KHOMP_LOG, CM_DISCONNECT);
}
if(fail_code != -1)
{
- DBG(FUNC,PVT_FMT(_target, "sending a 'unknown number' message/audio"));
+ DBG(FUNC,PVT_FMT(_target, "sending a 'unknown number' message/audio"));
if(sendRingBackStatus(fail_code) == RingbackDefs::RBST_UNSUPPORTED)
{
MatchExtension::ContextListType & contexts, std::string extra_context)
{
DBG(FUNC,PVT_FMT(_target, "(FXS) c"));
-
+
if(!_context.empty())
contexts.push_back(_context);
KHOMP generic endpoint/channel library.
Copyright (C) 2007-2010 Khomp Ind. & Com.
- The contents of this file are subject to the Mozilla Public License
- Version 1.1 (the "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
+ The contents of this file are subject to the Mozilla Public License
+ Version 1.1 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
case the provisions of "LGPL License" are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
- the LGPL License and not to allow others to use your version of this file
- under the MPL, indicate your decision by deleting the provisions above and
- replace them with the notice and other provisions required by the LGPL
- License. If you do not delete the provisions above, a recipient may use your
+ the LGPL License and not to allow others to use your version of this file
+ under the MPL, indicate your decision by deleting the provisions above and
+ replace them with the notice and other provisions required by the LGPL
+ License. If you do not delete the provisions above, a recipient may use your
version of this file under either the MPL or the LGPL License.
The LGPL header follows below:
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with this library; if not, write to the Free Software Foundation,
+ along with this library; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*******************************************************************************/
bool BoardPassive::KhompPvtHI::onSeizureStart(K3L_EVENT *e)
{
DBG(FUNC,PVT_FMT(_target,"(HI) c"));
-
+
try
{
ScopedPvtLock lock(this);
Globals::k3lapi.get_param(e, "orig_addr", orig_addr);
Globals::k3lapi.get_param(e, "dest_addr", dest_addr);
-
+
if(dest_addr.empty())
{
dest_addr="s";
}
- bool isdn_reverse_charge = false;
+ bool isdn_reverse_charge = false;
std::string isdn_reverse_charge_str;
- int isdn_status = Globals::k3lapi.get_param(e, "isdn_reverse_charge", isdn_reverse_charge_str);
+ int isdn_status = Globals::k3lapi.get_param(e, "isdn_reverse_charge", isdn_reverse_charge_str);
if (isdn_status == ksSuccess && !isdn_reverse_charge_str.empty())
{
if(isdn_reverse_charge || r2_category == kg2CollectCall)
{
- call()->_collect_call = true;
+ call()->_collect_call = true;
}
#if SWITCH_LESS_THAN(1,0,6)
LOG(ERROR, PVT_FMT(target(), "(KPR) r (unable to lock %s!)") % err._msg.c_str() );
return false;
}
-
- DBG(FUNC, PVT_FMT(_target, "(KPR) r"));
+
+ DBG(FUNC, PVT_FMT(_target, "(KPR) r"));
return true;
}
KHOMP generic endpoint/channel library.
Copyright (C) 2007-2010 Khomp Ind. & Com.
- The contents of this file are subject to the Mozilla Public License
- Version 1.1 (the "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
+ The contents of this file are subject to the Mozilla Public License
+ Version 1.1 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
case the provisions of "LGPL License" are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
- the LGPL License and not to allow others to use your version of this file
- under the MPL, indicate your decision by deleting the provisions above and
- replace them with the notice and other provisions required by the LGPL
- License. If you do not delete the provisions above, a recipient may use your
+ the LGPL License and not to allow others to use your version of this file
+ under the MPL, indicate your decision by deleting the provisions above and
+ replace them with the notice and other provisions required by the LGPL
+ License. If you do not delete the provisions above, a recipient may use your
version of this file under either the MPL or the LGPL License.
The LGPL header follows below:
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with this library; if not, write to the Free Software Foundation,
+ along with this library; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*******************************************************************************/
KHOMP generic endpoint/channel library.
Copyright (C) 2007-2010 Khomp Ind. & Com.
- The contents of this file are subject to the Mozilla Public License
- Version 1.1 (the "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
+ The contents of this file are subject to the Mozilla Public License
+ Version 1.1 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
case the provisions of "LGPL License" are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
- the LGPL License and not to allow others to use your version of this file
- under the MPL, indicate your decision by deleting the provisions above and
- replace them with the notice and other provisions required by the LGPL
- License. If you do not delete the provisions above, a recipient may use your
+ the LGPL License and not to allow others to use your version of this file
+ under the MPL, indicate your decision by deleting the provisions above and
+ replace them with the notice and other provisions required by the LGPL
+ License. If you do not delete the provisions above, a recipient may use your
version of this file under either the MPL or the LGPL License.
The LGPL header follows below:
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with this library; if not, write to the Free Software Foundation,
+ along with this library; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*******************************************************************************/
{
return file.provide();
}
-
+
bool Logger::start()
{
/* we love shortcuts! */
- typedef LogManager::Option LogOpt;
+ typedef LogManager::Option LogOpt;
typedef LogOpt::Flags Flags;
- typedef LogOpt::InitFlags FL;
+ typedef LogOpt::InitFlags FL;
/* configures default log levels */
Logger::Logg.classe(C_ERROR)
std::string new_gen;
for (unsigned int i = 0;; i++)
- {
- std::string tmp = base_path + STG(FMT("generic.%d.log") % i);
+ {
+ std::string tmp = base_path + STG(FMT("generic.%d.log") % i);
if (access(tmp.c_str(), R_OK|W_OK) != 0 && errno == ENOENT)
- {
+ {
new_gen = tmp;
break;
- }
- }
+ }
+ }
std::string old_gen = base_path + "generic.log";
if (rename(old_gen.c_str(), new_gen.c_str()) != 0)
- {
+ {
Logger::Logg(C_ERROR, FMT("unable to move generic log file: %s.") % strerror(errno));
return false;
- }
+ }
Globals::logs_being_rotated = true;
Strings::Merger strs;
- for (Strings::vector_type::iterator i = tokens.begin(); i != tokens.end(); i++)
- {
+ for (Strings::vector_type::iterator i = tokens.begin(); i != tokens.end(); i++)
+ {
std::string tok = Strings::trim(*i);
/**/ if ((tok) == "errors") flag_errors = true;
else if ((tok) == "link") flag_link = true;
else if ((tok) == "cas") flag_cas = true;
else if ((tok) == "standard")
- {
+ {
flag_errors = true;
flag_warnings = true;
flag_messages = true;
flag_link = true;
- }
+ }
else if ((tok) == "all")
- {
+ {
flag_errors = true;
flag_warnings = true;
flag_messages = true;
flag_modem = true;
flag_link = true;
flag_cas = true;
- }
- else
- {
+ }
+ else
+ {
K::Logger::Logg2(classe, s, FMT("WARNING: The following console message option is not valid and will be ignored: %s.") % (tok) );
continue;
- }
+ }
strs.add(tok);
}
bool flag_streams = false;
Strings::Merger strs;
-
- for (Strings::vector_type::iterator i = tokens.begin(); i != tokens.end(); i++)
- {
+
+ for (Strings::vector_type::iterator i = tokens.begin(); i != tokens.end(); i++)
+ {
std::string tok = Strings::trim(*i);
/**/ if ((tok) == "errors") flag_errors = true;
else if ((tok) == "locks") flag_locks = true;
else if ((tok) == "streams") flag_streams = true;
else if ((tok) == "standard")
- {
+ {
flag_errors = true;
flag_warnings = true;
flag_messages = true;
flag_link = true;
- }
+ }
else if ((tok) == "debugging")
- {
+ {
flag_errors = true;
flag_warnings = true;
flag_messages = true;
flag_link = true;
flag_cas = true;
flag_functions = true;
- }
+ }
else if ((tok) == "all")
- {
+ {
flag_errors = true;
flag_warnings = true;
flag_messages = true;
KHOMP generic endpoint/channel library.
Copyright (C) 2007-2010 Khomp Ind. & Com.
- The contents of this file are subject to the Mozilla Public License
- Version 1.1 (the "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
+ The contents of this file are subject to the Mozilla Public License
+ Version 1.1 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
case the provisions of "LGPL License" are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
- the LGPL License and not to allow others to use your version of this file
- under the MPL, indicate your decision by deleting the provisions above and
- replace them with the notice and other provisions required by the LGPL
- License. If you do not delete the provisions above, a recipient may use your
+ the LGPL License and not to allow others to use your version of this file
+ under the MPL, indicate your decision by deleting the provisions above and
+ replace them with the notice and other provisions required by the LGPL
+ License. If you do not delete the provisions above, a recipient may use your
version of this file under either the MPL or the LGPL License.
The LGPL header follows below:
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with this library; if not, write to the Free Software Foundation,
+ along with this library; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*******************************************************************************/
/* not beautiful, should think of something! */
#define FUNCTION_VALUE(x) reinterpret_cast< Config::FunctionValue Options::* >( x )
-void Opt::initialize(void)
-{
+void Opt::initialize(void)
+{
Globals::options.add(Config::Option("debug", &Options::_debug, false));
Globals::options.add(Config::Option("dialplan", &Options::_dialplan, "XML"));
Globals::options.add(Config::Option("context", &Options::_context, "default"));
Globals::options.add(Config::Option("flash-to-digits", &Options::_flash, "*1"));
- Globals::options.add(Config::Option("delay-ringback-co", &Options::_ringback_co_delay, 1500u, 0u, 999000u));
+ Globals::options.add(Config::Option("delay-ringback-co", &Options::_ringback_co_delay, 1500u, 0u, 999000u));
Globals::options.add(Config::Option("delay-ringback-pbx", &Options::_ringback_pbx_delay, 2500u, 0u, 999000u));
-
- Globals::options.add(Config::Option("disconnect-delay", &Options::_disconnect_delay, 0u, 0u, 100000u));
+
+ Globals::options.add(Config::Option("disconnect-delay", &Options::_disconnect_delay, 0u, 0u, 100000u));
Globals::options.add(Config::Option("input-volume", &Options::_input_volume, 0, -10, 10));
Globals::options.add(Config::Option("output-volume", &Options::_output_volume, 0, -10, 10));
- Globals::options.add(Config::Option("fxs-co-dialtone",
+ Globals::options.add(Config::Option("fxs-co-dialtone",
FUNCTION_VALUE(&Options::_fxs_co_dialtone), ""));
- Globals::options.add(Config::Option("log-to-disk",
+ Globals::options.add(Config::Option("log-to-disk",
FUNCTION_VALUE(&Options::_log_disk_option), "standard", false));
Globals::options.add(Config::Option("callgroup", &Options::_callgroup, "0"));
Globals::options.add(Config::Option("pickupgroup", &Options::_pickupgroup, "0"));
-
+
Globals::options.add(Config::Option("log-to-console",
FUNCTION_VALUE(&Options::_log_console_option), "standard", false));
Globals::options.add(Config::Option("trace",
FUNCTION_VALUE(&Options::_log_trace_option), "", false));
- Globals::options.add(Config::Option("record-prefix",
+ Globals::options.add(Config::Option("record-prefix",
FUNCTION_VALUE(&Options::_record_prefix), "/var/spool/freeswitch/monitor/"));
-
+
Globals::options.add(Config::Option("fxs-global-orig", &Options::_fxs_global_orig_base, "0"));
Globals::options.add(Config::Option("language", &Options::_global_language, ""));
(unsigned int)KHOMP_READ_PACKET_SIZE, (unsigned int)KHOMP_MIN_READ_PACKET_SIZE, (unsigned int)KHOMP_MAX_READ_PACKET_SIZE, 8u));
Globals::options.add(Config::Option("user-transfer-digits", &Options::_user_xfer_digits, ""));
-
+
/* aliases */
Globals::options.synonym("context-gsm", "context-gsm-call");
Globals::options.synonym("context-gsm-alt", "context-gsm-call-alt");
try
{
/* everything should start clean! */
- cleanConfiguration();
+ cleanConfiguration();
/* reset loaded options */
Globals::options.reset(&Opt::_options);
DBG(FUNC,FMT("%s") % (*i).c_str());
}
}
- catch (std::runtime_error & e)
- {
+ catch (std::runtime_error & e)
+ {
LOG(ERROR, FMT("unable to obtain general options: %s: procedure aborted!") % e.what());
- }
+ }
}
void Opt::commit(void)
OrigToDestMapType::const_iterator endOfHotlines = _fxs_hotline.end();
for (OrigToDestMapType::const_iterator i = _fxs_hotline.begin(); i != endOfHotlines; i++)
- {
+ {
BranchToObjectMapType::const_iterator j = _fxs_branch_map.find(i->first);
if (j == _fxs_branch_map.end())
- {
+ {
LOG(ERROR, FMT("unable to find branch '%s': hotline '%s' to '%s' is invalid!")
% i->first % i->first % i->second);
- }
- }
+ }
+ }
/* Check FXS options correcteness */
BranchToOptMapType::const_iterator endOfOptions = _branch_options.end();
-
+
for (BranchToOptMapType::const_iterator i = _branch_options.begin(); i != endOfOptions; i++)
- {
- BranchToObjectMapType::const_iterator j = _fxs_branch_map.find(i->first);
+ {
+ BranchToObjectMapType::const_iterator j = _fxs_branch_map.find(i->first);
if (j == _fxs_branch_map.end())
- {
+ {
LOG(ERROR, FMT("unable to find branch '%s' for options '%s'")
% i->first % i->second);
- }
- }
+ }
+ }
}
void Opt::loadConfiguration(const char *file_name, const char **section, bool show_errors)
/* Load all the global settings pertinent to all boards */
settings = processSimpleXML(cfg,"settings");
-
+
/* Process channel settings */
processSimpleXML(settings,"channels");
/* Process fxs options settings */
processFXSOptions(settings);
-
+
switch_xml_free(xml);
}
if (mkdir(str.c_str(), 493 /* 0755 */) < 0 && errno != EEXIST)
throw Config::Failure("the default recording directory could not be created.");
- _value = str;
+ _value = str;
}
-void Options::CentralOfficeDialtone::operator()(const Config::StringType & str)
+void Options::CentralOfficeDialtone::operator()(const Config::StringType & str)
{
Strings::vector_type tokens;
Strings::tokenize(str, tokens, ",");
- for (Strings::vector_type::iterator i = tokens.begin(); i != tokens.end(); i++)
+ for (Strings::vector_type::iterator i = tokens.begin(); i != tokens.end(); i++)
_value.push_back(*i);
}
-void Options::LogDiskOption::operator()(const Config::StringType & str)
+void Options::LogDiskOption::operator()(const Config::StringType & str)
{
K::Logger::processLogDisk(NULL, str, false, true);
}
-void Options::LogConsoleOption::operator()(const Config::StringType & str)
+void Options::LogConsoleOption::operator()(const Config::StringType & str)
{
K::Logger::processLogConsole(NULL, str, false, true);
}
}
catch (Config::Failure e)
{
- LOG(ERROR,FMT("config processing error: %s. [%s=%s]")
+ LOG(ERROR,FMT("config processing error: %s. [%s=%s]")
% e.what()
% var
% val);
}
catch (Config::Failure e)
{
- LOG(ERROR,FMT("config processing error: %s. [%s=%s]")
+ LOG(ERROR,FMT("config processing error: %s. [%s=%s]")
% e.what()
% var
% val);
cadence.ring_s = Strings::toulong(Strings::trim(values[1]));
if (values.size() == 4)
- {
+ {
cadence.ring_ext = Strings::toulong(Strings::trim(values[2]));
cadence.ring_ext_s = Strings::toulong(Strings::trim(values[3]));
- }
+ }
_cadences.erase(var); /* erases previous (possibly predefined) cadence */
_cadences.insert(CadencesPairType(var, cadence));
- }
+ }
}
catch (Config::Failure e)
{
- LOG(ERROR,FMT("config processing error: %s. [%s=%s]")
+ LOG(ERROR,FMT("config processing error: %s. [%s=%s]")
% e.what()
% var
% val);
- }
+ }
catch (Strings::invalid_value e)
- {
- LOG(ERROR,FMT("file '%s': number expected at cadence '%s', got '%s'.")
+ {
+ LOG(ERROR,FMT("file '%s': number expected at cadence '%s', got '%s'.")
% "khomp.conf.xml"
% var
% e.value().c_str());
- }
+ }
}
}
}
if (!found)
{
- LOG(WARNING, FMT("file 'khomp.conf.xml': board with serial number '%u' not found!")
+ LOG(WARNING, FMT("file 'khomp.conf.xml': board with serial number '%u' not found!")
% serial_number);
break;
}
catch (Config::Failure e)
{
- LOG(ERROR,FMT("config processing error: %s. [%s=%s]")
+ LOG(ERROR,FMT("config processing error: %s. [%s=%s]")
% e.what()
% var
% val);
}
catch (Config::Failure e)
{
- LOG(ERROR,FMT("config processing error: %s. [%s=%s]")
+ LOG(ERROR,FMT("config processing error: %s. [%s=%s]")
% e.what()
% var
- % val);
+ % val);
}
catch (Strings::invalid_value e)
{
- LOG(WARNING, FMT("file '%s': number expected, got '%s'!")
+ LOG(WARNING, FMT("file '%s': number expected, got '%s'!")
% "khomp.conf.xml" % e.value().c_str());
- }
+ }
}
}
}
Strings::tokenize(var, branches, " ,");
if (branches.size() < 1)
- {
+ {
//TODO: Get linenumber
- LOG(WARNING, FMT("file '%s': no branches specified in line %d!")
+ LOG(WARNING, FMT("file '%s': no branches specified in line %d!")
% "khomp.conf.xml" % 0);
- }
+ }
else
- {
+ {
for (Strings::vector_type::iterator iter = branches.begin();
iter != branches.end(); iter++)
- {
+ {
std::string tmp_branch = Strings::trim(*iter);
unsigned long branch_number = Strings::toulong(tmp_branch);
}
catch (Config::Failure e)
{
- LOG(ERROR,FMT("config processing error: %s. [%s=%s]")
+ LOG(ERROR,FMT("config processing error: %s. [%s=%s]")
% e.what()
% var
- % val);
+ % val);
}
catch (Strings::invalid_value e)
{
- LOG(WARNING, FMT("file '%s': number expected, got '%s'!")
+ LOG(WARNING, FMT("file '%s': number expected, got '%s'!")
% "khomp.conf.xml" % e.value().c_str());
}
}
KHOMP generic endpoint/channel library.
Copyright (C) 2007-2010 Khomp Ind. & Com.
- The contents of this file are subject to the Mozilla Public License
- Version 1.1 (the "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
+ The contents of this file are subject to the Mozilla Public License
+ Version 1.1 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
case the provisions of "LGPL License" are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
- the LGPL License and not to allow others to use your version of this file
- under the MPL, indicate your decision by deleting the provisions above and
- replace them with the notice and other provisions required by the LGPL
- License. If you do not delete the provisions above, a recipient may use your
+ the LGPL License and not to allow others to use your version of this file
+ under the MPL, indicate your decision by deleting the provisions above and
+ replace them with the notice and other provisions required by the LGPL
+ License. If you do not delete the provisions above, a recipient may use your
version of this file under either the MPL or the LGPL License.
The LGPL header follows below:
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with this library; if not, write to the Free Software Foundation,
+ along with this library; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*******************************************************************************/
funProcessSMSChannelString(int *cause)
: _cause(cause), _all_fail(true), _pvt(NULL)
- {};
+ {};
bool operator()(unsigned int dev, unsigned int obj, SpecFlagsType & flags)
- {
+ {
Board::KhompPvt *pvt = Board::findFree(dev, obj);
if (pvt)
{
- // found something? check if its GSM
+ // found something? check if its GSM
if (pvt->application(SMS_CHECK, NULL, NULL))
- {
- // used for cause definition
+ {
+ // used for cause definition
if (_all_fail)
_all_fail = (pvt ? !pvt->isOK() : true);
if (flags & SPF_CYCLIC)
- {
+ {
Board::queueAddChannel(_channels, dev, obj);
return true;
- }
- else
- {
- _pvt = pvt;
+ }
+ else
+ {
+ _pvt = pvt;
return false;
- }
- }
- else
- {
- // not gsm, return ASAP and stop search
+ }
+ }
+ else
+ {
+ // not gsm, return ASAP and stop search
LOG(ERROR, PVT_FMT(pvt->target(), "channel is NOT a GSM channel! unable to send message!"));
return false;
}
}
- // keep searching
+ // keep searching
return true;
}
Board::KhompPvt * pvt(SpecFlagsType & flags)
- {
+ {
if ((flags & SPF_CYCLIC) && !_pvt)
- {
- // we have no pvt 'till now, lets find a suitable one..
+ {
+ // we have no pvt 'till now, lets find a suitable one..
_pvt = Board::queueFindFree(_channels);
}
if (!_pvt && _cause && !(*_cause))
- {
+ {
if (_all_fail)
- {
- // all channels are in fail
+ {
+ // all channels are in fail
*_cause = SWITCH_CAUSE_NETWORK_OUT_OF_ORDER;
- }
- else
- {
+ }
+ else
+ {
// otherwise, congestion..
*_cause = SWITCH_CAUSE_SWITCH_CONGESTION;
}
funProcessSMSChannelString proc(cause);
SpecFlagsType flags = SPF_FIRST;
- SpecFunType fun(proc, false);
+ SpecFunType fun(proc, false);
- switch (processSpecAtoms(str, flags, fun))
- {
+ switch (processSpecAtoms(str, flags, fun))
+ {
case SPR_FAIL:
DBG(FUNC, FMT("SPR_FAIL: %p") % cause);
if (cause)
case SPR_CONTINUE:
pvt = proc.pvt(flags);
DBG(FUNC, FMT("pvt = %p") % pvt);
-
+
if (cause && !(*cause))
{
if (!pvt)
}
return true;
- }
+ }
return true;
}
unsigned int opt_size = (pvt->hasNumberDial() ? 3 : 2);
unsigned int opt_arg = opt_size - 1;
-
+
if (dial_args.size() == opt_size)
{
Strings::vector_type options_args;
std::string sms_string(sms_charv);
Strings::vector_type sms_args;
- Strings::tokenize(sms_string, sms_args, "/|,", 3); // '/' is a backward compatibility feature!
+ Strings::tokenize(sms_string, sms_args, "/|,", 3); // '/' is a backward compatibility feature!
DBG(FUNC, FMT("processing SMS string [%d] : '%s'") % sms_args.size() % sms_string);
conf = true;
}
- // get options/values
+ // get options/values
pvt->send_sms.sms_dest = dest;
pvt->send_sms.sms_conf = conf;
pvt->send_sms.sms_body = sms_args[2];
switch (processSpecAtoms(tokens[0], flags, fun))
{
case SPR_CONTINUE:
- // remove context from spec
+ // remove context from spec
opts = tokens[0];
- // log this!
+ // log this!
DBG(CONF, FMT("group '%s' is now '%s', with context '%s'...")
% name % tokens[0] % tokens[1]);
break;
default:
LOG(WARNING, FMT("skipping group '%s', bad configuration!\n") % name.c_str());
- // "zero" group
+ // "zero" group
opts.clear();
- // log this!
+ // log this!
DBG(CONF, FMT("group '%s' have misconfigured options, ignoring...") % name);
break;
}
KHOMP generic endpoint/channel library.
Copyright (C) 2007-2010 Khomp Ind. & Com.
- The contents of this file are subject to the Mozilla Public License
- Version 1.1 (the "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
+ The contents of this file are subject to the Mozilla Public License
+ Version 1.1 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
case the provisions of "LGPL License" are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
- the LGPL License and not to allow others to use your version of this file
- under the MPL, indicate your decision by deleting the provisions above and
- replace them with the notice and other provisions required by the LGPL
- License. If you do not delete the provisions above, a recipient may use your
+ the LGPL License and not to allow others to use your version of this file
+ under the MPL, indicate your decision by deleting the provisions above and
+ replace them with the notice and other provisions required by the LGPL
+ License. If you do not delete the provisions above, a recipient may use your
version of this file under either the MPL or the LGPL License.
The LGPL header follows below:
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with this library; if not, write to the Free Software Foundation,
+ along with this library; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*******************************************************************************/
_flags[SMS_DOING_UPLOAD]._value = false;
/*
- NOW LOADING ...
+ NOW LOADING ...
_flags[BRIDGED]._name = "BRIDGED";
_flags[BRIDGED]._value = false;
void ChanCommandHandler::unreference()
{
-
+
if (!_fifo)
return;
-
+
if(_fifo->_thread)
{
_fifo->_thread->join();
void ChanEventHandler::unreference()
{
-
+
if (!_fifo)
return;
-
+
if(_fifo->_thread)
{
_fifo->_thread->join();
const char * answerInfoToString(int answer_info)
{
switch (answer_info)
- {
+ {
case Board::KhompPvt::CI_MESSAGE_BOX:
return "MessageBox";
case Board::KhompPvt::CI_HUMAN_ANSWER:
return "Unknown";
case Board::KhompPvt::CI_FAX:
return "Fax";
- }
+ }
return NULL;
}
/******************************* Match functions ******************************/
-bool MatchExtension::canMatch(std::string & context, std::string & exten,
+bool MatchExtension::canMatch(std::string & context, std::string & exten,
std::string & caller_id, bool match_more)
{
if(!match_more)
char key_digit = '#';
size_t finished = exten.find_last_of(key_digit);
char last_char = exten.at(exten.size() - 1);
-
+
if(finished != std::string::npos && last_char == key_digit)
{
if(exten.size() <= 1)
return false;
}
}
-
+
return true;
/*
DBG(FUNC,"extension cannot match, returning");
if(xml)
- switch_xml_free(xml);
+ switch_xml_free(xml);
return false;
}
{
std::string expression;
- if (switch_xml_child(xcond, "condition"))
- {
+ if (switch_xml_child(xcond, "condition"))
+ {
LOG(ERROR,"Nested conditions are not allowed");
- }
+ }
switch_xml_t xexpression = switch_xml_child(xcond, "expression");
- if ((xexpression = switch_xml_child(xcond, "expression")))
+ if ((xexpression = switch_xml_child(xcond, "expression")))
{
expression = switch_str_nil(xexpression->txt);
}
- else
+ else
{
expression = switch_xml_attr_soft(xcond, "expression");
- }
+ }
if(expression.empty() || expression == "^(.*)$")
- {
+ {
//We're not gonna take it
//No, we ain't gonna take it
// We're not gonna take it anymore
continue;
}
- int pm = -1;
+ int pm = -1;
switch_status_t is_match = SWITCH_STATUS_FALSE;
is_match = switch_regex_match_partial(exten.c_str(),expression.c_str(),&pm);
{
// not match
}
- }
+ }
xexten = xexten->next;
}
}
if(xml)
- switch_xml_free(xml);
+ switch_xml_free(xml);
return false;
*/
MatchExtension::MatchType MatchExtension::matchExtension(
- std::string & context,
+ std::string & context,
std::string & exten,
- std::string & callerid,
+ std::string & callerid,
bool match_only)
{
if(!canMatch(context,exten,callerid))
}
}
}
-
+
ref_context.clear();
ref_extension.clear();
{
/* get total of kommuter devices */
_kommuter_count = e->AddInfo;
-
+
if(Opt::_options._kommuter_activation() == "manual")
{
if (_kommuter_count > 0)
return true;
}
- if (_kommuter_count > 0)
- {
+ if (_kommuter_count > 0)
+ {
bool start_timer = false;
int timeout = Opt::_options._kommuter_timeout();
std::string param = STG(FMT("timeout=%d") % timeout);
for (int kommuter = 0; kommuter < _kommuter_count; kommuter++)
- {
+ {
try
{
Globals::k3lapi.command(-1, kommuter, CM_START_WATCHDOG, param.c_str());
}
if(timeout == 0)
- {
+ {
DBG(FUNC, D("kommuter watchdog timer not created because timeout is 0."));
return true;
- }
+ }
if (start_timer)
- {
+ {
if (!Globals::global_timer)
- {
+ {
LOG(ERROR, D("error creating the timer for kommuter."));
}
else
{
DBG(FUNC, D("no kommuter devices were found on system."));
}
-
+
return true;
}
//Remove one from vector
//_events->pop_back();
-
+
if(_events->size() == 0)
{
delete _events;
bool ESL::unregisterEvents()
{
DBG(FUNC, "Unregister ESLs");
-
+
if(!_events)
return true;
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Emmanuel Schmidbauer <e.schmidbauer@gmail.com>
*
uint32_t bit, channels;
iananame = switch_parse_codec_buf(dup, &interval, &rate, &bit, &channels, &codec_modname, NULL);
}
-
+
}
if (switch_core_codec_ready(&tech_pvt->read_codec)) {
return status;
}
-/*
- State methods they get called when the state changes to the specific state
+/*
+ State methods they get called when the state changes to the specific state
returning SWITCH_STATUS_SUCCESS tells the core to execute the standard state method next
so if you fully implement the state you can return SWITCH_STATUS_FALSE to skip it.
*/
if ((vars = (switch_event_t *) switch_channel_get_private(channel, "__loopback_vars__"))) {
switch_event_header_t *h;
-
+
switch_channel_set_private(channel, "__loopback_vars__", NULL);
for (h = vars->headers; h; h = h->next) {
if ((argc = switch_split(dup, ',', argv))) {
int i;
for (i = 0; i < argc; i++) {
-
+
if (!zstr(argv[i])) {
const char *val = switch_channel_get_variable(channel, argv[i]);
if(!zstr(val)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Transfer variable [%s]=[%s] %s -> %s\n",
argv[i], val, switch_channel_get_name(channel), switch_channel_get_name(tech_pvt->other_channel));
-
+
switch_channel_set_variable(tech_pvt->other_channel, argv[i], val);
}
}
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
goto end;
}
- } else {
+ } else {
switch_mutex_lock(tech_pvt->mutex);
if ((tech_pvt->other_session = switch_core_session_locate(tech_pvt->other_uuid))) {
tech_pvt->other_tech_pvt = switch_core_session_get_private(tech_pvt->other_session);
do_reset(tech_pvt);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s CHANNEL ROUTING\n", switch_channel_get_name(channel));
-
+
if (switch_test_flag(tech_pvt, TFLAG_RUNNING_APP)) {
switch_clear_flag(tech_pvt, TFLAG_RUNNING_APP);
}
- if (switch_test_flag(tech_pvt, TFLAG_APP) && !switch_test_flag(tech_pvt, TFLAG_OUTBOUND) &&
+ if (switch_test_flag(tech_pvt, TFLAG_APP) && !switch_test_flag(tech_pvt, TFLAG_OUTBOUND) &&
(app = switch_channel_get_variable(channel, "loopback_app"))) {
switch_caller_extension_t *extension = NULL;
switch_channel_set_private(channel, "__loopback_vars__", NULL);
switch_event_destroy(&vars);
}
-
+
if (tech_pvt) {
switch_core_timer_destroy(&tech_pvt->timer);
if (tech_pvt->write_frame) {
switch_frame_free(&tech_pvt->write_frame);
}
-
+
tech_pvt->write_frame = (switch_frame_t *) pop;
switch_clear_flag(tech_pvt->write_frame, SFF_RAW_RTP);
- tech_pvt->write_frame->timestamp = 0;
+ tech_pvt->write_frame->timestamp = 0;
tech_pvt->write_frame->codec = &tech_pvt->read_codec;
*frame = tech_pvt->write_frame;
{
switch_assert(channel);
-
+
for (;;) {
- if ((switch_channel_get_state(channel) < CS_HANGUP &&
+ if ((switch_channel_get_state(channel) < CS_HANGUP &&
switch_channel_get_state(channel) == switch_channel_get_running_state(channel) && switch_channel_get_running_state(channel) >= want_state) ||
(other_channel && switch_channel_down_nosig(other_channel)) || switch_channel_down(channel)) {
break;
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
- if (switch_test_flag(frame, SFF_CNG) ||
+ if (switch_test_flag(frame, SFF_CNG) ||
(switch_test_flag(tech_pvt, TFLAG_BOWOUT) && switch_test_flag(tech_pvt, TFLAG_BOWOUT_USED))) {
switch_core_timer_sync(&tech_pvt->timer);
switch_core_timer_sync(&tech_pvt->other_tech_pvt->timer);
find_non_loopback_bridge(tech_pvt->other_session, &br_b, &b_uuid);
switch_mutex_lock(tech_pvt->mutex);
-
+
if (br_a) {
ch_a = switch_core_session_get_channel(br_a);
switch_core_media_bug_transfer_recordings(session, br_a);
ch_b = switch_core_session_get_channel(br_b);
switch_core_media_bug_transfer_recordings(tech_pvt->other_session, br_b);
}
-
+
if (ch_a && ch_b && switch_channel_test_flag(ch_a, CF_BRIDGED) && switch_channel_test_flag(ch_b, CF_BRIDGED)) {
switch_set_flag_locked(tech_pvt, TFLAG_BOWOUT);
if (a_uuid && b_uuid) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
"%s detected bridge on both ends, attempting direct connection.\n", switch_channel_get_name(channel));
-
+
/* channel_masquerade eat your heart out....... */
switch_ivr_uuid_bridge(a_uuid, b_uuid);
good_to_go = 1;
if (br_a) switch_core_session_rwunlock(br_a);
if (br_b) switch_core_session_rwunlock(br_b);
-
+
if (good_to_go) {
return SWITCH_STATUS_SUCCESS;
}
if (switch_test_flag(tech_pvt, TFLAG_LINKED) && tech_pvt->other_tech_pvt) {
switch_frame_t *clone;
-
+
if (frame->codec->implementation != tech_pvt->write_codec.implementation) {
/* change codecs to match */
tech_init(tech_pvt, session, frame->codec);
if (switch_frame_dup(frame, &clone) != SWITCH_STATUS_SUCCESS) {
abort();
}
-
- if ((status = switch_queue_trypush(tech_pvt->other_tech_pvt->frame_queue, clone)) != SWITCH_STATUS_SUCCESS) {
+
+ if ((status = switch_queue_trypush(tech_pvt->other_tech_pvt->frame_queue, clone)) != SWITCH_STATUS_SUCCESS) {
clear_queue(tech_pvt->other_tech_pvt);
status = switch_queue_trypush(tech_pvt->other_tech_pvt->frame_queue, clone);
}
loopback_private_t *tech_pvt;
int done = 1, pass = 0;
switch_core_session_t *other_session;
-
+
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
if (!zstr(msg->string_array_arg[0])) {
switch_channel_set_profile_var(tech_pvt->other_channel, "caller_id_name", msg->string_array_arg[0]);
}
-
+
if (!zstr(msg->string_array_arg[1])) {
switch_channel_set_profile_var(tech_pvt->other_channel, "caller_id_number", msg->string_array_arg[1]);
}
if (!zstr(msg->string_array_arg[0])) {
switch_channel_set_profile_var(tech_pvt->other_channel, "callee_id_name", msg->string_array_arg[0]);
}
-
+
if (!zstr(msg->string_array_arg[1])) {
switch_channel_set_profile_var(tech_pvt->other_channel, "callee_id_number", msg->string_array_arg[1]);
}
}
-
+
pass = 1;
}
break;
if (!zstr(msg->string_arg) && switch_core_session_get_partner(tech_pvt->other_session, &other_session) == SWITCH_STATUS_SUCCESS) {
char *ext = switch_core_session_strdup(other_session, msg->string_arg);
char *context = NULL, *dp = NULL;
-
+
if ((context = strchr(ext, ' '))) {
*context++ = '\0';
-
+
if ((dp = strchr(context, ' '))) {
*dp++ = '\0';
}
if (!done && tech_pvt->other_session && (pass || switch_test_flag(tech_pvt, TFLAG_RUNNING_APP))) {
switch_status_t r = SWITCH_STATUS_FALSE;
-
+
if (switch_core_session_get_partner(tech_pvt->other_session, &other_session) == SWITCH_STATUS_SUCCESS) {
r = switch_core_session_receive_message(other_session, msg);
switch_core_session_rwunlock(other_session);
}
-
+
return r;
}
-
+
return SWITCH_STATUS_SUCCESS;
}
switch_event_t *clone = NULL;
switch_core_session_add_stream(*new_session, NULL);
-
+
if ((tech_pvt = (loopback_private_t *) switch_core_session_alloc(*new_session, sizeof(loopback_private_t))) != 0) {
channel = switch_core_session_get_channel(*new_session);
switch_snprintf(name, sizeof(name), "loopback/%s-a", outbound_profile->destination_number);
if (clone) {
switch_event_add_header_string(clone, SWITCH_STACK_BOTTOM, "loopback_app", app);
}
-
+
if (arg) {
switch_channel_set_variable(channel, "loopback_app_arg", arg);
if (clone) {
return SWITCH_STATUS_TERM;
}
-
+
memset(&globals, 0, sizeof(globals));
/* connect my internal structure to the blank pointer passed to me */
{
switch_event_free_subclass("loopback::bowout");
-
+
return SWITCH_STATUS_SUCCESS;
}
<configuration name="portaudio.conf" description="Soundcard Endpoint">
<settings>
- <!-- indev, outdev, ringdev:
- partial case sensitive string match on something in the name
+ <!-- indev, outdev, ringdev:
+ partial case sensitive string match on something in the name
or the device number prefixed with # eg "#1" (or blank for default) -->
<!-- device to use for input -->
<!-- <param name="unload-on-device-fail" value="true"/> -->
</settings>
- <!--
+ <!--
mod_portaudio "streams"
The portaudio streams were introduced to support multiple devices and multiple channels in mod_portaudio.
want to use them at the same time, you can do it configuring streams and endpoints here.
A "stream" is just a logical container for some settings required by portaudio in order to stream audio and
- define a friendly name for that configuration. Streams in itself do not do anything else than contain configs.
- Once you have your streams defined you can proceed to define "endpoints". Go to the "<endpoints>" section
+ define a friendly name for that configuration. Streams in itself do not do anything else than contain configs.
+ Once you have your streams defined you can proceed to define "endpoints". Go to the "<endpoints>" section
for more information on endpoints.
You can use the command "pa shstreams" (portaudio shared streams) to show the configured streams.
<!-- This sample "usb1" configuration was tested with a USB Griffin iMic device -->
<stream name="usb1">
- <!--
- Which device to use for input in this stream
- The value for this parameter must be either in the form '#devno',
+ <!--
+ Which device to use for input in this stream
+ The value for this parameter must be either in the form '#devno',
for example '#2' for device number 2, or 'device-name', like 'iMic USB audio system'
The output of command "pa devlist" will show you device names and numbers as enumerated
by portaudio.
-->
<param name="indev" value="#2" />
- <!--
+ <!--
Same as the indev but for output. In this case the device is capable of input and output
Some devices are capable of input only or output only (see the default example)
-->
<!-- The sample rate to use for this stream -->
<param name="sample-rate" value="48000" />
- <!--
+ <!--
Size of the packets in milliseconds. The smaller the number the less latency you'll have
- The minimum value is 10ms
+ The minimum value is 10ms
-->
<param name="codec-ms" value="10" />
- <!--
+ <!--
How many channels to open for this stream.
If you're device is stereo, you can choose 2 here. However, bear in mind that then
your left and right channels will be separated and when creating endpoints you will have
</stream>
</streams>
- <!--
+ <!--
mod_portaudio "endpoints"
Endpoints is a way to define the input and output that a given portaudio channel will use.
-->
<endpoints>
- <!--
- An endpoint is a handle name to refer to a configuration that determines where to read media from
- and write media to. The endpoint can use any input/output stream combination for that purpose as
+ <!--
+ An endpoint is a handle name to refer to a configuration that determines where to read media from
+ and write media to. The endpoint can use any input/output stream combination for that purpose as
long as the streams match the sampling rate and codec-ms (see <streams> XML tag).
You can also omit the instream or the outstream parameter (but obviously not both).
-->
- <!--
+ <!--
Configuration for a "default" bidirectional endpoint that uses the default stream defined previously in
the <streams> section.
-->
<endpoint name="default">
- <!--
+ <!--
The instream, outstream is the name of the stream and channel to use. The stream
- name is the same you configured in the <streams> section. This parameters follow
+ name is the same you configured in the <streams> section. This parameters follow
the syntax <stream-name>:<channel index>. You can omit either the outstream
- or the instream, but not both! The channel index is zero-based and must be consistent
+ or the instream, but not both! The channel index is zero-based and must be consistent
with the number of channels available for that stream (as configured in the <stream> section).
You cannot use index 1 if you chose channels=1 in the stream configuration.
-->
<param name="outstream" value="default:0" />
</endpoint>
- <!--
+ <!--
This endpoint uses the USB stream defined previously in the <streams> section and
- is 'send-only' or 'output-only' and uses the channel index 0 (left channel in a stereo device)
+ is 'send-only' or 'output-only' and uses the channel index 0 (left channel in a stereo device)
-->
<endpoint name="usb1out-left">
<param name="outstream" value="usb1:0" />
</endpoint>
- <!--
+ <!--
This endpoint uses the USB stream defined previously in the <streams> section and
- is 'send-only' or 'output-only' and uses the channel index 1 (right channel in a stereo device)
+ is 'send-only' or 'output-only' and uses the channel index 1 (right channel in a stereo device)
-->
<endpoint name="usb1out-right">
<param name="outstream" value="usb1:1" />
</endpoint>
- <!--
+ <!--
This endpoint uses the USB stream defined previously in the <streams> section and
- is 'receive-only' or 'input-only' and uses the channel index 0 (left channel in a stereo device)
+ is 'receive-only' or 'input-only' and uses the channel index 0 (left channel in a stereo device)
-->
<endpoint name="usb1in-left">
<param name="instream" value="usb1:0" />
</endpoint>
- <!--
+ <!--
This endpoint uses the USB stream defined previously in the <streams> section and
- is 'receive-only' or 'input-only' and uses the channel index 1 (right channel in a stereo device)
+ is 'receive-only' or 'input-only' and uses the channel index 1 (right channel in a stereo device)
-->
<endpoint name="usb1in-right">
<param name="instream" value="usb1:1" />
</endpoint>
- <!--
+ <!--
This endpoint uses the USB stream defined previously in the <streams> section and
- is 'bidirectional' or 'send-receive' and uses the channel index 0 (left channel in a stereo device)
+ is 'bidirectional' or 'send-receive' and uses the channel index 0 (left channel in a stereo device)
-->
<endpoint name="usb1-left">
<param name="instream" value="usb1:0" />
<param name="outstream" value="usb1:0" />
</endpoint>
- <!--
+ <!--
This endpoint uses the USB stream defined previously in the <streams> section and
- is 'bidirectional' or 'send-receive' and uses the channel index 1 (right channel in a stereo device)
+ is 'bidirectional' or 'send-receive' and uses the channel index 1 (right channel in a stereo device)
-->
<endpoint name="usb1-right">
<param name="instream" value="usb1:1" />
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Moises Silva <moises.silva@gmail.com> (Multiple endpoints work sponsored by Comrex Corporation)
* Raymond Chandler <intralanman@freeswitch.org>
static int get_dev_by_number(char *numstr, int in);
SWITCH_STANDARD_API(pa_cmd);
-/*
- State methods they get called when the state changes to the specific state
+/*
+ State methods they get called when the state changes to the specific state
returning SWITCH_STATUS_SUCCESS tells the core to execute the standard state method next
so if you fully implement the state you can return SWITCH_STATUS_FALSE to skip it.
*/
}
if (!tech_pvt->audio_endpoint &&
- switch_test_flag(tech_pvt, TFLAG_OUTBOUND) &&
+ switch_test_flag(tech_pvt, TFLAG_OUTBOUND) &&
!switch_test_flag(tech_pvt, TFLAG_AUTO_ANSWER)) {
add_pvt(tech_pvt, PA_SLAVE);
switch_channel_mark_ring_ready(channel);
}
- while (switch_channel_get_state(channel) == CS_ROUTING &&
+ while (switch_channel_get_state(channel) == CS_ROUTING &&
!switch_channel_test_flag(channel, CF_ANSWERED) &&
!switch_test_flag(tech_pvt, TFLAG_ANSWER)) {
switch_size_t olen = globals.readfile_timer.samples;
switch_core_file_seek(&fh, &pos, 0, SEEK_SET);
}
- if (globals.ring_stream && (! switch_test_flag(globals.call_list, TFLAG_MASTER) ||
- ( !globals.no_ring_during_call && globals.main_stream != globals.ring_stream)) ) { //if there is a ring stream and not an active call or if there is an active call and we are allowed to ring during it AND the ring stream is not the main stream
+ if (globals.ring_stream && (! switch_test_flag(globals.call_list, TFLAG_MASTER) ||
+ ( !globals.no_ring_during_call && globals.main_stream != globals.ring_stream)) ) { //if there is a ring stream and not an active call or if there is an active call and we are allowed to ring during it AND the ring stream is not the main stream
WriteAudioStream(globals.ring_stream->stream, abuf, (long) olen, 0, &globals.ring_stream->write_timer);
}
} else {
static audio_stream_t* find_audio_stream(int indev, int outdev, int already_locked)
{
audio_stream_t *cur_stream;
-
+
if (! globals.stream_list) {
return NULL;
}
}
globals.main_stream = get_audio_stream(globals.indev, globals.outdev);
-
+
if (globals.main_stream) {
return SWITCH_STATUS_SUCCESS;
}
CloseAudioStream(stream->stream);
stream->stream = NULL;
-
+
if (stream->write_timer.timer_interface) {
switch_core_timer_destroy(&stream->write_timer);
}
static switch_status_t destroy_audio_stream(int indev, int outdev)
{
audio_stream_t *stream;
-
+
switch_mutex_lock(globals.streams_lock);
stream = find_audio_stream(indev, outdev,1);
if (stream == NULL) {
switch_mutex_unlock(globals.streams_lock);
- return SWITCH_STATUS_FALSE;
+ return SWITCH_STATUS_FALSE;
}
remove_stream(stream, 1);
switch_mutex_lock(globals.pvt_lock);
for (tp = globals.call_list; tp; tp = tp->next) {
-
+
if (tp == tech_pvt) {
if (switch_test_flag(tp, TFLAG_MASTER)) {
switch_clear_flag_locked(tp, TFLAG_MASTER);
endpoint->read_frame.data = endpoint->read_buf;
endpoint->read_frame.buflen = sizeof(endpoint->read_buf);
endpoint->read_frame.source = __FILE__;
- samples = ReadAudioStream(endpoint->in_stream->stream,
- endpoint->read_frame.data, STREAM_SAMPLES_PER_PACKET(endpoint->in_stream),
+ samples = ReadAudioStream(endpoint->in_stream->stream,
+ endpoint->read_frame.data, STREAM_SAMPLES_PER_PACKET(endpoint->in_stream),
endpoint->inchan, &endpoint->read_timer);
if (!samples) {
if (tech_pvt->audio_endpoint) {
return channel_endpoint_read(tech_pvt->audio_endpoint, frame);
}
-
+
if (!globals.main_stream) {
goto normal_return;
}
if (!switch_test_flag(endpoint->master, TFLAG_IO)) {
return SWITCH_STATUS_SUCCESS;
}
- WriteAudioStream(endpoint->out_stream->stream, (short *)frame->data,
- (int)(frame->datalen / sizeof(SAMPLE)),
+ WriteAudioStream(endpoint->out_stream->stream, (short *)frame->data,
+ (int)(frame->datalen / sizeof(SAMPLE)),
endpoint->outchan, &(endpoint->write_timer));
return SWITCH_STATUS_SUCCESS;
}
if (!stream) {
return rc;
}
-
+
switch_mutex_lock(stream->mutex);
if (input) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_CRIT, "Invalid portaudio endpoint %s\n", endpoint_name);
goto error;
}
-
+
switch_mutex_lock(endpoint->mutex);
if (endpoint->master) {
}
codec_ms = endpoint->in_stream ? endpoint->in_stream->codec_ms : endpoint->out_stream->codec_ms;
- samples_per_packet = endpoint->in_stream ?
+ samples_per_packet = endpoint->in_stream ?
STREAM_SAMPLES_PER_PACKET(endpoint->in_stream) : STREAM_SAMPLES_PER_PACKET(endpoint->out_stream);
sample_rate = endpoint->in_stream ? endpoint->in_stream->sample_rate : endpoint->out_stream->sample_rate;
if (switch_core_timer_init(&endpoint->read_timer,
- globals.timer_name, codec_ms,
+ globals.timer_name, codec_ms,
samples_per_packet, module_pool) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed to setup read timer for endpoint '%s'!\n", endpoint->name);
goto error;
/* The write timer must be setup regardless */
if (switch_core_timer_init(&endpoint->write_timer,
- globals.timer_name, codec_ms,
+ globals.timer_name, codec_ms,
samples_per_packet, module_pool) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed to setup read timer for endpoint '%s'!\n", endpoint->name);
goto error;
}
if (switch_core_codec_init(&endpoint->read_codec,
- "L16", NULL, NULL, sample_rate, codec_ms, 1,
+ "L16", NULL, NULL, sample_rate, codec_ms, 1,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
goto error;
}
if (switch_core_codec_init(&endpoint->write_codec,
- "L16", NULL, NULL, sample_rate, codec_ms, 1,
+ "L16", NULL, NULL, sample_rate, codec_ms, 1,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
goto error;
switch_core_session_set_read_codec(tech_pvt->session, &endpoint->read_codec);
switch_core_session_set_write_codec(tech_pvt->session, &endpoint->write_codec);
- /* try to acquire the stream */
+ /* try to acquire the stream */
if (take_stream_channel(endpoint->in_stream, endpoint->inchan, 1)) {
retcause = SWITCH_CAUSE_USER_BUSY;
goto error;
if (!strcmp(var, "indev")) {
devval = check_device(val, 1);
if (devval < 0) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"Invalid indev specified for stream '%s'\n", stream_name);
stream->indev = -1;
continue;
} else if (!strcmp(var, "outdev")) {
devval = check_device(val, 0);
if (devval < 0) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"Invalid outdev specified for stream '%s'\n", stream_name);
stream->outdev = -1;
continue;
} else if (!strcmp(var, "sample-rate")) {
stream->sample_rate = atoi(val);
if (stream->sample_rate < MIN_STREAM_SAMPLE_RATE) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"Invalid sample rate specified for stream '%s', forcing to 8000\n", stream_name);
stream->sample_rate = MIN_STREAM_SAMPLE_RATE;
}
} else if (!strcmp(var, "channels")) {
stream->channels = atoi(val);
if (stream->channels < 1 || stream->channels > MAX_IO_CHANNELS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"Invalid number of channels specified for stream '%s', forcing to 1\n", stream_name);
stream->channels = 1;
}
}
}
if (stream->indev < 0 && stream->outdev < 0) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"You need at least one device for stream '%s'\n", stream_name);
continue;
}
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
"Created stream '%s', sample-rate = %d, codec-ms = %d\n", stream->name, stream->sample_rate, stream->codec_ms);
switch_core_hash_insert(globals.sh_streams, stream->name, stream);
}
if (!check_input && stream->outdev < 0) {
return NULL;
}
-
+
*chanindex = cnum;
return stream;
stream = check_stream(val, 1, &endpoint->inchan) ;
if (!stream) {
endpoint->in_stream = NULL;
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"Invalid instream specified for endpoint '%s'\n", endpoint_name);
continue;
}
} else if (!strcmp(var, "outstream")) {
stream = check_stream(val, 0, &endpoint->outchan);
if (!stream) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"Invalid outstream specified for endpoint '%s'\n", endpoint_name);
endpoint->out_stream = NULL;
continue;
}
}
if (!endpoint->in_stream && !endpoint->out_stream) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"You need at least one stream for endpoint '%s'\n", endpoint_name);
continue;
}
if (check_stream_compat(endpoint->in_stream, endpoint->out_stream)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"Incompatible input and output streams for endpoint '%s'\n", endpoint_name);
continue;
}
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
- "Created endpoint '%s', instream = %s, outstream = %s\n", endpoint->name,
- endpoint->in_stream ? endpoint->in_stream->name : "(none)",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
+ "Created endpoint '%s', instream = %s, outstream = %s\n", endpoint->name,
+ endpoint->in_stream ? endpoint->in_stream->name : "(none)",
endpoint->out_stream ? endpoint->out_stream->name : "(none)");
switch_core_hash_insert(globals.endpoints, endpoint->name, endpoint);
}
switch_event_free_subclass(MY_EVENT_ERROR_AUDIO_DEV);
switch_event_free_subclass(MY_EVENT_CALL_HELD);
switch_event_free_subclass(MY_EVENT_CALL_RESUMED);
-
+
switch_safe_free(globals.dialplan);
switch_safe_free(globals.context);
if (globals.destroying_streams || ! audio_stream->stream) {
break;
}
-
+
WriteAudioStream(audio_stream->stream, abuf, (long) olen, 0, &(audio_stream->write_timer));
wrote += (int) olen;
if (samples) {
switch_core_codec_destroy(&globals.write_codec);
switch_core_timer_destroy(&globals.read_timer);
switch_core_timer_destroy(&globals.readfile_timer);
-
+
return SWITCH_STATUS_FALSE;
}
}
{
PaError err;
if (inputParameters->device != -1) {
- err = OpenAudioStream(&shstream->stream, inputParameters->device != -1 ? inputParameters : NULL,
- outputParameters->device != -1 ? outputParameters : NULL, shstream->sample_rate,
+ err = OpenAudioStream(&shstream->stream, inputParameters->device != -1 ? inputParameters : NULL,
+ outputParameters->device != -1 ? outputParameters : NULL, shstream->sample_rate,
paClipOff, STREAM_SAMPLES_PER_PACKET(shstream), globals.dual_streams);
} else {
- err = OpenAudioStream(&shstream->stream, NULL, outputParameters, shstream->sample_rate,
+ err = OpenAudioStream(&shstream->stream, NULL, outputParameters, shstream->sample_rate,
paClipOff, STREAM_SAMPLES_PER_PACKET(shstream), 0);
}
if (err != paNoError) {
outputParameters.suggestedLatency = Pa_GetDeviceInfo(outputParameters.device)->defaultLowOutputLatency;
outputParameters.hostApiSpecificStreamInfo = NULL;
}
-
+
err = open_shared_audio_stream(shstream, &inputParameters, &outputParameters);
if (err != paNoError) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
- "Error opening audio device retrying (indev = %d, outdev = %d, error = %s)\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ "Error opening audio device retrying (indev = %d, outdev = %d, error = %s)\n",
inputParameters.device, outputParameters.device, Pa_GetErrorText(err));
switch_yield(1000000);
err = open_shared_audio_stream(shstream, &inputParameters, &outputParameters);
}
return -1;
}
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Created shared audio stream %s: %d channels %d\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Created shared audio stream %s: %d channels %d\n",
shstream->name, shstream->sample_rate, shstream->channels);
return 0;
}
outputParameters.suggestedLatency = Pa_GetDeviceInfo(outputParameters.device)->defaultLowOutputLatency;
outputParameters.hostApiSpecificStreamInfo = NULL;
}
-
+
err = open_audio_stream(&(stream->stream), &inputParameters, &outputParameters);
if (err != paNoError) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening audio device retrying\n");
switch_core_hash_this(hi, &var, NULL, &val);
e = val;
stream->write_function(stream, "%s> instream: %s, outstream: %s\n",
- e->name, e->in_stream ? e->in_stream->name : "(none)",
+ e->name, e->in_stream ? e->in_stream->name : "(none)",
e->out_stream ? e->out_stream->name : "(none)");
cnt++;
}
} else if (argv[1] && !strcmp(argv[0], "outdev")) {
func = set_outdev;
} else if (argv[1] && argv[2] && !strcmp(argv[0], "preparestream")) {
- func = prepare_stream;
+ func = prepare_stream;
} else if (argv[1] && argv[2] && !strcmp(argv[0], "switchstream")) {
- func = switch_stream;
+ func = switch_stream;
} else if (argv[1] && !strcmp(argv[0], "ringdev")) {
func = set_ringdev;
} else if ((argv[1] && !strcmp(argv[0], "play"))) {
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
/************************************************************************/
/* Called from PortAudio.
- * Read and write data
+ * Read and write data
*/
static int iblockingIOCallback(const void *inputBuffer, void *outputBuffer,
unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo * timeInfo, PaStreamCallbackFlags statusFlags, void *userData)
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
tech_pvt->session = session;
}
-/*
- State methods they get called when the state changes to the specific state
+/*
+ State methods they get called when the state changes to the specific state
returning SWITCH_STATUS_SUCCESS tells the core to execute the standard state method next
so if you fully implement the state you can return SWITCH_STATUS_FALSE to skip it.
*/
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
switch_core_session_t *session;
switch_caller_profile_t *caller_profile;
switch_media_handle_t *media_handle;
- switch_core_media_params_t mparams;
+ switch_core_media_params_t mparams;
} private_object_t;
static struct {
/* BODY OF THE MODULE */
/*************************************************************************************************************************************************************/
-/*
- State methods they get called when the state changes to the specific state
+/*
+ State methods they get called when the state changes to the specific state
returning SWITCH_STATUS_SUCCESS tells the core to execute the standard state method next
so if you fully implement the state you can return SWITCH_STATUS_FALSE to skip it.
*/
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s RTC DESTROY\n", switch_channel_get_name(channel));
switch_media_handle_destroy(session);
-
+
return SWITCH_STATUS_SUCCESS;
}
case SWITCH_MESSAGE_INDICATE_ANSWER:
case SWITCH_MESSAGE_INDICATE_PROGRESS:
{
-
+
if (((var = switch_channel_get_variable(channel, "rtp_secure_media"))) &&
(switch_true(var) || switch_core_media_crypto_str2type(var) != CRYPTO_INVALID)) {
switch_channel_set_flag(tech_pvt->channel, CF_SECURE);
switch_assert(session != NULL);
switch_assert(tech_pvt != NULL);
-
+
switch_core_session_add_stream(session, NULL);
tech_pvt->session = session;
*new_session = NULL;
- if (!(nsession = switch_core_session_request_uuid(rtc_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND,
+ if (!(nsession = switch_core_session_request_uuid(rtc_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND,
flags, pool, switch_event_get_header(var_event, "origination_uuid")))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error Creating Session\n");
goto error;
if ((hval = switch_event_get_header(var_event, "rtc_secure_media"))) {
switch_channel_set_variable(nchannel, "rtc_secure_media", hval);
}
-
+
rtc_attach_private(nsession, tech_pvt, NULL);
return cause;
}
-static int rtc_recover_callback(switch_core_session_t *session)
+static int rtc_recover_callback(switch_core_session_t *session)
{
private_object_t *tech_pvt = rtc_new_pvt(session);
rtc_attach_private(session, tech_pvt, NULL);
-
+
return 1;
}
if (new_node != NULL) {
new_node->next = node;
new_node->prev = node->prev;
-
+
if (node->prev != NULL) {
node->prev->next = new_node;
}
uint32_t array_size;
if (read_proc(&array_size, sizeof(uint32_t), user_data) == sizeof(uint32_t)) {
array_size = swap_uint32(array_size);
-
+
for (i = 0; i < array_size; ++i) {
element = amf0_data_read(read_proc, user_data);
if (data->u.string_data.mbstr) {
free(data->u.string_data.mbstr);
data->u.string_data.mbstr = NULL;
- }
+ }
break;
case AMF0_TYPE_NULL: break;
case AMF0_TYPE_UNDEFINED: break;
static void rehash(Hash *pH, int new_size){
struct _ht *new_ht; /* The new hash table */
HashElem *elem, *next_elem; /* For looping over existing elements */
-
+
assert( (new_size & (new_size-1))==0 );
new_ht = (struct _ht *)pH->xMalloc( new_size*sizeof(struct _ht) );
if( new_ht==0 ) return;
){
HashElem *elem; /* Used to loop thru the element list */
int count; /* Number of elements left to test */
-
+
if( pH->ht ){
struct _ht *pEntry = &pH->ht[h];
elem = pEntry->chain;
int h; /* the hash of the key modulo hash table size */
HashElem *elem; /* Used to loop thru the element list */
HashElem *new_elem; /* New element added to the pH */
-
+
assert( pH!=0 );
hraw = binHash(pKey, nKey);
assert( (pH->htsize & (pH->htsize-1))==0 );
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", RTMP_EVENT_ATTACH);
return SWITCH_STATUS_TERM;
}
-
+
memset(&rtmp_globals, 0, sizeof(rtmp_globals));
switch_mutex_init(&rtmp_globals.mutex, SWITCH_MUTEX_NESTED, pool);
switch_event_free_subclass(RTMP_EVENT_LOGOUT);
switch_event_free_subclass(RTMP_EVENT_DETACH);
switch_event_free_subclass(RTMP_EVENT_ATTACH);
-
+
switch_mutex_lock(rtmp_globals.mutex);
while ((hi = switch_core_hash_first_iter(rtmp_globals.profile_hash, hi))) {
void *val;
amf0_object_add(object, "description", amf0_str("description"));
amf0_object_add(object, "details", amf0_str("details"));
amf0_object_add(object, "clientid", amf0_number_new(217834719));
-
+
rtmp_send_invoke_free(rsession, RTMP_DEFAULT_STREAM_NOTIFY, 0, state->stream_id,
amf0_str("onStatus"),
amf0_number_new(0),
You can place files in the skinny-patterns directory to get included.
-->
<X-PRE-PROCESS cmd="include" data="skinny-patterns/*.xml"/>
-
+
</context>
</include>
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2010, Mathieu Parent <math.parent@gmail.com>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Mathieu Parent <math.parent@gmail.com>
*
*
/* Look for \200, if found, next character indicates string id */
char match = (char) 128;
-
+
tmp = switch_mprintf("");
if (zstr(str)) {
result = switch_core_session_locate(uuid);
#endif
if(!result) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
"Unable to find session %s on %s:%d, line %d\n",
uuid, listener->device_name, listener->device_instance, *line_instance_p);
}
{
switch_cache_db_handle_t *dbh = NULL;
char *dsn;
-
+
if (!zstr(profile->odbc_dsn)) {
dsn = profile->odbc_dsn;
} else {
if (switch_cache_db_get_db_handle_dsn(&dbh, dsn) != SWITCH_STATUS_SUCCESS) {
dbh = NULL;
}
-
+
return dbh;
}
skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG,
"Line %d, Call %d Change State to %s (%d)\n",
line_instance, call_id,
- skinny_call_state2str(call_state), call_state);
+ skinny_call_state2str(call_state), call_state);
}
"SELECT call_state FROM skinny_active_lines "
"WHERE device_name='%q' AND device_instance=%d "
"AND call_state not in (%d,%d,%d)",
- listener->device_name, listener->device_instance,
+ listener->device_name, listener->device_instance,
SKINNY_ON_HOOK, SKINNY_IN_USE_REMOTELY, SKINNY_HOLD
))) {
tech_pvt->codec_ms != (uint32_t)tech_pvt->read_impl.microseconds_per_packet / 1000) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Changing Codec from %s@%dms to %s@%dms\n",
- tech_pvt->read_impl.iananame, tech_pvt->read_impl.microseconds_per_packet / 1000,
+ tech_pvt->read_impl.iananame, tech_pvt->read_impl.microseconds_per_packet / 1000,
tech_pvt->rm_encoding, tech_pvt->codec_ms);
switch_core_session_lock_codec_write(tech_pvt->session);
if (switch_rtp_ready(tech_pvt->rtp_session)) {
switch_assert(tech_pvt->read_codec.implementation);
- if (switch_rtp_change_interval(tech_pvt->rtp_session,
+ if (switch_rtp_change_interval(tech_pvt->rtp_session,
tech_pvt->read_impl.microseconds_per_packet,
tech_pvt->read_impl.samples_per_packet
) != SWITCH_STATUS_SUCCESS) {
switch_channel_t *channel = switch_core_session_get_channel(tech_pvt->session);
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
- switch_goto_status(SWITCH_STATUS_FALSE, end);
+ switch_goto_status(SWITCH_STATUS_FALSE, end);
}
}
tech_pvt->session = session;
}
-/*
- State methods they get called when the state changes to the specific state
+/*
+ State methods they get called when the state changes to the specific state
returning SWITCH_STATUS_SUCCESS tells the core to execute the standard state method next
so if you fully implement the state you can return SWITCH_STATUS_FALSE to skip it.
*/
skinny_profile_find_listener_by_device_name_and_instance(helper->tech_pvt->profile, device_name, device_instance, &listener);
if(listener) {
- if(!strcmp(device_name, helper->listener->device_name)
+ if(!strcmp(device_name, helper->listener->device_name)
&& (device_instance == helper->listener->device_instance)
&& (line_instance == helper->line_instance)) {/* the calling line */
helper->tech_pvt->caller_profile->dialplan = switch_core_strdup(helper->tech_pvt->caller_profile->pool, listener->profile->dialplan);
skinny_profile_find_listener_by_device_name_and_instance(helper->tech_pvt->profile, device_name, device_instance, &listener);
if(listener) {
- if(!strcmp(device_name, helper->listener->device_name)
+ if(!strcmp(device_name, helper->listener->device_name)
&& (device_instance == helper->listener->device_instance)
&& (line_instance == helper->line_instance)) {/* the calling line */
helper->tech_pvt->caller_profile->dialplan = switch_core_strdup(helper->tech_pvt->caller_profile->pool, listener->profile->dialplan);
if(listener) {
if((call_state == SKINNY_PROCEED) || (call_state == SKINNY_CONNECTED)) { /* calling parties */
send_stop_tone(listener, line_instance, call_id);
- send_set_lamp(listener, SKINNY_BUTTON_LINE, line_instance, SKINNY_LAMP_OFF);
- send_clear_prompt_status(listener, line_instance, call_id);
+ send_set_lamp(listener, SKINNY_BUTTON_LINE, line_instance, SKINNY_LAMP_OFF);
+ send_clear_prompt_status(listener, line_instance, call_id);
}
send_set_lamp(listener, SKINNY_BUTTON_LINE, line_instance, SKINNY_LAMP_OFF);
send_define_current_time_date(listener);
listener->digit_timeout_time = 0;
- skinny_log_ls(listener, helper->tech_pvt->session, SWITCH_LOG_DEBUG,
- "channel_on_hangup_callback - cause=%s [%d], call_state = %s [%d]\n",
+ skinny_log_ls(listener, helper->tech_pvt->session, SWITCH_LOG_DEBUG,
+ "channel_on_hangup_callback - cause=%s [%d], call_state = %s [%d]\n",
switch_channel_cause2str(helper->cause), helper->cause,
skinny_call_state2str(call_state), call_state);
switch_clear_flag_locked(tech_pvt, TFLAG_IO);
- skinny_log_s(session, SWITCH_LOG_DEBUG, "%s CHANNEL HANGUP [%s]\n",
+ skinny_log_s(session, SWITCH_LOG_DEBUG, "%s CHANNEL HANGUP [%s]\n",
switch_channel_get_name(channel), switch_channel_cause2str(cause));
helper.tech_pvt= tech_pvt;
skinny_profile_t *profile = listener->profile;
char *sql;
- skinny_log_l(listener, SWITCH_LOG_DEBUG,
+ skinny_log_l(listener, SWITCH_LOG_DEBUG,
"Clean device from DB with name '%s'\n",
device_name);
}
} else {
- skinny_log_l_msg(listener, SWITCH_LOG_DEBUG,
+ skinny_log_l_msg(listener, SWITCH_LOG_DEBUG,
"Clean device from DB, missing device name.\n");
}
}
skinny_profile_t *profile = listener->profile;
char *sql;
- skinny_log_l(listener, SWITCH_LOG_DEBUG,
+ skinny_log_l(listener, SWITCH_LOG_DEBUG,
"Clean listener from DB with name '%s' and instance '%d'\n",
listener->device_name, listener->device_instance);
}
} else {
- skinny_log_l_msg(listener, SWITCH_LOG_DEBUG,
+ skinny_log_l_msg(listener, SWITCH_LOG_DEBUG,
"Clean listener from DB, missing device name.\n");
}
}
switch_event_fire(&event);
}
break;
- default:
+ default:
skinny_log_l_msg(listener, SWITCH_LOG_DEBUG, "Communication Error\n");
}
switch_safe_free(request);
switch_snprintf(dbname, sizeof(dbname), "skinny_%s", profile->name);
profile->dbname = switch_core_strdup(profile->pool, dbname);
-
-
-
+
+
+
if ((dbh = skinny_get_db_handle(profile))) {
switch_cache_db_test_reactive(dbh, "select count(*) from skinny_devices", NULL, devices_sql);
switch_cache_db_test_reactive(dbh, "select count(*) from skinny_lines", NULL, lines_sql);
switch_cache_db_test_reactive(dbh, "select count(*) from skinny_active_lines", NULL, active_lines_sql);
switch_cache_db_release_db_handle(&dbh);
}
-
+
skinny_profile_respawn(profile, 0);
/* Register profile */
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2010, Mathieu Parent <math.parent@gmail.com>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Mathieu Parent <math.parent@gmail.com>
*
*
char *dbname;
char *odbc_dsn;
switch_odbc_handle_t *master_odbc;
- switch_mutex_t *sql_mutex;
+ switch_mutex_t *sql_mutex;
/* stats */
uint32_t ib_calls;
uint32_t ob_calls;
uint32_t ib_failed_calls;
- uint32_t ob_failed_calls;
+ uint32_t ob_failed_calls;
/* listener */
int listener_threads;
- switch_mutex_t *listener_mutex;
+ switch_mutex_t *listener_mutex;
switch_socket_t *sock;
switch_mutex_t *sock_mutex;
struct listener *listeners;
uint32_t transfer_from_call_id;
/* codec */
- char *iananame;
+ char *iananame;
switch_codec_t read_codec;
switch_codec_t write_codec;
switch_codec_implementation_t read_impl;
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2010, Mathieu Parent <math.parent@gmail.com>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Mathieu Parent <math.parent@gmail.com>
*
*
skinny_profile_find_listener_by_device_name(profile, device_name, &listener);
if(listener) {
- send_forward_stat(listener, number);
+ send_forward_stat(listener, number);
stream->write_function(stream, "+OK\n");
} else {
skinny_profile_find_listener_by_device_name(profile, device_name, &listener);
if(listener) {
- send_display_prompt_status(listener, 0, display, 0, 0);
+ send_display_prompt_status(listener, 0, display, 0, 0);
stream->write_function(stream, "+OK\n");
} else {
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2010, Mathieu Parent <math.parent@gmail.com>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Mathieu Parent <math.parent@gmail.com>
*
*
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2010, Mathieu Parent <math.parent@gmail.com>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Mathieu Parent <math.parent@gmail.com>
*
*
message->data.start_tone.call_id = call_id;
skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG,
- "Sending Start Tone with Tone (%s), Line Instance (%d), Call ID (%d)\n",
+ "Sending Start Tone with Tone (%s), Line Instance (%d), Call ID (%d)\n",
skinny_tone2str(tone), line_instance, call_id);
return skinny_send_reply_quiet(listener, message, SWITCH_TRUE);
skinny_message_t *message;
skinny_create_message(message, FORWARD_STAT_MESSAGE, forward_stat);
-
+
if ( number && number[0] )
{
message->data.forward_stat.active_forward = 1;
return skinny_send_reply_quiet(listener, message, SWITCH_TRUE);
}
-switch_status_t perform_send_srvreq_response(listener_t *listener,
+switch_status_t perform_send_srvreq_response(listener_t *listener,
const char *file, const char *func, int line,
char *ip, uint32_t port)
{
/* ... */
skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG,
- "Send Start Media Transmission with Conf ID(%d), Passthrough Party ID (%d), ...\n",
+ "Send Start Media Transmission with Conf ID(%d), Passthrough Party ID (%d), ...\n",
conference_id, pass_thru_party_id);
return skinny_send_reply_quiet(listener, message, SWITCH_TRUE);
/* ... */
skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG,
- "Send Stop Media Transmission with Conf ID (%d), Passthrough Party ID (%d), Conf ID2 (%d)\n",
+ "Send Stop Media Transmission with Conf ID (%d), Passthrough Party ID (%d), Conf ID2 (%d)\n",
conference_id, pass_thru_party_id, conference_id2);
return skinny_send_reply_quiet(listener, message, SWITCH_TRUE);
if ( listener->profile->debug >= 9 ) {
skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG,
- "Send Define Time Date with %.4d-%.2d-%.2d %.2d:%.2d:%.2d.%d, Timestamp (%d), DOW (%d)\n",
+ "Send Define Time Date with %.4d-%.2d-%.2d %.2d:%.2d:%.2d.%d, Timestamp (%d), DOW (%d)\n",
year, month, day, hour, minute, seconds, milliseconds, timestamp, day_of_week);
}
tmp = skinny_format_message(display);
skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG,
- "Send Display Prompt Status with Timeout (%d), Display (%s), Line Instance (%d), Call ID (%d)\n",
+ "Send Display Prompt Status with Timeout (%d), Display (%s), Line Instance (%d), Call ID (%d)\n",
timeout, tmp, line_instance, call_id);
switch_safe_free(tmp);
message->data.display_prompt_status.call_id = call_id;
skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG,
- "Send Display Prompt Status with Timeout (%d), Display (%s), Line Instance (%d), Call ID (%d)\n",
+ "Send Display Prompt Status with Timeout (%d), Display (%s), Line Instance (%d), Call ID (%d)\n",
timeout, skinny_textid2str(display_textid), line_instance, call_id);
return skinny_send_reply_quiet(listener, message, SWITCH_TRUE);
tmp = skinny_format_message(notify);
skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG,
- "Send Display Pri Notify with Timeout (%d), Priority (%d), Message (%s)\n",
+ "Send Display Pri Notify with Timeout (%d), Priority (%d), Message (%s)\n",
message_timeout, priority, tmp);
switch_safe_free(tmp);
}
-switch_status_t perform_send_reset(listener_t *listener,
+switch_status_t perform_send_reset(listener_t *listener,
const char *file, const char *func, int line,
uint32_t reset_type)
{
return skinny_send_reply_quiet(listener, message, SWITCH_TRUE);
}
-switch_status_t perform_send_extended_data(listener_t *listener,
+switch_status_t perform_send_extended_data(listener_t *listener,
const char *file, const char *func, int line,
uint32_t message_type,
uint32_t application_id,
switch_copy_string(message->data.extended_data.data, data, data_length);
skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG,
- "Send Extended Data with Application ID (%d), Line Instance (%d), Call ID (%d), ...\n",
+ "Send Extended Data with Application ID (%d), Line Instance (%d), Call ID (%d), ...\n",
application_id, line_instance, call_id );
return skinny_send_reply_quiet(listener, message, SWITCH_TRUE);
ptr = (char *) reply;
if (listener_is_ready(listener)) {
- if (listener->profile->debug >= 10 ||
+ if (listener->profile->debug >= 10 ||
(listener->profile->debug >= 9 && reply->type != KEEP_ALIVE_ACK_MESSAGE)) {
skinny_log_l_ffl(listener, file, func, line, SWITCH_LOG_DEBUG,
"Sending %s (type=%x,length=%d).\n",
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2010, Mathieu Parent <math.parent@gmail.com>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Mathieu Parent <math.parent@gmail.com>
*
*
uint32_t serviceNumber; /*!< Service Number */
} levelPreference_t; /*!< Level Preference Structure */
-/*!
+/*!
* \brief Layout Config Structure (Update Capabilities Message Struct)
* \since 20080111
*/
skinny_codecs payload_capability; /*!< PayLoad Capability */
uint32_t maxFramesPerPacket; /*!< Maximum Number of Frames per IP Packet */
uint32_t unknown[2]; /*!< this are related to G.723 */
-} audioCap_t;
+} audioCap_t;
/*!
* \brief Video Capabilities Structure
dataCap_t dataCaps[SKINNY_MAX_DATA_CAPABILITIES]; /*!< Data Capabilities */
uint32_t unknown; /*!< Unknown */
-};
+};
/* ServiceUrlStatReqMessage */
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2010, Mathieu Parent <math.parent@gmail.com>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Mathieu Parent <math.parent@gmail.com>
*
*
channel = switch_core_session_get_channel(nsession);
- snprintf(name, sizeof(name), "SKINNY/%s/%s:%d/%d", listener->profile->name,
+ snprintf(name, sizeof(name), "SKINNY/%s/%s:%d/%d", listener->profile->name,
listener->device_name, listener->device_instance, *line_instance_p);
switch_channel_set_name(channel, name);
if (switch_channel_get_state(channel) == CS_NEW) {
switch_channel_set_state(channel, CS_HIBERNATE);
} else {
- skinny_log_ls_msg(listener, nsession, SWITCH_LOG_CRIT,
+ skinny_log_ls_msg(listener, nsession, SWITCH_LOG_CRIT,
"Wow! this channel should be in CS_NEW state, but it is not!\n");
}
action = SKINNY_ACTION_WAIT;
*data = switch_core_session_strdup(session, current_application->application_data);
} else {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
"Unknown skinny dialplan application %s\n", current_application->application_name);
}
}
// get listener profile setting for ringdown/autodial
// if initial offhook - and we have a ringdown/autodial configured, just dial it in one shot
if (!dest && append_dest == '\0' && listener->ext_autodial ) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
"triggering auto dial to (%s)\n", listener->ext_autodial);
tech_pvt->caller_profile->destination_number = switch_core_strdup(tech_pvt->caller_profile->pool, listener->ext_autodial);
struct skinny_session_send_call_info_all_helper *helper = pArg;
listener_t *listener = NULL;
- skinny_profile_find_listener_by_device_name_and_instance(helper->tech_pvt->profile,
+ skinny_profile_find_listener_by_device_name_and_instance(helper->tech_pvt->profile,
device_name, device_instance, &listener);
if(listener) {
skinny_session_send_call_info(helper->tech_pvt->session, listener, line_instance);
listener = helper->listener;
if ( ! listener ) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(helper->tech_pvt->session), SWITCH_LOG_DEBUG,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(helper->tech_pvt->session), SWITCH_LOG_DEBUG,
"no defined listener on channel var setup, will not attempt to set variables\n");
return(0);
}
/* Process through and extract any variables from the user and set in the channel */
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(helper->tech_pvt->session), SWITCH_LOG_DEBUG,
- "searching for user (id=%s) in profile %s in channel var setup\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(helper->tech_pvt->session), SWITCH_LOG_DEBUG,
+ "searching for user (id=%s) in profile %s in channel var setup\n",
listener->device_name, listener->profile->domain);
- if (switch_xml_locate_user("id", listener->device_name, listener->profile->domain, "",
+ if (switch_xml_locate_user("id", listener->device_name, listener->profile->domain, "",
&xroot, &xdomain, &xuser, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(helper->tech_pvt->session), SWITCH_LOG_WARNING,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(helper->tech_pvt->session), SWITCH_LOG_WARNING,
"unable to find user (id=%s) in channel var setup\n", listener->device_name);
}
if ( xuser ) {
char *uid = (char *) switch_xml_attr_soft(xuser, "id");
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(helper->tech_pvt->session), SWITCH_LOG_DEBUG,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(helper->tech_pvt->session), SWITCH_LOG_DEBUG,
"found user (id=%s) in channel var setup\n", uid);
if ((xvariables = switch_xml_child(xuser, "variables"))) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(helper->tech_pvt->session), SWITCH_LOG_DEBUG,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(helper->tech_pvt->session), SWITCH_LOG_DEBUG,
"found variables section in user xml");
-
+
for (xvariable = switch_xml_child(xvariables, "variable"); xvariable; xvariable = xvariable->next) {
char *name = (char *) switch_xml_attr_soft(xvariable, "name");
char *value = (char *) switch_xml_attr_soft(xvariable, "value");
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(helper->tech_pvt->session), SWITCH_LOG_DEBUG,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(helper->tech_pvt->session), SWITCH_LOG_DEBUG,
"found variable (%s=%s) for user (%s) in channel var setup\n", name, value, listener->device_name);
switch_channel_set_variable_name_printf(helper->channel, value, "%s", name);
listener_t *listener = NULL;
uint32_t active_calls = 0;
- skinny_profile_find_listener_by_device_name_and_instance(helper->tech_pvt->profile,
+ skinny_profile_find_listener_by_device_name_and_instance(helper->tech_pvt->profile,
device_name, device_instance, &listener);
if(listener && helper->tech_pvt->session && helper->remote_session) {
switch_channel_t *channel = switch_core_session_get_channel(helper->tech_pvt->session);
helper->lines_count++;
switch_channel_set_variable(channel, "effective_callee_id_number", value);
switch_channel_set_variable(channel, "effective_callee_id_name", caller_name);
-
+
active_calls = skinny_line_count_active(listener);
- skinny_log_l(listener, SWITCH_LOG_DEBUG,
+ skinny_log_l(listener, SWITCH_LOG_DEBUG,
"Ring Lines Callback with Callee Number (%s), Caller Name (%s), Dest Number (%s), Active Calls (%d)\n",
value, caller_name, helper->tech_pvt->caller_profile->destination_number, active_calls);
msg.from = __FILE__;
if (switch_core_session_receive_message(helper->remote_session, &msg) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(helper->tech_pvt->session), SWITCH_LOG_WARNING,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(helper->tech_pvt->session), SWITCH_LOG_WARNING,
"Unable to send SWITCH_MESSAGE_INDICATE_DISPLAY message to channel %s\n",
switch_core_session_get_uuid(helper->remote_session));
}
skinny_profile_find_listener_by_device_name_and_instance(helper->tech_pvt->profile, device_name, device_instance, &listener);
if(listener) {
- if(!strcmp(device_name, helper->listener->device_name)
+ if(!strcmp(device_name, helper->listener->device_name)
&& (device_instance == helper->listener->device_instance)
&& (line_instance == helper->line_instance)) {/* the answering line */
/* nothing */
channel2 = switch_core_session_get_channel(session2);
local_uuid2 = switch_channel_get_uuid(channel2);
remote_uuid2 = switch_channel_get_partner_uuid(channel2);
- skinny_log_ls(listener, session2, SWITCH_LOG_INFO, "SST: tx from session - local_uuid=%s remote_uuid=%s local_uuid2=%s remote_uuid2=%s\n",
+ skinny_log_ls(listener, session2, SWITCH_LOG_INFO, "SST: tx from session - local_uuid=%s remote_uuid=%s local_uuid2=%s remote_uuid2=%s\n",
local_uuid, remote_uuid, local_uuid2, remote_uuid2);
skinny_log_ls(listener, session2, SWITCH_LOG_INFO, "SST: attempting ivr bridge from (%s) to (%s)\n", remote_uuid, remote_uuid2);
}
/* we clean up device above, so this below block will never trigger. I don't
- know the full details of why there would be multiple listeners with
+ know the full details of why there would be multiple listeners with
the same device - maybe a VGC or similar? Not really high priority for
support at the moment, but may need to revisit this later */
skinny_log_l_msg(listener, SWITCH_LOG_CRIT, "Unable to handle last number redial stimulus message, couldn't create incoming session.\n");
return SWITCH_STATUS_FALSE;
}
- skinny_session_process_dest(session, listener, line_instance,
+ skinny_session_process_dest(session, listener, line_instance,
empty_null2(listener->ext_redial,listener->profile->ext_redial), '\0', 0);
break;
case SKINNY_BUTTON_SPEED_DIAL:
if(session) {
status = skinny_session_transfer(session, listener, line_instance);
- }
+ }
break;
case SKINNY_BUTTON_VOICEMAIL:
skinny_create_incoming_session(listener, &line_instance, &session);
skinny_log_l_msg(listener, SWITCH_LOG_CRIT, "Unable to handle stimulus message, couldn't create incoming session.\n");
return SWITCH_STATUS_FALSE;
}
- skinny_session_process_dest(session, listener, line_instance,
+ skinny_session_process_dest(session, listener, line_instance,
empty_null2(listener->ext_voicemail, listener->profile->ext_voicemail), '\0', 0);
break;
}
switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
- }
+ }
else {
status = skinny_session_answer(session, listener, line_instance);
}
"AND skinny_active_lines.device_instance = skinny_lines.device_instance "
"AND skinny_active_lines.line_instance = skinny_lines.line_instance "
"WHERE skinny_lines.device_name='%q' AND skinny_lines.device_instance=%d",
- listener->device_name, listener->device_instance)))
+ listener->device_name, listener->device_instance)))
{
skinny_execute_sql_callback(listener->profile, listener->profile->sql_mutex, sql, skinny_hangup_active_calls_callback, &helper);
switch_safe_free(sql);
message->data.forward_stat.line_instance = request->data.forward_stat_req.line_instance;
if ( listener->profile->debug >= 9 ) {
- skinny_log_l(listener, SWITCH_LOG_DEBUG, "Handle Forward Stat Req Message with Line Instance (%d)\n",
+ skinny_log_l(listener, SWITCH_LOG_DEBUG, "Handle Forward Stat Req Message with Line Instance (%d)\n",
request->data.forward_stat_req.line_instance);
}
skinny_send_reply_quiet(listener, message, SWITCH_TRUE);
send_set_lamp(listener, SKINNY_BUTTON_LINE, line_instance, SKINNY_LAMP_ON);
}
} else {
- skinny_log_l(listener, SWITCH_LOG_WARNING, "Unable to find session for call id=%d.\n",
+ skinny_log_l(listener, SWITCH_LOG_WARNING, "Unable to find session for call id=%d.\n",
request->data.open_receive_channel_ack.pass_thru_party_id);
}
end:
if (message) {
skinny_send_reply_quiet(listener, message, SWITCH_FALSE);
} else {
- skinny_log_l(listener, SWITCH_LOG_ERROR, "Profile %s doesn't have a default <soft-key-set-set>.\n",
+ skinny_log_l(listener, SWITCH_LOG_ERROR, "Profile %s doesn't have a default <soft-key-set-set>.\n",
listener->profile->name);
}
skinny_log_l_msg(listener, SWITCH_LOG_CRIT, "Unable to handle soft key event, could not create incoming session.\n");
return SWITCH_STATUS_FALSE;
}
- skinny_session_process_dest(session, listener, line_instance,
+ skinny_session_process_dest(session, listener, line_instance,
empty_null2(listener->ext_redial,listener->profile->ext_redial), '\0', 0);
break;
case SOFTKEY_NEWCALL:
skinny_log_l_msg(listener, SWITCH_LOG_CRIT, "Unable to handle soft key event, could not create incoming session.\n");
return SWITCH_STATUS_FALSE;
}
- skinny_session_process_dest(session, listener, line_instance,
+ skinny_session_process_dest(session, listener, line_instance,
empty_null2(listener->ext_meetme, listener->profile->ext_meetme), '\0', 0);
break;
case SOFTKEY_CALLPICKUP:
skinny_log_l_msg(listener, SWITCH_LOG_CRIT, "Unable to handle soft key event, could not create incoming session.\n");
return SWITCH_STATUS_FALSE;
}
- skinny_session_process_dest(session, listener, line_instance,
+ skinny_session_process_dest(session, listener, line_instance,
empty_null2(listener->ext_pickup, listener->profile->ext_pickup), '\0', 0);
break;
case SOFTKEY_CFWDALL:
skinny_log_l_msg(listener, SWITCH_LOG_CRIT, "Unable to handle soft key event, could not create incoming session.\n");
return SWITCH_STATUS_FALSE;
}
- skinny_session_process_dest(session, listener, line_instance,
+ skinny_session_process_dest(session, listener, line_instance,
empty_null2(listener->ext_cfwdall, listener->profile->ext_cfwdall), '\0', 0);
break;
default:
message->data.unregister_ack.unregister_status = 0; /* OK */
skinny_log_l(listener, SWITCH_LOG_DEBUG, "Handle Unregister with Status (%d)\n", message->data.unregister_ack.unregister_status);
-
+
skinny_send_reply_quiet(listener, message, SWITCH_TRUE);
/* Close socket */
message->data.soft_key_template.soft_key[i].soft_key_event = soft_key_template_default_events[i];
}
-
+
if ( listener->profile->debug >= 9 ) {
skinny_log_l_msg(listener, SWITCH_LOG_DEBUG, "Handle Soft Key Template Request with Default Template\n");
}
}
if ( listener->profile->debug >= 9 ) {
- skinny_log_l(listener, SWITCH_LOG_DEBUG, "Update headset accessory status (%s)\n",
+ skinny_log_l(listener, SWITCH_LOG_DEBUG, "Update headset accessory status (%s)\n",
skinny_accessory_state2str(request->data.headset_status.mode));
}
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Skinny-DeviceToUser-Call-Id", "%d", request->data.data.call_id);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Skinny-DeviceToUser-Transaction-Id", "%d", request->data.data.transaction_id);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Skinny-DeviceToUser-Data-Length", "%d", request->data.data.data_length);
-
+
tmp = malloc(request->data.data.data_length + 1);
memcpy(tmp, request->data.data.data, request->data.data.data_length);
switch_status_t skinny_handle_request(listener_t *listener, skinny_message_t *request)
{
- if (listener->profile->debug >= 10 ||
+ if (listener->profile->debug >= 10 ||
(listener->profile->debug >= 9 && request->type != KEEP_ALIVE_MESSAGE)) {
skinny_log_l(listener, SWITCH_LOG_DEBUG, "Received %s (type=%x,length=%d).\n",
skinny_message_type2str(request->type), request->type, request->length);
case UPDATE_CAPABILITIES_MESSAGE:
return skinny_handle_updatecapabilities(listener, request);
case SERVER_REQ_MESSAGE:
- return skinny_handle_server_req_message(listener, request);
+ return skinny_handle_server_req_message(listener, request);
default:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
"Unhandled %s (type=%x,length=%d).\n", skinny_message_type2str(request->type), request->type, request->length);
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2010, Mathieu Parent <math.parent@gmail.com>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Mathieu Parent <math.parent@gmail.com>
*
*
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2010, Mathieu Parent <math.parent@gmail.com>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Mathieu Parent <math.parent@gmail.com>
*
*
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2010, Mathieu Parent <math.parent@gmail.com>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Mathieu Parent <math.parent@gmail.com>
*
*
//gcc -Wall -ggdb client.c -o client -lX11 -lpthread
/*
-
- Interactive client for the Skype API
+
+ Interactive client for the Skype API
USAGE: client [Xserver instance]
-# ./client :103
+# ./client :103
*/
}
-/*
- State methods they get called when the state changes to the specific state
+/*
+ State methods they get called when the state changes to the specific state
returning SWITCH_STATUS_SUCCESS tells the core to execute the standard state method next
so if you fully implement the state you can return SWITCH_STATUS_FALSE to skip it.
*/
switch_mutex_lock(globals.mutex);
/* Fact is the real interface start from 1 */
- //XXX no, is just a convention, but you can have it start from 0. I do not, for aestetic reasons :-)
+ //XXX no, is just a convention, but you can have it start from 0. I do not, for aestetic reasons :-)
for (i = 0; i < SKYPOPEN_MAX_INTERFACES; i++) {
int interface_id;
}
#endif
-// CLOUDTREE (THomas Hazel) - is there a capable freeswitch list?
+// CLOUDTREE (THomas Hazel) - is there a capable freeswitch list?
int skypopen_list_size(struct SkypopenList *list)
{
return list->entries;
-//indent -gnu -ts4 -br -brs -cdw -lp -ce -nbfda -npcs -nprs -npsl -nbbo -saf -sai -saw -cs -bbo -nhnl -nut -sob -l90
+//indent -gnu -ts4 -br -brs -cdw -lp -ce -nbfda -npcs -nprs -npsl -nbbo -saf -sai -saw -cs -bbo -nhnl -nut -sob -l90
#include "skypiax.h"
/* LOCKS */
#endif /* ASTERISK_VERSION_1_4 */
};
-/*! \brief fake skypiax_pvt structure values,
+/*! \brief fake skypiax_pvt structure values,
* just for logging purposes */
struct skypiax_pvt skypiax_log_struct = {
.name = "none",
};
-/*! \brief Default skypiax_pvt structure values,
+/*! \brief Default skypiax_pvt structure values,
* used by skypiax_mkif to initialize the interfaces */
struct skypiax_pvt skypiax_default = {
.interface_state = SKYPIAX_STATE_DOWN,
.skypiax_dir_entry_extension_prefix = 6,
};
-/*!
+/*!
* \brief PVT structure for a skypiax interface (channel), created by skypiax_mkif
*/
struct skypiax_pvt *skypiax_iflist = NULL;
#ifdef ASTERISK_VERSION_1_6
struct ast_cli_entry myclis[] = {
-/*
+/*
* CLI do not works since some time on 1.6, they changed the CLI mechanism
*/
#if 0
return res;
}
-/*! \brief PBX interface function -build skypiax pvt structure
+/*! \brief PBX interface function -build skypiax pvt structure
* skypiax calls initiated by the PBX arrive here */
struct ast_channel *skypiax_request(const char *type, int format, void *data, int *cause)
{
return &f;
}
-/*! \brief Initiate skypiax call from PBX
+/*! \brief Initiate skypiax call from PBX
* used from the dial() application
*/
int skypiax_originate_call(struct ast_channel *c, char *idest, int timeout)
* \brief Load the module into Asterisk and start its threads
*
* This function register the module into Asterisk,
- * create the interfaces for the channels,
+ * create the interfaces for the channels,
* start the auxiliary threads for the interfaces,
* then start a monitor thread. The monitor thread
* will signal Asterisk when an interface receive a call.
* \brief Unload the module from Asterisk and shutdown its threads
*
* This function unregister the module from Asterisk,
- * destroy the interfaces for the channels,
+ * destroy the interfaces for the channels,
* shutdown the auxiliary threads for the interfaces,
* then shutdown its monitor thread.
*
return 0;
}
-/*! \brief The skypiax monitoring thread
+/*! \brief The skypiax monitoring thread
* \note This thread monitors all the skypiax interfaces that are not in a call
- * (and thus do not have a separate thread) indefinitely
+ * (and thus do not have a separate thread) indefinitely
* */
void *skypiax_do_monitor(void *data)
{
/* If there are errors... */
if (res < 0) {
- if (errno == EINTR) /* EINTR is just the select
+ if (errno == EINTR) /* EINTR is just the select
being interrupted by a SIGURG, or so */
continue;
else {
}
/*!
- * \brief Initialize the soundcard channels (input and output) used by one interface (a multichannel soundcard can be used by multiple interfaces)
+ * \brief Initialize the soundcard channels (input and output) used by one interface (a multichannel soundcard can be used by multiple interfaces)
* \param p the skypiax_pvt of the interface
*
- * This function initialize the soundcard channels (input and output) used by one interface (a multichannel soundcard can be used by multiple interfaces). It simply pass its parameters to the right function for the sound system for which has been compiled, eg. alsa_init for ALSA, oss_init for OSS, winmm_init for Windows Multimedia, etc and return the result
+ * This function initialize the soundcard channels (input and output) used by one interface (a multichannel soundcard can be used by multiple interfaces). It simply pass its parameters to the right function for the sound system for which has been compiled, eg. alsa_init for ALSA, oss_init for OSS, winmm_init for Windows Multimedia, etc and return the result
*
* \return zero on success, -1 on error.
*/
}
/*!
- * \brief Shutdown the soundcard channels (input and output) used by one interface (a multichannel soundcard can be used by multiple interfaces)
+ * \brief Shutdown the soundcard channels (input and output) used by one interface (a multichannel soundcard can be used by multiple interfaces)
* \param p the skypiax_pvt of the interface
*
* This function shutdown the soundcard channels (input and output) used by one interface (a multichannel soundcard can be used by multiple interfaces). It simply pass its parameters to the right function for the sound system for which has been compiled, eg. alsa_shutdown for ALSA, oss_shutdown for OSS, winmm_shutdown for Windows Multimedia, etc and return the result
int friends_count = 0;
while (p->skype_friends[0] == '\0') {
- /* FIXME needs a timeout, can't wait forever!
+ /* FIXME needs a timeout, can't wait forever!
* eg. when skype is running but not connected! */
usleep(100);
friends_count++;
* So, we have the Skype username (the HANDLE, I think is called).
* But we want to call the names we see in the Skype contact list
* So, let's check the DISPLAYNAME (the end user modified contact name)
- * Then, we check the FULLNAME (that appears as it was the DISPLAYNAME
+ * Then, we check the FULLNAME (that appears as it was the DISPLAYNAME
* if the end user has not modify it)
- * If we still have neither DISPLAYNAME nor FULLNAME, we'll use the
+ * If we still have neither DISPLAYNAME nor FULLNAME, we'll use the
* Skipe username (the HANDLE)
*/
skypiax_signaling_write(p, msg_to_skype);
int displayname_count = 0;
while (p->skype_displayname[0] == '\0') {
- /* FIXME needs a timeout, can't wait forever!
+ /* FIXME needs a timeout, can't wait forever!
* eg. when skype is running but not connected! */
usleep(100);
displayname_count++;
where2 = strstr(p->skype_displayname, "DISPLAYNAME ");
if (where2) {
- /* there can be some *smart* that makes a displayname
+ /* there can be some *smart* that makes a displayname
* that is different than first<space>last, */
- /* maybe initials, simbols, slashes,
+ /* maybe initials, simbols, slashes,
* something smartish... let's check */
if (where2[12] != '\0') {
skypiax_signaling_write(p, msg_to_skype);
int fullname_count = 0;
while (p->skype_fullname[0] == '\0') {
- /* FIXME needs a timeout, can't wait forever!
+ /* FIXME needs a timeout, can't wait forever!
* eg. when skype is running but not connected! */
usleep(100);
fullname_count++;
where2 = strstr(p->skype_fullname, "FULLNAME ");
if (where2) {
- /* there can be some *smart* that makes a fullname
+ /* there can be some *smart* that makes a fullname
* that is different than first<space>last, */
/* maybe initials, simbols, slashes,
* something smartish... let's check */
-//indent -gnu -ts4 -br -brs -cdw -lp -ce -nbfda -npcs -nprs -npsl -nbbo -saf -sai -saw -cs -bbo -nhnl -nut -sob -l90
+//indent -gnu -ts4 -br -brs -cdw -lp -ce -nbfda -npcs -nprs -npsl -nbbo -saf -sai -saw -cs -bbo -nhnl -nut -sob -l90
#ifndef _SKYPIAX_H_
#define _SKYPIAX_H_
#define SKYPIAX_FRAME_SIZE 160
/* SKYPIAX INTERNAL STRUCTS */
-/*!
+/*!
* \brief structure for exchanging messages with the skype client
*/
#ifdef WANT_SKYPE_X11
#endif //WIN32
-/*!
+/*!
* \brief PVT structure for a skypiax interface (channel), created by skypiax_mkif
*/
struct skypiax_pvt {
{
struct snd_pcm_str *stream = &pcm->streams[direction];
struct snd_pcm_substream *substream;
-
+
for (substream = stream->substream; substream != NULL; substream = substream->next)
substream->ops = ops;
}
void snd_pcm_set_sync(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
-
+
runtime->sync.id32[0] = substream->pcm->card->number;
runtime->sync.id32[1] = -1;
runtime->sync.id32[2] = -1;
* Standard ioctl routine
*/
-static inline unsigned int div32(unsigned int a, unsigned int b,
+static inline unsigned int div32(unsigned int a, unsigned int b,
unsigned int *r)
{
if (b == 0) {
/**
* snd_interval_ratnum - refine the interval value
* @i: interval to refine
- * @rats_count: number of ratnum_t
+ * @rats_count: number of ratnum_t
* @rats: ratnum_t array
* @nump: pointer to store the resultant numerator
* @denp: pointer to store the resultant denominator
}
t.min = div_down(best_num, best_den);
t.openmin = !!(best_num % best_den);
-
+
result_num = best_num;
result_diff = best_diff;
result_den = best_den;
}
t.min = div_down(best_num, best_den);
t.openmin = !!(best_num % best_den);
-
+
best_num = best_den = best_diff = 0;
for (k = 0; k < rats_count; ++k) {
unsigned int num;
constrs->rules_num++;
va_end(args);
return 0;
-}
+}
EXPORT_SYMBOL(snd_pcm_hw_rule_add);
* @var: hw_params variable to apply the range
* @min: the minimal value
* @max: the maximal value
- *
+ *
* Apply the min/max range constraint to an interval parameter.
*/
int snd_pcm_hw_constraint_minmax(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var,
{
struct snd_pcm_hw_constraint_list *list = rule->private;
return snd_interval_list(hw_param_interval(params, rule->var), list->count, list->list, list->mask);
-}
+}
/**
* @cond: condition bits
* @var: hw_params variable to apply the list constraint
* @l: list
- *
+ *
* Apply the list of constraints to an interval parameter.
*/
int snd_pcm_hw_constraint_list(struct snd_pcm_runtime *runtime,
* @var: hw_params variable to apply the ratnums constraint
* @r: struct snd_ratnums constriants
*/
-int snd_pcm_hw_constraint_ratnums(struct snd_pcm_runtime *runtime,
+int snd_pcm_hw_constraint_ratnums(struct snd_pcm_runtime *runtime,
unsigned int cond,
snd_pcm_hw_param_t var,
struct snd_pcm_hw_constraint_ratnums *r)
* @var: hw_params variable to apply the ratdens constraint
* @r: struct snd_ratdens constriants
*/
-int snd_pcm_hw_constraint_ratdens(struct snd_pcm_runtime *runtime,
+int snd_pcm_hw_constraint_ratdens(struct snd_pcm_runtime *runtime,
unsigned int cond,
snd_pcm_hw_param_t var,
struct snd_pcm_hw_constraint_ratdens *r)
* @width: sample bits width
* @msbits: msbits width
*/
-int snd_pcm_hw_constraint_msbits(struct snd_pcm_runtime *runtime,
+int snd_pcm_hw_constraint_msbits(struct snd_pcm_runtime *runtime,
unsigned int cond,
unsigned int width,
unsigned int msbits)
snd_pcm_hw_param_t var,
unsigned long step)
{
- return snd_pcm_hw_rule_add(runtime, cond, var,
+ return snd_pcm_hw_rule_add(runtime, cond, var,
snd_pcm_hw_rule_step, (void *) step,
var, -1);
}
};
return snd_interval_list(hw_param_interval(params, rule->var),
ARRAY_SIZE(pow2_sizes), pow2_sizes, 0);
-}
+}
/**
* snd_pcm_hw_constraint_pow2 - add a hw constraint power-of-2 rule
unsigned int cond,
snd_pcm_hw_param_t var)
{
- return snd_pcm_hw_rule_add(runtime, cond, var,
+ return snd_pcm_hw_rule_add(runtime, cond, var,
snd_pcm_hw_rule_pow2, NULL,
var, -1);
}
* values > minimum. Reduce configuration space accordingly.
* Return the minimum.
*/
-int snd_pcm_hw_param_first(struct snd_pcm_substream *pcm,
- struct snd_pcm_hw_params *params,
+int snd_pcm_hw_param_first(struct snd_pcm_substream *pcm,
+ struct snd_pcm_hw_params *params,
snd_pcm_hw_param_t var, int *dir)
{
int changed = _snd_pcm_hw_param_first(params, var);
* values < maximum. Reduce configuration space accordingly.
* Return the maximum.
*/
-int snd_pcm_hw_param_last(struct snd_pcm_substream *pcm,
+int snd_pcm_hw_param_last(struct snd_pcm_substream *pcm,
struct snd_pcm_hw_params *params,
snd_pcm_hw_param_t var, int *dir)
{
case SNDRV_PCM_STATE_DRAINING:
if (is_playback)
err = -EPIPE;
- else
+ else
avail = 0; /* indicate draining */
goto _endloop;
case SNDRV_PCM_STATE_OPEN:
*availp = avail;
return err;
}
-
+
static int snd_pcm_lib_write_transfer(struct snd_pcm_substream *substream,
unsigned int hwoff,
unsigned long data, unsigned int off,
}
return 0;
}
-
+
typedef int (*transfer_f)(struct snd_pcm_substream *substream, unsigned int hwoff,
unsigned long data, unsigned int off,
snd_pcm_uframes_t size);
-static snd_pcm_sframes_t snd_pcm_lib_write1(struct snd_pcm_substream *substream,
+static snd_pcm_sframes_t snd_pcm_lib_write1(struct snd_pcm_substream *substream,
unsigned long data,
snd_pcm_uframes_t size,
int nonblock,
}
return 0;
}
-
+
snd_pcm_sframes_t snd_pcm_lib_writev(struct snd_pcm_substream *substream,
void __user **bufs,
snd_pcm_uframes_t frames)
EXPORT_SYMBOL(snd_pcm_lib_writev);
-static int snd_pcm_lib_read_transfer(struct snd_pcm_substream *substream,
+static int snd_pcm_lib_read_transfer(struct snd_pcm_substream *substream,
unsigned int hwoff,
unsigned long data, unsigned int off,
snd_pcm_uframes_t frames)
struct snd_pcm_runtime *runtime;
int nonblock;
int err;
-
+
err = pcm_sanity_check(substream);
if (err < 0)
return err;
}
return 0;
}
-
+
snd_pcm_sframes_t snd_pcm_lib_readv(struct snd_pcm_substream *substream,
void __user **bufs,
snd_pcm_uframes_t frames)
};
#endif
-int snd_pcm_hw_refine(struct snd_pcm_substream *substream,
+int snd_pcm_hw_refine(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
unsigned int k;
if (i->empty)
printk("empty");
else
- printk("%c%u %u%c",
+ printk("%c%u %u%c",
i->openmin ? '(' : '[', i->min,
i->max, i->openmax ? ')' : ']');
printk(" -> ");
#ifdef RULES_DEBUG
if (i->empty)
printk("empty\n");
- else
- printk("%c%u %u%c\n",
+ else
+ printk("%c%u %u%c\n",
i->openmin ? '(' : '[', i->min,
i->max, i->openmax ? ')' : ']');
#endif
for (k = 0; k < constrs->rules_num; k++)
rstamps[k] = 0;
- for (k = 0; k <= SNDRV_PCM_HW_PARAM_LAST_INTERVAL; k++)
+ for (k = 0; k <= SNDRV_PCM_HW_PARAM_LAST_INTERVAL; k++)
vstamps[k] = (params->rmask & (1 << k)) ? 1 : 0;
do {
again = 0;
if (i->empty)
printk("empty");
else
- printk("%c%u %u%c",
+ printk("%c%u %u%c",
i->openmin ? '(' : '[', i->min,
i->max, i->openmax ? ')' : ']');
}
if (i->empty)
printk("empty");
else
- printk("%c%u %u%c",
+ printk("%c%u %u%c",
i->openmin ? '(' : '[', i->min,
i->max, i->openmax ? ')' : ']');
}
{
struct snd_pcm_status status;
int res;
-
+
memset(&status, 0, sizeof(status));
res = snd_pcm_status(substream, &status);
if (res < 0)
{
struct snd_pcm_runtime *runtime;
unsigned int channel;
-
+
channel = info->channel;
runtime = substream->runtime;
//giovanni snd_pcm_stream_lock_irq(substream);
{
struct snd_pcm_channel_info info;
int res;
-
+
if (copy_from_user(&info, _info, sizeof(info)))
return -EFAULT;
res = snd_pcm_channel_info(substream, &info);
int state)
{
int res;
-
+
res = ops->pre_action(substream, state);
if (res < 0)
return res;
struct snd_pcm_runtime *runtime;
struct snd_card *card;
int result = 0;
-
+
if (PCM_RUNTIME_CHECK(substream))
return -ENXIO;
runtime = substream->runtime;
return snd_interval_list(hw_param_interval(params, rule->var),
snd_pcm_known_rates.count,
snd_pcm_known_rates.list, hw->rates);
-}
+}
static int snd_pcm_hw_rule_buffer_bytes_max(struct snd_pcm_hw_params *params,
struct snd_pcm_hw_rule *rule)
t.openmax = 0;
t.integer = 1;
return snd_interval_refine(hw_param_interval(params, rule->var), &t);
-}
+}
int snd_pcm_hw_constraints_init(struct snd_pcm_substream *substream)
{
SNDRV_PCM_HW_PARAM_SAMPLE_BITS, -1);
if (err < 0)
return err;
- err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
+ err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
snd_pcm_hw_rule_sample_bits, NULL,
- SNDRV_PCM_HW_PARAM_FORMAT,
+ SNDRV_PCM_HW_PARAM_FORMAT,
SNDRV_PCM_HW_PARAM_SAMPLE_BITS, -1);
if (err < 0)
return err;
- err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
+ err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
snd_pcm_hw_rule_div, NULL,
SNDRV_PCM_HW_PARAM_FRAME_BITS, SNDRV_PCM_HW_PARAM_CHANNELS, -1);
if (err < 0)
return err;
- err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FRAME_BITS,
+ err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FRAME_BITS,
snd_pcm_hw_rule_mul, NULL,
SNDRV_PCM_HW_PARAM_SAMPLE_BITS, SNDRV_PCM_HW_PARAM_CHANNELS, -1);
if (err < 0)
return err;
- err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FRAME_BITS,
+ err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FRAME_BITS,
snd_pcm_hw_rule_mulkdiv, (void*) 8,
SNDRV_PCM_HW_PARAM_PERIOD_BYTES, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, -1);
if (err < 0)
return err;
- err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FRAME_BITS,
+ err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FRAME_BITS,
snd_pcm_hw_rule_mulkdiv, (void*) 8,
SNDRV_PCM_HW_PARAM_BUFFER_BYTES, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, -1);
if (err < 0)
return err;
- err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
+ err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
snd_pcm_hw_rule_div, NULL,
SNDRV_PCM_HW_PARAM_FRAME_BITS, SNDRV_PCM_HW_PARAM_SAMPLE_BITS, -1);
if (err < 0)
return err;
- err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
+ err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
snd_pcm_hw_rule_mulkdiv, (void*) 1000000,
SNDRV_PCM_HW_PARAM_PERIOD_SIZE, SNDRV_PCM_HW_PARAM_PERIOD_TIME, -1);
if (err < 0)
return err;
- err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
+ err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
snd_pcm_hw_rule_mulkdiv, (void*) 1000000,
SNDRV_PCM_HW_PARAM_BUFFER_SIZE, SNDRV_PCM_HW_PARAM_BUFFER_TIME, -1);
if (err < 0)
return err;
- err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIODS,
+ err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIODS,
snd_pcm_hw_rule_div, NULL,
SNDRV_PCM_HW_PARAM_BUFFER_SIZE, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, -1);
if (err < 0)
return err;
- err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
+ err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
snd_pcm_hw_rule_div, NULL,
SNDRV_PCM_HW_PARAM_BUFFER_SIZE, SNDRV_PCM_HW_PARAM_PERIODS, -1);
if (err < 0)
return err;
- err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
+ err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
snd_pcm_hw_rule_mulkdiv, (void*) 8,
SNDRV_PCM_HW_PARAM_PERIOD_BYTES, SNDRV_PCM_HW_PARAM_FRAME_BITS, -1);
if (err < 0)
return err;
- err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
+ err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
snd_pcm_hw_rule_muldivk, (void*) 1000000,
SNDRV_PCM_HW_PARAM_PERIOD_TIME, SNDRV_PCM_HW_PARAM_RATE, -1);
if (err < 0)
return err;
- err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_SIZE,
+ err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_SIZE,
snd_pcm_hw_rule_mul, NULL,
SNDRV_PCM_HW_PARAM_PERIOD_SIZE, SNDRV_PCM_HW_PARAM_PERIODS, -1);
if (err < 0)
return err;
- err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_SIZE,
+ err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_SIZE,
snd_pcm_hw_rule_mulkdiv, (void*) 8,
SNDRV_PCM_HW_PARAM_BUFFER_BYTES, SNDRV_PCM_HW_PARAM_FRAME_BITS, -1);
if (err < 0)
return err;
- err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_SIZE,
+ err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_SIZE,
snd_pcm_hw_rule_muldivk, (void*) 1000000,
SNDRV_PCM_HW_PARAM_BUFFER_TIME, SNDRV_PCM_HW_PARAM_RATE, -1);
if (err < 0)
return err;
- err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES,
+ err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES,
snd_pcm_hw_rule_muldivk, (void*) 8,
SNDRV_PCM_HW_PARAM_PERIOD_SIZE, SNDRV_PCM_HW_PARAM_FRAME_BITS, -1);
if (err < 0)
return err;
- err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
+ err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
snd_pcm_hw_rule_muldivk, (void*) 8,
SNDRV_PCM_HW_PARAM_BUFFER_SIZE, SNDRV_PCM_HW_PARAM_FRAME_BITS, -1);
if (err < 0)
return err;
- err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_TIME,
+ err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_TIME,
snd_pcm_hw_rule_mulkdiv, (void*) 1000000,
SNDRV_PCM_HW_PARAM_PERIOD_SIZE, SNDRV_PCM_HW_PARAM_RATE, -1);
if (err < 0)
return err;
- err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_TIME,
+ err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_TIME,
snd_pcm_hw_rule_mulkdiv, (void*) 1000000,
SNDRV_PCM_HW_PARAM_BUFFER_SIZE, SNDRV_PCM_HW_PARAM_RATE, -1);
if (err < 0)
if (err < 0)
return err;
- err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
+ err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
snd_pcm_hw_rule_buffer_bytes_max, substream,
SNDRV_PCM_HW_PARAM_BUFFER_BYTES, -1);
if (err < 0)
}
if (!(hw->rates & (SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_CONTINUOUS))) {
- err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
+ err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
snd_pcm_hw_rule_rate, hw,
SNDRV_PCM_HW_PARAM_RATE, -1);
if (err < 0)
snd_pcm_stream_unlock_irq(substream);
return err;
}
-
+
static int snd_pcm_delay(struct snd_pcm_substream *substream,
snd_pcm_sframes_t __user *res)
{
err = -EFAULT;
return err;
}
-
+
static int snd_pcm_sync_ptr(struct snd_pcm_substream *substream,
struct snd_pcm_sync_ptr __user *_sync_ptr)
{
if (get_user(sync_ptr.flags, (unsigned __user *)&(_sync_ptr->flags)))
return -EFAULT;
if (copy_from_user(&sync_ptr.c.control, &(_sync_ptr->c.control), sizeof(struct snd_pcm_mmap_control)))
- return -EFAULT;
+ return -EFAULT;
status = runtime->status;
control = runtime->control;
if (sync_ptr.flags & SNDRV_PCM_SYNC_PTR_HWSYNC) {
{
struct snd_pcm_runtime *runtime = substream->runtime;
int arg;
-
+
if (get_user(arg, _arg))
return -EFAULT;
if (arg < 0 || arg > SNDRV_PCM_TSTAMP_TYPE_LAST)
runtime->tstamp_type = SNDRV_PCM_TSTAMP_TYPE_MONOTONIC;
return 0;
}
-
+
static int snd_pcm_common_ioctl1(struct file *file,
struct snd_pcm_substream *substream,
unsigned int cmd, void __user *arg)
{
mm_segment_t fs;
int result;
-
+
fs = snd_enter_user();
switch (substream->stream) {
case SNDRV_PCM_STREAM_PLAYBACK:
{
struct snd_pcm_substream *substream = area->vm_private_data;
struct snd_pcm_runtime *runtime;
-
+
if (substream == NULL)
return VM_FAULT_SIGBUS;
runtime = substream->runtime;
{
struct snd_pcm_substream *substream = area->vm_private_data;
struct snd_pcm_runtime *runtime;
-
+
if (substream == NULL)
return VM_FAULT_SIGBUS;
runtime = substream->runtime;
unsigned long offset;
struct page * page;
size_t dma_bytes;
-
+
if (substream == NULL)
return VM_FAULT_SIGBUS;
runtime = substream->runtime;
static int snd_pcm_mmap(struct file *file, struct vm_area_struct *area)
{
struct snd_pcm_file * pcm_file;
- struct snd_pcm_substream *substream;
+ struct snd_pcm_substream *substream;
unsigned long offset;
-
+
pcm_file = file->private_data;
substream = pcm_file->substream;
if (PCM_RUNTIME_CHECK(substream))
return result;
}
- /*
+ /*
* allocate the devices -- we can't have them static, as the number
* can be specified at load time
*/
#if LINUX_VERSION_CODE == KERNEL_VERSION(2, 6, 18)
-#define CENTOS_5
+#define CENTOS_5
#define WANT_HRTIMER /* undef this only if you don't want to use High Resolution Timers (why?) */
#endif /* CentOS 5.x */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24)
-#define WANT_HRTIMER
+#define WANT_HRTIMER
#endif /* HRTIMER */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0)
-#define WANT_DEFINE_SPINLOCK
+#define WANT_DEFINE_SPINLOCK
#endif /* DEFINE_SPINLOCK */
#define SKYPOPEN_BLK 1920
struct cdev cdev; /* Char device structure */
wait_queue_head_t inq; /* read and write queues */
wait_queue_head_t outq; /* read and write queues */
-#ifndef WANT_HRTIMER
+#ifndef WANT_HRTIMER
struct timer_list timer_inq;
struct timer_list timer_outq;
-#else// WANT_HRTIMER
+#else// WANT_HRTIMER
struct hrtimer timer_inq;
struct hrtimer timer_outq;
-#endif// WANT_HRTIMER
+#endif// WANT_HRTIMER
int timer_inq_started;
int timer_outq_started;
int opened;
#ifdef WIN32
enum {
- SKYPECONTROLAPI_ATTACH_SUCCESS = 0, /* Client is successfully
+ SKYPECONTROLAPI_ATTACH_SUCCESS = 0, /* Client is successfully
attached and API window handle can be found
in wParam parameter */
SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION = 1, /* Skype has acknowledged
connection request and is waiting
for confirmation from the user. */
- /* The client is not yet attached
+ /* The client is not yet attached
* and should wait for SKYPECONTROLAPI_ATTACH_SUCCESS message */
SKYPECONTROLAPI_ATTACH_REFUSED = 2, /* User has explicitly
denied access to client */
at the moment.
For example, this happens when no user
is currently logged in. */
- /* Client should wait for
- * SKYPECONTROLAPI_ATTACH_API_AVAILABLE
+ /* Client should wait for
+ * SKYPECONTROLAPI_ATTACH_API_AVAILABLE
* broadcast before making any further */
/* connection attempts. */
SKYPECONTROLAPI_ATTACH_API_AVAILABLE = 0x8001
}
if (continue_is_broken) {
XFlush(disp);
- skypopen_sleep(20000); //20 msec
+ skypopen_sleep(20000); //20 msec
WARNINGA("continue_is_broken\n", SKYPOPEN_P_LOG);
continue;
}
really need to change this.
-->
<!-- <param name="renegotiate-codec-on-hold" value="true"/> -->
- <!-- Turn on proxy hold when proxy media and proxy mode are disabled
+ <!-- Turn on proxy hold when proxy media and proxy mode are disabled
By default it is not set
- -->
+ -->
<!-- <param name="proxy-hold" value="true"/> -->
<!-- Choose the proxy notify events. Default is not set
switch_core_media_proxy_remote_addr(tech_pvt->session, NULL);
}
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
"3PCC-PROXY nomedia - sending ack, SDP:\n%s\n", tech_pvt->mparams.local_sdp_str);
-
+
if (sofia_use_soa(tech_pvt)) {
nua_ack(tech_pvt->nh,
TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
SOATAG_USER_SDP_STR(tech_pvt->mparams.local_sdp_str),
SOATAG_REUSE_REJECTED(1),
- SOATAG_RTP_SELECT(1),
+ SOATAG_RTP_SELECT(1),
SOATAG_AUDIO_AUX("cn telephone-event"),
TAG_IF(sofia_test_pflag(tech_pvt->profile, PFLAG_DISABLE_100REL), NUTAG_INCLUDE_EXTRA_SDP(1)),
TAG_END());
TAG_IF(tech_pvt->mparams.local_sdp_str, SIPTAG_CONTENT_TYPE_STR("application/sdp")),
TAG_IF(tech_pvt->mparams.local_sdp_str, SIPTAG_PAYLOAD_STR(tech_pvt->mparams.local_sdp_str)),
SOATAG_AUDIO_AUX("cn telephone-event"),
- TAG_END());
+ TAG_END());
}
SIPTAG_CONTACT_STR(tech_pvt->profile->url),
SOATAG_USER_SDP_STR(tech_pvt->mparams.local_sdp_str),
TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
- SOATAG_REUSE_REJECTED(1),
+ SOATAG_REUSE_REJECTED(1),
SOATAG_RTP_SELECT(1),
SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1),
TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
}
}
- if ((tech_pvt->mparams.last_sdp_str && strstr(tech_pvt->mparams.last_sdp_str, "a=setup")) ||
+ if ((tech_pvt->mparams.last_sdp_str && strstr(tech_pvt->mparams.last_sdp_str, "a=setup")) ||
(tech_pvt->mparams.local_sdp_str && strstr(tech_pvt->mparams.local_sdp_str, "a=setup"))) {
session_timeout = 0;
}
switch (msg->message_id) {
case SWITCH_MESSAGE_INDICATE_DEFLECT: {
-
+
char *extra_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_HEADER_PREFIX);
char ref_to[1024] = "";
const char *var;
if (!switch_channel_test_flag(channel, CF_AVPF) && switch_true(switch_core_get_variable("sofia_send_info_vid_refresh"))) {
const char *pl = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<media_control><vc_primitive><to_encoder><picture_fast_update /></to_encoder></vc_primitive></media_control>\n";
switch_time_t now = switch_micro_time_now();
-
+
if (!tech_pvt->last_vid_info || (now - tech_pvt->last_vid_info) > 500000) {
-
+
tech_pvt->last_vid_info = now;
-
+
if (!zstr(msg->string_arg)) {
pl = msg->string_arg;
}
-
+
nua_info(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("application/media_control+xml"), SIPTAG_PAYLOAD_STR(pl), TAG_END());
}
-
+
}
break;
case SWITCH_MESSAGE_INDICATE_BROADCAST:
nua_invite(tech_pvt->nh,
NUTAG_MEDIA_ENABLE(0),
- TAG_IF(msg->string_arg, SIPTAG_CONTENT_TYPE_STR("application/sdp")),
+ TAG_IF(msg->string_arg, SIPTAG_CONTENT_TYPE_STR("application/sdp")),
SIPTAG_PAYLOAD_STR(msg->string_arg),
TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END());
-
+
switch_safe_free(extra_headers);
}
break;
sofia_glue_clear_soa(session, SWITCH_TRUE);
- nua_invite(tech_pvt->nh, NUTAG_MEDIA_ENABLE(0), SIPTAG_PAYLOAD_STR(""),
+ nua_invite(tech_pvt->nh, NUTAG_MEDIA_ENABLE(0), SIPTAG_PAYLOAD_STR(""),
TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END());
switch_safe_free(extra_headers);
switch_core_media_set_sdp_codec_string(tech_pvt->session, r_sdp, SDP_TYPE_RESPONSE);
switch_channel_set_variable(tech_pvt->channel, "absolute_codec_string", switch_channel_get_variable(tech_pvt->channel, "ep_codec_string"));
switch_core_media_prepare_codecs(tech_pvt->session, SWITCH_TRUE);
-
+
if ((status = switch_core_media_choose_port(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO, 0)) != SWITCH_STATUS_SUCCESS) {
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
goto end_lock;
}
-
+
switch_core_media_gen_local_sdp(session, SDP_TYPE_REQUEST, NULL, 0, NULL, 1);
if (!msg->numeric_arg) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR,
"Operation not permitted on an inbound non-answered call leg!\n");
} else {
- full_to = switch_str_nil(switch_channel_get_variable(channel, "sip_full_to"));
+ full_to = switch_str_nil(switch_channel_get_variable(channel, "sip_full_to"));
nua_notify(tech_pvt->nh, NUTAG_NEWSUB(1), NUTAG_SUBSTATE(nua_substate_active),
TAG_IF((full_to), SIPTAG_TO_STR(full_to)),SIPTAG_SUBSCRIPTION_STATE_STR("active"),
SIPTAG_EVENT_STR(event), TAG_END());
}
goto end_lock;
}
-
+
if (code == 302 && !zstr(msg->string_arg)) {
char *p;
stream->write_function(stream, " <ping>%d</ping>\n", gp->ping);
stream->write_function(stream, " <pingfreq>%d</pingfreq>\n", gp->ping_freq);
stream->write_function(stream, " <pingmin>%d</pingmin>\n", gp->ping_min);
- stream->write_function(stream, " <pingcount>%d</pingcount>\n", gp->ping_count);
+ stream->write_function(stream, " <pingcount>%d</pingcount>\n", gp->ping_count);
stream->write_function(stream, " <pingmax>%d</pingmax>\n", gp->ping_max);
stream->write_function(stream, " <pingtime>%0.2f</pingtime>\n", gp->ping_time);
stream->write_function(stream, " <pinging>%d</pinging>\n", gp->pinging);
if (exclude_contact) {
sql = switch_mprintf("select contact, profile_name, '%q' "
"from sip_registrations where profile_name='%q' "
- "and upper(sip_user)=upper('%q') "
+ "and upper(sip_user)=upper('%q') "
"and (sip_host='%q' or presence_hosts like '%%%q%%') "
"and contact not like '%%%q%%'", (concat != NULL) ? concat : "", profile->name, user, domain, domain, exclude_contact);
} else {
go = 1;
}
}
-
+
if (!go) return 0;
-
+
*q++ = '\0';
} else {
return 0;
}
-
+
if (!strncasecmp(q, "sips:", 5)) {
q += 5;
} else if (!strncasecmp(q, "sip:", 4)) {
switch_url_encode(q, qenc, enclen);
mod = 1;
}
-
+
cp->destination_number = switch_core_sprintf(cp->pool, "%s/%s@%s", o, qenc ? qenc : q, e);
return mod;
void write_csta_xml_chunk(switch_event_t *event, switch_stream_handle_t stream, const char *csta_event, char *fwdtype)
{
const char *device = switch_event_get_header(event, "device");
-
+
switch_assert(csta_event);
stream.write_function(&stream, "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<%s xmlns=\"http://www.ecma-international.org/standards/ecma-323/csta/ed3\">\n", csta_event);
switch_event_free_subclass(MY_EVENT_REGISTER);
switch_event_free_subclass(MY_EVENT_GATEWAY_ADD);
switch_event_free_subclass(MY_EVENT_BYE_RESPONSE);
-
+
switch_console_del_complete_func("::sofia::list_profiles");
switch_console_set_complete("del sofia");
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Mathieu Rene <mrene@avgs.ca>
*
* rtp.c -- RTP Controllable Channel Module
switch_channel_t *channel;
switch_codec_t read_codec, write_codec;
switch_frame_t read_frame;
-
-
+
+
switch_rtp_bug_flag_t rtp_bugs;
switch_rtp_t *rtp_session;
-
+
uint32_t timestamp_send;
-
+
const char *local_address;
const char *remote_address;
const char *codec;
int ptime;
-
+
const switch_codec_implementation_t *negotiated_codecs[SWITCH_MAX_CODECS];
int num_negotiated_codecs;
-
+
char *origin;
-
+
switch_port_t local_port;
switch_port_t remote_port;
switch_payload_t agreed_pt; /*XXX*/
static switch_status_t channel_on_destroy(switch_core_session_t *session);
static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event,
switch_caller_profile_t *outbound_profile,
- switch_core_session_t **new_session,
+ switch_core_session_t **new_session,
switch_memory_pool_t **pool,
switch_originate_flag_t flags, switch_call_cause_t *cancel_cause);
static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id);
endpoint_interface->io_routines = &crtp_io_routines;
endpoint_interface->state_handler = &crtp_state_handlers;
crtp.endpoint_interface = endpoint_interface;
-
+
//SWITCH_ADD_API(api_interface, "rtp_test", "test", test_function, "");
}
static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event,
switch_caller_profile_t *outbound_profile,
- switch_core_session_t **new_session,
+ switch_core_session_t **new_session,
switch_memory_pool_t **pool,
switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
{
switch_channel_t *channel;
char name[128];
- crtp_private_t *tech_pvt = NULL;
+ crtp_private_t *tech_pvt = NULL;
switch_caller_profile_t *caller_profile;
switch_rtp_flag_t rtp_flags[SWITCH_RTP_FLAG_INVALID] = {0};
-
+
const char *err;
-
+
const char *local_addr = switch_event_get_header_nil(var_event, kLOCALADDR),
*szlocal_port = switch_event_get_header_nil(var_event, kLOCALPORT),
*remote_addr = switch_event_get_header_nil(var_event, kREMOTEADDR),
//*szrfc2833_pt = switch_event_get_header_nil(var_event, kRFC2833PT),
*szrate = switch_event_get_header_nil(var_event, kRATE),
*szpt = switch_event_get_header_nil(var_event, kPT);
-
-
+
+
switch_port_t local_port = !zstr(szlocal_port) ? (switch_port_t)atoi(szlocal_port) : 0,
remote_port = !zstr(szremote_port) ? (switch_port_t)atoi(szremote_port) : 0;
-
+
int ptime = !zstr(szptime) ? atoi(szptime) : 0,
//rfc2833_pt = !zstr(szrfc2833_pt) ? atoi(szrfc2833_pt) : 0,
rate = !zstr(szrate) ? atoi(szrate) : 8000,
pt = !zstr(szpt) ? atoi(szpt) : 0;
-
+
if (
((zstr(remote_addr) || remote_port == 0) && (zstr(local_addr) || local_port == 0)) ||
zstr(codec) ||
zstr(szpt)) {
-
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing required arguments\n");
goto fail;
}
-
-
+
+
if (!(*new_session = switch_core_session_request(crtp.endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, 0, pool))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't request session.\n");
goto fail;
}
-
+
channel = switch_core_session_get_channel(*new_session);
-
+
tech_pvt = switch_core_session_alloc(*new_session, sizeof *tech_pvt);
tech_pvt->session = *new_session;
tech_pvt->channel = channel;
tech_pvt->ptime = ptime;
tech_pvt->agreed_pt = (switch_payload_t)pt;
tech_pvt->dtmf_type = DTMF_2833; /* XXX */
-
+
if (zstr(local_addr) || local_port == 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "The local address and port must be set\n");
goto fail;
} else {
tech_pvt->mode = RTP_SENDRECV;
}
-
+
switch_core_session_set_private(*new_session, tech_pvt);
-
+
caller_profile = switch_caller_profile_clone(*new_session, outbound_profile);
switch_channel_set_caller_profile(channel, caller_profile);
-
-
+
+
snprintf(name, sizeof(name), "rtp/%s", outbound_profile->destination_number);
switch_channel_set_name(channel, name);
-
+
switch_channel_set_state(channel, CS_INIT);
if (switch_core_codec_init(&tech_pvt->read_codec,
rate,
ptime,
1,
- SWITCH_CODEC_FLAG_ENCODE /*| SWITCH_CODEC_FLAG_DECODE*/,
+ SWITCH_CODEC_FLAG_ENCODE /*| SWITCH_CODEC_FLAG_DECODE*/,
NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
goto fail;
}
}
-
+
if (switch_core_session_set_read_codec(*new_session, &tech_pvt->read_codec) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't set read codec?\n");
goto fail;
}
-
+
if (switch_core_session_set_write_codec(*new_session, &tech_pvt->write_codec) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't set write codec?\n");
goto fail;
}
-
+
if (!(tech_pvt->rtp_session = switch_rtp_new(local_addr, local_port, remote_addr, remote_port, tech_pvt->agreed_pt,
tech_pvt->read_codec.implementation->samples_per_packet, ptime * 1000,
rtp_flags, "soft", &err, switch_core_session_get_pool(*new_session)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't setup RTP session: [%s]\n", err);
goto fail;
}
-
+
if (switch_core_session_thread_launch(*new_session) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't start session thread.\n");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't start session thread.\n");
goto fail;
}
-
+
switch_channel_mark_answered(channel);
-
+
return SWITCH_CAUSE_SUCCESS;
-
+
fail:
if (tech_pvt) {
if (tech_pvt->read_codec.implementation) {
switch_core_codec_destroy(&tech_pvt->read_codec);
}
-
+
if (tech_pvt->write_codec.implementation) {
switch_core_codec_destroy(&tech_pvt->write_codec);
}
}
-
+
if (*new_session) {
switch_core_session_destroy(new_session);
}
static switch_status_t channel_on_init(switch_core_session_t *session)
{
-
+
switch_channel_t *channel = switch_core_session_get_channel(session);
-
+
switch_channel_set_state(channel, CS_CONSUME_MEDIA);
-
+
return SWITCH_STATUS_FALSE;
}
static switch_status_t channel_on_destroy(switch_core_session_t *session)
{
crtp_private_t *tech_pvt = NULL;
-
+
if ((tech_pvt = switch_core_session_get_private(session))) {
-
+
if (tech_pvt->read_codec.implementation) {
switch_core_codec_destroy(&tech_pvt->read_codec);
}
-
+
if (tech_pvt->write_codec.implementation) {
switch_core_codec_destroy(&tech_pvt->write_codec);
}
}
-
+
return SWITCH_STATUS_SUCCESS;
}
crtp_private_t *tech_pvt;
switch_channel_t *channel;
switch_status_t status;
-
+
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
-
+
tech_pvt = switch_core_session_get_private(session);
assert(tech_pvt != NULL);
-
+
if (!tech_pvt->rtp_session || tech_pvt->mode == RTP_SENDONLY) {
switch_yield(20000); /* replace by local timer XXX */
goto cng;
}
-
+
if (switch_rtp_has_dtmf(tech_pvt->rtp_session)) {
switch_dtmf_t dtmf = { 0 };
switch_rtp_dequeue_dtmf(tech_pvt->rtp_session, &dtmf);
switch_channel_queue_dtmf(channel, &dtmf);
}
-
+
tech_pvt->read_frame.flags = SFF_NONE;
tech_pvt->read_frame.codec = &tech_pvt->read_codec;
status = switch_rtp_zerocopy_read_frame(tech_pvt->rtp_session, &tech_pvt->read_frame, flags);
if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
goto cng;
}
-
+
*frame = &tech_pvt->read_frame;
return SWITCH_STATUS_SUCCESS;
-
+
cng:
*frame = &tech_pvt->read_frame;
tech_pvt->read_frame.codec = &tech_pvt->read_codec;
tech_pvt->read_frame.flags |= SFF_CNG;
tech_pvt->read_frame.datalen = 0;
-
+
return SWITCH_STATUS_SUCCESS;
}
crtp_private_t *tech_pvt;
switch_channel_t *channel;
//int frames = 0, bytes = 0, samples = 0;
-
+
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
-
+
tech_pvt = switch_core_session_get_private(session);
assert(tech_pvt != NULL);
-
-
+
+
#if 0
if (!switch_test_flag(frame, SFF_CNG) && !switch_test_flag(frame, SFF_PROXY_PACKET)) {
if (tech_pvt->read_codec.implementation->encoded_bytes_per_packet) {
frames = ((int) frame->datalen / bytes);
} else
frames = 1;
-
+
samples = frames * tech_pvt->read_codec.implementation->samples_per_packet;
}
-
+
tech_pvt->timestamp_send += samples;
#endif
if (tech_pvt->mode == RTP_RECVONLY) {
static switch_status_t channel_send_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf)
{
crtp_private_t *tech_pvt = NULL;
-
+
tech_pvt = switch_core_session_get_private(session);
assert(tech_pvt != NULL);
-
+
switch(tech_pvt->dtmf_type) {
case DTMF_2833:
{
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Discarding DTMF %c of length %d, DTMF type is NONE\n", dtmf->digit, dtmf->duration);
}
}
-
+
return SWITCH_STATUS_SUCCESS;
}
if (zstr(chan_val) || zstr(event_val)) {
return 1;
- }
+ }
return strcasecmp(chan_val, event_val);
}
switch_channel_set_variable(channel, kREMOTEADDR, remote_addr);
switch_channel_set_variable(channel, kREMOTEPORT, szremote_port);
-
+
if (switch_rtp_set_remote_address(tech_pvt->rtp_session, remote_addr, remote_port, 0, SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error setting RTP remote address: %s\n", err);
} else {
tech_pvt->mode = RTP_SENDRECV;
}
}
-
+
if (compare_var(event, channel, kCODEC) ||
compare_var(event, channel, kPTIME) ||
compare_var(event, channel, kPT) ||
rate,
ptime,
1,
- SWITCH_CODEC_FLAG_ENCODE /*| SWITCH_CODEC_FLAG_DECODE*/,
+ SWITCH_CODEC_FLAG_ENCODE /*| SWITCH_CODEC_FLAG_DECODE*/,
NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
goto fail;
switch_rtp_set_default_payload(tech_pvt->rtp_session, (switch_payload_t)pt);
//switch_rtp_set_recv_pt(tech_pvt->rtp_session, pt);
}
-
+
if (compare_var(event, channel, kRFC2833PT)) {
const char *szpt = switch_channel_get_variable(channel, kRFC2833PT);
int pt = !zstr(szpt) ? atoi(szpt) : 0;
-
+
switch_channel_set_variable(channel, kRFC2833PT, szpt);
switch_rtp_set_telephony_event(tech_pvt->rtp_session, (switch_payload_t)pt);
}
-
+
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Received unknown command [%s] in event.\n", !command ? "null" : command);
}
if (tech_pvt->read_codec.implementation) {
switch_core_codec_destroy(&tech_pvt->read_codec);
}
-
+
if (tech_pvt->write_codec.implementation) {
switch_core_codec_destroy(&tech_pvt->write_codec);
}
static switch_status_t channel_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg)
{
crtp_private_t *tech_pvt = NULL;
-
+
tech_pvt = switch_core_session_get_private(session);
assert(tech_pvt != NULL);
-
+
switch (msg->message_id) {
case SWITCH_MESSAGE_INDICATE_DEBUG_MEDIA:
{
if (switch_rtp_ready(tech_pvt->rtp_session) && !zstr(msg->string_array_arg[0]) && !zstr(msg->string_array_arg[1])) {
switch_rtp_flag_t flags[SWITCH_RTP_FLAG_INVALID] = {0};
int x = 0;
-
+
if (!strcasecmp(msg->string_array_arg[0], "read")) {
flags[SWITCH_RTP_FLAG_DEBUG_RTP_READ]++;x++;
} else if (!strcasecmp(msg->string_array_arg[0], "write")) {
flags[SWITCH_RTP_FLAG_DEBUG_RTP_READ]++;x++;
flags[SWITCH_RTP_FLAG_DEBUG_RTP_WRITE]++;
}
-
+
if (x) {
if (switch_true(msg->string_array_arg[1])) {
switch_rtp_set_flags(tech_pvt->rtp_session, flags);
{
if (switch_rtp_ready(tech_pvt->rtp_session)) {
int len = 0, maxlen = 0, qlen = 0, maxqlen = 50;
-
+
if (msg->string_arg) {
char *p;
const char *s;
-
+
if (!strcasecmp(msg->string_arg, "pause")) {
switch_rtp_pause_jitter_buffer(tech_pvt->rtp_session, SWITCH_TRUE);
goto end;
switch_rtp_debug_jitter_buffer(tech_pvt->rtp_session, s);
goto end;
}
-
-
+
+
if ((len = atoi(msg->string_arg))) {
qlen = len / (tech_pvt->read_codec.implementation->microseconds_per_packet / 1000);
if (qlen < 1) {
qlen = 3;
}
}
-
+
if (qlen) {
if ((p = strchr(msg->string_arg, ':'))) {
p++;
maxlen = atol(p);
}
}
-
-
+
+
if (maxlen) {
maxqlen = maxlen / (tech_pvt->read_codec.implementation->microseconds_per_packet / 1000);
}
}
-
+
if (qlen) {
if (maxqlen < qlen) {
maxqlen = qlen * 5;
}
if (switch_rtp_activate_jitter_buffer(tech_pvt->rtp_session, qlen, maxqlen,
- tech_pvt->read_codec.implementation->samples_per_packet,
+ tech_pvt->read_codec.implementation->samples_per_packet,
tech_pvt->read_codec.implementation->samples_per_second) == SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session),
- SWITCH_LOG_DEBUG, "Setting Jitterbuffer to %dms (%d frames) (%d max frames)\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session),
+ SWITCH_LOG_DEBUG, "Setting Jitterbuffer to %dms (%d frames) (%d max frames)\n",
len, qlen, maxqlen);
switch_channel_set_flag(tech_pvt->channel, CF_JITTERBUFFER);
if (!switch_false(switch_channel_get_variable(tech_pvt->channel, "rtp_jitter_buffer_plc"))) {
switch_channel_set_flag(tech_pvt->channel, CF_JITTERBUFFER_PLC);
}
} else {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session),
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session),
SWITCH_LOG_WARNING, "Error Setting Jitterbuffer to %dms (%d frames)\n", len, qlen);
}
-
+
} else {
switch_rtp_deactivate_jitter_buffer(tech_pvt->rtp_session);
}
if (argc < 2 || argc == (DIG_MAX_ARGS + 1)) {
usage(1);
}
-
+
if (!strcasecmp(argv[i], "xml")) {
switch_event_add_header_string(stream->param_event, SWITCH_STACK_BOTTOM, "xml", "true");
i++;
if (!dig->sres) {
usage(1);
}
-
+
for (; i <= argc && (string = argv[i]); i++) {
if (multiple)
stream->write_function(stream, "%s", string);
if (!srv || srv[strlen(srv) - 1] != '.') {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s: invalid transport specifier \"%s\"\n"
-
+
"\tspecifier should have name/service/srv-id\n"
"\twhere name is protocol name (e.g, \"tls-udp\")\n"
"\t service specifies service as per RFC 2915 (e.g., \"SIPS+D2U\")\n"
- "\t srv-id is prefix for SRV lookup (e.g., \"_sips._udp.\")\n%s",
- name,
+ "\t srv-id is prefix for SRV lookup (e.g., \"_sips._udp.\")\n%s",
+ name,
tport,
srv ? "\t and it should end with a dot \".\"\n" : "");
port = transport_is_secure(tport) ? "5061" : "5060";
if (xml) {
- stream->write_function(stream,
+ stream->write_function(stream,
" <route>\n"
" <preference>%u</preference>\n"
" <weight>%.3f</weight>\n"
{
private_object_t *tech_pvt = switch_core_session_get_private(session);
switch_core_session_t *other_session;
-
+
if (tech_pvt->proxy_refer_uuid && (other_session = switch_core_session_locate(tech_pvt->proxy_refer_uuid))) {
switch_core_session_message_t *msg;
-
+
msg = switch_core_session_alloc(other_session, sizeof(*msg));
msg->message_id = SWITCH_MESSAGE_INDICATE_RESPOND;
msg->from = __FILE__;
tech_pvt->proxy_refer_uuid = NULL;
}
-
+
if (status == 481 && sip && !sip->sip_retry_after && sip->sip_call_id && (!sofia_private || !sofia_private->is_call)) {
char *sql;
static switch_status_t sofia_pass_notify(switch_core_session_t *session, const char *uuid, const char *payload)
{
switch_core_session_t *other_session;
-
+
if ((other_session = switch_core_session_locate(uuid))) {
switch_core_session_message_t *msg;
-
+
msg = switch_core_session_alloc(other_session, sizeof(*msg));
MESSAGE_STAMP_FFL(msg);
msg->message_id = SWITCH_MESSAGE_INDICATE_BLIND_TRANSFER_RESPONSE;
}
goto error;
}
-
+
if (!(gateway = sofia_reg_find_gateway(sofia_private->gateway_name))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Gateway information missing\n");
if (nsession) {
const char *vval;
switch_channel_t *nchannel = switch_core_session_get_channel(nsession);
-
+
if (!(vval = switch_channel_get_variable(nchannel, "sip_copy_custom_headers")) || switch_true(vval)) {
switch_ivr_transfer_variable(session, nsession, SOFIA_SIP_BYE_HEADER_PREFIX_T);
}
if (status < 200) {
return;
}
-
+
if (tech_pvt->proxy_refer_uuid && (other_session = switch_core_session_locate(tech_pvt->proxy_refer_uuid))) {
switch_core_session_message_t *msg;
if (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MEDIA) && r_sdp) {
if (sofia_test_pflag(tech_pvt->profile, PFLAG_3PCC_PROXY)) {
switch_channel_set_variable_partner(tech_pvt->channel, SWITCH_B_SDP_VARIABLE, r_sdp);
-
+
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "3PCC-PROXY, Got my ACK\n");
sofia_media_activate_rtp(tech_pvt);
switch_core_media_proxy_remote_addr(tech_pvt->session, r_sdp);
sofia_clear_flag(tech_pvt, TFLAG_PASS_ACK);
}
-
+
}
-
-
+
+
if (sofia_test_flag(tech_pvt, TFLAG_PASS_ACK)) {
switch_core_session_t *other_session;
}
- if ((refer_to = sip_header_as_string(nua_handle_home(nh), (void *) sip->sip_refer_to))) {
+ if ((refer_to = sip_header_as_string(nua_handle_home(nh), (void *) sip->sip_refer_to))) {
if ((iparams = strchr(refer_to, ';'))) {
*iparams++ = '\0';
to_user = "n/a";
to_host = "n/a";
}
-
+
while (ap) {
switch_snprintf(accept_header + strlen(accept_header), sizeof(accept_header) - strlen(accept_header),
"%s%s ", ap->ac_type, ap->ac_next ? "," : "");
switch_event_fire(&event);
}
-
+
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_UNREGISTER) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "profile-name", profile->name);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from-user", sofia_private->user);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "reason", "socket-disconnection");
switch_event_fire(&event);
}
-
+
sofia_reg_check_socket(profile, sofia_private->call_id, sofia_private->network_ip, sofia_private->network_port);
nua_handle_destroy(nh);
case nua_i_notify:
case nua_i_info:
-
+
if (event == nua_i_invite) {
if (sip->sip_session_expires && profile->minimum_session_expires) {
if (sip->sip_session_expires->x_delta < profile->minimum_session_expires) {
sofia_reg_check_expire(profile, now, 0);
ireg_loops = 0;
}
-
+
if(++iping_loops >= (uint32_t)profile->iping_freq) {
time_t now = switch_epoch_time_now(NULL);
sofia_reg_check_ping_expire(profile, now, profile->iping_seconds);
}
if (switch_queue_pop_timeout(mod_sofia_globals.general_event_queue, &pop, 100000) == SWITCH_STATUS_SUCCESS) {
-
+
do {
switch_event_t *event = (switch_event_t *) pop;
general_event_handler(event);
ping_min = atoi(val);
} else if (!strcmp(var, "ping-user-agent")) {
options_user_agent = val;
- } else if (!strcmp(var, "ping-monitoring")) { // if true then every gw ping result will fire a gateway status event
+ } else if (!strcmp(var, "ping-monitoring")) { // if true then every gw ping result will fire a gateway status event
ping_monitoring = switch_true(val);
} else if (!strcmp(var, "proxy")) {
proxy = val;
int found = 1; // Used to break up long if/elseif chain (MSVC2015 fails (parser stack overflow) otherwise)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s [%s]\n", var, val);
-
+
if (!strcasecmp(var, "debug") && val) {
profile->debug = atoi(val);
} else if (!strcasecmp(var, "parse-invite-tel-params")) {
found = 0;
}
if (found) continue;
-
+
if (!strcasecmp(var, "multiple-registrations")) {
if (val && !strcasecmp(val, "call-id")) {
sofia_set_pflag(profile, PFLAG_MULTIREG);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Setting nonce TTL to 60 seconds\n");
profile->nonce_ttl = 60;
}
-
+
if (!profile->max_auth_validity) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Setting MAX Auth Validity to 0 Attempts\n");
profile->max_auth_validity = 0;
gateway->uptime = switch_time_now();
do_fire_gateway_state_event = SWITCH_TRUE;
}
-
+
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
"Ping succeeded %s with code %d - count %d/%d/%d, state %s\n",
gateway->name, status, gateway->ping_min, gateway->ping_count, gateway->ping_max, sofia_gateway_status_name(gateway->status));
}
if (gateway->ping_sent) {
gateway->ping_time = (float)(switch_time_now() - gateway->ping_sent) / 1000;
- gateway->ping_sent = 0;
+ gateway->ping_sent = 0;
}
} else {
if (gateway->state == REG_STATE_REGED) {
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Passing %d %s to other leg\n%s\n", status, phrase, switch_str_nil(r_sdp));
-
+
if (switch_core_session_compare(session, other_session)) {
private_object_t *other_tech_pvt = switch_core_session_get_private(other_session);
sofia_set_flag(other_tech_pvt, TFLAG_PASS_ACK);
} else if (status > 299) {
switch_core_media_reset_t38(session);
switch_core_media_reset_t38(other_session);
- } else if (status == 200 && switch_channel_test_flag(channel, CF_T38_PASSTHRU) &&
+ } else if (status == 200 && switch_channel_test_flag(channel, CF_T38_PASSTHRU) &&
has_t38 && sip->sip_payload && sip->sip_payload->pl_data) {
switch_t38_options_t *t38_options = switch_core_media_extract_t38_options(session, sip->sip_payload->pl_data);
tech_pvt->mparams.last_sdp_str = NULL;
tech_pvt->mparams.last_sdp_response = NULL;
-
+
if (r_sdp && (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA))) {
const char *var;
-
+
if ((var = switch_channel_get_variable(channel, "bypass_media_sdp_filter"))) {
if ((patched_sdp = switch_core_media_process_sdp_filter(r_sdp, var, session))) {
r_sdp = patched_sdp;
if ((switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA)) ||
(sofia_test_flag(profile, TFLAG_INB_NOMEDIA) || sofia_test_flag(profile, TFLAG_PROXY_MEDIA))) {
-
+
/* This marr in our code brought to you by people who can't read........ */
if (profile->ndlb & SM_NDLB_ALLOW_BAD_IANANAME && r_sdp && (p = (char *) switch_stristr("g729a/8000", r_sdp))) {
p += 4;
if (switch_channel_test_flag(channel, CF_PROXY_MODE) && r_sdp) {
char ibuf[35] = "", pbuf[35] = "";
const char *ptr;
-
+
if ((ptr = switch_stristr("c=IN IP4", r_sdp))) {
int i = 0;
if ((ptr = switch_stristr("m=audio", r_sdp))) {
int i = 0;
-
+
ptr += 7;
while(*ptr == ' ') {
switch_channel_set_variable(channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE, pbuf);
}
-
+
if (switch_channel_test_flag(channel, CF_PROXY_MEDIA) && switch_channel_direction(tech_pvt->channel) == SWITCH_CALL_DIRECTION_INBOUND) {
switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "PROXY MEDIA");
}
}
if (switch_channel_test_flag(channel, CF_3P_NOMEDIA_REQUESTED)) {
-
+
if (switch_channel_test_flag(channel, CF_3P_NOMEDIA_REQUESTED_BLEG)) {
switch_core_session_t *other_session;
-
+
switch_channel_clear_flag(channel, CF_3P_NOMEDIA_REQUESTED_BLEG);
-
+
if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) {
if (switch_core_session_compare(session, other_session)) {
//switch_channel_t *other_channel = switch_core_session_get_channel(other_session);
private_object_t *other_tech_pvt = switch_core_session_get_private(other_session);
sofia_glue_clear_soa(other_session, SWITCH_TRUE);
-
+
if (sofia_use_soa(other_tech_pvt)) {
nua_ack(other_tech_pvt->nh,
TAG_IF(!zstr(other_tech_pvt->user_via), SIPTAG_VIA_STR(other_tech_pvt->user_via)),
SIPTAG_CONTACT_STR(other_tech_pvt->reply_contact),
SOATAG_USER_SDP_STR(r_sdp),
SOATAG_REUSE_REJECTED(1),
- SOATAG_RTP_SELECT(1),
+ SOATAG_RTP_SELECT(1),
SOATAG_AUDIO_AUX("cn telephone-event"),
TAG_IF(sofia_test_pflag(other_tech_pvt->profile, PFLAG_DISABLE_100REL), NUTAG_INCLUDE_EXTRA_SDP(1)),
TAG_END());
TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
TAG_END());
-
+
}
switch_core_session_rwunlock(other_session);
}
} else {
switch_channel_set_variable(channel, SWITCH_R_SDP_VARIABLE, r_sdp);
}
-
+
switch_channel_clear_flag(channel, CF_3P_NOMEDIA_REQUESTED);
goto done;
} else if (switch_channel_test_flag(channel, CF_3P_MEDIA_REQUESTED)) {
uint8_t match = 0;
-
+
switch_channel_clear_flag(channel, CF_PROXY_MODE);
-
+
switch_core_media_choose_port(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO, 0);
switch_core_media_prepare_codecs(tech_pvt->session, SWITCH_FALSE);
switch_core_media_gen_local_sdp(session, SDP_TYPE_RESPONSE, NULL, 0, NULL, 0);
switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "RECEIVED");
sofia_set_flag_locked(tech_pvt, TFLAG_READY);
-
+
sofia_set_flag(tech_pvt, TFLAG_SDP);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "RESTABLISH MEDIA SDP:\n%s\n", tech_pvt->mparams.local_sdp_str);
SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
SOATAG_USER_SDP_STR(tech_pvt->mparams.local_sdp_str),
SOATAG_REUSE_REJECTED(1),
- SOATAG_RTP_SELECT(1),
+ SOATAG_RTP_SELECT(1),
SOATAG_AUDIO_AUX("cn telephone-event"),
TAG_IF(sofia_test_pflag(tech_pvt->profile, PFLAG_DISABLE_100REL), NUTAG_INCLUDE_EXTRA_SDP(1)),
TAG_END());
SOATAG_AUDIO_AUX("cn telephone-event"),
TAG_END());
}
-
+
switch_channel_clear_flag(channel, CF_3P_MEDIA_REQUESTED);
goto done;
}
goto done;
}
}
-
+
if (r_sdp && !sofia_test_flag(tech_pvt, TFLAG_SDP)) {
if (switch_channel_test_flag(channel, CF_PROXY_MODE)) {
}
goto done;
-
+
} else {
ss_state = nua_callstate_completed;
goto state_process;
goto done;
}
-
+
if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) {
switch_core_session_message_t *msg;
private_object_t *other_tech_pvt;
switch_core_media_clear_rtp_flag(other_session, SWITCH_MEDIA_TYPE_AUDIO, SWITCH_RTP_FLAG_AUTOADJ);
-
- if (switch_channel_test_flag(channel, CF_PROXY_MODE) && !is_t38 &&
+
+ if (switch_channel_test_flag(channel, CF_PROXY_MODE) && !is_t38 &&
((profile->media_options & MEDIA_OPT_MEDIA_ON_HOLD) || media_on_hold)) {
if (switch_stristr("sendonly", r_sdp) || switch_stristr("0.0.0.0", r_sdp) || switch_stristr("inactive", r_sdp)) {
tech_pvt->mparams.hold_laps = 1;
//if (switch_channel_direction(tech_pvt->channel) == SWITCH_CALL_DIRECTION_INBOUND) {
//const char *r_sdp = switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE);
-
+
switch_core_media_prepare_codecs(tech_pvt->session, SWITCH_TRUE);
if (sofia_media_tech_media(tech_pvt, r_sdp) != SWITCH_STATUS_SUCCESS) {
switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "CODEC NEGOTIATION ERROR");
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
}
goto done;
- } else {
+ } else {
int hold_related = 0;
if (sofia_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
} else if (switch_stristr("sendonly", r_sdp) || switch_stristr("0.0.0.0", r_sdp) || switch_stristr("inactive", r_sdp)) {
hold_related = 1;
}
-
+
if (!is_t38 && hold_related && switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) {
if (switch_core_session_compare(session, other_session)) {
switch_core_session_message_t *msg;
switch_core_session_rwunlock(other_session);
goto done;
}
-
+
msg = switch_core_session_alloc(other_session, sizeof(*msg));
-
+
if (switch_stristr("inactive", r_sdp)) {
sofia_set_flag_locked(other_tech_pvt, TFLAG_SIP_HOLD_INACTIVE);
//switch_channel_set_variable(channel, "sofia_hold_inactive", "true");
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Indicating %s to other leg.\n%s\n", hold_msg, r_sdp);
switch_core_session_queue_message(other_session, msg);
-
-
-
+
+
+
switch_core_media_gen_local_sdp(session, SDP_TYPE_RESPONSE, NULL, 0, NULL, 0);
if (sofia_use_soa(tech_pvt)){
nua_respond(tech_pvt->nh, SIP_200_OK,
}
switch_core_session_rwunlock(other_session);
goto done;
- }
+ }
}
switch_core_session_rwunlock(other_session);
}
}
-
+
if (is_ok) {
if (switch_core_session_local_crypto_key(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO)) {
SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
SIPTAG_CONTENT_TYPE_STR("application/sdp"), SIPTAG_PAYLOAD_STR(tech_pvt->mparams.local_sdp_str), TAG_END());
}
-
+
if (switch_event_create_subclass(&s_event, SWITCH_EVENT_CUSTOM, MY_EVENT_REINVITE) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "Unique-ID", switch_core_session_get_uuid(session));
switch_event_fire(&s_event);
if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) {
other_channel = switch_core_session_get_channel(other_session);
switch_channel_pass_sdp(channel, other_channel, r_sdp);
-
+
if (sofia_test_flag(tech_pvt, TFLAG_3PCC) && sofia_test_pflag(profile, PFLAG_3PCC_PROXY)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "3PCC-PROXY, Got my ACK\n");
sofia_set_flag(tech_pvt, TFLAG_3PCC_HAS_ACK);
if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) {
other_channel = switch_core_session_get_channel(other_session);
switch_channel_pass_sdp(channel, other_channel, r_sdp);
-
+
//switch_channel_answer(other_channel);
switch_core_session_queue_indication(other_session, SWITCH_MESSAGE_INDICATE_ANSWER);
} else {
uint8_t match = 0;
-
+
match = sofia_media_negotiate_sdp(session, r_sdp, SDP_TYPE_RESPONSE);
-
+
sofia_set_flag_locked(tech_pvt, TFLAG_ANS);
goto done;
}
}
-
+
switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "NO CODECS");
switch_channel_hangup(channel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION);
}
{
switch_core_session_t *other_session;
private_object_t *tech_pvt = switch_core_session_get_private(session);
-
+
if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) {
switch_core_session_message_t *msg;
-
+
tech_pvt->proxy_refer_uuid = switch_core_session_strdup(session, switch_core_session_get_uuid(other_session));
msg = switch_core_session_alloc(other_session, sizeof(*msg));
MESSAGE_STAMP_FFL(msg);
SIPTAG_SUBSCRIPTION_STATE_STR("terminated;reason=noresource"),
SIPTAG_PAYLOAD_STR("SIP/2.0 200 OK\r\n"), SIPTAG_EVENT_STR(etmp), TAG_END());
}
-
+
if (refer_to->r_url->url_params) {
switch_channel_set_variable(b_channel, "sip_h_X-FS-Refer-Params", refer_to->r_url->url_params);
}
}
other_tech_pvt = (private_object_t *) switch_core_session_get_private(other_session);
-
+
if (sip->sip_content_type->c_type && sip->sip_content_type->c_subtype) {
ct = sip->sip_content_type->c_type;
}
-
+
nua_message(other_tech_pvt->nh,
TAG_IF(ct, SIPTAG_CONTENT_TYPE_STR(su_strdup(other_tech_pvt->nh->nh_home, ct))),
TAG_IF(!zstr(other_tech_pvt->user_via), SIPTAG_VIA_STR(other_tech_pvt->user_via)),
const char *ct = NULL;
char *pl = NULL;
switch_channel_t *channel = switch_core_session_get_channel(session);
-
+
if (sip && sip->sip_payload && sip->sip_payload->pl_data) {
pl = sip->sip_payload->pl_data;
}
other_tech_pvt = (private_object_t *) switch_core_session_get_private(other_session);
-
+
if (sip->sip_content_type->c_type && sip->sip_content_type->c_subtype) {
ct = sip->sip_content_type->c_type;
}
uparams = NULL;
}
-
+
if (uparams) {
if (switch_stristr("transport=tcp", uparams)) {
is_tcp = 1;
}
- if (sofia_test_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION) ||
- (sofia_test_pflag(profile, PFLAG_TLS_ALWAYS_NAT) && (is_tcp || is_tls)) ||
- (!is_tcp && !is_tls && (zstr(network_ip) || !switch_check_network_list_ip(network_ip, profile->local_network)) &&
- profile->server_rport_level >= 2 && sip->sip_user_agent &&
- sip->sip_user_agent->g_string &&
+ if (sofia_test_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION) ||
+ (sofia_test_pflag(profile, PFLAG_TLS_ALWAYS_NAT) && (is_tcp || is_tls)) ||
+ (!is_tcp && !is_tls && (zstr(network_ip) || !switch_check_network_list_ip(network_ip, profile->local_network)) &&
+ profile->server_rport_level >= 2 && sip->sip_user_agent &&
+ sip->sip_user_agent->g_string &&
(!strncasecmp(sip->sip_user_agent->g_string, "Polycom", 7) || !strncasecmp(sip->sip_user_agent->g_string, "KIRK Wireless Server", 20)))
) {
if (sip && sip->sip_via) {
char *var_name = NULL;
var_name = switch_mprintf("sip_invite_%s", argv1[x1]);
switch_channel_set_variable(channel, var_name, "true");
- switch_safe_free( var_name );
+ switch_safe_free( var_name );
}
}
}
if (bcp->originatee_caller_profile) {
switch_caller_profile_t *cp;
- cp = switch_caller_profile_dup(tech_pvt->caller_profile->pool,
+ cp = switch_caller_profile_dup(tech_pvt->caller_profile->pool,
bcp->originatee_caller_profile);
switch_channel_set_originatee_caller_profile(tech_pvt->channel, cp);
switch_channel_event_set_data(b_channel, event);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "att_xfer_replaced_by", sip->sip_call_id->i_id);
switch_event_fire(&event);
- }
+ }
switch_channel_hangup(b_channel, SWITCH_CAUSE_ATTENDED_TRANSFER);
}
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Ken Rice <krice@freeswitch.org>
* Paul D. Tinsley <pdt at jackhammer.org>
{
switch_assert(network_ip);
- return (profile->extsipip &&
- !switch_check_network_list_ip(network_ip, "loopback.auto") &&
+ return (profile->extsipip &&
+ !switch_check_network_list_ip(network_ip, "loopback.auto") &&
!switch_check_network_list_ip(network_ip, profile->local_network));
}
switch_assert(session != NULL);
switch_assert(profile != NULL);
switch_assert(tech_pvt != NULL);
-
+
switch_core_session_add_stream(session, NULL);
switch_mutex_lock(tech_pvt->flag_mutex);
tech_pvt->mparams.cng_pt = tech_pvt->cng_pt;
tech_pvt->mparams.rtp_timeout_sec = profile->rtp_timeout_sec;
tech_pvt->mparams.rtp_hold_timeout_sec = profile->rtp_hold_timeout_sec;
-
+
if (profile->rtp_digit_delay) {
tech_pvt->mparams.dtmf_delay = profile->rtp_digit_delay;
}
new_uri = switch_core_session_sprintf(session, "%s;%s@%s", lhs, invite_tel_params, rhs);
}
}
-
+
return new_uri;
}
for (; hi; hi = hi->next) {
const char *name = (char *) hi->name;
char *value = (char *) hi->value;
-
+
if (!strcasecmp(name, "sip_geolocation")) {
stream.write_function(&stream, "Geolocation: %s\r\n", value);
}
switch_channel_t *channel = switch_core_session_get_channel(session);
char pstr[32];
-
+
if (!sip || !channel) {
return;
}
switch_true(switch_channel_get_variable_dup(tech_pvt->channel, "sofia_hold_inactive", SWITCH_FALSE, -1))) {
hold_char = "#";
}
-
+
if (switch_channel_test_flag(tech_pvt->channel, CF_RECOVERING)) {
const char *recover_contact = switch_channel_get_variable(tech_pvt->channel, "sip_recover_contact");
recover_via = switch_channel_get_variable(tech_pvt->channel, "sip_recover_via");
if (!zstr(invite_record_route)) {
record_route = switch_core_session_sprintf(session, "Record-Route: %s", invite_record_route);
}
-
+
if (recover_contact) {
char *tmp = switch_core_session_strdup(session, recover_contact);
tech_pvt->redirected = sofia_glue_get_url_from_contact(tmp, 0);
const char *from_display = switch_channel_get_variable(tech_pvt->channel, "sip_from_display");
const char *invite_req_uri = switch_channel_get_variable(tech_pvt->channel, "sip_invite_req_uri");
const char *invite_domain = switch_channel_get_variable(tech_pvt->channel, "sip_invite_domain");
-
+
const char *use_name, *use_number;
if (zstr(tech_pvt->dest)) {
}
switch_channel_set_variable(channel, "sip_req_uri", s);
}
-
+
switch_channel_set_variable(channel, "sip_to_host", sofia_glue_get_host(to_str, switch_core_session_get_pool(session)));
switch_channel_set_variable(channel, "sip_from_host", sofia_glue_get_host(from_str, switch_core_session_get_pool(session)));
TAG_IF(!zstr(record_route), SIPTAG_HEADER_STR(record_route)),
SIPTAG_TO_STR(to_str), SIPTAG_FROM_STR(from_str), SIPTAG_CONTACT_STR(invite_contact), TAG_END()))) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT,
"Error creating HANDLE!\nurl_str=[%s]\ncall_id=[%s]\nto_str=[%s]\nfrom_str=[%s]\ninvite_contact=[%s]\n",
url_str,
call_id ? call_id : "N/A",
to_str,
from_str,
invite_contact);
-
+
switch_safe_free(d_url);
return SWITCH_STATUS_FALSE;
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "%s sending invite version: %s\nLocal SDP:\n%s\n",
- switch_channel_get_name(tech_pvt->channel), switch_version_full_human(),
+ switch_channel_get_name(tech_pvt->channel), switch_version_full_human(),
tech_pvt->mparams.local_sdp_str ? tech_pvt->mparams.local_sdp_str : "NO SDP PRESENT\n");
- if ((switch_channel_get_private(tech_pvt->channel, "t38_options")) ||
+ if ((switch_channel_get_private(tech_pvt->channel, "t38_options")) ||
((switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MODE) ||
switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MEDIA) )
&& switch_stristr("m=image", tech_pvt->mparams.local_sdp_str))) {
&& (other_session = switch_core_session_locate(val))) {
other_channel = switch_core_session_get_channel(other_session);
switch_channel_set_variable(other_channel, SWITCH_B_SDP_VARIABLE, sdp);
-
+
#if 0
if (!sofia_test_flag(tech_pvt, TFLAG_CHANGE_MEDIA) && !switch_channel_test_flag(tech_pvt->channel, CF_RECOVERING) &&
(switch_channel_direction(other_channel) == SWITCH_CALL_DIRECTION_OUTBOUND &&
contact = sofia_glue_get_url_from_contact(buf, SWITCH_TRUE);
if (!contact) return NULL;
-
+
if ((p = strstr(contact, "fs_path="))) {
p += 8;
char *url = NULL, *e;
switch_assert(buf);
-
+
while(*buf == ' ') {
buf++;
}
switch_bool_t sofia_glue_profile_exists(const char *key)
{
switch_bool_t tf = SWITCH_FALSE;
-
+
switch_mutex_lock(mod_sofia_globals.hash_mutex);
if (switch_core_hash_find(mod_sofia_globals.profile_hash, key)) {
tf = SWITCH_TRUE;
switch_mutex_lock(mod_sofia_globals.hash_mutex);
for (gp = profile->gateways; gp; gp = gp->next) {
int reged = (gp->status == SOFIA_GATEWAY_UP);
-
+
if (up ? reged : !reged) {
stream->write_function(stream, "%s ", gp->name);
}
for (hi = switch_core_hash_first(mod_sofia_globals.profile_hash); hi; hi = switch_core_hash_next(&hi)) {
switch_core_hash_this(hi, &var, NULL, &val);
if ((pptr = (sofia_profile_t *) val)) {
- nua_set_params(pptr->nua, TPTAG_LOG(on), TAG_END());
+ nua_set_params(pptr->nua, TPTAG_LOG(on), TAG_END());
}
}
}
switch_mutex_unlock(mod_sofia_globals.hash_mutex);
}
-int sofia_recover_callback(switch_core_session_t *session)
+int sofia_recover_callback(switch_core_session_t *session)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
const char *rr;
int r = 0;
const char *profile_name = switch_channel_get_variable_dup(channel, "recovery_profile_name", SWITCH_FALSE, -1);
-
+
if (zstr(profile_name)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Missing profile\n");
int te = atoi(tmp);
if (te > 64) {
tech_pvt->te = (switch_payload_t)te;
- }
+ }
}
if ((tmp = switch_channel_get_variable(tech_pvt->channel, "rtp_2833_recv_payload"))) {
int te = atoi(tmp);
if (te > 64) {
tech_pvt->recv_te = (switch_payload_t)te;
- }
+ }
}
rr = switch_channel_get_variable(channel, "sip_invite_record_route");
if (zstr(rr)) {
switch_channel_set_variable_printf(channel, "sip_invite_route_uri", "<sip:%s@%s:%s;transport=%s>",
switch_channel_get_variable(channel, "sip_from_user"),
- switch_channel_get_variable(channel, "sip_network_ip"),
+ switch_channel_get_variable(channel, "sip_network_ip"),
switch_channel_get_variable(channel, "sip_network_port"),
switch_channel_get_variable(channel,"sip_via_protocol")
);
sofia_glue_attach_private(session, profile, tech_pvt, NULL);
switch_channel_set_name(tech_pvt->channel, switch_channel_get_variable(channel, "channel_name"));
-
+
switch_channel_set_variable(channel, "sip_invite_call_id", switch_channel_get_variable(channel, "sip_call_id"));
if (switch_true(switch_channel_get_variable(channel, "sip_nat_detected"))) {
" expires BIGINT\n"
");\n";
-
+
int x;
char *indexes[] = {
"create index sr_call_id on sip_registrations (call_id)",
"create index ssd_expires on sip_shared_appearance_dialogs (expires)",
NULL
};
-
+
switch_cache_db_handle_t *dbh = sofia_glue_get_db_handle(profile);
char *test2;
char *err;
if (!dbh) {
return 0;
}
-
+
test_sql = switch_mprintf("delete from sip_registrations where sub_host is null "
"and hostname='%q' "
switch_cache_db_test_reactive(dbh, "select ping_expires from sip_registrations", NULL, "alter table sip_registrations add column ping_expires INTEGER not null default 0");
switch_cache_db_test_reactive(dbh, "select ping_time from sip_registrations", NULL, "alter table sip_registrations add column ping_time BIGINT not null default 0");
switch_cache_db_test_reactive(dbh, "select force_ping from sip_registrations", NULL, "alter table sip_registrations add column force_ping INTEGER not null default 0");
-
+
test2 = switch_mprintf("%s;%s", test_sql, test_sql);
-
+
if (switch_cache_db_execute_sql(dbh, test2, &err) != SWITCH_STATUS_SUCCESS) {
if (switch_stristr("read-only", err)) {
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "GREAT SCOTT!!! Cannot execute batched statements! [%s]\n"
"If you are using mysql, make sure you are using MYODBC 3.51.18 or higher and enable FLAG_MULTI_STATEMENTS\n", err);
-
+
switch_cache_db_release_db_handle(&dbh);
free(test2);
free(test_sql);
free(test_sql);
test_sql = switch_mprintf("delete from sip_subscriptions where hostname='%q' and full_to='XXX'", mod_sofia_globals.hostname);
-
+
switch_cache_db_test_reactive(dbh, test_sql, "DROP TABLE sip_subscriptions", sub_sql);
free(test_sql);
switch_cache_db_test_reactive(dbh, test_sql, "DROP TABLE sip_dialogs", dialog_sql);
-
+
free(test_sql);
test_sql = switch_mprintf("delete from sip_presence where hostname='%q' or open_closed=''", mod_sofia_globals.hostname);
mod_sofia_globals.hostname);
switch_cache_db_test_reactive(dbh, test_sql, "DROP TABLE sip_shared_appearance_dialogs", shared_appearance_dialogs_sql);
-
+
free(test_sql);
for (x = 0; indexes[x]; x++) {
char *sql;
switch_assert(sqlp && *sqlp);
- sql = *sqlp;
+ sql = *sqlp;
switch_sql_queue_manager_push(profile->qm, sql, 1, !sql_already_dynamic);
char *sql;
switch_assert(sqlp && *sqlp);
- sql = *sqlp;
+ sql = *sqlp;
switch_mutex_lock(profile->dbh_mutex);
switch_sql_queue_manager_push_confirm(profile->qm, sql, 0, !sql_already_dynamic);
char *sql;
switch_assert(sqlp && *sqlp);
- sql = *sqlp;
+ sql = *sqlp;
switch_sql_queue_manager_push(profile->qm, sql, 0, !sql_already_dynamic);
{
switch_cache_db_handle_t *dbh = NULL;
char *dsn;
-
+
if (!zstr(profile->odbc_dsn)) {
dsn = profile->odbc_dsn;
} else {
if (_switch_cache_db_get_db_handle_dsn(&dbh, dsn, file, func, line) != SWITCH_STATUS_SUCCESS) {
dbh = NULL;
}
-
+
return dbh;
}
if (mutex) {
switch_mutex_unlock(mutex);
}
-
+
return NULL;
}
}
register_host = strdup(s);
-
- /* remove port for register_host for testing nat acl take into account
- ipv6 addresses which are required to have brackets around the addr
+
+ /* remove port for register_host for testing nat acl take into account
+ ipv6 addresses which are required to have brackets around the addr
*/
-
+
if ((p = strchr(register_host, ']'))) {
if (*(p + 1) == ':') {
*(p + 1) = '\0';
*p = '\0';
}
}
-
+
/* register_proxy should always start with "sip:" or "sips:" */
assert(register_host);
user_via = sofia_glue_create_external_via(NULL, profile, transport);
} else {
user_via = sofia_glue_create_external_via(NULL, profile, SOFIA_TRANSPORT_UDP);
- contact_str = profile->public_url;
+ contact_str = profile->public_url;
}
} else {
id = switch_mprintf("sip:%s@%s", user, host);
switch_assert(id);
-
+
if ((ptr = sofia_glue_find_parameter(o_contact, "transport="))) {
sofia_transport_t transport = sofia_glue_str2transport( ptr + 10 );
goto end;
}
- if (switch_channel_test_flag(tech_pvt->channel, CF_BRIDGED) &&
+ if (switch_channel_test_flag(tech_pvt->channel, CF_BRIDGED) &&
(uuid = switch_channel_get_partner_uuid(tech_pvt->channel)) && (other_session = switch_core_session_locate(uuid))) {
other_channel = switch_core_session_get_channel(other_session);
&& strcmp(network_addr_a, switch_str_nil(tech_pvt->profile->extsipip))) {
switch_core_session_message_t *msg;
-
+
switch_log_printf(SWITCH_CHANNEL_ID_LOG, __FILE__, __SWITCH_FUNC__, __LINE__, switch_channel_get_uuid(inbound_channel),
SWITCH_LOG_NOTICE, "Will simplify channel [%s]\n", switch_channel_get_name(inbound_channel));
-
+
msg = switch_core_session_alloc(inbound_session, sizeof(*msg));
MESSAGE_STAMP_FFL(msg);
msg->message_id = SWITCH_MESSAGE_INDICATE_SIMPLIFY;
switch_core_recovery_track(inbound_session);
switch_channel_set_flag(inbound_channel, CF_SIMPLIFY);
-
+
}
}
}
sofia_glue_get_addr(de->data->e_msg, np->network_ip, sizeof(np->network_ip), &np->network_port);
-
+
if (sofia_glue_check_nat(profile, np->network_ip)) {
np->is_auto_nat = 1;
}
if ((tp = switch_stristr("transport=", full_contact_dup))) {
tp += 10;
}
-
+
if (zstr(tp)) {
tp = "udp";
}
switch_zmalloc(path_encoded, path_encoded_len);
switch_copy_string(path_encoded, ";fs_path=", 10);
switch_url_encode(path_val, path_encoded + 9, path_encoded_len - 9);
-
+
contact_str = switch_mprintf("%s <%s;fs_nat=yes%s>", display, full_contact_dup, path_encoded);
free(full_contact_dup);
if (zstr(contact_host)) {
np->is_nat = "No contact host";
}
-
+
if (np->is_nat) {
contact_host = np->network_ip;
switch_snprintf(new_port, sizeof(new_port), ":%d", np->network_port);
port = NULL;
}
-
-
+
+
if (port) {
switch_snprintf(new_port, sizeof(new_port), ":%s", port);
}
-
+
ipv6 = strchr(contact_host, ':');
-
+
if (contact->m_url->url_params) {
contact_str = switch_mprintf("%s <sip:%s%s%s%s%s%s;%s>%s",
ipv6 ? "[" : "", contact_host, ipv6 ? "]" : "", new_port, np->is_nat ? ";fs_nat=yes" : "");
}
}
-
+
return contact_str;
}
if (partner && switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) {
if (switch_core_session_compare(session, other_session)) {
struct private_object *other_tech_pvt = switch_core_session_get_private(other_session);
-
+
sofia_clear_flag(other_tech_pvt, TFLAG_ENABLE_SOA);
}
switch_core_session_rwunlock(other_session);
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
stream->write_function(stream, "--%s\r\nContent-Type: %s\r\nContent-Length: %d\r\n%s\r\n", boundary, dname, strlen(dval), dval + 1);
} else {
stream->write_function(stream, "--%s\r\nContent-Type: %s\r\nContent-Length: %d\r\n\r\n%s\r\n", boundary, dname, strlen(dval) + 1, dval);
- }
+ }
}
}
probe_euser = (p + 1);
}
- if (probe_euser && probe_host &&
+ if (probe_euser && probe_host &&
((profile = sofia_glue_find_profile(probe_host)) || (profile_name && (profile = sofia_glue_find_profile(profile_name))))) {
sql = switch_mprintf("select state,status,rpid,presence_id,uuid from sip_dialogs "
"where hostname='%q' and profile_name='%q' and call_info_state != 'seized' and "
if (!profile && profile_name) {
profile = sofia_glue_find_profile(profile_name);
}
-
+
if (!profile) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot find profile for domain %s\n", probe_host);
goto end;
if (!zstr(remote_ip) && sofia_glue_check_nat(profile, remote_ip)) {
sofia_transport_t transport = sofia_glue_str2transport(tp);
-
+
switch (transport) {
case SOFIA_TRANSPORT_TCP:
contact_str = profile->tcp_public_contact;
break;
}
} else {
- contact_str = profile->public_url;
+ contact_str = profile->public_url;
}
} else {
char *ptr;
prpid = rpid = dialog_rpid;
}
- contact_stripped = sofia_glue_strip_uri(contact_str);
+ contact_stripped = sofia_glue_strip_uri(contact_str);
pl = gen_pidf(user_agent, clean_id, contact_stripped, open, rpid, prpid, status, &ct);
free(contact_stripped);
}
char *contact = contact_str;
sstr = switch_mprintf("active;expires=%ld", exp_delta);
-
+
if (strstr(buf, "fs_path=") && !strstr(contact_str, "fs_path=")) {
char *e = strchr(buf,';');
size_t l = e ? e-buf : strlen(buf);
"set expires=%ld, "
"network_ip='%q',network_port='%d',sip_user='%q',sip_host='%q',full_via='%q',full_to='%q',full_from='%q',contact='%q' "
"where call_id='%q' and profile_name='%q' and hostname='%q'",
- (long) switch_epoch_time_now(NULL) + exp_delta,
+ (long) switch_epoch_time_now(NULL) + exp_delta,
np.network_ip, np.network_port, from_user, from_host, full_via, full_to, full_from, contact,
-
+
call_id, profile->name, mod_sofia_globals.hostname);
if (mod_sofia_globals.debug_presence > 0 || mod_sofia_globals.debug_sla > 0) {
if (!sofia_private) {
nua_handle_destroy(nh);
}
-
+
break;
}
} else {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "type", "text/plain");
}
-
+
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_full", full_from);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "sip_profile", profile->name);
-
+
if (sip->sip_call_info) {
sip_call_info_t *call_info = sip->sip_call_info;
char *ci = sip_header_as_string(nua_handle_home(nh), (void *) call_info);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "sip_call_info", ci);
}
-
+
/* Loop thru unknown Headers Here so we can do something with them */
for (un = sip->sip_unknown; un; un = un->un_next) {
if (!strncasecmp(un->un_name, "Diversion", 9)) {
}
}
}
-
+
if (msg) {
switch_event_add_body(event, "%s", msg);
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Ken Rice, <krice at freeswitch.org> (work sponsored by Comet Signaling LLC, CopperCom, Inc and Asteria Solutions Group, Inc)
* Paul D. Tinsley <pdt at jackhammer.org>
}
static void sofia_reg_new_sub_handle(sofia_gateway_subscription_t *gw_sub_ptr)
-{
+{
sofia_gateway_t *gateway_ptr = gw_sub_ptr->gateway;
char *user_via = NULL;
char *register_host = sofia_glue_get_register_host(gateway_ptr->register_proxy);
int ss_state = nua_callstate_authenticating;
-
-
+
+
/* check for NAT and place a Via header if necessary (hostname or non-local IP) */
if (register_host && sofia_glue_check_nat(gateway_ptr->profile, register_host)) {
user_via = sofia_glue_create_external_via(NULL, gateway_ptr->profile, gateway_ptr->register_transport);
}
-
+
if (gw_sub_ptr->nh) {
nua_handle_bind(gw_sub_ptr->nh, NULL);
nua_handle_destroy(gw_sub_ptr->nh);
gw_sub_ptr->nh = NULL;
sofia_private_free(gw_sub_ptr->sofia_private);
}
-
+
gw_sub_ptr->nh = nua_handle(gateway_ptr->profile->nua, NULL,
- NUTAG_URL(gateway_ptr->register_proxy),
+ NUTAG_URL(gateway_ptr->register_proxy),
TAG_IF(user_via, SIPTAG_VIA_STR(user_via)),
SIPTAG_TO_STR(gateway_ptr->register_to),
NUTAG_CALLSTATE_REF(ss_state), SIPTAG_FROM_STR(gateway_ptr->register_from), TAG_END());
if (!gw_sub_ptr->sofia_private) {
switch_zmalloc(gw_sub_ptr->sofia_private, sizeof(*gw_sub_ptr->sofia_private));
}
-
+
switch_set_string(gw_sub_ptr->sofia_private->gateway_name, gateway_ptr->name);
nua_handle_bind(gw_sub_ptr->nh, gw_sub_ptr->sofia_private);
}
static void sofia_reg_kill_sub(sofia_gateway_subscription_t *gw_sub_ptr)
-{
+{
sofia_gateway_t *gateway_ptr = gw_sub_ptr->gateway;
sofia_private_free(gw_sub_ptr->sofia_private);
if (gw_sub_ptr->nh) {
nua_handle_bind(gw_sub_ptr->nh, NULL);
}
-
+
if (gw_sub_ptr->state != SUB_STATE_SUBED && gw_sub_ptr->state != SUB_STATE_UNSUBSCRIBE) {
if (gw_sub_ptr->nh) {
nua_handle_destroy(gw_sub_ptr->nh);
}
for (gw_sub_ptr = gateway_ptr->subscriptions; gw_sub_ptr; gw_sub_ptr = gw_sub_ptr->next) {
-
+
if (gw_sub_ptr->state == SUB_STATE_SUBED) {
sofia_reg_kill_sub(gw_sub_ptr);
}
case SUB_STATE_UNSUBED:
sofia_reg_new_sub_handle(gw_sub_ptr);
-
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "subscribing to [%s] on gateway [%s]\n", gw_sub_ptr->event, gateway_ptr->name);
-
+
if (now) {
nua_subscribe(gw_sub_ptr->nh,
- NUTAG_URL(gw_sub_ptr->request_uri),
+ NUTAG_URL(gw_sub_ptr->request_uri),
SIPTAG_EVENT_STR(gw_sub_ptr->event),
TAG_IF(strcmp(gw_sub_ptr->content_type, "NO_CONTENT_TYPE"), SIPTAG_ACCEPT_STR(gw_sub_ptr->content_type)),
SIPTAG_TO_STR(gateway_ptr->register_from),
TAG_NULL());
gw_sub_ptr->retry = now + gw_sub_ptr->retry_seconds;
} else {
- nua_unsubscribe(gw_sub_ptr->nh,
+ nua_unsubscribe(gw_sub_ptr->nh,
NUTAG_URL(gw_sub_ptr->request_uri),
SIPTAG_EVENT_STR(gw_sub_ptr->event),
TAG_IF(strcmp(gw_sub_ptr->content_type, "NO_CONTENT_TYPE"), SIPTAG_ACCEPT_STR(gw_sub_ptr->content_type)),
switch_core_hash_delete(mod_sofia_globals.gateway_hash, gateway_ptr->name);
free(pkey);
}
-
+
if (gateway_ptr->state == REG_STATE_NOREG) {
if (last) {
} else {
profile->gateways = gateway_ptr->next;
}
-
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Deleted gateway %s\n", gateway_ptr->name);
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_GATEWAY_DEL) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "profile-name", gateway_ptr->profile->name);
if (delta < 1) {
delta = 1;
}
-
+
gateway_ptr->expires = now + delta;
gateway_ptr->state = REG_STATE_REGED;
case REG_STATE_TIMEOUT:
{
nua_handle_t *nh = gateway_ptr->nh;
-
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Timeout Registering %s\n", gateway_ptr->name);
gateway_ptr->nh = NULL;
dst = sofia_glue_get_destination(argv[3]);
switch_assert(dst);
-
+
nh = nua_handle(profile->nua, NULL, SIPTAG_FROM_STR(profile->url), SIPTAG_TO_STR(to), NUTAG_URL(dst->contact), SIPTAG_CONTACT_STR(profile->url),
SIPTAG_CALL_ID_STR(call_id), TAG_END());
pvt->ping_sent = switch_time_now();
nua_handle_bind(nh, pvt);
- nua_options(nh,
+ nua_options(nh,
NTATAG_SIP_T2(5000),
NTATAG_SIP_T4(10000),
TAG_IF(dst->route_uri, NUTAG_PROXY(dst->route_uri)), TAG_IF(dst->route, SIPTAG_ROUTE_STR(dst->route)), TAG_END());
sql = switch_mprintf("delete from sip_registrations where expires > 0 and hostname='%q'", mod_sofia_globals.hostname);
}
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
-
+
long sofia_reg_uniform_distribution(int max)
{
-/*
+/*
* Generate a random number following a uniform distribution between 0 and max
*/
int result;
"profile_name='%q' and orig_hostname='%q' and "
"ping_expires > 0 and ping_expires <= %ld",
mod_sofia_globals.hostname, profile->name, mod_sofia_globals.hostname, (long) now);
-
+
sofia_glue_execute_sql_callback(profile, profile->dbh_mutex, sql, sofia_reg_nat_callback, profile);
switch_safe_free(sql);
} else if (sofia_test_pflag(profile, PFLAG_UDP_NAT_OPTIONS_PING)) {
" from sip_registrations where (status like '%%UDP-NAT%%' or force_ping=1)"
" and hostname='%q' and profile_name='%q' and ping_expires > 0 and ping_expires <= %ld ",
mod_sofia_globals.hostname, profile->name, (long) now);
-
+
sofia_glue_execute_sql_callback(profile, profile->dbh_mutex, sql, sofia_reg_nat_callback, profile);
switch_safe_free(sql);
} else if (sofia_test_pflag(profile, PFLAG_NAT_OPTIONS_PING)) {
"and profile_name='%q' and orig_hostname='%q' and "
"ping_expires > 0 and ping_expires <= %ld",
mod_sofia_globals.hostname, profile->name, mod_sofia_globals.hostname, (long) now);
-
+
sofia_glue_execute_sql_callback(profile, profile->dbh_mutex, sql, sofia_reg_nat_callback, profile);
switch_safe_free(sql);
} else {
sql = switch_mprintf("delete from sip_authentication where expires > 0 and hostname='%q'", mod_sofia_globals.hostname);
sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
-
+
sql = switch_mprintf("delete from sip_subscriptions where expires >= -1 and hostname='%q'", mod_sofia_globals.hostname);
sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
sofia_glue_execute_sql_callback(profile, profile->dbh_mutex, sql, sofia_reg_find_callback, &cbt);
-
+
switch_safe_free(sql);
return cbt.list;
if (regtype == REG_REGISTER) {
nua_respond(nh, SIP_401_UNAUTHORIZED, TAG_IF(msg, NUTAG_WITH_THIS_MSG(msg)), SIPTAG_WWW_AUTHENTICATE_STR(auth_str), TAG_END());
} else if (regtype == REG_INVITE) {
- nua_respond(nh, SIP_407_PROXY_AUTH_REQUIRED,
- TAG_IF(msg, NUTAG_WITH_THIS_MSG(msg)),
+ nua_respond(nh, SIP_407_PROXY_AUTH_REQUIRED,
+ TAG_IF(msg, NUTAG_WITH_THIS_MSG(msg)),
SIPTAG_PROXY_AUTHENTICATE_STR(auth_str), TAG_END());
}
{
char buf[32] = "";
char *sql;
-
+
sql = switch_mprintf("select count(*) from sip_registrations where profile_name='%q' and "
"sip_user='%q' and (sip_host='%q' or presence_hosts like '%%%q%%')", profile->name, user, host, host);
-
+
sofia_glue_execute_sql2str(profile, profile->dbh_mutex, sql, buf, sizeof(buf));
switch_safe_free(sql);
- return atoi(buf);
+ return atoi(buf);
}
static int debounce_check(sofia_profile_t *profile, const char *user, const char *host)
} else {
uparams = NULL;
}
-
+
if (sip && sip->sip_via && (vproto = sip->sip_via->v_protocol)) {
if (!strcasecmp(vproto, "sip/2.0/ws")) {
}
if (!to_user || !to_host) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can not do authorization without a complete header in REGISTER request from %s:%d\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can not do authorization without a complete header in REGISTER request from %s:%d\n",
network_ip, network_port);
nua_respond(nh, SIP_401_UNAUTHORIZED, NUTAG_WITH_THIS_MSG(de->data->e_msg), TAG_END());
avoid_multi_reg = 1;
}
- /* Allow us to force the SIP user to be something specific - needed if
+ /* Allow us to force the SIP user to be something specific - needed if
* we - for example - want to be able to ensure that the username a UA can
* be contacted at is the same one that they used for authentication.
*/
/* Log line added to support Fail2Ban */
if (sofia_test_pflag(profile, PFLAG_LOG_AUTH_FAIL)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "SIP auth %s (%s) on sofia profile '%s' "
- "for [%s@%s] from ip %s\n", forbidden ? "failure" : "challenge",
+ "for [%s@%s] from ip %s\n", forbidden ? "failure" : "challenge",
(regtype == REG_INVITE) ? "INVITE" : "REGISTER", profile->name, to_user, to_host, network_ip);
}
/* Log line added to support Fail2Ban */
if (sofia_test_pflag(profile, PFLAG_LOG_AUTH_FAIL)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "SIP auth challenge (%s) on sofia profile '%s' "
- "for [%s@%s] from ip %s\n", (regtype == REG_INVITE) ? "INVITE" : "REGISTER",
+ "for [%s@%s] from ip %s\n", (regtype == REG_INVITE) ? "INVITE" : "REGISTER",
profile->name, to_user, to_host, network_ip);
}
} else {
char buf[32] = "";
-
- sql = switch_mprintf("select count(*) from sip_registrations where sip_user='%q' and sip_username='%q' and sip_host='%q' and contact='%q'",
+
+ sql = switch_mprintf("select count(*) from sip_registrations where sip_user='%q' and sip_username='%q' and sip_host='%q' and contact='%q'",
to_user, username, reg_host, contact_str);
contact = sofia_glue_get_url_from_contact(contact_str, 1);
url = switch_mprintf("sofia/%q/%s:%q", profile->name, proto, sofia_glue_strip_proto(contact));
-
+
switch_core_add_registration(to_user, reg_host, call_id, url, (long) reg_time + (long) exptime + profile->sip_expires_late_margin,
network_ip, network_port_c, is_tls ? "tls" : is_tcp ? "tcp" : "udp", reg_meta);
switch_safe_free(url);
switch_safe_free(contact);
-
+
if ((is_wss || is_ws || (sofia_test_pflag(profile, PFLAG_TCP_UNREG_ON_SOCKET_CLOSE) && (is_tcp || is_tls))) && !sofia_private && call_id) {
char key[256] = "";
nua_handle_t *hnh;
switch_core_hash_insert(profile->reg_nh_hash, key, nh);
}
}
-
+
if (!update_registration) {
sql = switch_mprintf("insert into sip_registrations "
"user_agent,server_user,server_host,profile_name,hostname,network_ip,network_port,sip_username,sip_realm,"
"mwi_user,mwi_host, orig_server_host, orig_hostname, sub_host, ping_status, ping_count, force_ping) "
"values ('%q','%q', '%q','%q','%q','%q', '%q', %ld, '%q', '%q', '%q', '%q', '%q', '%q', '%q','%q','%q','%q','%q','%q','%q','%q', '%q', %d, %d)",
- call_id, to_user, reg_host, profile->presence_hosts ? profile->presence_hosts : "",
+ call_id, to_user, reg_host, profile->presence_hosts ? profile->presence_hosts : "",
contact_str, reg_desc, rpid, (long) reg_time + (long) exptime + profile->sip_expires_late_margin,
- agent, from_user, guess_ip4, profile->name, mod_sofia_globals.hostname, network_ip, network_port_c, username, realm,
+ agent, from_user, guess_ip4, profile->name, mod_sofia_globals.hostname, network_ip, network_port_c, username, realm,
mwi_user, mwi_host, guess_ip4, mod_sofia_globals.hostname, sub_host, "Reachable", 0, force_ping);
} else {
sql = switch_mprintf("update sip_registrations set call_id='%q',"
mod_sofia_globals.hostname, mod_sofia_globals.hostname,
(long) reg_time + (long) exptime + profile->sip_expires_late_margin, force_ping,
to_user, username, reg_host, contact_str);
- }
+ }
if (sql) {
sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
}
if (!update_registration && sofia_reg_reg_count(profile, to_user, reg_host) == 1) {
- sql = switch_mprintf("delete from sip_presence where sip_user='%q' and sip_host='%q' and profile_name='%q' and open_closed='closed'",
+ sql = switch_mprintf("delete from sip_presence where sip_user='%q' and sip_host='%q' and profile_name='%q' and open_closed='closed'",
to_user, reg_host, profile->name);
if (mod_sofia_globals.debug_presence > 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "DELETE PRESENCE SQL: %s\n", sql);
} else {
sql = switch_mprintf("delete from sip_registrations where call_id='%q' and expires!=%ld", call_id, (long) reg_time + (long) exptime + profile->sip_expires_late_margin);
}
-
+
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
}
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
switch_event_fire(&event);
}
-
+
if (multi_reg) {
char *icontact, *p;
} else {
sql = switch_mprintf("delete from sip_registrations where call_id='%q'", call_id);
}
-
+
sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
switch_safe_free(icontact);
}
}
- if ((sofia_test_pflag(profile, PFLAG_PRESENCE_ON_REGISTER) ||
- (reg_count == 1 && sofia_test_pflag(profile, PFLAG_PRESENCE_ON_FIRST_REGISTER))
+ if ((sofia_test_pflag(profile, PFLAG_PRESENCE_ON_REGISTER) ||
+ (reg_count == 1 && sofia_test_pflag(profile, PFLAG_PRESENCE_ON_FIRST_REGISTER))
|| send_pres == 1 || (reg_count == 1 && send_pres == 2)) && debounce_ok) {
-
+
if (sofia_test_pflag(profile, PFLAG_PRESENCE_PROBE_ON_REGISTER)) {
if (switch_event_create(&s_event, SWITCH_EVENT_PRESENCE_PROBE) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "proto", SOFIA_CHAT_PROTO);
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "rpid", "unknown");
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "status", "Registered");
switch_event_fire(&s_event);
- }
+ }
}
}
} else {
nua_respond(nh, SIP_200_OK, TAG_IF(contact, SIPTAG_CONTACT(sip->sip_contact)), TAG_IF(path_val, SIPTAG_PATH_STR(path_val)),
TAG_IF(!zstr(expbuf), SIPTAG_EXPIRES_STR(expbuf)),
NUTAG_WITH_THIS_MSG(de->data->e_msg), SIPTAG_DATE_STR(date), TAG_END());
-
+
} else if ((contact_list = sofia_reg_find_reg_url_with_positive_expires_multi(profile, from_user, reg_host, reg_time, contact_str, exptime))) {
/* all + 1 tag_i elements initialized as NULL - last one implies TAG_END() */
switch_zmalloc(contact_tags, sizeof(*contact_tags) * (contact_list->count + 1));
contact_tags[i].t_value = (tag_value_t) m->val;
++i;
}
-
+
nua_respond(nh, SIP_200_OK, TAG_IF(path_val, SIPTAG_PATH_STR(path_val)),
TAG_IF(!zstr(expbuf), SIPTAG_EXPIRES_STR(expbuf)),
if (sip->sip_to && sip->sip_to->a_url && sip->sip_to->a_url->url_host) {
const char *to_host = sip->sip_to->a_url->url_host;
if (profile->reg_db_domain) {
- if (!sofia_glue_profile_exists(to_host)) {
+ if (!sofia_glue_profile_exists(to_host)) {
if (sofia_glue_add_profile(switch_core_strdup(profile->pool, to_host), profile) == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Auto-Adding Alias [%s] for profile [%s]\n", to_host, profile->name);
}
}
end:
-
+
if (!sofia_private_p || !*sofia_private_p) nua_handle_destroy(nh);
}
nua_handle_destroy(nh);
return;
}
-
+
if (sofia_private && !zstr(sofia_private->gateway_name)) {
- gateway = sofia_reg_find_gateway(sofia_private->gateway_name);
+ gateway = sofia_reg_find_gateway(sofia_private->gateway_name);
}
if (sofia_private && gateway) {
if (expi > 0 && expi != gateway->freq) {
//gateway->freq = expi;
//gateway->expires_str = switch_core_sprintf(gateway->pool, "%d", expi);
-
+
if (expi > 60) {
gateway->expires = switch_epoch_time_now(NULL) + (expi - 15);
} else {
const char *sip_auth_password = NULL;
char *dup_user = NULL;
char *dup_pass = NULL;
-
+
if (session && (channel = switch_core_session_get_channel(session))) {
sip_auth_username = switch_channel_get_variable(channel, "sip_auth_username");
sip_auth_password = switch_channel_get_variable(channel, "sip_auth_password");
for (x_param = switch_xml_child(x_params, "param"); x_param; x_param = x_param->next) {
const char *var = switch_xml_attr_soft(x_param, "name");
const char *val = switch_xml_attr_soft(x_param, "value");
-
+
if (!strcasecmp(var, "reverse-auth-user")) {
dup_user = strdup(val);
sip_auth_username = dup_user;
} else if (gateway) {
switch_snprintf(authentication, sizeof(authentication), "%s:%s:%s:%s", scheme, realm, gateway->auth_username, gateway->register_password);
} else {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR,
"Cannot locate any authentication credentials to complete an authentication request for realm '%s'\n", realm);
goto cancel;
}
tl_gets(tags, NUTAG_CALLSTATE_REF(ss_state), SIPTAG_WWW_AUTHENTICATE_REF(authenticate), TAG_END());
- nua_authenticate(nh,
- TAG_IF(sofia_private && !zstr(sofia_private->gateway_name), SIPTAG_EXPIRES_STR(gateway ? gateway->expires_str : "3600")),
+ nua_authenticate(nh,
+ TAG_IF(sofia_private && !zstr(sofia_private->gateway_name), SIPTAG_EXPIRES_STR(gateway ? gateway->expires_str : "3600")),
NUTAG_AUTH(authentication), TAG_END());
goto end;
ret = AUTH_FORBIDDEN;
goto end;
}
-
+
if (zstr(passwd) && zstr(a1_hash)) {
ret = AUTH_OK;
goto skip_auth;
#ifdef SOFIA_DEBUG_RWLOCKS
if (status == SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_ERROR, "XXXXXXXXXXXXXX GW LOCK %s\n", gateway->profile->name);
+ switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_ERROR, "XXXXXXXXXXXXXX GW LOCK %s\n", gateway->profile->name);
}
#endif
gateway->next = profile->gateways;
profile->gateways = gateway;
-
+
switch_mutex_unlock(profile->gw_mutex);
switch_mutex_lock(mod_sofia_globals.hash_mutex);
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005/2012, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Steve Underwood 0.0.1 <steveu@coppice.org>
*
tech_pvt->session = session;
}
-/*
+/*
State methods. They get called when the state changes to the specified state.
Returning SWITCH_STATUS_SUCCESS tells the core to execute the standard state method next,
so if you fully implement the state you can return SWITCH_STATUS_FALSE to skip it.
/*
* Copyright (c) 2011, Anthony Minessale II
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
- *
+ *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
int family = AF_INET;
memset(handle, 0, sizeof(*handle));
-
- if (strchr(host, ':')) {
+
+ if (strchr(host, ':')) {
family = AF_INET6;
}
-
+
if ((!(flags & MCAST_SEND) && !(flags & MCAST_RECV)) || (handle->sock = (mcast_socket_t)socket(family, SOCK_DGRAM, 0)) == mcast_sock_invalid ) {
return -1;
}
handle->send_addr.sin_port = htons(port);
handle->family = AF_INET;
}
-
+
if ( setsockopt(handle->sock, SOL_SOCKET, SO_REUSEADDR, (void *)&one, sizeof(one)) != 0 ) {
mcast_socket_close(handle);
return -1;
}
-
+
if ((flags & MCAST_RECV)) {
if (handle->family == AF_INET) {
struct ip_mreq mreq;
-
+
handle->recv_addr.sin_family = AF_INET;
handle->recv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
handle->recv_addr.sin_port = htons(port);
struct addrinfo addr_criteria;
struct addrinfo *mcast_addr;
char service[80] = "";
-
+
memset(&addr_criteria, 0, sizeof(addr_criteria));
addr_criteria.ai_family = AF_UNSPEC;
addr_criteria.ai_socktype = SOCK_DGRAM;
addr_criteria.ai_protocol = IPPROTO_UDP;
addr_criteria.ai_flags |= AI_NUMERICHOST;
-
+
snprintf(service, sizeof(service), "%d", port);
getaddrinfo(host, service, &addr_criteria, &mcast_addr);
-
+
memset(&handle->recv_addr6, 0, sizeof(handle->recv_addr6));
handle->recv_addr6.sin6_family = AF_INET6;
handle->recv_addr6.sin6_port = htons(port);
inet_pton(AF_INET6, "::0", &(handle->recv_addr6.sin6_addr));
memcpy(&mreq.ipv6mr_multiaddr, &((struct sockaddr_in6 *)mcast_addr->ai_addr)->sin6_addr, sizeof(struct in6_addr));
-
+
mreq.ipv6mr_interface = 0;
setsockopt(handle->sock, IPPROTO_IPV6, IPV6_JOIN_GROUP, (const char *)&mreq, sizeof(mreq));
if ((flags & MCAST_TTL_CONTINENT)) {
handle->ttl = 128;
}
-
+
if ((flags & MCAST_TTL_UNIVERSE)) {
handle->ttl = 255;
}
}
handle->ready = 1;
-
+
return 0;
}
/*
* Copyright (c) 2011, Anthony Minessale II
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
- *
+ *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
/*
* Copyright (c) 2011, Anthony Minessale II
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
- *
+ *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
*((char *)handle.buffer + r) = '\0';
return (char *) handle.buffer;
}
-
+
return NULL;
}
/*
* Copyright (c) 2011, Anthony Minessale II
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
- *
+ *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 1.3.35
- *
- * This file is not intended to be easily readable and contains a number of
+ *
+ * This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make
- * changes to this file unless you know what you are doing--modify the SWIG
- * interface file instead.
+ * changes to this file unless you know what you are doing--modify the SWIG
+ * interface file instead.
* ----------------------------------------------------------------------------- */
#define SWIGPERL
SwigValueWrapper() : tt(0) { }
SwigValueWrapper(const SwigValueWrapper<T>& rhs) : tt(new T(*rhs.tt)) { }
SwigValueWrapper(const T& t) : tt(new T(t)) { }
- ~SwigValueWrapper() { delete tt; }
+ ~SwigValueWrapper() { delete tt; }
SwigValueWrapper& operator=(const T& t) { delete tt; tt = new T(t); return *this; }
operator T&() const { return *tt; }
T *operator&() { return tt; }
#ifndef SWIGUNUSED
# if defined(__GNUC__)
# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
-# define SWIGUNUSED __attribute__ ((__unused__))
+# define SWIGUNUSED __attribute__ ((__unused__))
# else
# define SWIGUNUSED
# endif
# elif defined(__ICC)
-# define SWIGUNUSED __attribute__ ((__unused__))
+# define SWIGUNUSED __attribute__ ((__unused__))
# else
-# define SWIGUNUSED
+# define SWIGUNUSED
# endif
#endif
# ifdef __cplusplus
# define SWIGUNUSEDPARM(p)
# else
-# define SWIGUNUSEDPARM(p) p SWIGUNUSED
+# define SWIGUNUSEDPARM(p) p SWIGUNUSED
# endif
#endif
# define SWIGSTDCALL __stdcall
# else
# define SWIGSTDCALL
-# endif
+# endif
#endif
/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
creating a static or dynamic library from the swig runtime code.
In 99.9% of the cases, swig just needs to declare them as 'static'.
-
+
But only do this if is strictly necessary, ie, if you have problems
with your compiler or so.
*/
#define SWIG_POINTER_OWN 0x1
-/*
+/*
Flags/methods for returning states.
-
- The swig conversion methods, as ConvertPtr, return and integer
+
+ The swig conversion methods, as ConvertPtr, return and integer
that tells if the conversion was successful or not. And if not,
an error code can be returned (see swigerrors.swg for the codes).
-
+
Use the following macros/flags to set or process the returning
states.
-
+
In old swig versions, you usually write code as:
if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
} else {
// fail code
}
-
+
I.e., now SWIG_ConvertPtr can return new objects and you can
identify the case and take care of the deallocation. Of course that
requires also to SWIG_ConvertPtr to return new result values, as
- int SWIG_ConvertPtr(obj, ptr,...) {
- if (<obj is ok>) {
- if (<need new object>) {
- *ptr = <ptr to new allocated object>;
- return SWIG_NEWOBJ;
- } else {
- *ptr = <ptr to old object>;
- return SWIG_OLDOBJ;
- }
- } else {
- return SWIG_BADOBJ;
- }
+ int SWIG_ConvertPtr(obj, ptr,...) {
+ if (<obj is ok>) {
+ if (<need new object>) {
+ *ptr = <ptr to new allocated object>;
+ return SWIG_NEWOBJ;
+ } else {
+ *ptr = <ptr to old object>;
+ return SWIG_OLDOBJ;
+ }
+ } else {
+ return SWIG_BADOBJ;
+ }
}
Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
int fooi(int);
and you call
-
+
food(1) // cast rank '1' (1 -> 1.0)
fooi(1) // cast rank '0'
*/
-#define SWIG_OK (0)
+#define SWIG_OK (0)
#define SWIG_ERROR (-1)
#define SWIG_IsOK(r) (r >= 0)
-#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError)
+#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError)
/* The CastRankLimit says how many bits are used for the cast rank */
#define SWIG_CASTRANKLIMIT (1 << 8)
# endif
# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1)
# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK)
-SWIGINTERNINLINE int SWIG_AddCast(int r) {
+SWIGINTERNINLINE int SWIG_AddCast(int r) {
return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r;
}
-SWIGINTERNINLINE int SWIG_CheckState(int r) {
- return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0;
+SWIGINTERNINLINE int SWIG_CheckState(int r) {
+ return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0;
}
#else /* no cast-rank mode */
# define SWIG_AddCast
void *clientdata; /* Language specific module data */
} swig_module_info;
-/*
+/*
Compare two type names skipping the space characters, therefore
"char*" == "char *" and "Class<int>" == "Class<int >", etc.
return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
}
-/*
+/*
Dynamic pointer casting. Down an inheritance hierarchy
*/
SWIGRUNTIME swig_type_info *
return type->name;
}
-/*
+/*
Set the clientdata field for a type
*/
SWIGRUNTIME void
swig_cast_info *cast = ti->cast;
/* if (ti->clientdata == clientdata) return; */
ti->clientdata = clientdata;
-
+
while (cast) {
if (!cast->converter) {
swig_type_info *tc = cast->type;
if (!tc->clientdata) {
SWIG_TypeClientData(tc, clientdata);
}
- }
+ }
cast = cast->next;
}
}
SWIG_TypeClientData(ti, clientdata);
ti->owndata = 1;
}
-
+
/*
Search for a swig_type_info structure only by mangled name
Search is a O(log #types)
-
- We start searching at module start, and finish searching when start == end.
+
+ We start searching at module start, and finish searching when start == end.
Note: if start == end at the beginning of the function, we go all the way around
the circular list.
*/
SWIGRUNTIME swig_type_info *
-SWIG_MangledTypeQueryModule(swig_module_info *start,
- swig_module_info *end,
+SWIG_MangledTypeQueryModule(swig_module_info *start,
+ swig_module_info *end,
const char *name) {
swig_module_info *iter = start;
do {
register size_t r = iter->size - 1;
do {
/* since l+r >= 0, we can (>> 1) instead (/ 2) */
- register size_t i = (l + r) >> 1;
+ register size_t i = (l + r) >> 1;
const char *iname = iter->types[i]->name;
if (iname) {
register int compare = strcmp(name, iname);
- if (compare == 0) {
+ if (compare == 0) {
return iter->types[i];
} else if (compare < 0) {
if (i) {
Search for a swig_type_info structure for either a mangled name or a human readable name.
It first searches the mangled names of the types, which is a O(log #types)
If a type is not found it then searches the human readable names, which is O(#types).
-
- We start searching at module start, and finish searching when start == end.
+
+ We start searching at module start, and finish searching when start == end.
Note: if start == end at the beginning of the function, we go all the way around
the circular list.
*/
SWIGRUNTIME swig_type_info *
-SWIG_TypeQueryModule(swig_module_info *start,
- swig_module_info *end,
+SWIG_TypeQueryModule(swig_module_info *start,
+ swig_module_info *end,
const char *name) {
/* STEP 1: Search the name field using binary search */
swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
iter = iter->next;
} while (iter != end);
}
-
+
/* neither found a match */
return 0;
}
-/*
+/*
Pack binary data into a string
*/
SWIGRUNTIME char *
return c;
}
-/*
+/*
Unpack binary data from a string
*/
SWIGRUNTIME const char *
uu = ((d - '0') << 4);
else if ((d >= 'a') && (d <= 'f'))
uu = ((d - ('a'-10)) << 4);
- else
+ else
return (char *) 0;
d = *(c++);
if ((d >= '0') && (d <= '9'))
uu |= (d - '0');
else if ((d >= 'a') && (d <= 'f'))
uu |= (d - ('a'-10));
- else
+ else
return (char *) 0;
*u = uu;
}
return c;
}
-/*
+/*
Pack 'void *' into a string buffer.
*/
SWIGRUNTIME char *
#endif
/* Errors in SWIG */
-#define SWIG_UnknownError -1
-#define SWIG_IOError -2
-#define SWIG_RuntimeError -3
-#define SWIG_IndexError -4
-#define SWIG_TypeError -5
-#define SWIG_DivisionByZero -6
-#define SWIG_OverflowError -7
-#define SWIG_SyntaxError -8
-#define SWIG_ValueError -9
+#define SWIG_UnknownError -1
+#define SWIG_IOError -2
+#define SWIG_RuntimeError -3
+#define SWIG_IndexError -4
+#define SWIG_TypeError -5
+#define SWIG_DivisionByZero -6
+#define SWIG_OverflowError -7
+#define SWIG_SyntaxError -8
+#define SWIG_ValueError -9
#define SWIG_SystemError -10
#define SWIG_AttributeError -11
-#define SWIG_MemoryError -12
+#define SWIG_MemoryError -12
#define SWIG_NullReferenceError -13
#ifndef pTHX_
#define pTHX_
-#endif
+#endif
#include <string.h>
#ifdef __cplusplus
/* Error manipulation */
-#define SWIG_ErrorType(code) SWIG_Perl_ErrorType(code)
+#define SWIG_ErrorType(code) SWIG_Perl_ErrorType(code)
#define SWIG_Error(code, msg) sv_setpvf(GvSV(PL_errgv),"%s %s\n", SWIG_ErrorType(code), msg)
-#define SWIG_fail goto fail
+#define SWIG_fail goto fail
/* Perl-specific SWIG API */
#endif
/* Macro to call an XS function */
-#ifdef PERL_OBJECT
-# define SWIG_CALLXS(_name) _name(cv,pPerl)
-#else
-# ifndef MULTIPLICITY
-# define SWIG_CALLXS(_name) _name(cv)
-# else
-# define SWIG_CALLXS(_name) _name(PERL_GET_THX, cv)
-# endif
-#endif
+#ifdef PERL_OBJECT
+# define SWIG_CALLXS(_name) _name(cv,pPerl)
+#else
+# ifndef MULTIPLICITY
+# define SWIG_CALLXS(_name) _name(cv)
+# else
+# define SWIG_CALLXS(_name) _name(PERL_GET_THX, cv)
+# endif
+#endif
#ifdef PERL_OBJECT
#define MAGIC_PPERL CPerlObj *pPerl = (CPerlObj *) this;
#endif
-/*
+/*
Define how strict is the cast between strings and integers/doubles
when overloading between these types occurs.
-
+
The default is making it as strict as possible by using SWIG_AddCast
when needed.
-
+
You can use -DSWIG_PERL_NO_STRICT_STR2NUM at compilation time to
disable the SWIG_AddCast, making the casting between string and
numbers less strict.
#endif
#ifdef SWIG_PERL_STRICT_STR2NUM
/* string takes precedence */
-#define SWIG_Str2NumCast(x) SWIG_AddCast(x)
+#define SWIG_Str2NumCast(x) SWIG_AddCast(x)
#else
/* number takes precedence */
#define SWIG_Str2NumCast(x) x
if (!type) return NULL;
if (type->clientdata != NULL) {
return (const char*) type->clientdata;
- }
+ }
else {
return type->name;
}
SWIGRUNTIME swig_cast_info *
SWIG_TypeProxyCheck(const char *c, swig_type_info *ty) {
- SWIG_TypeCheck_Template(( (!iter->type->clientdata && (strcmp(iter->type->name, c) == 0))
+ SWIG_TypeCheck_Template(( (!iter->type->clientdata && (strcmp(iter->type->name, c) == 0))
|| (iter->type->clientdata && (strcmp((char*)iter->type->clientdata, c) == 0))), ty);
}
*ptr = voidptr;
}
- /*
+ /*
* DISOWN implementation: we need a perl guru to check this one.
*/
if (tsv && (flags & SWIG_POINTER_DISOWN)) {
- /*
+ /*
* almost copy paste code from below SWIG_POINTER_OWN setting
*/
SV *obj = sv;
if (isGV(gv)) {
HV *hv = GvHVn(gv);
/*
- * To set ownership (see below), a newSViv(1) entry is added.
+ * To set ownership (see below), a newSViv(1) entry is added.
* Hence, to remove ownership, we delete the entry.
*/
if (hv_exists_ent(hv, obj, 0)) {
#ifndef PERL_OBJECT
#define swig_create_magic(s,a,b,c) _swig_create_magic(s,a,b,c)
#ifndef MULTIPLICITY
- SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(SV *, MAGIC *), int (*get)(SV *,MAGIC *))
+ SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(SV *, MAGIC *), int (*get)(SV *,MAGIC *))
#else
- SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(struct interpreter*, SV *, MAGIC *), int (*get)(struct interpreter*, SV *,MAGIC *))
+ SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(struct interpreter*, SV *, MAGIC *), int (*get)(struct interpreter*, SV *,MAGIC *))
#endif
#else
# define swig_create_magic(s,a,b,c) _swig_create_magic(pPerl,s,a,b,c)
-SWIGRUNTIME void _swig_create_magic(CPerlObj *pPerl, SV *sv, const char *name, int (CPerlObj::*set)(SV *, MAGIC *), int (CPerlObj::*get)(SV *, MAGIC *))
+SWIGRUNTIME void _swig_create_magic(CPerlObj *pPerl, SV *sv, const char *name, int (CPerlObj::*set)(SV *, MAGIC *), int (CPerlObj::*get)(SV *, MAGIC *))
#endif
{
MAGIC *mg;
-#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0)
+#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0)
-#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else
+#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else
#define SWIG_name "MCASTc::boot_MCAST"
#define SWIG_prefix "MCASTc::"
-#define SWIGVERSION 0x010335
+#define SWIGVERSION 0x010335
#define SWIG_VERSION SWIGVERSION
-#define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a))
-#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),reinterpret_cast< void** >(a))
+#define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a))
+#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),reinterpret_cast< void** >(a))
#include <stdexcept>
{
if (SvPOK(obj)) {
STRLEN len = 0;
- char *cstr = SvPV(obj, len);
+ char *cstr = SvPV(obj, len);
size_t size = len + 1;
if (cptr) {
if (alloc) {
} else {
swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
if (pchar_descriptor) {
- char* vptr = 0;
+ char* vptr = 0;
if (SWIG_ConvertPtr(obj, (void**)&vptr, pchar_descriptor, 0) == SWIG_OK) {
if (cptr) *cptr = vptr;
if (psize) *psize = vptr ? (strlen(vptr) + 1) : 0;
} else {
if (val) *val = static_cast< int >(v);
}
- }
+ }
return res;
}
SWIGINTERNINLINE SV *
SWIG_From_long SWIG_PERL_DECL_ARGS_1(long value)
-{
+{
SV *obj = sv_newmortal();
sv_setiv(obj, (IV) value);
return obj;
SWIGINTERNINLINE SV *
SWIG_From_int SWIG_PERL_DECL_ARGS_1(int value)
-{
+{
return SWIG_From_long SWIG_PERL_CALL_ARGS_1(value);
}
}
-SWIGINTERNINLINE SV *
+SWIGINTERNINLINE SV *
SWIG_FromCharPtr(const char *cptr)
-{
+{
return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0));
}
int ecode3 = 0 ;
int argvi = 0;
dXSARGS;
-
+
if ((items < 3) || (items > 3)) {
SWIG_croak("Usage: new_McastHandle(host,port,flags);");
}
ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2);
if (!SWIG_IsOK(ecode2)) {
SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_McastHandle" "', argument " "2"" of type '" "int""'");
- }
+ }
arg2 = static_cast< int >(val2);
ecode3 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), &val3);
if (!SWIG_IsOK(ecode3)) {
SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "new_McastHandle" "', argument " "3"" of type '" "int""'");
- }
+ }
arg3 = static_cast< int >(val3);
result = (McastHandle *)new McastHandle((char const *)arg1,arg2,arg3);
ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_McastHandle, SWIG_OWNER | SWIG_SHADOW); argvi++ ;
if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
-
-
+
+
XSRETURN(argvi);
fail:
if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
-
-
+
+
SWIG_croak_null();
}
}
int res1 = 0 ;
int argvi = 0;
dXSARGS;
-
+
if ((items < 1) || (items > 1)) {
SWIG_croak("Usage: delete_McastHandle(self);");
}
res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_McastHandle, SWIG_POINTER_DISOWN | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_McastHandle" "', argument " "1"" of type '" "McastHandle *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_McastHandle" "', argument " "1"" of type '" "McastHandle *""'");
}
arg1 = reinterpret_cast< McastHandle * >(argp1);
delete arg1;
-
-
-
+
+
+
XSRETURN(argvi);
fail:
-
+
SWIG_croak_null();
}
}
int alloc2 = 0 ;
int argvi = 0;
dXSARGS;
-
+
if ((items < 2) || (items > 2)) {
SWIG_croak("Usage: McastHandle_send(self,data);");
}
res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_McastHandle, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "McastHandle_send" "', argument " "1"" of type '" "McastHandle *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "McastHandle_send" "', argument " "1"" of type '" "McastHandle *""'");
}
arg1 = reinterpret_cast< McastHandle * >(argp1);
res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2);
arg2 = reinterpret_cast< char * >(buf2);
result = (int)(arg1)->send((char const *)arg2);
ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ;
-
+
if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
XSRETURN(argvi);
fail:
-
+
if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
SWIG_croak_null();
}
int ecode2 = 0 ;
int argvi = 0;
dXSARGS;
-
+
if ((items < 1) || (items > 2)) {
SWIG_croak("Usage: McastHandle_recv(self,ms);");
}
res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_McastHandle, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "McastHandle_recv" "', argument " "1"" of type '" "McastHandle *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "McastHandle_recv" "', argument " "1"" of type '" "McastHandle *""'");
}
arg1 = reinterpret_cast< McastHandle * >(argp1);
if (items > 1) {
ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2);
if (!SWIG_IsOK(ecode2)) {
SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "McastHandle_recv" "', argument " "2"" of type '" "int""'");
- }
+ }
arg2 = static_cast< int >(val2);
}
result = (char *)(arg1)->recv(arg2);
ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ;
-
-
+
+
XSRETURN(argvi);
fail:
-
-
+
+
SWIG_croak_null();
}
}
int res1 = 0 ;
int argvi = 0;
dXSARGS;
-
+
if ((items < 1) || (items > 1)) {
SWIG_croak("Usage: McastHandle_filenum(self);");
}
res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_McastHandle, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "McastHandle_filenum" "', argument " "1"" of type '" "McastHandle *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "McastHandle_filenum" "', argument " "1"" of type '" "McastHandle *""'");
}
arg1 = reinterpret_cast< McastHandle * >(argp1);
result = (int)(arg1)->filenum();
ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ;
-
+
XSRETURN(argvi);
fail:
-
+
SWIG_croak_null();
}
}
};
/* -----------------------------------------------------------------------------
* Type initialization:
- * This problem is tough by the requirement that no dynamic
- * memory is used. Also, since swig_type_info structures store pointers to
+ * This problem is tough by the requirement that no dynamic
+ * memory is used. Also, since swig_type_info structures store pointers to
* swig_cast_info structures and swig_cast_info structures store pointers back
- * to swig_type_info structures, we need some lookup code at initialization.
- * The idea is that swig generates all the structures that are needed.
- * The runtime then collects these partially filled structures.
- * The SWIG_InitializeModule function takes these initial arrays out of
+ * to swig_type_info structures, we need some lookup code at initialization.
+ * The idea is that swig generates all the structures that are needed.
+ * The runtime then collects these partially filled structures.
+ * The SWIG_InitializeModule function takes these initial arrays out of
* swig_module, and does all the lookup, filling in the swig_module.types
* array with the correct data and linking the correct swig_cast_info
* structures together.
*
- * The generated swig_type_info structures are assigned staticly to an initial
+ * The generated swig_type_info structures are assigned staticly to an initial
* array. We just loop through that array, and handle each type individually.
* First we lookup if this type has been already loaded, and if so, use the
* loaded structure instead of the generated one. Then we have to fill in the
* a column is one of the swig_cast_info structures for that type.
* The cast_initial array is actually an array of arrays, because each row has
* a variable number of columns. So to actually build the cast linked list,
- * we find the array of casts associated with the type, and loop through it
+ * we find the array of casts associated with the type, and loop through it
* adding the casts to the list. The one last trick we need to do is making
* sure the type pointer in the swig_cast_info struct is correct.
*
- * First off, we lookup the cast->type name to see if it is already loaded.
+ * First off, we lookup the cast->type name to see if it is already loaded.
* There are three cases to handle:
* 1) If the cast->type has already been loaded AND the type we are adding
* casting info to has not been loaded (it is in this module), THEN we
* replace the cast->type pointer with the type pointer that has already
* been loaded.
- * 2) If BOTH types (the one we are adding casting info to, and the
+ * 2) If BOTH types (the one we are adding casting info to, and the
* cast->type) are loaded, THEN the cast info has already been loaded by
* the previous module so we just ignore it.
* 3) Finally, if cast->type has not already been loaded, then we add that
size_t i;
swig_module_info *module_head, *iter;
int found, init;
-
+
clientdata = clientdata;
-
+
/* check to see if the circular list has been setup, if not, set it up */
if (swig_module.next==0) {
/* Initialize the swig_module */
} else {
init = 0;
}
-
+
/* Try and load any already created modules */
module_head = SWIG_GetModule(clientdata);
if (!module_head) {
}
iter=iter->next;
} while (iter!= module_head);
-
+
/* if the is found in the list, then all is done and we may leave */
if (found) return;
/* otherwise we must add out module into the list */
swig_module.next = module_head->next;
module_head->next = &swig_module;
}
-
+
/* When multiple interpeters are used, a module could have already been initialized in
a different interpreter, but not yet have a pointer in this interpreter.
In this case, we do not want to continue adding types... everything should be
set up already */
if (init == 0) return;
-
+
/* Now work on filling in swig_module.types */
#ifdef SWIGRUNTIME_DEBUG
printf("SWIG_InitializeModule: size %d\n", swig_module.size);
swig_type_info *type = 0;
swig_type_info *ret;
swig_cast_info *cast;
-
+
#ifdef SWIGRUNTIME_DEBUG
printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
#endif
-
+
/* if there is another module already loaded */
if (swig_module.next != &swig_module) {
type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name);
} else {
type = swig_module.type_initial[i];
}
-
+
/* Insert casting types */
cast = swig_module.cast_initial[i];
while (cast->type) {
if (!ocast) ret = 0;
}
}
-
+
if (!ret) {
#ifdef SWIGRUNTIME_DEBUG
printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name);
swig_module.types[i] = type;
}
swig_module.types[i] = 0;
-
+
#ifdef SWIGRUNTIME_DEBUG
printf("**** SWIG_InitializeModule: Cast List ******\n");
for (i = 0; i < swig_module.size; ++i) {
size_t i;
swig_cast_info *equiv;
static int init_run = 0;
-
+
if (init_run) return;
init_run = 1;
-
+
for (i = 0; i < swig_module.size; i++) {
if (swig_module.types[i]->clientdata) {
equiv = swig_module.types[i]->cast;
XS(SWIG_init) {
dXSARGS;
int i;
-
+
SWIG_InitializeModule(0);
-
+
/* Install commands */
for (i = 0; swig_commands[i].name; i++) {
newXS((char*) swig_commands[i].name,swig_commands[i].wrapper, (char*)__FILE__);
}
-
+
/* Install variables */
for (i = 0; swig_variables[i].name; i++) {
SV *sv;
} else {
sv_setiv(sv,(IV) 0);
}
- swig_create_magic(sv, (char *) swig_variables[i].name, swig_variables[i].set, swig_variables[i].get);
+ swig_create_magic(sv, (char *) swig_variables[i].name, swig_variables[i].set, swig_variables[i].get);
}
-
+
/* Install constant */
for (i = 0; swig_constants[i].type; i++) {
SV *sv;
}
SvREADONLY_on(sv);
}
-
+
SWIG_TypeClientData(SWIGTYPE_p_McastHandle, (void*) "MCAST::McastHandle");
ST(0) = &PL_sv_yes;
XSRETURN(1);
mcast_socket_create("231.3.3.7", 1337, &handle, MCAST_SEND | MCAST_RECV | MCAST_TTL_HOST);
perror("create");
-
+
if (!strcmp(argv[1], "send")) {
mcast_socket_send(&handle, argv[2], strlen(argv[2]));
exit(0);
-/*
+/*
* Freeswitch Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Seven Du <dujinfang@gmail.com>
*
void verto_broadcast(const char *event_channel, cJSON *json, const char *key, switch_event_channel_id_t id);
static int ssl_init = 0;
-static int verto_init_ssl(verto_profile_t *profile)
+static int verto_init_ssl(verto_profile_t *profile)
{
const char *err = "";
int i = 0;
for (i = 0; i < profile->i; i++) {
if (profile->ip[i].secure) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SSL NOT ENABLED FOR LISTENER %s:%d. REVERTING TO WS\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SSL NOT ENABLED FOR LISTENER %s:%d. REVERTING TO WS\n",
profile->ip[i].local_ip, profile->ip[i].local_port);
profile->ip[i].secure = 0;
}
jsock_sub_node_t *thisnp = NULL, *np, *last = NULL;
np = head->tail = head->node;
-
+
while (np) {
thisnp = np;
if (!jsock || thisnp->jsock == jsock) {
x++;
-
+
if (last) {
last->next = np;
} else {
switch_channel_event_set_data(channel, event);
switch_event_fire(&event);
}
-
+
switch_core_session_rwunlock(session);
}
}
-
+
switch_console_free_matches(&matches);
}
}
switch_zmalloc(node, sizeof(*node));
node->jsock = jsock;
node->head = head;
-
+
if (!head->node) {
head->node = node;
head->tail = node;
cJSON_AddItemToObject(msg, "method", cJSON_CreateString(method));
cJSON_AddItemToObject(msg, "params", params);
-
+
if (call_id) {
cJSON_AddItemToObject(params, "callID", cJSON_CreateString(call_id));
}
if (paramsP) {
*paramsP = params;
}
-
+
return msg;
}
if (switch_queue_trypush(jsock->event_queue, jp) == SWITCH_STATUS_SUCCESS) {
status = SWITCH_STATUS_SUCCESS;
-
+
if (jsock->lost_events) {
int le = jsock->lost_events;
jsock->lost_events = 0;
{
jsock_sub_node_head_t *head;
- if ((head = switch_core_hash_find(verto_globals.event_channel_hash, event_channel))) {
+ if ((head = switch_core_hash_find(verto_globals.event_channel_hash, event_channel))) {
jsock_sub_node_t *np;
-
+
for(np = head->node; np; np = np->next) {
cJSON *msg = NULL, *params;
-
+
if (!use_jsock || use_jsock == np->jsock) {
params = cJSON_Duplicate(event, 1);
cJSON_AddItemToObject(params, "eventSerno", cJSON_CreateNumber(np->serno++));
char *main_channel = strdup(event_channel);
char *p = strchr(main_channel, '.');
if (p) *p = '\0';
- write_event(main_channel, use_jsock, event);
+ write_event(main_channel, use_jsock, event);
free(main_channel);
}
switch_thread_rwlock_unlock(verto_globals.event_channel_rwlock);
static jrpc_func_t jrpc_get_func(jsock_t *jsock, const char *method)
{
- jrpc_func_t func = NULL;
+ jrpc_func_t func = NULL;
char *main_method = NULL;
switch_assert(method);
cur = next;
}
- switch_safe_free(edup);
+ switch_safe_free(edup);
}
}
set_perm(allowed_jsapi, &jsock->allowed_jsapi);
set_perm(allowed_fsapi, &jsock->allowed_fsapi);
set_perm(allowed_event_channels, &jsock->allowed_event_channels);
-
+
switch_event_add_header_string(jsock->allowed_methods, SWITCH_STACK_BOTTOM, "login", MARKER);
}
goto end;
}
- login = cJSON_GetObjectCstr(params, "login");
- passwd = cJSON_GetObjectCstr(params, "passwd");
+ login = cJSON_GetObjectCstr(params, "login");
+ passwd = cJSON_GetObjectCstr(params, "passwd");
if (zstr(login)) {
goto end;
if ((json_ptr = cJSON_GetObjectItem(params, "loginParams"))) {
cJSON * i;
-
+
for(i = json_ptr->child; i; i = i->next) {
if (i->type == cJSON_True) {
switch_event_add_header_string(req_params, SWITCH_STACK_BOTTOM, i->string, "true");
if ((json_ptr = cJSON_GetObjectItem(params, "userVariables"))) {
cJSON * i;
-
+
for(i = json_ptr->child; i; i = i->next) {
if (i->type == cJSON_True) {
switch_event_add_header_string(jsock->user_vars, SWITCH_STACK_BOTTOM, i->string, "true");
}
switch_event_add_header_string(req_params, SWITCH_STACK_BOTTOM, "action", "jsonrpc-authenticate");
-
+
if (switch_xml_locate_user_merged("id", id, domain, NULL, &x_user, req_params) != SWITCH_STATUS_SUCCESS && !jsock->profile->blind_reg) {
*code = CODE_AUTH_FAILED;
switch_snprintf(message, mlen, "Login Incorrect");
jsock->domain = switch_core_strdup(jsock->pool, domain);
jsock->uid = switch_core_sprintf(jsock->pool, "%s@%s", id, domain);
jsock->ready = 1;
-
+
if (!x_user) {
switch_event_destroy(&req_params);
r = SWITCH_TRUE;
for (x_param = switch_xml_child(x_params, "param"); x_param; x_param = x_param->next) {
const char *var = switch_xml_attr_soft(x_param, "name");
const char *val = switch_xml_attr_soft(x_param, "value");
-
+
if (!use_passwd && !strcasecmp(var, "password")) {
use_passwd = val;
} else if (!strcasecmp(var, "jsonrpc-password")) {
for (x_param = switch_xml_child(x_params, "variable"); x_param; x_param = x_param->next) {
const char *var = switch_xml_attr_soft(x_param, "name");
const char *val = switch_xml_attr_soft(x_param, "value");
-
+
switch_event_add_header_string(jsock->vars, SWITCH_STACK_BOTTOM, var, val);
}
}
switch_xml_free(x_user);
}
-
+
switch_event_destroy(&req_params);
}
end:
return r;
-
+
}
static void set_call_params(cJSON *params, verto_pvt_t *tech_pvt) {
const char *callee_id_number = NULL;
caller_id_name = switch_channel_get_variable(tech_pvt->channel, "caller_id_name");
- caller_id_number = switch_channel_get_variable(tech_pvt->channel, "caller_id_number");
+ caller_id_number = switch_channel_get_variable(tech_pvt->channel, "caller_id_number");
callee_id_name = switch_channel_get_variable(tech_pvt->channel, "callee_id_name");
callee_id_number = switch_channel_get_variable(tech_pvt->channel, "callee_id_number");
if (callee_id_name) cJSON_AddItemToObject(params, "callee_id_name", cJSON_CreateString(callee_id_name));
if (callee_id_number) cJSON_AddItemToObject(params, "callee_id_number", cJSON_CreateString(callee_id_number));
-
- cJSON_AddItemToObject(params, "display_direction",
+
+ cJSON_AddItemToObject(params, "display_direction",
cJSON_CreateString(switch_channel_direction(tech_pvt->channel) == SWITCH_CALL_DIRECTION_OUTBOUND ? "outbound" : "inbound"));
int tries = 0;
top:
-
+
status = switch_mutex_trylock(verto_globals.detach_mutex);
if (status == SWITCH_STATUS_SUCCESS) {
switch_core_session_request_video_refresh(tech_pvt->session);
cJSON_AddItemToObject(params, "sdp", cJSON_CreateString(tech_pvt->mparams->local_sdp_str));
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Local attach SDP %s:\n%s\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Local attach SDP %s:\n%s\n",
switch_channel_get_name(tech_pvt->channel),
tech_pvt->mparams->local_sdp_str);
set_call_params(params, tech_pvt);
if (!switch_channel_up_nosig(tech_pvt->channel)) {
continue;
}
-
+
if (tech_pvt->detach_time && (now - tech_pvt->detach_time) > verto_globals.detach_timeout) {
switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_RECOVERY_ON_TIMER_EXPIRE);
}
static void set_session_id(jsock_t *jsock, const char *uuid)
{
//cJSON *params, *msg = jrpc_new(0);
-
+
if (!zstr(uuid)) {
switch_set_string(jsock->uuid_str, uuid);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s re-connecting session %s\n", jsock->name, jsock->uuid_str);
result = cJSON_GetObjectItem(json, "result");
version = cJSON_GetObjectCstr(json, "jsonrpc");
id = cJSON_GetObjectItem(json, "id");
-
+
if ((params = cJSON_GetObjectItem(json, "params"))) {
sessid = cJSON_GetObjectCstr(params, "sessid");
}
process_jrpc_response(jsock, json);
return NULL;
}
-
+
reply = jrpc_new(0);
jrpc_add_id(reply, id, "", 0);
jrpc_add_error(reply, -32601, "Invalid Method, Missing Method or Permission Denied", id);
} else {
if (func(method, params, jsock, &response) == SWITCH_TRUE) {
-
+
if (params) {
echo = cJSON_GetObjectItem(params, "echoParams");
}
reply = jrpc_new(0);
jrpc_add_error(reply, -32600, "Invalid Request", NULL);
}
-
+
if (reply) {
ws_write_json(jsock, &reply, SWITCH_TRUE);
}
-
+
if (json) {
cJSON_Delete(json);
}
switch_ssize_t bytes;
ws_opcode_t oc;
uint8_t *data;
-
+
bytes = ws_read_frame(&jsock->ws, &oc, &data);
-
+
if (bytes < 0) {
die("BAD READ %" SWITCH_SSIZE_T_FMT "\n", bytes);
break;
if (*s == '#') {
char repl[2048] = "";
switch_time_t a, b;
-
+
if (s[1] == 'S' && s[2] == 'P') {
if (s[3] == 'U') {
if (!(size = atoi(p))) {
continue;
}
-
+
a = switch_time_now();
do {
bytes = ws_read_frame(&jsock->ws, &oc, &data);
b = switch_time_now();
if (!bytes || !data) continue;
-
+
if (s[0] != '#') goto nm;
switch_snprintf(repl, sizeof(repl), "#SPU %ld", (long)((b - a) / 1000));
if (process_input(jsock, data, bytes) != SWITCH_STATUS_SUCCESS) {
die("Input Error\n");
}
-
+
if (!switch_test_flag(jsock, JPFLAG_CHECK_ATTACH) && switch_test_flag(jsock, JPFLAG_AUTHED)) {
attach_calls(jsock);
switch_set_flag(jsock, JPFLAG_CHECK_ATTACH);
add_jsock(jsock);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Starting client thread.\n", jsock->name);
-
+
if ((jsock->ptype & PTYPE_CLIENT) || (jsock->ptype & PTYPE_CLIENT_SSL)) {
client_run(jsock);
} else {
if (jsock->client_socket != ws_sock_invalid) {
close_socket(&jsock->client_socket);
}
-
+
switch_event_destroy(&jsock->allowed_methods);
switch_event_destroy(&jsock->allowed_fsapi);
switch_event_destroy(&jsock->allowed_jsapi);
switch_thread_rwlock_wrlock(jsock->rwlock);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Thread ended\n", jsock->name);
switch_thread_rwlock_unlock(jsock->rwlock);
-
+
return NULL;
}
switch_bool_t ok = SWITCH_TRUE;
top:
-
+
if (!jsock->allowed_fsapi) {
ok = SWITCH_FALSE;
goto end;
for (hp = jsock->user_vars->headers; hp; hp = hp->next) {
switch_channel_set_variable(tech_pvt->channel, hp->name, hp->value);
}
-
+
if ((var = switch_event_get_header(jsock->params, "caller-id-name"))) {
caller_profile->callee_id_name = switch_core_strdup(caller_profile->pool, var);
}
return status;
}
}
-
+
switch_core_media_gen_local_sdp(session, SDP_TYPE_REQUEST, NULL, 0, NULL, 0);
}
msg = jrpc_new_req(method, tech_pvt->call_id, ¶ms);
-
+
if (tech_pvt->mparams->local_sdp_str) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Local %s SDP %s:\n%s\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Local %s SDP %s:\n%s\n",
method,
switch_channel_get_name(tech_pvt->channel),
tech_pvt->mparams->local_sdp_str);
-
+
cJSON_AddItemToObject(params, "sdp", cJSON_CreateString(tech_pvt->mparams->local_sdp_str));
set_call_params(params, tech_pvt);
-
+
jsock_queue_event(jsock, &msg, SWITCH_TRUE);
} else {
status = SWITCH_STATUS_FALSE;
}
-
+
switch_thread_rwlock_unlock(jsock->rwlock);
}
-
+
return status;
}
switch_core_session_clear_crypto(session);
while(--tries > 0) {
-
+
status = verto_connect(session, "verto.attach");
if (status == SWITCH_STATUS_SUCCESS) {
if (zstr(tech_pvt->mparams->rtpip)) {
tech_pvt->mparams->rtpip = tech_pvt->mparams->rtpip6;
}
-
+
if (profile->rtpip_cur6 == profile->rtpip_index6) {
profile->rtpip_cur6 = 0;
}
}
if (zstr(tech_pvt->mparams->rtpip)) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "%s has no media ip, check your configuration\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "%s has no media ip, check your configuration\n",
switch_channel_get_name(tech_pvt->channel));
switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_BEARERCAPABILITY_NOTAVAIL);
}
tech_pvt->mparams->inbound_codec_string = switch_core_session_strdup(tech_pvt->session, profile->inbound_codec_string);
tech_pvt->mparams->outbound_codec_string = switch_core_session_strdup(tech_pvt->session, profile->outbound_codec_string);
-
+
tech_pvt->mparams->jb_msec = "-1";
switch_media_handle_set_media_flag(tech_pvt->smh, SCMF_SUPPRESS_CNG);
//tech_pvt->mparams->manual_video_rtp_bugs = profile->manual_video_rtp_bugs;
tech_pvt->mparams->local_network = switch_core_session_strdup(tech_pvt->session, profile->local_network);
-
+
//tech_pvt->mparams->rtcp_audio_interval_msec = profile->rtpp_audio_interval_msec;
//tech_pvt->mparams->rtcp_video_interval_msec = profile->rtpp_video_interval_msec;
switch_status_t status = SWITCH_STATUS_SUCCESS;
switch_core_media_prepare_codecs(tech_pvt->session, SWITCH_TRUE);
-
+
if (tech_pvt->r_sdp) {
if (verto_tech_media(tech_pvt, tech_pvt->r_sdp, SDP_TYPE_REQUEST) != SWITCH_STATUS_SUCCESS) {
switch_channel_set_variable(tech_pvt->channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "CODEC NEGOTIATION ERROR");
tech_pvt->channel = channel;
tech_pvt->jsock_uuid = (char *) jsock_uuid_str;
switch_core_session_set_private_class(session, tech_pvt, SWITCH_PVT_SECONDARY);
-
-
+
+
tech_pvt->call_id = switch_core_session_strdup(session, switch_core_session_get_uuid(session));
if ((tech_pvt->smh = switch_core_session_get_media_handle(session))) {
tech_pvt->mparams = switch_core_media_get_mparams(tech_pvt->smh);
verto_set_media_options(tech_pvt, profile);
}
-
+
switch_snprintf(name, sizeof(name), "verto.rtc/%s", tech_pvt->jsock_uuid);
switch_channel_set_name(channel, name);
switch_channel_add_state_handler(channel, &verto_state_handlers);
switch_core_event_hook_add_receive_message(session, messagehook);
-
+
track_pvt(tech_pvt);
//switch_channel_clear_flag(tech_pvt->channel, CF_ANSWERED);
static switch_bool_t verto__answer_func(const char *method, cJSON *params, jsock_t *jsock, cJSON **response)
{
- cJSON *obj = cJSON_CreateObject();
+ cJSON *obj = cJSON_CreateObject();
switch_core_session_t *session;
cJSON *dialog = NULL;
const char *call_id = NULL, *sdp = NULL;
cJSON_AddItemToObject(obj, "message", cJSON_CreateString("CallID missing"));
err = 1; goto cleanup;
}
-
+
if (!(sdp = cJSON_GetObjectCstr(params, "sdp"))) {
cJSON_AddItemToObject(obj, "message", cJSON_CreateString("SDP missing"));
err = 1; goto cleanup;
switch_core_session_t *other_session = NULL;
tech_pvt->r_sdp = switch_core_session_strdup(session, sdp);
- switch_channel_set_variable(tech_pvt->channel, SWITCH_R_SDP_VARIABLE, sdp);
+ switch_channel_set_variable(tech_pvt->channel, SWITCH_R_SDP_VARIABLE, sdp);
switch_channel_set_variable(tech_pvt->channel, "verto_client_address", jsock->name);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Remote SDP %s:\n%s\n", switch_channel_get_name(tech_pvt->channel), sdp);
switch_core_media_set_sdp_codec_string(session, sdp, SDP_TYPE_RESPONSE);
cJSON_AddItemToObject(obj, "message", cJSON_CreateString("CODEC ERROR"));
err = 1;
}
-
+
if (!err && switch_core_media_activate_rtp(tech_pvt->session) != SWITCH_STATUS_SUCCESS) {
switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
cJSON_AddItemToObject(obj, "message", cJSON_CreateString("MEDIA ERROR"));
err = 1;
}
}
-
+
if (!err) {
if (callee_id_name) {
switch_channel_set_profile_var(tech_pvt->channel, "callee_id_name", callee_id_name);
cleanup:
-
+
if (!err) return SWITCH_TRUE;
static switch_bool_t verto__bye_func(const char *method, cJSON *params, jsock_t *jsock, cJSON **response)
{
- cJSON *obj = cJSON_CreateObject();
+ cJSON *obj = cJSON_CreateObject();
switch_core_session_t *session;
cJSON *dialog = NULL;
const char *call_id = NULL, *cause_str = NULL;
int err = 0;
switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
-
+
*response = obj;
if (!(dialog = cJSON_GetObjectItem(params, "dialogParams"))) {
}
}
- cJSON_AddItemToObject(obj, "callID", cJSON_CreateString(call_id));
+ cJSON_AddItemToObject(obj, "callID", cJSON_CreateString(call_id));
if ((session = switch_core_session_locate(call_id))) {
verto_pvt_t *tech_pvt = switch_core_session_get_private_class(session, SWITCH_PVT_SECONDARY);
cleanup:
-
+
if (!err) return SWITCH_TRUE;
if (tech_pvt && b_tech_pvt) {
switch_channel_set_variable(tech_pvt->channel, "refer_uuid", switch_core_session_get_uuid(b_tech_pvt->session));
switch_channel_set_variable(b_tech_pvt->channel, "transfer_disposition", "replaced");
-
+
br_a = switch_channel_get_partner_uuid(tech_pvt->channel);
br_b = switch_channel_get_partner_uuid(b_tech_pvt->channel);
switch_channel_set_flag(tchannel, CF_ATTENDED_TRANSFER);
switch_core_session_rwunlock(tmp);
}
-
+
if (switch_true(switch_channel_get_variable(tech_pvt->channel, "recording_follow_transfer")) &&
(tmp = switch_core_session_locate(br_a))) {
switch_channel_set_variable(switch_core_session_get_channel(tmp), "transfer_disposition", "bridge");
static switch_bool_t verto__modify_func(const char *method, cJSON *params, jsock_t *jsock, cJSON **response)
{
- cJSON *obj = cJSON_CreateObject();
+ cJSON *obj = cJSON_CreateObject();
switch_core_session_t *session;
cJSON *dialog = NULL;
const char *call_id = NULL, *destination = NULL, *action = NULL;
int err = 0;
-
+
*response = obj;
if (!(dialog = cJSON_GetObjectItem(params, "dialogParams"))) {
err = 1; goto cleanup;
}
- cJSON_AddItemToObject(obj, "callID", cJSON_CreateString(call_id));
- cJSON_AddItemToObject(obj, "action", cJSON_CreateString(action));
+ cJSON_AddItemToObject(obj, "callID", cJSON_CreateString(call_id));
+ cJSON_AddItemToObject(obj, "action", cJSON_CreateString(action));
if ((session = switch_core_session_locate(call_id))) {
verto_pvt_t *tech_pvt = switch_core_session_get_private_class(session, SWITCH_PVT_SECONDARY);
-
- if (!strcasecmp(action, "transfer")) {
+
+ if (!strcasecmp(action, "transfer")) {
switch_core_session_t *other_session = NULL;
if (!(destination = cJSON_GetObjectCstr(params, "destination"))) {
err = 1; goto rwunlock;
}
- if (switch_core_session_get_partner(tech_pvt->session, &other_session) == SWITCH_STATUS_SUCCESS) {
+ if (switch_core_session_get_partner(tech_pvt->session, &other_session) == SWITCH_STATUS_SUCCESS) {
switch_ivr_session_transfer(other_session, destination, NULL, NULL);
cJSON_AddItemToObject(obj, "message", cJSON_CreateString("CALL TRANSFERRED"));
switch_core_session_rwunlock(other_session);
switch_core_media_toggle_hold(session, !!!switch_channel_test_flag(tech_pvt->channel, CF_PROTO_HOLD));
}
- cJSON_AddItemToObject(obj, "holdState", cJSON_CreateString(switch_channel_test_flag(tech_pvt->channel, CF_PROTO_HOLD) ? "held" : "active"));
+ cJSON_AddItemToObject(obj, "holdState", cJSON_CreateString(switch_channel_test_flag(tech_pvt->channel, CF_PROTO_HOLD) ? "held" : "active"));
rwunlock:
-
+
switch_core_session_rwunlock(session);
} else {
cJSON_AddItemToObject(obj, "message", cJSON_CreateString("CALL DOES NOT EXIST"));
cleanup:
-
+
if (!err) return SWITCH_TRUE;
switch_channel_set_variable(tech_pvt->channel, SWITCH_R_SDP_VARIABLE, tech_pvt->r_sdp);
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Remote SDP %s:\n%s\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Remote SDP %s:\n%s\n",
switch_channel_get_name(tech_pvt->channel), tech_pvt->r_sdp);
switch_core_media_clear_ice(tech_pvt->session);
cJSON_AddItemToObject(obj, "message", cJSON_CreateString("CODEC NEGOTIATION ERROR"));
err = 1; goto cleanup;
}
-
+
cleanup:
if (tech_pvt) {
cJSON_AddItemToObject(obj, "code", cJSON_CreateNumber(CODE_SESSION_ERROR));
- return SWITCH_FALSE;
+ return SWITCH_FALSE;
}
static void parse_user_vars(cJSON *obj, switch_core_session_t *session)
char *pproto = NULL;
*response = cJSON_CreateObject();
-
+
if ((dialog = cJSON_GetObjectItem(params, "dialogParams")) && (call_id = cJSON_GetObjectCstr(dialog, "callID"))) {
switch_core_session_t *session = NULL;
-
+
if ((session = switch_core_session_locate(call_id))) {
parse_user_vars(dialog, session);
- if ((dtmf = cJSON_GetObjectCstr(params, "dtmf"))) {
+ if ((dtmf = cJSON_GetObjectCstr(params, "dtmf"))) {
verto_pvt_t *tech_pvt = switch_core_session_get_private_class(session, SWITCH_PVT_SECONDARY);
char *send = switch_mprintf("~%s", dtmf);
if (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MODE)) {
switch_core_session_t *other_session = NULL;
-
+
if (switch_core_session_get_partner(tech_pvt->session, &other_session) == SWITCH_STATUS_SUCCESS) {
switch_core_session_send_dtmf_string(other_session, send);
switch_core_session_rwunlock(other_session);
switch_core_session_rwunlock(session);
}
}
-
+
if ((txt = cJSON_GetObjectItem(params, "txt"))) {
switch_core_session_t *session;
char charbuf[2] = "";
char *chardata = NULL;
cJSON *data;
-
+
if ((data = cJSON_GetObjectItem(txt, "code"))) {
charbuf[0] = data->valueint;
chardata = charbuf;
switch_mutex_lock(tech_pvt->text_read_mutex);
switch_buffer_write(tech_pvt->text_read_buffer, chardata, strlen(chardata));
switch_mutex_unlock(tech_pvt->text_read_mutex);
-
+
if ((switch_mutex_trylock(tech_pvt->text_cond_mutex) == SWITCH_STATUS_SUCCESS)) {
switch_thread_cond_signal(tech_pvt->text_cond);
switch_mutex_unlock(tech_pvt->text_cond_mutex);
}
switch_core_session_rwunlock(session);
}
-
+
}
if ((msg = cJSON_GetObjectItem(params, "msg"))) {
cJSON *i, *indialog = cJSON_GetObjectItem(msg, "inDialog");
const char *body = cJSON_GetObjectCstr(msg, "body");
switch_bool_t is_dialog = indialog && (indialog->type == cJSON_True || (indialog->type == cJSON_String && switch_true(indialog->valuestring)));
-
+
if (!zstr(to)) {
if (strchr(to, '+')) {
pproto = strdup(to);
proto = pproto;
}
}
-
+
if (!zstr(to) && !zstr(body) && switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", VERTO_CHAT_PROTO);
-
+
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", jsock->uid);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_user", jsock->id);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_host", jsock->domain);
-
+
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to", to);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "type", "text/plain");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_full", jsock->id);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "verto_profile", jsock->profile->name);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "verto_jsock_uuid", jsock->uuid_str);
-
+
for(i = msg->child; i; i = i->next) {
if (!zstr(i->string) && !zstr(i->valuestring) && (!strncasecmp(i->string, "from_", 5) || !strncasecmp(i->string, "to_", 3))) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, i->string, i->valuestring);
if (strcasecmp(proto, VERTO_CHAT_PROTO)) {
switch_core_chat_send(proto, event);
}
-
+
if (is_dialog) {
if ((dialog = cJSON_GetObjectItem(params, "dialogParams")) && (call_id = cJSON_GetObjectCstr(dialog, "callID"))) {
switch_core_session_t *session = NULL;
-
+
if ((session = switch_core_session_locate(call_id))) {
switch_core_session_queue_event(session, &event);
switch_core_session_rwunlock(session);
} else {
switch_core_chat_send("GLOBAL", event);
}
-
+
if (event) {
switch_event_destroy(&event);
}
} else {
r = SWITCH_FALSE;
- cJSON_AddItemToObject(*response, "message", cJSON_CreateString("INVALID MESSAGE to and body params required"));
+ cJSON_AddItemToObject(*response, "message", cJSON_CreateString("INVALID MESSAGE to and body params required"));
}
-
-
+
+
switch_safe_free(pproto);
}
const char *var, *destination_number, *call_id = NULL, *sdp = NULL,
*caller_id_name = NULL, *caller_id_number = NULL, *remote_caller_id_name = NULL, *remote_caller_id_number = NULL,*context = NULL;
switch_event_header_t *hp;
-
+
*response = obj;
if (switch_event_create_plain(&var_event, SWITCH_EVENT_CHANNEL_DATA) != SWITCH_STATUS_SUCCESS) {
if ((canvas = cJSON_GetObjectItem(dialog, "conferenceCanvasID"))) {
int canvas_id = 0;
-
+
if (!zstr(canvas->valuestring)) {
canvas_id = atoi(canvas->valuestring);
} else if (canvas->valueint) {
} else if (bandwidth->valueint) {
bwval = bandwidth->valueint;
}
-
+
if (bwval < 0) bwval = 0;
-
+
if (core_bw && bwval && bwval < core_bw) {
switch_channel_set_variable_printf(channel, "rtp_video_max_bandwidth_in", "%d", bwval);
}
remote_caller_id_name = cJSON_GetObjectCstr(dialog, "remote_caller_id_name");
remote_caller_id_number = cJSON_GetObjectCstr(dialog, "remote_caller_id_number");
-
+
if (zstr(caller_id_name)) {
if ((var = switch_event_get_header(jsock->params, "caller-id-name"))) {
caller_id_name = var;
caller_id_number = var;
}
}
-
+
if (!(context = switch_event_get_header(jsock->vars, "user_context"))) {
context = switch_either(jsock->context, jsock->profile->context);
}
jsock->remote_host,
cJSON_GetObjectCstr(dialog, "ani"),
cJSON_GetObjectCstr(dialog, "aniii"),
- cJSON_GetObjectCstr(dialog, "rdnis"),
- modname,
+ cJSON_GetObjectCstr(dialog, "rdnis"),
+ modname,
context,
destination_number))) {
-
+
switch_channel_set_caller_profile(channel, caller_profile);
-
+
}
switch_ivr_set_user(session, jsock->uid);
switch_channel_set_variable(channel, SWITCH_R_SDP_VARIABLE, sdp);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Remote SDP %s:\n%s\n", switch_channel_get_name(tech_pvt->channel), sdp);
- cJSON_AddItemToObject(obj, "message", cJSON_CreateString("CALL CREATED"));
- cJSON_AddItemToObject(obj, "callID", cJSON_CreateString(tech_pvt->call_id));
+ cJSON_AddItemToObject(obj, "message", cJSON_CreateString("CALL CREATED"));
+ cJSON_AddItemToObject(obj, "callID", cJSON_CreateString(tech_pvt->call_id));
switch_channel_add_state_handler(channel, &verto_state_handlers);
switch_core_event_hook_add_receive_message(session, messagehook);
switch_channel_set_state(channel, CS_INIT);
track_pvt(tech_pvt);
switch_core_session_thread_launch(session);
-
+
cleanup:
switch_event_destroy(&var_event);
cJSON_AddItemToObject(obj, "code", cJSON_CreateNumber(CODE_SESSION_ERROR));
return SWITCH_FALSE;
-
+
}
static switch_bool_t event_channel_check_auth(jsock_t *jsock, const char *event_channel)
if (event_channel_check_auth(jsock, event_channel)) {
if (!*sub_list) {
- *sub_list = cJSON_CreateArray();
+ *sub_list = cJSON_CreateArray();
}
if (jsock_sub_channel(jsock, event_channel) == SWITCH_STATUS_SUCCESS) {
cJSON_AddItemToArray(*sub_list, cJSON_CreateString(event_channel));
} else {
if (!*exist_list) {
- *exist_list = cJSON_CreateArray();
+ *exist_list = cJSON_CreateArray();
}
cJSON_AddItemToArray(*exist_list, cJSON_CreateString(event_channel));
}
r = SWITCH_TRUE;
} else {
if (!*err_list) {
- *err_list = cJSON_CreateArray();
+ *err_list = cJSON_CreateArray();
}
cJSON_AddItemToArray(*err_list, cJSON_CreateString(event_channel));
}
parse_subs(jsock, jchannel->valuestring, &subs, &errs, &exist);
} else if (jchannel->type == cJSON_Array) {
int i, len = cJSON_GetArraySize(jchannel);
-
+
for(i = 0; i < len; i++) {
cJSON *str = cJSON_GetArrayItem(jchannel, i);
if (str->type == cJSON_String) {
return r;
}
-static void do_unsub(jsock_t *jsock, const char *event_channel, cJSON **subs, cJSON **errs)
+static void do_unsub(jsock_t *jsock, const char *event_channel, cJSON **subs, cJSON **errs)
{
if (jsock_unsub_channel(jsock, event_channel)) {
if (!*subs) {
- *subs = cJSON_CreateArray();
+ *subs = cJSON_CreateArray();
}
cJSON_AddItemToArray(*subs, cJSON_CreateString(event_channel));
} else {
if (!*errs) {
- *errs = cJSON_CreateArray();
+ *errs = cJSON_CreateArray();
}
cJSON_AddItemToArray(*errs, cJSON_CreateString(event_channel));
}
do_unsub(jsock, jchannel->valuestring, &subs, &errs);
} else if (jchannel->type == cJSON_Array) {
int i, len = cJSON_GetArraySize(jchannel);
-
+
for(i = 0; i < len; i++) {
cJSON *str = cJSON_GetArrayItem(jchannel, i);
if (str->type == cJSON_String) {
}
- cJSON_AddItemToObject(params, "userid", cJSON_CreateString(jsock->uid));
+ cJSON_AddItemToObject(params, "userid", cJSON_CreateString(jsock->uid));
display = switch_event_get_header(jsock->params, "caller-id-name");
if (display) {
}
jevent = cJSON_Duplicate(params, 1);
-
+
broadcast = cJSON_GetObjectItem(params, "localBroadcast");
if (broadcast && broadcast->type == cJSON_True) {
reply = cJSON_CreateObject();
SWITCH_STANDARD_STREAM(stream);
-
+
if (cmd && (status = switch_api_execute(cmd->valuestring, arg ? arg->valuestring : NULL, NULL, &stream)) == SWITCH_STATUS_SUCCESS) {
cJSON_AddItemToObject(reply, "message", cJSON_CreateString((char *) stream.data));
} else {
jrpc_add_func("verto.unsubscribe", verto__unsubscribe_func);
jrpc_add_func("verto.broadcast", verto__broadcast_func);
jrpc_add_func("verto.modify", verto__modify_func);
-
+
}
die("ACCEPT FAILED\n");
}
}
-
+
for (i = 0; i < profile->i; i++) {
if ( profile->server_socket[i] == sock ) {
if (profile->ip[i].secure) {
jsock->local_sock = sock;
jsock->profile = profile;
-
+
if (zstr(jsock->name)) {
if (family == PF_INET) {
jsock->remote_port = ntohs(jsock->remote_addr.sin_port);
jsock->name = switch_core_sprintf(pool, "[%s]:%d", jsock->remote_host, jsock->remote_port);
}
}
-
+
jsock->ptype = ptype;
for(i = 0; i < profile->conn_acl_count; i++) {
if (!switch_check_network_list_ip(jsock->remote_host, profile->conn_acl[i])) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Client Connect from %s:%d refused by ACL %s\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Client Connect from %s:%d refused by ACL %s\n",
jsock->name, jsock->remote_host, jsock->remote_port, profile->conn_acl[i]);
goto error;
}
}
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Client Connect from %s:%d accepted\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Client Connect from %s:%d accepted\n",
jsock->name, jsock->remote_host, jsock->remote_port);
if (switch_event_create_subclass(&s_event, SWITCH_EVENT_CUSTOM, MY_EVENT_CLIENT_CONNECT) == SWITCH_STATUS_SUCCESS) {
return 0;
error:
-
+
if (jsock) {
if (jsock->client_socket != ws_sock_invalid) {
close_socket(&jsock->client_socket);
return -1;
}
-static ws_socket_t prepare_socket(ips_t *ips)
+static ws_socket_t prepare_socket(ips_t *ips)
{
ws_socket_t sock = ws_sock_invalid;
#ifndef WIN32
if ((sock = socket(family, SOCK_STREAM, IPPROTO_TCP)) < 0) {
die("Socket Error!\n");
}
-
+
if ( setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &reuse_addr, sizeof(reuse_addr)) < 0 ) {
die("Socket setsockopt Error!\n");
}
die("Bind Error!\n");
}
}
-
+
if (listen(sock, MAXPENDING) < 0) {
die("Listen error\n");
}
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "MCAST JSON PARSE ERR: %s\n", (char *)profile->mcast_sub.buffer);
}
-
+
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "MCAST INVALID READ %d\n", bytes);
}
int max = 2;
memset(&pfds[0], 0, sizeof(pfds[0]) * MAX_BIND+2);
-
+
for (i = 0; i < profile->i; i++) {
pfds[i].sock = profile->server_socket[i];
pfds[i].events = SWITCH_POLL_READ|SWITCH_POLL_ERROR;
if (res == 0) {
return 0;
}
-
+
for (x = 0; x < max; x++) {
if (pfds[x].revents & SWITCH_POLL_ERROR) {
die("POLL ERROR\n");
if (pfds[x].revents & SWITCH_POLL_HUP) {
die("POLL HUP\n");
}
-
+
if (pfds[x].revents & SWITCH_POLL_READ) {
if (profile->mcast_ip && pfds[x].sock == (switch_os_socket_t)profile->mcast_sub.sock) {
handle_mcast_sub(profile);
int sanity = 50;
switch_mutex_lock(verto_globals.mutex);
- for(pp = verto_globals.profile_head; pp; pp = pp->next) {
+ for(pp = verto_globals.profile_head; pp; pp = pp->next) {
kill_profile(pp);
}
switch_mutex_unlock(verto_globals.mutex);
listeners++;
}
}
-
+
if (!listeners) {
die("Client Socket Error! No Listeners!\n");
}
if (mcast_socket_create(profile->mcast_ip, profile->mcast_port, &profile->mcast_sub, MCAST_RECV | MCAST_TTL_HOST) < 0) {
ok++;
}
-
+
if (ok && mcast_socket_create(profile->mcast_ip, profile->mcast_port + 1, &profile->mcast_pub, MCAST_SEND | MCAST_TTL_HOST) > 0) {
mcast_socket_close(&profile->mcast_sub);
ok = 0;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "MCAST Disabled\n");
}
}
-
-
+
+
while(profile->running) {
if (profile_one_loop(profile) < 0) {
goto error;
}
return r;
-
+
}
static void do_shutdown(void)
}
}
switch_mutex_unlock(verto_globals.mutex);
-
+
return r;
}
if (!profile_exists(profile->name)) {
status = SWITCH_STATUS_SUCCESS;
}
-
+
if (status == SWITCH_STATUS_SUCCESS) {
profile->next = verto_globals.profile_head;
verto_globals.profile_head = profile;
}
switch_mutex_unlock(verto_globals.mutex);
-
+
return status;
}
static switch_status_t parse_config(const char *cf)
{
-
+
switch_xml_t cfg, xml, settings, param, xprofile, xprofiles;
switch_xml_t xvhosts, xvhost, rewrites, rule;
switch_status_t status = SWITCH_STATUS_SUCCESS;
var = (char *) switch_xml_attr_soft(param, "name");
val = (char *) switch_xml_attr_soft(param, "value");
-
+
if (!strcasecmp(var, "bind-local")) {
const char *secure = switch_xml_attr_soft(param, "secure");
if (i < MAX_BIND) {
} else if (!strcasecmp(var, "secure-chain")) {
set_string(profile->chain, val);
} else if (!strcasecmp(var, "inbound-codec-string") && !zstr(val)) {
- profile->inbound_codec_string = switch_core_strdup(profile->pool, val);
+ profile->inbound_codec_string = switch_core_strdup(profile->pool, val);
} else if (!strcasecmp(var, "outbound-codec-string") && !zstr(val)) {
- profile->outbound_codec_string = switch_core_strdup(profile->pool, val);
+ profile->outbound_codec_string = switch_core_strdup(profile->pool, val);
} else if (!strcasecmp(var, "blind-reg") && !zstr(val)) {
profile->blind_reg = switch_true(val);
} else if (!strcasecmp(var, "userauth") && !zstr(val)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid External RTP IP.\n");
} else {
profile->extrtpip = switch_core_strdup(profile->pool, val);
- }
+ }
} else if (!strcasecmp(var, "debug")) {
if (val) {
profile->debug = atoi(val);
if (zstr(profile->ip[0].local_ip) ) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s: local_ip bad\n", profile->name);
if (profile->ip[0].local_port <= 0 ) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s: local_port bad\n", profile->name);
-
+
if (zstr(profile->ip[0].local_ip) || profile->ip[0].local_port <= 0) {
del_profile(profile);
switch_core_destroy_memory_pool(&pool);
for (i = 0; i < profile->i; i++) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
- strchr(profile->ip[i].local_ip, ':') ? "%s Bound to [%s]:%d\n" : "%s Bound to %s:%d\n",
+ strchr(profile->ip[i].local_ip, ':') ? "%s Bound to [%s]:%d\n" : "%s Bound to %s:%d\n",
profile->name, profile->ip[i].local_ip, profile->ip[i].local_port);
}
}
parse_config("verto.conf");
switch_mutex_lock(verto_globals.mutex);
- for(p = verto_globals.profile_head; p; p = p->next) {
+ for(p = verto_globals.profile_head; p; p = p->next) {
verto_init_ssl(p);
}
switch_mutex_unlock(verto_globals.mutex);
for(p = profile->jsock_head; p; p = p->next) {
if (p->ptype & PTYPE_CLIENT) {
int i;
-
+
for (i = 0; i < profile->i; i++) {
if (profile->server_socket[i] == p->local_sock) {
stream->write_function(stream, "%s\t%s:%d\n", p->name, profile->ip[i].local_ip, profile->ip[i].local_port);
profile->running = 0;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "profile %s shutdown, Waiting for %d threads\n", profile->name, profile->jsock_count);
-
+
while(--sanity > 0 && profile->jsock_count > 0) {
switch_yield(100000);
}
static switch_call_cause_t verto_outgoing_channel(switch_core_session_t *session,
switch_event_t *var_event,
switch_caller_profile_t *outbound_profile,
- switch_core_session_t **new_session,
- switch_memory_pool_t **pool,
+ switch_core_session_t **new_session,
+ switch_memory_pool_t **pool,
switch_originate_flag_t flags,
switch_call_cause_t *cancel_cause);
switch_io_routines_t verto_io_routines = {
{
verto_pvt_t *tech_pvt = switch_core_session_get_private_class(session, SWITCH_PVT_SECONDARY);
switch_status_t status;
-
+
switch_mutex_lock(tech_pvt->text_cond_mutex);
status = switch_thread_cond_timedwait(tech_pvt->text_cond, tech_pvt->text_cond_mutex, 100000);
switch_mutex_lock(tech_pvt->text_write_mutex);
-
+
if (frame) {
switch_buffer_write(tech_pvt->text_write_buffer, frame->data, frame->datalen);
}
}
}
}
-
+
switch_mutex_unlock(tech_pvt->text_write_mutex);
switch_mutex_lock(verto_globals.mutex);
for(profile = verto_globals.profile_head; profile; profile = profile->next) {
-
+
switch_mutex_lock(profile->mutex);
-
+
for(jsock = profile->jsock_head; jsock; jsock = jsock->next) {
if (jsock->ready && !zstr(jsock->uid) && !zstr(uid) && !strcmp(uid, jsock->uid)) {
use_stream->write_function(use_stream, "%s/u:%s,", EP_NAME, jsock->uuid_str);
static switch_call_cause_t verto_outgoing_channel(switch_core_session_t *session,
switch_event_t *var_event,
switch_caller_profile_t *outbound_profile,
- switch_core_session_t **new_session,
- switch_memory_pool_t **pool,
+ switch_core_session_t **new_session,
+ switch_memory_pool_t **pool,
switch_originate_flag_t flags,
switch_call_cause_t *cancel_cause)
{
if ((flags & SOF_NO_LIMITS)) {
myflags |= SOF_NO_LIMITS;
}
-
+
if ((flags & SOF_FORKED_DIAL)) {
myflags |= SOF_NOBLOCK;
}
-
+
if (switch_ivr_originate(session, new_session, &cause, dial_str, 0, NULL,
NULL, NULL, outbound_profile, var_event, myflags, cancel_cause) == SWITCH_STATUS_SUCCESS) {
switch_core_session_rwunlock(*new_session);
}
-
+
free(dial_str);
}
} else {
const char *dialed_user = switch_event_get_header(var_event, "dialed_user");
const char *dialed_domain = switch_event_get_header(var_event, "dialed_domain");
-
+
if (dialed_user) {
if (dialed_domain) {
switch_event_add_header(var_event, SWITCH_STACK_BOTTOM, "verto_orig_dest", "%s@%s", dialed_user, dialed_domain);
switch_caller_profile_t *caller_profile;
verto_pvt_t *tech_pvt = NULL;
char name[512];
-
+
tech_pvt = switch_core_session_alloc(*new_session, sizeof(*tech_pvt));
tech_pvt->pool = switch_core_session_get_pool(*new_session);
tech_pvt->session = *new_session;
if (session) {
switch_channel_t *ochannel = switch_core_session_get_channel(session);
-
+
if (switch_true(switch_channel_get_variable(ochannel, SWITCH_BYPASS_MEDIA_VARIABLE))) {
switch_channel_set_flag(channel, CF_PROXY_MODE);
switch_channel_set_flag(ochannel, CF_PROXY_MODE);
if ((tech_pvt->smh = switch_core_session_get_media_handle(*new_session))) {
tech_pvt->mparams = switch_core_media_get_mparams(tech_pvt->smh);
}
-
+
switch_snprintf(name, sizeof(name), "verto.rtc/%s", tech_pvt->jsock_uuid);
switch_channel_set_name(channel, name);
switch_channel_set_variable(channel, "jsock_uuid_str", tech_pvt->jsock_uuid);
if ((caller_profile = switch_caller_profile_dup(switch_core_session_get_pool(*new_session), outbound_profile))) {
- switch_channel_set_caller_profile(channel, caller_profile);
- }
-
+ switch_channel_set_caller_profile(channel, caller_profile);
+ }
+
switch_channel_add_state_handler(channel, &verto_state_handlers);
switch_core_event_hook_add_receive_message(*new_session, messagehook);
switch_channel_set_state(channel, CS_INIT);
switch_mutex_lock(verto_globals.mutex);
for(profile = verto_globals.profile_head; profile; profile = profile->next) {
-
+
switch_mutex_lock(profile->mutex);
-
+
for(jsock = profile->jsock_head; jsock; jsock = jsock->next) {
if (jsock->ready && !zstr(jsock->uid) && !strcmp(uid, jsock->uid)) {
jsock_queue_event(jsock, &msg, SWITCH_FALSE);
const char *to = switch_event_get_header(message_event, "to");
const char *from = switch_event_get_header(message_event, "from");
const char *body = switch_event_get_body(message_event);
- const char *call_id = switch_event_get_header(message_event, "call_id");
+ const char *call_id = switch_event_get_header(message_event, "call_id");
//DUMP_EVENT(message_event);
obj = jrpc_new_req("verto.info", call_id, ¶ms);
msg = json_add_child_obj(params, "msg", NULL);
-
+
cJSON_AddItemToObject(msg, "from", cJSON_CreateString(from));
cJSON_AddItemToObject(msg, "to", cJSON_CreateString(to));
cJSON_AddItemToObject(msg, "body", cJSON_CreateString(body));
for (eh = message_event->headers; eh; eh = eh->next) {
if ((!strncasecmp(eh->name, "from_", 5) || !strncasecmp(eh->name, "to_", 3))) {
- cJSON_AddItemToObject(msg, eh->name, cJSON_CreateString(eh->value));
+ cJSON_AddItemToObject(msg, eh->name, cJSON_CreateString(eh->value));
}
}
switch_cache_db_handle_t *dbh = NULL;
const char *dsn;
-
+
if (!(dsn = switch_core_get_variable("json_db_handle"))) {
dsn = "json";
if (switch_cache_db_get_db_handle_dsn(&dbh, dsn) != SWITCH_STATUS_SUCCESS) {
dbh = NULL;
}
-
+
return dbh;
}
static int jcallback(void *pArg, int argc, char **argv, char **columnNames)
{
char **data = (char **) pArg;
-
+
if (argv[0] && !*data) {
*data = strdup(argv[0]);
}
switch_mutex_unlock(json_GLOBALS.store_mutex);
} else {
JSON_STORE = switch_core_hash_find(json_GLOBALS.store_hash, storename);
-
+
if (!JSON_STORE) {
JSON_STORE = cJSON_CreateObject();
switch_core_hash_insert(json_GLOBALS.store_hash, storename, JSON_STORE);
switch(cmd) {
case CMD_RETRIEVE:
obj = json_retrieve(file, NULL);
-
+
if (!obj) {
error = "CANNOT LOAD DATA";
} else {
switch_mutex_unlock(json_GLOBALS.store_mutex);
}
-
+
goto end;
}
default:
break;
}
-
+
if (switch_true(verbose) || cmd == CMD_DUMP) {
cJSON *dump;
} else {
switch_mutex_unlock(json_GLOBALS.store_mutex);
}
-
+
if (cmd == CMD_COMMIT || commit) {
switch_bool_t ok;
end:
-
+
if (!zstr(error)) {
cJSON_AddItemToObject(reply, "errorMessage", cJSON_CreateString(error));
}
add_it("calleeIDName", "caller-callee-id-name");
add_it("calleeIDNumber", "caller-callee-id-number");
add_it("channelUUID", "unique-id");
-
+
add_it("presenceCallDirection", "presence-call-direction");
add_it("channelPresenceID", "channel-presence-id");
add_it("channelPresenceData", "channel-presence-data");
add_it(hp->name, hp->name);
}
}
-
+
switch_event_channel_broadcast(event_channel, &msg, __FILE__, NO_EVENT_CHANNEL_ID);
free(event_channel);
event_channel = switch_mprintf("FSevent.%s", switch_event_name(event->event_id));
switch_tolower_max(event_channel + 8);
}
-
+
cJSON_AddItemToObject(msg, "eventChannel", cJSON_CreateString(event_channel));
cJSON_AddItemToObject(msg, "data", data);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MY_EVENT_LOGIN);
return SWITCH_STATUS_TERM;
}
-
+
if (switch_event_reserve_subclass(MY_EVENT_CLIENT_DISCONNECT) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MY_EVENT_CLIENT_DISCONNECT);
return SWITCH_STATUS_TERM;
}
-
+
if (switch_event_reserve_subclass(MY_EVENT_CLIENT_CONNECT) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MY_EVENT_CLIENT_CONNECT);
return SWITCH_STATUS_TERM;
}
-
+
memset(&verto_globals, 0, sizeof(verto_globals));
verto_globals.pool = pool;
#ifndef WIN32
switch_thread_cond_create(&verto_globals.detach_cond, verto_globals.pool);
verto_globals.detach_timeout = 120;
-
+
memset(&json_GLOBALS, 0, sizeof(json_GLOBALS));
switch_event_channel_bind(SWITCH_EVENT_CHANNEL_GLOBAL, verto_broadcast, &verto_globals.event_channel_id);
-
+
r = init();
if (r) return SWITCH_STATUS_TERM;
switch_event_free_subclass(MY_EVENT_LOGIN);
switch_event_free_subclass(MY_EVENT_CLIENT_DISCONNECT);
switch_event_free_subclass(MY_EVENT_CLIENT_CONNECT);
-
+
json_cleanup();
switch_core_hash_destroy(&json_GLOBALS.store_hash);
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Seven Du <dujinfang@gmail.com>
*
#else
#include <sys/socket.h>
#include <arpa/inet.h>
-#include <sys/wait.h>
+#include <sys/wait.h>
#endif
#include <string.h>
#ifndef WIN32
#define VERTO_CHAT_PROTO "verto"
-#define copy_string(x,y,z) strncpy(x, y, z - 1)
-#define set_string(x,y) strncpy(x, y, sizeof(x)-1)
+#define copy_string(x,y,z) strncpy(x, y, z - 1)
+#define set_string(x,y) strncpy(x, y, sizeof(x)-1)
#define CODE_INVALID -32600
#define CODE_AUTH_REQUIRED -32000
char *uid;
char *dialplan;
char *context;
-
+
char remote_host[256];
int remote_port;
struct verto_profile_s *profile;
switch_thread_rwlock_t *rwlock;
-
+
switch_mutex_t *write_mutex;
switch_mutex_t *filter_mutex;
switch_frame_t text_read_frame;
switch_thread_cond_t *text_cond;
- switch_mutex_t *text_cond_mutex;
- switch_mutex_t *text_read_mutex;
- switch_mutex_t *text_write_mutex;
+ switch_mutex_t *text_cond_mutex;
+ switch_mutex_t *text_read_mutex;
+ switch_mutex_t *text_write_mutex;
switch_buffer_t *text_read_buffer;
switch_buffer_t *text_write_buffer;
int ssl_ready;
int ready;
int debug;
-
+
int in_thread;
int blind_reg;
switch_thread_rwlock_t *tech_rwlock;
switch_thread_cond_t *detach_cond;
- switch_mutex_t *detach_mutex;
- switch_mutex_t *detach2_mutex;
+ switch_mutex_t *detach_mutex;
+ switch_mutex_t *detach2_mutex;
uint32_t detached;
uint32_t detach_timeout;
#define ms_sleep(x) usleep( x * 1000);
#else
#define ms_sleep(x) Sleep( x );
-#endif
+#endif
#ifdef _MSC_VER
/* warning C4706: assignment within conditional expression*/
#ifndef WSS_STANDALONE
-void init_ssl(void)
+void init_ssl(void)
{
// SSL_library_init();
}
-void deinit_ssl(void)
+void deinit_ssl(void)
{
return;
}
e = strchr(v, '\n');
}
}
-
+
if (v && e) {
int cplen;
size_t len = e - v;
-
+
if (len > buflen - 1) {
cplen = buflen -1;
} else {
cplen = len;
}
-
+
strncpy(buf, v, cplen);
*(buf+cplen) = '\0';
return 1;
}
-
+
}
}
return 0;
}
-static int b64encode(unsigned char *in, size_t ilen, unsigned char *out, size_t olen)
+static int b64encode(unsigned char *in, size_t ilen, unsigned char *out, size_t olen)
{
int y=0,bytes=0;
size_t x=0;
SHA1Update(&sha, in, strlen(in));
SHA1Final(&sha, digest);
}
-#else
+#else
static void sha1_digest(unsigned char *digest, char *in)
{
}
*(wsh->buffer + wsh->datalen) = '\0';
-
+
if (strncasecmp(wsh->buffer, "GET ", 4)) {
goto err;
}
-
+
p = wsh->buffer + 4;
-
+
e = strchr(p, ' ');
if (!e) {
goto err;
cheezy_get_var(wsh->buffer, "Sec-WebSocket-Key", key, sizeof(key));
cheezy_get_var(wsh->buffer, "Sec-WebSocket-Version", version, sizeof(version));
cheezy_get_var(wsh->buffer, "Sec-WebSocket-Protocol", proto, sizeof(proto));
-
+
if (!*key) {
goto err;
}
-
+
snprintf(input, sizeof(input), "%s%s", key, WEBSOCKET_GUID);
sha1_digest(output, input);
b64encode((unsigned char *)output, SHA1_HASH_SIZE, (unsigned char *)b64, sizeof(b64));
snprintf(proto_buf, sizeof(proto_buf), "Sec-WebSocket-Protocol: %s\r\n", proto);
}
- snprintf(respond, sizeof(respond),
+ snprintf(respond, sizeof(respond),
"HTTP/1.1 101 Switching Protocols\r\n"
"Upgrade: websocket\r\n"
"Connection: Upgrade\r\n"
if (r == -1) {
err = SSL_get_error(wsh->ssl, r);
-
+
if (err == SSL_ERROR_WANT_READ) {
if (!block) {
r = -2;
}
}
} while (r == -1 && xp_is_blocking(xp_errno()) && wsh->x < 1000);
-
+
end:
if (wsh->x >= 10000 || (block && wsh->x >= 1000)) {
if (r >= 0) {
wsh->x = 0;
}
-
+
return r;
}
if (ssl_err) {
r = ssl_err * -1;
}
-
+
return r;
}
do {
r = send(wsh->sock, (void *)((unsigned char *)data + wrote), bytes - wrote, 0);
-
+
if (r > 0) {
wrote += r;
}
}
ms_sleep(ms);
}
-
+
} while (--sanity > 0 && ((r == -1 && xp_is_blocking(xp_errno())) || (wsh->block && wrote < bytes)));
-
+
//if (r<0) {
//printf("wRITE FAIL: %s\n", strerror(errno));
//}
if (code == 0) {
return -1;
}
-
+
if (code < 0) {
if (code == -1 && SSL_get_error(wsh->ssl, code) != SSL_ERROR_WANT_READ) {
return -1;
}
} while (wsh->sanity > 0);
-
+
if (!wsh->sanity) {
return -1;
}
-
+
}
while (!wsh->down && !wsh->handshake) {
}
wsh->logical_established = 1;
-
+
return 0;
}
if (wsh->down > 1) {
return;
}
-
+
wsh->down = 2;
if (wsh->write_buffer) {
}
-ssize_t ws_close(wsh_t *wsh, int16_t reason)
+ssize_t ws_close(wsh_t *wsh, int16_t reason)
{
-
+
if (wsh->down) {
return -1;
}
wsh->down = 1;
-
+
if (wsh->uri) {
free(wsh->uri);
wsh->uri = NULL;
wsh->sock = ws_sock_invalid;
return reason * -1;
-
+
}
ssize_t ws_read_frame(wsh_t *wsh, ws_opcode_t *oc, uint8_t **data)
{
-
+
ssize_t need = 2;
char *maskp;
int ll = 0;
}
return ws_close(wsh, WS_PROTO_ERR);
}
-
+
if (wsh->datalen < need) {
if ((wsh->datalen += ws_raw_read(wsh, wsh->buffer + wsh->datalen, 9 - wsh->datalen, WS_BLOCK)) < need) {
/* too small - protocol err */
{
int fin = (wsh->buffer[0] >> 7) & 1;
int mask = (wsh->buffer[1] >> 7) & 1;
-
+
if (!fin && *oc != WSOC_CONTINUATION) {
frag = 1;
if (mask) {
need += 4;
-
+
if (need > wsh->datalen) {
/* too small - protocol err */
*oc = WSOC_CLOSE;
wsh->plen = wsh->buffer[1] & 0x7f;
wsh->payload = &wsh->buffer[2];
-
+
if (wsh->plen == 127) {
uint64_t *u64;
int more = 0;
}
-
+
u64 = (uint64_t *) wsh->payload;
wsh->payload += 8;
wsh->plen = ntoh64(*u64);
if (need + blen > (ssize_t)wsh->bbuflen) {
void *tmp;
-
+
wsh->bbuflen = need + blen + wsh->rplen;
if ((tmp = realloc(wsh->bbuffer, wsh->bbuflen))) {
}
wsh->rplen = wsh->plen - need;
-
+
if (wsh->rplen) {
memcpy(wsh->body, wsh->payload, wsh->rplen);
}
-
+
while(need) {
ssize_t r = ws_raw_read(wsh, wsh->body + wsh->rplen, need, WS_BLOCK);
wsh->rplen += r;
need -= r;
}
-
+
if (mask && maskp) {
ssize_t i;
wsh->body[i] ^= maskp[i % 4];
}
}
-
+
if (*oc == WSOC_PING) {
ws_write_frame(wsh, WSOC_PONG, wsh->body, wsh->rplen);
}
*data = (uint8_t *)wsh->bbuffer;
-
+
//printf("READ[%ld][%d]-----------------------------:\n[%s]\n-------------------------------\n", wsh->packetlen, *oc, (char *)*data);
hdr[1] = 127;
hlen += 8;
-
+
u64 = (uint64_t *) &hdr[2];
*u64 = hton64(bytes);
}
abort();
}
}
-
+
bp = (uint8_t *) wsh->write_buffer;
memcpy(bp, (void *) &hdr[0], hlen);
memcpy(bp + hlen, data, bytes);
-
+
raw_ret = ws_raw_write(wsh, bp, (hlen + bytes));
if (raw_ret != (ssize_t) (hlen + bytes)) {
return raw_ret;
}
-
+
return bytes;
}
#include <sys/types.h>
#ifndef _MSC_VER
#include <arpa/inet.h>
-#include <sys/wait.h>
+#include <sys/wait.h>
#include <sys/socket.h>
#include <unistd.h>
#else
//#include "sha1.h"
#include <openssl/ssl.h>
-#if defined(_MSC_VER) || defined(__APPLE__) || defined(__FreeBSD__) || (defined(__SVR4) && defined(__sun))
+#if defined(_MSC_VER) || defined(__APPLE__) || defined(__FreeBSD__) || (defined(__SVR4) && defined(__sun))
#define __bswap_64(x) \
x = (x>>56) | \
((x<<40) & 0x00FF000000000000) | \
#ifndef _MSC_VER
static inline uint64_t get_unaligned_uint64(const void *p)
-{
+{
const struct { uint64_t d; } __attribute__((packed)) *pp = p;
return pp->d;
}
char *content_type;
mod_amqp_keypart_t format_fields[MAX_ROUTING_KEY_FORMAT_FIELDS+1];
-
+
/* Array to store the possible event subscriptions */
int event_subscriptions;
switch_event_node_t *event_nodes[SWITCH_EVENT_ALL];
switch_event_types_t event_ids[SWITCH_EVENT_ALL];
switch_event_node_t *eventNode;
-
+
/* Because only the 'running' thread will be reading or writing to the two connection pointers
- * this does not 'yet' need a read/write lock. Before these structures can be destroyed,
+ * this does not 'yet' need a read/write lock. Before these structures can be destroyed,
* the running thread must be joined first.
*/
mod_amqp_connection_t *conn_root;
mod_amqp_connection_t *conn_active;
-
+
/* Rabbit connections are not thread safe so one connection per thread.
Communicate with sender thread using a queue */
switch_thread_t *producer_thread;
switch_queue_t *send_queue;
unsigned int send_queue_size;
-
+
int reconnect_interval_ms;
int circuit_breaker_ms;
switch_time_t circuit_breaker_reset_time;
typedef struct {
char *name;
-
+
char *exchange;
char *queue;
char *binding_key;
/* Note: The AMQP channel is not reentrant this MUTEX serializes sending events. */
mod_amqp_connection_t *conn_root;
mod_amqp_connection_t *conn_active;
-
+
int reconnect_interval_ms;
/* Listener thread */
typedef struct {
char *name;
-
+
char *exchange;
char *exchange_type;
int exchange_durable;
/* Note: The AMQP channel is not reentrant this MUTEX serializes sending events. */
mod_amqp_connection_t *conn_root;
mod_amqp_connection_t *conn_active;
-
+
int reconnect_interval_ms;
/* Logging thread */
}
profile->conn_active = NULL;
/* We are not going to open the command queue connection on create, but instead wait for the running thread to open it */
-
+
/* Start the worker threads */
switch_threadattr_create(&thd_attr, profile->pool);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
continue;
}
- /* Check if exchange already exists */
+ /* Check if exchange already exists */
amqp_exchange_declare(profile->conn_active->state, 1,
amqp_cstring_bytes(profile->exchange),
amqp_cstring_bytes("topic"),
0, /* passive */
profile->exchange_durable,
amqp_empty_table);
-
+
if (mod_amqp_log_if_amqp_error(amqp_get_rpc_reply(profile->conn_active->state), "Declaring exchange")) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Profile[%s] failed to create exchange\n", profile->name);
goto err;
}
-
+
/* Create a bounded FIFO queue for sending messages */
if (switch_queue_create(&(profile->send_queue), profile->send_queue_size, profile->pool) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot create send queue of size %d!\n", profile->send_queue_size);
default:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Send failed with a generic error\n");
-
+
/* Send failed and closed the connection; reconnect will happen at the beginning of the loop
* NB: do we need a delay here to prevent a fast reconnect-send-fail loop? */
break;
0, /* passive */
profile->exchange_durable,
amqp_empty_table);
-
+
if (mod_amqp_log_if_amqp_error(amqp_get_rpc_reply(profile->conn_active->state), "Declaring exchange")) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Profile[%s] failed to create exchange\n", profile->name);
goto err;
}
-
+
/* Create a bounded FIFO queue for sending messages */
if (switch_queue_create(&(profile->send_queue), profile->send_queue_size, profile->pool) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot create send queue of size %d!\n", profile->send_queue_size);
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* mod_cdr_csv.c -- Asterisk Compatible CDR Module
*
*/
while ( len ) {
int sent = send( conn->sock, cbuf, len, flags );
if ( sent == -1 ) {
- if (errno == EPIPE)
+ if (errno == EPIPE)
conn->connected = 0;
conn->err = MONGO_IO_ERROR;
return MONGO_ERROR;
if ( ! conn->connected ) {
conn->err = MONGO_CONN_FAIL;
return MONGO_ERROR;
- }
+ }
else {
mongo_clear_errors( conn );
return MONGO_OK;
MONGO_EXPORT void gridfile_get_chunk( gridfile *gfile, int n, bson* out ) {
bson query;
-
+
bson_iterator it;
bson_oid_t id;
int result;
if( bson_find( &it, &out, "ismaster" ) )
ismaster = bson_iterator_bool( &it );
if( bson_find( &it, &out, "maxBsonObjectSize" ) ) {
- max_bson_size = bson_iterator_int( &it );
+ max_bson_size = bson_iterator_int( &it );
}
conn->max_bson_size = max_bson_size;
} else {
ismaster = bson_iterator_bool( &it );
if( bson_find( &it, &out, "maxBsonObjectSize" ) )
- max_bson_size = bson_iterator_int( &it );
+ max_bson_size = bson_iterator_int( &it );
conn->max_bson_size = max_bson_size;
if( bson_find( &it, &out, "setName" ) ) {
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
*
* Contributor(s):
* Daniel Swarbrick <daniel.swarbrick@gmail.com>
- *
+ *
* mod_cdr_mongodb.c -- MongoDB CDR Module
*
* Derived from:
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
*
* Contributor(s):
* Daniel Swarbrick <daniel.swarbrick@gmail.com>
- *
+ *
* mod_cdr_sqlite.c -- SQLite CDR Module
*
* Derived from:
<!-- in additon to cookie, optionally restrict by ACL -->
<!--<param name="apply-inbound-acl" value="lan"/>-->
<!-- alternative is "binary" -->
- <!--<param name="encoding" value="string"/>-->
+ <!--<param name="encoding" value="string"/>-->
<!-- provide compatability with previous OTP release (use with care) -->
<!--<param name="compat-rel" value="12"/> -->
</settings>
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Andrew Thompson <andrew@hijacked.us>
* Rob Charlton <rob.charlton@savageminds.com>
/* Stolen from code added to ei in R12B-5.
* Since not everyone has this version yet;
- * provide our own version.
+ * provide our own version.
* */
#define put8(s,n) do { \
ei_encode_switch_event_headers(ebuf, event);
}
-/* function to make rpc call to remote node to retrieve a pid -
+/* function to make rpc call to remote node to retrieve a pid -
calls module:function(Ref). The response comes back as
{rex, {Ref, Pid}}
*/
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Andrew Thompson <andrew@hijacked.us>
* Rob Charlton <rob.charlton@savageminds.com>
/* reply mutex is locked */
if ((p = find_fetch_reply(uuid_str))) {
switch (p->state) {
- case reply_waiting:
+ case reply_waiting:
{
/* clone the reply so it doesn't get destroyed on us */
ei_x_buff *nbuf = malloc(sizeof(*nbuf));
memcpy(nbuf->buff, buf->buff, buf->buffsz);
nbuf->index = buf->index;
nbuf->buffsz = buf->buffsz;
-
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Got reply for %s\n", uuid_str);
-
+
/* copy info into the reply struct */
p->state = reply_found;
p->reply = nbuf;
strncpy(p->winner, listener->peer_nodename, MAXNODELEN);
-
+
/* signal waiting thread that its time to wake up */
switch_thread_cond_signal(p->ready_or_found);
/* reply OK */
switch_thread_rwlock_unlock(session->event_rwlock);
switch_thread_rwlock_unlock(session->rwlock);
-
+
ei_x_encode_atom(rbuf, "ok");
} else {
ei_x_encode_tuple_header(rbuf, 2);
} else if (!fail) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM | SWITCH_STACK_NODUP, key, value);
}
-
+
/* Do not free malloc here! The above commands utilize the raw allocated memory and skip any copying/duplication. Faster. */
}
fail = SWITCH_TRUE;
break;
}
-
+
ei_get_type(buf->buff, &buf->index, &type, &size);
value = malloc(size + 1);
switch_core_hash_this(iter, &key, NULL, &val);
se = (session_elem_t*)val;
if (switch_test_flag(se, LFLAG_WAITING_FOR_PID) && se->spawn_reply && !strncmp(se->spawn_reply->hash, hash, 100)) {
-
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "found matching session for %s : %s\n", hash, se->uuid_str);
switch_mutex_lock(se->spawn_reply->mutex);
if (found) {
return SWITCH_STATUS_FALSE;
- }
+ }
ei_x_encode_tuple_header(rbuf, 2);
ei_x_encode_atom(rbuf, "error");
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Andrew Thompson <andrew@hijacked.us>
* Rob Charlton <rob.charlton@savageminds.com>
session_elem_t *find_session_elem_by_uuid(listener_t *listener, const char *uuid)
{
session_elem_t *session = NULL;
-
+
switch_thread_rwlock_rdlock(listener->session_rwlock);
if ((session = (session_elem_t*)switch_core_hash_find(listener->sessions, uuid))) {
switch_thread_rwlock_rdlock(session->rwlock);
switch_thread_rwlock_rdlock(listener->session_rwlock);
for (iter = switch_core_hash_first(listener->sessions); iter; iter = switch_core_hash_next(&iter)) {
switch_core_hash_this(iter, &key, NULL, &val);
-
+
if (((session_elem_t*)val)->process.type == ERLANG_PID && !ei_compare_pids(pid, &((session_elem_t*)val)->process.pid)) {
session = (session_elem_t*)val;
switch_thread_rwlock_rdlock(session->rwlock);
return session;
}
-static fetch_reply_t *new_fetch_reply(const char *uuid_str)
+static fetch_reply_t *new_fetch_reply(const char *uuid_str)
{
fetch_reply_t *reply = NULL;
switch_memory_pool_t *pool = NULL;
reply = switch_core_alloc(pool, sizeof(*reply));
switch_assert(reply != NULL);
memset(reply, 0, sizeof(*reply));
-
+
reply->uuid_str = switch_core_strdup(pool, uuid_str);
reply->pool = pool;
switch_thread_cond_create(&reply->ready_or_found, pool);
return reply;
}
-static void destroy_fetch_reply(fetch_reply_t *reply)
+static void destroy_fetch_reply(fetch_reply_t *reply)
{
switch_core_hash_delete_locked(mod_erlang_event_globals.fetch_reply_hash, reply->uuid_str, mod_erlang_event_globals.fetch_reply_mutex);
/* lock so nothing can have it while we delete it */
switch_core_destroy_memory_pool(&(reply->pool));
}
-fetch_reply_t *find_fetch_reply(const char *uuid)
+fetch_reply_t *find_fetch_reply(const char *uuid)
{
fetch_reply_t *reply = NULL;
/*switch_log_printf(SWITCH_CHANNEL_UUID_LOG(sp->uuid_str), SWITCH_LOG_DEBUG, "flushed event %s for %s\n", switch_event_name(pevent->event_id), sp->uuid_str); */
- /* events from attached sessions are wrapped in a {call_event,<EVT>} tuple
+ /* events from attached sessions are wrapped in a {call_event,<EVT>} tuple
to distinguish them from normal events (if they are sent to the same process)
*/
/*switch_log_printf(SWITCH_CHANNEL_UUID_LOG(sp->uuid_str), SWITCH_LOG_DEBUG, "popped event %s for %s\n", switch_event_name(pevent->event_id), sp->uuid_str); */
- /* events from attached sessions are wrapped in a {call_event,<EVT>} tuple
+ /* events from attached sessions are wrapped in a {call_event,<EVT>} tuple
to distinguish them from normal events (if they are sent to the same process)
*/
ei_x_buff ebuf;
prefs.compat_rel = 0;
prefs.max_event_bulk = 1;
prefs.max_log_bulk = 1;
-
+
if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", cf);
/* insert the waiting marker */
switch_set_flag(session_element, LFLAG_WAITING_FOR_PID);
-
+
/* attach the session to the listener */
add_session_elem_to_listener(listener, session_element);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Added session to listener\n");
switch_mutex_lock(p->mutex);
-
+
if (!strcmp(function, "!")) {
/* send a message to request a pid */
ei_x_buff rbuf;
return;
}
-
+
/* first work out if there is a listener already talking to the node we want to talk to */
listener = find_listener(node);
/* if there is no listener, then create one */
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Andrew Thompson <andrew@hijacked.us>
* Rob Charlton <rob.charlton@savageminds.com>
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Seven Du <dujinfang@gmail.com>
*
const char *hval;
send = 0;
-
+
for (hp = l->filters->headers; hp; hp = hp->next) {
if ((hval = switch_event_get_header(event, hp->name))) {
const char *comp_to = hp->value;
switch_ivr_parse_all_events(session);
- if (switch_channel_get_state(channel) != CS_HIBERNATE &&
- !switch_channel_test_flag(channel, CF_REDIRECT) && !switch_channel_test_flag(channel, CF_TRANSFER) && !switch_channel_test_flag(channel, CF_RESET)
+ if (switch_channel_get_state(channel) != CS_HIBERNATE &&
+ !switch_channel_test_flag(channel, CF_REDIRECT) && !switch_channel_test_flag(channel, CF_TRANSFER) && !switch_channel_test_flag(channel, CF_RESET)
&& (switch_test_flag(listener, LFLAG_RESUME) || ((var = switch_channel_get_variable(channel, "socket_resume")) && switch_true(var)))) {
switch_channel_set_state(channel, CS_EXECUTE);
}
static void send_disconnect(listener_t *listener, const char *message)
{
-
+
char disco_buf[512] = "";
switch_size_t len, mlen;
}
mlen = strlen(message);
-
+
if (listener->session) {
switch_snprintf(disco_buf, sizeof(disco_buf), "Content-Type: text/disconnect-notice\n"
"Controlled-Session-UUID: %s\n"
ptr = (mbuf + pos);
}
-
+
status = switch_socket_recv(listener->sock, ptr, &mlen);
if (prefs.done || (!SWITCH_STATUS_IS_BREAK(status) && status != SWITCH_STATUS_SUCCESS)) {
status = switch_socket_recv(listener->sock, p, &mlen);
if (prefs.done || (!SWITCH_STATUS_IS_BREAK(status) && status != SWITCH_STATUS_SUCCESS)) {
- free(body);
+ free(body);
switch_goto_status(SWITCH_STATUS_FALSE, end);
}
}
}
- if (switch_test_flag(listener, LFLAG_HANDLE_DISCO) &&
+ if (switch_test_flag(listener, LFLAG_HANDLE_DISCO) &&
listener->linger_timeout != (time_t) -1 && switch_epoch_time_now(NULL) > listener->linger_timeout) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(listener->session), SWITCH_LOG_DEBUG, "linger timeout, closing socket\n");
status = SWITCH_STATUS_FALSE;
switch_set_flag_locked(listener, LFLAG_HANDLE_DISCO);
if (switch_test_flag(listener, LFLAG_LINGER)) {
char disco_buf[512] = "";
-
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(listener->session), SWITCH_LOG_DEBUG, "%s Socket Linger %d\n",
+
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(listener->session), SWITCH_LOG_DEBUG, "%s Socket Linger %d\n",
switch_channel_get_name(channel), (int)listener->linger_timeout);
-
+
switch_snprintf(disco_buf, sizeof(disco_buf), "Content-Type: text/disconnect-notice\n"
"Controlled-Session-UUID: %s\n"
- "Content-Disposition: linger\n"
+ "Content-Disposition: linger\n"
"Channel-Name: %s\n"
"Linger-Time: %d\n"
- "Content-Length: 0\n\n",
+ "Content-Length: 0\n\n",
switch_core_session_get_uuid(listener->session), switch_channel_get_name(channel), (int)listener->linger_timeout);
if (listener->linger_timeout != (time_t) -1) {
listener->linger_timeout += switch_epoch_time_now(NULL);
}
-
+
len = strlen(disco_buf);
switch_socket_send(listener->sock, disco_buf, &len);
} else {
switch_bool_t ok = SWITCH_TRUE;
top:
-
+
if (!switch_core_hash_find(listener->allowed_api_hash, check_cmd)) {
ok = SWITCH_FALSE;
goto end;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "ADDING CUSTOM EVENT: %s\n", m->val);
switch_core_hash_insert(listener->event_hash, m->val, MARKER);
}
-
+
switch_console_free_matches(&events);
}
}
void *val;
switch_assert(listener->allowed_event_hash);
-
+
for (hi = switch_core_hash_first(listener->allowed_event_hash); hi; hi = switch_core_hash_next(&hi)) {
switch_core_hash_this(hi, &var, NULL, &val);
switch_core_hash_insert(listener->event_hash, (char *)var, MARKER);
*tmp++ = '\0';
pass = tmp;
}
-
+
if (zstr(user) || zstr(domain_name)) {
switch_snprintf(reply, reply_len, "-ERR invalid");
switch_clear_flag_locked(listener, LFLAG_RUNNING);
if ((uuid = cmd + 9)) {
char *fmt;
strip_cr(uuid);
-
+
if ((fmt = strchr(uuid, ' '))) {
*fmt++ = '\0';
}
-
+
if (!(listener->session = switch_core_session_locate(uuid))) {
if (fmt) {
switch_snprintf(reply, reply_len, "-ERR invalid uuid");
listener->format = EVENT_FORMAT_PLAIN;
} else if (!strcasecmp(fmt, "json")) {
listener->format = EVENT_FORMAT_JSON;
- }
+ }
}
switch_set_flag_locked(listener, LFLAG_SESSION);
const char *uuid = NULL;
char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
switch_uuid_str(uuid_str, sizeof(uuid_str));
-
+
switch_event_add_header_string(*event, SWITCH_STACK_BOTTOM, "Event-UUID", uuid_str);
strip_cr(cmd);
if ((arg_copy = strchr(api_copy, ' '))) {
*arg_copy++ = '\0';
}
-
+
ok = auth_api_command(listener, api_copy, arg_copy);
free(api_copy);
goto done;
}
}
-
+
if (!(acs.console_execute = switch_true(console_execute))) {
if ((arg = strchr(api_cmd, ' '))) {
*arg++ = '\0';
}
}
-
+
acs.listener = listener;
acs.api_cmd = api_cmd;
acs.arg = arg;
if (listener->sa && (listener->remote_port = switch_sockaddr_get_port(listener->sa))) {
launch_listener_thread(listener);
continue;
- }
+ }
}
-
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error initilizing connection\n");
close_socket(&listener->sock);
expire_listener(&listener);
-
+
}
end:
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
// Use the JSON string as the message body
zmq::message_t msg(pjson, strlen(pjson), free_message_data, NULL);
-
+
// Send the message
_publisher.send(msg);
}
void Listen() {
// All we do is sit here and block the run loop thread so it doesn't return
// it seems that if you want to keep your module running you can't return from the run loop
-
+
char_msg msg;
while(true) {
// Listen for term message
<configuration name="format_cdr.conf" description="Multi Format CDR CURL logger">
- <!-- You can have multiple profiles, to allow logging to both json and cdr simultaneously, or to
+ <!-- You can have multiple profiles, to allow logging to both json and cdr simultaneously, or to
different paths or servers with different settings, just be sure to use different name for
each profile. -->
<profiles>
<!-- optional: if not present we do log the b leg -->
<!-- true or false if we should create a cdr for the b leg of a call-->
<param name="log-b-leg" value="false"/>
-
+
<!-- optional: if not present, all filenames are the uuid of the call -->
<!-- true or false if a leg files are prefixed "a_" -->
<param name="prefix-a-leg" value="true"/>
<!-- encode the post data may be 'true' for url encoding, 'false' for no encoding, 'base64' for base64 encoding or 'textxml' for text/xml -->
<param name="encode" value="true"/>
- <!-- optional: set to true to disable Expect: 100-continue lighttpd requires this setting -->
- <!--<param name="disable-100-continue" value="true"/>-->
-
+ <!-- optional: set to true to disable Expect: 100-continue lighttpd requires this setting -->
+ <!--<param name="disable-100-continue" value="true"/>-->
+
<!-- optional: full path to the error log dir for failed web posts if not specified its the same as log-dir -->
<!-- either an absolute path, a relative path assuming ${prefix}/logs or a blank or omitted value will default to ${prefix}/logs/format_cdr -->
<!-- <param name="err-log-dir" value="/tmp"/> -->
<!-- which auhtentification scheme to use. Supported values are: basic, digest, NTLM, GSS-NEGOTIATE or "any" for automatic detection -->
- <!--<param name="auth-scheme" value="basic"/>-->
+ <!--<param name="auth-scheme" value="basic"/>-->
<!-- optional: this will enable the CA root certificate check by libcurl to
verify that the certificate was issued by a major Certificate Authority.
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Brian West <brian@freeswitch.org>
* Bret McDanel <trixter AT 0xdecafbad.com>
* Justin Cassidy <xachenant@hotmail.com>
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_format_cdr_shutdown);
SWITCH_MODULE_DEFINITION(mod_format_cdr, mod_format_cdr_load, mod_format_cdr_shutdown, NULL);
-/* this function would have access to the HTML returned by the webserver, we don't need it
+/* this function would have access to the HTML returned by the webserver, we don't need it
* and the default curl activity is to print to stdout, something not as desirable
* so we have a dummy function here
*/
if (!zstr(profile->ssl_cacert_file)) {
switch_curl_easy_setopt(curl_handle, CURLOPT_CAINFO, profile->ssl_cacert_file);
}
-
+
switch_curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, profile->timeout);
/* these were used for testing, optionally they may be enabled if someone desires
{
switch_xml_free(xml_cdr);
}
-
+
if ( json_cdr )
{
cJSON_Delete(json_cdr);
profile->base_err_log_dir[profile->err_dir_count++] = switch_core_sprintf(profile->pool, "%s%s%s", SWITCH_GLOBAL_dirs.log_dir, SWITCH_PATH_SEPARATOR, val);
}
}
-
+
}
} else if (!strcasecmp(var, "enable-cacert-check") && switch_true(val)) {
profile->enable_cacert_check = 1;
profile->encode_values = switch_true(val) ? ENCODING_DEFAULT : ENCODING_NONE;
}
}
-
+
if (!profile->err_dir_count) {
if (!zstr(profile->base_log_dir)) {
profile->base_err_log_dir[profile->err_dir_count++] = switch_core_strdup(profile->pool, profile->base_log_dir);
} else {
- profile->base_err_log_dir[profile->err_dir_count++] = switch_core_sprintf(profile->pool, "%s%sformat_cdr",
+ profile->base_err_log_dir[profile->err_dir_count++] = switch_core_sprintf(profile->pool, "%s%sformat_cdr",
SWITCH_GLOBAL_dirs.log_dir, SWITCH_PATH_SEPARATOR);
}
}
memset(&globals, 0, sizeof(globals));
- if (switch_event_bind_removable(modname, SWITCH_EVENT_TRAP, SWITCH_EVENT_SUBCLASS_ANY,
+ if (switch_event_bind_removable(modname, SWITCH_EVENT_TRAP, SWITCH_EVENT_SUBCLASS_ANY,
event_handler, NULL, &globals.node) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
return SWITCH_STATUS_GENERR;
}
switch_safe_free(profile->log_dir);
-
+
switch_thread_rwlock_destroy(profile->log_path_lock);
switch_core_destroy_memory_pool(&profile->pool);
<!-- Whether to URL encode the individual JSON values. Defaults to true, set to false for standard JSON. -->
<param name="encode-values" value="true"/>
- <!-- Normally if url and log-dir are present, url is attempted first and log-dir second.
+ <!-- Normally if url and log-dir are present, url is attempted first and log-dir second.
This options allows to do both systematically. -->
<param name="log-http-and-disk" value="false"/>
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Brian West <brian@freeswitch.org>
* Bret McDanel <trixter AT 0xdecafbad.com>
* Justin Cassidy <xachenant@hotmail.com>
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_json_cdr_shutdown);
SWITCH_MODULE_DEFINITION(mod_json_cdr, mod_json_cdr_load, mod_json_cdr_shutdown, NULL);
-/* this function would have access to the HTML returned by the webserver, we don't need it
+/* this function would have access to the HTML returned by the webserver, we don't need it
* and the default curl activity is to print to stdout, something not as desirable
* so we have a dummy function here
*/
switch_log_printf(SWITCH_CHANNEL_UUID_LOG(data->uuid), SWITCH_LOG_INFO, "Backup file %s\n", path);
if (path) {
-#ifdef _MSC_VER
+#ifdef _MSC_VER
mode_t mode = S_IRUSR | S_IWUSR;
-#else
+#else
mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
-#endif
- if ((fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, mode)) > -1) {
+#endif
+ if ((fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, mode)) > -1) {
switch_size_t json_len = strlen(json_text);
switch_ssize_t wrote = 0, x;
do { x = write(fd, json_text, json_len);
char ebuf[512] = { 0 };
switch_log_printf(SWITCH_CHANNEL_UUID_LOG(data->uuid), SWITCH_LOG_ERROR, "Can't open %s! [%s]\n",
path, switch_strerror_r(errno, ebuf, sizeof(ebuf)));
-
+
}
switch_safe_free(path);
}
}
} else {
switch_log_printf(SWITCH_CHANNEL_UUID_LOG(data->uuid), SWITCH_LOG_NOTICE, "Not writing to file\n");
- }
+ }
}
-
-void destroy_cdr_data(cdr_data_t *data)
+
+void destroy_cdr_data(cdr_data_t *data)
{
switch_safe_free(data->json_text);
switch_safe_free(data->json_text_escaped);
curl_json_text = switch_mprintf("cdr=%s", data->json_text_escaped);
switch_assert(curl_json_text != NULL);
-
+
} else {
headers = switch_curl_slist_append(headers, "Content-Type: application/json");
curl_json_text = (char *)data->json_text;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error Generating Data!\n");
return SWITCH_STATUS_FALSE;
}
-
+
cdr_data = malloc(sizeof(cdr_data_t));
switch_assert(cdr_data);
-
+
json_text = cJSON_PrintUnformatted(json_cdr);
if (globals.url_count && globals.encode) {
switch_size_t need_bytes = strlen(json_text) * 3;
-
+
json_text_escaped = malloc(need_bytes);
switch_assert(json_text_escaped);
memset(json_text_escaped, 0, need_bytes);
if (switch_queue_trypush(globals.queue, cdr_data) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Unable to push cdr to queue\n");
backup_cdr(cdr_data);
- destroy_cdr_data(cdr_data);
+ destroy_cdr_data(cdr_data);
}
} else {
process_cdr(cdr_data);
}
-
+
cJSON_Delete(json_cdr);
return SWITCH_STATUS_SUCCESS;
globals.base_err_log_dir[globals.err_dir_count++] = switch_core_sprintf(globals.pool, "%s%s%s", SWITCH_GLOBAL_dirs.log_dir, SWITCH_PATH_SEPARATOR, val);
}
}
-
+
}
} else if (!strcasecmp(var, "enable-cacert-check") && switch_true(val)) {
globals.enable_cacert_check = 1;
}
switch_safe_free(globals.log_dir);
-
+
for (;err_dir_index < globals.err_dir_count; err_dir_index++) {
switch_safe_free(globals.err_log_dir[err_dir_index]);
}
cmd_used = (char *) cmd;
arg_used = (char *) arg;
-
+
if (!stream->param_event) {
switch_event_create(&stream->param_event, SWITCH_EVENT_API);
if (cmd_used != cmd) {
switch_safe_free(cmd_used);
}
-
+
if (arg_used != arg) {
switch_safe_free(arg_used);
}
char *full_path = NULL;
switch_stream_handle_t stream_field = { 0 };
switch_stream_handle_t stream_value = { 0 };
- switch_bool_t insert_fail = SWITCH_FALSE;
+ switch_bool_t insert_fail = SWITCH_FALSE;
SWITCH_STANDARD_STREAM(stream_field);
SWITCH_STANDARD_STREAM(stream_value);
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Chris Parker <cparker@segv.org>
* Mathieu Rene <mrene@avgs.ca>
*
return SWITCH_STATUS_TERM;
}
*/
-
+
if ((signal_bond = switch_channel_get_partner_uuid(channel)) && !zstr(signal_bond)) {
if (rc_avpair_add(rad_config, &send, PW_FS_OTHER_LEG_ID, (void*) signal_bond, -1, PW_FS_PEC) == NULL) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "[mod_radius_cdr] Failed adding Freeswitch-Other-Leg-Id: %s\n", uuid_str);
rc_destroy(rad_config);
goto end;
}
-
+
{
const char *direction_str = profile->direction == SWITCH_CALL_DIRECTION_INBOUND ? "inbound" : "outbound";
-
+
if (rc_avpair_add(rad_config, &send, PW_FS_DIRECTION, (void *) direction_str, -1, PW_FS_PEC) == NULL) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Direction: %s\n", direction_str);
rc_destroy(rad_config);
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Chris Parker <cparker AT segv.org>
*
* Description: Contains definitions and structs used by the radius cdr module.
hex_digit[1] = hex_buf[i + 1];
bin_buf[i / 2] = strtol(hex_digit, NULL, 16);
}
-
+
switch_b64_encode(bin_buf, SHA_1_HASH_BUF_SIZE / 2, (unsigned char *)buf, SHA_1_HASH_BUF_SIZE);
}
}
}
if (!call) {
- /* this scenario can only happen if a call was originated through a mechanism other than <dial>
+ /* this scenario can only happen if a call was originated through a mechanism other than <dial>
and then the rayo APP was executed to offer control */
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Outbound call that wasn't created with <dial>, will try to offer control\n");
}
return SWITCH_STATUS_TERM;
}
-
+
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Loading module\n");
* Shutdown module. Notifies threads to stop.
*/
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_rayo_shutdown)
-{
+{
switch_status_t result;
switch_event_free_subclass("rayo::cpa");
}
/**
- * Handle hungup call event
+ * Handle hungup call event
*/
static void on_channel_hangup_complete_event(switch_event_t *event)
{
/* acknowledge command */
rayo_component_send_start(RAYO_COMPONENT(component), iq);
- /* TODO hangup race condition */
+ /* TODO hangup race condition */
subscribe(switch_core_session_get_uuid(session), "hangup", RAYO_JID(component));
/* ready to forward detector events */
rayo_actor_command_handler_add(RAT_CALL_COMPONENT, "cpa", "set:"RAYO_EXT_NS":stop", stop_cpa_component);
switch_event_bind("rayo_cpa_component", SWITCH_EVENT_CUSTOM, "rayo::cpa", on_rayo_cpa_detector_event, NULL);
switch_event_bind("rayo_cpa_component", SWITCH_EVENT_CHANNEL_HANGUP_COMPLETE, NULL, on_channel_hangup_complete_event, NULL);
-
+
globals.pool = pool;
switch_core_hash_init(&globals.subscribers);
switch_mutex_init(&globals.subscribers_mutex, SWITCH_MUTEX_NESTED, pool);
cmd_dup = strdup(cmd);
argc = switch_separate_string(cmd_dup, ' ', argv, sizeof(argv) / sizeof(argv[0]));
-
+
if (argc != 3) {
stream->write_function(stream, "-ERR: USAGE %s\n", RAYO_CPA_DETECTOR_SYNTAX);
} else {
switch_hash_index_t *hi;
switch_mutex_lock(handler->mutex);
-
+
/* check input on each component */
for (hi = switch_core_hash_first(handler->dtmf_components); hi; hi = switch_core_hash_next(&hi)) {
const void *jid;
} else {
*authzid = strdup(decoded);
}
-
+
end:
switch_safe_free(decoded);
}
if (zstr(gw_name)) {
gw_name = "default";
}
-
+
gateway = switch_core_hash_find(mod_smpp_globals.gateways, gw_name);
if (!gateway) {
if (switch_event_create(&message, SWITCH_EVENT_MESSAGE) != SWITCH_STATUS_SUCCESS) {
return;
}
-
+
/* Copy over recognized channel vars. Then call the chat send function */
/* Cycle through all of the channel headers, and ones with 'smpp_' prefix copy over without the prefix */
for ( chan_var = switch_channel_variable_first(channel); chan_var; chan_var = chan_var->next) {
if ( !strncmp(chan_var->name, "smpp_", 5) ) {
switch_event_add_header_string(message, SWITCH_STACK_BOTTOM, chan_var->name + 5, chan_var->value);
} else {
- switch_event_add_header_string(message, SWITCH_STACK_BOTTOM, chan_var->name, chan_var->value);
+ switch_event_add_header_string(message, SWITCH_STACK_BOTTOM, chan_var->name, chan_var->value);
}
}
-
+
/* Unlock the channel variables */
switch_channel_variable_last(channel);
mod_smpp_chat_send_function(message, data);
if (switch_event_create(&message, SWITCH_EVENT_MESSAGE) != SWITCH_STATUS_SUCCESS) {
switch_goto_status(SWITCH_STATUS_GENERR, done);
}
-
+
switch_event_add_header_string(message, SWITCH_STACK_BOTTOM, "to_user", argv[1]);
switch_event_add_header_string(message, SWITCH_STACK_BOTTOM, "from_user", argv[2]);
switch_event_set_body(message, argv[3]);
done:
switch_safe_free(cmd_dup);
return status;
-
+
}
-switch_status_t mod_smpp_do_config()
+switch_status_t mod_smpp_do_config()
{
char *conf = "smpp.conf";
switch_xml_t xml, cfg, gateways, gateway, params, param;
}
if ( (gateways = switch_xml_child(cfg, "gateways")) != NULL) {
- for (gateway = switch_xml_child(gateways, "gateway"); gateway; gateway = gateway->next) {
+ for (gateway = switch_xml_child(gateways, "gateway"); gateway; gateway = gateway->next) {
mod_smpp_gateway_t *new_gateway = NULL;
char *host = NULL, *system_id = NULL, *password = NULL, *profile = NULL, *system_type = NULL;
int port = 0, debug = 0;
-
+
char *name = (char *)switch_xml_attr_soft(gateway, "name");
// Load params
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Gateways config is missing\n");
goto err;
}
-
+
return SWITCH_STATUS_SUCCESS;
-
+
err:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Configuration failed\n");
return SWITCH_STATUS_GENERR;
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
-
+
memset(&mod_smpp_globals, 0, sizeof(mod_smpp_globals_t));
mod_smpp_globals.pool = pool;
mod_smpp_globals.debug = 0;
switch_core_hash_init(&(mod_smpp_globals.gateways));
-
+
if ( mod_smpp_do_config() != SWITCH_STATUS_SUCCESS ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to load due to bad configs\n");
return SWITCH_STATUS_TERM;
SWITCH_ADD_CHAT(mod_smpp_chat_interface, "smpp", mod_smpp_interface_chat_send);
SWITCH_ADD_API(mod_smpp_api_interface, "smpp_debug", "mod_smpp toggle debug", mod_smpp_debug_api, NULL);
SWITCH_ADD_API(mod_smpp_api_interface, "smpp_send", "mod_smpp send", mod_smpp_send_api, NULL);
- SWITCH_ADD_CHAT_APP(mod_smpp_chat_app_interface, "smpp_send", "send message to gateway", "send message to gateway",
+ SWITCH_ADD_CHAT_APP(mod_smpp_chat_app_interface, "smpp_send", "send message to gateway", "send message to gateway",
mod_smpp_chat_send_function, "", SCAF_NONE);
- SWITCH_ADD_APP(mod_smpp_app_interface, "smpp_send", NULL, NULL, mod_smpp_app_send_function,
+ SWITCH_ADD_APP(mod_smpp_app_interface, "smpp_send", NULL, NULL, mod_smpp_app_send_function,
"smpp_send", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
/* indicate that the module should continue to be loaded */
/* mod_smpp_gateway.c */
switch_status_t mod_smpp_gateway_authenticate(mod_smpp_gateway_t *gateway);
switch_status_t mod_smpp_gateway_connect(mod_smpp_gateway_t *gateway);
-switch_status_t mod_smpp_gateway_create(mod_smpp_gateway_t **gw, char *name, char*host, int port, int debug, char *system_id,
+switch_status_t mod_smpp_gateway_create(mod_smpp_gateway_t **gw, char *name, char*host, int port, int debug, char *system_id,
char *password, char *system_type, char *profile);
switch_status_t mod_smpp_gateway_destroy(mod_smpp_gateway_t **gateway);
switch_status_t mod_smpp_gateway_send_message(mod_smpp_gateway_t *gateway, switch_event_t *message);
static void *SWITCH_THREAD_FUNC mod_smpp_gateway_read_thread(switch_thread_t *thread, void *obj);
-switch_status_t mod_smpp_gateway_create(mod_smpp_gateway_t **gw, char *name, char *host, int port, int debug, char *system_id,
+switch_status_t mod_smpp_gateway_create(mod_smpp_gateway_t **gw, char *name, char *host, int port, int debug, char *system_id,
char *password, char *system_type, char *profile) {
mod_smpp_gateway_t *gateway = NULL;
switch_memory_pool_t *pool = NULL;
-
+
switch_core_new_memory_pool(&pool);
gateway = switch_core_alloc(pool, sizeof(mod_smpp_gateway_t));
gateway->system_type = system_type ? switch_core_strdup(gateway->pool, system_type) : "freeswitch_smpp";
gateway->profile = profile ? switch_core_strdup(gateway->pool, profile) : "default";
- if ( switch_sockaddr_info_get(&(gateway->socketaddr), gateway->host, SWITCH_INET,
+ if ( switch_sockaddr_info_get(&(gateway->socketaddr), gateway->host, SWITCH_INET,
gateway->port, 0, mod_smpp_globals.pool) != SWITCH_STATUS_SUCCESS ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to get socketaddr info\n");
goto err;
}
- if ( switch_socket_create(&(gateway->socket), switch_sockaddr_get_family(gateway->socketaddr),
+ if ( switch_socket_create(&(gateway->socket), switch_sockaddr_get_family(gateway->socketaddr),
SOCK_STREAM, SWITCH_PROTO_TCP, mod_smpp_globals.pool) != SWITCH_STATUS_SUCCESS ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create the socket\n");
goto err;
switch_core_hash_insert(mod_smpp_globals.gateways, name, (void *) gateway);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Gateway %s created\n", gateway->host);
-
+
*gw = gateway;
return SWITCH_STATUS_SUCCESS;
req_b->addr_ton = 1;
strncpy( (char *)req_b->address_range, gateway->host, sizeof(req_b->address_range));
-
+
if ( gateway->system_id ) {
strncpy((char *)req_b->system_id, gateway->system_id, sizeof(req_b->system_id));
}
-
+
if ( gateway->password ) {
strncpy((char *)req_b->password, gateway->password, sizeof(req_b->password));
}
-
+
if ( gateway->system_type ) {
strncpy((char *)req_b->system_type, gateway->system_type, sizeof(req_b->system_type));
}
switch_goto_status(SWITCH_STATUS_GENERR, done);
}
- if( write_len != local_buffer_len ){
+ if( write_len != local_buffer_len ){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "smpp: Was not able to send entire buffer\n");
switch_goto_status(SWITCH_STATUS_GENERR, done);
}
if ( req_b ) {
switch_safe_free(req_b);
}
-
+
return status;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to connect the socket %d\n", status);
return SWITCH_STATUS_GENERR;
}
-
+
if ( mod_smpp_gateway_authenticate(gateway) != SWITCH_STATUS_SUCCESS ) {
return SWITCH_STATUS_GENERR;
}
switch_goto_status(SWITCH_STATUS_GENERR, done);
}
- if ( read_len != 4 ){
+ if ( read_len != 4 ){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error in recv(PEEK) %d\n", (unsigned int )read_len);
switch_goto_status(SWITCH_STATUS_GENERR, done);
}
read_len = ntohl(*local_buffer32 );
if ( read_len > 1500 ) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Corrupted PDU size from gateway [%s]\n", gateway->name);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Corrupted PDU size from gateway [%s]\n", gateway->name);
switch_goto_status(SWITCH_STATUS_GENERR, done);
}
case DELIVER_SM:
if ( gennack->command_status == ESME_ROK ) {
deliver_sm_t *res = (deliver_sm_t *) data;
-
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "New SMS received from[%s] to[%s] message[%s]\n",
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "New SMS received from[%s] to[%s] message[%s]\n",
res->source_addr, res->destination_addr, res->short_message);
-
+
mod_smpp_message_decode(gateway, res, &evt);
}
break;
- case ENQUIRE_LINK:
+ case ENQUIRE_LINK:
case ENQUIRE_LINK_RESP:
case SUBMIT_SM_RESP:
switch (gennack->command_status) {
*event = evt;
}
- done:
+ done:
switch_safe_free(local_buffer);
return status;
}
}
mod_smpp_gateway_send_deliver_sm_response(gateway, event);
-
+
switch_core_chat_send("smpp", event);
switch_event_destroy(&event);
/* Fire message to the chat plan, then respond */
if ( event ) {
char *str = NULL;
switch_event_serialize(event, &str, SWITCH_FALSE);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown packet event: %s\n", str);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown packet event: %s\n", str);
switch_safe_free(str);
}
}
switch_goto_status(SWITCH_STATUS_GENERR, done);
}
- if( write_len != local_buffer_len ){
+ if( write_len != local_buffer_len ){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "smpp: Was not able to send entire buffer\n");
switch_goto_status(SWITCH_STATUS_GENERR, done);
}
switch_goto_status(SWITCH_STATUS_GENERR, done);
}
- if( write_len != local_buffer_len ){
+ if( write_len != local_buffer_len ){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "smpp: Was not able to send entire buffer\n");
switch_goto_status(SWITCH_STATUS_GENERR, done);
}
switch_goto_status(SWITCH_STATUS_GENERR, done);
}
- if( write_len != local_buffer_len ){
+ if( write_len != local_buffer_len ){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "smpp: Was not able to send entire buffer\n");
switch_goto_status(SWITCH_STATUS_GENERR, done);
}
return status;
}
-switch_status_t mod_smpp_gateway_destroy(mod_smpp_gateway_t **gw)
+switch_status_t mod_smpp_gateway_destroy(mod_smpp_gateway_t **gw)
{
mod_smpp_gateway_t *gateway = NULL;
if ( !gw || !*gw ) {
return SWITCH_STATUS_SUCCESS;
}
-
+
gateway = *gw;
-
+
switch_core_hash_delete(mod_smpp_globals.gateways, gateway->name);
gateway->running = 0;
int local_buffer_len = sizeof(local_buffer);
switch_status_t status = SWITCH_STATUS_SUCCESS;
switch_size_t write_len = 0;
-
+
if ( mod_smpp_message_create(gateway, message, &msg) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to send message due to message_create failure\n");
switch_goto_status(SWITCH_STATUS_GENERR, done);
memset(local_buffer, 0, sizeof(local_buffer));
if( smpp34_pack2( local_buffer, sizeof(local_buffer), &local_buffer_len, (void*)&(msg->req)) != 0 ){
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "smpp: Unable to encode message:%d:\n%s\n", smpp34_errno, smpp34_strerror);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "smpp: Unable to encode message:%d:\n%s\n", smpp34_errno, smpp34_strerror);
switch_goto_status(SWITCH_STATUS_GENERR, done);
}
write_len = local_buffer_len;
if ( mod_smpp_gateway_get_next_sequence(gateway, &(msg->req.sequence_number)) ) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to fetch next gateway sequence number\n");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to fetch next gateway sequence number\n");
switch_goto_status(SWITCH_STATUS_GENERR, done);
}
switch_goto_status(SWITCH_STATUS_GENERR, done);
}
- if ( write_len != local_buffer_len ){
+ if ( write_len != local_buffer_len ){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "smpp: Did not send all of message to gateway");
switch_goto_status(SWITCH_STATUS_GENERR, done);
}
switch_status_t mod_smpp_message_encode_body(char *body, int length, unsigned char *bin, uint8_t *enc_length)
{
int i = 0;
-
+
for ( i = 0; i < length; i++ ) {
bin[i*2] = body[i] / 16;
bin[i*2 + 1] = body[i] % 16;
return SWITCH_STATUS_SUCCESS;
}
-/*
+/*
Scratch notes taken during development/interop:
char *message = "5361792048656c6c6f20746f204d79204c6974746c6520467269656e64";
''.join('%02x' % ord(c) for c in u'Скажите привет моему маленькому другу'.encode('utf16'))
- Variable length UTF-16 russian text:
+ Variable length UTF-16 russian text:
char *message = "fffe21043a043004360438044204350420003f044004380432043504420420003c043e0435043c04430420003c0430043b0435043d044c043a043e043c044304200034044004430433044304";
char *mesg_txt = "This is a test SMS message from FreeSWITCH over SMPP";
{
mod_smpp_message_t *msg = calloc(1, sizeof(mod_smpp_message_t));
char *body = switch_event_get_body(event);
-
+
assert(*message == NULL);
if ( !body ) {
msg->req.sm_default_msg_id = 0;
msg->req.data_coding = 0;
msg->req.source_addr_ton = 1;
- msg->req.source_addr_npi = 1;
+ msg->req.source_addr_npi = 1;
msg->req.dest_addr_ton = 1;
msg->req.dest_addr_npi = 1;
msg->req.esm_class = 1; /* 0 => default, 1 => datagram, 2 => forward(transaction), 3 => store and forward
snprintf((char *)msg->req.short_message, sizeof(msg->req.short_message), "%s", body);
msg->req.sm_length = strlen(body);
- if ( 0 && mod_smpp_message_encode_body(body, strlen(body),
+ if ( 0 && mod_smpp_message_encode_body(body, strlen(body),
(unsigned char *) &(msg->req.short_message), &(msg->req.sm_length)) != SWITCH_STATUS_SUCCESS ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to encode message body\n");
goto err;
char *str = NULL;
if (switch_event_create(&evt, SWITCH_EVENT_MESSAGE) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create new event\n");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create new event\n");
}
switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM, "endpoint", "mod_smpp");
switch_status_t mod_smpp_message_destroy(mod_smpp_message_t **msg)
{
if ( msg ) {
- switch_safe_free(*msg);
+ switch_safe_free(*msg);
}
return SWITCH_STATUS_SUCCESS;
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* Contributor(s):
* Daniel Swarbrick <daniel.swarbrick@gmail.com>
* Stefan Knoblich <s.knoblich@axsentis.de>
- *
+ *
* mod_snmp.c -- SNMP AgentX Subagent Module
*
*/
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* Contributor(s):
* Daniel Swarbrick <daniel.swarbrick@gmail.com>
* Stefan Knoblich <s.knoblich@axsentis.de>
- *
+ *
* mod_snmp.c -- SNMP AgentX Subagent Module
*
*/
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* Contributor(s):
* Daniel Swarbrick <daniel.swarbrick@gmail.com>
* Stefan Knoblich <s.knoblich@axsentis.de>
- *
+ *
* subagent.h -- SNMP Agent Definitions
*
*/
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Cesar Cepeda <cesar@auronix.com>
* Emmanuel Schmidbauer <e.schmidbauer@gmail.com>
const void *vvar;
switch_console_callback_match_t *my_matches = NULL;
switch_status_t status = SWITCH_STATUS_FALSE;
-
+
switch_mutex_lock(globals.mutex);
for (hi = switch_core_hash_first(globals.source_hash); hi; hi = switch_core_hash_next(&hi)) {
switch_core_hash_this(hi, &vvar, NULL, &val);
switch_console_push_match(&my_matches, (const char *) vvar);
}
switch_mutex_unlock(globals.mutex);
-
+
if (my_matches) {
*matches = my_matches;
status = SWITCH_STATUS_SUCCESS;
}
-
+
return status;
}
while (RUNNING && !source->stopped && source->ready) {
const char *fname;
-
+
if (source->dir_handle) {
switch_dir_close(source->dir_handle);
source->dir_handle = NULL;
if ((p = strrchr(tmp_buf, '/'))) {
*p++ = '\0';
- switch_snprintf(png_buf, sizeof(png_buf), "%s/art/%s.png", tmp_buf, p);
+ switch_snprintf(png_buf, sizeof(png_buf), "%s/art/%s.png", tmp_buf, p);
if (switch_file_exists(png_buf, temp_pool) == SWITCH_STATUS_SUCCESS) {
source->cover_art = switch_img_read_png(png_buf, SWITCH_IMG_FMT_I420);
}
source->serno++;
switch_safe_free(source->banner_txt);
title = artist = NULL;
-
+
switch_core_file_get_string(&fh, SWITCH_AUDIO_COL_STR_ARTIST, &artist);
switch_core_file_get_string(&fh, SWITCH_AUDIO_COL_STR_TITLE, &title);
if (!title && !artist) {
char *e, *p, *args[3];
int argc;
-
+
switch_set_string(tmp_space, path_buf);
p = tmp_space;
-
+
while((e = strchr(p, '/'))) {
*e = '\0';
p = e+1;
}
argc = switch_split(p, '-', args);
-
+
if (argc > 0) {
while(*args[0] == ' ') {
args[0]++;
while(end_of(args[0]) == ' ') {
end_of(args[0]) = '\0';
}
-
+
artist = args[0];
if (argc > 1) {
artist = NULL;
}
}
-
+
if (title && (source->cover_art || switch_core_file_has_video(&fh, SWITCH_TRUE))) {
const char *format = "#cccccc:#333333:FreeSans.ttf:3%:";
-
+
if (artist) {
source->banner_txt = switch_mprintf("%s%s (%s)", format, title, artist);
} else {
source->banner_txt = switch_mprintf("%s%s", format, title);
}
}
-
+
while (RUNNING && !source->stopped) {
int is_open;
switch_core_timer_next(&source->timer);
olen = source->samples;
-
+
if (source->chime_total) {
if (source->chime_counter > 0) {
source->chime_counter -= (int32_t)source->samples;
}
-
+
if (!switch_test_flag((&source->chime_fh), SWITCH_FILE_OPEN) && source->chime_counter <= 0) {
char *val;
source->hup = 0;
if (is_open) {
is_open = 0;
-
+
switch_core_file_close(use_fh);
flush_video_queue(source->video_q);
switch_buffer_zero(audio_buffer);
if (use_fh == &source->chime_fh) {
source->chime_counter = source->rate * source->chime_freq;
switch_core_file_close(&fh);
- use_fh = &fh;
+ use_fh = &fh;
}
goto retry;
}
}
-
+
if (is_open) {
int svr = 0;
switch_core_file_read(&fh, source->abuf, &olen);
olen = source->samples;
}
-
+
switch_assert(source->abuflen >= olen * 2 * source->channels);
if (switch_core_file_read(use_fh, source->abuf, &olen) != SWITCH_STATUS_SUCCESS || !olen) {
goto retry;
}
}
-
+
if (source->total) {
if (source->energy_avg && source->agc) {
void *pop;
uint32_t bused = 0;
local_stream_context_t *cp = NULL;
-
+
switch_assert(source->abuflen <= source->prebuf);
used = switch_buffer_read(audio_buffer, dist_buf, source->abuflen);
-
+
switch_mutex_lock(source->mutex);
for (cp = source->context_list; cp && RUNNING; cp = cp->next) {
if (!cp->ready) {
continue;
}
-
+
switch_mutex_lock(cp->audio_mutex);
if (switch_test_flag(cp->handle, SWITCH_FILE_OPEN)) {
bused = (uint32_t)switch_buffer_inuse(cp->audio_buffer);
if (bused > source->samples * 768) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Flushing Stream Handle Buffer [%s() %s:%d] size: %u samples: %ld\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Flushing Stream Handle Buffer [%s() %s:%d] size: %u samples: %ld\n",
cp->func, cp->file, cp->line, bused, (long)source->samples);
switch_buffer_zero(cp->audio_buffer);
} else {
}
switch_mutex_unlock(source->mutex);
-
+
while (switch_queue_trypop(source->video_q, &pop) == SWITCH_STATUS_SUCCESS) {
switch_image_t *img;
switch_image_t *imgcp = NULL;
}
}
}
- }
+ }
switch_img_free(&img);
}
}
}
switch_safe_free(source->banner_txt);
-
+
if (switch_test_flag((&fh), SWITCH_FILE_OPEN)) {
switch_core_file_close(&fh);
}
//}
pool = handle->memory_pool;
-
+
if ((context = switch_core_alloc(pool, sizeof(*context))) == 0) {
abort();
}
goto end;
}
- if (!switch_core_has_video() ||
+ if (!switch_core_has_video() ||
(switch_test_flag(handle, SWITCH_FILE_FLAG_VIDEO) && !source->has_video && !source->blank_img && !source->cover_art && !source->banner_txt)) {
switch_clear_flag_locked(handle, SWITCH_FILE_FLAG_VIDEO);
}
last->next = cp->next;
} else {
source->context_list = cp->next;
- }
+ }
break;
}
last = cp;
}
switch_mutex_lock(context->audio_mutex);
-
+
if (source->has_video) {
flush_video_queue(context->video_q);
switch_queue_trypush(context->video_q, NULL);
switch_queue_interrupt_all(context->video_q);
flush_video_queue(context->video_q);
}
-
+
source->total--;
switch_img_free(&context->banner_img);
if (src_img) {
switch_image_t *img = NULL;
-
+
if (context->sent_png && --context->sent_png > 0) {
return SWITCH_STATUS_BREAK;
}
if (!(context->ready && context->source->ready)) {
return SWITCH_STATUS_FALSE;
}
-
+
while (!(flags & SVR_BLOCK) && switch_queue_size(context->video_q) < buf_qsize) {
return SWITCH_STATUS_BREAK;
}
switch_img_fill(frame->img, 0, 0, frame->img->d_w, frame->img->d_h, &bgcolor);
context->pop_count--;
}
-
+
now = switch_micro_time_now();
if (context->banner_img) {
context->serno = context->source->serno;
context->pop_count = 5;
}
-
+
if (context->source->banner_txt) {
if ((!context->banner_timeout || context->banner_timeout >= now)) {
if (context->newres) {
switch_img_overlay(frame->img, context->banner_img, 0, frame->img->d_h - context->banner_img->d_h, context->source->text_opacity);
}
- if (frame->img && context->source->logo_img &&
+ if (frame->img && context->source->logo_img &&
(context->source->logo_always || context->banner_img) && frame->img->d_w >= context->source->logo_img->d_w) {
int x = 0, y = 0;
-
+
switch_img_find_position(context->source->logo_pos,
- frame->img->d_w, frame->img->d_h,
+ frame->img->d_w, frame->img->d_h,
context->source->logo_img->d_w, context->source->logo_img->d_h,
&x, &y);
*len = 0;
return SWITCH_STATUS_FALSE;
}
-
+
if (context->source->has_video) {
if (!switch_test_flag(handle, SWITCH_FILE_FLAG_VIDEO)) {
switch_set_flag_locked(handle, SWITCH_FILE_FLAG_VIDEO);
*len = bytes / 2 / context->source->channels;
} else {
size_t blank;
-
+
switch_assert(handle->samplerate <= 48000);
switch_assert(handle->real_channels <= 2);
stream->write_function(stream, "+OK stream: %s", local_stream_name);
}
}
-
+
} else if (!strcasecmp(argv[0], "show")) {
switch_hash_index_t *hi;
const void *var;
}
}
}
-
+
goto done;
-
+
usage:
stream->write_function(stream, "-USAGE: %s\n", LOCAL_STREAM_SYNTAX);
-
+
done:
switch_safe_free(mycmd);
if (!launch_streams(NULL)) {
return SWITCH_STATUS_GENERR;
}
-
+
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
file_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_FILE_INTERFACE);
file_interface->interface_name = modname;
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2015, Anthony Minessale II <anthm@freeswitch.org>
*
return SWITCH_STATUS_GENERR;
}
ext++;
-
+
if ((context = (png_file_context_t *)switch_core_alloc(handle->memory_pool, sizeof(png_file_context_t))) == 0) {
return SWITCH_STATUS_MEMERR;
}
status = SWITCH_STATUS_FALSE;
switch_goto_status(status, end);
}
-
+
memset(data, 0, *len * 2 * handle->channels);
end:
switch_img_write_png(frame->img, data->path);
return SWITCH_FALSE;
}
-
+
if (!data->write_img) {
switch_img_copy(frame->img, &data->write_img);
}
stream->write_function(stream, "-USAGE: <uuid> <path> [concat | split <other_path>]\n");
goto end;
}
-
+
uuid = argv[0];
if (!(session_ = switch_core_session_locate(uuid))) {
SWITCH_ADD_API(api_interface, "uuid_write_png", "grab an image from a call",uuid_write_png_function, "");
switch_console_set_complete("add uuid_write_png ::console::list_uuid");
-
+
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
* mod_shell_stream.c -- Local Streaming Audio
if (context->thread) {
switch_thread_join(&st, context->thread);
}
-
+
if (context->audio_buffer) {
switch_buffer_destroy(&context->audio_buffer);
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Rupa Schomaker <rupa@rupa.com>
* John Wehle <john@feith.com>
switch_mutex_lock(context->audio_mutex);
context->curlfd = curlfd;
switch_mutex_unlock(context->audio_mutex);
-
+
return 0;
}
}
context->channels = handle->channels;
-
+
if (globals.brate) {
lame_set_brate(context->gfp, globals.brate);
} else {
lame_set_brate(context->gfp, 16 * (handle->samplerate / 8000) * handle->channels);
}
-
+
lame_set_num_channels(context->gfp, handle->channels);
lame_set_in_samplerate(context->gfp, handle->samplerate);
-
+
if (globals.resample) {
lame_set_out_samplerate(context->gfp, globals.resample);
} else {
} else {
const char *mask = "wb+";
-
+
if (switch_test_flag(handle, SWITCH_FILE_WRITE_APPEND)) {
mask = "ab+";
}
if (newbytes < bytes) {
bytes = newbytes;
}
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Padding mp3 stream with %ds of empty audio. (%s)\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Padding mp3 stream with %ds of empty audio. (%s)\n",
context->buffer_seconds, context->stream_url);
memset(data, 255, bytes);
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
handle->pos = sf_seek(context->handle, frames, SEEK_END);
} else if (switch_test_flag(handle, SWITCH_FILE_WRITE_OVER)) {
handle->pos = sf_seek(context->handle, frames, SEEK_SET);
- } else {
+ } else {
sf_command(context->handle, SFC_FILE_TRUNCATE, &frames, sizeof(frames));
}
sndfile_context *context = handle->private_info;
sf_count_t count;
switch_status_t r = SWITCH_STATUS_SUCCESS;
-
+
if (!handle->seekable) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "File is not seekable\n");
return SWITCH_STATUS_NOTIMPL;
r = SWITCH_STATUS_BREAK;
count = sf_seek(context->handle, -1, SEEK_END);
}
-
+
*cur_sample = (unsigned int) count;
- handle->pos = *cur_sample;
-
+ handle->pos = *cur_sample;
+
return r;
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
}
sh = switch_core_alloc(handle->memory_pool, sizeof(*sh));
-
+
if (ms > 0) {
sh->samples = (handle->samplerate / 1000) * ms;
} else {
if (handle->params) {
if ((tmp = switch_event_get_header(handle->params, "loops"))) {
loops = atoi(tmp);
- switch_buffer_set_loops(audio_buffer, loops);
+ switch_buffer_set_loops(audio_buffer, loops);
}
}
* To playback a video file
* play_video /tmp/test.mp4
*
- * Notes:
+ * Notes:
*
* Audio Requires at least libvlc version 1.2
* Video Requires at least libvlc 2.0.2
ret = switch_vasprintf(&ldata, fmt, args);
if (ret == -1) return;
-
+
if (end_of(ldata) == '\n') {
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, fslevel, "VLC: %s", ldata);
} else {
switch_safe_free(ldata);
}
-
+
void yuyv_to_i420(uint8_t *pixels, void *out_buffer, int src_width, int src_height)
libvlc_media_list_t *ml = libvlc_media_subitems(vcontext->m);
if (ml) {
int i, count = libvlc_media_list_count(ml);
-
+
for (i = 0; i < count; i++) {
libvlc_media_t *media = libvlc_media_list_item_at_index(ml, i);
if (media) return media;
switch_assert(context->img);
yuyv_to_i420(*p_pixels, context->img->img_data, context->width, context->height);
-
+
switch_mutex_unlock(context->video_mutex);
}
if (context->channel && !switch_channel_test_flag(context->channel, CF_VIDEO)) return;
if (!context->img) context->img = switch_img_alloc(NULL, SWITCH_IMG_FMT_I420, context->width, context->height, 0); switch_assert(context->img);
-
+
yuyv_to_i420(*p_pixels, context->img->img_data, context->width, context->height);
switch_mutex_unlock(context->video_mutex);
vlc_file_context_t *context = (vlc_file_context_t *) data;
//int samples = 0;
int bytes = 0, bread = 0, blen = 0;
-
+
if (context->playing == 0) return -1;
switch_mutex_lock(context->audio_mutex);
blen = switch_buffer_inuse(context->audio_buffer);
-
+
if (!(bytes = blen)) {
*size = 0;
*output = NULL;
bread = switch_buffer_read(context->audio_buffer, *output, bytes);
switch_mutex_unlock(context->audio_mutex);
-
+
*size = (size_t) bread;
return 0;
//free(unknown);
}
-static switch_status_t av_init_handle(switch_file_handle_t *handle, switch_image_t *img)
+static switch_status_t av_init_handle(switch_file_handle_t *handle, switch_image_t *img)
{
switch_memory_pool_t *pool;
char *imem_main, *imem_slave;
switch_mutex_init(&vcontext->video_mutex, SWITCH_MUTEX_NESTED, vcontext->pool);
switch_thread_cond_create(&vcontext->cond, vcontext->pool);
switch_thread_cond_create(&acontext->cond, acontext->pool);
-
+
switch_core_timer_init(&vcontext->timer, "soft", 1, 1000, vcontext->pool);
vcontext->timer.start -= 60000000;
switch_core_timer_sync(&vcontext->timer);
"samplerate=%d:"
"channels=%d:"
"id=1:"
- "caching=0",
+ "caching=0",
vcontext->samplerate, vcontext->channels);
-
+
vcontext->m = libvlc_media_new_location(acontext->vlc_handle, imem_main);
-
- libvlc_media_add_option_flag( vcontext->m, imem_slave, libvlc_media_option_trusted );
+
+ libvlc_media_add_option_flag( vcontext->m, imem_slave, libvlc_media_option_trusted );
if (vcontext->m == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "VLC error opening %s for writing\n", acontext->path);
return SWITCH_STATUS_FALSE;
}
-
+
vcontext->mp = libvlc_media_player_new_from_media(vcontext->m);
vcontext->samples = 0;
vcontext->pts = 0;
-
+
acontext->vcontext = vcontext;
-
+
return SWITCH_STATUS_SUCCESS;
}
vcontext->playing = 0;
vcontext->err = 0;
-
+
vcontext->mp = libvlc_media_player_new_from_media(vcontext->m);
if (!handle->samplerate) {
vcontext->channels = handle->channels;
libvlc_audio_set_format(vcontext->mp, "S16N", vcontext->samplerate, handle->channels);
-
+
m_event_manager = libvlc_media_event_manager(vcontext->m);
libvlc_event_attach(m_event_manager, libvlc_MediaStateChanged, vlc_media_av_state_callback, (void *) acontext);
if (handle->mm.fps > 0.0f) {
handle->mm.keyint = (int) 2.0f * handle->mm.fps;
}
-
- path = switch_core_sprintf(context->pool,
+
+ path = switch_core_sprintf(context->pool,
"#transcode{"
"venc=x264{keyint=%d},"
"vcodec=h264,"
"access=avio,"
"mux=flv,"
"dst=rtmp://%s"
- "}",
+ "}",
handle->mm.keyint, handle->mm.ab, handle->mm.vb, handle->mm.channels, handle->mm.samplerate, path);
}
context->path = switch_core_strdup(context->pool, path);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "VLC attempt to open %s %s %s %s\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "VLC attempt to open %s %s %s %s\n",
context->path, switch_test_flag(handle, SWITCH_FILE_FLAG_READ) ? "read" : "",
switch_test_flag(handle, SWITCH_FILE_FLAG_WRITE) ? "write" : "",
switch_test_flag(handle, SWITCH_FILE_FLAG_VIDEO) ? "video" : ""
context->channels = handle->channels;
libvlc_audio_set_format(context->mp, "S16N", context->samplerate, handle->channels);
-
+
m_event_manager = libvlc_media_event_manager(context->m);
libvlc_event_attach(m_event_manager, libvlc_MediaStateChanged, vlc_media_state_callback, (void *) context);
mp_event_manager = libvlc_media_player_event_manager(context->mp);
libvlc_event_attach(mp_event_manager, libvlc_MediaPlayerEncounteredError, vlc_mediaplayer_error_callback, (void *) context);
-
+
libvlc_audio_set_callbacks(context->mp, vlc_auto_play_callback, NULL,NULL,NULL,NULL, (void *) context);
libvlc_media_player_play(context->mp);
switch_core_sprintf(context->pool, "--sout=%s", path)
};
int opts_count = 2;
-
+
if ( !handle->samplerate)
handle->samplerate = 16000;
-
+
context->samplerate = handle->samplerate;
context->channels = handle->channels;
}
if (!is_stream && switch_test_flag(handle, SWITCH_FILE_FLAG_VIDEO)) {
- if (switch_file_open(&fd, realpath, SWITCH_FOPEN_WRITE | SWITCH_FOPEN_CREATE | SWITCH_FOPEN_TRUNCATE,
+ if (switch_file_open(&fd, realpath, SWITCH_FOPEN_WRITE | SWITCH_FOPEN_CREATE | SWITCH_FOPEN_TRUNCATE,
SWITCH_FPROT_UREAD | SWITCH_FPROT_UWRITE, handle->memory_pool) == SWITCH_STATUS_SUCCESS) {
switch_file_close(fd);
} else {
return SWITCH_STATUS_GENERR;
}
}
-
+
return SWITCH_STATUS_SUCCESS;
}
}
status = libvlc_media_get_state(vcontext->m);
-
+
if (status == libvlc_Error) {
vcontext->err = acontext->err = 1;
return SWITCH_STATUS_GENERR;
}
-
+
while (!vcontext->err && vcontext->playing == 0) {
libvlc_media_t *newmedia;
- switch_mutex_lock(acontext->cond_mutex);
- switch_thread_cond_wait(acontext->cond, acontext->cond_mutex);
- switch_mutex_unlock(acontext->cond_mutex);
+ switch_mutex_lock(acontext->cond_mutex);
+ switch_thread_cond_wait(acontext->cond, acontext->cond_mutex);
+ switch_mutex_unlock(acontext->cond_mutex);
//switch_yield(50000);
if (status == 6) {
int done = 1;
newmedia = get_list_media(vcontext);
-
+
if (newmedia) {
libvlc_event_manager_t *m_event_manager;
-
+
libvlc_media_player_set_media(vcontext->mp, newmedia);
libvlc_media_release(vcontext->m);
vcontext->m = newmedia;
-
+
m_event_manager = libvlc_media_event_manager(vcontext->m);
- libvlc_event_attach(m_event_manager, libvlc_MediaStateChanged, vlc_media_av_state_callback, (void *) acontext);
+ libvlc_event_attach(m_event_manager, libvlc_MediaStateChanged, vlc_media_av_state_callback, (void *) acontext);
if (libvlc_media_player_play(vcontext->mp) != -1) {
done = 0;
switch_mutex_lock(vcontext->audio_mutex);
read = switch_buffer_read(vcontext->audio_buffer, data, bytes);
switch_mutex_unlock(vcontext->audio_mutex);
-
+
status = libvlc_media_get_state(vcontext->m);
if (!read && (status == libvlc_Stopped || status == libvlc_Ended || status == libvlc_Error)) {
}
status = libvlc_media_get_state(context->m);
-
+
if (status == libvlc_Error) {
return SWITCH_STATUS_GENERR;
}
- switch_mutex_lock(context->cond_mutex);
+ switch_mutex_lock(context->cond_mutex);
while (context->playing == 0 && status != libvlc_Ended && status != libvlc_Error) {
- switch_thread_cond_wait(context->cond, context->cond_mutex);
+ switch_thread_cond_wait(context->cond, context->cond_mutex);
status = libvlc_media_get_state(context->m);
}
- switch_mutex_lock(context->cond_mutex);
+ switch_mutex_lock(context->cond_mutex);
if (context->err == 1) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "VLC error\n");
return SWITCH_STATUS_FALSE;
}
- switch_mutex_lock(context->audio_mutex);
+ switch_mutex_lock(context->audio_mutex);
read = switch_buffer_read(context->audio_buffer, data, bytes);
switch_mutex_unlock(context->audio_mutex);
-
+
status = libvlc_media_get_state(context->m);
if (!read && (status == libvlc_Stopped || status == libvlc_Ended || status == libvlc_Error)) {
if (vcontext->err) {
return SWITCH_STATUS_FALSE;
}
-
+
if ((flags & SVR_CHECK)) {
return SWITCH_STATUS_BREAK;
}
if (vcontext->err) {
return SWITCH_STATUS_FALSE;
}
-
+
if ((flags & SVR_BLOCK)) {
status = switch_queue_pop(vcontext->video_queue, &pop);
} else {
if (frame->img) {
switch_image_t *img_copy = NULL;
vlc_frame_data_t *fdata = NULL;
-
+
switch_img_copy(frame->img, &img_copy);
switch_zmalloc(fdata, sizeof(*fdata));
if (!vcontext) {
return SWITCH_STATUS_SUCCESS;
- }
+ }
if (!vcontext->vid_ready) {
return SWITCH_STATUS_SUCCESS;
if (!vcontext->playing) {
- vcontext->playing = 1;
+ vcontext->playing = 1;
libvlc_media_player_play(vcontext->mp);
}
switch_mutex_lock(context->audio_mutex);
context->samples += *len;
switch_buffer_write(context->audio_buffer, data, bytes);
- switch_mutex_unlock(context->audio_mutex);
+ switch_mutex_unlock(context->audio_mutex);
if (!context->playing) {
- context->playing = 1;
+ context->playing = 1;
libvlc_media_player_play(context->mp);
}
return SWITCH_STATUS_FALSE;
}
}
-
+
vcontext->ending = 1;
if (vcontext && vcontext->video_queue) {
switch_queue_push(vcontext->video_queue, NULL);
}
-
+
if (switch_test_flag(handle, SWITCH_FILE_FLAG_WRITE) && switch_test_flag(handle, SWITCH_FILE_FLAG_VIDEO)) {
if (vcontext->cond && switch_mutex_trylock(vcontext->cond_mutex) == SWITCH_STATUS_SUCCESS) {
while((vcontext->audio_buffer && switch_buffer_inuse(vcontext->audio_buffer)) || switch_queue_size(vcontext->video_queue)) {
libvlc_state_t status = libvlc_media_get_state(vcontext->m);
-
+
if (status == libvlc_Ended || status == libvlc_Error || status == libvlc_Stopped ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "VLC done. status = %d\n", status);
break;
switch(command) {
case SCFC_FLUSH_AUDIO:
- switch_mutex_lock(context->audio_mutex);
+ switch_mutex_lock(context->audio_mutex);
switch_buffer_zero(context->audio_buffer);
- switch_mutex_unlock(context->audio_mutex);
+ switch_mutex_unlock(context->audio_mutex);
break;
default:
break;
if (switch_test_flag(handle, SWITCH_FILE_FLAG_VIDEO)) {
return vlc_file_av_close(handle);
}
-
+
context->playing = 0;
libvlc_media_player_stop(context->mp);
switch_mutex_unlock(context->audio_mutex);
if (context->m) libvlc_media_release(context->m);
-
+
if (context->vlc_handle) libvlc_release(context->vlc_handle);
return SWITCH_STATUS_SUCCESS;
if( context->mp ) libvlc_media_player_stop(context->mp);
if( context->m ) libvlc_media_release(context->m);
-
+
context->playing = 0;
switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE, "OK");
int r = 0;
if (!context->ending) {
- switch_mutex_lock(context->cond_mutex);
+ switch_mutex_lock(context->cond_mutex);
//while (!switch_queue_size(context->video_queue)) {
// switch_yield(20000);
//}
//if (!switch_queue_size(context->video_queue)) {
- // switch_thread_cond_wait(context->cond, context->cond_mutex);
+ // switch_thread_cond_wait(context->cond, context->cond_mutex);
//}
- switch_mutex_unlock(context->cond_mutex);
+ switch_mutex_unlock(context->cond_mutex);
}
-
+
if (*cookie == 'v') {
switch_image_t *img = NULL;
vlc_frame_data_t *fdata = NULL;
void *pop;
-
+
if (switch_queue_trypop(context->video_queue, &pop) == SWITCH_STATUS_SUCCESS && pop) {
img = (switch_image_t *) pop;
} else {
goto nada;
}
-
+
fdata = (vlc_frame_data_t *) img->user_priv;
-
+
*dts = *pts = fdata->pts;
*size = img->d_w * img->d_h * 2;
context->video_frame_buffer_len = *size;
context->video_frame_buffer = switch_core_alloc(context->pool, context->video_frame_buffer_len);
}
-
+
*output = context->video_frame_buffer;
switch_img_to_raw(img, *output, 0, SWITCH_IMG_FMT_YUY2);
switch_img_free(&img);
switch_mutex_lock(context->audio_mutex);
if (context->sync_offset < 0 && !context->sync_ready) {
uint32_t need = (context->samplerate / 1000) * abs(context->sync_offset / 1000) * context->channels * 2;
-
+
if (context->audio_frame_buffer_len < need) {
context->audio_frame_buffer_len = need;
context->audio_frame_buffer = switch_core_alloc(context->pool, context->audio_frame_buffer_len);
}
-
+
memset(context->audio_frame_buffer, 0, need);
*pts = *dts = context->pts;
*size = need;
switch_mutex_unlock(context->audio_mutex);
return 0;
}
-
+
if ((blen = switch_buffer_inuse(context->audio_buffer))) {
uint32_t read_bytes = 0;
int64_t lpts;
void vlc_write_video_imem_release_callback(void *data, const char *cookie, size_t size, void *unknown)
{
-
+
}
static switch_status_t video_read_callback(switch_core_session_t *session, switch_frame_t *frame, void *user_data)
switch_core_timer_sync(&context->timer);
fdata->pts = context->timer.samplecount;
switch_mutex_unlock(context->audio_mutex);
-
+
img_copy->user_priv = (void *) fdata;
switch_queue_push(context->video_queue, img_copy);
switch_core_timer_init(&context->timer, "soft", 1, 1000, context->pool);
- switch_channel_set_flag(channel, CF_VIDEO_DECODED_READ);
+ switch_channel_set_flag(channel, CF_VIDEO_DECODED_READ);
switch_core_media_get_vid_params(session, &vid_params);
switch_channel_set_flag(channel, CF_VIDEO_ECHO);
switch_core_session_raw_read(session);
"samplerate=%d:"
"channels=%d:"
"id=1:"
- "caching=0",
+ "caching=0",
context->samplerate, context->channels);
-
+
context->m = libvlc_media_new_location(vlc_handle, imem_main);
-
- libvlc_media_add_option_flag( context->m, imem_slave, libvlc_media_option_trusted );
+
+ libvlc_media_add_option_flag( context->m, imem_slave, libvlc_media_option_trusted );
if ( context->m == NULL ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "VLC error opening %s for writing\n", data);
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
return ;
}
-
+
context->mp = libvlc_media_player_new_from_media(context->m);
context->samples = 0;
switch_channel_audio_sync(channel);
-
+
if (offset) {
context->sync_offset = offset * 1000;
}
if (!SWITCH_READ_ACCEPTABLE(status)) {
break;
}
-
+
if (switch_test_flag(read_frame, SFF_CNG)) {
audio_data = audio_data_buf;
audio_datalen = read_impl.decoded_bytes_per_packet;
break;
}
}
-
+
vlc_status = libvlc_media_get_state(context->m);
if (vlc_status == libvlc_Ended || vlc_status == libvlc_Error || vlc_status == libvlc_Stopped ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "VLC done. status = %d\n", vlc_status);
break;
- }
+ }
}
switch_core_session_set_video_read_callback(session, NULL, NULL);
context->ending = 1;
-
+
if (switch_mutex_trylock(context->cond_mutex) == SWITCH_STATUS_SUCCESS) {
switch_thread_cond_signal(context->cond);
switch_mutex_unlock(context->cond_mutex);
tech_pvt->audio_datalen = SWITCH_RECOMMENDED_BUFFER_SIZE;
tech_pvt->audio_data = switch_core_session_alloc(session, tech_pvt->audio_datalen);
-
+
if (osession) {
switch_core_session_get_read_impl(osession, &tech_pvt->read_impl);
} else {
if (val) tmp = atoi(val);
if (tmp == 0) tmp = 20;
tech_pvt->read_impl.microseconds_per_packet = tmp * 1000;
-
+
tech_pvt->read_impl.iananame = "L16";
tmp = 0;
libvlc_audio_set_format(context->mp, "S16N", tech_pvt->read_impl.actual_samples_per_second, tech_pvt->read_impl.number_of_channels);
libvlc_audio_set_callbacks(context->mp, vlc_play_audio_callback, NULL,NULL,NULL,NULL, (void *) context);
-
+
libvlc_video_set_format_callbacks(context->mp, video_format_setup_callback, video_format_clean_callback);
libvlc_video_set_callbacks(context->mp, vlc_video_lock_callback, vlc_video_channel_unlock_callback, vlc_video_display_callback, context);
void *pop;
while (switch_queue_trypop(tech_pvt->context->video_queue, &pop) == SWITCH_STATUS_SUCCESS && pop) {
- switch_image_t *img = (switch_image_t *) pop;
+ switch_image_t *img = (switch_image_t *) pop;
switch_img_free(&img);
}
}
switch_channel_t *channel;
vlc_private_t *tech_pvt;
void *pop;
-
+
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
switch_assert(tech_pvt != NULL);
switch_assert(tech_pvt->context);
-
+
switch_img_free(&tech_pvt->read_video_frame.img);
if (tech_pvt->context->video_queue) {
while(switch_queue_size(tech_pvt->context->video_queue) > 1) {
- if (switch_queue_trypop(tech_pvt->context->video_queue, &pop) == SWITCH_STATUS_SUCCESS) {
+ if (switch_queue_trypop(tech_pvt->context->video_queue, &pop) == SWITCH_STATUS_SUCCESS) {
switch_image_t *img = (switch_image_t *) pop;
switch_img_free(&img);
} else {
}
}
if (switch_queue_pop(tech_pvt->context->video_queue, &pop) == SWITCH_STATUS_SUCCESS) {
- switch_image_t *img = (switch_image_t *) pop;
+ switch_image_t *img = (switch_image_t *) pop;
if (!img) return SWITCH_STATUS_FALSE;
-
+
tech_pvt->read_video_frame.img = img;
*frame = &tech_pvt->read_video_frame;
switch_set_flag(*frame, SFF_RAW_RTP);
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
-
+
vlc_file_supported_formats[argc++] = "vlc";
vlc_file_supported_formats[argc++] = "mp4"; /* maybe add config for this mod to enable or disable these */
vlc_file_supported_formats[argc++] = "mov";
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2015, Anthony Minessale II <anthm@freeswitch.org>
*
buf, &size, &encoded_rate, NULL);
}
-
+
if (size > 0) {
// timecode still need to figure out for sync
// switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%02x %02x %02x | len:%d m:%d st:%d i:%d\n", hdr[0], hdr[1], hdr[2], datalen, frame->m, start_bit, is_iframe);
-
+
if (!context->video) {
context->video_track_id = context->segment->AddVideoTrack(frame->img->d_w, frame->img->d_h, 0);
const void *data;
int duration = 0;
-
+
switch_buffer_peek_zerocopy(context->buf, &data);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "VID samplecount: %u\n", context->timer.samplecount);
}
end:
-
+
return status;
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
SWITCH_MODULE_RUNTIME_FUNCTION(mod_basic_runtime);
SWITCH_MODULE_LOAD_FUNCTION(mod_basic_load);
-/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
+/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
* Defines a switch_loadable_module_function_table_t and a static const char[] modname
*/
SWITCH_MODULE_DEFINITION(mod_basic, mod_basic_load, mod_basic_shutdown, NULL);
static void _on_error(mb_interpreter_t* s, mb_error_e e, char* m, int p, unsigned short row, unsigned short col, int abort_code) {
mb_unrefvar(s);
if(SE_NO_ERR != e) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
"Error:\n [POS] %d, [ROW] %d, [COL] %d,\n [CODE] %d, [MESSAGE] %s, [ABORT CODE] %d\n", p, row, col, e, m, abort_code);
}
}
} fs_data_t;
-static int fun_execute(mb_interpreter_t* s, void** l)
+static int fun_execute(mb_interpreter_t* s, void** l)
{
int result = MB_FUNC_OK;
fs_data_t *fsdata = (fs_data_t *) mb_get_user_data(s);
end:
return result;
-}
+}
-static int fun_setvar(mb_interpreter_t* s, void** l)
+static int fun_setvar(mb_interpreter_t* s, void** l)
{
int result = MB_FUNC_OK;
fs_data_t *fsdata = (fs_data_t *) mb_get_user_data(s);
end:
return result;
-}
+}
-static int fun_getarg(mb_interpreter_t* s, void** l)
+static int fun_getarg(mb_interpreter_t* s, void** l)
{
int result = MB_FUNC_OK;
fs_data_t *fsdata = (fs_data_t *) mb_get_user_data(s);
return result;
}
-static int fun_getvar(mb_interpreter_t* s, void** l)
+static int fun_getvar(mb_interpreter_t* s, void** l)
{
int result = MB_FUNC_OK;
fs_data_t *fsdata = (fs_data_t *) mb_get_user_data(s);
if (var.type == MB_DT_STRING && fsdata->session) {
switch_channel_t *channel = switch_core_session_get_channel(fsdata->session);
const char *value = switch_channel_get_variable(channel, var.value.string);
-
+
mb_push_string(s, l, strdup(value));
} else {
end:
return result;
-}
+}
-static int fun_api(mb_interpreter_t* s, void** l)
+static int fun_api(mb_interpreter_t* s, void** l)
{
int result = MB_FUNC_OK;
fs_data_t *fsdata = (fs_data_t *) mb_get_user_data(s);
end:
return result;
-}
+}
-static int fun_log(mb_interpreter_t* s, void** l)
+static int fun_log(mb_interpreter_t* s, void** l)
{
int result = MB_FUNC_OK;
fs_data_t *fsdata = (fs_data_t *) mb_get_user_data(s);
if (level.type == MB_DT_STRING && data.type == MB_DT_STRING) {
switch_log_level_t fslevel = SWITCH_LOG_DEBUG;
-
+
fslevel = switch_log_str2level(level.value.string);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(fsdata->session), fslevel, "%s\n", data.value.string);
} else {
end:
return result;
-}
+}
-static int bprint(const char *fmt, ...)
+static int bprint(const char *fmt, ...)
{
char *data = NULL;
va_list ap;
int ret = 0;
-
+
va_start(ap, fmt);
ret = switch_vasprintf(&data, fmt, ap);
va_end(ap);
-
+
if (data) {
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_CONSOLE, "%s\n", data);
}
- switch_safe_free(data);
-
+ switch_safe_free(data);
+
return ret;
}
}
mb_open(&bi);
- mb_set_error_handler(bi, _on_error);
+ mb_set_error_handler(bi, _on_error);
mb_set_printer(bi, bprint);
fsdata.session = session;
mb_set_user_data(bi, (void *) &fsdata);
mb_register_func(bi, "FS_SETVAR", fun_setvar);
mb_register_func(bi, "FS_API", fun_api);
mb_register_func(bi, "FS_LOG", fun_log);
-
+
if (mb_load_file(bi, file) == MB_FUNC_OK) {
mb_run(bi);
} else {
{
basic_function(session, cmd);
-
+
return SWITCH_STATUS_SUCCESS;
}
MBAPI void mb_set_user_data(mb_interpreter_t* s, void *ptr);
MBAPI void *mb_get_user_data(mb_interpreter_t* s);
-
+
#ifdef MB_COMPACT_MODE
# pragma pack()
#endif /* MB_COMPACT_MODE */
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2007, Damjan Jovanovic <d a m j a n d o t j o v a t g m a i l d o t c o m>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Damjan Jovanovic <d a m j a n d o t j o v a t g m a i l d o t c o m>
*
*
char *derr = NULL;
pJNI_CreateJavaVM = (jint (*)(JavaVM **, void **, void *))switch_dso_func_sym(javaVMHandle, "JNI_CreateJavaVM", &derr);
-
+
if (!derr)
{
JNIEnv *env;
void Session::destroy(const char *err)
{
-
+
if (!allocated) {
return;
}
docall(L, arg_count, 1, 1, 0);
const char *err = lua_tostring(L, -1);
-
+
switch_channel_set_variable(channel, "lua_hangup_hook_return_val", err);
if (!zstr(err)) {
coresession = (Session *) vs;
}
}
-
+
if (!(coresession && coresession->hook_state)) {
return SWITCH_STATUS_FALSE;
}
dbh = NULL;
err = NULL;
char *tmp = NULL;
-
+
if (!zstr(user) || !zstr(pass)) {
- tmp = switch_mprintf("%s%s%s%s%s", dsn,
+ tmp = switch_mprintf("%s%s%s%s%s", dsn,
zstr(user) ? "" : ":",
zstr(user) ? "" : user,
zstr(pass) ? "" : ":",
zstr(pass) ? "" : pass
);
-
+
dsn = tmp;
}
}
switch_safe_free(tmp);
-
+
}
Dbh::~Dbh()
ret = lua_tonumber(lua_fun->L, -1);
lua_pop(lua_fun->L, 1);
-
+
if (ret != 0) {
return 1;
}
-
+
return 0; /* 0 to continue with next row */
}
g->gcstate = GCSatomic; /* finish mark phase */
g->GCestimate = g->GCmemtrav; /* save what was counted */;
work = atomic(L); /* add what was traversed by 'atomic' */
- g->GCestimate += work; /* estimate of total memory traversed */
+ g->GCestimate += work; /* estimate of total memory traversed */
sw = entersweep(L);
return work + sw * GCSWEEPCOST;
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
* mod_lua.c -- Lua
if (!zstr(err)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s\n", err);
}
-
+
// pass error up to top
if (fatal) {
lua_error(L);
}
while(input_code && (*input_code == ' ' || *input_code == '\n' || *input_code == '\r')) input_code++;
-
+
if (*input_code == '~') {
char *buff = input_code + 1;
error = luaL_loadbuffer(L, buff, strlen(buff), "line") || docall(L, 0, 0, 0, 1); //lua_pcall(L, 0, 0, 0);
lua_getglobal(L, "XML_STRING");
str = lua_tostring(L, -1);
-
+
if (str) {
if (zstr(str)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Result\n");
- } else if (!(xml = switch_xml_parse_str_dynamic((char *)str, SWITCH_TRUE))) {
- /* const char -> char conversion was OK because switch_xml_parse_str_dynamic makes a duplicate of str
+ } else if (!(xml = switch_xml_parse_str_dynamic((char *)str, SWITCH_TRUE))) {
+ /* const char -> char conversion was OK because switch_xml_parse_str_dynamic makes a duplicate of str
and saves this duplcate as root->m which is freed when switch_xml_free is issued
*/
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Parsing XML Result!\n");
switch_xml_t cfg, xml, settings, param, hook;
switch_stream_handle_t path_stream = {0};
switch_stream_handle_t cpath_stream = {0};
-
+
if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
return SWITCH_STATUS_TERM;
}
switch_safe_free(path_stream.data);
-
+
switch_xml_free(xml);
return SWITCH_STATUS_SUCCESS;
SWITCH_ADD_API(api_interface, "luarun", "run a script", luarun_api_function, "<script>");
SWITCH_ADD_API(api_interface, "lua", "run a script as an api function", lua_api_function, "<script>");
- SWITCH_ADD_APP(app_interface, "lua", "Launch LUA ivr", "Run a lua ivr on a channel", lua_function, "<script>",
+ SWITCH_ADD_APP(app_interface, "lua", "Launch LUA ivr", "Run a lua ivr on a channel", lua_function, "<script>",
SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC | SAF_SUPPORT_TEXT_ONLY);
SWITCH_ADD_DIALPLAN(dp_interface, "LUA", lua_dialplan_hunt);
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - mod_managed
* Copyright (C) 2008, Michael Giagnocavo <mgg@packetrino.com>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Michael Giagnocavo <mgg@packetrino.com>
* Jeff Lenk <jlenk@frontiernet.net> - Modified class to support Dotnet
- *
+ *
* freeswitch_managed.cpp -- Managed CoreSession subclasses
*
- */
+ */
#include <switch.h>
#include <switch_cpp.h>
#pragma unmanaged
#endif
-ManagedSession::ManagedSession():CoreSession()
+ManagedSession::ManagedSession():CoreSession()
{
-}
+}
-ManagedSession::ManagedSession(char *uuid):CoreSession(uuid)
+ManagedSession::ManagedSession(char *uuid):CoreSession(uuid)
{
-}
+}
-ManagedSession::ManagedSession(switch_core_session_t *session):CoreSession(session)
+ManagedSession::ManagedSession(switch_core_session_t *session):CoreSession(session)
{
-}
+}
-bool ManagedSession::begin_allow_threads()
+bool ManagedSession::begin_allow_threads()
{
return true;
}
-bool ManagedSession::end_allow_threads()
+bool ManagedSession::end_allow_threads()
{
return true;
}
-ManagedSession::~ManagedSession()
+ManagedSession::~ManagedSession()
{
ATTACH_THREADS
- // Do auto-hangup ourselves because CoreSession can't call check_hangup_hook
+ // Do auto-hangup ourselves because CoreSession can't call check_hangup_hook
// after ManagedSession destruction (cause at point it's pure virtual)
if (session) {
if (switch_test_flag(this, S_HUP) && !switch_channel_test_flag(channel, CF_TRANSFER)) {
}
}
-void ManagedSession::check_hangup_hook()
+void ManagedSession::check_hangup_hook()
{
ATTACH_THREADS
if (!hangupDelegate) {
hangupDelegate();
}
-switch_status_t ManagedSession::run_dtmf_callback(void *input, switch_input_type_t itype)
+switch_status_t ManagedSession::run_dtmf_callback(void *input, switch_input_type_t itype)
{
ATTACH_THREADS
if (!dtmfDelegate) {
char *result = dtmfDelegate(input, itype);
switch_status_t status = process_callback_result(result);
- RESULT_FREE(result);
+ RESULT_FREE(result);
return status;
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - mod_managed
* Copyright (C) 2008, Michael Giagnocavo <mgg@packetrino.com>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Michael Giagnocavo <mgg@packetrino.com>
* Jeff Lenk <jlenk@frontiernet.net> - Modified class to support Dotnet
*
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - mod_managed
* Copyright (C) 2008, Michael Giagnocavo <mgg@packetrino.com>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Michael Giagnocavo <mgg@giagnocavo.net>
* David Brazier <David.Brazier@360crm.co.uk>
- * Jeff Lenk <jlenk@frontiernet.net>
+ * Jeff Lenk <jlenk@frontiernet.net>
* Artur Kraev <ravenox@gmail.com>
*
* mod_mono.cpp -- FreeSWITCH mod_mono main class
*
- * Most of mod_mono is implmented in the mod_mono_managed Loader class.
+ * Most of mod_mono is implmented in the mod_mono_managed Loader class.
* The native code just handles getting the Mono runtime up and down
* and passing pointers into managed code.
- */
+ */
#include <switch.h>
-#include "freeswitch_managed.h"
+#include "freeswitch_managed.h"
#ifdef _MANAGED
#include <mscoree.h>
#define MOD_MANAGED_VERSION "Mono Version"
#endif
-SWITCH_BEGIN_EXTERN_C
+SWITCH_BEGIN_EXTERN_C
SWITCH_MODULE_LOAD_FUNCTION(mod_managed_load);
SWITCH_MODULE_DEFINITION_EX(mod_managed, mod_managed_load, NULL, NULL, SMODF_GLOBAL_SYMBOLS);
// Sets up delegates (and anything else needed) on the ManagedSession object
// Called from ManagedSession.Initialize Managed -> this is Unmanaged code so all pointers are marshalled and prevented from GC
// Exported method.
-SWITCH_MOD_DECLARE_NONSTD(void) InitManagedSession(ManagedSession *session, inputFunction dtmfDelegate, hangupFunction hangupDelegate)
+SWITCH_MOD_DECLARE_NONSTD(void) InitManagedSession(ManagedSession *session, inputFunction dtmfDelegate, hangupFunction hangupDelegate)
{
switch_assert(session);
if (!session) {
session->hangupDelegate = hangupDelegate;
}
-#ifndef _MANAGED
+#ifndef _MANAGED
#ifdef WIN32
#include <shlobj.h>
-#endif
+#endif
-switch_status_t setMonoDirs()
+switch_status_t setMonoDirs()
{
-#ifdef WIN32
+#ifdef WIN32
// Win32 Mono installs can't figure out their own path
// Guys in #mono say we should just deploy all the libs we need
// We'll first check for Program Files\Mono to allow people to use the symlink dir for a specific version.
FindClose(hFind);
}
- /* Got it */
+ /* Got it */
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Using Mono paths '%s' and '%s'.\n", libPath, etcPath);
mono_set_dirs(libPath, etcPath);
return SWITCH_STATUS_SUCCESS;
// On other platforms, it should just work if it hasn't been relocated
mono_set_dirs(NULL, NULL);
return SWITCH_STATUS_SUCCESS;
-#endif
+#endif
}
-switch_status_t loadRuntime()
+switch_status_t loadRuntime()
{
- /* Find and load mod_mono_managed.exe */
+ /* Find and load mod_mono_managed.exe */
char filename[256];
if (setMonoDirs() != SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_FALSE;
}
-#ifndef WIN32
+#ifndef WIN32
// So linux can find the .so
char xmlConfig[300];
switch_snprintf(xmlConfig, 300, "<configuration><dllmap dll=\"mod_managed\" target=\"%s%smod_managed.so\"/></configuration>", SWITCH_GLOBAL_dirs.mod_dir, SWITCH_PATH_SEPARATOR);
MonoAssemblyName *name = mono_assembly_name_new (MOD_MANAGED_ASM_NAME);
//Note also that it can't be allocated on the stack anymore and you'll need to create and destroy it with the following API:
//mono_assembly_name_free (name);
-
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Calling mono_assembly_loaded.\n");
if (!(managed_globals.mod_mono_asm = mono_assembly_loaded(name))) {
return SWITCH_STATUS_SUCCESS;
}
-MonoMethod * getMethod(const char *name, MonoClass * klass)
+MonoMethod * getMethod(const char *name, MonoClass * klass)
{
MonoMethodDesc * desc;
MonoMethod * method;
return method;
}
-switch_status_t findLoader()
+switch_status_t findLoader()
{
- /* Find loader class and methods */
+ /* Find loader class and methods */
MonoClass * loaderClass;
MonoImage * img = mono_assembly_get_image(managed_globals.mod_mono_asm);
#ifdef _MANAGED
-switch_status_t loadRuntime()
+switch_status_t loadRuntime()
{
- /* Find and load mod_dotnet_managed.dll */
+ /* Find and load mod_dotnet_managed.dll */
char filename[256];
switch_snprintf(filename, 256, "%s%s%s", SWITCH_GLOBAL_dirs.mod_dir, SWITCH_PATH_SEPARATOR, MOD_MANAGED_DLL);
return SWITCH_STATUS_SUCCESS;
}
-switch_status_t findLoader()
+switch_status_t findLoader()
{
try {
FreeSwitchManaged::loadMethod = FreeSwitchManaged::mod_dotnet_managed->GetType(MOD_MANAGED_IMAGE_NAME "." MOD_MANAGED_CLASS_NAME)->GetMethod("Load");
}
#endif
-SWITCH_MODULE_LOAD_FUNCTION(mod_managed_load)
+SWITCH_MODULE_LOAD_FUNCTION(mod_managed_load)
{
int success;
- /* connect my internal structure to the blank pointer passed to me */
+ /* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Loading mod_managed (Common Language Infrastructure), " MOD_MANAGED_VERSION "\n");
managed_globals.pool = pool;
-
- if (loadRuntime() != SWITCH_STATUS_SUCCESS) {
+
+ if (loadRuntime() != SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_FALSE;
}
-
- if (findLoader() != SWITCH_STATUS_SUCCESS) {
+
+ if (findLoader() != SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_FALSE;
}
#ifdef _MANAGED
/* Not sure if this is necesary on the loading thread */
mono_thread_attach(managed_globals.domain);
- /* Run loader */
+ /* Run loader */
MonoObject * exception = NULL;
MonoObject * objResult = mono_runtime_invoke(managed_globals.loadMethod, NULL, NULL, &exception);
if (exception) {
#endif
if (success) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Load completed successfully.\n");
- } else {
+ } else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Load did not return true.\n");
return SWITCH_STATUS_FALSE;
}
-
- /* We're good to register */
+
+ /* We're good to register */
switch_api_interface_t *api_interface;
switch_application_interface_t *app_interface;
#ifdef _MANAGED
#pragma unmanaged
#endif
-SWITCH_STANDARD_API(managedrun_api_function)
+SWITCH_STANDARD_API(managedrun_api_function)
{
if (zstr(cmd)) {
- stream->write_function(stream, "-ERR no args specified!\n");
+ stream->write_function(stream, "-ERR no args specified!\n");
return SWITCH_STATUS_SUCCESS;
}
#ifndef _MANAGED
#endif
if (executeBackgroundDelegate(cmd)) {
stream->write_function(stream, "+OK\n");
- } else {
+ } else {
stream->write_function(stream, "-ERR ExecuteBackground returned false (unknown module or exception?).\n");
}
#ifndef _MANAGED
return SWITCH_STATUS_SUCCESS;
}
-SWITCH_STANDARD_API(managed_api_function)
+SWITCH_STANDARD_API(managed_api_function)
{
if (zstr(cmd)) {
- stream->write_function(stream, "-ERR no args specified!\n");
+ stream->write_function(stream, "-ERR no args specified!\n");
return SWITCH_STATUS_SUCCESS;
}
#ifndef _MANAGED
mono_thread_attach(managed_globals.domain);
#endif
if (!(executeDelegate(cmd, stream, stream->param_event))) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Execute failed for %s (unknown module or exception).\n", cmd);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Execute failed for %s (unknown module or exception).\n", cmd);
}
#ifndef _MANAGED
mono_thread_detach(mono_thread_current());
return SWITCH_STATUS_SUCCESS;
}
-SWITCH_STANDARD_APP(managed_app_function)
+SWITCH_STANDARD_APP(managed_app_function)
{
if (zstr(data)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No args specified!\n");
#endif
}
-SWITCH_STANDARD_API(managedreload_api_function)
+SWITCH_STANDARD_API(managedreload_api_function)
{
if (zstr(cmd)) {
- stream->write_function(stream, "-ERR no args specified!\n");
+ stream->write_function(stream, "-ERR no args specified!\n");
return SWITCH_STATUS_SUCCESS;
}
#ifndef _MANAGED
mono_thread_attach(managed_globals.domain);
#endif
if (!(reloadDelegate(cmd))) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Execute failed for %s (unknown module or exception).\n", cmd);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Execute failed for %s (unknown module or exception).\n", cmd);
}
#ifndef _MANAGED
mono_thread_detach(mono_thread_current());
void Session::destroy(void)
{
-
+
if (!allocated) {
return;
}
switch_safe_free(cb_function);
switch_safe_free(cb_arg);
switch_safe_free(hangup_func_str);
- switch_safe_free(hangup_func_arg);
+ switch_safe_free(hangup_func_arg);
CoreSession::destroy();
}
switch_channel_set_private(channel, "CoreSession", NULL);
args.input_callback = NULL;
ap = NULL;
-
+
}
void Session::setInputCallback(char *cbfunc, char *funcargs)
HV *hash;
SV *this_sv;
char *code;
-
+
if (!(hash = get_hv("__dtmf", TRUE))) {
abort();
}
this_sv = newSV(strlen(str) + 1);
sv_setpv(this_sv, str);
hv_store(hash, "duration", 8, this_sv, 0);
-
+
code = switch_mprintf("eval { $__RV = &%s($%s, 'dtmf', \\%%__dtmf, %s);};", cb_function, suuid, switch_str_nil(cb_arg));
Perl_eval_pv(my_perl, code, FALSE);
free(code);
}
mod_perl_conjure_event(my_perl, event, var_name);
- code = switch_mprintf("eval {$__RV = &%s($%s, 'event', $%s, '%s');};$%s = undef;",
+ code = switch_mprintf("eval {$__RV = &%s($%s, 'event', $%s, '%s');};$%s = undef;",
cb_function, suuid, var_name, switch_str_nil(cb_arg), var_name);
Perl_eval_pv(my_perl, code, FALSE);
free(code);
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
void Session::destroy(void)
{
-
+
if (!allocated) {
return;
}
Py_DECREF(hangup_func);
hangup_func = NULL;
}
-
+
if (hangup_func_arg) {
Py_DECREF(hangup_func_arg);
hangup_func_arg = NULL;
/*! this is called every time ready is called as a workaround to
make it threadsafe. it sets a flag, and all the places where it
- comes in and out of threadswap, check it. so the end result is
+ comes in and out of threadswap, check it. so the end result is
you still get the hangup hook executed pretty soon after you
hangup. */
do_hangup_hook();
mark++;
if (hangup_func) {
-
+
if (!PyCallable_Check(hangup_func)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "function not callable\n");
return;
if (!Self) {
mod_python_conjure_session(NULL, session);
}
-
+
if (hangup_func_arg) {
arglist = Py_BuildValue("(OsO)", Self, what, hangup_func_arg);
} else {
if (!(result = PyEval_CallObject(hangup_func, arglist))) {
PyErr_Print();
}
-
+
Py_XDECREF(arglist);
Py_XDECREF(hangup_func_arg);
}
Py_XDECREF(hangup_func_arg);
hangup_func_arg = NULL;
}
-
+
hangup_func = pyfunc;
hangup_func_arg = arg;
Py_XDECREF(cb_arg);
cb_arg = NULL;
}
-
+
args.input_callback = NULL;
ap = NULL;
-
+
}
void Session::setInputCallback(PyObject *cbfunc, PyObject *funcargs)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "function not callable\n");
return SWITCH_STATUS_FALSE;
}
-
+
if (itype == SWITCH_INPUT_TYPE_DTMF) {
switch_dtmf_t *dtmf = (switch_dtmf_t *) input;
io = mod_python_conjure_DTMF(dtmf->digit, dtmf->duration);
if (!Self) {
mod_python_conjure_session(NULL, session);
}
-
+
if (cb_arg) {
arglist = Py_BuildValue("(OsOO)", Self, what, io, cb_arg);
} else {
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Brian Fertig <brian.fertig@convergencetek.com>
* Johny Kadarisman <jkr888@gmail.com>
* Traun Leyden <tleyden@branchcut.com>
/**
-* This function is similiar to PyErr_Print. It uses the freeswitch print/log mechanism instead of the python sys.stderr
+* This function is similiar to PyErr_Print. It uses the freeswitch print/log mechanism instead of the python sys.stderr
*/
static void print_python_error(const char * script)
{
if (buffer == NULL ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Not enough Memory to create the error buffer");
}
-
+
/* just for security that we will always have a string terminater */
memset(buffer, 0, 20 * 1024 * sizeof(char) );
/*Print error message*/
if (pyValue != NULL && (pyString=PyObject_Str(pyValue))!=NULL && (PyString_Check(pyString))) {
- strcat(buffer, "\nMessage: ");
+ strcat(buffer, "\nMessage: ");
strcat(buffer, PyString_AsString(pyString));
} else {
strcat(buffer, "\nMessage: <unknown exception date> ");
arg = Py_BuildValue("(s)", switch_str_nil(argv[1]));
}
- // invoke the handler
+ // invoke the handler
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Call python script \n");
result = PyEval_CallObjectWithKeywords(function, arg, (PyObject *) NULL);
Py_DECREF(function);
*str = strdup((char *) PyString_AsString(result));
}
} else if (!PyErr_ExceptionMatches(PyExc_SystemExit)) {
- // Print error, but ignore SystemExit
+ // Print error, but ignore SystemExit
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error calling python script\n");
print_python_error(script);
PyErr_Clear();
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Had to kill %d threads\n", thread_cnt);
- /* Give threads a few seconds to terminate.
+ /* Give threads a few seconds to terminate.
Not using switch_thread_join() since if threads refuse to die
then freeswitch will hang */
for (i = 0; i < 10 && thread_pool_head; i++) {
/* Add xml handler global variables */
Handle<Array> XML_REQUEST = Array::New(isolate, 4);
-
+
XML_REQUEST->Set(String::NewFromUtf8(isolate, "key_name"), String::NewFromUtf8(isolate, js_safe_str(xml_handler->key_name)));
XML_REQUEST->Set(String::NewFromUtf8(isolate, "key_value"), String::NewFromUtf8(isolate, js_safe_str(xml_handler->key_value)));
XML_REQUEST->Set(String::NewFromUtf8(isolate, "section"), String::NewFromUtf8(isolate, js_safe_str(xml_handler->section)));
}
if (xml_handler)
- {
+ {
Local<Value> value = context->Global()->Get(String::NewFromUtf8(isolate, "XML_STRING"));
String::Utf8Value str(value);
if (strcmp(js_safe_str(*str), "undefined"))
#endif
}
//isolate->Exit();
-
+
if (res.length() == 0) {
result = -1;
} else {
if (zstr(xml_handler.XML_STRING)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Result\n");
}
- else if (!(xml = switch_xml_parse_str_dynamic(xml_handler.XML_STRING, SWITCH_TRUE))) {
+ else if (!(xml = switch_xml_parse_str_dynamic(xml_handler.XML_STRING, SWITCH_TRUE))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Parsing XML Result!\n");
}
}
// Don't forget to free XML_STRING
switch_safe_free(xml_handler.XML_STRING);
-
+
}
-
+
switch_safe_free(mycmd);
return xml;
switch_stream_handle_t stream = { 0 };
if ((data = cJSON_GetObjectItem(json, "data"))) {
- path = cJSON_GetObjectItem(data, "path");
+ path = cJSON_GetObjectItem(data, "path");
}
if (!(path && data)) {
switch_safe_free(json_text);
v8_parse_and_execute(session, (char *) path->valuestring, &stream, NULL, NULL);
-
+
*json_reply = cJSON_Parse((char *)stream.data);
end:
switch_event_destroy(&stream.param_event);
switch_safe_free(stream.data);
-
+
return SWITCH_STATUS_SUCCESS;
}
}
/* Evaluate a prepared statement
- stepSuccessCode expected success code from switch_core_db_step()
+ stepSuccessCode expected success code from switch_core_db_step()
return true if step return expected success code, false otherwise
*/
void FSCoreDB::StepEx(const v8::FunctionCallbackInfo<Value>& info, int stepSuccessCode)
}
}
-/* Evaluate a prepared statement, to be used with statements that return data
+/* Evaluate a prepared statement, to be used with statements that return data
return true while data is available, false when done or error
*/
JS_COREDB_FUNCTION_IMPL(Next)
StepEx(info, SWITCH_CORE_DB_ROW);
}
-/* Evaluate a prepared statement, to be used with statements that return no data
- return true if statement has finished executing successfully, false otherwise
+/* Evaluate a prepared statement, to be used with statements that return no data
+ return true if statement has finished executing successfully, false otherwise
*/
JS_COREDB_FUNCTION_IMPL(Step)
{
HandleScope handle_scope(obj->GetIsolate());
Handle<Function> func;
-
+
if (!obj->_function.IsEmpty()) {
func = Local<Function>::New(obj->GetIsolate(), obj->_function);
}
void *arg = NULL;
switch_core_db_callback_func_t cb_func = NULL;
-
+
Handle<Function> func = Handle<Function>();
- if (info.Length() > 1)
+ if (info.Length() > 1)
func = JSBase::GetFunctionFromArg(info.GetIsolate(), info[1]);
if (!func.IsEmpty()) {
cb_func = FSDBH::Callback;
arg = this;
}
-
+
if (dbh) {
if (!func.IsEmpty()) {
if (switch_cache_db_execute_sql_callback(dbh, sql, cb_func, arg, &err) == SWITCH_STATUS_SUCCESS) {
delete obj;
}
}
-
+
return Handle<Object>();
}
}
}
}
-
+
info.GetReturnValue().Set(ret);
}
}
}
}
-
+
info.GetReturnValue().Set(ret);
}
}
switch_safe_free(path);
}
-
+
info.GetIsolate()->ThrowException(String::NewFromUtf8(info.GetIsolate(), "Failed to include javascript file"));
}
}
JS_CHECK_SCRIPT_STATE();
HandleScope handle_scope(info.GetIsolate());
string to, from, headers, body, file, convert_cmd, convert_ext;
-
+
if (info.Length() > 0) {
String::Utf8Value str(info[0]);
to = js_safe_str(*str);
if (info.Length() > 1) {
if (info[0]->IsObject()) {
obj_a = Handle<Object>::Cast(info[0]);
-
+
if (!(jss_a = JSBase::GetInstance<FSSession>(obj_a))) {
info.GetIsolate()->ThrowException(String::NewFromUtf8(info.GetIsolate(), "Cannot find session A"));
return;
SQLCHAR name[1024] = "";
SQLCHAR *data = _colbuf;
SQLLEN pcbValue;
-
+
SQLDescribeCol(_stmt, x, name, sizeof(name), &NameLength, &DataType, &ColumnSize, &DecimalDigits, &Nullable);
SQLGetData(_stmt, x, SQL_C_CHAR, _colbuf, _cblen, &pcbValue);
if (info.Length() > 0) {
if (info[0]->IsObject()) {
obj_b = Handle<Object>::Cast(info[0]);
-
+
if (!(jss_b = JSBase::GetInstance<FSSession>(obj_b))) {
info.GetIsolate()->ThrowException(String::NewFromUtf8(info.GetIsolate(), "Cannot find session B"));
return;
{
if (!_rootObject) {
/* This is the root object */
-
+
/* Free the xml struct if it still exists */
if (_xml) {
switch_xml_free(_xml);
}
-
+
/* Free all sub-objects in the hash and destroy the hash */
DestroyHash();
} else if (_rootObject && _xml && _rootObject->_obj_hash) {
} else {
rootObj = _rootObject;
}
-
+
if (!rootObj) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find XML root node\n");
return Handle<Value>();
newObj->RegisterInstance(info.GetIsolate(), "", true);
}
}
-
+
if (newObj) {
- return newObj->GetJavaScriptObject();
+ return newObj->GetJavaScriptObject();
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create new object - memory error?\n");
JS_CHECK_SCRIPT_STATE();
FSXML *obj = JSBase::GetInstance<FSXML>(info);
-
+
if (obj) {
switch_xml_remove(obj->_xml);
if (!obj->_rootObject) {
JSMain::JSMain(void)
{
isolate = Isolate::New();
-
+
extenderClasses = new vector<const js_class_definition_t *>();
extenderFunctions = new vector<js_function_t *>();
extenderInstances = new vector<registered_instance_t*>();
ostringstream ss;
ss << filename_string << ":" << linenum << ": " << exception_string << "\r\n";
-
+
// Print line of source code.
String::Utf8Value sourceline(message->GetSourceLine());
const char *sourceline_string = js_safe_str(*sourceline);
return;
}
}
-
+
args.GetReturnValue().Set(Undefined(args.GetIsolate()));
}
String::Utf8Value str(args[0]);
printf("%s\r\n", js_safe_str(*str));
-
+
args.GetReturnValue().Set(Undefined(args.GetIsolate()));
}
#endif
}
//isolate->Exit();
-
+
if (resultIsError) {
*resultIsError = isError;
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
<!-- pick a file name, a function name or 'all' -->
<!-- map as many as you need for specific debugging -->
<mappings>
- <!--
- name can be a file name, function name or 'all'
+ <!--
+ name can be a file name, function name or 'all'
value is one or more of debug,info,notice,warning,err,crit,alert,all
See examples below
Example: the following turns on debugging for error and critical levels only
<map name="all" value="err,crit"/>
- NOTE: using map name="all" will override any other settings! If you
+ NOTE: using map name="all" will override any other settings! If you
want a more specific set of console messages then you will need
to specify which files and/or functions you want to have debug
- messages. One option is to turn on just the more critical
- messages with map name="all", then specify the other types of
+ messages. One option is to turn on just the more critical
+ messages with map name="all", then specify the other types of
console messages you want to see for various files and functions.
Example: turn on ERROR, CRIT, ALERT for all modules, then specify other
<map name="mod_sndfile.c" value="warning,info,debug"/>
-->
<map name="all" value="console,debug,info,notice,warning,err,crit,alert"/>
-
+
<!--
You can use or modify this sample set of mappings. It turns on higher
level messages for all modules and then specifies extra lower level
messages for freetdm, Sofia, and switch core messages.
-
+
<map name="all" value="warning,err,crit,alert"/>
<map name="zap_analog.c" value="all"/>
<map name="zap_io.c" value="all"/>
<map name="zap_zt.c" value="all"/>
<map name="mod_freetdm" value="all"/>
<map name="sofia.c" value="notice"/>
- <map name="switch_core_state_machine.c" value="all"/>
-
+ <map name="switch_core_state_machine.c" value="all"/>
+
-->
</mappings>
<settings>
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
#else
static const char *
#endif
-
-
-
-
+
+
+
+
COLORS[] =
{ SWITCH_SEQ_DEFAULT_COLOR, SWITCH_SEQ_FRED, SWITCH_SEQ_FRED, SWITCH_SEQ_FRED, SWITCH_SEQ_FMAGEN, SWITCH_SEQ_FCYAN, SWITCH_SEQ_FGREEN,
SWITCH_SEQ_FYELLOW };
-/*
+/*
* mod_graylog2 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2014-2015, Grasshopper
*
gelf_text = cJSON_PrintUnformatted(gelf);
cJSON_Delete(gelf);
-
+
switch_safe_free(parsed_full_message);
-
+
return gelf_text;
}
}
if (zstr(value)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignoring empty value for param \"%s\"\n", name);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignoring empty value for param \"%s\"\n", name);
continue;
}
if (!strcmp(name, "server-host")) {
globals.server_host = switch_core_strdup(globals.pool, value);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "\"%s\" = \"%s\"\n", name, value);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "\"%s\" = \"%s\"\n", name, value);
} else if (!strcasecmp(name, "server-port")) {
int port = -1;
if (switch_is_number(value)) {
}
if (port > 0 && port <= 65535) {
globals.server_port = port;
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "\"%s\" = \"%s\"\n", name, value);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "\"%s\" = \"%s\"\n", name, value);
} else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid port: \"%s\"\n", value);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid port: \"%s\"\n", value);
}
} else if (!strcasecmp(name, "loglevel")) {
switch_log_level_t log_level = switch_log_str2level(value);
if (log_level == SWITCH_LOG_INVALID) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignoring invalid log level: \"%s\"\n", value);
} else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "\"%s\" = \"%s\"\n", name, value);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "\"%s\" = \"%s\"\n", name, value);
globals.log_level = log_level;
}
} else if (!strcasecmp(name, "send-uncompressed-header")) {
globals.send_uncompressed_header = switch_true(value);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "\"%s\" = \"%s\"\n", name, value);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "\"%s\" = \"%s\"\n", name, value);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignoring unknown param: \"%s\"\n", name);
}
<param name="uuid" value="true" />
</settings>
<mappings>
- <!--
- name can be a file name, function name or 'all'
+ <!--
+ name can be a file name, function name or 'all'
value is one or more of debug,info,notice,warning,err,crit,alert,all
Please see comments in console.conf.xml for more information
-->
}
sprintf((char *) to_filename, "%s.%i", profile->logfile, i);
-
+
if (switch_file_exists(to_filename, pool) == SWITCH_STATUS_SUCCESS) {
if ((status = switch_file_remove(to_filename, pool)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error removing log %s [%s]\n", to_filename, strerror(errno));
char *dup = strdup(node->data);
char *lines[100];
int argc, i;
-
+
argc = switch_split(dup, '\n', lines);
for (i = 0; i < argc; i++) {
switch_snprintf(buf, sizeof(buf), "%s %s\n", node->userdata, lines[i]);
- mod_logfile_raw_write(profile, buf);
+ mod_logfile_raw_write(profile, buf);
}
-
+
free(dup);
-
+
} else {
mod_logfile_raw_write(profile, node->data);
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, James Martelletti <james@nerdc0re.com>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Tamas Cseke <tamas.cseke@vcc.live>
*
* mod_raven.c -- Raven Logging
/*.directory_interface */ NULL
};
-static switch_status_t encode(const char *raw, int raw_len, char **encoded_out)
+static switch_status_t encode(const char *raw, int raw_len, char **encoded_out)
{
z_stream stream;
unsigned char *encoded = NULL, *compressed = NULL;
return SWITCH_STATUS_FALSE;
}
- stream.next_in = (unsigned char *)raw;
+ stream.next_in = (unsigned char *)raw;
stream.avail_in = raw_len;
do {
stream.avail_out = compressed_size - compressed_len;
stream.next_out = compressed + compressed_len;
-
+
ret = deflate(&stream, Z_FINISH);
assert(ret != Z_STREAM_ERROR);
compressed_len = compressed_size - stream.avail_out;
" sentry_client=%s,"
" sentry_timestamp=%d,"
" sentry_key=%s,"
- " sentry_secret=%s",
+ " sentry_secret=%s",
RAVEN_VERSION, RAVEN_UA,
timestamp, globals.key, globals.secret);
switch_curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDSIZE, strlen(encoded_body));
switch_curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, RAVEN_UA);
-
+
list = switch_curl_slist_append(list, auth_header);
list = switch_curl_slist_append(list, "Content-Type: application/octet-stream");
switch_curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, list);
if (level != SWITCH_LOG_CONSOLE && !zstr(node->data)) {
const char * raven_level;
-
+
switch (level) {
case SWITCH_LOG_DEBUG:
raven_level = "debug";
status = raven_capture(node->userdata, node->data, raven_level, node->file, node->func, node->line);
}
-
+
return status;
}
if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", cf);
return SWITCH_STATUS_FALSE;
- }
+ }
if ((settings = switch_xml_child(cfg, "settings"))) {
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, James Martelletti <james@nerdc0re.com>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* James Martelletti <james@nerdc0re.com>
*
*
/*
* Copyright (c) 2007-2014, Anthony Minessale II
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
- *
+ *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Michael B. Murdock <mike@mmurdock.org>
* Daniel Swarbrick <daniel.swarbrick@gmail.com>
say_file("digits/1_n.wav");
} else {
say_file("digits/%d.wav", c);
- }
+ }
say_file("currency/and.wav");
}
if (method == SSM_COUNTED) {
if ( gender == SSG_MASCULINE ) {
- say_file("digits/h-%d0_m.wav", b);
+ say_file("digits/h-%d0_m.wav", b);
} else if ( gender == SSG_NEUTER ) {
- say_file("digits/h-%d0_n.wav", b);
+ say_file("digits/h-%d0_n.wav", b);
} else {
say_file("digits/h-%d0.wav", b);
}
} else {
if (method == SSM_COUNTED) {
if ( gender == SSG_MASCULINE ) {
- say_file("digits/h-%d%d_m.wav", b,c);
+ say_file("digits/h-%d%d_m.wav", b,c);
} else if ( gender == SSG_NEUTER ) {
- say_file("digits/h-%d%d_n.wav", b,c);
+ say_file("digits/h-%d%d_n.wav", b,c);
} else {
say_file("digits/h-%d%d.wav", b,c);
}
if (c) {
if (method == SSM_COUNTED) {
if ( gender == SSG_MASCULINE ) {
- say_file("digits/h-%d_m.wav", c);
+ say_file("digits/h-%d_m.wav", c);
} else if ( gender == SSG_NEUTER ) {
- say_file("digits/h-%d_n.wav", c);
+ say_file("digits/h-%d_n.wav", c);
} else {
say_file("digits/h-%d.wav", c);
}
} else {
/*"one" used as an article is feminine or masculine in german, e.g. voicemail-message is feminine
only applies to the likes of 1, 101, 1001 etc.*/
- if ( b == 0 && c == 1 && gender == SSG_FEMININE ) {
+ if ( b == 0 && c == 1 && gender == SSG_FEMININE ) {
say_file("digits/1_f.wav");
} else if ( b == 0 && c == 1 && what ) {
say_file("digits/1_n.wav");
if (say_dow) {
say_file("time/day-%d.wav", tm.tm_wday);
}
-
+
if (say_month) {
say_file("time/mon-%d.wav", tm.tm_mon);
}
}
say_file("time/oclock.wav");
-
+
if (tm.tm_min < 10) {
say_file("digits/0.wav");
say_num(tm.tm_min, SSM_PRONOUNCED);
dollars++;
}
-
+
/* Say dollar amount */
if (atoi(dollars) == 1) {
say_file("digits/1_n.wav");
/*
* Copyright (c) 2007-2014, Anthony Minessale II
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
- *
+ *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Michael B. Murdock <mike@mmurdock.org>
*
in -= places[(uint32_t) x] * num;
}
}
-
+
switch (say_args->method) {
case SSM_PRONOUNCED_YEAR:
uint8_t say_date = 0, say_time = 0, say_year = 0, say_month = 0, say_dow = 0, say_day = 0, say_yesterday = 0, say_today = 0;
const char *tz = NULL;
- tz = switch_say_file_handle_get_variable(sh, "timezone");
+ tz = switch_say_file_handle_get_variable(sh, "timezone");
if (say_args->type == SST_TIME_MEASUREMENT) {
case SST_SHORT_DATE_TIME:
say_time = 1;
//Time is in the future
- if ((tm.tm_year > tm_now.tm_year) ||
- (tm.tm_year == tm_now.tm_year && tm.tm_mon > tm_now.tm_mon) ||
+ if ((tm.tm_year > tm_now.tm_year) ||
+ (tm.tm_year == tm_now.tm_year && tm.tm_mon > tm_now.tm_mon) ||
(tm.tm_year == tm_now.tm_year && tm.tm_mon == tm_now.tm_mon && tm.tm_mday > tm_now.tm_mday))
{
say_date = 1;
static switch_status_t say_ip(switch_say_file_handle_t *sh,
char *tosay,
switch_say_args_t *say_args)
-
+
{
char *a, *b, *c, *d;
switch_status_t status = SWITCH_STATUS_FALSE;
-
+
if (!(a = strdup(tosay))) {
abort();
}
say_num(sh, atoi(d), say_args->method);
end:
-
+
free(a);
return status;
switch_say_file_handle_t *sh;
switch_status_t status = SWITCH_STATUS_FALSE;
switch_event_t *var_event = NULL;
-
+
if (session) {
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_channel_get_variables(channel, &var_event);
}
switch_say_file_handle_create(&sh, say_args->ext, &var_event);
-
+
status = say_cb(sh, tosay, say_args);
if ((*rstr = switch_say_file_handle_detach_path(sh))) {
if (session && string) {
status = switch_ivr_play_file(session, NULL, string, args);
}
-
+
switch_safe_free(string);
}
say_interface->interface_name = "en";
say_interface->say_function = en_say;
say_interface->say_string_function = en_say_string;
-
+
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}
/*
* Copyright (c) 2007-2014, Anthony Minessale II
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
- *
+ *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Michael B. Murdock <mike@mmurdock.org>
* François Delawarde <fdelawarde@wirelessmundi.com>
/*
* Copyright (c) 2007-2014, Anthony Minessale II
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
- *
+ *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Michael B. Murdock <mike@mmurdock.org>
* François Delawarde <fdelawarde@wirelessmundi.com>
in -= places[(uint32_t) x] * num;
}
}
-
+
switch (say_args->method) {
case SSM_PRONOUNCED_YEAR:
uint8_t say_date = 0, say_time = 0, say_year = 0, say_month = 0, say_dow = 0, say_day = 0, say_yesterday = 0, say_today = 0;
const char *tz = NULL;
- tz = switch_say_file_handle_get_variable(sh, "timezone");
+ tz = switch_say_file_handle_get_variable(sh, "timezone");
if (say_args->type == SST_TIME_MEASUREMENT) {
int64_t hours = 0;
case SST_SHORT_DATE_TIME:
say_time = 1;
//Time is in the future
- if ((tm.tm_year > tm_now.tm_year) ||
- (tm.tm_year == tm_now.tm_year && tm.tm_mon > tm_now.tm_mon) ||
+ if ((tm.tm_year > tm_now.tm_year) ||
+ (tm.tm_year == tm_now.tm_year && tm.tm_mon > tm_now.tm_mon) ||
(tm.tm_year == tm_now.tm_year && tm.tm_mon == tm_now.tm_mon && tm.tm_mday > tm_now.tm_mday))
{
say_date = 1;
static switch_status_t say_ip(switch_say_file_handle_t *sh,
char *tosay,
switch_say_args_t *say_args)
-
+
{
char *a, *b, *c, *d;
switch_status_t status = SWITCH_STATUS_FALSE;
-
+
if (!(a = strdup(tosay))) {
abort();
}
say_num(sh, atoi(d), say_args->method);
end:
-
+
free(a);
return status;
switch_say_file_handle_t *sh;
switch_status_t status = SWITCH_STATUS_FALSE;
switch_event_t *var_event = NULL;
-
+
if (session) {
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_channel_get_variables(channel, &var_event);
}
switch_say_file_handle_create(&sh, say_args->ext, &var_event);
-
+
status = say_cb(sh, tosay, say_args);
if ((*rstr = switch_say_file_handle_detach_path(sh))) {
if (session && string) {
status = switch_ivr_play_file(session, NULL, string, args);
}
-
+
switch_safe_free(string);
}
say_interface->interface_name = "es_ar";
say_interface->say_function = es_say;
say_interface->say_string_function = es_say_string;
-
+
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}
/*
* Copyright (c) 2007, Anthony Minessale II
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
- *
+ *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Mahdi Moradi <m.moradi@sepanta.net>
* Babak Yakhchali <b.yakhchali@sepanta.net>
int jy, jm, jd;
long g_day_no, j_day_no;
int j_np;
-
+
int i;
gy = g_y-1600;
gm = g_m-1;
gd = g_d-1;
-
+
g_day_no = 365*gy+(gy+3)/4-(gy+99)/100+(gy+399)/400;
for (i=0;i<gm;++i)
g_day_no += g_days_in_month[i];
/* leap and after Feb */
++g_day_no;
g_day_no += gd;
-
+
j_day_no = g_day_no-79;
-
+
j_np = j_day_no / 12053;
j_day_no %= 12053;
-
+
jy = 979+33*j_np+4*(j_day_no/1461);
j_day_no %= 1461;
-
+
if (j_day_no >= 366) {
jy += (j_day_no-1)/365;
j_day_no = (j_day_no-1)%365;
}
-
+
for (i = 0; i < 11 && j_day_no >= j_days_in_month[i]; ++i) {
j_day_no -= j_days_in_month[i];
}
g_day_no--;
gy += 100*(g_day_no/36524); /* 36524 = 365*100 + 100/4 - 100/100 */
g_day_no = g_day_no % 36524;
-
+
if (g_day_no >= 365)
g_day_no++;
else
/*
* Copyright (c) 2007-2014, Anthony Minessale II
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
- *
+ *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Michael B. Murdock <mike@mmurdock.org>
* Marc O. Chouinard <mochouinard@moctel.com>
int ftdNumber = 0;
int itd = (b * 10) + c;
- /* Force full 2 digit playback */
+ /* Force full 2 digit playback */
if (itd <= 19)
ftdNumber = 1;
switch (itd) {
int fVal = c;
if (ftdNumber == 1)
fVal = itd;
-
+
if (method == SSM_COUNTED) {
say_file("digits/h-%d.wav", fVal);
} else {
/*
* Copyright (c) 2011-2012, Shahar Hadas
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
- *
+ *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* the Initial Developers. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* mod_say_he.c -- Say for Hebrew
*
*/
/* Check for special cases of thousands */
if (range == PGR_THOUSANDS && a == 0) {
- /* Check for special cases of 1000, 2000 ... 8000, 9000 */
+ /* Check for special cases of 1000, 2000 ... 8000, 9000 */
if (b == 0 && c != 0) {
switch_say_file(sh, "digits/%d000", c);
return SWITCH_STATUS_SUCCESS;
if (b == 1 && c == 0) {
switch_say_file(sh, "digits/10000");
return SWITCH_STATUS_SUCCESS;
- }
+ }
}
-
+
/* Check for special case of million */
if (range == PGR_MILLIONS && a == 0 && b == 0 && c == 1) {
switch_say_file(sh, "digits/million");
- return SWITCH_STATUS_SUCCESS;
+ return SWITCH_STATUS_SUCCESS;
}
- /* Check for Hebrew SSM_COUNTED special case. Anything above 10 needs to said differently */
+ /* Check for Hebrew SSM_COUNTED special case. Anything above 10 needs to said differently */
if (method == SSM_COUNTED && range == PGR_HUNDREDS && total <= 10) {
if (b) {
switch_say_file(sh, "digits/h-10%s", gender == SSG_MASCULINE ? "_m" : "");
/* In Hebrew, hundreds can be said as "<number> hundreds", but the more correct
* form of pronunciation required it to be recorded separately.
- * Note that hundreds are always pronounced in SSG_FEMININE form in hebrew, and were recorded as such.
+ * Note that hundreds are always pronounced in SSG_FEMININE form in hebrew, and were recorded as such.
*/
if (a) {
switch_say_file(sh, "digits/%d00", a);
case 5:
switch_say_file(sh, "digits/va");
break;
-
+
case 2:
case 3:
case 8:
- case 9:
+ case 9:
switch_say_file(sh, "digits/uu");
- break;
+ break;
case 1:
case 4:
case 6:
- case 7:
+ case 7:
switch_say_file(sh, "digits/ve");
- break;
-
+ break;
+
default:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "play_group unkonwn digit (%d) Error! (SSG_MASCULINE)\n", c);
- break;
- }
- }
+ break;
+ }
+ }
switch_say_file(sh, "digits/%d%d_m", b, c);
} else {
if ((range == PGR_MILLIONS && a) || (range != PGR_MILLIONS && total > 9)){ /* Check if need to say "and" */
case 3:
case 7:
case 8:
- case 9:
+ case 9:
switch_say_file(sh, "digits/uu");
- break;
-
+ break;
+
case 0:
case 1:
case 4:
case 5:
- case 6:
+ case 6:
switch_say_file(sh, "digits/ve");
- break;
+ break;
default:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "play_group unkonwn digit (%d) Error! (SSG_FEMININE)\n", c);
- break;
- }
- }
+ break;
+ }
+ }
switch_say_file(sh, "digits/%d%d", b, c);
}
c = 0; /* Skip the pronunciation on the c value */
case 5:
switch_say_file(sh, "digits/va");
break;
-
+
case 2:
- case 3:
- case 8:
+ case 3:
+ case 8:
switch_say_file(sh, "digits/uu");
break;
-
+
case 1:
case 4:
case 6:
case 7:
- case 9:
+ case 9:
switch_say_file(sh, "digits/ve");
break;
-
+
default:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "play_group unkonwn digit (%d) Error! (SSG_MASCULINE)\n", c);
- break;
- }
- }
+ break;
+ }
+ }
switch_say_file(sh, "digits/%d_m", c);
} else {
if ((range == PGR_MILLIONS && (b || a)) || (range != PGR_MILLIONS && total > 9)){ /* Check if need to say "and" */
case 8:
switch_say_file(sh, "digits/uu");
break;
-
+
case 1:
- case 3:
+ case 3:
case 4:
case 5:
case 6:
case 7:
- case 9:
+ case 9:
switch_say_file(sh, "digits/ve");
break;
-
+
default:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "play_group unkonwn digit (%d) Error! (SSG_FEMININE)\n", c);
- break;
- }
- }
+ break;
+ }
+ }
switch_say_file(sh, "digits/%d", c);
- }
+ }
}
if (what && (a || b || c)) {
switch (say_args->method) {
case SSM_COUNTED:
/* TODO add 'ha' (the)? */
- case SSM_PRONOUNCED:
+ case SSM_PRONOUNCED:
if ((status = play_group(SSM_PRONOUNCED, say_args->gender, inCopy, PGR_MILLIONS, places[8], places[7], places[6], "digits/million", sh)) != SWITCH_STATUS_SUCCESS) {
return status;
}
uint8_t say_date = 0, say_time = 0, say_year = 0, say_month = 0, say_dow = 0, say_day = 0, say_yesterday = 0, say_today = 0;
const char *tz = NULL;
- tz = switch_say_file_handle_get_variable(sh, "timezone");
+ tz = switch_say_file_handle_get_variable(sh, "timezone");
if (say_args->type == SST_TIME_MEASUREMENT) {
int64_t hours = 0;
say_args->gender = SSG_FEMININE;
- if (hours) {
+ if (hours) {
switch_say_file(sh, "time/hour");
say_num(sh, hours, SSM_PRONOUNCED);
} else {
switch_say_file(sh, "time/minutes");
}
- if (seconds) {
+ if (seconds) {
if (seconds == 1) {
switch_say_file(sh, "time/second");
say_num(sh, seconds, SSM_PRONOUNCED);
if (tz) {
int check = atoi(tz);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Timezone is [%s]\n", tz);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Timezone is [%s]\n", tz);
if (check) {
switch_time_exp_tz(&tm, target, check);
switch_time_exp_tz(&tm_now, target_now, check);
if (say_day) {
say_args->gender = SSG_MASCULINE;
say_num(sh, tm.tm_mday, SSM_PRONOUNCED);
- }
+ }
if (say_month) {
switch_say_file(sh, "time/at");
switch_say_file(sh, "time/mon-%d", tm.tm_mon);
say_args->gender = SSG_FEMININE;
say_num(sh, hour, SSM_PRONOUNCED);
- if (tm.tm_min) {
+ if (tm.tm_min) {
switch (tm.tm_min) {
case 2:
case 8:
case 30:
switch_say_file(sh, "digits/uu");
break;
-
+
case 50:
switch_say_file(sh, "digits/va");
break;
-
+
default:
switch_say_file(sh, "digits/ve");
- break;
+ break;
}
if (tm.tm_min == 1) {
switch_say_file(sh, "digits/1");
} else {
say_num(sh, tm.tm_min, SSM_PRONOUNCED);
- switch_say_file(sh, "time/minutes");
- }
+ switch_say_file(sh, "time/minutes");
+ }
}
-
+
switch_say_file(sh, "time/%s", pm ? "p-m" : "a-m");
}
static switch_status_t he_say_money(switch_say_file_handle_t *sh, char *tosay, switch_say_args_t *say_args)
-{
+{
char sbuf[16] = ""; /* enough for 999,999,999,999.99 (w/o the commas or leading $) */
char *currency = NULL;
char *cents = NULL;
}
currency = sbuf;
-
+
if ((cents = strchr(sbuf, '.'))) {
*cents++ = '\0';
if (strlen(cents) > 2) {
++currency;
}
- /* Say shekel amount (Israel currency) */
+ /* Say shekel amount (Israel currency) */
switch (atoi(currency)) {
case 1:
switch_say_file(sh, "currency/shekel");
switch_say_file(sh, "digits/1_m");
break;
-
+
case 2:
/* In the case of 2, because currency, we need a special case of 2 pronunciation */
- switch_say_file(sh, "digits/shney");
+ switch_say_file(sh, "digits/shney");
switch_say_file(sh, "currency/shkalim");
break;
-
+
default:
say_args->gender = SSG_MASCULINE;
he_say_general_count(sh, currency, say_args);
switch_say_file(sh, "currency/shkalim");
- break;
+ break;
}
- if (cents) {
+ if (cents) {
/* We need to use the value twice, so speed it up by atoi only once */
icents = atoi(cents);
-
- /* Say "and" */
+
+ /* Say "and" */
switch (icents) {
case 2:
case 8:
case 30:
case 80:
switch_say_file(sh, "digits/uu");
- break;
-
+ break;
+
case 50:
switch_say_file(sh, "digits/va");
break;
-
+
default:
switch_say_file(sh, "digits/ve");
- break;
- }
-
+ break;
+ }
+
/* Say agorot (Israel currency equivalent for "cents") */
switch (icents) {
case 0:
switch_say_file(sh, "digits/0");
switch_say_file(sh, "currency/agorot");
break;
-
+
case 1:
switch_say_file(sh, "currency/agora");
switch_say_file(sh, "digits/1");
break;
-
+
case 2:
/* In the case of 2, because currency, we need a special case of 2 pronunciation */
- switch_say_file(sh, "digits/shtey");
+ switch_say_file(sh, "digits/shtey");
switch_say_file(sh, "currency/agorot");
break;
-
+
default:
say_args->gender = SSG_FEMININE;
he_say_general_count(sh, cents, say_args);
switch_say_file(sh, "currency/agorot");
- break;
+ break;
}
}
static switch_status_t say_ip(switch_say_file_handle_t *sh,
char *tosay,
switch_say_args_t *say_args)
-
+
{
char *a, *b, *c, *d;
switch_status_t status = SWITCH_STATUS_FALSE;
-
+
if (!(a = strdup(tosay))) {
abort();
}
say_num(sh, atoi(d), say_args->method);
end:
-
+
free(a);
return status;
switch_say_file_handle_t *sh;
switch_status_t status = SWITCH_STATUS_FALSE;
switch_event_t *var_event = NULL;
-
+
if (session) {
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_channel_get_variables(channel, &var_event);
}
switch_say_file_handle_create(&sh, say_args->ext, &var_event);
-
+
status = say_cb(sh, tosay, say_args);
if ((*rstr = switch_say_file_handle_detach_path(sh))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "** he_say [%s]\n", string);
status = switch_ivr_play_file(session, NULL, string, args);
}
-
+
switch_safe_free(string);
}
/*
* Copyright (c) 2007-2014, Anthony Minessale II
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
- *
+ *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Michael B. Murdock <mike@mmurdock.org>
- * Tihomir Culjaga <tculjaga@gmail.com>
+ * Tihomir Culjaga <tculjaga@gmail.com>
*
* mod_say_hr.c -- Say for Croatian
*
char tisucu[64] = "";
char tgen[8] = "";
char mgen[8] = "";
-
-
+
+
int number;
switch_status_t status;
strcpy(tgen, gen);
-
+
if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf)-1)) || strlen(tosay) > 9) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
strcpy(milion, "digits/milijun.wav");
else
strcpy(milion, "digits/milijuna.wav");
-
- if (places[4] == 1)
+
+ if (places[4] == 1)
{
strcpy(tisucu, "digits/thousands-a.wav");
}
strcpy(tisucu, "digits/thousands-a.wav");
strcpy(tgen, "a");
break;
-
+
case 5:
case 6:
case 7:
case 9:
strcpy(tisucu, "digits/thousands-a.wav");
break;
-
+
case 2:
strcpy(tgen, "je");
strcpy(tisucu, "digits/thousands-e.wav");
break;
-
+
case 3:
case 4:
strcpy(tisucu, "digits/thousands-e.wav");
strcpy(tisucu, "digits/thousands-a.wav");
strcpy(tgen, "a");
break;
-
+
case 5:
case 6:
case 7:
case 9:
strcpy(tisucu, "digits/thousands-a.wav");
break;
-
+
case 2:
strcpy(tisucu, "digits/thousands-e.wav");
strcpy(tgen, "je");
break;
-
+
case 3:
case 4:
strcpy(tisucu, "digits/thousands-e.wav");
}
}
-
+
if ((status =
play_group(SSM_PRONOUNCED, mgen, places[8], places[7], places[6], milion, number, session, args)) != SWITCH_STATUS_SUCCESS) {
return status;
uint8_t say_date = 0, say_time = 0, say_year = 0, say_month = 0, say_dow = 0, say_day = 0, say_yesterday = 0, say_today = 0;
switch_channel_t *channel = switch_core_session_get_channel(session);
const char *tz = switch_channel_get_variable(channel, "timezone");
-
+
int sat_desetinka = 0;
int sat_jedinica = 0;
int minuta_desetinka = 0;
}
sat_jedinica = hours % 10;
-
+
if (hours > 10)
sat_desetinka = (int) (hours / 10);
-
- if (hours)
+
+ if (hours)
{
say_num(hours, SSM_PRONOUNCED, "");
-
+
if (sat_desetinka == 0 && sat_jedinica == 0)
{
nop;
case 1:
say_file("time/sat.wav");
break;
-
+
case 2:
case 3:
case 4:
say_file("time/sata.wav");
break;
-
+
case 0:
case 5:
case 6:
break;
}
}
- }
+ }
minuta_jedinica = minutes % 10;
-
+
if (minutes > 10)
minuta_desetinka = (int) (minutes / 10);
-
- if (minutes)
+
+ if (minutes)
{
-
-
+
+
if (minuta_desetinka == 1)
{
say_num(minutes, SSM_PRONOUNCED, "");
say_num(minutes, SSM_PRONOUNCED, "je");
say_file("time/minute.wav");
break;
-
+
case 3:
case 4:
say_num(minutes, SSM_PRONOUNCED, "");
say_file("time/minute.wav");
break;
-
+
case 1:
say_num(minutes, SSM_PRONOUNCED, "a");
say_file("time/minuta.wav");
break;
-
+
case 0:
case 5:
case 6:
break;
}
}
- }
+ }
sekunda_jedinica = seconds % 10;
-
+
if (seconds > 10)
sekunda_desetinka = (int) (seconds / 10);
-
- if (seconds)
+
+ if (seconds)
{
if (sekunda_desetinka == 1)
{
say_num(seconds, SSM_PRONOUNCED, "a");
say_file("time/sekunda.wav");
break;
-
+
case 2:
say_num(seconds, SSM_PRONOUNCED, "je");
say_file("time/sekunde.wav");
break;
-
+
case 3:
case 4:
say_num(seconds, SSM_PRONOUNCED, "");
say_file("time/sekunde.wav");
break;
-
+
case 0:
case 5:
case 6:
say_num(seconds, SSM_PRONOUNCED, "a");
say_file("time/sekunda.wav");
break;
-
+
case 2:
say_num(seconds, SSM_PRONOUNCED, "je");
say_file("time/sekunde.wav");
break;
-
+
case 3:
case 4:
say_num(seconds, SSM_PRONOUNCED, "");
say_file("time/sekunde.wav");
break;
-
+
case 0:
case 5:
case 6:
break;
}
}
- }
+ }
return SWITCH_STATUS_SUCCESS;
}
if (say_day) {
say_num(tm.tm_mday, SSM_COUNTED, "");
}
-
+
if (say_month) {
say_file("time/mon-%d.wav", tm.tm_mon);
}
-
+
if (say_year) {
int y = tm.tm_year + 1900;
int tis = 0;
-
+
//say_num(tm.tm_year + 1900, SSM_PRONOUNCED, "");
//1 - 99 => h-1a.wav - h-99a.wav
if (y >= 1 && y <= 99)
say_file("digits/thousand-u.wav");
if (0 != (int) ((y - 1000) - ((y - 1000) % 100)))
say_file("digits/h-%da.wav", (int) ((y - 1000) - ((y - 1000) % 100)));
-
+
say_file("digits/h-%da.wav", (int) y % 100);
}
//2000 => 2je.wav + thousand-ta.wav
say_file("digits/thousands-e.wav");
if (0 != (int) ((y - 2000) - ((y - 2000) % 100)))
say_file("digits/h-%da.wav", (int) ((y - 2000) - ((y - 2000) % 100)));
-
+
say_file("digits/h-%da.wav", (int) y % 100);
}
// 3000 => [3-9].wav + thousand-ta.wav
tis = y - (y % 1000);
if (0 != (int) ((y - tis) - ((y - tis) % 100)))
say_file("digits/h-%da.wav", (int) ((y - tis) - ((y - tis) % 100)));
-
+
say_file("digits/h-%da.wav", (int) y % 100);
}
-
+
//say_num(tm.tm_year + 1900, SSM_COUNTED, "a");
}
-
- if (say_time)
+
+ if (say_time)
{
say_num(tm.tm_hour, SSM_PRONOUNCED, "");
-
+
sat_jedinica = tm.tm_hour % 10;
-
+
if (tm.tm_hour >= 10)
sat_desetinka = (int) (tm.tm_hour / 10);
-
-
- if (tm.tm_hour)
+
+
+ if (tm.tm_hour)
{
if (sat_desetinka == 0 && sat_jedinica == 0)
{
case 1:
say_file("time/sat.wav");
break;
-
+
case 2:
case 3:
case 4:
say_file("time/sata.wav");
break;
-
+
case 0:
case 5:
case 6:
case 9:
say_file("time/sati.wav");
break;
-
+
}
}
- }
-
+ }
+
minuta_jedinica = tm.tm_min % 10;
-
+
if (tm.tm_min >= 10)
minuta_desetinka = (int) (tm.tm_min / 10);
-
- if (tm.tm_min)
+
+ if (tm.tm_min)
{
if (minuta_desetinka == 1)
{
say_num(tm.tm_min, SSM_PRONOUNCED, "je");
say_file("time/minute.wav");
break;
-
+
case 3:
case 4:
say_num(tm.tm_min, SSM_PRONOUNCED, "");
say_file("time/minute.wav");
break;
-
+
case 1:
say_num(tm.tm_min, SSM_PRONOUNCED, "a");
say_file("time/minuta.wav");
break;
-
+
case 0:
case 5:
case 6:
break;
}
}
- }
-
+ }
+
sekunda_jedinica = tm.tm_sec % 10;
-
+
if (tm.tm_sec >= 10)
sekunda_desetinka = (int) (tm.tm_sec / 10);
-
- if (tm.tm_sec)
+
+ if (tm.tm_sec)
{
if (sekunda_desetinka == 1)
{
say_num(tm.tm_sec, SSM_PRONOUNCED, "a");
say_file("time/sekunda.wav");
break;
-
+
case 2:
say_num(tm.tm_sec, SSM_PRONOUNCED, "je");
say_file("time/sekunde.wav");
break;
-
+
case 3:
case 4:
say_num(tm.tm_sec, SSM_PRONOUNCED, "");
say_file("time/sekunde.wav");
break;
-
+
case 0:
case 5:
case 6:
say_num(tm.tm_sec, SSM_PRONOUNCED, "a");
say_file("time/sekunda.wav");
break;
-
+
case 2:
say_num(tm.tm_sec, SSM_PRONOUNCED, "je");
say_file("time/sekunde.wav");
break;
-
+
case 3:
case 4:
say_num(tm.tm_sec, SSM_PRONOUNCED, "");
say_file("time/sekunde.wav");
break;
-
+
case 0:
case 5:
case 6:
break;
}
}
- }
+ }
}
return SWITCH_STATUS_SUCCESS;
char sbuf[16] = "";
char *kuna = NULL;
char *lipa = NULL;
-
+
int zadnja_kuna = 0;
int predzadnja_kuna = 0;
int zadnja_lipa = 0;
int predzadnja_lipa = 0;
- if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)-1)))
+ if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)-1)))
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
}
kuna = sbuf;
-
- if ((lipa = strchr(sbuf, '.')))
+
+ if ((lipa = strchr(sbuf, '.')))
{
*lipa++ = '\0';
- if (strlen(lipa) > 2)
+ if (strlen(lipa) > 2)
{
lipa[2] = '\0';
}
}
- if (sbuf[0] == '+')
+ if (sbuf[0] == '+')
{
kuna++;
}
- if (sbuf[0] == '-')
+ if (sbuf[0] == '-')
{
say_file("currency/negative.wav");
kuna++;
if (kuna != NULL && strlen(kuna) > 0)
zadnja_kuna = (int) ((char) *(kuna + strlen(kuna) - 1) - '0');
-
+
if (kuna != NULL && strlen(kuna) > 1)
predzadnja_kuna = (int) ((char) *(kuna + strlen(kuna) - 2) - '0');
-
-
+
+
if (predzadnja_kuna == 1)
{
hr_say_count(session, "", kuna, say_args, args);
say_file("currency/kuna.wav");
break;
- case 0:
+ case 0:
case 5:
case 6:
case 7:
hr_say_count(session, "", kuna, say_args, args);
say_file("currency/kuna.wav");
break;
-
+
case 2:
hr_say_count(session, "je", kuna, say_args, args);
say_file("currency/kune.wav");
break;
-
+
case 3:
case 4:
hr_say_count(session, "", kuna, say_args, args);
break;
}
}
-
+
if (lipa)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "lipa:%s \n", lipa);
else
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "lipa: NULL \n");
-
+
if (lipa)
{
/* Say "and" */
say_file("currency/and.wav");
-
+
if (lipa != NULL && strlen(lipa) > 0)
zadnja_lipa = (int) ((char) *(lipa + strlen(lipa) - 1) - '0');
-
+
if (lipa != NULL && strlen(lipa) > 1)
predzadnja_lipa = (int) ((char) *(lipa + strlen(lipa) - 2) - '0');
-
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "zadnja_lipa:%d \n", zadnja_lipa);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "predzadnja_lipa:%d \n", predzadnja_lipa);
-
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "zadnja_lipa:%d \n", zadnja_lipa);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "predzadnja_lipa:%d \n", predzadnja_lipa);
+
if (predzadnja_lipa == 1)
{
hr_say_count(session, "", lipa, say_args, args);
say_file("currency/lipa.wav");
break;
- case 0:
+ case 0:
case 5:
case 6:
case 7:
hr_say_count(session, "", lipa, say_args, args);
say_file("currency/lipa.wav");
break;
-
+
case 2:
hr_say_count(session, "je", lipa, say_args, args);
say_file("currency/lipa.wav");
break;
-
+
case 3:
case 4:
hr_say_count(session, "", lipa, say_args, args);
/*
* Copyright (c) 2007-2014, Anthony Minessale II
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
- *
+ *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Michael B. Murdock <mike@mmurdock.org>
*
if (hours) {
say_num(hours, SSM_PRONOUNCED);
say_file("time/hour.wav");
- }
+ }
if (minutes) {
say_num(minutes, SSM_PRONOUNCED);
say_file("time/minute.wav");
/*
* Copyright (c) 2007-2014, Anthony Minessale II
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
- *
+ *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Michael B. Murdock <mike@mmurdock.org>
*
/*
* Copyright (c) 2007-2014, Anthony Minessale II
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
- *
+ *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Michael B. Murdock <mike@mmurdock.org>
* Leo Noordergraaf <leo.noordergraaf@deanconnect.nl>
/*
* Copyright (c) 2007, Anthony Minessale II
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
- *
+ *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Michael B. Murdock <mike@mmurdock.org>
* Mariusz Czułada <manieq.net@gmail.com>
static switch_status_t pl_say_ip(switch_say_file_handle_t *sh,
char *tosay,
switch_say_args_t *say_args)
-
+
{
char *a, *b, *c, *d;
switch_status_t status = SWITCH_STATUS_FALSE;
-
+
if (!(a = strdup(tosay))) {
abort();
}
say_num(sh, atoi(d), say_args->method, SSG_MASCULINE);
end:
-
+
free(a);
return status;
switch_say_file_handle_t *sh;
switch_status_t status = SWITCH_STATUS_FALSE;
switch_event_t *var_event = NULL;
-
+
if (session) {
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_channel_get_variables(channel, &var_event);
}
switch_say_file_handle_create(&sh, say_args->ext, &var_event);
-
+
status = say_cb(sh, tosay, say_args);
if ((*rstr = switch_say_file_handle_detach_path(sh))) {
if (session && string) {
status = switch_ivr_play_file(session, NULL, string, args);
}
-
+
switch_safe_free(string);
}
say_interface->interface_name = "pl";
say_interface->say_function = pl_say;
say_interface->say_string_function = pl_say_string;
-
+
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}
/*
* Copyright (c) 2007-2014, Anthony Minessale II
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
- *
+ *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Michael B. Murdock <mike@mmurdock.org>
* António Silva <asilva@wirelessmundi.com>
if (tm.tm_min) {
say_file("currency/and.wav");
say_num(tm.tm_min, SSM_PRONOUNCED);
- } else {
+ } else {
say_file("time/oclock.wav");
}
/*
* Copyright (c) 2007-2014, Anthony Minessale II
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
- *
+ *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Michael B. Murdock <mike@mmurdock.org>
* Boris Buklov (BBV) <buklov@mail.ru>
}
}
- //миллионы
+ //миллионы
if (places[8] || places[7] || places[6]) {
if ((in_ % 1000000 > 0) && (matrix[cases][gender].all != 1)) { // если поле миллионов есть цифры поизнести как числительое именительного падежа
if ((status = play_group(male, nominativus, places[8], places[7], places[6], million, sh)) != SWITCH_STATUS_SUCCESS) {
}
}
}
- //тысячи
+ //тысячи
if (places[5] || places[4] || places[3]) {
if ((in_ % 1000 > 0) && (matrix[cases][gender].all != 1)) { // если поле миллионов есть цифры поизнести как числительое именительного падежа
if ((status = play_group(male, nominativus, places[5], places[4], places[3], thousand, sh)) != SWITCH_STATUS_SUCCESS) {
else {
switch_say_file(sh, "currency/%s",matrix_currency[say_opt->currency].first[5]);
}
-
-
+
+
/* Say kopecks */
ru_say_count(sh, kopecks, matrix_currency[say_opt->currency].second_gender,matrix_currency[say_opt->currency].second_cases);
switch_time_exp_t tm, tm_now;
uint8_t say_date = 0, say_time = 0, say_year = 0, say_month = 0, say_dow = 0, say_day = 0, say_yesterday = 0, say_today = 0;
const char *tz = NULL;
- tz = switch_say_file_handle_get_variable(sh, "timezone");
+ tz = switch_say_file_handle_get_variable(sh, "timezone");
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " ru_say_time %s type=%d method=%d\n", tosay, say_args->type, say_args->method);
case SST_ITEMS:
case SST_PERSONS:
case SST_MESSAGES:
-
+
say_cb = ru_say_general_count;
break;
case SST_TIME_MEASUREMENT:
}
-
+
static switch_status_t run_callback(switch_new_say_callback_ru_t say_cb, char *tosay, switch_say_args_t *say_args, switch_core_session_t *session, char **rstr)
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "ru_say!!! %s %s %s !\n",gender, cases,currency);
if (cases) {
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "ru_say!!! %s!\n", cases);
-
+
if ((strcmp(cases,"nominativus")==0) || (strcmp(cases,"именительный")==0)) {
say_opt.cases=(cases_t)0;
}
}
if (gender) {
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "ru_say!!! %s!\n", gender);
-
+
if ((strcmp(gender,"male")==0) || (strcmp(gender,"мужской")==0)) {
say_opt.gender=(say_gender_t)0;
}
if ((strcmp(gender,"plural_h")==0) || (strcmp(gender,"множественное_порядковый")==0)) {
say_opt.gender=(say_gender_t)7;
}
-
+
}
if (currency) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "ru_say!!! %s!\n", currency);
-
+
if ((strcmp(currency,"ruble")==0) || (strcmp(currency,"рубль")==0)) {
say_opt.currency=(currency_t)0;
// switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "rul!!! \n");
-
+
}
if ((strcmp(currency,"dollar")==0) || (strcmp(currency,"доллар")==0)) {
// switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "dollar!!! !\n");
}
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "ru_say!!! %s! say_opt.gender=%d say_opt.cases=%d\n", tosay,say_opt.gender,say_opt.cases);
-
+
}
switch_say_file_handle_create(&sh, say_args->ext, &var_event);
//запуск ru_ip,ru_say_money ...
switch_new_say_callback_ru_t say_cb = NULL;
char *string = NULL;
switch_status_t status;
-
+
status = SWITCH_STATUS_FALSE;
-
+
say_cb = choose_callback(say_args);
if (say_cb) {
//http://ru.wiktionary.org/wiki/%D0%BE%D0%B4%D0%B8%D0%BD
//http://ru.wiktionary.org/wiki/%D0%BF%D0%B5%D1%80%D0%B2%D1%8B%D0%B9
-
+
typedef enum {
million,
typedef struct {
say_gender_t gender;
cases_t cases;
- currency_t currency;
+ currency_t currency;
} say_opt_t;
char *second[6];
say_gender_t second_gender;
cases_t second_cases;
-
+
};
// описываем как произносить валяюты от 0 до 5 дальше идёт номер рода и падежа (с нуля)
typedef switch_status_t (*switch_new_say_callback_ru_t) (switch_say_file_handle_t *sh, char *tosay, switch_say_args_t *say_args,say_opt_t *say_opt);
-//именительный
+//именительный
//именительный количественный/числительное
//мужской род родительный падеж
-//дательный Кого? Что?
+//дательный Кого? Что?
//количественный/числительное
//мужской
#define m_20 {\
-//Винительный Кого? animate - одушевлённый
+//Винительный Кого? animate - одушевлённый
//количественный/числительное
//мужской
#define m_30 {\
-//Винительный Что? inanimate - неодушевлённый
+//Винительный Что? inanimate - неодушевлённый
//количественный/числительное
//мужской
#define m_40 {\
-//Творительный Кем? Чем?
+//Творительный Кем? Чем?
//количественный/числительное
//мужской
#define m_50 {\
-//Предложный О ком? О чём?
+//Предложный О ком? О чём?
//количественный/числительное
//мужской
#define m_60 {\
-//именительный
+//именительный
//именительный количественный/числительное
//мужской
#define m_60 {\
/*
* Copyright (c) 2007-2014, Anthony Minessale II
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
- *
+ *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Michael B. Murdock <mike@mmurdock.org>
* Daniel Swarbrick <daniel.swarbrick@gmail.com>
static switch_status_t play_group(switch_say_method_t method, switch_say_gender_t gender, int a, int b, int c, char *what, switch_say_file_handle_t *sh)
{
- /*swedish makes the distiction between utrum for "one" (en) and neutrum for "one" (ett), e.g. voicemail-message is neutrum but recording is utrum.
+ /*swedish makes the distiction between utrum for "one" (en) and neutrum for "one" (ett), e.g. voicemail-message is neutrum but recording is utrum.
This only applies to the likes of 1, 101, 1001 etc.
files referenced below:
SSM_COUNTED=r-%d
if (minutes == 0) {
switch_say_file(sh, "time/midnatt");
} else {
- switch_say_file(sh, "digits/0");
+ switch_say_file(sh, "digits/0");
switch_say_file(sh, "time/timmar");
}
}
/*
* Copyright (c) 2007-2014, Anthony Minessale II
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
- *
+ *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* PeteDao <petekay@gmail.com>
* Steve Underwood 0.0.1 <steveu@coppice.org>
* Dome Charoenyost <dome@tel.co.th>
- *
+ *
*
* mod_say_th.c -- Say for Thai
*
/*
* Copyright (c) 2007-2014, Anthony Minessale II
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
- *
+ *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* PeteDao <petekay@gmail.com>
* Steve Underwood 0.0.1 <steveu@coppice.org>
interval_timer_t interval_timers[MAX_INTERVAL + 1][TIMERS_PER_INTERVAL];
/** Maps IDs to timers */
interval_timer_t *active_interval_timers[MAX_ACTIVE_TIMERS];
- /** Next timer to assign for a particular interval */
+ /** Next timer to assign for a particular interval */
int next_interval_timer_num[MAX_INTERVAL + 1];
/** Synchronizes access to timer creation / deletion */
switch_mutex_t *interval_timers_mutex;
* Timer module interface: start a new timer
* @param timer the timer
* @return SWITCH_STATUS_SUCCESS if successful otherwise SWITCH_STATUS_GENERR
- */
+ */
static switch_status_t mod_posix_timer_init(switch_timer_t *timer)
{
interval_timer_t *it;
sigaddset(&sigmask, SIG);
sigprocmask(SIG_BLOCK, &sigmask, NULL);
- /* set up signal handler */
+ /* set up signal handler */
memset(&sa, 0, sizeof(sa));
sa.sa_flags = SA_SIGINFO | SA_RESTART;
sa.sa_sigaction = timer_signal_handler;
/**
- * Return a random sample from a normal distrubtion centered at mean with
+ * Return a random sample from a normal distrubtion centered at mean with
* the specified standard deviation.
*
* THIS FUNCTION IS NOT REENTRANT!!!
return 0;
}
-/*
+/*
* Calculate x - y
* @return 0 if x is before y, the difference otherwise.
*/
y->tv_nsec += 1000000000 * nsec;
y->tv_sec -= nsec;
}
-
+
/* Return 0 if result is negative. */
if(x->tv_sec < y->tv_sec) {
return 0.0f;
int interval_counts[4] = { 0, 0, 0, 0 };
int toggle[2] = { 75, 100 };
int timer_count = 0;
-
+
int i = 0;
printf("test_create_destroy()\n");
for(i = 0; i < 100000000; i++) {
/* stop the timer */
timer_if->timer_destroy(&timer);
- if (!shutdown) {
+ if (!shutdown) {
check_result(d);
}
free(d);
return NULL;
}
-
+
/* return result */
return d;
}
int i = 0;
struct timespec start, now, period;
double elapsed = 0.0f;
-
+
printf("test_timer_session(%d, %f, %d, %d, %f, %f)\n", interval[0], test_duration, cps, max_sessions, duration_mean, duration_std_dev);
#ifndef SWITCH_H
-#define SWITCH_H
+#define SWITCH_H
#include <pthread.h>
#include <time.h>
<!-- optional: if not present we do log the b leg -->
<!-- true or false if we should create a cdr for the b leg of a call-->
<param name="log-b-leg" value="false"/>
-
+
<!-- optional: if not present, all filenames are the uuid of the call -->
<!-- true or false if a leg files are prefixed "a_" -->
<param name="prefix-a-leg" value="true"/>
<!-- encode the post data may be 'true' for url encoding, 'false' for no encoding, 'base64' for base64 encoding or 'textxml' for text/xml -->
<param name="encode" value="true"/>
- <!-- optional: set to true to disable Expect: 100-continue lighttpd requires this setting -->
- <!--<param name="disable-100-continue" value="true"/>-->
-
+ <!-- optional: set to true to disable Expect: 100-continue lighttpd requires this setting -->
+ <!--<param name="disable-100-continue" value="true"/>-->
+
<!-- optional: full path to the error log dir for failed web posts if not specified its the same as log-dir -->
<!-- either an absolute path, a relative path assuming ${prefix}/logs or a blank or omitted value will default to ${prefix}/logs/xml_cdr -->
<!-- <param name="err-log-dir" value="/tmp"/> -->
<!-- which auhtentification scheme to use. Supported values are: basic, digest, NTLM, GSS-NEGOTIATE or "any" for automatic detection -->
- <!--<param name="auth-scheme" value="basic"/>-->
+ <!--<param name="auth-scheme" value="basic"/>-->
<!-- optional: this will enable the CA root certificate check by libcurl to
verify that the certificate was issued by a major Certificate Authority.
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Brian West <brian@freeswitch.org>
* Bret McDanel <trixter AT 0xdecafbad.com>
* Justin Cassidy <xachenant@hotmail.com>
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_xml_cdr_shutdown);
SWITCH_MODULE_DEFINITION(mod_xml_cdr, mod_xml_cdr_load, mod_xml_cdr_shutdown, NULL);
-/* this function would have access to the HTML returned by the webserver, we don't need it
+/* this function would have access to the HTML returned by the webserver, we don't need it
* and the default curl activity is to print to stdout, something not as desirable
* so we have a dummy function here
*/
if (globals.ssl_cacert_file) {
switch_curl_easy_setopt(curl_handle, CURLOPT_CAINFO, globals.ssl_cacert_file);
}
-
+
if (globals.cookie_file) {
switch_curl_easy_setopt(curl_handle, CURLOPT_COOKIEJAR, globals.cookie_file);
switch_curl_easy_setopt(curl_handle, CURLOPT_COOKIEFILE, globals.cookie_file);
globals.cookie_file = switch_core_strdup(globals.pool, val);
}
}
-
+
if (zstr(globals.base_err_log_dir)) {
if (!zstr(globals.base_log_dir)) {
globals.base_err_log_dir = switch_core_strdup(globals.pool, globals.base_log_dir);
globals.base_err_log_dir = switch_core_sprintf(globals.pool, "%s%sxml_cdr", SWITCH_GLOBAL_dirs.log_dir, SWITCH_PATH_SEPARATOR);
}
}
-
+
}
if (globals.retries && globals.delay == 0) {
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Bret McDanel <trixter AT 0xdecafbad.com>
* Justin Cassidy <xachenant@hotmail.com>
* Bret McDanel <trixter AT 0xdecafbad.com>
* Justin Cassidy <xachenant@hotmail.com>
* John Skopis <john+fs@skopis.com>
- *
+ *
* mod_xml_ldap.c -- LDAP XML Gateway
*
*/
char *val;
xml_ldap_attribute_t *next;
};
-
+
SWITCH_MODULE_LOAD_FUNCTION(mod_xml_ldap_load);
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_xml_ldap_shutdown);
SWITCH_MODULE_DEFINITION(mod_xml_ldap, mod_xml_ldap_load, mod_xml_ldap_shutdown, NULL);
{
return SWITCH_STATUS_FALSE;
}
-
+
SWITCH_MODULE_LOAD_FUNCTION(mod_xml_ldap_load)
{
switch_api_interface_t *xml_ldap_api_interface;
"vm-skip-instructions", "vm-cc", "vm-disk-quota", "accountcode", "user_context",
"vm_mailbox", "callgroup", "effective_caller_id_number", "effective_caller_id_name",
"outbound_caller_id_number", "outbound_caller_id_name", "toll_allow", NULL };
-
+
basedn = switch_mprintf(binding->basedn, dir_domain);
filter = switch_mprintf(binding->filter, dir_exten);
-
+
if (param_event) {
char *expanded = switch_event_expand_headers(param_event, filter);
-
+
if (expanded != filter) {
free(filter);
filter = expanded;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "searching in basedn %s with filter %s\n", basedn, filter);
-
+
if ((ldap_search_s(ld, basedn, LDAP_SCOPE_SUB, filter, NULL, 0, &msg) != LDAP_SUCCESS))
goto cleanup;
val = ldap_get_values(ld, entry, key);
switch_xml_set_attr_d(xml, key, val[0]);
-
+
ldap_memfree(key);
ldap_value_free(val);
}
ber_free(ber, 0);
-
+
dn = ldap_get_dn(ld, entry);
rec(&xml, &off, ld, dn);
-
+
*xoff = 1;
}
ldap_value_free(val);
for (key = ldap_first_attribute(ld, entry, &ber); key != NULL; key = ldap_next_attribute(ld, entry, ber)) {
-
+
if (!strncasecmp("fstag", key, 5) || !strncasecmp("objectclass", key, 10)) {
ldap_memfree(key);
continue;
switch (binding->bt) {
case XML_LDAP_CONFIG:
break;
-
+
case XML_LDAP_DIRECTORY:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "from cb got %s=%s\n", hi->name, hi->value);
if (!strncmp(hi->name, "user", strlen(hi->name))) {
dir_domain = strdup(hi->value);
}
break;
-
+
case XML_LDAP_DIALPLAN:
case XML_LDAP_PHRASE:
break;
<extension name="rejections">
<condition field="${radius_auth_result}" expression="^2$">
- <action application="hangup" data="CALL_REJECTED"/>
+ <action application="hangup" data="CALL_REJECTED"/>
</condition>
</extension>
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* William King <william.king@quentustech.com>
*
* mod_xml_radius.c -- Radius authentication and authorization
*new_handle = NULL;
goto err;
}
-
+
if (rc_add_config(*new_handle, "auth_order", "radius", "mod_radius_cdr.c", 0) != 0) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error adding auth_order\n");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error adding auth_order\n");
goto err;
}
-
+
if ((server = switch_xml_child(xml, "connection")) == NULL ) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'connection' section in config file.\n");
- goto err;
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'connection' section in config file.\n");
+ goto err;
}
-
+
for (param = switch_xml_child(server, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr_soft(param, "name");
char *val = (char *) switch_xml_attr_soft(param, "value");
-
+
if ( GLOBAL_DEBUG ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Attempting to add param '%s' with value '%s' \n", var, val);
}
-
+
if (strncmp(var, "dictionary", 10) == 0) {
if ( rc_read_dictionary(*new_handle, val) != 0) {
goto err;
}
} else if (rc_add_config(*new_handle, var, val, "mod_xml_radius", 0) != 0) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error adding param '%s' with value '%s' \n", var, val);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error adding param '%s' with value '%s' \n", var, val);
goto err;
}
}
return SWITCH_STATUS_GENERR;
}
-switch_status_t do_config()
+switch_status_t do_config()
{
char *conf = "xml_radius.conf";
switch_xml_t xml, cfg, tmp, server, param;
seq = 1;
}
}
-
+
if ( serv && timeout && deadtime && retries && dict && seq ) {
globals.auth_invite_configs = tmp;
} else {
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'connection' section for auth_invite\n");
goto err;
- }
+ }
} else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Could not find 'auth_invite' section in config file.\n");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Could not find 'auth_invite' section in config file.\n");
}
-
+
serv = timeout = deadtime = retries = dict = seq = 0;
if ((tmp = switch_xml_dup(switch_xml_child(cfg, "auth_reg"))) != NULL ) {
if ( (server = switch_xml_child(tmp, "connection")) != NULL) {
seq = 1;
}
}
-
+
if ( serv && timeout && deadtime && retries && dict && seq ) {
globals.auth_reg_configs = tmp;
} else {
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'connection' section for auth_invite\n");
goto err;
- }
+ }
} else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Could not find 'auth_reg' section in config file.\n");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Could not find 'auth_reg' section in config file.\n");
}
if ((tmp = switch_xml_child(cfg, "global")) != NULL ) {
seq = 1;
}
}
-
+
if ( serv && timeout && deadtime && retries && dict && seq ) {
globals.auth_app_configs = tmp;
} else {
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'connection' section for auth_app\n");
goto err;
- }
+ }
} else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Could not find 'auth_app' section in config file.\n");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Could not find 'auth_app' section in config file.\n");
}
-
+
serv = timeout = deadtime = retries = dict = seq = 0;
if (( tmp = switch_xml_dup(switch_xml_child(cfg, "acct_start"))) != NULL ) {
if ( (server = switch_xml_child(tmp, "connection")) != NULL) {
seq = 1;
}
}
-
+
if ( serv && timeout && deadtime && retries && dict && seq ) {
globals.acct_start_configs = tmp;
} else {
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'connection' section for acct_start\n");
goto err;
- }
+ }
} else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Could not find 'acct_start' section in config file.\n");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Could not find 'acct_start' section in config file.\n");
}
-
+
serv = timeout = deadtime = retries = dict = seq = 0;
if (( tmp = switch_xml_dup(switch_xml_child(cfg, "acct_end"))) != NULL ) {
if ( (server = switch_xml_child(tmp, "connection")) != NULL) {
seq = 1;
}
}
-
+
if ( serv && timeout && deadtime && retries && dict && seq ) {
globals.acct_end_configs = tmp;
} else {
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'connection' section for acct_end\n");
goto err;
- }
+ }
} else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Could not find 'acct_end' section in config file.\n");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Could not find 'acct_end' section in config file.\n");
}
-
+
if ( xml ) {
switch_xml_free(xml);
xml = NULL;
}
return SWITCH_STATUS_SUCCESS;
-
+
err:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: Configuration error\n");
if ( xml ) {
switch_xml_free(xml);
xml = NULL;
}
-
+
return SWITCH_STATUS_GENERR;
}
-switch_status_t mod_xml_radius_add_params(switch_core_session_t *session, switch_event_t *params, rc_handle *handle, VALUE_PAIR **send, switch_xml_t fields)
+switch_status_t mod_xml_radius_add_params(switch_core_session_t *session, switch_event_t *params, rc_handle *handle, VALUE_PAIR **send, switch_xml_t fields)
{
switch_xml_t param;
void *av_value = NULL;
-
+
if ( (param = switch_xml_child(fields, "param")) == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to locate a param under the fields section\n");
- goto err;
+ goto err;
}
-
+
for (; param; param = param->next) {
DICT_ATTR *attribute = NULL;
DICT_VENDOR *vendor = NULL;
int attr_num = 0, vend_num = 0;
-
+
char *var = (char *) switch_xml_attr(param, "name");
char *vend = (char *) switch_xml_attr(param, "vendor");
char *variable = (char *) switch_xml_attr(param, "variable");
char *regex = (char *) switch_xml_attr(param, "regex");
attribute = rc_dict_findattr(handle, var);
-
+
if ( attribute == NULL ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: Could not locate attribute '%s' in the configured dictionary\n", var);
goto err;
}
-
+
if ( GLOBAL_DEBUG ) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: dict attr '%s' value '%d' type '%d'\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: dict attr '%s' value '%d' type '%d'\n",
attribute->name, attribute->value, attribute->type);
}
-
+
attr_num = attribute->value;
-
+
if ( vend ) {
vendor = rc_dict_findvend(handle, vend);
-
+
if ( vendor == NULL ) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: Could not locate vendor '%s' in the configured dictionary %p\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: Could not locate vendor '%s' in the configured dictionary %p\n",
vend, vend);
goto err;
- }
+ }
if ( GLOBAL_DEBUG ) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: dict vend name '%s' vendorpec '%d'\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: dict vend name '%s' vendorpec '%d'\n",
vendor->vendorname, vendor->vendorpec);
}
-
+
vend_num = vendor->vendorpec;
- }
-
+ }
+
if ( var ) {
if ( session ) {
switch_channel_t *channel = switch_core_session_get_channel(session);
if ( skip_if_set && switch_channel_get_variable(channel, skip_if_set) ) {
goto end_loop;
}
-
+
/* Accounting only */
if ( strncmp( var, "h323-setup-time", 15) == 0 ) {
switch_caller_profile_t *profile = switch_channel_get_caller_profile(channel);
switch_time_t time = profile->times->created;
switch_time_exp_t tm;
-
+
if ( !time ) {
goto end_loop;
}
-
+
switch_time_exp_lt(&tm, time);
-
+
if ( GLOBAL_TIME_FORMAT == 1 ) {
av_value = switch_mprintf("%02u:%02u:%02u.%03u %s %s %s %02u %04u",
tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_usec/1000,
if (rc_avpair_add(handle, send, attr_num, av_value, -1, vend_num) == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: failed to add option to handle\n");
goto err;
- }
+ }
if ( GLOBAL_DEBUG ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: value: %s\n", (char *) av_value);
}
if ( !time ) {
goto end_loop;
}
-
+
switch_time_exp_lt(&tm, time);
if ( GLOBAL_TIME_FORMAT == 1 ) {
if (rc_avpair_add(handle, send, attr_num, av_value, -1, vend_num) == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: failed to add option to handle\n");
goto err;
- }
+ }
if ( GLOBAL_DEBUG ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: value: %s\n", (char *) av_value);
}
goto end_loop;
}
}
-
+
switch_time_exp_lt(&tm, time);
if ( GLOBAL_TIME_FORMAT == 1 ) {
if (rc_avpair_add(handle, send, attr_num, av_value, -1, vend_num) == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: failed to add option to handle\n");
goto err;
- }
+ }
if ( GLOBAL_DEBUG ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: value: %s\n", (char *) av_value);
}
if (rc_avpair_add(handle, send, 30, av_value, -1, 9) == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: failed to add disconnect cause \n");
goto err;
- }
-
+ }
+
} else {
if ( format == NULL ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing format attribute for %s variable\n", variable);
if ( attribute->type == 0 ) {
const char *val = NULL;
-
+
if ( other_leg ) {
val = switch_channel_get_variable_partner(channel, variable);
if ( val == NULL && variable_secondary != NULL) {
val = switch_channel_get_variable(channel, variable_secondary);
}
}
-
+
if ( regex && val ) {
switch_regex_t *re = NULL;
int ovector[30];
}
switch_regex_safe_free(re);
}
-
+
if ( val == NULL && val_default != NULL) {
- av_value = switch_mprintf(format, val_default);
+ av_value = switch_mprintf(format, val_default);
} else {
av_value = switch_mprintf(format, val);
}
-
+
if ( GLOBAL_DEBUG ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: value: %s\n", (char *) av_value);
}
-
+
if (rc_avpair_add(handle, send, attr_num, av_value, -1, vend_num) == NULL) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"mod_xml_radius: failed to add option with val '%s' to handle\n", (char *) av_value);
goto err;
- }
+ }
} else if ( attribute->type == 1 ) {
const char *data = switch_channel_get_variable(channel, variable);
int number = 0;
-
+
if ( data ) {
number = atoi(data);
}
-
+
if (rc_avpair_add(handle, send, attr_num, &number, -1, vend_num) == NULL) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"mod_xml_radius: failed to add option with value '%d' to handle\n", number);
goto err;
- }
+ }
}
- }
+ }
} else if ( params ) {
/* Auth only */
char *tmp = switch_event_get_header(params, variable);
if ( GLOBAL_DEBUG ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: param var '%s' val: %s\n", variable, tmp);
}
-
+
if ( tmp == NULL ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: Unable to locate '%s' on the event\n", variable);
- goto err;
+ goto err;
}
-
+
av_value = switch_mprintf(format, tmp);
if (rc_avpair_add(handle, send, attr_num, av_value, -1, vend_num) == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: failed to add option to handle\n");
goto err;
- }
+ }
} else {
goto err;
}
av_value = NULL;
}
}
-
+
return SWITCH_STATUS_SUCCESS;
err:
if ( av_value != NULL ) {
av_value = NULL;
}
return SWITCH_STATUS_GENERR;
-
+
}
/* static switch_status_t name (_In_opt_z_ const char *cmd, _In_opt_ switch_core_session_t *session, _In_ switch_stream_handle_t *stream) */
if (GLOBAL_DEBUG ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: starting invite authentication\n");
}
-
+
if ( mod_xml_radius_new_handle(&new_handle, globals.auth_invite_configs) != SWITCH_STATUS_SUCCESS ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to load radius handle for digest invite authentication\n");
- goto err;
+ goto err;
}
if ( new_handle == NULL ) {
goto err;
}
-
+
if ((fields = switch_xml_child(globals.auth_invite_configs, "fields")) == NULL ) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'fields' section in config file.\n");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'fields' section in config file.\n");
goto err;
}
-
+
if ( mod_xml_radius_add_params(NULL, params, new_handle, &send, fields) != SWITCH_STATUS_SUCCESS ) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to add params to rc_handle\n");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to add params to rc_handle\n");
goto err;
}
-
+
if (rc_avpair_add(new_handle, &send, PW_SERVICE_TYPE, &service, -1, 0) == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: failed to add option to handle\n");
goto err;
}
-
+
result = rc_auth(new_handle, 0, send, &recv, msg);
-
+
if ( GLOBAL_DEBUG ){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: result(RC=%d) %s \n", result, msg);
}
-
+
if ( result != 0 ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: Failed to authenticate\n");
goto err;
switch_xml_set_attr_d(dom, "name", switch_event_get_header(params, "domain"));
usr = switch_xml_add_child_d(dom, "user", 0);
vars = switch_xml_add_child_d(usr, "variables", 0);
-
+
switch_xml_set_attr_d(usr, "id", switch_event_get_header(params, "user"));
-
+
var = switch_xml_add_child_d(vars, "variable", param_idx++);
switch_xml_set_attr_d(var, "name", "radius_auth_result");
switch_xml_set_attr_d(var, "value", "0");
if ( GLOBAL_DEBUG ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "XML: %s \n", switch_xml_toxml(xml, 1));
}
-
+
if ( recv ) {
rc_avpair_free(recv);
recv = NULL;
rc_destroy(new_handle);
new_handle = NULL;
}
-
+
return NULL;
}
if (GLOBAL_DEBUG ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: starting registration authentication\n");
}
-
+
if ( mod_xml_radius_new_handle(&new_handle, globals.auth_reg_configs) != SWITCH_STATUS_SUCCESS ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to load radius handle for registration authentication\n");
- goto err;
+ goto err;
}
if ( new_handle == NULL ) {
goto err;
}
-
+
if ((fields = switch_xml_child(globals.auth_reg_configs, "fields")) == NULL ) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'fields' section in config file.\n");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'fields' section in config file.\n");
goto err;
}
-
+
if ( mod_xml_radius_add_params(NULL, params, new_handle, &send, fields) != SWITCH_STATUS_SUCCESS ) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to add params to rc_handle\n");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to add params to rc_handle\n");
goto err;
}
-
+
if (rc_avpair_add(new_handle, &send, PW_SERVICE_TYPE, &service, -1, 0) == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: failed to add option to handle\n");
goto err;
}
-
+
result = rc_auth(new_handle, 0, send, &recv, msg);
-
+
if ( GLOBAL_DEBUG ){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: result(RC=%d) %s \n", result, msg);
}
-
+
if ( result != 0 ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: Failed to authenticate\n");
goto err;
switch_xml_set_attr_d(dom, "name", switch_event_get_header(params, "domain"));
usr = switch_xml_add_child_d(dom, "user", 0);
vars = switch_xml_add_child_d(usr, "variables", 0);
-
+
switch_xml_set_attr_d(usr, "id", switch_event_get_header(params, "user"));
-
+
service_vp = recv;
while (service_vp != NULL) {
rc_avpair_tostr(new_handle, service_vp, name, 512, value, 512);
if ( GLOBAL_DEBUG ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "XML: %s \n", switch_xml_toxml(xml, 1));
}
-
+
if ( recv ) {
rc_avpair_free(recv);
recv = NULL;
rc_destroy(new_handle);
new_handle = NULL;
}
-
+
return NULL;
}
-static switch_xml_t mod_xml_radius_directory_search(const char *section, const char *tag_name, const char *key_name, const char *key_value,
+static switch_xml_t mod_xml_radius_directory_search(const char *section, const char *tag_name, const char *key_name, const char *key_value,
switch_event_t *params, void *user_data)
{
char *event_buf = NULL;
switch_xml_t xml = NULL;
char *auth_method = switch_event_get_header(params,"sip_auth_method");
-
+
if ( GLOBAL_DEBUG ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: starting authentication\n");
switch_event_serialize(params, &event_buf, SWITCH_TRUE);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Event: %s \n", event_buf);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "\nSection: %s \nTag: %s\nKey_name: %s\nKey_value: %s\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "\nSection: %s \nTag: %s\nKey_name: %s\nKey_value: %s\n",
section, tag_name, key_name, key_value);
}
-
+
if ( auth_method == NULL) {
return NULL;
}
-
+
if ( strncmp( "INVITE", auth_method, 6) == 0) {
xml = mod_xml_radius_auth_invite(params);
} else if ( strncmp( "REGISTER", auth_method, 8) == 0) {
char *anti = NULL;
int all_matched = 1;
int result = 0;
-
+
if ( (condition = switch_xml_child(conditions, "condition")) == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to locate a condition under the conditions section\n");
return SWITCH_STATUS_FALSE;
}
-
+
for (; condition; condition = condition->next) {
-
+
if ( (param = switch_xml_child(condition, "param")) == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to locate a param under this condition\n");
return SWITCH_STATUS_FALSE;
}
-
+
all_matched = 1;
for (; param && all_matched; param = param->next) {
channel_var = (char *) switch_xml_attr(param, "var");
regex = (char *) switch_xml_attr(param, "regex");
anti = (char *) switch_xml_attr(param, "anti");
-
+
if ( channel_var == NULL || regex == NULL ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Improperly constructed mod_radius condition: %s %s\n", channel_var, regex);
continue;
}
-
+
if ( ( channel_val = switch_channel_get_variable(channel, channel_var) ) == NULL ) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"Improperly constructed mod_radius condition, no such channel variable: %s %s\n", channel_var, regex);
continue;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Didn't match: %s == %s \n", switch_channel_get_variable(channel, channel_var), regex);
all_matched = 0;
} else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Result of %s match: %s == %s \n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Result of %s match: %s == %s \n",
anti, switch_channel_get_variable(channel, channel_var), regex);
}
}
return SWITCH_STATUS_SUCCESS;
}
}
-
+
return SWITCH_STATUS_FALSE;
}
mod_xml_radius_check_conditions(channel, conditions) != SWITCH_STATUS_SUCCESS ) {
goto end;
}
-
+
if ( mod_xml_radius_new_handle(&new_handle, globals.acct_start_configs) != SWITCH_STATUS_SUCCESS || new_handle == NULL ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create new accounting_start handle for call: %s\n",
switch_channel_get_variable(channel, "uuid"));
- goto end;
+ goto end;
}
if ((fields = switch_xml_child(globals.acct_start_configs, "fields")) == NULL ) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'fields' section in config file.\n");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'fields' section in config file.\n");
goto end;
}
-
+
if ( mod_xml_radius_add_params(session, NULL, new_handle, &send, fields) != SWITCH_STATUS_SUCCESS ) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to add params to rc_handle\n");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to add params to rc_handle\n");
goto end;
}
-
+
if (rc_avpair_add(new_handle, &send, PW_ACCT_STATUS_TYPE, &service, -1, 0) == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: failed to add option to handle\n");
goto end;
- }
+ }
if (rc_acct(new_handle, 0, send) == OK_RC) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "mod_xml_radius: Accounting Start success\n");
rc_handle *new_handle = NULL;
switch_xml_t fields = NULL, conditions = NULL;
switch_channel_t *channel = switch_core_session_get_channel(session);
-
+
if (GLOBAL_DEBUG ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: starting accounting stop\n");
switch_core_session_execute_application(session, "info", NULL);
}
-
+
/* If there are conditions defined, and none of them pass, then skip this accounting */
if ((conditions = switch_xml_child(globals.acct_end_configs, "conditions")) != NULL &&
mod_xml_radius_check_conditions(channel, conditions) != SWITCH_STATUS_SUCCESS ) {
goto end;
}
-
+
if ( mod_xml_radius_new_handle(&new_handle, globals.acct_end_configs) != SWITCH_STATUS_SUCCESS || new_handle == NULL ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create new accounting_end handle for call: %s\n",
switch_channel_get_variable(channel, "uuid"));
- goto end;
+ goto end;
}
if ((fields = switch_xml_child(globals.acct_end_configs, "fields")) == NULL ) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'fields' section in config file.\n");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'fields' section in config file.\n");
goto end;
}
-
+
if ( mod_xml_radius_add_params(session, NULL, new_handle, &send, fields) != SWITCH_STATUS_SUCCESS ) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to add params to rc_handle\n");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to add params to rc_handle\n");
goto end;
}
-
+
if (rc_avpair_add(new_handle, &send, PW_ACCT_STATUS_TYPE, &service, -1, 0) == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: failed to add option to handle\n");
goto end;
- }
+ }
if (rc_acct(new_handle, 0, send) == OK_RC) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "mod_xml_radius: Accounting Stop success\n");
rc_destroy(new_handle);
new_handle = NULL;
}
-
+
return SWITCH_STATUS_SUCCESS;
}
switch_channel_get_variable(channel, "uuid"));
goto err;
}
-
+
if ((fields = switch_xml_child(globals.auth_app_configs, "fields")) == NULL ) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'fields' section in config file.\n");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'fields' section in config file.\n");
goto err;
}
-
+
if ( mod_xml_radius_add_params(session, NULL, new_handle, &send, fields) != SWITCH_STATUS_SUCCESS ) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to add params to rc_handle\n");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to add params to rc_handle\n");
goto err;
}
-
+
if (rc_avpair_add(new_handle, &send, PW_SERVICE_TYPE, &service, -1, 0) == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: failed to add option to handle\n");
goto err;
}
-
+
result = rc_auth(new_handle, 0, send, &recv, msg);
-
+
if ( GLOBAL_DEBUG ){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: result(RC=%d) %s \n", result, msg);
}
- temp = switch_mprintf("%d",result);
+ temp = switch_mprintf("%d",result);
switch_channel_set_variable(channel, "radius_auth_result", temp);
free(temp);
temp = NULL;
rc_destroy(new_handle);
new_handle = NULL;
}
-
+
return;
err:
if ( recv ) {
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
-
+
memset(&globals, 0, sizeof(globals));
globals.pool = pool;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: Failed to load configs\n");
return SWITCH_STATUS_TERM;
}
-
+
if ( globals.auth_invite_configs && globals.auth_reg_configs ) {
status = switch_xml_bind_search_function(mod_xml_radius_directory_search, switch_xml_parse_section_string("directory"), NULL);
}
-
+
SWITCH_ADD_API(mod_xml_radius_api_interface, "xml_radius_debug", "mod_xml_radius toggle debug", mod_xml_radius_debug_api, NULL);
switch_core_add_state_handler(&state_handlers);
SWITCH_ADD_APP(app_interface, "radius_auth", NULL, NULL, radius_auth_handle, "radius_auth", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
-
+
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}
<configuration name="xml_radius.conf" description="Radius XML Gateway">
<!--
auth_invite is only called when a directory lookup is done on an inbound invite. Usually that means a digest auth challenge on the invite.
-
- auth_reg is only called on the actual registration.
-
+
+ auth_reg is only called on the actual registration.
+
auth_app is used when an invite is in the dialplan. If your profile requires digest auth then this isn't needed.
but if your profile is doing only ip authentication this allows you to authenticate the call without the need for digest auth.
-
+
acct_start happens when the call goes into the state 'routing' which means it is starting the dialplan
-->
<auth_invite>
<param name="Digest-Response" variable="sip_auth_response" format="%s"/>
<param name="Digest-Realm" variable="sip_auth_realm" format="%s"/>
<param name="Digest-Nonce" variable="sip_auth_nonce" format="%s"/>
- <param name="Digest-Username" variable="sip_auth_username" format="%s"/>
+ <param name="Digest-Username" variable="sip_auth_username" format="%s"/>
<param name="Digest-URI" variable="sip_auth_uri" format="%s"/>
<param name="Digest-Method" variable="sip_auth_method" format="%s"/>
<param name="Digest-Algorithm" variable="sip_auth_method" format="MD5"/>
<param name="Digest-Qop" variable="sip_auth_qop" format="%s"/>
<param name="Digest-CNonce" variable="sip_auth_cnonce" format="%s"/>
- <param name="Digest-Nonce-Count" variable="sip_auth_nc" format="%s"/>
+ <param name="Digest-Nonce-Count" variable="sip_auth_nc" format="%s"/>
</fields>
</auth_invite>
<auth_reg>
<param name="dictionary" value="/usr/share/freeradius/dictionary.cisco"/>
<param name="seqfile" value="/var/run/radius.seq"/>
</connection>
- <fields>
+ <fields>
</fields>
</auth_reg>
<acct_start>
<param vendor="Cisco" name="Cisco-AVPair" variable="sip_from_user" variable_secondary="ani" format="src-number-in=%s" />
<param vendor="Cisco" name="Cisco-AVPair" variable="sip_from_user" variable_secondary="ani" format="src-number-out=%s" />
<param name="Calling-Station-Id" variable="sip_from_user" variable_secondary="ani" format="%s"/>
- <param vendor="Cisco" name="Cisco-AVPair" variable="sip_to_host" format="dst-gw-ip=%s"/>
+ <param vendor="Cisco" name="Cisco-AVPair" variable="sip_to_host" format="dst-gw-ip=%s"/>
<param vendor="Cisco" name="Cisco-AVPair" variable="destination_number" format="dst-gw-name=%s"/>
<param vendor="Cisco" name="Cisco-AVPair" variable="destination_number" format="dst-number-in=%s" />
<param vendor="Cisco" name="Cisco-AVPair" variable="destination_number" format="dst-number-out=%s" />
<param vendor="Cisco" name="Cisco-AVPair" variable="sip_from_user" variable_secondary="ani" format="src-number-in=%s" />
<param vendor="Cisco" name="Cisco-AVPair" variable="sip_from_user" variable_secondary="ani" format="src-number-out=%s" />
<param name="Calling-Station-Id" variable="sip_from_user" variable_secondary="ani" format="%s"/>
- <param vendor="Cisco" name="Cisco-AVPair" variable="sip_to_host" format="dst-gw-ip=%s"/>
+ <param vendor="Cisco" name="Cisco-AVPair" variable="sip_to_host" format="dst-gw-ip=%s"/>
<param vendor="Cisco" name="Cisco-AVPair" variable="sip_to_user" variable_secondary="dialed_extension" format="dst-gw-name=%s"/>
<param vendor="Cisco" name="Cisco-AVPair" variable="sip_to_user" variable_secondary="dialed_extension" format="dst-number-in=%s" />
<param name="Called-Station-Id" variable="destination_number" format="%s"/>
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", "websocket::stophook");
return SWITCH_STATUS_TERM;
}
-
+
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
/* fs api command will write to stream, calling http_stream_write / http_stream_raw_write */
/* switch_api_execute will stream INVALID COMMAND before it fails */
switch_api_execute(command, api_str, NULL, &stream);
-
+
if (globals.commands_to_log != NULL) {
full_command = switch_mprintf("%s%s%s", command, (api_str==NULL ? "" : " "), api_str);
{
switch_event_free_subclass("websocket::stophook");
-
+
/* Cann't find a way to stop the websockets, use this for a workaround before finding the real one that works */
stop_all_websockets();
#ifndef WSS_STANDALONE
-void init_ssl(void)
+void init_ssl(void)
{
// SSL_library_init();
}
-void deinit_ssl(void)
+void deinit_ssl(void)
{
return;
}
globals.ssl_method = TLSv1_server_method(); /* create server instance */
globals.ssl_ctx = SSL_CTX_new(globals.ssl_method); /* create context */
assert(globals.ssl_ctx);
-
+
/* set the local certificate from CertFile */
SSL_CTX_use_certificate_file(globals.ssl_ctx, globals.cert, SSL_FILETYPE_PEM);
/* set the private key from KeyFile */
e = strchr(v, '\n');
}
}
-
+
if (v && e) {
size_t cplen;
size_t len = e - v;
-
+
if (len > buflen - 1) {
cplen = buflen -1;
} else {
cplen = len;
}
-
+
strncpy(buf, v, cplen);
*(buf+cplen) = '\0';
return 1;
}
-
+
}
}
return 0;
}
-static int b64encode(unsigned char *in, size_t ilen, unsigned char *out, size_t olen)
+static int b64encode(unsigned char *in, size_t ilen, unsigned char *out, size_t olen)
{
int y=0,bytes=0;
size_t x=0;
SHA1Update(&sha, in, strlen(in));
SHA1Final(&sha, digest);
}
-#else
+#else
static void sha1_digest(unsigned char *digest, char *in)
{
sha1_digest(output, input);
b64encode((unsigned char *)output, SHA1_HASH_SIZE, (unsigned char *)b64, sizeof(b64));
- snprintf(respond, sizeof(respond),
+ snprintf(respond, sizeof(respond),
"HTTP/1.1 101 Switching Protocols\r\n"
"Upgrade: websocket\r\n"
"Connection: Upgrade\r\n"
if (wsh->down > 1) {
return;
}
-
+
wsh->down = 2;
if (wsh->ssl) {
}
}
-issize_t ws_close(wsh_t *wsh, int16_t reason)
+issize_t ws_close(wsh_t *wsh, int16_t reason)
{
-
+
if (wsh->down) {
return -1;
}
issize_t ws_read_frame(wsh_t *wsh, ws_opcode_t *oc, uint8_t **data)
{
-
+
issize_t need = 2;
char *maskp;
if (mask) {
need += 4;
-
+
if (need > wsh->datalen) {
/* too small - protocol err */
*oc = WSOC_CLOSE;
wsh->plen = wsh->buffer[1] & 0x7f;
wsh->payload = &wsh->buffer[2];
-
+
if (wsh->plen == 127) {
uint64_t *u64;
if ((need + wsh->datalen) > (issize_t)wsh->buflen) {
/* too big - Ain't nobody got time fo' dat */
*oc = WSOC_CLOSE;
- return ws_close(wsh, WS_DATA_TOO_BIG);
+ return ws_close(wsh, WS_DATA_TOO_BIG);
}
wsh->rplen = wsh->plen - need;
wsh->rplen += r;
need -= r;
}
-
+
if (mask && maskp) {
issize_t i;
wsh->payload[i] ^= maskp[i % 4];
}
}
-
+
if (*oc == WSOC_PING) {
ws_write_frame(wsh, WSOC_PONG, wsh->payload, wsh->rplen);
goto again;
}
-
+
*(wsh->payload+wsh->rplen) = '\0';
*data = (uint8_t *)wsh->payload;
}
memcpy(wsh->wbuffer + wsh->wdatalen, data, bytes);
-
+
wsh->wdatalen += (issize_t)bytes;
return (issize_t)bytes;
if (!wsh->wdatalen) {
return -1;
}
-
+
r = ws_write_frame(wsh, oc, wsh->wbuffer, wsh->wdatalen);
-
+
wsh->wdatalen = 0;
return r;
hdr[1] = 127;
hlen += 8;
-
+
u64 = (uint64_t *) &hdr[2];
*u64 = htonl((unsigned long)bytes);
}
if (ws_raw_write(wsh, data, bytes) != (issize_t)bytes) {
return -2;
}
-
+
return (issize_t)bytes;
}
#include <sys/types.h>
#ifndef _MSC_VER
#include <arpa/inet.h>
-#include <sys/wait.h>
+#include <sys/wait.h>
#include <sys/socket.h>
#else
#pragma warning(disable:4996)
#ifndef _MSC_VER
static inline uint64_t get_unaligned_uint64(const void *p)
-{
+{
const struct { uint64_t d; } __attribute__((packed)) *pp = p;
return pp->d;
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
* mod_xml_scgi.c -- SCGI XML Gateway
int timeout;
switch_hash_t *vars_map;
char *bindings;
-
+
char *server;
switch_thread_t *thread;
struct xml_binding *next;
switch_yield(10000000);
}
}
-
+
return NULL;
}
while((len = scgi_recv(&handle, buf, sizeof(buf))) > 0) {
char *expanded = switch_event_expand_headers(params, (char *)buf);
-
+
bytes += len;
if (bytes > XML_SCGI_MAX_BYTES) {
if (expanded != (char *)buf) {
free(expanded);
}
-
+
memset(buf, 0, sizeof(buf));
}
goto end;
}
-
+
if (GLOBAL_DEBUG) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "DEBUG:\nURL: %s\nPOST_DATA:\n%s\n\nRESPONSE:\n-----\n%s\n-----\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "DEBUG:\nURL: %s\nPOST_DATA:\n%s\n\nRESPONSE:\n-----\n%s\n-----\n",
binding->url, data, switch_str_nil(txt));
}
-
+
if (bytes && txt) {
if (!(xml = switch_xml_parse_str_dynamic(txt, FALSE))) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Parsing Result! [%s]\ndata: [%s] RESPONSE[%s]\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Parsing Result! [%s]\ndata: [%s] RESPONSE[%s]\n",
binding->url, data, switch_str_nil(txt));
}
txt = NULL;
} else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Received error trying to fetch %s\ndata: [%s] RESPONSE [%s]\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Received error trying to fetch %s\ndata: [%s] RESPONSE [%s]\n",
binding->url, data, switch_str_nil(txt));
}
end:
-
+
switch_safe_free(data);
switch_safe_free(txt);
-
+
return xml;
}
if (bind_mask) {
binding->bindings = switch_core_strdup(globals.pool, bind_mask);
- }
+ }
if (vars_map) {
switch_zmalloc(hash_node, sizeof(hash_node_t));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Binding [%s] XML Fetch Function [%s] [%s]\n",
zstr(bname) ? "N/A" : bname, binding->url, binding->bindings ? binding->bindings : "all");
switch_xml_bind_search_function(xml_url_fetch, switch_xml_parse_section_string(binding->bindings), binding);
-
+
if (binding->server) {
launch_monitor_thread(binding);
}
binding->next = globals.bindings;
globals.bindings = binding;
-
+
x++;
binding = NULL;
}
break;
}
-
+
switch_yield(5000000);
}
}
}
}
-
+
return r;
}
close(fds[0]);
fds[0] = -1;
-
+
if (system_ready < 0) {
printf("FreeSWITCH[%d] Error starting system! pid:%d\n", (int)getpid(), (int) pid);
kill(pid, 9);
if (switch_core_set_process_privileges() < 0) {
return 255;
}
-
+
switch (priority) {
case 2:
set_realtime_priority();
set_auto_priority();
break;
}
-
+
switch_core_setrlimits();
} else {
(void)read(fds[1], &v, sizeof(v));
}
-
+
shutdown(fds[1], 2);
close(fds[1]);
fds[1] = -1;
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2015, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Michael Jerris <mike@jerris.com>
* Eliot Gable <egable@gmail.com>
* William King <william.king@quentustech.com>
SWITCH_DECLARE(switch_status_t) switch_mutex_init(switch_mutex_t ** lock, unsigned int flags, switch_memory_pool_t *pool)
{
#ifdef WIN32
- /* Old version of APR misunderstands mutexes. On Windows, mutexes are cross-process.
+ /* Old version of APR misunderstands mutexes. On Windows, mutexes are cross-process.
APR has no reason to not use critical sections instead of mutexes. */
if (flags == SWITCH_MUTEX_NESTED) flags = SWITCH_MUTEX_DEFAULT;
#endif
if (!sock || !buf || !len) {
return SWITCH_STATUS_GENERR;
}
-
+
return apr_socket_send(sock, buf, len);
}
{
if (opt == SWITCH_SO_TCP_KEEPIDLE) {
int r = -10;
-
+
#if defined(TCP_KEEPIDLE)
r = setsockopt(jsock->client_socket, SOL_TCP, TCP_KEEPIDLE, (void *)&on, sizeof(on));
#endif
return SWITCH_STATUS_NOTIMPL;
}
-
+
return r ? SWITCH_STATUS_FALSE : SWITCH_STATUS_SUCCESS;
}
{
return apr_mcast_interface(sock, iface);
}
-
+
/* socket functions */
{
if (!pollset || !descriptor) {
return SWITCH_STATUS_FALSE;
- }
-
+ }
+
return apr_pollset_remove((apr_pollset_t *) pollset, (const apr_pollfd_t *) descriptor);
}
if (!pollfd || !sock) {
return SWITCH_STATUS_FALSE;
}
-
+
if ((*pollfd = (switch_pollfd_t*)apr_palloc(pool, sizeof(switch_pollfd_t))) == 0) {
return SWITCH_STATUS_MEMERR;
}
-
+
memset(*pollfd, 0, sizeof(switch_pollfd_t));
(*pollfd)->desc_type = (switch_pollset_type_t) APR_POLL_SOCKET;
(*pollfd)->reqevents = flags;
(*pollfd)->desc.s = sock;
(*pollfd)->client_data = client_data;
-
+
return SWITCH_STATUS_SUCCESS;
}
SWITCH_DECLARE(switch_status_t) switch_pollset_poll(switch_pollset_t *pollset, switch_interval_time_t timeout, int32_t *num, const switch_pollfd_t **descriptors)
{
apr_status_t st = SWITCH_STATUS_FALSE;
-
+
if (pollset) {
st = apr_pollset_poll((apr_pollset_t *) pollset, timeout, num, (const apr_pollfd_t **) descriptors);
-
+
if (st == APR_TIMEUP) {
st = SWITCH_STATUS_TIMEOUT;
}
}
-
+
return st;
}
/**
* Get the timeout value for a pipe or manipulate the blocking state.
* @param thepipe The pipe we are getting a timeout for.
- * @param timeout The current timeout value in microseconds.
+ * @param timeout The current timeout value in microseconds.
*/
SWITCH_DECLARE(switch_status_t) switch_file_pipe_timeout_get(switch_file_t *thepipe, switch_interval_time_t *timeout)
{
/**
* Set the timeout value for a pipe or manipulate the blocking state.
* @param thepipe The pipe we are setting a timeout on.
- * @param timeout The timeout value in microseconds. Values < 0 mean wait
+ * @param timeout The timeout value in microseconds. Values < 0 mean wait
* forever, 0 means do not wait at all.
*/
SWITCH_DECLARE(switch_status_t) switch_file_pipe_timeout_set(switch_file_t *thepipe, switch_interval_time_t timeout)
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
switch_uuid_str(uuid_str, sizeof(uuid_str));
profile->uuid_str = switch_core_strdup(pool, uuid_str);
-
+
if (!context) {
context = "default";
}
profile->soft = n;
} else {
for(pp = profile->soft; pp && pp->next; pp = pp->next);
-
+
if (pp) {
pp->next = n;
- }
+ }
}
}
switch_channel_timetable_t *times = NULL;
switch_snprintf(header_name, sizeof(header_name), "%s-Direction", prefix);
- switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->direction == SWITCH_CALL_DIRECTION_INBOUND ?
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->direction == SWITCH_CALL_DIRECTION_INBOUND ?
"inbound" : "outbound");
switch_snprintf(header_name, sizeof(header_name), "%s-Logical-Direction", prefix);
- switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->logical_direction == SWITCH_CALL_DIRECTION_INBOUND ?
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->logical_direction == SWITCH_CALL_DIRECTION_INBOUND ?
"inbound" : "outbound");
-
+
if (!zstr(caller_profile->username)) {
switch_snprintf(header_name, sizeof(header_name), "%s-Username", prefix);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->username);
}
}
-
+
if (!(times = caller_profile->times)) {
times = caller_profile->old_times;
}
if (caller_application->application_data && strstr(caller_application->application_data, "\\'")) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "App not added, Invalid character sequence in data string [%s]\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "App not added, Invalid character sequence in data string [%s]\n",
caller_application->application_data);
return;
}
-
+
if (!caller_extension->applications) {
caller_extension->applications = caller_application;
} else if (caller_extension->last_application) {
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Michael Jerris <mike@jerris.com>
*
};
-SWITCH_DECLARE(void) switch_channel_perform_set_callstate(switch_channel_t *channel, switch_channel_callstate_t callstate,
+SWITCH_DECLARE(void) switch_channel_perform_set_callstate(switch_channel_t *channel, switch_channel_callstate_t callstate,
const char *file, const char *func, int line)
{
switch_event_t *event;
switch_channel_callstate_t o_callstate = channel->callstate;
if (o_callstate == callstate || o_callstate == CCS_HANGUP) return;
-
+
channel->callstate = callstate;
if (channel->device_node) {
channel->device_node->callstate = callstate;
}
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_DEBUG,
- "(%s) Callstate Change %s -> %s\n", channel->name,
+ "(%s) Callstate Change %s -> %s\n", channel->name,
switch_channel_callstate2str(o_callstate), switch_channel_callstate2str(callstate));
switch_channel_check_device_state(channel, channel->callstate);
return SWITCH_STATUS_SUCCESS;
}
-SWITCH_DECLARE(switch_status_t) switch_channel_dtmf_lock(switch_channel_t *channel)
+SWITCH_DECLARE(switch_status_t) switch_channel_dtmf_lock(switch_channel_t *channel)
{
return switch_mutex_lock(channel->dtmf_mutex);
}
-SWITCH_DECLARE(switch_status_t) switch_channel_try_dtmf_lock(switch_channel_t *channel)
+SWITCH_DECLARE(switch_status_t) switch_channel_try_dtmf_lock(switch_channel_t *channel)
{
return switch_mutex_trylock(channel->dtmf_mutex);
}
-SWITCH_DECLARE(switch_status_t) switch_channel_dtmf_unlock(switch_channel_t *channel)
+SWITCH_DECLARE(switch_status_t) switch_channel_dtmf_unlock(switch_channel_t *channel)
{
return switch_mutex_unlock(channel->dtmf_mutex);
}
switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "%s SHORT DTMF DIGIT LEN [%d]\n",
switch_channel_get_name(channel), new_dtmf.duration);
new_dtmf.duration = switch_core_min_dtmf_duration(0);
- }
+ }
}
-
+
if (!new_dtmf.duration) {
new_dtmf.duration = switch_core_default_dtmf_duration(0);
}
-
+
switch_zmalloc(dt, sizeof(*dt));
*dt = new_dtmf;
}
}
}
-
+
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "presence-call-info-state", call_info_state);
-
+
if (call_info) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "presence-call-info", call_info);
}
if (!!on == !!switch_channel_test_flag(channel, CF_LEG_HOLDING)) {
goto end;
}
-
+
if (on) {
switch_channel_set_flag(channel, CF_LEG_HOLDING);
} else {
if (!zstr(var)) {
char *expanded = switch_channel_expand_variables(channel, var);
-
+
if (expanded != var) {
var = switch_core_session_strdup(channel->session, expanded);
free(expanded);
}
switch_mutex_unlock(channel->profile_mutex);
-
+
}
SWITCH_DECLARE(switch_status_t) switch_channel_get_scope_variables(switch_channel_t *channel, switch_event_t **event)
} else {
profile_node_t *pn, *n = switch_core_alloc(channel->caller_profile->pool, sizeof(*n));
int var_found;
-
+
n->var = switch_core_strdup(channel->caller_profile->pool, name);
n->val = v;
channel->caller_profile->soft = n;
} else {
var_found = 0;
-
+
for(pn = channel->caller_profile->soft; pn ; pn = pn->next) {
if (!strcasecmp(pn->var,n->var)) {
pn->val = n->val;
break;
}
}
-
+
if (pn && !pn->next && !var_found) {
pn->next = n;
}
}
-SWITCH_DECLARE(void) switch_channel_process_export(switch_channel_t *channel, switch_channel_t *peer_channel,
+SWITCH_DECLARE(void) switch_channel_process_export(switch_channel_t *channel, switch_channel_t *peer_channel,
switch_event_t *var_event, const char *export_varname)
{
switch_event_del_header(var_event, export_varname);
switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, export_varname, export_vars);
}
-
+
if (peer_channel) {
switch_channel_set_variable(peer_channel, export_varname, export_vars);
}
if ((argc = switch_separate_string(cptmp, ',', argv, (sizeof(argv) / sizeof(argv[0]))))) {
int x;
-
+
for (x = 0; x < argc; x++) {
const char *vval;
if ((vval = switch_channel_get_variable(channel, argv[x]))) {
if (var_event) {
switch_event_del_header(var_event, vvar);
switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, vvar, vval);
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(channel->session), SWITCH_LOG_DEBUG,
- "%s EXPORTING[%s] [%s]=[%s] to event\n",
- switch_channel_get_name(channel),
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(channel->session), SWITCH_LOG_DEBUG,
+ "%s EXPORTING[%s] [%s]=[%s] to event\n",
+ switch_channel_get_name(channel),
export_varname,
vvar, vval);
}
if (peer_channel) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(channel->session), SWITCH_LOG_DEBUG,
- "%s EXPORTING[%s] [%s]=[%s] to %s\n",
- switch_channel_get_name(channel),
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(channel->session), SWITCH_LOG_DEBUG,
+ "%s EXPORTING[%s] [%s]=[%s] to %s\n",
+ switch_channel_get_name(channel),
export_varname,
vvar, vval, switch_channel_get_name(peer_channel));
switch_channel_set_variable(peer_channel, vvar, vval);
}
-SWITCH_DECLARE(switch_status_t) switch_channel_export_variable_var_check(switch_channel_t *channel,
- const char *varname, const char *val,
+SWITCH_DECLARE(switch_status_t) switch_channel_export_variable_var_check(switch_channel_t *channel,
+ const char *varname, const char *val,
const char *export_varname, switch_bool_t var_check)
{
char *var_name = NULL;
}
}
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(channel->session), SWITCH_LOG_DEBUG, "EXPORT (%s) %s[%s]=[%s]\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(channel->session), SWITCH_LOG_DEBUG, "EXPORT (%s) %s[%s]=[%s]\n",
export_varname, local ? "" : "(REMOTE ONLY) ",
var_name ? var_name : "", val ? val : "UNDEF");
-
+
switch_channel_set_variable_var_check(channel, var, val, var_check);
if (var && val) {
return SWITCH_STATUS_SUCCESS;
}
-SWITCH_DECLARE(switch_status_t) switch_channel_export_variable_printf(switch_channel_t *channel, const char *varname,
+SWITCH_DECLARE(switch_status_t) switch_channel_export_variable_printf(switch_channel_t *channel, const char *varname,
const char *export_varname, const char *fmt, ...)
{
switch_status_t status = SWITCH_STATUS_FALSE;
char *data = NULL;
va_list ap;
int ret;
-
+
switch_assert(channel != NULL);
-
+
va_start(ap, fmt);
ret = switch_vasprintf(&data, fmt, ap);
va_end(ap);
-
+
if (ret == -1) {
return SWITCH_STATUS_FALSE;
}
-
+
status = switch_channel_export_variable(channel, varname, data, export_varname);
-
+
free(data);
-
+
return status;
}
}
switch_channel_variable_last(orig_channel);
}
-
+
return x ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
}
char header_name[128] = "";
int col_count = 0, i = 0;
char *data_copy = NULL;
-
+
if (zstr(presence_data_cols)) {
presence_data_cols = switch_channel_get_variable_dup(channel, "presence_data_cols", SWITCH_FALSE, -1);
if (zstr(presence_data_cols)) {
return;
}
}
-
+
data_copy = strdup(presence_data_cols);
-
+
col_count = switch_split(data_copy, ':', cols);
-
+
for (i = 0; i < col_count; i++) {
const char *val = NULL;
switch_snprintf(header_name, sizeof(header_name), "PD-%s", cols[i]);
val = switch_channel_get_variable(channel, cols[i]);
switch_channel_set_profile_var(channel, header_name, val);
}
-
+
switch_safe_free(data_copy);
}
{
switch_assert(channel);
-
+
for (;;) {
if ((channel->state < CS_HANGUP && channel->state == channel->running_state && channel->running_state == want_state) ||
(other_channel && switch_channel_down_nosig(other_channel)) || switch_channel_down(channel)) {
if (brto) {
hr->uuid = switch_core_session_strdup(channel->session, brto);
}
-
+
if (channel->hold_record) {
hr->next = channel->hold_record;
}
if (flag == CF_VIDEO_ECHO || flag == CF_VIDEO_BLANK || flag == CF_VIDEO_DECODED_READ || flag == CF_VIDEO_PASSIVE) {
switch_core_session_start_video_thread(channel->session);
}
-
+
if (flag == CF_VIDEO_DECODED_READ && channel->flags[CF_VIDEO]) {
switch_core_session_request_video_refresh(channel->session);
}
switch_core_hash_init(&channel->app_flag_hash);
new++;
}
-
+
if (new || !(flagp = switch_core_hash_find(channel->app_flag_hash, key))) {
flagp = switch_core_session_alloc(channel->session, sizeof(uint32_t));
switch_core_hash_insert(channel->app_flag_hash, key, flagp);
SWITCH_DECLARE(void) switch_channel_clear_app_flag_key(const char *key, switch_channel_t *channel, uint32_t flags)
{
uint32_t *flagp = NULL;
-
+
switch_assert(channel != NULL);
switch_mutex_lock(channel->flag_mutex);
if (channel->app_flag_hash && (flagp = switch_core_hash_find(channel->app_flag_hash, key))) {
r = (*flagp & flags);
}
switch_mutex_unlock(channel->flag_mutex);
-
+
return r;
}
return state;
}
-SWITCH_DECLARE(int) switch_channel_state_change_pending(switch_channel_t *channel)
+SWITCH_DECLARE(int) switch_channel_state_change_pending(switch_channel_t *channel)
{
if (switch_channel_down_nosig(channel) || !switch_core_session_in_thread(channel->session)) {
return 0;
ret = ((switch_channel_test_flag(channel, CF_ANSWERED) ||
switch_channel_test_flag(channel, CF_EARLY_MEDIA)) && !switch_channel_test_flag(channel, CF_PROXY_MODE) &&
switch_core_session_get_read_codec(channel->session) && switch_core_session_get_write_codec(channel->session));
-
+
if (!ret)
return ret;
ret = 0;
if (!channel->hangup_cause && channel->state > CS_ROUTING && channel->state < CS_HANGUP && channel->state != CS_RESET &&
- !switch_channel_test_flag(channel, CF_TRANSFER) && !switch_channel_test_flag(channel, CF_NOT_READY) &&
+ !switch_channel_test_flag(channel, CF_TRANSFER) && !switch_channel_test_flag(channel, CF_NOT_READY) &&
!switch_channel_state_change_pending(channel)) {
ret++;
}
switch_mutex_unlock(channel->flag_mutex);
switch_channel_clear_flag(channel, CF_TAGGED);
-
+
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_DEBUG, "(%s) Running State Change %s (Cur %d Tot %" SWITCH_SIZE_T_FMT ")\n",
channel->name, state_names[state], switch_core_session_count(), switch_core_session_id() - 1);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Presence-Call-Direction",
channel->direction == SWITCH_CALL_DIRECTION_OUTBOUND ? "outbound" : "inbound");
- switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Channel-HIT-Dialplan",
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Channel-HIT-Dialplan",
switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_INBOUND ||
switch_channel_test_flag(channel, CF_DIALPLAN) ? "true" : "false");
switch_core_session_ctl(SCSC_VERBOSE_EVENTS, &global_verbose_events);
- if (global_verbose_events ||
+ if (global_verbose_events ||
switch_channel_test_flag(channel, CF_VERBOSE_EVENTS) ||
switch_event_get_header(event, "presence-data-cols") ||
event->event_id == SWITCH_EVENT_CHANNEL_CREATE ||
event->event_id == SWITCH_EVENT_SESSION_HEARTBEAT ||
event->event_id == SWITCH_EVENT_API ||
event->event_id == SWITCH_EVENT_RECORD_START ||
- event->event_id == SWITCH_EVENT_RECORD_STOP ||
+ event->event_id == SWITCH_EVENT_RECORD_STOP ||
event->event_id == SWITCH_EVENT_PLAYBACK_START ||
event->event_id == SWITCH_EVENT_PLAYBACK_STOP ||
event->event_id == SWITCH_EVENT_CALL_UPDATE ||
for (hi = ep->headers; hi; hi = hi->next) {
char buf[1024];
char *vvar = NULL, *vval = NULL;
-
+
vvar = (char *) hi->name;
vval = (char *) hi->value;
-
+
switch_assert(vvar && vval);
switch_snprintf(buf, sizeof(buf), "scope_variable_%s", vvar);
-
+
if (!switch_event_get_header(event, buf)) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, buf, vval);
}
vvar = (char *) hi->name;
vval = (char *) hi->value;
-
+
switch_assert(vvar && vval);
switch_snprintf(buf, sizeof(buf), "variable_%s", vvar);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, buf, vval);
switch_mutex_lock(channel->profile_mutex);
cp = switch_caller_profile_clone(channel->session, channel->caller_profile);
switch_mutex_unlock(channel->profile_mutex);
-
+
switch_channel_set_caller_profile(channel, cp);
}
switch_assert(channel != NULL);
switch_mutex_lock(channel->profile_mutex);
-
+
if (channel->caller_profile) {
profile = channel->caller_profile->originator_caller_profile;
}
switch_channel_set_state(channel, CS_EXECUTE);
}
-/* XXX This is a somewhat simple operation. Were essentially taking the extension that one channel
- was executing and generating a new extension for another channel that starts out where the
- original one left off with an optional forward offset. Since all we are really doing is
- copying a few basic pool-allocated structures from one channel to another there really is
- not much to worry about here in terms of threading since we use read-write locks.
- While the features are nice, they only really are needed in one specific crazy attended
+/* XXX This is a somewhat simple operation. Were essentially taking the extension that one channel
+ was executing and generating a new extension for another channel that starts out where the
+ original one left off with an optional forward offset. Since all we are really doing is
+ copying a few basic pool-allocated structures from one channel to another there really is
+ not much to worry about here in terms of threading since we use read-write locks.
+ While the features are nice, they only really are needed in one specific crazy attended
transfer scenario where one channel was in the middle of calling a particular extension
when it was rudely cut off by a transfer key press. XXX */
cp->caller_id_name = cp->callee_id_name;
cp->caller_id_number = cp->callee_id_number;
-
+
cp->callee_id_name = tname;
cp->callee_id_number = tnum;
} else if (tmp) {
channel->caller_profile->callee_id_name = tmp;
}
-
+
if (channel->caller_profile->callee_id_number) {
tmp = channel->caller_profile->caller_id_number;
switch_channel_set_variable(channel, "pre_transfer_caller_id_number", channel->caller_profile->caller_id_number);
}
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(channel->session), SWITCH_LOG_INFO, "%s Flipping CID from \"%s\" <%s> to \"%s\" <%s>\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(channel->session), SWITCH_LOG_INFO, "%s Flipping CID from \"%s\" <%s> to \"%s\" <%s>\n",
switch_channel_get_name(channel),
switch_str_nil(switch_channel_get_variable(channel, "pre_transfer_caller_id_name")),
switch_str_nil(switch_channel_get_variable(channel, "pre_transfer_caller_id_number")),
switch_mutex_unlock(channel->profile_mutex);
switch_channel_set_flag(channel, CF_TRANSFER);
- switch_channel_set_state(channel, CS_ROUTING);
+ switch_channel_set_state(channel, CS_ROUTING);
}
SWITCH_DECLARE(void) switch_channel_set_caller_extension(switch_channel_t *channel, switch_caller_extension_t *caller_extension)
switch_assert(channel != NULL);
switch_channel_sort_cid(channel);
-
+
switch_mutex_lock(channel->profile_mutex);
caller_extension->next = channel->caller_profile->caller_extension;
channel->caller_profile->caller_extension = caller_extension;
}
-SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_ring_ready_value(switch_channel_t *channel,
+SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_ring_ready_value(switch_channel_t *channel,
switch_ring_ready_t rv,
const char *file, const char *func, int line)
{
switch_core_session_t *other_session;
switch_channel_t *other_channel;
int doit = 1;
-
+
if (switch_core_session_get_partner(channel->session, &other_session) == SWITCH_STATUS_SUCCESS) {
other_channel = switch_core_session_get_channel(other_session);
if (switch_channel_test_flag(other_channel, CF_ZRTP_HASH) && !switch_channel_test_flag(other_channel, CF_ZRTP_PASSTHRU)) {
-
+
switch_channel_set_flag(channel, CF_ZRTP_PASSTHRU);
switch_channel_set_flag(other_channel, CF_ZRTP_PASSTHRU);
-
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(channel->session), SWITCH_LOG_INFO,
+
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(channel->session), SWITCH_LOG_INFO,
"%s Activating ZRTP passthru mode.\n", switch_channel_get_name(channel));
-
+
switch_channel_set_variable(channel, "zrtp_passthru_active", "true");
switch_channel_set_variable(other_channel, "zrtp_passthru_active", "true");
switch_channel_set_variable(channel, "zrtp_secure_media", "false");
if (doit) {
switch_channel_set_variable(channel, "zrtp_passthru_active", "false");
switch_channel_set_variable(channel, "zrtp_secure_media", "true");
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(channel->session), SWITCH_LOG_INFO,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(channel->session), SWITCH_LOG_INFO,
"%s ZRTP not negotiated on both sides; disabling ZRTP passthru mode.\n", switch_channel_get_name(channel));
switch_channel_clear_flag(channel, CF_ZRTP_PASSTHRU);
switch_channel_clear_flag(channel, CF_ZRTP_HASH);
if (switch_core_session_get_partner(channel->session, &other_session) == SWITCH_STATUS_SUCCESS) {
- other_channel = switch_core_session_get_channel(other_session);
+ other_channel = switch_core_session_get_channel(other_session);
switch_channel_set_variable(other_channel, "zrtp_passthru_active", "false");
switch_channel_set_variable(other_channel, "zrtp_secure_media", "true");
switch_channel_clear_flag(other_channel, CF_ZRTP_PASSTHRU);
switch_channel_clear_flag(other_channel, CF_ZRTP_HASH);
-
+
switch_core_session_rwunlock(other_session);
}
switch_channel_check_zrtp(channel);
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_NOTICE, "Pre-Answer %s!\n", channel->name);
switch_channel_set_flag(channel, CF_EARLY_MEDIA);
-
+
switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "EARLY MEDIA");
if (switch_true(switch_channel_get_variable(channel, "video_mirror_input"))) {
switch_channel_set_flag(channel, CF_VIDEO_MIRROR_INPUT);
}
-
+
if (channel->caller_profile && channel->caller_profile->times) {
switch_mutex_lock(channel->profile_mutex);
channel->caller_profile->times->progress_media = switch_micro_time_now();
}
- /* if we're the child of another channel and the other channel is in a blocking read they will never realize we have answered so send
+ /* if we're the child of another channel and the other channel is in a blocking read they will never realize we have answered so send
a SWITCH_SIG_BREAK to interrupt any blocking reads on that channel
*/
if ((uuid = switch_channel_get_variable(channel, SWITCH_ORIGINATOR_VARIABLE))
return status;
}
-SWITCH_DECLARE(switch_status_t) switch_channel_perform_ring_ready_value(switch_channel_t *channel, switch_ring_ready_t rv,
+SWITCH_DECLARE(switch_status_t) switch_channel_perform_ring_ready_value(switch_channel_t *channel, switch_ring_ready_t rv,
const char *file, const char *func, int line)
{
switch_core_session_message_t msg = { 0 };
static void do_api_on(switch_channel_t *channel, const char *variable)
{
char *app;
- char *arg = NULL;
+ char *arg = NULL;
switch_stream_handle_t stream = { 0 };
app = switch_core_session_strdup(channel->session, variable);
-
+
if ((arg = strchr(app, ' '))) {
*arg++ = '\0';
}
-
+
SWITCH_STANDARD_STREAM(stream);
switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "%s process %s: %s(%s)\n%s\n",
channel->name, variable, app, switch_str_nil(arg), (char *) stream.data);
switch_event_t *event;
int x = 0;
-
+
switch_channel_get_variables(channel, &event);
-
+
for (hp = event->headers; hp; hp = hp->next) {
char *var = hp->name;
char *val = hp->value;
int i;
for (i = 0; i < hp->idx; i++) {
x++;
- do_api_on(channel, hp->array[i]);
+ do_api_on(channel, hp->array[i]);
}
} else {
x++;
}
}
}
-
+
switch_event_destroy(&event);
return x ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
break;
}
}
-
+
if (!strncasecmp(app, "perl", 4)) {
bg++;
}
-
+
if (bg) {
switch_core_session_execute_application_async(channel->session, app, arg);
} else {
switch_core_get_variables(&event);
switch_channel_get_variables(channel, &cevent);
switch_event_merge(event, cevent);
-
+
for (hp = event->headers; hp; hp = hp->next) {
char *var = hp->name;
char *val = hp->value;
int i;
for (i = 0; i < hp->idx; i++) {
x++;
- do_execute_on(channel, hp->array[i]);
+ do_execute_on(channel, hp->array[i]);
}
} else {
x++;
}
}
}
-
+
switch_event_destroy(&event);
switch_event_destroy(&cevent);
switch_channel_set_flag(channel, CF_VIDEO_MIRROR_INPUT);
//switch_channel_set_flag(channel, CF_VIDEO_DECODED_READ);
}
-
+
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_ANSWER) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(channel, event);
switch_event_fire(&event);
}
- /* if we're the child of another channel and the other channel is in a blocking read they will never realize we have answered so send
+ /* if we're the child of another channel and the other channel is in a blocking read they will never realize we have answered so send
a SWITCH_SIG_BREAK to interrupt any blocking reads on that channel
*/
if ((uuid = switch_channel_get_variable(channel, SWITCH_ORIGINATOR_VARIABLE))
if (switch_channel_get_variable(channel, "absolute_codec_string")) {
- /* inherit_codec == true will implicitly clear the absolute_codec_string
+ /* inherit_codec == true will implicitly clear the absolute_codec_string
variable if used since it was the reason it was set in the first place and is no longer needed */
if (switch_true(switch_channel_get_variable(channel, "inherit_codec"))) {
switch_channel_set_variable(channel, "absolute_codec_string", NULL);
switch_channel_set_callstate(channel, CCS_ACTIVE);
send_ind(channel, SWITCH_MESSAGE_ANSWER_EVENT, file, func, line);
-
+
switch_core_media_check_autoadj(channel->session);
if (switch_channel_test_flag(channel, CF_RTT)) {
}
- if (switch_core_session_in_thread(channel->session) && !switch_channel_test_flag(channel, CF_PROXY_MODE) &&
+ if (switch_core_session_in_thread(channel->session) && !switch_channel_test_flag(channel, CF_PROXY_MODE) &&
!switch_channel_test_flag(channel, CF_HAS_TEXT)) {
const char *delay;
if ((delay = switch_channel_get_variable(channel, "answer_delay"))) {
uint32_t msec = atoi(delay);
-
+
if (msec) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(channel->session), SWITCH_LOG_DEBUG, "Answer delay for %u msec\n", msec);
switch_ivr_sleep(channel->session, msec, SWITCH_TRUE, NULL);
int ooffset = 0;
char *ptr;
int idx = -1;
-
+
if ((expanded = switch_channel_expand_variables_check(channel, (char *) vname, var_list, api_list, recur+1)) == vname) {
expanded = NULL;
} else {
*ptr++ = '\0';
idx = atoi(ptr);
}
-
+
if ((sub_val = (char *) switch_channel_get_variable_dup(channel, vname, SWITCH_TRUE, idx))) {
if (var_list && !switch_event_check_permission_list(var_list, vname)) {
sub_val = "<Variable Expansion Permission Denied>";
} else {
sub_val = expanded_sub_val;
}
-
+
if (offset || ooffset) {
cloned_sub_val = strdup(sub_val);
switch_assert(cloned_sub_val);
if (stream.data) {
char *expanded_vname = NULL;
-
+
if ((expanded_vname = switch_channel_expand_variables_check(channel, (char *) vname, var_list, api_list, recur+1)) == vname) {
expanded_vname = NULL;
} else {
prof[9] = caller_profile->chan_name;
prof[10] = caller_profile->uuid;
prof[11] = caller_profile->transfer_source;
-
+
prof_names[0] = "context";
prof_names[1] = "destination_number";
prof_names[2] = "caller_id_name";
new_len = (strlen(prof[x]) * 3) + 1;
if (encode_len < new_len) {
char *tmp;
-
+
encode_len = new_len;
if (!(tmp = realloc(encode_buf, encode_len))) {
switch_caller_profile_t *caller_profile;
switch_app_log_t *app_log, *ap;
char *last_app = NULL, *last_arg = NULL;
- char start[80] = "", resurrect[80] = "", answer[80] = "", hold[80],
+ char start[80] = "", resurrect[80] = "", answer[80] = "", hold[80],
bridge[80] = "", progress[80] = "", progress_media[80] = "", end[80] = "", tmp[80] = "",
profile_start[80] = "";
int32_t duration = 0, legbillsec = 0, billsec = 0, mduration = 0, billmsec = 0, legbillmsec = 0, progressmsec = 0, progress_mediamsec = 0;
const char *replace = NULL;
X = malloc(len);
-
+
for (i = 0; i < proceed; i++) {
if (pcre_get_substring(dtstr, ovector, proceed, i, &replace) > 0) {
switch_size_t plen = strlen(replace);
switch_safe_free(substituted);
substituted = switch_string_replace(substituted ? substituted : dtstr, replace, X);
-
+
pcre_free_substring(replace);
}
}
-
+
if (!zstr(substituted)) {
digit_string = substituted;
}
switch_split(tof_data, ' ', tof_array);
transfer_on_fail = tof_array[0];
- /*
+ /*
if the variable continue_on_fail is set it can be:
'true' to continue on all failures.
'false' to not continue.
A list of codes either names or numbers eg "user_busy,normal_temporary_failure,603"
- failure_causes acts as the opposite version
+ failure_causes acts as the opposite version
EXCEPTION... ATTENDED_TRANSFER never is a reason to continue.......
*/
if (cause != SWITCH_CAUSE_ATTENDED_TRANSFER) {
return;
}
}
-
+
if (transfer_on_fail || failure_causes) {
const char *cause_str;
char cause_num[35] = "";
if (!x) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
"Failure causes [%s]: Cause: %s\n", failure_causes, cause_str);
-
+
switch_ivr_session_transfer(session, tof_array[1], tof_array[2], tof_array[3]);
}
}
}
}
}
- }
+ }
}
- if (!switch_channel_test_flag(channel, CF_TRANSFER) && !switch_channel_test_flag(channel, CF_CONFIRM_BLIND_TRANSFER) &&
+ if (!switch_channel_test_flag(channel, CF_TRANSFER) && !switch_channel_test_flag(channel, CF_CONFIRM_BLIND_TRANSFER) &&
switch_channel_get_state(channel) != CS_ROUTING) {
switch_channel_hangup(channel, cause);
}
memset(&drec->stats, 0, sizeof(switch_device_stats_t));
-
+
switch_mutex_lock(drec->mutex);
for(np = drec->uuid_list; np; np = np->next) {
drec->stats.total++;
} else {
drec->stats.total_out++;
}
-
+
if (!np->hup_profile) {
drec->stats.offhook++;
if (np->direction == SWITCH_CALL_DIRECTION_INBOUND) {
switch_yield(100000);
}
- switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "Destroying device cdr %s on device [%s]\n",
+ switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "Destroying device cdr %s on device [%s]\n",
channel->device_node->parent->uuid,
channel->device_node->parent->device_id);
pool = channel->device_node->parent->pool;
switch_mutex_lock(globals.device_mutex);
- switch_core_destroy_memory_pool(&pool);
+ switch_core_destroy_memory_pool(&pool);
switch_mutex_unlock(globals.device_mutex);
-
-
+
+
}
-SWITCH_DECLARE(void) switch_channel_process_device_hangup(switch_channel_t *channel)
+SWITCH_DECLARE(void) switch_channel_process_device_hangup(switch_channel_t *channel)
{
switch_channel_check_device_state(channel, channel->callstate);
if (!channel->device_node) {
return;
}
-
+
switch_mutex_lock(globals.device_mutex);
node = channel->device_node;
drec = channel->device_node->parent;
}
last = newhr;
- }
+ }
if (!drec->stats.offhook) { /* this is final call */
switch_core_hash_delete(globals.device_hash, drec->device_id);
- switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "Processing last call from device [%s]\n",
+ switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "Processing last call from device [%s]\n",
drec->device_id);
switch_channel_set_flag(channel, CF_FINAL_DEVICE_LEG);
} else {
drec->refs--;
switch_mutex_unlock(globals.device_mutex);
-
+
}
static void switch_channel_check_device_state(switch_channel_t *channel, switch_channel_callstate_t callstate)
}
}
- switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG1,
+ switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG1,
"%s device: %s\nState: %s Dev State: %s/%s Total:%u Offhook:%u "
- "Ringing:%u Early:%u Active:%u Held:%u Unheld:%u Hungup:%u Dur: %u Ringtime: %u Holdtime: %u %s\n",
+ "Ringing:%u Early:%u Active:%u Held:%u Unheld:%u Hungup:%u Dur: %u Ringtime: %u Holdtime: %u %s\n",
switch_channel_get_name(channel),
drec->device_id,
switch_channel_callstate2str(callstate),
switch_mutex_unlock(drec->mutex);
switch_mutex_unlock(globals.device_mutex);
-
+
if (event) {
switch_event_fire(&event);
}
add_uuid(drec, channel);
-
+
switch_mutex_unlock(globals.device_mutex);
switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "Setting DEVICE ID to [%s]\n", device_id);
-
+
switch_channel_check_device_state(channel, channel->callstate);
-
+
return device_id;
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
switch_core_flag_t cflags = switch_core_flags();
int full = 0;
-
+
if (!(cflags & SCF_USE_SQL)) {
return NULL;
}
char *s_argv[100] = { 0 };
char *r_argv[1] = { 0 }, *r_cols[1] = {0};
list = strdup(p);
-
+
argc = switch_separate_string(list, ':', s_argv, (sizeof(s_argv) / sizeof(s_argv[0])));
for (i = 0; (int)i < argc; i++) {
}
stream.write_function(&stream, " and hostname='%s' order by a%d", switch_core_get_hostname(), h.words + 1);
-
+
switch_cache_db_execute_sql_callback(db, stream.data, comp_callback, &h, &errmsg);
if (errmsg) {
if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
switch_stream_handle_t mystream = { 0 };
SWITCH_STANDARD_STREAM(mystream);
-
+
if (!strcasecmp(argv[0], "stickyadd")) {
mystream.write_function(&mystream, "insert into complete values (1,");
for (x = 0; x < 10; x++) {
} else if (!strcasecmp(argv[0], "del")) {
char *what = argv[1];
if (zstr(what)) {
- switch_safe_free(mystream.data);
- switch_safe_free(mydata);
+ switch_safe_free(mystream.data);
+ switch_safe_free(mydata);
return SWITCH_STATUS_FALSE;
} else if (!strcasecmp(what, "*")) {
mystream.write_function(&mystream, "delete from complete where hostname='%q'", switch_core_get_hostname());
free(mydata);
return SWITCH_STATUS_FALSE;
}
-
+
if (!strcasecmp(argv[0], "stickyadd") && argc == 3) {
sql = switch_mprintf("delete from aliases where alias='%q' and hostname='%q'", argv[1], switch_core_get_switchname());
switch_cache_db_persistant_execute(db, sql, 5);
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Michael Jerris <mike@jerris.com>
* Paul D. Tinsley <pdt at jackhammer.org>
char *domain;
const char *var;
- switch_thread_rwlock_rdlock(runtime.global_var_rwlock);
+ switch_thread_rwlock_rdlock(runtime.global_var_rwlock);
if (!(var = switch_core_get_variable("domain"))) {
var = "freeswitch.local";
}
switch_channel_clear_flag(channel, CF_SERVICE_VIDEO);
switch_core_session_kill_channel(session, SWITCH_SIG_BREAK);
-
+
}
SWITCH_DECLARE(void) switch_core_service_session_av(switch_core_session_t *session, switch_bool_t audio, switch_bool_t video)
{
#ifdef SOLARIS_PRIVILEGES
priv_set_t *basicset;
-
+
/* make the process privilege-aware */
setpflags(PRIV_AWARE, 1);
if (setppriv(PRIV_SET, PRIV_EFFECTIVE, basicset) != 0) {
fprintf(stderr, "ERROR: Failed to acquire basic privileges (%s)\n", strerror(errno));
}
-
+
/* we need high-resolution clock, and this requires a non-basic privilege */
if (priv_set(PRIV_ON, PRIV_EFFECTIVE, PRIV_PROC_CLOCK_HIGHRES, NULL) < 0) {
fprintf(stderr, "ERROR: Failed to acquire proc_clock_highres privilege (%s)\n", strerror(errno));
fprintf(stderr, "ERROR: Failed to acquire sys_resource privilege (%s)\n", strerror(errno));
return -1;
}
-
+
/* we need to read directories belonging to other uid */
if (priv_set(PRIV_ON, PRIV_EFFECTIVE, PRIV_FILE_DAC_SEARCH, NULL) < 0) {
fprintf(stderr, "ERROR: Failed to acquire file_dac_search privilege (%s)\n", strerror(errno));
#ifdef HAVE_SETRLIMIT
struct rlimit rlp;
- /*
+ /*
Setting the stack size on FreeBSD results in an instant crash.
If anyone knows how to fix this,
- feel free to submit a patch to https://freeswitch.org/jira
+ feel free to submit a patch to https://freeswitch.org/jira
*/
#ifndef __FreeBSD__
if (!sched_setaffinity(0, sizeof(set), &set)) {
status = SWITCH_STATUS_SUCCESS;
}
-
+
#else
#if WIN32
if (SetThreadAffinityMask(GetCurrentThread(), (DWORD_PTR) cpu)) {
}
-#ifdef ENABLE_ZRTP
+#ifdef ENABLE_ZRTP
static void switch_core_set_serial(void)
{
char buf[13] = "";
/* one per customer */
return SWITCH_STATUS_SUCCESS;
}
-
+
memset(&runtime, 0, sizeof(runtime));
gethostname(runtime.hostname, sizeof(runtime.hostname));
runtime.max_db_handles = 50;
runtime.db_handle_timeout = 5000000;
-
+
runtime.runlevel++;
runtime.dummy_cng_frame.data = runtime.dummy_data;
runtime.dummy_cng_frame.datalen = sizeof(runtime.dummy_data);
GetSystemInfo( &sysinfo );
runtime.cpu_count = sysinfo.dwNumberOfProcessors;
}
-#endif
+#endif
if (!runtime.cpu_count) runtime.cpu_count = 1;
}
switch_log_init(runtime.memory_pool, runtime.colorize_console);
-
+
runtime.tipping_point = 0;
runtime.timer_affinity = -1;
runtime.microseconds_per_tick = 20000;
runtime.running = 1;
runtime.initiated = switch_mono_micro_time_now();
-
+
switch_scheduler_add_task(switch_epoch_time_now(NULL), heartbeat_callback, "heartbeat", "core", 0, NULL, SSHF_NONE | SSHF_NO_DEL);
switch_scheduler_add_task(switch_epoch_time_now(NULL), check_ip_callback, "check_ip", "core", 0, NULL, SSHF_NONE | SSHF_NO_DEL | SSHF_OWN_THREAD);
for (param = switch_xml_child(settings, "codec"); param; param = param->next) {
const char *var = switch_xml_attr_soft(param, "name");
const char *val = switch_xml_attr_soft(param, "ptime");
-
+
if (!zstr(var) && !zstr(val)) {
uint32_t *p;
uint32_t v = switch_atoul(val);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error adding %s, defaults cannot be changed\n", var);
continue;
}
-
+
if (v == 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error adding %s, invalid ptime\n", var);
continue;
}
} else if (!strcasecmp(var, "db-handle-timeout")) {
long tmp = atol(val);
-
+
if (tmp > 0 && tmp < 5001) {
runtime.db_handle_timeout = (uint32_t) tmp * 1000000;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "db-handle-timeout must be between 1 and 5000\n");
}
-
+
} else if (!strcasecmp(var, "multiple-registrations")) {
runtime.multiple_registrations = switch_true(val);
} else if (!strcasecmp(var, "auto-create-schemas")) {
if (tmp > runtime.cpu_count / 2) {
tmp = runtime.cpu_count / 2;
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "This value cannot be higher than %d so setting it to that value\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "This value cannot be higher than %d so setting it to that value\n",
runtime.cpu_count / 2);
}
"| Anthony Minessale II, Michael Jerris, Brian West, Others |\n"
"| FreeSWITCH (http://www.freeswitch.org) |\n"
"| Paypal Donations Appreciated: paypal@freeswitch.org |\n"
- "| Brought to you by ClueCon http://www.cluecon.com/ |\n"
- ".=============================================================.\n"
+ "| Brought to you by ClueCon http://www.cluecon.com/ |\n"
+ ".=============================================================.\n"
"\n");
}
if (switch_core_init(flags, console, err) != SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_GENERR;
}
-
+
if (runtime.runlevel > 1) {
/* one per customer */
return SWITCH_STATUS_SUCCESS;
#ifdef WIN32
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%s%s\n\n", switch_core_banner(), use);
#else
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%s%s%s%s%s%s\n\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%s%s%s%s%s%s\n\n",
SWITCH_SEQ_DEFAULT_COLOR,
SWITCH_SEQ_FYELLOW, SWITCH_SEQ_BBLUE,
- switch_core_banner(),
+ switch_core_banner(),
use, SWITCH_SEQ_DEFAULT_COLOR);
-
+
#endif
{
int *intval = (int *) val;
int oldintval = 0, newintval = 0;
-
+
if (intval) {
oldintval = *intval;
}
if (!zstr(arg)) {
tech = strdup(arg);
-
+
if ((prof = strchr(tech, ':'))) {
*prof++ = '\0';
}
switch_core_set_signal_handlers();
pid = switch_fork();
-
+
if (pid) {
if (wait) {
waitpid(pid, NULL, 0);
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Michael Jerris <mike@jerris.com>
* Paul D. Tinsley <pdt at jackhammer.org>
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
- * Software distributed under the License is distributed on an "AS IS" basis,
+ * Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
* switch_cert.c -- Cert Functions
if (ssl_count == 0) {
num = CRYPTO_num_locks();
-
+
ssl_mutexes = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(switch_mutex_t*));
switch_assert(ssl_mutexes != NULL);
while ((v = strsep(&p, ":")) && (i != (MAX_FPLEN - 1))) {
sscanf(v, "%02x", (uint32_t *) &fdata[i++]);
}
-
+
free(tmp);
i = !memcmp(fdata, fp->data, i);
while ((v = strsep(&p, ":")) && (i != (MAX_FPLEN - 1))) {
sscanf(v, "%02x", (uint32_t *) &fp->data[i++]);
}
-
+
free(tmp);
return i;
unsigned int i, j;
evp = get_evp_by_name(fp->type);
-
+
if (X509_digest(x509, evp, fp->data, &fp->len) != 1 || fp->len <= 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "FP DIGEST ERR!\n");
return -1;
*(&fp->str[fp->len * 3]) = '\0';
return 0;
-
+
}
SWITCH_DECLARE(int) switch_core_cert_gen_fingerprint(const char *prefix, dtls_fingerprint_t *fp)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "FP BIO ERR!\n");
goto end;
}
-
+
if (BIO_read_filename(bio, rsa) != 1) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "FP FILE ERR!\n");
goto end;
}
switch_core_cert_extract_fingerprint(x509, fp);
-
+
ret = 1;
end:
}
free(rsa);
-
+
return ret;
}
}
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
-
+
//bio_err=BIO_new_fp(stderr, BIO_NOCLOSE);
-
+
mkcert(&x509, &pkey, 1024, 0, 36500);
//RSA_print_fp(stdout, pkey->pkey.rsa, 0);
PEM_write_PrivateKey(fp, pkey, NULL, NULL, 0, NULL, NULL);
fclose(fp);
}
-
+
if (rsa && (fp = fopen(rsa, "w"))) {
PEM_write_X509(fp, x509);
fclose(fp);
EVP_PKEY *pk;
RSA *rsa;
X509_NAME *name=NULL;
-
+
switch_assert(pkeyp);
switch_assert(x509p);
if (*pkeyp == NULL) {
if ((pk = EVP_PKEY_new()) == NULL) {
- abort();
+ abort();
}
} else {
pk = *pkeyp;
*/
X509_NAME_add_entry_by_txt(name, "C", MBSTRING_ASC, (unsigned char *)"US", -1, -1, 0);
X509_NAME_add_entry_by_txt(name, "CN", MBSTRING_ASC, (unsigned char *)"FreeSWITCH", -1, -1, 0);
-
+
/* Its self signed so set the issuer name to be the same as the
* subject.
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Michael Jerris <mike@jerris.com>
* Paul D. Tinsley <pdt at jackhammer.org>
}
session->real_read_codec = codec;
session->real_read_impl = *codec->implementation;
-
+
/* set read_codec with real_read_codec if it no longer is ready */
if (!switch_core_codec_ready(session->read_codec)) {
session->read_codec = codec;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Restore previous codec %s:%d.\n",
switch_channel_get_name(session->channel),
session->read_impl.iananame ? session->read_impl.iananame : "N/A", session->read_impl.ianacode);
-
+
} else if (session->real_read_codec) {
session->read_codec = session->real_read_codec;
*impp = session->write_impl;
return SWITCH_STATUS_SUCCESS;
}
-
+
memset(impp, 0, sizeof(*impp));
impp->number_of_channels = 1;
return SWITCH_STATUS_FALSE;
{
switch_codec_interface_t *codec_interface;
switch_status_t status = SWITCH_STATUS_FALSE;
-
+
if (zstr(codec_name) || zstr(fmtp) || !codec_fmtp) {
return SWITCH_STATUS_FALSE;
}
memset(codec_fmtp, 0, sizeof(*codec_fmtp));
-
+
if ((codec_interface = switch_loadable_module_get_codec_interface(codec_name, NULL))) {
if (codec_interface->parse_fmtp) {
codec_fmtp->actual_samples_per_second = rate;
}
-SWITCH_DECLARE(switch_status_t) switch_core_codec_copy(switch_codec_t *codec, switch_codec_t *new_codec,
+SWITCH_DECLARE(switch_status_t) switch_core_codec_copy(switch_codec_t *codec, switch_codec_t *new_codec,
const switch_codec_settings_t *codec_settings, switch_memory_pool_t *pool)
{
switch_assert(codec != NULL);
switch_assert(new_codec != NULL);
-
- return switch_core_codec_init(new_codec,
+
+ return switch_core_codec_init(new_codec,
codec->implementation->iananame,
codec->implementation->modname,
codec->fmtp_in,
codec->flags,
codec_settings,
pool);
-
+
}
SWITCH_DECLARE(switch_status_t) switch_core_codec_init_with_bitrate(switch_codec_t *codec, const char *codec_name, const char *modname, const char *fmtp,
goto found;
}
-
+
/* If no specific codec interval is requested opt for 20ms above all else because lots of stuff assumes it */
if (!ms) {
for (iptr = codec_interface->implementations; iptr; iptr = iptr->next) {
switch_set_flag(codec, SWITCH_CODEC_FLAG_READY);
return SWITCH_STATUS_SUCCESS;
} else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Codec %s Exists but not at the desired implementation. %dhz %dms %dch\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Codec %s Exists but not at the desired implementation. %dhz %dms %dch\n",
codec_name, rate, ms, channels);
-
+
}
UNPROTECT_INTERFACE(codec_interface);
uint32_t frames = encoded_data_len / codec->implementation->encoded_bytes_per_packet / codec->implementation->number_of_channels;
if (frames && codec->implementation->decoded_bytes_per_packet * frames > *decoded_data_len) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Buffer size sanity check failed! edl:%u ebpp:%u fr:%u ddl:%u\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Buffer size sanity check failed! edl:%u ebpp:%u fr:%u ddl:%u\n",
encoded_data_len, codec->implementation->encoded_bytes_per_packet, frames, *decoded_data_len);
*decoded_data_len = codec->implementation->decoded_bytes_per_packet;
memset(decoded_data, 255, *decoded_data_len);
return SWITCH_STATUS_SUCCESS;
}
}
-
+
if (codec->mutex) switch_mutex_lock(codec->mutex);
status = codec->implementation->decode(codec, other_codec, encoded_data, encoded_data_len, encoded_rate,
decoded_data, decoded_data_len, decoded_rate, flag);
if (codec->implementation->encode_video) {
status = codec->implementation->encode_video(codec, frame);
-
+
if (status == SWITCH_STATUS_MORE_DATA) {
frame->flags |= SFF_SAME_IMAGE;
} else {
}
-SWITCH_DECLARE(switch_status_t) switch_core_codec_control(switch_codec_t *codec,
- switch_codec_control_command_t cmd,
+SWITCH_DECLARE(switch_status_t) switch_core_codec_control(switch_codec_t *codec,
+ switch_codec_control_command_t cmd,
switch_codec_control_type_t ctype,
void *cmd_data,
switch_codec_control_type_t atype,
void *cmd_arg,
switch_codec_control_type_t *rtype,
- void **ret_data)
+ void **ret_data)
{
switch_status_t status = SWITCH_STATUS_FALSE;
switch_assert(codec != NULL);
-
+
if (!codec->implementation || !switch_core_codec_ready(codec)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec is not initialized!\n");
abort();
}
codec->implementation->destroy(codec);
-
+
UNPROTECT_INTERFACE(codec->codec_interface);
if (mutex) switch_mutex_unlock(mutex);
-
+
if (free_pool) {
switch_core_destroy_memory_pool(&pool);
}
memset(codec, 0, sizeof(*codec));
-
+
return SWITCH_STATUS_SUCCESS;
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Michael Jerris <mike@jerris.com>
*
*
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Michael Jerris <mike@jerris.com>
* Paul D. Tinsley <pdt at jackhammer.org>
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
* switch_core_event_hook.c Core Event Hooks
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Michael Jerris <mike@jerris.com>
* Paul D. Tinsley <pdt at jackhammer.org>
char *modname;
const char *val;
int tmp;
-
+
fp = switch_core_strdup(fh->memory_pool, file_path);
while (*fp == '{') {
char *parsed = NULL;
-
+
if (switch_event_create_brackets(fp, '{', '}', ',', &fh->params, &parsed, SWITCH_FALSE) != SWITCH_STATUS_SUCCESS || !parsed) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
goto fail;
}
-
+
fp = parsed;
}
file_path = fp;
-
+
if ((timeout = switch_event_get_header(fh->params, "timeout"))) {
if ((to = atoi(timeout)) < 1) {
to = 0;
if ((val = switch_event_get_header(fh->params, "vb"))) {
tmp = atoi(val);
-
+
if (strrchr(val, 'k')) {
tmp *= 1024;
} else if (strrchr(val, 'm')) {
} else if (strrchr(val, 'm')) {
tmp *= 1048576;
}
-
+
if (tmp > 0 && tmp < 104857600 /*100mb*/) {
fh->mm.vbuf = tmp;
} else {
fh->samples_in = 0;
fh->max_samples = 0;
-
+
if (switch_test_flag(fh, SWITCH_FILE_FLAG_FREE_POOL)) {
switch_core_destroy_memory_pool(&fh->memory_pool);
}
if ((status = fh->file_interface->file_read(fh, fh->pre_buffer_data, &rlen)) == SWITCH_STATUS_BREAK) {
return SWITCH_STATUS_BREAK;
}
-
+
if (status != SWITCH_STATUS_SUCCESS || !rlen) {
switch_set_flag_locked(fh, SWITCH_FILE_BUFFER_DONE);
{
switch_status_t status;
int ok = 1;
-
+
switch_assert(fh != NULL);
if (!switch_test_flag(fh, SWITCH_FILE_OPEN) || !fh->file_interface->file_seek) {
} else if (!switch_test_flag(fh, SWITCH_FILE_FLAG_READ)) {
ok = 0;
}
-
+
if (!ok) {
return SWITCH_STATUS_FALSE;
}
-
+
if (fh->buffer) {
switch_buffer_zero(fh->buffer);
}
SWITCH_DECLARE(switch_status_t) switch_core_file_command(switch_file_handle_t *fh, switch_file_command_t command)
{
switch_status_t status = SWITCH_STATUS_FALSE;
-
+
switch_assert(fh != NULL);
switch_assert(fh->file_interface != NULL);
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Michael Jerris <mike@jerris.com>
* Paul D. Tinsley <pdt at jackhammer.org>
int r = 0;
r = switch_hashtable_insert_destructor(hash, strdup(key), (void *)data, HASHTABLE_FLAG_FREE_KEY | HASHTABLE_DUP_CHECK, destructor);
-
+
return r ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
}
switch_event_t *event = NULL;
switch_event_header_t *header = NULL;
switch_status_t status = SWITCH_STATUS_GENERR;
-
+
switch_event_create_subclass(&event, SWITCH_EVENT_CLONE, NULL);
switch_assert(event);
-
+
/* iterate through the hash, call callback, if callback returns NULL or true, put the key on the list (event)
When done, iterate through the list deleting hash entries
*/
-
+
for (hi = switch_core_hash_first(hash); hi; hi = switch_core_hash_next(&hi)) {
const void *key;
void *val;
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "delete", (const char *) key);
}
}
-
+
/* now delete them */
for (header = event->headers; header; header = header->next) {
if (switch_core_hash_delete(hash, header->value)) {
}
switch_event_destroy(&event);
-
+
return status;
}
-/*
+/*
* FreeSWITCH Moular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Michael Jerris <mike@jerris.com>
* Paul D. Tinsley <pdt at jackhammer.org>
SWITCH_DECLARE(void) switch_core_gen_encoded_silence(unsigned char *data, const switch_codec_implementation_t *read_impl, switch_size_t len)
{
unsigned char g729_filler[] = {
- 114, 170, 250, 103, 54, 211, 203, 194, 94, 64,
+ 114, 170, 250, 103, 54, 211, 203, 194, 94, 64,
229, 127, 79, 96, 207, 82, 216, 110, 245, 81,
- 114, 170, 250, 103, 54, 211, 203, 194, 94, 64,
+ 114, 170, 250, 103, 54, 211, 203, 194, 94, 64,
229, 127, 79, 96, 207, 82, 216, 110, 245, 81,
- 114, 170, 250, 103, 54, 211, 203, 194, 94, 64,
+ 114, 170, 250, 103, 54, 211, 203, 194, 94, 64,
229, 127, 79, 96, 207, 82, 216, 110, 245, 81,
- 114, 170, 250, 103, 54, 211, 203, 194, 94, 64,
+ 114, 170, 250, 103, 54, 211, 203, 194, 94, 64,
229, 127, 79, 96, 207, 82, 216, 110, 245, 81,
- 114, 170, 250, 103, 54, 211, 203, 194, 94, 64,
+ 114, 170, 250, 103, 54, 211, 203, 194, 94, 64,
229, 127, 79, 96, 207, 82, 216, 110, 245, 81,
- 114, 170, 250, 103, 54, 211, 203, 194, 94, 64,
+ 114, 170, 250, 103, 54, 211, 203, 194, 94, 64,
229, 127, 79, 96, 207, 82, 216, 110, 245, 81,
- 114, 170, 250, 103, 54, 211, 203, 194, 94, 64,
+ 114, 170, 250, 103, 54, 211, 203, 194, 94, 64,
229, 127, 79, 96, 207, 82, 216, 110, 245, 81
};
-
+
if (read_impl->ianacode == 18 || switch_stristr("g729", read_impl->iananame)) {
memcpy(data, g729_filler, len);
} else {
switch_mutex_lock(session->read_codec->mutex);
top:
-
+
for(i = 0; i < 2; i++) {
if (session->dmachine[i]) {
switch_channel_dtmf_lock(session->channel);
switch_channel_dtmf_unlock(session->channel);
}
}
-
+
if (switch_channel_down(session->channel) || !switch_core_codec_ready(session->read_codec)) {
*frame = NULL;
status = SWITCH_STATUS_FALSE;
msg.message_id = SWITCH_MESSAGE_HEARTBEAT_EVENT;
msg.numeric_arg = session->track_duration;
switch_core_session_receive_message(session, &msg);
-
+
switch_event_create(&event, SWITCH_EVENT_SESSION_HEARTBEAT);
switch_channel_event_set_data(session->channel, event);
switch_event_fire(&event);
if (!switch_core_codec_ready(session->read_codec)) {
*frame = NULL;
status = SWITCH_STATUS_FALSE;
- goto even_more_done;
+ goto even_more_done;
}
}
if (switch_channel_test_flag(session->channel, CF_PAUSE_BUGS) && !switch_core_media_bug_test_flag(bp, SMBF_NO_PAUSE)) {
continue;
}
-
+
if (!switch_channel_test_flag(session->channel, CF_ANSWERED) && switch_core_media_bug_test_flag(bp, SMBF_ANSWER_REQ)) {
continue;
}
prune++;
continue;
}
-
+
if (bp->ready) {
if (switch_test_flag(bp, SMBF_TAP_NATIVE_READ)) {
- if ((*frame)->codec && (*frame)->codec->implementation &&
- (*frame)->codec->implementation->encoded_bytes_per_packet &&
+ if ((*frame)->codec && (*frame)->codec->implementation &&
+ (*frame)->codec->implementation->encoded_bytes_per_packet &&
(*frame)->datalen != (*frame)->codec->implementation->encoded_bytes_per_packet) {
switch_set_flag((*frame), SFF_CNG);
break;
}
}
}
-
+
if ((bp->stop_time && bp->stop_time <= switch_epoch_time_now(NULL)) || ok == SWITCH_FALSE) {
switch_set_flag(bp, SMBF_PRUNE);
prune++;
if (session->read_codec->implementation->impl_id != codec_impl.impl_id) {
need_codec = TRUE;
tap_only = 0;
- }
-
+ }
+
if (codec_impl.actual_samples_per_second != session->read_impl.actual_samples_per_second) {
do_resample = 1;
}
if (tap_only) {
switch_media_bug_t *bp;
switch_bool_t ok = SWITCH_TRUE;
- int prune = 0;
+ int prune = 0;
if (session->bugs && switch_test_flag((*frame), SFF_CNG)) {
switch_thread_rwlock_rdlock(session->bug_rwlock);
if (switch_channel_test_flag(session->channel, CF_PAUSE_BUGS) && !switch_core_media_bug_test_flag(bp, SMBF_NO_PAUSE)) {
continue;
}
-
+
if (!switch_channel_test_flag(session->channel, CF_ANSWERED) && switch_core_media_bug_test_flag(bp, SMBF_ANSWER_REQ)) {
continue;
}
prune++;
continue;
}
-
+
if (bp->ready && (*frame)->codec && (*frame)->codec->implementation && (*frame)->codec->implementation->encoded_bytes_per_packet) {
if (switch_test_flag(bp, SMBF_TAP_NATIVE_READ)) {
if (bp->callback) {
switch_frame_t tmp_frame = {0};
unsigned char data[SWITCH_RECOMMENDED_BUFFER_SIZE] = {0};
-
-
+
+
tmp_frame.codec = (*frame)->codec;
tmp_frame.datalen = (*frame)->codec->implementation->encoded_bytes_per_packet;
tmp_frame.samples = (*frame)->codec->implementation->samples_per_packet;
tmp_frame.channels = (*frame)->codec->implementation->number_of_channels;
tmp_frame.data = data;
-
+
switch_core_gen_encoded_silence(data, (*frame)->codec->implementation, tmp_frame.datalen);
-
+
bp->native_read_frame = &tmp_frame;
ok = bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_TAP_NATIVE_READ);
bp->native_read_frame = NULL;
}
}
}
-
+
if ((bp->stop_time && bp->stop_time <= switch_epoch_time_now(NULL)) || ok == SWITCH_FALSE) {
switch_set_flag(bp, SMBF_PRUNE);
prune++;
if (prune) {
switch_core_media_bug_prune(session);
}
-
-
+
+
}
switch_core_session_t *other_session;
const char *uuid = switch_channel_get_partner_uuid(switch_core_session_get_channel(session));
switch_clear_flag(session, SSF_READ_TRANSCODE);
-
+
if (uuid && (other_session = switch_core_session_locate(uuid))) {
switch_set_flag(other_session, SSF_READ_CODEC_RESET);
switch_set_flag(other_session, SSF_READ_CODEC_RESET);
switch_clear_flag(session, SSF_READ_CODEC_RESET);
}
-
+
if (status == SWITCH_STATUS_SUCCESS && need_codec) {
switch_frame_t *enc_frame, *read_frame = *frame;
read_frame->codec->implementation->iananame, read_frame->codec->implementation->ianacode);
switch_core_codec_copy(read_frame->codec, &session->bug_codec, NULL, NULL);
if (!switch_core_codec_ready(&session->bug_codec)) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "%s Error setting BUG codec %s!\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "%s Error setting BUG codec %s!\n",
switch_core_session_get_name(session), read_frame->codec->implementation->iananame);
}
}
switch_channel_test_flag(session->channel, CF_CNG_PLC)) && !session->plc) {
session->plc = plc_init(NULL);
}
-
+
if (!switch_test_flag(read_frame->codec, SWITCH_CODEC_FLAG_HAS_PLC) && session->plc && switch_test_flag(read_frame, SFF_PLC)) {
session->raw_read_frame.datalen = read_frame->codec->implementation->decoded_bytes_per_packet;
session->raw_read_frame.samples = session->raw_read_frame.datalen / sizeof(int16_t) / session->read_impl.number_of_channels;
if (!switch_core_codec_ready(codec)) {
codec = read_frame->codec;
}
-
+
if (!switch_core_codec_ready(codec)) {
switch_thread_rwlock_unlock(session->bug_rwlock);
goto done;
}
-
+
codec->cur_frame = read_frame;
session->read_codec->cur_frame = read_frame;
status = switch_core_codec_decode(codec,
read_frame->data,
read_frame->datalen,
session->read_impl.actual_samples_per_second,
- session->raw_read_frame.data, &session->raw_read_frame.datalen, &session->raw_read_frame.rate,
+ session->raw_read_frame.data, &session->raw_read_frame.datalen, &session->raw_read_frame.rate,
&read_frame->flags);
if (status == SWITCH_STATUS_NOT_INITALIZED) {
switch_thread_rwlock_unlock(session->bug_rwlock);
}
-
+
if (status == SWITCH_STATUS_SUCCESS && session->read_impl.number_of_channels == 1) {
if (session->plc) {
if (switch_test_flag(read_frame, SFF_PLC)) {
status = switch_resample_create(&session->read_resampler,
read_frame->codec->implementation->actual_samples_per_second,
session->read_impl.actual_samples_per_second,
- session->read_impl.decoded_bytes_per_packet, SWITCH_RESAMPLE_QUALITY,
+ session->read_impl.decoded_bytes_per_packet, SWITCH_RESAMPLE_QUALITY,
session->read_impl.number_of_channels);
switch_mutex_unlock(session->resample_mutex);
uint32_t samples = bytes / 2 / bp->read_demux_frame->channels;
memcpy(data, read_frame->data, read_frame->datalen);
- datalen = switch_unmerge_sln((int16_t *)data, samples,
- bp->read_demux_frame->data, samples,
+ datalen = switch_unmerge_sln((int16_t *)data, samples,
+ bp->read_demux_frame->data, samples,
bp->read_demux_frame->channels) * 2 * bp->read_demux_frame->channels;
switch_buffer_write(bp->raw_read_buffer, data, datalen);
goto done;
}
}
-
+
if (perfect || switch_buffer_inuse(session->raw_read_buffer) >= session->read_impl.decoded_bytes_per_packet) {
if (perfect) {
enc_frame = read_frame;
switch_mutex_unlock(session->read_codec->mutex);
switch_mutex_unlock(session->codec_read_mutex);
-
+
if (status == SWITCH_STATUS_SUCCESS && switch_channel_get_callstate(session->channel) == CCS_UNHELD) {
switch_channel_set_callstate(session->channel, CCS_ACTIVE);
}
switch_status_t status;
switch_dtmf_t new_dtmf;
int fed = 0;
-
+
if (switch_channel_down(session->channel)) {
return SWITCH_STATUS_FALSE;
}
- if (switch_test_flag(dtmf, DTMF_FLAG_SENSITIVE)) {
+ if (switch_test_flag(dtmf, DTMF_FLAG_SENSITIVE)) {
return SWITCH_STATUS_SUCCESS;
}
} else if (!new_dtmf.duration) {
new_dtmf.duration = switch_core_default_dtmf_duration(0);
}
-
+
if (!switch_test_flag(dtmf, DTMF_FLAG_SKIP_PROCESS)) {
if (session->dmachine[0]) {
char str[2] = { dtmf->digit, '\0' };
return SWITCH_STATUS_FALSE;
}
- if (switch_test_flag(dtmf, DTMF_FLAG_SENSITIVE)) {
+ if (switch_test_flag(dtmf, DTMF_FLAG_SENSITIVE)) {
return SWITCH_STATUS_SUCCESS;
}
switch_assert(dtmf);
new_dtmf = *dtmf;
-
+
if (new_dtmf.digit != 'w' && new_dtmf.digit != 'W') {
if (new_dtmf.duration > switch_core_max_dtmf_duration(0)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s EXCESSIVE DTMF DIGIT [%c] LEN [%d]\n",
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s SHORT DTMF DIGIT [%c] LEN [%d]\n",
switch_channel_get_name(session->channel), new_dtmf.digit, new_dtmf.duration);
new_dtmf.duration = switch_core_min_dtmf_duration(0);
- }
+ }
}
if (!new_dtmf.duration) {
new_dtmf.duration = switch_core_default_dtmf_duration(0);
}
- if (!switch_test_flag(dtmf, DTMF_FLAG_SKIP_PROCESS)) {
+ if (!switch_test_flag(dtmf, DTMF_FLAG_SKIP_PROCESS)) {
for (ptr = session->event_hooks.send_dtmf; ptr; ptr = ptr->next) {
if ((status = ptr->send_dtmf(session, dtmf, SWITCH_DTMF_SEND)) != SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_SUCCESS;
if (session->endpoint_interface->io_routines->send_dtmf) {
int send = 0;
status = SWITCH_STATUS_SUCCESS;
-
+
if (switch_channel_test_cap(session->channel, CC_QUEUEABLE_DTMF_DELAY) && (dtmf->digit == 'w' || dtmf->digit == 'W')) {
send = 1;
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s SHORT DTMF DIGIT [%c] LEN [%d]\n",
switch_channel_get_name(session->channel), dtmf.digit, dtmf.duration);
dtmf.duration = switch_core_min_dtmf_duration(0);
- }
+ }
}
if (!dtmf.duration) {
dtmf.duration = switch_core_default_dtmf_duration(0);
}
-
+
if (switch_core_session_send_dtmf(session, &dtmf) == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s send dtmf\ndigit=%c ms=%u samples=%u\n",
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Seven Du <dujinfang@gmail.com>
*
switch_timer_t video_timer;
- switch_vid_params_t vid_params;
+ switch_vid_params_t vid_params;
switch_file_handle_t *video_read_fh;
switch_file_handle_t *video_write_fh;
case sdp_inactive:
return SWITCH_MEDIA_FLOW_INACTIVE;
}
-
+
return SWITCH_MEDIA_FLOW_SENDRECV;
}
- switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(aleg_session->channel), SWITCH_LOG_DEBUG1,
+ switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(aleg_session->channel), SWITCH_LOG_DEBUG1,
"Deciding whether to pass zrtp-hash between a-leg and b-leg\n");
if (!(switch_channel_test_flag(aleg_session->channel, CF_ZRTP_PASSTHRU_REQ))) {
- switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(aleg_session->channel), SWITCH_LOG_DEBUG1,
+ switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(aleg_session->channel), SWITCH_LOG_DEBUG1,
"CF_ZRTP_PASSTHRU_REQ not set on a-leg, so not propagating zrtp-hash\n");
return;
}
bleg_engine->local_sdp_zrtp_hash = switch_core_session_strdup(bleg_session, aleg_engine->remote_sdp_zrtp_hash);
switch_channel_set_variable(bleg_session->channel, "l_sdp_audio_zrtp_hash", bleg_engine->local_sdp_zrtp_hash);
}
-
+
if (bleg_engine->remote_sdp_zrtp_hash) {
switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(aleg_session->channel), SWITCH_LOG_DEBUG, "Passing b-leg remote zrtp-hash (audio) to a-leg\n");
aleg_engine->local_sdp_zrtp_hash = switch_core_session_strdup(aleg_session, bleg_engine->remote_sdp_zrtp_hash);
switch_media_handle_t *smh;
time_t now;
uint32_t fps, elapsed = 0;
-
+
switch_assert(session);
-
+
if (!(smh = session->media_handle)) {
return SWITCH_STATUS_FALSE;
- }
+ }
if (!switch_channel_test_flag(session->channel, CF_VIDEO)) {
return 0;
if (!(smh->vid_started && smh->vid_frames && elapsed > 0)) {
return 0;
}
-
- fps = switch_round_to_step(smh->vid_frames / (elapsed), 5);
+
+ fps = switch_round_to_step(smh->vid_frames / (elapsed), 5);
if (smh->vid_frames > 1000) {
smh->vid_started = switch_epoch_time_now(NULL);
if (fps > 0) {
video_globals.fps = fps;
-
+
if (smh->vid_params.fps != fps) {
switch_channel_set_variable_printf(session->channel, "video_fps", "%d", fps);
smh->vid_params.fps = fps;
return engine->local_sdp_zrtp_hash;
}
-
+
return engine->remote_sdp_zrtp_hash;
}
sdp_attribute_t *attr;
switch_assert(sdp);
-
+
if (!t38_options) {
t38_options = switch_core_session_alloc(session, sizeof(switch_t38_options_t));
} else {
t38_options->sdp_o_line = "unknown";
}
-
+
if (m->m_connections && m->m_connections->c_address) {
t38_options->remote_ip = switch_core_session_strdup(session, m->m_connections->c_address);
} else if (sdp->sdp_connection && sdp->sdp_connection->c_address) {
}
a_engine = &smh->engines[SWITCH_MEDIA_TYPE_AUDIO];
- v_engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO];
- t_engine = &smh->engines[SWITCH_MEDIA_TYPE_TEXT];
-
+ v_engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO];
+ t_engine = &smh->engines[SWITCH_MEDIA_TYPE_TEXT];
+
if (!switch_media_handle_test_media_flag(smh, SCMF_DISABLE_RTP_AUTOADJ) &&
- !((val = switch_channel_get_variable(session->channel, "disable_rtp_auto_adjust")) && switch_true(val)) &&
+ !((val = switch_channel_get_variable(session->channel, "disable_rtp_auto_adjust")) && switch_true(val)) &&
!switch_channel_test_flag(session->channel, CF_AVPF)) {
/* Reactivate the NAT buster flag. */
-
+
if (a_engine->rtp_session) {
switch_rtp_set_flag(a_engine->rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
x++;
}
-
+
if (v_engine->rtp_session) {
switch_rtp_set_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
x++;
//?
-SWITCH_DECLARE(switch_status_t) switch_core_media_process_t38_passthru(switch_core_session_t *session,
+SWITCH_DECLARE(switch_status_t) switch_core_media_process_t38_passthru(switch_core_session_t *session,
switch_core_session_t *other_session, switch_t38_options_t *t38_options)
{
char *remote_host;
remote_host = switch_rtp_get_remote_host(a_engine->rtp_session);
remote_port = switch_rtp_get_remote_port(a_engine->rtp_session);
-
+
a_engine->cur_payload_map->remote_sdp_ip = switch_core_session_strdup(session, t38_options->remote_ip);
a_engine->cur_payload_map->remote_sdp_port = t38_options->remote_port;
-
- if (remote_host && remote_port && !strcmp(remote_host, a_engine->cur_payload_map->remote_sdp_ip) &&
+
+ if (remote_host && remote_port && !strcmp(remote_host, a_engine->cur_payload_map->remote_sdp_ip) &&
remote_port == a_engine->cur_payload_map->remote_sdp_port) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
"Audio params are unchanged for %s.\n",
switch_channel_get_name(session->channel));
} else {
const char *err = NULL;
-
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
+
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
"Audio params changed for %s from %s:%d to %s:%d\n",
switch_channel_get_name(session->channel),
remote_host, remote_port, a_engine->cur_payload_map->remote_sdp_ip, a_engine->cur_payload_map->remote_sdp_port);
-
+
switch_snprintf(tmp, sizeof(tmp), "%d", a_engine->cur_payload_map->remote_sdp_port);
switch_channel_set_variable(session->channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE, a_engine->cur_payload_map->remote_sdp_ip);
switch_channel_set_variable(session->channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE, tmp);
switch_channel_hangup(session->channel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION);
}
}
-
+
switch_core_media_copy_t38_options(t38_options, other_session);
return SWITCH_STATUS_SUCCESS;
*ptP = pt;
}
if (recv_ptP) {
- *recv_ptP = recv_pt;
+ *recv_ptP = recv_pt;
}
-
+
if (!zstr(fmtp) && fmtpP) {
*fmtpP = fmtp;
}
}
return SWITCH_STATUS_FALSE;
-
+
}
-SWITCH_DECLARE(payload_map_t *) switch_core_media_add_payload_map(switch_core_session_t *session,
+SWITCH_DECLARE(payload_map_t *) switch_core_media_add_payload_map(switch_core_session_t *session,
switch_media_type_t type,
- const char *name,
- const char *modname,
+ const char *name,
+ const char *modname,
const char *fmtp,
switch_sdp_type_t sdp_type,
- uint32_t pt,
- uint32_t rate,
+ uint32_t pt,
+ uint32_t rate,
uint32_t ptime,
uint32_t channels,
uint8_t negotiated)
exists = (type == pmap->type && !strcasecmp(name, pmap->iananame));
break;
}
-
+
if (exists) {
if (!zstr(fmtp) && !zstr(pmap->rm_fmtp)) {
continue;
}
}
-
+
break;
}
}
engine->pmap_tail = engine->pmap_tail->next;
}
}
-
+
switch_mutex_unlock(smh->sdp_mutex);
return pmap;
preferred = "PCMU";
fallback = "PCMU";
} else {
-
+
if (!(preferred = switch_channel_get_variable(session->channel, "absolute_codec_string"))) {
preferred = switch_channel_get_variable(session->channel, "codec_string");
}
if (switch_stristr("IGNORE_MARK_BIT", str)) {
*flag_pole |= RTP_BUG_IGNORE_MARK_BIT;
- }
+ }
if (switch_stristr("~IGNORE_MARK_BIT", str)) {
*flag_pole &= ~RTP_BUG_IGNORE_MARK_BIT;
- }
+ }
if (switch_stristr("SEND_LINEAR_TIMESTAMPS", str)) {
*flag_pole |= RTP_BUG_SEND_LINEAR_TIMESTAMPS;
return SWITCH_STATUS_SUCCESS;
}
-
+
//#define SAME_KEY
#ifdef SAME_KEY
} else {
key = engine->ssec[ctype].remote_raw_key;
}
-
+
switch_rtp_get_random(key, SUITES[ctype].keylen);
#ifdef SAME_KEY
}
switch_channel_set_variable_name_printf(smh->session->channel, engine->ssec[ctype].local_crypto_key, "rtp_last_%s_local_crypto_key", type2str(type));
switch_channel_set_flag(smh->session->channel, CF_SECURE);
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_DEBUG, "Set Local %s crypto Key [%s]\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_DEBUG, "Set Local %s crypto Key [%s]\n",
type2str(type),
engine->ssec[ctype].local_crypto_key);
p++;
type = switch_core_media_crypto_str2type(p);
-
+
if (type == CRYPTO_INVALID) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error near [%s]\n", p);
goto bad;
if (engine->ssec[engine->crypto_type].remote_crypto_key && switch_channel_test_flag(session->channel, CF_SECURE)) {
switch_core_media_add_crypto(&engine->ssec[engine->crypto_type], engine->ssec[engine->crypto_type].remote_crypto_key, SWITCH_RTP_CRYPTO_RECV);
-
+
switch_rtp_add_crypto_key(engine->rtp_session, SWITCH_RTP_CRYPTO_SEND, 1,
- engine->ssec[engine->crypto_type].crypto_type,
- engine->ssec[engine->crypto_type].local_raw_key,
+ engine->ssec[engine->crypto_type].crypto_type,
+ engine->ssec[engine->crypto_type].local_raw_key,
SUITES[engine->ssec[engine->crypto_type].crypto_type].keylen);
- switch_rtp_add_crypto_key(engine->rtp_session, SWITCH_RTP_CRYPTO_RECV,
+ switch_rtp_add_crypto_key(engine->rtp_session, SWITCH_RTP_CRYPTO_RECV,
engine->ssec[engine->crypto_type].crypto_tag,
- engine->ssec[engine->crypto_type].crypto_type,
- engine->ssec[engine->crypto_type].remote_raw_key,
+ engine->ssec[engine->crypto_type].crypto_type,
+ engine->ssec[engine->crypto_type].remote_raw_key,
SUITES[engine->ssec[engine->crypto_type].crypto_type].keylen);
switch_channel_set_variable(session->channel, varname, "true");
switch_media_handle_t *smh;
char *fields[CRYPTO_INVALID+1];
int argc = 0, i = 0, j = 0, k = 0;
-
+
if (!(smh = session->media_handle)) {
return;
}
var = "rtp_secure_media";
val = switch_channel_get_variable(session->channel, var);
}
-
+
if (!zstr(val) && (suites = strchr(val, ':'))) {
*suites++ = '\0';
}
if (smh->crypto_mode != CRYPTO_MODE_FORBIDDEN && !zstr(suites)) {
argc = switch_split((char *)suites, ':', fields);
-
+
for (i = 0; i < argc; i++) {
int ok = 0;
-
+
for (j = 0; j < CRYPTO_INVALID; j++) {
if (!strcasecmp(fields[i], SUITES[j].name)) {
smh->crypto_suite_order[k++] = SUITES[j].type;
break;
}
}
-
+
if (!ok) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "INVALID SUITE SUPPLIED\n");
}
-SWITCH_DECLARE(int) switch_core_session_check_incoming_crypto(switch_core_session_t *session,
+SWITCH_DECLARE(int) switch_core_session_check_incoming_crypto(switch_core_session_t *session,
const char *varname,
switch_media_type_t type, const char *crypto, int crypto_tag, switch_sdp_type_t sdp_type)
{
if (switch_channel_test_flag(session->channel, CF_AVPF)) {
return 0;
}
-
+
engine = &session->media_handle->engines[type];
-
+
for (i = 0; smh->crypto_suite_order[i] != CRYPTO_INVALID; i++) {
switch_rtp_crypto_key_type_t j = SUITES[smh->crypto_suite_order[i]].type;
-
+
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,"looking for crypto suite [%s] in [%s]\n", SUITES[j].name, crypto);
-
+
if (switch_stristr(SUITES[j].name, crypto)) {
ctype = SUITES[j].type;
vval = SUITES[j].name;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Change Remote key to [%s]\n", crypto);
engine->ssec[engine->crypto_type].remote_crypto_key = switch_core_session_strdup(session, crypto);
-
+
if (engine->type == SWITCH_MEDIA_TYPE_AUDIO) {
switch_channel_set_variable(session->channel, "srtp_remote_audio_crypto_key", crypto);
switch_channel_set_variable_printf(session->channel, "srtp_remote_audio_crypto_tag", "%d", crypto_tag);
}
engine->ssec[engine->crypto_type].crypto_tag = crypto_tag;
-
-
+
+
if (switch_rtp_ready(engine->rtp_session) && switch_channel_test_flag(session->channel, CF_SECURE)) {
switch_core_media_add_crypto(&engine->ssec[engine->crypto_type], engine->ssec[engine->crypto_type].remote_crypto_key, SWITCH_RTP_CRYPTO_RECV);
switch_rtp_add_crypto_key(engine->rtp_session, SWITCH_RTP_CRYPTO_RECV, engine->ssec[engine->crypto_type].crypto_tag,
engine->ssec[engine->crypto_type].crypto_type, engine->ssec[engine->crypto_type].remote_raw_key, SUITES[engine->ssec[engine->crypto_type].crypto_type].keylen);
}
got_crypto++;
-
+
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Ignoring unacceptable key\n");
}
engine->ssec[engine->crypto_type].crypto_tag = crypto_tag;
got_crypto++;
-
+
switch_channel_set_variable(session->channel, varname, vval);
switch_channel_set_flag(smh->session->channel, CF_SECURE);
}
a_engine = &smh->engines[SWITCH_MEDIA_TYPE_AUDIO];
- v_engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO];
- t_engine = &smh->engines[SWITCH_MEDIA_TYPE_TEXT];
+ v_engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO];
+ t_engine = &smh->engines[SWITCH_MEDIA_TYPE_TEXT];
if (a_engine->rtp_session) {
switch_rtp_sync_stats(a_engine->rtp_session);
SWITCH_DECLARE(void) switch_core_media_set_stats(switch_core_session_t *session)
{
-
+
if (!session->media_handle) {
return;
}
}
a_engine = &smh->engines[SWITCH_MEDIA_TYPE_AUDIO];
- v_engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO];
- //t_engine = &smh->engines[SWITCH_MEDIA_TYPE_TEXT];
+ v_engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO];
+ //t_engine = &smh->engines[SWITCH_MEDIA_TYPE_TEXT];
+
-
if (smh->video_timer.timer_interface) {
switch_core_timer_destroy(&smh->video_timer);
}
}
-
+
session->media_handle->engines[SWITCH_MEDIA_TYPE_VIDEO].read_frame.buflen = SWITCH_RTP_MAX_BUF_LEN;
session->media_handle->engines[SWITCH_MEDIA_TYPE_VIDEO].type = SWITCH_MEDIA_TYPE_VIDEO;
session->media_handle->engines[SWITCH_MEDIA_TYPE_VIDEO].crypto_type = CRYPTO_INVALID;
-
+
switch_channel_set_variable(session->channel, "video_media_flow", "sendrecv");
switch_channel_set_variable(session->channel, "audio_media_flow", "sendrecv");
}
session->media_handle->mparams = params;
-
+
if (!session->media_handle->mparams->video_key_freq) {
session->media_handle->mparams->video_key_freq = 10000000;
}
switch_mutex_init(&session->media_handle->sdp_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
switch_mutex_init(&session->media_handle->control_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
- session->media_handle->engines[SWITCH_MEDIA_TYPE_AUDIO].ssrc =
+ session->media_handle->engines[SWITCH_MEDIA_TYPE_AUDIO].ssrc =
(uint32_t) ((intptr_t) &session->media_handle->engines[SWITCH_MEDIA_TYPE_AUDIO] + (uint32_t) time(NULL));
- session->media_handle->engines[SWITCH_MEDIA_TYPE_VIDEO].ssrc =
+ session->media_handle->engines[SWITCH_MEDIA_TYPE_VIDEO].ssrc =
(uint32_t) ((intptr_t) &session->media_handle->engines[SWITCH_MEDIA_TYPE_VIDEO] + (uint32_t) time(NULL) / 2);
- session->media_handle->engines[SWITCH_MEDIA_TYPE_TEXT].ssrc =
+ session->media_handle->engines[SWITCH_MEDIA_TYPE_TEXT].ssrc =
(uint32_t) ((intptr_t) &session->media_handle->engines[SWITCH_MEDIA_TYPE_TEXT] + (uint32_t) time(NULL) / 2);
switch_assert(smh);
smh->media_flags[flag] = 1;
-
+
}
SWITCH_DECLARE(void) switch_media_handle_set_media_flags(switch_media_handle_t *smh, switch_core_media_flag_t flags[SCMF_MAX])
smh->media_flags[i] = flags[i];
}
}
-
+
}
SWITCH_DECLARE(void) switch_media_handle_clear_media_flag(switch_media_handle_t *smh, switch_core_media_flag_t flag)
if (!smh->media_flags[SCMF_RUNNING]) {
goto end;
}
-
+
engine = &smh->engines[type];
flow = engine->smode;
if (!session->media_handle) {
return SWITCH_STATUS_FALSE;
}
-
+
return SWITCH_STATUS_SUCCESS;
}
const char *ocodec = NULL, *val;
switch_media_handle_t *smh;
char *tmp_codec_string;
-
+
switch_assert(session);
if (!(smh = session->media_handle)) {
codec_string = ocodec;
goto ready;
}
-
+
if (!(codec_string = switch_channel_get_variable(session->channel, "codec_string"))) {
codec_string = switch_core_media_get_codec_string(smh->session);
}
if (!codec_string) {
codec_string = "PCMU@20i,PCMA@20i,speex@20i";
}
-
+
tmp_codec_string = switch_core_session_strdup(smh->session, codec_string);
switch_channel_set_variable(session->channel, "rtp_use_codec_string", codec_string);
smh->codec_order_last = switch_separate_string(tmp_codec_string, ',', smh->codec_order, SWITCH_MAX_CODECS);
switch_channel_set_variable(session->channel, "jitterbuffer_msec", input);
}
-
+
if (v_engine->rtp_session) {
if (!strncasecmp(input, "vbsize:", 7)) {
int frames = 0, max_frames = 0;
s = input + 7;
-
+
frames = atoi(s);
if ((s = strchr(s, ':')) && *(s+1) != '\0') {
max_frames = atoi(s+1);
}
-
+
if (frames > 0) {
switch_rtp_set_video_buffer_size(v_engine->rtp_session, frames, max_frames);
}
return;
} else if (!strncasecmp(input, "vdebug:", 7)) {
s = input + 7;
-
+
if (s && !strcmp(s, "off")) {
s = NULL;
}
if (!strncasecmp(input, "tbsize:", 7)) {
int frames = 0, max_frames = 0;
s = input + 7;
-
+
frames = atoi(s);
if ((s = strchr(s, ':')) && *(s+1) != '\0') {
max_frames = atoi(s+1);
}
-
+
if (frames > 0) {
switch_rtp_set_video_buffer_size(t_engine->rtp_session, frames, max_frames);
}
return;
} else if (!strncasecmp(input, "tdebug:", 7)) {
s = input + 7;
-
+
if (s && !strcmp(s, "off")) {
s = NULL;
}
}
}
}
-
+
if (jb_msec || (val = switch_channel_get_variable(session->channel, "jitterbuffer_msec")) || (val = smh->mparams->jb_msec)) {
char *p;
if (strchr(val, 'p') && jb_msec > 0) {
jb_msec *= -1;
}
-
+
if ((p = strchr(val, ':'))) {
p++;
maxlen = atoi(p);
"Invalid Jitterbuffer spec [%d] must be between 10 and 10000\n", jb_msec);
} else {
int qlen, maxqlen = 50;
-
+
qlen = jb_msec / (a_engine->read_impl.microseconds_per_packet / 1000);
if (maxlen) {
maxqlen = qlen * 5;
}
if (switch_rtp_activate_jitter_buffer(a_engine->rtp_session, qlen, maxqlen,
- a_engine->read_impl.samples_per_packet,
+ a_engine->read_impl.samples_per_packet,
a_engine->read_impl.samples_per_second) == SWITCH_STATUS_SUCCESS) {
if (!silent) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session),
- SWITCH_LOG_DEBUG, "Setting Jitterbuffer to %dms (%d frames) (%d max frames)\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session),
+ SWITCH_LOG_DEBUG, "Setting Jitterbuffer to %dms (%d frames) (%d max frames)\n",
jb_msec, qlen, maxqlen);
}
switch_channel_set_flag(session->channel, CF_JITTERBUFFER);
switch_channel_set_flag(session->channel, CF_JITTERBUFFER_PLC);
}
} else if (!silent) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session),
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session),
SWITCH_LOG_WARNING, "Error Setting Jitterbuffer to %dms (%d frames)\n", jb_msec, qlen);
}
-
+
}
}
}
v_engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO];
-
+
if ((var = switch_channel_get_variable_dup(session->channel, "jb_av_sync_msec", SWITCH_FALSE, -1))) {
int tmp;
char *p;
-
+
if (!strcasecmp(var, "disabled")) {
return;
}
frames = atoi(p);
}
}
-
+
switch_rtp_get_video_buffer_size(v_engine->rtp_session, &min_frames, &max_frames, &cur_frames, NULL);
fps = video_globals.fps;
sync_audio = 1;
}
}
-
+
if (!jb_sync_msec) {
jb_sync_msec = (double)(1000 / fps) * frames;
}
-
+
if (frames != cur_frames && frames > min_frames) {
switch_rtp_set_video_buffer_size(v_engine->rtp_session, frames, 0);
sync_audio = 1;
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session),
- SWITCH_LOG_DEBUG1, "%s %s \"%s\" Sync A/V JB to %dms %u VFrames FPS %u a:%s v:%s sync_ms:%d\n",
+ SWITCH_LOG_DEBUG1, "%s %s \"%s\" Sync A/V JB to %dms %u VFrames FPS %u a:%s v:%s sync_ms:%d\n",
switch_core_session_get_uuid(session),
switch_channel_get_name(session->channel),
switch_channel_get_variable_dup(session->channel, "caller_id_name", SWITCH_FALSE, -1),
jb_sync_msec, frames, video_globals.fps, sync_audio ? "yes" : "no", sync_video ? "yes" : "no", jb_sync_msec);
-
+
if (sync_audio) {
check_jb(session, NULL, jb_sync_msec, 0, SWITCH_TRUE);
}
if (lock) {
if (smh->read_mutex[type] && switch_mutex_trylock(smh->read_mutex[type]) != SWITCH_STATUS_SUCCESS) {
/* return CNG, another thread is already reading */
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG1, "%s is already being read for %s\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG1, "%s is already being read for %s\n",
switch_channel_get_name(session->channel), type2str(type));
return SWITCH_STATUS_INUSE;
}
int x;
*tfP = switch_core_alloc(pool, sizeof(**tfP));
-
+
switch_buffer_create_dynamic(&(*tfP)->write_buffer, 512, 1024, 0);
(*tfP)->pool = pool;
(*tfP)->text_write_frame_data = switch_core_alloc(pool, SWITCH_RTP_MAX_BUF_LEN);
*new_datalen = datalen;
*(buf + datalen) = '\0';
-
+
while (*buf & 0x80) {
if (buf + 3 > e) {
*new_datalen = 0;
return 0;
}
-
+
pt[count] = *buf & 0x7F;
len[count] = (ntohs(*(uint16_t *)(buf + 2)) & 0x03ff);
buf += 4;
*new_payload = pt[idx];
memcpy(new_data, buf, len[idx]);
-
+
*(((char *)new_data) + len[idx]) = '\0';
return 1;
-
+
}
static void *get_rtt_payload(void *data, switch_size_t datalen, switch_payload_t *new_payload, uint32_t *new_datalen, int *red_level)
*new_datalen = 0;
return NULL;
}
-
+
return buf;
}
if (smh->read_mutex[type] && switch_mutex_trylock(smh->read_mutex[type]) != SWITCH_STATUS_SUCCESS) {
/* return CNG, another thread is already reading */
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG1, "%s is already being read for %s\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG1, "%s is already being read for %s\n",
switch_channel_get_name(session->channel), type2str(type));
return SWITCH_STATUS_INUSE;
}
engine->read_frame.m = SWITCH_FALSE;
engine->read_frame.img = NULL;
engine->read_frame.payload = 0;
-
+
while (smh->media_flags[SCMF_RUNNING] && engine->read_frame.datalen == 0) {
engine->read_frame.flags = SFF_NONE;
status = switch_rtp_zerocopy_read_frame(engine->rtp_session, &engine->read_frame, flags);
switch_channel_execute_on(session->channel, "execute_on_media_timeout");
switch_goto_status(SWITCH_STATUS_SUCCESS, end);
}
-
+
switch_channel_hangup(session->channel, SWITCH_CAUSE_MEDIA_TIMEOUT);
}
status = SWITCH_STATUS_INUSE;
goto end;
}
-
+
if (status == SWITCH_STATUS_BREAK) {
goto end;
}
smh->vid_started = switch_epoch_time_now(NULL);
}
smh->vid_frames++;
-
+
if ((smh->vid_frames % 5) == 0) {
switch_core_media_get_video_fps(session);
}
-
+
if (video_globals.fps && (!video_globals.synced || ((smh->vid_frames % 300) == 0))) {
check_jb_sync(session);
}
int rtp_hold_timeout_sec = 0;
engine->reset_codec = 0;
-
+
if (switch_rtp_ready(engine->rtp_session)) {
if (type == SWITCH_MEDIA_TYPE_VIDEO) {
switch_core_media_set_video_codec(session, 1);
switch_goto_status(SWITCH_STATUS_GENERR, end);
}
}
-
+
if (type == SWITCH_MEDIA_TYPE_AUDIO && engine->read_impl.samples_per_second) {
if ((val = switch_channel_get_variable(session->channel, "rtp_timeout_sec"))) {
int v = atoi(val);
rtp_timeout_sec = v;
}
}
-
+
if ((val = switch_channel_get_variable(session->channel, "rtp_hold_timeout_sec"))) {
int v = atoi(val);
if (v >= 0) {
memset((*frame)->data, 0, (*frame)->datalen);
switch_goto_status(SWITCH_STATUS_SUCCESS, end);
}
-
+
/* Try to read an RTCP frame, if successful raise an event */
if (switch_rtcp_zerocopy_read_frame(engine->rtp_session, &rtcp_frame) == SWITCH_STATUS_SUCCESS) {
switch_rtp_dequeue_dtmf(engine->rtp_session, &dtmf);
switch_channel_queue_dtmf(session->channel, &dtmf);
}
-
+
if (type != SWITCH_MEDIA_TYPE_TEXT && engine->read_frame.datalen > 0) {
uint32_t bytes = 0;
int frames = 1;
*frame = NULL;
switch_goto_status(SWITCH_STATUS_GENERR, end);
}
-
+
/* check for timing issues */
if (smh->media_flags[SCMF_AUTOFIX_TIMING]) {
char is_vbr;
engine->check_frames++;
/* CBR */
- if ((smh->media_flags[SCMF_AUTOFIX_TIMING] && (engine->read_frame.datalen % 10) == 0)
+ if ((smh->media_flags[SCMF_AUTOFIX_TIMING] && (engine->read_frame.datalen % 10) == 0)
&& (engine->check_frames < MAX_CODEC_CHECK_FRAMES) && !is_vbr) {
engine->check_frames++;
-
+
if (engine->last_ts && engine->read_frame.datalen != engine->read_impl.encoded_bytes_per_packet) {
uint32_t codec_ms = (int) (engine->read_frame.timestamp -
engine->last_ts = engine->read_frame.timestamp;
engine->last_seq = engine->read_frame.seq;
- } else if (smh->media_flags[SCMF_AUTOFIX_TIMING] && is_vbr && switch_rtp_get_jitter_buffer(engine->rtp_session)
+ } else if (smh->media_flags[SCMF_AUTOFIX_TIMING] && is_vbr && switch_rtp_get_jitter_buffer(engine->rtp_session)
&& engine->read_frame.timestamp && engine->read_frame.seq && engine->read_impl.samples_per_second) {
uint32_t codec_ms = (int) (engine->read_frame.timestamp -
engine->last_ts) / (engine->read_impl.samples_per_second / 1000);
(!smh->mparams->te || engine->read_frame.payload != smh->mparams->te) &&
engine->read_frame.payload != engine->cur_payload_map->recv_pt &&
engine->read_frame.payload != engine->cur_payload_map->pt) {
-
+
payload_map_t *pmap;
-
+
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
"alternate payload received (received %d, expecting %d)\n",
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
"Changing current codec to %s (payload type %d).\n",
pmap->iananame, pmap->pt);
-
+
/* mark to re-set codec */
engine->reset_codec = 1;
break;
}
}
switch_mutex_unlock(smh->sdp_mutex);
-
+
if (!engine->reset_codec) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
"Could not change to payload type %d, ignoring...\n",
if (type == SWITCH_MEDIA_TYPE_TEXT && !switch_test_flag((&engine->read_frame), SFF_CNG)) {
if (engine->red_pt) {
unsigned char *p = engine->read_frame.data;
-
+
*(p + engine->read_frame.datalen) = '\0';
engine->tf->text_frame = engine->read_frame;
-
+
if (switch_test_flag((&engine->read_frame), SFF_PLC)) {
switch_jb_t *jb = switch_core_session_get_jb(session, SWITCH_MEDIA_TYPE_TEXT);
int i = 0;
-
+
engine->tf->text_frame.datalen = 0;
for (i = 1; i < 3; i++) {
if (switch_jb_peek_frame(jb, 0, engine->read_frame.seq, i, &frame) == SWITCH_STATUS_SUCCESS) {
if (get_rtt_red_seq(engine->read_frame.seq,
- frame.data,
- frame.datalen,
+ frame.data,
+ frame.datalen,
frame.seq,
&engine->tf->text_frame.payload,
engine->tf->text_frame.data,
&engine->tf->text_frame.datalen)) {
break;
-
+
}
}
}
} else {
- if (!(engine->tf->text_frame.data = get_rtt_payload(engine->read_frame.data,
- engine->tf->text_frame.datalen,
+ if (!(engine->tf->text_frame.data = get_rtt_payload(engine->read_frame.data,
+ engine->tf->text_frame.datalen,
&engine->tf->text_frame.payload,
&engine->tf->text_frame.datalen,
&engine->tf->red_level))) {
}
//?
-SWITCH_DECLARE(switch_status_t) switch_core_media_write_frame(switch_core_session_t *session,
+SWITCH_DECLARE(switch_status_t) switch_core_media_write_frame(switch_core_session_t *session,
switch_frame_t *frame, switch_io_flag_t flags, int stream_id, switch_media_type_t type)
{
switch_status_t status = SWITCH_STATUS_SUCCESS;
if (switch_channel_test_flag(session->channel, CF_VIDEO_ONLY) && type == SWITCH_MEDIA_TYPE_AUDIO) {
return SWITCH_STATUS_SUCCESS;
- }
+ }
if (type != SWITCH_MEDIA_TYPE_TEXT) {
switch_t38_options_t *local_t38_options = switch_channel_get_private(channel, "t38_options");
switch_assert(t38_options);
-
+
if (!local_t38_options) {
local_t38_options = switch_core_session_alloc(session, sizeof(switch_t38_options_t));
}
//#define get_int_value(_var, _set) { const char *__v = switch_channel_get_variable(session->channel, _var); if (__v) { _set = atol(__v);} }
//?
-static void switch_core_session_parse_codec_settings(switch_core_session_t *session, switch_media_type_t type)
+static void switch_core_session_parse_codec_settings(switch_core_session_t *session, switch_media_type_t type)
{
switch_media_handle_t *smh;
switch_rtp_engine_t *engine;
}
if (!(engine = &smh->engines[type])) return;
-
+
switch(type) {
case SWITCH_MEDIA_TYPE_AUDIO:
break;
if (!(bwv = switch_channel_get_variable(session->channel, "rtp_video_max_bandwidth"))) {
bwv = switch_channel_get_variable(session->channel, "rtp_video_max_bandwidth_out");
}
-
+
if (!bwv) {
bwv = "1mb";
}
-
+
system_bw = switch_parse_bandwidth_string(bwv);
if (engine->sdp_bw && engine->sdp_bw <= system_bw) {
} else {
v_engine->read_frame.rate = v_engine->cur_payload_map->rm_rate;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Set VIDEO Codec %s %s/%ld %d ms\n",
- switch_channel_get_name(session->channel), v_engine->cur_payload_map->rm_encoding,
+ switch_channel_get_name(session->channel), v_engine->cur_payload_map->rm_encoding,
v_engine->cur_payload_map->rm_rate, v_engine->cur_payload_map->codec_ms);
v_engine->read_frame.codec = &v_engine->read_codec;
switch_core_session_set_video_write_codec(session, &v_engine->write_codec);
- switch_channel_set_variable_printf(session->channel, "rtp_last_video_codec_string", "%s@%dh",
+ switch_channel_set_variable_printf(session->channel, "rtp_last_video_codec_string", "%s@%dh",
v_engine->cur_payload_map->rm_encoding, v_engine->cur_payload_map->rm_rate);
msg.message_id = SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ;
switch_rtp_set_default_payload(v_engine->rtp_session, v_engine->cur_payload_map->pt);
-
+
//XX
switch_core_session_receive_message(session, &msg);
}
-
+
switch_channel_set_variable(session->channel, "rtp_use_video_codec_name", v_engine->cur_payload_map->rm_encoding);
switch_channel_set_variable(session->channel, "rtp_use_video_codec_fmtp", v_engine->cur_payload_map->rm_fmtp);
switch_channel_set_variable_printf(session->channel, "rtp_use_video_codec_rate", "%d", v_engine->cur_payload_map->rm_rate);
if (strcasecmp(a_engine->read_impl.iananame, a_engine->cur_payload_map->iananame) ||
(uint32_t) a_engine->read_impl.microseconds_per_packet / 1000 != a_engine->cur_payload_map->codec_ms ||
a_engine->read_impl.samples_per_second != a_engine->cur_payload_map->rm_rate ) {
-
+
if (session->read_resampler) {
switch_mutex_lock(session->resample_mutex);
switch_resample_destroy(&session->read_resampler);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Deactivating read resampler\n");
switch_mutex_unlock(session->resample_mutex);
}
-
+
if (session->write_resampler) {
switch_mutex_lock(session->resample_mutex);
switch_resample_destroy(&session->write_resampler);
switch_core_session_reset(session, 0, 0);
switch_channel_audio_sync(session->channel);
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
"Changing Codec from %s@%dms@%dhz to %s@%dms@%luhz\n",
- a_engine->read_impl.iananame,
+ a_engine->read_impl.iananame,
a_engine->read_impl.microseconds_per_packet / 1000,
a_engine->read_impl.actual_samples_per_second,
- a_engine->cur_payload_map->iananame,
+ a_engine->cur_payload_map->iananame,
a_engine->cur_payload_map->codec_ms,
a_engine->cur_payload_map->rm_rate);
-
+
switch_yield(a_engine->read_impl.microseconds_per_packet);
switch_core_session_lock_codec_write(session);
switch_core_session_lock_codec_read(session);
switch_channel_hangup(session->channel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION);
switch_goto_status(SWITCH_STATUS_FALSE, end);
}
-
+
a_engine->read_codec.session = session;
switch_channel_set_variable_printf(session->channel, "rtp_use_codec_rate", "%d", a_engine->cur_payload_map->rm_rate);
switch_channel_set_variable_printf(session->channel, "rtp_use_codec_ptime", "%d", a_engine->cur_payload_map->codec_ms);
switch_channel_set_variable_printf(session->channel, "rtp_use_codec_channels", "%d", a_engine->cur_payload_map->channels);
- switch_channel_set_variable_printf(session->channel, "rtp_last_audio_codec_string", "%s@%dh@%di@%dc",
+ switch_channel_set_variable_printf(session->channel, "rtp_last_audio_codec_string", "%s@%dh@%di@%dc",
a_engine->cur_payload_map->iananame, a_engine->cur_payload_map->rm_rate, a_engine->cur_payload_map->codec_ms, a_engine->cur_payload_map->channels);
switch_assert(a_engine->read_codec.implementation);
if (switch_rtp_ready(a_engine->rtp_session)) {
switch_assert(a_engine->read_codec.implementation);
-
+
if (switch_rtp_change_interval(a_engine->rtp_session,
- a_engine->read_impl.microseconds_per_packet,
+ a_engine->read_impl.microseconds_per_packet,
a_engine->read_impl.samples_per_packet) != SWITCH_STATUS_SUCCESS) {
switch_channel_hangup(session->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
switch_goto_status(SWITCH_STATUS_FALSE, end);
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Set Codec %s %s/%ld %d ms %d samples %d bits %d channels\n",
- switch_channel_get_name(session->channel), a_engine->cur_payload_map->iananame, a_engine->cur_payload_map->rm_rate,
+ switch_channel_get_name(session->channel), a_engine->cur_payload_map->iananame, a_engine->cur_payload_map->rm_rate,
a_engine->cur_payload_map->codec_ms,
a_engine->read_impl.samples_per_packet, a_engine->read_impl.bits_per_second, a_engine->read_impl.number_of_channels);
a_engine->read_frame.codec = &a_engine->read_codec;
return status;
}
-static void clear_ice(switch_core_session_t *session, switch_media_type_t type)
+static void clear_ice(switch_core_session_t *session, switch_media_type_t type)
{
switch_media_handle_t *smh;
switch_rtp_engine_t *engine;
if (a_engine->rtp_session) {
switch_rtp_set_flag(a_engine->rtp_session, SWITCH_RTP_FLAG_PAUSE);
}
-
+
if (v_engine->rtp_session) {
switch_rtp_set_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_PAUSE);
}
if (a_engine->rtp_session) {
switch_rtp_clear_flag(a_engine->rtp_session, SWITCH_RTP_FLAG_PAUSE);
}
-
+
if (v_engine->rtp_session) {
switch_rtp_clear_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_PAUSE);
}
int i;
smh->video_count = 0;
for (i = 0; i < smh->mparams->num_codecs; i++) {
-
+
if (smh->codecs[i]->codec_type == SWITCH_CODEC_TYPE_VIDEO) {
if (switch_channel_direction(session->channel) == SWITCH_CALL_DIRECTION_INBOUND &&
switch_channel_test_flag(session->channel, CF_NOVIDEO)) {
if (strchr(ip, ':')) {
if (!zstr(smh->mparams->rtpip6)) {
smh->mparams->rtpip = smh->mparams->rtpip6;
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_DEBUG, "%s choosing family v6\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_DEBUG, "%s choosing family v6\n",
switch_channel_get_name(smh->session->channel));
status = SWITCH_STATUS_SUCCESS;
}
} else {
if (!zstr(smh->mparams->rtpip4)) {
smh->mparams->rtpip = smh->mparams->rtpip4;
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_DEBUG, "%s choosing family v4\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_DEBUG, "%s choosing family v4\n",
switch_channel_get_name(smh->session->channel));
status = SWITCH_STATUS_SUCCESS;
}
if (zstr(attr->a_name)) {
continue;
}
-
+
if (!strcasecmp(attr->a_name, "ice-ufrag")) {
if (engine->ice_in.ufrag && !strcmp(engine->ice_in.ufrag, attr->a_value)) {
engine->new_ice = 0;
char *p;
engine->remote_dtls_fingerprint.type = switch_core_session_strdup(smh->session, attr->a_value);
-
+
if ((p = strchr(engine->remote_dtls_fingerprint.type, ' '))) {
*p++ = '\0';
engine->new_ice = 1;
}
}
-
+
//if (strcasecmp(engine->remote_dtls_fingerprint.type, "sha-256")) {
// switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_WARNING, "Unsupported fingerprint type.\n");
generate_local_fingerprint(smh, type);
switch_channel_set_flag(smh->session->channel, CF_DTLS);
-
+
} else if (!engine->remote_ssrc && !strcasecmp(attr->a_name, "ssrc") && attr->a_value) {
engine->remote_ssrc = (uint32_t) atol(attr->a_value);
if (engine->rtp_session && engine->remote_ssrc) {
switch_rtp_set_remote_ssrc(engine->rtp_session, engine->remote_ssrc);
}
-
+
#ifdef RTCP_MUX
} else if (!strcasecmp(attr->a_name, "rtcp-mux")) {
if (!smh->mparams->rtcp_audio_interval_msec) {
smh->mparams->rtcp_audio_interval_msec = SWITCH_RTCP_AUDIO_INTERVAL_MSEC;
- }
+ }
#endif
} else if (!strcasecmp(attr->a_name, "candidate")) {
switch_channel_set_flag(smh->session->channel, CF_ICE);
}
data = switch_core_session_strdup(smh->session, attr->a_value);
-
+
argc = switch_split(data, ' ', fields);
-
+
cid = fields[1] ? atoi(fields[1]) - 1 : 0;
if (argc < 5 || engine->ice_in.cand_idx[cid] >= MAX_CAND - 1) {
}
if (!ip_possible(smh, fields[4])) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_DEBUG,
- "Drop %s Candidate cid: %d proto: %s type: %s addr: %s:%s (no network path)\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_DEBUG,
+ "Drop %s Candidate cid: %d proto: %s type: %s addr: %s:%s (no network path)\n",
type == SWITCH_MEDIA_TYPE_VIDEO ? "video" : "audio",
cid+1, fields[2], fields[7], fields[4], fields[5]);
continue;
} else {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_DEBUG,
- "Save %s Candidate cid: %d proto: %s type: %s addr: %s:%s\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_DEBUG,
+ "Save %s Candidate cid: %d proto: %s type: %s addr: %s:%s\n",
type == SWITCH_MEDIA_TYPE_VIDEO ? "video" : "audio",
cid+1, fields[2], fields[7], fields[4], fields[5]);
}
-
-
+
+
engine->ice_in.cands[engine->ice_in.cand_idx[cid]][cid].foundation = switch_core_session_strdup(smh->session, fields[0]);
engine->ice_in.cands[engine->ice_in.cand_idx[cid]][cid].component_id = atoi(fields[1]);
engine->ice_in.cands[engine->ice_in.cand_idx[cid]][cid].transport = switch_core_session_strdup(smh->session, fields[2]);
engine->ice_in.cands[engine->ice_in.cand_idx[cid]][cid].priority = atol(fields[3]);
engine->ice_in.cands[engine->ice_in.cand_idx[cid]][cid].con_addr = switch_core_session_strdup(smh->session, fields[4]);
engine->ice_in.cands[engine->ice_in.cand_idx[cid]][cid].con_port = (switch_port_t)atoi(fields[5]);
-
+
j = 6;
while(j < argc && fields[j+1]) {
if (!strcasecmp(fields[j], "typ")) {
- engine->ice_in.cands[engine->ice_in.cand_idx[cid]][cid].cand_type = switch_core_session_strdup(smh->session, fields[j+1]);
+ engine->ice_in.cands[engine->ice_in.cand_idx[cid]][cid].cand_type = switch_core_session_strdup(smh->session, fields[j+1]);
} else if (!strcasecmp(fields[j], "raddr")) {
engine->ice_in.cands[engine->ice_in.cand_idx[cid]][cid].raddr = switch_core_session_strdup(smh->session, fields[j+1]);
} else if (!strcasecmp(fields[j], "rport")) {
} else if (!strcasecmp(fields[j], "generation")) {
engine->ice_in.cands[engine->ice_in.cand_idx[cid]][cid].generation = switch_core_session_strdup(smh->session, fields[j+1]);
}
-
+
j += 2;
}
for (ai = 0; ai < engine->cand_acl_count; ai++) {
for (i = 0; i < engine->ice_in.cand_idx[cid]; i++) {
if (switch_check_network_list_ip(engine->ice_in.cands[i][cid].con_addr, engine->cand_acl[ai])) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_DEBUG,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_DEBUG,
"Choose %s candidate, index %d, %s:%d\n", cid ? "rtcp" : "rtp", i,
engine->ice_in.cands[i][cid].con_addr, engine->ice_in.cands[i][cid].con_port);
engine->ice_in.is_chosen[cid] = 1;
engine->ice_in.cands[i][cid].ready++;
ip_choose_family(smh, engine->ice_in.cands[i][cid].con_addr);
-
+
if (cid == 0 && got_rtcp_mux && engine->ice_in.cand_idx[1] < MAX_CAND) {
-
+
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_DEBUG,
"Choose same candidate, index %d, for rtcp based on rtcp-mux attribute %s:%d\n", engine->ice_in.cand_idx[1],
engine->ice_in.cands[i][cid].con_addr, engine->ice_in.cands[i][cid].con_port);
engine->ice_in.chosen[1] = engine->ice_in.cand_idx[1];
engine->ice_in.is_chosen[1] = 1;
engine->ice_in.cand_idx[1]++;
-
+
goto done_choosing;
}
-
+
goto next_cid;
}
}
if (!engine->ice_in.is_chosen[0]) {
/* PUNT */
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_DEBUG, "%s no suitable candidates found.\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_DEBUG, "%s no suitable candidates found.\n",
switch_channel_get_name(smh->session->channel));
return SWITCH_STATUS_FALSE;
}
if (engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_addr && engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_port) {
char tmp[80] = "";
engine->cur_payload_map->remote_sdp_ip = switch_core_session_strdup(smh->session, (char *) engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_addr);
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_DEBUG,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_DEBUG,
"setting remote %s ice addr to index %d %s:%d based on candidate\n", type2str(type), engine->ice_in.chosen[0],
engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_addr, engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_port);
engine->ice_in.cands[engine->ice_in.chosen[0]][0].ready++;
engine->cur_payload_map->remote_sdp_ip = switch_core_session_strdup(smh->session, (char *) engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_addr);
engine->cur_payload_map->remote_sdp_port = (switch_port_t) engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_port;
-
+
if (!smh->mparams->remote_ip) {
smh->mparams->remote_ip = engine->cur_payload_map->remote_sdp_ip;
}
-
+
switch_snprintf(tmp, sizeof(tmp), "%d", engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_port);
switch_channel_set_variable(smh->session->channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE, engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_addr);
- switch_channel_set_variable(smh->session->channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE, tmp);
+ switch_channel_set_variable(smh->session->channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE, tmp);
}
if (engine->ice_in.cands[engine->ice_in.chosen[1]][1].con_port) {
engine->ice_in.cands[engine->ice_in.chosen[1]][1].con_addr, engine->ice_in.cands[engine->ice_in.chosen[1]][1].con_port);
engine->remote_rtcp_ice_port = engine->ice_in.cands[engine->ice_in.chosen[1]][1].con_port;
engine->remote_rtcp_ice_addr = switch_core_session_strdup(smh->session, engine->ice_in.cands[engine->ice_in.chosen[1]][1].con_addr);
-
+
engine->remote_rtcp_port = engine->ice_in.cands[engine->ice_in.chosen[1]][1].con_port;
}
if (switch_rtp_ready(engine->rtp_session) && engine->ice_in.cands[engine->ice_in.chosen[0]][0].ready && engine->new_ice) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_INFO, "RE-Activating %s ICE\n", type2str(type));
- switch_rtp_activate_ice(engine->rtp_session,
+ switch_rtp_activate_ice(engine->rtp_session,
engine->ice_in.ufrag,
engine->ice_out.ufrag,
engine->ice_out.pwd,
ICE_GOOGLE_JINGLE,
NULL
#else
- switch_ice_direction(smh->session) ==
+ switch_ice_direction(smh->session) ==
SWITCH_CALL_DIRECTION_OUTBOUND ? ICE_VANILLA : (ICE_VANILLA | ICE_CONTROLLED),
&engine->ice_in
#endif
);
-
+
engine->new_ice = 0;
}
-
+
if (engine->rtp_session && ((val = switch_channel_get_variable(smh->session->channel,
- type == SWITCH_MEDIA_TYPE_VIDEO ?
- "rtcp_video_interval_msec" : "rtcp_audio_interval_msec"))
- || (val = type == SWITCH_MEDIA_TYPE_VIDEO ?
+ type == SWITCH_MEDIA_TYPE_VIDEO ?
+ "rtcp_video_interval_msec" : "rtcp_audio_interval_msec"))
+ || (val = type == SWITCH_MEDIA_TYPE_VIDEO ?
smh->mparams->rtcp_video_interval_msec : smh->mparams->rtcp_audio_interval_msec))) {
-
+
switch_port_t remote_rtcp_port = engine->remote_rtcp_port;
if (remote_rtcp_port) {
if (!strcasecmp(val, "passthru")) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_INFO, "Activating %s RTCP PASSTHRU PORT %d\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_INFO, "Activating %s RTCP PASSTHRU PORT %d\n",
type2str(type), remote_rtcp_port);
switch_rtp_activate_rtcp(engine->rtp_session, -1, remote_rtcp_port, engine->rtcp_mux > 0);
} else {
}
}
}
-
+
if (engine->rtp_session && engine->ice_in.cands[engine->ice_in.chosen[1]][1].ready) {
if (engine->rtcp_mux > 0 && !strcmp(engine->ice_in.cands[engine->ice_in.chosen[1]][1].con_addr, engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_addr)
&& engine->ice_in.cands[engine->ice_in.chosen[1]][1].con_port == engine->ice_in.cands[engine->ice_in.chosen[0]][0].con_port) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_INFO, "Skipping %s RTCP ICE (Same as RTP)\n", type2str(type));
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_INFO, "Activating %s RTCP ICE\n", type2str(type));
-
- switch_rtp_activate_ice(engine->rtp_session,
+
+ switch_rtp_activate_ice(engine->rtp_session,
engine->ice_in.ufrag,
engine->ice_out.ufrag,
engine->ice_out.pwd,
ICE_GOOGLE_JINGLE,
NULL
#else
- switch_ice_direction(smh->session) ==
+ switch_ice_direction(smh->session) ==
SWITCH_CALL_DIRECTION_OUTBOUND ? ICE_VANILLA : (ICE_VANILLA | ICE_CONTROLLED),
&engine->ice_in
#endif
);
}
-
+
}
-
+
}
return ice_seen ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_BREAK;
}
for (g = 0; g < smh->mparams->num_codecs && g < total_codecs; g++) {
const switch_codec_implementation_t *imp = codec_array[g];
-
+
for(j = 0; j < m_idx; j++) {
if (mtmp[j].imp == imp) {
*&matches[f++] = *&mtmp[j];
{
payload_map_t *pmap;
int top = 0;
-
+
for (pmap = engine->payload_map; pmap && pmap->allocated; pmap = pmap->next) {
pmap->negotiated = 1;
if (!top++) pmap->current = 1;
a_engine->reject_avp = 0;
switch_media_handle_set_media_flag(smh, SCMF_RECV_SDP);
-
+
switch_core_session_parse_crypto_prefs(session);
clear_pmaps(a_engine);
scrooge = 1;
greedy = 1;
} else {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "rtp_codec_negotiation ignored invalid value : '%s' \n", val );
- }
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "rtp_codec_negotiation ignored invalid value : '%s' \n", val );
+ }
}
if ((smh->origin = switch_core_session_strdup(session, (char *) sdp->sdp_origin->o_username))) {
switch_channel_set_flag(session->channel, CF_LIBERAL_DTMF);
}
- if (switch_stristr("T38FaxFillBitRemoval:", r_sdp) || switch_stristr("T38FaxTranscodingMMR:", r_sdp) ||
+ if (switch_stristr("T38FaxFillBitRemoval:", r_sdp) || switch_stristr("T38FaxTranscodingMMR:", r_sdp) ||
switch_stristr("T38FaxTranscodingJBIG:", r_sdp)) {
switch_channel_set_variable(session->channel, "t38_broken_boolean", "true");
}
got_webrtc++;
switch_core_session_set_ice(session);
}
-
+
if (m->m_proto_name && !strcasecmp(m->m_proto_name, "UDP/TLS/RTP/SAVPF")) {
switch_channel_set_flag(session->channel, CF_AVPF_MOZ);
}
restore_pmaps(a_engine);
fmatch = 0;
-
+
goto t38_done;
} else {
switch_t38_options_t *t38_options = switch_core_media_process_udptl(session, sdp, m);
const char *var = switch_channel_get_variable(channel, "t38_passthru");
int pass = switch_channel_test_flag(smh->session->channel, CF_T38_PASSTHRU);
-
+
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s T38 ACCEPT on %s\n",
switch_channel_get_name(channel),
sdp_type == SDP_TYPE_RESPONSE ? "response" : "request");
-
+
if (switch_channel_test_app_flag_key("T38", session->channel, CF_APP_T38)) {
if (proceed) *proceed = 0;
}
}
}
- if ((pass == 2 && switch_channel_test_flag(smh->session->channel, CF_T38_PASSTHRU))
+ if ((pass == 2 && switch_channel_test_flag(smh->session->channel, CF_T38_PASSTHRU))
|| !switch_channel_test_flag(session->channel, CF_REINVITE) ||
-
- switch_channel_test_flag(session->channel, CF_PROXY_MODE) ||
- switch_channel_test_flag(session->channel, CF_PROXY_MEDIA) ||
+
+ switch_channel_test_flag(session->channel, CF_PROXY_MODE) ||
+ switch_channel_test_flag(session->channel, CF_PROXY_MEDIA) ||
!switch_rtp_ready(a_engine->rtp_session)) {
pass = 0;
}
-
+
if (pass && switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) {
switch_channel_t *other_channel = switch_core_session_get_channel(other_session);
switch_core_session_message_t *msg;
switch_channel_set_app_flag_key("T38", channel, CF_APP_T38_POSSIBLE);
switch_channel_set_app_flag_key("T38", other_channel, CF_APP_T38_POSSIBLE);
-
- if (switch_true(switch_channel_get_variable(session->channel, "t38_broken_boolean")) &&
+
+ if (switch_true(switch_channel_get_variable(session->channel, "t38_broken_boolean")) &&
switch_true(switch_channel_get_variable(session->channel, "t38_pass_broken_boolean"))) {
switch_channel_set_variable(other_channel, "t38_broken_boolean", "true");
}
-
+
a_engine->cur_payload_map->remote_sdp_ip = switch_core_session_strdup(session, t38_options->remote_ip);
a_engine->cur_payload_map->remote_sdp_port = t38_options->remote_port;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Audio params changed for %s from %s:%d to %s:%d\n",
switch_channel_get_name(session->channel),
remote_host, remote_port, a_engine->cur_payload_map->remote_sdp_ip, a_engine->cur_payload_map->remote_sdp_port);
-
+
switch_snprintf(tmp, sizeof(tmp), "%d", a_engine->cur_payload_map->remote_sdp_port);
switch_channel_set_variable(session->channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE, a_engine->cur_payload_map->remote_sdp_ip);
switch_channel_set_variable(session->channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE, tmp);
switch_core_media_check_autoadj(session);
}
-
+
switch_core_media_copy_t38_options(t38_options, other_session);
switch_channel_set_flag(smh->session->channel, CF_T38_PASSTHRU);
switch_channel_set_flag(other_session->channel, CF_T38_PASSTHRU);
-
+
msg = switch_core_session_alloc(other_session, sizeof(*msg));
msg->message_id = SWITCH_MESSAGE_INDICATE_REQUEST_IMAGE_MEDIA;
msg->from = __FILE__;
fmatch ? "IS" : "IS NOT",
sdp_type == SDP_TYPE_RESPONSE ? "response" : "request");
-
+
goto done;
}
} else if (m->m_type == sdp_media_audio && m->m_port && got_audio && got_savp) {
break;
}
}
-
+
for (attr = sdp->sdp_attributes; attr; attr = attr->a_next) {
if (zstr(attr->a_name)) {
continue;
}
-
+
if (!strncasecmp(attr->a_name, "ice", 3)) {
ice++;
} else if (sendonly < 2 && !strcasecmp(attr->a_name, "sendonly")) {
} else if (!strcasecmp(attr->a_name, "recvonly")) {
switch_channel_set_variable(session->channel, "media_audio_mode", "sendonly");
recvonly = 1;
-
+
if (switch_rtp_ready(a_engine->rtp_session)) {
switch_rtp_set_max_missed_packets(a_engine->rtp_session, 0);
a_engine->max_missed_hold_packets = 0;
switch_core_media_prepare_codecs(session, SWITCH_TRUE);
codec_array = smh->codecs;
total_codecs = smh->mparams->num_codecs;
-
+
if (switch_rtp_has_dtls() && dtls_ok(session)) {
for (attr = m->m_attributes; attr; attr = attr->a_next) {
-
+
if (!strcasecmp(attr->a_name, "fingerprint") && !zstr(attr->a_value)) {
got_crypto = 1;
}
skip_rtcp = 1;
if (!smh->mparams->rtcp_video_interval_msec) {
smh->mparams->rtcp_video_interval_msec = SWITCH_RTCP_VIDEO_INTERVAL_MSEC;
- }
+ }
} else if (!strcasecmp(attr->a_name, "ice-ufrag")) {
skip_rtcp = 1;
}
if (!got_rtcp_mux) {
a_engine->rtcp_mux = -1;
}
-
+
for (attr = m->m_attributes; attr; attr = attr->a_next) {
if (!strcasecmp(attr->a_name, "rtcp") && attr->a_value && !skip_rtcp) {
a_engine->remote_rtcp_port = (switch_port_t)atoi(attr->a_value);
maxptime = atoi(attr->a_value);
} else if (got_crypto < 1 && !strcasecmp(attr->a_name, "crypto") && !zstr(attr->a_value)) {
int crypto_tag;
-
- if (!(smh->mparams->ndlb & SM_NDLB_ALLOW_CRYPTO_IN_AVP) &&
+
+ if (!(smh->mparams->ndlb & SM_NDLB_ALLOW_CRYPTO_IN_AVP) &&
!switch_true(switch_channel_get_variable(session->channel, "rtp_allow_crypto_in_avp"))) {
if (m->m_proto != sdp_proto_srtp && !got_webrtc) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "a=crypto in RTP/AVP, refer to rfc3711\n");
crypto = attr->a_value;
crypto_tag = atoi(crypto);
- got_crypto = switch_core_session_check_incoming_crypto(session,
+ got_crypto = switch_core_session_check_incoming_crypto(session,
"rtp_has_crypto", SWITCH_MEDIA_TYPE_AUDIO, crypto, crypto_tag, sdp_type);
}
}
x = 0;
-
+
for (map = m->m_rtpmaps; map; map = map->rm_next) {
int32_t i;
const char *rm_encoding;
if (!(rm_encoding = map->rm_encoding)) {
rm_encoding = "";
}
-
-
+
+
if (!strcasecmp(rm_encoding, "telephone-event")) {
if (!best_te || map->rm_rate == a_engine->cur_payload_map->rm_rate) {
best_te = (switch_payload_t) map->rm_pt;
}
continue;
}
-
+
if (!switch_media_handle_test_media_flag(smh, SCMF_SUPPRESS_CNG) && !cng_pt && !strcasecmp(rm_encoding, "CN")) {
cng_pt = (switch_payload_t) map->rm_pt;
if (a_engine->rtp_session) {
}
continue;
}
-
-
+
+
if (x++ < skip) {
continue;
}
}
map_bit_rate = switch_known_bitrate((switch_payload_t)map->rm_pt);
-
+
if (!ptime && !strcasecmp(map->rm_encoding, "g723")) {
codec_ms = 30;
}
-
+
remote_codec_rate = map->rm_rate;
fmtp_remote_codec_rate = 0;
memset(&codec_fmtp, 0, sizeof(codec_fmtp));
if ((zstr(map->rm_encoding) || (smh->mparams->ndlb & SM_NDLB_ALLOW_BAD_IANANAME)) && map->rm_pt < 96) {
match = (map->rm_pt == imp->ianacode) ? 1 : 0;
} else {
- match = (!strcasecmp(rm_encoding, imp->iananame) &&
+ match = (!strcasecmp(rm_encoding, imp->iananame) &&
((map->rm_pt < 96 && imp->ianacode < 96) || (map->rm_pt > 95 && imp->ianacode > 95)) &&
(remote_codec_rate == codec_rate || fmtp_remote_codec_rate == imp->actual_samples_per_second)) ? 1 : 0;
if (fmtp_remote_codec_rate) {
}
}
- if (match && bit_rate && map_bit_rate && map_bit_rate != bit_rate && strcasecmp(map->rm_encoding, "ilbc") &&
+ if (match && bit_rate && map_bit_rate && map_bit_rate != bit_rate && strcasecmp(map->rm_encoding, "ilbc") &&
strcasecmp(map->rm_encoding, "isac")) {
/* if a bit rate is specified and doesn't match, this is not a codec match, except for ILBC */
match = 0;
}
- if (match && remote_codec_rate && codec_rate && remote_codec_rate != codec_rate && (!strcasecmp(map->rm_encoding, "pcma") ||
+ if (match && remote_codec_rate && codec_rate && remote_codec_rate != codec_rate && (!strcasecmp(map->rm_encoding, "pcma") ||
!strcasecmp(map->rm_encoding, "pcmu"))) {
/* if the sampling rate is specified and doesn't match, this is not a codec match for G.711 */
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "sampling rates have to match for G.711\n");
match = 0;
}
-
+
if (match) {
if (scrooge) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
} else if ((ptime && codec_ms && codec_ms * 1000 != imp->microseconds_per_packet) || remote_codec_rate != codec_rate) {
/* ptime does not match */
match = 0;
-
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
- "Audio Codec Compare [%s:%d:%u:%d:%u:%d] is saved as a near-match\n",
+
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
+ "Audio Codec Compare [%s:%d:%u:%d:%u:%d] is saved as a near-match\n",
imp->iananame, imp->ianacode, codec_rate, imp->microseconds_per_packet / 1000, bit_rate, imp->number_of_channels);
near_matches[nm_idx].codec_idx = i;
matches[m_idx].map = map;
m_idx++;
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
- "Audio Codec Compare [%s:%d:%u:%d:%u:%d] ++++ is saved as a match\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
+ "Audio Codec Compare [%s:%d:%u:%d:%u:%d] ++++ is saved as a match\n",
imp->iananame, imp->ianacode, codec_rate, imp->microseconds_per_packet / 1000, bit_rate, imp->number_of_channels);
-
+
if (m_idx >= MAX_MATCHES) {
break;
}
near_rate = near_matches[j].rate;
near_match = near_matches[j].imp;
- near_map = near_matches[j].map;
-
+ near_map = near_matches[j].map;
+
switch_snprintf(tmp, sizeof(tmp), "%s@%uh@%ui%dc", near_match->iananame, near_rate ? near_rate : near_match->samples_per_second,
codec_ms, near_match->number_of_channels);
-
+
prefs[0] = tmp;
num = switch_loadable_module_get_codecs_sorted(search, fmtp, 1, prefs, 1);
-
+
if (num) {
timp = search[0];
} else {
timp = near_match;
}
-
+
if (!maxptime || timp->microseconds_per_packet / 1000 <= maxptime) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Substituting codec %s@%ui@%uh@%dc\n",
timp->iananame, timp->microseconds_per_packet / 1000, timp->actual_samples_per_second, timp->number_of_channels);
}
}
}
-
+
if (m_idx) {
int j;
a_engine->codec_negotiated = 1;
for(j = 0; j < m_idx; j++) {
- payload_map_t *pmap = switch_core_media_add_payload_map(session,
+ payload_map_t *pmap = switch_core_media_add_payload_map(session,
SWITCH_MEDIA_TYPE_AUDIO,
matches[j].map->rm_encoding,
matches[j].imp->modname,
matches[j].map->rm_fmtp,
- sdp_type,
+ sdp_type,
matches[j].map->rm_pt,
matches[j].imp->samples_per_second,
matches[j].imp->microseconds_per_packet / 1000,
mimp = matches[j].imp;
mmap = matches[j].map;
-
+
if (j == 0) {
a_engine->cur_payload_map = pmap;
a_engine->cur_payload_map->current = 1;
switch_rtp_set_default_payload(a_engine->rtp_session, pmap->pt);
}
}
-
+
pmap->rm_encoding = switch_core_session_strdup(session, (char *) mmap->rm_encoding);
pmap->iananame = switch_core_session_strdup(session, (char *) mimp->iananame);
pmap->recv_pt = (switch_payload_t) mmap->rm_pt;
pmap->codec_ms = mimp->microseconds_per_packet / 1000;
pmap->bitrate = mimp->bits_per_second;
pmap->channels = mmap->rm_params ? atoi(mmap->rm_params) : 1;
-
+
if (!strcasecmp((char *) mmap->rm_encoding, "opus")) {
if (pmap->channels == 1) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Invalid SDP for opus. Don't ask.. but it needs a /2\n");
} else {
pmap->adv_channels = pmap->channels;
}
-
+
pmap->remote_sdp_ip = switch_core_session_strdup(session, (char *) connection->c_address);
pmap->remote_sdp_port = (switch_port_t) m->m_port;
pmap->rm_fmtp = switch_core_session_strdup(session, (char *) mmap->rm_fmtp);
-
+
smh->negotiated_codecs[smh->num_negotiated_codecs++] = mimp;
pmap->recv_pt = (switch_payload_t)mmap->rm_pt;
-
+
}
}
if (match) {
char tmp[50];
//const char *mirror = switch_channel_get_variable(session->channel, "rtp_mirror_remote_audio_codec_payload");
-
+
switch_snprintf(tmp, sizeof(tmp), "%d", a_engine->cur_payload_map->remote_sdp_port);
switch_channel_set_variable(session->channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE, a_engine->cur_payload_map->remote_sdp_ip);
}
}
switch_mutex_unlock(smh->sdp_mutex);
-
+
smh->mparams->te = (switch_payload_t) ++pl;
}
switch_channel_set_variable(session->channel, "rtp_audio_recv_pt", tmp);
if (a_engine->read_impl.iananame) {
- if (!switch_core_codec_ready(&a_engine->read_codec) ||
- ((strcasecmp(matches[0].imp->iananame, a_engine->read_impl.iananame) ||
+ if (!switch_core_codec_ready(&a_engine->read_codec) ||
+ ((strcasecmp(matches[0].imp->iananame, a_engine->read_impl.iananame) ||
matches[0].imp->microseconds_per_packet != a_engine->read_impl.microseconds_per_packet ||
matches[0].imp->samples_per_second != a_engine->read_impl.samples_per_second
))) {
got_audio = 0;
} else {
got_audio = 1;
- }
+ }
}
}
best_te_rate = 8000;
}
- if (!best_te && (switch_media_handle_test_media_flag(smh, SCMF_LIBERAL_DTMF) ||
+ if (!best_te && (switch_media_handle_test_media_flag(smh, SCMF_LIBERAL_DTMF) ||
switch_channel_test_flag(session->channel, CF_LIBERAL_DTMF))) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
"No 2833 in SDP. Liberal DTMF mode adding %d as telephone-event.\n", smh->mparams->te);
best_te = smh->mparams->te;
}
if (best_te) {
smh->mparams->te_rate = best_te_rate;
-
- if (smh->mparams->dtmf_type == DTMF_AUTO || smh->mparams->dtmf_type == DTMF_2833 ||
+
+ if (smh->mparams->dtmf_type == DTMF_AUTO || smh->mparams->dtmf_type == DTMF_2833 ||
switch_media_handle_test_media_flag(smh, SCMF_LIBERAL_DTMF)) {
if (sdp_type == SDP_TYPE_REQUEST) {
smh->mparams->te = smh->mparams->recv_te = (switch_payload_t) best_te;
smh->mparams->dtmf_type = DTMF_2833;
}
}
-
+
if (a_engine->rtp_session) {
switch_rtp_set_telephony_event(a_engine->rtp_session, smh->mparams->te);
switch_channel_set_variable_printf(session->channel, "rtp_2833_send_payload", "%d", smh->mparams->te);
switch_channel_set_variable_printf(session->channel, "rtp_2833_recv_payload", "%d", smh->mparams->recv_te);
}
-
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Set 2833 dtmf send payload to %u recv payload to %u\n",
+
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Set 2833 dtmf send payload to %u recv payload to %u\n",
switch_channel_get_name(session->channel), smh->mparams->te, smh->mparams->recv_te);
smh->mparams->recv_te = smh->mparams->te = 0;
}
}
-
+
} else if (!got_text && m->m_type == sdp_media_text && m->m_port) {
sdp_rtpmap_t *map;
payload_map_t *red_pmap = NULL;
if (m->m_connections) {
connection = m->m_connections;
}
-
+
if (!connection) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot find a c= line in the sdp at media or session level!\n");
match = 0;
switch_channel_set_flag(session->channel, CF_TEXT_POSSIBLE);
got_text++;
-
+
for (map = m->m_rtpmaps; map; map = map->rm_next) {
payload_map_t *pmap;
if (map->rm_fmtp) {
pmap->rm_fmtp = switch_core_session_strdup(session, (char *) map->rm_fmtp);
}
-
+
t_engine->cur_payload_map = pmap;
-
+
if (!strcasecmp(map->rm_encoding, "red")) {
red_pmap = pmap;
}
for (attr = m->m_attributes; attr; attr = attr->a_next) {
if (!strcasecmp(attr->a_name, "rtcp") && attr->a_value) {
switch_channel_set_variable(session->channel, "sip_remote_text_rtcp_port", attr->a_value);
-
+
} else if (!got_text_crypto && !strcasecmp(attr->a_name, "crypto") && !zstr(attr->a_value)) {
int crypto_tag;
-
- if (!(smh->mparams->ndlb & SM_NDLB_ALLOW_CRYPTO_IN_AVP) &&
+
+ if (!(smh->mparams->ndlb & SM_NDLB_ALLOW_CRYPTO_IN_AVP) &&
!switch_true(switch_channel_get_variable(session->channel, "rtp_allow_crypto_in_avp"))) {
if (m->m_proto != sdp_proto_srtp && !got_webrtc) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "a=crypto in RTP/AVP, refer to rfc3711\n");
goto done;
}
}
-
+
crypto = attr->a_value;
crypto_tag = atoi(crypto);
-
- got_text_crypto = switch_core_session_check_incoming_crypto(session,
- "rtp_has_text_crypto",
+
+ got_text_crypto = switch_core_session_check_incoming_crypto(session,
+ "rtp_has_text_crypto",
SWITCH_MEDIA_TYPE_TEXT, crypto, crypto_tag, sdp_type);
-
+
}
}
m_idx = 0;
memset(matches, 0, sizeof(matches[0]) * MAX_MATCHES);
memset(near_matches, 0, sizeof(near_matches[0]) * MAX_MATCHES);
-
+
switch_channel_set_variable(session->channel, "video_possible", "true");
switch_channel_set_flag(session->channel, CF_VIDEO_SDP_RECVD);
-
+
connection = sdp->sdp_connection;
if (m->m_connections) {
connection = m->m_connections;
}
-
+
if (!connection) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot find a c= line in the sdp at media or session level!\n");
match = 0;
if (sdp_type == SDP_TYPE_REQUEST) {
sdp_bandwidth_t *bw;
int tias = 0;
-
+
for (bw = m->m_bandwidths; bw; bw = bw->b_next) {
if (bw->b_modifier == sdp_bw_as && !tias) {
v_engine->sdp_bw = bw->b_value;
if (switch_stristr("fir", attr->a_value)) {
v_engine->fir++;
}
-
+
if (switch_stristr("pli", attr->a_value)) {
v_engine->pli++;
}
if (switch_stristr("tmmbr", attr->a_value)) {
v_engine->tmmbr++;
}
-
+
rtcp_auto_video = 1;
smh->mparams->rtcp_video_interval_msec = SWITCH_RTCP_VIDEO_INTERVAL_MSEC;
}
got_video_rtcp = 1;
} else if (!got_video_crypto && !strcasecmp(attr->a_name, "crypto") && !zstr(attr->a_value)) {
int crypto_tag;
-
- if (!(smh->mparams->ndlb & SM_NDLB_ALLOW_CRYPTO_IN_AVP) &&
+
+ if (!(smh->mparams->ndlb & SM_NDLB_ALLOW_CRYPTO_IN_AVP) &&
!switch_true(switch_channel_get_variable(session->channel, "rtp_allow_crypto_in_avp"))) {
if (m->m_proto != sdp_proto_srtp && !got_webrtc) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "a=crypto in RTP/AVP, refer to rfc3711\n");
goto done;
}
}
-
+
crypto = attr->a_value;
crypto_tag = atoi(crypto);
-
- got_video_crypto = switch_core_session_check_incoming_crypto(session,
- "rtp_has_video_crypto",
+
+ got_video_crypto = switch_core_session_check_incoming_crypto(session,
+ "rtp_has_video_crypto",
SWITCH_MEDIA_TYPE_VIDEO, crypto, crypto_tag, sdp_type);
-
+
}
}
}
}
}
-
+
if (!(rm_encoding = map->rm_encoding)) {
rm_encoding = "";
}
for (i = 0; i < total_codecs; i++) {
const switch_codec_implementation_t *imp = codec_array[i];
-
+
if (imp->codec_type != SWITCH_CODEC_TYPE_VIDEO) {
continue;
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Video Codec Compare [%s:%d] +++ is saved as a match\n",
imp->iananame, map->rm_pt);
- m_idx++;
+ m_idx++;
}
vmatch = 0;
v_engine->codec_negotiated = 1;
for(j = 0; j < m_idx; j++) {
- payload_map_t *pmap = switch_core_media_add_payload_map(session,
+ payload_map_t *pmap = switch_core_media_add_payload_map(session,
SWITCH_MEDIA_TYPE_VIDEO,
- matches[j].map->rm_encoding,
+ matches[j].map->rm_encoding,
matches[j].imp->modname,
matches[j].map->rm_fmtp,
- sdp_type,
+ sdp_type,
matches[j].map->rm_pt,
matches[j].imp->samples_per_second,
matches[j].imp->microseconds_per_packet / 1000,
switch_rtp_set_default_payload(v_engine->rtp_session, pmap->pt);
}
}
-
+
mimp = matches[j].imp;
map = matches[j].map;
-
+
pmap->rm_encoding = switch_core_session_strdup(session, (char *) map->rm_encoding);
pmap->recv_pt = (switch_payload_t) map->rm_pt;
pmap->rm_rate = map->rm_rate;
pmap->remote_sdp_ip = switch_core_session_strdup(session, (char *) connection->c_address);
pmap->remote_sdp_port = (switch_port_t) m->m_port;
pmap->rm_fmtp = switch_core_session_strdup(session, (char *) inherit_video_fmtp ? inherit_video_fmtp : map->rm_fmtp);
- smh->negotiated_codecs[smh->num_negotiated_codecs++] = mimp;
+ smh->negotiated_codecs[smh->num_negotiated_codecs++] = mimp;
#if 0
if (j == 0 && (!switch_true(mirror) && switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND)) {
if (switch_core_codec_ready(&v_engine->read_codec) && strcasecmp(matches[0].imp->iananame, v_engine->read_codec.implementation->iananame)) {
v_engine->reset_codec = 1;
}
-
+
if (switch_core_media_set_video_codec(session, 0) == SWITCH_STATUS_SUCCESS) {
if (check_ice(smh, SWITCH_MEDIA_TYPE_VIDEO, sdp, m) == SWITCH_STATUS_FALSE) {
vmatch = 0;
if (rtcp_auto_audio && !skip_rtcp && !got_audio_rtcp && audio_port) {
switch_channel_set_variable_printf(session->channel, "rtp_remote_audio_rtcp_port", "%d", audio_port + 1);
a_engine->remote_rtcp_port = audio_port + 1;
-
+
if (!smh->mparams->rtcp_audio_interval_msec) {
smh->mparams->rtcp_audio_interval_msec = SWITCH_RTCP_AUDIO_INTERVAL_MSEC;
}
}
}
-
+
if (!saw_audio) {
payload_map_t *pmap;
a_engine->rmode = SWITCH_MEDIA_FLOW_DISABLED;
switch_channel_set_variable(smh->session->channel, "audio_media_flow", "inactive");
-
+
pmap = switch_core_media_add_payload_map(session,
SWITCH_MEDIA_TYPE_AUDIO,
}
t38_done:
-
+
if (parser) {
sdp_parser_free(parser);
}
switch_rtp_engine_t *a_engine;
switch_media_handle_t *smh;
switch_channel_t *channel = switch_core_session_get_channel(session);
-
+
switch_assert(session);
if (!(smh = session->media_handle)) {
a_engine = &smh->engines[SWITCH_MEDIA_TYPE_AUDIO];
v_engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO];
-
+
if (switch_core_session_get_partner(session, &b_session) == SWITCH_STATUS_SUCCESS) {
b_channel = switch_core_session_get_channel(b_session);
}
const char *msg = "hold";
const char *info;
- if ((switch_channel_test_flag(session->channel, CF_SLA_BARGE) || switch_channel_test_flag(session->channel, CF_SLA_BARGING)) &&
+ if ((switch_channel_test_flag(session->channel, CF_SLA_BARGE) || switch_channel_test_flag(session->channel, CF_SLA_BARGING)) &&
(!b_channel || switch_channel_test_flag(b_channel, CF_EVENT_LOCK_PRI))) {
switch_channel_mark_hold(session->channel, sendonly);
switch_channel_set_flag(session->channel, CF_PROTO_HOLD);
bypass_after_hold_b = switch_true(switch_channel_get_variable_dup(b_channel, "bypass_media_after_hold", SWITCH_FALSE, -1));
}
}
-
+
switch_yield(250000);
if (b_channel && (switch_channel_test_flag(session->channel, CF_BYPASS_MEDIA_AFTER_HOLD) ||
return NULL;
}
- v_engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO];
+ v_engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO];
if (!width) width = 352;
if (!height) height = 288;
if (!fps) fps = 15;
-
+
if (!(width && height && fps)) {
return;
}
fr.packetlen = buflen;
fr.data = buf + 12;
fr.buflen = buflen - 12;
-
+
blank_img = switch_img_alloc(NULL, SWITCH_IMG_FMT_I420, width, height, 1);
switch_color_set_rgb(&bgcolor, "#000000");
frame_ms = (uint32_t) 1000 / fps;
frames = (uint32_t) ms / frame_ms;
-
+
switch_core_media_gen_key_frame(session);
if (switch_core_session_read_lock(session) != SWITCH_STATUS_SUCCESS) {
return NULL;
}
-
+
if (!(smh = session->media_handle)) {
return NULL;
}
switch_core_session_get_partner(session, &b_session);
switch_channel_set_flag(session->channel, CF_VIDEO_WRITING);
-
+
if (b_session) {
switch_channel_set_flag(b_session->channel, CF_VIDEO_BLANK);
}
- v_engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO];
+ v_engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO];
buf = switch_core_session_alloc(session, buflen);
fr.buflen = buflen - 12;
switch_core_media_gen_key_frame(session);
-
+
if (smh->video_write_fh && smh->video_write_fh->mm.source_fps) {
fps = (int) smh->video_write_fh->mm.source_fps;
} else {
return SWITCH_STATUS_FALSE;
}
- v_engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO];
+ v_engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO];
switch_core_session_start_video_thread(session);
if (fh && smh->video_read_fh) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "File is already open\n");
switch_mutex_unlock(v_engine->mh.file_read_mutex);
- return SWITCH_STATUS_FALSE;
+ return SWITCH_STATUS_FALSE;
}
-
+
if (fh) {
switch_channel_set_flag_recursive(session->channel, CF_VIDEO_DECODED_READ);
switch_channel_set_flag(session->channel, CF_VIDEO_READ_FILE_ATTACHED);
switch_channel_clear_flag_recursive(session->channel, CF_VIDEO_DECODED_READ);
switch_core_session_video_reset(session);
}
-
+
if (!fh) {
switch_channel_clear_flag(session->channel, CF_VIDEO_READ_FILE_ATTACHED);
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "File is already open\n");
smh->video_write_fh = fh;
switch_mutex_unlock(v_engine->mh.file_write_mutex);
- return SWITCH_STATUS_SUCCESS;
+ return SWITCH_STATUS_SUCCESS;
}
if (fh) {
smh->video_write_thread = NULL;
switch_core_session_write_blank_video(session, 500);
}
-
+
smh->video_write_fh = fh;
switch_mutex_unlock(v_engine->mh.file_write_mutex);
}
if (!fh) switch_channel_video_sync(session->channel);
-
+
switch_core_session_wake_video_thread(session);
-
+
return SWITCH_STATUS_SUCCESS;
}
if (a_engine && a_engine->write_fb && !(flags & SWITCH_IO_FLAG_QUEUED)) {
switch_frame_t *dupframe = NULL;
-
+
if (switch_frame_buffer_dup(a_engine->write_fb, frame, &dupframe) == SWITCH_STATUS_SUCCESS) {
switch_frame_buffer_push(a_engine->write_fb, dupframe);
dupframe = NULL;
if (switch_channel_test_flag(session->channel, CF_PAUSE_BUGS) && !switch_core_media_bug_test_flag(bp, SMBF_NO_PAUSE)) {
continue;
}
-
+
if (!switch_channel_test_flag(session->channel, CF_ANSWERED) && switch_core_media_bug_test_flag(bp, SMBF_ANSWER_REQ)) {
continue;
}
prune++;
continue;
}
-
+
if (bp->ready) {
if (switch_test_flag(bp, SMBF_TAP_NATIVE_WRITE)) {
if (bp->callback) {
}
}
}
-
+
if ((bp->stop_time && bp->stop_time <= switch_epoch_time_now(NULL)) || ok == SWITCH_FALSE) {
switch_set_flag(bp, SMBF_PRUNE);
prune++;
write_impl.samples_per_packet, switch_core_session_get_pool(session));
mh->up = 1;
-
+
switch_frame_buffer_create(&a_engine->write_fb, 500);
while(switch_channel_up_nosig(session->channel) && mh->up == 1) {
void *pop;
- if (session->write_impl.microseconds_per_packet != write_impl.microseconds_per_packet ||
+ if (session->write_impl.microseconds_per_packet != write_impl.microseconds_per_packet ||
session->write_impl.samples_per_packet != write_impl.samples_per_packet) {
-
+
write_impl = session->write_impl;
switch_core_timer_destroy(&timer);
switch_core_timer_init(&timer, "soft", write_impl.microseconds_per_packet / 1000,
write_impl.samples_per_packet, switch_core_session_get_pool(session));
-
+
}
-
+
switch_core_timer_next(&timer);
if (switch_frame_buffer_trypop(a_engine->write_fb, &pop) == SWITCH_STATUS_SUCCESS && pop) {
switch_frame_t *frame = (switch_frame_t *)pop;
-
+
if ((switch_size_t)pop == 1) {
break;
}
a_engine->mh.session = session;
switch_threadattr_create(&thd_attr, pool);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
-
+
switch_thread_cond_create(&a_engine->mh.cond, pool);
switch_mutex_init(&a_engine->mh.cond_mutex, SWITCH_MUTEX_NESTED, pool);
switch_thread_create(&a_engine->media_thread, thd_attr, audio_write_thread, &a_engine->mh, switch_core_session_get_pool(session));
cr_frame.data = CR;
cr_frame.datalen = 3;
-
+
t_engine = &smh->engines[SWITCH_MEDIA_TYPE_TEXT];
t_engine->thread_id = switch_thread_self();
run = 1;
}
switch_mutex_unlock(smh->control_mutex);
-
+
if (run) {
t_engine->engine_function(session, t_engine->engine_user_data);
switch_mutex_lock(smh->control_mutex);
if (!switch_channel_test_flag(session->channel, CF_TEXT_PASSIVE)) {
status = switch_core_session_read_text_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
-
+
if (!SWITCH_READ_ACCEPTABLE(status)) {
switch_cond_next();
continue;
t_engine->mh.session = session;
switch_threadattr_create(&thd_attr, pool);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
-
+
switch_thread_cond_create(&t_engine->mh.cond, pool);
switch_mutex_init(&t_engine->mh.cond_mutex, SWITCH_MUTEX_NESTED, pool);
//switch_mutex_init(&t_engine->mh.file_read_mutex, SWITCH_MUTEX_NESTED, pool);
switch_img_fill(blank_img, 0, 0, blank_img->d_w, blank_img->d_h, &bgcolor);
}
}
-
-
+
+
v_engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO];
v_engine->thread_id = switch_thread_self();
switch_core_media_check_dtls(session, SWITCH_MEDIA_TYPE_VIDEO);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Video thread started. Echo is %s\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Video thread started. Echo is %s\n",
switch_channel_get_name(session->channel), switch_channel_test_flag(channel, CF_VIDEO_ECHO) ? "on" : "off");
switch_core_session_request_video_refresh(session);
continue;
}
- if (!switch_channel_test_flag(channel, CF_VIDEO_READY) &&
+ if (!switch_channel_test_flag(channel, CF_VIDEO_READY) &&
switch_channel_test_flag(channel, CF_VIDEO_DECODED_READ) && (++xloops > 10 || switch_channel_test_flag(channel, CF_VIDEO_PASSIVE))) {
switch_channel_set_flag(channel, CF_VIDEO_READY);
}
-
+
if (switch_channel_test_flag(channel, CF_VIDEO_PASSIVE)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Video thread paused. Echo is %s\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Video thread paused. Echo is %s\n",
switch_channel_get_name(session->channel), switch_channel_test_flag(channel, CF_VIDEO_ECHO) ? "on" : "off");
switch_thread_cond_wait(mh->cond, mh->cond_mutex);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Video thread resumed Echo is %s\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Video thread resumed Echo is %s\n",
switch_channel_get_name(session->channel), switch_channel_test_flag(channel, CF_VIDEO_ECHO) ? "on" : "off");
switch_core_session_request_video_refresh(session);
}
switch_yield(10000);
continue;
}
-
+
if (v_engine->engine_function) {
int run = 0;
}
vloops++;
-
+
send_blank = blank_enabled || switch_channel_test_flag(channel, CF_VIDEO_ECHO);
-
+
if (switch_channel_test_flag(channel, CF_VIDEO_READY) && !switch_test_flag(read_frame, SFF_CNG)) {
switch_mutex_lock(mh->file_read_mutex);
if (smh->video_read_fh && switch_test_flag(smh->video_read_fh, SWITCH_FILE_OPEN) && read_frame->img) {
smh->video_read_fh->mm.fps = smh->vid_params.fps;
switch_core_file_write_video(smh->video_read_fh, read_frame);
- }
+ }
switch_mutex_unlock(mh->file_read_mutex);
}
-
+
if ((switch_channel_test_flag(channel, CF_VIDEO_WRITING) || session->video_read_callback) && !switch_channel_test_flag(channel, CF_VIDEO_BLANK)) {
send_blank = 0;
}
v_engine->mh.session = session;
switch_threadattr_create(&thd_attr, pool);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
-
+
switch_thread_cond_create(&v_engine->mh.cond, pool);
switch_mutex_init(&v_engine->mh.cond_mutex, SWITCH_MUTEX_NESTED, pool);
switch_mutex_init(&v_engine->mh.file_read_mutex, SWITCH_MUTEX_NESTED, pool);
}
engine = &smh->engines[type];
-
+
switch_mutex_lock(smh->control_mutex);
r = (engine->engine_function_running > 0);
switch_mutex_unlock(smh->control_mutex);
}
engine = &smh->engines[type];
-
+
switch_mutex_lock(smh->control_mutex);
if (engine->engine_function_running > 0) {
engine->engine_function_running = -1;
switch_media_handle_t *smh;
switch_assert(session);
-
+
if (!(smh = session->media_handle)) {
return SWITCH_FALSE;
}
v_engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO];
-
+
return switch_thread_equal(switch_thread_self(), v_engine->thread_id) ? SWITCH_TRUE : SWITCH_FALSE;
}
a_engine = &smh->engines[SWITCH_MEDIA_TYPE_AUDIO];
v_engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO];
t_engine = &smh->engines[SWITCH_MEDIA_TYPE_TEXT];
-
+
if (zstr(sdp_str)) {
sdp_str = smh->mparams->remote_sdp_str;
}
if ((p = (char *) switch_stristr("m=image ", sdp_str))) {
char *tmp = p + 8;
-
+
if (tmp && atoi(tmp)) {
port_ptr = tmp;
}
}
}
-
+
if (switch_rtp_set_remote_address(v_engine->rtp_session, v_engine->cur_payload_map->remote_sdp_ip,
v_engine->cur_payload_map->remote_sdp_port, remote_rtcp_port, SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "VIDEO RTP REPORTS ERROR: [%s]\n", err);
}
}
-
+
if (switch_rtp_set_remote_address(t_engine->rtp_session, t_engine->cur_payload_map->remote_sdp_ip,
t_engine->cur_payload_map->remote_sdp_port, remote_rtcp_port, SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "TEXT RTP REPORTS ERROR: [%s]\n", err);
switch_goto_status(SWITCH_STATUS_BREAK, end);
} else if (remote_host && ( (strcmp(remote_host, "0.0.0.0") == 0) ||
(strcmp(a_engine->cur_payload_map->remote_sdp_ip, "0.0.0.0") == 0))) {
-
+
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
"Remote address changed from [%s] to [%s]. Ignoring...\n",
a_engine->cur_payload_map->remote_sdp_ip, remote_host);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "AUDIO RTP CHANGING DEST TO: [%s:%d]\n",
a_engine->cur_payload_map->remote_sdp_ip, a_engine->cur_payload_map->remote_sdp_port);
if (!switch_media_handle_test_media_flag(smh, SCMF_DISABLE_RTP_AUTOADJ) &&
- !((val = switch_channel_get_variable(session->channel, "disable_rtp_auto_adjust")) && switch_true(val)) &&
+ !((val = switch_channel_get_variable(session->channel, "disable_rtp_auto_adjust")) && switch_true(val)) &&
!switch_channel_test_flag(session->channel, CF_AVPF)) {
/* Reactivate the NAT buster flag. */
switch_rtp_set_flag(a_engine->rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
{
switch_assert(network_ip);
- return (smh->mparams->extsipip &&
- !switch_check_network_list_ip(network_ip, "loopback.auto") &&
+ return (smh->mparams->extsipip &&
+ !switch_check_network_list_ip(network_ip, "loopback.auto") &&
!switch_check_network_list_ip(network_ip, smh->mparams->local_network));
}
//?
SWITCH_DECLARE(switch_status_t) switch_core_media_ext_address_lookup(switch_core_session_t *session, char **ip, switch_port_t *port, const char *sourceip)
-
+
{
char *error = "";
switch_status_t status = SWITCH_STATUS_FALSE;
}
engine->local_sdp_ip = smh->mparams->rtpip;
-
+
sdp_port = engine->local_sdp_port;
switch_nat_add_mapping(engine->local_sdp_port, SWITCH_NAT_UDP, &sdp_port, SWITCH_FALSE);
switch_snprintf(vname, sizeof(vname), "rtp_adv_%s_ip", tstr);
-
+
/* Find an IP address to use */
if (!(use_ip = switch_channel_get_variable(session->channel, vname))
&& !zstr(smh->mparams->extrtpip)) {
{
switch_status_t status = SWITCH_STATUS_SUCCESS;
switch_media_handle_t *smh;
-
+
if (!(smh = session->media_handle)) {
return SWITCH_STATUS_FALSE;
}
if (zstr(smh->mparams->rtpip)) {
-
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "%s has no media ip\n",
+
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "%s has no media ip\n",
switch_channel_get_name(smh->session->channel));
switch_channel_hangup(smh->session->channel, SWITCH_CAUSE_BEARERCAPABILITY_NOTAVAIL);
if (v_engine->media_thread) {
switch_status_t st;
switch_channel_clear_flag(session->channel, CF_VIDEO_PASSIVE);
-
+
v_engine->mh.up = 0;
switch_thread_join(&st, v_engine->media_thread);
v_engine->media_thread = NULL;
}
- if (v_engine->local_sdp_port > 0 && !zstr(smh->mparams->remote_ip) &&
+ if (v_engine->local_sdp_port > 0 && !zstr(smh->mparams->remote_ip) &&
switch_core_media_check_nat(smh, smh->mparams->remote_ip)) {
switch_nat_del_mapping((switch_port_t) v_engine->local_sdp_port, SWITCH_NAT_UDP);
switch_nat_del_mapping((switch_port_t) v_engine->local_sdp_port + 1, SWITCH_NAT_UDP);
}
- if (t_engine->local_sdp_port > 0 && !zstr(smh->mparams->remote_ip) &&
+ if (t_engine->local_sdp_port > 0 && !zstr(smh->mparams->remote_ip) &&
switch_core_media_check_nat(smh, smh->mparams->remote_ip)) {
switch_nat_del_mapping((switch_port_t) t_engine->local_sdp_port, SWITCH_NAT_UDP);
switch_nat_del_mapping((switch_port_t) t_engine->local_sdp_port + 1, SWITCH_NAT_UDP);
switch_rtp_release_port(smh->mparams->rtpip, a_engine->local_sdp_port);
}
- if (a_engine->local_sdp_port > 0 && !zstr(smh->mparams->remote_ip) &&
+ if (a_engine->local_sdp_port > 0 && !zstr(smh->mparams->remote_ip) &&
switch_core_media_check_nat(smh, smh->mparams->remote_ip)) {
switch_nat_del_mapping((switch_port_t) a_engine->local_sdp_port, SWITCH_NAT_UDP);
switch_nat_del_mapping((switch_port_t) a_engine->local_sdp_port + 1, SWITCH_NAT_UDP);
tmp[16] = '\0';
smh->cname = switch_core_session_strdup(session, tmp);
}
-
+
if (!engine->ice_out.ufrag) {
switch_stun_random_string(tmp, 16, NULL);
tmp[16] = '\0';
if (!engine->ice_out.pwd) {
switch_stun_random_string(tmp, 24, NULL);
tmp[24] = '\0';
- engine->ice_out.pwd = switch_core_session_strdup(session, tmp);
+ engine->ice_out.pwd = switch_core_session_strdup(session, tmp);
}
if (!engine->ice_out.cands[0][0].foundation) {
engine->ice_out.cands[0][0].generation = "0";
//add rport stuff later
-
+
engine->ice_out.cands[0][0].ready = 1;
SWITCH_DECLARE(void) switch_core_session_wake_video_thread(switch_core_session_t *session)
{
switch_media_handle_t *smh;
- switch_rtp_engine_t *v_engine;
+ switch_rtp_engine_t *v_engine;
if (!(smh = session->media_handle)) {
return;
if (!zstr(engine->local_dtls_fingerprint.str) && switch_rtp_has_dtls() && dtls_ok(session)) {
dtls_type_t xtype, dtype = engine->dtls_controller ? DTLS_TYPE_CLIENT : DTLS_TYPE_SERVER;
-
+
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "RE-SETTING %s DTLS\n", type2str(engine->type));
-
+
xtype = DTLS_TYPE_RTP;
if (engine->rtcp_mux > 0) xtype |= DTLS_TYPE_RTCP;
-
+
switch_rtp_add_dtls(engine->rtp_session, &engine->local_dtls_fingerprint, &engine->remote_dtls_fingerprint, dtype | xtype);
-
+
if (engine->rtcp_mux < 1) {
xtype = DTLS_TYPE_RTCP;
switch_rtp_add_dtls(engine->rtp_session, &engine->local_dtls_fingerprint, &engine->remote_dtls_fingerprint, dtype | xtype);
}
-
+
}
engine->new_dtls = 0;
}
status = SWITCH_STATUS_SUCCESS;
goto end;
- }
+ }
}
if ((status = switch_core_media_set_codec(session, 0, smh->mparams->codec_flags)) != SWITCH_STATUS_SUCCESS) {
flags[SWITCH_RTP_FLAG_BYTESWAP]++;
}
#endif
-
+
if ((flags[SWITCH_RTP_FLAG_BYTESWAP]) && (val = switch_channel_get_variable(session->channel, "rtp_disable_byteswap")) && switch_true(val)) {
flags[SWITCH_RTP_FLAG_BYTESWAP] = 0;
}
char *remote_host = switch_rtp_get_remote_host(a_engine->rtp_session);
switch_port_t remote_port = switch_rtp_get_remote_port(a_engine->rtp_session);
- if (remote_host && remote_port && !strcmp(remote_host, a_engine->cur_payload_map->remote_sdp_ip) &&
+ if (remote_host && remote_port && !strcmp(remote_host, a_engine->cur_payload_map->remote_sdp_ip) &&
remote_port == a_engine->cur_payload_map->remote_sdp_port) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Audio params are unchanged for %s.\n",
switch_channel_get_name(session->channel));
if (a_engine->rtp_session && is_reinvite) {
const char *rport = NULL;
switch_port_t remote_rtcp_port = a_engine->remote_rtcp_port;
-
+
if (!remote_rtcp_port) {
if ((rport = switch_channel_get_variable(session->channel, "rtp_remote_audio_rtcp_port"))) {
remote_rtcp_port = (switch_port_t)atoi(rport);
if (switch_channel_up(session->channel)) {
switch_channel_set_variable(session->channel, "rtp_use_timer_name", timer_name);
-
+
a_engine->rtp_session = switch_rtp_new(a_engine->local_sdp_ip,
if ((val = switch_channel_get_variable(session->channel, "rtp_manual_rtp_bugs"))) {
switch_core_media_parse_rtp_bugs(&a_engine->rtp_bugs, val);
}
-
+
//if (switch_channel_test_flag(session->channel, CF_AVPF)) {
// smh->mparams->manual_rtp_bugs = RTP_BUG_SEND_LINEAR_TIMESTAMPS;
//}
switch_channel_get_name(switch_core_session_get_channel(session)), vad_in ? "in" : "", vad_out ? "out" : "");
}
-
+
if (a_engine->ice_in.cands[a_engine->ice_in.chosen[0]][0].ready) {
-
+
gen_ice(session, SWITCH_MEDIA_TYPE_AUDIO, NULL, 0);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Activating Audio ICE\n");
- switch_rtp_activate_ice(a_engine->rtp_session,
+ switch_rtp_activate_ice(a_engine->rtp_session,
a_engine->ice_in.ufrag,
a_engine->ice_out.ufrag,
a_engine->ice_out.pwd,
ICE_GOOGLE_JINGLE,
NULL
#else
- switch_ice_direction(session) ==
+ switch_ice_direction(session) ==
SWITCH_CALL_DIRECTION_OUTBOUND ? ICE_VANILLA : (ICE_VANILLA | ICE_CONTROLLED),
&a_engine->ice_in
#endif
);
-
-
+
+
}
if (!remote_rtcp_port && rport) {
remote_rtcp_port = (switch_port_t)atoi(rport);
}
-
+
if (!strcasecmp(val, "passthru")) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Activating RTCP PASSTHRU PORT %d\n", remote_rtcp_port);
switch_rtp_activate_rtcp(a_engine->rtp_session, -1, remote_rtcp_port, a_engine->rtcp_mux > 0);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Activating RTCP PORT %d\n", remote_rtcp_port);
switch_rtp_activate_rtcp(a_engine->rtp_session, interval, remote_rtcp_port, a_engine->rtcp_mux > 0);
-
+
}
if (a_engine->ice_in.cands[a_engine->ice_in.chosen[1]][1].ready) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Skipping RTCP ICE (Same as RTP)\n");
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Activating RTCP ICE\n");
-
- switch_rtp_activate_ice(a_engine->rtp_session,
+
+ switch_rtp_activate_ice(a_engine->rtp_session,
a_engine->ice_in.ufrag,
a_engine->ice_out.ufrag,
a_engine->ice_out.pwd,
ICE_GOOGLE_JINGLE,
NULL
#else
- switch_ice_direction(session) ==
+ switch_ice_direction(session) ==
SWITCH_CALL_DIRECTION_OUTBOUND ? ICE_VANILLA : (ICE_VANILLA | ICE_CONTROLLED),
&a_engine->ice_in
#endif
);
}
-
+
}
}
xtype = DTLS_TYPE_RTP;
if (a_engine->rtcp_mux > 0 && smh->mparams->rtcp_audio_interval_msec) xtype |= DTLS_TYPE_RTCP;
-
+
switch_rtp_add_dtls(a_engine->rtp_session, &a_engine->local_dtls_fingerprint, &a_engine->remote_dtls_fingerprint, dtype | xtype);
if (a_engine->rtcp_mux < 1 && smh->mparams->rtcp_audio_interval_msec) {
}
if (smh->mparams->recv_te) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Set 2833 dtmf receive payload to %u\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Set 2833 dtmf receive payload to %u\n",
switch_channel_get_name(session->channel), smh->mparams->recv_te);
switch_rtp_set_telephony_recv_event(a_engine->rtp_session, smh->mparams->recv_te);
switch_channel_set_variable_printf(session->channel, "rtp_2833_recv_payload", "%d", smh->mparams->recv_te);
if (smh->mparams->dtmf_delay) {
switch_rtp_set_interdigit_delay(a_engine->rtp_session, smh->mparams->dtmf_delay);
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
"%s Set rtp dtmf delay to %u\n", switch_channel_get_name(session->channel), smh->mparams->dtmf_delay);
-
+
}
if (smh->mparams->cng_pt && !switch_media_handle_test_media_flag(smh, SCMF_SUPPRESS_CNG)) {
}
-
+
text:
//if (switch_channel_test_flag(session->channel, CF_MSRP)) { // skip RTP RTT
//const char *port = switch_channel_get_variable(session->channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE);
char *remote_host = switch_rtp_get_remote_host(t_engine->rtp_session);
switch_port_t remote_port = switch_rtp_get_remote_port(t_engine->rtp_session);
-
+
if (remote_host && remote_port && !strcmp(remote_host, t_engine->cur_payload_map->remote_sdp_ip) && remote_port == t_engine->cur_payload_map->remote_sdp_port) {
switch_rtp_set_default_payload(t_engine->rtp_session, t_engine->cur_payload_map->pt);
}
}
-
+
switch_snprintf(tmp, sizeof(tmp), "%d", t_engine->local_sdp_port);
switch_channel_set_variable(session->channel, SWITCH_LOCAL_TEXT_IP_VARIABLE, a_engine->adv_sdp_ip);
switch_channel_set_variable(session->channel, SWITCH_LOCAL_TEXT_PORT_VARIABLE, tmp);
remote_rtcp_port = (switch_port_t)atoi(rport);
}
}
-
+
if (switch_rtp_set_remote_address
(t_engine->rtp_session, t_engine->cur_payload_map->remote_sdp_ip, t_engine->cur_payload_map->remote_sdp_port, remote_rtcp_port, SWITCH_TRUE,
&err) != SWITCH_STATUS_SUCCESS) {
flags[SWITCH_RTP_FLAG_RAW_WRITE]++;
if (!switch_media_handle_test_media_flag(smh, SCMF_DISABLE_RTP_AUTOADJ) && !switch_channel_test_flag(session->channel, CF_PROXY_MODE) &&
- !((val = switch_channel_get_variable(session->channel, "disable_rtp_auto_adjust")) && switch_true(val)) &&
+ !((val = switch_channel_get_variable(session->channel, "disable_rtp_auto_adjust")) && switch_true(val)) &&
!switch_channel_test_flag(session->channel, CF_AVPF)) {
- flags[SWITCH_RTP_FLAG_AUTOADJ]++;
+ flags[SWITCH_RTP_FLAG_AUTOADJ]++;
}
if (switch_channel_test_flag(session->channel, CF_PROXY_MEDIA)) {
flags[SWITCH_RTP_FLAG_NOBLOCK] = 0;
flags[SWITCH_RTP_FLAG_TEXT]++;
//flags[SWITCH_RTP_FLAG_VIDEO]++;
-
+
t_engine->rtp_session = switch_rtp_new(a_engine->local_sdp_ip,
t_engine->local_sdp_port,
t_engine->cur_payload_map->remote_sdp_ip,
if (switch_rtp_ready(t_engine->rtp_session)) {
const char *ssrc;
-
+
if (!t_engine->tf) {
switch_rtp_text_factory_create(&t_engine->tf, switch_core_session_get_pool(session));
} else {
switch_rtp_set_ssrc(t_engine->rtp_session, t_engine->ssrc);
}
-
+
if (t_engine->remote_ssrc) {
switch_rtp_set_remote_ssrc(t_engine->rtp_session, t_engine->remote_ssrc);
}
if (t_engine->ice_in.cands[t_engine->ice_in.chosen[0]][0].ready) {
-
+
gen_ice(session, SWITCH_MEDIA_TYPE_TEXT, NULL, 0);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Activating Text ICE\n");
-
- switch_rtp_activate_ice(t_engine->rtp_session,
+
+ switch_rtp_activate_ice(t_engine->rtp_session,
t_engine->ice_in.ufrag,
t_engine->ice_out.ufrag,
t_engine->ice_out.pwd,
ICE_GOOGLE_JINGLE,
NULL
#else
- switch_ice_direction(session) ==
+ switch_ice_direction(session) ==
SWITCH_CALL_DIRECTION_OUTBOUND ? ICE_VANILLA : (ICE_VANILLA | ICE_CONTROLLED),
&t_engine->ice_in
#endif
);
-
-
+
+
}
if ((val = switch_channel_get_variable(session->channel, "rtcp_text_interval_msec")) || (val = smh->mparams->rtcp_text_interval_msec)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO,
"Activating TEXT RTCP PORT %d interval %d mux %d\n", remote_port, interval, t_engine->rtcp_mux);
switch_rtp_activate_rtcp(t_engine->rtp_session, interval, remote_port, t_engine->rtcp_mux > 0);
-
+
}
-
+
if (t_engine->ice_in.cands[t_engine->ice_in.chosen[1]][1].ready) {
- if (t_engine->rtcp_mux > 0 && !strcmp(t_engine->ice_in.cands[t_engine->ice_in.chosen[1]][1].con_addr,
+ if (t_engine->rtcp_mux > 0 && !strcmp(t_engine->ice_in.cands[t_engine->ice_in.chosen[1]][1].con_addr,
t_engine->ice_in.cands[t_engine->ice_in.chosen[0]][0].con_addr) &&
t_engine->ice_in.cands[t_engine->ice_in.chosen[1]][1].con_port == t_engine->ice_in.cands[t_engine->ice_in.chosen[0]][0].con_port) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Skipping TEXT RTCP ICE (Same as TEXT RTP)\n");
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Activating TEXT RTCP ICE\n");
- switch_rtp_activate_ice(t_engine->rtp_session,
+ switch_rtp_activate_ice(t_engine->rtp_session,
t_engine->ice_in.ufrag,
t_engine->ice_out.ufrag,
t_engine->ice_out.pwd,
ICE_GOOGLE_JINGLE,
NULL
#else
- switch_ice_direction(session) ==
+ switch_ice_direction(session) ==
SWITCH_CALL_DIRECTION_OUTBOUND ? ICE_VANILLA : (ICE_VANILLA | ICE_CONTROLLED),
&t_engine->ice_in
#endif
);
-
-
-
+
+
+
}
-
+
}
}
-
+
if (!zstr(t_engine->local_dtls_fingerprint.str) && switch_rtp_has_dtls() && dtls_ok(smh->session)) {
- dtls_type_t xtype,
+ dtls_type_t xtype,
dtype = t_engine->dtls_controller ? DTLS_TYPE_CLIENT : DTLS_TYPE_SERVER;
xtype = DTLS_TYPE_RTP;
if (t_engine->rtcp_mux > 0 && smh->mparams->rtcp_text_interval_msec) xtype |= DTLS_TYPE_RTCP;
-
+
switch_rtp_add_dtls(t_engine->rtp_session, &t_engine->local_dtls_fingerprint, &t_engine->remote_dtls_fingerprint, dtype | xtype);
-
+
if (t_engine->rtcp_mux < 1 && smh->mparams->rtcp_text_interval_msec) {
xtype = DTLS_TYPE_RTCP;
switch_rtp_add_dtls(t_engine->rtp_session, &t_engine->local_dtls_fingerprint, &t_engine->remote_dtls_fingerprint, dtype | xtype);
}
}
-
-
+
+
if ((val = switch_channel_get_variable(session->channel, "rtp_manual_text_rtp_bugs"))) {
switch_core_media_parse_rtp_bugs(&t_engine->rtp_bugs, val);
}
-
+
//if (switch_channel_test_flag(session->channel, CF_AVPF)) {
//smh->mparams->manual_video_rtp_bugs = RTP_BUG_SEND_LINEAR_TIMESTAMPS;
//}
-
+
switch_rtp_intentional_bugs(t_engine->rtp_session, t_engine->rtp_bugs | smh->mparams->manual_text_rtp_bugs);
//XX
switch_core_session_apply_crypto(session, SWITCH_MEDIA_TYPE_TEXT);
-
+
if (switch_channel_test_flag(session->channel, CF_ZRTP_PASSTHRU)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Activating text UDPTL mode\n");
switch_rtp_udptl_mode(t_engine->rtp_session);
goto end;
}
}
-
+
text_up:
video:
-
+
if (switch_channel_direction(session->channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
switch_core_media_check_video_codecs(session);
}
//const char *port = switch_channel_get_variable(session->channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE);
char *remote_host = switch_rtp_get_remote_host(v_engine->rtp_session);
switch_port_t remote_port = switch_rtp_get_remote_port(v_engine->rtp_session);
-
+
if (remote_host && remote_port && !strcmp(remote_host, v_engine->cur_payload_map->remote_sdp_ip) && remote_port == v_engine->cur_payload_map->remote_sdp_port) {
switch_rtp_set_default_payload(v_engine->rtp_session, v_engine->cur_payload_map->pt);
}
}
-
+
switch_snprintf(tmp, sizeof(tmp), "%d", v_engine->local_sdp_port);
switch_channel_set_variable(session->channel, SWITCH_LOCAL_VIDEO_IP_VARIABLE, a_engine->adv_sdp_ip);
switch_channel_set_variable(session->channel, SWITCH_LOCAL_VIDEO_PORT_VARIABLE, tmp);
remote_rtcp_port = (switch_port_t)atoi(rport);
}
}
-
+
if (switch_rtp_set_remote_address
(v_engine->rtp_session, v_engine->cur_payload_map->remote_sdp_ip, v_engine->cur_payload_map->remote_sdp_port, remote_rtcp_port, SWITCH_TRUE,
&err) != SWITCH_STATUS_SUCCESS) {
flags[SWITCH_RTP_FLAG_RAW_WRITE]++;
if (!switch_media_handle_test_media_flag(smh, SCMF_DISABLE_RTP_AUTOADJ) && !switch_channel_test_flag(session->channel, CF_PROXY_MODE) &&
- !((val = switch_channel_get_variable(session->channel, "disable_rtp_auto_adjust")) && switch_true(val)) &&
+ !((val = switch_channel_get_variable(session->channel, "disable_rtp_auto_adjust")) && switch_true(val)) &&
!switch_channel_test_flag(session->channel, CF_AVPF)) {
- flags[SWITCH_RTP_FLAG_AUTOADJ]++;
+ flags[SWITCH_RTP_FLAG_AUTOADJ]++;
}
if ((val = switch_channel_get_variable(session->channel, "rtp_gen_ts_delta_video")) && switch_true(val)) {
flags[SWITCH_RTP_FLAG_USE_TIMER] = 0;
flags[SWITCH_RTP_FLAG_NOBLOCK] = 0;
flags[SWITCH_RTP_FLAG_VIDEO]++;
-
+
if (v_engine->fir) {
flags[SWITCH_RTP_FLAG_FIR]++;
}
if (v_engine->pli) {
switch_rtp_set_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_PLI);
}
-
+
switch_rtp_set_payload_map(v_engine->rtp_session, &v_engine->payload_map);
switch_channel_set_flag(session->channel, CF_VIDEO);
switch_core_session_start_video_thread(session);
-
+
switch_rtp_set_video_buffer_size(v_engine->rtp_session, 1, 0);
if ((ssrc = switch_channel_get_variable(session->channel, "rtp_use_video_ssrc"))) {
uint32_t ssrc_ul = (uint32_t) strtoul(ssrc, NULL, 10);
} else {
switch_rtp_set_ssrc(v_engine->rtp_session, v_engine->ssrc);
}
-
+
if (v_engine->remote_ssrc) {
switch_rtp_set_remote_ssrc(v_engine->rtp_session, v_engine->remote_ssrc);
}
if (v_engine->ice_in.cands[v_engine->ice_in.chosen[0]][0].ready) {
-
+
gen_ice(session, SWITCH_MEDIA_TYPE_VIDEO, NULL, 0);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Activating Video ICE\n");
-
- switch_rtp_activate_ice(v_engine->rtp_session,
+
+ switch_rtp_activate_ice(v_engine->rtp_session,
v_engine->ice_in.ufrag,
v_engine->ice_out.ufrag,
v_engine->ice_out.pwd,
ICE_GOOGLE_JINGLE,
NULL
#else
- switch_ice_direction(session) ==
+ switch_ice_direction(session) ==
SWITCH_CALL_DIRECTION_OUTBOUND ? ICE_VANILLA : (ICE_VANILLA | ICE_CONTROLLED),
&v_engine->ice_in
#endif
);
-
-
+
+
}
if ((val = switch_channel_get_variable(session->channel, "rtcp_video_interval_msec")) || (val = smh->mparams->rtcp_video_interval_msec)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO,
"Activating VIDEO RTCP PORT %d interval %d mux %d\n", remote_port, interval, v_engine->rtcp_mux);
switch_rtp_activate_rtcp(v_engine->rtp_session, interval, remote_port, v_engine->rtcp_mux > 0);
-
+
}
-
+
if (v_engine->ice_in.cands[v_engine->ice_in.chosen[1]][1].ready) {
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Activating VIDEO RTCP ICE\n");
- switch_rtp_activate_ice(v_engine->rtp_session,
+ switch_rtp_activate_ice(v_engine->rtp_session,
v_engine->ice_in.ufrag,
v_engine->ice_out.ufrag,
v_engine->ice_out.pwd,
ICE_GOOGLE_JINGLE,
NULL
#else
- switch_ice_direction(session) ==
+ switch_ice_direction(session) ==
SWITCH_CALL_DIRECTION_OUTBOUND ? ICE_VANILLA : (ICE_VANILLA | ICE_CONTROLLED),
&v_engine->ice_in
#endif
);
-
-
-
+
+
+
}
-
+
}
}
-
+
if (!zstr(v_engine->local_dtls_fingerprint.str) && switch_rtp_has_dtls() && dtls_ok(smh->session)) {
- dtls_type_t xtype,
+ dtls_type_t xtype,
dtype = v_engine->dtls_controller ? DTLS_TYPE_CLIENT : DTLS_TYPE_SERVER;
xtype = DTLS_TYPE_RTP;
if (v_engine->rtcp_mux > 0 && smh->mparams->rtcp_video_interval_msec) xtype |= DTLS_TYPE_RTCP;
-
+
switch_rtp_add_dtls(v_engine->rtp_session, &v_engine->local_dtls_fingerprint, &v_engine->remote_dtls_fingerprint, dtype | xtype);
-
+
if (v_engine->rtcp_mux < 1 && smh->mparams->rtcp_video_interval_msec) {
xtype = DTLS_TYPE_RTCP;
switch_rtp_add_dtls(v_engine->rtp_session, &v_engine->local_dtls_fingerprint, &v_engine->remote_dtls_fingerprint, dtype | xtype);
}
}
-
-
+
+
if ((val = switch_channel_get_variable(session->channel, "rtp_manual_video_rtp_bugs"))) {
switch_core_media_parse_rtp_bugs(&v_engine->rtp_bugs, val);
}
-
+
if (switch_channel_test_flag(session->channel, CF_AVPF)) {
smh->mparams->manual_video_rtp_bugs = RTP_BUG_SEND_LINEAR_TIMESTAMPS;
}
-
+
switch_rtp_intentional_bugs(v_engine->rtp_session, v_engine->rtp_bugs | smh->mparams->manual_video_rtp_bugs);
//XX
switch_core_session_apply_crypto(session, SWITCH_MEDIA_TYPE_VIDEO);
-
+
if (switch_channel_test_flag(session->channel, CF_ZRTP_PASSTHRU)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Activating video UDPTL mode\n");
switch_rtp_udptl_mode(v_engine->rtp_session);
}
return "RTP/AVP";
-
+
}
static char *get_setup(switch_rtp_engine_t *engine, switch_core_session_t *session, switch_sdp_type_t sdp_type)
//?
-static void generate_m(switch_core_session_t *session, char *buf, size_t buflen,
+static void generate_m(switch_core_session_t *session, char *buf, size_t buflen,
switch_port_t port, const char *family, const char *ip,
- int cur_ptime, const char *append_audio, const char *sr, int use_cng, int cng_type, switch_event_t *map, int secure,
+ int cur_ptime, const char *append_audio, const char *sr, int use_cng, int cng_type, switch_event_t *map, int secure,
switch_sdp_type_t sdp_type)
{
int i = 0;
a_engine = &smh->engines[SWITCH_MEDIA_TYPE_AUDIO];
- //switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "m=audio %d RTP/%sAVP%s",
+ //switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "m=audio %d RTP/%sAVP%s",
//port, secure ? "S" : "", switch_channel_test_flag(session->channel, CF_AVPF) ? "F" : "");
- switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "m=audio %d %s", port,
+ switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "m=audio %d %s", port,
get_media_profile_name(session, secure || a_engine->crypto_type != CRYPTO_INVALID));
include_external = switch_channel_var_true(session->channel, "include_external_ip");
already_did[smh->ianacodes[i]] = 1;
}
-
+
switch_snprintf(buf + strlen(buf), buflen - strlen(buf), " %d", smh->ianacodes[i]);
}
}
}
}
-
+
//if (!switch_media_handle_test_media_flag(smh, SCMF_SUPPRESS_CNG) && cng_type && use_cng) {
//switch_snprintf(buf + strlen(buf), buflen - strlen(buf), " %d", cng_type);
//}
-
+
switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "\r\n");
memset(already_did, 0, sizeof(already_did));
-
+
for (i = 0; i < smh->mparams->num_codecs; i++) {
const switch_codec_implementation_t *imp = smh->codecs[i];
char *fmtp = imp->fmtp;
}
}
}
-
+
if (smh->ianacodes[i] < 128) {
if (already_did[smh->ianacodes[i]]) {
continue;
}
-
+
already_did[smh->ianacodes[i]] = 1;
}
if (channels > 1) {
switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "a=rtpmap:%d %s/%d/%d\r\n", smh->ianacodes[i], imp->iananame, rate, channels);
-
+
} else {
switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "a=rtpmap:%d %s/%d\r\n", smh->ianacodes[i], imp->iananame, rate);
}
}
- if ((smh->mparams->dtmf_type == DTMF_2833 || switch_media_handle_test_media_flag(smh, SCMF_LIBERAL_DTMF) ||
+ if ((smh->mparams->dtmf_type == DTMF_2833 || switch_media_handle_test_media_flag(smh, SCMF_LIBERAL_DTMF) ||
switch_channel_test_flag(session->channel, CF_LIBERAL_DTMF)) && smh->mparams->te > 95) {
for (i = 0; i < smh->num_rates; i++) {
if (switch_channel_test_flag(session->channel, CF_AVPF)) {
- switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "a=rtpmap:%d telephone-event/%d\r\n",
+ switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "a=rtpmap:%d telephone-event/%d\r\n",
smh->dtmf_ianacodes[i], smh->rates[i]);
} else {
- switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "a=rtpmap:%d telephone-event/%d\r\na=fmtp:%d 0-16\r\n",
+ switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "a=rtpmap:%d telephone-event/%d\r\na=fmtp:%d 0-16\r\n",
smh->dtmf_ianacodes[i], smh->rates[i], smh->dtmf_ianacodes[i]);
}
}
}
if (!zstr(a_engine->local_dtls_fingerprint.type) && secure) {
- switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "a=fingerprint:%s %s\r\na=setup:%s\r\n", a_engine->local_dtls_fingerprint.type,
+ switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "a=fingerprint:%s %s\r\na=setup:%s\r\n", a_engine->local_dtls_fingerprint.type,
a_engine->local_dtls_fingerprint.str, get_setup(a_engine, session, sdp_type));
}
-
+
if (smh->mparams->rtcp_audio_interval_msec) {
if (a_engine->rtcp_mux > 0) {
switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "a=rtcp-mux\r\n");
switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "a=ice-pwd:%s\r\n", ice_out->pwd);
- switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "a=candidate:%s 1 %s %u %s %d typ host generation 0\r\n",
+ switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "a=candidate:%s 1 %s %u %s %d typ host generation 0\r\n",
tmp1, ice_out->cands[0][0].transport, c1,
ice_out->cands[0][0].con_addr, ice_out->cands[0][0].con_port
);
strcmp(a_engine->local_sdp_ip, ice_out->cands[0][0].con_addr)
&& a_engine->local_sdp_port != ice_out->cands[0][0].con_port) {
- switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "a=candidate:%s 1 %s %u %s %d typ srflx raddr %s rport %d generation 0\r\n",
+ switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "a=candidate:%s 1 %s %u %s %d typ srflx raddr %s rport %d generation 0\r\n",
tmp2, ice_out->cands[0][0].transport, c2,
ice_out->cands[0][0].con_addr, ice_out->cands[0][0].con_port,
a_engine->local_sdp_ip, a_engine->local_sdp_port
}
if (a_engine->rtcp_mux < 1 || switch_channel_direction(session->channel) == SWITCH_CALL_DIRECTION_OUTBOUND || switch_channel_test_flag(session->channel, CF_RECOVERING)) {
-
- switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "a=candidate:%s 2 %s %u %s %d typ host generation 0\r\n",
+
+ switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "a=candidate:%s 2 %s %u %s %d typ host generation 0\r\n",
tmp1, ice_out->cands[0][0].transport, c1,
ice_out->cands[0][0].con_addr, ice_out->cands[0][0].con_port + (a_engine->rtcp_mux > 0 ? 0 : 1)
);
if (!zstr(a_engine->local_sdp_ip) && !zstr(ice_out->cands[0][1].con_addr) &&
strcmp(a_engine->local_sdp_ip, ice_out->cands[0][1].con_addr)
&& a_engine->local_sdp_port != ice_out->cands[0][1].con_port) {
-
- switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "a=candidate:%s 2 %s %u %s %d typ srflx raddr %s rport %d generation 0\r\n",
+
+ switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "a=candidate:%s 2 %s %u %s %d typ srflx raddr %s rport %d generation 0\r\n",
tmp2, ice_out->cands[0][0].transport, c2,
ice_out->cands[0][0].con_addr, ice_out->cands[0][0].con_port + (a_engine->rtcp_mux > 0 ? 0 : 1),
a_engine->local_sdp_ip, a_engine->local_sdp_port + (a_engine->rtcp_mux > 0 ? 0 : 1)
}
}
-
-
+
+
#ifdef GOOGLE_ICE
switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "a=ice-options:google-ice\r\n");
#endif
//}
}
} else {
- if (switch_media_handle_test_media_flag(smh, SCMF_SUPPRESS_CNG)) {
+ if (switch_media_handle_test_media_flag(smh, SCMF_SUPPRESS_CNG)) {
switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "a=silenceSupp:off - - - -\r\n");
}
}
if (!cur_ptime) {
cur_ptime = ptime;
}
-
+
if (!noptime && cur_ptime) {
switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "a=ptime:%d\r\n", cur_ptime);
}
}
//?
-SWITCH_DECLARE(void) switch_core_media_check_dtmf_type(switch_core_session_t *session)
+SWITCH_DECLARE(void) switch_core_media_check_dtmf_type(switch_core_session_t *session)
{
const char *val;
switch_media_handle_t *smh;
for (m = sdp->sdp_media; m; m = m->m_next) {
if (m->m_proto == sdp_proto_rtp) {
sdp_rtpmap_t *map;
-
+
for (map = m->m_rtpmaps; map; map = map->rm_next) {
if (map->rm_encoding) {
char buf[25] = "";
} else {
switch_snprintf(key, sizeof(key), "%s", map->rm_encoding);
}
-
+
switch_event_add_header_string(*pt, SWITCH_STACK_BOTTOM, key, buf);
if (map->rm_fmtp) {
}
}
}
-
+
sdp_parser_free(parser);
return SWITCH_STATUS_SUCCESS;
-
+
}
//?
if (is_outbound || switch_channel_test_flag(session->channel, CF_RECOVERING) ||
switch_channel_test_flag(session->channel, CF_3PCC)) {
- if (!switch_channel_test_flag(session->channel, CF_AVPF) &&
+ if (!switch_channel_test_flag(session->channel, CF_AVPF) &&
switch_true(switch_channel_get_variable(session->channel, "media_webrtc"))) {
switch_channel_set_flag(session->channel, CF_AVPF);
switch_channel_set_flag(session->channel, CF_ICE);
switch_zmalloc(buf, SDPBUFLEN);
-
+
switch_core_media_check_dtmf_type(session);
if (switch_media_handle_test_media_flag(smh, SCMF_SUPPRESS_CNG) ||
smh->mparams->cng_pt = 0;
}
-
+
if (!smh->payload_space) {
int i;
- /* it could be 98 but chrome reserves 98 and 99 for some internal stuff even though they should not.
+ /* it could be 98 but chrome reserves 98 and 99 for some internal stuff even though they should not.
Everyone expects dtmf to be at 101 and Its not worth the trouble so we'll start at 102 */
smh->payload_space = 102;
memset(smh->rates, 0, sizeof(smh->rates));
if (smh->rates[j] == 0) {
break;
}
-
+
if (smh->rates[j] == smh->codecs[i]->samples_per_second) {
goto do_next;
}
}
-
+
smh->rates[smh->num_rates++] = smh->codecs[i]->samples_per_second;
}
-
+
do_next:
continue;
}
-
+
if (sdp_type == SDP_TYPE_REQUEST) {
switch_core_session_t *orig_session = NULL;
- switch_core_session_get_partner(session, &orig_session);
+ switch_core_session_get_partner(session, &orig_session);
for (i = 0; i < smh->mparams->num_codecs; i++) {
const switch_codec_implementation_t *imp = smh->codecs[i];
smh->payload_space++;
}
- if (orig_session &&
- switch_core_session_get_payload_code(orig_session,
+ if (orig_session &&
+ switch_core_session_get_payload_code(orig_session,
imp->codec_type == SWITCH_CODEC_TYPE_AUDIO ? SWITCH_MEDIA_TYPE_AUDIO : SWITCH_MEDIA_TYPE_VIDEO,
imp->iananame, imp->samples_per_second, smh->fmtp[i], &orig_pt, NULL, &orig_fmtp) == SWITCH_STATUS_SUCCESS) {
}
smh->ianacodes[i] = orig_pt;
-
+
if (!zstr(orig_fmtp)) {
smh->fmtps[i] = switch_core_session_strdup(session, orig_fmtp);
}
imp->number_of_channels,
SWITCH_FALSE);
}
-
+
for (i = 0; i < smh->num_rates; i++) {
if (smh->rates[i] == 8000 || smh->num_rates == 1) {
smh->dtmf_ianacodes[i] = smh->mparams->te;
smh->cng_ianacodes[i] = (switch_payload_t)smh->payload_space++;
}
}
-
+
if (orig_session) {
switch_core_session_rwunlock(orig_session);
}
smh->session_id++;
-
+
if ((smh->mparams->ndlb & SM_NDLB_SENDRECV_IN_SESSION) ||
((var_val = switch_channel_get_variable(session->channel, "ndlb_sendrecv_in_session")) && switch_true(var_val))) {
if (!zstr(sr)) {
"v=0\r\n"
"o=%s %010u %010u IN %s %s\r\n"
"s=%s\r\n"
- "c=IN %s %s\r\n"
+ "c=IN %s %s\r\n"
"t=0 0\r\n"
"%s",
username, smh->owner_id, smh->session_id, family, ip, username, family, ip, srbuf);
}
if (a_engine->codec_negotiated) {
- switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "m=audio %d %s", port,
- get_media_profile_name(session, !a_engine->no_crypto &&
+ switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "m=audio %d %s", port,
+ get_media_profile_name(session, !a_engine->no_crypto &&
(switch_channel_test_flag(session->channel, CF_DTLS) || a_engine->crypto_type != CRYPTO_INVALID)));
-
-
+
+
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), " %d", a_engine->cur_payload_map->pt);
-
+
if (switch_media_handle_test_media_flag(smh, SCMF_MULTI_ANSWER_AUDIO)) {
switch_mutex_lock(smh->sdp_mutex);
for (pmap = a_engine->cur_payload_map; pmap && pmap->allocated; pmap = pmap->next) {
switch_mutex_unlock(smh->sdp_mutex);
}
- if ((smh->mparams->dtmf_type == DTMF_2833 || switch_media_handle_test_media_flag(smh, SCMF_LIBERAL_DTMF) ||
+ if ((smh->mparams->dtmf_type == DTMF_2833 || switch_media_handle_test_media_flag(smh, SCMF_LIBERAL_DTMF) ||
switch_channel_test_flag(session->channel, CF_LIBERAL_DTMF)) && smh->mparams->te > 95) {
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), " %d", smh->mparams->te);
}
-
+
if (!switch_media_handle_test_media_flag(smh, SCMF_SUPPRESS_CNG) && smh->mparams->cng_pt && use_cng) {
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), " %d", smh->mparams->cng_pt);
}
-
+
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "\r\n");
if (!a_engine->cur_payload_map->adv_channels) {
a_engine->cur_payload_map->adv_channels = get_channels(a_engine->cur_payload_map->rm_encoding, 1);
}
-
+
if (a_engine->cur_payload_map->adv_channels > 1) {
- switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=rtpmap:%d %s/%d/%d\r\n",
+ switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=rtpmap:%d %s/%d/%d\r\n",
a_engine->cur_payload_map->pt, a_engine->cur_payload_map->rm_encoding, rate, a_engine->cur_payload_map->adv_channels);
} else {
- switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=rtpmap:%d %s/%d\r\n",
+ switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=rtpmap:%d %s/%d\r\n",
a_engine->cur_payload_map->pt, a_engine->cur_payload_map->rm_encoding, rate);
}
}
- if ((smh->mparams->dtmf_type == DTMF_2833 || switch_media_handle_test_media_flag(smh, SCMF_LIBERAL_DTMF) ||
+ if ((smh->mparams->dtmf_type == DTMF_2833 || switch_media_handle_test_media_flag(smh, SCMF_LIBERAL_DTMF) ||
switch_channel_test_flag(session->channel, CF_LIBERAL_DTMF))
&& smh->mparams->te > 95) {
if (switch_channel_test_flag(session->channel, CF_AVPF)) {
- switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=rtpmap:%d telephone-event/%d\r\n",
+ switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=rtpmap:%d telephone-event/%d\r\n",
smh->mparams->te, smh->mparams->te_rate);
} else {
- switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=rtpmap:%d telephone-event/%d\r\na=fmtp:%d 0-16\r\n",
+ switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=rtpmap:%d telephone-event/%d\r\na=fmtp:%d 0-16\r\n",
smh->mparams->te, smh->mparams->te_rate, smh->mparams->te);
}
}
if (!zstr(sr)) {
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=%s\r\n", sr);
}
-
+
if (!zstr(a_engine->local_dtls_fingerprint.type)) {
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=fingerprint:%s %s\na=setup:%s\r\n",
- a_engine->local_dtls_fingerprint.type,
+ a_engine->local_dtls_fingerprint.type,
a_engine->local_dtls_fingerprint.str, get_setup(a_engine, session, sdp_type));
}
-
+
if (smh->mparams->rtcp_audio_interval_msec) {
if (a_engine->rtcp_mux > 0) {
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=rtcp-mux\r\n");
switch_stun_random_string(tmp3, 10, "0123456789");
ice_out = &a_engine->ice_out;
-
-
+
+
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ice-ufrag:%s\r\n", ice_out->ufrag);
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ice-pwd:%s\r\n", ice_out->pwd);
- switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=candidate:%s 1 %s %u %s %d typ host generation 0\r\n",
+ switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=candidate:%s 1 %s %u %s %d typ host generation 0\r\n",
tmp1, ice_out->cands[0][0].transport, c1,
ice_out->cands[0][0].con_addr, ice_out->cands[0][0].con_port
);
strcmp(a_engine->local_sdp_ip, ice_out->cands[0][0].con_addr)
&& a_engine->local_sdp_port != ice_out->cands[0][0].con_port) {
- switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=candidate:%s 1 %s %u %s %d typ srflx raddr %s rport %d generation 0\r\n",
+ switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=candidate:%s 1 %s %u %s %d typ srflx raddr %s rport %d generation 0\r\n",
tmp2, ice_out->cands[0][0].transport, c3,
ice_out->cands[0][0].con_addr, ice_out->cands[0][0].con_port,
a_engine->local_sdp_ip, a_engine->local_sdp_port
if (a_engine->rtcp_mux < 1 || is_outbound || switch_channel_test_flag(session->channel, CF_RECOVERING)) {
- switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=candidate:%s 2 %s %u %s %d typ host generation 0\r\n",
+ switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=candidate:%s 2 %s %u %s %d typ host generation 0\r\n",
tmp1, ice_out->cands[0][0].transport, c2,
ice_out->cands[0][0].con_addr, ice_out->cands[0][0].con_port + (a_engine->rtcp_mux > 0 ? 0 : 1)
);
-
+
if (include_external && !zstr(smh->mparams->extsipip)) {
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=candidate:%s 2 %s %u %s %d typ host generation 0\n",
tmp3, ice_out->cands[0][0].transport, c2,
);
}
-
- if (!zstr(a_engine->local_sdp_ip) && !zstr(ice_out->cands[0][0].con_addr) &&
+
+
+ if (!zstr(a_engine->local_sdp_ip) && !zstr(ice_out->cands[0][0].con_addr) &&
strcmp(a_engine->local_sdp_ip, ice_out->cands[0][0].con_addr)
- && a_engine->local_sdp_port != ice_out->cands[0][0].con_port) {
-
- switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=candidate:%s 2 %s %u %s %d typ srflx raddr %s rport %d generation 0\r\n",
+ && a_engine->local_sdp_port != ice_out->cands[0][0].con_port) {
+
+ switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=candidate:%s 2 %s %u %s %d typ srflx raddr %s rport %d generation 0\r\n",
tmp2, ice_out->cands[0][0].transport, c4,
ice_out->cands[0][0].con_addr, ice_out->cands[0][0].con_port + (a_engine->rtcp_mux > 0 ? 0 : 1),
a_engine->local_sdp_ip, a_engine->local_sdp_port + (a_engine->rtcp_mux > 0 ? 0 : 1)
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ssrc:%u mslabel:%s\r\n", a_engine->ssrc, smh->msid);
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ssrc:%u label:%sa0\r\n", a_engine->ssrc, smh->msid);
-
+
#ifdef GOOGLE_ICE
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ice-options:google-ice\r\n");
#endif
if (a_engine->reject_avp) {
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "m=audio 0 RTP/AVP 19\r\n");
}
-
+
} else if (smh->mparams->num_codecs) {
int i;
int cur_ptime = 0, this_ptime = 0, cng_type = 0;
smh->mparams->cng_pt = 0;
}
}
-
+
mult = switch_channel_get_variable(session->channel, "sdp_m_per_ptime");
if (switch_channel_test_flag(session->channel, CF_AVPF) || (mult && switch_false(mult))) {
char *bp = buf;
int both = (switch_channel_test_flag(session->channel, CF_AVPF) || switch_channel_test_flag(session->channel, CF_DTLS)) ? 0 : 1;
- if ((!a_engine->no_crypto && switch_channel_test_flag(session->channel, CF_SECURE)) ||
+ if ((!a_engine->no_crypto && switch_channel_test_flag(session->channel, CF_SECURE)) ||
switch_channel_test_flag(session->channel, CF_DTLS)) {
generate_m(session, buf, SDPBUFLEN, port, family, ip, 0, append_audio, sr, use_cng, cng_type, map, 1, sdp_type);
bp = (buf + strlen(buf));
for (i = 0; i < smh->mparams->num_codecs; i++) {
const switch_codec_implementation_t *imp = smh->codecs[i];
-
+
if (imp->codec_type != SWITCH_CODEC_TYPE_AUDIO) {
continue;
}
-
+
this_ptime = imp->microseconds_per_packet / 1000;
-
+
if (!strcasecmp(imp->iananame, "ilbc") || !strcasecmp(imp->iananame, "isac")) {
this_ptime = 20;
}
-
+
if (cur_ptime != this_ptime) {
char *bp = buf;
int both = 1;
- cur_ptime = this_ptime;
-
- if ((!a_engine->no_crypto && switch_channel_test_flag(session->channel, CF_SECURE)) ||
+ cur_ptime = this_ptime;
+
+ if ((!a_engine->no_crypto && switch_channel_test_flag(session->channel, CF_SECURE)) ||
switch_channel_test_flag(session->channel, CF_DTLS)) {
generate_m(session, bp, SDPBUFLEN - strlen(buf), port, family, ip, cur_ptime, append_audio, sr, use_cng, cng_type, map, 1, sdp_type);
bp = (buf + strlen(buf));
generate_m(session, bp, SDPBUFLEN - strlen(buf), port, family, ip, cur_ptime, append_audio, sr, use_cng, cng_type, map, 0, sdp_type);
}
}
-
+
}
}
for (i = 0; i < smh->mparams->num_codecs; i++) {
const switch_codec_implementation_t *imp = smh->codecs[i];
-
-
+
+
if (imp->codec_type == SWITCH_CODEC_TYPE_VIDEO) {
has_vid = 1;
break;
if (!has_vid) {
if (switch_channel_test_flag(session->channel, CF_VIDEO_SDP_RECVD)) {
switch_channel_clear_flag(session->channel, CF_VIDEO_SDP_RECVD);
- switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "m=video 0 %s 19\r\n",
- get_media_profile_name(session,
- (switch_channel_test_flag(session->channel, CF_SECURE)
- && switch_channel_direction(session->channel) == SWITCH_CALL_DIRECTION_OUTBOUND) ||
+ switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "m=video 0 %s 19\r\n",
+ get_media_profile_name(session,
+ (switch_channel_test_flag(session->channel, CF_SECURE)
+ && switch_channel_direction(session->channel) == SWITCH_CALL_DIRECTION_OUTBOUND) ||
a_engine->crypto_type != CRYPTO_INVALID || switch_channel_test_flag(session->channel, CF_DTLS)));
}
} else {
}
}
-
+
if (!v_engine->local_sdp_port) {
switch_core_media_choose_port(session, SWITCH_MEDIA_TYPE_VIDEO, 0);
}
}
- switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "m=video %d %s",
- v_port,
- get_media_profile_name(session,
- (loops == 0 && switch_channel_test_flag(session->channel, CF_SECURE)
- && switch_channel_direction(session->channel) == SWITCH_CALL_DIRECTION_OUTBOUND) ||
+ switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "m=video %d %s",
+ v_port,
+ get_media_profile_name(session,
+ (loops == 0 && switch_channel_test_flag(session->channel, CF_SECURE)
+ && switch_channel_direction(session->channel) == SWITCH_CALL_DIRECTION_OUTBOUND) ||
a_engine->crypto_type != CRYPTO_INVALID || switch_channel_test_flag(session->channel, CF_DTLS)));
-
-
-
+
+
+
/*****************************/
if (v_engine->codec_negotiated) {
payload_map_t *pmap;
switch_core_media_set_video_codec(session, 0);
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), " %d", v_engine->cur_payload_map->pt);
-
+
if (switch_media_handle_test_media_flag(smh, SCMF_MULTI_ANSWER_VIDEO)) {
switch_mutex_lock(smh->sdp_mutex);
for (pmap = v_engine->cur_payload_map; pmap && pmap->allocated; pmap = pmap->next) {
int already_did[128] = { 0 };
for (i = 0; i < smh->mparams->num_codecs; i++) {
const switch_codec_implementation_t *imp = smh->codecs[i];
-
+
if (imp->codec_type != SWITCH_CODEC_TYPE_VIDEO) {
continue;
}
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "\r\n");
-
+
if (!(vbw = switch_channel_get_variable(smh->session->channel, "rtp_video_max_bandwidth"))) {
vbw = switch_channel_get_variable(smh->session->channel, "rtp_video_max_bandwidth_in");
}
bw = switch_parse_bandwidth_string(vbw);
-
+
if (bw > 0) {
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "b=AS:%d\r\n", bw);
//switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "b=TIAS:%d\r\n", bw);
if (!rate) {
rate = imp->samples_per_second;
}
-
+
channels = get_channels(imp->iananame, imp->number_of_channels);
//if (!strcasecmp(imp->iananame, "VP8")) {
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=rtpmap:%d %s/%d\r\n", ianacode, imp->iananame,
imp->samples_per_second);
}
-
+
if (!zstr(ov_fmtp)) {
fmtp = (char *) ov_fmtp;
} else {
-
+
if (map) {
fmtp = switch_event_get_header(map, imp->iananame);
}
-
+
if (!zstr(smh->fmtp[i])) {
fmtp = smh->fmtp[i];
} else if (smh->fmtps[i]) {
fmtp = smh->fmtps[i];
}
-
+
if (zstr(fmtp)) fmtp = imp->fmtp;
if (zstr(fmtp)) fmtp = (char *) pass_fmtp;
}
-
+
if (!zstr(fmtp) && strcasecmp(fmtp, "_blank_")) {
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=fmtp:%d %s\r\n", ianacode, fmtp);
}
}
-
+
}
if ((is_outbound || switch_channel_test_flag(session->channel, CF_RECOVERING))
if (v_engine->codec_negotiated) {
- add_fb(buf, SDPBUFLEN, v_engine->cur_payload_map->pt, v_engine->fir || fir,
+ add_fb(buf, SDPBUFLEN, v_engine->cur_payload_map->pt, v_engine->fir || fir,
v_engine->nack || nack, v_engine->pli || pli, v_engine->tmmbr || tmmbr);
if (switch_media_handle_test_media_flag(smh, SCMF_MULTI_ANSWER_VIDEO)) {
}
switch_mutex_unlock(smh->sdp_mutex);
}
-
+
} else if (smh->mparams->num_codecs) {
int i;
int already_did[128] = { 0 };
for (i = 0; i < smh->mparams->num_codecs; i++) {
const switch_codec_implementation_t *imp = smh->codecs[i];
-
+
if (imp->codec_type != SWITCH_CODEC_TYPE_VIDEO) {
continue;
add_fb(buf, SDPBUFLEN, smh->ianacodes[i], v_engine->fir || fir, v_engine->nack || nack, v_engine->pli || pli, v_engine->pli || pli);
}
-
+
}
-
+
//switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ssrc:%u\r\n", v_engine->ssrc);
if (v_engine->ice_out.cands[0][0].ready) {
uint32_t c2 = c1 - 1;
uint32_t c3 = c1 - 2;
uint32_t c4 = c1 - 3;
-
+
tmp1[10] = '\0';
tmp2[10] = '\0';
tmp3[10] = '\0';
switch_stun_random_string(tmp3, 10, "0123456789");
ice_out = &v_engine->ice_out;
-
-
+
+
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ssrc:%u cname:%s\r\n", v_engine->ssrc, smh->cname);
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ssrc:%u msid:%s v0\r\n", v_engine->ssrc, smh->msid);
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ssrc:%u mslabel:%s\r\n", v_engine->ssrc, smh->msid);
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ssrc:%u label:%sv0\r\n", v_engine->ssrc, smh->msid);
-
-
+
+
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ice-ufrag:%s\r\n", ice_out->ufrag);
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ice-pwd:%s\r\n", ice_out->pwd);
- switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=candidate:%s 1 %s %u %s %d typ host generation 0\r\n",
+ switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=candidate:%s 1 %s %u %s %d typ host generation 0\r\n",
tmp1, ice_out->cands[0][0].transport, c1,
ice_out->cands[0][0].con_addr, ice_out->cands[0][0].con_port
);
strcmp(v_engine->local_sdp_ip, ice_out->cands[0][0].con_addr)
&& v_engine->local_sdp_port != ice_out->cands[0][0].con_port) {
- switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=candidate:%s 1 %s %u %s %d typ srflx raddr %s rport %d generation 0\r\n",
+ switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=candidate:%s 1 %s %u %s %d typ srflx raddr %s rport %d generation 0\r\n",
tmp2, ice_out->cands[0][0].transport, c3,
ice_out->cands[0][0].con_addr, ice_out->cands[0][0].con_port,
v_engine->local_sdp_ip, v_engine->local_sdp_port
if (v_engine->rtcp_mux < 1 || is_outbound || switch_channel_test_flag(session->channel, CF_RECOVERING)) {
- switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=candidate:%s 2 %s %u %s %d typ host generation 0\r\n",
+ switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=candidate:%s 2 %s %u %s %d typ host generation 0\r\n",
tmp1, ice_out->cands[0][0].transport, c2,
ice_out->cands[0][0].con_addr, ice_out->cands[0][0].con_port + (v_engine->rtcp_mux > 0 ? 0 : 1)
);
-
+
if (include_external && !zstr(smh->mparams->extsipip)) {
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=candidate:%s 2 %s %u %s %d typ host generation 0\n",
tmp3, ice_out->cands[0][0].transport, c2,
if (!zstr(v_engine->local_sdp_ip) && !zstr(ice_out->cands[0][1].con_addr) &&
strcmp(v_engine->local_sdp_ip, ice_out->cands[0][1].con_addr)
&& v_engine->local_sdp_port != ice_out->cands[0][1].con_port) {
-
- switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=candidate:%s 2 %s %u %s %d typ srflx generation 0\r\n",
+
+ switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=candidate:%s 2 %s %u %s %d typ srflx generation 0\r\n",
tmp2, ice_out->cands[0][0].transport, c4,
ice_out->cands[0][0].con_addr, ice_out->cands[0][0].con_port + (v_engine->rtcp_mux > 0 ? 0 : 1),
v_engine->local_sdp_ip, v_engine->local_sdp_port + (v_engine->rtcp_mux > 0 ? 0 : 1)
}
}
-
-
+
+
#ifdef GOOGLE_ICE
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ice-options:google-ice\r\n");
#endif
}
-
+
if (loops == 0 && switch_channel_test_flag(session->channel, CF_SECURE) && !switch_channel_test_flag(session->channel, CF_DTLS)) {
int i;
-
+
for (i = 0; smh->crypto_suite_order[i] != CRYPTO_INVALID; i++) {
switch_rtp_crypto_key_type_t j = SUITES[smh->crypto_suite_order[i]].type;
-
+
if ((a_engine->crypto_type == j || a_engine->crypto_type == CRYPTO_INVALID) && !zstr(a_engine->ssec[j].local_crypto_key)) {
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=crypto:%s\r\n", v_engine->ssec[j].local_crypto_key);
}
}
- if (switch_channel_test_flag(session->channel, CF_DTLS) ||
- !switch_channel_test_flag(session->channel, CF_SECURE) ||
+ if (switch_channel_test_flag(session->channel, CF_DTLS) ||
+ !switch_channel_test_flag(session->channel, CF_SECURE) ||
smh->crypto_mode == CRYPTO_MODE_MANDATORY || smh->crypto_mode == CRYPTO_MODE_FORBIDDEN) {
break;
}
if (!want_msrps) {
want_msrps = switch_channel_test_flag(session->channel, CF_WANT_MSRPS);
}
-
+
if (want_msrp || want_msrps) {
smh->msrp_session = switch_msrp_session_new(switch_core_session_get_pool(session), switch_core_session_get_uuid(session), want_msrps);
switch_core_session_start_text_thread(session);
}
}
-
+
if (smh->msrp_session) {
switch_msrp_session_t *msrp_session = smh->msrp_session;
"a=sendonly\na=file-selector:%s\n", file_selector);
}
}
- }
+ }
// RTP TEXT
if (sdp_type == SDP_TYPE_RESPONSE && !switch_channel_test_flag(session->channel, CF_RTT)) {
if (switch_channel_test_flag(session->channel, CF_TEXT_SDP_RECVD)) {
switch_channel_clear_flag(session->channel, CF_TEXT_SDP_RECVD);
- switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "m=text 0 %s 19\r\n",
- get_media_profile_name(session,
- (switch_channel_test_flag(session->channel, CF_SECURE)
- && switch_channel_direction(session->channel) == SWITCH_CALL_DIRECTION_OUTBOUND) ||
+ switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "m=text 0 %s 19\r\n",
+ get_media_profile_name(session,
+ (switch_channel_test_flag(session->channel, CF_SECURE)
+ && switch_channel_direction(session->channel) == SWITCH_CALL_DIRECTION_OUTBOUND) ||
a_engine->crypto_type != CRYPTO_INVALID || switch_channel_test_flag(session->channel, CF_DTLS)));
}
- } else if ((switch_channel_test_flag(session->channel, CF_WANT_RTT) || switch_channel_test_flag(session->channel, CF_RTT) ||
+ } else if ((switch_channel_test_flag(session->channel, CF_WANT_RTT) || switch_channel_test_flag(session->channel, CF_RTT) ||
switch_channel_var_true(session->channel, "rtp_enable_text")) &&
switch_channel_test_cap(session->channel, CC_RTP_RTT)) {
t_engine->t140_pt = 0;
}
}
-
+
if (!t_engine->local_sdp_port) {
switch_core_media_choose_port(session, SWITCH_MEDIA_TYPE_TEXT, 0);
}
}
- switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "m=text %d %s",
- t_port,
- get_media_profile_name(session,
- (loops == 0 && switch_channel_test_flag(session->channel, CF_SECURE)
- && switch_channel_direction(session->channel) == SWITCH_CALL_DIRECTION_OUTBOUND) ||
+ switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "m=text %d %s",
+ t_port,
+ get_media_profile_name(session,
+ (loops == 0 && switch_channel_test_flag(session->channel, CF_SECURE)
+ && switch_channel_direction(session->channel) == SWITCH_CALL_DIRECTION_OUTBOUND) ||
a_engine->crypto_type != CRYPTO_INVALID || switch_channel_test_flag(session->channel, CF_DTLS)));
-
-
+
+
/*****************************/
if (t_engine->codec_negotiated) {
-
+
switch_mutex_lock(smh->sdp_mutex);
for (pmap = t_engine->payload_map; pmap && pmap->allocated; pmap = pmap->next) {
}
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), " %d", pmap->pt);
-
+
}
switch_mutex_unlock(smh->sdp_mutex);
}
if (pmap->type != SWITCH_MEDIA_TYPE_TEXT || !pmap->negotiated) {
continue;
}
-
+
if (!strcasecmp(pmap->iananame, "t140")) {
t_engine->t140_pt = pmap->pt;
}
if (!strcasecmp(pmap->iananame, "red")) {
t_engine->red_pt = pmap->pt;
}
-
+
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=rtpmap:%d %s/%ld\r\n",
pmap->pt, pmap->iananame, pmap->rate);
-
+
}
switch_mutex_unlock(smh->sdp_mutex);
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=fmtp:%d %d/%d/%d\r\n", t_engine->red_pt, t_engine->t140_pt, t_engine->t140_pt, t_engine->t140_pt);
}
-
+
if (t_engine->smode == SWITCH_MEDIA_FLOW_SENDONLY) {
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "%s", "a=sendonly\r\n");
} else if (t_engine->smode == SWITCH_MEDIA_FLOW_RECVONLY) {
if (!zstr(t_engine->local_dtls_fingerprint.type)) {
- switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=fingerprint:%s %s\na=setup:%s\r\n", t_engine->local_dtls_fingerprint.type,
+ switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=fingerprint:%s %s\na=setup:%s\r\n", t_engine->local_dtls_fingerprint.type,
t_engine->local_dtls_fingerprint.str, get_setup(t_engine, session, sdp_type));
}
}
//switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ssrc:%u\r\n", t_engine->ssrc);
-
+
if (t_engine->ice_out.cands[0][0].ready) {
char tmp1[11] = "";
char tmp2[11] = "";
uint32_t c2 = c1 - 1;
uint32_t c3 = c1 - 2;
uint32_t c4 = c1 - 3;
-
+
tmp1[10] = '\0';
tmp2[10] = '\0';
switch_stun_random_string(tmp1, 10, "0123456789");
switch_stun_random_string(tmp2, 10, "0123456789");
ice_out = &t_engine->ice_out;
-
-
+
+
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ssrc:%u cname:%s\r\n", t_engine->ssrc, smh->cname);
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ssrc:%u msid:%s v0\r\n", t_engine->ssrc, smh->msid);
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ssrc:%u mslabel:%s\r\n", t_engine->ssrc, smh->msid);
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ssrc:%u label:%sv0\r\n", t_engine->ssrc, smh->msid);
-
-
+
+
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ice-ufrag:%s\r\n", ice_out->ufrag);
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ice-pwd:%s\r\n", ice_out->pwd);
- switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=candidate:%s 1 %s %u %s %d typ host generation 0\r\n",
+ switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=candidate:%s 1 %s %u %s %d typ host generation 0\r\n",
tmp1, ice_out->cands[0][0].transport, c1,
ice_out->cands[0][0].con_addr, ice_out->cands[0][0].con_port
);
- if (!zstr(t_engine->local_sdp_ip) && !zstr(ice_out->cands[0][0].con_addr) &&
+ if (!zstr(t_engine->local_sdp_ip) && !zstr(ice_out->cands[0][0].con_addr) &&
strcmp(t_engine->local_sdp_ip, ice_out->cands[0][0].con_addr)
&& t_engine->local_sdp_port != ice_out->cands[0][0].con_port) {
- switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=candidate:%s 1 %s %u %s %d typ srflx raddr %s rport %d generation 0\r\n",
+ switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=candidate:%s 1 %s %u %s %d typ srflx raddr %s rport %d generation 0\r\n",
tmp2, ice_out->cands[0][0].transport, c3,
ice_out->cands[0][0].con_addr, ice_out->cands[0][0].con_port,
t_engine->local_sdp_ip, t_engine->local_sdp_port
if (t_engine->rtcp_mux < 1 || is_outbound || switch_channel_test_flag(session->channel, CF_RECOVERING)) {
- switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=candidate:%s 2 %s %u %s %d typ host generation 0\r\n",
+ switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=candidate:%s 2 %s %u %s %d typ host generation 0\r\n",
tmp1, ice_out->cands[0][0].transport, c2,
ice_out->cands[0][0].con_addr, ice_out->cands[0][0].con_port + (t_engine->rtcp_mux > 0 ? 0 : 1)
);
-
-
- if (!zstr(t_engine->local_sdp_ip) && !zstr(ice_out->cands[0][1].con_addr) &&
+
+
+ if (!zstr(t_engine->local_sdp_ip) && !zstr(ice_out->cands[0][1].con_addr) &&
strcmp(t_engine->local_sdp_ip, ice_out->cands[0][1].con_addr)
&& t_engine->local_sdp_port != ice_out->cands[0][1].con_port) {
-
- switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=candidate:%s 2 %s %u %s %d typ srflx generation 0\r\n",
+
+ switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=candidate:%s 2 %s %u %s %d typ srflx generation 0\r\n",
tmp2, ice_out->cands[0][0].transport, c4,
ice_out->cands[0][0].con_addr, ice_out->cands[0][0].con_port + (t_engine->rtcp_mux > 0 ? 0 : 1),
t_engine->local_sdp_ip, t_engine->local_sdp_port + (t_engine->rtcp_mux > 0 ? 0 : 1)
}
}
-
-
+
+
#ifdef GOOGLE_ICE
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ice-options:google-ice\r\n");
#endif
}
-
+
if (loops == 0 && switch_channel_test_flag(session->channel, CF_SECURE) && !switch_channel_test_flag(session->channel, CF_DTLS)) {
int i;
-
+
for (i = 0; smh->crypto_suite_order[i] != CRYPTO_INVALID; i++) {
switch_rtp_crypto_key_type_t j = SUITES[smh->crypto_suite_order[i]].type;
-
+
if ((t_engine->crypto_type == j || t_engine->crypto_type == CRYPTO_INVALID) && !zstr(t_engine->ssec[j].local_crypto_key)) {
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=crypto:%s\r\n", t_engine->ssec[j].local_crypto_key);
}
}
- if (switch_channel_test_flag(session->channel, CF_DTLS) ||
- !switch_channel_test_flag(session->channel, CF_SECURE) ||
+ if (switch_channel_test_flag(session->channel, CF_DTLS) ||
+ !switch_channel_test_flag(session->channel, CF_SECURE) ||
smh->crypto_mode == CRYPTO_MODE_MANDATORY || smh->crypto_mode == CRYPTO_MODE_FORBIDDEN) {
break;
}
if (map) {
switch_event_destroy(&map);
}
-
+
if (ptmap) {
switch_event_destroy(&ptmap);
}
const char *username;
const char *bit_removal_on = "a=T38FaxFillBitRemoval\r\n";
const char *bit_removal_off = "";
-
+
const char *mmr_on = "a=T38FaxTranscodingMMR\r\n";
const char *mmr_off = "";
username = smh->mparams->sdp_username;
var = switch_channel_get_variable(session->channel, "t38_broken_boolean");
-
+
broken_boolean = switch_true(var);
};
-
+
if (broken_boolean) {
bit_removal_on = "a=T38FaxFillBitRemoval:1\r\n";
q += 7;
strncpy(q, strchr(a_engine->adv_sdp_ip, ':') ? "6 " : "4 ", 2);
p +=2;
- q +=2;
+ q +=2;
strncpy(q, a_engine->adv_sdp_ip, strlen(a_engine->adv_sdp_ip));
q += strlen(a_engine->adv_sdp_ip);
v_engine->cur_payload_map = pmap;
switch_snprintf(vport_buf, sizeof(vport_buf), "%u", v_engine->adv_sdp_port);
-
+
if (switch_channel_media_ready(session->channel) && !switch_rtp_ready(v_engine->rtp_session)) {
switch_channel_set_flag(session->channel, CF_VIDEO_POSSIBLE);
switch_channel_set_flag(session->channel, CF_REINVITE);
t_engine->cur_payload_map = pmap;
switch_snprintf(tport_buf, sizeof(tport_buf), "%u", t_engine->adv_sdp_port);
-
+
if (switch_channel_media_ready(session->channel) && !switch_rtp_ready(t_engine->rtp_session)) {
switch_channel_set_flag(session->channel, CF_TEXT_POSSIBLE);
switch_channel_set_flag(session->channel, CF_REINVITE);
SWITCH_DECLARE(void) switch_core_media_hard_mute(switch_core_session_t *session, switch_bool_t on)
{
switch_core_session_message_t msg = { 0 };
-
+
msg.from = __FILE__;
msg.message_id = SWITCH_MESSAGE_INDICATE_HARD_MUTE;
dtls_state_t dtls_state = switch_rtp_dtls_state(engine->rtp_session, DTLS_TYPE_RTP);
int flags = 0;
switch_status_t status;
-
+
if (dtls_state == DS_READY || dtls_state >= DS_FAIL) return 0;
status = switch_rtp_zerocopy_read_frame(engine->rtp_session, &engine->read_frame, flags);
-
+
if (!SWITCH_READ_ACCEPTABLE(status)) {
return 0;
}
if (!switch_channel_test_flag(session->channel, CF_DTLS)) {
return SWITCH_TRUE;
}
-
+
engine = &smh->engines[type];
if (engine->rmode == SWITCH_MEDIA_FLOW_DISABLED) {
do {
if (engine->rtp_session) checking = check_engine(engine);
} while (switch_channel_ready(session->channel) && checking);
-
+
if (!checking) {
return SWITCH_TRUE;
}
-
+
return SWITCH_FALSE;
}
engine = &smh->engines[type];
if (switch_core_codec_ready(&engine->write_codec)) {
- status = switch_core_codec_control(&engine->write_codec, SCC_VIDEO_BANDWIDTH,
+ status = switch_core_codec_control(&engine->write_codec, SCC_VIDEO_BANDWIDTH,
SCCT_INT, &bitrate, SCCT_NONE, NULL, NULL, NULL);
}
-
+
return status;
}
switch_channel_audio_sync(session->channel);
switch_rtp_reset_jb(a_engine->rtp_session);
}
-
+
if (switch_channel_test_flag(session->channel, CF_CONFERENCE)) {
switch_channel_set_flag(session->channel, CF_CONFERENCE_RESET_MEDIA);
}
}
break;
-
+
case SWITCH_MESSAGE_INDICATE_HOLD:
{
if (a_engine && a_engine->rtp_session) {
case SWITCH_MESSAGE_INDICATE_HARD_MUTE:
if (a_engine->rtp_session) {
if (session->bugs && msg->numeric_arg) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
"%s has a media bug, hard mute not allowed.\n", switch_channel_get_name(session->channel));
} else {
if (msg->numeric_arg) {
switch_rtp_clear_flag(a_engine->rtp_session, SWITCH_RTP_FLAG_MUTE);
}
- rtp_flush_read_buffer(a_engine->rtp_session, SWITCH_RTP_FLUSH_ONCE);
+ rtp_flush_read_buffer(a_engine->rtp_session, SWITCH_RTP_FLUSH_ONCE);
}
}
{
switch_rtp_engine_t *engine = &smh->engines[msg->numeric_reply];
uint32_t level = (uint32_t) msg->numeric_arg;
-
+
if (engine->rtp_session) {
switch_core_codec_control(&engine->read_codec, SCC_DEBUG, SCCT_INT, (void *)&level, SCCT_NONE, NULL, NULL, NULL);
switch_core_codec_control(&engine->write_codec, SCC_DEBUG, SCCT_INT, (void *)&level, SCCT_NONE, NULL, NULL, NULL);
if (engine->rtp_session) {
if (iotype == SWITCH_IO_READ) {
- switch_core_codec_control(&engine->read_codec, SCC_CODEC_SPECIFIC,
- SCCT_STRING, (void *)msg->string_array_arg[2],
+ switch_core_codec_control(&engine->read_codec, SCC_CODEC_SPECIFIC,
+ SCCT_STRING, (void *)msg->string_array_arg[2],
SCCT_STRING, (void *)msg->string_array_arg[3], &reply_type, &reply);
} else {
- switch_core_codec_control(&engine->write_codec, SCC_CODEC_SPECIFIC,
- SCCT_STRING, (void *)msg->string_array_arg[2],
+ switch_core_codec_control(&engine->write_codec, SCC_CODEC_SPECIFIC,
+ SCCT_STRING, (void *)msg->string_array_arg[2],
SCCT_STRING, (void *)msg->string_array_arg[3], &reply_type, &reply);
}
-
-
+
+
if (reply_type == SCCT_STRING) {
msg->string_array_arg[4] = (char *)reply;
}
if (switch_rtp_ready(a_engine->rtp_session)) {
const char *val;
int ok = 0;
-
+
if (!switch_channel_test_flag(session->channel, CF_VIDEO) &&
(!(val = switch_channel_get_variable(session->channel, "rtp_jitter_buffer_during_bridge")) || switch_false(val))) {
if (switch_channel_test_flag(session->channel, CF_JITTERBUFFER) && switch_channel_test_cap_partner(session->channel, CC_FS_RTP)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
- "%s PAUSE Jitterbuffer\n", switch_channel_get_name(session->channel));
+ "%s PAUSE Jitterbuffer\n", switch_channel_get_name(session->channel));
switch_rtp_pause_jitter_buffer(a_engine->rtp_session, SWITCH_TRUE);
switch_set_flag(smh, SMF_JB_PAUSED);
}
}
-
+
if (switch_channel_test_flag(session->channel, CF_PASS_RFC2833) && switch_channel_test_flag_partner(session->channel, CF_FS_RTP)) {
switch_rtp_set_flag(a_engine->rtp_session, SWITCH_RTP_FLAG_PASS_RFC2833);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
ok = smh->media_flags[SCMF_RTP_AUTOFLUSH_DURING_BRIDGE];
}
}
-
+
if (ok) {
rtp_flush_read_buffer(a_engine->rtp_session, SWITCH_RTP_FLUSH_STICK);
switch_channel_set_flag(session->channel, CF_AUTOFLUSH_DURING_BRIDGE);
} else {
rtp_flush_read_buffer(a_engine->rtp_session, SWITCH_RTP_FLUSH_ONCE);
}
-
+
}
}
goto end;
case SWITCH_MESSAGE_INDICATE_UNBRIDGE:
if (switch_rtp_ready(a_engine->rtp_session)) {
-
+
if (switch_test_flag(smh, SMF_JB_PAUSED)) {
switch_clear_flag(smh, SMF_JB_PAUSED);
if (switch_channel_test_flag(session->channel, CF_JITTERBUFFER)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
- "%s RESUME Jitterbuffer\n", switch_channel_get_name(session->channel));
+ "%s RESUME Jitterbuffer\n", switch_channel_get_name(session->channel));
switch_rtp_pause_jitter_buffer(a_engine->rtp_session, SWITCH_FALSE);
}
}
-
+
if (switch_rtp_test_flag(a_engine->rtp_session, SWITCH_RTP_FLAG_PASS_RFC2833)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s deactivate passthru 2833 mode.\n",
switch_channel_get_name(session->channel));
switch_rtp_clear_flag(a_engine->rtp_session, SWITCH_RTP_FLAG_PASS_RFC2833);
}
-
+
if (switch_channel_test_flag(session->channel, CF_NOTIMER_DURING_BRIDGE)) {
- if (!switch_rtp_test_flag(a_engine->rtp_session, SWITCH_RTP_FLAG_UDPTL) &&
+ if (!switch_rtp_test_flag(a_engine->rtp_session, SWITCH_RTP_FLAG_UDPTL) &&
!switch_rtp_test_flag(a_engine->rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA)) {
switch_rtp_set_flag(a_engine->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
//switch_rtp_set_flag(a_engine->rtp_session, SWITCH_RTP_FLAG_NOBLOCK);
a_engine->codec_negotiated = 0;
v_engine->codec_negotiated = 0;
-
+
if (session->track_duration) {
switch_core_session_enable_heartbeat(session, session->track_duration);
}
case SWITCH_MESSAGE_INDICATE_3P_NOMEDIA:
switch_channel_set_flag(session->channel, CF_PROXY_MODE);
- switch_core_media_set_local_sdp(session, NULL, SWITCH_FALSE);
+ switch_core_media_set_local_sdp(session, NULL, SWITCH_FALSE);
break;
case SWITCH_MESSAGE_INDICATE_NOMEDIA:
{
if (*msg->string_arg == '=') {
switch_channel_set_variable(session->channel, "codec_string", msg->string_arg);
} else {
- switch_channel_set_variable_printf(session->channel,
+ switch_channel_set_variable_printf(session->channel,
"codec_string", "=%s", switch_channel_get_variable(session->channel, "ep_codec_string"));
}
}
rtp_flush_read_buffer(a_engine->rtp_session, SWITCH_RTP_FLUSH_UNSTICK);
-
+
} else {
if (switch_test_flag(smh, SMF_JB_PAUSED)) {
switch_clear_flag(smh, SMF_JB_PAUSED);
}
-
+
default:
break;
}
if (!(smh = session->media_handle)) {
return 0;
- }
+ }
return switch_rtp_ready(smh->engines[type].rtp_session);
}
if (switch_rtp_ready(smh->engines[type].rtp_session)) {
switch_rtp_set_flag(smh->engines[type].rtp_session, flag);
- }
+ }
}
//?
if (switch_rtp_ready(smh->engines[type].rtp_session)) {
switch_rtp_clear_flag(smh->engines[type].rtp_session, flag);
- }
+ }
}
//?
if (!(smh = session->media_handle)) {
return;
- }
+ }
if (switch_rtp_ready(smh->engines[type].rtp_session)) {
switch_rtp_set_telephony_event(smh->engines[type].rtp_session, te);
char ratestr[20] = "";
char bitstr[20] = "";
switch_codec_fmtp_t codec_fmtp = { 0 };
-
+
if (!codec_ms) {
codec_ms = switch_default_ptime(map->rm_encoding, map->rm_pt);
}
map_channels = map->rm_params ? atoi(map->rm_params) : 1;
map_bit_rate = switch_known_bitrate((switch_payload_t)map->rm_pt);
-
+
if (!ptime && !strcasecmp(map->rm_encoding, "g723")) {
ptime = codec_ms = 30;
}
-
+
if (zstr(map->rm_fmtp)) {
if (!strcasecmp(map->rm_encoding, "ilbc")) {
ptime = codec_ms = 30;
if ((var = switch_channel_get_variable(channel, "ep_codec_prefer_sdp")) && switch_true(var)) {
prefer_sdp = 1;
}
-
+
if (!zstr(codec_string)) {
char *tmp_codec_string;
if ((tmp_codec_string = strdup(codec_string))) {
for (m = sdp->sdp_media; m; m = m->m_next) {
ptime = dptime;
-
+
if ((m->m_type == sdp_media_audio || m->m_type == sdp_media_video) && m->m_port) {
for (map = m->m_rtpmaps; map; map = map->rm_next) {
for (attr = m->m_attributes; attr; attr = attr->a_next) {
break;
}
}
- switch_core_media_add_payload_map(session,
+ switch_core_media_add_payload_map(session,
m->m_type == sdp_media_audio ? SWITCH_MEDIA_TYPE_AUDIO : SWITCH_MEDIA_TYPE_VIDEO,
map->rm_encoding,
NULL,
if (match) {
add_audio_codec(map, imp, ptime, buf, sizeof(buf));
}
-
+
}
}
if (!(smh = session->media_handle)) {
return SWITCH_STATUS_FALSE;
}
-
+
engine = &smh->engines[type];
if (engine->cur_payload_map->iananame) {
smh->owner_id = 0;
smh->session_id = 0;
-
+
a_engine->local_dtls_fingerprint.len = 0;
v_engine->local_dtls_fingerprint.len = 0;
t_engine->local_dtls_fingerprint.len = 0;
}
r_sdp = switch_channel_get_variable(o_session->channel, SWITCH_R_SDP_VARIABLE);
-
+
a_engine = &smh->engines[SWITCH_MEDIA_TYPE_AUDIO];
v_engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO];
t_engine = &smh->engines[SWITCH_MEDIA_TYPE_TEXT];
clear_pmaps(a_engine);
clear_pmaps(v_engine);
-
+
pmap = switch_core_media_add_payload_map(session,
SWITCH_MEDIA_TYPE_AUDIO,
"PROXY",
90000,
1,
SWITCH_TRUE);
-
+
v_engine->cur_payload_map = pmap;
switch_channel_set_flag(session->channel, CF_VIDEO);
1000,
1,
SWITCH_TRUE);
-
+
t_engine->cur_payload_map = pmap;
switch_channel_set_flag(session->channel, CF_HAS_TEXT);
const char *a_ip;
const char *r_ip;
const char *r_port;
- const char *tmp;
+ const char *tmp;
switch_rtp_engine_t *a_engine, *v_engine;
switch_media_handle_t *smh;
if (!(smh = session->media_handle)) {
return;
}
-
+
ip = switch_channel_get_variable(session->channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE);
port = switch_channel_get_variable(session->channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE);
const char *vtmp = switch_channel_get_variable(session->channel, "rtp_last_video_codec_string");
switch_channel_set_variable_printf(session->channel, "rtp_use_codec_string", "%s%s%s", tmp, vtmp ? "," : "", vtmp ? vtmp : "");
}
-
+
if ((tmp = switch_channel_get_variable(session->channel, "rtp_use_codec_string"))) {
char *tmp_codec_string = switch_core_session_strdup(smh->session, tmp);
smh->codec_order_last = switch_separate_string(tmp_codec_string, ',', smh->codec_order, SWITCH_MAX_CODECS);
}
switch_core_media_set_codec(session, 0, smh->mparams->codec_flags);
-
+
a_engine->adv_sdp_ip = smh->mparams->extrtpip = (char *) ip;
a_engine->adv_sdp_port = a_engine->local_sdp_port = (switch_port_t)atoi(port);
a_engine->codec_negotiated = 1;
if ((tmp = switch_channel_get_variable(session->channel, "rtp_use_video_pt"))) {
v_engine->cur_payload_map->pt = (switch_payload_t)atoi(tmp);
}
-
+
if ((tmp = switch_channel_get_variable(session->channel, "rtp_video_recv_pt"))) {
v_engine->cur_payload_map->recv_pt = (switch_payload_t)atoi(tmp);
}
switch_core_media_add_crypto(&a_engine->ssec[a_engine->crypto_type], a_engine->ssec[a_engine->crypto_type].local_crypto_key, SWITCH_RTP_CRYPTO_SEND);
switch_core_media_add_crypto(&a_engine->ssec[a_engine->crypto_type], a_engine->ssec[a_engine->crypto_type].remote_crypto_key, SWITCH_RTP_CRYPTO_RECV);
switch_channel_set_flag(smh->session->channel, CF_SECURE);
-
+
switch_rtp_add_crypto_key(a_engine->rtp_session, SWITCH_RTP_CRYPTO_SEND, idx,
a_engine->crypto_type,
- a_engine->ssec[a_engine->crypto_type].local_raw_key,
+ a_engine->ssec[a_engine->crypto_type].local_raw_key,
SUITES[a_engine->crypto_type].keylen);
-
- switch_rtp_add_crypto_key(a_engine->rtp_session, SWITCH_RTP_CRYPTO_RECV,
+
+ switch_rtp_add_crypto_key(a_engine->rtp_session, SWITCH_RTP_CRYPTO_RECV,
a_engine->ssec[a_engine->crypto_type].crypto_tag,
- a_engine->crypto_type,
- a_engine->ssec[a_engine->crypto_type].remote_raw_key,
+ a_engine->crypto_type,
+ a_engine->ssec[a_engine->crypto_type].remote_raw_key,
SUITES[a_engine->crypto_type].keylen);
}
SWITCH_DECLARE(void) switch_core_media_init(void)
{
- switch_core_gen_certs(DTLS_SRTP_FNAME ".pem");
+ switch_core_gen_certs(DTLS_SRTP_FNAME ".pem");
video_globals.cpu_count = switch_core_cpu_count();
video_globals.cur_cpu = 0;
static int find_pt(const char *sdp, const char *name)
{
const char *p;
-
+
if ((p = switch_stristr(name, sdp))) {
if (p < end_of_p(sdp) && *(p+strlen(name)) == '/' && *(p-1) == ' ') {
p -= 2;
int tst;
end++;
-
+
if (remove || only) {
pt = payload_number(arg);
-
+
if (pt < 0) {
pt = find_pt(sdp_str, arg);
}
while(*i != ' ' && i < end) {
*o++ = *i++;
}
-
+
*o++ = *i++;
}
-
+
if (slash && switch_is_leading_number(i)) {
-
+
number = atoi(i);
-
+
while(i < end && ((*i > 47 && *i < 58) || *i == ' ')) {
if (remove) {
*o++ = *i;
}
i++;
-
+
if (*i == ' ') {
break;
}
-
+
}
if (remove) {
while (i < end && !strncasecmp(i, "a=rtpmap:", 9)) {
const char *t = i + 9;
-
+
number = atoi(t);
if (remove) {
while (i < end && !strncasecmp(i, "a=fmtp:", 7)) {
const char *t = i + 7;
-
+
number = atoi(t);
if (remove) {
}
*o = '\0';
-
+
return new_sdp;
}
}
- switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG,
- "%s Filter command %s(%s)\nFROM:\n==========\n%s\nTO:\n==========\n%s\n\n",
+ switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG,
+ "%s Filter command %s(%s)\nFROM:\n==========\n%s\nTO:\n==========\n%s\n\n",
switch_channel_get_name(channel),
command, arg, patched_sdp ? patched_sdp : sdp, tmp_sdp);
-
+
if (tmp_sdp) {
switch_safe_free(patched_sdp);
if (!(smh = session->media_handle)) {
return NULL;
}
-
+
if (!(engine = &smh->engines[mtype])) {
return NULL;
}
switch_media_handle_t *smh = NULL;
switch_assert(session);
-
+
if (!(smh = session->media_handle)) {
return SWITCH_STATUS_FALSE;
}
-
+
if (switch_channel_test_flag(channel, CF_VIDEO)) {
switch_core_session_message_t msg = { 0 };
switch_time_t now = switch_micro_time_now();
}
-SWITCH_DECLARE(switch_status_t) switch_core_media_codec_control(switch_core_session_t *session,
+SWITCH_DECLARE(switch_status_t) switch_core_media_codec_control(switch_core_session_t *session,
switch_media_type_t mtype,
switch_io_type_t iotype,
- switch_codec_control_command_t cmd,
+ switch_codec_control_command_t cmd,
switch_codec_control_type_t ctype,
void *cmd_data,
switch_codec_control_type_t atype,
void *cmd_arg,
switch_codec_control_type_t *rtype,
- void **ret_data)
+ void **ret_data)
{
switch_rtp_engine_t *engine = NULL;
switch_media_handle_t *smh = NULL;
if (!(smh = session->media_handle)) {
return SWITCH_STATUS_FALSE;
}
-
+
if (!(engine = &smh->engines[mtype])) {
return SWITCH_STATUS_NOTIMPL;
}
return SWITCH_STATUS_FALSE;
}
-SWITCH_DECLARE(switch_bool_t) switch_core_media_codec_get_cap(switch_core_session_t *session,
- switch_media_type_t mtype,
+SWITCH_DECLARE(switch_bool_t) switch_core_media_codec_get_cap(switch_core_session_t *session,
+ switch_media_type_t mtype,
switch_codec_flag_t flag) {
switch_rtp_engine_t *engine = NULL;
switch_media_handle_t *smh = NULL;
}
codec = &engine->write_codec;
-
+
if (!switch_core_codec_ready(codec)) {
return SWITCH_FALSE;
}
return SWITCH_FALSE;
}
-SWITCH_DECLARE(switch_status_t) switch_core_session_write_encoded_video_frame(switch_core_session_t *session,
+SWITCH_DECLARE(switch_status_t) switch_core_session_write_encoded_video_frame(switch_core_session_t *session,
switch_frame_t *frame, switch_io_flag_t flags, int stream_id)
{
switch_io_event_hook_video_write_frame_t *ptr;
smh->video_init = 0;
smh->video_last_key_time = 0;
switch_core_session_send_and_request_video_refresh(session);
-
+
type = 1;
switch_core_media_codec_control(session, SWITCH_MEDIA_TYPE_VIDEO, SWITCH_IO_READ, SCC_VIDEO_RESET, SCCT_INT, (void *)&type, SCCT_NONE, NULL, NULL, NULL);
switch_core_session_request_video_refresh(session);
return SWITCH_STATUS_SUCCESS;
}
- v_engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO];
+ v_engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO];
if (smh->write_mutex[SWITCH_MEDIA_TYPE_VIDEO] && switch_mutex_trylock(smh->write_mutex[SWITCH_MEDIA_TYPE_VIDEO]) != SWITCH_STATUS_SUCCESS) {
/* return CNG, another thread is already writing */
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG1, "%s is already being written to for %s\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG1, "%s is already being written to for %s\n",
switch_channel_get_name(session->channel), type2str(SWITCH_MEDIA_TYPE_VIDEO));
return SWITCH_STATUS_INUSE;
}
}
smh->video_last_key_time = now;
- }
+ }
if (smh->mparams->video_key_freq && (now - smh->video_last_key_time) > smh->mparams->video_key_freq) {
switch_core_media_gen_key_frame(smh->session);
smh->video_last_key_time = now;
- }
+ }
if (!img) {
switch_status_t vstatus;
if (!switch_rtp_test_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_GEN_TS_MANUAL)) {
switch_rtp_set_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_GEN_TS_DELTA);
}
-
+
vstatus = switch_core_session_write_encoded_video_frame(session, frame, flags, stream_id);
switch_goto_status(vstatus, done);
} else {
/* When desired, scale video to match the input signal (if output is bigger) */
- if (switch_channel_test_flag(session->channel, CF_VIDEO_READY) && smh->vid_params.width &&
- switch_channel_test_flag(session->channel, CF_VIDEO_MIRROR_INPUT) &&
+ if (switch_channel_test_flag(session->channel, CF_VIDEO_READY) && smh->vid_params.width &&
+ switch_channel_test_flag(session->channel, CF_VIDEO_MIRROR_INPUT) &&
((smh->vid_params.width != img->d_w) || (smh->vid_params.height != img->d_h))) {
switch_img_letterbox(img, &dup_img, smh->vid_params.width, smh->vid_params.height, "#000000f");
img = dup_img;
}
-
+
if (session->bugs) {
switch_media_bug_t *bp;
int prune = 0;
if (switch_channel_test_flag(session->channel, CF_PAUSE_BUGS) && !switch_core_media_bug_test_flag(bp, SMBF_NO_PAUSE)) {
continue;
}
-
+
if (!switch_channel_test_flag(session->channel, CF_ANSWERED) && switch_core_media_bug_test_flag(bp, SMBF_ANSWER_REQ)) {
continue;
}
-
+
if (switch_test_flag(bp, SMBF_PRUNE)) {
prune++;
continue;
}
-
+
if (bp->ready && switch_test_flag(bp, SMBF_WRITE_VIDEO_STREAM)) {
switch_image_t *dimg = NULL;
-
+
switch_img_copy(img, &dimg);
switch_queue_push(bp->write_video_queue, dimg);
}
- if (bp->ready && img &&
+ if (bp->ready && img &&
(switch_test_flag(bp, SMBF_WRITE_VIDEO_PING) || (switch_core_media_bug_test_flag(bp, SMBF_SPY_VIDEO_STREAM) && !patched))) {
switch_frame_t bug_frame = { 0 };
switch_core_media_bug_patch_spy_frame(bp, img, SWITCH_RW_WRITE);
}
-
+
}
if (ok == SWITCH_FALSE) {
if (prune) {
switch_core_media_bug_prune(session);
}
-
+
}
write_frame = *frame;
if (!switch_test_flag(frame, SFF_USE_VIDEO_TIMESTAMP)) {
if (!(timer = switch_core_media_get_timer(session, SWITCH_MEDIA_TYPE_VIDEO))) {
-
+
if (!smh->video_timer.timer_interface) {
switch_core_timer_init(&smh->video_timer, "soft", 1, 90, switch_core_session_get_pool(session));
}
do {
frame->datalen = SWITCH_DEFAULT_VIDEO_SIZE;
encode_status = switch_core_codec_encode_video(codec, frame);
-
+
if (encode_status == SWITCH_STATUS_SUCCESS || encode_status == SWITCH_STATUS_MORE_DATA) {
switch_assert((encode_status == SWITCH_STATUS_SUCCESS && frame->m) || !frame->m);
-
+
if (frame->flags & SFF_PICTURE_RESET) {
switch_core_session_video_reinit(session);
frame->flags &= ~SFF_PICTURE_RESET;
switch_set_flag(frame, SFF_RAW_RTP_PARSE_FRAME);
status = switch_core_session_write_encoded_video_frame(session, frame, flags, stream_id);
}
-
+
} while(status == SWITCH_STATUS_SUCCESS && encode_status == SWITCH_STATUS_MORE_DATA);
done:
}
switch_img_free(&dup_img);
-
+
return status;
}
if (!(smh = session->media_handle)) {
return SWITCH_STATUS_FALSE;
}
-
+
if (!switch_channel_test_flag(session->channel, CF_VIDEO_DECODED_READ)) {
return SWITCH_STATUS_GENERR;;
}
}
switch_core_session_get_read_impl(session, &read_impl);
-
+
while(switch_channel_ready(session->channel) && timeout_ms > 0) {
switch_frame_t *read_frame;
switch_status_t status;
-
- if (video_globals.synced &&
+
+ if (video_globals.synced &&
switch_channel_test_flag(session->channel, CF_VIDEO_READY) && smh->vid_params.width && smh->vid_params.height && smh->vid_params.fps) {
return SWITCH_STATUS_SUCCESS;
}
}
return SWITCH_STATUS_TIMEOUT;
-
+
}
SWITCH_DECLARE(switch_status_t) switch_core_session_read_video_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags,
uint32_t loops = 0;
switch_media_handle_t *smh;
int patchers = 0;
-
+
switch_assert(session != NULL);
if (!(smh = session->media_handle)) {
if (!(*frame)) {
goto done;
}
-
+
if (switch_channel_test_flag(session->channel, CF_VIDEO_DEBUG_READ)) {
if (switch_test_flag((*frame), SFF_CNG)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "VIDEO: CNG\n");
} else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,
"VIDEO: seq: %d ts: %u len: %4d %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x mark: %d\n",
(*frame)->seq, (*frame)->timestamp, (*frame)->datalen,
*((uint8_t *)(*frame)->data), *((uint8_t *)(*frame)->data + 1),
(*frame)->img = NULL;
decode_status = switch_core_codec_decode_video((*frame)->codec, *frame);
-
+
if ((*frame)->img && switch_channel_test_flag(session->channel, CF_VIDEO_DEBUG_READ)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "IMAGE %dx%d %dx%d\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "IMAGE %dx%d %dx%d\n",
(*frame)->img->w, (*frame)->img->h, (*frame)->img->d_w, (*frame)->img->d_h);
}
if (decode_status == SWITCH_STATUS_MORE_DATA || !(*frame)->img) {
goto top;
- }
+ }
}
if (!switch_channel_test_flag(session->channel, CF_VIDEO_READY) && *frame) {
}
}
- if (bp->ready && (*frame) && (*frame)->img &&
+ if (bp->ready && (*frame) && (*frame)->img &&
(switch_test_flag(bp, SMBF_READ_VIDEO_PING) || (switch_core_media_bug_test_flag(bp, SMBF_SPY_VIDEO_STREAM) && !patched))) {
-
+
if (bp->callback && switch_test_flag(bp, SMBF_READ_VIDEO_PING)) {
if (switch_test_flag(bp, SMBF_READ_VIDEO_PATCH)) {
prune++;
}
}
-
+
switch_thread_rwlock_unlock(session->bug_rwlock);
if (prune) {
}
-SWITCH_DECLARE(switch_status_t) switch_core_session_set_video_read_callback(switch_core_session_t *session,
+SWITCH_DECLARE(switch_status_t) switch_core_session_set_video_read_callback(switch_core_session_t *session,
switch_core_video_thread_callback_func_t func, void *user_data)
{
switch_status_t status = SWITCH_STATUS_SUCCESS;
-SWITCH_DECLARE(switch_status_t) switch_core_session_set_text_read_callback(switch_core_session_t *session,
+SWITCH_DECLARE(switch_status_t) switch_core_session_set_text_read_callback(switch_core_session_t *session,
switch_core_text_thread_callback_func_t func, void *user_data)
{
switch_status_t status = SWITCH_STATUS_SUCCESS;
if (!(*frame)) {
goto done;
}
-
+
now = switch_micro_time_now();
if (switch_test_flag((*frame), SFF_CNG)) {
switch_set_flag((*frame), SFF_TEXT_LINE_BREAK);
break;
}
-
+
if (*p == 0xE2 && *(p+1) == 0x80 && *(p+2) == 0xA8) {
switch_set_flag((*frame), SFF_TEXT_LINE_BREAK);
break;
}
-
+
p++;
}
}
-
+
if ((*frame)->data && (*frame)->datalen && !((*frame)->flags & SFF_CNG)) {
if (!session->text_buffer) {
switch_mutex_init(&session->text_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
int bytes = 0;
if ((*frame)) {
- switch_size_t inuse = 0;
+ switch_size_t inuse = 0;
if ((*frame)->data && (*frame)->datalen && !((*frame)->flags & SFF_CNG)) {
switch_mutex_lock(session->text_mutex);
inuse = switch_buffer_inuse(bp->text_buffer);
- if (zstr(bp->text_framedata) && inuse &&
+ if (zstr(bp->text_framedata) && inuse &&
(switch_channel_test_flag(session->channel, CF_TEXT_IDLE) || switch_test_flag((*frame), SFF_TEXT_LINE_BREAK))) {
if (inuse + 1 > bp->text_framesize) {
void *tmp = malloc(inuse + 1024);
memcpy(tmp, bp->text_framedata, bp->text_framesize);
-
+
switch_assert(tmp);
-
+
bp->text_framesize = inuse + 1024;
-
+
free(bp->text_framedata);
bp->text_framedata = tmp;
-
+
}
-
+
bytes = switch_buffer_read(bp->text_buffer, bp->text_framedata, inuse);
- *(bp->text_framedata + bytes) = '\0';
+ *(bp->text_framedata + bytes) = '\0';
ok = bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_READ_TEXT);
bp->text_framedata[0] = '\0';
} else ok = SWITCH_TRUE;
}
}
-
+
if (ok == SWITCH_FALSE) {
switch_set_flag(bp, SMBF_PRUNE);
prune++;
}
}
-
+
switch_thread_rwlock_unlock(session->bug_rwlock);
if (prune) {
switch_core_media_bug_prune(session);
}
}
-
+
if (status == SWITCH_STATUS_SUCCESS || status == SWITCH_STATUS_BREAK) {
if ((switch_channel_test_flag(session->channel, CF_QUEUE_TEXT_EVENTS) || switch_channel_test_flag(session->channel, CF_FIRE_TEXT_EVENTS)) &&
(*frame)->datalen && !switch_test_flag((*frame), SFF_CNG)) {
switch_buffer_create_dynamic(&session->text_line_buffer, 512, 1024, 0);
}
switch_buffer_write(session->text_line_buffer, (*frame)->data, (*frame)->datalen);
-
-
+
+
if (switch_channel_test_flag(session->channel, CF_TEXT_IDLE) || switch_test_flag((*frame), SFF_TEXT_LINE_BREAK)) {
switch_buffer_write(session->text_line_buffer, eof, 1);
data = switch_buffer_get_head_pointer(session->text_line_buffer);
uint16_t *u16;
pos = t_engine->tf->red_pos + 1;
-
+
if (pos == t_engine->tf->red_max) pos = 0;
for (;;) {
buf++;//3
*buf += (len & 0x300) >> 8;
buf++;//4
- *buf = len & 0xff;
+ *buf = len & 0xff;
}
buf++;
if (pos == t_engine->tf->red_pos) break;
-
+
pos++;
if (pos == t_engine->tf->red_max) pos = 0;
}
-
+
plen = ((loops - 1) * 4) + 1;
pos = t_engine->tf->red_pos + 1;
-
+
if (pos == t_engine->tf->red_max) pos = 0;
for (;;) {
if (switch_channel_down(session->channel)) {
return SWITCH_STATUS_FALSE;
}
-
+
if (switch_core_session_media_flow(session, SWITCH_MEDIA_TYPE_TEXT) == SWITCH_MEDIA_FLOW_RECVONLY || switch_core_session_media_flow(session, SWITCH_MEDIA_TYPE_TEXT) == SWITCH_MEDIA_FLOW_INACTIVE) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG3, "Writing text to RECVONLY/INACTIVE session\n");
return SWITCH_STATUS_SUCCESS;
if (smh->write_mutex[SWITCH_MEDIA_TYPE_TEXT] && switch_mutex_trylock(smh->write_mutex[SWITCH_MEDIA_TYPE_TEXT]) != SWITCH_STATUS_SUCCESS) {
/* return CNG, another thread is already writing */
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG1, "%s is already being written to for %s\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG1, "%s is already being written to for %s\n",
switch_channel_get_name(session->channel), type2str(SWITCH_MEDIA_TYPE_TEXT));
goto done;
}
if (t_engine->tf->write_empty > TEXT_PERIOD_TIMEOUT / TEXT_TIMER_MS) {
int pos;
-
+
for(pos = 0; pos < t_engine->tf->red_max; pos++) {
t_engine->tf->red_ts[pos] = 0;
t_engine->tf->red_buf[pos][0] = '\0';
frame->m = 1;
t_engine->tf->write_empty = 0;
-
+
} else {
frame->m = 0;
}
- t_engine->tf->red_buflen[t_engine->tf->red_pos] =
+ t_engine->tf->red_buflen[t_engine->tf->red_pos] =
switch_buffer_read(t_engine->tf->write_buffer, t_engine->tf->red_buf[t_engine->tf->red_pos], RED_PACKET_SIZE);
*(t_engine->tf->red_buf[t_engine->tf->red_pos] + t_engine->tf->red_buflen[t_engine->tf->red_pos]) = '\0';
frame.data = data;
frame.datalen = strlen(data);
-
+
switch_core_session_write_text_frame(session, &frame, 0, 0);
frame.data = CR;
frame.datalen = 3;
-
+
switch_core_session_write_text_frame(session, &frame, 0, 0);
switch_safe_free(data);
switch_mutex_lock(session->codec_write_mutex);
if (!(frame->codec && frame->codec->implementation)) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "%s has received a bad frame with no codec!\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "%s has received a bad frame with no codec!\n",
switch_channel_get_name(session->channel));
switch_channel_hangup(session->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
switch_mutex_unlock(session->codec_write_mutex);
switch_mutex_lock(frame->codec->mutex);
if (!(switch_core_codec_ready(session->write_codec) && switch_core_codec_ready(frame->codec))) goto error;
-
+
if ((session->write_codec && frame->codec && session->write_codec->implementation != frame->codec->implementation)) {
if (session->write_impl.codec_id == frame->codec->implementation->codec_id ||
session->write_impl.microseconds_per_packet != frame->codec->implementation->microseconds_per_packet) {
switch_set_flag(other_session, SSF_WRITE_CODEC_RESET);
switch_core_session_rwunlock(other_session);
}
-
+
switch_clear_flag(session, SSF_WRITE_TRANSCODE);
}
if (do_resample && status == SWITCH_STATUS_SUCCESS) {
status = SWITCH_STATUS_RESAMPLE;
}
-
+
/* mux or demux to match */
if (session->write_impl.number_of_channels != frame->codec->implementation->number_of_channels) {
uint32_t rlen = session->raw_write_frame.datalen / 2 / frame->codec->implementation->number_of_channels;
- switch_mux_channels((int16_t *) session->raw_write_frame.data, rlen,
+ switch_mux_channels((int16_t *) session->raw_write_frame.data, rlen,
frame->codec->implementation->number_of_channels, session->write_impl.number_of_channels);
session->raw_write_frame.datalen = rlen * 2 * session->write_impl.number_of_channels;
}
-
+
switch (status) {
case SWITCH_STATUS_RESAMPLE:
resample++;
goto error;
}
}
-
+
if (session->write_resampler) {
if (switch_resample_calc_buffer_size(session->write_resampler->to_rate, session->write_resampler->from_rate,
write_frame->datalen / 2 / session->write_resampler->channels) > SWITCH_RECOMMENDED_BUFFER_SIZE) {
-
+
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "%s not enough buffer space for required resample operation!\n",
switch_channel_get_name(session->channel));
switch_channel_hangup(session->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
switch_mutex_unlock(session->resample_mutex);
goto error;
}
-
+
switch_resample_process(session->write_resampler, data, write_frame->datalen / 2 / session->write_resampler->channels);
switch_mutex_lock(bp->write_mutex);
switch_buffer_write(bp->raw_write_buffer, write_frame->data, write_frame->datalen);
switch_mutex_unlock(bp->write_mutex);
-
+
if (bp->callback) {
ok = bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_WRITE);
}
status = switch_resample_create(&session->write_resampler,
frame->codec->implementation->actual_samples_per_second,
session->write_impl.actual_samples_per_second,
- session->write_impl.decoded_bytes_per_packet, SWITCH_RESAMPLE_QUALITY,
+ session->write_impl.decoded_bytes_per_packet, SWITCH_RESAMPLE_QUALITY,
session->write_impl.number_of_channels);
}
switch_mutex_unlock(session->resample_mutex);
msg.numeric_arg = 1;
msg.message_id = SWITCH_MESSAGE_RESAMPLE_EVENT;
switch_core_session_receive_message(session, &msg);
-
+
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Activating write resampler\n");
}
int ok = 0;
switch_mutex_lock(session->resample_mutex);
- if (session->write_resampler) {
+ if (session->write_resampler) {
switch_resample_destroy(&session->write_resampler);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Deactivating write resampler\n");
ok = 1;
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Michael Jerris <mike@jerris.com>
* Paul D. Tinsley <pdt at jackhammer.org>
}
if ((!bug->raw_read_buffer && (!bug->raw_write_buffer || !switch_test_flag(bug, SMBF_WRITE_STREAM)))) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)), SWITCH_LOG_ERROR,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)), SWITCH_LOG_ERROR,
"%s Buffer Error (raw_read_buffer=%p, raw_write_buffer=%p, read=%s, write=%s)\n",
switch_channel_get_name(bug->session->channel),
- (void *)bug->raw_read_buffer, (void *)bug->raw_write_buffer,
+ (void *)bug->raw_read_buffer, (void *)bug->raw_write_buffer,
switch_test_flag(bug, SMBF_READ_STREAM) ? "yes" : "no",
switch_test_flag(bug, SMBF_WRITE_STREAM) ? "yes" : "no");
return SWITCH_STATUS_FALSE;
} else {
uint32_t frame_size;
switch_codec_implementation_t read_impl = { 0 };
-
+
switch_core_session_get_read_impl(bug->session, &read_impl);
frame_size = read_impl.decoded_bytes_per_packet;
bug->record_frame_size = frame_size;
if (do_write && do_write > SWITCH_RECOMMENDED_BUFFER_SIZE) {
do_write = 1280;
}
-
+
if (do_read) {
switch_mutex_lock(bug->read_mutex);
frame->datalen = (uint32_t) switch_buffer_read(bug->raw_read_buffer, frame->data, do_read);
} else {
for (x = 0; x < blen; x++) {
int32_t w = 0, r = 0, z = 0;
-
+
if (x < rlen) {
r = (int32_t) * (fp + x);
}
if (x < wlen) {
w = (int32_t) * (dp + x);
}
-
+
z = w + r;
if (z > SWITCH_SMAX || z < SWITCH_SMIN) {
switch_queue_create(&bug->spy_video_queue[i], SWITCH_CORE_QUEUE_LEN, switch_core_session_get_pool(bug->session));
}
}
-
+
spy_q = bug->spy_video_queue[rw];
while(switch_queue_size(spy_q) > 0) {
if ((float)w/h == aspect169) {
if ((float)bug->spy_img[rw]->d_w / bug->spy_img[rw]->d_h == aspect169) {
spy_tmp = switch_img_copy_rect(bug->spy_img[rw], bug->spy_img[rw]->d_w / 4, 0, bug->spy_img[rw]->d_w / 2, bug->spy_img[rw]->d_h);
-
+
} else {
switch_img_copy(bug->spy_img[rw], &spy_tmp);
}
spyw = (int) (float)w * scaler;
spyh = (int) (float)h * scaler;
-
+
if (bug->spy_img[rw]->d_w != spyw || bug->spy_img[rw]->d_h != spyh) {
switch_image_t *tmp_img = NULL;
-
+
switch_img_scale(bug->spy_img[rw], &tmp_img, spyw, spyh);
switch_img_free(&bug->spy_img[rw]);
bug->spy_img[rw] = tmp_img;
void *pop;
uint8_t *buf;
switch_size_t buflen = SWITCH_RTP_MAX_BUF_LEN;
- switch_frame_t frame = { 0 };
+ switch_frame_t frame = { 0 };
buf = switch_core_session_alloc(bug->session, buflen);
frame.packet = buf;
switch_status_t status;
int w = 0, h = 0, ok = 1;
-
+
if ((status = switch_queue_pop(main_q, &pop)) == SWITCH_STATUS_SUCCESS) {
switch_img_free(&img);
-
+
if (!pop) {
goto end;
}
img = (switch_image_t *) pop;
-
+
w = img->d_w;
h = img->d_h;
if (other_img) {
if (other_img->d_w != w || other_img->d_h != h) {
switch_image_t *tmp_img = NULL;
-
+
switch_img_scale(other_img, &tmp_img, w, h);
switch_img_free(&other_img);
other_img = tmp_img;
}
}
-
+
w *= 2;
-
+
if (!IMG || IMG->d_h != h || IMG->d_w != w) {
switch_img_free(&IMG);
IMG = switch_img_alloc(NULL, SWITCH_IMG_FMT_I420, w, h, 1);
const char *function,
const char *target,
switch_media_bug_callback_t callback,
- void *user_data, time_t stop_time,
- switch_media_bug_flag_t flags,
+ void *user_data, time_t stop_time,
+ switch_media_bug_flag_t flags,
switch_media_bug_t **new_bug)
{
switch_media_bug_t *bug, *bp;
if (!zstr(bp->function) && !strcasecmp(function, bp->function)) {
punt = 1;
break;
- }
+ }
}
switch_thread_rwlock_unlock(session->bug_rwlock);
}
}
-
+
if (punt) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Only one bug of this type allowed!\n");
return SWITCH_STATUS_GENERR;
if (target) {
bug->target = switch_core_session_strdup(session, target);
}
-
+
bug->stop_time = stop_time;
bytes = bug->read_impl.decoded_bytes_per_packet;
switch_buffer_create_dynamic(&bug->text_buffer, 512, 1024, 0);
switch_zmalloc(bug->text_framedata, 1024);
bug->text_framesize = 1024;
-
+
}
if ((switch_test_flag(bug, SMBF_READ_VIDEO_STREAM) || switch_test_flag(bug, SMBF_WRITE_VIDEO_STREAM))) {
}
}
-
+
if (bug->callback) {
switch_bool_t result = bug->callback(bug, bug->user_data, SWITCH_ABC_TYPE_INIT);
if (result == SWITCH_FALSE) {
switch_memory_pool_t *pool = switch_core_session_get_pool(session);
switch_threadattr_create(&thd_attr, pool);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
- switch_thread_create(&bug->video_bug_thread, thd_attr, video_bug_thread, bug, pool);
+ switch_thread_create(&bug->video_bug_thread, thd_attr, video_bug_thread, bug, pool);
}
for(bp = session->bugs; bp; bp = bp->next) {
if (bp->ready && !switch_test_flag(bp, SMBF_TAP_NATIVE_READ) && !switch_test_flag(bp, SMBF_TAP_NATIVE_WRITE)) {
tap_only = 0;
- }
+ }
}
switch_thread_rwlock_unlock(session->bug_rwlock);
const char *save_stereo = switch_channel_get_variable(new_channel, "record_stereo");
const char *orig_stereo = switch_channel_get_variable(orig_channel, "record_stereo");
const char *new_stereo = orig_stereo;
-
+
switch_thread_rwlock_wrlock(orig_session->bug_rwlock);
switch_channel_set_variable(new_channel, "RECORD_MIN_SEC", "0");
switch_channel_set_variable(new_channel, "record_append", "true");
}
-SWITCH_DECLARE(switch_status_t) switch_core_media_bug_transfer_callback(switch_core_session_t *orig_session, switch_core_session_t *new_session,
+SWITCH_DECLARE(switch_status_t) switch_core_media_bug_transfer_callback(switch_core_session_t *orig_session, switch_core_session_t *new_session,
switch_media_bug_callback_t callback, void * (*user_data_dup_func) (switch_core_session_t *, void *))
{
switch_media_bug_t *new_bug = NULL, *cur = NULL, *bp = NULL, *last = NULL;
while (bp) {
cur = bp;
bp = bp->next;
-
+
if (cur->callback == callback) {
if (last) {
last->next = cur->next;
return x;
}
-SWITCH_DECLARE(switch_status_t) switch_core_media_bug_exec_all(switch_core_session_t *orig_session,
+SWITCH_DECLARE(switch_status_t) switch_core_media_bug_exec_all(switch_core_session_t *orig_session,
const char *function, switch_media_bug_exec_cb_t cb, void *user_data)
{
switch_media_bug_t *bp;
switch_thread_rwlock_rdlock(session->bug_rwlock);
for (bp = session->bugs; bp; bp = bp->next) {
int thread_locked = (bp->thread_id && bp->thread_id == switch_thread_self());
- stream->write_function(stream,
+ stream->write_function(stream,
" <media-bug>\n"
" <function>%s</function>\n"
" <target>%s</target>\n"
" <thread-locked>%d</thread-locked>\n"
- " </media-bug>\n",
+ " </media-bug>\n",
bp->function, bp->target, thread_locked);
}
}
stream->write_function(stream, "</media-bugs>\n");
-
+
return SWITCH_STATUS_SUCCESS;
}
if (session->bugs) {
switch_thread_rwlock_wrlock(session->bug_rwlock);
for (bp = session->bugs; bp; bp = bp->next) {
- if (!switch_test_flag(session, SSF_DESTROYABLE) &&
+ if (!switch_test_flag(session, SSF_DESTROYABLE) &&
((bp->thread_id && bp->thread_id != switch_thread_self()) || switch_test_flag(bp, SMBF_LOCK))) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "BUG is thread locked skipping.\n");
last = bp;
continue;
}
-
+
if (!zstr(function) && strcmp(bp->function, function)) {
last = bp;
continue;
if (bp->read_video_queue) {
switch_queue_push(bp->read_video_queue, NULL);
}
-
+
if (bp->write_video_queue) {
switch_queue_push(bp->write_video_queue, NULL);
}
for(bp2 = session->bugs; bp2; bp2 = bp2->next) {
if (bp2->ready && !switch_test_flag(bp2, SMBF_TAP_NATIVE_READ) && !switch_test_flag(bp2, SMBF_TAP_NATIVE_WRITE)) {
tap_only = 0;
- }
+ }
}
}
-
+
if (tap_only) {
switch_set_flag(session, SSF_MEDIA_BUG_TAP_ONLY);
} else {
if (bp) {
status = switch_core_media_bug_close(&bp);
}
-
+
return status;
}
ttl++;
goto top;
}
-
+
return ttl;
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Michael Jerris <mike@jerris.com>
* Paul D. Tinsley <pdt at jackhammer.org>
#ifdef DEBUG_ALLOC
if (memory > DEBUG_ALLOC_CUTOFF)
- switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "%p %p Session Allocate %s %d\n",
+ switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "%p %p Session Allocate %s %d\n",
(void *) session->pool, (void *) session, apr_pool_tag(session->pool, NULL), (int) memory);
#endif
#endif
#ifdef DEBUG_ALLOC
- switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "%p Perm Allocate %s %d\n",
+ switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "%p Perm Allocate %s %d\n",
(void *)memory_manager.memory_pool, apr_pool_tag(memory_manager.memory_pool, NULL), (int) memory);
#endif
switch_assert(duped != NULL);
#ifdef DEBUG_ALLOC
- switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "%p Perm Allocate %s %d\n",
+ switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "%p Perm Allocate %s %d\n",
(void *) memory_manager.memory_pool, apr_pool_tag(memory_manager.memory_pool, NULL), (int) len);
#endif
#ifdef DEBUG_ALLOC
len = strlen(todup);
if (len > DEBUG_ALLOC_CUTOFF)
- switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "%p %p Sess Strdup Allocate %s %ld\n",
+ switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "%p %p Sess Strdup Allocate %s %ld\n",
(void *) session->pool, (void *)session, apr_pool_tag(session->pool, NULL), strlen(todup));
#endif
#ifdef DEBUG_ALLOC
if (len > DEBUG_ALLOC_CUTOFF)
- switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "%p Core Strdup Allocate %s %d\n",
+ switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "%p Core Strdup Allocate %s %d\n",
(void *) pool, apr_pool_tag(pool, NULL), (int)len);
#endif
#ifdef DEBUG_ALLOC
if (memory > DEBUG_ALLOC_CUTOFF)
- switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "%p Core Allocate %s %d\n",
+ switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "%p Core Allocate %s %d\n",
(void *) pool, apr_pool_tag(pool, NULL), (int) memory);
/*switch_assert(memory < 20000); */
#endif
#endif
#ifdef DEBUG_ALLOC
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%p DESTROY POOL\n", (void *) pop);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%p DESTROY POOL\n", (void *) pop);
#endif
apr_pool_destroy(pop);
#ifdef USE_MEM_LOCK
#else
apr_pool_mutex_set(pop, NULL);
#ifdef DEBUG_ALLOC
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%p DESTROY POOL\n", (void *) pop);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%p DESTROY POOL\n", (void *) pop);
#endif
apr_pool_clear(pop);
if (switch_queue_trypush(memory_manager.pool_recycle_queue, pop) != SWITCH_STATUS_SUCCESS) {
switch_mutex_lock(memory_manager.mem_lock);
#endif
#ifdef DEBUG_ALLOC
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%p DESTROY POOL\n", (void *) pop);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%p DESTROY POOL\n", (void *) pop);
#endif
apr_pool_destroy(pop);
#ifdef USE_MEM_LOCK
memory_manager.pool_thread_running = 0;
switch_thread_join(&st, pool_thread_p);
-
-
+
+
while (switch_queue_trypop(memory_manager.pool_queue, &pop) == SWITCH_STATUS_SUCCESS && pop) {
apr_pool_destroy(pop);
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Michael Jerris <mike@jerris.com>
* Paul D. Tinsley <pdt at jackhammer.org>
odd = switch_test_flag(alloc, SPF_ODD);
alloc->flags |= runtime.port_alloc_flags;
-
+
if (!(even && odd)) {
if (even) {
if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
return SWITCH_FALSE;
}
-
+
if (switch_sockaddr_info_get(&local_addr, alloc->ip, SWITCH_UNSPEC, port, 0, pool) == SWITCH_STATUS_SUCCESS) {
if (switch_socket_create(&sock, family, type, 0, pool) == SWITCH_STATUS_SUCCESS) {
if (switch_socket_bind(sock, local_addr) == SWITCH_STATUS_SUCCESS) {
switch_socket_close(sock);
}
}
-
+
switch_core_destroy_memory_pool(&pool);
-
+
return r;
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Michael Jerris <mike@jerris.com>
* Paul D. Tinsley <pdt at jackhammer.org>
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Michael Jerris <mike@jerris.com>
* Paul D. Tinsley <pdt at jackhammer.org>
{
int i = (int) target;
- if (i == 0 || i == 1) {
+ if (i == 0 || i == 1) {
return session->dmachine[i];
}
}
SWITCH_DECLARE(switch_status_t) switch_core_session_set_codec_slin(switch_core_session_t *session, switch_slin_data_t *data)
-
+
{
switch_codec_implementation_t read_impl = { 0 };
int interval;
if ((session = switch_core_session_locate(np->str))) {
const char *this_val;
if (switch_channel_up_nosig(session->channel) &&
- (this_val = switch_channel_get_variable_dup(session->channel, var_name, SWITCH_FALSE, -1)) &&
+ (this_val = switch_channel_get_variable_dup(session->channel, var_name, SWITCH_FALSE, -1)) &&
(!var_val || (like && switch_stristr(like, var_val)) || !strcmp(this_val, var_val))) {
switch_console_push_match(&my_matches, (const char *) np->str);
}
switch_core_session_t *session;
switch_memory_pool_t *pool;
struct str_node *head = NULL, *np;
-
+
switch_core_new_memory_pool(&pool);
-
+
switch_mutex_lock(runtime.session_hash_mutex);
for (hi = switch_core_hash_first(session_manager.session_table); hi; hi = switch_core_hash_next(&hi)) {
switch_core_hash_this(hi, NULL, NULL, &val);
}
switch_mutex_unlock(runtime.session_hash_mutex);
- for(np = head; np; np = np->next) {
+ for(np = head; np; np = np->next) {
if ((session = switch_core_session_locate(np->str))) {
switch_channel_hangup(session->channel, cause);
switch_core_session_rwunlock(session);
switch_channel_set_variable(peer_channel, SWITCH_ORIGINATOR_CODEC_VARIABLE, ep);
}
-
+
if (switch_channel_test_flag(channel, CF_MSRPS) || switch_channel_test_flag(channel, CF_WANT_MSRPS)) {
switch_channel_set_flag(peer_channel, CF_WANT_MSRPS);
} else if (switch_channel_test_flag(channel, CF_MSRP) || switch_channel_test_flag(channel, CF_WANT_MSRP)) {
if ((status = switch_core_session_read_lock_hangup(session)) != SWITCH_STATUS_SUCCESS) {
return status;
}
-
+
if (!message->_file) {
message->_file = file;
}
if (zstr(message->string_array_arg[0]) && !zstr(message->string_arg)) {
arg = switch_core_session_strdup(session, message->string_arg);
- switch_separate_string(arg, '|', (char **)message->string_array_arg, 2);
+ switch_separate_string(arg, '|', (char **)message->string_array_arg, 2);
}
if (!zstr(message->string_array_arg[0])) {
if (!zstr(message->string_array_arg[1])) {
switch_channel_set_variable(session->channel, "last_sent_callee_id_number", message->string_array_arg[1]);
}
-
+
if (switch_true(switch_channel_get_variable(session->channel, SWITCH_IGNORE_DISPLAY_UPDATES_VARIABLE))) {
switch_log_printf(SWITCH_CHANNEL_ID_LOG, message->_file, message->_func, message->_line,
switch_log_printf(SWITCH_CHANNEL_ID_LOG, message->_file, message->_func, message->_line,
switch_core_session_get_uuid(session), SWITCH_LOG_DEBUG, "%s skip receive message [%s] (channel is hungup already)\n",
switch_channel_get_name(session->channel), message_names[message->message_id]);
-
+
} else {
if (session->media_handle) {
status = switch_core_media_receive_message(session, message);
switch_channel_clear_flag(session->channel, CF_CONFIRM_BLIND_TRANSFER);
if (!zstr(uuid) && (other_session = switch_core_session_locate(uuid))) {
- switch_core_session_message_t msg = { 0 };
+ switch_core_session_message_t msg = { 0 };
msg.message_id = SWITCH_MESSAGE_INDICATE_BLIND_TRANSFER_RESPONSE;
msg.from = __FILE__;
msg.numeric_arg = 1;
switch_core_session_wake_session_thread(session);
}
-
+
return status;
}
top:
status = switch_mutex_trylock(session->mutex);
-
+
if (status == SWITCH_STATUS_SUCCESS) {
switch_thread_cond_signal(session->cond);
switch_mutex_unlock(session->mutex);
switch_event_t *event;
switch_core_session_t *session;
char *uuid = task->cmd_arg;
- switch_core_session_message_t msg = { 0 };
+ switch_core_session_message_t msg = { 0 };
if ((session = switch_core_session_locate(uuid))) {
switch_event_create(&event, SWITCH_EVENT_SESSION_HEARTBEAT);
if (check_status == SWITCH_STATUS_SUCCESS) {
switch_thread_data_t *td = (switch_thread_data_t *) pop;
-#ifdef DEBUG_THREAD_POOL
+#ifdef DEBUG_THREAD_POOL
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "Worker Thread %ld Processing\n", (long) (intptr_t) thread);
#endif
td->func(thread, td->obj);
"Artoo reduces the max sessions to %d thus, saving the switch from certain doom.\n", sess_count - 10);
}
-
+
switch_mutex_unlock(session_manager.mutex);
}
-static switch_status_t check_queue(void)
+static switch_status_t check_queue(void)
{
switch_status_t status = SWITCH_STATUS_FALSE;
switch_mutex_lock(session_manager.mutex);
switch_threadattr_t *thd_attr;
switch_memory_pool_t *pool;
switch_thread_pool_node_t *node;
-
+
switch_core_new_memory_pool(&pool);
node = switch_core_alloc(pool, sizeof(*node));
node->pool = pool;
status = switch_queue_push(session_manager.thread_queue, td);
check_queue();
- return status;
+ return status;
}
SWITCH_DECLARE(switch_status_t) switch_core_session_thread_pool_launch(switch_core_session_t *session)
switch_status_t status = SWITCH_STATUS_FALSE;
switch_thread_t *thread;
switch_threadattr_t *thd_attr;
-
+
if (switch_test_flag(session, SSF_THREAD_RUNNING) || switch_test_flag(session, SSF_THREAD_STARTED)) {
status = SWITCH_STATUS_INUSE;
goto end;
if (switch_test_flag((&runtime), SCF_SESSION_THREAD_POOL)) {
return switch_core_session_thread_pool_launch(session);
}
-
+
switch_mutex_lock(session->mutex);
if (switch_test_flag(session, SSF_THREAD_RUNNING)) {
status = SWITCH_STATUS_SUCCESS;
} else {
switch_clear_flag(session, SSF_THREAD_RUNNING);
- switch_clear_flag(session, SSF_THREAD_STARTED);
+ switch_clear_flag(session, SSF_THREAD_STARTED);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Cannot create thread!\n");
thread_launch_failure();
}
SWITCH_DECLARE(const char *) switch_core_session_get_text_buffer(switch_core_session_t *session)
{
const char *buf = NULL;
-
+
if (session->text_buffer) {
switch_mutex_lock(session->text_mutex);
buf = (const char *)switch_core_session_strdup(session, (const char *) switch_buffer_get_head_pointer(session->text_buffer));
}
}
}
-
+
if ((callflow = switch_xml_child(xml, "callflow"))) {
if ((tag2 = switch_xml_child(callflow, "caller_profile"))) {
switch_caller_profile_t *caller_profile;
count = session_manager.session_count;
sps = --runtime.sps;
switch_mutex_unlock(runtime.throttle_mutex);
-
+
if (sps <= 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Throttle Error! %d\n", session_manager.session_count);
UNPROTECT_INTERFACE(endpoint_interface);
{
switch_event_t *execute_event;
char *ap, *arp;
-
+
if (!arg && strstr(app, "::")) {
ap = switch_core_session_strdup(session, app);
app = ap;
arg = arp + 2;
}
}
-
+
if (switch_event_create(&execute_event, SWITCH_EVENT_COMMAND) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "call-command", "execute");
switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "execute-app-name", app);
if (arg) {
switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "execute-app-arg", arg);
}
-
+
if (!switch_channel_test_flag(session->channel, CF_PROXY_MODE)) {
switch_channel_set_flag(session->channel, CF_BLOCK_BROADCAST_UNTIL_MEDIA);
}
switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "event-lock", "true");
switch_core_session_queue_private_event(session, &execute_event, SWITCH_FALSE);
-
+
return SWITCH_STATUS_SUCCESS;
}
*p++ = '0';
arg = p;
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s ASYNC CALL CONVERTED TO INLINE %s(%s)\n",
- switch_channel_get_name(session->channel), app, switch_str_nil(arg));
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s ASYNC CALL CONVERTED TO INLINE %s(%s)\n",
+ switch_channel_get_name(session->channel), app, switch_str_nil(arg));
}
-
+
if ((application_interface = switch_loadable_module_get_application_interface(app)) == 0) {
return SWITCH_STATUS_FALSE;
}
if (switch_test_flag(application_interface, SAF_ZOMBIE_EXEC)) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s ZOMBIE EXEC %s(%s)\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s ZOMBIE EXEC %s(%s)\n",
switch_channel_get_name(session->channel), app, switch_str_nil(arg));
goto exec;
}
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
"%s Channel is hungup and application '%s' does not have the zombie_exec flag.\n",
switch_channel_get_name(session->channel), app);
} while(!ready && sanity);
if (!ready) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
"Cannot execute app '%s' media required on an outbound channel that does not have media established\n", app);
switch_goto_status(SWITCH_STATUS_FALSE, done);
}
}
}
- if (switch_channel_text_only(session->channel) &&
- !switch_test_flag(application_interface, SAF_SUPPORT_NOMEDIA) &&
+ if (switch_channel_text_only(session->channel) &&
+ !switch_test_flag(application_interface, SAF_SUPPORT_NOMEDIA) &&
!switch_test_flag(application_interface, SAF_SUPPORT_TEXT_ONLY)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Application %s does not support text-only mode on channel %s!\n",
app, switch_channel_get_name(session->channel));
if (expanded && *expanded == '%' && (*(expanded+1) == '[' || *(expanded+2) == '[')) {
char *p, *dup;
switch_event_t *ovars = NULL;
-
+
p = expanded + 1;
if (*p != '[') {
}
dup = strdup(p);
-
+
if (expanded != arg) {
switch_safe_free(expanded);
}
scope = 1;
}
-
+
if ( switch_core_test_flag(SCF_DIALPLAN_TIMESTAMPS) ) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "EXECUTE %s %s(%s)\n",
switch_channel_get_name(session->channel), app, switch_str_nil(expanded));
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
switch_mux_channels((int16_t *) data, rlen, 1, sh->channels);
*datalen = rlen * 2 * sh->channels;
}
-
+
return status;
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Michael Jerris <mike@jerris.com>
* Paul D. Tinsley <pdt at jackhammer.org>
sql_manager.total_handles--;
break;
}
-
+
last = dbh_ptr;
}
switch_mutex_unlock(sql_manager.dbh_mutex);
hash = switch_ci_hashfunc_default(db_str, &hlen);
thread_hash = switch_ci_hashfunc_default(thread_str, &hlen);
-
+
switch_mutex_lock(sql_manager.dbh_mutex);
for (dbh_ptr = sql_manager.handle_pool; dbh_ptr; dbh_ptr = dbh_ptr->next) {
if (!r) {
for (dbh_ptr = sql_manager.handle_pool; dbh_ptr; dbh_ptr = dbh_ptr->next) {
- if (dbh_ptr->hash == hash && (dbh_ptr->type != SCDB_TYPE_PGSQL || !dbh_ptr->use_count) && !switch_test_flag(dbh_ptr, CDF_PRUNE) &&
+ if (dbh_ptr->hash == hash && (dbh_ptr->type != SCDB_TYPE_PGSQL || !dbh_ptr->use_count) && !switch_test_flag(dbh_ptr, CDF_PRUNE) &&
switch_mutex_trylock(dbh_ptr->mutex) == SWITCH_STATUS_SUCCESS) {
r = dbh_ptr;
break;
}
- }
+ }
}
-
+
if (r) {
r->use_count++;
r->total_used_count++;
switch_mutex_unlock(sql_manager.dbh_mutex);
return r;
-
+
}
/*!
{
switch_status_t r;
char *dsn;
-
+
if (!sql_manager.manage) {
return SWITCH_STATUS_FALSE;
}
if ((r = _switch_cache_db_get_db_handle_dsn(dbh, dsn, file, func, line)) != SWITCH_STATUS_SUCCESS) {
*dbh = NULL;
}
-
+
return r;
}
} else {
if (!prune) {
if (!sanity) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SANITY CHECK FAILED! Handle %s (%s;%s) was not properly released.\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SANITY CHECK FAILED! Handle %s (%s;%s) was not properly released.\n",
dbh->name, dbh->creator, dbh->last_user);
} else {
locked++;
}
continue;
}
-
+
}
if (locked) {
(*dbh)->last_used = switch_epoch_time_now(NULL);
(*dbh)->io_mutex = NULL;
-
+
if ((*dbh)->use_count) {
if (--(*dbh)->use_count == 0) {
(*dbh)->thread_hash = 1;
}
-SWITCH_DECLARE(switch_status_t) _switch_cache_db_get_db_handle_dsn(switch_cache_db_handle_t **dbh, const char *dsn,
+SWITCH_DECLARE(switch_status_t) _switch_cache_db_get_db_handle_dsn(switch_cache_db_handle_t **dbh, const char *dsn,
const char *file, const char *func, int line)
{
switch_cache_db_connection_options_t connection_options = { {0} };
} else {
switch_set_string(tmp, dsn+7);
}
-
+
connection_options.odbc_options.dsn = tmp;
if ((p = strchr(tmp, ':'))) {
*p++ = '\0';
connection_options.odbc_options.user = p;
-
+
if ((p = strchr(connection_options.odbc_options.user, ':'))) {
*p++ = '\0';
connection_options.odbc_options.pass = p;
while(runtime.max_db_handles && sql_manager.total_handles >= runtime.max_db_handles && sql_manager.total_used_handles >= sql_manager.total_handles) {
if (!waiting++) {
- switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_WARNING, "Max handles %u exceeded, blocking....\n",
+ switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_WARNING, "Max handles %u exceeded, blocking....\n",
runtime.max_db_handles);
}
switch_yield(yield_len);
total_yield += yield_len;
-
+
if (runtime.db_handle_timeout && total_yield > runtime.db_handle_timeout) {
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_ERROR, "Error connecting\n");
*dbh = NULL;
snprintf(db_str, sizeof(db_str) - 1, "db=\"%s\",type=\"%s\"", db_name, db_type);
}
snprintf(db_callsite_str, sizeof(db_callsite_str) - 1, "%s:%d", file, line);
- snprintf(thread_str, sizeof(thread_str) - 1, "thread=\"%lu\"", (unsigned long) (intptr_t) self);
+ snprintf(thread_str, sizeof(thread_str) - 1, "thread=\"%lu\"", (unsigned long) (intptr_t) self);
if ((new_dbh = get_handle(db_str, db_callsite_str, thread_str))) {
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG10,
if (new_dbh) {
new_dbh->last_used = switch_epoch_time_now(NULL);
}
-
+
*dbh = new_dbh;
return *dbh ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
char *tmp = NULL;
char *type = NULL;
switch_mutex_t *io_mutex = dbh->io_mutex;
-
+
if (io_mutex) switch_mutex_lock(io_mutex);
if (err) {
switch_cache_db_execute_sql_real(dbh, sql, &errmsg);
if (io_mutex) switch_mutex_unlock(io_mutex);
-
+
if (errmsg) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL ERR [%s]\n", errmsg);
switch_safe_free(errmsg);
break;
}
}
-
+
return status;
}
-SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute_trans_full(switch_cache_db_handle_t *dbh,
+SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute_trans_full(switch_cache_db_handle_t *dbh,
char *sql, uint32_t retries,
const char *pre_trans_execute,
const char *post_trans_execute,
case SCDB_TYPE_ODBC:
{
switch_odbc_status_t result;
-
+
if ((result = switch_odbc_SQLSetAutoCommitAttr(dbh->native_handle.odbc_dbh, 0)) != SWITCH_ODBC_SUCCESS) {
char tmp[100];
switch_snprintfv(tmp, sizeof(tmp), "%q-%i", "Unable to Set AutoCommit Off", result);
case SCDB_TYPE_PGSQL:
{
switch_pgsql_status_t result;
-
+
if ((result = switch_pgsql_SQLSetAutoCommitAttr(dbh->native_handle.pgsql_dbh, 0)) != SWITCH_PGSQL_SUCCESS) {
char tmp[100];
switch_snprintfv(tmp, sizeof(tmp), "%q-%i", "Unable to Set AutoCommit Off", result);
goto again;
}
-
+
switch_yield(100000);
if (begin_retries == 0) {
r = h->callback(h->pdata, event);
switch_event_destroy(&event);
-
+
return r;
}
h.callback = callback;
h.pdata = pdata;
-
+
switch (dbh->type) {
case SCDB_TYPE_PGSQL:
{
h.callback = callback;
h.pdata = pdata;
-
+
switch (dbh->type) {
case SCDB_TYPE_PGSQL:
{
while (sql_manager.db_thread_running == 1) {
if (++sec == SQL_CACHE_TIMEOUT) {
- sql_close(switch_epoch_time_now(NULL));
+ sql_close(switch_epoch_time_now(NULL));
sec = 0;
}
int tries = 0;
top:
-
+
status = switch_mutex_trylock(qm->cond_mutex);
if (status == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL ERR: [%s] %s\n", job->sql, err);
switch_safe_free(err);
}
-
+
switch_cache_db_release_db_handle(&dbh);
-
+
if (pool) {
switch_core_destroy_memory_pool(&pool);
}
static switch_thread_data_t *new_job(switch_sql_queue_manager_t *qm, const char *sql,
switch_core_db_callback_func_t callback,
switch_core_db_err_callback_func_t err_callback,
- switch_core_db_event_callback_func_t event_callback,
- switch_core_db_err_callback_func_t event_err_callback,
+ switch_core_db_event_callback_func_t event_callback,
+ switch_core_db_err_callback_func_t event_err_callback,
void *pdata)
{
switch_memory_pool_t *pool;
}
-SWITCH_DECLARE(void) switch_sql_queue_manager_execute_sql_callback(switch_sql_queue_manager_t *qm,
+SWITCH_DECLARE(void) switch_sql_queue_manager_execute_sql_callback(switch_sql_queue_manager_t *qm,
const char *sql, switch_core_db_callback_func_t callback, void *pdata)
{
-
+
switch_thread_data_t *td;
if ((td = new_job(qm, sql, callback, NULL, NULL, NULL, pdata))) {
switch_thread_pool_launch_thread(&td);
switch_core_db_callback_func_t callback,
switch_core_db_err_callback_func_t err_callback, void *pdata)
{
-
+
switch_thread_data_t *td;
if ((td = new_job(qm, sql, callback, err_callback, NULL, NULL, pdata))) {
switch_thread_pool_launch_thread(&td);
}
}
-SWITCH_DECLARE(void) switch_sql_queue_manager_execute_sql_event_callback(switch_sql_queue_manager_t *qm,
+SWITCH_DECLARE(void) switch_sql_queue_manager_execute_sql_event_callback(switch_sql_queue_manager_t *qm,
const char *sql, switch_core_db_event_callback_func_t callback, void *pdata)
{
-
+
switch_thread_data_t *td;
if ((td = new_job(qm, sql, NULL, NULL, callback, NULL, pdata))) {
switch_thread_pool_launch_thread(&td);
switch_core_db_err_callback_func_t err_callback,
void *pdata)
{
-
+
switch_thread_data_t *td;
if ((td = new_job(qm, sql, NULL, NULL, callback, err_callback, pdata))) {
switch_thread_pool_launch_thread(&td);
}
}
} while(status != SWITCH_STATUS_SUCCESS);
-
+
qm_wake(qm);
return SWITCH_STATUS_SUCCESS;
}
if (switch_cache_db_get_db_handle_dsn(&dbh, qm->dsn) == SWITCH_STATUS_SUCCESS) {
- switch_cache_db_execute_sql(dbh, (char *)sql, NULL);
+ switch_cache_db_execute_sql(dbh, (char *)sql, NULL);
switch_cache_db_release_db_handle(&dbh);
}
SWITCH_DECLARE(switch_status_t) switch_sql_queue_manager_init_name(const char *name,
- switch_sql_queue_manager_t **qmp,
+ switch_sql_queue_manager_t **qmp,
uint32_t numq, const char *dsn, uint32_t max_trans,
const char *pre_trans_execute,
const char *post_trans_execute,
switch_mutex_init(&qm->cond2_mutex, SWITCH_MUTEX_NESTED, qm->pool);
switch_mutex_init(&qm->mutex, SWITCH_MUTEX_NESTED, qm->pool);
switch_thread_cond_create(&qm->cond, qm->pool);
-
+
qm->sql_queue = switch_core_alloc(qm->pool, sizeof(switch_queue_t *) * numq);
qm->written = switch_core_alloc(qm->pool, sizeof(uint32_t) * numq);
qm->pre_written = switch_core_alloc(qm->pool, sizeof(uint32_t) * numq);
case SCDB_TYPE_ODBC:
{
switch_odbc_status_t result;
-
+
if ((result = switch_odbc_SQLSetAutoCommitAttr(qm->event_db->native_handle.odbc_dbh, 0)) != SWITCH_ODBC_SUCCESS) {
char tmp[100];
switch_snprintfv(tmp, sizeof(tmp), "%q-%i", "Unable to Set AutoCommit Off", result);
case SCDB_TYPE_PGSQL:
{
switch_pgsql_status_t result;
-
+
if ((result = switch_pgsql_SQLSetAutoCommitAttr(qm->event_db->native_handle.pgsql_dbh, 0)) != SWITCH_PGSQL_SUCCESS) {
char tmp[100];
switch_snprintfv(tmp, sizeof(tmp), "%q-%i", "Unable to Set AutoCommit Off", result);
if (!qm_ttl(qm)) {
goto check;
}
- written = do_trans(qm);
+ written = do_trans(qm);
iterations += written;
} while(written == qm->max_trans);
-
+
if (switch_test_flag((&runtime), SCF_DEBUG_SQL)) {
char line[128] = "";
switch_size_t l;
-
+
switch_snprintf(line, sizeof(line), "%s RUN QUEUE [", qm->name);
-
+
for (i = 0; i < qm->numq; i++) {
l = strlen(line);
switch_snprintf(line + l, sizeof(line) - l, "%d%s", switch_queue_size(qm->sql_queue[i]), i == qm->numq - 1 ? "" : "|");
}
-
+
l = strlen(line);
switch_snprintf(line + l, sizeof(line) - l, "]--[%d]\n", iterations);
-
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "%s", line);
-
+
}
check:
switch_cache_db_release_db_handle(&qm->event_db);
qm->thread_running = 0;
-
+
return NULL;
}
}
data_copy = strdup(data);
-
+
col_count = switch_split(data_copy, ':', cols);
SWITCH_STANDARD_STREAM(stream);
}
switch_safe_free(data_copy);
-
+
return r;
-
+
}
case SWITCH_EVENT_CHANNEL_DESTROY:
{
const char *uuid = switch_event_get_header(event, "unique-id");
-
+
if (uuid) {
new_sql() = switch_mprintf("delete from channels where uuid='%q'",
uuid);
case SWITCH_EVENT_CHANNEL_HOLD:
case SWITCH_EVENT_CHANNEL_UNHOLD:
case SWITCH_EVENT_CHANNEL_EXECUTE: {
-
+
new_sql() = switch_mprintf("update channels set application='%q',application_data='%q',"
"presence_id='%q',presence_data='%q',accountcode='%q' where uuid='%q'",
switch_event_get_header_nil(event, "application"),
extra_cols,
switch_event_get_header_nil(event, "unique-id"));
free(extra_cols);
-
+
} else {
new_sql() = switch_mprintf("update channels set state='%q' where uuid='%q'",
switch_event_get_header_nil(event, "channel-state"),
if (uuid && (extra_cols = parse_presence_data_cols(event))) {
new_sql() = switch_mprintf("update channels set %s where uuid='%q'", extra_cols, uuid);
switch_safe_free(extra_cols);
- }
+ }
new_sql() = switch_mprintf("update channels set call_uuid='%q' where uuid='%q' or uuid='%q'",
switch_event_get_header_nil(event, "channel-call-uuid"), a_uuid, b_uuid);
-
+
new_sql() = switch_mprintf("insert into calls (call_uuid,call_created,call_created_epoch,"
"caller_uuid,callee_uuid,hostname) "
if (uuid && (extra_cols = parse_presence_data_cols(event))) {
new_sql() = switch_mprintf("update channels set %s where uuid='%q'", extra_cols, uuid);
switch_safe_free(extra_cols);
- }
+ }
new_sql() = switch_mprintf("update channels set call_uuid=uuid where call_uuid='%q'",
switch_event_get_header_nil(event, "channel-call-uuid"));
-
+
new_sql() = switch_mprintf("delete from calls where (caller_uuid='%q' or callee_uuid='%q')",
cuuid, cuuid);
break;
if (sql_idx) {
int i = 0;
-
+
for (i = 0; i < sql_idx; i++) {
if (switch_stristr("update channels", sql[i]) || switch_stristr("delete from channels", sql[i])) {
" metadata VARCHAR(256)\n"
");\n";
-
+
static char detailed_calls_sql[] =
"b.cid_num as b_cid_num,"
"b.ip_addr as b_ip_addr,"
"b.dest as b_dest,"
-
+
"b.presence_id as b_presence_id,"
"b.presence_data as b_presence_data,"
"b.accountcode as b_accountcode,"
switch_cache_db_execute_sql(dbh, sql, NULL);
switch_safe_free(sql);
}
-
+
switch_cache_db_release_db_handle(&dbh);
}
if (argc < 4) {
return 0;
}
-
+
if (!(xml = switch_xml_parse_str_dynamic(argv[4], SWITCH_TRUE))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "XML ERROR\n");
return 0;
const char *cbname;
switch_channel_set_flag(session->channel, CF_RECOVERING);
-
+
if (switch_channel_get_partner_uuid(channel)) {
switch_channel_set_flag(channel, CF_RECOVERING_BRIDGE);
if ((cbname = switch_channel_get_variable(channel, "secondary_recovery_module"))) {
switch_core_recover_callback_t recover_callback;
-
+
if ((recover_callback = switch_core_get_secondary_recover_callback(cbname))) {
r = recover_callback(session);
}
}
-
-
+
+
}
-
+
if (r > 0) {
if (!switch_channel_test_flag(channel, CF_RECOVERING_BRIDGE)) {
}
switch_channel_set_state(channel, CS_INIT);
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE,
"Resurrecting fallen channel %s\n", switch_channel_get_name(channel));
switch_core_session_thread_launch(session);
*rp = (*rp) + 1;
-
+
}
} else {
}
SWITCH_DECLARE(int) switch_core_recovery_recover(const char *technology, const char *profile_name)
-
+
{
char *sql = NULL;
char *errmsg = NULL;
}
if (zstr(technology)) {
-
+
if (zstr(profile_name)) {
sql = switch_mprintf("select technology, profile_name, hostname, uuid, metadata "
- "from recovery where runtime_uuid!='%q'",
+ "from recovery where runtime_uuid!='%q'",
switch_core_get_uuid());
} else {
sql = switch_mprintf("select technology, profile_name, hostname, uuid, metadata "
- "from recovery where runtime_uuid!='%q' and profile_name='%q'",
+ "from recovery where runtime_uuid!='%q' and profile_name='%q'",
switch_core_get_uuid(), profile_name);
}
if (zstr(profile_name)) {
sql = switch_mprintf("select technology, profile_name, hostname, uuid, metadata "
- "from recovery where technology='%q' and runtime_uuid!='%q'",
+ "from recovery where technology='%q' and runtime_uuid!='%q'",
technology, switch_core_get_uuid());
} else {
sql = switch_mprintf("select technology, profile_name, hostname, uuid, metadata "
- "from recovery where technology='%q' and runtime_uuid!='%q' and profile_name='%q'",
+ "from recovery where technology='%q' and runtime_uuid!='%q' and profile_name='%q'",
technology, switch_core_get_uuid(), profile_name);
}
}
switch_cache_db_execute_sql_callback(dbh, sql, recover_callback, &r, &errmsg);
-
+
if (errmsg) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL ERR: [%s] %s\n", sql, errmsg);
switch_safe_free(errmsg);
if (zstr(technology)) {
if (zstr(profile_name)) {
- sql = switch_mprintf("delete from recovery where runtime_uuid!='%q'",
+ sql = switch_mprintf("delete from recovery where runtime_uuid!='%q'",
switch_core_get_uuid());
} else {
- sql = switch_mprintf("delete from recovery where runtime_uuid!='%q' and profile_name='%q'",
+ sql = switch_mprintf("delete from recovery where runtime_uuid!='%q' and profile_name='%q'",
switch_core_get_uuid(), profile_name);
}
} else {
if (zstr(profile_name)) {
- sql = switch_mprintf("delete from recovery where runtime_uuid!='%q' and technology='%q' ",
+ sql = switch_mprintf("delete from recovery where runtime_uuid!='%q' and technology='%q' ",
switch_core_get_uuid(), technology);
} else {
- sql = switch_mprintf("delete from recovery where runtime_uuid!='%q' and technology='%q' and profile_name='%q'",
+ sql = switch_mprintf("delete from recovery where runtime_uuid!='%q' and technology='%q' and profile_name='%q'",
switch_core_get_uuid(), technology, profile_name);
}
}
if (force) {
sql = switch_mprintf("delete from recovery where uuid='%q'", switch_core_session_get_uuid(session));
-
+
} else {
sql = switch_mprintf("delete from recovery where runtime_uuid='%q' and uuid='%q'",
switch_core_get_uuid(), switch_core_session_get_uuid(session));
}
switch_sql_queue_manager_push(sql_manager.qm, sql, 3, SWITCH_FALSE);
-
+
switch_channel_clear_flag(channel, CF_TRACKED);
}
-
+
}
SWITCH_DECLARE(void) switch_core_recovery_track(switch_core_session_t *session)
} else {
sql = switch_mprintf("insert into recovery (runtime_uuid, technology, profile_name, hostname, uuid, metadata) "
"values ('%q','%q','%q','%q','%q','%q')",
- switch_core_get_uuid(), switch_str_nil(technology),
+ switch_core_get_uuid(), switch_str_nil(technology),
switch_str_nil(profile_name), switch_core_get_switchname(), switch_core_session_get_uuid(session), xml_cdr_text);
}
switch_safe_free(xml_cdr_text);
switch_channel_set_flag(channel, CF_TRACKED);
-
+
}
-
+
}
-SWITCH_DECLARE(switch_status_t) switch_core_add_registration(const char *user, const char *realm, const char *token, const char *url, uint32_t expires,
+SWITCH_DECLARE(switch_status_t) switch_core_add_registration(const char *user, const char *realm, const char *token, const char *url, uint32_t expires,
const char *network_ip, const char *network_port, const char *network_proto,
const char *metadata)
{
}
if (runtime.multiple_registrations) {
- sql = switch_mprintf("delete from registrations where hostname='%q' and (url='%q' or token='%q')",
+ sql = switch_mprintf("delete from registrations where hostname='%q' and (url='%q' or token='%q')",
switch_core_get_switchname(), url, switch_str_nil(token));
} else {
- sql = switch_mprintf("delete from registrations where reg_user='%q' and realm='%q' and hostname='%q'",
+ sql = switch_mprintf("delete from registrations where reg_user='%q' and realm='%q' and hostname='%q'",
user, realm, switch_core_get_switchname());
}
);
}
-
+
switch_sql_queue_manager_push(sql_manager.qm, sql, 0, SWITCH_FALSE);
-
+
return SWITCH_STATUS_SUCCESS;
}
SWITCH_DECLARE(switch_status_t) switch_core_expire_registration(int force)
{
-
+
char *sql;
time_t now;
if (!sql_manager.manage) goto skip;
- top:
+ top:
/* Activate SQL database */
if (switch_core_db_handle(&sql_manager.dbh) != SWITCH_STATUS_SUCCESS) {
switch_cache_db_test_reactive(sql_manager.dbh, "select hostname from aliases", "DROP TABLE aliases", create_alias_sql);
switch_cache_db_test_reactive(sql_manager.dbh, "select hostname from complete", "DROP TABLE complete", create_complete_sql);
switch_cache_db_test_reactive(sql_manager.dbh, "select hostname from nat", "DROP TABLE nat", create_nat_sql);
- switch_cache_db_test_reactive(sql_manager.dbh, "delete from registrations where reg_user=''",
+ switch_cache_db_test_reactive(sql_manager.dbh, "delete from registrations where reg_user=''",
"DROP TABLE registrations", create_registrations_sql);
switch_cache_db_test_reactive(sql_manager.dbh, "select metadata from registrations", NULL, "ALTER TABLE registrations ADD COLUMN metadata VARCHAR(256)");
switch_cache_db_test_reactive(sql_manager.dbh, "select * from basic_calls where sent_callee_name=''", "DROP VIEW basic_calls", basic_calls_sql);
switch_cache_db_test_reactive(sql_manager.dbh, "select * from detailed_calls where sent_callee_name=''", "DROP VIEW detailed_calls", detailed_calls_sql);
if (runtime.odbc_dbtype == DBTYPE_DEFAULT) {
- switch_cache_db_test_reactive(sql_manager.dbh, "delete from registrations where reg_user=''",
+ switch_cache_db_test_reactive(sql_manager.dbh, "delete from registrations where reg_user=''",
"DROP TABLE registrations", create_registrations_sql);
} else {
char *tmp = switch_string_replace(create_registrations_sql, "url TEXT", "url VARCHAR(max)");
- switch_cache_db_test_reactive(sql_manager.dbh, "delete from registrations where reg_user=''",
+ switch_cache_db_test_reactive(sql_manager.dbh, "delete from registrations where reg_user=''",
"DROP TABLE registrations", tmp);
free(tmp);
}
case SCDB_TYPE_ODBC:
{
switch_odbc_status_t result;
-
+
if ((result = switch_odbc_SQLSetAutoCommitAttr(sql_manager.dbh->native_handle.odbc_dbh, 0)) != SWITCH_ODBC_SUCCESS) {
char tmp[100];
switch_snprintfv(tmp, sizeof(tmp), "%q-%i", "Unable to Set AutoCommit Off", result);
case SCDB_TYPE_PGSQL:
{
switch_pgsql_status_t result;
-
+
if ((result = switch_pgsql_SQLSetAutoCommitAttr(sql_manager.dbh->native_handle.pgsql_dbh, 0)) != SWITCH_PGSQL_SUCCESS) {
char tmp[100];
switch_snprintfv(tmp, sizeof(tmp), "%q-%i", "Unable to Set AutoCommit Off", result);
}
break;
}
-
+
switch_cache_db_execute_sql(sql_manager.dbh, "delete from channels where hostname=''", &err);
if (!err) {
switch_cache_db_execute_sql(sql_manager.dbh, "delete from channels where hostname=''", &err);
}
}
-
+
if (err) {
//runtime.odbc_dsn = NULL;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Database Error [%s]\n", err);
//switch_cache_db_release_db_handle(&sql_manager.dbh);
- if (switch_stristr("read-only", err)) {
+ if (switch_stristr("read-only", err)) {
switch_safe_free(err);
} else {
switch_safe_free(err);
switch_event_bind("core_db", SWITCH_EVENT_CALL_SECURE, SWITCH_EVENT_SUBCLASS_ANY, core_event_handler, NULL);
switch_event_bind("core_db", SWITCH_EVENT_NAT, SWITCH_EVENT_SUBCLASS_ANY, core_event_handler, NULL);
switch_event_bind("core_db", SWITCH_EVENT_CODEC, SWITCH_EVENT_SUBCLASS_ANY, core_event_handler, NULL);
-#endif
+#endif
switch_threadattr_create(&thd_attr, sql_manager.memory_pool);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL is not enabled\n");
}
-
+
switch_mutex_unlock(sql_manager.ctl_mutex);
}
}
count++;
-
+
if (dbh->use_count) {
used++;
}
-
+
stream->write_function(stream, "%s\n\tType: %s\n\tLast used: %d\n\tTotal used: %ld\n\tFlags: %s, %s(%d)\n"
"\tCreator: %s\n\tLast User: %s\n",
cleankey_str,
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Michael Jerris <mike@jerris.com>
* Paul D. Tinsley <pdt at jackhammer.org>
switch_core_recovery_untrack(session, SWITCH_TRUE);
}
-
+
if (!switch_channel_test_flag(session->channel, CF_ZOMBIE_EXEC)) {
return;
}
status = switch_core_session_execute_application(session,
current_application->application_name, current_application->application_data);
-
-
+
+
if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_IGNORE) {
return;
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Standard ROUTING\n", switch_channel_get_name(session->channel));
switch_channel_set_variable(session->channel, "call_uuid", switch_core_session_get_uuid(session));
-
+
if ((switch_channel_test_flag(session->channel, CF_ANSWERED) ||
switch_channel_test_flag(session->channel, CF_EARLY_MEDIA) ||
switch_channel_test_flag(session->channel, CF_SIGNAL_BRIDGE_TTL)) && switch_channel_test_flag(session->channel, CF_PROXY_MODE)) {
switch_channel_clear_flag(session->channel, CF_RESET);
switch_core_session_video_reset(session);
-
+
if ((extension = switch_channel_get_caller_extension(session->channel)) == 0) {
switch_channel_hangup(session->channel, SWITCH_CAUSE_NORMAL_CLEARING);
return;
}
- if (switch_channel_ready(session->channel) && switch_channel_get_state(session->channel) == CS_EXECUTE &&
- switch_channel_test_flag(session->channel, CF_CONFIRM_BLIND_TRANSFER) &&
+ if (switch_channel_ready(session->channel) && switch_channel_get_state(session->channel) == CS_EXECUTE &&
+ switch_channel_test_flag(session->channel, CF_CONFIRM_BLIND_TRANSFER) &&
(uuid = switch_channel_get_variable(session->channel, "blind_transfer_uuid"))) {
switch_core_session_t *other_session;
if ((other_session = switch_core_session_locate(uuid))) {
- switch_core_session_message_t msg = { 0 };
+ switch_core_session_message_t msg = { 0 };
msg.message_id = SWITCH_MESSAGE_INDICATE_BLIND_TRANSFER_RESPONSE;
msg.from = __FILE__;
msg.numeric_arg = 0;
switch_channel_clear_flag(session->channel, CF_CONFIRM_BLIND_TRANSFER);
}
}
-
+
if (switch_channel_ready(session->channel) && switch_channel_get_state(session->channel) == CS_EXECUTE) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "%s has executed the last dialplan instruction, hanging up.\n",
switch_channel_get_name(session->channel));
if (session->endpoint_interface->io_routines->state_run) {
rstatus = session->endpoint_interface->io_routines->state_run(session);
}
-
+
if (rstatus == SWITCH_STATUS_SUCCESS) {
for (ptr = session->event_hooks.state_run; ptr; ptr = ptr->next) {
if ((rstatus = ptr->state_run(session)) != SWITCH_STATUS_SUCCESS) {
switch_event_t *event;
STATE_MACRO(init, "INIT");
-
+
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_CREATE) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(session->channel, event);
switch_event_fire(&event);
switch_channel_set_flag(session->channel, CF_THREAD_SLEEPING);
if (switch_channel_get_state(session->channel) == switch_channel_get_running_state(session->channel)) {
switch_ivr_parse_all_events(session);
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG1, "%s session thread sleep state: %s!\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG1, "%s session thread sleep state: %s!\n",
switch_channel_get_name(session->channel),
switch_channel_state_name(switch_channel_get_running_state(session->channel)));
switch_thread_cond_wait(session->cond, session->mutex);
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG1, "%s session thread wake state: %s!\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG1, "%s session thread wake state: %s!\n",
switch_channel_get_name(session->channel),
switch_channel_state_name(switch_channel_get_running_state(session->channel)));
}
switch_safe_free(cmd);
-
+
switch_safe_free(stream.data);
}
}
}
switch_channel_process_device_hangup(session->channel);
-
+
switch_set_flag(session, SSF_HANGUP);
}
if (switch_true(switch_channel_get_variable(session->channel, "hangup_complete_with_xml"))) {
switch_xml_t cdr = NULL;
char *xml_cdr_text;
-
+
if (switch_ivr_generate_xml_cdr(session, &cdr) == SWITCH_STATUS_SUCCESS) {
xml_cdr_text = switch_xml_toxml(cdr, SWITCH_FALSE);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "CDR-Attached", "xml");
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Michael Jerris <mike@jerris.com>
* Paul D. Tinsley <pdt at jackhammer.org>
int i;
switch_assert(name);
-
+
for(i = 0; POS_TABLE[i].name; i++) {
if (!strcasecmp(POS_TABLE[i].name, name)) {
r = POS_TABLE[i].pos;
break;
}
}
-
+
return r;
}
int i;
switch_assert(name);
-
+
for(i = 0; IMG_FIT_TABLE[i].name; i++) {
if (!strcasecmp(IMG_FIT_TABLE[i].name, name)) {
r = IMG_FIT_TABLE[i].fit;
break;
}
}
-
+
return r;
}
return SWITCH_FALSE;
#endif
}
-
+
SWITCH_DECLARE(switch_image_t *)switch_img_alloc(switch_image_t *img,
switch_img_fmt_t fmt,
unsigned int d_w,
static inline void switch_img_draw_pixel(switch_image_t *img, int x, int y, switch_rgb_color_t *color)
{
-#ifdef SWITCH_HAVE_YUV
+#ifdef SWITCH_HAVE_YUV
switch_yuv_color_t yuv;
if (x < 0 || y < 0 || x >= img->d_w || y >= img->d_h) return;
SWITCH_DECLARE(void) switch_img_fill(switch_image_t *img, int x, int y, int w, int h, switch_rgb_color_t *color)
{
-#ifdef SWITCH_HAVE_YUV
+#ifdef SWITCH_HAVE_YUV
int len, i, max_h;
switch_yuv_color_t yuv_color;
static inline void switch_img_get_rgb_pixel(switch_image_t *img, switch_rgb_color_t *rgb, int x, int y)
{
-#ifdef SWITCH_HAVE_YUV
+#ifdef SWITCH_HAVE_YUV
if (x < 0 || y < 0 || x >= img->d_w || y >= img->d_h) return;
if (img->fmt == SWITCH_IMG_FMT_I420) {
rgb->g = *(++a);
rgb->b = *(++a);
}
-#endif
+#endif
}
SWITCH_DECLARE(void) switch_img_overlay(switch_image_t *IMG, switch_image_t *img, int x, int y, uint8_t percent)
switch_color_set_rgb(&rgb, str);
switch_color_rgb2yuv(&rgb, color);
-#endif
+#endif
}
#if SWITCH_HAVE_FREETYPE
switch_memory_pool_t *pool;
switch_assert(handleP);
-
+
old_handle = *handleP;
*handleP = NULL;
if (!old_handle) return;
-
+
#if SWITCH_HAVE_FREETYPE
if (old_handle->library) {
SWITCH_DECLARE(uint32_t) switch_img_txt_handle_render(switch_img_txt_handle_t *handle, switch_image_t *img,
int x, int y, const char *text,
- const char *font_family, const char *font_color,
+ const char *font_family, const char *font_color,
const char *bgcolor, uint16_t font_size, double angle)
{
#if SWITCH_HAVE_FREETYPE
if (error) continue;
this_x = pen.x + slot->bitmap_left;
-
+
if (img) {
/* now, draw to our target surface (convert position) */
draw_bitmap(handle, img, &slot->bitmap, this_x, pen.y - slot->bitmap_top + font_size);
if (strchr(text, ':')) {
argc = switch_split(duptxt, ':', argv);
-
+
if (argc > 0 && !zstr(argv[0])) {
fg = argv[0];
}
if (argc > 1 && !zstr(argv[1])) {
bg = argv[1];
}
-
+
if (argc > 2 && !zstr(argv[2])) {
font_face = argv[2];
}
-
+
if (argc > 3 && !zstr(argv[3])) {
fontsz = argv[3];
}
txt = argv[4];
}
} else txt = duptxt;
-
+
if (!txt) txt = duptxt;
if (strrchr(fontsz, '%')) {
while (*txt == ' ') txt++;
while (end_of(txt) == ' ') end_of(txt) = '\0';
-
+
len = strlen(txt);
if (len < 5) len = 5;
NULL,
font_size / 2, font_size / 2,
txt, NULL, fg, bg, 0, 0);
-
+
height = font_size * 2;
-
+
if (full && w > width) {
width = w;
} else {
int y_pos = 0;
switch_image_t *IMG = NULL, *scale_img = NULL;
switch_rgb_color_t bgcolor = { 0 };
-
+
switch_assert(imgP);
*imgP = NULL;
screen_aspect = (double) IMG->d_w / IMG->d_h;
img_aspect = (double) img->d_w / img->d_h;
-
+
if (screen_aspect > img_aspect) {
img_w = img_aspect * IMG->d_h;
img_h = IMG->d_w / img_aspect;
y_pos = (IMG->d_h - img_h) / 2;
}
-
+
switch_img_scale(img, &scale_img, img_w, img_h);
switch_img_patch(IMG, scale_img, x_pos, y_pos);
switch_img_free(&scale_img);
new_w = src->d_w;
new_h = src->d_h;
-
+
if (src->d_w < width && src->d_h < height) {
float rw = (float)new_w / width;
float rh = (float)new_h / height;
new_h = height;
}
} else {
- while(new_w > width || new_h > height) {
+ while(new_w > width || new_h > height) {
if (new_w > width) {
double m = (double) width / new_w;
new_w = width;
if (destP) {
*destP = dest;
}
-
+
return SWITCH_STATUS_SUCCESS;
#else
return SWITCH_STATUS_FALSE;
*xP = (sw - iw);
*yP = (sh - ih) / 2;
break;
- case POS_RIGHT_BOT:
+ case POS_RIGHT_BOT:
*xP = (sw - iw);
*yP = (sh - ih);
break;
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
{
EventConsumer *E = (EventConsumer *) event->bind_user_data;
switch_event_t *dup;
-
+
switch_event_dup(&dup, event);
if (switch_queue_trypush(E->events, dup) != SWITCH_STATUS_SUCCESS) {
SWITCH_DECLARE_CONSTRUCTOR EventConsumer::EventConsumer(const char *event_name, const char *subclass_name, int len)
{
- switch_core_new_memory_pool(&pool);
+ switch_core_new_memory_pool(&pool);
switch_queue_create(&events, len, pool);
node_index = 0;
ready = 1;
-
+
if (!zstr(event_name)) {
bind(event_name, subclass_name);
}
if (zstr(subclass_name)) {
subclass_name = NULL;
}
-
- if (node_index <= SWITCH_EVENT_ALL &&
+
+ if (node_index <= SWITCH_EVENT_ALL &&
switch_event_bind_removable(__FILE__, event_id, subclass_name, event_handler, this, &enodes[node_index]) == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "bound to %s %s\n", event_name, switch_str_nil(subclass_name));
node_index++;
if (!ready) {
return NULL;
}
-
+
if (block) {
if (timeout > 0) {
switch_queue_pop_timeout(events, &pop, (switch_interval_time_t) timeout * 1000); // millisec rather than microsec
if (!ready) {
return;
- }
+ }
ready = 0;
name = "no name";
}
- switch_ivr_menu_init(&menu, main ? main->menu : NULL, name, greeting_sound, short_greeting_sound, invalid_sound,
+ switch_ivr_menu_init(&menu, main ? main->menu : NULL, name, greeting_sound, short_greeting_sound, invalid_sound,
exit_sound, transfer_sound, confirm_macro, confirm_key, tts_engine, tts_voice, confirm_attempts, inter_timeout,
digit_len, timeout, max_failures, max_timeouts, pool);
-
+
}
-
+
SWITCH_DECLARE_CONSTRUCTOR IVRMenu::~IVRMenu()
{
if (menu) {
switch_ivr_action_t ivr_action = SWITCH_IVR_ACTION_NOOP;
this_check_void();
-
+
if (switch_ivr_menu_str2action(action, &ivr_action) == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "bind %s to %s(%s)\n", bind, action, arg);
switch_ivr_menu_bind_action(menu, ivr_action, arg, bind);
if (switch_event_create_json(&event, subclass_name) != SWITCH_STATUS_SUCCESS) {
return;
}
-
+
event_id = event->event_id;
} else {
switch_safe_free(serialized_string);
-
+
if (!event) {
return "";
}
return serialized_string;
}
}
-
+
return "";
}
} else {
switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "Trying to addBody an event that does not exist!\n");
}
-
+
return false;
}
SWITCH_DECLARE(char *)Event::getBody(void)
{
-
+
this_check((char *)"");
if (event) {
} else {
switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "Trying to getBody an event that does not exist!\n");
}
-
+
return NULL;
}
} else {
switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "Trying to getType an event that does not exist!\n");
}
-
+
return (char *) "invalid";
}
SWITCH_DECLARE_CONSTRUCTOR DTMF::~DTMF()
{
-
+
}
allocated = 1;
} else {
cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
- if (switch_ivr_originate(a_leg ? a_leg->session : NULL, &session, &cause, nuuid, 60, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL)
+ if (switch_ivr_originate(a_leg ? a_leg->session : NULL, &session, &cause, nuuid, 60, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL)
== SWITCH_STATUS_SUCCESS) {
channel = switch_core_session_get_channel(session);
allocated = 1;
SWITCH_DECLARE(char *) CoreSession::getXMLCDR()
{
-
+
switch_xml_t cdr = NULL;
this_check((char *)"");
{
this_check_void();
sanity_check_noreturn;
-
+
if (channel && e->event) {
switch_channel_event_set_data(channel, e->event);
}
SWITCH_DECLARE(void) CoreSession::hangupState(void)
{
- sanity_check_noreturn;
+ sanity_check_noreturn;
this->begin_allow_threads();
if (switch_channel_down(channel)) {
switch_core_session_hangup_state(session, SWITCH_FALSE);
SWITCH_DECLARE(void) CoreSession::hangup(const char *cause)
{
this_check_void();
- sanity_check_noreturn;
+ sanity_check_noreturn;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "CoreSession::hangup\n");
this->begin_allow_threads();
switch_channel_hangup(channel, switch_channel_str2cause(cause));
if (zstr(app)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No application specified\n");
return;
- }
+ }
begin_allow_threads();
switch_core_session_execute_application(session, app, data);
cb_state.funcargs = funcargs;
cb_state.function = cbfunc;
- args.buf = &cb_state;
+ args.buf = &cb_state;
args.buflen = sizeof(cb_state); // not sure what this is used for, copy mod_spidermonkey
switch_channel_set_private(channel, "CoreSession", this);
-
+
// we cannot set the actual callback to a python function, because
// the callback is a function pointer with a specific signature.
// so, set it to the following c function which will act as a proxy,
// finding the python callback in the args callback args structure
- args.input_callback = dtmf_callback;
+ args.input_callback = dtmf_callback;
ap = &args;
switch_ivr_collect_digits_callback(session, ap, digit_timeout, abs_timeout);
end_allow_threads();
return SWITCH_STATUS_SUCCESS;
-}
+}
SWITCH_DECLARE(char *) CoreSession::getDigits(int maxdigits, char *terminators, int timeout)
{
return getDigits(maxdigits, terminators, timeout, interdigit, 0);
}
-SWITCH_DECLARE(char *) CoreSession::getDigits(int maxdigits,
- char *terminators,
+SWITCH_DECLARE(char *) CoreSession::getDigits(int maxdigits,
+ char *terminators,
int timeout,
int interdigit,
int abstimeout)
char terminator;
memset(dtmf_buf, 0, sizeof(dtmf_buf));
- switch_ivr_collect_digits_count(session,
+ switch_ivr_collect_digits_count(session,
dtmf_buf,
sizeof(dtmf_buf),
- maxdigits,
- terminators,
- &terminator,
+ maxdigits,
+ terminators,
+ &terminator,
(uint32_t) timeout, (uint32_t)interdigit, (uint32_t)abstimeout);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "getDigits dtmf_buf: %s\n", dtmf_buf);
}
begin_allow_threads();
- switch_ivr_read(session, min_digits, max_digits, prompt_audio_file, NULL, dtmf_buf,
+ switch_ivr_read(session, min_digits, max_digits, prompt_audio_file, NULL, dtmf_buf,
sizeof(dtmf_buf), timeout, valid_terminators, (uint32_t)digit_timeout);
end_allow_threads();
return dtmf_buf;
}
-SWITCH_DECLARE(char *) CoreSession::playAndGetDigits(int min_digits,
- int max_digits,
- int max_tries,
- int timeout,
- char *terminators,
- char *audio_files,
+SWITCH_DECLARE(char *) CoreSession::playAndGetDigits(int min_digits,
+ int max_digits,
+ int max_tries,
+ int timeout,
+ char *terminators,
+ char *audio_files,
char *bad_input_audio_files,
char *digits_regex,
const char *var_name,
this_check((char *)"");
begin_allow_threads();
memset(dtmf_buf, 0, sizeof(dtmf_buf));
- switch_play_and_get_digits( session,
+ switch_play_and_get_digits( session,
(uint32_t) min_digits,
(uint32_t) max_digits,
- (uint32_t) max_tries,
- (uint32_t) timeout,
- terminators,
- audio_files,
+ (uint32_t) max_tries,
+ (uint32_t) timeout,
+ terminators,
+ audio_files,
bad_input_audio_files,
var_name,
- dtmf_buf,
- sizeof(dtmf_buf),
+ dtmf_buf,
+ sizeof(dtmf_buf),
digits_regex,
(uint32_t) digit_timeout,
transfer_on_failure);
return dtmf_buf;
}
-SWITCH_DECLARE(void) CoreSession::say(const char *tosay, const char *module_name, const char *say_type, const char *say_method, const char *say_gender)
+SWITCH_DECLARE(void) CoreSession::say(const char *tosay, const char *module_name, const char *say_type, const char *say_method, const char *say_gender)
{
this_check_void();
sanity_check_noreturn;
end_allow_threads();
}
-SWITCH_DECLARE(void) CoreSession::sayPhrase(const char *phrase_name, const char *phrase_data, const char *phrase_lang)
+SWITCH_DECLARE(void) CoreSession::sayPhrase(const char *phrase_name, const char *phrase_data, const char *phrase_lang)
{
this_check_void();
sanity_check_noreturn;
-
+
if (!(phrase_name)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error! invalid args.\n");
return;
this_check(-1);
sanity_check(-1);
-
+
memset(&local_fh, 0, sizeof(local_fh));
fhp = &local_fh;
local_fh.samples = starting_sample_count;
end_allow_threads();
fhp = NULL;
-
+
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
}
this_check(-1);
sanity_check(-1);
-
+
begin_allow_threads();
status = switch_ivr_sleep(session, ms, (switch_bool_t) sync, ap);
end_allow_threads();
SWITCH_DECLARE(bool) CoreSession::mediaReady() {
this_check(false);
- sanity_check(false);
+ sanity_check(false);
return switch_channel_media_ready(channel) != 0;
}
SWITCH_DECLARE(bool) CoreSession::answered() {
this_check(false);
- sanity_check(false);
+ sanity_check(false);
return switch_channel_test_flag(channel, CF_ANSWERED) != 0;
}
SWITCH_DECLARE(void) CoreSession::destroy(void)
{
this_check_void();
-
+
if (!allocated) {
return;
}
allocated = 0;
switch_safe_free(xml_cdr_text);
- switch_safe_free(uuid);
+ switch_safe_free(uuid);
switch_safe_free(tts_name);
switch_safe_free(voice_name);
}
if (channel) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
"%s destroy/unlink session from object\n", switch_channel_get_name(channel));
switch_channel_set_private(channel, "CoreSession", NULL);
if (switch_channel_up(channel) && switch_test_flag(this, S_HUP) && !switch_channel_test_flag(channel, CF_TRANSFER)) {
}
init_vars();
-
+
}
SWITCH_DECLARE(const char *) CoreSession::hangupCause()
}
// this session has no valid switch_core_session_t at this point, and therefore
- // no valid channel. since the threadstate is stored in the channel, and there
+ // no valid channel. since the threadstate is stored in the channel, and there
// is none, if we try to call begin_alllow_threads it will fail miserably.
// use the 'a leg session' to do the thread swapping stuff.
if (a_leg_session) a_leg_session->begin_allow_threads();
- if (switch_ivr_originate(aleg_core_session,
- &session,
- &cause,
- dest,
+ if (switch_ivr_originate(aleg_core_session,
+ &session,
+ &cause,
+ dest,
timeout,
- handlers,
- NULL,
- NULL,
+ handlers,
+ NULL,
+ NULL,
NULL,
NULL,
SOF_NONE,
return SWITCH_STATUS_FALSE;
}
-SWITCH_DECLARE(int) CoreSession::recordFile(char *file_name, int time_limit, int silence_threshold, int silence_hits)
+SWITCH_DECLARE(int) CoreSession::recordFile(char *file_name, int time_limit, int silence_threshold, int silence_hits)
{
switch_status_t status;
switch_file_handle_t local_fh;
}
-SWITCH_DECLARE(int) CoreSession::flushEvents()
+SWITCH_DECLARE(int) CoreSession::flushEvents()
{
switch_event_t *event;
return SWITCH_STATUS_SUCCESS;
}
-SWITCH_DECLARE(int) CoreSession::flushDigits()
+SWITCH_DECLARE(int) CoreSession::flushDigits()
{
this_check(-1);
sanity_check(-1);
return SWITCH_STATUS_SUCCESS;
}
-SWITCH_DECLARE(int) CoreSession::setAutoHangup(bool val)
+SWITCH_DECLARE(int) CoreSession::setAutoHangup(bool val)
{
this_check(-1);
sanity_check(-1);
if (!session) {
return SWITCH_STATUS_FALSE;
- }
+ }
if (val) {
switch_set_flag(this, S_HUP);
} else {
return SWITCH_STATUS_SUCCESS;
}
-SWITCH_DECLARE(void) CoreSession::waitForAnswer(CoreSession *calling_session)
+SWITCH_DECLARE(void) CoreSession::waitForAnswer(CoreSession *calling_session)
{
this_check_void();
sanity_check_noreturn;
-
+
switch_ivr_wait_for_answer(calling_session ? calling_session->session : NULL, session);
}
this_check_void();
sanity_check_noreturn;
-
+
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "CoreSession::seHangupHook, hangup_func: %p\n", hangup_func);
on_hangup = hangup_func;
switch_channel_t *channel = switch_core_session_get_channel(session);
{
if (zstr(val)) val = NULL;
if (zstr(val2)) val2 = NULL;
-
+
if (val2) {
return switch_core_set_var_conditional(var, val, val2);
} else {
switch_input_args_t args;
switch_channel_t *channel_a = NULL, *channel_b = NULL;
const char *err = "Channels not ready\n";
-
+
if (session_a.allocated && session_a.session && session_b.allocated && session_b.session) {
channel_a = switch_core_session_get_channel(session_a.session);
channel_b = switch_core_session_get_channel(session_b.session);
}
-SWITCH_DECLARE_NONSTD(switch_status_t) hanguphook(switch_core_session_t *session_hungup)
+SWITCH_DECLARE_NONSTD(switch_status_t) hanguphook(switch_core_session_t *session_hungup)
{
if (session_hungup) {
switch_channel_t *channel = switch_core_session_get_channel(session_hungup);
}
-SWITCH_DECLARE_NONSTD(switch_status_t) dtmf_callback(switch_core_session_t *session_cb,
- void *input,
- switch_input_type_t itype,
- void *buf,
+SWITCH_DECLARE_NONSTD(switch_status_t) dtmf_callback(switch_core_session_t *session_cb,
+ void *input,
+ switch_input_type_t itype,
+ void *buf,
unsigned int buflen) {
-
+
switch_channel_t *channel = switch_core_session_get_channel(session_cb);
CoreSession *coresession = NULL;
SWITCH_DECLARE(switch_status_t) CoreSession::process_callback_result(char *result)
{
-
+
this_check(SWITCH_STATUS_FALSE);
sanity_check(SWITCH_STATUS_FALSE);
-
+
return switch_ivr_process_fh(session, result, fhp);
}
#include "switch_curl.h"
#include <curl/curl.h>
-SWITCH_DECLARE(switch_CURL *) switch_curl_easy_init(void)
+SWITCH_DECLARE(switch_CURL *) switch_curl_easy_init(void)
{
return curl_easy_init();
}
if (!strncasecmp(hp->name, "attach_file:", 12)) {
char *pname = strdup(hp->name + 12);
-
+
if (pname) {
char *fname = strchr(pname, ':');
if (fname) {
-/*
+/*
* Cross Platform dso/dll load abstraction
* Copyright(C) 2008 Michael Jerris
*
* code prove defective in any respect, you (not the initial developer or any other contributor)
* assume the cost of any necessary servicing, repair or correction. This disclaimer of warranty
* constitutes an essential part of this license. No use of any covered code is authorized hereunder
- * except under this disclaimer.
+ * except under this disclaimer.
*
*/
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2015, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Dragos Oancea <droancea@yahoo.com>
*
* switch_estimators.c -- Estimators and Detectors (try to read into the future: packet loss, jitter, RTT, etc)
/* This function initializes the Kalman System Model
*
- * xk+1 = A*xk + wk
+ * xk+1 = A*xk + wk
* zk = H*xk + vk
* xk = state variable (must exist in physical world - measurable )
- * zk = measurment
- * wk,vk - white noise
- * A = state trasition matrix , (n x n ) matrix
- * H = state-to-measurment matrix , ( n x n ) matrix
+ * zk = measurment
+ * wk,vk - white noise
+ * A = state trasition matrix , (n x n ) matrix
+ * H = state-to-measurment matrix , ( n x n ) matrix
* Noise covariance:
* Q: Covariance matrix of wk, ( n x n ) diagonal matrix
- * R: Covariance matrix of vk , ( m x m ) diagonal matrix
- * R: if you want to be affected less by the measurement and get the estimate with less variation, increase R
- * Q: if you want to be affected more by the measurement and get the estimate with more variation, decrease Q
+ * R: Covariance matrix of vk , ( m x m ) diagonal matrix
+ * R: if you want to be affected less by the measurement and get the estimate with less variation, increase R
+ * Q: if you want to be affected more by the measurement and get the estimate with more variation, decrease Q
*
* (Phil Kim book)
*
est -> Q = Q; /*accuracy of system model */ /* SYSTEM MODEL: TO BE DEDUCTED */
est -> R = R; /*accuracy of measurement*/ /* SYSTEM MODEL: TO BE DEDUCTED */
est -> K = 0;
- est -> val_estimate = 0 ;
+ est -> val_estimate = 0 ;
est -> val_measured = 0 ; // [0-100 %] or [0-5000] or [0-2sec]
}
CUSUM Kalman functions to detect sudden change over a predefined thereshold.
y(t) = sampled RTT
-x(t)= desired RTT
+x(t)= desired RTT
Model:
x(t+1) = x(t) + delta(t)*v(t)
Noisy characteristic of RTT captured by measurment noise e(t) with variance Re.
The step changes in the desired RTT x(t) is modeled as the process noise v(t)
-with variance Rv and the discrete variable delta(t) .
+with variance Rv and the discrete variable delta(t) .
If a change occurs at time t, then delta(t) = 1 otherwise delta(t) = 0.
avg(x(t)) = avg(x(t-1)) + K(t)(y(t) - avg(x(t-1)))
K(t) = P(t-1)/(P(t-1) + Re))
-P(t) = (1-K(t))P(t-1) + delta(t-1)* Rv
+P(t) = (1-K(t))P(t-1) + delta(t-1)* Rv
e(t) = y(t) - avg(x(t))
g(t) = max(g(t-1) + e(t) - epsilon,0)
-if g(t) > 0 then
+if g(t) > 0 then
delta(t) = 1 // alarm
g(t) = 0
-else
+else
delta(t) = 0
endif
-constants:
+constants:
-epsilon = 0.005
-h = 0.05
+epsilon = 0.005
+h = 0.05
*/
SWITCH_DECLARE(switch_bool_t) switch_kalman_cusum_init(cusum_kalman_detector_t *detect_change, float epsilon,float h)
{
detector_change -> val_estimate_last = 0;
detector_change -> val_desired_last = 0;
- detector_change -> P_last = 0;
+ detector_change -> P_last = 0;
detector_change -> K_last = 0;
- detector_change -> delta = 0;
+ detector_change -> delta = 0;
detector_change -> measurement_noise_e = 0;
detector_change -> variance_Re = 0;
detector_change -> measurement_noise_v = 0;
detector_change -> last_q = 0;
detector_change -> N = 0;
return TRUE;
-}
+}
SWITCH_DECLARE (switch_bool_t) switch_kalman_cusum_detect_change(cusum_kalman_detector_t * detector, float measurement, float rtt_avg)
{
float K=0;
float P=0;
float g=0;
- float desired_val;
+ float desired_val;
float current_average;
float current_q;
float sample_variance_Re = 0;
return TRUE;
}
return FALSE;
-}
+}
/* Kalman filter abstract ( measure and estimate 1 single value per system model )
- * Given the measurment and the system model together with the current state ,
+ * Given the measurment and the system model together with the current state ,
* the function puts an estimate in the estimator struct */
SWITCH_DECLARE(switch_bool_t) switch_kalman_estimate(kalman_estimator_t * est, float measurement, int system_model)
{
if (system_model == EST_LOSS ) {
if ((measurement > 100) && (measurement < 0)) {
return SWITCH_FALSE ;
- }
+ }
}
if (system_model == EST_JITTER) {
float thresh_packet_loss = 5; /* % */
float thresh_rtt = 0.8 ; /*seconds*/
- if ((est_loss->val_estimate_last > thresh_packet_loss) &&
+ if ((est_loss->val_estimate_last > thresh_packet_loss) &&
(est_rtt->val_estimate_last > thresh_rtt )) {
return SWITCH_TRUE;
- }
+ }
return SWITCH_FALSE;
}
static void switch_event_deliver_thread_pool(switch_event_t **event)
{
switch_thread_data_t *td;
-
+
td = malloc(sizeof(*td));
switch_assert(td);
for(x = 0; x < (uint32_t)DISPATCH_THREAD_COUNT; x++) {
switch_queue_trypush(EVENT_DISPATCH_QUEUE, NULL);
}
-
+
switch_queue_interrupt_all(EVENT_DISPATCH_QUEUE);
-
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Stopping dispatch threads\n");
-
+
for(x = 0; x < (uint32_t)DISPATCH_THREAD_COUNT; x++) {
switch_status_t st;
switch_thread_join(&st, EVENT_DISPATCH_QUEUE_THREADS[x]);
{
if (!EVENT_DISPATCH_QUEUE) {
switch_mutex_lock(BLOCK);
-
+
if (!EVENT_DISPATCH_QUEUE) {
switch_queue_create(&EVENT_DISPATCH_QUEUE, DISPATCH_QUEUE_LEN * MAX_DISPATCH, THRUNTIME_POOL);
switch_event_launch_dispatch_threads(1);
-
+
while (!THREAD_COUNT) {
switch_cond_next();
}
}
switch_mutex_unlock(BLOCK);
- }
+ }
}
if (switch_event_serialize_json_obj(event, &cj) == SWITCH_STATUS_SUCCESS) {
*str = cJSON_PrintUnformatted(cj);
cJSON_Delete(cj);
-
+
return SWITCH_STATUS_SUCCESS;
}
const void *var;
void *val;
int x = 0;
-
+
for (hi = switch_core_hash_first(CUSTOM_HASH); hi; hi = switch_core_hash_next(&hi)) {
switch_core_hash_this(hi, &var, NULL, &val);
switch_console_push_match(matches, (const char *) var);
if (!func || thisnp->func == func) {
x++;
-
+
if (last) {
last->next = np;
} else {
}
static switch_status_t switch_event_channel_sub_channel(const char *event_channel, switch_event_channel_func_t func, switch_event_channel_id_t id)
-
+
{
switch_event_channel_sub_node_t *node, *np;
switch_event_channel_sub_node_head_t *head;
-static uint32_t _switch_event_channel_broadcast(const char *event_channel, const char *broadcast_channel,
+static uint32_t _switch_event_channel_broadcast(const char *event_channel, const char *broadcast_channel,
cJSON *json, const char *key, switch_event_channel_id_t id)
{
switch_event_channel_sub_node_t *np;
if (np->id == id) {
continue;
}
-
+
np->func(broadcast_channel, json, key, id);
x++;
}
*ecdP = NULL;
_switch_event_channel_broadcast(ecd->event_channel, ecd->event_channel, ecd->json, ecd->key, ecd->id);
-
+
if ((p = strchr(ecd->event_channel, '.'))) {
char *main_channel = strdup(ecd->event_channel);
p = strchr(main_channel, '.');
switch_mutex_unlock(EVENT_QUEUE_MUTEX);
while(SYSTEM_RUNNING) {
-
+
if (switch_queue_pop(queue, &pop) != SWITCH_STATUS_SUCCESS) {
continue;
}
switch_mutex_unlock(EVENT_QUEUE_MUTEX);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Event Channel Dispatch Thread Ended.\n");
- return NULL;
+ return NULL;
}
SWITCH_DECLARE(switch_status_t) switch_event_channel_broadcast(const char *event_channel, cJSON **json, const char *key, switch_event_channel_id_t id)
if (launch) {
switch_thread_data_t *td;
-
+
if (!EVENT_CHANNEL_DISPATCH_QUEUE) {
switch_queue_create(&EVENT_CHANNEL_DISPATCH_QUEUE, DISPATCH_QUEUE_LEN * MAX_DISPATCH, THRUNTIME_POOL);
}
td = malloc(sizeof(*td));
switch_assert(td);
-
+
td->alloc = 1;
td->func = switch_event_channel_deliver_thread;
td->obj = EVENT_CHANNEL_DISPATCH_QUEUE;
td->pool = NULL;
-
+
switch_thread_pool_launch_thread(&td);
}
} else {
ecd = NULL;
}
-
+
return status;
}
}
SWITCH_DECLARE(switch_status_t) switch_event_channel_bind(const char *event_channel, switch_event_channel_func_t func, switch_event_channel_id_t *id)
-
+
{
switch_status_t status = SWITCH_STATUS_SUCCESS;
cJSON_ReplaceItemInObject(dup, "eventChannel", cJSON_CreateString(np->event_channel));
cJSON_ReplaceItemInObject(data, "name", cJSON_CreateString(np->name));
-
+
switch_event_channel_broadcast(np->event_channel, &dup, __FILE__, la->channel_id);
}
switch_mutex_unlock(la->mutex);
switch_mutex_lock(la->mutex);
if (la->visible != visible || force) {
cJSON *msg, *data;
-
+
msg = cJSON_CreateObject();
data = json_add_child_obj(msg, "data", NULL);
cJSON_AddItemToObject(msg, "eventChannel", cJSON_CreateString(la->event_channel));
cJSON_AddItemToObject(data, "action", cJSON_CreateString(visible ? "hide" : "show"));
cJSON_AddItemToObject(data, "wireSerno", cJSON_CreateNumber(la->serno++));
-
+
la_broadcast(la, &msg);
la->visible = visible;
cJSON_AddItemToObject(data, "name", cJSON_CreateString(la->name));
cJSON_AddItemToObject(data, "wireSerno", cJSON_CreateNumber(-1));
cJSON_AddItemToObject(data, "data", cJSON_CreateObject());
-
+
la_broadcast(la, &msg);
while(np) {
}
la->head = la->tail = NULL;
-
+
switch_mutex_unlock(la->mutex);
return SWITCH_STATUS_SUCCESS;
cJSON_AddItemToObject(data, "name", cJSON_CreateString(la->name));
cJSON_AddItemToObject(data, "wireSerno", cJSON_CreateNumber(-1));
cJSON_AddItemToObject(data, "data", cJSON_CreateObject());
-
+
switch_event_channel_broadcast(la->event_channel, &msg, __FILE__, channel_id);
for (np = la->head; np; np = np->next) {
msg = cJSON_CreateObject();
data = json_add_child_obj(msg, "data", NULL);
-
+
cJSON_AddItemToObject(msg, "eventChannel", cJSON_CreateString(la->event_channel));
cJSON_AddItemToObject(data, "action", cJSON_CreateString("bootObj"));
cJSON_AddItemToObject(data, "name", cJSON_CreateString(la->name));
cJSON_AddItemToArray(row, cJSON_Duplicate(np->obj, 1));
cJSON_AddItemToArray(data, row);
}
-
+
switch_event_channel_broadcast(la->event_channel, &msg, __FILE__, channel_id);
pool = la->pool;
switch_live_array_clear(la);
-
+
switch_core_hash_destroy(&la->hash);
switch_mutex_lock(event_channel_manager.lamutex);
break;
}
}
-
+
if (!exist) {
node = switch_core_alloc(la->pool, sizeof(*node));
node->event_channel = switch_core_strdup(la->pool, event_channel);
return !exist;
}
-SWITCH_DECLARE(switch_status_t) switch_live_array_create(const char *event_channel, const char *name,
+SWITCH_DECLARE(switch_status_t) switch_live_array_create(const char *event_channel, const char *name,
switch_event_channel_id_t channel_id, switch_live_array_t **live_arrayP)
{
switch_live_array_t *la = NULL;
switch_core_new_memory_pool(&pool);
key = switch_core_sprintf(pool, "%s.%s", event_channel, name);
- switch_mutex_lock(event_channel_manager.lamutex);
+ switch_mutex_lock(event_channel_manager.lamutex);
la = switch_core_hash_find(event_channel_manager.lahash, key);
switch_mutex_unlock(event_channel_manager.lamutex);
-
+
if (la) {
la->new = SWITCH_FALSE;
} else {
la->channel_id = channel_id;
switch_core_hash_init(&la->hash);
switch_mutex_init(&la->mutex, SWITCH_MUTEX_NESTED, la->pool);
-
+
switch_mutex_lock(event_channel_manager.lamutex);
switch_core_hash_insert(event_channel_manager.lahash, la->key, la);
switch_mutex_unlock(event_channel_manager.lamutex);
switch_mutex_unlock(la->mutex);
*live_arrayP = la;
-
+
return SWITCH_STATUS_SUCCESS;
}
switch_mutex_lock(la->mutex);
if ((node = switch_core_hash_find(la->hash, name))) {
- dup = cJSON_Duplicate(node->obj, 1);
+ dup = cJSON_Duplicate(node->obj, 1);
}
switch_mutex_unlock(la->mutex);
switch_mutex_lock(la->mutex);
for (node = la->head; node; node = node->next) {
if (node->pos == idx) {
- dup = cJSON_Duplicate(node->obj, 1);
+ dup = cJSON_Duplicate(node->obj, 1);
break;
}
}
switch_mutex_unlock(la->mutex);
-
+
return dup;
}
switch_mutex_lock(la->mutex);
if ((node = switch_core_hash_find(la->hash, name))) {
np = la->head;
-
+
while(np) {
cur = np;
np = np->next;
if (index > -1 && index < la->pos && la->head) {
la_node_t *np, *last = NULL;
int i = 0;
-
+
for(np = la->head; np; np = np->next) {
-
+
if (i == index) {
if (last) {
node->next = last->next;
last = np;
i++;
}
-
+
} else {
msg = cJSON_CreateObject();
data = json_add_child_obj(msg, "data", NULL);
-
+
cJSON_AddItemToObject(msg, "eventChannel", cJSON_CreateString(la->event_channel));
cJSON_AddItemToObject(data, "action", cJSON_CreateString(action));
cJSON_AddItemToObject(data, "data", cJSON_Duplicate(node->obj, 1));
la_broadcast(la, &msg);
-
+
switch_mutex_unlock(la->mutex);
return status;
const char *context = NULL, *name = NULL;
switch_live_array_t *la = NULL;
cJSON *jla = NULL;
-
+
if ((jla = cJSON_GetObjectItem(json, "data")) && (jla = cJSON_GetObjectItem(jla, "liveArray"))) {
if ((context = cJSON_GetObjectCstr(jla, "context")) && (name = cJSON_GetObjectCstr(jla, "name"))) {
if (command) {
if (switch_live_array_create(context, name, channel_id, &la) == SWITCH_STATUS_SUCCESS) {
-
+
if (!strcasecmp(command, "bootstrap")) {
switch_live_array_bootstrap(la, sessid, channel_id);
} else {
/*
* Copyright (c) 2002, Christopher Clark
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
- *
+ *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
if (minsize > (1u << 30)) {*hp = NULL; return SWITCH_STATUS_FALSE;}
/* Enforce size as prime */
for (pindex=0; pindex < prime_table_length; pindex++) {
- if (primes[pindex] > minsize) {
- size = primes[pindex];
- break;
+ if (primes[pindex] > minsize) {
+ size = primes[pindex];
+ break;
}
}
h = (switch_hashtable_t *) malloc(sizeof(switch_hashtable_t));
h->table = newtable;
}
/* Plan B: realloc instead */
- else
+ else
{
newtable = (struct entry **)
realloc(h->table, newsize * sizeof(struct entry *));
freekey(e->k);
}
if (e->flags & HASHTABLE_FLAG_FREE_VALUE) {
- switch_safe_free(e->v);
+ switch_safe_free(e->v);
v = NULL;
} else if (e->destructor) {
e->destructor(e->v);
for (i = 0; i < (*h)->tablelength; i++) {
e = table[i];
while (NULL != e) {
- f = e; e = e->next;
+ f = e; e = e->next;
if (f->flags & HASHTABLE_FLAG_FREE_KEY) {
- freekey(f->k);
+ freekey(f->k);
}
-
+
if (f->flags & HASHTABLE_FLAG_FREE_VALUE) {
- switch_safe_free(f->v);
+ switch_safe_free(f->v);
} else if (f->destructor) {
f->destructor(f->v);
f->v = NULL;
}
- switch_safe_free(f);
+ switch_safe_free(f);
}
}
{
switch_hashtable_iterator_t *i = *iP;
-
+
if (i->e) {
- if ((i->e = i->e->next) != 0) {
+ if ((i->e = i->e->next) != 0) {
return i;
} else {
i->pos++;
while(i->pos < i->h->tablelength && !i->h->table[i->pos]) {
i->pos++;
}
-
+
if (i->pos >= i->h->tablelength) {
goto end;
}
-
- if ((i->e = i->h->table[i->pos]) != 0) {
+
+ if ((i->e = i->h->table[i->pos]) != 0) {
return i;
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Paul D. Tinsley <pdt at jackhammer.org>
* Neal Horman <neal at wanlink dot com>
switch_core_session_get_read_impl(session, &imp);
/*
- if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_INBOUND && !switch_channel_test_flag(channel, CF_PROXY_MODE) &&
+ if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_INBOUND && !switch_channel_test_flag(channel, CF_PROXY_MODE) &&
!switch_channel_media_ready(channel) && !switch_channel_test_flag(channel, CF_SERVICE)) {
if ((status = switch_channel_pre_answer(channel)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot establish media.\n");
*/
if (!switch_channel_media_ready(channel)) {
-
+
for (elapsed=0; switch_channel_ready(channel) && elapsed<(ms/20); elapsed++) {
if (switch_channel_test_flag(channel, CF_BREAK)) {
switch_channel_clear_flag(channel, CF_BREAK);
switch_goto_status(SWITCH_STATUS_BREAK, end);
}
-
+
switch_yield(20 * 1000);
}
switch_goto_status(SWITCH_STATUS_SUCCESS, end);
switch_dtmf_t dtmf = {0};
/*
- dtmf handler function you can hook up to be executed when a digit is dialed during 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.
*/
if (switch_channel_has_dtmf(channel)) {
if ((status = switch_ivr_dmachine_feed(args->dmachine, ds, NULL)) != SWITCH_STATUS_SUCCESS) {
break;
}
- }
+ }
if (args->input_callback) {
status = args->input_callback(session, (void *) &dtmf, SWITCH_INPUT_TYPE_DTMF, args->buf, args->buflen);
switch_clear_flag_locked(conninfo, SUF_READY);
switch_socket_shutdown(conninfo->socket, SWITCH_SHUTDOWN_READWRITE);
switch_thread_join(&st, conninfo->thread);
-
+
while (switch_test_flag(conninfo, SUF_THREAD_RUNNING)) {
switch_yield(10000);
if (++sanity >= 10000) {
switch_status_t status = SWITCH_STATUS_FALSE;
int el = 0, elp = 0, reneg_sec = 0;
const char *var = NULL;
-
+
if (zstr(cmd)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Invalid Command!\n");
return SWITCH_STATUS_FALSE;
if (!switch_channel_test_flag(channel, CF_BRIDGED) || switch_channel_test_flag(channel, CF_BROADCAST)) {
inner++;
hold_bleg = NULL;
- }
+ }
if (!switch_channel_test_flag(channel, CF_BROADCAST)) {
switch_channel_set_flag(channel, CF_BROADCAST);
if ((b_session = switch_core_session_locate(b_uuid))) {
switch_channel_t *b_channel = switch_core_session_get_channel(b_session);
switch_status_t st;
-
+
switch_ivr_broadcast(b_uuid, stream, SMF_ECHO_ALEG | SMF_LOOP);
st = switch_channel_wait_for_flag(b_channel, CF_BROADCAST, SWITCH_TRUE, 5000, NULL);
- if (st != SWITCH_STATUS_SUCCESS &&
+ if (st != SWITCH_STATUS_SUCCESS &&
switch_channel_ready(channel) && switch_channel_ready(b_channel) && !switch_channel_test_flag(b_channel, CF_BROADCAST)) {
switch_core_session_kill_channel(b_session, SWITCH_SIG_BREAK);
st = switch_channel_wait_for_flag(b_channel, CF_BROADCAST, SWITCH_TRUE, 5000, NULL);
-
- if (st != SWITCH_STATUS_SUCCESS &&
+
+ if (st != SWITCH_STATUS_SUCCESS &&
switch_channel_ready(channel) && switch_channel_ready(b_channel) && !switch_channel_test_flag(b_channel, CF_BROADCAST)) {
switch_core_session_flush_private_events(b_session);
}
if (switch_channel_test_flag(channel, CF_STOP_BROADCAST)) {
switch_channel_clear_flag(channel, CF_BROADCAST);
- switch_channel_set_flag(channel, CF_BREAK);
+ switch_channel_set_flag(channel, CF_BREAK);
}
-
+
switch_channel_audio_sync(channel);
if ((var = switch_channel_get_variable(channel, "media_reneg_after_broadcast"))) {
reneg_sec = -1;
}
}
-
+
if (reneg_sec) {
switch_stream_handle_t stream = { 0 };
char *api, *api_arg;
-
+
SWITCH_STANDARD_STREAM(stream);
if (reneg_sec > 0) {
api = "sched_api";
if ((extension = switch_caller_extension_new(session, "xferext", "xferext")) == 0) {
abort();
}
-
+
for (hp = event->headers; hp; hp = hp->next) {
char *app;
char *data;
-
+
if (!strcasecmp(hp->name, "application")) {
app = strdup(hp->value);
if (app) {
}
switch_channel_transfer_to_extension(channel, extension);
-
+
} else if (cmd_hash == CMD_HANGUP) {
char *cause_name = switch_event_get_header(event, "hangup-cause");
switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
{
switch_status_t status = SWITCH_STATUS_SUCCESS;
switch_channel_t *channel = switch_core_session_get_channel(session);
-
+
switch(message->message_id) {
case SWITCH_MESSAGE_INDICATE_ANSWER:
if (switch_channel_answer(channel) != SWITCH_STATUS_SUCCESS) {
while (switch_core_session_dequeue_signal_data(session, &data) == SWITCH_STATUS_SUCCESS) {
i++;
-
- msg.pointer_arg = data;
+
+ msg.pointer_arg = data;
switch_core_session_receive_message(session, &msg);
data = NULL;
if ((cause_str = strchr(to, ':'))) {
timeout_cause = switch_channel_str2cause(cause_str + 1);
}
-
+
if ((timeout = atoi(to)) < 0) {
timeout = 0;
} else {
switch_generate_sln_silence((int16_t *) write_frame.data, write_frame.samples, read_impl.number_of_channels, sval);
switch_core_session_write_frame(session, &write_frame, SWITCH_IO_FLAG_NONE, 0);
}
-
+
if (expires && switch_epoch_time_now(NULL) >= expires) {
switch_channel_hangup(channel, timeout_cause);
break;
if (switch_channel_has_dtmf(channel)) {
switch_dtmf_t dtmf = { 0 };
-
+
if (args && !args->input_callback && !args->buf && !args->dmachine) {
status = SWITCH_STATUS_BREAK;
break;
}
-
+
switch_channel_dequeue_dtmf(channel, &dtmf);
if (args) {
if ((status = switch_ivr_dmachine_feed(args->dmachine, ds, NULL)) != SWITCH_STATUS_SUCCESS) {
break;
}
- }
+ }
if (args->input_callback) {
if ((status = args->input_callback(session, (void *) &dtmf, SWITCH_INPUT_TYPE_DTMF, args->buf, args->buflen)) != SWITCH_STATUS_SUCCESS) {
switch_event_fire(&event);
}
}
-
+
if (args && args->dmachine) {
if ((status = switch_ivr_dmachine_ping(args->dmachine, NULL)) != SWITCH_STATUS_SUCCESS) {
break;
}
}
-
+
}
if ((status = switch_ivr_dmachine_feed(args->dmachine, ds, NULL)) != SWITCH_STATUS_SUCCESS) {
break;
}
- }
+ }
if (args->input_callback) {
status = args->input_callback(session, (void *) &dtmf, SWITCH_INPUT_TYPE_DTMF, args->buf, args->buflen);
if ((session = switch_core_session_locate(uuid))) {
channel = switch_core_session_get_channel(session);
-
+
if (switch_channel_test_flag(channel, CF_MEDIA_TRANS) || !switch_channel_test_flag(channel, CF_PROXY_MODE)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Operation is invalid\n");
switch_core_session_rwunlock(session);
/* If we had early media in bypass mode before, it is no longer relevant */
if (switch_channel_test_flag(channel, CF_EARLY_MEDIA)) {
switch_core_session_message_t msg2 = { 0 };
-
+
msg2.message_id = SWITCH_MESSAGE_INDICATE_CLEAR_PROGRESS;
msg2.from = __FILE__;
switch_core_session_receive_message(session, &msg2);
}
-
+
if ((flags & SMF_REPLYONLY_A)) {
msg.numeric_arg = 1;
}
-
+
switch_channel_set_flag(channel, CF_3P_MEDIA_REQUESTED);
if (switch_core_session_receive_message(session, &msg) != SWITCH_STATUS_SUCCESS) {
other_channel = switch_core_session_get_channel(other_session);
switch_assert(other_channel != NULL);
-
+
switch_channel_set_flag(other_channel, CF_3P_MEDIA_REQUESTED);
switch_channel_set_variable(other_channel, "rtp_secure_media", "optional");
-
+
switch_core_session_receive_message(other_session, &msg);
switch_channel_wait_for_flag(other_channel, CF_REQ_MEDIA, SWITCH_FALSE, 10000, NULL);
switch_channel_wait_for_flag(other_channel, CF_MEDIA_ACK, SWITCH_TRUE, 10000, NULL);
if (other_channel) {
switch_channel_clear_state_handler(channel, NULL);
}
-
+
switch_channel_clear_flag(channel, CF_MEDIA_TRANS);
switch_core_session_rwunlock(session);
if ((session = switch_core_session_locate(uuid))) {
channel = switch_core_session_get_channel(session);
-
+
if (switch_channel_test_flag(channel, CF_MEDIA_TRANS)) {
switch_core_session_rwunlock(session);
return SWITCH_STATUS_INUSE;
/* If we had early media in bypass mode before, it is no longer relevant */
if (switch_channel_test_flag(channel, CF_EARLY_MEDIA)) {
switch_core_session_message_t msg2 = { 0 };
-
+
msg2.message_id = SWITCH_MESSAGE_INDICATE_CLEAR_PROGRESS;
msg2.from = __FILE__;
switch_core_session_receive_message(session, &msg2);
}
-
+
if ((flags & SMF_REPLYONLY_A)) {
msg.numeric_arg = 1;
}
-
+
if (switch_core_session_receive_message(session, &msg) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Can't re-establsh media on %s\n", switch_channel_get_name(channel));
switch_core_session_rwunlock(session);
if ((session = switch_core_session_locate(uuid))) {
status = SWITCH_STATUS_SUCCESS;
channel = switch_core_session_get_channel(session);
-
+
if (switch_channel_test_flag(channel, CF_MEDIA_TRANS) || (!(flags & SMF_FORCE) && switch_channel_test_flag(channel, CF_PROXY_MODE))) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Operation is invalid\n");
switch_core_session_rwunlock(session);
if ((flags & SMF_REBRIDGE) && (other_uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE)) &&
(other_session = switch_core_session_locate(other_uuid))) {
other_channel = switch_core_session_get_channel(other_session);
-
+
switch_channel_set_flag(channel, CF_REDIRECT);
switch_channel_set_flag(channel, CF_RESET);
-
+
switch_channel_set_flag(other_channel, CF_RESET);
switch_channel_set_flag(other_channel, CF_REDIRECT);
}
switch_channel_set_state(other_channel, CS_PARK);
-
+
if (switch_core_session_in_thread(session)) {
switch_yield(100000);
} else {
switch_channel_wait_for_state(other_channel, channel, CS_PARK);
}
-
-
+
+
if (!switch_core_session_in_thread(session)) {
switch_channel_wait_for_state(channel, NULL, CS_PARK);
}
switch_core_session_rwunlock(session);
}
-
+
return status;
}
if (switch_channel_test_flag(channel, CF_SECURE)) {
switch_core_session_rwunlock(session);
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR,
"Cannot bypass %s due to secure connection.\n", switch_channel_get_name(channel));
return SWITCH_STATUS_FALSE;
}
td->obj = job;
td->pool = pool;
switch_thread_pool_launch_thread(&td);
-
+
}
switch_channel_set_variable(channel, SWITCH_TEMP_HOLD_MUSIC_VARIABLE, NULL);
switch_channel_execute_on(channel, "execute_on_blind_transfer");
-
+
if ((profile = switch_channel_get_caller_profile(channel))) {
const char *var;
/* Set CF_TRANSFER flag before hanging up bleg to avoid race condition */
switch_channel_set_flag(channel, CF_TRANSFER);
- /* If HANGUP_AFTER_BRIDGE is set to 'true', SWITCH_SIGNAL_BRIDGE_VARIABLE
+ /* If HANGUP_AFTER_BRIDGE is set to 'true', SWITCH_SIGNAL_BRIDGE_VARIABLE
* will not have a value, so we need to check SWITCH_BRIDGE_VARIABLE */
uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BRIDGE_VARIABLE);
extension, use_context);
- new_profile->transfer_source = switch_core_sprintf(new_profile->pool, "%ld:%s:bl_xfer:%s/%s/%s",
+ new_profile->transfer_source = switch_core_sprintf(new_profile->pool, "%ld:%s:bl_xfer:%s/%s/%s",
(long) switch_epoch_time_now(NULL), new_profile->uuid_str,
extension, use_context, use_dialplan);
switch_channel_add_variable_var_check(channel, SWITCH_TRANSFER_HISTORY_VARIABLE, new_profile->transfer_source, SWITCH_FALSE, SWITCH_STACK_PUSH);
add_stat(x_in, stats->inbound.flaws, "flaw_total");
add_stat_double(x_in, stats->inbound.R, "quality_percentage");
add_stat_double(x_in, stats->inbound.mos, "mos");
-
+
if (stats->inbound.error_log) {
switch_xml_t x_err_log, x_err;
if (!(x_err_log = switch_xml_add_child_d(x_stat, "error-log", off++))) {
abort();
}
-
+
for(ep = stats->inbound.error_log; ep; ep = ep->next) {
if (!(ep->start && ep->stop)) continue;
add_stat(x_out, stats->outbound.cng_packet_count, "cng_packet_count");
add_stat(x_out, stats->rtcp.packet_count, "rtcp_packet_count");
add_stat(x_out, stats->rtcp.octet_count, "rtcp_octet_count");
-
+
return off;
}
switch_xml_t variable;
if (!val) val = "";
-
+
if (!zstr(var) && ((variable = switch_xml_add_child_d(xml, var, off++)))) {
if ((data = malloc(dlen))) {
memset(data, 0, dlen);
free(data);
} else abort();
}
-
+
return off;
-
+
}
for (; hi; hi = hi->next) {
if (hi->idx) {
int i;
-
+
for (i = 0; i < hi->idx; i++) {
off = switch_ivr_set_xml_chan_var(xml, hi->name, hi->array[i], off);
}
}
switch_snprintf(tmp, sizeof(tmp), "%" SWITCH_TIME_T_FMT, caller_profile->times->last_hold);
switch_xml_set_txt_d(time_tag, tmp);
-
+
if (!(time_tag = switch_xml_add_child_d(x_times, "hold_accum_time", t_off++))) {
goto error;
}
#define add_jstat(_j, _i, _s) \
switch_snprintf(var_val, sizeof(var_val), "%" SWITCH_SIZE_T_FMT, _i); \
- cJSON_AddItemToObject(_j, _s, cJSON_CreateNumber(_i))
+ cJSON_AddItemToObject(_j, _s, cJSON_CreateNumber(_i))
SWITCH_DECLARE(void) switch_ivr_set_json_call_stats(cJSON *json, switch_core_session_t *session, switch_media_type_t type)
{
add_jstat(j_in, stats->inbound.flaws, "flaw_total");
add_jstat(j_in, stats->inbound.R, "quality_percentage");
add_jstat(j_in, stats->inbound.mos, "mos");
-
+
if (stats->inbound.error_log) {
cJSON *j_err_log, *j_err;
switch_snprintf(tmp, sizeof(tmp), "%d", switch_channel_get_state(channel));
cJSON_AddItemToObject(j_channel_data, "state_number", cJSON_CreateString((char *) tmp));
-
+
if ((f = switch_channel_get_flag_string(channel))) {
cJSON_AddItemToObject(j_channel_data, "flags", cJSON_CreateString((char *) f));
free(f);
*json_cdr = cdr;
return SWITCH_STATUS_SUCCESS;
-
+
}
packet.header.seq = htons(++seq);
packet.header.version = 2;
}
-
+
if (switch_jb_get_packet(jb, (switch_rtp_packet_t *) &packet, &plen) == SWITCH_STATUS_SUCCESS) {
write_frame.data = packet.body;
write_frame.datalen = (uint32_t) plen - 12;
char *p;
p = switch_core_session_strdup(session, module_name);
module_name = p;
-
+
if ((p = strchr(module_name, ':'))) {
*p++ = '\0';
chan_lang = p;
if ((si = switch_loadable_module_get_say_interface(module_name))) {
/* should go back and proto all the say mods to const.... */
switch_say_args_t say_args = {0};
-
+
say_args.type = switch_ivr_get_say_type_by_name(say_type);
say_args.method = switch_ivr_get_say_method_by_name(say_method);
say_args.gender = switch_ivr_get_say_gender_by_name(say_gender);
-
+
status = si->say_function(session, (char *) tosay, &say_args, args);
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Invalid SAY Interface [%s]!\n", module_name);
}
if (channel) {
- const char *p = switch_channel_get_variable(channel, "sound_prefix_enforced");
+ const char *p = switch_channel_get_variable(channel, "sound_prefix_enforced");
if (!switch_true(p)) {
save_path = switch_channel_get_variable(channel, "sound_prefix");
if (sound_path) {
if ((si = switch_loadable_module_get_say_interface(module_name)) && si->say_string_function) {
/* should go back and proto all the say mods to const.... */
switch_say_args_t say_args = {0};
-
+
say_args.type = switch_ivr_get_say_type_by_name(say_type);
say_args.method = switch_ivr_get_say_method_by_name(say_method);
say_args.gender = switch_ivr_get_say_gender_by_name(say_gender);
return buffer;
}
-SWITCH_DECLARE(switch_status_t) switch_ivr_set_user_xml(switch_core_session_t *session, const char *prefix,
+SWITCH_DECLARE(switch_status_t) switch_ivr_set_user_xml(switch_core_session_t *session, const char *prefix,
const char *user, const char *domain, switch_xml_t x_user)
{
switch_xml_t x_params, x_param;
}
status = switch_ivr_set_user_xml(session, prefix, user, domain, x_user);
-
+
goto done;
error:
SWITCH_DECLARE(switch_status_t) switch_ivr_process_fh(switch_core_session_t *session, const char *cmd, switch_file_handle_t *fhp)
{
if (zstr(cmd)) {
- return SWITCH_STATUS_SUCCESS;
+ return SWITCH_STATUS_SUCCESS;
}
if (fhp) {
if (!strncasecmp(cmd, "speed", 5)) {
char *p;
-
+
if ((p = strchr(cmd, ':'))) {
p++;
if (*p == '+' || *p == '-') {
} else if (!strncasecmp(cmd, "volume", 6)) {
char *p;
-
+
if ((p = strchr(cmd, ':'))) {
p++;
if (*p == '+' || *p == '-') {
}
return SWITCH_STATUS_SUCCESS;
}
-
+
if (fhp->vol) {
switch_normalize_volume(fhp->vol);
}
-
+
return SWITCH_STATUS_FALSE;
} else if (!strcasecmp(cmd, "pause")) {
if (switch_test_flag(fhp, SWITCH_FILE_PAUSE)) {
unsigned int pos = 0;
char *p;
//codec = switch_core_session_get_read_codec(session);
-
+
if ((p = strchr(cmd, ':'))) {
p++;
if (*p == '+' || *p == '-') {
}
return SWITCH_STATUS_FALSE;
-
+
}
#define START_SAMPLES 32768
} else {
ext = "wav";
}
-
- tmp_file = switch_core_session_sprintf(session, "%s%smsg_%s.%s",
- SWITCH_GLOBAL_dirs.temp_dir, SWITCH_PATH_SEPARATOR, uuid_str, ext);
-
+
+ tmp_file = switch_core_session_sprintf(session, "%s%smsg_%s.%s",
+ SWITCH_GLOBAL_dirs.temp_dir, SWITCH_PATH_SEPARATOR, uuid_str, ext);
+
switch_core_session_get_read_impl(session, &read_impl);
-
+
new_fh.channels = read_impl.number_of_channels;
new_fh.native_rate = read_impl.actual_samples_per_second;
for (x_domain = switch_xml_child(x_domains, "domain"); x_domain; x_domain = x_domain->next) {
const char *dname = switch_xml_attr(x_domain, "name");
if (!dname || (strcasecmp(dname, "*") && strcasecmp(domain_name, dname))) continue;
-
+
for (x_exten = switch_xml_child(x_domain, "exten"); x_exten; x_exten = x_exten->next) {
const char *regex = switch_xml_attr(x_exten, "regex");
const char *proto = switch_xml_attr(x_exten, "proto");
-
+
if (!zstr(regex) && !zstr(proto)) {
proceed = switch_regex_perform(exten_name, regex, &re, ovector, sizeof(ovector) / sizeof(ovector[0]));
switch_regex_safe_free(re);
-
+
if (proceed) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Mapping %s@%s to proto %s matching expression [%s]\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Mapping %s@%s to proto %s matching expression [%s]\n",
exten_name, domain_name, proto, regex);
r = strdup(proto);
goto end;
}
-
+
}
}
}
}
return r;
-
+
}
SWITCH_DECLARE(switch_status_t) switch_ivr_kill_uuid(const char *uuid, switch_call_cause_t cause)
switch_channel_clear_flag(channel, CF_CONFIRM_BLIND_TRANSFER);
if (!zstr(uuid) && (other_session = switch_core_session_locate(uuid))) {
- switch_core_session_message_t msg = { 0 };
+ switch_core_session_message_t msg = { 0 };
msg.message_id = SWITCH_MESSAGE_INDICATE_BLIND_TRANSFER_RESPONSE;
msg.from = __FILE__;
msg.numeric_arg = success;
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2015, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Michael Jerris <mike@jerris.com>
* Bret McDanel <bret AT 0xdecafbad dot com>
return (const char *) dmachine->name;
}
-SWITCH_DECLARE(switch_status_t) switch_ivr_dmachine_create(switch_ivr_dmachine_t **dmachine_p,
+SWITCH_DECLARE(switch_status_t) switch_ivr_dmachine_create(switch_ivr_dmachine_t **dmachine_p,
const char *name,
switch_memory_pool_t *pool,
- uint32_t digit_timeout_ms,
+ uint32_t digit_timeout_ms,
uint32_t input_timeout_ms,
switch_ivr_dmachine_callback_t match_callback,
switch_ivr_dmachine_callback_t nonmatch_callback,
dmachine->match.dmachine = dmachine;
dmachine->name = switch_core_strdup(dmachine->pool, name);
switch_mutex_init(&dmachine->mutex, SWITCH_MUTEX_NESTED, dmachine->pool);
-
+
switch_core_hash_init(&dmachine->binding_hash);
-
+
if (match_callback) {
dmachine->match_callback = match_callback;
}
}
dmachine->user_data = user_data;
-
+
*dmachine_p = dmachine;
-
+
return SWITCH_STATUS_SUCCESS;
}
switch_memory_pool_t *pool;
if (!(dmachine && *dmachine)) return;
-
+
pool = (*dmachine)->pool;
switch_core_hash_destroy(&(*dmachine)->binding_hash);
-
+
if ((*dmachine)->my_pool) {
switch_core_destroy_memory_pool(&pool);
}
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Digit parser %s: Error Setting realm to '%s'\n", dmachine->name, realm);
-
+
return SWITCH_STATUS_FALSE;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Digit parser %s: Clearing realm '%s'\n", dmachine->name, realm);
if (headp == dmachine->realm) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
"Digit parser %s: '%s' was the active realm, no realm currently selected.\n", dmachine->name, realm);
dmachine->realm = NULL;
}
return SWITCH_STATUS_SUCCESS;
}
-SWITCH_DECLARE(switch_status_t) switch_ivr_dmachine_bind(switch_ivr_dmachine_t *dmachine,
+SWITCH_DECLARE(switch_status_t) switch_ivr_dmachine_bind(switch_ivr_dmachine_t *dmachine,
const char *realm,
const char *digits,
- switch_byte_t is_priority,
+ switch_byte_t is_priority,
int32_t key,
switch_ivr_dmachine_callback_t callback,
void *user_data)
msg = "Reuse Existing ";
binding = ptr;
binding->callback = callback;
- binding->user_data = user_data;
+ binding->user_data = user_data;
goto done;
}
}
-
-
+
+
binding = switch_core_alloc(dmachine->pool, sizeof(*binding));
if (*digits == '~') {
switch_ivr_dmachine_set_realm(dmachine, realm);
}
- if (binding->is_regex && dmachine->max_digit_len != DMACHINE_MAX_DIGIT_LEN -1) {
+ if (binding->is_regex && dmachine->max_digit_len != DMACHINE_MAX_DIGIT_LEN -1) {
dmachine->max_digit_len = DMACHINE_MAX_DIGIT_LEN -1;
} else if (len > dmachine->max_digit_len) {
dmachine->max_digit_len = (uint32_t) len;
}
-
+
done:
if (binding->is_regex) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%sDigit parser %s: binding %s/%s/%d callback: %p data: %p\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%sDigit parser %s: binding %s/%s/%d callback: %p data: %p\n",
msg, dmachine->name, digits, realm, key, (void *)(intptr_t) callback, user_data);
} else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%sDigit parser %s: binding %s/%s/%d callback: %p data: %p\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%sDigit parser %s: binding %s/%s/%d callback: %p data: %p\n",
msg, dmachine->name, digits, realm, key, (void *)(intptr_t) callback, user_data);
}
dm_match_t best = DM_MATCH_NONE;
switch_ivr_dmachine_binding_t *bp, *exact_bp = NULL, *partial_bp = NULL, *both_bp = NULL, *r_bp = NULL;
int pmatches = 0, ematches = 0, rmatches = 0;
-
+
if (!dmachine->cur_digit_len || !dmachine->realm) goto end;
for(bp = dmachine->realm->binding_list; bp; bp = bp->next) {
if (bp->is_regex) {
switch_status_t r_status = switch_regex_match(dmachine->digits, bp->digits);
-
+
bp->rmatch = r_status == SWITCH_STATUS_SUCCESS;
rmatches++;
for(bp = dmachine->realm->binding_list; bp; bp = bp->next) {
if (bp->is_regex) {
if (bp->rmatch) {
- if ((bp->is_priority && ! ematches) || is_timeout || (bp == dmachine->realm->binding_list && !bp->next)) {
+ if ((bp->is_priority && ! ematches) || is_timeout || (bp == dmachine->realm->binding_list && !bp->next)) {
best = DM_MATCH_EXACT;
exact_bp = bp;
break;
} else {
int pmatch = !strncmp(dmachine->digits, bp->digits, strlen(dmachine->digits));
- if (!exact_bp && pmatch && (!rmatches || bp->is_priority || is_timeout) && !strcmp(bp->digits, dmachine->digits)) {
+ if (!exact_bp && pmatch && (!rmatches || bp->is_priority || is_timeout) && !strcmp(bp->digits, dmachine->digits)) {
best = DM_MATCH_EXACT;
exact_bp = bp;
- if (bp->is_priority || dmachine->cur_digit_len == dmachine->max_digit_len) break;
- }
+ if (bp->is_priority || dmachine->cur_digit_len == dmachine->max_digit_len) break;
+ }
if (!(both_bp && partial_bp) && strlen(bp->digits) != strlen(dmachine->digits) && pmatch) {
-
+
if (exact_bp) {
best = DM_MATCH_BOTH;
both_bp = bp;
best = DM_MATCH_NEVER;
}
-
+
end:
if (is_timeout) {
if (both_bp) {
r_bp = exact_bp ? exact_bp : both_bp;
}
- }
+ }
if (best == DM_MATCH_EXACT && exact_bp) {
r_bp = exact_bp;
}
-
-
+
+
if (r_bp) {
dmachine->last_matching_binding = r_bp;
switch_set_string(dmachine->last_matching_digits, dmachine->digits);
}
return best;
-
+
}
static switch_bool_t switch_ivr_dmachine_check_timeout(switch_ivr_dmachine_t *dmachine)
if (is_match == DM_MATCH_NEVER) {
is_timeout++;
}
-
+
if (switch_mutex_trylock(dmachine->mutex) != SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_SUCCESS;
}
r = SWITCH_STATUS_FALSE;
} else if (is_match == DM_MATCH_EXACT || (is_match == DM_MATCH_BOTH && is_timeout)) {
r = SWITCH_STATUS_FOUND;
-
+
dmachine->match.match_digits = dmachine->last_matching_digits;
dmachine->match.match_key = dmachine->last_matching_binding->key;
dmachine->match.user_data = dmachine->last_matching_binding->user_data;
-
+
if (match_p) {
*match_p = &dmachine->match;
}
dmachine->is_match = 1;
dmachine->match.type = DM_MATCH_POSITIVE;
-
+
if (dmachine->last_matching_binding->callback) {
s = dmachine->last_matching_binding->callback(&dmachine->match);
-
+
switch(s) {
case SWITCH_STATUS_CONTINUE:
r = SWITCH_STATUS_SUCCESS;
} else {
r = SWITCH_STATUS_SUCCESS;
}
-
+
if (r != SWITCH_STATUS_FOUND && r != SWITCH_STATUS_SUCCESS && r != SWITCH_STATUS_BREAK) {
switch_set_string(dmachine->last_failed_digits, dmachine->digits);
dmachine->match.match_digits = dmachine->last_failed_digits;
-
+
dmachine->match.type = DM_MATCH_NEGATIVE;
-
+
if (dmachine->nonmatch_callback) {
dmachine->match.user_data = dmachine->user_data;
s = dmachine->nonmatch_callback(&dmachine->match);
}
}
-
+
clear++;
}
-
+
if (clear) {
switch_ivr_dmachine_clear(dmachine);
}
{
const char *p;
switch_status_t status = SWITCH_STATUS_BREAK;
-
+
if (!zstr(digits)) {
status = SWITCH_STATUS_SUCCESS;
}
if (dmachine->cur_digit_len < dmachine->max_digit_len) {
switch_status_t istatus;
char *e = dmachine->digits + strlen(dmachine->digits);
-
+
*e++ = *p;
*e = '\0';
dmachine->cur_digit_len++;
status = SWITCH_STATUS_FALSE;
}
}
-
+
return status;
}
if (!SWITCH_READ_ACCEPTABLE(status)) {
break;
}
-
+
switch_ivr_parse_all_events(session);
if (args && (args->input_callback || args->buf || args->buflen)) {
switch_dtmf_t dtmf = {0};
/*
- dtmf handler function you can hook up to be executed when a digit is dialed during 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.
*/
if (switch_channel_has_dtmf(channel)) {
switch_normalize_to_16bit(mixed);
fp[x] = (int16_t) mixed;
}
-
+
} else {
st = switch_core_file_read(&dh->fh, rframe->data, &len);
rframe->samples = (uint32_t) len;
switch_mutex_unlock(rh->buffer_mutex);
break;
}
-
+
samples = switch_buffer_read(rh->thread_buffer, data, bsize) / 2 / channels;
switch_mutex_unlock(rh->buffer_mutex);
switch_memory_pool_t *pool = switch_core_session_get_pool(session);
int sanity = 200;
-
+
switch_core_session_get_read_impl(session, &rh->read_impl);
switch_mutex_init(&rh->buffer_mutex, SWITCH_MUTEX_NESTED, pool);
switch_threadattr_create(&thd_attr, pool);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
switch_thread_create(&rh->thread, thd_attr, recording_thread, bug, pool);
-
+
while(--sanity > 0 && !rh->thread_ready) {
switch_yield(10000);
}
nframe = switch_core_media_bug_get_native_read_frame(bug);
len = nframe->datalen;
-
+
if (!rh->wready) {
unsigned char fill_data[SWITCH_RECOMMENDED_BUFFER_SIZE] = {0};
switch_size_t fill_len = len;
switch_core_gen_encoded_silence(fill_data, &rh->read_impl, len);
switch_core_file_write(&rh->out_fh, fill_data, &fill_len);
}
-
-
+
+
if (rh->last_read_time && rh->last_read_time < now) {
diff = (now - rh->last_read_time) / rh->read_impl.microseconds_per_packet;
-
+
if (diff > 3) {
unsigned char fill_data[SWITCH_RECOMMENDED_BUFFER_SIZE] = {0};
switch_core_gen_encoded_silence(fill_data, &rh->read_impl, len);
-
+
while(diff > 1) {
switch_size_t fill_len = len;
switch_core_file_write(&rh->in_fh, fill_data, &fill_len);
switch_time_t now = switch_time_now();
switch_time_t diff;
rh->wready = 1;
-
+
nframe = switch_core_media_bug_get_native_write_frame(bug);
len = nframe->datalen;
}
-
+
if (rh->last_write_time && rh->last_write_time < now) {
diff = (now - rh->last_write_time) / rh->read_impl.microseconds_per_packet;
-
+
if (diff > 3) {
unsigned char fill_data[SWITCH_RECOMMENDED_BUFFER_SIZE] = {0};
switch_core_gen_encoded_silence(fill_data, &rh->read_impl, len);
-
+
while(diff > 1) {
switch_size_t fill_len = len;
switch_core_file_write(&rh->out_fh, fill_data, &fill_len);
}
}
}
-
+
switch_core_file_write(&rh->out_fh, mask ? null_data : nframe->data, &len);
rh->last_write_time = now;
rh->writes++;
}
}
-
+
//if (switch_core_file_has_video(rh->fh, SWITCH_TRUE)) {
//switch_core_media_set_video_file(session, NULL, SWITCH_RW_READ);
//switch_channel_clear_flag_recursive(session->channel, CF_VIDEO_DECODED_READ);
}
}
}
-
+
send_record_stop_event(channel, &read_impl, rh);
-
+
switch_channel_execute_on(channel, SWITCH_RECORD_POST_PROCESS_EXEC_APP_VARIABLE);
if ((var = switch_channel_get_variable(channel, SWITCH_RECORD_POST_PROCESS_EXEC_API_VARIABLE))) {
char *cmd = switch_core_session_strdup(session, var);
char *data, *expanded = NULL;
switch_stream_handle_t stream = { 0 };
-
+
SWITCH_STANDARD_STREAM(stream);
if ((data = strchr(cmd, ':'))) {
break;
} else {
len = (switch_size_t) frame.datalen / 2 / frame.channels;
-
+
if (rh->thread_buffer) {
switch_mutex_lock(rh->buffer_mutex);
switch_buffer_write(rh->thread_buffer, mask ? null_data : data, frame.datalen);
}
return SWITCH_FALSE;
}
-
+
rh->writes++;
-
+
/* check for silence timeout */
if (rh->silence_threshold) {
switch_codec_implementation_t read_impl = { 0 };
case SWITCH_ABC_TYPE_STREAM_VIDEO_PING:
if (rh->fh) {
if (!bug->video_ping_frame) break;
-
- if ((len || bug->video_ping_frame->img) && switch_core_file_write_video(rh->fh, bug->video_ping_frame) != SWITCH_STATUS_SUCCESS &&
+
+ if ((len || bug->video_ping_frame->img) && switch_core_file_write_video(rh->fh, bug->video_ping_frame) != SWITCH_STATUS_SUCCESS &&
rh->hangup_on_error) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error writing video to %s\n", rh->file);
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
case SWITCH_ABC_TYPE_READ_TEXT:
{
const char *text = switch_core_media_bug_get_text(bug);
-
+
if (!zstr(text)) {
switch_event_t *event = NULL;
if (switch_event_create(&event, SWITCH_EVENT_TEXT) == SWITCH_STATUS_SUCCESS) {
switch_event_add_body(event, text, SWITCH_VA_NONE);
-
+
if (switch_true(switch_core_get_variable("fire_text_events"))) {
switch_event_t *clone = NULL;
switch_event_dup(&clone, event);
switch_event_fire(&clone);
}
-
+
switch_core_session_queue_event(session, &event);
}
}
return SWITCH_STATUS_FALSE;
}
-static void* switch_ivr_record_user_data_dup(switch_core_session_t *session, void *user_data)
+static void* switch_ivr_record_user_data_dup(switch_core_session_t *session, void *user_data)
{
struct record_helper *rh = (struct record_helper *) user_data, *dup = NULL;
switch_channel_set_variable(new_channel, SWITCH_RECORD_POST_PROCESS_EXEC_API_VARIABLE, var);
}
switch_channel_transfer_variable_prefix(orig_channel, new_channel, SWITCH_RECORD_POST_PROCESS_EXEC_APP_VARIABLE);
-
+
return switch_core_media_bug_transfer_callback(orig_session, new_session, record_callback, switch_ivr_record_user_data_dup);
}
if (switch_core_media_bug_test_flag(bug, SMBF_SPY_VIDEO_STREAM)) {
switch_core_media_bug_push_spy_frame(bug, frame, SWITCH_RW_READ);
}
-
+
if (switch_core_media_bug_test_flag(bug, SMBF_SPY_VIDEO_STREAM_BLEG)) {
switch_core_media_bug_push_spy_frame(bug, frame, SWITCH_RW_WRITE);
}
switch (type) {
case SWITCH_ABC_TYPE_INIT:
- if (switch_core_media_bug_test_flag(bug, SMBF_READ_VIDEO_STREAM) ||
- switch_core_media_bug_test_flag(bug, SMBF_WRITE_VIDEO_STREAM) ||
+ if (switch_core_media_bug_test_flag(bug, SMBF_READ_VIDEO_STREAM) ||
+ switch_core_media_bug_test_flag(bug, SMBF_WRITE_VIDEO_STREAM) ||
switch_core_media_bug_test_flag(bug, SMBF_READ_VIDEO_PING)) {
switch_core_session_set_video_read_callback(ep->eavesdropper, video_eavesdrop_callback, (void *)bug);
switch_channel_set_flag_recursive(switch_core_session_get_channel(session), CF_VIDEO_DECODED_READ);
switch_channel_clear_flag_recursive(e_channel, CF_VIDEO_DECODED_READ);
}
- if (switch_core_media_bug_test_flag(bug, SMBF_READ_VIDEO_STREAM) ||
- switch_core_media_bug_test_flag(bug, SMBF_WRITE_VIDEO_STREAM) ||
+ if (switch_core_media_bug_test_flag(bug, SMBF_READ_VIDEO_STREAM) ||
+ switch_core_media_bug_test_flag(bug, SMBF_WRITE_VIDEO_STREAM) ||
switch_core_media_bug_test_flag(bug, SMBF_READ_VIDEO_PING)) {
switch_core_session_set_video_read_callback(ep->eavesdropper, NULL, NULL);
}
if (switch_buffer_inuse(ep->r_buffer) >= rframe->datalen) {
uint32_t bytes;
int channels = rframe->channels ? rframe->channels : 1;
-
+
switch_buffer_lock(ep->r_buffer);
bytes = (uint32_t) switch_buffer_read(ep->r_buffer, ep->data, rframe->datalen);
-
+
rframe->datalen = switch_merge_sln(rframe->data, rframe->samples, (int16_t *) ep->data, bytes / 2, channels) * 2 * channels;
rframe->samples = rframe->datalen / 2;
if (!bug->video_ping_frame || !bug->video_ping_frame->img) {
break;
}
-
+
if (ep->eavesdropper && switch_core_session_read_lock(ep->eavesdropper) == SWITCH_STATUS_SUCCESS) {
if (switch_core_session_write_video_frame(ep->eavesdropper, bug->video_ping_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error writing video to %s\n", switch_core_session_get_name(ep->eavesdropper));
switch_channel_t *a = switch_core_session_get_channel(ep->eavesdropper);
switch_channel_t *b = switch_core_session_get_channel(data->caller);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s telling %s to exec %s:%s\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s telling %s to exec %s:%s\n",
switch_channel_get_name(b), switch_channel_get_name(a), data->var, data->val);
switch_core_session_execute_application(ep->eavesdropper, data->var, data->val);
msg.message_id = SWITCH_MESSAGE_INDICATE_DISPLAY;
msg.string_array_arg[0] = data->var;
msg.string_array_arg[1] = data->val;
-
- switch_core_session_receive_message(ep->eavesdropper, &msg);
+
+ switch_core_session_receive_message(ep->eavesdropper, &msg);
}
}
write_frame.data = buf;
write_frame.buflen = sizeof(buf);
write_frame.rate = codec.implementation->actual_samples_per_second;
-
+
/* Make sure that at least one leg is bridged, default to both */
if (! (flags & (ED_BRIDGE_READ | ED_BRIDGE_WRITE))) {
flags |= ED_BRIDGE_READ | ED_BRIDGE_WRITE;
write_flags = SMBF_WRITE_STREAM | SMBF_WRITE_REPLACE;
}
- if (switch_channel_test_flag(session->channel, CF_VIDEO) && switch_channel_test_flag(tsession->channel, CF_VIDEO)) {
- if ((vval = switch_channel_get_variable(session->channel, "eavesdrop_show_listener_video"))) {
+ if (switch_channel_test_flag(session->channel, CF_VIDEO) && switch_channel_test_flag(tsession->channel, CF_VIDEO)) {
+ if ((vval = switch_channel_get_variable(session->channel, "eavesdrop_show_listener_video"))) {
if (switch_true(vval) || !strcasecmp(vval, "aleg") || !strcasecmp(vval, "bleg") || !strcasecmp(vval, "both")) {
read_flags |= SMBF_SPY_VIDEO_STREAM;
}
read_flags |= SMBF_SPY_VIDEO_STREAM_BLEG;
}
}
-
- if ((vval = switch_channel_get_variable(session->channel, "eavesdrop_concat_video")) && switch_true(vval)) {
+
+ if ((vval = switch_channel_get_variable(session->channel, "eavesdrop_concat_video")) && switch_true(vval)) {
read_flags |= SMBF_READ_VIDEO_STREAM;
read_flags |= SMBF_WRITE_VIDEO_STREAM;
} else {
read_flags &= ~SMBF_SPY_VIDEO_STREAM_BLEG;
}
-
+
if (switch_core_media_bug_add(tsession, "eavesdrop", uuid,
eavesdrop_callback, ep, 0,
read_flags | write_flags | SMBF_READ_PING | SMBF_THREAD_LOCK | SMBF_NO_PAUSE,
goto end;
}
- if ((vval = switch_channel_get_variable(session->channel, "eavesdrop_video_spy_fmt"))) {
+ if ((vval = switch_channel_get_variable(session->channel, "eavesdrop_video_spy_fmt"))) {
switch_media_bug_set_spy_fmt(bug, switch_media_bug_parse_spy_fmt(vval));
}
fcommand = db;
}
- if (switch_core_media_bug_test_flag(bug, SMBF_READ_VIDEO_STREAM) ||
+ if (switch_core_media_bug_test_flag(bug, SMBF_READ_VIDEO_STREAM) ||
switch_core_media_bug_test_flag(bug, SMBF_WRITE_VIDEO_STREAM)) {
vid_dual = 1;
}
if (vid_dual || switch_core_media_bug_test_flag(bug, SMBF_READ_VIDEO_PING)) {
vid_bug = 1;
}
-
+
if (fcommand) {
char *d;
for (d = fcommand; *d; d++) {
switch_core_session_get_read_impl(tsession, &tread_impl);
switch_core_session_get_read_impl(session, &read_impl);
-
- if (tread_impl.number_of_channels != ep->tread_impl.number_of_channels ||
+
+ if (tread_impl.number_of_channels != ep->tread_impl.number_of_channels ||
tread_impl.actual_samples_per_second != ep->tread_impl.actual_samples_per_second) {
tchanged = 1;
}
read_impl.actual_samples_per_second != ep->read_impl.actual_samples_per_second) {
changed = 1;
}
-
+
if (changed || tchanged) {
if (changed) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
- "SPYING CHANNEL CODEC CHANGE FROM %dhz@%dc to %dhz@%dc\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
+ "SPYING CHANNEL CODEC CHANGE FROM %dhz@%dc to %dhz@%dc\n",
ep->read_impl.actual_samples_per_second,
ep->read_impl.number_of_channels,
read_impl.actual_samples_per_second,
}
if (tchanged) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
- "SPYED CHANNEL CODEC CHANGE FROM %dhz@%dc to %dhz@%dc\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
+ "SPYED CHANNEL CODEC CHANGE FROM %dhz@%dc to %dhz@%dc\n",
ep->tread_impl.actual_samples_per_second,
ep->tread_impl.number_of_channels,
tread_impl.actual_samples_per_second,
tread_impl.number_of_channels);
tlen = tread_impl.decoded_bytes_per_packet;
-
+
if (len > tlen) {
len = tlen;
}
-
+
switch_core_codec_destroy(&codec);
-
+
if (switch_core_codec_init(&codec,
"L16",
NULL,
goto end;
}
}
-
+
ep->read_impl = read_impl;
ep->tread_impl = tread_impl;
}
-
+
if (ep->tread_impl.number_of_channels != ep->read_impl.number_of_channels) {
uint32_t rlen = write_frame.datalen / 2 / ep->tread_impl.number_of_channels;
-
+
switch_mux_channels((int16_t *) write_frame.data, rlen, ep->tread_impl.number_of_channels, ep->read_impl.number_of_channels);
write_frame.datalen = rlen * 2 * ep->read_impl.number_of_channels;
write_frame.samples = write_frame.datalen / 2;
}
-
+
if ((status = switch_core_session_write_frame(session, &write_frame, SWITCH_IO_FLAG_NONE, 0)) != SWITCH_STATUS_SUCCESS) {
break;
}
char *file_path = NULL;
char *ext;
char *in_file = NULL, *out_file = NULL;
-
+
if ((p = switch_channel_get_variable(channel, "RECORD_HANGUP_ON_ERROR"))) {
hangup_on_error = switch_true(p);
}
if (switch_true(switch_channel_get_variable(channel, "RECORD_TOGGLE_ON_REPEAT"))) {
return switch_ivr_stop_record_session(session, file);
}
-
+
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Already recording [%s]\n", file);
return SWITCH_STATUS_SUCCESS;
}
-
+
if ((p = switch_channel_get_variable(channel, "RECORD_CHECK_BRIDGE")) && switch_true(p)) {
switch_core_session_t *other_session;
int exist = 0;
switch_status_t rstatus = SWITCH_STATUS_SUCCESS;
-
+
if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) {
switch_channel_t *other_channel = switch_core_session_get_channel(other_session);
if ((bug = switch_channel_get_private(other_channel, file))) {
}
switch_core_session_rwunlock(other_session);
}
-
+
if (exist) {
return rstatus;
}
if ((vval = switch_channel_get_variable(channel, "enable_file_write_buffering"))) {
int tmp = atoi(vval);
-
+
if (tmp > 0) {
fh->pre_buffer_datalen = tmp;
} else if (switch_true(vval)) {
fh->pre_buffer_datalen = SWITCH_DEFAULT_FILE_BUFFER_LEN;
}
-
+
if (!switch_is_file_path(file)) {
char *tfile = NULL;
char *e;
if (file_path && !strstr(file_path, SWITCH_URL_SEPARATOR)) {
char *p;
char *path = switch_core_session_strdup(session, file_path);
-
+
if ((p = strrchr(path, *SWITCH_PATH_SEPARATOR))) {
*p = '\0';
path = NULL;
}
}
-
+
rh = switch_core_session_alloc(session, sizeof(*rh));
if ((ext = strrchr(file, '.'))) {
if (switch_core_file_has_video(fh, SWITCH_TRUE)) {
//switch_core_media_set_video_file(session, fh, SWITCH_RW_READ);
//switch_channel_set_flag_recursive(session->channel, CF_VIDEO_DECODED_READ);
-
- if ((vval = switch_channel_get_variable(channel, "record_concat_video")) && switch_true(vval)) {
+
+ if ((vval = switch_channel_get_variable(channel, "record_concat_video")) && switch_true(vval)) {
flags |= SMBF_READ_VIDEO_STREAM;
flags |= SMBF_WRITE_VIDEO_STREAM;
} else {
if ((p = switch_channel_get_variable(channel, "RECORD_PRE_BUFFER_FRAMES"))) {
int tmp = atoi(p);
-
+
if (tmp > 0) {
switch_core_media_bug_set_pre_buffer_framecount(bug, tmp);
}
if (pvt) {
switch_mutex_lock(pvt->mutex);
-
+
if (pvt->ready) {
switch_dtmf_t *dt = NULL;
switch_zmalloc(dt, sizeof(*dt));
switch_event_fire(&event);
}
}
-
+
dt = NULL;
- /*
+ /*
SWITCH_STATUS_FALSE indicates pretend there never was a DTMF
since we will be generating it inband now.
*/
{
switch_size_t bytes;
void *pop;
-
+
if (pvt->skip) {
pvt->skip--;
return SWITCH_TRUE;
}
-
+
switch_mutex_lock(pvt->mutex);
if (!switch_buffer_inuse(pvt->audio_buffer)) {
if (switch_queue_trypop(pvt->digit_queue, &pop) == SWITCH_STATUS_SUCCESS) {
switch_dtmf_t *dtmf = (switch_dtmf_t *) pop;
-
+
if (dtmf->source != SWITCH_DTMF_INBAND_AUDIO) {
char buf[2] = "";
SWITCH_LOG_WARNING, "%s Truncating DTMF duration %d ms to %d ms\n",
switch_channel_get_name(switch_core_session_get_channel(pvt->session)), dtmf->duration / 8, duration);
}
-
+
pvt->ts.duration = duration;
teletone_run(&pvt->ts, buf);
} switch_tone_container_t;
-static void tone_detect_set_total_time(switch_tone_container_t *cont, int index)
+static void tone_detect_set_total_time(switch_tone_container_t *cont, int index)
{
char *total_time = switch_mprintf("%d", (int)(switch_micro_time_now() - cont->list[index].start_time) / 1000);
- switch_channel_set_variable_name_printf(switch_core_session_get_channel(cont->session), total_time, "tone_detect_%s_total_time",
+ switch_channel_set_variable_name_printf(switch_core_session_get_channel(cont->session), total_time, "tone_detect_%s_total_time",
cont->list[index].key);
switch_safe_free(total_time);
}
switch_core_session_execute_application_async(cont->session, cont->list[i].app, cont->list[i].data);
}
}
-
+
return SWITCH_STATUS_SUCCESS;
}
case SWITCH_ABC_TYPE_READ_REPLACE:
case SWITCH_ABC_TYPE_WRITE_REPLACE:
{
-
+
if (type == SWITCH_ABC_TYPE_READ_REPLACE) {
frame = switch_core_media_bug_get_read_replace_frame(bug);
} else {
int ok = 0;
*digit = dtmf->digit;
dval = switch_dtmftoi(digit);
-
+
if (direction == SWITCH_DTMF_RECV && (md->sr[direction].map[dval].bind_flags & SBF_DIAL_ALEG)) {
ok = 1;
} else if (direction == SWITCH_DTMF_SEND && (md->sr[direction].map[dval].bind_flags & SBF_DIAL_BLEG)) {
{
switch_channel_t *channel = switch_core_session_get_channel(session);
uint8_t enabled = (uint8_t)(intptr_t)switch_channel_get_private(channel, SWITCH_BLOCK_DTMF_KEY);
-
+
if (enabled) {
switch_channel_set_private(channel, SWITCH_BLOCK_DTMF_KEY, NULL);
}
md->sr[SWITCH_DTMF_RECV].map[key].app = switch_core_session_strdup(session, app);
md->sr[SWITCH_DTMF_RECV].map[key].flags |= SMF_HOLD_BLEG;
md->sr[SWITCH_DTMF_RECV].map[key].bind_flags = bind_flags;
-
+
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Bound A-Leg: %c%c %s\n", meta, switch_itodtmf((char)key), app);
}
if ((bind_flags & SBF_DIAL_BLEG)) {
return SWITCH_STATUS_SUCCESS;
}
-SWITCH_DECLARE(switch_status_t) switch_ivr_play_and_detect_speech(switch_core_session_t *session,
- const char *file,
- const char *mod_name,
- const char *grammar,
- char **result,
+SWITCH_DECLARE(switch_status_t) switch_ivr_play_and_detect_speech(switch_core_session_t *session,
+ const char *file,
+ const char *mod_name,
+ const char *grammar,
+ char **result,
uint32_t input_timeout,
switch_input_args_t *args)
{
if (status == SWITCH_STATUS_SUCCESS && switch_true(switch_channel_get_variable(channel, "asr_intercept_dtmf"))) {
const char *p;
-
+
if ((p = switch_stristr("<input>", xmlstr))) {
p += 7;
}
case SWITCH_ABC_TYPE_INIT:
{
switch_threadattr_t *thd_attr = NULL;
-
+
switch_threadattr_create(&thd_attr, sth->pool);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
switch_thread_create(&sth->thread, thd_attr, speech_thread, sth, sth->pool);
switch_mutex_unlock(sth->mutex);
}
}
-
+
switch_thread_join(&st, sth->thread);
}
return SWITCH_STATUS_FALSE;
}
-SWITCH_DECLARE(switch_status_t) switch_ivr_set_param_detect_speech(switch_core_session_t *session, const char *name, const char *val)
+SWITCH_DECLARE(switch_status_t) switch_ivr_set_param_detect_speech(switch_core_session_t *session, const char *name, const char *val)
{
struct speech_thread_handle *sth = switch_channel_get_private(switch_core_session_get_channel(session), SWITCH_SPEECH_KEY);
switch_status_t status = SWITCH_STATUS_FALSE;
overly_helper_t *oht = (overly_helper_t *) user_data;
switch_core_session_t *session = switch_core_media_bug_get_session(bug);
switch_channel_t *channel = switch_core_session_get_channel(session);
-
+
switch (type) {
case SWITCH_ABC_TYPE_INIT:
- {
+ {
}
break;
case SWITCH_ABC_TYPE_CLOSE:
return SWITCH_STATUS_FALSE;
}
-SWITCH_DECLARE(switch_status_t) switch_ivr_video_write_overlay_session(switch_core_session_t *session, const char *img_path,
+SWITCH_DECLARE(switch_status_t) switch_ivr_video_write_overlay_session(switch_core_session_t *session, const char *img_path,
switch_img_position_t pos, uint8_t alpha)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
}
switch_channel_set_private(channel, "_video_write_overlay_bug_", bug);
-
+
return SWITCH_STATUS_SUCCESS;
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
- * switch_ivr_bridge.c -- IVR Library
+ * switch_ivr_bridge.c -- IVR Library
*
*/
if (read_frame->data && read_frame->datalen && !switch_test_flag(read_frame, SFF_CNG)) {
switch_buffer_write(text_buffer, read_frame->data, read_frame->datalen);
}
-
+
inuse = switch_buffer_inuse(text_buffer);
if (inuse && (switch_channel_test_flag(channel, CF_TEXT_IDLE) || switch_test_flag(read_frame, SFF_TEXT_LINE_BREAK))) {
int bytes = 0;
-
+
if (inuse + 4 > text_framesize) {
void *tmp = malloc(inuse + 1024);
memcpy(tmp, text_framedata, text_framesize);
switch_assert(tmp);
-
+
text_framesize = inuse + 1024;
-
+
free(text_framedata);
text_framedata = tmp;
}
text_framedata[x] = '\0';
bytes = strlen((char *)text_framedata);
break;
- }
+ }
}
}
if (!bytes) continue;
- *(text_framedata + bytes) = '\r';
- *(text_framedata + bytes + 1) = '\n';
- *(text_framedata + bytes + 2) = '\0';
+ *(text_framedata + bytes) = '\r';
+ *(text_framedata + bytes + 1) = '\n';
+ *(text_framedata + bytes + 2) = '\0';
bytes += 2;
-
+
frame.data = text_framedata;
frame.datalen = strlen((char *)frame.data);
read_frame = &frame;
}
}
-
+
if (!switch_test_flag(read_frame, SFF_CNG)) {
switch_status_t tstatus = switch_core_session_write_text_frame(vh->session_b, read_frame, 0, 0);
}
}
} else {
- if (a_codec->implementation->impl_id != b_codec->implementation->impl_id ||
+ if (a_codec->implementation->impl_id != b_codec->implementation->impl_id ||
switch_channel_test_flag(b_channel, CF_VIDEO_DECODED_READ)) {
switch_channel_set_flag_recursive(channel, CF_VIDEO_DECODED_READ);
set_decoded_read = 1;
}
status = switch_core_session_read_video_frame(vh->session_a, &read_frame, SWITCH_IO_FLAG_NONE, 0);
-
+
if (!SWITCH_READ_ACCEPTABLE(status)) {
switch_cond_next();
continue;
}
}
-
- if (switch_test_flag(read_frame, SFF_CNG) ||
+
+ if (switch_test_flag(read_frame, SFF_CNG) ||
switch_channel_test_flag(channel, CF_LEG_HOLDING) || switch_channel_test_flag(b_channel, CF_VIDEO_READ_FILE_ATTACHED)) {
continue;
}
-
+
if (switch_channel_media_up(b_channel)) {
if (switch_core_session_write_video_frame(vh->session_b, read_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) {
switch_cond_next();
if (!zstr(peer_caller_profile->caller_id_number)) {
number = peer_caller_profile->caller_id_number;
} else {
- number = caller_profile->caller_id_number;
+ number = caller_profile->caller_id_number;
}
if (zstr(number)) {
}
}
-
+
if (zstr(name)) {
name = number;
}
}
inner_bridge = switch_channel_test_flag(chan_a, CF_INNER_BRIDGE);
-
+
if (!switch_channel_test_flag(chan_a, CF_ANSWERED) && (bridge_answer_timeout = switch_channel_get_variable(chan_a, "bridge_answer_timeout"))) {
if ((answer_timeout = atoi(bridge_answer_timeout)) < 0) {
answer_timeout = 0;
if (switch_channel_test_flag(chan_a, CF_HAS_TEXT) && switch_channel_test_flag(chan_b, CF_HAS_TEXT) && !txt_launch) {
txt_launch++;
-
+
th.session_a = session_a;
th.session_b = session_b;
switch_core_media_start_engine_function(th.session_a, SWITCH_MEDIA_TYPE_TEXT, text_bridge_thread, &th);
if (!played_banner && switch_channel_test_flag(chan_a, CF_VIDEO) && switch_channel_test_flag(chan_b, CF_VIDEO) &&
switch_channel_test_flag(chan_a, CF_ANSWERED) && switch_channel_test_flag(chan_b, CF_ANSWERED) &&
++banner_counter > 100 &&
- switch_channel_test_flag(chan_a, CF_VIDEO_READY) && switch_channel_test_flag(chan_b, CF_VIDEO_READY) &&
+ switch_channel_test_flag(chan_a, CF_VIDEO_READY) && switch_channel_test_flag(chan_b, CF_VIDEO_READY) &&
switch_channel_test_flag(chan_a, CF_BRIDGE_ORIGINATOR) && banner_file) {
const char *b_banner_file = switch_channel_get_variable(chan_b, "video_pre_call_banner");
b_banner_file = switch_channel_get_variable(chan_a, "video_pre_call_banner_bleg");
}
-
+
switch_channel_clear_flag(chan_a, CF_VIDEO_PAUSE_READ);
switch_channel_clear_flag(chan_b, CF_VIDEO_PAUSE_READ);
}
played_banner = 1;
-
+
switch_channel_clear_flag(chan_a, CF_AUDIO_PAUSE_READ);
switch_channel_clear_flag(chan_b, CF_AUDIO_PAUSE_READ);
switch_channel_clear_flag(chan_a, CF_AUDIO_PAUSE_WRITE);
switch_channel_clear_flag(chan_b, CF_AUDIO_PAUSE_WRITE);
}
-
+
if (!exec_check) {
}
exec_check = 1;
}
-
+
if (exec_app) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session_a), SWITCH_LOG_DEBUG, "%s Bridge execute app %s(%s)\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session_a), SWITCH_LOG_DEBUG, "%s Bridge execute app %s(%s)\n",
switch_channel_get_name(chan_a), exec_app, exec_data);
switch_core_session_execute_application_async(session_a, exec_app, exec_data);
exec_app = exec_data = NULL;
}
-
+
if ((bypass_media_after_bridge || switch_channel_test_flag(chan_b, CF_BYPASS_MEDIA_AFTER_BRIDGE)) && switch_channel_test_flag(chan_a, CF_ANSWERED)
&& switch_channel_test_flag(chan_b, CF_ANSWERED)) {
switch_ivr_sleep(session_a, 5000, SWITCH_FALSE, NULL);
continue;
}
-
+
/* read audio from 1 channel and write it to the other */
status = switch_core_session_read_frame(session_a, &read_frame, SWITCH_IO_FLAG_NONE, stream_id);
read_frame_count++;
if (switch_test_flag(read_frame, SFF_CNG)) {
if (silence_val) {
- switch_generate_sln_silence((int16_t *) silence_frame.data, silence_frame.samples,
+ switch_generate_sln_silence((int16_t *) silence_frame.data, silence_frame.samples,
read_impl.number_of_channels, silence_val);
read_frame = &silence_frame;
} else if (!switch_channel_test_flag(chan_b, CF_ACCEPT_CNG)) {
switch_channel_set_variable(chan_a, SWITCH_BRIDGE_VARIABLE, NULL);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session_a), SWITCH_LOG_DEBUG, "BRIDGE THREAD DONE [%s]\n", switch_channel_get_name(chan_a));
switch_channel_clear_flag(chan_a, CF_BRIDGED);
-
+
if (switch_channel_test_flag(chan_a, CF_LEG_HOLDING) || switch_channel_test_flag(chan_a, CF_HANGUP_HELD)) {
if (switch_channel_ready(chan_b) &&
switch_channel_get_state(chan_b) != CS_PARK && !data->other_leg_data->clean_exit && !switch_channel_test_flag(chan_b, CF_3P_NOMEDIA_REQUESTED)) {
const char *ext = switch_channel_get_variable(chan_a, "hold_hangup_xfer_exten");
-
+
switch_channel_stop_broadcast(chan_b);
if (zstr(ext)) {
state = switch_channel_get_state(channel);
if (!switch_channel_test_flag(channel, CF_TRANSFER) && !switch_channel_test_flag(channel, CF_REDIRECT) &&
- !switch_channel_test_flag(channel, CF_XFER_ZOMBIE) && bd && !bd->clean_exit && state != CS_PARK && state != CS_ROUTING &&
+ !switch_channel_test_flag(channel, CF_XFER_ZOMBIE) && bd && !bd->clean_exit && state != CS_PARK && state != CS_ROUTING &&
state == CS_EXCHANGE_MEDIA && !switch_channel_test_flag(channel, CF_INNER_BRIDGE)) {
if (state < CS_HANGUP && switch_true(switch_channel_get_variable(channel, SWITCH_PARK_AFTER_BRIDGE_VARIABLE))) {
int max = 1000, loops = max;
switch_channel_set_variable(channel, SWITCH_UUID_BRIDGE, NULL);
-
+
for (;;) {
state = switch_channel_get_state(other_channel);
running_state = switch_channel_get_running_state(other_channel);
}
if (state < CS_HANGUP && state == running_state) {
-
+
if (--loops < 1) {
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
switch_channel_hangup(other_channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
} else {
loops = max;
}
-
+
switch_yield(20000);
}
msg->message_id = SWITCH_MESSAGE_INDICATE_UNBRIDGE;
msg->from = __FILE__;
msg->string_arg = switch_channel_get_variable(channel, SWITCH_SIGNAL_BRIDGE_VARIABLE);
- switch_core_session_queue_message(session, msg);
-
+ switch_core_session_queue_message(session, msg);
+
switch_core_event_hook_remove_state_change(session, hanguphook);
return SWITCH_STATUS_SUCCESS;
switch_channel_set_variable(channel, SWITCH_BRIDGE_VARIABLE, switch_channel_get_variable(channel, SWITCH_SIGNAL_BRIDGE_VARIABLE));
switch_channel_set_variable(channel, SWITCH_LAST_BRIDGE_VARIABLE, switch_channel_get_variable(channel, SWITCH_SIGNAL_BRIDGE_VARIABLE));
-
+
switch_channel_set_bridge_time(channel);
}
}
- if ((dmachine[0] = switch_core_session_get_dmachine(session, DIGIT_TARGET_SELF)) ||
+ if ((dmachine[0] = switch_core_session_get_dmachine(session, DIGIT_TARGET_SELF)) ||
(dmachine[1] = switch_core_session_get_dmachine(session, DIGIT_TARGET_PEER))) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
"%s not hibernating due to active digit parser, semi-hibernation engaged.\n", switch_channel_get_name(channel));
while(switch_channel_ready(channel) && switch_channel_get_state(channel) == CS_HIBERNATE) {
switch_ivr_parse_all_messages(session);
}
}
-
+
return SWITCH_STATUS_SUCCESS;
}
}
}
}
-
+
if (switch_channel_test_flag(channel, CF_BRIDGE_ORIGINATOR)) {
switch_channel_clear_flag_recursive(channel, CF_BRIDGE_ORIGINATOR);
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_UNBRIDGE) == SWITCH_STATUS_SUCCESS) {
originator_cp->callee_id_name = switch_core_strdup(originator_cp->pool, originatee_cp->callee_id_name);
originator_cp->callee_id_number = switch_core_strdup(originator_cp->pool, originatee_cp->callee_id_number);
-
+
switch_channel_process_export(peer_channel, channel, NULL, SWITCH_BRIDGE_EXPORT_VARS_VARIABLE);
switch_channel_process_export(channel, peer_channel, NULL, SWITCH_BRIDGE_EXPORT_VARS_VARIABLE);
static void abort_call(switch_channel_t *caller_channel, switch_channel_t *peer_channel)
{
switch_call_cause_t cause = switch_channel_get_cause(caller_channel);
-
+
if (!cause) {
cause = SWITCH_CAUSE_ORIGINATOR_CANCEL;
}
-
+
switch_channel_hangup(peer_channel, cause);
}
}
check_bridge_export(caller_channel, peer_channel);
-
+
switch_channel_set_flag_recursive(caller_channel, CF_MEDIA_BRIDGE_TTL);
switch_channel_set_flag_recursive(peer_channel, CF_MEDIA_BRIDGE_TTL);
if (switch_channel_test_flag(peer_channel, CF_ANSWERED) || switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA) ||
switch_channel_test_flag(peer_channel, CF_RING_READY)) {
const char *app, *data;
-
+
if (!switch_channel_ready(caller_channel)) {
abort_call(caller_channel, peer_channel);
goto done;
switch_channel_set_state(peer_channel, CS_CONSUME_MEDIA);
switch_channel_set_variable(peer_channel, "call_uuid", switch_core_session_get_uuid(session));
-
+
switch_channel_set_bridge_time(caller_channel);
switch_channel_set_bridge_time(peer_channel);
if ((app = switch_channel_get_variable(caller_channel, "bridge_pre_execute_aleg_app"))) {
switch_channel_set_variable(caller_channel, "bridge_pre_execute_app", app);
-
+
if ((data = switch_channel_get_variable(caller_channel, "bridge_pre_execute_aleg_data"))) {
switch_channel_set_variable(caller_channel, "bridge_pre_execute_data", data);
}
if ((data = switch_channel_get_variable(caller_channel, "bridge_pre_execute_bleg_data"))) {
switch_channel_set_variable(peer_channel, "bridge_pre_execute_data", data);
}
-
+
}
-
+
switch_channel_set_private(peer_channel, "_bridge_", b_leg);
switch_channel_set_state(peer_channel, CS_EXCHANGE_MEDIA);
if ((cause = switch_channel_get_cause(peer_channel))) {
switch_channel_set_variable(caller_channel, SWITCH_BRIDGE_HANGUP_CAUSE_VARIABLE, switch_channel_cause2str(cause));
}
-
+
if (switch_channel_down_nosig(peer_channel)) {
switch_bool_t copy_xml_cdr = switch_true(switch_channel_get_variable(peer_channel, SWITCH_COPY_XML_CDR_VARIABLE));
switch_bool_t copy_json_cdr = switch_true(switch_channel_get_variable(peer_channel, SWITCH_COPY_JSON_CDR_VARIABLE));
if (copy_xml_cdr || copy_json_cdr) {
- char *cdr_text = NULL;
+ char *cdr_text = NULL;
switch_channel_wait_for_state(peer_channel, caller_channel, CS_DESTROY);
switch_safe_free(cdr_text);
}
}
-
+
}
-
+
switch_core_session_rwunlock(peer_session);
} else {
if (cause == SWITCH_CAUSE_NONE) {
cause = SWITCH_CAUSE_NORMAL_CLEARING;
}
-
+
if (hup) {
explicit = !strcasecmp(hup, "explicit");
}
-
+
if (cause && !switch_channel_test_flag(peer_channel, CF_ANSWERED)) {
switch_channel_handle_cause(caller_channel, cause);
}
-
+
if (explicit) {
if (switch_channel_test_flag(peer_channel, CF_INTERCEPTED)) {
switch_channel_set_flag(peer_channel, CF_INTERCEPT);
early = switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA);
if ((state != CS_EXECUTE && state != CS_SOFT_EXECUTE && state != CS_PARK && state != CS_ROUTING) || ((answered || early) && state < CS_HANGUP)) {
-
+
if (!switch_channel_test_flag(caller_channel, CF_TRANSFER)) {
if ((answered && switch_true(switch_channel_get_variable(caller_channel, SWITCH_PARK_AFTER_BRIDGE_VARIABLE))) ||
{
switch_channel_t *channel = switch_core_session_get_channel(session);
- if (switch_channel_test_flag(channel, CF_PROXY_MODE) &&
+ if (switch_channel_test_flag(channel, CF_PROXY_MODE) &&
!switch_channel_test_flag(channel, CF_MEDIA_TRANS) && !switch_channel_test_flag(channel, CF_3P_MEDIA_REQUESTED)) {
switch_ivr_media(switch_core_session_get_uuid(session), SMF_NONE);
}
switch_channel_t *channel = switch_core_session_get_channel(session);
int done = 0;
- if (!switch_channel_test_flag(channel, CF_3P_MEDIA_REQUESTED) &&
+ if (!switch_channel_test_flag(channel, CF_3P_MEDIA_REQUESTED) &&
switch_channel_test_flag(channel, CF_PROXY_MODE) && !switch_channel_test_flag(channel, CF_3P_NOMEDIA_REQUESTED)) {
if (switch_core_session_get_partner(session, &sbsession) == SWITCH_STATUS_SUCCESS) {
switch_channel_t *sbchannel = switch_core_session_get_channel(sbsession);
- if (switch_channel_test_flag(sbchannel, CF_PROXY_MODE)) {
+ if (switch_channel_test_flag(sbchannel, CF_PROXY_MODE)) {
/* Clear this now, otherwise will cause the one we're interested in to hang up too...*/
switch_channel_set_variable(sbchannel, SWITCH_SIGNAL_BRIDGE_VARIABLE, NULL);
switch_channel_hangup(sbchannel, SWITCH_CAUSE_ATTENDED_TRANSFER);
}
if (done) return;
-
+
switch_channel_set_variable(channel, SWITCH_SIGNAL_BRIDGE_VARIABLE, NULL);
switch_channel_set_variable(channel, SWITCH_BRIDGE_VARIABLE, NULL);
switch_channel_set_variable(channel, SWITCH_BRIDGE_UUID_VARIABLE, NULL);
if (switch_channel_direction(originatee_channel) == SWITCH_CALL_DIRECTION_OUTBOUND && switch_channel_test_flag(originatee_channel, CF_DIALPLAN)) {
switch_channel_clear_flag(originatee_channel, CF_DIALPLAN);
}
-
+
cleanup_proxy_mode_a(originator_session);
cleanup_proxy_mode_a(originatee_session);
- /* override transmit state for originator_channel to bridge to originatee_channel
+ /* override transmit state for originator_channel to bridge to originatee_channel
* install pointer to originatee_session into originator_channel
* set CF_TRANSFER on both channels and change state to CS_SOFT_EXECUTE to
* interrupt anything they are already doing.
originatee_cp = switch_channel_get_caller_profile(originatee_channel);
-
+
if (switch_channel_outbound_display(originator_channel)) {
switch_channel_invert_cid(originator_channel);
-
+
if (switch_channel_direction(originator_channel) == SWITCH_CALL_DIRECTION_INBOUND) {
switch_channel_clear_flag(originatee_channel, CF_BLEG);
}
if (switch_channel_inbound_display(originatee_channel)) {
switch_channel_invert_cid(originatee_channel);
-
+
if (switch_channel_direction(originatee_channel) == SWITCH_CALL_DIRECTION_INBOUND) {
switch_channel_set_flag(originatee_channel, CF_BLEG);
}
switch_channel_set_originator_caller_profile(originatee_channel, switch_caller_profile_clone(originatee_session, originator_cp));
switch_channel_set_originatee_caller_profile(originator_channel, switch_caller_profile_clone(originator_session, originatee_cp));
-
+
originator_cp->callee_id_name = switch_core_strdup(originator_cp->pool, originatee_cp->callee_id_name);
originator_cp->callee_id_number = switch_core_strdup(originator_cp->pool, originatee_cp->callee_id_number);
switch_channel_clear_flag(originatee_channel, CF_ORIGINATING);
- originator_cp->transfer_source = switch_core_sprintf(originator_cp->pool,
- "%ld:%s:uuid_br:%s", (long)switch_epoch_time_now(NULL), originator_cp->uuid_str,
+ originator_cp->transfer_source = switch_core_sprintf(originator_cp->pool,
+ "%ld:%s:uuid_br:%s", (long)switch_epoch_time_now(NULL), originator_cp->uuid_str,
switch_core_session_get_uuid(originatee_session));
- switch_channel_add_variable_var_check(originator_channel, SWITCH_TRANSFER_HISTORY_VARIABLE,
+ switch_channel_add_variable_var_check(originator_channel, SWITCH_TRANSFER_HISTORY_VARIABLE,
originator_cp->transfer_source, SWITCH_FALSE, SWITCH_STACK_PUSH);
switch_channel_set_variable(originator_channel, SWITCH_TRANSFER_SOURCE_VARIABLE, originator_cp->transfer_source);
-
+
originatee_cp->transfer_source = switch_core_sprintf(originatee_cp->pool,
- "%ld:%s:uuid_br:%s", (long)switch_epoch_time_now(NULL), originatee_cp->uuid_str,
+ "%ld:%s:uuid_br:%s", (long)switch_epoch_time_now(NULL), originatee_cp->uuid_str,
switch_core_session_get_uuid(originator_session));
- switch_channel_add_variable_var_check(originatee_channel, SWITCH_TRANSFER_HISTORY_VARIABLE,
+ switch_channel_add_variable_var_check(originatee_channel, SWITCH_TRANSFER_HISTORY_VARIABLE,
originatee_cp->transfer_source, SWITCH_FALSE, SWITCH_STACK_PUSH);
switch_channel_set_variable(originatee_channel, SWITCH_TRANSFER_SOURCE_VARIABLE, originatee_cp->transfer_source);
switch_channel_t *rchannel = switch_core_session_get_channel(rsession);
const char *brto;
- if ((brto = switch_channel_get_variable(rchannel, SWITCH_ORIGINATE_SIGNAL_BOND_VARIABLE)) ||
+ if ((brto = switch_channel_get_variable(rchannel, SWITCH_ORIGINATE_SIGNAL_BOND_VARIABLE)) ||
(brto = switch_channel_get_partner_uuid(rchannel))) {
switch_copy_string(b_uuid, brto, blen);
status = SWITCH_STATUS_SUCCESS;
switch_channel_t *channel, *rchannel, *bchannel = NULL;
const char *buuid, *var;
char brto[SWITCH_UUID_FORMATTED_LENGTH + 1] = "";
-
+
if (bleg) {
if (switch_ivr_find_bridged_uuid(uuid, brto, sizeof(brto)) == SWITCH_STATUS_SUCCESS) {
uuid = switch_core_session_strdup(session, brto);
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Neal Horman <neal at wanlink dot com>
*
}
action->function = function;
-
+
if (menu->actions) {
for(ap = menu->actions; ap && ap->next; ap = ap->next);
ap->next = action;
char *app = switch_core_session_strdup(session, app_str);
char *data = strchr(app, ' ');
char *expanded = NULL;
-
+
if (data) {
*data++ = '\0';
}
-
+
expanded = switch_channel_expand_variables(channel, data);
-
+
switch_core_session_execute_application(session, app, expanded);
-
+
if (expanded && expanded != data) {
free(expanded);
}
char *digits_regex = switch_core_session_sprintf(session, "^%s$", menu->pin);
if (switch_play_and_get_digits(session, (uint32_t)strlen(menu->pin), (uint32_t)strlen(menu->pin), 3, 3000, "#",
- menu->prompt_pin_file, menu->bad_pin_file, NULL, digit_buffer, sizeof(digit_buffer),
+ menu->prompt_pin_file, menu->bad_pin_file, NULL, digit_buffer, sizeof(digit_buffer),
digits_regex, 10000, NULL) != SWITCH_STATUS_SUCCESS) {
switch_goto_status(SWITCH_STATUS_FALSE, end);
}
const char *pin = switch_xml_attr_soft(xml_menu, "pin");
const char *prompt_pin_file = switch_xml_attr_soft(xml_menu, "pin-file");
const char *bad_pin_file = switch_xml_attr_soft(xml_menu, "bad-pin-file");
-
+
switch_ivr_menu_t *menu = NULL;
if (zstr(max_timeouts)) {
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Michael Jerris <mike@jerris.com>
* Travis Cross <tc@traviscross.com>
if (!strcasecmp(collect->key, "exec")) {
char *data;
char *app_name, *app_data;
-
+
if (!(data = collect->file)) {
goto wbreak;
}
if (zstr(file)) {
file = "silence";
}
-
+
status = switch_ivr_read(collect->session,
(uint32_t)len,
(uint32_t)len,
collect->file, NULL, buf, sizeof(buf), collect->confirm_timeout, NULL, 0);
-
-
+
+
if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK && status != SWITCH_STATUS_TOO_SMALL) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(collect->session), SWITCH_LOG_ERROR, "%s Error Playing File!\n",
switch_channel_get_name(channel));
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
}
-
+
if (!strcmp(collect->key, buf)) {
switch_channel_set_flag(channel, CF_WINNER);
switch_channel_set_variable(channel, "group_dial_status", "winner");
switch_snprintf(tmp, sizeof(tmp), "%s@%uh@%ui",
impl.iananame, impl.samples_per_second, (uint32_t)impl.microseconds_per_packet / 1000);
}
-
+
if (ep && switch_stristr(impl.iananame, ep)) {
switch_channel_set_variable(caller_channel, "absolute_codec_string", tmp);
switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(caller_channel), SWITCH_LOG_DEBUG, "Setting codec string on %s to %s\n",
if (originate_status[i].peer_channel && switch_channel_test_flag(originate_status[i].peer_channel, CF_CHANNEL_SWAP)) {
const char *key = switch_channel_get_variable(originate_status[i].peer_channel, "channel_swap_uuid");
switch_core_session_t *swap_session, *old_session;
-
+
if ((swap_session = switch_core_session_locate(key))) {
switch_channel_clear_flag(originate_status[i].peer_channel, CF_CHANNEL_SWAP);
switch_channel_hangup(originate_status[i].peer_channel, SWITCH_CAUSE_PICKED_OFF);
switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(originate_status[i].peer_channel), SWITCH_LOG_DEBUG, "Swapping %s for %s\n",
switch_core_session_get_name(swap_session), switch_channel_get_name(originate_status[i].peer_channel));
-
-
+
+
old_session = originate_status[i].peer_session;
originate_status[i].peer_session = swap_session;
originate_status[i].peer_channel = switch_core_session_get_channel(originate_status[i].peer_session);
originate_status[i].caller_profile = switch_channel_get_caller_profile(originate_status[i].peer_channel);
switch_channel_set_flag(originate_status[i].peer_channel, CF_ORIGINATING);
-
+
switch_channel_answer(originate_status[i].peer_channel);
switch_channel_set_variable(originate_status[i].peer_channel, "picked_up_uuid", switch_core_session_get_uuid(old_session));
}
}
}
-
- if (!switch_channel_test_flag(originate_status[i].peer_channel, CF_PARK) &&
+
+ if (!switch_channel_test_flag(originate_status[i].peer_channel, CF_PARK) &&
!switch_channel_test_flag(originate_status[i].peer_channel, CF_CONSUME_ON_ORIGINATE)) {
if (switch_core_session_messages_waiting(originate_status[i].peer_session)) {
if (switch_channel_test_flag(originate_status[i].peer_channel, CF_THREAD_SLEEPING)) {
if (rval == 0 && pickups_without_timelimit) {
for (i = 0; i < len; i++) {
- if (originate_status[i].peer_channel && switch_channel_test_flag(originate_status[i].peer_channel, CF_PICKUP) &&
+ if (originate_status[i].peer_channel && switch_channel_test_flag(originate_status[i].peer_channel, CF_PICKUP) &&
switch_channel_up(originate_status[i].peer_channel)) {
switch_channel_hangup(originate_status[i].peer_channel, SWITCH_CAUSE_NO_PICKUP);
}
}
- if (pindex > -1 && caller_channel && switch_channel_ready(caller_channel) && !switch_channel_media_ready(caller_channel) &&
+ if (pindex > -1 && caller_channel && switch_channel_ready(caller_channel) && !switch_channel_media_ready(caller_channel) &&
switch_channel_media_ready(originate_status[pindex].peer_channel)) {
inherit_codec(caller_channel, originate_status[pindex].peer_session);
}
return -1;
}
wrote = teletone_mux_tones(ts, map);
-
+
if (tto->channels != 1) {
if (tto->mux_buflen < wrote * 2 * tto->channels) {
tto->mux_buflen = wrote * 2 * tto->channels;
switch_core_file_seek(ringback.fh, &pos, 0, SEEK_SET);
switch_core_file_read(ringback.fh, write_frame.data, &olen);
if (olen == 0) {
- switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(caller_channel), SWITCH_LOG_ERROR,
+ switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(caller_channel), SWITCH_LOG_ERROR,
"Failure to read or re-read after seeking to beginning on file [%s]\n", ringback.fh->file_path);
break;
}
}
} else if (ringback.silence) {
write_frame.datalen = write_frame.codec->implementation->decoded_bytes_per_packet;
- switch_generate_sln_silence((int16_t *) write_frame.data, write_frame.datalen / 2,
+ switch_generate_sln_silence((int16_t *) write_frame.data, write_frame.datalen / 2,
write_frame.codec->implementation->number_of_channels, ringback.silence);
}
switch_buffer_destroy(&ringback.audio_buffer);
}
-
+
switch_ivr_parse_all_events(session);
-
+
switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
if (switch_core_codec_ready(&write_codec)) {
if (!switch_channel_test_flag(caller_channel, CF_ANSWERED)
&& !switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA)) {
- if (oglobals->bridge_early_media > -1 && len == 1 && originate_status[0].peer_session &&
- switch_channel_media_ready(originate_status[0].peer_channel)) {
+ if (oglobals->bridge_early_media > -1 && len == 1 && originate_status[0].peer_session &&
+ switch_channel_media_ready(originate_status[0].peer_channel)) {
inherit_codec(caller_channel, originate_status[0].peer_session);
}
if ((status = switch_channel_pre_answer(caller_channel)) != SWITCH_STATUS_SUCCESS) {
}
} else if (oglobals->bridge_early_media > -1 && zstr(ringback_data) && len == 1 && originate_status[0].peer_session) {
switch_codec_implementation_t read_impl = { 0 }, write_impl = { 0 };
-
+
if (switch_channel_ready(originate_status[0].peer_channel)
&& switch_core_session_get_read_impl(originate_status[0].peer_session, &read_impl) == SWITCH_STATUS_SUCCESS
&& switch_core_session_get_write_impl(oglobals->session, &write_impl) == SWITCH_STATUS_SUCCESS) {
- if (read_impl.impl_id == write_impl.impl_id &&
+ if (read_impl.impl_id == write_impl.impl_id &&
read_impl.microseconds_per_packet == write_impl.microseconds_per_packet &&
read_impl.actual_samples_per_second == write_impl.actual_samples_per_second) {
ringback->asis++;
switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(caller_channel), SWITCH_LOG_DEBUG, "bridge_early_media: passthrough enabled\n");
} else {
switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(caller_channel), SWITCH_LOG_DEBUG, "bridge_early_media: codecs don't match (%s@%uh@%di / %s@%uh@%di)\n",
- read_impl.iananame, read_impl.actual_samples_per_second, read_impl.microseconds_per_packet / 1000,
+ read_impl.iananame, read_impl.actual_samples_per_second, read_impl.microseconds_per_packet / 1000,
write_impl.iananame, write_impl.actual_samples_per_second, write_impl.microseconds_per_packet / 1000);
}
}
const char *cid_name_override,
const char *cid_num_override,
switch_caller_profile_t *caller_profile_override,
- switch_event_t *ovars, switch_originate_flag_t flags,
+ switch_event_t *ovars, switch_originate_flag_t flags,
switch_call_cause_t *cancel_cause)
{
int x_argc = 0;
if (session) {
switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "ent_originate_aleg_uuid", switch_core_session_get_uuid(session));
}
-
+
if (channel) {
const char *tmp_var = NULL;
for (i = 0; i < MAX_PEERS && i < state->ttl; i++) {
switch_core_session_t *session = state->originate_status[i].peer_session;
switch_channel_t *channel = NULL;
-
+
if (session) channel = switch_core_session_get_channel(session);
if (!session || !channel || !switch_channel_up(channel)) {
if (!session || !channel || !switch_channel_up(channel)) {
continue;
}
-
+
if (switch_channel_media_ready(channel)) {
ready++;
state->oglobals->bridge_early_media = -1;
state->oglobals->ignore_early_media = 1;
}
-
+
if (switch_channel_test_flag(channel, CF_ANSWERED)) {
answered++;
}
}
}
}
-
+
if (!ready || answered || ring_ready) {
break;
}
-
+
if (!datalen) {
continue;
}
for (i = 0; i < MAX_PEERS && i < state->ttl; i++) {
switch_core_session_t *session = originate_status[i].peer_session;
switch_channel_t *channel = originate_status[i].peer_channel;
-
+
if (!session) continue;
if (switch_core_codec_ready((&read_codecs[i]))) {
switch_channel_set_variable(caller_channel, "originate_causes", NULL);
}
}
-
-
+
+
if (strstr(bridgeto, SWITCH_ENT_ORIGINATE_DELIM)) {
return switch_ivr_enterprise_originate(session, bleg, cause, bridgeto, timelimit_sec, table, cid_name_override, cid_num_override,
caller_profile_override, ovars, flags, cancel_cause);
if (!switch_channel_test_flag(caller_channel, CF_ANSWERED) && switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA)) {
switch_channel_set_variable(caller_channel, SWITCH_B_SDP_VARIABLE, NULL);
switch_channel_answer(caller_channel);
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
"Must answer channel %s due to SIP PARADOX\n", switch_channel_get_name(caller_channel));
}
switch_channel_set_variable(caller_channel, SWITCH_B_SDP_VARIABLE, NULL);
switch_ivr_media(switch_core_session_get_uuid(session), SMF_NONE);
}
}
-
+
if (switch_channel_test_flag(caller_channel, CF_PROXY_MODE) && switch_channel_test_flag(caller_channel, CF_ANSWERED)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
"Channel is already up, delaying proxy mode 'till both legs are answered.\n");
/* Some channel are created from an originating channel and some aren't so not all outgoing calls have a way to get params
- so we will normalize dialstring params and channel variables (when there is an originator) into an event that we
+ so we will normalize dialstring params and channel variables (when there is an originator) into an event that we
will use as a pseudo hash to consult for params as needed.
*/
data++;
}
- if ((ovars && switch_true(switch_event_get_header(ovars,"origination_nested_vars"))) ||
- (caller_channel && switch_true(switch_channel_get_variable(caller_channel, "origination_nested_vars")))
+ if ((ovars && switch_true(switch_event_get_header(ovars,"origination_nested_vars"))) ||
+ (caller_channel && switch_true(switch_channel_get_variable(caller_channel, "origination_nested_vars")))
|| switch_true(switch_core_get_variable("origination_nested_vars")) || switch_stristr("origination_nested_vars=true", data)) {
oglobals.check_vars = SWITCH_FALSE;
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Parse Error!\n");
switch_goto_status(SWITCH_STATUS_GENERR, done);
}
-
+
data = parsed;
}
}
data = parsed;
}
-
+
/* strip leading spaces (again) */
while (data && *data && *data == ' ') {
data++;
}
}
}
-
+
if (oglobals.session) {
switch_event_header_t *hi;
const char *cdr_total_var;
}
}
/* When using the AND operator, the fail_on_single_reject flag may be set in order to indicate that a single
- rejections should terminate the attempt rather than a timeout, answer, or rejection by all.
+ rejections should terminate the attempt rather than a timeout, answer, or rejection by all.
If the value is set to 'true' any fail cause will end the attempt otherwise it can contain a comma (,) separated
list of cause names which should be considered fatal
*/
if (cid_num_override) {
dftflags |= SOF_NO_EFFECTIVE_CID_NUM;
}
-
+
if (cid_name_override) {
dftflags |= SOF_NO_EFFECTIVE_CID_NAME;
}
oglobals.sent_ring = 0;
oglobals.progress = 0;
myflags = dftflags;
-
+
if (try > 0) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Originate attempt %d/%d in %d ms\n", try + 1, retries,
}
p = pipe_names[r];
-
+
while (p && *p) {
if (*p == '[') {
end = switch_find_end_paren(p, '[', ']');
}
q = 0;
}
-
+
if (*p == '\'') {
q = !q;
}
if (end && p < end && *p == ',' && *(p-1) != '\\') {
-
+
if (q || alt) {
*p = QUOTED_ESC_COMMA;
} else {
switch_event_t *local_var_event = NULL, *originate_var_event = NULL;
end = NULL;
-
+
chan_type = peer_names[i];
-
+
/* strip leading spaces */
while (chan_type && *chan_type && *chan_type == ' ') {
chan_type++;
}
-
+
/* extract channel variables, allowing multiple sets of braces */
-
+
if (*chan_type == '[') {
switch_event_create_plain(&local_var_event, SWITCH_EVENT_CHANNEL_DATA);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Parsing session specific variables\n");
while (*chan_type == '[') {
char *parsed = NULL;
- char *bend = switch_find_end_paren(chan_type, '[', ']');
+ char *bend = switch_find_end_paren(chan_type, '[', ']');
for (p = chan_type + 1; p && p < bend && *p; p++) {
if (*p == QUOTED_ESC_COMMA) {
*p = ',';
}
- }
-
- if (switch_event_create_brackets(chan_type, '[', ']', UNQUOTED_ESC_COMMA,
+ }
+
+ if (switch_event_create_brackets(chan_type, '[', ']', UNQUOTED_ESC_COMMA,
&local_var_event, &parsed, SWITCH_FALSE) != SWITCH_STATUS_SUCCESS || !parsed) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Parse Error!\n");
switch_goto_status(SWITCH_STATUS_GENERR, done);
}
-
+
if (chan_type == parsed) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Parse Error!\n");
- switch_goto_status(SWITCH_STATUS_GENERR, done);
+ switch_goto_status(SWITCH_STATUS_GENERR, done);
} else {
chan_type = parsed;
}
}
-
-
+
+
/* strip leading spaces (again) */
while (chan_type && *chan_type && *chan_type == ' ') {
chan_type++;
}
-
+
if ((chan_data = strchr(chan_type, '/')) != 0) {
*chan_data = '\0';
chan_data++;
status = SWITCH_STATUS_FALSE;
goto done;
}
-
+
if ((caller_caller_profile = oglobals.caller_profile_override)) {
new_profile = switch_caller_profile_dup(oglobals.pool, caller_caller_profile);
} else {
if (and_argc > 1 || or_argc > 1) {
myflags |= SOF_FORKED_DIAL;
- }
-
+ }
+
if (var_event) {
const char *vvar;
if ((vvar = switch_event_get_header(var_event, "forked_dial")) && switch_true(vvar)) {
}
}
-
+
/* Valid in both {} and [] with [] taking precedence */
- /* make a special var event with mixture of the {} and the [] vars to pass down as global vars to the outgoing channel
+ /* make a special var event with mixture of the {} and the [] vars to pass down as global vars to the outgoing channel
so if something like the user channel does another originate our options will be passed down properly
*/
-
+
switch_event_dup(&originate_var_event, var_event);
if (local_var_event) {
switch_set_flag(new_profile, SWITCH_CPF_HIDE_NUMBER);
}
}
-
+
switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "originate_early_media", oglobals.early_ok ? "true" : "false");
new_name = switch_core_session_sprintf(session, "_%s", switch_channel_get_name(caller_channel));
switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "sip_h_X-FS-Channel-Name", new_name);
}
-
-
+
+
reason = switch_core_session_outgoing_channel(oglobals.session, originate_var_event, chan_type,
new_profile, &new_session, NULL, myflags, cancel_cause);
switch_event_destroy(&originate_var_event);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Cannot create outgoing channel of type [%s] cause: [%s]\n",
chan_type, switch_channel_cause2str(reason));
if (local_var_event) switch_event_destroy(&local_var_event);
-
+
if (fail_on_single_reject_var) {
const char *cause_str = switch_channel_cause2str(reason);
int neg = *fail_on_single_reject_var == '!';
originate_status[i].peer_session = new_session;
switch_channel_set_flag(originate_status[i].peer_channel, CF_ORIGINATING);
-
+
if (caller_channel) {
switch_channel_set_variable(originate_status[i].peer_channel, "call_uuid", switch_channel_get_variable(caller_channel, "call_uuid"));
}
-
+
if (local_var_event) {
const char *device_id = switch_event_get_header(local_var_event, "device_id");
if (switch_true(switch_channel_get_variable(originate_status[i].peer_channel, "leg_required"))) {
originate_status[i].tagged = 1;
}
-
+
if ((vvar = switch_channel_get_variable(originate_status[i].peer_channel, "origination_channel_name"))) {
switch_channel_set_name(originate_status[i].peer_channel, vvar);
}
if ((vvar = switch_channel_get_variable(originate_status[i].peer_channel, "leg_timeout"))) {
int val = atoi(vvar);
-
+
if (val > 0) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Setting leg timeout to %d\n",
switch_channel_get_name(originate_status[i].peer_channel), val);
originate_status[i].per_channel_timelimit_sec = (uint32_t) val;
}
}
-
+
if ((vvar = switch_channel_get_variable(originate_status[i].peer_channel, "leg_progress_timeout"))) {
int val = atoi(vvar);
if (val > 0) {
if (a_session) {
switch_channel_t *channel = switch_core_session_get_channel(a_session);
- char *val =
- switch_core_session_sprintf(a_session, "%s;%s;%s",
+ char *val =
+ switch_core_session_sprintf(a_session, "%s;%s;%s",
switch_core_session_get_uuid(originate_status[i].peer_session),
switch_str_nil(switch_channel_get_variable(originate_status[i].peer_channel, "callee_id_name")),
switch_str_nil(switch_channel_get_variable(originate_status[i].peer_channel, "callee_id_number")));
-
+
switch_channel_set_variable(originate_status[i].peer_channel, "originating_leg_uuid", switch_core_session_get_uuid(a_session));
-
+
switch_channel_add_variable_var_check(channel, "originated_legs", val, SWITCH_FALSE, SWITCH_STACK_PUSH);
-
+
}
if (l_session) {
switch_core_session_rwunlock(l_session);
l_session = NULL;
}
-
+
switch_channel_execute_on(originate_status[i].peer_channel, SWITCH_CHANNEL_EXECUTE_ON_ORIGINATE_VARIABLE);
switch_channel_api_on(originate_status[i].peer_channel, SWITCH_CHANNEL_API_ON_ORIGINATE_VARIABLE);
}
-
+
if (table) {
switch_channel_add_state_handler(originate_status[i].peer_channel, table);
}
-
+
if (oglobals.monitor_early_media_ring || oglobals.monitor_early_media_fail || oglobals.ignore_early_media == 4) {
switch_channel_set_flag(originate_status[i].peer_channel, CF_CONSUME_ON_ORIGINATE);
}
*cause = SWITCH_CAUSE_SUCCESS;
goto outer_for;
}
-
+
if (!switch_core_session_running(originate_status[i].peer_session)) {
if (originate_status[i].per_channel_delay_start) {
switch_channel_set_flag(originate_status[i].peer_channel, CF_BLOCK_STATE);
while ((!caller_channel || switch_channel_ready(caller_channel) || switch_channel_test_flag(caller_channel, CF_XFER_ZOMBIE)) &&
check_channel_status(&oglobals, originate_status, and_argc, &force_reason)) {
time_t elapsed = switch_epoch_time_now(NULL) - start;
-
+
read_packet = 0;
if (cancel_cause && *cancel_cause > 0) {
}
goto notready;
}
-
+
if ((to = (uint8_t) (elapsed >= (time_t) timelimit_sec)) || (fail_on_single_reject && oglobals.hups)) {
int ok = 0;
for (i = 0; i < and_argc; i++) {
switch_channel_t *pchannel;
const char *cause_str;
-
+
if (!originate_status[i].peer_session) {
continue;
}
if (neg) {
pos = !pos;
}
-
+
if (pos) {
ok = 0;
break;
switch_status_t rst;
rst = setup_ringback(&oglobals, originate_status, and_argc, ringback_data, &ringback, &write_frame, &write_codec);
-
+
if (oglobals.bridge_early_media > -1) {
switch_threadattr_t *thd_attr = NULL;
switch_threadattr_create(&thd_attr, switch_core_session_get_pool(session));
goto do_continue;
}
- if (oglobals.bridge_early_media > -1) {
+ if (oglobals.bridge_early_media > -1) {
write_frame.datalen = 0;
switch_mutex_lock(early_state.mutex);
if (ringback.asis) {
}
}
- }
+ }
do_continue:
if (i != oglobals.idx) {
holding = NULL;
-
+
if (oglobals.idx == IDX_TIMEOUT || to) {
reason = SWITCH_CAUSE_NO_ANSWER;
} else {
if ((holding_session = switch_core_session_locate(holding))) {
switch_channel_t *holding_channel = switch_core_session_get_channel(holding_session);
-
+
switch_channel_set_variable(holding_channel, SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE, "true");
if (caller_channel && switch_true(switch_channel_get_variable(caller_channel, "recording_follow_transfer"))) {
if (switch_true(switch_channel_get_variable(holding_channel, "recording_follow_transfer"))) {
switch_core_media_bug_transfer_recordings(holding_session, originate_status[i].peer_session);
}
-
+
switch_core_session_rwunlock(holding_session);
}
switch_channel_set_flag(originate_status[i].peer_channel, CF_LAZY_ATTENDED_TRANSFER);
}
wait_for_cause(originate_status[i].peer_channel);
-
+
if (switch_channel_down_nosig(originate_status[i].peer_channel)) {
*cause = switch_channel_get_cause(originate_status[i].peer_channel);
break;
}
-
+
}
}
}
for (i = 0; i < and_argc; i++) {
switch_channel_state_t state;
switch_core_session_t *peer_session;
- char *val;
+ char *val;
if (!originate_status[i].peer_channel) {
continue;
}
-
+
if (session) {
- val = switch_core_session_sprintf(originate_status[i].peer_session, "%s;%s",
- switch_core_session_get_uuid(originate_status[i].peer_session),
+ val = switch_core_session_sprintf(originate_status[i].peer_session, "%s;%s",
+ switch_core_session_get_uuid(originate_status[i].peer_session),
switch_channel_cause2str(switch_channel_get_cause(originate_status[i].peer_channel)));
-
+
switch_channel_add_variable_var_check(switch_core_session_get_channel(session), "originate_causes", val, SWITCH_FALSE, SWITCH_STACK_PUSH);
}
originate_status[i].down_session = originate_status[i].peer_session;
originate_status[i].peer_session = NULL;
originate_status[i].peer_channel = NULL;
-
+
switch_core_session_rwunlock(peer_session);
}
for (i = 0; i < and_argc; i++) {
switch_channel_t *pchannel;
const char *cause_str;
-
+
if (!originate_status[i].down_session) {
continue;
}
-
+
pchannel = switch_core_session_get_channel(originate_status[i].down_session);
wait_for_cause(pchannel);
if (switch_channel_down_nosig(pchannel)) {
int neg, pos;
-
+
cause_str = switch_channel_cause2str(switch_channel_get_cause(pchannel));
neg = *fail_on_single_reject_var == '!';
if (neg) {
pos = !pos;
- }
-
+ }
+
if (pos) {
ok = 0;
break;
}
}
}
-
+
if (!ok) {
goto outer_for;
}
// Now main SWITCH_SIGNAL_BOND_VARIABLE is populated, don't need this one anymore...
switch_channel_set_variable(caller_channel, SWITCH_ORIGINATE_SIGNAL_BOND_VARIABLE, NULL);
}
-
+
switch_channel_execute_on(bchan, SWITCH_CHANNEL_EXECUTE_ON_POST_ORIGINATE_VARIABLE);
switch_channel_api_on(bchan, SWITCH_CHANNEL_API_ON_POST_ORIGINATE_VARIABLE);
if (*file == '{') {
tfile = switch_core_session_strdup(session, file);
-
+
while (*file == '{') {
if ((e = switch_find_end_paren(tfile, '{', '}'))) {
*e = '\0';
}
}
}
-
+
file = switch_core_session_sprintf(session, "%s%s%s%s%s", switch_str_nil(tfile), tfile ? "}" : "", prefix, SWITCH_PATH_SEPARATOR, file);
}
if ((ext = strrchr(file, '.'))) {
arg_recursion_check_stop(args);
return SWITCH_STATUS_GENERR;
}
-
+
if ((p = switch_channel_get_variable(channel, "record_fill_cng")) || (fh->params && (p = switch_event_get_header(fh->params, "record_fill_cng")))) {
if (!strcasecmp(p, "true")) {
if ((p = switch_channel_get_variable(channel, "record_indication")) || (fh->params && (p = switch_event_get_header(fh->params, "record_indication")))) {
int flags = SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT;
waste_resources = 1400;
-
+
if (switch_core_file_open(&ind_fh,
p,
read_impl.number_of_channels,
}
}
- if ((p = switch_channel_get_variable(channel, "record_waste_resources")) ||
+ if ((p = switch_channel_get_variable(channel, "record_waste_resources")) ||
(fh->params && (p = switch_event_get_header(fh->params, "record_waste_resources")))) {
if (!strcasecmp(p, "true")) {
}
}
}
-
+
if (fill_cng || waste_resources) {
if (switch_core_codec_init(&write_codec,
"L16",
if (switch_core_file_has_video(fh, SWITCH_TRUE)) {
- switch_core_session_request_video_refresh(session);
-
- if ((p = switch_channel_get_variable(channel, "record_play_video")) ||
+ switch_core_session_request_video_refresh(session);
+
+ if ((p = switch_channel_get_variable(channel, "record_play_video")) ||
(fh->params && (p = switch_event_get_header(fh->params, "record_play_video")))) {
video_file = switch_core_session_strdup(session, p);
-
- if (switch_core_file_open(&vfh, video_file, fh->channels,
+
+ if (switch_core_file_open(&vfh, video_file, fh->channels,
read_impl.actual_samples_per_second, vid_play_file_flags, NULL) != SWITCH_STATUS_SUCCESS) {
memset(&vfh, 0, sizeof(vfh));
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Failure opening video playback file.\n");
}
}
- if (!switch_test_flag(&vfh, SWITCH_FILE_OPEN)) {
+ if (!switch_test_flag(&vfh, SWITCH_FILE_OPEN)) {
echo_on = 1;
switch_channel_set_flag_recursive(channel, CF_VIDEO_DECODED_READ);
switch_channel_set_flag(channel, CF_VIDEO_ECHO);
}
-
+
switch_core_media_set_video_file(session, fh, SWITCH_RW_READ);
} else if (switch_channel_test_flag(channel, CF_VIDEO)) {
switch_channel_set_flag(channel, CF_VIDEO_BLANK);
if (switch_test_flag(&vfh, SWITCH_FILE_FLAG_VIDEO_EOF)) {
//switch_core_media_set_video_file(session, NULL, SWITCH_RW_WRITE);
-
+
switch_core_media_lock_video_file(session, SWITCH_RW_WRITE);
switch_core_file_close(&vfh);
memset(&vfh, 0, sizeof(vfh));
-
- if (switch_core_file_open(&vfh, video_file, fh->channels,
+
+ if (switch_core_file_open(&vfh, video_file, fh->channels,
read_impl.actual_samples_per_second, vid_play_file_flags, NULL) != SWITCH_STATUS_SUCCESS) {
memset(&vfh, 0, sizeof(vfh));
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Failure opening video playback file.\n");
}
-
+
if (switch_core_file_has_video(&vfh, SWITCH_TRUE)) {
//switch_core_media_set_video_file(session, &vfh, SWITCH_RW_WRITE);
switch_core_media_gen_key_frame(session);
if (switch_test_flag(&ind_fh, SWITCH_FILE_OPEN)) {
switch_size_t olen = write_frame.codec->implementation->samples_per_packet;
-
+
if (switch_core_file_read(&ind_fh, write_frame.data, &olen) == SWITCH_STATUS_SUCCESS) {
write_frame.samples = olen;
write_frame.datalen = olen * 2 * ind_fh.channels;;
break;
}
}
-
+
if (waste_resources || switch_test_flag(&ind_fh, SWITCH_FILE_OPEN)) {
if (switch_core_session_write_frame(session, &write_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) {
if (fill_cng || waste_resources) {
switch_core_codec_destroy(&write_codec);
}
-
+
if (switch_core_file_has_video(fh, SWITCH_FALSE)) {
if (echo_on) {
switch_channel_clear_flag(channel, CF_VIDEO_ECHO);
timeout_samples = read_impl.actual_samples_per_second * tmp;
cumulative = 1;
}
-
+
} else if ((var = switch_channel_get_variable(channel, "playback_timeout_sec"))) {
int tmp = atoi(var);
if (tmp > 1) {
NULL,
NULL,
fh->samplerate,
- interval, read_impl.number_of_channels,
+ interval, read_impl.number_of_channels,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, pool) == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session),
- SWITCH_LOG_DEBUG, "Codec Activated %s@%uhz %u channels %dms\n",
+ SWITCH_LOG_DEBUG, "Codec Activated %s@%uhz %u channels %dms\n",
codec_name, fh->samplerate, read_impl.number_of_channels, interval);
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
- "Raw Codec Activation Failed %s@%uhz %u channels %dms\n", codec_name,
+ "Raw Codec Activation Failed %s@%uhz %u channels %dms\n", codec_name,
fh->samplerate, read_impl.number_of_channels, interval);
switch_core_session_io_write_lock(session);
switch_channel_set_private(channel, "__fh", NULL);
channels = read_impl.number_of_channels;
if (framelen == 0) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "%s cannot play or record native files with variable length data\n", switch_channel_get_name(channel));
-
+
switch_core_session_io_write_lock(session);
switch_channel_set_private(channel, "__fh", NULL);
switch_core_session_io_rwunlock(session);
continue;
}
switch_core_timer_sync(&timer); // Sync timer
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
"Setup timer success %u bytes per %d ms! %d ch\n", len, interval, codec.implementation->number_of_channels);
}
write_frame.rate = fh->samplerate;
done = 1;
break;
}
-
+
if (args->dmachine) {
char ds[2] = {dtmf.digit, '\0'};
if (ostatus != SWITCH_STATUS_SUCCESS) {
status = ostatus;
}
-
+
switch_event_destroy(&event);
}
}
if ((rstatus = switch_core_file_read(fh, abuf, &olen)) == SWITCH_STATUS_BREAK) {
continue;
}
-
+
if (rstatus != SWITCH_STATUS_SUCCESS) {
eof++;
continue;
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "done playing file %s\n", file);
- switch_channel_set_variable_printf(channel, "playback_last_offset_pos", "%d", fh->offset_pos);
+ switch_channel_set_variable_printf(channel, "playback_last_offset_pos", "%d", fh->offset_pos);
if (read_impl.samples_per_second) {
switch_channel_set_variable_printf(channel, "playback_seconds", "%d", fh->samples_in / fh->native_rate);
switch_core_session_io_write_lock(session);
switch_channel_set_private(channel, "__fh", NULL);
switch_core_session_io_rwunlock(session);
-
+
switch_core_media_set_video_file(session, NULL, SWITCH_RW_WRITE);
switch_core_file_close(fh);
break;
}
}
-
+
if (abuf) {
switch_size_t olen = raw_codec.implementation->samples_per_packet;
-
+
if (switch_core_file_read(&fh, abuf, &olen) != SWITCH_STATUS_SUCCESS) {
break;
}
-
+
write_frame.samples = (uint32_t) olen;
write_frame.datalen = (uint32_t) (olen * sizeof(int16_t) * fh.channels);
if ((status = switch_core_session_write_frame(session, &write_frame, SWITCH_IO_FLAG_NONE, 0)) != SWITCH_STATUS_SUCCESS) {
break;
}
}
-
+
if (countdown) {
if (!--countdown) {
switch_channel_set_variable(channel, "wait_for_silence_timeout", "false");
break;
}
}
-
+
if (abuf) {
switch_size_t olen = raw_codec.implementation->samples_per_packet;
-
+
if (switch_core_file_read(&fh, abuf, &olen) != SWITCH_STATUS_SUCCESS) {
break;
}
-
+
write_frame.samples = (uint32_t) olen;
write_frame.datalen = (uint32_t) (olen * sizeof(int16_t) * fh.channels);
if ((status = switch_core_session_write_frame(session, &write_frame, SWITCH_IO_FLAG_NONE, 0)) != SWITCH_STATUS_SUCCESS) {
break;
}
}
-
+
data = (int16_t *) read_frame->data;
for (energy = 0, j = 0, count = 0; count < read_frame->samples; count++) {
break;
}
}
-
+
if (abuf) {
switch_size_t olen = raw_codec.implementation->samples_per_packet;
-
+
if (switch_core_file_read(&fh, abuf, &olen) != SWITCH_STATUS_SUCCESS) {
break;
}
-
+
write_frame.samples = (uint32_t) olen;
write_frame.datalen = (uint32_t) (olen * sizeof(int16_t) * fh.channels);
if ((status = switch_core_session_write_frame(session, &write_frame, SWITCH_IO_FLAG_NONE, 0)) != SWITCH_STATUS_SUCCESS) {
break;
}
}
-
+
data = (int16_t *) read_frame->data;
for (energy = 0, j = 0, count = 0; count < read_frame->samples; count++) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "OPEN TTS %s\n", tts_name);
codec_name = "L16";
-
+
if (need_create) {
if (switch_core_codec_init(codec,
codec_name,
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Michael Jerris <mike@jerris.com>
*
SWITCH_DECLARE(switch_status_t) switch_ivr_say_spell(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
{
char *p;
-
+
arg_recursion_check_start(args);
for (p = tosay; p && *p; p++) {
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
* switch_jitterbuffer.c -- Audio/Video Jitter Buffer
{
switch_jb_node_t *a = (switch_jb_node_t *) l;
switch_jb_node_t *b = (switch_jb_node_t *) r;
-
+
if (!a->visible) return 0;
if (!b->visible) return 1;
/* Maintain reverse pointers in a doubly linked list. */
e->prev = tail;
-
+
tail = e;
}
}
if (!np) {
-
+
np = switch_core_alloc(jb->pool, sizeof(*np));
-
+
np->next = jb->node_list;
if (np->next) {
np->next->prev = np;
}
jb->node_list = np;
-
+
}
switch_assert(np);
} else if (node->prev) {
node->prev->next = node->next;
}
-
+
if (node->next) {
node->next->prev = node->prev;
}
}
switch_mutex_unlock(jb->list_mutex);
-
+
if (x) jb->complete_frames--;
}
static inline switch_jb_node_t *jb_find_lowest_seq(switch_jb_t *jb, uint32_t ts)
{
switch_jb_node_t *np, *lowest = NULL;
-
+
switch_mutex_lock(jb->list_mutex);
for (np = jb->node_list; np; np = np->next) {
if (!np->visible) continue;
}
sort_free_nodes(jb);
- switch_mutex_unlock(jb->list_mutex);
+ switch_mutex_unlock(jb->list_mutex);
}
static void jb_frame_inc_line(switch_jb_t *jb, int i, int line)
{
uint32_t old_frame_len = jb->frame_len;
-
+
if (i == 0) {
jb->frame_len = jb->min_frame_len;
goto end;
if (!lowest || !(lowest = jb_find_lowest_seq(jb, lowest->packet.header.ts))) {
goto end;
}
-
+
switch_mutex_lock(jb->mutex);
jb->node_list = sort_nodes(jb->node_list, node_cmp);
for (np = lowest->next; np; np = np->next) {
-
+
if (!np->visible) continue;
-
+
if (ntohs(np->packet.header.seq) != ntohs(np->prev->packet.header.seq) + 1) {
uint32_t val = (uint32_t)htons(ntohs(np->prev->packet.header.seq) + 1);
}
break;
}
-
+
if (np->packet.header.ts != lowest->packet.header.ts || !np->next) {
r = 1;
}
}
-
+
switch_mutex_unlock(jb->mutex);
end:
static inline void drop_second_newest_frame(switch_jb_t *jb)
{
switch_jb_node_t *second_newest = jb_find_penultimate_node(jb);
-
+
if (second_newest) {
drop_ts(jb, second_newest->packet.header.ts);
jb_debug(jb, 1, "Dropping second highest frame ts:%u\n", ntohl(second_newest->packet.header.ts));
switch_core_inthash_insert(jb->node_hash_ts, node->packet.header.ts, node);
}
- jb_debug(jb, (packet->header.m ? 1 : 2), "PUT packet last_ts:%u ts:%u seq:%u%s\n",
+ jb_debug(jb, (packet->header.m ? 1 : 2), "PUT packet last_ts:%u ts:%u seq:%u%s\n",
ntohl(jb->highest_wrote_ts), ntohl(node->packet.header.ts), ntohs(node->packet.header.seq), packet->header.m ? " <MARK>" : "");
if (jb->write_init && jb->type == SJB_VIDEO) {
} else {
seq_diff = abs(((int)ntohs(packet->header.seq) - ntohs(jb->highest_wrote_seq)));
}
-
+
if (ntohl(jb->highest_wrote_ts) > (UINT_MAX - 1000) && ntohl(node->packet.header.ts) < 1000) {
ts_diff = (UINT_MAX - ntohl(node->packet.header.ts)) + ntohl(node->packet.header.ts);
} else {
ts_diff = abs((int)((int64_t)ntohl(node->packet.header.ts) - (int64_t)ntohl(jb->highest_wrote_ts)));
}
-
+
if (((seq_diff >= jb->max_frame_len) || (ts_diff > (900000 * 5)))) {
jb_debug(jb, 2, "CHANGE DETECTED, PUNT %u\n", abs(((int)ntohs(packet->header.seq) - ntohs(jb->highest_wrote_seq))));
switch_jb_reset(jb);
}
}
-
- if (!jb->write_init || ntohs(packet->header.seq) > ntohs(jb->highest_wrote_seq) ||
+
+ if (!jb->write_init || ntohs(packet->header.seq) > ntohs(jb->highest_wrote_seq) ||
(ntohs(jb->highest_wrote_seq) > USHRT_MAX - 100 && ntohs(packet->header.seq) < 100) ) {
jb->highest_wrote_seq = packet->header.seq;
}
jb->highest_wrote_ts = packet->header.ts;
}
}
-
+
if (!jb->write_init) jb->write_init = 1;
}
jb->dropped = 0;
jb_debug(jb, 2, "%s", "DROPPED FRAME DETECTED RESYNCING\n");
jb->target_seq = 0;
-
+
if (jb->session) {
switch_core_session_request_video_refresh(jb->session);
}
//if (jb->session) {
// switch_core_session_request_video_refresh(jb->session);
//}
-
+
for (x = 0; x < 10; x++) {
increment_seq(jb);
if ((node = switch_core_inthash_find(jb->node_hash, jb->target_seq))) {
}
*nodep = node;
-
+
if (node) {
set_read_seq(jb, node->packet.header.seq);
return SWITCH_STATUS_SUCCESS;
}
return SWITCH_STATUS_NOTFOUND;
-
+
}
}
*nodep = node;
-
+
if (node) {
set_read_ts(jb, node->packet.header.ts);
node->packet.header.seq = htons(jb->psuedo_seq);
}
return SWITCH_STATUS_NOTFOUND;
-
+
}
static inline switch_status_t jb_next_packet(switch_jb_t *jb, switch_jb_node_t **nodep)
}
}
}
-
+
return (jb->complete_frames >= jb->frame_len) || jb->flush;
}
uint16_t want_seq = seq + peek;
node = switch_core_inthash_find(jb->node_hash, htons(want_seq));
} else if (ts && jb->samples_per_frame) {
- uint32_t want_ts = ts + (peek * jb->samples_per_frame);
+ uint32_t want_ts = ts + (peek * jb->samples_per_frame);
node = switch_core_inthash_find(jb->node_hash_ts, htonl(want_ts));
}
return SWITCH_STATUS_FALSE;
}
-SWITCH_DECLARE(switch_status_t) switch_jb_get_frames(switch_jb_t *jb, uint32_t *min_frame_len, uint32_t *max_frame_len, uint32_t *cur_frame_len, uint32_t *highest_frame_len)
+SWITCH_DECLARE(switch_status_t) switch_jb_get_frames(switch_jb_t *jb, uint32_t *min_frame_len, uint32_t *max_frame_len, uint32_t *cur_frame_len, uint32_t *highest_frame_len)
{
switch_mutex_lock(jb->mutex);
if (jb->frame_len < jb->min_frame_len) {
jb->frame_len = jb->min_frame_len;
}
-
+
if (jb->frame_len > jb->highest_frame_len) {
jb->highest_frame_len = jb->frame_len;
}
{
switch_jb_t *jb = *jbp;
*jbp = NULL;
-
+
if (jb->type == SJB_VIDEO) {
switch_core_inthash_destroy(&jb->missing_seq_hash);
}
uint16_t seq;
//const char *token;
switch_time_t then = 0;
-
+
switch_core_hash_this(hi, &var, NULL, &val);
//token = (const char *) val;
//printf("WTf\n");
// continue;
//}
-
+
seq = ntohs(*((uint16_t *) var));
then = (intptr_t) val;
//jb_debug(jb, 3, "NACKABLE seq %u too soon to repeat\n", seq);
continue;
}
-
+
//if (then != 1) {
// jb_debug(jb, 3, "NACKABLE seq %u not too soon to repeat %lu\n", seq, switch_time_now() - then);
//}
//jb_frame_inc(jb, 1);
}
-
+
switch_mutex_unlock(jb->mutex);
}
jb_debug(jb, 2, "GOT %u WANTED %u; MARK SEQS MISSING %u - %u\n", got, want, want, got - 1);
-
+
for (i = want; i < got; i++) {
jb_debug(jb, 2, "MARK MISSING %u ts:%u\n", i, ntohl(packet->header.ts));
switch_core_inthash_insert(jb->missing_seq_hash, (uint32_t)htons(i), (void *)(intptr_t)1);
if (switch_test_flag(jb, SJB_QUEUE_ONLY) && jb->complete_frames > jb->max_frame_len) {
drop_oldest_frame(jb);
}
-
+
switch_mutex_unlock(jb->mutex);
return SWITCH_STATUS_SUCCESS;
if (jb->type == SJB_VIDEO && jb->channel && jb->video_low_bitrate) {
//switch_time_t now = switch_time_now();
//int ok = (now - jb->last_bitrate_change) > 10000;
-
+
if (switch_channel_test_flag(jb->channel, CF_VIDEO_BITRATE_UNMANAGABLE) && jb->frame_len == jb->min_frame_len) {
jb_debug(jb, 2, "%s", "Allow BITRATE changes\n");
switch_channel_clear_flag(jb->channel, CF_VIDEO_BITRATE_UNMANAGABLE);
switch_core_session_message_t msg = { 0 };
jb->bitrate_control = jb->video_low_bitrate;
-
+
msg.message_id = SWITCH_MESSAGE_INDICATE_BITRATE_REQ;
msg.numeric_arg = jb->bitrate_control * 1024;
msg.from = __FILE__;
-
+
jb_debug(jb, 2, "Force BITRATE to %d\n", jb->bitrate_control);
switch_core_session_receive_message(jb->session, &msg);
switch_channel_set_flag(jb->channel, CF_VIDEO_BITRATE_UNMANAGABLE);
}
}
}
-
+
jb->period_miss_pct = ((double)jb->period_miss_count / jb->period_count) * 100;
jb_debug(jb, 2, "Miss percent %02f too high, resetting buffer.\n", jb->period_miss_pct);
switch_jb_reset(jb);
}
-
+
if ((status = jb_next_packet(jb, &node)) == SWITCH_STATUS_SUCCESS) {
jb_debug(jb, 2, "Found next frame cur ts: %u seq: %u\n", htonl(node->packet.header.ts), htons(node->packet.header.seq));
- if (!jb->read_init || ntohs(node->packet.header.seq) > ntohs(jb->highest_read_seq) ||
+ if (!jb->read_init || ntohs(node->packet.header.seq) > ntohs(jb->highest_read_seq) ||
(ntohs(jb->highest_read_seq) > USHRT_MAX - 10 && ntohs(node->packet.header.seq) <= 10) ) {
jb->highest_read_seq = node->packet.header.seq;
}
-
+
if (jb->type == SJB_TEXT || jb->type == SJB_AUDIO ||
(jb->read_init && htons(node->packet.header.seq) >= htons(jb->highest_read_seq) && (ntohl(node->packet.header.ts) > ntohl(jb->highest_read_ts)))) {
jb->complete_frames--;
} else if (!jb->read_init) {
jb->highest_read_ts = node->packet.header.ts;
}
-
+
if (!jb->read_init) jb->read_init = 1;
} else {
if (jb->type == SJB_VIDEO) {
switch_jb_reset(jb);
switch_goto_status(SWITCH_STATUS_RESTART, end);
case SWITCH_STATUS_NOTFOUND:
- default:
+ default:
if (jb->consec_miss_count > jb->frame_len) {
switch_jb_reset(jb);
jb_frame_inc(jb, 1);
}
}
}
-
+
if (node) {
status = SWITCH_STATUS_SUCCESS;
-
+
*packet = node->packet;
*len = node->len;
jb->last_len = *len;
} else {
seq = jb->last_target_seq;
}
-
+
packet->header.seq = seq;
packet->header.ts = ts;
}
switch_mutex_unlock(jb->mutex);
-
+
if (jb->complete_frames > jb->max_frame_len) {
thin_frames(jb, 8, 25);
}
return tolower(*(const unsigned char *)s1) - tolower(*(const unsigned char *)s2);
}
-static void *glue_malloc(size_t theSize)
-{
- return(malloc(theSize));
-}
+static void *glue_malloc(size_t theSize)
+{
+ return(malloc(theSize));
+}
-static void glue_free(void *thePtr)
-{
- free(thePtr);
-}
+static void glue_free(void *thePtr)
+{
+ free(thePtr);
+}
static void *(*cJSON_malloc)(size_t sz) = glue_malloc;
static void (*cJSON_free)(void *ptr) = glue_free;
}
n=sign*n*pow(10.0,(scale+subscale*signsubscale)); /* number = +/- number.fraction * 10^+/- exponent */
-
+
item->valuedouble=n;
item->valueint=(int)n;
item->type=cJSON_Number;
{
const char *ptr=str+1;char *ptr2;char *out;int len=0;unsigned uc,uc2;
if (*str!='\"') {ep=str;return 0;} /* not a string! */
-
+
while (*ptr!='\"' && *ptr && ++len) if (*ptr++ == '\\') ptr++; /* Skip escaped quotes. */
-
+
out=(char*)cJSON_malloc(len+1); /* This is how long we need for the string, roughly. */
if (!out) return 0;
-
+
ptr=str+1;ptr2=out;
while (*ptr!='\"' && *ptr)
{
}
len=4;if (uc<0x80) len=1;else if (uc<0x800) len=2;else if (uc<0x10000) len=3; ptr2+=len;
-
+
switch (len) {
case 4: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
case 3: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
static char *print_string_ptr(const char *str)
{
const char *ptr;char *ptr2,*out;int len=0;unsigned char token;
-
+
if (!str) return cJSON_strdup("");
ptr=str;while ((token=*ptr) && ++len) {if (strchr("\"\\\b\f\n\r\t",token)) len++; else if (token<32) len+=5;ptr++;}
-
+
out=(char*)cJSON_malloc(len+3);
if (!out) return 0;
size_t len=5;
cJSON *child=item->child;
int numentries=0,i=0,fail=0;
-
+
/* How many entries in the array? */
while (child) numentries++,child=child->next;
/* Allocate an array to hold the values for each */
if (ret) len+=strlen(ret)+2+(fmt?1:0); else fail=1;
child=child->next;
}
-
+
/* If we didn't fail, try to malloc the output string */
if (!fail) out=(char*)cJSON_malloc(len);
/* If that fails, we fail. */
cJSON_free(entries);
return 0;
}
-
+
/* Compose the output array. */
*out='[';
ptr=out+1;*ptr=0;
}
cJSON_free(entries);
*ptr++=']';*ptr++=0;
- return out;
+ return out;
}
/* Build an object from the text. */
{
cJSON *child;
if (*value!='{') {ep=value;return 0;} /* not an object! */
-
+
item->type=cJSON_Object;
value=skip(value+1);
if (*value=='}') return value+1; /* empty array. */
-
+
item->child=child=cJSON_New_Item();
if (!item->child) return 0;
value=skip(parse_string(child,skip(value)));
if (*value!=':') {ep=value;return 0;} /* fail! */
value=skip(parse_value(child,skip(value+1))); /* skip any spacing, get the value. */
if (!value) return 0;
-
+
while (*value==',')
{
cJSON *new_item;
value=skip(parse_value(child,skip(value+1))); /* skip any spacing, get the value. */
if (!value) return 0;
}
-
+
if (*value=='}') return value+1; /* end of array */
ep=value;return 0; /* malformed. */
}
if (str && ret) len+=strlen(ret)+strlen(str)+2+(fmt?2+depth:0); else fail=1;
child=child->next;
}
-
+
/* Try to allocate the output string */
if (!fail) out=(char*)cJSON_malloc(len);
if (!out) fail=1;
cJSON_free(names);cJSON_free(entries);
return 0;
}
-
+
/* Compose the output: */
*out='{';ptr=out+1;if (fmt)*ptr++='\n';*ptr=0;
for (i=0;i<numentries;i++)
if (fmt) *ptr++='\n';*ptr=0;
cJSON_free(names[i]);cJSON_free(entries[i]);
}
-
+
cJSON_free(names);cJSON_free(entries);
if (fmt) for (i=0;i<depth-1;i++) *ptr++='\t';
*ptr++='}';*ptr++=0;
- return out;
+ return out;
}
/* Get Array size/item / object item. */
SWITCH_DECLARE(cJSON *)cJSON_GetObjectItem(const cJSON *object,const char *string) {cJSON *c=object->child; while (c && cJSON_strcasecmp(c->string,string)) c=c->next; return c;}
-SWITCH_DECLARE(const char *)cJSON_GetObjectCstr(const cJSON *object, const char *string)
+SWITCH_DECLARE(const char *)cJSON_GetObjectCstr(const cJSON *object, const char *string)
{
cJSON *cj = cJSON_GetObjectItem(object, string);
static switch_limit_interface_t *get_backend(const char *backend) {
switch_limit_interface_t *limit = NULL;
-
+
if (!backend) {
return NULL;
}
-
+
if (!(limit = switch_loadable_module_get_limit_interface(backend))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Unable to locate limit backend: %s\n", backend);
}
-
+
return limit;
}
switch_channel_state_t state = switch_channel_get_state(channel);
const char *vval = switch_channel_get_variable(channel, LIMIT_IGNORE_TRANSFER_VARIABLE);
const char *backendlist = switch_channel_get_variable(channel, LIMIT_BACKEND_VARIABLE);
-
+
if (zstr(backendlist)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Unset limit backendlist!\n");
return SWITCH_STATUS_SUCCESS;
char *argv[6] = { 0 };
char *mydata = strdup(backendlist);
int x;
-
+
argc = switch_separate_string(mydata, ',', argv, (sizeof(argv) / sizeof(argv[0])));
for (x = 0; x < argc; x++) {
switch_limit_release(argv[x], session, NULL, NULL);
switch_core_event_hook_remove_state_change(session, limit_state_handler);
/* Remove limit_backend variable so we register another hook if limit is called again */
switch_channel_set_variable(channel, LIMIT_BACKEND_VARIABLE, NULL);
-
+
free(mydata);
}
-
+
return SWITCH_STATUS_SUCCESS;
}
switch_limit_interface_t *limit = NULL;
switch_channel_t *channel = NULL;
int status = SWITCH_STATUS_SUCCESS;
-
+
assert(session);
channel = switch_core_session_get_channel(session);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "incr called: %s_%s max:%d, interval:%d\n",
realm, resource, max, interval);
-
+
if ((status = limit->incr(session, realm, resource, max, interval)) == SWITCH_STATUS_SUCCESS) {
/* race condition? what if another leg is doing the same thing? */
const char *existing = switch_channel_get_variable(channel, LIMIT_BACKEND_VARIABLE);
switch_core_event_hook_add_state_change(session, limit_state_handler);
}
}
-
+
release_backend(limit);
-
+
end:
return status;
}
SWITCH_DECLARE(switch_status_t) switch_limit_release(const char *backend, switch_core_session_t *session, const char *realm, const char *resource) {
switch_limit_interface_t *limit = NULL;
int status = SWITCH_STATUS_SUCCESS;
-
+
/* locate impl, call appropriate func */
if (!(limit = get_backend(backend))) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Limit subsystem %s not found!\n", backend);
switch_goto_status(SWITCH_STATUS_GENERR, end);
}
-
+
status = limit->release(session, realm, resource);
-
+
end:
release_backend(limit);
return status;
SWITCH_DECLARE(int) switch_limit_usage(const char *backend, const char *realm, const char *resource, uint32_t *rcount) {
switch_limit_interface_t *limit = NULL;
int usage = 0;
-
+
/* locate impl, call appropriate func */
if (!(limit = get_backend(backend))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Limit subsystem %s not found!\n", backend);
goto end;
}
-
+
usage = limit->usage(realm, resource, rcount);
-
+
end:
release_backend(limit);
return usage;
SWITCH_DECLARE(switch_status_t) switch_limit_reset(const char *backend) {
switch_limit_interface_t *limit = NULL;
int status = SWITCH_STATUS_SUCCESS;
-
+
/* locate impl, call appropriate func */
if (!(limit = get_backend(backend))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Limit subsystem %s not found!\n", backend);
switch_goto_status(SWITCH_STATUS_GENERR, end);
}
-
+
status = limit->reset();
-
+
end:
release_backend(limit);
return status;
SWITCH_DECLARE(switch_status_t) switch_limit_interval_reset(const char *backend, const char *realm, const char *resource) {
switch_limit_interface_t *limit = NULL;
int status = SWITCH_STATUS_SUCCESS;
-
+
/* locate impl, call appropriate func */
if (!(limit = get_backend(backend))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Limit subsystem %s not found!\n", backend);
switch_goto_status(SWITCH_STATUS_GENERR, end);
}
-
+
if (!limit->interval_reset) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Limit subsystem %s does not implement interval_reset!\n", backend);
switch_goto_status(SWITCH_STATUS_GENERR, end);
}
status = limit->interval_reset(realm, resource);
-
+
end:
release_backend(limit);
return status;
SWITCH_DECLARE(char *) switch_limit_status(const char *backend) {
switch_limit_interface_t *limit = NULL;
char *status = NULL;
-
+
/* locate impl, call appropriate func */
if (!(limit = get_backend(backend))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Limit subsystem %s not found!\n", backend);
switch_goto_status(strdup("-ERR"), end);
}
-
+
status = limit->status();
-
+
end:
release_backend(limit);
return status;
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Seven Du <dujinfang@gmail.com>
*
const char *interface_name;
struct switch_codec_node_s *next;
} switch_codec_node_t;
-
+
struct switch_loadable_module {
char *key;
if (impl->decoded_bytes_per_packet > SWITCH_RECOMMENDED_BUFFER_SIZE) {
load_interface = 0;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
- "Failed to load codec interface %s from %s due to bytes per frame %d exceeding buffer size %d.\n",
+ "Failed to load codec interface %s from %s due to bytes per frame %d exceeding buffer size %d.\n",
ptr->interface_name,
key, impl->decoded_bytes_per_packet, SWITCH_RECOMMENDED_BUFFER_SIZE);
break;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
"Adding Codec %s %d %s %dhz %dms %dch %dbps\n",
impl->iananame, impl->ianacode,
- ptr->interface_name, impl->actual_samples_per_second,
+ ptr->interface_name, impl->actual_samples_per_second,
impl->microseconds_per_packet / 1000, impl->number_of_channels, impl->bits_per_second);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
/*
- const char *from;
+ const char *from;
const char *to;
const char *subject;
const char *body;
const char *type;
const char *hint;
- */
+ */
dest_proto = switch_event_get_header(message_event, "dest_proto");
switch_mutex_lock(loadable_modules.mutex);
for (hi = switch_core_hash_first(loadable_modules.chat_hash); hi; hi = switch_core_hash_next(&hi)) {
switch_core_hash_this(hi, &var, NULL, &val);
-
+
if ((ci = (switch_chat_interface_t *) val)) {
if (ci->chat_send && !strncasecmp(ci->interface_name, "GLOBAL_", 7)) {
status = ci->chat_send(message_event);
-
+
if (status == SWITCH_STATUS_SUCCESS) {
if (switch_true(switch_event_get_header(message_event, "final_delivery"))) {
- /* The event was handled by an extension in the chatplan,
- * so the event will be duplicated, modified and queued again,
+ /* The event was handled by an extension in the chatplan,
+ * so the event will be duplicated, modified and queued again,
* but it won't be processed by the chatplan again.
* So this copy of the event can be destroyed by the caller.
- */
+ */
do_skip = 1;
}
} else if (status == SWITCH_STATUS_BREAK) {
switch_safe_free(hi);
switch_mutex_unlock(loadable_modules.mutex);
}
-
+
if (!do_skip && !switch_stristr("GLOBAL", dest_proto)) {
if ((ci = switch_loadable_module_get_chat_interface(dest_proto)) && ci->chat_send) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Chat Thread Ended\n");
- return NULL;
+ return NULL;
}
}
switch_mutex_lock(chat_globals.mutex);
-
+
if (idx >= chat_globals.msg_queue_len) {
int i;
chat_globals.msg_queue_len = idx + 1;
switch_threadattr_create(&thd_attr, chat_globals.pool);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
- switch_thread_create(&chat_globals.msg_queue_thread[i],
- thd_attr,
- chat_thread_run,
- chat_globals.msg_queue[i],
+ switch_thread_create(&chat_globals.msg_queue_thread[i],
+ thd_attr,
+ chat_thread_run,
+ chat_globals.msg_queue[i],
chat_globals.pool);
}
}
event = *eventp;
*eventp = NULL;
-
+
if (chat_globals.running == 0) {
chat_process_event(&event);
return;
switch_mutex_lock(chat_globals.mutex);
idx = IDX;
- IDX++;
+ IDX++;
if (IDX >= chat_globals.msg_queue_len) IDX = 0;
switch_mutex_unlock(chat_globals.mutex);
-
+
chat_thread_start(idx);
if (switch_queue_trypush(chat_globals.msg_queue[idx], event) != SWITCH_STATUS_SUCCESS) {
}
expanded = switch_event_expand_headers(message, data);
-
+
status = cai->chat_application_function(message, expanded);
if (expanded != data) {
if (blocking) {
switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "blocking", "true");
}
-
+
if (body) {
switch_event_add_body(message_event, "%s", body);
}
} else {
abort();
- }
+ }
if (dest_proto) {
switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "dest_proto", dest_proto);
}
-
+
if (blocking) {
status = chat_process_event(&message_event);
} else {
}
return status;
-
+
}
continue;
}
global = switch_true(sglobal);
-
+
if (path && zstr(path)) {
path = SWITCH_GLOBAL_dirs.mod_dir;
}
chat_globals.running = 0;
- for (i = 0; i < chat_globals.msg_queue_len; i++) {
+ for (i = 0; i < chat_globals.msg_queue_len; i++) {
switch_queue_push(chat_globals.msg_queue[i], NULL);
}
}
switch_mutex_unlock(loadable_modules.mutex);
-
+
if (i) PROTECT_INTERFACE(i);
return i;
switch_codec_node_t *node, *head;
switch_mutex_lock(loadable_modules.mutex);
-
+
if ((head = switch_core_hash_find(loadable_modules.codec_hash, name))) {
if (modname) {
for (node = head; node; node = node->next) {
int i;
for(i = 0; i < arraylen; i++) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"DEBUG %d %s:%d %d\n", i, array[i]->iananame, array[i]->ianacode, array[i]->microseconds_per_packet / 1000);
}
for (i = 0; i < arraylen; i++) {
int this_ptime = array[i]->microseconds_per_packet / 1000;
-
+
if (!strcasecmp(array[i]->iananame, "ilbc")) {
this_ptime = 20;
}
for (hi = switch_core_hash_first(loadable_modules.codec_hash); hi; hi = switch_core_hash_next(&hi)) {
switch_core_hash_this(hi, NULL, NULL, &val);
head = (switch_codec_node_t *) val;
-
+
for (node = head; node; node = node->next) {
codec_interface = (switch_codec_interface_t *) node->ptr;
/* Look for the default ptime of the codec because it's the safest choice */
for (imp = codec_interface->implementations; imp; imp = imp->next) {
uint32_t default_ptime = switch_default_ptime(imp->iananame, imp->ianacode);
-
+
if (imp->microseconds_per_packet / 1000 == (int)default_ptime) {
array[i++] = imp;
goto found;
}
found:
-
+
if (i > arraylen) {
break;
}
-
+
}
switch_safe_free(hi);
}
cur = next;
}
-
+
if ((p = strchr(name, '.'))) {
*p++ = '\0';
*modname = name;
if (ointerval == 0) {
ointerval = switch_default_ptime(name, 0);
}
-
+
if (orate == 0) {
orate = switch_default_rate(name, 0);
}
if (ochannels == 0) {
ochannels = 1;
}
-
+
switch_copy_string(jbuf, prefs[j], sizeof(jbuf));
jname = switch_parse_codec_buf(jbuf, &jinterval, &jrate, &jbit, &jchannels, &jmodname, &jfmtp);
jchannels = 1;
}
- if (!strcasecmp(name, jname) && ointerval == jinterval && orate == jrate && ochannels == jchannels &&
+ if (!strcasecmp(name, jname) && ointerval == jinterval && orate == jrate && ochannels == jchannels &&
!strcasecmp(switch_str_nil(fmtp), switch_str_nil(jfmtp))) {
goto next_x;
}
for (imp = codec_interface->implementations; imp; imp = imp->next) {
uint32_t default_ptime = switch_default_ptime(imp->iananame, imp->ianacode);
uint32_t default_rate = switch_default_rate(imp->iananame, imp->ianacode);
-
+
if (imp->codec_type != SWITCH_CODEC_TYPE_VIDEO) {
uint32_t crate = !strcasecmp(imp->iananame, "g722") ? imp->samples_per_second : imp->actual_samples_per_second;
(interval && (uint32_t) (imp->microseconds_per_packet / 1000) != interval)) {
continue;
}
-
+
if (((!rate && crate != default_rate) || (rate && (uint32_t) imp->actual_samples_per_second != rate))) {
continue;
}
if (channels && imp->number_of_channels != channels) {
continue;
- }
+ }
}
array[i++] = imp;
cmd_used = (char *) cmd;
arg_used = (char *) arg;
}
-
+
if (!stream->param_event) {
switch_event_create(&stream->param_event, SWITCH_EVENT_API);
if (cmd_used != cmd) {
switch_safe_free(cmd_used);
}
-
+
if (arg_used != arg) {
switch_safe_free(arg_used);
}
function = cJSON_GetObjectItem(json, "command");
- if (function && function->valuestring
+ if (function && function->valuestring
&& cJSON_GetObjectItem(json, "data") && (json_api = switch_loadable_module_get_json_api_interface(function->valuestring)) != 0) {
if ((status = json_api->function(json, session, &json_reply)) != SWITCH_STATUS_SUCCESS) {
cJSON_AddItemToObject(json, "status", cJSON_CreateString("error"));
} else {
cJSON_AddItemToObject(json, "status", cJSON_CreateString("success"));
}
-
+
if (!json_reply) {
json_reply = cJSON_CreateNull();
}
} else {
cJSON_AddItemToObject(json, "response", json_reply);
}
-
+
UNPROTECT_INTERFACE(json_api);
} else {
status = SWITCH_STATUS_FALSE;
struct switch_stream_handle stream;
switch_event_t *param_event;
};
-
+
SWITCH_DECLARE(char *) switch_say_file_handle_get_variable(switch_say_file_handle_t *sh, const char *var)
{
char *ret = NULL;
}
return ret;
-
+
}
SWITCH_DECLARE(char *) switch_say_file_handle_get_path(switch_say_file_handle_t *sh)
SWITCH_DECLARE(char *) switch_say_file_handle_detach_path(switch_say_file_handle_t *sh)
{
char *path;
-
+
switch_assert(sh);
path = (char *) sh->stream.data;
sh->stream.data = NULL;
SWITCH_DECLARE(void) switch_say_file_handle_destroy(switch_say_file_handle_t **sh)
{
switch_assert(sh);
-
+
switch_safe_free((*sh)->stream.data);
switch_safe_free((*sh)->ext);
memset(*sh, 0, sizeof(**sh));
SWITCH_STANDARD_STREAM((*sh)->stream);
-
+
if (var_event) {
(*sh)->param_event = *var_event;
*var_event = NULL;
va_list ap;
va_start(ap, fmt);
-
+
if ((ret = switch_vsnprintf(buf, sizeof(buf), fmt, ap)) > 0) {
if (!sh->cnt++) {
sh->stream.write_function(&sh->stream, "file_string://%s.%s", buf, sh->ext);
}
}
-
+
va_end(ap);
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
#else
static const char *
#endif
-
-
-
-
+
+
+
+
COLORS[] =
{ SWITCH_SEQ_DEFAULT_COLOR, SWITCH_SEQ_FRED, SWITCH_SEQ_FRED, SWITCH_SEQ_FRED, SWITCH_SEQ_FMAGEN, SWITCH_SEQ_FCYAN, SWITCH_SEQ_FGREEN,
SWITCH_SEQ_FYELLOW };
bufpt = buf;
}
j = 0;
- if (needQuote)
+ if (needQuote)
bufpt[j++] = '\'';
for (i = 0; (ch = escarg[i]) != 0; i++) {
bufpt[j++] = (char) ch;
globals.ssl_ready = 0;
msrp_deinit_ssl();
-
+
return 0;
}
} else if (devlist && !dev && !trydev) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "No InternetGatewayDevice found and I am NOT going to try your printer because printers should not route to the internet, that would be DAFT\n");
}
-
+
if (dev) {
descXML = miniwget(dev->descURL, &descXMLsize);
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
* switch_odbc.c -- ODBC
err_str = strdup((char *)"SQL ERROR!");
}
}
-
+
if (err_str) {
if (!switch_stristr("already exists", err_str) && !switch_stristr("duplicate key name", err_str)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERR: [%s]\n[%s]\n", sql, switch_str_nil(err_str));
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
stmt = NULL; /* Make sure we don't try to free this handle again */
-
+
if (!err_cnt) {
return SWITCH_ODBC_SUCCESS;
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
bytes_per_frame += 882;
ms_per_frame += 10000;
- }
+ }
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Eliot Gable <egable@gmail.com>
* Seven Du <dujinfang@gmail.com>
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "No DB Connection\n");
goto done;
}
-
+
/* Try a non-blocking read on the connection to gobble up any EOF from a closed connection and mark the connection BAD if it is closed. */
PQconsumeInput(handle->con);
char *err_str;
struct pollfd fds[2] = { {0} };
int poll_res = 0;
-
+
if(!handle) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "**BUG** Null handle passed to switch_pgsql_next_result.\n");
return SWITCH_PGSQL_FAIL;
}
memset(res, 0, sizeof(switch_pgsql_result_t));
-
+
res->result = PQgetResult(handle->con);
if (res->result) {
*result_out = res;
free(er);
}
}
-
+
if (err_str) {
if (!switch_stristr("already exists", err_str) && !switch_stristr("duplicate key name", err_str)) {
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_ERROR, "ERR: [%s]\n[%s]\n", sql, switch_str_nil(err_str));
if (switch_pgsql_handle_exec_base(handle, sql, err) == SWITCH_PGSQL_FAIL) {
goto error;
}
-
+
if (switch_pgsql_next_result(handle, &result) == SWITCH_PGSQL_FAIL) {
err_cnt++;
err_str = switch_pgsql_handle_get_error(handle);
names[col] = malloc(len+1);
names[col][len] = '\0';
strncpy(names[col], tmp, len);
-
+
len = PQgetlength(result->result, row, col);
vals[col] = malloc(len+1);
vals[col][len] = '\0';
PQclear(tmp);
x++;
}
-
+
if (x) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "Flushing %d results\n", x);
}
* Copyright (c) 2009, Sangoma Technologies
* Moises Silva <moy@sangoma.com>
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
- *
+ *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
#include <errno.h>
#endif
-struct profile_timer
+struct profile_timer
{
/* bool, just used to retrieve the values for the first time and not calculate the percentage of idle time */
int valid_last_times;
};
#ifdef __linux__
-static int read_cpu_stats(switch_profile_timer_t *p,
- unsigned long long *user,
- unsigned long long *nice,
- unsigned long long *system,
- unsigned long long *idle,
- unsigned long long *iowait,
- unsigned long long *irq,
- unsigned long long *softirq,
+static int read_cpu_stats(switch_profile_timer_t *p,
+ unsigned long long *user,
+ unsigned long long *nice,
+ unsigned long long *system,
+ unsigned long long *idle,
+ unsigned long long *iowait,
+ unsigned long long *irq,
+ unsigned long long *softirq,
unsigned long long *steal)
{
// the output of proc should not change that often from one kernel to other
FILETIME kernelTime;
FILETIME userTime;
__int64 i64UserTime, i64KernelTime, i64IdleTime;
-
+
if (!GetSystemTimes(&idleTime, &kernelTime, &userTime)) {
return SWITCH_FALSE;
}
-
+
i64UserTime = (__int64)userTime.dwLowDateTime | ((__int64)userTime.dwHighDateTime << 32);
i64KernelTime = (__int64)kernelTime.dwLowDateTime | ((__int64)kernelTime.dwHighDateTime << 32);
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Michael Jerris <mike@jerris.com>
*
*
}
-SWITCH_DECLARE(void) switch_capture_regex(switch_regex_t *re, int match_count, const char *field_data,
+SWITCH_DECLARE(void) switch_capture_regex(switch_regex_t *re, int match_count, const char *field_data,
int *ovector, const char *var, switch_cap_callback_t callback, void *user_data)
-
+
{
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
switch_zmalloc(resampler, sizeof(*resampler));
if (!channels) channels = 1;
-
+
resampler->resampler = speex_resampler_init(channels, from_rate, to_rate, quality, &err);
if (!resampler->resampler) {
resampler->factor = (lto_rate / lfrom_rate);
resampler->rfactor = (lfrom_rate / lto_rate);
resampler->channels = channels;
-
+
//resampler->to_size = resample_buffer(to_rate, from_rate, (uint32_t) to_size);
resampler->to_size = switch_resample_calc_buffer_size(resampler->to_rate, resampler->from_rate, to_size) / 2;
resampler->to = realloc(resampler->to, resampler->to_size * sizeof(int16_t) * resampler->channels);
switch_assert(resampler->to);
}
-
+
resampler->to_len = resampler->to_size;
speex_resampler_process_interleaved_int(resampler->resampler, src, &srclen, resampler->to, &resampler->to_len);
return resampler->to_len;
sum_rnd += rnd2;
}
- s = (int16_t) ((int16_t) sum_rnd / (int) divisor);
+ s = (int16_t) ((int16_t) sum_rnd / (int) divisor);
for (j = 0; j < channels; j++) {
*data = s;
- data++;
+ data++;
}
}
for (i = 0; i < samples; i++) {
- for (j = 0; j < channels; j++) {
+ for (j = 0; j < channels; j++) {
data[k++] = data[i + samples];
}
}
-#else
+#else
uint32_t k = 0, len = samples * 2 * orig_channels;
int16_t *orig = NULL;
memcpy(orig, data, len);
for (i = 0; i < samples; i++) {
- for (j = 0; j < channels; j++) {
+ for (j = 0; j < channels; j++) {
data[k++] = orig[i];
}
}
-
+
free(orig);
#endif
} else {
chart = neg;
}
-
+
i = abs(vol) - 1;
-
+
switch_assert(i < 13);
newrate = chart[i];
} else {
chart = neg;
}
-
+
i = abs(vol) - 1;
-
+
switch_assert(i < 4);
newrate = chart[i];
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Marcel Barbulescu <marcelbarbulescu@gmail.com>
* Seven Du <dujinfang@gmail.com>
} ts_normalize_t;
struct switch_rtp {
- /*
+ /*
* Two sockets are needed because we might be transcoding protocol families
* (e.g. receive over IPv4 and send over IPv6). In case the protocol
* families are equal, sock_input == sock_output and only one socket is
switch_dtls_t *dtls;
switch_dtls_t *rtcp_dtls;
-
+
rtp_hdr_t last_rtp_hdr;
-
+
uint16_t seq;
uint32_t ssrc;
uint32_t remote_ssrc;
#endif
if (rtp_session->dtmf_data.in_digit_sanity && !--rtp_session->dtmf_data.in_digit_sanity) {
-
+
rtp_session->dtmf_data.last_digit = 0;
rtp_session->dtmf_data.in_digit_ts = 0;
rtp_session->dtmf_data.in_digit_queued = 0;
if (!bytes) return RESULT_CONTINUE;
- /* RFC2833 ... like all RFC RE: VoIP, guaranteed to drive you to insanity!
+ /* RFC2833 ... like all RFC RE: VoIP, guaranteed to drive you to insanity!
We know the real rules here, but if we enforce them, it's an interop nightmare so,
we put up with as much as we can so we don't have to deal with being punished for
doing it right. Nice guys finish last!
*/
-
+
if (bytes > rtp_header_len && !rtp_session->flags[SWITCH_RTP_FLAG_PROXY_MEDIA] &&
rtp_session->last_rtp_hdr.pt == rtp_session->recv_te) {
switch_size_t len = bytes - rtp_header_len;
if (rtp_session->jb && (rtp_session->rtp_bugs & RTP_BUG_FLUSH_JB_ON_DTMF)) {
switch_jb_reset(rtp_session->jb);
}
-
+
}
/* only set sanity if we do NOT ignore the packet */
rtp_session->dtmf_data.in_digit_sanity = 2000;
}
- if (rtp_session->dtmf_data.last_duration > duration &&
+ if (rtp_session->dtmf_data.last_duration > duration &&
rtp_session->dtmf_data.last_duration > 0xFC17 && ts == rtp_session->dtmf_data.in_digit_ts) {
rtp_session->dtmf_data.flip++;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "done digit=%c ts=%u start_ts=%u dur=%u ddur=%u\n",
dtmf.digit, ts, rtp_session->dtmf_data.in_digit_ts, duration, dtmf.duration);
#endif
-
+
if (!(rtp_session->rtp_bugs & RTP_BUG_IGNORE_DTMF_DURATION) && !rtp_session->dtmf_data.in_digit_queued) {
#ifdef DEBUG_2833
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Queuing digit %c:%d\n", dtmf.digit, dtmf.duration / 8);
/* Drat, they are sending audio still as well as DTMF ok fine..... *sigh* */
rtp_session->dtmf_data.in_interleaved = 1;
}
-
+
if (rtp_session->dtmf_data.in_interleaved || (rtp_session->rtp_bugs & RTP_BUG_IGNORE_DTMF_DURATION)) {
if (rtp_session->last_rtp_hdr.pt == rtp_session->recv_te) {
return RESULT_GOTO_RECVFROM;
}
ice->next_run = now + RTP_STUN_FREQ;
-
+
if (ice == &rtp_session->rtcp_ice && rtp_session->rtcp_sock_output) {
- sock_output = rtp_session->rtcp_sock_output;
+ sock_output = rtp_session->rtcp_sock_output;
}
if (!sock_output) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_CRIT, "%s send %s stun\n", rtp_session_name(rtp_session), rtp_type(rtp_session));
#endif
switch_socket_sendto(sock_output, ice->addr, 0, (void *) packet, &bytes);
-
+
ice->sending = 3;
// end:
int is_rtcp = ice == &rtp_session->rtcp_ice;
uint32_t elapsed;
switch_time_t ref_point;
-
+
//if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO]) {
// switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_WARNING, "WTF OK %s CALL\n", rtp_type(rtp_session));
//}
cpylen = sizeof(buf);
}
-
+
memcpy(buf, data, cpylen);
packet = switch_stun_packet_parse(buf, (uint32_t)cpylen);
if (!packet) {
if (!rtp_session->first_stun) {
rtp_session->first_stun = rtp_session->last_stun;
}
-
+
if (ice->last_ok) {
ref_point = ice->last_ok;
} else {
ref_point = rtp_session->first_stun;
- }
-
+ }
+
elapsed = (unsigned int) ((switch_micro_time_now() - ref_point) / 1000);
end_buf = buf + ((sizeof(buf) > packet->header.length) ? packet->header.length : sizeof(buf));
switch_stun_packet_first_attribute(packet, attr);
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG8, "%s STUN PACKET TYPE: %s\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG8, "%s STUN PACKET TYPE: %s\n",
rtp_type(rtp_session), switch_stun_value_to_name(SWITCH_STUN_TYPE_PACKET_TYPE, packet->header.type));
do {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG8, "|---: %s STUN ATTR %d %x %s\n", rtp_type(rtp_session), attr->type, attr->type,
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG8, "|------: %s\n", username);
}
break;
-
+
case SWITCH_STUN_ATTR_PRIORITY:
{
uint32_t priority = 0;
if (packet->header.type != SWITCH_STUN_BINDING_REQUEST && packet->header.type != SWITCH_STUN_BINDING_RESPONSE) {
goto end;
}
-
+
if ((ice->type & ICE_VANILLA)) {
char foo1[13] = "", foo2[13] = "";
if (!ok) ok = !memcmp(packet->header.id, ice->last_sent_id, 12);
} else {
ice->rready = 1;
}
-
+
if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO]) {
switch_core_session_video_reinit(rtp_session->session);
}
memcpy(foo1, packet->header.id, 12);
memcpy(foo2, ice->last_sent_id, 12);
- if (!ok && ice == &rtp_session->ice && rtp_session->rtcp_ice.ice_params && pri &&
+ if (!ok && ice == &rtp_session->ice && rtp_session->rtcp_ice.ice_params && pri &&
*pri == rtp_session->rtcp_ice.ice_params->cands[rtp_session->rtcp_ice.ice_params->chosen[1]][1].priority) {
ice = &rtp_session->rtcp_ice;
ok = 1;
char bufb[50];
char adj_port[6];
switch_channel_t *channel = NULL;
-
+
ice->missed_count++;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_WARNING, "missed %d\n", ice->missed_count);
ice = icep[j];
ok = 1;
-
+
if (j != IPR_RTP) {
break;
}
old = rtp_session->remote_port;
-
+
//tx_host = switch_get_addr(bufa, sizeof(bufa), rtp_session->from_addr);
old_host = switch_get_addr(bufb, sizeof(bufb), rtp_session->remote_addr);
-
+
host = ice->ice_params->cands[ice->ice_params->chosen[ice->proto]][ice->proto].con_addr;
port = ice->ice_params->cands[ice->ice_params->chosen[ice->proto]][ice->proto].con_port;
if (!host || !port) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_ERROR, "Error setting remote host!\n");
- return;
+ return;
}
-
+
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_INFO,
"%s ICE Auto Changing port from %s:%u to %s:%u\n", rtp_type(rtp_session), old_host, old, host, port);
-
+
if (channel) {
switch_channel_set_variable(channel, "remote_media_ip_reported", switch_channel_get_variable(channel, "remote_media_ip"));
switch_channel_set_variable(channel, "remote_media_ip", host);
}
rtp_session->auto_adj_used = 1;
-
+
switch_rtp_set_remote_address(rtp_session, host, port, 0, SWITCH_FALSE, &err);
- if (switch_sockaddr_info_get(&ice->addr, host, SWITCH_UNSPEC, port, 0, rtp_session->pool) != SWITCH_STATUS_SUCCESS ||
+ if (switch_sockaddr_info_get(&ice->addr, host, SWITCH_UNSPEC, port, 0, rtp_session->pool) != SWITCH_STATUS_SUCCESS ||
!ice->addr) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_ERROR, "Error setting remote host!\n");
return;
}
-
+
if ((rtp_session->rtp_bugs & RTP_BUG_ALWAYS_AUTO_ADJUST)) {
switch_rtp_set_flag(rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
} else {
switch_rtp_clear_flag(rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
}
-
+
}
}
}
}
if (ice->missed_count > 5 && !(ice->type & ICE_GOOGLE_JINGLE)) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_WARNING, "missed too many: %d, looking for new ICE dest.\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_WARNING, "missed too many: %d, looking for new ICE dest.\n",
ice->missed_count);
ice->rready = 0;
ok = 1;
//if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] || 1) {
// switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_WARNING, "WTF OK %s %d\n", rtp_type(rtp_session), ok);
//}
-
+
if (ok) {
const char *host = NULL, *host2 = NULL;
switch_port_t port = 0, port2 = 0;
port2 = switch_sockaddr_get_port(ice->addr);
cmp = switch_cmp_addr(from_addr, ice->addr);
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG4,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG4,
"STUN from %s:%d %s\n", host, port, cmp ? "EXPECTED" : "IGNORED");
if (cmp) {
if (!strcmp(ice->ice_params->cands[i][ice->proto].con_addr, host) &&
ice->ice_params->cands[i][ice->proto].cand_type &&
!strcmp(ice->ice_params->cands[i][ice->proto].cand_type, "relay")) {
-
+
if (elapsed < 1000) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_WARNING,
- "Skiping RELAY stun/%s/dtls port change from %s:%u to %s:%u\n", is_rtcp ? "rtcp" : "rtp",
+ "Skiping RELAY stun/%s/dtls port change from %s:%u to %s:%u\n", is_rtcp ? "rtcp" : "rtp",
host2, port2,
host, port);
-
+
goto end;
}
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_NOTICE,
- "Auto Changing %s stun/%s/dtls port from %s:%u to %s:%u\n", rtp_type(rtp_session), is_rtcp ? "rtcp" : "rtp",
+ "Auto Changing %s stun/%s/dtls port from %s:%u to %s:%u\n", rtp_type(rtp_session), is_rtcp ? "rtcp" : "rtp",
host2, port2,
host, port);
}
}
} else if (packet->header.type == SWITCH_STUN_BINDING_ERROR_RESPONSE) {
-
+
if (rtp_session->session) {
switch_core_session_message_t msg = { 0 };
msg.from = __FILE__;
msg.numeric_arg = packet->header.type;
msg.pointer_arg = packet;
msg.message_id = SWITCH_MESSAGE_INDICATE_STUN_ERROR;
- switch_core_session_receive_message(rtp_session->session, &msg);
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG,
+ switch_core_session_receive_message(rtp_session->session, &msg);
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG,
"STUN/ICE binding error received on %s channel\n", rtp_type(rtp_session));
}
{
switch_rtp_t *rtp_session = zrtp_stream_get_userdata(stream);
zrtp_session_info_t zrtp_session_info;
-
+
switch_channel_t *channel = switch_core_session_get_channel(rtp_session->session);
switch_event_t *fsevent = NULL;
const char *type;
}
if (!rtp_session->flags[SWITCH_RTP_FLAG_VIDEO]) {
-
+
if (rtp_session->session) {
switch_channel_t *channel = switch_core_session_get_channel(rtp_session->session);
rtp_session->ts += rtp_session->samples_per_interval;
if (rtp_session->ts <= rtp_session->last_write_ts && rtp_session->ts > 0) {
rtp_session->ts = rtp_session->last_write_ts + rtp_session->samples_per_interval;
- }
+ }
}
return m;
rtp_session->stats.inbound.flaws = 0;
}
- if (rtp_session->stats.inbound.recved > 0 &&
+ if (rtp_session->stats.inbound.recved > 0 &&
rtp_session->stats.inbound.flaws && (force || rtp_session->stats.inbound.last_flaw != rtp_session->stats.inbound.flaws)) {
int R;
if (diff < 1) diff = 1;
penalty = diff * 2;
-
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG3, "%s %s %d consecutive flaws, adding %d flaw penalty\n",
- rtp_session_name(rtp_session), rtp_type(rtp_session),
+
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG3, "%s %s %d consecutive flaws, adding %d flaw penalty\n",
+ rtp_session_name(rtp_session), rtp_type(rtp_session),
rtp_session->consecutive_flaws, penalty);
rtp_session->bad_stream++;
rtp_session->stats.inbound.flaws += penalty;
-
+
if (rtp_session->stats.inbound.error_log) {
rtp_session->stats.inbound.error_log->flaws += penalty;
rtp_session->stats.inbound.error_log->consecutive_flaws++;
}
R = (int)((double)((double)(rtp_session->stats.inbound.recved - rtp_session->stats.inbound.flaws) / (double)rtp_session->stats.inbound.recved) * 100.0);
-
+
if (R < 0 || R > 100) R = 100;
rtp_session->stats.inbound.R = R;
if (rtp_session->stats.inbound.last_processed_seq > 0 && seq > (int)(rtp_session->stats.inbound.last_processed_seq + 1)) {
int lost = (seq - rtp_session->stats.inbound.last_processed_seq - 1);
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "%s Got: %s seq %d but expected: %d lost: %d\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "%s Got: %s seq %d but expected: %d lost: %d\n",
rtp_session_name(rtp_session),
rtp_type(rtp_session),
seq,
} else {
rtp_session->stats.inbound.last_loss = 0;
}
-
+
rtp_session->stats.inbound.last_processed_seq = seq;
/* Burst and Packet Loss */
} else {
do_mos(rtp_session, SWITCH_FALSE);
}
-
+
if (rtp_session->stats.inbound.last_loss || rtp_session->bad_stream) {
if (rtp_session->session && (!rtp_session->stats.inbound.error_log || rtp_session->stats.inbound.error_log->stop)) {
struct error_period *error = switch_core_session_alloc(rtp_session->session, sizeof(*error));
rtp_session->recovering_stream = 0;
rtp_session->clean_stream++;
}
-
+
if ( diff_time < 0 ) {
diff_time = -diff_time;
}
-
+
rtp_session->stats.inbound.jitter_n++;
rtp_session->stats.inbound.jitter_add += diff_time;
} else {
cur_diff = 0;
}
-
+
rtp_session->stats.inbound.jitter_addsq += (cur_diff * cur_diff);
rtp_session->stats.inbound.last_proc_time = current_time;
}
rtp_session->stats.inbound.variance = (double)rtp_session->stats.inbound.jitter_addsq / (double)rtp_session->stats.inbound.jitter_n;
-
+
//printf("CHECK %d +%ld +%ld %f %f\n", rtp_session->timer.samplecount, diff_time, (diff_time * diff_time), rtp_session->stats.inbound.mean_interval, rtp_session->stats.inbound.variance);
-
+
ipdv = rtp_session->old_mean - rtp_session->stats.inbound.mean_interval;
if ( ipdv > IPDV_THRESHOLD ) { /* It shows Increasing Delays */
} else {
expected_pkt = stats->high_ext_seq_recv - stats->last_rpt_ext_seq;
}
-
+
pkt_lost = expected_pkt - stats->period_pkt_count;
stats->cum_lost=stats->cum_lost+pkt_lost;
if (expected_pkt > 0 && pkt_lost > 0) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "rtcp_stats_init: %s ssrc[%u] base_seq[%u]\n", rtp_type(rtp_session), stats->ssrc, stats->base_seq);
}
- if (rtp_session->flags[SWITCH_RTP_FLAG_ENABLE_RTCP] && (switch_core_media_codec_get_cap(rtp_session->session,
+ if (rtp_session->flags[SWITCH_RTP_FLAG_ENABLE_RTCP] && (switch_core_media_codec_get_cap(rtp_session->session,
SWITCH_MEDIA_TYPE_AUDIO, SWITCH_CODEC_FLAG_HAS_ADJ_BITRATE))) {
kalman_estimator_t *estimators[KALMAN_SYSTEM_MODELS];
cusum_kalman_detector_t *detectors[KALMAN_SYSTEM_MODELS];
break;
}
}
-
+
mantissa = (bps >> exp);
tmmbx->parts[0] = (uint8_t) ((exp << 2) + ((mantissa >> 15) & 0x03));
get_next_write_ts(rtp_session, 0);
rtp_session->send_msg.header.ts = htonl(rtp_session->ts);
-
+
switch_rtp_write_manual(rtp_session, (void *) data, 2, 0, rtp_session->cng_pt, ntohl(rtp_session->send_msg.header.ts), &frame_flags);
-
+
if (switch_rtp_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER)) {
rtp_session->last_write_samplecount = rtp_session->timer.samplecount;
}
}
//switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_ERROR, "TIME CHECK %d > %d\n", (int)((now - rtp_session->rtcp_last_sent) / 1000), rate);
-
+
if (!rtcp_ok && (!rtp_session->rtcp_last_sent || (int)((now - rtp_session->rtcp_last_sent) / 1000) > rate)) {
//switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_ERROR, "TIME UP\n");
rtcp_ok = 1;
}
-
+
if (rtcp_ok && using_ice(rtp_session)) {
if (rtp_session->flags[SWITCH_RTP_FLAG_RTCP_MUX]) {
if (!rtp_session->ice.rready) {
}
//switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_ERROR, "WTF %d %d %d %d\n", rate, rtp_session->rtcp_sent_packets, rtcp_ok, nack_ttl);
-
+
if (rtp_session->rtcp_sock_output && rtp_session->flags[SWITCH_RTP_FLAG_ENABLE_RTCP] && !rtp_session->flags[SWITCH_RTP_FLAG_RTCP_PASSTHRU] && rtcp_ok) {
switch_rtcp_numbers_t * stats = &rtp_session->stats.rtcp;
struct switch_rtcp_receiver_report *rr;
rtp_session->rtcp_last_sent = now;
rtp_session->rtcp_sent_packets++;
}
-
+
rtp_session->rtcp_send_msg.header.version = 2;
rtp_session->rtcp_send_msg.header.p = 0;
rtp_session->rtcp_send_msg.header.count = 1;
-
+
if (!rtp_session->stats.rtcp.sent_pkt_count) {
rtp_session->rtcp_send_msg.header.type = _RTCP_PT_RR; /* Receiver report */
rr=(struct switch_rtcp_receiver_report*) rtp_session->rtcp_send_msg.body;
p = (uint8_t *) (&rtp_session->rtcp_send_msg) + rtcp_bytes;
ext_hdr = (switch_rtcp_ext_hdr_t *) p;
-
+
ext_hdr->version = 2;
ext_hdr->p = 0;
ext_hdr->fmt = _RTCP_PSFB_PLI;
ext_hdr->pt = _RTCP_PT_PSFB;
-
+
ext_hdr->send_ssrc = htonl(rtp_session->ssrc);
ext_hdr->recv_ssrc = htonl(rtp_session->remote_ssrc);
-
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "Sending RTCP PLI %u %u\n",
+
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "Sending RTCP PLI %u %u\n",
rtp_session->ssrc, rtp_session->remote_ssrc);
-
- ext_hdr->length = htons((uint8_t)(sizeof(switch_rtcp_ext_hdr_t) / 4) - 1);
+
+ ext_hdr->length = htons((uint8_t)(sizeof(switch_rtcp_ext_hdr_t) / 4) - 1);
rtcp_bytes += sizeof(switch_rtcp_ext_hdr_t);
rtp_session->pli_count = 0;
}
uint32_t *nack;
p = (uint8_t *) (&rtp_session->rtcp_send_msg) + rtcp_bytes;
ext_hdr = (switch_rtcp_ext_hdr_t *) p;
-
+
ext_hdr->version = 2;
ext_hdr->p = 0;
ext_hdr->fmt = _RTCP_RTPFB_NACK;
nack = (uint32_t *) p;
*nack = cur_nack[n];
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "Sending RTCP NACK %u\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "Sending RTCP NACK %u\n",
ntohs(*nack & 0xFFFF));
-
+
rtcp_bytes += sizeof(switch_rtcp_ext_hdr_t) + sizeof(cur_nack[n]);
cur_nack[n] = 0;
}
nack_ttl = 0;
}
-
+
if (rtp_session->fir_count) {
switch_rtcp_ext_hdr_t *ext_hdr;
rtcp_fir_t *fir;
if (switch_rtp_test_flag(rtp_session, SWITCH_RTP_FLAG_OLD_FIR)) {
p = (uint8_t *) (&rtp_session->rtcp_send_msg) + rtcp_bytes;
ext_hdr = (switch_rtcp_ext_hdr_t *) p;
-
+
ext_hdr->version = 2;
ext_hdr->pt = _RTCP_PT_FIR;
rtcp_bytes += sizeof(switch_rtcp_ext_hdr_t);
p += sizeof(switch_rtcp_ext_hdr_t);
fir = (rtcp_fir_t *) p;
-
+
ext_hdr->version = 2;
ext_hdr->p = 0;
ext_hdr->fmt = _RTCP_PSFB_FIR;
ext_hdr->pt = _RTCP_PT_PSFB;
-
+
ext_hdr->send_ssrc = htonl(rtp_session->ssrc);
ext_hdr->recv_ssrc = 0;
-
+
fir->ssrc = htonl(rtp_session->remote_ssrc);
fir->seq = rtp_session->fir_seq;
fir->r1 = fir->r2 = fir->r3 = 0;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "Sending RTCP FIR SEQ %d\n", rtp_session->fir_seq);
rtp_session->fir_seq++;
-
- ext_hdr->length = htons((uint8_t)((sizeof(switch_rtcp_ext_hdr_t) + sizeof(rtcp_fir_t)) / 4) - 1);
+
+ ext_hdr->length = htons((uint8_t)((sizeof(switch_rtcp_ext_hdr_t) + sizeof(rtcp_fir_t)) / 4) - 1);
rtcp_bytes += sizeof(switch_rtcp_ext_hdr_t) + sizeof(rtcp_fir_t);
rtp_session->fir_count = 0;
}
tmmbx->ssrc = htonl(rtp_session->remote_ssrc);
calc_bw_exp(bps, 17, tmmbx);
-
+
ext_hdr->length = htons((uint8_t)((sizeof(switch_rtcp_ext_hdr_t) + sizeof(rtcp_tmmbx_t)) / 4) - 1);
- rtcp_bytes += sizeof(switch_rtcp_ext_hdr_t) + sizeof(rtcp_tmmbx_t);
+ rtcp_bytes += sizeof(switch_rtcp_ext_hdr_t) + sizeof(rtcp_tmmbx_t);
}
}
unit->type = _RTCP_SDES_NOTE;
snprintf((char *)unit->value, 80, "FreeSWITCH.org -- Come to ClueCon.com");
unit->length = strlen((char *)unit->value);
- sdes_bytes += sizeof(switch_rtcp_sdes_unit_t) + unit->length;
+ sdes_bytes += sizeof(switch_rtcp_sdes_unit_t) + unit->length;
sdes_bytes ++;//END
sdes_bytes += 4 - (sdes_bytes % 4);
-
+
sdes->length = htons((uint16_t)(sdes_bytes / 4) - 1);
rtcp_bytes += sdes_bytes;
if (rtp_session->flags[SWITCH_RTP_FLAG_SECURE_SEND]) {
int sbytes = (int) rtcp_bytes;
int stat = srtp_protect_rtcp(rtp_session->send_ctx[rtp_session->srtp_idx_rtcp], &rtp_session->rtcp_send_msg.header, &sbytes);
-
+
if (stat) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_ERROR, "Error: SRTP RTCP protection failed with code %d\n", stat);
goto end;
const char *old_host;
char bufb[50];
old_host = switch_get_addr(bufb, sizeof(bufb), rtp_session->rtcp_remote_addr);
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_CRIT, "%s SEND %s RTCP %s:%d %ld\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_CRIT, "%s SEND %s RTCP %s:%d %ld\n",
rtp_session_name(rtp_session),
rtp_type(rtp_session),
old_host,
rtcp_bytes);
}
#endif
- if (switch_socket_sendto(rtp_session->rtcp_sock_output, rtp_session->rtcp_remote_addr, 0, (void *)&rtp_session->rtcp_send_msg, &rtcp_bytes ) != SWITCH_STATUS_SUCCESS) {
+ if (switch_socket_sendto(rtp_session->rtcp_sock_output, rtp_session->rtcp_remote_addr, 0, (void *)&rtp_session->rtcp_send_msg, &rtcp_bytes ) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG,"RTCP packet not written\n");
} else {
rtp_session->stats.inbound.period_packet_count = 0;
}
}
-
+
if (rtp_session->ice.ice_user) {
if (ice_out(rtp_session, &rtp_session->ice) == SWITCH_STATUS_GENERR) {
ret = -1;
static switch_status_t enable_remote_rtcp_socket(switch_rtp_t *rtp_session, const char **err) {
-
+
switch_status_t status = SWITCH_STATUS_SUCCESS;
if (rtp_session->flags[SWITCH_RTP_FLAG_ENABLE_RTCP]) {
- if (switch_sockaddr_info_get(&rtp_session->rtcp_remote_addr, rtp_session->eff_remote_host_str, SWITCH_UNSPEC,
+ if (switch_sockaddr_info_get(&rtp_session->rtcp_remote_addr, rtp_session->eff_remote_host_str, SWITCH_UNSPEC,
rtp_session->remote_rtcp_port, 0, rtp_session->pool) != SWITCH_STATUS_SUCCESS || !rtp_session->rtcp_remote_addr) {
*err = "RTCP Remote Address Error!";
return SWITCH_STATUS_FALSE;
} else {
const char *host;
char bufa[50];
-
+
host = switch_get_addr(bufa, sizeof(bufa), rtp_session->rtcp_remote_addr);
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG,
"Setting RTCP remote addr to %s:%d %d\n", host, rtp_session->remote_rtcp_port, rtp_session->rtcp_remote_addr->family);
}
- if (rtp_session->rtcp_sock_input && switch_sockaddr_get_family(rtp_session->rtcp_remote_addr) ==
+ if (rtp_session->rtcp_sock_input && switch_sockaddr_get_family(rtp_session->rtcp_remote_addr) ==
switch_sockaddr_get_family(rtp_session->rtcp_local_addr)) {
rtp_session->rtcp_sock_output = rtp_session->rtcp_sock_input;
} else {
} else {
*err = "RTCP NOT ACTIVE!";
}
-
+
return status;
-
+
}
static switch_status_t enable_local_rtcp_socket(switch_rtp_t *rtp_session, const char **err) {
*err = "RTCP Local Address Error!";
goto done;
}
-
+
if (switch_socket_create(&rtcp_new_sock, switch_sockaddr_get_family(rtp_session->rtcp_local_addr), SOCK_DGRAM, 0, rtp_session->pool) != SWITCH_STATUS_SUCCESS) {
*err = "RTCP Socket Error!";
goto done;
}
-
+
if (switch_socket_opt_set(rtcp_new_sock, SWITCH_SO_REUSEADDR, 1) != SWITCH_STATUS_SUCCESS) {
*err = "RTCP Socket Error!";
goto done;
}
-
+
if (switch_socket_bind(rtcp_new_sock, rtp_session->rtcp_local_addr) != SWITCH_STATUS_SUCCESS) {
*err = "RTCP Bind Error!";
goto done;
}
-
+
if (switch_sockaddr_info_get(&rtp_session->rtcp_from_addr, switch_get_addr(bufa, sizeof(bufa), rtp_session->from_addr),
SWITCH_UNSPEC, switch_sockaddr_get_port(rtp_session->from_addr) + 1, 0, rtp_session->pool) != SWITCH_STATUS_SUCCESS) {
*err = "RTCP From Address Error!";
switch_socket_create_pollset(&rtp_session->rtcp_read_pollfd, rtp_session->rtcp_sock_input, SWITCH_POLLIN | SWITCH_POLLERR, rtp_session->pool);
done:
-
+
if (*err) {
-
+
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_ERROR, "Error allocating rtcp [%s]\n", *err);
status = SWITCH_STATUS_FALSE;
}
if (rtcp_new_sock) {
switch_socket_close(rtcp_new_sock);
}
-
+
if (rtcp_old_sock) {
switch_socket_close(rtcp_old_sock);
}
goto done;
}
-
+
if (rtp_session->sock_input) {
switch_rtp_kill_socket(rtp_session);
}
*err = "Multicast Socket interface Error";
goto done;
}
-
+
if (switch_mcast_join(new_sock, rtp_session->local_addr, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
*err = "Multicast Error";
goto done;
*err = "Mutlicast TTL set failed";
goto done;
}
-
+
}
}
status = SWITCH_STATUS_SUCCESS;
*err = "Success";
}
-
+
switch_rtp_set_flag(rtp_session, SWITCH_RTP_FLAG_IO);
done:
}
if (rtp_session->missed_count >= max) {
-
+
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_WARNING,
"new max missed packets(%d->%d) greater than current missed packets(%d). RTP will timeout.\n",
rtp_session->missed_count, max, rtp_session->missed_count);
rtp_session->rtcp_sent_packets = 0;
rtp_session->rtcp_last_sent = 0;
rtp_session->ice_adj = 0;
-
+
//switch_rtp_del_dtls(rtp_session, DTLS_TYPE_RTP|DTLS_TYPE_RTCP);
switch_rtp_set_flag(rtp_session, SWITCH_RTP_FLAG_PAUSE);
switch_rtp_set_flag(rtp_session, SWITCH_RTP_FLAG_MUTE);
rtcp_stats_init(rtp_session);
-
+
if (rtp_session->ice.ready) {
switch_rtp_reset_vb(rtp_session);
rtp_session->ice.ready = rtp_session->ice.rready = 0;
}
}
-SWITCH_DECLARE(switch_status_t) switch_rtp_udptl_mode(switch_rtp_t *rtp_session)
+SWITCH_DECLARE(switch_status_t) switch_rtp_udptl_mode(switch_rtp_t *rtp_session)
{
switch_socket_t *sock;
switch_socket_shutdown(rtp_session->rtcp_sock_input, SWITCH_SHUTDOWN_READWRITE);
}
- if (rtp_session->rtcp_sock_output && rtp_session->rtcp_sock_output != rtp_session->rtcp_sock_input &&
+ if (rtp_session->rtcp_sock_output && rtp_session->rtcp_sock_output != rtp_session->rtcp_sock_input &&
rtp_session->rtcp_sock_output != rtp_session->sock_input) {
switch_socket_shutdown(rtp_session->rtcp_sock_output, SWITCH_SHUTDOWN_READWRITE);
}
if ((sock = rtp_session->rtcp_sock_input)) {
rtp_session->rtcp_sock_input = NULL;
switch_socket_close(sock);
-
+
if (rtp_session->rtcp_sock_output && rtp_session->rtcp_sock_output != sock) {
if ((sock = rtp_session->rtcp_sock_output)) {
rtp_session->rtcp_sock_output = NULL;
switch_rtp_set_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA);
switch_socket_opt_set(rtp_session->sock_input, SWITCH_SO_NONBLOCK, FALSE);
switch_rtp_clear_flag(rtp_session, SWITCH_RTP_FLAG_NOBLOCK);
-
+
WRITE_DEC(rtp_session);
READ_DEC(rtp_session);
switch_rtp_clear_flag(rtp_session, SWITCH_RTP_FLAG_FLUSH);
switch_rtp_break(rtp_session);
-
+
return SWITCH_STATUS_SUCCESS;
}
if (rtp_session->flags[SWITCH_RTP_FLAG_ENABLE_RTCP]) {
- if (rtp_session->flags[SWITCH_RTP_FLAG_RTCP_MUX]) {
+ if (rtp_session->flags[SWITCH_RTP_FLAG_RTCP_MUX]) {
rtp_session->rtcp_remote_addr = rtp_session->remote_addr;
rtp_session->rtcp_sock_output = rtp_session->sock_output;
}/* else {
rtp_session->remote_rtcp_port = rtp_session->eff_remote_port + 1;
}
status = enable_remote_rtcp_socket(rtp_session, err);
-
+
if (rtp_session->rtcp_dtls) {
//switch_sockaddr_info_get(&rtp_session->rtcp_dtls->remote_addr, host, SWITCH_UNSPEC, port, 0, rtp_session->pool);
rtp_session->rtcp_dtls->remote_addr = rtp_session->rtcp_remote_addr;
uint8_t raw_key_data[cr_kslen*2] = { 0 };
unsigned char *local_key, *remote_key, *local_salt, *remote_salt;
unsigned char local_key_buf[cr_kslen] = {0}, remote_key_buf[cr_kslen] = {0};
-
+
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_INFO, "%s Fingerprint Verified.\n", rtp_type(rtp_session));
#ifdef HAVE_OPENSSL_DTLS_SRTP
#else
return -1;
#endif
-
+
if ((dtls->type & DTLS_TYPE_CLIENT)) {
local_key = raw_key_data;
remote_key = local_key + cr_keylen;
local_salt = remote_key + cr_keylen;
remote_salt = local_salt + cr_saltlen;
-
+
} else {
remote_key = raw_key_data;
local_key = remote_key + cr_keylen;
memcpy(remote_key_buf, remote_key, cr_keylen);
memcpy(remote_key_buf + cr_keylen, remote_salt, cr_saltlen);
-
+
if (dtls == rtp_session->rtcp_dtls && rtp_session->rtcp_dtls != rtp_session->dtls) {
switch_rtp_add_crypto_key(rtp_session, SWITCH_RTP_CRYPTO_SEND_RTCP, 0, AES_CM_128_HMAC_SHA1_80, local_key_buf, cr_kslen);
switch_rtp_add_crypto_key(rtp_session, SWITCH_RTP_CRYPTO_RECV_RTCP, 0, AES_CM_128_HMAC_SHA1_80, remote_key_buf, cr_kslen);
if (dtls->new_state) {
if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO]) {
switch_core_session_t *other_session;
-
+
if (rtp_session->session && switch_core_session_get_partner(rtp_session->session, &other_session) == SWITCH_STATUS_SUCCESS) {
switch_core_session_request_video_refresh(other_session);
switch_core_session_rwunlock(other_session);
switch_size_t bytes;
unsigned char buf[4096] = "";
int ready = rtp_session->ice.ice_user ? (rtp_session->ice.rready && rtp_session->ice.ready) : 1;
-
+
if (!dtls->bytes && !ready) {
return 0;
ret = SSL_get_error(dtls->ssl, ret);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_ERROR, "%s DTLS packet read err %d\n", rtp_type(rtp_session), ret);
}
-
+
if (dtls_states[dtls->state]) {
r = dtls_states[dtls->state](rtp_session, dtls);
}
}
-
+
return r;
}
if ((cert = SSL_get_peer_certificate(dtls->ssl))) {
switch_core_cert_extract_fingerprint(cert, dtls->remote_fp);
-
+
r = switch_core_cert_verify(dtls->remote_fp);
X509_free(cert);
if (rtp_session->dtls && rtp_session->dtls == rtp_session->rtcp_dtls) {
rtp_session->rtcp_dtls = NULL;
}
-
+
if (rtp_session->dtls) {
free_dtls(&rtp_session->dtls);
}
-
+
if (rtp_session->jb) {
switch_jb_reset(rtp_session->jb);
}
if (!switch_rtp_ready(rtp_session)) {
return SWITCH_STATUS_FALSE;
}
-
+
if (!((type & DTLS_TYPE_RTP) || (type & DTLS_TYPE_RTCP)) || !((type & DTLS_TYPE_CLIENT) || (type & DTLS_TYPE_SERVER))) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_CRIT, "INVALID TYPE!\n");
}
switch_rtp_del_dtls(rtp_session, type);
-
+
if ((type & DTLS_TYPE_RTP) && (type & DTLS_TYPE_RTCP)) {
kind = "RTP/RTCP";
} else if ((type & DTLS_TYPE_RTP)) {
kind = "RTCP";
}
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_INFO,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_INFO,
"Activate %s %s DTLS %s\n", kind, rtp_type(rtp_session), (type & DTLS_TYPE_SERVER) ? "server" : "client");
if (((type & DTLS_TYPE_RTP) && rtp_session->dtls) || ((type & DTLS_TYPE_RTCP) && rtp_session->rtcp_dtls)) {
}
dtls->ca = switch_core_sprintf(rtp_session->pool, "%s%sca-bundle.crt", SWITCH_GLOBAL_dirs.certs_dir, SWITCH_PATH_SEPARATOR);
-
+
dtls->ssl_ctx = SSL_CTX_new((type & DTLS_TYPE_SERVER) ? DTLSv1_server_method() : DTLSv1_client_method());
switch_assert(dtls->ssl_ctx);
SSL_CTX_set_mode(dtls->ssl_ctx, SSL_MODE_AUTO_RETRY);
//SSL_CTX_set_verify(dtls->ssl_ctx, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, NULL);
- SSL_CTX_set_verify(dtls->ssl_ctx, SSL_VERIFY_NONE, NULL);
+ SSL_CTX_set_verify(dtls->ssl_ctx, SSL_VERIFY_NONE, NULL);
SSL_CTX_set_cipher_list(dtls->ssl_ctx, "ECDH:!RC4:!SSLv3:RSA_WITH_AES_128_CBC_SHA");
//SSL_CTX_set_cipher_list(dtls->ssl_ctx, "ECDHE-RSA-AES256-GCM-SHA384");
//SSL_CTX_set_tlsext_use_srtp(dtls->ssl_ctx, "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32");
SSL_CTX_set_tlsext_use_srtp(dtls->ssl_ctx, "SRTP_AES128_CM_SHA1_80");
#endif
-
+
dtls->type = type;
dtls->read_bio = BIO_new(BIO_s_mem());
switch_assert(dtls->read_bio);
dtls->write_bio = BIO_new(BIO_s_mem());
switch_assert(dtls->write_bio);
-
+
BIO_set_mem_eof_return(dtls->read_bio, -1);
BIO_set_mem_eof_return(dtls->write_bio, -1);
return SWITCH_STATUS_FALSE;
}
- if (!zstr(dtls->ca) && switch_file_exists(dtls->ca, rtp_session->pool) == SWITCH_STATUS_SUCCESS
+ if (!zstr(dtls->ca) && switch_file_exists(dtls->ca, rtp_session->pool) == SWITCH_STATUS_SUCCESS
&& (ret = SSL_CTX_load_verify_locations(dtls->ssl_ctx, dtls->ca, NULL)) != 1) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_ERROR, "%s DTLS check chain cert failed [%d]\n",
rtp_type(rtp_session) ,
dtls->local_fp = local_fp;
dtls->remote_fp = remote_fp;
dtls->rtp_session = rtp_session;
-
+
switch_core_cert_expand_fingerprint(remote_fp, remote_fp->str);
if ((type & DTLS_TYPE_RTP)) {
rtp_session->flags[SWITCH_RTP_FLAG_VIDEO_BREAK] = 1;
switch_rtp_break(rtp_session);
-
+
return SWITCH_STATUS_SUCCESS;
-
+
}
srtp_policy_t *policy;
err_status_t stat;
switch_status_t status = SWITCH_STATUS_SUCCESS;
-
+
switch_channel_t *channel = switch_core_session_get_channel(rtp_session->session);
switch_event_t *fsevent = NULL;
int idx = 0;
case AES_CM_128_NULL_AUTH:
crypto_policy_set_aes_cm_128_null_auth(&policy->rtp);
crypto_policy_set_aes_cm_128_null_auth(&policy->rtcp);
-
+
if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
switch_channel_set_variable(channel, "rtp_has_crypto", "AES_CM_128_NULL_AUTH");
}
policy->key = (uint8_t *) crypto_key->key;
policy->next = NULL;
-
+
policy->window_size = 1024;
policy->allow_repeat_tx = 1;
}
if (status == SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_INFO, "Activating %s Secure %s RECV\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_INFO, "Activating %s Secure %s RECV\n",
rtp_type(rtp_session), idx ? "RTCP" : "RTP");
rtp_session->flags[SWITCH_RTP_FLAG_SECURE_RECV] = 1;
} else {
if ((status = switch_core_timer_init(&rtp_session->timer,
rtp_session->timer_name, ms_per_packet / 1000,
samples_per_interval, rtp_session->pool)) == SWITCH_STATUS_SUCCESS) {
-
+
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG,
"RE-Starting timer [%s] %d bytes per %dms\n", rtp_session->timer_name, samples_per_interval, ms_per_packet / 1000);
} else {
-
+
memset(&rtp_session->timer, 0, sizeof(rtp_session->timer));
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_ERROR,
"Problem RE-Starting timer [%s] %d bytes per %dms\n", rtp_session->timer_name, samples_per_interval, ms_per_packet / 1000);
return status;
}
-SWITCH_DECLARE(switch_status_t) switch_rtp_set_ssrc(switch_rtp_t *rtp_session, uint32_t ssrc)
+SWITCH_DECLARE(switch_status_t) switch_rtp_set_ssrc(switch_rtp_t *rtp_session, uint32_t ssrc)
{
rtp_session->ssrc = ssrc;
rtp_session->send_msg.header.ssrc = htonl(rtp_session->ssrc);
return SWITCH_STATUS_SUCCESS;
}
-SWITCH_DECLARE(switch_status_t) switch_rtp_set_remote_ssrc(switch_rtp_t *rtp_session, uint32_t ssrc)
+SWITCH_DECLARE(switch_status_t) switch_rtp_set_remote_ssrc(switch_rtp_t *rtp_session, uint32_t ssrc)
{
rtp_session->remote_ssrc = ssrc;
rtp_session->flags[SWITCH_RTP_FLAG_DETECT_SSRC] = 0;
rtp_session->recv_te = INVALID_PT;
rtp_session->cng_pt = INVALID_PT;
rtp_session->session = session;
-
+
switch_mutex_init(&rtp_session->flag_mutex, SWITCH_MUTEX_NESTED, pool);
switch_mutex_init(&rtp_session->read_mutex, SWITCH_MUTEX_NESTED, pool);
switch_mutex_init(&rtp_session->write_mutex, SWITCH_MUTEX_NESTED, pool);
rtp_session->stats.inbound.jitter_addsq = 0;
rtp_session->stats.inbound.min_variance = 0;
rtp_session->stats.inbound.max_variance = 0;
-
+
/* Burst and Packet Loss */
rtp_session->stats.inbound.lossrate = 0;
rtp_session->stats.inbound.burstrate = 0;
SWITCH_DECLARE(switch_status_t) switch_rtp_pause_jitter_buffer(switch_rtp_t *rtp_session, switch_bool_t pause)
{
-
+
if (!switch_rtp_ready(rtp_session) || !rtp_session->jb) {
return SWITCH_STATUS_FALSE;
}
}
rtp_session->pause_jb = pause ? 1 : 0;
-
+
return SWITCH_STATUS_SUCCESS;
}
SWITCH_DECLARE(switch_status_t) switch_rtp_deactivate_jitter_buffer(switch_rtp_t *rtp_session)
{
-
+
if (!switch_rtp_ready(rtp_session) || !rtp_session->jb) {
return SWITCH_STATUS_FALSE;
}
rtp_session->flags[SWITCH_RTP_FLAG_KILL_JB]++;
-
+
return SWITCH_STATUS_SUCCESS;
}
SWITCH_DECLARE(switch_status_t) switch_rtp_get_video_buffer_size(switch_rtp_t *rtp_session, uint32_t *min_frame_len, uint32_t *max_frame_len, uint32_t *cur_frame_len, uint32_t *highest_frame_len)
{
-
+
if (rtp_session->vb) {
return switch_jb_get_frames(rtp_session->vb, min_frame_len, max_frame_len, cur_frame_len, highest_frame_len);
}
if (!max_frames) {
max_frames = rtp_session->last_max_vb_frames;
}
-
+
if (!max_frames || frames >= max_frames) {
max_frames = frames * 10;
}
rtp_session->last_max_vb_frames = max_frames;
-
+
if (!rtp_session->vb) {
switch_jb_create(&rtp_session->vb, rtp_session->flags[SWITCH_RTP_FLAG_TEXT] ? SJB_TEXT : SJB_VIDEO, frames, max_frames, rtp_session->pool);
switch_jb_set_session(rtp_session->vb, rtp_session->session);
switch_core_session_request_video_refresh(rtp_session->session);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "Setting video buffer %u Frames.\n", frames);
-
+
return SWITCH_STATUS_SUCCESS;
}
if (name) x = atoi(name);
if (x < 0) x = 0;
-
+
if (rtp_session->jb) {
switch_jb_debug_level(rtp_session->jb, x);
} else if (rtp_session->vb) {
return SWITCH_STATUS_SUCCESS;
}
-SWITCH_DECLARE(switch_status_t) switch_rtp_activate_jitter_buffer(switch_rtp_t *rtp_session,
- uint32_t queue_frames,
- uint32_t max_queue_frames,
- uint32_t samples_per_packet,
+SWITCH_DECLARE(switch_status_t) switch_rtp_activate_jitter_buffer(switch_rtp_t *rtp_session,
+ uint32_t queue_frames,
+ uint32_t max_queue_frames,
+ uint32_t samples_per_packet,
uint32_t samples_per_second)
{
switch_status_t status = SWITCH_STATUS_FALSE;
}
-
+
return status;
}
if (!rtp_session->ms_per_packet) {
return SWITCH_STATUS_FALSE;
}
-
+
rtp_session->flags[SWITCH_RTP_FLAG_ENABLE_RTCP] = 1;
if (!(rtp_session->remote_rtcp_port = remote_port)) {
rtp_session->flags[SWITCH_RTP_FLAG_RTCP_MUX]++;
}
-
+
if (send_rate == -1) {
-
+
rtp_session->flags[SWITCH_RTP_FLAG_RTCP_PASSTHRU] = 1;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG, "RTCP passthru enabled. Remote Port: %d\n", rtp_session->remote_rtcp_port);
} else {
if (rtp_session->flags[SWITCH_RTP_FLAG_RTCP_MUX]) {
- if (switch_sockaddr_info_get(&rtp_session->rtcp_remote_addr, rtp_session->eff_remote_host_str, SWITCH_UNSPEC,
+ if (switch_sockaddr_info_get(&rtp_session->rtcp_remote_addr, rtp_session->eff_remote_host_str, SWITCH_UNSPEC,
rtp_session->remote_rtcp_port, 0, rtp_session->pool) != SWITCH_STATUS_SUCCESS || !rtp_session->rtcp_remote_addr) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_ERROR, "RTCP MUX Remote Address Error!");
return SWITCH_STATUS_FALSE;
rtp_session->rtcp_sock_output = rtp_session->sock_output;
rtp_session->rtcp_recv_msg_p = (rtcp_msg_t *) &rtp_session->recv_msg;
-
+
return SWITCH_STATUS_SUCCESS;
//return enable_remote_rtcp_socket(rtp_session, &err);
}
-SWITCH_DECLARE(switch_status_t) switch_rtp_activate_ice(switch_rtp_t *rtp_session, char *login, char *rlogin,
- const char *password, const char *rpassword, ice_proto_t proto,
+SWITCH_DECLARE(switch_status_t) switch_rtp_activate_ice(switch_rtp_t *rtp_session, char *login, char *rlogin,
+ const char *password, const char *rpassword, ice_proto_t proto,
switch_core_media_ice_type_t type, ice_t *ice_params)
{
char ice_user[80];
char *host = NULL;
switch_port_t port = 0;
char bufc[50];
-
+
switch_mutex_lock(rtp_session->ice_mutex);
if (proto == IPR_RTP) {
- ice = &rtp_session->ice;
+ ice = &rtp_session->ice;
rtp_session->flags[SWITCH_RTP_FLAG_PAUSE] = 0;
rtp_session->flags[SWITCH_RTP_FLAG_MUTE] = 0;
} else {
}
ice->proto = proto;
-
+
if ((type & ICE_VANILLA)) {
switch_snprintf(ice_user, sizeof(ice_user), "%s:%s", login, rlogin);
switch_snprintf(user_ice, sizeof(user_ice), "%s:%s", rlogin, login);
if (rpassword) {
ice->rpass = switch_core_strdup(rtp_session->pool, rpassword);
}
-
+
if ((ice->type & ICE_VANILLA) && ice->ice_params) {
host = ice->ice_params->cands[ice->ice_params->chosen[ice->proto]][ice->proto].con_addr;
port = ice->ice_params->cands[ice->ice_params->chosen[ice->proto]][ice->proto].con_port;
port = switch_sockaddr_get_port(ice->addr);
}
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_NOTICE, "Activating %s %s ICE: %s %s:%d\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_NOTICE, "Activating %s %s ICE: %s %s:%d\n",
proto == IPR_RTP ? "RTP" : "RTCP", rtp_type(rtp_session), ice_user, host, port);
if (rtp_session->sock_output && rtp_session->sock_output != rtp_session->sock_input) {
switch_socket_shutdown(rtp_session->sock_output, SWITCH_SHUTDOWN_READWRITE);
}
-
+
if (rtp_session->flags[SWITCH_RTP_FLAG_ENABLE_RTCP]) {
if (rtp_session->rtcp_sock_input) {
ping_socket(rtp_session);
if (!rtp_session) {
return SWITCH_STATUS_FALSE;
}
-
+
if (rtp_session->flags[SWITCH_RTP_FLAG_VAD]) {
switch_channel_t *channel = switch_core_session_get_channel(rtp_session->vad_data.session);
return;
}
-SWITCH_DECLARE(void) switch_rtp_set_interdigit_delay(switch_rtp_t *rtp_session, uint32_t delay)
+SWITCH_DECLARE(void) switch_rtp_set_interdigit_delay(switch_rtp_t *rtp_session, uint32_t delay)
{
rtp_session->interdigit_delay = delay;
}
rtp_session->rtcp_autoadj_threshold = 1;
rtp_session->rtcp_autoadj_tally = 0;
-
+
rtp_flush_read_buffer(rtp_session, SWITCH_RTP_FLUSH_ONCE);
} else if (i == SWITCH_RTP_FLAG_NOBLOCK && rtp_session->sock_input) {
switch_socket_opt_set(rtp_session->sock_input, SWITCH_SO_NONBLOCK, TRUE);
rtp_session->rtcp_autoadj_window = 20;
rtp_session->rtcp_autoadj_threshold = 1;
rtp_session->rtcp_autoadj_tally = 0;
-
+
if (rtp_session->session) {
switch_channel_t *channel = switch_core_session_get_channel(rtp_session->session);
const char *x = switch_channel_get_variable(channel, "rtp_auto_adjust_threshold");
static void set_dtmf_delay(switch_rtp_t *rtp_session, uint32_t ms, uint32_t max_ms)
{
int upsamp, max_upsamp;
-
+
if (!max_ms) max_ms = ms;
rtp_session->last_write_ts += upsamp;
}
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG, "Queue digit delay of %dms\n", ms);
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG, "Queue digit delay of %dms\n", ms);
}
static void do_2833(switch_rtp_t *rtp_session)
if (loops != 1) {
rtp_session->sending_dtmf = 0;
rtp_session->need_mark = 1;
-
+
if (rtp_session->flags[SWITCH_RTP_FLAG_USE_TIMER]) {
rtp_session->last_write_samplecount = rtp_session->timer.samplecount;
}
rtp_session->queue_delay = 0;
}
}
-
+
if (rtp_session->queue_delay) {
return;
}
free(rdigit);
return;
}
-
-
+
+
memset(rtp_session->dtmf_data.out_digit_packet, 0, 4);
rtp_session->dtmf_data.out_digit_sofar = samples;
rtp_session->dtmf_data.out_digit_sub_sofar = samples;
rtp_session->rtp_bugs & RTP_BUG_CISCO_SKIP_MARK_BIT_2833 ? 0 : 1,
rtp_session->te, rtp_session->dtmf_data.timestamp_dtmf, &flags);
-
+
rtp_session->stats.outbound.raw_bytes += wrote;
rtp_session->stats.outbound.dtmf_packet_count++;
-
+
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG, "Send start packet for [%c] ts=%u dur=%d/%d/%d seq=%d lw=%u\n",
rtp_session->dtmf_data.out_digit,
rtp_session->dtmf_data.timestamp_dtmf,
switch_size_t bytes;
uint32_t flushed = 0;
switch_size_t bytes_out = 0;
-
+
if (!switch_rtp_ready(rtp_session)) {
return 0;
}
if (!force) {
if ((rtp_session->jb && !rtp_session->pause_jb && jb_valid(rtp_session)) ||
- rtp_session->flags[SWITCH_RTP_FLAG_PROXY_MEDIA] ||
+ rtp_session->flags[SWITCH_RTP_FLAG_PROXY_MEDIA] ||
rtp_session->flags[SWITCH_RTP_FLAG_UDPTL] ||
rtp_session->flags[SWITCH_RTP_FLAG_DTMF_ON]
) {
return bytes_in;
}
}
-
+
READ_INC(rtp_session);
if (switch_rtp_ready(rtp_session) ) {
bytes_out = bytes_in;
goto end;
}
-
+
if (rtp_session->flags[SWITCH_RTP_FLAG_DEBUG_RTP_READ]) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session),
SWITCH_LOG_CONSOLE, "%s FLUSH\n",
if (switch_rtp_ready(rtp_session)) {
bytes = sizeof(rtp_msg_t);
switch_socket_recvfrom(rtp_session->from_addr, rtp_session->sock_input, 0, (void *) &rtp_session->recv_msg, &bytes);
-
+
if (bytes) {
int do_cng = 0;
switch_rtp_clear_flag(rtp_session, SWITCH_RTP_FLAG_NOBLOCK);
switch_socket_opt_set(rtp_session->sock_input, SWITCH_SO_NONBLOCK, FALSE);
}
-
+
if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] && rtp_session->session) {
//int type = 1; // sum flags: 1 encoder; 2; decoder
}
end:
-
+
READ_DEC(rtp_session);
return bytes_out;
switch_mutex_lock(rtp_session->flag_mutex);
- for (pmap = *rtp_session->pmaps; pmap && pmap->allocated; pmap = pmap->next) {
+ for (pmap = *rtp_session->pmaps; pmap && pmap->allocated; pmap = pmap->next) {
if (!pmap->negotiated) {
continue;
}
switch_mutex_lock(rtp_session->flag_mutex);
- for (pmap = *rtp_session->pmaps; pmap && pmap->allocated; pmap = pmap->next) {
+ for (pmap = *rtp_session->pmaps; pmap && pmap->allocated; pmap = pmap->next) {
if (pmap->negotiated) {
r = pmap->pt;
break;
#define return_cng_frame() do_cng = 1; goto timer_check
-static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t *bytes, switch_frame_flag_t *flags,
+static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t *bytes, switch_frame_flag_t *flags,
payload_map_t **pmapP, switch_status_t poll_status, switch_bool_t return_jb_packet)
{
switch_status_t status = SWITCH_STATUS_FALSE;
switch_size_t xcheck_jitter = 0;
int tries = 0;
int block = 0;
-
+
switch_assert(bytes);
more:
*bytes = 0;
return SWITCH_STATUS_BREAK;
}
-
+
if (block) {
int to = 20000;
int fdr = 0;
to = rtp_session->timer.interval * 1000;
}
}
-
+
poll_status = switch_poll(rtp_session->read_pollfd, 1, &fdr, to);
-
+
if (rtp_session->flags[SWITCH_RTP_FLAG_USE_TIMER] && rtp_session->timer.interval) {
switch_core_timer_sync(&rtp_session->timer);
}
block = 0;
}
-
+
*bytes = sizeof(rtp_msg_t);
sync = 0;
if (*bytes) {
b = (unsigned char *) &rtp_session->recv_msg;
-
+
/* version 2 probably rtp, zrtp cookie present means zrtp */
rtp_session->has_rtp = (rtp_session->recv_msg.header.version == 2 || ntohl(*(int *)(b+4)) == ZRTP_MAGIC_COOKIE);
rtp_session->has_ice = 0;
break;
default:
- if (rtp_session->rtcp_recv_msg_p->header.version == 2 &&
+ if (rtp_session->rtcp_recv_msg_p->header.version == 2 &&
rtp_session->rtcp_recv_msg_p->header.type > 199 && rtp_session->rtcp_recv_msg_p->header.type < 208) {
rtp_session->has_rtcp = 1;
rtp_session->has_rtp = 0;
rtp_session->has_ice = 0;
}
break;
- }
+ }
}
}
if (rtp_session->has_rtp || rtp_session->flags[SWITCH_RTP_FLAG_UDPTL]) {
rtp_session->missed_count = 0;
- switch_cp_addr(rtp_session->rtp_from_addr, rtp_session->from_addr);
+ switch_cp_addr(rtp_session->rtp_from_addr, rtp_session->from_addr);
}
-
+
if (rtp_session->has_rtp) {
rtp_session->last_rtp_hdr = rtp_session->recv_msg.header;
-
+
if (bytes && !rtp_session->flags[SWITCH_RTP_FLAG_PROXY_MEDIA] && !rtp_session->flags[SWITCH_RTP_FLAG_UDPTL] &&
- rtp_session->last_rtp_hdr.pt != 13 &&
- rtp_session->last_rtp_hdr.pt != rtp_session->recv_te &&
+ rtp_session->last_rtp_hdr.pt != 13 &&
+ rtp_session->last_rtp_hdr.pt != rtp_session->recv_te &&
rtp_session->last_rtp_hdr.pt != rtp_session->cng_pt) {
int accept_packet = 1;
-
+
if (rtp_session->pmaps && *rtp_session->pmaps) {
payload_map_t *pmap;
accept_packet = 0;
switch_mutex_lock(rtp_session->flag_mutex);
- for (pmap = *rtp_session->pmaps; pmap && pmap->allocated; pmap = pmap->next) {
-
+ for (pmap = *rtp_session->pmaps; pmap && pmap->allocated; pmap = pmap->next) {
+
if (!pmap->negotiated) {
continue;
}
}
switch_mutex_unlock(rtp_session->flag_mutex);
}
-
+
if (!accept_packet && !(rtp_session->rtp_bugs & RTP_BUG_ACCEPT_ANY_PAYLOAD) && !(rtp_session->rtp_bugs & RTP_BUG_ACCEPT_ANY_PACKETS)) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1,
- "Invalid Packet SEQ: %d TS: %d PT:%d ignored\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1,
+ "Invalid Packet SEQ: %d TS: %d PT:%d ignored\n",
ntohs(rtp_session->recv_msg.header.seq), ntohl(rtp_session->last_rtp_hdr.ts), rtp_session->last_rtp_hdr.pt);
*bytes = 0;
}
}
-
+
if (rtp_session->flags[SWITCH_RTP_FLAG_DETECT_SSRC]) {
//if (rtp_session->remote_ssrc != rtp_session->stats.rtcp.peer_ssrc && rtp_session->stats.rtcp.peer_ssrc) {
// rtp_session->remote_ssrc = rtp_session->stats.rtcp.peer_ssrc;
//}
-
+
if (rtp_session->remote_ssrc != rtp_session->last_rtp_hdr.ssrc && rtp_session->last_rtp_hdr.ssrc) {
rtp_session->remote_ssrc = ntohl(rtp_session->last_rtp_hdr.ssrc);
}
//}
return SWITCH_STATUS_GENERR;
}
-
+
if (rtp_session->flags[SWITCH_RTP_FLAG_UDPTL]) {
goto udptl;
}
// switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_WARNING, "WTF BYTES %ld b=%d\n", *bytes, *b);
//}
-
+
if (rtp_session->has_ice) {
if (rtp_session->ice.ice_user) {
handle_ice(rtp_session, &rtp_session->ice, (void *) &rtp_session->recv_msg, *bytes);
}
if (rtp_session->dtls) {
-
+
if (rtp_session->rtcp_dtls && rtp_session->rtcp_dtls != rtp_session->dtls) {
rtp_session->rtcp_dtls->bytes = 0;
rtp_session->rtcp_dtls->data = NULL;
}
}
- if (status == SWITCH_STATUS_SUCCESS && *bytes) {
- if (rtp_session->flags[SWITCH_RTP_FLAG_RTCP_MUX]) {
+ if (status == SWITCH_STATUS_SUCCESS && *bytes) {
+ if (rtp_session->flags[SWITCH_RTP_FLAG_RTCP_MUX]) {
*flags &= ~SFF_RTCP;
if (rtp_session->has_rtcp) {
*flags |= SFF_RTCP;
if (rtp_session->flags[SWITCH_RTP_FLAG_SECURE_RECV]) {
int sbytes = (int) *bytes;
err_status_t stat = 0;
-
-
+
+
if ((stat = srtp_unprotect_rtcp(rtp_session->recv_ctx[rtp_session->srtp_idx_rtcp], &rtp_session->rtcp_recv_msg_p->header, &sbytes))) {
//++rtp_session->srtp_errs[rtp_session->srtp_idx_rtp]++;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_ERROR, "RTCP UNPROTECT ERR\n");
} else {
//rtp_session->srtp_errs[rtp_session->srtp_idx_rtp] = 0;
}
-
+
*bytes = sbytes;
}
#endif
}
}
-
+
if ((*bytes && (!rtp_write_ready(rtp_session, *bytes, __LINE__) || !rtp_session->has_rtp || rtp_session->has_rtcp)) || sync) {
rtp_session->hot_hits = 0;
my_host, switch_sockaddr_get_port(rtp_session->local_addr),
old_host, rtp_session->remote_port,
tx_host, switch_sockaddr_get_port(rtp_session->rtp_from_addr),
- rtp_session->last_rtp_hdr.pt, ntohl(rtp_session->last_rtp_hdr.ts), ntohs(rtp_session->last_rtp_hdr.seq),
+ rtp_session->last_rtp_hdr.pt, ntohl(rtp_session->last_rtp_hdr.ts), ntohs(rtp_session->last_rtp_hdr.seq),
rtp_session->last_rtp_hdr.m);
}
{
int r = (rand() % 10000) + 1;
if (r <= 200) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_ALERT,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_ALERT,
"Simulate dropped packet ......... ts: %u seq: %u\n", ntohl(rtp_session->last_rtp_hdr.ts), ntohs(rtp_session->last_rtp_hdr.seq));
*bytes = 0;
}
uint16_t seq = ntohs((uint16_t) rtp_session->last_rtp_hdr.seq);
ts = ntohl(rtp_session->last_rtp_hdr.ts);
-#ifdef DEBUG_MISSED_SEQ
+#ifdef DEBUG_MISSED_SEQ
if (rtp_session->last_seq && rtp_session->last_seq+1 != seq) {
//2012-11-28 18:33:11.799070 [ERR] switch_rtp.c:2883 Missed -65536 RTP frames from sequence [65536] to [-1] (missed). Time since last read [20021]
switch_size_t flushed_packets_diff = rtp_session->stats.inbound.flush_packet_count - rtp_session->last_flush_packet_count;
rtp_session->last_seq+1, (flushed_packets_diff == 1) ? " (flushed by FS)" : " (missed)",
rtp_session->last_read_time ? now-rtp_session->last_read_time : 0);
} else { /* We missed multiple packets */
- if (flushed_packets_diff == 0) {
+ if (flushed_packets_diff == 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"Missed %ld RTP frames from sequence [%d] to [%d] (missed). Time since last read [%ld]\n",
num_missed, rtp_session->last_seq+1, seq-1,
}
#endif
rtp_session->last_seq = seq;
-
+
rtp_session->last_flush_packet_count = rtp_session->stats.inbound.flush_packet_count;
-
-
+
+
if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] && now - rtp_session->last_read_time > 5000000) {
switch_rtp_video_refresh(rtp_session);
}
}
- if (!rtp_session->flags[SWITCH_RTP_FLAG_PROXY_MEDIA] && !rtp_session->flags[SWITCH_RTP_FLAG_UDPTL] && !rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] &&
- *bytes && rtp_session->last_rtp_hdr.pt != rtp_session->recv_te &&
+ if (!rtp_session->flags[SWITCH_RTP_FLAG_PROXY_MEDIA] && !rtp_session->flags[SWITCH_RTP_FLAG_UDPTL] && !rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] &&
+ *bytes && rtp_session->last_rtp_hdr.pt != rtp_session->recv_te &&
ts && !rtp_session->jb && !rtp_session->pause_jb && jb_valid(rtp_session) && ts == rtp_session->last_cng_ts) {
/* we already sent this frame..... */
*bytes = 0;
#ifdef ENABLE_ZRTP
/* ZRTP Recv */
if (zrtp_on) {
-
+
unsigned int sbytes = (int) *bytes;
zrtp_status_t stat = 0;
-
+
stat = zrtp_process_srtp(rtp_session->zrtp_stream, (void *) &rtp_session->recv_msg, &sbytes);
-
+
switch (stat) {
case zrtp_status_ok:
*bytes = sbytes;
}
}
#endif
-
+
#ifdef ENABLE_SRTP
- if (rtp_session->flags[SWITCH_RTP_FLAG_SECURE_RECV] && rtp_session->has_rtp &&
- (check_recv_payload(rtp_session) ||
- rtp_session->last_rtp_hdr.pt == rtp_session->recv_te ||
+ if (rtp_session->flags[SWITCH_RTP_FLAG_SECURE_RECV] && rtp_session->has_rtp &&
+ (check_recv_payload(rtp_session) ||
+ rtp_session->last_rtp_hdr.pt == rtp_session->recv_te ||
rtp_session->last_rtp_hdr.pt == rtp_session->cng_pt)) {
//if (rtp_session->flags[SWITCH_RTP_FLAG_SECURE_RECV] && (!rtp_session->ice.ice_user || rtp_session->has_rtp)) {
int sbytes = (int) *bytes;
switch_rtp_clear_flag(rtp_session, SWITCH_RTP_FLAG_SECURE_RECV_RESET);
srtp_dealloc(rtp_session->recv_ctx[rtp_session->srtp_idx_rtp]);
rtp_session->recv_ctx[rtp_session->srtp_idx_rtp] = NULL;
- if ((stat = srtp_create(&rtp_session->recv_ctx[rtp_session->srtp_idx_rtp],
+ if ((stat = srtp_create(&rtp_session->recv_ctx[rtp_session->srtp_idx_rtp],
&rtp_session->recv_policy[rtp_session->srtp_idx_rtp])) || !rtp_session->recv_ctx[rtp_session->srtp_idx_rtp]) {
-
+
rtp_session->flags[SWITCH_RTP_FLAG_SECURE_RECV] = 0;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_ERROR, "Error! RE-Activating Secure RTP RECV\n");
rtp_session->flags[SWITCH_RTP_FLAG_SECURE_RECV] = 0;
return SWITCH_STATUS_FALSE;
} else {
-
+
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_INFO, "RE-Activating Secure RTP RECV\n");
rtp_session->srtp_errs[rtp_session->srtp_idx_rtp] = 0;
}
if (!rtp_session->flags[SWITCH_RTP_FLAG_PROXY_MEDIA] && !rtp_session->flags[SWITCH_RTP_FLAG_UDPTL] &&
rtp_session->has_rtp && rtp_session->recv_msg.header.x) { /* header extensions */
uint16_t length;
-
+
rtp_session->recv_msg.ext = (switch_rtp_hdr_ext_t *) RTP_BODY(rtp_session);
length = ntohs((uint16_t)rtp_session->recv_msg.ext->length);
-
+
if (length < SWITCH_RTP_MAX_BUF_LEN_WORDS) {
rtp_session->recv_msg.ebody = (char *)rtp_session->recv_msg.ext + (length * 4) + 4;
if (*bytes > (length * 4 + 4)) {
#ifdef DEBUG_CHROME
-
+
if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] && rtp_session->has_rtp) {
-
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,
"VIDEO: seq: %d ts: %u len: %ld %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x mark: %d\n",
ntohs(rtp_session->last_rtp_hdr.seq), ntohl(rtp_session->last_rtp_hdr.ts), *bytes,
*((uint8_t *)RTP_BODY(rtp_session)), *((uint8_t *)RTP_BODY(rtp_session) + 1),
*((uint8_t *)RTP_BODY(rtp_session) + 6), *((uint8_t *)RTP_BODY(rtp_session) + 7),
*((uint8_t *)RTP_BODY(rtp_session) + 8), *((uint8_t *)RTP_BODY(rtp_session) + 9),
*((uint8_t *)RTP_BODY(rtp_session) + 10), rtp_session->last_rtp_hdr.m);
-
+
}
-#endif
+#endif
}
-
+
rtp_session->stats.inbound.raw_bytes += *bytes;
-
+
if (rtp_session->last_rtp_hdr.pt == rtp_session->recv_te) {
rtp_session->stats.inbound.dtmf_packet_count++;
} else if (rtp_session->last_rtp_hdr.pt == rtp_session->cng_pt || rtp_session->last_rtp_hdr.pt == 13) {
rtp_session->stats.inbound.packet_count++;
}
- if (!rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] &&
- ((rtp_session->recv_te && rtp_session->last_rtp_hdr.pt == rtp_session->recv_te) ||
+ if (!rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] &&
+ ((rtp_session->recv_te && rtp_session->last_rtp_hdr.pt == rtp_session->recv_te) ||
(*bytes < rtp_header_len && *bytes > 0 && !(rtp_session->flags[SWITCH_RTP_FLAG_PROXY_MEDIA] || rtp_session->flags[SWITCH_RTP_FLAG_UDPTL])))) {
return SWITCH_STATUS_BREAK;
}
if (ts) {
rtp_session->last_read_ts = ts;
}
-
+
if (rtp_session->flags[SWITCH_RTP_FLAG_BYTESWAP] && check_recv_payload(rtp_session)) {
switch_swap_linear((int16_t *)RTP_BODY(rtp_session), (int) *bytes - rtp_header_len);
}
switch_jb_destroy(&rtp_session->vb);
}
}
-
+
if (rtp_session->has_rtp && *bytes) {
uint32_t read_ssrc = ntohl(rtp_session->last_rtp_hdr.ssrc);
}
if (rtp_session->vb && jb_valid(rtp_session)) {
- status = switch_jb_put_packet(rtp_session->vb, (switch_rtp_packet_t *) &rtp_session->recv_msg, *bytes);
+ status = switch_jb_put_packet(rtp_session->vb, (switch_rtp_packet_t *) &rtp_session->recv_msg, *bytes);
if (status == SWITCH_STATUS_TOO_LATE) {
goto more;
}
-
+
status = SWITCH_STATUS_FALSE;
*bytes = 0;
goto more;
}
-
+
status = SWITCH_STATUS_FALSE;
*bytes = 0;
return status;
}
} else {
- if (rtp_session->last_rtp_hdr.m && rtp_session->last_rtp_hdr.pt != rtp_session->recv_te &&
+ if (rtp_session->last_rtp_hdr.m && rtp_session->last_rtp_hdr.pt != rtp_session->recv_te &&
!rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] && !(rtp_session->rtp_bugs & RTP_BUG_IGNORE_MARK_BIT)) {
switch_rtp_set_flag(rtp_session, SWITCH_RTP_FLAG_FLUSH);
} else if (rtp_session->last_jb_read_ssrc && rtp_session->last_jb_read_ssrc != read_ssrc) {
break;
}
}
-
+
if (rtp_session->vb && jb_valid(rtp_session)) {
switch_status_t vstatus = switch_jb_get_packet(rtp_session->vb, (switch_rtp_packet_t *) &rtp_session->recv_msg, bytes);
status = vstatus;
rtp_session->last_rtp_hdr.pt = pt;
}
}
-
+
if (vstatus == SWITCH_STATUS_SUCCESS) {
rtp_session->last_rtp_hdr = rtp_session->recv_msg.header;
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "Got NACK [%u][0x%x] for seq %u\n", nack, nack, ntohs(seq));
-
+
if (switch_jb_get_packet_by_seq(rtp_session->vbw, seq, (switch_rtp_packet_t *) send_msg, &bytes) == SWITCH_STATUS_SUCCESS) {
if (rtp_session->flags[SWITCH_RTP_FLAG_DEBUG_RTP_WRITE]) {
old_host, rtp_session->remote_port,
tx_host, switch_sockaddr_get_port(rtp_session->rtcp_from_addr),
send_msg->header.pt, ntohl(send_msg->header.ts), ntohs(send_msg->header.seq), send_msg->header.m);
-
+
}
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "RE----SEND %u\n", ntohs(send_msg->header.seq));
int i;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG3,
- "RTCP packet bytes %" SWITCH_SIZE_T_FMT " type %d pad %d\n",
+ "RTCP packet bytes %" SWITCH_SIZE_T_FMT " type %d pad %d\n",
bytes, msg->header.type, msg->header.p);
-
+
if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] && (msg->header.type == _RTCP_PT_RTPFB || msg->header.type == _RTCP_PT_PSFB || msg->header.type < 200)) {
- rtcp_ext_msg_t *extp = (rtcp_ext_msg_t *) msg;
+ rtcp_ext_msg_t *extp = (rtcp_ext_msg_t *) msg;
if (extp->header.fmt != 15) { // <---- REMOVE WHEN BRIA STOPS SENDING UNSOLICITED REMB
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "PICKED UP %s XRTCP type: %d fmt: %d\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "PICKED UP %s XRTCP type: %d fmt: %d\n",
rtp_type(rtp_session), msg->header.type, extp->header.fmt);
}
-
+
if (msg->header.type == _RTCP_PT_FIR ||
(msg->header.type == _RTCP_PT_PSFB && (extp->header.fmt == _RTCP_PSFB_FIR || extp->header.fmt == _RTCP_PSFB_PLI))) {
if (msg->header.type == _RTCP_PT_RTPFB && extp->header.fmt == _RTCP_RTPFB_NACK) {
uint32_t *nack = (uint32_t *) extp->body;
int i;
-
+
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "Got NACK count %d\n", ntohs(extp->header.length) - 2);
sec = (uint32_t)(now/1000000); /* converted to second (NTP most significant bits) */
ntp_sec = sec+NTP_TIME_OFFSET; /* 32bits most significant */
ntp_usec = (uint32_t)(now - (sec*1000000)); /* micro seconds */
- lsr_now = (uint32_t)(ntp_usec*0.065536) | (ntp_sec&0x0000ffff)<<16; // 0.065536 is used for convertion from useconds
+ lsr_now = (uint32_t)(ntp_usec*0.065536) | (ntp_sec&0x0000ffff)<<16; // 0.065536 is used for convertion from useconds
if (msg->header.type == _RTCP_PT_SR) { /* Sender report */
struct switch_rtcp_sender_report* sr = (struct switch_rtcp_sender_report*)msg->body;
-
+
rtp_session->stats.rtcp.packet_count += ntohl(sr->sender_info.pc);
rtp_session->stats.rtcp.octet_count += ntohl(sr->sender_info.oc);
packet_ssrc = sr->ssrc;
}
if (rtp_session->flags[SWITCH_RTP_FLAG_ADJ_BITRATE_CAP] && rtp_session->flags[SWITCH_RTP_FLAG_ESTIMATORS] && !rtp_session->flags[SWITCH_RTP_FLAG_VIDEO]) {
-
+
/* SWITCH_RTP_FLAG_ADJ_BITRATE_CAP : Can the codec change its bitrate on the fly per API command ? */
#ifdef DEBUG_ESTIMATORS_
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG3, "Current packet loss: [%d %%] Current RTT: [%f ms]\n", percent_fraction, rtt_now);
packet_loss_increase = 1;
}
#ifdef DEBUG_ESTIMATORS_
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG3, "ESTIMATORS: Packet loss will be: [%f] RTT will be: [%f ms]\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG3, "ESTIMATORS: Packet loss will be: [%f] RTT will be: [%f ms]\n",
rtp_session->estimators[EST_LOSS]->val_estimate_last, rtp_session->estimators[EST_RTT]->val_estimate_last);
-#endif
+#endif
if (rtp_session->rtcp_frame.reports[i].loss_avg != old_avg) {
/*getting bad*/
#ifdef DEBUG_ESTIMATORS_
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG3, "Slow link conditions: Loss average: [%d %%], Previous loss: [%d %%]. \
Going to minimum bitrate!",rtp_session->rtcp_frame.reports[i].loss_avg, old_avg);
-#endif
- switch_core_media_codec_control(rtp_session->session, SWITCH_MEDIA_TYPE_AUDIO,
+#endif
+ switch_core_media_codec_control(rtp_session->session, SWITCH_MEDIA_TYPE_AUDIO,
SWITCH_IO_WRITE, SCC_AUDIO_ADJUST_BITRATE, SCCT_STRING, "minimum", SCCT_NONE, NULL, NULL, NULL);
/* if after going to minimum bitrate we still have packet loss then we increase ptime. TODO */
} else if (packet_loss_increase && (rtp_session->estimators[EST_LOSS]->val_estimate_last >= 5)) {
/* sudden change in the mean value of packet loss percentage */
- switch_core_media_codec_control(rtp_session->session, SWITCH_MEDIA_TYPE_AUDIO,
- SWITCH_IO_WRITE, SCC_AUDIO_ADJUST_BITRATE,
- SCCT_STRING, "decrease",
+ switch_core_media_codec_control(rtp_session->session, SWITCH_MEDIA_TYPE_AUDIO,
+ SWITCH_IO_WRITE, SCC_AUDIO_ADJUST_BITRATE,
+ SCCT_STRING, "decrease",
SCCT_NONE, NULL, NULL, NULL);
#ifdef DEBUG_ESTIMATORS_
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG3,"Sudden change in the mean value of packet loss percentage !\n");
#endif
- switch_core_media_codec_control(rtp_session->session, SWITCH_MEDIA_TYPE_AUDIO,
- SWITCH_IO_WRITE, SCC_AUDIO_PACKET_LOSS, SCCT_INT,
- (void *)&rtp_session->rtcp_frame.reports[i].loss_avg,
+ switch_core_media_codec_control(rtp_session->session, SWITCH_MEDIA_TYPE_AUDIO,
+ SWITCH_IO_WRITE, SCC_AUDIO_PACKET_LOSS, SCCT_INT,
+ (void *)&rtp_session->rtcp_frame.reports[i].loss_avg,
SCCT_NONE, NULL, NULL, NULL);
} else if (!rtt_increase && rtp_session->estimators[EST_LOSS]->val_estimate_last >= rtp_session->rtcp_frame.reports[i].loss_avg ) {
/* lossy because of congestion (queues full somewhere -> some packets are dropped , but RTT is good ), packet loss with many small gaps */
#ifdef DEBUG_ESTIMATORS_
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG3, "packet loss, but RTT is not bad\n");
-#endif
- switch_core_media_codec_control(rtp_session->session, SWITCH_MEDIA_TYPE_AUDIO,
- SWITCH_IO_WRITE, SCC_AUDIO_PACKET_LOSS, SCCT_INT,
- (void *)&rtp_session->rtcp_frame.reports[i].loss_avg,
+#endif
+ switch_core_media_codec_control(rtp_session->session, SWITCH_MEDIA_TYPE_AUDIO,
+ SWITCH_IO_WRITE, SCC_AUDIO_PACKET_LOSS, SCCT_INT,
+ (void *)&rtp_session->rtcp_frame.reports[i].loss_avg,
SCCT_NONE, NULL, NULL, NULL);
} else if ((rtp_session->estimators[EST_LOSS]->val_estimate_last < 1) && packet_loss_increase) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG3, "small packet loss average\n");
#endif
/*small loss_avg*/
- switch_core_media_codec_control(rtp_session->session, SWITCH_MEDIA_TYPE_AUDIO,
- SWITCH_IO_WRITE, SCC_AUDIO_ADJUST_BITRATE,
- SCCT_STRING, "default",
+ switch_core_media_codec_control(rtp_session->session, SWITCH_MEDIA_TYPE_AUDIO,
+ SWITCH_IO_WRITE, SCC_AUDIO_ADJUST_BITRATE,
+ SCCT_STRING, "default",
SCCT_NONE, NULL, NULL, NULL);
- switch_core_media_codec_control(rtp_session->session, SWITCH_MEDIA_TYPE_AUDIO,
- SWITCH_IO_WRITE, SCC_AUDIO_PACKET_LOSS, SCCT_INT,
- (void *)&rtp_session->rtcp_frame.reports[i].loss_avg,
+ switch_core_media_codec_control(rtp_session->session, SWITCH_MEDIA_TYPE_AUDIO,
+ SWITCH_IO_WRITE, SCC_AUDIO_PACKET_LOSS, SCCT_INT,
+ (void *)&rtp_session->rtcp_frame.reports[i].loss_avg,
SCCT_NONE, NULL, NULL, NULL);
- } else if ((rtp_session->estimators[EST_LOSS]->val_estimate_last < 5) &&
+ } else if ((rtp_session->estimators[EST_LOSS]->val_estimate_last < 5) &&
(rtp_session->rtcp_frame.reports[i].rtt_avg < rtp_session->estimators[EST_RTT]->val_estimate_last)) {
/* estimate that packet loss will decrease, we can increase the bitrate */
- switch_core_media_codec_control(rtp_session->session, SWITCH_MEDIA_TYPE_AUDIO,
- SWITCH_IO_WRITE, SCC_AUDIO_ADJUST_BITRATE,
- SCCT_STRING, "increase",
+ switch_core_media_codec_control(rtp_session->session, SWITCH_MEDIA_TYPE_AUDIO,
+ SWITCH_IO_WRITE, SCC_AUDIO_ADJUST_BITRATE,
+ SCCT_STRING, "increase",
SCCT_NONE, NULL, NULL, NULL);
- switch_core_media_codec_control(rtp_session->session, SWITCH_MEDIA_TYPE_AUDIO,
- SWITCH_IO_WRITE, SCC_AUDIO_PACKET_LOSS, SCCT_INT,
- (void *)&rtp_session->rtcp_frame.reports[i].loss_avg,
+ switch_core_media_codec_control(rtp_session->session, SWITCH_MEDIA_TYPE_AUDIO,
+ SWITCH_IO_WRITE, SCC_AUDIO_PACKET_LOSS, SCCT_INT,
+ (void *)&rtp_session->rtcp_frame.reports[i].loss_avg,
SCCT_NONE, NULL, NULL, NULL);
} else {
/* *do nothing about bitrate, just pass the packet loss to the codec */
#ifdef DEBUG_ESTIMATORS_
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG3,"do nothing about bitrate, just pass the packet loss to the codec\n");
-#endif
- switch_core_media_codec_control(rtp_session->session, SWITCH_MEDIA_TYPE_AUDIO,
- SWITCH_IO_WRITE, SCC_AUDIO_PACKET_LOSS, SCCT_INT,
- (void *)&rtp_session->rtcp_frame.reports[i].loss_avg,
+#endif
+ switch_core_media_codec_control(rtp_session->session, SWITCH_MEDIA_TYPE_AUDIO,
+ SWITCH_IO_WRITE, SCC_AUDIO_PACKET_LOSS, SCCT_INT,
+ (void *)&rtp_session->rtcp_frame.reports[i].loss_avg,
SCCT_NONE, NULL, NULL, NULL);
}
}
} else {
if (!rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] && rtp_session->rtcp_frame.reports[i].loss_avg != old_avg) {
- switch_core_media_codec_control(rtp_session->session, SWITCH_MEDIA_TYPE_AUDIO,
- SWITCH_IO_WRITE, SCC_AUDIO_PACKET_LOSS, SCCT_INT,
- (void *)&rtp_session->rtcp_frame.reports[i].loss_avg,
+ switch_core_media_codec_control(rtp_session->session, SWITCH_MEDIA_TYPE_AUDIO,
+ SWITCH_IO_WRITE, SCC_AUDIO_PACKET_LOSS, SCCT_INT,
+ (void *)&rtp_session->rtcp_frame.reports[i].loss_avg,
SCCT_NONE, NULL, NULL, NULL);
}
}
rtp_session->rtcp_fresh_frame = 1;
rtp_session->stats.rtcp.peer_ssrc = ntohl(packet_ssrc);
}
-
+
if (msg->header.type > 194 && msg->header.type < 255) {
status = SWITCH_STATUS_SUCCESS;
switch_size_t remain = *bytes;
switch_status_t status = SWITCH_STATUS_FALSE;
rtcp_msg_t *msg = rtp_session->rtcp_recv_msg_p;
-
+
if (msg->header.version != 2) {
if (msg->header.version == 0) {
if (rtp_session->ice.ice_user) {
len = ((switch_size_t)ntohs(msg->header.length) * 4) + 4;
if (msg->header.version != 2 || !(msg->header.type > 191 && msg->header.type < 210)) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_WARNING,
- "INVALID RTCP PACKET TYPE %d VER %d LEN %" SWITCH_SIZE_T_FMT "\n", msg->header.type,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_WARNING,
+ "INVALID RTCP PACKET TYPE %d VER %d LEN %" SWITCH_SIZE_T_FMT "\n", msg->header.type,
msg->header.version, len);
status = SWITCH_STATUS_BREAK;
break;
}
- //switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_CRIT,
+ //switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_CRIT,
//"WTF BYTES %ld REMAIN %ld PACKET TYPE %d LEN %ld\n", *bytes, remain, msg->header.type, len);
if (len > remain) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_WARNING,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_WARNING,
"RTCP INVALID LENGTH %" SWITCH_SIZE_T_FMT "\n", len);
len = remain;
}
*bytes = sizeof(rtcp_msg_t);
- if ((status = switch_socket_recvfrom(rtp_session->rtcp_from_addr, rtp_session->rtcp_sock_input, 0, (void *) rtp_session->rtcp_recv_msg_p, bytes))
+ if ((status = switch_socket_recvfrom(rtp_session->rtcp_from_addr, rtp_session->rtcp_sock_input, 0, (void *) rtp_session->rtcp_recv_msg_p, bytes))
!= SWITCH_STATUS_SUCCESS) {
*bytes = 0;
}
if (rtp_session->rtcp_dtls) {
char *b = (char *) rtp_session->rtcp_recv_msg_p;
-
+
if (*b == 0 || *b == 1) {
if (rtp_session->rtcp_ice.ice_user) {
handle_ice(rtp_session, &rtp_session->rtcp_ice, (void *) rtp_session->rtcp_recv_msg_p, *bytes);
}
*bytes = 0;
}
-
+
if (*bytes && (*b >= 20) && (*b <= 64)) {
rtp_session->rtcp_dtls->bytes = *bytes;
rtp_session->rtcp_dtls->data = (void *) rtp_session->rtcp_recv_msg_p;
rtp_session->rtcp_dtls->bytes = 0;
rtp_session->rtcp_dtls->data = NULL;
}
-
+
do_dtls(rtp_session, rtp_session->rtcp_dtls);
-
+
if (rtp_session->rtcp_dtls->bytes) {
*bytes = 0;
//if (rtp_session->flags[SWITCH_RTP_FLAG_SECURE_RECV] && (!rtp_session->ice.ice_user || rtp_session->rtcp_recv_msg_p->header.version == 2)) {
int sbytes = (int) *bytes;
err_status_t stat = 0;
-
+
if ((stat = srtp_unprotect_rtcp(rtp_session->recv_ctx[rtp_session->srtp_idx_rtcp], &rtp_session->rtcp_recv_msg_p->header, &sbytes))) {
//++rtp_session->srtp_errs[rtp_session->srtp_idx_rtp]++;
} else {
//rtp_session->srtp_errs[rtp_session->srtp_idx_rtp] = 0;
}
-
+
*bytes = sbytes;
-
+
}
#endif
if (bytes) {
unsigned int sbytes = (int) *bytes;
zrtp_status_t stat = 0;
-
+
stat = zrtp_process_srtcp(rtp_session->zrtp_stream, (void *) rtp_session->rtcp_recv_msg_p, &sbytes);
-
+
switch (stat) {
case zrtp_status_ok:
*bytes = sbytes;
const char *tx_host;
const char *old_host;
char bufa[50], bufb[50];
-
+
tx_host = switch_get_addr(bufa, sizeof(bufa), rtp_session->rtcp_from_addr);
old_host = switch_get_addr(bufb, sizeof(bufb), rtp_session->rtcp_remote_addr);
"Auto Changing %s RTCP port from %s:%u to %s:%u\n", rtp_type(rtp_session), old_host, old, tx_host,
switch_sockaddr_get_port(rtp_session->rtcp_from_addr));
-
+
rtp_session->eff_remote_host_str = switch_core_strdup(rtp_session->pool, tx_host);
rtp_session->remote_rtcp_port = switch_sockaddr_get_port(rtp_session->rtcp_from_addr);
status = enable_remote_rtcp_socket(rtp_session, &err);
rtp_session->rtcp_auto_adj_used = 1;
-
+
if ((rtp_session->rtp_bugs & RTP_BUG_ALWAYS_AUTO_ADJUST)) {
switch_rtp_set_flag(rtp_session, SWITCH_RTP_FLAG_RTCP_AUTOADJ);
} else {
}
}
} else {
-
+
if ((rtp_session->rtp_bugs & RTP_BUG_ALWAYS_AUTO_ADJUST)) {
switch_rtp_set_flag(rtp_session, SWITCH_RTP_FLAG_RTCP_AUTOADJ);
} else {
switch_rtp_clear_flag(rtp_session, SWITCH_RTP_FLAG_RTCP_AUTOADJ);
}
rtp_session->rtcp_auto_adj_used = 0;
-
+
}
}
-
+
if (*bytes) {
return process_rtcp_packet(rtp_session, bytes);
}
return status;
}
-static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_type,
+static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_type,
payload_map_t **pmapP, switch_frame_flag_t *flags, switch_io_flag_t io_flags)
{
-
+
switch_channel_t *channel = NULL;
switch_size_t bytes = 0;
switch_size_t rtcp_bytes = 0;
bytes = 0;
if (rtp_session->flags[SWITCH_RTP_FLAG_USE_TIMER] &&
- !rtp_session->flags[SWITCH_RTP_FLAG_PROXY_MEDIA] &&
- !rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] &&
+ !rtp_session->flags[SWITCH_RTP_FLAG_PROXY_MEDIA] &&
+ !rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] &&
!rtp_session->flags[SWITCH_RTP_FLAG_UDPTL] &&
rtp_session->read_pollfd) {
-
+
if (rtp_session->jb && !rtp_session->pause_jb && jb_valid(rtp_session)) {
while (switch_poll(rtp_session->read_pollfd, 1, &fdr, 0) == SWITCH_STATUS_SUCCESS) {
status = read_rtp_packet(rtp_session, &bytes, flags, pmapP, SWITCH_STATUS_SUCCESS, SWITCH_FALSE);
break;
}
}
-
+
} else if ((rtp_session->flags[SWITCH_RTP_FLAG_AUTOFLUSH] || rtp_session->flags[SWITCH_RTP_FLAG_STICKY_FLUSH])) {
-
+
if (switch_poll(rtp_session->read_pollfd, 1, &fdr, 0) == SWITCH_STATUS_SUCCESS) {
status = read_rtp_packet(rtp_session, &bytes, flags, pmapP, SWITCH_STATUS_SUCCESS, SWITCH_FALSE);
if (status == SWITCH_STATUS_GENERR) {
if (bytes) {
if (switch_poll(rtp_session->read_pollfd, 1, &fdr, 0) == SWITCH_STATUS_SUCCESS) {
rtp_session->hot_hits++;//+= rtp_session->samples_per_interval;
-
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG10, "%s Hot Hit %d\n",
+
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG10, "%s Hot Hit %d\n",
rtp_session_name(rtp_session),
- rtp_session->hot_hits);
+ rtp_session->hot_hits);
} else {
rtp_session->hot_hits = 0;
}
}
-
+
if (rtp_session->hot_hits > 1 && !rtp_session->sync_packets) {// >= (rtp_session->samples_per_second * 30)) {
hot_socket = 1;
}
if (rtp_session->flags[SWITCH_RTP_FLAG_TEXT]) {
///NOOP
- } else if (hot_socket && (rtp_session->hot_hits % 10) != 0) {
+ } else if (hot_socket && (rtp_session->hot_hits % 10) != 0) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG10, "%s timer while HOT\n", rtp_session_name(rtp_session));
switch_core_timer_next(&rtp_session->timer);
} else if (hot_socket) {
switch_core_timer_sync(&rtp_session->timer);
reset_jitter_seq(rtp_session);
} else {
-
+
if (rtp_session->sync_packets) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG10,
rtp_session_name(rtp_session),
rtp_session->sync_packets, (rtp_session->ms_per_packet * rtp_session->sync_packets) / 1000);
if (!rtp_session->flags[SWITCH_RTP_FLAG_PAUSE]) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG3, "%s syncing %d %s packet(s)\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG3, "%s syncing %d %s packet(s)\n",
rtp_session_name(rtp_session),
rtp_session->sync_packets, rtp_type(rtp_session));
}
}
-
+
rtp_session->sync_packets = 0;
}
}
if (!switch_rtp_ready(rtp_session)) {
break;
}
-
+
if (!rtp_session->flags[SWITCH_RTP_FLAG_USE_TIMER] && rtp_session->read_pollfd) {
int pt = poll_sec * 1000000;
do_2833(rtp_session);
- if (rtp_session->dtmf_data.out_digit_dur > 0 || rtp_session->dtmf_data.in_digit_sanity || rtp_session->sending_dtmf ||
+ if (rtp_session->dtmf_data.out_digit_dur > 0 || rtp_session->dtmf_data.in_digit_sanity || rtp_session->sending_dtmf ||
switch_queue_size(rtp_session->dtmf_data.dtmf_queue) || switch_queue_size(rtp_session->dtmf_data.dtmf_inqueue)) {
pt = 20000;
}
-
+
if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] && !rtp_session->flags[SWITCH_RTP_FLAG_PROXY_MEDIA]) {
pt = 200000;
}
if ((io_flags & SWITCH_IO_FLAG_NOBLOCK)) {
pt = 0;
}
-
+
poll_status = switch_poll(rtp_session->read_pollfd, 1, &fdr, pt);
}
}
-
-
+
+
if (poll_status == SWITCH_STATUS_SUCCESS || (rtp_session->vb && switch_jb_poll(rtp_session->vb))) {
got_rtp_poll = 1;
if (read_pretriggered) {
read_pretriggered = 0;
} else {
-
+
status = read_rtp_packet(rtp_session, &bytes, flags, pmapP, poll_status, SWITCH_TRUE);
if (status == SWITCH_STATUS_GENERR) {
goto end;
}
- if (rtp_session->max_missed_packets && read_loops == 1 && !rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] &&
+ if (rtp_session->max_missed_packets && read_loops == 1 && !rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] &&
!rtp_session->flags[SWITCH_RTP_FLAG_UDPTL]) {
if (bytes && status == SWITCH_STATUS_SUCCESS) {
rtp_session->missed_count = 0;
goto end;
}
}
-
+
if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO]) {
- //switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_CRIT, "Read bytes (%i) %ld\n", status, bytes);
-
+ //switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_CRIT, "Read bytes (%i) %ld\n", status, bytes);
+
if (bytes == 0) {
if (check_rtcp_and_ice(rtp_session) == -1) {
ret = -1;
ret = -1;
goto end;
}
-
+
if (!SWITCH_STATUS_IS_BREAK(poll_status) && poll_status != SWITCH_STATUS_TIMEOUT) {
char tmp[128] = "";
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_ERROR, "Poll failed with error: %d [%s]\n",
ret = -1;
goto end;
}
-
-
- if ((!(io_flags & SWITCH_IO_FLAG_NOBLOCK)) &&
+
+
+ if ((!(io_flags & SWITCH_IO_FLAG_NOBLOCK)) &&
(rtp_session->dtmf_data.out_digit_dur == 0) && !rtp_session->flags[SWITCH_RTP_FLAG_ENABLE_RTCP]) {
return_cng_frame();
}
}
-
+
rtcp:
if (rtp_session->flags[SWITCH_RTP_FLAG_ENABLE_RTCP]) {
rtcp_poll_status = SWITCH_STATUS_FALSE;
-
+
if (rtp_session->flags[SWITCH_RTP_FLAG_RTCP_MUX] && has_rtcp) {
if (rtp_session->rtcp_recv_msg_p->header.version == 2) { //rtcp muxed
rtp_session->rtcp_from_addr = rtp_session->from_addr;
}
has_rtcp = 0;
-
+
} else if (rtp_session->rtcp_read_pollfd) {
rtcp_poll_status = switch_poll(rtp_session->rtcp_read_pollfd, 1, &rtcp_fdr, 0);
}
-
+
if (rtcp_poll_status == SWITCH_STATUS_SUCCESS) {
-
+
if (!rtp_session->flags[SWITCH_RTP_FLAG_RTCP_MUX]) {
rtcp_status = read_rtcp_packet(rtp_session, &rtcp_bytes, flags);
}
-
+
if (rtcp_status == SWITCH_STATUS_SUCCESS) {
switch_rtp_reset_media_timer(rtp_session);
-
+
if (rtp_session->flags[SWITCH_RTP_FLAG_RTCP_PASSTHRU]) {
switch_channel_t *channel = switch_core_session_get_channel(rtp_session->session);
const char *uuid = switch_channel_get_partner_uuid(channel);
switch_rtp_t *other_rtp_session = NULL;
if ((other_session = switch_core_session_locate(uuid))) {
- switch_channel_t *other_channel = switch_core_session_get_channel(other_session);
- if ((other_rtp_session = switch_channel_get_private(other_channel, "__rtcp_audio_rtp_session")) &&
+ switch_channel_t *other_channel = switch_core_session_get_channel(other_session);
+ if ((other_rtp_session = switch_channel_get_private(other_channel, "__rtcp_audio_rtp_session")) &&
other_rtp_session->rtcp_sock_output &&
switch_rtp_test_flag(other_rtp_session, SWITCH_RTP_FLAG_ENABLE_RTCP)) {
other_rtp_session->rtcp_send_msg = rtp_session->rtcp_recv_msg;
-
+
#ifdef ENABLE_SRTP
if (switch_rtp_test_flag(other_rtp_session, SWITCH_RTP_FLAG_SECURE_SEND)) {
int sbytes = (int) rtcp_bytes;
if (zrtp_on && !rtp_session->flags[SWITCH_RTP_FLAG_PROXY_MEDIA]) {
unsigned int sbytes = (unsigned int) bytes;
zrtp_status_t stat = zrtp_status_fail;
-
+
stat = zrtp_process_rtcp(other_rtp_session->zrtp_stream, (void *) &other_rtp_session->rtcp_send_msg, &sbytes);
-
+
switch (stat) {
case zrtp_status_ok:
break;
default:
break;
}
-
+
bytes = sbytes;
}
#endif
- if (switch_socket_sendto(other_rtp_session->rtcp_sock_output, other_rtp_session->rtcp_remote_addr, 0,
+ if (switch_socket_sendto(other_rtp_session->rtcp_sock_output, other_rtp_session->rtcp_remote_addr, 0,
(const char*)&other_rtp_session->rtcp_send_msg, &rtcp_bytes ) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG,"RTCP packet not written\n");
}
-
-
+
+
}
switch_core_session_rwunlock(other_session);
}
}
-
+
}
if (rtp_session->flags[SWITCH_RTP_FLAG_RTCP_MUX]) {
process_rtcp_packet(rtp_session, &rtcp_bytes);
ret = 1;
-
+
if (!rtp_session->flags[SWITCH_RTP_FLAG_USE_TIMER] && rtp_session->timer.interval) {
switch_core_timer_sync(&rtp_session->timer);
reset_jitter_seq(rtp_session);
}
}
- if ((!(io_flags & SWITCH_IO_FLAG_NOBLOCK)) &&
+ if ((!(io_flags & SWITCH_IO_FLAG_NOBLOCK)) &&
(rtp_session->dtmf_data.out_digit_dur == 0) && !got_rtp_poll) {
return_cng_frame();
}
bytes = do_flush(rtp_session, SWITCH_FALSE, bytes);
switch_rtp_clear_flag(rtp_session, SWITCH_RTP_FLAG_FLUSH);
}
-
+
if ((!bytes && rtp_session->flags[SWITCH_RTP_FLAG_BREAK]) || (bytes && bytes == 4 && *((int *) &rtp_session->recv_msg) == UINT_MAX)) {
switch_rtp_clear_flag(rtp_session, SWITCH_RTP_FLAG_BREAK);
- if (!rtp_session->flags[SWITCH_RTP_FLAG_NOBLOCK] || !rtp_session->flags[SWITCH_RTP_FLAG_USE_TIMER] ||
- rtp_session->flags[SWITCH_RTP_FLAG_PROXY_MEDIA] || rtp_session->flags[SWITCH_RTP_FLAG_UDPTL] ||
+ if (!rtp_session->flags[SWITCH_RTP_FLAG_NOBLOCK] || !rtp_session->flags[SWITCH_RTP_FLAG_USE_TIMER] ||
+ rtp_session->flags[SWITCH_RTP_FLAG_PROXY_MEDIA] || rtp_session->flags[SWITCH_RTP_FLAG_UDPTL] ||
(bytes && bytes < 5) || (!bytes && poll_loop)) {
bytes = 0;
reset_jitter_seq(rtp_session);
goto recvfrom;
}
- if (bytes && rtp_session->last_rtp_hdr.m && rtp_session->last_rtp_hdr.pt != rtp_session->recv_te &&
+ if (bytes && rtp_session->last_rtp_hdr.m && rtp_session->last_rtp_hdr.pt != rtp_session->recv_te &&
!rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] &&
!rtp_session->flags[SWITCH_RTP_FLAG_TEXT] &&
!(rtp_session->rtp_bugs & RTP_BUG_IGNORE_MARK_BIT)) {
if (rtp_session->flags[SWITCH_RTP_FLAG_UDPTL]) {
#if 0
if (rtp_session->has_rtp && check_recv_payload(rtp_session)) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_WARNING,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_WARNING,
"Ignoring udptl packet of size of %ld bytes that looks strikingly like a RTP packet.\n", (long)bytes);
bytes = 0;
- goto do_continue;
+ goto do_continue;
}
#endif
*flags |= SFF_UDPTL_PACKET;
bytes = 0;
goto do_continue;
}
-
+
if (rtp_session->last_rtp_hdr.pt && (rtp_session->last_rtp_hdr.pt == rtp_session->cng_pt || rtp_session->last_rtp_hdr.pt == 13)) {
return_cng_frame();
}
result_continue:
timer_check:
-
+
if (rtp_session->flags[SWITCH_RTP_FLAG_MUTE]) {
do_cng++;
}
continue;
}
-
- if (!rtp_session->flags[SWITCH_RTP_FLAG_PAUSE] && !rtp_session->flags[SWITCH_RTP_FLAG_DTMF_ON] && !rtp_session->dtmf_data.in_digit_ts
+
+ if (!rtp_session->flags[SWITCH_RTP_FLAG_PAUSE] && !rtp_session->flags[SWITCH_RTP_FLAG_DTMF_ON] && !rtp_session->dtmf_data.in_digit_ts
&& rtp_session->cng_count > (rtp_session->one_second * 2) && rtp_session->jitter_lead > JITTER_LEAD_FRAMES) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "%s %s timeout\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "%s %s timeout\n",
rtp_session_name(rtp_session), rtp_type(rtp_session));
if (rtp_session->stats.inbound.error_log) {
switch_mutex_lock(rtp_session->dtmf_data.dtmf_mutex);
if (switch_queue_trypop(rtp_session->dtmf_data.dtmf_inqueue, &pop) == SWITCH_STATUS_SUCCESS) {
-
+
_dtmf = (switch_dtmf_t *) pop;
*dtmf = *_dtmf;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG, "RTP RECV DTMF %c:%d\n", dtmf->digit, dtmf->duration);
frame->ssrc = ntohl(rtp_session->last_rtp_hdr.ssrc);
frame->m = rtp_session->last_rtp_hdr.m ? SWITCH_TRUE : SWITCH_FALSE;
}
-
+
#ifdef ENABLE_ZRTP
if (zrtp_on && rtp_session->flags[SWITCH_ZRTP_FLAG_SECURE_MITM_RECV]) {
zrtp_session_info_t zrtp_session_info;
if (rtp_session->zrtp_session && (zrtp_status_ok == zrtp_session_get(rtp_session->zrtp_session, &zrtp_session_info))) {
if (zrtp_session_info.sas_is_ready) {
-
+
switch_channel_t *channel = switch_core_session_get_channel(rtp_session->session);
const char *uuid = switch_channel_get_partner_uuid(channel);
static int rtp_write_ready(switch_rtp_t *rtp_session, uint32_t bytes, int line)
{
if (!rtp_session) return 0;
-
+
if (rtp_session->ice.ice_user && !(rtp_session->ice.rready || rtp_session->ice.ready)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG3, "Skip sending %s packet %ld bytes (ice not ready @ line %d!)\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG3, "Skip sending %s packet %ld bytes (ice not ready @ line %d!)\n",
rtp_type(rtp_session), (long)bytes, line);
return 0;
}
if (rtp_session->dtls && rtp_session->dtls->state != DS_READY) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG3, "Skip sending %s packet %ld bytes (dtls not ready @ line %d!)\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG3, "Skip sending %s packet %ld bytes (dtls not ready @ line %d!)\n",
rtp_type(rtp_session), (long)bytes, line);
return 0;
}
-
+
return 1;
}
|| rtp_session->ts == rtp_session->samples_per_interval)) {
m++;
}
-
- if (rtp_session->flags[SWITCH_RTP_FLAG_USE_TIMER] &&
+
+ if (rtp_session->flags[SWITCH_RTP_FLAG_USE_TIMER] &&
(rtp_session->timer.samplecount - rtp_session->last_write_samplecount) > rtp_session->samples_per_interval * 10) {
m++;
}
-
+
if (!rtp_session->flags[SWITCH_RTP_FLAG_USE_TIMER] &&
((unsigned) ((switch_micro_time_now() - rtp_session->last_write_timestamp))) > (rtp_session->ms_per_packet * 10)) {
m++;
}
-
+
if (rtp_session->cn && payload != rtp_session->cng_pt) {
rtp_session->cn = 0;
m++;
}
-
+
if (rtp_session->need_mark && !rtp_session->sending_dtmf) {
m++;
rtp_session->need_mark = 0;
rtp_session->flags[SWITCH_RTP_FLAG_RESET] = 1;
rtp_session->ts = 0;
}
-
+
/* If the marker was set, and the timestamp seems to have started over - set a new SSRC, to indicate this is a new stream */
- if (m && !switch_rtp_test_flag(rtp_session, SWITCH_RTP_FLAG_SECURE_SEND) && (rtp_session->rtp_bugs & RTP_BUG_CHANGE_SSRC_ON_MARKER) &&
+ if (m && !switch_rtp_test_flag(rtp_session, SWITCH_RTP_FLAG_SECURE_SEND) && (rtp_session->rtp_bugs & RTP_BUG_CHANGE_SSRC_ON_MARKER) &&
(rtp_session->flags[SWITCH_RTP_FLAG_RESET] || (rtp_session->ts <= rtp_session->last_write_ts && rtp_session->last_write_ts > 0))) {
switch_rtp_set_ssrc(rtp_session, (uint32_t) ((intptr_t) rtp_session + (uint32_t) switch_epoch_time_now(NULL)));
}
-
+
if (!switch_rtp_test_flag(rtp_session, SWITCH_RTP_FLAG_VIDEO) && !switch_rtp_test_flag(rtp_session, SWITCH_RTP_FLAG_UDPTL)) {
send_msg->header.m = (m && !(rtp_session->rtp_bugs & RTP_BUG_NEVER_SEND_MARKER)) ? 1 : 0;
}
if (switch_rtp_test_flag(rtp_session, SWITCH_RTP_FLAG_GEN_TS_DELTA) || switch_rtp_test_flag(rtp_session, SWITCH_RTP_FLAG_VIDEO)) {
- /* Normalize the timestamps to our own base by generating a made up starting point then adding the measured deltas to that base
+ /* Normalize the timestamps to our own base by generating a made up starting point then adding the measured deltas to that base
so if the timestamps and ssrc of the source change, it will not break the other end's jitter bufffer / decoder etc *cough* CHROME *cough*
*/
rtp_session->ts_norm.last_ssrc = send_msg->header.ssrc;
rtp_session->ts_norm.last_frame = ntohl(send_msg->header.ts);
}
-
+
if (ntohl(send_msg->header.ts) != rtp_session->ts_norm.last_frame) {
int32_t delta = (int32_t) (ntohl(send_msg->header.ts) - rtp_session->ts_norm.last_frame);
-
+
if (switch_rtp_test_flag(rtp_session, SWITCH_RTP_FLAG_VIDEO) && delta > 0 && delta < 90000) {
rtp_session->ts_norm.delta = delta;
}
}
}
}
-
+
rtp_session->ts_norm.last_frame = ntohl(send_msg->header.ts);
send_msg->header.ts = htonl(rtp_session->ts_norm.ts);
}
uint32_t len = sizeof(decoded);
time_t now = switch_epoch_time_now(NULL);
send = 0;
-
+
if (rtp_session->vad_data.scan_freq && rtp_session->vad_data.next_scan <= now) {
rtp_session->vad_data.bg_count = rtp_session->vad_data.bg_level = 0;
rtp_session->vad_data.next_scan = now + rtp_session->vad_data.scan_freq;
} else {
if (score > rtp_session->vad_data.bg_level && !switch_test_flag(&rtp_session->vad_data, SWITCH_VAD_FLAG_TALKING)) {
uint32_t diff = score - rtp_session->vad_data.bg_level;
-
+
if (rtp_session->vad_data.hangover_hits) {
rtp_session->vad_data.hangover_hits--;
}
rtp_session->vad_data.total_talk_time += (rtp_session->vad_data.stop_talking - rtp_session->vad_data.start_talking);
switch_clear_flag(&rtp_session->vad_data, SWITCH_VAD_FLAG_TALKING);
-
+
rtp_session->vad_data.hangover_hits = rtp_session->vad_data.hangunder_hits = rtp_session->vad_data.cng_count = 0;
if (switch_test_flag(&rtp_session->vad_data, SWITCH_VAD_FLAG_EVENTS_NOTALK)) {
-
+
if ((rtp_session->vad_data.fire_events & VAD_FIRE_NOT_TALK)) {
switch_event_t *event;
if (switch_event_create(&event, SWITCH_EVENT_NOTALK) == SWITCH_STATUS_SUCCESS) {
if (rtp_session->flags[SWITCH_RTP_FLAG_SECURE_SEND_RESET] || !rtp_session->send_ctx[rtp_session->srtp_idx_rtp]) {
-
+
switch_rtp_clear_flag(rtp_session, SWITCH_RTP_FLAG_SECURE_SEND_RESET);
srtp_dealloc(rtp_session->send_ctx[rtp_session->srtp_idx_rtp]);
rtp_session->send_ctx[rtp_session->srtp_idx_rtp] = NULL;
- if ((stat = srtp_create(&rtp_session->send_ctx[rtp_session->srtp_idx_rtp],
+ if ((stat = srtp_create(&rtp_session->send_ctx[rtp_session->srtp_idx_rtp],
&rtp_session->send_policy[rtp_session->srtp_idx_rtp])) || !rtp_session->send_ctx[rtp_session->srtp_idx_rtp]) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_ERROR,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_ERROR,
"Error! RE-Activating %s Secure RTP SEND\n", rtp_type(rtp_session));
rtp_session->flags[SWITCH_RTP_FLAG_SECURE_SEND] = 0;
ret = -1;
goto end;
} else {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_INFO,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_INFO,
"RE-Activating %s Secure RTP SEND\n", rtp_type(rtp_session));
}
}
stat = srtp_protect(rtp_session->send_ctx[rtp_session->srtp_idx_rtp], &send_msg->header, &sbytes);
-
+
if (stat) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_ERROR,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_ERROR,
"Error: %s SRTP protection failed with code %d\n", rtp_type(rtp_session), stat);
}
if (zrtp_on && !rtp_session->flags[SWITCH_RTP_FLAG_PROXY_MEDIA]) {
unsigned int sbytes = (int) bytes;
zrtp_status_t stat = zrtp_status_fail;
-
+
stat = zrtp_process_rtp(rtp_session->zrtp_stream, (void *) send_msg, &sbytes);
send_msg->header.pt, ntohl(send_msg->header.ts), ntohs(send_msg->header.seq), send_msg->header.m);
}
-
+
if (rtp_session->flags[SWITCH_RTP_FLAG_NACK]) {
switch_channel_t *channel = switch_core_session_get_channel(rtp_session->session);
#ifdef RTP_WRITE_PLOSS
{
int r = (rand() % 10000) + 1;
-
+
if (r <= 200) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_ALERT,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_ALERT,
"Simulate dropping packet ......... ts: %u seq: %u\n", ntohl(send_msg->header.ts), ntohs(send_msg->header.seq));
} else {
if (switch_socket_sendto(rtp_session->sock_output, rtp_session->remote_addr, 0, (void *) send_msg, &bytes) != SWITCH_STATUS_SUCCESS) {
rtp_session->stats.outbound.raw_bytes += bytes;
rtp_session->stats.outbound.packet_count++;
-
+
if (rtp_session->flags[SWITCH_RTP_FLAG_ENABLE_RTCP]) {
rtp_session->stats.rtcp.sent_pkt_count++;
}
if (switch_true(switch_channel_get_variable(switch_core_session_get_channel(rtp_session->session), "fire_not_talk_events"))) {
rtp_session->vad_data.fire_events |= VAD_FIRE_NOT_TALK;
}
-
+
if (switch_core_codec_init(&rtp_session->vad_data.vad_codec,
codec->implementation->iananame,
if (!rtp_write_ready(rtp_session, frame->datalen, __LINE__)) {
return 0;
}
-
+
//if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO]) {
// rtp_session->flags[SWITCH_RTP_FLAG_DEBUG_RTP_READ]++;
// rtp_session->flags[SWITCH_RTP_FLAG_DEBUG_RTP_WRITE]++;
if (switch_test_flag(frame, SFF_PROXY_PACKET) || switch_test_flag(frame, SFF_UDPTL_PACKET) ||
rtp_session->flags[SWITCH_RTP_FLAG_PROXY_MEDIA] || rtp_session->flags[SWITCH_RTP_FLAG_UDPTL]) {
-
+
//if (rtp_session->flags[SWITCH_RTP_FLAG_PROXY_MEDIA] || rtp_session->flags[SWITCH_RTP_FLAG_UDPTL]) {
switch_size_t bytes;
//char bufa[50];
if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] && rtp_session->payload > 0) {
send_msg->header.pt = rtp_session->payload;
}
-
+
send_msg->header.ssrc = htonl(rtp_session->ssrc);
send_msg->header.seq = htons(++rtp_session->seq);
}
if (zrtp_status_ok == zrtp_session_get(rtp_session->zrtp_session, &zrtp_session_info)) {
if (zrtp_session_info.sas_is_ready) {
-
+
switch_channel_t *channel = switch_core_session_get_channel(rtp_session->session);
const char *uuid = switch_channel_get_partner_uuid(channel);
}
#endif
- fwd = (rtp_session->flags[SWITCH_RTP_FLAG_RAW_WRITE] &&
+ fwd = (rtp_session->flags[SWITCH_RTP_FLAG_RAW_WRITE] &&
(switch_test_flag(frame, SFF_RAW_RTP) || switch_test_flag(frame, SFF_RAW_RTP_PARSE_FRAME))) ? 1 : 0;
- if (!fwd && !rtp_session->sending_dtmf && !rtp_session->queue_delay &&
+ if (!fwd && !rtp_session->sending_dtmf && !rtp_session->queue_delay &&
rtp_session->flags[SWITCH_RTP_FLAG_RAW_WRITE] && (rtp_session->rtp_bugs & RTP_BUG_GEN_ONE_GEN_ALL)) {
-
+
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_WARNING, "Generating RTP locally but timestamp passthru is configured, disabling....\n");
rtp_session->flags[SWITCH_RTP_FLAG_RAW_WRITE] = 0;
rtp_session->flags[SWITCH_RTP_FLAG_RESET] = 1;
wrote = switch_rtp_write_manual(rtp_session, frame->data, frame->datalen,
frame->m, frame->payload, (uint32_t) (frame->timestamp), &frame->flags);
-
+
rtp_session->stats.outbound.raw_bytes += wrote;
rtp_session->stats.outbound.media_bytes += wrote;
rtp_session->stats.outbound.media_packet_count++;
SWITCH_DECLARE(switch_status_t) switch_rtp_write_raw(switch_rtp_t *rtp_session, void *data, switch_size_t *bytes, switch_bool_t process_encryption)
{
switch_status_t status = SWITCH_STATUS_FALSE;
-
+
switch_assert(bytes);
if (!switch_rtp_ready(rtp_session) || !rtp_session->remote_addr || *bytes > SWITCH_RTP_MAX_BUF_LEN) {
process_encryption = SWITCH_FALSE;
#ifdef ENABLE_SRTP
if (rtp_session->flags[SWITCH_RTP_FLAG_SECURE_SEND]) {
-
+
int sbytes = (int) *bytes;
err_status_t stat;
switch_rtp_clear_flag(rtp_session, SWITCH_RTP_FLAG_SECURE_SEND_RESET);
srtp_dealloc(rtp_session->send_ctx[rtp_session->srtp_idx_rtp]);
rtp_session->send_ctx[rtp_session->srtp_idx_rtp] = NULL;
- if ((stat = srtp_create(&rtp_session->send_ctx[rtp_session->srtp_idx_rtp],
+ if ((stat = srtp_create(&rtp_session->send_ctx[rtp_session->srtp_idx_rtp],
&rtp_session->send_policy[rtp_session->srtp_idx_rtp])) || !rtp_session->send_ctx[rtp_session->srtp_idx_rtp]) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_ERROR, "Error! RE-Activating Secure RTP SEND\n");
rtp_session->flags[SWITCH_RTP_FLAG_SECURE_SEND] = 0;
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
*
*
- * switch_scheduler.c -- Switch Scheduler
+ * switch_scheduler.c -- Switch Scheduler
*
*/
if (zstr(group)) {
return 0;
}
-
+
hash = switch_ci_hashfunc_default(group, &hlen);
switch_mutex_lock(globals.task_mutex);
}
}
}
-
+
switch_core_destroy_memory_pool(&globals.memory_pool);
}
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Christopher M. Rienzo <chris@rienzo.com>
*
struct speex_context {
switch_codec_t *codec;
- speex_codec_settings_t codec_settings;
+ speex_codec_settings_t codec_settings;
unsigned int flags;
/* Encoder */
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Fanzhou Zhao <fanzhou@gmail.com> 2006-08-22 (Bugfix 2357-2358)
*
break;
}
} while (xlen < packet->header.length);
-
+
if ((uint32_t) (packet->header.length + 20) > (uint32_t) (len - bytes_left)) {
/*
* the packet length is longer than the length of all attributes?
*/
packet->header.length = (uint16_t) ((len - bytes_left) - 20);
}
-
+
return packet;
}
{
switch_stun_packet_attribute_t *attribute;
switch_stun_ip_t *ip;
-
+
attribute = (switch_stun_packet_attribute_t *) ((uint8_t *) & packet->first_attribute + ntohs(packet->header.length));
attribute->type = htons(SWITCH_STUN_ATTR_XOR_MAPPED_ADDRESS);
{
switch_stun_packet_attribute_t *attribute;
switch_stun_ip_t *ip;
-
+
attribute = (switch_stun_packet_attribute_t *) ((uint8_t *) & packet->first_attribute + ntohs(packet->header.length));
attribute->type = htons(SWITCH_STUN_ATTR_XOR_MAPPED_ADDRESS);
unsigned int elapsed = 0;
int funny = 0;
int size = sizeof(buf);
- int xlen = sizeof(switch_stun_packet_header_t);
+ int xlen = sizeof(switch_stun_packet_header_t);
switch_assert(err);
switch_core_session_t *peer_session,
switch_input_callback_function_t dtmf_callback,
void *session_data,
- void *peer_session_data)
+ void *peer_session_data)
{
switch_status_t status;
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Massimo Cetra <devel@navynet.it> - Timezone functionality
*
if (res > 900 && res < 1100) {
one_k = 1;
}
-
+
if (res > 1500) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
"Timer resolution of %ld microseconds detected!\n"
{
switch_time_t now = switch_micro_time_now();
int64_t elapsed = (now - timer->start);
-
+
timer->tick = (elapsed / timer->interval) / 1000;
timer->samplecount = (uint32_t)(timer->tick * timer->samples);
}
it->fd = fd;
-
+
return SWITCH_STATUS_SUCCESS;
}
timerfd_gettime(it->fd, &val);
diff = val.it_interval.tv_nsec / 1000;
-
+
if (diff > 0) {
/* still pending */
timer->diff = diff;
if (offset == 0) {
return switch_time_now();
} else if (offset < 0) offset = 0;
-
+
if (win32_use_qpc) {
/* Use QueryPerformanceCounter */
spec.it_interval.tv_nsec = runtime.microseconds_per_tick * 1000;
spec.it_value.tv_sec = 0;
spec.it_value.tv_nsec = 100000;
-
+
if (timerfd_settime(tfd, 0, &spec, NULL)) {
close(tfd);
tfd = -1;
runtime.profile_timer = switch_new_profile_timer();
switch_get_system_idle_time(runtime.profile_timer, &runtime.profile_time);
- if (runtime.timer_affinity > -1) {
+ if (runtime.timer_affinity > -1) {
switch_core_thread_set_cpu_affinity(runtime.timer_affinity);
}
spec.it_interval.tv_nsec = runtime.microseconds_per_tick * 1000;
timerfd_settime(tfd, 0, &spec, NULL);
}
-
+
last_MICROSECONDS_PER_TICK = runtime.microseconds_per_tick;
#endif
switch_get_system_idle_time(runtime.profile_timer, &runtime.profile_time);
profile_tick = 0;
}
-
+
if (runtime.sps <= 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Over Session Rate of %d!\n", runtime.sps_total);
}
}
sps_interval_ticks++;
-
+
if (runtime.sps_last > runtime.sps_peak_fivemin) {
runtime.sps_peak_fivemin = runtime.sps_last;
}
}
globals.use_cond_yield = 0;
-
+
for (x = (runtime.microseconds_per_tick / 1000); x <= MAX_ELEMENTS; x += (runtime.microseconds_per_tick / 1000)) {
if (TIMER_MATRIX[x].mutex && switch_mutex_trylock(TIMER_MATRIX[x].mutex) == SWITCH_STATUS_SUCCESS) {
switch_thread_cond_broadcast(TIMER_MATRIX[x].cond);
return SWITCH_STATUS_TERM;
}
-/*
+/*
This converts a struct tm to a switch_time_exp_t
We have to use UNIX structures to do our exams
and use switch_* functions for the output.
if (zstr(tz_name) || !TIMEZONES_LIST.hash) {
return NULL;
}
-
+
if ((value = switch_core_hash_find(TIMEZONES_LIST.hash, tz_name)) == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Timezone '%s' not found!\n", tz_name);
}
/*
- * This file was originally written for NetBSD and is in the public domain,
+ * This file was originally written for NetBSD and is in the public domain,
* so clarified as of 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov).
- *
+ *
* Iw was modified by Massimo Cetra in order to be used with Callweaver and Freeswitch.
*/
/* **************************************************************************
-
+
************************************************************************** */
static const char gmt[] = "GMT";
/* **************************************************************************
-
+
************************************************************************** */
}
/* **************************************************************************
-
+
************************************************************************** */
#if (_MSC_VER >= 1400) // VC8+
#define switch_assert(expr) assert(expr);__analysis_assume( expr )
}
/* **************************************************************************
-
+
************************************************************************** */
static void tztime(const time_t *const timep, const char *tzstring, struct tm *const tmp)
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Juan Jose Comellas <juanjo@comellas.org>
* Seven Du <dujinfang@gmail.com>
for (np = fb->head; np; np = np->next) {
x++;
-
+
if (!np->inuse && ((orig->packet && np->frame->packet) || (!orig->packet && !np->frame->packet))) {
if (np == fb->head) {
fb->total--;
np->prev = np->next = NULL;
break;
- }
+ }
}
-
+
if (!np) {
np = switch_core_alloc(fb->pool, sizeof(*np));
np->frame = switch_core_alloc(fb->pool, sizeof(*np->frame));
-
+
if (orig->packet) {
np->frame->packet = switch_core_alloc(fb->pool, SWITCH_RTP_MAX_BUF_LEN);
} else {
if (orig->img && !switch_test_flag(orig, SFF_ENCODED)) {
switch_img_copy(orig->img, &np->frame->img);
}
-
+
switch_mutex_unlock(fb->mutex);
return np->frame;
old_frame = *frameP;
*frameP = NULL;
-
+
node = (switch_frame_node_t *) old_frame->extra_data;
node->inuse = 0;
switch_img_free(&node->frame->img);
-
+
fb->total++;
if (fb->head) {
switch_assert(node->next != node);
switch_assert(node->prev != node);
-
+
switch_mutex_unlock(fb->mutex);
switch_assert(orig->buflen);
new_frame = find_free_frame(fb, orig);
-
+
*clone = new_frame;
return SWITCH_STATUS_SUCCESS;
break;
}
}
-
+
va_end(ap);
return r;
} else {
e = ptr + strlen(ptr);
}
-
+
mlen = (e - ptr) + 1;
if (pool) {
if (total + 2 >= ilen) {
if (ilen + DLINE_BLOCK_SIZE > DLINE_MAX_SIZE) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Single line limit reached!\n");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Single line limit reached!\n");
break;
}
//while ((c = fgetc(fd)) != EOF) {
while (fread(&c, 1, 1, fd) == 1) {
-
+
if (total + 2 >= ilen) {
if (ilen + DLINE_BLOCK_SIZE > DLINE_MAX_SIZE) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Single line limit reached!\n");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Single line limit reached!\n");
break;
}
strncmp(ip, "192.168.", 8) && /* 192.168.0.0 - 192.168.255.255 (192.168/16 prefix) */
strncmp(ip, "127.", 4) && /* 127.0.0.0 - 127.255.255.255 (127/8 prefix) */
strncmp(ip, "255.", 4) &&
- strncmp(ip, "0.", 2) &&
+ strncmp(ip, "0.", 2) &&
strncmp(ip, "1.", 2) &&
strncmp(ip, "2.", 2) &&
strncmp(ip, "172.16.", 7) && /* 172.16.0.0 - 172.31.255.255 (172.16/12 prefix) */
while ((*sp == 13 ) || (*sp == 10 ) || (*sp == 9 ) || (*sp == 32) || (*sp == 11) ) {
sp++;
}
-
+
if (zstr(sp)) {
return strdup(SWITCH_BLANK_STRING);
}
for (i = 0; i < count; ++i) {
array[i] = cleanup_separated_string(array[i], 0);
}
-
+
return count;
}
if (*buf == '^' && *(buf+1) == '^') {
char *p = buf + 2;
-
+
if (p && *p && *(p+1)) {
buf = p;
delim = *buf++;
if (sock == SWITCH_SOCK_INVALID) {
return SWITCH_SOCK_INVALID;
- }
+ }
pfds[0].fd = sock;
if ((flags & SWITCH_POLL_PRI)) {
pfds[0].events |= POLLPRI;
}
-
+
s = poll(pfds, 1, ms);
if (s < 0) {
int s = 0, r = 0, i;
pfds = calloc(len, sizeof(struct pollfd));
-
+
for (i = 0; i < len; i++) {
if (waitlist[i].sock == SWITCH_SOCK_INVALID) {
break;
}
pfds[i].fd = waitlist[i].sock;
-
+
if ((waitlist[i].events & SWITCH_POLL_READ)) {
pfds[i].events |= POLLIN;
}
pfds[i].events |= POLLPRI;
}
}
-
+
s = poll(pfds, len, ms);
if (s < 0) {
/* Wouldn't you rather know?? */
assert(sock <= FD_SETSIZE);
#endif
-
+
if ((flags & SWITCH_POLL_READ)) {
#ifdef WIN32
#pragma warning( push )
#pragma warning( disable : 4127 )
FD_SET(sock, rfds);
-#pragma warning( pop )
+#pragma warning( pop )
#else
FD_SET(sock, rfds);
#endif
#pragma warning( push )
#pragma warning( disable : 4127 )
FD_SET(sock, wfds);
-#pragma warning( pop )
+#pragma warning( pop )
#else
FD_SET(sock, wfds);
#endif
#pragma warning( push )
#pragma warning( disable : 4127 )
FD_SET(sock, efds);
-#pragma warning( pop )
+#pragma warning( pop )
#else
FD_SET(sock, efds);
#endif
tv.tv_sec = ms / 1000;
tv.tv_usec = (ms % 1000) * ms;
-
+
s = select(sock + 1, (flags & SWITCH_POLL_READ) ? rfds : NULL, (flags & SWITCH_POLL_WRITE) ? wfds : NULL, (flags & SWITCH_POLL_ERROR) ? efds : NULL, &tv);
if (s < 0) {
assert(waitlist[i].sock <= FD_SETSIZE);
#endif
flags |= waitlist[i].events;
-
+
if ((waitlist[i].events & SWITCH_POLL_READ)) {
#ifdef WIN32
#pragma warning( push )
#pragma warning( disable : 4127 )
FD_SET(waitlist[i].sock, rfds);
-#pragma warning( pop )
+#pragma warning( pop )
#else
FD_SET(waitlist[i].sock, rfds);
#endif
#pragma warning( push )
#pragma warning( disable : 4127 )
FD_SET(waitlist[i].sock, wfds);
-#pragma warning( pop )
+#pragma warning( pop )
#else
FD_SET(waitlist[i].sock, wfds);
#endif
#pragma warning( push )
#pragma warning( disable : 4127 )
FD_SET(waitlist[i].sock, efds);
-#pragma warning( pop )
+#pragma warning( pop )
#else
FD_SET(waitlist[i].sock, efds);
#endif
tv.tv_sec = ms / 1000;
tv.tv_usec = (ms % 1000) * ms;
-
+
s = select(max_fd + 1, (flags & SWITCH_POLL_READ) ? rfds : NULL, (flags & SWITCH_POLL_WRITE) ? wfds : NULL, (flags & SWITCH_POLL_ERROR) ? efds : NULL, &tv);
if (s < 0) {
SWITCH_DECLARE(int) switch_dow_str2int(const char *exp) {
int ret = -1;
int x;
-
+
for (x = 0; x < switch_arraylen(DOW); x++) {
if (!strncasecmp(DOW[x], exp, 3)) {
ret = x + 1;
DOW_COMA = ','
} dow_t;
-static inline dow_t _dow_read_token(const char **s)
+static inline dow_t _dow_read_token(const char **s)
{
int i;
-
+
if (**s == '-') {
(*s)++;
return DOW_HYPHEN;
{
dow_t cur, prev = DOW_EOF, range_start = DOW_EOF;
const char *p = exp;
-
+
while ((cur = _dow_read_token(&p)) != DOW_EOF) {
if (cur == DOW_COMA) {
/* Reset state */
- cur = prev = DOW_EOF;
+ cur = prev = DOW_EOF;
} else if (cur == DOW_HYPHEN) {
/* Save the previous token and move to the next one */
range_start = prev;
return SWITCH_TRUE;
}
}
-
+
prev = cur;
}
}
len = strlen(p);
-
+
/* region 1, TBD add more....*/
if (len == 11 && p[0] == '1') {
r = switch_mprintf("%c (%c%c%c) %c%c%c-%c%c%c%c", p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8],p[9],p[10]);
} else if (node->type == GUMBO_NODE_ELEMENT && node->v.element.tag != GUMBO_TAG_SCRIPT && node->v.element.tag != GUMBO_TAG_STYLE) {
GumboVector *children = &node->v.element.children;
int i;
-
+
if (node->v.element.tag != GUMBO_TAG_UNKNOWN && node->v.element.tag <= GUMBO_TAG_LAST) {
GumboAttribute* attr = NULL;
const char *aval = NULL;
-
+
if (node->v.element.tag == GUMBO_TAG_SPAN) {
if ((attr = gumbo_get_attribute(&node->v.element.attributes, "class"))) {
aval = attr->value;
len++;
}
}
-
+
for (x = 0; x < len*2; x++) {
stream->write_function(stream, "%s", " ");
}
} else {
for (i = 0; i < children->length; ++i) {
- process((GumboNode*) children->data[i], stream);
+ process((GumboNode*) children->data[i], stream);
}
}
if (!strncasecmp(p, "Content-Type:", 13)) {
got_ct++;
}
-
+
if (!got_ct) continue;
if (*p == '\n') {
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Michael Jerris <mike@jerris.com>
* Paul D. Tinsley <pdt at jackhammer.org>
#define __IS_VP8_KEY_FRAME(byte) !(((byte) & 0x01))
-static inline int IS_VP8_KEY_FRAME(uint8_t *data)
+static inline int IS_VP8_KEY_FRAME(uint8_t *data)
{
uint8_t S;
uint8_t DES;
if (X & 0x40) data++; // L
if (X & 0x30) data++; // T/K
}
-
+
if (S && (PID == 0)) {
return __IS_VP8_KEY_FRAME(*data);
} else {
return SWITCH_STATUS_FALSE;
}
-
+
context->last_ts = 0;
context->last_received_timestamp = 0;
context->last_received_complete_picture = 0;
int token_parts = 1;
int cpus = switch_core_cpu_count();
int sane, threads = 1;
-
+
if (!context->codec_settings.video.width) {
context->codec_settings.video.width = 1280;
}
if (context->codec_settings.video.bandwidth == -1) {
context->codec_settings.video.bandwidth = 0;
}
-
+
if (context->codec_settings.video.bandwidth) {
context->bandwidth = context->codec_settings.video.bandwidth;
} else {
context->pkt = NULL;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(codec->session), SWITCH_LOG_NOTICE,
- "VPX reset encoder picture from %dx%d to %dx%d %u BW\n",
+ "VPX reset encoder picture from %dx%d to %dx%d %u BW\n",
config->g_w, config->g_h, context->codec_settings.video.width, context->codec_settings.video.height, context->bandwidth);
context->start_time = switch_micro_time_now();
-
+
config->g_timebase.num = 1;
config->g_timebase.den = 1000;
config->g_pass = VPX_RC_ONE_PASS;
config->g_w = context->codec_settings.video.width;
- config->g_h = context->codec_settings.video.height;
+ config->g_h = context->codec_settings.video.height;
config->rc_target_bitrate = context->bandwidth;
config->g_lag_in_frames = 0;
config->kf_max_dist = 360;//2000;
threads = cpus / 4;
if (threads < 1) threads = 1;
config->g_threads = threads;
-
+
if (context->is_vp9) {
//config->rc_dropframe_thresh = 2;
token_parts = (cpus > 1) ? 3 : 0;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec %s init error: [%d:%s]\n", vpx_codec_iface_name(context->encoder_interface), context->encoder.err, context->encoder.err_detail);
return SWITCH_STATUS_FALSE;
}
-
+
context->encoder_init = 1;
if (context->is_vp9) {
//Set cpu usage, a bit lower than normal (-6) but higher than android (-12)
vpx_codec_control(&context->encoder, VP8E_SET_CPUUSED, -6);
vpx_codec_control(&context->encoder, VP8E_SET_TOKEN_PARTITIONS, token_parts);
-
+
// Enable noise reduction
vpx_codec_control(&context->encoder, VP8E_SET_NOISE_SENSITIVITY, 1);
//Set max data rate for Intra frames.
context->need_key_frame = 3;
}
-
+
if (!context->encoder_init) {
if (init_encoder(codec) != SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_FALSE;
context->enc_iter = NULL;
context->last_ts = frame->timestamp;
context->last_ms = now;
-
+
return consume_partition(context, frame);
}
#if 0
int key = 0;
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,
"VIDEO VPX: seq: %d ts: %u len: %ld %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x mark: %d\n",
frame->seq, frame->timestamp, frame->datalen,
*((uint8_t *)data), *((uint8_t *)data + 1),
*((uint8_t *)data + 10), frame->m);
#endif
-
+
DES = *data;
data++;
S = (DES & 0x10);
// PID = DES & 0x07;
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "DATA LEN %d S BIT %d PID: %d\n", frame->datalen, S, PID);
-
+
if (DES & 0x80) { // X
uint8_t X = *data;
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "X BIT SET\n");
len = frame->datalen - (data - (uint8_t *)frame->data);
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "POST PARSE: DATA LEN %d KEY %d KEYBYTE = %0x\n", len, key, *data);
-
+
if (len <= 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid packet %d\n", len);
return SWITCH_STATUS_RESTART;
init_decoder(codec);
context->need_decoder_reset = 0;
}
-
+
if (!context->decoder_init) {
init_decoder(codec);
}
}
decoder = &context->decoder;
-
+
// switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "len: %d ts: %u mark:%d\n", frame->datalen, frame->timestamp, frame->m);
// context->last_received_timestamp = frame->timestamp;
if (is_start) {
context->got_start_frame = 1;
}
-
+
if (is_keyframe) {
if (context->got_key_frame <= 0) {
context->got_key_frame = 1;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "VPX control error!\n");
switch_goto_status(SWITCH_STATUS_RESTART, end);
}
-
+
if (corrupted) {
frame->img = NULL;
#ifdef DEBUG_VP9
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "decoded: %dx%d\n", frame->img->d_w, frame->img->d_h);
#endif
}
-
+
switch_buffer_zero(context->vpx_packet_buffer);
-
+
if (!frame->img) {
//context->need_decoder_reset = 1;
context->got_key_frame = 0;
}
-static switch_status_t switch_vpx_control(switch_codec_t *codec,
- switch_codec_control_command_t cmd,
+static switch_status_t switch_vpx_control(switch_codec_t *codec,
+ switch_codec_control_command_t cmd,
switch_codec_control_type_t ctype,
void *cmd_data,
switch_codec_control_type_t atype,
void *cmd_arg,
switch_codec_control_type_t *rtype,
- void **ret_data)
+ void **ret_data)
{
vpx_context_t *context = (vpx_context_t *)codec->private_info;
}
break;
case SCC_VIDEO_GEN_KEYFRAME:
- context->need_key_frame = 1;
+ context->need_key_frame = 1;
break;
case SCC_VIDEO_BANDWIDTH:
{
vpx_context_t *context = (vpx_context_t *)codec->private_info;
if (context) {
-
+
switch_img_free(&context->patch_img);
if ((codec->flags & SWITCH_CODEC_FLAG_ENCODE)) {
char *s;
s = (char *) switch_must_malloc(SWITCH_XML_BUFSIZE);
-
+
do {
len += (l = fread((s + len), 1, SWITCH_XML_BUFSIZE, fp));
if (l == SWITCH_XML_BUFSIZE) {
if (switch_is_number(cacheable)) {
int cache_ms = atol(cacheable);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "caching lookup for user %s@%s for %d milliseconds\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "caching lookup for user %s@%s for %d milliseconds\n",
user_name, domain_name, cache_ms);
time_now = switch_micro_time_now();
expires = time_now + (cache_ms * 1000);
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Mathieu Rene <mathieu.rene@gmail.com>
*
*
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Michael Jerris <mike@jerris.com>
* Pawel Pierscionek <pawel@voiceworks.pl>
for(i = 1; i < argc; i++) {
if (!strstr(argv[i], "-")) break;
-
+
if (!strcmp(argv[i], "-v")) {
verbose = SWITCH_TRUE;
}
);
return 255;
}
-
+
file = argv[i];
script = argv[i+1];
printf("Cannot init mod_sndfile [%s]\n", err);
fail();
}
-
+
if (switch_core_file_open(&fh, file, c, rate, file_flags, NULL) != SWITCH_STATUS_SUCCESS) {
printf("Cannot open file %s\n", file);
fail();
}
-
+
teletone_init_session(&ts, 0, teletone_handler, &fh);
ts.rate = rate;
ts.channels = c;
teletone_run(&ts, script);
teletone_destroy_session(&ts);
switch_core_file_close(&fh);
-
+
printf("File: %s generated...\n\nPlease support:\nFreeSWITCH http://www.freeswitch.org\nClueCon http://www.cluecon.com\n", file);
end: