SWITCH_DECLARE(void) switch_channel_clear_private_flag(switch_channel_t *channel, uint32_t flags);
SWITCH_DECLARE(int) switch_channel_test_private_flag(switch_channel_t *channel, uint32_t flags);
-SWITCH_DECLARE(void) switch_channel_set_app_flag(switch_channel_t *channel, uint32_t flags);
-SWITCH_DECLARE(void) switch_channel_clear_app_flag(switch_channel_t *channel, uint32_t flags);
-SWITCH_DECLARE(int) switch_channel_test_app_flag(switch_channel_t *channel, uint32_t flags);
+SWITCH_DECLARE(void) switch_channel_set_app_flag_key(const char *app, switch_channel_t *channel, uint32_t flags);
+SWITCH_DECLARE(void) switch_channel_clear_app_flag_key(const char *app, switch_channel_t *channel, uint32_t flags);
+SWITCH_DECLARE(int) switch_channel_test_app_flag_key(const char *app, switch_channel_t *channel, uint32_t flags);
+
+#define switch_channel_set_app_flag(_c, _f) switch_channel_set_app_flag_key(__FILE__, _c, _f)
+#define switch_channel_clear_app_flag(_c, _f) switch_channel_clear_app_flag_key(__FILE__, _c, _f)
+#define switch_channel_test_app_flag(_c, _f) switch_channel_test_app_flag_key(__FILE__, _c, _f)
+
+
SWITCH_DECLARE(void) switch_channel_set_hangup_time(switch_channel_t *channel);
SWITCH_DECLARE(switch_call_direction_t) switch_channel_direction(switch_channel_t *channel);
SWITCH_DECLARE(switch_core_session_t *) switch_channel_get_session(switch_channel_t *channel);
switch (pvt->t38_mode) {
case T38_MODE_REQUESTED:
{
- if (switch_channel_test_app_flag(channel, CF_APP_T38)) {
+ if (switch_channel_test_app_flag_key("T38", channel, CF_APP_T38)) {
switch_core_session_message_t msg = { 0 };
pvt->t38_mode = T38_MODE_NEGOTIATED;
spanfax_init(pvt, T38_MODE);
break;
case T38_MODE_UNKNOWN:
{
- if (switch_channel_test_app_flag(channel, CF_APP_T38)) {
+ if (switch_channel_test_app_flag_key("T38", channel, CF_APP_T38)) {
if (negotiate_t38(pvt) == T38_MODE_NEGOTIATED) {
/* is is safe to call this again, it was already called above in AUDIO_MODE */
/* but this is the only way to set up the t38 stuff */
msg.string_arg = peer_uuid;
switch_core_session_receive_message(session, &msg);
- while (switch_channel_ready(channel) && switch_channel_up(other_channel) && !switch_channel_test_app_flag(channel, CF_APP_T38)) {
+ while (switch_channel_ready(channel) && switch_channel_up(other_channel) && !switch_channel_test_app_flag_key("T38", channel, CF_APP_T38)) {
status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
if (!SWITCH_READ_ACCEPTABLE(status) || pvt->done) {
goto end_unlock;
}
- if (!switch_channel_test_app_flag(channel, CF_APP_T38)) {
+ if (!switch_channel_test_app_flag_key("T38", channel, CF_APP_T38)) {
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s Could not negotiate T38\n", switch_channel_get_name(channel));
goto end_unlock;
/* wake up the audio side */
switch_channel_set_private(channel, "_t38_pvt", pvt);
- switch_channel_set_app_flag(other_channel, CF_APP_T38);
+ switch_channel_set_app_flag_key("T38", other_channel, CF_APP_T38);
while (switch_channel_ready(channel) && switch_channel_up(other_channel)) {
switch_event_fire(&event);
}
- while (switch_channel_ready(channel) && switch_channel_up(other_channel) && !switch_channel_test_app_flag(channel, CF_APP_T38)) {
+ while (switch_channel_ready(channel) && switch_channel_up(other_channel) && !switch_channel_test_app_flag_key("T38", channel, CF_APP_T38)) {
status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
if (!SWITCH_READ_ACCEPTABLE(status)) {
goto end_unlock;
}
- if (!switch_channel_test_app_flag(channel, CF_APP_T38)) {
+ if (!switch_channel_test_app_flag_key("T38", channel, CF_APP_T38)) {
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
goto end_unlock;
}
switch_mutex_t *mutex;
} fifo_queue_t;
+typedef enum {
+ FIFO_APP_BRIDGE_TAG = (1 << 0),
+ FIFO_APP_TRACKING = (1 << 1)
+} fifo_app_flag_t;
switch_size_t retsize;
const char *ced_name, *ced_number, *cid_name, *cid_number;
- if (switch_channel_test_app_flag(consumer_channel, CF_APP_TAGGED)) {
+ if (switch_channel_test_app_flag(consumer_channel, FIFO_APP_BRIDGE_TAG)) {
goto end;
}
- switch_channel_set_app_flag(consumer_channel, CF_APP_TAGGED);
+ switch_channel_set_app_flag(consumer_channel, FIFO_APP_BRIDGE_TAG);
switch_channel_set_variable(consumer_channel, "fifo_bridged", "true");
switch_channel_set_variable(consumer_channel, "fifo_manual_bridge", "true");
break;
case SWITCH_MESSAGE_INDICATE_UNBRIDGE:
{
- if (switch_channel_test_app_flag(consumer_channel, CF_APP_TAGGED)) {
+ if (switch_channel_test_app_flag(consumer_channel, FIFO_APP_BRIDGE_TAG)) {
char date[80] = "";
switch_time_exp_t tm;
switch_time_t ts = switch_micro_time_now();
long epoch_start = 0, epoch_end = 0;
const char *epoch_start_a = NULL;
- switch_channel_clear_app_flag(consumer_channel, CF_APP_TAGGED);
+ switch_channel_clear_app_flag(consumer_channel, FIFO_APP_BRIDGE_TAG);
switch_channel_set_variable(consumer_channel, "fifo_bridged", NULL);
ts = switch_micro_time_now();
return;
}
- if (switch_true(switch_channel_get_variable(channel, "fifo_track_call"))) {
+ if (switch_channel_test_app_flag(channel, FIFO_APP_TRACKING)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s trying to double-track call!\n", switch_channel_get_name(channel));
return;
}
add_bridge_call(data);
+ switch_channel_set_app_flag(channel, FIFO_APP_TRACKING);
+
switch_channel_set_variable(channel, "fifo_outbound_uuid", data);
switch_channel_set_variable(channel, "fifo_track_call", "true");
switch_channel_set_variable(channel, "fifo_timestamp", date);
switch_channel_set_variable(channel, "fifo_serviced_uuid", NULL);
- switch_channel_set_app_flag(channel, CF_APP_TAGGED);
+ switch_channel_set_app_flag(channel, FIFO_APP_BRIDGE_TAG);
if (chime_list) {
char *list_dup = switch_core_session_strdup(session, chime_list);
}
}
- switch_channel_clear_app_flag(channel, CF_APP_TAGGED);
+ switch_channel_clear_app_flag(channel, FIFO_APP_BRIDGE_TAG);
abort:
switch_channel_set_flag(other_channel, CF_BREAK);
- while (switch_channel_ready(channel) && switch_channel_ready(other_channel) && switch_channel_test_app_flag(other_channel, CF_APP_TAGGED)) {
+ while (switch_channel_ready(channel) && switch_channel_ready(other_channel) && switch_channel_test_app_flag(other_channel, FIFO_APP_BRIDGE_TAG)) {
status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
if (!SWITCH_READ_ACCEPTABLE(status)) {
break;
switch_mutex_unlock(globals.mutex);
- switch_channel_clear_app_flag(channel, CF_APP_TAGGED);
+ switch_channel_clear_app_flag(channel, FIFO_APP_BRIDGE_TAG);
switch_core_media_bug_resume(session);
switch (pvt->t38_mode) {
case T38_MODE_REQUESTED:
{
- if (switch_channel_test_app_flag(channel, CF_APP_T38)) {
+ if (switch_channel_test_app_flag_key("T38", channel, CF_APP_T38)) {
switch_core_session_message_t msg = { 0 };
pvt->t38_mode = T38_MODE_NEGOTIATED;
spanfax_init(pvt, T38_MODE);
break;
case T38_MODE_UNKNOWN:
{
- if (switch_channel_test_app_flag(channel, CF_APP_T38)) {
+ if (switch_channel_test_app_flag_key("T38", channel, CF_APP_T38)) {
if (negotiate_t38(pvt) == T38_MODE_NEGOTIATED) {
/* is is safe to call this again, it was already called above in AUDIO_MODE */
/* but this is the only way to set up the t38 stuff */
msg.string_arg = peer_uuid;
switch_core_session_receive_message(session, &msg);
- while (switch_channel_ready(channel) && switch_channel_up(other_channel) && !switch_channel_test_app_flag(channel, CF_APP_T38)) {
+ while (switch_channel_ready(channel) && switch_channel_up(other_channel) && !switch_channel_test_app_flag_key("T38", channel, CF_APP_T38)) {
status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
if (!SWITCH_READ_ACCEPTABLE(status) || pvt->done) {
goto end_unlock;
}
- if (!switch_channel_test_app_flag(channel, CF_APP_T38)) {
+ if (!switch_channel_test_app_flag_key("T38", channel, CF_APP_T38)) {
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s Could not negotiate T38\n", switch_channel_get_name(channel));
goto end_unlock;
/* wake up the audio side */
switch_channel_set_private(channel, "_t38_pvt", pvt);
- switch_channel_set_app_flag(other_channel, CF_APP_T38);
+ switch_channel_set_app_flag_key("T38", other_channel, CF_APP_T38);
while (switch_channel_ready(channel) && switch_channel_up(other_channel)) {
switch_event_fire(&event);
}
- while (switch_channel_ready(channel) && switch_channel_up(other_channel) && !switch_channel_test_app_flag(channel, CF_APP_T38)) {
+ while (switch_channel_ready(channel) && switch_channel_up(other_channel) && !switch_channel_test_app_flag_key("T38", channel, CF_APP_T38)) {
status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
if (!SWITCH_READ_ACCEPTABLE(status)) {
goto end_unlock;
}
- if (!switch_channel_test_app_flag(channel, CF_APP_T38)) {
+ if (!switch_channel_test_app_flag_key("T38", channel, CF_APP_T38)) {
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
goto end_unlock;
}
match = sofia_glue_negotiate_sdp(session, r_sdp);
}
- if (match && switch_channel_test_app_flag(tech_pvt->channel, CF_APP_T38)) {
+ if (match && switch_channel_test_app_flag_key("T38", tech_pvt->channel, CF_APP_T38)) {
goto done;
}
switch_channel_set_variable(tech_pvt->channel, "has_t38", "true");
switch_channel_set_private(tech_pvt->channel, "t38_options", t38_options);
- switch_channel_set_app_flag(tech_pvt->channel, CF_APP_T38);
+ switch_channel_set_app_flag_key("T38", tech_pvt->channel, CF_APP_T38);
return t38_options;
}
uint32_t caps[CC_FLAG_MAX];
uint8_t state_flags[CF_FLAG_MAX];
uint32_t private_flags;
- uint32_t app_flags;
switch_caller_profile_t *caller_profile;
const switch_state_handler_table_t *state_handlers[SWITCH_MAX_STATE_HANDLERS];
int state_handler_index;
switch_event_t *variables;
switch_hash_t *private_hash;
+ switch_hash_t *app_flag_hash;
switch_call_cause_t hangup_cause;
int vi;
int event_count;
return (channel->private_flags & flags);
}
-SWITCH_DECLARE(void) switch_channel_set_app_flag(switch_channel_t *channel, uint32_t flags)
+SWITCH_DECLARE(void) switch_channel_set_app_flag_key(const char *key, switch_channel_t *channel, uint32_t flags)
{
+ uint32_t *flagp = NULL;
+
switch_assert(channel != NULL);
switch_mutex_lock(channel->flag_mutex);
- channel->app_flags |= flags;
+
+ if (channel->app_flag_hash) {
+ flagp = switch_core_hash_find(channel->app_flag_hash, key);
+ } else {
+ switch_core_hash_init(&channel->app_flag_hash, switch_core_session_get_pool(channel->session));
+ flagp = switch_core_session_alloc(channel->session, sizeof(uint32_t));
+ switch_core_hash_insert(channel->app_flag_hash, key, flagp);
+ }
+
+ if (flagp) *flagp |= flags;
switch_mutex_unlock(channel->flag_mutex);
}
-SWITCH_DECLARE(void) switch_channel_clear_app_flag(switch_channel_t *channel, uint32_t flags)
+SWITCH_DECLARE(void) switch_channel_clear_app_flag_key(const char *key, switch_channel_t *channel, uint32_t flags)
{
+ uint32_t *flagp = NULL;
+
switch_assert(channel != NULL);
switch_mutex_lock(channel->flag_mutex);
- if (!flags) {
- channel->app_flags = 0;
- } else {
- channel->app_flags &= ~flags;
+ if (channel->app_flag_hash && (flagp = switch_core_hash_find(channel->app_flag_hash, key))) {
+ if (!flags) {
+ *flagp = 0;
+ } else {
+ *flagp &= ~flags;
+ }
}
switch_mutex_unlock(channel->flag_mutex);
}
-SWITCH_DECLARE(int) switch_channel_test_app_flag(switch_channel_t *channel, uint32_t flags)
+SWITCH_DECLARE(int) switch_channel_test_app_flag_key(const char *key, switch_channel_t *channel, uint32_t flags)
{
+ int r = 0;
+ uint32_t *flagp = NULL;
switch_assert(channel != NULL);
- return (channel->app_flags & flags);
+
+ switch_mutex_lock(channel->flag_mutex);
+ if (channel->app_flag_hash && (flagp = switch_core_hash_find(channel->app_flag_hash, key))) {
+ r = (*flagp & flags);
+ }
+ switch_mutex_unlock(channel->flag_mutex);
+
+
+ return r;
}
SWITCH_DECLARE(void) switch_channel_set_state_flag(switch_channel_t *channel, switch_channel_flag_t flag)