diff --git a/src/freeseer/plugins/videomixer/videopassthrough/__init__.py b/src/freeseer/plugins/videomixer/videopassthrough/__init__.py index 8597af56..e90a01d4 100644 --- a/src/freeseer/plugins/videomixer/videopassthrough/__init__.py +++ b/src/freeseer/plugins/videomixer/videopassthrough/__init__.py @@ -34,6 +34,7 @@ import pygst pygst.require("0.10") import gst +import logging # PyQt modules from PyQt4.QtCore import SIGNAL @@ -45,13 +46,15 @@ # .freeseer-plugin custom modules import widget +log = logging.getLogger(__name__) + class VideoPassthroughConfig(Config): """Configuration class for VideoPassthrough plugin.""" input = options.StringOption("Video Test Source") input_type = options.StringOption("video/x-raw-rgb") framerate = options.IntegerOption(30) - resolution = options.StringOption("NOSCALE") + resolution = options.ChoiceOption(widget.resmap.keys(), "No Scaling") class VideoPassthrough(IVideoMixer): @@ -78,9 +81,15 @@ def get_videomixer_bin(self): bin.add(videoscale) videoscale_cap = gst.element_factory_make("capsfilter", "videoscale_cap") - if self.config.resolution != "NOSCALE": + + # Change the resolution of the source video. + log.debug("Record Resolution: %s", self.config.resolution) + if self.config.resolution != "No Scaling": + width, height = widget.resmap[self.config.resolution] videoscale_cap.set_property('caps', - gst.caps_from_string('%s, width=640, height=480' % (self.config.input_type))) + gst.caps_from_string("{}, width={}, height={}" + .format(self.config.input_type, width, height))) + bin.add(videoscale_cap) # --- End Video Scaler @@ -127,6 +136,7 @@ def __enable_connections(self): self.widget.connect(self.widget.framerateSlider, SIGNAL("valueChanged(int)"), self.set_framerate) self.widget.connect(self.widget.framerateSpinBox, SIGNAL("valueChanged(int)"), self.set_framerate) self.widget.connect(self.widget.inputSettingsToolButton, SIGNAL('clicked()'), self.source1_setup) + self.widget.connect(self.widget.videoscaleComboBox, SIGNAL("currentIndexChanged(const QString&)"), self.set_videoscale) def widget_load_config(self, plugman): self.load_config(plugman) @@ -149,6 +159,9 @@ def widget_load_config(self, plugman): vcolour_index = self.widget.videocolourComboBox.findText(self.config.input_type) self.widget.videocolourComboBox.setCurrentIndex(vcolour_index) + vscale_index = self.widget.videoscaleComboBox.findText(self.config.resolution) + self.widget.videoscaleComboBox.setCurrentIndex(vscale_index) + # Need to set both the Slider and Spingbox since connections # are not yet loaded at this point self.widget.framerateSlider.setValue(self.config.framerate) @@ -182,6 +195,10 @@ def set_framerate(self, framerate): self.config.framerate = framerate self.config.save() + def set_videoscale(self, resolution): + self.config.resolution = resolution + self.config.save() + ### ### Translations ### diff --git a/src/freeseer/plugins/videomixer/videopassthrough/widget.py b/src/freeseer/plugins/videomixer/videopassthrough/widget.py index 51d599b7..33915ad2 100644 --- a/src/freeseer/plugins/videomixer/videopassthrough/widget.py +++ b/src/freeseer/plugins/videomixer/videopassthrough/widget.py @@ -26,6 +26,8 @@ @author: Thanh Ha ''' +from collections import OrderedDict + from PyQt4.QtCore import Qt from PyQt4.QtGui import QComboBox from PyQt4.QtGui import QFormLayout @@ -40,6 +42,16 @@ from PyQt4.QtGui import QWidget +resmap = OrderedDict([ + ('No Scaling', (0, 0)), + ('240p', (320, 240)), + ('360p', (480, 360)), + ('480p', (640, 480)), + ('720p', (1280, 720)), + ('1080p', (1920, 1080)), +]) + + class ConfigWidget(QWidget): def __init__(self, parent=None): @@ -87,6 +99,7 @@ def __init__(self, parent=None): self.videoscaleLabel = QLabel("Video Scale") self.videoscaleComboBox = QComboBox() - self.videoscaleComboBox.addItem("NOSCALE") + for scale in resmap: + self.videoscaleComboBox.addItem(scale) self.videoscaleComboBox.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Maximum) layout.addRow(self.videoscaleLabel, self.videoscaleComboBox) diff --git a/src/freeseer/settings.py b/src/freeseer/settings.py index b1db013b..987fc18a 100644 --- a/src/freeseer/settings.py +++ b/src/freeseer/settings.py @@ -39,21 +39,8 @@ class FreeseerConfig(Config): """General Freeseer profile settings.""" - resmap = { - # No Scaling - 'default': '0x0', - - # Scaling - '240p': '320x240', - '360p': '480x360', - '480p': '640x480', - '720p': '1280x720', - '1080p': '1920x1080' - } - videodir = options.FolderOption('~/Videos', auto_create=True) auto_hide = options.BooleanOption(False) - resolution = options.ChoiceOption(resmap.keys(), 'default') enable_audio_recording = options.BooleanOption(True) enable_video_recording = options.BooleanOption(True) videomixer = options.StringOption('Video Passthrough')