sl@0: // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #ifndef __MMF_VIDEOINPUT_H__ sl@0: #define __MMF_VIDEOINPUT_H__ sl@0: sl@0: // Standard EPOC32 includes required by this header file sl@0: #include sl@0: #include sl@0: sl@0: #include sl@0: #include sl@0: sl@0: // Public Media Server includes sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #include "mmfVideoInputInterfaceUIDs.hrh" sl@0: #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS sl@0: #include sl@0: #endif sl@0: // DevSound sl@0: sl@0: const TUint KVideoInputDefaultFrameSize = 0x1000; sl@0: //#define KVideoInputCanResample //uncomment this to allow Video Input to sample rate convert sl@0: const TUid KUidMmfVideoInput = {KMmfUidVideoInputInterface}; sl@0: sl@0: class CHardwareCodec; sl@0: sl@0: void Panic(TInt aPanicCode); sl@0: sl@0: class MMMFVideoInput : public MDataSource sl@0: /* sl@0: Interface class to allow dynamic linkage to CMMFVideoInput. sl@0: */ sl@0: { sl@0: public: sl@0: //factory function sl@0: inline static MMMFVideoInput* NewVideoInputL(TUid aImplementationUid, const TDesC8& aInitData); sl@0: //interface sl@0: virtual void HWFillBufferL(CMMFBuffer* aBuffer, MDataSink* aConsumer) = 0; sl@0: protected: sl@0: //constructor sl@0: inline MMMFVideoInput() : MDataSource(KUidMmfVideoInput) {}; sl@0: }; sl@0: sl@0: inline MMMFVideoInput* MMMFVideoInput::NewVideoInputL( TUid aImplementationUid, const TDesC8& aInitData ) sl@0: { sl@0: //make sure the cast will be ok by checking the uid is what we expect sl@0: // __ASSERT_ALWAYS(aImplementationUid==KUidMmfVideoInput, Panic(EMMFVideoInputPanicBadUID)); sl@0: MMMFVideoInput* retPtr = STATIC_CAST(MMMFVideoInput*, MDataSource::NewSourceL(aImplementationUid, aInitData)); sl@0: return retPtr; sl@0: } sl@0: sl@0: sl@0: class CMMFVideoInput : public CBase, public MMMFVideoInput sl@0: /** sl@0: The interface into DevSound sl@0: **/ sl@0: { sl@0: public: sl@0: sl@0: static MDataSource* NewSourceL(); sl@0: virtual ~CMMFVideoInput(); sl@0: sl@0: //MDataSource mixin implementations sl@0: virtual TFourCC SourceDataTypeCode(TMediaId /*aMediaId*/); sl@0: virtual void FillBufferL(CMMFBuffer* aBuffer, MDataSink* aConsumer,TMediaId /*aMediaId*/);//called by a MDataSink to request buffer fill sl@0: virtual void BufferEmptiedL(CMMFBuffer* aBuffer); //called by MDataSink to pass back emptied buffer to the source sl@0: virtual TBool CanCreateSourceBuffer(); sl@0: virtual CMMFBuffer* CreateSourceBufferL(TMediaId /*aMediaId*/); sl@0: //XXX optimal source buffer size creation may depend on the sink buffer & vice versa sl@0: virtual CMMFBuffer* CreateSourceBufferL(TMediaId aMediaId, CMMFBuffer& /*aSinkBuffer*/) sl@0: {return CreateSourceBufferL(aMediaId);}; sl@0: virtual CMMFBuffer* CreateSourceBufferL(TMediaId /*aMediaId*/, TBool &aReference); sl@0: //XXX optimal source buffer size creation may depend on the sink buffer & vice versa sl@0: virtual CMMFBuffer* CreateSourceBufferL(TMediaId aMediaId, CMMFBuffer& /*aSinkBuffer*/, TBool &aReference) sl@0: {return CreateSourceBufferL(aMediaId, aReference);}; sl@0: virtual TInt SourceThreadLogon(MAsyncEventHandler& aEventHandler); sl@0: virtual void SourceThreadLogoff(); sl@0: virtual void SourcePrimeL(); sl@0: virtual void SourceStopL(); sl@0: virtual void SourcePlayL(); sl@0: virtual void SetSourcePrioritySettings(const TMMFPrioritySettings& aPrioritySettings); sl@0: sl@0: virtual void NegotiateL(MDataSink& aSink); sl@0: sl@0: // MMMFVideoInput mixin implementations sl@0: TInt BytesPlayed(); sl@0: void HWFillBufferL(CMMFBuffer* aBuffer, MDataSink* aConsumer); //called by a FillBufferL if using HW codec sl@0: sl@0: TRequestStatus iBufferStatus; sl@0: sl@0: protected: sl@0: virtual void ConstructSourceL( const TDesC8& aInitData ) ; sl@0: sl@0: private: sl@0: inline CMMFVideoInput() {} sl@0: sl@0: MAsyncEventHandler* iEventHandler; sl@0: sl@0: sl@0: sl@0: private: sl@0: sl@0: enum TCodec sl@0: { sl@0: EUseARMCodec=0, sl@0: EUseHWCodec sl@0: }; sl@0: sl@0: enum TState sl@0: { sl@0: EIdle=0, sl@0: EDevSoundReady, sl@0: EBufferEmpty sl@0: }; sl@0: sl@0: enum TError sl@0: { sl@0: ECantCreateBuffer, sl@0: EEmptyBuffer, sl@0: EDevSoundNotLoaded, sl@0: EUnknown sl@0: }; sl@0: sl@0: sl@0: MDataSink* iConsumer; sl@0: TState iState; sl@0: CHardwareCodec* iHWCodec; sl@0: CMMFBuffer* iBuffer; sl@0: sl@0: TBool iFirstBufferRead; sl@0: sl@0: TBool iDevSoundLoaded; sl@0: TBool iStopped; sl@0: sl@0: TError iError; sl@0: TInt iMMFDevsoundError; sl@0: TCodec iCodecSelect; sl@0: TMMFPrioritySettings iPrioritySettings; sl@0: sl@0: TUint iSinkSampleRate; sl@0: TUint iSinkChannels; sl@0: TFourCC iSinkFourCC; sl@0: TBool iNeedsSWConversion; sl@0: CMMFChannelAndSampleRateConverterFactory* iChannelAndSampleRateConverterFactory; sl@0: CMMFChannelAndSampleRateConverter* iChannelAndSampleRateConverter; sl@0: CMMFDataBuffer* iConvertBuffer; sl@0: CMMFBuffer* iBufferToEmpty; sl@0: CMMFBuffer* iDevSoundBuf; sl@0: }; sl@0: sl@0: #endif