[asterisk-commits] mmichelson: branch mmichelson/transfer r386372 - in /team/mmichelson/transfer...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Apr 23 14:35:25 CDT 2013
Author: mmichelson
Date: Tue Apr 23 14:35:21 2013
New Revision: 386372
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=386372
Log:
Switch to queuing a blind transfer bridge action on a queue in the two-party scenario.
Right now, the frame is queued but it is unhandled right now by the bridge. This will soon
change. Just you wait.
Modified:
team/mmichelson/transfer/include/asterisk/bridging.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=386372&r1=386371&r2=386372
==============================================================================
--- team/mmichelson/transfer/include/asterisk/bridging.h (original)
+++ team/mmichelson/transfer/include/asterisk/bridging.h Tue Apr 23 14:35:21 2013
@@ -221,6 +221,8 @@
AST_BRIDGE_ACTION_PLAY_FILE,
/*! Bridge channel is to run the indicated application. */
AST_BRIDGE_ACTION_RUN_APP,
+ /*! Bridge channel is to execute a blind transfer. */
+ AST_BRIDGE_ACTION_BLIND_TRANSFER,
/*
* Bridge actions put after this comment must never be put onto
Modified: team/mmichelson/transfer/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/transfer/main/bridging.c?view=diff&rev=386372&r1=386371&r2=386372
==============================================================================
--- team/mmichelson/transfer/main/bridging.c (original)
+++ team/mmichelson/transfer/main/bridging.c Tue Apr 23 14:35:21 2013
@@ -4232,11 +4232,59 @@
return AST_BRIDGE_TRANSFER_SUCCESS;
}
+/* XXX These buffer sizes could use more consideration. Currently
+ * just numbers pulled out of thin air.
+ */
+struct blind_transfer_data {
+ char transferer_name[128];
+ char transferee_name[128];
+ char exten[AST_MAX_EXTENSION];
+ char context[AST_MAX_CONTEXT];
+};
+
+static enum ast_transfer_result queue_blind_transfer_bridge_action(struct ast_bridge *bridge,
+ struct ast_channel *transferer, const char *exten, const char *context)
+{
+ RAII_VAR(struct ast_bridge_channel *, transferer_bridge_channel, NULL, ao2_cleanup);
+ struct blind_transfer_data blind_data;
+ struct ast_channel *transferee;
+
+ /* XXX This method of getting the bridged channel is not
+ * the preferred way of doing it. The problem is that the
+ * preferred way hasn't actually been written yet
+ */
+ ast_channel_lock(transferer);
+ transferer_bridge_channel = ast_channel_internal_bridge_channel(transferer);
+ if (!transferer_bridge_channel) {
+ ast_channel_unlock(transferer);
+ return AST_BRIDGE_TRANSFER_FAIL;
+ }
+ ao2_ref(transferer_bridge_channel, +1);
+ transferee = ast_bridged_channel(transferer);
+ if (!transferee) {
+ ast_channel_unlock(transferer);
+ return AST_BRIDGE_TRANSFER_FAIL;
+ }
+ ast_copy_string(blind_data.transferee_name, ast_channel_name(transferee),
+ sizeof(blind_data.transferee_name));
+ ast_copy_string(blind_data.transferer_name, ast_channel_name(transferer),
+ sizeof(blind_data.transferer_name));
+ ast_channel_unlock(transferer);
+
+ ast_copy_string(blind_data.exten, exten, sizeof(blind_data.exten));
+ ast_copy_string(blind_data.context, context, sizeof(blind_data.context));
+
+ /* XXX Why doesn't this function return success/failure? */
+ ast_bridge_channel_queue_action_data(transferer_bridge_channel,
+ AST_BRIDGE_ACTION_BLIND_TRANSFER, &blind_data, sizeof(blind_data));
+
+ return AST_BRIDGE_TRANSFER_SUCCESS;
+}
+
enum ast_transfer_result ast_bridge_blind_transfer(struct ast_channel *transferer,
const char *exten, const char *context, struct ast_framehook *hook)
{
RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
- struct ast_channel *bridged_channel;
int do_bridge_transfer;
int transfer_prohibited;
@@ -4265,21 +4313,8 @@
return local_channel_swap_transfer(transferer, bridge, exten, context);
}
- ast_channel_lock(transferer);
- bridged_channel = ast_bridged_channel(transferer);
- if (!bridged_channel) {
- ast_channel_unlock(transferer);
- return AST_BRIDGE_TRANSFER_FAIL;
- }
- ast_channel_ref(bridged_channel);
- ast_channel_unlock(transferer);
-
- /* XXX This is temporary. In general reaching across the bridge is a terrible
- * idea. This will be replaced with a blind transfer bridge action once I create it.
- */
- ast_after_bridge_set_goto(bridged_channel, context, exten, 1);
- return ast_bridge_remove(bridge, bridged_channel) == 0 ? AST_BRIDGE_TRANSFER_SUCCESS :
- AST_BRIDGE_TRANSFER_FAIL;
+ return queue_blind_transfer_bridge_action(bridge, transferer, exten, context);
+
}
enum ast_transfer_result ast_bridge_attended_transfer(struct ast_channel *to_transferee,
More information about the asterisk-commits
mailing list