Tizen 2.0 Release
[framework/multimedia/gst-plugins-good0.10.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 void
31 goom_secure_param (PluginParam * p)
32 {
33   p->changed = empty_fct;
34   p->change_listener = empty_fct;
35   p->user_data = 0;
36   p->name = p->desc = 0;
37   p->rw = 1;
38 }
39
40 void
41 goom_secure_f_param (PluginParam * p, const char *name)
42 {
43   secure_param (p);
44
45   p->name = name;
46   p->type = PARAM_FLOATVAL;
47   FVAL (*p) = 0.5f;
48   FMIN (*p) = 0.0f;
49   FMAX (*p) = 1.0f;
50   FSTEP (*p) = 0.01f;
51 }
52
53 void
54 goom_secure_f_feedback (PluginParam * p, const char *name)
55 {
56   secure_f_param (p, name);
57
58   p->rw = 0;
59 }
60
61 void
62 goom_secure_s_param (PluginParam * p, const char *name)
63 {
64   secure_param (p);
65
66   p->name = name;
67   p->type = PARAM_STRVAL;
68   SVAL (*p) = 0;
69 }
70
71 void
72 goom_secure_b_param (PluginParam * p, const char *name, int value)
73 {
74   secure_param (p);
75
76   p->name = name;
77   p->type = PARAM_BOOLVAL;
78   BVAL (*p) = value;
79 }
80
81 void
82 goom_secure_i_param (PluginParam * p, const char *name)
83 {
84   secure_param (p);
85
86   p->name = name;
87   p->type = PARAM_INTVAL;
88   IVAL (*p) = 50;
89   IMIN (*p) = 0;
90   IMAX (*p) = 100;
91   ISTEP (*p) = 1;
92 }
93
94 void
95 goom_secure_i_feedback (PluginParam * p, const char *name)
96 {
97   secure_i_param (p, name);
98
99   p->rw = 0;
100 }
101
102 void
103 goom_plugin_parameters (PluginParameters * p, const char *name, int nb)
104 {
105   p->name = name;
106   p->desc = "";
107   p->nbParams = nb;
108   p->params = malloc (nb * sizeof (PluginParam *));
109 }
110
111 void
112 goom_plugin_parameters_free (PluginParameters * p)
113 {
114   free (p->params);
115 }
116
117 /*---------------------------------------------------------------------------*/
118
119 void
120 goom_set_str_param_value (PluginParam * p, const char *str)
121 {
122   int len = strlen (str);
123
124   if (SVAL (*p))
125     SVAL (*p) = (char *) realloc (SVAL (*p), len + 1);
126   else
127     SVAL (*p) = (char *) malloc (len + 1);
128   memcpy (SVAL (*p), str, len + 1);
129 }
130
131 void
132 goom_set_list_param_value (PluginParam * p, const char *str)
133 {
134   int len = strlen (str);
135
136 #ifdef VERBOSE
137   printf ("%s: %d\n", str, len);
138 #endif
139   if (LVAL (*p))
140     LVAL (*p) = (char *) realloc (LVAL (*p), len + 1);
141   else
142     LVAL (*p) = (char *) malloc (len + 1);
143   memcpy (LVAL (*p), str, len + 1);
144 }