|
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: Definition of the ClientProgDLSource class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_CCLIENTAUDIOPROGDLSOURCE_H |
|
20 #define C_CCLIENTAUDIOPROGDLSOURCE_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <ProgDLSource.h> |
|
24 #include <downloadmgrclient.h> |
|
25 #include <mmfcontrollerframework.h> |
|
26 #include <MultimediaDataSource.h> |
|
27 |
|
28 #include "SourceBase.h" |
|
29 #include "TransferRateMonitor.h" |
|
30 #include "ProgDLSourceCustomCommands.h" |
|
31 #include "EventAO.h" |
|
32 #include "DownloadGateway.h" |
|
33 |
|
34 |
|
35 class MCustomCommand; |
|
36 |
|
37 namespace multimedia |
|
38 { |
|
39 |
|
40 class CEventNotifier; |
|
41 |
|
42 class MTransferRateMonitor; |
|
43 |
|
44 /** |
|
45 * Implements the ClientSide Source for the ProgDL Source. |
|
46 * Provides functionality to the Clients to query attributes |
|
47 * from the ServerSide source |
|
48 * @lib EnhancedMediaClient.lib |
|
49 * @since S60 v3.2 |
|
50 */ |
|
51 class CClientProgDLSource : public CSourceBase, |
|
52 public MProgDLSource, |
|
53 public MDownloadGatewayObserver, |
|
54 public MTransferRateObserver, |
|
55 public MSourceStateObserver |
|
56 { |
|
57 public: |
|
58 /** |
|
59 * Function to Create the Object. |
|
60 */ |
|
61 CClientProgDLSource(); |
|
62 /** |
|
63 * Destructor. |
|
64 */ |
|
65 ~CClientProgDLSource(); |
|
66 /** |
|
67 * Post Contructor. This is to Support the new type of Construction |
|
68 * of the Object. Notice there is no Two phased Constructor in this class |
|
69 */ |
|
70 TInt PostConstructor(); |
|
71 |
|
72 /** |
|
73 * Associates the DownloadGateway with the Progressive Download Source. |
|
74 * This Gateway class sends all the Browser Events to the Source. |
|
75 */ |
|
76 TInt SetDownloadGateway(CDownloadGateway* aDownloadGateway); |
|
77 |
|
78 // From MControl begins |
|
79 /** |
|
80 * From MControl. |
|
81 * Adds the Observer to this Object |
|
82 * @since S60 v3.2 |
|
83 * @param aObserver Client which set the Observer. |
|
84 */ |
|
85 TInt AddObserver( MControlObserver& aObserver ); |
|
86 /** |
|
87 * From MControl. |
|
88 * Removes the Observer to this Object |
|
89 * @since S60 v3.2 |
|
90 * @param aObserver Client which set the Observer. |
|
91 */ |
|
92 TInt RemoveObserver( MControlObserver& aObserver ); |
|
93 /** |
|
94 * From MControl. |
|
95 * Returns the Type of this Object. |
|
96 * request and that it is now outstanding |
|
97 * @since S60 v3.2 |
|
98 */ |
|
99 TUid Type(); |
|
100 /** |
|
101 * From MControl. |
|
102 * Returns the Control Type of this Object. |
|
103 * |
|
104 * @since S60 v3.2 |
|
105 */ |
|
106 TControlType ControlType(); |
|
107 // From MControl ends |
|
108 |
|
109 // From MSourceControl begins |
|
110 /** |
|
111 * From MSourceControl. |
|
112 * Returns the Size in Bytes of the Source. |
|
113 * Since this is ProgDL Source, the size represents |
|
114 * the file size which will be passed by the Client |
|
115 * to the Source |
|
116 * @since S60 v3.2 |
|
117 * @param aSize Size returned by the Source. |
|
118 */ |
|
119 TInt GetSize( TUint& aSize ); |
|
120 /** |
|
121 * From MSourceControl. |
|
122 * Returns the Mime Type of the Data for which |
|
123 * the Source is initialized. |
|
124 * @since S60 v3.2 |
|
125 * @param aMimeType MimeType returned by the Source. |
|
126 */ |
|
127 TInt GetMimeType( TDes8& aMimeType ); |
|
128 /** |
|
129 * From MSourceControl. |
|
130 * Closes the Source. |
|
131 * |
|
132 * @since S60 v3.2 |
|
133 */ |
|
134 TInt Close(); |
|
135 // From MSourceControl ends |
|
136 |
|
137 // From MProgDLSource begins |
|
138 /** |
|
139 * From MProgDLSource. |
|
140 * Opens the Source with the FileName and TransactionID |
|
141 * Here it connects to the Browser and attaches to the |
|
142 * download corresponding to the TransactionID |
|
143 * |
|
144 * @since S60 v3.2 |
|
145 * @param aFileName FileName to be Opened by the Source |
|
146 * @param aDLTxId TransactionID to connect to the Browser |
|
147 */ |
|
148 TInt Open( const TDesC& aFileName,TInt32 aDLTxId ); |
|
149 /** |
|
150 * From MProgDLSource. |
|
151 * Moves the Finished Download to the new Location. This is done |
|
152 * by calling the browser which is invoked through the Gateway. |
|
153 * |
|
154 * @since S60 v3.2 |
|
155 * @param aFileName FileName to be Opened by the Source |
|
156 */ |
|
157 TInt MoveFile(const TDesC& aDestFileName ); |
|
158 /** |
|
159 * From MProgDLSource. |
|
160 * Cancels the Ongoing Download |
|
161 * |
|
162 * @since S60 v3.2 |
|
163 */ |
|
164 TInt CancelDownload(); |
|
165 /** |
|
166 * From MProgDLSource. |
|
167 * Resumes the Paused download |
|
168 * |
|
169 * @since S60 v3.2 |
|
170 */ |
|
171 TInt ResumeDownload(); |
|
172 /** |
|
173 * From MProgDLSource. |
|
174 * Gets the Current FileSize from the Browser which is getting |
|
175 * Downloaded |
|
176 * |
|
177 * @since S60 v3.2 |
|
178 * @param aSize Size of the File already downloaded |
|
179 */ |
|
180 TInt GetCurrentFileSize( TUint& aSize ); |
|
181 /** |
|
182 * From MProgDLSource. |
|
183 * Gets the Expected FileSize from the Browser which is getting |
|
184 * Downloaded |
|
185 * |
|
186 * @since S60 v3.2 |
|
187 * @param aSize Final Size of the File |
|
188 */ |
|
189 TInt GetExpectedFileSize( TUint& aSize ); |
|
190 /** |
|
191 * From MProgDLSource. |
|
192 * Return the Current Download Status of the Download |
|
193 * |
|
194 * @since S60 v3.2 |
|
195 */ |
|
196 TDownloadStatus GetDownloadStatus(); |
|
197 /** |
|
198 * From MProgDLSource. |
|
199 * Queries if the Download is Complete from the Gateway |
|
200 * |
|
201 * @since S60 v3.2 |
|
202 * @param aBool Download Complete Status |
|
203 */ |
|
204 TInt IsDownloadComplete(TBool& aBool); |
|
205 /** |
|
206 * From MProgDLSource. |
|
207 * Gets the Percentage of the File already Downloaded |
|
208 * |
|
209 * @since S60 v3.2 |
|
210 * @param aPercent Percentage of the File downloaded |
|
211 */ |
|
212 TInt GetPercentageDownloaded(TUint& aPercent); |
|
213 /** |
|
214 * From MProgDLSource. |
|
215 * Gets the Percentage of the File Buffered before Playback starts. |
|
216 * This query is to the ServerSide Source which is in Buffering State |
|
217 * |
|
218 * @since S60 v3.2 |
|
219 * @param aPercent Percentage of Data Buffered before Playback starts. |
|
220 */ |
|
221 TInt GetPercentageBuffered(TUint& aPercent); |
|
222 /** |
|
223 * From MProgDLSource. |
|
224 * This is the DownloadRate that tells you how fast data is downloaded |
|
225 * by the Download Manager |
|
226 * |
|
227 * @since S60 v3.2 |
|
228 * @param aRate Rate at which Data is Downloaded. |
|
229 */ |
|
230 TInt GetDownloadingRate(TUint& aRate); |
|
231 /** |
|
232 * From MProgDLSource. |
|
233 * Returns the BitRate of the Data played from the Source |
|
234 * |
|
235 * @since S60 v3.2 |
|
236 * @param aRate BitRate of the Data Played from the Source |
|
237 */ |
|
238 TInt GetBitRate(TUint& aRate); |
|
239 /** |
|
240 * From MProgDLSource. |
|
241 * Returns the FileName associated with the Download. |
|
242 * This value is set by the Client when it calls Open(). |
|
243 * |
|
244 * @since S60 v3.2 |
|
245 * @param aFileName FileName to be Opened by the Source |
|
246 */ |
|
247 TInt FileName(TPtr& aFileName); |
|
248 // From MProgDLSource ends |
|
249 |
|
250 // From MDownloadGatewayObserver |
|
251 /** |
|
252 * From MDownloadGatewayObserver. |
|
253 * The Gateway Observer sends event which it receives from the |
|
254 * Download Manager. |
|
255 * |
|
256 * @since S60 v3.2 |
|
257 * @param aStatus Current Download Status |
|
258 */ |
|
259 void Event(TDownloadStatus aStatus); |
|
260 /** |
|
261 * From MDownloadGatewayObserver. |
|
262 * Notifies the Client that the Move of the File Complete |
|
263 * with an ErrorCode returned. |
|
264 * |
|
265 * @since S60 v3.2 |
|
266 * @param aError Move Complete with this ErrorCode. |
|
267 */ |
|
268 void MoveFileComplete(TInt aError); |
|
269 // MDownloadGatewayObserver Ends |
|
270 |
|
271 |
|
272 // From CSourceBase begins |
|
273 /** |
|
274 * From CSourceBase. |
|
275 * Callback from the StreamControl when the Source is Created |
|
276 * |
|
277 * @since S60 v3.2 |
|
278 * @param aCustomCommand Custom Command handle to send message to the Source |
|
279 * @param aSourceHandle Handle Identifying the Source |
|
280 */ |
|
281 void ServerSourceCreated( MCustomCommand& aCustomCommand, |
|
282 TMMFMessageDestination& aSourceHandle ); |
|
283 /** |
|
284 * From CSourceBase. |
|
285 * Callback from the StreamControl when the ServerSource is Deleted |
|
286 * |
|
287 * @since S60 v3.2 |
|
288 */ |
|
289 void ServerSourceDeleted(); |
|
290 /** |
|
291 * From CSourceBase. |
|
292 * Returns the Content Protection information to the Stream Control |
|
293 * Currently returns KErrNotSupported |
|
294 * @since S60 v3.2 |
|
295 */ |
|
296 TBool IsEncrypted(); |
|
297 /** |
|
298 * From CSourceBase. |
|
299 * Returns the SourceUID |
|
300 * |
|
301 * @since S60 v3.2 |
|
302 */ |
|
303 TUid GetSourceUid(); |
|
304 /** |
|
305 * From CSourceBase. |
|
306 * Returns the Header Data passed when the Client calls Open |
|
307 * Currently return KErrNotSupported |
|
308 * @since S60 v3.2 |
|
309 */ |
|
310 TInt GetHeaderData(TPtr& aPtr); |
|
311 // From CSourceBase ends |
|
312 |
|
313 //MTransferRateObserver begins |
|
314 /** |
|
315 * From MTransferRateObserver. |
|
316 * Callback from the TransferRate Monitor that the Rate Changed |
|
317 * @since S60 v3.2 |
|
318 */ |
|
319 void TransferRateChanged(); |
|
320 /** |
|
321 * From MTransferRateObserver |
|
322 * Method from the Transfer Rate Monitor to query CurrentFile Size. |
|
323 * @since S60 v3.2 |
|
324 * @param aCurrentSize Current File Size returned to the Caller |
|
325 */ |
|
326 TInt GetCurrentSize( TUint& aCurrentSize ); |
|
327 // MTransferRateObserver ends |
|
328 |
|
329 // MSourceStateObserver begins |
|
330 /** |
|
331 * From MSourceStateObserver. |
|
332 * Callback from the Active Object that the Source State changed. |
|
333 * @since S60 v3.2 |
|
334 */ |
|
335 void SourceStateChanged(); |
|
336 // MSourceStateObserver ends |
|
337 |
|
338 private: |
|
339 // Variable to determine if the ServerSource exists |
|
340 TBool iServerSourceExists; |
|
341 |
|
342 // FileSize from the Client |
|
343 TUint iSourceSize; |
|
344 // Current Size from the Browser |
|
345 TInt iCurrentSize; |
|
346 // Destination File Name |
|
347 TFileName iDestFileName; |
|
348 |
|
349 // Handle to send messages to the Server Side Source |
|
350 MCustomCommand* iCustomCommand; |
|
351 // Handle Identifying the Server Side Source |
|
352 TMMFMessageDestination iSourceHandle; |
|
353 |
|
354 // Current State of the Source |
|
355 TPckgBuf<CMultimediaDataSource::TState> iStatePckg; |
|
356 // Observer monitoring the State change event |
|
357 CEventAO* iStateEvent; |
|
358 // Current State of the Source |
|
359 CMultimediaDataSource::TState iSourceState; |
|
360 // Event Notifier to notify Clients |
|
361 CEventNotifier* iEventNotifier; |
|
362 // Storing the Download Complete Status |
|
363 TBool isDownloadComplete; |
|
364 // Storing the Download Paused status |
|
365 TBool isDownloadPaused; |
|
366 // Storing the DownloadID/Transaction ID |
|
367 TInt32 iDownloadId; |
|
368 // FileName passed to Open the Source |
|
369 HBufC* iFileName; |
|
370 // Gateway Attached to this Source to talk to Browser |
|
371 CDownloadGateway* iDownloadGateway; |
|
372 // Transfer Rate monitor |
|
373 CTransferRateMonitor* iMonitor; |
|
374 // Current Size of the File in Bytes. |
|
375 TUint iCurrentBytes; |
|
376 // Is the Playback in Progressive Mode |
|
377 TBool iProgressiveMode; |
|
378 }; |
|
379 } // namespace multimedia |
|
380 |
|
381 #endif // CLIENTAUDIOPROGDLSOURCE_H |
|
382 |
|
383 // End of file |