[svn-commits] file: branch group/media_formats r411019 - /team/group/media_formats/channels/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Mar 24 11:19:41 CDT 2014


Author: file
Date: Mon Mar 24 11:19:32 2014
New Revision: 411019

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=411019
Log:
Knock out chan_misdn some.

Modified:
    team/group/media_formats/channels/chan_misdn.c

Modified: team/group/media_formats/channels/chan_misdn.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/channels/chan_misdn.c?view=diff&rev=411019&r1=411018&r2=411019
==============================================================================
--- team/group/media_formats/channels/chan_misdn.c (original)
+++ team/group/media_formats/channels/chan_misdn.c Mon Mar 24 11:19:32 2014
@@ -120,6 +120,7 @@
 #include "asterisk/features_config.h"
 #include "asterisk/bridge.h"
 #include "asterisk/pickup.h"
+#include "asterisk/format_cache.h"
 
 #include "chan_misdn_config.h"
 #include "isdn_lib.h"
@@ -690,9 +691,6 @@
 static const char misdn_type[] = "mISDN";
 
 static int tracing = 0;
-
-/*! \brief Only alaw and mulaw is allowed for now */
-static struct ast_format prefformat; /*  AST_FORMAT_SLINEAR ;  AST_FORMAT_ULAW | */
 
 static int *misdn_debug;
 static int *misdn_debug_only;
@@ -7436,7 +7434,7 @@
 	}
 
 	tmp->frame.frametype = AST_FRAME_VOICE;
-	ast_format_set(&tmp->frame.subclass.format, AST_FORMAT_ALAW, 0);
+	tmp->frame.subclass.format = ast_format_copy(ast_format_alaw);
 	tmp->frame.datalen = len;
 	tmp->frame.samples = len;
 	tmp->frame.mallocd = 0;
@@ -7501,13 +7499,13 @@
 	}
 
 
-	if (!frame->subclass.format.id) {
+	if (!frame->subclass.format) {
 		chan_misdn_log(4, ch->bc->port, "misdn_write: * prods us\n");
 		return 0;
 	}
 
-	if (ast_format_cmp(&frame->subclass.format, &prefformat) == AST_FORMAT_CMP_NOT_EQUAL) {
-		chan_misdn_log(-1, ch->bc->port, "Got Unsupported Frame with Format:%s\n", ast_getformatname(&frame->subclass.format));
+	if (ast_format_cmp(frame->subclass.format, prefformat) == AST_FORMAT_CMP_NOT_EQUAL) {
+		chan_misdn_log(-1, ch->bc->port, "Got Unsupported Frame with Format:%s\n", frame->subclass.format->codec->name);
 		return 0;
 	}
 
@@ -8174,12 +8172,18 @@
 
 static struct ast_channel *misdn_new(struct chan_list *chlist, int state,  char *exten, char *callerid, struct ast_format_cap *cap, const char *linkedid, int port, int c)
 {
+	struct ast_format_cap *native;
 	struct ast_channel *tmp;
 	char *cid_name = NULL;
 	char *cid_num = NULL;
 	int chan_offset = 0;
 	int tmp_port = misdn_cfg_get_next_port(0);
-	struct ast_format tmpfmt;
+	struct ast_format *tmpfmt;
+
+	native = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
+	if (!native) {
+		return NULL;
+	}
 
 	for (; tmp_port > 0; tmp_port = misdn_cfg_get_next_port(tmp_port)) {
 		if (tmp_port == port) {
@@ -8200,11 +8204,14 @@
 		chan_misdn_log(2, port, " --> * NEW CHANNEL dialed:%s caller:%s\n", exten, callerid);
 
 		ast_best_codec(cap, &tmpfmt);
-		ast_format_cap_add(ast_channel_nativeformats(tmp), &prefformat);
-		ast_format_copy(ast_channel_writeformat(tmp), &tmpfmt);
-		ast_format_copy(ast_channel_rawwriteformat(tmp), &tmpfmt);
-		ast_format_copy(ast_channel_readformat(tmp), &tmpfmt);
-		ast_format_copy(ast_channel_rawreadformat(tmp), &tmpfmt);
+		ast_format_cap_add(native, ast_format_alaw, 0);
+		ast_channel_nativeformats_set(tmp, native);
+		ast_channel_set_writeformat(tmp, tmpfmt);
+		ast_channel_set_rawwriteformat(tmp, tmpfmt);
+		ast_channel_set_readformat(tmp, tmpfmt);
+		ast_channel_set_rawreadformat(tmp, tmpfmt);
+
+		ao2_ref(tmpfmt, -1);
 
 		/* Link the channel and private together */
 		chan_list_ref(chlist, "Give a reference to ast_channel");
@@ -8241,6 +8248,8 @@
 	} else {
 		chan_misdn_log(-1, 0, "Unable to allocate channel structure\n");
 	}
+
+	ao2_ref(native, -1);
 
 	return tmp;
 }
@@ -10207,14 +10216,13 @@
 		ch->addr = bc->addr;
 
 		{
-			struct ast_format_cap *cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
-			struct ast_format tmpfmt;
+			struct ast_format_cap *cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
 			if (!(cap)) {
 				return RESPONSE_ERR;
 			}
-			ast_format_cap_add(cap, ast_format_set(&tmpfmt, AST_FORMAT_ALAW, 0));
+			ast_format_cap_add(cap, ast_format_alaw, 0);
 			chan = misdn_new(ch, AST_STATE_RESERVED, bc->dialed.number, bc->caller.number, cap, NULL, bc->port, bc->channel);
-			cap = ast_format_cap_destroy(cap);
+			ao2_ref(cap, -1);
 		}
 		if (!chan) {
 			chan_list_unref(ch, "Failed to create a new channel");
@@ -11287,7 +11295,8 @@
 #if defined(AST_MISDN_ENHANCEMENTS)
 	misdn_cc_destroy();
 #endif	/* defined(AST_MISDN_ENHANCEMENTS) */
-	misdn_tech.capabilities = ast_format_cap_destroy(misdn_tech.capabilities);
+	ao2_ref(misdn_tech.capabilities, -1);
+	misdn_tech.capabilities = NULL;
 
 	return 0;
 }
@@ -11316,11 +11325,10 @@
 	};
 
 
-	if (!(misdn_tech.capabilities = ast_format_cap_alloc(0))) {
+	if (!(misdn_tech.capabilities = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
 		return AST_MODULE_LOAD_DECLINE;
 	}
-	ast_format_set(&prefformat, AST_FORMAT_ALAW, 0);
-	ast_format_cap_add(misdn_tech.capabilities, &prefformat);
+	ast_format_cap_add(misdn_tech.capabilities, ast_format_alaw, 0);
 
 	max_ports = misdn_lib_maxports_get();
 




More information about the svn-commits mailing list