diff options
author | Guido van Rossum <guido@python.org> | 1992-09-24 16:03:56 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1992-09-24 16:03:56 (GMT) |
commit | cfb6bb2a3036b366aff6add44dce23a6db5b8f50 (patch) | |
tree | 4efa72f7ca2cb588f0f06514530bfad014528007 /Demo/sgi/video/Vreceive.py | |
parent | 691e59bcb7919218bb797ed318580d719eaeef92 (diff) | |
download | cpython-cfb6bb2a3036b366aff6add44dce23a6db5b8f50.zip cpython-cfb6bb2a3036b366aff6add44dce23a6db5b8f50.tar.gz cpython-cfb6bb2a3036b366aff6add44dce23a6db5b8f50.tar.bz2 |
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.
Diffstat (limited to 'Demo/sgi/video/Vreceive.py')
-rwxr-xr-x | Demo/sgi/video/Vreceive.py | 28 |
1 files changed, 15 insertions, 13 deletions
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 @@ import getopt 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 @@ def usage(msg): sys.exit(2) +# Main program: parse options and main loop. + def main(): sys.stdout = sys.stderr @@ -55,13 +59,12 @@ def main(): 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 @@ def main(): 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 @@ def opensocket(group, port): # 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 @@ def opensocket(group, port): return s + main() |