#define SWITCH_L_SDP_VARIABLE "switch_l_sdp"
#define SWITCH_B_SDP_VARIABLE "switch_m_sdp"
#define SWITCH_BRIDGE_VARIABLE "bridge_to"
+#define SWITCH_LAST_BRIDGE_VARIABLE "last_bridge_to"
#define SWITCH_SIGNAL_BRIDGE_VARIABLE "signal_bridge_to"
#define SWITCH_SIGNAL_BOND_VARIABLE "signal_bond"
#define SWITCH_ORIGINATOR_VARIABLE "originator"
}
break;
case SWITCH_EVENT_CHANNEL_DESTROY:
- new_sql() = switch_mprintf("delete from channels where uuid='%q' and hostname='%q'",
- switch_event_get_header_nil(event, "unique-id"), switch_core_get_variable("hostname"));
+ {
+ const char *uuid = switch_event_get_header(event, "unique-id");
+ const char *sig = switch_event_get_header(event, "signal_bridge");
+
+ if (uuid) {
+ new_sql() = switch_mprintf("delete from channels where uuid='%q' and hostname='%q'",
+ uuid, switch_core_get_variable("hostname"));
+ if (switch_true(sig)) {
+ new_sql() = switch_mprintf("delete from calls where caller_uuid='%q' and hostname='%q'",
+ uuid, switch_core_get_variable("hostname"));
+ }
+ }
+ }
break;
case SWITCH_EVENT_CHANNEL_UUID:
{
}
switch_channel_set_variable(channel, SWITCH_BRIDGE_VARIABLE, switch_channel_get_variable(channel, SWITCH_SIGNAL_BRIDGE_VARIABLE));
+ switch_channel_set_variable(channel, SWITCH_LAST_BRIDGE_VARIABLE, switch_channel_get_variable(channel, SWITCH_SIGNAL_BRIDGE_VARIABLE));
if (switch_channel_test_flag(channel, CF_BRIDGE_ORIGINATOR)) {
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_BRIDGE) == SWITCH_STATUS_SUCCESS) {
switch_channel_add_state_handler(caller_channel, &signal_bridge_state_handlers);
switch_channel_add_state_handler(peer_channel, &signal_bridge_state_handlers);
+ switch_channel_set_variable(caller_channel, "signal_bridge", "true");
+ switch_channel_set_variable(peer_channel, "signal_bridge", "true");
+
/* fire events that will change the data table from "show channels" */
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_EXECUTE) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(caller_channel, event);
if (switch_core_session_read_lock(peer_session) == SWITCH_STATUS_SUCCESS) {
switch_channel_set_variable(caller_channel, SWITCH_BRIDGE_VARIABLE, switch_core_session_get_uuid(peer_session));
switch_channel_set_variable(peer_channel, SWITCH_BRIDGE_VARIABLE, switch_core_session_get_uuid(session));
+ switch_channel_set_variable(caller_channel, SWITCH_LAST_BRIDGE_VARIABLE, switch_core_session_get_uuid(peer_session));
+ switch_channel_set_variable(peer_channel, SWITCH_LAST_BRIDGE_VARIABLE, switch_core_session_get_uuid(session));
if (!switch_channel_media_ready(caller_channel) ||
(!switch_channel_test_flag(peer_channel, CF_ANSWERED) && !switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA))) {