javauis/mmapi_akn/baseline/inc.dsa/cmmasnapshot.h
branchRCL_3
changeset 24 6c158198356e
equal deleted inserted replaced
23:e5618cc85d74 24: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 takes snapshot and resizes bitmap if needed.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef CMMASNAPSHOT_H
       
    19 #define CMMASNAPSHOT_H
       
    20 
       
    21 //  INCLUDES
       
    22 #include <bitmaptransforms.h>
       
    23 #include "tmmaparametervalidator.h"
       
    24 #include "mmmasnapshot.h"
       
    25 
       
    26 //  FORWARD DECLARATIONS
       
    27 class MMMAGuiPlayer;
       
    28 class MMMAEventPoster;
       
    29 class MMMASnapshotReadyCallback;
       
    30 
       
    31 
       
    32 //  CLASS DECLARATION
       
    33 /**
       
    34 *   This class takes snapshot from MMMAGuiPlayer and resizes bitmap
       
    35 *   if needed. Then bitmap is converted to wanted image format and posted
       
    36 *   to java side. This class is used only from CMMAVideoControl and
       
    37 *   this class is made to separate many asynchronous calls from control and
       
    38 *   resource releasing.
       
    39 *
       
    40 *
       
    41 */
       
    42 
       
    43 NONSHARABLE_CLASS(CMMASnapshot): public CActive
       
    44 {
       
    45 private: // private state
       
    46     enum TMMASnapshotState
       
    47     {
       
    48         EIdle,
       
    49         ETakingSnapshot,
       
    50         EResizing,
       
    51         EEncoding
       
    52     };
       
    53 public:
       
    54     /**
       
    55      * Creates new CMMASnapshot which will be associated to gui player.
       
    56      *
       
    57      * @param aGuiPlayer Player used to take snapshot bitmap.
       
    58      * @param aCallBack Will be informed when completed.
       
    59      */
       
    60     static CMMASnapshot* NewL(MMMAGuiPlayer* aGuiPlayer,
       
    61                               MMMASnapshotReadyCallback& aCallBack);
       
    62     /**
       
    63      * Destructor.
       
    64      */
       
    65     virtual ~CMMASnapshot();
       
    66 
       
    67 private:
       
    68     /**
       
    69      * Creates required member variables.
       
    70      */
       
    71     void ConstructL();
       
    72 
       
    73     /**
       
    74      * Contructs new CMMASnapshot.
       
    75      *
       
    76      * @param aGuiPlayer Used to take snapshot bitmap.
       
    77      * @param aCallBack Will be informed when completed.
       
    78      */
       
    79     CMMASnapshot(MMMAGuiPlayer* aGuiPlayer,
       
    80                  MMMASnapshotReadyCallback& aCallBack);
       
    81 
       
    82 public: // new methods
       
    83     /**
       
    84      * Takes snapshot from player and converts it to according to
       
    85      * the properties.
       
    86      *
       
    87      * @param aProperties Snapshot's properties.
       
    88      */
       
    89     void TakeSnapShotL(const TDesC& aProperties);
       
    90 
       
    91     /**
       
    92      * Caller takes the ownership of the buffer.
       
    93      *
       
    94      * @return Image buffer. Ownership is transferred.
       
    95      */
       
    96     HBufC8* ImageBuffer();
       
    97 
       
    98 
       
    99 private:// New methods
       
   100     /**
       
   101      * Resizing image to size of settings
       
   102      */
       
   103     void ResizeL();
       
   104 
       
   105     /**
       
   106      * Encodes bitmap to wanted mime-type
       
   107      */
       
   108     void EncodeL();
       
   109 
       
   110     /**
       
   111      * Called when snapshot is ready or error occures. This method will
       
   112      * inform also the MMMASnapshotReadyCallback interface.
       
   113      *
       
   114      * @param aError Error code for the caller class.
       
   115      */
       
   116     void Completed(TInt aError);
       
   117 
       
   118 public: // CActive
       
   119     void RunL();
       
   120     TInt RunError(TInt aError);
       
   121     void DoCancel();
       
   122 
       
   123 private:
       
   124     /**
       
   125      * Bitmap encoder, owned
       
   126      */
       
   127     CImageEncoder* iEncoder;
       
   128 
       
   129     /**
       
   130      * Bitmap will be got from gui player and ownership is
       
   131      * transfers to this class, owned
       
   132      */
       
   133     CFbsBitmap* iBitmap;
       
   134 
       
   135     /**
       
   136      * Bitmap scaler, owned
       
   137      */
       
   138     CBitmapScaler* iScaler;
       
   139 
       
   140     /**
       
   141      * Buffer used for storing encoded data, owned
       
   142      */
       
   143     HBufC8* iBuffer;
       
   144 
       
   145     /**
       
   146      * Bitmap settings, owned
       
   147      */
       
   148     CMMAImageSettings* iSettings;
       
   149 
       
   150     /**
       
   151      * Snapshot encoding
       
   152      */
       
   153     MMMASnapshot::TEncoding iEncoding;
       
   154 
       
   155     /**
       
   156      * GUI player interface, used for taking snapshot, not owned
       
   157      */
       
   158     MMMAGuiPlayer* iGUIPlayer;
       
   159 
       
   160     /**
       
   161      * When snapshot is ready or error occures callback will be informed.
       
   162      */
       
   163     MMMASnapshotReadyCallback& iCallBack;
       
   164 
       
   165     /**
       
   166      * Internal state
       
   167      */
       
   168     TMMASnapshotState iState;
       
   169 };
       
   170 
       
   171 #endif // CMMASNAPSHOT_H
       
   172 
       
   173 
       
   174 
       
   175 
       
   176 
       
   177