[pitivi: 13/16] Change the actioner.Renderer class to work with a settings instance which is not the settings instan
- From: Thibault Saunier <tsaunier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi: 13/16] Change the actioner.Renderer class to work with a settings instance which is not the settings instan
- Date: Tue, 7 Jun 2011 16:27:50 +0000 (UTC)
commit 9f87204c75c2b936796dcd0ed78896212c2d0895
Author: Alex BÄ?luÈ? <alexandru balut gmail com>
Date: Thu May 26 16:56:09 2011 +0200
Change the actioner.Renderer class to work with a settings instance which is not the settings instance of the project
The reason is that the changes to the settings which can also be made in the Project Settings dialog must not be saved when they are changed in the Render dialog.
pitivi/actioner.py | 16 ++++++++---
pitivi/settings.py | 19 +++++++------
pitivi/ui/encodingdialog.py | 58 +++++++++++++++++++++++++++++++++++-------
3 files changed, 69 insertions(+), 24 deletions(-)
---
diff --git a/pitivi/actioner.py b/pitivi/actioner.py
index ac821fd..5dd89b8 100644
--- a/pitivi/actioner.py
+++ b/pitivi/actioner.py
@@ -46,7 +46,7 @@ class Actioner(Loggable, Signallable):
"error" : None
}
- def __init__(self, project, pipeline=None):
+ def __init__(self, project, pipeline=None, settings=None):
Loggable.__init__(self)
# grab the Pipeline and settings
self.project = project
@@ -56,7 +56,10 @@ class Actioner(Loggable, Signallable):
self.pipeline = self.project.pipeline
self.acting = False
self.action = None
- self.settings = project.getSettings()
+ if settings:
+ self.settings = settings
+ else:
+ self.settings = project.getSettings()
self.timestarted = 0
def _eosCb(self, unused_pipeline):
@@ -164,12 +167,15 @@ class Actioner(Loggable, Signallable):
class Renderer(Actioner):
""" Rendering helper methods """
- def __init__(self, project, pipeline=None, outfile=None):
+ def __init__(self, project, pipeline=None, settings=None, outfile=None):
"""
+ @param settings: The export settings to be used, or None to use
+ the default export settings of the project.
+ @type settings: ExportSettings
@param outfile: The destination URI
@type outfile: C{URI}
"""
- Actioner.__init__(self, project, pipeline)
+ Actioner.__init__(self, project, pipeline, settings)
self.detectStreamTypes()
self.outfile = outfile
@@ -247,7 +253,7 @@ class Previewer(Actioner):
""" Previewing helper methods """
def __init__(self, project, pipeline=None, ui=None):
- Actioner.__init__(self, project, pipeline)
+ Actioner.__init__(self, project, pipeline=pipeline)
self.ui = ui
def _isReady(self):
diff --git a/pitivi/settings.py b/pitivi/settings.py
index f74a2d7..b2c5670 100644
--- a/pitivi/settings.py
+++ b/pitivi/settings.py
@@ -442,9 +442,12 @@ class ExportSettings(Signallable, Loggable):
Multimedia export settings
Signals:
-
'settings-changed' : the settings have changed
'encoders-changed' : The encoders or muxer have changed
+
+ @ivar render_scale: The scale to be applied to the video width and height
+ when rendering.
+ @type render_scale: int
"""
__signals__ = {
"settings-changed" : None,
@@ -457,14 +460,6 @@ class ExportSettings(Signallable, Loggable):
# TODO : switch to using GstFraction internally where appliable
- # The following dependant attributes caches are common to all instances!
- # A (muxer -> containersettings) map.
- _containersettings_cache = {}
- # A (vencoder -> vcodecsettings) map.
- _vcodecsettings_cache = {}
- # A (aencoder -> acodecsettings) map.
- _acodecsettings_cache = {}
-
muxers, aencoders, vencoders = available_combinations()
def __init__(self, **unused_kw):
@@ -480,6 +475,12 @@ class ExportSettings(Signallable, Loggable):
self.vencoder = "theoraenc"
self.aencoder = "vorbisenc"
self.muxer = "oggmux"
+ # A (muxer -> containersettings) map.
+ self._containersettings_cache = {}
+ # A (vencoder -> vcodecsettings) map.
+ self._vcodecsettings_cache = {}
+ # A (aencoder -> acodecsettings) map.
+ self._acodecsettings_cache = {}
def copy(self):
ret = ExportSettings()
diff --git a/pitivi/ui/encodingdialog.py b/pitivi/ui/encodingdialog.py
index 3829fd6..eb6ce36 100644
--- a/pitivi/ui/encodingdialog.py
+++ b/pitivi/ui/encodingdialog.py
@@ -110,6 +110,8 @@ class EncodingDialog(Renderer, Loggable):
@type preferred_aencoder: str
@ivar preferred_vencoder: The last video encoder selected by the user.
@type preferred_vencoder: str
+ @ivar settings: The settings used for rendering.
+ @type settings: ExportSettings
"""
def __init__(self, app, project, pipeline=None):
@@ -130,7 +132,15 @@ class EncodingDialog(Renderer, Loggable):
# FIXME: re-enable this widget when bug #637078 is implemented
self.selected_only_button.destroy()
- Renderer.__init__(self, project, pipeline)
+ # The Render dialog and the Project Settings dialog have some
+ # common settings, for example the audio sample rate.
+ # When these common settings are changed in the Render dialog,
+ # we don't want them to be saved, so we create a copy of the project's
+ # settings to be used by the Render dialog for rendering.
+ render_settings = project.getSettings().copy()
+ # Note: render_settings will end up as self.settings.
+ Renderer.__init__(self, project,
+ pipeline=pipeline, settings=render_settings)
# Directory and Filename
self.filebutton.set_current_folder(self.app.settings.lastExportFolder)
@@ -274,6 +284,13 @@ class EncodingDialog(Renderer, Loggable):
def _projectSettingsDestroyCb(self, dialog):
"""Handle the destruction of the ProjectSettingsDialog."""
+ settings = self.project.getSettings()
+ self.settings.setVideoProperties(width=settings.videowidth,
+ height=settings.videoheight,
+ framerate=settings.videorate)
+ self.settings.setAudioProperties(nbchanns=settings.audiochannels,
+ rate=settings.audiorate,
+ depth=settings.audiodepth)
self._displaySettings()
def _frameRateComboChangedCb(self, combo):
@@ -288,7 +305,8 @@ class EncodingDialog(Renderer, Loggable):
self.preferred_vencoder = vencoder
def _videoSettingsButtonClickedCb(self, button):
- self._elementSettingsDialog(self.video_encoder_combo, 'vcodecsettings')
+ factory = get_combo_value(self.video_encoder_combo)
+ self._elementSettingsDialog(factory, 'vcodecsettings')
def _channelsComboChangedCb(self, combo):
self.settings.setAudioProperties(nbchanns=get_combo_value(combo))
@@ -307,14 +325,21 @@ class EncodingDialog(Renderer, Loggable):
self.preferred_aencoder = aencoder
def _audioSettingsButtonClickedCb(self, button):
- self._elementSettingsDialog(self.audio_encoder_combo, 'acodecsettings')
+ factory = get_combo_value(self.audio_encoder_combo)
+ self._elementSettingsDialog(factory, 'acodecsettings')
- def _elementSettingsDialog(self, combo, settings_attr):
- factory = get_combo_value(combo)
- settings = getattr(self.settings, settings_attr)
- dialog = GstElementSettingsDialog(factory, settings)
- dialog.window.set_transient_for(self.window)
+ def _elementSettingsDialog(self, factory, settings_attr):
+ """Open a dialog to edit the properties for the specified factory.
+ @param factory: An element factory whose properties the user will edit.
+ @type factory: gst.ElementFactory
+ @param settings_attr: The ExportSettings attribute holding
+ the properties.
+ @type settings_attr: str
+ """
+ properties = getattr(self.settings, settings_attr)
+ dialog = GstElementSettingsDialog(factory, properties=properties)
+ dialog.window.set_transient_for(self.window)
response = dialog.window.run()
if response == gtk.RESPONSE_OK:
setattr(self.settings, settings_attr, dialog.getSettings())
@@ -360,7 +385,20 @@ class EncodingDialog(Renderer, Loggable):
self.debug("Render window is being deleted")
self.destroy()
- def destroy(self):
+ def _updateProjectSettings(self):
+ """Updates the settings of the project."""
# TODO: Do this only when the settings actually changed.
- self.project.setSettings(self.settings)
+ settings = self.project.getSettings()
+ settings.setEncoders(muxer=self.settings.muxer,
+ aencoder=self.settings.aencoder,
+ vencoder=self.settings.vencoder)
+ settings.containersettings = self.settings.containersettings
+ settings.acodecsettings = self.settings.acodecsettings
+ settings.vcodecsettings = self.settings.vcodecsettings
+ settings.setVideoProperties(render_scale=self.settings.render_scale)
+ # Signal that the project settings have been changed.
+ self.project.setSettings(settings)
+
+ def destroy(self):
+ self._updateProjectSettings()
self.window.destroy()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]