os/mm/mmdevicefw/speechrecogsupport/tsrc/ASR/src/ASRController/CustomMmfASRController.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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 __TEST_MMF_CUSTOM_MMF_ASR_CONTROLLER_H__
    17 #define __TEST_MMF_CUSTOM_MMF_ASR_CONTROLLER_H__
    18 
    19 //include all the header files for now
    20 //
    21 #include <mmf/common/speechrecognitioncustomcommands.h>
    22 #include <mmf/common/speechrecognitiondataclient.h>
    23 #include <mmf/common/speechrecognitioncustomcommandimplementor.h>
    24 #include <mmf/common/speechrecognitioncustomcommands.h>
    25 #include <mmf/common/speechrecognitioncustomcommandparser.h>
    26 
    27 #include <speechrecognitionutility.h>
    28 
    29 #include "Database/sddatabase.h"
    30 
    31 
    32 // custom asr controller plugin class
    33 class CCustomMmfASRController:	public CMMFController, 
    34 								public MAsyncEventHandler,			
    35 								public MSpeechRecognitionCustomCommandImplementor
    36 
    37 	{
    38 public:
    39 	static CMMFController* NewL() ;
    40           ~CCustomMmfASRController();
    41 
    42 	//implement CMMFController ecom plugin interface
    43 	virtual void AddDataSourceL(MDataSource& aDataSource);
    44 	virtual void AddDataSinkL(MDataSink& aDataSink);
    45 	virtual void RemoveDataSourceL(MDataSource& aDataSource);
    46 	virtual void RemoveDataSinkL(MDataSink& aDataSink);
    47 	virtual void ResetL();
    48 	virtual void PrimeL();
    49 	virtual void PlayL();
    50 	virtual void PauseL();
    51 	virtual void StopL();
    52 	virtual TTimeIntervalMicroSeconds PositionL() const;
    53 	virtual void SetPositionL(const TTimeIntervalMicroSeconds& aPosition);
    54 	virtual TTimeIntervalMicroSeconds DurationL() const;
    55 	virtual void CustomCommand(TMMFMessage& aMessage);
    56 	virtual void SetPrioritySettings(const TMMFPrioritySettings& aPrioritySettings);
    57 	virtual void GetNumberOfMetaDataEntriesL(TInt& aNumberOfEntries) ;
    58 	virtual CMMFMetaDataEntry* GetMetaDataEntryL(TInt aIndex) ;
    59 
    60 	//from MAsyncEventHandler
    61 	virtual TInt SendEventToClient(const TMMFEvent& aEvent);
    62 
    63 	//
    64 	virtual void MSrAddPronunciationL( TLexiconID aLexiconID, TModelBankID aModelBankID,
    65 										  TModelID aModelID, TPronunciationID& aPronunciationID ) ;
    66 	virtual void MSrAddRuleL( TGrammarID aGrammarID, TLexiconID aLexiconID,
    67 								 TPronunciationID aPronunciationID, TRuleID& aRuleID );
    68 	virtual void MSrCancel() ;
    69 	virtual void MSrCommitChangesL() ;
    70 	virtual void MSrCreateGrammarL( TGrammarID& aGrammarID ) ;
    71 	virtual void MSrCreateLexiconL( TLexiconID& aLexiconID ) ;
    72 	virtual void MSrCreateModelBankL( TModelBankID& aModelBankID ) ;
    73 	virtual void MSrEndRecSessionL() ;
    74 	virtual void MSrGetAllModelIDsL( TModelBankID aModelBankID, RArray<TModelID>& aModelIDs ) ;
    75 	virtual void MSrGetAllPronunciationIDsL( TLexiconID aLexiconID, RArray<TPronunciationID>& aPronunciationIDs ) ;
    76 	virtual void MSrGetAllRuleIDsL( TGrammarID aGrammarID, RArray<TRuleID>& aRuleIDs ) ;
    77 	
    78 	virtual void MSrGetAllModelBankIDsL( RArray<TModelBankID>& aModelBankIDs ) ;
    79 	virtual void MSrGetAllLexiconIDsL( RArray<TLexiconID>& aLexiconIDs ) ;
    80 	virtual void MSrGetAllGrammarIDsL( RArray<TGrammarID>& aGrammarIDs ) ;
    81 
    82 	virtual void MSrGetAllClientModelBankIDsL( RArray<TModelBankID>& aModelBankIDs ) ;
    83 	virtual void MSrGetAllClientLexiconIDsL( RArray<TLexiconID>& aLexiconIDs ) ;
    84 	virtual void MSrGetAllClientGrammarIDsL( RArray<TGrammarID>& aGrammarIDs ) ;
    85 
    86 	virtual void MSrGetAvailableStorageL( TInt& aCount ) ;
    87 	virtual void MSrGetEnginePropertiesL(  const RArray<TInt>& aPropertyId, 
    88 						RArray<TInt>& aPropertyValue) ;
    89 	virtual void MSrLoadEngineParametersL( const RArray<TInt>& aParameterId, 
    90 						const RArray<TInt>& aParameterValue );
    91 	virtual void MSrGetModelCountL( TModelBankID aModelBankID, TInt& aCount ) ;
    92 	virtual void MSrGetRuleValidityL( TGrammarID aGrammarID, TRuleID aRuleID, TBool& aValid ) ;
    93 	virtual void MSrGetUtteranceDurationL( TModelBankID aModelBankID, TModelID aModelID,
    94 											   TTimeIntervalMicroSeconds32& aDuration) ;
    95 	virtual void MSrLoadGrammarL( TGrammarID aGrammarID ) ;
    96 	virtual void MSrLoadLexiconL( TLexiconID aLexiconID ) ;
    97 	virtual void MSrLoadModelsL( TModelBankID aModelBankID ) ;
    98 	virtual void MSrPlayUtteranceL( TModelBankID aModelBankID, TModelID aModelID) ;
    99 	virtual void MSrRecognizeL( CSDClientResultSet& aResultSet ) ;
   100 	virtual void MSrRecordL( TTimeIntervalMicroSeconds32 aRecordTime ) ;
   101 	virtual void MSrRemoveGrammarL( TGrammarID aGrammarID ) ;
   102 	virtual void MSrRemoveLexiconL( TLexiconID aLexiconID ) ;
   103 	virtual void MSrRemoveModelBankL( TModelBankID aModelBankID );
   104 	virtual void MSrRemoveModelL( TModelBankID aModelBankID, TModelID aModelID );
   105 	virtual void MSrRemovePronunciationL( TLexiconID aLexiconID, TPronunciationID aPronunciationID );
   106 	virtual void MSrRemoveRuleL( TGrammarID aGrammarID, TRuleID aRuleID );
   107 	virtual void MSrStartRecSessionL( TRecognitionMode aMode );
   108 	virtual void MSrTrainL( TModelBankID aModelBankID, TModelID& aModelID );
   109 	virtual void MSrUnloadRuleL( TGrammarID aGrammarID, TRuleID aRuleID );
   110 	virtual void MSrSetClientUid(TUid aClientUid);
   111 	
   112 public:
   113 	
   114 	enum TControllerState
   115 	{
   116 	ESTraining,
   117 	ESRecognition
   118 	};
   119 
   120 private:
   121 	TBool IsMemoryAllocCmd(TMMFMessage& aMessage );
   122 	TInt  AllocMemoryTestL();
   123 
   124 	//[ state access functions ]
   125 	TControllerState State() const;
   126 	void SetState( TControllerState aState );
   127 	
   128 	//[ Invariant function ]
   129 	TBool InVariant() const;
   130 protected:
   131      CCustomMmfASRController();
   132 	 void ConstructL();
   133 	 
   134 private:
   135 	TControllerState iState;    // main state of the controller
   136 	TRecognitionMode iRecognitionMode; // recognition mode the controller is in
   137 	TTimeIntervalMicroSeconds32	iRecordTime; // the duration of the recording for both recognition and trainning
   138 
   139 	TGrammarID iLoadedGrammarID;
   140 	TLexiconID iLoadedLexiconID;
   141 	TModelBankID iLoadedModelBankID;
   142 	
   143 	CSDClientResultSet* iResultSet; // data structure containing the result set
   144 	TInt iMaxResults;				// maximum number of results
   145 
   146 	TBool iRecognizeComplete;  //a flag to rememeber that we are in recognize mode
   147 	CSDDatabase* iDatabase;
   148 	};
   149 
   150 #endif