[svn-commits] mmichelson: branch mmichelson/transfer r387542 - in /team/mmichelson/transfer...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu May 2 17:56:17 CDT 2013


Author: mmichelson
Date: Thu May  2 17:56:15 2013
New Revision: 387542

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=387542
Log:
Address latest review feedback.

I also added a clarification about when the callback
for blind transfers would be called.


Modified:
    team/mmichelson/transfer/include/asterisk/bridging.h
    team/mmichelson/transfer/include/asterisk/channel.h
    team/mmichelson/transfer/main/bridging.c
    team/mmichelson/transfer/main/channel.c

Modified: team/mmichelson/transfer/include/asterisk/bridging.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/transfer/include/asterisk/bridging.h?view=diff&rev=387542&r1=387541&r2=387542
==============================================================================
--- team/mmichelson/transfer/include/asterisk/bridging.h (original)
+++ team/mmichelson/transfer/include/asterisk/bridging.h Thu May  2 17:56:15 2013
@@ -1273,6 +1273,8 @@
     AST_BRIDGE_TRANSFER_FAIL,
 };
 
+typedef void (*transfer_channel_cb)(struct ast_channel *chan, void *user_data);
+
 /*!
  * \brief Blind transfer target to the extension and context provided
  *
@@ -1283,6 +1285,8 @@
  * Callers may also provide a callback to be called on the channel that will
  * be running dialplan. The user data passed into ast_bridge_transfer_blind
  * will be given as the argument to the callback to be interpreted as desired.
+ * This callback is guaranteed to be called in the same thread as
+ * ast_bridge_transfer_blind() and before ast_bridge_transfer_blind() returns.
  *
  * \note Do not call this function with the transferer or its tech_pvt locked.
  *
@@ -1296,8 +1300,7 @@
  */
 enum ast_transfer_result ast_bridge_transfer_blind(struct ast_channel *transferer,
 		const char *exten, const char *context,
-		void (*new_channel_cb)(struct ast_channel *chan, void *user_data),
-		void *user_data);
+		transfer_channel_cb new_channel_cb, void *user_data);
 
 /*!
  * \brief Attended transfer

Modified: team/mmichelson/transfer/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/transfer/include/asterisk/channel.h?view=diff&rev=387542&r1=387541&r2=387542
==============================================================================
--- team/mmichelson/transfer/include/asterisk/channel.h (original)
+++ team/mmichelson/transfer/include/asterisk/channel.h Thu May  2 17:56:15 2013
@@ -4183,4 +4183,22 @@
  */
 struct ast_channel *ast_channel_bridge_peer(struct ast_channel *chan);
 
+/*!
+ * \brief Get a reference to the channel's bridge pointer.
+ * \since 12.0.0
+ *
+ * \param chan The channel whose bridge channel is desired
+ *
+ * \note This increases the reference count of the bridge_channel.
+ * Use ao2_ref() or ao2_cleanup() to decrement the refcount when
+ * you are finished with it.
+ *
+ * \note It is expected that the channel is locked prior to
+ * placing this call.
+ *
+ * \retval NULL The channel has no bridge_channel
+ * \retval non-NULL A reference to the bridge_channel
+ */
+struct ast_bridge_channel *ast_channel_get_bridge_channel(struct ast_channel *chan);
+
 #endif /* _ASTERISK_CHANNEL_H */

Modified: team/mmichelson/transfer/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/transfer/main/bridging.c?view=diff&rev=387542&r1=387541&r2=387542
==============================================================================
--- team/mmichelson/transfer/main/bridging.c (original)
+++ team/mmichelson/transfer/main/bridging.c Thu May  2 17:56:15 2013
@@ -4785,8 +4785,7 @@
  */
 static enum ast_transfer_result blind_transfer_bridge(struct ast_channel *transferer,
 		struct ast_bridge *bridge, const char *exten, const char *context,
-		void (*new_channel_cb)(struct ast_channel *chan, void *user_data),
-		void *user_data)
+		transfer_channel_cb new_channel_cb, void *user_data)
 {
 	struct ast_channel *local;
 	char chan_name[AST_MAX_EXTENSION + AST_MAX_CONTEXT + 2];
@@ -4863,19 +4862,17 @@
  */
 static int bridge_channel_queue_blind_transfer(struct ast_channel *transferee,
 		const char *exten, const char *context,
-		void (*new_channel_cb)(struct ast_channel *chan, void *user_data),
-		void *user_data)
+		transfer_channel_cb new_channel_cb, void *user_data)
 {
 	RAII_VAR(struct ast_bridge_channel *, transferee_bridge_channel, NULL, ao2_cleanup);
 	struct blind_transfer_data blind_data;
 
-	{
-		SCOPED_LOCK(lock, transferee, ast_channel_lock, ast_channel_unlock);
-		transferee_bridge_channel = ast_channel_internal_bridge_channel(transferee);
-		if (!transferee_bridge_channel) {
-			return -1;
-		}
-		ao2_ref(transferee_bridge_channel, +1);
+	ast_channel_lock(transferee);
+	transferee_bridge_channel = ast_channel_get_bridge_channel(transferee);
+	ast_channel_unlock(transferee);
+
+	if (!transferee_bridge_channel) {
+		return -1;
 	}
 
 	if (new_channel_cb) {
@@ -4910,13 +4907,12 @@
 	RAII_VAR(struct ast_bridge_channel *, transferer_bridge_channel, NULL, ao2_cleanup);
 	struct ast_exten *parking_exten;
 
-	{
-		SCOPED_LOCK(lock, transferer, ast_channel_lock, ast_channel_unlock);
-		transfer_bridge_channel = ast_channel_internal_bridge_channel(transferer);
-		if (!transferer) {
-			return PARKING_FAILURE;
-		}
-		ao2_ref(transferer_bridge_channel, +1);
+	ast_channel_lock(transferer);
+	transfer_bridge_channel = ast_channel_get_bridge_channel(transferer);
+	ast_channel_unlock(transferer);
+
+	if (!transfer_bridge_channel) {
+		return PARKING_FAILURE;
 	}
 
 	parking_exten = ast_get_parking_exten(exten, NULL, context);
@@ -4968,8 +4964,7 @@
 
 enum ast_transfer_result ast_bridge_transfer_blind(struct ast_channel *transferer,
 		const char *exten, const char *context,
-		void (*new_channel_cb)(struct ast_channel *chan, void *user_data),
-		void *user_data)
+		transfer_channel_cb new_channel_cb, void *user_data)
 {
 	RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
 	RAII_VAR(struct ao2_container *, channels, NULL, ao2_cleanup);

Modified: team/mmichelson/transfer/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/transfer/main/channel.c?view=diff&rev=387542&r1=387541&r2=387542
==============================================================================
--- team/mmichelson/transfer/main/channel.c (original)
+++ team/mmichelson/transfer/main/channel.c Thu May  2 17:56:15 2013
@@ -11297,3 +11297,14 @@
 	ao2_ref(bridge, -1);
 	return peer;
 }
+
+struct ast_bridge_channel *ast_channel_get_bridge_channel(struct ast_channel *chan)
+{
+	struct ast_bridge_channel *bridge_channel;
+
+	bridge_channel = ast_channel_internal_bridge_channel(chan);
+	if (bridge_channel) {
+		ao2_ref(bridge_channel, +1);
+	}
+	return bridge_channel;
+}




More information about the svn-commits mailing list