os/mm/mmlibs/mmfw/tsrc/mmfunittest/VCLNT/TS_VideoInput/MmfVideoInput.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfunittest/VCLNT/TS_VideoInput/MmfVideoInput.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,172 @@
     1.4 +// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#ifndef __MMF_VIDEOINPUT_H__
    1.20 +#define __MMF_VIDEOINPUT_H__
    1.21 +
    1.22 +// Standard EPOC32 includes required by this header file
    1.23 +#include <e32base.h>
    1.24 +#include <e32std.h>
    1.25 +
    1.26 +#include <e32hal.h>
    1.27 +#include <e32svr.h>
    1.28 +
    1.29 +// Public Media Server includes
    1.30 +#include <mmf/server/mmfdatasink.h>
    1.31 +#include <mmf/server/mmfdatasource.h>
    1.32 +#include <mmf/server/mmfdatapath.h>
    1.33 +#include <mmf/server/mmfdatasourcesink.hrh>
    1.34 +
    1.35 +#include <mmf/server/mmfcodec.h>
    1.36 +#include <mmf/server/mmfdatabuffer.h>
    1.37 +#include <mmf/common/mmfpaniccodes.h>
    1.38 +
    1.39 +#include "mmfVideoInputInterfaceUIDs.hrh"
    1.40 +#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
    1.41 +#include <mmf/common/mmfhelper.h>
    1.42 +#endif
    1.43 +// DevSound
    1.44 +
    1.45 +const TUint KVideoInputDefaultFrameSize = 0x1000;
    1.46 +//#define KVideoInputCanResample		//uncomment this to allow Video Input to sample rate convert
    1.47 +const TUid KUidMmfVideoInput	= {KMmfUidVideoInputInterface};
    1.48 +
    1.49 +class CHardwareCodec;
    1.50 +
    1.51 +void Panic(TInt aPanicCode);
    1.52 +
    1.53 +class MMMFVideoInput : public MDataSource
    1.54 +/*
    1.55 +Interface class to allow dynamic linkage to CMMFVideoInput.
    1.56 +*/
    1.57 +	{
    1.58 +public:
    1.59 +	//factory function
    1.60 +	inline static MMMFVideoInput* NewVideoInputL(TUid aImplementationUid, const TDesC8& aInitData);
    1.61 +	//interface
    1.62 +	virtual void HWFillBufferL(CMMFBuffer* aBuffer, MDataSink* aConsumer) = 0;
    1.63 +protected:
    1.64 +	//constructor
    1.65 +	inline MMMFVideoInput() : MDataSource(KUidMmfVideoInput) {};
    1.66 +	};
    1.67 +
    1.68 +inline MMMFVideoInput* MMMFVideoInput::NewVideoInputL( TUid aImplementationUid,  const TDesC8& aInitData )
    1.69 +	{
    1.70 +	//make sure the cast will be ok by checking the uid is what we expect
    1.71 +//	__ASSERT_ALWAYS(aImplementationUid==KUidMmfVideoInput, Panic(EMMFVideoInputPanicBadUID));
    1.72 +	MMMFVideoInput* retPtr = STATIC_CAST(MMMFVideoInput*, MDataSource::NewSourceL(aImplementationUid, aInitData));
    1.73 +	return retPtr;
    1.74 +	}
    1.75 +
    1.76 +
    1.77 +class CMMFVideoInput : public CBase, public MMMFVideoInput
    1.78 +/**
    1.79 +The interface into DevSound
    1.80 +**/
    1.81 +	{
    1.82 +public:
    1.83 +
    1.84 +	static MDataSource* NewSourceL();
    1.85 +	virtual ~CMMFVideoInput();
    1.86 +
    1.87 +	//MDataSource mixin implementations
    1.88 +	virtual TFourCC SourceDataTypeCode(TMediaId /*aMediaId*/);
    1.89 +	virtual void FillBufferL(CMMFBuffer* aBuffer, MDataSink* aConsumer,TMediaId /*aMediaId*/);//called by a MDataSink to request buffer fill
    1.90 +	virtual void BufferEmptiedL(CMMFBuffer* aBuffer); //called by MDataSink to pass back emptied buffer to the source
    1.91 +	virtual TBool CanCreateSourceBuffer();
    1.92 +	virtual CMMFBuffer* CreateSourceBufferL(TMediaId /*aMediaId*/);
    1.93 +		//XXX optimal source buffer size creation may depend on the sink buffer & vice versa
    1.94 +	virtual CMMFBuffer* CreateSourceBufferL(TMediaId aMediaId, CMMFBuffer& /*aSinkBuffer*/)
    1.95 +		{return CreateSourceBufferL(aMediaId);};
    1.96 +	virtual CMMFBuffer* CreateSourceBufferL(TMediaId /*aMediaId*/, TBool &aReference);
    1.97 +		//XXX optimal source buffer size creation may depend on the sink buffer & vice versa
    1.98 +	virtual CMMFBuffer* CreateSourceBufferL(TMediaId aMediaId, CMMFBuffer& /*aSinkBuffer*/, TBool &aReference)
    1.99 +		{return CreateSourceBufferL(aMediaId, aReference);};
   1.100 +	virtual TInt SourceThreadLogon(MAsyncEventHandler& aEventHandler);
   1.101 +	virtual void SourceThreadLogoff();
   1.102 +	virtual void SourcePrimeL();
   1.103 +	virtual void SourceStopL();
   1.104 +	virtual void SourcePlayL();
   1.105 +	virtual void SetSourcePrioritySettings(const TMMFPrioritySettings& aPrioritySettings);
   1.106 +
   1.107 +	virtual void NegotiateL(MDataSink& aSink);
   1.108 +
   1.109 +	// MMMFVideoInput mixin implementations
   1.110 +	TInt BytesPlayed();
   1.111 +	void HWFillBufferL(CMMFBuffer* aBuffer, MDataSink* aConsumer); //called by a FillBufferL if using HW codec
   1.112 +
   1.113 +	TRequestStatus iBufferStatus;
   1.114 +
   1.115 +protected:
   1.116 +	virtual void ConstructSourceL( const TDesC8& aInitData ) ;
   1.117 +
   1.118 +private:
   1.119 +	inline CMMFVideoInput() {}
   1.120 +
   1.121 +	MAsyncEventHandler* iEventHandler;
   1.122 +
   1.123 +
   1.124 +
   1.125 +private:
   1.126 +
   1.127 +	enum TCodec
   1.128 +		{
   1.129 +		EUseARMCodec=0,
   1.130 +		EUseHWCodec
   1.131 +		};
   1.132 +
   1.133 +	enum TState
   1.134 +		{
   1.135 +		EIdle=0,
   1.136 +		EDevSoundReady,
   1.137 +		EBufferEmpty
   1.138 +		};
   1.139 +
   1.140 +	enum TError
   1.141 +		{
   1.142 +		ECantCreateBuffer,
   1.143 +		EEmptyBuffer,
   1.144 +		EDevSoundNotLoaded,
   1.145 +		EUnknown
   1.146 +		};
   1.147 +
   1.148 +
   1.149 +	MDataSink* iConsumer;
   1.150 +	TState iState;
   1.151 +	CHardwareCodec* iHWCodec;
   1.152 +	CMMFBuffer* iBuffer;
   1.153 +
   1.154 +	TBool iFirstBufferRead;
   1.155 +
   1.156 +	TBool iDevSoundLoaded;
   1.157 +	TBool iStopped;
   1.158 +
   1.159 +	TError iError;
   1.160 +	TInt iMMFDevsoundError;
   1.161 +	TCodec iCodecSelect;
   1.162 +	TMMFPrioritySettings iPrioritySettings;
   1.163 +
   1.164 +	TUint iSinkSampleRate;
   1.165 +	TUint iSinkChannels;
   1.166 +	TFourCC iSinkFourCC;
   1.167 +	TBool iNeedsSWConversion;
   1.168 +	CMMFChannelAndSampleRateConverterFactory* iChannelAndSampleRateConverterFactory;
   1.169 +	CMMFChannelAndSampleRateConverter* iChannelAndSampleRateConverter;
   1.170 +	CMMFDataBuffer* iConvertBuffer;
   1.171 +	CMMFBuffer* iBufferToEmpty;
   1.172 +	CMMFBuffer* iDevSoundBuf;
   1.173 +	};
   1.174 +
   1.175 +#endif