|
1 /* |
|
2 * Copyright (c) 2004 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: Implementation of the VtUiUtility class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "VtUiUtility.h" |
|
22 #include "VtUiPanic.h" |
|
23 #include <featmgr.h> |
|
24 #include <mvtengmedia.h> |
|
25 #include <cvtlogger.h> |
|
26 #include <aknutils.h> |
|
27 #include "tVtuifeaturevariation.h" |
|
28 |
|
29 // Characters to open number entry. |
|
30 _LIT( KVtUiDTMFCharacters, "0123456789*#" ); |
|
31 |
|
32 // ============================ MEMBER FUNCTIONS =============================== |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // VtUiUtility::GetAudioRoutingAvailability |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 void VtUiUtility::GetAudioRoutingAvailability( |
|
39 MVtEngAudio& aAudio, |
|
40 TInt& aAvailable ) |
|
41 { |
|
42 aAvailable = 0; |
|
43 TVtUiBTVariation btvariation; |
|
44 const TBool bluetoothAudioSupported = |
|
45 btvariation.IsBTSupported(); |
|
46 |
|
47 MVtEngAudio::TAudioRoutingState routingState; |
|
48 if ( aAudio.GetRoutingState( routingState ) == KErrNone ) |
|
49 { |
|
50 // Deactivate BT handsfree. |
|
51 if ( bluetoothAudioSupported && |
|
52 IsAudioRoutingAvailable( |
|
53 aAudio, |
|
54 routingState, |
|
55 MVtEngAudio::EAudioBT, |
|
56 MVtEngAudio::EAudioHandset ) ) |
|
57 { |
|
58 aAvailable |= EDeactivateBtHandsfree; |
|
59 } |
|
60 |
|
61 // Activate BT handsfree. |
|
62 if ( bluetoothAudioSupported && |
|
63 ( IsAudioRoutingAvailable( |
|
64 aAudio, |
|
65 routingState, |
|
66 MVtEngAudio::EAudioHandset, |
|
67 MVtEngAudio::EAudioBT ) || |
|
68 IsAudioRoutingAvailable( |
|
69 aAudio, |
|
70 routingState, |
|
71 MVtEngAudio::EAudioLoudspeaker, |
|
72 MVtEngAudio::EAudioBT ) ) ) |
|
73 { |
|
74 aAvailable |= EActivateBtHandsfree; |
|
75 } |
|
76 |
|
77 // Deactivate loudspeaker |
|
78 if ( IsAudioRoutingAvailable( |
|
79 aAudio, |
|
80 routingState, |
|
81 MVtEngAudio::EAudioLoudspeaker, |
|
82 MVtEngAudio::EAudioHandset ) ) |
|
83 { |
|
84 aAvailable |= EDeactivateLoudspeaker; |
|
85 } |
|
86 |
|
87 // Activate loudspeaker |
|
88 if ( IsAudioRoutingAvailable( |
|
89 aAudio, |
|
90 routingState, |
|
91 MVtEngAudio::EAudioHandset, |
|
92 MVtEngAudio::EAudioLoudspeaker ) || |
|
93 ( bluetoothAudioSupported && |
|
94 IsAudioRoutingAvailable( |
|
95 aAudio, |
|
96 routingState, |
|
97 MVtEngAudio::EAudioBT, |
|
98 MVtEngAudio::EAudioLoudspeaker ) ) ) |
|
99 { |
|
100 aAvailable |= EActivateLoudspeaker; |
|
101 } |
|
102 } |
|
103 } |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // VtUiUtility::GetOutgoingMediaState |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 void VtUiUtility::GetOutgoingMediaState( |
|
110 MVtEngMedia& aMedia, |
|
111 TInt& aAvailable ) |
|
112 { |
|
113 TInt outgoingMediaState; |
|
114 const TInt err = |
|
115 aMedia.GetMediaState( |
|
116 MVtEngMedia::EMediaOutgoing, |
|
117 outgoingMediaState ); |
|
118 if ( err == KErrNone ) |
|
119 { |
|
120 // If source is still image, then video sending is off. |
|
121 MVtEngMedia::TMediaSource source; |
|
122 if ( aMedia.GetSource( source ) == KErrNone ) |
|
123 { |
|
124 if ( source == MVtEngMedia::EMediaStillImage ) |
|
125 { |
|
126 outgoingMediaState &= ~MVtEngMedia::EMediaVideo; |
|
127 } |
|
128 } |
|
129 TBool freezeSupported; |
|
130 if( aMedia.GetFreezeSupported( freezeSupported ) == KErrNone ) |
|
131 { |
|
132 TBool isFrozen; |
|
133 if( freezeSupported && aMedia.GetFreezeState( isFrozen ) == KErrNone ) |
|
134 { |
|
135 if( isFrozen ) |
|
136 { |
|
137 outgoingMediaState &= ~MVtEngMedia::EMediaVideo; |
|
138 } |
|
139 } |
|
140 } |
|
141 } |
|
142 else |
|
143 { |
|
144 outgoingMediaState = |
|
145 ( MVtEngMedia::EMediaAudio | MVtEngMedia::EMediaVideo ); |
|
146 } |
|
147 aAvailable = outgoingMediaState; |
|
148 } |
|
149 |
|
150 // ----------------------------------------------------------------------------- |
|
151 // VtUiUtility::GetIncomingMediaState |
|
152 // ----------------------------------------------------------------------------- |
|
153 // |
|
154 void VtUiUtility::GetIncomingMediaState( |
|
155 MVtEngMedia& aMedia, |
|
156 TInt& aAvailable ) |
|
157 { |
|
158 TInt mediaState; |
|
159 const TInt err = |
|
160 aMedia.GetMediaState( |
|
161 MVtEngMedia::EMediaIncoming, |
|
162 mediaState ); |
|
163 if ( err != KErrNone ) |
|
164 { |
|
165 mediaState = |
|
166 ( MVtEngMedia::EMediaAudio | MVtEngMedia::EMediaVideo ); |
|
167 } |
|
168 |
|
169 aAvailable = mediaState; |
|
170 } |
|
171 |
|
172 // ----------------------------------------------------------------------------- |
|
173 // VtUiUtility::HasStillImage |
|
174 // ----------------------------------------------------------------------------- |
|
175 // |
|
176 TBool VtUiUtility::HasStillImage( |
|
177 MVtEngMedia& aMedia ) |
|
178 { |
|
179 TInt caps; |
|
180 const TInt capsErr = aMedia.GetSourcesCaps( caps ); |
|
181 return ( capsErr == KErrNone ) && |
|
182 ( caps & MVtEngMedia::ESourceCapsStillImage ); |
|
183 } |
|
184 |
|
185 // ----------------------------------------------------------------------------- |
|
186 // VtUiUtility::GetFreezeState |
|
187 // ----------------------------------------------------------------------------- |
|
188 // |
|
189 TBool VtUiUtility::GetFreezeState( |
|
190 MVtEngMedia& aMedia ) |
|
191 { |
|
192 TBool isFrozen; |
|
193 const TInt err = aMedia.GetFreezeState( isFrozen ); |
|
194 if ( err == KErrNone ) |
|
195 { |
|
196 return isFrozen; |
|
197 } |
|
198 else //provider was not ready |
|
199 { |
|
200 return EFalse; |
|
201 } |
|
202 } |
|
203 |
|
204 // ----------------------------------------------------------------------------- |
|
205 // VtUiUtility::IsFreezeSupported |
|
206 // ----------------------------------------------------------------------------- |
|
207 // |
|
208 TBool VtUiUtility::IsFreezeSupported( |
|
209 MVtEngMedia& aMedia ) |
|
210 { |
|
211 TBool isFreezeSupported; |
|
212 const TInt err = aMedia.GetFreezeSupported( isFreezeSupported ); |
|
213 if ( err == KErrNone ) |
|
214 { |
|
215 return isFreezeSupported; |
|
216 } |
|
217 else //provider was not ready |
|
218 { |
|
219 return EFalse; |
|
220 } |
|
221 } |
|
222 |
|
223 // ----------------------------------------------------------------------------- |
|
224 // VtUiUtility::GetVideoQuality |
|
225 // ----------------------------------------------------------------------------- |
|
226 // |
|
227 void VtUiUtility::GetVideoQuality( |
|
228 MVtEngMedia& aMedia, |
|
229 MVtEngMedia::TVideoQuality& aVideoQuality ) |
|
230 { |
|
231 aMedia.GetVideoQuality( aVideoQuality ); |
|
232 } |
|
233 |
|
234 // ----------------------------------------------------------------------------- |
|
235 // VtUiUtility::GetObjectSharingState |
|
236 // ----------------------------------------------------------------------------- |
|
237 // |
|
238 void VtUiUtility::GetObjectSharingState( |
|
239 MVtEngMedia& aMedia, |
|
240 MVtEngMedia::TShareObjectState& aShareObjectState ) |
|
241 { |
|
242 aMedia.GetObjectSharingState( aShareObjectState ); |
|
243 } |
|
244 |
|
245 |
|
246 // ----------------------------------------------------------------------------- |
|
247 // VtUiUtility::IsZoomAllowed |
|
248 // ----------------------------------------------------------------------------- |
|
249 // |
|
250 TBool VtUiUtility::IsZoomAllowed( |
|
251 MVtEngMedia& aMedia ) |
|
252 { |
|
253 TBool result = EFalse; |
|
254 |
|
255 TInt currentStep; |
|
256 if ( aMedia.GetCurrentZoomStep( currentStep ) == KErrNone ) |
|
257 { |
|
258 TInt max; |
|
259 if ( aMedia.GetMaxZoomStep( max ) == KErrNone ) |
|
260 { |
|
261 // Zooming is allowed if maximum zoom step is greater than |
|
262 // zero and camera is in use (and not still image / none). |
|
263 TInt avail; |
|
264 GetOutgoingMediaState( aMedia, avail ); |
|
265 |
|
266 result = ( max > 0 ) && ( avail & MVtEngMedia::EMediaVideo ); |
|
267 } |
|
268 } |
|
269 |
|
270 __VTPRINT2( DEBUG_GEN, "Ui.AllowZoom.%d", result ) |
|
271 return result; |
|
272 } |
|
273 |
|
274 // ----------------------------------------------------------------------------- |
|
275 // VtUiUtility::HasCameras |
|
276 // ----------------------------------------------------------------------------- |
|
277 // |
|
278 TBool VtUiUtility::HasCameras( MVtEngMedia& aMedia ) |
|
279 { |
|
280 TInt sourceCaps; |
|
281 if ( aMedia.GetSourcesCaps( sourceCaps ) != KErrNone ) |
|
282 { |
|
283 sourceCaps = 0; |
|
284 } |
|
285 return ( sourceCaps & MVtEngMedia::ESourceCapsPrimaryCamera ) || |
|
286 ( sourceCaps & MVtEngMedia::ESourceCapsSecondaryCamera ); |
|
287 } |
|
288 |
|
289 // ----------------------------------------------------------------------------- |
|
290 // VtUiUtility::IsAudioRoutingAvailable |
|
291 // ----------------------------------------------------------------------------- |
|
292 // |
|
293 TBool VtUiUtility::IsAudioRoutingAvailable( |
|
294 MVtEngAudio& aAudio, |
|
295 const MVtEngAudio::TAudioRoutingState aCurrent, |
|
296 const MVtEngAudio::TAudioRoutingState aSource, |
|
297 const MVtEngAudio::TAudioRoutingState aTarget ) |
|
298 { |
|
299 TBool result = EFalse; |
|
300 if ( aCurrent == aSource ) |
|
301 { |
|
302 TBool available = EFalse; |
|
303 TInt err = aAudio.GetRoutingAvailability( aTarget, available ); |
|
304 |
|
305 result = ( ( err == KErrNone ) && ( available ) ); |
|
306 } |
|
307 |
|
308 return result; |
|
309 } |
|
310 |
|
311 |
|
312 // ----------------------------------------------------------------------------- |
|
313 // VtUiUtility::IsDTMFEvent |
|
314 // ----------------------------------------------------------------------------- |
|
315 // |
|
316 TBool VtUiUtility::IsDTMFEvent( const TKeyEvent& aKeyEvent, TChar& aDtmfTone ) |
|
317 { |
|
318 TBuf<1> buffer; // one character |
|
319 buffer.Append( aKeyEvent.iCode ); |
|
320 AknTextUtils::ConvertDigitsTo( buffer, EDigitTypeWestern ); |
|
321 aDtmfTone = buffer[ 0 ]; |
|
322 return |
|
323 ( KVtUiDTMFCharacters().Locate( buffer[ 0 ] ) != KErrNotFound ); |
|
324 } |
|
325 |
|
326 // ----------------------------------------------------------------------------- |
|
327 // VtUiUtility::IsDTMFCharacter |
|
328 // ----------------------------------------------------------------------------- |
|
329 // |
|
330 TBool VtUiUtility::IsDTMFCharacter( const TChar aChar ) |
|
331 { |
|
332 return |
|
333 ( KVtUiDTMFCharacters().Locate( aChar ) != KErrNotFound ); |
|
334 } |
|
335 |
|
336 // End of File |