2005-06-19 11:32:42 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2006-11-06 15:22:40 +00:00
|
|
|
* modify it under the terms of the GNU Library General Public
|
2005-06-19 11:32:42 +00:00
|
|
|
* 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
|
2006-11-06 15:22:40 +00:00
|
|
|
* Library General Public License for more details.
|
2005-06-19 11:32:42 +00:00
|
|
|
*
|
2006-11-06 15:22:40 +00:00
|
|
|
* 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.
|
2005-06-19 11:32:42 +00:00
|
|
|
*/
|
|
|
|
|
2005-08-20 12:14:28 +00:00
|
|
|
#include <gst/check/gstcheck.h>
|
2005-06-19 11:32:42 +00:00
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
2008-12-16 09:23:21 +00:00
|
|
|
/* multiple artists are possible (unfixed) */
|
2005-06-19 11:32:42 +00:00
|
|
|
#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
|
2010-03-03 10:45:38 +00:00
|
|
|
check_tags (const GstTagList * list, const gchar * tag, const gchar * value,
|
|
|
|
...)
|
2005-06-19 11:32:42 +00:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2008-12-16 09:23:21 +00:00
|
|
|
static void
|
|
|
|
check_tags_empty (const GstTagList * list)
|
|
|
|
{
|
|
|
|
GST_DEBUG ("taglist: %" GST_PTR_FORMAT, list);
|
|
|
|
fail_unless ((list == NULL) || (gst_tag_list_is_empty (list)));
|
|
|
|
}
|
|
|
|
|
2005-12-06 19:29:15 +00:00
|
|
|
#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); \
|
2008-12-16 09:23:21 +00:00
|
|
|
mark_point(); \
|
2005-06-19 11:32:42 +00:00
|
|
|
} G_STMT_END;
|
|
|
|
|
2005-12-06 19:29:15 +00:00
|
|
|
#define NEW_LIST_UNFIXED(mode) \
|
|
|
|
G_STMT_START { \
|
|
|
|
if (list) gst_tag_list_free (list); \
|
|
|
|
list = gst_tag_list_new (); \
|
2005-06-19 11:32:42 +00:00
|
|
|
gst_tag_list_add (list, mode, UTAG, UNFIXED1, UTAG, UNFIXED2, \
|
2005-12-06 19:29:15 +00:00
|
|
|
UTAG, UNFIXED3, UTAG, UNFIXED4, NULL); \
|
2008-12-16 09:23:21 +00:00
|
|
|
mark_point(); \
|
2005-06-19 11:32:42 +00:00
|
|
|
} G_STMT_END;
|
|
|
|
|
2005-12-06 19:29:15 +00:00
|
|
|
#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 (); \
|
2005-06-19 11:32:42 +00:00
|
|
|
gst_tag_list_add (list2, GST_TAG_MERGE_APPEND, FTAG, FIXED3, \
|
2005-12-06 19:29:15 +00:00
|
|
|
FTAG, FIXED4, NULL); \
|
|
|
|
if (merge) gst_tag_list_free (merge); \
|
|
|
|
merge = gst_tag_list_merge (list, list2, mode); \
|
2008-12-16 09:23:21 +00:00
|
|
|
mark_point(); \
|
2005-06-19 11:32:42 +00:00
|
|
|
} G_STMT_END;
|
|
|
|
|
2005-12-06 19:29:15 +00:00
|
|
|
#define NEW_LISTS_UNFIXED(mode) \
|
|
|
|
G_STMT_START { \
|
|
|
|
if (list) gst_tag_list_free (list); \
|
|
|
|
list = gst_tag_list_new (); \
|
2005-06-19 11:32:42 +00:00
|
|
|
gst_tag_list_add (list, GST_TAG_MERGE_APPEND, UTAG, UNFIXED1, \
|
2005-12-06 19:29:15 +00:00
|
|
|
UTAG, UNFIXED2, NULL); \
|
|
|
|
if (list2) gst_tag_list_free (list2); \
|
|
|
|
list2 = gst_tag_list_new (); \
|
2005-06-19 11:32:42 +00:00
|
|
|
gst_tag_list_add (list2, GST_TAG_MERGE_APPEND, UTAG, UNFIXED3,\
|
2005-12-06 19:29:15 +00:00
|
|
|
UTAG, UNFIXED4, NULL); \
|
|
|
|
if (merge) gst_tag_list_free (merge); \
|
|
|
|
merge = gst_tag_list_merge (list, list2, mode); \
|
2008-12-16 09:23:21 +00:00
|
|
|
mark_point(); \
|
2005-06-19 11:32:42 +00:00
|
|
|
} G_STMT_END;
|
|
|
|
|
2008-12-16 09:23:21 +00:00
|
|
|
#define NEW_LISTS_EMPTY1(mode) \
|
|
|
|
G_STMT_START { \
|
|
|
|
if (list) gst_tag_list_free (list); \
|
|
|
|
list = 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); \
|
|
|
|
mark_point(); \
|
|
|
|
} G_STMT_END;
|
|
|
|
|
|
|
|
#define NEW_LISTS_EMPTY2(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 = NULL; \
|
|
|
|
if (merge) gst_tag_list_free (merge); \
|
|
|
|
merge = gst_tag_list_merge (list, list2, mode); \
|
|
|
|
mark_point(); \
|
|
|
|
} G_STMT_END;
|
2005-06-19 11:32:42 +00:00
|
|
|
|
|
|
|
|
2008-12-16 09:23:21 +00:00
|
|
|
GST_START_TEST (test_basics)
|
|
|
|
{
|
2005-06-19 11:32:42 +00:00
|
|
|
/* 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);
|
2008-12-16 09:23:21 +00:00
|
|
|
}
|
2005-06-19 11:32:42 +00:00
|
|
|
|
2008-12-16 09:23:21 +00:00
|
|
|
GST_END_TEST
|
|
|
|
GST_START_TEST (test_add)
|
|
|
|
{
|
|
|
|
GstTagList *list = NULL;
|
2005-06-19 11:32:42 +00:00
|
|
|
|
2008-12-16 09:23:21 +00:00
|
|
|
/* check additions */
|
2005-06-19 11:32:42 +00:00
|
|
|
/* 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);
|
|
|
|
|
2008-12-16 09:23:21 +00:00
|
|
|
/* clean up */
|
|
|
|
if (list)
|
|
|
|
gst_tag_list_free (list);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST
|
|
|
|
GST_START_TEST (test_merge)
|
|
|
|
{
|
|
|
|
GstTagList *list = NULL, *list2 = NULL, *merge = NULL;
|
|
|
|
|
2005-06-19 11:32:42 +00:00
|
|
|
/* check merging */
|
|
|
|
/* unfixed */
|
2008-12-16 09:23:21 +00:00
|
|
|
GST_DEBUG ("unfixed");
|
2005-06-19 11:32:42 +00:00
|
|
|
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 */
|
2008-12-16 09:23:21 +00:00
|
|
|
GST_DEBUG ("fixed");
|
2005-06-19 11:32:42 +00:00
|
|
|
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);
|
2005-08-20 12:39:05 +00:00
|
|
|
|
2008-12-16 09:23:21 +00:00
|
|
|
/* first list empty */
|
|
|
|
GST_DEBUG ("first empty");
|
|
|
|
NEW_LISTS_EMPTY1 (GST_TAG_MERGE_REPLACE_ALL);
|
|
|
|
check_tags (merge, FTAG, FIXED3, NULL);
|
|
|
|
NEW_LISTS_EMPTY1 (GST_TAG_MERGE_REPLACE);
|
|
|
|
check_tags (merge, FTAG, FIXED3, NULL);
|
|
|
|
NEW_LISTS_EMPTY1 (GST_TAG_MERGE_PREPEND);
|
|
|
|
check_tags (merge, FTAG, FIXED3, NULL);
|
|
|
|
NEW_LISTS_EMPTY1 (GST_TAG_MERGE_APPEND);
|
|
|
|
check_tags (merge, FTAG, FIXED3, NULL);
|
|
|
|
NEW_LISTS_EMPTY1 (GST_TAG_MERGE_KEEP);
|
|
|
|
check_tags (merge, FTAG, FIXED3, NULL);
|
|
|
|
NEW_LISTS_EMPTY1 (GST_TAG_MERGE_KEEP_ALL);
|
|
|
|
check_tags_empty (merge);
|
|
|
|
|
|
|
|
/* second list empty */
|
|
|
|
GST_DEBUG ("second empty");
|
|
|
|
NEW_LISTS_EMPTY2 (GST_TAG_MERGE_REPLACE_ALL);
|
|
|
|
check_tags_empty (merge);
|
|
|
|
NEW_LISTS_EMPTY2 (GST_TAG_MERGE_REPLACE);
|
|
|
|
check_tags (merge, FTAG, FIXED1, NULL);
|
|
|
|
NEW_LISTS_EMPTY2 (GST_TAG_MERGE_PREPEND);
|
|
|
|
check_tags (merge, FTAG, FIXED1, NULL);
|
|
|
|
NEW_LISTS_EMPTY2 (GST_TAG_MERGE_APPEND);
|
|
|
|
check_tags (merge, FTAG, FIXED1, NULL);
|
|
|
|
NEW_LISTS_EMPTY2 (GST_TAG_MERGE_KEEP);
|
|
|
|
check_tags (merge, FTAG, FIXED1, NULL);
|
|
|
|
NEW_LISTS_EMPTY2 (GST_TAG_MERGE_KEEP_ALL);
|
|
|
|
check_tags (merge, FTAG, FIXED1, NULL);
|
|
|
|
|
2005-08-20 12:39:05 +00:00
|
|
|
/* clean up */
|
|
|
|
if (list)
|
|
|
|
gst_tag_list_free (list);
|
|
|
|
if (list2)
|
|
|
|
gst_tag_list_free (list2);
|
|
|
|
if (merge)
|
|
|
|
gst_tag_list_free (merge);
|
2005-06-19 11:32:42 +00:00
|
|
|
}
|
|
|
|
|
2005-10-14 17:01:56 +00:00
|
|
|
GST_END_TEST
|
|
|
|
GST_START_TEST (test_date_tags)
|
|
|
|
{
|
|
|
|
GstTagList *tag_list, *tag_list2;
|
|
|
|
GDate *date, *date2;
|
|
|
|
gchar *str;
|
|
|
|
|
|
|
|
date = g_date_new_dmy (14, 10, 2005);
|
|
|
|
tag_list = gst_tag_list_new ();
|
|
|
|
gst_tag_list_add (tag_list, GST_TAG_MERGE_APPEND, GST_TAG_DATE, date, NULL);
|
|
|
|
|
|
|
|
str = gst_structure_to_string (tag_list);
|
|
|
|
fail_if (str == NULL);
|
|
|
|
fail_if (strstr (str, "2005-10-14") == NULL);
|
|
|
|
|
|
|
|
tag_list2 = gst_structure_from_string (str, NULL);
|
|
|
|
fail_if (tag_list2 == NULL);
|
|
|
|
fail_if (!gst_tag_list_get_date (tag_list2, GST_TAG_DATE, &date2));
|
|
|
|
gst_tag_list_free (tag_list2);
|
|
|
|
g_free (str);
|
|
|
|
|
|
|
|
fail_if (g_date_compare (date, date2) != 0);
|
|
|
|
fail_if (g_date_get_day (date) != 14);
|
|
|
|
fail_if (g_date_get_month (date) != 10);
|
|
|
|
fail_if (g_date_get_year (date) != 2005);
|
|
|
|
fail_if (g_date_get_day (date2) != 14);
|
|
|
|
fail_if (g_date_get_month (date2) != 10);
|
|
|
|
fail_if (g_date_get_year (date2) != 2005);
|
|
|
|
g_date_free (date2);
|
|
|
|
|
|
|
|
gst_tag_list_free (tag_list);
|
|
|
|
g_date_free (date);
|
|
|
|
}
|
2006-07-01 20:56:56 +00:00
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2006-10-07 18:41:19 +00:00
|
|
|
GST_START_TEST (test_type)
|
|
|
|
{
|
|
|
|
GstTagList *taglist;
|
|
|
|
|
|
|
|
taglist = gst_tag_list_new ();
|
|
|
|
fail_unless (GST_IS_TAG_LIST (taglist));
|
|
|
|
fail_unless (gst_is_tag_list (taglist));
|
|
|
|
gst_tag_list_free (taglist);
|
|
|
|
|
|
|
|
/* this isn't okay */
|
|
|
|
ASSERT_CRITICAL (fail_if (gst_is_tag_list (NULL)));
|
|
|
|
|
|
|
|
/* this however should be fine */
|
|
|
|
fail_if (GST_IS_TAG_LIST (NULL));
|
2006-10-09 11:20:44 +00:00
|
|
|
|
|
|
|
/* check gst_tag_list_is_empty */
|
|
|
|
ASSERT_CRITICAL (gst_tag_list_is_empty (NULL));
|
|
|
|
taglist = gst_tag_list_new ();
|
|
|
|
fail_unless (gst_tag_list_is_empty (taglist));
|
|
|
|
gst_tag_list_add (taglist, GST_TAG_MERGE_APPEND, GST_TAG_ARTIST, "JD", NULL);
|
|
|
|
fail_if (gst_tag_list_is_empty (taglist));
|
|
|
|
gst_tag_list_free (taglist);
|
2006-10-07 18:41:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2006-10-26 08:49:52 +00:00
|
|
|
GST_START_TEST (test_set_non_utf8_string)
|
|
|
|
{
|
|
|
|
GstTagList *taglist;
|
|
|
|
guint8 foobar[2] = { 0xff, 0x00 }; /* not UTF-8 */
|
|
|
|
|
|
|
|
taglist = gst_tag_list_new ();
|
|
|
|
fail_unless (taglist != NULL);
|
|
|
|
|
|
|
|
ASSERT_WARNING (gst_tag_list_add (taglist, GST_TAG_MERGE_APPEND,
|
|
|
|
GST_TAG_ARTIST, (gchar *) foobar, NULL));
|
|
|
|
|
|
|
|
/* That string field with a non-UTF8 string should not have been added */
|
|
|
|
fail_unless (gst_tag_list_is_empty (taglist));
|
|
|
|
|
|
|
|
gst_tag_list_free (taglist);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2009-03-26 01:09:03 +00:00
|
|
|
GST_START_TEST (test_buffer_tags)
|
|
|
|
{
|
|
|
|
GstTagList *tags;
|
|
|
|
GstBuffer *buf1, *buf2;
|
|
|
|
|
|
|
|
tags = gst_tag_list_new ();
|
|
|
|
buf1 = gst_buffer_new_and_alloc (222);
|
|
|
|
buf2 = gst_buffer_new_and_alloc (100);
|
|
|
|
gst_tag_list_add (tags, GST_TAG_MERGE_APPEND, GST_TAG_IMAGE, buf1,
|
|
|
|
GST_TAG_PREVIEW_IMAGE, buf2, NULL);
|
|
|
|
gst_buffer_unref (buf1);
|
|
|
|
gst_buffer_unref (buf2);
|
|
|
|
|
|
|
|
buf1 = buf2 = NULL;
|
|
|
|
fail_if (!gst_tag_list_get_buffer (tags, GST_TAG_IMAGE, &buf1));
|
|
|
|
gst_buffer_unref (buf1);
|
|
|
|
fail_if (!gst_tag_list_get_buffer (tags, GST_TAG_PREVIEW_IMAGE, &buf2));
|
|
|
|
gst_buffer_unref (buf2);
|
|
|
|
|
|
|
|
fail_if (gst_tag_list_get_buffer_index (tags, GST_TAG_IMAGE, 1, &buf1));
|
|
|
|
fail_if (gst_tag_list_get_buffer_index (tags, GST_TAG_IMAGE, 2, &buf1));
|
|
|
|
fail_if (gst_tag_list_get_buffer_index (tags, GST_TAG_PREVIEW_IMAGE, 1,
|
|
|
|
&buf1));
|
|
|
|
fail_if (gst_tag_list_get_buffer_index (tags, GST_TAG_PREVIEW_IMAGE, 2,
|
|
|
|
&buf1));
|
|
|
|
|
|
|
|
fail_if (!gst_tag_list_get_buffer_index (tags, GST_TAG_IMAGE, 0, &buf1));
|
|
|
|
fail_if (!gst_tag_list_get_buffer_index (tags, GST_TAG_PREVIEW_IMAGE, 0,
|
|
|
|
&buf2));
|
|
|
|
fail_unless_equals_int (GST_BUFFER_SIZE (buf1), 222);
|
|
|
|
fail_unless_equals_int (GST_BUFFER_SIZE (buf2), 100);
|
|
|
|
|
|
|
|
gst_buffer_unref (buf1);
|
|
|
|
gst_buffer_unref (buf2);
|
|
|
|
|
|
|
|
gst_tag_list_free (tags);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2009-05-30 19:50:40 +00:00
|
|
|
GST_START_TEST (test_empty_tags)
|
|
|
|
{
|
|
|
|
GstTagList *tags;
|
|
|
|
|
2009-07-16 12:59:07 +00:00
|
|
|
/* only get g_warnings() with git */
|
|
|
|
if (GST_VERSION_NANO != 1)
|
|
|
|
return;
|
|
|
|
|
2009-05-30 19:50:40 +00:00
|
|
|
tags = gst_tag_list_new ();
|
|
|
|
ASSERT_WARNING (gst_tag_list_add (tags, GST_TAG_MERGE_APPEND,
|
|
|
|
GST_TAG_ARTIST, NULL, NULL));
|
|
|
|
ASSERT_WARNING (gst_tag_list_add (tags, GST_TAG_MERGE_APPEND,
|
|
|
|
GST_TAG_ARTIST, "", NULL));
|
|
|
|
gst_tag_list_add (tags, GST_TAG_MERGE_APPEND, GST_TAG_ARTIST, "xyz", NULL);
|
|
|
|
gst_tag_list_free (tags);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2009-06-14 15:17:50 +00:00
|
|
|
GST_START_TEST (test_new_full)
|
|
|
|
{
|
|
|
|
GstTagList *tags;
|
|
|
|
gchar *artist, *title;
|
|
|
|
gdouble track_gain;
|
|
|
|
guint track_num;
|
|
|
|
|
|
|
|
tags = gst_tag_list_new_full (GST_TAG_ARTIST, "Arty Ist",
|
|
|
|
GST_TAG_TRACK_NUMBER, 9, GST_TAG_TRACK_GAIN, 4.242, GST_TAG_TITLE,
|
|
|
|
"Title!", NULL);
|
|
|
|
|
|
|
|
fail_unless (gst_tag_list_get_string (tags, GST_TAG_ARTIST, &artist));
|
|
|
|
fail_unless_equals_string (artist, "Arty Ist");
|
|
|
|
fail_unless (gst_tag_list_get_string (tags, GST_TAG_TITLE, &title));
|
|
|
|
fail_unless_equals_string (title, "Title!");
|
|
|
|
fail_unless (gst_tag_list_get_uint (tags, GST_TAG_TRACK_NUMBER, &track_num));
|
|
|
|
fail_unless_equals_int (track_num, 9);
|
|
|
|
fail_unless (gst_tag_list_get_double (tags, GST_TAG_TRACK_GAIN, &track_gain));
|
|
|
|
fail_unless_equals_float (track_gain, 4.242);
|
|
|
|
fail_unless (tags != NULL);
|
|
|
|
|
|
|
|
gst_tag_list_free (tags);
|
|
|
|
g_free (artist);
|
|
|
|
g_free (title);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2010-07-11 18:00:54 +00:00
|
|
|
GST_START_TEST (test_merge_strings_with_comma)
|
|
|
|
{
|
|
|
|
GstTagList *tags;
|
|
|
|
gchar *artists = NULL;
|
|
|
|
|
|
|
|
tags = gst_tag_list_new ();
|
|
|
|
gst_tag_list_add (tags, GST_TAG_MERGE_APPEND, GST_TAG_ARTIST, "Foo", NULL);
|
|
|
|
gst_tag_list_add (tags, GST_TAG_MERGE_APPEND, GST_TAG_ARTIST, "Bar", NULL);
|
|
|
|
gst_tag_list_add (tags, GST_TAG_MERGE_APPEND, GST_TAG_ARTIST, "Yay", NULL);
|
|
|
|
gst_tag_list_get_string (tags, GST_TAG_ARTIST, &artists);
|
|
|
|
fail_unless (artists != NULL);
|
|
|
|
/* can't check for exact string since the comma separator is i18n-ed */
|
|
|
|
fail_unless (strstr (artists, "Foo") != NULL);
|
|
|
|
fail_unless (strstr (artists, "Bar") != NULL);
|
|
|
|
fail_unless (strstr (artists, "Yay") != NULL);
|
|
|
|
g_free (artists);
|
|
|
|
gst_tag_list_free (tags);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2006-10-07 18:41:19 +00:00
|
|
|
static Suite *
|
2005-12-06 19:29:15 +00:00
|
|
|
gst_tag_suite (void)
|
2005-06-19 11:32:42 +00:00
|
|
|
{
|
|
|
|
Suite *s = suite_create ("GstTag");
|
|
|
|
TCase *tc_chain = tcase_create ("general");
|
|
|
|
|
|
|
|
suite_add_tcase (s, tc_chain);
|
2008-12-16 09:23:21 +00:00
|
|
|
tcase_add_test (tc_chain, test_basics);
|
|
|
|
tcase_add_test (tc_chain, test_add);
|
2005-06-19 11:32:42 +00:00
|
|
|
tcase_add_test (tc_chain, test_merge);
|
2010-07-11 18:00:54 +00:00
|
|
|
tcase_add_test (tc_chain, test_merge_strings_with_comma);
|
2005-10-14 17:01:56 +00:00
|
|
|
tcase_add_test (tc_chain, test_date_tags);
|
2006-10-07 18:41:19 +00:00
|
|
|
tcase_add_test (tc_chain, test_type);
|
2006-10-26 08:49:52 +00:00
|
|
|
tcase_add_test (tc_chain, test_set_non_utf8_string);
|
2009-03-26 01:09:03 +00:00
|
|
|
tcase_add_test (tc_chain, test_buffer_tags);
|
2009-05-30 19:50:40 +00:00
|
|
|
tcase_add_test (tc_chain, test_empty_tags);
|
2009-06-14 15:17:50 +00:00
|
|
|
tcase_add_test (tc_chain, test_new_full);
|
2005-10-14 17:01:56 +00:00
|
|
|
|
2005-06-19 11:32:42 +00:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2006-07-01 20:56:56 +00:00
|
|
|
GST_CHECK_MAIN (gst_tag);
|