[asterisk-commits] mmichelson: branch mmichelson/more_transfer r388957 - /team/mmichelson/more_t...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri May 17 11:07:55 CDT 2013
Author: mmichelson
Date: Fri May 17 11:07:54 2013
New Revision: 388957
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=388957
Log:
Address latest comments from review.
Modified:
team/mmichelson/more_transfer/main/bridging.c
Modified: team/mmichelson/more_transfer/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/more_transfer/main/bridging.c?view=diff&rev=388957&r1=388956&r2=388957
==============================================================================
--- team/mmichelson/more_transfer/main/bridging.c (original)
+++ team/mmichelson/more_transfer/main/bridging.c Fri May 17 11:07:54 2013
@@ -4902,23 +4902,33 @@
static enum ast_transfer_result attended_transfer_bridge(struct ast_channel *chan1,
struct ast_channel *chan2, struct ast_bridge *bridge1, struct ast_bridge *bridge2)
{
+ static const char *dest = "_attended at transfer/m";
struct ast_channel *local_chan;
int cause;
+ int res;
local_chan = ast_request("Local", ast_channel_nativeformats(chan1), chan1,
- "BridgeAttendedTransfer", &cause);
+ dest, &cause);
if (!local_chan) {
return AST_BRIDGE_TRANSFER_FAIL;
}
if (bridge2) {
- ast_local_setup_bridge(local_chan, bridge2, chan2, NULL);
+ res = ast_local_setup_bridge(local_chan, bridge2, chan2, NULL);
} else {
- ast_local_setup_masquerade(local_chan, chan2);
- }
-
- ast_call(local_chan, "BridgeAttendedTransfer", 0);
+ res = ast_local_setup_masquerade(local_chan, chan2);
+ }
+
+ if (res) {
+ ast_hangup(local_chan);
+ return AST_BRIDGE_TRANSFER_FAIL;
+ }
+
+ if (ast_call(local_chan, dest, 0)) {
+ ast_hangup(local_chan);
+ return AST_BRIDGE_TRANSFER_FAIL;
+ }
if (ast_bridge_impart(bridge1, local_chan, chan1, NULL, 1)) {
ast_hangup(local_chan);
@@ -5175,6 +5185,21 @@
return AST_BRIDGE_TRANSFER_SUCCESS;
}
+static struct ast_bridge *acquire_bridge(struct ast_channel *chan)
+{
+ struct ast_bridge *bridge;
+
+ ast_channel_lock(chan);
+ bridge = ast_channel_get_bridge(chan);
+ ast_channel_unlock(chan);
+ if (ast_test_flag(&bridge->feature_flags, AST_BRIDGE_FLAG_MASQUERADE_ONLY)) {
+ ao2_ref(bridge, -1);
+ bridge = NULL;
+ }
+
+ return bridge;
+}
+
enum ast_transfer_result ast_bridge_transfer_attended(struct ast_channel *to_transferee,
struct ast_channel *to_transfer_target)
{
@@ -5188,13 +5213,8 @@
int transfer_prohibited;
int do_bridge_transfer;
- ast_channel_lock(to_transferee);
- to_transferee_bridge = ast_channel_get_bridge(to_transferee);
- ast_channel_unlock(to_transferee);
-
- ast_channel_lock(to_transfer_target);
- to_target_bridge = ast_channel_get_bridge(to_transfer_target);
- ast_channel_unlock(to_transfer_target);
+ to_transferee_bridge = acquire_bridge(to_transferee);
+ to_target_bridge = acquire_bridge(to_transfer_target);
/* They can't both be unbridged, you silly goose! */
if (!to_transferee_bridge && !to_target_bridge) {
More information about the asterisk-commits
mailing list