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

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Feb 17 12:37:12 CST 2014


Author: file
Date: Mon Feb 17 12:37:08 2014
New Revision: 408287

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=408287
Log:
Move chan_console over.

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

Modified: team/group/media_formats/channels/chan_console.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/channels/chan_console.c?view=diff&rev=408287&r1=408286&r2=408287
==============================================================================
--- team/group/media_formats/channels/chan_console.c (original)
+++ team/group/media_formats/channels/chan_console.c Mon Feb 17 12:37:08 2014
@@ -77,6 +77,7 @@
 #include "asterisk/callerid.h"
 #include "asterisk/astobj2.h"
 #include "asterisk/stasis_channels.h"
+#include "asterisk/format_cache.h"
 
 /*! 
  * \brief The sample rate to request from PortAudio 
@@ -270,12 +271,12 @@
 	PaError res;
 	struct ast_frame f = {
 		.frametype = AST_FRAME_VOICE,
+		.subclass.format = ast_format_slin16,
 		.src = "console_stream_monitor",
 		.data.ptr = buf,
 		.datalen = sizeof(buf),
 		.samples = sizeof(buf) / sizeof(int16_t),
 	};
-	ast_format_set(&f.subclass.format, AST_FORMAT_SLINEAR16, 0);
 
 	for (;;) {
 		pthread_testcancel();
@@ -421,19 +422,28 @@
  */
 static struct ast_channel *console_new(struct console_pvt *pvt, const char *ext, const char *ctx, int state, const char *linkedid)
 {
+	struct ast_format_cap *caps;
 	struct ast_channel *chan;
+
+	caps = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
+	if (!caps) {
+		return NULL;
+	}
 
 	if (!(chan = ast_channel_alloc(1, state, pvt->cid_num, pvt->cid_name, NULL, 
 		ext, ctx, linkedid, 0, "Console/%s", pvt->name))) {
+		ao2_ref(caps, -1);
 		return NULL;
 	}
 
 	ast_channel_stage_snapshot(chan);
 
 	ast_channel_tech_set(chan, &console_tech);
-	ast_format_set(ast_channel_readformat(chan), AST_FORMAT_SLINEAR16, 0);
-	ast_format_set(ast_channel_writeformat(chan), AST_FORMAT_SLINEAR16, 0);
-	ast_format_cap_add(ast_channel_nativeformats(chan), ast_channel_readformat(chan));
+	ast_channel_set_readformat(chan, ast_format_slin16);
+	ast_channel_set_writeformat(chan, ast_format_slin16);
+	ast_format_cap_add(caps, ast_format_slin16, 0);
+	ast_channel_nativeformats_set(chan, caps);
+	ao2_ref(caps, -1);
 	ast_channel_tech_pvt_set(chan, ref_pvt(pvt));
 
 	pvt->owner = chan;
@@ -469,7 +479,7 @@
 		return NULL;
 	}
 
-	if (!(ast_format_cap_has_joint(cap, console_tech.capabilities))) {
+	if (!(ast_format_cap_iscompatible(cap, console_tech.capabilities))) {
 		ast_log(LOG_NOTICE, "Channel requested with unsupported format(s): '%s'\n", ast_getformatname_multiple(buf, sizeof(buf), cap));
 		goto return_unref;
 	}
@@ -1467,7 +1477,8 @@
 
 static int unload_module(void)
 {
-	console_tech.capabilities = ast_format_cap_destroy(console_tech.capabilities);
+	ao2_ref(console_tech.capabilities, -1);
+	console_tech.capabilities = NULL;
 	ast_channel_unregister(&console_tech);
 	ast_cli_unregister_multiple(cli_console, ARRAY_LEN(cli_console));
 
@@ -1495,13 +1506,12 @@
  */
 static int load_module(void)
 {
-	struct ast_format tmpfmt;
 	PaError res;
 
-	if (!(console_tech.capabilities = ast_format_cap_alloc(0))) {
+	if (!(console_tech.capabilities = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
 		return AST_MODULE_LOAD_DECLINE;
 	}
-	ast_format_cap_add(console_tech.capabilities, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR16, 0));
+	ast_format_cap_add(console_tech.capabilities, ast_format_slin16, 0);
 
 	init_pvt(&globals, NULL);
 




More information about the svn-commits mailing list