[asterisk-commits] tilghman: branch group/codec_bits r107155 - in /team/group/codec_bits: channe...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Mar 10 13:01:18 CDT 2008
Author: tilghman
Date: Mon Mar 10 13:01:17 2008
New Revision: 107155
URL: http://svn.digium.com/view/asterisk?view=rev&rev=107155
Log:
Commit some of the changes - not even 10% complete
Modified:
team/group/codec_bits/channels/chan_agent.c
team/group/codec_bits/channels/chan_iax2.c
team/group/codec_bits/channels/chan_sip.c
team/group/codec_bits/channels/chan_skinny.c
team/group/codec_bits/include/asterisk/channel.h
team/group/codec_bits/include/asterisk/frame.h
Modified: team/group/codec_bits/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/channels/chan_agent.c?view=diff&rev=107155&r1=107154&r2=107155
==============================================================================
--- team/group/codec_bits/channels/chan_agent.c (original)
+++ team/group/codec_bits/channels/chan_agent.c Mon Mar 10 13:01:17 2008
@@ -177,19 +177,22 @@
static AST_LIST_HEAD_STATIC(agents, agent_pvt); /*!< Holds the list of agents (loaded form agents.conf). */
#define CHECK_FORMATS(ast, p) do { \
+ struct ast_str *fromstr = NULL, *tostr = NULL; \
if (p->chan) {\
- if (ast->nativeformats != p->chan->nativeformats) { \
- ast_debug(1, "Native formats changing from %d to %d\n", ast->nativeformats, p->chan->nativeformats); \
+ if (memcmp(&ast->nativeformats, &p->chan->nativeformats, sizeof(ast->nativeformats))) { \
+ ast_debug(1, "Native formats changing from %s to %s\n", ast_codec2bitstring(ast->nativeformats, &fromstr), ast_codec2bitstring(p->chan->nativeformats, &tostr)); \
/* Native formats changed, reset things */ \
ast->nativeformats = p->chan->nativeformats; \
- ast_debug(1, "Resetting read to %d and write to %d\n", ast->readformat, ast->writeformat);\
+ ast_debug(1, "Resetting read to %s and write to %s\n", ast_codec2bitstring(ast->readformat, &fromstr), ast_codec2bitstring(ast->writeformat, &tostr));\
ast_set_read_format(ast, ast->readformat); \
ast_set_write_format(ast, ast->writeformat); \
} \
- if (p->chan->readformat != ast->rawreadformat && !p->chan->generator) \
+ if (memcmp(&p->chan->readformat, &ast->rawreadformat, sizeof(ast->rawreadformat)) && !p->chan->generator) \
ast_set_read_format(p->chan, ast->rawreadformat); \
- if (p->chan->writeformat != ast->rawwriteformat && !p->chan->generator) \
+ if (memcmp(&p->chan->writeformat, &ast->rawwriteformat, sizeof(ast->rawwriteformat)) && !p->chan->generator) \
ast_set_write_format(p->chan, ast->rawwriteformat); \
+ ast_free(fromstr); \
+ ast_free(tostr); \
} \
} while(0)
@@ -209,7 +212,7 @@
} while(0)
/*--- Forward declarations */
-static struct ast_channel *agent_request(const char *type, int format, void *data, int *cause);
+static struct ast_channel *agent_request(const char *type, const struct ast_extended_codec format, void *data, int *cause);
static int agent_devicestate(void *data);
static void agent_logoff_maintenance(struct agent_pvt *p, char *loginchan, long logintime, const char *uniqueid, char *logcommand);
static int agent_digit_begin(struct ast_channel *ast, char digit);
@@ -233,7 +236,7 @@
static const struct ast_channel_tech agent_tech = {
.type = "Agent",
.description = tdesc,
- .capabilities = -1,
+ .capabilities = { { -1, -1, -1, -1, -1, -1, -1, -1 }, { -1, -1, -1, -1, -1, -1, -1 }, -1 },
.requester = agent_request,
.devicestate = agent_devicestate,
.send_digit_begin = agent_digit_begin,
@@ -550,7 +553,7 @@
else {
if ((f->frametype != AST_FRAME_VOICE) ||
(f->frametype != AST_FRAME_VIDEO) ||
- (f->subclass == p->chan->writeformat)) {
+ (!memcmp(&f->codec, &p->chan->writeformat, sizeof(f->codec)))) {
res = ast_write(p->chan, f);
} else {
ast_debug(1, "Dropping one incompatible %s frame on '%s' to '%s'\n",
@@ -653,17 +656,17 @@
res = ast_set_read_format(p->chan, ast_best_codec(p->chan->nativeformats));
ast_debug(3, "Set read format, result '%d'\n", res);
if (res)
- ast_log(LOG_WARNING, "Unable to set read format to %s\n", ast_getformatname(ast_best_codec(p->chan->nativeformats)));
+ ast_log(LOG_WARNING, "Unable to set read format to %s\n", ast_getformatname(p->chan->nativeformats));
} else {
/* Agent hung-up */
p->chan = NULL;
}
if (!res) {
- res = ast_set_write_format(p->chan, ast_best_codec(p->chan->nativeformats));
+ res = ast_set_write_format(p->chan, p->chan->nativeformats);
ast_debug(3, "Set write format, result '%d'\n", res);
if (res)
- ast_log(LOG_WARNING, "Unable to set write format to %s\n", ast_getformatname(ast_best_codec(p->chan->nativeformats)));
+ ast_log(LOG_WARNING, "Unable to set write format to %s\n", ast_getformatname(p->chan->nativeformats));
}
if(!res) {
/* Call is immediately up, or might need ack */
@@ -950,11 +953,12 @@
ast_copy_string(tmp->exten, p->chan->exten, sizeof(tmp->exten));
/* XXX Is this really all we copy form the originating channel?? */
} else {
- tmp->nativeformats = AST_FORMAT_SLINEAR;
- tmp->writeformat = AST_FORMAT_SLINEAR;
- tmp->rawwriteformat = AST_FORMAT_SLINEAR;
- tmp->readformat = AST_FORMAT_SLINEAR;
- tmp->rawreadformat = AST_FORMAT_SLINEAR;
+ struct ast_extended_codec codec = { .audio[0] = AST_FORMAT_SLINEAR };
+ tmp->nativeformats = codec;
+ tmp->writeformat = codec;
+ tmp->rawwriteformat = codec;
+ tmp->readformat = codec;
+ tmp->rawreadformat = codec;
}
/* Safe, agentlock already held */
tmp->tech_pvt = p;
@@ -1269,7 +1273,7 @@
}
/*! \brief Part of the Asterisk PBX interface */
-static struct ast_channel *agent_request(const char *type, int format, void *data, int *cause)
+static struct ast_channel *agent_request(const char *type, const struct ast_extended_codec format, void *data, int *cause)
{
struct agent_pvt *p;
struct ast_channel *chan = NULL;
@@ -1948,14 +1952,22 @@
AST_LIST_LOCK(&agents);
ast_mutex_lock(&p->lock);
if (!res) {
- res = ast_set_read_format(chan, ast_best_codec(chan->nativeformats));
- if (res)
- ast_log(LOG_WARNING, "Unable to set read format to %d\n", ast_best_codec(chan->nativeformats));
+ struct ast_extended_codec codec = ast_best_codec(chan->nativeformats);
+ res = ast_set_read_format(chan, codec);
+ if (res) {
+ struct ast_str *str = NULL;
+ ast_log(LOG_WARNING, "Unable to set read format to %s\n", ast_codec2bitstring(codec, &str));
+ ast_free(str);
+ }
}
if (!res) {
- res = ast_set_write_format(chan, ast_best_codec(chan->nativeformats));
- if (res)
- ast_log(LOG_WARNING, "Unable to set write format to %d\n", ast_best_codec(chan->nativeformats));
+ struct ast_extended_codec codec = ast_best_codec(chan->nativeformats);
+ res = ast_set_write_format(chan, codec);
+ if (res) {
+ struct ast_str *str = NULL;
+ ast_log(LOG_WARNING, "Unable to set write format to %s\n", ast_codec2bitstring(codec, &str));
+ ast_free(str);
+ }
}
/* Check once more just in case */
if (p->chan)
Modified: team/group/codec_bits/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/channels/chan_iax2.c?view=diff&rev=107155&r1=107154&r2=107155
==============================================================================
--- team/group/codec_bits/channels/chan_iax2.c (original)
+++ team/group/codec_bits/channels/chan_iax2.c Mon Mar 10 13:01:17 2008
@@ -2718,7 +2718,7 @@
now = ast_tvdiff_ms(tv, pvt->rxcore);
if(now >= (next = jb_next(pvt->jb))) {
- ret = jb_get(pvt->jb,&frame,now,ast_codec_interp_len(pvt->voiceformat));
+ ret = jb_get(pvt->jb,&frame,now,ast_codec_interp_len(pvt->voiceformat, NULL));
switch(ret) {
case JB_OK:
fr = frame.data;
@@ -3170,7 +3170,7 @@
/* But move the calling channel's native codec to the top of the preference list */
memcpy(&ourprefs, &prefs, sizeof(ourprefs));
if (c)
- ast_codec_pref_prepend(&ourprefs, c->nativeformats, 1);
+ ast_codec_pref_prepend(&ourprefs, c->nativeformats, NULL, 1);
ast_codec_pref_convert(&ourprefs, cai->prefs, sizeof(cai->prefs), 1);
return 0;
}
@@ -3195,7 +3195,7 @@
/* Move the calling channel's native codec to the top of the preference list */
if (c) {
ast_log(LOG_DEBUG, "prepending %x to prefs\n", c->nativeformats);
- ast_codec_pref_prepend(&ourprefs, c->nativeformats, 1);
+ ast_codec_pref_prepend(&ourprefs, c->nativeformats, NULL, 1);
}
ast_codec_pref_convert(&ourprefs, cai->prefs, sizeof(cai->prefs), 1);
ast_copy_string(cai->context, peer->context, sizeof(cai->context));
@@ -8259,7 +8259,7 @@
} else
pref = iaxs[fr->callno]->prefs;
- format = ast_codec_choose(&pref, iaxs[fr->callno]->capability & iaxs[fr->callno]->peercapability, 0);
+ format = ast_codec_choose(&pref, iaxs[fr->callno]->capability & iaxs[fr->callno]->peercapability, NULL, 0);
ast_codec_pref_string(&iaxs[fr->callno]->rprefs, caller_pref_buf, sizeof(caller_pref_buf) - 1);
ast_codec_pref_string(&iaxs[fr->callno]->prefs, host_pref_buf, sizeof(host_pref_buf) - 1);
}
@@ -8303,7 +8303,7 @@
pref = iaxs[fr->callno]->rprefs;
using_prefs = "caller";
}
- format = ast_codec_choose(&pref, iaxs[fr->callno]->peercapability & iaxs[fr->callno]->capability, 1);
+ format = ast_codec_choose(&pref, iaxs[fr->callno]->peercapability & iaxs[fr->callno]->capability, NULL, 1);
} else /* if no codec_prefs IE do it the old way */
format = ast_best_codec(iaxs[fr->callno]->peercapability & iaxs[fr->callno]->capability);
@@ -8681,7 +8681,7 @@
} else /* if no codec_prefs IE do it the old way */
pref = iaxs[fr->callno]->prefs;
- format = ast_codec_choose(&pref, iaxs[fr->callno]->capability & iaxs[fr->callno]->peercapability, 0);
+ format = ast_codec_choose(&pref, iaxs[fr->callno]->capability & iaxs[fr->callno]->peercapability, NULL, 0);
ast_codec_pref_string(&iaxs[fr->callno]->rprefs, caller_pref_buf, sizeof(caller_pref_buf) - 1);
ast_codec_pref_string(&iaxs[fr->callno]->prefs, host_pref_buf, sizeof(host_pref_buf) - 1);
}
@@ -8728,7 +8728,7 @@
pref = iaxs[fr->callno]->rprefs;
using_prefs = "caller";
}
- format = ast_codec_choose(&pref, iaxs[fr->callno]->peercapability & iaxs[fr->callno]->capability, 1);
+ format = ast_codec_choose(&pref, iaxs[fr->callno]->peercapability & iaxs[fr->callno]->capability, NULL, 1);
} else /* if no codec_prefs IE do it the old way */
format = ast_best_codec(iaxs[fr->callno]->peercapability & iaxs[fr->callno]->capability);
}
@@ -10108,9 +10108,9 @@
} else if (!strcasecmp(v->name, "username")) {
ast_string_field_set(peer, username, v->value);
} else if (!strcasecmp(v->name, "allow")) {
- ast_parse_allow_disallow(&peer->prefs, &peer->capability, v->value, 1);
+ ast_parse_allow_disallow(&peer->prefs, &peer->capability, NULL, v->value, 1);
} else if (!strcasecmp(v->name, "disallow")) {
- ast_parse_allow_disallow(&peer->prefs, &peer->capability, v->value, 0);
+ ast_parse_allow_disallow(&peer->prefs, &peer->capability, NULL, v->value, 0);
} else if (!strcasecmp(v->name, "callerid")) {
if (!ast_strlen_zero(v->value)) {
char name2[80];
@@ -10302,9 +10302,9 @@
}
}
} else if (!strcasecmp(v->name, "allow")) {
- ast_parse_allow_disallow(&user->prefs, &user->capability, v->value, 1);
+ ast_parse_allow_disallow(&user->prefs, &user->capability, NULL, v->value, 1);
} else if (!strcasecmp(v->name, "disallow")) {
- ast_parse_allow_disallow(&user->prefs, &user->capability,v->value, 0);
+ ast_parse_allow_disallow(&user->prefs, &user->capability, NULL, v->value, 0);
} else if (!strcasecmp(v->name, "trunk")) {
ast_set2_flag(user, ast_true(v->value), IAX_TRUNK);
if (ast_test_flag(user, IAX_TRUNK) && (timingfd < 0)) {
@@ -10761,9 +10761,9 @@
} else
ast_log(LOG_WARNING, "bandwidth must be either low, medium, or high\n");
} else if (!strcasecmp(v->name, "allow")) {
- ast_parse_allow_disallow(&prefs, &capability, v->value, 1);
+ ast_parse_allow_disallow(&prefs, &capability, NULL, v->value, 1);
} else if (!strcasecmp(v->name, "disallow")) {
- ast_parse_allow_disallow(&prefs, &capability, v->value, 0);
+ ast_parse_allow_disallow(&prefs, &capability, NULL, v->value, 0);
} else if (!strcasecmp(v->name, "register")) {
iax2_register(v->value, v->lineno);
} else if (!strcasecmp(v->name, "iaxcompat")) {
Modified: team/group/codec_bits/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/channels/chan_sip.c?view=diff&rev=107155&r1=107154&r2=107155
==============================================================================
--- team/group/codec_bits/channels/chan_sip.c (original)
+++ team/group/codec_bits/channels/chan_sip.c Mon Mar 10 13:01:17 2008
@@ -5216,11 +5216,11 @@
}
/* Set the native formats for audio and merge in video */
- tmp->nativeformats = ast_codec_choose(&i->prefs, what, 1) | video | text;
+ tmp->nativeformats = ast_codec_choose(&i->prefs, what, NULL, 1) | video | text;
ast_debug(3, "*** Our native formats are %s \n", ast_getformatname_multiple(buf, SIPBUFSIZE, tmp->nativeformats));
ast_debug(3, "*** Joint capabilities are %s \n", ast_getformatname_multiple(buf, SIPBUFSIZE, i->jointcapability));
ast_debug(3, "*** Our capabilities are %s \n", ast_getformatname_multiple(buf, SIPBUFSIZE, i->capability));
- ast_debug(3, "*** AST_CODEC_CHOOSE formats are %s \n", ast_getformatname_multiple(buf, SIPBUFSIZE, ast_codec_choose(&i->prefs, what, 1)));
+ ast_debug(3, "*** AST_CODEC_CHOOSE formats are %s \n", ast_getformatname_multiple(buf, SIPBUFSIZE, ast_codec_choose(&i->prefs, what, NULL, 1)));
if (i->prefcodec)
ast_debug(3, "*** Our preferred formats from the incoming channel are %s \n", ast_getformatname_multiple(buf, SIPBUFSIZE, i->prefcodec));
@@ -6602,7 +6602,7 @@
if (!format) /* non-codec or not found */
continue;
ast_debug(1, "Setting framing for %d to %ld\n", format, framing);
- ast_codec_pref_setsize(pref, format, framing);
+ ast_codec_pref_setsize(pref, format, NULL, framing);
}
ast_rtp_codec_setpref(p->rtp, pref);
}
@@ -6858,7 +6858,7 @@
ast_getformatname_multiple(s1, SIPBUFSIZE, p->jointcapability),
ast_getformatname_multiple(s2, SIPBUFSIZE, p->owner->nativeformats));
}
- p->owner->nativeformats = ast_codec_choose(&p->prefs, p->jointcapability, 1) | (p->capability & vpeercapability) | (p->capability & tpeercapability);
+ p->owner->nativeformats = ast_codec_choose(&p->prefs, p->jointcapability, NULL, 1) | (p->capability & vpeercapability) | (p->capability & tpeercapability);
ast_set_read_format(p->owner, p->owner->readformat);
ast_set_write_format(p->owner, p->owner->writeformat);
}
@@ -7651,7 +7651,7 @@
if (p->rtp) {
struct ast_codec_pref *pref = ast_rtp_codec_getpref(p->rtp);
- fmt = ast_codec_pref_getsize(pref, codec);
+ fmt = ast_codec_pref_getsize(pref, codec, NULL);
} else /* I dont see how you couldn't have p->rtp, but good to check for and error out if not there like earlier code */
return;
ast_str_append(m_buf, 0, " %d", rtp_code);
@@ -19455,11 +19455,11 @@
user->amaflags = format;
}
} else if (!strcasecmp(v->name, "allow")) {
- int error = ast_parse_allow_disallow(&user->prefs, &user->capability, v->value, TRUE);
+ int error = ast_parse_allow_disallow(&user->prefs, &user->capability, NULL, v->value, TRUE);
if (error)
ast_log(LOG_WARNING, "Codec configuration errors found in line %d : %s = %s\n", v->lineno, v->name, v->value);
} else if (!strcasecmp(v->name, "disallow")) {
- int error = ast_parse_allow_disallow(&user->prefs, &user->capability, v->value, FALSE);
+ int error = ast_parse_allow_disallow(&user->prefs, &user->capability, NULL, v->value, FALSE);
if (error)
ast_log(LOG_WARNING, "Codec configuration errors found in line %d : %s = %s\n", v->lineno, v->name, v->value);
} else if (!strcasecmp(v->name, "autoframing")) {
@@ -19823,11 +19823,11 @@
} else if (!strcasecmp(v->name, "pickupgroup")) {
peer->pickupgroup = ast_get_group(v->value);
} else if (!strcasecmp(v->name, "allow")) {
- int error = ast_parse_allow_disallow(&peer->prefs, &peer->capability, v->value, TRUE);
+ int error = ast_parse_allow_disallow(&peer->prefs, &peer->capability, NULL, v->value, TRUE);
if (error)
ast_log(LOG_WARNING, "Codec configuration errors found in line %d : %s = %s\n", v->lineno, v->name, v->value);
} else if (!strcasecmp(v->name, "disallow")) {
- int error = ast_parse_allow_disallow(&peer->prefs, &peer->capability, v->value, FALSE);
+ int error = ast_parse_allow_disallow(&peer->prefs, &peer->capability, NULL, v->value, FALSE);
if (error)
ast_log(LOG_WARNING, "Codec configuration errors found in line %d : %s = %s\n", v->lineno, v->name, v->value);
} else if (!strcasecmp(v->name, "registertrying")) {
@@ -20393,11 +20393,11 @@
externrefresh = 10;
}
} else if (!strcasecmp(v->name, "allow")) {
- int error = ast_parse_allow_disallow(&default_prefs, &global_capability, v->value, TRUE);
+ int error = ast_parse_allow_disallow(&default_prefs, &global_capability, NULL, v->value, TRUE);
if (error)
ast_log(LOG_WARNING, "Codec configuration errors found in line %d : %s = %s\n", v->lineno, v->name, v->value);
} else if (!strcasecmp(v->name, "disallow")) {
- int error = ast_parse_allow_disallow(&default_prefs, &global_capability, v->value, FALSE);
+ int error = ast_parse_allow_disallow(&default_prefs, &global_capability, NULL, v->value, FALSE);
if (error)
ast_log(LOG_WARNING, "Codec configuration errors found in line %d : %s = %s\n", v->lineno, v->name, v->value);
} else if (!strcasecmp(v->name, "autoframing")) {
Modified: team/group/codec_bits/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/channels/chan_skinny.c?view=diff&rev=107155&r1=107154&r2=107155
==============================================================================
--- team/group/codec_bits/channels/chan_skinny.c (original)
+++ team/group/codec_bits/channels/chan_skinny.c Mon Mar 10 13:01:17 2008
@@ -1891,7 +1891,7 @@
if (!(req = req_alloc(sizeof(struct open_receive_channel_message), OPEN_RECEIVE_CHANNEL_MESSAGE)))
return;
- fmt = ast_codec_pref_getsize(&l->prefs, ast_best_codec(l->capability));
+ fmt = ast_codec_pref_getsize(&l->prefs, ast_best_codec(l->capability), NULL);
req->data.openreceivechannel.conferenceId = htolel(sub->callid);
req->data.openreceivechannel.partyId = htolel(sub->callid);
@@ -2338,7 +2338,7 @@
if (!(req = req_alloc(sizeof(struct start_media_transmission_message), START_MEDIA_TRANSMISSION_MESSAGE)))
return -1;
- fmt = ast_codec_pref_getsize(&l->prefs, ast_best_codec(l->capability));
+ fmt = ast_codec_pref_getsize(&l->prefs, ast_best_codec(l->capability), NULL);
if (skinnydebug)
ast_debug(1, "Setting payloadType to '%d' (%d ms)\n", fmt.bits, fmt.cur_ms);
@@ -2921,9 +2921,9 @@
} else if (!strcasecmp(v->name, "regexten")) {
ast_copy_string(regexten, v->value, sizeof(regexten));
} else if (!strcasecmp(v->name, "allow")) {
- ast_parse_allow_disallow(&d->prefs, &d->capability, v->value, 1);
+ ast_parse_allow_disallow(&d->prefs, &d->capability, NULL, v->value, 1);
} else if (!strcasecmp(v->name, "disallow")) {
- ast_parse_allow_disallow(&d->prefs, &d->capability, v->value, 0);
+ ast_parse_allow_disallow(&d->prefs, &d->capability, NULL, v->value, 0);
} else if (!strcasecmp(v->name, "version")) {
ast_copy_string(d->version_id, v->value, sizeof(d->version_id));
} else if (!strcasecmp(v->name, "canreinvite")) {
@@ -4813,7 +4813,7 @@
if (!(req = req_alloc(sizeof(struct start_media_transmission_message), START_MEDIA_TRANSMISSION_MESSAGE)))
return -1;
- fmt = ast_codec_pref_getsize(&l->prefs, ast_best_codec(l->capability));
+ fmt = ast_codec_pref_getsize(&l->prefs, ast_best_codec(l->capability), NULL);
if (skinnydebug)
ast_debug(1, "Setting payloadType to '%d' (%d ms)\n", fmt.bits, fmt.cur_ms);
@@ -5825,9 +5825,9 @@
if (ast_str2cos(v->value, &cos_video))
ast_log(LOG_WARNING, "Invalid cos_video value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "allow")) {
- ast_parse_allow_disallow(&default_prefs, &default_capability, v->value, 1);
+ ast_parse_allow_disallow(&default_prefs, &default_capability, NULL, v->value, 1);
} else if (!strcasecmp(v->name, "disallow")) {
- ast_parse_allow_disallow(&default_prefs, &default_capability, v->value, 0);
+ ast_parse_allow_disallow(&default_prefs, &default_capability, NULL, v->value, 0);
} else if (!strcasecmp(v->name, "bindport")) {
if (sscanf(v->value, "%d", &ourport) == 1) {
bindaddr.sin_port = htons(ourport);
Modified: team/group/codec_bits/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/include/asterisk/channel.h?view=diff&rev=107155&r1=107154&r2=107155
==============================================================================
--- team/group/codec_bits/include/asterisk/channel.h (original)
+++ team/group/codec_bits/include/asterisk/channel.h Mon Mar 10 13:01:17 2008
@@ -245,12 +245,12 @@
const char * const type;
const char * const description;
- int capabilities; /*!< Bitmap of formats this channel can handle */
+ struct ast_extended_codec capabilities; /*!< Bitmap of formats this channel can handle */
int properties; /*!< Technology Properties */
/*! \brief Requester - to set up call data structures (pvt's) */
- struct ast_channel *(* const requester)(const char *type, int format, void *data, int *cause);
+ struct ast_channel *(* const requester)(const char *type, const struct ast_extended_codec format, void *data, int *cause);
int (* const devicestate)(void *data); /*!< Devicestate call back */
@@ -452,7 +452,7 @@
struct ast_filestream *stream; /*!< Stream itself. */
int vstreamid; /*!< For streaming video playback, the schedule ID */
struct ast_filestream *vstream; /*!< Video Stream itself. */
- int oldwriteformat; /*!< Original writer format */
+ struct ast_extended_codec oldwriteformat; /*!< Original writer format */
int timingfd; /*!< Timing fd */
int (*timingfunc)(const void *data);
@@ -498,13 +498,13 @@
AST_LIST_HEAD_NOLOCK(, ast_frame) readq;
int alertpipe[2];
- int nativeformats; /*!< Kinds of data this channel can natively handle */
- int readformat; /*!< Requested read format */
- int writeformat; /*!< Requested write format */
+ struct ast_extended_codec nativeformats; /*!< Kinds of data this channel can natively handle */
+ struct ast_extended_codec readformat; /*!< Requested read format */
+ struct ast_extended_codec writeformat; /*!< Requested write format */
struct ast_trans_pvt *writetrans; /*!< Write translation path */
struct ast_trans_pvt *readtrans; /*!< Read translation path */
- int rawreadformat; /*!< Raw read format */
- int rawwriteformat; /*!< Raw write format */
+ struct ast_extended_codec rawreadformat; /*!< Raw read format */
+ struct ast_extended_codec rawwriteformat; /*!< Raw write format */
struct ast_audiohook_list *audiohooks;
@@ -781,7 +781,7 @@
* \retval NULL failure
* \retval non-NULL channel on success
*/
-struct ast_channel *ast_request(const char *type, int format, void *data, int *status);
+struct ast_channel *ast_request(const char *type, const struct ast_extended_codec format, void *data, int *status);
/*!
* \brief Request a channel of a given type, with data as optional information used
@@ -798,7 +798,7 @@
* \return Returns an ast_channel on success or no answer, NULL on failure. Check the value of chan->_state
* to know if the call was answered or not.
*/
-struct ast_channel *ast_request_and_dial(const char *type, int format, void *data,
+struct ast_channel *ast_request_and_dial(const char *type, const struct ast_extended_codec format, void *data,
int timeout, int *reason, const char *cid_num, const char *cid_name);
/*!
@@ -815,7 +815,7 @@
* \return Returns an ast_channel on success or no answer, NULL on failure. Check the value of chan->_state
* to know if the call was answered or not.
*/
-struct ast_channel *__ast_request_and_dial(const char *type, int format, void *data,
+struct ast_channel *__ast_request_and_dial(const char *type, const struct ast_extended_codec format, void *data,
int timeout, int *reason, const char *cid_num, const char *cid_name, struct outgoing_helper *oh);
/*!\brief Register a channel technology (a new channel driver)
@@ -1078,7 +1078,7 @@
* \param format format to change to
* \return Returns 0 on success, -1 on failure
*/
-int ast_set_read_format(struct ast_channel *chan, int format);
+int ast_set_read_format(struct ast_channel *chan, struct ast_extended_codec ecodec);
/*! \brief Sets write format on channel chan
* Set write format for channel to whichever component of "format" is best.
@@ -1086,7 +1086,7 @@
* \param format new format for writing
* \return Returns 0 on success, -1 on failure
*/
-int ast_set_write_format(struct ast_channel *chan, int format);
+int ast_set_write_format(struct ast_channel *chan, struct ast_extended_codec ecodec);
/*!
* \brief Sends text to a channel
@@ -1306,8 +1306,10 @@
/*! Pick the best codec */
/* Choose the best codec... Uhhh... Yah. */
-int ast_best_codec(int fmts);
-
+struct ast_extended_codec ast_best_codec(struct ast_extended_codec ecodec);
+
+/*! Convert the bitfield into an array of integers, for printing */
+const char *ast_codec2bitstring(struct ast_extended_codec ecodec, struct ast_str **str);
/*! Checks the value of an option */
/*!
Modified: team/group/codec_bits/include/asterisk/frame.h
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/include/asterisk/frame.h?view=diff&rev=107155&r1=107154&r2=107155
==============================================================================
--- team/group/codec_bits/include/asterisk/frame.h (original)
+++ team/group/codec_bits/include/asterisk/frame.h Mon Mar 10 13:01:17 2008
@@ -37,6 +37,12 @@
struct ast_codec_pref {
char order[32];
char framing[32];
+};
+
+struct ast_extended_codec {
+ int audio[8]; /* 256 bits */
+ int video[7]; /* 224 bits */
+ int image; /* 32 bits */
};
/*! \page Def_Frame AST Multimedia and signalling frames
@@ -165,6 +171,8 @@
long len;
/*! Sequence number */
int seqno;
+ /*! 512-bit bitfield for codec type */
+ struct ast_extended_codec codec;
};
/*!
@@ -381,7 +389,7 @@
/*! \brief Definition of supported media formats (codecs) */
struct ast_format_list {
- int bits; /*!< bitmask value */
+ struct ast_extended_codec bits; /*!< bitmask value */
char *name; /*!< short name */
int samplespersecond; /*!< Number of samples per second (8000/16000) */
char *desc; /*!< Description */
@@ -449,7 +457,7 @@
* \param format id of format
* \return A static string containing the name of the format or "unknown" if unknown.
*/
-char* ast_getformatname(int format);
+char* ast_getformatname(struct ast_extended_codec format);
/*! \brief Get the names of a set of formats
* \param buf a buffer for the output string
@@ -459,21 +467,22 @@
* ex: for format=AST_FORMAT_GSM|AST_FORMAT_SPEEX|AST_FORMAT_ILBC it will return "0x602 (GSM|SPEEX|ILBC)"
* \return The return value is buf.
*/
-char* ast_getformatname_multiple(char *buf, size_t size, int format);
+char* ast_getformatname_multiple(char *buf, size_t size, struct ast_extended_codec format);
/*!
* \brief Gets a format from a name.
* \param name string of format
* \return This returns the form of the format in binary on success, 0 on error.
*/
-int ast_getformatbyname(const char *name);
+struct ast_extended_codec ast_getformatbyname(const char *name);
/*! \brief Get a name from a format
* Gets a name from a format
* \param codec codec number (1,2,4,8,16,etc.)
+ * \param ecodec Extended codec bitfield
* \return This returns a static string identifying the format on success, 0 on error.
*/
-char *ast_codec2str(int codec);
+char *ast_codec2str(struct ast_extended_codec ecodec);
/*! \name AST_Smoother
*/
@@ -541,36 +550,36 @@
*/
int ast_codec_pref_index(struct ast_codec_pref *pref, int index);
-/*! \brief Remove audio a codec from a preference list */
-void ast_codec_pref_remove(struct ast_codec_pref *pref, int format);
-
-/*! \brief Append a audio codec to a preference list, removing it first if it was already there
-*/
-int ast_codec_pref_append(struct ast_codec_pref *pref, int format);
+/*! \brief Remove an audio codec from a preference list */
+void ast_codec_pref_remove(struct ast_codec_pref *pref, struct ast_extended_codec ecodec);
+
+/*! \brief Append an audio codec to a preference list, removing it first if it was already there
+*/
+int ast_codec_pref_append(struct ast_codec_pref *pref, struct ast_extended_codec ecodec);
/*! \brief Prepend an audio codec to a preference list, removing it first if it was already there
*/
-void ast_codec_pref_prepend(struct ast_codec_pref *pref, int format, int only_if_existing);
+void ast_codec_pref_prepend(struct ast_codec_pref *pref, struct ast_extended_codec ecodec, int only_if_existing);
/*! \brief Select the best audio format according to preference list from supplied options.
If "find_best" is non-zero then if nothing is found, the "Best" format of
the format list is selected, otherwise 0 is returned. */
-int ast_codec_choose(struct ast_codec_pref *pref, int formats, int find_best);
+int ast_codec_choose(struct ast_codec_pref *pref, struct ast_extended_codec ecodec, int find_best);
/*! \brief Set packet size for codec
*/
-int ast_codec_pref_setsize(struct ast_codec_pref *pref, int format, int framems);
+int ast_codec_pref_setsize(struct ast_codec_pref *pref, struct ast_extended_codec ecodec, int framems);
/*! \brief Get packet size for codec
*/
-struct ast_format_list ast_codec_pref_getsize(struct ast_codec_pref *pref, int format);
+struct ast_format_list ast_codec_pref_getsize(struct ast_codec_pref *pref, struct ast_extended_codec ecodec);
/*! \brief Parse an "allow" or "deny" line in a channel or device configuration
and update the capabilities mask and pref if provided.
Video codecs are not added to codec preference lists, since we can not transcode
\return Returns number of errors encountered during parsing
*/
-int ast_parse_allow_disallow(struct ast_codec_pref *pref, int *mask, const char *list, int allowing);
+int ast_parse_allow_disallow(struct ast_codec_pref *pref, struct ast_extended_codec *ecodec_mask, const char *list, int allowing);
/*! \brief Dump audio codec preference list into a string */
int ast_codec_pref_string(struct ast_codec_pref *pref, char *buf, size_t size);
@@ -582,16 +591,16 @@
int ast_codec_get_samples(struct ast_frame *f);
/*! \brief Returns the number of bytes for the number of samples of the given format */
-int ast_codec_get_len(int format, int samples);
+int ast_codec_get_len(struct ast_extended_codec ecodec, int samples);
/*! \brief Appends a frame to the end of a list of frames, truncating the maximum length of the list */
struct ast_frame *ast_frame_enqueue(struct ast_frame *head, struct ast_frame *f, int maxlen, int dupe);
/*! \brief Gets duration in ms of interpolation frame for a format */
-static inline int ast_codec_interp_len(int format)
+static inline int ast_codec_interp_len(struct ast_extended_codec ecodec)
{
- return (format == AST_FORMAT_ILBC) ? 30 : 20;
+ return (ecodec.audio[0] == AST_FORMAT_ILBC) ? 30 : 20;
}
/*!
More information about the asterisk-commits
mailing list