mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 11:41:09 +00:00
check/Makefile.am: add gsttag
Original commit message from CVS: * check/Makefile.am: add gsttag * check/gst/gsttag.c: (check_tags), (START_TEST), (gst_tag_suite), (main): move over from testsuite dir and clean up * configure.ac: * gst/gsttag.c: * testsuite/Makefile.am: * testsuite/tags/.cvsignore: * testsuite/tags/Makefile.am: * testsuite/tags/merge.c: remove testsuite/tags
This commit is contained in:
parent
0944ac134b
commit
d10d12dbcb
16 changed files with 519 additions and 435 deletions
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
|||
2005-06-19 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* check/Makefile.am:
|
||||
add gsttag
|
||||
* check/gst/gsttag.c: (check_tags), (START_TEST), (gst_tag_suite),
|
||||
(main):
|
||||
move over from testsuite dir and clean up
|
||||
* configure.ac:
|
||||
* gst/gsttag.c:
|
||||
* testsuite/Makefile.am:
|
||||
* testsuite/tags/.cvsignore:
|
||||
* testsuite/tags/Makefile.am:
|
||||
* testsuite/tags/merge.c:
|
||||
remove testsuite/tags
|
||||
|
||||
2005-06-19 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* docs/gst/gstreamer-sections.txt:
|
||||
|
|
|
@ -33,6 +33,7 @@ TESTS = $(top_builddir)/tools/gst-register \
|
|||
gst/gstobject \
|
||||
gst/gstpad \
|
||||
gst/gstsystemclock \
|
||||
gst/gsttag \
|
||||
pipelines/simple_launch_lines \
|
||||
pipelines/cleanup \
|
||||
gst-libs/gdp
|
||||
|
|
202
check/gst/gsttag.c
Normal file
202
check/gst/gsttag.c
Normal file
|
@ -0,0 +1,202 @@
|
|||
/*
|
||||
* Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
|
||||
*
|
||||
* parse1.c: Test various parsing stuff
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "../gstcheck.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/* multiple artists are possible */
|
||||
#define UTAG GST_TAG_ARTIST
|
||||
#define UNFIXED1 "Britney Spears"
|
||||
#define UNFIXED2 "Evanescence"
|
||||
#define UNFIXED3 "AC/DC"
|
||||
#define UNFIXED4 "The Prodigy"
|
||||
|
||||
/* license is fixed */
|
||||
#define FTAG GST_TAG_LICENSE
|
||||
#define FIXED1 "Lesser General Public License"
|
||||
#define FIXED2 "Microsoft End User License Agreement"
|
||||
#define FIXED3 "Mozilla Public License"
|
||||
#define FIXED4 "Public Domain"
|
||||
|
||||
/* checks that a tag contains the given values and not more values */
|
||||
static void
|
||||
check_tags (const GstTagList * list, const gchar * tag, gchar * value, ...)
|
||||
{
|
||||
va_list args;
|
||||
gchar *str;
|
||||
guint i = 0;
|
||||
|
||||
va_start (args, value);
|
||||
while (value != NULL) {
|
||||
fail_unless (gst_tag_list_get_string_index (list, tag, i, &str));
|
||||
fail_unless (strcmp (value, str) == 0);
|
||||
g_free (str);
|
||||
|
||||
value = va_arg (args, gchar *);
|
||||
i++;
|
||||
}
|
||||
fail_unless (i == gst_tag_list_get_tag_size (list, tag));
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
#define NEW_LIST_FIXED(mode) \
|
||||
G_STMT_START { \
|
||||
if (list) gst_tag_list_free (list); \
|
||||
list = gst_tag_list_new (); \
|
||||
gst_tag_list_add (list, mode, FTAG, FIXED1, FTAG, FIXED2, \
|
||||
FTAG, FIXED3, FTAG, FIXED4, NULL); \
|
||||
} G_STMT_END;
|
||||
|
||||
#define NEW_LIST_UNFIXED(mode) \
|
||||
G_STMT_START { \
|
||||
if (list) gst_tag_list_free (list); \
|
||||
list = gst_tag_list_new (); \
|
||||
gst_tag_list_add (list, mode, UTAG, UNFIXED1, UTAG, UNFIXED2, \
|
||||
UTAG, UNFIXED3, UTAG, UNFIXED4, NULL); \
|
||||
} G_STMT_END;
|
||||
|
||||
#define NEW_LISTS_FIXED(mode) \
|
||||
G_STMT_START { \
|
||||
if (list) gst_tag_list_free (list); \
|
||||
list = gst_tag_list_new (); \
|
||||
gst_tag_list_add (list, GST_TAG_MERGE_APPEND, FTAG, FIXED1, \
|
||||
FTAG, FIXED2, NULL); \
|
||||
if (list2) gst_tag_list_free (list2); \
|
||||
list2 = gst_tag_list_new (); \
|
||||
gst_tag_list_add (list2, GST_TAG_MERGE_APPEND, FTAG, FIXED3, \
|
||||
FTAG, FIXED4, NULL); \
|
||||
if (merge) gst_tag_list_free (merge); \
|
||||
merge = gst_tag_list_merge (list, list2, mode); \
|
||||
} G_STMT_END;
|
||||
|
||||
#define NEW_LISTS_UNFIXED(mode) \
|
||||
G_STMT_START { \
|
||||
if (list) gst_tag_list_free (list); \
|
||||
list = gst_tag_list_new (); \
|
||||
gst_tag_list_add (list, GST_TAG_MERGE_APPEND, UTAG, UNFIXED1, \
|
||||
UTAG, UNFIXED2, NULL); \
|
||||
if (list2) gst_tag_list_free (list2); \
|
||||
list2 = gst_tag_list_new (); \
|
||||
gst_tag_list_add (list2, GST_TAG_MERGE_APPEND, UTAG, UNFIXED3,\
|
||||
UTAG, UNFIXED4, NULL); \
|
||||
if (merge) gst_tag_list_free (merge); \
|
||||
merge = gst_tag_list_merge (list, list2, mode); \
|
||||
} G_STMT_END;
|
||||
|
||||
|
||||
START_TEST (test_merge)
|
||||
{
|
||||
GstTagList *list = NULL, *list2 = NULL, *merge = NULL;
|
||||
|
||||
/* make sure the assumptions work */
|
||||
fail_unless (gst_tag_is_fixed (FTAG));
|
||||
fail_unless (!gst_tag_is_fixed (UTAG));
|
||||
/* we check string here only */
|
||||
fail_unless (gst_tag_get_type (FTAG) == G_TYPE_STRING);
|
||||
fail_unless (gst_tag_get_type (UTAG) == G_TYPE_STRING);
|
||||
|
||||
/* check additions */
|
||||
|
||||
/* unfixed */
|
||||
NEW_LIST_UNFIXED (GST_TAG_MERGE_REPLACE_ALL);
|
||||
check_tags (list, UTAG, UNFIXED4, NULL);
|
||||
NEW_LIST_UNFIXED (GST_TAG_MERGE_REPLACE);
|
||||
check_tags (list, UTAG, UNFIXED4, NULL);
|
||||
NEW_LIST_UNFIXED (GST_TAG_MERGE_PREPEND);
|
||||
check_tags (list, UTAG, UNFIXED4, UNFIXED3, UNFIXED2, UNFIXED1, NULL);
|
||||
NEW_LIST_UNFIXED (GST_TAG_MERGE_APPEND);
|
||||
check_tags (list, UTAG, UNFIXED1, UNFIXED2, UNFIXED3, UNFIXED4, NULL);
|
||||
NEW_LIST_UNFIXED (GST_TAG_MERGE_KEEP);
|
||||
check_tags (list, UTAG, UNFIXED1, NULL);
|
||||
NEW_LIST_UNFIXED (GST_TAG_MERGE_KEEP_ALL);
|
||||
check_tags (list, UTAG, NULL);
|
||||
|
||||
/* fixed */
|
||||
NEW_LIST_FIXED (GST_TAG_MERGE_REPLACE_ALL);
|
||||
check_tags (list, FTAG, FIXED4, NULL);
|
||||
NEW_LIST_FIXED (GST_TAG_MERGE_REPLACE);
|
||||
check_tags (list, FTAG, FIXED4, NULL);
|
||||
NEW_LIST_FIXED (GST_TAG_MERGE_PREPEND);
|
||||
check_tags (list, FTAG, FIXED4, NULL);
|
||||
NEW_LIST_FIXED (GST_TAG_MERGE_APPEND);
|
||||
check_tags (list, FTAG, FIXED1, NULL);
|
||||
NEW_LIST_FIXED (GST_TAG_MERGE_KEEP);
|
||||
check_tags (list, FTAG, FIXED1, NULL);
|
||||
NEW_LIST_FIXED (GST_TAG_MERGE_KEEP_ALL);
|
||||
check_tags (list, FTAG, NULL);
|
||||
|
||||
/* check merging */
|
||||
/* unfixed */
|
||||
NEW_LISTS_UNFIXED (GST_TAG_MERGE_REPLACE_ALL);
|
||||
check_tags (merge, UTAG, UNFIXED3, UNFIXED4, NULL);
|
||||
NEW_LISTS_UNFIXED (GST_TAG_MERGE_REPLACE);
|
||||
check_tags (merge, UTAG, UNFIXED3, UNFIXED4, NULL);
|
||||
NEW_LISTS_UNFIXED (GST_TAG_MERGE_PREPEND);
|
||||
check_tags (merge, UTAG, UNFIXED3, UNFIXED4, UNFIXED1, UNFIXED2, NULL);
|
||||
NEW_LISTS_UNFIXED (GST_TAG_MERGE_APPEND);
|
||||
check_tags (merge, UTAG, UNFIXED1, UNFIXED2, UNFIXED3, UNFIXED4, NULL);
|
||||
NEW_LISTS_UNFIXED (GST_TAG_MERGE_KEEP);
|
||||
check_tags (merge, UTAG, UNFIXED1, UNFIXED2, NULL);
|
||||
NEW_LISTS_UNFIXED (GST_TAG_MERGE_KEEP_ALL);
|
||||
check_tags (merge, UTAG, UNFIXED1, UNFIXED2, NULL);
|
||||
|
||||
/* fixed */
|
||||
NEW_LISTS_FIXED (GST_TAG_MERGE_REPLACE_ALL);
|
||||
check_tags (merge, FTAG, FIXED3, NULL);
|
||||
NEW_LISTS_FIXED (GST_TAG_MERGE_REPLACE);
|
||||
check_tags (merge, FTAG, FIXED3, NULL);
|
||||
NEW_LISTS_FIXED (GST_TAG_MERGE_PREPEND);
|
||||
check_tags (merge, FTAG, FIXED3, NULL);
|
||||
NEW_LISTS_FIXED (GST_TAG_MERGE_APPEND);
|
||||
check_tags (merge, FTAG, FIXED1, NULL);
|
||||
NEW_LISTS_FIXED (GST_TAG_MERGE_KEEP);
|
||||
check_tags (merge, FTAG, FIXED1, NULL);
|
||||
NEW_LISTS_FIXED (GST_TAG_MERGE_KEEP_ALL);
|
||||
check_tags (merge, FTAG, FIXED1, NULL);
|
||||
}
|
||||
|
||||
END_TEST Suite *
|
||||
gst_tag_suite (void)
|
||||
{
|
||||
Suite *s = suite_create ("GstTag");
|
||||
TCase *tc_chain = tcase_create ("general");
|
||||
|
||||
suite_add_tcase (s, tc_chain);
|
||||
tcase_add_test (tc_chain, test_merge);
|
||||
return s;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int nf;
|
||||
|
||||
Suite *s = gst_tag_suite ();
|
||||
SRunner *sr = srunner_create (s);
|
||||
|
||||
gst_check_init (&argc, &argv);
|
||||
|
||||
srunner_run_all (sr, CK_NORMAL);
|
||||
nf = srunner_ntests_failed (sr);
|
||||
srunner_free (sr);
|
||||
|
||||
return nf;
|
||||
}
|
|
@ -694,7 +694,6 @@ testsuite/plugin/Makefile
|
|||
testsuite/refcounting/Makefile
|
||||
testsuite/schedulers/Makefile
|
||||
testsuite/states/Makefile
|
||||
testsuite/tags/Makefile
|
||||
testsuite/threads/Makefile
|
||||
testsuite/trigger/Makefile
|
||||
examples/Makefile
|
||||
|
|
92
gst/gsttag.c
92
gst/gsttag.c
|
@ -195,7 +195,7 @@ _gst_tag_initialize (void)
|
|||
* @dest: uninitialized GValue to store result in
|
||||
* @src: GValue to copy from
|
||||
*
|
||||
* This is a convenience function for the func argument of gst_tag_register().
|
||||
* This is a convenience function for the func argument of gst_tag_register().
|
||||
* It creates a copy of the first value from the list.
|
||||
*/
|
||||
void
|
||||
|
@ -211,7 +211,7 @@ gst_tag_merge_use_first (GValue * dest, const GValue * src)
|
|||
* gst_tag_merge_strings_with_comma:
|
||||
* @dest: uninitialized GValue to store result in
|
||||
* @src: GValue to copy from
|
||||
*
|
||||
*
|
||||
* This is a convenience function for the func argument of gst_tag_register().
|
||||
* It concatenates all given strings using a comma. The tag must be registered
|
||||
* as a G_TYPE_STRING or this function will fail.
|
||||
|
@ -331,7 +331,7 @@ gst_tag_get_type (const gchar * tag)
|
|||
* gst_tag_get_nick
|
||||
* @tag: the tag
|
||||
*
|
||||
* Returns the human-readable name of this tag, You must not change or free
|
||||
* Returns the human-readable name of this tag, You must not change or free
|
||||
* this string.
|
||||
*
|
||||
* Returns: the human-readable name of this tag
|
||||
|
@ -352,7 +352,7 @@ gst_tag_get_nick (const gchar * tag)
|
|||
* gst_tag_get_description:
|
||||
* @tag: the tag
|
||||
*
|
||||
* Returns the human-readable description of this tag, You must not change or
|
||||
* Returns the human-readable description of this tag, You must not change or
|
||||
* free this string.
|
||||
*
|
||||
* Returns: the human-readable description of this tag
|
||||
|
@ -514,7 +514,7 @@ gst_tag_list_copy_foreach (GQuark tag, const GValue * value, gpointer user_data)
|
|||
* @into: list to merge into
|
||||
* @from: list to merge from
|
||||
* @mode: the mode to use
|
||||
*
|
||||
*
|
||||
* Inserts the tags of the second list into the first list using the given mode.
|
||||
*/
|
||||
void
|
||||
|
@ -834,7 +834,7 @@ gst_event_new_tag (GstTagList * list)
|
|||
* @tag_event: a tagging #GstEvent
|
||||
*
|
||||
* Gets the taglist from a given tagging event.
|
||||
*
|
||||
*
|
||||
* Returns: The #GstTagList of the event
|
||||
*/
|
||||
GstTagList *
|
||||
|
@ -852,11 +852,11 @@ gst_event_tag_get_list (GstEvent * tag_event)
|
|||
* @tag: tag to read out
|
||||
* @index: number of entry to read out
|
||||
*
|
||||
* Gets the value that is at the given index for the given tag in the given
|
||||
* Gets the value that is at the given index for the given tag in the given
|
||||
* list.
|
||||
*
|
||||
* Returns: The GValue for the specified entry or NULL if the tag wasn't available
|
||||
* or the tag doesn't have as many entries
|
||||
*
|
||||
* Returns: The GValue for the specified entry or NULL if the tag wasn't
|
||||
* available or the tag doesn't have as many entries
|
||||
*/
|
||||
G_CONST_RETURN GValue *
|
||||
gst_tag_list_get_value_index (const GstTagList * list, const gchar * tag,
|
||||
|
@ -888,11 +888,12 @@ gst_tag_list_get_value_index (const GstTagList * list, const gchar * tag,
|
|||
* @list: list to get the tag from
|
||||
* @tag: tag to read out
|
||||
*
|
||||
* Copies the contents for the given tag into the value, merging multiple values
|
||||
* into one if multiple values are associated with the tag.
|
||||
* Copies the contents for the given tag into the value,
|
||||
* merging multiple values into one if multiple values are associated
|
||||
* 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
|
||||
|
@ -925,38 +926,39 @@ gst_tag_list_copy_value (GValue * dest, const GstTagList * list,
|
|||
|
||||
/***** evil macros to get all the gst_tag_list_get_*() functions right *****/
|
||||
|
||||
#define TAG_MERGE_FUNCS(name,type) \
|
||||
gboolean \
|
||||
gst_tag_list_get_ ## name (const GstTagList *list, const gchar *tag, \
|
||||
type *value) \
|
||||
{ \
|
||||
GValue v = { 0, }; \
|
||||
\
|
||||
g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE); \
|
||||
g_return_val_if_fail (tag != NULL, FALSE); \
|
||||
g_return_val_if_fail (value != NULL, FALSE); \
|
||||
\
|
||||
if (!gst_tag_list_copy_value (&v, list, tag)) \
|
||||
return FALSE; \
|
||||
*value = COPY_FUNC (g_value_get_ ## name (&v)); \
|
||||
g_value_unset (&v); \
|
||||
return TRUE; \
|
||||
} \
|
||||
\
|
||||
gboolean \
|
||||
gst_tag_list_get_ ## name ## _index (const GstTagList *list, const gchar *tag, \
|
||||
guint index, type *value) \
|
||||
{ \
|
||||
const GValue *v; \
|
||||
\
|
||||
g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE); \
|
||||
g_return_val_if_fail (tag != NULL, FALSE); \
|
||||
g_return_val_if_fail (value != NULL, FALSE); \
|
||||
\
|
||||
if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL) \
|
||||
return FALSE; \
|
||||
*value = COPY_FUNC (g_value_get_ ## name (v)); \
|
||||
return TRUE; \
|
||||
#define TAG_MERGE_FUNCS(name,type) \
|
||||
gboolean \
|
||||
gst_tag_list_get_ ## name (const GstTagList *list, const gchar *tag, \
|
||||
type *value) \
|
||||
{ \
|
||||
GValue v = { 0, }; \
|
||||
\
|
||||
g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE); \
|
||||
g_return_val_if_fail (tag != NULL, FALSE); \
|
||||
g_return_val_if_fail (value != NULL, FALSE); \
|
||||
\
|
||||
if (!gst_tag_list_copy_value (&v, list, tag)) \
|
||||
return FALSE; \
|
||||
*value = COPY_FUNC (g_value_get_ ## name (&v)); \
|
||||
g_value_unset (&v); \
|
||||
return TRUE; \
|
||||
} \
|
||||
\
|
||||
gboolean \
|
||||
gst_tag_list_get_ ## name ## _index (const GstTagList *list, \
|
||||
const gchar *tag, \
|
||||
guint index, type *value) \
|
||||
{ \
|
||||
const GValue *v; \
|
||||
\
|
||||
g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE); \
|
||||
g_return_val_if_fail (tag != NULL, FALSE); \
|
||||
g_return_val_if_fail (value != NULL, FALSE); \
|
||||
\
|
||||
if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL) \
|
||||
return FALSE; \
|
||||
*value = COPY_FUNC (g_value_get_ ## name (v)); \
|
||||
return TRUE; \
|
||||
}
|
||||
|
||||
#define COPY_FUNC /**/
|
||||
|
|
|
@ -195,7 +195,7 @@ _gst_tag_initialize (void)
|
|||
* @dest: uninitialized GValue to store result in
|
||||
* @src: GValue to copy from
|
||||
*
|
||||
* This is a convenience function for the func argument of gst_tag_register().
|
||||
* This is a convenience function for the func argument of gst_tag_register().
|
||||
* It creates a copy of the first value from the list.
|
||||
*/
|
||||
void
|
||||
|
@ -211,7 +211,7 @@ gst_tag_merge_use_first (GValue * dest, const GValue * src)
|
|||
* gst_tag_merge_strings_with_comma:
|
||||
* @dest: uninitialized GValue to store result in
|
||||
* @src: GValue to copy from
|
||||
*
|
||||
*
|
||||
* This is a convenience function for the func argument of gst_tag_register().
|
||||
* It concatenates all given strings using a comma. The tag must be registered
|
||||
* as a G_TYPE_STRING or this function will fail.
|
||||
|
@ -331,7 +331,7 @@ gst_tag_get_type (const gchar * tag)
|
|||
* gst_tag_get_nick
|
||||
* @tag: the tag
|
||||
*
|
||||
* Returns the human-readable name of this tag, You must not change or free
|
||||
* Returns the human-readable name of this tag, You must not change or free
|
||||
* this string.
|
||||
*
|
||||
* Returns: the human-readable name of this tag
|
||||
|
@ -352,7 +352,7 @@ gst_tag_get_nick (const gchar * tag)
|
|||
* gst_tag_get_description:
|
||||
* @tag: the tag
|
||||
*
|
||||
* Returns the human-readable description of this tag, You must not change or
|
||||
* Returns the human-readable description of this tag, You must not change or
|
||||
* free this string.
|
||||
*
|
||||
* Returns: the human-readable description of this tag
|
||||
|
@ -514,7 +514,7 @@ gst_tag_list_copy_foreach (GQuark tag, const GValue * value, gpointer user_data)
|
|||
* @into: list to merge into
|
||||
* @from: list to merge from
|
||||
* @mode: the mode to use
|
||||
*
|
||||
*
|
||||
* Inserts the tags of the second list into the first list using the given mode.
|
||||
*/
|
||||
void
|
||||
|
@ -834,7 +834,7 @@ gst_event_new_tag (GstTagList * list)
|
|||
* @tag_event: a tagging #GstEvent
|
||||
*
|
||||
* Gets the taglist from a given tagging event.
|
||||
*
|
||||
*
|
||||
* Returns: The #GstTagList of the event
|
||||
*/
|
||||
GstTagList *
|
||||
|
@ -852,11 +852,11 @@ gst_event_tag_get_list (GstEvent * tag_event)
|
|||
* @tag: tag to read out
|
||||
* @index: number of entry to read out
|
||||
*
|
||||
* Gets the value that is at the given index for the given tag in the given
|
||||
* Gets the value that is at the given index for the given tag in the given
|
||||
* list.
|
||||
*
|
||||
* Returns: The GValue for the specified entry or NULL if the tag wasn't available
|
||||
* or the tag doesn't have as many entries
|
||||
*
|
||||
* Returns: The GValue for the specified entry or NULL if the tag wasn't
|
||||
* available or the tag doesn't have as many entries
|
||||
*/
|
||||
G_CONST_RETURN GValue *
|
||||
gst_tag_list_get_value_index (const GstTagList * list, const gchar * tag,
|
||||
|
@ -888,11 +888,12 @@ gst_tag_list_get_value_index (const GstTagList * list, const gchar * tag,
|
|||
* @list: list to get the tag from
|
||||
* @tag: tag to read out
|
||||
*
|
||||
* Copies the contents for the given tag into the value, merging multiple values
|
||||
* into one if multiple values are associated with the tag.
|
||||
* Copies the contents for the given tag into the value,
|
||||
* merging multiple values into one if multiple values are associated
|
||||
* 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
|
||||
|
@ -925,38 +926,39 @@ gst_tag_list_copy_value (GValue * dest, const GstTagList * list,
|
|||
|
||||
/***** evil macros to get all the gst_tag_list_get_*() functions right *****/
|
||||
|
||||
#define TAG_MERGE_FUNCS(name,type) \
|
||||
gboolean \
|
||||
gst_tag_list_get_ ## name (const GstTagList *list, const gchar *tag, \
|
||||
type *value) \
|
||||
{ \
|
||||
GValue v = { 0, }; \
|
||||
\
|
||||
g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE); \
|
||||
g_return_val_if_fail (tag != NULL, FALSE); \
|
||||
g_return_val_if_fail (value != NULL, FALSE); \
|
||||
\
|
||||
if (!gst_tag_list_copy_value (&v, list, tag)) \
|
||||
return FALSE; \
|
||||
*value = COPY_FUNC (g_value_get_ ## name (&v)); \
|
||||
g_value_unset (&v); \
|
||||
return TRUE; \
|
||||
} \
|
||||
\
|
||||
gboolean \
|
||||
gst_tag_list_get_ ## name ## _index (const GstTagList *list, const gchar *tag, \
|
||||
guint index, type *value) \
|
||||
{ \
|
||||
const GValue *v; \
|
||||
\
|
||||
g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE); \
|
||||
g_return_val_if_fail (tag != NULL, FALSE); \
|
||||
g_return_val_if_fail (value != NULL, FALSE); \
|
||||
\
|
||||
if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL) \
|
||||
return FALSE; \
|
||||
*value = COPY_FUNC (g_value_get_ ## name (v)); \
|
||||
return TRUE; \
|
||||
#define TAG_MERGE_FUNCS(name,type) \
|
||||
gboolean \
|
||||
gst_tag_list_get_ ## name (const GstTagList *list, const gchar *tag, \
|
||||
type *value) \
|
||||
{ \
|
||||
GValue v = { 0, }; \
|
||||
\
|
||||
g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE); \
|
||||
g_return_val_if_fail (tag != NULL, FALSE); \
|
||||
g_return_val_if_fail (value != NULL, FALSE); \
|
||||
\
|
||||
if (!gst_tag_list_copy_value (&v, list, tag)) \
|
||||
return FALSE; \
|
||||
*value = COPY_FUNC (g_value_get_ ## name (&v)); \
|
||||
g_value_unset (&v); \
|
||||
return TRUE; \
|
||||
} \
|
||||
\
|
||||
gboolean \
|
||||
gst_tag_list_get_ ## name ## _index (const GstTagList *list, \
|
||||
const gchar *tag, \
|
||||
guint index, type *value) \
|
||||
{ \
|
||||
const GValue *v; \
|
||||
\
|
||||
g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE); \
|
||||
g_return_val_if_fail (tag != NULL, FALSE); \
|
||||
g_return_val_if_fail (value != NULL, FALSE); \
|
||||
\
|
||||
if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL) \
|
||||
return FALSE; \
|
||||
*value = COPY_FUNC (g_value_get_ ## name (v)); \
|
||||
return TRUE; \
|
||||
}
|
||||
|
||||
#define COPY_FUNC /**/
|
||||
|
|
|
@ -33,6 +33,7 @@ TESTS = $(top_builddir)/tools/gst-register \
|
|||
gst/gstobject \
|
||||
gst/gstpad \
|
||||
gst/gstsystemclock \
|
||||
gst/gsttag \
|
||||
pipelines/simple_launch_lines \
|
||||
pipelines/cleanup \
|
||||
gst-libs/gdp
|
||||
|
|
202
tests/check/gst/gsttag.c
Normal file
202
tests/check/gst/gsttag.c
Normal file
|
@ -0,0 +1,202 @@
|
|||
/*
|
||||
* Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
|
||||
*
|
||||
* parse1.c: Test various parsing stuff
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "../gstcheck.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/* multiple artists are possible */
|
||||
#define UTAG GST_TAG_ARTIST
|
||||
#define UNFIXED1 "Britney Spears"
|
||||
#define UNFIXED2 "Evanescence"
|
||||
#define UNFIXED3 "AC/DC"
|
||||
#define UNFIXED4 "The Prodigy"
|
||||
|
||||
/* license is fixed */
|
||||
#define FTAG GST_TAG_LICENSE
|
||||
#define FIXED1 "Lesser General Public License"
|
||||
#define FIXED2 "Microsoft End User License Agreement"
|
||||
#define FIXED3 "Mozilla Public License"
|
||||
#define FIXED4 "Public Domain"
|
||||
|
||||
/* checks that a tag contains the given values and not more values */
|
||||
static void
|
||||
check_tags (const GstTagList * list, const gchar * tag, gchar * value, ...)
|
||||
{
|
||||
va_list args;
|
||||
gchar *str;
|
||||
guint i = 0;
|
||||
|
||||
va_start (args, value);
|
||||
while (value != NULL) {
|
||||
fail_unless (gst_tag_list_get_string_index (list, tag, i, &str));
|
||||
fail_unless (strcmp (value, str) == 0);
|
||||
g_free (str);
|
||||
|
||||
value = va_arg (args, gchar *);
|
||||
i++;
|
||||
}
|
||||
fail_unless (i == gst_tag_list_get_tag_size (list, tag));
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
#define NEW_LIST_FIXED(mode) \
|
||||
G_STMT_START { \
|
||||
if (list) gst_tag_list_free (list); \
|
||||
list = gst_tag_list_new (); \
|
||||
gst_tag_list_add (list, mode, FTAG, FIXED1, FTAG, FIXED2, \
|
||||
FTAG, FIXED3, FTAG, FIXED4, NULL); \
|
||||
} G_STMT_END;
|
||||
|
||||
#define NEW_LIST_UNFIXED(mode) \
|
||||
G_STMT_START { \
|
||||
if (list) gst_tag_list_free (list); \
|
||||
list = gst_tag_list_new (); \
|
||||
gst_tag_list_add (list, mode, UTAG, UNFIXED1, UTAG, UNFIXED2, \
|
||||
UTAG, UNFIXED3, UTAG, UNFIXED4, NULL); \
|
||||
} G_STMT_END;
|
||||
|
||||
#define NEW_LISTS_FIXED(mode) \
|
||||
G_STMT_START { \
|
||||
if (list) gst_tag_list_free (list); \
|
||||
list = gst_tag_list_new (); \
|
||||
gst_tag_list_add (list, GST_TAG_MERGE_APPEND, FTAG, FIXED1, \
|
||||
FTAG, FIXED2, NULL); \
|
||||
if (list2) gst_tag_list_free (list2); \
|
||||
list2 = gst_tag_list_new (); \
|
||||
gst_tag_list_add (list2, GST_TAG_MERGE_APPEND, FTAG, FIXED3, \
|
||||
FTAG, FIXED4, NULL); \
|
||||
if (merge) gst_tag_list_free (merge); \
|
||||
merge = gst_tag_list_merge (list, list2, mode); \
|
||||
} G_STMT_END;
|
||||
|
||||
#define NEW_LISTS_UNFIXED(mode) \
|
||||
G_STMT_START { \
|
||||
if (list) gst_tag_list_free (list); \
|
||||
list = gst_tag_list_new (); \
|
||||
gst_tag_list_add (list, GST_TAG_MERGE_APPEND, UTAG, UNFIXED1, \
|
||||
UTAG, UNFIXED2, NULL); \
|
||||
if (list2) gst_tag_list_free (list2); \
|
||||
list2 = gst_tag_list_new (); \
|
||||
gst_tag_list_add (list2, GST_TAG_MERGE_APPEND, UTAG, UNFIXED3,\
|
||||
UTAG, UNFIXED4, NULL); \
|
||||
if (merge) gst_tag_list_free (merge); \
|
||||
merge = gst_tag_list_merge (list, list2, mode); \
|
||||
} G_STMT_END;
|
||||
|
||||
|
||||
START_TEST (test_merge)
|
||||
{
|
||||
GstTagList *list = NULL, *list2 = NULL, *merge = NULL;
|
||||
|
||||
/* make sure the assumptions work */
|
||||
fail_unless (gst_tag_is_fixed (FTAG));
|
||||
fail_unless (!gst_tag_is_fixed (UTAG));
|
||||
/* we check string here only */
|
||||
fail_unless (gst_tag_get_type (FTAG) == G_TYPE_STRING);
|
||||
fail_unless (gst_tag_get_type (UTAG) == G_TYPE_STRING);
|
||||
|
||||
/* check additions */
|
||||
|
||||
/* unfixed */
|
||||
NEW_LIST_UNFIXED (GST_TAG_MERGE_REPLACE_ALL);
|
||||
check_tags (list, UTAG, UNFIXED4, NULL);
|
||||
NEW_LIST_UNFIXED (GST_TAG_MERGE_REPLACE);
|
||||
check_tags (list, UTAG, UNFIXED4, NULL);
|
||||
NEW_LIST_UNFIXED (GST_TAG_MERGE_PREPEND);
|
||||
check_tags (list, UTAG, UNFIXED4, UNFIXED3, UNFIXED2, UNFIXED1, NULL);
|
||||
NEW_LIST_UNFIXED (GST_TAG_MERGE_APPEND);
|
||||
check_tags (list, UTAG, UNFIXED1, UNFIXED2, UNFIXED3, UNFIXED4, NULL);
|
||||
NEW_LIST_UNFIXED (GST_TAG_MERGE_KEEP);
|
||||
check_tags (list, UTAG, UNFIXED1, NULL);
|
||||
NEW_LIST_UNFIXED (GST_TAG_MERGE_KEEP_ALL);
|
||||
check_tags (list, UTAG, NULL);
|
||||
|
||||
/* fixed */
|
||||
NEW_LIST_FIXED (GST_TAG_MERGE_REPLACE_ALL);
|
||||
check_tags (list, FTAG, FIXED4, NULL);
|
||||
NEW_LIST_FIXED (GST_TAG_MERGE_REPLACE);
|
||||
check_tags (list, FTAG, FIXED4, NULL);
|
||||
NEW_LIST_FIXED (GST_TAG_MERGE_PREPEND);
|
||||
check_tags (list, FTAG, FIXED4, NULL);
|
||||
NEW_LIST_FIXED (GST_TAG_MERGE_APPEND);
|
||||
check_tags (list, FTAG, FIXED1, NULL);
|
||||
NEW_LIST_FIXED (GST_TAG_MERGE_KEEP);
|
||||
check_tags (list, FTAG, FIXED1, NULL);
|
||||
NEW_LIST_FIXED (GST_TAG_MERGE_KEEP_ALL);
|
||||
check_tags (list, FTAG, NULL);
|
||||
|
||||
/* check merging */
|
||||
/* unfixed */
|
||||
NEW_LISTS_UNFIXED (GST_TAG_MERGE_REPLACE_ALL);
|
||||
check_tags (merge, UTAG, UNFIXED3, UNFIXED4, NULL);
|
||||
NEW_LISTS_UNFIXED (GST_TAG_MERGE_REPLACE);
|
||||
check_tags (merge, UTAG, UNFIXED3, UNFIXED4, NULL);
|
||||
NEW_LISTS_UNFIXED (GST_TAG_MERGE_PREPEND);
|
||||
check_tags (merge, UTAG, UNFIXED3, UNFIXED4, UNFIXED1, UNFIXED2, NULL);
|
||||
NEW_LISTS_UNFIXED (GST_TAG_MERGE_APPEND);
|
||||
check_tags (merge, UTAG, UNFIXED1, UNFIXED2, UNFIXED3, UNFIXED4, NULL);
|
||||
NEW_LISTS_UNFIXED (GST_TAG_MERGE_KEEP);
|
||||
check_tags (merge, UTAG, UNFIXED1, UNFIXED2, NULL);
|
||||
NEW_LISTS_UNFIXED (GST_TAG_MERGE_KEEP_ALL);
|
||||
check_tags (merge, UTAG, UNFIXED1, UNFIXED2, NULL);
|
||||
|
||||
/* fixed */
|
||||
NEW_LISTS_FIXED (GST_TAG_MERGE_REPLACE_ALL);
|
||||
check_tags (merge, FTAG, FIXED3, NULL);
|
||||
NEW_LISTS_FIXED (GST_TAG_MERGE_REPLACE);
|
||||
check_tags (merge, FTAG, FIXED3, NULL);
|
||||
NEW_LISTS_FIXED (GST_TAG_MERGE_PREPEND);
|
||||
check_tags (merge, FTAG, FIXED3, NULL);
|
||||
NEW_LISTS_FIXED (GST_TAG_MERGE_APPEND);
|
||||
check_tags (merge, FTAG, FIXED1, NULL);
|
||||
NEW_LISTS_FIXED (GST_TAG_MERGE_KEEP);
|
||||
check_tags (merge, FTAG, FIXED1, NULL);
|
||||
NEW_LISTS_FIXED (GST_TAG_MERGE_KEEP_ALL);
|
||||
check_tags (merge, FTAG, FIXED1, NULL);
|
||||
}
|
||||
|
||||
END_TEST Suite *
|
||||
gst_tag_suite (void)
|
||||
{
|
||||
Suite *s = suite_create ("GstTag");
|
||||
TCase *tc_chain = tcase_create ("general");
|
||||
|
||||
suite_add_tcase (s, tc_chain);
|
||||
tcase_add_test (tc_chain, test_merge);
|
||||
return s;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int nf;
|
||||
|
||||
Suite *s = gst_tag_suite ();
|
||||
SRunner *sr = srunner_create (s);
|
||||
|
||||
gst_check_init (&argc, &argv);
|
||||
|
||||
srunner_run_all (sr, CK_NORMAL);
|
||||
nf = srunner_ntests_failed (sr);
|
||||
srunner_free (sr);
|
||||
|
||||
return nf;
|
||||
}
|
|
@ -19,7 +19,7 @@ SUBDIRS = \
|
|||
dlopen dynparams \
|
||||
elements ghostpads indexers negotiation pad \
|
||||
$(GST_PARSE_DIRS) \
|
||||
plugin refcounting schedulers states tags threads trigger
|
||||
plugin refcounting schedulers states threads trigger
|
||||
|
||||
DIST_SUBDIRS = \
|
||||
bins bytestream caps cleanup clock \
|
||||
|
@ -27,7 +27,7 @@ DIST_SUBDIRS = \
|
|||
dlopen dynparams \
|
||||
elements ghostpads indexers negotiation pad \
|
||||
parse \
|
||||
plugin refcounting schedulers states tags threads trigger
|
||||
plugin refcounting schedulers states threads trigger
|
||||
|
||||
tests_pass = test_gst_init
|
||||
tests_fail =
|
||||
|
|
3
tests/old/testsuite/tags/.gitignore
vendored
3
tests/old/testsuite/tags/.gitignore
vendored
|
@ -1,3 +0,0 @@
|
|||
Makefile
|
||||
Makefile.in
|
||||
merge
|
|
@ -1,5 +0,0 @@
|
|||
include ../Rules
|
||||
|
||||
tests_pass = merge
|
||||
tests_fail =
|
||||
tests_ignore =
|
|
@ -1,162 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
|
||||
*
|
||||
* parse1.c: Test various parsing stuff
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/* multiple artists are possible */
|
||||
#define UTAG GST_TAG_ARTIST
|
||||
#define UNFIXED1 "Britney Spears"
|
||||
#define UNFIXED2 "Evanescene"
|
||||
#define UNFIXED3 "AC/DC"
|
||||
#define UNFIXED4 "The Prodigy"
|
||||
|
||||
/* license is fixed */
|
||||
#define FTAG GST_TAG_LICENSE
|
||||
#define FIXED1 "Lesser General Public License"
|
||||
#define FIXED2 "Microsoft End User License Agreement"
|
||||
#define FIXED3 "Mozilla Public License"
|
||||
#define FIXED4 "Public Domain"
|
||||
|
||||
/* checks that a tag contains the given values and not more values */
|
||||
static void
|
||||
check (const GstTagList * list, const gchar * tag, gchar * value, ...)
|
||||
{
|
||||
va_list args;
|
||||
gchar *str;
|
||||
guint i = 0;
|
||||
|
||||
va_start (args, value);
|
||||
while (value != NULL) {
|
||||
g_assert (gst_tag_list_get_string_index (list, tag, i, &str));
|
||||
g_assert (strcmp (value, str) == 0);
|
||||
g_free (str);
|
||||
|
||||
value = va_arg (args, gchar *);
|
||||
i++;
|
||||
}
|
||||
g_assert (i == gst_tag_list_get_tag_size (list, tag));
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
#define NEW_LIST_FIXED(mode) G_STMT_START{ \
|
||||
if (list) gst_tag_list_free (list);\
|
||||
list = gst_tag_list_new (); \
|
||||
gst_tag_list_add (list, mode, FTAG, FIXED1, FTAG, FIXED2, FTAG, FIXED3, FTAG, FIXED4, NULL); \
|
||||
}G_STMT_END
|
||||
#define NEW_LIST_UNFIXED(mode) G_STMT_START{ \
|
||||
if (list) gst_tag_list_free (list);\
|
||||
list = gst_tag_list_new (); \
|
||||
gst_tag_list_add (list, mode, UTAG, UNFIXED1, UTAG, UNFIXED2, UTAG, UNFIXED3, UTAG, UNFIXED4, NULL);\
|
||||
}G_STMT_END
|
||||
#define NEW_LISTS_FIXED(mode) G_STMT_START{ \
|
||||
if (list) gst_tag_list_free (list);\
|
||||
list = gst_tag_list_new (); \
|
||||
gst_tag_list_add (list, GST_TAG_MERGE_APPEND, FTAG, FIXED1, FTAG, FIXED2, NULL); \
|
||||
if (list2) gst_tag_list_free (list2);\
|
||||
list2 = gst_tag_list_new (); \
|
||||
gst_tag_list_add (list2, GST_TAG_MERGE_APPEND, FTAG, FIXED3, FTAG, FIXED4, NULL); \
|
||||
if (merge) gst_tag_list_free (merge);\
|
||||
merge = gst_tag_list_merge (list, list2, mode); \
|
||||
}G_STMT_END
|
||||
#define NEW_LISTS_UNFIXED(mode) G_STMT_START{ \
|
||||
if (list) gst_tag_list_free (list);\
|
||||
list = gst_tag_list_new (); \
|
||||
gst_tag_list_add (list, GST_TAG_MERGE_APPEND, UTAG, UNFIXED1, UTAG, UNFIXED2, NULL); \
|
||||
if (list2) gst_tag_list_free (list2);\
|
||||
list2 = gst_tag_list_new (); \
|
||||
gst_tag_list_add (list2, GST_TAG_MERGE_APPEND, UTAG, UNFIXED3, UTAG, UNFIXED4, NULL); \
|
||||
if (merge) gst_tag_list_free (merge);\
|
||||
merge = gst_tag_list_merge (list, list2, mode); \
|
||||
}G_STMT_END
|
||||
gint
|
||||
main (gint argc, gchar * argv[])
|
||||
{
|
||||
GstTagList *list = NULL, *list2 = NULL, *merge = NULL;
|
||||
|
||||
gst_init (&argc, &argv);
|
||||
|
||||
/* make sure the assumptions work */
|
||||
g_assert (gst_tag_is_fixed (FTAG));
|
||||
g_assert (!gst_tag_is_fixed (UTAG));
|
||||
/* we check string here only */
|
||||
g_assert (gst_tag_get_type (FTAG) == G_TYPE_STRING);
|
||||
g_assert (gst_tag_get_type (UTAG) == G_TYPE_STRING);
|
||||
|
||||
/* check additions */
|
||||
/* unfixed */
|
||||
NEW_LIST_UNFIXED (GST_TAG_MERGE_REPLACE_ALL);
|
||||
check (list, UTAG, UNFIXED4, NULL);
|
||||
NEW_LIST_UNFIXED (GST_TAG_MERGE_REPLACE);
|
||||
check (list, UTAG, UNFIXED4, NULL);
|
||||
NEW_LIST_UNFIXED (GST_TAG_MERGE_PREPEND);
|
||||
check (list, UTAG, UNFIXED4, UNFIXED3, UNFIXED2, UNFIXED1, NULL);
|
||||
NEW_LIST_UNFIXED (GST_TAG_MERGE_APPEND);
|
||||
check (list, UTAG, UNFIXED1, UNFIXED2, UNFIXED3, UNFIXED4, NULL);
|
||||
NEW_LIST_UNFIXED (GST_TAG_MERGE_KEEP);
|
||||
check (list, UTAG, UNFIXED1, NULL);
|
||||
NEW_LIST_UNFIXED (GST_TAG_MERGE_KEEP_ALL);
|
||||
check (list, UTAG, NULL);
|
||||
/* fixed */
|
||||
NEW_LIST_FIXED (GST_TAG_MERGE_REPLACE_ALL);
|
||||
check (list, FTAG, FIXED4, NULL);
|
||||
NEW_LIST_FIXED (GST_TAG_MERGE_REPLACE);
|
||||
check (list, FTAG, FIXED4, NULL);
|
||||
NEW_LIST_FIXED (GST_TAG_MERGE_PREPEND);
|
||||
check (list, FTAG, FIXED4, NULL);
|
||||
NEW_LIST_FIXED (GST_TAG_MERGE_APPEND);
|
||||
check (list, FTAG, FIXED1, NULL);
|
||||
NEW_LIST_FIXED (GST_TAG_MERGE_KEEP);
|
||||
check (list, FTAG, FIXED1, NULL);
|
||||
NEW_LIST_FIXED (GST_TAG_MERGE_KEEP_ALL);
|
||||
check (list, FTAG, NULL);
|
||||
|
||||
/* check merging */
|
||||
/* unfixed */
|
||||
NEW_LISTS_UNFIXED (GST_TAG_MERGE_REPLACE_ALL);
|
||||
check (merge, UTAG, UNFIXED3, UNFIXED4, NULL);
|
||||
NEW_LISTS_UNFIXED (GST_TAG_MERGE_REPLACE);
|
||||
check (merge, UTAG, UNFIXED3, UNFIXED4, NULL);
|
||||
NEW_LISTS_UNFIXED (GST_TAG_MERGE_PREPEND);
|
||||
check (merge, UTAG, UNFIXED3, UNFIXED4, UNFIXED1, UNFIXED2, NULL);
|
||||
NEW_LISTS_UNFIXED (GST_TAG_MERGE_APPEND);
|
||||
check (merge, UTAG, UNFIXED1, UNFIXED2, UNFIXED3, UNFIXED4, NULL);
|
||||
NEW_LISTS_UNFIXED (GST_TAG_MERGE_KEEP);
|
||||
check (merge, UTAG, UNFIXED1, UNFIXED2, NULL);
|
||||
NEW_LISTS_UNFIXED (GST_TAG_MERGE_KEEP_ALL);
|
||||
check (merge, UTAG, UNFIXED1, UNFIXED2, NULL);
|
||||
/* fixed */
|
||||
NEW_LISTS_FIXED (GST_TAG_MERGE_REPLACE_ALL);
|
||||
check (merge, FTAG, FIXED3, NULL);
|
||||
NEW_LISTS_FIXED (GST_TAG_MERGE_REPLACE);
|
||||
check (merge, FTAG, FIXED3, NULL);
|
||||
NEW_LISTS_FIXED (GST_TAG_MERGE_PREPEND);
|
||||
check (merge, FTAG, FIXED3, NULL);
|
||||
NEW_LISTS_FIXED (GST_TAG_MERGE_APPEND);
|
||||
check (merge, FTAG, FIXED1, NULL);
|
||||
NEW_LISTS_FIXED (GST_TAG_MERGE_KEEP);
|
||||
check (merge, FTAG, FIXED1, NULL);
|
||||
NEW_LISTS_FIXED (GST_TAG_MERGE_KEEP_ALL);
|
||||
check (merge, FTAG, FIXED1, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -19,7 +19,7 @@ SUBDIRS = \
|
|||
dlopen dynparams \
|
||||
elements ghostpads indexers negotiation pad \
|
||||
$(GST_PARSE_DIRS) \
|
||||
plugin refcounting schedulers states tags threads trigger
|
||||
plugin refcounting schedulers states threads trigger
|
||||
|
||||
DIST_SUBDIRS = \
|
||||
bins bytestream caps cleanup clock \
|
||||
|
@ -27,7 +27,7 @@ DIST_SUBDIRS = \
|
|||
dlopen dynparams \
|
||||
elements ghostpads indexers negotiation pad \
|
||||
parse \
|
||||
plugin refcounting schedulers states tags threads trigger
|
||||
plugin refcounting schedulers states threads trigger
|
||||
|
||||
tests_pass = test_gst_init
|
||||
tests_fail =
|
||||
|
|
3
testsuite/tags/.gitignore
vendored
3
testsuite/tags/.gitignore
vendored
|
@ -1,3 +0,0 @@
|
|||
Makefile
|
||||
Makefile.in
|
||||
merge
|
|
@ -1,5 +0,0 @@
|
|||
include ../Rules
|
||||
|
||||
tests_pass = merge
|
||||
tests_fail =
|
||||
tests_ignore =
|
|
@ -1,162 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
|
||||
*
|
||||
* parse1.c: Test various parsing stuff
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/* multiple artists are possible */
|
||||
#define UTAG GST_TAG_ARTIST
|
||||
#define UNFIXED1 "Britney Spears"
|
||||
#define UNFIXED2 "Evanescene"
|
||||
#define UNFIXED3 "AC/DC"
|
||||
#define UNFIXED4 "The Prodigy"
|
||||
|
||||
/* license is fixed */
|
||||
#define FTAG GST_TAG_LICENSE
|
||||
#define FIXED1 "Lesser General Public License"
|
||||
#define FIXED2 "Microsoft End User License Agreement"
|
||||
#define FIXED3 "Mozilla Public License"
|
||||
#define FIXED4 "Public Domain"
|
||||
|
||||
/* checks that a tag contains the given values and not more values */
|
||||
static void
|
||||
check (const GstTagList * list, const gchar * tag, gchar * value, ...)
|
||||
{
|
||||
va_list args;
|
||||
gchar *str;
|
||||
guint i = 0;
|
||||
|
||||
va_start (args, value);
|
||||
while (value != NULL) {
|
||||
g_assert (gst_tag_list_get_string_index (list, tag, i, &str));
|
||||
g_assert (strcmp (value, str) == 0);
|
||||
g_free (str);
|
||||
|
||||
value = va_arg (args, gchar *);
|
||||
i++;
|
||||
}
|
||||
g_assert (i == gst_tag_list_get_tag_size (list, tag));
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
#define NEW_LIST_FIXED(mode) G_STMT_START{ \
|
||||
if (list) gst_tag_list_free (list);\
|
||||
list = gst_tag_list_new (); \
|
||||
gst_tag_list_add (list, mode, FTAG, FIXED1, FTAG, FIXED2, FTAG, FIXED3, FTAG, FIXED4, NULL); \
|
||||
}G_STMT_END
|
||||
#define NEW_LIST_UNFIXED(mode) G_STMT_START{ \
|
||||
if (list) gst_tag_list_free (list);\
|
||||
list = gst_tag_list_new (); \
|
||||
gst_tag_list_add (list, mode, UTAG, UNFIXED1, UTAG, UNFIXED2, UTAG, UNFIXED3, UTAG, UNFIXED4, NULL);\
|
||||
}G_STMT_END
|
||||
#define NEW_LISTS_FIXED(mode) G_STMT_START{ \
|
||||
if (list) gst_tag_list_free (list);\
|
||||
list = gst_tag_list_new (); \
|
||||
gst_tag_list_add (list, GST_TAG_MERGE_APPEND, FTAG, FIXED1, FTAG, FIXED2, NULL); \
|
||||
if (list2) gst_tag_list_free (list2);\
|
||||
list2 = gst_tag_list_new (); \
|
||||
gst_tag_list_add (list2, GST_TAG_MERGE_APPEND, FTAG, FIXED3, FTAG, FIXED4, NULL); \
|
||||
if (merge) gst_tag_list_free (merge);\
|
||||
merge = gst_tag_list_merge (list, list2, mode); \
|
||||
}G_STMT_END
|
||||
#define NEW_LISTS_UNFIXED(mode) G_STMT_START{ \
|
||||
if (list) gst_tag_list_free (list);\
|
||||
list = gst_tag_list_new (); \
|
||||
gst_tag_list_add (list, GST_TAG_MERGE_APPEND, UTAG, UNFIXED1, UTAG, UNFIXED2, NULL); \
|
||||
if (list2) gst_tag_list_free (list2);\
|
||||
list2 = gst_tag_list_new (); \
|
||||
gst_tag_list_add (list2, GST_TAG_MERGE_APPEND, UTAG, UNFIXED3, UTAG, UNFIXED4, NULL); \
|
||||
if (merge) gst_tag_list_free (merge);\
|
||||
merge = gst_tag_list_merge (list, list2, mode); \
|
||||
}G_STMT_END
|
||||
gint
|
||||
main (gint argc, gchar * argv[])
|
||||
{
|
||||
GstTagList *list = NULL, *list2 = NULL, *merge = NULL;
|
||||
|
||||
gst_init (&argc, &argv);
|
||||
|
||||
/* make sure the assumptions work */
|
||||
g_assert (gst_tag_is_fixed (FTAG));
|
||||
g_assert (!gst_tag_is_fixed (UTAG));
|
||||
/* we check string here only */
|
||||
g_assert (gst_tag_get_type (FTAG) == G_TYPE_STRING);
|
||||
g_assert (gst_tag_get_type (UTAG) == G_TYPE_STRING);
|
||||
|
||||
/* check additions */
|
||||
/* unfixed */
|
||||
NEW_LIST_UNFIXED (GST_TAG_MERGE_REPLACE_ALL);
|
||||
check (list, UTAG, UNFIXED4, NULL);
|
||||
NEW_LIST_UNFIXED (GST_TAG_MERGE_REPLACE);
|
||||
check (list, UTAG, UNFIXED4, NULL);
|
||||
NEW_LIST_UNFIXED (GST_TAG_MERGE_PREPEND);
|
||||
check (list, UTAG, UNFIXED4, UNFIXED3, UNFIXED2, UNFIXED1, NULL);
|
||||
NEW_LIST_UNFIXED (GST_TAG_MERGE_APPEND);
|
||||
check (list, UTAG, UNFIXED1, UNFIXED2, UNFIXED3, UNFIXED4, NULL);
|
||||
NEW_LIST_UNFIXED (GST_TAG_MERGE_KEEP);
|
||||
check (list, UTAG, UNFIXED1, NULL);
|
||||
NEW_LIST_UNFIXED (GST_TAG_MERGE_KEEP_ALL);
|
||||
check (list, UTAG, NULL);
|
||||
/* fixed */
|
||||
NEW_LIST_FIXED (GST_TAG_MERGE_REPLACE_ALL);
|
||||
check (list, FTAG, FIXED4, NULL);
|
||||
NEW_LIST_FIXED (GST_TAG_MERGE_REPLACE);
|
||||
check (list, FTAG, FIXED4, NULL);
|
||||
NEW_LIST_FIXED (GST_TAG_MERGE_PREPEND);
|
||||
check (list, FTAG, FIXED4, NULL);
|
||||
NEW_LIST_FIXED (GST_TAG_MERGE_APPEND);
|
||||
check (list, FTAG, FIXED1, NULL);
|
||||
NEW_LIST_FIXED (GST_TAG_MERGE_KEEP);
|
||||
check (list, FTAG, FIXED1, NULL);
|
||||
NEW_LIST_FIXED (GST_TAG_MERGE_KEEP_ALL);
|
||||
check (list, FTAG, NULL);
|
||||
|
||||
/* check merging */
|
||||
/* unfixed */
|
||||
NEW_LISTS_UNFIXED (GST_TAG_MERGE_REPLACE_ALL);
|
||||
check (merge, UTAG, UNFIXED3, UNFIXED4, NULL);
|
||||
NEW_LISTS_UNFIXED (GST_TAG_MERGE_REPLACE);
|
||||
check (merge, UTAG, UNFIXED3, UNFIXED4, NULL);
|
||||
NEW_LISTS_UNFIXED (GST_TAG_MERGE_PREPEND);
|
||||
check (merge, UTAG, UNFIXED3, UNFIXED4, UNFIXED1, UNFIXED2, NULL);
|
||||
NEW_LISTS_UNFIXED (GST_TAG_MERGE_APPEND);
|
||||
check (merge, UTAG, UNFIXED1, UNFIXED2, UNFIXED3, UNFIXED4, NULL);
|
||||
NEW_LISTS_UNFIXED (GST_TAG_MERGE_KEEP);
|
||||
check (merge, UTAG, UNFIXED1, UNFIXED2, NULL);
|
||||
NEW_LISTS_UNFIXED (GST_TAG_MERGE_KEEP_ALL);
|
||||
check (merge, UTAG, UNFIXED1, UNFIXED2, NULL);
|
||||
/* fixed */
|
||||
NEW_LISTS_FIXED (GST_TAG_MERGE_REPLACE_ALL);
|
||||
check (merge, FTAG, FIXED3, NULL);
|
||||
NEW_LISTS_FIXED (GST_TAG_MERGE_REPLACE);
|
||||
check (merge, FTAG, FIXED3, NULL);
|
||||
NEW_LISTS_FIXED (GST_TAG_MERGE_PREPEND);
|
||||
check (merge, FTAG, FIXED3, NULL);
|
||||
NEW_LISTS_FIXED (GST_TAG_MERGE_APPEND);
|
||||
check (merge, FTAG, FIXED1, NULL);
|
||||
NEW_LISTS_FIXED (GST_TAG_MERGE_KEEP);
|
||||
check (merge, FTAG, FIXED1, NULL);
|
||||
NEW_LISTS_FIXED (GST_TAG_MERGE_KEEP_ALL);
|
||||
check (merge, FTAG, FIXED1, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue