[asterisk-commits] dvossel: branch dvossel/fixtheworld_phase1_step3 r302001 - /team/dvossel/fixt...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jan 14 16:03:36 CST 2011


Author: dvossel
Date: Fri Jan 14 16:03:32 2011
New Revision: 302001

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=302001
Log:
updates to chan_console

Modified:
    team/dvossel/fixtheworld_phase1_step3/channels/chan_console.c

Modified: team/dvossel/fixtheworld_phase1_step3/channels/chan_console.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/channels/chan_console.c?view=diff&rev=302001&r1=302000&r2=302001
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/channels/chan_console.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/channels/chan_console.c Fri Jan 14 16:03:32 2011
@@ -183,7 +183,7 @@
 static struct ast_jb_conf global_jbconf;
 
 /*! Channel Technology Callbacks @{ */
-static struct ast_channel *console_request(const char *type, format_t format,
+static struct ast_channel *console_request(const char *type, struct ast_cap *cap,
 	const struct ast_channel *requestor, void *data, int *cause);
 static int console_digit_begin(struct ast_channel *c, char digit);
 static int console_digit_end(struct ast_channel *c, char digit, unsigned int duration);
@@ -198,15 +198,9 @@
 static int console_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
 /*! @} */
 
-/*!
- * \brief Formats natively supported by this module.
- */
-#define SUPPORTED_FORMATS ( AST_FORMAT_SLINEAR16 )
-
-static const struct ast_channel_tech console_tech = {
+static struct ast_channel_tech console_tech = {
 	.type = "Console",
 	.description = "Console Channel Driver",
-	.capabilities = SUPPORTED_FORMATS,
 	.requester = console_request,
 	.send_digit_begin = console_digit_begin,
 	.send_digit_end = console_digit_end,
@@ -265,12 +259,12 @@
 	PaError res;
 	struct ast_frame f = {
 		.frametype = AST_FRAME_VOICE,
-		.subclass.codec = AST_FORMAT_SLINEAR16,
 		.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();
@@ -424,9 +418,9 @@
 	}
 
 	chan->tech = &console_tech;
-	chan->nativeformats = AST_FORMAT_SLINEAR16;
-	chan->readformat = AST_FORMAT_SLINEAR16;
-	chan->writeformat = AST_FORMAT_SLINEAR16;
+	ast_format_set(&chan->readformat, AST_FORMAT_SLINEAR16, 0);
+	ast_format_set(&chan->writeformat, AST_FORMAT_SLINEAR16, 0);
+	ast_cap_add(chan->nativeformats, &chan->readformat);
 	chan->tech_pvt = ref_pvt(pvt);
 
 	pvt->owner = chan;
@@ -448,9 +442,8 @@
 	return chan;
 }
 
-static struct ast_channel *console_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
-{
-	format_t oldformat = format;
+static struct ast_channel *console_request(const char *type, struct ast_cap *cap, const struct ast_channel *requestor, void *data, int *cause)
+{
 	struct ast_channel *chan = NULL;
 	struct console_pvt *pvt;
 	char buf[512];
@@ -460,9 +453,8 @@
 		return NULL;
 	}
 
-	format &= SUPPORTED_FORMATS;
-	if (!format) {
-		ast_log(LOG_NOTICE, "Channel requested with unsupported format(s): '%s'\n", ast_getformatname_multiple(buf, sizeof(buf), oldformat));
+	if (!(ast_cap_has_joint(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;
 	}
 
@@ -1457,6 +1449,7 @@
 
 static int unload_module(void)
 {
+	console_tech.capabilities = ast_cap_destroy(console_tech.capabilities);
 	ast_channel_unregister(&console_tech);
 	ast_cli_unregister_multiple(cli_console, ARRAY_LEN(cli_console));
 
@@ -1474,7 +1467,13 @@
 
 static int load_module(void)
 {
+	struct ast_format tmpfmt;
 	PaError res;
+
+	if (!(console_tech.capabilities = ast_cap_alloc())) {
+		return AST_MODULE_LOAD_DECLINE;
+	}
+	ast_cap_add(console_tech.capabilities, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR16, 0));
 
 	init_pvt(&globals, NULL);
 




More information about the asterisk-commits mailing list