ensonic gstreamer: gstreamer/ gstreamer/gst/ gstreamer/tests/check/gst/
[email protected] Tue, 16 Dec 2008 01:23:35 -0800 (PST)
| Newsgroups | gmane.comp.video.gstreamer.cvs |
|---|---|
| Message-ID | <[email protected]> |
CVS Root: /cvs/gstreamer
Module: gstreamer
Changes by: ensonic
Date: Tue Dec 16 2008 09:23:35 UTC
Log message:
* gst/gsttaglist.c:
* tests/check/gst/gsttag.c:
More complete unit tests. Fix handling of empty taglists (they were
not merged before).
Modified files:
. : ChangeLog
gst : gsttaglist.c
tests/check/gst : gsttag.c
Links:
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/ChangeLog.diff?r1=1.4194&r2=1.4195
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/gsttaglist.c.diff?r1=1.66&r2=1.67
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/tests/check/gst/gsttag.c.diff?r1=1.11&r2=1.12
====Begin Diffs====
Index: ChangeLog
===================================================================
RCS file: /cvs/gstreamer/gstreamer/ChangeLog,v
retrieving revision 1.4194
retrieving revision 1.4195
diff -u -d -r1.4194 -r1.4195
--- ChangeLog 16 Dec 2008 07:07:33 -0000 1.4194
+++ ChangeLog 16 Dec 2008 09:23:18 -0000 1.4195
@@ -1,3 +1,10 @@
+2008-12-16 Stefan Kost <[email protected]>
+
+ * gst/gsttaglist.c:
+ * tests/check/gst/gsttag.c:
+ More complete unit tests. Fix handling of empty taglists (they were
+ not merged before).
2008-12-15 Stefan Kost <[email protected]>
* gst/gsttaglist.h:
Index: gsttaglist.c
RCS file: /cvs/gstreamer/gstreamer/gst/gsttaglist.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -d -r1.66 -r1.67
--- gsttaglist.c 31 Oct 2008 14:24:49 -0000 1.66
+++ gsttaglist.c 16 Dec 2008 09:23:21 -0000 1.67
@@ -640,7 +640,7 @@
* @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.
+ * Inserts the tags of the @from list into the first list using the given mode.
*/
void
gst_tag_list_insert (GstTagList * into, const GstTagList * from,
@@ -692,23 +692,31 @@
gst_tag_list_merge (const GstTagList * list1, const GstTagList * list2,
GstTagMergeMode mode)
{
+ const GstTagList *list1_cp, *list2_cp;
+ GstTagList *ret;
g_return_val_if_fail (list1 == NULL || GST_IS_TAG_LIST (list1), NULL);
g_return_val_if_fail (list2 == NULL || GST_IS_TAG_LIST (list2), NULL);
g_return_val_if_fail (GST_TAG_MODE_IS_VALID (mode), NULL);
+ /* nothing to merge */
if (!list1 && !list2) {
return NULL;
- } else if (!list1) {
- return gst_tag_list_copy (list2);
- } else if (!list2) {
- return gst_tag_list_copy (list1);
- } else {
- GstTagList *ret;
-
- ret = gst_tag_list_copy (list1);
- gst_tag_list_insert (ret, list2, mode);
- return ret;
}
+ /* create empty list, we need to do this to correctly handling merge modes */
+ list1_cp = (list1) ? list1 : gst_tag_list_new ();
+ list2_cp = (list2) ? list2 : gst_tag_list_new ();
+ ret = gst_tag_list_copy (list1_cp);
+ gst_tag_list_insert (ret, list2_cp, mode);
+ if (!list1)
+ gst_tag_list_free ((GstTagList *) list1_cp);
+ if (!list2)
+ gst_tag_list_free ((GstTagList *) list2_cp);
+ return ret;
}
/**
@@ -818,6 +826,10 @@
g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
g_return_if_fail (tag != NULL);
+ if (mode == GST_TAG_MERGE_REPLACE_ALL) {
+ gst_structure_remove_all_fields (list);
+ }
while (tag != NULL) {
GValue value = { 0, };
Index: gsttag.c
RCS file: /cvs/gstreamer/gstreamer/tests/check/gst/gsttag.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- gsttag.c 6 Nov 2006 15:22:40 -0000 1.11
+++ gsttag.c 16 Dec 2008 09:23:21 -0000 1.12
@@ -21,7 +21,7 @@
#include <string.h>
-/* multiple artists are possible */
+/* multiple artists are possible (unfixed) */
#define UTAG GST_TAG_ARTIST
#define UNFIXED1 "Britney Spears"
#define UNFIXED2 "Evanescence"
@@ -56,12 +56,20 @@
va_end (args);
+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)));
+}
#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); \
+ mark_point(); \
} G_STMT_END;
#define NEW_LIST_UNFIXED(mode) \
@@ -70,6 +78,7 @@
gst_tag_list_add (list, mode, UTAG, UNFIXED1, UTAG, UNFIXED2, \
UTAG, UNFIXED3, UTAG, UNFIXED4, NULL); \
#define NEW_LISTS_FIXED(mode) \
@@ -84,6 +93,7 @@
FTAG, FIXED4, NULL); \
if (merge) gst_tag_list_free (merge); \
merge = gst_tag_list_merge (list, list2, mode); \
#define NEW_LISTS_UNFIXED(mode) \
@@ -98,22 +108,52 @@
UTAG, UNFIXED4, NULL); \
+#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); \
+} G_STMT_END;
+#define NEW_LISTS_EMPTY2(mode) \
+ list = gst_tag_list_new (); \
+ gst_tag_list_add (list, GST_TAG_MERGE_APPEND, FTAG, FIXED1, \
+ FTAG, FIXED2, NULL); \
+ list2 = NULL; \
-GST_START_TEST (test_merge)
-{
- GstTagList *list = NULL, *list2 = NULL, *merge = NULL;
+GST_START_TEST (test_basics)
/* 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 */
+GST_END_TEST
+GST_START_TEST (test_add)
+ GstTagList *list = NULL;
+ /* check additions */
/* unfixed */
NEW_LIST_UNFIXED (GST_TAG_MERGE_REPLACE_ALL);
check_tags (list, UTAG, UNFIXED4, NULL);
@@ -142,8 +182,19 @@
NEW_LIST_FIXED (GST_TAG_MERGE_KEEP_ALL);
check_tags (list, FTAG, NULL);
+ /* clean up */
+ if (list)
+ gst_tag_list_free (list);
+GST_START_TEST (test_merge)
+ GstTagList *list = NULL, *list2 = NULL, *merge = NULL;
/* check merging */
+ GST_DEBUG ("unfixed");
NEW_LISTS_UNFIXED (GST_TAG_MERGE_REPLACE_ALL);
check_tags (merge, UTAG, UNFIXED3, UNFIXED4, NULL);
NEW_LISTS_UNFIXED (GST_TAG_MERGE_REPLACE);
@@ -158,6 +209,7 @@
check_tags (merge, UTAG, UNFIXED1, UNFIXED2, NULL);
/* fixed */
+ GST_DEBUG ("fixed");
NEW_LISTS_FIXED (GST_TAG_MERGE_REPLACE_ALL);
check_tags (merge, FTAG, FIXED3, NULL);
NEW_LISTS_FIXED (GST_TAG_MERGE_REPLACE);
@@ -171,6 +223,36 @@
NEW_LISTS_FIXED (GST_TAG_MERGE_KEEP_ALL);
check_tags (merge, FTAG, FIXED1, NULL);
+ /* 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);
+ NEW_LISTS_EMPTY1 (GST_TAG_MERGE_PREPEND);
+ NEW_LISTS_EMPTY1 (GST_TAG_MERGE_APPEND);
+ NEW_LISTS_EMPTY1 (GST_TAG_MERGE_KEEP);
+ 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);
+ NEW_LISTS_EMPTY2 (GST_TAG_MERGE_REPLACE);
+ check_tags (merge, FTAG, FIXED1, NULL);
+ NEW_LISTS_EMPTY2 (GST_TAG_MERGE_PREPEND);
+ NEW_LISTS_EMPTY2 (GST_TAG_MERGE_APPEND);
+ NEW_LISTS_EMPTY2 (GST_TAG_MERGE_KEEP);
+ NEW_LISTS_EMPTY2 (GST_TAG_MERGE_KEEP_ALL);
/* clean up */
if (list)
gst_tag_list_free (list);
@@ -268,6 +350,8 @@
TCase *tc_chain = tcase_create ("general");
suite_add_tcase (s, tc_chain);
+ tcase_add_test (tc_chain, test_basics);
+ tcase_add_test (tc_chain, test_add);
tcase_add_test (tc_chain, test_merge);
tcase_add_test (tc_chain, test_date_tags);
tcase_add_test (tc_chain, test_type);
------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you. Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/