os/mm/devsoundextensions/drmaudioplayer/DRMPlayUtility/src/mmfclientdrmaudioplayer.h
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/devsoundextensions/drmaudioplayer/DRMPlayUtility/src/mmfclientdrmaudioplayer.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,248 @@
1.4 +/*
1.5 +* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description: DRM Client AudioPlay Utility
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +
1.23 +#ifndef __MMFCLIENTAUDIOPLAY_H__
1.24 +#define __MMFCLIENTAUDIOPLAY_H__
1.25 +
1.26 +#include <e32std.h>
1.27 +#include <e32base.h>
1.28 +#include <mdaaudiosampleplayer.h>
1.29 +#include <mmf/common/mmfcontroller.h>
1.30 +#include <mmf/server/mmffile.h>
1.31 +#include <mmf/server/mmfdes.h>
1.32 +#include <mmfcontrollerimplementationuids.hrh>
1.33 +#include <mmf/common/mmfstandardcustomcommands.h>
1.34 +#include "mmfdrm.h"
1.35 +//#include "MmfClientUtility.h"
1.36 +
1.37 +static const TUid KUidMmfAudioController = {KMmfUidControllerAudio};
1.38 +
1.39 +/**
1.40 +Mixin class to allow notification that the timed silence has finished.
1.41 +*/
1.42 +class MRepeatTrailingSilenceTimerObs
1.43 + {
1.44 +public:
1.45 + virtual void RepeatTrailingSilenceTimerComplete() = 0;
1.46 + };
1.47 +
1.48 +/**
1.49 +CTimer-based active object that waits the requested time before notifying its observer.
1.50 +*/
1.51 +class CRepeatTrailingSilenceTimer : public CTimer
1.52 + {
1.53 +public:
1.54 + static CRepeatTrailingSilenceTimer* NewL(MRepeatTrailingSilenceTimerObs& aObs);
1.55 + void RunL();
1.56 +private:
1.57 + CRepeatTrailingSilenceTimer(MRepeatTrailingSilenceTimerObs& aObs);
1.58 +private:
1.59 + MRepeatTrailingSilenceTimerObs& iObs;
1.60 + };
1.61 +
1.62 +
1.63 +
1.64 +/**
1.65 +Concrete implementation of the CDRMPlayerUtility API.
1.66 +@see CDRMPlayerUtility
1.67 +*/
1.68 +class CMMFDrmAudioPlayerUtility : public CActive
1.69 + {
1.70 + enum TDRMUtilityState {
1.71 + EIdle,
1.72 + EInitializing,
1.73 + EPlaying,
1.74 + EPaused
1.75 + };
1.76 +
1.77 +friend class CDrmPlayerUtility;
1.78 +
1.79 +public:
1.80 + static CMMFDrmAudioPlayerUtility* NewFilePlayerL(const TDesC& aFileName,
1.81 + MDrmAudioPlayerCallback& aCallback,
1.82 + TInt aPriority = EMdaPriorityNormal,
1.83 + TMdaPriorityPreference aPref = EMdaPriorityPreferenceTimeAndQuality);
1.84 + static CMMFDrmAudioPlayerUtility* NewDesPlayerL(const TDesC8& aData,
1.85 + MDrmAudioPlayerCallback& aCallback,
1.86 + TInt aPriority = EMdaPriorityNormal,
1.87 + TMdaPriorityPreference aPref = EMdaPriorityPreferenceTimeAndQuality);
1.88 + static CMMFDrmAudioPlayerUtility* NewDesPlayerReadOnlyL(const TDesC8& aData,
1.89 + MDrmAudioPlayerCallback& aCallback,
1.90 + TInt aPriority = EMdaPriorityNormal,
1.91 + TMdaPriorityPreference aPref = EMdaPriorityPreferenceTimeAndQuality);
1.92 +
1.93 + static CMMFDrmAudioPlayerUtility* NewL(MDrmAudioPlayerCallback& aCallback,
1.94 + TInt aPriority = EMdaPriorityNormal,
1.95 + TMdaPriorityPreference aPref = EMdaPriorityPreferenceTimeAndQuality);
1.96 +
1.97 + ~CMMFDrmAudioPlayerUtility();
1.98 + void Play();
1.99 + void Stop();
1.100 + void SetVolume(TInt aVolume);
1.101 + void SetRepeats(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds& aTrailingSilence);
1.102 + void SetVolumeRamp(const TTimeIntervalMicroSeconds& aRampDuration);
1.103 + const TTimeIntervalMicroSeconds& Duration();
1.104 + TInt MaxVolume();
1.105 + void OpenFileL(const TDesC& aFileName);
1.106 + void OpenFileL(const RFile& aFile);
1.107 + void OpenFileL(const TMMSource& aSource);
1.108 + void OpenDesL(const TDesC8& aDescriptor);
1.109 + void OpenUrlL(const TDesC& aUrl, TInt aIapId = KUseDefaultIap, const TDesC8& aMimeType=KNullDesC8);
1.110 +
1.111 + // API Additions since version 7.0
1.112 + TInt Pause();
1.113 + void Close();
1.114 + TInt GetPosition(TTimeIntervalMicroSeconds& aPosition);
1.115 + void SetPosition(const TTimeIntervalMicroSeconds& aPosition);
1.116 +
1.117 + TInt SetPriority(TInt aPriority, TMdaPriorityPreference aPref);
1.118 + TInt GetVolume(TInt& aVolume);
1.119 + TInt GetNumberOfMetaDataEntries(TInt& aNumEntries);
1.120 + CMMFMetaDataEntry* GetMetaDataEntryL(TInt aMetaDataIndex);
1.121 + TInt SetPlayWindow(const TTimeIntervalMicroSeconds& aStart,
1.122 + const TTimeIntervalMicroSeconds& aEnd);
1.123 + TInt ClearPlayWindow();
1.124 + TInt SetBalance(TInt aBalance = KMMFBalanceCenter);
1.125 + TInt GetBalance(TInt& aBalance);
1.126 + TInt GetBitRate(TUint& aBitRate);
1.127 +
1.128 + void RegisterForAudioLoadingNotification(MAudioLoadingObserver& aLoadingObserver);
1.129 +
1.130 + void GetAudioLoadingProgressL(TInt& aPercentageProgress);
1.131 + const CMMFControllerImplementationInformation& ControllerImplementationInformationL();
1.132 +
1.133 + TInt CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom);
1.134 + TInt CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2);
1.135 + void CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom, TRequestStatus& aStatus);
1.136 + void CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TRequestStatus& aStatus);
1.137 +
1.138 +
1.139 +protected:
1.140 + CMMFDrmAudioPlayerUtility(MDrmAudioPlayerCallback& aCallback, TInt aActivePriority);
1.141 + void DoPlay();
1.142 + void RunL();
1.143 + void DoCancel();
1.144 +
1.145 +private:
1.146 + void ConstructL(TInt aPriority = EMdaPriorityNormal,
1.147 + TMdaPriorityPreference aPref = EMdaPriorityPreferenceTimeAndQuality);
1.148 +
1.149 + void ConstructL(const TDesC& aFileName,
1.150 + TInt aPriority = EMdaPriorityNormal,
1.151 + TMdaPriorityPreference aPref = EMdaPriorityPreferenceTimeAndQuality);
1.152 +
1.153 + void ConstructL(const TDesC8& aData,
1.154 + TInt aPriority = EMdaPriorityNormal,
1.155 + TMdaPriorityPreference aPref = EMdaPriorityPreferenceTimeAndQuality);
1.156 +
1.157 + void ConstructReadOnlyL(const TDesC8& aData,
1.158 + TInt aPriority = EMdaPriorityNormal,
1.159 + TMdaPriorityPreference aPref = EMdaPriorityPreferenceTimeAndQuality);
1.160 +
1.161 + void ConnectL();
1.162 +
1.163 + //Returns True if Destination CustomCommand needs to be blocked
1.164 + TBool IsValidCustomCommandDestination(TUid aDestinationUid, const TDesC8& aParam);
1.165 + TBool CheckCustomInterfaceBuilderImplL(const TDesC8& aParam);
1.166 +
1.167 + // last play window command
1.168 + enum TPlayWindowCommand
1.169 + {
1.170 + ENone,
1.171 + ESet,
1.172 + EClear
1.173 + };
1.174 +
1.175 + MDrmAudioPlayerCallback& iCallback;
1.176 + TDRMUtilityState iState;
1.177 + TTimeIntervalMicroSeconds iDuration; // Needed because of api "Duration()" that returns a reference
1.178 +
1.179 +
1.180 + CMMFControllerImplementationInformation* iControllerImplementationInformation;
1.181 + CDrm* iDrm;
1.182 + RDrmSession* iDrmSession;
1.183 + TInt iError;
1.184 + TFileName iFileName;
1.185 + CBufFlat* iMetaDataBuffer;
1.186 + MAudioLoadingObserver* iLoadingObserver;
1.187 + TAsyncCallbackStatePckgBuf iAsyncCallback;
1.188 + TErrorDurationStructPckgBuf iErrorDurationStruct;
1.189 + TRequestStatus* iRequestStatus;
1.190 + TDes8* iDataPointer;
1.191 + TDRMCustomCommand iCustomCommand;
1.192 + TPckgCustomCommand iCustomCommandPckg;
1.193 +
1.194 + struct TCustomCommands
1.195 + {
1.196 + const TMMFMessageDestinationPckg* iDestination;
1.197 + TInt iFunction;
1.198 + const TDesC8* iDataTo1;
1.199 + const TDesC8* iDataTo2;
1.200 + const TDes8* iDataFrom;
1.201 +
1.202 + TCustomCommands(const TMMFMessageDestinationPckg& aDestination, TInt aFunction,const TDesC8& aDataTo1,const TDesC8& aDataTo2,TDes8& aDataFrom)
1.203 + {
1.204 + iDestination = &aDestination;
1.205 + iFunction = aFunction;
1.206 + iDataTo1 = &aDataTo1;
1.207 + iDataTo2 = &aDataTo2;
1.208 + iDataFrom = &aDataFrom;
1.209 + };
1.210 + };
1.211 + struct TCustomCommandsAsync
1.212 + {
1.213 + const TMMFMessageDestinationPckg* iDestination;
1.214 + TInt iFunction;
1.215 + const TDesC8* iDataTo1;
1.216 + const TDesC8* iDataTo2;
1.217 + TDes8* iDataFrom;
1.218 + TRequestStatus* iRequestStatus;
1.219 +
1.220 + TCustomCommandsAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction,const TDesC8& aDataTo1,const TDesC8& aDataTo2, TDes8& aDataFrom,TRequestStatus& aStatus)
1.221 + {
1.222 + iDestination = &aDestination;
1.223 + iFunction = aFunction;
1.224 + iDataTo1 = &aDataTo1;
1.225 + iDataTo2 = &aDataTo2;
1.226 + iDataFrom = &aDataFrom;
1.227 + iRequestStatus = &aStatus;
1.228 + };
1.229 + };
1.230 + struct TCustomCommandsAsyncNoData
1.231 + {
1.232 + const TMMFMessageDestinationPckg* iDestination;
1.233 + TInt iFunction;
1.234 + const TDesC8* iDataTo1;
1.235 + const TDesC8* iDataTo2;
1.236 + TRequestStatus* iRequestStatus;
1.237 +
1.238 + TCustomCommandsAsyncNoData(const TMMFMessageDestinationPckg& aDestination, TInt aFunction,const TDesC8& aDataTo1,const TDesC8& aDataTo2,TRequestStatus& aStatus)
1.239 + {
1.240 + iDestination = &aDestination;
1.241 + iFunction = aFunction;
1.242 + iDataTo1 = &aDataTo1;
1.243 + iDataTo2 = &aDataTo2;
1.244 + iRequestStatus = &aStatus;
1.245 + };
1.246 + };
1.247 +
1.248 + typedef TPckg<TCustomCommands> TPckgTCustomCommandStructure;
1.249 + };
1.250 +
1.251 +#endif