imagingandcamerafws/camerafw/Include/CameraSnapshot.h
changeset 0 40261b775718
equal deleted inserted replaced
-1:000000000000 0:40261b775718
       
     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  @publishedPartner
       
    19  @prototype
       
    20 */
       
    21 
       
    22 #ifndef CAMERASNAPSHOT_H
       
    23 #define CAMERASNAPSHOT_H
       
    24 
       
    25 #include <ecam.h>
       
    26 #include <gdi.h>
       
    27 #include <ecamcapturecontrol.h>
       
    28 #include <ecam/ecamcommonuids.hrh>
       
    29 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    30 #include <ecam/ecamcommonuidsconst.hrh>
       
    31 #endif
       
    32 class MCameraSnapshot;
       
    33 class MCameraSnapshot2;
       
    34 
       
    35 class MImplementationFactory;
       
    36 
       
    37 /** 
       
    38 Constant used to specify the default display time. When this default display time is specified by the client, the implementation 
       
    39 may use its own time interval in order to display the direct snapshot data.
       
    40 
       
    41 @see CCamera::CCameraSnapshot::TSnapshotParameters::iDisplayTime
       
    42 
       
    43 @publishedPartner
       
    44 @prototype
       
    45 */
       
    46 static const TInt KECamSnapshotDefaultDisplayTime = 0;
       
    47 
       
    48 /** 
       
    49 The current Version of the TSnapshotParameters class.
       
    50 
       
    51 @publishedPartner
       
    52 @prototype
       
    53 */
       
    54 static const TUint KECamSnapshotParametersCurrentVersion = 1;
       
    55 
       
    56 /** 
       
    57 UID used to identify the event that, the request for snapshot has completed successfully.
       
    58 A callback to MCameraObserver2::HandleEvent() will occur when the snapshot data is ready to be retrieved.
       
    59 If a call to StartSnapshot() is made without a successful call to PrepareSnapshotL() then the callback returns KErrNotReady.
       
    60 */
       
    61 static const TUid KUidECamEventCameraSnapshot = {KUidECamEventSnapshotUidValue};
       
    62 
       
    63 /** 
       
    64 UID used to identify the CCamera::CCameraSnapshot API.
       
    65 This is the UID which is used to obtain the CCameraSnapshot interface, 
       
    66 via a call to CCamera::CustomInterface().
       
    67 
       
    68 @see KECamSnapshotUidValue
       
    69 @see CCamera::CCameraSnapshot
       
    70 */
       
    71 static const TUid KECamSnapshotUid = {KECamSnapshotUidValue};
       
    72 
       
    73 /**
       
    74 This class allows the client to request snapshot data in a specified image format for both still images and video.
       
    75 
       
    76 Snapshot object may be created out of new classes: CCameraImageCapture and CCameraVideoCaptureControl. The client selects 
       
    77 snapshot parameters calling PrepareSnapshotL(const TSnapshotParameters& aSnapshotParameters). It can then enable and 
       
    78 disable the snapshot generation by calling EnableSnapshotL() and DisableSnapshotL(). The client application using this API 
       
    79 shall provide MCaptureImageObserver and MCaptureVideoObserver interface. Callbacks available are MCaptureImageObserver::
       
    80 ClientSnapshotForImageReady and MCaptureVideoObserver::ClientSnapshotReady.
       
    81 
       
    82 Snapshots are supposed to be displayed on a particular viewfinder. So, while destruction, client shall destroy snapshot 
       
    83 first. In general, child objects shall be destroyed before the parent objects.
       
    84 
       
    85 Following is valid for older clients who created snapshots using NewL method:-
       
    86 The client selects snapshot parameters calling PrepareSnapshotL(). It can then start and stop 
       
    87 receiving notifications from the ECam implementation by calling StartSnapshot() and StopSnapshot().
       
    88 The client application using this API should provide MCameraObserver2 interface to be signalled,
       
    89 with event KUidECamEventCameraSnapshot, when snapshot data is available to be retrieved from 
       
    90 the ECam implementation.
       
    91 The client can then retrieve the snapshot data from the ECam implementation calling SnapshotDataL().
       
    92 
       
    93 @note This class provides a standardised client interface for the camera snapshot. Classes cannot be derived from it.
       
    94 
       
    95 @note   If the class methods leave, the output type parameter value is not guaranteed to be valid.
       
    96 
       
    97 @publishedPartner
       
    98 @prototype
       
    99 */
       
   100 
       
   101 class CCamera::CCameraSnapshot: public CBase
       
   102 	{
       
   103 	
       
   104 	friend class CCamera;
       
   105 
       
   106 	friend CCamera::CCameraSnapshot* CCamera::CCameraImageCapture::GetSnapshotHandleL(TInt aClientViewFinderId) const;
       
   107 	friend CCamera::CCameraSnapshot* CCamera::CCameraVideoCaptureControl::GetSnapshotHandleL(TInt aClientViewFinderId) const;
       
   108 
       
   109 public:
       
   110 	/** 
       
   111 	Describes the state of snapshot. 
       
   112 	The enumeration list may be extended in future.
       
   113 	*/
       
   114 	enum TSnapshotState
       
   115 		{
       
   116 		/** Snapshot has not been prepared. */
       
   117 		ESnapshotNotCreated,
       
   118 		/** Snapshot has been prepared but not yet enabled. */
       
   119 		ESnapshotInactive,
       
   120 		/** Snapshot has been prepared and enabled but not yet disabled. */
       
   121 		ESnapshotActive,
       
   122 		/** Snapshot has been disabled. */
       
   123 		ESnapshotDisabled,
       
   124 		};
       
   125 	
       
   126 	/** 
       
   127 	Specifies the video frames to be used in order to create snapshots fo video. 
       
   128 	The enumeration list may be extended in future.
       
   129 	*/	
       
   130 	enum TSnapshotVideoFrames
       
   131 		{
       
   132 		/** Snapshot for video created from first video frame. Used by default. */
       
   133 		ESnapshotVideoFirstFrame,
       
   134 		/** Snapshot for video created from last video frame. */
       
   135 		ESnapshotVideoLastFrame,
       
   136 		/** Snapshot for video created from first and last video frame. */
       
   137 		ESnapshotVideoFirstAndLastFrame,
       
   138 		/** Snapshot for video created from every video frame. */
       
   139 		ESnapshotVideoEveryFrame
       
   140 		};
       
   141 		
       
   142 	/**
       
   143 	Specifes the parameters necessary for client snapshots.
       
   144 	*/
       
   145 	class TSnapshotParameters
       
   146 		{
       
   147 	public:
       
   148 		IMPORT_C TSnapshotParameters();
       
   149 		
       
   150 		IMPORT_C TUint Size() const;
       
   151 		IMPORT_C TUint Version() const;
       
   152 				
       
   153 		IMPORT_C TBool IsAspectRatioMaintained() const;
       
   154 		
       
   155 		IMPORT_C void SetAspectRatioState(TBool aIsAspectRatioMaintained);
       
   156 		
       
   157 	private:
       
   158 		//for future expansion
       
   159 		TUint iSize:24;
       
   160 		TUint iVersion:8;
       
   161 		
       
   162 		// reserved for future expansion
       
   163 		TInt iReserved1;
       
   164 		TInt iReserved2;
       
   165 		TInt iReserved3;
       
   166 		
       
   167 		TInt iReserved5;
       
   168 		TInt iReserved6;
       
   169 		TInt iReserved7;
       
   170 		
       
   171 		TUint iReserved4:31;
       
   172 		
       
   173 		/** Set to ETrue if the aspect ratio of the snapshot image must be maintained when scaling down */
       
   174 		TUint iIsAspectRatioMaintained:1;
       
   175 		
       
   176 	public:
       
   177 		/** The image format that the snapshot must have. */
       
   178 		CCamera::TFormat iFormat;
       
   179 		/** The top left corner position (in pixels) which determines the layout of the snapshot image  
       
   180 		within the dimensions provided by the iSnapshotSize parameter when the snapshot has been scaled 
       
   181 		maintaining its aspect ratio. ECam implementation is supposed to calculate the proportion between
       
   182 		the top left corner and the snapshot size and hence use it, in case, the snapshot size used is different. */
       
   183 		TPoint iPosition;
       
   184 		/** The size of the snapshot in pixels. The snapshot size may be changed by the implementation to meet hardware 
       
   185 		requirements, performance etc. */
       
   186 		TSize iSnapshotSize;
       
   187 		};
       
   188 	
       
   189 public:	
       
   190 	IMPORT_C static CCameraSnapshot* NewL(CCamera& aCamera);
       
   191 	
       
   192     IMPORT_C CCamera::CCameraV2Histogram* CreateHistogramHandleL() const;
       
   193     
       
   194   	IMPORT_C TUint32 SupportedFormats();
       
   195 	
       
   196 	IMPORT_C void PrepareSnapshotL(CCamera::TFormat aFormat, const TPoint& aPosition, const TSize& aSize, const TRgb& aBgColor, TBool aMaintainAspectRatio);
       
   197 	IMPORT_C void PrepareSnapshotL(CCamera::TFormat aFormat, const TSize& aSize, TBool aMaintainAspectRatio);
       
   198 	
       
   199 	IMPORT_C void SetBgColorL(const TRgb& aBgColor); 
       
   200 	IMPORT_C void SetPositionL(const TPoint& aPosition);
       
   201 	
       
   202 	IMPORT_C TBool IsSnapshotActive() const;
       
   203 	IMPORT_C void StartSnapshot();
       
   204 	IMPORT_C void StopSnapshot();
       
   205 	    	
       
   206 	IMPORT_C MCameraBuffer& SnapshotDataL(RArray<TInt>& aFrameIndexOrder);
       
   207 	
       
   208 	IMPORT_C ~CCameraSnapshot();
       
   209 	
       
   210 	IMPORT_C void PrepareSnapshotL(const TSnapshotParameters& aSnapshotParameters);
       
   211 	
       
   212 	IMPORT_C void GetSnapshotParametersL(TSnapshotParameters& aSnapshotParameters);
       
   213 	IMPORT_C void SetSnapshotParametersL(const TSnapshotParameters& aSnapshotParameters); 
       
   214 	
       
   215 	IMPORT_C void GetSnapshotStatusL(TSnapshotState& aSnapshotState) const;
       
   216 	
       
   217 	IMPORT_C void SelectSnapshotVideoFramesL(TSnapshotVideoFrames aSnapshotVideoFrames);
       
   218 	
       
   219 	IMPORT_C void EnableSnapshotL();
       
   220 	IMPORT_C void DisableSnapshotL();
       
   221 	
       
   222 private:
       
   223 	IMPORT_C static CCameraSnapshot* CreateL(CCamera& aCamera, MImplementationFactory& aImplFactory, TInt aClientViewFinderId);
       
   224 	
       
   225 	CCameraSnapshot(CCamera& aOwner);
       
   226 	void ConstructL();
       
   227 	void ConstructL(const MImplementationFactory& aImplFactory, TInt aClientViewFinderId);
       
   228 
       
   229 private:	
       
   230 	CCamera&        iOwner;
       
   231 	MCameraSnapshot*  iImpl;   // not owned
       
   232 	MCameraSnapshot2* iImpl2;  // not owned
       
   233 	};
       
   234 	
       
   235 #endif // CAMERASNAPSHOT_H