54
|
1 |
/*
|
|
2 |
* Copyright (c) 2007-2010 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: Implemantation of CCamSnapshot class.
|
|
15 |
* Temporary own implementation of MCameraSnapshot.
|
|
16 |
* To be replaced by ECam CCamera::CCameraSnapshot.
|
|
17 |
*
|
|
18 |
*/
|
|
19 |
|
|
20 |
|
|
21 |
#include "camcameracontrollerflags.hrh"
|
|
22 |
|
|
23 |
#include <e32base.h>
|
|
24 |
#include <fbs.h>
|
|
25 |
|
|
26 |
#include <ecam/camerasnapshot.h>
|
|
27 |
|
|
28 |
#include "camlogging.h"
|
|
29 |
#include "mcamcameraobserver.h"
|
|
30 |
#include "camcameraevents.h"
|
|
31 |
#include "cambuffer.h"
|
|
32 |
#include "cambuffershare.h"
|
|
33 |
#include "camimagedecoder.h"
|
|
34 |
#include "cambitmapscaler.h"
|
|
35 |
#include "camsnapshot.h"
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
// ===========================================================================
|
|
43 |
// Local constants
|
|
44 |
static const TPoint KDefaultPosition = TPoint(0,0);
|
|
45 |
static const TRgb KDefaultBackgroudColor = KRgbWhite;
|
|
46 |
static const TUint32 KSupportedSnapshotFormats =
|
|
47 |
( CCamera::EFormatFbsBitmapColor4K
|
|
48 |
| CCamera::EFormatFbsBitmapColor64K
|
|
49 |
| CCamera::EFormatFbsBitmapColor16M
|
|
50 |
| CCamera::EFormatFbsBitmapColor16MU
|
|
51 |
);
|
|
52 |
static const TInt KCallbackPriority = CActive::EPriorityIdle;
|
|
53 |
|
|
54 |
static const TUint KEventInterest = ( ECamCameraEventClassImage
|
|
55 |
| ECamCameraEventClassVideo
|
|
56 |
| ECamCameraEventClassVfData
|
|
57 |
);
|
|
58 |
|
|
59 |
// ===========================================================================
|
|
60 |
// Local methods
|
|
61 |
|
|
62 |
#ifndef CAMERAAPP_CAPI_V2
|
|
63 |
|
|
64 |
// Not needed when new CAPI support ready.
|
|
65 |
TECAMEvent::TECAMEvent( TUid aEventType,
|
|
66 |
TInt aErrorCode )
|
|
67 |
: iErrorCode( aErrorCode )
|
|
68 |
{
|
|
69 |
iEventType.iUid = aEventType.iUid;
|
|
70 |
#pragma message("camsnapshot.cpp, temporarily define TECAMEvent constructor")
|
|
71 |
}
|
|
72 |
#endif
|
|
73 |
|
|
74 |
|
|
75 |
#include "campointerutility.inl"
|
|
76 |
using namespace NCamCameraController;
|
|
77 |
|
|
78 |
|
|
79 |
// ===========================================================================
|
|
80 |
// public constructors and destructor
|
|
81 |
|
|
82 |
// ---------------------------------------------------------------------------
|
|
83 |
// static 2-phase constructor
|
|
84 |
// ---------------------------------------------------------------------------
|
|
85 |
//
|
|
86 |
CCamSnapshot*
|
|
87 |
CCamSnapshot::NewL( CCamera& aCamera,
|
|
88 |
MCameraObserver2& aObserver,
|
|
89 |
MCamCameraObservable& aObservable )
|
|
90 |
{
|
|
91 |
CCamSnapshot* self =
|
|
92 |
new (ELeave) CCamSnapshot( aCamera, aObserver, aObservable );
|
|
93 |
|
|
94 |
CleanupStack::PushL( self );
|
|
95 |
self->ConstructL();
|
|
96 |
CleanupStack::Pop( self );
|
|
97 |
|
|
98 |
return self;
|
|
99 |
}
|
|
100 |
|
|
101 |
// ---------------------------------------------------------------------------
|
|
102 |
// Destructor
|
|
103 |
// ---------------------------------------------------------------------------
|
|
104 |
//
|
|
105 |
CCamSnapshot::~CCamSnapshot()
|
|
106 |
{
|
|
107 |
PRINT( _L("Camera => ~CCamSnapshot") );
|
|
108 |
iObservable.DetachObserver( this );
|
|
109 |
|
|
110 |
delete iSnapshotBitmap;
|
|
111 |
|
|
112 |
// No need to Cancel(), destructors do it already.
|
|
113 |
delete iIdle;
|
|
114 |
delete iDecoder;
|
|
115 |
delete iScaler;
|
|
116 |
|
|
117 |
SetImageData( NULL );
|
|
118 |
|
|
119 |
PRINT( _L("Camera <= ~CCamSnapshot") );
|
|
120 |
}
|
|
121 |
|
|
122 |
// ===========================================================================
|
|
123 |
// from MCameraSnapshot
|
|
124 |
|
|
125 |
// ---------------------------------------------------------------------------
|
|
126 |
// SupportedFormats
|
|
127 |
// ---------------------------------------------------------------------------
|
|
128 |
//
|
|
129 |
TUint32
|
|
130 |
CCamSnapshot::SupportedFormats()
|
|
131 |
{
|
|
132 |
return KSupportedSnapshotFormats;
|
|
133 |
}
|
|
134 |
|
|
135 |
|
|
136 |
// ---------------------------------------------------------------------------
|
|
137 |
// PrepareSnapshotL
|
|
138 |
// ---------------------------------------------------------------------------
|
|
139 |
//
|
|
140 |
void
|
|
141 |
CCamSnapshot::PrepareSnapshotL( CCamera::TFormat aFormat,
|
|
142 |
const TPoint& aPosition,
|
|
143 |
const TSize& aSize,
|
|
144 |
const TRgb& aBgColor,
|
|
145 |
TBool aMaintainAspectRatio )
|
|
146 |
{
|
|
147 |
PRINT( _L("Camera => CCamSnapshot::PrepareSnapshotL") );
|
|
148 |
|
|
149 |
if( !(KSupportedSnapshotFormats & aFormat) )
|
|
150 |
{
|
|
151 |
PRINT( _L("Camera <> Not supported format, LEAVE") );
|
|
152 |
User::Leave( KErrNotSupported );
|
|
153 |
}
|
|
154 |
else
|
|
155 |
{
|
|
156 |
PRINT( _L("Camera <> do prepare..") );
|
|
157 |
iSnapshotOn = EFalse;
|
|
158 |
iStatus = KErrNotReady;
|
|
159 |
iDecoder->Cancel();
|
|
160 |
iScaler->Cancel();
|
|
161 |
iSnapshotBitmap->Reset();
|
|
162 |
|
|
163 |
PRINT( _L("Camera <> Init bitmap scaler..") );
|
|
164 |
iScaler->InitScalingL( aSize,
|
|
165 |
Format2DisplayMode( iFormat ),
|
|
166 |
aMaintainAspectRatio );
|
|
167 |
|
|
168 |
PRINT1( _L("Camera <> Attach as controller observer, interest: %032b"), KEventInterest );
|
|
169 |
iObservable.AttachObserverL( this, KEventInterest );
|
|
170 |
|
|
171 |
PRINT( _L("Camera <> Store parameters..") );
|
|
172 |
iFormat = aFormat;
|
|
173 |
iPosition = aPosition;
|
|
174 |
iSize = aSize;
|
|
175 |
iBackgroundColor = aBgColor;
|
|
176 |
iMaintainAspectRatio = aMaintainAspectRatio;
|
|
177 |
}
|
|
178 |
|
|
179 |
PRINT( _L("Camera <= CCamSnapshot::PrepareSnapshotL") );
|
|
180 |
}
|
|
181 |
|
|
182 |
|
|
183 |
// ---------------------------------------------------------------------------
|
|
184 |
// PrepareSnapshotL
|
|
185 |
// ---------------------------------------------------------------------------
|
|
186 |
//
|
|
187 |
void
|
|
188 |
CCamSnapshot::PrepareSnapshotL( CCamera::TFormat aFormat,
|
|
189 |
const TSize& aSize,
|
|
190 |
TBool aMaintainAspectRatio )
|
|
191 |
{
|
|
192 |
PrepareSnapshotL( aFormat,
|
|
193 |
KDefaultPosition,
|
|
194 |
aSize,
|
|
195 |
KDefaultBackgroudColor,
|
|
196 |
aMaintainAspectRatio );
|
|
197 |
}
|
|
198 |
|
|
199 |
|
|
200 |
// ---------------------------------------------------------------------------
|
|
201 |
// SetBgColorL
|
|
202 |
// ---------------------------------------------------------------------------
|
|
203 |
//
|
|
204 |
void
|
|
205 |
CCamSnapshot::SetBgColorL( const TRgb& aBgColor )
|
|
206 |
{
|
|
207 |
iBackgroundColor = aBgColor;
|
|
208 |
}
|
|
209 |
|
|
210 |
|
|
211 |
// ---------------------------------------------------------------------------
|
|
212 |
// SetPositionL
|
|
213 |
// ---------------------------------------------------------------------------
|
|
214 |
//
|
|
215 |
void
|
|
216 |
CCamSnapshot::SetPositionL( const TPoint& aPosition )
|
|
217 |
{
|
|
218 |
iPosition = aPosition;
|
|
219 |
}
|
|
220 |
|
|
221 |
|
|
222 |
// ---------------------------------------------------------------------------
|
|
223 |
// IsSnapshotActive
|
|
224 |
// ---------------------------------------------------------------------------
|
|
225 |
//
|
|
226 |
TBool
|
|
227 |
CCamSnapshot::IsSnapshotActive() const
|
|
228 |
{
|
|
229 |
return iSnapshotOn;
|
|
230 |
}
|
|
231 |
|
|
232 |
// ---------------------------------------------------------------------------
|
|
233 |
// StartSnapshot
|
|
234 |
// ---------------------------------------------------------------------------
|
|
235 |
//
|
|
236 |
void
|
|
237 |
CCamSnapshot::StartSnapshot()
|
|
238 |
{
|
|
239 |
iSnapshotOn = ETrue;
|
|
240 |
}
|
|
241 |
|
|
242 |
|
|
243 |
// ---------------------------------------------------------------------------
|
|
244 |
// StopSnapshot
|
|
245 |
// ---------------------------------------------------------------------------
|
|
246 |
//
|
|
247 |
void
|
|
248 |
CCamSnapshot::StopSnapshot()
|
|
249 |
{
|
|
250 |
iSnapshotOn = EFalse;
|
|
251 |
|
|
252 |
iUseNextVfFrame = EFalse;
|
|
253 |
}
|
|
254 |
|
|
255 |
|
|
256 |
// ---------------------------------------------------------------------------
|
|
257 |
// SnapshotDataL
|
|
258 |
// ---------------------------------------------------------------------------
|
|
259 |
//
|
|
260 |
MCameraBuffer&
|
|
261 |
CCamSnapshot::SnapshotDataL( RArray<TInt>& aFrameIndexOrder )
|
|
262 |
{
|
|
263 |
PRINT( _L("Camera => CCamSnapshot::SnapshotDataL") );
|
|
264 |
|
|
265 |
// Leave if not ready or other error.
|
|
266 |
User::LeaveIfError( iStatus );
|
|
267 |
|
|
268 |
if( !iSnapshotOn || !iSnapshotBitmap )
|
|
269 |
{
|
|
270 |
User::Leave( KErrNotReady );
|
|
271 |
}
|
|
272 |
|
|
273 |
// Set the frame order
|
|
274 |
aFrameIndexOrder.Reset();
|
|
275 |
User::LeaveIfError( aFrameIndexOrder.Append( 0 ) );
|
|
276 |
|
|
277 |
// Client *must* call Release() for the buffer
|
|
278 |
CCamBuffer* buffer = CCamBuffer::NewL( *iSnapshotBitmap, NULL );
|
|
279 |
|
|
280 |
PRINT( _L("Camera <= CCamSnapshot::SnapshotDataL") );
|
|
281 |
return *buffer;
|
|
282 |
}
|
|
283 |
|
|
284 |
|
|
285 |
// ===========================================================================
|
|
286 |
// From MCamCameraObserver
|
|
287 |
|
|
288 |
// ---------------------------------------------------------------------------
|
|
289 |
//
|
|
290 |
// ---------------------------------------------------------------------------
|
|
291 |
//
|
|
292 |
void
|
|
293 |
CCamSnapshot::HandleCameraEventL( TInt aStatus,
|
|
294 |
TCamCameraEventId aEventId,
|
|
295 |
TAny* aEventData /*= NULL*/ )
|
|
296 |
{
|
|
297 |
if( iSnapshotOn )
|
|
298 |
{
|
|
299 |
switch( aEventId )
|
|
300 |
{
|
|
301 |
// ---------------------------------------------------
|
|
302 |
// Viewfinder frame ready event
|
|
303 |
//
|
|
304 |
case ECamCameraEventVfFrameReady:
|
|
305 |
{
|
|
306 |
if( iUseNextVfFrame )
|
|
307 |
{
|
|
308 |
iUseNextVfFrame = EFalse;
|
|
309 |
|
|
310 |
// Take the viewfinder frame just as it would be
|
|
311 |
// a still image, just in bitmap format.
|
|
312 |
PRINT( _L("Camera <> CCamSnapshot: Storing VF frame as snapshot") );
|
|
313 |
|
|
314 |
|
|
315 |
// TEMP ==>
|
|
316 |
CCamBufferShare* share = NULL;
|
|
317 |
TRAPD( error,
|
|
318 |
{
|
|
319 |
if( KErrNone == aStatus )
|
|
320 |
{
|
|
321 |
CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
|
|
322 |
CleanupStack::PushL( bitmap );
|
|
323 |
User::LeaveIfError( bitmap->Duplicate( static_cast<CFbsBitmap*>( aEventData )->Handle() ) );
|
|
324 |
|
|
325 |
CCamBuffer* buffer = CCamBuffer::NewL( bitmap, NULL );
|
|
326 |
CleanupStack::Pop( bitmap );
|
|
327 |
|
|
328 |
CleanupStack::PushL( buffer );
|
|
329 |
share = new (ELeave) CCamBufferShare( buffer );
|
|
330 |
CleanupStack::Pop( buffer );
|
|
331 |
}
|
|
332 |
});
|
|
333 |
if( KErrNone != error )
|
|
334 |
{
|
|
335 |
aStatus = error;
|
|
336 |
}
|
|
337 |
if( share ) share->Reserve();
|
|
338 |
// <== TEMP
|
|
339 |
|
|
340 |
|
|
341 |
StartSnapshotProcessing( share, aStatus );
|
|
342 |
|
|
343 |
// TEMP ==>
|
|
344 |
if( share ) share->Release();
|
|
345 |
// <== TEMP
|
|
346 |
}
|
|
347 |
break;
|
|
348 |
}
|
|
349 |
// ---------------------------------------------------
|
|
350 |
// Image captured event
|
|
351 |
//
|
|
352 |
// Need to decode the snapshot from the image data.
|
|
353 |
case ECamCameraEventImageData:
|
|
354 |
{
|
|
355 |
if( !iVideoMode )
|
|
356 |
{
|
|
357 |
PRINT( _L("Camera <> CCamSnapshot: Starting to decode snapshot") );
|
|
358 |
CCamBufferShare* share = static_cast<CCamBufferShare*>( aEventData );
|
|
359 |
StartSnapshotProcessing( share, aStatus );
|
|
360 |
}
|
|
361 |
break;
|
|
362 |
}
|
|
363 |
// ---------------------------------------------------
|
|
364 |
// Video init might come before snapshot is
|
|
365 |
// initialized, so we do not rely on this event
|
|
366 |
// case ECamCameraEventVideoInit:
|
|
367 |
// {
|
|
368 |
// PRINT( _L("Camera <> CCamSnapshot: Video mode entered") );
|
|
369 |
// break;
|
|
370 |
// }
|
|
371 |
// ---------------------------------------------------
|
|
372 |
case ECamCameraEventVideoRelease:
|
|
373 |
{
|
|
374 |
PRINT( _L("Camera <> CCamSnapshot: Video mode left") );
|
|
375 |
iVideoMode = EFalse;
|
|
376 |
break;
|
|
377 |
}
|
|
378 |
// ---------------------------------------------------
|
|
379 |
// Video started event
|
|
380 |
//
|
|
381 |
// Use next vf frame as snapshot.
|
|
382 |
case ECamCameraEventVideoStart:
|
|
383 |
{
|
|
384 |
PRINT( _L("Camera <> CCamSnapshot: Video started, will use next VF frame as snapshot") );
|
|
385 |
SetImageData( NULL );
|
|
386 |
if( KErrNone == aStatus )
|
|
387 |
{
|
|
388 |
iVideoMode = ETrue;
|
|
389 |
iUseNextVfFrame = ETrue;
|
|
390 |
}
|
|
391 |
break;
|
|
392 |
}
|
|
393 |
// ---------------------------------------------------
|
|
394 |
// Video stopped.
|
|
395 |
//
|
|
396 |
// Provide the vf frame as snapshot.
|
|
397 |
case ECamCameraEventVideoStop:
|
|
398 |
{
|
|
399 |
if( iVideoMode )
|
|
400 |
{
|
|
401 |
PRINT( _L("Camera <> CCamSnapshot: Video stopped, provide the VF frame snapshot..") );
|
|
402 |
|
|
403 |
// Cancel any activity, if not ready for some reason.
|
|
404 |
if( iIdle ) iIdle->Cancel();
|
|
405 |
if( iScaler ) iScaler->Cancel();
|
|
406 |
if( iDecoder ) iDecoder->Cancel();
|
|
407 |
|
|
408 |
// Snapshot is in iSnapshotBitmap
|
|
409 |
SetImageData( NULL );
|
|
410 |
|
|
411 |
// Need to clear this flag as no events are notified
|
|
412 |
// when this flag is on.
|
|
413 |
iVideoMode = EFalse;
|
|
414 |
|
|
415 |
PRINT( _L("Camera <> CCamSnapshot: Start snapshot callback") );
|
|
416 |
iIdle->Start( TCallBack( SnapshotReadyCallback, this ) );
|
|
417 |
}
|
|
418 |
break;
|
|
419 |
}
|
|
420 |
// ---------------------------------------------------
|
|
421 |
default:
|
|
422 |
{
|
|
423 |
// Other events ignored
|
|
424 |
break;
|
|
425 |
}
|
|
426 |
// ---------------------------------------------------
|
|
427 |
}
|
|
428 |
}
|
|
429 |
}
|
|
430 |
|
|
431 |
|
|
432 |
|
|
433 |
|
|
434 |
// ===========================================================================
|
|
435 |
// from MCamImageDecoderObserver
|
|
436 |
|
|
437 |
// ---------------------------------------------------------------------------
|
|
438 |
// ImageDecodedL <<virtual>>
|
|
439 |
// ---------------------------------------------------------------------------
|
|
440 |
//
|
|
441 |
void
|
|
442 |
CCamSnapshot::ImageDecodedL( TInt aStatus, const CFbsBitmap* aBitmap, const CFbsBitmap* /*aMask*/ )
|
|
443 |
{
|
|
444 |
PRINT1( _L("Camera => CCamSnapshot::ImageDecoded, status in: %d"), aStatus );
|
|
445 |
if( iSnapshotOn )
|
|
446 |
{
|
|
447 |
iStatus = aStatus;
|
|
448 |
|
|
449 |
iSnapshotBitmap->Reset();
|
|
450 |
|
|
451 |
if( iStatus == KErrNone )
|
|
452 |
{
|
|
453 |
iStatus = iSnapshotBitmap->Duplicate( aBitmap->Handle() );
|
|
454 |
}
|
|
455 |
PRINT1( _L("Camera <> status after bitmap duplicate: %d"), iStatus );
|
|
456 |
|
|
457 |
// Release image data, as not used anymore.
|
|
458 |
// All that is needed is iSnapshotBitmap.
|
|
459 |
SetImageData( NULL );
|
|
460 |
|
|
461 |
if( iStatus == KErrNone )
|
|
462 |
{
|
|
463 |
iScaler->StartScaling( *iSnapshotBitmap );
|
|
464 |
}
|
|
465 |
else
|
|
466 |
{
|
|
467 |
iIdle->Start( TCallBack( SnapshotReadyCallback, this ) );
|
|
468 |
}
|
|
469 |
}
|
|
470 |
PRINT( _L("Camera <= CCamSnapshot::ImageDecoded") );
|
|
471 |
}
|
|
472 |
|
|
473 |
// ===========================================================================
|
|
474 |
// from MCamBitmapScalerObserver
|
|
475 |
|
|
476 |
// ---------------------------------------------------------------------------
|
|
477 |
// BitmapScaled <<virtual>>
|
|
478 |
// ---------------------------------------------------------------------------
|
|
479 |
//
|
|
480 |
void
|
|
481 |
CCamSnapshot::BitmapScaled( TInt aStatus, const CFbsBitmap* aBitmap )
|
|
482 |
{
|
|
483 |
// Release any data we hold, as it's not needed anymore.
|
|
484 |
SetImageData( NULL );
|
|
485 |
|
|
486 |
if( iSnapshotOn )
|
|
487 |
{
|
|
488 |
iStatus = aStatus;
|
|
489 |
iSnapshotBitmap->Reset();
|
|
490 |
|
|
491 |
if( KErrNone == iStatus )
|
|
492 |
{
|
|
493 |
iStatus = iSnapshotBitmap->Duplicate( aBitmap->Handle() );
|
|
494 |
}
|
|
495 |
|
|
496 |
TECAMEvent event( KUidECamEventCameraSnapshot, iStatus );
|
|
497 |
iObserver.HandleEvent( event );
|
|
498 |
}
|
|
499 |
}
|
|
500 |
|
|
501 |
|
|
502 |
// ===========================================================================
|
|
503 |
// public new methods
|
|
504 |
|
|
505 |
// ---------------------------------------------------------------------------
|
|
506 |
// StartSnapshotProcessing
|
|
507 |
// ---------------------------------------------------------------------------
|
|
508 |
//
|
|
509 |
void
|
|
510 |
CCamSnapshot::StartSnapshotProcessing( CCamBufferShare* aBuffer,
|
|
511 |
TInt aError )
|
|
512 |
{
|
|
513 |
PRINT1( _L("Camera => CCamSnapshot::StartSnapshotProcessing, status in:%d"), aError );
|
|
514 |
|
|
515 |
if( iSnapshotOn )
|
|
516 |
{
|
|
517 |
TRAP( iStatus, DoStartSnapshotProcessingL( aBuffer, aError ) );
|
|
518 |
|
|
519 |
if( iStatus != KErrNone )
|
|
520 |
{
|
|
521 |
iIdle->Start( TCallBack( SnapshotReadyCallback, this ) );
|
|
522 |
}
|
|
523 |
}
|
|
524 |
|
|
525 |
PRINT1( _L("Camera <= CCamSnapshot::StartSnapshotProcessing, status out:%d"), aError );
|
|
526 |
}
|
|
527 |
|
|
528 |
|
|
529 |
// ---------------------------------------------------------------------------
|
|
530 |
// SnapshotReadyCallback <<static>>
|
|
531 |
// ---------------------------------------------------------------------------
|
|
532 |
//
|
|
533 |
// static
|
|
534 |
TInt
|
|
535 |
CCamSnapshot::SnapshotReadyCallback( TAny* aSelf )
|
|
536 |
{
|
|
537 |
PRINT( _L("Camera => CCamSnapshot::SnapshotReadyCallback <<static>>") );
|
|
538 |
CCamSnapshot* self( static_cast<CCamSnapshot*>( aSelf ) );
|
|
539 |
|
|
540 |
if( !self->iVideoMode )
|
|
541 |
{
|
|
542 |
TECAMEvent event( KUidECamEventCameraSnapshot, self->iStatus );
|
|
543 |
self->iObserver.HandleEvent( event );
|
|
544 |
}
|
|
545 |
else
|
|
546 |
{
|
|
547 |
// In video mode we must wait for the video stopped event
|
|
548 |
// even to report error.
|
|
549 |
PRINT( _L("Camera <> CCamSnapshot: Video mode, wait until video stopped.") );
|
|
550 |
}
|
|
551 |
|
|
552 |
PRINT( _L("Camera <= CCamSnapshot::SnapshotReadyCallback <<static>>") );
|
|
553 |
return EFalse;
|
|
554 |
}
|
|
555 |
|
|
556 |
|
|
557 |
|
|
558 |
// ===========================================================================
|
|
559 |
// private methods
|
|
560 |
|
|
561 |
// ---------------------------------------------------------------------------
|
|
562 |
// DoStartSnapshotProcessingL
|
|
563 |
//
|
|
564 |
// Helper method for StartSnapshotProcessing.
|
|
565 |
// ---------------------------------------------------------------------------
|
|
566 |
//
|
|
567 |
void
|
|
568 |
CCamSnapshot::DoStartSnapshotProcessingL( CCamBufferShare* aBuffer,
|
|
569 |
TInt aError )
|
|
570 |
{
|
|
571 |
PRINT1( _L("Camera => CCamSnapshot::DoStartSnapshotProcessingL, status in:%d"), aError );
|
|
572 |
|
|
573 |
// Cancel all ongoing activity.
|
|
574 |
iDecoder->Cancel();
|
|
575 |
iScaler->Cancel();
|
|
576 |
SetImageData( NULL ); // Release any old.
|
|
577 |
|
|
578 |
// Check that we have the data needed.
|
|
579 |
CheckNonNullL( aBuffer, KErrNotFound );
|
|
580 |
CheckNonNullL( aBuffer->SharedBuffer(), KErrNotFound );
|
|
581 |
User::LeaveIfError( aError );
|
|
582 |
|
|
583 |
|
|
584 |
SetImageData( aBuffer );
|
|
585 |
MCameraBuffer* buffer = iImageData->SharedBuffer();
|
|
586 |
|
|
587 |
// First try to use bitmap data if available
|
|
588 |
TRAP( aError,
|
|
589 |
{
|
|
590 |
CFbsBitmap& bitmap = buffer->BitmapL( 0 );
|
|
591 |
PRINT( _L("Camera <> Using bitmap data, just scale..") );
|
|
592 |
// Simulate that the bitmap has been decoded now.
|
|
593 |
ImageDecodedL( aError, &bitmap, NULL );
|
|
594 |
});
|
|
595 |
|
|
596 |
// If problems with bitmap data, try encoded data.
|
|
597 |
if( KErrNone != aError )
|
|
598 |
{
|
|
599 |
PRINT( _L("Camera <> Using encoded data, decode first") );
|
|
600 |
// If not able to use bitmap (or there is none),
|
|
601 |
// start converting bitmap from encoded image data.
|
|
602 |
TRAP( aError, iDecoder->StartConversionL( iImageData ) );
|
|
603 |
}
|
|
604 |
|
|
605 |
|
|
606 |
// Neither of the formats could be used.
|
|
607 |
// Release the image data.
|
|
608 |
if( KErrNone != aError )
|
|
609 |
{
|
|
610 |
SetImageData( NULL );
|
|
611 |
User::Leave( aError );
|
|
612 |
}
|
|
613 |
PRINT( _L("Camera <= CCamSnapshot::DoStartSnapshotProcessingL") );
|
|
614 |
}
|
|
615 |
|
|
616 |
|
|
617 |
// ---------------------------------------------------------------------------
|
|
618 |
// Format2DisplayMode
|
|
619 |
// ---------------------------------------------------------------------------
|
|
620 |
//
|
|
621 |
TDisplayMode
|
|
622 |
CCamSnapshot::Format2DisplayMode( CCamera::TFormat aFormat ) const
|
|
623 |
{
|
|
624 |
switch( aFormat )
|
|
625 |
{
|
|
626 |
case CCamera::EFormatFbsBitmapColor4K: return EColor4K;
|
|
627 |
case CCamera::EFormatFbsBitmapColor64K: return EColor64K;
|
|
628 |
case CCamera::EFormatFbsBitmapColor16M: return EColor16M;
|
|
629 |
case CCamera::EFormatFbsBitmapColor16MU: return EColor16MU;
|
|
630 |
default: return EColor16MU;
|
|
631 |
}
|
|
632 |
}
|
|
633 |
|
|
634 |
|
|
635 |
|
|
636 |
// ---------------------------------------------------------------------------
|
|
637 |
// SetImageData
|
|
638 |
//
|
|
639 |
// Release old shared buffer (if any exists) and store pointer to new one and
|
|
640 |
// reserve it (if any provided). Can be used to just release any existing
|
|
641 |
// share with NULL parameter.
|
|
642 |
// ---------------------------------------------------------------------------
|
|
643 |
//
|
|
644 |
void
|
|
645 |
CCamSnapshot::SetImageData( CCamBufferShare* aImageData )
|
|
646 |
{
|
|
647 |
if( iImageData )
|
|
648 |
{
|
|
649 |
iImageData->Release();
|
|
650 |
}
|
|
651 |
|
|
652 |
iImageData = aImageData;
|
|
653 |
|
|
654 |
if( iImageData )
|
|
655 |
{
|
|
656 |
iImageData->Reserve();
|
|
657 |
}
|
|
658 |
}
|
|
659 |
|
|
660 |
|
|
661 |
|
|
662 |
// ===========================================================================
|
|
663 |
// private constructors
|
|
664 |
|
|
665 |
// ---------------------------------------------------------------------------
|
|
666 |
// 2nd phase constructor
|
|
667 |
// ---------------------------------------------------------------------------
|
|
668 |
//
|
|
669 |
void
|
|
670 |
CCamSnapshot::ConstructL()
|
|
671 |
{
|
|
672 |
iSnapshotBitmap = new (ELeave) CFbsBitmap;
|
|
673 |
|
|
674 |
iDecoder = CCamImageDecoder::NewL( *this );
|
|
675 |
iScaler = CCamBitmapScaler::NewL( *this );
|
|
676 |
|
|
677 |
iIdle = CIdle::NewL( KCallbackPriority );
|
|
678 |
}
|
|
679 |
|
|
680 |
// ---------------------------------------------------------------------------
|
|
681 |
// 1st phase constructor
|
|
682 |
// ---------------------------------------------------------------------------
|
|
683 |
//
|
|
684 |
CCamSnapshot::CCamSnapshot( CCamera& aCamera,
|
|
685 |
MCameraObserver2& aObserver,
|
|
686 |
MCamCameraObservable& aObservable )
|
|
687 |
: iObserver( aObserver ),
|
|
688 |
iObservable( aObservable ),
|
|
689 |
iCameraHandle( aCamera.Handle() ),
|
|
690 |
iSnapshotOn( EFalse ),
|
|
691 |
iStatus( KErrNotReady )
|
|
692 |
{
|
|
693 |
}
|
|
694 |
|
|
695 |
// end of file
|