gst/goom/: Add license headers in all source files. Remove filter.c from
[platform/upstream/gst-plugins-good.git] / gst / goom / config_param.c
1 /* Goom Project
2  * Copyright (C) <2003> Jean-Christophe Hoelt <jeko@free.fr>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #include "goom_config_param.h"
21 #include <string.h>
22
23 /* TODO: Ajouter goom_ devant ces fonctions */
24
25 static void
26 empty_fct (PluginParam * dummy)
27 {
28 }
29
30 PluginParam
31 goom_secure_param ()
32 {
33   PluginParam p;
34
35   p.changed = empty_fct;
36   p.change_listener = empty_fct;
37   p.user_data = 0;
38   p.name = p.desc = 0;
39   p.rw = 1;
40   return p;
41 }
42
43 PluginParam
44 goom_secure_f_param (char *name)
45 {
46   PluginParam p = secure_param ();
47
48   p.name = name;
49   p.type = PARAM_FLOATVAL;
50   FVAL (p) = 0.5f;
51   FMIN (p) = 0.0f;
52   FMAX (p) = 1.0f;
53   FSTEP (p) = 0.01f;
54   return p;
55 }
56
57 PluginParam
58 goom_secure_f_feedback (char *name)
59 {
60   PluginParam p = secure_f_param (name);
61
62   p.rw = 0;
63   return p;
64 }
65
66 PluginParam
67 goom_secure_s_param (char *name)
68 {
69   PluginParam p = secure_param ();
70
71   p.name = name;
72   p.type = PARAM_STRVAL;
73   SVAL (p) = 0;
74   return p;
75 }
76
77 PluginParam
78 goom_secure_b_param (char *name, int value)
79 {
80   PluginParam p = secure_param ();
81
82   p.name = name;
83   p.type = PARAM_BOOLVAL;
84   BVAL (p) = value;
85   return p;
86 }
87
88 PluginParam
89 goom_secure_i_param (char *name)
90 {
91   PluginParam p = secure_param ();
92
93   p.name = name;
94   p.type = PARAM_INTVAL;
95   IVAL (p) = 50;
96   IMIN (p) = 0;
97   IMAX (p) = 100;
98   ISTEP (p) = 1;
99   return p;
100 }
101
102 PluginParam
103 goom_secure_i_feedback (char *name)
104 {
105   PluginParam p = secure_i_param (name);
106
107   p.rw = 0;
108   return p;
109 }
110
111 PluginParameters
112 goom_plugin_parameters (const char *name, int nb)
113 {
114   PluginParameters p;
115
116   p.name = (char *) name;
117   p.desc = "";
118   p.nbParams = nb;
119   p.params = (PluginParam **) malloc (nb * sizeof (PluginParam *));
120   return p;
121 }
122
123 void
124 goom_plugin_parameters_free (PluginParameters * p)
125 {
126   free (p->params);
127 }
128
129 /*---------------------------------------------------------------------------*/
130
131 void
132 goom_set_str_param_value (PluginParam * p, const char *str)
133 {
134   int len = strlen (str);
135
136   if (SVAL (*p))
137     SVAL (*p) = (char *) realloc (SVAL (*p), len + 1);
138   else
139     SVAL (*p) = (char *) malloc (len + 1);
140   memcpy (SVAL (*p), str, len + 1);
141 }
142
143 void
144 goom_set_list_param_value (PluginParam * p, const char *str)
145 {
146   int len = strlen (str);
147
148 #ifdef VERBOSE
149   printf ("%s: %d\n", str, len);
150 #endif
151   if (LVAL (*p))
152     LVAL (*p) = (char *) realloc (LVAL (*p), len + 1);
153   else
154     LVAL (*p) = (char *) malloc (len + 1);
155   memcpy (LVAL (*p), str, len + 1);
156 }