]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Make a couple of changes to help AMI events to be more clear in what is occurring.
authorMark Michelson <mmichelson@digium.com>
Fri, 2 Aug 2013 14:13:04 +0000 (14:13 +0000)
committerMark Michelson <mmichelson@digium.com>
Fri, 2 Aug 2013 14:13:04 +0000 (14:13 +0000)
* BridgeEnter now contains the unique ID of the channel that is to be swapped out, if applicable.
* There is a ParkedCallSwap event that is sent when a parked channel has a new channel take its place.

(closes issue ASTERISK-22193)
reported by Mark Michelson

Review: https://reviewboard.asterisk.org/r/2712

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396107 65c4cc65-6c06-0410-ace0-fbb531ad65f3

include/asterisk/parking.h
include/asterisk/stasis_bridges.h
main/bridge_channel.c
main/cel.c
main/manager_bridges.c
main/stasis_bridges.c
res/parking/parking_bridge.c
res/parking/parking_manager.c

index b9c80d43c67fc5035a25ef72db517aa3f6dcc2cf..25149854ade34ec5dd195ff53b760ded0bbe69b6 100644 (file)
@@ -45,6 +45,7 @@ enum ast_parked_call_event_type {
        PARKED_CALL_GIVEUP,
        PARKED_CALL_UNPARKED,
        PARKED_CALL_FAILED,
+       PARKED_CALL_SWAP,
 };
 
 /*!
index 7fa059fedbd89d1374f54b9e1648047ae4694d4f..d82bcffaf7d7a92e212fdadcad461aff8e6215d7 100644 (file)
@@ -215,8 +215,10 @@ struct stasis_message *ast_bridge_blob_create(struct stasis_message_type *type,
  *
  * \param bridge The bridge a channel entered
  * \param chan The channel that entered the bridge
+ * \param swap The channel being swapped out of the bridge
  */
-void ast_bridge_publish_enter(struct ast_bridge *bridge, struct ast_channel *chan);
+void ast_bridge_publish_enter(struct ast_bridge *bridge, struct ast_channel *chan,
+               struct ast_channel *swap);
 
 /*!
  * \since 12
index f0163ff2ec430beff53b79269a695a16196b91e4..c782ec67d5cf1d81628a74b934c8bd5a06c5e0e6 100644 (file)
@@ -1429,7 +1429,7 @@ int bridge_channel_internal_push(struct ast_bridge_channel *bridge_channel)
                bridge->v_table->name,
                bridge->uniqueid);
 
-       ast_bridge_publish_enter(bridge, bridge_channel->chan);
+       ast_bridge_publish_enter(bridge, bridge_channel->chan, swap ? swap->chan : NULL);
        if (swap) {
                ast_bridge_channel_leave_bridge(swap, BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE);
                bridge_channel_internal_pull(swap);
index 2b5306e21a995656cc0113bbe89415249b718059..befb2b2575f77df9f0c607765ddcb2b7105f4d0b 100644 (file)
@@ -1304,6 +1304,9 @@ static void cel_parking_cb(
        case PARKED_CALL_FAILED:
                reason = "ParkedCallFailed";
                break;
+       case PARKED_CALL_SWAP:
+               reason = "ParkedCallSwap";
+               break;
        }
 
        extra = ast_json_pack("{s: s}", "reason", reason);
index 5d831b5b4498218158ec7531ebb149c1caf94c93..77533c6001c496d1ad950179bf13c7343504c283 100644 (file)
@@ -58,6 +58,9 @@ static struct stasis_message_router *bridge_state_router;
                        <syntax>
                                <bridge_snapshot/>
                                <channel_snapshot/>
+                               <parameter name="SwapUniqueid">
+                                       <para>The uniqueid of the channel being swapped out of the bridge</para>
+                               </parameter>
                        </syntax>
                </managerEventInstance>
        </managerEvent>
@@ -247,9 +250,11 @@ static void channel_enter_cb(void *data, struct stasis_subscription *sub,
                                    struct stasis_topic *topic,
                                    struct stasis_message *message)
 {
+       static const char *swap_name = "SwapUniqueid: ";
        struct ast_bridge_blob *blob = stasis_message_data(message);
        RAII_VAR(struct ast_str *, bridge_text, NULL, ast_free);
        RAII_VAR(struct ast_str *, channel_text, NULL, ast_free);
+       const char *swap_id;
 
        bridge_text = ast_manager_build_bridge_state_string(blob->bridge, "");
        channel_text = ast_manager_build_channel_state_string(blob->channel);
@@ -257,11 +262,17 @@ static void channel_enter_cb(void *data, struct stasis_subscription *sub,
                return;
        }
 
+       swap_id = ast_json_string_get(ast_json_object_get(blob->blob, "swap"));
+
        manager_event(EVENT_FLAG_CALL, "BridgeEnter",
                "%s"
-               "%s",
+               "%s"
+               "%s%s%s",
                ast_str_buffer(bridge_text),
-               ast_str_buffer(channel_text));
+               ast_str_buffer(channel_text),
+               swap_id ? swap_name : "",
+               S_OR(swap_id, ""),
+               swap_id ? "\r\n" : "");
 }
 
 static void channel_leave_cb(void *data, struct stasis_subscription *sub,
index 251f9d7afb4ea7b186f11ff49a5d5ceaf7884de8..a3eeef675b3eac46ecfd926bba60aa1f00092d38 100644 (file)
@@ -380,11 +380,20 @@ struct stasis_message *ast_bridge_blob_create(
        return msg;
 }
 
-void ast_bridge_publish_enter(struct ast_bridge *bridge, struct ast_channel *chan)
+void ast_bridge_publish_enter(struct ast_bridge *bridge, struct ast_channel *chan,
+               struct ast_channel *swap)
 {
        RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
+       RAII_VAR(struct ast_json *, blob, NULL, ao2_cleanup);
 
-       msg = ast_bridge_blob_create(ast_channel_entered_bridge_type(), bridge, chan, NULL);
+       if (swap) {
+               blob = ast_json_pack("{s: s}", "swap", ast_channel_uniqueid(swap));
+               if (!blob) {
+                       return;
+               }
+       }
+
+       msg = ast_bridge_blob_create(ast_channel_entered_bridge_type(), bridge, chan, blob);
        if (!msg) {
                return;
        }
index 04250bf25adae118c0d9db4a73812fe6968a4360..55d853386188f020f54ec26faf7b44bf96055423 100644 (file)
@@ -254,6 +254,8 @@ static int bridge_parking_push(struct ast_bridge_parking *self, struct ast_bridg
                                ast_channel_name(bridge_channel->chan));
                }
 
+               publish_parked_call(pu, PARKED_CALL_SWAP);
+
                return 0;
        }
 
index 65a9ef00472c19f6357a74dbca57587ee7392444..f952ff23a03af2bec710bb2264511993728ccdcd 100644 (file)
@@ -526,6 +526,9 @@ static void parked_call_message_response(struct ast_parked_call_payload *parked_
        case PARKED_CALL_UNPARKED:
                event_type = "UnParkedCall";
                break;
+       case PARKED_CALL_SWAP:
+               event_type = "ParkedCallSwap";
+               break;
        case PARKED_CALL_FAILED:
                /* PARKED_CALL_FAILED doesn't currently get a message and is used exclusively for bridging */
                return;