os/mm/devsoundextensions/drmaudioplayer/DRMPlayUtility/src/mmfclientdrmaudioplayer.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). 
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description:   DRM Client AudioPlay Utility
sl@0
    15
*
sl@0
    16
*/
sl@0
    17
sl@0
    18
sl@0
    19
sl@0
    20
#ifndef __MMFCLIENTAUDIOPLAY_H__
sl@0
    21
#define __MMFCLIENTAUDIOPLAY_H__
sl@0
    22
sl@0
    23
#include <e32std.h>
sl@0
    24
#include <e32base.h>
sl@0
    25
#include <mdaaudiosampleplayer.h>
sl@0
    26
#include <mmf/common/mmfcontroller.h>
sl@0
    27
#include <mmf/server/mmffile.h>
sl@0
    28
#include <mmf/server/mmfdes.h>
sl@0
    29
#include <mmfcontrollerimplementationuids.hrh>
sl@0
    30
#include <mmf/common/mmfstandardcustomcommands.h>
sl@0
    31
#include "mmfdrm.h"
sl@0
    32
//#include "MmfClientUtility.h"
sl@0
    33
sl@0
    34
static const TUid KUidMmfAudioController = {KMmfUidControllerAudio}; 
sl@0
    35
sl@0
    36
/**
sl@0
    37
Mixin class to allow notification that the timed silence has finished.
sl@0
    38
*/
sl@0
    39
class MRepeatTrailingSilenceTimerObs
sl@0
    40
	{
sl@0
    41
public:
sl@0
    42
	virtual void RepeatTrailingSilenceTimerComplete() = 0;
sl@0
    43
	};
sl@0
    44
sl@0
    45
/**
sl@0
    46
CTimer-based active object that waits the requested time before notifying its observer.
sl@0
    47
*/
sl@0
    48
class CRepeatTrailingSilenceTimer : public CTimer
sl@0
    49
	{
sl@0
    50
public:
sl@0
    51
	static CRepeatTrailingSilenceTimer* NewL(MRepeatTrailingSilenceTimerObs& aObs);
sl@0
    52
	void RunL();
sl@0
    53
private:
sl@0
    54
	CRepeatTrailingSilenceTimer(MRepeatTrailingSilenceTimerObs& aObs);
sl@0
    55
private:
sl@0
    56
	MRepeatTrailingSilenceTimerObs& iObs;
sl@0
    57
	};
sl@0
    58
sl@0
    59
sl@0
    60
sl@0
    61
/**
sl@0
    62
Concrete implementation of the CDRMPlayerUtility API.
sl@0
    63
@see CDRMPlayerUtility
sl@0
    64
*/
sl@0
    65
class CMMFDrmAudioPlayerUtility : public CActive
sl@0
    66
	{
sl@0
    67
	enum TDRMUtilityState {
sl@0
    68
		EIdle,
sl@0
    69
		EInitializing,
sl@0
    70
		EPlaying,
sl@0
    71
		EPaused
sl@0
    72
		};
sl@0
    73
sl@0
    74
friend class CDrmPlayerUtility;
sl@0
    75
sl@0
    76
public:
sl@0
    77
	static CMMFDrmAudioPlayerUtility* NewFilePlayerL(const TDesC& aFileName, 
sl@0
    78
								MDrmAudioPlayerCallback& aCallback, 
sl@0
    79
								TInt aPriority = EMdaPriorityNormal, 
sl@0
    80
								TMdaPriorityPreference aPref = EMdaPriorityPreferenceTimeAndQuality);
sl@0
    81
	static CMMFDrmAudioPlayerUtility* NewDesPlayerL(const TDesC8& aData, 
sl@0
    82
								MDrmAudioPlayerCallback& aCallback, 
sl@0
    83
								TInt aPriority = EMdaPriorityNormal, 
sl@0
    84
								TMdaPriorityPreference aPref = EMdaPriorityPreferenceTimeAndQuality);
sl@0
    85
	static CMMFDrmAudioPlayerUtility* NewDesPlayerReadOnlyL(const TDesC8& aData, 
sl@0
    86
								MDrmAudioPlayerCallback& aCallback, 
sl@0
    87
								TInt aPriority = EMdaPriorityNormal, 
sl@0
    88
								TMdaPriorityPreference aPref = EMdaPriorityPreferenceTimeAndQuality);
sl@0
    89
sl@0
    90
	static CMMFDrmAudioPlayerUtility* NewL(MDrmAudioPlayerCallback& aCallback,
sl@0
    91
								TInt aPriority = EMdaPriorityNormal,
sl@0
    92
								TMdaPriorityPreference aPref = EMdaPriorityPreferenceTimeAndQuality);
sl@0
    93
sl@0
    94
	~CMMFDrmAudioPlayerUtility();
sl@0
    95
	void Play();
sl@0
    96
	void Stop();
sl@0
    97
	void SetVolume(TInt aVolume);
sl@0
    98
	void SetRepeats(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds& aTrailingSilence);
sl@0
    99
	void SetVolumeRamp(const TTimeIntervalMicroSeconds& aRampDuration);
sl@0
   100
	const TTimeIntervalMicroSeconds& Duration();
sl@0
   101
	TInt MaxVolume();
sl@0
   102
	void OpenFileL(const TDesC& aFileName);
sl@0
   103
	void OpenFileL(const RFile& aFile);
sl@0
   104
	void OpenFileL(const TMMSource& aSource);
sl@0
   105
	void OpenDesL(const TDesC8& aDescriptor);
sl@0
   106
	void OpenUrlL(const TDesC& aUrl, TInt aIapId = KUseDefaultIap, const TDesC8& aMimeType=KNullDesC8);
sl@0
   107
sl@0
   108
	// API Additions since version 7.0	
sl@0
   109
	TInt Pause();
sl@0
   110
	void Close();
sl@0
   111
	TInt GetPosition(TTimeIntervalMicroSeconds& aPosition);
sl@0
   112
	void SetPosition(const TTimeIntervalMicroSeconds& aPosition);
sl@0
   113
sl@0
   114
	TInt SetPriority(TInt aPriority, TMdaPriorityPreference aPref);
sl@0
   115
	TInt GetVolume(TInt& aVolume);
sl@0
   116
	TInt GetNumberOfMetaDataEntries(TInt& aNumEntries);
sl@0
   117
	CMMFMetaDataEntry* GetMetaDataEntryL(TInt aMetaDataIndex);
sl@0
   118
	TInt SetPlayWindow(const TTimeIntervalMicroSeconds& aStart,
sl@0
   119
								const TTimeIntervalMicroSeconds& aEnd);
sl@0
   120
	TInt ClearPlayWindow();
sl@0
   121
	TInt SetBalance(TInt aBalance = KMMFBalanceCenter);
sl@0
   122
	TInt GetBalance(TInt& aBalance);
sl@0
   123
	TInt GetBitRate(TUint& aBitRate);
sl@0
   124
	
sl@0
   125
    void RegisterForAudioLoadingNotification(MAudioLoadingObserver& aLoadingObserver);
sl@0
   126
sl@0
   127
	void GetAudioLoadingProgressL(TInt& aPercentageProgress);
sl@0
   128
	const CMMFControllerImplementationInformation& ControllerImplementationInformationL();
sl@0
   129
	
sl@0
   130
	TInt CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom);
sl@0
   131
	TInt CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2);
sl@0
   132
	void CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom, TRequestStatus& aStatus);
sl@0
   133
	void CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TRequestStatus& aStatus);
sl@0
   134
sl@0
   135
sl@0
   136
protected:
sl@0
   137
	CMMFDrmAudioPlayerUtility(MDrmAudioPlayerCallback& aCallback, TInt aActivePriority);
sl@0
   138
	void DoPlay();
sl@0
   139
	void RunL();
sl@0
   140
	void DoCancel();
sl@0
   141
sl@0
   142
private:
sl@0
   143
	void ConstructL(TInt aPriority = EMdaPriorityNormal,
sl@0
   144
					TMdaPriorityPreference aPref = EMdaPriorityPreferenceTimeAndQuality);
sl@0
   145
sl@0
   146
	void ConstructL(const TDesC& aFileName, 
sl@0
   147
					TInt aPriority = EMdaPriorityNormal, 
sl@0
   148
					TMdaPriorityPreference aPref = EMdaPriorityPreferenceTimeAndQuality);
sl@0
   149
sl@0
   150
	void ConstructL(const TDesC8& aData, 
sl@0
   151
					TInt aPriority = EMdaPriorityNormal, 
sl@0
   152
					TMdaPriorityPreference aPref = EMdaPriorityPreferenceTimeAndQuality);
sl@0
   153
sl@0
   154
	void ConstructReadOnlyL(const TDesC8& aData, 
sl@0
   155
					TInt aPriority = EMdaPriorityNormal, 
sl@0
   156
					TMdaPriorityPreference aPref = EMdaPriorityPreferenceTimeAndQuality);
sl@0
   157
sl@0
   158
	void ConnectL();
sl@0
   159
	
sl@0
   160
	//Returns True if Destination CustomCommand needs to be blocked
sl@0
   161
	TBool IsValidCustomCommandDestination(TUid aDestinationUid, const TDesC8& aParam);
sl@0
   162
    TBool CheckCustomInterfaceBuilderImplL(const TDesC8& aParam);
sl@0
   163
    
sl@0
   164
	// last play window command
sl@0
   165
	enum TPlayWindowCommand
sl@0
   166
		{
sl@0
   167
		ENone,
sl@0
   168
		ESet,
sl@0
   169
		EClear
sl@0
   170
		};
sl@0
   171
sl@0
   172
	MDrmAudioPlayerCallback& iCallback;
sl@0
   173
	TDRMUtilityState iState;
sl@0
   174
	TTimeIntervalMicroSeconds iDuration; // Needed because of api "Duration()" that returns a reference
sl@0
   175
sl@0
   176
	
sl@0
   177
	CMMFControllerImplementationInformation* iControllerImplementationInformation;
sl@0
   178
	CDrm*						iDrm;
sl@0
   179
	RDrmSession*				iDrmSession;
sl@0
   180
	TInt						iError;
sl@0
   181
	TFileName iFileName;
sl@0
   182
	CBufFlat*					iMetaDataBuffer;
sl@0
   183
	MAudioLoadingObserver*		iLoadingObserver;
sl@0
   184
	TAsyncCallbackStatePckgBuf	iAsyncCallback;
sl@0
   185
	TErrorDurationStructPckgBuf	iErrorDurationStruct;
sl@0
   186
	TRequestStatus*				iRequestStatus;
sl@0
   187
	TDes8*						iDataPointer;
sl@0
   188
	TDRMCustomCommand			iCustomCommand;
sl@0
   189
	TPckgCustomCommand			iCustomCommandPckg;
sl@0
   190
sl@0
   191
    struct TCustomCommands
sl@0
   192
       {
sl@0
   193
       const TMMFMessageDestinationPckg* iDestination;
sl@0
   194
       TInt iFunction;
sl@0
   195
       const TDesC8* iDataTo1;
sl@0
   196
       const TDesC8* iDataTo2; 
sl@0
   197
       const TDes8* iDataFrom;
sl@0
   198
sl@0
   199
       TCustomCommands(const TMMFMessageDestinationPckg& aDestination, TInt aFunction,const TDesC8& aDataTo1,const TDesC8& aDataTo2,TDes8& aDataFrom)
sl@0
   200
          {
sl@0
   201
          iDestination = &aDestination;
sl@0
   202
          iFunction = aFunction;
sl@0
   203
          iDataTo1 = &aDataTo1;
sl@0
   204
          iDataTo2 = &aDataTo2;
sl@0
   205
          iDataFrom = &aDataFrom;
sl@0
   206
          };
sl@0
   207
       };
sl@0
   208
     struct TCustomCommandsAsync
sl@0
   209
       {
sl@0
   210
       const TMMFMessageDestinationPckg* iDestination;
sl@0
   211
       TInt iFunction;
sl@0
   212
       const TDesC8* iDataTo1;
sl@0
   213
       const TDesC8* iDataTo2; 
sl@0
   214
       TDes8* iDataFrom;
sl@0
   215
       TRequestStatus* iRequestStatus;
sl@0
   216
sl@0
   217
       TCustomCommandsAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction,const TDesC8& aDataTo1,const TDesC8& aDataTo2, TDes8& aDataFrom,TRequestStatus& aStatus)
sl@0
   218
          {
sl@0
   219
          iDestination = &aDestination;
sl@0
   220
          iFunction = aFunction;
sl@0
   221
          iDataTo1 = &aDataTo1;
sl@0
   222
          iDataTo2 = &aDataTo2;
sl@0
   223
          iDataFrom = &aDataFrom;
sl@0
   224
          iRequestStatus = &aStatus;
sl@0
   225
          };
sl@0
   226
       };
sl@0
   227
     struct TCustomCommandsAsyncNoData
sl@0
   228
       {
sl@0
   229
       const TMMFMessageDestinationPckg* iDestination;
sl@0
   230
       TInt iFunction;
sl@0
   231
       const TDesC8* iDataTo1;
sl@0
   232
       const TDesC8* iDataTo2; 
sl@0
   233
       TRequestStatus* iRequestStatus;
sl@0
   234
sl@0
   235
       TCustomCommandsAsyncNoData(const TMMFMessageDestinationPckg& aDestination, TInt aFunction,const TDesC8& aDataTo1,const TDesC8& aDataTo2,TRequestStatus& aStatus)
sl@0
   236
          {
sl@0
   237
          iDestination = &aDestination;
sl@0
   238
          iFunction = aFunction;
sl@0
   239
          iDataTo1 = &aDataTo1;
sl@0
   240
          iDataTo2 = &aDataTo2;
sl@0
   241
          iRequestStatus = &aStatus;
sl@0
   242
          };
sl@0
   243
       };
sl@0
   244
sl@0
   245
    typedef TPckg<TCustomCommands> TPckgTCustomCommandStructure;
sl@0
   246
	}; 
sl@0
   247
sl@0
   248
#endif