~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Open Mash Cross Reference
mash/tcl/vat/application-vat.tcl

Component: ~ [ mash ] ~ [ apps ] ~ [ gsm ] ~ [ lib ] ~ [ otcl ] ~ [ srm ] ~ [ tcl8.3 ] ~ [ tclcl ] ~ [ tk8.3 ] ~ [ tutorials ] ~

  1 # application-vat.tcl --
  2 #
  3 #       FIXME: This file needs a description here.
  4 #
  5 # Copyright (c) 1996-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/vat/application-vat.tcl,v 1.61 2002/12/16 23:15:01 aswan Exp $
 32 
 33 
 34 import RTPApplication AddressBlock AudioAgent VatUI \
 35         FontInitializer WidgetResourceInitializer CoordinationBus
 36 #
 37 # The base class for the vat application.  Parses the command line
 38 # arguments, creates all the necessary agents and objects, configures
 39 # them, and splices them together.
 40 #
 41 Class VatApplication -superclass RTPApplication
 42 
 43 #
 44 # The vat application constructor.  Parse the command line
 45 # options in argument <i>argv</i> and build the app.
 46 # Creates a frame using the provided <i>widgetPath</i> and pack the vat ui in it.
 47 #
 48 VatApplication instproc init { widgetPath argv } {
 49         $self next vat
 50         set o [$self options]
 51         $self init_args $o
 52 
 53         # Search for some good fonts for the user interface and intial
 54         # the configuration options accordingly.
 55         new FontInitializer $o
 56         option add *Font [$o get_option helv14b] startupFile
 57         option add *Radiobutton.font [$o get_option helv12b] 100
 58 
 59         $self init_resources $o
 60 
 61         $o load_preferences "rtp vat"
 62         set argv [$o parse_args $argv]
 63 
 64         # Source the user's hook file if it exists. The function
 65         # user_hook, which may be defined in this file, will be
 66         # called at the end of init.
 67         if {[$o get_option userhookFile] != ""} {
 68                 if {[file isfile [$o get_option userhookFile]] && \
 69                         [file readable [$o get_option userhookFile]]} {
 70                         source [$o get_option userhookFile]
 71                 } else {
 72                         puts stderr "Unable to source \"[$o get_option userhookFile]\". Not a file or not readable."
 73                 }
 74         }
 75 
 76         set spec [$self check_hostspec $argv [$self get_option megaAudioSession]]
 77         $self check_rtp_sdes
 78 
 79         $self instvar ui_ agent_
 80 
 81         set agent_ [new AudioAgent $self $spec]
 82 
 83         if [catch {$self init_confbus} msg] {
 84                 $self warn "Error initializing conference bus: $msg"
 85         }
 86 
 87         set ui_ [$self init_ui $widgetPath $spec]
 88 
 89         $self user_hook
 90 
 91         # vat can sometimes take a long time to process events at start up.
 92         # To avoid displaying a blank window for a long time, we'll update the
 93         # window now.
 94         update idletasks
 95 }
 96 
 97 #
 98 # Creates a frame using the provided <i>widgetPath</i> and pack the vat ui in it.
 99 #
100 VatApplication instproc init_ui { widgetPath spec } {
101         $self instvar agent_ glob_chan_
102 
103         frame $widgetPath
104         set ui [new VatUI $widgetPath $glob_chan_ $agent_ "$self exit" $spec]
105         pack $widgetPath -expand 1 -fill both
106 
107         return $ui
108 }
109 
110 #
111 VatApplication instproc reset { ab } {
112         $self instvar ui_
113         $ui_ reset
114 }
115 
116 #
117 VatApplication instproc exit {} {
118     $self instvar ui_ agent_ local_chan_ glob_chan_
119     delete $ui_
120     $agent_ release
121     $agent_ shutdown
122     delete $agent_
123     delete $local_chan_
124     delete $glob_chan_
125     exit
126 }
127 
128 #
129 VatApplication instproc init_args o {
130         $o register_option -B maxbw
131         $o register_option -C conferenceName
132         $o register_option -D device
133         $o register_option -f audioFormat
134         $o register_option -F maxfps
135         $o register_option -I confBusChannel
136         $o register_option -K sessionKey
137         $o register_option -M colorFile
138         $o register_option -m mtu
139         $o register_option -o outfile
140         $o register_option -t defaultTTL
141         $o register_option -T softJPEGthresh
142         $o register_option -u userhookFile
143         $o register_option -V visual
144         # dummy option for compatibility
145         $o register_boolean_option -r compat
146         $o register_option -confid confid
147         $o register_option -loopback loopback
148         $o register_list_option -map rtpMap
149 
150         # MeGa resources
151         $o register_option -rport megaRecvAudioPort
152         $o register_option -ofmt megaAudioFormat
153         $o register_option -usemega megaAudioSession
154         $o register_option -megactrl megaAudioCtrl
155         $o register_option -sspec audioSessionSpec
156         $o register_option -maxsbw maxAudioSessionBW
157         $o register_option -sbw audioSessionBW
158         $o register_option -sloc audioServiceLocation
159 
160         # cues option
161         $o register_boolean_option -useCues useCues
162 
163         # lame options
164         $o register_option -lb bitRate
165         $o register_option -ls sampleRate
166 }
167 
168 #
169 # Initialize the configuration data base with all of the default
170 # options assumed by vat.  These can be overridden.
171 #
172 VatApplication instproc init_resources o {
173         new WidgetResourceInitializer
174 
175         # used by TopLevelWindow, AudioControlMenu, and VatApplication
176         $o add_default iconPrefix vat:
177 
178         # used when creating new CoordinationBus; get and set by AddressBlock
179         $o add_default defaultTTL 16
180 
181         # used by c++ code
182         $o add_default afDevice -1
183         $o add_default afBlocks 2
184         $o add_default afSoftOuputGain 0
185         $o add_default afSoftInputGain 0
186         $o add_default audioFileName /dev/audio
187 
188         # used by AudioControlMenu; set by AddressBlock
189         $o add_default audioFormat PCM2
190 
191         # WAS used by init_confbus
192         $o add_default confBusChannel 0
193 
194         # lame defaults
195         $o add_default sampleRate 44100
196         $o add_default bitRate 128
197 }
198 
199 #
200 # Create a global bus for communication between tools
201 # on different machines, and a local bus for tools on
202 # the same machine.
203 #
204 VatApplication instproc init_confbus {} {
205         # set channel [$self get_option confBusChannel]
206         # $self instvar cb_ agent_
207         # if { $channel != 0 } {
208         #       set cb_ [new CoordinationBus -channel $channel]
209         #       $agent_ attach_coordbus $cb_
210         # } else {
211         #       set cb_ ""
212         # }
213 
214         $self instvar agent_ local_chan_ glob_chan_
215         set local_chan_ [new CoordinationBus -channel 2]
216         $agent_ attach_local_channel $local_chan_
217 
218         set ttl [$self get_option defaultTTL]
219         set glob_chan_ [new CoordinationBus -channel 3 -ttl $ttl]
220         $agent_ attach_global_channel $glob_chan_
221 }
222 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.