diff --git a/livesupport/modules/gstreamerElements/etc/Makefile.in b/livesupport/modules/gstreamerElements/etc/Makefile.in index e69c0150b..cd727bc20 100644 --- a/livesupport/modules/gstreamerElements/etc/Makefile.in +++ b/livesupport/modules/gstreamerElements/etc/Makefile.in @@ -21,7 +21,7 @@ # # # Author : $Author: maroy $ -# Version : $Revision: 1.1 $ +# Version : $Revision: 1.2 $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/etc/Makefile.in,v $ # # @configure_input@ @@ -125,10 +125,12 @@ LDFLAGS = @LDFLAGS@ ${GSTREAMER_LIBS} \ ONESHOT_READER_LIB_OBJS = ${TMP_DIR}/oneshot-reader.o MINIMAL_AUDIO_SMIL_LIB_OBJS = ${TMP_DIR}/seek.o \ - ${TMP_DIR}/seek-pack.o\ + ${TMP_DIR}/util.o \ + ${TMP_DIR}/seek-pack.o \ ${TMP_DIR}/minimal-audio-smil.o PARTIAL_PLAY_LIB_OBJS = ${TMP_DIR}/seek.o \ + ${TMP_DIR}/util.o \ ${TMP_DIR}/seek-pack.o \ ${TMP_DIR}/smil-util.o \ ${TMP_DIR}/partial-play.o @@ -137,6 +139,7 @@ SWITCHER_LIB_OBJS = ${TMP_DIR}/smil-util.o \ ${TMP_DIR}/switcher.o TEST_RUNNER_OBJS = ${TMP_DIR}/TestRunner.o \ + ${TMP_DIR}/SwitcherTest.o \ ${TMP_DIR}/PartialPlayTest.o \ ${TMP_DIR}/OneshotReaderTest.o \ ${TMP_DIR}/MinimalAudioSmilTest.o diff --git a/livesupport/modules/gstreamerElements/src/PartialPlayTest.cxx b/livesupport/modules/gstreamerElements/src/PartialPlayTest.cxx index ea74d6fc0..7b953c84f 100644 --- a/livesupport/modules/gstreamerElements/src/PartialPlayTest.cxx +++ b/livesupport/modules/gstreamerElements/src/PartialPlayTest.cxx @@ -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/PartialPlayTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -55,6 +55,16 @@ static const char * testFile = "var/1minutecounter.mp3"; /* =============================================== local function prototypes */ +/** + * Signal handler for the eos event of the switcher element. + * + * @param element the element emitting the eos signal + * @param userData pointer to the container bin of the switcher. + */ +static void +eos_signal_handler(GstElement * element, + gpointer userData); + /* ============================================================= module code */ @@ -98,6 +108,7 @@ PartialPlayTest :: firstTest(void) /* set filename property on the file source */ g_object_set(G_OBJECT(filter), "location", testFile, NULL); g_object_set(G_OBJECT(filter), "config", "3s;10s-17s", NULL); + g_signal_connect(filter, "eos", G_CALLBACK(eos_signal_handler), pipeline); gst_element_link(filter, sink); @@ -107,13 +118,27 @@ PartialPlayTest :: firstTest(void) gst_element_set_state(sink, GST_STATE_READY); gst_element_set_state(pipeline, GST_STATE_PLAYING); - // TODO: actually run the test - // unfortunately currently partialplay does get into EOS state - // when needed - //while (gst_bin_iterate(GST_BIN(pipeline))); + while (gst_bin_iterate(GST_BIN(pipeline))); /* clean up nicely */ gst_element_set_state(pipeline, GST_STATE_NULL); gst_object_unref(GST_OBJECT (pipeline)); } + +/*------------------------------------------------------------------------------ + * eos signal handler for the switcher element + *----------------------------------------------------------------------------*/ +static void +eos_signal_handler(GstElement * element, + gpointer userData) +{ + GstElement * container = GST_ELEMENT(userData); + + g_return_if_fail(container != NULL); + g_return_if_fail(GST_IS_ELEMENT(container)); + + // set the container into eos state + gst_element_set_eos(container); +} + diff --git a/livesupport/modules/gstreamerElements/src/SwitcherTest.cxx b/livesupport/modules/gstreamerElements/src/SwitcherTest.cxx new file mode 100644 index 000000000..74a7d0c29 --- /dev/null +++ b/livesupport/modules/gstreamerElements/src/SwitcherTest.cxx @@ -0,0 +1,150 @@ +/*------------------------------------------------------------------------------ + + Copyright (c) 2004 Media Development Loan Fund + + This file is part of the LiveSupport project. + http://livesupport.campware.org/ + To report bugs, send an e-mail to bugs@campware.org + + LiveSupport is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + LiveSupport 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LiveSupport; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + + Author : $Author: maroy $ + Version : $Revision: 1.1 $ + Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/SwitcherTest.cxx,v $ + +------------------------------------------------------------------------------*/ + +/* ============================================================ include files */ + +#ifdef HAVE_CONFIG_H +#include "configure.h" +#endif + +#include +#include + +#include + +#include "SwitcherTest.h" + + +using namespace LiveSupport::GstreamerElements; + +/* =================================================== local data structures */ + + +/* ================================================ local constants & macros */ + +CPPUNIT_TEST_SUITE_REGISTRATION(SwitcherTest); + +static const char * testFile = "var/1minutecounter.mp3"; + + +/* =============================================== local function prototypes */ + +/** + * Signal handler for the eos event of the switcher element. + * + * @param element the element emitting the eos signal + * @param userData pointer to the container bin of the switcher. + */ +static void +eos_signal_handler(GstElement * element, + gpointer userData); + + +/* ============================================================= module code */ + +/*------------------------------------------------------------------------------ + * Set up the test environment + *----------------------------------------------------------------------------*/ +void +SwitcherTest :: setUp(void) throw () +{ +} + + +/*------------------------------------------------------------------------------ + * Clean up the test environment + *----------------------------------------------------------------------------*/ +void +SwitcherTest :: tearDown(void) throw () +{ +} + + +/*------------------------------------------------------------------------------ + * A simple smoke test. + *----------------------------------------------------------------------------*/ +void +SwitcherTest :: firstTest(void) + throw (CPPUNIT_NS::Exception) +{ + GstElement * pipeline; + GstElement * source; + GstElement * decoder; + GstElement * sw; + GstElement * switcher; + GstElement * sink; + + /* initialize GStreamer */ + gst_init(0, 0); + + /* create elements */ + pipeline = gst_pipeline_new("audio-player"); + source = gst_element_factory_make("filesrc", "source"); + decoder = gst_element_factory_make("mad", "decoder"); + sw = gst_element_factory_make("switch", "sw"); + switcher = gst_element_factory_make("switcher", "switcher"); + sink = gst_element_factory_make("alsasink", "alsa-output"); + + /* set filename property on the file source */ + g_object_set(G_OBJECT(source), "location", testFile, NULL); + g_object_set(G_OBJECT(switcher), "source-config", "0[3s]", NULL); + /* listen for the eos event on switcher, so the pipeline can be stopped */ + g_signal_connect(switcher, "eos", G_CALLBACK(eos_signal_handler), pipeline); + + gst_element_link_many(source, decoder, sw, switcher, sink, NULL); + gst_bin_add_many(GST_BIN(pipeline), + source, decoder, sw, switcher, sink, NULL); + + gst_element_set_state(sink, GST_STATE_READY); + gst_element_set_state(pipeline, GST_STATE_PLAYING); + + while (gst_bin_iterate(GST_BIN(pipeline))); + + /* clean up nicely */ + gst_element_set_state(pipeline, GST_STATE_NULL); + gst_object_unref(GST_OBJECT (pipeline)); +} + + +/*------------------------------------------------------------------------------ + * eos signal handler for the switcher element + *----------------------------------------------------------------------------*/ +static void +eos_signal_handler(GstElement * element, + gpointer userData) +{ + GstElement * container = GST_ELEMENT(userData); + + g_return_if_fail(container != NULL); + g_return_if_fail(GST_IS_ELEMENT(container)); + + // set the container into eos state + gst_element_set_eos(container); +} + diff --git a/livesupport/modules/gstreamerElements/src/SwitcherTest.h b/livesupport/modules/gstreamerElements/src/SwitcherTest.h new file mode 100644 index 000000000..73b482408 --- /dev/null +++ b/livesupport/modules/gstreamerElements/src/SwitcherTest.h @@ -0,0 +1,106 @@ +/*------------------------------------------------------------------------------ + + Copyright (c) 2004 Media Development Loan Fund + + This file is part of the LiveSupport project. + http://livesupport.campware.org/ + To report bugs, send an e-mail to bugs@campware.org + + LiveSupport is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + LiveSupport 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LiveSupport; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + + Author : $Author: maroy $ + Version : $Revision: 1.1 $ + Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/SwitcherTest.h,v $ + +------------------------------------------------------------------------------*/ +#ifndef SwitcherTest_h +#define SwitcherTest_h + +#ifndef __cplusplus +#error This is a C++ include file +#endif + + +/* ============================================================ include files */ + +#ifdef HAVE_CONFIG_H +#include "configure.h" +#endif + +#include + + +namespace LiveSupport { +namespace GstreamerElements { + +/* ================================================================ constants */ + + +/* =================================================================== macros */ + + +/* =============================================================== data types */ + +/** + * Unit test for the partialplay gstreamer element. + * + * @author $Author: maroy $ + * @version $Revision: 1.1 $ + */ +class SwitcherTest : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(SwitcherTest); + CPPUNIT_TEST(firstTest); + CPPUNIT_TEST_SUITE_END(); + + protected: + + /** + * A simple smoke test. + * + * @exception CPPUNIT_NS::Exception on test failures. + */ + void + firstTest(void) throw (CPPUNIT_NS::Exception); + + + public: + + /** + * Set up the environment for the test case. + */ + void + setUp(void) throw (); + + /** + * Clean up the environment after the test case. + */ + void + tearDown(void) throw (); +}; + + +/* ================================================= external data structures */ + + +/* ====================================================== function prototypes */ + + +} // namespace GstreamerElements +} // namespace LiveSupport + +#endif // SwitcherTest_h + diff --git a/livesupport/modules/gstreamerElements/src/partial-play.c b/livesupport/modules/gstreamerElements/src/partial-play.c index b684dec5a..913093aa4 100644 --- a/livesupport/modules/gstreamerElements/src/partial-play.c +++ b/livesupport/modules/gstreamerElements/src/partial-play.c @@ -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/partial-play.c,v $ ------------------------------------------------------------------------------*/ @@ -86,7 +86,7 @@ GST_PLUGIN_DEFINE ( "partialplay", "Partial play", plugin_init, - "$Revision: 1.1 $", + "$Revision: 1.2 $", "GPL", "LiveSupport", "http://livesupport.campware.org/" @@ -113,6 +113,17 @@ livesupport_partial_play_class_init(LivesupportPartialPlayClass * klass); static void livesupport_partial_play_base_init(LivesupportPartialPlayClass * klass); +/** + * Signal handler for the eos event of the SeekPack->bin element. + * + * @param element the element emitting the eos signal + * @param userData pointer to the container bin of the switcher, + * which is this PartialPlay element + */ +static void +seek_pack_eos_signal_handler(GstElement * element, + gpointer userData); + /** * PartialPlay instance initializer. * @@ -329,6 +340,25 @@ livesupport_partial_play_class_init(LivesupportPartialPlayClass * klass) } +/*------------------------------------------------------------------------------ + * eos signal handler for the seekPack->bin element + *----------------------------------------------------------------------------*/ +static void +seek_pack_eos_signal_handler(GstElement * element, + gpointer userData) +{ + GstElement * container = GST_ELEMENT(userData); + + g_return_if_fail(container != NULL); + g_return_if_fail(GST_IS_ELEMENT(container)); + + /* set the container into eos state */ + + GST_DEBUG("SeekPack.bin setting PartialPlay to eos"); + gst_element_set_eos(container); +} + + /*------------------------------------------------------------------------------ * Initialize a new PartialPlay element. *----------------------------------------------------------------------------*/ @@ -343,6 +373,11 @@ livesupport_partial_play_init(LivesupportPartialPlay * pplay) gst_element_get_pad(pplay->seekPack->bin, "src"), "src"); + g_signal_connect(pplay->seekPack->bin, + "eos", + G_CALLBACK(seek_pack_eos_signal_handler), + pplay); + /* TODO: free these strings when disposing of the object */ pplay->location = g_strdup(""); pplay->config = g_strdup(""); diff --git a/livesupport/modules/gstreamerElements/src/seek-pack.c b/livesupport/modules/gstreamerElements/src/seek-pack.c index fc4c77eb9..86ed91186 100644 --- a/livesupport/modules/gstreamerElements/src/seek-pack.c +++ b/livesupport/modules/gstreamerElements/src/seek-pack.c @@ -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/seek-pack.c,v $ ------------------------------------------------------------------------------*/ @@ -42,6 +42,7 @@ #include +#include "util.h" #include "seek.h" #include "seek-pack.h" @@ -61,6 +62,16 @@ /* =============================================== local function prototypes */ +/** + * Signal handler for the eos event of the switcher element. + * + * @param element the element emitting the eos signal + * @param userData pointer to the container bin of the switcher. + */ +static void +switcher_eos_signal_handler(GstElement * element, + gpointer userData); + /** * Perform the seeks on the SeekPack, set by the initialization function. * @@ -73,6 +84,25 @@ livesupport_seek_pack_seek(LivesupportSeekPack * seekPack); /* ============================================================= module code */ +/*------------------------------------------------------------------------------ + * eos signal handler for the switcher element + *----------------------------------------------------------------------------*/ +static void +switcher_eos_signal_handler(GstElement * element, + gpointer userData) +{ + GstElement * container = GST_ELEMENT(userData); + + g_return_if_fail(container != NULL); + g_return_if_fail(GST_IS_ELEMENT(container)); + + /* set the container into eos state */ + + GST_DEBUG("SeekPack.switcher setting SeekPack.bin to eos"); + gst_element_set_eos(container); +} + + /*------------------------------------------------------------------------------ * Create a new SeekPack. *----------------------------------------------------------------------------*/ @@ -102,6 +132,11 @@ livesupport_seek_pack_new(const gchar * uniqueName) seekPack->bin = gst_bin_new(str); g_free(str); + g_signal_connect(seekPack->switcher, + "eos", + G_CALLBACK(switcher_eos_signal_handler), + seekPack->bin); + seekPack->silenceDuration = 0LL; seekPack->startTime = 0LL; seekPack->endTime = 0LL; diff --git a/livesupport/modules/gstreamerElements/src/seek.c b/livesupport/modules/gstreamerElements/src/seek.c index 1a9d08df2..f3e3356d4 100644 --- a/livesupport/modules/gstreamerElements/src/seek.c +++ b/livesupport/modules/gstreamerElements/src/seek.c @@ -22,13 +22,14 @@ Author : $Author: maroy $ - Version : $Revision: 1.1 $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/seek.c,v $ ------------------------------------------------------------------------------*/ /* ============================================================ include files */ +#include "util.h" #include "seek.h" @@ -69,17 +70,6 @@ seek_element(GstElement * element, gint64 seekTime); #endif -#ifndef SEEK_ELEMENT -/** - * Return the first src pad for an element. - * - * @param element the element to return the pad from. - * @return the first src pad for element, or NULL. - */ -static GstPad * -get_src_pad(GstElement * element); -#endif - #ifndef SEEK_ELEMENT /** * Seek on the first src pad of an element. @@ -112,30 +102,6 @@ seek_element(GstElement * element, #endif -#ifndef SEEK_ELEMENT -/*------------------------------------------------------------------------------ - * Return the first src pad for an element. - *----------------------------------------------------------------------------*/ -static GstPad * -get_src_pad(GstElement * element) -{ - const GList * pads; - - for (pads = gst_element_get_pad_list(element); - pads; - pads = g_list_next(pads)) { - GstPad * pad = pads->data; - - if (GST_PAD_IS_SRC(pad)) { - return pad; - } - } - - return 0; -} -#endif - - #ifndef SEEK_ELEMENT /*------------------------------------------------------------------------------ * Seek on the first src pad of an element. diff --git a/livesupport/modules/gstreamerElements/src/switcher.c b/livesupport/modules/gstreamerElements/src/switcher.c index 7f454d0b6..3710688d5 100644 --- a/livesupport/modules/gstreamerElements/src/switcher.c +++ b/livesupport/modules/gstreamerElements/src/switcher.c @@ -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/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.1 $", + "$Revision: 1.2 $", "GPL", "LiveSupport", "http://livesupport.campware.org/" @@ -385,7 +385,6 @@ livesupport_switcher_chain(GstPad * pad, g_return_if_fail(LIVESUPPORT_IS_SWITCHER(switcher)); if (switcher->eos) { - GstElement * parent; GstEvent * event; GST_DEBUG("switcher_chain: eos"); @@ -394,22 +393,6 @@ livesupport_switcher_chain(GstPad * pad, gst_pad_send_event(switcher->srcpad, event); gst_element_set_eos(GST_ELEMENT(switcher)); - parent = GST_ELEMENT(gst_element_get_parent(GST_ELEMENT(switcher))); - if (parent) { - gst_element_set_eos(parent); - } - /* TODO: fix this mess here... */ - /* - for (parent = - GST_ELEMENT(gst_element_get_parent(GST_ELEMENT(switcher))); - parent; - parent = GST_ELEMENT(gst_element_get_parent(parent))) { - - GST_DEBUG("switcher_chain: eos #1.1"); - gst_element_set_eos(parent); - } - */ - return; } diff --git a/livesupport/modules/gstreamerElements/src/util.c b/livesupport/modules/gstreamerElements/src/util.c new file mode 100644 index 000000000..799e8aa06 --- /dev/null +++ b/livesupport/modules/gstreamerElements/src/util.c @@ -0,0 +1,68 @@ +/*------------------------------------------------------------------------------ + + Copyright (c) 2004 Media Development Loan Fund + + This file is part of the LiveSupport project. + http://livesupport.campware.org/ + To report bugs, send an e-mail to bugs@campware.org + + LiveSupport is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + LiveSupport 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LiveSupport; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + + Author : $Author: maroy $ + Version : $Revision: 1.1 $ + Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/util.c,v $ + +------------------------------------------------------------------------------*/ + +/* ============================================================ include files */ + +#include "util.h" + + +/* =================================================== local data structures */ + + +/* ================================================ local constants & macros */ + + +/* =============================================== local function prototypes */ + + +/* ============================================================= module code */ + +/*------------------------------------------------------------------------------ + * Return the first src pad for an element. + *----------------------------------------------------------------------------*/ +GstPad * +get_src_pad(GstElement * element) +{ + const GList * pads; + + g_return_val_if_fail(element != NULL, NULL); + + for (pads = gst_element_get_pad_list(element); + pads; + pads = g_list_next(pads)) { + GstPad * pad = pads->data; + + if (GST_PAD_IS_SRC(pad)) { + return pad; + } + } + + return 0; +} + diff --git a/livesupport/modules/gstreamerElements/src/util.h b/livesupport/modules/gstreamerElements/src/util.h new file mode 100644 index 000000000..cce18f036 --- /dev/null +++ b/livesupport/modules/gstreamerElements/src/util.h @@ -0,0 +1,68 @@ +/*------------------------------------------------------------------------------ + + Copyright (c) 2004 Media Development Loan Fund + + This file is part of the LiveSupport project. + http://livesupport.campware.org/ + To report bugs, send an e-mail to bugs@campware.org + + LiveSupport is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + LiveSupport 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LiveSupport; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + + Author : $Author: maroy $ + Version : $Revision: 1.1 $ + Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/util.h,v $ + +------------------------------------------------------------------------------*/ +#ifndef Util_h +#define Util_h + +/** + * @file + * Utility functions helping to work with SMIL-related data structures. + * + * @author $Author: maroy $ + * @version $Revision: 1.1 $ + */ + + +/* ============================================================ include files */ + +#include + + +/* ================================================================ constants */ + + +/* =================================================================== macros */ + + +/* =============================================================== data types */ + + +/* ====================================================== function prototypes */ + +/** + * Return the first src pad for an element. + * + * @param element the element to return the pad from. + * @return the first src pad for element, or NULL. + */ +GstPad * +get_src_pad(GstElement * element); + + +#endif /* Util_h */ +