imaging/imagingfws/MediaClientImage/Include/MdaImageConverterPriv.h
changeset 0 5752a19fdefe
equal deleted inserted replaced
-1:000000000000 0:5752a19fdefe
       
     1 // Copyright (c) 1998-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 // MdaImageConverter.h
       
    15 // Implementation of the API interfaces defined in MdaImageConverter.h
       
    16 // 
       
    17 //
       
    18 
       
    19 #ifndef __MDAIMAGECONVERTERPRIV_H__
       
    20 #define __MDAIMAGECONVERTERPRIV_H__
       
    21 
       
    22 #include <fbs.h>
       
    23 #include <bitdev.h>
       
    24 
       
    25 #include <icl/imagedata.h>
       
    26 #include <mda/client/resource.h>
       
    27 #include <mda/client/utility.h>
       
    28 
       
    29 #include "BitmapConverter.h"
       
    30 #include <bitmaptransforms.h>
       
    31 
       
    32 #include <mda/common/video.h>
       
    33 
       
    34 enum 
       
    35 	{
       
    36 	EMDAImConvPanicNotImplemented=1,
       
    37 	EMDAImConvPanicNotYetOpen
       
    38 	};
       
    39 
       
    40 
       
    41 class CMdaServer;
       
    42 class REComSession;
       
    43 class MMdaImageUtilObserver;
       
    44 class TFrameDataBlock;
       
    45 class TImageDataBlock;
       
    46 
       
    47 // CMdaImageUtilityPriv
       
    48 class CMdaImageUtilityPriv; // declared here
       
    49 NONSHARABLE_CLASS( CMdaImageUtilityPriv ): public CBase
       
    50 	{
       
    51 friend class CMdaImageUtility;
       
    52 friend class CMdaImageDataReadUtility;
       
    53 friend class CMdaImageBitmapToBitmapUtility;
       
    54 
       
    55 public:
       
    56 	virtual ~CMdaImageUtilityPriv();
       
    57 protected:
       
    58 	virtual void Close();
       
    59 	virtual void ConvertL(CFbsBitmap& aBitmap,TInt aFrameNumber = 0) = 0;
       
    60 	virtual void ConvertL(CFbsBitmap& aBitmap,CFbsBitmap& aMaskBitmap,TInt aFrameNumber = 0) = 0;
       
    61 	virtual void CancelConvertL() = 0;
       
    62 	virtual void FrameInfo(TInt aFrame,TFrameInfo& aInfo) const;
       
    63 	virtual TInt FrameCount() const;
       
    64 protected:
       
    65 	CMdaImageUtilityPriv(MMdaImageUtilObserver& aObserver, CMdaImageUtility* aParent);
       
    66 	void Close(TBool aFullClose);
       
    67 	void Initialize();
       
    68 	virtual void DoClose();
       
    69 	void SelfComplete(TInt aError);
       
    70 	void SetUidsFromOrigFormatsL(TMdaClipFormat* aFormat,TMdaPackage* aCodec,TMdaPackage* aExtra);
       
    71 	void OpenFsSessionL();
       
    72 	void OpenEcomSessionL();
       
    73 	void CloseEcomSession();
       
    74 #if defined(__ECOM_POWERDOWN_WORKAROUND)
       
    75 	void OpenWaitTimerL();
       
    76 #endif defined(__ECOM_POWERDOWN_WORKAROUND)
       
    77 	// Calls from CActive derived parent objects
       
    78 	virtual void RunL()=0;
       
    79 	virtual void DoCancel()=0;
       
    80 protected:
       
    81 	MMdaImageUtilObserver&	iObserver;
       
    82 	CMdaImageUtility*		iParent;	// link back to the handle class
       
    83 	TUid					iImageType;
       
    84 	TUid					iImageSubType;
       
    85 	TFrameDataBlock*		iFrameData;
       
    86 	TImageDataBlock*		iImageData;
       
    87 	RFs						iFs;
       
    88 	REComSession*			iEcomSession; // not owned
       
    89 #if defined(__ECOM_POWERDOWN_WORKAROUND)
       
    90 	RTimer iWaitTimer;
       
    91 	TInt iWaitTimeCount;
       
    92 #endif defined(__ECOM_POWERDOWN_WORKAROUND)
       
    93 	};
       
    94 
       
    95 // CMdaImageDataReadUtilityPriv
       
    96 class CImageDecoder;
       
    97 class CMdaImageDataReadUtility;
       
    98 class CMdaImageDataReadUtilityPriv; // declared here
       
    99 NONSHARABLE_CLASS( CMdaImageDataReadUtilityPriv ): public CMdaImageUtilityPriv
       
   100 	{
       
   101 public:
       
   102 	virtual ~CMdaImageDataReadUtilityPriv();
       
   103 	// From CMdaImageUtility
       
   104 	virtual void ConvertL(CFbsBitmap& aBitmap,TInt aFrameNumber = 0);
       
   105 	virtual void ConvertL(CFbsBitmap& aBitmap,CFbsBitmap& aMaskBitmap,TInt aFrameNumber = 0);
       
   106 	virtual void CancelConvertL();
       
   107 	virtual void RunL();
       
   108 	virtual void DoCancel();
       
   109 public:
       
   110 	virtual void FrameInfo(TInt aFrame,TFrameInfo& aInfo) const;
       
   111 	virtual TInt FrameCount() const;
       
   112 	virtual void DoClose();
       
   113 	const TDesC& FrameCommentL(TInt aFrameNumber);
       
   114 protected:
       
   115 	enum TState
       
   116 		{
       
   117 		EStateClosed,
       
   118 		EStateOpening,
       
   119 		EStateOpeningWait,
       
   120 		EStateOpen,
       
   121 		EStateConverting
       
   122 		};
       
   123 	CMdaImageDataReadUtilityPriv(MMdaImageUtilObserver& aObserver, CMdaImageDataReadUtility* aParent);
       
   124 
       
   125 	// Creates relevant iDecoder property - depending on subclass.
       
   126 	// Called by "background" AO processing.
       
   127  	virtual void DoOpenL()=0;
       
   128 private:
       
   129 	inline CMdaImageDataReadUtility* Parent() const;
       
   130 	void GetCommentL();
       
   131 
       
   132 protected:
       
   133 	CImageDecoder* iDecoder;
       
   134 	TState iState;
       
   135 
       
   136 	TBool iPrevConvertUnderflowed;
       
   137 	TSize iDestinationSize; // used to check we don't continue with different bitmap
       
   138 	TInt iDestinationHandle;
       
   139 	TInt iDestinationMaskHandle; 
       
   140 	TInt iKeptFrameNumber;
       
   141 	TDisplayMode iDestinationDisplayMode;
       
   142 	TDisplayMode iDestinationMaskDisplayMode;
       
   143 	RPointerArray<HBufC> iComment;
       
   144 	};
       
   145 
       
   146 
       
   147 class CImageEncoder;
       
   148 class CFrameImageData;
       
   149 class CMdaImageDataWriteUtility;
       
   150 class CMdaImageDataWriteUtilityPriv; // declared here
       
   151 NONSHARABLE_CLASS( CMdaImageDataWriteUtilityPriv ): public CMdaImageUtilityPriv
       
   152 	{
       
   153 friend class CMdaImageDataWriteUtility;
       
   154 
       
   155 public:
       
   156 	virtual ~CMdaImageDataWriteUtilityPriv();
       
   157 	// From CMdaImageUtility
       
   158 	virtual void ConvertL(CFbsBitmap& aBitmap,TInt aFrameNumber = 0);
       
   159 	virtual void ConvertL(CFbsBitmap& aBitmap,const TRect& aSourceRect,TInt aFrameNumber = 0);
       
   160 	virtual void ConvertL(CFbsBitmap& aBitmap,CFbsBitmap& aMaskBitmap,TInt aFrameNumber = 0);
       
   161 	virtual void CancelConvertL();
       
   162 	CImageEncoder* Encoder() const;
       
   163 protected:
       
   164 	virtual void RunL();
       
   165 	virtual void DoCancel();
       
   166 protected:
       
   167 	enum TState
       
   168 		{
       
   169 		EStateClosed,
       
   170 		EStateCreating,
       
   171 		EStateOpen,
       
   172 		EStateConverting,
       
   173 		EStateCopying,
       
   174 		EStateCancelled
       
   175 		};
       
   176 	CMdaImageDataWriteUtilityPriv(MMdaImageUtilObserver& aObserver, CMdaImageDataWriteUtility* aParent);
       
   177 
       
   178 	virtual void DoClose();
       
   179 
       
   180 	// Creates relevant <code>iEncoder</code> property - depending on subclass.
       
   181 	// Called by "background" AO processing.
       
   182 	virtual void DoCreateL(TBool aFullCreate=ETrue)=0;
       
   183 
       
   184 	// Used at end to copy any data to destination if req. Default is no-op.
       
   185 	virtual void DoFinalCopyL();
       
   186 
       
   187 	// Complete iEncoder initialisation once created
       
   188 	void CompleteEncoderCreationL();
       
   189 private:
       
   190 	inline CMdaImageDataWriteUtility* Parent() const;
       
   191 protected:
       
   192 	CImageEncoder* iEncoder;
       
   193 	CFrameImageData* iFrameImageData;
       
   194 	TState iState;
       
   195 	};
       
   196 
       
   197 class CMdaImageFileToBitmapUtility;
       
   198 class CMdaImageFileToBitmapUtilityPriv; // declared here
       
   199 NONSHARABLE_CLASS( CMdaImageFileToBitmapUtilityPriv ): public CMdaImageDataReadUtilityPriv
       
   200 	{
       
   201 public:
       
   202 	static CMdaImageFileToBitmapUtilityPriv* NewL(MMdaImageUtilObserver& aObserver, CMdaImageFileToBitmapUtility* aParent);
       
   203 	virtual ~CMdaImageFileToBitmapUtilityPriv();
       
   204 	void OpenL(const TDesC& aFileName,TMdaClipFormat* aFormat = NULL,TMdaPackage* aCodec = NULL,TMdaPackage* aExtra = NULL);
       
   205 protected:
       
   206 	CMdaImageFileToBitmapUtilityPriv(MMdaImageUtilObserver& aObserver, CMdaImageFileToBitmapUtility* aParent);
       
   207 	void ConstructL();
       
   208 	// from CMdaImageDataReadUtility
       
   209 	void DoOpenL();
       
   210 private:
       
   211 	inline CMdaImageFileToBitmapUtility* Parent() const;
       
   212 protected:
       
   213 	HBufC *iFileName;
       
   214 	};
       
   215 
       
   216 class CMdaImageDescToBitmapUtility;
       
   217 class CMdaImageDescToBitmapUtilityPriv; // declared here
       
   218 NONSHARABLE_CLASS( CMdaImageDescToBitmapUtilityPriv ): public CMdaImageDataReadUtilityPriv
       
   219 	{
       
   220 public:
       
   221 	static CMdaImageDescToBitmapUtilityPriv* NewL(MMdaImageUtilObserver& aObserver,CMdaImageDescToBitmapUtility* aParent);
       
   222 	void OpenL(const TDesC8& aDescriptor,TMdaClipFormat* aFormat = NULL,TMdaPackage* aCodec = NULL,TMdaPackage* aExtra = NULL);
       
   223 protected:
       
   224 	CMdaImageDescToBitmapUtilityPriv(MMdaImageUtilObserver& aObserver, CMdaImageDescToBitmapUtility* aParent);
       
   225 	void ConstructL();
       
   226 	// from CMdaImageDataReadUtilityPriv
       
   227 	void DoOpenL();
       
   228 private:
       
   229 	inline CMdaImageDescToBitmapUtility* Parent() const;
       
   230 protected:
       
   231 	const TDesC8* iDescriptor; // not owned
       
   232 	};
       
   233 
       
   234 class CMdaImageBitmapToFileUtility;
       
   235 class CMdaImageBitmapToFileUtilityPriv; // declared here
       
   236 NONSHARABLE_CLASS( CMdaImageBitmapToFileUtilityPriv ): public CMdaImageDataWriteUtilityPriv
       
   237 	{
       
   238 public:
       
   239 	static CMdaImageBitmapToFileUtilityPriv* NewL(MMdaImageUtilObserver& aObserver,CMdaImageBitmapToFileUtility* aParent);
       
   240 	virtual ~CMdaImageBitmapToFileUtilityPriv();
       
   241 	void CreateL(const TDesC& aFileName,TMdaClipFormat* aFormat,TMdaPackage* aCodec,TMdaPackage* aExtra);
       
   242 protected:
       
   243 	CMdaImageBitmapToFileUtilityPriv(MMdaImageUtilObserver& aObserver, CMdaImageBitmapToFileUtility* aParent);
       
   244 	void ConstructL();
       
   245 	// from CMdaImageDataWriteUtility
       
   246 	void DoCreateL(TBool aFullCreate=ETrue);
       
   247 private:
       
   248 	inline CMdaImageBitmapToFileUtility* Parent() const;
       
   249 protected:
       
   250 	HBufC *iFileName;
       
   251 	};
       
   252 
       
   253 class CMdaImageBitmapToDescUtility;
       
   254 class CMdaImageBitmapToDescUtilityPriv; // declared here
       
   255 NONSHARABLE_CLASS( CMdaImageBitmapToDescUtilityPriv ): public CMdaImageDataWriteUtilityPriv
       
   256 	{
       
   257 public:
       
   258 	static CMdaImageBitmapToDescUtilityPriv* NewL(MMdaImageUtilObserver& aObserver,CMdaImageBitmapToDescUtility* aParent);
       
   259 	void CreateL(TDes8& aDescriptor,TMdaClipFormat* aFormat,TMdaPackage* aCodec,TMdaPackage* aExtra);
       
   260 	virtual ~CMdaImageBitmapToDescUtilityPriv();
       
   261 protected:
       
   262 	CMdaImageBitmapToDescUtilityPriv(MMdaImageUtilObserver& aObserver, CMdaImageBitmapToDescUtility* aParent);
       
   263 	// from CMdaImageDataWriteUtility
       
   264 	virtual void DoCreateL(TBool aFullCreate=ETrue);
       
   265 	virtual void DoFinalCopyL();
       
   266 private:
       
   267 	inline CMdaImageBitmapToDescUtility* Parent() const;
       
   268 protected:
       
   269 	TDes8*	iDescriptor;
       
   270 	HBufC8* iSecondBuffer; 
       
   271 	};
       
   272 
       
   273 class CMdaImageBitmapToBitmapUtilityPriv; // declared here
       
   274 NONSHARABLE_CLASS( CMdaImageBitmapToBitmapUtilityPriv ): public CMdaImageUtilityPriv
       
   275 	{
       
   276 public:
       
   277 	static CMdaImageBitmapToBitmapUtilityPriv* NewL(MMdaImageUtilObserver& aObserver, CMdaImageBitmapToBitmapUtility* aParent);
       
   278 	~CMdaImageBitmapToBitmapUtilityPriv();
       
   279 	void OpenL(CFbsBitmap& aBitmap);
       
   280 	// from CMdaImageUtility
       
   281 	virtual void ConvertL(CFbsBitmap& aBitmap, TInt aFrameNumber = 0);
       
   282 	virtual void ConvertL(CFbsBitmap& aBitmap, CFbsBitmap& aMaskBitmap, TInt aFrameNumber = 0);
       
   283 	virtual void CancelConvertL();
       
   284 	virtual void RunL();
       
   285 	virtual void DoCancel();
       
   286 	// From CMdaImageUtility
       
   287 	virtual void DoClose();
       
   288 protected:
       
   289 	CMdaImageBitmapToBitmapUtilityPriv(MMdaImageUtilObserver& aObserver, CMdaImageBitmapToBitmapUtility* aParent);
       
   290 private:
       
   291 	inline CMdaImageBitmapToBitmapUtility* Parent() const;
       
   292 
       
   293 protected:
       
   294 	enum TUtilState
       
   295 		{
       
   296 		EClosed,
       
   297 		EReady,
       
   298 		EOpening,
       
   299 		ECopying
       
   300 		};
       
   301 protected:
       
   302 //	RMdaSourceStreamPort iSrcPort;
       
   303 //	RMdaDestinationStreamPort iDstPort;
       
   304 private:
       
   305 	CBitmapConverter* iBitmapCopier;
       
   306 	TUtilState iState;
       
   307 	CFbsBitmap* iSrcBitmap;
       
   308 	};
       
   309 
       
   310 class CMdaBitmapRotator;
       
   311 class CMdaBitmapRotatorPriv; // declared here
       
   312 NONSHARABLE_CLASS( CMdaBitmapRotatorPriv ): public CActive
       
   313 	{
       
   314 public:
       
   315 	static CMdaBitmapRotatorPriv* NewL();
       
   316 	virtual ~CMdaBitmapRotatorPriv();
       
   317 	void RotateL(MMdaImageUtilObserver& aObserver,CFbsBitmap& aSrcBitmap,CFbsBitmap& aTgtBitmap,CMdaBitmapRotator::TRotationAngle aAngle);
       
   318 	void RotateL(MMdaImageUtilObserver& aObserver,CFbsBitmap& aBitmap,CMdaBitmapRotator::TRotationAngle aAngle);
       
   319 	void CancelRotation();
       
   320 protected:	
       
   321 	CMdaBitmapRotatorPriv();
       
   322 	void ConstructL();
       
   323 	// from CActive
       
   324 	virtual void RunL();
       
   325 	virtual void DoCancel();
       
   326 	CBitmapRotator::TRotationAngle MapRotationAngle(CMdaBitmapRotator::TRotationAngle aAngle);
       
   327 protected:
       
   328 	MMdaImageUtilObserver*	iObserver; // not owned
       
   329 	CBitmapRotator*			iBitmapRotator;
       
   330 	};
       
   331 
       
   332 class CMdaBitmapScaler;
       
   333 class CMdaBitmapScalerPriv; // declared here
       
   334 NONSHARABLE_CLASS( CMdaBitmapScalerPriv ): public CActive
       
   335 	{
       
   336 public:
       
   337 	static CMdaBitmapScalerPriv* NewL();
       
   338 	virtual ~CMdaBitmapScalerPriv();
       
   339 	void ScaleL(MMdaImageUtilObserver& aObserver,CFbsBitmap& aSrcBitmap,CFbsBitmap& aTgtBitmap,TBool aMaintainAspectRatio = ETrue);
       
   340 	void ScaleL(MMdaImageUtilObserver& aObserver,CFbsBitmap& aBitmap,TSize aDestSize,TBool aMaintainAspectRatio = ETrue);
       
   341 	void CancelScaling();
       
   342 protected:
       
   343 	CMdaBitmapScalerPriv();
       
   344 	void ConstructL();
       
   345 	// from CActive
       
   346 	virtual void RunL();
       
   347 	virtual void DoCancel();
       
   348 protected:
       
   349 	MMdaImageUtilObserver*	iObserver;	// not owned
       
   350 	CBitmapScaler*			iBitmapScaler;
       
   351 	};
       
   352 
       
   353 #include "MdaImageConverterPriv.inl"
       
   354 
       
   355 #endif // __MDAIMAGECONVERTERPRIV_H__
       
   356