diff options
Diffstat (limited to 'channels/chan_console.c')
-rw-r--r-- | channels/chan_console.c | 33 |
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))) |