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

Open Mash Cross Reference
mash/tcl/demo/simple-video-rx.tcl

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

  1 # simple-video-rx.tcl --
  2 #
  3 #       A simple video receiver
  4 #
  5 # Copyright (c) 1997-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 
 32 if {[catch {source [file join $env(TCLCL_IMPORT_DIRS) import.tcl]} res]} {
 33         puts "error sourcing the import.tcl initialization script: $res"
 34 }
 35 
 36 Import enable
 37 import Application AddressBlock VideoAgent TkWindow
 38 import VideoWidget
 39 
 40 
 41 #
 42 # SimpleVideoRxApp
 43 #
 44 Class SimpleVideoRxApp -superclass Application
 45 
 46 SimpleVideoRxApp instproc init {} {
 47         $self next sv
 48         $self instvar agent_ srcmgr_
 49 
 50         #$self add_default defaultTTL 16
 51 
 52         # a VideoAgent object abstracts away the networking
 53         set spec 224.1.2.3/12345
 54         set agent_ [new VideoAgent $self $spec]
 55         puts "Listening to $spec"
 56 
 57         # another object (called SimpleVideoRxSourceManager) is in charge 
 58         # of listening to the VideoAgent events and responding to them
 59         set srcmgr_ [new SimpleVideoRxSourceManager $agent_]
 60 
 61         # let's request the videoagent to send events to the source manager
 62         $agent_ attach $srcmgr_
 63 }
 64 
 65 
 66 #
 67 # SimpleVideoRxSourceManager
 68 #
 69 Class SimpleVideoRxSourceManager -superclass Observer
 70 
 71 SimpleVideoRxSourceManager instproc init {agent} {
 72         $self next
 73         $self instvar agent_ target_
 74 
 75         # just write up the name of the VideoAgent
 76         set agent_ $agent
 77 
 78         # initialize the target_ handler. The target_ is the object that will 
 79         #       receive the frames once they've been decoded
 80         set target_ ""
 81 }
 82 
 83 #
 84 #       SimpleVideoRxSourceManager::trigger_sdes
 85 #
 86 #       trigger_sdes is an event raised by the VideoAgent when somebody 
 87 #       joins our session
 88 #
 89 SimpleVideoRxSourceManager instproc trigger_sdes {src} {
 90         puts "trigger_sdes: [$src sdes cname] ([$src sdes name]) joined the session"
 91 }
 92 
 93 #
 94 #       SimpleVideoRxSourceManager::trigger_media
 95 #
 96 #       trigger_media is an event raised by the VideoAgent when some source 
 97 #       joined to our session starts transmitting
 98 #
 99 SimpleVideoRxSourceManager instproc trigger_media {src} {
100 
101         # we wait a little to give time for the VideoAgent to create and install 
102         # a decoder, and for such decoder to get one packet so that it can 
103         # realize the format, size, and color subsampling scheme of the video 
104         # stream
105         after idle "$self really_activate $src"
106 }
107 
108 #
109 #       SimpleVideoRxSourceManager::really_activate
110 #
111 #       when a source has started transmitting and the decoder is already 
112 #       installed, really_activate attaches a renderer object to the decoder's 
113 #       output
114 #
115 SimpleVideoRxSourceManager instproc really_activate {src} {
116 
117         $self instvar window_ target_ decoder_ csss_ window_ renderer_
118 
119         puts "trigger_media: [$src sdes cname] ([$src sdes name]) is transmitting"
120 
121         # get the decoder handler
122         set decoder_ [$src handler]
123         if {$decoder_ == ""} {
124                 puts "\tcouldn't find a decoder"
125                 return
126         } else {
127                 puts "\tVideoAgent created a decoder [$decoder_ info class]"
128         }
129 
130         # create a receiver for the frames (the Renderer object)
131         set renderer_ [new Renderer/Null]
132 
133         # attach the renderer to the decoder's output
134         $decoder_ attach $renderer_
135 }
136 
137 # get rid of the main window
138 wm withdraw .
139 
140 # create the main object
141 set app [new SimpleVideoRxApp]
142 
143 
144 # ///////////////////////////////
145 # to get the display propierties
146 #import VisualFrame
147 #set vframe_ [new VisualFrame .top]
148 #[$vframe_ set colorModel_] info class; # returns Colormodel/TrueColor/24
149 
150 

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