|
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 FileSource. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef FILEMULTIMEDIASOURCE_H |
|
21 #define FILEMULTIMEDIASOURCE_H |
|
22 |
|
23 |
|
24 #include <MultimediaDataSource.h> |
|
25 #include <mmfcontrollerframework.h> |
|
26 #include "FileDataSourceCommon.h" |
|
27 |
|
28 class CReadWriteRequest; |
|
29 class CTransferBufferCopy; |
|
30 class MGenericFile; |
|
31 class CSinkQueueItem; |
|
32 class MDataSource; |
|
33 class TMMFMessage; |
|
34 class MDataSink; |
|
35 class MDataSource; |
|
36 class MAsyncEventHandler; |
|
37 |
|
38 |
|
39 class CFileMultimediaSource : public CMultimediaDataSource |
|
40 { |
|
41 public: |
|
42 // From MDataSource |
|
43 IMPORT_C static CFileMultimediaSource* NewL(MDataSource& aDataSource); |
|
44 |
|
45 // From CMultimediaDataSource begins |
|
46 TInt SetObserver( MMultimediaDataSourceObserver& aObserver ); |
|
47 TInt GetObserver( MMultimediaDataSourceObserver*& aObserver ); |
|
48 void Event( TUid aEvent ); |
|
49 TInt SetDataTypeCode(TFourCC aSourceFourCC ); |
|
50 TInt GetDataTypeCode(TFourCC& aSourceFourCC ); |
|
51 TInt GetSize( TUint& aSize ); |
|
52 TInt Open(); |
|
53 TInt Close(); |
|
54 TInt Prime(); |
|
55 TInt Play(); |
|
56 TInt Stop(); |
|
57 TInt FillBuffer( CMMFBuffer* aBuffer); |
|
58 |
|
59 |
|
60 TInt GetDRMProtection( TBool& aIsProtected ); |
|
61 TInt EvaluateIntent( ContentAccess::TIntent aIntent ); |
|
62 TInt ExecuteIntent( ContentAccess::TIntent aIntent ); |
|
63 TInt SetAgentProperty( ContentAccess::TAgentProperty aProperty, |
|
64 TInt aValue); |
|
65 const TDesC& UniqueId() const; |
|
66 // From MCustomInterface |
|
67 TAny* CustomInterface( TUid aInterfaceUid ); |
|
68 |
|
69 /* Seeking Interface */ |
|
70 // Returns true if byte position can be reset to zero. |
|
71 // Valid in all states |
|
72 TInt GetSeekingSupport( TBool& aSeekSupport ); |
|
73 // Returns true if byte position can be set anywhere between zero and |
|
74 // GetSize(). |
|
75 // Valid in all states |
|
76 TInt GetRandomSeekingSupport( TBool& aSeekSupport ); |
|
77 // Moves read position pointer to byte location requested by the observer |
|
78 // between zero and GetSize(). If the size specified is out of range, this |
|
79 // function returns KErrArgument. |
|
80 TInt Seek( TUint aPosInBytes ); |
|
81 |
|
82 // From CMultimediaDataSource ends |
|
83 void SourceCustomCommand(TMMFMessage& aMessage); |
|
84 // A common function that implements FillBuffer requests |
|
85 TInt AppendBufferToSinkQueue( CMMFBuffer* aBuffer, |
|
86 MMultimediaDataSourceObserver* aObserver, |
|
87 MDataSink* aConsumer,TBool aTop); |
|
88 TInt ServiceFillBuffer(); |
|
89 |
|
90 public : |
|
91 virtual ~CFileMultimediaSource() ; |
|
92 // static MDataSource* NewSourceL(/*TUid aType*/) ; |
|
93 |
|
94 void SetTransferBuffer(TBool aTBuffer) ; |
|
95 TBool CanUseTransferBuffer () ; |
|
96 TInt ReadRequestStatus(CReadWriteRequest* aRequest,TRequestStatus& aStatus); |
|
97 |
|
98 protected: |
|
99 /** |
|
100 Indicates for which purpose the object instance is being created |
|
101 */ |
|
102 enum TMMFileMode |
|
103 { |
|
104 /** The object is created for being a source */ |
|
105 ESourceMode, |
|
106 /** The object is created for being a sink */ |
|
107 ESinkMode |
|
108 }; |
|
109 |
|
110 void ConstructL(const TDesC8& aInitData, TMMFileMode aFileMode) ; |
|
111 CFileMultimediaSource(MDataSource& aDataSource) ; |
|
112 void ConstructL(); |
|
113 void StoreRequestL( CReadWriteRequest* aRequest ) ; |
|
114 void CancelRequests(); |
|
115 |
|
116 TInt EmptySinkQueue(); |
|
117 CTransferBufferCopy* ObtainCopyOfTransferBufferL(TInt aMaxLength); |
|
118 |
|
119 void StateChanged(TState newState); |
|
120 |
|
121 private: |
|
122 |
|
123 // New Functions |
|
124 const TDesC& FileName() const ; |
|
125 const TDesC& Extension() const ; |
|
126 const TDesC& FilePath() const ; |
|
127 const TDesC& FileDrive() const ; |
|
128 const TFileName FullName() const; |
|
129 RFile& FileL() ; |
|
130 |
|
131 private: |
|
132 class CFileMultimediaSourceAsyncEventHandler : public MAsyncEventHandler |
|
133 { |
|
134 public: |
|
135 CFileMultimediaSourceAsyncEventHandler(CFileMultimediaSource* aParent); |
|
136 virtual ~CFileMultimediaSourceAsyncEventHandler(); |
|
137 public: |
|
138 virtual TInt SendEventToClient(const TMMFEvent& aEvent); |
|
139 private: |
|
140 CFileMultimediaSource* iParent; |
|
141 }; |
|
142 |
|
143 class CCAFParameters : public CBase |
|
144 { |
|
145 public: |
|
146 CCAFParameters() : iUniqueId(NULL), iEnableUI(EFalse) {} |
|
147 ~CCAFParameters() { delete iUniqueId; } |
|
148 public: |
|
149 HBufC* iUniqueId; |
|
150 TBool iEnableUI; |
|
151 }; |
|
152 |
|
153 |
|
154 |
|
155 private: |
|
156 MGenericFile* iFile; |
|
157 RFs iFsSession; |
|
158 |
|
159 TBool iFileHandle; |
|
160 RFile iHandle; |
|
161 TBool iReserved; |
|
162 |
|
163 TFileName iFullFileName ; |
|
164 HBufC* iFileName ; |
|
165 HBufC* iFileExt ; |
|
166 HBufC* iFilePath ; |
|
167 HBufC* iFileDrive ; |
|
168 CCAFParameters* iCAFParameters; |
|
169 |
|
170 TFourCC iSinkFourCC ; |
|
171 TFourCC iSourceFourCC ; |
|
172 |
|
173 // Queue of buffers from controller |
|
174 TSglQue<CSinkQueueItem>* iSinkQueue; |
|
175 //MDataSink* iConsumer; |
|
176 // Sink item Counter |
|
177 TInt iSnkItemsCount; |
|
178 // Observer bit rate in bps |
|
179 //Keeps track of the read position within the file. Needed in order to enable passing of the |
|
180 //read position to the CReadRequest to manage the LastBuffer flag. |
|
181 //NB: Continuous reads once EOF has been reached will result in iPosition going > iDLFileSize, |
|
182 //but this causes no ill effects |
|
183 TUint iSnkBytes; |
|
184 |
|
185 TInt iDownloadSize; |
|
186 |
|
187 // Transfer bit rate in bps |
|
188 TUint iTransferRate; |
|
189 |
|
190 TUint iObserverBitRate; |
|
191 |
|
192 // Buffering size in bytes |
|
193 TUint iBufferedDataSize; |
|
194 |
|
195 TInt iDLFileSize; //holds the cached file size |
|
196 TMMFMessage* iMessage; |
|
197 |
|
198 MMultimediaDataSourceObserver* iObserver; |
|
199 RPointerArray<CReadWriteRequest> iRequests; |
|
200 |
|
201 MAsyncEventHandler *iEventHandler; |
|
202 |
|
203 RPointerArray<CTransferBufferCopy> iTransferBufferCopies; |
|
204 TBool isDownloadComplete; |
|
205 TInt iFileSize; |
|
206 |
|
207 // Pointer to the Preset Repository |
|
208 |
|
209 TUint iInitialBufferingPercentage; |
|
210 // Parent MDataSource |
|
211 MDataSource* iParentDataSource; |
|
212 HBufC8* iInitData; |
|
213 }; |
|
214 |
|
215 #endif //__FILEDATASOURCE_H_ |