[Freeswitch-svn] [commit] r7402 - in freeswitch/trunk/src: . include mod/applications/mod_commands mod/applications/mod_conference mod/applications/mod_dptools mod/applications/mod_enum mod/applications/mod_esf mod/applications/mod_fifo mod/applications/mod_limit mod/applications/mod_rss mod/applications/mod_voicemail mod/dialplans/mod_dialplan_asterisk mod/dialplans/mod_dialplan_directory mod/dialplans/mod_dialplan_xml mod/endpoints/mod_dingaling mod/endpoints/mod_iax mod/endpoints/mod_portaudio mod/endpoints/mod_sofia mod/endpoints/mod_woomera mod/event_handlers/mod_event_socket mod/languages/mod_spidermonkey mod/say/mod_say_de mod/say/mod_say_en mod/say/mod_say_es mod/say/mod_say_fr mod/say/mod_say_it mod/say/mod_say_nl
Freeswitch SVN
mikej at freeswitch.org
Mon Jan 28 02:26:11 EST 2008
Author: mikej
Date: Mon Jan 28 02:26:10 2008
New Revision: 7402
Modified:
freeswitch/trunk/src/include/switch_channel.h
freeswitch/trunk/src/include/switch_core.h
freeswitch/trunk/src/include/switch_ivr.h
freeswitch/trunk/src/include/switch_platform.h
freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
freeswitch/trunk/src/mod/applications/mod_enum/mod_enum.c
freeswitch/trunk/src/mod/applications/mod_esf/mod_esf.c
freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c
freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c
freeswitch/trunk/src/mod/applications/mod_rss/mod_rss.c
freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c
freeswitch/trunk/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c
freeswitch/trunk/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c
freeswitch/trunk/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c
freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c
freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c
freeswitch/trunk/src/mod/endpoints/mod_woomera/mod_woomera.c
freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
freeswitch/trunk/src/mod/say/mod_say_de/mod_say_de.c
freeswitch/trunk/src/mod/say/mod_say_en/mod_say_en.c
freeswitch/trunk/src/mod/say/mod_say_es/mod_say_es.c
freeswitch/trunk/src/mod/say/mod_say_fr/mod_say_fr.c
freeswitch/trunk/src/mod/say/mod_say_it/mod_say_it.c
freeswitch/trunk/src/mod/say/mod_say_nl/mod_say_nl.c
freeswitch/trunk/src/switch_channel.c
freeswitch/trunk/src/switch_core.c
freeswitch/trunk/src/switch_core_codec.c
freeswitch/trunk/src/switch_core_session.c
freeswitch/trunk/src/switch_cpp.cpp
freeswitch/trunk/src/switch_ivr.c
freeswitch/trunk/src/switch_ivr_async.c
freeswitch/trunk/src/switch_ivr_bridge.c
freeswitch/trunk/src/switch_ivr_menu.c
freeswitch/trunk/src/switch_ivr_originate.c
freeswitch/trunk/src/switch_ivr_play_say.c
freeswitch/trunk/src/switch_rtp.c
Log:
code analysis, clean up asserts related to switch_core_session_get_channel.
Modified: freeswitch/trunk/src/include/switch_channel.h
==============================================================================
--- freeswitch/trunk/src/include/switch_channel.h (original)
+++ freeswitch/trunk/src/include/switch_channel.h Mon Jan 28 02:26:10 2008
@@ -97,28 +97,28 @@
\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
@@ -126,7 +126,7 @@
\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
@@ -418,7 +418,7 @@
\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
@@ -426,8 +426,8 @@
\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
@@ -435,30 +435,30 @@
\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
@@ -467,9 +467,9 @@
\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)
Modified: freeswitch/trunk/src/include/switch_core.h
==============================================================================
--- freeswitch/trunk/src/include/switch_core.h (original)
+++ freeswitch/trunk/src/include/switch_core.h Mon Jan 28 02:26:10 2008
@@ -405,7 +405,7 @@
\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
@@ -512,7 +512,7 @@
\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
Modified: freeswitch/trunk/src/include/switch_ivr.h
==============================================================================
--- freeswitch/trunk/src/include/switch_ivr.h (original)
+++ freeswitch/trunk/src/include/switch_ivr.h Mon Jan 28 02:26:10 2008
@@ -98,7 +98,7 @@
\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
@@ -388,8 +388,8 @@
\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);
@@ -408,7 +408,7 @@
\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
Modified: freeswitch/trunk/src/include/switch_platform.h
==============================================================================
--- freeswitch/trunk/src/include/switch_platform.h (original)
+++ freeswitch/trunk/src/include/switch_platform.h Mon Jan 28 02:26:10 2008
@@ -313,6 +313,8 @@
#define _Inout_
#define _Inout_opt_
#define _In_bytecount_(x)
+#define _Out_opt_bytecapcount_(x)
+#define _Ret_
#endif
Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c Mon Jan 28 02:26:10 2008
@@ -1465,7 +1465,6 @@
}
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)) {
@@ -2016,8 +2015,6 @@
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");
@@ -2063,8 +2060,6 @@
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");
@@ -2119,7 +2114,6 @@
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;
Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c Mon Jan 28 02:26:10 2008
@@ -1366,7 +1366,6 @@
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);
@@ -1550,7 +1549,6 @@
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) {
@@ -2450,13 +2448,10 @@
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)
@@ -2486,7 +2481,6 @@
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);
@@ -3637,7 +3631,6 @@
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");
@@ -3684,12 +3677,10 @@
}
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) {
@@ -3699,7 +3690,6 @@
if (session != NULL) {
caller_channel = switch_core_session_get_channel(session);
-
}
if (switch_strlen_zero(cid_name)) {
@@ -3723,7 +3713,6 @@
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)) {
@@ -3942,8 +3931,6 @@
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)) {
@@ -3987,8 +3974,6 @@
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;
Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c Mon Jan 28 02:26:10 2008
@@ -111,10 +111,7 @@
{
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;
@@ -164,29 +161,19 @@
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);
@@ -329,12 +316,8 @@
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;
@@ -344,7 +327,7 @@
*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);
@@ -353,35 +336,23 @@
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)
@@ -420,12 +391,8 @@
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 {
@@ -440,7 +407,7 @@
}
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);
}
}
@@ -470,14 +437,10 @@
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");
@@ -550,14 +513,11 @@
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 {
@@ -599,27 +559,18 @@
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;
@@ -640,15 +591,11 @@
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);
@@ -659,17 +606,13 @@
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;
@@ -700,13 +643,7 @@
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");
@@ -742,15 +679,11 @@
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);
}
}
@@ -1025,8 +958,6 @@
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 = "*";
@@ -1067,8 +998,6 @@
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;
@@ -1122,12 +1051,9 @@
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);
@@ -1135,7 +1061,6 @@
SWITCH_STANDARD_APP(gentones_function)
{
- switch_channel_t *channel;
char *tone_script = NULL;
switch_input_args_t args = { 0 };
char *l;
@@ -1146,12 +1071,7 @@
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';
@@ -1208,8 +1128,6 @@
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 {
@@ -1301,8 +1219,6 @@
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;
}
Modified: freeswitch/trunk/src/mod/applications/mod_enum/mod_enum.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_enum/mod_enum.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_enum/mod_enum.c Mon Jan 28 02:26:10 2008
@@ -547,8 +547,6 @@
enum_route_t *rtp;
char *dp = (char *) arg;
- assert(channel != NULL);
-
if (!caller_profile) {
caller_profile = switch_channel_get_caller_profile(channel);
}
@@ -597,8 +595,6 @@
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;
}
Modified: freeswitch/trunk/src/mod/applications/mod_esf/mod_esf.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_esf/mod_esf.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_esf/mod_esf.c Mon Jan 28 02:26:10 2008
@@ -56,7 +56,7 @@
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;
@@ -77,11 +77,6 @@
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);
Modified: freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c Mon Jan 28 02:26:10 2008
@@ -40,10 +40,7 @@
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:
@@ -51,10 +48,8 @@
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;
}
}
@@ -67,10 +62,8 @@
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;
@@ -194,7 +187,7 @@
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;
@@ -208,8 +201,7 @@
return;
}
-
- if (switch_strlen_zero(data)) {
+ if (switch_strlen_zero(data)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Args\n");
return;
}
@@ -221,17 +213,13 @@
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) {
@@ -254,8 +242,7 @@
check_string(announce);
check_string(moh);
-
- if (moh) {
+ if (moh) {
switch_ivr_broadcast(uuid, moh, SMF_LOOP | SMF_ECHO_ALEG);
}
@@ -284,9 +271,7 @@
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);
}
@@ -345,9 +330,8 @@
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");
@@ -360,9 +344,7 @@
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;
@@ -389,8 +371,7 @@
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");
@@ -404,9 +385,7 @@
switch_event_fire(&event);
}
-
-
- if (announce) {
+ if (announce) {
switch_ivr_play_file(session, NULL, announce, NULL);
} else {
switch_ivr_sleep(session, 500);
@@ -477,8 +456,7 @@
}
}
-
- 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");
@@ -495,7 +473,6 @@
} 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)
Modified: freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c Mon Jan 28 02:26:10 2008
@@ -284,18 +284,13 @@
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';",
@@ -406,16 +401,12 @@
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])));
}
@@ -423,9 +414,8 @@
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);
@@ -441,12 +431,8 @@
switch_safe_free(sql);
return;
-
- error:
+error:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "USAGE: db %s\n", DB_USAGE);
-
-
-
}
@@ -536,16 +522,12 @@
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])));
}
@@ -585,10 +567,7 @@
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);
@@ -600,12 +579,9 @@
return;
}
+ switch_mutex_lock(globals.mutex);
- switch_mutex_lock(globals.mutex);
-
-
-
- realm = argv[0];
+ realm = argv[0];
id = argv[1];
max = atoi(argv[2]);
@@ -639,11 +615,8 @@
limit_execute_sql(sql, NULL);
switch_safe_free(sql);
-
- done:
-
+done:
switch_mutex_unlock(globals.mutex);
-
}
Modified: freeswitch/trunk/src/mod/applications/mod_rss/mod_rss.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_rss/mod_rss.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_rss/mod_rss.c Mon Jan 28 02:26:10 2008
@@ -155,7 +155,7 @@
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 };
@@ -185,16 +185,12 @@
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;
Modified: freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c Mon Jan 28 02:26:10 2008
@@ -792,13 +792,9 @@
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;
@@ -870,7 +866,7 @@
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 };
@@ -878,8 +874,6 @@
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);
@@ -1040,15 +1034,13 @@
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)) {
@@ -1227,10 +1219,10 @@
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;
@@ -1246,16 +1238,11 @@
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;
@@ -1684,7 +1671,7 @@
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;
@@ -1693,7 +1680,7 @@
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;
@@ -1719,10 +1706,6 @@
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,
@@ -2059,10 +2042,7 @@
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);
Modified: freeswitch/trunk/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c
==============================================================================
--- freeswitch/trunk/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c (original)
+++ freeswitch/trunk/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c Mon Jan 28 02:26:10 2008
@@ -52,13 +52,8 @@
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;
@@ -89,11 +84,7 @@
{
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));
@@ -109,11 +100,7 @@
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;
@@ -134,7 +121,7 @@
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;
@@ -144,9 +131,6 @@
cf = arg;
}
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
if (!caller_profile) {
caller_profile = switch_channel_get_caller_profile(channel);
}
Modified: freeswitch/trunk/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c
==============================================================================
--- freeswitch/trunk/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c (original)
+++ freeswitch/trunk/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c Mon Jan 28 02:26:10 2008
@@ -86,16 +86,13 @@
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);
}
@@ -103,7 +100,6 @@
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;
}
Modified: freeswitch/trunk/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c
==============================================================================
--- freeswitch/trunk/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c (original)
+++ freeswitch/trunk/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c Mon Jan 28 02:26:10 2008
@@ -47,14 +47,11 @@
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;
@@ -186,11 +183,10 @@
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);
@@ -204,11 +200,9 @@
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))) {
Modified: freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c Mon Jan 28 02:26:10 2008
@@ -906,7 +906,6 @@
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;
@@ -1052,7 +1051,7 @@
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;
@@ -1061,9 +1060,6 @@
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();
@@ -1148,15 +1144,12 @@
*/
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);
@@ -1171,12 +1164,9 @@
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);
@@ -1205,12 +1195,9 @@
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);
@@ -1258,18 +1245,13 @@
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);
@@ -1351,12 +1333,9 @@
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);
@@ -1452,13 +1431,10 @@
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);
@@ -1506,10 +1482,6 @@
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);
@@ -1524,12 +1496,8 @@
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);
@@ -1564,13 +1532,9 @@
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);
@@ -2572,7 +2536,6 @@
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));
Modified: freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c Mon Jan 28 02:26:10 2008
@@ -339,8 +339,6 @@
}
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();
@@ -456,26 +454,15 @@
*/
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);
@@ -485,52 +472,24 @@
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);
@@ -548,7 +507,7 @@
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) {
@@ -561,21 +520,14 @@
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);
@@ -601,9 +553,7 @@
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;
@@ -611,20 +561,15 @@
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);
@@ -635,16 +580,11 @@
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;
@@ -655,7 +595,6 @@
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;
@@ -685,12 +624,9 @@
return SWITCH_STATUS_SUCCESS;
}
}
-
-
switch_yield(1000);
}
-
return SWITCH_STATUS_FALSE;
cng:
@@ -701,19 +637,11 @@
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)) {
@@ -732,13 +660,7 @@
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)) {
@@ -750,13 +672,7 @@
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) {
@@ -824,7 +740,6 @@
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;
@@ -844,23 +759,16 @@
}
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;
+ struct private_object *tech_pvt = switch_core_session_get_private(session);
+ char *body = switch_event_get_body(event);
- 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))) {
+ if (!body) {
body = "";
}
@@ -893,7 +801,6 @@
SWITCH_MODULE_LOAD_FUNCTION(mod_iax_load)
{
-
module_pool = pool;
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
@@ -980,7 +887,6 @@
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) {
@@ -1111,7 +1017,6 @@
break;
}
-
if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
iaxevent->ies.username,
globals.dialplan,
@@ -1128,7 +1033,6 @@
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,
@@ -1163,7 +1067,6 @@
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;
@@ -1177,7 +1080,6 @@
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;
}
@@ -1192,13 +1094,11 @@
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) {
@@ -1206,7 +1106,6 @@
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);
}
@@ -1215,10 +1114,8 @@
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;
Modified: freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c Mon Jan 28 02:26:10 2008
@@ -165,25 +165,18 @@
*/
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 {
@@ -196,12 +189,9 @@
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;
@@ -297,40 +287,17 @@
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;
}
@@ -429,13 +396,7 @@
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);
@@ -450,20 +411,15 @@
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) {
@@ -476,7 +432,6 @@
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL KILL\n", switch_channel_get_name(channel));
-
return SWITCH_STATUS_SUCCESS;
}
@@ -488,47 +443,24 @@
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);
@@ -538,15 +470,9 @@
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) {
@@ -590,7 +516,6 @@
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) {
@@ -605,7 +530,6 @@
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;
@@ -642,13 +566,8 @@
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) {
@@ -672,35 +591,18 @@
}
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);
@@ -743,7 +645,6 @@
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;
@@ -790,7 +691,6 @@
}
return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
-
}
@@ -817,14 +717,11 @@
"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;
@@ -1043,8 +940,7 @@
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++) {
@@ -1093,8 +989,6 @@
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) {
@@ -1194,8 +1088,6 @@
return err;
}
-
-
static switch_status_t engage_device(int sample_rate, int codec_ms)
{
PaStreamParameters inputParameters, outputParameters;
@@ -1236,13 +1128,9 @@
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;
@@ -1261,7 +1149,6 @@
/* 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);
@@ -1271,14 +1158,9 @@
}
}
-
-
return SWITCH_STATUS_SUCCESS;
-
-
}
-
static switch_status_t engage_ring_device(int sample_rate, int channels)
{
PaStreamParameters outputParameters;
@@ -1301,7 +1183,6 @@
/* 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;
@@ -1312,8 +1193,6 @@
return SWITCH_STATUS_SUCCESS;
}
-
-
static switch_status_t dtmf_call(char **argv, int argc, switch_stream_handle_t *stream)
{
char *dtmf_str = argv[0];
@@ -1382,7 +1261,6 @@
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)
@@ -1406,7 +1284,6 @@
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)
@@ -1446,12 +1323,9 @@
}
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)
@@ -1676,19 +1550,9 @@
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");
@@ -1815,13 +1679,10 @@
}
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\"> "
@@ -1856,7 +1717,6 @@
}
switch_safe_free(mycmd);
-
return status;
}
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Mon Jan 28 02:26:10 2008
@@ -73,13 +73,8 @@
*/
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;
@@ -116,18 +111,12 @@
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;
}
@@ -135,18 +124,12 @@
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;
}
@@ -154,35 +137,23 @@
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;
}
@@ -247,16 +218,10 @@
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);
@@ -364,19 +329,12 @@
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;
}
@@ -445,14 +403,10 @@
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)) {
@@ -467,10 +421,8 @@
}
}
-
tech_pvt->video_read_frame.datalen = 0;
-
if (switch_test_flag(tech_pvt, TFLAG_IO)) {
switch_status_t status;
@@ -512,14 +464,10 @@
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))) {
@@ -552,14 +500,10 @@
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)) {
@@ -642,15 +586,11 @@
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))) {
@@ -700,16 +640,10 @@
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)) {
@@ -737,29 +671,11 @@
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;
}
@@ -792,14 +708,10 @@
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) {
@@ -1109,15 +1021,10 @@
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))) {
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Mon Jan 28 02:26:10 2008
@@ -119,12 +119,9 @@
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);
}
@@ -1302,8 +1299,6 @@
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;
@@ -1437,8 +1432,6 @@
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);
@@ -1821,22 +1814,19 @@
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());
@@ -2115,8 +2105,6 @@
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;
@@ -2125,14 +2113,10 @@
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);
@@ -2219,18 +2203,13 @@
}
}
}
-
return;
}
}
-
-
return;
fail:
-
nua_respond(nh, 488, "Unsupported Request", NUTAG_WITH_THIS(nua), TAG_END());
-
}
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Mon Jan 28 02:26:10 2008
@@ -385,10 +385,8 @@
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) {
@@ -399,7 +397,6 @@
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);
}
@@ -651,8 +648,8 @@
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;
@@ -665,12 +662,8 @@
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);
@@ -897,14 +890,10 @@
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);
@@ -1497,24 +1486,20 @@
{
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) {
@@ -1962,7 +1947,6 @@
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) &&
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c Mon Jan 28 02:26:10 2008
@@ -750,8 +750,7 @@
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());
}
Modified: freeswitch/trunk/src/mod/endpoints/mod_woomera/mod_woomera.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_woomera/mod_woomera.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_woomera/mod_woomera.c Mon Jan 28 02:26:10 2008
@@ -200,16 +200,12 @@
*/
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
@@ -244,53 +240,25 @@
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;
@@ -316,13 +284,7 @@
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) {
@@ -332,7 +294,7 @@
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:
{
@@ -345,7 +307,6 @@
break;
}
-
return SWITCH_STATUS_SUCCESS;
}
@@ -384,15 +345,10 @@
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(;;) {
@@ -406,15 +362,10 @@
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;
@@ -430,15 +381,9 @@
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) {
@@ -449,7 +394,6 @@
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;
@@ -953,24 +897,17 @@
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);
@@ -1014,18 +951,6 @@
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;
@@ -1038,17 +963,6 @@
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;
@@ -1154,12 +1068,8 @@
return NULL;
}
-
-
-
static void *woomera_thread_run(void *obj)
{
-
int res = 0;
woomera_message wmsg;
woomera_profile *profile;
@@ -1209,28 +1119,8 @@
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")) {
@@ -1277,7 +1167,6 @@
switch_yield(100);
}
-
if (profile->woomera_socket) {
woomera_printf(profile, profile->woomera_socket, "BYE%s", WOOMERA_RECORD_SEPERATOR);
woomera_socket_close(&profile->woomera_socket);
@@ -1290,7 +1179,6 @@
SWITCH_MODULE_RUNTIME_FUNCTION(mod_woomera_runtime)
{
-
woomera_thread_run(&default_profile);
return SWITCH_STATUS_TERM;
Modified: freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
==============================================================================
--- freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c (original)
+++ freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c Mon Jan 28 02:26:10 2008
@@ -653,7 +653,6 @@
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");
@@ -763,8 +762,7 @@
}
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;
}
Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c (original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c Mon Jan 28 02:26:10 2008
@@ -1317,14 +1317,9 @@
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;
@@ -1334,16 +1329,12 @@
{
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);
}
@@ -1368,10 +1359,7 @@
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) {
@@ -1439,10 +1427,7 @@
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) {
@@ -1498,10 +1483,7 @@
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) {
@@ -1575,16 +1557,11 @@
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);
@@ -1604,7 +1581,6 @@
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);
@@ -1634,10 +1610,7 @@
char posbuf[35] = "";
METHOD_SANITY_CHECK();
-
channel = switch_core_session_get_channel(jss->session);
- switch_assert(channel != NULL);
-
CHANNEL_SANITY_CHECK();
if (argc > 0) {
@@ -1700,9 +1673,7 @@
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;
@@ -1729,7 +1700,6 @@
}
channel = switch_core_session_get_channel(jss->session);
- switch_assert(channel != NULL);
if (argc > 0) {
const char *var, *val;
@@ -1813,8 +1783,6 @@
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
channel = switch_core_session_get_channel(jss->session);
- switch_assert(channel != NULL);
-
CHANNEL_SANITY_CHECK();
if (argc < 3) {
@@ -1892,10 +1860,7 @@
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) {
@@ -1958,10 +1923,7 @@
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);
@@ -1974,10 +1936,7 @@
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);
@@ -2009,14 +1968,10 @@
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;
}
@@ -2033,7 +1988,6 @@
METHOD_SANITY_CHECK();
channel = switch_core_session_get_channel(jss->session);
- switch_assert(channel != NULL);
started = switch_timestamp_now();
@@ -2072,9 +2026,7 @@
jsrefcount saveDepth;
METHOD_SANITY_CHECK();
-
channel = switch_core_session_get_channel(jss->session);
- switch_assert(channel != NULL);
started = switch_timestamp_now();
@@ -2111,10 +2063,7 @@
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;
@@ -2203,10 +2152,7 @@
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) {
@@ -2542,7 +2488,6 @@
if (jss && jss->session) {
channel = switch_core_session_get_channel(jss->session);
- switch_assert(channel != NULL);
caller_profile = switch_channel_get_caller_profile(channel);
}
Modified: freeswitch/trunk/src/mod/say/mod_say_de/mod_say_de.c
==============================================================================
--- freeswitch/trunk/src/mod/say/mod_say_de/mod_say_de.c (original)
+++ freeswitch/trunk/src/mod/say/mod_say_de/mod_say_de.c Mon Jan 28 02:26:10 2008
@@ -169,17 +169,12 @@
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;
@@ -420,16 +415,10 @@
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;
Modified: freeswitch/trunk/src/mod/say/mod_say_en/mod_say_en.c
==============================================================================
--- freeswitch/trunk/src/mod/say/mod_say_en/mod_say_en.c (original)
+++ freeswitch/trunk/src/mod/say/mod_say_en/mod_say_en.c Mon Jan 28 02:26:10 2008
@@ -169,17 +169,12 @@
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;
@@ -420,16 +415,10 @@
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;
Modified: freeswitch/trunk/src/mod/say/mod_say_es/mod_say_es.c
==============================================================================
--- freeswitch/trunk/src/mod/say/mod_say_es/mod_say_es.c (original)
+++ freeswitch/trunk/src/mod/say/mod_say_es/mod_say_es.c Mon Jan 28 02:26:10 2008
@@ -169,17 +169,12 @@
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;
@@ -420,16 +415,10 @@
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;
Modified: freeswitch/trunk/src/mod/say/mod_say_fr/mod_say_fr.c
==============================================================================
--- freeswitch/trunk/src/mod/say/mod_say_fr/mod_say_fr.c (original)
+++ freeswitch/trunk/src/mod/say/mod_say_fr/mod_say_fr.c Mon Jan 28 02:26:10 2008
@@ -169,17 +169,12 @@
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;
@@ -420,16 +415,10 @@
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;
Modified: freeswitch/trunk/src/mod/say/mod_say_it/mod_say_it.c
==============================================================================
--- freeswitch/trunk/src/mod/say/mod_say_it/mod_say_it.c (original)
+++ freeswitch/trunk/src/mod/say/mod_say_it/mod_say_it.c Mon Jan 28 02:26:10 2008
@@ -169,17 +169,12 @@
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;
@@ -420,16 +415,10 @@
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;
Modified: freeswitch/trunk/src/mod/say/mod_say_nl/mod_say_nl.c
==============================================================================
--- freeswitch/trunk/src/mod/say/mod_say_nl/mod_say_nl.c (original)
+++ freeswitch/trunk/src/mod/say/mod_say_nl/mod_say_nl.c Mon Jan 28 02:26:10 2008
@@ -169,17 +169,12 @@
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;
@@ -420,16 +415,10 @@
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;
Modified: freeswitch/trunk/src/switch_channel.c
==============================================================================
--- freeswitch/trunk/src/switch_channel.c (original)
+++ freeswitch/trunk/src/switch_channel.c Mon Jan 28 02:26:10 2008
@@ -157,7 +157,6 @@
SWITCH_DECLARE(switch_call_cause_t) switch_channel_get_cause(switch_channel_t *channel)
{
- switch_assert(channel != NULL);
return channel->hangup_cause;
}
@@ -165,7 +164,6 @@
{
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;
@@ -182,9 +180,9 @@
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);
@@ -201,7 +199,6 @@
{
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);
@@ -214,8 +211,6 @@
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)) {
@@ -233,14 +228,14 @@
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);
@@ -255,9 +250,6 @@
char *string;
int i, argc;
char *argv[256];
-
-
- switch_assert(channel != NULL);
if (switch_strlen_zero(dtmf_string)) {
return SWITCH_STATUS_FALSE;
@@ -265,7 +257,7 @@
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;
@@ -281,12 +273,12 @@
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;
@@ -299,18 +291,17 @@
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);
@@ -405,7 +396,7 @@
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;
@@ -433,7 +424,7 @@
}
channel->vi = 0;
switch_mutex_unlock(channel->profile_mutex);
-
+
}
SWITCH_DECLARE(switch_event_header_t *) switch_channel_variable_first(switch_channel_t *channel)
@@ -488,7 +479,7 @@
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);
@@ -507,7 +498,7 @@
{
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;
@@ -576,11 +567,11 @@
{
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;
}
@@ -611,7 +602,7 @@
return SWITCH_STATUS_TIMEOUT;
}
}
-
+
return SWITCH_STATUS_SUCCESS;
}
@@ -665,10 +656,10 @@
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;
@@ -713,19 +704,19 @@
{
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) {
@@ -778,172 +769,172 @@
}
/* 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);
@@ -957,7 +948,7 @@
}
} 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) {
@@ -965,7 +956,7 @@
switch_assert(0);
}
}
- done:
+done:
switch_mutex_unlock(channel->flag_mutex);
return channel->state;
@@ -1014,7 +1005,7 @@
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);
@@ -1038,7 +1029,7 @@
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);
@@ -1055,9 +1046,9 @@
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);
}
@@ -1144,7 +1135,7 @@
profile = channel->caller_profile->originator_caller_profile;
}
switch_mutex_unlock(channel->profile_mutex);
-
+
return profile;
}
@@ -1158,7 +1149,7 @@
profile = channel->caller_profile->originatee_caller_profile;
}
switch_mutex_unlock(channel->profile_mutex);
-
+
return profile;
}
@@ -1190,7 +1181,7 @@
channel->state_handlers[index] = state_handler;
- end:
+end:
switch_mutex_unlock(channel->flag_mutex);
return index;
}
@@ -1281,15 +1272,15 @@
}
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);
@@ -1339,12 +1330,12 @@
}
/* 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;
}
@@ -1442,12 +1433,12 @@
}
/* 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");
@@ -1485,14 +1476,14 @@
}
#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)
{
@@ -1509,7 +1500,7 @@
if (!(p = strchr(q, '$'))) {
break;
}
-
+
if (*(p-1) == '\\') {
q = p + 1;
continue;
@@ -1519,11 +1510,11 @@
q = p + 1;
continue;
}
-
+
nv = 1;
break;
}
-
+
if (!nv) {
return (char *)in;
}
@@ -1537,7 +1528,7 @@
c = data;
for (p = indup; p && *p; p++) {
vtype = 0;
-
+
if (*p == '\\') {
if (*(p + 1) == '$') {
nv = 1;
@@ -1595,11 +1586,11 @@
br--;
}
}
-
+
e++;
}
p = e;
-
+
if ((vval = strchr(vname, '('))) {
e = vval - 1;
*vval++ = '\0';
@@ -1642,11 +1633,11 @@
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;
}
@@ -1690,10 +1681,10 @@
} 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);
@@ -1737,7 +1728,7 @@
}
}
free(indup);
-
+
return data;
}
@@ -1765,7 +1756,7 @@
}
switch_assert(caller_profile != NULL);
-
+
prof[0] = caller_profile->context;
prof[1] = caller_profile->destination_number;
prof[2] = caller_profile->caller_id_name;
@@ -1777,7 +1768,7 @@
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";
@@ -1814,13 +1805,13 @@
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;
@@ -1864,7 +1855,7 @@
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;
}
@@ -1874,7 +1865,7 @@
last_app = ap->app;
last_arg = ap->arg;
}
-
+
if (caller_profile->times) {
switch_time_exp_t tm;
switch_size_t retsize;
@@ -1909,7 +1900,7 @@
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);
@@ -1928,7 +1919,7 @@
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);
@@ -1952,7 +1943,7 @@
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);
Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c (original)
+++ freeswitch/trunk/src/switch_core.c Mon Jan 28 02:26:10 2008
@@ -184,7 +184,6 @@
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) {
Modified: freeswitch/trunk/src/switch_core_codec.c
==============================================================================
--- freeswitch/trunk/src/switch_core_codec.c (original)
+++ freeswitch/trunk/src/switch_core_codec.c Mon Jan 28 02:26:10 2008
@@ -38,12 +38,9 @@
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);
@@ -75,12 +72,9 @@
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);
Modified: freeswitch/trunk/src/switch_core_session.c
==============================================================================
--- freeswitch/trunk/src/switch_core_session.c (original)
+++ freeswitch/trunk/src/switch_core_session.c Mon Jan 28 02:26:10 2008
@@ -77,7 +77,6 @@
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);
@@ -86,10 +85,7 @@
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);
}
}
@@ -255,7 +251,6 @@
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);
}
@@ -363,14 +358,9 @@
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__;
@@ -556,14 +546,8 @@
{
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;
}
@@ -579,12 +563,9 @@
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);
@@ -609,6 +590,7 @@
SWITCH_DECLARE(switch_channel_t *) switch_core_session_get_channel(switch_core_session_t *session)
{
+ switch_assert(session->channel);
return session->channel;
}
@@ -906,7 +888,6 @@
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 = "";
@@ -914,8 +895,6 @@
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);
@@ -934,8 +913,7 @@
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);
@@ -958,14 +936,12 @@
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;
@@ -1085,9 +1061,7 @@
}
done:
-
session->stack_count--;
-
return status;
}
Modified: freeswitch/trunk/src/switch_cpp.cpp
==============================================================================
--- freeswitch/trunk/src/switch_cpp.cpp (original)
+++ freeswitch/trunk/src/switch_cpp.cpp Mon Jan 28 02:26:10 2008
@@ -72,7 +72,7 @@
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);
@@ -300,11 +300,8 @@
}
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,
@@ -380,7 +377,6 @@
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);
@@ -390,14 +386,7 @@
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;
}
@@ -451,12 +440,10 @@
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
@@ -530,19 +517,13 @@
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;
@@ -560,16 +541,13 @@
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");
@@ -585,8 +563,6 @@
}
-
-
switch_status_t process_callback_result(char *ret,
struct input_callback_state *cb_state,
switch_core_session_t *session)
Modified: freeswitch/trunk/src/switch_ivr.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr.c (original)
+++ freeswitch/trunk/src/switch_ivr.c Mon Jan 28 02:26:10 2008
@@ -40,17 +40,12 @@
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);
@@ -121,12 +116,9 @@
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;
@@ -159,14 +151,10 @@
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);
@@ -270,9 +258,6 @@
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;
@@ -382,10 +367,6 @@
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);
@@ -399,16 +380,13 @@
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);
@@ -536,14 +514,11 @@
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;
}
@@ -606,15 +581,12 @@
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';
@@ -709,14 +681,11 @@
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);
@@ -740,14 +709,11 @@
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);
@@ -782,7 +748,7 @@
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;
}
@@ -834,7 +800,6 @@
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;
@@ -846,7 +811,6 @@
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);
@@ -870,19 +834,14 @@
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 */
@@ -930,7 +889,6 @@
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);
}
@@ -938,7 +896,6 @@
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);
@@ -1339,7 +1296,7 @@
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;
@@ -1347,9 +1304,6 @@
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;
}
@@ -1553,7 +1507,7 @@
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;
@@ -1570,7 +1524,6 @@
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)) {
Modified: freeswitch/trunk/src/switch_ivr_async.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_async.c (original)
+++ freeswitch/trunk/src/switch_ivr_async.c Mon Jan 28 02:26:10 2008
@@ -251,7 +251,6 @@
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);
@@ -263,16 +262,13 @@
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;
@@ -350,14 +346,9 @@
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)) {
@@ -384,13 +375,11 @@
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;
}
@@ -673,17 +662,15 @@
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");
@@ -696,11 +683,6 @@
}
}
- 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;
@@ -713,7 +695,6 @@
fh->channels = channels;
fh->samplerate = read_codec->implementation->actual_samples_per_second;
-
if (switch_core_file_open(fh,
file,
channels,
@@ -791,7 +772,6 @@
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;
@@ -830,29 +810,22 @@
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)))) {
@@ -899,11 +872,10 @@
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) {
@@ -977,11 +949,10 @@
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;
@@ -993,16 +964,12 @@
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)))) {
@@ -1105,17 +1072,14 @@
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,
@@ -1123,19 +1087,14 @@
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)) {
@@ -1143,7 +1102,7 @@
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;
@@ -1190,7 +1149,6 @@
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);
@@ -1220,7 +1178,6 @@
}
}
-
if ((status = switch_core_media_bug_add(session, tone_detect_callback, cont, timeout, bflags, &cont->bug)) != SWITCH_STATUS_SUCCESS) {
return status;
}
@@ -1250,7 +1207,6 @@
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);
@@ -1267,7 +1223,6 @@
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");
@@ -1372,28 +1327,24 @@
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;
}
@@ -1401,20 +1352,17 @@
{
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;
}
@@ -1422,20 +1370,17 @@
{
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;
}
@@ -1446,12 +1391,11 @@
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)))) {
@@ -1459,18 +1403,13 @@
}
}
- 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);
@@ -1497,7 +1436,6 @@
return SWITCH_STATUS_FALSE;
}
-
sth = switch_core_session_alloc(session, sizeof(*sth));
sth->pool = switch_core_session_get_pool(session);
sth->session = session;
@@ -1680,15 +1618,11 @@
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",
@@ -1699,7 +1633,6 @@
mypath = strdup(path);
-
if ((nomedia = switch_channel_test_flag(channel, CF_BYPASS_MEDIA))) {
switch_ivr_media(uuid, SMF_REBRIDGE);
}
Modified: freeswitch/trunk/src/switch_ivr_bridge.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_bridge.c (original)
+++ freeswitch/trunk/src/switch_ivr_bridge.c Mon Jan 28 02:26:10 2008
@@ -231,14 +231,11 @@
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);
@@ -261,10 +258,7 @@
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));
@@ -275,10 +269,7 @@
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));
@@ -298,10 +289,7 @@
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));
@@ -316,12 +304,9 @@
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);
@@ -422,13 +407,10 @@
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) {
@@ -439,10 +421,7 @@
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);
@@ -480,15 +459,10 @@
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;
@@ -545,31 +519,18 @@
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;
Modified: freeswitch/trunk/src/switch_ivr_menu.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_menu.c (original)
+++ freeswitch/trunk/src/switch_ivr_menu.c Mon Jan 28 02:26:10 2008
@@ -302,7 +302,6 @@
}
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");
Modified: freeswitch/trunk/src/switch_ivr_originate.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_originate.c (original)
+++ freeswitch/trunk/src/switch_ivr_originate.c Mon Jan 28 02:26:10 2008
@@ -36,18 +36,12 @@
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;
}
@@ -79,7 +73,6 @@
char buf[10] = SWITCH_BLANK_STRING;
char *p, term;
-
if (!strcasecmp(collect->key, "exec")) {
char *data;
const switch_application_interface_t *application_interface;
@@ -244,12 +237,12 @@
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;
@@ -257,15 +250,10 @@
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;
@@ -279,8 +267,6 @@
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");
}
@@ -290,7 +276,7 @@
}
- 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",
@@ -346,8 +332,6 @@
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;
@@ -378,8 +362,6 @@
}
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 {
@@ -453,7 +435,6 @@
}
return status;
-
}
#define MAX_PEERS 128
@@ -555,9 +536,7 @@
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))) {
@@ -830,7 +809,6 @@
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) {
Modified: freeswitch/trunk/src/switch_ivr_play_say.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_play_say.c (original)
+++ freeswitch/trunk/src/switch_ivr_play_say.c Mon Jan 28 02:26:10 2008
@@ -98,13 +98,10 @@
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;
@@ -164,7 +161,6 @@
goto done;
}
-
if (!(sound_path = (char *) switch_xml_attr(language, "sound-path"))) {
sound_path = (char *) switch_xml_attr(language, "sound_path");
}
@@ -345,11 +341,11 @@
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;
@@ -357,22 +353,17 @@
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,
@@ -504,7 +495,6 @@
}
}
-
if (status != SWITCH_STATUS_SUCCESS) {
break;
}
@@ -586,12 +576,7 @@
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);
@@ -672,7 +657,7 @@
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;
@@ -698,9 +683,6 @@
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");
@@ -730,13 +712,11 @@
}
}
-
if (!fh) {
fh = &lfh;
memset(fh, 0, sizeof(lfh));
}
-
if (fh->samples > 0) {
sample_start = fh->samples;
fh->samples = 0;
@@ -748,8 +728,6 @@
fh->prebuf = maybe;
}
}
-
-
if (switch_core_file_open(fh,
file,
@@ -764,7 +742,6 @@
asis = 1;
}
-
write_frame.data = abuf;
write_frame.buflen = FILE_STARTSAMPLES;
@@ -803,14 +780,6 @@
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;
@@ -856,7 +825,6 @@
framelen = codec.implementation->bytes_per_frame;
}
-
if (timer_name) {
uint32_t len;
@@ -984,14 +952,12 @@
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);
@@ -1034,8 +1000,6 @@
write_frame.datalen = write_frame.samples * 2;
}
-
-
llen = olen;
if (timer_name) {
@@ -1069,7 +1033,6 @@
break;
}
-
if (timer_name) {
if (switch_core_timer_next(&timer) != SWITCH_STATUS_SUCCESS) {
break;
@@ -1128,7 +1091,7 @@
{
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,
@@ -1136,12 +1099,6 @@
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);
@@ -1238,7 +1195,7 @@
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;
@@ -1255,9 +1212,6 @@
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;
@@ -1502,10 +1456,7 @@
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;
@@ -1516,14 +1467,13 @@
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 };
@@ -1540,9 +1490,6 @@
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);
Modified: freeswitch/trunk/src/switch_rtp.c
==============================================================================
--- freeswitch/trunk/src/switch_rtp.c (original)
+++ freeswitch/trunk/src/switch_rtp.c Mon Jan 28 02:26:10 2008
@@ -1620,8 +1620,7 @@
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);
}
}
@@ -1637,8 +1636,7 @@
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);
}
}
More information about the Freeswitch-svn
mailing list