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