6 from time
import millitimer
8 HS
= 40 # Header size (must be same as in tv.py)
10 # Rely on UDP packet (de)fragmentation for smoother images
11 # (Changed for broadcast)
14 PF
= 2 # Default packfactor
16 # Default receiver station is voorn.
17 # Kwik has no yellow pages, so...
18 HOST
= '192.16.201.121'
22 PF
= eval(sys
.argv
[1])
33 centerx
, centery
= 400, 300
47 readsource(SRC_FRAMEGRABBER
)
49 s
= socket(AF_INET
, SOCK_DGRAM
)
50 if HOST
== '<broadcast>':
55 linesperchunk
= MAX
/bytesperline
56 linesperchunk
= linesperchunk
/PF
*PF
57 nchunks
= (h
+linesperchunk
-1)/linesperchunk
60 print 'linesperchunk=', linesperchunk
,
61 print 'nchunks=', nchunks
,
62 print 'w=', w
, 'h=', h
83 linesperchunk
= MAX
/bytesperline
84 linesperchunk
= linesperchunk
/PF
*PF
85 nchunks
= (h
+linesperchunk
-1)/linesperchunk
88 print 'linesperchunk=', linesperchunk
,
89 print 'nchunks=', nchunks
,
90 print 'w=', w
, 'h=', h
100 readsource(SRC_FRAMEGRABBER
)
106 fps
= int(10000.0*nframes
/(t2
-t1
)) * 0.1
107 msg
= `fps`
+ ' frames/sec'
111 RGBcolor(255,255,255)
116 rectcopy(centerx
-w
/2, centery
-w
/2, centerx
+w
/2, centery
+w
/2, 0, 0)
118 for i
in range(nchunks
):
120 y2
= y1
+ linesperchunk
-1
122 data
= lrectread(x1
, y1
, x2
, y2
)
123 data2
= packrect(x2
-x1
+1, y2
-y1
+1, PF
, data
)
124 prefix
= `w
, h
, PF
, x1
, y1
, x2
, y2`
125 prefix
= prefix
+ ' ' * (HS
-len(prefix
))
126 data3
= prefix
+ data2
127 s
.sendto(data3
, addr
)