mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-24 21:22:09 +00:00
change CS_DONE to CS_DESTROY and add state handler for destroy and tear down critical parts of the channel from this method which is not called until it's impossible for anything to be referencing the channel (after final write lock and before destroying the pool)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12986 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
@@ -143,6 +143,7 @@ static void add_pvt(private_t *tech_pvt, int master);
|
||||
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);
|
||||
@@ -425,6 +426,22 @@ static void remove_pvt(private_t *tech_pvt)
|
||||
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;
|
||||
@@ -719,7 +736,13 @@ static switch_state_handler_table_t channel_event_handlers = {
|
||||
/*.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 = {
|
||||
|
||||
@@ -206,6 +206,7 @@ SWITCH_STANDARD_API(dl_pres);
|
||||
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);
|
||||
@@ -1207,6 +1208,33 @@ static switch_status_t channel_on_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);
|
||||
@@ -1238,20 +1266,6 @@ static switch_status_t channel_on_hangup(switch_core_session_t *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;
|
||||
@@ -1554,7 +1568,13 @@ switch_state_handler_table_t dingaling_event_handlers = {
|
||||
/*.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 = {
|
||||
|
||||
@@ -416,6 +416,7 @@ static switch_status_t iax_set_codec(private_t *tech_pvt, struct iax_session *ia
|
||||
|
||||
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);
|
||||
@@ -488,6 +489,23 @@ static switch_status_t channel_on_execute(switch_core_session_t *session)
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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)
|
||||
{
|
||||
private_t *tech_pvt = switch_core_session_get_private(session);
|
||||
@@ -498,14 +516,6 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session)
|
||||
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);
|
||||
}
|
||||
|
||||
if (!switch_core_codec_ready(&tech_pvt->write_codec)) {
|
||||
switch_core_codec_destroy(&tech_pvt->write_codec);
|
||||
}
|
||||
|
||||
switch_mutex_lock(globals.mutex);
|
||||
if (tech_pvt->iax_session) {
|
||||
if (!switch_test_flag(tech_pvt, TFLAG_HANGUP)) {
|
||||
@@ -787,7 +797,13 @@ switch_state_handler_table_t iax_state_handlers = {
|
||||
/*.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 = {
|
||||
|
||||
@@ -88,6 +88,7 @@ static struct {
|
||||
|
||||
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);
|
||||
@@ -339,10 +340,36 @@ static switch_status_t channel_on_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;
|
||||
@@ -370,17 +397,7 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session)
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -754,7 +771,11 @@ static switch_state_handler_table_t channel_event_handlers = {
|
||||
/*.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 = {
|
||||
|
||||
@@ -70,7 +70,14 @@ static switch_state_handler_table_t opalfs_event_handlers = {
|
||||
/*.on_execute */ FSConnection::on_execute,
|
||||
/*.on_hangup */ on_hangup,
|
||||
/*.on_loopback */ FSConnection::on_loopback,
|
||||
/*.on_transmit */ FSConnection::on_transmit
|
||||
/*.on_transmit */ FSConnection::on_transmit,
|
||||
/*.on_soft_execute */ NULL,
|
||||
/*.on_consume_media*/ NULL,
|
||||
/*.on_hibernate*/ NULL,
|
||||
/*.on_reset*/ NULL,
|
||||
/*.on_park*/ NULL,
|
||||
/*.on_reporting*/ NULL,
|
||||
/*.on_destroy*/ on_destroy
|
||||
};
|
||||
|
||||
|
||||
@@ -826,23 +833,11 @@ switch_status_t FSConnection::on_execute()
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/* this function has to be called with the original session beause the FSConnection might already be destroyed and we
|
||||
will can't have it be a method of a dead object
|
||||
*/
|
||||
static switch_status_t on_hangup(switch_core_session_t *session)
|
||||
static switch_status_t on_destroy(switch_core_session_t *session)
|
||||
{
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
opal_private_t *tech_pvt = (opal_private_t *) switch_core_session_get_private(session);
|
||||
|
||||
/* if this is still here it was our idea to hangup not opal's */
|
||||
if (tech_pvt->me) {
|
||||
Q931::CauseValues cause = (Q931::CauseValues)switch_channel_get_cause_q850(channel);
|
||||
tech_pvt->me->SetQ931Cause(cause);
|
||||
tech_pvt->me->ClearCallSynchronous(NULL, H323TranslateToCallEndReason(cause, UINT_MAX));
|
||||
tech_pvt->me = NULL;
|
||||
}
|
||||
|
||||
|
||||
if (tech_pvt->read_codec.implementation) {
|
||||
switch_core_codec_destroy(&tech_pvt->read_codec);
|
||||
}
|
||||
@@ -869,7 +864,27 @@ static switch_status_t on_hangup(switch_core_session_t *session)
|
||||
|
||||
switch_core_session_unset_read_codec(session);
|
||||
switch_core_session_unset_write_codec(session);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
/* this function has to be called with the original session beause the FSConnection might already be destroyed and we
|
||||
will can't have it be a method of a dead object
|
||||
*/
|
||||
static switch_status_t on_hangup(switch_core_session_t *session)
|
||||
{
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
opal_private_t *tech_pvt = (opal_private_t *) switch_core_session_get_private(session);
|
||||
|
||||
/* if this is still here it was our idea to hangup not opal's */
|
||||
if (tech_pvt->me) {
|
||||
Q931::CauseValues cause = (Q931::CauseValues)switch_channel_get_cause_q850(channel);
|
||||
tech_pvt->me->SetQ931Cause(cause);
|
||||
tech_pvt->me->ClearCallSynchronous(NULL, H323TranslateToCallEndReason(cause, UINT_MAX));
|
||||
tech_pvt->me = NULL;
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -148,6 +148,7 @@ static void add_pvt(private_t *tech_pvt, int master);
|
||||
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);
|
||||
@@ -469,6 +470,13 @@ static void tech_close_file(private_t *tech_pvt)
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
@@ -692,7 +700,14 @@ switch_state_handler_table_t portaudio_event_handlers = {
|
||||
/*.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 = {
|
||||
|
||||
@@ -100,6 +100,7 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_ip, globals.ip);
|
||||
|
||||
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);
|
||||
@@ -185,6 +186,30 @@ static switch_status_t channel_on_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 = 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);
|
||||
|
||||
|
||||
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;
|
||||
@@ -200,14 +225,6 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session)
|
||||
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));
|
||||
switch_mutex_lock(globals.mutex);
|
||||
@@ -462,7 +479,14 @@ switch_state_handler_table_t reference_state_handlers = {
|
||||
/*.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 = {
|
||||
|
||||
@@ -79,6 +79,7 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_rates_string,
|
||||
|
||||
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);
|
||||
@@ -182,6 +183,29 @@ static switch_status_t channel_on_init(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;
|
||||
@@ -205,13 +229,6 @@ static switch_status_t channel_on_hangup(switch_core_session_t * session)
|
||||
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));
|
||||
@@ -490,7 +507,13 @@ switch_state_handler_table_t skypiax_state_handlers = {
|
||||
/*.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 = {
|
||||
|
||||
@@ -232,6 +232,34 @@ static int hangup_cause_to_sip(switch_call_cause_t cause)
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -282,8 +310,6 @@ switch_status_t sofia_on_hangup(switch_core_session_t *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));
|
||||
|
||||
@@ -379,21 +405,6 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
|
||||
|
||||
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';
|
||||
}
|
||||
@@ -2378,7 +2389,10 @@ switch_state_handler_table_t sofia_event_handlers = {
|
||||
/*.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)
|
||||
|
||||
@@ -932,6 +932,25 @@ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "unicall_on_execute(%p)\n
|
||||
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;
|
||||
@@ -948,10 +967,6 @@ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "unicall_on_hangup(%p)\n"
|
||||
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));
|
||||
|
||||
@@ -1722,7 +1737,14 @@ switch_state_handler_table_t unicall_state_handlers =
|
||||
/*.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 =
|
||||
|
||||
Reference in New Issue
Block a user