Merge branch 'master' into smgmaster

This commit is contained in:
Moises Silva committed 2011-01-19 10:19:31 -05:00
commit 1045117d9c
314 files changed
+6552 -1565

No files matched your search

@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -5046,7 +5046,7 @@ static switch_status_t conference_local_play_file(conference_obj_t *conference,
goto done;
}
if (conference->sound_prefix) {
if (!switch_is_file_path(path) && conference->sound_prefix) {
if (!(dpath = switch_mprintf("%s%s%s", conference->sound_prefix, SWITCH_PATH_SEPARATOR, path))) {
status = SWITCH_STATUS_MEMERR;
goto done;
@@ -5827,7 +5827,7 @@ SWITCH_STANDARD_APP(conference_function)
toplay = conference->kicked_sound;
}
if (conference->sound_prefix) {
if (!switch_is_file_path(toplay) && conference->sound_prefix) {
dfile = switch_mprintf("%s%s%s", conference->sound_prefix, SWITCH_PATH_SEPARATOR, toplay);
switch_assert(dfile);
toplay = dfile;
@@ -5845,6 +5845,8 @@ SWITCH_STANDARD_APP(conference_function)
if (rl) {
switch_thread_rwlock_unlock(conference->rwlock);
}
switch_channel_set_variable(channel, "last_transfered_conference", NULL);
}
/* Create a thread for the conference and launch it */
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -389,7 +389,7 @@ SWITCH_STANDARD_APP(dtmf_unbind_function)
int kval = 0;
if (key) {
kval = atoi(key);
kval = switch_dtmftoi(key);
}
switch_ivr_unbind_dtmf_meta_session(session, kval);
@@ -405,7 +405,7 @@ SWITCH_STANDARD_APP(dtmf_bind_function)
if (!zstr(data) && (lbuf = switch_core_session_strdup(session, data))
&& (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) == 4) {
int kval = atoi(argv[0]);
int kval = switch_dtmftoi(argv[0]);
switch_bind_flag_t bind_flags = 0;
if (strchr(argv[1], 'a')) {
@@ -1485,6 +1485,8 @@ SWITCH_STANDARD_APP(ivr_application_function)
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Unable to find menu\n");
}
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No menus configured\n");
}
switch_xml_free(cxml);
} else {
@@ -2531,7 +2533,7 @@ SWITCH_STANDARD_APP(audio_bridge_function)
camp_data = (char *) data;
}
if (!(moh = switch_channel_get_variable(caller_channel, "hold_music"))) {
if (!(moh = switch_channel_get_hold_music(caller_channel))) {
moh = switch_channel_get_variable(caller_channel, "campon_hold_music");
}
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
+42 -10
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -397,12 +397,12 @@ static switch_status_t on_dtmf(switch_core_session_t *session, void *input, swit
const char *moh_a = NULL, *moh_b = NULL;
if (!(moh_b = switch_channel_get_variable(bchan, "fifo_music"))) {
moh_b = switch_channel_get_variable(bchan, "hold_music");
moh_b = switch_channel_get_hold_music(bchan);
}
if (!(moh_a = switch_channel_get_variable(channel, "fifo_hold_music"))) {
if (!(moh_a = switch_channel_get_variable(channel, "fifo_music"))) {
moh_a = switch_channel_get_variable(channel, "hold_music");
moh_a = switch_channel_get_hold_music(channel);
}
}
@@ -582,6 +582,8 @@ static int check_caller_outbound_call(const char *key)
{
int x = 0;
if (!key) return x;
switch_mutex_lock(globals.caller_orig_mutex);
x = !!switch_core_hash_find(globals.caller_orig_hash, key);
switch_mutex_unlock(globals.caller_orig_mutex);
@@ -592,6 +594,8 @@ static int check_caller_outbound_call(const char *key)
static void add_caller_outbound_call(const char *key, switch_call_cause_t *cancel_cause)
{
if (!key) return;
switch_mutex_lock(globals.caller_orig_mutex);
switch_core_hash_insert(globals.caller_orig_hash, key, cancel_cause);
switch_mutex_unlock(globals.caller_orig_mutex);
@@ -599,6 +603,8 @@ static void add_caller_outbound_call(const char *key, switch_call_cause_t *cance
static void del_caller_outbound_call(const char *key)
{
if (!key) return;
switch_mutex_lock(globals.caller_orig_mutex);
switch_core_hash_delete(globals.caller_orig_hash, key);
switch_mutex_unlock(globals.caller_orig_mutex);
@@ -608,6 +614,8 @@ static void cancel_caller_outbound_call(const char *key, switch_call_cause_t cau
{
switch_call_cause_t *cancel_cause = NULL;
if (!key) return;
switch_mutex_lock(globals.caller_orig_mutex);
if ((cancel_cause = (switch_call_cause_t *) switch_core_hash_find(globals.caller_orig_hash, key))) {
*cancel_cause = cause;
@@ -624,6 +632,8 @@ static int check_bridge_call(const char *key)
{
int x = 0;
if (!key) return x;
switch_mutex_lock(globals.bridge_mutex);
x = !!switch_core_hash_find(globals.bridge_hash, key);
switch_mutex_unlock(globals.bridge_mutex);
@@ -634,6 +644,8 @@ static int check_bridge_call(const char *key)
static void add_bridge_call(const char *key)
{
if (!key) return;
switch_mutex_lock(globals.bridge_mutex);
switch_core_hash_insert(globals.bridge_hash, key, (void *)&marker);
switch_mutex_unlock(globals.bridge_mutex);
@@ -651,6 +663,8 @@ static int check_consumer_outbound_call(const char *key)
{
int x = 0;
if (!key) return x;
switch_mutex_lock(globals.consumer_orig_mutex);
x = !!switch_core_hash_find(globals.consumer_orig_hash, key);
switch_mutex_unlock(globals.consumer_orig_mutex);
@@ -660,6 +674,8 @@ static int check_consumer_outbound_call(const char *key)
static void add_consumer_outbound_call(const char *key, switch_call_cause_t *cancel_cause)
{
if (!key) return;
switch_mutex_lock(globals.consumer_orig_mutex);
switch_core_hash_insert(globals.consumer_orig_hash, key, cancel_cause);
switch_mutex_unlock(globals.consumer_orig_mutex);
@@ -667,6 +683,8 @@ static void add_consumer_outbound_call(const char *key, switch_call_cause_t *can
static void del_consumer_outbound_call(const char *key)
{
if (!key) return;
switch_mutex_lock(globals.consumer_orig_mutex);
switch_core_hash_delete(globals.consumer_orig_hash, key);
switch_mutex_unlock(globals.consumer_orig_mutex);
@@ -676,6 +694,8 @@ static void cancel_consumer_outbound_call(const char *key, switch_call_cause_t c
{
switch_call_cause_t *cancel_cause = NULL;
if (!key) return;
switch_mutex_lock(globals.consumer_orig_mutex);
if ((cancel_cause = (switch_call_cause_t *) switch_core_hash_find(globals.consumer_orig_hash, key))) {
*cancel_cause = cause;
@@ -953,9 +973,14 @@ static switch_status_t messagehook (switch_core_session_t *session, switch_core_
consumer_channel = switch_core_session_get_channel(consumer_session);
outbound_id = switch_channel_get_variable(consumer_channel, "fifo_outbound_uuid");
if (!outbound_id) return SWITCH_STATUS_SUCCESS;
switch (msg->message_id) {
case SWITCH_MESSAGE_INDICATE_BRIDGE:
case SWITCH_MESSAGE_INDICATE_UNBRIDGE:
if (msg->numeric_arg == 42) {
goto end;
}
if ((caller_session = switch_core_session_locate(msg->string_arg))) {
caller_channel = switch_core_session_get_channel(caller_session);
if (msg->message_id == SWITCH_MESSAGE_INDICATE_BRIDGE) {
@@ -1008,7 +1033,6 @@ static switch_status_t messagehook (switch_core_session_t *session, switch_core_
switch_channel_get_variable(caller_channel, "fifo_import_prefix"));
}
ced_name = switch_channel_get_variable(consumer_channel, "callee_id_name");
ced_number = switch_channel_get_variable(consumer_channel, "callee_id_number");
@@ -1949,6 +1973,8 @@ static uint32_t fifo_add_outbound(const char *node_name, const char *url, uint32
priority = MAX_PRI - 1;
}
if (!node_name) return 0;
switch_mutex_lock(globals.mutex);
if (!(node = switch_core_hash_find(globals.fifo_hash, node_name))) {
@@ -2079,17 +2105,18 @@ SWITCH_STANDARD_APP(fifo_track_call_function)
return;
}
switch_core_event_hook_add_receive_message(session, messagehook);
switch_core_event_hook_add_state_run(session, hanguphook);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s tracking call on uuid %s!\n", switch_channel_get_name(channel), data);
switch_channel_set_variable(channel, "fifo_outbound_uuid", data);
switch_channel_set_variable(channel, "fifo_track_call", "true");
add_bridge_call(data);
switch_channel_set_app_flag_key(FIFO_APP_KEY, channel, FIFO_APP_TRACKING);
switch_channel_set_variable(channel, "fifo_outbound_uuid", data);
switch_channel_set_variable(channel, "fifo_track_call", "true");
switch_core_event_hook_add_receive_message(session, messagehook);
switch_core_event_hook_add_state_run(session, hanguphook);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s tracking call on uuid %s!\n", switch_channel_get_name(channel), data);
if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
col1 = "manual_calls_in_count";
@@ -4166,6 +4193,8 @@ static void fifo_member_add(char *fifo_name, char *originate_string, int simo_co
char *sql, *name_dup, *p;
fifo_node_t *node = NULL;
if (!fifo_name) return;
if (switch_stristr("fifo_outbound_uuid=", originate_string)) {
extract_fifo_outbound_uuid(originate_string, digest, sizeof(digest));
} else {
@@ -4213,6 +4242,9 @@ static void fifo_member_del(char *fifo_name, char *originate_string)
callback_t cbt = { 0 };
fifo_node_t *node = NULL;
if (!fifo_name) return;
if (switch_stristr("fifo_outbound_uuid=", originate_string)) {
extract_fifo_outbound_uuid(originate_string, digest, sizeof(digest));
} else {
+6
View File
@@ -0,0 +1,6 @@
BASE=../../../..
LOCAL_SOURCES=fsk.c uart.c fsk_callerid.c
LOCAL_OBJS=fsk.o uart.o fsk_callerid.o
include $(BASE)/build/modmake.rules
+351
View File
@@ -0,0 +1,351 @@
/*
* bell202.c
*
* Copyright (c) 2005 Robert Krten. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This module contains a Bell-202 1200-baud FSK decoder, suitable for
* use in a library. The general style of the library calls is modeled
* after the POSIX pthread_*() functions.
*
* 2005 03 20 R. Krten created
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <math.h>
#include "fsk.h"
#include "uart.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
fsk_modem_definition_t fsk_modem_definitions[] =
{
{ /* FSK_V23_FORWARD_MODE1 */ 1700, 1300, 600 },
{ /* FSK_V23_FORWARD_MODE2 */ 2100, 1300, 1200 },
{ /* FSK_V23_BACKWARD */ 450, 390, 75 },
{ /* FSK_BELL202 */ 2200, 1200, 1200 },
};
/*
* dsp_fsk_attr_init
*
* Initializes the attributes structure; this must be done before the
* attributes structure is used.
*/
void dsp_fsk_attr_init (dsp_fsk_attr_t *attr)
{
memset(attr, 0, sizeof(*attr));
}
/*
* dsp_fsk_attr_get_bithandler
* dsp_fsk_attr_set_bithandler
* dsp_fsk_attr_get_bytehandler
* dsp_fsk_attr_set_bytehandler
* dsp_fsk_attr_getsamplerate
* dsp_fsk_attr_setsamplerate
*
* These functions get and set their respective elements from the
* attributes structure. If an error code is returned, it is just
* zero == ok, -1 == fail.
*/
bithandler_func_t dsp_fsk_attr_get_bithandler(dsp_fsk_attr_t *attr, void **bithandler_arg)
{
*bithandler_arg = attr->bithandler_arg;
return attr->bithandler;
}
void dsp_fsk_attr_set_bithandler(dsp_fsk_attr_t *attr, bithandler_func_t bithandler, void *bithandler_arg)
{
attr->bithandler = bithandler;
attr->bithandler_arg = bithandler_arg;
}
bytehandler_func_t dsp_fsk_attr_get_bytehandler(dsp_fsk_attr_t *attr, void **bytehandler_arg)
{
*bytehandler_arg = attr->bytehandler_arg;
return attr->bytehandler;
}
void dsp_fsk_attr_set_bytehandler(dsp_fsk_attr_t *attr, bytehandler_func_t bytehandler, void *bytehandler_arg)
{
attr->bytehandler = bytehandler;
attr->bytehandler_arg = bytehandler_arg;
}
int dsp_fsk_attr_get_samplerate (dsp_fsk_attr_t *attr)
{
return attr->sample_rate;
}
int dsp_fsk_attr_set_samplerate (dsp_fsk_attr_t *attr, int samplerate)
{
if (samplerate <= 0) {
return -1;
}
attr->sample_rate = samplerate;
return 0;
}
/*
* dsp_fsk_create
*
* Creates a handle for subsequent use. The handle is created to contain
* a context data structure for use by the sample handler function. The
* function expects an initialized attributes structure, and returns the
* handle or a NULL if there were errors.
*
* Once created, the handle can be used until it is destroyed.
*/
dsp_fsk_handle_t *dsp_fsk_create(dsp_fsk_attr_t *attr)
{
int i;
double phi_mark, phi_space;
dsp_fsk_handle_t *handle;
handle = malloc(sizeof(*handle));
if (!handle) {
return NULL;
}
memset(handle, 0, sizeof(*handle));
/* fill the attributes member */
memcpy(&handle->attr, attr, sizeof(*attr));
/* see if we can do downsampling. We only really need 6 samples to "match" */
if (attr->sample_rate / fsk_modem_definitions[FSK_BELL202].freq_mark > 6) {
handle->downsampling_count = attr->sample_rate / fsk_modem_definitions[FSK_BELL202].freq_mark / 6;
} else {
handle->downsampling_count = 1;
}
handle->current_downsample = 1;
/* calculate the correlate size (number of samples required for slowest wave) */
handle->corrsize = attr->sample_rate / handle->downsampling_count / fsk_modem_definitions[FSK_BELL202].freq_mark;
/* allocate the correlation sin/cos arrays and initialize */
for (i = 0; i < 4; i++) {
handle->correlates[i] = malloc(sizeof(double) * handle->corrsize);
if (handle->correlates[i] == NULL) {
/* some failed, back out memory allocations */
dsp_fsk_destroy(&handle);
return NULL;
}
}
/* now initialize them */
phi_mark = 2. * M_PI / ((double) attr->sample_rate / (double) handle->downsampling_count / (double) fsk_modem_definitions[FSK_BELL202].freq_mark);
phi_space = 2. * M_PI / ((double) attr->sample_rate / (double) handle->downsampling_count / (double) fsk_modem_definitions[FSK_BELL202].freq_space);
for (i = 0; i < handle->corrsize; i++) {
handle->correlates[0][i] = sin(phi_mark * (double) i);
handle->correlates[1][i] = cos(phi_mark * (double) i);
handle->correlates[2][i] = sin(phi_space * (double) i);
handle->correlates[3][i] = cos(phi_space * (double) i);
}
/* initialize the ring buffer */
handle->buffer = malloc(sizeof(double) * handle->corrsize);
if (!handle->buffer) { /* failed; back out memory allocations */
dsp_fsk_destroy(&handle);
return NULL;
}
memset(handle->buffer, 0, sizeof(double) * handle->corrsize);
handle->ringstart = 0;
/* initalize intra-cell position */
handle->cellpos = 0;
handle->celladj = fsk_modem_definitions[FSK_BELL202].baud_rate / (double) attr->sample_rate * (double) handle->downsampling_count;
/* if they have provided a byte handler, add a UART to the processing chain */
if (handle->attr.bytehandler) {
dsp_uart_attr_t uart_attr;
dsp_uart_handle_t *uart_handle;
dsp_uart_attr_init(&uart_attr);
dsp_uart_attr_set_bytehandler(&uart_attr, handle->attr.bytehandler, handle->attr.bytehandler_arg);
uart_handle = dsp_uart_create(&uart_attr);
if (uart_handle == NULL) {
dsp_fsk_destroy(&handle);
return NULL;
}
handle->attr.bithandler = dsp_uart_bit_handler;
handle->attr.bithandler_arg = uart_handle;
}
return handle;
}
/*
* dsp_fsk_destroy
*
* 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.
*/
void dsp_fsk_destroy(dsp_fsk_handle_t **handle)
{
int i;
/* if empty handle, just return */
if (*handle == NULL) {
return;
}
for (i = 0; i < 4; i++) {
if ((*handle)->correlates[i] != NULL) {
free((*handle)->correlates[i]);
(*handle)->correlates[i] = NULL;
}
}
if ((*handle)->buffer != NULL) {
free((*handle)->buffer);
(*handle)->buffer = NULL;
}
if ((*handle)->attr.bytehandler) {
dsp_uart_handle_t** dhandle = (void *)(&(*handle)->attr.bithandler_arg);
dsp_uart_destroy(dhandle);
}
free(*handle);
*handle = NULL;
}
/*
* dsp_fsk_sample
*
* This is the main processing entry point. The function accepts a normalized
* sample (i.e., one whose range is between -1 and +1). The function performs
* the Bell-202 FSK modem decode processing, and, if it detects a valid bit,
* will call the bithandler associated with the attributes structure.
*
* For the Bell-202 standard, a logical zero (space) is 2200 Hz, and a logical
* one (mark) is 1200 Hz.
*/
void
dsp_fsk_sample (dsp_fsk_handle_t *handle, double normalized_sample)
{
double val;
double factors[4];
int i, j;
/* if we can avoid processing samples, do so */
if (handle->downsampling_count != 1) {
if (handle->current_downsample < handle->downsampling_count) {
handle->current_downsample++;
return; /* throw this sample out */
}
handle->current_downsample = 1;
}
/* store sample in buffer */
handle->buffer[handle->ringstart++] = normalized_sample;
if (handle->ringstart >= handle->corrsize) {
handle->ringstart = 0;
}
/* do the correlation calculation */
factors[0] = factors[1] = factors[2] = factors[3] = 0; /* clear out intermediate sums */
j = handle->ringstart;
for (i = 0; i < handle->corrsize; i++) {
if (j >= handle->corrsize) {
j = 0;
}
val = handle->buffer[j];
factors[0] += handle->correlates[0][i] * val;
factors[1] += handle->correlates[1][i] * val;
factors[2] += handle->correlates[2][i] * val;
factors[3] += handle->correlates[3][i] * val;
j++;
}
/* store the bit (bit value is comparison of the two sets of correlate factors) */
handle->previous_bit = handle->current_bit;
handle->current_bit = (factors[0] * factors[0] + factors[1] * factors[1] > factors[2] * factors[2] + factors[3] * factors[3]);
/* if there's a transition, we can synchronize the cell position */
if (handle->previous_bit != handle->current_bit) {
handle->cellpos = 0.5; /* adjust cell position to be in the middle of the cell */
}
handle->cellpos += handle->celladj; /* walk the cell along */
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;
case FSK_STATE_CHANSEIZE:
{
if (handle->last_bit != handle->current_bit) {
handle->conscutive_state_bits++;
} else {
handle->conscutive_state_bits = 0;
}
if (handle->conscutive_state_bits > 15) {
handle->state = FSK_STATE_CARRIERSIG;
handle->conscutive_state_bits = 0;
}
}
break;
case FSK_STATE_CARRIERSIG:
{
if (handle->current_bit) {
handle->conscutive_state_bits++;
} else {
handle->conscutive_state_bits = 0;
}
if (handle->conscutive_state_bits > 15) {
handle->state = FSK_STATE_DATA;
handle->conscutive_state_bits = 0;
}
}
break;
}
handle->last_bit = handle->current_bit;
}
}
+113
View File
@@ -0,0 +1,113 @@
/*
* bell202.h
*
* Copyright (c) 2005 Robert Krten. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This module contains the manifest constants and declarations for
* the Bell-202 1200 baud FSK modem.
*
* 2005 03 20 R. Krten created
*/
#ifndef __FSK_H__
#define __FSK_H__
#include "uart.h"
typedef struct {
int freq_space; /* Frequency of the 0 bit */
int freq_mark; /* Frequency of the 1 bit */
int baud_rate; /* baud rate for the modem */
} fsk_modem_definition_t;
/* Must be kept in sync with fsk_modem_definitions array in fsk.c */
/* V.23 definitions: http://www.itu.int/rec/recommendation.asp?type=folders&lang=e&parent=T-REC-V.23 */
typedef enum {
FSK_V23_FORWARD_MODE1 = 0, /* Maximum 600 bps for long haul */
FSK_V23_FORWARD_MODE2, /* Standard 1200 bps V.23 */
FSK_V23_BACKWARD, /* 75 bps return path for V.23 */
FSK_BELL202 /* Bell 202 half-duplex 1200 bps */
} fsk_modem_types_t;
typedef enum {
FSK_STATE_CHANSEIZE = 0,
FSK_STATE_CARRIERSIG,
FSK_STATE_DATA
} fsk_state_t;
typedef struct dsp_fsk_attr_s
{
int sample_rate; /* sample rate in HZ */
bithandler_func_t bithandler; /* bit handler */
void *bithandler_arg; /* arbitrary ID passed to bithandler as first argument */
bytehandler_func_t bytehandler; /* byte handler */
void *bytehandler_arg; /* arbitrary ID passed to bytehandler as first argument */
} dsp_fsk_attr_t;
typedef struct
{
fsk_state_t state;
dsp_fsk_attr_t attr; /* attributes structure */
double *correlates[4]; /* one for each of sin/cos for mark/space */
int corrsize; /* correlate size (also number of samples in ring buffer) */
double *buffer; /* sample ring buffer */
int ringstart; /* ring buffer start offset */
double cellpos; /* bit cell position */
double celladj; /* bit cell adjustment for each sample */
int previous_bit; /* previous bit (for detecting a transition to sync-up cell position) */
int current_bit; /* current bit */
int last_bit;
int downsampling_count; /* number of samples to skip */
int current_downsample; /* current skip count */
int conscutive_state_bits; /* number of bits in a row that matches the pattern for the current state */
} dsp_fsk_handle_t;
/*
* Function prototypes
*
* General calling order is:
* a) create the attributes structure (dsp_fsk_attr_init)
* b) initialize fields in the attributes structure (dsp_fsk_attr_set_*)
* c) create a Bell-202 handle (dsp_fsk_create)
* d) feed samples through the handler (dsp_fsk_sample)
*/
void dsp_fsk_attr_init(dsp_fsk_attr_t *attributes);
bithandler_func_t dsp_fsk_attr_get_bithandler(dsp_fsk_attr_t *attributes, void **bithandler_arg);
void dsp_fsk_attr_set_bithandler(dsp_fsk_attr_t *attributes, bithandler_func_t bithandler, void *bithandler_arg);
bytehandler_func_t dsp_fsk_attr_get_bytehandler(dsp_fsk_attr_t *attributes, void **bytehandler_arg);
void dsp_fsk_attr_set_bytehandler(dsp_fsk_attr_t *attributes, bytehandler_func_t bytehandler, void *bytehandler_arg);
int dsp_fsk_attr_get_samplerate(dsp_fsk_attr_t *attributes);
int dsp_fsk_attr_set_samplerate(dsp_fsk_attr_t *attributes, int samplerate);
dsp_fsk_handle_t * dsp_fsk_create(dsp_fsk_attr_t *attributes);
void dsp_fsk_destroy(dsp_fsk_handle_t **handle);
void dsp_fsk_sample(dsp_fsk_handle_t *handle, double normalized_sample);
extern fsk_modem_definition_t fsk_modem_definitions[];
#endif
+398
View File
@@ -0,0 +1,398 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Anthony Minessale II <anthm@freeswitch.org>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Anthony Minessale II <anthm@freeswitch.org>
*
* mod_fsk -- FSK data transfer
*
*/
#include "switch.h"
#include "fsk_callerid.h"
void bitstream_init(bitstream_t *bsp, uint8_t *data, uint32_t datalen, endian_t endian, uint8_t ss)
{
memset(bsp, 0, sizeof(*bsp));
bsp->data = data;
bsp->datalen = datalen;
bsp->endian = endian;
bsp->ss = ss;
if (endian < 0) {
bsp->top = bsp->bit_index = 7;
bsp->bot = 0;
} else {
bsp->top = bsp->bit_index = 0;
bsp->bot = 7;
}
}
int8_t bitstream_get_bit(bitstream_t *bsp)
{
int8_t bit = -1;
if (bsp->byte_index >= bsp->datalen) {
goto done;
}
if (bsp->ss) {
if (!bsp->ssv) {
bsp->ssv = 1;
return 0;
} else if (bsp->ssv == 2) {
bsp->byte_index++;
bsp->ssv = 0;
return 1;
}
}
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;
}
done:
return bit;
}
static void fsk_byte_handler (void *x, int data)
{
fsk_data_state_t *state = (fsk_data_state_t *) x;
uint8_t byte = (uint8_t)data;
top:
if (state->init == 3) {
return;
}
if (state->dlen) {
goto add_byte;
}
if (state->bpos == 1) {
state->blen = byte;
if ((uint32_t)(state->dlen = state->bpos + byte + 2) > state->bufsize) {
state->dlen = state->bufsize;
}
goto top;
}
add_byte:
if (state->bpos <= state->dlen) {
state->buf[state->bpos++] = byte;
} else {
state->init = 3;
}
}
switch_status_t fsk_data_init(fsk_data_state_t *state, uint8_t *data, uint32_t datalen)
{
memset(state, 0, sizeof(*state));
state->buf = data;
state->bufsize = datalen;
state->bpos = 2;
return SWITCH_STATUS_SUCCESS;
}
switch_status_t fsk_data_add_sdmf(fsk_data_state_t *state, const char *date, char *number)
{
size_t dlen = strlen(date);
size_t nlen = strlen(number);
state->buf[0] = CID_TYPE_SDMF;
memcpy(&state->buf[state->bpos], date, dlen);
state->bpos += dlen;
memcpy(&state->buf[state->bpos], number, nlen);
state->bpos += nlen;
return SWITCH_STATUS_SUCCESS;
}
switch_status_t fsk_data_add_mdmf(fsk_data_state_t *state, mdmf_type_t type, const uint8_t *data, uint32_t datalen)
{
state->buf[0] = CID_TYPE_MDMF;
state->buf[state->bpos++] = type;
state->buf[state->bpos++] = (uint8_t)datalen;
memcpy(&state->buf[state->bpos], data, datalen);
state->bpos += datalen;
return SWITCH_STATUS_SUCCESS;
}
switch_status_t fsk_data_add_checksum(fsk_data_state_t *state)
{
uint32_t i;
uint8_t check = 0;
state->buf[1] = (uint8_t)(state->bpos - 2);
for (i = 0; i < state->bpos; i++) {
check = check + state->buf[i];
}
state->checksum = state->buf[state->bpos] = (uint8_t)(256 - check);
state->bpos++;
state->dlen = state->bpos;
state->blen = state->buf[1];
return SWITCH_STATUS_SUCCESS;
}
switch_status_t fsk_data_parse(fsk_data_state_t *state, size_t *type, char **data, size_t *len)
{
size_t i;
int sum = 0;
top:
if (state->checksum != 0 || state->ppos >= state->dlen - 1) {
return SWITCH_STATUS_FALSE;
}
if (!state->ppos) {
for(i = 0; i < state->bpos; i++) {
sum += state->buf[i];
}
state->checksum = sum % 256;
state->ppos = 2;
if (state->buf[0] != CID_TYPE_MDMF && state->buf[0] != CID_TYPE_SDMF) {
state->checksum = -1;
}
goto top;
}
if (state->buf[0] == CID_TYPE_SDMF) {
/* convert sdmf to mdmf so we don't need 2 parsers */
if (state->ppos == 2) {
*type = MDMF_DATETIME;
*len = 8;
} else {
if (state->buf[state->ppos] == 'P' || state->buf[state->ppos] == 'O') {
*type = MDMF_NO_NUM;
*len = 1;
} else {
*type = MDMF_PHONE_NUM;
*len = state->blen - 8;
}
}
*data = (char *)&state->buf[state->ppos];
state->ppos += *len;
return SWITCH_STATUS_SUCCESS;
} else if (state->buf[0] == CID_TYPE_MDMF) {
*type = state->buf[state->ppos++];
*len = state->buf[state->ppos++];
*data = (char *)&state->buf[state->ppos];
state->ppos += *len;
return SWITCH_STATUS_SUCCESS;
}
return SWITCH_STATUS_FALSE;
}
switch_status_t fsk_demod_feed(fsk_data_state_t *state, int16_t *data, size_t samples)
{
uint32_t x;
int16_t *sp = data;
if (state->init == 3) {
return SWITCH_STATUS_FALSE;
}
for (x = 0; x < samples; x++) {
dsp_fsk_sample (state->fsk1200_handle, (double) *sp++ / 32767.0);
if (state->dlen && state->bpos >= state->dlen) {
state->init = 3;
return SWITCH_STATUS_FALSE;
}
}
return SWITCH_STATUS_SUCCESS;
}
switch_status_t fsk_demod_destroy(fsk_data_state_t *state)
{
dsp_fsk_destroy(&state->fsk1200_handle);
memset(state, 0, sizeof(*state));
return SWITCH_STATUS_SUCCESS;
}
int fsk_demod_init(fsk_data_state_t *state, int rate, uint8_t *buf, size_t bufsize)
{
dsp_fsk_attr_t fsk1200_attr;
if (state->fsk1200_handle) {
dsp_fsk_destroy(&state->fsk1200_handle);
}
memset(state, 0, sizeof(*state));
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);
state->fsk1200_handle = dsp_fsk_create (&fsk1200_attr);
if (state->fsk1200_handle == NULL) {
return SWITCH_STATUS_FALSE;
}
return SWITCH_STATUS_SUCCESS;
}
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) {
fsk_trans->bit_accum -= (FSK_MOD_FACTOR + fsk_trans->bit_factor);
break;
}
buf[i] = teletone_dds_state_modulate_sample(&fsk_trans->dds, bit);
}
return i;
}
int32_t fsk_modulator_generate_carrier_bits(fsk_modulator_t *fsk_trans, uint32_t bits)
{
uint32_t i = 0;
size_t r = 0;
int8_t bit = 1;
for (i = 0; i < 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) {
break;
}
} else {
break;
}
}
return i;
}
void fsk_modulator_generate_chan_sieze(fsk_modulator_t *fsk_trans)
{
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) {
break;
}
} else {
break;
}
bit = !bit;
}
}
void fsk_modulator_send_data(fsk_modulator_t *fsk_trans)
{
size_t r = 0;
int8_t bit = 0;
while((bit = bitstream_get_bit(&fsk_trans->bs)) > -1) {
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) {
break;
}
} else {
break;
}
}
}
switch_status_t fsk_modulator_init(fsk_modulator_t *fsk_trans,
fsk_modem_types_t modem_type,
uint32_t sample_rate,
fsk_data_state_t *fsk_data,
float db_level,
uint32_t carrier_bits_start,
uint32_t carrier_bits_stop,
uint32_t chan_sieze_bits,
fsk_write_sample_t write_sample_callback,
void *user_data)
{
memset(fsk_trans, 0, sizeof(*fsk_trans));
fsk_trans->modem_type = modem_type;
teletone_dds_state_set_tone(&fsk_trans->dds, fsk_modem_definitions[fsk_trans->modem_type].freq_space, sample_rate, 0);
teletone_dds_state_set_tone(&fsk_trans->dds, fsk_modem_definitions[fsk_trans->modem_type].freq_mark, sample_rate, 1);
fsk_trans->bit_factor = (uint32_t)((fsk_modem_definitions[fsk_trans->modem_type].baud_rate * FSK_MOD_FACTOR) / (float)sample_rate);
fsk_trans->samples_per_bit = (uint32_t) (sample_rate / fsk_modem_definitions[fsk_trans->modem_type].baud_rate);
fsk_trans->est_bytes = (int32_t)(((fsk_data->dlen * 10) + carrier_bits_start + carrier_bits_stop + chan_sieze_bits) * ((fsk_trans->samples_per_bit + 1) * 2));
fsk_trans->bit_accum = 0;
fsk_trans->fsk_data = fsk_data;
teletone_dds_state_set_tx_level(&fsk_trans->dds, db_level);
bitstream_init(&fsk_trans->bs, fsk_trans->fsk_data->buf, (uint32_t)fsk_trans->fsk_data->dlen, ENDIAN_BIG, 1);
fsk_trans->carrier_bits_start = carrier_bits_start;
fsk_trans->carrier_bits_stop = carrier_bits_stop;
fsk_trans->chan_sieze_bits = chan_sieze_bits;
fsk_trans->write_sample_callback = write_sample_callback;
fsk_trans->user_data = user_data;
return SWITCH_STATUS_SUCCESS;
}
+144
View File
@@ -0,0 +1,144 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Anthony Minessale II <anthm@freeswitch.org>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Anthony Minessale II <anthm@freeswitch.org>
*
* mod_fsk -- FSK data transfer
*
*/
#ifndef __FSK_CALLER_ID_H
#define __FSK_CALLER_ID_H
SWITCH_BEGIN_EXTERN_C
#include "fsk.h"
#include "uart.h"
#define FSK_MOD_FACTOR 0x10000
typedef enum {
ENDIAN_BIG = 1,
ENDIAN_LITTLE = -1
} endian_t;
typedef enum {
CID_TYPE_SDMF = 0x04,
CID_TYPE_MDMF = 0x80
} cid_type_t;
typedef enum {
MDMF_DATETIME = 1,
MDMF_PHONE_NUM = 2,
MDMF_DDN = 3,
MDMF_NO_NUM = 4,
MDMF_PHONE_NAME = 7,
MDMF_NO_NAME = 8,
MDMF_ALT_ROUTE = 9,
MDMF_NAME_VALUE = 10,
MDMF_INVALID = 11
} mdmf_type_t;
struct bitstream {
uint8_t *data;
uint32_t datalen;
uint32_t byte_index;
uint8_t bit_index;
int8_t endian;
uint8_t top;
uint8_t bot;
uint8_t ss;
uint8_t ssv;
};
struct fsk_data_state {
dsp_fsk_handle_t *fsk1200_handle;
uint8_t init;
uint8_t *buf;
size_t bufsize;
size_t blen;
size_t bpos;
size_t dlen;
size_t ppos;
int checksum;
};
typedef struct bitstream bitstream_t;
typedef struct fsk_data_state fsk_data_state_t;
typedef switch_status_t (*fsk_write_sample_t)(int16_t *buf, size_t buflen, void *user_data);
struct fsk_modulator {
teletone_dds_state_t dds;
bitstream_t bs;
uint32_t carrier_bits_start;
uint32_t carrier_bits_stop;
uint32_t chan_sieze_bits;
uint32_t bit_factor;
uint32_t bit_accum;
uint32_t sample_counter;
int32_t samples_per_bit;
int32_t est_bytes;
fsk_modem_types_t modem_type;
fsk_data_state_t *fsk_data;
fsk_write_sample_t write_sample_callback;
void *user_data;
int16_t sample_buffer[64];
};
typedef int (*fsk_data_decoder_t)(fsk_data_state_t *state);
typedef void (*logger_t)(const char *file, const char *func, int line, int level, const char *fmt, ...);
typedef struct fsk_modulator fsk_modulator_t;
switch_status_t fsk_data_init(fsk_data_state_t *state, uint8_t *data, uint32_t datalen);
void bitstream_init(bitstream_t *bsp, uint8_t *data, uint32_t datalen, endian_t endian, uint8_t ss);
int8_t bitstream_get_bit(bitstream_t *bsp);
switch_status_t fsk_data_add_mdmf(fsk_data_state_t *state, mdmf_type_t type, const uint8_t *data, uint32_t datalen);
switch_status_t fsk_data_add_checksum(fsk_data_state_t *state);
switch_status_t fsk_data_parse(fsk_data_state_t *state, size_t *type, char **data, size_t *len);
switch_status_t fsk_demod_feed(fsk_data_state_t *state, int16_t *data, size_t samples);
switch_status_t fsk_demod_destroy(fsk_data_state_t *state);
int fsk_demod_init(fsk_data_state_t *state, int rate, uint8_t *buf, size_t bufsize);
size_t fsk_modulator_generate_bit(fsk_modulator_t *fsk_trans, int8_t bit, int16_t *buf, size_t buflen);
int32_t fsk_modulator_generate_carrier_bits(fsk_modulator_t *fsk_trans, uint32_t bits);
void fsk_modulator_generate_chan_sieze(fsk_modulator_t *fsk_trans);
void fsk_modulator_send_data(fsk_modulator_t *fsk_trans);
switch_status_t fsk_modulator_init(fsk_modulator_t *fsk_trans,
fsk_modem_types_t modem_type,
uint32_t sample_rate,
fsk_data_state_t *fsk_data,
float db_level,
uint32_t carrier_bits_start,
uint32_t carrier_bits_stop,
uint32_t chan_sieze_bits,
fsk_write_sample_t write_sample_callback,
void *user_data);
#define fsk_modulator_send_all(_it) fsk_modulator_generate_chan_sieze(_it); \
fsk_modulator_generate_carrier_bits(_it, _it->carrier_bits_start); \
fsk_modulator_send_data(_it); \
fsk_modulator_generate_carrier_bits(_it, _it->carrier_bits_stop)
SWITCH_END_EXTERN_C
#endif
+486
View File
@@ -0,0 +1,486 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Anthony Minessale II <anthm@freeswitch.org>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Anthony Minessale II <anthm@freeswitch.org>
*
* mod_fsk.c -- FSK data transfer
*
*/
#include <switch.h>
#include "fsk_callerid.h"
/* Prototypes */
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_fsk_shutdown);
SWITCH_MODULE_RUNTIME_FUNCTION(mod_fsk_runtime);
SWITCH_MODULE_LOAD_FUNCTION(mod_fsk_load);
/* 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_status_t my_write_sample(int16_t *buf, size_t buflen, void *user_data)
{
switch_buffer_t *buffer = (switch_buffer_t *) user_data;
switch_buffer_write(buffer, buf, buflen * 2);
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t write_fsk_data(uint32_t rate, int32_t db, switch_buffer_t *buffer, switch_event_t *event, const char *prefix)
{
fsk_modulator_t fsk_trans;
fsk_data_state_t fsk_data = {0};
uint8_t databuf[1024] = "";
char time_str[9];
struct tm tm;
time_t now;
switch_event_header_t *hp;
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);
fsk_data_init(&fsk_data, databuf, sizeof(databuf));
fsk_data_add_mdmf(&fsk_data, MDMF_DATETIME, (uint8_t *)time_str, strlen(time_str));
if (prefix) {
plen = strlen(prefix);
}
if (event) {
for (hp = event->headers; hp; hp = hp->next) {
char *packed;
char *name = hp->name;
if (plen && strncasecmp(name, prefix, plen)) {
continue;
}
name += plen;
if (zstr(name)) {
continue;
}
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")) {
fsk_data_add_mdmf(&fsk_data, MDMF_PHONE_NAME, (uint8_t *)hp->value, strlen(hp->value));
} else {
packed = switch_mprintf("%q:%q", name, hp->value);
fsk_data_add_mdmf(&fsk_data, MDMF_NAME_VALUE, (uint8_t *)packed, strlen(packed));
free(packed);
}
}
}
fsk_data_add_checksum(&fsk_data);
fsk_modulator_init(&fsk_trans, FSK_BELL202, rate, &fsk_data, db, 180, 5, 300, my_write_sample, buffer);
fsk_modulator_send_all((&fsk_trans));
fsk_demod_destroy(&fsk_data);
return SWITCH_STATUS_SUCCESS;
}
SWITCH_STANDARD_APP(fsk_send_function) {
switch_event_t *event = NULL;
switch_buffer_t *buffer;
switch_slin_data_t sdata = { 0 };
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");
return;
}
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)) {
status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
if (!SWITCH_READ_ACCEPTABLE(status)) {
break;
}
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,
sdata.codec.implementation->decoded_bytes_per_packet - sdata.write_frame.datalen);
sdata.write_frame.datalen = sdata.codec.implementation->decoded_bytes_per_packet;
}
sdata.write_frame.samples = sdata.write_frame.datalen / 2;
switch_core_session_write_frame(sdata.session, &sdata.write_frame, SWITCH_IO_FLAG_NONE, 0);
}
switch_buffer_destroy(&buffer);
switch_core_codec_destroy(&sdata.codec);
switch_core_session_set_read_codec(session, NULL);
}
typedef struct {
switch_core_session_t *session;
fsk_data_state_t fsk_data;
uint8_t fbuf[512];
int skip;
} switch_fsk_detect_t;
static switch_bool_t fsk_detect_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type)
{
switch_fsk_detect_t *pvt = (switch_fsk_detect_t *) user_data;
//switch_frame_t *frame = NULL;
switch_channel_t *channel = switch_core_session_get_channel(pvt->session);
switch (type) {
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:
{
fsk_demod_destroy(&pvt->fsk_data);
}
break;
case SWITCH_ABC_TYPE_WRITE_REPLACE:
case SWITCH_ABC_TYPE_READ_REPLACE:
{
switch_frame_t *rframe;
if (type == SWITCH_ABC_TYPE_READ_REPLACE) {
rframe = switch_core_media_bug_get_read_replace_frame(bug);
} else {
rframe = switch_core_media_bug_get_write_replace_frame(bug);
}
if (!pvt->skip && fsk_demod_feed(&pvt->fsk_data, rframe->data, rframe->datalen / 2) != SWITCH_STATUS_SUCCESS) {
char str[1024] = "";
size_t type, mlen;
char *sp;
switch_event_t *event;
const char *app_var;
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);
//printf("TYPE %u LEN %u VAL [%s]\n", (unsigned)type, (unsigned)mlen, str);
val = str;
switch(type) {
case MDMF_DATETIME:
varname = "fsk_datetime";
break;
case MDMF_PHONE_NAME:
varname = "fsk_phone_name";
break;
case MDMF_PHONE_NUM:
varname = "fsk_phone_num";
break;
case MDMF_NAME_VALUE:
varname = switch_core_session_sprintf(pvt->session, "fsk_%s", val);
if ((p = strchr(varname, ':'))) {
*p++ = '\0';
val = p;
}
break;
default:
break;
}
if (varname && val) {
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_add_header_string(event, SWITCH_STACK_BOTTOM, varname, val);
}
}
}
if (event) {
if (switch_core_session_queue_event(pvt->session, &event) != SWITCH_STATUS_SUCCESS) {
switch_event_destroy(&event);
}
}
if ((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_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_core_media_bug_set_read_replace_frame(bug, rframe);
} else {
switch_core_media_bug_set_write_replace_frame(bug, rframe);
}
if (pvt->skip && !--pvt->skip) {
return SWITCH_FALSE;
}
}
break;
case SWITCH_ABC_TYPE_WRITE:
default:
break;
}
return SWITCH_TRUE;
}
switch_status_t stop_fsk_detect_session(switch_core_session_t *session)
{
switch_media_bug_t *bug;
switch_channel_t *channel = switch_core_session_get_channel(session);
if ((bug = switch_channel_get_private(channel, "fsk"))) {
switch_channel_set_private(channel, "fsk", NULL);
switch_core_media_bug_remove(session, &bug);
return SWITCH_STATUS_SUCCESS;
}
return SWITCH_STATUS_FALSE;
}
switch_status_t fsk_detect_session(switch_core_session_t *session, const char *flags)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_media_bug_t *bug;
switch_status_t status;
switch_fsk_detect_t *pvt = { 0 };
switch_codec_implementation_t read_impl = { 0 };
int bflags = SMBF_READ_REPLACE;
if (strchr(flags, 'w')) {
bflags = SMBF_WRITE_REPLACE;
}
switch_core_session_get_read_impl(session, &read_impl);
if (!(pvt = switch_core_session_alloc(session, sizeof(*pvt)))) {
return SWITCH_STATUS_MEMERR;
}
pvt->session = session;
if (switch_channel_pre_answer(channel) != SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_FALSE;
}
if ((status = switch_core_media_bug_add(session, "fsk_detect", NULL,
fsk_detect_callback, pvt, 0, bflags | SMBF_NO_PAUSE, &bug)) != SWITCH_STATUS_SUCCESS) {
return status;
}
switch_channel_set_private(channel, "fsk", bug);
return SWITCH_STATUS_SUCCESS;
}
SWITCH_STANDARD_APP(fsk_recv_function)
{
fsk_detect_session(session, data);
}
SWITCH_STANDARD_APP(fsk_display_function)
{
/* expected to be called via 'execute_on_fsk' -- passes display update over FSK */
const char *cid_name, *cid_num;
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_core_session_message_t *msg;
switch_core_session_t *psession, *usession = NULL;
char *flags = (char *) data;
cid_name = switch_channel_get_variable(channel, "fsk_phone_name");
cid_num = switch_channel_get_variable(channel, "fsk_phone_num");
if (zstr(cid_name)) {
cid_name = cid_num;
}
if (zstr(cid_num)) {
return;
}
if (strchr(flags, 'b')) {
if (switch_core_session_get_partner(session, &psession) == SWITCH_STATUS_SUCCESS) {
usession = psession;
}
}
if (!usession) {
usession = session;
}
msg = switch_core_session_alloc(usession, sizeof(*msg));
MESSAGE_STAMP_FFL(msg);
msg->message_id = SWITCH_MESSAGE_INDICATE_DISPLAY;
msg->string_array_arg[0] = switch_core_session_strdup(usession, cid_name);
msg->string_array_arg[1] = switch_core_session_strdup(usession, cid_num);
msg->from = __FILE__;
switch_core_session_queue_message(usession, msg);
if (psession) {
switch_core_session_rwunlock(psession);
psession = NULL;
}
}
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));
}
if (!(fsk_simplify_profile = switch_channel_get_variable(channel, "fsk_simplify_profile"))) {
fsk_simplify_profile = "internal";
}
fsk_simplify_context = switch_channel_get_variable(channel, "fsk_simplify_context");
if (!zstr(sip_uri)) {
switch_core_session_t *psession;
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_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);
}
}
}
/* Macro expands to: switch_status_t mod_fsk_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool) */
SWITCH_MODULE_LOAD_FUNCTION(mod_fsk_load)
{
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);
SWITCH_ADD_APP(app_interface, "fsk_send", "fsk_send", NULL, fsk_send_function, NULL, SAF_NONE);
SWITCH_ADD_APP(app_interface, "fsk_recv", "fsk_recv", NULL, fsk_recv_function, NULL, SAF_NONE);
SWITCH_ADD_APP(app_interface, "fsk_simplify", "fsk_simplify", NULL, fsk_simplify_function, NULL, SAF_NONE);
SWITCH_ADD_APP(app_interface, "fsk_display", "fsk_display", NULL, fsk_display_function, NULL, SAF_NONE);
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}
/*
Called when the system shuts down
Macro expands to: switch_status_t mod_fsk_shutdown() */
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_fsk_shutdown)
{
/* Cleanup dynamically allocated config settings */
return SWITCH_STATUS_SUCCESS;
}
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4
*/
+124
View File
@@ -0,0 +1,124 @@
/*
* uart.c
*
* Copyright (c) 2005 Robert Krten. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This module contains a simple 8-bit UART, which performs a callback
* with the decoded byte value.
*
* 2005 06 11 R. Krten created
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "uart.h"
/*
* dsp_uart_attr_init
*
* Initializes the attributes structure; this must be done before the
* attributes structure is used.
*/
void dsp_uart_attr_init (dsp_uart_attr_t *attr)
{
memset (attr, 0, sizeof (*attr));
}
/*
* dsp_uart_attr_get_bytehandler
* dsp_uart_attr_set_bytehandler
*
* These functions get and set their respective elements from the
* attributes structure. If an error code is returned, it is just
* zero == ok, -1 == fail.
*/
bytehandler_func_t dsp_uart_attr_get_bytehandler(dsp_uart_attr_t *attr, void **bytehandler_arg)
{
*bytehandler_arg = attr->bytehandler_arg;
return attr->bytehandler;
}
void dsp_uart_attr_set_bytehandler(dsp_uart_attr_t *attr, bytehandler_func_t bytehandler, void *bytehandler_arg)
{
attr->bytehandler = bytehandler;
attr->bytehandler_arg = bytehandler_arg;
}
dsp_uart_handle_t *dsp_uart_create(dsp_uart_attr_t *attr)
{
dsp_uart_handle_t *handle;
handle = malloc(sizeof (*handle));
if (handle) {
memset(handle, 0, sizeof (*handle));
/* fill the attributes member */
memcpy(&handle->attr, attr, sizeof (*attr));
}
return handle;
}
void dsp_uart_destroy(dsp_uart_handle_t **handle)
{
if (*handle) {
free(*handle);
*handle = NULL;
}
}
void dsp_uart_bit_handler(void *x, int bit)
{
dsp_uart_handle_t *handle = (dsp_uart_handle_t *) x;
if (!handle->have_start) {
if (bit) {
return; /* waiting for start bit (0) */
}
handle->have_start = 1;
handle->data = 0;
handle->nbits = 0;
return;
}
handle->data >>= 1;
handle->data |= 0x80 * !!bit;
handle->nbits++;
if (handle->nbits == 8) {
handle->attr.bytehandler(handle->attr.bytehandler_arg, handle->data);
handle->nbits = 0;
handle->data = 0;
handle->have_start = 0;
}
/* might consider handling errors in the future... */
}
+76
View File
@@ -0,0 +1,76 @@
/*
* uart.h
*
* Copyright (c) 2005 Robert Krten. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This module contains the manifest constants and declarations for
* the UART module.
*
* 2005 06 19 R. Krten created
*/
#ifndef __UART_H__
#define __UART_H__
typedef void (*bytehandler_func_t) (void *, int);
typedef void (*bithandler_func_t) (void *, int);
typedef struct dsp_uart_attr_s
{
bytehandler_func_t bytehandler; /* byte handler */
void *bytehandler_arg; /* arbitrary ID passed to bytehandler as first argument */
} dsp_uart_attr_t;
typedef struct
{
dsp_uart_attr_t attr;
int have_start; /* wait for start bit to show up */
int data; /* data buffer */
int nbits; /* number of bits accumulated so far */
} dsp_uart_handle_t;
/*
* Function prototypes
*
* General calling order is:
* a) create the attributes structure (dsp_uart_attr_init)
* b) initialize fields in the attributes structure (dsp_uart_attr_set_*)
* c) create a Bell-202 handle (dsp_uart_create)
* d) feed bits through dsp_uart_bit_handler
*/
void dsp_uart_attr_init(dsp_uart_attr_t *attributes);
bytehandler_func_t dsp_uart_attr_get_bytehandler(dsp_uart_attr_t *attributes, void **bytehandler_arg);
void dsp_uart_attr_set_bytehandler(dsp_uart_attr_t *attributes, bytehandler_func_t bytehandler, void *bytehandler_arg);
dsp_uart_handle_t * dsp_uart_create(dsp_uart_attr_t *attributes);
void dsp_uart_destroy(dsp_uart_handle_t **handle);
void dsp_uart_bit_handler(void *handle, int bit);
#endif
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
+11 -7
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -263,10 +263,14 @@ SWITCH_HASH_DELETE_FUNC(limit_hash_remote_cleanup_callback)
SWITCH_STANDARD_SCHED_FUNC(limit_hash_cleanup_callback)
{
switch_thread_rwlock_wrlock(globals.limit_hash_rwlock);
switch_core_hash_delete_multi(globals.limit_hash, limit_hash_cleanup_delete_callback, NULL);
if (globals.limit_hash) {
switch_core_hash_delete_multi(globals.limit_hash, limit_hash_cleanup_delete_callback, NULL);
}
switch_thread_rwlock_unlock(globals.limit_hash_rwlock);
task->runtime = switch_epoch_time_now(NULL) + LIMIT_HASH_CLEANUP_INTERVAL;
if (globals.limit_hash) {
task->runtime = switch_epoch_time_now(NULL) + LIMIT_HASH_CLEANUP_INTERVAL;
}
}
/* !\brief Releases usage of a limit_hash-controlled ressource */
@@ -991,7 +995,9 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_hash_shutdown)
free(val);
switch_core_hash_delete(globals.db_hash, key);
}
switch_core_hash_destroy(&globals.limit_hash);
switch_core_hash_destroy(&globals.db_hash);
switch_thread_rwlock_unlock(globals.limit_hash_rwlock);
switch_thread_rwlock_unlock(globals.db_hash_rwlock);
@@ -999,8 +1005,6 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_hash_shutdown)
switch_thread_rwlock_destroy(globals.db_hash_rwlock);
switch_thread_rwlock_destroy(globals.limit_hash_rwlock);
switch_core_hash_destroy(&globals.limit_hash);
switch_core_hash_destroy(&globals.db_hash);
return SWITCH_STATUS_SUCCESS;
}
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005/2006, Anthony Minessale II <anthmct@yahoo.com>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -17,7 +17,7 @@
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Anthony Minessale II <anthmct@yahoo.com>
* Anthony Minessale II <anthm@freeswitch.org>
*
* The Initial Developer of this module is
* Darren Schreiber <d@d-man.org>
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005/2006, Anthony Minessale II <anthmct@yahoo.com>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -17,13 +17,13 @@
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Anthony Minessale II <anthmct@yahoo.com>
* Anthony Minessale II <anthm@freeswitch.org>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Anthony Minessale II <anthmct@yahoo.com>
* Anthony Minessale II <anthm@freeswitch.org>
* Neal Horman <neal at wanlink dot com>
* Tihomir Culjaga <tculjaga@gmail.com>
*
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
+2 -2
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -83,7 +83,7 @@ static switch_status_t spy_on_exchange_media(switch_core_session_t *session)
static switch_status_t spy_on_park(switch_core_session_t *session)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
const char *moh = switch_channel_get_variable(channel, "hold_music");
const char *moh = switch_channel_get_hold_music(channel);
while (switch_channel_ready(channel) && switch_channel_get_state(channel) == CS_PARK) {
if (moh) {
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -234,7 +234,7 @@ SWITCH_STANDARD_APP(valet_parking_function)
}
if (!(tmp = switch_channel_get_variable(channel, "valet_hold_music"))) {
tmp = switch_channel_get_variable(channel, "hold_music");
tmp = switch_channel_get_hold_music(channel);
}
if (tmp)
music = tmp;
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -311,6 +311,7 @@ static void destroy_profile(const char *profile_name, switch_bool_t block)
/* Static buffer, 2 bytes */
static switch_xml_config_string_options_t config_dtmf = { NULL, 2, "[0-9#\\*]" };
static switch_xml_config_string_options_t config_dtmf_optional = { NULL, 2, "[0-9#\\*]?" };
static switch_xml_config_string_options_t config_login_keys = { NULL, 16, "[0-9#\\*]*" };
static switch_xml_config_string_options_t config_file_ext = { NULL, 10, NULL };
static switch_xml_config_int_options_t config_int_0_10000 = { SWITCH_TRUE, 0, SWITCH_TRUE, 10000 };
@@ -520,8 +521,8 @@ vm_profile_t *profile_set_config(vm_profile_t *profile)
SWITCH_CONFIG_SET_ITEM(profile->config[i++], "urgent-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
&profile->urgent_key, "*", &config_dtmf, NULL, NULL);
SWITCH_CONFIG_SET_ITEM(profile->config[i++], "operator-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
&profile->operator_key, "", &config_dtmf, NULL, NULL);
SWITCH_CONFIG_SET_ITEM(profile->config[i++], "vmain-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &profile->vmain_key, "", &config_dtmf, NULL, NULL);
&profile->operator_key, "", &config_dtmf_optional, NULL, NULL);
SWITCH_CONFIG_SET_ITEM(profile->config[i++], "vmain-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &profile->vmain_key, "", &config_dtmf_optional, NULL, NULL);
SWITCH_CONFIG_SET_ITEM(profile->config[i++], "vmain-extension", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
&profile->vmain_ext, "", &profile->config_str_pool, NULL, NULL);
SWITCH_CONFIG_SET_ITEM(profile->config[i++], "forward-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
@@ -1973,12 +1974,22 @@ static void voicemail_check_main(switch_core_session_t *session, vm_profile_t *p
if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
TRY_CODE(switch_ivr_phrase_macro(session, VM_CHOOSE_GREETING_FAIL_MACRO, NULL, NULL, NULL));
} else {
switch_event_t *params;
TRY_CODE(switch_ivr_phrase_macro(session, VM_CHOOSE_GREETING_SELECTED_MACRO, input, NULL, NULL));
sql =
switch_mprintf("update voicemail_prefs set greeting_path='%s' where username='%s' and domain='%s'", file_path, myid,
domain_name);
vm_execute_sql(profile, sql, profile->mutex);
switch_safe_free(sql);
switch_event_create_subclass(&params, SWITCH_EVENT_CUSTOM, VM_EVENT_MAINT);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "VM-Action", "change-greeting");
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "VM-Greeting-Path", file_path);
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);
switch_event_fire(&params);
}
switch_safe_free(file_path);
} else if (!strcmp(input, profile->record_greeting_key)) {
@@ -1989,6 +2000,7 @@ static void voicemail_check_main(switch_core_session_t *session, vm_profile_t *p
if (num < 1 || num > VM_MAX_GREETINGS) {
TRY_CODE(switch_ivr_phrase_macro(session, VM_CHOOSE_GREETING_FAIL_MACRO, NULL, NULL, NULL));
} else {
switch_event_t *params;
file_path = switch_mprintf("%s%sgreeting_%d.%s", dir_path, SWITCH_PATH_SEPARATOR, num, profile->file_ext);
TRY_CODE(create_file(session, profile, VM_RECORD_GREETING_MACRO, file_path, &message_len, SWITCH_TRUE, NULL, NULL));
sql =
@@ -1997,6 +2009,14 @@ static void voicemail_check_main(switch_core_session_t *session, vm_profile_t *p
vm_execute_sql(profile, sql, profile->mutex);
switch_safe_free(sql);
switch_safe_free(file_path);
switch_event_create_subclass(&params, SWITCH_EVENT_CUSTOM, VM_EVENT_MAINT);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "VM-Action", "record-greeting");
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "VM-Greeting-Path", file_path);
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);
switch_event_fire(&params);
}
} else if (!strcmp(input, profile->change_pass_key)) {
@@ -2027,12 +2047,21 @@ static void voicemail_check_main(switch_core_session_t *session, vm_profile_t *p
switch_event_fire(&params);
} else if (!strcmp(input, profile->record_name_key)) {
switch_event_t *params;
file_path = switch_mprintf("%s%srecorded_name.%s", dir_path, SWITCH_PATH_SEPARATOR, profile->file_ext);
TRY_CODE(create_file(session, profile, VM_RECORD_NAME_MACRO, file_path, &message_len, SWITCH_FALSE, NULL, NULL));
sql = switch_mprintf("update voicemail_prefs set name_path='%s' where username='%s' and domain='%s'", file_path, myid, domain_name);
vm_execute_sql(profile, sql, profile->mutex);
switch_safe_free(file_path);
switch_safe_free(sql);
switch_event_create_subclass(&params, SWITCH_EVENT_CUSTOM, VM_EVENT_MAINT);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "VM-Action", "record-name");
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "VM-Name-Path", file_path);
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);
switch_event_fire(&params);
}
continue;
}
@@ -2337,6 +2366,7 @@ static switch_status_t deliver_vm(vm_profile_t *profile,
const char *filename;
switch_xml_t x_param, x_params;
char *vm_email = NULL;
char *vm_email_from = NULL;
char *vm_notify_email = NULL;
char *email_addr = NULL;
char *vm_timezone = NULL;
@@ -2401,6 +2431,8 @@ static switch_status_t deliver_vm(vm_profile_t *profile,
vm_email = switch_core_strdup(pool, val);
} else if (!strcasecmp(var, "vm-notify-mailto")) {
vm_notify_email = switch_core_strdup(pool, val);
} else if (!strcasecmp(var, "vm-mailfrom")) {
vm_email_from = switch_core_strdup(pool, val);
} else if (!strcasecmp(var, "email-addr")) {
email_addr = switch_core_strdup(pool, val);
} else if (!strcasecmp(var, "vm-email-all-messages") && (send_main = switch_true(val))) {
@@ -2544,7 +2576,9 @@ static switch_status_t deliver_vm(vm_profile_t *profile,
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "voicemail_message_len", duration_str);
if (zstr(profile->email_from)) {
if (!zstr(vm_email_from)) {
from = switch_core_strdup(pool, vm_email_from);
} else if (zstr(profile->email_from)) {
from = switch_core_sprintf(pool, "%s@%s", myid, domain_name);
} else {
from = switch_event_expand_headers(params, profile->email_from);
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
+2 -2
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthmct@yahoo.com>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -17,7 +17,7 @@
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Anthony Minessale II <anthmct@yahoo.com>
* Anthony Minessale II <anthm@freeswitch.org>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
+1 -1
View File
@@ -1,6 +1,6 @@
BASE=../../../..
CELT=celt-0.7.1
CELT=celt-0.10.0
CELT_DIR=$(switch_srcdir)/libs/$(CELT)
CELT_BUILDDIR=$(switch_builddir)/libs/$(CELT)
+4 -4
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -54,7 +54,7 @@ static switch_status_t switch_celt_init(switch_codec_t *codec, switch_codec_flag
}
context->mode_object = celt_mode_create(codec->implementation->actual_samples_per_second, codec->implementation->samples_per_packet, NULL);
celt_mode_info(context->mode_object, CELT_GET_FRAME_SIZE, &context->frame_size);
context->bytes_per_packet = (codec->implementation->bits_per_second * context->frame_size / codec->implementation->actual_samples_per_second + 4) / 8;
/*
@@ -111,7 +111,7 @@ static switch_status_t switch_celt_encode(switch_codec_t *codec,
return SWITCH_STATUS_FALSE;
}
*encoded_data_len = (uint32_t) celt_encode(context->encoder_object, (void *) decoded_data, NULL,
*encoded_data_len = (uint32_t) celt_encode(context->encoder_object, (void *) decoded_data, codec->implementation->samples_per_packet,
(unsigned char *) encoded_data, context->bytes_per_packet);
return SWITCH_STATUS_SUCCESS;
@@ -130,7 +130,7 @@ static switch_status_t switch_celt_decode(switch_codec_t *codec,
return SWITCH_STATUS_FALSE;
}
if (celt_decode(context->decoder_object, encoded_data, encoded_data_len, decoded_data)) {
if (celt_decode(context->decoder_object, encoded_data, encoded_data_len, decoded_data, codec->implementation->samples_per_packet)) {
return SWITCH_STATUS_GENERR;
}
+4 -4
View File
@@ -42,7 +42,7 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\..\..\..\libs\celt-0.7.1\libcelt"
AdditionalIncludeDirectories="..\..\..\..\libs\celt-0.10.0\libcelt"
UsePrecompiledHeader="0"
/>
<Tool
@@ -108,7 +108,7 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\..\..\..\libs\celt-0.7.1\libcelt"
AdditionalIncludeDirectories="..\..\..\..\libs\celt-0.10.0\libcelt"
UsePrecompiledHeader="0"
/>
<Tool
@@ -172,7 +172,7 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\..\..\..\libs\celt-0.7.1\libcelt"
AdditionalIncludeDirectories="..\..\..\..\libs\celt-0.10.0\libcelt"
UsePrecompiledHeader="0"
/>
<Tool
@@ -238,7 +238,7 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\..\..\..\libs\celt-0.7.1\libcelt"
AdditionalIncludeDirectories="..\..\..\..\libs\celt-0.10.0\libcelt"
UsePrecompiledHeader="0"
/>
<Tool
+4 -4
View File
@@ -65,7 +65,7 @@
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>..\..\..\..\libs\celt-0.7.1\libcelt;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\..\..\libs\celt-0.10.0\libcelt;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PrecompiledHeader>
</PrecompiledHeader>
</ClCompile>
@@ -80,7 +80,7 @@
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<ClCompile>
<AdditionalIncludeDirectories>..\..\..\..\libs\celt-0.7.1\libcelt;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\..\..\libs\celt-0.10.0\libcelt;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PrecompiledHeader>
</PrecompiledHeader>
</ClCompile>
@@ -93,7 +93,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>..\..\..\..\libs\celt-0.7.1\libcelt;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\..\..\libs\celt-0.10.0\libcelt;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PrecompiledHeader>
</PrecompiledHeader>
</ClCompile>
@@ -108,7 +108,7 @@
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<ClCompile>
<AdditionalIncludeDirectories>..\..\..\..\libs\celt-0.7.1\libcelt;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\..\..\libs\celt-0.10.0\libcelt;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PrecompiledHeader>
</PrecompiledHeader>
</ClCompile>
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
+2 -2
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -163,7 +163,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_ilbc_load)
"mode=30", /* default fmtp to send (can be overridden by the init function) */
8000, /* samples transferred per second */
8000, /* actual samples transferred per second */
13300, /* bits transferred per second */
13330, /* bits transferred per second */
30000, /* number of microseconds per frame */
ILBC_BLOCK_LEN_30MS, /* number of samples per frame */
ILBC_BLOCK_LEN_30MS * 2, /* number of bytes per frame decompressed */
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
+2 -2
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005/2006, Anthony Minessale II <anthmct@yahoo.com>
* Copyright (C) 2005/2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -17,7 +17,7 @@
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Anthony Minessale II <anthmct@yahoo.com>
* Anthony Minessale II <anthm@freeswitch.org>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005/2006, Anthony Minessale II <anthmct@yahoo.com>
* Copyright (C) 2005/2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -17,7 +17,7 @@
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Anthony Minessale II <anthmct@yahoo.com>
* Anthony Minessale II <anthm@freeswitch.org>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
@@ -1512,7 +1512,7 @@ static switch_status_t load_config(int reload_type)
hotline = val;
} else if (!strcasecmp(var, "dial_regex")) {
dial_regex = val;
} else if (!strcasecmp(var, "hold_music")) {
} else if (!strcasecmp(var, SWITCH_HOLD_MUSIC_VARIABLE)) {
hold_music = val;
} else if (!strcasecmp(var, "fail_dial_regex")) {
fail_dial_regex = val;
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -2744,7 +2744,7 @@ bool BoardE1::KhompPvtFXS::transfer(std::string & context, bool blind)
callFXS()->_uuid_other_session = getUUID(peer_session);
const char *stream = NULL;
if (!(stream = switch_channel_get_variable(peer_channel, SWITCH_HOLD_MUSIC_VARIABLE)))
if (!(stream = switch_channel_get_hold_music(peer_channel)))
{
stream = "silence";
}
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005/2006, Anthony Minessale II <anthmct@yahoo.com>
* Copyright (C) 2005/2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -17,7 +17,7 @@
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Anthony Minessale II <anthmct@yahoo.com>
* Anthony Minessale II <anthm@freeswitch.org>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
+2 -2
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005/2006, Anthony Minessale II <anthmct@yahoo.com>
* Copyright (C) 2005/2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -17,7 +17,7 @@
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Anthony Minessale II <anthmct@yahoo.com>
* Anthony Minessale II <anthm@freeswitch.org>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
+58 -14
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -43,8 +43,6 @@ SWITCH_MODULE_DEFINITION(mod_sofia, mod_sofia_load, mod_sofia_shutdown, NULL);
struct mod_sofia_globals mod_sofia_globals;
switch_endpoint_interface_t *sofia_endpoint_interface;
static switch_frame_t silence_frame = { 0 };
static char silence_data[13] = "";
#define STRLEN 15
@@ -1094,8 +1092,10 @@ static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_f
sofia_glue_do_invite(session);
}
#endif
*frame = &silence_frame;
*frame = &tech_pvt->read_frame;
switch_set_flag((*frame), SFF_CNG);
(*frame)->datalen = tech_pvt->read_impl.encoded_bytes_per_packet;
memset((*frame)->data, 0, (*frame)->datalen);
return SWITCH_STATUS_SUCCESS;
}
@@ -1346,7 +1346,13 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
char *p;
const char *s;
if (!strncasecmp(msg->string_arg, "debug:", 6)) {
if (!strcasecmp(msg->string_arg, "pause")) {
switch_rtp_pause_jitter_buffer(tech_pvt->rtp_session, SWITCH_TRUE);
goto end;
} else if (!strcasecmp(msg->string_arg, "resume")) {
switch_rtp_pause_jitter_buffer(tech_pvt->rtp_session, SWITCH_FALSE);
goto end;
} else if (!strncasecmp(msg->string_arg, "debug:", 6)) {
s = msg->string_arg + 6;
if (s && !strcmp(s, "off")) {
s = NULL;
@@ -1426,10 +1432,16 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
{
sofia_glue_tech_simplify(tech_pvt);
if (switch_rtp_ready(tech_pvt->rtp_session)) {
const char *val;
int ok = 0;
if (switch_channel_test_flag(tech_pvt->channel, CF_JITTERBUFFER) && switch_channel_test_cap_partner(tech_pvt->channel, CC_FS_RTP)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
"%s PAUSE Jitterbuffer\n", switch_channel_get_name(channel));
switch_rtp_pause_jitter_buffer(tech_pvt->rtp_session, SWITCH_TRUE);
}
if (sofia_test_flag(tech_pvt, TFLAG_PASS_RFC2833) && switch_channel_test_flag_partner(channel, CF_FS_RTP)) {
switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_PASS_RFC2833);
@@ -1455,6 +1467,12 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
if (switch_rtp_ready(tech_pvt->rtp_session)) {
const char *val;
int ok = 0;
if (switch_channel_test_flag(tech_pvt->channel, CF_JITTERBUFFER)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
"%s RESUME Jitterbuffer\n", switch_channel_get_name(channel));
switch_rtp_pause_jitter_buffer(tech_pvt->rtp_session, SWITCH_FALSE);
}
if (switch_rtp_test_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_PASS_RFC2833)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s deactivate passthru 2833 mode.\n",
@@ -3704,7 +3722,7 @@ SWITCH_STANDARD_API(sofia_function)
"--------------------------------------------------------------------------------\n"
"sofia help\n"
"sofia profile <profile_name> [[start|stop|restart|rescan]|"
"flush_inbound_reg [<call_id>] [reboot]|"
"flush_inbound_reg [<call_id>|<[user]@domain>] [reboot]|"
"[register|unregister] [<gateway name>|all]|"
"killgw <gateway name>|"
"[stun-auto-disable|stun-enabled] [true|false]]|"
@@ -3772,11 +3790,39 @@ SWITCH_STANDARD_API(sofia_function)
int wdon = -1;
if (argc > 1) {
if (!strcasecmp(argv[1], "debug")) {
if (argc > 2) {
if (strstr(argv[2], "presence")) {
mod_sofia_globals.debug_presence = 1;
stream->write_function(stream, "+OK Debugging presence\n");
}
if (strstr(argv[2], "sla")) {
mod_sofia_globals.debug_sla = 1;
stream->write_function(stream, "+OK Debugging sla\n");
}
if (strstr(argv[2], "none")) {
stream->write_function(stream, "+OK Debugging nothing\n");
mod_sofia_globals.debug_presence = 0;
mod_sofia_globals.debug_sla = 0;
}
}
stream->write_function(stream, "+OK Debugging summary: presence: %s sla: %s\n",
mod_sofia_globals.debug_presence ? "on" : "off",
mod_sofia_globals.debug_sla ? "on" : "off");
goto done;
}
if (!strcasecmp(argv[1], "siptrace")) {
if (argc > 2) {
ston = switch_true(argv[2]);
}
}
if (!strcasecmp(argv[1], "watchdog")) {
if (argc > 2) {
wdon = switch_true(argv[2]);
@@ -3791,7 +3837,7 @@ SWITCH_STANDARD_API(sofia_function)
sofia_glue_global_watchdog(wdon);
stream->write_function(stream, "+OK Global watchdog %s", wdon ? "on" : "off");
} else {
stream->write_function(stream, "-ERR Usage: siptrace <on|off>|watchdog <on|off>");
stream->write_function(stream, "-ERR Usage: siptrace <on|off>|watchdog <on|off>|debug <sla|presence|none");
}
goto done;
@@ -4795,11 +4841,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load)
switch_management_interface_t *management_interface;
struct in_addr in;
silence_frame.data = silence_data;
silence_frame.datalen = sizeof(silence_data);
silence_frame.buflen = sizeof(silence_data);
silence_frame.flags = SFF_CNG;
memset(&mod_sofia_globals, 0, sizeof(mod_sofia_globals));
mod_sofia_globals.destroy_private.destroy_nh = 1;
mod_sofia_globals.destroy_private.is_static = 1;
@@ -4920,6 +4961,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load)
switch_console_set_complete("add sofia global siptrace ::[on:off");
switch_console_set_complete("add sofia global watchdog ::[on:off");
switch_console_set_complete("add sofia global debug ::[presence:sla:none");
switch_console_set_complete("add sofia profile");
switch_console_set_complete("add sofia profile restart all");
+6 -1
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -225,6 +225,8 @@ typedef enum {
PFLAG_DEL_SUBS_ON_REG,
PFLAG_IGNORE_183NOSDP,
PFLAG_PRESENCE_PROBE_ON_REGISTER,
PFLAG_PRESENCE_ON_REGISTER,
PFLAG_PRESENCE_ON_FIRST_REGISTER,
PFLAG_NO_CONNECTION_REUSE,
/* No new flags below this line */
PFLAG_MAX
@@ -403,6 +405,7 @@ struct sofia_gateway {
char *register_from;
char *register_contact;
char *extension;
char *real_extension;
char *register_to;
char *register_proxy;
char *register_sticky_proxy;
@@ -501,6 +504,7 @@ struct sofia_profile {
char *challenge_realm;
char *rtcp_audio_interval_msec;
char *rtcp_video_interval_msec;
char *jb_msec;
sofia_cid_type_t cid_type;
sofia_dtmf_t dtmf_type;
int auto_restart;
@@ -1050,3 +1054,4 @@ void sofia_glue_build_vid_refresh_message(switch_core_session_t *session, const
void sofia_glue_check_dtmf_type(private_object_t *tech_pvt);
void sofia_glue_parse_rtp_bugs(uint32_t *flag_pole, const char *str);
char *sofia_glue_gen_contact_str(sofia_profile_t *profile, sip_t const *sip, sofia_nat_parse_t *np);
void sofia_glue_pause_jitterbuffer(switch_core_session_t *session, switch_bool_t on);
+77 -17
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -161,6 +161,15 @@ static void extract_header_vars(sofia_profile_t *profile, sip_t const *sip, swit
char *full;
if (sip) {
if (sip->sip_route) {
if ((full = sip_header_as_string(profile->home, (void *) sip->sip_route))) {
const char *v = switch_channel_get_variable(channel, "sip_full_route");
if (!v) {
switch_channel_set_variable(channel, "sip_full_route", full);
}
su_free(profile->home, full);
}
}
if (sip->sip_via) {
if ((full = sip_header_as_string(profile->home, (void *) sip->sip_via))) {
const char *v = switch_channel_get_variable(channel, "sip_full_via");
@@ -1468,8 +1477,6 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
TPTAG_TLS_VERIFY_POLICY(0)),
TAG_IF(sofia_test_pflag(profile, PFLAG_TLS),
TPTAG_TLS_VERSION(profile->tls_version)),
TAG_IF(sofia_test_pflag(profile, PFLAG_TLS),
TPTAG_KEEPALIVE(20000)),
TAG_IF(!strchr(profile->sipip, ':'),
NTATAG_UDP_MTU(65535)),
TAG_IF(sofia_test_pflag(profile, PFLAG_DISABLE_SRV),
@@ -2056,10 +2063,6 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag)
from_user = username;
}
if (zstr(extension)) {
extension = username;
}
if (zstr(proxy)) {
proxy = realm;
}
@@ -2151,8 +2154,13 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag)
sipip = profile->sipip;
}
gateway->extension = switch_core_strdup(gateway->pool, extension);
if (zstr(extension)) {
extension = username;
} else {
gateway->real_extension = switch_core_strdup(gateway->pool, extension);
}
gateway->extension = switch_core_strdup(gateway->pool, extension);
if (!strncasecmp(proxy, "sip:", 4)) {
gateway->register_proxy = switch_core_strdup(gateway->pool, proxy);
@@ -2351,6 +2359,11 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile)
} else {
sofia_clear_pflag(profile, PFLAG_DISABLE_HOLD);
}
} else if (!strcasecmp(var, "auto-jitterbuffer-msec")) {
int msec = atoi(val);
if (msec > 19) {
profile->jb_msec = switch_core_strdup(profile->pool, val);
}
} else if (!strcasecmp(var, "sip-trace")) {
if (switch_true(val)) {
sofia_set_flag(profile, TFLAG_TPORT_LOG);
@@ -2406,6 +2419,17 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile)
} else {
sofia_clear_pflag(profile, PFLAG_PRESENCE_PROBE_ON_REGISTER);
}
} else if (!strcasecmp(var, "send-presence-on-register")) {
if (switch_true(val)) {
sofia_set_pflag(profile, PFLAG_PRESENCE_ON_REGISTER);
} else if (!strcasecmp(val, "first-only")) {
sofia_clear_pflag(profile, PFLAG_PRESENCE_ON_REGISTER);
sofia_set_pflag(profile, PFLAG_PRESENCE_ON_FIRST_REGISTER);
} else {
sofia_clear_pflag(profile, PFLAG_PRESENCE_ON_REGISTER);
sofia_clear_pflag(profile, PFLAG_PRESENCE_ON_FIRST_REGISTER);
}
} else if (!strcasecmp(var, "cid-in-1xx")) {
if (switch_true(val)) {
sofia_set_pflag(profile, PFLAG_CID_IN_1XX);
@@ -2995,6 +3019,7 @@ switch_status_t config_sofia(int reload, char *profile_name)
sofia_set_pflag(profile, PFLAG_PASS_CALLEE_ID);
sofia_set_pflag(profile, PFLAG_MESSAGE_QUERY_ON_FIRST_REGISTER);
sofia_set_pflag(profile, PFLAG_SQL_IN_TRANS);
sofia_set_pflag(profile, PFLAG_PRESENCE_ON_REGISTER);
profile->shutdown_type = "false";
profile->local_network = "localnet.auto";
sofia_set_flag(profile, TFLAG_ENABLE_SOA);
@@ -3077,6 +3102,16 @@ switch_status_t config_sofia(int reload, char *profile_name)
} else {
sofia_clear_pflag(profile, PFLAG_PRESENCE_PROBE_ON_REGISTER);
}
} else if (!strcasecmp(var, "send-presence-on-register")) {
if (switch_true(val)) {
sofia_set_pflag(profile, PFLAG_PRESENCE_ON_REGISTER);
} else if (!strcasecmp(val, "first-only")) {
sofia_clear_pflag(profile, PFLAG_PRESENCE_ON_REGISTER);
sofia_set_pflag(profile, PFLAG_PRESENCE_ON_FIRST_REGISTER);
} else {
sofia_clear_pflag(profile, PFLAG_PRESENCE_ON_REGISTER);
sofia_clear_pflag(profile, PFLAG_PRESENCE_ON_FIRST_REGISTER);
}
} else if (!strcasecmp(var, "cid-in-1xx")) {
if (switch_true(val)) {
sofia_set_pflag(profile, PFLAG_CID_IN_1XX);
@@ -3089,6 +3124,11 @@ switch_status_t config_sofia(int reload, char *profile_name)
} else {
sofia_clear_pflag(profile, PFLAG_DISABLE_HOLD);
}
} else if (!strcasecmp(var, "auto-jitterbuffer-msec")) {
int msec = atoi(val);
if (msec > 19) {
profile->jb_msec = switch_core_strdup(profile->pool, val);
}
} else if (!strcasecmp(var, "dtmf-type")) {
if (!strcasecmp(val, "rfc2833")) {
profile->dtmf_type = DTMF_2833;
@@ -5550,7 +5590,7 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
switch_core_event_hook_add_state_change(a_session, xfer_hanguphook);
switch_channel_set_variable(a_channel, "att_xfer_kill_uuid", switch_core_session_get_uuid(b_session));
if ((tmp = switch_channel_get_variable(a_channel, SWITCH_HOLD_MUSIC_VARIABLE))) {
if ((tmp = switch_channel_get_hold_music(a_channel))) {
moh = tmp;
}
@@ -6212,6 +6252,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
char acl_token[512] = "";
sofia_transport_t transport;
const char *gw_name = NULL;
const char *gw_param_name = NULL;
char *call_info_str = NULL;
nua_handle_t *bnh = NULL;
char sip_acl_authed_by[512] = "";
@@ -6844,7 +6885,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
if (sip->sip_request->rq_url->url_params) {
gw_name = sofia_glue_find_parameter_value(session, sip->sip_request->rq_url->url_params, "gw=");
gw_param_name = sofia_glue_find_parameter_value(session, sip->sip_request->rq_url->url_params, "gw=");
}
if (strstr(destination_number, "gw+")) {
@@ -6859,19 +6900,35 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
}
}
if (gw_name) {
sofia_gateway_t *gateway;
if (gw_name && (gateway = sofia_reg_find_gateway(gw_name))) {
if (gw_name || gw_param_name) {
sofia_gateway_t *gateway = NULL;
char *extension = NULL;
if (gw_name && ((gateway = sofia_reg_find_gateway(gw_name)))) {
gw_param_name = NULL;
extension = gateway->extension;
}
if (!gateway && gw_param_name) {
gateway = sofia_reg_find_gateway(gw_param_name);
extension = gateway->real_extension;
}
if (gateway) {
context = switch_core_session_strdup(session, gateway->register_context);
switch_channel_set_variable(channel, "sip_gateway", gateway->name);
if (gateway->extension) {
if (!strcasecmp(gateway->extension, "auto_to_user")) {
if (!zstr(extension)) {
if (!strcasecmp(extension, "auto_to_user")) {
destination_number = sip->sip_to->a_url->url_user;
} else if (!strcasecmp(extension, "auto")) {
if (gw_name) {
destination_number = sip->sip_to->a_url->url_user;
}
} else {
destination_number = switch_core_session_strdup(session, gateway->extension);
destination_number = switch_core_session_strdup(session, extension);
}
} else {
} else if (!gw_param_name) {
destination_number = sip->sip_to->a_url->url_user;
}
@@ -7100,6 +7157,9 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
switch_channel_set_variable(channel, "sip_history_info", un->un_value);
}
}
} else if (!strcasecmp(un->un_name, "X-FS-Channel-Name") && !zstr(un->un_value)) {
switch_channel_set_name(channel, un->un_value);
switch_channel_set_variable(channel, "push_channel_name", "true");
} else if (!strcasecmp(un->un_name, "X-FS-Support")) {
tech_pvt->x_freeswitch_support_remote = switch_core_session_strdup(session, un->un_value);
} else if (!strncasecmp(un->un_name, "X-", 2) || !strncasecmp(un->un_name, "P-", 2)) {
+115 -28
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -70,7 +70,7 @@ void sofia_glue_set_image_sdp(private_object_t *tech_pvt, switch_t38_options_t *
port = tech_pvt->proxy_sdp_audio_port;
}
}
if (!port) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "%s NO PORT!\n", switch_channel_get_name(tech_pvt->channel));
return;
@@ -377,6 +377,13 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32
sofia_glue_check_dtmf_type(tech_pvt);
if (sofia_test_pflag(tech_pvt->profile, PFLAG_SUPPRESS_CNG) ||
((val = switch_channel_get_variable(tech_pvt->channel, "supress_cng")) && switch_true(val)) ||
((val = switch_channel_get_variable(tech_pvt->channel, "suppress_cng")) && switch_true(val))) {
use_cng = 0;
tech_pvt->cng_pt = 0;
}
if (!tech_pvt->payload_space) {
int i;
@@ -388,6 +395,13 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32
tech_pvt->ianacodes[i] = imp->ianacode;
if (tech_pvt->ianacodes[i] > 64) {
if (tech_pvt->dtmf_type == DTMF_2833 && tech_pvt->te > 95 && tech_pvt->te == tech_pvt->payload_space) {
tech_pvt->payload_space++;
}
if (!sofia_test_pflag(tech_pvt->profile, PFLAG_SUPPRESS_CNG) &&
tech_pvt->cng_pt && use_cng && tech_pvt->cng_pt == tech_pvt->payload_space) {
tech_pvt->payload_space++;
}
tech_pvt->ianacodes[i] = tech_pvt->payload_space++;
}
}
@@ -401,13 +415,6 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32
verbose_sdp = 1;
}
if (sofia_test_pflag(tech_pvt->profile, PFLAG_SUPPRESS_CNG) ||
((val = switch_channel_get_variable(tech_pvt->channel, "supress_cng")) && switch_true(val)) ||
((val = switch_channel_get_variable(tech_pvt->channel, "suppress_cng")) && switch_true(val))) {
use_cng = 0;
tech_pvt->cng_pt = 0;
}
if (!force && !ip && !sr
&& (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MODE) || switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MEDIA))) {
return;
@@ -832,6 +839,8 @@ void sofia_glue_attach_private(switch_core_session_t *session, sofia_profile_t *
switch_channel_set_cap(tech_pvt->channel, CC_MEDIA_ACK);
switch_channel_set_cap(tech_pvt->channel, CC_BYPASS_MEDIA);
switch_channel_set_cap(tech_pvt->channel, CC_PROXY_MEDIA);
switch_channel_set_cap(tech_pvt->channel, CC_JITTERBUFFER);
switch_channel_set_cap(tech_pvt->channel, CC_FS_RTP);
switch_core_session_set_private(session, tech_pvt);
@@ -2693,8 +2702,8 @@ switch_status_t sofia_glue_tech_set_codec(private_object_t *tech_pvt, int force)
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE | tech_pvt->profile->codec_flags,
NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "Can't load codec?\n");
switch_goto_status(SWITCH_STATUS_FALSE, end);
switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION);
switch_goto_status(SWITCH_STATUS_FALSE, end);
}
if (switch_core_codec_init_with_bitrate(&tech_pvt->write_codec,
@@ -3152,8 +3161,8 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
}
}
if ((val = switch_channel_get_variable(tech_pvt->channel, "jitterbuffer_msec"))) {
int len = atoi(val);
if ((val = switch_channel_get_variable(tech_pvt->channel, "jitterbuffer_msec")) || (val = tech_pvt->profile->jb_msec)) {
int jb_msec = atoi(val);
int maxlen = 0;
char *p;
@@ -3162,13 +3171,13 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
maxlen = atoi(p);
}
if (len < 20 || len > 10000) {
if (jb_msec < 20 || jb_msec > 10000) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR,
"Invalid Jitterbuffer spec [%d] must be between 20 and 10000\n", len);
"Invalid Jitterbuffer spec [%d] must be between 20 and 10000\n", jb_msec);
} else {
int qlen, maxqlen = 50;
qlen = len / (tech_pvt->read_impl.microseconds_per_packet / 1000);
qlen = jb_msec / (tech_pvt->read_impl.microseconds_per_packet / 1000);
if (maxlen) {
maxqlen = maxlen / (tech_pvt->read_impl.microseconds_per_packet / 1000);
@@ -3178,11 +3187,11 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
tech_pvt->read_impl.samples_per_packet,
tech_pvt->read_impl.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)\n", len, qlen);
SWITCH_LOG_DEBUG, "Setting Jitterbuffer to %dms (%d frames)\n", jb_msec, qlen);
switch_channel_set_flag(tech_pvt->channel, CF_JITTERBUFFER);
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session),
SWITCH_LOG_WARNING, "Error Setting Jitterbuffer to %dms (%d frames)\n", len, qlen);
SWITCH_LOG_WARNING, "Error Setting Jitterbuffer to %dms (%d frames)\n", jb_msec, qlen);
}
}
@@ -3548,13 +3557,53 @@ void sofia_glue_set_r_sdp_codec_string(switch_core_session_t *session, const cha
}
if (match) {
if (ptime > 0) {
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), ",%s@%uh@%di", imp->iananame, (unsigned int) map->rm_rate,
ptime);
} else {
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), ",%s@%uh", imp->iananame, (unsigned int) map->rm_rate);
int codec_ms = ptime;
uint32_t map_bit_rate = 0;
char ptstr[20] = "";
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);
}
already_did[imp->ianacode] = 1;
map_bit_rate = switch_known_bitrate(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;
map_bit_rate = 13330;
}
} else {
if ((switch_core_codec_parse_fmtp(map->rm_encoding, map->rm_fmtp, map->rm_rate, &codec_fmtp)) == SWITCH_STATUS_SUCCESS) {
if (codec_fmtp.bits_per_second) {
map_bit_rate = codec_fmtp.bits_per_second;
}
if (codec_fmtp.microseconds_per_packet) {
codec_ms = (codec_fmtp.microseconds_per_packet / 1000);
}
}
}
if (map->rm_rate) {
switch_snprintf(ratestr, sizeof(ratestr), "@%uh", (unsigned int) map->rm_rate);
}
if (codec_ms) {
switch_snprintf(ptstr, sizeof(ptstr), "@%di", codec_ms);
}
if (map_bit_rate) {
switch_snprintf(bitstr, sizeof(bitstr), "@%db", map_bit_rate);
}
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), ",%s%s%s%s", map->rm_encoding, ratestr, ptstr, bitstr);
break;
}
}
@@ -3661,7 +3710,7 @@ void sofia_glue_toggle_hold(private_object_t *tech_pvt, int sendonly)
switch_rtp_set_max_missed_packets(tech_pvt->rtp_session, tech_pvt->max_missed_hold_packets);
}
if (!(stream = switch_channel_get_variable(tech_pvt->channel, SWITCH_HOLD_MUSIC_VARIABLE))) {
if (!(stream = switch_channel_get_hold_music(tech_pvt->channel))) {
stream = tech_pvt->profile->hold_music;
}
@@ -3998,7 +4047,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
sdp_attribute_t *attr;
int first = 0, last = 0;
int ptime = 0, dptime = 0, maxptime = 0, dmaxptime = 0;
int sendonly = 0;
int sendonly = 0, recvonly = 0;
int greedy = 0, x = 0, skip = 0, mine = 0;
switch_channel_t *channel = switch_core_session_get_channel(session);
const char *val;
@@ -4066,6 +4115,19 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
if (!strcasecmp(attr->a_name, "sendonly") || !strcasecmp(attr->a_name, "inactive")) {
sendonly = 1;
switch_channel_set_variable(tech_pvt->channel, "media_audio_mode", "recvonly");
} else if (!strcasecmp(attr->a_name, "recvonly")) {
switch_channel_set_variable(tech_pvt->channel, "media_audio_mode", "sendonly");
recvonly = 1;
if (switch_rtp_ready(tech_pvt->rtp_session)) {
switch_rtp_set_max_missed_packets(tech_pvt->rtp_session, 0);
tech_pvt->max_missed_hold_packets = 0;
tech_pvt->max_missed_packets = 0;
} else {
switch_channel_set_variable(tech_pvt->channel, "rtp_timeout_sec", "0");
switch_channel_set_variable(tech_pvt->channel, "rtp_hold_timeout_sec", "0");
}
} else if (sendonly < 2 && !strcasecmp(attr->a_name, "sendrecv")) {
sendonly = 0;
} else if (!strcasecmp(attr->a_name, "ptime")) {
@@ -4075,6 +4137,11 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
}
}
if (sendonly != 1 && recvonly != 1) {
switch_channel_set_variable(tech_pvt->channel, "media_audio_mode", NULL);
}
if (sofia_test_pflag(tech_pvt->profile, PFLAG_DISABLE_HOLD) ||
((val = switch_channel_get_variable(tech_pvt->channel, "sip_disable_hold")) && switch_true(val))) {
sendonly = 0;
@@ -4376,6 +4443,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
if (zstr(map->rm_fmtp)) {
if (!strcasecmp(map->rm_encoding, "ilbc")) {
ptime = codec_ms = 30;
map_bit_rate = 13330;
}
} else {
if ((switch_core_codec_parse_fmtp(map->rm_encoding, map->rm_fmtp, map->rm_rate, &codec_fmtp)) == SWITCH_STATUS_SUCCESS) {
@@ -4387,8 +4455,6 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
}
}
}
for (i = first; i < last && i < tech_pvt->num_codecs; i++) {
const switch_codec_implementation_t *imp = tech_pvt->codecs[i];
@@ -4399,7 +4465,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Audio Codec Compare [%s:%d:%u:%d:%u]/[%s:%d:%u:%d:%u]\n",
rm_encoding, map->rm_pt, (int) map->rm_rate, ptime, map_bit_rate,
rm_encoding, map->rm_pt, (int) map->rm_rate, codec_ms, map_bit_rate,
imp->iananame, imp->ianacode, codec_rate, imp->microseconds_per_packet / 1000, bit_rate);
if ((zstr(map->rm_encoding) || (tech_pvt->profile->ndlb & PFLAG_NDLB_ALLOW_BAD_IANANAME)) && map->rm_pt < 96) {
match = (map->rm_pt == imp->ianacode) ? 1 : 0;
@@ -6065,6 +6131,19 @@ void sofia_glue_tech_simplify(private_object_t *tech_pvt)
}
}
void sofia_glue_pause_jitterbuffer(switch_core_session_t *session, switch_bool_t on)
{
switch_core_session_message_t *msg;
msg = switch_core_session_alloc(session, sizeof(*msg));
MESSAGE_STAMP_FFL(msg);
msg->message_id = SWITCH_MESSAGE_INDICATE_JITTER_BUFFER;
msg->string_arg = switch_core_session_strdup(session, on ? "pause" : "resume");
msg->from = __FILE__;
switch_core_session_queue_message(session, msg);
}
void sofia_glue_build_vid_refresh_message(switch_core_session_t *session, const char *pl)
{
switch_core_session_message_t *msg;
@@ -6134,6 +6213,14 @@ void sofia_glue_parse_rtp_bugs(uint32_t *flag_pole, const char *str)
if (switch_stristr("~NEVER_SEND_MARKER", str)) {
*flag_pole &= ~RTP_BUG_NEVER_SEND_MARKER;
}
if (switch_stristr("IGNORE_DTMF_DURATION", str)) {
*flag_pole |= RTP_BUG_IGNORE_DTMF_DURATION;
}
if (switch_stristr("~IGNORE_DTMF_DURATION", str)) {
*flag_pole &= ~RTP_BUG_IGNORE_DTMF_DURATION;
}
}
char *sofia_glue_gen_contact_str(sofia_profile_t *profile, sip_t const *sip, sofia_nat_parse_t *np)
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
+59 -29
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -606,16 +606,16 @@ void sofia_reg_expire_call_id(sofia_profile_t *profile, const char *call_id, int
sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status,rpid,expires"
",user_agent,server_user,server_host,profile_name,network_ip"
",%d from sip_registrations where call_id='%q' %s", reboot, call_id, sqlextra);
switch_safe_free(sqlextra);
switch_mutex_lock(profile->ireg_mutex);
sofia_glue_execute_sql_callback(profile, NULL, sql, sofia_reg_del_callback, profile);
switch_mutex_unlock(profile->ireg_mutex);
switch_safe_free(sql);
sql = switch_mprintf("delete from sip_registrations where call_id='%q' or (sip_user='%q' and sip_host='%q')", call_id, user, host);
sql = switch_mprintf("delete from sip_registrations where call_id='%q' %s", call_id, sqlextra);
sofia_glue_execute_sql_now(profile, &sql, SWITCH_FALSE);
switch_safe_free(sqlextra);
switch_safe_free(sql);
switch_safe_free(dup);
@@ -875,9 +875,19 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
long reg_count = 0;
int delete_subs;
const char *agent = "unknown";
const char *pres_on_reg = NULL;
int send_pres = 0;
delete_subs = sofia_test_pflag(profile, PFLAG_DEL_SUBS_ON_REG);
if (v_event && *v_event) pres_on_reg = switch_event_get_header(*v_event, "send-presence-on-register");
if (!(send_pres = switch_true(pres_on_reg))) {
if (pres_on_reg && !strcasecmp(pres_on_reg, "first-only")) {
send_pres = 2;
}
}
/* all callers must confirm that sip, sip->sip_request and sip->sip_contact are not NULL */
switch_assert(sip != NULL && sip->sip_contact != NULL && sip->sip_request != NULL);
@@ -1078,7 +1088,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
if (exptime && v_event && *v_event) {
char *exp_var;
char *allow_multireg = NULL;
int force_connectile = 0;
int auto_connectile = 0;
allow_multireg = switch_event_get_header(*v_event, "sip-allow-multiple-registrations");
if (allow_multireg && switch_false(allow_multireg)) {
@@ -1097,11 +1107,26 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
if (profile->rport_level == 3 && sip->sip_user_agent &&
sip->sip_user_agent->g_string && !strncasecmp(sip->sip_user_agent->g_string, "Polycom", 7)) {
force_connectile = 1;
if (sip && sip->sip_via) {
const char *host = sip->sip_via->v_host;
const char *c_port = sip->sip_via->v_port;
int port = 0;
if (c_port) port = atoi(c_port);
if (!port) port = 5060;
if (host && strcmp(network_ip, host)) {
auto_connectile = 1;
} else if (port != network_port) {
auto_connectile = 1;
}
} else {
auto_connectile = 1;
}
}
if ((v_contact_str = switch_event_get_header(*v_event, "sip-force-contact")) || force_connectile) {
if ((!strcasecmp(v_contact_str, "NDLB-connectile-dysfunction-2.0")) || force_connectile) {
if ((v_contact_str = switch_event_get_header(*v_event, "sip-force-contact")) || auto_connectile) {
if ((!strcasecmp(v_contact_str, "NDLB-connectile-dysfunction-2.0")) || auto_connectile) {
char *path_encoded;
size_t path_encoded_len;
char my_contact_str[1024];
@@ -1314,7 +1339,9 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
if (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'",
to_user, reg_host, profile->name);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "DELETE PRESENCE SQL: %s\n", sql);
if (mod_sofia_globals.debug_presence > 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "DELETE PRESENCE SQL: %s\n", sql);
}
sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
}
@@ -1388,7 +1415,6 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
}
}
if (send && switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", SOFIA_CHAT_PROTO);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", rpid);
@@ -1476,27 +1502,31 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
}
}
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, "login", profile->name);
switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "from", "%s@%s", to_user, sub_host);
switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "to", "%s@%s", to_user, sub_host);
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "event_type", "presence");
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
switch_event_fire(&s_event);
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)) {
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, "login", profile->name);
switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "from", "%s@%s", to_user, sub_host);
switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "to", "%s@%s", to_user, sub_host);
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "event_type", "presence");
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
switch_event_fire(&s_event);
}
} else {
if (switch_event_create(&s_event, SWITCH_EVENT_PRESENCE_IN) == 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, "login", profile->name);
switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "from", "%s@%s", to_user, sub_host);
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 {
if (switch_event_create(&s_event, SWITCH_EVENT_PRESENCE_IN) == 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, "login", profile->name);
switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "from", "%s@%s", to_user, sub_host);
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 {
if (switch_event_create_subclass(&s_event, SWITCH_EVENT_CUSTOM, MY_EVENT_UNREGISTER) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "profile-name", profile->name);
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005/2006, Anthony Minessale II <anthmct@yahoo.com>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -17,7 +17,7 @@
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Anthony Minessale II <anthmct@yahoo.com>
* Anthony Minessale II <anthm@freeswitch.org>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
Loaded 100 of 314 files, more files were not shown because too many files have changed in this diff. Show more