[asterisk-commits] dvossel: branch dvossel/fixtheworld_phase1_step3 r305128 - in /team/dvossel/f...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Jan 31 12:31:22 CST 2011
Author: dvossel
Date: Mon Jan 31 12:31:17 2011
New Revision: 305128
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=305128
Log:
introduction of the ast_format_cap_set function
Modified:
team/dvossel/fixtheworld_phase1_step3/addons/chan_ooh323.c
team/dvossel/fixtheworld_phase1_step3/channels/chan_h323.c
team/dvossel/fixtheworld_phase1_step3/channels/chan_iax2.c
team/dvossel/fixtheworld_phase1_step3/channels/chan_mgcp.c
team/dvossel/fixtheworld_phase1_step3/channels/chan_phone.c
team/dvossel/fixtheworld_phase1_step3/channels/chan_sip.c
team/dvossel/fixtheworld_phase1_step3/channels/chan_skinny.c
team/dvossel/fixtheworld_phase1_step3/channels/chan_unistim.c
team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_cap.h
team/dvossel/fixtheworld_phase1_step3/main/channel.c
team/dvossel/fixtheworld_phase1_step3/main/format_cap.c
team/dvossel/fixtheworld_phase1_step3/res/res_calendar.c
Modified: team/dvossel/fixtheworld_phase1_step3/addons/chan_ooh323.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/addons/chan_ooh323.c?view=diff&rev=305128&r1=305127&r2=305128
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/addons/chan_ooh323.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/addons/chan_ooh323.c Mon Jan 31 12:31:17 2011
@@ -1457,8 +1457,7 @@
p->rtp, p->dtmfcodec, "audio", "cisco-telephone-event", 0);
}
- ast_format_cap_remove_all(p->owner->nativeformats);
- ast_format_cap_add(p->owner->nativeformats, fmt);
+ ast_format_cap_set(p->owner->nativeformats, fmt);
ast_set_write_format(p->owner, &p->owner->writeformat);
ast_set_read_format(p->owner, &p->owner->readformat);
ast_channel_unlock(p->owner);
@@ -1504,8 +1503,7 @@
if (gH323Debug)
ast_verbose("Readformat before update %s\n",
ast_getformatname(&p->owner->readformat));
- ast_format_cap_remove_all(p->owner->nativeformats);
- ast_format_cap_add(p->owner->nativeformats, fmt);
+ ast_format_cap_set(p->owner->nativeformats, fmt);
ast_set_read_format(p->owner, &p->owner->readformat);
ast_channel_unlock(p->owner);
} else
@@ -2522,8 +2520,7 @@
gPort = 1720;
gIP[0] = '\0';
strcpy(gCallerID, DEFAULT_H323ID);
- ast_format_cap_remove_all(gCap);
- ast_format_cap_add(gCap, ast_format_set(&tmpfmt, AST_FORMAT_ALAW, 0));
+ ast_format_cap_set(gCap, ast_format_set(&tmpfmt, AST_FORMAT_ALAW, 0));
memset(&gPrefs, 0, sizeof(struct ast_codec_pref));
gDTMFMode = H323_DTMF_RFC2833;
gDTMFCodec = 101;
@@ -4267,8 +4264,7 @@
if (f->frametype == AST_FRAME_VOICE && !p->faxmode) {
if (!(ast_format_cap_iscompatible(p->owner->nativeformats, &f->subclass.format))) {
ast_debug(1, "Oooh, voice format changed to %s\n", ast_getformatname(&f->subclass.format));
- ast_format_cap_remove_all(p->owner->nativeformats);
- ast_format_cap_add(p->owner->nativeformats, &f->subclass.format);
+ ast_format_cap_set(p->owner->nativeformats, &f->subclass.format);
ast_set_read_format(p->owner, &p->owner->readformat);
ast_set_write_format(p->owner, &p->owner->writeformat);
}
Modified: team/dvossel/fixtheworld_phase1_step3/channels/chan_h323.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/channels/chan_h323.c?view=diff&rev=305128&r1=305127&r2=305128
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/channels/chan_h323.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/channels/chan_h323.c Mon Jan 31 12:31:17 2011
@@ -780,8 +780,7 @@
}
if (h323debug)
ast_debug(1, "Oooh, format changed to '%s'\n", ast_getformatname(&f->subclass.format));
- ast_format_cap_remove_all(pvt->owner->nativeformats);
- ast_format_cap_add(pvt->owner->nativeformats, &f->subclass.format);
+ ast_format_cap_set(pvt->owner->nativeformats, &f->subclass.format);
pvt->nativeformats = ast_format_to_old_bitfield(&f->subclass.format);
@@ -1049,8 +1048,7 @@
ast_format_cap_from_old_bitfield(ch->nativeformats, fmt);
ast_codec_choose(&pvt->options.prefs, ch->nativeformats, 1, &tmpfmt)/* | (pvt->jointcapability & AST_FORMAT_VIDEO_MASK)*/;
- ast_format_cap_remove_all(ch->nativeformats);
- ast_format_cap_add(ch->nativeformats, &tmpfmt);
+ ast_format_cap_set(ch->nativeformats, &tmpfmt);
pvt->nativeformats = ast_format_cap_to_old_bitfield(ch->nativeformats);
ast_best_codec(ch->nativeformats, &tmpfmt);
Modified: team/dvossel/fixtheworld_phase1_step3/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/channels/chan_iax2.c?view=diff&rev=305128&r1=305127&r2=305128
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/channels/chan_iax2.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/channels/chan_iax2.c Mon Jan 31 12:31:17 2011
@@ -10370,8 +10370,7 @@
struct ast_format_cap *orignative = ast_format_cap_dup(iaxs[fr->callno]->owner->nativeformats);
struct ast_format_cap *native = iaxs[fr->callno]->owner->nativeformats;
if (orignative) {
- ast_format_cap_remove_all(native);
- ast_format_cap_add(native, &f.subclass.format);
+ ast_format_cap_set(native, &f.subclass.format);
if (iaxs[fr->callno]->owner->readformat.id) {
ast_set_read_format(iaxs[fr->callno]->owner, &iaxs[fr->callno]->owner->readformat);
}
@@ -12177,8 +12176,7 @@
ast_hangup(c);
return NULL;
}
- ast_format_cap_remove_all(c->nativeformats);
- ast_format_cap_add(c->nativeformats, &best_fmt_native);
+ ast_format_cap_set(c->nativeformats, &best_fmt_native);
}
ast_best_codec(c->nativeformats, &c->readformat);
ast_format_copy(&c->writeformat, &c->readformat);
Modified: team/dvossel/fixtheworld_phase1_step3/channels/chan_mgcp.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/channels/chan_mgcp.c?view=diff&rev=305128&r1=305127&r2=305128
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/channels/chan_mgcp.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/channels/chan_mgcp.c Mon Jan 31 12:31:17 2011
@@ -1209,8 +1209,7 @@
if (f->frametype == AST_FRAME_VOICE) {
if (!ast_format_cap_iscompatible(sub->owner->nativeformats, &f->subclass.format)) {
ast_debug(1, "Oooh, format changed to %s\n", ast_getformatname(&f->subclass.format));
- ast_format_cap_remove_all(sub->owner->nativeformats);
- ast_format_cap_add(sub->owner->nativeformats, &f->subclass.format);
+ ast_format_cap_set(sub->owner->nativeformats, &f->subclass.format);
ast_set_read_format(sub->owner, &sub->owner->readformat);
ast_set_write_format(sub->owner, &sub->owner->writeformat);
}
@@ -2556,8 +2555,7 @@
ast_format_cap_iter_start(p->cap);
while (!(ast_format_cap_iter_next(p->cap, &tmpfmt))) {
if (p->ncs && !fc) {
- ast_format_cap_remove_all(p->cap);
- ast_format_cap_add(p->cap, &tmpfmt); /* sb5120e bug */
+ ast_format_cap_set(p->cap, &tmpfmt); /* sb5120e bug */
break;
} else {
fc = 0;
Modified: team/dvossel/fixtheworld_phase1_step3/channels/chan_phone.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/channels/chan_phone.c?view=diff&rev=305128&r1=305127&r2=305128
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/channels/chan_phone.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/channels/chan_phone.c Mon Jan 31 12:31:17 2011
@@ -1440,22 +1440,18 @@
} else if (!strcasecmp(v->name, "format")) {
struct ast_format tmpfmt;
if (!strcasecmp(v->value, "g729")) {
- ast_format_cap_remove_all(prefcap);
- ast_format_cap_add(prefcap, ast_format_set(&tmpfmt, AST_FORMAT_G729A, 0));
+ ast_format_cap_set(prefcap, ast_format_set(&tmpfmt, AST_FORMAT_G729A, 0));
} else if (!strcasecmp(v->value, "g723.1")) {
- ast_format_cap_remove_all(prefcap);
- ast_format_cap_add(prefcap, ast_format_set(&tmpfmt, AST_FORMAT_G723_1, 0));
+ ast_format_cap_set(prefcap, ast_format_set(&tmpfmt, AST_FORMAT_G723_1, 0));
} else if (!strcasecmp(v->value, "slinear")) {
ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0);
if (mode == MODE_FXS) {
ast_format_cap_add(prefcap, &tmpfmt);
} else {
- ast_format_cap_remove_all(prefcap);
- ast_format_cap_add(prefcap, &tmpfmt);
+ ast_format_cap_set(prefcap, &tmpfmt);
}
} else if (!strcasecmp(v->value, "ulaw")) {
- ast_format_cap_remove_all(prefcap);
- ast_format_cap_add(prefcap, ast_format_set(&tmpfmt, AST_FORMAT_ULAW, 0));
+ ast_format_cap_set(prefcap, ast_format_set(&tmpfmt, AST_FORMAT_ULAW, 0));
} else
ast_log(LOG_WARNING, "Unknown format '%s'\n", v->value);
} else if (!strcasecmp(v->name, "echocancel")) {
Modified: team/dvossel/fixtheworld_phase1_step3/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/channels/chan_sip.c?view=diff&rev=305128&r1=305127&r2=305128
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/channels/chan_sip.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/channels/chan_sip.c Mon Jan 31 12:31:17 2011
@@ -6049,10 +6049,8 @@
if (fmt.id) {
ast_log(LOG_NOTICE, "Changing codec to '%s' for this call because of ${SIP_CODEC} variable\n", codec);
if (ast_format_cap_iscompatible(p->jointcaps, &fmt)) {
- ast_format_cap_remove_all(p->jointcaps);
- ast_format_cap_add(p->jointcaps, &fmt);
- ast_format_cap_remove_all(p->caps);
- ast_format_cap_add(p->caps, &fmt);
+ ast_format_cap_set(p->jointcaps, &fmt);
+ ast_format_cap_set(p->caps, &fmt);
} else
ast_log(LOG_NOTICE, "Ignoring ${SIP_CODEC} variable because it is not shared by both ends.\n");
} else
@@ -8736,8 +8734,7 @@
if (ast_test_flag(&p->flags[1], SIP_PAGE2_PREFERRED_CODEC)) { /* respond with single most preferred joint codec, limiting the other side's choice */
ast_codec_choose(&p->prefs, p->jointcaps, 1, &tmp_fmt);
- ast_format_cap_remove_all(p->jointcaps);
- ast_format_cap_add(p->jointcaps, &tmp_fmt);
+ ast_format_cap_set(p->jointcaps, &tmp_fmt);
}
ast_rtp_codecs_payloads_copy(&newaudiortp, ast_rtp_instance_get_codecs(p->rtp), p->rtp);
@@ -8883,9 +8880,8 @@
}
ast_codec_choose(&p->prefs, p->jointcaps, 1, &tmp_fmt);
- ast_format_cap_remove_all(p->owner->nativeformats);
-
- ast_format_cap_add(p->owner->nativeformats, &tmp_fmt);
+
+ ast_format_cap_set(p->owner->nativeformats, &tmp_fmt);
ast_format_cap_joint_copy(p->caps, vpeercapability, p->owner->nativeformats);
ast_format_cap_joint_copy(p->caps, tpeercapability, p->owner->nativeformats);
Modified: team/dvossel/fixtheworld_phase1_step3/channels/chan_skinny.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/channels/chan_skinny.c?view=diff&rev=305128&r1=305127&r2=305128
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/channels/chan_skinny.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/channels/chan_skinny.c Mon Jan 31 12:31:17 2011
@@ -4274,8 +4274,7 @@
if (f->frametype == AST_FRAME_VOICE) {
if (!(ast_format_cap_iscompatible(ast->nativeformats, &f->subclass.format))) {
ast_debug(1, "Oooh, format changed to %s\n", ast_getformatname(&f->subclass.format));
- ast_format_cap_remove_all(ast->nativeformats);
- ast_format_cap_add(ast->nativeformats, &f->subclass.format);
+ ast_format_cap_set(ast->nativeformats, &f->subclass.format);
ast_set_read_format(ast, &ast->readformat);
ast_set_write_format(ast, &ast->writeformat);
}
Modified: team/dvossel/fixtheworld_phase1_step3/channels/chan_unistim.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/channels/chan_unistim.c?view=diff&rev=305128&r1=305127&r2=305128
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/channels/chan_unistim.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/channels/chan_unistim.c Mon Jan 31 12:31:17 2011
@@ -4044,8 +4044,7 @@
ast_getformatname_multiple(tmp, sizeof(tmp), sub->owner->nativeformats),
ast_getformatname(&f->subclass.format));
- ast_format_cap_remove_all(sub->owner->nativeformats);
- ast_format_cap_add(sub->owner->nativeformats, &f->subclass.format);
+ ast_format_cap_set(sub->owner->nativeformats, &f->subclass.format);
ast_set_read_format(sub->owner, &sub->owner->readformat);
ast_set_write_format(sub->owner, &sub->owner->writeformat);
}
Modified: team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_cap.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_cap.h?view=diff&rev=305128&r1=305127&r2=305128
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_cap.h (original)
+++ team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_cap.h Mon Jan 31 12:31:17 2011
@@ -150,6 +150,11 @@
void ast_format_cap_remove_all(struct ast_format_cap *cap);
/*!
+ * \brief Remove all previous formats and set a single new format.
+ */
+void ast_format_cap_set(struct ast_format_cap *cap, struct ast_format *format);
+
+/*!
* \brief Find if ast_format is within the capabilities of the ast_format_cap object.
*
* retval 1 format is compatible with formats held in ast_format_cap object.
Modified: team/dvossel/fixtheworld_phase1_step3/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/channel.c?view=diff&rev=305128&r1=305127&r2=305128
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/channel.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/channel.c Mon Jan 31 12:31:17 2011
@@ -4999,8 +4999,7 @@
ast_format_copy(rawformat, &best_set_fmt);
ast_channel_lock(chan);
- ast_format_cap_remove_all(chan->nativeformats);
- ast_format_cap_add(chan->nativeformats, &best_set_fmt);
+ ast_format_cap_set(chan->nativeformats, &best_set_fmt);
ast_channel_unlock(chan);
if (*trans) {
Modified: team/dvossel/fixtheworld_phase1_step3/main/format_cap.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/format_cap.c?view=diff&rev=305128&r1=305127&r2=305128
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/format_cap.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/format_cap.c Mon Jan 31 12:31:17 2011
@@ -282,6 +282,12 @@
ao2_callback(cap->formats, OBJ_NODATA | cap->nolock | OBJ_MULTIPLE | OBJ_UNLINK, NULL, NULL);
}
+void ast_format_cap_set(struct ast_format_cap *cap, struct ast_format *format)
+{
+ ast_format_cap_remove_all(cap);
+ ast_format_cap_add(cap, format);
+}
+
int ast_format_cap_iscompatible(const struct ast_format_cap *cap, const struct ast_format *format)
{
struct ast_format *f;
Modified: team/dvossel/fixtheworld_phase1_step3/res/res_calendar.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/res/res_calendar.c?view=diff&rev=305128&r1=305127&r2=305128
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/res/res_calendar.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/res/res_calendar.c Mon Jan 31 12:31:17 2011
@@ -707,8 +707,7 @@
ast_format_set(&chan->rawwriteformat, AST_FORMAT_SLINEAR, 0);
ast_format_set(&chan->rawreadformat, AST_FORMAT_SLINEAR, 0);
/* clear native formats and set to slinear. write format is signlear so just use that to set it */
- ast_format_cap_remove_all(chan->nativeformats);
- ast_format_cap_add(chan->nativeformats, &chan->writeformat);
+ ast_format_cap_set(chan->nativeformats, &chan->writeformat);
if (!(datastore = ast_datastore_alloc(&event_notification_datastore, NULL))) {
ast_log(LOG_ERROR, "Could not allocate datastore, notification not being sent!\n");
More information about the asterisk-commits
mailing list