[asterisk-commits] mjordan: branch 12 r414122 - in /branches/12: bridges/ include/asterisk/ main...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sun May 18 15:29:28 CDT 2014
Author: mjordan
Date: Sun May 18 15:29:12 2014
New Revision: 414122
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=414122
Log:
bridge_native_rtp/bridge_channel: Fix direct media issues due to frame hook
This patch fixes issues with direct media bridges that occur after a blind
transfer. These issues were caught by the (currently failing)
pjsip/transfers/blind_transfer/caller_direct_media test.
The test currently fails primarily for two reasons:
(1) When Bob and Charlie (the transfer target and the transfer destination)
enter a bridge together, the framehook remains on the transfer target
channel until both channels are in the bridge. As it consumes voice frames,
the initial bridge type is a simple bridge. The framehook is removed when
both channels are in the bridge; however, this does not currently cause the
bridging framework to re-evaluate the bridge. This patch adds a
AST_SOFTHANGUP_UNBRIDGE poke to the transfer target channel when a
framehook is removed so the bridge can re-evaluate itself.
(2) When a channel leaves a native RTP bridge, it may be leaving due to being
hung up. Sending a re-INVITE to a channel that is about to be hung up is
not nice - in fact, there's a good chance we'll send the BYE request before
the channel has had a chance to send back a 200 OK. To be somewhat nicer,
this patch adds a function to channel.h that allows the bridging framework
to query for exactly why a channel is leaving a bridge via the channel's
soft hangup flags. This allows it to only send the re-INVITE if there's a
chance the channel will survive the native bridging experience.
Review: https://reviewboard.asterisk.org/r/3535/
Modified:
branches/12/bridges/bridge_native_rtp.c
branches/12/include/asterisk/channel.h
branches/12/main/bridge_channel.c
branches/12/main/channel.c
branches/12/main/framehook.c
branches/12/res/res_pjsip_session.c
Modified: branches/12/bridges/bridge_native_rtp.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/bridges/bridge_native_rtp.c?view=diff&rev=414122&r1=414121&r2=414122
==============================================================================
--- branches/12/bridges/bridge_native_rtp.c (original)
+++ branches/12/bridges/bridge_native_rtp.c Sun May 18 15:29:12 2014
@@ -230,8 +230,10 @@
break;
case AST_RTP_GLUE_RESULT_REMOTE:
if (!target) {
- glue0->update_peer(c0->chan, NULL, NULL, NULL, NULL, 0);
- if (glue1) {
+ if (ast_channel_is_leaving_bridge(c0->chan)) {
+ glue0->update_peer(c0->chan, NULL, NULL, NULL, NULL, 0);
+ }
+ if (glue1 && ast_channel_is_leaving_bridge(c1->chan)) {
glue1->update_peer(c1->chan, NULL, NULL, NULL, NULL, 0);
}
} else {
@@ -485,8 +487,9 @@
}
/* Direct RTP may have occurred, tear it down */
- glue->update_peer(bridge_channel->chan, NULL, NULL, NULL, NULL, 0);
-
+ if (ast_channel_is_leaving_bridge(bridge_channel->chan)) {
+ glue->update_peer(bridge_channel->chan, NULL, NULL, NULL, NULL, 0);
+ }
native_rtp_bridge_stop(bridge, NULL);
}
Modified: branches/12/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/branches/12/include/asterisk/channel.h?view=diff&rev=414122&r1=414121&r2=414122
==============================================================================
--- branches/12/include/asterisk/channel.h (original)
+++ branches/12/include/asterisk/channel.h Sun May 18 15:29:12 2014
@@ -4284,6 +4284,22 @@
int ast_channel_is_bridged(const struct ast_channel *chan);
/*!
+ * \brief Determine if a channel is leaving a bridge, but \em not hung up
+ * \since 12.3.0
+ *
+ * \param chan The channel to test
+ *
+ * \note If a channel is hung up, it is implicitly leaving any bridge it
+ * may be in. This function is used to test if a channel is leaving a bridge
+ * but may survive the experience, if it has a place to go to (dialplan or
+ * otherwise)
+ *
+ * \retval 0 The channel is not leaving the bridge or is hung up
+ * \retval non-zero The channel is leaving the bridge
+ */
+int ast_channel_is_leaving_bridge(struct ast_channel *chan);
+
+/*!
* \brief Get the channel's bridge peer only if the bridge is two-party.
* \since 12.0.0
*
Modified: branches/12/main/bridge_channel.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/bridge_channel.c?view=diff&rev=414122&r1=414121&r2=414122
==============================================================================
--- branches/12/main/bridge_channel.c (original)
+++ branches/12/main/bridge_channel.c Sun May 18 15:29:12 2014
@@ -1756,9 +1756,9 @@
/* If we are not going to be hung up after leaving a bridge, and we were an
* outgoing channel, clear the outgoing flag.
*/
- if (ast_test_flag(ast_channel_flags(bridge_channel->chan), AST_FLAG_OUTGOING)
- && (ast_channel_softhangup_internal_flag(bridge_channel->chan) & (AST_SOFTHANGUP_ASYNCGOTO | AST_SOFTHANGUP_UNBRIDGE)
- || bridge_channel->state == BRIDGE_CHANNEL_STATE_WAIT)) {
+ if (ast_test_flag(ast_channel_flags(bridge_channel->chan), AST_FLAG_OUTGOING) &&
+ (ast_channel_is_leaving_bridge(bridge_channel->chan) ||
+ bridge_channel->state == BRIDGE_CHANNEL_STATE_WAIT)) {
ast_debug(2, "Channel %s will survive this bridge; clearing outgoing (dialed) flag\n", ast_channel_name(bridge_channel->chan));
ast_clear_flag(ast_channel_flags(bridge_channel->chan), AST_FLAG_OUTGOING);
}
Modified: branches/12/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/channel.c?view=diff&rev=414122&r1=414121&r2=414122
==============================================================================
--- branches/12/main/channel.c (original)
+++ branches/12/main/channel.c Sun May 18 15:29:12 2014
@@ -10151,6 +10151,18 @@
return ast_channel_internal_bridge(chan) != NULL;
}
+int ast_channel_is_leaving_bridge(struct ast_channel *chan)
+{
+ int flags = ast_channel_softhangup_internal_flag(chan);
+
+ /* We test the flags independently here in case they are masked with
+ * actual "hangup" soft-hangup flags
+ */
+ return (flags == AST_SOFTHANGUP_ASYNCGOTO ||
+ flags == AST_SOFTHANGUP_UNBRIDGE ||
+ flags == (AST_SOFTHANGUP_ASYNCGOTO | AST_SOFTHANGUP_UNBRIDGE));
+}
+
struct ast_channel *ast_channel_bridge_peer(struct ast_channel *chan)
{
struct ast_channel *peer;
Modified: branches/12/main/framehook.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/framehook.c?view=diff&rev=414122&r1=414121&r2=414122
==============================================================================
--- branches/12/main/framehook.c (original)
+++ branches/12/main/framehook.c Sun May 18 15:29:12 2014
@@ -189,6 +189,10 @@
}
AST_LIST_TRAVERSE_SAFE_END;
+ if (ast_channel_is_bridged(chan)) {
+ ast_softhangup_nolock(chan, AST_SOFTHANGUP_UNBRIDGE);
+ }
+
return res;
}
Modified: branches/12/res/res_pjsip_session.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/res/res_pjsip_session.c?view=diff&rev=414122&r1=414121&r2=414122
==============================================================================
--- branches/12/res/res_pjsip_session.c (original)
+++ branches/12/res/res_pjsip_session.c Sun May 18 15:29:12 2014
@@ -780,6 +780,9 @@
return -1;
}
}
+ ast_debug(3, "Sending session refresh SDP via %s to %s\n",
+ method == AST_SIP_SESSION_REFRESH_METHOD_INVITE ? "re-INVITE" : "UPDATE",
+ ast_sorcery_object_get_id(session->endpoint));
ast_sip_session_send_request_with_cb(session, tdata, on_response);
return 0;
}
More information about the asterisk-commits
mailing list