sl@0: // Copyright (c) 2003-2009 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: sl@0: // sl@0: sl@0: #ifndef __MMF_AUDIOTONECONTROLLER_H__ sl@0: #define __MMF_AUDIOTONECONTROLLER_H__ sl@0: sl@0: // Standard EPOC32 includes required by this header file sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: // Public Media Server includes sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #include sl@0: #include sl@0: sl@0: sl@0: /** sl@0: Panic category and codes for the Audio Tone Controller sl@0: @internalTechnology sl@0: */ sl@0: _LIT(KMMFAudioToneControllerPanicCategory, "MMFAudioToneController"); sl@0: enum TMMFMdaAudioToneControllerPanicCodes sl@0: { sl@0: EMMFMdaAudioToneControllerAlreadyPrepared, sl@0: EMMFMdaAudioToneControllerBadToneConfig, sl@0: EMMFMdaAudioToneControllerBadMixinCall sl@0: }; sl@0: sl@0: /** sl@0: The public API for clients of the MMFAudioToneController sl@0: @internalTechnology sl@0: */ sl@0: sl@0: class CMMFAudioToneController : public CMMFController, sl@0: public MMMFAudioPlayDeviceCustomCommandImplementor, sl@0: public MMMFAudioPlayControllerCustomCommandImplementor, sl@0: public MDevSoundObserver, sl@0: public MMMFAudioPlayControllerSetRepeatsCustomCommandImplementor sl@0: { sl@0: public: sl@0: static CMMFController* NewL(); sl@0: virtual ~CMMFAudioToneController(); sl@0: sl@0: //implement CMMFController ecom plugin interface sl@0: virtual void AddDataSourceL(MDataSource& aDataSource); sl@0: virtual void AddDataSinkL(MDataSink& aDataSink); sl@0: virtual void RemoveDataSourceL(MDataSource& aDataSource); sl@0: virtual void RemoveDataSinkL(MDataSink& aDataSink); sl@0: sl@0: virtual void ResetL(); sl@0: virtual void PrimeL(); sl@0: virtual void PrimeL(TMMFMessage& aMessage); sl@0: virtual void PlayL(); sl@0: virtual void PauseL(); sl@0: virtual void StopL(); sl@0: sl@0: virtual TTimeIntervalMicroSeconds PositionL() const {User::Leave(KErrNotSupported); TTimeIntervalMicroSeconds zero(0); return zero;} sl@0: virtual void SetPositionL(const TTimeIntervalMicroSeconds& /*aPosition*/){} sl@0: virtual TTimeIntervalMicroSeconds DurationL() const {TTimeIntervalMicroSeconds zero(0); return zero;} sl@0: virtual void CustomCommand(TMMFMessage& aMessage); sl@0: sl@0: virtual void SetPrioritySettings(const TMMFPrioritySettings& aPrioritySettings); sl@0: sl@0: virtual void GetNumberOfMetaDataEntriesL(TInt& /*aNumberOfEntries*/){User::Leave(KErrNotSupported);} sl@0: virtual CMMFMetaDataEntry* GetMetaDataEntryL(TInt /*aIndex*/){User::Leave(KErrNotSupported); return NULL;} sl@0: sl@0: //from MMMFAudioPlayDeviceCustomCommandImplementor sl@0: virtual void MapdSetVolumeL(TInt aVolume); sl@0: virtual void MapdGetMaxVolumeL(TInt& aMaxVolume); sl@0: virtual void MapdGetVolumeL(TInt& aVolume); sl@0: virtual void MapdSetVolumeRampL(const TTimeIntervalMicroSeconds& aRampDuration); sl@0: virtual void MapdSetBalanceL(TInt aBalance); sl@0: virtual void MapdGetBalanceL(TInt& aBalance); sl@0: sl@0: //from MMMFAudioPlayControllerCustomCommandImplementor sl@0: virtual void MapcSetPlaybackWindowL(const TTimeIntervalMicroSeconds& /*aStart*/, const TTimeIntervalMicroSeconds& /*aEnd*/) {User::Leave(KErrNotSupported);} sl@0: virtual void MapcDeletePlaybackWindowL() {User::Leave(KErrNotSupported);} sl@0: virtual void MapcGetLoadingProgressL(TInt& /*aPercentageComplete*/) {User::Leave(KErrNotSupported);} sl@0: sl@0: sl@0: sl@0: // From DevSoundObserver sl@0: void InitializeComplete(TInt aError); sl@0: void ToneFinished(TInt aError); sl@0: void BufferToBeFilled(CMMFBuffer* /*aBuffer*/) {Panic(EMMFMdaAudioToneControllerBadMixinCall);} sl@0: void PlayError(TInt /*aError*/) {Panic(EMMFMdaAudioToneControllerBadMixinCall);} sl@0: void BufferToBeEmptied(CMMFBuffer* /*aBuffer*/) {Panic(EMMFMdaAudioToneControllerBadMixinCall);} sl@0: void RecordError(TInt /*aError*/) {Panic(EMMFMdaAudioToneControllerBadMixinCall);} sl@0: void ConvertError(TInt /*aError*/) {Panic(EMMFMdaAudioToneControllerBadMixinCall);} sl@0: void DeviceMessage(TUid /*aMessageId*/, const TDesC8& /*aMsg*/) {Panic(EMMFMdaAudioToneControllerBadMixinCall);} sl@0: void SendEventToClient(const TMMFEvent& aEvent); sl@0: sl@0: //from MMMFAudioPlayControllerSetRepeatsCustomCommandImplementor sl@0: virtual TInt MapcSetRepeats(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds& aTrailingSilence); sl@0: sl@0: sl@0: public: sl@0: sl@0: /** sl@0: TControllerState is an enumeration within the namespace CMMFAudioToneController sl@0: The enumeration provides a set of control states: sl@0: EStopped is the initial state the controller resides in after it has been loaded sl@0: EPrimed is the state the controller is in when it has been associated with datapaths but is not streaming data sl@0: EPlaying is the state the controller is in when it is streaming data sl@0: */ sl@0: enum TControllerState sl@0: { sl@0: EStopped, sl@0: EPrimed, sl@0: EPriming, sl@0: EPausePlaying, sl@0: EPlaying, sl@0: }; sl@0: sl@0: protected: sl@0: CMMFAudioToneController(); sl@0: protected: sl@0: void ConstructL(); sl@0: void NegotiateL(); sl@0: sl@0: // state accessor functions sl@0: TBool SetState( TControllerState aState ); sl@0: TControllerState State() const ; sl@0: TBool IsValidStateTransition( TControllerState aState ) const; sl@0: TBool Invariant() const; sl@0: TBool IsValidState( TControllerState aState ) const ; sl@0: TBool ResetPostCondition() const; sl@0: sl@0: void CalculateLeftRightBalance( TInt& aLeft, TInt& aRight, TInt aBalance ) const; sl@0: void CalculateBalance( TInt& aBalance, TInt aLeft, TInt aRight ) const; sl@0: sl@0: sl@0: void Panic(TInt aPanicCode) const {User::Panic(KMMFAudioToneControllerPanicCategory, aPanicCode);} sl@0: sl@0: private: sl@0: /** The data source provided by the Controller Framework, not owned (do not delete) */ sl@0: MDataSource* iDataSource; sl@0: sl@0: /** buffer that holds the data to be played */ sl@0: CMMFDataBuffer* iToneSequenceData; sl@0: sl@0: /** the Dev Sound that will be used to play the tone*/ sl@0: CMMFDevSound* iMMFDevSound; sl@0: sl@0: /** Current state of the controller, see TControllerState*/ sl@0: TControllerState iState; sl@0: sl@0: /** Priority setting used to controll access the Dev Sound*/ sl@0: TMMFPrioritySettings iPrioritySettings; sl@0: sl@0: /** Indicates whether both a surce and data sink have been supplied by the Controller Framework*/ sl@0: TBool iSourceAndSinkAdded; sl@0: sl@0: /** Indicates whether DevSound supports resume for current configuration*/ sl@0: TBool iIsResumeSupported; sl@0: sl@0: /** Used to store message */ sl@0: TMMFMessage* iMessage; sl@0: }; sl@0: sl@0: sl@0: #endif