Package flumotion :: Package component :: Package plugs :: Package cortado :: Module wizard_gtk
[hide private]

Source Code for Module flumotion.component.plugs.cortado.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  """Wizard plugin for the cortado http plug 
 19  """ 
 20   
 21  import gettext 
 22  from zope.interface import implements 
 23   
 24  from flumotion.admin.assistant.interfaces import IHTTPConsumerPlugin, \ 
 25          IHTTPConsumerPluginLine 
 26  from flumotion.admin.assistant.models import HTTPServer, HTTPPlug 
 27  from flumotion.ui.plugarea import WizardPlugLine 
 28   
 29  _ = gettext.gettext 
 30   
 31  __version__ = "$Rev$" 
 32   
 33  # Copied from posixpath.py 
 34   
 35   
36 -def slashjoin(a, *p):
37 """Join two or more pathname components, inserting '/' as needed""" 38 path = a 39 for b in p: 40 if b.startswith('/'): 41 path = b 42 elif path == '' or path.endswith('/'): 43 path += b 44 else: 45 path += '/' + b 46 return path
47 48
49 -class CortadoHTTPPlug(HTTPPlug):
50 """I am a model representing the configuration file for a 51 Cortado HTTP streaming plug. 52 """ 53 plugType = "component-cortado" 54 55 # Component 56
57 - def getProperties(self):
58 p = super(CortadoHTTPPlug, self).getProperties() 59 60 p.codebase = self.server.getCodebase() 61 p.stream_url = self.streamer.getURL() 62 p.has_video = self.videoProducer is not None 63 p.has_audio = self.audioProducer is not None 64 65 width = 320 66 height = 240 67 if self.videoProducer: 68 width = self.videoProducer.properties.width 69 height = self.videoProducer.properties.height 70 71 p.width = width 72 p.height = height 73 p.buffer_size = 40 74 75 return p
76 77
78 -class CortadoHTTPServer(HTTPServer):
79 """I am a model representing the configuration file for a 80 HTTP server component which will be used to serve a cortado 81 java applet. 82 Most of the interesting logic here is actually in a plug. 83 """ 84 componentType = 'http-server' 85
86 - def __init__(self, streamer, audioProducer, videoProducer, mountPoint):
87 """ 88 @param streamer: streamer 89 @type streamer: L{HTTPStreamer} 90 @param audioProducer: audio producer 91 @type audioProducer: L{flumotion.admin.assistant.models.AudioProducer} 92 subclass or None 93 @param videoProducer: video producer 94 @type videoProducer: L{flumotion.admin.assistant.models.VideoProducer} 95 subclass or None 96 @param mountPoint: 97 @type mountPoint: 98 """ 99 self.streamer = streamer 100 101 super(CortadoHTTPServer, self).__init__(mountPoint=mountPoint, 102 worker=streamer.worker) 103 104 porter = streamer.getPorter() 105 self.properties.porter_socket_path = porter.getSocketPath() 106 self.properties.porter_username = porter.getUsername() 107 self.properties.porter_password = porter.getPassword() 108 self.properties.port = porter.getPort() 109 self.properties.type = 'slave' 110 plug = CortadoHTTPPlug(self, streamer, audioProducer, videoProducer) 111 self.addPlug(plug)
112
113 - def getCodebase(self):
114 """Returns the base of directory of the applet 115 @returns: directory 116 """ 117 return 'http://%s:%d%s' % (self.streamer.hostname, 118 self.properties.port, 119 self.properties.mount_point)
120
121 - def getProperties(self):
122 properties = super(CortadoHTTPServer, self).getProperties() 123 hostname = self.streamer.getHostname() 124 if hostname: 125 properties.hostname = hostname 126 return properties
127 128
129 -class CortadoPlugLine(WizardPlugLine):
130 implements(IHTTPConsumerPluginLine) 131 gladeFile = '' 132 inactiveMessage = \ 133 _('Cortado player should be installed to enable this option') 134
135 - def __init__(self, wizard, description):
136 WizardPlugLine.__init__(self, wizard, None, description) 137 self.setActive(True)
138
139 - def plugActiveChanged(self, active):
140 pass
141
142 - def getConsumer(self, streamer, audioProducer, videoProducer):
143 mountPoint = slashjoin(streamer.properties.mount_point, "cortado/") 144 return CortadoHTTPServer(streamer, audioProducer, 145 videoProducer, mountPoint)
146 147
148 -class CortadoWizardPlugin(object):
149 implements(IHTTPConsumerPlugin) 150
151 - def __init__(self, wizard):
152 self.wizard = wizard
153
154 - def workerChanged(self, worker):
155 d = self.wizard.runInWorker( 156 worker, 157 'flumotion.worker.checks.cortado', 'checkCortado') 158 159 def check(found): 160 return bool(found)
161 d.addCallback(check) 162 return d
163
164 - def getPlugWizard(self, description):
165 return CortadoPlugLine(self.wizard, description)
166