[pitivi] project: Fix setting audio properties
- From: Thibault Saunier <tsaunier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] project: Fix setting audio properties
- Date: Thu, 11 Jun 2015 09:22:00 +0000 (UTC)
commit 541825d0d971870db2e6650814853f4d73c77e6c
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Wed May 20 05:16:30 2015 +0200
project: Fix setting audio properties
pitivi/project.py | 33 ++++++++++++++++-----------------
pitivi/render.py | 2 +-
tests/test_project.py | 22 ++++++++++++++++++++++
3 files changed, 39 insertions(+), 18 deletions(-)
---
diff --git a/pitivi/project.py b/pitivi/project.py
index 30fd3cd..700a0a5 100644
--- a/pitivi/project.py
+++ b/pitivi/project.py
@@ -876,22 +876,21 @@ class Project(Loggable, GES.Project):
self.audio_profile.set_restriction(restriction)
self._has_rendering_values = rendering
- def set_video_restriction_value(self, name, value):
- if self.video_profile.get_restriction()[0][name] != value and value:
- restriction = self.video_profile.get_restriction().copy_nth(0)
+ @staticmethod
+ def _set_restriction(profile, name, value):
+ if profile.get_restriction()[0][name] != value and value:
+ restriction = profile.get_restriction().copy_nth(0)
restriction.set_value(name, value)
- self.video_profile.set_restriction(restriction)
+ profile.set_restriction(restriction)
return True
return False
- def set_audio_restriction_value(self, name, value):
- if self.audio_profile.get_restriction()[0][name] != value and value:
- restriction = self.audio_profile.get_restriction().copy_nth(0)
- restriction[0][name] = value
- self.audio_profile.set_restriction(restriction)
- return True
- return False
+ def setVideoRestriction(self, name, value):
+ return Project._set_restriction(self.video_profile, name, value)
+
+ def __setAudioRestriction(self, name, value):
+ return Project._set_restriction(self.audio_profile, name, value)
@property
def videowidth(self):
@@ -899,7 +898,7 @@ class Project(Loggable, GES.Project):
@videowidth.setter
def videowidth(self, value):
- if value and self.set_video_restriction_value("width", int(value)):
+ if value and self.setVideoRestriction("width", int(value)):
self._emitChange("rendering-settings-changed", "width", value)
@property
@@ -908,7 +907,7 @@ class Project(Loggable, GES.Project):
@videoheight.setter
def videoheight(self, value):
- if value and self.set_video_restriction_value("height", int(value)):
+ if value and self.setVideoRestriction("height", int(value)):
self._emitChange("rendering-settings-changed", "height", value)
@property
@@ -917,7 +916,7 @@ class Project(Loggable, GES.Project):
@videorate.setter
def videorate(self, value):
- if self.set_video_restriction_value("framerate", value):
+ if self.setVideoRestriction("framerate", value):
self._emitChange("rendering-settings-changed", "videorate", value)
@property
@@ -926,7 +925,7 @@ class Project(Loggable, GES.Project):
@videopar.setter
def videopar(self, value):
- if self.set_video_restriction_value("pixel-aspect-ratio", value):
+ if self.setVideoRestriction("pixel-aspect-ratio", value):
self._emitChange(
"rendering-settings-changed", "pixel-aspect-ratio", value)
@@ -936,7 +935,7 @@ class Project(Loggable, GES.Project):
@audiochannels.setter
def audiochannels(self, value):
- if value and self.set_audio_restriction_value("channels", int(value)):
+ if value and self.__setAudioRestriction("channels", int(value)):
self._emitChange("rendering-settings-changed", "channels", value)
@property
@@ -948,7 +947,7 @@ class Project(Loggable, GES.Project):
@audiorate.setter
def audiorate(self, value):
- if value and self.set_audio_restriction_value("rate", int(value)):
+ if value and self.__setAudioRestriction("rate", int(value)):
self._emitChange("rendering-settings-changed", "rate", value)
@property
diff --git a/pitivi/render.py b/pitivi/render.py
index 9754b3d..a03daa0 100644
--- a/pitivi/render.py
+++ b/pitivi/render.py
@@ -942,7 +942,7 @@ class RenderDialog(Loggable):
caps = Gst.Caps.from_string(struct.get_caps().to_string())
fixed = caps.fixate()
fmt = fixed.get_structure(0).get_value("format")
- self.project.set_video_restriction_value("format", fmt)
+ self.project.setVideoRestriction("format", fmt)
self._factory_formats[encoder_string] = fmt
break
diff --git a/tests/test_project.py b/tests/test_project.py
index 0783252..8bbae73 100644
--- a/tests/test_project.py
+++ b/tests/test_project.py
@@ -26,6 +26,7 @@ from unittest import TestCase
from gi.repository import GES
from gi.repository import GLib
+from gi.repository import Gst
from pitivi.application import Pitivi
from pitivi.project import ProjectManager
@@ -391,6 +392,27 @@ class TestProjectLoading(TestCase):
self.assertTrue(result[2], "Asset re-adding failed")
+class TestProjectChanging(TestCase):
+
+ def testAudio(self):
+ project = _createRealProject(name="noname")
+ project.audiochannels = 2
+ self.assertEqual(2, project.audiochannels)
+ project.audiorate = 44100
+ self.assertEqual(44100, project.audiorate)
+
+ def testVideo(self):
+ project = _createRealProject(name="noname")
+ project.videowidth = 1920
+ self.assertEqual(1920, project.videowidth)
+ project.videoheight = 1080
+ self.assertEqual(1080, project.videoheight)
+ project.videorate = Gst.Fraction(50, 7)
+ self.assertEqual(Gst.Fraction(50, 7), project.videorate)
+ project.videopar = Gst.Fraction(2, 7)
+ self.assertEqual(Gst.Fraction(2, 7), project.videopar)
+
+
class TestExportSettings(TestCase):
"""Test the project.MultimediaSettings class."""
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]