add taglib checks and docs

Original commit message from CVS:
add taglib checks and docs
This commit is contained in:
Thomas Vander Stichele 2006-04-01 16:50:49 +00:00
parent 3bf58dfa1c
commit 99d8cf0d15
19 changed files with 623 additions and 15 deletions

View file

@ -1,3 +1,32 @@
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:

View file

@ -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

View file

@ -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 =

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -6,3 +6,11 @@ GstDfbVideoSink
GstDfbVideoSinkClass
</SECTION>
<SECTION>
<FILE>element-tagid3v2mux</FILE>
GstTagLibMux
<TITLE>tagid3v2mux</TITLE>
<SUBSECTION Standard>
GstTagLibMuxClass
</SECTION>

View file

@ -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

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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);

View file

@ -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.
*

View file

@ -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

1
tests/check/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
test-registry.xml

34
tests/check/Makefile.am Normal file
View file

@ -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)

3
tests/check/elements/.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
.dirstamp
tagid3v2mux

View file

@ -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;
}