added ogg vorbis and SMIL test cases to the SeekPack test

This commit is contained in:
maroy 2005-06-29 14:45:53 +00:00
parent adab12d9e4
commit 26a0ffe30d
5 changed files with 255 additions and 44 deletions

View file

@ -22,7 +22,7 @@
Author : $Author: maroy $
Version : $Revision: 1.2 $
Version : $Revision: 1.3 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/SeekPackTest.cxx,v $
------------------------------------------------------------------------------*/
@ -52,9 +52,19 @@ using namespace LiveSupport::GstreamerElements;
CPPUNIT_TEST_SUITE_REGISTRATION(SeekPackTest);
/**
* A test file.
* An mp3 test file.
*/
static const char * testFile = "var/5seccounter.mp3";
static const char * mp3File = "var/5seccounter.mp3";
/**
* An ogg vorbis test file.
*/
static const char * oggVorbisFile = "var/5seccounter.ogg";
/**
* A smil test file.
*/
static const char * smilFile = "var/simple.smil";
/* =============================================== local function prototypes */
@ -173,13 +183,13 @@ eos_signal_handler(GstElement * element,
* A simple smoke test.
*----------------------------------------------------------------------------*/
void
SeekPackTest :: firstTest(void)
SeekPackTest :: mp3Test(void)
throw (CPPUNIT_NS::Exception)
{
gint64 timePlayed;
char str[256];
timePlayed = playFile(testFile,
timePlayed = playFile(mp3File,
2LL * GST_SECOND,
1LL * GST_SECOND,
3LL * GST_SECOND);
@ -193,13 +203,13 @@ SeekPackTest :: firstTest(void)
* A test with no silence.
*----------------------------------------------------------------------------*/
void
SeekPackTest :: noSilenceTest(void)
SeekPackTest :: mp3NoSilenceTest(void)
throw (CPPUNIT_NS::Exception)
{
gint64 timePlayed;
char str[256];
timePlayed = playFile(testFile,
timePlayed = playFile(mp3File,
0LL * GST_SECOND,
1LL * GST_SECOND,
3LL * GST_SECOND);
@ -213,13 +223,13 @@ SeekPackTest :: noSilenceTest(void)
* Open ended test
*----------------------------------------------------------------------------*/
void
SeekPackTest :: openEndedTest(void)
SeekPackTest :: mp3OpenEndedTest(void)
throw (CPPUNIT_NS::Exception)
{
gint64 timePlayed;
char str[256];
timePlayed = playFile(testFile,
timePlayed = playFile(mp3File,
2LL * GST_SECOND,
1LL * GST_SECOND,
-1LL);
@ -228,3 +238,123 @@ SeekPackTest :: openEndedTest(void)
CPPUNIT_ASSERT_MESSAGE(str, timePlayed < 6.1 * GST_SECOND);
}
/*------------------------------------------------------------------------------
* A simple test with an ogg vorbis file
*----------------------------------------------------------------------------*/
void
SeekPackTest :: oggVorbisTest(void)
throw (CPPUNIT_NS::Exception)
{
gint64 timePlayed;
char str[256];
timePlayed = playFile(oggVorbisFile,
2LL * GST_SECOND,
1LL * GST_SECOND,
3LL * GST_SECOND);
g_snprintf(str, 256, "time played: %" G_GINT64_FORMAT, timePlayed);
CPPUNIT_ASSERT_MESSAGE(str, timePlayed > 3.9 * GST_SECOND);
CPPUNIT_ASSERT_MESSAGE(str, timePlayed < 4.1 * GST_SECOND);
}
/*------------------------------------------------------------------------------
* A no silence test with an ogg vorbis file
*----------------------------------------------------------------------------*/
void
SeekPackTest :: oggVorbisNoSilenceTest(void)
throw (CPPUNIT_NS::Exception)
{
gint64 timePlayed;
char str[256];
timePlayed = playFile(oggVorbisFile,
0LL * GST_SECOND,
1LL * GST_SECOND,
3LL * GST_SECOND);
g_snprintf(str, 256, "time played: %" G_GINT64_FORMAT, timePlayed);
CPPUNIT_ASSERT_MESSAGE(str, timePlayed > 1.9 * GST_SECOND);
CPPUNIT_ASSERT_MESSAGE(str, timePlayed < 2.1 * GST_SECOND);
}
/*------------------------------------------------------------------------------
* An open ended test with an ogg vorbis file
*----------------------------------------------------------------------------*/
void
SeekPackTest :: oggVorbisOpenEndedTest(void)
throw (CPPUNIT_NS::Exception)
{
gint64 timePlayed;
char str[256];
timePlayed = playFile(oggVorbisFile,
2LL * GST_SECOND,
1LL * GST_SECOND,
-1LL);
g_snprintf(str, 256, "time played: %" G_GINT64_FORMAT, timePlayed);
CPPUNIT_ASSERT_MESSAGE(str, timePlayed > 3.9 * GST_SECOND);
CPPUNIT_ASSERT_MESSAGE(str, timePlayed < 4.1 * GST_SECOND);
}
/*------------------------------------------------------------------------------
* A simple test with a SMIL file
*----------------------------------------------------------------------------*/
void
SeekPackTest :: smilTest(void)
throw (CPPUNIT_NS::Exception)
{
gint64 timePlayed;
char str[256];
timePlayed = playFile(smilFile,
2LL * GST_SECOND,
1LL * GST_SECOND,
3LL * GST_SECOND);
g_snprintf(str, 256, "time played: %" G_GINT64_FORMAT, timePlayed);
CPPUNIT_ASSERT_MESSAGE(str, timePlayed > 3.9 * GST_SECOND);
CPPUNIT_ASSERT_MESSAGE(str, timePlayed < 4.1 * GST_SECOND);
}
/*------------------------------------------------------------------------------
* A simple test with a SMIL file, without silence
*----------------------------------------------------------------------------*/
void
SeekPackTest :: smilNoSilenceTest(void)
throw (CPPUNIT_NS::Exception)
{
gint64 timePlayed;
char str[256];
timePlayed = playFile(smilFile,
0LL * GST_SECOND,
1LL * GST_SECOND,
3LL * GST_SECOND);
g_snprintf(str, 256, "time played: %" G_GINT64_FORMAT, timePlayed);
CPPUNIT_ASSERT_MESSAGE(str, timePlayed > 1.9 * GST_SECOND);
CPPUNIT_ASSERT_MESSAGE(str, timePlayed < 2.1 * GST_SECOND);
}
/*------------------------------------------------------------------------------
* A simple test with a SMIL file, playing until EOS
*----------------------------------------------------------------------------*/
void
SeekPackTest :: smilOpenEndedTest(void)
throw (CPPUNIT_NS::Exception)
{
gint64 timePlayed;
char str[256];
timePlayed = playFile(smilFile,
2LL * GST_SECOND,
1LL * GST_SECOND,
-1LL);
g_snprintf(str, 256, "time played: %" G_GINT64_FORMAT, timePlayed);
CPPUNIT_ASSERT_MESSAGE(str, timePlayed > 3.9 * GST_SECOND);
CPPUNIT_ASSERT_MESSAGE(str, timePlayed < 4.1 * GST_SECOND);
}

View file

@ -22,7 +22,7 @@
Author : $Author: maroy $
Version : $Revision: 1.1 $
Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/SeekPackTest.h,v $
------------------------------------------------------------------------------*/
@ -58,14 +58,20 @@ namespace GstreamerElements {
* Unit test for the SeekPack structure.
*
* @author $Author: maroy $
* @version $Revision: 1.1 $
* @version $Revision: 1.2 $
*/
class SeekPackTest : public CPPUNIT_NS::TestFixture
{
CPPUNIT_TEST_SUITE(SeekPackTest);
CPPUNIT_TEST(firstTest);
CPPUNIT_TEST(noSilenceTest);
CPPUNIT_TEST(openEndedTest);
CPPUNIT_TEST(mp3Test);
CPPUNIT_TEST(mp3NoSilenceTest);
CPPUNIT_TEST(mp3OpenEndedTest);
CPPUNIT_TEST(oggVorbisTest);
CPPUNIT_TEST(oggVorbisNoSilenceTest);
CPPUNIT_TEST(oggVorbisOpenEndedTest);
CPPUNIT_TEST(smilTest);
CPPUNIT_TEST(smilNoSilenceTest);
CPPUNIT_TEST(smilOpenEndedTest);
CPPUNIT_TEST_SUITE_END();
private:
@ -92,28 +98,76 @@ class SeekPackTest : public CPPUNIT_NS::TestFixture
protected:
/**
* A simple smoke test.
* A simple mp3 smoke test.
*
* @exception CPPUNIT_NS::Exception on test failures.
*/
void
firstTest(void) throw (CPPUNIT_NS::Exception);
mp3Test(void) throw (CPPUNIT_NS::Exception);
/**
* A test with no silence.
* An mp3 test with no silence.
*
* @exception CPPUNIT_NS::Exception on test failures.
*/
void
noSilenceTest(void) throw (CPPUNIT_NS::Exception);
mp3NoSilenceTest(void) throw (CPPUNIT_NS::Exception);
/**
* An open ended play test.
* An open ended mp3 play test.
*
* @exception CPPUNIT_NS::Exception on test failures.
*/
void
openEndedTest(void) throw (CPPUNIT_NS::Exception);
mp3OpenEndedTest(void) throw (CPPUNIT_NS::Exception);
/**
* Try SeekPack on an ogg vorbis file.
*
* @exception CPPUNIT_NS::Exception on test failures.
*/
void
oggVorbisTest(void) throw (CPPUNIT_NS::Exception);
/**
* Try SeekPack on an ogg vorbis file, without playing silence.
*
* @exception CPPUNIT_NS::Exception on test failures.
*/
void
oggVorbisNoSilenceTest(void) throw (CPPUNIT_NS::Exception);
/**
* Try SeekPack on an ogg vorbis file, playing until EOS.
*
* @exception CPPUNIT_NS::Exception on test failures.
*/
void
oggVorbisOpenEndedTest(void) throw (CPPUNIT_NS::Exception);
/**
* Try SeekPack on a SMIL file.
*
* @exception CPPUNIT_NS::Exception on test failures.
*/
void
smilTest(void) throw (CPPUNIT_NS::Exception);
/**
* Try SeekPack on a SMIL file, with no silence in the front.
*
* @exception CPPUNIT_NS::Exception on test failures.
*/
void
smilNoSilenceTest(void) throw (CPPUNIT_NS::Exception);
/**
* Try SeekPack on a SMIL file, playing until EOS.
*
* @exception CPPUNIT_NS::Exception on test failures.
*/
void
smilOpenEndedTest(void) throw (CPPUNIT_NS::Exception);
public:

View file

@ -22,7 +22,7 @@
Author : $Author: maroy $
Version : $Revision: 1.5 $
Version : $Revision: 1.6 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/seek-pack.c,v $
------------------------------------------------------------------------------*/
@ -121,8 +121,6 @@ livesupport_seek_pack_new(const gchar * uniqueName)
seekPack->audioconvert = gst_element_factory_make("audioconvert", str);
seekPack->source = NULL;
/* TODO: typefind, and create Ogg Vorbis parser/decoder */
seekPack->parser = NULL;
/* generate decoder later, by autoplugging */
seekPack->decoder = 0;
@ -146,17 +144,6 @@ livesupport_seek_pack_new(const gchar * uniqueName)
seekPack->sendingSilence = TRUE;
gst_element_link_many(seekPack->silence,
seekPack->audioconvert,
seekPack->switcher,
NULL);
/* put all inside the bin, and link up a ghost pad to switch's src pad */
gst_bin_add_many(GST_BIN(seekPack->bin),
seekPack->silence,
seekPack->audioconvert,
seekPack->switcher,
NULL);
gst_element_add_ghost_pad(seekPack->bin,
gst_element_get_pad(seekPack->switcher, "src"),
"src");
@ -206,14 +193,32 @@ livesupport_seek_pack_init(LivesupportSeekPack * seekPack,
name);
g_free(name);
/* link up the silence element with the switcher first */
gst_element_link_many(seekPack->silence,
seekPack->audioconvert,
seekPack->switcher,
NULL);
/* seek on the decoder, and link it up with the switcher */
gst_element_link(seekPack->source, seekPack->decoder);
livesupport_seek_pack_seek(seekPack);
gst_element_link(seekPack->decoder, seekPack->switcher);
/* put all inside the bin, and link up a ghost pad to switch's src pad */
gst_bin_add_many(GST_BIN(seekPack->bin),
seekPack->silence,
seekPack->audioconvert,
seekPack->source,
seekPack->decoder,
NULL);
/* put the switcher last into the bin, and also link it as last
* otherwise we'll get a:
* "assertion failed: (group->group_links == NULL)"
* error later on when trying to free up the pipeline
* see http://bugzilla.gnome.org/show_bug.cgi?id=309122
*/
gst_bin_add(GST_BIN(seekPack->bin), seekPack->switcher);
}

View file

@ -22,7 +22,7 @@
Author : $Author: maroy $
Version : $Revision: 1.4 $
Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/seek-pack.h,v $
------------------------------------------------------------------------------*/
@ -35,7 +35,7 @@
* some silence and then some specified part of the source.
*
* @author $Author: maroy $
* @version $Revision: 1.4 $
* @version $Revision: 1.5 $
*/
#ifdef __cplusplus
@ -70,7 +70,6 @@ struct _LivesupportSeekPack {
GstElement * audioconvert;
GstElement * source;
GstElement * parser;
GstElement * decoder;
GstElement * switcher;

View file

@ -22,7 +22,7 @@
Author : $Author: maroy $
Version : $Revision: 1.7 $
Version : $Revision: 1.8 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/switcher.c,v $
------------------------------------------------------------------------------*/
@ -64,7 +64,7 @@ GST_PLUGIN_DEFINE (
"switcher",
"A filter that connects to a swtich, and changes its source",
plugin_init,
"$Revision: 1.7 $",
"$Revision: 1.8 $",
"GPL",
"LiveSupport",
"http://livesupport.campware.org/"
@ -481,9 +481,20 @@ livesupport_switcher_loop(GstElement * element)
GST_INFO("handling event type %d", GST_EVENT_TYPE(event));
if (GST_EVENT_TYPE(event) == GST_EVENT_EOS) {
switch (GST_EVENT_TYPE(event)) {
case GST_EVENT_EOS:
switch_to_next_source(switcher);
} else {
break;
case GST_EVENT_FLUSH:
/* silently discard flush events
* this is because when having an Ogg Vorbis source
* as the second source, the flush event will indefinately
* bounce back and forward, and the filesrc will regenerate
* new flush events ad infinitum */
break;
default:
gst_pad_event_default(switcher->srcpad, event);
}
} else {
@ -510,7 +521,19 @@ livesupport_switcher_loop(GstElement * element)
GST_INFO("handling event type %d", GST_EVENT_TYPE(event));
switch (GST_EVENT_TYPE(event)) {
case GST_EVENT_FLUSH:
/* silently discard flush events
* this is because when having an Ogg Vorbis source
* as the second source, the flush event will indefinately
* bounce back and forward, and the filesrc will regenerate
* new flush events ad infinitum */
break;
default:
gst_pad_event_default(switcher->srcpad, event);
}
return;
}