Chromium Code Reviews| Index: content/browser/speech/speech_recognizer_impl_android.h |
| diff --git a/content/browser/speech/speech_recognizer_impl_android.h b/content/browser/speech/speech_recognizer_impl_android.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..040d354eb26aa775737981d65ed60617aaa16504 |
| --- /dev/null |
| +++ b/content/browser/speech/speech_recognizer_impl_android.h |
| @@ -0,0 +1,77 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_IMPL_ANDROID_H_ |
| +#define CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_IMPL_ANDROID_H_ |
| + |
| +#include <jni.h> |
| + |
| +#include "base/android/scoped_java_ref.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "content/browser/speech/speech_recognizer.h" |
| +#include "content/public/common/speech_recognition_error.h" |
| +#include "content/public/common/speech_recognition_result.h" |
| + |
| +namespace content { |
| + |
| +class SpeechRecognitionEventListener; |
| + |
| +class CONTENT_EXPORT SpeechRecognizerImplAndroid : public SpeechRecognizer { |
| + public: |
| + static void Init(JNIEnv* env); |
| + |
| + SpeechRecognizerImplAndroid(SpeechRecognitionEventListener* listener, |
| + int session_id); |
| + |
| + // SpeechRecognizer methods |
| + virtual void StartRecognition() OVERRIDE; |
| + virtual void AbortRecognition() OVERRIDE; |
| + virtual void StopAudioCapture() OVERRIDE; |
| + virtual bool IsActive() const OVERRIDE; |
| + virtual bool IsCapturingAudio() const OVERRIDE; |
| + |
| + // Called from Java methods via JNI |
| + 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.
|
| + void OnSoundStartJNI(JNIEnv* env, jobject obj); |
| + void OnSoundEndJNI(JNIEnv* env, jobject obj); |
| + void OnAudioEndJNI(JNIEnv* env, jobject obj); |
| + void OnRecognitionResultsJNI(JNIEnv* env, jobject obj, jobjectArray strings, |
| + jfloatArray floats, jboolean interim); |
| + void OnRecognitionErrorJNI(JNIEnv* env, jobject obj, jint error); |
| + void OnRecognitionEndJNI(JNIEnv* env, jobject obj); |
| + |
| + private: |
| + enum State { |
| + STATE_IDLE = 0, |
| + STATE_CAPTURING_AUDIO, |
| + STATE_AWAITING_FINAL_RESULT |
| + }; |
| + |
| + virtual ~SpeechRecognizerImplAndroid(); |
| + |
| + // Calls to Java methods via JNI |
| + void StartRecognitionJNI(bool continuous, bool interim_results); |
| + void AbortRecognitionJNI(); |
| + void StopRecognitionJNI(); |
|
bulach
2013/06/07 15:35:10
ditto for the JNI suffix
janx
2013/06/10 16:51:18
Done.
|
| + |
| + // Wrappers for inbound JNI calls |
| + void OnAudioStart(); |
| + void OnSoundStart(); |
| + void OnSoundEnd(); |
| + void OnAudioEnd(); |
| + void OnRecognitionResults(std::vector<string16> options, |
| + std::vector<float> scores, bool provisional); |
| + void OnRecognitionError(SpeechRecognitionError error); |
| + void OnRecognitionEnd(); |
| + |
| + base::android::ScopedJavaGlobalRef<jobject> j_recognition_; |
| + State state_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(SpeechRecognizerImplAndroid); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_IMPL_ANDROID_H_ |