summaryrefslogtreecommitdiff
path: root/channels/chan_oss.c
diff options
context:
space:
mode:
authorDavid Vossel <dvossel@digium.com>2011-02-03 16:22:10 +0000
committerDavid Vossel <dvossel@digium.com>2011-02-03 16:22:10 +0000
commitc26c190711a1bbe3b5fff1a93facae333757c56e (patch)
tree00da0caa5a07b7b25729f089dbcafb08129fa9be /channels/chan_oss.c
parent652fb64a01c7a8656697d07e606620ee0ced6929 (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: https://origsvn.digium.com/svn/asterisk/trunk@306010 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_oss.c')
-rw-r--r--channels/chan_oss.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/channels/chan_oss.c b/channels/chan_oss.c
index 3c4f2c943..10b0ed0fd 100644
--- a/channels/chan_oss.c
+++ b/channels/chan_oss.c
@@ -326,7 +326,7 @@ static struct chan_oss_pvt oss_default = {
static int setformat(struct chan_oss_pvt *o, int mode);
-static struct ast_channel *oss_request(const char *type, format_t format, const struct ast_channel *requestor,
+static struct ast_channel *oss_request(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor,
void *data, int *cause);
static int oss_digit_begin(struct ast_channel *c, char digit);
static int oss_digit_end(struct ast_channel *c, char digit, unsigned int duration);
@@ -344,7 +344,6 @@ static char tdesc[] = "OSS Console Channel Driver";
static struct ast_channel_tech oss_tech = {
.type = "Console",
.description = tdesc,
- .capabilities = AST_FORMAT_SLINEAR, /* overwritten later */
.requester = oss_request,
.send_digit_begin = oss_digit_begin,
.send_digit_end = oss_digit_end,
@@ -719,7 +718,7 @@ static struct ast_frame *oss_read(struct ast_channel *c)
return f;
/* ok we can build and deliver the frame to the caller */
f->frametype = AST_FRAME_VOICE;
- f->subclass.codec = AST_FORMAT_SLINEAR;
+ ast_format_set(&f->subclass.format, AST_FORMAT_SLINEAR, 0);
f->samples = FRAME_SIZE;
f->datalen = FRAME_SIZE * 2;
f->data.ptr = o->oss_read_buf + AST_FRIENDLY_OFFSET;
@@ -794,13 +793,15 @@ static struct ast_channel *oss_new(struct chan_oss_pvt *o, char *ext, char *ctx,
if (o->sounddev < 0)
setformat(o, O_RDWR);
ast_channel_set_fd(c, 0, o->sounddev); /* -1 if device closed, override later */
- c->nativeformats = AST_FORMAT_SLINEAR;
+
+ ast_format_set(&c->readformat, AST_FORMAT_SLINEAR, 0);
+ ast_format_set(&c->writeformat, AST_FORMAT_SLINEAR, 0);
+ ast_format_cap_add(c->nativeformats, &c->readformat);
+
/* if the console makes the call, add video to the offer */
- if (state == AST_STATE_RINGING)
- c->nativeformats |= console_video_formats;
+ /* if (state == AST_STATE_RINGING) TODO XXX CONSOLE VIDEO IS DISABLED UNTIL IT GETS A MAINTAINER
+ c->nativeformats |= console_video_formats; */
- c->readformat = AST_FORMAT_SLINEAR;
- c->writeformat = AST_FORMAT_SLINEAR;
c->tech_pvt = o;
if (!ast_strlen_zero(o->language))
@@ -830,7 +831,7 @@ static struct ast_channel *oss_new(struct chan_oss_pvt *o, char *ext, char *ctx,
return c;
}
-static struct ast_channel *oss_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
+static struct ast_channel *oss_request(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, void *data, int *cause)
{
struct ast_channel *c;
struct chan_oss_pvt *o;
@@ -840,6 +841,7 @@ static struct ast_channel *oss_request(const char *type, format_t format, const
);
char *parse = ast_strdupa(data);
char buf[256];
+ struct ast_format tmpfmt;
AST_NONSTANDARD_APP_ARGS(args, parse, '/');
o = find_desc(args.name);
@@ -850,8 +852,8 @@ static struct ast_channel *oss_request(const char *type, format_t format, const
/* XXX we could default to 'dsp' perhaps ? */
return NULL;
}
- if ((format & AST_FORMAT_SLINEAR) == 0) {
- ast_log(LOG_NOTICE, "Format %s unsupported\n", ast_getformatname_multiple(buf, sizeof(buf), format));
+ if (!(ast_format_cap_iscompatible(cap, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0)))) {
+ ast_log(LOG_NOTICE, "Format %s unsupported\n", ast_getformatname_multiple(buf, sizeof(buf), cap));
return NULL;
}
if (o->owner) {
@@ -1437,6 +1439,7 @@ static int load_module(void)
struct ast_config *cfg = NULL;
char *ctg = NULL;
struct ast_flags config_flags = { 0 };
+ struct ast_format tmpfmt;
/* Copy the default jb config over global_jbconf */
memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf));
@@ -1463,7 +1466,13 @@ static int load_module(void)
return AST_MODULE_LOAD_FAILURE;
}
- oss_tech.capabilities |= console_video_formats;
+ if (!(oss_tech.capabilities = ast_format_cap_alloc())) {
+ return AST_MODULE_LOAD_FAILURE;
+ }
+ ast_format_cap_add(oss_tech.capabilities, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));
+
+ /* TODO XXX CONSOLE VIDEO IS DISABLE UNTIL IT HAS A MAINTAINER
+ * add console_video_formats to oss_tech.capabilities once this occurs. */
if (ast_channel_register(&oss_tech)) {
ast_log(LOG_ERROR, "Unable to register channel type 'OSS'\n");
@@ -1495,6 +1504,7 @@ static int unload_module(void)
ast_free(o);
o = next;
}
+ oss_tech.capabilities = ast_format_cap_destroy(oss_tech.capabilities);
return 0;
}