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 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  """Wizard plugin for the cortado http plug 
 23  """ 
 24   
 25  from zope.interface import implements 
 26   
 27  from flumotion.admin.assistant.interfaces import IHTTPConsumerPlugin 
 28  from flumotion.admin.assistant.models import HTTPServer, HTTPPlug 
 29  from flumotion.common.fraction import fractionAsFloat, fractionFromValue 
 30   
 31  __version__ = "$Rev: 7785 $" 
 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 CortadoWizardPlugin(object):
130 implements(IHTTPConsumerPlugin) 131
132 - def __init__(self, wizard):
133 self.wizard = wizard
134
135 - def workerChanged(self, worker):
136 d = self.wizard.runInWorker( 137 worker, 138 'flumotion.worker.checks.cortado', 'checkCortado') 139 140 def check(found): 141 return bool(found)
142 d.addCallback(check) 143 return d
144
145 - def getConsumer(self, streamer, audioProducer, videoProducer):
146 mountPoint = slashjoin(streamer.properties.mount_point, 147 "cortado/") 148 return CortadoHTTPServer(streamer, audioProducer, 149 videoProducer, 150 mountPoint)
151