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

Open Mash Cross Reference
mash/tcl/psvp/fx_forward/back.tcl

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

  1 # back.tcl --
  2 #
  3 #       FIXME: This file needs a description here.
  4 #
  5 # Copyright (c) 1999-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 import RTPApplication
 32 import GraphComm
 33 import FAgent
 34 
 35 Class FX_Forward_Back -superclass RTPApplication
 36 
 37 FX_Forward_Back instproc init args {
 38     $self next fx_forw_back
 39 
 40     $self init_resources
 41 
 42     [$self options] register_option -from_cntrl from_cntrl
 43     [$self options] register_option -to_cntrl to_cntrl
 44 
 45     eval [$self options] parse_args $args;
 46 
 47     $self instvar from_cntrl_obj_
 48     $self instvar to_cntrl_obj_
 49 
 50     set from_cntrl_spec [split [$self get_option from_cntrl] "/"]
 51     set from_addr [lindex $from_cntrl_spec 0];
 52     set from_port [lindex $from_cntrl_spec 1];
 53     set from_ttl [lindex $from_cntrl_spec 2];
 54 
 55     set from_cntrl_obj_ [new GraphComm/Back/From $self [$self get_option comm_id] $from_addr $from_port $from_ttl];
 56 
 57     set to_cntrl_spec [split [$self get_option to_cntrl] "/"]
 58     set to_addr [lindex $to_cntrl_spec 0];
 59     set to_port [lindex $to_cntrl_spec 1];
 60     set to_ttl [lindex $to_cntrl_spec 2];
 61 
 62     set to_cntrl_obj_ [new GraphComm/Back/To $self [$self get_option comm_id] $to_addr $to_port $to_ttl];
 63 
 64     $from_cntrl_obj_ install $to_cntrl_obj_
 65     $to_cntrl_obj_ install $from_cntrl_obj_
 66 }
 67 
 68 FX_Forward_Back instproc init_resources {} {
 69     $self add_option network ip
 70     $self add_option mtu 1024
 71     $self add_option defaultTTL 32
 72     $self add_option sessionType rtpv2
 73     $self add_option maxVideoSessionBW 30000000
 74 
 75     set hname [exec hostname];
 76     set pid [pid];
 77 
 78     $self add_option comm_id ${hname}.${pid};
 79 }
 80 
 81 FX_Forward_Back instproc GenerateNewTunnelSpec {} {
 82     $self instvar used_ports_;
 83 
 84     set new_port [expr (int(rand() * 10000)*2) + 5000];
 85     while {[info exists used_ports_($new_port)]} {
 86         set new_port [expr (int(rand() * 10000)*2) + 5000];
 87     }
 88     set used_ports_($new_port) 1;
 89 
 90     set q1 228
 91     set q2 [expr int(rand() * 200) + 10]
 92     set q3 [expr int(rand() * 200) + 10]
 93     set q4 [expr int(rand() * 200) + 10]
 94 
 95     return "$q1.$q2.$q3.$q4/$new_port"
 96 }
 97 
 98 Class GraphComm/Back -superclass GraphComm
 99 
100 GraphComm/Back instproc init {app id addr port ttl} {
101     $self next $id $addr $port
102 
103     $self instvar app_
104 
105     set app_ $app;
106 
107     $self instvar dest_;
108 
109     set dest_ ""
110 }
111 
112 GraphComm/Back instproc install {dest} {
113     $self instvar dest_;
114 
115     set dest_ $dest;
116 }
117 
118 GraphComm/Back instproc recv_trigger_command {cmd} {
119     $self instvar dest_;
120 
121     if {$dest_ == ""} {
122         return;
123     }
124 
125     $dest_ send_trigger_command $cmd
126 }
127 
128 GraphComm/Back instproc recv_misc {cmd} {
129     $self instvar dest_;
130 
131     if {$dest_ == ""} {
132         return;
133     }
134 
135     $dest_ send_misc $cmd
136 }
137 
138 GraphComm/Back instproc recv_debug {data} {
139     $self instvar dest_;
140 
141     if {$dest_ == ""} {
142         return;
143     }
144 
145     $dest_ send_debug $data
146 }
147 
148 GraphComm/Back instproc new_input {new_name} {
149     $self instvar dest_;
150 
151     if {$dest_ == ""} {
152         return;
153     }
154     $self next $new_name
155 
156     $dest_ create_input $new_name
157 }
158 
159 GraphComm/Back instproc new_output {new_name} {
160     $self instvar dest_;
161 
162     if {$dest_ == ""} {
163         return;
164     }
165     $self next $new_name
166 
167     $dest_ create_output $new_name
168 }
169 
170 GraphComm/Back instproc new_parameter {new_name} {
171     $self instvar dest_;
172 
173     if {$dest_ == ""} {
174         return;
175     }
176     $self next $new_name
177 
178     $dest_ create_parameter $new_name
179 }
180 
181 GraphComm/Back instproc new_input_attribute {input_name attr_name} {
182     $self instvar dest_;
183 
184     if {$dest_ == ""} {
185         return;
186     }
187     $self next $input_name $attr_name
188 
189     $dest_ create_input_attr $input_name $attr_name
190 }
191 
192 GraphComm/Back instproc new_output_attribute {output_name attr_name} {
193     $self instvar dest_;
194 
195     if {$dest_ == ""} {
196         return;
197     }
198     $self next $output_name $attr_name
199 
200     $dest_ create_output_attr $output_name $attr_name
201 }
202 
203 GraphComm/Back instproc new_parameter_attribute {parameter_name attr_name} {
204     $self instvar dest_;
205 
206     if {$dest_ == ""} {
207         return;
208     }
209     $self next $parameter_name $attr_name
210 
211     $dest_ create_parameter_attr $parameter_name $attr_name
212 }
213 
214 GraphComm/Back instproc update_input_attr_value {input_name attr_name value} {
215     $self instvar dest_;
216 
217     if {$dest_ == ""} {
218         return;
219     }
220     $self next $input_name $attr_name $value
221 
222     $dest_ set_input_attr $input_name $attr_name $value
223 }
224 
225 GraphComm/Back instproc update_output_attr_value {output_name attr_name value} {
226     $self instvar dest_;
227 
228     if {$dest_ == ""} {
229         return;
230     }
231     $self next $output_name $attr_name $value
232 
233     $dest_ set_output_attr $output_name $attr_name $value
234 }
235 
236 GraphComm/Back instproc update_parameter_attr_value {parameter_name attr_name value} {
237     $self instvar dest_;
238 
239     if {$dest_ == ""} {
240         return;
241     }
242     $self next $parameter_name $attr_name $value
243 
244     $dest_ set_parameter_attr $parameter_name $attr_name $value
245 }
246 
247 GraphComm/Back instproc set_input_attr {input_name attr_name value} {
248     $self create_input $input_name
249     $self create_input_attr $input_name $attr_name
250     $self next $input_name $attr_name $value
251 }
252 
253 GraphComm/Back instproc set_output_attr {output_name attr_name value} {
254     $self create_output $output_name
255     $self create_output_attr $output_name $attr_name
256     $self next $output_name $attr_name $value
257 }
258 
259 GraphComm/Back instproc set_parameter_attr {parameter_name attr_name value} {
260     $self create_parameter $parameter_name
261     $self create_parameter_attr $parameter_name $attr_name
262     $self next $parameter_name $attr_name $value
263 }
264 
265 Class GraphComm/Back/From -superclass GraphComm/Back
266 
267 GraphComm/Back/From instproc update_input_attr_value {input_name attr_name value} {
268     $self instvar dest_;
269 
270     if {$dest_ == ""} {
271         return;
272     }
273 
274     $self instvar app_
275 
276     if {$attr_name == "spec"} {
277         set split_spec [split $value "/"];
278         set addr [lindex $split_spec 0];
279         set port [lindex $split_spec 1];
280         set srcid [lindex $split_spec 2];
281 
282         $self instvar tunnels_
283         if {[info exists tunnels_($addr,$port)]} {
284             set fagent $tunnels_($addr,$port);
285             set tunnel_spec $tunnel_specs_($addr,$port);
286         } else {
287             set tunnel_spec [$app_ GenerateNewTunnelSpec];
288             set fagent [new FAgent $app_ "${addr}/${port}" $tunnel_spec];
289             set tunnels_($addr,$port) $fagent;
290             set tunnel_specs_($addr,$port) $tunnel_spec;
291         }
292         if {$srcid != "*"} {
293             $fagent install_src_callback $srcid "$self complete_input_setup $srcid $fagent $input_name $tunnel_spec"
294             return;
295         } else {
296             set value "${tunnel_spec}/*";
297         }
298     }
299     $self next $input_name $attr_name $value;
300 }
301 
302 GraphComm/Back/From instproc complete_input_setup {srcid fagent input_name tunnel_spec} {
303     set new_id [$fagent translate_srcid $srcid];
304 
305     $self instvar dest_;
306 
307     $dest_ set_input_attr $input_name spec "${tunnel_spec}/${new_id}"
308 }
309 
310 Class GraphComm/Back/To -superclass GraphComm/Back
311 
312 set app [new FX_Forward_Back $argv];
313 

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