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

Source Code for Module flumotion.component.encoders.smoke.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 Fluendo, S.L. (www.fluendo.com). 
  6  # All rights reserved. 
  7   
  8  # This file may be distributed and/or modified under the terms of 
  9  # the GNU General Public License version 2 as published by 
 10  # the Free Software Foundation. 
 11  # This file is distributed without any warranty; without even the implied 
 12  # warranty of merchantability or fitness for a particular purpose. 
 13  # See "LICENSE.GPL" in the source distribution for more information. 
 14   
 15  # Licensees having purchased or holding a valid Flumotion Advanced 
 16  # Streaming Server license may use this file in accordance with the 
 17  # Flumotion Advanced Streaming Server Commercial License Agreement. 
 18  # See "LICENSE.Flumotion" in the source distribution for more information. 
 19   
 20  # Headers in this file shall remain intact. 
 21   
 22  import gettext 
 23  import os 
 24   
 25  from zope.interface import implements 
 26   
 27  from flumotion.admin.assistant.interfaces import IEncoderPlugin 
 28  from flumotion.admin.assistant.models import VideoEncoder 
 29  from flumotion.admin.gtk.basesteps import VideoEncoderStep 
 30  from flumotion.common.fraction import fractionAsFloat 
 31   
 32  __version__ = "$Rev$" 
 33  _ = gettext.gettext 
 34   
 35   
36 -class SmokeVideoEncoder(VideoEncoder):
37 componentType = 'smoke-encoder' 38
39 - def __init__(self):
40 super(SmokeVideoEncoder, self).__init__() 41 self.framerate = 25.0 42 self.keyframe_interval = 2.0 43 44 self.properties.qmin = 10 45 self.properties.qmax = 85 46 self.properties.threshold = 3000
47
48 - def getProperties(self):
49 properties = super(SmokeVideoEncoder, self).getProperties() 50 51 properties.keyframe = int(self.framerate * self.keyframe_interval) 52 53 return properties
54 55
56 -class SmokeStep(VideoEncoderStep):
57 name = 'SmokeEncoder' 58 title = _('Smoke Encoder') 59 sidebarName = _('Smoke') 60 section = _('Conversion') 61 gladeFile = os.path.join(os.path.dirname(os.path.abspath(__file__)), 62 'wizard.glade') 63 componentType = 'smoke' 64 docSection = 'help-configuration-assistant-encoder-smoke' 65 docAnchor = '' 66 docVersion = 'local' 67 68 # WizardStep 69
70 - def setup(self):
71 self.qmin.data_type = int 72 self.qmax.data_type = int 73 self.threshold.data_type = int 74 self.keyframe_interval.data_type = float 75 76 producer = self.wizard.getScenario().getVideoProducer(self.wizard) 77 self.model.framerate = fractionAsFloat(producer.getFramerate()) 78 self.model.keyframe_interval = 20 / self.model.framerate 79 80 self.add_proxy(self.model.properties, 81 ['qmin', 'qmax', 'threshold']) 82 self.add_proxy(self.model, ['keyframe_interval']) 83 84 step = 1 / self.model.framerate 85 page = 1.0 86 self.keyframe_interval.set_increments(step, page)
87
88 - def workerChanged(self, worker):
89 self.model.worker = worker 90 self.wizard.requireElements(worker, 'smokeenc')
91 92
93 -class SmokeWizardPlugin(object):
94 implements(IEncoderPlugin) 95
96 - def __init__(self, wizard):
97 self.wizard = wizard 98 self.model = SmokeVideoEncoder()
99
100 - def getConversionStep(self):
101 return SmokeStep(self.wizard, self.model)
102