sl@0: /* sl@0: * Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: DRM Client AudioPlay Utility sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: #ifndef __MMFCLIENTAUDIOPLAY_H__ sl@0: #define __MMFCLIENTAUDIOPLAY_H__ sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "mmfdrm.h" sl@0: //#include "MmfClientUtility.h" sl@0: sl@0: static const TUid KUidMmfAudioController = {KMmfUidControllerAudio}; sl@0: sl@0: /** sl@0: Mixin class to allow notification that the timed silence has finished. sl@0: */ sl@0: class MRepeatTrailingSilenceTimerObs sl@0: { sl@0: public: sl@0: virtual void RepeatTrailingSilenceTimerComplete() = 0; sl@0: }; sl@0: sl@0: /** sl@0: CTimer-based active object that waits the requested time before notifying its observer. sl@0: */ sl@0: class CRepeatTrailingSilenceTimer : public CTimer sl@0: { sl@0: public: sl@0: static CRepeatTrailingSilenceTimer* NewL(MRepeatTrailingSilenceTimerObs& aObs); sl@0: void RunL(); sl@0: private: sl@0: CRepeatTrailingSilenceTimer(MRepeatTrailingSilenceTimerObs& aObs); sl@0: private: sl@0: MRepeatTrailingSilenceTimerObs& iObs; sl@0: }; sl@0: sl@0: sl@0: sl@0: /** sl@0: Concrete implementation of the CDRMPlayerUtility API. sl@0: @see CDRMPlayerUtility sl@0: */ sl@0: class CMMFDrmAudioPlayerUtility : public CActive sl@0: { sl@0: enum TDRMUtilityState { sl@0: EIdle, sl@0: EInitializing, sl@0: EPlaying, sl@0: EPaused sl@0: }; sl@0: sl@0: friend class CDrmPlayerUtility; sl@0: sl@0: public: sl@0: static CMMFDrmAudioPlayerUtility* NewFilePlayerL(const TDesC& aFileName, sl@0: MDrmAudioPlayerCallback& aCallback, sl@0: TInt aPriority = EMdaPriorityNormal, sl@0: TMdaPriorityPreference aPref = EMdaPriorityPreferenceTimeAndQuality); sl@0: static CMMFDrmAudioPlayerUtility* NewDesPlayerL(const TDesC8& aData, sl@0: MDrmAudioPlayerCallback& aCallback, sl@0: TInt aPriority = EMdaPriorityNormal, sl@0: TMdaPriorityPreference aPref = EMdaPriorityPreferenceTimeAndQuality); sl@0: static CMMFDrmAudioPlayerUtility* NewDesPlayerReadOnlyL(const TDesC8& aData, sl@0: MDrmAudioPlayerCallback& aCallback, sl@0: TInt aPriority = EMdaPriorityNormal, sl@0: TMdaPriorityPreference aPref = EMdaPriorityPreferenceTimeAndQuality); sl@0: sl@0: static CMMFDrmAudioPlayerUtility* NewL(MDrmAudioPlayerCallback& aCallback, sl@0: TInt aPriority = EMdaPriorityNormal, sl@0: TMdaPriorityPreference aPref = EMdaPriorityPreferenceTimeAndQuality); sl@0: sl@0: ~CMMFDrmAudioPlayerUtility(); sl@0: void Play(); sl@0: void Stop(); sl@0: void SetVolume(TInt aVolume); sl@0: void SetRepeats(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds& aTrailingSilence); sl@0: void SetVolumeRamp(const TTimeIntervalMicroSeconds& aRampDuration); sl@0: const TTimeIntervalMicroSeconds& Duration(); sl@0: TInt MaxVolume(); sl@0: void OpenFileL(const TDesC& aFileName); sl@0: void OpenFileL(const RFile& aFile); sl@0: void OpenFileL(const TMMSource& aSource); sl@0: void OpenDesL(const TDesC8& aDescriptor); sl@0: void OpenUrlL(const TDesC& aUrl, TInt aIapId = KUseDefaultIap, const TDesC8& aMimeType=KNullDesC8); sl@0: sl@0: // API Additions since version 7.0 sl@0: TInt Pause(); sl@0: void Close(); sl@0: TInt GetPosition(TTimeIntervalMicroSeconds& aPosition); sl@0: void SetPosition(const TTimeIntervalMicroSeconds& aPosition); sl@0: sl@0: TInt SetPriority(TInt aPriority, TMdaPriorityPreference aPref); sl@0: TInt GetVolume(TInt& aVolume); sl@0: TInt GetNumberOfMetaDataEntries(TInt& aNumEntries); sl@0: CMMFMetaDataEntry* GetMetaDataEntryL(TInt aMetaDataIndex); sl@0: TInt SetPlayWindow(const TTimeIntervalMicroSeconds& aStart, sl@0: const TTimeIntervalMicroSeconds& aEnd); sl@0: TInt ClearPlayWindow(); sl@0: TInt SetBalance(TInt aBalance = KMMFBalanceCenter); sl@0: TInt GetBalance(TInt& aBalance); sl@0: TInt GetBitRate(TUint& aBitRate); sl@0: sl@0: void RegisterForAudioLoadingNotification(MAudioLoadingObserver& aLoadingObserver); sl@0: sl@0: void GetAudioLoadingProgressL(TInt& aPercentageProgress); sl@0: const CMMFControllerImplementationInformation& ControllerImplementationInformationL(); sl@0: sl@0: TInt CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom); sl@0: TInt CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2); sl@0: void CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom, TRequestStatus& aStatus); sl@0: void CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TRequestStatus& aStatus); sl@0: sl@0: sl@0: protected: sl@0: CMMFDrmAudioPlayerUtility(MDrmAudioPlayerCallback& aCallback, TInt aActivePriority); sl@0: void DoPlay(); sl@0: void RunL(); sl@0: void DoCancel(); sl@0: sl@0: private: sl@0: void ConstructL(TInt aPriority = EMdaPriorityNormal, sl@0: TMdaPriorityPreference aPref = EMdaPriorityPreferenceTimeAndQuality); sl@0: sl@0: void ConstructL(const TDesC& aFileName, sl@0: TInt aPriority = EMdaPriorityNormal, sl@0: TMdaPriorityPreference aPref = EMdaPriorityPreferenceTimeAndQuality); sl@0: sl@0: void ConstructL(const TDesC8& aData, sl@0: TInt aPriority = EMdaPriorityNormal, sl@0: TMdaPriorityPreference aPref = EMdaPriorityPreferenceTimeAndQuality); sl@0: sl@0: void ConstructReadOnlyL(const TDesC8& aData, sl@0: TInt aPriority = EMdaPriorityNormal, sl@0: TMdaPriorityPreference aPref = EMdaPriorityPreferenceTimeAndQuality); sl@0: sl@0: void ConnectL(); sl@0: sl@0: //Returns True if Destination CustomCommand needs to be blocked sl@0: TBool IsValidCustomCommandDestination(TUid aDestinationUid, const TDesC8& aParam); sl@0: TBool CheckCustomInterfaceBuilderImplL(const TDesC8& aParam); sl@0: sl@0: // last play window command sl@0: enum TPlayWindowCommand sl@0: { sl@0: ENone, sl@0: ESet, sl@0: EClear sl@0: }; sl@0: sl@0: MDrmAudioPlayerCallback& iCallback; sl@0: TDRMUtilityState iState; sl@0: TTimeIntervalMicroSeconds iDuration; // Needed because of api "Duration()" that returns a reference sl@0: sl@0: sl@0: CMMFControllerImplementationInformation* iControllerImplementationInformation; sl@0: CDrm* iDrm; sl@0: RDrmSession* iDrmSession; sl@0: TInt iError; sl@0: TFileName iFileName; sl@0: CBufFlat* iMetaDataBuffer; sl@0: MAudioLoadingObserver* iLoadingObserver; sl@0: TAsyncCallbackStatePckgBuf iAsyncCallback; sl@0: TErrorDurationStructPckgBuf iErrorDurationStruct; sl@0: TRequestStatus* iRequestStatus; sl@0: TDes8* iDataPointer; sl@0: TDRMCustomCommand iCustomCommand; sl@0: TPckgCustomCommand iCustomCommandPckg; sl@0: sl@0: struct TCustomCommands sl@0: { sl@0: const TMMFMessageDestinationPckg* iDestination; sl@0: TInt iFunction; sl@0: const TDesC8* iDataTo1; sl@0: const TDesC8* iDataTo2; sl@0: const TDes8* iDataFrom; sl@0: sl@0: TCustomCommands(const TMMFMessageDestinationPckg& aDestination, TInt aFunction,const TDesC8& aDataTo1,const TDesC8& aDataTo2,TDes8& aDataFrom) sl@0: { sl@0: iDestination = &aDestination; sl@0: iFunction = aFunction; sl@0: iDataTo1 = &aDataTo1; sl@0: iDataTo2 = &aDataTo2; sl@0: iDataFrom = &aDataFrom; sl@0: }; sl@0: }; sl@0: struct TCustomCommandsAsync sl@0: { sl@0: const TMMFMessageDestinationPckg* iDestination; sl@0: TInt iFunction; sl@0: const TDesC8* iDataTo1; sl@0: const TDesC8* iDataTo2; sl@0: TDes8* iDataFrom; sl@0: TRequestStatus* iRequestStatus; sl@0: sl@0: TCustomCommandsAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction,const TDesC8& aDataTo1,const TDesC8& aDataTo2, TDes8& aDataFrom,TRequestStatus& aStatus) sl@0: { sl@0: iDestination = &aDestination; sl@0: iFunction = aFunction; sl@0: iDataTo1 = &aDataTo1; sl@0: iDataTo2 = &aDataTo2; sl@0: iDataFrom = &aDataFrom; sl@0: iRequestStatus = &aStatus; sl@0: }; sl@0: }; sl@0: struct TCustomCommandsAsyncNoData sl@0: { sl@0: const TMMFMessageDestinationPckg* iDestination; sl@0: TInt iFunction; sl@0: const TDesC8* iDataTo1; sl@0: const TDesC8* iDataTo2; sl@0: TRequestStatus* iRequestStatus; sl@0: sl@0: TCustomCommandsAsyncNoData(const TMMFMessageDestinationPckg& aDestination, TInt aFunction,const TDesC8& aDataTo1,const TDesC8& aDataTo2,TRequestStatus& aStatus) sl@0: { sl@0: iDestination = &aDestination; sl@0: iFunction = aFunction; sl@0: iDataTo1 = &aDataTo1; sl@0: iDataTo2 = &aDataTo2; sl@0: iRequestStatus = &aStatus; sl@0: }; sl@0: }; sl@0: sl@0: typedef TPckg TPckgTCustomCommandStructure; sl@0: }; sl@0: sl@0: #endif