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

Side by Side Diff: webrtc/modules/audio_processing/aec_dump/capture_stream_info.cc

Issue 2865113002: AecDump implementation. (Closed)
Patch Set: Removed extra build deps from dependent CL. 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/capture_stream_info.h"
12
13 namespace webrtc {
14 CaptureStreamInfo::CaptureStreamInfo(std::unique_ptr<WriteToFileTask> task)
15 : task_(std::move(task)) {
16 RTC_DCHECK(task_);
17 task_->GetEvent()->set_type(audioproc::Event::STREAM);
18 }
19
20 CaptureStreamInfo::~CaptureStreamInfo() = default;
21
22 void CaptureStreamInfo::AddInput(const FloatAudioFrame& src) {
23 RTC_DCHECK(task_);
24 auto* stream = task_->GetEvent()->mutable_stream();
25
26 for (size_t i = 0; i < src.num_channels(); ++i) {
27 const auto& channel_view = src.channel(i);
28 stream->add_input_channel(channel_view.begin(),
29 sizeof(float) * channel_view.size());
30 }
31 }
32
33 void CaptureStreamInfo::AddOutput(const FloatAudioFrame& src) {
34 RTC_DCHECK(task_);
35 auto* stream = task_->GetEvent()->mutable_stream();
36
37 for (size_t i = 0; i < src.num_channels(); ++i) {
38 const auto& channel_view = src.channel(i);
39 stream->add_output_channel(channel_view.begin(),
40 sizeof(float) * channel_view.size());
41 }
42 }
43
44 void CaptureStreamInfo::AddInput(const AudioFrame& frame) {
45 RTC_DCHECK(task_);
46 auto* stream = task_->GetEvent()->mutable_stream();
47 const size_t data_size =
48 sizeof(int16_t) * frame.samples_per_channel_ * frame.num_channels_;
49 stream->set_input_data(frame.data_, data_size);
50 }
51
52 void CaptureStreamInfo::AddOutput(const AudioFrame& frame) {
53 RTC_DCHECK(task_);
54 auto* stream = task_->GetEvent()->mutable_stream();
55 const size_t data_size =
56 sizeof(int16_t) * frame.samples_per_channel_ * frame.num_channels_;
57 stream->set_output_data(frame.data_, data_size);
58 }
59
60 void CaptureStreamInfo::AddAudioProcessingState(
61 const AecDump::AudioProcessingState& state) {
62 RTC_DCHECK(task_);
63 auto* stream = task_->GetEvent()->mutable_stream();
64 stream->set_delay(state.delay);
65 stream->set_drift(state.drift);
66 stream->set_level(state.level);
67 stream->set_keypress(state.keypress);
68 }
69 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698