1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# Live video output (display video on the screen, presumably from the net)
import gl
from VFile import Displayer
# Video output (displayer) class.
class LiveVideoOut:
def init(self, wid, xywh, vw, vh):
##print 'Init', wid, xywh
##print 'video', vw, vw
self.vw = vw
self.vh = vh
self.disp = Displayer().init()
info = ('rgb8', vw, vh, 1, 8, 0, 0, 0, 0)
self.disp.setinfo(info)
self.wid = wid
oldwid = gl.winget()
gl.winset(wid)
self.disp.initcolormap()
self.resize(xywh)
gl.winset(oldwid)
return self
def resize(self, (x, y, w, h)):
oldwid = gl.winget()
gl.winset(self.wid)
##print 'Resize', x, y, w, h
gl.winposition(x, x+w-1, y, y+h-1)
gl.reshapeviewport()
if w < self.vw or h < self.vh:
self.toosmall = 1
else:
self.disp.xorigin = (w-self.vw)/2
self.disp.yorigin = (h-self.vh)/2
self.toosmall = 0
##print 'VIDEO OFFSET:', \
## self.disp.xorigin, self.disp.yorigin
self.disp.clear()
gl.winset(oldwid)
def putnextpacket(self, pos, data):
if self.toosmall:
return
oldwid = gl.winget()
gl.winset(self.wid)
nline = len(data)/self.vw
if nline*self.vw <> len(data):
print 'Incorrect-sized video fragment'
self.disp.showpartframe(data, None, (0, pos, self.vw, nline))
gl.winset(oldwid)
def close(self):
##print 'Done video out'
pass
|