javauis/mmapi_qt/baseline/inc/cmmacameraplayer.h
changeset 23 98ccebc37403
equal deleted inserted replaced
21:2a9601315dfc 23:98ccebc37403
       
     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 <ecam.h>
       
    24 #include "cmmaplayer.h"
       
    25 #include "mmmaguiplayer.h"
       
    26 #include "mmmasnapshot.h"
       
    27 #include "cmmacamerawindow.h"
       
    28 
       
    29 // CONSTANTS
       
    30 _LIT(KMMACameraPlayer, "CameraPlayer");
       
    31 
       
    32 //  CLASS DECLARATION
       
    33 /**
       
    34 *   This class is used for playing camera.
       
    35 *
       
    36 *
       
    37 */
       
    38 
       
    39 NONSHARABLE_CLASS(CMMACameraPlayer): public CMMAPlayer,
       
    40         public MMMAGuiPlayer,
       
    41         public MMMASnapshot,
       
    42         public MCameraObserver
       
    43 {
       
    44 public: // Construction
       
    45     /**
       
    46      * Creates new CMMACameraPlayer for the camera at certain index.
       
    47      * Index must be smaller CCamera::CamerasAvailable().
       
    48      * @param aCameraIndex Index of the camera.
       
    49      */
       
    50     static CMMACameraPlayer* NewLC(TInt aCameraIndex);
       
    51 
       
    52     //   Destructor
       
    53     ~CMMACameraPlayer();
       
    54 
       
    55 protected:
       
    56     //   C++ constructor
       
    57     CMMACameraPlayer();
       
    58     void ConstructL(TInt aCameraIndex);
       
    59 
       
    60 private: // new methods
       
    61     TInt64 CurrentTime();
       
    62     void ResolveViewFinderSizeL(TSize& aSize);
       
    63     void ResolveScreenSizeL(TSize& aSize);
       
    64     void ResolveCaptureSizes(const CCamera::TFormat aFormat,
       
    65                              const TInt aNumImageSizesSupported,
       
    66                              const TSize& aRequestSize,
       
    67                              TSize& aSourceSize,
       
    68                              TInt& aSourceIndex,
       
    69                              TInt& aLargestIndex);
       
    70 
       
    71 public: // from CMMAPlayer
       
    72     void StartL();
       
    73     void StopL(TBool aPostEvent);
       
    74     void DeallocateL();
       
    75     void RealizeL();
       
    76     void PrefetchL();
       
    77     void GetDuration(TInt64* aDuration);
       
    78     void SetMediaTimeL(TInt64* aTime);
       
    79     void GetMediaTime(TInt64* aMediaTime);
       
    80     void CloseL();
       
    81     const TDesC& Type();
       
    82 public: // From MCameraObserver
       
    83     void ReserveComplete(TInt aError);
       
    84     void PowerOnComplete(TInt aError);
       
    85     void ViewFinderFrameReady(CFbsBitmap& aFrame);
       
    86 
       
    87     void ImageReady(CFbsBitmap* aBitmap,
       
    88                     HBufC8* aData,
       
    89                     TInt aError);
       
    90 
       
    91     void FrameBufferReady(MFrameBuffer* aFrameBuffer,
       
    92                           TInt aError);
       
    93 
       
    94 public: // From MMMAGuiPlayer
       
    95     void SetDisplayL(MMMADisplay* aDisplay);
       
    96     TSize SourceSize();
       
    97     void NotifyWithStringEvent(CMMAPlayerEvent::TEventType aEventType,
       
    98                                const TDesC& aStringEventData);
       
    99     MMMASnapshot* SnapshoterL();
       
   100 
       
   101 public: // From MMMASnapshot
       
   102     MMMASnapshot::TEncoding TakeSnapshotL(TRequestStatus* aStatus,
       
   103                                           const TSize& aSize,
       
   104                                           const CMMAImageSettings& aSettings);
       
   105     CFbsBitmap* SnapshotBitmap();
       
   106     HBufC8* SnapshotEncoded();
       
   107 
       
   108 public: // New methods
       
   109     TInt CameraHandle();
       
   110     /**
       
   111      * Disables or enables viewfinder stopping.
       
   112      * Needed when using recording.
       
   113      *
       
   114      * @param aStopViewFinder If true viewfinder will be really stopped.
       
   115      */
       
   116     void SetViewFinderMode(TBool aStopViewFinder);
       
   117 
       
   118 private: // Data
       
   119     /**
       
   120       * Window used to render viewfinder.
       
   121       * Owned.
       
   122       */
       
   123     CMMACameraWindow* iWindow;
       
   124 
       
   125     /**
       
   126      * Camera instance used for taking snapshots and recording.
       
   127      * iWindow uses this to create duplicated camera instance.
       
   128      * Owned.
       
   129      */
       
   130     CCamera* iCamera;
       
   131     MMMADisplay* iDisplay;
       
   132 
       
   133     // index to be used for size enumeration
       
   134     TInt iSourceSizeIndex;
       
   135 
       
   136     TInt64 iMediaTime;
       
   137     TInt64 iStartTime;
       
   138 
       
   139     TRequestStatus* iSnapshotStatus;
       
   140 
       
   141     // Owned.
       
   142     CFbsBitmap* iSnapshotBitmap;
       
   143     HBufC8* iSnapshotEncoded;
       
   144 
       
   145     TSize iSize;
       
   146     TBool iStopViewFinder;
       
   147 
       
   148     // inner class for waiting realize, owned
       
   149     class CRealizeWait : public CActiveSchedulerWait
       
   150     {
       
   151     public:
       
   152         TInt iError;
       
   153     };
       
   154     CRealizeWait* iRealizeWait;
       
   155 };
       
   156 
       
   157 #endif // CMMACAMERAPLAYER_H