OLD | NEW |
(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_impl.h" |
| 12 |
| 13 namespace webrtc { |
| 14 CaptureStreamInfoImpl::CaptureStreamInfoImpl( |
| 15 std::unique_ptr<WriteToFileTask> task) |
| 16 : task_(std::move(task)) { |
| 17 RTC_DCHECK(task_); |
| 18 task_->GetEvent()->set_type(audioproc::Event::STREAM); |
| 19 } |
| 20 |
| 21 CaptureStreamInfoImpl::~CaptureStreamInfoImpl() = default; |
| 22 |
| 23 void CaptureStreamInfoImpl::AddInput(const FloatAudioFrame& src) { |
| 24 RTC_DCHECK(task_); |
| 25 auto* stream = task_->GetEvent()->mutable_stream(); |
| 26 |
| 27 for (size_t i = 0; i < src.num_channels(); ++i) { |
| 28 const auto& channel_view = src.channel(i); |
| 29 stream->add_input_channel(channel_view.begin(), |
| 30 sizeof(float) * channel_view.size()); |
| 31 } |
| 32 } |
| 33 |
| 34 void CaptureStreamInfoImpl::AddOutput(const FloatAudioFrame& src) { |
| 35 RTC_DCHECK(task_); |
| 36 auto* stream = task_->GetEvent()->mutable_stream(); |
| 37 |
| 38 for (size_t i = 0; i < src.num_channels(); ++i) { |
| 39 const auto& channel_view = src.channel(i); |
| 40 stream->add_output_channel(channel_view.begin(), |
| 41 sizeof(float) * channel_view.size()); |
| 42 } |
| 43 } |
| 44 |
| 45 void CaptureStreamInfoImpl::AddInput(const AudioFrame& frame) { |
| 46 RTC_DCHECK(task_); |
| 47 audioproc::Stream* stream = task_->GetEvent()->mutable_stream(); |
| 48 const size_t data_size = |
| 49 sizeof(int16_t) * frame.samples_per_channel_ * frame.num_channels_; |
| 50 stream->set_input_data(frame.data_, data_size); |
| 51 } |
| 52 |
| 53 void CaptureStreamInfoImpl::AddOutput(const AudioFrame& frame) { |
| 54 RTC_DCHECK(task_); |
| 55 audioproc::Stream* stream = task_->GetEvent()->mutable_stream(); |
| 56 const size_t data_size = |
| 57 sizeof(int16_t) * frame.samples_per_channel_ * frame.num_channels_; |
| 58 stream->set_output_data(frame.data_, data_size); |
| 59 } |
| 60 |
| 61 void CaptureStreamInfoImpl::set_delay(int delay) { |
| 62 RTC_DCHECK(task_); |
| 63 task_->GetEvent()->mutable_stream()->set_delay(delay); |
| 64 } |
| 65 void CaptureStreamInfoImpl::set_drift(int drift) { |
| 66 RTC_DCHECK(task_); |
| 67 task_->GetEvent()->mutable_stream()->set_drift(drift); |
| 68 } |
| 69 void CaptureStreamInfoImpl::set_level(int level) { |
| 70 RTC_DCHECK(task_); |
| 71 task_->GetEvent()->mutable_stream()->set_level(level); |
| 72 } |
| 73 void CaptureStreamInfoImpl::set_keypress(bool keypress) { |
| 74 RTC_DCHECK(task_); |
| 75 task_->GetEvent()->mutable_stream()->set_keypress(keypress); |
| 76 } |
| 77 } // namespace webrtc |
OLD | NEW |