added ls_gst_autoplug_get_position() function, to make sure position

information is reported correctly
This commit is contained in:
maroy 2005-09-05 19:46:48 +00:00
parent a499b508f3
commit 3d5fb09162
4 changed files with 89 additions and 6 deletions

View file

@ -22,7 +22,7 @@
Author : $Author: maroy $ Author : $Author: maroy $
Version : $Revision: 1.2 $ Version : $Revision: 1.3 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/include/LiveSupport/GstreamerElements/autoplug.h,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/include/LiveSupport/GstreamerElements/autoplug.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -34,7 +34,7 @@
* Functions for autoplugging gstreamer elements based on their MIME types. * Functions for autoplugging gstreamer elements based on their MIME types.
* *
* @author $Author: maroy $ * @author $Author: maroy $
* @version $Revision: 1.2 $ * @version $Revision: 1.3 $
*/ */
#ifdef __cplusplus #ifdef __cplusplus
@ -76,6 +76,19 @@ ls_gst_autoplug_plug_source(GstElement * source,
const gchar * name, const gchar * name,
const GstCaps * caps); const GstCaps * caps);
/**
* Return the current position in a previously autoplugged element.
* This is a workaround function, as querying the element returned by
* ls_gst_autoplug_plug_source() with the standard gstreamer calls
* will not give satisfactory results.
*
* @param element a GstElement that was returned by a previous call to
* ls_gst_autoplug_plug_source()
* @return the current position, in nanoseconds
*/
gint64
ls_gst_autoplug_get_position(GstElement * element);
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */

View file

@ -22,7 +22,7 @@
Author : $Author: maroy $ Author : $Author: maroy $
Version : $Revision: 1.10 $ Version : $Revision: 1.11 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/AutoplugTest.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/AutoplugTest.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -115,6 +115,11 @@ static const char * embeddedSmilFile = "var/embedded.smil";
*/ */
static const char * sequentialSmilFile = "var/sequentialSmil.smil"; static const char * sequentialSmilFile = "var/sequentialSmil.smil";
/**
* A long (in time) playlist
*/
static const char * longSmilFile = "var/bach.smil";
/* =============================================== local function prototypes */ /* =============================================== local function prototypes */
@ -460,5 +465,34 @@ AutoplugTest :: playlistOpenTest(void)
std::cerr << "duration for " << sequentialSmilFile << ": " std::cerr << "duration for " << sequentialSmilFile << ": "
<< *duration << std::endl; << *duration << std::endl;
#endif #endif
duration = openFile(longSmilFile);
#ifdef PRINT_TIMES
std::cerr << "duration for " << longSmilFile << ": "
<< *duration << std::endl;
#endif
}
/*------------------------------------------------------------------------------
* A test to see if play duration is reported properly.
*----------------------------------------------------------------------------*/
void
AutoplugTest :: playDurationTest(void)
throw (CPPUNIT_NS::Exception)
{
gint64 duration;
duration = playFile(mp3TestFile);
#ifdef PRINT_TIMES
std::cerr << "duration for " << mp3TestFile << ": "
<< duration << std::endl;
#endif
duration = playFile(sequentialSmilFile);
#ifdef PRINT_TIMES
std::cerr << "duration for " << sequentialSmilFile << ": "
<< duration << std::endl;
#endif
} }

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/AutoplugTest.h,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/AutoplugTest.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -65,7 +65,7 @@ using namespace boost::posix_time;
* 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 AutoplugTest : public CPPUNIT_NS::TestFixture class AutoplugTest : public CPPUNIT_NS::TestFixture
{ {
@ -79,6 +79,7 @@ class AutoplugTest : public CPPUNIT_NS::TestFixture
CPPUNIT_TEST(shortTest); CPPUNIT_TEST(shortTest);
CPPUNIT_TEST(shortSmilTest); CPPUNIT_TEST(shortSmilTest);
CPPUNIT_TEST(playlistOpenTest); CPPUNIT_TEST(playlistOpenTest);
CPPUNIT_TEST(playDurationTest);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
private: private:
@ -183,6 +184,14 @@ class AutoplugTest : public CPPUNIT_NS::TestFixture
void void
playlistOpenTest(void) throw (CPPUNIT_NS::Exception); playlistOpenTest(void) throw (CPPUNIT_NS::Exception);
/**
* A test to see if play duration is reported properly.
*
* @exception CPPUNIT_NS::Exception on test failures.
*/
void
playDurationTest(void) throw (CPPUNIT_NS::Exception);
public: public:

View file

@ -27,7 +27,7 @@
Author : $Author: maroy $ Author : $Author: maroy $
Version : $Revision: 1.9 $ Version : $Revision: 1.10 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/autoplug.c,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/autoplug.c,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -801,3 +801,30 @@ ls_gst_autoplug_plug_source(GstElement * source,
return bin; return bin;
} }
/*------------------------------------------------------------------------------
* Return the current position of an autoplugged element
*----------------------------------------------------------------------------*/
gint64
ls_gst_autoplug_get_position(GstElement * element)
{
GstFormat format;
gint64 position;
GstElement * sink;
if (!element || !GST_IS_BIN(element)) {
return 0LL;
}
if (!(sink = gst_bin_get_by_name(GST_BIN(element), "audiosink"))) {
return 0LL;
}
format = GST_FORMAT_TIME;
if (!gst_element_query(sink, GST_QUERY_POSITION, &format, &position)
|| format != GST_FORMAT_TIME) {
return 0LL;
}
return position;
}