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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "webrtc/modules/audio_processing/aec_dump/aec_dump.h"
12
13 #include "webrtc/base/ignore_wundef.h"
14 // Files generated at build-time by the protobuf compiler.
15 RTC_PUSH_IGNORING_WUNDEF()
16 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD
17 #include "external/webrtc/webrtc/modules/audio_processing/debug.pb.h"
18 #else
19 #include "webrtc/modules/audio_processing/debug.pb.h"
20 #endif
21 RTC_POP_IGNORING_WUNDEF()
22
23 namespace webrtc {
24 AecDump::CaptureStreamInfo::CaptureStreamInfo()
25 : 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
26 RTC_DCHECK(event_);
27 event_->set_type(audioproc::Event::STREAM);
28 }
29
30 AecDump::CaptureStreamInfo::~CaptureStreamInfo() {
31 // |event_| can't be in a unique_ptr, because of the no-protobuf
32 // implementation of AecDump::CaptureStreamInfo. In the no-protobuf
33 // case, a forward-declared audioproc::Event would have to be
34 // destroyed.
35 if (event_) {
36 delete event_;
37 }
38 }
39
40 void AecDump::CaptureStreamInfo::AddInput(FloatAudioFrame src) {
41 auto* stream = event_->mutable_stream();
42
43 for (size_t i = 0; i < src.num_channels(); ++i) {
44 const auto& channel_view = src.channel(i);
45 stream->add_input_channel(channel_view.begin(),
46 sizeof(float) * channel_view.size());
47 }
48 }
49
50 void AecDump::CaptureStreamInfo::AddOutput(FloatAudioFrame src) {
51 auto* stream = event_->mutable_stream();
52
53 for (size_t i = 0; i < src.num_channels(); ++i) {
54 const auto& channel_view = src.channel(i);
55 stream->add_output_channel(channel_view.begin(),
56 sizeof(float) * channel_view.size());
57 }
58 }
59
60 void AecDump::CaptureStreamInfo::AddInput(const AudioFrame& frame) {
61 audioproc::Stream* stream = event_->mutable_stream();
62 const size_t data_size =
63 sizeof(int16_t) * frame.samples_per_channel_ * frame.num_channels_;
64 stream->set_input_data(frame.data_, data_size);
65 }
66
67 void AecDump::CaptureStreamInfo::AddOutput(const AudioFrame& frame) {
68 audioproc::Stream* stream = event_->mutable_stream();
69 const size_t data_size =
70 sizeof(int16_t) * frame.samples_per_channel_ * frame.num_channels_;
71 stream->set_output_data(frame.data_, data_size);
72 }
73
74 void AecDump::CaptureStreamInfo::set_delay(int delay) {
75 event_->mutable_stream()->set_delay(delay);
76 }
77 void AecDump::CaptureStreamInfo::set_drift(int drift) {
78 event_->mutable_stream()->set_drift(drift);
79 }
80 void AecDump::CaptureStreamInfo::set_level(int level) {
81 event_->mutable_stream()->set_level(level);
82 }
83 void AecDump::CaptureStreamInfo::set_keypress(bool keypress) {
84 event_->mutable_stream()->set_keypress(keypress);
85 }
86
87 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
88 auto result = std::unique_ptr<audioproc::Event>(event_);
89 event_ = nullptr;
90 return result;
91 }
92 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698