sl@0: // Copyright (c) 2001-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 __MMFFILE_H_ sl@0: #define __MMFFILE_H_ sl@0: sl@0: #include sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: class CReadWriteRequest; sl@0: class CTransferBufferCopy; sl@0: class MGenericFile; sl@0: sl@0: /** sl@0: @publishedAll sl@0: @released sl@0: sl@0: Provides the filename and path of file. sl@0: sl@0: Used by CMMFFile::ConstructL(). sl@0: */ sl@0: class TMMFFileParams sl@0: { sl@0: public: sl@0: /** sl@0: Filename and path of file. sl@0: */ sl@0: TFileName iPath ; // Filename and path of file. sl@0: private: sl@0: /** sl@0: This member is internal and not intended for use. sl@0: */ sl@0: TInt iReserved1; sl@0: }; sl@0: sl@0: /** sl@0: @publishedAll sl@0: */ sl@0: const TUid KFileHandleUid = {0x101FFA19}; sl@0: const TUid KMMFileSourceUid = {0x101F7DA9}; sl@0: const TUid KMMFileHandleSourceUid = {0x101F7DAA}; sl@0: sl@0: /** sl@0: @publishedAll sl@0: @released sl@0: sl@0: Provides a pointer to the file handle sl@0: sl@0: Used by CMMFFile::ConstructL(). sl@0: */ sl@0: class TMMFFileHandleParams sl@0: { sl@0: public: sl@0: TMMFFileHandleParams(RFile* aFile) : iUid(KFileHandleUid), iFile(aFile) {} sl@0: TMMFFileHandleParams() : iUid(KFileHandleUid) {} sl@0: sl@0: TUid iUid; sl@0: /** sl@0: Handle of file sl@0: */ sl@0: RFile* iFile; sl@0: private: sl@0: /** sl@0: This member is internal and not intended for use. sl@0: */ sl@0: TInt iReserved1; sl@0: }; sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: typedef TPckgBuf TMMFFileConfig ; sl@0: sl@0: /** sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: typedef TPckgBuf TMMFFileHandleConfig ; sl@0: sl@0: sl@0: /** sl@0: @publishedAll sl@0: @released sl@0: sl@0: This details how big the iTransferBufferCopies array of CMMFFile may sl@0: become before we start looking to free entries. sl@0: */ sl@0: const TInt KAcceptableTransferBufferCopiesSize = 5; sl@0: sl@0: /** sl@0: @publishedAll sl@0: @released sl@0: sl@0: This details how big the iTransferBufferCopies array of CMMFFile may sl@0: become before we start looking to free entries. sl@0: */ sl@0: const TInt KMaximumTransferBufferCopiesSize = 100; sl@0: sl@0: sl@0: /** sl@0: @publishedAll sl@0: @released sl@0: sl@0: MultiMedia framework class. Represents a physical file. sl@0: sl@0: This may be source file from which data is read or destination to which data is written. sl@0: sl@0: Intended to be used by controller plugin developers for source and sink plugins. sl@0: */ sl@0: class CMMFFile : public CMMFClip sl@0: { sl@0: public: sl@0: // From MDataSource sl@0: virtual TFourCC SourceDataTypeCode(TMediaId aMediaId) ; sl@0: virtual void FillBufferL( CMMFBuffer* aBuffer, MDataSink* aConsumer, TMediaId aMediaId ) ; sl@0: virtual void BufferEmptiedL( CMMFBuffer* aBuffer ) ; sl@0: virtual TBool CanCreateSourceBuffer() ; sl@0: virtual CMMFBuffer* CreateSourceBufferL( TMediaId aMediaId, TBool &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: sl@0: // From MDataSink sl@0: virtual TFourCC SinkDataTypeCode(TMediaId aMediaId) ; //used by data path MDataSource/Sink for codec matching sl@0: virtual void EmptyBufferL( CMMFBuffer* aBuffer, MDataSource* aSupplier, TMediaId aMediaId ) ; sl@0: virtual void BufferFilledL( CMMFBuffer* aBuffer ) ; sl@0: virtual TBool CanCreateSinkBuffer() ; sl@0: virtual CMMFBuffer* CreateSinkBufferL( TMediaId aMediaId , TBool &aReference) ; sl@0: virtual TInt SinkThreadLogon(MAsyncEventHandler& aEventHandler) ; sl@0: virtual void SinkThreadLogoff(); sl@0: virtual void SinkPrimeL(); sl@0: virtual void SinkStopL(); sl@0: sl@0: // From CMMFClip sl@0: virtual void ReadBufferL( TInt aLength, CMMFBuffer* aBuffer, TInt aPosition, MDataSink* aConsumer); sl@0: virtual void WriteBufferL( TInt aLength, CMMFBuffer* aBuffer, TInt aPosition, MDataSource* aSupplier); sl@0: virtual void ReadBufferL( CMMFBuffer* aBuffer, TInt aPosition, MDataSink* aConsumer) ; sl@0: virtual void WriteBufferL( CMMFBuffer* aBuffer, TInt aPosition, MDataSource* aSupplier) ; sl@0: virtual void ReadBufferL( CMMFBuffer* aBuffer, TInt aPosition ) ; sl@0: virtual void WriteBufferL( CMMFBuffer* aBuffer, TInt aPosition ) ; sl@0: virtual TInt64 BytesFree() ; // amount of space available for the clip sl@0: virtual TInt Size() ; sl@0: virtual TInt Delete(); sl@0: virtual TInt SetSize(TInt aSize); sl@0: sl@0: // New Functions sl@0: virtual const TDesC& FileName() const ; sl@0: virtual const TDesC& Extension() const ; sl@0: virtual const TDesC& FilePath() const ; sl@0: virtual const TDesC& FileDrive() const ; sl@0: virtual const TFileName FullName() const; sl@0: virtual RFile& FileL() ; sl@0: sl@0: public : sl@0: virtual ~CMMFFile() ; sl@0: static MDataSource* NewSourceL() ; sl@0: static MDataSink* NewSinkL() ; sl@0: sl@0: void SetTransferBuffer (TBool aTBuffer) ; sl@0: TBool CanUseTransferBuffer () ; sl@0: virtual TBool SinkStopped(); sl@0: sl@0: protected: sl@0: /** sl@0: Indicates for which purpose the object instance is being created sl@0: */ sl@0: enum TMMFileMode sl@0: { sl@0: /** The object is created for being a source */ sl@0: ESourceMode, sl@0: /** The object is created for being a sink */ sl@0: ESinkMode sl@0: }; sl@0: virtual void ConstructSourceL( const TDesC8& aInitData ) ; sl@0: virtual void ConstructSinkL( const TDesC8& aInitData ) ; sl@0: void ConstructL(const TDesC8& aInitData, TMMFileMode aFileMode) ; sl@0: CMMFFile() ; sl@0: sl@0: void StoreRequestL( CReadWriteRequest* aRequest ) ; sl@0: void CancelRequests(); sl@0: sl@0: sl@0: CTransferBufferCopy* ObtainCopyOfTransferBufferL(TInt aMaxLength); sl@0: sl@0: public: sl@0: // Additional virtuals for DRM Intent sl@0: virtual TInt ExecuteIntent(ContentAccess::TIntent aIntent); sl@0: virtual TInt EvaluateIntent(ContentAccess::TIntent aIntent) const; sl@0: virtual TBool IsProtectedL() const; sl@0: sl@0: virtual TInt SetAgentProperty(ContentAccess::TAgentProperty aProperty, TInt aValue); sl@0: virtual const TDesC& UniqueId() const; sl@0: sl@0: private: sl@0: class CMMFFileAsyncEventHandler : public MAsyncEventHandler sl@0: { sl@0: public: sl@0: CMMFFileAsyncEventHandler(CMMFFile* aParent); sl@0: virtual ~CMMFFileAsyncEventHandler(); sl@0: public: sl@0: virtual TInt SendEventToClient(const TMMFEvent& aEvent); sl@0: private: sl@0: CMMFFile* iParent; sl@0: }; sl@0: sl@0: class CCAFParameters : public CBase sl@0: { sl@0: public: sl@0: CCAFParameters() : iUniqueId(NULL), iEnableUI(EFalse) {} sl@0: ~CCAFParameters() { delete iUniqueId; } sl@0: public: sl@0: HBufC* iUniqueId; sl@0: TBool iEnableUI; sl@0: }; sl@0: sl@0: public: sl@0: virtual TInt Data(ContentAccess::CData*& aData); sl@0: virtual void SourcePauseL(); sl@0: sl@0: private: sl@0: MGenericFile* iFile; sl@0: RFs iFsSession; sl@0: sl@0: TBool iFileHandle; sl@0: RFile iHandle; sl@0: TBool iReserved; sl@0: sl@0: TBool iSinkNotStopped; sl@0: sl@0: TFileName iFullFileName ; sl@0: HBufC* iFileName ; sl@0: HBufC* iFileExt ; sl@0: HBufC* iFilePath ; sl@0: HBufC* iFileDrive ; sl@0: CCAFParameters* iCAFParameters; sl@0: TInt iFileSize; //holds the cached file size sl@0: sl@0: //Keeps track of the read position within the file. Needed in order to enable passing of the sl@0: //read position to the CReadRequest to manage the LastBuffer flag. sl@0: //NB: Continuous reads once EOF has been reached will result in iPosition going > iFileSize, sl@0: //but this causes no ill effects sl@0: TUint iPosition; sl@0: sl@0: TFourCC iSinkFourCC ; sl@0: TFourCC iSourceFourCC ; sl@0: sl@0: sl@0: RPointerArray iRequests; sl@0: sl@0: MAsyncEventHandler *iEventHandler; sl@0: CMMFFileAsyncEventHandler* iMmfFileEventHandler; sl@0: sl@0: RPointerArray iTransferBufferCopies; sl@0: friend class CMMFFileAsyncEventHandler; sl@0: }; sl@0: sl@0: #endif