1 # dc-api.tcl --
2 #
3 # Object contained in the app that opens a TclDP RPC port to allow
4 # remote processes to control the DC, such as choosing which streams
5 # to broadcast.
6 #
7 # Copyright (c) 2000-2002 The Regents of the University of California.
8 # All rights reserved.
9 #
10 # Redistribution and use in source and binary forms, with or without
11 # modification, are permitted provided that the following conditions are met:
12 #
13 # A. Redistributions of source code must retain the above copyright notice,
14 # this list of conditions and the following disclaimer.
15 # B. Redistributions in binary form must reproduce the above copyright notice,
16 # this list of conditions and the following disclaimer in the documentation
17 # and/or other materials provided with the distribution.
18 # C. Neither the names of the copyright holders nor the names of its
19 # contributors may be used to endorse or promote products derived from this
20 # software without specific prior written permission.
21 #
22 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
23 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
26 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
33 import DpClient
34
35 # this class provides remote control of the DC using the TclDP RPC mechanism;
36 # it affects the DC by simulating GUI events
37
38 namespace eval DcApi {
39 variable self
40 }
41
42 Class DcApi
43
44 DcApi instproc init {appDC uiDC port} {
45 set DcApi::self $self
46
47 $self instvar m_appHandle m_uiHandle m_server
48 set m_appHandle $appDC
49 set m_uiHandle $uiDC
50
51 # get copies of these variables from the UI for future use
52 $self instvar m_uiThumbnailFrame m_uiPreviewFrame m_uiBroadcastFrame
53 $self instvar m_framePV m_frameBC
54 set m_uiThumbnailFrame [$m_uiHandle set m_uiThumbnailFrame]
55 set m_uiPreviewFrame [$m_uiHandle set m_uiPreviewFrame]
56 set m_uiBroadcastFrame [$m_uiHandle set m_uiBroadcastFrame]
57 set m_framePV [$m_uiHandle set m_framePV]
58 set m_frameBC [$m_uiHandle set m_frameBC]
59
60 # create a TclDP RPC server
61 if {[catch {new DpServer $port} m_server]} {
62 puts "WARNING: dc: Unable to start DP server on DC"
63 set m_server ""
64 }
65 }
66
67 # FIXME - we should catch errors or something here so we can't crash DC
68
69 DcApi public broadcastThumbnail {uiThumbnail} {
70 $self instvar m_uiBroadcastFrame m_frameBC
71
72 set x [winfo rootx $m_frameBC]
73 set y [winfo rooty $m_frameBC]
74 # use a dummy dragNDrop since don't need to zoom
75 $m_uiBroadcastFrame DropThumbnail "dummy" $uiThumbnail $x $y
76 }
77
78 DcApi public previewThumbnail {uiThumbnail} {
79 $self instvar m_uiPreviewFrame m_framePV
80
81 set x [winfo rootx $m_framePV]
82 set y [winfo rooty $m_framePV]
83 # use a dummy dragNDrop since don't need to zoom
84 $m_uiPreviewFrame DropThumbnail "dummy" $uiThumbnail $x $y
85 }
86
87 DcApi public removePreview {uiPreview} {
88 $self instvar m_uiPreviewFrame
89
90 $m_uiPreviewFrame RemovePreview $uiPreview
91 }
92
93 DcApi public removeBroadcast {uiBroadcast} {
94 $self instvar m_uiBroadcastFrame
95
96 $m_uiBroadcastFrame RemoveBroadcast $uiBroadcast
97 }
98
99 #
100 # the following 3 functions return info about the windows present in the
101 # DC
102 #
103 # they all return an array in the form of a list, to use the info, you should:
104 #
105 # set infoList [$self getThumbnailInfo]
106 # array set infoArray $infoList
107 #
108 # the "windows" element of the array is a list of windows in the given frame
109 #
110 # set windowList $infoArray(windows)
111 #
112 # you can then go through each item and look at the values associated with
113 # each item
114 #
115 # foreach index $windowList {
116 # set addr $infoArray($index,addr)
117 # set addr $infoArray($index,hostname)
118 # $self broadcastThumbnail $index
119 # }
120 #
121 # the index itself is a handle to the thumbnail, preview, or broadcast window
122 # and can be passed to the DcApi functions to cause/cease transmission of
123 # video from a given source (as seen in the above "foreach" loop)
124
125 DcApi public getThumbnailInfo {} {
126 $self instvar m_uiThumbnailFrame
127
128 return [$m_uiThumbnailFrame getThumbnailInfo]
129 }
130
131 DcApi public getPreviewInfo {} {
132 $self instvar m_uiPreviewFrame
133
134 return [$m_uiPreviewFrame getPreviewInfo]
135 }
136
137 DcApi public getBroadcastInfo {} {
138 $self instvar m_uiBroadcastFrame
139
140 return [$m_uiBroadcastFrame getBroadcastInfo]
141 }
142
143 DcApi public clearBroadcastPane {} {
144 $self instvar m_uiBroadcastFrame
145
146 set broadcastInfoList [$m_uiBroadcastFrame getBroadcastInfo]
147 array set broadcastInfo $broadcastInfoList
148 foreach index $broadcastInfo(windows) {
149 $self removeBroadcast $index
150 }
151 }
152
153 DcApi public clearPreviewPane {} {
154 $self instvar m_uiPreviewFrame
155
156 set broadcastInfoList [$m_uiPreviewFrame getPreviewInfo]
157 array set broadcastInfo $broadcastInfoList
158 foreach index $broadcastInfo(windows) {
159 $self removePreview $index
160 }
161 }
162
163 DcApi instproc getInfo {} {
164 $self instvar m_uiThumbnailFrame m_uiPreviewFrame m_uiBroadcastFrame
165
166 puts stdout "CDcUI::getInfo: called"
167
168 set thumbs [$m_uiThumbnailFrame getThumbnailInfo]
169
170 array set thumbsInfo $thumbs
171 set thumbsIndices $thumbsInfo(windows)
172
173 puts stdout "thumbs: $thumbs"
174 puts stdout "thumbsIndices: $thumbsIndices"
175
176 $self clearPreviewPane
177 set x 1
178 after 1000 {set x 0}
179 vwait x
180 $self clearBroadcastPane
181 set x 1
182 after 1000 {set x 0}
183 vwait x
184
185 # preview window
186 set index [lindex $thumbsIndices 0]
187 $self previewThumbnail $index
188
189 # broadcast window
190 set index [lindex $thumbsIndices 1]
191 $self broadcastThumbnail $index
192 }
193
194 #
195 # API
196 #
197 # The functions below can be called remotely using the TclDP RPC mechanism
198 # to cause GUI events to occur, simulating a director drag-n-dropping
199 #
200
201 # we need wrappers since the remote callers don't have a handle to the DcApi
202 # object
203
204 proc dcApi_getInfo {} {
205 return [$DcApi::self getInfo]
206 }
207
208 proc dcApi_clearPreviewPane {} {
209 return [$DcApi::self clearPreviewPane]
210 }
211
212 proc dcApi_clearBroadcastPane {} {
213 return [$DcApi::self clearBroadcastPane]
214 }
215
216 proc dcApi_getThumbnailInfo {} {
217 return [$DcApi::self getThumbnailInfo]
218 }
219
220 proc dcApi_getPreviewInfo {} {
221 return [$DcApi::self getPreviewInfo]
222 }
223
224 proc dcApi_getBroadcastInfo {} {
225 return [$DcApi::self getBroadcastInfo]
226 }
227
228 proc dcApi_previewThumbnail {uiThumbnail} {
229 return [$DcApi::self previewThumbnail $uiThumbnail]
230 }
231
232 proc dcApi_broadcastThumbnail {uiThumbnail} {
233 return [$DcApi::self broadcastThumbnail $uiThumbnail]
234 }
235
236 proc dcApi_removePreview {uiPreview} {
237 return [$DcApi::self removePreview $uiPreview]
238 }
239
240 proc dcApi_removeBroadcast {uiBroadcast} {
241 return [$DcApi::self removeBroadcast $uiBroadcast]
242 }
243
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.