Package flumotion :: Package component :: Package producers :: Package bttv :: Module wizard_gtk
[hide private]

Source Code for Module flumotion.component.producers.bttv.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  # NOTE: 
 19  # v4l talks about "signal" (PAL/...) and "channel" (TV/Composite/...) 
 20  # and frequency 
 21  # gst talks about "norm" and "channel" 
 22  # and frequency 
 23  # apps (and flumotion) talk about "TV Norm" and "source", 
 24  # and channel (corresponding to frequency) 
 25   
 26  import gettext 
 27  import os 
 28   
 29  from zope.interface import implements 
 30   
 31  from flumotion.admin.assistant.interfaces import IProducerPlugin 
 32  from flumotion.admin.assistant.models import VideoProducer 
 33  from flumotion.common import errors 
 34  from flumotion.common.i18n import N_, gettexter 
 35  from flumotion.common.messages import Info 
 36  from flumotion.admin.gtk.basesteps import VideoProducerStep 
 37   
 38  __version__ = "$Rev$" 
 39  _ = gettext.gettext 
 40  T_ = gettexter() 
 41   
 42   
43 -class TVCardProducer(VideoProducer):
44 componentType = 'tvcard-producer' 45
46 - def __init__(self):
47 super(TVCardProducer, self).__init__() 48 49 self.properties.device = '/dev/video0' 50 self.properties.signal = '' 51 self.properties.channel = ''
52 53
54 -class TVCardStep(VideoProducerStep):
55 name = 'TVCard' 56 title = _('TV Card') 57 icon = 'tv.png' 58 gladeFile = os.path.join(os.path.dirname(os.path.abspath(__file__)), 59 'wizard.glade') 60 componentType = 'bttv' 61 docSection = 'help-configuration-assistant-producer-video-tvcard' 62 docAnchor = '' 63 docVersion = 'local' 64
65 - def __init__(self, wizard, model):
66 VideoProducerStep.__init__(self, wizard, model) 67 self._inSetup = False
68 69 # WizardStep 70
71 - def setup(self):
72 self._inSetup = True 73 74 self.device.data_type = str 75 self.width.data_type = int 76 self.height.data_type = int 77 self.framerate.data_type = float 78 self.channel.data_type = str 79 self.signal.data_type = str 80 81 self.channel.prefill(['']) 82 self.signal.prefill(['']) 83 self.device.prefill(['/dev/video0', 84 '/dev/video1', 85 '/dev/video2', 86 '/dev/video3']) 87 88 self.add_proxy(self.model.properties, 89 ['device', 'height', 'width', 90 'framerate', 'signal', 'channel']) 91 92 self._inSetup = False
93
94 - def workerChanged(self, worker):
95 self.model.worker = worker 96 self._clearCombos() 97 self._runChecks()
98 99 # Private 100
101 - def _clearCombos(self):
102 self.channel.clear() 103 self.channel.set_sensitive(False) 104 self.signal.clear() 105 self.signal.set_sensitive(False)
106
107 - def _runChecks(self):
108 if self._inSetup: 109 return None 110 111 self.wizard.waitForTask('bttv checks') 112 113 device = self.device.get_selected() 114 assert device 115 msg = Info(T_( 116 N_("Probing the TV card. This can take a while...")), 117 mid='tvcard-check') 118 self.wizard.add_msg(msg) 119 d = self.runInWorker('flumotion.worker.checks.video', 'checkTVCard', 120 device, mid='tvcard-check') 121 122 def errRemoteRunFailure(failure): 123 failure.trap(errors.RemoteRunFailure) 124 self.debug('a RemoteRunFailure happened') 125 self._clearCombos() 126 self.wizard.taskFinished(True)
127 128 def errRemoteRunError(failure): 129 failure.trap(errors.RemoteRunError) 130 self.debug('a RemoteRunError happened') 131 self._clearCombos() 132 self.wizard.taskFinished(True)
133 134 def deviceFound(result): 135 if not result: 136 self._clearCombos() 137 self.wizard.taskFinished(True) 138 return None 139 140 deviceName, channels, signals = result 141 self.wizard.clear_msg('tvcard-check') 142 self.channel.prefill(channels) 143 self.channel.set_sensitive(True) 144 self.signal.prefill(signals) 145 self.signal.set_sensitive(True) 146 self.wizard.taskFinished() 147 148 d.addCallback(deviceFound) 149 d.addErrback(errRemoteRunFailure) 150 d.addErrback(errRemoteRunError) 151 152 # Callbacks 153
154 - def on_device__changed(self, combo):
155 self._runChecks()
156 157
158 -class BTTVWizardPlugin(object):
159 implements(IProducerPlugin) 160
161 - def __init__(self, wizard):
162 self.wizard = wizard 163 self.model = TVCardProducer()
164
165 - def getProductionStep(self, type):
166 return TVCardStep(self.wizard, self.model)
167