imagingandcamerafws/imagingunittest/testcodec/inc/TestAsyncConvert.h
changeset 0 40261b775718
equal deleted inserted replaced
-1:000000000000 0:40261b775718
       
     1 // Copyright (c) 2003-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 #ifndef __TESTASYNCCONVERT_H__
       
    17 #define __TESTASYNCCONVERT_H__
       
    18 
       
    19 #include "imageconversion.h"
       
    20 #include "TestAsyncCodec.h"
       
    21 #include <icl/imageplugin.h>
       
    22 
       
    23 // forward refs
       
    24 class CTestAsyncReadCodec;
       
    25 class CTestAsyncWriteCodec;
       
    26 
       
    27 // MAsyncSchedulerObserver
       
    28 // mixin class to handle callbacks from an CAsyncScheduler object
       
    29 class MAsyncSchedulerObserver
       
    30 	{
       
    31 public:
       
    32 	virtual void MasoProcessL(TInt error) = 0;
       
    33 	};
       
    34 
       
    35 class CAsyncScheduler : public CActive
       
    36 	{
       
    37 public:
       
    38 	CAsyncScheduler(MAsyncSchedulerObserver& aSchedulerObserver);
       
    39 	void Start();
       
    40 
       
    41 	// From CActive
       
    42 	virtual void RunL();
       
    43 	virtual void DoCancel() {};
       
    44 
       
    45 private:
       
    46 	MAsyncSchedulerObserver& iSchedulerObserver;
       
    47 	};
       
    48 
       
    49 
       
    50 class CTestAsyncDecoder : public CImageDecoderPlugin, 
       
    51 	public MAsyncSchedulerObserver
       
    52 	{
       
    53 public:
       
    54 	static CTestAsyncDecoder* NewL();
       
    55 	virtual ~CTestAsyncDecoder();
       
    56 
       
    57 	virtual void ImageType(TInt aFrameNumber, TUid& aImageType, TUid& aImageSubType) const;
       
    58 	CFrameInfoStrings* FrameInfoStringsL(RFs& aFs, TInt aFrameNumber);
       
    59 
       
    60 	// From CImageDecoderPlugin
       
    61 	virtual void DoConvert();
       
    62 	virtual TInt NumberOfImageComments() const;
       
    63 	virtual HBufC* ImageCommentL(TInt aCommentNumber) const;
       
    64 	virtual TInt NumberOfFrameComments(TInt aFrameNumber) const;
       
    65 	virtual HBufC* FrameCommentL(TInt aFrameNumber, TInt aCommentNumber) const;
       
    66 	void ScanDataL();
       
    67 	virtual void Cleanup();
       
    68 
       
    69 	// from MAsyncSchedulerObserver
       
    70 	virtual void MasoProcessL(TInt aError);
       
    71 
       
    72 	// callback from CTestAsyncReadCodec to indicate completion
       
    73 	// of CTestAsyncReadCodec::ProcessFrameL()
       
    74 	void ProcessFrameComplete(TInt aError);
       
    75 
       
    76 private:
       
    77 	CTestAsyncDecoder();
       
    78 	void ConstructL();
       
    79 
       
    80 
       
    81 private:
       
    82 	enum TDecodeState
       
    83 		{
       
    84 		EDecodeInit,
       
    85 		EDecodeInProgress,
       
    86 		EDecodeFinished
       
    87 		};
       
    88 	TDecodeState iDecodeState;
       
    89 	
       
    90 	CTestAsyncReadCodec* iImageReadCodec;	// not owned
       
    91 	TInt iDecodeIterations;
       
    92 
       
    93 	TInt iMaxValue;
       
    94 	TBool iReadHeaders;
       
    95 
       
    96 	CAsyncScheduler* iScheduler;
       
    97 
       
    98 	TInt iError;
       
    99 	};
       
   100 
       
   101 
       
   102 class CTestAsyncEncoder : public CImageEncoderPlugin, public MAsyncSchedulerObserver
       
   103 	{
       
   104 public:
       
   105 	static CTestAsyncEncoder* NewL();
       
   106 	virtual ~CTestAsyncEncoder();
       
   107 
       
   108 	// From CImageEncoderPlugin
       
   109 	virtual void DoConvert();
       
   110 	void PrepareEncoderL(const CFrameImageData* aFrameImageData);
       
   111 	virtual void Cleanup();
       
   112 	void UpdateHeaderL();
       
   113 
       
   114 	// from MAsyncSchedulerObserver
       
   115 	virtual void MasoProcessL(TInt aError);
       
   116 
       
   117 	// callback from CTestAsyncWriteCodec to indicate completion
       
   118 	// of CTestAsyncWriteCodec::ProcessFrameL()
       
   119 	void ProcessFrameComplete(TInt aError);
       
   120 
       
   121 private:
       
   122 	CTestAsyncEncoder();
       
   123 	void ConstructL();
       
   124 
       
   125 
       
   126 private:
       
   127 	enum TEncodeState
       
   128 		{
       
   129 		EEncodeInit,
       
   130 		EEncodeInProgress,
       
   131 		EEncodeFinished
       
   132 		};
       
   133 	TEncodeState iEncodeState;
       
   134 	
       
   135 	CTestAsyncWriteCodec* iImageWriteCodec;	// not owned
       
   136 	TInt iEncodeIterations;
       
   137 
       
   138 	TInt iMaxValue;
       
   139 	TBool iReadHeaders;
       
   140 
       
   141 	CAsyncScheduler* iScheduler;
       
   142 
       
   143 	TInt iError;
       
   144 	};
       
   145 
       
   146 
       
   147 #endif
       
   148