1 /* GStreamer Editing Services
2 * Copyright (C) 2012 Paul Lange <palango@gmx.de>
3 * Copyright (C) <2014> Thibault Saunier <thibault.saunier@collabora.com>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
24 #include <glib-object.h>
27 #include "ges-meta-container.h"
28 #include "ges-marker-list.h"
31 * SECTION: gesmetacontainer
32 * @short_description: An interface for storing meta
34 * Interface that allows reading and writing meta
37 static GQuark ges_meta_key;
39 G_DEFINE_INTERFACE_WITH_CODE (GESMetaContainer, ges_meta_container,
40 G_TYPE_OBJECT, ges_meta_key =
41 g_quark_from_static_string ("ges-meta-container-data"););
49 static guint _signals[LAST_SIGNAL] = { 0 };
51 typedef struct RegisteredMeta
57 typedef struct ContainerData
59 GstStructure *structure;
60 GHashTable *static_items;
64 ges_meta_container_default_init (GESMetaContainerInterface * iface)
68 * GESMetaContainer::notify:
69 * @container: a #GESMetaContainer
70 * @prop: the key of the value that changed
71 * @value: the #GValue containing the new value
73 * The notify signal is used to be notify of changes of values
76 _signals[NOTIFY_SIGNAL] =
77 g_signal_new ("notify-meta", G_TYPE_FROM_INTERFACE (iface),
78 G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE | G_SIGNAL_DETAILED |
79 G_SIGNAL_NO_HOOKS, 0, NULL, NULL, g_cclosure_marshal_generic,
80 G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_VALUE);
84 _free_meta_container_data (ContainerData * data)
86 gst_structure_free (data->structure);
87 g_hash_table_unref (data->static_items);
89 g_slice_free (ContainerData, data);
93 _free_static_item (RegisteredMeta * item)
95 g_slice_free (RegisteredMeta, item);
98 static ContainerData *
99 _create_container_data (GESMetaContainer * container)
101 ContainerData *data = g_slice_new (ContainerData);
102 data->structure = gst_structure_new_empty ("metadatas");
103 data->static_items = g_hash_table_new_full (g_str_hash, g_str_equal,
104 g_free, (GDestroyNotify) (GDestroyNotify) _free_static_item);
105 g_object_set_qdata_full (G_OBJECT (container), ges_meta_key, data,
106 (GDestroyNotify) _free_meta_container_data);
111 static GstStructure *
112 _meta_container_get_structure (GESMetaContainer * container)
116 data = g_object_get_qdata (G_OBJECT (container), ges_meta_key);
118 data = _create_container_data (container);
120 return data->structure;
125 GESMetaForeachFunc func;
126 const GESMetaContainer *container;
128 } MetadataForeachData;
131 structure_foreach_wrapper (GQuark field_id, const GValue * value,
134 MetadataForeachData *data = (MetadataForeachData *) user_data;
136 data->func (data->container, g_quark_to_string (field_id), value, data->data);
141 _append_foreach (GQuark field_id, const GValue * value, GESMetaContainer * self)
143 ges_meta_container_set_meta (self, g_quark_to_string (field_id), value);
149 * ges_meta_container_foreach:
150 * @container: container to iterate over
151 * @func: (scope call): function to be called for each metadata
152 * @user_data: (closure): user specified data
154 * Calls the given function for each metadata inside the meta container. Note
155 * that if there is no metadata, the function won't be called at all.
158 ges_meta_container_foreach (GESMetaContainer * container,
159 GESMetaForeachFunc func, gpointer user_data)
161 GstStructure *structure;
162 MetadataForeachData foreach_data;
164 g_return_if_fail (GES_IS_META_CONTAINER (container));
165 g_return_if_fail (func != NULL);
167 structure = _meta_container_get_structure (container);
169 foreach_data.func = func;
170 foreach_data.container = container;
171 foreach_data.data = user_data;
173 gst_structure_foreach (structure,
174 (GstStructureForeachFunc) structure_foreach_wrapper, &foreach_data);
177 /* _can_write_value should have been checked before calling */
179 _register_meta (GESMetaContainer * container, GESMetaFlag flags,
180 const gchar * meta_item, GType type)
183 RegisteredMeta *static_item;
185 data = g_object_get_qdata (G_OBJECT (container), ges_meta_key);
187 data = _create_container_data (container);
188 else if (g_hash_table_lookup (data->static_items, meta_item)) {
189 GST_WARNING_OBJECT (container, "Static meta %s already registered",
195 static_item = g_slice_new0 (RegisteredMeta);
196 static_item->item_type = type;
197 static_item->flags = flags;
198 g_hash_table_insert (data->static_items, g_strdup (meta_item), static_item);
204 _set_value (GESMetaContainer * container, const gchar * meta_item,
205 const GValue * value)
207 GstStructure *structure;
208 gchar *val = gst_value_serialize (value);
211 GST_WARNING_OBJECT (container, "Could not set value on item: %s",
218 structure = _meta_container_get_structure (container);
220 GST_DEBUG_OBJECT (container, "Setting meta_item %s value: %s::%s",
221 meta_item, G_VALUE_TYPE_NAME (value), val);
223 gst_structure_set_value (structure, meta_item, value);
224 g_signal_emit (container, _signals[NOTIFY_SIGNAL], 0, meta_item, value);
231 _can_write_value (GESMetaContainer * container, const gchar * item_name,
235 RegisteredMeta *static_item = NULL;
237 data = g_object_get_qdata (G_OBJECT (container), ges_meta_key);
239 _create_container_data (container);
243 static_item = g_hash_table_lookup (data->static_items, item_name);
245 if (static_item == NULL)
248 if ((static_item->flags & GES_META_WRITABLE) == FALSE) {
249 GST_WARNING_OBJECT (container, "Can not write %s", item_name);
253 if (static_item->item_type != type) {
254 GST_WARNING_OBJECT (container, "Can not set value of type %s on %s "
255 "its type is: %s", g_type_name (static_item->item_type), item_name,
263 #define CREATE_SETTER(name, value_ctype, value_gtype, setter_name) \
265 ges_meta_container_set_ ## name (GESMetaContainer *container, \
266 const gchar *meta_item, value_ctype value) \
268 GValue gval = { 0 }; \
271 g_return_val_if_fail (GES_IS_META_CONTAINER (container), FALSE); \
272 g_return_val_if_fail (meta_item != NULL, FALSE); \
274 if (_can_write_value (container, meta_item, value_gtype) == FALSE) \
277 g_value_init (&gval, value_gtype); \
278 g_value_set_ ##setter_name (&gval, value); \
280 ret = _set_value (container, meta_item, &gval); \
281 g_value_unset (&gval); \
286 * ges_meta_container_set_boolean:
287 * @container: Target container
288 * @meta_item: Name of the meta item to set
289 * @value: Value to set
291 * Sets the value of a given meta item
293 * Return: %TRUE if the meta could be added, %FALSE otherwise
295 CREATE_SETTER (boolean, gboolean, G_TYPE_BOOLEAN, boolean);
298 * ges_meta_container_set_int:
299 * @container: Target container
300 * @meta_item: Name of the meta item to set
301 * @value: Value to set
303 * Sets the value of a given meta item
305 * Return: %TRUE if the meta could be added, %FALSE otherwise
307 CREATE_SETTER (int, gint, G_TYPE_INT, int);
310 * ges_meta_container_set_uint:
311 * @container: Target container
312 * @meta_item: Name of the meta item to set
313 * @value: Value to set
315 * Sets the value of a given meta item
317 * Return: %TRUE if the meta could be added, %FALSE otherwise
319 CREATE_SETTER (uint, guint, G_TYPE_UINT, uint);
322 * ges_meta_container_set_int64:
323 * @container: Target container
324 * @meta_item: Name of the meta item to set
325 * @value: Value to set
327 * Sets the value of a given meta item
329 * Return: %TRUE if the meta could be added, %FALSE otherwise
331 CREATE_SETTER (int64, gint64, G_TYPE_INT64, int64);
334 * ges_meta_container_set_uint64:
335 * @container: Target container
336 * @meta_item: Name of the meta item to set
337 * @value: Value to set
339 * Sets the value of a given meta item
341 * Return: %TRUE if the meta could be added, %FALSE otherwise
343 CREATE_SETTER (uint64, guint64, G_TYPE_UINT64, uint64);
346 * ges_meta_container_set_float:
347 * @container: Target container
348 * @meta_item: Name of the meta item to set
349 * @value: Value to set
351 * Sets the value of a given meta item
353 * Return: %TRUE if the meta could be added, %FALSE otherwise
355 CREATE_SETTER (float, float, G_TYPE_FLOAT, float);
358 * ges_meta_container_set_double:
359 * @container: Target container
360 * @meta_item: Name of the meta item to set
361 * @value: Value to set
363 * Sets the value of a given meta item
365 * Return: %TRUE if the meta could be added, %FALSE otherwise
367 CREATE_SETTER (double, double, G_TYPE_DOUBLE, double);
370 * ges_meta_container_set_date:
371 * @container: Target container
372 * @meta_item: Name of the meta item to set
373 * @value: Value to set
375 * Sets the value of a given meta item
377 * Return: %TRUE if the meta could be added, %FALSE otherwise
379 CREATE_SETTER (date, const GDate *, G_TYPE_DATE, boxed);
382 * ges_meta_container_set_date_time:
383 * @container: Target container
384 * @meta_item: Name of the meta item to set
385 * @value: Value to set
387 * Sets the value of a given meta item
389 * Return: %TRUE if the meta could be added, %FALSE otherwise
391 CREATE_SETTER (date_time, const GstDateTime *, GST_TYPE_DATE_TIME, boxed);
394 * ges_meta_container_set_string:
395 * @container: Target container
396 * @meta_item: Name of the meta item to set
397 * @value: Value to set
399 * Sets the value of a given meta item
401 * Return: %TRUE if the meta could be added, %FALSE otherwise
403 CREATE_SETTER (string, const gchar *, G_TYPE_STRING, string);
406 * ges_meta_container_set_meta:
407 * @container: Target container
408 * @meta_item: Name of the meta item to set
409 * @value: (allow-none): Value to set
411 * Sets the value of a given meta item
413 * Return: %TRUE if the meta could be added, %FALSE otherwise
416 ges_meta_container_set_meta (GESMetaContainer * container,
417 const gchar * meta_item, const GValue * value)
419 g_return_val_if_fail (GES_IS_META_CONTAINER (container), FALSE);
420 g_return_val_if_fail (meta_item != NULL, FALSE);
423 GstStructure *structure = _meta_container_get_structure (container);
424 gst_structure_remove_field (structure, meta_item);
426 g_signal_emit (container, _signals[NOTIFY_SIGNAL], 0, meta_item, value);
431 if (_can_write_value (container, meta_item, G_VALUE_TYPE (value)) == FALSE)
434 return _set_value (container, meta_item, value);
438 * ges_meta_container_set_marker_list:
439 * @container: Target container
440 * @meta_item: Name of the meta item to set
441 * @list: (allow-none) (transfer none): List to set
443 * Associates a marker list with the given meta item
445 * Return: %TRUE if the meta could be added, %FALSE otherwise
449 ges_meta_container_set_marker_list (GESMetaContainer * container,
450 const gchar * meta_item, const GESMarkerList * list)
453 GValue v = G_VALUE_INIT;
454 g_return_val_if_fail (GES_IS_META_CONTAINER (container), FALSE);
455 g_return_val_if_fail (meta_item != NULL, FALSE);
458 GstStructure *structure = _meta_container_get_structure (container);
459 gst_structure_remove_field (structure, meta_item);
461 g_signal_emit (container, _signals[NOTIFY_SIGNAL], 0, meta_item, list);
466 g_return_val_if_fail (GES_IS_MARKER_LIST ((gpointer) list), FALSE);
468 if (_can_write_value (container, meta_item, GES_TYPE_MARKER_LIST) == FALSE)
471 g_value_init_from_instance (&v, (gpointer) list);
473 ret = _set_value (container, meta_item, &v);
481 * ges_meta_container_metas_to_string:
482 * @container: a #GESMetaContainer
484 * Serializes a meta container to a string.
486 * Returns: (nullable): a newly-allocated string, or NULL in case of an error.
487 * The string must be freed with g_free() when no longer needed.
490 ges_meta_container_metas_to_string (GESMetaContainer * container)
492 GstStructure *structure;
494 g_return_val_if_fail (GES_IS_META_CONTAINER (container), NULL);
496 structure = _meta_container_get_structure (container);
498 return gst_structure_to_string (structure);
502 * ges_meta_container_add_metas_from_string:
503 * @container: Target container
504 * @str: a string created with ges_meta_container_metas_to_string()
506 * Deserializes a meta container.
508 * Returns: TRUE on success, FALSE if there was an error.
511 ges_meta_container_add_metas_from_string (GESMetaContainer * container,
514 GstStructure *n_structure;
516 g_return_val_if_fail (GES_IS_META_CONTAINER (container), FALSE);
518 n_structure = gst_structure_from_string (str, NULL);
519 if (n_structure == NULL) {
520 GST_WARNING_OBJECT (container, "Could not add metas: %s", str);
524 gst_structure_foreach (n_structure, (GstStructureForeachFunc) _append_foreach,
527 gst_structure_free (n_structure);
531 #define CREATE_REGISTER_STATIC(name, value_ctype, value_gtype, setter_name) \
533 ges_meta_container_register_meta_ ## name (GESMetaContainer *container,\
534 GESMetaFlag flags, const gchar *meta_item, value_ctype value) \
537 GValue gval = { 0 }; \
539 g_return_val_if_fail (GES_IS_META_CONTAINER (container), FALSE); \
540 g_return_val_if_fail (meta_item != NULL, FALSE); \
542 if (!_register_meta (container, flags, meta_item, value_gtype)) \
545 g_value_init (&gval, value_gtype); \
546 g_value_set_ ##setter_name (&gval, value); \
548 ret = _set_value (container, meta_item, &gval); \
550 g_value_unset (&gval); \
555 * ges_meta_container_register_meta_boolean:
556 * @container: Target container
557 * @flags: The #GESMetaFlag to be used
558 * @meta_item: Name of the meta item to set
559 * @value: Value to set
561 * Sets a static meta on @container. This method lets you define static
562 * metadatas, which means that the type of the registered will be the only
563 * type accepted for this meta on that particular @container.
565 * Return: %TRUE if the meta could be registered, %FALSE otherwise
567 CREATE_REGISTER_STATIC (boolean, gboolean, G_TYPE_BOOLEAN, boolean);
570 * ges_meta_container_register_meta_int:
571 * @container: Target container
572 * @flags: The #GESMetaFlag to be used
573 * @meta_item: Name of the meta item to set
574 * @value: Value to set
576 * Sets a static meta on @container. This method lets you define static
577 * metadatas, which means that the type of the registered will be the only
578 * type accepted for this meta on that particular @container.
580 * Return: %TRUE if the meta could be registered, %FALSE otherwise
582 CREATE_REGISTER_STATIC (int, gint, G_TYPE_INT, int);
585 * ges_meta_container_register_meta_uint:
586 * @container: Target container
587 * @flags: The #GESMetaFlag to be used
588 * @meta_item: Name of the meta item to set
589 * @value: Value to set
591 * Sets a static meta on @container. This method lets you define static
592 * metadatas, which means that the type of the registered will be the only
593 * type accepted for this meta on that particular @container.
595 * Return: %TRUE if the meta could be registered, %FALSE otherwise
597 CREATE_REGISTER_STATIC (uint, guint, G_TYPE_UINT, uint);
600 * ges_meta_container_register_meta_int64:
601 * @container: Target container
602 * @flags: The #GESMetaFlag to be used
603 * @meta_item: Name of the meta item to set
604 * @value: Value to set
606 * Sets a static meta on @container. This method lets you define static
607 * metadatas, which means that the type of the registered will be the only
608 * type accepted for this meta on that particular @container.
610 * Return: %TRUE if the meta could be registered, %FALSE otherwise
612 CREATE_REGISTER_STATIC (int64, gint64, G_TYPE_INT64, int64);
615 * ges_meta_container_register_meta_uint64:
616 * @container: Target container
617 * @flags: The #GESMetaFlag to be used
618 * @meta_item: Name of the meta item to set
619 * @value: Value to set
621 * Sets a static meta on @container. This method lets you define static
622 * metadatas, which means that the type of the registered will be the only
623 * type accepted for this meta on that particular @container.
625 * Return: %TRUE if the meta could be registered, %FALSE otherwise
627 CREATE_REGISTER_STATIC (uint64, guint64, G_TYPE_UINT64, uint64);
630 * ges_meta_container_register_meta_float:
631 * @container: Target container
632 * @flags: The #GESMetaFlag to be used
633 * @meta_item: Name of the meta item to set
634 * @value: Value to set
636 * Sets a static meta on @container. This method lets you define static
637 * metadatas, which means that the type of the registered will be the only
638 * type accepted for this meta on that particular @container.
640 * Return: %TRUE if the meta could be registered, %FALSE otherwise
642 CREATE_REGISTER_STATIC (float, float, G_TYPE_FLOAT, float);
645 * ges_meta_container_register_meta_double:
646 * @container: Target container
647 * @flags: The #GESMetaFlag to be used
648 * @meta_item: Name of the meta item to set
649 * @value: Value to set
651 * Sets a static meta on @container. This method lets you define static
652 * metadatas, which means that the type of the registered will be the only
653 * type accepted for this meta on that particular @container.
655 * Return: %TRUE if the meta could be registered, %FALSE otherwise
657 CREATE_REGISTER_STATIC (double, double, G_TYPE_DOUBLE, double);
660 * ges_meta_container_register_meta_date:
661 * @container: Target container
662 * @flags: The #GESMetaFlag to be used
663 * @meta_item: Name of the meta item to set
664 * @value: (allow-none): Value to set
666 * Sets a static meta on @container. This method lets you define static
667 * metadatas, which means that the type of the registered will be the only
668 * type accepted for this meta on that particular @container.
670 * Return: %TRUE if the meta could be registered, %FALSE otherwise
672 CREATE_REGISTER_STATIC (date, const GDate *, G_TYPE_DATE, boxed);
675 * ges_meta_container_register_meta_date_time:
676 * @container: Target container
677 * @flags: The #GESMetaFlag to be used
678 * @meta_item: Name of the meta item to set
679 * @value: (allow-none): Value to set
681 * Sets a static meta on @container. This method lets you define static
682 * metadatas, which means that the type of the registered will be the only
683 * type accepted for this meta on that particular @container.
685 * Return: %TRUE if the meta could be registered, %FALSE otherwise
687 CREATE_REGISTER_STATIC (date_time, const GstDateTime *, GST_TYPE_DATE_TIME,
691 * ges_meta_container_register_meta_string:
692 * @container: Target container
693 * @flags: The #GESMetaFlag to be used
694 * @meta_item: Name of the meta item to set
695 * @value: (allow-none): Value to set
697 * Sets a static meta on @container. This method lets you define static
698 * metadatas, which means that the type of the registered will be the only
699 * type accepted for this meta on that particular @container.
701 * Return: %TRUE if the meta could be registered, %FALSE otherwise
703 CREATE_REGISTER_STATIC (string, const gchar *, G_TYPE_STRING, string);
706 * ges_meta_container_register_meta:
707 * @container: Target container
708 * @flags: The #GESMetaFlag to be used
709 * @meta_item: Name of the meta item to set
710 * @value: Value to set
712 * Sets a static meta on @container. This method lets you define static
713 * metadatas, which means that the type of the registered will be the only
714 * type accepted for this meta on that particular @container.
716 * Return: %TRUE if the static meta could be added, %FALSE otherwise
719 ges_meta_container_register_meta (GESMetaContainer * container,
720 GESMetaFlag flags, const gchar * meta_item, const GValue * value)
722 g_return_val_if_fail (GES_IS_META_CONTAINER (container), FALSE);
723 g_return_val_if_fail (meta_item != NULL, FALSE);
725 if (!_register_meta (container, flags, meta_item, G_VALUE_TYPE (value)))
728 return _set_value (container, meta_item, value);
732 ges_meta_container_check_meta_registered (GESMetaContainer * container,
733 const gchar * meta_item, GESMetaFlag * flags, GType * type)
736 RegisteredMeta *static_item;
738 data = g_object_get_qdata (G_OBJECT (container), ges_meta_key);
742 static_item = g_hash_table_lookup (data->static_items, meta_item);
743 if (static_item == NULL) {
744 GST_WARNING_OBJECT (container, "Static meta %s has not been registered yet",
751 *type = static_item->item_type;
754 *flags = static_item->flags;
759 /* Copied from gsttaglist.c */
760 /***** evil macros to get all the *_get_* functions right *****/
762 #define CREATE_GETTER(name,type) \
764 ges_meta_container_get_ ## name (GESMetaContainer *container, \
765 const gchar *meta_item, type value) \
767 GstStructure *structure; \
769 g_return_val_if_fail (GES_IS_META_CONTAINER (container), FALSE); \
770 g_return_val_if_fail (meta_item != NULL, FALSE); \
771 g_return_val_if_fail (value != NULL, FALSE); \
773 structure = _meta_container_get_structure (container); \
775 return gst_structure_get_ ## name (structure, meta_item, value); \
779 * ges_meta_container_get_boolean:
780 * @container: Target container
781 * @meta_item: Name of the meta item to get
782 * @dest: (out): Destination to which value of meta item will be copied
784 * Gets the value of a given meta item, returns NULL if @meta_item
787 CREATE_GETTER (boolean, gboolean *);
790 * ges_meta_container_get_int:
791 * @container: Target container
792 * @meta_item: Name of the meta item to get
793 * @dest: (out): Destination to which value of meta item will be copied
795 * Gets the value of a given meta item, returns NULL if @meta_item
798 CREATE_GETTER (int, gint *);
801 * ges_meta_container_get_uint:
802 * @container: Target container
803 * @meta_item: Name of the meta item to get
804 * @dest: (out): Destination to which value of meta item will be copied
806 * Gets the value of a given meta item, returns NULL if @meta_item
809 CREATE_GETTER (uint, guint *);
812 * ges_meta_container_get_double:
813 * @container: Target container
814 * @meta_item: Name of the meta item to get
815 * @dest: (out): Destination to which value of meta item will be copied
817 * Gets the value of a given meta item, returns NULL if @meta_item
820 CREATE_GETTER (double, gdouble *);
823 * ges_meta_container_get_int64:
824 * @container: Target container
825 * @meta_item: Name of the meta item to get
826 * @dest: (out): Destination to which value of meta item will be copied
828 * Gets the value of a given meta item, returns %FALSE if @meta_item
832 ges_meta_container_get_int64 (GESMetaContainer * container,
833 const gchar * meta_item, gint64 * dest)
835 GstStructure *structure;
838 g_return_val_if_fail (GES_IS_META_CONTAINER (container), FALSE);
839 g_return_val_if_fail (meta_item != NULL, FALSE);
840 g_return_val_if_fail (dest != NULL, FALSE);
842 structure = _meta_container_get_structure (container);
844 value = gst_structure_get_value (structure, meta_item);
845 if (!value || G_VALUE_TYPE (value) != G_TYPE_INT64)
848 *dest = g_value_get_int64 (value);
854 * ges_meta_container_get_uint64:
855 * @container: Target container
856 * @meta_item: Name of the meta item to get
857 * @dest: (out): Destination to which value of meta item will be copied
859 * Gets the value of a given meta item, returns %FALSE if @meta_item
863 ges_meta_container_get_uint64 (GESMetaContainer * container,
864 const gchar * meta_item, guint64 * dest)
866 GstStructure *structure;
869 g_return_val_if_fail (GES_IS_META_CONTAINER (container), FALSE);
870 g_return_val_if_fail (meta_item != NULL, FALSE);
871 g_return_val_if_fail (dest != NULL, FALSE);
873 structure = _meta_container_get_structure (container);
875 value = gst_structure_get_value (structure, meta_item);
876 if (!value || G_VALUE_TYPE (value) != G_TYPE_UINT64)
879 *dest = g_value_get_uint64 (value);
885 * ges_meta_container_get_float:
886 * @container: Target container
887 * @meta_item: Name of the meta item to get
888 * @dest: (out): Destination to which value of meta item will be copied
890 * Gets the value of a given meta item, returns %FALSE if @meta_item
894 ges_meta_container_get_float (GESMetaContainer * container,
895 const gchar * meta_item, gfloat * dest)
897 GstStructure *structure;
900 g_return_val_if_fail (GES_IS_META_CONTAINER (container), FALSE);
901 g_return_val_if_fail (meta_item != NULL, FALSE);
902 g_return_val_if_fail (dest != NULL, FALSE);
904 structure = _meta_container_get_structure (container);
906 value = gst_structure_get_value (structure, meta_item);
907 if (!value || G_VALUE_TYPE (value) != G_TYPE_FLOAT)
910 *dest = g_value_get_float (value);
916 * ges_meta_container_get_string:
917 * @container: Target container
918 * @meta_item: Name of the meta item to get
920 * Gets the value of a given meta item, returns NULL if @meta_item
924 ges_meta_container_get_string (GESMetaContainer * container,
925 const gchar * meta_item)
927 GstStructure *structure;
929 g_return_val_if_fail (GES_IS_META_CONTAINER (container), FALSE);
930 g_return_val_if_fail (meta_item != NULL, FALSE);
932 structure = _meta_container_get_structure (container);
934 return gst_structure_get_string (structure, meta_item);
938 * ges_meta_container_get_meta:
939 * @container: Target container
940 * @key: The key name of the meta to retrieve
942 * Gets the value of a given meta item, returns NULL if @key
945 * Returns: the #GValue corresponding to the meta with the given @key.
948 ges_meta_container_get_meta (GESMetaContainer * container, const gchar * key)
950 GstStructure *structure;
952 g_return_val_if_fail (GES_IS_META_CONTAINER (container), FALSE);
953 g_return_val_if_fail (key != NULL, FALSE);
955 structure = _meta_container_get_structure (container);
957 return gst_structure_get_value (structure, key);
961 * ges_meta_container_get_marker_list:
962 * @container: Target container
963 * @key: The key name of the list to retrieve
965 * Gets the value of a given meta item, returns NULL if @key
968 * Returns: (transfer full): the #GESMarkerList corresponding to the meta with the given @key.
972 ges_meta_container_get_marker_list (GESMetaContainer * container,
975 GstStructure *structure;
978 g_return_val_if_fail (GES_IS_META_CONTAINER (container), FALSE);
979 g_return_val_if_fail (key != NULL, FALSE);
981 structure = _meta_container_get_structure (container);
983 v = gst_structure_get_value (structure, key);
989 return GES_MARKER_LIST (g_value_dup_object (v));
993 * ges_meta_container_get_date:
994 * @container: Target container
995 * @meta_item: Name of the meta item to get
996 * @dest: (out): Destination to which value of meta item will be copied
998 * Gets the value of a given meta item, returns NULL if @meta_item
1001 CREATE_GETTER (date, GDate **);
1004 * ges_meta_container_get_date_time:
1005 * @container: Target container
1006 * @meta_item: Name of the meta item to get
1007 * @dest: (out): Destination to which value of meta item will be copied
1009 * Gets the value of a given meta item, returns NULL if @meta_item
1012 CREATE_GETTER (date_time, GstDateTime **);