[asterisk-commits] sgriepentrog: branch 11 r402042 - in /branches/11: ./ include/asterisk/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Oct 25 18:32:22 CDT 2013


Author: sgriepentrog
Date: Fri Oct 25 18:32:19 2013
New Revision: 402042

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=402042
Log:
rtp_engine: fix rtp payloads copy and improve argument names

In function ast_rtp_instance_early _bridge_make_compatible the
use of instance 0/1 as arguments doesn't clearly communicate a
direction that the copying of payloads from the source channel
to the destination channel will occur, making it more probable
to have the arguments to ast_rtp_codecs_payloads_copy() put in
the reverse order.  This patch renames the arguments with _dst
and _src suffixes and corrects the copy direction.

(closes issue ASTERISK-21464)
Reported by: Kevin Stewart
Review: https://reviewboard.asterisk.org/r/2894/
........

Merged revisions 402000 from http://svn.asterisk.org/svn/asterisk/branches/1.8
Test shows rtpmap:119 being copied per this change, but is not in sip invite

Modified:
    branches/11/   (props changed)
    branches/11/include/asterisk/rtp_engine.h
    branches/11/main/rtp_engine.c

Propchange: branches/11/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.

Modified: branches/11/include/asterisk/rtp_engine.h
URL: http://svnview.digium.com/svn/asterisk/branches/11/include/asterisk/rtp_engine.h?view=diff&rev=402042&r1=402041&r2=402042
==============================================================================
--- branches/11/include/asterisk/rtp_engine.h (original)
+++ branches/11/include/asterisk/rtp_engine.h Fri Oct 25 18:32:19 2013
@@ -1608,12 +1608,12 @@
 /*!
  * \brief Make two channels compatible for early bridging
  *
- * \param c0 First channel part of the bridge
- * \param c1 Second channel part of the bridge
- *
- * \since 1.8
- */
-void ast_rtp_instance_early_bridge_make_compatible(struct ast_channel *c0, struct ast_channel *c1);
+ * \param c_dst Destination channel to copy to
+ * \param c_src Source channel to copy from
+ *
+ * \since 1.8
+ */
+void ast_rtp_instance_early_bridge_make_compatible(struct ast_channel *c_dst, struct ast_channel *c_src);
 
 /*!
  * \brief Early bridge two channels that use RTP instances

Modified: branches/11/main/rtp_engine.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/rtp_engine.c?view=diff&rev=402042&r1=402041&r2=402042
==============================================================================
--- branches/11/main/rtp_engine.c (original)
+++ branches/11/main/rtp_engine.c Fri Oct 25 18:32:19 2013
@@ -1627,90 +1627,90 @@
 	return instance->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,
-		*vinstance0 = NULL, *vinstance1 = NULL,
-		*tinstance0 = NULL, *tinstance1 = NULL;
-	struct ast_rtp_glue *glue0, *glue1;
-	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_format_cap *cap0 = ast_format_cap_alloc_nolock();
-	struct ast_format_cap *cap1 = ast_format_cap_alloc_nolock();
+void ast_rtp_instance_early_bridge_make_compatible(struct ast_channel *c_dst, struct ast_channel *c_src)
+{
+	struct ast_rtp_instance *instance_dst = NULL, *instance_src = NULL,
+		*vinstance_dst = NULL, *vinstance_src = NULL,
+		*tinstance_dst = NULL, *tinstance_src = NULL;
+	struct ast_rtp_glue *glue_dst, *glue_src;
+	enum ast_rtp_glue_result audio_glue_dst_res = AST_RTP_GLUE_RESULT_FORBID, video_glue_dst_res = AST_RTP_GLUE_RESULT_FORBID;
+	enum ast_rtp_glue_result audio_glue_src_res = AST_RTP_GLUE_RESULT_FORBID, video_glue_src_res = AST_RTP_GLUE_RESULT_FORBID;
+	struct ast_format_cap *cap_dst = ast_format_cap_alloc_nolock();
+	struct ast_format_cap *cap_src = ast_format_cap_alloc_nolock();
 
 	/* Lock both channels so we can look for the glue that binds them together */
-	ast_channel_lock_both(c0, c1);
-
-	if (!cap1 || !cap0) {
+	ast_channel_lock_both(c_dst, c_src);
+
+	if (!cap_src || !cap_dst) {
 		goto done;
 	}
 
 	/* Grab glue that binds each channel to something using the RTP engine */
-	if (!(glue0 = ast_rtp_instance_get_glue(ast_channel_tech(c0)->type)) || !(glue1 = ast_rtp_instance_get_glue(ast_channel_tech(c1)->type))) {
-		ast_debug(1, "Can't find native functions for channel '%s'\n", glue0 ? ast_channel_name(c1) : ast_channel_name(c0));
+	if (!(glue_dst = ast_rtp_instance_get_glue(ast_channel_tech(c_dst)->type)) || !(glue_src = ast_rtp_instance_get_glue(ast_channel_tech(c_src)->type))) {
+		ast_debug(1, "Can't find native functions for channel '%s'\n", glue_dst ? ast_channel_name(c_src) : ast_channel_name(c_dst));
 		goto done;
 	}
 
-	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;
+	audio_glue_dst_res = glue_dst->get_rtp_info(c_dst, &instance_dst);
+	video_glue_dst_res = glue_dst->get_vrtp_info ? glue_dst->get_vrtp_info(c_dst, &vinstance_dst) : AST_RTP_GLUE_RESULT_FORBID;
+
+	audio_glue_src_res = glue_src->get_rtp_info(c_src, &instance_src);
+	video_glue_src_res = glue_src->get_vrtp_info ? glue_src->get_vrtp_info(c_src, &vinstance_src) : AST_RTP_GLUE_RESULT_FORBID;
 
 	/* If we are carrying video, and both sides are not going to remotely bridge... fail the native bridge */
-	if (video_glue0_res != AST_RTP_GLUE_RESULT_FORBID && (audio_glue0_res != AST_RTP_GLUE_RESULT_REMOTE || video_glue0_res != AST_RTP_GLUE_RESULT_REMOTE)) {
-		audio_glue0_res = AST_RTP_GLUE_RESULT_FORBID;
-	}
-	if (video_glue1_res != AST_RTP_GLUE_RESULT_FORBID && (audio_glue1_res != AST_RTP_GLUE_RESULT_REMOTE || video_glue1_res != AST_RTP_GLUE_RESULT_REMOTE)) {
-		audio_glue1_res = AST_RTP_GLUE_RESULT_FORBID;
-	}
-	if (audio_glue0_res == AST_RTP_GLUE_RESULT_REMOTE && (video_glue0_res == AST_RTP_GLUE_RESULT_FORBID || video_glue0_res == AST_RTP_GLUE_RESULT_REMOTE) && glue0->get_codec) {
-		glue0->get_codec(c0, cap0);
-	}
-	if (audio_glue1_res == AST_RTP_GLUE_RESULT_REMOTE && (video_glue1_res == AST_RTP_GLUE_RESULT_FORBID || video_glue1_res == AST_RTP_GLUE_RESULT_REMOTE) && glue1->get_codec) {
-		glue1->get_codec(c1, cap1);
+	if (video_glue_dst_res != AST_RTP_GLUE_RESULT_FORBID && (audio_glue_dst_res != AST_RTP_GLUE_RESULT_REMOTE || video_glue_dst_res != AST_RTP_GLUE_RESULT_REMOTE)) {
+		audio_glue_dst_res = AST_RTP_GLUE_RESULT_FORBID;
+	}
+	if (video_glue_src_res != AST_RTP_GLUE_RESULT_FORBID && (audio_glue_src_res != AST_RTP_GLUE_RESULT_REMOTE || video_glue_src_res != AST_RTP_GLUE_RESULT_REMOTE)) {
+		audio_glue_src_res = AST_RTP_GLUE_RESULT_FORBID;
+	}
+	if (audio_glue_dst_res == AST_RTP_GLUE_RESULT_REMOTE && (video_glue_dst_res == AST_RTP_GLUE_RESULT_FORBID || video_glue_dst_res == AST_RTP_GLUE_RESULT_REMOTE) && glue_dst->get_codec) {
+		glue_dst->get_codec(c_dst, cap_dst);
+	}
+	if (audio_glue_src_res == AST_RTP_GLUE_RESULT_REMOTE && (video_glue_src_res == AST_RTP_GLUE_RESULT_FORBID || video_glue_src_res == AST_RTP_GLUE_RESULT_REMOTE) && glue_src->get_codec) {
+		glue_src->get_codec(c_src, cap_src);
 	}
 
 	/* If any sort of bridge is forbidden just completely bail out and go back to generic bridging */
-	if (audio_glue0_res != AST_RTP_GLUE_RESULT_REMOTE || audio_glue1_res != AST_RTP_GLUE_RESULT_REMOTE) {
+	if (audio_glue_dst_res != AST_RTP_GLUE_RESULT_REMOTE || audio_glue_src_res != AST_RTP_GLUE_RESULT_REMOTE) {
 		goto done;
 	}
 
 	/* Make sure we have matching codecs */
-	if (!ast_format_cap_has_joint(cap0, cap1)) {
+	if (!ast_format_cap_has_joint(cap_dst, cap_src)) {
 		goto done;
 	}
 
-	ast_rtp_codecs_payloads_copy(&instance0->codecs, &instance1->codecs, instance1);
-
-	if (vinstance0 && vinstance1) {
-		ast_rtp_codecs_payloads_copy(&vinstance0->codecs, &vinstance1->codecs, vinstance1);
-	}
-	if (tinstance0 && tinstance1) {
-		ast_rtp_codecs_payloads_copy(&tinstance0->codecs, &tinstance1->codecs, tinstance1);
-	}
-
-	if (glue0->update_peer(c0, instance1, vinstance1, tinstance1, cap1, 0)) {
+	ast_rtp_codecs_payloads_copy(&instance_src->codecs, &instance_dst->codecs, instance_dst);
+
+	if (vinstance_dst && vinstance_src) {
+		ast_rtp_codecs_payloads_copy(&vinstance_src->codecs, &vinstance_dst->codecs, vinstance_dst);
+	}
+	if (tinstance_dst && tinstance_src) {
+		ast_rtp_codecs_payloads_copy(&tinstance_src->codecs, &tinstance_dst->codecs, tinstance_dst);
+	}
+
+	if (glue_dst->update_peer(c_dst, instance_src, vinstance_src, tinstance_src, cap_src, 0)) {
 		ast_log(LOG_WARNING, "Channel '%s' failed to setup early bridge to '%s'\n",
-			ast_channel_name(c0), ast_channel_name(c1));
+			ast_channel_name(c_dst), ast_channel_name(c_src));
 	} else {
 		ast_debug(1, "Seeded SDP of '%s' with that of '%s'\n",
-			ast_channel_name(c0), ast_channel_name(c1));
+			ast_channel_name(c_dst), ast_channel_name(c_src));
 	}
 
 done:
-	ast_channel_unlock(c0);
-	ast_channel_unlock(c1);
-
-	ast_format_cap_destroy(cap0);
-	ast_format_cap_destroy(cap1);
-
-	unref_instance_cond(&instance0);
-	unref_instance_cond(&instance1);
-	unref_instance_cond(&vinstance0);
-	unref_instance_cond(&vinstance1);
-	unref_instance_cond(&tinstance0);
-	unref_instance_cond(&tinstance1);
+	ast_channel_unlock(c_dst);
+	ast_channel_unlock(c_src);
+
+	ast_format_cap_destroy(cap_dst);
+	ast_format_cap_destroy(cap_src);
+
+	unref_instance_cond(&instance_dst);
+	unref_instance_cond(&instance_src);
+	unref_instance_cond(&vinstance_dst);
+	unref_instance_cond(&vinstance_src);
+	unref_instance_cond(&tinstance_dst);
+	unref_instance_cond(&tinstance_src);
 }
 
 int ast_rtp_instance_early_bridge(struct ast_channel *c0, struct ast_channel *c1)




More information about the asterisk-commits mailing list