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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Apr 17 06:44:04 CDT 2013


Author: file
Date: Wed Apr 17 06:40:28 2013
New Revision: 385961

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=385961
Log:
Add DTMF checks.

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=385961&r1=385960&r2=385961
==============================================================================
--- team/file/bridge_native/bridges/bridge_native_rtp.c (original)
+++ team/file/bridge_native/bridges/bridge_native_rtp.c Wed Apr 17 06:40:28 2013
@@ -101,8 +101,9 @@
 
 static int native_rtp_bridge_compatible(struct ast_bridge *bridge)
 {
-	struct ast_channel *c0 = AST_LIST_FIRST(&bridge->channels)->chan;
-	struct ast_channel *c1 = AST_LIST_LAST(&bridge->channels)->chan;
+	struct ast_bridge_channel *c0 = AST_LIST_FIRST(&bridge->channels);
+	struct ast_bridge_channel *c1 = AST_LIST_LAST(&bridge->channels);
+	enum ast_rtp_glue_result native_type;
 	struct ast_rtp_glue *glue0, *glue1;
 	struct ast_rtp_instance *instance0 = NULL, *instance1 = NULL, *vinstance0 = NULL, *vinstance1 = NULL;
 	RAII_VAR(struct ast_format_cap *, cap0, ast_format_cap_alloc_nolock(), ast_format_cap_destroy);
@@ -111,19 +112,45 @@
 
 	/* We require two channels before even considering native bridging */
 	if (c0 == c1) {
-		return 0;
-	}
-
-	if (native_rtp_bridge_get(c0, c1, &glue0, &glue1, &instance0, &instance1, &vinstance0, &vinstance1) == AST_RTP_GLUE_RESULT_FORBID) {
+		ast_debug(1, "Bridge '%s' can not use native RTP bridge as two channels are required\n",
+			bridge->uniqueid);
+		return 0;
+	}
+
+	if ((native_type = native_rtp_bridge_get(c0->chan, c1->chan, &glue0, &glue1, &instance0, &instance1, &vinstance0, &vinstance1))
+		== AST_RTP_GLUE_RESULT_FORBID) {
+		ast_debug(1, "Bridge '%s' can not use native RTP bridge as it was forbidden while getting details\n",
+			bridge->uniqueid);
+		return 0;
+	}
+
+	if (ao2_container_count(c0->features->dtmf_hooks) && ast_rtp_instance_dtmf_mode_get(instance0)) {
+		ast_debug(1, "Bridge '%s' can not use native RTP bridge as channel '%s' has DTMF hooks\n",
+			bridge->uniqueid, ast_channel_name(c0->chan));
+		return 0;
+	}
+
+	if (ao2_container_count(c1->features->dtmf_hooks) && ast_rtp_instance_dtmf_mode_get(instance1)) {
+		ast_debug(1, "Bridge '%s' can not use native RTP bridge as channel '%s' has DTMF hooks\n",
+			bridge->uniqueid, ast_channel_name(c0->chan));
+		return 0;
+	}
+
+	if ((native_type == AST_RTP_GLUE_RESULT_LOCAL) && ((ast_rtp_instance_get_engine(instance0)->local_bridge !=
+		ast_rtp_instance_get_engine(instance1)->local_bridge) ||
+		(ast_rtp_instance_get_engine(instance0)->dtmf_compatible &&
+			!ast_rtp_instance_get_engine(instance0)->dtmf_compatible(c0->chan, instance0, c1->chan, instance1)))) {
+		ast_debug(1, "Bridge '%s' can not use local native RTP bridge as local bridge or DTMF is not compatible\n",
+			bridge->uniqueid);
 		return 0;
 	}
 
 	/* Make sure that codecs match */
 	if (glue0->get_codec) {
-		glue0->get_codec(c0, cap0);
+		glue0->get_codec(c0->chan, cap0);
 	}
 	if (glue1->get_codec) {
-		glue1->get_codec(c1, cap1);
+		glue1->get_codec(c1->chan, cap1);
 	}
 	if (!ast_format_cap_is_empty(cap0) && !ast_format_cap_is_empty(cap1) && !ast_format_cap_has_joint(cap0, cap1)) {
 		char tmp0[256] = { 0, }, tmp1[256] = { 0, };
@@ -134,10 +161,10 @@
 		return 0;
 	}
 
-	read_ptime0 = (ast_codec_pref_getsize(&ast_rtp_instance_get_codecs(instance0)->pref, ast_channel_rawreadformat(c0))).cur_ms;
-	read_ptime1 = (ast_codec_pref_getsize(&ast_rtp_instance_get_codecs(instance1)->pref, ast_channel_rawreadformat(c1))).cur_ms;
-	write_ptime0 = (ast_codec_pref_getsize(&ast_rtp_instance_get_codecs(instance0)->pref, ast_channel_rawwriteformat(c0))).cur_ms;
-	write_ptime1 = (ast_codec_pref_getsize(&ast_rtp_instance_get_codecs(instance1)->pref, ast_channel_rawwriteformat(c1))).cur_ms;
+	read_ptime0 = (ast_codec_pref_getsize(&ast_rtp_instance_get_codecs(instance0)->pref, ast_channel_rawreadformat(c0->chan))).cur_ms;
+	read_ptime1 = (ast_codec_pref_getsize(&ast_rtp_instance_get_codecs(instance1)->pref, ast_channel_rawreadformat(c1->chan))).cur_ms;
+	write_ptime0 = (ast_codec_pref_getsize(&ast_rtp_instance_get_codecs(instance0)->pref, ast_channel_rawwriteformat(c0->chan))).cur_ms;
+	write_ptime1 = (ast_codec_pref_getsize(&ast_rtp_instance_get_codecs(instance1)->pref, ast_channel_rawwriteformat(c1->chan))).cur_ms;
 
 	if (read_ptime0 != write_ptime1 || read_ptime1 != write_ptime0) {
 		ast_debug(1, "Packetization differs between RTP streams (%d != %d or %d != %d). Cannot native bridge in RTP\n",




More information about the asterisk-commits mailing list