[asterisk-commits] mmichelson: branch mmichelson/transfer r386463 - in /team/mmichelson/transfer...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Apr 24 16:58:02 CDT 2013
Author: mmichelson
Date: Wed Apr 24 16:57:58 2013
New Revision: 386463
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=386463
Log:
Make use of the framehook passed into ast_bridge_blind_transfer()
Whether transferring the entire bridge or a single channel, the framehook
is applied to the outbound channel that is entering the dialplan. This
way, if the caller of ast_bridge_blind_transer() cares about the progress
of that call, they can track it via the framehook.
I also fixed an incorrect piece of documentation in the framehook API.
"positive" and "non-negative" are not the same thing.
Modified:
team/mmichelson/transfer/include/asterisk/bridging.h
team/mmichelson/transfer/include/asterisk/framehook.h
team/mmichelson/transfer/main/bridging.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=386463&r1=386462&r2=386463
==============================================================================
--- team/mmichelson/transfer/include/asterisk/bridging.h (original)
+++ team/mmichelson/transfer/include/asterisk/bridging.h Wed Apr 24 16:57:58 2013
@@ -1239,7 +1239,7 @@
* \return The success or failure result of the blind transfer
*/
enum ast_transfer_result ast_bridge_blind_transfer(struct ast_channel *transferer,
- const char *exten, const char *context, struct ast_framehook *hook);
+ const char *exten, const char *context, struct ast_framehook_interface *hook);
/*!
* \brief Attended transfer
Modified: team/mmichelson/transfer/include/asterisk/framehook.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/transfer/include/asterisk/framehook.h?view=diff&rev=386463&r1=386462&r2=386463
==============================================================================
--- team/mmichelson/transfer/include/asterisk/framehook.h (original)
+++ team/mmichelson/transfer/include/asterisk/framehook.h Wed Apr 24 16:57:58 2013
@@ -228,7 +228,7 @@
* provide it during the event and destruction callbacks. It is entirely up to the
* application using this API to manage the memory associated with the data pointer.
*
- * \retval On success, positive id representing this hook on the channel
+ * \retval On success, non-negative id representing this hook on the channel
* \retval On failure, -1
*/
int ast_framehook_attach(struct ast_channel *chan, struct ast_framehook_interface *i);
Modified: team/mmichelson/transfer/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/transfer/main/bridging.c?view=diff&rev=386463&r1=386462&r2=386463
==============================================================================
--- team/mmichelson/transfer/main/bridging.c (original)
+++ team/mmichelson/transfer/main/bridging.c Wed Apr 24 16:57:58 2013
@@ -4286,10 +4286,12 @@
* \param bridge The bridge where the transfer is being performed
* \param exten The destination extension for the blind transfer
* \param context The destination context for the blind transfer
+ * \param hook Framehook to attach to local channel
* \return The success or failure of the operation
*/
static enum ast_transfer_result blind_transfer_bridge(struct ast_channel *transferer,
- struct ast_bridge *bridge, const char *exten, const char *context)
+ struct ast_bridge *bridge, const char *exten, const char *context,
+ struct ast_framehook_interface *hook)
{
struct ast_channel *local;
char chan_name[AST_MAX_EXTENSION + AST_MAX_CONTEXT + 2];
@@ -4298,6 +4300,9 @@
snprintf(chan_name, sizeof(chan_name), "%s@%s", exten, context);
local = ast_request("Local", slin_cap, transferer, chan_name, &cause);
if (!local) {
+ return AST_BRIDGE_TRANSFER_FAIL;
+ }
+ if (hook && ast_framehook_attach(local, hook) < 0) {
return AST_BRIDGE_TRANSFER_FAIL;
}
if (ast_call(local, chan_name, 0)) {
@@ -4354,19 +4359,28 @@
* \param transferee The channel to have the action queued on
* \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
*/
static int queue_blind_transfer_bridge_action(struct ast_channel *transferee,
- const char *exten, const char *context)
+ const char *exten, const char *context, struct ast_framehook_interface *hook)
{
RAII_VAR(struct ast_bridge_channel *, transferee_bridge_channel, NULL, ao2_cleanup);
struct blind_transfer_data blind_data;
- ast_channel_lock(transferee);
- transferee_bridge_channel = ast_channel_internal_bridge_channel(transferee);
- ao2_ref(transferee_bridge_channel, +1);
- ast_channel_unlock(transferee);
+ {
+ 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);
+
+ if (hook && ast_framehook_attach(transferee, hook) < 0) {
+ return -1;
+ }
+ }
ast_copy_string(blind_data.exten, exten, sizeof(blind_data.exten));
ast_copy_string(blind_data.context, context, sizeof(blind_data.context));
@@ -4421,7 +4435,7 @@
}
enum ast_transfer_result ast_bridge_blind_transfer(struct ast_channel *transferer,
- const char *exten, const char *context, struct ast_framehook *hook)
+ const char *exten, const char *context, struct ast_framehook_interface *hook)
{
RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
RAII_VAR(struct ao2_container *, channels, NULL, ao2_cleanup);
@@ -4471,7 +4485,7 @@
}
if (do_bridge_transfer) {
- return blind_transfer_bridge(transferer, bridge, exten, context);
+ return blind_transfer_bridge(transferer, bridge, exten, context, hook);
}
/* Reaching this portion means that we're dealing with a two-party bridge */
@@ -4481,7 +4495,7 @@
return AST_BRIDGE_TRANSFER_FAIL;
}
- if (queue_blind_transfer_bridge_action(transferee, exten, context)) {
+ if (queue_blind_transfer_bridge_action(transferee, exten, context, hook)) {
return AST_BRIDGE_TRANSFER_FAIL;
}
More information about the asterisk-commits
mailing list