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

Unified Diff: webrtc/modules/audio_processing/aec_dump/capture_stream_info_impl.cc

Issue 2865113002: AecDump implementation. (Closed)
Patch Set: Clean up of impl code. Created 3 years, 7 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
Index: webrtc/modules/audio_processing/aec_dump/capture_stream_info_impl.cc
diff --git a/webrtc/modules/audio_processing/aec_dump/capture_stream_info_impl.cc b/webrtc/modules/audio_processing/aec_dump/capture_stream_info_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..248097ac0f34c2cb4edb567484bc3d1d0e522539
--- /dev/null
+++ b/webrtc/modules/audio_processing/aec_dump/capture_stream_info_impl.cc
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "webrtc/modules/audio_processing/aec_dump/aec_dump.h"
+
+#include "webrtc/base/ignore_wundef.h"
+// Files generated at build-time by the protobuf compiler.
+RTC_PUSH_IGNORING_WUNDEF()
+#ifdef WEBRTC_ANDROID_PLATFORM_BUILD
+#include "external/webrtc/webrtc/modules/audio_processing/debug.pb.h"
+#else
+#include "webrtc/modules/audio_processing/debug.pb.h"
+#endif
+RTC_POP_IGNORING_WUNDEF()
+
+namespace webrtc {
+AecDump::CaptureStreamInfo::CaptureStreamInfo()
+ : event_(new audioproc::Event()) {
peah-webrtc 2017/05/09 07:14:57 I think the separation of the capture stream infor
aleloi 2017/05/12 13:07:56 Changed after offline discussion. To avoid creati
+ RTC_DCHECK(event_);
+ event_->set_type(audioproc::Event::STREAM);
+}
+
+AecDump::CaptureStreamInfo::~CaptureStreamInfo() {
+ // |event_| can't be in a unique_ptr, because of the no-protobuf
+ // implementation of AecDump::CaptureStreamInfo. In the no-protobuf
+ // case, a forward-declared audioproc::Event would have to be
+ // destroyed.
+ if (event_) {
+ delete event_;
+ }
+}
+
+void AecDump::CaptureStreamInfo::AddInput(FloatAudioFrame src) {
+ auto* stream = event_->mutable_stream();
+
+ for (size_t i = 0; i < src.num_channels(); ++i) {
+ const auto& channel_view = src.channel(i);
+ stream->add_input_channel(channel_view.begin(),
+ sizeof(float) * channel_view.size());
+ }
+}
+
+void AecDump::CaptureStreamInfo::AddOutput(FloatAudioFrame src) {
+ auto* stream = event_->mutable_stream();
+
+ for (size_t i = 0; i < src.num_channels(); ++i) {
+ const auto& channel_view = src.channel(i);
+ stream->add_output_channel(channel_view.begin(),
+ sizeof(float) * channel_view.size());
+ }
+}
+
+void AecDump::CaptureStreamInfo::AddInput(const AudioFrame& frame) {
+ audioproc::Stream* stream = event_->mutable_stream();
+ const size_t data_size =
+ sizeof(int16_t) * frame.samples_per_channel_ * frame.num_channels_;
+ stream->set_input_data(frame.data_, data_size);
+}
+
+void AecDump::CaptureStreamInfo::AddOutput(const AudioFrame& frame) {
+ audioproc::Stream* stream = event_->mutable_stream();
+ const size_t data_size =
+ sizeof(int16_t) * frame.samples_per_channel_ * frame.num_channels_;
+ stream->set_output_data(frame.data_, data_size);
+}
+
+void AecDump::CaptureStreamInfo::set_delay(int delay) {
+ event_->mutable_stream()->set_delay(delay);
+}
+void AecDump::CaptureStreamInfo::set_drift(int drift) {
+ event_->mutable_stream()->set_drift(drift);
+}
+void AecDump::CaptureStreamInfo::set_level(int level) {
+ event_->mutable_stream()->set_level(level);
+}
+void AecDump::CaptureStreamInfo::set_keypress(bool keypress) {
+ event_->mutable_stream()->set_keypress(keypress);
+}
+
+std::unique_ptr<audioproc::Event> AecDump::CaptureStreamInfo::GetEventMsg() {
peah-webrtc 2017/05/09 07:14:57 This part of the class is a bit error prone. It me
aleloi 2017/05/12 13:07:56 The code is rather different now after the Capture
+ auto result = std::unique_ptr<audioproc::Event>(event_);
+ event_ = nullptr;
+ return result;
+}
+} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698