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