[pitivi: 7/28] project.py: set width/height on filter caps when settings change. stop/pause pipeline to make sure c



commit 34fcdd3d66a92af02a28b6e1dc45bb4ffa6424fa
Author: Brandon Lewis <brandon_lewis alum berkeley edu>
Date:   Mon Feb 1 19:53:14 2010 -0800

    project.py: set width/height on filter caps when settings change. stop/pause
    pipeline to make sure caps are renegotiated

 pitivi/project.py |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/pitivi/project.py b/pitivi/project.py
index 614a197..fd47ef9 100644
--- a/pitivi/project.py
+++ b/pitivi/project.py
@@ -34,6 +34,7 @@ from pitivi.settings import ExportSettings
 from pitivi.signalinterface import Signallable
 from pitivi.action import ViewAction
 from pitivi.utils import Seeker
+import gst
 
 class ProjectError(Exception):
     """Project error"""
@@ -81,6 +82,7 @@ class Project(Signallable, Loggable):
         self.urichanged = False
         self.format = None
         self.sources = SourceList()
+        self.sources.connect("source-added", self._sourceAddedCb)
         self.sources.connect("source-removed", self._sourceRemovedCb)
 
         self._dirty = False
@@ -93,6 +95,19 @@ class Project(Signallable, Loggable):
         self.view_action.addProducers(self.factory)
         self.seeker = Seeker(80)
 
+        self.getCapsFromSettings()
+
+    def getCapsFromSettings(self):
+        settings = self.getSettings()
+        formatstr = "video/x-raw-rgb,width=(int)%d,height=(int)%d;"\
+            "video/x-raw-yuv,width=(int)%d,height=(int)%d"
+        capstr = formatstr % (
+            settings.videowidth,
+            settings.videoheight,
+            settings.videowidth,
+            settings.videoheight)
+        self._videocaps = gst.Caps(capstr)
+
     def release(self):
         self.pipeline.release()
         self.pipeline = None
@@ -116,6 +131,7 @@ class Project(Signallable, Loggable):
         self.log("Setting %s as the project's settings", settings)
         oldsettings = self.settings
         self.settings = settings
+        self._projectSettingsChanged()
         self.emit('settings-changed', oldsettings, settings)
 
     def unsetSettings(self, unused_settings):
@@ -186,5 +202,16 @@ class Project(Signallable, Loggable):
     def hasUnsavedModifications(self):
         return self._dirty
 
+    def _projectSettingsChanged(self):
+        self.getCapsFromSettings()
+        for fact in self.sources.getSources():
+            fact.setFilterCaps(self._videocaps)
+        if self.pipeline.getState() != gst.STATE_NULL:
+            self.pipeline.stop()
+            self.pipeline.pause()
+
+    def _sourceAddedCb(self, sourcelist, factory):
+        factory.setFilterCaps(self._videocaps)
+
     def _sourceRemovedCb(self, sourclist, uri, factory):
         self.timeline.removeFactory(factory)



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