1 /**
2 * @file vidfilt.c Video Filter
3 *
4 * Copyright (C) 2010 Creytiv.com
5 */
6 #include <re.h>
7 #include <baresip.h>
8 #include "core.h"
9
10
11 /**
12 * Register a new Video Filter
13 *
14 * @param vidfiltl List of Video-Filters
15 * @param vf Video Filter to register
16 */
vidfilt_register(struct list * vidfiltl,struct vidfilt * vf)17 void vidfilt_register(struct list *vidfiltl, struct vidfilt *vf)
18 {
19 if (!vf)
20 return;
21
22 list_append(vidfiltl, &vf->le, vf);
23
24 info("vidfilt: %s\n", vf->name);
25 }
26
27
28 /**
29 * Unregister a Video Filter
30 *
31 * @param vf Video Filter to unregister
32 */
vidfilt_unregister(struct vidfilt * vf)33 void vidfilt_unregister(struct vidfilt *vf)
34 {
35 if (!vf)
36 return;
37
38 list_unlink(&vf->le);
39 }
40
41
vidfilt_enc_destructor(void * arg)42 static void vidfilt_enc_destructor(void *arg)
43 {
44 struct vidfilt_enc_st *st = arg;
45
46 list_unlink(&st->le);
47 }
48
49
vidfilt_enc_append(struct list * filtl,void ** ctx,const struct vidfilt * vf)50 int vidfilt_enc_append(struct list *filtl, void **ctx,
51 const struct vidfilt *vf)
52 {
53 struct vidfilt_enc_st *st = NULL;
54 int err;
55
56 if (vf->encupdh) {
57 err = vf->encupdh(&st, ctx, vf);
58 if (err)
59 return err;
60 }
61 else {
62 st = mem_zalloc(sizeof(*st), vidfilt_enc_destructor);
63 if (!st)
64 return ENOMEM;
65 }
66
67 st->vf = vf;
68 list_append(filtl, &st->le, st);
69
70 return 0;
71 }
72
73
vidfilt_dec_destructor(void * arg)74 static void vidfilt_dec_destructor(void *arg)
75 {
76 struct vidfilt_dec_st *st = arg;
77
78 list_unlink(&st->le);
79 }
80
81
vidfilt_dec_append(struct list * filtl,void ** ctx,const struct vidfilt * vf)82 int vidfilt_dec_append(struct list *filtl, void **ctx,
83 const struct vidfilt *vf)
84 {
85 struct vidfilt_dec_st *st = NULL;
86 int err;
87
88 if (vf->decupdh) {
89 err = vf->decupdh(&st, ctx, vf);
90 if (err)
91 return err;
92 }
93 else {
94 st = mem_zalloc(sizeof(*st), vidfilt_dec_destructor);
95 if (!st)
96 return ENOMEM;
97 }
98
99 st->vf = vf;
100 list_append(filtl, &st->le, st);
101
102 return 0;
103 }
104