1 # application-hmsp.tcl --
2 #
3 # FIXME: This file needs a description here.
4 #
5 # Copyright (c) 1997-2002 The Regents of the University of California.
6 # All rights reserved.
7 #
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions are met:
10 #
11 # A. Redistributions of source code must retain the above copyright notice,
12 # this list of conditions and the following disclaimer.
13 # B. Redistributions in binary form must reproduce the above copyright notice,
14 # this list of conditions and the following disclaimer in the documentation
15 # and/or other materials provided with the distribution.
16 # C. Neither the names of the copyright holders nor the names of its
17 # contributors may be used to endorse or promote products derived from this
18 # software without specific prior written permission.
19 #
20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
21 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
24 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #
31 # @(#) $Header: /usr/mash/src/repository/mash/mash-1/tcl/hmsp/application-hmsp.tcl,v 1.10 2002/02/03 04:27:11 lim Exp $
32
33
34 import Application Timer/Periodic RTSP_Client
35
36 # Headless version of MSP. It's a bit easier to test the rtsp client/server by tweaking scripts compared to bringing up a GUI. This is just a rough start...
37
38 Class HMSP_Application -superclass {Application Timer/Periodic}
39
40 HMSP_Application instproc init { argv } {
41
42 $self instvar ui_ net_ session_ delta_ history_ offset_
43
44 set o [$self options]
45 $self next msp
46 $self init_args $o
47 $self init_resources $o
48 $o parse_args $argv
49 $self parse_file
50
51 set offset_ 0
52 set history_ ""
53 set net_ [new RTSP_Client]
54 $net_ init_vars $self
55 if {[$self get_option autoStart] == "true"} {
56 set url [$self get_option defaultAddr]
57 $self open $url
58 }
59 }
60
61 # Address file is downloaded using HTTP and parsed here.
62 HMSP_Application private parse_file { } {
63 $self instvar name_ spurts_ acolor_ uname_
64
65 set sFile [$self get_option serverFile]
66 if {$sFile == ""} {
67 return 0
68 }
69 set fd [open $sFile "r"]
70 if { $fd < 0 } {
71 puts "$name_: error opening $sFile"
72 exit 1
73 }
74
75 while { [gets $fd line] > 0 } {
76 set cmd [lindex $line 0]
77 switch $cmd {
78 uri {
79 set v [lindex $line 1]
80 $self add_default defaultAddr $v
81 $self add_default autoStart "true"
82 }
83 activity {
84 # Set up bindings so that look-ups can occur both ways.
85 set info [split [join [lrange $line 1 end]] ":"]
86 set name [string trim [lindex $info 0]]
87 set color [string trim [lindex $info 2]]
88 set spurts_($name) [string trim [lindex $info 1]]
89 set acolor_($name) $color
90 set uname_($color) $name
91 }
92 }
93 }
94 close $fd
95 return 1
96 }
97
98 HMSP_Application instproc init_args o {
99 $o register_option -server serverFile
100 }
101
102 # Invoked when slider is dragged.
103 HMSP_Application instproc play-offset { } {
104 $self instvar net_ slider_
105
106 if {$slider_ == "ACTIVE"} {
107 $net_ send "PLAY"
108 $self stop
109 $self start_timer
110 }
111 return
112 }
113
114 HMSP_Application instproc display-stats { } {
115 }
116
117 HMSP_Application instproc start_vic args {
118 puts "vic $args"
119 }
120 HMSP_Application instproc start_vat args {
121 puts "vat $args"
122 }
123
124 HMSP_Application private open { url {off 0} } {
125 $self instvar net_ history_ ui_
126 $self clean_up
127 $net_ open $url
128 $net_ wait READY
129 return
130 }
131
132 HMSP_Application instproc offset { } {
133 $self instvar offset_
134 return $offset_
135 }
136
137 HMSP_Application public play_pause { } {
138 $self instvar net_ slider_
139 if {$slider_ == "ACTIVE"} {
140 $net_ playOrPause
141 }
142 }
143
144 HMSP_Application public play { } {
145 $self instvar net_
146 $net_ play
147 }
148
149 HMSP_Application public play-update args {
150 puts stderr "get rid of play-update"
151 }
152
153
154 HMSP_Application public play_stop { } {
155 $self tkvar offset_
156 $self instvar net_ slider_
157 if {$slider_ == "ACTIVE"} {
158 set offset_ 0
159 $net_ playOrPause STOP
160 }
161 }
162
163 #
164 # 'spurts' is a list of start times, expressed in % of total length
165 #
166 HMSP_Application instproc update-activity { } {
167
168 # acolor_ is the active color
169 puts "++++ UPDATE"
170 $self instvar ui_ spurts_ acolor_ uname_ seekto_ net_
171
172 foreach user_name [array names spurts_] {
173 set spurts $spurts_($user_name)
174 set color $acolor_($user_name)
175
176 # set g [lindex [split [wm geometry .] "+"] 0]
177 # set w [lindex [split $g "x"] 0]
178 set w 650
179 set e [$net_ set session_(endtime_)]
180 set s [$net_ set session_(starttime_)]
181
182 foreach starttime $spurts {
183 set st [expr ($w - 40) * ($starttime - $s)/($e - $s) + 20]
184 # set iid [$ui_(main).scale.activity create rect $st 10 [expr $st+2] 20 \
185 # -fill $color -outline $color -tag $color]
186 # $ui_(main).scale.activity bind $iid <ButtonPress-1> \
187 # "$self tkvar offset_;set offset_ [expr $starttime - $s]; $self play-offset"
188 }
189 }
190 # foreach color [array names uname_] {
191 # set n $uname_($color)
192 # $ui_(main).scale.activity bind $color <Enter> "$self show-balloon %x %y {$n} $color"
193 # $ui_(main).scale.activity bind $color <Leave> "$self hide-balloon"
194 # }
195 }
196
197 #FIXME who made these?
198 HMSP_Application private clean_up { } {
199 # $self clean-net
200 }
201
202 HMSP_Application instproc exit { } {
203 $self instvar net_
204
205 $self clean_up
206 if {[info exists net_]} {
207 $net_ send "CLOSE"
208 }
209 exit 0
210 }
211
212 HMSP_Application instproc play_update { label } {
213 $self instvar ui_
214 set label [string tolower $label]
215 if {$label == "pause"} {
216 $ui_(main).cp.playOrPause configure -text $label -image VcrIcons(pause)
217 $self start_timer
218 } else {
219 $ui_(main).cp.playOrPause configure -text $label -image VcrIcons(splay)
220 $self stop
221 }
222 }
223
224 HMSP_Application instproc start_timer { } {
225 $self instvar net_ delta_
226
227 # Convert to msec
228 set delta_ [expr [$net_ duration] * 0.001 * 1000]
229 $self start $delta_
230 }
231
232 HMSP_Application instproc timeout { } {
233 $self tkvar offset_
234 $self instvar delta_
235
236 set offset_ [expr $offset_ + $delta_ * 0.001]
237 # $self update-elapsed
238 }
239
240 #
241 # this is more or less what mui has to do...!
242 #
243 HMSP_Application private init_resources o {
244 $o add_default defaultmediaList "audio video"
245 $o add_default videoAddr 224.8.8.2
246 $o add_default videoPort 8000
247 $o add_default videoTTL 16
248
249 $o add_default audioAddr 224.8.9.2
250 $o add_default audioPort 9000
251 $o add_default audioTTL 16
252 # $o add_default serverAddr "rtsp://mirage.cs.berkeley.edu:2025/archive/CSCW4/CSCW4"
253 # $o add_default serverAddr "rtsp://rose.cs.berkeley.edu:12123/archive/CSCW4/CSCW4"
254 $o add_default serverAddr "rtsp://heart.cs.berkeley.edu:2025/x/CSCW4/CSCW4"
255 $o add_default mtu 1024
256 $o add_default network ip
257 $o add_default framerate 8
258 $o add_default defaultTTL 16
259 $o add_default maxbw -1
260 $o add_default bandwidth 1000000
261 $o add_default iconPrefix "AMASH Remote Player: "
262 $o add_default priority 10
263 $o add_default confBusChannel 0
264
265 $o add_default videoFormat h.261
266 $o add_default sessionType rtpv2
267 $o add_default grabber none
268 $o add_default stampInterval 1000
269 $o add_default switchInterval 5
270 $o add_default dither Dither
271 $o add_default tile 1
272 $o add_default filterGain 0.25
273 $o add_default statsFilter 0.0625
274 $o add_default useHardwareDecode false
275 $o add_default infoHighlightColor LightYellow2
276 $o add_default useJPEGforH261 false
277 $o add_default stillGrabber false
278 $o add_default siteDropTime "300"
279
280 #
281 # color resources
282 #
283 $o add_default medianCutColors 150
284 $o add_default gamma 0.7
285
286 #FIXME
287 $o add_default jvColors 32
288
289 $o add_default foundry adobe
290
291 $o add_default suppressUserName true
292
293 $o add_default softJPEGthresh -1
294 $o add_default softJPEGcthresh 6
295
296 $o add_default sunvideoDevice 0
297 $o add_default enableBVC false
298 $o add_default audioFormat PCM2
299
300 # true to allow voice-switch to switch to self
301 $o add_default vain false
302
303 # list of sdes items to display in info window
304 $o add_default sdesList "cname tool email note"
305
306 # resources used by audio widgets FIXME merge
307 $o add_default disabledColor gray50
308 $o add_default highlightColor gray95
309 $o add_default idleDropTime "20"
310 $o add_default defaultPriority "100"
311
312 # MeGa Resources
313 $o add_default megaCtrl 224.4.5.24/50000/1
314 $o add_default megaFormat h261
315 # multicast is default
316 $o add_default megaRecvPort 0
317
318 # (scuba) default session bandwidth (kb/s).
319 $o add_default maxSessionBW 128000
320 # 60 seconds max startup wait for first message
321 $o add_default megaStartupWait 60
322
323
324 ### Vat startup defaults
325
326 # colors
327 $o add_default titleReleased "gray95"
328 $o add_default titleHave "#aaaaaa"
329 $o add_default titlePinned "black"
330
331 $o add_default mikeGain "32"
332 $o add_default lineinGain "180"
333 $o add_default linein2Gain "180"
334 $o add_default linein3Gain "180"
335 $o add_default speakerGain "180"
336 $o add_default jackGain "180"
337 $o add_default lineoutGain "180"
338 $o add_default lineout2Gain "180"
339
340 $o add_default speakerMute "false"
341 $o add_default mikeMute "true"
342
343 $o add_default speakerMode "NetMutesMike"
344 $o add_default jackMode "FullDuplex"
345 $o add_default lineoutMode "NetMutesMike"
346 $o add_default lineout2Mode "NetMutesMike"
347 $o add_default maxPlayout "6"
348 $o add_default lectureMode "false"
349 $o add_default useNames "false"
350 $o add_default defaultTTL "16"
351
352 $o add_default filterLength "256"
353 $o add_default filterMaxTaps "35"
354
355 $o add_default meterEnable "true"
356 $o add_default meterStyle "discrete"
357 $o add_default inputPort "Mike"
358 $o add_default outputPort "Speaker"
359 $o add_default mikeAGC "false"
360 $o add_default mikeAGCLevel ""
361 $o add_default speakerAGC "false"
362 $o add_default speakerAGCLevel ""
363
364 $o add_default defaultPriority "100"
365 $o add_default idleDropTime "20"
366 $o add_default autoRaise "true"
367 $o add_default externalEchoCancel "false"
368 $o add_default silenceThresh "20"
369 $o add_default talkThresh ""
370 $o add_default echoThresh "70"
371 $o add_default echoSuppressTime "400"
372 $o add_default keepSites "false"
373 $o add_default muteNewSites "false"
374 $o add_default sortSites "true"
375 $o add_default compactSites "true"
376 $o add_default compressionSlope "0.0625"
377 $o add_default key ""
378 $o add_default afDevice "-1"
379 $o add_default afBlocks "2"
380 $o add_default afSoftOuputGain ""
381 $o add_default afSoftInputGain ""
382 $o add_default siteDropTime "300"
383 $o add_default audioFileName "/dev/audio"
384 $o add_default statTimeConst 0.1
385 $o add_default statsFilter 0.0625
386
387 $o add_default mtu 1024
388 $o add_default network ip
389 $o add_default maxbw -1
390 $o add_default bandwidth 128
391 $o add_default confBusChannel 0
392 $o add_default sessionType rtp
393
394 $o add_default foundry adobe
395 $o add_default recvOnly false
396
397 $o add_default suppressUserName true
398
399 # list of sdes items to display in info window
400 $o add_default sdesList "cname tool email"
401 }
402
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.