OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_RECORD_JNI_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_RECORD_JNI_H_ |
12 #define WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_RECORD_JNI_H_ | 12 #define WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_RECORD_JNI_H_ |
13 | 13 |
| 14 #include <memory> |
| 15 |
14 #include <jni.h> | 16 #include <jni.h> |
15 | 17 |
16 #include "webrtc/base/thread_checker.h" | 18 #include "webrtc/base/thread_checker.h" |
17 #include "webrtc/modules/audio_device/android/audio_manager.h" | 19 #include "webrtc/modules/audio_device/android/audio_manager.h" |
18 #include "webrtc/modules/audio_device/include/audio_device_defines.h" | 20 #include "webrtc/modules/audio_device/include/audio_device_defines.h" |
19 #include "webrtc/modules/audio_device/audio_device_generic.h" | 21 #include "webrtc/modules/audio_device/audio_device_generic.h" |
20 #include "webrtc/modules/utility/include/helpers_android.h" | 22 #include "webrtc/modules/utility/include/helpers_android.h" |
21 #include "webrtc/modules/utility/include/jvm_android.h" | 23 #include "webrtc/modules/utility/include/jvm_android.h" |
22 | 24 |
23 namespace webrtc { | 25 namespace webrtc { |
(...skipping 15 matching lines...) Expand all Loading... |
39 // | 41 // |
40 // This class uses AttachCurrentThreadIfNeeded to attach to a Java VM if needed | 42 // This class uses AttachCurrentThreadIfNeeded to attach to a Java VM if needed |
41 // and detach when the object goes out of scope. Additional thread checking | 43 // and detach when the object goes out of scope. Additional thread checking |
42 // guarantees that no other (possibly non attached) thread is used. | 44 // guarantees that no other (possibly non attached) thread is used. |
43 class AudioRecordJni { | 45 class AudioRecordJni { |
44 public: | 46 public: |
45 // Wraps the Java specific parts of the AudioRecordJni into one helper class. | 47 // Wraps the Java specific parts of the AudioRecordJni into one helper class. |
46 class JavaAudioRecord { | 48 class JavaAudioRecord { |
47 public: | 49 public: |
48 JavaAudioRecord(NativeRegistration* native_registration, | 50 JavaAudioRecord(NativeRegistration* native_registration, |
49 rtc::scoped_ptr<GlobalRef> audio_track); | 51 std::unique_ptr<GlobalRef> audio_track); |
50 ~JavaAudioRecord(); | 52 ~JavaAudioRecord(); |
51 | 53 |
52 int InitRecording(int sample_rate, size_t channels); | 54 int InitRecording(int sample_rate, size_t channels); |
53 bool StartRecording(); | 55 bool StartRecording(); |
54 bool StopRecording(); | 56 bool StopRecording(); |
55 bool EnableBuiltInAEC(bool enable); | 57 bool EnableBuiltInAEC(bool enable); |
56 bool EnableBuiltInAGC(bool enable); | 58 bool EnableBuiltInAGC(bool enable); |
57 bool EnableBuiltInNS(bool enable); | 59 bool EnableBuiltInNS(bool enable); |
58 | 60 |
59 private: | 61 private: |
60 rtc::scoped_ptr<GlobalRef> audio_record_; | 62 std::unique_ptr<GlobalRef> audio_record_; |
61 jmethodID init_recording_; | 63 jmethodID init_recording_; |
62 jmethodID start_recording_; | 64 jmethodID start_recording_; |
63 jmethodID stop_recording_; | 65 jmethodID stop_recording_; |
64 jmethodID enable_built_in_aec_; | 66 jmethodID enable_built_in_aec_; |
65 jmethodID enable_built_in_agc_; | 67 jmethodID enable_built_in_agc_; |
66 jmethodID enable_built_in_ns_; | 68 jmethodID enable_built_in_ns_; |
67 }; | 69 }; |
68 | 70 |
69 explicit AudioRecordJni(AudioManager* audio_manager); | 71 explicit AudioRecordJni(AudioManager* audio_manager); |
70 ~AudioRecordJni(); | 72 ~AudioRecordJni(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 | 112 |
111 // Stores thread ID in first call to OnDataIsRecorded() from high-priority | 113 // Stores thread ID in first call to OnDataIsRecorded() from high-priority |
112 // thread in Java. Detached during construction of this object. | 114 // thread in Java. Detached during construction of this object. |
113 rtc::ThreadChecker thread_checker_java_; | 115 rtc::ThreadChecker thread_checker_java_; |
114 | 116 |
115 // Calls AttachCurrentThread() if this thread is not attached at construction. | 117 // Calls AttachCurrentThread() if this thread is not attached at construction. |
116 // Also ensures that DetachCurrentThread() is called at destruction. | 118 // Also ensures that DetachCurrentThread() is called at destruction. |
117 AttachCurrentThreadIfNeeded attach_thread_if_needed_; | 119 AttachCurrentThreadIfNeeded attach_thread_if_needed_; |
118 | 120 |
119 // Wraps the JNI interface pointer and methods associated with it. | 121 // Wraps the JNI interface pointer and methods associated with it. |
120 rtc::scoped_ptr<JNIEnvironment> j_environment_; | 122 std::unique_ptr<JNIEnvironment> j_environment_; |
121 | 123 |
122 // Contains factory method for creating the Java object. | 124 // Contains factory method for creating the Java object. |
123 rtc::scoped_ptr<NativeRegistration> j_native_registration_; | 125 std::unique_ptr<NativeRegistration> j_native_registration_; |
124 | 126 |
125 // Wraps the Java specific parts of the AudioRecordJni class. | 127 // Wraps the Java specific parts of the AudioRecordJni class. |
126 rtc::scoped_ptr<AudioRecordJni::JavaAudioRecord> j_audio_record_; | 128 std::unique_ptr<AudioRecordJni::JavaAudioRecord> j_audio_record_; |
127 | 129 |
128 // Raw pointer to the audio manger. | 130 // Raw pointer to the audio manger. |
129 const AudioManager* audio_manager_; | 131 const AudioManager* audio_manager_; |
130 | 132 |
131 // Contains audio parameters provided to this class at construction by the | 133 // Contains audio parameters provided to this class at construction by the |
132 // AudioManager. | 134 // AudioManager. |
133 const AudioParameters audio_parameters_; | 135 const AudioParameters audio_parameters_; |
134 | 136 |
135 // Delay estimate of the total round-trip delay (input + output). | 137 // Delay estimate of the total round-trip delay (input + output). |
136 // Fixed value set once in AttachAudioBuffer() and it can take one out of two | 138 // Fixed value set once in AttachAudioBuffer() and it can take one out of two |
(...skipping 17 matching lines...) Expand all Loading... |
154 bool recording_; | 156 bool recording_; |
155 | 157 |
156 // Raw pointer handle provided to us in AttachAudioBuffer(). Owned by the | 158 // Raw pointer handle provided to us in AttachAudioBuffer(). Owned by the |
157 // AudioDeviceModuleImpl class and called by AudioDeviceModuleImpl::Create(). | 159 // AudioDeviceModuleImpl class and called by AudioDeviceModuleImpl::Create(). |
158 AudioDeviceBuffer* audio_device_buffer_; | 160 AudioDeviceBuffer* audio_device_buffer_; |
159 }; | 161 }; |
160 | 162 |
161 } // namespace webrtc | 163 } // namespace webrtc |
162 | 164 |
163 #endif // WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_RECORD_JNI_H_ | 165 #endif // WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_RECORD_JNI_H_ |
OLD | NEW |