Changed the init() interface of LiveVideoOut to read out the window
size automatically -- the video is always centered. Added
resizevideo() and reshapewindow() interfaces. Documented all methods.
Changed Vsend/Vreceive to use the new interface. Allow window
resizing by the user in Vreceive.
diff --git a/Demo/sgi/video/Vreceive.py b/Demo/sgi/video/Vreceive.py
index 334fe66..17a803f 100755
--- a/Demo/sgi/video/Vreceive.py
+++ b/Demo/sgi/video/Vreceive.py
@@ -19,6 +19,8 @@
from senddefs import *
+# Print usage message and exit(2).
+
def usage(msg):
print msg
print 'usage: Vreceive [-m mcastgrp] [-p port]'
@@ -27,6 +29,8 @@
sys.exit(2)
+# Main program: parse options and main loop.
+
def main():
sys.stdout = sys.stderr
@@ -55,13 +59,12 @@
gl.foreground()
gl.prefsize(width, height)
wid = gl.winopen('Vreceive')
+ gl.winconstraints()
gl.qdevice(DEVICE.ESCKEY)
gl.qdevice(DEVICE.WINSHUT)
gl.qdevice(DEVICE.WINQUIT)
- x, y = gl.getorigin()
- lvo = LiveVideoOut.LiveVideoOut().init(wid, (x, y, width, height), \
- width, height)
+ lvo = LiveVideoOut.LiveVideoOut().init(wid, width, height)
ifdlist = [gl.qgetfd(), s.fileno()]
ofdlist = []
@@ -77,18 +80,16 @@
DEVICE.WINSHUT, DEVICE.WINQUIT):
break
if dev == DEVICE.REDRAW:
- gl.clear()
+ lvo.reshapewindow()
elif s.avail():
data = s.recv(16*1024)
pos, w, h = struct.unpack('hhh', data[:6])
if (w, h) <> (width, height):
- x, y = gl.getorigin()
+ x, y = gl.getorigin()
y = y + height - h
+ gl.winposition(x, x+w-1, y, y+h-1)
width, height = w, h
- lvo.close()
- lvo = LiveVideoOut.LiveVideoOut() \
- .init(wid, (x, y, width, height), \
- width, height)
+ lvo.resizevideo(width, height)
lvo.putnextpacket(pos, data[6:])
else:
x = select.select(selectargs)
@@ -103,16 +104,16 @@
# Create the socket
s = socket(AF_INET, SOCK_DGRAM)
- # Bind the port to it
- s.bind('', port)
-
# Allow multiple copies of this program on one machine
s.setsockopt(SOL_SOCKET, SO_REUSEPORT, 1) # (Not strictly needed)
+ # Bind the port to it
+ s.bind('', port)
+
# Look up the group once
group = gethostbyname(group)
- # Ugly: construct binary group address
+ # Construct binary group address
group_bytes = eval(regsub.gsub('\.', ',', group))
grpaddr = 0
for byte in group_bytes: grpaddr = (grpaddr << 8) | byte
@@ -126,4 +127,5 @@
return s
+
main()