summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/baresip.h7
-rw-r--r--modules/amr/amr.c4
-rw-r--r--modules/auloop/auloop.c2
-rw-r--r--modules/bv32/bv32.c2
-rw-r--r--modules/codec2/codec2.c2
-rw-r--r--modules/g711/g711.c4
-rw-r--r--modules/g722/g722.c2
-rw-r--r--modules/g7221/g7221.c2
-rw-r--r--modules/g726/g726.c3
-rw-r--r--modules/gsm/gsm.c2
-rw-r--r--modules/ilbc/ilbc.c2
-rw-r--r--modules/isac/isac.c2
-rw-r--r--modules/l16/l16.c3
-rw-r--r--modules/mpa/mpa.c2
-rw-r--r--modules/opus/encode.c2
-rw-r--r--modules/opus/opus.c2
-rw-r--r--modules/silk/silk.c2
-rw-r--r--modules/speex/speex.c2
-rw-r--r--src/account.c6
-rw-r--r--src/aucodec.c26
-rw-r--r--src/baresip.c13
-rw-r--r--src/conf.c2
-rw-r--r--test/call.c2
23 files changed, 52 insertions, 44 deletions
diff --git a/include/baresip.h b/include/baresip.h
index 9502497..7f3ea3e 100644
--- a/include/baresip.h
+++ b/include/baresip.h
@@ -817,11 +817,11 @@ struct aucodec {
sdp_fmtp_cmp_h *fmtp_cmph;
};
-void aucodec_register(struct aucodec *ac);
+void aucodec_register(struct list *aucodecl, struct aucodec *ac);
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 list *aucodec_list(void);
/*
@@ -1122,6 +1122,7 @@ struct player *baresip_player(void);
struct message *baresip_message(void);
struct list *baresip_mnatl(void);
struct list *baresip_mencl(void);
+struct list *baresip_aucodecl(void);
#ifdef __cplusplus
diff --git a/modules/amr/amr.c b/modules/amr/amr.c
index 0596812..52c20b3 100644
--- a/modules/amr/amr.c
+++ b/modules/amr/amr.c
@@ -313,10 +313,10 @@ static int module_init(void)
int err = 0;
#ifdef AMR_WB
- aucodec_register(&amr_wb);
+ aucodec_register(baresip_aucodecl(), &amr_wb);
#endif
#ifdef AMR_NB
- aucodec_register(&amr_nb);
+ aucodec_register(baresip_aucodecl(), &amr_nb);
#endif
return err;
diff --git a/modules/auloop/auloop.c b/modules/auloop/auloop.c
index 2017411..328366f 100644
--- a/modules/auloop/auloop.c
+++ b/modules/auloop/auloop.c
@@ -184,7 +184,7 @@ static void start_codec(struct audio_loop *al, const char *name)
struct auenc_param prm = {PTIME};
int err;
- al->ac = aucodec_find(name,
+ al->ac = aucodec_find(baresip_aucodecl(), name,
configv[al->index].srate,
configv[al->index].ch);
if (!al->ac) {
diff --git a/modules/bv32/bv32.c b/modules/bv32/bv32.c
index f604885..d3dd45c 100644
--- a/modules/bv32/bv32.c
+++ b/modules/bv32/bv32.c
@@ -160,7 +160,7 @@ static struct aucodec bv32 = {
static int module_init(void)
{
- aucodec_register(&bv32);
+ aucodec_register(baresip_aucodecl(), &bv32);
return 0;
}
diff --git a/modules/codec2/codec2.c b/modules/codec2/codec2.c
index 67fd7e6..b6911dc 100644
--- a/modules/codec2/codec2.c
+++ b/modules/codec2/codec2.c
@@ -180,7 +180,7 @@ static struct aucodec codec2 = {
static int module_init(void)
{
- aucodec_register(&codec2);
+ aucodec_register(baresip_aucodecl(), &codec2);
return 0;
}
diff --git a/modules/g711/g711.c b/modules/g711/g711.c
index 0353fe0..7c01b61 100644
--- a/modules/g711/g711.c
+++ b/modules/g711/g711.c
@@ -109,8 +109,8 @@ static struct aucodec pcma = {
static int module_init(void)
{
- aucodec_register(&pcmu);
- aucodec_register(&pcma);
+ aucodec_register(baresip_aucodecl(), &pcmu);
+ aucodec_register(baresip_aucodecl(), &pcma);
return 0;
}
diff --git a/modules/g722/g722.c b/modules/g722/g722.c
index 2b5a7a4..fae0958 100644
--- a/modules/g722/g722.c
+++ b/modules/g722/g722.c
@@ -171,7 +171,7 @@ static struct aucodec g722 = {
static int module_init(void)
{
- aucodec_register(&g722);
+ aucodec_register(baresip_aucodecl(), &g722);
return 0;
}
diff --git a/modules/g7221/g7221.c b/modules/g7221/g7221.c
index 7651e92..3e2de02 100644
--- a/modules/g7221/g7221.c
+++ b/modules/g7221/g7221.c
@@ -28,7 +28,7 @@ static struct g7221_aucodec g7221 = {
static int module_init(void)
{
- aucodec_register((struct aucodec *)&g7221);
+ aucodec_register(baresip_aucodecl(), (struct aucodec *)&g7221);
return 0;
}
diff --git a/modules/g726/g726.c b/modules/g726/g726.c
index a23a985..59430ab 100644
--- a/modules/g726/g726.c
+++ b/modules/g726/g726.c
@@ -180,10 +180,11 @@ static struct g726_aucodec g726[4] = {
static int module_init(void)
{
+ struct list *aucodecl = baresip_aucodecl();
size_t i;
for (i=0; i<ARRAY_SIZE(g726); i++)
- aucodec_register((struct aucodec *)&g726[i]);
+ aucodec_register(aucodecl, (struct aucodec *)&g726[i]);
return 0;
}
diff --git a/modules/gsm/gsm.c b/modules/gsm/gsm.c
index 2fc006e..be225d8 100644
--- a/modules/gsm/gsm.c
+++ b/modules/gsm/gsm.c
@@ -158,7 +158,7 @@ static int module_init(void)
{
debug("gsm: GSM v%u.%u.%u\n", GSM_MAJOR, GSM_MINOR, GSM_PATCHLEVEL);
- aucodec_register(&ac_gsm);
+ aucodec_register(baresip_aucodecl(), &ac_gsm);
return 0;
}
diff --git a/modules/ilbc/ilbc.c b/modules/ilbc/ilbc.c
index 7c2ceed..918f7fc 100644
--- a/modules/ilbc/ilbc.c
+++ b/modules/ilbc/ilbc.c
@@ -337,7 +337,7 @@ static int module_init(void)
(void)re_snprintf(ilbc_fmtp, sizeof(ilbc_fmtp),
"mode=%d", DEFAULT_MODE);
- aucodec_register(&ilbc);
+ aucodec_register(baresip_aucodecl(), &ilbc);
return 0;
}
diff --git a/modules/isac/isac.c b/modules/isac/isac.c
index 9e98c35..868ef0e 100644
--- a/modules/isac/isac.c
+++ b/modules/isac/isac.c
@@ -201,7 +201,7 @@ static int module_init(void)
unsigned i;
for (i=0; i<ARRAY_SIZE(isacv); i++)
- aucodec_register(&isacv[i]);
+ aucodec_register(baresip_aucodecl(), &isacv[i]);
return 0;
}
diff --git a/modules/l16/l16.c b/modules/l16/l16.c
index 2f81caa..204a8f5 100644
--- a/modules/l16/l16.c
+++ b/modules/l16/l16.c
@@ -75,10 +75,11 @@ static struct aucodec l16v[NR_CODECS] = {
static int module_init(void)
{
+ struct list *aucodecl = baresip_aucodecl();
size_t i;
for (i=0; i<NR_CODECS; i++)
- aucodec_register(&l16v[i]);
+ aucodec_register(aucodecl, &l16v[i]);
return 0;
}
diff --git a/modules/mpa/mpa.c b/modules/mpa/mpa.c
index c32b68a..316afd1 100644
--- a/modules/mpa/mpa.c
+++ b/modules/mpa/mpa.c
@@ -177,7 +177,7 @@ static int module_init(void)
return -1;
}
- aucodec_register(&mpa);
+ aucodec_register(baresip_aucodecl(), &mpa);
#ifdef DEBUG
info("MPA init with %s\n",mpa.fmtp);
diff --git a/modules/opus/encode.c b/modules/opus/encode.c
index f7937c5..7ee1ca2 100644
--- a/modules/opus/encode.c
+++ b/modules/opus/encode.c
@@ -72,7 +72,7 @@ int opus_encode_update(struct auenc_state **aesp, const struct aucodec *ac,
struct auenc_state *aes;
struct opus_param prm, conf_prm;
opus_int32 fch, vbr;
- const struct aucodec *auc = aucodec_find("opus", 48000, 2);
+ const struct aucodec *auc = ac;
(void)param;
diff --git a/modules/opus/opus.c b/modules/opus/opus.c
index d1e9c24..78ed3bf 100644
--- a/modules/opus/opus.c
+++ b/modules/opus/opus.c
@@ -136,7 +136,7 @@ static int module_init(void)
debug("opus: fmtp=\"%s\"\n", fmtp);
- aucodec_register(&opus);
+ aucodec_register(baresip_aucodecl(), &opus);
return 0;
}
diff --git a/modules/silk/silk.c b/modules/silk/silk.c
index 73432d2..f1aba89 100644
--- a/modules/silk/silk.c
+++ b/modules/silk/silk.c
@@ -237,7 +237,7 @@ static int module_init(void)
{
debug("silk: SILK %s\n", SKP_Silk_SDK_get_version());
- aucodec_register(&silk[0]);
+ aucodec_register(baresip_aucodecl(), &silk[0]);
return 0;
}
diff --git a/modules/speex/speex.c b/modules/speex/speex.c
index 13c6e79..aa26902 100644
--- a/modules/speex/speex.c
+++ b/modules/speex/speex.c
@@ -494,7 +494,7 @@ static int speex_init(void)
sconf.vad ? "vad" : (sconf.vbr ? "on" : "off"));
for (i=0; i<ARRAY_SIZE(speexv); i++)
- aucodec_register(&speexv[i]);
+ aucodec_register(baresip_aucodecl(), &speexv[i]);
return 0;
}
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()));
diff --git a/test/call.c b/test/call.c
index 9180a27..e3cfa8d 100644
--- a/test/call.c
+++ b/test/call.c
@@ -62,7 +62,7 @@ struct fixture {
f->magic = MAGIC; \
f->exp_estab = 1; \
f->exp_closed = 1; \
- aucodec_register(&dummy_pcma); \
+ aucodec_register(baresip_aucodecl(), &dummy_pcma); \
\
err = ua_alloc(&f->a.ua, \
"A <sip:a:xxx@127.0.0.1>;regint=0" prm); \