summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Vander Stichele <thomas@apestaart.org>2006-04-01 16:50:49 +0000
committerThomas Vander Stichele <thomas@apestaart.org>2006-04-01 16:50:49 +0000
commit99d8cf0d15a412b1e3452a95cc2a5b94a47da2fc (patch)
treea268bd9ce2ed59a695abfa493c37308e6ef0b1a9
parent3bf58dfa1c11135e4fd25cacb52b410f846ac8d1 (diff)
downloadgst-plugins-bad-99d8cf0d15a412b1e3452a95cc2a5b94a47da2fc.tar.gz
gst-plugins-bad-99d8cf0d15a412b1e3452a95cc2a5b94a47da2fc.tar.bz2
gst-plugins-bad-99d8cf0d15a412b1e3452a95cc2a5b94a47da2fc.zip
add taglib checks and docs
Original commit message from CVS: add taglib checks and docs
-rw-r--r--ChangeLog29
-rw-r--r--configure.ac9
-rw-r--r--docs/plugins/Makefile.am5
-rw-r--r--docs/plugins/gst-plugins-bad-plugins-decl-list.txt13
-rw-r--r--docs/plugins/gst-plugins-bad-plugins-decl.txt53
-rw-r--r--docs/plugins/gst-plugins-bad-plugins-docs.sgml2
-rw-r--r--docs/plugins/gst-plugins-bad-plugins-sections.txt8
-rw-r--r--docs/plugins/gst-plugins-bad-plugins-undocumented.txt7
-rw-r--r--docs/plugins/inspect/plugin-qtdemux.xml4
-rw-r--r--docs/plugins/inspect/plugin-speed.xml4
-rw-r--r--docs/plugins/inspect/plugin-taglib.xml20
-rw-r--r--docs/plugins/inspect/plugin-tta.xml2
-rw-r--r--ext/taglib/gsttaglib.cc4
-rw-r--r--sys/dxr3/ac3_padder.h6
-rw-r--r--tests/Makefile.am8
-rw-r--r--tests/check/.gitignore1
-rw-r--r--tests/check/Makefile.am34
-rw-r--r--tests/check/elements/.gitignore3
-rw-r--r--tests/check/elements/tagid3v2mux.c426
19 files changed, 623 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index 4481b1f8..1a021882 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,34 @@
2006-04-01 Thomas Vander Stichele <thomas at apestaart dot org>
+ * sys/dxr3/ac3_padder.h:
+ fix up doc strings
+ * docs/plugins/Makefile.am:
+ * docs/plugins/gst-plugins-bad-plugins-decl-list.txt:
+ * docs/plugins/gst-plugins-bad-plugins-decl.txt:
+ * docs/plugins/gst-plugins-bad-plugins-docs.sgml:
+ * docs/plugins/gst-plugins-bad-plugins-sections.txt:
+ * docs/plugins/gst-plugins-bad-plugins-undocumented.txt:
+ * docs/plugins/inspect/plugin-qtdemux.xml:
+ * docs/plugins/inspect/plugin-speed.xml:
+ * docs/plugins/inspect/plugin-taglib.xml:
+ * docs/plugins/inspect/plugin-tta.xml:
+ commit updates
+ * configure.ac:
+ * ext/taglib/gsttaglib.cc:
+ * tests/Makefile.am:
+ * tests/check/.cvsignore:
+ * tests/check/Makefile.am:
+ * tests/check/elements/.cvsignore:
+ * tests/check/elements/tagid3v2mux.c:
+ (test_taglib_id3mux_create_tags), (test_taglib_id3mux_check_tags),
+ (fill_mp3_buffer), (got_buffer), (demux_pad_added),
+ (test_taglib_id3mux_check_output_buffer),
+ (test_taglib_id3mux_with_tags), (GST_START_TEST),
+ (tagid3v2mux_suite), (main):
+ add the tagid3v2mux check from #336110
+
+2006-04-01 Thomas Vander Stichele <thomas at apestaart dot org>
+
* configure.ac:
rework like the other configure.ac files
* Makefile.am:
diff --git a/configure.ac b/configure.ac
index afcb58f3..ade77ab5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -121,6 +121,11 @@ dnl *** checks for programs ***
dnl find a compiler
AC_PROG_CC
+dnl determine c++ compiler
+AC_PROG_CXX
+dnl determine if c++ is available on this system
+AC_CHECK_PROG(HAVE_CXX, $CXX, yes, no)
+
AC_PATH_PROG(VALGRIND_PATH, valgrind, no)
AM_CONDITIONAL(HAVE_VALGRIND, test ! "x$VALGRIND_PATH" = "xno")
@@ -157,6 +162,9 @@ AM_PATH_CHECK(0.9.2, HAVE_CHECK=yes, HAVE_CHECK=no)
AM_CONDITIONAL(HAVE_CHECK, test "x$HAVE_CHECK" = "xyes")
GST_CHECK_GST_PLUGINS_BASE($GST_MAJORMINOR, [$GSTPB_REQ], no)
+GSTPB_PLUGINS_DIR=`$PKG_CONFIG gstreamer-plugins-base-$GST_MAJORMINOR --variable pluginsdir`
+AC_SUBST(GSTPB_PLUGINS_DIR)
+AC_MSG_NOTICE(Using GStreamer Base Plugins in $GSTPB_PLUGINS_DIR)
dnl set license and copyright notice
GST_LICENSE="LGPL"
@@ -697,6 +705,7 @@ common/Makefile
common/m4/Makefile
m4/Makefile
tests/Makefile
+tests/check/Makefile
tests/icles/Makefile
)
AC_OUTPUT
diff --git a/docs/plugins/Makefile.am b/docs/plugins/Makefile.am
index 3ac322d5..4b623eef 100644
--- a/docs/plugins/Makefile.am
+++ b/docs/plugins/Makefile.am
@@ -58,7 +58,7 @@ MKDB_OPTIONS=--sgml-mode
# Used for dependencies.
HFILE_GLOB=$(DOC_SOURCE_DIR)/*/*/*.h
-CFILE_GLOB=$(DOC_SOURCE_DIR)/*/*/*.c
+CFILE_GLOB=$(DOC_SOURCE_DIR)/*/*/*.c $(DOC_SOURCE_DIR)/*/*/*.cc
# this is a wingo addition
# thomasvs: another nice wingo addition would be an explanation on why
@@ -86,7 +86,8 @@ EXAMPLE_CFILES = \
$(top_srcdir)/ext/directfb/dfb-example.c
EXTRA_HFILES = \
- $(top_srcdir)/ext/directfb/dfbvideosink.h
+ $(top_srcdir)/ext/directfb/dfbvideosink.h \
+ $(top_srcdir)/ext/taglib/gsttaglib.h
# Images to copy into HTML directory.
HTML_IMAGES =
diff --git a/docs/plugins/gst-plugins-bad-plugins-decl-list.txt b/docs/plugins/gst-plugins-bad-plugins-decl-list.txt
index ad63ed4b..66937127 100644
--- a/docs/plugins/gst-plugins-bad-plugins-decl-list.txt
+++ b/docs/plugins/gst-plugins-bad-plugins-decl-list.txt
@@ -16,3 +16,16 @@ GST_DFBVIDEOSINK_CLASS
GST_IS_DFBVIDEOSINK_CLASS
</SECTION>
+<SECTION>
+<FILE>gsttaglib</FILE>
+GstTagLibMuxPriv
+<TITLE>GstTagLibMux</TITLE>
+<SUBSECTION Standard>
+GST_TAGLIB_MUX
+GST_IS_TAGLIB_MUX
+GST_TYPE_TAGLIB_MUX
+gst_tag_lib_mux_get_type
+GST_TAGLIB_MUX_CLASS
+GST_IS_TAGLIB_MUX_CLASS
+</SECTION>
+
diff --git a/docs/plugins/gst-plugins-bad-plugins-decl.txt b/docs/plugins/gst-plugins-bad-plugins-decl.txt
index dcd20c0f..a5bfd6fe 100644
--- a/docs/plugins/gst-plugins-bad-plugins-decl.txt
+++ b/docs/plugins/gst-plugins-bad-plugins-decl.txt
@@ -133,3 +133,56 @@ void
<RETURNS>GType </RETURNS>
void
</FUNCTION>
+<STRUCT>
+<NAME>GstTagLibMuxPriv</NAME>
+</STRUCT>
+<STRUCT>
+<NAME>GstTagLibMux</NAME>
+typedef struct _GstTagLibMux {
+ GstElement element;
+
+ GstPad *srcpad;
+ GstPad *sinkpad;
+ GstTagList *event_tags; /* tags received from upstream elements */
+ gsize tag_size;
+ gboolean render_tag;
+
+ GstEvent *newsegment_ev; /* cached newsegment event from upstream */
+} GstTagLibMux;
+</STRUCT>
+<STRUCT>
+<NAME>GstTagLibMuxClass</NAME>
+typedef struct _GstTagLibMuxClass {
+ GstElementClass parent_class;
+} GstTagLibMuxClass;
+</STRUCT>
+<MACRO>
+<NAME>GST_TYPE_TAGLIB_MUX</NAME>
+#define GST_TYPE_TAGLIB_MUX \
+ (gst_tag_lib_mux_get_type())
+</MACRO>
+<MACRO>
+<NAME>GST_TAGLIB_MUX</NAME>
+#define GST_TAGLIB_MUX(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_TAGLIB_MUX,GstTagLibMux))
+</MACRO>
+<MACRO>
+<NAME>GST_TAGLIB_MUX_CLASS</NAME>
+#define GST_TAGLIB_MUX_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_TAGLIB_MUX,GstTagLibMuxClass))
+</MACRO>
+<MACRO>
+<NAME>GST_IS_TAGLIB_MUX</NAME>
+#define GST_IS_TAGLIB_MUX(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_TAGLIB_MUX))
+</MACRO>
+<MACRO>
+<NAME>GST_IS_TAGLIB_MUX_CLASS</NAME>
+#define GST_IS_TAGLIB_MUX_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TAGLIB_MUX))
+</MACRO>
+<FUNCTION>
+<NAME>gst_tag_lib_mux_get_type</NAME>
+<RETURNS>GType </RETURNS>
+void
+</FUNCTION>
diff --git a/docs/plugins/gst-plugins-bad-plugins-docs.sgml b/docs/plugins/gst-plugins-bad-plugins-docs.sgml
index 65a828e9..592f573a 100644
--- a/docs/plugins/gst-plugins-bad-plugins-docs.sgml
+++ b/docs/plugins/gst-plugins-bad-plugins-docs.sgml
@@ -14,6 +14,7 @@
<title>gst-plugins-bad Elements</title>
<xi:include href="xml/element-dfbvideosink.xml" />
+ <xi:include href="xml/element-tagid3v2mux.xml" />
</chapter>
<chapter>
@@ -25,6 +26,7 @@
<xi:include href="xml/plugin-qtdemux.xml" />
<xi:include href="xml/plugin-sdlvideosink.xml" />
<xi:include href="xml/plugin-speed.xml" />
+ <xi:include href="xml/plugin-taglib.xml" />
<xi:include href="xml/plugin-tta.xml" />
</chapter>
diff --git a/docs/plugins/gst-plugins-bad-plugins-sections.txt b/docs/plugins/gst-plugins-bad-plugins-sections.txt
index da82aa0c..c0b65657 100644
--- a/docs/plugins/gst-plugins-bad-plugins-sections.txt
+++ b/docs/plugins/gst-plugins-bad-plugins-sections.txt
@@ -6,3 +6,11 @@ GstDfbVideoSink
GstDfbVideoSinkClass
</SECTION>
+<SECTION>
+<FILE>element-tagid3v2mux</FILE>
+GstTagLibMux
+<TITLE>tagid3v2mux</TITLE>
+<SUBSECTION Standard>
+GstTagLibMuxClass
+</SECTION>
+
diff --git a/docs/plugins/gst-plugins-bad-plugins-undocumented.txt b/docs/plugins/gst-plugins-bad-plugins-undocumented.txt
index 69f30a77..7deee536 100644
--- a/docs/plugins/gst-plugins-bad-plugins-undocumented.txt
+++ b/docs/plugins/gst-plugins-bad-plugins-undocumented.txt
@@ -1,8 +1,9 @@
-100% symbol docs coverage.
-9 symbols documented.
+92% symbol docs coverage.
+11 symbols documented.
0 symbols incomplete.
-0 not documented.
+1 not documented.
+GstTagLibMux
diff --git a/docs/plugins/inspect/plugin-qtdemux.xml b/docs/plugins/inspect/plugin-qtdemux.xml
index 8c982fd0..33f00943 100644
--- a/docs/plugins/inspect/plugin-qtdemux.xml
+++ b/docs/plugins/inspect/plugin-qtdemux.xml
@@ -3,10 +3,10 @@
<description>Quicktime stream demuxer</description>
<filename>../../gst/qtdemux/.libs/libgstqtdemux.so</filename>
<basename>libgstqtdemux.so</basename>
- <version>0.10.1</version>
+ <version>0.10.1.1</version>
<license>LGPL</license>
<source>gst-plugins-bad</source>
- <package>GStreamer source release</package>
+ <package>GStreamer CVS/prerelease</package>
<origin>http://gstreamer.freedesktop.org/</origin>
<elements>
<element>
diff --git a/docs/plugins/inspect/plugin-speed.xml b/docs/plugins/inspect/plugin-speed.xml
index cc962eea..78faa4a4 100644
--- a/docs/plugins/inspect/plugin-speed.xml
+++ b/docs/plugins/inspect/plugin-speed.xml
@@ -3,10 +3,10 @@
<description>Set speed/pitch on audio/raw streams (resampler)</description>
<filename>../../gst/speed/.libs/libgstspeed.so</filename>
<basename>libgstspeed.so</basename>
- <version>0.10.1</version>
+ <version>0.10.1.1</version>
<license>LGPL</license>
<source>gst-plugins-bad</source>
- <package>GStreamer source release</package>
+ <package>GStreamer CVS/prerelease</package>
<origin>http://gstreamer.freedesktop.org/</origin>
<elements>
<element>
diff --git a/docs/plugins/inspect/plugin-taglib.xml b/docs/plugins/inspect/plugin-taglib.xml
new file mode 100644
index 00000000..50b30bba
--- /dev/null
+++ b/docs/plugins/inspect/plugin-taglib.xml
@@ -0,0 +1,20 @@
+<plugin>
+ <name>taglib</name>
+ <description>Tag-writing plug-in based on taglib</description>
+ <filename>../../ext/taglib/.libs/libgsttaglib.so</filename>
+ <basename>libgsttaglib.so</basename>
+ <version>0.10.2.1</version>
+ <license>LGPL</license>
+ <source>gst-plugins-bad</source>
+ <package>GStreamer Bad Plug-ins CVS/prerelease</package>
+ <origin>Unknown package origin</origin>
+ <elements>
+ <element>
+ <name>tagid3v2mux</name>
+ <longname>TagLib ID3v2 Muxer</longname>
+ <class>Formatter/Metadata</class>
+ <description>Adds an ID3v2 header to the beginning of MP3 files</description>
+ <author>Christophe Fergeau &lt;teuf@gnome.org&gt;</author>
+ </element>
+ </elements>
+</plugin> \ No newline at end of file
diff --git a/docs/plugins/inspect/plugin-tta.xml b/docs/plugins/inspect/plugin-tta.xml
index be1e93a8..fc344bc8 100644
--- a/docs/plugins/inspect/plugin-tta.xml
+++ b/docs/plugins/inspect/plugin-tta.xml
@@ -3,7 +3,7 @@
<description>TTA lossless audio format handling</description>
<filename>../../gst/tta/.libs/libgsttta.so</filename>
<basename>libgsttta.so</basename>
- <version>0.10.1</version>
+ <version>0.10.1.1</version>
<license>LGPL</license>
<source>gst-plugins-bad</source>
<package>gst-tta</package>
diff --git a/ext/taglib/gsttaglib.cc b/ext/taglib/gsttaglib.cc
index 1f466518..affcb600 100644
--- a/ext/taglib/gsttaglib.cc
+++ b/ext/taglib/gsttaglib.cc
@@ -62,7 +62,7 @@ GST_DEBUG_CATEGORY_STATIC (gst_tag_lib_mux_debug);
#define GST_CAT_DEFAULT gst_tag_lib_mux_debug
static const GstElementDetails gst_tag_lib_mux_details =
-GST_ELEMENT_DETAILS ("TagLib ID3 Muxer",
+GST_ELEMENT_DETAILS ("TagLib ID3v2 Muxer",
"Formatter/Metadata",
"Adds an ID3v2 header to the beginning of MP3 files",
"Christophe Fergeau <teuf@gnome.org>");
@@ -640,4 +640,4 @@ GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"taglib",
"Tag-writing plug-in based on taglib",
- plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
+ plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
diff --git a/sys/dxr3/ac3_padder.h b/sys/dxr3/ac3_padder.h
index c9a7447e..63d17090 100644
--- a/sys/dxr3/ac3_padder.h
+++ b/sys/dxr3/ac3_padder.h
@@ -1,7 +1,7 @@
/* GStreamer
* Copyright (C) 2003 Martin Soto <martinsoto@users.sourceforge.net>
*
- * ac3_padder.h: Pad AC3 frames for use with an SPDIF interface.
+ * ac3_padder.h: Pad AC3 frames for use with an SPDIF interface.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -109,7 +109,7 @@ extern int
ac3p_parse(ac3_padder *padder);
-/**
+/*
* ac3p_frame
* @padder The padder structure.
*
@@ -117,7 +117,7 @@ ac3p_parse(ac3_padder *padder);
*/
#define ac3p_frame(padder) ((guint *) &((padder)->frame))
-/**
+/*
* ac3p_frame_size
* @padder The padder structure.
*
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0658f015..aababe77 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,3 +1,9 @@
+if HAVE_CHECK
+SUBDIRS_CHECK = check
+else
+SUBDIRS_CHECK =
+endif
+
if USE_X
SUBDIRS_ICLES = icles
else
@@ -5,7 +11,9 @@ SUBDIRS_ICLES =
endif
SUBDIRS = \
+ $(SUBDIRS_CHECK) \
$(SUBDIRS_ICLES)
DIST_SUBDIRS = \
+ check \
icles
diff --git a/tests/check/.gitignore b/tests/check/.gitignore
new file mode 100644
index 00000000..5d45c6c3
--- /dev/null
+++ b/tests/check/.gitignore
@@ -0,0 +1 @@
+test-registry.xml
diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am
new file mode 100644
index 00000000..d3637504
--- /dev/null
+++ b/tests/check/Makefile.am
@@ -0,0 +1,34 @@
+include $(top_srcdir)/common/check.mak
+
+CHECK_REGISTRY = $(top_builddir)/tests/check/test-registry.xml
+
+GST_TOOLS_DIR = $(top_builddir)/tools
+
+REGISTRY_ENVIRONMENT = \
+ GST_REGISTRY=$(CHECK_REGISTRY)
+
+# FIXME: the PLUGIN_PATH has a hack to reach good for now
+# decide if it's worth it to add a .pc file for this, plus a dependancy on it
+TESTS_ENVIRONMENT = \
+ $(REGISTRY_ENVIRONMENT) \
+ GST_PLUGIN_SYSTEM_PATH= \
+ GST_PLUGIN_PATH=$(top_builddir)/ext:$(GSTPB_PLUGINS_DIR)/../gst-plugins-good:$(GSTPB_PLUGINS_DIR):$(GST_PLUGINS_DIR)
+
+plugindir = $(libdir)/gstreamer-@GST_MAJORMINOR@
+
+# override to _not_ install the test plugins
+install-pluginLTLIBRARIES:
+
+# the core dumps of some machines have PIDs appended
+CLEANFILES = core.* test-registry.xml
+
+SUPPRESSIONS = $(top_srcdir)/common/gst.supp
+
+clean-local: clean-local-check
+
+check_PROGRAMS = \
+ elements/tagid3v2mux
+TESTS = $(check_PROGRAMS)
+
+AM_CFLAGS = $(GST_OBJ_CFLAGS) $(GST_CHECK_CFLAGS) $(CHECK_CFLAGS)
+LDADD = $(GST_OBJ_LIBS) $(GST_CHECK_LIBS) $(CHECK_LIBS)
diff --git a/tests/check/elements/.gitignore b/tests/check/elements/.gitignore
new file mode 100644
index 00000000..9571b0df
--- /dev/null
+++ b/tests/check/elements/.gitignore
@@ -0,0 +1,3 @@
+.dirstamp
+tagid3v2mux
+
diff --git a/tests/check/elements/tagid3v2mux.c b/tests/check/elements/tagid3v2mux.c
new file mode 100644
index 00000000..da032dc4
--- /dev/null
+++ b/tests/check/elements/tagid3v2mux.c
@@ -0,0 +1,426 @@
+/* GStreamer
+ *
+ * unit test for the taglib-based id3v2mux element
+ *
+ * Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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
+ * Library General Public License for more details.
+ *
+ * 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.
+ */
+
+#include <gst/check/gstcheck.h>
+
+#include <gst/gst.h>
+#include <string.h>
+
+#define TEST_ARTIST "Ar T\303\255st"
+#define TEST_TITLE "M\303\274llermilch!"
+#define TEST_ALBUM "Boom"
+#define TEST_DATE g_date_new_dmy(1,1,2006)
+#define TEST_TRACK_NUMBER 7
+#define TEST_TRACK_COUNT 19
+#define TEST_VOLUME_NUMBER 2
+#define TEST_VOLUME_COUNT 3
+
+/* #define TEST_TRACK_GAIN 1.45 (not implemented yet) */
+/* #define TEST_ALBUM_GAIN 0.78 (not implemented yet) */
+
+/* for dummy mp3 frame sized MP3_FRAME_SIZE bytes,
+ * start: ff fb b0 44 00 00 08 00 00 4b 00 00 00 00 00 00 */
+static const guint8 mp3_dummyhdr[] = { 0xff, 0xfb, 0xb0, 0x44, 0x00, 0x00,
+ 0x08, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00
+};
+
+#define MP3_FRAME_SIZE 626
+
+static GstTagList *
+test_taglib_id3mux_create_tags (guint32 mask)
+{
+ GstTagList *tags;
+
+ tags = gst_tag_list_new ();
+
+ if (mask & (1 << 0)) {
+ gst_tag_list_add (tags, GST_TAG_MERGE_KEEP,
+ GST_TAG_ARTIST, TEST_ARTIST, NULL);
+ }
+ if (mask & (1 << 1)) {
+ gst_tag_list_add (tags, GST_TAG_MERGE_KEEP,
+ GST_TAG_TITLE, TEST_TITLE, NULL);
+ }
+ if (mask & (1 << 2)) {
+ gst_tag_list_add (tags, GST_TAG_MERGE_KEEP,
+ GST_TAG_ALBUM, TEST_ALBUM, NULL);
+ }
+ if (mask & (1 << 3)) {
+ GDate *date;
+
+ date = TEST_DATE;
+ gst_tag_list_add (tags, GST_TAG_MERGE_KEEP, GST_TAG_DATE, date, NULL);
+ g_date_free (date);
+ }
+ if (mask & (1 << 4)) {
+ gst_tag_list_add (tags, GST_TAG_MERGE_KEEP,
+ GST_TAG_TRACK_NUMBER, TEST_TRACK_NUMBER, NULL);
+ }
+ if (mask & (1 << 5)) {
+ gst_tag_list_add (tags, GST_TAG_MERGE_KEEP,
+ GST_TAG_TRACK_COUNT, TEST_TRACK_COUNT, NULL);
+ }
+ if (mask & (1 << 6)) {
+ gst_tag_list_add (tags, GST_TAG_MERGE_KEEP,
+ GST_TAG_ALBUM_VOLUME_NUMBER, TEST_VOLUME_NUMBER, NULL);
+ }
+ if (mask & (1 << 7)) {
+ gst_tag_list_add (tags, GST_TAG_MERGE_KEEP,
+ GST_TAG_ALBUM_VOLUME_COUNT, TEST_VOLUME_COUNT, NULL);
+ }
+ if (mask & (1 << 8)) {
+ }
+ if (mask & (1 << 9)) {
+ }
+ if (mask & (1 << 10)) {
+ }
+ if (mask & (1 << 11)) {
+ }
+ if (mask & (1 << 12)) {
+ }
+ if (mask & (1 << 13)) {
+ }
+ return tags;
+}
+
+static void
+test_taglib_id3mux_check_tags (GstTagList * tags, guint32 mask)
+{
+ if (mask & (1 << 0)) {
+ gchar *s = NULL;
+
+ fail_unless (gst_tag_list_get_string (tags, GST_TAG_ARTIST, &s));
+ fail_unless (g_str_equal (s, TEST_ARTIST));
+ g_free (s);
+ }
+ if (mask & (1 << 1)) {
+ gchar *s = NULL;
+
+ fail_unless (gst_tag_list_get_string (tags, GST_TAG_TITLE, &s));
+ fail_unless (g_str_equal (s, TEST_TITLE));
+ g_free (s);
+ }
+ if (mask & (1 << 2)) {
+ gchar *s = NULL;
+
+ fail_unless (gst_tag_list_get_string (tags, GST_TAG_ALBUM, &s));
+ fail_unless (g_str_equal (s, TEST_ALBUM));
+ g_free (s);
+ }
+ if (mask & (1 << 3)) {
+ GDate *shouldbe, *date = NULL;
+
+ shouldbe = TEST_DATE;
+ fail_unless (gst_tag_list_get_date (tags, GST_TAG_DATE, &date));
+ fail_unless (g_date_compare (shouldbe, date) == 0);
+ g_date_free (shouldbe);
+ g_date_free (date);
+ }
+ if (mask & (1 << 4)) {
+ gst_tag_list_add (tags, GST_TAG_MERGE_KEEP,
+ GST_TAG_TRACK_NUMBER, TEST_TRACK_NUMBER, NULL);
+ }
+ if (mask & (1 << 5)) {
+ gst_tag_list_add (tags, GST_TAG_MERGE_KEEP,
+ GST_TAG_TRACK_COUNT, TEST_TRACK_COUNT, NULL);
+ }
+ if (mask & (1 << 6)) {
+ gst_tag_list_add (tags, GST_TAG_MERGE_KEEP,
+ GST_TAG_ALBUM_VOLUME_NUMBER, TEST_VOLUME_NUMBER, NULL);
+ }
+ if (mask & (1 << 7)) {
+ gst_tag_list_add (tags, GST_TAG_MERGE_KEEP,
+ GST_TAG_ALBUM_VOLUME_COUNT, TEST_VOLUME_COUNT, NULL);
+ }
+ if (mask & (1 << 8)) {
+ }
+ if (mask & (1 << 9)) {
+ }
+ if (mask & (1 << 10)) {
+ }
+ if (mask & (1 << 11)) {
+ }
+ if (mask & (1 << 12)) {
+ }
+ if (mask & (1 << 13)) {
+ }
+}
+
+static void
+fill_mp3_buffer (GstElement * fakesrc, GstBuffer * buf, GstPad * pad,
+ guint64 * p_offset)
+{
+ GstCaps *caps;
+
+ g_assert (GST_BUFFER_SIZE (buf) == MP3_FRAME_SIZE);
+
+ GST_LOG ("filling buffer with fake mp3 data, offset = %" G_GUINT64_FORMAT,
+ *p_offset);
+
+ memcpy (GST_BUFFER_DATA (buf), mp3_dummyhdr, sizeof (mp3_dummyhdr));
+ caps = gst_caps_new_simple ("audio/mpeg", "mpegversion", G_TYPE_INT, 1,
+ "layer", G_TYPE_INT, 3, NULL);
+ gst_buffer_set_caps (buf, caps);
+ gst_caps_unref (caps);
+
+ GST_BUFFER_OFFSET (buf) = *p_offset;
+ *p_offset += GST_BUFFER_SIZE (buf);
+}
+
+static void
+got_buffer (GstElement * fakesink, GstBuffer * buf, GstPad * pad,
+ GstBuffer ** p_buf)
+{
+ gint64 off;
+ guint size;
+
+ off = GST_BUFFER_OFFSET (buf);
+ size = GST_BUFFER_SIZE (buf);
+
+ GST_LOG ("got buffer, size=%u, offset=%" G_GINT64_FORMAT, size, off);
+
+ fail_unless (GST_BUFFER_OFFSET_IS_VALID (buf));
+
+ if (*p_buf == NULL || (off + size) > GST_BUFFER_SIZE (*p_buf)) {
+ GstBuffer *newbuf;
+
+ /* not very elegant, but who cares */
+ newbuf = gst_buffer_new_and_alloc (off + size);
+ if (*p_buf) {
+ memcpy (GST_BUFFER_DATA (newbuf), GST_BUFFER_DATA (*p_buf),
+ GST_BUFFER_SIZE (*p_buf));
+ }
+ memcpy (GST_BUFFER_DATA (newbuf) + off, GST_BUFFER_DATA (buf), size);
+ if (*p_buf)
+ gst_buffer_unref (*p_buf);
+ *p_buf = newbuf;
+ } else {
+ memcpy (GST_BUFFER_DATA (*p_buf) + off, GST_BUFFER_DATA (buf), size);
+ }
+}
+static void
+demux_pad_added (GstElement * id3demux, GstPad * srcpad, GstBuffer ** p_outbuf)
+{
+ GstElement *fakesink, *pipeline;
+
+ GST_LOG ("id3demux added source pad with caps %" GST_PTR_FORMAT,
+ GST_PAD_CAPS (srcpad));
+
+ pipeline = id3demux;
+ while (GST_OBJECT_PARENT (pipeline) != NULL)
+ pipeline = (GstElement *) GST_OBJECT_PARENT (pipeline);
+
+ fakesink = gst_element_factory_make ("fakesink", "fakesink");
+ g_assert (fakesink != NULL);
+
+ /* set up sink */
+ g_object_set (fakesink, "signal-handoffs", TRUE, NULL);
+ g_signal_connect (fakesink, "handoff", G_CALLBACK (got_buffer), p_outbuf);
+
+ gst_bin_add (GST_BIN (pipeline), fakesink);
+ gst_element_set_state (fakesink, GST_STATE_PLAYING);
+
+ fail_unless (gst_element_link (id3demux, fakesink));
+}
+
+static void
+test_taglib_id3mux_check_output_buffer (GstBuffer * buf)
+{
+ guint8 *data = GST_BUFFER_DATA (buf);
+ guint size = GST_BUFFER_SIZE (buf);
+ guint off;
+
+ g_assert (size % MP3_FRAME_SIZE == 0);
+
+ for (off = 0; off < size; off += MP3_FRAME_SIZE) {
+ fail_unless (memcmp (data + off, mp3_dummyhdr, sizeof (mp3_dummyhdr)) == 0);
+ }
+}
+
+static void
+test_taglib_id3mux_with_tags (GstTagList * tags, guint32 mask)
+{
+ GstMessage *msg;
+ GstTagList *tags_read = NULL;
+ GstElement *pipeline, *id3mux, *id3demux, *fakesrc;
+ GstBus *bus;
+ guint64 offset;
+ GstBuffer *outbuf = NULL;
+
+ pipeline = gst_pipeline_new ("pipeline");
+ g_assert (pipeline != NULL);
+
+ fakesrc = gst_element_factory_make ("fakesrc", "fakesrc");
+ g_assert (fakesrc != NULL);
+
+ id3mux = gst_element_factory_make ("tagid3v2mux", "tagid3v2mux");
+ g_assert (id3mux != NULL);
+
+ id3demux = gst_element_factory_make ("id3demux", "id3demux");
+ g_assert (id3demux != NULL);
+
+ outbuf = NULL;
+ g_signal_connect (id3demux, "pad-added",
+ G_CALLBACK (demux_pad_added), &outbuf);
+
+ gst_bin_add (GST_BIN (pipeline), fakesrc);
+ gst_bin_add (GST_BIN (pipeline), id3mux);
+ gst_bin_add (GST_BIN (pipeline), id3demux);
+
+ gst_tag_setter_merge_tags (GST_TAG_SETTER (id3mux), tags,
+ GST_TAG_MERGE_APPEND);
+
+ gst_element_link_many (fakesrc, id3mux, id3demux, NULL);
+
+ /* set up source */
+ g_object_set (fakesrc, "signal-handoffs", TRUE, "can-activate-pull", FALSE,
+ "filltype", 2, "sizetype", 2, "sizemax", MP3_FRAME_SIZE,
+ "num-buffers", 16, NULL);
+
+ offset = 0;
+ g_signal_connect (fakesrc, "handoff", G_CALLBACK (fill_mp3_buffer), &offset);
+
+ gst_element_set_state (pipeline, GST_STATE_PLAYING);
+ fail_unless (gst_element_get_state (pipeline, NULL, NULL,
+ -1) == GST_STATE_CHANGE_SUCCESS);
+
+ bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
+
+ GST_LOG ("Waiting for tag ...");
+ msg =
+ gst_bus_poll (bus, GST_MESSAGE_TAG | GST_MESSAGE_EOS | GST_MESSAGE_ERROR,
+ -1);
+ if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR) {
+ GError *err;
+ gchar *dbg;
+
+ gst_message_parse_error (msg, &err, &dbg);
+ g_printerr ("ERROR from element %s: %s\n%s\n",
+ GST_OBJECT_NAME (msg->src), err->message, GST_STR_NULL (dbg));
+ g_error_free (err);
+ g_free (dbg);
+ } else if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_EOS) {
+ g_printerr ("EOS message, but were waiting for TAGS!\n");
+ }
+ fail_unless (msg->type == GST_MESSAGE_TAG);
+
+ gst_message_parse_tag (msg, &tags_read);
+ gst_message_unref (msg);
+
+ GST_LOG ("Got tags: %" GST_PTR_FORMAT, tags_read);
+ test_taglib_id3mux_check_tags (tags_read, mask);
+ gst_tag_list_free (tags_read);
+
+ GST_LOG ("Waiting for EOS ...");
+ msg = gst_bus_poll (bus, GST_MESSAGE_EOS | GST_MESSAGE_ERROR, -1);
+ if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR) {
+ GError *err;
+ gchar *dbg;
+
+ gst_message_parse_error (msg, &err, &dbg);
+ g_printerr ("ERROR from element %s: %s\n%s\n",
+ GST_OBJECT_NAME (msg->src), err->message, GST_STR_NULL (dbg));
+ g_error_free (err);
+ g_free (dbg);
+ }
+ fail_unless (msg->type == GST_MESSAGE_EOS);
+ gst_message_unref (msg);
+
+ gst_object_unref (bus);
+
+ GST_LOG ("Got EOS, shutting down ...");
+ gst_element_set_state (pipeline, GST_STATE_NULL);
+ gst_object_unref (pipeline);
+
+ test_taglib_id3mux_check_output_buffer (outbuf);
+ gst_buffer_unref (outbuf);
+
+ GST_LOG ("Done");
+}
+
+GST_START_TEST (test_id3v2mux)
+{
+ GstTagList *tags;
+ gint i;
+
+ g_random_set_seed (247166295);
+
+ /* internal consistency check */
+ tags = test_taglib_id3mux_create_tags (0xFFFFFFFF);
+ test_taglib_id3mux_check_tags (tags, 0xFFFFFFFF);
+ gst_tag_list_free (tags);
+
+ /* now the real tests */
+ for (i = 0; i < 50; ++i) {
+ guint32 mask;
+
+ mask = g_random_int ();
+ GST_LOG ("tag mask = %08x (i=%d)", mask, i);
+
+ if (mask == 0)
+ continue;
+
+ /* create tags */
+ tags = test_taglib_id3mux_create_tags (mask);
+ GST_LOG ("tags for mask %08x = %" GST_PTR_FORMAT, mask, tags);
+
+ /* double-check for internal consistency */
+ test_taglib_id3mux_check_tags (tags, mask);
+
+ /* test with pipeline */
+ test_taglib_id3mux_with_tags (tags, mask);
+
+ /* free tags */
+ gst_tag_list_free (tags);
+ }
+}
+
+GST_END_TEST;
+
+static Suite *
+tagid3v2mux_suite (void)
+{
+ Suite *s = suite_create ("tagid3v2mux");
+ TCase *tc_chain = tcase_create ("general");
+
+ suite_add_tcase (s, tc_chain);
+ tcase_add_test (tc_chain, test_id3v2mux);
+
+ return s;
+}
+
+int
+main (int argc, char **argv)
+{
+ int nf;
+
+ Suite *s = tagid3v2mux_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;
+}