ok gsm works
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@206 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
ad4559308b
commit
b4845b9ff1
|
@ -92,7 +92,7 @@ extern "C" {
|
||||||
SWITCH_DECLARE(switch_caller_profile *) switch_caller_profile_clone(switch_core_session *session,
|
SWITCH_DECLARE(switch_caller_profile *) switch_caller_profile_clone(switch_core_session *session,
|
||||||
switch_caller_profile *tocopy);
|
switch_caller_profile *tocopy);
|
||||||
|
|
||||||
SWITCH_DECLARE(void) switch_caller_profile_event_set_data(switch_caller_profile *caller_profile, switch_event *event);
|
SWITCH_DECLARE(void) switch_caller_profile_event_set_data(switch_caller_profile *caller_profile, char *prefix, switch_event *event);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -53,6 +53,8 @@ SWITCH_DECLARE(void) switch_channel_set_caller_profile(switch_channel *channel,
|
||||||
SWITCH_DECLARE(switch_caller_profile *) switch_channel_get_caller_profile(switch_channel *channel);
|
SWITCH_DECLARE(switch_caller_profile *) switch_channel_get_caller_profile(switch_channel *channel);
|
||||||
SWITCH_DECLARE(void) switch_channel_set_originator_caller_profile(switch_channel *channel, switch_caller_profile *caller_profile);
|
SWITCH_DECLARE(void) switch_channel_set_originator_caller_profile(switch_channel *channel, switch_caller_profile *caller_profile);
|
||||||
SWITCH_DECLARE(switch_caller_profile *) switch_channel_get_originator_caller_profile(switch_channel *channel);
|
SWITCH_DECLARE(switch_caller_profile *) switch_channel_get_originator_caller_profile(switch_channel *channel);
|
||||||
|
SWITCH_DECLARE(void) switch_channel_set_originatee_caller_profile(switch_channel *channel, switch_caller_profile *caller_profile);
|
||||||
|
SWITCH_DECLARE(switch_caller_profile *) switch_channel_get_originatee_caller_profile(switch_channel *channel);
|
||||||
SWITCH_DECLARE(char *) switch_channel_get_variable(switch_channel *channel, char *varname);
|
SWITCH_DECLARE(char *) switch_channel_get_variable(switch_channel *channel, char *varname);
|
||||||
SWITCH_DECLARE(switch_status) switch_channel_set_variable(switch_channel *channel, char *varname, char *value);
|
SWITCH_DECLARE(switch_status) switch_channel_set_variable(switch_channel *channel, char *varname, char *value);
|
||||||
SWITCH_DECLARE(void) switch_channel_set_caller_extension(switch_channel *channel, switch_caller_extension *caller_extension);
|
SWITCH_DECLARE(void) switch_channel_set_caller_extension(switch_channel *channel, switch_caller_extension *caller_extension);
|
||||||
|
|
|
@ -176,30 +176,27 @@ struct switch_codec_settings {
|
||||||
float pp_dereverb_level;
|
float pp_dereverb_level;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct switch_file_handle {
|
||||||
|
const struct switch_file_interface *file_interface;
|
||||||
|
const struct switch_file_implementation *implementation;
|
||||||
|
switch_file_t *fd;
|
||||||
|
unsigned int sample_count;
|
||||||
|
switch_codec_flag flags;
|
||||||
|
switch_memory_pool *memory_pool;
|
||||||
|
void *private;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct switch_file_implementation {
|
||||||
|
const struct switch_file_implementation *next;
|
||||||
|
int codec_iananum;
|
||||||
|
};
|
||||||
|
|
||||||
struct switch_codec {
|
struct switch_codec {
|
||||||
const struct switch_codec_interface *codec_interface;
|
const struct switch_codec_interface *codec_interface;
|
||||||
const struct switch_codec_implementation *implementation;
|
const struct switch_codec_implementation *implementation;
|
||||||
struct switch_codec_settings codec_settings;
|
struct switch_codec_settings codec_settings;
|
||||||
switch_codec_flag flags;
|
switch_codec_flag flags;
|
||||||
switch_memory_pool *memory_pool;
|
switch_memory_pool *memory_pool;
|
||||||
|
|
||||||
switch_frame raw_write_frame;
|
|
||||||
unsigned char *raw_write_frame_data;
|
|
||||||
switch_buffer *raw_write_buffer;
|
|
||||||
|
|
||||||
switch_frame enc_write_frame;
|
|
||||||
unsigned char *enc_write_frame_data;
|
|
||||||
switch_buffer *enc_write_buffer;
|
|
||||||
|
|
||||||
|
|
||||||
switch_frame raw_read_frame;
|
|
||||||
unsigned char *raw_read_frame_data;
|
|
||||||
switch_buffer *raw_read_buffer;
|
|
||||||
|
|
||||||
switch_frame enc_read_frame;
|
|
||||||
unsigned char *enc_read_frame_data;
|
|
||||||
switch_buffer *enc_read_buffer;
|
|
||||||
|
|
||||||
void *private;
|
void *private;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -34,10 +34,14 @@
|
||||||
|
|
||||||
static const char modname[] = "mod_codec_gsm";
|
static const char modname[] = "mod_codec_gsm";
|
||||||
|
|
||||||
|
struct gsm_context {
|
||||||
|
gsm encoder;
|
||||||
|
gsm decoder;
|
||||||
|
};
|
||||||
|
|
||||||
static switch_status switch_gsm_init(switch_codec *codec, switch_codec_flag flags, const struct switch_codec_settings *codec_settings)
|
static switch_status switch_gsm_init(switch_codec *codec, switch_codec_flag flags, const struct switch_codec_settings *codec_settings)
|
||||||
{
|
{
|
||||||
gsm context;
|
struct gsm_context *context;
|
||||||
int encoding, decoding;
|
int encoding, decoding;
|
||||||
|
|
||||||
encoding = (flags & SWITCH_CODEC_FLAG_ENCODE);
|
encoding = (flags & SWITCH_CODEC_FLAG_ENCODE);
|
||||||
|
@ -46,18 +50,26 @@ static switch_status switch_gsm_init(switch_codec *codec, switch_codec_flag flag
|
||||||
if (!(encoding || decoding)) {
|
if (!(encoding || decoding)) {
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
} else {
|
} else {
|
||||||
context = gsm_create();
|
context = switch_core_alloc(codec->memory_pool, sizeof(*context));
|
||||||
}
|
if (encoding) context->encoder = gsm_create();
|
||||||
|
if (decoding) context->decoder = gsm_create();
|
||||||
|
}
|
||||||
|
|
||||||
codec->private = context;
|
codec->private = context;
|
||||||
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static switch_status switch_gsm_destroy(switch_codec *codec)
|
static switch_status switch_gsm_destroy(switch_codec *codec)
|
||||||
{
|
{
|
||||||
gsm_destroy((gsm)codec->private);
|
struct gsm_context *context = codec->private;
|
||||||
|
int encoding = (codec->flags & SWITCH_CODEC_FLAG_ENCODE);
|
||||||
|
int decoding = (codec->flags & SWITCH_CODEC_FLAG_DECODE);
|
||||||
|
|
||||||
|
if (encoding) gsm_destroy(context->encoder);
|
||||||
|
if (decoding) gsm_destroy(context->decoder);
|
||||||
|
|
||||||
codec->private = NULL;
|
codec->private = NULL;
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -71,24 +83,23 @@ static switch_status switch_gsm_encode(switch_codec *codec,
|
||||||
size_t *encoded_data_len,
|
size_t *encoded_data_len,
|
||||||
unsigned int *flag)
|
unsigned int *flag)
|
||||||
{
|
{
|
||||||
gsm context = codec->private;
|
struct gsm_context *context = codec->private;
|
||||||
int cbret = 0;
|
int cbret = 0;
|
||||||
|
|
||||||
if (!context) {
|
if (!context) {
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
if (decoded_data_len % 160 == 0) {
|
if (decoded_data_len % 320 == 0) {
|
||||||
unsigned int new_len = 0;
|
unsigned int new_len = 0;
|
||||||
gsm_signal *ddp = decoded_data;
|
gsm_signal *ddp = decoded_data;
|
||||||
gsm_byte *edp = encoded_data;
|
gsm_byte *edp = encoded_data;
|
||||||
int x;
|
int x;
|
||||||
int loops = (int) decoded_data_len / 160;
|
int loops = (int) decoded_data_len / 320;
|
||||||
|
|
||||||
for(x = 0; x < loops && new_len < *encoded_data_len; x++) {
|
for(x = 0; x < loops && new_len < *encoded_data_len; x++) {
|
||||||
gsm_encode(context, ddp, edp);
|
gsm_encode(context->encoder, ddp, edp);
|
||||||
edp += 10;
|
edp += 33;
|
||||||
ddp += 80;
|
ddp += 160;
|
||||||
new_len += 10;
|
new_len += 33;
|
||||||
}
|
}
|
||||||
if( new_len <= *encoded_data_len ) {
|
if( new_len <= *encoded_data_len ) {
|
||||||
*encoded_data_len = new_len;
|
*encoded_data_len = new_len;
|
||||||
|
@ -124,9 +135,9 @@ static switch_status switch_gsm_decode(switch_codec *codec,
|
||||||
int x;
|
int x;
|
||||||
unsigned int new_len = 0;
|
unsigned int new_len = 0;
|
||||||
for(x = 0; x < loops && new_len < *decoded_data_len; x++) {
|
for(x = 0; x < loops && new_len < *decoded_data_len; x++) {
|
||||||
gsm_decode(&context, ddp, edp);
|
gsm_decode(context->decoder, edp, ddp);
|
||||||
ddp += 80;
|
ddp += 160;
|
||||||
edp += 10;
|
edp += 33;
|
||||||
new_len += 320;
|
new_len += 320;
|
||||||
}
|
}
|
||||||
if (new_len <= *decoded_data_len) {
|
if (new_len <= *decoded_data_len) {
|
||||||
|
@ -139,7 +150,6 @@ static switch_status switch_gsm_decode(switch_codec *codec,
|
||||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "yo this frame is an odd size [%d]\n", encoded_data_len);
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "yo this frame is an odd size [%d]\n", encoded_data_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +164,7 @@ static const switch_codec_implementation gsm_8k_implementation = {
|
||||||
/*.encoded_bytes_per_frame*/ 33,
|
/*.encoded_bytes_per_frame*/ 33,
|
||||||
/*.number_of_channels*/ 1,
|
/*.number_of_channels*/ 1,
|
||||||
/*.pref_frames_per_packet*/ 1,
|
/*.pref_frames_per_packet*/ 1,
|
||||||
/*.max_frames_per_packet*/ 7,
|
/*.max_frames_per_packet*/ 1,
|
||||||
/*.init*/ switch_gsm_init,
|
/*.init*/ switch_gsm_init,
|
||||||
/*.encode*/ switch_gsm_encode,
|
/*.encode*/ switch_gsm_encode,
|
||||||
/*.decode*/ switch_gsm_decode,
|
/*.decode*/ switch_gsm_decode,
|
||||||
|
|
|
@ -190,7 +190,6 @@ static void audio_bridge_function(switch_core_session *session, char *data)
|
||||||
time_t start;
|
time_t start;
|
||||||
|
|
||||||
peer_channel = switch_core_session_get_channel(peer_session);
|
peer_channel = switch_core_session_get_channel(peer_session);
|
||||||
|
|
||||||
memset(&other_audio_thread, 0, sizeof(other_audio_thread));
|
memset(&other_audio_thread, 0, sizeof(other_audio_thread));
|
||||||
memset(&this_audio_thread, 0, sizeof(this_audio_thread));
|
memset(&this_audio_thread, 0, sizeof(this_audio_thread));
|
||||||
other_audio_thread.objs[0] = session;
|
other_audio_thread.objs[0] = session;
|
||||||
|
@ -226,6 +225,7 @@ static void audio_bridge_function(switch_core_session *session, char *data)
|
||||||
|
|
||||||
if (switch_channel_test_flag(peer_channel, CF_ANSWERED)) {
|
if (switch_channel_test_flag(peer_channel, CF_ANSWERED)) {
|
||||||
switch_channel_answer(caller_channel);
|
switch_channel_answer(caller_channel);
|
||||||
|
|
||||||
switch_core_session_launch_thread(session, audio_bridge_thread, (void *) &other_audio_thread);
|
switch_core_session_launch_thread(session, audio_bridge_thread, (void *) &other_audio_thread);
|
||||||
audio_bridge_thread(NULL, (void *) &this_audio_thread);
|
audio_bridge_thread(NULL, (void *) &this_audio_thread);
|
||||||
switch_channel_hangup(peer_channel);
|
switch_channel_hangup(peer_channel);
|
||||||
|
|
|
@ -367,8 +367,7 @@ static switch_status exosip_outgoing_channel(switch_core_session *session, switc
|
||||||
{
|
{
|
||||||
if ((*new_session = switch_core_session_request(&exosip_endpoint_interface, NULL))) {
|
if ((*new_session = switch_core_session_request(&exosip_endpoint_interface, NULL))) {
|
||||||
struct private_object *tech_pvt;
|
struct private_object *tech_pvt;
|
||||||
switch_channel *channel, *orig_channel;
|
switch_channel *channel;
|
||||||
switch_caller_profile *caller_profile, *originator_caller_profile = NULL;
|
|
||||||
|
|
||||||
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object)))) {
|
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object)))) {
|
||||||
memset(tech_pvt, 0, sizeof(*tech_pvt));
|
memset(tech_pvt, 0, sizeof(*tech_pvt));
|
||||||
|
@ -384,6 +383,8 @@ static switch_status exosip_outgoing_channel(switch_core_session *session, switc
|
||||||
|
|
||||||
if (outbound_profile) {
|
if (outbound_profile) {
|
||||||
char name[128];
|
char name[128];
|
||||||
|
switch_caller_profile *caller_profile;
|
||||||
|
|
||||||
caller_profile = switch_caller_profile_clone(*new_session, outbound_profile);
|
caller_profile = switch_caller_profile_clone(*new_session, outbound_profile);
|
||||||
switch_channel_set_caller_profile(channel, caller_profile);
|
switch_channel_set_caller_profile(channel, caller_profile);
|
||||||
tech_pvt->caller_profile = caller_profile;
|
tech_pvt->caller_profile = caller_profile;
|
||||||
|
@ -394,16 +395,6 @@ static switch_status exosip_outgoing_channel(switch_core_session *session, switc
|
||||||
switch_core_session_destroy(new_session);
|
switch_core_session_destroy(new_session);
|
||||||
return SWITCH_STATUS_GENERR;
|
return SWITCH_STATUS_GENERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (session == NULL) means it was originated from the core not from another channel */
|
|
||||||
if (session && (orig_channel = switch_core_session_get_channel(session))) {
|
|
||||||
switch_caller_profile *cloned_profile;
|
|
||||||
|
|
||||||
if ((originator_caller_profile = switch_channel_get_caller_profile(orig_channel))) {
|
|
||||||
cloned_profile = switch_caller_profile_clone(*new_session, originator_caller_profile);
|
|
||||||
switch_channel_set_originator_caller_profile(channel, cloned_profile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch_channel_set_flag(channel, CF_OUTBOUND);
|
switch_channel_set_flag(channel, CF_OUTBOUND);
|
||||||
switch_set_flag(tech_pvt, TFLAG_OUTBOUND);
|
switch_set_flag(tech_pvt, TFLAG_OUTBOUND);
|
||||||
|
|
|
@ -477,7 +477,7 @@ static switch_status channel_outgoing_channel(switch_core_session *session, swit
|
||||||
if ((*new_session = switch_core_session_request(&channel_endpoint_interface, NULL))) {
|
if ((*new_session = switch_core_session_request(&channel_endpoint_interface, NULL))) {
|
||||||
struct private_object *tech_pvt;
|
struct private_object *tech_pvt;
|
||||||
switch_channel *channel, *orig_channel;
|
switch_channel *channel, *orig_channel;
|
||||||
switch_caller_profile *caller_profile, *originator_caller_profile = NULL;
|
switch_caller_profile *caller_profile;
|
||||||
unsigned int req = 0, cap = 0;
|
unsigned int req = 0, cap = 0;
|
||||||
|
|
||||||
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object)))) {
|
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object)))) {
|
||||||
|
@ -523,17 +523,6 @@ static switch_status channel_outgoing_channel(switch_core_session *session, swit
|
||||||
caller_profile->destination_number,
|
caller_profile->destination_number,
|
||||||
NULL, 0, req, cap);
|
NULL, 0, req, cap);
|
||||||
|
|
||||||
|
|
||||||
/* (session == NULL) means it was originated from the core not from another channel */
|
|
||||||
if (session && (orig_channel = switch_core_session_get_channel(session))) {
|
|
||||||
switch_caller_profile *cloned_profile;
|
|
||||||
|
|
||||||
if ((originator_caller_profile = switch_channel_get_caller_profile(orig_channel))) {
|
|
||||||
cloned_profile = switch_caller_profile_clone(*new_session, originator_caller_profile);
|
|
||||||
switch_channel_set_originator_caller_profile(channel, cloned_profile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch_channel_set_flag(channel, CF_OUTBOUND);
|
switch_channel_set_flag(channel, CF_OUTBOUND);
|
||||||
switch_set_flag(tech_pvt, TFLAG_OUTBOUND);
|
switch_set_flag(tech_pvt, TFLAG_OUTBOUND);
|
||||||
switch_channel_set_state(channel, CS_INIT);
|
switch_channel_set_state(channel, CS_INIT);
|
||||||
|
@ -904,8 +893,10 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IAX_EVENT_BUSY:
|
case IAX_EVENT_REJECT:
|
||||||
case IAX_EVENT_HANGUP:
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Rejected call.\n");
|
||||||
|
case IAX_EVENT_BUSY:
|
||||||
|
case IAX_EVENT_HANGUP:
|
||||||
if (tech_pvt) {
|
if (tech_pvt) {
|
||||||
switch_channel *channel;
|
switch_channel *channel;
|
||||||
|
|
||||||
|
@ -941,9 +932,6 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
|
||||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Call transfer occurred.\n");
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Call transfer occurred.\n");
|
||||||
//session[0] = iaxevent->session;
|
//session[0] = iaxevent->session;
|
||||||
break;
|
break;
|
||||||
case IAX_EVENT_REJECT:
|
|
||||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Rejected call.\n");
|
|
||||||
break;
|
|
||||||
case IAX_EVENT_DTMF:
|
case IAX_EVENT_DTMF:
|
||||||
if (tech_pvt) {
|
if (tech_pvt) {
|
||||||
switch_channel *channel;
|
switch_channel *channel;
|
||||||
|
|
|
@ -44,17 +44,27 @@ void playback_function(switch_core_session *session, char *data)
|
||||||
switch_file_t *fd;
|
switch_file_t *fd;
|
||||||
char buf[960];
|
char buf[960];
|
||||||
char dtmf[128];
|
char dtmf[128];
|
||||||
|
char *ext;
|
||||||
int interval = 0, samples = 0;
|
int interval = 0, samples = 0;
|
||||||
size_t len = 0, ilen = 0;
|
size_t len = 0, ilen = 0;
|
||||||
switch_frame write_frame;
|
switch_frame write_frame;
|
||||||
switch_timer timer;
|
switch_timer timer;
|
||||||
switch_core_thread_session thread_session;
|
switch_core_thread_session thread_session;
|
||||||
switch_codec codec;
|
switch_codec codec;
|
||||||
|
char *codec_name;
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
channel = switch_core_session_get_channel(session);
|
channel = switch_core_session_get_channel(session);
|
||||||
assert(channel != NULL);
|
assert(channel != NULL);
|
||||||
|
|
||||||
|
|
||||||
|
if (!(ext = strrchr(data, '.'))) {
|
||||||
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Invalid Format\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ext++;
|
||||||
|
|
||||||
switch_channel_answer(channel);
|
switch_channel_answer(channel);
|
||||||
|
|
||||||
write_frame.data = buf;
|
write_frame.data = buf;
|
||||||
|
@ -65,19 +75,20 @@ void playback_function(switch_core_session *session, char *data)
|
||||||
switch_channel_hangup(channel);
|
switch_channel_hangup(channel);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "OPEN FILE %s\n", data);
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "OPEN FILE %s\n", data);
|
||||||
|
|
||||||
interval = 20;
|
interval = 20;
|
||||||
len = 320;
|
len = 320;
|
||||||
samples = 160;
|
samples = 160;
|
||||||
|
codec_name = "L16";
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
interval = 30;
|
interval = 20;
|
||||||
len = 480;
|
len = 33;
|
||||||
samples = 240;
|
samples = 160;
|
||||||
|
codec_name = "gsm";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
write_frame.samples = samples;
|
write_frame.samples = samples;
|
||||||
|
@ -91,7 +102,7 @@ void playback_function(switch_core_session *session, char *data)
|
||||||
|
|
||||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "setup timer success %d bytes per %d ms!\n", len, interval);
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "setup timer success %d bytes per %d ms!\n", len, interval);
|
||||||
|
|
||||||
if (switch_core_codec_init(&codec, "L16", 8000, interval, SWITCH_CODEC_FLAG_ENCODE|SWITCH_CODEC_FLAG_DECODE, NULL) == SWITCH_STATUS_SUCCESS) {
|
if (switch_core_codec_init(&codec, codec_name, 8000, interval, SWITCH_CODEC_FLAG_ENCODE|SWITCH_CODEC_FLAG_DECODE, NULL) == SWITCH_STATUS_SUCCESS) {
|
||||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Raw Codec Activated\n");
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Raw Codec Activated\n");
|
||||||
write_frame.codec = &codec;
|
write_frame.codec = &codec;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -297,7 +297,7 @@ static switch_status channel_outgoing_channel(switch_core_session *session, swit
|
||||||
if ((*new_session = switch_core_session_request(&channel_endpoint_interface, NULL))) {
|
if ((*new_session = switch_core_session_request(&channel_endpoint_interface, NULL))) {
|
||||||
struct private_object *tech_pvt;
|
struct private_object *tech_pvt;
|
||||||
switch_channel *channel, *orig_channel;
|
switch_channel *channel, *orig_channel;
|
||||||
switch_caller_profile *caller_profile, *originator_caller_profile = NULL;
|
switch_caller_profile *caller_profile;
|
||||||
|
|
||||||
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object)))) {
|
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object)))) {
|
||||||
memset(tech_pvt, 0, sizeof(*tech_pvt));
|
memset(tech_pvt, 0, sizeof(*tech_pvt));
|
||||||
|
@ -323,17 +323,6 @@ static switch_status channel_outgoing_channel(switch_core_session *session, swit
|
||||||
return SWITCH_STATUS_GENERR;
|
return SWITCH_STATUS_GENERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (session == NULL) means it was originated from the core not from another channel */
|
|
||||||
if (session && (orig_channel = switch_core_session_get_channel(session))) {
|
|
||||||
switch_caller_profile *cloned_profile;
|
|
||||||
|
|
||||||
if ((originator_caller_profile = switch_channel_get_caller_profile(orig_channel))) {
|
|
||||||
cloned_profile = switch_caller_profile_clone(*new_session, originator_caller_profile);
|
|
||||||
switch_channel_set_originator_caller_profile(channel, cloned_profile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
switch_channel_set_flag(channel, CF_OUTBOUND);
|
switch_channel_set_flag(channel, CF_OUTBOUND);
|
||||||
switch_set_flag(tech_pvt, TFLAG_OUTBOUND);
|
switch_set_flag(tech_pvt, TFLAG_OUTBOUND);
|
||||||
switch_channel_set_state(channel, CS_INIT);
|
switch_channel_set_state(channel, CS_INIT);
|
||||||
|
|
|
@ -348,8 +348,8 @@ static switch_status woomerachan_outgoing_channel(switch_core_session *session,
|
||||||
if ((*new_session = switch_core_session_request(&woomerachan_endpoint_interface, NULL))) {
|
if ((*new_session = switch_core_session_request(&woomerachan_endpoint_interface, NULL))) {
|
||||||
struct private_object *tech_pvt;
|
struct private_object *tech_pvt;
|
||||||
switch_channel *channel, *orig_channel;
|
switch_channel *channel, *orig_channel;
|
||||||
switch_caller_profile *caller_profile, *originator_caller_profile = NULL;
|
|
||||||
|
|
||||||
|
|
||||||
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object)))) {
|
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object)))) {
|
||||||
memset(tech_pvt, 0, sizeof(*tech_pvt));
|
memset(tech_pvt, 0, sizeof(*tech_pvt));
|
||||||
tech_pvt->profile = &default_profile;
|
tech_pvt->profile = &default_profile;
|
||||||
|
@ -364,6 +364,8 @@ static switch_status woomerachan_outgoing_channel(switch_core_session *session,
|
||||||
|
|
||||||
if (outbound_profile) {
|
if (outbound_profile) {
|
||||||
char name[128];
|
char name[128];
|
||||||
|
switch_caller_profile *caller_profile;
|
||||||
|
|
||||||
caller_profile = switch_caller_profile_clone(*new_session, outbound_profile);
|
caller_profile = switch_caller_profile_clone(*new_session, outbound_profile);
|
||||||
switch_channel_set_caller_profile(channel, caller_profile);
|
switch_channel_set_caller_profile(channel, caller_profile);
|
||||||
tech_pvt->caller_profile = caller_profile;
|
tech_pvt->caller_profile = caller_profile;
|
||||||
|
@ -375,16 +377,6 @@ static switch_status woomerachan_outgoing_channel(switch_core_session *session,
|
||||||
return SWITCH_STATUS_GENERR;
|
return SWITCH_STATUS_GENERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (session == NULL) means it was originated from the core not from another channel */
|
|
||||||
if (session && (orig_channel = switch_core_session_get_channel(session))) {
|
|
||||||
switch_caller_profile *cloned_profile;
|
|
||||||
|
|
||||||
if ((originator_caller_profile = switch_channel_get_caller_profile(orig_channel))) {
|
|
||||||
cloned_profile = switch_caller_profile_clone(*new_session, originator_caller_profile);
|
|
||||||
switch_channel_set_originator_caller_profile(channel, cloned_profile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch_channel_set_flag(channel, CF_OUTBOUND);
|
switch_channel_set_flag(channel, CF_OUTBOUND);
|
||||||
switch_set_flag(tech_pvt, TFLAG_OUTBOUND);
|
switch_set_flag(tech_pvt, TFLAG_OUTBOUND);
|
||||||
switch_channel_set_state(channel, CS_INIT);
|
switch_channel_set_state(channel, CS_INIT);
|
||||||
|
|
|
@ -75,30 +75,39 @@ SWITCH_DECLARE(switch_caller_profile *) switch_caller_profile_clone(switch_core_
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(void) switch_caller_profile_event_set_data(switch_caller_profile *caller_profile, switch_event *event)
|
SWITCH_DECLARE(void) switch_caller_profile_event_set_data(switch_caller_profile *caller_profile, char *prefix, switch_event *event)
|
||||||
|
|
||||||
{
|
{
|
||||||
if (caller_profile->dialplan) {
|
char header_name[1024];
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Dialplan", caller_profile->dialplan);
|
|
||||||
}
|
if (caller_profile->dialplan) {
|
||||||
if (caller_profile->caller_id_name) {
|
snprintf(header_name, sizeof(header_name), "%s-Dialplan", prefix);
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Caller-ID-Name", caller_profile->caller_id_name);
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->dialplan);
|
||||||
}
|
}
|
||||||
if (caller_profile->caller_id_number) {
|
if (caller_profile->caller_id_name) {
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Caller-ID-Number", caller_profile->caller_id_number);
|
snprintf(header_name, sizeof(header_name), "%s-Caller-ID-Name", prefix);
|
||||||
}
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->caller_id_name);
|
||||||
if (caller_profile->network_addr) {
|
}
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Network-Addr", caller_profile->network_addr);
|
if (caller_profile->caller_id_number) {
|
||||||
}
|
snprintf(header_name, sizeof(header_name), "%s-Caller-ID-Number", prefix);
|
||||||
if (caller_profile->ani) {
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->caller_id_number);
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-ANI", caller_profile->ani);
|
}
|
||||||
}
|
if (caller_profile->network_addr) {
|
||||||
if (caller_profile->ani2) {
|
snprintf(header_name, sizeof(header_name), "%s-Network-Addr", prefix);
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-ANI2", caller_profile->ani2);
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->network_addr);
|
||||||
}
|
}
|
||||||
if (caller_profile->destination_number) {
|
if (caller_profile->ani) {
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Destination-Number", caller_profile->destination_number);
|
snprintf(header_name, sizeof(header_name), "%s-ANI", prefix);
|
||||||
}
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->ani);
|
||||||
|
}
|
||||||
|
if (caller_profile->ani2) {
|
||||||
|
snprintf(header_name, sizeof(header_name), "%s-ANI2", prefix);
|
||||||
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->ani2);
|
||||||
|
}
|
||||||
|
if (caller_profile->destination_number) {
|
||||||
|
snprintf(header_name, sizeof(header_name), "%s-Destination-Number", prefix);
|
||||||
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->destination_number);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ struct switch_channel {
|
||||||
switch_channel_flag flags;
|
switch_channel_flag flags;
|
||||||
switch_caller_profile *caller_profile;
|
switch_caller_profile *caller_profile;
|
||||||
switch_caller_profile *originator_caller_profile;
|
switch_caller_profile *originator_caller_profile;
|
||||||
|
switch_caller_profile *originatee_caller_profile;
|
||||||
switch_caller_extension *caller_extension;
|
switch_caller_extension *caller_extension;
|
||||||
const struct switch_event_handler_table *event_handlers;
|
const struct switch_event_handler_table *event_handlers;
|
||||||
switch_hash *variables;
|
switch_hash *variables;
|
||||||
|
@ -397,13 +398,14 @@ SWITCH_DECLARE(switch_channel_state) switch_channel_set_state(switch_channel *ch
|
||||||
|
|
||||||
SWITCH_DECLARE(void) switch_channel_event_set_data(switch_channel *channel, switch_event *event)
|
SWITCH_DECLARE(void) switch_channel_event_set_data(switch_channel *channel, switch_event *event)
|
||||||
{
|
{
|
||||||
switch_caller_profile *caller_profile, *originator_caller_profile;
|
switch_caller_profile *caller_profile, *originator_caller_profile, *originatee_caller_profile;
|
||||||
switch_hash_index_t* hi;
|
switch_hash_index_t* hi;
|
||||||
void *val;
|
void *val;
|
||||||
const void *var;
|
const void *var;
|
||||||
|
|
||||||
caller_profile = switch_channel_get_caller_profile(channel);
|
caller_profile = switch_channel_get_caller_profile(channel);
|
||||||
originator_caller_profile = switch_channel_get_originator_caller_profile(channel);
|
originator_caller_profile = switch_channel_get_originator_caller_profile(channel);
|
||||||
|
originatee_caller_profile = switch_channel_get_originatee_caller_profile(channel);
|
||||||
|
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-State", (char *) switch_channel_state_name(channel->state));
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-State", (char *) switch_channel_state_name(channel->state));
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Name", switch_channel_get_name(channel));
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Name", switch_channel_get_name(channel));
|
||||||
|
@ -412,12 +414,17 @@ SWITCH_DECLARE(void) switch_channel_event_set_data(switch_channel *channel, swit
|
||||||
|
|
||||||
/* Index Caller's Profile */
|
/* Index Caller's Profile */
|
||||||
if (caller_profile) {
|
if (caller_profile) {
|
||||||
switch_caller_profile_event_set_data(caller_profile, event);
|
switch_caller_profile_event_set_data(caller_profile, "Caller", event);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Index Originator's Profile */
|
/* Index Originator's Profile */
|
||||||
if (originator_caller_profile) {
|
if (originator_caller_profile) {
|
||||||
switch_caller_profile_event_set_data(originator_caller_profile, event);
|
switch_caller_profile_event_set_data(originator_caller_profile, "Originator", event);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Index Originatee's Profile */
|
||||||
|
if (originatee_caller_profile) {
|
||||||
|
switch_caller_profile_event_set_data(originatee_caller_profile, "Originatee", event);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Index Variables */
|
/* Index Variables */
|
||||||
|
@ -452,12 +459,24 @@ SWITCH_DECLARE(void) switch_channel_set_originator_caller_profile(switch_channel
|
||||||
channel->originator_caller_profile = caller_profile;
|
channel->originator_caller_profile = caller_profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SWITCH_DECLARE(void) switch_channel_set_originatee_caller_profile(switch_channel *channel, switch_caller_profile *caller_profile)
|
||||||
|
{
|
||||||
|
assert(channel != NULL);
|
||||||
|
channel->originatee_caller_profile = caller_profile;
|
||||||
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(switch_caller_profile *) switch_channel_get_originator_caller_profile(switch_channel *channel)
|
SWITCH_DECLARE(switch_caller_profile *) switch_channel_get_originator_caller_profile(switch_channel *channel)
|
||||||
{
|
{
|
||||||
assert(channel != NULL);
|
assert(channel != NULL);
|
||||||
return channel->originator_caller_profile;
|
return channel->originator_caller_profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SWITCH_DECLARE(switch_caller_profile *) switch_channel_get_originatee_caller_profile(switch_channel *channel)
|
||||||
|
{
|
||||||
|
assert(channel != NULL);
|
||||||
|
return channel->originatee_caller_profile;
|
||||||
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(void) switch_channel_set_event_handlers(switch_channel *channel, const struct switch_event_handler_table *event_handlers)
|
SWITCH_DECLARE(void) switch_channel_set_event_handlers(switch_channel *channel, const struct switch_event_handler_table *event_handlers)
|
||||||
{
|
{
|
||||||
assert(channel != NULL);
|
assert(channel != NULL);
|
||||||
|
|
|
@ -521,6 +521,31 @@ SWITCH_DECLARE(switch_status) switch_core_session_outgoing_channel(switch_core_s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (*new_session) {
|
||||||
|
switch_caller_profile *profile = NULL, *peer_profile = NULL, *cloned_profile = NULL;
|
||||||
|
switch_channel *channel = NULL, *peer_channel = NULL;
|
||||||
|
|
||||||
|
if ((channel = switch_core_session_get_channel(session))) {
|
||||||
|
profile = switch_channel_get_caller_profile(channel);
|
||||||
|
}
|
||||||
|
if ((peer_channel = switch_core_session_get_channel(*new_session))) {
|
||||||
|
peer_profile = switch_channel_get_caller_profile(peer_channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (channel && peer_channel) {
|
||||||
|
if (profile) {
|
||||||
|
if ((cloned_profile = switch_caller_profile_clone(*new_session, profile))) {
|
||||||
|
switch_channel_set_originator_caller_profile(peer_channel, cloned_profile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (peer_profile) {
|
||||||
|
if ((cloned_profile = switch_caller_profile_clone(session, peer_profile))) {
|
||||||
|
switch_channel_set_originatee_caller_profile(channel, cloned_profile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,20 +31,20 @@
|
||||||
*/
|
*/
|
||||||
#include <switch_utils.h>
|
#include <switch_utils.h>
|
||||||
|
|
||||||
SWITCH_DECLARE(char *) switch_cut_path(char *in)
|
SWITCH_DECLARE(char *) switch_cut_path(char *in)
|
||||||
{
|
{
|
||||||
char *p, *ret = in;
|
char *p, *ret = in;
|
||||||
char delims[] = "/\\";
|
char delims[] = "/\\";
|
||||||
char *i;
|
char *i;
|
||||||
|
|
||||||
for(i = delims; *i; i++) {
|
for(i = delims; *i; i++) {
|
||||||
p = in;
|
p = in;
|
||||||
while((p = strchr(p, *i))) {
|
while((p = strchr(p, *i))) {
|
||||||
ret = ++p;
|
ret = ++p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SWITCH_DECLARE(void) switch_swap_linear(int16_t *buf, int len)
|
SWITCH_DECLARE(void) switch_swap_linear(int16_t *buf, int len)
|
||||||
|
|
Loading…
Reference in New Issue