1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 from twisted.web.resource import Resource
23 from twisted.web.static import Data
24
25 from flumotion.common import log
26 from flumotion.common.errors import ComponentStartError
27 from flumotion.component.misc.httpserver.httpserver import HTTPFileStreamer
28 from flumotion.component.plugs.base import ComponentPlug
29
30 __version__ = "$Rev$"
31
32 HTML5TEMPLATE = \
33 """
34 <html>
35 <head><title>Flumotion Stream</title></head>
36 <body>
37 <video height="%(height)d" width="%(width)d" controls autoplay>
38 <source type='%(mime-type)s; codecs="%(codecs)s"' src="%(stream-url)s">
39 </source>
40 </video>
41 </body>
42 """
43
44
46 if value:
47 return 'true'
48 return 'false'
49
50
52 """I generate the directory used to serve an html5 viewing page
53 It contains::
54 - a html file, usually called index.html.
55 """
56
57 - def __init__(self, mount_point, properties):
58 Resource.__init__(self)
59
60 index_name = properties.get('index', 'index.html')
61
62 root = mount_point
63 if not root.endswith("/"):
64 root += "/"
65 if index_name != 'index.html':
66 root = None
67 self._mount_point_root = root
68 self._properties = properties
69 self._index_content = self._get_index_content()
70 self._index_name = index_name
71 self._addChildren()
72
74 self.putChild(self._index_name,
75 self._index_content)
76 self.putChild('', self._index_content)
77
79 ns = {}
80 for attribute in ['codecs',
81 'mime-type',
82 'width',
83 'height',
84 'stream-url']:
85 ns[attribute] = self._properties[attribute]
86
87 content = HTML5TEMPLATE % ns
88 return Data(content, 'text/html')
89
90
92 """I am a component plug for a http-server which plugs in a
93 http resource containing a html5 viewing page.
94 """
95
96 - def start(self, component):
109
110
127
128 if __name__ == "__main__":
129 test()
130