mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-04 11:58:52 +00:00
Filter channels used as internal mechanisms
This adds new flags to the channel tech properties that flag it as different types of implementation detail used exclusively to provide a feature. Examples of channels that would have these flags include the announcement and recording channels used by confbridge which are the only two marked as such by this patch. Review: https://reviewboard.asterisk.org/r/2633/ (closes issue ASTERISK-21873) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@394808 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -134,6 +134,7 @@ static struct ast_channel_tech announce_tech = {
|
||||
.send_text = ast_unreal_sendtext,
|
||||
.queryoption = ast_unreal_queryoption,
|
||||
.setoption = ast_unreal_setoption,
|
||||
.properties = AST_CHAN_TP_ANNOUNCER,
|
||||
};
|
||||
|
||||
struct ast_channel_tech *conf_announce_get_tech(void)
|
||||
|
@@ -86,6 +86,7 @@ static struct ast_channel_tech record_tech = {
|
||||
.call = rec_call,
|
||||
.read = rec_read,
|
||||
.write = rec_write,
|
||||
.properties = AST_CHAN_TP_RECORDER,
|
||||
};
|
||||
|
||||
struct ast_channel_tech *conf_record_get_tech(void)
|
||||
|
@@ -195,14 +195,17 @@ static void confbridge_publish_manager_event(
|
||||
{
|
||||
struct ast_bridge_blob *blob = stasis_message_data(message);
|
||||
const char *conference_name;
|
||||
RAII_VAR(struct ast_str *, bridge_text,
|
||||
ast_manager_build_bridge_state_string(blob->bridge, ""),
|
||||
ast_free);
|
||||
RAII_VAR(struct ast_str *, bridge_text, NULL, ast_free);
|
||||
RAII_VAR(struct ast_str *, channel_text, NULL, ast_free);
|
||||
|
||||
ast_assert(blob != NULL);
|
||||
ast_assert(event != NULL);
|
||||
|
||||
bridge_text = ast_manager_build_bridge_state_string(blob->bridge, "");
|
||||
if (!bridge_text) {
|
||||
return;
|
||||
}
|
||||
|
||||
conference_name = ast_json_string_get(ast_json_object_get(blob->blob, "conference"));
|
||||
ast_assert(conference_name != NULL);
|
||||
|
||||
|
@@ -854,15 +854,25 @@ struct ast_channel;
|
||||
/*! \brief ast_channel_tech Properties */
|
||||
enum {
|
||||
/*!
|
||||
* \brief Channels have this property if they can accept input with jitter;
|
||||
* \brief Channels have this property if they can accept input with jitter;
|
||||
* i.e. most VoIP channels
|
||||
*/
|
||||
AST_CHAN_TP_WANTSJITTER = (1 << 0),
|
||||
/*!
|
||||
* \brief Channels have this property if they can create jitter;
|
||||
* \brief Channels have this property if they can create jitter;
|
||||
* i.e. most VoIP channels
|
||||
*/
|
||||
AST_CHAN_TP_CREATESJITTER = (1 << 1),
|
||||
/*!
|
||||
* \brief Channels have this property if they are an implementation detail
|
||||
* used for announcing messages; i.e. to a bridge
|
||||
*/
|
||||
AST_CHAN_TP_ANNOUNCER = (1 << 2),
|
||||
/*!
|
||||
* \brief Channels have this property if they are an implementation detail
|
||||
* used for recording audio; i.e. from a bridge
|
||||
*/
|
||||
AST_CHAN_TP_RECORDER = (1 << 3),
|
||||
};
|
||||
|
||||
/*! \brief ast_channel flags */
|
||||
|
@@ -84,6 +84,7 @@ struct ast_channel_snapshot {
|
||||
struct ast_flags softhangup_flags; /*!< softhangup channel flags */
|
||||
struct varshead *manager_vars; /*!< Variables to be appended to manager events */
|
||||
struct varshead *channel_vars; /*!< Variables set on the channel */
|
||||
int tech_properties; /*!< Properties of the channel's technology */
|
||||
};
|
||||
|
||||
/*!
|
||||
|
@@ -1902,11 +1902,7 @@ static int cdr_object_update_party_b(void *obj, void *arg, int flags)
|
||||
/*! \internal \brief Filter channel snapshots by technology */
|
||||
static int filter_channel_snapshot(struct ast_channel_snapshot *snapshot)
|
||||
{
|
||||
if (!strncmp(snapshot->name, "CBAnn", 5) ||
|
||||
!strncmp(snapshot->name, "CBRec", 5)) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return snapshot->tech_properties & (AST_CHAN_TP_ANNOUNCER | AST_CHAN_TP_RECORDER);
|
||||
}
|
||||
|
||||
/*! \internal \brief Filter a channel cache update */
|
||||
|
24
main/cel.c
24
main/cel.c
@@ -1196,6 +1196,14 @@ static void clear_bridge_primary(const char *bridge_id)
|
||||
ao2_callback(bridge_primaries, OBJ_KEY | OBJ_NODATA | OBJ_UNLINK | OBJ_MULTIPLE, bridge_match_cb, dup_id);
|
||||
}
|
||||
|
||||
static int cel_filter_channel_snapshot(struct ast_channel_snapshot *snapshot)
|
||||
{
|
||||
if (!snapshot) {
|
||||
return 0;
|
||||
}
|
||||
return snapshot->tech_properties & (AST_CHAN_TP_ANNOUNCER | AST_CHAN_TP_RECORDER);
|
||||
}
|
||||
|
||||
static void cel_snapshot_update_cb(void *data, struct stasis_subscription *sub,
|
||||
struct stasis_topic *topic,
|
||||
struct stasis_message *message)
|
||||
@@ -1209,6 +1217,10 @@ static void cel_snapshot_update_cb(void *data, struct stasis_subscription *sub,
|
||||
old_snapshot = stasis_message_data(update->old_snapshot);
|
||||
new_snapshot = stasis_message_data(update->new_snapshot);
|
||||
|
||||
if (cel_filter_channel_snapshot(old_snapshot) || cel_filter_channel_snapshot(new_snapshot)) {
|
||||
return;
|
||||
}
|
||||
|
||||
update_bridge_primary(new_snapshot);
|
||||
|
||||
for (i = 0; i < ARRAY_LEN(cel_channel_monitors); ++i) {
|
||||
@@ -1242,6 +1254,10 @@ static void cel_bridge_enter_cb(
|
||||
struct ast_channel_snapshot *chan_snapshot = blob->channel;
|
||||
RAII_VAR(struct bridge_assoc *, assoc, find_bridge_primary_by_bridge_id(snapshot->uniqueid), ao2_cleanup);
|
||||
|
||||
if (cel_filter_channel_snapshot(chan_snapshot)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (snapshot->capabilities & (AST_BRIDGE_CAPABILITY_1TO1MIX | AST_BRIDGE_CAPABILITY_NATIVE)) {
|
||||
if (assoc && assoc->track_as_conf) {
|
||||
report_event_snapshot(chan_snapshot, AST_CEL_CONF_ENTER, NULL, NULL, NULL);
|
||||
@@ -1303,6 +1319,10 @@ static void cel_bridge_leave_cb(
|
||||
struct ast_bridge_snapshot *snapshot = blob->bridge;
|
||||
struct ast_channel_snapshot *chan_snapshot = blob->channel;
|
||||
|
||||
if (cel_filter_channel_snapshot(chan_snapshot)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (snapshot->capabilities & (AST_BRIDGE_CAPABILITY_1TO1MIX | AST_BRIDGE_CAPABILITY_NATIVE)) {
|
||||
RAII_VAR(struct bridge_assoc *, assoc,
|
||||
find_bridge_primary_by_bridge_id(snapshot->uniqueid),
|
||||
@@ -1366,6 +1386,10 @@ static void cel_dial_cb(void *data, struct stasis_subscription *sub,
|
||||
{
|
||||
struct ast_multi_channel_blob *blob = stasis_message_data(message);
|
||||
|
||||
if (cel_filter_channel_snapshot(ast_multi_channel_blob_get_channel(blob, "caller"))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!get_caller_uniqueid(blob)) {
|
||||
return;
|
||||
}
|
||||
|
@@ -140,6 +140,7 @@ struct ast_str *ast_manager_build_bridge_state_string(
|
||||
suffix, snapshot->num_channels);
|
||||
|
||||
if (!res) {
|
||||
ast_free(out);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -239,6 +240,9 @@ static void bridge_merge_cb(void *data, struct stasis_subscription *sub,
|
||||
|
||||
to_text = ast_manager_build_bridge_state_string(merge_msg->to, "");
|
||||
from_text = ast_manager_build_bridge_state_string(merge_msg->from, "From");
|
||||
if (!to_text || !from_text) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*** DOCUMENTATION
|
||||
<managerEventInstance>
|
||||
@@ -271,6 +275,9 @@ static void channel_enter_cb(void *data, struct stasis_subscription *sub,
|
||||
|
||||
bridge_text = ast_manager_build_bridge_state_string(blob->bridge, "");
|
||||
channel_text = ast_manager_build_channel_state_string(blob->channel);
|
||||
if (!bridge_text || !channel_text) {
|
||||
return;
|
||||
}
|
||||
|
||||
manager_event(EVENT_FLAG_CALL, "BridgeEnter",
|
||||
"%s"
|
||||
@@ -289,6 +296,9 @@ static void channel_leave_cb(void *data, struct stasis_subscription *sub,
|
||||
|
||||
bridge_text = ast_manager_build_bridge_state_string(blob->bridge, "");
|
||||
channel_text = ast_manager_build_channel_state_string(blob->channel);
|
||||
if (!bridge_text || !channel_text) {
|
||||
return;
|
||||
}
|
||||
|
||||
manager_event(EVENT_FLAG_CALL, "BridgeLeave",
|
||||
"%s"
|
||||
@@ -312,6 +322,10 @@ static int send_bridge_list_item_cb(void *obj, void *arg, void *data, int flags)
|
||||
char *id_text = data;
|
||||
RAII_VAR(struct ast_str *, bridge_info, ast_manager_build_bridge_state_string(snapshot, ""), ast_free);
|
||||
|
||||
if (!bridge_info) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
astman_append(s,
|
||||
"Event: BridgeListItem\r\n"
|
||||
"%s"
|
||||
@@ -367,6 +381,19 @@ static int send_bridge_info_item_cb(void *obj, void *arg, void *data, int flags)
|
||||
char *uniqueid = obj;
|
||||
struct mansession *s = arg;
|
||||
char *id_text = data;
|
||||
RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
|
||||
struct ast_channel_snapshot *snapshot;
|
||||
msg = stasis_cache_get(ast_channel_topic_all_cached(),
|
||||
ast_channel_snapshot_type(), uniqueid);
|
||||
|
||||
if (!msg) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
snapshot = stasis_message_data(msg);
|
||||
if (snapshot->tech_properties & (AST_CHAN_TP_ANNOUNCER | AST_CHAN_TP_RECORDER)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
astman_append(s,
|
||||
"Event: BridgeInfoChannel\r\n"
|
||||
@@ -419,7 +446,7 @@ static int manager_bridge_info(struct mansession *s, const struct message *m)
|
||||
"%s"
|
||||
"%s"
|
||||
"\r\n",
|
||||
ast_str_buffer(bridge_info),
|
||||
S_COR(bridge_info, ast_str_buffer(bridge_info), ""),
|
||||
ast_str_buffer(id_text));
|
||||
|
||||
return 0;
|
||||
|
@@ -533,6 +533,11 @@ struct ast_str *ast_manager_build_channel_state_string_prefix(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (snapshot->tech_properties & (AST_CHAN_TP_ANNOUNCER | AST_CHAN_TP_RECORDER)) {
|
||||
ast_free(out);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
res = ast_str_set(&out, 0,
|
||||
"%sChannel: %s\r\n"
|
||||
"%sChannelState: %d\r\n"
|
||||
@@ -560,6 +565,7 @@ struct ast_str *ast_manager_build_channel_state_string_prefix(
|
||||
prefix, snapshot->uniqueid);
|
||||
|
||||
if (!res) {
|
||||
ast_free(out);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1209,6 +1215,9 @@ static void channel_hold_cb(void *data, struct stasis_subscription *sub,
|
||||
}
|
||||
|
||||
channel_event_string = ast_manager_build_channel_state_string(obj->snapshot);
|
||||
if (!channel_event_string) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj->blob) {
|
||||
musicclass = ast_json_string_get(ast_json_object_get(obj->blob, "musicclass"));
|
||||
@@ -1232,6 +1241,9 @@ static void channel_unhold_cb(void *data, struct stasis_subscription *sub,
|
||||
RAII_VAR(struct ast_str *, channel_event_string, NULL, ast_free);
|
||||
|
||||
channel_event_string = ast_manager_build_channel_state_string(obj->snapshot);
|
||||
if (!channel_event_string) {
|
||||
return;
|
||||
}
|
||||
|
||||
manager_event(EVENT_FLAG_CALL, "Unhold",
|
||||
"%s",
|
||||
|
@@ -256,6 +256,7 @@ struct ast_channel_snapshot *ast_channel_snapshot_create(struct ast_channel *cha
|
||||
|
||||
snapshot->manager_vars = ast_channel_get_manager_vars(chan);
|
||||
snapshot->channel_vars = ast_channel_get_vars(chan);
|
||||
snapshot->tech_properties = ast_channel_tech(chan)->properties;
|
||||
|
||||
ao2_ref(snapshot, +1);
|
||||
return snapshot;
|
||||
|
@@ -266,6 +266,9 @@ static struct ast_str *manager_build_parked_call_string(const struct ast_parked_
|
||||
}
|
||||
|
||||
parkee_string = ast_manager_build_channel_state_string_prefix(payload->parkee, "Parkee");
|
||||
if (!parkee_string) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (payload->retriever) {
|
||||
retriever_string = ast_manager_build_channel_state_string_prefix(payload->retriever, "Retriever");
|
||||
|
Reference in New Issue
Block a user