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 <array> |
| 12 #include <utility> |
| 13 |
| 14 #include "webrtc/modules/audio_processing/aec_dump/aec_dump_factory.h" |
| 15 |
| 16 #include "webrtc/base/task_queue.h" |
| 17 #include "webrtc/modules/include/module_common_types.h" |
| 18 #include "webrtc/test/gtest.h" |
| 19 #include "webrtc/test/testsupport/fileutils.h" |
| 20 |
| 21 TEST(AecDumper, APICallsDoNotCrash) { |
| 22 // Note order of initialization: AecDump uses the task queue in its |
| 23 // d-tor. The task queue has to be initialized first. |
| 24 rtc::TaskQueue file_writer_queue("file_writer_queue"); |
| 25 |
| 26 std::vector<std::string> file_names; |
| 27 for (const std::string prefix : {"aecdump0", "aecdump1", "aecdump2"}) { |
| 28 file_names.push_back( |
| 29 webrtc::test::TempFilename(webrtc::test::OutputPath(), prefix)); |
| 30 } |
| 31 |
| 32 auto aec_dump = |
| 33 webrtc::AecDumpFactory::Create(file_names[0], -1, &file_writer_queue); |
| 34 EXPECT_TRUE(aec_dump); |
| 35 |
| 36 aec_dump = |
| 37 webrtc::AecDumpFactory::Create(file_names[1], -1, &file_writer_queue); |
| 38 |
| 39 aec_dump = |
| 40 webrtc::AecDumpFactory::Create(file_names[2], 10, &file_writer_queue); |
| 41 |
| 42 FILE* fid = nullptr; |
| 43 aec_dump = webrtc::AecDumpFactory::Create(fid, 10, &file_writer_queue); |
| 44 |
| 45 const webrtc::AudioFrame frame; |
| 46 aec_dump->WriteRenderStreamMessage(frame); |
| 47 |
| 48 auto capture_stream_info = aec_dump->GetCaptureStreamInfo(); |
| 49 |
| 50 capture_stream_info->AddInput(frame); |
| 51 capture_stream_info->AddOutput(frame); |
| 52 |
| 53 aec_dump->WriteCaptureStreamMessage(std::move(capture_stream_info)); |
| 54 |
| 55 capture_stream_info = aec_dump->GetCaptureStreamInfo(); |
| 56 std::vector<rtc::ArrayView<const float>> audio_channels; |
| 57 std::array<float, 160> audio_data; |
| 58 audio_channels.emplace_back(audio_data); |
| 59 |
| 60 capture_stream_info->AddInput(audio_channels); |
| 61 capture_stream_info->AddOutput(audio_channels); |
| 62 |
| 63 aec_dump->WriteCaptureStreamMessage(std::move(capture_stream_info)); |
| 64 |
| 65 webrtc::InternalAPMConfig apm_config; |
| 66 aec_dump->WriteConfig(apm_config, false); |
| 67 |
| 68 aec_dump->WriteConfig(apm_config, true); |
| 69 |
| 70 webrtc::ProcessingConfig processing_config; |
| 71 aec_dump->WriteInitMessage(processing_config); |
| 72 |
| 73 for (const auto& filename : file_names) { |
| 74 remove(filename.c_str()); |
| 75 } |
| 76 } |
OLD | NEW |