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 19 matching lines...) Expand all Loading... |
30 | 30 |
31 // AudioRecordJni::JavaAudioRecord implementation. | 31 // AudioRecordJni::JavaAudioRecord implementation. |
32 AudioRecordJni::JavaAudioRecord::JavaAudioRecord( | 32 AudioRecordJni::JavaAudioRecord::JavaAudioRecord( |
33 NativeRegistration* native_reg, | 33 NativeRegistration* native_reg, |
34 std::unique_ptr<GlobalRef> audio_record) | 34 std::unique_ptr<GlobalRef> audio_record) |
35 : audio_record_(std::move(audio_record)), | 35 : audio_record_(std::move(audio_record)), |
36 init_recording_(native_reg->GetMethodId("initRecording", "(II)I")), | 36 init_recording_(native_reg->GetMethodId("initRecording", "(II)I")), |
37 start_recording_(native_reg->GetMethodId("startRecording", "()Z")), | 37 start_recording_(native_reg->GetMethodId("startRecording", "()Z")), |
38 stop_recording_(native_reg->GetMethodId("stopRecording", "()Z")), | 38 stop_recording_(native_reg->GetMethodId("stopRecording", "()Z")), |
39 enable_built_in_aec_(native_reg->GetMethodId("enableBuiltInAEC", "(Z)Z")), | 39 enable_built_in_aec_(native_reg->GetMethodId("enableBuiltInAEC", "(Z)Z")), |
40 enable_built_in_agc_(native_reg->GetMethodId("enableBuiltInAGC", "(Z)Z")), | |
41 enable_built_in_ns_(native_reg->GetMethodId("enableBuiltInNS", "(Z)Z")) {} | 40 enable_built_in_ns_(native_reg->GetMethodId("enableBuiltInNS", "(Z)Z")) {} |
42 | 41 |
43 AudioRecordJni::JavaAudioRecord::~JavaAudioRecord() {} | 42 AudioRecordJni::JavaAudioRecord::~JavaAudioRecord() {} |
44 | 43 |
45 int AudioRecordJni::JavaAudioRecord::InitRecording( | 44 int AudioRecordJni::JavaAudioRecord::InitRecording( |
46 int sample_rate, size_t channels) { | 45 int sample_rate, size_t channels) { |
47 return audio_record_->CallIntMethod(init_recording_, | 46 return audio_record_->CallIntMethod(init_recording_, |
48 static_cast<jint>(sample_rate), | 47 static_cast<jint>(sample_rate), |
49 static_cast<jint>(channels)); | 48 static_cast<jint>(channels)); |
50 } | 49 } |
51 | 50 |
52 bool AudioRecordJni::JavaAudioRecord::StartRecording() { | 51 bool AudioRecordJni::JavaAudioRecord::StartRecording() { |
53 return audio_record_->CallBooleanMethod(start_recording_); | 52 return audio_record_->CallBooleanMethod(start_recording_); |
54 } | 53 } |
55 | 54 |
56 bool AudioRecordJni::JavaAudioRecord::StopRecording() { | 55 bool AudioRecordJni::JavaAudioRecord::StopRecording() { |
57 return audio_record_->CallBooleanMethod(stop_recording_); | 56 return audio_record_->CallBooleanMethod(stop_recording_); |
58 } | 57 } |
59 | 58 |
60 bool AudioRecordJni::JavaAudioRecord::EnableBuiltInAEC(bool enable) { | 59 bool AudioRecordJni::JavaAudioRecord::EnableBuiltInAEC(bool enable) { |
61 return audio_record_->CallBooleanMethod(enable_built_in_aec_, | 60 return audio_record_->CallBooleanMethod(enable_built_in_aec_, |
62 static_cast<jboolean>(enable)); | 61 static_cast<jboolean>(enable)); |
63 } | 62 } |
64 | 63 |
65 bool AudioRecordJni::JavaAudioRecord::EnableBuiltInAGC(bool enable) { | |
66 return audio_record_->CallBooleanMethod(enable_built_in_agc_, | |
67 static_cast<jboolean>(enable)); | |
68 } | |
69 | |
70 bool AudioRecordJni::JavaAudioRecord::EnableBuiltInNS(bool enable) { | 64 bool AudioRecordJni::JavaAudioRecord::EnableBuiltInNS(bool enable) { |
71 return audio_record_->CallBooleanMethod(enable_built_in_ns_, | 65 return audio_record_->CallBooleanMethod(enable_built_in_ns_, |
72 static_cast<jboolean>(enable)); | 66 static_cast<jboolean>(enable)); |
73 } | 67 } |
74 | 68 |
75 // AudioRecordJni implementation. | 69 // AudioRecordJni implementation. |
76 AudioRecordJni::AudioRecordJni(AudioManager* audio_manager) | 70 AudioRecordJni::AudioRecordJni(AudioManager* audio_manager) |
77 : j_environment_(JVM::GetInstance()->environment()), | 71 : j_environment_(JVM::GetInstance()->environment()), |
78 audio_manager_(audio_manager), | 72 audio_manager_(audio_manager), |
79 audio_parameters_(audio_manager->GetRecordAudioParameters()), | 73 audio_parameters_(audio_manager->GetRecordAudioParameters()), |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 ALOGD("total_delay_in_milliseconds: %d", total_delay_in_milliseconds_); | 188 ALOGD("total_delay_in_milliseconds: %d", total_delay_in_milliseconds_); |
195 } | 189 } |
196 | 190 |
197 int32_t AudioRecordJni::EnableBuiltInAEC(bool enable) { | 191 int32_t AudioRecordJni::EnableBuiltInAEC(bool enable) { |
198 ALOGD("EnableBuiltInAEC%s", GetThreadInfo().c_str()); | 192 ALOGD("EnableBuiltInAEC%s", GetThreadInfo().c_str()); |
199 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 193 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
200 return j_audio_record_->EnableBuiltInAEC(enable) ? 0 : -1; | 194 return j_audio_record_->EnableBuiltInAEC(enable) ? 0 : -1; |
201 } | 195 } |
202 | 196 |
203 int32_t AudioRecordJni::EnableBuiltInAGC(bool enable) { | 197 int32_t AudioRecordJni::EnableBuiltInAGC(bool enable) { |
204 ALOGD("EnableBuiltInAGC%s", GetThreadInfo().c_str()); | 198 // TODO(henrika): possibly remove when no longer used by any client. |
205 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 199 FATAL() << "Should never be called"; |
206 return j_audio_record_->EnableBuiltInAGC(enable) ? 0 : -1; | 200 return -1; |
207 } | 201 } |
208 | 202 |
209 int32_t AudioRecordJni::EnableBuiltInNS(bool enable) { | 203 int32_t AudioRecordJni::EnableBuiltInNS(bool enable) { |
210 ALOGD("EnableBuiltInNS%s", GetThreadInfo().c_str()); | 204 ALOGD("EnableBuiltInNS%s", GetThreadInfo().c_str()); |
211 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 205 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
212 return j_audio_record_->EnableBuiltInNS(enable) ? 0 : -1; | 206 return j_audio_record_->EnableBuiltInNS(enable) ? 0 : -1; |
213 } | 207 } |
214 | 208 |
215 void JNICALL AudioRecordJni::CacheDirectBufferAddress( | 209 void JNICALL AudioRecordJni::CacheDirectBufferAddress( |
216 JNIEnv* env, jobject obj, jobject byte_buffer, jlong nativeAudioRecord) { | 210 JNIEnv* env, jobject obj, jobject byte_buffer, jlong nativeAudioRecord) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 // of |playDelayMs| and |recDelayMs|, hence the distributions does not matter. | 247 // of |playDelayMs| and |recDelayMs|, hence the distributions does not matter. |
254 audio_device_buffer_->SetVQEData(total_delay_in_milliseconds_, | 248 audio_device_buffer_->SetVQEData(total_delay_in_milliseconds_, |
255 0, // recDelayMs | 249 0, // recDelayMs |
256 0); // clockDrift | 250 0); // clockDrift |
257 if (audio_device_buffer_->DeliverRecordedData() == -1) { | 251 if (audio_device_buffer_->DeliverRecordedData() == -1) { |
258 ALOGE("AudioDeviceBuffer::DeliverRecordedData failed!"); | 252 ALOGE("AudioDeviceBuffer::DeliverRecordedData failed!"); |
259 } | 253 } |
260 } | 254 } |
261 | 255 |
262 } // namespace webrtc | 256 } // namespace webrtc |
OLD | NEW |