Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2372)

Unified Diff: content/renderer/media/webrtc_audio_device_impl.cc

Issue 187913002: Support the Aec dump for the APM in chrome (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: minor fix to one comment. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/media/webrtc_audio_device_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/webrtc_audio_device_impl.cc
diff --git a/content/renderer/media/webrtc_audio_device_impl.cc b/content/renderer/media/webrtc_audio_device_impl.cc
index 7e27af1a08cfac518300914d164e73cac44da714..48dbdc6af97b04de2b870d28de85995c84b92086 100644
--- a/content/renderer/media/webrtc_audio_device_impl.cc
+++ b/content/renderer/media/webrtc_audio_device_impl.cc
@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "base/metrics/histogram.h"
+#include "base/platform_file.h"
#include "base/strings/string_util.h"
#include "base/win/windows_version.h"
#include "content/renderer/media/webrtc_audio_capturer.h"
@@ -27,7 +28,8 @@ WebRtcAudioDeviceImpl::WebRtcAudioDeviceImpl()
initialized_(false),
playing_(false),
recording_(false),
- microphone_volume_(0) {
+ microphone_volume_(0),
+ aec_dump_file_(base::kInvalidPlatformFileValue) {
DVLOG(1) << "WebRtcAudioDeviceImpl::WebRtcAudioDeviceImpl()";
}
@@ -220,6 +222,8 @@ int32_t WebRtcAudioDeviceImpl::Terminate() {
DCHECK(!renderer_.get() || !renderer_->IsStarted())
<< "The shared audio renderer shouldn't be running";
+ DisableAecDump();
+
capturers_.clear();
initialized_ = false;
@@ -431,10 +435,17 @@ void WebRtcAudioDeviceImpl::AddAudioCapturer(
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(capturer.get());
DCHECK(!capturer->device_id().empty());
- base::AutoLock auto_lock(lock_);
- DCHECK(std::find(capturers_.begin(), capturers_.end(), capturer) ==
- capturers_.end());
- capturers_.push_back(capturer);
+ {
+ base::AutoLock auto_lock(lock_);
+ DCHECK(std::find(capturers_.begin(), capturers_.end(), capturer) ==
+ capturers_.end());
+ capturers_.push_back(capturer);
+ }
+
+ // Start the Aec dump if the Aec dump has been enabled and has not been
+ // started.
+ if (aec_dump_file_ != base::kInvalidPlatformFileValue)
+ MaybeStartAecDump();
}
void WebRtcAudioDeviceImpl::RemoveAudioCapturer(
@@ -491,4 +502,47 @@ bool WebRtcAudioDeviceImpl::GetAuthorizedDeviceInfoForAudioRenderer(
session_id, output_sample_rate, output_frames_per_buffer);
}
+void WebRtcAudioDeviceImpl::EnableAecDump(
+ const base::PlatformFile& aec_dump_file) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK_NE(aec_dump_file, base::kInvalidPlatformFileValue);
+ DCHECK_EQ(aec_dump_file_, base::kInvalidPlatformFileValue);
+ aec_dump_file_ = aec_dump_file;
+ MaybeStartAecDump();
+}
+
+void WebRtcAudioDeviceImpl::DisableAecDump() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ // Simply invalidate the |aec_dump_file_| if we have not pass the ownership
+ // to WebRtc.
+ if (aec_dump_file_ != base::kInvalidPlatformFileValue) {
+ base::ClosePlatformFile(aec_dump_file_);
+ aec_dump_file_ = base::kInvalidPlatformFileValue;
+ return;
+ }
+
+ // We might have call StartAecDump() on one of the capturer. Loop
+ // through all the capturers and call StopAecDump() on each of them.
+ for (CapturerList::const_iterator iter = capturers_.begin();
+ iter != capturers_.end(); ++iter) {
+ (*iter)->StopAecDump();
+ }
+}
+
+void WebRtcAudioDeviceImpl::MaybeStartAecDump() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK_NE(aec_dump_file_, base::kInvalidPlatformFileValue);
+
+ // Start the Aec dump on the current default capturer.
+ scoped_refptr<WebRtcAudioCapturer> default_capturer(GetDefaultCapturer());
+ if (!default_capturer)
+ return;
+
+ default_capturer->StartAecDump(aec_dump_file_);
+
+ // Invalidate the |aec_dump_file_| since the ownership of the file has been
+ // passed to WebRtc.
+ aec_dump_file_ = base::kInvalidPlatformFileValue;
+}
+
} // namespace content
« no previous file with comments | « content/renderer/media/webrtc_audio_device_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698