1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/inc/mmf/server/MmfFile.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,277 @@
1.4 +// Copyright (c) 2001-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 __MMFFILE_H_
1.20 +#define __MMFFILE_H_
1.21 +
1.22 +#include <f32file.h>
1.23 +
1.24 +#include <mmf/server/mmfclip.h>
1.25 +#include <mmf/server/mmfdatabuffer.h>
1.26 +#include <mmf/common/mmcaf.h>
1.27 +
1.28 +class CReadWriteRequest;
1.29 +class CTransferBufferCopy;
1.30 +class MGenericFile;
1.31 +
1.32 +/**
1.33 +@publishedAll
1.34 +@released
1.35 +
1.36 +Provides the filename and path of file.
1.37 +
1.38 +Used by CMMFFile::ConstructL().
1.39 +*/
1.40 +class TMMFFileParams
1.41 + {
1.42 +public:
1.43 + /**
1.44 + Filename and path of file.
1.45 + */
1.46 + TFileName iPath ; // Filename and path of file.
1.47 +private:
1.48 + /**
1.49 + This member is internal and not intended for use.
1.50 + */
1.51 + TInt iReserved1;
1.52 + };
1.53 +
1.54 +/**
1.55 +@publishedAll
1.56 +*/
1.57 +const TUid KFileHandleUid = {0x101FFA19};
1.58 +const TUid KMMFileSourceUid = {0x101F7DA9};
1.59 +const TUid KMMFileHandleSourceUid = {0x101F7DAA};
1.60 +
1.61 +/**
1.62 +@publishedAll
1.63 +@released
1.64 +
1.65 +Provides a pointer to the file handle
1.66 +
1.67 +Used by CMMFFile::ConstructL().
1.68 +*/
1.69 +class TMMFFileHandleParams
1.70 + {
1.71 +public:
1.72 + TMMFFileHandleParams(RFile* aFile) : iUid(KFileHandleUid), iFile(aFile) {}
1.73 + TMMFFileHandleParams() : iUid(KFileHandleUid) {}
1.74 +
1.75 + TUid iUid;
1.76 + /**
1.77 + Handle of file
1.78 + */
1.79 + RFile* iFile;
1.80 +private:
1.81 + /**
1.82 + This member is internal and not intended for use.
1.83 + */
1.84 + TInt iReserved1;
1.85 + };
1.86 +
1.87 +
1.88 +
1.89 +
1.90 +/**
1.91 +@publishedAll
1.92 +@released
1.93 +*/
1.94 +typedef TPckgBuf<TMMFFileParams> TMMFFileConfig ;
1.95 +
1.96 +/**
1.97 +@publishedAll
1.98 +@released
1.99 +*/
1.100 +typedef TPckgBuf<TMMFFileHandleParams> TMMFFileHandleConfig ;
1.101 +
1.102 +
1.103 +/**
1.104 +@publishedAll
1.105 +@released
1.106 +
1.107 +This details how big the iTransferBufferCopies array of CMMFFile may
1.108 +become before we start looking to free entries.
1.109 +*/
1.110 +const TInt KAcceptableTransferBufferCopiesSize = 5;
1.111 +
1.112 +/**
1.113 +@publishedAll
1.114 +@released
1.115 +
1.116 +This details how big the iTransferBufferCopies array of CMMFFile may
1.117 +become before we start looking to free entries.
1.118 +*/
1.119 +const TInt KMaximumTransferBufferCopiesSize = 100;
1.120 +
1.121 +
1.122 +/**
1.123 +@publishedAll
1.124 +@released
1.125 +
1.126 +MultiMedia framework class. Represents a physical file.
1.127 +
1.128 +This may be source file from which data is read or destination to which data is written.
1.129 +
1.130 +Intended to be used by controller plugin developers for source and sink plugins.
1.131 +*/
1.132 +class CMMFFile : public CMMFClip
1.133 + {
1.134 +public:
1.135 + // From MDataSource
1.136 + virtual TFourCC SourceDataTypeCode(TMediaId aMediaId) ;
1.137 + virtual void FillBufferL( CMMFBuffer* aBuffer, MDataSink* aConsumer, TMediaId aMediaId ) ;
1.138 + virtual void BufferEmptiedL( CMMFBuffer* aBuffer ) ;
1.139 + virtual TBool CanCreateSourceBuffer() ;
1.140 + virtual CMMFBuffer* CreateSourceBufferL( TMediaId aMediaId, TBool &aReference ) ;
1.141 + virtual TInt SourceThreadLogon(MAsyncEventHandler& aEventHandler) ;
1.142 + virtual void SourceThreadLogoff();
1.143 + virtual void SourcePrimeL();
1.144 + virtual void SourceStopL();
1.145 +
1.146 + // From MDataSink
1.147 + virtual TFourCC SinkDataTypeCode(TMediaId aMediaId) ; //used by data path MDataSource/Sink for codec matching
1.148 + virtual void EmptyBufferL( CMMFBuffer* aBuffer, MDataSource* aSupplier, TMediaId aMediaId ) ;
1.149 + virtual void BufferFilledL( CMMFBuffer* aBuffer ) ;
1.150 + virtual TBool CanCreateSinkBuffer() ;
1.151 + virtual CMMFBuffer* CreateSinkBufferL( TMediaId aMediaId , TBool &aReference) ;
1.152 + virtual TInt SinkThreadLogon(MAsyncEventHandler& aEventHandler) ;
1.153 + virtual void SinkThreadLogoff();
1.154 + virtual void SinkPrimeL();
1.155 + virtual void SinkStopL();
1.156 +
1.157 + // From CMMFClip
1.158 + virtual void ReadBufferL( TInt aLength, CMMFBuffer* aBuffer, TInt aPosition, MDataSink* aConsumer);
1.159 + virtual void WriteBufferL( TInt aLength, CMMFBuffer* aBuffer, TInt aPosition, MDataSource* aSupplier);
1.160 + virtual void ReadBufferL( CMMFBuffer* aBuffer, TInt aPosition, MDataSink* aConsumer) ;
1.161 + virtual void WriteBufferL( CMMFBuffer* aBuffer, TInt aPosition, MDataSource* aSupplier) ;
1.162 + virtual void ReadBufferL( CMMFBuffer* aBuffer, TInt aPosition ) ;
1.163 + virtual void WriteBufferL( CMMFBuffer* aBuffer, TInt aPosition ) ;
1.164 + virtual TInt64 BytesFree() ; // amount of space available for the clip
1.165 + virtual TInt Size() ;
1.166 + virtual TInt Delete();
1.167 + virtual TInt SetSize(TInt aSize);
1.168 +
1.169 + // New Functions
1.170 + virtual const TDesC& FileName() const ;
1.171 + virtual const TDesC& Extension() const ;
1.172 + virtual const TDesC& FilePath() const ;
1.173 + virtual const TDesC& FileDrive() const ;
1.174 + virtual const TFileName FullName() const;
1.175 + virtual RFile& FileL() ;
1.176 +
1.177 +public :
1.178 + virtual ~CMMFFile() ;
1.179 + static MDataSource* NewSourceL() ;
1.180 + static MDataSink* NewSinkL() ;
1.181 +
1.182 + void SetTransferBuffer (TBool aTBuffer) ;
1.183 + TBool CanUseTransferBuffer () ;
1.184 + virtual TBool SinkStopped();
1.185 +
1.186 +protected:
1.187 + /**
1.188 + Indicates for which purpose the object instance is being created
1.189 + */
1.190 + enum TMMFileMode
1.191 + {
1.192 + /** The object is created for being a source */
1.193 + ESourceMode,
1.194 + /** The object is created for being a sink */
1.195 + ESinkMode
1.196 + };
1.197 + virtual void ConstructSourceL( const TDesC8& aInitData ) ;
1.198 + virtual void ConstructSinkL( const TDesC8& aInitData ) ;
1.199 + void ConstructL(const TDesC8& aInitData, TMMFileMode aFileMode) ;
1.200 + CMMFFile() ;
1.201 +
1.202 + void StoreRequestL( CReadWriteRequest* aRequest ) ;
1.203 + void CancelRequests();
1.204 +
1.205 +
1.206 + CTransferBufferCopy* ObtainCopyOfTransferBufferL(TInt aMaxLength);
1.207 +
1.208 +public:
1.209 + // Additional virtuals for DRM Intent
1.210 + virtual TInt ExecuteIntent(ContentAccess::TIntent aIntent);
1.211 + virtual TInt EvaluateIntent(ContentAccess::TIntent aIntent) const;
1.212 + virtual TBool IsProtectedL() const;
1.213 +
1.214 + virtual TInt SetAgentProperty(ContentAccess::TAgentProperty aProperty, TInt aValue);
1.215 + virtual const TDesC& UniqueId() const;
1.216 +
1.217 +private:
1.218 + class CMMFFileAsyncEventHandler : public MAsyncEventHandler
1.219 + {
1.220 + public:
1.221 + CMMFFileAsyncEventHandler(CMMFFile* aParent);
1.222 + virtual ~CMMFFileAsyncEventHandler();
1.223 + public:
1.224 + virtual TInt SendEventToClient(const TMMFEvent& aEvent);
1.225 + private:
1.226 + CMMFFile* iParent;
1.227 + };
1.228 +
1.229 + class CCAFParameters : public CBase
1.230 + {
1.231 + public:
1.232 + CCAFParameters() : iUniqueId(NULL), iEnableUI(EFalse) {}
1.233 + ~CCAFParameters() { delete iUniqueId; }
1.234 + public:
1.235 + HBufC* iUniqueId;
1.236 + TBool iEnableUI;
1.237 + };
1.238 +
1.239 +public:
1.240 + virtual TInt Data(ContentAccess::CData*& aData);
1.241 + virtual void SourcePauseL();
1.242 +
1.243 +private:
1.244 + MGenericFile* iFile;
1.245 + RFs iFsSession;
1.246 +
1.247 + TBool iFileHandle;
1.248 + RFile iHandle;
1.249 + TBool iReserved;
1.250 +
1.251 + TBool iSinkNotStopped;
1.252 +
1.253 + TFileName iFullFileName ;
1.254 + HBufC* iFileName ;
1.255 + HBufC* iFileExt ;
1.256 + HBufC* iFilePath ;
1.257 + HBufC* iFileDrive ;
1.258 + CCAFParameters* iCAFParameters;
1.259 + TInt iFileSize; //holds the cached file size
1.260 +
1.261 + //Keeps track of the read position within the file. Needed in order to enable passing of the
1.262 + //read position to the CReadRequest to manage the LastBuffer flag.
1.263 + //NB: Continuous reads once EOF has been reached will result in iPosition going > iFileSize,
1.264 + //but this causes no ill effects
1.265 + TUint iPosition;
1.266 +
1.267 + TFourCC iSinkFourCC ;
1.268 + TFourCC iSourceFourCC ;
1.269 +
1.270 +
1.271 + RPointerArray<CReadWriteRequest> iRequests;
1.272 +
1.273 + MAsyncEventHandler *iEventHandler;
1.274 + CMMFFileAsyncEventHandler* iMmfFileEventHandler;
1.275 +
1.276 + RPointerArray<CTransferBufferCopy> iTransferBufferCopies;
1.277 + friend class CMMFFileAsyncEventHandler;
1.278 + };
1.279 +
1.280 +#endif