Merge branch 'master' into v1.2.stable

Conflicts:
	configure.in
This commit is contained in:
Ken Rice
2013-03-01 14:18:40 -06:00
71 changed files with 11024 additions and 524 deletions
+13 -9
View File
@@ -138,6 +138,7 @@ SWITCH_BEGIN_EXTERN_C
#define SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE "proto_specific_hangup_cause"
#define SWITCH_TRANSFER_HISTORY_VARIABLE "transfer_history"
#define SWITCH_TRANSFER_SOURCE_VARIABLE "transfer_source"
#define SWITCH_SENSITIVE_DTMF_VARIABLE "sensitive_dtmf"
#define SWITCH_CHANNEL_EXECUTE_ON_ANSWER_VARIABLE "execute_on_answer"
#define SWITCH_CHANNEL_EXECUTE_ON_PRE_ANSWER_VARIABLE "execute_on_pre_answer"
@@ -246,7 +247,8 @@ typedef enum {
typedef enum {
DTMF_FLAG_SKIP_PROCESS = (1 << 0)
DTMF_FLAG_SKIP_PROCESS = (1 << 0),
DTMF_FLAG_SENSITIVE = (1 << 1)
} dtmf_flag_t;
typedef struct {
@@ -1480,7 +1482,8 @@ SMBF_WRITE_STREAM - Include the Write Stream
SMBF_WRITE_REPLACE - Replace the Write Stream
SMBF_READ_REPLACE - Replace the Read Stream
SMBF_STEREO - Record in stereo
SMBF_ANSWER_RECORD_REQ - Don't record until the channel is answered
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 -
@@ -1496,13 +1499,14 @@ typedef enum {
SMBF_READ_PING = (1 << 4),
SMBF_STEREO = (1 << 5),
SMBF_ANSWER_REQ = (1 << 6),
SMBF_THREAD_LOCK = (1 << 7),
SMBF_PRUNE = (1 << 8),
SMBF_NO_PAUSE = (1 << 9),
SMBF_STEREO_SWAP = (1 << 10),
SMBF_LOCK = (1 << 11),
SMBF_TAP_NATIVE_READ = (1 << 12),
SMBF_TAP_NATIVE_WRITE = (1 << 13)
SMBF_BRIDGE_REQ = (1 << 7),
SMBF_THREAD_LOCK = (1 << 8),
SMBF_PRUNE = (1 << 9),
SMBF_NO_PAUSE = (1 << 10),
SMBF_STEREO_SWAP = (1 << 11),
SMBF_LOCK = (1 << 12),
SMBF_TAP_NATIVE_READ = (1 << 13),
SMBF_TAP_NATIVE_WRITE = (1 << 14)
} switch_media_bug_flag_enum_t;
typedef uint32_t switch_media_bug_flag_t;
+12 -4
View File
@@ -919,11 +919,19 @@ SWITCH_DECLARE(char *) switch_find_end_paren(const char *s, char open, char clos
static inline switch_bool_t switch_is_file_path(const char *file)
{
const char *e;
int r;
int r, x;
if (*file == '[' && *(file + 1) == *SWITCH_PATH_SEPARATOR) {
if ((e = switch_find_end_paren(file, '[', ']'))) {
file = e + 1;
for (x = 0; x < 2; x++) {
if (*file == '[' && *(file + 1) == *SWITCH_PATH_SEPARATOR) {
if ((e = switch_find_end_paren(file, '[', ']'))) {
file = e + 1;
}
} else if (*file == '{') {
if ((e = switch_find_end_paren(file, '{', '}'))) {
file = e + 1;
}
} else {
break;
}
}
#ifdef WIN32
+2 -4
View File
@@ -187,13 +187,11 @@ static switch_bool_t avmd_callback(switch_media_bug_t * bug, void *user_data, sw
break;
case SWITCH_ABC_TYPE_READ_PING:
break;
case SWITCH_ABC_TYPE_CLOSE:
break;
case SWITCH_ABC_TYPE_READ:
break;
case SWITCH_ABC_TYPE_WRITE:
case SWITCH_ABC_TYPE_TAP_NATIVE_READ:
case SWITCH_ABC_TYPE_TAP_NATIVE_WRITE:
break;
case SWITCH_ABC_TYPE_READ_REPLACE:
+464 -1
View File
@@ -24,6 +24,7 @@
* Contributor(s):
*
* Rupa Schomaker <rupa@rupa.com>
* Yossi Neiman <mishehu@freeswitch.org>
*
* mod_curl.c -- API for performing http queries
*
@@ -32,6 +33,12 @@
#include <switch.h>
#include <switch_curl.h>
#include <json.h>
#ifdef _MSC_VER
#include <WinSock2.h>
#else
#include <sys/socket.h>
#endif
/* Prototypes */
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_curl_shutdown);
@@ -45,10 +52,19 @@ SWITCH_MODULE_DEFINITION(mod_curl, mod_curl_load, mod_curl_shutdown, NULL);
static char *SYNTAX = "curl url [headers|json|content-type <mime-type>] [get|head|post [post_data]]";
#define HTTP_SENDFILE_ACK_EVENT "curl_sendfile::ack"
#define HTTP_SENDFILE_RESPONSE_SIZE 32768
static struct {
switch_memory_pool_t *pool;
} globals;
typedef enum {
CSO_NONE = (1 << 0),
CSO_EVENT = (1 << 1),
CSO_STREAM = (1 << 2)
} curlsendfile_output_t;
struct http_data_obj {
switch_stream_handle_t stream;
switch_size_t bytes;
@@ -61,6 +77,29 @@ struct http_data_obj {
};
typedef struct http_data_obj http_data_t;
struct http_sendfile_data_obj {
switch_memory_pool_t *pool;
switch_file_t *file_handle;
long http_response_code;
char *http_response;
switch_curl_slist_t *headers;
char *mydata;
char *url;
char *identifier_str;
char *filename_element;
char *filename_element_name;
char *extrapost_elements;
switch_CURL *curl_handle;
struct curl_httppost *formpost;
struct curl_httppost *lastptr;
uint8_t flags; /* This is for where to send output of the curl_sendfile commands */
switch_stream_handle_t *stream;
char *sendfile_response;
switch_size_t sendfile_response_count;
};
typedef struct http_sendfile_data_obj http_sendfile_data_t;
struct callback_obj {
switch_memory_pool_t *pool;
char *name;
@@ -230,6 +269,427 @@ static char *print_json(switch_memory_pool_t *pool, http_data_t *http_data)
return data;
}
static size_t http_sendfile_response_callback(void *ptr, size_t size, size_t nmemb, void *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_copy_string(&http_data->sendfile_response[http_data->sendfile_response_count], ptr, (realsize+1));
http_data->sendfile_response_count += realsize;
}
else
{
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;
}
// This function and do_lookup_url functions could possibly be merged together. Or at least have do_lookup_url call this up as part of the initialization routine as it is a subset of the operations.
static void http_sendfile_initialize_curl(http_sendfile_data_t *http_data)
{
uint8_t count;
http_data->curl_handle = curl_easy_init();
if (!strncasecmp(http_data->url, "https", 5))
{
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
* 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 */
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)
curl_formadd(&http_data->formpost, &http_data->lastptr, CURLFORM_COPYNAME, argv2[0], CURLFORM_COPYCONTENTS, argv2[1], CURLFORM_END);
}
}
/* 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 */
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);
}
static switch_status_t http_sendfile_test_file_open(http_sendfile_data_t *http_data, switch_event_t *event)
{
switch_status_t retval = switch_file_open(&http_data->file_handle, http_data->filename_element, SWITCH_FOPEN_READ, SWITCH_FPROT_UREAD,http_data->pool);
if(retval != SWITCH_STATUS_SUCCESS)
{
if(switch_test_flag(http_data, CSO_EVENT))
{
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, HTTP_SENDFILE_ACK_EVENT) == SWITCH_STATUS_SUCCESS)
{
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", "Failure");
switch_event_fire(&event);
switch_event_destroy(&event);
}
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;
}
static void http_sendfile_success_report(http_sendfile_data_t *http_data, switch_event_t *event)
{
if(switch_test_flag(http_data, CSO_EVENT))
{
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, HTTP_SENDFILE_ACK_EVENT) == SWITCH_STATUS_SUCCESS)
{
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);
}
#define HTTP_SENDFILE_APP_SYNTAX "<url> <filenameParamName=filepath> [nopost|postparam1=foo&postparam2=bar... [event|none [identifier ]]]"
SWITCH_STANDARD_APP(http_sendfile_app_function)
{
switch_event_t *event = NULL;
char *argv[10] = { 0 }, *argv2[10] = { 0 };
int argc = 0, argc2 = 0;
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])))))
{
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]);
http_data->filename_element = switch_core_strdup(pool, argv2[1]);
}
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))
http_data->identifier_str = switch_core_session_get_uuid(session);
else
http_data->identifier_str = switch_core_strdup(pool, argv[i++]);
}
}
}
}
}
else
{
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_EVENT);
else if(!strncasecmp(send_output, "none", 4))
switch_set_flag(http_data, CSO_NONE);
else
{
switch_set_flag(http_data, CSO_NONE);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Invalid parameter %s specified for curl_sendfile_report. Setting default of 'none'.\n", send_output);
}
}
else
{
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 = switch_core_session_get_uuid(session);
else if(!zstr(identifier))
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 && http_data->headers)
{
switch_curl_slist_free_all(http_data->headers);
}
return;
}
#define HTTP_SENDFILE_SYNTAX "<url> <filenameParamName=filepath> [nopost|postparam1=foo&postparam2=bar... [event|stream|both|none [identifier ]]]"
SWITCH_STANDARD_API(http_sendfile_function)
{
switch_status_t status;
switch_bool_t new_memory_pool = SWITCH_FALSE;
char *argv[10] = { 0 }, *argv2[10] = { 0 };
int argc = 0, argc2 = 0;
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;
goto http_sendfile_usage;
}
if(session)
{
pool = switch_core_session_get_pool(session);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "We're using a session's memory pool for curl_sendfile. Maybe we should consider always making a new memory pool?\n");
}
else
{
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])))))
{
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]);
http_data->filename_element = switch_core_strdup(pool, argv2[1]);
}
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))
switch_set_flag(http_data, CSO_EVENT);
else if(!strncasecmp(argv[i], "stream", 6))
switch_set_flag(http_data, CSO_STREAM);
else if(!strncasecmp(argv[i], "both", 4))
{
switch_set_flag(http_data, CSO_EVENT);
switch_set_flag(http_data, CSO_STREAM);
}
else
{
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;
http_sendfile_usage:
stream->write_function(stream, "-USAGE\n%s\n", HTTP_SENDFILE_SYNTAX);
goto http_sendfile_done;
http_sendfile_done:
if (http_data && http_data->headers)
{
switch_curl_slist_free_all(http_data->headers);
}
if (new_memory_pool == SWITCH_TRUE)
{
switch_core_destroy_memory_pool(&pool);
}
return status;
}
SWITCH_STANDARD_APP(curl_app_function)
{
switch_status_t status = SWITCH_STATUS_SUCCESS;
@@ -430,7 +890,10 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_curl_load)
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);
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}
+21 -1
View File
@@ -166,6 +166,7 @@ struct http_file_context {
int samples;
switch_file_handle_t fh;
char *cache_file;
char *cache_file_base;
char *meta_file;
char *lock_file;
char *metadata;
@@ -2308,6 +2309,7 @@ static char *load_cache_data(http_file_context_t *context, const char *url)
}
}
context->cache_file_base = switch_core_sprintf(context->pool, "%s%s%s", globals.cache_path, SWITCH_PATH_SEPARATOR, digest);
context->cache_file = switch_core_sprintf(context->pool, "%s%s%s.%s", globals.cache_path, SWITCH_PATH_SEPARATOR, digest, ext);
context->meta_file = switch_core_sprintf(context->pool, "%s.meta", context->cache_file);
context->lock_file = switch_core_sprintf(context->pool, "%s.lock", context->cache_file);
@@ -2511,7 +2513,7 @@ static switch_status_t write_meta_file(http_file_context_t *context, const char
}
switch_snprintf(write_data, sizeof(write_data),
"%" SWITCH_TIME_T_FMT ":%s",
"%" TIME_T_FMT ":%s",
switch_epoch_time_now(NULL) + ttl,
data);
@@ -2573,6 +2575,9 @@ static switch_status_t locate_url_file(http_file_context_t *context, const char
lock_file(context, SWITCH_TRUE);
if (!context->url_params || !switch_true(switch_event_get_header(context->url_params, "nohead"))) {
const char *ct = NULL;
const char *newext = NULL;
if ((status = fetch_cache_data(context, url, &headers, NULL)) != SWITCH_STATUS_SUCCESS) {
if (status == SWITCH_STATUS_NOTFOUND) {
unreachable = 2;
@@ -2584,6 +2589,21 @@ static switch_status_t locate_url_file(http_file_context_t *context, const char
}
}
if ((!context->url_params || !switch_event_get_header(context->url_params, "ext"))
&& headers && (ct = switch_event_get_header(headers, "content-type"))) {
if (!strcasecmp(ct, "audio/mpeg")) {
newext = "mp3";
} else if (!strcasecmp(ct, "audio/wav")) {
newext = "wav";
}
}
if (newext) {
context->cache_file = switch_core_sprintf(context->pool, "%s.%s", context->cache_file, newext);
}
if (switch_file_exists(context->cache_file, context->pool) != SWITCH_STATUS_SUCCESS && unreachable) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "File at url [%s] is unreachable!\n", url);
goto end;
+29 -11
View File
@@ -342,9 +342,15 @@ static char *get_bridge_data(switch_memory_pool_t *pool, char *dialed_number, ch
static profile_t *locate_profile(const char *profile_name)
{
profile_t *profile = NULL;
if (zstr(profile_name)) {
profile = globals.default_profile;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "profile_name is empty\n");
if (globals.default_profile) {
profile = globals.default_profile;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "using default_profile\n");
} else if ((profile = switch_core_hash_find(globals.profile_hash, "default"))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "no default set, using profile named \"default\"\n");
}
} else if (!(profile = switch_core_hash_find(globals.profile_hash, profile_name))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error invalid profile %s\n", profile_name);
}
@@ -1367,18 +1373,31 @@ static switch_call_cause_t lcr_outgoing_channel(switch_core_session_t *session,
const char *intralata = NULL;
switch_core_session_t *mysession = NULL, *locked_session = NULL;
switch_channel_t *channel = NULL;
dest = strdup(outbound_profile->destination_number);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Entering lcr endpoint for %s\n", dest);
if (!dest) {
goto done;
}
int argc;
char *argv[32] = { 0 };
char *mydata = NULL;
switch_core_new_memory_pool(&pool);
routes.pool = pool;
if (!outbound_profile->destination_number) {
goto done;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Entering lcr endpoint for %s\n", outbound_profile->destination_number);
mydata = switch_core_strdup(pool, outbound_profile->destination_number);
if ((argc = switch_separate_string(mydata, '/', argv, (sizeof(argv) / sizeof(argv[0]))))) {
if (argc > 1) {
lcr_profile = switch_core_strdup(pool, argv[0]);
dest = switch_core_strdup(pool, argv[1]);
}
}
if (!dest) {
dest = outbound_profile->destination_number;
}
if (var_event && (skip = switch_event_get_header(var_event, "lcr_recurse_variables")) && switch_false(skip)) {
if ((var = switch_event_get_header(var_event, SWITCH_CALL_TIMEOUT_VARIABLE)) || (var = switch_event_get_header(var_event, "leg_timeout"))) {
timelimit = atoi(var);
@@ -1516,7 +1535,6 @@ static switch_call_cause_t lcr_outgoing_channel(switch_core_session_t *session,
}
lcr_destroy(routes.head);
switch_core_destroy_memory_pool(&pool);
switch_safe_free(dest);
if (cause == SWITCH_CAUSE_NONE) {
cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
+2
View File
@@ -210,6 +210,8 @@ static switch_bool_t vmd_callback(switch_media_bug_t *bug, void *user_data, swit
case SWITCH_ABC_TYPE_CLOSE:
case SWITCH_ABC_TYPE_READ:
case SWITCH_ABC_TYPE_WRITE:
case SWITCH_ABC_TYPE_TAP_NATIVE_READ:
case SWITCH_ABC_TYPE_TAP_NATIVE_WRITE:
break;
case SWITCH_ABC_TYPE_READ_REPLACE:
+1 -2
View File
@@ -4685,9 +4685,8 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
* Handle params, strip them off the destination and add them to the
* invite contact.
*
* TODO:
* - Add parameters back to destination url?
*/
if ((params = strchr(dest, ';'))) {
char *tp_param;
+1 -1
View File
@@ -1046,7 +1046,7 @@ void sofia_presence_set_hash_key(char *hash_key, int32_t len, sip_t const *sip);
void sofia_glue_sql_close(sofia_profile_t *profile, time_t prune);
int sofia_glue_init_sql(sofia_profile_t *profile);
char *sofia_overcome_sip_uri_weakness(switch_core_session_t *session, const char *uri, const sofia_transport_t transport, switch_bool_t uri_only,
const char *params);
const char *params, const char *invite_tel_params);
switch_bool_t sofia_glue_execute_sql_callback(sofia_profile_t *profile, switch_mutex_t *mutex, char *sql, switch_core_db_callback_func_t callback,
void *pdata);
char *sofia_glue_execute_sql2str(sofia_profile_t *profile, switch_mutex_t *mutex, char *sql, char *resbuf, size_t len);
+1 -1
View File
@@ -8060,7 +8060,7 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
}
tmp = sofia_overcome_sip_uri_weakness(session, url, transport, SWITCH_TRUE, NULL);
tmp = sofia_overcome_sip_uri_weakness(session, url, transport, SWITCH_TRUE, NULL, NULL);
if ((at = strchr(tmp, '@'))) {
url = switch_core_session_sprintf(session, "sip:%s%s", user, at);
+21 -6
View File
@@ -1447,12 +1447,13 @@ void sofia_glue_get_addr(msg_t *msg, char *buf, size_t buflen, int *port)
}
char *sofia_overcome_sip_uri_weakness(switch_core_session_t *session, const char *uri, const sofia_transport_t transport, switch_bool_t uri_only,
const char *params)
const char *params, const char *invite_tel_params)
{
char *stripped = switch_core_session_strdup(session, uri);
char *new_uri = NULL;
char *p;
stripped = sofia_glue_get_url_from_contact(stripped, 0);
/* remove our params so we don't make any whiny moronic device piss it's pants and forget who it is for a half-hour */
@@ -1496,6 +1497,18 @@ char *sofia_overcome_sip_uri_weakness(switch_core_session_t *session, const char
}
}
if (!zstr(invite_tel_params)) {
char *lhs, *rhs = strchr(new_uri, '@');
if (!zstr(rhs)) {
*rhs++ = '\0';
lhs = new_uri;
new_uri = switch_core_session_sprintf(session, "%s;%s@%s", lhs, invite_tel_params, rhs);
}
}
return new_uri;
}
@@ -2191,6 +2204,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
const char *screen = "no";
const char *invite_params = switch_channel_get_variable(tech_pvt->channel, "sip_invite_params");
const char *invite_to_params = switch_channel_get_variable(tech_pvt->channel, "sip_invite_to_params");
const char *invite_tel_params = switch_channel_get_variable(switch_core_session_get_channel(session), "sip_invite_tel_params");
const char *invite_to_uri = switch_channel_get_variable(tech_pvt->channel, "sip_invite_to_uri");
const char *invite_from_uri = switch_channel_get_variable(tech_pvt->channel, "sip_invite_from_uri");
const char *invite_contact_params = switch_channel_get_variable(tech_pvt->channel, "sip_invite_contact_params");
@@ -2199,6 +2213,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
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)) {
@@ -2335,10 +2350,10 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
}
}
url_str = sofia_overcome_sip_uri_weakness(session, url, tech_pvt->transport, SWITCH_TRUE, invite_params);
invite_contact = sofia_overcome_sip_uri_weakness(session, tech_pvt->invite_contact, tech_pvt->transport, SWITCH_FALSE, invite_contact_params);
from_str = sofia_overcome_sip_uri_weakness(session, invite_from_uri ? invite_from_uri : use_from_str, 0, SWITCH_TRUE, invite_from_params);
to_str = sofia_overcome_sip_uri_weakness(session, invite_to_uri ? invite_to_uri : tech_pvt->dest_to, 0, SWITCH_FALSE, invite_to_params);
url_str = sofia_overcome_sip_uri_weakness(session, url, tech_pvt->transport, SWITCH_TRUE, invite_params, invite_tel_params);
invite_contact = sofia_overcome_sip_uri_weakness(session, tech_pvt->invite_contact, tech_pvt->transport, SWITCH_FALSE, invite_contact_params, NULL);
from_str = sofia_overcome_sip_uri_weakness(session, invite_from_uri ? invite_from_uri : use_from_str, 0, SWITCH_TRUE, invite_from_params, NULL);
to_str = sofia_overcome_sip_uri_weakness(session, invite_to_uri ? invite_to_uri : tech_pvt->dest_to, 0, SWITCH_FALSE, invite_to_params, NULL);
switch_channel_set_variable(channel, "sip_outgoing_contact_uri", invite_contact);
@@ -2603,7 +2618,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
dst = sofia_glue_get_destination(tech_pvt->dest);
if (dst->route_uri) {
route_uri = sofia_overcome_sip_uri_weakness(tech_pvt->session, dst->route_uri, tech_pvt->transport, SWITCH_TRUE, NULL);
route_uri = sofia_overcome_sip_uri_weakness(tech_pvt->session, dst->route_uri, tech_pvt->transport, SWITCH_TRUE, NULL, NULL);
}
if (dst->route) {
+2 -1
View File
@@ -2700,6 +2700,7 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
const char *from_id = NULL, *from_name = NULL;
const char *to_user = switch_str_nil(switch_event_get_header(helper->event, "variable_sip_to_user"));
const char *from_user = switch_str_nil(switch_event_get_header(helper->event, "variable_sip_from_user"));
const char *disable_early = switch_str_nil(switch_event_get_header(helper->event, "variable_presence_disable_early"));
char *clean_to_user = NULL;
char *clean_from_user = NULL;
int force_status = 0;
@@ -2844,7 +2845,7 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
}
if (sofia_test_pflag(profile, PFLAG_PRESENCE_DISABLE_EARLY) &&
if ((sofia_test_pflag(profile, PFLAG_PRESENCE_DISABLE_EARLY) || switch_true(disable_early)) &&
(!zstr(call_info_state) && (!strcasecmp(call_info_state, "alterting") || !strcasecmp(call_info_state, "progressing")))) {
goto end;
}
@@ -1120,6 +1120,16 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_TRANSFER_SOURCE_VARIABLE_get() {
}
SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_SENSITIVE_DTMF_VARIABLE_get() {
char * jresult ;
char *result = 0 ;
result = (char *)("sensitive_dtmf");
jresult = SWIG_csharp_string_callback((const char *)result);
return jresult;
}
SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_CHANNEL_EXECUTE_ON_ANSWER_VARIABLE_get() {
char * jresult ;
char *result = 0 ;
@@ -7103,6 +7113,30 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_media_bug_get_write_replace_fra
}
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_media_bug_get_native_read_frame(void * jarg1) {
void * jresult ;
switch_media_bug_t *arg1 = (switch_media_bug_t *) 0 ;
switch_frame_t *result = 0 ;
arg1 = (switch_media_bug_t *)jarg1;
result = (switch_frame_t *)switch_core_media_bug_get_native_read_frame(arg1);
jresult = (void *)result;
return jresult;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_core_media_bug_get_native_write_frame(void * jarg1) {
void * jresult ;
switch_media_bug_t *arg1 = (switch_media_bug_t *) 0 ;
switch_frame_t *result = 0 ;
arg1 = (switch_media_bug_t *)jarg1;
result = (switch_frame_t *)switch_core_media_bug_get_native_write_frame(arg1);
jresult = (void *)result;
return jresult;
}
SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_media_bug_set_write_replace_frame(void * jarg1, void * jarg2) {
switch_media_bug_t *arg1 = (switch_media_bug_t *) 0 ;
switch_frame_t *arg2 = (switch_frame_t *) 0 ;
@@ -12344,6 +12378,34 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_cache_db_execute_sql_event_callback(voi
}
SWIGEXPORT void SWIGSTDCALL CSharp_switch_sql_queue_manger_execute_sql_callback(void * jarg1, char * jarg2, void * jarg3, void * jarg4) {
switch_sql_queue_manager_t *arg1 = (switch_sql_queue_manager_t *) 0 ;
char *arg2 = (char *) 0 ;
switch_core_db_callback_func_t arg3 = (switch_core_db_callback_func_t) 0 ;
void *arg4 = (void *) 0 ;
arg1 = (switch_sql_queue_manager_t *)jarg1;
arg2 = (char *)jarg2;
arg3 = (switch_core_db_callback_func_t)jarg3;
arg4 = (void *)jarg4;
switch_sql_queue_manger_execute_sql_callback(arg1,(char const *)arg2,arg3,arg4);
}
SWIGEXPORT void SWIGSTDCALL CSharp_switch_sql_queue_manger_execute_sql_event_callback(void * jarg1, char * jarg2, void * jarg3, void * jarg4) {
switch_sql_queue_manager_t *arg1 = (switch_sql_queue_manager_t *) 0 ;
char *arg2 = (char *) 0 ;
switch_core_db_event_callback_func_t arg3 = (switch_core_db_event_callback_func_t) 0 ;
void *arg4 = (void *) 0 ;
arg1 = (switch_sql_queue_manager_t *)jarg1;
arg2 = (char *)jarg2;
arg3 = (switch_core_db_event_callback_func_t)jarg3;
arg4 = (void *)jarg4;
switch_sql_queue_manger_execute_sql_event_callback(arg1,(char const *)arg2,arg3,arg4);
}
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_fork() {
void * jresult ;
pid_t result;
@@ -20270,6 +20332,50 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_switch_file_handle_prefix_get(void * jarg1)
}
SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_max_samples_set(void * jarg1, int jarg2) {
switch_file_handle *arg1 = (switch_file_handle *) 0 ;
int arg2 ;
arg1 = (switch_file_handle *)jarg1;
arg2 = (int)jarg2;
if (arg1) (arg1)->max_samples = arg2;
}
SWIGEXPORT int SWIGSTDCALL CSharp_switch_file_handle_max_samples_get(void * jarg1) {
int jresult ;
switch_file_handle *arg1 = (switch_file_handle *) 0 ;
int result;
arg1 = (switch_file_handle *)jarg1;
result = (int) ((arg1)->max_samples);
jresult = result;
return jresult;
}
SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle__params_set(void * jarg1, void * jarg2) {
switch_file_handle *arg1 = (switch_file_handle *) 0 ;
switch_event_t *arg2 = (switch_event_t *) 0 ;
arg1 = (switch_file_handle *)jarg1;
arg2 = (switch_event_t *)jarg2;
if (arg1) (arg1)->params = arg2;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_switch_file_handle__params_get(void * jarg1) {
void * jresult ;
switch_file_handle *arg1 = (switch_file_handle *) 0 ;
switch_event_t *result = 0 ;
arg1 = (switch_file_handle *)jarg1;
result = (switch_event_t *) ((arg1)->params);
jresult = (void *)result;
return jresult;
}
SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_file_handle() {
void * jresult ;
switch_file_handle *result = 0 ;
@@ -27316,6 +27422,18 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_channel_state_thread_unlock(void * jar
}
SWIGEXPORT int SWIGSTDCALL CSharp_switch_channel_state_thread_trylock(void * jarg1) {
int jresult ;
switch_channel_t *arg1 = (switch_channel_t *) 0 ;
switch_status_t result;
arg1 = (switch_channel_t *)jarg1;
result = (switch_status_t)switch_channel_state_thread_trylock(arg1);
jresult = result;
return jresult;
}
SWIGEXPORT int SWIGSTDCALL CSharp_switch_buffer_create(void * jarg1, void * jarg2, void * jarg3) {
int jresult ;
switch_memory_pool_t *arg1 = (switch_memory_pool_t *) 0 ;
@@ -38054,6 +38172,18 @@ SWIGEXPORT void SWIGSTDCALL CSharp_CoreSession_SetTtsParameters(void * jarg1, ch
}
SWIGEXPORT void SWIGSTDCALL CSharp_CoreSession_set_tts_params(void * jarg1, char * jarg2, char * jarg3) {
CoreSession *arg1 = (CoreSession *) 0 ;
char *arg2 = (char *) 0 ;
char *arg3 = (char *) 0 ;
arg1 = (CoreSession *)jarg1;
arg2 = (char *)jarg2;
arg3 = (char *)jarg3;
(arg1)->set_tts_params(arg2,arg3);
}
SWIGEXPORT int SWIGSTDCALL CSharp_CoreSession_CollectDigits__SWIG_0(void * jarg1, int jarg2) {
int jresult ;
CoreSession *arg1 = (CoreSession *) 0 ;
@@ -376,6 +376,10 @@ public class CoreSession : IDisposable {
freeswitchPINVOKE.CoreSession_SetTtsParameters(swigCPtr, tts_name, voice_name);
}
public void set_tts_params(string tts_name, string voice_name) {
freeswitchPINVOKE.CoreSession_set_tts_params(swigCPtr, tts_name, voice_name);
}
public int CollectDigits(int abs_timeout) {
int ret = freeswitchPINVOKE.CoreSession_CollectDigits__SWIG_0(swigCPtr, abs_timeout);
return ret;
@@ -600,7 +604,8 @@ public class DTMF : IDisposable {
namespace FreeSWITCH.Native {
public enum dtmf_flag_t {
DTMF_FLAG_SKIP_PROCESS = (1 << 0)
DTMF_FLAG_SKIP_PROCESS = (1 << 0),
DTMF_FLAG_SENSITIVE = (1 << 1)
}
}
@@ -1124,6 +1129,18 @@ public class freeswitch {
return ret;
}
public static switch_frame switch_core_media_bug_get_native_read_frame(SWIGTYPE_p_switch_media_bug bug) {
IntPtr cPtr = freeswitchPINVOKE.switch_core_media_bug_get_native_read_frame(SWIGTYPE_p_switch_media_bug.getCPtr(bug));
switch_frame ret = (cPtr == IntPtr.Zero) ? null : new switch_frame(cPtr, false);
return ret;
}
public static switch_frame switch_core_media_bug_get_native_write_frame(SWIGTYPE_p_switch_media_bug bug) {
IntPtr cPtr = freeswitchPINVOKE.switch_core_media_bug_get_native_write_frame(SWIGTYPE_p_switch_media_bug.getCPtr(bug));
switch_frame ret = (cPtr == IntPtr.Zero) ? null : new switch_frame(cPtr, false);
return ret;
}
public static void switch_core_media_bug_set_write_replace_frame(SWIGTYPE_p_switch_media_bug bug, switch_frame frame) {
freeswitchPINVOKE.switch_core_media_bug_set_write_replace_frame(SWIGTYPE_p_switch_media_bug.getCPtr(bug), switch_frame.getCPtr(frame));
}
@@ -2913,6 +2930,14 @@ public class freeswitch {
return ret;
}
public static void switch_sql_queue_manger_execute_sql_callback(SWIGTYPE_p_switch_sql_queue_manager qm, string sql, SWIGTYPE_p_f_p_void_int_p_p_char_p_p_char__int callback, SWIGTYPE_p_void pdata) {
freeswitchPINVOKE.switch_sql_queue_manger_execute_sql_callback(SWIGTYPE_p_switch_sql_queue_manager.getCPtr(qm), sql, SWIGTYPE_p_f_p_void_int_p_p_char_p_p_char__int.getCPtr(callback), SWIGTYPE_p_void.getCPtr(pdata));
}
public static void switch_sql_queue_manger_execute_sql_event_callback(SWIGTYPE_p_switch_sql_queue_manager qm, string sql, SWIGTYPE_p_f_p_void_p_switch_event__int callback, SWIGTYPE_p_void pdata) {
freeswitchPINVOKE.switch_sql_queue_manger_execute_sql_event_callback(SWIGTYPE_p_switch_sql_queue_manager.getCPtr(qm), sql, SWIGTYPE_p_f_p_void_p_switch_event__int.getCPtr(callback), SWIGTYPE_p_void.getCPtr(pdata));
}
public static SWIGTYPE_p_pid_t switch_fork() {
SWIGTYPE_p_pid_t ret = new SWIGTYPE_p_pid_t(freeswitchPINVOKE.switch_fork(), true);
return ret;
@@ -4372,6 +4397,11 @@ public class freeswitch {
freeswitchPINVOKE.switch_channel_state_thread_unlock(SWIGTYPE_p_switch_channel.getCPtr(channel));
}
public static switch_status_t switch_channel_state_thread_trylock(SWIGTYPE_p_switch_channel channel) {
switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_channel_state_thread_trylock(SWIGTYPE_p_switch_channel.getCPtr(channel));
return ret;
}
public static switch_status_t switch_buffer_create(SWIGTYPE_p_apr_pool_t pool, SWIGTYPE_p_p_switch_buffer buffer, SWIGTYPE_p_switch_size_t max_len) {
switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_buffer_create(SWIGTYPE_p_apr_pool_t.getCPtr(pool), SWIGTYPE_p_p_switch_buffer.getCPtr(buffer), SWIGTYPE_p_switch_size_t.getCPtr(max_len));
if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve();
@@ -6382,6 +6412,7 @@ public class freeswitch {
public static readonly string SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE = freeswitchPINVOKE.SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE_get();
public static readonly string SWITCH_TRANSFER_HISTORY_VARIABLE = freeswitchPINVOKE.SWITCH_TRANSFER_HISTORY_VARIABLE_get();
public static readonly string SWITCH_TRANSFER_SOURCE_VARIABLE = freeswitchPINVOKE.SWITCH_TRANSFER_SOURCE_VARIABLE_get();
public static readonly string SWITCH_SENSITIVE_DTMF_VARIABLE = freeswitchPINVOKE.SWITCH_SENSITIVE_DTMF_VARIABLE_get();
public static readonly string SWITCH_CHANNEL_EXECUTE_ON_ANSWER_VARIABLE = freeswitchPINVOKE.SWITCH_CHANNEL_EXECUTE_ON_ANSWER_VARIABLE_get();
public static readonly string SWITCH_CHANNEL_EXECUTE_ON_PRE_ANSWER_VARIABLE = freeswitchPINVOKE.SWITCH_CHANNEL_EXECUTE_ON_PRE_ANSWER_VARIABLE_get();
public static readonly string SWITCH_CHANNEL_EXECUTE_ON_MEDIA_VARIABLE = freeswitchPINVOKE.SWITCH_CHANNEL_EXECUTE_ON_MEDIA_VARIABLE_get();
@@ -6956,6 +6987,9 @@ class freeswitchPINVOKE {
[DllImport("mod_managed", EntryPoint="CSharp_SWITCH_TRANSFER_SOURCE_VARIABLE_get")]
public static extern string SWITCH_TRANSFER_SOURCE_VARIABLE_get();
[DllImport("mod_managed", EntryPoint="CSharp_SWITCH_SENSITIVE_DTMF_VARIABLE_get")]
public static extern string SWITCH_SENSITIVE_DTMF_VARIABLE_get();
[DllImport("mod_managed", EntryPoint="CSharp_SWITCH_CHANNEL_EXECUTE_ON_ANSWER_VARIABLE_get")]
public static extern string SWITCH_CHANNEL_EXECUTE_ON_ANSWER_VARIABLE_get();
@@ -8507,6 +8541,12 @@ class freeswitchPINVOKE {
[DllImport("mod_managed", EntryPoint="CSharp_switch_core_media_bug_get_write_replace_frame")]
public static extern IntPtr switch_core_media_bug_get_write_replace_frame(HandleRef jarg1);
[DllImport("mod_managed", EntryPoint="CSharp_switch_core_media_bug_get_native_read_frame")]
public static extern IntPtr switch_core_media_bug_get_native_read_frame(HandleRef jarg1);
[DllImport("mod_managed", EntryPoint="CSharp_switch_core_media_bug_get_native_write_frame")]
public static extern IntPtr switch_core_media_bug_get_native_write_frame(HandleRef jarg1);
[DllImport("mod_managed", EntryPoint="CSharp_switch_core_media_bug_set_write_replace_frame")]
public static extern void switch_core_media_bug_set_write_replace_frame(HandleRef jarg1, HandleRef jarg2);
@@ -9698,6 +9738,12 @@ class freeswitchPINVOKE {
[DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_execute_sql_event_callback")]
public static extern int switch_cache_db_execute_sql_event_callback(HandleRef jarg1, string jarg2, HandleRef jarg3, HandleRef jarg4, ref string jarg5);
[DllImport("mod_managed", EntryPoint="CSharp_switch_sql_queue_manger_execute_sql_callback")]
public static extern void switch_sql_queue_manger_execute_sql_callback(HandleRef jarg1, string jarg2, HandleRef jarg3, HandleRef jarg4);
[DllImport("mod_managed", EntryPoint="CSharp_switch_sql_queue_manger_execute_sql_event_callback")]
public static extern void switch_sql_queue_manger_execute_sql_event_callback(HandleRef jarg1, string jarg2, HandleRef jarg3, HandleRef jarg4);
[DllImport("mod_managed", EntryPoint="CSharp_switch_fork")]
public static extern IntPtr switch_fork();
@@ -11612,6 +11658,18 @@ class freeswitchPINVOKE {
[DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_prefix_get")]
public static extern string switch_file_handle_prefix_get(HandleRef jarg1);
[DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_max_samples_set")]
public static extern void switch_file_handle_max_samples_set(HandleRef jarg1, int jarg2);
[DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_max_samples_get")]
public static extern int switch_file_handle_max_samples_get(HandleRef jarg1);
[DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle__params_set")]
public static extern void switch_file_handle__params_set(HandleRef jarg1, HandleRef jarg2);
[DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle__params_get")]
public static extern IntPtr switch_file_handle__params_get(HandleRef jarg1);
[DllImport("mod_managed", EntryPoint="CSharp_new_switch_file_handle")]
public static extern IntPtr new_switch_file_handle();
@@ -13394,6 +13452,9 @@ class freeswitchPINVOKE {
[DllImport("mod_managed", EntryPoint="CSharp_switch_channel_state_thread_unlock")]
public static extern void switch_channel_state_thread_unlock(HandleRef jarg1);
[DllImport("mod_managed", EntryPoint="CSharp_switch_channel_state_thread_trylock")]
public static extern int switch_channel_state_thread_trylock(HandleRef jarg1);
[DllImport("mod_managed", EntryPoint="CSharp_switch_buffer_create")]
public static extern int switch_buffer_create(HandleRef jarg1, HandleRef jarg2, HandleRef jarg3);
@@ -15809,6 +15870,9 @@ class freeswitchPINVOKE {
[DllImport("mod_managed", EntryPoint="CSharp_CoreSession_SetTtsParameters")]
public static extern void CoreSession_SetTtsParameters(HandleRef jarg1, string jarg2, string jarg3);
[DllImport("mod_managed", EntryPoint="CSharp_CoreSession_set_tts_params")]
public static extern void CoreSession_set_tts_params(HandleRef jarg1, string jarg2, string jarg3);
[DllImport("mod_managed", EntryPoint="CSharp_CoreSession_CollectDigits__SWIG_0")]
public static extern int CoreSession_CollectDigits__SWIG_0(HandleRef jarg1, int jarg2);
@@ -21801,6 +21865,8 @@ public enum switch_abc_type_t {
SWITCH_ABC_TYPE_WRITE_REPLACE,
SWITCH_ABC_TYPE_READ_REPLACE,
SWITCH_ABC_TYPE_READ_PING,
SWITCH_ABC_TYPE_TAP_NATIVE_READ,
SWITCH_ABC_TYPE_TAP_NATIVE_WRITE,
SWITCH_ABC_TYPE_CLOSE
}
@@ -27959,7 +28025,8 @@ namespace FreeSWITCH.Native {
SWITCH_FILE_DONE = (1 << 13),
SWITCH_FILE_BUFFER_DONE = (1 << 14),
SWITCH_FILE_WRITE_APPEND = (1 << 15),
SWITCH_FILE_WRITE_OVER = (1 << 16)
SWITCH_FILE_WRITE_OVER = (1 << 16),
SWITCH_FILE_NOMUX = (1 << 17)
}
}
@@ -28417,6 +28484,27 @@ public class switch_file_handle : IDisposable {
}
}
public int max_samples {
set {
freeswitchPINVOKE.switch_file_handle_max_samples_set(swigCPtr, value);
}
get {
int ret = freeswitchPINVOKE.switch_file_handle_max_samples_get(swigCPtr);
return ret;
}
}
public switch_event _params {
set {
freeswitchPINVOKE.switch_file_handle__params_set(swigCPtr, switch_event.getCPtr(value));
}
get {
IntPtr cPtr = freeswitchPINVOKE.switch_file_handle__params_get(swigCPtr);
switch_event ret = (cPtr == IntPtr.Zero) ? null : new switch_event(cPtr, false);
return ret;
}
}
public switch_file_handle() : this(freeswitchPINVOKE.new_switch_file_handle(), true) {
}
@@ -31462,11 +31550,14 @@ namespace FreeSWITCH.Native {
SMBF_READ_PING = (1 << 4),
SMBF_STEREO = (1 << 5),
SMBF_ANSWER_REQ = (1 << 6),
SMBF_THREAD_LOCK = (1 << 7),
SMBF_PRUNE = (1 << 8),
SMBF_NO_PAUSE = (1 << 9),
SMBF_STEREO_SWAP = (1 << 10),
SMBF_LOCK = (1 << 11)
SMBF_BRIDGE_REQ = (1 << 7),
SMBF_THREAD_LOCK = (1 << 8),
SMBF_PRUNE = (1 << 9),
SMBF_NO_PAUSE = (1 << 10),
SMBF_STEREO_SWAP = (1 << 11),
SMBF_LOCK = (1 << 12),
SMBF_TAP_NATIVE_READ = (1 << 13),
SMBF_TAP_NATIVE_WRITE = (1 << 14)
}
}
+18 -10
View File
@@ -394,12 +394,17 @@ SWITCH_DECLARE(switch_status_t) switch_channel_queue_dtmf(switch_channel_t *chan
switch_status_t status;
void *pop;
switch_dtmf_t new_dtmf = { 0 };
switch_bool_t sensitive = switch_true(switch_channel_get_variable_dup(channel, SWITCH_SENSITIVE_DTMF_VARIABLE, SWITCH_FALSE, -1));
switch_assert(dtmf);
switch_mutex_lock(channel->dtmf_mutex);
new_dtmf = *dtmf;
if (sensitive) {
switch_set_flag((&new_dtmf), DTMF_FLAG_SENSITIVE);
}
if ((status = switch_core_session_recv_dtmf(channel->session, dtmf) != SWITCH_STATUS_SUCCESS)) {
goto done;
}
@@ -407,18 +412,19 @@ SWITCH_DECLARE(switch_status_t) switch_channel_queue_dtmf(switch_channel_t *chan
if (is_dtmf(new_dtmf.digit)) {
switch_dtmf_t *dt;
int x = 0;
char str[2] = "";
str[0] = new_dtmf.digit;
if (!sensitive) {
switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "RECV DTMF %c:%d\n", new_dtmf.digit, new_dtmf.duration);
}
if (new_dtmf.digit != 'w' && new_dtmf.digit != 'W') {
if (new_dtmf.duration > switch_core_max_dtmf_duration(0)) {
switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG1, "%s EXCESSIVE DTMF DIGIT [%s] LEN [%d]\n",
switch_channel_get_name(channel), str, new_dtmf.duration);
switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "%s EXCESSIVE DTMF DIGIT LEN [%d]\n",
switch_channel_get_name(channel), new_dtmf.duration);
new_dtmf.duration = switch_core_max_dtmf_duration(0);
} else if (new_dtmf.duration < switch_core_min_dtmf_duration(0)) {
switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG1, "%s SHORT DTMF DIGIT [%s] LEN [%d]\n",
switch_channel_get_name(channel), str, new_dtmf.duration);
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);
}
}
@@ -519,14 +525,16 @@ SWITCH_DECLARE(switch_status_t) switch_channel_dequeue_dtmf(switch_channel_t *ch
void *pop;
switch_dtmf_t *dt;
switch_status_t status = SWITCH_STATUS_FALSE;
int sensitive = 0;
switch_mutex_lock(channel->dtmf_mutex);
if (switch_queue_trypop(channel->dtmf_queue, &pop) == SWITCH_STATUS_SUCCESS) {
dt = (switch_dtmf_t *) pop;
*dtmf = *dt;
sensitive = switch_test_flag(dtmf, DTMF_FLAG_SENSITIVE);
if (switch_queue_trypush(channel->dtmf_log_queue, dt) != SWITCH_STATUS_SUCCESS) {
if (!sensitive && switch_queue_trypush(channel->dtmf_log_queue, dt) != SWITCH_STATUS_SUCCESS) {
free(dt);
}
@@ -534,11 +542,11 @@ SWITCH_DECLARE(switch_status_t) switch_channel_dequeue_dtmf(switch_channel_t *ch
if (dtmf->duration > switch_core_max_dtmf_duration(0)) {
switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_WARNING, "%s EXCESSIVE DTMF DIGIT [%c] LEN [%d]\n",
switch_channel_get_name(channel), dtmf->digit, dtmf->duration);
switch_channel_get_name(channel), sensitive ? 'S' : dtmf->digit, dtmf->duration);
dtmf->duration = switch_core_max_dtmf_duration(0);
} else if (dtmf->duration < switch_core_min_dtmf_duration(0)) {
switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_WARNING, "%s SHORT DTMF DIGIT [%c] LEN [%d]\n",
switch_channel_get_name(channel), dtmf->digit, dtmf->duration);
switch_channel_get_name(channel), sensitive ? 'S' : dtmf->digit, dtmf->duration);
dtmf->duration = switch_core_min_dtmf_duration(0);
} else if (!dtmf->duration) {
dtmf->duration = switch_core_default_dtmf_duration(0);
@@ -548,7 +556,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_dequeue_dtmf(switch_channel_t *ch
}
switch_mutex_unlock(channel->dtmf_mutex);
if (status == SWITCH_STATUS_SUCCESS && switch_event_create(&event, SWITCH_EVENT_DTMF) == SWITCH_STATUS_SUCCESS) {
if (!sensitive && status == SWITCH_STATUS_SUCCESS && switch_event_create(&event, SWITCH_EVENT_DTMF) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(channel, event);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "DTMF-Digit", "%c", dtmf->digit);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "DTMF-Duration", "%u", dtmf->duration);
+3 -1
View File
@@ -233,9 +233,11 @@ SWITCH_DECLARE(switch_core_db_t *) switch_core_db_open_file(const char *filename
if (cb_arg.ok && (1 == cb_arg.rows)) {
break;
} else if (0 == i) {
char *cpath = switch_mprintf("%s.%ld.cdb", path, (long) switch_epoch_time_now(NULL));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQLite integrity_check failed for [%s]. Deleting file and retrying\n", path);
switch_core_db_close(db);
remove(path);
rename(path, cpath);
free(cpath);
continue;
} else {
+32
View File
@@ -299,6 +299,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
do_resample = 1;
}
if (session->bugs && !need_codec) {
do_bugs = 1;
need_codec = 1;
}
if (switch_test_flag(*frame, SFF_CNG)) {
if (!session->bugs && !session->plc) {
/* Check if other session has bugs */
@@ -551,6 +556,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
if (!switch_channel_test_flag(session->channel, CF_ANSWERED) && switch_core_media_bug_test_flag(bp, SMBF_ANSWER_REQ)) {
continue;
}
if (!switch_channel_test_flag(session->channel, CF_BRIDGED) && switch_core_media_bug_test_flag(bp, SMBF_BRIDGE_REQ)) {
continue;
}
if (switch_test_flag(bp, SMBF_PRUNE)) {
prune++;
continue;
@@ -595,6 +605,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
if (!switch_channel_test_flag(session->channel, CF_ANSWERED) && switch_core_media_bug_test_flag(bp, SMBF_ANSWER_REQ)) {
continue;
}
if (!switch_channel_test_flag(session->channel, CF_BRIDGED) && switch_core_media_bug_test_flag(bp, SMBF_BRIDGE_REQ)) {
continue;
}
if (switch_test_flag(bp, SMBF_PRUNE)) {
prune++;
continue;
@@ -757,6 +772,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
continue;
}
if (!switch_channel_test_flag(session->channel, CF_BRIDGED) && switch_core_media_bug_test_flag(bp, SMBF_BRIDGE_REQ)) {
continue;
}
if (switch_test_flag(bp, SMBF_PRUNE)) {
prune++;
continue;
@@ -953,6 +972,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
need_codec = TRUE;
}
if (session->bugs && !need_codec) {
do_bugs = TRUE;
need_codec = TRUE;
}
if (frame->codec->implementation->actual_samples_per_second != session->write_impl.actual_samples_per_second) {
need_codec = TRUE;
do_resample = TRUE;
@@ -1463,6 +1487,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_recv_dtmf(switch_core_sessio
return SWITCH_STATUS_FALSE;
}
if (switch_test_flag(dtmf, DTMF_FLAG_SENSITIVE)) {
return SWITCH_STATUS_SUCCESS;
}
switch_assert(dtmf);
new_dtmf = *dtmf;
@@ -1506,6 +1534,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf(switch_core_sessio
return SWITCH_STATUS_FALSE;
}
if (switch_test_flag(dtmf, DTMF_FLAG_SENSITIVE)) {
return SWITCH_STATUS_SUCCESS;
}
switch_assert(dtmf);
new_dtmf = *dtmf;
+2 -1
View File
@@ -2037,7 +2037,7 @@ static void core_event_handler(switch_event_t *event)
break;
case SWITCH_EVENT_CHANNEL_ANSWER:
case SWITCH_EVENT_CHANNEL_PROGRESS_MEDIA:
case SWITCH_EVENT_CODEC:
new_sql() =
switch_mprintf
("update channels set read_codec='%q',read_rate='%q',read_bit_rate='%q',write_codec='%q',write_rate='%q',write_bit_rate='%q' where uuid='%q'",
@@ -3280,6 +3280,7 @@ switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_
switch_event_bind("core_db", SWITCH_EVENT_MODULE_UNLOAD, SWITCH_EVENT_SUBCLASS_ANY, core_event_handler, NULL);
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
switch_threadattr_create(&thd_attr, sql_manager.memory_pool);
+4 -2
View File
@@ -1108,14 +1108,12 @@ static switch_bool_t record_callback(switch_media_bug_t *bug, void *user_data, s
{
nframe = switch_core_media_bug_get_native_read_frame(bug);
len = nframe->datalen;
printf("WRITE IN %d\n", nframe->datalen);
switch_core_file_write(&rh->in_fh, nframe->data, &len);
}
break;
case SWITCH_ABC_TYPE_TAP_NATIVE_WRITE:
{
nframe = switch_core_media_bug_get_native_write_frame(bug);
printf("WRITE OUT %d\n", nframe->datalen);
len = nframe->datalen;
switch_core_file_write(&rh->out_fh, nframe->data, &len);
}
@@ -1845,6 +1843,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t
flags |= SMBF_ANSWER_REQ;
}
if ((p = switch_channel_get_variable(channel, "RECORD_BRIDGE_REQ")) && switch_true(p)) {
flags |= SMBF_BRIDGE_REQ;
}
if ((p = switch_channel_get_variable(channel, "RECORD_APPEND")) && switch_true(p)) {
file_flags |= SWITCH_FILE_WRITE_APPEND;
}
+80 -12
View File
@@ -1229,7 +1229,7 @@ static switch_status_t setup_ringback(originate_global_t *oglobals, originate_st
} else {
switch_core_session_get_read_impl(oglobals->session, &peer_read_impl);
}
if (switch_core_codec_init(write_codec,
"L16",
NULL,
@@ -1273,6 +1273,11 @@ static switch_status_t setup_ringback(originate_global_t *oglobals, originate_st
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(oglobals->session), SWITCH_LOG_DEBUG, "Play Ringback File [%s]\n", ringback_data);
if (switch_test_flag((&ringback->fhb), SWITCH_FILE_OPEN)) {
switch_core_file_close(&ringback->fhb);
}
ringback->fhb.channels = read_codec->implementation->number_of_channels;
ringback->fhb.samplerate = read_codec->implementation->actual_samples_per_second;
if (switch_core_file_open(&ringback->fhb,
@@ -1689,13 +1694,18 @@ static void *SWITCH_THREAD_FUNC early_thread_run(switch_thread_t *thread, void *
int16_t mux_data[SWITCH_RECOMMENDED_BUFFER_SIZE / 2] = { 0 };
int32_t sample;
switch_core_session_t *session;
switch_codec_t *read_codec, read_codecs[MAX_PEERS] = { {0} };
int i, x, ready = 0, answered = 0;
switch_codec_t read_codecs[MAX_PEERS] = { {0} };
int i, x, ready = 0, answered = 0, ring_ready = 0;
int16_t *data;
uint32_t datalen = 0;
switch_status_t status;
switch_frame_t *read_frame = NULL;
switch_codec_implementation_t read_impl = { 0 };
if (state->oglobals->session) {
switch_core_session_get_read_impl(state->oglobals->session, &read_impl);
}
for (i = 0; i < MAX_PEERS && (session = state->originate_status[i].peer_session); i++) {
originate_status[i].peer_session = session;
switch_core_session_read_lock(session);
@@ -1712,25 +1722,29 @@ static void *SWITCH_THREAD_FUNC early_thread_run(switch_thread_t *thread, void *
if (switch_channel_media_ready(channel)) {
ready++;
if (switch_channel_test_flag(channel, CF_RING_READY)) {
ring_ready = 1;
state->oglobals->bridge_early_media = -1;
state->oglobals->ignore_early_media = 1;
}
if (switch_channel_test_flag(channel, CF_ANSWERED)) {
answered++;
}
if (!state->ringback->asis) {
if (!switch_core_codec_ready((&read_codecs[i]))) {
read_codec = switch_core_session_get_read_codec(session);
if (switch_core_codec_init(&read_codecs[i],
"L16",
NULL,
read_codec->implementation->actual_samples_per_second,
read_codec->implementation->microseconds_per_packet / 1000,
read_impl.actual_samples_per_second,
read_impl.microseconds_per_packet / 1000,
1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Codec Error!\n");
} else {
switch_core_session_set_read_codec(session, &read_codecs[i]);
}
switch_core_session_set_read_codec(session, NULL);
switch_core_session_set_read_codec(session, &read_codecs[i]);
}
status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
if (SWITCH_READ_ACCEPTABLE(status)) {
@@ -1766,7 +1780,7 @@ static void *SWITCH_THREAD_FUNC early_thread_run(switch_thread_t *thread, void *
switch_mutex_unlock(state->mutex);
}
if (!ready || answered) {
if (!ready || answered || ring_ready) {
break;
}
}
@@ -1774,13 +1788,16 @@ static void *SWITCH_THREAD_FUNC early_thread_run(switch_thread_t *thread, void *
for (i = 0; i < MAX_PEERS && (session = originate_status[i].peer_session); i++) {
if (switch_core_codec_ready((&read_codecs[i]))) {
switch_core_session_set_read_codec(session, NULL);
switch_core_codec_destroy(&read_codecs[i]);
}
switch_core_session_reset(session, SWITCH_FALSE, SWITCH_TRUE);
switch_core_session_rwunlock(session);
}
state->oglobals->early_ok = 1;
if (!ring_ready) {
state->oglobals->early_ok = 1;
}
return NULL;
}
@@ -2048,6 +2065,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
switch_event_header_t *hi;
const char *cdr_total_var;
const char *cdr_var;
const char *json_cdr_var;
if ((cdr_var = switch_channel_get_variable(caller_channel, "failed_xml_cdr_prefix"))) {
char buf[128] = "";
@@ -2060,6 +2078,16 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
}
}
if ((json_cdr_var = switch_channel_get_variable(caller_channel, "failed_json_cdr_prefix"))) {
char buf[128] = "";
switch_snprintf(buf, sizeof(buf), "%s_total", json_cdr_var);
if ((cdr_total_var = switch_channel_get_variable(caller_channel, buf))) {
int tmp = atoi(cdr_total_var);
if (tmp > 0) {
cdr_total = tmp;
}
}
}
/* Copy all the missing applicable channel variables from A-leg into the event */
if ((hi = switch_channel_variable_first(caller_channel))) {
@@ -3073,7 +3101,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
}
}
write_frame.datalen = (uint32_t) (ringback.asis ? olen : olen * 2);
write_frame.samples = (uint32_t) olen;
write_frame.samples = (uint32_t) olen;
} else if (ringback.audio_buffer) {
if ((write_frame.datalen = (uint32_t) switch_buffer_read_loop(ringback.audio_buffer,
@@ -3438,7 +3466,12 @@ write_frame.samples = (uint32_t) olen;
} else {
const char *cdr_var = NULL;
const char *json_cdr_var = NULL;
switch_xml_t cdr = NULL;
cJSON *json_cdr = NULL;
char *json_text;
char *xml_text;
char buf[128] = "", buf2[128] = "";
@@ -3446,6 +3479,10 @@ write_frame.samples = (uint32_t) olen;
cdr_var = switch_channel_get_variable(caller_channel, "failed_xml_cdr_prefix");
}
if (caller_channel) {
json_cdr_var = switch_channel_get_variable(caller_channel, "failed_json_cdr_prefix");
}
if (peer_channel) {
wait_for_cause(peer_channel);
*cause = switch_channel_get_cause(peer_channel);
@@ -3491,6 +3528,37 @@ write_frame.samples = (uint32_t) olen;
switch_channel_set_variable(caller_channel, buf, buf2);
}
if (json_cdr_var) {
for (i = 0; i < and_argc; i++) {
switch_channel_t *channel;
if (!originate_status[i].peer_session) {
continue;
}
channel = switch_core_session_get_channel(originate_status[i].peer_session);
switch_channel_wait_for_state_timeout(channel, CS_REPORTING, 5000);
if (!switch_channel_test_flag(channel, CF_TIMESTAMP_SET)) {
switch_channel_set_timestamps(channel);
}
if (switch_ivr_generate_json_cdr(originate_status[i].peer_session, &json_cdr, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) {
json_text = cJSON_PrintUnformatted(json_cdr);
switch_snprintf(buf, sizeof(buf), "%s_%d", json_cdr_var, ++cdr_total);
switch_channel_set_variable(caller_channel, buf, json_text);
// switch_safe_free(json_text);
cJSON_Delete(json_cdr);
json_cdr = NULL;
}
}
switch_snprintf(buf, sizeof(buf), "%s_total", json_cdr_var);
switch_snprintf(buf2, sizeof(buf2), "%d", cdr_total ? cdr_total : 0);
switch_channel_set_variable(caller_channel, buf, buf2);
}
if (caller_channel && switch_channel_test_flag(caller_channel, CF_INTERCEPTED)) {
*cause = SWITCH_CAUSE_PICKED_OFF;
}
+22 -9
View File
@@ -1185,20 +1185,33 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
if (!strstr(file, SWITCH_URL_SEPARATOR)) {
if (!switch_is_file_path(file)) {
char *tfile = NULL;
char *tfile = NULL, *tfile2 = NULL;
char *e;
int x;
if (*file == '[') {
tfile = switch_core_session_strdup(session, file);
if ((e = switch_find_end_paren(tfile, '[', ']'))) {
*e = '\0';
file = e + 1;
for (x = 0; x < 2; x++) {
if (*file == '[') {
tfile = switch_core_session_strdup(session, file);
if ((e = switch_find_end_paren(tfile, '[', ']'))) {
*e = '\0';
file = e + 1;
} else {
tfile = NULL;
}
} else if (*file == '{') {
tfile2 = switch_core_session_strdup(session, file);
if ((e = switch_find_end_paren(tfile2, '{', '}'))) {
*e = '\0';
file = e + 1;
} else {
tfile2 = NULL;
}
} else {
tfile = NULL;
break;
}
}
file = switch_core_session_sprintf(session, "%s%s%s%s%s", switch_str_nil(tfile), tfile ? "]" : "", prefix, SWITCH_PATH_SEPARATOR, file);
file = switch_core_session_sprintf(session, "%s%s%s%s%s%s%s", switch_str_nil(tfile), tfile ? "]" : "", switch_str_nil(tfile2), tfile2 ? "}" : "", prefix, SWITCH_PATH_SEPARATOR, file);
}
if ((ext = strrchr(file, '.'))) {
ext++;
@@ -2040,7 +2053,7 @@ SWITCH_DECLARE(switch_status_t) switch_play_and_get_digits(switch_core_session_t
if (zstr(digits_regex)) {
return SWITCH_STATUS_SUCCESS;
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Test Regex [%s][%s]\n", digit_buffer, digits_regex);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG1, "Test Regex [%s][%s]\n", digit_buffer, digits_regex);
if (switch_regex_match(digit_buffer, digits_regex) == SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_SUCCESS;
} else {
+8
View File
@@ -1597,6 +1597,14 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_udptl_mode(switch_rtp_t *rtp_session)
{
switch_socket_t *sock;
if (!switch_rtp_ready(rtp_session)) {
return SWITCH_STATUS_FALSE;
}
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA)) {
ping_socket(rtp_session);
}
READ_INC(rtp_session);
WRITE_INC(rtp_session);