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

Open Mash Cross Reference
mash/tcl/vic/ui-videoboxmgr.tcl

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

  1 # ui-videoboxmgr.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/vic/ui-videoboxmgr.tcl,v 1.6 2002/02/03 04:39:55 lim Exp $
 32 
 33 
 34 import VideoBox Configuration
 35 
 36 #
 37 # A VideoBoxManager can be used to create a set of VideoBoxes and intelligently
 38 # assign an ActiveSource to each.  A VideoBoxManager is not required in order to
 39 # instantiate a VideoBox.
 40 #
 41 Class VideoBoxManager -superclass Observer -configuration {
 42         interestingCnames { }
 43         interestingNicknames { }
 44 }
 45 
 46 
 47 #-configuration {
 48 #       interestingCnames { 128.32.130.23 128.32.130.24 128.32.130.25 128.32.130.26 128.32.130.27 }
 49 #       interestingNicknames { Landay McCanne }
 50 #}
 51 
 52 
 53 #
 54 # Create, but do not pack, <i>n</i> VideoBoxes within the provided <i>frame</i> with the provided list of <i>attributes</i>.
 55 #
 56 VideoBoxManager public init { ActiveSourceManager n frame vbAttributes } {
 57         $self instvar interestingCnames_ interestingNicknames_ videoBoxes_
 58         lappend interestingCnames_ [$self get_option interestingCnames]
 59         lappend interestingNicknames_ [$self get_option interestingNicknames]
 60 
 61         $self instvar asm_
 62         set asm_ $ActiveSourceManager
 63 
 64         set i 0
 65         while { $i < $n} {
 66                 set vb "vb$i"
 67                 #set vbox [VideoBox $frame.$vb -size medium -border false -nametag true -ui $self -updateSpeed normal]
 68                 set vbox [eval VideoBox $frame.$vb -ui $self $vbAttributes]
 69 #vbxmgr   prev line  (want this to be optional and not a list)     $vbAttributes]
 70                 lappend videoBoxes_ $vbox
 71                 $vbox set_manager_switched
 72                 incr i
 73         }
 74 }
 75 
 76 #
 77 # Return a list of the VideoBoxes managed by this VideoBoxManager.
 78 #
 79 VideoBoxManager public get_videoboxes {} {
 80         $self instvar videoBoxes_
 81         return $videoBoxes_
 82 }
 83 
 84 #
 85 # Add the <i>cname</i> to the list of cnames the user would like to
 86 # appear in a VideoBox managed by this VideoBoxManager.  The list is
 87 # used to by the VideoBoxManager::is_interested_in method to determine whether
 88 # or not the <i>src</i> it is provided is interesting to that VideoBox.
 89 #
 90 VideoBoxManager public declare_interest_cname { cname } {
 91         $self instvar interestingCnames_
 92         lappend interestingCnames_ $cname
 93 }
 94 
 95 #
 96 VideoBoxManager public undeclare_interest_cname { cname } {
 97         $self instvar interestingCnames_
 98         set i [lsearch $interestingCnames_ $cname]
 99         set interestingCnames_ [lreplace $interestingCnames_ $i $i]
100 }
101 
102 #
103 VideoBoxManager public undeclare_interest_all_cnames { } {
104         $self instvar interestingCnames_
105         set interestingCnames_ {}
106 }
107 
108 #
109 VideoBoxManager public get_interesting_cnames { } {
110         $self instvar interestingCnames_
111         return $interestingCnames_
112 }
113 
114 #
115 # Switches <i>src</i> into a VideoBox if it is interested in it.
116 #
117 VideoBoxManager public maybe_switch_in {src} {
118         $self instvar asm_
119         $asm_ instvar active_
120 
121         # make sure that the source is active before you consider or
122         # try to switch to it
123         if { [$asm_ get_activesource $src] != {} } {
124                 foreach vb [$self get_videoboxes] {
125                         if { [$vb is_manager_switched] && \
126                                         [$self is_interested_in $vb $src] } {
127                                 $vb switch $src
128                         }
129                 }
130         }
131 }
132 
133 #
134 # Return a list of Sources being displayed in VideoBoxes managed by this
135 # VideoBoxManager.
136 #
137 VideoBoxManager public srcs_visible {} {
138         lappend srcList
139 
140         foreach vb [$self get_videoboxes] {
141                 lappend srcList [$vb get_src_displayed]
142         }
143 
144         return $srcList
145 }
146 
147 
148 # should check with vbxmgr to make sure all vb's have something in them before switching a non-empty vb
149 # try VideoBoxManager public vacancies to return true if it cycles through all te vbs it maintains and any are $isEmpty_
150 
151 #
152 # If the provided Source <i>src</i> is interesting to this VideoBoxManager,
153 # return 1.  Otherwise, return 0.
154 # <br>
155 # The provided <i>src</i> qualifies as interesting if it is not already
156 # being displayed in a VideoBox managed by this VideoBoxManager AND:
157 # <table>
158 #           <tr><td>   the provided VideoBox <i>vb</i> is currently empty
159 # </td></tr><tr><td>      OR
160 # </td></tr><tr><td>   the provided <i>src</i> has an interesting cname or nickname WHILE
161 # </td></tr><tr><td>   there is a Source being displayed in <i>vb</i> which does not
162 # </td></tr>
163 # </table>
164 #
165 VideoBoxManager private is_interested_in { vb src } {
166         # is $src already in a video box?
167         if {[lsearch [$self srcs_visible] $src] == -1} {
168                 # $src must not already be in a video box
169                 if [$vb is_empty] {
170                         # since this VideoBox is empty, yes it is interested in the $src regardless of what the $src is
171 #vbxmgr                 puts stderr "vb ($vb) ---------------------------- INTERESTED in $src cuz empty"
172                         return 1
173                 } else {
174                         # prepare to check if provided Source has an interesting cname
175                         set interesting_cnames { 128.32.130.23 128.32.130.24 128.32.130.25 128.32.130.26 128.32.130.27 } ;# make sure set to {} if nothing
176                         set src_cname [$src sdes cname]
177                         set self_cname [[$vb get_src_displayed] sdes cname]
178                         # mutate cname list into a list of regular expressions
179                         foreach cname $interesting_cnames {
180                                 # prepend @ and append $ to force an exact match
181                                 set cname_expr @$cname$
182                                 lappend cname_expr_list $cname_expr
183                         }
184 
185                         # prepare to check if provided Source has an interesting nickname
186                         global src_nickname
187                         set interesting_nicknames { Landay McCanne } ;# make sure set to {} if nothing
188                         set src_nick_name $src_nickname($src)
189                         set self_nickname $src_nickname([$vb get_src_displayed])
190 
191                         # check if provided Source has an interesting cname
192                         if {[llength $interesting_cnames] != 0} {
193                                 set like_cname [ $self is_interested_in_thingy $src $cname_expr_list $src_cname $self_cname ]
194                         } else {
195                                 set like_cname 0
196                         }
197 
198                         # check if provided Source has an interesting nickname
199                         if {[llength $interesting_nicknames] != 0} {
200                                 set like_nickname [ $self is_interested_in_thingy $src $interesting_nicknames $src_nick_name $self_nickname ]
201                         } else {
202                                 set like_nickname 0
203                         }
204 
205                         # return whether or not the provided Source has an interesting cname or nickname
206                         if { $like_cname || $like_nickname } {
207                                 return 1
208                         } else {
209                                 return 0
210                         }
211                 }
212         } else {
213                 # $src must already be in a video box, so this video box is not interested in it
214 #vbxmgr         puts stderr "vb ($vb) ---------------------------- NOT interested in $src, cuz it's already in a VideoBox"
215                 return 0
216         }
217 }
218 
219 # ??? update w/ change nickname
220 # does cnames b4 nnames
221 
222 #
223 # Return 1 if the given Source <i>src</i> has an interesting thingy.
224 # The thingy qualifies as interesting if the provided <i>src</i>
225 # case-insensitive matches a thingy in the provided list of regular
226 # expressions, <i>interestingRegexps</i>, while there is a Source being
227 # displayed in a certain VideoBox which does not.
228 # <br>
229 # Supply the thingy of the <i>src</i> as <i>srcThingy</i> and the thingy
230 # of the Source currently being displayed in this certain VideoBox as <i>selfThingy</i>.
231 #
232 VideoBoxManager private is_interested_in_thingy { src interestingRegexps srcThingy selfThingy } {
233 #vbx
234         # the video box is non-empty
235         foreach regular_expr $interestingRegexps {
236                 if {[regexp -nocase $regular_expr $selfThingy] == 1} {
237                         # this video box is already displaying an interesting source, so returning NO
238 #vbxmgr                 puts stderr "vb  ---------------------------- NOT interested in $src \
239 #vbxmgr                                 cuz i'm displaying $selfThingy, which is interesting"
240                         return 0
241                 }
242         }
243         # this video box is displaying an uninteresting source
244         foreach regular_expr $interestingRegexps {
245                 if {[regexp -nocase $regular_expr $srcThingy] == 1} {
246                         # the provided $src is interesting, so returning YES
247 #vbxmgr                 puts stderr "vb  ---------------------------- INTERESTED in $src cuz \
248 #vbxmgr                                 $srcThingy is interesting and i'm displaying $selfThingy, which is uninteresting"
249                         return 1
250                 }
251         }
252         # the provided $src is uninteresting, so returning NO
253 #vbxmgr puts stderr "vb ---------------------------- NOT interested in $src cuz i'm non-empty \
254 #vbxmgr                 and $srcThingy is uninteresting"
255         return 0
256 }
257 
258 #
259 # Returns the VideoBox in the provided <i>vbList</i> that was least recently switched to.
260 # If the provided list is empty, "" is returned.
261 #
262 VideoBoxManager public least_recently_switched { vbList } {
263         if { [llength $vbList] < 1 } {
264                 return ""
265         }
266 
267         set stalest_stamp [[lindex $vbList 0] get_sequence_stamp]
268         foreach vb $vbList {
269                 if { [$vb get_sequence_stamp] <= $stalest_stamp } {
270                         set stalest_stamp [$vb get_sequence_stamp]
271                         set stalest_box $vb
272                 }
273         }
274         return $stalest_box
275 }
276 
277 
278 VideoBoxManager public drop_thumbnail { src x y } {
279         $self instvar videoBoxes_ asm_
280         foreach vb $videoBoxes_ {
281 
282                 set l [winfo rootx $vb]
283                 set t [winfo rooty $vb]
284                 set r [expr $l + [winfo width $vb ] - 1]
285                 set b [expr $t + [winfo height $vb] - 1]
286 
287                 if { $x >= $l && $x <= $r && $y >= $t && $y <= $b } {
288                         $vb switch $src
289                         $vb set_label_textvariable ""
290                         # FIXME: the name method is defined only on
291                         # UISource/Video and not on ActiveSource
292                         $vb set_label_text [[$asm_ get_activesource $src] name]
293                         return 1
294                 }
295         }
296 
297         return 0
298 }
299 
300 
301 VideoBoxManager public change_name { src name } {
302         $self instvar videoBoxes_ asm_
303         set as [$asm_ get_activesource $src]
304         foreach vb $videoBoxes_ {
305                 if { $as == [$vb get_activesource] } {
306                         $vb set_label_text $name
307                 }
308         }
309 }
310 
311 

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