mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-16 08:49:01 +00:00
<refactor>
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4944 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
5cd76f4a03
commit
f40f87ebca
@ -526,6 +526,14 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_message_send(char *uuid_str,
|
|||||||
*/
|
*/
|
||||||
SWITCH_DECLARE(switch_status_t) switch_core_session_queue_message(switch_core_session_t *session, switch_core_session_message_t *message);
|
SWITCH_DECLARE(switch_status_t) switch_core_session_queue_message(switch_core_session_t *session, switch_core_session_message_t *message);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief pass an indication message on a session
|
||||||
|
\param session the session to pass the message across
|
||||||
|
\param indication the indication message to pass
|
||||||
|
\return SWITCH_STATUS_SUCCESS if the message was passed
|
||||||
|
*/
|
||||||
|
SWITCH_DECLARE(switch_status_t) switch_core_session_pass_indication(switch_core_session_t *session, switch_core_session_message_types_t indication);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Queue an indication message on a session
|
\brief Queue an indication message on a session
|
||||||
\param session the session to queue the message to
|
\param session the session to queue the message to
|
||||||
@ -639,13 +647,6 @@ SWITCH_DECLARE(switch_call_cause_t) switch_core_session_outgoing_channel(switch_
|
|||||||
switch_caller_profile_t *caller_profile,
|
switch_caller_profile_t *caller_profile,
|
||||||
switch_core_session_t **new_session, switch_memory_pool_t **pool);
|
switch_core_session_t **new_session, switch_memory_pool_t **pool);
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Answer the channel of a given session
|
|
||||||
\param session the session to answer the channel of
|
|
||||||
\return SWITCH_STATUS_SUCCESS if the channel was answered
|
|
||||||
*/
|
|
||||||
SWITCH_DECLARE(switch_status_t) switch_core_session_answer_channel(switch_core_session_t *session);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Receive a message on a given session
|
\brief Receive a message on a given session
|
||||||
\param session the session to receive the message from
|
\param session the session to receive the message from
|
||||||
|
@ -35,7 +35,6 @@
|
|||||||
SWITCH_BEGIN_EXTERN_C typedef struct switch_io_event_hooks switch_io_event_hooks_t;
|
SWITCH_BEGIN_EXTERN_C typedef struct switch_io_event_hooks switch_io_event_hooks_t;
|
||||||
|
|
||||||
typedef struct switch_io_event_hook_outgoing_channel switch_io_event_hook_outgoing_channel_t;
|
typedef struct switch_io_event_hook_outgoing_channel switch_io_event_hook_outgoing_channel_t;
|
||||||
typedef struct switch_io_event_hook_answer_channel switch_io_event_hook_answer_channel_t;
|
|
||||||
typedef struct switch_io_event_hook_receive_message switch_io_event_hook_receive_message_t;
|
typedef struct switch_io_event_hook_receive_message switch_io_event_hook_receive_message_t;
|
||||||
typedef struct switch_io_event_hook_receive_event switch_io_event_hook_receive_event_t;
|
typedef struct switch_io_event_hook_receive_event switch_io_event_hook_receive_event_t;
|
||||||
typedef struct switch_io_event_hook_read_frame switch_io_event_hook_read_frame_t;
|
typedef struct switch_io_event_hook_read_frame switch_io_event_hook_read_frame_t;
|
||||||
@ -48,7 +47,6 @@ typedef struct switch_io_event_hook_state_change switch_io_event_hook_state_chan
|
|||||||
|
|
||||||
|
|
||||||
typedef switch_status_t (*switch_outgoing_channel_hook_t) (switch_core_session_t *, switch_caller_profile_t *, switch_core_session_t *);
|
typedef switch_status_t (*switch_outgoing_channel_hook_t) (switch_core_session_t *, switch_caller_profile_t *, switch_core_session_t *);
|
||||||
typedef switch_status_t (*switch_answer_channel_hook_t) (switch_core_session_t *);
|
|
||||||
typedef switch_status_t (*switch_receive_message_hook_t) (switch_core_session_t *, switch_core_session_message_t *);
|
typedef switch_status_t (*switch_receive_message_hook_t) (switch_core_session_t *, switch_core_session_message_t *);
|
||||||
typedef switch_status_t (*switch_receive_event_hook_t) (switch_core_session_t *, switch_event_t *);
|
typedef switch_status_t (*switch_receive_event_hook_t) (switch_core_session_t *, switch_event_t *);
|
||||||
typedef switch_status_t (*switch_read_frame_hook_t) (switch_core_session_t *, switch_frame_t **, int, switch_io_flag_t, int);
|
typedef switch_status_t (*switch_read_frame_hook_t) (switch_core_session_t *, switch_frame_t **, int, switch_io_flag_t, int);
|
||||||
@ -67,23 +65,16 @@ struct switch_io_event_hook_outgoing_channel {
|
|||||||
struct switch_io_event_hook_outgoing_channel *next;
|
struct switch_io_event_hook_outgoing_channel *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*! \brief Node in which to store custom answer channel callback hooks */
|
|
||||||
struct switch_io_event_hook_answer_channel {
|
|
||||||
/*! the answer channel callback hook */
|
|
||||||
switch_answer_channel_hook_t answer_channel;
|
|
||||||
struct switch_io_event_hook_answer_channel *next;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*! \brief Node in which to store custom receive message callback hooks */
|
/*! \brief Node in which to store custom receive message callback hooks */
|
||||||
struct switch_io_event_hook_receive_message {
|
struct switch_io_event_hook_receive_message {
|
||||||
/*! the answer channel callback hook */
|
/*! the message callback hook */
|
||||||
switch_receive_message_hook_t receive_message;
|
switch_receive_message_hook_t receive_message;
|
||||||
struct switch_io_event_hook_receive_message *next;
|
struct switch_io_event_hook_receive_message *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*! \brief Node in which to store custom receive message callback hooks */
|
/*! \brief Node in which to store custom receive message callback hooks */
|
||||||
struct switch_io_event_hook_receive_event {
|
struct switch_io_event_hook_receive_event {
|
||||||
/*! the answer channel callback hook */
|
/*! the event callback hook */
|
||||||
switch_receive_event_hook_t receive_event;
|
switch_receive_event_hook_t receive_event;
|
||||||
struct switch_io_event_hook_receive_event *next;
|
struct switch_io_event_hook_receive_event *next;
|
||||||
};
|
};
|
||||||
@ -141,8 +132,6 @@ struct switch_io_event_hook_state_change {
|
|||||||
struct switch_io_event_hooks {
|
struct switch_io_event_hooks {
|
||||||
/*! a list of outgoing channel hooks */
|
/*! a list of outgoing channel hooks */
|
||||||
switch_io_event_hook_outgoing_channel_t *outgoing_channel;
|
switch_io_event_hook_outgoing_channel_t *outgoing_channel;
|
||||||
/*! a list of answer channel hooks */
|
|
||||||
switch_io_event_hook_answer_channel_t *answer_channel;
|
|
||||||
/*! a list of receive message hooks */
|
/*! a list of receive message hooks */
|
||||||
switch_io_event_hook_receive_message_t *receive_message;
|
switch_io_event_hook_receive_message_t *receive_message;
|
||||||
/*! a list of queue message hooks */
|
/*! a list of queue message hooks */
|
||||||
@ -180,14 +169,6 @@ extern switch_io_event_hooks_t switch_core_session_get_event_hooks(switch_core_s
|
|||||||
SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_outgoing_channel(switch_core_session_t *session,
|
SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_outgoing_channel(switch_core_session_t *session,
|
||||||
switch_outgoing_channel_hook_t outgoing_channel);
|
switch_outgoing_channel_hook_t outgoing_channel);
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Add an event hook to be executed when a session answers a channel
|
|
||||||
\param session session to bind hook to
|
|
||||||
\param answer_channel hook to bind
|
|
||||||
\return SWITCH_STATUS_SUCCESS on suceess
|
|
||||||
*/
|
|
||||||
SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_answer_channel(switch_core_session_t *session, switch_answer_channel_hook_t answer_channel);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Add an event hook to be executed when a session sends a message
|
\brief Add an event hook to be executed when a session sends a message
|
||||||
\param session session to bind hook to
|
\param session session to bind hook to
|
||||||
@ -250,7 +231,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_send_dtmf(switch_core
|
|||||||
\param state_change hook to bind
|
\param state_change hook to bind
|
||||||
\return SWITCH_STATUS_SUCCESS on suceess
|
\return SWITCH_STATUS_SUCCESS on suceess
|
||||||
*/
|
*/
|
||||||
SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_state_change(switch_core_session_t *session, switch_answer_channel_hook_t state_change);
|
SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_state_change(switch_core_session_t *session, switch_state_change_hook_t state_change);
|
||||||
///\}
|
///\}
|
||||||
|
|
||||||
SWITCH_END_EXTERN_C
|
SWITCH_END_EXTERN_C
|
||||||
|
@ -81,8 +81,6 @@ struct switch_io_event_hooks;
|
|||||||
struct switch_io_routines {
|
struct switch_io_routines {
|
||||||
/*! creates an outgoing session from given session, caller profile */
|
/*! creates an outgoing session from given session, caller profile */
|
||||||
switch_call_cause_t (*outgoing_channel) (switch_core_session_t *, switch_caller_profile_t *, switch_core_session_t **, switch_memory_pool_t **);
|
switch_call_cause_t (*outgoing_channel) (switch_core_session_t *, switch_caller_profile_t *, switch_core_session_t **, switch_memory_pool_t **);
|
||||||
/*! answers the given session's channel */
|
|
||||||
switch_status_t (*answer_channel) (switch_core_session_t *);
|
|
||||||
/*! read a frame from a session */
|
/*! read a frame from a session */
|
||||||
switch_status_t (*read_frame) (switch_core_session_t *, switch_frame_t **, int, switch_io_flag_t, int);
|
switch_status_t (*read_frame) (switch_core_session_t *, switch_frame_t **, int, switch_io_flag_t, int);
|
||||||
/*! write a frame to a session */
|
/*! write a frame to a session */
|
||||||
|
@ -349,6 +349,7 @@ typedef enum {
|
|||||||
<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_ANSWER - indicate answer
|
||||||
SWITCH_MESSAGE_INDICATE_PROGRESS - indicate progress
|
SWITCH_MESSAGE_INDICATE_PROGRESS - indicate progress
|
||||||
SWITCH_MESSAGE_INDICATE_BRIDGE - indicate a bridge starting
|
SWITCH_MESSAGE_INDICATE_BRIDGE - indicate a bridge starting
|
||||||
SWITCH_MESSAGE_INDICATE_UNBRIDGE - indicate a bridge ending
|
SWITCH_MESSAGE_INDICATE_UNBRIDGE - indicate a bridge ending
|
||||||
@ -363,6 +364,7 @@ typedef enum {
|
|||||||
typedef enum {
|
typedef enum {
|
||||||
SWITCH_MESSAGE_REDIRECT_AUDIO,
|
SWITCH_MESSAGE_REDIRECT_AUDIO,
|
||||||
SWITCH_MESSAGE_TRANSMIT_TEXT,
|
SWITCH_MESSAGE_TRANSMIT_TEXT,
|
||||||
|
SWITCH_MESSAGE_INDICATE_ANSWER,
|
||||||
SWITCH_MESSAGE_INDICATE_PROGRESS,
|
SWITCH_MESSAGE_INDICATE_PROGRESS,
|
||||||
SWITCH_MESSAGE_INDICATE_BRIDGE,
|
SWITCH_MESSAGE_INDICATE_BRIDGE,
|
||||||
SWITCH_MESSAGE_INDICATE_UNBRIDGE,
|
SWITCH_MESSAGE_INDICATE_UNBRIDGE,
|
||||||
|
@ -1513,6 +1513,9 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
|
|||||||
assert(tech_pvt != NULL);
|
assert(tech_pvt != NULL);
|
||||||
|
|
||||||
switch (msg->message_id) {
|
switch (msg->message_id) {
|
||||||
|
case SWITCH_MESSAGE_INDICATE_ANSWER:
|
||||||
|
channel_answer_channel(session);
|
||||||
|
break;
|
||||||
case SWITCH_MESSAGE_INDICATE_BRIDGE:
|
case SWITCH_MESSAGE_INDICATE_BRIDGE:
|
||||||
if (tech_pvt->rtp_session && switch_test_flag(tech_pvt->profile, TFLAG_TIMER)) {
|
if (tech_pvt->rtp_session && switch_test_flag(tech_pvt->profile, TFLAG_TIMER)) {
|
||||||
switch_rtp_clear_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
|
switch_rtp_clear_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
|
||||||
@ -1571,7 +1574,6 @@ static const switch_state_handler_table_t channel_event_handlers = {
|
|||||||
|
|
||||||
static const switch_io_routines_t channel_io_routines = {
|
static const switch_io_routines_t channel_io_routines = {
|
||||||
/*.outgoing_channel */ channel_outgoing_channel,
|
/*.outgoing_channel */ channel_outgoing_channel,
|
||||||
/*.answer_channel */ channel_answer_channel,
|
|
||||||
/*.read_frame */ channel_read_frame,
|
/*.read_frame */ channel_read_frame,
|
||||||
/*.write_frame */ channel_write_frame,
|
/*.write_frame */ channel_write_frame,
|
||||||
/*.kill_channel */ channel_kill_channel,
|
/*.kill_channel */ channel_kill_channel,
|
||||||
|
@ -747,6 +747,29 @@ static switch_status_t channel_answer_channel(switch_core_session_t *session)
|
|||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static switch_status_t channel_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg)
|
||||||
|
{
|
||||||
|
switch_channel_t *channel;
|
||||||
|
private_t *tech_pvt;
|
||||||
|
|
||||||
|
channel = switch_core_session_get_channel(session);
|
||||||
|
assert(channel != NULL);
|
||||||
|
|
||||||
|
tech_pvt = (private_t *) switch_core_session_get_private(session);
|
||||||
|
assert(tech_pvt != NULL);
|
||||||
|
|
||||||
|
switch (msg->message_id) {
|
||||||
|
case SWITCH_MESSAGE_INDICATE_ANSWER:
|
||||||
|
channel_answer_channel(session);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
static const switch_state_handler_table_t channel_event_handlers = {
|
static const switch_state_handler_table_t channel_event_handlers = {
|
||||||
/*.on_init */ channel_on_init,
|
/*.on_init */ channel_on_init,
|
||||||
/*.on_ring */ channel_on_ring,
|
/*.on_ring */ channel_on_ring,
|
||||||
@ -758,13 +781,13 @@ static const switch_state_handler_table_t channel_event_handlers = {
|
|||||||
|
|
||||||
static const switch_io_routines_t channel_io_routines = {
|
static const switch_io_routines_t channel_io_routines = {
|
||||||
/*.outgoing_channel */ channel_outgoing_channel,
|
/*.outgoing_channel */ channel_outgoing_channel,
|
||||||
/*.answer_channel */ channel_answer_channel,
|
|
||||||
/*.read_frame */ channel_read_frame,
|
/*.read_frame */ channel_read_frame,
|
||||||
/*.write_frame */ channel_write_frame,
|
/*.write_frame */ channel_write_frame,
|
||||||
/*.kill_channel */ channel_kill_channel,
|
/*.kill_channel */ channel_kill_channel,
|
||||||
/*.waitfor_read */ channel_waitfor_read,
|
/*.waitfor_read */ channel_waitfor_read,
|
||||||
/*.waitfor_write */ channel_waitfor_write,
|
/*.waitfor_write */ channel_waitfor_write,
|
||||||
/*.send_dtmf */ channel_send_dtmf
|
/*.send_dtmf */ channel_send_dtmf,
|
||||||
|
/*.receive_message*/ channel_receive_message
|
||||||
};
|
};
|
||||||
|
|
||||||
static const switch_endpoint_interface_t channel_endpoint_interface = {
|
static const switch_endpoint_interface_t channel_endpoint_interface = {
|
||||||
|
@ -718,6 +718,9 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
|
|||||||
|
|
||||||
|
|
||||||
switch (msg->message_id) {
|
switch (msg->message_id) {
|
||||||
|
case SWITCH_MESSAGE_INDICATE_ANSWER:
|
||||||
|
channel_answer_channel(session);
|
||||||
|
break;
|
||||||
case SWITCH_MESSAGE_INDICATE_PROGRESS:
|
case SWITCH_MESSAGE_INDICATE_PROGRESS:
|
||||||
{
|
{
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Engage Early Media\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Engage Early Media\n");
|
||||||
@ -788,7 +791,6 @@ static const switch_state_handler_table_t channel_event_handlers = {
|
|||||||
|
|
||||||
static const switch_io_routines_t channel_io_routines = {
|
static const switch_io_routines_t channel_io_routines = {
|
||||||
/*.outgoing_channel */ channel_outgoing_channel,
|
/*.outgoing_channel */ channel_outgoing_channel,
|
||||||
/*.answer_channel */ channel_answer_channel,
|
|
||||||
/*.read_frame */ channel_read_frame,
|
/*.read_frame */ channel_read_frame,
|
||||||
/*.write_frame */ channel_write_frame,
|
/*.write_frame */ channel_write_frame,
|
||||||
/*.kill_channel */ channel_kill_channel,
|
/*.kill_channel */ channel_kill_channel,
|
||||||
|
@ -675,9 +675,14 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
|||||||
break;
|
break;
|
||||||
case SWITCH_MESSAGE_INDICATE_RINGING:
|
case SWITCH_MESSAGE_INDICATE_RINGING:
|
||||||
nua_respond(tech_pvt->nh, SIP_180_RINGING, SIPTAG_CONTACT_STR(tech_pvt->profile->url), TAG_END());
|
nua_respond(tech_pvt->nh, SIP_180_RINGING, SIPTAG_CONTACT_STR(tech_pvt->profile->url), TAG_END());
|
||||||
|
switch_channel_mark_ring_ready(channel);
|
||||||
|
break;
|
||||||
|
case SWITCH_MESSAGE_INDICATE_ANSWER:
|
||||||
|
sofia_answer_channel(session);
|
||||||
break;
|
break;
|
||||||
case SWITCH_MESSAGE_INDICATE_PROGRESS:{
|
case SWITCH_MESSAGE_INDICATE_PROGRESS:{
|
||||||
if (!switch_test_flag(tech_pvt, TFLAG_ANS)) {
|
if (!switch_test_flag(tech_pvt, TFLAG_ANS)) {
|
||||||
|
|
||||||
switch_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA);
|
switch_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA);
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Asked to send early media by %s\n", msg->from);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Asked to send early media by %s\n", msg->from);
|
||||||
|
|
||||||
@ -708,7 +713,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
|||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Ring SDP:\n%s\n", tech_pvt->local_sdp_str);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Ring SDP:\n%s\n", tech_pvt->local_sdp_str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
switch_channel_mark_pre_answered(channel);
|
||||||
nua_respond(tech_pvt->nh,
|
nua_respond(tech_pvt->nh,
|
||||||
SIP_183_SESSION_PROGRESS,
|
SIP_183_SESSION_PROGRESS,
|
||||||
SIPTAG_CONTACT_STR(tech_pvt->profile->url),
|
SIPTAG_CONTACT_STR(tech_pvt->profile->url),
|
||||||
@ -754,7 +759,6 @@ static switch_status_t sofia_receive_event(switch_core_session_t *session, switc
|
|||||||
|
|
||||||
static const switch_io_routines_t sofia_io_routines = {
|
static const switch_io_routines_t sofia_io_routines = {
|
||||||
/*.outgoing_channel */ sofia_outgoing_channel,
|
/*.outgoing_channel */ sofia_outgoing_channel,
|
||||||
/*.answer_channel */ sofia_answer_channel,
|
|
||||||
/*.read_frame */ sofia_read_frame,
|
/*.read_frame */ sofia_read_frame,
|
||||||
/*.write_frame */ sofia_write_frame,
|
/*.write_frame */ sofia_write_frame,
|
||||||
/*.kill_channel */ sofia_kill_channel,
|
/*.kill_channel */ sofia_kill_channel,
|
||||||
|
@ -930,6 +930,9 @@ static switch_status_t wanpipe_receive_message(switch_core_session_t *session, s
|
|||||||
break;
|
break;
|
||||||
case SWITCH_MESSAGE_INDICATE_REDIRECT:
|
case SWITCH_MESSAGE_INDICATE_REDIRECT:
|
||||||
break;
|
break;
|
||||||
|
case SWITCH_MESSAGE_INDICATE_ANSWER:
|
||||||
|
wanpipe_answer_channel(session);
|
||||||
|
break;
|
||||||
case SWITCH_MESSAGE_INDICATE_PROGRESS:
|
case SWITCH_MESSAGE_INDICATE_PROGRESS:
|
||||||
break;
|
break;
|
||||||
case SWITCH_MESSAGE_INDICATE_RINGING:
|
case SWITCH_MESSAGE_INDICATE_RINGING:
|
||||||
@ -969,7 +972,6 @@ static switch_status_t wanpipe_kill_channel(switch_core_session_t *session, int
|
|||||||
|
|
||||||
static const switch_io_routines_t wanpipe_io_routines = {
|
static const switch_io_routines_t wanpipe_io_routines = {
|
||||||
/*.outgoing_channel */ wanpipe_outgoing_channel,
|
/*.outgoing_channel */ wanpipe_outgoing_channel,
|
||||||
/*.answer_channel */ wanpipe_answer_channel,
|
|
||||||
/*.read_frame */ wanpipe_read_frame,
|
/*.read_frame */ wanpipe_read_frame,
|
||||||
/*.write_frame */ wanpipe_write_frame,
|
/*.write_frame */ wanpipe_write_frame,
|
||||||
/*.kill_channel */ wanpipe_kill_channel,
|
/*.kill_channel */ wanpipe_kill_channel,
|
||||||
@ -1422,16 +1424,8 @@ static int on_proceed(struct sangoma_pri *spri, sangoma_pri_event_t event_type,
|
|||||||
channel = switch_core_session_get_channel(session);
|
channel = switch_core_session_get_channel(session);
|
||||||
assert(channel != NULL);
|
assert(channel != NULL);
|
||||||
|
|
||||||
if ((msg = malloc(sizeof(*msg)))) {
|
switch_core_session_pass_indication(session, SWITCH_MESSAGE_INDICATE_PROGRESS);
|
||||||
memset(msg, 0, sizeof(*msg));
|
|
||||||
msg->message_id = SWITCH_MESSAGE_INDICATE_PROGRESS;
|
|
||||||
msg->from = __FILE__;
|
|
||||||
switch_core_session_queue_message(session, msg);
|
|
||||||
switch_set_flag(msg, SCSMF_DYNAMIC);
|
|
||||||
switch_channel_mark_pre_answered(channel);
|
switch_channel_mark_pre_answered(channel);
|
||||||
} else {
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
switch_core_session_rwunlock(session);
|
switch_core_session_rwunlock(session);
|
||||||
} else {
|
} else {
|
||||||
@ -1457,7 +1451,7 @@ static int on_ringing(struct sangoma_pri *spri, sangoma_pri_event_t event_type,
|
|||||||
channel = switch_core_session_get_channel(session);
|
channel = switch_core_session_get_channel(session);
|
||||||
assert(channel != NULL);
|
assert(channel != NULL);
|
||||||
|
|
||||||
switch_core_session_queue_indication(session, SWITCH_MESSAGE_INDICATE_RINGING);
|
switch_core_session_pass_indication(session, SWITCH_MESSAGE_INDICATE_RINGING);
|
||||||
switch_channel_mark_ring_ready(channel);
|
switch_channel_mark_ring_ready(channel);
|
||||||
|
|
||||||
switch_core_session_rwunlock(session);
|
switch_core_session_rwunlock(session);
|
||||||
|
@ -447,7 +447,6 @@ static const switch_state_handler_table_t woomera_event_handlers = {
|
|||||||
|
|
||||||
static const switch_io_routines_t woomera_io_routines = {
|
static const switch_io_routines_t woomera_io_routines = {
|
||||||
/*.outgoing_channel */ woomera_outgoing_channel,
|
/*.outgoing_channel */ woomera_outgoing_channel,
|
||||||
/*.answer_channel */ NULL,
|
|
||||||
/*.read_frame */ woomera_read_frame,
|
/*.read_frame */ woomera_read_frame,
|
||||||
/*.write_frame */ woomera_write_frame,
|
/*.write_frame */ woomera_write_frame,
|
||||||
/*.kill_channel */ woomera_kill_channel,
|
/*.kill_channel */ woomera_kill_channel,
|
||||||
|
@ -1080,7 +1080,6 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_pre_answered(switch_
|
|||||||
SWITCH_DECLARE(switch_status_t) switch_channel_perform_pre_answer(switch_channel_t *channel, const char *file, const char *func, int line)
|
SWITCH_DECLARE(switch_status_t) switch_channel_perform_pre_answer(switch_channel_t *channel, const char *file, const char *func, int line)
|
||||||
{
|
{
|
||||||
switch_core_session_message_t msg;
|
switch_core_session_message_t msg;
|
||||||
char *uuid = switch_core_session_get_uuid(channel->session);
|
|
||||||
switch_status_t status;
|
switch_status_t status;
|
||||||
|
|
||||||
assert(channel != NULL);
|
assert(channel != NULL);
|
||||||
@ -1099,7 +1098,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_pre_answer(switch_channel
|
|||||||
|
|
||||||
msg.message_id = SWITCH_MESSAGE_INDICATE_PROGRESS;
|
msg.message_id = SWITCH_MESSAGE_INDICATE_PROGRESS;
|
||||||
msg.from = channel->name;
|
msg.from = channel->name;
|
||||||
status = switch_core_session_message_send(uuid, &msg);
|
status = switch_core_session_receive_message(channel->session, &msg);
|
||||||
|
|
||||||
if (status == SWITCH_STATUS_SUCCESS) {
|
if (status == SWITCH_STATUS_SUCCESS) {
|
||||||
status = switch_channel_perform_mark_pre_answered(channel, file, func, line);
|
status = switch_channel_perform_mark_pre_answered(channel, file, func, line);
|
||||||
@ -1111,7 +1110,6 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_pre_answer(switch_channel
|
|||||||
SWITCH_DECLARE(switch_status_t) switch_channel_perform_ring_ready(switch_channel_t *channel, const char *file, const char *func, int line)
|
SWITCH_DECLARE(switch_status_t) switch_channel_perform_ring_ready(switch_channel_t *channel, const char *file, const char *func, int line)
|
||||||
{
|
{
|
||||||
switch_core_session_message_t msg;
|
switch_core_session_message_t msg;
|
||||||
char *uuid = switch_core_session_get_uuid(channel->session);
|
|
||||||
switch_status_t status;
|
switch_status_t status;
|
||||||
|
|
||||||
assert(channel != NULL);
|
assert(channel != NULL);
|
||||||
@ -1130,7 +1128,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_ring_ready(switch_channel
|
|||||||
|
|
||||||
msg.message_id = SWITCH_MESSAGE_INDICATE_RINGING;
|
msg.message_id = SWITCH_MESSAGE_INDICATE_RINGING;
|
||||||
msg.from = channel->name;
|
msg.from = channel->name;
|
||||||
status = switch_core_session_message_send(uuid, &msg);
|
status = switch_core_session_receive_message(channel->session, &msg);
|
||||||
|
|
||||||
if (status == SWITCH_STATUS_SUCCESS) {
|
if (status == SWITCH_STATUS_SUCCESS) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_NOTICE, "Ring Ready %s!\n", channel->name);
|
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_NOTICE, "Ring Ready %s!\n", channel->name);
|
||||||
@ -1185,6 +1183,9 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_answered(switch_chan
|
|||||||
|
|
||||||
SWITCH_DECLARE(switch_status_t) switch_channel_perform_answer(switch_channel_t *channel, const char *file, const char *func, int line)
|
SWITCH_DECLARE(switch_status_t) switch_channel_perform_answer(switch_channel_t *channel, const char *file, const char *func, int line)
|
||||||
{
|
{
|
||||||
|
switch_core_session_message_t msg;
|
||||||
|
switch_status_t status;
|
||||||
|
|
||||||
assert(channel != NULL);
|
assert(channel != NULL);
|
||||||
|
|
||||||
if (channel->hangup_cause || channel->state >= CS_HANGUP) {
|
if (channel->hangup_cause || channel->state >= CS_HANGUP) {
|
||||||
@ -1195,7 +1196,12 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_answer(switch_channel_t *
|
|||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (switch_core_session_answer_channel(channel->session) == SWITCH_STATUS_SUCCESS) {
|
|
||||||
|
msg.message_id = SWITCH_MESSAGE_INDICATE_ANSWER;
|
||||||
|
msg.from = channel->name;
|
||||||
|
status = switch_core_session_receive_message(channel->session, &msg);
|
||||||
|
|
||||||
|
if (status == SWITCH_STATUS_SUCCESS) {
|
||||||
return switch_channel_perform_mark_answered(channel, file, func, line);
|
return switch_channel_perform_mark_answered(channel, file, func, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,29 +52,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_outgoing(switch_core_
|
|||||||
return SWITCH_STATUS_MEMERR;
|
return SWITCH_STATUS_MEMERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_answer_channel(switch_core_session_t *session, switch_answer_channel_hook_t answer_channel)
|
SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_state_change(switch_core_session_t *session, switch_state_change_hook_t state_change)
|
||||||
{
|
|
||||||
switch_io_event_hook_answer_channel_t *hook, *ptr;
|
|
||||||
|
|
||||||
assert(answer_channel != NULL);
|
|
||||||
if ((hook = switch_core_session_alloc(session, sizeof(*hook))) != 0) {
|
|
||||||
hook->answer_channel = answer_channel;
|
|
||||||
if (!session->event_hooks.answer_channel) {
|
|
||||||
session->event_hooks.answer_channel = hook;
|
|
||||||
} else {
|
|
||||||
for (ptr = session->event_hooks.answer_channel; ptr && ptr->next; ptr = ptr->next);
|
|
||||||
ptr->next = hook;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
return SWITCH_STATUS_MEMERR;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_state_change(switch_core_session_t *session, switch_answer_channel_hook_t state_change)
|
|
||||||
{
|
{
|
||||||
switch_io_event_hook_state_change_t *hook, *ptr;
|
switch_io_event_hook_state_change_t *hook, *ptr;
|
||||||
|
|
||||||
|
@ -320,29 +320,6 @@ SWITCH_DECLARE(switch_call_cause_t) switch_core_session_outgoing_channel(switch_
|
|||||||
return cause;
|
return cause;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(switch_status_t) switch_core_session_answer_channel(switch_core_session_t *session)
|
|
||||||
{
|
|
||||||
switch_io_event_hook_answer_channel_t *ptr;
|
|
||||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
|
||||||
|
|
||||||
assert(session != NULL);
|
|
||||||
|
|
||||||
if (session->endpoint_interface->io_routines->answer_channel) {
|
|
||||||
status = session->endpoint_interface->io_routines->answer_channel(session);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status == SWITCH_STATUS_SUCCESS) {
|
|
||||||
for (ptr = session->event_hooks.answer_channel; ptr; ptr = ptr->next) {
|
|
||||||
if ((status = ptr->answer_channel(session)) != SWITCH_STATUS_SUCCESS) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
SWITCH_DECLARE(switch_status_t) switch_core_session_receive_message(switch_core_session_t *session, switch_core_session_message_t *message)
|
SWITCH_DECLARE(switch_status_t) switch_core_session_receive_message(switch_core_session_t *session, switch_core_session_message_t *message)
|
||||||
{
|
{
|
||||||
switch_io_event_hook_receive_message_t *ptr;
|
switch_io_event_hook_receive_message_t *ptr;
|
||||||
@ -367,6 +344,31 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_receive_message(switch_core_
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SWITCH_DECLARE(switch_status_t) switch_core_session_pass_indication(switch_core_session_t *session, switch_core_session_message_types_t indication)
|
||||||
|
{
|
||||||
|
switch_core_session_message_t msg = {0};
|
||||||
|
switch_core_session_t *other_session;
|
||||||
|
char *uuid;
|
||||||
|
switch_channel_t *channel;
|
||||||
|
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||||
|
|
||||||
|
assert(session != NULL);
|
||||||
|
|
||||||
|
channel = switch_core_session_get_channel(session);
|
||||||
|
assert(channel != NULL);
|
||||||
|
|
||||||
|
if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) {
|
||||||
|
msg.message_id = indication;
|
||||||
|
msg.from = __FILE__;
|
||||||
|
status = switch_core_session_receive_message(other_session, &msg);
|
||||||
|
switch_core_session_rwunlock(other_session);
|
||||||
|
} else {
|
||||||
|
status = SWITCH_STATUS_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(switch_status_t) switch_core_session_queue_indication(switch_core_session_t *session, switch_core_session_message_types_t indication)
|
SWITCH_DECLARE(switch_status_t) switch_core_session_queue_indication(switch_core_session_t *session, switch_core_session_message_types_t indication)
|
||||||
{
|
{
|
||||||
switch_core_session_message_t *msg;
|
switch_core_session_message_t *msg;
|
||||||
@ -375,8 +377,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_queue_indication(switch_core
|
|||||||
memset(msg, 0, sizeof(*msg));
|
memset(msg, 0, sizeof(*msg));
|
||||||
msg->message_id = indication;
|
msg->message_id = indication;
|
||||||
msg->from = __FILE__;
|
msg->from = __FILE__;
|
||||||
switch_core_session_queue_message(session, msg);
|
|
||||||
switch_set_flag(msg, SCSMF_DYNAMIC);
|
switch_set_flag(msg, SCSMF_DYNAMIC);
|
||||||
|
switch_core_session_queue_message(session, msg);
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user