[pitivi: 5/13] discoverer: add an elements whose sole purpose is to EOS after a buffer.
- From: Edward Hervey <edwardrv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi: 5/13] discoverer: add an elements whose sole purpose is to EOS after a buffer.
- Date: Tue, 2 Mar 2010 11:13:23 +0000 (UTC)
commit 51ba99d7d482aeaf3dd21e54703fd6a90ead032c
Author: Alessandro Decina <alessandro d gmail com>
Date: Mon Mar 1 15:12:08 2010 +0100
discoverer: add an elements whose sole purpose is to EOS after a buffer.
Add EOSSir and use it instead of fakesink.num_buffers = 1 if we have cached
thumbnails. Fixes not-expected errors when discovering images.
pitivi/discoverer.py | 53 +++++++++++++++++++++++++++++++++++++++++++------
pitivi/log/log.py | 2 +-
2 files changed, 47 insertions(+), 8 deletions(-)
---
diff --git a/pitivi/discoverer.py b/pitivi/discoverer.py
index 3d44924..1c0fc0f 100644
--- a/pitivi/discoverer.py
+++ b/pitivi/discoverer.py
@@ -49,6 +49,40 @@ from pitivi.settings import xdg_cache_home
# what encoded format it is
# We will need that in order to create proper Stream objects.
+class EOSSir(gst.Element):
+ __gstdetails__ = (
+ "EOSSir",
+ "Generic",
+ "pushes EOS after the first buffer",
+ "Alessandro Decina <alessandro d gmail com>"
+ )
+
+ srctemplate = gst.PadTemplate("src", gst.PAD_SRC,
+ gst.PAD_ALWAYS, gst.Caps("ANY"))
+ sinktemplate = gst.PadTemplate("sink", gst.PAD_SINK,
+ gst.PAD_ALWAYS, gst.Caps("ANY"))
+
+ __gsttemplates__ = (srctemplate, sinktemplate)
+
+ def __init__(self):
+ gst.Element.__init__(self)
+
+ self.sinkpad = gst.Pad(self.sinktemplate, "sink")
+ self.sinkpad.set_chain_function(self.chain)
+ self.add_pad(self.sinkpad)
+
+ self.srcpad = gst.Pad(self.srctemplate, "src")
+ self.add_pad(self.srcpad)
+
+ def chain(self, pad, buf):
+ ret = self.srcpad.push(buf)
+ if ret == gst.FLOW_OK:
+ self.info("pushed, doing EOS")
+ self.srcpad.push_event(gst.event_new_eos())
+
+ return ret
+gobject.type_register(EOSSir)
+
class Discoverer(Signallable, Loggable):
"""
Queues requests to discover information about given files.
@@ -185,6 +219,8 @@ class Discoverer(Signallable, Loggable):
self._finishAnalysisAfterResult(rescan=rescan)
def _emitError(self):
+ self.debug("emitting error %s, %s, %s",
+ self.current_uri, self.error, self.error_detail)
self.emit("discovery-error", self.current_uri, self.error, self.error_detail)
def _emitErrorMissingPlugins(self):
@@ -511,21 +547,24 @@ class Discoverer(Signallable, Loggable):
thumbnail = self._getThumbnailFilenameFromPad(pad)
self.thumbnails[pad] = thumbnail
+ have_thumbnail = os.path.exists(thumbnail)
- if os.path.exists(thumbnail):
+ pad.set_blocked_async(True, self._videoPadBlockCb)
+
+ if have_thumbnail:
self.debug("we already have a thumbnail %s for %s", thumbnail, pad)
sink = gst.element_factory_make("fakesink")
- sink.props.num_buffers = 1
- self.dynamic_elements.append(sink)
- self.pipeline.add(sink)
+ eossir = EOSSir()
+ self.dynamic_elements.extend([eossir, sink])
+ self.pipeline.add(eossir, sink)
+ eossir.set_state(gst.STATE_PLAYING)
sink.set_state(gst.STATE_PLAYING)
- pad.link(sink.get_pad("sink"))
+ pad.link(eossir.get_pad("sink"))
+ eossir.link(sink)
return
- pad.set_blocked_async(True, self._videoPadBlockCb)
-
queue = gst.element_factory_make("queue")
queue.props.max_size_bytes = 5 * 1024 * 1024
queue.props.max_size_time = 5 * gst.SECOND
diff --git a/pitivi/log/log.py b/pitivi/log/log.py
index 74a3fc1..794ad0c 100644
--- a/pitivi/log/log.py
+++ b/pitivi/log/log.py
@@ -430,7 +430,7 @@ def stderrHandler(level, object, category, file, line, message):
safeprintf(sys.stderr, '%s [%5d] [0x%12x] %-32s %-17s %-15s %-4s %s %s\n',
getFormattedLevelName(level), os.getpid(), thread.get_ident(),
o[:32], category,
- time.strftime("%b %d %H:%M:%S")
+ time.time()
, "", message, where)
sys.stderr.flush()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]