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