[pitivi] factories: Setup alpha/ffmpegcolorspace elements for video streams



commit 8a4214cb98d7fa5c9f24d30e5f4849b12cb7edb0
Author: Edward Hervey <bilboed bilboed com>
Date:   Sun Aug 23 13:12:55 2009 +0200

    factories: Setup alpha/ffmpegcolorspace elements for video streams
    
    This needs more work though because it's not doing the mixing properly :)

 pitivi/factories/base.py |   21 ++++++++++++++++++++-
 pitivi/factories/file.py |    4 +++-
 2 files changed, 23 insertions(+), 2 deletions(-)
---
diff --git a/pitivi/factories/base.py b/pitivi/factories/base.py
index 1b769f2..d7ed5bc 100644
--- a/pitivi/factories/base.py
+++ b/pitivi/factories/base.py
@@ -28,7 +28,7 @@ import gst
 from pitivi.log.loggable import Loggable
 from pitivi.elements.singledecodebin import SingleDecodeBin
 from pitivi.signalinterface import Signallable
-from pitivi.stream import match_stream_groups_map, AudioStream
+from pitivi.stream import match_stream_groups_map, AudioStream, VideoStream
 
 # FIXME: define a proper hierarchy
 class ObjectFactoryError(Exception):
@@ -327,6 +327,12 @@ class SourceFactory(ObjectFactory):
             del bin.volume
             del bin.aconv
             del bin.ares
+        elif hasattr(bin, "alpha"):
+            for elt in [bin.csp, bin.alpha]:
+                elt.set_state(gst.STATE_NULL)
+                bin.remove(elt)
+            del bin.csp
+            del bin.alpha
 
         if hasattr(bin, "ghostpad"):
             # singledecodebin found something on this pad
@@ -353,6 +359,14 @@ class SourceFactory(ObjectFactory):
             b.aconv.sync_state_with_parent()
             b.ares.sync_state_with_parent()
             b.volume.sync_state_with_parent()
+        elif isinstance(output_stream, VideoStream):
+            self.debug("Adding alpha element")
+            b.csp = gst.element_factory_make("ffmpegcolorspace", "internal-colorspace")
+            b.alpha = gst.element_factory_make("alpha", "internal-alpha")
+            b.add(b.csp, b.alpha)
+            b.csp.link(b.alpha)
+            b.csp.sync_state_with_parent()
+            b.alpha.sync_state_with_parent()
 
         b.add(b.decodebin)
         return b
@@ -369,6 +383,9 @@ class SourceFactory(ObjectFactory):
 
             pad.link(topbin.aconv.get_pad("sink"))
             topbin.ghostpad = gst.GhostPad("src", topbin.volume.get_pad("src"))
+        elif hasattr(topbin, "alpha"):
+            pad.link(topbin.csp.get_pad("sink"))
+            topbin.ghostpad = gst.GhostPad("src", topbin.alpha.get_pad("src"))
         else:
             topbin.ghostpad = gst.GhostPad("src", pad)
 
@@ -383,6 +400,8 @@ class SourceFactory(ObjectFactory):
         del topbin.ghostpad
         if hasattr(topbin, "volume"):
             pad.unlink(topbin.aconv.get_pad("sink"))
+        elif hasattr(topbin, "alpha"):
+            pad.unlink(topbin.csp.get_pad("sink"))
 
     def addInputStream(self, stream):
         raise AssertionError("source factories can't have input streams")
diff --git a/pitivi/factories/file.py b/pitivi/factories/file.py
index d14a01d..55ad6fe 100644
--- a/pitivi/factories/file.py
+++ b/pitivi/factories/file.py
@@ -43,13 +43,15 @@ class FileSourceFactory(RandomAccessSourceFactory):
         self.filename = uri
 
     def getInterpolatedProperties(self, stream):
+        self.debug("stream:%r", stream)
         # FIXME: dummy implementation
         props = RandomAccessSourceFactory.getInterpolatedProperties(self, 
             stream)
         if isinstance(stream, AudioStream):
             props.update({"volume" : (0.0, 2.0)})
         elif isinstance(stream, VideoStream):
-            props.update({"alpha" : None})
+            props.update({"alpha" : (0.0, 1.0)})
+        self.debug("returning %r", props)
         return props
 
 class PictureFileSourceFactory(FileSourceFactory):



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