|
1 /* GStreamer |
|
2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu> |
|
3 * 2000 Wim Taymans <wtay@chello.be> |
|
4 * 2003 Benjamin Otte <in7y118@public.uni-hamburg.de> |
|
5 * |
|
6 * gstelementfactory.c: GstElementFactory object, support routines |
|
7 * |
|
8 * This library is free software; you can redistribute it and/or |
|
9 * modify it under the terms of the GNU Library General Public |
|
10 * License as published by the Free Software Foundation; either |
|
11 * version 2 of the License, or (at your option) any later version. |
|
12 * |
|
13 * This library is distributed in the hope that it will be useful, |
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
16 * Library General Public License for more details. |
|
17 * |
|
18 * You should have received a copy of the GNU Library General Public |
|
19 * License along with this library; if not, write to the |
|
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|
21 * Boston, MA 02111-1307, USA. |
|
22 */ |
|
23 |
|
24 /** |
|
25 * SECTION:gstelementfactory |
|
26 * @short_description: Create GstElements from a factory |
|
27 * @see_also: #GstElement, #GstPlugin, #GstPluginFeature, #GstPadTemplate. |
|
28 * |
|
29 * #GstElementFactory is used to create instances of elements. A |
|
30 * GstElementfactory can be added to a #GstPlugin as it is also a |
|
31 * #GstPluginFeature. |
|
32 * |
|
33 * Use the gst_element_factory_find() and gst_element_factory_create() |
|
34 * functions to create element instances or use gst_element_factory_make() as a |
|
35 * convenient shortcut. |
|
36 * |
|
37 * The following code example shows you how to create a GstFileSrc element. |
|
38 * |
|
39 * <example> |
|
40 * <title>Using an element factory</title> |
|
41 * <programlisting language="c"> |
|
42 * #include <gst/gst.h> |
|
43 * GstElement *src; |
|
44 * GstElementFactory *srcfactory; |
|
45 * gst_init(&argc,&argv); |
|
46 * srcfactory = gst_element_factory_find("filesrc"); |
|
47 * g_return_if_fail(srcfactory != NULL); |
|
48 * src = gst_element_factory_create(srcfactory,"src"); |
|
49 * g_return_if_fail(src != NULL); |
|
50 * ... |
|
51 * </programlisting> |
|
52 * </example> |
|
53 * |
|
54 * Last reviewed on 2005-11-23 (0.9.5) |
|
55 */ |
|
56 |
|
57 #include "gst_private.h" |
|
58 |
|
59 #include "gstelement.h" |
|
60 #include "gstinfo.h" |
|
61 #include "gsturi.h" |
|
62 #include "gstregistry.h" |
|
63 |
|
64 #include "glib-compat-private.h" |
|
65 |
|
66 GST_DEBUG_CATEGORY_STATIC (element_factory_debug); |
|
67 #define GST_CAT_DEFAULT element_factory_debug |
|
68 |
|
69 static void gst_element_factory_class_init (GstElementFactoryClass * klass); |
|
70 static void gst_element_factory_init (GstElementFactory * factory); |
|
71 static void gst_element_factory_finalize (GObject * object); |
|
72 void __gst_element_details_clear (GstElementDetails * dp); |
|
73 static void gst_element_factory_cleanup (GstElementFactory * factory); |
|
74 |
|
75 static GstPluginFeatureClass *parent_class = NULL; |
|
76 |
|
77 /* static guint gst_element_factory_signals[LAST_SIGNAL] = { 0 }; */ |
|
78 #ifdef __SYMBIAN32__ |
|
79 EXPORT_C |
|
80 #endif |
|
81 |
|
82 |
|
83 GType |
|
84 gst_element_factory_get_type (void) |
|
85 { |
|
86 static GType elementfactory_type = 0; |
|
87 |
|
88 if (G_UNLIKELY (elementfactory_type == 0)) { |
|
89 static const GTypeInfo elementfactory_info = { |
|
90 sizeof (GstElementFactoryClass), |
|
91 NULL, |
|
92 NULL, |
|
93 (GClassInitFunc) gst_element_factory_class_init, |
|
94 NULL, |
|
95 NULL, |
|
96 sizeof (GstElementFactory), |
|
97 0, |
|
98 (GInstanceInitFunc) gst_element_factory_init, |
|
99 NULL |
|
100 }; |
|
101 |
|
102 elementfactory_type = g_type_register_static (GST_TYPE_PLUGIN_FEATURE, |
|
103 "GstElementFactory", &elementfactory_info, 0); |
|
104 GST_DEBUG_CATEGORY_INIT (element_factory_debug, "GST_ELEMENT_FACTORY", |
|
105 GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED, |
|
106 "element factories keep information about installed elements"); |
|
107 } |
|
108 return elementfactory_type; |
|
109 } |
|
110 static void |
|
111 gst_element_factory_class_init (GstElementFactoryClass * klass) |
|
112 { |
|
113 GObjectClass *gobject_class; |
|
114 GstObjectClass *gstobject_class; |
|
115 GstPluginFeatureClass *gstpluginfeature_class; |
|
116 |
|
117 gobject_class = (GObjectClass *) klass; |
|
118 gstobject_class = (GstObjectClass *) klass; |
|
119 gstpluginfeature_class = (GstPluginFeatureClass *) klass; |
|
120 |
|
121 parent_class = g_type_class_peek_parent (klass); |
|
122 |
|
123 gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_element_factory_finalize); |
|
124 } |
|
125 |
|
126 static void |
|
127 gst_element_factory_init (GstElementFactory * factory) |
|
128 { |
|
129 factory->staticpadtemplates = NULL; |
|
130 factory->numpadtemplates = 0; |
|
131 |
|
132 factory->uri_type = GST_URI_UNKNOWN; |
|
133 factory->uri_protocols = NULL; |
|
134 |
|
135 factory->interfaces = NULL; |
|
136 } |
|
137 |
|
138 static void |
|
139 gst_element_factory_finalize (GObject * object) |
|
140 { |
|
141 GstElementFactory *factory = GST_ELEMENT_FACTORY (object); |
|
142 |
|
143 gst_element_factory_cleanup (factory); |
|
144 G_OBJECT_CLASS (parent_class)->finalize (object); |
|
145 } |
|
146 |
|
147 /** |
|
148 * gst_element_factory_find: |
|
149 * @name: name of factory to find |
|
150 * |
|
151 * Search for an element factory of the given name. Refs the returned |
|
152 * element factory; caller is responsible for unreffing. |
|
153 * |
|
154 * Returns: #GstElementFactory if found, NULL otherwise |
|
155 */ |
|
156 #ifdef __SYMBIAN32__ |
|
157 EXPORT_C |
|
158 #endif |
|
159 |
|
160 GstElementFactory * |
|
161 gst_element_factory_find (const gchar * name) |
|
162 { |
|
163 GstPluginFeature *feature; |
|
164 |
|
165 g_return_val_if_fail (name != NULL, NULL); |
|
166 |
|
167 feature = gst_registry_find_feature (gst_registry_get_default (), name, |
|
168 GST_TYPE_ELEMENT_FACTORY); |
|
169 if (feature) |
|
170 return GST_ELEMENT_FACTORY (feature); |
|
171 |
|
172 /* this isn't an error, for instance when you query if an element factory is |
|
173 * present */ |
|
174 GST_LOG ("no such element factory \"%s\"", name); |
|
175 return NULL; |
|
176 } |
|
177 #ifdef __SYMBIAN32__ |
|
178 EXPORT_C |
|
179 #endif |
|
180 |
|
181 |
|
182 void |
|
183 __gst_element_details_clear (GstElementDetails * dp) |
|
184 { |
|
185 g_free (dp->longname); |
|
186 g_free (dp->klass); |
|
187 g_free (dp->description); |
|
188 g_free (dp->author); |
|
189 memset (dp, 0, sizeof (GstElementDetails)); |
|
190 } |
|
191 |
|
192 #define VALIDATE_SET(__dest, __src, __entry) \ |
|
193 G_STMT_START { \ |
|
194 if (g_utf8_validate (__src->__entry, -1, NULL)) { \ |
|
195 __dest->__entry = g_strdup (__src->__entry); \ |
|
196 } else { \ |
|
197 g_warning ("Invalid UTF-8 in " G_STRINGIFY (__entry) ": %s", \ |
|
198 __src->__entry); \ |
|
199 __dest->__entry = g_strdup ("[ERROR: invalid UTF-8]"); \ |
|
200 } \ |
|
201 } G_STMT_END |
|
202 |
|
203 #ifdef __SYMBIAN32__ |
|
204 EXPORT_C |
|
205 #endif |
|
206 void |
|
207 __gst_element_details_set (GstElementDetails * dest, |
|
208 const GstElementDetails * src) |
|
209 { |
|
210 VALIDATE_SET (dest, src, longname); |
|
211 VALIDATE_SET (dest, src, klass); |
|
212 VALIDATE_SET (dest, src, description); |
|
213 VALIDATE_SET (dest, src, author); |
|
214 } |
|
215 #ifdef __SYMBIAN32__ |
|
216 EXPORT_C |
|
217 #endif |
|
218 |
|
219 |
|
220 void |
|
221 __gst_element_details_copy (GstElementDetails * dest, |
|
222 const GstElementDetails * src) |
|
223 { |
|
224 __gst_element_details_clear (dest); |
|
225 __gst_element_details_set (dest, src); |
|
226 } |
|
227 |
|
228 static void |
|
229 gst_element_factory_cleanup (GstElementFactory * factory) |
|
230 { |
|
231 GList *item; |
|
232 |
|
233 __gst_element_details_clear (&factory->details); |
|
234 if (factory->type) { |
|
235 g_type_class_unref (g_type_class_peek (factory->type)); |
|
236 factory->type = 0; |
|
237 } |
|
238 |
|
239 for (item = factory->staticpadtemplates; item; item = item->next) { |
|
240 GstStaticPadTemplate *templ = item->data; |
|
241 GstCaps *caps = (GstCaps *) & (templ->static_caps); |
|
242 |
|
243 g_free ((gchar *) templ->static_caps.string); |
|
244 |
|
245 /* FIXME: this is not threadsafe */ |
|
246 if (caps->refcount == 1) { |
|
247 GstStructure *structure; |
|
248 guint i; |
|
249 |
|
250 for (i = 0; i < caps->structs->len; i++) { |
|
251 structure = (GstStructure *) gst_caps_get_structure (caps, i); |
|
252 gst_structure_set_parent_refcount (structure, NULL); |
|
253 gst_structure_free (structure); |
|
254 } |
|
255 g_ptr_array_free (caps->structs, TRUE); |
|
256 caps->refcount = 0; |
|
257 } |
|
258 g_free (templ); |
|
259 } |
|
260 g_list_free (factory->staticpadtemplates); |
|
261 factory->staticpadtemplates = NULL; |
|
262 factory->numpadtemplates = 0; |
|
263 factory->uri_type = GST_URI_UNKNOWN; |
|
264 if (factory->uri_protocols) { |
|
265 g_strfreev (factory->uri_protocols); |
|
266 factory->uri_protocols = NULL; |
|
267 } |
|
268 |
|
269 g_list_foreach (factory->interfaces, (GFunc) g_free, NULL); |
|
270 g_list_free (factory->interfaces); |
|
271 factory->interfaces = NULL; |
|
272 } |
|
273 |
|
274 /** |
|
275 * gst_element_register: |
|
276 * @plugin: #GstPlugin to register the element with, or NULL for a static |
|
277 * element (note that passing NULL only works in GStreamer 0.10.13 and later) |
|
278 * @name: name of elements of this type |
|
279 * @rank: rank of element (higher rank means more importance when autoplugging) |
|
280 * @type: GType of element to register |
|
281 * |
|
282 * Create a new elementfactory capable of instantiating objects of the |
|
283 * @type and add the factory to @plugin. |
|
284 * |
|
285 * Returns: TRUE, if the registering succeeded, FALSE on error |
|
286 */ |
|
287 #ifdef __SYMBIAN32__ |
|
288 EXPORT_C |
|
289 #endif |
|
290 |
|
291 gboolean |
|
292 gst_element_register (GstPlugin * plugin, const gchar * name, guint rank, |
|
293 GType type) |
|
294 { |
|
295 GstElementFactory *factory; |
|
296 GType *interfaces; |
|
297 guint n_interfaces, i; |
|
298 GstElementClass *klass; |
|
299 GList *item; |
|
300 |
|
301 g_return_val_if_fail (name != NULL, FALSE); |
|
302 g_return_val_if_fail (g_type_is_a (type, GST_TYPE_ELEMENT), FALSE); |
|
303 |
|
304 factory = GST_ELEMENT_FACTORY (g_object_new (GST_TYPE_ELEMENT_FACTORY, NULL)); |
|
305 gst_plugin_feature_set_name (GST_PLUGIN_FEATURE (factory), name); |
|
306 GST_LOG_OBJECT (factory, "Created new elementfactory for type %s", |
|
307 g_type_name (type)); |
|
308 |
|
309 klass = GST_ELEMENT_CLASS (g_type_class_ref (type)); |
|
310 if ((klass->details.longname == NULL) || |
|
311 (klass->details.klass == NULL) || (klass->details.author == NULL)) |
|
312 goto detailserror; |
|
313 |
|
314 factory->type = type; |
|
315 __gst_element_details_copy (&factory->details, &klass->details); |
|
316 for (item = klass->padtemplates; item; item = item->next) { |
|
317 GstPadTemplate *templ = item->data; |
|
318 GstStaticPadTemplate *newt; |
|
319 |
|
320 newt = g_new0 (GstStaticPadTemplate, 1); |
|
321 newt->name_template = g_intern_string (templ->name_template); |
|
322 newt->direction = templ->direction; |
|
323 newt->presence = templ->presence; |
|
324 newt->static_caps.string = gst_caps_to_string (templ->caps); |
|
325 factory->staticpadtemplates = |
|
326 g_list_append (factory->staticpadtemplates, newt); |
|
327 } |
|
328 factory->numpadtemplates = klass->numpadtemplates; |
|
329 klass->elementfactory = factory; |
|
330 |
|
331 /* special stuff for URI handling */ |
|
332 if (g_type_is_a (type, GST_TYPE_URI_HANDLER)) { |
|
333 GstURIHandlerInterface *iface = (GstURIHandlerInterface *) |
|
334 g_type_interface_peek (klass, GST_TYPE_URI_HANDLER); |
|
335 |
|
336 if (!iface || (!iface->get_type && !iface->get_type_full) || |
|
337 (!iface->get_protocols && !iface->get_protocols_full)) |
|
338 goto urierror; |
|
339 if (iface->get_type) |
|
340 factory->uri_type = iface->get_type (); |
|
341 else if (iface->get_type_full) |
|
342 factory->uri_type = iface->get_type_full (factory->type); |
|
343 if (!GST_URI_TYPE_IS_VALID (factory->uri_type)) |
|
344 goto urierror; |
|
345 if (iface->get_protocols) |
|
346 factory->uri_protocols = g_strdupv (iface->get_protocols ()); |
|
347 else if (iface->get_protocols_full) |
|
348 factory->uri_protocols = iface->get_protocols_full (factory->type); |
|
349 if (!factory->uri_protocols) |
|
350 goto urierror; |
|
351 } |
|
352 |
|
353 interfaces = g_type_interfaces (type, &n_interfaces); |
|
354 for (i = 0; i < n_interfaces; i++) { |
|
355 __gst_element_factory_add_interface (factory, g_type_name (interfaces[i])); |
|
356 } |
|
357 g_free (interfaces); |
|
358 |
|
359 if (plugin && plugin->desc.name) { |
|
360 GST_PLUGIN_FEATURE (factory)->plugin_name = plugin->desc.name; |
|
361 } else { |
|
362 GST_PLUGIN_FEATURE (factory)->plugin_name = "NULL"; |
|
363 } |
|
364 gst_plugin_feature_set_rank (GST_PLUGIN_FEATURE (factory), rank); |
|
365 GST_PLUGIN_FEATURE (factory)->loaded = TRUE; |
|
366 |
|
367 gst_registry_add_feature (gst_registry_get_default (), |
|
368 GST_PLUGIN_FEATURE (factory)); |
|
369 |
|
370 return TRUE; |
|
371 |
|
372 /* ERRORS */ |
|
373 urierror: |
|
374 { |
|
375 GST_WARNING_OBJECT (factory, "error with uri handler!"); |
|
376 gst_element_factory_cleanup (factory); |
|
377 return FALSE; |
|
378 } |
|
379 |
|
380 detailserror: |
|
381 { |
|
382 GST_WARNING_OBJECT (factory, |
|
383 "The GstElementDetails don't seem to have been set properly"); |
|
384 gst_element_factory_cleanup (factory); |
|
385 return FALSE; |
|
386 } |
|
387 } |
|
388 |
|
389 /** |
|
390 * gst_element_factory_create: |
|
391 * @factory: factory to instantiate |
|
392 * @name: name of new element |
|
393 * |
|
394 * Create a new element of the type defined by the given elementfactory. |
|
395 * It will be given the name supplied, since all elements require a name as |
|
396 * their first argument. |
|
397 * |
|
398 * Returns: new #GstElement or NULL if the element couldn't be created |
|
399 */ |
|
400 #ifdef __SYMBIAN32__ |
|
401 EXPORT_C |
|
402 #endif |
|
403 |
|
404 GstElement * |
|
405 gst_element_factory_create (GstElementFactory * factory, const gchar * name) |
|
406 { |
|
407 GstElement *element; |
|
408 GstElementClass *oclass; |
|
409 GstElementFactory *newfactory; |
|
410 |
|
411 g_return_val_if_fail (factory != NULL, NULL); |
|
412 |
|
413 newfactory = |
|
414 GST_ELEMENT_FACTORY (gst_plugin_feature_load (GST_PLUGIN_FEATURE |
|
415 (factory))); |
|
416 |
|
417 if (newfactory == NULL) |
|
418 goto load_failed; |
|
419 |
|
420 factory = newfactory; |
|
421 |
|
422 if (name) |
|
423 GST_INFO ("creating element \"%s\" named \"%s\"", |
|
424 GST_PLUGIN_FEATURE_NAME (factory), GST_STR_NULL (name)); |
|
425 else |
|
426 GST_INFO ("creating element \"%s\"", GST_PLUGIN_FEATURE_NAME (factory)); |
|
427 |
|
428 if (factory->type == 0) |
|
429 goto no_type; |
|
430 |
|
431 /* create an instance of the element, cast so we don't assert on NULL */ |
|
432 element = GST_ELEMENT_CAST (g_object_new (factory->type, NULL)); |
|
433 if (G_UNLIKELY (element == NULL)) |
|
434 goto no_element; |
|
435 |
|
436 /* fill in the pointer to the factory in the element class. The |
|
437 * class will not be unreffed currently. |
|
438 * FIXME: This isn't safe and may leak a refcount on the factory if 2 threads |
|
439 * create the first instance of an element at the same moment */ |
|
440 oclass = GST_ELEMENT_GET_CLASS (element); |
|
441 if (G_UNLIKELY (oclass->elementfactory == NULL)) |
|
442 oclass->elementfactory = factory; |
|
443 else |
|
444 gst_object_unref (factory); |
|
445 |
|
446 if (name) |
|
447 gst_object_set_name (GST_OBJECT (element), name); |
|
448 |
|
449 GST_DEBUG ("created element \"%s\"", GST_PLUGIN_FEATURE_NAME (factory)); |
|
450 |
|
451 return element; |
|
452 |
|
453 /* ERRORS */ |
|
454 load_failed: |
|
455 { |
|
456 GST_WARNING_OBJECT (factory, "loading plugin returned NULL!"); |
|
457 return NULL; |
|
458 } |
|
459 no_type: |
|
460 { |
|
461 GST_WARNING_OBJECT (factory, "factory has no type"); |
|
462 gst_object_unref (factory); |
|
463 return NULL; |
|
464 } |
|
465 no_element: |
|
466 { |
|
467 GST_WARNING_OBJECT (factory, "could not create element"); |
|
468 gst_object_unref (factory); |
|
469 return NULL; |
|
470 } |
|
471 } |
|
472 |
|
473 /** |
|
474 * gst_element_factory_make: |
|
475 * @factoryname: a named factory to instantiate |
|
476 * @name: name of new element |
|
477 * |
|
478 * Create a new element of the type defined by the given element factory. |
|
479 * If name is NULL, then the element will receive a guaranteed unique name, |
|
480 * consisting of the element factory name and a number. |
|
481 * If name is given, it will be given the name supplied. |
|
482 * |
|
483 * Returns: new #GstElement or NULL if unable to create element |
|
484 */ |
|
485 #ifdef __SYMBIAN32__ |
|
486 EXPORT_C |
|
487 #endif |
|
488 |
|
489 GstElement * |
|
490 gst_element_factory_make (const gchar * factoryname, const gchar * name) |
|
491 { |
|
492 GstElementFactory *factory; |
|
493 GstElement *element; |
|
494 |
|
495 g_return_val_if_fail (factoryname != NULL, NULL); |
|
496 |
|
497 GST_LOG ("gstelementfactory: make \"%s\" \"%s\"", |
|
498 factoryname, GST_STR_NULL (name)); |
|
499 |
|
500 factory = gst_element_factory_find (factoryname); |
|
501 if (factory == NULL) |
|
502 goto no_factory; |
|
503 |
|
504 GST_LOG_OBJECT (factory, "found factory %p", factory); |
|
505 element = gst_element_factory_create (factory, name); |
|
506 gst_object_unref (factory); |
|
507 if (element == NULL) |
|
508 goto create_failed; |
|
509 |
|
510 return element; |
|
511 |
|
512 /* ERRORS */ |
|
513 no_factory: |
|
514 { |
|
515 GST_INFO ("no such element factory \"%s\"!", factoryname); |
|
516 return NULL; |
|
517 } |
|
518 create_failed: |
|
519 { |
|
520 GST_INFO_OBJECT (factory, "couldn't create instance!"); |
|
521 return NULL; |
|
522 } |
|
523 } |
|
524 #ifdef __SYMBIAN32__ |
|
525 EXPORT_C |
|
526 #endif |
|
527 |
|
528 |
|
529 void |
|
530 __gst_element_factory_add_static_pad_template (GstElementFactory * factory, |
|
531 GstStaticPadTemplate * templ) |
|
532 { |
|
533 g_return_if_fail (factory != NULL); |
|
534 g_return_if_fail (templ != NULL); |
|
535 |
|
536 factory->staticpadtemplates = |
|
537 g_list_append (factory->staticpadtemplates, templ); |
|
538 factory->numpadtemplates++; |
|
539 } |
|
540 |
|
541 /** |
|
542 * gst_element_factory_get_element_type: |
|
543 * @factory: factory to get managed #GType from |
|
544 * |
|
545 * Get the #GType for elements managed by this factory. The type can |
|
546 * only be retrieved if the element factory is loaded, which can be |
|
547 * assured with gst_plugin_feature_load(). |
|
548 * |
|
549 * Returns: the #GType for elements managed by this factory or 0 if |
|
550 * the factory is not loaded. |
|
551 */ |
|
552 #ifdef __SYMBIAN32__ |
|
553 EXPORT_C |
|
554 #endif |
|
555 |
|
556 GType |
|
557 gst_element_factory_get_element_type (GstElementFactory * factory) |
|
558 { |
|
559 g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), 0); |
|
560 |
|
561 return factory->type; |
|
562 } |
|
563 |
|
564 /** |
|
565 * gst_element_factory_get_longname: |
|
566 * @factory: a #GstElementFactory |
|
567 * |
|
568 * Gets the longname for this factory |
|
569 * |
|
570 * Returns: the longname |
|
571 */ |
|
572 #ifdef __SYMBIAN32__ |
|
573 EXPORT_C |
|
574 #endif |
|
575 |
|
576 G_CONST_RETURN gchar * |
|
577 gst_element_factory_get_longname (GstElementFactory * factory) |
|
578 { |
|
579 g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), NULL); |
|
580 |
|
581 return factory->details.longname; |
|
582 } |
|
583 |
|
584 /** |
|
585 * gst_element_factory_get_klass: |
|
586 * @factory: a #GstElementFactory |
|
587 * |
|
588 * Gets the class for this factory. |
|
589 * |
|
590 * Returns: the class |
|
591 */ |
|
592 #ifdef __SYMBIAN32__ |
|
593 EXPORT_C |
|
594 #endif |
|
595 |
|
596 G_CONST_RETURN gchar * |
|
597 gst_element_factory_get_klass (GstElementFactory * factory) |
|
598 { |
|
599 g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), NULL); |
|
600 |
|
601 return factory->details.klass; |
|
602 } |
|
603 |
|
604 /** |
|
605 * gst_element_factory_get_description: |
|
606 * @factory: a #GstElementFactory |
|
607 * |
|
608 * Gets the description for this factory. |
|
609 * |
|
610 * Returns: the description |
|
611 */ |
|
612 #ifdef __SYMBIAN32__ |
|
613 EXPORT_C |
|
614 #endif |
|
615 |
|
616 G_CONST_RETURN gchar * |
|
617 gst_element_factory_get_description (GstElementFactory * factory) |
|
618 { |
|
619 g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), NULL); |
|
620 |
|
621 return factory->details.description; |
|
622 } |
|
623 |
|
624 /** |
|
625 * gst_element_factory_get_author: |
|
626 * @factory: a #GstElementFactory |
|
627 * |
|
628 * Gets the author for this factory. |
|
629 * |
|
630 * Returns: the author |
|
631 */ |
|
632 #ifdef __SYMBIAN32__ |
|
633 EXPORT_C |
|
634 #endif |
|
635 |
|
636 G_CONST_RETURN gchar * |
|
637 gst_element_factory_get_author (GstElementFactory * factory) |
|
638 { |
|
639 g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), NULL); |
|
640 |
|
641 return factory->details.author; |
|
642 } |
|
643 |
|
644 /** |
|
645 * gst_element_factory_get_num_pad_templates: |
|
646 * @factory: a #GstElementFactory |
|
647 * |
|
648 * Gets the number of pad_templates in this factory. |
|
649 * |
|
650 * Returns: the number of pad_templates |
|
651 */ |
|
652 #ifdef __SYMBIAN32__ |
|
653 EXPORT_C |
|
654 #endif |
|
655 |
|
656 guint |
|
657 gst_element_factory_get_num_pad_templates (GstElementFactory * factory) |
|
658 { |
|
659 g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), 0); |
|
660 |
|
661 return factory->numpadtemplates; |
|
662 } |
|
663 |
|
664 /** |
|
665 * __gst_element_factory_add_interface: |
|
666 * @elementfactory: The elementfactory to add the interface to |
|
667 * @interfacename: Name of the interface |
|
668 * |
|
669 * Adds the given interfacename to the list of implemented interfaces of the |
|
670 * element. |
|
671 */ |
|
672 #ifdef __SYMBIAN32__ |
|
673 EXPORT_C |
|
674 #endif |
|
675 |
|
676 void |
|
677 __gst_element_factory_add_interface (GstElementFactory * elementfactory, |
|
678 const gchar * interfacename) |
|
679 { |
|
680 g_return_if_fail (GST_IS_ELEMENT_FACTORY (elementfactory)); |
|
681 g_return_if_fail (interfacename != NULL); |
|
682 g_return_if_fail (interfacename[0] != '\0'); /* no empty string */ |
|
683 |
|
684 elementfactory->interfaces = |
|
685 g_list_prepend (elementfactory->interfaces, g_strdup (interfacename)); |
|
686 } |
|
687 |
|
688 /** |
|
689 * gst_element_factory_get_static_pad_templates: |
|
690 * @factory: a #GstElementFactory |
|
691 * |
|
692 * Gets the #GList of #GstStaticPadTemplate for this factory. |
|
693 * |
|
694 * Returns: the padtemplates |
|
695 */ |
|
696 #ifdef __SYMBIAN32__ |
|
697 EXPORT_C |
|
698 #endif |
|
699 |
|
700 G_CONST_RETURN GList * |
|
701 gst_element_factory_get_static_pad_templates (GstElementFactory * factory) |
|
702 { |
|
703 g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), NULL); |
|
704 |
|
705 return factory->staticpadtemplates; |
|
706 } |
|
707 |
|
708 /** |
|
709 * gst_element_factory_get_uri_type: |
|
710 * @factory: a #GstElementFactory |
|
711 * |
|
712 * Gets the type of URIs the element supports or GST_URI_UNKNOWN if none. |
|
713 * |
|
714 * Returns: type of URIs this element supports |
|
715 */ |
|
716 #ifdef __SYMBIAN32__ |
|
717 EXPORT_C |
|
718 #endif |
|
719 |
|
720 gint |
|
721 gst_element_factory_get_uri_type (GstElementFactory * factory) |
|
722 { |
|
723 g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), GST_URI_UNKNOWN); |
|
724 |
|
725 return factory->uri_type; |
|
726 } |
|
727 |
|
728 /** |
|
729 * gst_element_factory_get_uri_protocols: |
|
730 * @factory: a #GstElementFactory |
|
731 * |
|
732 * Gets a NULL-terminated array of protocols this element supports or NULL if |
|
733 * no protocols are supported. You may not change the contents of the returned |
|
734 * array, as it is still owned by the element factory. Use g_strdupv() to |
|
735 * make a copy of the protocol string array if you need to. |
|
736 * |
|
737 * Returns: the supported protocols or NULL |
|
738 */ |
|
739 #ifdef __SYMBIAN32__ |
|
740 EXPORT_C |
|
741 #endif |
|
742 |
|
743 gchar ** |
|
744 gst_element_factory_get_uri_protocols (GstElementFactory * factory) |
|
745 { |
|
746 g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), NULL); |
|
747 |
|
748 return factory->uri_protocols; |
|
749 } |
|
750 |
|
751 /** |
|
752 * gst_element_factory_has_interface: |
|
753 * @factory: a #GstElementFactory |
|
754 * @interfacename: an interface name |
|
755 * |
|
756 * Check if @factory implements the interface with name @interfacename. |
|
757 * |
|
758 * Returns: #TRUE when @factory implement the interface. |
|
759 * |
|
760 * Since: 0.10.14 |
|
761 */ |
|
762 #ifdef __SYMBIAN32__ |
|
763 EXPORT_C |
|
764 #endif |
|
765 |
|
766 gboolean |
|
767 gst_element_factory_has_interface (GstElementFactory * factory, |
|
768 const gchar * interfacename) |
|
769 { |
|
770 GList *walk; |
|
771 |
|
772 g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), FALSE); |
|
773 |
|
774 for (walk = factory->interfaces; walk; walk = g_list_next (walk)) { |
|
775 gchar *iname = (gchar *) walk->data; |
|
776 |
|
777 if (!strcmp (iname, interfacename)) |
|
778 return TRUE; |
|
779 } |
|
780 return FALSE; |
|
781 } |