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 |
(...skipping 12 matching lines...) Expand all Loading... |
23 #define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__) | 23 #define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__) |
24 #define ALOGW(...) __android_log_print(ANDROID_LOG_WARN, TAG, __VA_ARGS__) | 24 #define ALOGW(...) __android_log_print(ANDROID_LOG_WARN, TAG, __VA_ARGS__) |
25 #define ALOGI(...) __android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__) | 25 #define ALOGI(...) __android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__) |
26 | 26 |
27 namespace webrtc { | 27 namespace webrtc { |
28 | 28 |
29 // AudioRecordJni::JavaAudioRecord implementation. | 29 // AudioRecordJni::JavaAudioRecord implementation. |
30 AudioRecordJni::JavaAudioRecord::JavaAudioRecord( | 30 AudioRecordJni::JavaAudioRecord::JavaAudioRecord( |
31 NativeRegistration* native_reg, rtc::scoped_ptr<GlobalRef> audio_record) | 31 NativeRegistration* native_reg, rtc::scoped_ptr<GlobalRef> audio_record) |
32 : audio_record_(audio_record.Pass()), | 32 : audio_record_(audio_record.Pass()), |
33 init_recording_(native_reg->GetMethodId("InitRecording", "(II)I")), | 33 init_recording_(native_reg->GetMethodId("initRecording", "(II)I")), |
34 start_recording_(native_reg->GetMethodId("StartRecording", "()Z")), | 34 start_recording_(native_reg->GetMethodId("startRecording", "()Z")), |
35 stop_recording_(native_reg->GetMethodId("StopRecording", "()Z")), | 35 stop_recording_(native_reg->GetMethodId("stopRecording", "()Z")), |
36 enable_built_in_aec_(native_reg->GetMethodId( | 36 enable_built_in_aec_(native_reg->GetMethodId( |
37 "EnableBuiltInAEC", "(Z)Z")) { | 37 "enableBuiltInAEC", "(Z)Z")), |
| 38 enable_built_in_agc_(native_reg->GetMethodId( |
| 39 "enableBuiltInAGC", "(Z)Z")), |
| 40 enable_built_in_ns_(native_reg->GetMethodId( |
| 41 "enableBuiltInNS", "(Z)Z")) { |
38 } | 42 } |
39 | 43 |
40 AudioRecordJni::JavaAudioRecord::~JavaAudioRecord() {} | 44 AudioRecordJni::JavaAudioRecord::~JavaAudioRecord() {} |
41 | 45 |
42 int AudioRecordJni::JavaAudioRecord::InitRecording( | 46 int AudioRecordJni::JavaAudioRecord::InitRecording( |
43 int sample_rate, int channels) { | 47 int sample_rate, int channels) { |
44 return audio_record_->CallIntMethod(init_recording_, | 48 return audio_record_->CallIntMethod(init_recording_, |
45 static_cast<jint>(sample_rate), | 49 static_cast<jint>(sample_rate), |
46 static_cast<jint>(channels)); | 50 static_cast<jint>(channels)); |
47 } | 51 } |
48 | 52 |
49 bool AudioRecordJni::JavaAudioRecord::StartRecording() { | 53 bool AudioRecordJni::JavaAudioRecord::StartRecording() { |
50 return audio_record_->CallBooleanMethod(start_recording_); | 54 return audio_record_->CallBooleanMethod(start_recording_); |
51 } | 55 } |
52 | 56 |
53 bool AudioRecordJni::JavaAudioRecord::StopRecording() { | 57 bool AudioRecordJni::JavaAudioRecord::StopRecording() { |
54 return audio_record_->CallBooleanMethod(stop_recording_); | 58 return audio_record_->CallBooleanMethod(stop_recording_); |
55 } | 59 } |
56 | 60 |
57 bool AudioRecordJni::JavaAudioRecord::EnableBuiltInAEC(bool enable) { | 61 bool AudioRecordJni::JavaAudioRecord::EnableBuiltInAEC(bool enable) { |
58 return audio_record_->CallBooleanMethod(enable_built_in_aec_, | 62 return audio_record_->CallBooleanMethod(enable_built_in_aec_, |
59 static_cast<jboolean>(enable)); | 63 static_cast<jboolean>(enable)); |
60 } | 64 } |
61 | 65 |
| 66 bool AudioRecordJni::JavaAudioRecord::EnableBuiltInAGC(bool enable) { |
| 67 return audio_record_->CallBooleanMethod(enable_built_in_agc_, |
| 68 static_cast<jboolean>(enable)); |
| 69 } |
| 70 |
| 71 bool AudioRecordJni::JavaAudioRecord::EnableBuiltInNS(bool enable) { |
| 72 return audio_record_->CallBooleanMethod(enable_built_in_ns_, |
| 73 static_cast<jboolean>(enable)); |
| 74 } |
| 75 |
62 // AudioRecordJni implementation. | 76 // AudioRecordJni implementation. |
63 AudioRecordJni::AudioRecordJni(AudioManager* audio_manager) | 77 AudioRecordJni::AudioRecordJni(AudioManager* audio_manager) |
64 : j_environment_(JVM::GetInstance()->environment()), | 78 : j_environment_(JVM::GetInstance()->environment()), |
65 audio_manager_(audio_manager), | 79 audio_manager_(audio_manager), |
66 audio_parameters_(audio_manager->GetRecordAudioParameters()), | 80 audio_parameters_(audio_manager->GetRecordAudioParameters()), |
67 total_delay_in_milliseconds_(0), | 81 total_delay_in_milliseconds_(0), |
68 direct_buffer_address_(nullptr), | 82 direct_buffer_address_(nullptr), |
69 direct_buffer_capacity_in_bytes_(0), | 83 direct_buffer_capacity_in_bytes_(0), |
70 frames_per_buffer_(0), | 84 frames_per_buffer_(0), |
71 initialized_(false), | 85 initialized_(false), |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 RTC_DCHECK_GT(total_delay_in_milliseconds_, 0); | 193 RTC_DCHECK_GT(total_delay_in_milliseconds_, 0); |
180 ALOGD("total_delay_in_milliseconds: %d", total_delay_in_milliseconds_); | 194 ALOGD("total_delay_in_milliseconds: %d", total_delay_in_milliseconds_); |
181 } | 195 } |
182 | 196 |
183 int32_t AudioRecordJni::EnableBuiltInAEC(bool enable) { | 197 int32_t AudioRecordJni::EnableBuiltInAEC(bool enable) { |
184 ALOGD("EnableBuiltInAEC%s", GetThreadInfo().c_str()); | 198 ALOGD("EnableBuiltInAEC%s", GetThreadInfo().c_str()); |
185 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 199 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
186 return j_audio_record_->EnableBuiltInAEC(enable) ? 0 : -1; | 200 return j_audio_record_->EnableBuiltInAEC(enable) ? 0 : -1; |
187 } | 201 } |
188 | 202 |
| 203 int32_t AudioRecordJni::EnableBuiltInAGC(bool enable) { |
| 204 ALOGD("EnableBuiltInAGC%s", GetThreadInfo().c_str()); |
| 205 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 206 return j_audio_record_->EnableBuiltInAGC(enable) ? 0 : -1; |
| 207 } |
| 208 |
| 209 int32_t AudioRecordJni::EnableBuiltInNS(bool enable) { |
| 210 ALOGD("EnableBuiltInNS%s", GetThreadInfo().c_str()); |
| 211 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 212 return j_audio_record_->EnableBuiltInNS(enable) ? 0 : -1; |
| 213 } |
| 214 |
189 void JNICALL AudioRecordJni::CacheDirectBufferAddress( | 215 void JNICALL AudioRecordJni::CacheDirectBufferAddress( |
190 JNIEnv* env, jobject obj, jobject byte_buffer, jlong nativeAudioRecord) { | 216 JNIEnv* env, jobject obj, jobject byte_buffer, jlong nativeAudioRecord) { |
191 webrtc::AudioRecordJni* this_object = | 217 webrtc::AudioRecordJni* this_object = |
192 reinterpret_cast<webrtc::AudioRecordJni*> (nativeAudioRecord); | 218 reinterpret_cast<webrtc::AudioRecordJni*> (nativeAudioRecord); |
193 this_object->OnCacheDirectBufferAddress(env, byte_buffer); | 219 this_object->OnCacheDirectBufferAddress(env, byte_buffer); |
194 } | 220 } |
195 | 221 |
196 void AudioRecordJni::OnCacheDirectBufferAddress( | 222 void AudioRecordJni::OnCacheDirectBufferAddress( |
197 JNIEnv* env, jobject byte_buffer) { | 223 JNIEnv* env, jobject byte_buffer) { |
198 ALOGD("OnCacheDirectBufferAddress"); | 224 ALOGD("OnCacheDirectBufferAddress"); |
(...skipping 28 matching lines...) Expand all Loading... |
227 // of |playDelayMs| and |recDelayMs|, hence the distributions does not matter. | 253 // of |playDelayMs| and |recDelayMs|, hence the distributions does not matter. |
228 audio_device_buffer_->SetVQEData(total_delay_in_milliseconds_, | 254 audio_device_buffer_->SetVQEData(total_delay_in_milliseconds_, |
229 0, // recDelayMs | 255 0, // recDelayMs |
230 0); // clockDrift | 256 0); // clockDrift |
231 if (audio_device_buffer_->DeliverRecordedData() == -1) { | 257 if (audio_device_buffer_->DeliverRecordedData() == -1) { |
232 ALOGE("AudioDeviceBuffer::DeliverRecordedData failed!"); | 258 ALOGE("AudioDeviceBuffer::DeliverRecordedData failed!"); |
233 } | 259 } |
234 } | 260 } |
235 | 261 |
236 } // namespace webrtc | 262 } // namespace webrtc |
OLD | NEW |