| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/media/webrtc_audio_device_impl.h" | 5 #include "content/renderer/media/webrtc_audio_device_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/win/windows_version.h" | 10 #include "base/win/windows_version.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 } // namespace | 29 } // namespace |
| 30 | 30 |
| 31 WebRtcAudioDeviceImpl::WebRtcAudioDeviceImpl() | 31 WebRtcAudioDeviceImpl::WebRtcAudioDeviceImpl() |
| 32 : ref_count_(0), | 32 : ref_count_(0), |
| 33 render_loop_(base::MessageLoopProxy::current()), | 33 render_loop_(base::MessageLoopProxy::current()), |
| 34 audio_transport_callback_(NULL), | 34 audio_transport_callback_(NULL), |
| 35 input_delay_ms_(0), | 35 input_delay_ms_(0), |
| 36 output_delay_ms_(0), | 36 output_delay_ms_(0), |
| 37 last_error_(AudioDeviceModule::kAdmErrNone), | 37 last_error_(AudioDeviceModule::kAdmErrNone), |
| 38 last_process_time_(base::TimeTicks::Now()), | 38 last_process_time_(base::TimeTicks::Now()), |
| 39 session_id_(0), | |
| 40 initialized_(false), | 39 initialized_(false), |
| 41 playing_(false), | 40 playing_(false), |
| 42 agc_is_enabled_(false) { | 41 agc_is_enabled_(false) { |
| 43 DVLOG(1) << "WebRtcAudioDeviceImpl::WebRtcAudioDeviceImpl()"; | 42 DVLOG(1) << "WebRtcAudioDeviceImpl::WebRtcAudioDeviceImpl()"; |
| 44 } | 43 } |
| 45 | 44 |
| 46 WebRtcAudioDeviceImpl::~WebRtcAudioDeviceImpl() { | 45 WebRtcAudioDeviceImpl::~WebRtcAudioDeviceImpl() { |
| 47 DVLOG(1) << "WebRtcAudioDeviceImpl::~WebRtcAudioDeviceImpl()"; | 46 DVLOG(1) << "WebRtcAudioDeviceImpl::~WebRtcAudioDeviceImpl()"; |
| 48 Terminate(); | 47 Terminate(); |
| 49 } | 48 } |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 // before the new level is effective due to the IPC scheme. | 206 // before the new level is effective due to the IPC scheme. |
| 208 // During this time, |current_mic_level| will contain "non-valid" values | 207 // During this time, |current_mic_level| will contain "non-valid" values |
| 209 // and it might reduce the AGC performance. Measurements on Windows 7 have | 208 // and it might reduce the AGC performance. Measurements on Windows 7 have |
| 210 // shown that we might receive old volume levels for one or two callbacks. | 209 // shown that we might receive old volume levels for one or two callbacks. |
| 211 SetMicrophoneVolume(new_mic_level); | 210 SetMicrophoneVolume(new_mic_level); |
| 212 } | 211 } |
| 213 } | 212 } |
| 214 | 213 |
| 215 void WebRtcAudioDeviceImpl::SetCaptureFormat( | 214 void WebRtcAudioDeviceImpl::SetCaptureFormat( |
| 216 const media::AudioParameters& params) { | 215 const media::AudioParameters& params) { |
| 216 DVLOG(1) << "WebRtcAudioDeviceImpl::SetCaptureFormat()"; |
| 217 input_audio_parameters_ = params; | 217 input_audio_parameters_ = params; |
| 218 } | 218 } |
| 219 | 219 |
| 220 int32_t WebRtcAudioDeviceImpl::ChangeUniqueId(const int32_t id) { | 220 int32_t WebRtcAudioDeviceImpl::ChangeUniqueId(const int32_t id) { |
| 221 NOTIMPLEMENTED(); | 221 NOTIMPLEMENTED(); |
| 222 return -1; | 222 return -1; |
| 223 } | 223 } |
| 224 | 224 |
| 225 int32_t WebRtcAudioDeviceImpl::TimeUntilNextProcess() { | 225 int32_t WebRtcAudioDeviceImpl::TimeUntilNextProcess() { |
| 226 // Calculate the number of milliseconds until this module wants its | 226 // Calculate the number of milliseconds until this module wants its |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 } | 485 } |
| 486 | 486 |
| 487 int32_t WebRtcAudioDeviceImpl::StartRecording() { | 487 int32_t WebRtcAudioDeviceImpl::StartRecording() { |
| 488 DCHECK(initialized_); | 488 DCHECK(initialized_); |
| 489 DVLOG(1) << "StartRecording()"; | 489 DVLOG(1) << "StartRecording()"; |
| 490 LOG_IF(ERROR, !audio_transport_callback_) << "Audio transport is missing"; | 490 LOG_IF(ERROR, !audio_transport_callback_) << "Audio transport is missing"; |
| 491 if (!audio_transport_callback_ || !capturer_) { | 491 if (!audio_transport_callback_ || !capturer_) { |
| 492 return -1; | 492 return -1; |
| 493 } | 493 } |
| 494 | 494 |
| 495 if (session_id_ <= 0) { | |
| 496 LOG(ERROR) << session_id_ << " is an invalid session id."; | |
| 497 return -1; | |
| 498 } | |
| 499 | |
| 500 if (capturer_->is_recording()) { | 495 if (capturer_->is_recording()) { |
| 501 // webrtc::VoiceEngine assumes that it is OK to call Start() twice and | 496 // webrtc::VoiceEngine assumes that it is OK to call Start() twice and |
| 502 // that the call is ignored the second time. | 497 // that the call is ignored the second time. |
| 503 return 0; | 498 return 0; |
| 504 } | 499 } |
| 505 | 500 |
| 506 start_capture_time_ = base::Time::Now(); | 501 start_capture_time_ = base::Time::Now(); |
| 507 | 502 |
| 508 // Specify the session_id which is mapped to a certain device. | 503 // Start capturing using the selected device. |
| 509 capturer_->SetDevice(session_id_); | |
| 510 capturer_->Start(); | 504 capturer_->Start(); |
| 511 return 0; | 505 return 0; |
| 512 } | 506 } |
| 513 | 507 |
| 514 int32_t WebRtcAudioDeviceImpl::StopRecording() { | 508 int32_t WebRtcAudioDeviceImpl::StopRecording() { |
| 515 DVLOG(1) << "StopRecording()"; | 509 DVLOG(1) << "StopRecording()"; |
| 516 if (!capturer_ || !capturer_->is_recording()) { | 510 if (!capturer_ || !capturer_->is_recording()) { |
| 517 // webrtc::VoiceEngine assumes that it is OK to call Stop() | 511 // webrtc::VoiceEngine assumes that it is OK to call Stop() |
| 518 // more than once. | 512 // more than once. |
| 519 return 0; | 513 return 0; |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 873 int32_t WebRtcAudioDeviceImpl::SetLoudspeakerStatus(bool enable) { | 867 int32_t WebRtcAudioDeviceImpl::SetLoudspeakerStatus(bool enable) { |
| 874 NOTIMPLEMENTED(); | 868 NOTIMPLEMENTED(); |
| 875 return -1; | 869 return -1; |
| 876 } | 870 } |
| 877 | 871 |
| 878 int32_t WebRtcAudioDeviceImpl::GetLoudspeakerStatus(bool* enabled) const { | 872 int32_t WebRtcAudioDeviceImpl::GetLoudspeakerStatus(bool* enabled) const { |
| 879 NOTIMPLEMENTED(); | 873 NOTIMPLEMENTED(); |
| 880 return -1; | 874 return -1; |
| 881 } | 875 } |
| 882 | 876 |
| 883 void WebRtcAudioDeviceImpl::SetSessionId(int session_id) { | |
| 884 session_id_ = session_id; | |
| 885 } | |
| 886 | |
| 887 } // namespace content | 877 } // namespace content |
| OLD | NEW |