mmfenh/advancedaudiocontroller/tsrc/advancedaudiocontrollertestmodule/AudioPlaybackTestModule/inc/SimpleSoundPlayer.h
changeset 0 71ca22bcf22a
child 18 2eb3b066cc7d
equal deleted inserted replaced
-1:000000000000 0:71ca22bcf22a
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  mmftsplay test component
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __SOUND_PLAYER_H
       
    19 #define  __SOUND_PLAYER_H
       
    20 
       
    21 #include <MdaAudioSamplePlayer.h>
       
    22 #include <StifTestModule.h>
       
    23 #include "EventTarget.h"
       
    24 #include "Parameters.h"
       
    25 
       
    26 #include <e32std.h>
       
    27 #include <e32base.h>
       
    28 #include <StifLogger.h>
       
    29 #include <MdaAudioSamplePlayer.h>
       
    30 #include "FileNameParameters.h"
       
    31 #include "Des8Parameters.h"
       
    32 //#include "FileHandlerParameters.h"
       
    33 #include "UrlParameters.h"
       
    34 #include "ObjectCountDown.h"
       
    35 #include <audiooutput.h>
       
    36 
       
    37 const TInt KRunCaseOpen = 2;
       
    38 const TInt KSubCaseNone = 0;
       
    39 //Error
       
    40 const TInt KErrIncorrect = -1502;	//-1101
       
    41 
       
    42 const TInt KRepeatTimes = 3;
       
    43 const TUid KUidInterfaceMMFController = {KMmfUidPluginInterfaceController};
       
    44 
       
    45 
       
    46 class CSimpleSoundPlayer: public CBase , public MEventTarget , public MMdaAudioPlayerCallback,
       
    47 public MAudioLoadingObserver, public MMMFAudioResourceNotificationCallback
       
    48 	{
       
    49 public:
       
    50 	static CSimpleSoundPlayer* NewUrlL(const TDesC &aDescriptor, TInt aIapId, const TDesC8 &aMime, CTestModuleIf &aConsole, CStifLogger &aLogger, TBool aImmediate=ETrue);
       
    51 	static CSimpleSoundPlayer* NewUrlLC(const TDesC &aDescriptor, TInt aIapId, const TDesC8 &aMime, CTestModuleIf &aConsole, CStifLogger &aLogger, TBool aImmediate=ETrue);
       
    52 
       
    53 	static CSimpleSoundPlayer* NewL(const TDesC8 &aDescriptor, CTestModuleIf &aConsole, CStifLogger &aLogger, TBool aImmediate=ETrue);
       
    54 	static CSimpleSoundPlayer* NewLC(const TDesC8 &aDescriptor, CTestModuleIf &aConsole, CStifLogger &aLogger, TBool aImmediate=ETrue);
       
    55 
       
    56 	static CSimpleSoundPlayer* NewL(const TFileName &aFile, CTestModuleIf &aConsole, CStifLogger &iLogger, TBool aImmediate=ETrue);
       
    57 	static CSimpleSoundPlayer* NewLC(const TFileName &aFile, CTestModuleIf &aConsole, CStifLogger &iLogger, TBool aImmediate=ETrue);
       
    58 
       
    59 	static CSimpleSoundPlayer* NewL(const RFile &aFile, CTestModuleIf &aConsole, CStifLogger &iLogger, TBool aImmediate=ETrue);
       
    60 	static CSimpleSoundPlayer* NewLC(const RFile &aFile, CTestModuleIf &aConsole, CStifLogger &iLogger, TBool aImmediate=ETrue);
       
    61 	~CSimpleSoundPlayer();
       
    62 
       
    63 
       
    64     static CSimpleSoundPlayer* NewL(CTestModuleIf &aConsole, CStifLogger &iLogger, TBool aUseSharedHeap = EFalse);
       
    65 	static CSimpleSoundPlayer* NewLC(CTestModuleIf &aConsole, CStifLogger &iLogger, TBool aUseSharedHeap);
       
    66 
       
    67 
       
    68 	// from MMdaAudioPlayerCallback
       
    69 	virtual void MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& aDuration);
       
    70 	virtual void MapcPlayComplete(TInt aError);
       
    71 	virtual void DoCancel();
       
    72 
       
    73 	virtual void MaloLoadingStarted();
       
    74 	virtual void MaloLoadingComplete();
       
    75 
       
    76 	virtual void MarncResourceAvailable(TUid aNotificationEventId, const TDesC8 &aNotificationData);
       
    77 
       
    78 	void SetVolumeRamp(const TTimeIntervalMicroSeconds &aRampDuration);
       
    79 	void SetRepeats(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds &aTrailingSilence);
       
    80 	void SetPosition(const TTimeIntervalMicroSeconds &aPosition);
       
    81 	TInt SetPlayWindow(const TTimeIntervalMicroSeconds &aStart, const TTimeIntervalMicroSeconds &aEnd);
       
    82 	TTimeIntervalMicroSeconds GetPlayDuration();
       
    83 	TTime GetPlayStartTime();
       
    84 	TTime GetPlayStopTime();
       
    85 	TInt GetBalance(TInt &aBalance);
       
    86 	TInt SetBalance(TInt aBalance);
       
    87 	TInt SetPriority(TInt aPriority, TMdaPriorityPreference aPref);
       
    88 	TInt SetThread_Priority();
       
    89 	TTimeIntervalMicroSeconds GetDuration();
       
    90 	TTimeIntervalMicroSeconds GetDuration_Para();
       
    91 	TInt ClearPlayWindow();
       
    92 	void GetConImpInfo();
       
    93 	void GetLoad_Percentage();
       
    94 	void GetBit_Rate();
       
    95 	void GetDRMCmd();
       
    96 	void CancelNotification();
       
    97 	void CtrImpInfo();
       
    98 	void Set_Priority();
       
    99 
       
   100 	TInt Play();
       
   101 	TInt OpenDesL(const TDesC8 &aSoundDes , const TBool &aImmediate=ETrue) ;
       
   102 	TInt GetPosition(TTimeIntervalMicroSeconds &aPosition);
       
   103 
       
   104 	void SetSupervisor(TObjectCountDown *aCounter) ;
       
   105 	void SetPlayCompleteTarget(MEventTarget *aTarget, CParameters *aParameters) ;
       
   106 
       
   107 	void SetVolume(TInt aNewVolume);
       
   108 	TInt GetVolume(TInt &aVolume);
       
   109 	TInt MaxVolume();
       
   110 
       
   111 	TInt GetNumberOfMetaDataEntries(TInt &aNumEntries);
       
   112 	CMMFMetaDataEntry *GetMetaDataEntryL(TInt aMetaDataIndex);
       
   113 
       
   114 	TInt OpenFile(const TFileName &aFile);
       
   115 	TInt OpenWithFileHandler(const RFile &aFile);
       
   116     TInt OpenWithFileSource(const TMMSource &aSource);
       
   117     TInt OpenWithDesc(const TDesC8 &aDescriptor);
       
   118 
       
   119     void RegNotification();
       
   120 	void RegLoadNotification();
       
   121 
       
   122 	void SetRunCase(TInt aRunCase);
       
   123     void SetSubCase(TInt aSubCase);
       
   124     
       
   125  
       
   126     void AudioOutputCreationL();
       
   127     void LoopPlayL();
       
   128    
       
   129 
       
   130 
       
   131 private:
       
   132 
       
   133     TInt Open_UrlL(const TDesC &aUrl, TInt aIapId, const TDesC8 &aMime) ;
       
   134 
       
   135 	TInt OpenUrlL(const TDesC &aUrl, TInt aIapId, const TDesC8 &aMime) ;
       
   136 	TInt Pause();
       
   137 	TInt PauseResume();
       
   138 	TInt OpenL(const TFileName &aFileName , const TBool &aImmediate);
       
   139 	TInt OpenFileHandlerL(const TFileName &aFileName , const TBool &aImmediate);
       
   140 	TInt Stop(const TBool &aAlsoClose=ETrue);
       
   141 
       
   142 	CSimpleSoundPlayer(CTestModuleIf &aConsole, CStifLogger &iLogger, TBool aImmediate=ETrue);
       
   143 	void ConstructUrlL(const TDesC &aDescriptor, TInt aIapId, const TDesC8 &aMime);
       
   144 	void ConstructL(const TDesC8 &aDescriptor);
       
   145 	void ConstructL(const TFileName &aFile);
       
   146 	void ConstructL(const RFile &aFile);
       
   147 	void ConstructL(TBool aUseSharedHeap);
       
   148 
       
   149 
       
   150 	void Exit(TInt aExitCode);
       
   151 
       
   152 
       
   153 
       
   154 
       
   155 private:
       
   156 	MEventTarget *iEventTarget;
       
   157 	CParameters *iParameters;
       
   158 
       
   159 	TObjectCountDown *iSupervisor;
       
   160 	CMdaAudioPlayerUtility* iMdaPlayer;
       
   161 	CMdaAudioPlayerUtility* iMdaPlayer_1;
       
   162 	CMdaAudioPlayerUtility* iMdaPlayer_2;
       
   163 	CMdaAudioPlayerUtility* iMdaPlayer_3;
       
   164 	CTestModuleIf &iConsole;
       
   165 	TBool iImmediate;
       
   166 	CStifLogger &iLogger;	
       
   167 	CAudioOutput* iAudioOutput;
       
   168 		
       
   169 	TTime iLastPlayTime;
       
   170 	TTime iLastStopTime;
       
   171 
       
   172 
       
   173 public:
       
   174 	static const TInt KPlayerActionPlay;
       
   175 	static const TInt KPlayerActionPause;
       
   176 	static const TInt KPlayerActionPauseResume;
       
   177 	static const TInt KPlayerActionStopPlayFile;
       
   178 	static const TInt KPlayerActionReportPosition;
       
   179 	static const TInt KPlayerActionReportDuration;
       
   180 	static const TInt KPlayerActionReportDuration_Para;
       
   181 	static const TInt KPlayerActionStopPlayDes;
       
   182 	static const TInt KPlayerActionReportVolume;
       
   183 	static const TInt KPlayerActionStopPlayUrl;
       
   184 	static const TInt KPlayerActionStopPlayFileHandler;
       
   185 
       
   186 	TInt ExecuteL(CParameters *aParams) ;
       
   187 
       
   188 	enum TState
       
   189 	{
       
   190 		ENotReady,
       
   191 		EReady,
       
   192 		EPlaying,
       
   193 		EPaused
       
   194 	};
       
   195 	TInt iPlayerId;
       
   196 	TState iState;
       
   197 	TBool iSoundOpen;
       
   198 	/////TBool iAutoClose;
       
   199 	TInt iFinalError;
       
   200 	TTimeIntervalMicroSeconds iPosition;
       
   201 	TTimeIntervalMicroSeconds startPosition;
       
   202 	TTimeIntervalMicroSeconds endPosition;
       
   203 	TInt aBalance;
       
   204 	TBool playVolume;
       
   205 	TBool metaInfo;
       
   206 	TBool playWindow;
       
   207 	TBool clearWindow;
       
   208 	TBool setBalance;
       
   209 	TBool iDontPlayAudioClip; // Binh
       
   210 
       
   211 	TInt iRunCase;
       
   212     TInt iSubCase;
       
   213 
       
   214 private:
       
   215     TBool iIsLoopPlayEnabled;
       
   216 
       
   217 };
       
   218 
       
   219 #endif //__SOUND_PLAYER_H
       
   220