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

Source Code for Module flumotion.component.plugs.html5.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 html5 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, Muxer, \ 
 27          Encoder 
 28  from flumotion.ui.plugarea import WizardPlugLine 
 29   
 30  _ = gettext.gettext 
 31   
 32  __version__ = "$Rev$" 
 33   
 34  # Copied from posixpath.py 
 35   
 36   
37 -def slashjoin(a, *p):
38 """Join two or more pathname components, inserting '/' as needed""" 39 path = a 40 for b in p: 41 if b.startswith('/'): 42 path = b 43 elif path == '' or path.endswith('/'): 44 path += b 45 else: 46 path += '/' + b 47 return path
48 49
50 -class Html5HTTPPlug(HTTPPlug):
51 """I am a model representing the configuration file for a 52 HTML5 HTTP streaming plug. 53 """ 54 plugType = "component-html5" 55 56 # Component 57
58 - def getProperties(self):
59 p = super(Html5HTTPPlug, self).getProperties() 60 #TODO: find the encoders and muxer and pass in to the Html5HTTPPlug 61 # find muxer 62 muxer = self.streamer 63 while not isinstance(muxer, Muxer): 64 muxer = muxer.eaters[0] 65 66 p.codecs = "" 67 p.mime_type = "" 68 if muxer.componentType == "ogg-muxer": 69 p.mime_type = "video/ogg" 70 elif muxer.componentType == "webm-muxer": 71 p.mime_type = "video/webm" 72 # now find the encoders 73 for eater in muxer.eaters: 74 encoder = eater 75 codec = "" 76 while not isinstance(encoder, Encoder): 77 encoder = encoder.eaters[0] 78 if encoder.componentType == "theora-encoder": 79 codec = "theora" 80 elif encoder.componentType == "vorbis-encoder": 81 codec = "vorbis" 82 elif encoder.componentType == "vp8-encoder": 83 codec = "vp8" 84 if p.codecs: 85 p.codecs = "%s,%s" % (p.codecs, codec) 86 else: 87 p.codecs = codec 88 89 p.stream_url = self.streamer.getURL() 90 91 width = 320 92 height = 240 93 if self.videoProducer: 94 width = self.videoProducer.properties.width 95 height = self.videoProducer.properties.height 96 97 p.width = width 98 p.height = height 99 100 return p
101 102
103 -class Html5HTTPServer(HTTPServer):
104 """I am a model representing the configuration file for a 105 HTTP server component which will be used to serve an html5 106 video watching page. 107 Most of the interesting logic here is actually in a plug. 108 """ 109 componentType = 'http-server' 110
111 - def __init__(self, streamer, audioProducer, videoProducer, mountPoint):
112 """ 113 @param streamer: streamer 114 @type streamer: L{HTTPStreamer} 115 @param audioProducer: audio producer 116 @type audioProducer: L{flumotion.admin.assistant.models.AudioProducer} 117 subclass or None 118 @param videoProducer: video producer 119 @type videoProducer: L{flumotion.admin.assistant.models.VideoProducer} 120 subclass or None 121 @param mountPoint: 122 @type mountPoint: 123 """ 124 self.streamer = streamer 125 super(Html5HTTPServer, self).__init__(mountPoint=mountPoint, 126 worker=streamer.worker) 127 128 porter = streamer.getPorter() 129 self.properties.porter_socket_path = porter.getSocketPath() 130 self.properties.porter_username = porter.getUsername() 131 self.properties.porter_password = porter.getPassword() 132 self.properties.port = porter.getPort() 133 self.properties.type = 'slave' 134 plug = Html5HTTPPlug(self, streamer, audioProducer, videoProducer) 135 self.addPlug(plug)
136
137 - def getProperties(self):
138 properties = super(Html5HTTPServer, self).getProperties() 139 hostname = self.streamer.getHostname() 140 if hostname: 141 properties.hostname = hostname 142 return properties
143 144
145 -class Html5PlugLine(WizardPlugLine):
146 implements(IHTTPConsumerPluginLine) 147 gladeFile = '' 148
149 - def __init__(self, wizard, description):
150 WizardPlugLine.__init__(self, wizard, None, description) 151 self.setActive(True)
152
153 - def plugActiveChanged(self, active):
154 pass
155
156 - def getConsumer(self, streamer, audioProducer, videoProducer):
157 mountPoint = slashjoin(streamer.properties.mount_point, "html5/") 158 return Html5HTTPServer(streamer, audioProducer, 159 videoProducer, mountPoint)
160 161
162 -class Html5WizardPlugin(object):
163 implements(IHTTPConsumerPlugin) 164
165 - def __init__(self, wizard):
166 self.wizard = wizard
167
168 - def getPlugWizard(self, description):
169 return Html5PlugLine(self.wizard, description)
170