javauis/mmapi_akn/baseline/inc.nga/cmmacameraplayer.h
branchRCL_3
changeset 60 6c158198356e
equal deleted inserted replaced
59:e5618cc85d74 60:6c158198356e
       
     1 /*
       
     2 * Copyright (c) 2002-2007 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:  This class is used for playing camera.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CMMACAMERAPLAYER_H
       
    20 #define CMMACAMERAPLAYER_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <sensrvdatalistener.h>
       
    24 #include <sensrvchannel.h>
       
    25 #include <sensrvorientationsensor.h>
       
    26 #include <ECamOrientationCustomInterface2.h>
       
    27 #include <ECamUIOrientationOverrideCustomAPI.h>
       
    28 #include <ecam.h>
       
    29 #include "cmmaplayer.h"
       
    30 #include "mmmaguiplayer.h"
       
    31 #include "mmmasnapshot.h"
       
    32 #include "cmmacamerawindow.h"
       
    33 
       
    34 // CONSTANTS
       
    35 _LIT(KMMACameraPlayer, "CameraPlayer");
       
    36 
       
    37 enum TCamActiveCamera
       
    38 {
       
    39   ECamActiveCameraPrimary,
       
    40   ECamActiveCameraSecondary,
       
    41   ECamActiveCameraNone
       
    42 };
       
    43 
       
    44 
       
    45 enum TCamImageOrientation
       
    46 {
       
    47   ECamOrientation0,
       
    48   ECamOrientation90,
       
    49   ECamOrientation180,
       
    50   ECamOrientation270,
       
    51   ECamOrientationIgnore,
       
    52   ECamOrientationCount
       
    53 };
       
    54 
       
    55 //  CLASS DECLARATION
       
    56 /**
       
    57 *   This class is used for playing camera.
       
    58 *
       
    59 *
       
    60 */
       
    61 
       
    62 NONSHARABLE_CLASS(CMMACameraPlayer): public CMMAPlayer,
       
    63         public MMMAGuiPlayer,
       
    64         public MMMASnapshot,
       
    65         public MCameraObserver2,
       
    66         public MSensrvDataListener
       
    67 {
       
    68 public: // Construction
       
    69     /**
       
    70      * Creates new CMMACameraPlayer for the camera at certain index.
       
    71      * Index must be smaller CCamera::CamerasAvailable().
       
    72      * @param aCameraIndex Index of the camera.
       
    73      */
       
    74     static CMMACameraPlayer* NewLC(TCamActiveCamera aCameraIndex);
       
    75 
       
    76     //   Destructor
       
    77     ~CMMACameraPlayer();
       
    78 
       
    79 protected:
       
    80     //   C++ constructor
       
    81     CMMACameraPlayer(TCamActiveCamera aCameraIndex);
       
    82     void ConstructL(TCamActiveCamera aCameraIndex);
       
    83 
       
    84 private: // new methods
       
    85     TInt64 CurrentTime();
       
    86     void ResolveViewFinderSizeL(TSize& aSize);
       
    87     void ResolveScreenSizeL(TSize& aSize);
       
    88     void ResolveCaptureSizes(const CCamera::TFormat aFormat,
       
    89                              const TInt aNumImageSizesSupported,
       
    90                              const TSize& aRequestSize,
       
    91                              TSize& aSourceSize,
       
    92                              TInt& aSourceIndex,
       
    93                              TInt& aLargestIndex);
       
    94     /**
       
    95      * Registers and start listening to sensor channel.
       
    96      */
       
    97     void UpdateSensorInfoL();
       
    98 
       
    99     /**
       
   100      * Copies bitmap image from camerabuffer to iSnapshotBitmap
       
   101      */
       
   102     void HandleBitmapCopyL(MCameraBuffer& aCameraBuffer,
       
   103                            CFbsBitmap* aSrcBitmap);
       
   104 
       
   105     /**
       
   106      * Determines amount of image rotation required for the given sensor
       
   107      * orientation input.
       
   108      */
       
   109     static TCamImageOrientation MapSensorOrientatio2CamOrientation( 
       
   110         const TSensrvOrientationData::TSensrvDeviceOrientation& aSensorOrientation, 
       
   111         TCamImageOrientation aLastImageOrientation,
       
   112         TCamActiveCamera aActiveCameraIndex);
       
   113 
       
   114     /**
       
   115      * Convert UI orienation setting value of type TCamImageOrientation
       
   116      * to MCameraOrientation TOrientation value.
       
   117      */
       
   118     static MCameraOrientation::TOrientation 
       
   119       Map2CameraOrientation(const TCamImageOrientation& aSettingOrientation);
       
   120 
       
   121 public: // from CMMAPlayer
       
   122     void StartL(TBool aPostEvent);
       
   123     void StopL(TBool aPostEvent);
       
   124     void DeallocateL();
       
   125     void RealizeL();
       
   126     void PrefetchL();
       
   127     void GetDuration(TInt64* aDuration);
       
   128     void SetMediaTimeL(TInt64* aTime);
       
   129     void GetMediaTime(TInt64* aMediaTime);
       
   130     void CloseL();
       
   131     const TDesC& Type();
       
   132 public: // From MCameraObserver2
       
   133     void HandleEvent(const TECAMEvent& aEvent);
       
   134     void ViewFinderReady(MCameraBuffer& aCameraBuffer,TInt aError);
       
   135     void ImageBufferReady(MCameraBuffer& aCameraBuffer,TInt aError);
       
   136     void VideoBufferReady(MCameraBuffer& aCameraBuffer,TInt aError);
       
   137 
       
   138 public: // From MMMAGuiPlayer
       
   139     void SetDisplayL(MMMADisplay* aDisplay);
       
   140     TSize SourceSize();
       
   141     void NotifyWithStringEvent(CMMAPlayerEvent::TEventType aEventType,
       
   142                                const TDesC& aStringEventData);
       
   143     MMMASnapshot* SnapshoterL();
       
   144 
       
   145 public: // From MMMASnapshot
       
   146     MMMASnapshot::TEncoding TakeSnapshotL(TRequestStatus* aStatus,
       
   147                                           const TSize& aSize,
       
   148                                           const CMMAImageSettings& aSettings);
       
   149     CFbsBitmap* SnapshotBitmap();
       
   150     HBufC8* SnapshotEncoded();
       
   151 
       
   152 private: // From MSensrvDataListener
       
   153     void DataReceived(CSensrvChannel& aChannel,
       
   154                        TInt aCount, 
       
   155                        TInt aDataLost);
       
   156     void DataError(CSensrvChannel& aChannel,
       
   157                     TSensrvErrorSeverity aError);
       
   158     void GetDataListenerInterfaceL(TUid aInterfaceUid,
       
   159                                     TAny*& aInterface);
       
   160 
       
   161 public: // New methods
       
   162     TInt CameraHandle();
       
   163     /**
       
   164      * Disables or enables viewfinder stopping.
       
   165      * Needed when using recording.
       
   166      *
       
   167      * @param aStopViewFinder If true viewfinder will be really stopped.
       
   168      */
       
   169     void SetViewFinderMode(TBool aStopViewFinder);
       
   170 
       
   171 private: // Data
       
   172     /**
       
   173       * Window used to render viewfinder.
       
   174       * Owned.
       
   175       */
       
   176     CMMACameraWindow* iWindow;
       
   177 
       
   178     /**
       
   179      * Camera instance used for taking snapshots and recording.
       
   180      * iWindow uses this to create duplicated camera instance.
       
   181      * Owned.
       
   182      */
       
   183     CCamera* iCamera;
       
   184     MMMADisplay* iDisplay;
       
   185 
       
   186     // index to be used for size enumeration
       
   187     TInt iSourceSizeIndex;
       
   188 
       
   189     TInt64 iMediaTime;
       
   190     TInt64 iStartTime;
       
   191 
       
   192     TRequestStatus* iSnapshotStatus;
       
   193 
       
   194     // Owned.
       
   195     CFbsBitmap* iSnapshotBitmap;
       
   196     HBufC8* iSnapshotEncoded;
       
   197 
       
   198     TSize iSize;
       
   199     TBool iStopViewFinder;
       
   200 
       
   201     // inner class for waiting realize, owned
       
   202     class CRealizeWait : public CActiveSchedulerWait
       
   203     {
       
   204     public:
       
   205         TInt iError;
       
   206     };
       
   207     CRealizeWait* iRealizeWait;
       
   208 
       
   209     TCamActiveCamera iActiveCameraIndex;
       
   210     TCamImageOrientation  iImageOrientation;
       
   211     TCamImageOrientation  iLastImageOrientation;
       
   212     // owned
       
   213     CSensrvChannel* iAccSensorChannel;
       
   214     // not owned
       
   215     MCameraOrientation* iCustomInterfaceOrientation;
       
   216     // not owned
       
   217     MCameraUIOrientationOverride* iCustomInterfaceUIOrientationOverride;
       
   218 };
       
   219 
       
   220 #endif // CMMACAMERAPLAYER_H