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

Open Mash Cross Reference
mash/tcl/vd/rf/rf.tcl

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

  1 # rf.tcl --
  2 #
  3 #       allows you to specify that the Real Networks video input should switch
  4 #       when one of the RVC video inputs switches
  5 #
  6 # Copyright (c) 2000-2002 The Regents of the University of California.
  7 # All rights reserved.
  8 #
  9 # Redistribution and use in source and binary forms, with or without
 10 # modification, are permitted provided that the following conditions are met:
 11 #
 12 # A. Redistributions of source code must retain the above copyright notice,
 13 #    this list of conditions and the following disclaimer.
 14 # B. Redistributions in binary form must reproduce the above copyright notice,
 15 #    this list of conditions and the following disclaimer in the documentation
 16 #    and/or other materials provided with the distribution.
 17 # C. Neither the names of the copyright holders nor the names of its
 18 #    contributors may be used to endorse or promote products derived from this
 19 #    software without specific prior written permission.
 20 #
 21 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
 22 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 23 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 24 # ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
 25 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 26 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 27 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 28 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 29 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 30 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 31 
 32 Import enable
 33 
 34 import 405Client
 35 
 36 # use the Tcl namespace facility to prevent conflicts
 37 namespace eval RealFollower {
 38     variable self
 39     variable enabled
 40     variable followOutput
 41     variable output
 42 }
 43 
 44 Class RealFollower
 45 
 46 RealFollower instproc init {base {extendedGUI 1}} {
 47     $self instvar 405_ statusLabel_ currentInput_
 48 
 49     set 405_ [new 405Client]
 50 
 51     # so that the callback can refer to this object
 52     set RealFollower::self $self
 53 
 54     # in the future, may want to allow other output sources to be switched,
 55     #   so use a global variable to make transition to checkbuttons easier
 56     set RealFollower::output "realNetworks"
 57     set RealFollower::enabled 0
 58     set RealFollower::followOutput "htsr"
 59 
 60     set statusLabel_ ""
 61     set currentInput_ "Erik is a god"
 62 
 63     # FIXME - should provide some getFilter library function that you give a
 64     #   list of all the things you're interested in, and it gives you an
 65     #   efficient filter expression to pass to callback_register
 66     set callback "$self processAmxMsg"
 67     set filter [$self getFilter $RealFollower::followOutput]
 68     $405_ callback_register $callback $filter
 69     $405_ callback_enable $callback
 70 
 71     $self initUI $base $extendedGUI
 72 }
 73 
 74 RealFollower instproc initUI {base {extendedGUI 1}} {
 75     $self instvar statusLabel_ currentInput_ 405_
 76 
 77     frame $base.controls -borderwidth 3
 78     pack $base.controls -side top -fill x
 79 
 80     checkbutton $base.controls.onOff -text "Enable Real Following" -variable RealFollower::enabled
 81     pack $base.controls.onOff -side left
 82 
 83     # get the current input
 84     set result [$405_ matrix_getInputSource $RealFollower::output]
 85     set currentInput_ $result
 86     set curFrame "$base.status"
 87     frame $curFrame
 88     pack $curFrame -side top -fill x
 89     set statusLabel_ [label $curFrame.currentState -text "current: $currentInput_"]
 90     pack $curFrame.currentState -side left
 91 
 92     if {$extendedGUI} {
 93         frame $base.outputs -borderwidth 3
 94         pack $base.outputs -side top -fill x
 95 
 96         # I have to give each button its own frame to make it look pretty and
 97         #  line up correctly
 98         frame $base.outputs.labelFrame
 99         pack $base.outputs.labelFrame -side top -fill x
100         label $base.outputs.labelFrame.outputLabel -text "Follow Output"
101         pack $base.outputs.labelFrame.outputLabel -side left
102 
103         frame $base.outputs.htsrBut
104         pack $base.outputs.htsrBut -side top -fill x
105         radiobutton $base.outputs.htsrBut.htsr -text "htsr" -variable RealFollower::followOutput -value "htsr" -command "$self setOutput htsr"
106         pack $base.outputs.htsrBut.htsr -side left
107 
108         frame $base.outputs.htsr2But
109         pack $base.outputs.htsr2But -side top -fill x
110         radiobutton $base.outputs.htsr2But.htsr2 -text "htsr2" -variable RealFollower::followOutput -value "htsr2" -command "$self setOutput htsr2"
111         pack $base.outputs.htsr2But.htsr2 -side left
112     }
113 
114     set RealFollower::followOutput "htsr"
115 
116     # if you want the default to be on, have to set RealFollower::enabled
117     #   to 1
118     set RealFollower::enabled 0
119 #    set RealFollower::enabled 1
120 }
121 
122 RealFollower public enable {} {
123     set RealFollower::enabled 1
124 }
125 
126 RealFollower public disable {} {
127     set RealFollower::enabled 0
128 }
129 
130 RealFollower public AMXSwitch { target output } {
131     $self instvar 405_
132 
133     $405_ matrix_switchVideoStream $target $output
134 }
135 
136 RealFollower public processAmxMsg { amxMsg } {
137     $self instvar currentInput_ statusLabel_
138 
139 #    puts stdout "RealFollower::processAmxMsg amxMsg is $amxMsg"
140 #    puts stdout "RealFollower::output is $RealFollower::output"
141 
142     if {[llength $amxMsg] != 0} {
143         set eventInfo [lindex $amxMsg 0]
144         set type [lindex $eventInfo 0]
145         set eventData [lindex $amxMsg 1]
146     }
147 
148     if {$type == "matrixSwitch"} {
149         set input [lindex $eventData 0]
150         set output [lindex $eventData 1]
151         if {$output == $RealFollower::followOutput} {
152             if {$RealFollower::enabled} {
153 #               puts stdout "should switch $input to $RealFollower::output"
154                 $self AMXSwitch $input $RealFollower::output
155             }
156         }
157         if {$output == $RealFollower::output} {
158             set currentInput_ $input
159 #           puts stdout "updating status to $input"
160             $statusLabel_ configure -text "current: $currentInput_"
161         }
162 
163     }
164 
165     return ""
166 }
167 
168 RealFollower public setOutput {output} {
169     $self instvar 405_
170 
171     switch -exact -- $output {
172         htsr -
173         htsr2 {
174             set RealFollower::followOutput $output
175 
176             # we have to reregister the callback with the updated filter to
177             #   only get the stuff we want
178             set filter [$self getFilter $RealFollower::followOutput]
179             set callback "$self processAmxMsg"
180             $405_ callback_register $callback $filter
181             $405_ callback_enable $callback
182         }
183         default {
184             return -code error "RealFollower::setOutput: output must be \[htsr, htsr2\]"
185         }
186     }
187 }
188 
189 RealFollower instproc getFilter {watchOutput} {
190     # This filters out all events except for matrixSwitch events that have an
191     #   output of $watchOutput or $RealFollower::output
192     set filter ""
193     set filter "$filter set doCallback 0\n"
194     set filter "$filter set info \[lindex \$arg 0\]\n"
195     set filter "$filter set type \[lindex \$info 0\]\n"
196     set filter "$filter set data \[lindex \$arg 1\]\n"
197     set filter "$filter if \{\$type == \"matrixSwitch\"\} \{\n"
198     set filter "$filter set output \[lindex \$data 1\]\n"
199     set filter "$filter if \{(\$output == \"$watchOutput\") || (\$output == \"$RealFollower::output\")\} \{\n"
200     set filter "$filter set doCallback 1\n"
201     set filter "$filter \}\n"
202     set filter "$filter \}\n"
203     return $filter
204 }
205 

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