1 # rtp-source-gen.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 VideoAgent
33
34 Class RTPSourceGenApp -superclass RTPApplication
35
36 RTPSourceGenApp instproc init args {
37 $self next "RTPSourceGen"
38
39 [$self options] register_option -in_spec in_spec;
40 [$self options] register_option -out_spec out_spec;
41
42 $self init_resources;
43
44 eval [$self options] parse_args $args;
45
46 $self instvar in_vagent_ out_vagent_ rtp_source_gen_;
47
48 set rtp_source_gen_ [new RTPSourceGenerator];
49
50 set in_vagent_ [new InVAgent $self [$self get_option in_spec] $rtp_source_gen_];
51 set out_vagent_ [new VideoAgent $self [$self get_option out_spec]];
52
53 $rtp_source_gen_ ssrc [$out_vagent_ get_local_srcid];
54 $rtp_source_gen_ target [$out_vagent_ get_transmitter];
55 [$out_vagent_ get_transmitter] set loopback_ 0;
56
57 $self build_ui;
58 }
59
60 RTPSourceGenApp instproc build_ui {} {
61 $self instvar frate_slider_ button_frame_
62 $self instvar rec_but_ play_but_ stop_but_;
63 $self instvar rtp_source_gen_;
64
65 set frate_slider_ [scale .fs -label "Framerate" -orient h -from 1 -to 100 -command "$rtp_source_gen_ framerate " -resolution 0.1];
66 set button_frame_ [frame .butframe];
67 set rec_but_ [button .butframe.rec -command "$rtp_source_gen_ record" -text "Record"];
68 set stop_but_ [button .butframe.stop -command "$rtp_source_gen_ stop" -text "Stop"];
69 set play_but_ [button .butframe.play -command "$rtp_source_gen_ play" -text "Play"];
70
71 pack $rec_but_ -side left -fill both -expand 1;
72 pack $stop_but_ -side left -fill both -expand 1;
73 pack $play_but_ -side right -fill both -expand 1;
74
75 pack $frate_slider_ -side top -fill both -expand 1;
76 pack $button_frame_ -side top -fill both -expand 1;
77
78 $self instvar save_frame_
79 $self instvar save_e_ save_b_ load_b_;
80
81 set save_frame_ [frame .savef];
82 set save_e_ [entry .savef.e];
83 set save_b_ [button .savef.sb -text "Save" -command "$rtp_source_gen_ save \[$save_e_ get\]"];
84 set load_b_ [button .savef.lb -text "Load" -command "$rtp_source_gen_ load \[$save_e_ get\]"];
85 pack $save_e_ -side left -fill both -expand 1;
86 pack $save_b_ -side right -fill both;
87 pack $load_b_ -side right -fill both;
88 pack $save_frame_ -side top -fill both -expand 1;
89
90 $self instvar out_label_;
91 $self instvar in_label_;
92
93 set in_label_ [label .in_spec -text "In: [$self get_option in_spec]"];
94 set out_label_ [label .out_spec -text "Out: [$self get_option out_spec]"];
95
96 pack $in_label_ -side top -fill both -expand 1;
97 pack $out_label_ -side top -fill both -expand 1;
98
99 }
100
101 RTPSourceGenApp instproc remote_cmd {cmd} {
102 $self instvar rtp_source_gen_;
103
104 $rtp_source_gen_ $cmd;
105 }
106
107 RTPSourceGenApp instproc init_resources {} {
108 $self add_option network ip
109 $self add_option mtu 1024
110 $self add_option defaultTTL 32
111 $self add_option sessionType rtpv2
112 $self add_option maxVideoSessionBW 30000000
113 $self add_option in_spec 224.2.3.4/22334
114 $self add_option out_spec 224.2.3.5/22336
115 }
116
117
118 Class InVAgent -superclass VideoAgent;
119
120 InVAgent instproc init {app spec gen} {
121 $self next $app $spec;
122
123 $self instvar gen_ attached_;
124 set gen_ $gen;
125 set attached_ 0;
126
127 }
128
129 InVAgent instproc create_decoder {src} {
130 $self instvar gen_ attached_;
131
132 if {!$attached_} {
133 set attached_ 1;
134 set d $gen_;
135 } else {
136 set d [new Module/VideoDecoder/Null];
137 }
138 $d set agent_ $self;
139 $d set src_ $src;
140 return $d;
141 }
142
143 InVAgent instproc deactivate src {
144 $self instvar gen_;
145
146 set d [$src handler];
147 if {$d != $gen_} {
148 $self next $src;
149 }
150 }
151
152 set app [new RTPSourceGenApp $argv];
153
154
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.