*/
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
\param session the session to queue the message to
switch_caller_profile_t *caller_profile,
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
\param session the session to receive the message from
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_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_event switch_io_event_hook_receive_event_t;
typedef struct switch_io_event_hook_read_frame switch_io_event_hook_read_frame_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_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);
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 */
struct switch_io_event_hook_receive_message {
- /*! the answer channel callback hook */
+ /*! the message callback hook */
switch_receive_message_hook_t receive_message;
struct switch_io_event_hook_receive_message *next;
};
/*! \brief Node in which to store custom receive message callback hooks */
struct switch_io_event_hook_receive_event {
- /*! the answer channel callback hook */
+ /*! the event callback hook */
switch_receive_event_hook_t receive_event;
struct switch_io_event_hook_receive_event *next;
};
struct switch_io_event_hooks {
/*! a list of outgoing channel hooks */
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 */
switch_io_event_hook_receive_message_t *receive_message;
/*! a list of queue message hooks */
SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_outgoing_channel(switch_core_session_t *session,
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
\param session session to bind hook to
\param state_change hook to bind
\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
struct switch_io_routines {
/*! 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 **);
- /*! answers the given session's channel */
- switch_status_t (*answer_channel) (switch_core_session_t *);
/*! read a frame from a session */
switch_status_t (*read_frame) (switch_core_session_t *, switch_frame_t **, int, switch_io_flag_t, int);
/*! write a frame to a session */
<pre>
SWITCH_MESSAGE_REDIRECT_AUDIO - Indication to redirect audio to another location if possible
SWITCH_MESSAGE_TRANSMIT_TEXT - A text message
+ SWITCH_MESSAGE_INDICATE_ANSWER - indicate answer
SWITCH_MESSAGE_INDICATE_PROGRESS - indicate progress
SWITCH_MESSAGE_INDICATE_BRIDGE - indicate a bridge starting
SWITCH_MESSAGE_INDICATE_UNBRIDGE - indicate a bridge ending
typedef enum {
SWITCH_MESSAGE_REDIRECT_AUDIO,
SWITCH_MESSAGE_TRANSMIT_TEXT,
+ SWITCH_MESSAGE_INDICATE_ANSWER,
SWITCH_MESSAGE_INDICATE_PROGRESS,
SWITCH_MESSAGE_INDICATE_BRIDGE,
SWITCH_MESSAGE_INDICATE_UNBRIDGE,
assert(tech_pvt != NULL);
switch (msg->message_id) {
+ case SWITCH_MESSAGE_INDICATE_ANSWER:
+ channel_answer_channel(session);
+ break;
case SWITCH_MESSAGE_INDICATE_BRIDGE:
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);
static const switch_io_routines_t channel_io_routines = {
/*.outgoing_channel */ channel_outgoing_channel,
- /*.answer_channel */ channel_answer_channel,
/*.read_frame */ channel_read_frame,
/*.write_frame */ channel_write_frame,
/*.kill_channel */ channel_kill_channel,
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 = {
/*.on_init */ channel_on_init,
/*.on_ring */ channel_on_ring,
static const switch_io_routines_t channel_io_routines = {
/*.outgoing_channel */ channel_outgoing_channel,
- /*.answer_channel */ channel_answer_channel,
/*.read_frame */ channel_read_frame,
/*.write_frame */ channel_write_frame,
/*.kill_channel */ channel_kill_channel,
/*.waitfor_read */ channel_waitfor_read,
/*.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 = {
switch (msg->message_id) {
+ case SWITCH_MESSAGE_INDICATE_ANSWER:
+ channel_answer_channel(session);
+ break;
case SWITCH_MESSAGE_INDICATE_PROGRESS:
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Engage Early Media\n");
static const switch_io_routines_t channel_io_routines = {
/*.outgoing_channel */ channel_outgoing_channel,
- /*.answer_channel */ channel_answer_channel,
/*.read_frame */ channel_read_frame,
/*.write_frame */ channel_write_frame,
/*.kill_channel */ channel_kill_channel,
break;
case SWITCH_MESSAGE_INDICATE_RINGING:
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;
case SWITCH_MESSAGE_INDICATE_PROGRESS:{
if (!switch_test_flag(tech_pvt, TFLAG_ANS)) {
+
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, "Ring SDP:\n%s\n", tech_pvt->local_sdp_str);
}
}
-
+ switch_channel_mark_pre_answered(channel);
nua_respond(tech_pvt->nh,
SIP_183_SESSION_PROGRESS,
SIPTAG_CONTACT_STR(tech_pvt->profile->url),
static const switch_io_routines_t sofia_io_routines = {
/*.outgoing_channel */ sofia_outgoing_channel,
- /*.answer_channel */ sofia_answer_channel,
/*.read_frame */ sofia_read_frame,
/*.write_frame */ sofia_write_frame,
/*.kill_channel */ sofia_kill_channel,
break;
case SWITCH_MESSAGE_INDICATE_REDIRECT:
break;
+ case SWITCH_MESSAGE_INDICATE_ANSWER:
+ wanpipe_answer_channel(session);
+ break;
case SWITCH_MESSAGE_INDICATE_PROGRESS:
break;
case SWITCH_MESSAGE_INDICATE_RINGING:
static const switch_io_routines_t wanpipe_io_routines = {
/*.outgoing_channel */ wanpipe_outgoing_channel,
- /*.answer_channel */ wanpipe_answer_channel,
/*.read_frame */ wanpipe_read_frame,
/*.write_frame */ wanpipe_write_frame,
/*.kill_channel */ wanpipe_kill_channel,
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
- if ((msg = malloc(sizeof(*msg)))) {
- 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);
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
- }
+ switch_core_session_pass_indication(session, SWITCH_MESSAGE_INDICATE_PROGRESS);
+ switch_channel_mark_pre_answered(channel);
switch_core_session_rwunlock(session);
} else {
channel = switch_core_session_get_channel(session);
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_core_session_rwunlock(session);
static const switch_io_routines_t woomera_io_routines = {
/*.outgoing_channel */ woomera_outgoing_channel,
- /*.answer_channel */ NULL,
/*.read_frame */ woomera_read_frame,
/*.write_frame */ woomera_write_frame,
/*.kill_channel */ woomera_kill_channel,
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;
- char *uuid = switch_core_session_get_uuid(channel->session);
switch_status_t status;
assert(channel != NULL);
msg.message_id = SWITCH_MESSAGE_INDICATE_PROGRESS;
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) {
status = switch_channel_perform_mark_pre_answered(channel, file, func, 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;
- char *uuid = switch_core_session_get_uuid(channel->session);
switch_status_t status;
assert(channel != NULL);
msg.message_id = SWITCH_MESSAGE_INDICATE_RINGING;
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) {
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_NOTICE, "Ring Ready %s!\n", channel->name);
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);
if (channel->hangup_cause || channel->state >= CS_HANGUP) {
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_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_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_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_state_change_t *hook, *ptr;
return cause;
}
-SWITCH_DECLARE(switch_status_t) switch_core_session_answer_channel(switch_core_session_t *session)
+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_answer_channel_t *ptr;
+ switch_io_event_hook_receive_message_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 (session->endpoint_interface->io_routines->receive_message) {
+ status = session->endpoint_interface->io_routines->receive_message(session, message);
+
}
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) {
+ for (ptr = session->event_hooks.receive_message; ptr; ptr = ptr->next) {
+ if ((status = ptr->receive_message(session, message)) != SWITCH_STATUS_SUCCESS) {
break;
}
}
}
-
+ switch_core_session_kill_channel(session, SWITCH_SIG_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_pass_indication(switch_core_session_t *session, switch_core_session_message_types_t indication)
{
- switch_io_event_hook_receive_message_t *ptr;
+ 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 (session->endpoint_interface->io_routines->receive_message) {
- status = session->endpoint_interface->io_routines->receive_message(session, message);
-
- }
-
- if (status == SWITCH_STATUS_SUCCESS) {
- for (ptr = session->event_hooks.receive_message; ptr; ptr = ptr->next) {
- if ((status = ptr->receive_message(session, message)) != SWITCH_STATUS_SUCCESS) {
- break;
- }
- }
+ 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;
}
- switch_core_session_kill_channel(session, SWITCH_SIG_BREAK);
return status;
}
memset(msg, 0, sizeof(*msg));
msg->message_id = indication;
msg->from = __FILE__;
- switch_core_session_queue_message(session, msg);
switch_set_flag(msg, SCSMF_DYNAMIC);
+ switch_core_session_queue_message(session, msg);
return SWITCH_STATUS_SUCCESS;
}