[asterisk-commits] kmoore: trunk r390250 - in /trunk: apps/ apps/confbridge/ apps/confbridge/inc...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri May 31 07:41:17 CDT 2013
Author: kmoore
Date: Fri May 31 07:41:10 2013
New Revision: 390250
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=390250
Log:
Remove remnant of snapshot blob JSON types
Remove usage of the once-mandatory snapshot blob type field, refactor
confbridge stasis messages accordingly, and remove
ast_bridge_blob_json_type().
Review: https://reviewboard.asterisk.org/r/2575/
Modified:
trunk/apps/app_confbridge.c
trunk/apps/confbridge/confbridge_manager.c
trunk/apps/confbridge/include/confbridge.h
trunk/include/asterisk/stasis_bridging.h
trunk/main/stasis_bridging.c
Modified: trunk/apps/app_confbridge.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_confbridge.c?view=diff&rev=390250&r1=390249&r2=390250
==============================================================================
--- trunk/apps/app_confbridge.c (original)
+++ trunk/apps/app_confbridge.c Fri May 31 07:41:10 2013
@@ -415,13 +415,12 @@
return "";
}
-static void send_conf_stasis(struct confbridge_conference *conference, struct ast_channel *chan, const char *type, struct ast_json *extras, int channel_topic)
+static void send_conf_stasis(struct confbridge_conference *conference, struct ast_channel *chan, struct stasis_message_type *type, struct ast_json *extras, int channel_topic)
{
RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
RAII_VAR(struct ast_json *, json_object, NULL, ast_json_unref);
- json_object = ast_json_pack("{s: s, s: s}",
- "type", type,
+ json_object = ast_json_pack("{s: s}",
"conference", conference->name);
if (!json_object) {
@@ -432,10 +431,10 @@
ast_json_object_update(json_object, extras);
}
- msg = ast_bridge_blob_create(confbridge_message_type(),
- conference->bridge,
- chan,
- json_object);
+ msg = ast_bridge_blob_create(type,
+ conference->bridge,
+ chan,
+ json_object);
if (!msg) {
return;
}
@@ -450,42 +449,42 @@
static void send_conf_start_event(struct confbridge_conference *conference)
{
- send_conf_stasis(conference, NULL, "confbridge_start", NULL, 0);
+ send_conf_stasis(conference, NULL, confbridge_start_type(), NULL, 0);
}
static void send_conf_end_event(struct confbridge_conference *conference)
{
- send_conf_stasis(conference, NULL, "confbridge_end", NULL, 0);
+ send_conf_stasis(conference, NULL, confbridge_end_type(), NULL, 0);
}
static void send_join_event(struct ast_channel *chan, struct confbridge_conference *conference)
{
- send_conf_stasis(conference, chan, "confbridge_join", NULL, 0);
+ send_conf_stasis(conference, chan, confbridge_join_type(), NULL, 0);
}
static void send_leave_event(struct ast_channel *chan, struct confbridge_conference *conference)
{
- send_conf_stasis(conference, chan, "confbridge_leave", NULL, 0);
+ send_conf_stasis(conference, chan, confbridge_leave_type(), NULL, 0);
}
static void send_start_record_event(struct confbridge_conference *conference)
{
- send_conf_stasis(conference, NULL, "confbridge_record", NULL, 0);
+ send_conf_stasis(conference, NULL, confbridge_start_record_type(), NULL, 0);
}
static void send_stop_record_event(struct confbridge_conference *conference)
{
- send_conf_stasis(conference, NULL, "confbridge_stop_record", NULL, 0);
+ send_conf_stasis(conference, NULL, confbridge_stop_record_type(), NULL, 0);
}
static void send_mute_event(struct ast_channel *chan, struct confbridge_conference *conference)
{
- send_conf_stasis(conference, chan, "confbridge_mute", NULL, 1);
+ send_conf_stasis(conference, chan, confbridge_mute_type(), NULL, 1);
}
static void send_unmute_event(struct ast_channel *chan, struct confbridge_conference *conference)
{
- send_conf_stasis(conference, chan, "confbridge_unmute", NULL, 1);
+ send_conf_stasis(conference, chan, confbridge_unmute_type(), NULL, 1);
}
static void set_rec_filename(struct confbridge_conference *conference, struct ast_str **filename, int is_new)
@@ -1420,7 +1419,7 @@
return;
}
- send_conf_stasis(conference, bridge_channel->chan, "confbridge_talking", talking_extras, 0);
+ send_conf_stasis(conference, bridge_channel->chan, confbridge_talking_type(), talking_extras, 0);
ast_json_unref(talking_extras);
}
Modified: trunk/apps/confbridge/confbridge_manager.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/confbridge/confbridge_manager.c?view=diff&rev=390250&r1=390249&r2=390250
==============================================================================
--- trunk/apps/confbridge/confbridge_manager.c (original)
+++ trunk/apps/confbridge/confbridge_manager.c Fri May 31 07:41:10 2013
@@ -206,61 +206,24 @@
header, value);
}
-static void stasis_confbridge_cb(void *data, struct stasis_subscription *sub,
- struct stasis_topic *topic,
- struct stasis_message *message)
+static void confbridge_publish_manager_event(
+ struct stasis_message *message,
+ const char *event,
+ struct ast_str *extra_text)
{
struct ast_bridge_blob *blob = stasis_message_data(message);
- const char *type = ast_bridge_blob_json_type(blob);
const char *conference_name;
- RAII_VAR(struct ast_str *, bridge_text, NULL, ast_free);
+ RAII_VAR(struct ast_str *, bridge_text,
+ ast_manager_build_bridge_state_string(blob->bridge, ""),
+ ast_free);
RAII_VAR(struct ast_str *, channel_text, NULL, ast_free);
- RAII_VAR(struct ast_str *, extra_text, NULL, ast_free);
- char *event;
-
- if (!blob || !type) {
- ast_assert(0);
- return;
- }
-
- if (!strcmp("confbridge_start", type)) {
- event = "ConfbridgeStart";
- } else if (!strcmp("confbridge_end", type)) {
- event = "ConfbridgeEnd";
- } else if (!strcmp("confbridge_leave", type)) {
- event = "ConfbridgeLeave";
- } else if (!strcmp("confbridge_join", type)) {
- event = "ConfbridgeJoin";
- } else if (!strcmp("confbridge_record", type)) {
- event = "ConfbridgeRecord";
- } else if (!strcmp("confbridge_stop_record", type)) {
- event = "ConfbridgeStopRecord";
- } else if (!strcmp("confbridge_mute", type)) {
- event = "ConfbridgeMute";
- } else if (!strcmp("confbridge_unmute", type)) {
- event = "ConfbridgeUnmute";
- } else if (!strcmp("confbridge_talking", type)) {
- const char *talking_status = ast_json_string_get(ast_json_object_get(blob->blob, "talking_status"));
- event = "ConfbridgeTalking";
-
- if (!talking_status) {
- return;
- }
-
- append_event_header(&extra_text, "TalkingStatus", talking_status);
-
- } else {
- return;
- }
+
+ ast_assert(blob != NULL);
+ ast_assert(event != NULL);
conference_name = ast_json_string_get(ast_json_object_get(blob->blob, "conference"));
-
- if (!conference_name) {
- ast_assert(0);
- return;
- }
-
- bridge_text = ast_manager_build_bridge_state_string(blob->bridge, "");
+ ast_assert(conference_name != NULL);
+
if (blob->channel) {
channel_text = ast_manager_build_channel_state_string(blob->channel);
}
@@ -272,20 +235,105 @@
"%s",
conference_name,
ast_str_buffer(bridge_text),
- channel_text ? ast_str_buffer(channel_text) : "",
- extra_text ? ast_str_buffer(extra_text) : "");
-}
-
-static struct stasis_message_type *confbridge_msg_type;
-
-struct stasis_message_type *confbridge_message_type(void)
-{
- return confbridge_msg_type;
-}
+ S_COR(channel_text, ast_str_buffer(channel_text), ""),
+ S_COR(extra_text, ast_str_buffer(extra_text), ""));
+}
+
+static void confbridge_start_cb(void *data, struct stasis_subscription *sub,
+ struct stasis_topic *topic,
+ struct stasis_message *message)
+{
+ confbridge_publish_manager_event(message, "ConfbridgeStart", NULL);
+}
+
+static void confbridge_end_cb(void *data, struct stasis_subscription *sub,
+ struct stasis_topic *topic,
+ struct stasis_message *message)
+{
+ confbridge_publish_manager_event(message, "ConfbridgeEnd", NULL);
+}
+
+static void confbridge_leave_cb(void *data, struct stasis_subscription *sub,
+ struct stasis_topic *topic,
+ struct stasis_message *message)
+{
+ confbridge_publish_manager_event(message, "ConfbridgeLeave", NULL);
+}
+
+static void confbridge_join_cb(void *data, struct stasis_subscription *sub,
+ struct stasis_topic *topic,
+ struct stasis_message *message)
+{
+ confbridge_publish_manager_event(message, "ConfbridgeJoin", NULL);
+}
+
+static void confbridge_start_record_cb(void *data, struct stasis_subscription *sub,
+ struct stasis_topic *topic,
+ struct stasis_message *message)
+{
+ confbridge_publish_manager_event(message, "ConfbridgeRecord", NULL);
+}
+
+static void confbridge_stop_record_cb(void *data, struct stasis_subscription *sub,
+ struct stasis_topic *topic,
+ struct stasis_message *message)
+{
+ confbridge_publish_manager_event(message, "ConfbridgeStopRecord", NULL);
+}
+
+static void confbridge_mute_cb(void *data, struct stasis_subscription *sub,
+ struct stasis_topic *topic,
+ struct stasis_message *message)
+{
+ confbridge_publish_manager_event(message, "ConfbridgeMute", NULL);
+}
+
+static void confbridge_unmute_cb(void *data, struct stasis_subscription *sub,
+ struct stasis_topic *topic,
+ struct stasis_message *message)
+{
+ confbridge_publish_manager_event(message, "ConfbridgeUnmute", NULL);
+}
+
+static void confbridge_talking_cb(void *data, struct stasis_subscription *sub,
+ struct stasis_topic *topic,
+ struct stasis_message *message)
+{
+ RAII_VAR(struct ast_str *, extra_text, NULL, ast_free);
+ struct ast_bridge_blob *blob = stasis_message_data(message);
+ const char *talking_status = ast_json_string_get(ast_json_object_get(blob->blob, "talking_status"));
+ if (!talking_status) {
+ return;
+ }
+
+ append_event_header(&extra_text, "TalkingStatus", talking_status);
+ if (!extra_text) {
+ return;
+ }
+
+ confbridge_publish_manager_event(message, "ConfbridgeTalking", extra_text);
+}
+
+STASIS_MESSAGE_TYPE_DEFN(confbridge_start_type);
+STASIS_MESSAGE_TYPE_DEFN(confbridge_end_type);
+STASIS_MESSAGE_TYPE_DEFN(confbridge_join_type);
+STASIS_MESSAGE_TYPE_DEFN(confbridge_leave_type);
+STASIS_MESSAGE_TYPE_DEFN(confbridge_start_record_type);
+STASIS_MESSAGE_TYPE_DEFN(confbridge_stop_record_type);
+STASIS_MESSAGE_TYPE_DEFN(confbridge_mute_type);
+STASIS_MESSAGE_TYPE_DEFN(confbridge_unmute_type);
+STASIS_MESSAGE_TYPE_DEFN(confbridge_talking_type);
void manager_confbridge_shutdown(void) {
- ao2_cleanup(confbridge_msg_type);
- confbridge_msg_type = NULL;
+ STASIS_MESSAGE_TYPE_CLEANUP(confbridge_start_type);
+ STASIS_MESSAGE_TYPE_CLEANUP(confbridge_end_type);
+ STASIS_MESSAGE_TYPE_CLEANUP(confbridge_join_type);
+ STASIS_MESSAGE_TYPE_CLEANUP(confbridge_leave_type);
+ STASIS_MESSAGE_TYPE_CLEANUP(confbridge_start_record_type);
+ STASIS_MESSAGE_TYPE_CLEANUP(confbridge_stop_record_type);
+ STASIS_MESSAGE_TYPE_CLEANUP(confbridge_mute_type);
+ STASIS_MESSAGE_TYPE_CLEANUP(confbridge_unmute_type);
+ STASIS_MESSAGE_TYPE_CLEANUP(confbridge_talking_type);
if (bridge_state_router) {
stasis_message_router_unsubscribe(bridge_state_router);
@@ -300,9 +348,15 @@
int manager_confbridge_init(void)
{
- if (!(confbridge_msg_type = stasis_message_type_create("confbridge"))) {
- return -1;
- }
+ STASIS_MESSAGE_TYPE_INIT(confbridge_start_type);
+ STASIS_MESSAGE_TYPE_INIT(confbridge_end_type);
+ STASIS_MESSAGE_TYPE_INIT(confbridge_join_type);
+ STASIS_MESSAGE_TYPE_INIT(confbridge_leave_type);
+ STASIS_MESSAGE_TYPE_INIT(confbridge_start_record_type);
+ STASIS_MESSAGE_TYPE_INIT(confbridge_stop_record_type);
+ STASIS_MESSAGE_TYPE_INIT(confbridge_mute_type);
+ STASIS_MESSAGE_TYPE_INIT(confbridge_unmute_type);
+ STASIS_MESSAGE_TYPE_INIT(confbridge_talking_type);
bridge_state_router = stasis_message_router_create(
stasis_caching_get_topic(ast_bridge_topic_all_cached()));
@@ -312,9 +366,65 @@
}
if (stasis_message_router_add(bridge_state_router,
- confbridge_message_type(),
- stasis_confbridge_cb,
- NULL)) {
+ confbridge_start_type(),
+ confbridge_start_cb,
+ NULL)) {
+ manager_confbridge_shutdown();
+ return -1;
+ }
+ if (stasis_message_router_add(bridge_state_router,
+ confbridge_end_type(),
+ confbridge_end_cb,
+ NULL)) {
+ manager_confbridge_shutdown();
+ return -1;
+ }
+ if (stasis_message_router_add(bridge_state_router,
+ confbridge_join_type(),
+ confbridge_join_cb,
+ NULL)) {
+ manager_confbridge_shutdown();
+ return -1;
+ }
+ if (stasis_message_router_add(bridge_state_router,
+ confbridge_leave_type(),
+ confbridge_leave_cb,
+ NULL)) {
+ manager_confbridge_shutdown();
+ return -1;
+ }
+ if (stasis_message_router_add(bridge_state_router,
+ confbridge_start_record_type(),
+ confbridge_start_record_cb,
+ NULL)) {
+ manager_confbridge_shutdown();
+ return -1;
+ }
+ if (stasis_message_router_add(bridge_state_router,
+ confbridge_stop_record_type(),
+ confbridge_stop_record_cb,
+ NULL)) {
+ manager_confbridge_shutdown();
+ return -1;
+ }
+ if (stasis_message_router_add(bridge_state_router,
+ confbridge_mute_type(),
+ confbridge_mute_cb,
+ NULL)) {
+ manager_confbridge_shutdown();
+ return -1;
+ }
+ if (stasis_message_router_add(bridge_state_router,
+ confbridge_unmute_type(),
+ confbridge_unmute_cb,
+ NULL)) {
+ manager_confbridge_shutdown();
+ return -1;
+ }
+ if (stasis_message_router_add(bridge_state_router,
+ confbridge_talking_type(),
+ confbridge_talking_cb,
+ NULL)) {
manager_confbridge_shutdown();
return -1;
}
@@ -328,9 +438,65 @@
}
if (stasis_message_router_add(channel_state_router,
- confbridge_message_type(),
- stasis_confbridge_cb,
- NULL)) {
+ confbridge_start_type(),
+ confbridge_start_cb,
+ NULL)) {
+ manager_confbridge_shutdown();
+ return -1;
+ }
+ if (stasis_message_router_add(channel_state_router,
+ confbridge_end_type(),
+ confbridge_end_cb,
+ NULL)) {
+ manager_confbridge_shutdown();
+ return -1;
+ }
+ if (stasis_message_router_add(channel_state_router,
+ confbridge_join_type(),
+ confbridge_join_cb,
+ NULL)) {
+ manager_confbridge_shutdown();
+ return -1;
+ }
+ if (stasis_message_router_add(channel_state_router,
+ confbridge_leave_type(),
+ confbridge_leave_cb,
+ NULL)) {
+ manager_confbridge_shutdown();
+ return -1;
+ }
+ if (stasis_message_router_add(channel_state_router,
+ confbridge_start_record_type(),
+ confbridge_start_record_cb,
+ NULL)) {
+ manager_confbridge_shutdown();
+ return -1;
+ }
+ if (stasis_message_router_add(channel_state_router,
+ confbridge_stop_record_type(),
+ confbridge_stop_record_cb,
+ NULL)) {
+ manager_confbridge_shutdown();
+ return -1;
+ }
+ if (stasis_message_router_add(channel_state_router,
+ confbridge_mute_type(),
+ confbridge_mute_cb,
+ NULL)) {
+ manager_confbridge_shutdown();
+ return -1;
+ }
+ if (stasis_message_router_add(channel_state_router,
+ confbridge_unmute_type(),
+ confbridge_unmute_cb,
+ NULL)) {
+ manager_confbridge_shutdown();
+ return -1;
+ }
+ if (stasis_message_router_add(channel_state_router,
+ confbridge_talking_type(),
+ confbridge_talking_cb,
+ NULL)) {
manager_confbridge_shutdown();
return -1;
}
Modified: trunk/apps/confbridge/include/confbridge.h
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/confbridge/include/confbridge.h?view=diff&rev=390250&r1=390249&r2=390250
==============================================================================
--- trunk/apps/confbridge/include/confbridge.h (original)
+++ trunk/apps/confbridge/include/confbridge.h Fri May 31 07:41:10 2013
@@ -465,12 +465,84 @@
/*!
* \since 12.0
- * \brief get the confbridge stasis message type
- *
- * \retval stasis message type for confbridge messages if it's available
- * \retval NULL if it isn't
- */
-struct stasis_message_type *confbridge_message_type(void);
+ * \brief get the confbridge start stasis message type
+ *
+ * \retval stasis message type for confbridge start messages if it's available
+ * \retval NULL if it isn't
+ */
+struct stasis_message_type *confbridge_start_type(void);
+
+/*!
+ * \since 12.0
+ * \brief get the confbridge end stasis message type
+ *
+ * \retval stasis message type for confbridge end messages if it's available
+ * \retval NULL if it isn't
+ */
+struct stasis_message_type *confbridge_end_type(void);
+
+/*!
+ * \since 12.0
+ * \brief get the confbridge join stasis message type
+ *
+ * \retval stasis message type for confbridge join messages if it's available
+ * \retval NULL if it isn't
+ */
+struct stasis_message_type *confbridge_join_type(void);
+
+/*!
+ * \since 12.0
+ * \brief get the confbridge leave stasis message type
+ *
+ * \retval stasis message type for confbridge leave messages if it's available
+ * \retval NULL if it isn't
+ */
+struct stasis_message_type *confbridge_leave_type(void);
+
+/*!
+ * \since 12.0
+ * \brief get the confbridge start_record stasis message type
+ *
+ * \retval stasis message type for confbridge start_record messages if it's available
+ * \retval NULL if it isn't
+ */
+struct stasis_message_type *confbridge_start_record_type(void);
+
+/*!
+ * \since 12.0
+ * \brief get the confbridge stop_record stasis message type
+ *
+ * \retval stasis message type for confbridge stop_record messages if it's available
+ * \retval NULL if it isn't
+ */
+struct stasis_message_type *confbridge_stop_record_type(void);
+
+/*!
+ * \since 12.0
+ * \brief get the confbridge mute stasis message type
+ *
+ * \retval stasis message type for confbridge mute messages if it's available
+ * \retval NULL if it isn't
+ */
+struct stasis_message_type *confbridge_mute_type(void);
+
+/*!
+ * \since 12.0
+ * \brief get the confbridge unmute stasis message type
+ *
+ * \retval stasis message type for confbridge unmute messages if it's available
+ * \retval NULL if it isn't
+ */
+struct stasis_message_type *confbridge_unmute_type(void);
+
+/*!
+ * \since 12.0
+ * \brief get the confbridge talking stasis message type
+ *
+ * \retval stasis message type for confbridge talking messages if it's available
+ * \retval NULL if it isn't
+ */
+struct stasis_message_type *confbridge_talking_type(void);
/*!
* \since 12.0
Modified: trunk/include/asterisk/stasis_bridging.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/stasis_bridging.h?view=diff&rev=390250&r1=390249&r2=390250
==============================================================================
--- trunk/include/asterisk/stasis_bridging.h (original)
+++ trunk/include/asterisk/stasis_bridging.h Fri May 31 07:41:10 2013
@@ -183,19 +183,6 @@
/*!
* \since 12
- * \brief Extracts the type field from a \ref ast_bridge_blob.
- *
- * Returned \c char* is still owned by \a obj
- *
- * \param obj Channel blob object.
- *
- * \retval Type field value from the blob.
- * \retval \c NULL on error.
- */
-const char *ast_bridge_blob_json_type(struct ast_bridge_blob *obj);
-
-/*!
- * \since 12
* \brief Publish a bridge channel enter event
*
* \param bridge The bridge a channel entered
Modified: trunk/main/stasis_bridging.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/stasis_bridging.c?view=diff&rev=390250&r1=390249&r2=390250
==============================================================================
--- trunk/main/stasis_bridging.c (original)
+++ trunk/main/stasis_bridging.c Fri May 31 07:41:10 2013
@@ -260,15 +260,6 @@
ao2_ref(msg, +1);
return msg;
-}
-
-const char *ast_bridge_blob_json_type(struct ast_bridge_blob *obj)
-{
- if (obj == NULL) {
- return NULL;
- }
-
- return ast_json_string_get(ast_json_object_get(obj->blob, "type"));
}
void ast_bridge_publish_enter(struct ast_bridge *bridge, struct ast_channel *chan)
More information about the asterisk-commits
mailing list