[asterisk-commits] file: branch file/bridge_native r385911 - in /team/file/bridge_native: bridge...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Apr 16 14:17:24 CDT 2013


Author: file
Date: Tue Apr 16 14:17:20 2013
New Revision: 385911

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=385911
Log:
Get local bridging working as well. Next up is some clean up, DTMF, and consolidation of code.

Modified:
    team/file/bridge_native/bridges/bridge_native_rtp.c
    team/file/bridge_native/include/asterisk/rtp_engine.h
    team/file/bridge_native/main/rtp_engine.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=385911&r1=385910&r2=385911
==============================================================================
--- team/file/bridge_native/bridges/bridge_native_rtp.c (original)
+++ team/file/bridge_native/bridges/bridge_native_rtp.c Tue Apr 16 14:17:20 2013
@@ -45,12 +45,6 @@
 #include "asterisk/bridging_technology.h"
 #include "asterisk/frame.h"
 #include "asterisk/rtp_engine.h"
-
-/*! \brief Structure which contains information about native bridged RTP capable channel */
-struct native_rtp_bridge {
-	/*! \brief What type of bridge is in progress */
-	enum ast_rtp_glue_result type;
-};
 
 static int native_rtp_bridge_compatible(struct ast_bridge *bridge)
 {
@@ -159,6 +153,23 @@
 	audio_glue1_res = glue1->get_rtp_info(c1, &instance1);
 	video_glue1_res = glue1->get_vrtp_info ? glue1->get_vrtp_info(c1, &vinstance1) : AST_RTP_GLUE_RESULT_FORBID;
 
+	if (audio_glue0_res == audio_glue1_res && audio_glue1_res == AST_RTP_GLUE_RESULT_REMOTE) {
+		if (glue0->allow_rtp_remote && !(glue0->allow_rtp_remote(c0, instance1))) {
+			/* If the allow_rtp_remote indicates that remote isn't allowed, revert to local bridge */
+			audio_glue0_res = audio_glue1_res = AST_RTP_GLUE_RESULT_LOCAL;
+		} else if (glue1->allow_rtp_remote && !(glue1->allow_rtp_remote(c1, instance0))) {
+			audio_glue0_res = audio_glue1_res = AST_RTP_GLUE_RESULT_LOCAL;
+		}
+	}
+	if (video_glue0_res == video_glue1_res && video_glue1_res == AST_RTP_GLUE_RESULT_REMOTE) {
+		if (glue0->allow_vrtp_remote && !(glue0->allow_vrtp_remote(c0, instance1))) {
+			/* if the allow_vrtp_remote indicates that remote isn't allowed, revert to local bridge */
+			video_glue0_res = video_glue1_res = AST_RTP_GLUE_RESULT_LOCAL;
+		} else if (glue1->allow_vrtp_remote && !(glue1->allow_vrtp_remote(c1, instance0))) {
+			video_glue0_res = video_glue1_res = AST_RTP_GLUE_RESULT_LOCAL;
+		}
+	}
+
 	if (glue0->get_codec) {
 		glue0->get_codec(c0, cap0);
 	}
@@ -166,10 +177,19 @@
 		glue1->get_codec(c1, cap1);
 	}
 
-	glue0->update_peer(c0, instance1, vinstance1, tinstance1, cap1, 0);
-	glue1->update_peer(c1, instance0, vinstance0, tinstance0, cap0, 0);
-
-	ast_log(LOG_NOTICE, "Res = %d %d %d %d\n", audio_glue0_res, audio_glue1_res, video_glue0_res, video_glue1_res);
+	if (audio_glue0_res == AST_RTP_GLUE_RESULT_LOCAL) {
+		if (ast_rtp_instance_get_engine(instance0)->local_bridge) {
+			ast_rtp_instance_get_engine(instance0)->local_bridge(instance0, instance1);
+		}
+		if (ast_rtp_instance_get_engine(instance1)->local_bridge) {
+			ast_rtp_instance_get_engine(instance1)->local_bridge(instance1, instance0);
+		}
+		ast_rtp_instance_set_bridged(instance0, instance1);
+		ast_rtp_instance_set_bridged(instance1, instance0);
+	} else {
+		glue0->update_peer(c0, instance1, vinstance1, tinstance1, cap1, 0);
+		glue1->update_peer(c1, instance0, vinstance0, tinstance0, cap0, 0);
+	}
 
 	return 0;
 }
@@ -185,9 +205,45 @@
 	struct ast_channel *c1 = AST_LIST_LAST(&bridge->channels)->chan;
 	struct ast_rtp_glue *glue0 = ast_rtp_instance_get_glue(ast_channel_tech(c0)->type);
 	struct ast_rtp_glue *glue1 = ast_rtp_instance_get_glue(ast_channel_tech(c1)->type);
-
-	glue0->update_peer(c0, NULL, NULL, NULL, 0, 0);
-	glue1->update_peer(c1, NULL, NULL, NULL, 0, 0);
+	enum ast_rtp_glue_result audio_glue0_res = AST_RTP_GLUE_RESULT_FORBID, video_glue0_res = AST_RTP_GLUE_RESULT_FORBID;
+	enum ast_rtp_glue_result audio_glue1_res = AST_RTP_GLUE_RESULT_FORBID, video_glue1_res = AST_RTP_GLUE_RESULT_FORBID;
+	struct ast_rtp_instance *instance0 = NULL, *instance1 = NULL, *vinstance0 = NULL, *vinstance1 = NULL;
+
+	audio_glue0_res = glue0->get_rtp_info(c0, &instance0);
+	video_glue0_res = glue0->get_vrtp_info ? glue0->get_vrtp_info(c0, &vinstance0) : AST_RTP_GLUE_RESULT_FORBID;
+	audio_glue1_res = glue1->get_rtp_info(c1, &instance1);
+	video_glue1_res = glue1->get_vrtp_info ? glue1->get_vrtp_info(c1, &vinstance1) : AST_RTP_GLUE_RESULT_FORBID;
+
+	if (audio_glue0_res == audio_glue1_res && audio_glue1_res == AST_RTP_GLUE_RESULT_REMOTE) {
+		if (glue0->allow_rtp_remote && !(glue0->allow_rtp_remote(c0, instance1))) {
+			/* If the allow_rtp_remote indicates that remote isn't allowed, revert to local bridge */
+			audio_glue0_res = audio_glue1_res = AST_RTP_GLUE_RESULT_LOCAL;
+		} else if (glue1->allow_rtp_remote && !(glue1->allow_rtp_remote(c1, instance0))) {
+			audio_glue0_res = audio_glue1_res = AST_RTP_GLUE_RESULT_LOCAL;
+		}
+	}
+	if (video_glue0_res == video_glue1_res && video_glue1_res == AST_RTP_GLUE_RESULT_REMOTE) {
+		if (glue0->allow_vrtp_remote && !(glue0->allow_vrtp_remote(c0, instance1))) {
+			/* if the allow_vrtp_remote indicates that remote isn't allowed, revert to local bridge */
+			video_glue0_res = video_glue1_res = AST_RTP_GLUE_RESULT_LOCAL;
+		} else if (glue1->allow_vrtp_remote && !(glue1->allow_vrtp_remote(c1, instance0))) {
+			video_glue0_res = video_glue1_res = AST_RTP_GLUE_RESULT_LOCAL;
+		}
+	}
+
+	if (audio_glue0_res == AST_RTP_GLUE_RESULT_LOCAL) {
+		if (ast_rtp_instance_get_engine(instance0)->local_bridge) {
+			ast_rtp_instance_get_engine(instance0)->local_bridge(instance0, NULL);
+		}
+		if (ast_rtp_instance_get_engine(instance1)->local_bridge) {
+			ast_rtp_instance_get_engine(instance1)->local_bridge(instance1, NULL);
+		}
+		ast_rtp_instance_set_bridged(instance0, instance1);
+		ast_rtp_instance_set_bridged(instance1, instance0);
+	} else {
+		glue0->update_peer(c0, NULL, NULL, NULL, NULL, 0);
+		glue1->update_peer(c1, NULL, NULL, NULL, NULL, 0);
+	}
 }
 
 static int native_rtp_bridge_write(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)

Modified: team/file/bridge_native/include/asterisk/rtp_engine.h
URL: http://svnview.digium.com/svn/asterisk/team/file/bridge_native/include/asterisk/rtp_engine.h?view=diff&rev=385911&r1=385910&r2=385911
==============================================================================
--- team/file/bridge_native/include/asterisk/rtp_engine.h (original)
+++ team/file/bridge_native/include/asterisk/rtp_engine.h Tue Apr 16 14:17:20 2013
@@ -1579,6 +1579,16 @@
 struct ast_rtp_instance *ast_rtp_instance_get_bridged(struct ast_rtp_instance *instance);
 
 /*!
+ * \brief Set the other RTP instance that an instance is bridged to
+ *
+ * \param instance The RTP instance that we want to set the bridged value on
+ * \param bridged The RTP instance they are bridged to
+ *
+ * \since 12
+ */
+void ast_rtp_instance_set_bridged(struct ast_rtp_instance *instance, struct ast_rtp_instance *bridged);
+
+/*!
  * \brief Make two channels compatible for early bridging
  *
  * \param c0 First channel part of the bridge

Modified: team/file/bridge_native/main/rtp_engine.c
URL: http://svnview.digium.com/svn/asterisk/team/file/bridge_native/main/rtp_engine.c?view=diff&rev=385911&r1=385910&r2=385911
==============================================================================
--- team/file/bridge_native/main/rtp_engine.c (original)
+++ team/file/bridge_native/main/rtp_engine.c Tue Apr 16 14:17:20 2013
@@ -1610,6 +1610,11 @@
 	return instance->bridged;
 }
 
+void ast_rtp_instance_set_bridged(struct ast_rtp_instance *instance, struct ast_rtp_instance *bridged)
+{
+	instance->bridged = bridged;
+}
+
 void ast_rtp_instance_early_bridge_make_compatible(struct ast_channel *c0, struct ast_channel *c1)
 {
 	struct ast_rtp_instance *instance0 = NULL, *instance1 = NULL,




More information about the asterisk-commits mailing list