[asterisk-commits] file: branch group/media_formats r411010 - in /team/group/media_formats/chann...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Mar 21 17:29:52 CDT 2014


Author: file
Date: Fri Mar 21 17:29:45 2014
New Revision: 411010

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=411010
Log:
Well, the C part of this compiles... the C++ part not so much, yet.

Modified:
    team/group/media_formats/channels/chan_h323.c
    team/group/media_formats/channels/h323/chan_h323.h

Modified: team/group/media_formats/channels/chan_h323.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/channels/chan_h323.c?view=diff&rev=411010&r1=411009&r2=411010
==============================================================================
--- team/group/media_formats/channels/chan_h323.c (original)
+++ team/group/media_formats/channels/chan_h323.c Fri Mar 21 17:29:45 2014
@@ -352,13 +352,22 @@
 /*! \brief Channel and private structures should be already locked */
 static void __oh323_update_info(struct ast_channel *c, struct oh323_pvt *pvt)
 {
-	h323_format chan_nativeformats_bits = ast_format_cap_to_old_bitfield(ast_channel_nativeformats(c));
+	h323_format chan_nativeformats_bits = ast_format_compatibility_cap2bitfield(ast_channel_nativeformats(c));
 	if (chan_nativeformats_bits != pvt->nativeformats) {
-		if (h323debug)
-			ast_debug(1, "Preparing %s for new native format\n", ast_channel_name(c));
-		ast_format_cap_from_old_bitfield(ast_channel_nativeformats(c), pvt->nativeformats);
-		ast_set_read_format(c, ast_channel_readformat(c));
-		ast_set_write_format(c, ast_channel_writeformat(c));
+		struct ast_format_cap *nativeformats;
+
+		nativeformats = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
+		if (nativeformats) {
+			if (h323debug)
+				ast_debug(1, "Preparing %s for new native format\n", ast_channel_name(c));
+
+			ast_format_compatibility_bitfield2cap(pvt->nativeformats, nativeformats);
+			ast_channel_nativeformats_set(c, nativeformats);
+			ast_set_read_format(c, ast_channel_readformat(c));
+			ast_set_write_format(c, ast_channel_writeformat(c));
+
+			ao2_ref(nativeformats, -1);
+		}
 	}
 	if (pvt->needhangup) {
 		if (h323debug)
@@ -787,20 +796,29 @@
 		/* We already hold the channel lock */
 		if (f->frametype == AST_FRAME_VOICE) {
 			if (!ast_format_cap_iscompatible_format(ast_channel_nativeformats(pvt->owner), f->subclass.format)) {
-				/* Try to avoid deadlock */
-				if (ast_channel_trylock(pvt->owner)) {
-					ast_log(LOG_NOTICE, "Format changed but channel is locked. Ignoring frame...\n");
-					return &ast_null_frame;
+				struct ast_format_cap *nativeformats;
+
+				nativeformats = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
+
+				if (nativeformats) {
+					/* Try to avoid deadlock */
+					if (ast_channel_trylock(pvt->owner)) {
+						ast_log(LOG_NOTICE, "Format changed but channel is locked. Ignoring frame...\n");
+						return &ast_null_frame;
+					}
+					if (h323debug)
+						ast_debug(1, "Oooh, format changed to '%s'\n", f->subclass.format->codec->name);
+					ast_format_cap_add(nativeformats, f->subclass.format, 0);
+					ast_channel_nativeformats_set(pvt->owner, nativeformats);
+
+					pvt->nativeformats = ast_format_compatibility_format2bitfield(f->subclass.format);
+
+					ast_set_read_format(pvt->owner, ast_channel_readformat(pvt->owner));
+					ast_set_write_format(pvt->owner, ast_channel_writeformat(pvt->owner));
+					ast_channel_unlock(pvt->owner);
+
+					ao2_ref(nativeformats, -1);
 				}
-				if (h323debug)
-					ast_debug(1, "Oooh, format changed to '%s'\n", f->subclass.format->codec->name);
-				ast_format_cap_set(ast_channel_nativeformats(pvt->owner), &f->subclass.format);
-
-				pvt->nativeformats = ast_format_compatibility_format2bitfield(f->subclass.format);
-
-				ast_set_read_format(pvt->owner, ast_channel_readformat(pvt->owner));
-				ast_set_write_format(pvt->owner, ast_channel_writeformat(pvt->owner));
-				ast_channel_unlock(pvt->owner);
 			}
 			/* Do in-band DTMF detection */
 			if ((pvt->options.dtmfmode & H323_DTMF_INBAND) && pvt->vad) {
@@ -1083,10 +1101,10 @@
 
 		ast_best_codec(nativeformats, &tmpfmt);
 
-		ast_format_cap_set(ast_channel_nativeformats(ch), &tmpfmt);
-
-		pvt->nativeformats = ast_format_cap_to_old_bitfield(ast_channel_nativeformats(ch));
-		ast_best_codec(ast_channel_nativeformats(ch), &tmpfmt);
+		ast_format_cap_remove_bytype(nativeformats, AST_MEDIA_TYPE_UNKNOWN);
+		ast_format_cap_add(nativeformats, tmpfmt, 0);
+
+		pvt->nativeformats = ast_format_compatibility_cap2bitfield(nativeformats);
 		ast_channel_set_writeformat(ch, tmpfmt);
 		ast_channel_set_rawwriteformat(ch, tmpfmt);
 		ast_channel_set_readformat(ch, tmpfmt);
@@ -2109,8 +2127,8 @@
 	if (pt != 128 && pvt->rtp) {	/* Payload type is invalid, so try to use previously decided */
 		struct ast_rtp_payload_type rtptype = ast_rtp_codecs_payload_lookup(ast_rtp_instance_get_codecs(pvt->rtp), pt);
 		if (rtptype.asterisk_format) {
-			if (pvt->nativeformats != ast_format_to_old_bitfield(&rtptype.format)) {
-				pvt->nativeformats = ast_format_to_old_bitfield(&rtptype.format);
+			if (pvt->nativeformats != ast_format_compatibility_format2bitfield(&rtptype.format)) {
+				pvt->nativeformats = ast_format_compatibility_format2bitfield(&rtptype.format);
 				nativeformats_changed = 1;
 			}
 		}

Modified: team/group/media_formats/channels/h323/chan_h323.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/channels/h323/chan_h323.h?view=diff&rev=411010&r1=411009&r2=411010
==============================================================================
--- team/group/media_formats/channels/h323/chan_h323.h (original)
+++ team/group/media_formats/channels/h323/chan_h323.h Fri Mar 21 17:29:45 2014
@@ -31,6 +31,7 @@
 
 #include <arpa/inet.h>
 #include "asterisk/format.h"
+#include "asterisk/format_compatibility.h"
 #include "asterisk/app.h"
 
 /*




More information about the asterisk-commits mailing list