Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_IMPL_ANDROID_H_ | |
| 6 #define CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_IMPL_ANDROID_H_ | |
| 7 | |
| 8 #include <jni.h> | |
| 9 | |
| 10 #include "base/android/scoped_java_ref.h" | |
| 11 #include "base/memory/ref_counted.h" | |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "content/browser/speech/speech_recognizer.h" | |
| 14 #include "content/public/common/speech_recognition_error.h" | |
| 15 #include "content/public/common/speech_recognition_result.h" | |
| 16 | |
| 17 namespace content { | |
| 18 | |
| 19 class SpeechRecognitionEventListener; | |
| 20 | |
| 21 class CONTENT_EXPORT SpeechRecognizerImplAndroid : public SpeechRecognizer { | |
| 22 public: | |
| 23 SpeechRecognizerImplAndroid(SpeechRecognitionEventListener* listener, | |
| 24 int session_id); | |
| 25 | |
| 26 // SpeechRecognizer methods | |
| 27 virtual void StartRecognition() OVERRIDE; | |
| 28 virtual void AbortRecognition() OVERRIDE; | |
| 29 virtual void StopAudioCapture() OVERRIDE; | |
| 30 virtual bool IsActive() const OVERRIDE; | |
| 31 virtual bool IsCapturingAudio() const OVERRIDE; | |
| 32 | |
| 33 // Called from Java methods via JNI | |
| 34 void OnAudioStart(JNIEnv* env, jobject obj); | |
| 35 void OnSoundStart(JNIEnv* env, jobject obj); | |
| 36 void OnSoundEnd(JNIEnv* env, jobject obj); | |
| 37 void OnAudioEnd(JNIEnv* env, jobject obj); | |
| 38 void OnRecognitionResults(JNIEnv* env, jobject obj, jobjectArray strings, | |
| 39 jfloatArray floats, jboolean interim); | |
| 40 void OnRecognitionError(JNIEnv* env, jobject obj, jint error); | |
| 41 void OnRecognitionEnd(JNIEnv* env, jobject obj); | |
| 42 | |
| 43 static bool RegisterSpeechRecognizer(JNIEnv* env); | |
| 44 | |
| 45 private: | |
| 46 enum State { | |
| 47 STATE_IDLE = 0, | |
| 48 STATE_CAPTURING_AUDIO, | |
| 49 STATE_AWAITING_FINAL_RESULT | |
| 50 }; | |
| 51 | |
| 52 void StartRecognitionOnUIThread(bool continuous, bool interim_results); | |
| 53 void OnRecognitionResultsOnIOThread(std::vector<string16> options, | |
| 54 std::vector<float> scores, | |
|
bulach
2013/06/11 07:24:48
vectors should be passed by const& rather than by
janx
2013/06/12 14:47:14
Moved creation of SpeechRecognitionResults object
| |
| 55 bool provisional); | |
| 56 | |
| 57 virtual ~SpeechRecognizerImplAndroid(); | |
| 58 | |
| 59 base::android::ScopedJavaGlobalRef<jobject> j_recognition_; | |
| 60 State state_; | |
| 61 | |
| 62 DISALLOW_COPY_AND_ASSIGN(SpeechRecognizerImplAndroid); | |
| 63 }; | |
| 64 | |
| 65 } // namespace content | |
| 66 | |
| 67 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_IMPL_ANDROID_H_ | |
| OLD | NEW |