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

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

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

  1 # application-tgw.tcl --
  2 #
  3 #       This is the base class for the tgw application, which can transcode
  4 #       video streams to lower bitrates, redirect them to other addresses,
  5 #       transcode them to RealMedia format (if you have the realproducersdk)
  6 #       and combine streams into one RealMedia stream...
  7 #
  8 # Copyright (c) 2000-2002 The Regents of the University of California.
  9 # All rights reserved.
 10 #
 11 # Redistribution and use in source and binary forms, with or without
 12 # modification, are permitted provided that the following conditions are met:
 13 #
 14 # A. Redistributions of source code must retain the above copyright notice,
 15 #    this list of conditions and the following disclaimer.
 16 # B. Redistributions in binary form must reproduce the above copyright notice,
 17 #    this list of conditions and the following disclaimer in the documentation
 18 #    and/or other materials provided with the distribution.
 19 # C. Neither the names of the copyright holders nor the names of its
 20 #    contributors may be used to endorse or promote products derived from this
 21 #    software without specific prior written permission.
 22 #
 23 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
 24 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 25 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 26 # ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
 27 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 28 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 29 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 30 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 31 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 32 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 33 
 34 import RTPApplication Configuration AddressBlock CoordinationBus \
 35         VideoHandler AudioAgent VicUI ExtOut \
 36         FontInitializer WidgetResourceInitializer TGWUI
 37 
 38 # The base class for the TGW application.  Parses the command line
 39 # arguments, creates all the necessary agents and objects, configures
 40 # them, and splices them together.
 41 # Creates a frame using the provided <i>widgetPath</i> and packs the tgw ui in it.
 42 #
 43 
 44 Class TGWApplication -superclass RTPApplication
 45 
 46 TGWApplication instproc init {widgetPath argv} {
 47         $self next tgw
 48 
 49         # Initialization of variables and resource db options
 50         set o [$self options]
 51         $self init_args $o
 52         # Search for some good fonts for the user interface and intial
 53         # the configuration options accordingly.
 54         new FontInitializer $o
 55         option add *Font [$o get_option helv12b] startupFile
 56         $self init_resources $o
 57         $o load_preferences "rtp vic"
 58         set argv [$o parse_args $argv]
 59 
 60         # Source the user's hook file if it exists. The function
 61         # user_hook, which may be defined in this file, will be
 62         # called at the end of init.
 63         if {[$o get_option userhookFile] != ""} {
 64                 if {[file isfile [$o get_option userhookFile]] && \
 65                         [file readable [$o get_option userhookFile]]} {
 66                         source [$o get_option userhookFile]
 67                 } else {
 68                         puts stderr "Unable to source \"[$o get_option userhookFile]\". Not a file or not readable."
 69                 }
 70         }
 71 
 72         set spec [$self check_hostspec [lindex $argv 0] [$self get_option megaVideoSession]]
 73         $self check_rtp_sdes
 74 
 75         # Backward compat. -B flag is kb/s.
 76         set t [$self get_option maxbw]
 77         if { $t > 0 } {
 78                 $o add_option maxbw [expr 1000*$t]
 79         }
 80 
 81         if { $spec != "" } {
 82                 #XXX need to do this to size the bandwidth slider in the GUI
 83                 set ab [new AddressBlock $spec]
 84                 $o add_option maxbw [$ab set maxbw_(0)]
 85                 delete $ab
 86         }
 87 
 88         # Create a Coordination Bus
 89         $self init_confbus
 90 
 91         # Create a VideoAgent and VideoPipeline
 92         $self instvar agent_ vpipe_ handler_ scuba_sess_
 93         set handler_ [new VideoHandler $spec]
 94         set agent_ [$handler_ agent]
 95         set vpipe_ [$handler_ vpipe]
 96 
 97         # Create the user interface for this application.
 98         $self instvar ui_
 99         set ui_ [$self init_ui $widgetPath $spec]
100 
101         $self user_hook
102 }
103 
104 # Build the main tgw user interface and pack it into a newly created
105 # window in the default top-level window.  Call init_confbus before this
106 # method, so that instvars local_chan_ and glob_chan_ are set.
107 # Creates a frame using the provided <i>widgetPath</i> and packs the tgw ui in it.
108 #
109 
110 TGWApplication instproc init_ui { widgetPath spec } {
111         $self instvar agent_ vpipe_
112         $self instvar local_chan_ glob_chan_
113 
114         frame $widgetPath
115         set ui [new TGWUI $widgetPath $local_chan_ $glob_chan_ $agent_ $vpipe_ "$self exit" [$self get_option noUI] [$self get_option realServerProfile] [$self get_option realStreamProfile]]
116         pack $widgetPath -expand 1 -fill both
117         update idletasks
118 
119         return $ui
120 }
121 
122 # A hook to gracefully shut down tgw.  Shuts down the
123 # underlying video agent and terminates the application.
124 #
125 TGWApplication instproc exit {} {
126         $self instvar agent_
127         $agent_ shutdown
128         exit 0
129 }
130 
131 # Register all of the command line options understood
132 # by tgw with the generic command-line parser.
133 #
134 TGWApplication private init_args o {
135         $o register_option -a audioSessionSpec
136         $o register_option -B maxbw
137         $o register_option -C conferenceName
138         $o register_option -c dither
139         $o register_option -D device
140         $o register_option -f videoFormat
141         $o register_option -F maxfps
142         $o register_option -I confBusChannel
143         $o register_option -K sessionKey
144         $o register_option -M colorFile
145         $o register_option -m mtu
146         $o register_option -o outfile
147         $o register_option -q jpegQfactor
148         $o register_option -t defaultTTL
149         $o register_option -T softJPEGthresh
150         $o register_option -U stampInterval
151         $o register_option -u userhookFile
152         $o register_option -V visual
153         $o register_option -N rtpName
154         $o register_list_option -map rtpMap
155 
156         $o register_boolean_option -H useHardwareDecode
157         $o register_boolean_option -P privateColormap
158 
159         # cues option
160         $o register_boolean_option -useCues useCues
161 
162         $o register_boolean_option -useRLM useRLM
163 
164         # rendezvous address, currently only for cam ctrls
165         $o register_option -rendez rendezSpec
166 
167     $o register_boolean_option -noUI noUI
168     $o register_option -realServerProfile realServerProfile
169     $o register_option -realStreamProfile realStreamProfile
170 }
171 
172 #
173 # Initialize the configuration data base with all of the default
174 # options assumed by tgw.  These can be overridden.
175 #
176 TGWApplication private init_resources o {
177         global tcl_platform
178         new WidgetResourceInitializer
179 
180         # used by TopLevelWindow and for VicUI's window-title
181         $o add_default iconPrefix tgw:
182 
183         # used when creating new CoordinationBus; get and set by AddressBlock
184         $o add_default defaultTTL 16
185 
186         # WAS used by init_confbus
187         $o add_default confBusChannel 0
188 
189         # used by ControlMenu; get and possibly set by AddressBlock
190         $o add_default videoFormat h.261
191 
192         # used by VideoPipeline; set by ControlMenu
193         $o add_default useJPEGforH261 false
194 
195         # used by MetworkMananger; only apps that set this are vic and mui.  maybe it should be add_option
196         $o add_default useLayersWindow 1
197 
198         $o add_default useRLM 0
199         $o add_default camctrl 0
200 
201         # used by c++ code
202         $o add_default jvColors 32
203         $o add_default softJPEGthresh -1
204         $o add_default softJPEGcthresh 6
205 
206         # used by VicApplication and ControlMenu
207         # (scuba) default session bandwidth (kb/s).
208         $o add_default maxVideoSessionBW 1000000
209 
210         # used by the Info window and ControlMenu
211         if {$tcl_platform(platform) != "windows"} {
212                 option add Vic.background gray85 startupFile
213                 option add Vic.foreground black startupFile
214                 option add Vic.disabledForeground gray40 startupFile
215                 $o add_default background gray85
216                 $o add_default foreground black
217                 $o add_default disabledForeground gray40
218         } else {
219                 set b [button .b____dummy____$self]
220                 $o add_default background [$b cget -background]
221                 $o add_default foreground [$b cget -foreground]
222                 $o add_default disabledForeground [$b cget -disabledforeground]
223                 destroy $b
224         }
225         
226         $o add_default noUI 0
227         $o add_default realServerProfile none
228         $o add_default realStreamProfile none
229 
230 }
231 
232 # Create a global bus for communication between tools
233 # on different machines, and a local bus for tools on
234 # the same machine.
235 #
236 TGWApplication instproc init_confbus {} {
237 
238         set channel [$self get_option confBusChannel]
239         if {$channel == ""} {set channel 2}
240 
241         $self instvar local_chan_ glob_chan_
242         set local_chan_ [new CoordinationBus -channel $channel]
243 
244         incr channel
245         set ttl [$self get_option defaultTTL]
246         set glob_chan_ [new CoordinationBus -channel $channel -ttl $ttl]
247 }
248 
249 

~ [ 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.