2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD 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
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = gstreamer-GstStructure.html
28 * strct = GstStructure
49 * - GstStructure* -> Structure
54 module gstreamer
.Structure
;
56 private import gstreamerc
.gstreamertypes
;
58 private import gstreamerc
.gstreamer
;
60 private import glib
.Str
;
61 private import gobject
.Value
;
67 * A GstStructure is a collection of key/value pairs. The keys are expressed
68 * as GQuarks and the values can be of any GType.
69 * In addition to the key/value pairs, a GstStructure also has a name.
70 * GstStructure is used by various GStreamer subsystems to store information
71 * in a flexible and extensible way. A GstStructure does not have a refcount
72 * because it usually is part of a higher level object such as GstCaps. It
73 * provides a means to enforce mutability using the refcount of the parent
74 * with the gst_structure_set_parent_refcount() method.
75 * A GstStructure can be created with gst_structure_empty_new() or
76 * gst_structure_new(), which both take a name and an optional set of
77 * key/value pairs along with the types of the values.
78 * Field values can be changed with gst_structure_set_value() or
79 * gst_structure_set().
80 * Field values can be retrieved with gst_structure_get_value() or the more
81 * convenient gst_structure_get_*() functions.
82 * Fields can be removed with gst_structure_remove_field() or
83 * gst_structure_remove_fields().
84 * Last reviewed on 2005-11-09 (0.9.4)
86 public class Structure
89 /** the main Gtk struct */
90 protected GstStructure
* gstStructure
;
93 public GstStructure
* getStructureStruct()
99 /** the main Gtk struct as a void* */
100 protected void* getStruct()
102 return cast(void*)gstStructure
;
106 * Sets our main struct and passes it to the parent class
108 public this (GstStructure
* gstStructure
)
110 this.gstStructure
= gstStructure
;
120 * Creates a new, empty GstStructure with the given name.
122 * name of new structure
124 * a new, empty GstStructure
126 public static Structure
emptyNew(char[] name
)
128 // GstStructure* gst_structure_empty_new (const gchar *name);
129 return new Structure( gst_structure_empty_new(Str
.toStringz(name
)) );
133 * Creates a new, empty GstStructure with the given name as a GQuark.
135 * name of new structure
137 * a new, empty GstStructure
139 public static Structure
idEmptyNew(GQuark quark
)
141 // GstStructure* gst_structure_id_empty_new (GQuark quark);
142 return new Structure( gst_structure_id_empty_new(quark
) );
146 * Creates a new GstStructure with the given name. Parses the
147 * list of variable arguments and sets fields to the values listed.
148 * Variable arguments should be passed as field name, field type,
149 * and value. Last variable argument should be NULL.
151 * name of new structure
153 * name of first field to set
155 * additional arguments
159 public this (char[] name
, char[] firstfield
, ... )
161 // GstStructure* gst_structure_new (const gchar *name, const gchar *firstfield, ...);
162 this(cast(GstStructure
*)gst_structure_new(Str
.toStringz(name
), Str
.toStringz(firstfield
)) );
166 * Creates a new GstStructure with the given name. Structure fields
167 * are set according to the varargs in a manner similar to
170 * name of new structure
172 * name of first field to set
174 * variable argument list
178 public this (char[] name
, char[] firstfield
, void* varargs
)
180 // GstStructure* gst_structure_new_valist (const gchar *name, const gchar *firstfield, va_list varargs);
181 this(cast(GstStructure
*)gst_structure_new_valist(Str
.toStringz(name
), Str
.toStringz(firstfield
), varargs
) );
185 * Duplicates a GstStructure and all its fields and values.
187 * a GstStructure to duplicate
189 * a new GstStructure.
191 public Structure
copy()
193 // GstStructure* gst_structure_copy (const GstStructure *structure);
194 return new Structure( gst_structure_copy(gstStructure
) );
198 * Frees a GstStructure and all its fields and values. The structure must not
199 * have a parent when this function is called.
201 * the GstStructure to free
205 // void gst_structure_free (GstStructure *structure);
206 gst_structure_free(gstStructure
);
210 * Get the name of structure as a string.
214 * the name of the structure.
216 public char[] getName()
218 // const gchar* gst_structure_get_name (const GstStructure *structure);
219 return Str
.toString(gst_structure_get_name(gstStructure
) );
223 * Checks if the structure has the given name
227 * structure name to check for
229 * TRUE if name matches the name of the structure.
231 public int hasName(char[] name
)
233 // gboolean gst_structure_has_name (const GstStructure *structure, const gchar *name);
234 return gst_structure_has_name(gstStructure
, Str
.toStringz(name
));
238 * Sets the name of the structure to the given name. The string
239 * provided is copied before being used.
243 * the new name of the structure
245 public void setName(char[] name
)
247 // void gst_structure_set_name (GstStructure *structure, const gchar *name);
248 gst_structure_set_name(gstStructure
, Str
.toStringz(name
));
252 * Get the name of structure as a GQuark.
256 * the quark representing the name of the structure.
258 public GQuark
getNameId()
260 // GQuark gst_structure_get_name_id (const GstStructure *structure);
261 return gst_structure_get_name_id(gstStructure
);
265 * Get the value of the field with GQuark field.
269 * the GQuark of the field to get
271 * the GValue corresponding to the field with the given name
274 public Value
idGetValue(GQuark field
)
276 // const GValue* gst_structure_id_get_value (const GstStructure *structure, GQuark field);
277 return new Value( gst_structure_id_get_value(gstStructure
, field
) );
281 * Sets the field with the given GQuark field to value. If the field
282 * does not exist, it is created. If the field exists, the previous
283 * value is replaced and freed.
287 * a GQuark representing a field
289 * the new value of the field
291 public void idSetValue(GQuark field
, Value value
)
293 // void gst_structure_id_set_value (GstStructure *structure, GQuark field, const GValue *value);
294 gst_structure_id_set_value(gstStructure
, field
, (value
is null) ?
null : value
.getValueStruct());
298 * Get the value of the field with name fieldname.
302 * the name of the field to get
304 * the GValue corresponding to the field with the given name.
306 public Value
getValue(char[] fieldname
)
308 // const GValue* gst_structure_get_value (const GstStructure *structure, const gchar *fieldname);
309 return new Value( gst_structure_get_value(gstStructure
, Str
.toStringz(fieldname
)) );
313 * Sets the field with the given name field to value. If the field
314 * does not exist, it is created. If the field exists, the previous
315 * value is replaced and freed.
319 * the name of the field to set
321 * the new value of the field
323 public void setValue(char[] fieldname
, Value value
)
325 // void gst_structure_set_value (GstStructure *structure, const gchar *fieldname, const GValue *value);
326 gst_structure_set_value(gstStructure
, Str
.toStringz(fieldname
), (value
is null) ?
null : value
.getValueStruct());
330 * Parses the variable arguments and sets fields accordingly.
331 * Variable arguments should be in the form field name, field type
332 * (as a GType), value(s). The last variable argument should be NULL.
336 * the name of the field to set
340 public void set(char[] fieldname
, ... )
342 // void gst_structure_set (GstStructure *structure, const gchar *fieldname, ...);
343 gst_structure_set(gstStructure
, Str
.toStringz(fieldname
));
347 * va_list form of gst_structure_set().
351 * the name of the field to set
355 public void setValist(char[] fieldname
, void* varargs
)
357 // void gst_structure_set_valist (GstStructure *structure, const gchar *fieldname, va_list varargs);
358 gst_structure_set_valist(gstStructure
, Str
.toStringz(fieldname
), varargs
);
362 * Identical to gst_structure_set, except that field names are
363 * passed using the GQuark for the field name. This allows more efficient
364 * setting of the structure if the caller already knows the associated
366 * The last variable argument must be NULL.
370 * the GQuark for the name of the field to set
375 public void idSet(GQuark fieldname
, ... )
377 // void gst_structure_id_set (GstStructure *structure, GQuark fieldname, ...);
378 gst_structure_id_set(gstStructure
, fieldname
);
382 * va_list form of gst_structure_id_set().
386 * the name of the field to set
391 public void idSetValist(GQuark fieldname
, void* varargs
)
393 // void gst_structure_id_set_valist (GstStructure *structure, GQuark fieldname, va_list varargs);
394 gst_structure_id_set_valist(gstStructure
, fieldname
, varargs
);
398 * Removes the field with the given name. If the field with the given
399 * name does not exist, the structure is unchanged.
403 * the name of the field to remove
405 public void removeField(char[] fieldname
)
407 // void gst_structure_remove_field (GstStructure *structure, const gchar *fieldname);
408 gst_structure_remove_field(gstStructure
, Str
.toStringz(fieldname
));
412 * Removes the fields with the given names. If a field does not exist, the
413 * argument is ignored.
417 * the name of the field to remove
419 * NULL-terminated list of more fieldnames to remove
421 public void removeFields(char[] fieldname
, ... )
423 // void gst_structure_remove_fields (GstStructure *structure, const gchar *fieldname, ...);
424 gst_structure_remove_fields(gstStructure
, Str
.toStringz(fieldname
));
428 * va_list form of gst_structure_remove_fields().
432 * the name of the field to remove
434 * NULL-terminated list of more fieldnames to remove
436 public void removeFieldsValist(char[] fieldname
, void* varargs
)
438 // void gst_structure_remove_fields_valist (GstStructure *structure, const gchar *fieldname, va_list varargs);
439 gst_structure_remove_fields_valist(gstStructure
, Str
.toStringz(fieldname
), varargs
);
443 * Removes all fields in a GstStructure.
447 public void removeAllFields()
449 // void gst_structure_remove_all_fields (GstStructure *structure);
450 gst_structure_remove_all_fields(gstStructure
);
454 * Finds the field with the given name, and returns the type of the
455 * value it contains. If the field is not found, G_TYPE_INVALID is
460 * the name of the field
462 * the GValue of the field
464 public GType
getFieldType(char[] fieldname
)
466 // GType gst_structure_get_field_type (const GstStructure *structure, const gchar *fieldname);
467 return gst_structure_get_field_type(gstStructure
, Str
.toStringz(fieldname
));
471 * Calls the provided function once for each field in the GstStructure. The
472 * function must not modify the fields. Also see gst_structure_map_in_place().
476 * a function to call for each field
480 * TRUE if the supplied function returns TRUE For each of the fields,
483 public int foreac(GstStructureForeachFunc func
, void* userData
)
485 // gboolean gst_structure_foreach (const GstStructure *structure, GstStructureForeachFunc func, gpointer user_data);
486 return gst_structure_foreach(gstStructure
, func
, userData
);
490 * Get the number of fields in the structure.
494 * the number of fields in the structure
498 // gint gst_structure_n_fields (const GstStructure *structure);
499 return gst_structure_n_fields(gstStructure
);
503 * Check if structure contains a field named fieldname.
507 * the name of a field
509 * TRUE if the structure contains a field with the given name
511 public int hasField(char[] fieldname
)
513 // gboolean gst_structure_has_field (const GstStructure *structure, const gchar *fieldname);
514 return gst_structure_has_field(gstStructure
, Str
.toStringz(fieldname
));
518 * Check if structure contains a field named fieldname and with GType type.
522 * the name of a field
524 * the type of a value
526 * TRUE if the structure contains a field with the given name and type
528 public int hasFieldTyped(char[] fieldname
, GType type
)
530 // gboolean gst_structure_has_field_typed (const GstStructure *structure, const gchar *fieldname, GType type);
531 return gst_structure_has_field_typed(gstStructure
, Str
.toStringz(fieldname
), type
);
535 * Sets the boolean pointed to by value corresponding to the value of the
536 * given field. Caller is responsible for making sure the field exists
537 * and has the correct type.
541 * the name of a field
543 * a pointer to a gboolean to set
545 * TRUE if the value could be set correctly. If there was no field
546 * with fieldname or the existing field did not contain a boolean, this
547 * function returns FALSE.
549 public int getBoolean(char[] fieldname
, int* value
)
551 // gboolean gst_structure_get_boolean (const GstStructure *structure, const gchar *fieldname, gboolean *value);
552 return gst_structure_get_boolean(gstStructure
, Str
.toStringz(fieldname
), value
);
556 * Sets the int pointed to by value corresponding to the value of the
557 * given field. Caller is responsible for making sure the field exists
558 * and has the correct type.
559 * Returns: TRUE if the value could be set correctly. If there was no field
560 * with fieldname or the existing field did not contain an int, this function
564 * the name of a field
566 * a pointer to an int to set
570 public int getInt(char[] fieldname
, int* value
)
572 // gboolean gst_structure_get_int (const GstStructure *structure, const gchar *fieldname, gint *value);
573 return gst_structure_get_int(gstStructure
, Str
.toStringz(fieldname
), value
);
577 * Sets the GstFourcc pointed to by value corresponding to the value of the
578 * given field. Caller is responsible for making sure the field exists
579 * and has the correct type.
580 * Returns: TRUE if the value could be set correctly. If there was no field
581 * with fieldname or the existing field did not contain a fourcc, this function
585 * the name of a field
587 * a pointer to a GstFourcc to set
591 public int getFourcc(char[] fieldname
, uint* value
)
593 // gboolean gst_structure_get_fourcc (const GstStructure *structure, const gchar *fieldname, guint32 *value);
594 return gst_structure_get_fourcc(gstStructure
, Str
.toStringz(fieldname
), value
);
598 * Sets the double pointed to by value corresponding to the value of the
599 * given field. Caller is responsible for making sure the field exists
600 * and has the correct type.
604 * the name of a field
606 * a pointer to a GstFourcc to set
608 * TRUE if the value could be set correctly. If there was no field
609 * with fieldname or the existing field did not contain a double, this
610 * function returns FALSE.
612 public int getDouble(char[] fieldname
, double* value
)
614 // gboolean gst_structure_get_double (const GstStructure *structure, const gchar *fieldname, gdouble *value);
615 return gst_structure_get_double(gstStructure
, Str
.toStringz(fieldname
), value
);
619 * Finds the field corresponding to fieldname, and returns the string
620 * contained in the field's value. Caller is responsible for making
621 * sure the field exists and has the correct type.
622 * The string should not be modified, and remains valid until the next
623 * call to a gst_structure_*() function with the given structure.
627 * the name of a field
629 * a pointer to the string or NULL when the field did not exist
630 * or did not contain a string.
632 public char[] getString(char[] fieldname
)
634 // const gchar* gst_structure_get_string (const GstStructure *structure, const gchar *fieldname);
635 return Str
.toString(gst_structure_get_string(gstStructure
, Str
.toStringz(fieldname
)) );
639 * Sets the date pointed to by value corresponding to the date of the
640 * given field. Caller is responsible for making sure the field exists
641 * and has the correct type.
642 * Returns: TRUE if the value could be set correctly. If there was no field
643 * with fieldname or the existing field did not contain a data, this function
647 * the name of a field
649 * a pointer to a GDate to set
653 public int getDate(char[] fieldname
, GDate
** value
)
655 // gboolean gst_structure_get_date (const GstStructure *structure, const gchar *fieldname, GDate **value);
656 return gst_structure_get_date(gstStructure
, Str
.toStringz(fieldname
), value
);
660 * Sets the clock time pointed to by value corresponding to the clock time
661 * of the given field. Caller is responsible for making sure the field exists
662 * and has the correct type.
666 * the name of a field
668 * a pointer to a GstClockTime to set
670 * TRUE if the value could be set correctly. If there was no field
671 * with fieldname or the existing field did not contain a GstClockTime, this
672 * function returns FALSE.
674 public int getClockTime(char[] fieldname
, GstClockTime
* value
)
676 // gboolean gst_structure_get_clock_time (const GstStructure *structure, const gchar *fieldname, GstClockTime *value);
677 return gst_structure_get_clock_time(gstStructure
, Str
.toStringz(fieldname
), value
);
681 * Sets the int pointed to by value corresponding to the value of the
682 * given field. Caller is responsible for making sure the field exists,
683 * has the correct type and that the enumtype is correct.
687 * the name of a field
689 * the enum type of a field
691 * a pointer to an int to set
693 * TRUE if the value could be set correctly. If there was no field
694 * with fieldname or the existing field did not contain an enum of the given
695 * type, this function returns FALSE.
697 public int getEnum(char[] fieldname
, GType enumtype
, int* value
)
699 // gboolean gst_structure_get_enum (const GstStructure *structure, const gchar *fieldname, GType enumtype, gint *value);
700 return gst_structure_get_enum(gstStructure
, Str
.toStringz(fieldname
), enumtype
, value
);
704 * Sets the integers pointed to by value_numerator and value_denominator
705 * corresponding to the value of the given field. Caller is responsible
706 * for making sure the field exists and has the correct type.
710 * the name of a field
712 * a pointer to an int to set
714 * a pointer to an int to set
716 * TRUE if the values could be set correctly. If there was no field
717 * with fieldname or the existing field did not contain a GstFraction, this
718 * function returns FALSE.
720 public int getFraction(char[] fieldname
, int* valueNumerator
, int* valueDenominator
)
722 // gboolean gst_structure_get_fraction (const GstStructure *structure, const gchar *fieldname, gint *value_numerator, gint *value_denominator);
723 return gst_structure_get_fraction(gstStructure
, Str
.toStringz(fieldname
), valueNumerator
, valueDenominator
);
727 * Calls the provided function once for each field in the GstStructure. In
728 * contrast to gst_structure_foreach(), the function may modify but not delete the
729 * fields. The structure must be mutable.
733 * a function to call for each field
737 * TRUE if the supplied function returns TRUE For each of the fields,
740 public int mapInPlace(GstStructureMapFunc func
, void* userData
)
742 // gboolean gst_structure_map_in_place (GstStructure *structure, GstStructureMapFunc func, gpointer user_data);
743 return gst_structure_map_in_place(gstStructure
, func
, userData
);
747 * Get the name of the given field number, counting from 0 onwards.
751 * the index to get the name of
753 * the name of the given field number
755 public char[] nthFieldName(uint index
)
757 // const gchar* gst_structure_nth_field_name (const GstStructure *structure, guint index);
758 return Str
.toString(gst_structure_nth_field_name(gstStructure
, index
) );
762 * Sets the parent_refcount field of GstStructure. This field is used to
763 * determine whether a structure is mutable or not. This function should only be
764 * called by code implementing parent objects of GstStructure, as described in
765 * the MT Refcounting section of the design documents.
769 * a pointer to the parent's refcount
771 public void setParentRefcount(int* refcount
)
773 // void gst_structure_set_parent_refcount (GstStructure *structure, gint *refcount);
774 gst_structure_set_parent_refcount(gstStructure
, refcount
);
778 * Converts structure to a human-readable string representation.
782 * a pointer to string allocated by g_malloc(). g_free() after
785 public char[] toString()
787 // gchar* gst_structure_to_string (const GstStructure *structure);
788 return Str
.toString(gst_structure_to_string(gstStructure
) );
792 * Creates a GstStructure from a string representation.
793 * If end is not NULL, a pointer to the place inside the given string
794 * where parsing ended will be returned.
796 * a string representation of a GstStructure.
798 * pointer to store the end of the string in.
800 * a new GstStructure or NULL when the string could not
801 * be parsed. Free after usage.
803 public static Structure
fromString(char[] string
, char** end
)
805 // GstStructure* gst_structure_from_string (const gchar *string, gchar **end);
806 return new Structure( gst_structure_from_string(Str
.toStringz(string
), end
) );
810 * Fixates a GstStructure by changing the given field to the nearest
811 * integer to target that is a subset of the existing field.
815 * a field in structure
817 * the target value of the fixation
819 * TRUE if the structure could be fixated
821 public int fixateFieldNearestInt(char[] fieldName
, int target
)
823 // gboolean gst_structure_fixate_field_nearest_int (GstStructure *structure, const char *field_name, int target);
824 return gst_structure_fixate_field_nearest_int(gstStructure
, Str
.toStringz(fieldName
), target
);
828 * Fixates a GstStructure by changing the given field to the nearest
829 * double to target that is a subset of the existing field.
833 * a field in structure
835 * the target value of the fixation
837 * TRUE if the structure could be fixated
839 public int fixateFieldNearestDouble(char[] fieldName
, double target
)
841 // gboolean gst_structure_fixate_field_nearest_double (GstStructure *structure, const char *field_name, double target);
842 return gst_structure_fixate_field_nearest_double(gstStructure
, Str
.toStringz(fieldName
), target
);
846 * Fixates a GstStructure by changing the given field to the nearest
847 * fraction to target_numerator/target_denominator that is a subset
848 * of the existing field.
852 * a field in structure
854 * The numerator of the target value of the fixation
855 * target_denominator:
856 * The denominator of the target value of the fixation
858 * TRUE if the structure could be fixated
860 public int fixateFieldNearestFraction(char[] fieldName
, int targetNumerator
, int targetDenominator
)
862 // gboolean gst_structure_fixate_field_nearest_fraction (GstStructure *structure, const char *field_name, const gint target_numerator, const gint target_denominator);
863 return gst_structure_fixate_field_nearest_fraction(gstStructure
, Str
.toStringz(fieldName
), targetNumerator
, targetDenominator
);
867 * Fixates a GstStructure by changing the given field_name field to the given
868 * target boolean if that field is not fixed yet.
872 * a field in structure
874 * the target value of the fixation
876 * TRUE if the structure could be fixated
878 * GstCaps, GstMessage, GstEvent, GstQuery
880 public int fixateFieldBoolean(char[] fieldName
, int target
)
882 // gboolean gst_structure_fixate_field_boolean (GstStructure *structure, const char *field_name, gboolean target);
883 return gst_structure_fixate_field_boolean(gstStructure
, Str
.toStringz(fieldName
), target
);