adding some inter channel communication and other code for real-world usage (not totally done)

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@646 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2006-02-22 02:50:33 +00:00
parent 4ff821ef76
commit fe3e994237
11 changed files with 194 additions and 36 deletions

View File

@ -76,6 +76,10 @@ extern "C" {
char *ani2; char *ani2;
/*! Destination Number */ /*! Destination Number */
char *destination_number; char *destination_number;
/*! channel name */
char *chan_name;
/*! unique id */
char *uuid;
}; };
/*! \brief An Abstract Representation of a dialplan Application */ /*! \brief An Abstract Representation of a dialplan Application */

View File

@ -129,6 +129,14 @@ SWITCH_DECLARE(void) switch_channel_set_originatee_caller_profile(switch_channel
*/ */
SWITCH_DECLARE(switch_caller_profile *) switch_channel_get_originatee_caller_profile(switch_channel *channel); SWITCH_DECLARE(switch_caller_profile *) switch_channel_get_originatee_caller_profile(switch_channel *channel);
/*!
\brief Retrive the given channel's unique id
\param channel channel to retrive the unique id from
\return the unique id
*/
SWITCH_DECLARE(char *) switch_channel_get_uuid(switch_channel *channel);
/*! /*!
\brief Set a variable on a given channel \brief Set a variable on a given channel
\param channel channel to set variable on \param channel channel to set variable on

View File

@ -64,13 +64,15 @@ typedef enum {
\enum switch_core_session_message_t \enum switch_core_session_message_t
\brief Possible types of messages for inter-session communication \brief Possible types of messages for inter-session communication
<pre> <pre>
SWITCH_MESSAGE_REDIRECT_AUDIO - Indication to redirect audio to another location if possible SWITCH_MESSAGE_REDIRECT_AUDIO - Indication to redirect audio to another location if possible
SWITCH_MESSAGE_TRANSMIT_TEXT - A text message SWITCH_MESSAGE_TRANSMIT_TEXT - A text message
SWITCH_MESSAGE_INDICATE_PROGRESS - indicate progress
</pre> </pre>
*/ */
typedef enum { typedef enum {
SWITCH_MESSAGE_REDIRECT_AUDIO, SWITCH_MESSAGE_REDIRECT_AUDIO,
SWITCH_MESSAGE_TRANSMIT_TEXT SWITCH_MESSAGE_TRANSMIT_TEXT,
SWITCH_MESSAGE_INDICATE_PROGRESS
} switch_core_session_message_t; } switch_core_session_message_t;
@ -171,18 +173,20 @@ typedef enum {
\brief Channel Flags \brief Channel Flags
<pre> <pre>
CF_SEND_AUDIO = (1 << 0) - Channel will send audio CF_SEND_AUDIO = (1 << 0) - Channel will send audio
CF_RECV_AUDIO = (1 << 1) - Channel will receive audio CF_RECV_AUDIO = (1 << 1) - Channel will receive audio
CF_ANSWERED = (1 << 2) - Channel is answered CF_ANSWERED = (1 << 2) - Channel is answered
CF_OUTBOUND = (1 << 3) - Channel is an outbound channel CF_OUTBOUND = (1 << 3) - Channel is an outbound channel
CF_EARLY_MEDIA = (1 << 4) - Channel is ready for audio before answer
</pre> </pre>
*/ */
typedef enum { typedef enum {
CF_SEND_AUDIO = (1 << 0), CF_SEND_AUDIO = (1 << 0),
CF_RECV_AUDIO = (1 << 1), CF_RECV_AUDIO = (1 << 1),
CF_ANSWERED = (1 << 2), CF_ANSWERED = (1 << 2),
CF_OUTBOUND = (1 << 3), CF_OUTBOUND = (1 << 3),
CF_EARLY_MEDIA = (1 << 4)
} switch_channel_flag; } switch_channel_flag;

View File

@ -47,8 +47,8 @@ static void *audio_bridge_thread(switch_thread *thread, void *obj)
{ {
struct switch_core_thread_session *data = obj; struct switch_core_thread_session *data = obj;
int *stream_id_p; int *stream_id_p;
int stream_id = 0; int stream_id = 0, ans_a = 0, ans_b = 0;
switch_channel *chan_a, *chan_b; switch_channel *chan_a, *chan_b;
switch_frame *read_frame; switch_frame *read_frame;
switch_core_session *session_a, *session_b; switch_core_session *session_a, *session_b;
@ -64,6 +64,11 @@ static void *audio_bridge_thread(switch_thread *thread, void *obj)
chan_a = switch_core_session_get_channel(session_a); chan_a = switch_core_session_get_channel(session_a);
chan_b = switch_core_session_get_channel(session_b); chan_b = switch_core_session_get_channel(session_b);
ans_a = switch_channel_test_flag(chan_a, CF_ANSWERED);
ans_b = switch_channel_test_flag(chan_b, CF_ANSWERED);
while (data->running > 0) { while (data->running > 0) {
switch_channel_state b_state = switch_channel_get_state(chan_b); switch_channel_state b_state = switch_channel_get_state(chan_b);
@ -76,6 +81,15 @@ static void *audio_bridge_thread(switch_thread *thread, void *obj)
break; break;
} }
if (!ans_b && switch_channel_test_flag(chan_a, CF_ANSWERED)) {
switch_channel_answer(chan_b);
}
if (!ans_a && switch_channel_test_flag(chan_b, CF_ANSWERED)) {
switch_channel_answer(chan_a);
}
if (switch_channel_has_dtmf(chan_a)) { if (switch_channel_has_dtmf(chan_a)) {
char dtmf[128]; char dtmf[128];
switch_channel_dequeue_dtmf(chan_a, dtmf, sizeof(dtmf)); switch_channel_dequeue_dtmf(chan_a, dtmf, sizeof(dtmf));
@ -229,12 +243,18 @@ static void audio_bridge_function(switch_core_session *session, char *data)
time(&start); time(&start);
while (switch_channel_get_state(caller_channel) == CS_EXECUTE && while (switch_channel_get_state(caller_channel) == CS_EXECUTE &&
switch_channel_get_state(peer_channel) == CS_TRANSMIT && switch_channel_get_state(peer_channel) == CS_TRANSMIT &&
!switch_channel_test_flag(peer_channel, CF_ANSWERED) && ((time(NULL) - start) < timelimit)) { !switch_channel_test_flag(peer_channel, CF_ANSWERED) &&
!switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA) &&
((time(NULL) - start) < timelimit)) {
switch_yield(20000); switch_yield(20000);
} }
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);
}
if (switch_channel_test_flag(peer_channel, CF_ANSWERED) ||
switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA)) {
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);

View File

@ -63,7 +63,8 @@ typedef enum {
TFLAG_USING_CODEC = (1 << 6), TFLAG_USING_CODEC = (1 << 6),
TFLAG_RTP = (1 << 7), TFLAG_RTP = (1 << 7),
TFLAG_BYE = (1 << 8), TFLAG_BYE = (1 << 8),
TFLAG_ANS = (1 << 9) TFLAG_ANS = (1 << 9),
TFLAG_EARLY_MEDIA = (1 << 10)
} TFLAGS; } TFLAGS;
@ -465,7 +466,7 @@ static switch_status exosip_answer_channel(switch_core_session *session)
tech_pvt = switch_core_session_get_private(session); tech_pvt = switch_core_session_get_private(session);
assert(tech_pvt != NULL); assert(tech_pvt != NULL);
if (!switch_test_flag(tech_pvt, TFLAG_ANS) && !switch_channel_test_flag(channel, CF_OUTBOUND)) { if (!switch_test_flag(tech_pvt, TFLAG_ANS) && !switch_channel_test_flag(channel, CF_OUTBOUND) ) {
char *buf = NULL; char *buf = NULL;
osip_message_t *answer = NULL; osip_message_t *answer = NULL;
@ -666,6 +667,54 @@ static switch_status exosip_waitfor_write(switch_core_session *session, int ms,
} }
static switch_status exosip_send_dtmf(switch_core_session *session, char *digits)
{
return SWITCH_STATUS_FALSE;
}
static switch_status exosip_receive_message(switch_core_session *session, switch_core_session_message *msg)
{
switch (msg->message_id) {
case SWITCH_MESSAGE_INDICATE_PROGRESS:
if (msg) {
struct private_object *tech_pvt;
switch_channel *channel = NULL;
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
tech_pvt = switch_core_session_get_private(session);
assert(tech_pvt != NULL);
if (!switch_test_flag(tech_pvt, TFLAG_EARLY_MEDIA)) {
char *buf = NULL;
osip_message_t *progress = NULL;
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Asked to send early media by %s\n", msg->from);
/* Transmit 183 Progress with SDP */
eXosip_lock();
eXosip_call_build_answer(tech_pvt->tid, 183, &progress);
sdp_message_to_str(tech_pvt->local_sdp, &buf);
osip_message_set_body(progress, buf, strlen(buf));
osip_message_set_content_type(progress, "application/sdp");
free(buf);
eXosip_call_send_answer(tech_pvt->tid, 183, progress);
eXosip_unlock();
switch_set_flag(tech_pvt, TFLAG_EARLY_MEDIA);
switch_channel_set_flag(channel, CF_EARLY_MEDIA);
}
}
break;
default:
break;
}
return SWITCH_STATUS_SUCCESS;
}
static const switch_io_routines exosip_io_routines = { static const switch_io_routines exosip_io_routines = {
/*.outgoing_channel */ exosip_outgoing_channel, /*.outgoing_channel */ exosip_outgoing_channel,
/*.answer_channel */ exosip_answer_channel, /*.answer_channel */ exosip_answer_channel,
@ -673,7 +722,9 @@ static const switch_io_routines exosip_io_routines = {
/*.write_frame */ exosip_write_frame, /*.write_frame */ exosip_write_frame,
/*.kill_channel */ exosip_kill_channel, /*.kill_channel */ exosip_kill_channel,
/*.waitfor_read */ exosip_waitfor_read, /*.waitfor_read */ exosip_waitfor_read,
/*.waitfor_read */ exosip_waitfor_write /*.waitfor_read */ exosip_waitfor_write,
/*.send_dtmf*/ exosip_send_dtmf,
/*.receive_message*/ exosip_receive_message
}; };
static const switch_state_handler_table exosip_event_handlers = { static const switch_state_handler_table exosip_event_handlers = {
@ -725,13 +776,15 @@ 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; switch_caller_profile *caller_profile = NULL;
snprintf(name, sizeof(name), "Exosip/%s-%04x", outbound_profile->destination_number, rand() & 0xffff);
switch_channel_set_name(channel, name);
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;
snprintf(name, sizeof(name), "Exosip/%s-%04x", caller_profile->destination_number, rand() & 0xffff);
switch_channel_set_name(channel, name);
} else { } else {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Doh! no caller profile\n"); switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Doh! no caller profile\n");
switch_core_session_destroy(new_session); switch_core_session_destroy(new_session);
@ -806,6 +859,9 @@ static switch_status exosip_create_call(eXosip_event_t * event)
return SWITCH_STATUS_MEMERR; return SWITCH_STATUS_MEMERR;
} }
snprintf(name, sizeof(name), "Exosip/%s-%04x", event->request->from->url->username, rand() & 0xffff);
switch_channel_set_name(channel, name);
if ((tech_pvt->caller_profile = switch_caller_profile_new(session, if ((tech_pvt->caller_profile = switch_caller_profile_new(session,
globals.dialplan, globals.dialplan,
event->request->from->displayname, event->request->from->displayname,
@ -820,8 +876,7 @@ static switch_status exosip_create_call(eXosip_event_t * event)
tech_pvt->cid = event->cid; tech_pvt->cid = event->cid;
tech_pvt->tid = event->tid; tech_pvt->tid = event->tid;
snprintf(name, sizeof(name), "Exosip/%s-%04x", tech_pvt->caller_profile->destination_number, rand() & 0xffff);
switch_channel_set_name(channel, name);
if ((remote_sdp = eXosip_get_sdp_info(event->request)) == 0) { if ((remote_sdp = eXosip_get_sdp_info(event->request)) == 0) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Cannot Find Remote SDP!\n"); switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Cannot Find Remote SDP!\n");

View File

@ -733,11 +733,13 @@ static switch_status channel_outgoing_channel(switch_core_session *session, swit
if (outbound_profile) { if (outbound_profile) {
char name[128]; char name[128];
snprintf(name, sizeof(name), "IAX/%s-%04x", outbound_profile->destination_number, rand() & 0xffff);
switch_channel_set_name(channel, name);
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;
snprintf(name, sizeof(name), "IAX/%s-%04x", caller_profile->destination_number, rand() & 0xffff);
switch_channel_set_name(channel, name);
} else { } else {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Doh! no caller profile\n"); switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Doh! no caller profile\n");
switch_core_session_destroy(new_session); switch_core_session_destroy(new_session);
@ -983,10 +985,11 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
iaxevent->ies.calling_ani, iaxevent->ies.calling_ani,
NULL, iaxevent->ies.called_number)) != 0) { NULL, iaxevent->ies.called_number)) != 0) {
char name[128]; char name[128];
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
snprintf(name, sizeof(name), "IAX/%s-%04x", tech_pvt->caller_profile->destination_number, snprintf(name, sizeof(name), "IAX/%s-%04x", tech_pvt->caller_profile->destination_number,
rand() & 0xffff); rand() & 0xffff);
switch_channel_set_name(channel, name); switch_channel_set_name(channel, name);
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
} }
if (iax_set_codec(tech_pvt, iaxevent->session, if (iax_set_codec(tech_pvt, iaxevent->session,

View File

@ -498,13 +498,14 @@ static switch_status channel_outgoing_channel(switch_core_session *session, swit
if (outbound_profile) { if (outbound_profile) {
char name[128]; char name[128];
snprintf(name, sizeof(name), "PortAudio/%s-%04x",
caller_profile->destination_number ? outbound_profile->destination_number : modname,
rand() & 0xffff);
switch_channel_set_name(channel, name);
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;
snprintf(name, sizeof(name), "PortAudio/%s-%04x",
caller_profile->destination_number ? caller_profile->destination_number : modname,
rand() & 0xffff);
switch_channel_set_name(channel, name);
} else { } else {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Doh! no caller profile\n"); switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Doh! no caller profile\n");
switch_core_session_destroy(new_session); switch_core_session_destroy(new_session);
@ -812,11 +813,12 @@ static switch_status place_call(char *dest, char *out, size_t outlen)
globals.cid_name, globals.cid_name,
globals.cid_num, NULL, NULL, NULL, dest)) != 0) { globals.cid_num, NULL, NULL, NULL, dest)) != 0) {
char name[128]; char name[128];
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
snprintf(name, sizeof(name), "PortAudio/%s-%04x", snprintf(name, sizeof(name), "PortAudio/%s-%04x",
tech_pvt->caller_profile->destination_number ? tech_pvt->caller_profile-> tech_pvt->caller_profile->destination_number ? tech_pvt->caller_profile->
destination_number : modname, rand() & 0xffff); destination_number : modname, rand() & 0xffff);
switch_channel_set_name(channel, name); switch_channel_set_name(channel, name);
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
} }
tech_pvt->session = session; tech_pvt->session = session;
if ((status = engage_device(tech_pvt)) == SWITCH_STATUS_SUCCESS) { if ((status = engage_device(tech_pvt)) == SWITCH_STATUS_SUCCESS) {

View File

@ -381,11 +381,12 @@ static switch_status wanpipe_outgoing_channel(switch_core_session *session, swit
} }
} }
snprintf(name, sizeof(name), "WanPipe/%s-%04x", caller_profile->destination_number, rand() & 0xffff);
switch_channel_set_name(channel, name);
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;
snprintf(name, sizeof(name), "WanPipe/%s-%04x", caller_profile->destination_number, rand() & 0xffff);
switch_channel_set_name(channel, name);
do { do {
if ((spri = &SPANS[span]->spri)) { if ((spri = &SPANS[span]->spri)) {
@ -704,6 +705,43 @@ static int on_answer(struct sangoma_pri *spri, sangoma_pri_event_t event_type, p
return 0; return 0;
} }
static int on_proceed(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *event)
{
switch_core_session *session;
switch_channel *channel;
struct channel_map *chanmap;
chanmap = spri->private;
if ((session = chanmap->map[event->proceeding.channel])) {
switch_caller_profile *originator;
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "-- Proceeding on channel %d\n", event->proceeding.channel);
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
if ((originator = switch_channel_get_originator_caller_profile(channel))) {
switch_core_session_message msg;
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "-- Passing progress to Originator %s\n", originator->chan_name);
msg.message_id = SWITCH_MESSAGE_INDICATE_PROGRESS;
msg.from = switch_channel_get_name(channel);
switch_core_session_message_send(originator->uuid, &msg);
switch_channel_set_flag(channel, CF_EARLY_MEDIA);
}
//switch_channel_answer(channel);
} else {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "-- Proceeding on channel %d but it's not in use?\n", event->proceeding.channel);
}
return 0;
}
static int on_ringing(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *event) static int on_ringing(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *event)
{ {
switch_core_session *session; switch_core_session *session;
@ -770,6 +808,7 @@ static int on_ring(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri
switch_core_session_set_private(session, tech_pvt); switch_core_session_set_private(session, tech_pvt);
sprintf(name, "w%dg%d", spri->span, event->ring.channel); sprintf(name, "w%dg%d", spri->span, event->ring.channel);
switch_channel_set_name(channel, name); switch_channel_set_name(channel, name);
} else { } else {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Hey where is my memory pool?\n"); switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Hey where is my memory pool?\n");
switch_core_session_destroy(&session); switch_core_session_destroy(&session);
@ -867,8 +906,10 @@ static void *pri_thread_run(switch_thread *thread, void *obj)
SANGOMA_MAP_PRI_EVENT((*spri), SANGOMA_PRI_EVENT_RING, on_ring); SANGOMA_MAP_PRI_EVENT((*spri), SANGOMA_PRI_EVENT_RING, on_ring);
SANGOMA_MAP_PRI_EVENT((*spri), SANGOMA_PRI_EVENT_RINGING, on_ringing); SANGOMA_MAP_PRI_EVENT((*spri), SANGOMA_PRI_EVENT_RINGING, on_ringing);
//SANGOMA_MAP_PRI_EVENT((*spri), SANGOMA_PRI_EVENT_SETUP_ACK, on_ringing); //SANGOMA_MAP_PRI_EVENT((*spri), SANGOMA_PRI_EVENT_SETUP_ACK, on_ringing);
SANGOMA_MAP_PRI_EVENT((*spri), SANGOMA_PRI_EVENT_PROCEEDING, on_proceed);
SANGOMA_MAP_PRI_EVENT((*spri), SANGOMA_PRI_EVENT_ANSWER, on_answer); SANGOMA_MAP_PRI_EVENT((*spri), SANGOMA_PRI_EVENT_ANSWER, on_answer);
SANGOMA_MAP_PRI_EVENT((*spri), SANGOMA_PRI_EVENT_HANGUP_REQ, on_hangup); SANGOMA_MAP_PRI_EVENT((*spri), SANGOMA_PRI_EVENT_HANGUP_REQ, on_hangup);
SANGOMA_MAP_PRI_EVENT((*spri), SANGOMA_PRI_EVENT_HANGUP, on_hangup);
SANGOMA_MAP_PRI_EVENT((*spri), SANGOMA_PRI_EVENT_INFO_RECEIVED, on_info); SANGOMA_MAP_PRI_EVENT((*spri), SANGOMA_PRI_EVENT_INFO_RECEIVED, on_info);
SANGOMA_MAP_PRI_EVENT((*spri), SANGOMA_PRI_EVENT_RESTART, on_restart); SANGOMA_MAP_PRI_EVENT((*spri), SANGOMA_PRI_EVENT_RESTART, on_restart);

View File

@ -490,11 +490,12 @@ static switch_status woomerachan_outgoing_channel(switch_core_session *session,
char name[128]; char name[128];
switch_caller_profile *caller_profile; switch_caller_profile *caller_profile;
snprintf(name, sizeof(name), "Woomera/%s-%04x", outbound_profile->destination_number, rand() & 0xffff);
switch_channel_set_name(channel, name);
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;
snprintf(name, sizeof(name), "Woomera/%s-%04x", caller_profile->destination_number, rand() & 0xffff);
switch_channel_set_name(channel, name);
} else { } else {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Doh! no caller profile\n"); switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Doh! no caller profile\n");
switch_core_session_destroy(new_session); switch_core_session_destroy(new_session);
@ -1067,10 +1068,11 @@ static void *woomera_channel_thread_run(switch_thread *thread, void *obj)
tech_pvt->profile->dialplan, tech_pvt->profile->dialplan,
cid_name, cid_num, ip, NULL, NULL, exten)) != 0) { cid_name, cid_num, ip, NULL, NULL, exten)) != 0) {
char name[128]; char name[128];
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
snprintf(name, sizeof(name), "Woomera/%s-%04x", tech_pvt->caller_profile->destination_number, snprintf(name, sizeof(name), "Woomera/%s-%04x", tech_pvt->caller_profile->destination_number,
rand() & 0xffff); rand() & 0xffff);
switch_channel_set_name(channel, name); switch_channel_set_name(channel, name);
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
} }
woomera_printf(tech_pvt->profile, tech_pvt->command_channel, woomera_printf(tech_pvt->profile, tech_pvt->command_channel,

View File

@ -68,6 +68,8 @@ SWITCH_DECLARE(switch_caller_profile *) switch_caller_profile_clone(switch_core_
profile->caller_id_number = switch_core_session_strdup(session, tocopy->caller_id_number); profile->caller_id_number = switch_core_session_strdup(session, tocopy->caller_id_number);
profile->network_addr = switch_core_session_strdup(session, tocopy->network_addr); profile->network_addr = switch_core_session_strdup(session, tocopy->network_addr);
profile->destination_number = switch_core_session_strdup(session, tocopy->destination_number); profile->destination_number = switch_core_session_strdup(session, tocopy->destination_number);
profile->uuid = switch_core_session_strdup(session, tocopy->uuid);
profile->chan_name = switch_core_session_strdup(session, tocopy->chan_name);
} }
return profile; return profile;

View File

@ -450,6 +450,16 @@ SWITCH_DECLARE(void) switch_channel_event_set_data(switch_channel *channel, swit
SWITCH_DECLARE(void) switch_channel_set_caller_profile(switch_channel *channel, switch_caller_profile *caller_profile) SWITCH_DECLARE(void) switch_channel_set_caller_profile(switch_channel *channel, switch_caller_profile *caller_profile)
{ {
assert(channel != NULL); assert(channel != NULL);
assert(channel->session != NULL);
if (!caller_profile->uuid) {
caller_profile->uuid = switch_core_session_strdup(channel->session, switch_core_session_get_uuid(channel->session));
}
if (!caller_profile->chan_name) {
caller_profile->chan_name = switch_core_session_strdup(channel->session, channel->name);
}
channel->caller_profile = caller_profile; channel->caller_profile = caller_profile;
} }
@ -479,6 +489,13 @@ SWITCH_DECLARE(switch_caller_profile *) switch_channel_get_originator_caller_pro
return channel->originator_caller_profile; return channel->originator_caller_profile;
} }
SWITCH_DECLARE(char *) switch_channel_get_uuid(switch_channel *channel)
{
assert(channel != NULL);
assert(channel->session != NULL);
return switch_core_session_get_uuid(channel->session);
}
SWITCH_DECLARE(switch_caller_profile *) switch_channel_get_originatee_caller_profile(switch_channel *channel) SWITCH_DECLARE(switch_caller_profile *) switch_channel_get_originatee_caller_profile(switch_channel *channel)
{ {
assert(channel != NULL); assert(channel != NULL);