bridge : Fix one-way direct-media when early bridging with native_rtp
authorJean Aunis <jean.aunis@prescom.fr>
Thu, 7 Sep 2017 09:41:09 +0000 (11:41 +0200)
committerRichard Mudgett <rmudgett@digium.com>
Wed, 20 Sep 2017 15:19:37 +0000 (10:19 -0500)
When two channels were early bridged in a native_rtp bridge, the RTP description
on one side was not updated when the other side answered.
This patch forbids non-answered channels to enter a native_rtp bridge, and
triggers a bridge reconfiguration when an ANSWER frame is received.

ASTERISK-27257

Change-Id: If1aaee1b4ed9658a1aa91ab715ee0a6413b878df

bridges/bridge_native_rtp.c
include/asterisk/bridge_technology.h
main/bridge_channel.c

index a46b420..edbfe58 100644 (file)
@@ -598,7 +598,8 @@ static int native_rtp_framehook_consume(void *data, enum ast_frame_type type)
  */
 static int native_rtp_bridge_capable(struct ast_channel *chan)
 {
-       return !ast_channel_has_hook_requiring_audio(chan);
+       return !ast_channel_has_hook_requiring_audio(chan)
+                       && ast_channel_state(chan) == AST_STATE_UP;
 }
 
 /*!
index def7b19..eaea28d 100644 (file)
@@ -108,11 +108,13 @@ struct ast_bridge_technology {
         *
         * \note On entry, bridge is already locked.
         *
-        * \note The bridge technology must tollerate a failed to join channel
+        * \note The bridge technology must tolerate a failed to join channel
         * until it can be kicked from the bridge.
         *
         * \note A channel may be in a suspended state already when joining a bridge
         * technology. The technology must handle this case.
+        *
+        * \note A channel may not be answered when joining a bridge technology.
         */
        int (*join)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel);
        /*!
index 66292bf..89e5571 100644 (file)
@@ -2313,6 +2313,10 @@ static void bridge_channel_handle_control(struct ast_bridge_channel *bridge_chan
        case AST_CONTROL_ANSWER:
                if (ast_channel_state(chan) != AST_STATE_UP) {
                        ast_answer(chan);
+                       ast_bridge_channel_lock_bridge(bridge_channel);
+                       bridge_channel->bridge->reconfigured = 1;
+                       bridge_reconfigured(bridge_channel->bridge, 0);
+                       ast_bridge_unlock(bridge_channel->bridge);
                } else {
                        ast_indicate(chan, -1);
                }