gststructure.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. /* GStreamer
  2. * Copyright (C) 2003 David A. Schleef <ds@schleef.org>
  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., 51 Franklin St, Fifth Floor,
  17. * Boston, MA 02110-1301, USA.
  18. */
  19. #ifndef __GST_STRUCTURE_H__
  20. #define __GST_STRUCTURE_H__
  21. #include <gst/gstconfig.h>
  22. #include <glib-object.h>
  23. #include <gst/gstclock.h>
  24. #include <gst/gstdatetime.h>
  25. #include <gst/glib-compat.h>
  26. G_BEGIN_DECLS
  27. GST_EXPORT GType _gst_structure_type;
  28. typedef struct _GstStructure GstStructure;
  29. #define GST_TYPE_STRUCTURE (_gst_structure_type)
  30. #define GST_IS_STRUCTURE(object) ((object) && (GST_STRUCTURE(object)->type == GST_TYPE_STRUCTURE))
  31. #define GST_STRUCTURE_CAST(object) ((GstStructure *)(object))
  32. #define GST_STRUCTURE(object) (GST_STRUCTURE_CAST(object))
  33. /**
  34. * GstStructureForeachFunc:
  35. * @field_id: the #GQuark of the field name
  36. * @value: the #GValue of the field
  37. * @user_data: user data
  38. *
  39. * A function that will be called in gst_structure_foreach(). The function may
  40. * not modify @value.
  41. *
  42. * Returns: %TRUE if the foreach operation should continue, %FALSE if
  43. * the foreach operation should stop with %FALSE.
  44. */
  45. typedef gboolean (*GstStructureForeachFunc) (GQuark field_id,
  46. const GValue * value,
  47. gpointer user_data);
  48. /**
  49. * GstStructureMapFunc:
  50. * @field_id: the #GQuark of the field name
  51. * @value: the #GValue of the field
  52. * @user_data: user data
  53. *
  54. * A function that will be called in gst_structure_map_in_place(). The function
  55. * may modify @value.
  56. *
  57. * Returns: %TRUE if the map operation should continue, %FALSE if
  58. * the map operation should stop with %FALSE.
  59. */
  60. typedef gboolean (*GstStructureMapFunc) (GQuark field_id,
  61. GValue * value,
  62. gpointer user_data);
  63. /**
  64. * GstStructureFilterMapFunc:
  65. * @field_id: the #GQuark of the field name
  66. * @value: the #GValue of the field
  67. * @user_data: user data
  68. *
  69. * A function that will be called in gst_structure_filter_and_map_in_place().
  70. * The function may modify @value, and the value will be removed from
  71. * the structure if %FALSE is returned.
  72. *
  73. * Returns: %TRUE if the field should be preserved, %FALSE if it
  74. * should be removed.
  75. */
  76. typedef gboolean (*GstStructureFilterMapFunc) (GQuark field_id,
  77. GValue * value,
  78. gpointer user_data);
  79. /**
  80. * GstStructure:
  81. * @type: the GType of a structure
  82. *
  83. * The GstStructure object. Most fields are private.
  84. */
  85. struct _GstStructure {
  86. GType type;
  87. /*< private >*/
  88. GQuark name;
  89. };
  90. GType gst_structure_get_type (void);
  91. GstStructure * gst_structure_new_empty (const gchar * name) G_GNUC_MALLOC;
  92. GstStructure * gst_structure_new_id_empty (GQuark quark) G_GNUC_MALLOC;
  93. GstStructure * gst_structure_new (const gchar * name,
  94. const gchar * firstfield,
  95. ...) G_GNUC_NULL_TERMINATED G_GNUC_MALLOC;
  96. GstStructure * gst_structure_new_valist (const gchar * name,
  97. const gchar * firstfield,
  98. va_list varargs) G_GNUC_MALLOC;
  99. GstStructure * gst_structure_new_id (GQuark name_quark,
  100. GQuark field_quark,
  101. ...) G_GNUC_MALLOC;
  102. GstStructure * gst_structure_new_from_string (const gchar * string);
  103. GstStructure * gst_structure_copy (const GstStructure * structure) G_GNUC_MALLOC;
  104. gboolean gst_structure_set_parent_refcount (GstStructure * structure,
  105. gint * refcount);
  106. void gst_structure_free (GstStructure * structure);
  107. const gchar * gst_structure_get_name (const GstStructure * structure);
  108. GQuark gst_structure_get_name_id (const GstStructure * structure);
  109. gboolean gst_structure_has_name (const GstStructure * structure,
  110. const gchar * name);
  111. void gst_structure_set_name (GstStructure * structure,
  112. const gchar * name);
  113. void gst_structure_id_set_value (GstStructure * structure,
  114. GQuark field,
  115. const GValue * value);
  116. void gst_structure_set_value (GstStructure * structure,
  117. const gchar * fieldname,
  118. const GValue * value);
  119. void gst_structure_id_take_value (GstStructure * structure,
  120. GQuark field,
  121. GValue * value);
  122. void gst_structure_take_value (GstStructure * structure,
  123. const gchar * fieldname,
  124. GValue * value);
  125. void gst_structure_set (GstStructure * structure,
  126. const gchar * fieldname,
  127. ...) G_GNUC_NULL_TERMINATED;
  128. void gst_structure_set_valist (GstStructure * structure,
  129. const gchar * fieldname,
  130. va_list varargs);
  131. void gst_structure_id_set (GstStructure * structure,
  132. GQuark fieldname,
  133. ...) G_GNUC_NULL_TERMINATED;
  134. void gst_structure_id_set_valist (GstStructure * structure,
  135. GQuark fieldname,
  136. va_list varargs);
  137. gboolean gst_structure_get_valist (const GstStructure * structure,
  138. const char * first_fieldname,
  139. va_list args);
  140. gboolean gst_structure_get (const GstStructure * structure,
  141. const char * first_fieldname,
  142. ...) G_GNUC_NULL_TERMINATED;
  143. gboolean gst_structure_id_get_valist (const GstStructure * structure,
  144. GQuark first_field_id,
  145. va_list args);
  146. gboolean gst_structure_id_get (const GstStructure * structure,
  147. GQuark first_field_id,
  148. ...) G_GNUC_NULL_TERMINATED;
  149. const GValue * gst_structure_id_get_value (const GstStructure * structure,
  150. GQuark field);
  151. const GValue * gst_structure_get_value (const GstStructure * structure,
  152. const gchar * fieldname);
  153. void gst_structure_remove_field (GstStructure * structure,
  154. const gchar * fieldname);
  155. void gst_structure_remove_fields (GstStructure * structure,
  156. const gchar * fieldname,
  157. ...) G_GNUC_NULL_TERMINATED;
  158. void gst_structure_remove_fields_valist (GstStructure * structure,
  159. const gchar * fieldname,
  160. va_list varargs);
  161. void gst_structure_remove_all_fields (GstStructure * structure);
  162. GType gst_structure_get_field_type (const GstStructure * structure,
  163. const gchar * fieldname);
  164. gboolean gst_structure_foreach (const GstStructure * structure,
  165. GstStructureForeachFunc func,
  166. gpointer user_data);
  167. gboolean gst_structure_map_in_place (GstStructure * structure,
  168. GstStructureMapFunc func,
  169. gpointer user_data);
  170. void gst_structure_filter_and_map_in_place (GstStructure * structure,
  171. GstStructureFilterMapFunc func,
  172. gpointer user_data);
  173. gint gst_structure_n_fields (const GstStructure * structure);
  174. const gchar * gst_structure_nth_field_name (const GstStructure * structure,
  175. guint index);
  176. gboolean gst_structure_id_has_field (const GstStructure * structure,
  177. GQuark field);
  178. gboolean gst_structure_id_has_field_typed (const GstStructure * structure,
  179. GQuark field,
  180. GType type);
  181. gboolean gst_structure_has_field (const GstStructure * structure,
  182. const gchar * fieldname);
  183. gboolean gst_structure_has_field_typed (const GstStructure * structure,
  184. const gchar * fieldname,
  185. GType type);
  186. /* utility functions */
  187. gboolean gst_structure_get_boolean (const GstStructure * structure,
  188. const gchar * fieldname,
  189. gboolean * value);
  190. gboolean gst_structure_get_int (const GstStructure * structure,
  191. const gchar * fieldname,
  192. gint * value);
  193. gboolean gst_structure_get_uint (const GstStructure * structure,
  194. const gchar * fieldname,
  195. guint * value);
  196. gboolean gst_structure_get_int64 (const GstStructure * structure,
  197. const gchar * fieldname,
  198. gint64 * value);
  199. gboolean gst_structure_get_uint64 (const GstStructure * structure,
  200. const gchar * fieldname,
  201. guint64 * value);
  202. gboolean gst_structure_get_double (const GstStructure * structure,
  203. const gchar * fieldname,
  204. gdouble * value);
  205. gboolean gst_structure_get_date (const GstStructure * structure,
  206. const gchar * fieldname,
  207. GDate ** value);
  208. gboolean gst_structure_get_date_time (const GstStructure * structure,
  209. const gchar * fieldname,
  210. GstDateTime ** value);
  211. gboolean gst_structure_get_clock_time (const GstStructure * structure,
  212. const gchar * fieldname,
  213. GstClockTime * value);
  214. const gchar * gst_structure_get_string (const GstStructure * structure,
  215. const gchar * fieldname);
  216. gboolean gst_structure_get_enum (const GstStructure * structure,
  217. const gchar * fieldname,
  218. GType enumtype,
  219. gint * value);
  220. gboolean gst_structure_get_fraction (const GstStructure * structure,
  221. const gchar * fieldname,
  222. gint * value_numerator,
  223. gint * value_denominator);
  224. gboolean gst_structure_get_flagset (const GstStructure * structure,
  225. const gchar * fieldname,
  226. guint * value_flags,
  227. guint * value_mask);
  228. gchar * gst_structure_to_string (const GstStructure * structure) G_GNUC_MALLOC;
  229. GstStructure * gst_structure_from_string (const gchar * string,
  230. gchar ** end) G_GNUC_MALLOC;
  231. gboolean gst_structure_fixate_field_nearest_int (GstStructure * structure,
  232. const char * field_name,
  233. int target);
  234. gboolean gst_structure_fixate_field_nearest_double (GstStructure * structure,
  235. const char * field_name,
  236. double target);
  237. gboolean gst_structure_fixate_field_boolean (GstStructure * structure,
  238. const char * field_name,
  239. gboolean target);
  240. gboolean gst_structure_fixate_field_string (GstStructure * structure,
  241. const char * field_name,
  242. const gchar * target);
  243. gboolean gst_structure_fixate_field_nearest_fraction (GstStructure * structure,
  244. const char * field_name,
  245. const gint target_numerator,
  246. const gint target_denominator);
  247. gboolean gst_structure_fixate_field (GstStructure * structure,
  248. const char * field_name);
  249. void gst_structure_fixate (GstStructure * structure);
  250. gboolean gst_structure_is_equal (const GstStructure * structure1,
  251. const GstStructure * structure2);
  252. gboolean gst_structure_is_subset (const GstStructure * subset,
  253. const GstStructure * superset);
  254. gboolean gst_structure_can_intersect (const GstStructure * struct1,
  255. const GstStructure * struct2);
  256. GstStructure * gst_structure_intersect (const GstStructure * struct1,
  257. const GstStructure * struct2) G_GNUC_MALLOC;
  258. #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
  259. G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstStructure, gst_structure_free)
  260. #endif
  261. G_END_DECLS
  262. #endif