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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jan 18 11:47:25 CST 2011


Author: dvossel
Date: Tue Jan 18 11:47:21 2011
New Revision: 302171

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=302171
Log:
conversion of chan_bridge.c to ast_format api

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

Modified: team/dvossel/fixtheworld_phase1_step3/channels/chan_bridge.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/channels/chan_bridge.c?view=diff&rev=302171&r1=302170&r2=302171
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/channels/chan_bridge.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/channels/chan_bridge.c Tue Jan 18 11:47:21 2011
@@ -46,17 +46,16 @@
 #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 @@
 }
 
 /*! \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 @@
 	/* 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 @@
 /*! \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 unload_module(void)
 {
 	ast_channel_unregister(&bridge_tech);
+	bridge_tech.capabilities = ast_format_cap_destroy(bridge_tech.capabilities);
 	return 0;
 }
 




More information about the asterisk-commits mailing list