aboutsummaryrefslogtreecommitdiffstats
path: root/channels/chan_bridge.c
diff options
context:
space:
mode:
authordvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b>2011-02-03 16:22:10 +0000
committerdvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b>2011-02-03 16:22:10 +0000
commit4aca3187a3db25ff4d2208f116f618b363dec7d5 (patch)
tree00da0caa5a07b7b25729f089dbcafb08129fa9be /channels/chan_bridge.c
parent8170aae0a0882a93ca1ef80736cb95c2d6126865 (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: http://svn.digium.com/svn/asterisk/trunk@306010 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_bridge.c')
-rw-r--r--channels/chan_bridge.c32
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;
}