[asterisk-commits] rmudgett: trunk r396417 - in /trunk: apps/confbridge/ include/asterisk/ main/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Aug 8 14:16:35 CDT 2013
Author: rmudgett
Date: Thu Aug 8 14:16:33 2013
New Revision: 396417
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=396417
Log:
Make bridge snapshots use prefixes.
* Changed ast_manager_build_bridge_state_string() to assume an empty
prefix string just like ast_manager_build_channel_state_string().
* Created ast_manager_build_bridge_state_string_prefix() to work just like
ast_manager_build_channel_state_string_prefix().
* Made BridgeMerge AMI event use To/From prefixes.
Modified:
trunk/apps/confbridge/confbridge_manager.c
trunk/include/asterisk/manager.h
trunk/main/manager_bridges.c
trunk/main/stasis_bridges.c
Modified: trunk/apps/confbridge/confbridge_manager.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/confbridge/confbridge_manager.c?view=diff&rev=396417&r1=396416&r2=396417
==============================================================================
--- trunk/apps/confbridge/confbridge_manager.c (original)
+++ trunk/apps/confbridge/confbridge_manager.c Thu Aug 8 14:16:33 2013
@@ -200,7 +200,7 @@
ast_assert(blob != NULL);
ast_assert(event != NULL);
- bridge_text = ast_manager_build_bridge_state_string(blob->bridge, "");
+ bridge_text = ast_manager_build_bridge_state_string(blob->bridge);
if (!bridge_text) {
return;
}
Modified: trunk/include/asterisk/manager.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/manager.h?view=diff&rev=396417&r1=396416&r2=396417
==============================================================================
--- trunk/include/asterisk/manager.h (original)
+++ trunk/include/asterisk/manager.h Thu Aug 8 14:16:33 2013
@@ -397,13 +397,27 @@
*
* \param snapshot the bridge snapshot for which to generate an AMI message
* body
+ * \param prefix What to prepend to the bridge fields
*
* \retval NULL on error
* \retval ast_str* on success (must be ast_freed by caller)
*/
+struct ast_str *ast_manager_build_bridge_state_string_prefix(
+ const struct ast_bridge_snapshot *snapshot,
+ const char *prefix);
+
+/*!
+ * \brief Generate the AMI message body from a bridge snapshot
+ * \since 12
+ *
+ * \param snapshot the bridge snapshot for which to generate an AMI message
+ * body
+ *
+ * \retval NULL on error
+ * \retval ast_str* on success (must be ast_freed by caller)
+ */
struct ast_str *ast_manager_build_bridge_state_string(
- const struct ast_bridge_snapshot *snapshot,
- const char *suffix);
+ const struct ast_bridge_snapshot *snapshot);
/*! \brief Struct containing info for an AMI event to send out. */
struct ast_manager_event_blob {
Modified: trunk/main/manager_bridges.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/manager_bridges.c?view=diff&rev=396417&r1=396416&r2=396417
==============================================================================
--- trunk/main/manager_bridges.c (original)
+++ trunk/main/manager_bridges.c Thu Aug 8 14:16:33 2013
@@ -108,31 +108,38 @@
*/
static struct stasis_subscription *topic_forwarder;
-struct ast_str *ast_manager_build_bridge_state_string(
+struct ast_str *ast_manager_build_bridge_state_string_prefix(
const struct ast_bridge_snapshot *snapshot,
- const char *suffix)
+ const char *prefix)
{
struct ast_str *out = ast_str_create(128);
- int res = 0;
+ int res;
+
if (!out) {
return NULL;
}
+
res = ast_str_set(&out, 0,
- "BridgeUniqueid%s: %s\r\n"
- "BridgeType%s: %s\r\n"
- "BridgeTechnology%s: %s\r\n"
- "BridgeNumChannels%s: %d\r\n",
- suffix, snapshot->uniqueid,
- suffix, snapshot->subclass,
- suffix, snapshot->technology,
- suffix, snapshot->num_channels);
-
+ "%sBridgeUniqueid: %s\r\n"
+ "%sBridgeType: %s\r\n"
+ "%sBridgeTechnology: %s\r\n"
+ "%sBridgeNumChannels: %d\r\n",
+ prefix, snapshot->uniqueid,
+ prefix, snapshot->subclass,
+ prefix, snapshot->technology,
+ prefix, snapshot->num_channels);
if (!res) {
ast_free(out);
return NULL;
}
return out;
+}
+
+struct ast_str *ast_manager_build_bridge_state_string(
+ const struct ast_bridge_snapshot *snapshot)
+{
+ return ast_manager_build_bridge_state_string_prefix(snapshot, "");
}
/*! \brief Typedef for callbacks that get called on channel snapshot updates */
@@ -201,7 +208,7 @@
if (!bridge_event_string) {
bridge_event_string =
ast_manager_build_bridge_state_string(
- new_snapshot ? new_snapshot : old_snapshot, "");
+ new_snapshot ? new_snapshot : old_snapshot);
if (!bridge_event_string) {
return;
}
@@ -224,8 +231,8 @@
ast_assert(merge_msg->to != NULL);
ast_assert(merge_msg->from != NULL);
- to_text = ast_manager_build_bridge_state_string(merge_msg->to, "");
- from_text = ast_manager_build_bridge_state_string(merge_msg->from, "From");
+ to_text = ast_manager_build_bridge_state_string_prefix(merge_msg->to, "To");
+ from_text = ast_manager_build_bridge_state_string_prefix(merge_msg->from, "From");
if (!to_text || !from_text) {
return;
}
@@ -234,7 +241,7 @@
<managerEventInstance>
<synopsis>Raised when two bridges are merged.</synopsis>
<syntax>
- <bridge_snapshot/>
+ <bridge_snapshot prefix="To"/>
<bridge_snapshot prefix="From"/>
</syntax>
</managerEventInstance>
@@ -256,7 +263,7 @@
RAII_VAR(struct ast_str *, channel_text, NULL, ast_free);
const char *swap_id;
- bridge_text = ast_manager_build_bridge_state_string(blob->bridge, "");
+ 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;
@@ -283,7 +290,7 @@
RAII_VAR(struct ast_str *, bridge_text, NULL, ast_free);
RAII_VAR(struct ast_str *, channel_text, NULL, ast_free);
- bridge_text = ast_manager_build_bridge_state_string(blob->bridge, "");
+ 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;
@@ -309,7 +316,7 @@
struct ast_bridge_snapshot *snapshot = stasis_message_data(obj);
struct mansession *s = arg;
char *id_text = data;
- RAII_VAR(struct ast_str *, bridge_info, ast_manager_build_bridge_state_string(snapshot, ""), ast_free);
+ RAII_VAR(struct ast_str *, bridge_info, ast_manager_build_bridge_state_string(snapshot), ast_free_ptr);
if (!bridge_info) {
return 0;
@@ -432,7 +439,7 @@
astman_send_ack(s, m, "Bridge channel listing will follow");
snapshot = stasis_message_data(msg);
- bridge_info = ast_manager_build_bridge_state_string(snapshot, "");
+ bridge_info = ast_manager_build_bridge_state_string(snapshot);
ao2_callback_data(snapshot->channels, OBJ_NODATA, send_bridge_info_item_cb, s, ast_str_buffer(id_text));
Modified: trunk/main/stasis_bridges.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/stasis_bridges.c?view=diff&rev=396417&r1=396416&r2=396417
==============================================================================
--- trunk/main/stasis_bridges.c (original)
+++ trunk/main/stasis_bridges.c Thu Aug 8 14:16:33 2013
@@ -537,8 +537,7 @@
}
channel_state = ast_manager_build_channel_state_string_prefix(blob->channel, "Transferer");
- bridge_state = ast_manager_build_bridge_state_string(blob->bridge, "");
-
+ bridge_state = ast_manager_build_bridge_state_string(blob->bridge);
if (!channel_state || !bridge_state) {
return NULL;
}
@@ -605,20 +604,21 @@
transferer1_state = ast_manager_build_channel_state_string_prefix(transfer_msg->to_transferee.channel_snapshot, "OrigTransferer");
transferer2_state = ast_manager_build_channel_state_string_prefix(transfer_msg->to_transfer_target.channel_snapshot, "SecondTransferer");
-
if (!transferer1_state || !transferer2_state) {
return NULL;
}
if (transfer_msg->to_transferee.bridge_snapshot) {
- bridge1_state = ast_manager_build_bridge_state_string(transfer_msg->to_transferee.bridge_snapshot, "Orig");
+ bridge1_state = ast_manager_build_bridge_state_string_prefix(
+ transfer_msg->to_transferee.bridge_snapshot, "Orig");
if (!bridge1_state) {
return NULL;
}
}
if (transfer_msg->to_transfer_target.bridge_snapshot) {
- bridge2_state = ast_manager_build_bridge_state_string(transfer_msg->to_transfer_target.bridge_snapshot, "Second");
+ bridge2_state = ast_manager_build_bridge_state_string_prefix(
+ transfer_msg->to_transfer_target.bridge_snapshot, "Second");
if (!bridge2_state) {
return NULL;
}
More information about the asterisk-commits
mailing list