From cf22542b26a5c866600aae1f07216d5061b4f651 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Sat, 17 May 2008 13:13:05 +0000 Subject: [PATCH] gst/extend/discoverer.py: Add timeout property. Original commit message from CVS: * gst/extend/discoverer.py: Add timeout property. Fix typos. Beautify debugging. Fix email. --- ChangeLog | 8 ++++++++ common | 2 +- gst/extend/discoverer.py | 27 ++++++++++++++++----------- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index c564ffc65d..5144f6cbea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-05-17 Edward Hervey + + * gst/extend/discoverer.py: + Add timeout property. + Fix typos. + Beautify debugging. + Fix email. + 2008-05-14 Edward Hervey Patch by: Jan Schmidt diff --git a/common b/common index 2d9c09df0f..3b3631082d 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 2d9c09df0fe4ad3f570fea9f649cfc6c4511080d +Subproject commit 3b3631082d04b426f450810e8836de94e9c5d60a diff --git a/gst/extend/discoverer.py b/gst/extend/discoverer.py index 8771d1b2bf..bba379af6e 100644 --- a/gst/extend/discoverer.py +++ b/gst/extend/discoverer.py @@ -2,19 +2,19 @@ # vi:si:et:sw=4:sts=4:ts=4 # discoverer.py -# (c) 2005 Edward Hervey +# (c) 2005-2008 Edward Hervey # Discovers multimedia information on files # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 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 # Lesser General Public License for more details. -# +# # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -45,7 +45,7 @@ class Discoverer(gst.Pipeline): None, (gobject.TYPE_BOOLEAN, )) } - + mimetype = None audiocaps = {} @@ -74,7 +74,7 @@ class Discoverer(gst.Pipeline): tags = {} - def __init__(self, filename, max_interleave=1.0): + def __init__(self, filename, max_interleave=1.0, timeout=3000): """ filename: str; absolute path of the file to be discovered. max_interleave: int or float; the maximum frame interleave in seconds. @@ -82,6 +82,7 @@ class Discoverer(gst.Pipeline): or the discoverer may not find out all input file's streams. The default value is 1 second and you shouldn't have to change it, changing it mean larger discovering time and bigger memory usage. + timeout: int; duration in ms for the discovery to complete. """ gobject.GObject.__init__(self) @@ -114,13 +115,14 @@ class Discoverer(gst.Pipeline): self._nomorepads = False self._timeoutid = 0 + self._timeout = timeout self._max_interleave = max_interleave if not os.path.isfile(filename): self.debug("File '%s' does not exist, finished" % filename) self.finished = True return - + # the initial elements of the pipeline self.src = gst.element_factory_make("filesrc") self.src.set_property("location", filename) @@ -184,8 +186,8 @@ class Discoverer(gst.Pipeline): self.bus.connect("message", self._bus_message_cb) # 3s timeout - self._timeoutid = gobject.timeout_add(3000, self._timed_out_or_eos) - + self._timeoutid = gobject.timeout_add(self._timeout, self._timed_out_or_eos) + self.info("setting to PLAY") if not self.set_state(gst.STATE_PLAYING): self._finished() @@ -265,13 +267,16 @@ class Discoverer(gst.Pipeline): # the caps are fixed # We now get the total length of that stream q = gst.query_new_duration(gst.FORMAT_TIME) - pad.info("sending position query") + pad.info("sending duration query") if pad.get_peer().query(q): format, length = q.parse_duration() - pad.info("got position query answer : %d:%d" % (length, format)) + if format == gst.FORMAT_TIME: + pad.info("got duration (time) : %s" % (gst.TIME_ARGS(length),)) + else: + pad.info("got duration : %d [format:%d]" % (length, format)) else: length = -1 - gst.warning("position query didn't work") + gst.warning("duration query failed") # We store the caps and length in the proper location if "audio" in caps.to_string():