1 # application-msp.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/msp/application-msp.tcl,v 1.33 2002/02/03 04:28:01 lim Exp $
32
33
34 import Application Timer/Periodic RTSP_Client Bookmark VcrIcons \
35 Dialog MessageBox FontInitializer
36
37 # msp is the MASH streaming player, developed by Suchitra Raman as a
38 # client for the archive system. msp can be started from the command
39 # line, or as a netscape helper app. The -server flag allows msp to be
40 # passed a file which contains the starting uri, along with optional
41 # bookmarks.
42
43 # Status: alpha
44
45 # To Do: The vic and vat ui's should eventually be replaced by Cyndi's
46 # integrated UI. Also, needs to include mb capabilities. Switching
47 # sessions doesn't always work properly, and bookmarks need work. Also,
48 # needs a lot more error trapping.
49
50
51 Class MSP_Application -superclass {Application Timer/Periodic}
52
53 #FIXME
54 #source tcl/net/network.tcl
55 # had to add because of in_multicast proc, should be part of AddressBlock?
56
57
58 #source tcl/msp/ui-vic.tcl
59 #source tcl/msp/ui-vat.tcl
60
61 #
62 MSP_Application instproc init { w argv } {
63
64 $self instvar ui_ net_ session_ delta_ history_
65 $self tkvar offset_
66
67 set o [$self options]
68 $self next msp
69 $self init_args $o
70 $self init_resources $o
71 $o parse_args $argv
72 $self init_fonts $o
73 $self init_UI $w
74
75 set msp [$self get_option mspData]
76 if { $msp!={} } {
77 $self parse_msp $msp
78 } else {
79 $self parse_file [$self get_option serverFile]
80 }
81 set history_ ""
82 if [info exists net_] {
83 } else {
84 set net_ [new RTSP_Client]
85 $net_ init_vars $self
86 }
87 if {[$self get_option autoStart] == "true"} {
88 $self tkvar url_
89 $self instvar desc_
90 set url_ [$self get_option defaultAddr]
91 set desc_ [$self get_option defaultDesc]
92 $self open
93 }
94 }
95
96 #
97 MSP_Application private parse_line { line } {
98 set cmd [lindex $line 0]
99 switch $cmd {
100 uri {
101 set v [lindex $line 1]
102 $self add_default defaultAddr $v
103 $self add_default autoStart "true"
104 }
105 activity {
106 # Set up bindings so that look-ups can occur both ways.
107 set info [split [join [lrange $line 1 end]] ":"]
108 set name [string trim [lindex $info 0]]
109 set color [string trim [lindex $info 2]]
110 set spurts_($name) [string trim [lindex $info 1]]
111 set acolor_($name) $color
112 set uname_($color) $name
113 }
114 }
115 }
116
117
118 # Address file is downloaded using HTTP and parsed here.
119 MSP_Application private parse_file { sFile } {
120 $self instvar name_ spurts_ acolor_ uname_ bookmarks_
121 $self instvar ui_
122
123 if {$sFile == ""} {
124 return 0
125 }
126 set fd [open $sFile "r"]
127 if { $fd < 0 } {
128 puts "$name_: error opening $sFile"
129 exit 1
130 }
131
132 while { [gets $fd line] > 0 } {
133 set cmd [lindex $line 0]
134 switch $cmd {
135 uri {
136 set v [lindex $line 1]
137 $self add_default defaultAddr $v
138 $self add_default autoStart "true"
139 }
140 bookmark {
141 # Set up bindings so that look-ups can occur both ways.
142 set info [split [join [lrange $line 1 end]] "^"]
143 set name [string trim [lindex $info 2]]
144 set color [string trim [lindex $info 3]]
145 if {$color == ""} {
146 set color "black"
147 }
148 set offset [string trim [lindex $info 1]]
149 set addr [string trim [lindex $info 0]]
150 set bookmarks_($addr:$offset) [new Bookmark $name $addr $offset $color]
151 set idx "$addr:$offset"
152 $ui_(main).menubar.bookmarks.list add command -font [$self get_option entryFont] \
153 -label "$name ($idx)" \
154 -command "[list $self jump-to $idx]"
155 }
156 }
157 $self parse_line $line
158 }
159 close $fd
160 return 1
161 }
162
163 #
164 MSP_Application private parse_msp { msp } {
165 foreach line [split $msp "\n"] {
166 $self parse_line $line
167 }
168 }
169
170 #
171 MSP_Application instproc init_args o {
172 $o register_option -server serverFile
173 $o register_option -msp mspData
174 $o register_option -vusemega megaVideoSession
175 $o register_option -ausemega megaAudioSession
176 $o register_option -vrport megaRecvVideoPort
177 $o register_option -vmegactrl megaVideoCtrl
178 $o register_option -arport megaRecvAudioPort
179 $o register_option -amegactrl megaAudioCtrl
180
181 $o register_option -sspec videoSessionSpec
182 $o register_option -sbw videoSessionBW
183 $o register_option -sloc videoServiceLocation
184 $o register_boolean_option -scuba useScuba
185 }
186
187 #
188 MSP_Application instproc init_UI { path } {
189
190 $self instvar ui_ id_
191 wm title . "MARS Rover"
192
193 set id_ 0
194 set ui_(main) $path
195 frame $path -relief sunken
196 pack $path -fill x
197
198 $self build_menubar $path
199 $self build_entry $path
200 $self build_ctrlpanel $path
201 $self build_slider $path
202 $self build_title $path
203 }
204
205 #
206 MSP_Application instproc build_av { path } {
207 frame $path.av
208 frame $path.av.vic
209 frame $path.av.vat
210 pack $path.av -side bottom -expand 1 -fill both
211 pack $path.av.vat $path.av.vic -side left -expand 1 -fill both
212 }
213
214 #
215 MSP_Application instproc build_entry { w } {
216 $self tkvar url_
217 frame $w.entry -relief sunken
218 pack $w.entry -fill x
219 label $w.entry.label -text Location: -justify right
220 entry $w.entry.url -textvariable [$self tkvarname url_] -width 60\
221 -bg white -fg black -font [$self get_option entryFont]
222 bind $w.entry.url <Key-Return> "$self open"
223 pack $w.entry.label -anchor w -side left
224 pack $w.entry.url -fill x -side left -anchor e
225 }
226
227 #
228 MSP_Application instproc build_ctrlpanel { w } {
229 $self instvar net_
230
231 frame $w.cp -relief sunken -height 20
232 pack $w.cp -fill x -anchor w -side top
233 set mf [$self get_option medfont]
234 button $w.cp.stop -height 10 -font $mf -text "Stop" -image VcrIcons(sstop)\
235 -command "$self play-stop"
236 button $w.cp.playOrPause -height 10 -font $mf -text "Play" -image VcrIcons(splay)\
237 -command "$self play-pause"
238 pack $w.cp.playOrPause $w.cp.stop -side left -anchor w
239 }
240
241 #
242 MSP_Application instproc build_title { w } {
243 $self instvar net_
244
245 frame $w.sdes -relief sunken
246 frame $w.sinfo -relief sunken
247 frame $w.dur -relief sunken
248 pack $w.sdes $w.sinfo $w.dur -fill both -side top
249 set ef [$self get_option entryFont]
250 set bf [$self get_option mbFont]
251 # Build the session description label
252 label $w.sdes.label -text Title: -justify right \
253 -width 15 -anchor e
254 label $w.sdes.value -text " " -width 60 \
255 -fg black -bg white -font $ef -justify left -anchor w
256 pack $w.sdes.label $w.sdes.value -fill x -side left -anchor w
257
258 # Build the session info label
259 label $w.sinfo.label -text Information: -justify right \
260 -width 15 -anchor e
261 label $w.sinfo.value -text " " -width 60 \
262 -bg white -fg black -font $ef -justify left -anchor w\
263 -wraplength 5i
264 pack $w.sinfo.label $w.sinfo.value -fill x -side left -anchor w
265
266 # Build the session info label
267 label $w.dur.label -text Duration: -width 15 -justify right -anchor e
268 label $w.dur.value -text "0:00:00" \
269 -fg black -bg white -font $ef -width 60 \
270 -justify left -anchor w
271 pack $w.dur.label $w.dur.value -fill x -side left -anchor w
272 }
273
274 #
275 MSP_Application instproc build_slider { w } {
276
277 # Offset in the stream to control seeking
278 $self tkvar offset_
279 $self instvar slider_
280
281 set sf [$self get_option disableFont]
282 frame $w.scale -relief sunken
283 canvas $w.scale.activity -height 20 -width 650 -highlightthickness 0 -bd 1 -closeenough 1.0
284
285 set slider_ INACTIVE
286 scale $w.scale.slider -state disabled -orient horizontal \
287 -width 8 -length 650 -relief groove -showvalue 0 \
288 -from 0 -to 100 \
289 -font $sf -showvalue true \
290 -variable [$self tkvarname offset_] \
291 -troughcolor white
292
293 bind $w.scale.slider <ButtonRelease-2> "$self play-offset"
294 bind $w.scale.slider <ButtonRelease-1> "$self play-offset"
295 bind $w.scale.slider <ButtonPress-3> "$self edit_bookmark .bookmark"
296 pack $w.scale -expand 0 -side top -anchor w
297 pack $w.scale.activity $w.scale.slider -fill x -expand 0
298 }
299
300 # Invoked when play starts
301 MSP_Application instproc activate_slider { } {
302 $self instvar ui_ slider_ net_
303 #puts "Activating slider"
304 if {$slider_ == "INACTIVE"} {
305 set slider_ ACTIVE
306 set mf [$self get_option medfont]
307 set s [$net_ set session_(starttime_)]
308 set e [$net_ set session_(endtime_)]
309 $ui_(main).scale.slider configure -state active -font $mf -from 0 -to [expr int($e -$s)] \
310 -tickinterval [expr int(0.49 * ($e - $s))]
311 after 3000 $self read_bookmarks
312 after 3000 $self update-activity
313 }
314 }
315
316 # Invoked when slider is dragged.
317 MSP_Application instproc play-offset { } {
318 $self instvar net_ slider_
319
320 if {$slider_ == "ACTIVE"} {
321 $net_ send "PLAY"
322 $self cancel
323 $self start-timer
324 }
325 return
326 }
327
328 #
329 MSP_Application instproc build_menubar { path } {
330
331 $self instvar net_ history_
332
333 frame $path.menubar -relief sunken
334 pack $path.menubar -fill x
335
336 menubutton $path.menubar.file -text "File" -m $path.menubar.file.x -width 5
337 pack $path.menubar.file -side left
338 menu $path.menubar.file.x -tearoff no
339
340 $path.menubar.file.x add command -label "Open URL" -command "$self get_URL .open"
341 $path.menubar.file.x add command -label "Exit" -command "$self exit"
342
343 menubutton $path.menubar.view -text "View" -m $path.menubar.view.x -width 5
344 pack $path.menubar.view -side left
345
346 menubutton $path.menubar.bookmarks -text "Bookmarks" -m $path.menubar.bookmarks.list -width 10
347 pack $path.menubar.bookmarks -side left
348
349 menubutton $path.menubar.go -text "Go" -m $path.menubar.go.list -width 5
350 pack $path.menubar.go -side left
351
352
353 menubutton $path.menubar.help -text "Help" -m $path.menubar.help.help -width 5
354 pack $path.menubar.help -side left
355
356 menu $path.menubar.view.x -tearoff no
357 $path.menubar.view.x add command -label "Statistics" -command "$self display-stats"
358 $path.menubar.view.x add command -label "Preferences" -command " "
359
360 menu $path.menubar.go.list -tearoff no
361 menu $path.menubar.bookmarks.list -tearoff no
362 $path.menubar.bookmarks.list add command -label "Add Bookmark" -command "$self edit_bookmark .bookmark"
363 $path.menubar.bookmarks.list add separator
364 menu $path.menubar.help.help -tearoff no
365 $path.menubar.help.help add command -label "Help" -command " "
366 }
367
368 #
369 MSP_Application instproc display-stats { } {
370
371 }
372
373 #
374 MSP_Application instproc get_URL { w } {
375
376 $self tkvar url_
377 set url_ [$self get_option serverAddr]
378 toplevel $w
379 wm title $w "Open Presentation"
380 message $w.msg -width 200 -justify center -text "Enter URL"
381 pack $w.msg
382 entry $w.url -width 60 -textvariable [$self tkvarname url_]\
383 -font [$self get_option entryFont]
384 # bind $w.url <Key-Return> "destroy $w; $self open"
385 pack $w.url
386 frame $w.bf -relief sunken
387 pack $w.bf -pady 5
388 button $w.bf.ok -text "Open" -width 5 -command "destroy $w; $self open"
389 pack $w.bf.ok
390 button $w.bf.quit -text "Cancel" -width 5 -command "destroy $w"
391 pack $w.bf.quit -side right -before $w.bf.ok
392 }
393
394 #
395 MSP_Application instproc open { {off 0} } {
396 $self instvar net_ history_ ui_
397 $self tkvar url_
398 $self instvar desc_
399 $self clean-up
400 # Update the history list
401 set ef [$self get_option entryFont]
402 set h $url_
403 $ui_(main).menubar.go.list insert 1 command -font $ef \
404 -label "$h" -command "$self tkvar url_; set url_ $h; $self open"
405 if {![info exists desc_]} {
406 set desc_ ""
407 }
408 set err [$net_ open $url_ $desc_]
409 if { $err != "" } {
410 Dialog transient MessageBox -type ok -text $err \
411 -image Icons(warning)
412 }
413 return
414 }
415
416 #
417 MSP_Application instproc offset { } {
418 $self tkvar offset_
419 return $offset_
420 }
421
422 #
423 MSP_Application instproc play-pause { } {
424 $self instvar net_ slider_
425 if {$slider_ == "ACTIVE"} {
426 $net_ playOrPause
427 }
428 }
429
430 #
431 MSP_Application instproc play-stop { } {
432 $self tkvar offset_
433 $self instvar net_ slider_
434 if {$slider_ == "ACTIVE"} {
435 set offset_ 0
436 $net_ playOrPause STOP
437 }
438 }
439
440 #
441 MSP_Application instproc show-balloon { x y desc color } {
442 $self instvar uname_ ui_ id_
443
444 set w .balloon
445
446 if ![winfo exists $w] {
447 toplevel $w
448 wm overrideredirect $w 1
449 message $w.msg -font [$self get_option smallfont] \
450 -width 200 -bg white
451 pack $w.msg -side left
452 }
453 wm overrideredirect $w 1
454 set widget .main.scale.activity
455 set x [expr [winfo rootx $widget]+$x]
456 set y [expr [winfo rooty $widget]+$y + 10]
457 $w.msg config -text $desc -fg $color
458 wm geometry $w +$x+$y
459 }
460
461 #
462 MSP_Application instproc hide-balloon { } {
463 $self instvar ui_ id_
464 destroy .balloon
465 }
466
467 #
468 MSP_Application instproc update-activity { } {
469
470 # acolor_ is the active color
471 $self instvar ui_ spurts_ acolor_ uname_ seekto_ net_ bookmarks_
472 $self tkvar url_
473 #puts "==update-activity=="
474 foreach x [array names bookmarks_] {
475 set addr [$bookmarks_($x) set attributes_(addr)]
476 set offset [$bookmarks_($x) set attributes_(offset)]
477 set color [$bookmarks_($x) set attributes_(color)]
478 set name [$bookmarks_($x) set attributes_(name)]
479 if {$url_ == $addr} {
480 $self update-bookmark $offset $name $color
481 }
482 }
483
484 }
485
486 #
487 MSP_Application instproc update-bookmark {o n {color "black"}} {
488 $self instvar ui_ net_
489
490
491 # set g [lindex [split [wm geometry .] "+"] 0]
492 # set w [lindex [split $g "x"] 0]
493 set w 650
494
495 set mark 0
496 set e [$net_ set session_(endtime_)]
497 set s [$net_ set session_(starttime_)]
498
499 set st [expr ($w - 40) * ($o - $s)/($e - $s) + 20]
500 set iid [$ui_(main).scale.activity create rect $st 10 [expr $st+3] 20 \
501 -fill $color -outline $color -tag $color]
502 $ui_(main).scale.activity bind $iid <ButtonPress-1> \
503 "$self tkvar offset_;set offset_ [expr $o -$s]; $self play-offset"
504 set mark [expr $st+3]
505 $ui_(main).scale.activity bind $iid <Enter> "$self show-balloon %x %y {$n} $color"
506 $ui_(main).scale.activity bind $iid <Leave> "$self hide-balloon"
507 }
508
509 #
510 MSP_Application instproc update-title {name info duration {elapsed 00:00:00} } {
511 $self instvar ui_ app_
512 $ui_(main).sdes.value configure -text $name
513 $ui_(main).sinfo.value configure -text $info
514 $ui_(main).dur.value configure -text "$elapsed/[duration_readable $duration]"
515 set app_(duration) $duration
516 }
517
518 #
519 MSP_Application instproc update-elapsed { } {
520 $self instvar ui_ app_ net_
521 $self tkvar offset_
522 set elapsed [$net_ elapsed $offset_]
523 $ui_(main).dur.value configure -text "$elapsed/[duration_readable $app_(duration)]"
524 }
525
526 #
527 MSP_Application instproc clean-up { } {
528 $self instvar vic_ vat_ ui_
529
530 $self clean-net
531 if [info exists vic_(agent)] {
532 delete $vic_(agent)
533 }
534 if [info exists vat_(agent)] {
535 delete $vat_(agent)
536 }
537 destroy .main.av
538 $self build_av $ui_(main)
539 }
540
541 #
542 MSP_Application instproc exit { } {
543 $self instvar net_
544
545 $self clean-up
546 if {[info exists net_]} {
547 $net_ send "CLOSE"
548 }
549 exit 0
550 }
551
552 #
553 MSP_Application instproc play-update { label } {
554 $self instvar ui_
555 set label [string tolower $label]
556 if {$label == "pause"} {
557 $ui_(main).cp.playOrPause configure -text $label -image VcrIcons(pause)
558 $self start-timer
559 } else {
560 $ui_(main).cp.playOrPause configure -text $label -image VcrIcons(splay)
561 $self cancel
562 }
563 }
564
565 #
566 MSP_Application instproc start-timer { } {
567 $self instvar net_ delta_
568
569 # Convert to msec
570 set delta_ [expr [$net_ duration] * 0.001 * 1000]
571 $self start $delta_
572 }
573
574 #
575 MSP_Application instproc timeout { } {
576 $self tkvar offset_
577 $self instvar delta_
578
579 #set offset_ [expr $offset_ + $delta_ * 0.001]
580 $self update-elapsed
581 }
582
583 #
584 MSP_Application instproc add-bookmark { } {
585 $self tkvar offset_ bname_ url_
586 $self instvar bookmarks_ ui_ net_
587
588 set timestamp [expr [$net_ set session_(starttime_)] + $offset_]
589 set b [new Bookmark $bname_ $url_ $timestamp]
590 set bookmarks_($url_:$timestamp) $b
591
592 set idx "$url_:$timestamp"
593 set ef [$self get_option entryFont]
594 $ui_(main).menubar.bookmarks.list add command -font $ef \
595 -label "$bname_ ($url_:$timestamp)" -command "[list $self jump-to $idx]"
596 $self save_bookmark $b
597 $self update-bookmark $timestamp $bname_
598 }
599
600 #
601 MSP_Application instproc get_value opt {
602 return [$self get_option $opt]
603 }
604
605 #
606 MSP_Application private read_bookmarks { } {
607 $self instvar ui_ bookmarks_
608 $self tkvar url_
609
610 if [file exists ~/.msp/bookmarks.bm] {
611 set fd [open ~/.msp/bookmarks.bm]
612 while { [gets $fd line] > 0 } {
613 set f [split $line "^"]
614
615 set addr [lindex $f 0]
616 set offset [lindex $f 1]
617 set name [lindex $f 2]
618 set color [string trim [lindex $f 3]]
619 if {$color == ""} {
620 set color "black"
621 }
622 set b [new Bookmark $name $addr $offset $color]
623 set bookmarks_($addr:$offset) $b
624 set idx "$addr:$offset"
625
626 set ef [$self get_option entryFont]
627 $ui_(main).menubar.bookmarks.list add command -font $ef \
628 -label "$name ($addr:$offset)" \
629 -command "[list $self jump-to $idx]"
630 # if {$url_ == $addr} {
631 # puts "adding bookmark $name to canvas"
632 # $self update-bookmark $offset $name $color
633 # }
634
635 }
636 close $fd
637 }
638 }
639
640 #
641 MSP_Application instproc edit_bookmark { w } {
642 $self instvar slider_
643 if {$slider_ == "INACTIVE"} {
644 return
645 }
646 toplevel $w
647 wm title $w "Add Bookmark"
648 message $w.msg -width 200 -justify center -text "Label"
649 pack $w.msg
650 entry $w.url -width 40 -textvariable [$self tkvarname bname_]\
651 -font [$self get_option entryFont] -bg white -fg black
652 pack $w.url
653 frame $w.bf -relief sunken
654 pack $w.bf -pady 5
655 button $w.bf.ok -text "Add" -font [$self get_option mbFont] -width 5 -command "destroy $w; $self add-bookmark"
656 pack $w.bf.ok
657 button $w.bf.quit -text "Cancel" -font [$self get_option mbFont] -width 5 -command "destroy $w"
658 pack $w.bf.quit -side right -before $w.bf.ok
659 }
660
661 #
662 MSP_Application instproc save_bookmark { b } {
663 $self instvar net_
664 cd ~
665 if ![file exists .msp] {
666 exec mkdir .msp
667 }
668 cd .msp
669 set fd [open "bookmarks.bm" a+]
670 set addr [$b set attributes_(addr)]
671 set name [$b set attributes_(name)]
672 set timestamp [$b set attributes_(offset)]
673 #puts $fd "$addr\^$timestamp\^$name\^black"
674 close $fd
675 }
676
677 #
678 MSP_Application instproc jump-to { idx } {
679 $self tkvar offset_ url_
680 $self instvar net_ bookmarks_
681 #puts "jump-to $idx"
682 set bm $bookmarks_($idx)
683 set addr [$bm set attributes_(addr)]
684 if { $addr == [$net_ set session_(uri_)]} {
685 set offset_ [expr [$bm set attributes_(offset)] - [$net_ set session_(starttime_)]]
686 $net_ send "PLAY"
687 } else {
688 Dialog transient MessageBox -type ok -text "This demo version permits only 1 stream!" \
689 -image Icons(warning)
690 # We don't support multiple sessions
691 # set url_ [$bm set attributes_(addr)]
692 # set offset_ [expr [$bm set attributes_(offset)] - [$net_ set session_(starttime_)]]
693 # $self open $offset_
694 }
695 }
696
697 #
698 MSP_Application instproc display-stats { } {
699
700 }
701
702 #
703 MSP_Application instproc set-offset { o } {
704 $self tkvar offset_
705 set offset_ $o
706 }
707
708 #
709 # this is more or less what mui has to do...!
710 #
711 MSP_Application instproc init_resources o {
712 $o load_preferences "msp"
713
714 #
715 # use 2 pixels of padding by default
716 #
717 option add *padX 2
718 option add *padY 2
719 #
720 # don't put tearoffs in pull-down menus
721 #
722 option add *tearOff 0
723
724 option add *Radiobutton.relief flat startupFile
725 option add *Checkbutton.anchor w startupFile
726 option add *Radiobutton.anchor w startupFile
727 option add *Radiobutton.relief flat startupFile
728 global tcl_platform
729 # use the default colors if we are in windows
730 if {$tcl_platform(platform) != "windows"} {
731 option add *Scale.sliderForeground gray66 startupFile
732 option add *Scale.activeForeground gray80 startupFile
733 option add *Scale.background gray70 startupFile
734 option add Msp.background gray85
735 }
736 option add *VatVU.foreground black startupFile
737 option add *VatVU.peak gray50 startupFile
738 option add *VatVU.hot firebrick1 startupFile
739 option add *VatVU.hotLevel 90 startupFile
740
741 #
742 # These can be overridden.
743 #
744 # $self add_default geometry 400x620
745
746 $o add_default defaultDesc ""
747 $o add_default defaultmediaList "audio video"
748 $o add_default videoAddr 224.8.8.2
749 $o add_default videoPort 8000
750 $o add_default videoTTL 16
751
752 $o add_default audioAddr 224.8.9.2
753 $o add_default audioPort 9000
754 $o add_default audioTTL 16
755 $o add_default mediaboardTTL 16
756 # $o add_default serverAddr "rtsp://mirage.cs.berkeley.edu:2025/archive/CSCW4/CSCW4"
757 $o add_default serverAddr "rtsp://rose.cs.berkeley.edu:2025/archive/CSCW4/CSCW4"
758 $o add_default mtu 1024
759 $o add_default network ip
760 $o add_default framerate 8
761 $o add_default defaultTTL 16
762 $o add_default maxbw -1
763 $o add_default bandwidth 1000000
764 $o add_default iconPrefix "MARS Rover"
765 $o add_default priority 10
766 $o add_default confBusChannel 0
767
768 $o add_default videoFormat h.261
769 $o add_default sessionType rtpv2
770 $o add_default grabber none
771 $o add_default stampInterval 1000
772 $o add_default switchInterval 5
773 $o add_default dither Dither
774 $o add_default tile 1
775 $o add_default filterGain 0.25
776 $o add_default statsFilter 0.0625
777 $o add_default useHardwareDecode false
778 $o add_default infoHighlightColor LightYellow2
779 $o add_default useJPEGforH261 false
780 $o add_default stillGrabber false
781 $o add_default siteDropTime "300"
782
783 #
784 # color resources
785 #
786 $o add_default medianCutColors 150
787 $o add_default gamma 0.7
788
789 #FIXME
790 $o add_default jvColors 32
791
792 $o add_default foundry adobe
793
794 $o add_default suppressUserName true
795
796 $o add_default softJPEGthresh -1
797 $o add_default softJPEGcthresh 6
798
799 $o add_default sunvideoDevice 0
800 $o add_default enableBVC false
801 $o add_default audioFormat PCM2
802
803 # true to allow voice-switch to switch to self
804 $o add_default vain false
805
806 # list of sdes items to display in info window
807 $o add_default sdesList "cname tool email note"
808
809 # resources used by audio widgets FIXME merge
810 $o add_default disabledColor gray50
811 $o add_default highlightColor gray95
812 $o add_default idleDropTime "20"
813 $o add_default defaultPriority "100"
814
815 # MeGa Resources
816 $o add_default megaVideoCtrl 224.4.5.24/50000/1
817 $o add_default megaVideoFormat h261
818 # multicast is default
819 $o add_default megaVideoRecvPort 0
820 $o add_default megaAudioRecvPort 0
821
822 # (scuba) default session bandwidth (kb/s).
823 $o add_default maxVideoSessionBW 128000
824 # 60 seconds max startup wait for first message
825 $o add_default megaStartupWait 60
826
827
828 ### Vat startup defaults
829 option add Msp.iconPrefix Client: startupFile
830
831 # colors
832 $o add_default titleReleased "gray95"
833 $o add_default titleHave "#aaaaaa"
834 $o add_default titlePinned "black"
835
836 $o add_default inputGain "32"
837 $o add_default mikeGain "32"
838 $o add_default lineinGain "180"
839 $o add_default linein2Gain "180"
840 $o add_default linein3Gain "180"
841
842 $o add_default outputGain 180
843 $o add_default speakerGain "180"
844 $o add_default jackGain "180"
845 $o add_default lineoutGain "180"
846 $o add_default lineout2Gain "180"
847
848 $o add_default speakerMute "false"
849 $o add_default mikeMute "true"
850
851 $o add_default speakerMode "NetMutesMike"
852 $o add_default jackMode "FullDuplex"
853 $o add_default lineoutMode "NetMutesMike"
854 $o add_default lineout2Mode "NetMutesMike"
855 $o add_default maxPlayout "6"
856 $o add_default lectureMode "false"
857 $o add_default useNames "false"
858 $o add_default defaultTTL "16"
859
860 $o add_default filterLength "256"
861 $o add_default filterMaxTaps "35"
862
863 $o add_default meterEnable "true"
864 $o add_default meterStyle "discrete"
865 $o add_default inputPort {mike microphone mic}
866 $o add_default outputPort speaker
867 $o add_default mikeAGC "false"
868 $o add_default mikeAGCLevel ""
869 $o add_default speakerAGC "false"
870 $o add_default speakerAGCLevel ""
871
872 $o add_default defaultPriority "100"
873 $o add_default idleDropTime "20"
874 $o add_default autoRaise "true"
875 $o add_default externalEchoCancel "false"
876 $o add_default silenceThresh "20"
877 $o add_default talkThresh ""
878 $o add_default echoThresh "70"
879 $o add_default echoSuppressTime "400"
880 $o add_default keepSites "false"
881 $o add_default muteNewSites "false"
882 $o add_default sortSites "true"
883 $o add_default compactSites "true"
884 $o add_default compressionSlope "0.0625"
885 $o add_default key ""
886 $o add_default afDevice "-1"
887 $o add_default afBlocks "2"
888 $o add_default afSoftOuputGain ""
889 $o add_default afSoftInputGain ""
890 $o add_default siteDropTime "300"
891 $o add_default audioFileName "/dev/audio"
892 $o add_default statTimeConst 0.1
893 $o add_default statsFilter 0.0625
894
895 $o add_default mtu 1024
896 $o add_default network ip
897 $o add_default maxbw -1
898 $o add_default bandwidth 128
899 $o add_default confBusChannel 0
900 $o add_default sessionType rtp
901
902 $o add_default foundry adobe
903 $o add_default recvOnly false
904
905 $o add_default suppressUserName true
906 }
907
908 #
909 MSP_Application instproc init_fonts o {
910 new FontInitializer $o
911
912 option add *Font [$o get_option helv12] startupFile
913 # override some default fonts...
914 $o add_default mbFont [$o get_option helv12]
915 $o add_default helpFont [$o get_option times12]
916 $o add_default entryFont [$o get_option courier12]
917 $o add_default disableFont [$o get_option helv10o]
918 }
919
920 import MPlug/ScrolledUI
921
922 # This class allows the msp application to run as a MASH plug in.
923
924 Class MSP_Application/MPlug -superclass MSP_Application
925
926 #
927 MSP_Application/MPlug public init { argv } {
928 $self instvar mplug_
929 set mplug_ [new MPlug/ScrolledUI]
930
931 # on success, the following function returns NPRES_DONE which is
932 # defined to 0 in a .h file
933 # FIXME: how do I pull in constants defined in .h files into tcl?
934 if { [$mplug_ wait_for_stream] } {
935 puts stderr "Could not retrieve stream"
936 exit
937 }
938
939 if { [$mplug_ get mimetype] != "x-mash/x-msp" } {
940 $self do_error "msp cannot handle mimetype:\
941 [$mplug_ get mimetype]"
942 }
943
944 lappend argv -msp [$mplug_ get stream]
945 $self next [$mplug_ root].[pid] $argv
946 vwait forever
947 }
948
949 #
950 MSP_Application/MPlug private do_error { msg } {
951 $self instvar mplug_
952 label .label -text $msg -justify left -anchor w
953 pack .label -fill both -expand 1 -padx 10 -pady 10
954 vwait forever
955 }
956
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.