summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlfred E. Heggestad <alfred.heggestad@gmail.com>2017-05-20 20:19:50 +0200
committerAlfred E. Heggestad <alfred.heggestad@gmail.com>2017-05-20 20:19:50 +0200
commit7db06fe42f40366c29ab328173ec6c2bffd9ba40 (patch)
treeb00b4b39edf089d5cfbb2b57c0bc3f8cc19f3f97 /src
parent503944520f94545daace7e6236265362560da960 (diff)
vidcodec: make the API re-entrant
Diffstat (limited to 'src')
-rw-r--r--src/account.c6
-rw-r--r--src/baresip.c8
-rw-r--r--src/conf.c2
-rw-r--r--src/vidcodec.c49
-rw-r--r--src/video.c4
5 files changed, 37 insertions, 32 deletions
diff --git a/src/account.c b/src/account.c
index 6142a2e..e23d5c8 100644
--- a/src/account.c
+++ b/src/account.c
@@ -245,6 +245,7 @@ static int audio_codecs_decode(struct account *acc, const struct pl *prm)
#ifdef USE_VIDEO
static int video_codecs_decode(struct account *acc, const struct pl *prm)
{
+ struct list *vidcodecl = baresip_vidcodecl();
struct pl tmp;
if (!acc || !prm)
@@ -263,7 +264,8 @@ static int video_codecs_decode(struct account *acc, const struct pl *prm)
while (0 == csl_parse(&vcs, cname, sizeof(cname))) {
struct vidcodec *vc;
- vc = (struct vidcodec *)vidcodec_find(cname, NULL);
+ vc = (struct vidcodec *)vidcodec_find(vidcodecl,
+ cname, NULL);
if (!vc) {
warning("account: video codec not found: %s\n",
cname);
@@ -487,7 +489,7 @@ struct list *account_aucodecl(const struct account *acc)
struct list *account_vidcodecl(const struct account *acc)
{
return (acc && !list_isempty(&acc->vidcodecl))
- ? (struct list *)&acc->vidcodecl : vidcodec_list();
+ ? (struct list *)&acc->vidcodecl : baresip_vidcodecl();
}
#endif
diff --git a/src/baresip.c b/src/baresip.c
index dbed532..ce3f1aa 100644
--- a/src/baresip.c
+++ b/src/baresip.c
@@ -24,6 +24,7 @@ static struct baresip {
struct list ausrcl;
struct list auplayl;
struct list aufiltl;
+ struct list vidcodecl;
} baresip;
@@ -41,6 +42,7 @@ int baresip_init(struct config *cfg, bool prefer_ipv6)
list_init(&baresip.aucodecl);
list_init(&baresip.ausrcl);
list_init(&baresip.auplayl);
+ list_init(&baresip.vidcodecl);
/* Initialise Network */
err = net_alloc(&baresip.net, &cfg->net,
@@ -152,3 +154,9 @@ struct list *baresip_aufiltl(void)
{
return &baresip.aufiltl;
}
+
+
+struct list *baresip_vidcodecl(void)
+{
+ return &baresip.vidcodecl;
+}
diff --git a/src/conf.c b/src/conf.c
index 9a85c5d..7f7441b 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -355,7 +355,7 @@ int conf_modules(void)
print_populated("audio codec", list_count(baresip_aucodecl()));
print_populated("audio filter", list_count(baresip_aufiltl()));
#ifdef USE_VIDEO
- print_populated("video codec", list_count(vidcodec_list()));
+ print_populated("video codec", list_count(baresip_vidcodecl()));
print_populated("video filter", list_count(vidfilt_list()));
#endif
diff --git a/src/vidcodec.c b/src/vidcodec.c
index 620674a..cd335ad 100644
--- a/src/vidcodec.c
+++ b/src/vidcodec.c
@@ -8,20 +8,18 @@
#include <baresip.h>
-static struct list vidcodecl;
-
-
/**
* Register a Video Codec
*
- * @param vc Video Codec
+ * @param vidcodecl List of video-codecs
+ * @param vc Video Codec
*/
-void vidcodec_register(struct vidcodec *vc)
+void vidcodec_register(struct list *vidcodecl, struct vidcodec *vc)
{
- if (!vc)
+ if (!vidcodecl || !vc)
return;
- list_append(&vidcodecl, &vc->le, vc);
+ list_append(vidcodecl, &vc->le, vc);
info("vidcodec: %s\n", vc->name);
}
@@ -44,16 +42,18 @@ void vidcodec_unregister(struct vidcodec *vc)
/**
* Find a Video Codec by name
*
- * @param name Name of the Video Codec to find
- * @param variant Codec Variant
+ * @param vidcodecl List of video-codecs
+ * @param name Name of the Video Codec to find
+ * @param variant Codec Variant
*
* @return Matching Video Codec if found, otherwise NULL
*/
-const struct vidcodec *vidcodec_find(const char *name, const char *variant)
+const struct vidcodec *vidcodec_find(const struct list *vidcodecl,
+ const char *name, const char *variant)
{
struct le *le;
- for (le=vidcodecl.head; le; le=le->next) {
+ for (le=list_head(vidcodecl); le; le=le->next) {
struct vidcodec *vc = le->data;
@@ -73,15 +73,17 @@ const struct vidcodec *vidcodec_find(const char *name, const char *variant)
/**
* Find a Video Encoder by name
*
- * @param name Name of the Video Encoder to find
+ * @param vidcodecl List of video-codecs
+ * @param name Name of the Video Encoder to find
*
* @return Matching Video Encoder if found, otherwise NULL
*/
-const struct vidcodec *vidcodec_find_encoder(const char *name)
+const struct vidcodec *vidcodec_find_encoder(const struct list *vidcodecl,
+ const char *name)
{
struct le *le;
- for (le=vidcodecl.head; le; le=le->next) {
+ for (le=list_head(vidcodecl); le; le=le->next) {
struct vidcodec *vc = le->data;
@@ -99,15 +101,17 @@ const struct vidcodec *vidcodec_find_encoder(const char *name)
/**
* Find a Video Decoder by name
*
- * @param name Name of the Video Decoder to find
+ * @param vidcodecl List of video-codecs
+ * @param name Name of the Video Decoder to find
*
* @return Matching Video Decoder if found, otherwise NULL
*/
-const struct vidcodec *vidcodec_find_decoder(const char *name)
+const struct vidcodec *vidcodec_find_decoder(const struct list *vidcodecl,
+ const char *name)
{
struct le *le;
- for (le=vidcodecl.head; le; le=le->next) {
+ for (le=list_head(vidcodecl); le; le=le->next) {
struct vidcodec *vc = le->data;
@@ -120,14 +124,3 @@ const struct vidcodec *vidcodec_find_decoder(const char *name)
return NULL;
}
-
-
-/**
- * Get the list of Video Codecs
- *
- * @return List of Video Codecs
- */
-struct list *vidcodec_list(void)
-{
- return &vidcodecl;
-}
diff --git a/src/video.c b/src/video.c
index 2d6a470..9c1ec56 100644
--- a/src/video.c
+++ b/src/video.c
@@ -1142,11 +1142,13 @@ int video_decoder_set(struct video *v, struct vidcodec *vc, int pt_rx,
/* handle vidcodecs without a decoder */
if (!vc->decupdh) {
+ struct list *vidcodecl = baresip_vidcodecl();
struct vidcodec *vcd;
info("video: vidcodec '%s' has no decoder\n", vc->name);
- vcd = (struct vidcodec *)vidcodec_find_decoder(vc->name);
+ vcd = (struct vidcodec *)vidcodec_find_decoder(vidcodecl,
+ vc->name);
if (!vcd) {
warning("video: could not find decoder (%s)\n",
vc->name);