*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
/**
* SECTION:gsttaglist
+ * @title: GstTagList
* @short_description: List of tags and values used to describe media metadata
*
* List of tags and values used to describe media metadata.
*
- * Strings must be in ASCII or UTF-8 encoding. No other encodings are allowed.
- *
- * Last reviewed on 2009-06-09 (0.10.23)
+ * Strings in structures must be ASCII or UTF-8 encoded. Other encodings are
+ * not allowed. Strings must not be empty or %NULL.
*/
#ifdef HAVE_CONFIG_H
/* tags hash table: maps tag name string => GstTagInfo */
static GHashTable *__tags;
+GType _gst_tag_list_type = 0;
GST_DEFINE_MINI_OBJECT_TYPE (GstTagList, gst_tag_list);
static void __gst_tag_list_free (GstTagList * list);
{
g_mutex_init (&__tag_mutex);
+ _gst_tag_list_type = gst_tag_list_get_type ();
+
__tags = g_hash_table_new (g_str_hash, g_str_equal);
gst_tag_register_static (GST_TAG_TITLE, GST_TAG_FLAG_META,
G_TYPE_STRING,
_("composer"),
_("person(s) who composed the recording"),
gst_tag_merge_strings_with_comma);
+ gst_tag_register_static (GST_TAG_CONDUCTOR, GST_TAG_FLAG_META,
+ G_TYPE_STRING,
+ _("conductor"),
+ _("conductor/performer refinement"), gst_tag_merge_strings_with_comma);
gst_tag_register_static (GST_TAG_DURATION, GST_TAG_FLAG_DECODED,
G_TYPE_UINT64,
_("duration"), _("length in GStreamer time units (nanoseconds)"), NULL);
"or produced"), NULL);
gst_tag_register_static (GST_TAG_GEO_LOCATION_SUBLOCATION, GST_TAG_FLAG_META,
G_TYPE_STRING, _("geo location sublocation"),
- _("a location whithin a city where the media has been produced "
+ _("a location within a city where the media has been produced "
"or created (e.g. the neighborhood)"), NULL);
gst_tag_register_static (GST_TAG_GEO_LOCATION_HORIZONTAL_ERROR,
GST_TAG_FLAG_META, G_TYPE_DOUBLE, _("geo location horizontal error"),
gst_tag_register_static (GST_TAG_IMAGE_ORIENTATION, GST_TAG_FLAG_META,
G_TYPE_STRING, _("image orientation"),
_("How the image should be rotated or flipped before display"), NULL);
+ gst_tag_register_static (GST_TAG_PUBLISHER, GST_TAG_FLAG_META,
+ G_TYPE_STRING,
+ _("publisher"),
+ _("Name of the label or publisher"), gst_tag_merge_strings_with_comma);
+ gst_tag_register_static (GST_TAG_INTERPRETED_BY, GST_TAG_FLAG_META,
+ G_TYPE_STRING,
+ _("interpreted-by"),
+ _("Information about the people behind a remix and similar "
+ "interpretations"), gst_tag_merge_strings_with_comma);
+ gst_tag_register_static (GST_TAG_MIDI_BASE_NOTE, GST_TAG_FLAG_META,
+ G_TYPE_UINT,
+ _("midi-base-note"), _("Midi note number of the audio track."), NULL);
+ gst_tag_register_static (GST_TAG_PRIVATE_DATA, GST_TAG_FLAG_META,
+ GST_TYPE_SAMPLE,
+ _("private-data"), _("Private data"), gst_tag_merge_use_first);
+
}
/**
}
/**
- * gst_tag_register:
+ * gst_tag_register: (skip)
* @name: the name or identifier string
* @flag: a flag describing the type of tag info
* @type: the type this data is in
* @nick: human-readable name
* @blurb: a human-readable description about this tag
- * @func: function for merging multiple values of this tag, or NULL
+ * @func: (allow-none): function for merging multiple values of this tag, or %NULL
*
* Registers a new tag type for the use with GStreamer's type system. If a type
* with that name is already registered, that one is used.
*
* Important: if you do not supply a merge function the implication will be
* that there can only be one single value for this tag in a tag list and
- * any additional values will silenty be discarded when being added (unless
+ * any additional values will silently be discarded when being added (unless
* #GST_TAG_MERGE_REPLACE, #GST_TAG_MERGE_REPLACE_ALL, or
* #GST_TAG_MERGE_PREPEND is used as merge mode, in which case the new
* value will replace the old one in the list).
g_return_if_fail (blurb != NULL);
g_return_if_fail (type != 0 && type != GST_TYPE_LIST);
- return gst_tag_register_static (g_intern_string (name), flag, type,
+ gst_tag_register_static (g_intern_string (name), flag, type,
g_intern_string (nick), g_intern_string (blurb), func);
}
/**
- * gst_tag_register_static:
+ * gst_tag_register_static: (skip)
* @name: the name or identifier string (string constant)
* @flag: a flag describing the type of tag info
* @type: the type this data is in
* @nick: human-readable name or short description (string constant)
* @blurb: a human-readable description for this tag (string constant)
- * @func: function for merging multiple values of this tag, or NULL
+ * @func: (allow-none): function for merging multiple values of this tag, or %NULL
*
* Registers a new tag type for the use with GStreamer's type system.
*
*
* Checks if the given type is already registered.
*
- * Returns: TRUE if the type is already registered
+ * Returns: %TRUE if the type is already registered
*/
gboolean
gst_tag_exists (const gchar * tag)
* Returns the human-readable name of this tag, You must not change or free
* this string.
*
- * Returns: the human-readable name of this tag
+ * Returns: (nullable): the human-readable name of this tag
*/
const gchar *
gst_tag_get_nick (const gchar * tag)
g_return_val_if_fail (tag != NULL, NULL);
info = gst_tag_lookup (tag);
- g_return_val_if_fail (info != NULL, NULL);
+ if (!info) {
+ GST_WARNING ("Unknown tag: %s", tag);
+
+ return tag;
+ }
return info->nick;
}
* Returns the human-readable description of this tag, You must not change or
* free this string.
*
- * Returns: the human-readable description of this tag
+ * Returns: (nullable): the human-readable description of this tag
*/
const gchar *
gst_tag_get_description (const gchar * tag)
* Checks if the given tag is fixed. A fixed tag can only contain one value.
* Unfixed tags can contain lists of values.
*
- * Returns: TRUE, if the given tag is fixed.
+ * Returns: %TRUE, if the given tag is fixed.
*/
gboolean
gst_tag_is_fixed (const gchar * tag)
/* takes ownership of the structure */
static GstTagList *
-gst_tag_list_new_internal (GstStructure * s)
+gst_tag_list_new_internal (GstStructure * s, GstTagScope scope)
{
GstTagList *tag_list;
(GstMiniObjectFreeFunction) __gst_tag_list_free);
GST_TAG_LIST_STRUCTURE (tag_list) = s;
- GST_TAG_LIST_SCOPE (tag_list) = GST_TAG_SCOPE_STREAM;
+ GST_TAG_LIST_SCOPE (tag_list) = scope;
#ifdef DEBUG_REFCOUNT
GST_CAT_TRACE (GST_CAT_TAGS, "created taglist %p", tag_list);
gst_structure_free (GST_TAG_LIST_STRUCTURE (list));
+#ifdef USE_POISONING
+ memset (list, 0xff, sizeof (GstTagListImpl));
+#endif
+
g_slice_free1 (sizeof (GstTagListImpl), list);
}
g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL);
s = GST_TAG_LIST_STRUCTURE (list);
- return gst_tag_list_new_internal (gst_structure_copy (s));
+ return gst_tag_list_new_internal (gst_structure_copy (s),
+ GST_TAG_LIST_SCOPE (list));
}
/**
GstTagList *tag_list;
s = gst_structure_new_id_empty (GST_QUARK (TAGLIST));
- tag_list = gst_tag_list_new_internal (s);
+ tag_list = gst_tag_list_new_internal (s, GST_TAG_SCOPE_STREAM);
return tag_list;
}
/**
* gst_tag_list_new:
* @tag: tag
- * @...: NULL-terminated list of values to set
+ * @...: %NULL-terminated list of values to set
*
* Creates a new taglist and appends the values for the given tags. It expects
- * tag-value pairs like gst_tag_list_add(), and a NULL terminator after the
+ * tag-value pairs like gst_tag_list_add(), and a %NULL terminator after the
* last pair. The type of the values is implicit and is documented in the API
* reference, but can also be queried at runtime with gst_tag_get_type(). It
* is an error to pass a value of a type not matching the tag type into this
*
* Serializes a tag list to a string.
*
- * Returns: a newly-allocated string, or NULL in case of an error. The
- * string must be freed with g_free() when no longer needed.
+ * Returns: (nullable): a newly-allocated string, or %NULL in case of
+ * an error. The string must be freed with g_free() when no longer
+ * needed.
*/
gchar *
gst_tag_list_to_string (const GstTagList * list)
*
* Deserializes a tag list.
*
- * Returns: a new #GstTagList, or NULL in case of an error.
+ * Returns: (nullable): a new #GstTagList, or %NULL in case of an
+ * error.
*/
GstTagList *
gst_tag_list_new_from_string (const gchar * str)
{
GstTagList *tag_list;
+ GstStructure *s;
g_return_val_if_fail (str != NULL, NULL);
g_return_val_if_fail (g_str_has_prefix (str, "taglist"), NULL);
- tag_list = gst_tag_list_new_internal (gst_structure_from_string (str, NULL));
+ s = gst_structure_from_string (str, NULL);
+ if (s == NULL)
+ return NULL;
+
+ tag_list = gst_tag_list_new_internal (s, GST_TAG_SCOPE_STREAM);
+
return tag_list;
}
*
* Checks if the given taglist is empty.
*
- * Returns: TRUE if the taglist is empty, otherwise FALSE.
+ * Returns: %TRUE if the taglist is empty, otherwise %FALSE.
*/
gboolean
gst_tag_list_is_empty (const GstTagList * list)
*
* Checks if the two given taglists are equal.
*
- * Returns: TRUE if the taglists are equal, otherwise FALSE
+ * Returns: %TRUE if the taglists are equal, otherwise %FALSE
*/
gboolean
gst_tag_list_is_equal (const GstTagList * list1, const GstTagList * list2)
gst_structure_id_set_value (list, tag_quark, value);
break;
case GST_TAG_MERGE_PREPEND:
- gst_value_list_merge (&dest, value, value2);
- gst_structure_id_set_value (list, tag_quark, &dest);
- g_value_unset (&dest);
+ if (GST_VALUE_HOLDS_LIST (value2) && !GST_VALUE_HOLDS_LIST (value))
+ gst_value_list_prepend_value ((GValue *) value2, value);
+ else {
+ gst_value_list_merge (&dest, value, value2);
+ gst_structure_id_take_value (list, tag_quark, &dest);
+ }
break;
case GST_TAG_MERGE_APPEND:
- gst_value_list_merge (&dest, value2, value);
- gst_structure_id_set_value (list, tag_quark, &dest);
- g_value_unset (&dest);
+ if (GST_VALUE_HOLDS_LIST (value2) && !GST_VALUE_HOLDS_LIST (value))
+ gst_value_list_append_value ((GValue *) value2, value);
+ else {
+ gst_value_list_merge (&dest, value2, value);
+ gst_structure_id_take_value (list, tag_quark, &dest);
+ }
break;
case GST_TAG_MERGE_KEEP:
case GST_TAG_MERGE_KEEP_ALL:
/**
* gst_tag_list_merge:
- * @list1: first list to merge
- * @list2: second list to merge
+ * @list1: (allow-none): first list to merge
+ * @list2: (allow-none): second list to merge
* @mode: the mode to use
*
- * Merges the two given lists into a new list. If one of the lists is NULL, a
- * copy of the other is returned. If both lists are NULL, NULL is returned.
+ * Merges the two given lists into a new list. If one of the lists is %NULL, a
+ * copy of the other is returned. If both lists are %NULL, %NULL is returned.
*
* Free-function: gst_tag_list_unref
*
- * Returns: (transfer full): the new list
+ * Returns: (transfer full) (nullable): the new list
*/
GstTagList *
gst_tag_list_merge (const GstTagList * list1, const GstTagList * list2,
* @list: list to set tags in
* @mode: the mode to use
* @tag: tag
- * @...: NULL-terminated list of values to set
+ * @...: %NULL-terminated list of values to set
*
* Sets the values for the given tags using the specified mode.
*/
g_warning ("%s: %s", G_STRLOC, error);
g_free (error);
/* we purposely leak the value here, it might not be
- * in a sane state if an error condition occoured
+ * in a sane state if an error condition occurred
*/
return;
}
- gst_tag_list_add_value_internal (list, mode, tag, &value, info);
+ /* Facilitate GstBuffer -> GstSample transition */
+ if (G_UNLIKELY (info->type == GST_TYPE_SAMPLE &&
+ !GST_IS_SAMPLE (value.data[0].v_pointer))) {
+ g_warning ("Expected GstSample argument for tag '%s'", tag);
+ } else {
+ gst_tag_list_add_value_internal (list, mode, tag, &value, info);
+ }
g_value_unset (&value);
tag = va_arg (var_args, gchar *);
}
gst_tag_list_remove_tag (GstTagList * list, const gchar * tag)
{
g_return_if_fail (GST_IS_TAG_LIST (list));
+ g_return_if_fail (gst_tag_list_is_writable (list));
g_return_if_fail (tag != NULL);
gst_structure_remove_field (GST_TAG_LIST_STRUCTURE (list), tag);
* Gets the value that is at the given index for the given tag in the given
* list.
*
- * Returns: (transfer none): The GValue for the specified entry or NULL if the
- * tag wasn't available or the tag doesn't have as many entries
+ * Returns: (transfer none) (nullable): The GValue for the specified
+ * entry or %NULL if the tag wasn't available or the tag
+ * doesn't have as many entries
*/
const GValue *
gst_tag_list_get_value_index (const GstTagList * list, const gchar * tag,
* with the tag.
* You must g_value_unset() the value after use.
*
- * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
+ * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the
* given list.
*/
gboolean
return TRUE;
}
-/* FIXME 0.11: this whole merge function business is overdesigned, and the
+/* FIXME 2.0: this whole merge function business is overdesigned, and the
* _get_foo() API is misleading as well - how many application developers will
* expect gst_tag_list_get_string (list, GST_TAG_ARTIST, &val) might return a
* string with multiple comma-separated artists? _get_foo() should just be
* Copies the contents for the given tag into the value, merging multiple values
* into one if multiple values are associated with the tag.
*
- * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
+ * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the
* given list.
*/
/**
* Gets the value that is at the given index for the given tag in the given
* list.
*
- * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
+ * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the
* given list.
*/
TAG_MERGE_FUNCS (boolean, gboolean, TRUE);
* Copies the contents for the given tag into the value, merging multiple values
* into one if multiple values are associated with the tag.
*
- * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
+ * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the
* given list.
*/
/**
* Gets the value that is at the given index for the given tag in the given
* list.
*
- * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
+ * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the
* given list.
*/
TAG_MERGE_FUNCS (int, gint, TRUE);
* Copies the contents for the given tag into the value, merging multiple values
* into one if multiple values are associated with the tag.
*
- * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
+ * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the
* given list.
*/
/**
* Gets the value that is at the given index for the given tag in the given
* list.
*
- * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
+ * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the
* given list.
*/
TAG_MERGE_FUNCS (uint, guint, TRUE);
/**
+ * gst_tag_list_get_int64:
+ * @list: a #GstTagList to get the tag from
+ * @tag: tag to read out
+ * @value: (out): location for the result
+ *
+ * Copies the contents for the given tag into the value, merging multiple values
+ * into one if multiple values are associated with the tag.
+ *
+ * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the
+ * given list.
+ */
+/**
* gst_tag_list_get_int64_index:
* @list: a #GstTagList to get the tag from
* @tag: tag to read out
* Gets the value that is at the given index for the given tag in the given
* list.
*
- * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
+ * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the
* given list.
*/
TAG_MERGE_FUNCS (int64, gint64, TRUE);
* Copies the contents for the given tag into the value, merging multiple values
* into one if multiple values are associated with the tag.
*
- * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
+ * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the
* given list.
*/
/**
* Gets the value that is at the given index for the given tag in the given
* list.
*
- * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
+ * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the
* given list.
*/
TAG_MERGE_FUNCS (uint64, guint64, TRUE);
* Copies the contents for the given tag into the value, merging multiple values
* into one if multiple values are associated with the tag.
*
- * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
+ * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the
* given list.
*/
/**
* Gets the value that is at the given index for the given tag in the given
* list.
*
- * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
+ * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the
* given list.
*/
TAG_MERGE_FUNCS (float, gfloat, TRUE);
* Copies the contents for the given tag into the value, merging multiple values
* into one if multiple values are associated with the tag.
*
- * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
+ * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the
* given list.
*/
/**
* Gets the value that is at the given index for the given tag in the given
* list.
*
- * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
+ * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the
* given list.
*/
TAG_MERGE_FUNCS (double, gdouble, TRUE);
* Copies the contents for the given tag into the value, merging multiple values
* into one if multiple values are associated with the tag.
*
- * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
+ * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the
* given list.
*/
/**
* Gets the value that is at the given index for the given tag in the given
* list.
*
- * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
+ * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the
* given list.
*/
TAG_MERGE_FUNCS (pointer, gpointer, (*value != NULL));
*
* The resulting string in @value will be in UTF-8 encoding and should be
* freed by the caller using g_free when no longer needed. The
- * returned string is also guaranteed to be non-NULL and non-empty.
+ * returned string is also guaranteed to be non-%NULL and non-empty.
*
* Free-function: g_free
*
- * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
+ * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the
* given list.
*/
/**
*
* The resulting string in @value will be in UTF-8 encoding and should be
* freed by the caller using g_free when no longer needed. The
- * returned string is also guaranteed to be non-NULL and non-empty.
+ * returned string is also guaranteed to be non-%NULL and non-empty.
*
* Free-function: g_free
*
- * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
+ * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the
* given list.
*/
TAG_MERGE_FUNCS (string, gchar *, (*value != NULL));
/*
- *FIXME 0.11: Instead of _peek (non-copy) and _get (copy), we could have
+ *FIXME 2.0: Instead of _peek (non-copy) and _get (copy), we could have
* _get (non-copy) and _dup (copy) for strings, seems more
* widely used
*/
*
* The resulting string in @value will be in UTF-8 encoding and doesn't need
* to be freed by the caller. The returned string is also guaranteed to
- * be non-NULL and non-empty.
+ * be non-%NULL and non-empty.
*
- * Returns: TRUE, if a value was set, FALSE if the tag didn't exist in the
+ * Returns: %TRUE, if a value was set, %FALSE if the tag didn't exist in the
* given list.
*/
gboolean
*
* Free-function: g_date_free
*
- * Returns: TRUE, if a date was copied, FALSE if the tag didn't exist in the
- * given list or if it was #NULL.
+ * Returns: %TRUE, if a date was copied, %FALSE if the tag didn't exist in the
+ * given list or if it was %NULL.
*/
gboolean
gst_tag_list_get_date (const GstTagList * list, const gchar * tag,
*
* Free-function: g_date_free
*
- * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
- * given list or if it was #NULL.
+ * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the
+ * given list or if it was %NULL.
*/
gboolean
gst_tag_list_get_date_index (const GstTagList * list,
*
* Free-function: gst_date_time_unref
*
- * Returns: TRUE, if a datetime was copied, FALSE if the tag didn't exist in
- * thegiven list or if it was #NULL.
+ * Returns: %TRUE, if a datetime was copied, %FALSE if the tag didn't exist in
+ * the given list or if it was %NULL.
*/
gboolean
gst_tag_list_get_date_time (const GstTagList * list, const gchar * tag,
if (!gst_tag_list_copy_value (&v, list, tag))
return FALSE;
- g_return_val_if_fail (GST_VALUE_HOLDS_DATE_TIME (&v), FALSE);
-
*value = (GstDateTime *) g_value_dup_boxed (&v);
g_value_unset (&v);
return (*value != NULL);
*
* Free-function: gst_date_time_unref
*
- * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
- * given list or if it was #NULL.
+ * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the
+ * given list or if it was %NULL.
*/
gboolean
gst_tag_list_get_date_time_index (const GstTagList * list,
*
* Free-function: gst_sample_unref
*
- * Returns: TRUE, if a sample was returned, FALSE if the tag didn't exist in
- * the given list or if it was #NULL.
+ * Returns: %TRUE, if a sample was returned, %FALSE if the tag didn't exist in
+ * the given list or if it was %NULL.
*/
gboolean
gst_tag_list_get_sample (const GstTagList * list, const gchar * tag,
* pointer variable to store the result into
*
* Gets the sample that is at the given index for the given tag in the given
- * list and copies it into the variable pointed to by @smple. Free the sample
+ * list and copies it into the variable pointed to by @sample. Free the sample
* with gst_sample_unref() when it is no longer needed. You can retrieve the
* buffer from the sample using gst_sample_get_buffer() and the associated
* caps (if any) with gst_sample_get_caps().
*
* Free-function: gst_sample_unref
*
- * Returns: TRUE, if a sample was copied, FALSE if the tag didn't exist in the
- * given list or if it was #NULL.
+ * Returns: %TRUE, if a sample was copied, %FALSE if the tag didn't exist in the
+ * given list or if it was %NULL.
*/
gboolean
gst_tag_list_get_sample_index (const GstTagList * list,