[asterisk-commits] rmudgett: branch rmudgett/bridge_phase r389968 - in /team/rmudgett/bridge_pha...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue May 28 18:00:47 CDT 2013


Author: rmudgett
Date: Tue May 28 18:00:43 2013
New Revision: 389968

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=389968
Log:
Bridge API: Update ATTENDED_TRANSFER_COMPLETE_SOUND and BRIDGE_PLAY_SOUND.

* Removed unneeded notes about TRANSFER_CONTEXT.

Modified:
    team/rmudgett/bridge_phase/CHANGES
    team/rmudgett/bridge_phase/bridges/bridge_builtin_features.c
    team/rmudgett/bridge_phase/configs/chan_dahdi.conf.sample
    team/rmudgett/bridge_phase/configs/iax.conf.sample
    team/rmudgett/bridge_phase/configs/sip.conf.sample
    team/rmudgett/bridge_phase/configs/skinny.conf.sample
    team/rmudgett/bridge_phase/include/asterisk/bridging_features.h
    team/rmudgett/bridge_phase/main/bridging.c
    team/rmudgett/bridge_phase/main/manager.c

Modified: team/rmudgett/bridge_phase/CHANGES
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/CHANGES?view=diff&rev=389968&r1=389967&r2=389968
==============================================================================
--- team/rmudgett/bridge_phase/CHANGES (original)
+++ team/rmudgett/bridge_phase/CHANGES Tue May 28 18:00:43 2013
@@ -232,6 +232,13 @@
    that the REDIRECTING dialplan function can be used to set the redirecting
    reason to any string. It also allows for custom strings to be read as the
    redirecting reason from SIP Diversion headers.
+
+ * The channel variable TRANSFER_CONTEXT must be on the channel initiating a
+   DTMF blind transfer or DTMF attended transfer to have any effect.
+
+ * The channel variable ATTENDED_TRANSFER_COMPLETE_SOUND is no longer channel
+   driver specific.  If the channel variable is set, the sound will be played
+   to the target of an attended transfer.
 
 Realtime
 ------------------

Modified: team/rmudgett/bridge_phase/bridges/bridge_builtin_features.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/bridges/bridge_builtin_features.c?view=diff&rev=389968&r1=389967&r2=389968
==============================================================================
--- team/rmudgett/bridge_phase/bridges/bridge_builtin_features.c (original)
+++ team/rmudgett/bridge_phase/bridges/bridge_builtin_features.c Tue May 28 18:00:43 2013
@@ -261,6 +261,7 @@
 	struct ast_bridge_features caller_features;
 	int xfer_failed;
 	struct ast_bridge_features_attended_transfer *attended_transfer = hook_pvt;
+	const char *complete_sound;
 	const char *context;
 	enum atxfer_code transfer_code = ATXFER_INCOMPLETE;
 
@@ -377,6 +378,20 @@
 	ast_bridge_destroy(attended_bridge);
 	ast_bridge_features_cleanup(&caller_features);
 
+	/* Is there a courtesy sound to play to the peer? */
+	ast_channel_lock(bridge_channel->chan);
+	complete_sound = pbx_builtin_getvar_helper(bridge_channel->chan,
+		"ATTENDED_TRANSFER_COMPLETE_SOUND");
+	if (!ast_strlen_zero(complete_sound)) {
+		complete_sound = ast_strdupa(complete_sound);
+	} else {
+		complete_sound = NULL;
+	}
+	ast_channel_unlock(bridge_channel->chan);
+	if (complete_sound) {
+		pbx_builtin_setvar_helper(peer, "BRIDGE_PLAY_SOUND", complete_sound);
+	}
+
 	xfer_failed = -1;
 	switch (transfer_code) {
 	case ATXFER_INCOMPLETE:

Modified: team/rmudgett/bridge_phase/configs/chan_dahdi.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/configs/chan_dahdi.conf.sample?view=diff&rev=389968&r1=389967&r2=389968
==============================================================================
--- team/rmudgett/bridge_phase/configs/chan_dahdi.conf.sample (original)
+++ team/rmudgett/bridge_phase/configs/chan_dahdi.conf.sample Tue May 28 18:00:43 2013
@@ -863,12 +863,13 @@
 ;namedcallgroup=engineering,sales,netgroup,protgroup
 ;namedpickupgroup=sales
 
-; Channel variable to be set for all calls from this channel
+; Channel variables to be set for all calls from this channel
 ;setvar=CHANNEL=42
 ;setvar=ATTENDED_TRANSFER_COMPLETE_SOUND=beep   ; This channel variable will
                                                 ; cause the given audio file to
                                                 ; be played upon completion of
-                                                ; an attended transfer.
+                                                ; an attended transfer to the
+                                                ; target of the transfer.
 
 ;
 ; Specify whether the channel should be answered immediately or if the simple

Modified: team/rmudgett/bridge_phase/configs/iax.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/configs/iax.conf.sample?view=diff&rev=389968&r1=389967&r2=389968
==============================================================================
--- team/rmudgett/bridge_phase/configs/iax.conf.sample (original)
+++ team/rmudgett/bridge_phase/configs/iax.conf.sample Tue May 28 18:00:43 2013
@@ -550,7 +550,8 @@
 ;setvar=ATTENDED_TRANSFER_COMPLETE_SOUND=beep   ; This channel variable will
                                                 ; cause the given audio file to
                                                 ; be played upon completion of
-                                                ; an attended transfer.
+                                                ; an attended transfer to the
+                                                ; target of the transfer.
 ;dbsecret=mysecrets/place    ; Secrets can be stored in astdb, too
 ;transfer=no                 ; Disable IAX2 native transfer
 ;transfer=mediaonly          ; When doing IAX2 native transfers, transfer only

Modified: team/rmudgett/bridge_phase/configs/sip.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/configs/sip.conf.sample?view=diff&rev=389968&r1=389967&r2=389968
==============================================================================
--- team/rmudgett/bridge_phase/configs/sip.conf.sample (original)
+++ team/rmudgett/bridge_phase/configs/sip.conf.sample Tue May 28 18:00:43 2013
@@ -1518,7 +1518,8 @@
 ;setvar=ATTENDED_TRANSFER_COMPLETE_SOUND=beep   ; This channel variable will
                                                 ; cause the given audio file to
                                                 ; be played upon completion of
-                                                ; an attended transfer.
+                                                ; an attended transfer to the
+                                                ; target of the transfer.
 
 ;[pre14-asterisk]
 ;type=friend

Modified: team/rmudgett/bridge_phase/configs/skinny.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/configs/skinny.conf.sample?view=diff&rev=389968&r1=389967&r2=389968
==============================================================================
--- team/rmudgett/bridge_phase/configs/skinny.conf.sample (original)
+++ team/rmudgett/bridge_phase/configs/skinny.conf.sample Tue May 28 18:00:43 2013
@@ -131,7 +131,8 @@
 ;setvar=ATTENDED_TRANSFER_COMPLETE_SOUND=beep   ; This channel variable will
                                                 ; cause the given audio file to
                                                 ; be played upon completion of
-                                                ; an attended transfer.
+                                                ; an attended transfer to the
+                                                ; target of the transfer.
 ;mailbox=500
 ;callwaiting=yes
 ;transfer=yes

Modified: team/rmudgett/bridge_phase/include/asterisk/bridging_features.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/include/asterisk/bridging_features.h?view=diff&rev=389968&r1=389967&r2=389968
==============================================================================
--- team/rmudgett/bridge_phase/include/asterisk/bridging_features.h (original)
+++ team/rmudgett/bridge_phase/include/asterisk/bridging_features.h Tue May 28 18:00:43 2013
@@ -244,8 +244,7 @@
  * \brief Structure that contains configuration information for the blind transfer built in feature
  */
 struct ast_bridge_features_blind_transfer {
-/* BUGBUG the context should be figured out based upon TRANSFER_CONTEXT channel variable of A/B or current context of A/B. More appropriate for when channel moved to other bridges. */
-	/*! Context to use for transfers */
+	/*! Context to use for transfers (If not empty.) */
 	char context[AST_MAX_CONTEXT];
 };
 
@@ -253,14 +252,13 @@
  * \brief Structure that contains configuration information for the attended transfer built in feature
  */
 struct ast_bridge_features_attended_transfer {
-/* BUGBUG the context should be figured out based upon TRANSFER_CONTEXT channel variable of A/B or current context of A/B. More appropriate for when channel moved to other bridges. */
-	/*! Context to use for transfers */
+	/*! Context to use for transfers (If not empty.) */
 	char context[AST_MAX_CONTEXT];
-	/*! DTMF string used to abort the transfer */
+	/*! DTMF string used to abort the transfer (If not empty.) */
 	char abort[MAXIMUM_DTMF_FEATURE_STRING];
-	/*! DTMF string used to turn the transfer into a three way conference */
+	/*! DTMF string used to turn the transfer into a three way conference (If not empty.) */
 	char threeway[MAXIMUM_DTMF_FEATURE_STRING];
-	/*! DTMF string used to complete the transfer */
+	/*! DTMF string used to complete the transfer (If not empty.) */
 	char complete[MAXIMUM_DTMF_FEATURE_STRING];
 };
 

Modified: team/rmudgett/bridge_phase/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/main/bridging.c?view=diff&rev=389968&r1=389967&r2=389968
==============================================================================
--- team/rmudgett/bridge_phase/main/bridging.c (original)
+++ team/rmudgett/bridge_phase/main/bridging.c Tue May 28 18:00:43 2013
@@ -1701,6 +1701,54 @@
 
 /*!
  * \internal
+ * \brief Bridge channel to check if a BRIDGE_PLAY_SOUND needs to be played.
+ * \since 12.0.0
+ *
+ * \param bridge_channel What to check.
+ *
+ * \return Nothing
+ */
+static void handle_bridge_play_sound(struct ast_bridge_channel *bridge_channel)
+{
+	const char *play_file;
+
+	ast_channel_lock(bridge_channel->chan);
+	play_file = pbx_builtin_getvar_helper(bridge_channel->chan, "BRIDGE_PLAY_SOUND");
+	if (!ast_strlen_zero(play_file)) {
+		play_file = ast_strdupa(play_file);
+		pbx_builtin_setvar_helper(bridge_channel->chan, "BRIDGE_PLAY_SOUND", NULL);
+	} else {
+		play_file = NULL;
+	}
+	ast_channel_unlock(bridge_channel->chan);
+
+	if (play_file) {
+		ast_bridge_channel_queue_playfile(bridge_channel, NULL, play_file, NULL);
+	}
+}
+
+/*!
+ * \internal
+ * \brief Handle any BRIDGE_PLAY_SOUND channel variables in the bridge.
+ * \since 12.0.0
+ *
+ * \param bridge What to operate on.
+ *
+ * \note On entry, the bridge is already locked.
+ *
+ * \return Nothing
+ */
+static void handle_bridge_play_sounds(struct ast_bridge *bridge)
+{
+	struct ast_bridge_channel *bridge_channel;
+
+	AST_LIST_TRAVERSE(&bridge->channels, bridge_channel, entry) {
+		handle_bridge_play_sound(bridge_channel);
+	}
+}
+
+/*!
+ * \internal
  * \brief Notify the bridge that it has been reconfigured.
  * \since 12.0.0
  *
@@ -1729,6 +1777,11 @@
 		return;
 	}
 	bridge_complete_join(bridge);
+
+	if (bridge->dissolved) {
+		return;
+	}
+	handle_bridge_play_sounds(bridge);
 }
 
 /*!
@@ -5509,11 +5562,8 @@
 	bridge = ast_channel_get_bridge(chan);
 	ast_channel_unlock(chan);
 
-	if (!bridge) {
-		return NULL;
-	}
-
-	if (ast_test_flag(&bridge->feature_flags, AST_BRIDGE_FLAG_MASQUERADE_ONLY)) {
+	if (bridge
+		&& ast_test_flag(&bridge->feature_flags, AST_BRIDGE_FLAG_MASQUERADE_ONLY)) {
 		ao2_ref(bridge, -1);
 		bridge = NULL;
 	}
@@ -5615,6 +5665,7 @@
 	RAII_VAR(struct ast_bridge *, to_target_bridge, NULL, ao2_cleanup);
 	RAII_VAR(struct ao2_container *, channels, NULL, ao2_cleanup);
 	RAII_VAR(struct ast_channel *, transferee, NULL, ao2_cleanup);
+	const char *target_complete_sound;
 	struct ast_bridge *the_bridge;
 	struct ast_channel *chan_bridged;
 	struct ast_channel *chan_unbridged;
@@ -5627,6 +5678,43 @@
 	/* They can't both be unbridged, you silly goose! */
 	if (!to_transferee_bridge && !to_target_bridge) {
 		return AST_BRIDGE_TRANSFER_INVALID;
+	}
+
+	/* Is there a courtesy sound to play to the target? */
+	if (to_target_bridge) {
+		struct ast_bridge_channel *to_target_bridge_channel;
+
+		ast_channel_lock(to_transfer_target);
+		to_target_bridge_channel = ast_channel_get_bridge_channel(to_transfer_target);
+
+		target_complete_sound = pbx_builtin_getvar_helper(to_transfer_target,
+			"ATTENDED_TRANSFER_COMPLETE_SOUND");
+		if (!ast_strlen_zero(target_complete_sound)) {
+			target_complete_sound = ast_strdupa(target_complete_sound);
+		} else {
+			target_complete_sound = NULL;
+		}
+		ast_channel_unlock(to_transfer_target);
+
+		if (!target_complete_sound) {
+			ast_channel_lock(to_transferee);
+			target_complete_sound = pbx_builtin_getvar_helper(to_transferee,
+				"ATTENDED_TRANSFER_COMPLETE_SOUND");
+			if (!ast_strlen_zero(target_complete_sound)) {
+				target_complete_sound = ast_strdupa(target_complete_sound);
+			} else {
+				target_complete_sound = NULL;
+			}
+			ast_channel_unlock(to_transferee);
+		}
+
+		if (target_complete_sound) {
+			ast_bridge_channel_write_playfile(to_target_bridge_channel, NULL,
+				target_complete_sound, NULL);
+		}
+		ao2_cleanup(to_target_bridge_channel);
+	} else {
+		target_complete_sound = NULL;
 	}
 
 	/* Let's get the easy one out of the way first */

Modified: team/rmudgett/bridge_phase/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/main/manager.c?view=diff&rev=389968&r1=389967&r2=389968
==============================================================================
--- team/rmudgett/bridge_phase/main/manager.c (original)
+++ team/rmudgett/bridge_phase/main/manager.c Tue May 28 18:00:43 2013
@@ -4080,6 +4080,7 @@
 		pbx_builtin_setvar_helper(chan, "TRANSFER_CONTEXT", context);
 	}
 
+/* BUGBUG this is broken because the bridge DTMF hooks need both begin and end events to match correctly. */
 	for (feature_code = atxfer_feature->exten; feature_code && *feature_code; ++feature_code) {
 		struct ast_frame f = { AST_FRAME_DTMF, .subclass.integer = *feature_code };
 		ast_queue_frame(chan, &f);




More information about the asterisk-commits mailing list