|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @publishedAll |
|
19 @released |
|
20 */ |
|
21 |
|
22 #include <ecam/mcameraoverlay.h> |
|
23 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
24 #include <ecam/cameraoverlayconst.h> |
|
25 #endif |
|
26 #include "ecamversion.h" |
|
27 |
|
28 const TUint KBaselinedOverlayModeMask = (CCamera::CCameraOverlay::EModeVideo << 1) - 1; |
|
29 const TUint KOverlayGlobalStillMode = (CCamera::CCameraOverlay::EModeStillImageContinuous |
|
30 | CCamera::CCameraOverlay::EModeStillImageBracket |
|
31 | CCamera::CCameraOverlay::EModeStillImageBracketMerge |
|
32 | CCamera::CCameraOverlay::EModeStillImageTimed |
|
33 | CCamera::CCameraOverlay::EModeStillImageTimeLapse |
|
34 | CCamera::CCameraOverlay::EModeStillImageBurst); |
|
35 /** |
|
36 Factory function that creates a new camera overlay object on the heap. |
|
37 |
|
38 @param aCamera |
|
39 A reference to the camera object for which a camera overlay object is to be created. |
|
40 |
|
41 @leave KErrNoMemory if out of memory; also any system wide error. |
|
42 |
|
43 @return A pointer to the newly created camera overlay object. |
|
44 |
|
45 @note Clients using MCameraObserver are not recommended to use this extension class since they cannot handle events. |
|
46 */ |
|
47 |
|
48 EXPORT_C CCamera::CCameraOverlay* CCamera::CCameraOverlay::NewL(CCamera& aCamera) |
|
49 { |
|
50 CCamera::CCameraOverlay* self = new (ELeave) CCamera::CCameraOverlay(aCamera); |
|
51 CleanupStack::PushL(self); |
|
52 self->ConstructL(); |
|
53 CleanupStack::Pop(self); |
|
54 |
|
55 return self; |
|
56 } |
|
57 |
|
58 /** |
|
59 CCameraOverlay second phase constructor. |
|
60 |
|
61 This function used to initialise internal state of the object. |
|
62 It uses reference to the camera to retrieve overlay interface pointer. |
|
63 |
|
64 @leave KErrNotSupported if this functionality is not supported; also any system wide error. |
|
65 */ |
|
66 void CCamera::CCameraOverlay::ConstructL() |
|
67 { |
|
68 iImpl = static_cast<MCameraOverlay*>(iOwner.CustomInterface(KECamMCameraOverlayUid)); |
|
69 |
|
70 if (iImpl == NULL) |
|
71 { |
|
72 User::Leave(KErrNotSupported); |
|
73 } |
|
74 |
|
75 iImpl2 = static_cast<MCameraOverlay2*>(iOwner.CustomInterface(KECamMCameraOverlay2Uid)); |
|
76 } |
|
77 |
|
78 /** |
|
79 Constructor for the CCamera::CCameraOverlay class. |
|
80 |
|
81 @param aOwner |
|
82 A reference to the camera object for which a camera overlay object is to be created. |
|
83 */ |
|
84 CCamera::CCameraOverlay::CCameraOverlay(CCamera& aOwner):iOwner(aOwner), iImpl(NULL), iImpl2(NULL) |
|
85 { |
|
86 } |
|
87 |
|
88 /** |
|
89 Destructor for the CCamera::CCameraOverlay class. |
|
90 */ |
|
91 EXPORT_C CCamera::CCameraOverlay::~CCameraOverlay() |
|
92 { |
|
93 if (iImpl != NULL) |
|
94 { |
|
95 iImpl->Release(); |
|
96 } |
|
97 if (iImpl2 != NULL) |
|
98 { |
|
99 iImpl2->Release(); |
|
100 } |
|
101 } |
|
102 |
|
103 /** |
|
104 Creates an image overlay object on the ECam implementation, returning a handle to the newly created object. |
|
105 |
|
106 @param aParameters |
|
107 The parameters characterizing the overlay to be created. |
|
108 @param aBitmap |
|
109 The image that is to become the overlay. |
|
110 By default this is set to NULL, allowing the client to provide the image at some point after |
|
111 the overlay object has been created, by using SetOverlayBitmapL(). |
|
112 |
|
113 @leave KErrNoMemory if out of memory; also any system wide error. |
|
114 |
|
115 @leave KErrArgument if the member variables in TOverlayParameters are such that they create mutual exclusion. |
|
116 |
|
117 @return The overlay handle. |
|
118 */ |
|
119 EXPORT_C TUint CCamera::CCameraOverlay::CreateOverlayL(const TOverlayParameters& aParameters, CFbsBitmap* aBitmap) |
|
120 { |
|
121 CCamera::CCameraOverlay::TOverlayParameters overlayParameters = aParameters; |
|
122 if (aParameters.iCurrentModes & EModeViewfinder) |
|
123 { |
|
124 overlayParameters.iCurrentModes |= EModeClientViewfinder; |
|
125 overlayParameters.iCurrentModes |= EModeDirectViewfinder; |
|
126 } |
|
127 if (aParameters.iCurrentModes & EModeStillImage) |
|
128 { |
|
129 overlayParameters.iCurrentModes |= KOverlayGlobalStillMode; |
|
130 } |
|
131 return iImpl->CreateOverlayL(overlayParameters, aBitmap); |
|
132 } |
|
133 |
|
134 /** |
|
135 Allows the overlay image data to be changed for a specified overlay. |
|
136 Use this function to set the overlay image data if it was not specified when the overlay |
|
137 was created using CreateOverlayL(). |
|
138 |
|
139 @param aOverlayHandle |
|
140 The handle of the overlay whose overlay image data is to be changed. |
|
141 @param aBitmap |
|
142 The new image data for the overlay. |
|
143 |
|
144 @leave KErrArgument if aOverlayHandle is out of range; also any system wide error. |
|
145 |
|
146 @note Once this method is called, overlay size should not be changed for the given overlay. Hence, SetOverlayParametersL |
|
147 should not be called after this method. |
|
148 */ |
|
149 EXPORT_C void CCamera::CCameraOverlay::SetOverlayBitmapL(TUint aOverlayHandle, const CFbsBitmap* aBitmap) |
|
150 { |
|
151 iImpl->SetOverlayBitmapL(aOverlayHandle, aBitmap); |
|
152 } |
|
153 |
|
154 /** |
|
155 @publishedPartner |
|
156 @prototype |
|
157 |
|
158 Allows the overlay image data to be changed for a specified overlay. Ownership of the bitmap is passed to the |
|
159 implementation. |
|
160 Use this function to set the overlay image data if it was not specified when the overlay was created using |
|
161 CreateOverlayL(). |
|
162 |
|
163 @param aOverlayHandle |
|
164 The handle of the overlay whose overlay image data is to be changed. |
|
165 @param aBitmap |
|
166 The new image data for the overlay. |
|
167 |
|
168 @leave May leave with any error code. |
|
169 |
|
170 @note If required, implementation is free to modify the overlay bitmap passed to it. |
|
171 |
|
172 @note SetOverlayParametersL should not be called after this method for the given overlay since it may change the overlay |
|
173 parameters considerably. In such a case, SetOverlayParametersL may leave with error KErrArgument. |
|
174 */ |
|
175 EXPORT_C void CCamera::CCameraOverlay::SetModifiableOverlayBitmapL(TUint aOverlayHandle, CFbsBitmap* aBitmap) |
|
176 { |
|
177 if(iImpl2 != NULL) |
|
178 { |
|
179 iImpl2->SetModifiableOverlayBitmapL(aOverlayHandle, aBitmap); |
|
180 } |
|
181 else |
|
182 { |
|
183 User::Leave(KErrNotSupported); |
|
184 } |
|
185 } |
|
186 |
|
187 /** |
|
188 Gets the overlay image data for a specified overlay. |
|
189 |
|
190 @param aOverlayHandle |
|
191 The handle of the overlay whose overlay image data is to be obtained. |
|
192 @param aBitmap |
|
193 A CFbsBitmap that will receive the returned image data for the overlay. |
|
194 |
|
195 @leave KErrArgument if aOverlayHandle is out of range; also any system wide error. |
|
196 |
|
197 @leave KErrNotSupported if a sharing client (which did not create the given overlay) tries to retrieve the overlay bitmap |
|
198 and the implementation may not be interested in providing the overlay. |
|
199 |
|
200 @note The ECam implementation will transfer the ownership of the aBitmap to the client. |
|
201 */ |
|
202 EXPORT_C void CCamera::CCameraOverlay::GetOverlayBitmapL(TUint aOverlayHandle, CFbsBitmap* aBitmap) |
|
203 { |
|
204 iImpl->GetOverlayBitmapL(aOverlayHandle, aBitmap); |
|
205 } |
|
206 |
|
207 /** |
|
208 Gets the parameters that characterize a given overlay. |
|
209 |
|
210 @param aOverlayHandle |
|
211 The handle of the overlay whose parameters are required. |
|
212 @param aInfo |
|
213 Reference to TOverlayParameters object that will contain the returned overlay parameters. |
|
214 |
|
215 @leave KErrArgument if aOverlayHandle is out of range; also any system wide error. |
|
216 */ |
|
217 EXPORT_C void CCamera::CCameraOverlay::GetOverlayParametersL(TUint aOverlayHandle, TOverlayParameters& aInfo) |
|
218 { |
|
219 iImpl->GetOverlayParametersL(aOverlayHandle, aInfo); |
|
220 |
|
221 // for clients not using CCamera::New2L() turn new overlay modes into old ones |
|
222 if (iOwner.CameraVersion() == KCameraDefaultVersion) |
|
223 { |
|
224 // specific viewfinder modes into "old" EModeViewfinder |
|
225 if (aInfo.iCurrentModes & (EModeClientViewfinder | EModeDirectViewfinder)) |
|
226 { |
|
227 aInfo.iCurrentModes |= EModeViewfinder; |
|
228 } |
|
229 // turn different drive modes into "old" EModeStillImage |
|
230 if (aInfo.iCurrentModes & ( EModeStillImageContinuous | EModeStillImageBracket | |
|
231 EModeStillImageBracketMerge | EModeStillImageTimed | |
|
232 EModeStillImageTimeLapse | EModeStillImageBurst |
|
233 ) |
|
234 ) |
|
235 { |
|
236 aInfo.iCurrentModes |= EModeStillImage; |
|
237 } |
|
238 // for old clients we present only old set of features |
|
239 aInfo.iCurrentModes &= KBaselinedOverlayModeMask; |
|
240 } |
|
241 else |
|
242 { |
|
243 if (aInfo.iCurrentModes & EModeViewfinder) |
|
244 { |
|
245 aInfo.iCurrentModes |= EModeClientViewfinder; |
|
246 aInfo.iCurrentModes |= EModeDirectViewfinder; |
|
247 } |
|
248 if (aInfo.iCurrentModes & EModeStillImage) |
|
249 { |
|
250 aInfo.iCurrentModes |= KOverlayGlobalStillMode; |
|
251 } |
|
252 } |
|
253 } |
|
254 |
|
255 /** |
|
256 Sets new parameters that characterize a given overlay. |
|
257 |
|
258 @param aOverlayHandle |
|
259 The handle of the overlay whose parameters are to be changed. |
|
260 @param aParameters |
|
261 The new overlay parameters. |
|
262 |
|
263 @leave KErrNotSupported if TOverlayCameraMode passed in TOverlayParameters is not supported; |
|
264 also any system wide error. |
|
265 |
|
266 @leave KErrArgument if the member variables in TOverlayParameters are such that they create mutual exclusion. |
|
267 */ |
|
268 EXPORT_C void CCamera::CCameraOverlay::SetOverlayParametersL(TUint aOverlayHandle, const TOverlayParameters& aParameters) |
|
269 { |
|
270 CCamera::CCameraOverlay::TOverlayParameters overlayParameters = aParameters; |
|
271 if (aParameters.iCurrentModes & EModeViewfinder) |
|
272 { |
|
273 overlayParameters.iCurrentModes |= EModeClientViewfinder; |
|
274 overlayParameters.iCurrentModes |= EModeDirectViewfinder; |
|
275 } |
|
276 if (aParameters.iCurrentModes & EModeStillImage) |
|
277 { |
|
278 overlayParameters.iCurrentModes |= KOverlayGlobalStillMode; |
|
279 } |
|
280 |
|
281 iImpl->SetOverlayParametersL(aOverlayHandle, overlayParameters); |
|
282 } |
|
283 |
|
284 /** |
|
285 Releases the specified overlay handle. |
|
286 |
|
287 @note If the handle specified in aOverlayHandle is invalid (out of range) the function |
|
288 call is ignored and no error is reported. |
|
289 |
|
290 @param aOverlayHandle |
|
291 The handle of the overlay that is to be released. |
|
292 */ |
|
293 EXPORT_C void CCamera::CCameraOverlay::ReleaseOverlay(TUint aOverlayHandle) |
|
294 { |
|
295 iImpl->ReleaseOverlay(aOverlayHandle); |
|
296 } |
|
297 |
|
298 /** |
|
299 Gets information on the overlay functionality supported by the ECam implementation. |
|
300 |
|
301 @param aInfo |
|
302 A reference to a TOverlaySupportInfo object that will receive the overlay support information. |
|
303 */ |
|
304 EXPORT_C void CCamera::CCameraOverlay::GetOverlaySupport(TOverlaySupportInfo& aInfo) |
|
305 { |
|
306 iImpl->GetOverlaySupport(aInfo); |
|
307 // we hide new overlay modes for clients not using New2L()/NewDuplicate2L() |
|
308 if (iOwner.CameraVersion() == KCameraDefaultVersion) |
|
309 { |
|
310 aInfo.iSupportedModes &= KBaselinedOverlayModeMask; |
|
311 } |
|
312 else |
|
313 { |
|
314 if (aInfo.iSupportedModes & EModeViewfinder) |
|
315 { |
|
316 aInfo.iSupportedModes |= EModeClientViewfinder; |
|
317 aInfo.iSupportedModes |= EModeDirectViewfinder; |
|
318 } |
|
319 if (aInfo.iSupportedModes & EModeStillImage) |
|
320 { |
|
321 aInfo.iSupportedModes |= KOverlayGlobalStillMode; |
|
322 } |
|
323 } |
|
324 } |
|
325 |
|
326 /** |
|
327 Gets all the overlay handles maintained by the ECam implementation, in order of their Z-Value. |
|
328 |
|
329 @param aOverlayHandles |
|
330 Returned list, in Z-Value order, of all the overlay handles maintained on the ECam implementation. |
|
331 The topmost overlay is the first element of the array. |
|
332 |
|
333 @leave KErrNoMemory if out of memory; also any system wide error. |
|
334 |
|
335 @note Implementation shall give preference to the sequence in which the client has passed the overlay handles in case of |
|
336 any mis-match with the 'z-order' of each such overlay. Implementation shall amend the 'z-order' of the overlays if |
|
337 required to remove any ambiguity. |
|
338 */ |
|
339 EXPORT_C void CCamera::CCameraOverlay::GetAllOverlaysInZOrderL(RArray<TUint>& aOverlayHandles) |
|
340 { |
|
341 iImpl->GetAllOverlaysInZOrderL(aOverlayHandles); |
|
342 } |
|
343 |
|
344 /** |
|
345 Sets the Z-Order of all the overlay handles known by this CCameraOverlay object. |
|
346 |
|
347 @param aOverlayHandles |
|
348 The overlay handles in aOverlayHandles array. This must be the complete current set |
|
349 of handles known to this CCameraOverlay object. The client specifies the desired |
|
350 order by placing the topmost overlay in the first element of the array. |
|
351 |
|
352 @leave KErrNoMemory if out of memory; also any system wide error. |
|
353 |
|
354 @note Implementation shall give preference to the sequence in which the client has passed the overlay handles in case of |
|
355 any mis-match with the 'z-order' of each such overlay. Implementation shall amend the 'z-order' of the overlays if |
|
356 required to remove any ambiguity. |
|
357 */ |
|
358 EXPORT_C void CCamera::CCameraOverlay::SetAllOverlaysInZOrderL(const RArray<TUint>& aOverlayHandles) |
|
359 { |
|
360 iImpl->SetAllOverlaysInZOrderL(aOverlayHandles); |
|
361 } |
|
362 |
|
363 /** |
|
364 Constructor for the TOverlaySupportInfo class. |
|
365 */ |
|
366 EXPORT_C CCamera::CCameraOverlay::TOverlaySupportInfo::TOverlaySupportInfo() |
|
367 { |
|
368 iDesiredCameraMode = CCamera::CCameraOverlay::EModeNone; |
|
369 iViewFinderHandle = KECamOverlayInvalidViewFinderHandle; |
|
370 } |
|
371 |
|
372 /** |
|
373 Returns the size of the class. Used for extensibility by deriving from this base class and adding new member variables. |
|
374 Intended to be used for implementation of methods where this class reference is passed as function arguments. |
|
375 Implementation of such methods can find out the whether the actual class passed is base or the derived one. So, if a new application |
|
376 is made to run on an old implementation, an error may occur once the old implementation detects this by getting |
|
377 the size information of the T class passed. Also, if an old application is made to run on a new implementation, this can be |
|
378 corrrectly handled if the derived class variables handling is done in a proper 'if-else' statement. |
|
379 |
|
380 @return The size of the class. |
|
381 |
|
382 @note The size will be modified when the T-class gets updated. |
|
383 */ |
|
384 EXPORT_C TUint CCamera::CCameraOverlay::TOverlaySupportInfo::Size() const |
|
385 { |
|
386 return sizeof(CCamera::CCameraOverlay::TOverlaySupportInfo); |
|
387 } |
|
388 |
|
389 /** |
|
390 Returns the version of the class. Used for extensibility specially when the class members are not added but the Reserved |
|
391 members get used at a later stage. |
|
392 |
|
393 @return The version of the class. |
|
394 |
|
395 @note The version will be modified when the T-class gets updated. |
|
396 */ |
|
397 EXPORT_C TUint CCamera::CCameraOverlay::TOverlaySupportInfo::Version() const |
|
398 { |
|
399 return KECamOverlaySupportInfoCurrentVersion; |
|
400 } |
|
401 |
|
402 /** |
|
403 Constructor for the TOverlayParameters class. |
|
404 */ |
|
405 EXPORT_C CCamera::CCameraOverlay::TOverlayParameters::TOverlayParameters() |
|
406 { |
|
407 iViewFinderHandle = KECamOverlayInvalidViewFinderHandle; |
|
408 } |
|
409 |
|
410 /** |
|
411 Returns the size of the class. Used for extensibility by deriving from this base class and adding new member variables. |
|
412 Intended to be used for implementation of methods where this class reference is passed as function arguments. |
|
413 Implementation of such methods can find out the whether the actual class passed is base or the derived one. So, if a new application |
|
414 is made to run on an old implementation, an error may occur once the old implementation detects this by getting |
|
415 the size information of the T class passed. Also, if an old application is made to run on a new implementation, this can be |
|
416 corrrectly handled if the derived class variables handling is done in a proper 'if-else' statement. |
|
417 |
|
418 @return The size of the class. |
|
419 |
|
420 @note The size will be modified when the T-class gets updated. |
|
421 */ |
|
422 EXPORT_C TUint CCamera::CCameraOverlay::TOverlayParameters::Size() const |
|
423 { |
|
424 return sizeof(CCamera::CCameraOverlay::TOverlayParameters); |
|
425 } |
|
426 |
|
427 /** |
|
428 Returns the version of the class. Used for extensibility specially when the class members are not added but the Reserved |
|
429 members get used at a later stage. |
|
430 |
|
431 @return The version of the class. |
|
432 |
|
433 @note The version will be modified when the T-class gets updated. |
|
434 */ |
|
435 EXPORT_C TUint CCamera::CCameraOverlay::TOverlayParameters::Version() const |
|
436 { |
|
437 return KECamOverlayParametersCurrentVersion; |
|
438 } |
|
439 |
|
440 /** |
|
441 @publishedPartner |
|
442 @prototype |
|
443 |
|
444 Gets all the overlay handles maintained by the ECam implementation, in order of their z-value, for a particular camera mode. |
|
445 If for viewfinder, then the handle number is used to get the z-value for the viewfinder whose handle number is passed. |
|
446 |
|
447 @param aOverlayCameraMode |
|
448 The specific camera mode whose overlays' z-value information is required. |
|
449 |
|
450 @param aViewFinderHandle |
|
451 The specific viewfinder handle, if overlays' z-value information is required for viewfinder camera mode. |
|
452 |
|
453 @param aOverlayHandles |
|
454 Returned list, in z-value order, of all the overlay handles maintained on the ECam implementation. |
|
455 The topmost overlay is the first element of the array. |
|
456 |
|
457 @leave May leave with any error code. |
|
458 |
|
459 @note Implementation shall give preference to the sequence in which the client has passed the overlay handles in case of |
|
460 any mis-match with the 'z-order' of each such overlay. Implementation shall amend the 'z-order' of the overlays if |
|
461 required to remove any ambiguity. |
|
462 */ |
|
463 EXPORT_C void CCamera::CCameraOverlay::GetAllOverlaysInZOrderL(CCamera::CCameraOverlay::TOverlayCameraMode aOverlayCameraMode, TInt aViewFinderHandle, RArray<TUint>& aOverlayHandles) const |
|
464 { |
|
465 if(iImpl2 != NULL) |
|
466 { |
|
467 iImpl2->GetAllOverlaysInZOrderL(aOverlayCameraMode, aViewFinderHandle, aOverlayHandles); |
|
468 } |
|
469 else |
|
470 { |
|
471 User::Leave(KErrNotSupported); |
|
472 } |
|
473 } |
|
474 |
|
475 /** |
|
476 @publishedPartner |
|
477 @prototype |
|
478 |
|
479 Sets all the overlay handles maintained by the ECam implementation, in order of their z-value for a particular camera mode. |
|
480 If for viewfinder, then the handle number is used to set the z-value for the viewfinder whose handle number is passed. |
|
481 |
|
482 @param aOverlayCameraMode |
|
483 The specific camera mode whose overlays' z-value is to be set. |
|
484 |
|
485 @param aViewFinderHandle |
|
486 The specific viewfinder handle, if overlays' z-value is required to be set for viewfinder camera mode. |
|
487 |
|
488 @param aOverlayHandles |
|
489 The overlay handles in aOverlayHandles array. This must be the complete current set |
|
490 of handles known to this CCameraOverlay object for the given camera mode (and for the given viewfinder, if applicable). |
|
491 The client specifies the desired order by placing the topmost overlay in the first element of the array. |
|
492 |
|
493 @leave May leave with any error code. |
|
494 |
|
495 @note Implementation shall give preference to the sequence in which the client has passed the overlay handles in case of |
|
496 any mis-match with the 'z-order' of each such overlay. Implementation shall amend the 'z-order' of the overlays if |
|
497 required to remove any ambiguity. |
|
498 */ |
|
499 EXPORT_C void CCamera::CCameraOverlay::SetAllOverlaysInZOrderL(CCamera::CCameraOverlay::TOverlayCameraMode aOverlayCameraMode, TInt aViewFinderHandle, const RArray<TUint>& aOverlayHandles) |
|
500 { |
|
501 if(iImpl2 != NULL) |
|
502 { |
|
503 iImpl2->SetAllOverlaysInZOrderL(aOverlayCameraMode, aViewFinderHandle, aOverlayHandles); |
|
504 } |
|
505 else |
|
506 { |
|
507 User::Leave(KErrNotSupported); |
|
508 } |
|
509 } |