os/mm/mmlibs/mmfw/tsrc/mmfunittest/VCLNT/TS_VideoInput/MmfVideoInput.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 2002-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 __MMF_VIDEOINPUT_H__
    17 #define __MMF_VIDEOINPUT_H__
    18 
    19 // Standard EPOC32 includes required by this header file
    20 #include <e32base.h>
    21 #include <e32std.h>
    22 
    23 #include <e32hal.h>
    24 #include <e32svr.h>
    25 
    26 // Public Media Server includes
    27 #include <mmf/server/mmfdatasink.h>
    28 #include <mmf/server/mmfdatasource.h>
    29 #include <mmf/server/mmfdatapath.h>
    30 #include <mmf/server/mmfdatasourcesink.hrh>
    31 
    32 #include <mmf/server/mmfcodec.h>
    33 #include <mmf/server/mmfdatabuffer.h>
    34 #include <mmf/common/mmfpaniccodes.h>
    35 
    36 #include "mmfVideoInputInterfaceUIDs.hrh"
    37 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
    38 #include <mmf/common/mmfhelper.h>
    39 #endif
    40 // DevSound
    41 
    42 const TUint KVideoInputDefaultFrameSize = 0x1000;
    43 //#define KVideoInputCanResample		//uncomment this to allow Video Input to sample rate convert
    44 const TUid KUidMmfVideoInput	= {KMmfUidVideoInputInterface};
    45 
    46 class CHardwareCodec;
    47 
    48 void Panic(TInt aPanicCode);
    49 
    50 class MMMFVideoInput : public MDataSource
    51 /*
    52 Interface class to allow dynamic linkage to CMMFVideoInput.
    53 */
    54 	{
    55 public:
    56 	//factory function
    57 	inline static MMMFVideoInput* NewVideoInputL(TUid aImplementationUid, const TDesC8& aInitData);
    58 	//interface
    59 	virtual void HWFillBufferL(CMMFBuffer* aBuffer, MDataSink* aConsumer) = 0;
    60 protected:
    61 	//constructor
    62 	inline MMMFVideoInput() : MDataSource(KUidMmfVideoInput) {};
    63 	};
    64 
    65 inline MMMFVideoInput* MMMFVideoInput::NewVideoInputL( TUid aImplementationUid,  const TDesC8& aInitData )
    66 	{
    67 	//make sure the cast will be ok by checking the uid is what we expect
    68 //	__ASSERT_ALWAYS(aImplementationUid==KUidMmfVideoInput, Panic(EMMFVideoInputPanicBadUID));
    69 	MMMFVideoInput* retPtr = STATIC_CAST(MMMFVideoInput*, MDataSource::NewSourceL(aImplementationUid, aInitData));
    70 	return retPtr;
    71 	}
    72 
    73 
    74 class CMMFVideoInput : public CBase, public MMMFVideoInput
    75 /**
    76 The interface into DevSound
    77 **/
    78 	{
    79 public:
    80 
    81 	static MDataSource* NewSourceL();
    82 	virtual ~CMMFVideoInput();
    83 
    84 	//MDataSource mixin implementations
    85 	virtual TFourCC SourceDataTypeCode(TMediaId /*aMediaId*/);
    86 	virtual void FillBufferL(CMMFBuffer* aBuffer, MDataSink* aConsumer,TMediaId /*aMediaId*/);//called by a MDataSink to request buffer fill
    87 	virtual void BufferEmptiedL(CMMFBuffer* aBuffer); //called by MDataSink to pass back emptied buffer to the source
    88 	virtual TBool CanCreateSourceBuffer();
    89 	virtual CMMFBuffer* CreateSourceBufferL(TMediaId /*aMediaId*/);
    90 		//XXX optimal source buffer size creation may depend on the sink buffer & vice versa
    91 	virtual CMMFBuffer* CreateSourceBufferL(TMediaId aMediaId, CMMFBuffer& /*aSinkBuffer*/)
    92 		{return CreateSourceBufferL(aMediaId);};
    93 	virtual CMMFBuffer* CreateSourceBufferL(TMediaId /*aMediaId*/, TBool &aReference);
    94 		//XXX optimal source buffer size creation may depend on the sink buffer & vice versa
    95 	virtual CMMFBuffer* CreateSourceBufferL(TMediaId aMediaId, CMMFBuffer& /*aSinkBuffer*/, TBool &aReference)
    96 		{return CreateSourceBufferL(aMediaId, aReference);};
    97 	virtual TInt SourceThreadLogon(MAsyncEventHandler& aEventHandler);
    98 	virtual void SourceThreadLogoff();
    99 	virtual void SourcePrimeL();
   100 	virtual void SourceStopL();
   101 	virtual void SourcePlayL();
   102 	virtual void SetSourcePrioritySettings(const TMMFPrioritySettings& aPrioritySettings);
   103 
   104 	virtual void NegotiateL(MDataSink& aSink);
   105 
   106 	// MMMFVideoInput mixin implementations
   107 	TInt BytesPlayed();
   108 	void HWFillBufferL(CMMFBuffer* aBuffer, MDataSink* aConsumer); //called by a FillBufferL if using HW codec
   109 
   110 	TRequestStatus iBufferStatus;
   111 
   112 protected:
   113 	virtual void ConstructSourceL( const TDesC8& aInitData ) ;
   114 
   115 private:
   116 	inline CMMFVideoInput() {}
   117 
   118 	MAsyncEventHandler* iEventHandler;
   119 
   120 
   121 
   122 private:
   123 
   124 	enum TCodec
   125 		{
   126 		EUseARMCodec=0,
   127 		EUseHWCodec
   128 		};
   129 
   130 	enum TState
   131 		{
   132 		EIdle=0,
   133 		EDevSoundReady,
   134 		EBufferEmpty
   135 		};
   136 
   137 	enum TError
   138 		{
   139 		ECantCreateBuffer,
   140 		EEmptyBuffer,
   141 		EDevSoundNotLoaded,
   142 		EUnknown
   143 		};
   144 
   145 
   146 	MDataSink* iConsumer;
   147 	TState iState;
   148 	CHardwareCodec* iHWCodec;
   149 	CMMFBuffer* iBuffer;
   150 
   151 	TBool iFirstBufferRead;
   152 
   153 	TBool iDevSoundLoaded;
   154 	TBool iStopped;
   155 
   156 	TError iError;
   157 	TInt iMMFDevsoundError;
   158 	TCodec iCodecSelect;
   159 	TMMFPrioritySettings iPrioritySettings;
   160 
   161 	TUint iSinkSampleRate;
   162 	TUint iSinkChannels;
   163 	TFourCC iSinkFourCC;
   164 	TBool iNeedsSWConversion;
   165 	CMMFChannelAndSampleRateConverterFactory* iChannelAndSampleRateConverterFactory;
   166 	CMMFChannelAndSampleRateConverter* iChannelAndSampleRateConverter;
   167 	CMMFDataBuffer* iConvertBuffer;
   168 	CMMFBuffer* iBufferToEmpty;
   169 	CMMFBuffer* iDevSoundBuf;
   170 	};
   171 
   172 #endif