diff --git a/src/include/switch_channel.h b/src/include/switch_channel.h index 13d5793e5a..c91d3ccece 100644 --- a/src/include/switch_channel.h +++ b/src/include/switch_channel.h @@ -490,6 +490,10 @@ SWITCH_DECLARE(switch_status_t) switch_channel_set_timestamps(_In_ switch_channe SWITCH_DECLARE(void) switch_channel_audio_sync(switch_channel_t *channel); +SWITCH_DECLARE(void) switch_channel_set_private_flag(switch_channel_t *channel, uint32_t flags); +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_END_EXTERN_C diff --git a/src/switch_channel.c b/src/switch_channel.c index cc199b05a7..4370c7cc23 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -116,6 +116,7 @@ struct switch_channel { switch_channel_state_t state; switch_channel_state_t running_state; switch_channel_flag_t flags; + uint32_t private_flags; switch_channel_flag_t state_flags; switch_caller_profile_t *caller_profile; const switch_state_handler_table_t *state_handlers[SWITCH_MAX_STATE_HANDLERS]; @@ -749,6 +750,30 @@ SWITCH_DECLARE(void) switch_channel_set_flag(switch_channel_t *channel, switch_c } } + +SWITCH_DECLARE(void) switch_channel_set_private_flag(switch_channel_t *channel, uint32_t flags) +{ + switch_assert(channel != NULL); + switch_mutex_lock(channel->flag_mutex); + channel->private_flags |= flags; + switch_mutex_unlock(channel->flag_mutex); +} + +SWITCH_DECLARE(void) switch_channel_clear_private_flag(switch_channel_t *channel, uint32_t flags) +{ + switch_assert(channel != NULL); + switch_mutex_lock(channel->flag_mutex); + channel->private_flags &= ~flags; + switch_mutex_unlock(channel->flag_mutex); +} + +SWITCH_DECLARE(int) switch_channel_test_private_flag(switch_channel_t *channel, uint32_t flags) +{ + switch_assert(channel != NULL); + return (channel->private_flags & flags); +} + + SWITCH_DECLARE(void) switch_channel_set_state_flag(switch_channel_t *channel, switch_channel_flag_t flags) { switch_assert(channel != NULL);