summaryrefslogtreecommitdiff
path: root/channels/chan_console.c
diff options
context:
space:
mode:
authorDavid Vossel <dvossel@digium.com>2011-02-03 16:22:10 +0000
committerDavid Vossel <dvossel@digium.com>2011-02-03 16:22:10 +0000
commitc26c190711a1bbe3b5fff1a93facae333757c56e (patch)
tree00da0caa5a07b7b25729f089dbcafb08129fa9be /channels/chan_console.c
parent652fb64a01c7a8656697d07e606620ee0ced6929 (diff)
Asterisk media architecture conversion - no more format bitfields
This patch is the foundation of an entire new way of looking at media in Asterisk. The code present in this patch is everything required to complete phase1 of my Media Architecture proposal. For more information about this project visit the link below. https://wiki.asterisk.org/wiki/display/AST/Media+Architecture+Proposal The primary function of this patch is to convert all the usages of format bitfields in Asterisk to use the new format and format_cap APIs. Functionally no change in behavior should be present in this patch. Thanks to twilson and russell for all the time they spent reviewing these changes. Review: https://reviewboard.asterisk.org/r/1083/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@306010 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_console.c')
-rw-r--r--channels/chan_console.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/channels/chan_console.c b/channels/chan_console.c
index 64c1b87fc..eb961b682 100644
--- a/channels/chan_console.c
+++ b/channels/chan_console.c
@@ -183,7 +183,7 @@ static struct ast_jb_conf default_jbconf = {
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_format_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_indicate(struct ast_channel *chan, int cond,
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 @@ static void *stream_monitor(void *data)
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 @@ static struct ast_channel *console_new(struct console_pvt *pvt, const char *ext,
}
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_format_cap_add(chan->nativeformats, &chan->readformat);
chan->tech_pvt = ref_pvt(pvt);
pvt->owner = chan;
@@ -448,9 +442,8 @@ static struct ast_channel *console_new(struct console_pvt *pvt, const char *ext,
return chan;
}
-static struct ast_channel *console_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
+static struct ast_channel *console_request(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, void *data, int *cause)
{
- format_t oldformat = format;
struct ast_channel *chan = NULL;
struct console_pvt *pvt;
char buf[512];
@@ -460,9 +453,8 @@ static struct ast_channel *console_request(const char *type, format_t format, co
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_format_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 void stop_streams(void)
static int unload_module(void)
{
+ console_tech.capabilities = ast_format_cap_destroy(console_tech.capabilities);
ast_channel_unregister(&console_tech);
ast_cli_unregister_multiple(cli_console, ARRAY_LEN(cli_console));
@@ -1474,8 +1467,14 @@ static int unload_module(void)
static int load_module(void)
{
+ struct ast_format tmpfmt;
PaError res;
+ if (!(console_tech.capabilities = ast_format_cap_alloc())) {
+ return AST_MODULE_LOAD_DECLINE;
+ }
+ ast_format_cap_add(console_tech.capabilities, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR16, 0));
+
init_pvt(&globals, NULL);
if (!(pvts = ao2_container_alloc(NUM_PVT_BUCKETS, pvt_hash_cb, pvt_cmp_cb)))