*/
#define switch_core_session_destroy(session) switch_core_session_perform_destroy(session, __FILE__, __SWITCH_FUNC__, __LINE__)
+SWITCH_DECLARE(void) switch_core_session_destroy_state(switch_core_session_t *session);
+
/*!
\brief Provide the total number of sessions
\return the total number of allocated sessions
SWITCH_SHN_ON_HIBERNATE,
SWITCH_SHN_ON_RESET,
SWITCH_SHN_ON_PARK,
- SWITCH_SHN_ON_REPORTING
+ SWITCH_SHN_ON_REPORTING,
+ SWITCH_SHN_ON_DESTROY
} switch_state_handler_name_t;
struct switch_state_handler_table {
switch_state_handler_t on_park;
/*! executed when the state changes to reporting */
switch_state_handler_t on_reporting;
+ /*! executed when the state changes to destroy */
+ switch_state_handler_t on_destroy;
void *padding[10];
};
CS_RESET - Channel is in a reset state.
CS_HANGUP - Channel is flagged for hangup and ready to end.
CS_REPORTING - Channel is ready to collect call detail.
-CS_DONE - Channel is ready to be destroyed and out of the state machine
+CS_DESTROY - Channel is ready to be destroyed and out of the state machine
</pre>
*/
typedef enum {
CS_RESET,
CS_HANGUP,
CS_REPORTING,
- CS_DONE,
+ CS_DESTROY,
CS_NONE
} switch_channel_state_t;
static void remove_pvt(private_t *tech_pvt);
static switch_status_t channel_on_init(switch_core_session_t *session);
static switch_status_t channel_on_hangup(switch_core_session_t *session);
+static switch_status_t channel_on_destroy(switch_core_session_t *session);
static switch_status_t channel_on_routing(switch_core_session_t *session);
static switch_status_t channel_on_exchange_media(switch_core_session_t *session);
static switch_status_t channel_on_soft_execute(switch_core_session_t *session);
switch_mutex_unlock(globals.pvt_lock);
}
+static switch_status_t channel_on_destroy(switch_core_session_t *session)
+{
+ switch_channel_t *channel = NULL;
+ private_t *tech_pvt = NULL;
+
+ channel = switch_core_session_get_channel(session);
+ assert(channel != NULL);
+
+ tech_pvt = switch_core_session_get_private(session);
+ assert(tech_pvt != NULL);
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
+
+
static switch_status_t channel_on_hangup(switch_core_session_t *session)
{
switch_channel_t *channel = NULL;
/*.on_execute */ channel_on_execute,
/*.on_hangup */ channel_on_hangup,
/*.on_exchange_media */ channel_on_exchange_media,
- /*.on_soft_execute */ channel_on_soft_execute
+ /*.on_soft_execute */ channel_on_soft_execute,
+ /*.on_consume_media*/ NULL,
+ /*.on_hibernate*/ NULL,
+ /*.on_reset*/ NULL,
+ /*.on_park*/ NULL,
+ /*.on_reporting*/ NULL,
+ /*.on_destroy*/ channel_on_destroy
};
static switch_io_routines_t channel_io_routines = {
SWITCH_STANDARD_API(dl_debug);
static switch_status_t channel_on_init(switch_core_session_t *session);
static switch_status_t channel_on_hangup(switch_core_session_t *session);
+static switch_status_t channel_on_destroy(switch_core_session_t *session);
static switch_status_t channel_on_routing(switch_core_session_t *session);
static switch_status_t channel_on_exchange_media(switch_core_session_t *session);
static switch_status_t channel_on_soft_execute(switch_core_session_t *session);
return SWITCH_STATUS_SUCCESS;
}
+static switch_status_t channel_on_destroy(switch_core_session_t *session)
+{
+ //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);
+
+ if (tech_pvt->rtp_session) {
+ switch_rtp_destroy(&tech_pvt->rtp_session);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "NUKE RTP\n");
+ tech_pvt->rtp_session = NULL;
+ }
+
+ if (switch_core_codec_ready(&tech_pvt->read_codec)) {
+ switch_core_codec_destroy(&tech_pvt->read_codec);
+ }
+
+ if (switch_core_codec_ready(&tech_pvt->write_codec)) {
+ switch_core_codec_destroy(&tech_pvt->write_codec);
+ }
+
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
+
static switch_status_t channel_on_hangup(switch_core_session_t *session)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
ldl_session_destroy(&tech_pvt->dlsession);
}
- if (tech_pvt->rtp_session) {
- switch_rtp_destroy(&tech_pvt->rtp_session);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "NUKE RTP\n");
- tech_pvt->rtp_session = NULL;
- }
-
- if (switch_core_codec_ready(&tech_pvt->read_codec)) {
- switch_core_codec_destroy(&tech_pvt->read_codec);
- }
-
- if (switch_core_codec_ready(&tech_pvt->write_codec)) {
- switch_core_codec_destroy(&tech_pvt->write_codec);
- }
-
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL HANGUP\n", switch_channel_get_name(channel));
return SWITCH_STATUS_SUCCESS;
/*.on_execute */ channel_on_execute,
/*.on_hangup */ channel_on_hangup,
/*.on_exchange_media */ channel_on_exchange_media,
- /*.on_soft_execute */ channel_on_soft_execute
+ /*.on_soft_execute */ channel_on_soft_execute,
+ /*.on_consume_media*/ NULL,
+ /*.on_hibernate*/ NULL,
+ /*.on_reset*/ NULL,
+ /*.on_park*/ NULL,
+ /*.on_reporting*/ NULL,
+ /*.on_destroy*/ channel_on_destroy
};
switch_io_routines_t dingaling_io_routines = {
static switch_status_t channel_on_init(switch_core_session_t *session);
static switch_status_t channel_on_hangup(switch_core_session_t *session);
+static switch_status_t channel_on_destroy(switch_core_session_t *session);
static switch_status_t channel_on_routing(switch_core_session_t *session);
static switch_status_t channel_on_exchange_media(switch_core_session_t *session);
static switch_status_t channel_on_soft_execute(switch_core_session_t *session);
return SWITCH_STATUS_SUCCESS;
}
-static switch_status_t channel_on_hangup(switch_core_session_t *session)
+static switch_status_t channel_on_destroy(switch_core_session_t *session)
{
private_t *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_clear_flag_locked(tech_pvt, TFLAG_CODEC);
-
if (switch_core_codec_ready(&tech_pvt->read_codec)) {
switch_core_codec_destroy(&tech_pvt->read_codec);
}
switch_core_codec_destroy(&tech_pvt->write_codec);
}
+ return SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t channel_on_hangup(switch_core_session_t *session)
+{
+ private_t *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_clear_flag_locked(tech_pvt, TFLAG_CODEC);
+
switch_mutex_lock(globals.mutex);
if (tech_pvt->iax_session) {
if (!switch_test_flag(tech_pvt, TFLAG_HANGUP)) {
/*.on_execute */ channel_on_execute,
/*.on_hangup */ channel_on_hangup,
/*.on_exchange_media */ channel_on_exchange_media,
- /*.on_soft_execute */ channel_on_soft_execute
+ /*.on_soft_execute */ channel_on_soft_execute,
+ /*.on_consume_media*/ NULL,
+ /*.on_hibernate*/ NULL,
+ /*.on_reset*/ NULL,
+ /*.on_park*/ NULL,
+ /*.on_reporting*/ NULL,
+ /*.on_destroy*/ channel_on_destroy
};
switch_io_routines_t iax_io_routines = {
static switch_status_t channel_on_init(switch_core_session_t *session);
static switch_status_t channel_on_hangup(switch_core_session_t *session);
+static switch_status_t channel_on_destroy(switch_core_session_t *session);
static switch_status_t channel_on_routing(switch_core_session_t *session);
static switch_status_t channel_on_exchange_media(switch_core_session_t *session);
static switch_status_t channel_on_soft_execute(switch_core_session_t *session);
assert(tech_pvt != NULL);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL EXECUTE\n", switch_channel_get_name(channel));
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t channel_on_destroy(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_core_timer_destroy(&tech_pvt->timer);
+
+ if (switch_core_codec_ready(&tech_pvt->read_codec)) {
+ switch_core_codec_destroy(&tech_pvt->read_codec);
+ }
+
+ if (switch_core_codec_ready(&tech_pvt->write_codec)) {
+ switch_core_codec_destroy(&tech_pvt->write_codec);
+ }
+
return SWITCH_STATUS_SUCCESS;
}
+
static switch_status_t channel_on_hangup(switch_core_session_t *session)
{
switch_channel_t *channel = NULL;
tech_pvt->other_session = NULL;
}
switch_mutex_unlock(tech_pvt->mutex);
-
- switch_core_timer_destroy(&tech_pvt->timer);
-
- if (switch_core_codec_ready(&tech_pvt->read_codec)) {
- switch_core_codec_destroy(&tech_pvt->read_codec);
- }
-
- if (switch_core_codec_ready(&tech_pvt->write_codec)) {
- switch_core_codec_destroy(&tech_pvt->write_codec);
- }
-
+
return SWITCH_STATUS_SUCCESS;
}
/*.on_soft_execute */ channel_on_soft_execute,
/*.on_consume_media */ channel_on_consume_media,
/*.on_hibernate */ channel_on_hibernate,
- /*.on_reset */ channel_on_reset
+ /*.on_reset */ channel_on_reset,
+ /*.on_park*/ NULL,
+ /*.on_reporting*/ NULL,
+ /*.on_destroy*/ channel_on_destroy
+
};
static switch_io_routines_t channel_io_routines = {
/*.on_execute */ FSConnection::on_execute,\r
/*.on_hangup */ on_hangup,\r
/*.on_loopback */ FSConnection::on_loopback,\r
- /*.on_transmit */ FSConnection::on_transmit\r
+ /*.on_transmit */ FSConnection::on_transmit,\r
+ /*.on_soft_execute */ NULL,\r
+ /*.on_consume_media*/ NULL,\r
+ /*.on_hibernate*/ NULL,\r
+ /*.on_reset*/ NULL,\r
+ /*.on_park*/ NULL,\r
+ /*.on_reporting*/ NULL,\r
+ /*.on_destroy*/ on_destroy\r
};\r
\r
\r
return SWITCH_STATUS_SUCCESS;\r
}\r
\r
-\r
-/* this function has to be called with the original session beause the FSConnection might already be destroyed and we \r
- will can't have it be a method of a dead object\r
- */\r
-static switch_status_t on_hangup(switch_core_session_t *session)\r
+static switch_status_t on_destroy(switch_core_session_t *session)\r
{\r
switch_channel_t *channel = switch_core_session_get_channel(session);\r
opal_private_t *tech_pvt = (opal_private_t *) switch_core_session_get_private(session);\r
- \r
- /* if this is still here it was our idea to hangup not opal's */\r
- if (tech_pvt->me) {\r
- Q931::CauseValues cause = (Q931::CauseValues)switch_channel_get_cause_q850(channel);\r
- tech_pvt->me->SetQ931Cause(cause);\r
- tech_pvt->me->ClearCallSynchronous(NULL, H323TranslateToCallEndReason(cause, UINT_MAX));\r
- tech_pvt->me = NULL;\r
- }\r
- \r
+\r
if (tech_pvt->read_codec.implementation) {\r
switch_core_codec_destroy(&tech_pvt->read_codec);\r
}\r
\r
switch_core_session_unset_read_codec(session);\r
switch_core_session_unset_write_codec(session);\r
+ \r
+ return SWITCH_STATUS_SUCCESS;\r
+\r
+}\r
\r
+/* this function has to be called with the original session beause the FSConnection might already be destroyed and we \r
+ will can't have it be a method of a dead object\r
+ */\r
+static switch_status_t on_hangup(switch_core_session_t *session)\r
+{\r
+ switch_channel_t *channel = switch_core_session_get_channel(session);\r
+ opal_private_t *tech_pvt = (opal_private_t *) switch_core_session_get_private(session);\r
+ \r
+ /* if this is still here it was our idea to hangup not opal's */\r
+ if (tech_pvt->me) {\r
+ Q931::CauseValues cause = (Q931::CauseValues)switch_channel_get_cause_q850(channel);\r
+ tech_pvt->me->SetQ931Cause(cause);\r
+ tech_pvt->me->ClearCallSynchronous(NULL, H323TranslateToCallEndReason(cause, UINT_MAX));\r
+ tech_pvt->me = NULL;\r
+ }\r
+ \r
return SWITCH_STATUS_SUCCESS;\r
}\r
\r
static void remove_pvt(private_t *tech_pvt);
static switch_status_t channel_on_init(switch_core_session_t *session);
static switch_status_t channel_on_hangup(switch_core_session_t *session);
+static switch_status_t channel_on_destroy(switch_core_session_t *session);
static switch_status_t channel_on_routing(switch_core_session_t *session);
static switch_status_t channel_on_exchange_media(switch_core_session_t *session);
static switch_status_t channel_on_soft_execute(switch_core_session_t *session);
}
}
+static switch_status_t channel_on_destroy(switch_core_session_t *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_on_hangup(switch_core_session_t *session)
{
private_t *tech_pvt = switch_core_session_get_private(session);
/*.on_execute */ channel_on_execute,
/*.on_hangup */ channel_on_hangup,
/*.on_exchange_media */ channel_on_exchange_media,
- /*.on_soft_execute */ channel_on_soft_execute
+ /*.on_soft_execute */ channel_on_soft_execute,
+ /*.on_consume_media*/ NULL,
+ /*.on_hibernate*/ NULL,
+ /*.on_reset*/ NULL,
+ /*.on_park*/ NULL,
+ /*.on_reporting*/ NULL,
+ /*.on_destroy*/ channel_on_destroy
+
};
switch_io_routines_t portaudio_io_routines = {
static switch_status_t channel_on_init(switch_core_session_t *session);
static switch_status_t channel_on_hangup(switch_core_session_t *session);
+static switch_status_t channel_on_destroy(switch_core_session_t *session);
static switch_status_t channel_on_routing(switch_core_session_t *session);
static switch_status_t channel_on_exchange_media(switch_core_session_t *session);
static switch_status_t channel_on_soft_execute(switch_core_session_t *session);
return SWITCH_STATUS_SUCCESS;
}
-static switch_status_t channel_on_hangup(switch_core_session_t *session)
+static switch_status_t channel_on_destroy(switch_core_session_t *session)
{
switch_channel_t *channel = NULL;
private_t *tech_pvt = NULL;
tech_pvt = switch_core_session_get_private(session);
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 (switch_core_codec_ready(&tech_pvt->read_codec)) {
switch_core_codec_destroy(&tech_pvt->read_codec);
switch_core_codec_destroy(&tech_pvt->write_codec);
}
+ 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);
+ assert(channel != NULL);
+
+ tech_pvt = switch_core_session_get_private(session);
+ 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);
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL HANGUP\n", switch_channel_get_name(channel));
switch_mutex_lock(globals.mutex);
/*.on_execute */ channel_on_execute,
/*.on_hangup */ channel_on_hangup,
/*.on_exchange_media */ channel_on_exchange_media,
- /*.on_soft_execute */ channel_on_soft_execute
+ /*.on_soft_execute */ channel_on_soft_execute,
+ /*.on_consume_media*/ NULL,
+ /*.on_hibernate*/ NULL,
+ /*.on_reset*/ NULL,
+ /*.on_park*/ NULL,
+ /*.on_reporting*/ NULL,
+ /*.on_destroy*/ channel_on_destroy
+
};
switch_io_routines_t reference_io_routines = {
static switch_status_t channel_on_init(switch_core_session_t * session);
static switch_status_t channel_on_hangup(switch_core_session_t * session);
+static switch_status_t channel_on_destroy(switch_core_session_t * session);
static switch_status_t channel_on_routing(switch_core_session_t * session);
static switch_status_t channel_on_exchange_media(switch_core_session_t * session);
static switch_status_t channel_on_soft_execute(switch_core_session_t * session);
return SWITCH_STATUS_SUCCESS;
}
+static switch_status_t channel_on_hangup(switch_core_session_t * session)
+{
+ switch_channel_t *channel = NULL;
+ private_t *tech_pvt = NULL;
+
+ channel = switch_core_session_get_channel(session);
+ switch_assert(channel != NULL);
+
+ tech_pvt = switch_core_session_get_private(session);
+ switch_assert(tech_pvt != NULL);
+
+ if (switch_core_codec_ready(&tech_pvt->read_codec)) {
+ switch_core_codec_destroy(&tech_pvt->read_codec);
+ }
+
+ if (switch_core_codec_ready(&tech_pvt->write_codec)) {
+ switch_core_codec_destroy(&tech_pvt->write_codec);
+ }
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
+
static switch_status_t channel_on_hangup(switch_core_session_t * session)
{
switch_channel_t *channel = NULL;
skypiax_signaling_write(tech_pvt, msg_to_skype);
}
- if (switch_core_codec_ready(&tech_pvt->read_codec)) {
- switch_core_codec_destroy(&tech_pvt->read_codec);
- }
-
- if (switch_core_codec_ready(&tech_pvt->write_codec)) {
- switch_core_codec_destroy(&tech_pvt->write_codec);
- }
memset(tech_pvt->session_uuid_str, '\0', sizeof(tech_pvt->session_uuid_str));
DEBUGA_SKYPE("%s CHANNEL HANGUP\n", SKYPIAX_P_LOG, switch_channel_get_name(channel));
/*.on_execute */ channel_on_execute,
/*.on_hangup */ channel_on_hangup,
/*.on_exchange_media */ channel_on_exchange_media,
- /*.on_soft_execute */ channel_on_soft_execute
+ /*.on_soft_execute */ channel_on_soft_execute,
+ /*.on_consume_media*/ NULL,
+ /*.on_hibernate*/ NULL,
+ /*.on_reset*/ NULL,
+ /*.on_park*/ NULL,
+ /*.on_reporting*/ NULL,
+ /*.on_destroy*/ channel_on_destroy
};
switch_io_routines_t skypiax_io_routines = {
}
}
+switch_status_t sofia_on_destroy(switch_core_session_t *session)
+{
+ 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_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s SOFIA DESTROY\n", switch_channel_get_name(channel));
+
+ if (switch_core_codec_ready(&tech_pvt->read_codec)) {
+ switch_core_codec_destroy(&tech_pvt->read_codec);
+ }
+
+ if (switch_core_codec_ready(&tech_pvt->write_codec)) {
+ switch_core_codec_destroy(&tech_pvt->write_codec);
+ }
+
+ switch_core_session_unset_read_codec(session);
+ switch_core_session_unset_write_codec(session);
+
+ switch_mutex_lock(tech_pvt->profile->flag_mutex);
+ tech_pvt->profile->inuse--;
+ switch_mutex_unlock(tech_pvt->profile->flag_mutex);
+
+ sofia_glue_deactivate_rtp(tech_pvt);
+
+ return SWITCH_STATUS_SUCCESS;
+
+}
+
switch_status_t sofia_on_hangup(switch_core_session_t *session)
{
switch_core_session_t *a_session;
sofia_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
}
- sofia_glue_deactivate_rtp(tech_pvt);
-
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Channel %s hanging up, cause: %s\n",
switch_channel_get_name(channel), switch_channel_cause2str(cause));
sofia_clear_flag(tech_pvt, TFLAG_IO);
- if (switch_core_codec_ready(&tech_pvt->read_codec)) {
- switch_core_codec_destroy(&tech_pvt->read_codec);
- }
-
- if (switch_core_codec_ready(&tech_pvt->write_codec)) {
- switch_core_codec_destroy(&tech_pvt->write_codec);
- }
-
- switch_core_session_unset_read_codec(session);
- switch_core_session_unset_write_codec(session);
-
- switch_mutex_lock(tech_pvt->profile->flag_mutex);
- tech_pvt->profile->inuse--;
- switch_mutex_unlock(tech_pvt->profile->flag_mutex);
-
if (tech_pvt->sofia_private) {
*tech_pvt->sofia_private->uuid = '\0';
}
/*.on_soft_execute */ sofia_on_soft_execute,
/*.on_consume_media */ NULL,
/*.on_hibernate */ sofia_on_hibernate,
- /*.on_reset */ sofia_on_reset
+ /*.on_reset */ sofia_on_reset,
+ /*.on_park*/ NULL,
+ /*.on_reporting*/ NULL,
+ /*.on_destroy*/ sofia_on_destroy
};
static switch_status_t sofia_manage(char *relative_oid, switch_management_action_t action, char *data, switch_size_t datalen)
return SWITCH_STATUS_SUCCESS;
}
+static switch_status_t unicall_on_destroy(switch_core_session_t *session)
+{
+ switch_channel_t *channel;
+ private_t *tech_pvt;
+
+ channel = switch_core_session_get_channel(session);
+ assert(channel != NULL);
+ tech_pvt = switch_core_session_get_private(session);
+ assert(tech_pvt != NULL);
+
+ if (switch_core_codec_ready(&tech_pvt->read_codec))
+ switch_core_codec_destroy(&tech_pvt->read_codec);
+ if (switch_core_codec_ready(&tech_pvt->write_codec))
+ switch_core_codec_destroy(&tech_pvt->write_codec);
+
+ return SWITCH_STATUS_SUCCESS;
+
+}
+
static switch_status_t unicall_on_hangup(switch_core_session_t *session)
{
switch_channel_t *channel;
switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
//switch_thread_cond_signal(tech_pvt->cond);
- if (switch_core_codec_ready(&tech_pvt->read_codec))
- switch_core_codec_destroy(&tech_pvt->read_codec);
- if (switch_core_codec_ready(&tech_pvt->write_codec)
- switch_core_codec_destroy(&tech_pvt->write_codec);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s channel hangup\n", switch_channel_get_name(channel));
/*.on_execute */ unicall_on_execute,
/*.on_hangup */ unicall_on_hangup,
/*.on_exchange_media */ unicall_on_exchange_media,
- /*.on_soft_execute */ unicall_on_soft_execute
+ /*.on_soft_execute */ unicall_on_soft_execute,
+ /*.on_consume_media*/ NULL,
+ /*.on_hibernate*/ NULL,
+ /*.on_reset*/ NULL,
+ /*.on_park*/ NULL,
+ /*.on_reporting*/ NULL,
+ /*.on_destroy*/ unicall_on_destroy
+
};
switch_io_routines_t unicall_io_routines =
"CS_RESET",
"CS_HANGUP",
"CS_REPORTING",
- "CS_DONE",
+ "CS_DESTROY",
NULL
};
}
}
- return CS_DONE;
+ return CS_DESTROY;
}
SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_running_state(switch_channel_t *channel, switch_channel_state_t state,
int ok = 0;
switch_assert(channel != NULL);
- switch_assert(state <= CS_DONE);
+ switch_assert(state <= CS_DESTROY);
switch_mutex_lock(channel->state_mutex);
last_state = channel->state;
- switch_assert(last_state <= CS_DONE);
+ switch_assert(last_state <= CS_DESTROY);
if (last_state == state) {
goto done;
case CS_ROUTING:
case CS_EXECUTE:
case CS_HANGUP:
- case CS_DONE:
+ case CS_DESTROY:
default:
break;
case CS_HANGUP:
switch (state) {
case CS_REPORTING:
- case CS_DONE:
+ case CS_DESTROY:
ok++;
default:
break;
case CS_REPORTING:
switch (state) {
- case CS_DONE:
+ case CS_DESTROY:
ok++;
default:
break;
channel->hangup_cause = SWITCH_CAUSE_NORMAL_CLEARING;
}
- if (state < CS_DONE) {
+ if (state < CS_DESTROY) {
switch_core_session_signal_state_change(channel->session);
}
} else {
switch_assert((*frame)->codec != NULL);
-
- switch_mutex_lock((*frame)->codec->mutex);
if (!(session->read_codec && (*frame)->codec && (*frame)->codec->implementation) && switch_core_codec_ready((*frame)->codec)) {
status = SWITCH_STATUS_FALSE;
- switch_mutex_unlock((*frame)->codec->mutex);
goto done;
}
codec_impl = *(*frame)->codec->implementation;
- switch_mutex_unlock((*frame)->codec->mutex);
if (session->read_codec->implementation->impl_id != codec_impl.impl_id) {
need_codec = TRUE;
switch_status_t status = SWITCH_STATUS_FALSE;
if (session->rwlock) {
- if (switch_test_flag(session, SSF_DESTROYED) || switch_channel_get_state(session->channel) >= CS_DONE) {
+ if (switch_test_flag(session, SSF_DESTROYED) || switch_channel_get_state(session->channel) >= CS_DESTROY) {
status = SWITCH_STATUS_FALSE;
#ifdef SWITCH_DEBUG_RWLOCKS
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_ERROR, "%s Read lock FAIL\n",
return session->thread_running;
}
-
SWITCH_DECLARE(void) switch_core_session_perform_destroy(switch_core_session_t **session, const char *file, const char *func, int line)
{
switch_memory_pool_t *pool;
switch_event_fire(&event);
}
+ switch_core_session_destroy_state(*session);
switch_buffer_destroy(&(*session)->raw_read_buffer);
switch_buffer_destroy(&(*session)->raw_write_buffer);
UNPROTECT_INTERFACE(endpoint_interface);
}
+
+
SWITCH_STANDARD_SCHED_FUNC(sch_heartbeat_callback)
{
switch_event_t *event;
case SWITCH_EVENT_CHANNEL_STATE:
{
char *state = switch_event_get_header_nil(event, "channel-state-number");
- switch_channel_state_t state_i = CS_DONE;
+ switch_channel_state_t state_i = CS_DESTROY;
if (!switch_strlen_zero(state)) {
state_i = atoi(state);
switch (state_i) {
case CS_HANGUP:
- case CS_DONE:
+ case CS_DESTROY:
break;
case CS_ROUTING:
sql = switch_mprintf("update channels set state='%s',cid_name='%q',cid_num='%q',ip_addr='%s',dest='%q',dialplan='%q',context='%q' "
switch_channel_get_name(session->channel), switch_channel_cause2str(switch_channel_get_cause(session->channel)));
}
+static void switch_core_standard_on_destroy(switch_core_session_t *session)
+{
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Standard DESTROY\n",
+ switch_channel_get_name(session->channel));
+}
+
static void switch_core_standard_on_reset(switch_core_session_t *session)
{
SWITCH_DECLARE(void) switch_core_session_run(switch_core_session_t *session)
{
- switch_channel_state_t state = CS_NEW, midstate = CS_DONE, endstate;
+ switch_channel_state_t state = CS_NEW, midstate = CS_DESTROY, endstate;
const switch_endpoint_interface_t *endpoint_interface;
const switch_state_handler_table_t *driver_state_handler = NULL;
const switch_state_handler_table_t *application_state_handler = NULL;
switch_mutex_lock(session->mutex);
- while ((state = switch_channel_get_state(session->channel)) != CS_DONE) {
+ while ((state = switch_channel_get_state(session->channel)) != CS_DESTROY) {
switch_channel_wait_for_flag(session->channel, CF_BLOCK_STATE, SWITCH_FALSE, 0, NULL);
case CS_NEW: /* Just created, Waiting for first instructions */
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) State NEW\n", switch_channel_get_name(session->channel));
break;
- case CS_DONE:
+ case CS_DESTROY:
goto done;
case CS_REPORTING: /* Call Detail */
{
STATE_MACRO(reporting, "REPORTING");
- switch_channel_set_state(session->channel, CS_DONE);
+ switch_channel_set_state(session->channel, CS_DESTROY);
}
goto done;
case CS_HANGUP: /* Deactivate and end the thread */
break;
}
- if (midstate == CS_DONE) {
+ if (midstate == CS_DESTROY) {
break;
}
session->thread_running = 0;
}
+SWITCH_DECLARE(void) switch_core_session_destroy_state(switch_core_session_t *session)
+{
+ switch_channel_state_t state = CS_DESTROY, midstate = CS_DESTROY;
+ const switch_endpoint_interface_t *endpoint_interface;
+ const switch_state_handler_table_t *driver_state_handler = NULL;
+ const switch_state_handler_table_t *application_state_handler = NULL;
+ int proceed = 1;
+ int global_proceed = 1;
+ int do_extra_handlers = 1;
+ int silly = 0;
+ int index = 0;
+
+ switch_assert(session != NULL);
+
+ session->thread_running = 1;
+ endpoint_interface = session->endpoint_interface;
+ switch_assert(endpoint_interface != NULL);
+
+ driver_state_handler = endpoint_interface->state_handler;
+ switch_assert(driver_state_handler != NULL);
+
+ STATE_MACRO(destroy, "DESTROY");
+
+ return;
+}
+
/* For Emacs:
* Local Variables:
* mode:c