From 4f43acb07de88433ce513079233040e3e7c2b9d6 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sat, 4 Mar 2017 15:28:51 +0100 Subject: aucodec: move list of aucodec to struct baresip (#221) --- src/account.c | 6 ++++-- src/aucodec.c | 26 ++++++++------------------ src/baresip.c | 13 +++++++++++++ src/conf.c | 2 +- 4 files changed, 26 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/account.c b/src/account.c index e6d9ec8..6142a2e 100644 --- a/src/account.c +++ b/src/account.c @@ -187,6 +187,7 @@ static int csl_parse(struct pl *pl, char *str, size_t sz) static int audio_codecs_decode(struct account *acc, const struct pl *prm) { + struct list *aucodecl = baresip_aucodecl(); struct pl tmp; if (!acc || !prm) @@ -220,7 +221,8 @@ static int audio_codecs_decode(struct account *acc, const struct pl *prm) ch = pl_u32(&pl_ch); } - ac = (struct aucodec *)aucodec_find(cname, srate, ch); + ac = (struct aucodec *)aucodec_find(aucodecl, + cname, srate, ch); if (!ac) { warning("account: audio codec not found:" " %s/%u/%d\n", @@ -477,7 +479,7 @@ int account_auth(const struct account *acc, char **username, char **password, struct list *account_aucodecl(const struct account *acc) { return (acc && !list_isempty(&acc->aucodecl)) - ? (struct list *)&acc->aucodecl : aucodec_list(); + ? (struct list *)&acc->aucodecl : baresip_aucodecl(); } diff --git a/src/aucodec.c b/src/aucodec.c index 67e3256..35076ed 100644 --- a/src/aucodec.c +++ b/src/aucodec.c @@ -9,20 +9,18 @@ #include "core.h" -static struct list aucodecl; - - /** * Register an Audio Codec * - * @param ac Audio Codec object + * @param aucodecl List of audio-codecs + * @param ac Audio Codec object */ -void aucodec_register(struct aucodec *ac) +void aucodec_register(struct list *aucodecl, struct aucodec *ac) { - if (!ac) + if (!aucodecl || !ac) return; - list_append(&aucodecl, &ac->le, ac); + list_append(aucodecl, &ac->le, ac); info("aucodec: %s/%u/%u\n", ac->name, ac->srate, ac->ch); } @@ -42,12 +40,13 @@ void aucodec_unregister(struct aucodec *ac) } -const struct aucodec *aucodec_find(const char *name, uint32_t srate, +const struct aucodec *aucodec_find(const struct list *aucodecl, + const char *name, uint32_t srate, uint8_t ch) { struct le *le; - for (le=aucodecl.head; le; le=le->next) { + for (le=list_head(aucodecl); le; le=le->next) { struct aucodec *ac = le->data; @@ -65,12 +64,3 @@ const struct aucodec *aucodec_find(const char *name, uint32_t srate, return NULL; } - - -/** - * Get the list of Audio Codecs - */ -struct list *aucodec_list(void) -{ - return &aucodecl; -} diff --git a/src/baresip.c b/src/baresip.c index 809f106..ae715ce 100644 --- a/src/baresip.c +++ b/src/baresip.c @@ -20,6 +20,7 @@ static struct baresip { struct message *message; struct list mnatl; struct list mencl; + struct list aucodecl; } baresip; @@ -34,6 +35,7 @@ int baresip_init(struct config *cfg, bool prefer_ipv6) list_init(&baresip.mnatl); list_init(&baresip.mencl); + list_init(&baresip.aucodecl); /* Initialise Network */ err = net_alloc(&baresip.net, &cfg->net, @@ -116,3 +118,14 @@ struct message *baresip_message(void) { return baresip.message; } + + +/** + * Get the list of Audio Codecs + * + * @return List of audio-codecs + */ +struct list *baresip_aucodecl(void) +{ + return &baresip.aucodecl; +} diff --git a/src/conf.c b/src/conf.c index 9234b00..27d4be3 100644 --- a/src/conf.c +++ b/src/conf.c @@ -352,7 +352,7 @@ int conf_modules(void) goto out; } - print_populated("audio codec", list_count(aucodec_list())); + print_populated("audio codec", list_count(baresip_aucodecl())); print_populated("audio filter", list_count(aufilt_list())); #ifdef USE_VIDEO print_populated("video codec", list_count(vidcodec_list())); -- cgit v1.2.3