\param str the string to check
\return the code
*/
-SWITCH_DECLARE(switch_call_cause_t) switch_channel_str2cause(const char *str);
+SWITCH_DECLARE(switch_call_cause_t) switch_channel_str2cause(_In_ const char *str);
/*!
\brief return the cause code for a given channel
\param channel the channel
\return the code
*/
-SWITCH_DECLARE(switch_call_cause_t) switch_channel_get_cause(switch_channel_t *channel);
+SWITCH_DECLARE(switch_call_cause_t) switch_channel_get_cause(_In_ switch_channel_t *channel);
/*!
\brief return a cause string for a given cause
\param cause the code to check
\return the string
*/
-SWITCH_DECLARE(const char *) switch_channel_cause2str(switch_call_cause_t cause);
+SWITCH_DECLARE(const char *) switch_channel_cause2str(_In_ switch_call_cause_t cause);
/*!
\brief View the timetable of a channel
\param channel channel to retrieve timetable from
\return a pointer to the channel's timetable (created, answered, etc..)
*/
-SWITCH_DECLARE(switch_channel_timetable_t *) switch_channel_get_timetable(switch_channel_t *channel);
+SWITCH_DECLARE(switch_channel_timetable_t *) switch_channel_get_timetable(_In_ switch_channel_t *channel);
/*!
\brief Allocate a new channel
\param pool memory_pool to use for allocation
\return SWITCH_STATUS_SUCCESS if successful
*/
-SWITCH_DECLARE(switch_status_t) switch_channel_alloc(switch_channel_t **channel, switch_memory_pool_t *pool);
+SWITCH_DECLARE(switch_status_t) switch_channel_alloc(_In_ switch_channel_t **channel, _In_ switch_memory_pool_t *pool);
/*!
\brief Connect a newly allocated channel to a session object and setup it's initial state
\param channel channel to test
\return number of digits in the queue
*/
-SWITCH_DECLARE(switch_size_t) switch_channel_has_dtmf(switch_channel_t *channel);
+SWITCH_DECLARE(switch_size_t) switch_channel_has_dtmf(_In_ switch_channel_t *channel);
/*!
\brief Queue DTMF on a given channel
\param dtmf digit
\return SWITCH_STATUS_SUCCESS if successful
*/
-SWITCH_DECLARE(switch_status_t) switch_channel_queue_dtmf(switch_channel_t *channel, const switch_dtmf_t *dtmf);
-SWITCH_DECLARE(switch_status_t) switch_channel_queue_dtmf_string(switch_channel_t *channel, const char *dtmf_string);
+SWITCH_DECLARE(switch_status_t) switch_channel_queue_dtmf(_In_ switch_channel_t *channel, _In_ const switch_dtmf_t *dtmf);
+SWITCH_DECLARE(switch_status_t) switch_channel_queue_dtmf_string(_In_ switch_channel_t *channel, _In_ const char *dtmf_string);
/*!
\brief Retrieve DTMF digits from a given channel
\param dtmf digit
\return number of bytes read into the buffer
*/
-SWITCH_DECLARE(switch_status_t) switch_channel_dequeue_dtmf(switch_channel_t *channel, switch_dtmf_t *dtmf);
-SWITCH_DECLARE(void) switch_channel_flush_dtmf(switch_channel_t *channel);
-SWITCH_DECLARE(switch_size_t) switch_channel_dequeue_dtmf_string(switch_channel_t *channel, char *dtmf_str, switch_size_t len);
+SWITCH_DECLARE(switch_status_t) switch_channel_dequeue_dtmf(_In_ switch_channel_t *channel, _In_ switch_dtmf_t *dtmf);
+SWITCH_DECLARE(void) switch_channel_flush_dtmf(_In_ switch_channel_t *channel);
+SWITCH_DECLARE(switch_size_t) switch_channel_dequeue_dtmf_string(_In_ switch_channel_t *channel, _Out_opt_bytecapcount_(len) char *dtmf_str, _In_ switch_size_t len);
/*!
\brief Render the name of the provided state enum
\param state state to get name of
\return the string representation of the state
*/
-SWITCH_DECLARE(const char *) switch_channel_state_name(switch_channel_state_t state);
+SWITCH_DECLARE(const char *) switch_channel_state_name(_In_ switch_channel_state_t state);
/*!
\brief Render the enum of the provided state name
\param name the name of the state
\return the enum value (numeric)
*/
-SWITCH_DECLARE(switch_channel_state_t) switch_channel_name_state(const char *name);
+SWITCH_DECLARE(switch_channel_state_t) switch_channel_name_state(_In_ const char *name);
/*!
\brief Add information about a given channel to an event object
\param channel channel to add information about
\param event event to add information to
*/
-SWITCH_DECLARE(void) switch_channel_event_set_data(switch_channel_t *channel, switch_event_t *event);
+SWITCH_DECLARE(void) switch_channel_event_set_data(_In_ switch_channel_t *channel, _In_ switch_event_t *event);
/*!
\brief Expand varaibles in a string based on the variables in a paticular channel
\return the original string if no expansion takes place otherwise a new string that must be freed
\note it's necessary to test if the return val is the same as the input and free the string if it is not.
*/
-SWITCH_DECLARE(char *) switch_channel_expand_variables(switch_channel_t *channel, const char *in);
-SWITCH_DECLARE(char *) switch_channel_build_param_string(switch_channel_t *channel, switch_caller_profile_t *caller_profile, const char *prefix);
-SWITCH_DECLARE(switch_status_t) switch_channel_set_timestamps(switch_channel_t *channel);
+SWITCH_DECLARE(char *) switch_channel_expand_variables(_In_ switch_channel_t *channel, _In_ const char *in);
+SWITCH_DECLARE(char *) switch_channel_build_param_string(_In_ switch_channel_t *channel, _In_opt_ switch_caller_profile_t *caller_profile, _In_opt_ const char *prefix);
+SWITCH_DECLARE(switch_status_t) switch_channel_set_timestamps(_In_ switch_channel_t *channel);
#define switch_channel_stop_broadcast(_channel) if (switch_channel_test_flag(_channel, CF_BROADCAST)) switch_channel_set_flag(_channel, CF_BREAK | CF_STOP_BROADCAST)
\return a void pointer to the newly allocated memory
\note the memory will be in scope as long as the session exists
*/
-SWITCH_DECLARE(void *) switch_core_session_alloc(_In_ switch_core_session_t *session, _In_ switch_size_t memory);
+_Ret_ SWITCH_DECLARE(void *) switch_core_session_alloc(_In_ switch_core_session_t *session, _In_ switch_size_t memory);
/*!
\brief Copy a string using permanent memory allocation
\param session the session to retrieve from
\return a pointer to the channel object
*/
-SWITCH_DECLARE(switch_channel_t *) switch_core_session_get_channel(_In_ switch_core_session_t *session);
+_Ret_ SWITCH_DECLARE(switch_channel_t *) switch_core_session_get_channel(_In_ switch_core_session_t *session);
/*!
\brief Signal a session's state machine thread that a state change has occured
\param event the event to parse
\return SWITCH_STATUS_SUCCESS if successful
*/
-SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *session, switch_event_t *event);
+SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(_In_ switch_core_session_t *session, _In_ switch_event_t *event);
/*!
\brief Parse all commands from an event
\param peer_session_data data to pass to the DTMF callback for peer_session
\return SWITCH_STATUS_SUCCESS if all is well
*/
-SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_session_t *session,
- switch_core_session_t *peer_session,
+SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(_In_ switch_core_session_t *session,
+ _In_ switch_core_session_t *peer_session,
switch_input_callback_function_t dtmf_callback, void *session_data,
void *peer_session_data);
\param dialplan the new dialplan (OPTIONAL, may be NULL)
\param context the new context (OPTIONAL, may be NULL)
*/
-SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(switch_core_session_t *session, const char *extension, const char *dialplan, const char *context);
+SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(_In_ switch_core_session_t *session, const char *extension, const char *dialplan, const char *context);
/*!
\brief Transfer an existing session to another location in the future
#define _Inout_
#define _Inout_opt_
#define _In_bytecount_(x)
+#define _Out_opt_bytecapcount_(x)
+#define _Ret_
#endif
}
caller_channel = switch_core_session_get_channel(caller_session);
- switch_assert(caller_channel != NULL);
switch_channel_clear_state_handler(caller_channel, NULL);
if (*exten == '&' && *(exten + 1)) {
switch_channel_t *channel;
channel = switch_core_session_get_channel(psession);
- switch_assert(channel != NULL);
-
if (switch_strlen_zero(var_name)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No variable name specified.\n");
stream->write_function(stream, "-ERR No variable specified\n");
if ((psession = switch_core_session_locate(uuid))) {
switch_channel_t *channel;
channel = switch_core_session_get_channel(psession);
-
- switch_assert(channel != NULL);
if (switch_strlen_zero(var_name)) {
stream->write_function(stream, "-ERR No variable name specified!\n");
char *buf;
channel = switch_core_session_get_channel(psession);
- switch_assert(channel != NULL);
if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
switch_xml_t xml;
switch_assert(member != NULL);
channel = switch_core_session_get_channel(member->session);
- switch_assert(channel != NULL);
read_codec = switch_core_session_get_read_codec(member->session);
switch_assert(read_codec != NULL);
uint32_t low_count = 0, bytes = samples * 2;
call_list_t *call_list = NULL, *cp = NULL;
- switch_assert(channel != NULL);
switch_assert(member->conference != NULL);
if (switch_core_timer_init(&timer, member->conference->timer_name, interval, tsamples, NULL) == SWITCH_STATUS_SUCCESS) {
channel = switch_core_session_get_channel(member->session);
profile = switch_channel_get_caller_profile(channel);
-
stream->write_function(stream, "%u) %s (%s)\n", member->id, profile->caller_id_name, profile->caller_id_number);
-
}
switch_mutex_unlock(conference->member_mutex);
-
}
static void conference_list(conference_obj_t * conference, switch_stream_handle_t *stream, char *delim)
profile = switch_channel_get_caller_profile(channel);
name = switch_channel_get_name(channel);
-
stream->write_function(stream, "%u%s%s%s%s%s%s%s%s%s",
member->id, delim, name, delim, uuid, delim, profile->caller_id_name, delim, profile->caller_id_number, delim);
switch_channel_t *channel = NULL;
channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CUSTOM RING\n");
}
peer_channel = switch_core_session_get_channel(peer_session);
- switch_assert(peer_channel != NULL);
rdlock = 1;
goto callup;
}
-
conference_name = conference->name;
if (switch_thread_rwlock_tryrdlock(conference->rwlock) != SWITCH_STATUS_SUCCESS) {
if (session != NULL) {
caller_channel = switch_core_session_get_channel(session);
-
}
if (switch_strlen_zero(cid_name)) {
rdlock = 1;
peer_channel = switch_core_session_get_channel(peer_session);
- switch_assert(peer_channel != NULL);
/* make sure the conference still exists */
if (!switch_test_flag(conference, CFLAG_RUNNING)) {
switch_channel_t *channel = switch_core_session_get_channel(session);
call_list_t *call_list, *np;
- switch_assert(channel != NULL);
-
call_list = switch_channel_get_private(channel, "_conference_autocall_list_");
if (switch_strlen_zero(data)) {
conf_xml_cfg_t xml_cfg = { 0 };
switch_event_t *params = NULL;
- switch_assert(channel != NULL);
-
if (switch_strlen_zero(data)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Invalid arguments\n");
return;
{
switch_xml_t x_domain, xml = NULL, x_user, x_param, x_params;
char *user, *mailbox, *domain;
- switch_channel_t *channel;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
+ switch_channel_t *channel = switch_core_session_get_channel(session);
if (switch_strlen_zero(data)) {
goto error;
SWITCH_STANDARD_APP(ring_ready_function)
{
- switch_channel_t *channel;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
- switch_channel_ring_ready(channel);
+ switch_channel_ring_ready(switch_core_session_get_channel(session));
}
SWITCH_STANDARD_APP(break_function)
{
- switch_channel_t *channel;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
- switch_channel_set_flag(channel, CF_BREAK);
+ switch_channel_set_flag(switch_core_session_get_channel(session), CF_BREAK);
}
SWITCH_STANDARD_APP(queue_dtmf_function)
{
- switch_channel_t *channel;
- channel = switch_core_session_get_channel(session);
- switch_channel_queue_dtmf_string(channel, (const char *) data);
-
+ switch_channel_queue_dtmf_string(switch_core_session_get_channel(session), (const char *) data);
}
-
SWITCH_STANDARD_APP(send_dtmf_function)
{
switch_core_session_send_dtmf_string(session, (const char *) data);
SWITCH_STANDARD_APP(phrase_function)
{
- switch_channel_t *channel;
char *mydata = NULL;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
if (!switch_strlen_zero(data) && (mydata = switch_core_session_strdup(session, data))) {
const char *lang;
char *macro = mydata;
*mdata++ = '\0';
}
- lang = switch_channel_get_variable(channel, "language");
+ lang = switch_channel_get_variable(switch_core_session_get_channel(session), "language");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Execute %s(%s) lang %s\n", macro, switch_str_nil(mdata), switch_str_nil(lang));
switch_ivr_phrase_macro(session, macro, mdata, lang, NULL);
SWITCH_STANDARD_APP(hangup_function)
{
- switch_channel_t *channel;
switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
if (!switch_strlen_zero(data)) {
cause = switch_channel_str2cause(data);
}
- switch_channel_hangup(channel, cause);
+ switch_channel_hangup(switch_core_session_get_channel(session), cause);
}
SWITCH_STANDARD_APP(answer_function)
{
- switch_channel_t *channel;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
- switch_channel_answer(channel);
+ switch_channel_answer(switch_core_session_get_channel(session));
}
SWITCH_STANDARD_APP(pre_answer_function)
{
- switch_channel_t *channel;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
- switch_channel_pre_answer(channel);
+ switch_channel_pre_answer(switch_core_session_get_channel(session));
}
SWITCH_STANDARD_APP(redirect_function)
SWITCH_STANDARD_APP(set_function)
{
- switch_channel_t *channel;
char *var, *val = NULL;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
if (switch_strlen_zero(data)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No variable name specified.\n");
} else {
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SET [%s]=[%s]\n", var, val ? val : "UNDEF");
- switch_channel_set_variable(channel, var, val);
+ switch_channel_set_variable(switch_core_session_get_channel(session), var, val);
}
}
SWITCH_STANDARD_APP(set_profile_var_function)
{
- switch_channel_t *channel;
switch_caller_profile_t *caller_profile;
char *name, *val = NULL;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- caller_profile = switch_channel_get_caller_profile(channel);
+ caller_profile = switch_channel_get_caller_profile(switch_core_session_get_channel(session));
if (switch_strlen_zero(data)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No variable name specified.\n");
SWITCH_STANDARD_APP(export_function)
{
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
const char *exports;
char *new_exports = NULL, *new_exports_d = NULL, *var, *val = NULL, *var_name = NULL;
int local = 1;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
if (switch_strlen_zero(data)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No variable name specified.\n");
} else {
SWITCH_STANDARD_APP(unset_function)
{
- switch_channel_t *channel;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
if (switch_strlen_zero(data)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No variable name specified.\n");
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "UNSET [%s]\n", (char *) data);
- switch_channel_set_variable(channel, data, NULL);
+ switch_channel_set_variable(switch_core_session_get_channel(session), data, NULL);
}
}
SWITCH_STANDARD_APP(log_function)
{
- switch_channel_t *channel;
char *level, *log_str;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
if (data && (level = strdup(data))) {
switch_log_level_t ltype = SWITCH_LOG_DEBUG;
SWITCH_STANDARD_APP(info_function)
{
- switch_channel_t *channel;
switch_event_t *event;
char *buf;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
- switch_channel_event_set_data(channel, event);
+ switch_channel_event_set_data(switch_core_session_get_channel(session), event);
switch_event_serialize(event, &buf, SWITCH_FALSE);
switch_assert(buf);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "CHANNEL_DATA:\n%s\n", buf);
SWITCH_STANDARD_APP(event_function)
{
- switch_channel_t *channel;
switch_event_t *event;
char *argv[25] = { 0 };
int argc = 0;
char *lbuf;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_APPLICATION) == SWITCH_STATUS_SUCCESS) {
- switch_channel_event_set_data(channel, event);
+ switch_channel_event_set_data(switch_core_session_get_channel(session), event);
if (!switch_strlen_zero(data) && (lbuf = switch_core_session_strdup(session, data))
&& (argc = switch_separate_string(lbuf, ',', argv, (sizeof(argv) / sizeof(argv[0]))))) {
int x = 0;
SWITCH_STANDARD_APP(privacy_function)
{
- switch_channel_t *channel;
- switch_caller_profile_t *caller_profile;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- caller_profile = switch_channel_get_caller_profile(channel);
+ switch_caller_profile_t *caller_profile = switch_channel_get_caller_profile(switch_core_session_get_channel(session));
if (switch_strlen_zero(data)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No privacy mode specified.\n");
switch_size_t retsize;
switch_time_exp_t tm;
char date[80] = "";
- switch_channel_t *channel;
-
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
switch_time_exp_lt(&tm, switch_timestamp_now());
switch_strftime(date, &retsize, sizeof(date), argv[1], &tm);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SET [%s]=[%s]\n", argv[0], date);
- switch_channel_set_variable(channel, argv[0], date);
+ switch_channel_set_variable(switch_core_session_get_channel(session), argv[0], date);
}
}
const char *terminators;
switch_channel_t *channel = switch_core_session_get_channel(session);
const char *p;
-
- switch_assert(channel);
if (!(terminators = switch_channel_get_variable(channel, SWITCH_PLAYBACK_TERMINATORS_VARIABLE))) {
terminators = "*";
char *mydata = NULL;
switch_input_args_t args = { 0 };
- switch_assert(channel != NULL);
-
if (switch_strlen_zero(data) || !(mydata = switch_core_session_strdup(session, data))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Params!\n");
return;
SWITCH_STANDARD_APP(playback_function)
{
- switch_channel_t *channel = switch_core_session_get_channel(session);
switch_input_args_t args = { 0 };
- switch_assert(channel != NULL);
-
- switch_channel_pre_answer(channel);
+ switch_channel_pre_answer(switch_core_session_get_channel(session));
args.input_callback = on_dtmf;
switch_ivr_play_file(session, NULL, data, &args);
SWITCH_STANDARD_APP(gentones_function)
{
- switch_channel_t *channel;
char *tone_script = NULL;
switch_input_args_t args = { 0 };
char *l;
return;
}
- tone_script = switch_core_session_strdup(session, data);
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- switch_channel_pre_answer(channel);
+ switch_channel_pre_answer(switch_core_session_get_channel(session));
if ((l = strchr(tone_script, '|'))) {
*l++ = '\0';
const char *tmp;
int rate;
- switch_assert(channel != NULL);
-
if (!switch_strlen_zero(data) && (mydata = switch_core_session_strdup(session, data))) {
argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
} else {
uint8_t no_media_bridge = 0;
switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
- assert(caller_channel != NULL);
-
if (switch_strlen_zero(data)) {
return;
}
enum_route_t *rtp;
char *dp = (char *) arg;
- assert(channel != NULL);
-
if (!caller_profile) {
caller_profile = switch_channel_get_caller_profile(channel);
}
uint32_t cnt = 1;
switch_channel_t *channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
-
if (!(mydata = switch_core_session_strdup(session, data))) {
return;
}
SWITCH_STANDARD_APP(bcast_function)
{
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
switch_socket_t *socket;
switch_sockaddr_t *audio_addr = NULL, *control_packet_addr;
switch_frame_t *read_frame;
switch_port_t mcast_control_port = 6061;
char *mcast_port_str = "34567";
-
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
-
-
if (!switch_strlen_zero((char *) data)) {
mydata = switch_core_session_strdup(session, data);
assert(mydata != NULL);
static switch_status_t on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
{
- switch_core_session_t *bleg;
- switch_channel_t *channel;
-
- bleg = (switch_core_session_t *) buf;
+ switch_core_session_t *bleg = (switch_core_session_t *) buf;
switch (itype) {
case SWITCH_INPUT_TYPE_DTMF:
switch_dtmf_t *dtmf = (switch_dtmf_t *) input;
if (dtmf->digit == '*') {
- channel = switch_core_session_get_channel(session);
- if (switch_channel_test_flag(channel, CF_ORIGINATOR)) {
- channel = switch_core_session_get_channel(bleg);
- switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
+ if (switch_channel_test_flag(switch_core_session_get_channel(session), CF_ORIGINATOR)) {
+ switch_channel_hangup(switch_core_session_get_channel(bleg), SWITCH_CAUSE_NORMAL_CLEARING);
return SWITCH_STATUS_BREAK;
}
}
return SWITCH_STATUS_SUCCESS;
}
-
#define check_string(s) if (!switch_strlen_zero(s) && !strcasecmp(s, "undef")) { s = NULL; }
-
static switch_status_t read_frame_callback(switch_core_session_t *session, switch_frame_t *frame, void *user_data)
{
switch_queue_t *fifo = (switch_queue_t *) user_data;
int argc;
char *mydata = NULL, *argv[5] = { 0 };
fifo_node_t *node;
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
int nowait = 0;
const char *moh = NULL;
const char *announce = NULL;
return;
}
-
- if (switch_strlen_zero(data)) {
+ if (switch_strlen_zero(data)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Args\n");
return;
}
return;
}
- channel = switch_core_session_get_channel(session);
-
- switch_mutex_lock(globals.mutex);
+ switch_mutex_lock(globals.mutex);
if (!(node = switch_core_hash_find(globals.fifo_hash, argv[0]))) {
node = create_node(argv[0]);
}
switch_mutex_unlock(globals.mutex);
-
-
- moh = switch_channel_get_variable(channel, "fifo_music");
+ moh = switch_channel_get_variable(channel, "fifo_music");
announce = switch_channel_get_variable(channel, "fifo_announce");
if (argc > 2) {
check_string(announce);
check_string(moh);
-
- if (moh) {
+ if (moh) {
switch_ivr_broadcast(uuid, moh, SMF_LOOP | SMF_ECHO_ALEG);
}
switch_ivr_park(session, NULL);
-
-
- if (switch_channel_ready(channel)) {
+ if (switch_channel_ready(channel)) {
if (announce) {
switch_ivr_play_file(session, NULL, announce, NULL);
}
switch_mutex_unlock(node->mutex);
switch_channel_answer(channel);
}
-
- if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) {
+ if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(channel, event);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Name", "%s", argv[0]);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "consumer_start");
switch_channel_set_variable(channel, "fifo_status", "WAITING");
switch_channel_set_variable(channel, "fifo_timestamp", date);
-
-
- while(switch_channel_ready(channel)) {
+ while(switch_channel_ready(channel)) {
if (moh) {
args.read_frame_callback = read_frame_callback;
args.user_data = node->fifo;
switch_channel_t *other_channel = switch_core_session_get_channel(other_session);
switch_caller_profile_t *cloned_profile;
-
- if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) {
+ if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(other_channel, event);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Name", "%s", argv[0]);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "caller_pop");
switch_event_fire(&event);
}
-
-
- if (announce) {
+ if (announce) {
switch_ivr_play_file(session, NULL, announce, NULL);
} else {
switch_ivr_sleep(session, 500);
}
}
-
- if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) {
+ if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(channel, event);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Name", "%s", argv[0]);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Action", "consumer_stop");
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "USAGE %s\n", FIFO_USAGE);
}
-
}
static int xml_hash(switch_xml_t xml, switch_hash_t *hash, char *container, char *tag, int cc_off, int verbose)
static switch_status_t hanguphook(switch_core_session_t *session)
{
- switch_channel_t *channel;
- switch_channel_state_t state;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ switch_channel_state_t state = switch_channel_get_state(channel);
const char *realm = NULL;
const char *id = NULL;
char *sql = NULL;
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
-
- state = switch_channel_get_state(channel);
-
- if (state == CS_HANGUP || state == CS_RING) {
+ if (state == CS_HANGUP || state == CS_RING) {
id = switch_channel_get_variable(channel, "limit_id");
realm = switch_channel_get_variable(channel, "limit_realm");
sql = switch_mprintf("delete from limit_data where uuid='%q' and hostname='%q' and realm='%q'and id='%q';",
SWITCH_STANDARD_APP(db_function)
{
- switch_channel_t *channel;
int argc = 0;
char *argv[4] = { 0 };
char *mydata = NULL;
char *sql = NULL;
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
-
- if (!switch_strlen_zero(data)) {
+ if (!switch_strlen_zero(data)) {
mydata = switch_core_session_strdup(session, data);
argc = switch_separate_string(mydata, '/', argv, (sizeof(argv) / sizeof(argv[0])));
}
if (argc < 4 || !argv[0]) {
goto error;
}
-
-
- if (!strcasecmp(argv[0], "insert")) {
+
+ if (!strcasecmp(argv[0], "insert")) {
sql = switch_mprintf("delete from db_data where realm='%q' and data_key='%q'", argv[1], argv[2]);
switch_assert(sql);
limit_execute_sql(sql, globals.mutex);
switch_safe_free(sql);
return;
-
- error:
+error:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "USAGE: db %s\n", DB_USAGE);
-
-
-
}
SWITCH_STANDARD_APP(group_function)
{
- switch_channel_t *channel;
int argc = 0;
char *argv[3] = { 0 };
char *mydata = NULL;
char *sql;
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
-
- if (!switch_strlen_zero(data)) {
+ if (!switch_strlen_zero(data)) {
mydata = switch_core_session_strdup(session, data);
argc = switch_separate_string(mydata, ':', argv, (sizeof(argv) / sizeof(argv[0])));
}
int max = 0, got = 0;
char buf[80] = "";
callback_t cbt = { 0 };
- switch_channel_t *channel;
-
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
+ switch_channel_t *channel = switch_core_session_get_channel(session);
if (!switch_strlen_zero(data)) {
mydata = switch_core_session_strdup(session, data);
return;
}
+ switch_mutex_lock(globals.mutex);
- switch_mutex_lock(globals.mutex);
-
-
-
- realm = argv[0];
+ realm = argv[0];
id = argv[1];
max = atoi(argv[2]);
limit_execute_sql(sql, NULL);
switch_safe_free(sql);
-
- done:
-
+done:
switch_mutex_unlock(globals.mutex);
-
}
SWITCH_STANDARD_APP(rss_function)
{
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
switch_status_t status;
const char *err = NULL;
struct dtmf_buffer dtb = { 0 };
uint32_t matches = 0;
switch_input_args_t args = { 0 };
const char *vcf = NULL;
- char *chanvars = NULL;
-
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
+ char *chanvars = switch_channel_build_param_string(channel, NULL, NULL);
if ((vcf = switch_channel_get_variable(channel, "rss_alt_config"))) {
cf = vcf;
}
- chanvars = switch_channel_build_param_string(channel, NULL, NULL);
if (!(cxml = switch_xml_open_cfg(cf, &cfg, NULL))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
return;
uint32_t timeout)
{
switch_input_args_t args = { 0 }, *ap = NULL;
- switch_channel_t *channel;
switch_status_t status = SWITCH_STATUS_SUCCESS;
switch_size_t bslen;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
if (buf && buflen) {
memset(buf, 0, buflen);
args.input_callback = cancel_on_dtmf;
static switch_status_t create_file(switch_core_session_t *session, vm_profile_t *profile,
char *macro_name, char *file_path, switch_size_t *message_len, switch_bool_t limit)
{
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
switch_status_t status = SWITCH_STATUS_SUCCESS;
switch_file_handle_t fh = { 0 };
switch_input_args_t args = { 0 };
char input[10] = "" , key_buf[80] = "";
cc_t cc = { 0 };
switch_codec_t *read_codec;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
read_codec = switch_core_session_get_read_codec(session);
static switch_status_t listen_file(switch_core_session_t *session, vm_profile_t *profile, listen_callback_t *cbt)
{
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
switch_status_t status = SWITCH_STATUS_SUCCESS;
switch_input_args_t args = { 0 };
char term;
char input[10] = "" , key_buf[80] = "";
switch_file_handle_t fh = { 0 };
cc_t cc = { 0 };
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
if(switch_channel_ready(channel)) {
static void voicemail_check_main(switch_core_session_t *session, const char *profile_name, const char *domain_name, const char *id, int auth)
{
vm_check_state_t vm_check_state = VM_CHECK_START;
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
switch_caller_profile_t *caller_profile;
vm_profile_t *profile;
- switch_xml_t x_domain, x_domain_root, x_user, x_params, x_param;
+ switch_xml_t x_domain = NULL, x_domain_root = NULL, x_user = NULL, x_params, x_param;
switch_status_t status;
char pass_buf[80] = "", *mypass = NULL, id_buf[80] = "", *myfolder = NULL;
const char *thepass = NULL, *myid = id;
int heard_auto_saved = 0, heard_auto_new = 0;
char *email_vm = NULL;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
if (!(profile = switch_core_hash_find(globals.profile_hash, profile_name))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error invalid profile %s\n", profile_name);
return;
}
- x_user = x_domain = x_domain_root = NULL;
-
timeout = profile->digit_timeout;
attempts = profile->max_login_attempts;
static switch_status_t voicemail_leave_main(switch_core_session_t *session, const char *profile_name, const char *domain_name, const char *id)
{
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
char *myfolder = "inbox";
char sql[256];
prefs_callback_t cbt;
char *file_path = NULL;
char *dir_path = NULL;
switch_status_t status = SWITCH_STATUS_SUCCESS;
- switch_caller_profile_t *caller_profile;
+ switch_caller_profile_t *caller_profile = switch_channel_get_caller_profile(channel);
switch_file_handle_t fh = { 0 };
switch_input_args_t args = { 0 };
char *email_vm = NULL;
return SWITCH_STATUS_FALSE;
}
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- caller_profile = switch_channel_get_caller_profile(channel);
if(switch_strlen_zero(profile->storage_dir)) {
dir_path = switch_core_session_sprintf(session, "%s%svoicemail%s%s%s%s%s%s", SWITCH_GLOBAL_dirs.storage_dir,
SWITCH_PATH_SEPARATOR,
const char *id = NULL;
const char *auth_var = NULL;
int x = 0, check = 0, auth = 0;
- switch_channel_t *channel;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
+ switch_channel_t *channel = switch_core_session_get_channel(session);
if (switch_dir_make_recursive(SWITCH_GLOBAL_dirs.storage_dir, SWITCH_DEFAULT_DIR_PERMS, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error creating %s\n", SWITCH_GLOBAL_dirs.storage_dir);
int argc;
char *argv[4] = { 0 };
char *mydata;
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
-
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
-
-
if (data && (mydata = switch_core_session_strdup(session, data))) {
if ((argc = switch_separate_string(mydata, '|', argv, (sizeof(argv) / sizeof(argv[0])))) < 2) {
goto error;
{
void *y = NULL;
int x = 0;
-
- switch_channel_t *channel;
-
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
+ switch_channel_t *channel = switch_core_session_get_channel(session);
for (x = 0; x < 5; x++) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Avoiding initial deadlock on channel %s.\n", switch_channel_get_name(channel));
int argc;
char *argv[3] = { 0 };
char *mydata;
- switch_channel_t *channel;
-
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
-
+
if (data && (mydata = switch_core_session_strdup(session, data))) {
if ((argc = switch_separate_string(mydata, '|', argv, (sizeof(argv) / sizeof(argv[0])))) < 1) {
goto error;
SWITCH_STANDARD_DIALPLAN(asterisk_dialplan_hunt)
{
switch_caller_extension_t *extension = NULL;
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
char *cf = "extensions.conf";
switch_config_t cfg;
char *var, *val;
cf = arg;
}
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
if (!caller_profile) {
caller_profile = switch_channel_get_caller_profile(channel);
}
SWITCH_STANDARD_DIALPLAN(directory_dialplan_hunt)
{
switch_caller_extension_t *extension = NULL;
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
char *var, *val;
char filter[256];
switch_directory_handle_t dh;
char app[512];
char *data;
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
-
if (!caller_profile) {
caller_profile = switch_channel_get_caller_profile(channel);
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Hello %s You Dialed %s!\n", caller_profile->caller_id_name,
caller_profile->destination_number);
-
if (!(globals.directory_name && globals.host && globals.dn && globals.base && globals.pass)) {
return NULL;
}
static int parse_exten(switch_core_session_t *session, switch_caller_profile_t *caller_profile, switch_xml_t xexten, switch_caller_extension_t **extension)
{
switch_xml_t xcond, xaction;
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
char *exten_name = (char *) switch_xml_attr_soft(xexten, "name");
int proceed = 0;
char *expression_expanded = NULL, *field_expanded = NULL;
-
- channel = switch_core_session_get_channel(session);
-
for (xcond = switch_xml_child(xexten, "condition"); xcond; xcond = xcond->next) {
char *field = NULL;
char *do_break_a = NULL;
static switch_status_t dialplan_xml_locate(switch_core_session_t *session, switch_caller_profile_t *caller_profile, switch_xml_t * root,
switch_xml_t * node)
{
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
switch_status_t status = SWITCH_STATUS_GENERR;
switch_event_t *params = NULL;
- channel = switch_core_session_get_channel(session);
switch_event_create(¶ms, SWITCH_EVENT_MESSAGE);
switch_assert(params);
SWITCH_STANDARD_DIALPLAN(dialplan_hunt)
{
switch_caller_extension_t *extension = NULL;
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
switch_xml_t alt_root = NULL, cfg, xml = NULL, xcontext, xexten;
char *alt_path = (char *) arg;
-
- channel = switch_core_session_get_channel(session);
if (!caller_profile) {
if (!(caller_profile = switch_channel_get_caller_profile(channel))) {
static int do_candidates(struct private_object *tech_pvt, int force)
{
switch_channel_t *channel = switch_core_session_get_channel(tech_pvt->session);
- switch_assert(channel != NULL);
if (switch_test_flag(tech_pvt, TFLAG_DO_CAND)) {
return 1;
static switch_status_t negotiate_media(switch_core_session_t *session)
{
switch_status_t ret = SWITCH_STATUS_FALSE;
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
struct private_object *tech_pvt = NULL;
switch_time_t started;
switch_time_t now;
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
switch_set_flag_locked(tech_pvt, TFLAG_IO);
started = switch_timestamp_now();
*/
static switch_status_t channel_on_init(switch_core_session_t *session)
{
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
struct private_object *tech_pvt = NULL;
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
tech_pvt->read_frame.buflen = SWITCH_RTP_MAX_BUF_LEN;
switch_set_flag(tech_pvt, TFLAG_READY);
static switch_status_t channel_on_ring(switch_core_session_t *session)
{
- switch_channel_t *channel = NULL;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
struct private_object *tech_pvt = NULL;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
static switch_status_t channel_on_hangup(switch_core_session_t *session)
{
- switch_channel_t *channel = NULL;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
struct private_object *tech_pvt = NULL;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig)
{
- switch_channel_t *channel = NULL;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
struct private_object *tech_pvt = NULL;
- if (!(channel = switch_core_session_get_channel(session))) {
- return SWITCH_STATUS_SUCCESS;
- }
-
if (!(tech_pvt = switch_core_session_get_private(session))) {
return SWITCH_STATUS_SUCCESS;
}
-
switch (sig) {
case SWITCH_SIG_KILL:
switch_clear_flag_locked(tech_pvt, TFLAG_IO);
static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout, switch_io_flag_t flags, int stream_id)
{
struct private_object *tech_pvt = NULL;
- switch_channel_t *channel = NULL;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
int payload = 0;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
tech_pvt = (struct private_object *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, switch_io_flag_t flags, int stream_id)
{
struct private_object *tech_pvt;
- switch_channel_t *channel = NULL;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
switch_status_t status = SWITCH_STATUS_SUCCESS;
int bytes = 0, samples = 0, frames = 0;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
tech_pvt = (struct private_object *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
static switch_status_t channel_answer_channel(switch_core_session_t *session)
{
struct private_object *tech_pvt;
- switch_channel_t *channel = NULL;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
static switch_status_t channel_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg)
{
- switch_channel_t *channel;
struct private_object *tech_pvt;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
static switch_status_t channel_receive_event(switch_core_session_t *session, switch_event_t *event)
{
- switch_channel_t *channel;
struct private_object *tech_pvt;
char *subject, *body;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
switch_assert(tech_pvt != NULL);
channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "using Existing session for %s\n", ldl_session_get_id(dlsession));
}
channel = switch_core_session_get_channel(tech_pvt->session);
- switch_assert(channel != NULL);
-
if (tech_pvt->samprate || *samprate) {
unsigned short samples = iax_build_codec_rates();
*/
static switch_status_t channel_on_init(switch_core_session_t *session)
{
- switch_channel_t *channel;
- private_t *tech_pvt = NULL;
-
- tech_pvt = switch_core_session_get_private(session);
+ private_t *tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
-
iax_set_private(tech_pvt->iax_session, tech_pvt);
switch_set_flag_locked(tech_pvt, TFLAG_IO);
-
- //switch_thread_cond_create(&tech_pvt->cond, switch_core_session_get_pool(session));
- //switch_mutex_lock(tech_pvt->mutex);
-
/* Move Channel's State Machine to RING */
- switch_channel_set_state(channel, CS_RING);
+ switch_channel_set_state(switch_core_session_get_channel(session), CS_RING);
switch_mutex_lock(globals.mutex);
globals.calls++;
switch_mutex_unlock(globals.mutex);
static switch_status_t channel_on_ring(switch_core_session_t *session)
{
- switch_channel_t *channel = NULL;
- private_t *tech_pvt = NULL;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- tech_pvt = switch_core_session_get_private(session);
- switch_assert(tech_pvt != NULL);
-
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL RING\n", switch_channel_get_name(channel));
-
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL RING\n", switch_channel_get_name(switch_core_session_get_channel(session)));
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t channel_on_execute(switch_core_session_t *session)
{
-
- switch_channel_t *channel = NULL;
- private_t *tech_pvt = NULL;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- tech_pvt = switch_core_session_get_private(session);
- switch_assert(tech_pvt != NULL);
-
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL EXECUTE\n", switch_channel_get_name(channel));
-
-
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL EXECUTE\n", switch_channel_get_name(switch_core_session_get_channel(session)));
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t channel_on_hangup(switch_core_session_t *session)
{
- switch_channel_t *channel = NULL;
- private_t *tech_pvt = NULL;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
+ private_t *tech_pvt = switch_core_session_get_private(session);
- tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
switch_clear_flag_locked(tech_pvt, TFLAG_IO);
switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
- //switch_thread_cond_signal(tech_pvt->cond);
if (tech_pvt->read_codec.implementation) {
switch_core_codec_destroy(&tech_pvt->read_codec);
iax_session_destroy(&tech_pvt->iax_session);
}
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL HANGUP\n", switch_channel_get_name(channel));
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL HANGUP\n", switch_channel_get_name(switch_core_session_get_channel(session)));
switch_mutex_lock(globals.mutex);
globals.calls--;
if (globals.calls < 0) {
static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig)
{
- switch_channel_t *channel = NULL;
- private_t *tech_pvt = NULL;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- tech_pvt = switch_core_session_get_private(session);
+ private_t *tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
switch (sig) {
case SWITCH_SIG_KILL:
switch_clear_flag_locked(tech_pvt, TFLAG_IO);
switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
- switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
- //switch_thread_cond_signal(tech_pvt->cond);
+ switch_channel_hangup(switch_core_session_get_channel(session), SWITCH_CAUSE_NORMAL_CLEARING);
break;
case SWITCH_SIG_BREAK:
switch_set_flag_locked(tech_pvt, TFLAG_BREAK);
static switch_status_t channel_waitfor_read(switch_core_session_t *session, int ms, int stream_id)
{
- private_t *tech_pvt = NULL;
-
- tech_pvt = switch_core_session_get_private(session);
+ private_t *tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
return SWITCH_STATUS_SUCCESS;
static switch_status_t channel_waitfor_write(switch_core_session_t *session, int ms, int stream_id)
{
- private_t *tech_pvt = NULL;
-
- tech_pvt = switch_core_session_get_private(session);
+ private_t *tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
return SWITCH_STATUS_SUCCESS;
-
}
static switch_status_t channel_send_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf)
{
- private_t *tech_pvt = NULL;
-
- tech_pvt = switch_core_session_get_private(session);
+ private_t *tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
if (tech_pvt->iax_session) {
iax_send_dtmf(tech_pvt->iax_session, dtmf->digit);
static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout, switch_io_flag_t flags, int stream_id)
{
- switch_channel_t *channel = NULL;
- private_t *tech_pvt = NULL;
+ private_t *tech_pvt = switch_core_session_get_private(session);
switch_time_t started = switch_timestamp_now();
unsigned int elapsed;
switch_byte_t *data;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
tech_pvt->read_frame.flags = SFF_NONE;
*frame = NULL;
switch_yield(1000);
continue;
}
- //switch_thread_cond_wait(tech_pvt->cond, tech_pvt->mutex);
if (switch_test_flag(tech_pvt, TFLAG_BREAK)) {
switch_clear_flag(tech_pvt, TFLAG_BREAK);
goto cng;
return SWITCH_STATUS_SUCCESS;
}
}
-
-
switch_yield(1000);
}
-
return SWITCH_STATUS_FALSE;
cng:
tech_pvt->read_frame.flags = SFF_CNG;
*frame = &tech_pvt->read_frame;
return SWITCH_STATUS_SUCCESS;
-
}
static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, switch_io_flag_t flags, int stream_id)
{
- switch_channel_t *channel = NULL;
- private_t *tech_pvt = NULL;
- //switch_frame_t *pframe;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- tech_pvt = switch_core_session_get_private(session);
+ private_t *tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
if (!switch_test_flag(tech_pvt, TFLAG_IO)) {
static switch_status_t channel_answer_channel(switch_core_session_t *session)
{
- private_t *tech_pvt;
- switch_channel_t *channel = NULL;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- tech_pvt = switch_core_session_get_private(session);
+ private_t *tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
if (!switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
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);
- switch_assert(channel != NULL);
-
- tech_pvt = (private_t *) switch_core_session_get_private(session);
+ private_t *tech_pvt = (private_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
switch (msg->message_id) {
return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
}
-
if (iax_set_codec(tech_pvt, tech_pvt->iax_session, &req, &cap, &samprate, IAX_QUERY) != SWITCH_STATUS_SUCCESS) {
switch_core_session_destroy(new_session);
return SWITCH_CAUSE_BEARERCAPABILITY_NOTIMPL;
}
return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
-
}
static switch_status_t channel_receive_event(switch_core_session_t *session, switch_event_t *event)
{
- switch_channel_t *channel;
- struct private_object *tech_pvt;
- char *body;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
+ struct private_object *tech_pvt = switch_core_session_get_private(session);
+ char *body = switch_event_get_body(event);
- tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
-
- if (!(body = switch_event_get_body(event))) {
+ if (!body) {
body = "";
}
SWITCH_MODULE_LOAD_FUNCTION(mod_iax_load)
{
-
module_pool = pool;
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
SWITCH_MODULE_RUNTIME_FUNCTION(mod_iax_runtime)
{
- //int refresh;
struct iax_event *iaxevent = NULL;
switch_event_t *s_event;
if (load_config() != SWITCH_STATUS_SUCCESS) {
break;
}
-
if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
iaxevent->ies.username,
globals.dialplan,
switch_snprintf(name, sizeof(name), "IAX/%s-%04x", tech_pvt->caller_profile->destination_number, rand() & 0xffff);
switch_channel_set_name(channel, name);
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
-
}
if (iax_set_codec(tech_pvt, iaxevent->session,
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hangup %s\n", switch_channel_get_name(channel));
switch_set_flag_locked(tech_pvt, TFLAG_HANGUP);
switch_channel_hangup(channel, iaxevent->etype == IAX_EVENT_HANGUP ? SWITCH_CAUSE_NORMAL_CLEARING : SWITCH_CAUSE_FACILITY_REJECTED);
- //switch_thread_cond_signal(tech_pvt->cond);
iaxevent->session = NULL;
}
break;
int bytes, frames;
if (!switch_test_flag(tech_pvt, TFLAG_CODEC)) {
- //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "audio with no codec yet!\n");
break;
}
memcpy(tech_pvt->read_frame.data, iaxevent->data, iaxevent->datalen);
/* wake up the i/o thread */
switch_set_flag_locked(tech_pvt, TFLAG_VOICE);
- //switch_thread_cond_signal(tech_pvt->cond);
}
}
break;
case IAX_EVENT_TRANSFER:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Call transfer occurred.\n");
- //session[0] = iaxevent->session;
break;
case IAX_EVENT_DTMF:
if (channel) {
if (globals.debug) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%c DTMF %s\n", dtmf.digit, switch_channel_get_name(channel));
}
-
switch_channel_queue_dtmf(channel, &dtmf);
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Don't know what to do with IAX event %d.\n", iaxevent->etype);
break;
}
-
iax_event_free(iaxevent);
}
-
}
running = 0;
*/
static switch_status_t channel_on_init(switch_core_session_t *session)
{
- switch_channel_t *channel;
- private_t *tech_pvt = NULL;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ private_t *tech_pvt = switch_core_session_get_private(session);
switch_time_t last;
int waitsec = globals.ring_interval * 1000000;
switch_file_handle_t fh = { 0 };
const char *val, *ring_file = NULL, *hold_file = NULL;
int16_t abuf[2048];
- tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
-
last = switch_timestamp_now() - waitsec;
-
-
if ((val = switch_channel_get_variable(channel, "pa_hold_file"))) {
hold_file = val;
} else {
if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
-
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL INIT %d %d\n",
switch_channel_get_name(channel), switch_channel_get_state(channel), switch_test_flag(tech_pvt, TFLAG_ANSWER));
-
-
if (engage_device(tech_pvt->sample_rate, tech_pvt->codec_ms) != SWITCH_STATUS_SUCCESS) {
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
return SWITCH_STATUS_FALSE;
switch_channel_set_state(channel, CS_RING);
return SWITCH_STATUS_SUCCESS;
-
}
static switch_status_t channel_on_ring(switch_core_session_t *session)
{
- switch_channel_t *channel = NULL;
- private_t *tech_pvt = NULL;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- tech_pvt = switch_core_session_get_private(session);
- switch_assert(tech_pvt != NULL);
-
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL RING\n", switch_channel_get_name(channel));
-
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL RING\n", switch_channel_get_name(switch_core_session_get_channel(session)));
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t channel_on_execute(switch_core_session_t *session)
{
-
- switch_channel_t *channel = NULL;
- private_t *tech_pvt = NULL;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- tech_pvt = switch_core_session_get_private(session);
- switch_assert(tech_pvt != NULL);
-
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL EXECUTE\n", switch_channel_get_name(channel));
-
-
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL EXECUTE\n", switch_channel_get_name(switch_core_session_get_channel(session)));
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t channel_on_hangup(switch_core_session_t *session)
{
- switch_channel_t *channel = NULL;
- private_t *tech_pvt = NULL;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- tech_pvt = switch_core_session_get_private(session);
+ private_t *tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
remove_pvt(tech_pvt);
switch_core_file_close(&tech_pvt->fh);
}
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL HANGUP\n", switch_channel_get_name(channel));
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL HANGUP\n", switch_channel_get_name(switch_core_session_get_channel(session)));
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig)
{
- switch_channel_t *channel = NULL;
- private_t *tech_pvt = NULL;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- tech_pvt = switch_core_session_get_private(session);
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ private_t *tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
switch (sig) {
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL KILL\n", switch_channel_get_name(channel));
-
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t channel_on_loopback(switch_core_session_t *session)
{
- switch_channel_t *channel = NULL;
- private_t *tech_pvt = NULL;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- tech_pvt = switch_core_session_get_private(session);
- switch_assert(tech_pvt != NULL);
-
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL LOOPBACK\n");
-
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t channel_waitfor_read(switch_core_session_t *session, int ms, int stream_id)
{
- private_t *tech_pvt = NULL;
-
- tech_pvt = switch_core_session_get_private(session);
- switch_assert(tech_pvt != NULL);
-
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t channel_waitfor_write(switch_core_session_t *session, int ms, int stream_id)
{
- private_t *tech_pvt = NULL;
-
- tech_pvt = switch_core_session_get_private(session);
- switch_assert(tech_pvt != NULL);
-
return SWITCH_STATUS_SUCCESS;
-
}
static switch_status_t channel_send_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf)
{
- private_t *tech_pvt = NULL;
-
- tech_pvt = switch_core_session_get_private(session);
+ private_t *tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "DTMF ON CALL %s [%c]\n", tech_pvt->call_id, dtmf->digit);
static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout, switch_io_flag_t flags, int stream_id)
{
- switch_channel_t *channel = NULL;
- private_t *tech_pvt = NULL;
+ private_t *tech_pvt = switch_core_session_get_private(session);
int samples = 0;
switch_status_t status = SWITCH_STATUS_FALSE;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
if (!globals.audio_stream) {
return SWITCH_STATUS_SUCCESS;
hold:
-
{
switch_size_t olen = globals.read_codec.implementation->samples_per_frame;
if (switch_core_timer_next(&globals.timer) != SWITCH_STATUS_SUCCESS) {
goto cng;
}
-
tech_pvt->hold_frame.datalen = (uint32_t) (olen * sizeof(int16_t));
tech_pvt->hold_frame.samples = (uint32_t) olen;
*frame = &tech_pvt->hold_frame;
static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, switch_io_flag_t flags, int stream_id)
{
- switch_channel_t *channel = NULL;
- private_t *tech_pvt = NULL;
switch_status_t status = SWITCH_STATUS_FALSE;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- tech_pvt = switch_core_session_get_private(session);
+ private_t *tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
if (!globals.audio_stream) {
}
return status;
-
}
static switch_status_t channel_answer_channel(switch_core_session_t *session)
{
- private_t *tech_pvt;
- switch_channel_t *channel = NULL;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- tech_pvt = switch_core_session_get_private(session);
- switch_assert(tech_pvt != NULL);
-
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);
- switch_assert(channel != NULL);
-
- tech_pvt = switch_core_session_get_private(session);
+ private_t *tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
-
switch (msg->message_id) {
case SWITCH_MESSAGE_INDICATE_ANSWER:
channel_answer_channel(session);
switch_caller_profile_t *outbound_profile,
switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags)
{
-
if ((*new_session = switch_core_session_request(portaudio_endpoint_interface, pool)) != 0) {
private_t *tech_pvt;
switch_channel_t *channel;
}
return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
-
}
"Input Device: %d, Output Device: %d, Ring Device: %d Sample Rate: %d MS: %d\n", globals.indev,
globals.outdev, globals.ringdev, globals.sample_rate, globals.codec_ms);
-
switch_core_hash_init(&globals.call_hash, module_pool);
switch_mutex_init(&globals.device_lock, SWITCH_MUTEX_NESTED, module_pool);
switch_mutex_init(&globals.pvt_lock, SWITCH_MUTEX_NESTED, module_pool);
switch_mutex_init(&globals.flag_mutex, SWITCH_MUTEX_NESTED, module_pool);
-
-
if (switch_event_reserve_subclass(MY_EVENT_RINGING) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass!\n");
return SWITCH_STATUS_GENERR;
int i, printCount, cr = 7;
PaError err;
static double standardSampleRates[] = { 8000.0, 9600.0, 11025.0, 12000.0, 16000.0, 22050.0, 24000.0, 32000.0,
- 44100.0, 48000.0, 88200.0, 96000.0, 192000.0, -1
- };
+ 44100.0, 48000.0, 88200.0, 96000.0, 192000.0, -1};
printCount = cr;
for (i = 0; standardSampleRates[i] > 0; i++) {
PaError err;
const char *line = "--------------------------------------------------------------------------------\n";
-
-
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,
"PortAudio version number = %d\nPortAudio version text = '%s'\n", Pa_GetVersion(), Pa_GetVersionText());
if (globals.audio_stream) {
return err;
}
-
-
static switch_status_t engage_device(int sample_rate, int codec_ms)
{
PaStreamParameters inputParameters, outputParameters;
return SWITCH_STATUS_FALSE;
}
-
-
globals.read_frame.rate = sample_rate;
globals.read_frame.codec = &globals.read_codec;
-
-
switch_mutex_lock(globals.device_lock);
/* LOCKED ************************************************************************************************** */
inputParameters.device = globals.indev;
/* UNLOCKED ************************************************************************************************* */
switch_mutex_unlock(globals.device_lock);
-
if (err != paNoError) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open audio device!\n");
switch_core_codec_destroy(&globals.read_codec);
}
}
-
-
return SWITCH_STATUS_SUCCESS;
-
-
}
-
static switch_status_t engage_ring_device(int sample_rate, int channels)
{
PaStreamParameters outputParameters;
/* UNLOCKED ************************************************************************************************* */
switch_mutex_unlock(globals.device_lock);
-
if (err != paNoError) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open ring device!\n");
return SWITCH_STATUS_FALSE;
return SWITCH_STATUS_SUCCESS;
}
-
-
static switch_status_t dtmf_call(char **argv, int argc, switch_stream_handle_t *stream)
{
char *dtmf_str = argv[0];
switch_mutex_unlock(globals.pvt_lock);
return SWITCH_STATUS_SUCCESS;
-
}
static switch_status_t hangup_call(char **argv, int argc, switch_stream_handle_t *stream)
switch_mutex_unlock(globals.pvt_lock);
return SWITCH_STATUS_SUCCESS;
-
}
static switch_status_t answer_call(char **argv, int argc, switch_stream_handle_t *stream)
}
done:
switch_mutex_unlock(globals.pvt_lock);
-
stream->write_function(stream, "Answered %d channels.\n", x);
-
return SWITCH_STATUS_SUCCESS;
-
}
static switch_status_t do_flags(char **argv, int argc, switch_stream_handle_t *stream)
http = switch_event_get_header(stream->event, "http-host");
}
-
if (http) {
stream->write_function(stream, "Content-type: text/html\n\n");
-#if 0
- switch_event_header_t *hp;
- stream->write_function(stream, "<pre>");
- for (hp = stream->event->headers; hp; hp = hp->next) {
- stream->write_function(stream, "[%s]=[%s]\n", hp->name, hp->value);
- }
- stream->write_function(stream, "</pre>");
-#endif
-
wcmd = switch_str_nil(switch_event_get_header(stream->event, "wcmd"));
action = switch_event_get_header(stream->event, "action");
}
done:
-
if (http) {
-
stream->write_function(stream,
"<br><br><table align=center><tr><td><center><form method=post>\n"
"<input type=text name=wcmd size=40><br><br>\n"
-
"<input name=action type=submit value=\"call\"> "
"<input name=action type=submit value=\"hangup\"> "
"<input name=action type=submit value=\"list\"> "
}
switch_safe_free(mycmd);
-
return status;
}
*/
static switch_status_t sofia_on_init(switch_core_session_t *session)
{
- switch_channel_t *channel = NULL;
- private_object_t *tech_pvt;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- tech_pvt = (private_object_t *) switch_core_session_get_private(session);
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
tech_pvt->read_frame.buflen = SWITCH_RTP_MAX_BUF_LEN;
static switch_status_t sofia_on_ring(switch_core_session_t *session)
{
- switch_channel_t *channel = NULL;
- private_object_t *tech_pvt = NULL;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- tech_pvt = (private_object_t *) switch_core_session_get_private(session);
+ private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s SOFIA RING\n", switch_channel_get_name(channel));
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s SOFIA RING\n", switch_channel_get_name(switch_core_session_get_channel(session)));
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t sofia_on_reset(switch_core_session_t *session)
{
- switch_channel_t *channel = NULL;
- private_object_t *tech_pvt = NULL;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- tech_pvt = (private_object_t *) switch_core_session_get_private(session);
+ private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s SOFIA RESET\n", switch_channel_get_name(channel));
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s SOFIA RESET\n", switch_channel_get_name(switch_core_session_get_channel(session)));
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t sofia_on_hibernate(switch_core_session_t *session)
{
- switch_channel_t *channel = NULL;
- private_object_t *tech_pvt = NULL;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- tech_pvt = (private_object_t *) switch_core_session_get_private(session);
+ private_object_t *tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s SOFIA HIBERNATE\n", switch_channel_get_name(channel));
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s SOFIA HIBERNATE\n", switch_channel_get_name(switch_core_session_get_channel(session)));
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t sofia_on_execute(switch_core_session_t *session)
{
- switch_channel_t *channel = NULL;
- private_object_t *tech_pvt = NULL;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- tech_pvt = (private_object_t *) switch_core_session_get_private(session);
+ private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s SOFIA EXECUTE\n", switch_channel_get_name(channel));
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s SOFIA EXECUTE\n", switch_channel_get_name(switch_core_session_get_channel(session)));
return SWITCH_STATUS_SUCCESS;
}
switch_status_t sofia_on_hangup(switch_core_session_t *session)
{
switch_core_session_t *a_session;
- private_object_t *tech_pvt;
- switch_channel_t *channel = NULL;
+ private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session);
+ switch_channel_t *channel = switch_core_session_get_channel(session);
switch_call_cause_t cause;
int sip_cause;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- tech_pvt = (private_object_t *) switch_core_session_get_private(session);
- switch_assert(tech_pvt != NULL);
if (tech_pvt->profile->rtpip && tech_pvt->local_sdp_audio_port) {
switch_rtp_release_port(tech_pvt->profile->rtpip, tech_pvt->local_sdp_audio_port);
static switch_status_t sofia_answer_channel(switch_core_session_t *session)
{
- private_object_t *tech_pvt;
- switch_channel_t *channel = NULL;
+ private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session);
+ switch_channel_t *channel = switch_core_session_get_channel(session);
switch_status_t status;
uint32_t session_timeout = 0;
const char *val;
- switch_assert(session != NULL);
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- tech_pvt = (private_object_t *) switch_core_session_get_private(session);
-
if (switch_test_flag(tech_pvt, TFLAG_ANS) || switch_channel_test_flag(channel, CF_OUTBOUND)) {
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t sofia_read_video_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout, switch_io_flag_t flags, int stream_id)
{
- private_object_t *tech_pvt = NULL;
- switch_channel_t *channel = NULL;
+ private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session);
+ switch_channel_t *channel = switch_core_session_get_channel(session);
int payload = 0;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
- tech_pvt = (private_object_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
if (switch_test_flag(tech_pvt, TFLAG_HUP)) {
}
}
-
tech_pvt->video_read_frame.datalen = 0;
-
if (switch_test_flag(tech_pvt, TFLAG_IO)) {
switch_status_t status;
static switch_status_t sofia_write_video_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, switch_io_flag_t flags, int stream_id)
{
- private_object_t *tech_pvt;
- switch_channel_t *channel = NULL;
+ private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session);
+ switch_channel_t *channel = switch_core_session_get_channel(session);
switch_status_t status = SWITCH_STATUS_SUCCESS;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- tech_pvt = (private_object_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
while (!(tech_pvt->video_read_codec.implementation && switch_rtp_ready(tech_pvt->video_rtp_session))) {
static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout, switch_io_flag_t flags, int stream_id)
{
- private_object_t *tech_pvt = NULL;
- switch_channel_t *channel = NULL;
+ private_object_t *tech_pvt = switch_core_session_get_private(session);
+ switch_channel_t *channel = switch_core_session_get_channel(session);
int payload = 0;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
- tech_pvt = (private_object_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
if (!(tech_pvt->profile->pflags & PFLAG_RUNNING)) {
static switch_status_t sofia_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, switch_io_flag_t flags, int stream_id)
{
- private_object_t *tech_pvt;
- switch_channel_t *channel = NULL;
+ private_object_t *tech_pvt = switch_core_session_get_private(session);
+ switch_channel_t *channel = switch_core_session_get_channel(session);
switch_status_t status = SWITCH_STATUS_SUCCESS;
int bytes = 0, samples = 0, frames = 0;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- tech_pvt = (private_object_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
while (!(tech_pvt->read_codec.implementation && switch_rtp_ready(tech_pvt->rtp_session))) {
static switch_status_t sofia_kill_channel(switch_core_session_t *session, int sig)
{
- private_object_t *tech_pvt;
- switch_channel_t *channel = NULL;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
+ private_object_t *tech_pvt = switch_core_session_get_private(session);
- tech_pvt = (private_object_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
-
switch (sig) {
case SWITCH_SIG_BREAK:
if (switch_rtp_ready(tech_pvt->rtp_session)) {
static switch_status_t sofia_waitfor_read(switch_core_session_t *session, int ms, int stream_id)
{
- private_object_t *tech_pvt;
- switch_channel_t *channel = NULL;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- tech_pvt = (private_object_t *) switch_core_session_get_private(session);
- switch_assert(tech_pvt != NULL);
-
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t sofia_waitfor_write(switch_core_session_t *session, int ms, int stream_id)
{
- private_object_t *tech_pvt;
- switch_channel_t *channel = NULL;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- tech_pvt = (private_object_t *) switch_core_session_get_private(session);
- switch_assert(tech_pvt != NULL);
-
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t sofia_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg)
{
- switch_channel_t *channel;
- private_object_t *tech_pvt;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ private_object_t *tech_pvt = switch_core_session_get_private(session);
switch_status_t status;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- tech_pvt = (private_object_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
if (msg->message_id == SWITCH_MESSAGE_INDICATE_ANSWER || msg->message_id == SWITCH_MESSAGE_INDICATE_PROGRESS) {
static switch_status_t sofia_receive_event(switch_core_session_t *session, switch_event_t *event)
{
- switch_channel_t *channel;
- struct private_object *tech_pvt;
+ struct private_object *tech_pvt = switch_core_session_get_private(session);
char *body;
nua_handle_t *msg_nh;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
if (!(body = switch_event_get_body(event))) {
sip_t const *sip,
tagi_t tags[])
{
- switch_channel_t *channel = NULL;
-
if (session) {
const char *tmp;
-
- channel = switch_core_session_get_channel(session);
+ switch_channel_t *channel = switch_core_session_get_channel(session);
if (sip->sip_user_agent && !switch_strlen_zero(sip->sip_user_agent->g_string)){
switch_channel_set_variable(channel, "sip_user_agent", sip->sip_user_agent->g_string);
}
char const *phrase,
nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[])
{
-
-
if (sip && session) {
switch_channel_t *channel = switch_core_session_get_channel(session);
const char *uuid;
if (session) {
channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
switch_assert(tech_pvt->nh != NULL);
sip_from_t const *from;
sip_to_t const *to;
sip_refer_to_t const *refer_to;
- private_object_t *tech_pvt = NULL;
+ private_object_t *tech_pvt = switch_core_session_get_private(session);
char *etmp = NULL, *exten = NULL;
- switch_channel_t *channel_a = NULL, *channel_b = NULL;
+ switch_channel_t *channel_a = switch_core_session_get_channel(session);
+ switch_channel_t *channel_b = NULL;
su_home_t *home = NULL;
char *full_ref_by = NULL;
char *full_ref_to = NULL;
- tech_pvt = switch_core_session_get_private(session);
- channel_a = switch_core_session_get_channel(session);
-
if (!sip->sip_cseq || !(etmp = switch_mprintf("refer;id=%u", sip->sip_cseq->cs_seq))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error!\n");
goto done;
}
-
if (switch_channel_test_flag(channel_a, CF_BYPASS_MEDIA)) {
nua_notify(tech_pvt->nh, NUTAG_NEWSUB(1), SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
NUTAG_SUBSTATE(nua_substate_terminated), SIPTAG_PAYLOAD_STR("SIP/2.0 403 Forbidden"), SIPTAG_EVENT_STR(etmp), TAG_END());
void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, switch_core_session_t *session, sip_t const *sip, tagi_t tags[])
{
- struct private_object *tech_pvt = NULL;
- switch_channel_t *channel = NULL;
/* placeholder for string searching */
const char *signal_ptr;
const char *rec_header;
if (session) {
/* Get the channel */
- channel = switch_core_session_get_channel(session);
-
- /* Barf if we didn't get it */
- switch_assert(channel != NULL);
-
+ switch_channel_t *channel = switch_core_session_get_channel(session);
/* make sure we have our privates */
- tech_pvt = switch_core_session_get_private(session);
-
+ struct private_object *tech_pvt = switch_core_session_get_private(session);
+
/* Barf if we didn't get it */
switch_assert(tech_pvt != NULL);
}
}
}
-
return;
}
}
-
-
return;
fail:
-
nua_respond(nh, 488, "Unsupported Request", NUTAG_WITH_THIS(nua), TAG_END());
-
}
tech_pvt->te = profile->te;
}
-
tech_pvt->dtmf_type = profile->dtmf_type;
-
if (tech_pvt->bcng_pt) {
tech_pvt->cng_pt = tech_pvt->bcng_pt;
} else if (!tech_pvt->cng_pt) {
tech_pvt->channel = switch_core_session_get_channel(session);
switch_core_session_set_private(session, tech_pvt);
-
switch_snprintf(name, sizeof(name), "sofia/%s/%s", profile->name, channame);
switch_channel_set_name(tech_pvt->channel, name);
}
char *alert_info = NULL;
const char *max_forwards = NULL;
const char *alertbuf;
- private_object_t *tech_pvt;
- switch_channel_t *channel = NULL;
+ private_object_t *tech_pvt = switch_core_session_get_private(session);
+ switch_channel_t *channel = switch_core_session_get_channel(session);
switch_caller_profile_t *caller_profile;
const char *cid_name, *cid_num;
char *e_dest = NULL;
const char *val;
const char *rep;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
rep = switch_channel_get_variable(channel, SOFIA_REPLACES_HEADER);
- tech_pvt = (private_object_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
switch_clear_flag_locked(tech_pvt, TFLAG_SDP);
void sofia_glue_do_xfer_invite(switch_core_session_t *session)
{
- private_object_t *tech_pvt;
- switch_channel_t *channel = NULL;
+ private_object_t *tech_pvt = switch_core_session_get_private(session);
+ switch_channel_t *channel = switch_core_session_get_channel(session);
switch_caller_profile_t *caller_profile;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- tech_pvt = (private_object_t *) switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
caller_profile = switch_channel_get_caller_profile(channel);
{
uint8_t match = 0;
switch_payload_t te = 0, cng_pt = 0;
- private_object_t *tech_pvt;
+ private_object_t *tech_pvt = switch_core_session_get_private(session);
sdp_media_t *m;
sdp_attribute_t *attr;
int first = 0, last = 0;
int ptime = 0, dptime = 0;
int sendonly = 0;
int greedy = 0, x = 0, skip = 0, mine = 0;
- switch_channel_t *channel = NULL;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
const char *val;
const char *crypto = NULL;
int got_crypto = 0;
- tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
greedy = !!(tech_pvt->profile->pflags & PFLAG_GREEDY);
if (!greedy) {
if ((val = switch_channel_get_variable(tech_pvt->channel, SWITCH_SIGNAL_BOND_VARIABLE))
&& (other_session = switch_core_session_locate(val))) {
other_channel = switch_core_session_get_channel(other_session);
- switch_assert(other_channel != NULL);
switch_channel_set_variable(other_channel, SWITCH_B_SDP_VARIABLE, sdp);
if (!switch_test_flag(tech_pvt, TFLAG_CHANGE_MEDIA) && (switch_channel_test_flag(other_channel, CF_OUTBOUND) &&
cancel:
if (session) {
- switch_channel_t *channel = switch_core_session_get_channel(session);
- switch_channel_hangup(channel, SWITCH_CAUSE_MANDATORY_IE_MISSING);
+ switch_channel_hangup(switch_core_session_get_channel(session), SWITCH_CAUSE_MANDATORY_IE_MISSING);
} else {
nua_cancel(nh, TAG_END());
}
*/
static switch_status_t woomera_on_init(switch_core_session_t *session)
{
- switch_channel_t *channel;
- struct private_object *tech_pvt = NULL;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ struct private_object *tech_pvt = switch_core_session_get_private(session);
int rate = 8000;
- tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
tech_pvt->frame.data = tech_pvt->databuf;
if (switch_core_codec_init
static switch_status_t woomera_on_ring(switch_core_session_t *session)
{
- switch_channel_t *channel = NULL;
- struct private_object *tech_pvt = NULL;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- tech_pvt = switch_core_session_get_private(session);
- switch_assert(tech_pvt != NULL);
-
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s WOOMERA RING\n", switch_channel_get_name(channel));
-
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s WOOMERA RING\n", switch_channel_get_name(switch_core_session_get_channel(session)));
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t woomera_on_execute(switch_core_session_t *session)
{
-
- switch_channel_t *channel = NULL;
- struct private_object *tech_pvt = NULL;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- tech_pvt = switch_core_session_get_private(session);
- switch_assert(tech_pvt != NULL);
-
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s WOOMERA EXECUTE\n", switch_channel_get_name(channel));
-
-
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s WOOMERA EXECUTE\n", switch_channel_get_name(switch_core_session_get_channel(session)));
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t woomera_on_hangup(switch_core_session_t *session)
{
- switch_channel_t *channel = NULL;
- struct private_object *tech_pvt = NULL;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- tech_pvt = switch_core_session_get_private(session);
+ struct private_object *tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
switch_core_codec_destroy(&tech_pvt->read_codec);
switch_core_codec_destroy(&tech_pvt->write_codec);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s WOOMERA HANGUP\n", switch_channel_get_name(channel));
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s WOOMERA HANGUP\n", switch_channel_get_name(switch_core_session_get_channel(session)));
tech_destroy(tech_pvt);
return SWITCH_STATUS_SUCCESS;
static switch_status_t woomera_kill_channel(switch_core_session_t *session, int sig)
{
- switch_channel_t *channel = NULL;
- struct private_object *tech_pvt = NULL;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- tech_pvt = switch_core_session_get_private(session);
+ struct private_object *tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
if (!tech_pvt->udp_socket) {
switch (sig) {
case SWITCH_SIG_KILL:
udp_socket_close(tech_pvt);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s WOOMERA KILL\n", switch_channel_get_name(channel));
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s WOOMERA KILL\n", switch_channel_get_name(switch_core_session_get_channel(session)));
break;
case SWITCH_SIG_BREAK:
{
break;
}
-
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t woomera_read_frame(switch_core_session_t *session, switch_frame_t **frame, int timeout, switch_io_flag_t flags, int stream_id)
{
- switch_channel_t *channel = NULL;
- struct private_object *tech_pvt = NULL;
+ struct private_object *tech_pvt = switch_core_session_get_private(session);
switch_frame_t *pframe;
switch_size_t len;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
for(;;) {
switch_yield(1000);
}
-
if (!tech_pvt->udp_socket) {
return SWITCH_STATUS_GENERR;
}
- /*
- if ((status = woomera_waitfor_read(session, -1)) != SWITCH_STATUS_SUCCESS) {
- return status;
- }1<
- */
+
pframe = &tech_pvt->frame;
*frame = pframe;
static switch_status_t woomera_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, switch_io_flag_t flags, int stream_id)
{
- switch_channel_t *channel = NULL;
- struct private_object *tech_pvt = NULL;
+ struct private_object *tech_pvt = switch_core_session_get_private(session);
switch_size_t len;
- //switch_frame_t *pframe;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
if (switch_test_flag(tech_pvt, TFLAG_ABORT) || !tech_pvt->udp_socket) {
return SWITCH_STATUS_SUCCESS;
}
- //pframe = &tech_pvt->frame;
len = frame->datalen;
if (switch_socket_sendto(tech_pvt->udp_socket, tech_pvt->udpwrite, 0, frame->data, &len) == SWITCH_STATUS_SUCCESS) {
frame->datalen = (uint32_t) len;
static void *woomera_channel_thread_run(switch_thread_t * thread, void *obj)
{
switch_core_session_t *session = obj;
- switch_channel_t *channel = NULL;
- struct private_object *tech_pvt = NULL;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ struct private_object *tech_pvt = switch_core_session_get_private(session);
woomera_message wmsg;
int res = 0;
- switch_assert(session != NULL);
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
if (!tech_pvt->udp_socket) {
tech_create_read_socket(tech_pvt);
}
-
for (;;) {
if (globals.panic) {
switch_set_flag_locked(tech_pvt, TFLAG_ABORT);
memset(tech_pvt->dtmfbuf, 0, sizeof(tech_pvt->dtmfbuf));
switch_mutex_unlock(tech_pvt->iolock);
}
-#if 1==0 /*convert to use switch_time_now */
- if (tech_pvt->timeout) {
- struct timeval now;
- int elapsed;
- gettimeofday(&now, NULL);
- elapsed = (((now.tv_sec * 1000) + now.tv_usec / 1000) - ((tech_pvt->started.tv_sec * 1000) + tech_pvt->started.tv_usec / 1000));
- if (elapsed > tech_pvt->timeout) {
- /* call timed out! */
- switch_set_flag_locked(tech_pvt, TFLAG_ABORT);
- }
- }
-#endif
if (!tech_pvt->command_channel) {
break;
switch_set_flag_locked(tech_pvt, TFLAG_ABORT);
continue;
} else if (!strcasecmp(wmsg.command, "DTMF")) {
- /*
- struct ast_frame dtmf_frame = {AST_FRAME_DTMF};
- int x = 0;
- for (x = 0; x < strlen(wmsg.command_args); x++) {
- dtmf_frame.subclass = wmsg.command_args[x];
- ast_queue_frame(tech_pvt->owner, ast_frdup(&dtmf_frame));
- if (globals.debug > 1) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, WOOMERA_DEBUG_PREFIX "SEND DTMF [%c] to %s\n", dtmf_frame.subclass, tech_pvt->owner->name);
- }
- }
- */
} else if (!strcasecmp(wmsg.command, "PROCEED")) {
/* This packet has lots of info so well keep it */
tech_pvt->call_info = wmsg;
return NULL;
}
-
-
-
static void *woomera_thread_run(void *obj)
{
-
int res = 0;
woomera_message wmsg;
woomera_profile *profile;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ALERT, "{%s} HELP! I lost my connection to woomera!\n", profile->name);
woomera_socket_close(&profile->woomera_socket);
- //global_set_flag(TFLAG_ABORT);
globals.panic = 1;
continue;
-
- /* Can't get to the following code --Commented out for now. */
-/* if (profile->woomera_socket)
- if (switch_test_flag(profile, PFLAG_INBOUND)) {
- woomera_printf(profile, profile->woomera_socket, "LISTEN%s", WOOMERA_RECORD_SEPERATOR);
- if (woomera_message_parse(profile->woomera_socket,
- &wmsg, WOOMERA_HARD_TIMEOUT, profile, &profile->event_queue) < 0) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "{%s} HELP! Woomera is broken!\n",
- profile->name);
- globals.panic = 1;
- woomera_socket_close(&profile->woomera_socket);
- }
- }
- if (profile->woomera_socket) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Woomera Thread Up {%s} %s/%d\n", profile->name,
- profile->woomera_host, profile->woomera_port);
- }
- }*/
- //continue;
}
if (!strcasecmp(wmsg.command, "INCOMING")) {
switch_yield(100);
}
-
if (profile->woomera_socket) {
woomera_printf(profile, profile->woomera_socket, "BYE%s", WOOMERA_RECORD_SEPERATOR);
woomera_socket_close(&profile->woomera_socket);
SWITCH_MODULE_RUNTIME_FUNCTION(mod_woomera_runtime)
{
-
woomera_thread_run(&default_profile);
return SWITCH_STATUS_TERM;
if (listener->session) {
switch_channel_t *channel = switch_core_session_get_channel(listener->session);
- switch_assert(channel != NULL);
if (!strncasecmp(cmd, "connect", 7)) {
switch_snprintf(reply, reply_len, "+OK");
}
if ((session = switch_core_session_locate(uuid))) {
- switch_channel_t *channel = switch_core_session_get_channel(session);
- if (!switch_channel_test_flag(channel, CF_CONTROLLED)) {
+ if (!switch_channel_test_flag(switch_core_session_get_channel(session), CF_CONTROLLED)) {
switch_core_session_rwunlock(session);
session = NULL;
}
static JSBool session_flush_digits(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
{
struct js_session *jss = JS_GetPrivate(cx, obj);
- switch_channel_t *channel;
-
METHOD_SANITY_CHECK();
- channel = switch_core_session_get_channel(jss->session);
- switch_assert(channel != NULL);
-
- switch_channel_flush_dtmf(channel);
+ switch_channel_flush_dtmf(switch_core_session_get_channel(jss->session));
*rval = BOOLEAN_TO_JSVAL(JS_TRUE);
return JS_TRUE;
{
struct js_session *jss = JS_GetPrivate(cx, obj);
switch_event_t *event;
- switch_channel_t *channel;
if (!jss || !jss->session) {
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
return JS_TRUE;
}
- channel = switch_core_session_get_channel(jss->session);
- switch_assert(channel != NULL);
-
while (switch_core_session_dequeue_event(jss->session, &event) == SWITCH_STATUS_SUCCESS) {
switch_event_destroy(&event);
}
switch_input_args_t args = { 0 };
METHOD_SANITY_CHECK();
-
channel = switch_core_session_get_channel(jss->session);
- switch_assert(channel != NULL);
-
CHANNEL_SANITY_CHECK();
if (argc > 0) {
switch_input_args_t args = { 0 };
METHOD_SANITY_CHECK();
-
channel = switch_core_session_get_channel(jss->session);
- switch_assert(channel != NULL);
-
CHANNEL_SANITY_CHECK();
if (argc > 0) {
switch_input_args_t args = { 0 };
METHOD_SANITY_CHECK();
-
channel = switch_core_session_get_channel(jss->session);
- switch_assert(channel != NULL);
-
CHANNEL_SANITY_CHECK();
if (argc > 0) {
static switch_status_t hanguphook(switch_core_session_t *session)
{
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
struct js_session *jss = NULL;
- switch_channel_state_t state;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- state = switch_channel_get_state(channel);
if ((jss = switch_channel_get_private(channel, "jss"))) {
+ switch_channel_state_t state = switch_channel_get_state(channel);
if (jss->hook_state != state) {
jss->hook_state = state;
check_hangup_hook(jss);
if (argc > 0) {
if ((function = JS_ValueToFunction(cx, argv[0]))) {
switch_channel_t *channel = switch_core_session_get_channel(jss->session);
- switch_assert(channel != NULL);
jss->on_hangup = function;
jss->hook_state = switch_channel_get_state(channel);
switch_channel_set_private(channel, "jss", jss);
char posbuf[35] = "";
METHOD_SANITY_CHECK();
-
channel = switch_core_session_get_channel(jss->session);
- switch_assert(channel != NULL);
-
CHANNEL_SANITY_CHECK();
if (argc > 0) {
switch_channel_t *channel;
METHOD_SANITY_CHECK();
-
channel = switch_core_session_get_channel(jss->session);
- switch_assert(channel != NULL);
if (argc > 1) {
char *var, *val;
}
channel = switch_core_session_get_channel(jss->session);
- switch_assert(channel != NULL);
if (argc > 0) {
const char *var, *val;
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
channel = switch_core_session_get_channel(jss->session);
- switch_assert(channel != NULL);
-
CHANNEL_SANITY_CHECK();
if (argc < 3) {
switch_channel_t *channel;
METHOD_SANITY_CHECK();
-
channel = switch_core_session_get_channel(jss->session);
- switch_assert(channel != NULL);
-
CHANNEL_SANITY_CHECK();
if (argc > 0) {
switch_channel_t *channel;
METHOD_SANITY_CHECK();
-
channel = switch_core_session_get_channel(jss->session);
- switch_assert(channel != NULL);
-
CHANNEL_SANITY_CHECK_ANSWER();
switch_channel_answer(channel);
switch_channel_t *channel;
METHOD_SANITY_CHECK();
-
channel = switch_core_session_get_channel(jss->session);
- switch_assert(channel != NULL);
-
CHANNEL_SANITY_CHECK_ANSWER();
switch_channel_pre_answer(channel);
static JSBool session_ready(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
{
struct js_session *jss = JS_GetPrivate(cx, obj);
- switch_channel_t *channel;
METHOD_SANITY_CHECK();
- channel = switch_core_session_get_channel(jss->session);
- switch_assert(channel != NULL);
-
- *rval = BOOLEAN_TO_JSVAL(switch_channel_ready(channel) ? JS_TRUE : JS_FALSE);
+ *rval = BOOLEAN_TO_JSVAL(switch_channel_ready(switch_core_session_get_channel(jss->session)) ? JS_TRUE : JS_FALSE);
return JS_TRUE;
}
METHOD_SANITY_CHECK();
channel = switch_core_session_get_channel(jss->session);
- switch_assert(channel != NULL);
started = switch_timestamp_now();
jsrefcount saveDepth;
METHOD_SANITY_CHECK();
-
channel = switch_core_session_get_channel(jss->session);
- switch_assert(channel != NULL);
started = switch_timestamp_now();
METHOD_SANITY_CHECK();
channel = switch_core_session_get_channel(jss->session);
- switch_assert(channel != NULL);
-
- /* you can execute some apps before you answer */
- /* CHANNEL_SANITY_CHECK(); */
+ /* you can execute some apps before you answer CHANNEL_SANITY_CHECK(); */
if (argc > 0) {
const switch_application_interface_t *application_interface;
switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
METHOD_SANITY_CHECK();
-
channel = switch_core_session_get_channel(jss->session);
- switch_assert(channel != NULL);
-
CHANNEL_SANITY_CHECK();
if (argc > 1) {
if (jss && jss->session) {
channel = switch_core_session_get_channel(jss->session);
- switch_assert(channel != NULL);
caller_profile = switch_channel_get_caller_profile(channel);
}
static switch_status_t de_say_general_count(switch_core_session_t *session,
char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
{
- switch_channel_t *channel;
int in;
int x = 0;
int places[9] = { 0 };
char sbuf[13] = "";
switch_status_t status;
- switch_assert(session != NULL);
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
static switch_status_t de_say_money(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method,
switch_input_args_t *args)
{
- switch_channel_t *channel;
-
char sbuf[16] = ""; /* enough for 999,999,999,999.99 (w/o the commas or leading $) */
char *dollars = NULL;
char *cents = NULL;
- switch_assert(session != NULL);
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
static switch_status_t en_say_general_count(switch_core_session_t *session,
char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
{
- switch_channel_t *channel;
int in;
int x = 0;
int places[9] = { 0 };
char sbuf[13] = "";
switch_status_t status;
- switch_assert(session != NULL);
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
static switch_status_t en_say_money(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method,
switch_input_args_t *args)
{
- switch_channel_t *channel;
-
char sbuf[16] = ""; /* enough for 999,999,999,999.99 (w/o the commas or leading $) */
char *dollars = NULL;
char *cents = NULL;
- switch_assert(session != NULL);
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
static switch_status_t es_say_general_count(switch_core_session_t *session,
char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
{
- switch_channel_t *channel;
int in;
int x = 0;
int places[9] = { 0 };
char sbuf[13] = "";
switch_status_t status;
- switch_assert(session != NULL);
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
static switch_status_t es_say_money(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method,
switch_input_args_t *args)
{
- switch_channel_t *channel;
-
char sbuf[16] = ""; /* enough for 999,999,999,999.99 (w/o the commas or leading $) */
char *dollars = NULL;
char *cents = NULL;
- switch_assert(session != NULL);
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
static switch_status_t fr_say_general_count(switch_core_session_t *session,
char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
{
- switch_channel_t *channel;
int in;
int x = 0;
int places[9] = { 0 };
char sbuf[13] = "";
switch_status_t status;
- switch_assert(session != NULL);
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
static switch_status_t fr_say_money(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method,
switch_input_args_t *args)
{
- switch_channel_t *channel;
-
char sbuf[16] = ""; /* enough for 999,999,999,999.99 (w/o the commas or leading $) */
char *dollars = NULL;
char *cents = NULL;
- switch_assert(session != NULL);
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
static switch_status_t it_say_general_count(switch_core_session_t *session,
char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
{
- switch_channel_t *channel;
int in;
int x = 0;
int places[9] = { 0 };
char sbuf[13] = "";
switch_status_t status;
- switch_assert(session != NULL);
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
static switch_status_t it_say_money(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method,
switch_input_args_t *args)
{
- switch_channel_t *channel;
-
char sbuf[16] = ""; /* enough for 999,999,999,999.99 (w/o the commas or leading $) */
char *dollars = NULL;
char *cents = NULL;
- switch_assert(session != NULL);
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
static switch_status_t nl_say_general_count(switch_core_session_t *session,
char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
{
- switch_channel_t *channel;
int in;
int x = 0;
int places[9] = { 0 };
char sbuf[13] = "";
switch_status_t status;
- switch_assert(session != NULL);
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
static switch_status_t nl_say_money(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method,
switch_input_args_t *args)
{
- switch_channel_t *channel;
-
char sbuf[16] = ""; /* enough for 999,999,999,999.99 (w/o the commas or leading $) */
char *dollars = NULL;
char *cents = NULL;
- switch_assert(session != NULL);
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
return SWITCH_STATUS_GENERR;
SWITCH_DECLARE(switch_call_cause_t) switch_channel_get_cause(switch_channel_t *channel)
{
- switch_assert(channel != NULL);
return channel->hangup_cause;
}
{
switch_channel_timetable_t *times = NULL;
- switch_assert(channel != NULL);
if (channel->caller_profile) {
switch_mutex_lock(channel->profile_mutex);
times = channel->caller_profile->times;
if (((*channel) = switch_core_alloc(pool, sizeof(switch_channel_t))) == 0) {
return SWITCH_STATUS_MEMERR;
}
-
+
switch_event_create(&(*channel)->variables, SWITCH_EVENT_MESSAGE);
-
+
switch_core_hash_init(&(*channel)->private_hash, pool);
switch_queue_create(&(*channel)->dtmf_queue, 128, pool);
{
switch_size_t has;
- switch_assert(channel != NULL);
switch_mutex_lock(channel->dtmf_mutex);
has = switch_queue_size(channel->dtmf_queue);
switch_mutex_unlock(channel->dtmf_mutex);
switch_status_t status;
void *pop;
- switch_assert(channel != NULL);
-
switch_mutex_lock(channel->dtmf_mutex);
if ((status = switch_core_session_recv_dtmf(channel->session, dtmf) != SWITCH_STATUS_SUCCESS)) {
if (++x > 100) {
status = SWITCH_STATUS_FALSE;
free(dt);
- goto done;
+ goto done;
}
}
}
-
+
status = SWITCH_STATUS_SUCCESS;
- done:
+done:
switch_mutex_unlock(channel->dtmf_mutex);
char *string;
int i, argc;
char *argv[256];
-
-
- switch_assert(channel != NULL);
if (switch_strlen_zero(dtmf_string)) {
return SWITCH_STATUS_FALSE;
string = switch_core_session_strdup(channel->session, dtmf_string);
argc = switch_separate_string(string, '+', argv, (sizeof(argv) / sizeof(argv[0])));
-
+
for(i = 0; i < argc; i++) {
dtmf.duration = SWITCH_DEFAULT_DTMF_DURATION;
dur = SWITCH_DEFAULT_DTMF_DURATION / 8;
dtmf.digit = *p;
if (switch_channel_queue_dtmf(channel, &dtmf) == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Queue dtmf\ndigit=%c ms=%u samples=%u\n",
- switch_channel_get_name(channel), dtmf.digit, dur, dtmf.duration);
+ switch_channel_get_name(channel), dtmf.digit, dur, dtmf.duration);
sent++;
}
}
}
-
+
}
return sent ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
switch_dtmf_t *dt;
switch_status_t status = SWITCH_STATUS_FALSE;
- switch_assert(channel != NULL);
-
switch_mutex_lock(channel->dtmf_mutex);
if (switch_queue_trypop(channel->dtmf_queue, &pop) == SWITCH_STATUS_SUCCESS) {
dt = (switch_dtmf_t *) pop;
+ /* TODO: Shouldn't we be doing a memcpy here? */
*dtmf = *dt;
free(dt);
status = SWITCH_STATUS_SUCCESS;
}
switch_mutex_unlock(channel->dtmf_mutex);
-
+
if (status == SWITCH_STATUS_SUCCESS && switch_event_create(&event, SWITCH_EVENT_DTMF) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(channel, event);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "DTMF-Digit", "%c", dtmf->digit);
switch_mutex_lock(channel->profile_mutex);
if (!(v = switch_event_get_header(channel->variables, (char*)varname))) {
switch_caller_profile_t *cp = channel->caller_profile;
-
+
if (cp) {
if (!strncmp(varname, "aleg_", 5)) {
cp = cp->originator_caller_profile;
}
channel->vi = 0;
switch_mutex_unlock(channel->profile_mutex);
-
+
}
SWITCH_DECLARE(switch_event_header_t *) switch_channel_variable_first(switch_channel_t *channel)
SWITCH_DECLARE(switch_status_t) switch_channel_set_variable(switch_channel_t *channel, const char *varname, const char *value)
{
switch_assert(channel != NULL);
-
+
if (!switch_strlen_zero(varname)) {
switch_mutex_lock(channel->profile_mutex);
switch_event_del_header(channel->variables, varname);
{
const char *uuid;
switch_assert(channel != NULL);
-
+
if (!switch_strlen_zero(varname)) {
if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) {
switch_core_session_t *session;
{
switch_channel_state_t state, mystate, ostate;
ostate = switch_channel_get_state(channel);
-
+
for(;;) {
state = switch_channel_get_running_state(other_channel);
mystate = switch_channel_get_running_state(channel);
-
+
if (mystate != ostate || state >= CS_HANGUP || state == want_state) {
break;
}
return SWITCH_STATUS_TIMEOUT;
}
}
-
+
return SWITCH_STATUS_SUCCESS;
}
uint8_t ret = 0;
switch_assert(channel != NULL);
-
+
if (!channel->hangup_cause && channel->state > CS_RING && channel->state < CS_HANGUP && channel->state != CS_RESET &&
!switch_test_flag(channel, CF_TRANSFER)) {
- ret++;
+ ret++;
}
return ret;
{
switch_mutex_lock(channel->flag_mutex);
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG, "%s Running State Change %s\n",
- channel->name, state_names[channel->state]);
+ channel->name, state_names[channel->state]);
channel->running_state = channel->state;
if (channel->state_flags) {
channel->flags |= channel->state_flags;
channel->state_flags = 0;
}
-
+
if (channel->state >= CS_RING) {
switch_clear_flag(channel, CF_TRANSFER);
switch_channel_presence(channel, "unknown", (char *) state_names[channel->state]);
}
-
+
if (channel->state < CS_HANGUP) {
switch_event_t *event;
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_STATE) == SWITCH_STATUS_SUCCESS) {
}
/* STUB for more dev
- case CS_INIT:
- switch(state) {
-
- case CS_NEW:
- case CS_INIT:
- case CS_LOOPBACK:
- case CS_TRANSMIT:
- case CS_RING:
- case CS_EXECUTE:
- case CS_HANGUP:
- case CS_DONE:
-
- default:
- break;
- }
- break;
- */
+ case CS_INIT:
+ switch(state) {
- switch (last_state) {
case CS_NEW:
- case CS_RESET:
- switch (state) {
- default:
- ok++;
- break;
- }
- break;
-
case CS_INIT:
- switch (state) {
- case CS_LOOPBACK:
- case CS_TRANSMIT:
- case CS_RING:
- case CS_EXECUTE:
- case CS_PARK:
- case CS_HOLD:
- case CS_HIBERNATE:
- case CS_RESET:
- ok++;
- default:
- break;
- }
- break;
-
case CS_LOOPBACK:
- switch (state) {
- case CS_TRANSMIT:
- case CS_RING:
- case CS_EXECUTE:
- case CS_PARK:
- case CS_HOLD:
- case CS_HIBERNATE:
- case CS_RESET:
- ok++;
- default:
- break;
- }
- break;
-
case CS_TRANSMIT:
- switch (state) {
- case CS_LOOPBACK:
- case CS_RING:
- case CS_EXECUTE:
- case CS_PARK:
- case CS_HOLD:
- case CS_HIBERNATE:
- case CS_RESET:
- ok++;
- default:
- break;
- }
- break;
-
- case CS_PARK:
- switch (state) {
- case CS_LOOPBACK:
- case CS_RING:
- case CS_EXECUTE:
- case CS_TRANSMIT:
- case CS_HIBERNATE:
- case CS_RESET:
- case CS_HOLD:
- ok++;
- default:
- break;
- }
- break;
-
- case CS_HOLD:
- switch (state) {
- case CS_LOOPBACK:
- case CS_RING:
- case CS_EXECUTE:
- case CS_TRANSMIT:
- case CS_HIBERNATE:
- case CS_RESET:
- case CS_PARK:
- ok++;
- default:
- break;
- }
- break;
- case CS_HIBERNATE:
- switch (state) {
- case CS_LOOPBACK:
- case CS_INIT:
- case CS_RING:
- case CS_EXECUTE:
- case CS_TRANSMIT:
- case CS_PARK:
- case CS_HOLD:
- case CS_RESET:
- ok++;
- default:
- break;
- }
- break;
-
case CS_RING:
- switch (state) {
- case CS_LOOPBACK:
- case CS_EXECUTE:
- case CS_TRANSMIT:
- case CS_PARK:
- case CS_HOLD:
- case CS_HIBERNATE:
- case CS_RESET:
- ok++;
- default:
- break;
- }
- break;
-
case CS_EXECUTE:
- switch (state) {
- case CS_LOOPBACK:
- case CS_TRANSMIT:
- case CS_RING:
- case CS_PARK:
- case CS_HOLD:
- case CS_HIBERNATE:
- case CS_RESET:
- ok++;
- default:
- break;
- }
- break;
-
case CS_HANGUP:
- switch (state) {
- case CS_DONE:
- ok++;
- default:
- break;
- }
- break;
+ case CS_DONE:
default:
- break;
+ break;
+ }
+ break;
+ */
+
+ switch (last_state) {
+case CS_NEW:
+case CS_RESET:
+ switch (state) {
+default:
+ ok++;
+ break;
+ }
+ break;
+
+case CS_INIT:
+ switch (state) {
+case CS_LOOPBACK:
+case CS_TRANSMIT:
+case CS_RING:
+case CS_EXECUTE:
+case CS_PARK:
+case CS_HOLD:
+case CS_HIBERNATE:
+case CS_RESET:
+ ok++;
+default:
+ break;
+ }
+ break;
+
+case CS_LOOPBACK:
+ switch (state) {
+case CS_TRANSMIT:
+case CS_RING:
+case CS_EXECUTE:
+case CS_PARK:
+case CS_HOLD:
+case CS_HIBERNATE:
+case CS_RESET:
+ ok++;
+default:
+ break;
+ }
+ break;
+
+case CS_TRANSMIT:
+ switch (state) {
+case CS_LOOPBACK:
+case CS_RING:
+case CS_EXECUTE:
+case CS_PARK:
+case CS_HOLD:
+case CS_HIBERNATE:
+case CS_RESET:
+ ok++;
+default:
+ break;
+ }
+ break;
+
+case CS_PARK:
+ switch (state) {
+case CS_LOOPBACK:
+case CS_RING:
+case CS_EXECUTE:
+case CS_TRANSMIT:
+case CS_HIBERNATE:
+case CS_RESET:
+case CS_HOLD:
+ ok++;
+default:
+ break;
+ }
+ break;
+
+case CS_HOLD:
+ switch (state) {
+case CS_LOOPBACK:
+case CS_RING:
+case CS_EXECUTE:
+case CS_TRANSMIT:
+case CS_HIBERNATE:
+case CS_RESET:
+case CS_PARK:
+ ok++;
+default:
+ break;
+ }
+ break;
+case CS_HIBERNATE:
+ switch (state) {
+case CS_LOOPBACK:
+case CS_INIT:
+case CS_RING:
+case CS_EXECUTE:
+case CS_TRANSMIT:
+case CS_PARK:
+case CS_HOLD:
+case CS_RESET:
+ ok++;
+default:
+ break;
+ }
+ break;
+
+case CS_RING:
+ switch (state) {
+case CS_LOOPBACK:
+case CS_EXECUTE:
+case CS_TRANSMIT:
+case CS_PARK:
+case CS_HOLD:
+case CS_HIBERNATE:
+case CS_RESET:
+ ok++;
+default:
+ break;
+ }
+ break;
+
+case CS_EXECUTE:
+ switch (state) {
+case CS_LOOPBACK:
+case CS_TRANSMIT:
+case CS_RING:
+case CS_PARK:
+case CS_HOLD:
+case CS_HIBERNATE:
+case CS_RESET:
+ ok++;
+default:
+ break;
+ }
+ break;
+
+case CS_HANGUP:
+ switch (state) {
+case CS_DONE:
+ ok++;
+default:
+ break;
+ }
+ break;
+
+default:
+ break;
}
if (ok) {
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG, "%s State Change %s -> %s\n",
- channel->name, state_names[last_state], state_names[state]);
+ channel->name, state_names[last_state], state_names[state]);
switch_mutex_lock(channel->flag_mutex);
channel->state = state;
switch_mutex_unlock(channel->flag_mutex);
}
} else {
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_WARNING,
- "%s Invalid State Change %s -> %s\n", channel->name, state_names[last_state], state_names[state]);
+ "%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_assert(0);
}
}
- done:
+done:
switch_mutex_unlock(channel->flag_mutex);
return channel->state;
if (caller_profile) {
switch_caller_profile_event_set_data(caller_profile, "Caller", event);
}
-
+
if (originator_caller_profile && originatee_caller_profile) {
/* Index Originator's Profile */
switch_caller_profile_event_set_data(originator_caller_profile, "Originator", event);
vvar = (char *) hi->name;
vval = (char *) hi->value;
x++;
-
+
switch_assert(vvar && vval);
switch_snprintf(buf, sizeof(buf), "variable_%s", vvar);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, buf, "%s", vval);
switch_assert(channel->session != NULL);
switch_mutex_lock(channel->profile_mutex);
switch_assert(caller_profile != NULL);
-
+
uuid = switch_core_session_get_uuid(channel->session);
-
+
if (!caller_profile->uuid || strcasecmp(caller_profile->uuid, uuid)) {
caller_profile->uuid = switch_core_session_strdup(channel->session, uuid);
}
profile = channel->caller_profile->originator_caller_profile;
}
switch_mutex_unlock(channel->profile_mutex);
-
+
return profile;
}
profile = channel->caller_profile->originatee_caller_profile;
}
switch_mutex_unlock(channel->profile_mutex);
-
+
return profile;
}
channel->state_handlers[index] = state_handler;
- end:
+end:
switch_mutex_unlock(channel->flag_mutex);
return index;
}
}
switch_channel_stop_broadcast(channel);
-
+
if (channel->state < CS_HANGUP) {
switch_event_t *event;
switch_channel_state_t last_state = channel->state;
-
+
channel->state = CS_HANGUP;
channel->hangup_cause = hangup_cause;
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_NOTICE, "Hangup %s [%s] [%s]\n",
- channel->name, state_names[last_state], switch_channel_cause2str(channel->hangup_cause));
+ channel->name, state_names[last_state], switch_channel_cause2str(channel->hangup_cause));
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_HANGUP) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Hangup-Cause", "%s", switch_channel_cause2str(channel->hangup_cause));
switch_channel_event_set_data(channel, event);
}
/* if we're the child of another channel and the other channel is in a blocking read they will never realize we have answered so send
- a SWITCH_SIG_BREAK to interrupt any blocking reads on that channel
- */
+ a SWITCH_SIG_BREAK to interrupt any blocking reads on that channel
+ */
if ((uuid = switch_channel_get_variable(channel, SWITCH_ORIGINATOR_VARIABLE))
&& (other_session = switch_core_session_locate(uuid))) {
- switch_core_session_kill_channel(other_session, SWITCH_SIG_BREAK);
- switch_core_session_rwunlock(other_session);
+ switch_core_session_kill_channel(other_session, SWITCH_SIG_BREAK);
+ switch_core_session_rwunlock(other_session);
}
return SWITCH_STATUS_SUCCESS;
}
}
/* if we're the child of another channel and the other channel is in a blocking read they will never realize we have answered so send
- a SWITCH_SIG_BREAK to interrupt any blocking reads on that channel
- */
+ a SWITCH_SIG_BREAK to interrupt any blocking reads on that channel
+ */
if ((uuid = switch_channel_get_variable(channel, SWITCH_ORIGINATOR_VARIABLE))
&& (other_session = switch_core_session_locate(uuid))) {
- switch_core_session_kill_channel(other_session, SWITCH_SIG_BREAK);
- switch_core_session_rwunlock(other_session);
+ switch_core_session_kill_channel(other_session, SWITCH_SIG_BREAK);
+ switch_core_session_rwunlock(other_session);
}
switch_channel_set_variable(channel, "endpoint_disposition", "ANSWER");
}
#define resize(l) {\
-char *dp;\
-olen += (len + l + block);\
-cpos = c - data;\
-if ((dp = realloc(data, olen))) {\
- data = dp;\
- c = data + cpos;\
- memset(c, 0, olen - cpos);\
- }} \
+ char *dp;\
+ olen += (len + l + block);\
+ cpos = c - data;\
+ if ((dp = realloc(data, olen))) {\
+ data = dp;\
+ c = data + cpos;\
+ memset(c, 0, olen - cpos);\
+ }} \
SWITCH_DECLARE(char *) switch_channel_expand_variables(switch_channel_t *channel, const char *in)
{
if (!(p = strchr(q, '$'))) {
break;
}
-
+
if (*(p-1) == '\\') {
q = p + 1;
continue;
q = p + 1;
continue;
}
-
+
nv = 1;
break;
}
-
+
if (!nv) {
return (char *)in;
}
c = data;
for (p = indup; p && *p; p++) {
vtype = 0;
-
+
if (*p == '\\') {
if (*(p + 1) == '$') {
nv = 1;
br--;
}
}
-
+
e++;
}
p = e;
-
+
if ((vval = strchr(vname, '('))) {
e = vval - 1;
*vval++ = '\0';
ooffset = atoi(ptr);
}
}
-
+
sub_val = switch_channel_get_variable(channel, vname);
if (offset || ooffset) {
cloned_sub_val = strdup(sub_val);
- switch_assert(cloned_sub_val);
+ switch_assert(cloned_sub_val);
sub_val = cloned_sub_val;
}
} else {
free(stream.data);
}
-
+
switch_safe_free(expanded);
switch_safe_free(expanded_vname);
-
+
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
free(data);
}
}
free(indup);
-
+
return data;
}
}
switch_assert(caller_profile != NULL);
-
+
prof[0] = caller_profile->context;
prof[1] = caller_profile->destination_number;
prof[2] = caller_profile->caller_id_name;
prof[8] = caller_profile->source;
prof[9] = caller_profile->chan_name;
prof[10] = caller_profile->uuid;
-
+
prof_names[0] = "context";
prof_names[1] = "destination_number";
prof_names[2] = "caller_id_name";
for (; hi; hi = hi->next) {
char *var = hi->name;
char *val = hi->value;
-
+
new_len = (strlen((char *) var) * 3) + 1;
if (encode_len < new_len) {
char *tmp;
-
+
encode_len = new_len;
-
+
tmp = realloc(encode_buf, encode_len);
switch_assert(tmp);
encode_buf = tmp;
if (!switch_strlen_zero(caller_profile->caller_id_name)) {
cid_buf = switch_core_session_sprintf(channel->session, "\"%s\" <%s>", caller_profile->caller_id_name,
- switch_str_nil(caller_profile->caller_id_number));
+ switch_str_nil(caller_profile->caller_id_number));
} else {
cid_buf = caller_profile->caller_id_number;
}
last_app = ap->app;
last_arg = ap->arg;
}
-
+
if (caller_profile->times) {
switch_time_exp_t tm;
switch_size_t retsize;
switch_channel_set_variable(channel, "profile_start_epoch", tmp);
switch_snprintf(tmp, sizeof(tmp), "%" SWITCH_TIME_T_FMT, caller_profile->times->profile_created);
switch_channel_set_variable(channel, "profile_start_uepoch", tmp);
-
+
tt_answered = (time_t) (caller_profile->times->answered / 1000000);
mtt_answered = (time_t) (caller_profile->times->answered / 1000);
switch_snprintf(tmp, sizeof(tmp), "%" TIME_T_FMT, tt_answered);
uduration = caller_profile->times->hungup - caller_profile->times->created;
duration = (int32_t)(tt_hungup - tt_created);
mduration = (int32_t)(mtt_hungup - mtt_created);
-
+
if (caller_profile->times->answered) {
billsec = (int32_t)(tt_hungup - tt_answered);
billmsec = (int32_t)(mtt_hungup - mtt_answered);
switch_snprintf(tmp, sizeof(tmp), "%d", legbillsec);
switch_channel_set_variable(channel, "flow_billsec", tmp);
-
+
switch_snprintf(tmp, sizeof(tmp), "%d", mduration);
switch_channel_set_variable(channel, "mduration", tmp);
switch_assert(thread != NULL);
switch_assert(session != NULL);
channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
switch_channel_set_flag(channel, CF_SERVICE);
while (data->running > 0) {
SWITCH_DECLARE(switch_status_t) switch_core_session_set_read_codec(switch_core_session_t *session, switch_codec_t *codec)
{
switch_event_t *event;
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
char tmp[30];
- switch_assert(session != NULL);
- channel = switch_core_session_get_channel(session);
-
if (switch_event_create(&event, SWITCH_EVENT_CODEC) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(session->channel, event);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-read-codec-name", "%s", codec->implementation->iananame);
SWITCH_DECLARE(switch_status_t) switch_core_session_set_write_codec(switch_core_session_t *session, switch_codec_t *codec)
{
switch_event_t *event;
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
char tmp[30];
- switch_assert(session != NULL);
- channel = switch_core_session_get_channel(session);
-
if (switch_event_create(&event, SWITCH_EVENT_CODEC) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(session->channel, event);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-write-codec-name", "%s", codec->implementation->iananame);
switch_hash_index_t *hi;
void *val;
switch_core_session_t *session;
- switch_channel_t *channel;
uint32_t loops = 0;
switch_mutex_lock(runtime.throttle_mutex);
if (val) {
session = (switch_core_session_t *) val;
switch_core_session_read_lock(session);
-
- channel = switch_core_session_get_channel(session);
- switch_channel_hangup(channel, cause);
-
+ switch_channel_hangup(switch_core_session_get_channel(session), cause);
switch_core_session_rwunlock(session);
}
}
switch_event_t *event;
switch_channel_t *peer_channel = switch_core_session_get_channel(*new_session);
-
if (session && channel) {
profile = switch_channel_get_caller_profile(channel);
}
switch_core_session_message_t msg = {0};
switch_core_session_t *other_session;
const char *uuid;
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
switch_status_t status = SWITCH_STATUS_SUCCESS;
- switch_assert(session != NULL);
-
- channel = switch_core_session_get_channel(session);
- switch_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__;
{
switch_status_t status = SWITCH_STATUS_FALSE;
void *pop;
- switch_channel_t *channel;
-
- switch_assert(session != NULL);
+ switch_channel_t *channel = switch_core_session_get_channel(session);
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
-
if (switch_channel_test_flag(channel, CF_EVENT_LOCK)) {
return status;
}
SWITCH_DECLARE(void) switch_core_session_reset(switch_core_session_t *session, switch_bool_t flush_dtmf)
{
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
switch_size_t has;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
/* clear resamplers*/
switch_resample_destroy(&session->read_resampler);
switch_resample_destroy(&session->write_resampler);
SWITCH_DECLARE(switch_channel_t *) switch_core_session_get_channel(switch_core_session_t *session)
{
+ switch_assert(session->channel);
return session->channel;
}
const switch_application_interface_t *application_interface, const char *arg) {
switch_app_log_t *log, *lp;
switch_event_t *event;
- switch_channel_t *channel;
if (!arg) {
arg = "";
log = switch_core_session_alloc(session, sizeof(*log));
- switch_assert(log != NULL);
-
log->app = switch_core_session_strdup(session, application_interface->interface_name);
log->arg = switch_core_session_strdup(session, arg);
switch_event_fire(&event);
}
- channel = switch_core_session_get_channel(session);
- switch_channel_clear_flag(channel, CF_BREAK);
+ switch_channel_clear_flag(session->channel, CF_BREAK);
switch_assert(application_interface->application_function);
int argc, x, count = 0;
char *expanded = NULL;
switch_caller_profile_t *profile, *new_profile, *pp;
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
switch_dialplan_interface_t *dialplan_interface = NULL;
switch_caller_extension_t *extension = NULL;
const switch_application_interface_t *application_interface;
switch_event_t *event;
switch_status_t status = SWITCH_STATUS_SUCCESS;
-
- channel = switch_core_session_get_channel(session);
if (!(profile = switch_channel_get_caller_profile(channel))) {
return SWITCH_STATUS_FALSE;
}
done:
-
session->stack_count--;
-
return status;
}
if (session) {
channel = switch_core_session_get_channel(session);
- if (channel && switch_test_flag(this, S_HUP)) {
+ if (switch_test_flag(this, S_HUP)) {
switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
}
switch_core_session_rwunlock(session);
}
channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
-
- return switch_channel_ready(channel) != 0;
-
+ return switch_channel_ready(channel) != 0;
}
int CoreSession::originate(CoreSession *a_leg_session,
return SWITCH_STATUS_FALSE;
}
channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
while (switch_core_session_dequeue_event(session, &event) == SWITCH_STATUS_SUCCESS) {
switch_event_destroy(&event);
int CoreSession::flushDigits()
{
- switch_channel_t *channel;
-
-
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
-
- switch_channel_flush_dtmf(channel);
-
+ switch_channel_flush_dtmf(switch_core_session_get_channel(session));
return SWITCH_STATUS_SUCCESS;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CoreSession::seHangupHook, hangup_func: %p\n", hangup_func);
on_hangup = hangup_func;
switch_channel_t *channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
hook_state = switch_channel_get_state(channel);
switch_channel_set_private(channel, "CoreSession", this);
switch_core_event_hook_add_state_change(session, hanguphook);
-
}
/** \brief Store a file handle in the callback args
switch_status_t hanguphook(switch_core_session_t *session_hungup)
{
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session_hungup);
CoreSession *coresession = NULL;
- switch_channel_state_t state;
-
+ switch_channel_state_t state = switch_channel_get_state(channel);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "hangup_hook called\n");
fflush(stdout);
- channel = switch_core_session_get_channel(session_hungup);
- assert(channel != NULL);
-
- state = switch_channel_get_state(channel);
-
if ((coresession = (CoreSession *) switch_channel_get_private(channel, "CoreSession"))) {
if (coresession->hook_state != state) {
coresession->hook_state = state;
void *buf,
unsigned int buflen) {
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session_cb);
CoreSession *coresession = NULL;
switch_status_t result;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "dtmf_callback called\n");
fflush(stdout);
- channel = switch_core_session_get_channel(session_cb);
- assert(channel != NULL);
-
coresession = (CoreSession *) switch_channel_get_private(channel, "CoreSession");
if (!coresession) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid CoreSession\n");
}
-
-
switch_status_t process_callback_result(char *ret,
struct input_callback_state *cb_state,
switch_core_session_t *session)
SWITCH_DECLARE(switch_status_t) switch_ivr_sleep(switch_core_session_t *session, uint32_t ms)
{
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
switch_status_t status = SWITCH_STATUS_SUCCESS;
- switch_time_t start, now, done = switch_timestamp_now() + (ms * 1000);
+ switch_time_t start = switch_timestamp_now(), now, done = switch_timestamp_now() + (ms * 1000);
switch_frame_t *read_frame;
int32_t left, elapsed;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- start = switch_timestamp_now();
-
for (;;) {
now = switch_timestamp_now();
elapsed = (int32_t) ((now - start) / 1000);
SWITCH_DECLARE(switch_status_t) switch_ivr_deactivate_unicast(switch_core_session_t *session)
{
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
switch_unicast_conninfo_t *conninfo;
int sanity = 0;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
if (!switch_channel_test_flag(channel, CF_UNICAST)) {
return SWITCH_STATUS_FALSE;
char *transport,
char *flags)
{
- switch_channel_t *channel;
- switch_unicast_conninfo_t *conninfo;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ switch_unicast_conninfo_t *conninfo = switch_core_session_alloc(session, sizeof(*conninfo));
switch_codec_t *read_codec;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- conninfo = switch_core_session_alloc(session, sizeof(*conninfo));
switch_assert(conninfo != NULL);
conninfo->local_ip = switch_core_session_strdup(session, local_ip);
char *event_lock = switch_event_get_header(event, "event-lock");
switch_status_t status = SWITCH_STATUS_FALSE;
- switch_assert(channel != NULL);
- switch_assert(event != NULL);
-
if (switch_strlen_zero(cmd)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Command!\n");
return SWITCH_STATUS_FALSE;
SWITCH_DECLARE(switch_status_t) switch_ivr_parse_all_events(switch_core_session_t *session)
{
switch_event_t *event;
- switch_channel_t *channel;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
while (switch_core_session_dequeue_private_event(session, &event) == SWITCH_STATUS_SUCCESS) {
switch_ivr_parse_event(session, event);
SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session, switch_input_args_t *args)
{
switch_status_t status = SWITCH_STATUS_SUCCESS;
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
switch_frame_t *read_frame;
int stream_id = 0;
switch_event_t *event;
switch_unicast_conninfo_t *conninfo = NULL;
switch_codec_t *read_codec = switch_core_session_get_read_codec(session);
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
if (!switch_channel_test_flag(channel, CF_ANSWERED)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Careful, Channel is unanswered. Pre-answering...\n");
switch_channel_pre_answer(channel);
SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_callback(switch_core_session_t *session, switch_input_args_t *args, uint32_t timeout)
{
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
switch_status_t status = SWITCH_STATUS_SUCCESS;
switch_time_t started = 0;
uint32_t elapsed;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
if (!args->input_callback) {
return SWITCH_STATUS_GENERR;
}
uint32_t abs_timeout)
{
switch_size_t i = 0, x = strlen(buf);
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
switch_status_t status = SWITCH_STATUS_FALSE;
switch_time_t started = 0, digit_started = 0;
uint32_t abs_elapsed = 0, digit_elapsed = 0;
uint32_t eff_timeout = 0;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
if (terminator != NULL)
*terminator = '\0';
SWITCH_DECLARE(switch_status_t) switch_ivr_hold(switch_core_session_t *session)
{
switch_core_session_message_t msg = { 0 };
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
msg.message_id = SWITCH_MESSAGE_INDICATE_HOLD;
msg.from = __FILE__;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
switch_channel_set_flag(channel, CF_HOLD);
switch_channel_set_flag(channel, CF_SUSPEND);
SWITCH_DECLARE(switch_status_t) switch_ivr_unhold(switch_core_session_t *session)
{
switch_core_session_message_t msg = { 0 };
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
msg.message_id = SWITCH_MESSAGE_INDICATE_UNHOLD;
msg.from = __FILE__;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
switch_channel_clear_flag(channel, CF_HOLD);
switch_channel_clear_flag(channel, CF_SUSPEND);
if ((session = switch_core_session_locate(uuid))) {
channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
+
if ((flags & SMF_REBRIDGE) && !switch_channel_test_flag(channel, CF_ORIGINATOR)) {
swap = 1;
}
if ((session = switch_core_session_locate(uuid))) {
status = SWITCH_STATUS_SUCCESS;
channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
if ((flags & SMF_REBRIDGE) && !switch_channel_test_flag(channel, CF_ORIGINATOR)) {
swap = 1;
if ((flags & SMF_REBRIDGE) && (other_uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE)) &&
(other_session = switch_core_session_locate(other_uuid))) {
other_channel = switch_core_session_get_channel(other_session);
- switch_assert(other_channel != NULL);
switch_core_session_receive_message(other_session, &msg);
switch_channel_clear_state_handler(other_channel, NULL);
SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(switch_core_session_t *session, const char *extension, const char *dialplan, const char *context)
{
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
switch_caller_profile_t *profile, *new_profile;
switch_core_session_message_t msg = { 0 };
switch_core_session_t *other_session;
switch_channel_t *other_channel = NULL;
const char *uuid = NULL;
- switch_assert(session != NULL);
switch_core_session_reset(session, SWITCH_TRUE);
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
switch_channel_clear_flag(channel, CF_ORIGINATING);
/* clear all state handlers */
if (uuid && (other_session = switch_core_session_locate(uuid))) {
other_channel = switch_core_session_get_channel(other_session);
- switch_assert(other_channel != NULL);
switch_channel_set_variable(other_channel, SWITCH_SIGNAL_BOND_VARIABLE, NULL);
switch_core_session_rwunlock(other_session);
}
if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BRIDGE_VARIABLE))
&& (other_session = switch_core_session_locate(uuid))) {
other_channel = switch_core_session_get_channel(other_session);
- switch_assert(other_channel != NULL);
switch_channel_set_variable(channel, SWITCH_SIGNAL_BRIDGE_VARIABLE, NULL);
switch_channel_set_variable(other_channel, SWITCH_SIGNAL_BRIDGE_VARIABLE, NULL);
SWITCH_DECLARE(switch_status_t) switch_ivr_generate_xml_cdr(switch_core_session_t *session, switch_xml_t * xml_cdr)
{
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
switch_caller_profile_t *caller_profile;
switch_xml_t variables, cdr, x_main_cp, x_caller_profile, x_caller_extension, x_times, time_tag,
x_application, x_callflow, x_inner_extension, x_apps, x_o;
char tmp[512];
int cdr_off = 0, v_off = 0;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
if (!(cdr = switch_xml_new("cdr"))) {
return SWITCH_STATUS_SUCCESS;
}
stfu_frame_t *jb_frame;
switch_frame_t *read_frame, write_frame = { 0 };
switch_status_t status;
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
uint32_t interval, samples;
uint32_t ts = 0;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Setting delay to %dms (%d frames)\n", delay_ms, qlen);
jb = stfu_n_init(qlen);
- channel = switch_core_session_get_channel(session);
write_frame.codec = read_codec;
while(switch_channel_ready(channel)) {
switch_media_bug_t *bug;
switch_channel_t *channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
if ((bug = switch_channel_get_private(channel, file))) {
switch_channel_set_private(channel, file, NULL);
switch_core_media_bug_remove(session, &bug);
SWITCH_DECLARE(switch_status_t) switch_ivr_displace_session(switch_core_session_t *session, const char *file, uint32_t limit, const char *flags)
{
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
switch_codec_t *read_codec;
switch_media_bug_t *bug;
switch_status_t status;
time_t to = 0;
displace_helper_t *dh;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
if ((bug = switch_channel_get_private(channel, file))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Only 1 of the same file per channel please!\n");
return SWITCH_STATUS_FALSE;
case SWITCH_ABC_TYPE_READ:
if (fh) {
switch_size_t len;
- switch_core_session_t *session;
- switch_channel_t *channel;
-
- session = switch_core_media_bug_get_session(bug);
- switch_assert(session != NULL);
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
+ switch_core_session_t *session = switch_core_media_bug_get_session(bug);
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+
if (switch_core_media_bug_read(bug, &frame) == SWITCH_STATUS_SUCCESS) {
int doit = 1;
if (!switch_channel_test_flag(channel, CF_ANSWERED) && switch_core_media_bug_test_flag(bug, SMBF_RECORD_ANSWER_REQ)) {
switch_media_bug_t *bug;
switch_channel_t *channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
if ((bug = switch_channel_get_private(channel, file))) {
switch_channel_set_private(channel, file, NULL);
switch_core_media_bug_remove(session, &bug);
return SWITCH_STATUS_SUCCESS;
}
-
return SWITCH_STATUS_FALSE;
}
SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t *session, char *file, uint32_t limit, switch_file_handle_t *fh)
{
- switch_channel_t *channel;
- switch_codec_t *read_codec;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ switch_codec_t *read_codec = switch_core_session_get_read_codec(session);
const char *p;
const char *vval;
switch_media_bug_t *bug;
switch_status_t status;
time_t to = 0;
switch_media_bug_flag_t flags = SMBF_READ_STREAM | SMBF_WRITE_STREAM;
- uint8_t channels;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
+ uint8_t channels = read_codec->implementation->number_of_channels;
if ((bug = switch_channel_get_private(channel, file))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Only 1 of the same file per channel please!\n");
}
}
- read_codec = switch_core_session_get_read_codec(session);
- switch_assert(read_codec != NULL);
-
- channels = read_codec->implementation->number_of_channels;
-
if ((p = switch_channel_get_variable(channel, "RECORD_STEREO")) && switch_true(p)) {
flags |= SMBF_STEREO;
channels = 2;
fh->channels = channels;
fh->samplerate = read_codec->implementation->actual_samples_per_second;
-
if (switch_core_file_open(fh,
file,
channels,
char digit_str[80];
switch_channel_t *channel = switch_core_session_get_channel(pvt->session);
- switch_assert(channel != NULL);
frame.data = data;
frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE;
switch_media_bug_t *bug;
switch_channel_t *channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
if ((bug = switch_channel_get_private(channel, "dtmf"))) {
switch_channel_set_private(channel, "dtmf", NULL);
switch_core_media_bug_remove(session, &bug);
return SWITCH_STATUS_SUCCESS;
}
-
return SWITCH_STATUS_FALSE;
-
}
SWITCH_DECLARE(switch_status_t) switch_ivr_inband_dtmf_session(switch_core_session_t *session)
{
- switch_channel_t *channel;
- switch_codec_t *read_codec;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ switch_codec_t *read_codec = switch_core_session_get_read_codec(session);
switch_media_bug_t *bug;
switch_status_t status;
switch_inband_dtmf_t *pvt;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- read_codec = switch_core_session_get_read_codec(session);
switch_assert(read_codec != NULL);
if (!(pvt = switch_core_session_alloc(session, sizeof(*pvt)))) {
static switch_status_t generate_on_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf)
{
-
- switch_media_bug_t *bug;
switch_channel_t *channel = switch_core_session_get_channel(session);
+ switch_media_bug_t *bug = switch_channel_get_private(channel, "dtmf_generate");
- if ((bug = (switch_media_bug_t *) switch_channel_get_private(channel, "dtmf_generate"))) {
+ if (bug) {
switch_inband_dtmf_generate_t *pvt = (switch_inband_dtmf_generate_t *) switch_core_media_bug_get_user_data(bug);
if (pvt) {
SWITCH_DECLARE(switch_status_t) switch_ivr_stop_inband_dtmf_generate_session(switch_core_session_t *session)
{
- switch_media_bug_t *bug;
switch_channel_t *channel = switch_core_session_get_channel(session);
+ switch_media_bug_t *bug = switch_channel_get_private(channel, "dtmf_generate");
- switch_assert(channel != NULL);
- if ((bug = switch_channel_get_private(channel, "dtmf_generate"))) {
+ if (bug) {
switch_channel_set_private(channel, "dtmf_generate", NULL);
switch_core_media_bug_remove(session, &bug);
return SWITCH_STATUS_SUCCESS;
SWITCH_DECLARE(switch_status_t) switch_ivr_inband_dtmf_generate_session(switch_core_session_t *session, switch_bool_t read_stream)
{
- switch_channel_t *channel;
- switch_codec_t *read_codec;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ switch_codec_t *read_codec = switch_core_session_get_read_codec(session);
switch_media_bug_t *bug;
switch_status_t status;
switch_inband_dtmf_generate_t *pvt;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- read_codec = switch_core_session_get_read_codec(session);
switch_assert(read_codec != NULL);
if (!(pvt = switch_core_session_alloc(session, sizeof(*pvt)))) {
SWITCH_DECLARE(switch_status_t) switch_ivr_stop_tone_detect_session(switch_core_session_t *session)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
- switch_tone_container_t *cont;
+ switch_tone_container_t *cont = switch_channel_get_private(channel, "_tone_detect_");
- switch_assert(channel != NULL);
- if ((cont = switch_channel_get_private(channel, "_tone_detect_"))) {
+ if (cont) {
switch_channel_set_private(channel, "_tone_detect_", NULL);
switch_core_media_bug_remove(session, &cont->bug);
return SWITCH_STATUS_SUCCESS;
}
-
return SWITCH_STATUS_FALSE;
-
}
SWITCH_DECLARE(switch_status_t) switch_ivr_tone_detect_session(switch_core_session_t *session,
const char *flags, time_t timeout,
const char *app, const char *data)
{
- switch_channel_t *channel;
- switch_codec_t *read_codec;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ switch_codec_t *read_codec = switch_core_session_get_read_codec(session);
switch_status_t status;
- switch_tone_container_t *cont = NULL;
+ switch_tone_container_t *cont = switch_channel_get_private(channel, "_tone_detect_");
char *p, *next;
int i = 0, ok = 0;
-
switch_media_bug_flag_t bflags = 0;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- read_codec = switch_core_session_get_read_codec(session);
switch_assert(read_codec != NULL);
if (switch_strlen_zero(key)) {
return SWITCH_STATUS_FALSE;
}
- if ((cont = switch_channel_get_private(channel, "_tone_detect_"))) {
+ if (cont) {
if (cont->index >= MAX_TONES) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Max Tones Reached!\n");
return SWITCH_STATUS_FALSE;
if (!ok) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid tone spec!\n");
return SWITCH_STATUS_FALSE;
-
}
cont->list[cont->index].key = switch_core_session_strdup(session, key);
}
}
-
if ((status = switch_core_media_bug_add(session, tone_detect_callback, cont, timeout, bflags, &cont->bug)) != SWITCH_STATUS_SUCCESS) {
return status;
}
switch_thread_cond_create(&sth->cond, sth->pool);
switch_mutex_init(&sth->mutex, SWITCH_MUTEX_NESTED, sth->pool);
-
switch_core_session_read_lock(sth->session);
switch_mutex_lock(sth->mutex);
goto done;
}
-
if (switch_event_create(&event, SWITCH_EVENT_DETECTED_SPEECH) == SWITCH_STATUS_SUCCESS) {
if (status == SWITCH_STATUS_SUCCESS) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Speech-Type", "detected-speech");
SWITCH_DECLARE(switch_status_t) switch_ivr_pause_detect_speech(switch_core_session_t *session)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
- struct speech_thread_handle *sth;
+ struct speech_thread_handle *sth = switch_channel_get_private(channel, SWITCH_SPEECH_KEY);
- switch_assert(channel != NULL);
- if ((sth = switch_channel_get_private(channel, SWITCH_SPEECH_KEY))) {
+ if (sth) {
switch_core_asr_pause(sth->ah);
return SWITCH_STATUS_SUCCESS;
}
-
return SWITCH_STATUS_FALSE;
}
SWITCH_DECLARE(switch_status_t) switch_ivr_resume_detect_speech(switch_core_session_t *session)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
- struct speech_thread_handle *sth;
+ struct speech_thread_handle *sth = switch_channel_get_private(channel, SWITCH_SPEECH_KEY);
- switch_assert(channel != NULL);
- if ((sth = switch_channel_get_private(channel, SWITCH_SPEECH_KEY))) {
+ if (sth) {
switch_core_asr_resume(sth->ah);
return SWITCH_STATUS_SUCCESS;
}
-
return SWITCH_STATUS_FALSE;
}
{
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_asr_flag_t flags = SWITCH_ASR_FLAG_NONE;
- struct speech_thread_handle *sth;
+ struct speech_thread_handle *sth = switch_channel_get_private(channel, SWITCH_SPEECH_KEY);
- switch_assert(channel != NULL);
- if ((sth = switch_channel_get_private(channel, SWITCH_SPEECH_KEY))) {
+ if (sth) {
if (switch_core_asr_load_grammar(sth->ah, grammar, path) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Error loading Grammar\n");
switch_core_asr_close(sth->ah, &flags);
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
return SWITCH_STATUS_FALSE;
}
-
return SWITCH_STATUS_SUCCESS;
}
-
return SWITCH_STATUS_FALSE;
}
{
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_asr_flag_t flags = SWITCH_ASR_FLAG_NONE;
- struct speech_thread_handle *sth;
+ struct speech_thread_handle *sth = switch_channel_get_private(channel, SWITCH_SPEECH_KEY);
- switch_assert(channel != NULL);
- if ((sth = switch_channel_get_private(channel, SWITCH_SPEECH_KEY))) {
+ if (sth) {
if (switch_core_asr_unload_grammar(sth->ah, grammar) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Error unloading Grammar\n");
switch_core_asr_close(sth->ah, &flags);
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
return SWITCH_STATUS_FALSE;
}
-
return SWITCH_STATUS_SUCCESS;
}
-
return SWITCH_STATUS_FALSE;
}
const char *dest,
switch_asr_handle_t *ah)
{
- switch_channel_t *channel;
- switch_codec_t *read_codec;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ switch_codec_t *read_codec = switch_core_session_get_read_codec(session);
switch_status_t status;
switch_asr_flag_t flags = SWITCH_ASR_FLAG_NONE;
- struct speech_thread_handle *sth;
- const char *val;
+ struct speech_thread_handle *sth = switch_channel_get_private(channel, SWITCH_SPEECH_KEY);
if (!ah) {
if (!(ah = switch_core_session_alloc(session, sizeof(*ah)))) {
}
}
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- read_codec = switch_core_session_get_read_codec(session);
switch_assert(read_codec != NULL);
-
- if ((val = switch_channel_get_variable(channel, "fire_asr_events"))) {
+ if ((switch_channel_get_variable(channel, "fire_asr_events"))) {
switch_set_flag(ah, SWITCH_ASR_FLAG_FIRE_EVENTS);
}
- if ((sth = switch_channel_get_private(channel, SWITCH_SPEECH_KEY))) {
+ if (sth) {
if (switch_core_asr_load_grammar(sth->ah, grammar, path) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Error loading Grammar\n");
switch_core_asr_close(sth->ah, &flags);
return SWITCH_STATUS_FALSE;
}
-
sth = switch_core_session_alloc(session, sizeof(*sth));
sth->pool = switch_core_session_get_pool(session);
sth->session = session;
switch_assert(path);
- if (!(session = switch_core_session_locate(uuid))) {
- //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "uuid [%s] does not match an existing session.\n", switch_str_nil(uuid));
+ if (!(master = session = switch_core_session_locate(uuid))) {
return SWITCH_STATUS_FALSE;
}
- master = session;
-
channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
if ((switch_channel_test_flag(channel, CF_EVENT_PARSE))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Channel [%s] already broadcasting...broadcast aborted\n",
mypath = strdup(path);
-
if ((nomedia = switch_channel_test_flag(channel, CF_BYPASS_MEDIA))) {
switch_ivr_media(uuid, SMF_REBRIDGE);
}
static switch_status_t audio_bridge_on_loopback(switch_core_session_t *session)
{
- switch_channel_t *channel = NULL;
- switch_ivr_bridge_data_t *bd;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ switch_ivr_bridge_data_t *bd = switch_channel_get_private(channel, "_bridge_");
switch_channel_state_t state;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
- if ((bd = (switch_ivr_bridge_data_t *) switch_channel_get_private(channel, "_bridge_"))) {
+ if (bd) {
switch_channel_set_private(channel, "_bridge_", NULL);
if (bd->session == session && *bd->b_uuid) {
audio_bridge_thread(NULL, (void *) bd);
static switch_status_t audio_bridge_on_ring(switch_core_session_t *session)
{
- switch_channel_t *channel = NULL;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
+ switch_channel_t *channel = switch_core_session_get_channel(session);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CUSTOM RING\n", switch_channel_get_name(channel));
static switch_status_t audio_bridge_on_hold(switch_core_session_t *session)
{
- switch_channel_t *channel = NULL;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
+ switch_channel_t *channel = switch_core_session_get_channel(session);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CUSTOM HOLD\n", switch_channel_get_name(channel));
static switch_status_t uuid_bridge_on_reset(switch_core_session_t *session)
{
- switch_channel_t *channel = NULL;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
+ switch_channel_t *channel = switch_core_session_get_channel(session);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CUSTOM RESET\n", switch_channel_get_name(channel));
static switch_status_t uuid_bridge_on_transmit(switch_core_session_t *session)
{
- switch_channel_t *channel = NULL;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
switch_core_session_t *other_session;
const char *other_uuid = NULL;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CUSTOM TRANSMIT\n", switch_channel_get_name(channel));
switch_channel_clear_state_handler(channel, NULL);
static switch_status_t signal_bridge_on_hangup(switch_core_session_t *session)
{
const char *uuid;
- switch_channel_t *channel = NULL;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
switch_core_session_t *other_session;
switch_event_t *event;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
if (switch_channel_test_flag(channel, CF_ORIGINATOR)) {
switch_channel_clear_flag(channel, CF_ORIGINATOR);
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_UNBRIDGE) == SWITCH_STATUS_SUCCESS) {
if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BRIDGE_VARIABLE))
&& (other_session = switch_core_session_locate(uuid))) {
- switch_channel_t *other_channel = NULL;
-
- other_channel = switch_core_session_get_channel(other_session);
- switch_assert(other_channel != NULL);
+ switch_channel_t *other_channel = switch_core_session_get_channel(other_session);
switch_channel_set_variable(channel, SWITCH_SIGNAL_BRIDGE_VARIABLE, NULL);
switch_channel_set_variable(other_channel, SWITCH_SIGNAL_BRIDGE_VARIABLE, NULL);
SWITCH_DECLARE(switch_status_t) switch_ivr_signal_bridge(switch_core_session_t *session, switch_core_session_t *peer_session)
{
- switch_channel_t *caller_channel, *peer_channel;
+ switch_channel_t *caller_channel = switch_core_session_get_channel(session);
+ switch_channel_t *peer_channel = switch_core_session_get_channel(peer_session);
switch_event_t *event;
- caller_channel = switch_core_session_get_channel(session);
- switch_assert(caller_channel != NULL);
-
- peer_channel = switch_core_session_get_channel(peer_session);
- switch_assert(peer_channel != NULL);
-
if (!switch_channel_ready(peer_channel)) {
switch_channel_hangup(caller_channel, switch_channel_get_cause(peer_channel));
return SWITCH_STATUS_FALSE;
switch_input_callback_function_t input_callback, void *session_data,
void *peer_session_data)
{
- switch_ivr_bridge_data_t *a_leg, *b_leg;
- switch_channel_t *caller_channel, *peer_channel;
+ switch_ivr_bridge_data_t *a_leg = switch_core_session_alloc(session, sizeof(*a_leg));
+ switch_ivr_bridge_data_t *b_leg = switch_core_session_alloc(peer_session, sizeof(*b_leg));
+ switch_channel_t *caller_channel = switch_core_session_get_channel(session);
+ switch_channel_t *peer_channel = switch_core_session_get_channel(peer_session);
int stream_id = 0;
switch_status_t status = SWITCH_STATUS_SUCCESS;
switch_channel_state_t state;
- switch_assert(session != NULL);
- switch_assert(peer_session != NULL);
-
- caller_channel = switch_core_session_get_channel(session);
- switch_assert(caller_channel != NULL);
-
switch_channel_set_flag(caller_channel, CF_ORIGINATOR);
-
- peer_channel = switch_core_session_get_channel(peer_session);
- switch_assert(peer_channel != NULL);
-
switch_channel_clear_flag(caller_channel, CF_TRANSFER);
switch_channel_clear_flag(peer_channel, CF_TRANSFER);
- a_leg = switch_core_session_alloc(session, sizeof(*a_leg));
- b_leg = switch_core_session_alloc(peer_session, sizeof(*b_leg));
-
- switch_assert(a_leg && b_leg);
-
b_leg->session = peer_session;
switch_copy_string(b_leg->b_uuid, switch_core_session_get_uuid(session), sizeof(b_leg->b_uuid));
b_leg->stream_id = stream_id;
}
channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
if (!(menu = switch_ivr_menu_find(stack, name))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Menu!\n");
static switch_status_t originate_on_ring(switch_core_session_t *session)
{
- switch_channel_t *channel = NULL;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
+ switch_channel_t *channel = switch_core_session_get_channel(session);
/* put the channel in a passive state so we can loop audio to it */
-
/* clear this handler so it only works once (next time (a.k.a. Transfer) we will do the real ring state) */
switch_channel_clear_state_handler(channel, &originate_state_handlers);
-
switch_channel_set_state(channel, CS_HOLD);
-
return SWITCH_STATUS_FALSE;
}
char buf[10] = SWITCH_BLANK_STRING;
char *p, term;
-
if (!strcasecmp(collect->key, "exec")) {
char *data;
const switch_application_interface_t *application_interface;
SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t *session, switch_core_session_t *peer_session)
{
- switch_channel_t *caller_channel;
- switch_channel_t *peer_channel;
+ switch_channel_t *caller_channel = switch_core_session_get_channel(session);
+ switch_channel_t *peer_channel = switch_core_session_get_channel(peer_session);
const char *ringback_data = NULL;
switch_frame_t write_frame = { 0 };
switch_codec_t write_codec = { 0 };
- switch_codec_t *read_codec = NULL;
+ switch_codec_t *read_codec = switch_core_session_get_read_codec(session);
uint8_t pass = 0;
ringback_t ringback = { 0 };
switch_core_session_message_t *message = NULL;
switch_status_t status = SWITCH_STATUS_SUCCESS;
uint8_t abuf[1024];
int timelimit = 60;
- const char *var;
+ const char *var = switch_channel_get_variable(caller_channel, "call_timeout");
switch_time_t start = 0;
- caller_channel = switch_core_session_get_channel(session);
- peer_channel = switch_core_session_get_channel(peer_session);
-
- switch_assert(caller_channel && peer_channel);
-
- if ((var = switch_channel_get_variable(caller_channel, "call_timeout"))) {
+ if (var) {
timelimit = atoi(var);
if (timelimit < 0) {
timelimit = 60;
return SWITCH_STATUS_SUCCESS;
}
- read_codec = switch_core_session_get_read_codec(session);
-
if (switch_channel_test_flag(caller_channel, CF_ANSWERED)) {
ringback_data = switch_channel_get_variable(caller_channel, "transfer_ringback");
}
}
- if ((read_codec = switch_core_session_get_read_codec(session)) && (ringback_data || !switch_channel_test_flag(caller_channel, CF_BYPASS_MEDIA))) {
+ if (read_codec && (ringback_data || !switch_channel_test_flag(caller_channel, CF_BYPASS_MEDIA))) {
if (!(pass = (uint8_t) switch_test_flag(read_codec, SWITCH_CODEC_FLAG_PASSTHROUGH))) {
if (switch_core_codec_init(&write_codec,
"L16",
goto done;
}
ringback.fh = &ringback.fhb;
-
-
} else {
teletone_init_session(&ringback.ts, 0, teletone_handler, &ringback);
ringback.ts.rate = read_codec->implementation->actual_samples_per_second;
}
if (switch_core_session_dequeue_message(peer_session, &message) == SWITCH_STATUS_SUCCESS) {
- //switch_core_session_receive_message(session, message);
-
if (switch_test_flag(message, SCSMF_DYNAMIC)) {
switch_safe_free(message);
} else {
}
return status;
-
}
#define MAX_PEERS 128
if (session) {
switch_event_header_t *hi;
-
caller_channel = switch_core_session_get_channel(session);
- switch_assert(caller_channel != NULL);
/* Copy all the applicable channel variables into the event */
if ((hi = switch_channel_variable_first(caller_channel))) {
caller_profiles[i] = new_profile;
peer_sessions[i] = new_session;
peer_channels[i] = switch_core_session_get_channel(new_session);
- switch_assert(peer_channels[i] != NULL);
switch_channel_set_flag(peer_channels[i], CF_ORIGINATING);
if (var_event) {
switch_status_t status = SWITCH_STATUS_GENERR;
const char *old_sound_prefix = NULL, *sound_path = NULL, *tts_engine = NULL, *tts_voice = NULL;
const char *module_name = NULL, *chan_lang = NULL;
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
uint8_t done = 0;
int matches = 0;
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
if (!macro_name) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No phrase macro specified.\n");
return status;
goto done;
}
-
if (!(sound_path = (char *) switch_xml_attr(language, "sound-path"))) {
sound_path = (char *) switch_xml_attr(language, "sound_path");
}
SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *session,
switch_file_handle_t *fh, const char *file, switch_input_args_t *args, uint32_t limit)
{
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
switch_dtmf_t dtmf = {0};
switch_file_handle_t lfh = { 0 };
switch_frame_t *read_frame;
- switch_codec_t codec, *read_codec;
+ switch_codec_t codec, *read_codec = switch_core_session_get_read_codec(session);
char *codec_name;
switch_status_t status = SWITCH_STATUS_SUCCESS;
const char *p;
time_t start = 0;
uint32_t org_silence_hits = 0;
+ switch_assert(read_codec != NULL);
+
if (!fh) {
fh = &lfh;
}
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
switch_channel_pre_answer(channel);
- read_codec = switch_core_session_get_read_codec(session);
- switch_assert(read_codec != NULL);
-
fh->channels = read_codec->implementation->number_of_channels;
fh->native_rate = read_codec->implementation->actual_samples_per_second;
-
if (switch_core_file_open(fh,
file,
fh->channels,
}
}
-
if (status != SWITCH_STATUS_SUCCESS) {
break;
}
switch_codec_t *read_codec = NULL, write_codec = { 0 };
switch_frame_t write_frame = { 0 };
switch_byte_t data[1024];
- switch_channel_t *channel;
-
- switch_assert(session != NULL);
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
+ switch_channel_t *channel = switch_core_session_get_channel(session);
switch_channel_pre_answer(channel);
read_codec = switch_core_session_get_read_codec(session);
SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *session, switch_file_handle_t *fh, const char *file, switch_input_args_t *args)
{
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
int16_t *abuf;
switch_dtmf_t dtmf = {0};
uint32_t interval = 0, samples = 0, framelen, sample_start = 0;
switch_zmalloc(abuf, FILE_STARTSAMPLES * sizeof(*abuf));
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
switch_channel_pre_answer(channel);
prefix = switch_channel_get_variable(channel, "sound_prefix");
}
}
-
if (!fh) {
fh = &lfh;
memset(fh, 0, sizeof(lfh));
}
-
if (fh->samples > 0) {
sample_start = fh->samples;
fh->samples = 0;
fh->prebuf = maybe;
}
}
-
-
if (switch_core_file_open(fh,
file,
asis = 1;
}
-
write_frame.data = abuf;
write_frame.buflen = FILE_STARTSAMPLES;
date = switch_core_session_strdup(session, p);
switch_channel_set_variable(channel, "RECORD_DATE", p);
}
-#if 0
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
- "OPEN FILE %s %uhz %u channels\n"
- "TITLE=%s\n"
- "COPYRIGHT=%s\n"
- "SOFTWARE=%s\n"
- "ARTIST=%s\n" "COMMENT=%s\n" "DATE=%s\n", file, fh->samplerate, fh->channels, title, copyright, software, artist, comment, date);
-#endif
switch_assert(read_codec != NULL);
interval = read_codec->implementation->microseconds_per_frame / 1000;
framelen = codec.implementation->bytes_per_frame;
}
-
if (timer_name) {
uint32_t len;
switch_clear_flag(fh, SWITCH_FILE_SEEK);
}
-
if (!asis && fh->speed && do_speed) {
float factor = 0.25f * abs(fh->speed);
switch_size_t newlen, supplement, step;
short *bp = write_frame.data;
switch_size_t wrote = 0;
-
supplement = (int) (factor * olen);
newlen = (fh->speed > 0) ? olen - supplement : olen + supplement;
step = (fh->speed > 0) ? (newlen / supplement) : (olen / supplement);
write_frame.datalen = write_frame.samples * 2;
}
-
-
llen = olen;
if (timer_name) {
break;
}
-
if (timer_name) {
if (switch_core_timer_next(&timer) != SWITCH_STATUS_SUCCESS) {
break;
{
char terminator; //used to hold terminator recieved from
- switch_channel_t *channel; //the channel contained in session
+ switch_channel_t *channel = switch_core_session_get_channel(session); //the channel contained in session
switch_status_t status; //used to recieve state out of called functions
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
min_digits, max_digits, max_tries, timeout, valid_terminators, prompt_audio_file,
bad_input_audio_file, digit_buffer_length, digits_regex);
- //Get the channel
- channel = switch_core_session_get_channel(session);
-
- //Make sure somebody is home
- switch_assert(channel != NULL);
-
//Answer the channel if it hasn't already been answered
switch_channel_pre_answer(channel);
switch_speech_handle_t *sh,
switch_codec_t *codec, switch_timer_t *timer, char *text, switch_input_args_t *args)
{
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
short abuf[960];
switch_dtmf_t dtmf = {0};
uint32_t len = 0;
char *p, *tmp = NULL;
const char *star, *pound;
switch_size_t starlen, poundlen;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
if (!sh) {
return SWITCH_STATUS_FALSE;
SWITCH_DECLARE(void) switch_ivr_clear_speech_cache(switch_core_session_t *session)
{
cached_speech_handle_t *cache_obj = NULL;
- switch_channel_t *channel;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
+ switch_channel_t *channel = switch_core_session_get_channel(session);
if ((cache_obj = switch_channel_get_private(channel, SWITCH_CACHE_SPEECH_HANDLES_OBJ_NAME))) {
switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
switch_core_codec_destroy(&cache_obj->codec);
switch_channel_set_private(channel, SWITCH_CACHE_SPEECH_HANDLES_OBJ_NAME, NULL);
}
-
}
SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text(switch_core_session_t *session,
const char *tts_name, const char *voice_name, char *text, switch_input_args_t *args)
{
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
uint32_t rate = 0;
int interval = 0;
switch_frame_t write_frame = { 0 };
const char *timer_name, *var;
cached_speech_handle_t *cache_obj = NULL;
int need_create = 1, need_alloc = 1;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
switch_channel_pre_answer(channel);
if (switch_test_flag(&rtp_session->vad_data, SWITCH_VAD_FLAG_EVENTS_TALK)) {
switch_event_t *event;
if (switch_event_create(&event, SWITCH_EVENT_TALK) == SWITCH_STATUS_SUCCESS) {
- switch_channel_t *channel = switch_core_session_get_channel(rtp_session->vad_data.session);
- switch_channel_event_set_data(channel, event);
+ switch_channel_event_set_data(switch_core_session_get_channel(rtp_session->vad_data.session), event);
switch_event_fire(&event);
}
}
if (switch_test_flag(&rtp_session->vad_data, SWITCH_VAD_FLAG_EVENTS_NOTALK)) {
switch_event_t *event;
if (switch_event_create(&event, SWITCH_EVENT_NOTALK) == SWITCH_STATUS_SUCCESS) {
- switch_channel_t *channel = switch_core_session_get_channel(rtp_session->vad_data.session);
- switch_channel_event_set_data(channel, event);
+ switch_channel_event_set_data(switch_core_session_get_channel(rtp_session->vad_data.session), event);
switch_event_fire(&event);
}
}