aboutsummaryrefslogtreecommitdiffstats
path: root/addons/chan_mobile.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 /addons/chan_mobile.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 'addons/chan_mobile.c')
-rw-r--r--addons/chan_mobile.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/addons/chan_mobile.c b/addons/chan_mobile.c
index 29d14e036..dd48f933e 100644
--- a/addons/chan_mobile.c
+++ b/addons/chan_mobile.c
@@ -71,7 +71,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#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 char *mblsendsms_desc =
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 @@ static struct msg_queue_entry *msg_queue_head(struct mbl_pvt *pvt);
* 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 @@ static struct ast_channel *mbl_new(int state, struct mbl_pvt *pvt, char *cid_num
}
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 @@ e_return:
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 @@ static struct ast_channel *mbl_request(const char *type, format_t format,
struct mbl_pvt *pvt;
char *dest_dev = NULL;
char *dest_num = NULL;
- format_t oldformat;
int group = -1;
if (!data) {
@@ -884,10 +882,9 @@ static struct ast_channel *mbl_request(const char *type, format_t format,
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 @@ static struct ast_frame *mbl_read(struct ast_channel *ast)
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 @@ static int unload_module(void)
if (sdp_session)
sdp_close(sdp_session);
+ mbl_tech.capabilities = ast_format_cap_destroy(mbl_tech.capabilities);
return 0;
}
@@ -4542,6 +4540,11 @@ static int load_module(void)
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);