stasis: Allow filtering by formatter

A subscriber can now indicate that it only wants messages
that have formatters of a specific type.  For instance,
manager can indicate that it only wants messages that have a
"to_ami" formatter.  You can combine this with the existing
filter for message type to get only messages with specific
formatters or messages of specific types.

ASTERISK-28186

Change-Id: Ifdb7a222a73b6b56c6bb9e4ee93dc8a394a5494c
This commit is contained in:
George Joseph
2018-11-29 08:53:51 -07:00
parent b899119a5d
commit 3f3dd992a2
6 changed files with 548 additions and 10 deletions

View File

@@ -40,6 +40,7 @@ struct stasis_message_type {
char *name;
unsigned int hash;
int id;
enum stasis_subscription_message_formatters available_formatters;
};
static struct stasis_message_vtable null_vtable = {};
@@ -80,6 +81,15 @@ int stasis_message_type_create(const char *name,
}
type->hash = ast_hashtab_hash_string(name);
type->vtable = vtable;
if (vtable->to_json) {
type->available_formatters |= STASIS_SUBSCRIPTION_FORMATTER_JSON;
}
if (vtable->to_ami) {
type->available_formatters |= STASIS_SUBSCRIPTION_FORMATTER_AMI;
}
if (vtable->to_event) {
type->available_formatters |= STASIS_SUBSCRIPTION_FORMATTER_EVENT;
}
type->id = ast_atomic_fetchadd_int(&message_type_id, +1);
*result = type;
@@ -101,6 +111,12 @@ int stasis_message_type_id(const struct stasis_message_type *type)
return type->id;
}
enum stasis_subscription_message_formatters stasis_message_type_available_formatters(
const struct stasis_message_type *type)
{
return type->available_formatters;
}
/*! \internal */
struct stasis_message {
/*! Time the message was created */