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