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