os/mm/mmdevicefw/speechrecogsupport/tsrc/ASR/src/ASRController/CustomMmfASRController.h
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmdevicefw/speechrecogsupport/tsrc/ASR/src/ASRController/CustomMmfASRController.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,150 @@
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 +#ifndef __TEST_MMF_CUSTOM_MMF_ASR_CONTROLLER_H__
1.20 +#define __TEST_MMF_CUSTOM_MMF_ASR_CONTROLLER_H__
1.21 +
1.22 +//include all the header files for now
1.23 +//
1.24 +#include <mmf/common/speechrecognitioncustomcommands.h>
1.25 +#include <mmf/common/speechrecognitiondataclient.h>
1.26 +#include <mmf/common/speechrecognitioncustomcommandimplementor.h>
1.27 +#include <mmf/common/speechrecognitioncustomcommands.h>
1.28 +#include <mmf/common/speechrecognitioncustomcommandparser.h>
1.29 +
1.30 +#include <speechrecognitionutility.h>
1.31 +
1.32 +#include "Database/sddatabase.h"
1.33 +
1.34 +
1.35 +// custom asr controller plugin class
1.36 +class CCustomMmfASRController: public CMMFController,
1.37 + public MAsyncEventHandler,
1.38 + public MSpeechRecognitionCustomCommandImplementor
1.39 +
1.40 + {
1.41 +public:
1.42 + static CMMFController* NewL() ;
1.43 + ~CCustomMmfASRController();
1.44 +
1.45 + //implement CMMFController ecom plugin interface
1.46 + virtual void AddDataSourceL(MDataSource& aDataSource);
1.47 + virtual void AddDataSinkL(MDataSink& aDataSink);
1.48 + virtual void RemoveDataSourceL(MDataSource& aDataSource);
1.49 + virtual void RemoveDataSinkL(MDataSink& aDataSink);
1.50 + virtual void ResetL();
1.51 + virtual void PrimeL();
1.52 + virtual void PlayL();
1.53 + virtual void PauseL();
1.54 + virtual void StopL();
1.55 + virtual TTimeIntervalMicroSeconds PositionL() const;
1.56 + virtual void SetPositionL(const TTimeIntervalMicroSeconds& aPosition);
1.57 + virtual TTimeIntervalMicroSeconds DurationL() const;
1.58 + virtual void CustomCommand(TMMFMessage& aMessage);
1.59 + virtual void SetPrioritySettings(const TMMFPrioritySettings& aPrioritySettings);
1.60 + virtual void GetNumberOfMetaDataEntriesL(TInt& aNumberOfEntries) ;
1.61 + virtual CMMFMetaDataEntry* GetMetaDataEntryL(TInt aIndex) ;
1.62 +
1.63 + //from MAsyncEventHandler
1.64 + virtual TInt SendEventToClient(const TMMFEvent& aEvent);
1.65 +
1.66 + //
1.67 + virtual void MSrAddPronunciationL( TLexiconID aLexiconID, TModelBankID aModelBankID,
1.68 + TModelID aModelID, TPronunciationID& aPronunciationID ) ;
1.69 + virtual void MSrAddRuleL( TGrammarID aGrammarID, TLexiconID aLexiconID,
1.70 + TPronunciationID aPronunciationID, TRuleID& aRuleID );
1.71 + virtual void MSrCancel() ;
1.72 + virtual void MSrCommitChangesL() ;
1.73 + virtual void MSrCreateGrammarL( TGrammarID& aGrammarID ) ;
1.74 + virtual void MSrCreateLexiconL( TLexiconID& aLexiconID ) ;
1.75 + virtual void MSrCreateModelBankL( TModelBankID& aModelBankID ) ;
1.76 + virtual void MSrEndRecSessionL() ;
1.77 + virtual void MSrGetAllModelIDsL( TModelBankID aModelBankID, RArray<TModelID>& aModelIDs ) ;
1.78 + virtual void MSrGetAllPronunciationIDsL( TLexiconID aLexiconID, RArray<TPronunciationID>& aPronunciationIDs ) ;
1.79 + virtual void MSrGetAllRuleIDsL( TGrammarID aGrammarID, RArray<TRuleID>& aRuleIDs ) ;
1.80 +
1.81 + virtual void MSrGetAllModelBankIDsL( RArray<TModelBankID>& aModelBankIDs ) ;
1.82 + virtual void MSrGetAllLexiconIDsL( RArray<TLexiconID>& aLexiconIDs ) ;
1.83 + virtual void MSrGetAllGrammarIDsL( RArray<TGrammarID>& aGrammarIDs ) ;
1.84 +
1.85 + virtual void MSrGetAllClientModelBankIDsL( RArray<TModelBankID>& aModelBankIDs ) ;
1.86 + virtual void MSrGetAllClientLexiconIDsL( RArray<TLexiconID>& aLexiconIDs ) ;
1.87 + virtual void MSrGetAllClientGrammarIDsL( RArray<TGrammarID>& aGrammarIDs ) ;
1.88 +
1.89 + virtual void MSrGetAvailableStorageL( TInt& aCount ) ;
1.90 + virtual void MSrGetEnginePropertiesL( const RArray<TInt>& aPropertyId,
1.91 + RArray<TInt>& aPropertyValue) ;
1.92 + virtual void MSrLoadEngineParametersL( const RArray<TInt>& aParameterId,
1.93 + const RArray<TInt>& aParameterValue );
1.94 + virtual void MSrGetModelCountL( TModelBankID aModelBankID, TInt& aCount ) ;
1.95 + virtual void MSrGetRuleValidityL( TGrammarID aGrammarID, TRuleID aRuleID, TBool& aValid ) ;
1.96 + virtual void MSrGetUtteranceDurationL( TModelBankID aModelBankID, TModelID aModelID,
1.97 + TTimeIntervalMicroSeconds32& aDuration) ;
1.98 + virtual void MSrLoadGrammarL( TGrammarID aGrammarID ) ;
1.99 + virtual void MSrLoadLexiconL( TLexiconID aLexiconID ) ;
1.100 + virtual void MSrLoadModelsL( TModelBankID aModelBankID ) ;
1.101 + virtual void MSrPlayUtteranceL( TModelBankID aModelBankID, TModelID aModelID) ;
1.102 + virtual void MSrRecognizeL( CSDClientResultSet& aResultSet ) ;
1.103 + virtual void MSrRecordL( TTimeIntervalMicroSeconds32 aRecordTime ) ;
1.104 + virtual void MSrRemoveGrammarL( TGrammarID aGrammarID ) ;
1.105 + virtual void MSrRemoveLexiconL( TLexiconID aLexiconID ) ;
1.106 + virtual void MSrRemoveModelBankL( TModelBankID aModelBankID );
1.107 + virtual void MSrRemoveModelL( TModelBankID aModelBankID, TModelID aModelID );
1.108 + virtual void MSrRemovePronunciationL( TLexiconID aLexiconID, TPronunciationID aPronunciationID );
1.109 + virtual void MSrRemoveRuleL( TGrammarID aGrammarID, TRuleID aRuleID );
1.110 + virtual void MSrStartRecSessionL( TRecognitionMode aMode );
1.111 + virtual void MSrTrainL( TModelBankID aModelBankID, TModelID& aModelID );
1.112 + virtual void MSrUnloadRuleL( TGrammarID aGrammarID, TRuleID aRuleID );
1.113 + virtual void MSrSetClientUid(TUid aClientUid);
1.114 +
1.115 +public:
1.116 +
1.117 + enum TControllerState
1.118 + {
1.119 + ESTraining,
1.120 + ESRecognition
1.121 + };
1.122 +
1.123 +private:
1.124 + TBool IsMemoryAllocCmd(TMMFMessage& aMessage );
1.125 + TInt AllocMemoryTestL();
1.126 +
1.127 + //[ state access functions ]
1.128 + TControllerState State() const;
1.129 + void SetState( TControllerState aState );
1.130 +
1.131 + //[ Invariant function ]
1.132 + TBool InVariant() const;
1.133 +protected:
1.134 + CCustomMmfASRController();
1.135 + void ConstructL();
1.136 +
1.137 +private:
1.138 + TControllerState iState; // main state of the controller
1.139 + TRecognitionMode iRecognitionMode; // recognition mode the controller is in
1.140 + TTimeIntervalMicroSeconds32 iRecordTime; // the duration of the recording for both recognition and trainning
1.141 +
1.142 + TGrammarID iLoadedGrammarID;
1.143 + TLexiconID iLoadedLexiconID;
1.144 + TModelBankID iLoadedModelBankID;
1.145 +
1.146 + CSDClientResultSet* iResultSet; // data structure containing the result set
1.147 + TInt iMaxResults; // maximum number of results
1.148 +
1.149 + TBool iRecognizeComplete; //a flag to rememeber that we are in recognize mode
1.150 + CSDDatabase* iDatabase;
1.151 + };
1.152 +
1.153 +#endif