*/
SWITCH_DECLARE(unsigned int) switch_channel_ready(switch_channel *channel);
+
+SWITCH_DECLARE(switch_channel_state) switch_channel_perform_set_state(switch_channel *channel,
+ const char *file,
+ const char *func,
+ int line,
+ switch_channel_state state);
+
/*!
\brief Set the current state of a channel
\param channel channel to set state of
\param state new state
\return current state of channel after application of new state
*/
-SWITCH_DECLARE(switch_channel_state) switch_channel_set_state(switch_channel *channel, switch_channel_state state);
+#define switch_channel_set_state(channel, state) switch_channel_perform_set_state(channel, __FILE__, __FUNCTION__, __LINE__, state)
/*!
\brief return a cause code for a given string
*/
SWITCH_DECLARE(void) switch_channel_clear_flag(switch_channel *channel, switch_channel_flag flags);
+SWITCH_DECLARE(switch_status) switch_channel_perform_answer(switch_channel *channel,
+ const char *file,
+ const char *func,
+ int line);
/*!
\brief Answer a channel (initiate/acknowledge a successful connection)
\param channel channel to answer
\return SWITCH_STATUS_SUCCESS if channel was answered successfully
*/
-SWITCH_DECLARE(switch_status) switch_channel_answer(switch_channel *channel);
+#define switch_channel_answer(channel) switch_channel_perform_answer(channel, __FILE__, __FUNCTION__, __LINE__)
+
+
+SWITCH_DECLARE(switch_status) switch_channel_perform_pre_answer(switch_channel *channel,
+ const char *file,
+ const char *func,
+ int line);
/*!
\brief Indicate progress on a channel to attempt early media
\param channel channel to pre-answer
\return SWITCH_STATUS_SUCCESS
-*/
-SWITCH_DECLARE(switch_status) switch_channel_pre_answer(switch_channel *channel);
+*/
+#define switch_channel_pre_answer(channel) switch_channel_perform_pre_answer(channel, __FILE__, __FUNCTION__, __LINE__)
/*!
\brief add a state handler table to a given channel
*/
SWITCH_DECLARE(char *) switch_channel_get_name(switch_channel *channel);
+
+SWITCH_DECLARE(switch_channel_state) switch_channel_perform_hangup(switch_channel *channel,
+ const char *file,
+ const char *func,
+ int line,
+ switch_call_cause_t hangup_cause);
+
/*!
\brief Hangup a channel flagging it's state machine to end
\param channel channel to hangup
\param hangup_cause the appropriate hangup cause
\return the resulting channel state.
*/
-SWITCH_DECLARE(switch_channel_state) switch_channel_hangup(switch_channel *channel, switch_call_cause_t hangup_cause);
-
+#define switch_channel_hangup(channel, hangup_cause) switch_channel_perform_hangup(channel, __FILE__, __FUNCTION__, __LINE__, hangup_cause)
/*!
\brief Test for presence of DTMF on a given channel
{ "MANDATORY_IE_LENGTH_ERROR", SWITCH_CAUSE_MANDATORY_IE_LENGTH_ERROR },
{ "PROTOCOL_ERROR", SWITCH_CAUSE_PROTOCOL_ERROR },
{ "INTERWORKING", SWITCH_CAUSE_INTERWORKING },
+ { "CRASH", SWITCH_CAUSE_CRASH },
{ NULL, 0 }
};
return state_names[state];
}
-SWITCH_DECLARE(switch_channel_state) switch_channel_set_state(switch_channel *channel, switch_channel_state state)
+SWITCH_DECLARE(switch_channel_state) switch_channel_perform_set_state(switch_channel *channel,
+ const char *file,
+ const char *func,
+ int line,
+ switch_channel_state state)
{
switch_channel_state last_state;
int ok = 0;
if (ok) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s State Change %s -> %s\n", channel->name,
- state_names[last_state], state_names[state]);
+ switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_DEBUG, "%s State Change %s -> %s\n",
+ channel->name,
+ state_names[last_state],
+ state_names[state]);
channel->state = state;
if (state == CS_HANGUP && channel->hangup_cause == SWITCH_CAUSE_UNALLOCATED) {
switch_core_session_signal_state_change(channel->session);
}
} else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s Invalid State Change %s -> %s\n", channel->name,
- state_names[last_state], state_names[state]);
+ switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_WARNING, "%s Invalid State Change %s -> %s\n",
+ channel->name,
+ state_names[last_state],
+ state_names[state]);
//we won't tolerate an invalid state change so we can make sure we are as robust as a nice cup of dark coffee!
if (channel->state < CS_HANGUP) {
}
-SWITCH_DECLARE(switch_channel_state) switch_channel_hangup(switch_channel *channel, switch_call_cause_t hangup_cause)
+SWITCH_DECLARE(switch_channel_state) switch_channel_perform_hangup(switch_channel *channel,
+ const char *file,
+ const char *func,
+ int line,
+ switch_call_cause_t hangup_cause)
{
assert(channel != NULL);
channel->state = CS_HANGUP;
channel->hangup_cause = hangup_cause;
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hangup %s [%s] [%s]\n", channel->name,
+ switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_NOTICE, "Hangup %s [%s] [%s]\n",
+ channel->name,
state_names[last_state], switch_channel_cause2str(channel->hangup_cause));
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_STATE) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(channel, event);
return channel->state;
}
-SWITCH_DECLARE(switch_status) switch_channel_pre_answer(switch_channel *channel)
+SWITCH_DECLARE(switch_status) switch_channel_perform_pre_answer(switch_channel *channel,
+ const char *file,
+ const char *func,
+ int line)
{
switch_core_session_message msg;
char *uuid = switch_core_session_get_uuid(channel->session);
status = switch_core_session_message_send(uuid, &msg);
if (status == SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Pre-Answer %s!\n", channel->name);
+ switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_NOTICE, "Pre-Answer %s!\n", channel->name);
switch_channel_set_flag(channel, CF_EARLY_MEDIA);
}
return status;
}
-SWITCH_DECLARE(switch_status) switch_channel_answer(switch_channel *channel)
+SWITCH_DECLARE(switch_status) switch_channel_perform_answer(switch_channel *channel,
+ const char *file,
+ const char *func,
+ int line)
{
assert(channel != NULL);
channel->times.answered = switch_time_now();
switch_channel_set_flag(channel, CF_ANSWERED);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Answer %s!\n", channel->name);
+ switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_NOTICE, "Answer %s!\n", channel->name);
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_ANSWER) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(channel, event);
switch_event_fire(&event);
return status;
}
-SWITCH_DECLARE(switch_status) switch_core_session_kill_channel(switch_core_session *session, switch_signal sig)
+SWITCH_DECLARE(switch_status) switch_core_session_perform_kill_channel(switch_core_session *session,
+ const char *file,
+ const char *func,
+ int line,
+ switch_signal sig)
{
struct switch_io_event_hook_kill_channel *ptr;
switch_status status = SWITCH_STATUS_FALSE;
+
+ switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_NOTICE, "Kill %s [%d]\n", switch_channel_get_name(session->channel), sig);
if (session->endpoint_interface->io_routines->kill_channel) {
if ((status = session->endpoint_interface->io_routines->kill_channel(session, sig)) == SWITCH_STATUS_SUCCESS) {
const switch_state_handler_table *driver_state_handler = NULL;
const switch_state_handler_table *application_state_handler = NULL;
+
/*
Life of the channel. you have channel and pool in your session
everywhere you go you use the session to malloc with