16 * You should have received a copy of the GNU Library General Public |
16 * You should have received a copy of the GNU Library General Public |
17 * License along with this library; if not, write to the |
17 * License along with this library; if not, write to the |
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 * Boston, MA 02111-1307, USA. |
19 * Boston, MA 02111-1307, USA. |
20 */ |
20 */ |
21 |
21 /** |
|
22 * SECTION:gstpropertyprobe |
|
23 * @short_description: Interface for probing possible property values |
|
24 * |
|
25 * The property probe is a way to autodetect allowed values for a GObject |
|
26 * property. It's primary use is to autodetect device-names in several elements. |
|
27 * |
|
28 * The interface is implemented by many hardware sources and sinks. |
|
29 */ |
22 #ifdef HAVE_CONFIG_H |
30 #ifdef HAVE_CONFIG_H |
23 #include "config.h" |
31 #include "config.h" |
24 #endif |
32 #endif |
25 |
33 |
26 #include <string.h> |
34 #include <string.h> |
71 gst_property_probe_iface_init (GstPropertyProbeInterface * iface) |
79 gst_property_probe_iface_init (GstPropertyProbeInterface * iface) |
72 { |
80 { |
73 static gboolean initialized = FALSE; |
81 static gboolean initialized = FALSE; |
74 |
82 |
75 if (!initialized) { |
83 if (!initialized) { |
|
84 /** |
|
85 * GstPropertyProbe::probe-needed |
|
86 * @pspec: #GParamSpec that needs a probe |
|
87 * |
|
88 */ |
|
89 /* FIXME: |
|
90 * what is the purpose of this signal, I can't find any usage of it |
|
91 * according to proto n *.h, it should be g_cclosure_marshal_VOID__PARAM |
|
92 */ |
76 gst_property_probe_signals[SIGNAL_PROBE_NEEDED] = |
93 gst_property_probe_signals[SIGNAL_PROBE_NEEDED] = |
77 g_signal_new ("probe-needed", G_TYPE_FROM_CLASS (iface), |
94 g_signal_new ("probe-needed", G_TYPE_FROM_CLASS (iface), |
78 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstPropertyProbeInterface, |
95 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstPropertyProbeInterface, |
79 probe_needed), NULL, NULL, g_cclosure_marshal_VOID__POINTER, |
96 probe_needed), NULL, NULL, g_cclosure_marshal_VOID__POINTER, |
80 G_TYPE_NONE, 1, G_TYPE_POINTER); |
97 G_TYPE_NONE, 1, G_TYPE_POINTER); |
97 */ |
114 */ |
98 #ifdef __SYMBIAN32__ |
115 #ifdef __SYMBIAN32__ |
99 EXPORT_C |
116 EXPORT_C |
100 #endif |
117 #endif |
101 |
118 |
102 |
|
103 const GList * |
119 const GList * |
104 gst_property_probe_get_properties (GstPropertyProbe * probe) |
120 gst_property_probe_get_properties (GstPropertyProbe * probe) |
105 { |
121 { |
106 GstPropertyProbeInterface *iface; |
122 GstPropertyProbeInterface *iface; |
107 |
123 |
108 g_return_val_if_fail (probe != NULL, NULL); |
124 g_return_val_if_fail (probe != NULL, NULL); |
|
125 g_return_val_if_fail (GST_IS_PROPERTY_PROBE (probe), NULL); |
109 |
126 |
110 iface = GST_PROPERTY_PROBE_GET_IFACE (probe); |
127 iface = GST_PROPERTY_PROBE_GET_IFACE (probe); |
111 |
128 |
112 if (iface->get_properties) |
129 if (iface->get_properties) |
113 return iface->get_properties (probe); |
130 return iface->get_properties (probe); |
114 |
131 |
115 return NULL; |
132 return NULL; |
116 } |
133 } |
117 #ifdef __SYMBIAN32__ |
134 |
118 EXPORT_C |
135 /** |
119 #endif |
136 * gst_property_probe_get_property: |
120 |
137 * @probe: the #GstPropertyProbe to get the properties for. |
|
138 * @name: name of the property. |
|
139 * |
|
140 * Get #GParamSpec for a property for which probing is supported. |
|
141 * |
|
142 * Returns: the #GParamSpec of %NULL. |
|
143 */ |
|
144 #ifdef __SYMBIAN32__ |
|
145 EXPORT_C |
|
146 #endif |
121 |
147 |
122 const GParamSpec * |
148 const GParamSpec * |
123 gst_property_probe_get_property (GstPropertyProbe * probe, const gchar * name) |
149 gst_property_probe_get_property (GstPropertyProbe * probe, const gchar * name) |
124 { |
150 { |
125 const GList *pspecs = gst_property_probe_get_properties (probe); |
151 const GList *pspecs; |
126 |
152 |
127 g_return_val_if_fail (probe != NULL, NULL); |
153 g_return_val_if_fail (probe != NULL, NULL); |
|
154 g_return_val_if_fail (GST_IS_PROPERTY_PROBE (probe), NULL); |
128 g_return_val_if_fail (name != NULL, NULL); |
155 g_return_val_if_fail (name != NULL, NULL); |
|
156 |
|
157 pspecs = gst_property_probe_get_properties (probe); |
129 |
158 |
130 while (pspecs) { |
159 while (pspecs) { |
131 const GParamSpec *pspec = pspecs->data; |
160 const GParamSpec *pspec = pspecs->data; |
132 |
161 |
133 if (!strcmp (pspec->name, name)) |
162 if (pspec) { |
134 return pspec; |
163 if (!strcmp (pspec->name, name)) |
|
164 return pspec; |
|
165 } else { |
|
166 GST_WARNING_OBJECT (probe, "NULL paramspec in property probe list"); |
|
167 } |
135 |
168 |
136 pspecs = pspecs->next; |
169 pspecs = pspecs->next; |
137 } |
170 } |
138 |
171 |
139 return NULL; |
172 return NULL; |
140 } |
173 } |
141 #ifdef __SYMBIAN32__ |
174 |
142 EXPORT_C |
175 /** |
143 #endif |
176 * gst_property_probe_probe_property: |
144 |
177 * @probe: the #GstPropertyProbe to check. |
|
178 * @pspec: #GParamSpec of the property. |
|
179 * |
|
180 * Runs a probe on the property specified by %pspec |
|
181 */ |
|
182 #ifdef __SYMBIAN32__ |
|
183 EXPORT_C |
|
184 #endif |
145 |
185 |
146 void |
186 void |
147 gst_property_probe_probe_property (GstPropertyProbe * probe, |
187 gst_property_probe_probe_property (GstPropertyProbe * probe, |
148 const GParamSpec * pspec) |
188 const GParamSpec * pspec) |
149 { |
189 { |
150 GstPropertyProbeInterface *iface; |
190 GstPropertyProbeInterface *iface; |
151 |
191 |
152 g_return_if_fail (probe != NULL); |
192 g_return_if_fail (probe != NULL); |
|
193 g_return_if_fail (GST_IS_PROPERTY_PROBE (probe)); |
153 g_return_if_fail (pspec != NULL); |
194 g_return_if_fail (pspec != NULL); |
154 |
195 |
155 iface = GST_PROPERTY_PROBE_GET_IFACE (probe); |
196 iface = GST_PROPERTY_PROBE_GET_IFACE (probe); |
156 |
197 |
157 if (iface->probe_property) |
198 if (iface->probe_property) |
159 } |
200 } |
160 |
201 |
161 /** |
202 /** |
162 * gst_property_probe_probe_property_name: |
203 * gst_property_probe_probe_property_name: |
163 * @probe: the #GstPropertyProbe to check. |
204 * @probe: the #GstPropertyProbe to check. |
164 * @name: name of the property to return. |
205 * @name: name of the property. |
165 * |
206 * |
166 * Runs a probe on the given property. |
207 * Runs a probe on the property specified by %name. |
167 */ |
208 */ |
168 #ifdef __SYMBIAN32__ |
209 #ifdef __SYMBIAN32__ |
169 EXPORT_C |
210 EXPORT_C |
170 #endif |
211 #endif |
171 |
|
172 |
212 |
173 void |
213 void |
174 gst_property_probe_probe_property_name (GstPropertyProbe * probe, |
214 gst_property_probe_probe_property_name (GstPropertyProbe * probe, |
175 const gchar * name) |
215 const gchar * name) |
176 { |
216 { |
177 const GParamSpec *pspec; |
217 const GParamSpec *pspec; |
178 |
218 |
179 g_return_if_fail (probe != NULL); |
219 g_return_if_fail (probe != NULL); |
|
220 g_return_if_fail (GST_IS_PROPERTY_PROBE (probe)); |
180 g_return_if_fail (name != NULL); |
221 g_return_if_fail (name != NULL); |
181 |
222 |
182 pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (probe), name); |
223 pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (probe), name); |
183 if (!pspec) { |
224 if (!pspec) { |
184 g_warning ("No such property %s", name); |
225 g_warning ("No such property %s", name); |
203 */ |
244 */ |
204 #ifdef __SYMBIAN32__ |
245 #ifdef __SYMBIAN32__ |
205 EXPORT_C |
246 EXPORT_C |
206 #endif |
247 #endif |
207 |
248 |
208 |
|
209 gboolean |
249 gboolean |
210 gst_property_probe_needs_probe (GstPropertyProbe * probe, |
250 gst_property_probe_needs_probe (GstPropertyProbe * probe, |
211 const GParamSpec * pspec) |
251 const GParamSpec * pspec) |
212 { |
252 { |
213 GstPropertyProbeInterface *iface; |
253 GstPropertyProbeInterface *iface; |
214 |
254 |
215 g_return_val_if_fail (probe != NULL, FALSE); |
255 g_return_val_if_fail (probe != NULL, FALSE); |
|
256 g_return_val_if_fail (GST_IS_PROPERTY_PROBE (probe), FALSE); |
216 g_return_val_if_fail (pspec != NULL, FALSE); |
257 g_return_val_if_fail (pspec != NULL, FALSE); |
217 |
258 |
218 iface = GST_PROPERTY_PROBE_GET_IFACE (probe); |
259 iface = GST_PROPERTY_PROBE_GET_IFACE (probe); |
219 |
260 |
220 if (iface->needs_probe) |
261 if (iface->needs_probe) |
234 */ |
275 */ |
235 #ifdef __SYMBIAN32__ |
276 #ifdef __SYMBIAN32__ |
236 EXPORT_C |
277 EXPORT_C |
237 #endif |
278 #endif |
238 |
279 |
239 |
|
240 gboolean |
280 gboolean |
241 gst_property_probe_needs_probe_name (GstPropertyProbe * probe, |
281 gst_property_probe_needs_probe_name (GstPropertyProbe * probe, |
242 const gchar * name) |
282 const gchar * name) |
243 { |
283 { |
244 const GParamSpec *pspec; |
284 const GParamSpec *pspec; |
245 |
285 |
246 g_return_val_if_fail (probe != NULL, FALSE); |
286 g_return_val_if_fail (probe != NULL, FALSE); |
|
287 g_return_val_if_fail (GST_IS_PROPERTY_PROBE (probe), FALSE); |
247 g_return_val_if_fail (name != NULL, FALSE); |
288 g_return_val_if_fail (name != NULL, FALSE); |
248 |
289 |
249 pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (probe), name); |
290 pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (probe), name); |
250 if (!pspec) { |
291 if (!pspec) { |
251 g_warning ("No such property %s", name); |
292 g_warning ("No such property %s", name); |
267 */ |
308 */ |
268 #ifdef __SYMBIAN32__ |
309 #ifdef __SYMBIAN32__ |
269 EXPORT_C |
310 EXPORT_C |
270 #endif |
311 #endif |
271 |
312 |
272 |
|
273 GValueArray * |
313 GValueArray * |
274 gst_property_probe_get_values (GstPropertyProbe * probe, |
314 gst_property_probe_get_values (GstPropertyProbe * probe, |
275 const GParamSpec * pspec) |
315 const GParamSpec * pspec) |
276 { |
316 { |
277 GstPropertyProbeInterface *iface; |
317 GstPropertyProbeInterface *iface; |
278 |
318 |
279 g_return_val_if_fail (probe != NULL, NULL); |
319 g_return_val_if_fail (probe != NULL, NULL); |
|
320 g_return_val_if_fail (GST_IS_PROPERTY_PROBE (probe), NULL); |
280 g_return_val_if_fail (pspec != NULL, NULL); |
321 g_return_val_if_fail (pspec != NULL, NULL); |
281 |
322 |
282 iface = GST_PROPERTY_PROBE_GET_IFACE (probe); |
323 iface = GST_PROPERTY_PROBE_GET_IFACE (probe); |
283 |
324 |
284 if (iface->get_values) |
325 if (iface->get_values) |
298 */ |
339 */ |
299 #ifdef __SYMBIAN32__ |
340 #ifdef __SYMBIAN32__ |
300 EXPORT_C |
341 EXPORT_C |
301 #endif |
342 #endif |
302 |
343 |
303 |
|
304 GValueArray * |
344 GValueArray * |
305 gst_property_probe_get_values_name (GstPropertyProbe * probe, |
345 gst_property_probe_get_values_name (GstPropertyProbe * probe, |
306 const gchar * name) |
346 const gchar * name) |
307 { |
347 { |
308 const GParamSpec *pspec; |
348 const GParamSpec *pspec; |
309 |
349 |
310 g_return_val_if_fail (probe != NULL, NULL); |
350 g_return_val_if_fail (probe != NULL, NULL); |
|
351 g_return_val_if_fail (GST_IS_PROPERTY_PROBE (probe), NULL); |
311 g_return_val_if_fail (name != NULL, NULL); |
352 g_return_val_if_fail (name != NULL, NULL); |
312 |
353 |
313 pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (probe), name); |
354 pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (probe), name); |
314 if (!pspec) { |
355 if (!pspec) { |
315 g_warning ("No such property %s", name); |
356 g_warning ("No such property %s", name); |
332 */ |
373 */ |
333 #ifdef __SYMBIAN32__ |
374 #ifdef __SYMBIAN32__ |
334 EXPORT_C |
375 EXPORT_C |
335 #endif |
376 #endif |
336 |
377 |
337 |
|
338 GValueArray * |
378 GValueArray * |
339 gst_property_probe_probe_and_get_values (GstPropertyProbe * probe, |
379 gst_property_probe_probe_and_get_values (GstPropertyProbe * probe, |
340 const GParamSpec * pspec) |
380 const GParamSpec * pspec) |
341 { |
381 { |
342 GstPropertyProbeInterface *iface; |
382 GstPropertyProbeInterface *iface; |
343 |
383 |
344 g_return_val_if_fail (probe != NULL, NULL); |
384 g_return_val_if_fail (probe != NULL, NULL); |
|
385 g_return_val_if_fail (GST_IS_PROPERTY_PROBE (probe), NULL); |
345 g_return_val_if_fail (pspec != NULL, NULL); |
386 g_return_val_if_fail (pspec != NULL, NULL); |
346 |
387 |
347 iface = GST_PROPERTY_PROBE_GET_IFACE (probe); |
388 iface = GST_PROPERTY_PROBE_GET_IFACE (probe); |
348 |
389 |
349 if (gst_property_probe_needs_probe (probe, pspec)) |
390 if (gst_property_probe_needs_probe (probe, pspec)) |
363 */ |
404 */ |
364 #ifdef __SYMBIAN32__ |
405 #ifdef __SYMBIAN32__ |
365 EXPORT_C |
406 EXPORT_C |
366 #endif |
407 #endif |
367 |
408 |
368 |
|
369 GValueArray * |
409 GValueArray * |
370 gst_property_probe_probe_and_get_values_name (GstPropertyProbe * probe, |
410 gst_property_probe_probe_and_get_values_name (GstPropertyProbe * probe, |
371 const gchar * name) |
411 const gchar * name) |
372 { |
412 { |
373 const GParamSpec *pspec; |
413 const GParamSpec *pspec; |
374 |
414 |
375 g_return_val_if_fail (probe != NULL, NULL); |
415 g_return_val_if_fail (probe != NULL, NULL); |
|
416 g_return_val_if_fail (GST_IS_PROPERTY_PROBE (probe), NULL); |
376 g_return_val_if_fail (name != NULL, NULL); |
417 g_return_val_if_fail (name != NULL, NULL); |
377 |
418 |
378 pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (probe), name); |
419 pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (probe), name); |
379 if (!pspec) { |
420 if (!pspec) { |
380 g_warning ("No such property %s", name); |
421 g_warning ("No such property %s", name); |