|
1 // Copyright (c) 2002-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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Client utility functions |
|
15 // |
|
16 // |
|
17 |
|
18 #ifndef __MMF_CLIENT_UTILITY_H__ |
|
19 #define __MMF_CLIENT_UTILITY_H__ |
|
20 |
|
21 #include <mda/common/audio.h> |
|
22 #include <mda/common/gsmaudio.h> |
|
23 #include <mda/client/utility.h> |
|
24 #include <mmf/common/mmffourcc.h> |
|
25 #include <mmfformatimplementationuids.hrh> |
|
26 #include "mmf/common/mmfcontrollerpluginresolver.h" |
|
27 #include <mmf/server/mmffile.h> |
|
28 #include <mmf/server/mmfdes.h> |
|
29 #include "mmf/common/mmfcontroller.h" |
|
30 |
|
31 #include <f32file.h> |
|
32 #include <caf/content.h> |
|
33 #include <caf/data.h> |
|
34 #include <mmf/common/mmfstandardcustomcommands.h> |
|
35 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
36 #include <mmf/common/mmfstandardcustomcommandsenums.h> |
|
37 #include <mmf/common/mmfstandardcustomcommandsimpl.h> |
|
38 #endif |
|
39 #ifdef SYMBIAN_BUILD_GCE |
|
40 #include <mmf/common/mmfvideosurfacecustomcommands.h> |
|
41 #endif |
|
42 |
|
43 class CMMSourceSink; // declared here. |
|
44 |
|
45 NONSHARABLE_CLASS( CMMSourceSink ): public CBase |
|
46 { |
|
47 public: |
|
48 IMPORT_C static CMMSourceSink* NewL(TUid aUid, const TDesC8& aDescriptor); |
|
49 IMPORT_C static CMMSourceSink* NewLC(TUid aUid, const TDesC8& aDescriptor); |
|
50 |
|
51 virtual ~CMMSourceSink(); |
|
52 virtual TUid SourceSinkUid() const; |
|
53 virtual const TDesC8& SourceSinkData() const; |
|
54 |
|
55 virtual TBool CarryingFileHandle() const; |
|
56 |
|
57 virtual void EvaluateIntentL(); |
|
58 protected: |
|
59 CMMSourceSink(TUid aUid); |
|
60 |
|
61 |
|
62 private: |
|
63 void ConstructL(const TDesC8& aDescriptor); |
|
64 |
|
65 const TUid iUid; |
|
66 HBufC8* iBuf; |
|
67 }; |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 class CMMFileSourceSink; // declared here. |
|
73 |
|
74 NONSHARABLE_CLASS( CMMFileSourceSink ): public CMMSourceSink |
|
75 { |
|
76 public: |
|
77 IMPORT_C static CMMFileSourceSink* NewL(TUid aUid, const RFile& aFile); |
|
78 IMPORT_C static CMMFileSourceSink* NewLC(TUid aUid, const RFile& aFile); |
|
79 |
|
80 IMPORT_C static CMMFileSourceSink* NewL(TUid aUid, const TMMSource& aMMSource); |
|
81 IMPORT_C static CMMFileSourceSink* NewLC(TUid aUid, const TMMSource& aMMSource); |
|
82 |
|
83 const TDesC& UniqueId() const {return *iUniqueId;} |
|
84 |
|
85 virtual ~CMMFileSourceSink(); |
|
86 |
|
87 const TDesC& FileName() const {return *iFileName;} |
|
88 const TDesC8& SourceSinkData() const; |
|
89 |
|
90 IMPORT_C void EvaluateIntentL(ContentAccess::TIntent aIntent); |
|
91 virtual void EvaluateIntentL(); |
|
92 |
|
93 TBool CarryingFileHandle() const; |
|
94 |
|
95 TBool UsingFileHandle() const {return iUsingFileHandle;}; |
|
96 const RFile& FileHandle() const {return iHandle;}; |
|
97 protected: |
|
98 CMMFileSourceSink(TUid aUid); |
|
99 |
|
100 private: |
|
101 void ConstructL(const TMMSource& aSource); |
|
102 void DoCreateFileSourceConfigDataL(); |
|
103 void ConstructL(const RFile& aFile); |
|
104 void DoCreateFileHandleSourceConfigDataL(); |
|
105 |
|
106 TBool iUsingFileHandle; |
|
107 RFile iHandle; |
|
108 HBufC* iFileName; |
|
109 HBufC8* iSourceSinkData; |
|
110 HBufC* iUniqueId; |
|
111 ContentAccess::TIntent iIntent; |
|
112 |
|
113 TBool iEnableUI; |
|
114 }; |
|
115 |
|
116 |
|
117 |
|
118 class CMMFMdaObjectStateChangeObserverCallback; // declared here. |
|
119 /** |
|
120 Active object utility class to allow the callback to be called asynchronously. |
|
121 This should help prevent re-entrant code in clients of the mediaframework. |
|
122 */ |
|
123 NONSHARABLE_CLASS( CMMFMdaObjectStateChangeObserverCallback ): public CActive |
|
124 { |
|
125 public: |
|
126 IMPORT_C static CMMFMdaObjectStateChangeObserverCallback* NewL(MMdaObjectStateChangeObserver& aCallback); |
|
127 virtual ~CMMFMdaObjectStateChangeObserverCallback(); |
|
128 IMPORT_C void CallBack(CBase* aObject, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode); |
|
129 private: |
|
130 CMMFMdaObjectStateChangeObserverCallback(MMdaObjectStateChangeObserver& aCallback); |
|
131 void RunL(); |
|
132 void DoCancel(); |
|
133 private: |
|
134 MMdaObjectStateChangeObserver& iCallback; |
|
135 CBase* iObject; |
|
136 TInt iPreviousState; |
|
137 TInt iCurrentState; |
|
138 TInt iErrorCode; |
|
139 }; |
|
140 |
|
141 class CMMFClientUtility; // declared here. |
|
142 |
|
143 NONSHARABLE_CLASS( CMMFClientUtility ) |
|
144 { |
|
145 public: |
|
146 IMPORT_C static TUid ConvertMdaFormatUidToECOMWrite(TUid aMdaFormatUid); |
|
147 IMPORT_C static TUid ConvertMdaFormatUidToECOMRead(TUid aMdaFormatUid); |
|
148 IMPORT_C static TFourCC ConvertMdaCodecToFourCC(TMdaPackage& aCodec); |
|
149 IMPORT_C static TInt GetFileHeaderData(const TDesC& aFileName, TDes8& aHeaderData, TInt aMaxLength); |
|
150 IMPORT_C static HBufC8* GetFileExtensionL(const TDesC& aFileName); |
|
151 static void PrioritiseControllersL( |
|
152 const RMMFControllerImplInfoArray& aControllers, |
|
153 const TDesC8& aHeaderDataPlayback, |
|
154 const TDesC8& aFileExtensionPlayback, |
|
155 const TDesC8& aHeaderDataRecord, |
|
156 const TDesC8& aFileExtensionRecord, |
|
157 RMMFControllerImplInfoArray& aPrioritisedControllers); |
|
158 static TInt GetBestMatchL(const CMMFFormatImplementationInformation* format, const TDesC8& aHeaderData, const TDesC8& aFileExtension); |
|
159 |
|
160 private: |
|
161 CMMFClientUtility(); |
|
162 }; |
|
163 |
|
164 class CMMFUtilityFileInfo; // declared here. |
|
165 class RMMFDRMPluginServerProxy; |
|
166 |
|
167 NONSHARABLE_CLASS( CMMFUtilityFileInfo ): public CBase |
|
168 { |
|
169 public: |
|
170 |
|
171 static CMMFUtilityFileInfo* NewL(TMMSource& aSource, TBool aSecureDRMMode = EFalse); |
|
172 static CMMFUtilityFileInfo* NewLC(TMMSource& aSource, TBool aSecureDRMMode = EFalse); |
|
173 |
|
174 ~CMMFUtilityFileInfo(); |
|
175 |
|
176 TBool GetFileMimeTypeL(TDes8& aMimeType); |
|
177 void GetFileHeaderDataL(TDes8& aHeaderData, TInt aMaxLength); |
|
178 TInt EvaluateIntent(ContentAccess::TIntent aIntent); |
|
179 |
|
180 private: |
|
181 CMMFUtilityFileInfo(); |
|
182 |
|
183 void ConstructL(const TMMSource& aSource, TBool aSecureDRMMode); |
|
184 |
|
185 private: |
|
186 ContentAccess::CData* iData; |
|
187 RMMFDRMPluginServerProxy* iDrmPluginServer; |
|
188 }; |
|
189 |
|
190 inline CMMFUtilityFileInfo::CMMFUtilityFileInfo() |
|
191 { |
|
192 }; |
|
193 |
|
194 /** |
|
195 * Mixin class that the user of the class CMMFFindAndOpenController must derive from. |
|
196 * @internalComponent |
|
197 */ |
|
198 class MMMFFindAndOpenControllerObserver |
|
199 { |
|
200 public: |
|
201 /** |
|
202 * Callback function to indicate the success or failure |
|
203 * of an attempt to find and open a suitable controller and |
|
204 * to add a source and sink. |
|
205 * @see CMMFFindAndOpenController |
|
206 * |
|
207 * @param aError |
|
208 * Indicates whether a controller has been opened sucessfully |
|
209 * This is passed by reference, mainly for the audio recorder utility |
|
210 * which opens two controllers: if the secondary controller (which is |
|
211 * always opened first) fails to open, then the audio recorder utility |
|
212 * may choose to set aError = KErrNone in the MfaocComplete() callback |
|
213 * to indicate to CFindAndOpenControler() that it should continue |
|
214 * to open the primary controller, even though opening the secondary failed. |
|
215 * @param aController |
|
216 * A pointer to the controller that has been opened or has failed to open |
|
217 * This is mainly for the audio recorder utility to indicate |
|
218 * which controller (primary or secondary) has been opened. |
|
219 * @param aControllerUid |
|
220 * the UID of the controller that has been opened |
|
221 * @param aSourceHandle |
|
222 * a pointer to the source handle |
|
223 * @internalComponent |
|
224 * a pointer to the sink handle |
|
225 */ |
|
226 virtual void MfaocComplete( |
|
227 TInt& aError, |
|
228 RMMFController* aController, |
|
229 TUid aControllerUid = KNullUid, |
|
230 TMMFMessageDestination* aSourceHandle = NULL, |
|
231 TMMFMessageDestination* aSinkHandle = NULL) = 0; |
|
232 }; |
|
233 |
|
234 |
|
235 class CMMFFindAndOpenController; // declared here. |
|
236 /** |
|
237 * Utility class used by the MMF client API classes. |
|
238 * Finds and opens a suitable controller and adds a source and a sink |
|
239 * asynchronously. Completion is indicated asynchronously |
|
240 * using the MMMFFindAndOpenControllerObserver mixin class. |
|
241 * |
|
242 * @internalComponent |
|
243 */ |
|
244 NONSHARABLE_CLASS( CMMFFindAndOpenController ): public CActive, public MMMFAddDataSourceSinkAsyncObserver |
|
245 { |
|
246 public: |
|
247 enum TControllerMode |
|
248 { |
|
249 EPlayback, |
|
250 ERecord, |
|
251 EConvert |
|
252 }; |
|
253 |
|
254 enum TControllerNumber |
|
255 { |
|
256 EPrimaryController, |
|
257 ESecondaryController |
|
258 }; |
|
259 |
|
260 class TSourceSink |
|
261 { |
|
262 public: |
|
263 IMPORT_C TSourceSink(TUid aUid, const TDesC8& aData = KNullDesC8); |
|
264 IMPORT_C TSourceSink(TUid aUid, const RFile& aFile); |
|
265 |
|
266 TUid iUid; |
|
267 const TDesC8& iConfigData; |
|
268 TBool iUseFileHandle; |
|
269 RFile iFileHandle; |
|
270 }; |
|
271 |
|
272 |
|
273 |
|
274 |
|
275 public: |
|
276 IMPORT_C static CMMFFindAndOpenController* NewL(MMMFFindAndOpenControllerObserver& aObserver); |
|
277 virtual ~CMMFFindAndOpenController(); |
|
278 |
|
279 // from CActive |
|
280 virtual void DoCancel(); |
|
281 virtual void RunL(); |
|
282 |
|
283 // from MMMFAddDataSourceSinkAsyncObserver |
|
284 virtual void MadssaoAddDataSourceSinkAsyncComplete(TInt aError, const TMMFMessageDestination& aHandle); |
|
285 |
|
286 IMPORT_C void Configure( |
|
287 TUid aMediaId, |
|
288 TMMFPrioritySettings aPrioritySettings, |
|
289 CMMFPluginSelectionParameters::TMediaIdMatchType aMediaIdMatchType = CMMFPluginSelectionParameters::EAllowOnlySuppliedMediaIds); |
|
290 |
|
291 IMPORT_C void ConfigureController(RMMFController& aController, CMMFControllerEventMonitor& aEventMonitor, TControllerMode aControllerMode = EPlayback); |
|
292 IMPORT_C void ConfigureSecondaryController(RMMFController& aController, CMMFControllerEventMonitor& aEventMonitor, TControllerMode aControllerMode = EPlayback); |
|
293 |
|
294 IMPORT_C void UseSharedHeap(); |
|
295 |
|
296 IMPORT_C void ConfigureSourceSink( |
|
297 TSourceSink aSource, |
|
298 TSourceSink aSink); |
|
299 IMPORT_C void ConfigureSecondarySourceSink( |
|
300 TSourceSink aSource, |
|
301 TSourceSink aSink); |
|
302 |
|
303 IMPORT_C void ConfigureSourceSink( |
|
304 const TMMSource& aSource, |
|
305 TSourceSink aSink); |
|
306 |
|
307 IMPORT_C void OpenByFileSource(const TMMSource& aFileSource, const TDesC& aFileNameSecondary = KNullDesC); |
|
308 |
|
309 IMPORT_C void OpenByFormatUid(TUid aFormatUid, TUid aFormatUidSecondary = KNullUid); |
|
310 IMPORT_C void OpenByDescriptor(const TDesC8& aDescriptor); |
|
311 IMPORT_C void OpenByUrl(const TDesC& aUrl, TInt aIapId, const TDesC8& aMimeType); |
|
312 IMPORT_C void OpenByControllerUid(TUid aControllerUid, TUid aSecondaryControllerUid = KNullUid); |
|
313 IMPORT_C void ReOpen(); |
|
314 IMPORT_C void Close(); |
|
315 |
|
316 IMPORT_C static TMMFFileConfig GetConfigFile(const TDesC& aFileName); |
|
317 IMPORT_C static TMMFDescriptorConfig GetConfigDescriptor(const TDesC8& aDescriptor); |
|
318 IMPORT_C void CloseConfig(); |
|
319 IMPORT_C static void GetConfigUrlL(CBufFlat*& aUrlCfgBuffer, const TDesC& aUrl, TInt aIapId); |
|
320 |
|
321 /** made public to check for further selected controllers in the queue */ |
|
322 inline TInt ControllerIndex() const; |
|
323 inline TInt ControllerCount() const; |
|
324 |
|
325 /** made public to stop checking for further selected controllers in the queue */ |
|
326 inline TBool StopTryLoadController() const; |
|
327 IMPORT_C void SetInitScreenNumber(TInt aScreenNumber, RMMFVideoSetInitScreenCustomCommands* aVideoSetInitScreenCustomCommands); |
|
328 #ifdef SYMBIAN_BUILD_GCE |
|
329 inline void SetSurfaceMode(TBool aUseSurface, RMMFVideoPlaySurfaceSupportCustomCommands* aVideoPlaySurfaceSupportCustomCommands); |
|
330 inline TInt SurfaceSupported(); |
|
331 #endif |
|
332 |
|
333 private: |
|
334 class CConfig: public CBase |
|
335 { |
|
336 public: |
|
337 CConfig(); |
|
338 ~CConfig(); |
|
339 void Close(); |
|
340 public: |
|
341 RMMFController* iController; // not owned |
|
342 CMMFControllerEventMonitor* iEventMonitor; // not owned |
|
343 |
|
344 /** indicates whether this controller is being used for |
|
345 playback, recording or converting */ |
|
346 TControllerMode iControllerMode; |
|
347 |
|
348 CMMSourceSink* iSource; |
|
349 CMMSourceSink* iSink; |
|
350 TUid iControllerUid; |
|
351 }; |
|
352 |
|
353 CMMFFindAndOpenController(MMMFFindAndOpenControllerObserver& aObserver); |
|
354 void ConstructL(); |
|
355 |
|
356 void Init(); |
|
357 |
|
358 void ConfigureSourceSink( |
|
359 CConfig& config, |
|
360 TSourceSink aSource, |
|
361 TSourceSink aSink); |
|
362 |
|
363 void ConfigureSourceSink( |
|
364 CConfig& config, |
|
365 const TMMSource& aSource, |
|
366 TSourceSink aSink); |
|
367 |
|
368 |
|
369 void ConfigureController( |
|
370 CConfig& config, |
|
371 RMMFController& aController, |
|
372 CMMFControllerEventMonitor& aEventMonitor, |
|
373 TControllerMode aControllerMode); |
|
374 |
|
375 void CloseController(); |
|
376 |
|
377 void OpenPrimaryController(void); |
|
378 |
|
379 void KickState(); |
|
380 void Process(); |
|
381 void SendError(TInt aError = KErrNone, TBool aForcedError = EFalse); |
|
382 void SchedSendError(TInt aError = KErrNone); |
|
383 void BuildControllerListFileNameL(); |
|
384 void BuildControllerListDescriptorL(); |
|
385 void BuildControllerListUrlL(); |
|
386 void BuildControllerListFormatL(); |
|
387 void TryNextController(); |
|
388 |
|
389 CMMSourceSink* CreateSourceSinkL(const TSourceSink& aParams); |
|
390 CMMSourceSink* CreateSourceSinkL(const TMMSource& aSource); |
|
391 |
|
392 CMMFUtilityFileInfo* CreateFileInfoL(TBool aSecureDRMMode = EFalse); |
|
393 void UseSecureDRMProcessL(TBool& aIsSecureDrmProcess); |
|
394 private: |
|
395 /** primary controller details */ |
|
396 CConfig* iPrimaryConfig; |
|
397 /** secondary controller details */ |
|
398 CConfig* iSecondaryConfig; |
|
399 /** points to either iPrimaryConfig or iSecondaryConfig */ |
|
400 CConfig* iCurrentConfig; // not owned |
|
401 |
|
402 enum TMode |
|
403 { |
|
404 EOpenByControllerUid, |
|
405 EOpenByFileName, |
|
406 EOpenByDescriptor, |
|
407 EOpenByUrl, |
|
408 EOpenByFormatUid |
|
409 }; |
|
410 TMode iMode; |
|
411 |
|
412 /** indicates what state the state machine is in */ |
|
413 enum TState |
|
414 { |
|
415 EIdle, |
|
416 EBuildControllerList, |
|
417 EOpenController, |
|
418 EAddSource, |
|
419 EAddSink, |
|
420 EWaitingForSource, |
|
421 EWaitingForSink, |
|
422 ESendError |
|
423 }; |
|
424 TState iState; |
|
425 |
|
426 MMMFFindAndOpenControllerObserver& iObserver; |
|
427 CMMFAddDataSourceSinkAsync* iAddDataSourceSinkAsync; |
|
428 |
|
429 TInt iControllerIndex; |
|
430 TInt iControllerCount; |
|
431 |
|
432 TFileName iFileNameSecondary; // for converting |
|
433 |
|
434 TFileName iFileName; |
|
435 TBool iUseFileHandle; |
|
436 TBool iOwnFileHandle; |
|
437 HBufC* iUniqueId; |
|
438 RFile iFileHandle; |
|
439 ContentAccess::TIntent iIntent; |
|
440 |
|
441 HBufC* iUrl; |
|
442 HBufC8* iMimeType; |
|
443 TPtr8 iDescriptor; |
|
444 TInt iIapId; |
|
445 TUid iFormatUid; |
|
446 TUid iFormatUidSecondary; // for converting |
|
447 |
|
448 TUid iMediaId; |
|
449 TMMFPrioritySettings iPrioritySettings; |
|
450 CMMFPluginSelectionParameters::TMediaIdMatchType iMediaIdMatchType; |
|
451 |
|
452 RMMFControllerImplInfoArray iControllers; |
|
453 RMMFControllerImplInfoArray iPrioritisedControllers; |
|
454 |
|
455 // if this is non-null, then it points to an element in |
|
456 // either iControllers or iPrioritisedControllers |
|
457 CMMFControllerImplementationInformation* iControllerImplInfo; // not owned |
|
458 |
|
459 TControllerMode iControllerMode; |
|
460 TBool iSourceSinkConfigured; |
|
461 TInt iError; |
|
462 |
|
463 TMMFMessageDestination iSourceHandle; |
|
464 TMMFMessageDestination iSinkHandle; |
|
465 TBool iEnableUi; |
|
466 |
|
467 TBool iUseSharedHeap; // should new controllers use shared heaps? |
|
468 TBool iStopTryLoadController; //stop to try loading the selected conrollers from the list |
|
469 RMMFVideoSetInitScreenCustomCommands* iVideoSetInitScreenCustomCommands; |
|
470 TInt iScreenNumber; |
|
471 TBool iHasDrmCapability; |
|
472 TBool iUsingSecureDrmProcess; |
|
473 |
|
474 #ifdef SYMBIAN_BUILD_GCE |
|
475 RMMFVideoPlaySurfaceSupportCustomCommands* iVideoPlaySurfaceSupportCustomCommands; |
|
476 TBool iUseVPU2; |
|
477 TInt iSurfaceSupported; |
|
478 #endif |
|
479 }; |
|
480 |
|
481 inline TInt CMMFFindAndOpenController::ControllerIndex() const |
|
482 { |
|
483 return iControllerIndex; |
|
484 } |
|
485 |
|
486 inline TInt CMMFFindAndOpenController::ControllerCount() const |
|
487 { |
|
488 return iControllerCount; |
|
489 } |
|
490 |
|
491 inline TBool CMMFFindAndOpenController::StopTryLoadController() const |
|
492 { |
|
493 return iStopTryLoadController; |
|
494 } |
|
495 |
|
496 #ifdef SYMBIAN_BUILD_GCE |
|
497 inline void CMMFFindAndOpenController::SetSurfaceMode(TBool aUseVPU2, RMMFVideoPlaySurfaceSupportCustomCommands* aVideoPlaySurfaceSupportCustomCommands) |
|
498 { |
|
499 iUseVPU2 = aUseVPU2; |
|
500 iSurfaceSupported = KErrNone; |
|
501 iVideoPlaySurfaceSupportCustomCommands = aVideoPlaySurfaceSupportCustomCommands; |
|
502 } |
|
503 |
|
504 inline TInt CMMFFindAndOpenController::SurfaceSupported() |
|
505 { |
|
506 return iSurfaceSupported; |
|
507 } |
|
508 #endif // SYMBIAN_BUILD_GCE |
|
509 |
|
510 #endif // __MMF_CLIENT_UTILITY_H__ |