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