1 # app-collaborator.tcl --
2 #
3 # FIXME: This file needs a description here.
4 #
5 # Copyright (c) 1998-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/applications/collaborator/app-collaborator.tcl,v 1.21 2002/02/03 04:21:46 lim Exp $
32
33
34 import RTPApplication WidgetResourceInitializer FontInitializer \
35 CollaboratorUI AudioAgent VideoAgent VideoHandler \
36 MTrace Tcl_Player Tcl_Recorder NetworkManager SSAC_Client \
37 MBDebugDlg MBUI MBPSInterp MB_Manager MBPageMgr MBNet \
38 Program UserApplication/Collaborator SDPParser \
39 MPlug/ScrolledUI Observer MBv2Session
40
41
42 Class CollaboratorApp -superclass { RTPApplication Observer }
43
44
45 #
46 # Invoked with "new CollaboratorApp". Parse the options supplied by
47 # <i>argv</i>. Creates a frame using the provided <i>widgetPath</i> and
48 # pack the mui application interface in it.
49 #
50 CollaboratorApp public init { widgetPath argv } {
51 $self next collaborator
52
53 # Initialization of variables and resource db options
54 set o [$self options]
55 $self init_args $o
56
57 $self init_fonts $o
58 $self init_mega $o
59
60 # load user prefs before process argv
61 $o load_preferences "rtp collaborator"
62 set argv [$o parse_args $argv]
63 append argv [$self parse_sdp_msg]
64 # Generate an error for extra args.
65 $self check_argv $argv
66
67 # if there is a cnamePrefix arg, then set the cname option
68 set cname [$self get_option cname]
69 if { $cname == "" } {
70 set cname [$self get_option cnamePrefix]
71 if { $cname != "" } {
72 set cname ${cname}@[localaddr]
73 $self add_option cname $cname
74 }
75 }
76
77 # Retrieving and checking for at least one media spec.
78 $self instvar have_video_ have_audio_ have_mb_ have_mbv2_ have_rover_ \
79 useMega_
80 $self instvar vspec_ aspec_ mbspec_ mbv2spec_
81 $self check_hostspecs
82 $self check_rtp_sdes
83
84 # now check if we have any rover options
85 # do this before calling setup_mega_options,
86 # so we can actually verify if a -megactrl flag was passed in or not
87 $self setup_rover
88 $self setup_mega
89
90 # init resources & load preferences
91 $self init_tk_options
92
93 if { $have_video_ } {
94 $self init_vic_resources $o
95 }
96 if { $have_audio_ } {
97 $self init_vat_resources $o
98 }
99 if { $have_mb_ } {
100 $self init_mb_resources $o
101 }
102 if { $have_mbv2_ } {
103 $self init_mbv2_resources $o
104 }
105 $self init_collaborator_resources $o
106
107 # Backward compat. -B flag is kb/s.
108 set t [$self get_option maxCollaboratorSessionBWkbps]
109 if { $t > 0 } {
110 $self add_option maxbw [expr 1000*$t]
111 } else {
112 $self add_option maxbw \
113 [$self get_option maxCollaboratorSessionBW]
114 }
115
116 # Create a Coordination Bus
117 $self init_confbus
118
119 if { $have_video_ } {
120 # Create a VideoAgent, VideoPipeline, and possibly set them
121 # up to use SCUBA
122 $self instvar videoAgent_ vpipe_ videoHandler_ scuba_sess_
123 set videoHandler_ [new VideoHandler $vspec_]
124 set videoAgent_ [$videoHandler_ agent]
125 set vpipe_ [$videoHandler_ vpipe]
126 if { [$self get_option useScuba] != "" } {
127 set scuba_sess_ [$videoHandler_ set scuba_sess_]
128 }
129 #FIXME need to do this to size the bandwidth slider in the GUI
130 if { $vspec_ != {} } {
131 set ab [new AddressBlock $vspec_]
132 $self add_option maxbw [$ab set maxbw_(0)]
133 delete $ab
134 } elseif $have_rover_ {
135 $self instvar ssacClient_
136 set spec [$ssacClient_ server_name]
137 set ab [new AddressBlock $spec]
138 $self add_option maxbw [$ab set maxbw_(0)]
139 delete $ab
140 }
141 }
142
143 if { $have_audio_ } {
144 # Create AudioAgent and put it on the conference bus.
145 $self instvar audioAgent_ local_chan_ glob_chan_
146 set audioAgent_ [new AudioAgent $self $aspec_]
147 if { $local_chan_ != {} } {
148 $audioAgent_ attach_local_channel $local_chan_
149 }
150 if { $glob_chan_ != {} } {
151 $audioAgent_ attach_global_channel $glob_chan_
152 }
153 }
154
155
156 if { $have_mb_ } {
157 MTrace init {trcMB}
158 # must do this before create ui, because mbManager is
159 # required to make ui
160 $self init_mb_variables
161 }
162
163 # Create the user interface for this application.
164 $self instvar ui_
165 set ui_ [$self build_ui $widgetPath]
166
167 if { $have_mb_ } {
168 $self instvar mgr_ mbnet_
169 # must create ui before do this, because need mbui arg
170 set mbui [$ui_ get_local_option mbUI]
171 set mbnet_ [new MBNet $mbui $mgr_]
172 $self instvar session_ mbAgent_
173 set session_ [$mbnet_ session]
174 set mbAgent_ [$mbnet_ mbAgent]
175 $mbnet_ adjust_spec
176 $ui_ set_local_option mbSession $session_
177 $ui_ set_local_option mbAgent $mbAgent_
178 [$ui_ get_local_option controlmenu,mb] new_hostspec
179
180 set logf [$o get_option playScript]
181 if {"none" != $logf} {
182 global mb
183 set isRT [$config get_option rtPlay]
184 set player [new Tcl_Player $logf [$self set sender_] \
185 $isRT]
186 # wait for 1 second for everything to settle down
187 after 15000 $player start
188 }
189 }
190
191 if { $have_mbv2_ } {
192 $self init_mbv2_session $mbv2spec_
193 }
194 }
195
196
197 CollaboratorApp public init_mbv2_session { spec } {
198 $self instvar mbv2_session_ ui_
199 set mbv2_session_ [new MBv2Session $spec \
200 [$self get_option cnamePrefix]]
201 $ui_ set_local_option mbv2Session $mbv2_session_
202 set o [$ui_ get_local_option observer,mbv2]
203 if { $o != {} } { $o session $mbv2_session_ }
204
205 # do the reset before the call to app_info, since we want to
206 # set up the observers for the source_update notification
207 $self reset {} srmv2 {}
208
209 set cname [$self get_option cname]
210 if { $cname == "" } {
211 set cname [user_heuristic]@[localaddr]
212 }
213 $mbv2_session_ app_info [$mbv2_session_ sender] \
214 [$self get_option rtpName] $cname
215 }
216
217
218 CollaboratorApp private setup_rover { } {
219 $self instvar have_rover_ ssacClient_ startport_
220
221 # first do the rover stuff
222 # check if we have the -megactrl/-unicast/-mars flag
223 # if so, we use that spec instead of the one in the catalog file
224
225 set usemega [$self get_option useMegaSession]
226 set megactrl [$self get_option myMegaCtrl]
227 set startport_ [$self get_option megaStartPort]
228
229 if { $megactrl == {} } \
230 { $self add_default myMegaCtrl 224.4.5.24/50000/31 }
231
232 if { [$self get_option sessionCatalog]=={} && \
233 [$self get_option sessionCatalogFile]=={} } {
234 set have_rover_ 0
235 } else {
236 # extract the catalog file
237 set ctg [$self get_option sessionCatalog]
238 if { $ctg == {} } {
239 set filename [$self get_option sessionCatalogFile]
240 if [catch {set fd [open $filename]}] {
241 puts stderr "could not open file $filename"
242 exit
243 }
244
245 set ctg [read $fd]
246 close $fd
247 }
248
249 # figure out what ssg port to use
250 # don't bother checking if the megactrl address is unicast
251 # or not; the SSAC_Client code will do that when you call
252 # "open"
253
254 set ssg_port $startport_
255 incr startport_ 2
256
257 # if $megactrl is empty, SSAC_Client will use the
258 # default address in the catalog file
259 set have_rover_ 1
260
261 # set the "data_multicast" flag to 1 in SSAC_Client if we are
262 # using MeGa
263 set usemega [$self get_option useMegaSession]
264 if { $usemega=={} } { set data_multicast 0 } \
265 else {set data_multicast 1 }
266 set ssacClient_ [new SSAC_Client $megactrl $ssg_port \
267 $data_multicast]
268 set media [$ssacClient_ open $ctg 0]
269
270 # add the name of the SSAC server as that for the MeGa service
271 # as well
272 set ab [new AddressBlock [$ssacClient_ server_name]]
273 $self add_option myMegaCtrl [$ab addr]/[$ab sport]/[$ab ttl]
274 delete $ab
275
276 $self do_rover_media $media
277 $ssacClient_ attach_observer $self
278 }
279 }
280
281
282 CollaboratorApp private do_rover_media { media } {
283 $self instvar vspec_ aspec_ mbspec_ mbv2spec_ have_video_ have_audio_ \
284 have_mb_ have_mbv2_
285
286 set have_video_ 0
287 set have_audio_ 0
288 set have_mb_ 0
289 set have_mbv2_ 0
290 set vspec_ {}
291 set aspec_ {}
292 set mbspec_ {}
293 set mbv2spec_ {}
294
295 #YYY: need to modify rover to work with mbv2
296 foreach m $media {
297 switch $m {
298 video {
299 set vspec_ {}
300 set have_video_ 1
301 }
302 audio {
303 set aspec_ {}
304 set have_audio_ 1
305 }
306 mediaboard {
307 set mbspec_ {}
308 $self add_option mbSessionSpec {}
309 set have_mb_ 1
310 }
311 }
312 }
313 }
314
315
316 CollaboratorApp private setup_mega { } {
317 $self instvar have_video_ have_audio_ have_mb_ have_rover_ useMega_ \
318 ssacClient_ startport_
319
320 set usemega [$self get_option useMegaSession]
321 set megactrl [$self get_option myMegaCtrl]
322
323 if { $usemega == {} } {
324 set useMega_ 0
325 return
326 }
327
328 set useMega_ 1
329
330 # add the following options for all the media types
331 set maxsbw [$self get_option maxCollaboratorSessionBW]
332 if { $maxsbw=={} } { set maxsbw 1000000 }
333 $self add_option maxAudioSessionBW $maxsbw
334 $self add_option maxVideoSessionBW $maxsbw
335 $self add_option maxMbSessionBW $maxsbw
336
337 # add the following options only if we don't have rover
338 if !$have_rover_ {
339 $self add_option megaAudioSession $usemega
340 $self add_option megaVideoSession $usemega
341 $self add_option megaMbSession $usemega
342 }
343
344 # first check whether we are trying to use unicast or multicast
345 set megaCtrl [split [$self get_option myMegaCtrl] /]
346 set addr [lindex $megaCtrl 0]
347 if ![regexp {^[0-9.]+$} $addr] {
348 # this looks like a hostname
349 set addr [gethostbyname $addr]
350 }
351 if [in_multicast $addr] {
352 set unicast 0
353 $self add_option megaRecvVideoPort 0
354 $self add_option megaRecvAudioPort 0
355 $self add_option megaRecvMbPort 0
356
357 set megaCtrl [$self get_option myMegaCtrl]
358 $self add_option megaAudioCtrl $megaCtrl
359 $self add_option megaVideoCtrl $megaCtrl
360 $self add_option megaMbCtrl $megaCtrl
361 } else {
362 set unicast 1
363
364 set port [lindex $megaCtrl 1]
365 if { $port == {} } {
366 set port [$self get_option megaforPort]
367 }
368
369 if $have_video_ {
370 $self add_option megaRecvVideoPort "$startport_:[expr \
371 $startport_ + 2]"
372 $self add_option megaVideoCtrl \
373 "$addr/$port:[expr $startport_+2]/1"
374 incr startport_ 4
375 }
376 if $have_audio_ {
377 $self add_option megaRecvAudioPort "$startport_:[expr \
378 $startport_ + 2]"
379 $self add_option megaAudioCtrl \
380 "$addr/$port:[expr $startport_+2]/1"
381 incr startport_ 4
382 }
383 if $have_mb_ {
384 $self add_option megaRecvMbPort "$startport_:[expr \
385 $startport_ + 2]"
386 $self add_option megaMbCtrl \
387 "$addr/$port:[expr $startport_+2]/1"
388 incr startport_ 4
389 }
390 }
391
392 # FIXME: if we are using MeGa, we *have* to use scuba
393 if { [$self get_option useScuba]=={} } {
394 $self add_option useScuba 1
395 $self add_option localScubaScope 1
396 }
397 }
398
399
400 #
401 # The commandline arguments that can be used for this application.
402 #
403 CollaboratorApp private init_args { o } {
404 # collaborator-specific options...
405 $o register_option -video videoSessionSpec
406 $o register_boolean_option -video videoSessionSpec 224.2.55.22/8000/31
407 $o register_option -v videoSessionSpec
408 $o register_boolean_option -v videoSessionSpec 224.2.55.22/8000/31
409 $o register_option -mb mbSessionSpec
410 $o register_boolean_option -mb mbSessionSpec 224.2.55.66/8000/31
411 $o register_option -audio audioSessionSpec
412 $o register_boolean_option -audio audioSessionSpec 224.2.55.44/8000/31
413 $o register_option -a audioSessionSpec
414 $o register_boolean_option -a audioSessionSpec 224.2.55.44/8000/31
415 $o register_option -mbv2 mbv2SessionSpec
416 $o register_boolean_option -mbv2 mbv2SessionSpec 224.2.55.77/8000/31
417
418 # name and cname options
419 $o register_option -cnameprefix cnamePrefix
420 $o register_option -myname rtpName
421
422 # MPlug will want to pass this app an sdp announcement
423 # in the form of a stream of data
424 $o register_option -sdp sdpAnnouncement
425 # A Helper will want to pass this app an sdp announcement
426 # in a file
427 $o register_option -sdpfile sdpAnnouncementFile
428 # use this option to turn on transmit as soon as we start up
429 $o register_boolean_option -xmit xmitVideoOnStartup
430
431 # from vic...
432 $o register_option -C conferenceName
433 $o register_option -c dither
434 $o register_option -D device
435 $o register_option -af audioFormat
436 $o register_option -vf videoFormat
437 $o register_option -F maxfps
438 $o register_option -I confBusChannel
439 $o register_option -GI globalConfBusChannel
440 $o register_option -K sessionKey
441 $o register_option -M colorFile
442 $o register_option -m mtu
443 $o register_option -o outfile
444 $o register_option -q jpegQfactor
445 $o register_option -t defaultTTL
446 $o register_option -T softJPEGthresh
447 $o register_option -U stampInterval
448 $o register_option -V visual
449 $o register_option -N rtpName
450 $o register_list_option -map rtpMap
451
452 $o register_boolean_option -H useHardwareDecode
453 $o register_boolean_option -P privateColormap
454
455 # MeGa resources
456 $o register_option -aofmt megaAudioFormat
457 $o register_option -vofmt megaVideoFormat
458 $o register_option -mbofmt megaMbFormat
459 $o register_option -mbv2ofmt megaMbv2Format
460
461 $o register_option -startport megaStartPort
462 $o register_option -usemega useMegaSession
463 $o register_boolean_option -usemega useMegaSession [pid]@[localaddr]
464 $o register_option -megactrl myMegaCtrl
465 $o register_option -unicast myMegaCtrl
466 $o register_option -mars myMegaCtrl
467 ###$o register_option -arport megaRecvAudioPort
468 ###$o register_option -vrport megaRecvVideoPort
469 ###$o register_option -mbrport megaRecvMbPort
470
471 ###$o register_option -ausemega megaAudioSession
472 ###$o register_option -vusemega megaVideoSession
473 ###$o register_option -mbusemega megaMbSession
474
475 ###$o register_option -amegactrl megaAudioCtrl
476 ###$o register_option -vmegactrl megaVideoCtrl
477 ###$o register_option -mbmegactrl megaMbCtrl
478
479 ###$o register_option -asspec audioSessionSpec
480 ###$o register_option -vsspec videoSessionSpec
481 ###$o register_option -mbsspec mbSessionSpec
482
483 $o register_option -maxsbw maxCollaboratorSessionBW
484 # from vic...
485 $o register_option -B maxCollaboratorSessionBWkbps
486
487 $o register_option -asbw audioSessionBW
488 $o register_option -vsbw videoSessionBW
489 $o register_option -mbsbw mbSessionBW
490
491 $o register_option -asloc audioServiceLocation
492 $o register_option -vsloc videoServiceLocation
493 $o register_option -mbsloc mbServiceLocation
494
495 $o register_boolean_option -scuba useScuba
496
497 # For MeGa use only.
498 $o register_boolean_option -localscuba localScubaScope
499
500 # cues option
501 $o register_boolean_option -useCues useCues
502
503 # from vat...
504 $o register_boolean_option -r compat
505 $o register_option -confid confid
506 $o register_option -loopback loopback
507 $o register_list_option -map rtpMap
508
509 # from mb...
510 $o register_option -u uid
511 $o register_option -dbg debug
512 $o register_option -ui showUI
513 $o register_option -drop drop
514 $o register_option -play playScript
515 $o register_option -rt rtPlay
516 $o register_option -rec record
517 $o register_option -tr trace
518 $o register_option -dp delayParams
519 $o register_option -follow followActive
520 $o register_boolean_option -recvonly recvOnly
521 $o register_option -geometry geometry
522
523 # rover options
524 $o register_option -ctg sessionCatalog
525 $o register_option -ctgfile sessionCatalogFile
526 }
527
528
529 CollaboratorApp private init_mega { o } {
530 # used by mega
531 $o add_default megaStartPort 10004
532 $o add_default megaforPort 60000
533 #$o add_default myMegaCtrl 224.4.5.24/50000/31
534 }
535
536
537 #
538 # Add default font configurations to the options database.
539 #
540 CollaboratorApp private init_fonts { o } {
541 new FontInitializer $o
542
543 # from VicApplication...
544 option add *Font [$o get_option helv12b] startupFile
545
546 # from VatApplication...
547 option add *Radiobutton.font [$o get_option helv12b] 100
548
549 # override the default fonts like mb does...
550 $o add_option smallfont [$o get_option helv10]
551 $o add_option noAudioFont [$o get_option helv10o]
552 $o add_option medfont [$o get_option helv12]
553 $o add_option helpFont [$o get_option times12]
554 }
555
556
557 CollaboratorApp private init_tk_options { } {
558 #
559 # don't put tearoffs in pull-down menus
560 #
561 option add *tearOff 0
562
563 option add *Radiobutton.relief flat startupFile
564 option add *Checkbutton.anchor w startupFile
565 option add *Radiobutton.anchor w startupFile
566
567 if { [winfo depth .] == 1 } {
568 # make mono look better
569 option add *selectBackground black startupFile
570 option add *selectForeground white startupFile
571 option add *activeForeground black startupFile
572 }
573 }
574
575
576 #
577 # Initialize the configuration data base with some of the default
578 # options assumed by vic. These can be overridden.
579 #
580 CollaboratorApp private init_vic_resources { o } {
581 global tcl_platform
582
583 # used by TopLevelWindow and for VicUI's window-title
584 $o add_default iconPrefix Collaborator:
585
586 # used when creating new CoordinationBus; get and set by AddressBlock
587 $o add_default defaultTTL 31
588
589 # is used by init_confbus
590 $o add_default confBusChannel 2
591 $o add_default globalConfBusChannel 3
592
593 # used by ControlMenu; get and possibly set by AddressBlock
594 $o add_default videoFormat h.261
595
596 # used by VideoPipeline; set by ControlMenu
597 $o add_default useJPEGforH261 false
598
599 # used by NetworkMananger; only apps that set this are vic and
600 # collaborator. Maybe it should be add_option
601 $o add_default useLayersWindow 1
602
603 # used by c++ code
604 $o add_default jvColors 32
605 $o add_default softJPEGthresh -1
606 $o add_default softJPEGcthresh 6
607
608 # used by VicApplication and ControlMenu
609 # (scuba) default session bandwidth (kb/s).
610 $o add_default maxVideoSessionBW 1000000
611
612 # used by the Info window and ControlMenu
613 if {$tcl_platform(platform) != "windows"} {
614 option add Vic.background gray85 startupFile
615 option add Vic.foreground black startupFile
616 option add Vic.disabledForeground gray40 startupFile
617 $o add_default background gray85
618 $o add_default foreground black
619 $o add_default disabledForeground gray40
620 } else {
621 set b [button .b____dummy____$self]
622 $o add_default background [$b cget -background]
623 $o add_default foreground [$b cget -foreground]
624 $o add_default disabledForeground [$b cget -disabledforeground]
625 destroy $b
626 }
627 }
628
629 #
630 # Initialize the configuration data base with some of the default
631 # options assumed by vat. These can be overridden.
632 #
633 CollaboratorApp private init_vat_resources { o } {
634 # used when creating new CoordinationBus; get and set by AddressBlock
635 $o add_default defaultTTL 31
636
637 # used by c++ code
638 $o add_default afDevice -1
639 $o add_default afBlocks 2
640 $o add_default afSoftOuputGain 0
641 $o add_default afSoftInputGain 0
642 $o add_default audioFileName /dev/audio
643
644 # used by AudioControlMenu; set by AddressBlock
645 $o add_default audioFormat PCM2
646
647 # is used by init_confbus
648 $o add_default confBusChannel 2
649 $o add_default globalConfBusChannel 3
650 }
651
652 #
653 # Initialize the configuration data base with some of the default
654 # options assumed by mb. These can be overridden.
655 #
656 CollaboratorApp private init_mb_resources { o } {
657 global env
658 $self instvar class_
659
660 option add *Radiobutton.relief flat startupFile
661
662 # option add Mb.geometry 700x500 startupFile
663
664 # used by Object
665 $o add_default debug 1
666
667 $o add_default playScript none
668 $o add_default rtPlay 0
669 $o add_default record 0
670 $o add_default showUI 1
671
672 $o add_default trace none
673
674 # default added by MBNet, used by AddressBlock
675 $o add_default defaultTTL 31
676 }
677
678
679 CollaboratorApp private init_mbv2_resources { o } {
680 option add *Radiobutton.relief flat startupFile
681 }
682
683
684 #
685 # Initialize the configuration data base with some of the default
686 # options specific to collaborator. These can be overridden.
687 #
688 CollaboratorApp private init_collaborator_resources { o } {
689 $o add_default transmitOnStartup 0
690 option add Collaborator.geometry 1000x680 startupFile
691 }
692
693
694 #
695 # Create a global bus for communication between tools
696 # on different machines, and a local bus for tools on
697 # the same machine.
698 #
699 CollaboratorApp private init_confbus {} {
700 #set channel [$self get_option confBusChannel]
701 #$self instvar cb_
702 #if { $channel != "" && $channel != 0 } {
703 # set cb_ [new CoordinationBus -channel $channel]
704 #} else {
705 # set cb_ ""
706 #}
707
708 $self instvar local_chan_ glob_chan_
709 set lc [$self get_option confBufChannel]
710 set gc [$self get_option globalConfBusChannel]
711
712 if [catch {set local_chan_ [new CoordinationBus -channel $lc]}] {
713 set local_chan_ ""
714 }
715
716 if [$self yesno useCues] {
717 # FIXME: cues doesn't work yet!
718 set ttl [$self get_option defaultTTL]
719 if [catch {set glob_chan_ [new CoordinationBus -channel $gc \
720 -ttl $ttl]}] {
721 set glob_chan_ ""
722 }
723 } else {
724 set glob_chan_ ""
725 }
726 }
727
728
729 #
730 # Checks for extraneous arguments.
731 #
732 CollaboratorApp private check_argv { argv } {
733 if { [llength $argv] > 0 } {
734 set extra [lindex $argv 0]
735 $self fatal "extra arguments (starting with $extra)"
736 }
737 }
738
739
740
741 #
742 # Initializes have_<media>_ instvars.
743 # For now, at least one of -v <videoSessionSpec> -a <audioSessionSpec> and -mb <mediaboardSessionSpec> are expected.
744 # The app will be exited if none are provided.
745 #
746 CollaboratorApp private check_hostspecs { } {
747 $self instvar have_video_ have_audio_ have_mb_ have_mbv2_
748 $self instvar vspec_ aspec_ mbspec_ mbv2spec_
749
750 set usemega [$self get_option useMegaSession]
751 if { $usemega=={} } {
752 set vspec_ [$self get_option videoSessionSpec]
753 set aspec_ [$self get_option audioSessionSpec]
754 set mbspec_ [$self get_option mbSessionSpec]
755 set mbv2spec_ [$self get_option mbv2SessionSpec]
756 } else {
757 set vspec_ {}
758 set aspec_ {}
759 set mbspec_ {}
760 set mbv2spec_ {}
761 }
762
763 set have_video_ [ expr { [$self get_option videoSessionSpec] != "" || \
764 [$self get_option megaVideoSession] != "" } ]
765 set have_audio_ [ expr { [$self get_option audioSessionSpec] != "" || \
766 [$self get_option megaAudioSession] != "" } ]
767 set have_mb_ [ expr { [$self get_option mbSessionSpec] != "" || \
768 [$self get_option megaMbSession] != "" } ]
769 set have_mbv2_ [ expr { [$self get_option mbv2SessionSpec] != "" } ]
770
771 if { $have_mbv2_ && [info commands srm_create_session] == "" } {
772 # we don't have mbv2 compiled in the MASH kernel
773 $self warn "cannot use mbv2; option isn't compiled into the\
774 MASH kernel"
775 set have_mbv2_ 0
776 set mbv2spec_ {}
777 $self add_option mbv2SessionSpec ""
778 }
779
780 if { $have_mbv2_ && $usemega!={} } {
781 # YYY
782 $self warn "cannot use mega with mbv2;\
783 will not join the mbv2 session"
784 if { !$have_video_ && !$have_audio_ && !$have_mb_ } {
785 $self fatal "no other media specified; exiting..."
786 }
787 set have_mbv2_ 0
788 set mbv2spec_ {}
789 }
790 if { $have_mb_ && $have_mbv2_ } {
791 $self warn "can't have mb and mbv2 in the same session"
792 $self warn "will join only the mbv2 session"
793 set have_mb_ 0
794 set mbspec_ {}
795 }
796
797 if { !$have_video_ && !$have_audio_ && !$have_mb_ && !$have_mbv2_ } {
798 $self add_option videoSessionSpec 224.2.55.22/8000
799 $self add_option audioSessionSpec 224.2.55.44/8000
800 #$self add_option mbSessionSpec 224.2.55.66/8000
801 #$self add_option mbv2SessionSpec 224.2.55.77/8000
802 $self check_hostspecs
803 }
804 }
805
806
807 #
808 # Create the user interface for this application.
809 # Creates a frame using the provided <i>widgetPath</i> and pack the mui ui in it.
810 #
811 CollaboratorApp public build_ui { path } {
812 $self instvar videoAgent_ audioAgent_ vpipe_ scuba_sess_ ssacClient_
813 $self instvar local_chan_ glob_chan_ mgr_ sender_ sdp_
814
815 $self instvar have_video_ have_audio_ have_mb_ have_mbv2_ have_rover_ \
816 useMega_
817
818 set ui [new CollaboratorUI $useMega_ "$self exit"]
819 $ui set_local_option have_video $have_video_
820 $ui set_local_option have_audio $have_audio_
821 $ui set_local_option have_mb $have_mb_
822 $ui set_local_option have_mbv2 $have_mbv2_
823 $ui set_local_option have_rover $have_rover_
824
825 if [array exists sdp_] {
826 $ui set_local_option sdp [array get sdp_]
827 }
828
829 if { $local_chan_!={} } {
830 $ui set_local_option can_voiceswitch 1
831 $ui set_local_option local_channel $local_chan_
832 } else {
833 $ui set_local_option can_voiceswitch 0
834 }
835
836 if $have_video_ {
837 $ui set_local_option videoAgent $videoAgent_
838 $ui set_local_option videoPipe $vpipe_
839 if [info exists scuba_sess_] {
840 $ui set_local_option scubaSession $scuba_sess_