[pitivi] previewers: don't uselessly decode streams.



commit 26d4e73e8987c064524597f9eec5662c7cb4372c
Author: Mathieu Duponchelle <mathieu duponchelle epitech eu>
Date:   Tue Jul 30 18:25:33 2013 +0200

    previewers: don't uselessly decode streams.

 pitivi/timeline/previewers.py |   21 +++++++++++++++++++--
 1 files changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/pitivi/timeline/previewers.py b/pitivi/timeline/previewers.py
index 4615a9c..6aa8cef 100644
--- a/pitivi/timeline/previewers.py
+++ b/pitivi/timeline/previewers.py
@@ -202,7 +202,7 @@ class VideoPreviewer(Clutter.ScrollActor, PreviewGenerator, Zoomable, Loggable):
         """
         # TODO: don't hardcode framerate
         self.pipeline = Gst.parse_launch(
-            "uridecodebin uri={uri} ! "
+            "uridecodebin uri={uri} name=decode ! "
             "videoconvert ! "
             "videorate ! "
             "videoscale method=lanczos ! "
@@ -230,6 +230,9 @@ class VideoPreviewer(Clutter.ScrollActor, PreviewGenerator, Zoomable, Loggable):
             # assume 16:9 aspect ratio
             self.thumb_width = 16 * self.thumb_height / 9
 
+        decode = self.pipeline.get_by_name("decode")
+        decode.connect("autoplug-select", self._autoplugSelectCb)
+
         # pop all messages from the bus so we won't be flooded with messages
         # from the prerolling phase
         while self.pipeline.get_bus().pop():
@@ -470,6 +473,12 @@ class VideoPreviewer(Clutter.ScrollActor, PreviewGenerator, Zoomable, Loggable):
             self._checkCPU()
         return Gst.BusSyncReply.PASS
 
+    def _autoplugSelectCb(self, decode, pad, caps, factory):
+        # Don't plug audio decoders / parsers.
+        if "Audio" in factory.get_klass():
+            return True
+        return False
+
     def _scrollCb(self, unused):
         self._update()
 
@@ -778,8 +787,10 @@ class AudioPreviewer(Clutter.Actor, PreviewGenerator, Zoomable, Loggable):
     def _launchPipeline(self):
         self.debug('Now generating waveforms for "%s"' % filename_from_uri(self._uri))
         self.peaks = None
-        self.pipeline = Gst.parse_launch("uridecodebin caps=audio/x-raw uri=" + self._uri + " ! audioconvert 
! level name=wavelevel interval=10000000 post-messages=true ! fakesink qos=false")
+        self.pipeline = Gst.parse_launch("uridecodebin uri=" + self._uri + " ! audioconvert ! level 
name=wavelevel interval=10000000 post-messages=true ! fakesink qos=false")
         self._level = self.pipeline.get_by_name("wavelevel")
+        decode = self.pipeline.get_by_name("decode")
+        decode.connect("autoplug-select", self._autoplugSelectCb)
         bus = self.pipeline.get_bus()
         bus.add_signal_watch()
 
@@ -918,6 +929,12 @@ class AudioPreviewer(Clutter.Actor, PreviewGenerator, Zoomable, Loggable):
                     self.adapter = PipelineCpuAdapter(self.pipeline)
                     self.adapter.start()
 
+    def _autoplugSelectCb(self, decode, pad, caps, factory):
+        # Don't plug video decoders / parsers.
+        if "Video" in factory.get_klass():
+            return True
+        return False
+
     def _drawContentCb(self, canvas, cr, surf_w, surf_h):
         cr.set_operator(cairo.OPERATOR_CLEAR)
         cr.paint()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]