diff options
Diffstat (limited to 'channels/chan_bridge.c')
-rw-r--r-- | channels/chan_bridge.c | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/channels/chan_bridge.c b/channels/chan_bridge.c index 8218bdceb..a58cfcc59 100644 --- a/channels/chan_bridge.c +++ b/channels/chan_bridge.c @@ -46,17 +46,16 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/app.h" #include "asterisk/bridging.h" -static struct ast_channel *bridge_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause); +static struct ast_channel *bridge_request(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, void *data, int *cause); static int bridge_call(struct ast_channel *ast, char *dest, int timeout); static int bridge_hangup(struct ast_channel *ast); static struct ast_frame *bridge_read(struct ast_channel *ast); static int bridge_write(struct ast_channel *ast, struct ast_frame *f); static struct ast_channel *bridge_bridgedchannel(struct ast_channel *chan, struct ast_channel *bridge); -static const struct ast_channel_tech bridge_tech = { +static struct ast_channel_tech bridge_tech = { .type = "Bridge", .description = "Bridge Interaction Channel", - .capabilities = -1, .requester = bridge_request, .call = bridge_call, .hangup = bridge_hangup, @@ -189,9 +188,10 @@ static int bridge_hangup(struct ast_channel *ast) } /*! \brief Called when we want to place a call somewhere, but not actually call it... yet */ -static struct ast_channel *bridge_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause) +static struct ast_channel *bridge_request(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, void *data, int *cause) { struct bridge_pvt *p = NULL; + struct ast_format slin; /* Try to allocate memory for our very minimal pvt structure */ if (!(p = ast_calloc(1, sizeof(*p)))) { @@ -215,11 +215,19 @@ static struct ast_channel *bridge_request(const char *type, format_t format, con /* Setup parameters on both new channels */ p->input->tech = p->output->tech = &bridge_tech; p->input->tech_pvt = p->output->tech_pvt = p; - p->input->nativeformats = p->output->nativeformats = AST_FORMAT_SLINEAR; - p->input->readformat = p->output->readformat = AST_FORMAT_SLINEAR; - p->input->rawreadformat = p->output->rawreadformat = AST_FORMAT_SLINEAR; - p->input->writeformat = p->output->writeformat = AST_FORMAT_SLINEAR; - p->input->rawwriteformat = p->output->rawwriteformat = AST_FORMAT_SLINEAR; + + ast_format_set(&slin, AST_FORMAT_SLINEAR, 0); + + ast_format_cap_add(p->input->nativeformats, &slin); + ast_format_cap_add(p->output->nativeformats, &slin); + ast_format_copy(&p->input->readformat, &slin); + ast_format_copy(&p->output->readformat, &slin); + ast_format_copy(&p->input->rawreadformat, &slin); + ast_format_copy(&p->output->rawreadformat, &slin); + ast_format_copy(&p->input->writeformat, &slin); + ast_format_copy(&p->output->writeformat, &slin); + ast_format_copy(&p->input->rawwriteformat, &slin); + ast_format_copy(&p->output->rawwriteformat, &slin); return p->input; } @@ -227,6 +235,11 @@ static struct ast_channel *bridge_request(const char *type, format_t format, con /*! \brief Load module into PBX, register channel */ static int load_module(void) { + if (!(bridge_tech.capabilities = ast_format_cap_alloc())) { + return AST_MODULE_LOAD_FAILURE; + } + + ast_format_cap_add_all(bridge_tech.capabilities); /* Make sure we can register our channel type */ if (ast_channel_register(&bridge_tech)) { ast_log(LOG_ERROR, "Unable to register channel class 'Bridge'\n"); @@ -239,6 +252,7 @@ static int load_module(void) static int unload_module(void) { ast_channel_unregister(&bridge_tech); + bridge_tech.capabilities = ast_format_cap_destroy(bridge_tech.capabilities); return 0; } |