added sequentialSmil test case as a solution for issue #1224

see http://bugs.campware.org/view.php?id=1224
This commit is contained in:
maroy 2005-07-02 19:51:01 +00:00
parent 02bce13c9e
commit be193cd01b
9 changed files with 90 additions and 19 deletions

View file

@ -22,7 +22,7 @@
Author : $Author: maroy $ Author : $Author: maroy $
Version : $Revision: 1.6 $ Version : $Revision: 1.7 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/MinimalAudioSmilTest.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/MinimalAudioSmilTest.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -119,6 +119,13 @@ static const char * fadeInOutSmilFile = "var/fadeInOut.smil";
static const char * fadeInOutParallelSmilFile = static const char * fadeInOutParallelSmilFile =
"var/fadeInOutParallel.smil"; "var/fadeInOutParallel.smil";
/**
* A SMIL file containing several audio elements in a par, that in effect
* play sequentially.
*/
static const char * sequentialSmilFile =
"var/sequentialSmil.smil";
/* =============================================== local function prototypes */ /* =============================================== local function prototypes */
@ -376,3 +383,20 @@ MinimalAudioSmilTest :: fadeInOutParallelTest(void)
CPPUNIT_ASSERT_MESSAGE(str, timePlayed < 5.1 * GST_SECOND); CPPUNIT_ASSERT_MESSAGE(str, timePlayed < 5.1 * GST_SECOND);
} }
/*------------------------------------------------------------------------------
* A sequential par element test.
*----------------------------------------------------------------------------*/
void
MinimalAudioSmilTest :: sequentialSmilTest(void)
throw (CPPUNIT_NS::Exception)
{
gint64 timePlayed;
char str[256];
timePlayed = playSmilFile(sequentialSmilFile);
g_snprintf(str, 256, "time played: %" G_GINT64_FORMAT, timePlayed);
CPPUNIT_ASSERT_MESSAGE(str, timePlayed > 34.7 * GST_SECOND);
CPPUNIT_ASSERT_MESSAGE(str, timePlayed < 35.0 * GST_SECOND);
}

View file

@ -22,7 +22,7 @@
Author : $Author: maroy $ Author : $Author: maroy $
Version : $Revision: 1.6 $ Version : $Revision: 1.7 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/MinimalAudioSmilTest.h,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/MinimalAudioSmilTest.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -58,7 +58,7 @@ namespace GstreamerElements {
* Unit test for the partialplay gstreamer element. * Unit test for the partialplay gstreamer element.
* *
* @author $Author: maroy $ * @author $Author: maroy $
* @version $Revision: 1.6 $ * @version $Revision: 1.7 $
*/ */
class MinimalAudioSmilTest : public CPPUNIT_NS::TestFixture class MinimalAudioSmilTest : public CPPUNIT_NS::TestFixture
{ {
@ -74,6 +74,7 @@ class MinimalAudioSmilTest : public CPPUNIT_NS::TestFixture
CPPUNIT_TEST(soundAnimationParallelTest); CPPUNIT_TEST(soundAnimationParallelTest);
CPPUNIT_TEST(fadeInOutTest); CPPUNIT_TEST(fadeInOutTest);
CPPUNIT_TEST(fadeInOutParallelTest); CPPUNIT_TEST(fadeInOutParallelTest);
CPPUNIT_TEST(sequentialSmilTest);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
private: private:
@ -182,6 +183,14 @@ class MinimalAudioSmilTest : public CPPUNIT_NS::TestFixture
void void
fadeInOutParallelTest(void) throw (CPPUNIT_NS::Exception); fadeInOutParallelTest(void) throw (CPPUNIT_NS::Exception);
/**
* A sequential par element test.
*
* @exception CPPUNIT_NS::Exception on test failures.
*/
void
sequentialSmilTest(void) throw (CPPUNIT_NS::Exception);
public: public:

View file

@ -22,7 +22,7 @@
Author : $Author: maroy $ Author : $Author: maroy $
Version : $Revision: 1.3 $ Version : $Revision: 1.4 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/partial-play.c,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/partial-play.c,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -86,7 +86,7 @@ GST_PLUGIN_DEFINE (
"partialplay", "partialplay",
"Partial play", "Partial play",
plugin_init, plugin_init,
"$Revision: 1.3 $", "$Revision: 1.4 $",
"GPL", "GPL",
"LiveSupport", "LiveSupport",
"http://livesupport.campware.org/" "http://livesupport.campware.org/"
@ -232,6 +232,7 @@ livesupport_partial_play_change_state(GstElement * element)
switch (GST_STATE_TRANSITION (element)) { switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY: case GST_STATE_NULL_TO_READY:
livesupport_seek_pack_set_state(pplay->seekPack, GST_STATE_READY);
break; break;
case GST_STATE_READY_TO_PAUSED: case GST_STATE_READY_TO_PAUSED:
@ -269,6 +270,7 @@ livesupport_partial_play_change_state(GstElement * element)
break; break;
case GST_STATE_READY_TO_NULL: case GST_STATE_READY_TO_NULL:
livesupport_seek_pack_set_state(pplay->seekPack, GST_STATE_NULL);
break; break;
default: default:

View file

@ -22,7 +22,7 @@
Author : $Author: maroy $ Author : $Author: maroy $
Version : $Revision: 1.7 $ Version : $Revision: 1.8 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/seek-pack.c,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/seek-pack.c,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -117,13 +117,16 @@ livesupport_seek_pack_new(const gchar * uniqueName)
g_snprintf(str, len, "%s_seekPackSilence", uniqueName); g_snprintf(str, len, "%s_seekPackSilence", uniqueName);
seekPack->silence = gst_element_factory_make("silence", str); seekPack->silence = gst_element_factory_make("silence", str);
g_snprintf(str, len, "%s_seekPackAudioConvert", uniqueName); g_snprintf(str, len, "%s_seekPackSilenceAudioConvert", uniqueName);
seekPack->audioconvert = gst_element_factory_make("audioconvert", str); seekPack->silenceConvert = gst_element_factory_make("audioconvert",
str);
seekPack->source = NULL; seekPack->source = NULL;
/* generate decoder later, by autoplugging */ /* generate decoder later, by autoplugging */
seekPack->decoder = 0; seekPack->decoder = 0;
seekPack->decoderConvert = 0;
seekPack->decoderScale = 0;
g_snprintf(str, len, "%s_seekPackSwitcher", uniqueName); g_snprintf(str, len, "%s_seekPackSwitcher", uniqueName);
seekPack->switcher = gst_element_factory_make("switcher", str); seekPack->switcher = gst_element_factory_make("switcher", str);
g_snprintf(str, len, "%s_seekPackBin", uniqueName); g_snprintf(str, len, "%s_seekPackBin", uniqueName);
@ -191,32 +194,41 @@ livesupport_seek_pack_init(LivesupportSeekPack * seekPack,
g_snprintf(name, len, "%s_seekPackDecoder", seekPack->name); g_snprintf(name, len, "%s_seekPackDecoder", seekPack->name);
seekPack->decoder = ls_gst_autoplug_plug_source(seekPack->source, seekPack->decoder = ls_gst_autoplug_plug_source(seekPack->source,
name); name);
g_snprintf(name, len, "%s_seekPackDecoderConvert", seekPack->name);
seekPack->decoderConvert = gst_element_factory_make("audioconvert", name);
g_snprintf(name, len, "%s_seekPackDecoderScale", seekPack->name);
seekPack->decoderScale = gst_element_factory_make("audioscale", name);
g_free(name); g_free(name);
/* link up the silence element with the switcher first */ /* link up the silence element with the switcher first */
gst_element_link_many(seekPack->silence, gst_element_link_many(seekPack->silence,
seekPack->audioconvert, seekPack->silenceConvert,
seekPack->switcher, seekPack->switcher,
NULL); NULL);
if (seekPack->decoder) { if (seekPack->decoder) {
/* seek on the decoder, and link it up with the switcher */ /* seek on the decoder, and link it up with the switcher */
gst_element_link(seekPack->source, seekPack->decoder); gst_element_link_many(seekPack->source, seekPack->decoder);
livesupport_seek_pack_seek(seekPack); livesupport_seek_pack_seek(seekPack);
gst_element_link(seekPack->decoder, seekPack->switcher);
} else { } else {
/* just fake the content with silence, /* just fake the content with silence,
* if it could not be auto-plugged */ * if it could not be auto-plugged */
seekPack->decoder = gst_element_factory_make("silence", "decoder"); seekPack->decoder = gst_element_factory_make("silence", "decoder");
gst_element_link(seekPack->decoder, seekPack->switcher);
} }
gst_element_link_many(seekPack->decoder,
seekPack->decoderConvert,
seekPack->decoderScale,
seekPack->switcher,
NULL);
/* put all inside the bin, and link up a ghost pad to switch's src pad */ /* put all inside the bin, and link up a ghost pad to switch's src pad */
gst_bin_add_many(GST_BIN(seekPack->bin), gst_bin_add_many(GST_BIN(seekPack->bin),
seekPack->silence, seekPack->silence,
seekPack->audioconvert, seekPack->silenceConvert,
seekPack->source, seekPack->source,
seekPack->decoder, seekPack->decoder,
seekPack->decoderConvert,
seekPack->decoderScale,
NULL); NULL);
/* put the switcher last into the bin, and also link it as last /* put the switcher last into the bin, and also link it as last
@ -287,15 +299,27 @@ livesupport_seek_pack_set_state(LivesupportSeekPack * seekPack,
{ {
/* FIXME: resetting the source from PLAYING state would make it lose /* FIXME: resetting the source from PLAYING state would make it lose
* it's seek position */ * it's seek position */
if (seekPack->audioconvert) { if (seekPack->silence) {
gst_element_set_state(seekPack->audioconvert, state); gst_element_set_state(seekPack->silence, state);
}
if (seekPack->silenceConvert) {
gst_element_set_state(seekPack->silenceConvert, state);
} }
if (seekPack->decoder) { if (seekPack->decoder) {
gst_element_set_state(seekPack->decoder, state); gst_element_set_state(seekPack->decoder, state);
} }
if (seekPack->decoderConvert) {
gst_element_set_state(seekPack->decoderConvert, state);
}
if (seekPack->decoderScale) {
gst_element_set_state(seekPack->decoderScale, state);
}
if (seekPack->switcher) { if (seekPack->switcher) {
gst_element_set_state(seekPack->switcher, state); gst_element_set_state(seekPack->switcher, state);
} }
if (seekPack->bin) {
gst_element_set_state(seekPack->bin, state);
}
} }

View file

@ -22,7 +22,7 @@
Author : $Author: maroy $ Author : $Author: maroy $
Version : $Revision: 1.5 $ Version : $Revision: 1.6 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/seek-pack.h,v $ 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. * some silence and then some specified part of the source.
* *
* @author $Author: maroy $ * @author $Author: maroy $
* @version $Revision: 1.5 $ * @version $Revision: 1.6 $
*/ */
#ifdef __cplusplus #ifdef __cplusplus
@ -67,10 +67,12 @@ struct _LivesupportSeekPack {
gchar * name; gchar * name;
GstElement * silence; GstElement * silence;
GstElement * audioconvert; GstElement * silenceConvert;
GstElement * source; GstElement * source;
GstElement * decoder; GstElement * decoder;
GstElement * decoderConvert;
GstElement * decoderScale;
GstElement * switcher; GstElement * switcher;
GstElement * bin; GstElement * bin;

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<smil xmlns = "http://www.w3.org/2001/SMIL20/Language">
<body>
<par>
<audio src="file:var/test10001.mp3" begin="0s"/>
<audio src="file:var/test10002.mp3" begin="11.23s"/>
<audio src="file:var/test10003.mp3" begin="23.45s"/>
</par>
</body>
</smil>