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 static void Init(JNIEnv* env); | |
| 24 | |
| 25 SpeechRecognizerImplAndroid(SpeechRecognitionEventListener* listener, | |
| 26 int session_id); | |
| 27 | |
| 28 // SpeechRecognizer methods | |
| 29 virtual void StartRecognition() OVERRIDE; | |
| 30 virtual void AbortRecognition() OVERRIDE; | |
| 31 virtual void StopAudioCapture() OVERRIDE; | |
| 32 virtual bool IsActive() const OVERRIDE; | |
| 33 virtual bool IsCapturingAudio() const OVERRIDE; | |
| 34 | |
| 35 // Called from Java methods via JNI | |
| 36 void OnAudioStartJNI(JNIEnv* env, jobject obj); | |
|
bulach
2013/06/07 15:35:10
remove the JNI suffix, we never use that.
janx
2013/06/10 16:51:18
Removed and refactored to single functions.
| |
| 37 void OnSoundStartJNI(JNIEnv* env, jobject obj); | |
| 38 void OnSoundEndJNI(JNIEnv* env, jobject obj); | |
| 39 void OnAudioEndJNI(JNIEnv* env, jobject obj); | |
| 40 void OnRecognitionResultsJNI(JNIEnv* env, jobject obj, jobjectArray strings, | |
| 41 jfloatArray floats, jboolean interim); | |
| 42 void OnRecognitionErrorJNI(JNIEnv* env, jobject obj, jint error); | |
| 43 void OnRecognitionEndJNI(JNIEnv* env, jobject obj); | |
| 44 | |
| 45 private: | |
| 46 enum State { | |
| 47 STATE_IDLE = 0, | |
| 48 STATE_CAPTURING_AUDIO, | |
| 49 STATE_AWAITING_FINAL_RESULT | |
| 50 }; | |
| 51 | |
| 52 virtual ~SpeechRecognizerImplAndroid(); | |
| 53 | |
| 54 // Calls to Java methods via JNI | |
| 55 void StartRecognitionJNI(bool continuous, bool interim_results); | |
| 56 void AbortRecognitionJNI(); | |
| 57 void StopRecognitionJNI(); | |
|
bulach
2013/06/07 15:35:10
ditto for the JNI suffix
janx
2013/06/10 16:51:18
Done.
| |
| 58 | |
| 59 // Wrappers for inbound JNI calls | |
| 60 void OnAudioStart(); | |
| 61 void OnSoundStart(); | |
| 62 void OnSoundEnd(); | |
| 63 void OnAudioEnd(); | |
| 64 void OnRecognitionResults(std::vector<string16> options, | |
| 65 std::vector<float> scores, bool provisional); | |
| 66 void OnRecognitionError(SpeechRecognitionError error); | |
| 67 void OnRecognitionEnd(); | |
| 68 | |
| 69 base::android::ScopedJavaGlobalRef<jobject> j_recognition_; | |
| 70 State state_; | |
| 71 | |
| 72 DISALLOW_COPY_AND_ASSIGN(SpeechRecognizerImplAndroid); | |
| 73 }; | |
| 74 | |
| 75 } // namespace content | |
| 76 | |
| 77 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_IMPL_ANDROID_H_ | |
| OLD | NEW |