From 31808e7afae8aaebb029d89c178e7d6fdf20dd96 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 23 Dec 2003 04:50:01 +0000 Subject: [PATCH] Add interface to setting GValues directly. Original commit message from CVS: Add interface to setting GValues directly. --- gst/gsttag.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ gst/gsttag.h | 8 ++++++++ gst/gsttaginterface.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ gst/gsttaginterface.h | 12 ++++++++++++ gst/gsttaglist.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ gst/gsttaglist.h | 8 ++++++++ gst/gsttagsetter.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ gst/gsttagsetter.h | 12 ++++++++++++ 8 files changed, 230 insertions(+) diff --git a/gst/gsttag.c b/gst/gsttag.c index 4ceb2a6..ae2db0d 100644 --- a/gst/gsttag.c +++ b/gst/gsttag.c @@ -577,6 +577,28 @@ gst_tag_list_add (GstTagList *list, GstTagMergeMode mode, const gchar *tag, ...) va_end (args); } /** + * gst_tag_list_add_values: + * @list: list to set tags in + * @mode: the mode to use + * @tag: tag + * @...: GValues to set + * + * Sets the GValues for the given tags using the specified mode. + */ +void +gst_tag_list_add_values (GstTagList *list, GstTagMergeMode mode, const gchar *tag, ...) +{ + va_list args; + + g_return_if_fail (GST_IS_TAG_LIST (list)); + g_return_if_fail (GST_TAG_MODE_IS_VALID (mode)); + g_return_if_fail (tag != NULL); + + va_start (args, tag); + gst_tag_list_add_valist_values (list, mode, tag, args); + va_end (args); +} +/** * gst_tag_list_add_valist: * @list: list to set tags in * @mode: the mode to use @@ -617,6 +639,33 @@ gst_tag_list_add_valist (GstTagList *list, GstTagMergeMode mode, const gchar *ta } } /** + * gst_tag_list_add_valist_values: + * @list: list to set tags in + * @mode: the mode to use + * @tag: tag + * @var_args: tag / GValue pairs to set + * + * Sets the GValues for the given tags using the specified mode. + */ +void +gst_tag_list_add_valist_values (GstTagList *list, GstTagMergeMode mode, const gchar *tag, va_list var_args) +{ + GstTagInfo *info; + GQuark quark; + + g_return_if_fail (GST_IS_TAG_LIST (list)); + g_return_if_fail (GST_TAG_MODE_IS_VALID (mode)); + g_return_if_fail (tag != NULL); + + while (tag != NULL) { + quark = g_quark_from_string (tag); + info = gst_tag_lookup (quark); + g_return_if_fail (info != NULL); + gst_tag_list_add_value_internal (list, mode, quark, va_arg (var_args, GValue *)); + tag = va_arg (var_args, gchar *); + } +} +/** * gst_tag_list_remove_tag: * @list: list to remove tag from * @tag: tag to remove diff --git a/gst/gsttag.h b/gst/gsttag.h index ddb690d..6593afd 100644 --- a/gst/gsttag.h +++ b/gst/gsttag.h @@ -88,10 +88,18 @@ void gst_tag_list_add (GstTagList * list, GstTagMergeMode mode, const gchar * tag, ...); +void gst_tag_list_add_values (GstTagList * list, + GstTagMergeMode mode, + const gchar * tag, + ...); void gst_tag_list_add_valist (GstTagList * list, GstTagMergeMode mode, const gchar * tag, va_list var_args); +void gst_tag_list_add_valist_values (GstTagList * list, + GstTagMergeMode mode, + const gchar * tag, + va_list var_args); void gst_tag_list_remove_tag (GstTagList * list, const gchar * tag); void gst_tag_list_foreach (GstTagList * list, diff --git a/gst/gsttaginterface.c b/gst/gsttaginterface.c index a7e6d71..582d977 100644 --- a/gst/gsttaginterface.c +++ b/gst/gsttaginterface.c @@ -139,6 +139,28 @@ gst_tag_setter_add (GstTagSetter *setter, GstTagMergeMode mode, const gchar *tag va_end (args); } /** + * gst_tag_setter_add_values: + * @setter: a #GstTagSetter + * @mode: the mode to use + * @tag: tag to set + * @...: more tag / GValue pairs to set + * + * Adds the given tag / GValue pairs on the setter using the given merge mode. + * The list must be terminated with GST_TAG_INVALID. + */ +void +gst_tag_setter_add_values (GstTagSetter *setter, GstTagMergeMode mode, const gchar *tag, ...) +{ + va_list args; + + g_return_if_fail (GST_IS_TAG_SETTER (setter)); + g_return_if_fail (GST_TAG_MODE_IS_VALID (mode)); + + va_start (args, tag); + gst_tag_setter_add_valist_values (setter, mode, tag, args); + va_end (args); +} +/** * gst_tag_setter_add_valist: * @setter: a #GstTagSetter * @mode: the mode to use @@ -163,6 +185,30 @@ gst_tag_setter_add_valist (GstTagSetter *setter, GstTagMergeMode mode, const gch gst_tag_list_add_valist (data->list, mode, tag, var_args); } /** + * gst_tag_setter_add_valist_values: + * @setter: a #GstTagSetter + * @mode: the mode to use + * @tag: tag to set + * @var_args: tag / GValue pairs to set + * + * Adds the given tag / GValue pairs on the setter using the given merge mode. + * The list must be terminated with GST_TAG_INVALID. + */ +void +gst_tag_setter_add_valist_values (GstTagSetter *setter, GstTagMergeMode mode, const gchar *tag, va_list var_args) +{ + GstTagData *data; + + g_return_if_fail (GST_IS_TAG_SETTER (setter)); + g_return_if_fail (GST_TAG_MODE_IS_VALID (mode)); + + data = gst_tag_setter_get_data (setter); + if (!data->list) + data->list = gst_tag_list_new (); + + gst_tag_list_add_valist_values (data->list, mode, tag, var_args); +} +/** * gst_tag_setter_get_list: * @setter: a #GstTagSetter * diff --git a/gst/gsttaginterface.h b/gst/gsttaginterface.h index 642e4e3..f28f431 100644 --- a/gst/gsttaginterface.h +++ b/gst/gsttaginterface.h @@ -55,10 +55,22 @@ void gst_tag_setter_add (GstTagSetter * setter, GstTagMergeMode mode, const gchar * tag, ...); + +void gst_tag_setter_add_values (GstTagSetter * setter, + GstTagMergeMode mode, + const gchar * tag, + ...); + void gst_tag_setter_add_valist (GstTagSetter * setter, GstTagMergeMode mode, const gchar * tag, va_list var_args); + +void gst_tag_setter_add_valist_values(GstTagSetter * setter, + GstTagMergeMode mode, + const gchar * tag, + va_list var_args); + G_CONST_RETURN GstTagList * gst_tag_setter_get_list (GstTagSetter * setter); diff --git a/gst/gsttaglist.c b/gst/gsttaglist.c index 4ceb2a6..ae2db0d 100644 --- a/gst/gsttaglist.c +++ b/gst/gsttaglist.c @@ -577,6 +577,28 @@ gst_tag_list_add (GstTagList *list, GstTagMergeMode mode, const gchar *tag, ...) va_end (args); } /** + * gst_tag_list_add_values: + * @list: list to set tags in + * @mode: the mode to use + * @tag: tag + * @...: GValues to set + * + * Sets the GValues for the given tags using the specified mode. + */ +void +gst_tag_list_add_values (GstTagList *list, GstTagMergeMode mode, const gchar *tag, ...) +{ + va_list args; + + g_return_if_fail (GST_IS_TAG_LIST (list)); + g_return_if_fail (GST_TAG_MODE_IS_VALID (mode)); + g_return_if_fail (tag != NULL); + + va_start (args, tag); + gst_tag_list_add_valist_values (list, mode, tag, args); + va_end (args); +} +/** * gst_tag_list_add_valist: * @list: list to set tags in * @mode: the mode to use @@ -617,6 +639,33 @@ gst_tag_list_add_valist (GstTagList *list, GstTagMergeMode mode, const gchar *ta } } /** + * gst_tag_list_add_valist_values: + * @list: list to set tags in + * @mode: the mode to use + * @tag: tag + * @var_args: tag / GValue pairs to set + * + * Sets the GValues for the given tags using the specified mode. + */ +void +gst_tag_list_add_valist_values (GstTagList *list, GstTagMergeMode mode, const gchar *tag, va_list var_args) +{ + GstTagInfo *info; + GQuark quark; + + g_return_if_fail (GST_IS_TAG_LIST (list)); + g_return_if_fail (GST_TAG_MODE_IS_VALID (mode)); + g_return_if_fail (tag != NULL); + + while (tag != NULL) { + quark = g_quark_from_string (tag); + info = gst_tag_lookup (quark); + g_return_if_fail (info != NULL); + gst_tag_list_add_value_internal (list, mode, quark, va_arg (var_args, GValue *)); + tag = va_arg (var_args, gchar *); + } +} +/** * gst_tag_list_remove_tag: * @list: list to remove tag from * @tag: tag to remove diff --git a/gst/gsttaglist.h b/gst/gsttaglist.h index ddb690d..6593afd 100644 --- a/gst/gsttaglist.h +++ b/gst/gsttaglist.h @@ -88,10 +88,18 @@ void gst_tag_list_add (GstTagList * list, GstTagMergeMode mode, const gchar * tag, ...); +void gst_tag_list_add_values (GstTagList * list, + GstTagMergeMode mode, + const gchar * tag, + ...); void gst_tag_list_add_valist (GstTagList * list, GstTagMergeMode mode, const gchar * tag, va_list var_args); +void gst_tag_list_add_valist_values (GstTagList * list, + GstTagMergeMode mode, + const gchar * tag, + va_list var_args); void gst_tag_list_remove_tag (GstTagList * list, const gchar * tag); void gst_tag_list_foreach (GstTagList * list, diff --git a/gst/gsttagsetter.c b/gst/gsttagsetter.c index a7e6d71..582d977 100644 --- a/gst/gsttagsetter.c +++ b/gst/gsttagsetter.c @@ -139,6 +139,28 @@ gst_tag_setter_add (GstTagSetter *setter, GstTagMergeMode mode, const gchar *tag va_end (args); } /** + * gst_tag_setter_add_values: + * @setter: a #GstTagSetter + * @mode: the mode to use + * @tag: tag to set + * @...: more tag / GValue pairs to set + * + * Adds the given tag / GValue pairs on the setter using the given merge mode. + * The list must be terminated with GST_TAG_INVALID. + */ +void +gst_tag_setter_add_values (GstTagSetter *setter, GstTagMergeMode mode, const gchar *tag, ...) +{ + va_list args; + + g_return_if_fail (GST_IS_TAG_SETTER (setter)); + g_return_if_fail (GST_TAG_MODE_IS_VALID (mode)); + + va_start (args, tag); + gst_tag_setter_add_valist_values (setter, mode, tag, args); + va_end (args); +} +/** * gst_tag_setter_add_valist: * @setter: a #GstTagSetter * @mode: the mode to use @@ -163,6 +185,30 @@ gst_tag_setter_add_valist (GstTagSetter *setter, GstTagMergeMode mode, const gch gst_tag_list_add_valist (data->list, mode, tag, var_args); } /** + * gst_tag_setter_add_valist_values: + * @setter: a #GstTagSetter + * @mode: the mode to use + * @tag: tag to set + * @var_args: tag / GValue pairs to set + * + * Adds the given tag / GValue pairs on the setter using the given merge mode. + * The list must be terminated with GST_TAG_INVALID. + */ +void +gst_tag_setter_add_valist_values (GstTagSetter *setter, GstTagMergeMode mode, const gchar *tag, va_list var_args) +{ + GstTagData *data; + + g_return_if_fail (GST_IS_TAG_SETTER (setter)); + g_return_if_fail (GST_TAG_MODE_IS_VALID (mode)); + + data = gst_tag_setter_get_data (setter); + if (!data->list) + data->list = gst_tag_list_new (); + + gst_tag_list_add_valist_values (data->list, mode, tag, var_args); +} +/** * gst_tag_setter_get_list: * @setter: a #GstTagSetter * diff --git a/gst/gsttagsetter.h b/gst/gsttagsetter.h index 642e4e3..f28f431 100644 --- a/gst/gsttagsetter.h +++ b/gst/gsttagsetter.h @@ -55,10 +55,22 @@ void gst_tag_setter_add (GstTagSetter * setter, GstTagMergeMode mode, const gchar * tag, ...); + +void gst_tag_setter_add_values (GstTagSetter * setter, + GstTagMergeMode mode, + const gchar * tag, + ...); + void gst_tag_setter_add_valist (GstTagSetter * setter, GstTagMergeMode mode, const gchar * tag, va_list var_args); + +void gst_tag_setter_add_valist_values(GstTagSetter * setter, + GstTagMergeMode mode, + const gchar * tag, + va_list var_args); + G_CONST_RETURN GstTagList * gst_tag_setter_get_list (GstTagSetter * setter); -- 2.7.4