[asterisk-commits] mjordan: branch group/media_formats-reviewed r414851 - /team/group/media_form...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu May 29 12:03:00 CDT 2014


Author: mjordan
Date: Thu May 29 12:02:54 2014
New Revision: 414851

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=414851
Log:
bridges/bridge_native_rtp: Port over to new format API

Review: https://reviewboard.asterisk.org/r/3506/

Modified:
    team/group/media_formats-reviewed/bridges/bridge_native_rtp.c

Modified: team/group/media_formats-reviewed/bridges/bridge_native_rtp.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/bridges/bridge_native_rtp.c?view=diff&rev=414851&r1=414850&r2=414851
==============================================================================
--- team/group/media_formats-reviewed/bridges/bridge_native_rtp.c (original)
+++ team/group/media_formats-reviewed/bridges/bridge_native_rtp.c Thu May 29 12:02:54 2014
@@ -133,8 +133,8 @@
 	RAII_VAR(struct ast_rtp_instance *, vinstance1, NULL, ao2_cleanup);
 	RAII_VAR(struct ast_rtp_instance *, tinstance0, NULL, ao2_cleanup);
 	RAII_VAR(struct ast_rtp_instance *, tinstance1, NULL, ao2_cleanup);
-	RAII_VAR(struct ast_format_cap *, cap0, ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK), ast_format_cap_destroy);
-	RAII_VAR(struct ast_format_cap *, cap1, ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK), ast_format_cap_destroy);
+	RAII_VAR(struct ast_format_cap *, cap0, ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT), ao2_cleanup);
+	RAII_VAR(struct ast_format_cap *, cap1, ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT), ao2_cleanup);
 
 	if (c0 == c1) {
 		return;
@@ -304,8 +304,8 @@
 	RAII_VAR(struct ast_rtp_instance *, instance1, NULL, ao2_cleanup);
 	RAII_VAR(struct ast_rtp_instance *, vinstance0, NULL, ao2_cleanup);
 	RAII_VAR(struct ast_rtp_instance *, vinstance1, NULL, ao2_cleanup);
-	RAII_VAR(struct ast_format_cap *, cap0, ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK), ast_format_cap_destroy);
-	RAII_VAR(struct ast_format_cap *, cap1, ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK), ast_format_cap_destroy);
+	RAII_VAR(struct ast_format_cap *, cap0, ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT), ao2_cleanup);
+	RAII_VAR(struct ast_format_cap *, cap1, ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT), ao2_cleanup);
 	int read_ptime0, read_ptime1, write_ptime0, write_ptime1;
 
 	/* We require two channels before even considering native bridging */
@@ -362,7 +362,7 @@
 	if (glue1->get_codec) {
 		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)) {
+	if (ast_format_cap_count(cap0) != 0 && ast_format_cap_count(cap1) != 0 && !ast_format_cap_iscompatible(cap0, cap1)) {
 		char tmp0[256] = { 0, }, tmp1[256] = { 0, };
 
 		ast_debug(1, "Channel codec0 = %s is not codec1 = %s, cannot native bridge in RTP.\n",
@@ -371,10 +371,10 @@
 		return 0;
 	}
 
-	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;
+	read_ptime0 = ast_format_cap_get_framing(cap0, ast_channel_rawreadformat(c0->chan));
+	read_ptime1 = ast_format_cap_get_framing(cap1, ast_channel_rawreadformat(c1->chan));
+	write_ptime0 = ast_format_cap_get_framing(cap0, ast_channel_rawwriteformat(c0->chan));
+	write_ptime1 = ast_format_cap_get_framing(cap1, ast_channel_rawwriteformat(c1->chan));
 
 	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",
@@ -492,7 +492,7 @@
 
 static int unload_module(void)
 {
-	ast_format_cap_destroy(native_rtp_bridge.format_capabilities);
+	ao2_t_ref(native_rtp_bridge.format_capabilities, -1, "Dispose of capabilities in module unload");
 	return ast_bridge_technology_unregister(&native_rtp_bridge);
 }
 
@@ -501,9 +501,9 @@
 	if (!(native_rtp_bridge.format_capabilities = ast_format_cap_alloc(0))) {
 		return AST_MODULE_LOAD_DECLINE;
 	}
-	ast_format_cap_add_all_by_type(native_rtp_bridge.format_capabilities, AST_FORMAT_TYPE_AUDIO);
-	ast_format_cap_add_all_by_type(native_rtp_bridge.format_capabilities, AST_FORMAT_TYPE_VIDEO);
-	ast_format_cap_add_all_by_type(native_rtp_bridge.format_capabilities, AST_FORMAT_TYPE_TEXT);
+	ast_format_cap_add_all_by_type(native_rtp_bridge.format_capabilities, AST_MEDIA_TYPE_AUDIO);
+	ast_format_cap_add_all_by_type(native_rtp_bridge.format_capabilities, AST_MEDIA_TYPE_VIDEO);
+	ast_format_cap_add_all_by_type(native_rtp_bridge.format_capabilities, AST_MEDIA_TYPE_TEXT);
 
 	return ast_bridge_technology_register(&native_rtp_bridge);
 }




More information about the asterisk-commits mailing list