devsound/devsoundrefplugin/src/controller/audio/MmfAudioToneController.h
changeset 0 79dd3e2336a0
equal deleted inserted replaced
-1:000000000000 0:79dd3e2336a0
       
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef __MMF_AUDIOTONECONTROLLER_H__
       
    17 #define __MMF_AUDIOTONECONTROLLER_H__
       
    18 
       
    19 // Standard EPOC32 includes required by this header file
       
    20 #include <e32base.h>
       
    21 #include <e32std.h>
       
    22 #include <ecom/implementationproxy.h>
       
    23 
       
    24 // Public Media Server includes
       
    25 #include <mmf/common/mmfcontroller.h>
       
    26 #include <mmf/server/mmfdatasink.h>
       
    27 #include <mmf/server/mmfdatasource.h>
       
    28 
       
    29 #include <mmf/common/mmfstandardcustomcommands.h>
       
    30 #include <mmf/server/sounddevice.h>
       
    31 
       
    32 
       
    33 /** 
       
    34 Panic category and codes for the Audio Tone Controller 
       
    35 @internalTechnology
       
    36 */
       
    37 _LIT(KMMFAudioToneControllerPanicCategory, "MMFAudioToneController");
       
    38 enum TMMFMdaAudioToneControllerPanicCodes
       
    39 	{
       
    40 	EMMFMdaAudioToneControllerAlreadyPrepared,
       
    41 	EMMFMdaAudioToneControllerBadToneConfig,
       
    42 	EMMFMdaAudioToneControllerBadMixinCall
       
    43 	};
       
    44 
       
    45 /**
       
    46 The public API for clients of the MMFAudioToneController
       
    47 @internalTechnology
       
    48 */
       
    49 
       
    50 class CMMFAudioToneController : public CMMFController, 
       
    51 							public MMMFAudioPlayDeviceCustomCommandImplementor,
       
    52 							public MMMFAudioPlayControllerCustomCommandImplementor,
       
    53 							public MDevSoundObserver,
       
    54 							public MMMFAudioPlayControllerSetRepeatsCustomCommandImplementor
       
    55 	{
       
    56 public:
       
    57 	static CMMFController* NewL();
       
    58 	virtual ~CMMFAudioToneController();
       
    59 
       
    60 	//implement CMMFController ecom plugin interface
       
    61 	virtual void AddDataSourceL(MDataSource& aDataSource);
       
    62 	virtual void AddDataSinkL(MDataSink& aDataSink);
       
    63 	virtual void RemoveDataSourceL(MDataSource& aDataSource);
       
    64 	virtual void RemoveDataSinkL(MDataSink& aDataSink);
       
    65 
       
    66 	virtual void ResetL();
       
    67 	virtual void PrimeL();
       
    68 	virtual void PrimeL(TMMFMessage& aMessage);
       
    69 	virtual void PlayL();
       
    70 	virtual void PauseL();
       
    71 	virtual void StopL();
       
    72 
       
    73 	virtual TTimeIntervalMicroSeconds PositionL() const {User::Leave(KErrNotSupported); TTimeIntervalMicroSeconds zero(0); return zero;}
       
    74 	virtual void SetPositionL(const TTimeIntervalMicroSeconds& /*aPosition*/){} 
       
    75 	virtual TTimeIntervalMicroSeconds DurationL() const {TTimeIntervalMicroSeconds zero(0); return zero;}
       
    76 	virtual void CustomCommand(TMMFMessage& aMessage);
       
    77 
       
    78 	virtual void SetPrioritySettings(const TMMFPrioritySettings& aPrioritySettings);
       
    79 
       
    80 	virtual void GetNumberOfMetaDataEntriesL(TInt& /*aNumberOfEntries*/){User::Leave(KErrNotSupported);}
       
    81 	virtual CMMFMetaDataEntry* GetMetaDataEntryL(TInt /*aIndex*/){User::Leave(KErrNotSupported); return NULL;}
       
    82 
       
    83 	//from MMMFAudioPlayDeviceCustomCommandImplementor
       
    84 	virtual void MapdSetVolumeL(TInt aVolume);
       
    85 	virtual void MapdGetMaxVolumeL(TInt& aMaxVolume);
       
    86 	virtual void MapdGetVolumeL(TInt& aVolume);
       
    87 	virtual void MapdSetVolumeRampL(const TTimeIntervalMicroSeconds& aRampDuration);
       
    88 	virtual void MapdSetBalanceL(TInt aBalance);
       
    89 	virtual void MapdGetBalanceL(TInt& aBalance);
       
    90 
       
    91 	//from MMMFAudioPlayControllerCustomCommandImplementor
       
    92 	virtual void MapcSetPlaybackWindowL(const TTimeIntervalMicroSeconds& /*aStart*/, const TTimeIntervalMicroSeconds& /*aEnd*/) {User::Leave(KErrNotSupported);}
       
    93 	virtual void MapcDeletePlaybackWindowL() {User::Leave(KErrNotSupported);}
       
    94 	virtual void MapcGetLoadingProgressL(TInt& /*aPercentageComplete*/) {User::Leave(KErrNotSupported);}
       
    95 
       
    96 
       
    97 
       
    98 	// From DevSoundObserver
       
    99 	void InitializeComplete(TInt aError);
       
   100 	void ToneFinished(TInt aError); 
       
   101 	void BufferToBeFilled(CMMFBuffer* /*aBuffer*/) {Panic(EMMFMdaAudioToneControllerBadMixinCall);}
       
   102 	void PlayError(TInt /*aError*/)	{Panic(EMMFMdaAudioToneControllerBadMixinCall);}
       
   103 	void BufferToBeEmptied(CMMFBuffer* /*aBuffer*/)	{Panic(EMMFMdaAudioToneControllerBadMixinCall);} 
       
   104 	void RecordError(TInt /*aError*/)	{Panic(EMMFMdaAudioToneControllerBadMixinCall);}
       
   105 	void ConvertError(TInt /*aError*/)  {Panic(EMMFMdaAudioToneControllerBadMixinCall);}
       
   106 	void DeviceMessage(TUid /*aMessageId*/, const TDesC8& /*aMsg*/) {Panic(EMMFMdaAudioToneControllerBadMixinCall);}	
       
   107 	void SendEventToClient(const TMMFEvent& aEvent);
       
   108 	
       
   109 	//from MMMFAudioPlayControllerSetRepeatsCustomCommandImplementor
       
   110 	virtual TInt MapcSetRepeats(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds& aTrailingSilence);
       
   111 
       
   112 
       
   113 public:
       
   114 
       
   115 /**
       
   116  TControllerState is an enumeration within the namespace  CMMFAudioToneController
       
   117  The enumeration provides a set of control states:
       
   118  EStopped is the initial state the controller resides in after it has been loaded
       
   119  EPrimed is the state the controller is in when it has been associated with datapaths but is not streaming data
       
   120  EPlaying is the state the controller is in when it is streaming data
       
   121 */
       
   122 	enum TControllerState
       
   123 		{
       
   124 		EStopped,
       
   125 		EPrimed,
       
   126 		EPriming,
       
   127 		EPausePlaying,
       
   128 		EPlaying,
       
   129 		};
       
   130 
       
   131 protected:
       
   132 	CMMFAudioToneController();
       
   133 protected:
       
   134 	void ConstructL();
       
   135 	void NegotiateL();
       
   136 
       
   137 	// state accessor functions
       
   138 	TBool SetState( TControllerState aState );
       
   139 	TControllerState State() const ;
       
   140 	TBool            IsValidStateTransition( TControllerState aState ) const;
       
   141 	TBool            Invariant() const;
       
   142 	TBool            IsValidState( TControllerState aState ) const ;
       
   143 	TBool            ResetPostCondition() const;
       
   144 
       
   145 	void             CalculateLeftRightBalance( TInt& aLeft, TInt& aRight, TInt aBalance ) const;
       
   146 	void			 CalculateBalance( TInt& aBalance, TInt aLeft, TInt aRight ) const;
       
   147 
       
   148 
       
   149 	void Panic(TInt aPanicCode) const {User::Panic(KMMFAudioToneControllerPanicCategory, aPanicCode);}
       
   150 
       
   151 private:
       
   152 /** The data source provided by the Controller Framework, not owned (do not delete) */
       
   153 	MDataSource*             iDataSource;
       
   154 
       
   155 /** buffer that holds the data to be played */
       
   156 	CMMFDataBuffer*          iToneSequenceData;
       
   157 
       
   158 /** the Dev Sound that will be used to play the tone*/
       
   159 	CMMFDevSound*            iMMFDevSound;
       
   160 
       
   161 /** Current state of the controller, see TControllerState*/
       
   162 	TControllerState         iState;
       
   163 
       
   164 /** Priority setting used to controll access the Dev Sound*/	
       
   165 	TMMFPrioritySettings     iPrioritySettings;
       
   166 
       
   167 /** Indicates whether both a surce and data sink have been supplied by the Controller Framework*/
       
   168 	TBool                    iSourceAndSinkAdded;
       
   169 
       
   170 /** Indicates whether DevSound supports resume for current configuration*/
       
   171 	TBool                    iIsResumeSupported;
       
   172 
       
   173 /** Used to store message */	
       
   174 	TMMFMessage*			 iMessage;
       
   175 	};
       
   176 
       
   177 
       
   178 #endif