1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/src/Client/Utility/mmfclientutility.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,510 @@
1.4 +// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Client utility functions
1.18 +//
1.19 +//
1.20 +
1.21 +#ifndef __MMF_CLIENT_UTILITY_H__
1.22 +#define __MMF_CLIENT_UTILITY_H__
1.23 +
1.24 +#include <mda/common/audio.h>
1.25 +#include <mda/common/gsmaudio.h>
1.26 +#include <mda/client/utility.h>
1.27 +#include <mmf/common/mmffourcc.h>
1.28 +#include <mmfformatimplementationuids.hrh>
1.29 +#include "mmf/common/mmfcontrollerpluginresolver.h"
1.30 +#include <mmf/server/mmffile.h>
1.31 +#include <mmf/server/mmfdes.h>
1.32 +#include "mmf/common/mmfcontroller.h"
1.33 +
1.34 +#include <f32file.h>
1.35 +#include <caf/content.h>
1.36 +#include <caf/data.h>
1.37 +#include <mmf/common/mmfstandardcustomcommands.h>
1.38 +#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
1.39 +#include <mmf/common/mmfstandardcustomcommandsenums.h>
1.40 +#include <mmf/common/mmfstandardcustomcommandsimpl.h>
1.41 +#endif
1.42 +#ifdef SYMBIAN_BUILD_GCE
1.43 +#include <mmf/common/mmfvideosurfacecustomcommands.h>
1.44 +#endif
1.45 +
1.46 +class CMMSourceSink; // declared here.
1.47 +
1.48 +NONSHARABLE_CLASS( CMMSourceSink ): public CBase
1.49 + {
1.50 +public:
1.51 + IMPORT_C static CMMSourceSink* NewL(TUid aUid, const TDesC8& aDescriptor);
1.52 + IMPORT_C static CMMSourceSink* NewLC(TUid aUid, const TDesC8& aDescriptor);
1.53 +
1.54 + virtual ~CMMSourceSink();
1.55 + virtual TUid SourceSinkUid() const;
1.56 + virtual const TDesC8& SourceSinkData() const;
1.57 +
1.58 + virtual TBool CarryingFileHandle() const;
1.59 +
1.60 + virtual void EvaluateIntentL();
1.61 +protected:
1.62 + CMMSourceSink(TUid aUid);
1.63 +
1.64 +
1.65 +private:
1.66 + void ConstructL(const TDesC8& aDescriptor);
1.67 +
1.68 + const TUid iUid;
1.69 + HBufC8* iBuf;
1.70 + };
1.71 +
1.72 +
1.73 +
1.74 +
1.75 +class CMMFileSourceSink; // declared here.
1.76 +
1.77 +NONSHARABLE_CLASS( CMMFileSourceSink ): public CMMSourceSink
1.78 + {
1.79 +public:
1.80 + IMPORT_C static CMMFileSourceSink* NewL(TUid aUid, const RFile& aFile);
1.81 + IMPORT_C static CMMFileSourceSink* NewLC(TUid aUid, const RFile& aFile);
1.82 +
1.83 + IMPORT_C static CMMFileSourceSink* NewL(TUid aUid, const TMMSource& aMMSource);
1.84 + IMPORT_C static CMMFileSourceSink* NewLC(TUid aUid, const TMMSource& aMMSource);
1.85 +
1.86 + const TDesC& UniqueId() const {return *iUniqueId;}
1.87 +
1.88 + virtual ~CMMFileSourceSink();
1.89 +
1.90 + const TDesC& FileName() const {return *iFileName;}
1.91 + const TDesC8& SourceSinkData() const;
1.92 +
1.93 + IMPORT_C void EvaluateIntentL(ContentAccess::TIntent aIntent);
1.94 + virtual void EvaluateIntentL();
1.95 +
1.96 + TBool CarryingFileHandle() const;
1.97 +
1.98 + TBool UsingFileHandle() const {return iUsingFileHandle;};
1.99 + const RFile& FileHandle() const {return iHandle;};
1.100 +protected:
1.101 + CMMFileSourceSink(TUid aUid);
1.102 +
1.103 +private:
1.104 + void ConstructL(const TMMSource& aSource);
1.105 + void DoCreateFileSourceConfigDataL();
1.106 + void ConstructL(const RFile& aFile);
1.107 + void DoCreateFileHandleSourceConfigDataL();
1.108 +
1.109 + TBool iUsingFileHandle;
1.110 + RFile iHandle;
1.111 + HBufC* iFileName;
1.112 + HBufC8* iSourceSinkData;
1.113 + HBufC* iUniqueId;
1.114 + ContentAccess::TIntent iIntent;
1.115 +
1.116 + TBool iEnableUI;
1.117 + };
1.118 +
1.119 +
1.120 +
1.121 +class CMMFMdaObjectStateChangeObserverCallback; // declared here.
1.122 +/**
1.123 +Active object utility class to allow the callback to be called asynchronously.
1.124 +This should help prevent re-entrant code in clients of the mediaframework.
1.125 +*/
1.126 +NONSHARABLE_CLASS( CMMFMdaObjectStateChangeObserverCallback ): public CActive
1.127 + {
1.128 +public:
1.129 + IMPORT_C static CMMFMdaObjectStateChangeObserverCallback* NewL(MMdaObjectStateChangeObserver& aCallback);
1.130 + virtual ~CMMFMdaObjectStateChangeObserverCallback();
1.131 + IMPORT_C void CallBack(CBase* aObject, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode);
1.132 +private:
1.133 + CMMFMdaObjectStateChangeObserverCallback(MMdaObjectStateChangeObserver& aCallback);
1.134 + void RunL();
1.135 + void DoCancel();
1.136 +private:
1.137 + MMdaObjectStateChangeObserver& iCallback;
1.138 + CBase* iObject;
1.139 + TInt iPreviousState;
1.140 + TInt iCurrentState;
1.141 + TInt iErrorCode;
1.142 + };
1.143 +
1.144 +class CMMFClientUtility; // declared here.
1.145 +
1.146 +NONSHARABLE_CLASS( CMMFClientUtility )
1.147 + {
1.148 +public:
1.149 + IMPORT_C static TUid ConvertMdaFormatUidToECOMWrite(TUid aMdaFormatUid);
1.150 + IMPORT_C static TUid ConvertMdaFormatUidToECOMRead(TUid aMdaFormatUid);
1.151 + IMPORT_C static TFourCC ConvertMdaCodecToFourCC(TMdaPackage& aCodec);
1.152 + IMPORT_C static TInt GetFileHeaderData(const TDesC& aFileName, TDes8& aHeaderData, TInt aMaxLength);
1.153 + IMPORT_C static HBufC8* GetFileExtensionL(const TDesC& aFileName);
1.154 + static void PrioritiseControllersL(
1.155 + const RMMFControllerImplInfoArray& aControllers,
1.156 + const TDesC8& aHeaderDataPlayback,
1.157 + const TDesC8& aFileExtensionPlayback,
1.158 + const TDesC8& aHeaderDataRecord,
1.159 + const TDesC8& aFileExtensionRecord,
1.160 + RMMFControllerImplInfoArray& aPrioritisedControllers);
1.161 + static TInt GetBestMatchL(const CMMFFormatImplementationInformation* format, const TDesC8& aHeaderData, const TDesC8& aFileExtension);
1.162 +
1.163 +private:
1.164 + CMMFClientUtility();
1.165 + };
1.166 +
1.167 +class CMMFUtilityFileInfo; // declared here.
1.168 +class RMMFDRMPluginServerProxy;
1.169 +
1.170 +NONSHARABLE_CLASS( CMMFUtilityFileInfo ): public CBase
1.171 + {
1.172 +public:
1.173 +
1.174 + static CMMFUtilityFileInfo* NewL(TMMSource& aSource, TBool aSecureDRMMode = EFalse);
1.175 + static CMMFUtilityFileInfo* NewLC(TMMSource& aSource, TBool aSecureDRMMode = EFalse);
1.176 +
1.177 + ~CMMFUtilityFileInfo();
1.178 +
1.179 + TBool GetFileMimeTypeL(TDes8& aMimeType);
1.180 + void GetFileHeaderDataL(TDes8& aHeaderData, TInt aMaxLength);
1.181 + TInt EvaluateIntent(ContentAccess::TIntent aIntent);
1.182 +
1.183 +private:
1.184 + CMMFUtilityFileInfo();
1.185 +
1.186 + void ConstructL(const TMMSource& aSource, TBool aSecureDRMMode);
1.187 +
1.188 +private:
1.189 + ContentAccess::CData* iData;
1.190 + RMMFDRMPluginServerProxy* iDrmPluginServer;
1.191 + };
1.192 +
1.193 +inline CMMFUtilityFileInfo::CMMFUtilityFileInfo()
1.194 + {
1.195 + };
1.196 +
1.197 +/**
1.198 + * Mixin class that the user of the class CMMFFindAndOpenController must derive from.
1.199 + * @internalComponent
1.200 + */
1.201 +class MMMFFindAndOpenControllerObserver
1.202 + {
1.203 +public:
1.204 + /**
1.205 + * Callback function to indicate the success or failure
1.206 + * of an attempt to find and open a suitable controller and
1.207 + * to add a source and sink.
1.208 + * @see CMMFFindAndOpenController
1.209 + *
1.210 + * @param aError
1.211 + * Indicates whether a controller has been opened sucessfully
1.212 + * This is passed by reference, mainly for the audio recorder utility
1.213 + * which opens two controllers: if the secondary controller (which is
1.214 + * always opened first) fails to open, then the audio recorder utility
1.215 + * may choose to set aError = KErrNone in the MfaocComplete() callback
1.216 + * to indicate to CFindAndOpenControler() that it should continue
1.217 + * to open the primary controller, even though opening the secondary failed.
1.218 + * @param aController
1.219 + * A pointer to the controller that has been opened or has failed to open
1.220 + * This is mainly for the audio recorder utility to indicate
1.221 + * which controller (primary or secondary) has been opened.
1.222 + * @param aControllerUid
1.223 + * the UID of the controller that has been opened
1.224 + * @param aSourceHandle
1.225 + * a pointer to the source handle
1.226 + * @internalComponent
1.227 + * a pointer to the sink handle
1.228 + */
1.229 + virtual void MfaocComplete(
1.230 + TInt& aError,
1.231 + RMMFController* aController,
1.232 + TUid aControllerUid = KNullUid,
1.233 + TMMFMessageDestination* aSourceHandle = NULL,
1.234 + TMMFMessageDestination* aSinkHandle = NULL) = 0;
1.235 + };
1.236 +
1.237 +
1.238 +class CMMFFindAndOpenController; // declared here.
1.239 +/**
1.240 + * Utility class used by the MMF client API classes.
1.241 + * Finds and opens a suitable controller and adds a source and a sink
1.242 + * asynchronously. Completion is indicated asynchronously
1.243 + * using the MMMFFindAndOpenControllerObserver mixin class.
1.244 + *
1.245 + * @internalComponent
1.246 + */
1.247 +NONSHARABLE_CLASS( CMMFFindAndOpenController ): public CActive, public MMMFAddDataSourceSinkAsyncObserver
1.248 + {
1.249 +public:
1.250 + enum TControllerMode
1.251 + {
1.252 + EPlayback,
1.253 + ERecord,
1.254 + EConvert
1.255 + };
1.256 +
1.257 + enum TControllerNumber
1.258 + {
1.259 + EPrimaryController,
1.260 + ESecondaryController
1.261 + };
1.262 +
1.263 + class TSourceSink
1.264 + {
1.265 + public:
1.266 + IMPORT_C TSourceSink(TUid aUid, const TDesC8& aData = KNullDesC8);
1.267 + IMPORT_C TSourceSink(TUid aUid, const RFile& aFile);
1.268 +
1.269 + TUid iUid;
1.270 + const TDesC8& iConfigData;
1.271 + TBool iUseFileHandle;
1.272 + RFile iFileHandle;
1.273 + };
1.274 +
1.275 +
1.276 +
1.277 +
1.278 +public:
1.279 + IMPORT_C static CMMFFindAndOpenController* NewL(MMMFFindAndOpenControllerObserver& aObserver);
1.280 + virtual ~CMMFFindAndOpenController();
1.281 +
1.282 + // from CActive
1.283 + virtual void DoCancel();
1.284 + virtual void RunL();
1.285 +
1.286 + // from MMMFAddDataSourceSinkAsyncObserver
1.287 + virtual void MadssaoAddDataSourceSinkAsyncComplete(TInt aError, const TMMFMessageDestination& aHandle);
1.288 +
1.289 + IMPORT_C void Configure(
1.290 + TUid aMediaId,
1.291 + TMMFPrioritySettings aPrioritySettings,
1.292 + CMMFPluginSelectionParameters::TMediaIdMatchType aMediaIdMatchType = CMMFPluginSelectionParameters::EAllowOnlySuppliedMediaIds);
1.293 +
1.294 + IMPORT_C void ConfigureController(RMMFController& aController, CMMFControllerEventMonitor& aEventMonitor, TControllerMode aControllerMode = EPlayback);
1.295 + IMPORT_C void ConfigureSecondaryController(RMMFController& aController, CMMFControllerEventMonitor& aEventMonitor, TControllerMode aControllerMode = EPlayback);
1.296 +
1.297 + IMPORT_C void UseSharedHeap();
1.298 +
1.299 + IMPORT_C void ConfigureSourceSink(
1.300 + TSourceSink aSource,
1.301 + TSourceSink aSink);
1.302 + IMPORT_C void ConfigureSecondarySourceSink(
1.303 + TSourceSink aSource,
1.304 + TSourceSink aSink);
1.305 +
1.306 + IMPORT_C void ConfigureSourceSink(
1.307 + const TMMSource& aSource,
1.308 + TSourceSink aSink);
1.309 +
1.310 + IMPORT_C void OpenByFileSource(const TMMSource& aFileSource, const TDesC& aFileNameSecondary = KNullDesC);
1.311 +
1.312 + IMPORT_C void OpenByFormatUid(TUid aFormatUid, TUid aFormatUidSecondary = KNullUid);
1.313 + IMPORT_C void OpenByDescriptor(const TDesC8& aDescriptor);
1.314 + IMPORT_C void OpenByUrl(const TDesC& aUrl, TInt aIapId, const TDesC8& aMimeType);
1.315 + IMPORT_C void OpenByControllerUid(TUid aControllerUid, TUid aSecondaryControllerUid = KNullUid);
1.316 + IMPORT_C void ReOpen();
1.317 + IMPORT_C void Close();
1.318 +
1.319 + IMPORT_C static TMMFFileConfig GetConfigFile(const TDesC& aFileName);
1.320 + IMPORT_C static TMMFDescriptorConfig GetConfigDescriptor(const TDesC8& aDescriptor);
1.321 + IMPORT_C void CloseConfig();
1.322 + IMPORT_C static void GetConfigUrlL(CBufFlat*& aUrlCfgBuffer, const TDesC& aUrl, TInt aIapId);
1.323 +
1.324 + /** made public to check for further selected controllers in the queue */
1.325 + inline TInt ControllerIndex() const;
1.326 + inline TInt ControllerCount() const;
1.327 +
1.328 + /** made public to stop checking for further selected controllers in the queue */
1.329 + inline TBool StopTryLoadController() const;
1.330 + IMPORT_C void SetInitScreenNumber(TInt aScreenNumber, RMMFVideoSetInitScreenCustomCommands* aVideoSetInitScreenCustomCommands);
1.331 +#ifdef SYMBIAN_BUILD_GCE
1.332 + inline void SetSurfaceMode(TBool aUseSurface, RMMFVideoPlaySurfaceSupportCustomCommands* aVideoPlaySurfaceSupportCustomCommands);
1.333 + inline TInt SurfaceSupported();
1.334 +#endif
1.335 +
1.336 +private:
1.337 + class CConfig: public CBase
1.338 + {
1.339 + public:
1.340 + CConfig();
1.341 + ~CConfig();
1.342 + void Close();
1.343 + public:
1.344 + RMMFController* iController; // not owned
1.345 + CMMFControllerEventMonitor* iEventMonitor; // not owned
1.346 +
1.347 + /** indicates whether this controller is being used for
1.348 + playback, recording or converting */
1.349 + TControllerMode iControllerMode;
1.350 +
1.351 + CMMSourceSink* iSource;
1.352 + CMMSourceSink* iSink;
1.353 + TUid iControllerUid;
1.354 + };
1.355 +
1.356 + CMMFFindAndOpenController(MMMFFindAndOpenControllerObserver& aObserver);
1.357 + void ConstructL();
1.358 +
1.359 + void Init();
1.360 +
1.361 + void ConfigureSourceSink(
1.362 + CConfig& config,
1.363 + TSourceSink aSource,
1.364 + TSourceSink aSink);
1.365 +
1.366 + void ConfigureSourceSink(
1.367 + CConfig& config,
1.368 + const TMMSource& aSource,
1.369 + TSourceSink aSink);
1.370 +
1.371 +
1.372 + void ConfigureController(
1.373 + CConfig& config,
1.374 + RMMFController& aController,
1.375 + CMMFControllerEventMonitor& aEventMonitor,
1.376 + TControllerMode aControllerMode);
1.377 +
1.378 + void CloseController();
1.379 +
1.380 + void OpenPrimaryController(void);
1.381 +
1.382 + void KickState();
1.383 + void Process();
1.384 + void SendError(TInt aError = KErrNone, TBool aForcedError = EFalse);
1.385 + void SchedSendError(TInt aError = KErrNone);
1.386 + void BuildControllerListFileNameL();
1.387 + void BuildControllerListDescriptorL();
1.388 + void BuildControllerListUrlL();
1.389 + void BuildControllerListFormatL();
1.390 + void TryNextController();
1.391 +
1.392 + CMMSourceSink* CreateSourceSinkL(const TSourceSink& aParams);
1.393 + CMMSourceSink* CreateSourceSinkL(const TMMSource& aSource);
1.394 +
1.395 + CMMFUtilityFileInfo* CreateFileInfoL(TBool aSecureDRMMode = EFalse);
1.396 + void UseSecureDRMProcessL(TBool& aIsSecureDrmProcess);
1.397 +private:
1.398 + /** primary controller details */
1.399 + CConfig* iPrimaryConfig;
1.400 + /** secondary controller details */
1.401 + CConfig* iSecondaryConfig;
1.402 + /** points to either iPrimaryConfig or iSecondaryConfig */
1.403 + CConfig* iCurrentConfig; // not owned
1.404 +
1.405 + enum TMode
1.406 + {
1.407 + EOpenByControllerUid,
1.408 + EOpenByFileName,
1.409 + EOpenByDescriptor,
1.410 + EOpenByUrl,
1.411 + EOpenByFormatUid
1.412 + };
1.413 + TMode iMode;
1.414 +
1.415 + /** indicates what state the state machine is in */
1.416 + enum TState
1.417 + {
1.418 + EIdle,
1.419 + EBuildControllerList,
1.420 + EOpenController,
1.421 + EAddSource,
1.422 + EAddSink,
1.423 + EWaitingForSource,
1.424 + EWaitingForSink,
1.425 + ESendError
1.426 + };
1.427 + TState iState;
1.428 +
1.429 + MMMFFindAndOpenControllerObserver& iObserver;
1.430 + CMMFAddDataSourceSinkAsync* iAddDataSourceSinkAsync;
1.431 +
1.432 + TInt iControllerIndex;
1.433 + TInt iControllerCount;
1.434 +
1.435 + TFileName iFileNameSecondary; // for converting
1.436 +
1.437 + TFileName iFileName;
1.438 + TBool iUseFileHandle;
1.439 + TBool iOwnFileHandle;
1.440 + HBufC* iUniqueId;
1.441 + RFile iFileHandle;
1.442 + ContentAccess::TIntent iIntent;
1.443 +
1.444 + HBufC* iUrl;
1.445 + HBufC8* iMimeType;
1.446 + TPtr8 iDescriptor;
1.447 + TInt iIapId;
1.448 + TUid iFormatUid;
1.449 + TUid iFormatUidSecondary; // for converting
1.450 +
1.451 + TUid iMediaId;
1.452 + TMMFPrioritySettings iPrioritySettings;
1.453 + CMMFPluginSelectionParameters::TMediaIdMatchType iMediaIdMatchType;
1.454 +
1.455 + RMMFControllerImplInfoArray iControllers;
1.456 + RMMFControllerImplInfoArray iPrioritisedControllers;
1.457 +
1.458 + // if this is non-null, then it points to an element in
1.459 + // either iControllers or iPrioritisedControllers
1.460 + CMMFControllerImplementationInformation* iControllerImplInfo; // not owned
1.461 +
1.462 + TControllerMode iControllerMode;
1.463 + TBool iSourceSinkConfigured;
1.464 + TInt iError;
1.465 +
1.466 + TMMFMessageDestination iSourceHandle;
1.467 + TMMFMessageDestination iSinkHandle;
1.468 + TBool iEnableUi;
1.469 +
1.470 + TBool iUseSharedHeap; // should new controllers use shared heaps?
1.471 + TBool iStopTryLoadController; //stop to try loading the selected conrollers from the list
1.472 + RMMFVideoSetInitScreenCustomCommands* iVideoSetInitScreenCustomCommands;
1.473 + TInt iScreenNumber;
1.474 + TBool iHasDrmCapability;
1.475 + TBool iUsingSecureDrmProcess;
1.476 +
1.477 +#ifdef SYMBIAN_BUILD_GCE
1.478 + RMMFVideoPlaySurfaceSupportCustomCommands* iVideoPlaySurfaceSupportCustomCommands;
1.479 + TBool iUseVPU2;
1.480 + TInt iSurfaceSupported;
1.481 +#endif
1.482 + };
1.483 +
1.484 +inline TInt CMMFFindAndOpenController::ControllerIndex() const
1.485 + {
1.486 + return iControllerIndex;
1.487 + }
1.488 +
1.489 +inline TInt CMMFFindAndOpenController::ControllerCount() const
1.490 + {
1.491 + return iControllerCount;
1.492 + }
1.493 +
1.494 +inline TBool CMMFFindAndOpenController::StopTryLoadController() const
1.495 + {
1.496 + return iStopTryLoadController;
1.497 + }
1.498 +
1.499 +#ifdef SYMBIAN_BUILD_GCE
1.500 +inline void CMMFFindAndOpenController::SetSurfaceMode(TBool aUseVPU2, RMMFVideoPlaySurfaceSupportCustomCommands* aVideoPlaySurfaceSupportCustomCommands)
1.501 + {
1.502 + iUseVPU2 = aUseVPU2;
1.503 + iSurfaceSupported = KErrNone;
1.504 + iVideoPlaySurfaceSupportCustomCommands = aVideoPlaySurfaceSupportCustomCommands;
1.505 + }
1.506 +
1.507 +inline TInt CMMFFindAndOpenController::SurfaceSupported()
1.508 + {
1.509 + return iSurfaceSupported;
1.510 + }
1.511 +#endif // SYMBIAN_BUILD_GCE
1.512 +
1.513 +#endif // __MMF_CLIENT_UTILITY_H__