|
1 /* |
|
2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include "mcespeakersink.h" |
|
22 #include "mcecomspeakersink.h" |
|
23 #include "mcesession.h" |
|
24 #include "mcemediastream.h" |
|
25 #include "mceitcsender.h" |
|
26 #include "mceavsink.h" |
|
27 #include "mceclilogs.h" |
|
28 #include "mcemanager.h" |
|
29 |
|
30 |
|
31 #define _FLAT_DATA static_cast<CMceComSpeakerSink*>( iFlatData ) |
|
32 #define FLAT_DATA( data ) _FLAT_DATA->data |
|
33 |
|
34 // ============================ MEMBER FUNCTIONS =============================== |
|
35 |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CMceSpeakerSink::NewL |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 EXPORT_C CMceSpeakerSink* CMceSpeakerSink::NewL() |
|
42 { |
|
43 CMceSpeakerSink* self = NewLC(); |
|
44 CleanupStack::Pop( self ); |
|
45 return self; |
|
46 } |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CMceSpeakerSink::NewLC |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 EXPORT_C CMceSpeakerSink* CMceSpeakerSink::NewLC() |
|
53 { |
|
54 CMceSpeakerSink* self = new (ELeave) CMceSpeakerSink(); |
|
55 CleanupStack::PushL( self ); |
|
56 self->ConstructL(); |
|
57 return self; |
|
58 |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CMceSpeakerSink::~CMceSpeakerSink |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 EXPORT_C CMceSpeakerSink::~CMceSpeakerSink() |
|
66 { |
|
67 if ( iEndpointProxy ) |
|
68 { |
|
69 CMceAvSink* endpointProxy = static_cast<CMceAvSink*>( iEndpointProxy ); |
|
70 endpointProxy->RemoveProxyClient( *this ); |
|
71 if ( endpointProxy->ReferenceCount() == 0 ) |
|
72 { |
|
73 delete endpointProxy; |
|
74 } |
|
75 iEndpointProxy = NULL; |
|
76 } |
|
77 } |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // CMceSpeakerSink::EnableL |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 EXPORT_C void CMceSpeakerSink::EnableL() |
|
84 { |
|
85 MCECLI_DEBUG("CMceSpeakerSink::EnableL, Entry"); |
|
86 |
|
87 CMceMediaSink::DoEnableL(); |
|
88 |
|
89 MCECLI_DEBUG("CMceSpeakerSink::EnableL, Exit"); |
|
90 |
|
91 } |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // CMceSpeakerSink::Disable |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 EXPORT_C void CMceSpeakerSink::DisableL() |
|
98 { |
|
99 MCECLI_DEBUG("CMceSpeakerSink::DisableL, Entry"); |
|
100 |
|
101 CMceMediaSink::DoDisableL(); |
|
102 |
|
103 MCECLI_DEBUG("CMceSpeakerSink::DisableL, Exit"); |
|
104 } |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CMceSpeakerSink::SetVolumeL |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 EXPORT_C void CMceSpeakerSink::SetVolumeL( TInt aVolume ) |
|
111 { |
|
112 MCECLI_DEBUG("CMceSpeakerSink::SetVolumeL, Entry"); |
|
113 MCECLI_DEBUG_DVALUE("volume", aVolume ); |
|
114 |
|
115 if ( MCE_ENDPOINT_ITC_ALLOWED( *this ) ) |
|
116 { |
|
117 CMceSession* session = iStream->Session(); |
|
118 |
|
119 TMceIds ids; |
|
120 session->PrepareForITC( ids ); |
|
121 ids.iMediaID = iStream->Id(); |
|
122 ids.iSinkID = Id(); |
|
123 |
|
124 TMceItcArgTInt volume( aVolume ); |
|
125 |
|
126 session->ITCSender().WriteL( ids, EMceItcSetVolume, volume ); |
|
127 } |
|
128 else |
|
129 { |
|
130 //NOP |
|
131 MCECLI_DEBUG("CMceSpeakerSink::SetVolumeL, done locally"); |
|
132 } |
|
133 |
|
134 FLAT_DATA( iVolume ) = aVolume; |
|
135 |
|
136 MCECLI_DEBUG("CMceSpeakerSink::SetVolumeL, Exit"); |
|
137 |
|
138 } |
|
139 |
|
140 // ----------------------------------------------------------------------------- |
|
141 // CMceSpeakerSink::VolumeL |
|
142 // ----------------------------------------------------------------------------- |
|
143 // |
|
144 EXPORT_C TInt CMceSpeakerSink::VolumeL() const |
|
145 { |
|
146 MCECLI_DEBUG("CMceSpeakerSink::VolumeL, Entry"); |
|
147 |
|
148 TInt volume( 0 ); |
|
149 |
|
150 if ( MCE_ENDPOINT_ITC_ALLOWED( *this ) ) |
|
151 { |
|
152 CMceSession* session = iStream->Session(); |
|
153 |
|
154 TMceIds ids; |
|
155 session->PrepareForITC( ids ); |
|
156 ids.iMediaID = iStream->Id(); |
|
157 ids.iSinkID = Id(); |
|
158 |
|
159 TMceItcArgTInt volumeArg; |
|
160 |
|
161 session->ITCSender().ReadL( ids, EMceItcVolume, volumeArg ); |
|
162 |
|
163 volume = volumeArg(); |
|
164 } |
|
165 else |
|
166 { |
|
167 volume = FLAT_DATA( iVolume ); |
|
168 } |
|
169 |
|
170 MCECLI_DEBUG("CMceSpeakerSink::VolumeL, Exit"); |
|
171 |
|
172 return volume; |
|
173 } |
|
174 |
|
175 // ----------------------------------------------------------------------------- |
|
176 // CMceSpeakerSink::MaxVolumeL |
|
177 // ----------------------------------------------------------------------------- |
|
178 // |
|
179 EXPORT_C TInt CMceSpeakerSink::MaxVolumeL() const |
|
180 { |
|
181 MCECLI_DEBUG("CMceSpeakerSink::MaxVolumeL"); |
|
182 |
|
183 TMceItcArgTInt maxVolume; |
|
184 |
|
185 if ( iStream && iStream->Session() && &iStream->Session()->Manager() ) |
|
186 { |
|
187 CMceManager& manager = iStream->Session()->Manager(); |
|
188 TMceIds ids; |
|
189 ids.iAppUID = manager.AppUid().iUid; |
|
190 _FLAT_DATA->SenderL( |
|
191 manager.ServerSession() ).ReadL( ids, EMceItcMaxVolume, maxVolume ); |
|
192 } |
|
193 else |
|
194 { |
|
195 MCECLI_DEBUG("CMceSpeakerSink::MaxVolumeL, not ready"); |
|
196 User::Leave( KErrNotReady ); |
|
197 } |
|
198 |
|
199 // If volume is not set, set it to half of the max volume |
|
200 if ( FLAT_DATA( iVolume ) == KMceNotAssignedInt ) |
|
201 { |
|
202 const TInt KMceVolumeDivider = 2; |
|
203 FLAT_DATA( iVolume ) = ( maxVolume() / KMceVolumeDivider ); |
|
204 } |
|
205 |
|
206 return maxVolume(); |
|
207 } |
|
208 |
|
209 // ----------------------------------------------------------------------------- |
|
210 // CMceSpeakerSink::SetRoutingL |
|
211 // ----------------------------------------------------------------------------- |
|
212 // |
|
213 EXPORT_C void CMceSpeakerSink::SetRoutingL( TInt aRoute ) |
|
214 { |
|
215 MCECLI_DEBUG("CMceSpeakerSink::SetRoutingL, Entry"); |
|
216 MCECLI_DEBUG_DVALUE("route", aRoute ); |
|
217 |
|
218 if ( MCE_ENDPOINT_ITC_ALLOWED( *this ) ) |
|
219 { |
|
220 CMceSession* session = iStream->Session(); |
|
221 |
|
222 TMceIds ids; |
|
223 session->PrepareForITC( ids ); |
|
224 ids.iMediaID = iStream->Id(); |
|
225 ids.iSinkID = Id(); |
|
226 |
|
227 TMceItcArgTInt route( aRoute ); |
|
228 |
|
229 session->ITCSender().WriteL( ids, EMceItcSetAudioRouting, route ); |
|
230 } |
|
231 else |
|
232 { |
|
233 //NOP |
|
234 MCECLI_DEBUG("CMceSpeakerSink::SetRoutingL, done locally"); |
|
235 } |
|
236 |
|
237 FLAT_DATA( iAudioRoute ) = aRoute; |
|
238 |
|
239 MCECLI_DEBUG("CMceSpeakerSink::SetRoutingL, Exit"); |
|
240 |
|
241 } |
|
242 |
|
243 // ----------------------------------------------------------------------------- |
|
244 // CMceSpeakerSink::RoutingL |
|
245 // ----------------------------------------------------------------------------- |
|
246 // |
|
247 EXPORT_C TInt CMceSpeakerSink::RoutingL() const |
|
248 { |
|
249 MCECLI_DEBUG("CMceSpeakerSink::RoutingL, Entry"); |
|
250 |
|
251 TInt route( 0 ); |
|
252 |
|
253 if ( MCE_ENDPOINT_ITC_ALLOWED( *this ) ) |
|
254 { |
|
255 CMceSession* session = iStream->Session(); |
|
256 |
|
257 TMceIds ids; |
|
258 session->PrepareForITC( ids ); |
|
259 ids.iMediaID = iStream->Id(); |
|
260 ids.iSinkID = Id(); |
|
261 |
|
262 TMceItcArgTInt routeArg; |
|
263 |
|
264 session->ITCSender().ReadL( ids, EMceItcAudioRouting, routeArg ); |
|
265 |
|
266 route = routeArg(); |
|
267 } |
|
268 else |
|
269 { |
|
270 route = FLAT_DATA( iAudioRoute ); |
|
271 } |
|
272 |
|
273 MCECLI_DEBUG("CMceSpeakerSink::RoutingL, Exit"); |
|
274 |
|
275 return route; |
|
276 } |
|
277 |
|
278 // ----------------------------------------------------------------------------- |
|
279 // CMceSpeakerSink::UsesEndpointProxy() |
|
280 // ----------------------------------------------------------------------------- |
|
281 // |
|
282 TBool CMceSpeakerSink::UsesEndpointProxy() const |
|
283 { |
|
284 return ETrue; |
|
285 } |
|
286 |
|
287 // ----------------------------------------------------------------------------- |
|
288 // CMceSpeakerSink::CreateEndpointProxyL() |
|
289 // ----------------------------------------------------------------------------- |
|
290 // |
|
291 MMceEndPointProxy* CMceSpeakerSink::CreateEndpointProxyL() const |
|
292 { |
|
293 return CMceAvSink::NewL(); |
|
294 } |
|
295 |
|
296 // ----------------------------------------------------------------------------- |
|
297 // CMceSpeakerSink::CMceSpeakerSink |
|
298 // ----------------------------------------------------------------------------- |
|
299 // |
|
300 CMceSpeakerSink::CMceSpeakerSink() |
|
301 { |
|
302 } |
|
303 |
|
304 // ----------------------------------------------------------------------------- |
|
305 // CMceSpeakerSink::ConstructL |
|
306 // ----------------------------------------------------------------------------- |
|
307 // |
|
308 void CMceSpeakerSink::ConstructL() |
|
309 { |
|
310 CMceComSpeakerSink* sink = CMceComSpeakerSink::NewLC(); |
|
311 CMceMediaSink::ConstructL( sink ); |
|
312 CleanupStack::Pop( sink ); |
|
313 } |
|
314 |
|
315 |