Package flumotion :: Package component :: Package encoders :: Package jpeg :: Module wizard_gtk
[hide private]

Source Code for Module flumotion.component.encoders.jpeg.wizard_gtk

 1  # -*- Mode: Python -*- 
 2  # vi:si:et:sw=4:sts=4:ts=4 
 3   
 4  # Flumotion - a streaming media server 
 5  # Copyright (C) 2004,2005,2006,2007,2008,2009 Fluendo, S.L. 
 6  # Copyright (C) 2010,2011 Flumotion Services, S.A. 
 7  # All rights reserved. 
 8  # 
 9  # This file may be distributed and/or modified under the terms of 
10  # the GNU Lesser General Public License version 2.1 as published by 
11  # the Free Software Foundation. 
12  # This file is distributed without any warranty; without even the implied 
13  # warranty of merchantability or fitness for a particular purpose. 
14  # See "LICENSE.LGPL" in the source distribution for more information. 
15  # 
16  # Headers in this file shall remain intact. 
17   
18  import gettext 
19  import os 
20   
21  from zope.interface import implements 
22   
23  from flumotion.admin.assistant.interfaces import IEncoderPlugin 
24  from flumotion.admin.assistant.models import VideoEncoder 
25  from flumotion.admin.gtk.basesteps import VideoEncoderStep 
26   
27  __version__ = "$Rev$" 
28  _ = gettext.gettext 
29   
30   
31 -def _fraction_from_float(number, denominator):
32 """ 33 Return a string to be used in serializing to XML. 34 """ 35 return "%d/%d" % (number * denominator, denominator)
36 37
38 -class JPEGVideoEncoder(VideoEncoder):
39 componentType = 'jpeg-encoder' 40
41 - def __init__(self):
42 super(JPEGVideoEncoder, self).__init__() 43 44 self.properties.framerate = 5.0 45 self.properties.quality = 84
46
47 - def getProperties(self):
48 properties = super(JPEGVideoEncoder, self).getProperties() 49 properties.framerate = _fraction_from_float(properties.framerate, 2) 50 return properties
51 52
53 -class JPEGStep(VideoEncoderStep):
54 name = 'JPEG encoder' 55 title = _('JPEG Encoder') 56 sidebarName = 'JPEG' 57 section = _('Conversion') 58 gladeFile = os.path.join(os.path.dirname(os.path.abspath(__file__)), 59 'wizard.glade') 60 componentType = 'jpeg' 61 docSection = 'help-configuration-assistant-encoder-jpeg' 62 docAnchor = '' 63 docVersion = 'local' 64 65 # WizardStep 66
67 - def setup(self):
68 self.framerate.data_type = float 69 self.quality.data_type = int 70 71 self.add_proxy(self.model.properties, 72 ['framerate', 'quality'])
73
74 - def workerChanged(self, worker):
75 self.model.worker = worker 76 self.wizard.requireElements(worker, 'jpegenc')
77 78
79 -class JPEGWizardPlugin(object):
80 implements(IEncoderPlugin) 81
82 - def __init__(self, wizard):
83 self.wizard = wizard 84 self.model = JPEGVideoEncoder()
85
86 - def getConversionStep(self):
87 return JPEGStep(self.wizard, self.model)
88