[asterisk-commits] file: branch file/bridge_native r388199 - /team/file/bridge_native/bridges/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu May 9 10:53:12 CDT 2013


Author: file
Date: Thu May  9 10:53:10 2013
New Revision: 388199

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=388199
Log:
Incorporate review feedback.

Modified:
    team/file/bridge_native/bridges/bridge_native_rtp.c

Modified: team/file/bridge_native/bridges/bridge_native_rtp.c
URL: http://svnview.digium.com/svn/asterisk/team/file/bridge_native/bridges/bridge_native_rtp.c?view=diff&rev=388199&r1=388198&r2=388199
==============================================================================
--- team/file/bridge_native/bridges/bridge_native_rtp.c (original)
+++ team/file/bridge_native/bridges/bridge_native_rtp.c Thu May  9 10:53:10 2013
@@ -60,16 +60,23 @@
 /*! \brief Frame hook that is called to intercept hold/unhold */
 static struct ast_frame *native_rtp_framehook(struct ast_channel *chan, struct ast_frame *f, enum ast_framehook_event event, void *data)
 {
+	RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
+
 	if (!f || (event != AST_FRAMEHOOK_EVENT_WRITE)) {
 		return f;
 	}
 
+	ast_channel_lock(chan);
+	bridge = ast_channel_get_bridge(chan);
+	ast_channel_unlock(chan);
+
 	/* It's safe for NULL to be passed to both of these, bridge_channel isn't used at all */
-	if (f->subclass.integer == AST_CONTROL_HOLD) {
-		native_rtp_bridge_leave(ast_channel_internal_bridge(chan), NULL);
-	} else if (((f->subclass.integer == AST_CONTROL_UNHOLD) || (f->subclass.integer == AST_CONTROL_UPDATE_RTP_PEER)) &&
-		ast_channel_is_bridged(chan)) {
-		native_rtp_bridge_join(ast_channel_internal_bridge(chan), NULL);
+	if (bridge) {
+		if (f->subclass.integer == AST_CONTROL_HOLD) {
+			native_rtp_bridge_leave(ast_channel_internal_bridge(chan), NULL);
+		} else if ((f->subclass.integer == AST_CONTROL_UNHOLD) || (f->subclass.integer == AST_CONTROL_UPDATE_RTP_PEER)) {
+			native_rtp_bridge_join(ast_channel_internal_bridge(chan), NULL);
+		}
 	}
 
 	return f;
@@ -307,13 +314,8 @@
 		ast_rtp_instance_set_bridged(instance0, instance1);
 		ast_rtp_instance_set_bridged(instance1, instance0);
 	} else {
-		/* Due to direct RTP setup the bridge *must* exist on the channel to allow media to be redirected */
-		ast_channel_internal_bridge_set(c0->chan, bridge);
-		ast_channel_internal_bridge_set(c1->chan, bridge);
 		glue0->update_peer(c0->chan, instance1, vinstance1, tinstance1, cap1, 0);
 		glue1->update_peer(c1->chan, instance0, vinstance0, tinstance0, cap0, 0);
-		ast_channel_internal_bridge_set(c0->chan, NULL);
-		ast_channel_internal_bridge_set(c1->chan, NULL);
 	}
 
 	return 0;




More information about the asterisk-commits mailing list