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