[asterisk-commits] dvossel: branch dvossel/fixtheworld_phase1_step3 r303195 - /team/dvossel/fixt...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Jan 20 15:39:18 CST 2011
Author: dvossel
Date: Thu Jan 20 15:39:14 2011
New Revision: 303195
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=303195
Log:
chan_mobile conversion to ast_format api
Modified:
team/dvossel/fixtheworld_phase1_step3/addons/chan_mobile.c
Modified: team/dvossel/fixtheworld_phase1_step3/addons/chan_mobile.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/addons/chan_mobile.c?view=diff&rev=303195&r1=303194&r2=303195
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/addons/chan_mobile.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/addons/chan_mobile.c Thu Jan 20 15:39:14 2011
@@ -71,7 +71,7 @@
#define DEVICE_FRAME_FORMAT AST_FORMAT_SLINEAR
#define CHANNEL_FRAME_SIZE 320
-static format_t prefformat = DEVICE_FRAME_FORMAT;
+static struct ast_format prefformat;
static int discovery_interval = 60; /* The device discovery interval, default 60 seconds. */
static pthread_t discovery_thread = AST_PTHREADT_NULL; /* The discovery thread */
@@ -196,7 +196,7 @@
static struct ast_channel *mbl_new(int state, struct mbl_pvt *pvt, char *cid_num,
const struct ast_channel *requestor);
-static struct ast_channel *mbl_request(const char *type, format_t format,
+static struct ast_channel *mbl_request(const char *type, struct ast_format_cap *cap,
const struct ast_channel *requestor, void *data, int *cause);
static int mbl_call(struct ast_channel *ast, char *dest, int timeout);
static int mbl_hangup(struct ast_channel *ast);
@@ -450,10 +450,9 @@
* channel stuff
*/
-static const struct ast_channel_tech mbl_tech = {
+static struct ast_channel_tech mbl_tech = {
.type = "Mobile",
.description = "Bluetooth Mobile Device Channel Driver",
- .capabilities = AST_FORMAT_SLINEAR,
.requester = mbl_request,
.call = mbl_call,
.hangup = mbl_hangup,
@@ -844,11 +843,11 @@
}
chn->tech = &mbl_tech;
- chn->nativeformats = prefformat;
- chn->rawreadformat = prefformat;
- chn->rawwriteformat = prefformat;
- chn->writeformat = prefformat;
- chn->readformat = prefformat;
+ ast_format_cap_add(chn->nativeformats, &prefformat);
+ ast_format_copy(&chn->rawreadformat, &prefformat);
+ ast_format_copy(&chn->rawwriteformat, &prefformat);
+ ast_format_copy(&chn->writeformat, &prefformat);
+ ast_format_copy(&chn->readformat, &prefformat);
chn->tech_pvt = pvt;
if (state == AST_STATE_RING)
@@ -867,7 +866,7 @@
return NULL;
}
-static struct ast_channel *mbl_request(const char *type, format_t format,
+static struct ast_channel *mbl_request(const char *type, struct ast_format_cap *cap,
const struct ast_channel *requestor, void *data, int *cause)
{
@@ -875,7 +874,6 @@
struct mbl_pvt *pvt;
char *dest_dev = NULL;
char *dest_num = NULL;
- format_t oldformat;
int group = -1;
if (!data) {
@@ -884,10 +882,9 @@
return NULL;
}
- oldformat = format;
- format &= (AST_FORMAT_SLINEAR);
- if (!format) {
- ast_log(LOG_WARNING, "Asked to get a channel of unsupported format '%s'\n", ast_getformatname(oldformat));
+ if (!(ast_format_cap_iscompatible(cap, &prefformat))) {
+ char tmp[256];
+ ast_log(LOG_WARNING, "Asked to get a channel of unsupported format '%s'\n", ast_getformatname_multiple(tmp, sizeof(tmp), cap));
*cause = AST_CAUSE_FACILITY_NOT_IMPLEMENTED;
return NULL;
}
@@ -1099,7 +1096,7 @@
memset(&pvt->fr, 0x00, sizeof(struct ast_frame));
pvt->fr.frametype = AST_FRAME_VOICE;
- pvt->fr.subclass.codec = DEVICE_FRAME_FORMAT;
+ ast_format_set(&pvt->fr.subclass.format, DEVICE_FRAME_FORMAT, 0);
pvt->fr.src = "Mobile";
pvt->fr.offset = AST_FRIENDLY_OFFSET;
pvt->fr.mallocd = 0;
@@ -4534,6 +4531,7 @@
if (sdp_session)
sdp_close(sdp_session);
+ mbl_tech.capabilities = ast_format_cap_destroy(mbl_tech.capabilities);
return 0;
}
@@ -4542,6 +4540,11 @@
int dev_id, s;
+ if (!(mbl_tech.capabilities = ast_format_cap_alloc())) {
+ return AST_MODULE_LOAD_DECLINE;
+ }
+ ast_format_set(&prefformat, DEVICE_FRAME_FORMAT, 0);
+ ast_format_cap_add(mbl_tech.capabilities, &prefformat);
/* Check if we have Bluetooth, no point loading otherwise... */
dev_id = hci_get_route(NULL);
s = hci_open_dev(dev_id);
More information about the asterisk-commits
mailing list