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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
21 #include <mmf/server/mmfclip.h>
22 #include <mmf/server/mmfdatabuffer.h>
23 #include "mmf/common/mmcaf.h"
25 class CReadWriteRequest;
26 class CTransferBufferCopy;
33 Provides the filename and path of file.
35 Used by CMMFFile::ConstructL().
41 Filename and path of file.
43 TFileName iPath ; // Filename and path of file.
46 This member is internal and not intended for use.
54 const TUid KFileHandleUid = {0x101FFA19};
55 const TUid KMMFileSourceUid = {0x101F7DA9};
56 const TUid KMMFileHandleSourceUid = {0x101F7DAA};
62 Provides a pointer to the file handle
64 Used by CMMFFile::ConstructL().
66 class TMMFFileHandleParams
69 TMMFFileHandleParams(RFile* aFile) : iUid(KFileHandleUid), iFile(aFile) {}
70 TMMFFileHandleParams() : iUid(KFileHandleUid) {}
79 This member is internal and not intended for use.
91 typedef TPckgBuf<TMMFFileParams> TMMFFileConfig ;
97 typedef TPckgBuf<TMMFFileHandleParams> TMMFFileHandleConfig ;
104 This details how big the iTransferBufferCopies array of CMMFFile may
105 become before we start looking to free entries.
107 const TInt KAcceptableTransferBufferCopiesSize = 5;
113 This details how big the iTransferBufferCopies array of CMMFFile may
114 become before we start looking to free entries.
116 const TInt KMaximumTransferBufferCopiesSize = 100;
123 MultiMedia framework class. Represents a physical file.
125 This may be source file from which data is read or destination to which data is written.
127 Intended to be used by controller plugin developers for source and sink plugins.
129 class CMMFFile : public CMMFClip
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();
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();
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);
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() ;
175 virtual ~CMMFFile() ;
176 static MDataSource* NewSourceL() ;
177 static MDataSink* NewSinkL() ;
179 void SetTransferBuffer (TBool aTBuffer) ;
180 TBool CanUseTransferBuffer () ;
181 virtual TBool SinkStopped();
185 Indicates for which purpose the object instance is being created
189 /** The object is created for being a source */
191 /** The object is created for being a sink */
194 virtual void ConstructSourceL( const TDesC8& aInitData ) ;
195 virtual void ConstructSinkL( const TDesC8& aInitData ) ;
196 void ConstructL(const TDesC8& aInitData, TMMFileMode aFileMode) ;
199 void StoreRequestL( CReadWriteRequest* aRequest ) ;
200 void CancelRequests();
203 CTransferBufferCopy* ObtainCopyOfTransferBufferL(TInt aMaxLength);
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;
211 virtual TInt SetAgentProperty(ContentAccess::TAgentProperty aProperty, TInt aValue);
212 virtual const TDesC& UniqueId() const;
215 class CMMFFileAsyncEventHandler : public MAsyncEventHandler
218 CMMFFileAsyncEventHandler(CMMFFile* aParent);
219 virtual ~CMMFFileAsyncEventHandler();
221 virtual TInt SendEventToClient(const TMMFEvent& aEvent);
226 class CCAFParameters : public CBase
229 CCAFParameters() : iUniqueId(NULL), iEnableUI(EFalse) {}
230 ~CCAFParameters() { delete iUniqueId; }
237 virtual TInt Data(ContentAccess::CData*& aData);
238 virtual void SourcePauseL();
248 TBool iSinkNotStopped;
250 TFileName iFullFileName ;
255 CCAFParameters* iCAFParameters;
256 TInt iFileSize; //holds the cached file size
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
264 TFourCC iSinkFourCC ;
265 TFourCC iSourceFourCC ;
268 RPointerArray<CReadWriteRequest> iRequests;
270 MAsyncEventHandler *iEventHandler;
271 CMMFFileAsyncEventHandler* iMmfFileEventHandler;
273 RPointerArray<CTransferBufferCopy> iTransferBufferCopies;
274 friend class CMMFFileAsyncEventHandler;