epoc32/include/mmf/server/mmffile.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 // Copyright (c) 2001-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 __MMFFILE_H_
    17 #define __MMFFILE_H_
    18 
    19 #include <f32file.h>
    20 
    21 #include <mmf/server/mmfclip.h>
    22 #include <mmf/server/mmfdatabuffer.h>
    23 #include "mmf/common/mmcaf.h"
    24 
    25 class CReadWriteRequest;
    26 class CTransferBufferCopy;
    27 class MGenericFile;
    28 
    29 /**
    30 @publishedAll
    31 @released
    32 
    33 Provides the filename and path of file. 
    34 
    35 Used by CMMFFile::ConstructL().
    36 */
    37 class TMMFFileParams
    38 	{
    39 public:
    40 	/**
    41 	Filename and path of file. 
    42 	*/
    43 	TFileName iPath ; // Filename and path of file.
    44 private:
    45 	/**
    46 	This member is internal and not intended for use.
    47 	*/
    48 	TInt iReserved1;
    49 	};
    50 	
    51 /**
    52 @publishedAll	
    53 */
    54 const TUid KFileHandleUid = {0x101FFA19};
    55 const TUid KMMFileSourceUid = {0x101F7DA9};
    56 const TUid KMMFileHandleSourceUid = {0x101F7DAA};
    57 	
    58 /**
    59 @publishedAll
    60 @released
    61 
    62 Provides a pointer to the file handle 
    63 
    64 Used by CMMFFile::ConstructL().
    65 */
    66 class TMMFFileHandleParams
    67 	{
    68 public:
    69 	TMMFFileHandleParams(RFile* aFile) : iUid(KFileHandleUid), iFile(aFile) {}
    70 	TMMFFileHandleParams() : iUid(KFileHandleUid) {}
    71 		
    72 	TUid iUid;
    73 	/**
    74 	Handle of file 
    75 	*/
    76 	RFile* iFile;
    77 private:
    78 	/**
    79 	This member is internal and not intended for use.
    80 	*/
    81 	TInt iReserved1;
    82 	};
    83 	
    84 	
    85 	
    86 
    87 /**
    88 @publishedAll
    89 @released
    90 */
    91 typedef TPckgBuf<TMMFFileParams>  TMMFFileConfig ;
    92 
    93 /**
    94 @publishedAll
    95 @released
    96 */
    97 typedef TPckgBuf<TMMFFileHandleParams>  TMMFFileHandleConfig ;
    98 
    99 
   100 /**
   101 @publishedAll
   102 @released
   103 
   104 This details how big the iTransferBufferCopies array of CMMFFile may
   105 become before we start looking to free entries.
   106 */
   107 const TInt KAcceptableTransferBufferCopiesSize = 5;
   108 
   109 /**
   110 @publishedAll
   111 @released
   112 
   113 This details how big the iTransferBufferCopies array of CMMFFile may
   114 become before we start looking to free entries.
   115 */
   116 const TInt KMaximumTransferBufferCopiesSize = 100;
   117 
   118 
   119 /**
   120 @publishedAll
   121 @released
   122 
   123 MultiMedia framework class.  Represents a physical file.
   124 
   125 This may be source file from which data is read or destination to which data is written.
   126 
   127 Intended to be used by controller plugin developers for source and sink plugins.
   128 */
   129 class CMMFFile : public CMMFClip
   130 	{
   131 public:
   132 	// From MDataSource
   133 	virtual TFourCC SourceDataTypeCode(TMediaId aMediaId) ;
   134 	virtual void FillBufferL( CMMFBuffer* aBuffer, MDataSink* aConsumer, TMediaId aMediaId ) ;
   135 	virtual void BufferEmptiedL( CMMFBuffer* aBuffer ) ;
   136 	virtual TBool CanCreateSourceBuffer() ;
   137 	virtual CMMFBuffer* CreateSourceBufferL( TMediaId aMediaId, TBool &aReference ) ;
   138 	virtual TInt SourceThreadLogon(MAsyncEventHandler& aEventHandler) ;
   139 	virtual void SourceThreadLogoff();
   140 	virtual void SourcePrimeL();
   141 	virtual void SourceStopL();
   142 
   143 	// From MDataSink
   144 	virtual TFourCC SinkDataTypeCode(TMediaId aMediaId) ; //used by data path MDataSource/Sink for codec matching
   145 	virtual void EmptyBufferL( CMMFBuffer* aBuffer, MDataSource* aSupplier, TMediaId aMediaId ) ;
   146 	virtual void BufferFilledL( CMMFBuffer* aBuffer ) ;
   147 	virtual TBool CanCreateSinkBuffer() ;
   148 	virtual CMMFBuffer* CreateSinkBufferL( TMediaId aMediaId , TBool &aReference) ;
   149 	virtual TInt SinkThreadLogon(MAsyncEventHandler& aEventHandler) ;
   150 	virtual void SinkThreadLogoff();
   151 	virtual void SinkPrimeL();
   152 	virtual void SinkStopL();
   153 
   154 	// From CMMFClip
   155 	virtual void ReadBufferL( TInt aLength, CMMFBuffer* aBuffer, TInt aPosition, MDataSink* aConsumer);
   156 	virtual void WriteBufferL( TInt aLength, CMMFBuffer* aBuffer, TInt aPosition, MDataSource* aSupplier);
   157 	virtual void ReadBufferL( CMMFBuffer* aBuffer, TInt aPosition, MDataSink* aConsumer) ;
   158 	virtual void WriteBufferL( CMMFBuffer* aBuffer, TInt aPosition, MDataSource* aSupplier) ;
   159 	virtual void ReadBufferL( CMMFBuffer* aBuffer, TInt aPosition ) ;
   160 	virtual void WriteBufferL( CMMFBuffer* aBuffer, TInt aPosition ) ;
   161 	virtual TInt64 BytesFree() ;  // amount of space available for the clip
   162 	virtual TInt Size() ;
   163 	virtual TInt Delete();
   164 	virtual TInt SetSize(TInt aSize);
   165 
   166 	// New Functions
   167 	virtual const TDesC& FileName() const ;
   168 	virtual const TDesC& Extension() const ;
   169 	virtual const TDesC& FilePath() const ;
   170 	virtual const TDesC& FileDrive() const ;
   171 	virtual const TFileName FullName() const;
   172 	virtual RFile& FileL() ;
   173 
   174 public :
   175 	virtual ~CMMFFile() ;
   176 	static MDataSource* NewSourceL() ;
   177 	static MDataSink* NewSinkL() ;
   178 
   179 	void SetTransferBuffer (TBool aTBuffer) ;
   180 	TBool CanUseTransferBuffer () ;
   181 	virtual TBool SinkStopped();
   182 
   183 protected:
   184 	/**
   185 	Indicates for which purpose the object instance is being created
   186 	*/
   187 	enum TMMFileMode
   188 		{
   189 		/** The object is created for being a source */
   190 		ESourceMode,
   191 		/** The object is created for being a sink */
   192 		ESinkMode
   193 		};
   194 	virtual void ConstructSourceL( const TDesC8& aInitData ) ;
   195 	virtual void ConstructSinkL( const TDesC8& aInitData ) ;
   196 	void ConstructL(const TDesC8& aInitData, TMMFileMode aFileMode) ;
   197 	CMMFFile() ;
   198 
   199 	void StoreRequestL( CReadWriteRequest* aRequest ) ;
   200 	void CancelRequests();
   201 
   202 
   203 	CTransferBufferCopy* ObtainCopyOfTransferBufferL(TInt aMaxLength);
   204 
   205 public:
   206 	// Additional virtuals for DRM Intent
   207 	virtual TInt ExecuteIntent(ContentAccess::TIntent aIntent);
   208 	virtual TInt EvaluateIntent(ContentAccess::TIntent aIntent) const;
   209 	virtual TBool IsProtectedL() const;
   210 
   211 	virtual TInt SetAgentProperty(ContentAccess::TAgentProperty aProperty, TInt aValue); 
   212 	virtual const TDesC& UniqueId() const;
   213 
   214 private:
   215 	class CMMFFileAsyncEventHandler : public MAsyncEventHandler
   216 		{
   217 		public:
   218 			CMMFFileAsyncEventHandler(CMMFFile* aParent);
   219 			virtual ~CMMFFileAsyncEventHandler();
   220 		public:
   221 			virtual TInt SendEventToClient(const TMMFEvent& aEvent);
   222 		private:
   223 			CMMFFile* iParent;
   224 		};
   225 		
   226 	class CCAFParameters : public CBase
   227 		{
   228 	public:
   229 		CCAFParameters() : iUniqueId(NULL), iEnableUI(EFalse) {}
   230 		~CCAFParameters() {	delete iUniqueId;	}
   231 	public:
   232 		HBufC* iUniqueId;
   233 		TBool iEnableUI;
   234 		};
   235 
   236 public:
   237 	virtual TInt Data(ContentAccess::CData*& aData);
   238 	virtual void SourcePauseL();
   239 	
   240 private:
   241 	MGenericFile* iFile;
   242 	RFs iFsSession;
   243 	
   244 	TBool iFileHandle;
   245 	RFile iHandle;
   246 	TBool iReserved;
   247 
   248 	TBool iSinkNotStopped;
   249 
   250 	TFileName iFullFileName ;
   251 	HBufC* iFileName ;
   252 	HBufC* iFileExt ;
   253 	HBufC* iFilePath ;
   254 	HBufC* iFileDrive ;
   255 	CCAFParameters* iCAFParameters;
   256 	TInt iFileSize; //holds the cached file size
   257 
   258 	//Keeps track of the read position within the file. Needed in order to enable passing of the
   259 	//read position to the CReadRequest to manage the LastBuffer flag.
   260 	//NB: Continuous reads once EOF has been reached will result in iPosition going > iFileSize,
   261 	//but this causes no ill effects
   262 	TUint iPosition;
   263 
   264 	TFourCC  iSinkFourCC ;
   265 	TFourCC  iSourceFourCC ;
   266 
   267 
   268 	RPointerArray<CReadWriteRequest> iRequests;
   269 
   270 	MAsyncEventHandler *iEventHandler;
   271 	CMMFFileAsyncEventHandler* iMmfFileEventHandler;
   272 
   273 	RPointerArray<CTransferBufferCopy> iTransferBufferCopies;
   274 	friend class CMMFFileAsyncEventHandler;
   275 	};
   276 
   277 #endif