os/mm/mmlibs/mmfw/tsrc/mmfunittest/MidiClnt/MidiTestCntrl/Ts_cmmfmiditestcontroller.h
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfunittest/MidiClnt/MidiTestCntrl/Ts_cmmfmiditestcontroller.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,246 @@
1.4 +// Copyright (c) 2003-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 +//
1.18 +
1.19 +
1.20 +#ifndef TS_CMMFMIDITESTCONTROLLER_H
1.21 +#define TS_CMMFMIDITESTCONTROLLER_H
1.22 +
1.23 +#include <e32std.h>
1.24 +#include <e32base.h>
1.25 +
1.26 +
1.27 +
1.28 +#include <ecom/implementationproxy.h>
1.29 +
1.30 +#include <mmf/common/mmfcontroller.h>
1.31 +#include <mmf/server/mmfdatasource.h>
1.32 +#include <mmf/server/mmfdatasink.h>
1.33 +
1.34 +#include <testframework.h>
1.35 +#include <mmf/common/midistandardcustomcommands.h>
1.36 +#include <mmf/common/mmfdrmcustomcommands.h>
1.37 +#include "CmmfMidiTestControllerUIDs.hrh"
1.38 +
1.39 +
1.40 +class CMMFMidiTestController : public CMMFController,
1.41 + public MMidiCustomCommandImplementor,
1.42 + public MMMFDRMCustomCommandImplementor
1.43 +{
1.44 +public:
1.45 + static CMMFMidiTestController* NewL(void);
1.46 + static CMMFMidiTestController* NewLC(void);
1.47 +
1.48 + //implement CMMFMidiTestController ecom plugin interface
1.49 + virtual void AddDataSourceL(MDataSource& aDataSource);
1.50 + virtual void AddDataSinkL(MDataSink& aDataSink);
1.51 + virtual void RemoveDataSourceL(MDataSource& aDataSource);
1.52 + virtual void RemoveDataSinkL(MDataSink& aDataSink);
1.53 + virtual void RemoveSourceSinkL();
1.54 + virtual void ResetL();//XXX - replacement for RemoveSourceSink()
1.55 + virtual void PrimeL();
1.56 + virtual void PlayL();
1.57 + virtual void PauseL();
1.58 + virtual void StopL();
1.59 + virtual TTimeIntervalMicroSeconds PositionL() const;
1.60 + virtual void SetPositionL(const TTimeIntervalMicroSeconds& aPosition);
1.61 + virtual TTimeIntervalMicroSeconds DurationL() const;
1.62 + virtual void CustomCommand(TMMFMessage& aMessage);
1.63 + virtual void SetPrioritySettings(const TMMFPrioritySettings& aPrioritySettings);
1.64 + virtual void GetNumberOfMetaDataEntriesL(TInt& aNumberOfEntries);
1.65 + virtual CMMFMetaDataEntry* GetMetaDataEntryL(TInt aIndex);
1.66 +
1.67 + TInt SendEventToClient(const TMMFEvent& aEvent);
1.68 + TInt OpenComplete();
1.69 + TInt PlayStarted();
1.70 + TInt SyncUpdate();
1.71 + TInt PlayFinished();
1.72 + TInt Stop();
1.73 + TInt Close();
1.74 + TInt TempoChanged();
1.75 + TInt VolumeChanged();
1.76 + TInt MuteChanged();
1.77 + TInt PolyphonyChanged();
1.78 + TInt InstrumentChanged();
1.79 + TInt SmfMetaDataEntryFound();
1.80 + TInt MipMessageReceived();
1.81 +
1.82 + //-------------------------------//
1.83 + // MMidiCustomCommandImplementor //
1.84 + //-------------------------------//
1.85 + virtual void MmcSetPositionMicroBeatsL(TInt64 aMicroBeats);
1.86 + virtual void MmcPositionMicroBeatsL(TInt64& aMicroBeats);
1.87 + virtual void MmcPlayNoteL(TInt aChannel,TInt aNote,const TTimeIntervalMicroSeconds& aDuration,TInt aNoteOnVelocity,TInt aNoteOffVelocity);
1.88 + virtual void MmcPlayNoteL(TInt aChannel,TInt aNote,const TTimeIntervalMicroSeconds& aStartTime, const TTimeIntervalMicroSeconds& aDuration,TInt aNoteOnVelocity,TInt aNoteOffVelocity);
1.89 + virtual void MmcStopNotesL(TInt aChannel);
1.90 + virtual void MmcNoteOnL(TInt aChannel,TInt aNote,TInt aVelocity);
1.91 + virtual void MmcNoteOffL(TInt aChannel,TInt aNote,TInt aVelocity);
1.92 + virtual void MmcPlaybackRateL(TInt& aPlayBackRate);
1.93 + virtual void MmcSetPlaybackRateL(TInt aPlayBackRate);
1.94 + virtual void MmcMaxPlaybackRateL(TInt& aMaxRate);
1.95 + virtual void MmcMinPlaybackRateL(TInt& aMinRate);
1.96 + virtual void MmcTempoMicroBeatsPerMinuteL(TInt& aMicroBeatsPerMinute);
1.97 + virtual void MmcSetTempoL(TInt aMicroBeatsPerMinute);
1.98 + virtual void MmcPitchTranspositionCentsL(TInt& aPitch);
1.99 + virtual void MmcSetPitchTranspositionL(TInt aCents, TInt& aCentsApplied);
1.100 + virtual void MmcDurationMicroBeatsL(TInt64& aDuration);
1.101 + virtual void MmcNumTracksL(TInt& aTracks);
1.102 + virtual void MmcSetTrackMuteL(TInt aTrack, TBool aMuted);
1.103 + virtual void MmcMimeTypeL(TDes8& aMimeType);
1.104 + virtual void MmcSetSyncUpdateCallbackIntervalL(const TTimeIntervalMicroSeconds& aMicroSeconds,TInt64 aMicroBeats);
1.105 + virtual void MmcSendMessageL(const TDesC8& aMidiMessage, TInt& aBytes);
1.106 + virtual void MmcSendMessageL(const TDesC8& aMidiMessage,const TTimeIntervalMicroSeconds& aTime, TInt& aBytes);
1.107 + virtual void MmcSendMipMessageL(const TArray<TMipMessageEntry>& aEntry);
1.108 + virtual void MmcNumberOfBanksL(TBool aCustom, TInt& aNumBanks);
1.109 + virtual void MmcGetBankIdL(TBool aCustom, TInt aBankIndex, TInt& aBankId);
1.110 + virtual void MmcLoadCustomBankL(const TDesC& aFileName,TInt& aBankId);
1.111 + virtual void MmcUnloadCustomBankL(TInt aBankId);
1.112 + virtual void MmcCustomBankLoadedL(TInt aBankId, TBool& aBankLoaded);
1.113 + virtual void MmcUnloadAllCustomBanksL();
1.114 + virtual void MmcNumberOfInstrumentsL(TInt aBankId, TBool aCustom, TInt& aNumInstruments);
1.115 + virtual void MmcGetInstrumentIdL(TInt aBankId,TBool aCustom,TInt aInstrumentIndex, TInt& aInstrumentId);
1.116 + virtual const TDesC& MmcInstrumentNameL(TInt aBankId, TBool aCustom, TInt aInstrumentId);
1.117 + virtual void MmcSetInstrumentL(TInt aChannel,TInt aBankId,TInt aInstrumentId);
1.118 + virtual void MmcLoadCustomInstrumentL(const TDesC& aFileName, TInt aFileBankId, TInt aFileInstrumentId, TInt aMemoryBankId, TInt aMemoryInstrumentId);
1.119 + virtual void MmcUnloadCustomInstrumentL(TInt aCustomBankId,TInt aInstrumentId);
1.120 + virtual const TDesC& MmcPercussionKeyNameL(TInt aNote, TInt aBankId, TBool aCustom, TInt aInstrumentId);
1.121 + virtual void MmcStopTimeL(TTimeIntervalMicroSeconds& aStopTime);
1.122 + virtual void MmcSetStopTimeL(const TTimeIntervalMicroSeconds& aStopTime);
1.123 + virtual void MmcPolyphonyL(TInt& aNumNotes);
1.124 + virtual void MmcChannelsSupportedL(TInt& aChannels);
1.125 + virtual void MmcChannelVolumeL(TInt aChannel, TReal32& aChannelVol);
1.126 + virtual void MmcMaxChannelVolumeL(TReal32& aMaxVol);
1.127 + virtual void MmcSetChannelVolumeL(TInt aChannel,TReal32 aVolume);
1.128 + virtual void MmcSetChannelMuteL(TInt aChannel,TBool aMuted);
1.129 + virtual void MmcVolumeL(TInt& aVolume);
1.130 + virtual void MmcMaxVolumeL(TInt& aMaxVolume);
1.131 + virtual void MmcSetVolumeL(TInt aVolume);
1.132 + virtual void MmcSetVolumeRampL(const TTimeIntervalMicroSeconds& aRampDuration);
1.133 + virtual void MmcGetBalanceL(TInt& aBalance);
1.134 + virtual void MmcSetBalanceL(TInt aBalance);
1.135 + virtual void MmcLoadCustomBankDataL(const TDesC8& aBankData,TInt& aBankId);
1.136 + virtual void MmcLoadCustomInstrumentDataL(const TDesC8& aInstrumentData, TInt aBankDataId, TInt aInstrumentDataId, TInt aMemoryBankId, TInt aMemoryInstrumentId);
1.137 + virtual void MmcSetMaxPolyphonyL(TInt aMaxNotes);
1.138 + virtual void MmcGetRepeatsL(TInt& aNumRepeats);
1.139 + virtual void MmcSetRepeatsL(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds& aTrailingSilence);
1.140 + virtual void MmcSetBankL(TBool aCustom);
1.141 + virtual void MmcIsTrackMuteL(TInt aTrack, TBool& aTrackMute);
1.142 + virtual void MmcIsChannelMuteL(TInt aChannel, TBool& aChannelMute);
1.143 + virtual void MmcGetInstrumentL(TInt aChannel, TInt& aInstrumentId, TInt& aBankId);
1.144 + virtual void MmcCloseL();
1.145 + virtual void MmcStopL(const TTimeIntervalMicroSeconds& aFadeOutDuration);
1.146 + virtual void MmcMaxPolyphonyL(TInt& aMaxNotes);
1.147 +
1.148 + // MMMFDRMCustomCommandImplementor
1.149 + virtual TInt MdcDisableAutomaticIntent(TBool aDisableAutoIntent);
1.150 + virtual TInt MdcExecuteIntent(ContentAccess::TIntent aIntent);
1.151 + virtual TInt MdcEvaluateIntent(ContentAccess::TIntent aIntent);
1.152 + virtual TInt MdcSetAgentProperty(ContentAccess::TAgentProperty aProperty, TInt aValue);
1.153 +private:
1.154 +
1.155 + class CControllerTimer : public CTimer
1.156 + {
1.157 + public:
1.158 + enum TimerType
1.159 + {
1.160 + ETmrOpenComplete,
1.161 + ETmrSyncUpdate,
1.162 + ETmrDelayPlayStarted,
1.163 + ETmrPlayFinished,
1.164 + ETmrDelayStop,
1.165 + ETmrDelayClose
1.166 + };
1.167 + public:
1.168 + static CControllerTimer* NewL(CMMFMidiTestController* aController);
1.169 + void DelayOpen(TTimeIntervalMicroSeconds aDelay);
1.170 + void DelayPlayStarted(TTimeIntervalMicroSeconds aDelay);
1.171 + void PlayFinished(TTimeIntervalMicroSeconds aDelay);
1.172 + void DelaySyncUpdate(TTimeIntervalMicroSeconds aDelay);
1.173 + void DelayStop(TTimeIntervalMicroSeconds aDelay);
1.174 + void DelayClose(TTimeIntervalMicroSeconds aDelay);
1.175 +
1.176 + void RunL();
1.177 + private:
1.178 + CControllerTimer(CMMFMidiTestController* aController);
1.179 + CMMFMidiTestController* iController;
1.180 + TimerType iType;
1.181 + };
1.182 +
1.183 + class CMidiEventGenerator : public CTimer
1.184 + {
1.185 + public:
1.186 + enum TEventType
1.187 + {
1.188 + EEventTempoChanged,
1.189 + EEventVolumeChanged,
1.190 + EEventMuteChanged,
1.191 + EEventPolyphonyChanged,
1.192 + EEventInstrumentChanged,
1.193 + EEventSmfMetaDataEntryFound,
1.194 + EEventMipMessageReceived
1.195 + };
1.196 + public:
1.197 + static CMidiEventGenerator* NewL(CMMFMidiTestController* aController);
1.198 + void MidiEventTrigger();
1.199 + void RunL();
1.200 + private:
1.201 + CMidiEventGenerator(CMMFMidiTestController* aController);
1.202 + CMMFMidiTestController* iController;
1.203 + TEventType iType;
1.204 + TTimeIntervalMicroSeconds iDelay;
1.205 + TInt iTriggerCount;
1.206 + };
1.207 +
1.208 +private:
1.209 + CMMFMidiTestController(void);
1.210 + ~CMMFMidiTestController(void);
1.211 + void ConstructL(void);
1.212 + void InsertInterfaceNameInChunk(const TDesC8& aInterfaceName);
1.213 +
1.214 +private:
1.215 +// CMidiCustomCommandParser* iMidiParser;
1.216 + MMidiEventHandler* iMidiEventHandler;
1.217 + CControllerTimer* iDelayEvent;
1.218 + CMidiEventGenerator* iMidiEventGenerator;
1.219 +
1.220 + TInt iPlayBackRate;
1.221 + TInt iMaxRate;
1.222 + TInt iMinRate;
1.223 + TInt iTempoMicroBeatsPerMinute;
1.224 + TInt iPitchTranspositionCents;
1.225 + TInt iCentsApplied;
1.226 + TTimeIntervalMicroSeconds iDurationMicroSeconds;
1.227 + TInt64 iDurationMicroBeats;
1.228 + TInt iNumTracks;
1.229 + TTimeIntervalMicroSeconds iPositionMicroSeconds;
1.230 + TInt64 iPositionMicroBeats;
1.231 + TInt iNumBanks;
1.232 + TInt iNumInstruments;
1.233 + TTimeIntervalMicroSeconds iStopTime;
1.234 + TInt iNumNotes;
1.235 + TInt iChannels;
1.236 + TReal32 iMaxVol;
1.237 + TInt iMaxVolume;
1.238 + TInt iBalance;
1.239 + TInt iRepeatNumberOfTimes;
1.240 + TTimeIntervalMicroSeconds iTrailingSilence;
1.241 + TInt iMaxNotes;
1.242 +
1.243 + CArrayFixFlat<TReal32>* iChanVolumeValues;
1.244 + TMidiState iCurrentMidiTestControllerState;
1.245 + TBool iDisableAutoIntent;
1.246 + MDataSource* iDataSource;
1.247 +};
1.248 +
1.249 +#endif