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.admin.assistant.interfaces import IProducerPlugin 
 37  from flumotion.admin.assistant.models import VideoProducer 
 38  from flumotion.common import errors 
 39  from flumotion.common.i18n import N_, gettexter 
 40  from flumotion.common.messages import Info 
 41  from flumotion.admin.gtk.basesteps import VideoProducerStep 
 42   
 43  __version__ = "$Rev: 7267 $" 
 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 docSection = 'help-configuration-assistant-producer-video-tvcard' 67 docAnchor = '' 68 docVersion = 'local' 69
70 - def __init__(self, wizard, model):
71 VideoProducerStep.__init__(self, wizard, model) 72 self._inSetup = False
73 74 # WizardStep 75
76 - def setup(self):
77 self._inSetup = True 78 79 self.device.data_type = str 80 self.width.data_type = int 81 self.height.data_type = int 82 self.framerate.data_type = float 83 self.channel.data_type = str 84 self.signal.data_type = str 85 86 self.channel.prefill(['']) 87 self.signal.prefill(['']) 88 self.device.prefill(['/dev/video0', 89 '/dev/video1', 90 '/dev/video2', 91 '/dev/video3']) 92 93 self.add_proxy(self.model.properties, 94 ['device', 'height', 'width', 95 'framerate', 'signal', 'channel']) 96 97 self._inSetup = False
98
99 - def workerChanged(self, worker):
100 self.model.worker = worker 101 self._clearCombos() 102 self._runChecks()
103 104 # Private 105
106 - def _clearCombos(self):
107 self.channel.clear() 108 self.channel.set_sensitive(False) 109 self.signal.clear() 110 self.signal.set_sensitive(False)
111
112 - def _runChecks(self):
113 if self._inSetup: 114 return None 115 116 self.wizard.waitForTask('bttv checks') 117 118 device = self.device.get_selected() 119 assert device 120 msg = Info(T_( 121 N_("Probing the TV card. This can take a while...")), 122 mid='tvcard-check') 123 self.wizard.add_msg(msg) 124 d = self.runInWorker('flumotion.worker.checks.video', 'checkTVCard', 125 device, mid='tvcard-check') 126 127 def errRemoteRunFailure(failure): 128 failure.trap(errors.RemoteRunFailure) 129 self.debug('a RemoteRunFailure happened') 130 self._clearCombos() 131 self.wizard.taskFinished(True)
132 133 def errRemoteRunError(failure): 134 failure.trap(errors.RemoteRunError) 135 self.debug('a RemoteRunError happened') 136 self._clearCombos() 137 self.wizard.taskFinished(True)
138 139 def deviceFound(result): 140 if not result: 141 self._clearCombos() 142 self.wizard.taskFinished(True) 143 return None 144 145 deviceName, channels, signals = result 146 self.wizard.clear_msg('tvcard-check') 147 self.channel.prefill(channels) 148 self.channel.set_sensitive(True) 149 self.signal.prefill(signals) 150 self.signal.set_sensitive(True) 151 self.wizard.taskFinished() 152 153 d.addCallback(deviceFound) 154 d.addErrback(errRemoteRunFailure) 155 d.addErrback(errRemoteRunError) 156 157 # Callbacks 158
159 - def on_device__changed(self, combo):
160 self._runChecks()
161 162
163 -class BTTVWizardPlugin(object):
164 implements(IProducerPlugin) 165
166 - def __init__(self, wizard):
167 self.wizard = wizard 168 self.model = TVCardProducer()
169
170 - def getProductionStep(self, type):
171 return TVCardStep(self.wizard, self.model)
172