def _mouseevent(type): gl.winset(G.focus._gid) orgx, orgy = gl.getorigin() sizex, sizey = gl.getsize() x = G.mousex - orgx y = G.mousey - orgy return type, G.focus, ((x, sizey - y), 1, 0, 0)
def showform(self): # Get position of video window gl.winset(self.window) x, y = gl.getorigin() width, height = gl.getsize() # Calculate position of form window x1 = x + width + 10 x2 = x1 + int(self.form.w) - 1 y2 = y + height - 1 y1 = y2 - int(self.form.h) + 1 # Position and show form window gl.prefposition(x1, x2, y1, y2) self.form.show_form(FL.PLACE_FREE, FL.TRUE, 'Vb Control')
def optfullsizewindow(self): if not self.window: return gl.winset(self.window) if self.use_24: x, y = self.maxx, self.maxy else: x, y = self.curx, self.cury left, bottom = gl.getorigin() width, height = gl.getsize() bottom = bottom+height-y gl.prefposition(left, left+x-1, bottom, bottom+y-1) gl.winconstraints() if not self.use_24: gl.keepaspect(x, y) gl.stepunit(8, 6) gl.maxsize(self.maxx, self.maxy) gl.winconstraints() self.bindvideo()
selectargs = (ifdlist, ofdlist, xfdlist, timeout) while 1: if gl.qtest(): dev, val = gl.qread() if dev in (DEVICE.ESCKEY, \ DEVICE.WINSHUT, DEVICE.WINQUIT): break if dev == DEVICE.REDRAW: 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() y = y + height - h gl.winposition(x, x + w - 1, y, y + h - 1) width, height = w, h lvo.resizevideo(width, height) lvo.putnextpacket(pos, data[6:]) else: x = select.select(selectargs) lvo.close() # Subroutine to create and properly initialize the receiving socket def opensocket(group, port):
#! /usr/bin/env python # Play CMIF movie files # Help function def help(): print 'Usage: Vplay [options] [file] ...' print print 'Options:' print '-M magnify : magnify the image by the given factor' print '-d : write some debug stuff on stderr' print '-l : loop, playing the movie over and over again' print '-m delta : drop frames closer than delta seconds (default 0.)' print '-n : don\'t wait after each file' print '-q : quiet, no informative messages' print '-r delta : regenerate input time base delta seconds apart' print '-s speed : speed change factor (default 1.0)' print '-t : use a 2nd thread for read-ahead' print '-x left : window offset from left of screen' print '-y top : window offset from top of screen' print '-w width : window width' print '-h height : window height' print '-b color : background color (white,black or (r,g,b))' print 'file ... : file(s) to play; default film.video' print print 'User interface:' print 'Press the left mouse button to stop or restart the movie.' print 'Press ESC or use the window manager Close or Quit command' print 'to close the window and play the next file (if any).' # Imported modules
dev, val = gl.qread() if dev == REDRAW: if bgcolor: r,g,b = bgcolor vin.clearto(r,g,b) else: vin.clear() if dev == LEFTMOUSE and val == 1: break # Continue outer loop if dev == ESCKEY and val == 1 or \ dev in (WINSHUT, WINQUIT): stop = 1 # Set xoff, yoff for the next window from the current window global xoff, yoff xoff, yoff = gl.getorigin() width, height = gl.getsize() scrheight = gl.getgdesc(GL.GD_YPMAX) yoff = scrheight - yoff - height gl.winclose(win) return 0 # Play a movie once; return 1 if user wants to stop, 0 if not def playonce(vin): vin.rewind() vin.colormapinited = 1 vin.magnify = magnify
#! /usr/bin/env python # Send live video UDP packets. # Usage: Vsend [-b] [-h height] [-p port] [-s size] [-t ttl] [-w width] # [host] .. import sys import time import struct import string from socket import * from SOCKET import * import gl, GL, DEVICE sys.path.append('/ufs/guido/src/video') import LiveVideoIn import LiveVideoOut import SV import getopt from IN import * from senddefs import * def usage(msg): print msg print 'usage: Vsend [-b] [-h height] [-p port] [-s size] [-t ttl] [-c type] [-m]', print '[-w width] [host] ...' print '-b : broadcast on local net' print '-h height : window height (default ' + ` DEFHEIGHT ` + ')' print '-p port : port to use (default ' + ` DEFPORT ` + ')' print '-t ttl : time-to-live (multicast only; default 1)' print '-s size : max packet size (default ' + ` DEFPKTMAX ` + ')' print '-w width : window width (default ' + ` DEFWIDTH ` + ')' print '-c type : Type: rgb8, mono or grey (default rgb8)'
frozen = 0 while 1: if gl.qtest(): dev, val = gl.qread() if dev in (DEVICE.ESCKEY, \ DEVICE.WINSHUT, DEVICE.WINQUIT): break if dev == DEVICE.WINFREEZE: frozen = 1 if dev == DEVICE.WINTHAW: frozen = 0 if dev == DEVICE.REDRAW: w, h = gl.getsize() x, y = gl.getorigin() if (w, h) <> (width, height): width, height = w, h lvi.resizevideo(width, height) lvo.resizevideo(width, height) rv = lvi.getnextpacket() if not rv: time.sleep(0.010) continue pos, data = rv if not frozen: lvo.putnextpacket(pos, data)
#! /usr/bin/env python
#! /usr/bin/env python # Send live video UDP packets. # Usage: Vsend [-b] [-h height] [-p port] [-s size] [-t ttl] [-w width] # [host] .. import sys import time import struct import string from socket import * from SOCKET import * import gl, GL, DEVICE sys.path.append('/ufs/guido/src/video') import LiveVideoIn import LiveVideoOut import SV import getopt from IN import * from senddefs import * def usage(msg): print msg print 'usage: Vsend [-b] [-h height] [-p port] [-s size] [-t ttl] [-c type] [-m]', print '[-w width] [host] ...' print '-b : broadcast on local net' print '-h height : window height (default ' + `DEFHEIGHT` + ')' print '-p port : port to use (default ' + `DEFPORT` + ')' print '-t ttl : time-to-live (multicast only; default 1)' print '-s size : max packet size (default ' + `DEFPKTMAX` + ')' print '-w width : window width (default ' + `DEFWIDTH` + ')' print '-c type : Type: rgb8, mono or grey (default rgb8)' print '[host] ...: host(s) to send to (default multicast to ' + \
#! /usr/bin/env python # Send live video UDP packets. # Usage: Vsend [-b] [-h height] [-p port] [-s size] [-t ttl] [-w width] # [host] .. import sys import time import struct import string import math from socket import * from SOCKET import * import gl, GL, DEVICE sys.path.append('/ufs/guido/src/video') import DisplayVideoIn import LiveVideoOut import SV import getopt from IN import * from senddefs import * def usage(msg): print msg print 'usage: Vsend [-b] [-h height] [-p port] [-s size] [-t ttl] [-c type] [-m]', print '[-w width] [host] ...' print '-b : broadcast on local net' print '-h height : window height (default ' + `DEFHEIGHT` + ')' print '-p port : port to use (default ' + `DEFPORT` + ')' print '-t ttl : time-to-live (multicast only; default 1)' print '-s size : max packet size (default ' + `DEFPKTMAX` + ')' print '-S size : use this packet size/window size' print '-w width : window width (default ' + `DEFWIDTH` + ')'
#! /usr/bin/env python # Send live video UDP packets. # Usage: Vsend [-b] [-h height] [-p port] [-s size] [-t ttl] [-w width] # [host] .. import sys import time import struct import string import math from socket import * from SOCKET import * import gl, GL, DEVICE sys.path.append('/ufs/guido/src/video') import DisplayVideoIn import LiveVideoOut import SV import getopt from IN import * from senddefs import * def usage(msg): print msg print 'usage: Vsend [-b] [-h height] [-p port] [-s size] [-t ttl] [-c type] [-m]', print '[-w width] [host] ...' print '-b : broadcast on local net' print '-h height : window height (default ' + ` DEFHEIGHT ` + ')' print '-p port : port to use (default ' + ` DEFPORT ` + ')' print '-t ttl : time-to-live (multicast only; default 1)' print '-s size : max packet size (default ' + ` DEFPKTMAX ` + ')' print '-S size : use this packet size/window size'