[asterisk-commits] dlee: branch dlee/ari-event-remodel2 r392488 - in /team/dlee/ari-event-remode...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jun 21 15:48:24 CDT 2013


Author: dlee
Date: Fri Jun 21 15:48:22 2013
New Revision: 392488

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=392488
Log:
Merged revisions 392318-392437 from http://svn.asterisk.org/svn/asterisk/trunk
........

Merged revisions 392465 from http://svn.asterisk.org/svn/asterisk/team/dlee/ari-url-shuffle

Modified:
    team/dlee/ari-event-remodel2/   (props changed)
    team/dlee/ari-event-remodel2/apps/confbridge/conf_config_parser.c
    team/dlee/ari-event-remodel2/bridges/bridge_softmix.c
    team/dlee/ari-event-remodel2/channels/chan_unistim.c
    team/dlee/ari-event-remodel2/contrib/scripts/autosupport
    team/dlee/ari-event-remodel2/include/asterisk/bridging.h
    team/dlee/ari-event-remodel2/include/asterisk/bridging_features.h
    team/dlee/ari-event-remodel2/include/asterisk/bridging_technology.h
    team/dlee/ari-event-remodel2/main/bridging.c
    team/dlee/ari-event-remodel2/main/features.c
    team/dlee/ari-event-remodel2/main/threadpool.c
    team/dlee/ari-event-remodel2/res/parking/parking_bridge_features.c
    team/dlee/ari-event-remodel2/res/res_sip_session.c

Propchange: team/dlee/ari-event-remodel2/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Jun 21 15:48:22 2013
@@ -1,1 +1,1 @@
-/team/dlee/ari-url-shuffle:1-392398
+/team/dlee/ari-url-shuffle:1-392465

Modified: team/dlee/ari-event-remodel2/apps/confbridge/conf_config_parser.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/apps/confbridge/conf_config_parser.c?view=diff&rev=392488&r1=392487&r2=392488
==============================================================================
--- team/dlee/ari-event-remodel2/apps/confbridge/conf_config_parser.c (original)
+++ team/dlee/ari-event-remodel2/apps/confbridge/conf_config_parser.c Fri Jun 21 15:48:22 2013
@@ -2161,8 +2161,10 @@
 		ao2_ref(menu, +1);
 		pvt->menu = menu;
 
-		ast_bridge_dtmf_hook(&user->features, pvt->menu_entry.dtmf, menu_hook_callback,
-			pvt, menu_hook_destroy, 0);
+		if (ast_bridge_dtmf_hook(&user->features, pvt->menu_entry.dtmf,
+			menu_hook_callback, pvt, menu_hook_destroy, 0)) {
+			menu_hook_destroy(pvt);
+		}
 	}
 
 	ao2_unlock(menu);

Modified: team/dlee/ari-event-remodel2/bridges/bridge_softmix.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/bridges/bridge_softmix.c?view=diff&rev=392488&r1=392487&r2=392488
==============================================================================
--- team/dlee/ari-event-remodel2/bridges/bridge_softmix.c (original)
+++ team/dlee/ari-event-remodel2/bridges/bridge_softmix.c Fri Jun 21 15:48:22 2013
@@ -378,11 +378,12 @@
  *
  * \param bridge_channel Which channel source is changing.
  *
- * \return Nothing
- */
-static void softmix_src_change(struct ast_bridge_channel *bridge_channel)
-{
-	ast_bridge_channel_queue_control_data(bridge_channel, AST_CONTROL_SRCCHANGE, NULL, 0);
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
+static int softmix_src_change(struct ast_bridge_channel *bridge_channel)
+{
+	return ast_bridge_channel_queue_control_data(bridge_channel, AST_CONTROL_SRCCHANGE, NULL, 0);
 }
 
 /*! \brief Function called when a channel is joined into the bridge */

Modified: team/dlee/ari-event-remodel2/channels/chan_unistim.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/channels/chan_unistim.c?view=diff&rev=392488&r1=392487&r2=392488
==============================================================================
--- team/dlee/ari-event-remodel2/channels/chan_unistim.c (original)
+++ team/dlee/ari-event-remodel2/channels/chan_unistim.c Fri Jun 21 15:48:22 2013
@@ -77,6 +77,7 @@
 #include "asterisk/astobj2.h"
 #include "asterisk/astdb.h"
 #include "asterisk/features_config.h"
+#include "asterisk/bridging.h"
 
 
 #define DEFAULTCONTEXT	  "default"
@@ -2305,72 +2306,36 @@
 	return 0;
 }
 
-static void unistim_quiet_chan(struct ast_channel *chan)
-{
-	if (chan && ast_channel_state(chan) == AST_STATE_UP) {
-		if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_MOH)) {
-			ast_moh_stop(chan);
-		} else if (ast_channel_generatordata(chan)) {
-			ast_deactivate_generator(chan);
-		}
-	}
-}
-
 static int attempt_transfer(struct unistim_subchannel *p1, struct unistim_subchannel *p2)
 {
-	int res = 0;
-	struct ast_channel
-	 *chana = NULL, *chanb = NULL, *bridgea = NULL, *bridgeb = NULL, *peera =
-		NULL, *peerb = NULL, *peerc = NULL, *peerd = NULL;
+	RAII_VAR(struct ast_channel *, chana, NULL, ast_channel_unref);
+	RAII_VAR(struct ast_channel *, chanb, NULL, ast_channel_unref);
 
 	if (!p1->owner || !p2->owner) {
 		ast_log(LOG_WARNING, "Transfer attempted without dual ownership?\n");
 		return -1;
 	}
-	chana = p1->owner;
-	chanb = p2->owner;
-	bridgea = ast_bridged_channel(chana);
-	bridgeb = ast_bridged_channel(chanb);
-
-	if (bridgea) {
-		peera = chana;
-		peerb = chanb;
-		peerc = bridgea;
-		peerd = bridgeb;
-	} else if (bridgeb) {
-		peera = chanb;
-		peerb = chana;
-		peerc = bridgeb;
-		peerd = bridgea;
-	}
-
-	if (peera && peerb && peerc && (peerb != peerc)) {
-		unistim_quiet_chan(peera);
-		unistim_quiet_chan(peerb);
-		unistim_quiet_chan(peerc);
-		if (peerd) {
-			unistim_quiet_chan(peerd);
-		}
-
-		ast_log(LOG_NOTICE, "UNISTIM transfer: trying to masquerade %s into %s\n", ast_channel_name(peerc), ast_channel_name(peerb));
-		if (ast_channel_masquerade(peerb, peerc)) {
-			ast_log(LOG_WARNING, "Failed to masquerade %s into %s\n", ast_channel_name(peerb),
-					ast_channel_name(peerc));
-			res = -1;
-		}
-		return res;
-	} else {
-		ast_log(LOG_NOTICE,
-				"Transfer attempted with no appropriate bridged calls to transfer\n");
-		if (chana) {
-			ast_softhangup_nolock(chana, AST_SOFTHANGUP_DEV);
-		}
-		if (chanb) {
-			ast_softhangup_nolock(chanb, AST_SOFTHANGUP_DEV);
-		}
-		return -1;
-	}
-	return 0;
+	chana = ast_channel_ref(p1->owner);
+	chanb = ast_channel_ref(p2->owner);
+
+	switch (ast_bridge_transfer_attended(chana, chanb)) {
+	case AST_BRIDGE_TRANSFER_INVALID:
+		ast_log(LOG_WARNING, "Transfer failed. Invalid bridge setup\n");
+		break;
+	case AST_BRIDGE_TRANSFER_NOT_PERMITTED:
+		ast_log(LOG_WARNING, "Transfer not permitted\n");
+		break;
+	case AST_BRIDGE_TRANSFER_FAIL:
+		ast_log(LOG_WARNING, "Transfer encountered internal error\n");
+		break;
+	case AST_BRIDGE_TRANSFER_SUCCESS:
+		return 0;
+	}
+
+	/* Control only reaches this point if transfer has failed */
+	ast_softhangup_nolock(chana, AST_SOFTHANGUP_DEV);
+	ast_softhangup_nolock(chanb, AST_SOFTHANGUP_DEV);
+	return -1;
 }
 
 void change_callerid(struct unistimsession *pte, int type, char *callerid)

Modified: team/dlee/ari-event-remodel2/contrib/scripts/autosupport
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/contrib/scripts/autosupport?view=diff&rev=392488&r1=392487&r2=392488
==============================================================================
--- team/dlee/ari-event-remodel2/contrib/scripts/autosupport (original)
+++ team/dlee/ari-event-remodel2/contrib/scripts/autosupport Fri Jun 21 15:48:22 2013
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# Autosupport Version 2.0.19
+# Autosupport Version 2.1.0
 # Collect support information
 #
 # Copyright (C) 2005-2013, Digium, Inc.
@@ -21,7 +21,7 @@
 # Ensure the PATH variable includes '/usr/sbin' and '/sbin'
 PATH=/usr/sbin:/sbin:${PATH}
 
-DATE_STAMP=$(date +%Y%m%d)
+DATE_STAMP=$(date +%F)
 OUTPUT_FILE=digiuminfo.txt
 TARBALL_OUTPUT_FILE="digium-info_${DATE_STAMP}.tar"
 VAR_LIB_LIST_FILE="list-of-varlibasterisk.txt"
@@ -30,10 +30,11 @@
 files="n";
 NONINTERACTIVE=0
 
+
 # If a prefix is specified on command-line, add it.
 if (set -u; : $1) 2> /dev/null
 then
-  if [ $1 == "-h" ] || [ $1 == "--help" ]; then
+  if [ $1 = "-h" ] || [ $1 = "--help" ]; then
     echo
     echo "Digium autosupport script"
     echo "Copyright (C) 2005-2013, Digium, Inc."
@@ -53,7 +54,7 @@
     echo "    XXXXXXXX_${TARBALL_OUTPUT_FILE}"
     echo
     exit
-  elif [ $1 == "-n" ] || [ $1 == "--non-interactive" ]; then
+  elif [ $1 = "-n" ] || [ $1 = "--non-interactive" ]; then
     FILE_PREFIX=
     NONINTERACTIVE=1
   else
@@ -187,7 +188,10 @@
       "core show uptime" "pri show spans" "misdn show stacks" "zap show channels" "dahdi show status" "dahdi show channels" \
       "dahdi show channel 1" "core show channels" "skype show version" "skype show licenses" "skype show users" \
       "skype show hostid" "show g729" "g729 show version" "g729 show licenses" "g729 show hostid" "fax show version" \
-      "fax show licenses" "fax show hostid" "fax show stats" "digium_phones show version"; do
+      "fax show licenses" "fax show hostid" "fax show stats" "digium_phones show version" "digium_phones show alerts" \
+			"digium_phones show applications" "digium_phones show firmwares" "digium_phones show lines" "digium_phones show networks" \
+			"digium_phones show phones" "digium_phones show sessions" "digium_phones show settings" "digium_phones show translations" ;
+	do
     echo "asterisk -rx \"$command\"" >> $OUTPUT;
     asterisk -rx "$command" >> $OUTPUT;
     echo >> $OUTPUT;
@@ -195,6 +199,67 @@
   done
   echo >> $OUTPUT;
 fi
+
+
+for type in alerts applications firmwares lines networks phones translations; 
+do 
+	echo "------------------" >> $OUTPUT; 
+	echo "DIGIUM PHONE: $type " >> $OUTPUT; 
+	echo "------------------" >> $OUTPUT; 
+	TEMP=$(asterisk -rx "digium_phones show $type"); 
+	if [ "$type" = "lines" ];
+	then
+		NUM=$(echo $TEMP | tail -n 1 | awk -F' ' '{print $(NF-4)}');
+		if [ $NUM -gt 0 ];
+		then
+			for l in $(echo $TEMP | sed 's/^--- [[:alpha:]]\+ --- //; 
+				s/Lines \(Un-\)\?Mapped to Phones --- //g; 
+				s/ Internal//g; 
+				s/---- [a-zA-Z0-9 ]\+ ----$//;
+				s/--- //g');
+			do
+				asterisk -rx "digium_phones show line $l" >> $OUTPUT;                                                                      
+				echo "--------" >> $OUTPUT;                                                                                                                         
+				echo >> $OUTPUT; 
+			done
+		else
+			echo "No configurations of type $type..." >> $OUTPUT;
+			echo >> $OUTPUT;
+		fi;
+	elif [ "$type" = "firmwares" ];
+	then
+		for f in $(echo $TEMP | sed 's/--- Configured Firmware Options --- //');
+		do
+			asterisk -rx "digium_phones show firmware $f" >> $OUTPUT;
+			echo "--------" >> $OUTPUT;                                                                                                                         
+			echo >> $OUTPUT; 
+		done
+	elif [ "$type" = "translations" ];
+	then
+		for t in $(echo $TEMP | sed 's/--- Translation tables ---//');
+		do
+			asterisk -rx "digium_phones show translation $t" 
+		done
+	else
+		NUM=$(echo $TEMP | tail -n 1 | awk -F' ' '{print $(NF-3)}'); 
+		if [ $NUM -gt 0 ]; 
+		then   
+			for t in $(echo $TEMP | sed 's/^--- [[:alpha:]]\+ --- //; 
+																	 s/---- [a-zA-Z0-9 ]\+ ----$//
+																	 s/---- Digium Phones ---- //'); 
+			do 
+				asterisk -rx "digium_phones show $(echo $type | sed 's/s\b//') $t" >> $OUTPUT; 
+				echo "--------" >> $OUTPUT; 
+				echo >> $OUTPUT; 
+			done; 
+		else 
+			echo "No configurations of type $type..." >> $OUTPUT;
+			echo >> $OUTPUT;
+		fi;
+	fi;
+done;
+echo >> $OUTPUT;
+
 
 echo "------------------" >> $OUTPUT;
 echo "OTHER INFO : cat /etc/*{issue,release,version}*" >> $OUTPUT;

Modified: team/dlee/ari-event-remodel2/include/asterisk/bridging.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/include/asterisk/bridging.h?view=diff&rev=392488&r1=392487&r2=392488
==============================================================================
--- team/dlee/ari-event-remodel2/include/asterisk/bridging.h (original)
+++ team/dlee/ari-event-remodel2/include/asterisk/bridging.h Fri Jun 21 15:48:22 2013
@@ -1088,9 +1088,10 @@
  * \param data Frame payload data to pass.
  * \param datalen Frame payload data length to pass.
  *
- * \return Nothing
- */
-typedef void (*ast_bridge_channel_post_action_data)(struct ast_bridge_channel *bridge_channel, enum ast_bridge_action_type action, const void *data, size_t datalen);
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
+typedef int (*ast_bridge_channel_post_action_data)(struct ast_bridge_channel *bridge_channel, enum ast_bridge_action_type action, const void *data, size_t datalen);
 
 /*!
  * \brief Queue an action frame onto the bridge channel with data.
@@ -1101,9 +1102,10 @@
  * \param data Frame payload data to pass.
  * \param datalen Frame payload data length to pass.
  *
- * \return Nothing
- */
-void ast_bridge_channel_queue_action_data(struct ast_bridge_channel *bridge_channel, enum ast_bridge_action_type action, const void *data, size_t datalen);
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
+int ast_bridge_channel_queue_action_data(struct ast_bridge_channel *bridge_channel, enum ast_bridge_action_type action, const void *data, size_t datalen);
 
 /*!
  * \brief Write an action frame into the bridge with data.
@@ -1114,9 +1116,10 @@
  * \param data Frame payload data to pass.
  * \param datalen Frame payload data length to pass.
  *
- * \return Nothing
- */
-void ast_bridge_channel_write_action_data(struct ast_bridge_channel *bridge_channel, enum ast_bridge_action_type action, const void *data, size_t datalen);
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
+int ast_bridge_channel_write_action_data(struct ast_bridge_channel *bridge_channel, enum ast_bridge_action_type action, const void *data, size_t datalen);
 
 /*!
  * \brief Queue a control frame onto the bridge channel with data.
@@ -1127,9 +1130,10 @@
  * \param data Frame payload data to pass.
  * \param datalen Frame payload data length to pass.
  *
- * \return Nothing
- */
-void ast_bridge_channel_queue_control_data(struct ast_bridge_channel *bridge_channel, enum ast_control_frame_type control, const void *data, size_t datalen);
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
+int ast_bridge_channel_queue_control_data(struct ast_bridge_channel *bridge_channel, enum ast_control_frame_type control, const void *data, size_t datalen);
 
 /*!
  * \brief Write a control frame into the bridge with data.
@@ -1140,9 +1144,10 @@
  * \param data Frame payload data to pass.
  * \param datalen Frame payload data length to pass.
  *
- * \return Nothing
- */
-void ast_bridge_channel_write_control_data(struct ast_bridge_channel *bridge_channel, enum ast_control_frame_type control, const void *data, size_t datalen);
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
+int ast_bridge_channel_write_control_data(struct ast_bridge_channel *bridge_channel, enum ast_control_frame_type control, const void *data, size_t datalen);
 
 /*!
  * \brief Write a hold frame into the bridge.
@@ -1151,9 +1156,10 @@
  * \param bridge_channel Which channel is putting the hold into the bridge.
  * \param moh_class The suggested music class for the other end to use.
  *
- * \return Nothing
- */
-void ast_bridge_channel_write_hold(struct ast_bridge_channel *bridge_channel, const char *moh_class);
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
+int ast_bridge_channel_write_hold(struct ast_bridge_channel *bridge_channel, const char *moh_class);
 
 /*!
  * \brief Write an unhold frame into the bridge.
@@ -1161,9 +1167,10 @@
  *
  * \param bridge_channel Which channel is putting the hold into the bridge.
  *
- * \return Nothing
- */
-void ast_bridge_channel_write_unhold(struct ast_bridge_channel *bridge_channel);
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
+int ast_bridge_channel_write_unhold(struct ast_bridge_channel *bridge_channel);
 
 /*!
  * \brief Run an application on the bridge channel.
@@ -1195,9 +1202,10 @@
  *
  * \note This is intended to be called by bridge hooks.
  *
- * \return Nothing
- */
-void ast_bridge_channel_write_app(struct ast_bridge_channel *bridge_channel, const char *app_name, const char *app_args, const char *moh_class);
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
+int ast_bridge_channel_write_app(struct ast_bridge_channel *bridge_channel, const char *app_name, const char *app_args, const char *moh_class);
 
 /*!
  * \brief Queue a bridge action run application frame onto the bridge channel.
@@ -1212,9 +1220,10 @@
  *
  * \note This is intended to be called by bridge hooks.
  *
- * \return Nothing
- */
-void ast_bridge_channel_queue_app(struct ast_bridge_channel *bridge_channel, const char *app_name, const char *app_args, const char *moh_class);
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
+int ast_bridge_channel_queue_app(struct ast_bridge_channel *bridge_channel, const char *app_name, const char *app_args, const char *moh_class);
 
 /*!
  * \brief Custom interpretation of the playfile name.
@@ -1256,9 +1265,10 @@
  *
  * \note This is intended to be called by bridge hooks.
  *
- * \return Nothing
- */
-void ast_bridge_channel_write_playfile(struct ast_bridge_channel *bridge_channel, ast_bridge_custom_play_fn custom_play, const char *playfile, const char *moh_class);
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
+int ast_bridge_channel_write_playfile(struct ast_bridge_channel *bridge_channel, ast_bridge_custom_play_fn custom_play, const char *playfile, const char *moh_class);
 
 /*!
  * \brief Queue a bridge action play file frame onto the bridge channel.
@@ -1273,9 +1283,10 @@
  *
  * \note This is intended to be called by bridge hooks.
  *
- * \return Nothing
- */
-void ast_bridge_channel_queue_playfile(struct ast_bridge_channel *bridge_channel, ast_bridge_custom_play_fn custom_play, const char *playfile, const char *moh_class);
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
+int ast_bridge_channel_queue_playfile(struct ast_bridge_channel *bridge_channel, ast_bridge_custom_play_fn custom_play, const char *playfile, const char *moh_class);
 
 /*!
  * \brief Custom callback run on a bridge channel.
@@ -1303,9 +1314,10 @@
  *
  * \note This is intended to be called by bridge hooks.
  *
- * \return Nothing
- */
-void ast_bridge_channel_write_callback(struct ast_bridge_channel *bridge_channel, ast_bridge_custom_callback_fn callback, const void *payload, size_t payload_size);
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
+int ast_bridge_channel_write_callback(struct ast_bridge_channel *bridge_channel, ast_bridge_custom_callback_fn callback, const void *payload, size_t payload_size);
 
 /*!
  * \brief Queue a bridge action custom callback frame onto the bridge channel.
@@ -1320,9 +1332,10 @@
  *
  * \note This is intended to be called by bridge hooks.
  *
- * \return Nothing
- */
-void ast_bridge_channel_queue_callback(struct ast_bridge_channel *bridge_channel, ast_bridge_custom_callback_fn callback, const void *payload, size_t payload_size);
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
+int ast_bridge_channel_queue_callback(struct ast_bridge_channel *bridge_channel, ast_bridge_custom_callback_fn callback, const void *payload, size_t payload_size);
 
 /*!
  * \brief Have a bridge channel park a channel in the bridge
@@ -1335,9 +1348,10 @@
  *
  * \note This is intended to be called by bridge hooks.
  *
- * \return Nothing
- */
-void ast_bridge_channel_write_park(struct ast_bridge_channel *bridge_channel, const char *parkee_uuid,
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
+int ast_bridge_channel_write_park(struct ast_bridge_channel *bridge_channel, const char *parkee_uuid,
 	const char *parker_uuid, const char *app_data);
 
 /*!

Modified: team/dlee/ari-event-remodel2/include/asterisk/bridging_features.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/include/asterisk/bridging_features.h?view=diff&rev=392488&r1=392487&r2=392488
==============================================================================
--- team/dlee/ari-event-remodel2/include/asterisk/bridging_features.h (original)
+++ team/dlee/ari-event-remodel2/include/asterisk/bridging_features.h Fri Jun 21 15:48:22 2013
@@ -390,7 +390,7 @@
  * \param remove_flags Dictates what situations the hook should be removed.
  *
  * \retval 0 on success
- * \retval -1 on failure
+ * \retval -1 on failure (The caller must cleanup any hook_pvt resources.)
  *
  * Example usage:
  *
@@ -420,7 +420,7 @@
  * \param remove_flags Dictates what situations the hook should be removed.
  *
  * \retval 0 on success
- * \retval -1 on failure
+ * \retval -1 on failure (The caller must cleanup any hook_pvt resources.)
  *
  * Example usage:
  *
@@ -450,7 +450,7 @@
  * \param remove_flags Dictates what situations the hook should be removed.
  *
  * \retval 0 on success
- * \retval -1 on failure
+ * \retval -1 on failure (The caller must cleanup any hook_pvt resources.)
  *
  * Example usage:
  *
@@ -481,7 +481,7 @@
  * \param remove_flags Dictates what situations the hook should be removed.
  *
  * \retval 0 on success
- * \retval -1 on failure
+ * \retval -1 on failure (The caller must cleanup any hook_pvt resources.)
  *
  * Example usage:
  *
@@ -503,7 +503,7 @@
 	enum ast_bridge_hook_remove_flags remove_flags);
 
 /*!
- * \brief attach an interval hook to a bridge features structure
+ * \brief Attach an interval hook to a bridge features structure
  *
  * \param features Bridge features structure
  * \param interval The interval that the hook should execute at in milliseconds
@@ -513,7 +513,7 @@
  * \param remove_flags Dictates what situations the hook should be removed.
  *
  * \retval 0 on success
- * \retval -1 on failure
+ * \retval -1 on failure (The caller must cleanup any hook_pvt resources.)
  *
  * \code
  * struct ast_bridge_features features;

Modified: team/dlee/ari-event-remodel2/include/asterisk/bridging_technology.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/include/asterisk/bridging_technology.h?view=diff&rev=392488&r1=392487&r2=392488
==============================================================================
--- team/dlee/ari-event-remodel2/include/asterisk/bridging_technology.h (original)
+++ team/dlee/ari-event-remodel2/include/asterisk/bridging_technology.h Fri Jun 21 15:48:22 2013
@@ -196,8 +196,11 @@
  * \param bridge_channel The bridge channel that has either started or stopped talking.
  * \param started_talking set to 1 when this indicates the channel has started talking set to 0
  * when this indicates the channel has stopped talking.
- */
-void ast_bridge_notify_talking(struct ast_bridge_channel *bridge_channel, int started_talking);
+ *
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
+int ast_bridge_notify_talking(struct ast_bridge_channel *bridge_channel, int started_talking);
 
 /*!
  * \brief Suspend a bridge technology from consideration

Modified: team/dlee/ari-event-remodel2/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/main/bridging.c?view=diff&rev=392488&r1=392487&r2=392488
==============================================================================
--- team/dlee/ari-event-remodel2/main/bridging.c (original)
+++ team/dlee/ari-event-remodel2/main/bridging.c Fri Jun 21 15:48:22 2013
@@ -397,7 +397,7 @@
 	return 0;
 }
 
-void ast_bridge_channel_queue_action_data(struct ast_bridge_channel *bridge_channel, enum ast_bridge_action_type action, const void *data, size_t datalen)
+int ast_bridge_channel_queue_action_data(struct ast_bridge_channel *bridge_channel, enum ast_bridge_action_type action, const void *data, size_t datalen)
 {
 	struct ast_frame frame = {
 		.frametype = AST_FRAME_BRIDGE_ACTION,
@@ -406,10 +406,10 @@
 		.data.ptr = (void *) data,
 	};
 
-	ast_bridge_channel_queue_frame(bridge_channel, &frame);
-}
-
-void ast_bridge_channel_queue_control_data(struct ast_bridge_channel *bridge_channel, enum ast_control_frame_type control, const void *data, size_t datalen)
+	return ast_bridge_channel_queue_frame(bridge_channel, &frame);
+}
+
+int ast_bridge_channel_queue_control_data(struct ast_bridge_channel *bridge_channel, enum ast_control_frame_type control, const void *data, size_t datalen)
 {
 	struct ast_frame frame = {
 		.frametype = AST_FRAME_CONTROL,
@@ -418,7 +418,7 @@
 		.data.ptr = (void *) data,
 	};
 
-	ast_bridge_channel_queue_frame(bridge_channel, &frame);
+	return ast_bridge_channel_queue_frame(bridge_channel, &frame);
 }
 
 void ast_bridge_channel_restore_formats(struct ast_bridge_channel *bridge_channel)
@@ -749,7 +749,7 @@
 	return ready;
 }
 
-void ast_bridge_notify_talking(struct ast_bridge_channel *bridge_channel, int started_talking)
+int ast_bridge_notify_talking(struct ast_bridge_channel *bridge_channel, int started_talking)
 {
 	struct ast_frame action = {
 		.frametype = AST_FRAME_BRIDGE_ACTION,
@@ -757,10 +757,10 @@
 			? AST_BRIDGE_ACTION_TALKING_START : AST_BRIDGE_ACTION_TALKING_STOP,
 	};
 
-	ast_bridge_channel_queue_frame(bridge_channel, &action);
-}
-
-static void bridge_channel_write_frame(struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
+	return ast_bridge_channel_queue_frame(bridge_channel, &action);
+}
+
+static int bridge_channel_write_frame(struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
 {
 	ast_bridge_channel_lock_bridge(bridge_channel);
 /*
@@ -771,9 +771,15 @@
  */
 	bridge_channel->bridge->technology->write(bridge_channel->bridge, bridge_channel, frame);
 	ast_bridge_unlock(bridge_channel->bridge);
-}
-
-void ast_bridge_channel_write_action_data(struct ast_bridge_channel *bridge_channel, enum ast_bridge_action_type action, const void *data, size_t datalen)
+
+	/*
+	 * Claim successful write to bridge.  If deferred frame
+	 * support is added, claim successfully deferred.
+	 */
+	return 0;
+}
+
+int ast_bridge_channel_write_action_data(struct ast_bridge_channel *bridge_channel, enum ast_bridge_action_type action, const void *data, size_t datalen)
 {
 	struct ast_frame frame = {
 		.frametype = AST_FRAME_BRIDGE_ACTION,
@@ -782,10 +788,10 @@
 		.data.ptr = (void *) data,
 	};
 
-	bridge_channel_write_frame(bridge_channel, &frame);
-}
-
-void ast_bridge_channel_write_control_data(struct ast_bridge_channel *bridge_channel, enum ast_control_frame_type control, const void *data, size_t datalen)
+	return bridge_channel_write_frame(bridge_channel, &frame);
+}
+
+int ast_bridge_channel_write_control_data(struct ast_bridge_channel *bridge_channel, enum ast_control_frame_type control, const void *data, size_t datalen)
 {
 	struct ast_frame frame = {
 		.frametype = AST_FRAME_CONTROL,
@@ -794,10 +800,10 @@
 		.data.ptr = (void *) data,
 	};
 
-	bridge_channel_write_frame(bridge_channel, &frame);
-}
-
-void ast_bridge_channel_write_hold(struct ast_bridge_channel *bridge_channel, const char *moh_class)
+	return bridge_channel_write_frame(bridge_channel, &frame);
+}
+
+int ast_bridge_channel_write_hold(struct ast_bridge_channel *bridge_channel, const char *moh_class)
 {
 	RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
 	size_t datalen;
@@ -813,14 +819,14 @@
 	}
 
 	ast_channel_publish_blob(bridge_channel->chan, ast_channel_hold_type(), blob);
-	ast_bridge_channel_write_control_data(bridge_channel, AST_CONTROL_HOLD, moh_class,
-		datalen);
-}
-
-void ast_bridge_channel_write_unhold(struct ast_bridge_channel *bridge_channel)
+	return ast_bridge_channel_write_control_data(bridge_channel, AST_CONTROL_HOLD,
+		moh_class, datalen);
+}
+
+int ast_bridge_channel_write_unhold(struct ast_bridge_channel *bridge_channel)
 {
 	ast_channel_publish_blob(bridge_channel->chan, ast_channel_unhold_type(), NULL);
-	ast_bridge_channel_write_control_data(bridge_channel, AST_CONTROL_UNHOLD, NULL, 0);
+	return ast_bridge_channel_write_control_data(bridge_channel, AST_CONTROL_UNHOLD, NULL, 0);
 }
 
 static int run_app_helper(struct ast_channel *chan, const char *app_name, const char *app_args)
@@ -884,7 +890,7 @@
 		data->moh_offset ? &data->app_name[data->moh_offset] : NULL);
 }
 
-static void payload_helper_app(ast_bridge_channel_post_action_data post_it,
+static int payload_helper_app(ast_bridge_channel_post_action_data post_it,
 	struct ast_bridge_channel *bridge_channel, const char *app_name, const char *app_args, const char *moh_class)
 {
 	struct bridge_run_app *app_data;
@@ -905,18 +911,18 @@
 		strcpy(&app_data->app_name[app_data->moh_offset], moh_class);/* Safe */
 	}
 
-	post_it(bridge_channel, AST_BRIDGE_ACTION_RUN_APP, app_data, len_data);
-}
-
-void ast_bridge_channel_write_app(struct ast_bridge_channel *bridge_channel, const char *app_name, const char *app_args, const char *moh_class)
-{
-	payload_helper_app(ast_bridge_channel_write_action_data,
+	return post_it(bridge_channel, AST_BRIDGE_ACTION_RUN_APP, app_data, len_data);
+}
+
+int ast_bridge_channel_write_app(struct ast_bridge_channel *bridge_channel, const char *app_name, const char *app_args, const char *moh_class)
+{
+	return payload_helper_app(ast_bridge_channel_write_action_data,
 		bridge_channel, app_name, app_args, moh_class);
 }
 
-void ast_bridge_channel_queue_app(struct ast_bridge_channel *bridge_channel, const char *app_name, const char *app_args, const char *moh_class)
-{
-	payload_helper_app(ast_bridge_channel_queue_action_data,
+int ast_bridge_channel_queue_app(struct ast_bridge_channel *bridge_channel, const char *app_name, const char *app_args, const char *moh_class)
+{
+	return payload_helper_app(ast_bridge_channel_queue_action_data,
 		bridge_channel, app_name, app_args, moh_class);
 }
 
@@ -971,7 +977,7 @@
 		payload->moh_offset ? &payload->playfile[payload->moh_offset] : NULL);
 }
 
-static void payload_helper_playfile(ast_bridge_channel_post_action_data post_it,
+static int payload_helper_playfile(ast_bridge_channel_post_action_data post_it,
 	struct ast_bridge_channel *bridge_channel, ast_bridge_custom_play_fn custom_play, const char *playfile, const char *moh_class)
 {
 	struct bridge_playfile *payload;
@@ -988,18 +994,18 @@
 		strcpy(&payload->playfile[payload->moh_offset], moh_class);/* Safe */
 	}
 
-	post_it(bridge_channel, AST_BRIDGE_ACTION_PLAY_FILE, payload, len_payload);
-}
-
-void ast_bridge_channel_write_playfile(struct ast_bridge_channel *bridge_channel, ast_bridge_custom_play_fn custom_play, const char *playfile, const char *moh_class)
-{
-	payload_helper_playfile(ast_bridge_channel_write_action_data,
+	return post_it(bridge_channel, AST_BRIDGE_ACTION_PLAY_FILE, payload, len_payload);
+}
+
+int ast_bridge_channel_write_playfile(struct ast_bridge_channel *bridge_channel, ast_bridge_custom_play_fn custom_play, const char *playfile, const char *moh_class)
+{
+	return payload_helper_playfile(ast_bridge_channel_write_action_data,
 		bridge_channel, custom_play, playfile, moh_class);
 }
 
-void ast_bridge_channel_queue_playfile(struct ast_bridge_channel *bridge_channel, ast_bridge_custom_play_fn custom_play, const char *playfile, const char *moh_class)
-{
-	payload_helper_playfile(ast_bridge_channel_queue_action_data,
+int ast_bridge_channel_queue_playfile(struct ast_bridge_channel *bridge_channel, ast_bridge_custom_play_fn custom_play, const char *playfile, const char *moh_class)
+{
+	return payload_helper_playfile(ast_bridge_channel_queue_action_data,
 		bridge_channel, custom_play, playfile, moh_class);
 }
 
@@ -1029,7 +1035,7 @@
 	data->callback(bridge_channel, data->payload_exists ? data->payload : NULL, data->payload_size);
 }
 
-static void payload_helper_cb(ast_bridge_channel_post_action_data post_it,
+static int payload_helper_cb(ast_bridge_channel_post_action_data post_it,
 	struct ast_bridge_channel *bridge_channel, ast_bridge_custom_callback_fn callback, const void *payload, size_t payload_size)
 {
 	struct bridge_custom_callback *cb_data;
@@ -1038,7 +1044,7 @@
 	/* Sanity check. */
 	if (!callback) {
 		ast_assert(0);
-		return;
+		return -1;
 	}
 
 	/* Fill in custom callback frame data. */
@@ -1050,18 +1056,18 @@
 		memcpy(cb_data->payload, payload, payload_size);/* Safe */
 	}
 
-	post_it(bridge_channel, AST_BRIDGE_ACTION_CALLBACK, cb_data, len_data);
-}
-
-void ast_bridge_channel_write_callback(struct ast_bridge_channel *bridge_channel, ast_bridge_custom_callback_fn callback, const void *payload, size_t payload_size)
-{
-	payload_helper_cb(ast_bridge_channel_write_action_data,
+	return post_it(bridge_channel, AST_BRIDGE_ACTION_CALLBACK, cb_data, len_data);
+}
+
+int ast_bridge_channel_write_callback(struct ast_bridge_channel *bridge_channel, ast_bridge_custom_callback_fn callback, const void *payload, size_t payload_size)
+{
+	return payload_helper_cb(ast_bridge_channel_write_action_data,
 		bridge_channel, callback, payload, payload_size);
 }
 
-void ast_bridge_channel_queue_callback(struct ast_bridge_channel *bridge_channel, ast_bridge_custom_callback_fn callback, const void *payload, size_t payload_size)
-{
-	payload_helper_cb(ast_bridge_channel_queue_action_data,
+int ast_bridge_channel_queue_callback(struct ast_bridge_channel *bridge_channel, ast_bridge_custom_callback_fn callback, const void *payload, size_t payload_size)
+{
+	return payload_helper_cb(ast_bridge_channel_queue_action_data,
 		bridge_channel, callback, payload, payload_size);
 }
 
@@ -1079,7 +1085,7 @@
 		payload->app_data_offset ? &payload->parkee_uuid[payload->app_data_offset] : NULL);
 }
 
-static void payload_helper_park(ast_bridge_channel_post_action_data post_it,
+static int payload_helper_park(ast_bridge_channel_post_action_data post_it,
 	struct ast_bridge_channel *bridge_channel,
 	const char *parkee_uuid,
 	const char *parker_uuid,
@@ -1100,12 +1106,12 @@
 		strcpy(&payload->parkee_uuid[payload->app_data_offset], app_data);
 	}
 
-	post_it(bridge_channel, AST_BRIDGE_ACTION_PARK, payload, len_payload);
-}
-
-void ast_bridge_channel_write_park(struct ast_bridge_channel *bridge_channel, const char *parkee_uuid, const char *parker_uuid, const char *app_data)
-{
-	payload_helper_park(ast_bridge_channel_write_action_data,
+	return post_it(bridge_channel, AST_BRIDGE_ACTION_PARK, payload, len_payload);
+}
+
+int ast_bridge_channel_write_park(struct ast_bridge_channel *bridge_channel, const char *parkee_uuid, const char *parker_uuid, const char *app_data)
+{
+	return payload_helper_park(ast_bridge_channel_write_action_data,
 		bridge_channel, parkee_uuid, parker_uuid, app_data);
 }
 
@@ -2349,9 +2355,9 @@
 	ast_heap_unlock(bridge_channel->features->interval_hooks);
 }
 
-static void bridge_channel_write_dtmf_stream(struct ast_bridge_channel *bridge_channel, const char *dtmf)
-{
-	ast_bridge_channel_write_action_data(bridge_channel,
+static int bridge_channel_write_dtmf_stream(struct ast_bridge_channel *bridge_channel, const char *dtmf)
+{
+	return ast_bridge_channel_write_action_data(bridge_channel,
 		AST_BRIDGE_ACTION_DTMF_STREAM, dtmf, strlen(dtmf) + 1);
 }
 
@@ -4493,6 +4499,21 @@
 		return 0;
 	}
 
+/*
+ * BUGBUG Need to take into account frame hooks on the unreal/local channels optimization.
+ *
+ * Frame hooks on the unreal/local channels may inhibit optimization here if they cannot
+ * be moved to an appropriate peer channel.
+ *
+ * caller -- Bridge -- L;1 -- L;2 -- Bridge -- agent
+ * Any frame hooks on L;1 need to be moved to agent channel.
+ * Any frame hooks on L;2 need to be moved to caller channel.
+ *
+ * Moving the frame hooks may cause the hooks to miss a frame if
+ * the destination channel has already read a frame but cannot
+ * write it into the bridge yet because optimization has the
+ * bridge locked.
+ */
 	other = ast_bridge_channel_peer(src_bridge_channel);
 	if (other && other->state == AST_BRIDGE_CHANNEL_STATE_WAIT) {
 		ast_debug(1, "Move-swap optimizing %s <-- %s.\n",
@@ -4596,6 +4617,7 @@
 		return 0;
 	}
 
+/* BUGBUG Frame hooks on the unreal/local channels need to inhibit optimization here. */
 	ast_debug(1, "Merge optimizing %s -- %s out.\n",
 		ast_channel_name(chan_bridge_channel->chan),
 		ast_channel_name(peer_bridge_channel->chan));
@@ -4893,6 +4915,15 @@
 
 	/* Once done we put it in the container. */
 	res = ao2_link(features->dtmf_hooks, hook) ? 0 : -1;
+	if (res) {
+		/*
+		 * Could not link the hook into the container.
+		 *
+		 * Remove the hook_pvt destructor call from the hook since we
+		 * are returning failure to install the hook.
+		 */
+		hook->destructor = NULL;
+	}
 	ao2_ref(hook, -1);
 
 	return res;
@@ -4916,6 +4947,15 @@
 
 	/* Once done we put it in the container. */
 	res = ao2_link(features->hangup_hooks, hook) ? 0 : -1;
+	if (res) {
+		/*
+		 * Could not link the hook into the container.
+		 *
+		 * Remove the hook_pvt destructor call from the hook since we
+		 * are returning failure to install the hook.
+		 */
+		hook->destructor = NULL;
+	}
 	ao2_ref(hook, -1);
 
 	return res;
@@ -4939,6 +4979,15 @@
 
 	/* Once done we put it in the container. */
 	res = ao2_link(features->join_hooks, hook) ? 0 : -1;
+	if (res) {
+		/*
+		 * Could not link the hook into the container.
+		 *
+		 * Remove the hook_pvt destructor call from the hook since we
+		 * are returning failure to install the hook.
+		 */
+		hook->destructor = NULL;
+	}
 	ao2_ref(hook, -1);
 
 	return res;
@@ -4962,6 +5011,15 @@
 
 	/* Once done we put it in the container. */
 	res = ao2_link(features->leave_hooks, hook) ? 0 : -1;
+	if (res) {
+		/*
+		 * Could not link the hook into the container.
+		 *
+		 * Remove the hook_pvt destructor call from the hook since we
+		 * are returning failure to install the hook.
+		 */
+		hook->destructor = NULL;
+	}
 	ao2_ref(hook, -1);
 
 	return res;
@@ -5013,11 +5071,17 @@
 		hook, hook->parms.timer.interval, features);
 	ast_heap_wrlock(features->interval_hooks);
 	res = ast_heap_push(features->interval_hooks, hook);
+	ast_heap_unlock(features->interval_hooks);
 	if (res) {
-		/* Could not push the hook onto the heap. */
+		/*
+		 * Could not push the hook into the heap
+		 *
+		 * Remove the hook_pvt destructor call from the hook since we
+		 * are returning failure to install the hook.
+		 */
+		hook->destructor = NULL;
 		ao2_ref(hook, -1);
 	}
-	ast_heap_unlock(features->interval_hooks);
 
 	return res ? -1 : 0;
 }
@@ -5791,8 +5855,9 @@
  * \param exten The destination extension for the transferee
  * \param context The destination context for the transferee
  * \param hook Frame hook to attach to transferee
- * \retval 0 Successfully queued the action
- * \retval non-zero Failed to queue the action
+ *
+ * \retval 0 on success.
+ * \retval -1 on error.
  */
 static int bridge_channel_queue_blind_transfer(struct ast_channel *transferee,
 		const char *exten, const char *context,
@@ -5816,11 +5881,8 @@
 	ast_copy_string(blind_data.exten, exten, sizeof(blind_data.exten));
 	ast_copy_string(blind_data.context, context, sizeof(blind_data.context));
 
-/* BUGBUG Why doesn't this function return success/failure? */
-	ast_bridge_channel_queue_action_data(transferee_bridge_channel,
-			AST_BRIDGE_ACTION_BLIND_TRANSFER, &blind_data, sizeof(blind_data));
-
-	return 0;
+	return ast_bridge_channel_queue_action_data(transferee_bridge_channel,
+		AST_BRIDGE_ACTION_BLIND_TRANSFER, &blind_data, sizeof(blind_data));
 }
 
 static int bridge_channel_queue_attended_transfer(struct ast_channel *transferee,
@@ -5840,11 +5902,9 @@
 	ast_copy_string(unbridged_chan_name, ast_channel_name(unbridged_chan),
 		sizeof(unbridged_chan_name));
 
-	ast_bridge_channel_queue_action_data(transferee_bridge_channel,
+	return ast_bridge_channel_queue_action_data(transferee_bridge_channel,
 		AST_BRIDGE_ACTION_ATTENDED_TRANSFER, unbridged_chan_name,
 		sizeof(unbridged_chan_name));
-
-	return 0;
 }
 
 enum try_parking_result {

Modified: team/dlee/ari-event-remodel2/main/features.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/main/features.c?view=diff&rev=392488&r1=392487&r2=392488
==============================================================================
--- team/dlee/ari-event-remodel2/main/features.c (original)
+++ team/dlee/ari-event-remodel2/main/features.c Fri Jun 21 15:48:22 2013
@@ -3308,10 +3308,11 @@
 		run_data->moh_offset ? &run_data->app_name[run_data->moh_offset] : NULL);
 }
 

[... 299 lines stripped ...]



More information about the asterisk-commits mailing list