summaryrefslogtreecommitdiff
path: root/main/frame.c
diff options
context:
space:
mode:
authorTilghman Lesher <tilghman@meg.abyt.es>2011-09-07 00:54:36 +0000
committerTilghman Lesher <tilghman@meg.abyt.es>2011-09-07 00:54:36 +0000
commitf03bccdb4dcc1893acd2139f5a420c80ebdbecea (patch)
treef063176117468e13fcb3c769e9aae086a8663084 /main/frame.c
parentf090651138a50f0d1f974f1223c48e2ccfd50850 (diff)
Implement the '!' negation element to negate codecs directly in the allow keyword.
This permits the list of codecs to be specified in one configuration line, instead of two or more, generally with the aim of either allowing all codecs with the exception of a few or disallowing most but permitting a few. Review: https://reviewboard.asterisk.org/r/1411/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@334574 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/frame.c')
-rw-r--r--main/frame.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/main/frame.c b/main/frame.c
index b664e2e84..4a9109694 100644
--- a/main/frame.c
+++ b/main/frame.c
@@ -730,13 +730,18 @@ void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix)
int ast_parse_allow_disallow(struct ast_codec_pref *pref, struct ast_format_cap *cap, const char *list, int allowing)
{
- int errors = 0, framems = 0, all = 0;
+ int errors = 0, framems = 0, all = 0, iter_allowing;
char *parse = NULL, *this = NULL, *psize = NULL;
struct ast_format format;
parse = ast_strdupa(list);
while ((this = strsep(&parse, ","))) {
+ iter_allowing = allowing;
framems = 0;
+ if (*this == '!') {
+ this++;
+ iter_allowing = !allowing;
+ }
if ((psize = strrchr(this, ':'))) {
*psize++ = '\0';
ast_debug(1, "Packetization for codec: %s is %s\n", this, psize);
@@ -750,13 +755,13 @@ int ast_parse_allow_disallow(struct ast_codec_pref *pref, struct ast_format_cap
all = strcasecmp(this, "all") ? 0 : 1;
if (!all && !ast_getformatbyname(this, &format)) {
- ast_log(LOG_WARNING, "Cannot %s unknown format '%s'\n", allowing ? "allow" : "disallow", this);
+ ast_log(LOG_WARNING, "Cannot %s unknown format '%s'\n", iter_allowing ? "allow" : "disallow", this);
errors++;
continue;
}
if (cap) {
- if (allowing) {
+ if (iter_allowing) {
if (all) {
ast_format_cap_add_all(cap);
} else {
@@ -773,13 +778,13 @@ int ast_parse_allow_disallow(struct ast_codec_pref *pref, struct ast_format_cap
if (pref) {
if (!all) {
- if (allowing) {
+ if (iter_allowing) {
ast_codec_pref_append(pref, &format);
ast_codec_pref_setsize(pref, &format, framems);
} else {
ast_codec_pref_remove(pref, &format);
}
- } else if (!allowing) {
+ } else if (!iter_allowing) {
memset(pref, 0, sizeof(*pref));
}
}