jdahlin - in flumotion/trunk: . flumotion/component/encoders flumotion/component/encoders/jpeg flumotion/component/encoders/smoke flumotion/component/encoders/speex flumotion/component/encoders/theora flumotion/component/encoders/vorbis

flumotion-commit at lists.fluendo.com flumotion-commit at lists.fluendo.com
Fri Dec 21 14:05:07 CET 2007


Author: jdahlin
Date: Fri Dec 21 14:03:27 2007
New Revision: 6029

Added:
   flumotion/trunk/flumotion/component/encoders/base.xml
   flumotion/trunk/flumotion/component/encoders/encodingprofile.py
   flumotion/trunk/flumotion/component/encoders/encodingwizardplugin.py
   flumotion/trunk/flumotion/component/encoders/jpeg/jpeg_wizard.py
   flumotion/trunk/flumotion/component/encoders/smoke/smoke_wizard.py
   flumotion/trunk/flumotion/component/encoders/speex/speex_wizard.py
   flumotion/trunk/flumotion/component/encoders/theora/theora_wizard.py
   flumotion/trunk/flumotion/component/encoders/vorbis/vorbis_wizard.py
Modified:
   flumotion/trunk/ChangeLog
   flumotion/trunk/flumotion/component/encoders/Makefile.am
   flumotion/trunk/flumotion/component/encoders/jpeg/jpeg.xml
   flumotion/trunk/flumotion/component/encoders/smoke/smoke.xml
   flumotion/trunk/flumotion/component/encoders/speex/speex.xml
   flumotion/trunk/flumotion/component/encoders/theora/theora.xml
   flumotion/trunk/flumotion/component/encoders/vorbis/vorbis.xml
Log:
2007-12-21  Johan Dahlin  <johan at gnome.org>

	* flumotion/component/encoders/*: 

	Add encoding profiles and encoding wizard plugins, 
	part of bug 812.



Modified: flumotion/trunk/ChangeLog
==============================================================================
--- flumotion/trunk/ChangeLog	(original)
+++ flumotion/trunk/ChangeLog	Fri Dec 21 14:03:27 2007
@@ -1,5 +1,12 @@
 2007-12-21  Johan Dahlin  <johan at gnome.org>
 
+	* flumotion/component/encoders/*: 
+
+	Add encoding profiles and encoding wizard plugins, 
+	part of bug 812.
+	
+2007-12-21  Johan Dahlin  <johan at gnome.org>
+
 	* flumotion/admin/text/connection.py (connected): Remove e,
 	should make pychecker happy.
 

Modified: flumotion/trunk/flumotion/component/encoders/Makefile.am
==============================================================================
--- flumotion/trunk/flumotion/component/encoders/Makefile.am	(original)
+++ flumotion/trunk/flumotion/component/encoders/Makefile.am	Fri Dec 21 14:03:27 2007
@@ -3,11 +3,16 @@
 componentdir = $(libdir)/flumotion/python/flumotion/component/encoders
 component_PYTHON = \
 	__init__.py
+component_DATA = \
+	base.xml \
+	encodingprofile.py \
+	encodingwizardplugin.py
 
 jpegdir = $(componentdir)/jpeg
 jpeg_PYTHON = \
 	jpeg/__init__.py \
 	jpeg/jpeg.py
+	jpeg/jpeg_wizard.py
 jpeg_DATA = \
 	jpeg/jpeg.xml
 
@@ -22,6 +27,7 @@
 smoke_PYTHON = \
 	smoke/__init__.py \
 	smoke/smoke.py
+	smoke/smoke_wizard.py
 smoke_DATA = \
 	smoke/smoke.xml
 
@@ -29,6 +35,7 @@
 speex_PYTHON = \
 	speex/__init__.py \
 	speex/speex.py
+	speex/speex_wizard.py
 speex_DATA = \
 	speex/speex.xml
 
@@ -36,6 +43,7 @@
 theora_PYTHON = \
 	theora/__init__.py \
 	theora/theora.py
+	theora/theora_wizard.py
 theora_DATA = \
 	theora/theora.xml
 
@@ -45,6 +53,7 @@
 	vorbis/vorbis.py \
 	vorbis/vorbisutils.py \
 	vorbis/vorbis010.py
+	vorbis/vorbis_wizard.py \
 vorbis_DATA = \
 	vorbis/vorbis.xml
 

Added: flumotion/trunk/flumotion/component/encoders/base.xml
==============================================================================
--- (empty file)
+++ flumotion/trunk/flumotion/component/encoders/base.xml	Fri Dec 21 14:03:27 2007
@@ -0,0 +1,15 @@
+<registry>
+  <bundles>
+    <bundle name="encoding-wizard">
+      <dependencies>
+        <dependency name="flumotion" />
+      </dependencies>
+      <directories>
+        <directory name="flumotion/component/encoders">
+          <filename location="encodingprofile.py" />
+          <filename location="encodingwizardplugin.py" />
+        </directory>
+      </directories>
+    </bundle>
+  </bundles>
+</registry> 

Added: flumotion/trunk/flumotion/component/encoders/encodingprofile.py
==============================================================================
--- (empty file)
+++ flumotion/trunk/flumotion/component/encoders/encodingprofile.py	Fri Dec 21 14:03:27 2007
@@ -0,0 +1,79 @@
+# -*- Mode: Python -*-
+# vi:si:et:sw=4:sts=4:ts=4
+#
+# Flumotion - a streaming media server
+# Copyright (C) 2004,2005,2006,2007 Fluendo, S.L. (www.fluendo.com).
+# All rights reserved.
+
+# This file may be distributed and/or modified under the terms of
+# the GNU General Public License version 2 as published by
+# the Free Software Foundation.
+# This file is distributed without any warranty; without even the implied
+# warranty of merchantability or fitness for a particular purpose.
+# See "LICENSE.GPL" in the source distribution for more information.
+
+# Licensees having purchased or holding a valid Flumotion Advanced
+# Streaming Server license may use this file in accordance with the
+# Flumotion Advanced Streaming Server Commercial License Agreement.
+# See "LICENSE.Flumotion" in the source distribution for more information.
+
+# Headers in this file shall remain intact.
+
+__version__ = "$Rev: 5969 $"
+
+import gettext
+
+_ = gettext.gettext
+
+
+class Property(object):
+    """
+    I am an object representing a component property.
+    I can be used to construct a user interface based, which
+    is done in the encoder part of the wizard
+
+    @ivar name: name
+    @ivar nick: description of the property
+    @ivar default: default value
+    @ivar datatype: the python data type of the property
+    """
+    def __init__(self, name, nick, default, datatype):
+        self.name = name
+        self.nick = nick
+        self.default = default
+        self.datatype = datatype
+
+    def save(self, value):
+        """
+        This is used to be able to override the value which is going to be
+        saved in the configuration xml when saving a property from the wizard.
+        @param value: value displayed in the wizard
+        @returns: value to be written in the configuration
+        """
+        return value
+
+
+class Int(Property):
+    """
+    I am an integer property
+    """
+    def __init__(self, name, nick, default, minimum, maximum, **kwargs):
+        Property.__init__(self, name, nick, default, datatype=int, **kwargs)
+        self.minimum = minimum
+        self.maximum = maximum
+
+
+class Profile(object):
+    """
+    @ivar name: the name of the profile
+    @type name: string
+    @ivar isdefault: if this is the prefered profile
+    @type isdefault: bool
+    @ivar properties: element properties this profile represents
+    @type properties: dict name -> string value
+    """
+
+    def __init__(self, name, isdefault=False, properties=None):
+        self.name = name
+        self.isdefault = isdefault
+        self.properties = properties or {}

Added: flumotion/trunk/flumotion/component/encoders/encodingwizardplugin.py
==============================================================================
--- (empty file)
+++ flumotion/trunk/flumotion/component/encoders/encodingwizardplugin.py	Fri Dec 21 14:03:27 2007
@@ -0,0 +1,133 @@
+# -*- Mode: Python -*-
+# vi:si:et:sw=4:sts=4:ts=4
+#
+# Flumotion - a streaming media server
+# Copyright (C) 2004,2005,2006,2007 Fluendo, S.L. (www.fluendo.com).
+# All rights reserved.
+
+# This file may be distributed and/or modified under the terms of
+# the GNU General Public License version 2 as published by
+# the Free Software Foundation.
+# This file is distributed without any warranty; without even the implied
+# warranty of merchantability or fitness for a particular purpose.
+# See "LICENSE.GPL" in the source distribution for more information.
+
+# Licensees having purchased or holding a valid Flumotion Advanced
+# Streaming Server license may use this file in accordance with the
+# Flumotion Advanced Streaming Server Commercial License Agreement.
+# See "LICENSE.Flumotion" in the source distribution for more information.
+
+# Headers in this file shall remain intact.
+
+__version__ = "$Rev: 5969 $"
+
+from flumotion.component.encoders.encodingprofile import Profile
+
+
+class EncodingWizardPlugin(object):
+    """
+    I am a base class used to write encoding plugins which
+    are going to diplay profiles and user configurable values
+    in the wizard
+    @ivar wizard: the wizard
+    @type wizard: L{flumotion.wizard.configurationwizard.ConfigurationWizard}
+    """
+    def __init__(self, wizard):
+        """
+        Creates a new encoding wizard plugin
+        @param wizard: the wizard
+        @type wizard: L{flumotion.wizard.configurationwizard.ConfigurationWizard}
+        """
+        self._profiles = self._create_profiles()
+        self.wizard = wizard
+
+    def _create_profiles(self):
+        profiles = []
+        for args in self.get_profile_presets():
+            profiles.append(self.create_profile(*args))
+        return profiles
+
+    # Public API
+
+    def get_default_profile(self):
+        """
+        Fetch the default profile.
+        @returns: the default profile
+        @rtype: L{flumotion.component.encoders.encodingprofile.Profile} list
+        """
+        for p in self._profiles:
+            if p.isdefault:
+                return p
+        raise AssertionError("No default profile")
+
+    def get_profiles(self):
+        """
+        Fetches the encoding profiles for the plugin.
+        @returns: available profiles
+        @rtype: L{flumotion.component.encoders.encodingprofile.Profile} list
+        """
+        return self._profiles
+
+    # Overridable in subclasses
+
+    def get_profile_presets(self):
+        """
+        This is called to get a list of values which should be used to create
+        the profiles.
+        For instance::
+
+          def get_profile_presets(self):
+              return [
+                  (_('Default'), 96, True),
+                  (_('Best'), 1024, False)
+                  ]
+
+        @returns: the profile presets
+        @rtype: a list of (name, bitrate, isdefault) tuples
+        """
+        raise NotImplementedError
+
+    def create_profile(self, name, bitrate, isdefault):
+        """
+        Creates a new profile based upon the values set
+        in get_profile_presets().
+        This can be overriden in a subclass if values apart
+        from bitrate should be included in a profile.
+
+        @param name: name of the profile
+        @param bitrate: the bitrate of the profile
+        @param isdefault: if this profile should be the default
+        @returns: a newly created profile
+        @rtype: L{flumotion.component.encoders.encodingprofile.Profile}
+        """
+        properties = dict(bitrate=bitrate)
+        return Profile(name, isdefault, properties)
+
+    def get_custom_properties(self):
+        """
+        This is called to get a list properties which can be set when
+        the user select the custom profile option
+        @returns: a list of properties
+        @rtype: L{flumotion.component.encoders.encodingprofile.Property} list
+        """
+        raise NotImplementedError
+
+    def get_custom_property_columns(self):
+        """
+        This is called to find out how many columns the properties
+        should be displayed in.
+        Default is 2, but some plugins with short or long property labels
+        want to change this.
+        @returns: the number of custom property columns
+        @rtype: int
+        """
+        return 2
+
+    def worker_changed(self, worker):
+        """
+        This is called when the wizard changes the worker
+        for the step.
+        Component and Gstreamer Element checks are usually done here.
+        @param worker: the current worker
+        @rtype worker:
+        """

Modified: flumotion/trunk/flumotion/component/encoders/jpeg/jpeg.xml
==============================================================================
--- flumotion/trunk/flumotion/component/encoders/jpeg/jpeg.xml	(original)
+++ flumotion/trunk/flumotion/component/encoders/jpeg/jpeg.xml	Fri Dec 21 14:03:27 2007
@@ -10,6 +10,8 @@
       <entries>
         <entry type="component" location="jpeg.py"
                function="JPEG" />
+        <entry type="wizard" location="jpeg_wizard.py"
+               function="JPEGWizardPlugin" />
       </entries>
       <properties>
         <property name="quality" type="int"
@@ -46,6 +48,21 @@
                 <filename location="jpeg.py" />
             </directory>
         </directories>
+
+    </bundle>
+
+    <bundle name="jpeg-wizard">
+        <dependencies>
+            <dependency name="component" />
+            <dependency name="jpeg-base" />
+            <dependency name="encoding-wizard" />
+        </dependencies>
+
+        <directories>
+            <directory name="flumotion/component/encoders/jpeg">
+                <filename location="jpeg_wizard.py" />
+            </directory>
+        </directories>
     </bundle>
 
   </bundles>

Added: flumotion/trunk/flumotion/component/encoders/jpeg/jpeg_wizard.py
==============================================================================
--- (empty file)
+++ flumotion/trunk/flumotion/component/encoders/jpeg/jpeg_wizard.py	Fri Dec 21 14:03:27 2007
@@ -0,0 +1,69 @@
+# -*- Mode: Python -*-
+# vi:si:et:sw=4:sts=4:ts=4
+#
+# Flumotion - a streaming media server
+# Copyright (C) 2004,2005,2006,2007 Fluendo, S.L. (www.fluendo.com).
+# All rights reserved.
+
+# This file may be distributed and/or modified under the terms of
+# the GNU General Public License version 2 as published by
+# the Free Software Foundation.
+# This file is distributed without any warranty; without even the implied
+# warranty of merchantability or fitness for a particular purpose.
+# See "LICENSE.GPL" in the source distribution for more information.
+
+# Licensees having purchased or holding a valid Flumotion Advanced
+# Streaming Server license may use this file in accordance with the
+# Flumotion Advanced Streaming Server Commercial License Agreement.
+# See "LICENSE.Flumotion" in the source distribution for more information.
+
+# Headers in this file shall remain intact.
+
+__version__ = "$Rev: 5969 $"
+
+import gettext
+
+from flumotion.component.encoders.encodingprofile import Profile, Int
+from flumotion.component.encoders.encodingwizardplugin import \
+     EncodingWizardPlugin
+
+_ = gettext.gettext
+
+def _fraction_from_float(number, denominator):
+    """
+    Return a string to be used in serializing to XML.
+    """
+    return "%d/%d" % (number * denominator, denominator)
+
+
+class Framerate(Int):
+    def save(self, value):
+        # save as fraction
+        return _fraction_from_float(value, 2)
+
+
+class JPEGWizardPlugin(EncodingWizardPlugin):
+    def get_profile_presets(self):
+        return [(_("0 (largest)"), 0, False),
+                (_("20"), 20, False),
+                (_("40"), 40, False),
+                (_("60"), 60, False),
+                (_("85 (default)"), 85, True),
+                (_("95"), 95, False),
+                (_("100 (smallest)"), 100, False)]
+
+    def create_profile(self, name, quality, isdefault):
+        properties = dict(quality=quality)
+
+        return Profile(name, isdefault, properties)
+
+    def get_custom_properties(self):
+        return [
+            Int("quality",_("Quality"),
+                85, 0, 100),
+            Framerate("framerate",_("Framerate"),
+                      5, 0.01, 100),
+            ]
+
+    def worker_changed(self, worker):
+        self.wizard.require_elements(self.worker, 'jpegenc')

Modified: flumotion/trunk/flumotion/component/encoders/smoke/smoke.xml
==============================================================================
--- flumotion/trunk/flumotion/component/encoders/smoke/smoke.xml	(original)
+++ flumotion/trunk/flumotion/component/encoders/smoke/smoke.xml	Fri Dec 21 14:03:27 2007
@@ -10,6 +10,8 @@
       <entries>
         <entry type="component" location="smoke.py"
                function="Smoke" />
+        <entry type="wizard" location="smoke_wizard.py"
+               function="SmokeWizardPlugin" />
       </entries>
       <properties>
         <property name="qmin" type="int"
@@ -52,6 +54,20 @@
         </directories>
     </bundle>
 
+    <bundle name="smoke-wizard">
+        <dependencies>
+            <dependency name="component" />
+            <dependency name="smoke-base" />
+            <dependency name="encoding-wizard" />
+        </dependencies>
+
+        <directories>
+            <directory name="flumotion/component/encoders/smoke">
+                <filename location="smoke_wizard.py" />
+            </directory>
+        </directories>
+    </bundle>
+
   </bundles>
 
 </registry> 

Added: flumotion/trunk/flumotion/component/encoders/smoke/smoke_wizard.py
==============================================================================
--- (empty file)
+++ flumotion/trunk/flumotion/component/encoders/smoke/smoke_wizard.py	Fri Dec 21 14:03:27 2007
@@ -0,0 +1,61 @@
+# -*- Mode: Python -*-
+# vi:si:et:sw=4:sts=4:ts=4
+#
+# Flumotion - a streaming media server
+# Copyright (C) 2004,2005,2006,2007 Fluendo, S.L. (www.fluendo.com).
+# All rights reserved.
+
+# This file may be distributed and/or modified under the terms of
+# the GNU General Public License version 2 as published by
+# the Free Software Foundation.
+# This file is distributed without any warranty; without even the implied
+# warranty of merchantability or fitness for a particular purpose.
+# See "LICENSE.GPL" in the source distribution for more information.
+
+# Licensees having purchased or holding a valid Flumotion Advanced
+# Streaming Server license may use this file in accordance with the
+# Flumotion Advanced Streaming Server Commercial License Agreement.
+# See "LICENSE.Flumotion" in the source distribution for more information.
+
+# Headers in this file shall remain intact.
+
+__version__ = "$Rev: 5969 $"
+
+import gettext
+
+from flumotion.component.encoders.encodingprofile import Profile, Int
+from flumotion.component.encoders.encodingwizardplugin import \
+     EncodingWizardPlugin
+
+_ = gettext.gettext
+
+class SmokeWizardPlugin(EncodingWizardPlugin):
+    def get_profile_presets(self):
+        return [(_("Default"), None, True)]
+
+    def create_profile(self, name, unused, isdefault):
+        properties = dict(qmin=10,
+                          qmax=85,
+                          threshold=300,
+                          keyframe=20)
+
+        return Profile(name, isdefault, properties)
+
+    def get_custom_properties(self):
+        return [
+            Int("qmin", _("Minimum JPEG quality"),
+                10, 0, 100),
+            Int("qmax",_("Maximum JPEG quality"),
+                85, 0, 100),
+            Int("threshold", _("Motion estimation"),
+                300, 0, 1000000000),
+            Int("keyframe",_("Keyframe interval"),
+                20, 0, 100000),
+        ]
+
+    def worker_changed(self, worker):
+        self.wizard.require_elements(self.worker, 'smokeenc')
+
+    def get_custom_property_columns(self):
+        return 1
+

Modified: flumotion/trunk/flumotion/component/encoders/speex/speex.xml
==============================================================================
--- flumotion/trunk/flumotion/component/encoders/speex/speex.xml	(original)
+++ flumotion/trunk/flumotion/component/encoders/speex/speex.xml	Fri Dec 21 14:03:27 2007
@@ -9,6 +9,8 @@
       <feeder name="default" />
       <entries>
         <entry type="component" location="speex.py" function="Speex" />
+        <entry type="wizard" location="speex_wizard.py"
+               function="SpeexWizardPlugin" />
       </entries>
       <properties>
         <property name="bitrate" type="int"
@@ -45,6 +47,20 @@
         </directories>
     </bundle>
 
+    <bundle name="speex-wizard">
+        <dependencies>
+            <dependency name="component" />
+            <dependency name="speex-base" />
+            <dependency name="encoding-wizard" />
+        </dependencies>
+
+        <directories>
+            <directory name="flumotion/component/encoders/speex">
+                <filename location="speex_wizard.py" />
+            </directory>
+        </directories>
+    </bundle>
+
   </bundles>
 
 </registry> 

Added: flumotion/trunk/flumotion/component/encoders/speex/speex_wizard.py
==============================================================================
--- (empty file)
+++ flumotion/trunk/flumotion/component/encoders/speex/speex_wizard.py	Fri Dec 21 14:03:27 2007
@@ -0,0 +1,44 @@
+# -*- Mode: Python -*-
+# vi:si:et:sw=4:sts=4:ts=4
+#
+# Flumotion - a streaming media server
+# Copyright (C) 2004,2005,2006,2007 Fluendo, S.L. (www.fluendo.com).
+# All rights reserved.
+
+# This file may be distributed and/or modified under the terms of
+# the GNU General Public License version 2 as published by
+# the Free Software Foundation.
+# This file is distributed without any warranty; without even the implied
+# warranty of merchantability or fitness for a particular purpose.
+# See "LICENSE.GPL" in the source distribution for more information.
+
+# Licensees having purchased or holding a valid Flumotion Advanced
+# Streaming Server license may use this file in accordance with the
+# Flumotion Advanced Streaming Server Commercial License Agreement.
+# See "LICENSE.Flumotion" in the source distribution for more information.
+
+# Headers in this file shall remain intact.
+
+__version__ = "$Rev: 5969 $"
+
+import gettext
+
+from flumotion.component.encoders.encodingprofile import Int
+from flumotion.component.encoders.encodingwizardplugin import \
+     EncodingWizardPlugin
+
+_ = gettext.gettext
+
+class SpeexWizardPlugin(EncodingWizardPlugin):
+    def get_profile_presets(self):
+        return [(_("11? (default)"), 11, True),
+                ]
+
+    def get_custom_properties(self):
+        return [
+            Int("bitrate", _("Bitrate"),
+                11, 3, 30),
+            ]
+
+    def worker_changed(self, worker):
+        self.wizard.require_elements(worker, 'speexenc2')

Modified: flumotion/trunk/flumotion/component/encoders/theora/theora.xml
==============================================================================
--- flumotion/trunk/flumotion/component/encoders/theora/theora.xml	(original)
+++ flumotion/trunk/flumotion/component/encoders/theora/theora.xml	Fri Dec 21 14:03:27 2007
@@ -10,7 +10,10 @@
       <entries>
         <entry type="component" location="theora.py"
                function="Theora"/>
+        <entry type="wizard" location="theora_wizard.py"
+               function="TheoraWizardPlugin" />
       </entries>
+
       <properties>
         <property name="bitrate" type="int"
                   description="Bitrate to encode at (in bps)" />
@@ -59,6 +62,20 @@
         </directories>
     </bundle>
 
+    <bundle name="theora-wizard">
+        <dependencies>
+            <dependency name="component" />
+            <dependency name="theora-base" />
+            <dependency name="encoding-wizard" />
+        </dependencies>
+
+        <directories>
+            <directory name="flumotion/component/encoders/theora">
+                <filename location="theora_wizard.py" />
+            </directory>
+        </directories>
+    </bundle>
+
   </bundles>
 
 </registry> 

Added: flumotion/trunk/flumotion/component/encoders/theora/theora_wizard.py
==============================================================================
--- (empty file)
+++ flumotion/trunk/flumotion/component/encoders/theora/theora_wizard.py	Fri Dec 21 14:03:27 2007
@@ -0,0 +1,86 @@
+# -*- Mode: Python -*-
+# vi:si:et:sw=4:sts=4:ts=4
+#
+# Flumotion - a streaming media server
+# Copyright (C) 2004,2005,2006,2007 Fluendo, S.L. (www.fluendo.com).
+# All rights reserved.
+
+# This file may be distributed and/or modified under the terms of
+# the GNU General Public License version 2 as published by
+# the Free Software Foundation.
+# This file is distributed without any warranty; without even the implied
+# warranty of merchantability or fitness for a particular purpose.
+# See "LICENSE.GPL" in the source distribution for more information.
+
+# Licensees having purchased or holding a valid Flumotion Advanced
+# Streaming Server license may use this file in accordance with the
+# Flumotion Advanced Streaming Server Commercial License Agreement.
+# See "LICENSE.Flumotion" in the source distribution for more information.
+
+# Headers in this file shall remain intact.
+
+__version__ = "$Rev: 5969 $"
+
+import gettext
+
+from flumotion.component.encoders.encodingprofile import Profile, Int
+from flumotion.component.encoders.encodingwizardplugin import \
+     EncodingWizardPlugin
+
+_ = gettext.gettext
+
+
+class Bitrate(Int):
+    def save(self, value):
+        # kbps -> bps
+        return value * 1000
+
+
+class NoiseSensitivty(Int):
+    def save(self, value):
+        # percentage -> [0..32768]
+        return int(value * (32768 / 100.0))
+
+
+class TheoraWizardPlugin(EncodingWizardPlugin):
+    def get_profile_presets(self):
+        return [(_("64 kbps (worst)"), 64, False),
+                (_("100 kbps"), 100, False),
+                (_("200 kbps"), 200, False),
+                (_("400 kbps (default)"), 400, True),
+                (_("700 kbps"), 700, False),
+                (_("900 kbps"), 900, False),
+                (_("1200 kbps (best)"), 1200, False)]
+
+    def create_profile(self, name, bitrate, isdefault):
+        properties = dict(bitrate=bitrate,
+                          keyframe_maxdistance=64,
+                          noise_sensitivity=0,
+                          sharpness=0)
+
+        return Profile(name, isdefault, properties)
+
+    def get_custom_properties(self):
+        return [
+            Bitrate("bitrate", _("Bitrate"),
+                    400, 0, 4000),
+            #Int("quality",_("Quality"),
+            #    16, 0, 63),
+            Int("keyframe_maxdistance",_("Keyframe max distance"),
+                64, 1, 32768),
+            NoiseSensitivty("noise_sensitivity", _("Noise sensitivity"),
+                            0, 0, 100),
+            Int("sharpness", _("Sharpness"),
+                0, 0, 2),
+            ]
+
+    def worker_changed(self, worker):
+        self.wizard.debug('running Theora checks')
+
+        def hasTheora(unused):
+            self.wizard.run_in_worker(
+                worker, 'flumotion.worker.checks.encoder', 'checkTheora')
+
+        d = self.wizard.require_elements(worker, 'theoraenc')
+        d.addCallback(hasTheora)
+

Modified: flumotion/trunk/flumotion/component/encoders/vorbis/vorbis.xml
==============================================================================
--- flumotion/trunk/flumotion/component/encoders/vorbis/vorbis.xml	(original)
+++ flumotion/trunk/flumotion/component/encoders/vorbis/vorbis.xml	Fri Dec 21 14:03:27 2007
@@ -14,6 +14,8 @@
       <entries>
         <entry type="component" location="vorbis.py"
                function="Vorbis"/>
+        <entry type="wizard" location="vorbis_wizard.py"
+               function="VorbisWizardPlugin" />
       </entries>
     </component>
  
@@ -49,6 +51,20 @@
         </directories>
     </bundle>
 
+    <bundle name="vorbis-wizard">
+        <dependencies>
+            <dependency name="component" />
+            <dependency name="vorbis-base" />
+            <dependency name="encoding-wizard" />
+        </dependencies>
+
+        <directories>
+            <directory name="flumotion/component/encoders/vorbis">
+                <filename location="vorbis_wizard.py" />
+            </directory>
+        </directories>
+    </bundle>
+
   </bundles>
 
 </registry> 

Added: flumotion/trunk/flumotion/component/encoders/vorbis/vorbis_wizard.py
==============================================================================
--- (empty file)
+++ flumotion/trunk/flumotion/component/encoders/vorbis/vorbis_wizard.py	Fri Dec 21 14:03:27 2007
@@ -0,0 +1,63 @@
+# -*- Mode: Python -*-
+# vi:si:et:sw=4:sts=4:ts=4
+#
+# Flumotion - a streaming media server
+# Copyright (C) 2004,2005,2006,2007 Fluendo, S.L. (www.fluendo.com).
+# All rights reserved.
+
+# This file may be distributed and/or modified under the terms of
+# the GNU General Public License version 2 as published by
+# the Free Software Foundation.
+# This file is distributed without any warranty; without even the implied
+# warranty of merchantability or fitness for a particular purpose.
+# See "LICENSE.GPL" in the source distribution for more information.
+
+# Licensees having purchased or holding a valid Flumotion Advanced
+# Streaming Server license may use this file in accordance with the
+# Flumotion Advanced Streaming Server Commercial License Agreement.
+# See "LICENSE.Flumotion" in the source distribution for more information.
+
+# Headers in this file shall remain intact.
+
+__version__ = "$Rev: 5969 $"
+
+import gettext
+
+from flumotion.component.encoders.encodingprofile import Int
+from flumotion.component.encoders.encodingwizardplugin import \
+     EncodingWizardPlugin
+
+_ = gettext.gettext
+
+class Bitrate(Int):
+    def save(self, value):
+        # kbps -> bps
+        return value * 1000
+
+
+class VorbisWizardPlugin(EncodingWizardPlugin):
+    def get_profile_presets(self):
+        return [(_("24 kbps (worst)"), 32, False),
+                (_("32 kbps"), 32, False),
+                (_("48 kbps"), 48, False),
+                (_("64 kbps (default)"), 64, True),
+                (_("96 kbps"), 96, False),
+                (_("128 kbps"), 128, False),
+                (_("144 kbps"), 144, False),
+                (_("192 kbps (best)"), 192, False),
+                ]
+
+    def get_custom_properties(self):
+        return [
+            Bitrate("bitrate", _("Bitrate"),
+                64, 6, 250),
+            ]
+
+    def worker_changed(self, worker):
+        self.wizard.debug('running Vorbis checks')
+        def hasVorbis(unused):
+            self.wizard.run_in_worker(
+                worker, 'flumotion.worker.checks.encoder', 'checkVorbis')
+
+        d = self.wizard.require_elements(worker, 'vorbisenc')
+        d.addCallback(hasVorbis)


More information about the flumotion-commit mailing list