henrik.lundin@webrtc.org | 0e6e4d2 | 2014-09-23 12:05:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2014 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame^] | 11 | #ifndef MODULES_AUDIO_CODING_ACM2_ACM_RECEIVE_TEST_H_ |
| 12 | #define MODULES_AUDIO_CODING_ACM2_ACM_RECEIVE_TEST_H_ |
henrik.lundin@webrtc.org | 0e6e4d2 | 2014-09-23 12:05:34 +0000 | [diff] [blame] | 13 | |
kwiberg | 16c5a96 | 2016-02-15 02:27:22 -0800 | [diff] [blame] | 14 | #include <memory> |
henrik.lundin | 4cf61dd | 2015-12-09 06:20:58 -0800 | [diff] [blame] | 15 | #include <string> |
| 16 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame^] | 17 | #include "api/audio_codecs/audio_decoder_factory.h" |
| 18 | #include "rtc_base/constructormagic.h" |
| 19 | #include "rtc_base/scoped_ref_ptr.h" |
| 20 | #include "system_wrappers/include/clock.h" |
henrik.lundin@webrtc.org | 0e6e4d2 | 2014-09-23 12:05:34 +0000 | [diff] [blame] | 21 | |
| 22 | namespace webrtc { |
| 23 | class AudioCodingModule; |
kwiberg | 4e14f09 | 2015-08-24 05:27:22 -0700 | [diff] [blame] | 24 | class AudioDecoder; |
henrik.lundin@webrtc.org | 0e6e4d2 | 2014-09-23 12:05:34 +0000 | [diff] [blame] | 25 | struct CodecInst; |
| 26 | |
| 27 | namespace test { |
| 28 | class AudioSink; |
| 29 | class PacketSource; |
| 30 | |
| 31 | class AcmReceiveTestOldApi { |
| 32 | public: |
| 33 | enum NumOutputChannels { |
| 34 | kArbitraryChannels = 0, |
| 35 | kMonoOutput = 1, |
| 36 | kStereoOutput = 2 |
| 37 | }; |
| 38 | |
| 39 | AcmReceiveTestOldApi(PacketSource* packet_source, |
| 40 | AudioSink* audio_sink, |
| 41 | int output_freq_hz, |
kwiberg | 5adaf73 | 2016-10-04 09:33:27 -0700 | [diff] [blame] | 42 | NumOutputChannels exptected_output_channels, |
| 43 | rtc::scoped_refptr<AudioDecoderFactory> decoder_factory); |
kwiberg | b8e56ee | 2016-08-29 06:37:33 -0700 | [diff] [blame] | 44 | virtual ~AcmReceiveTestOldApi(); |
henrik.lundin@webrtc.org | 0e6e4d2 | 2014-09-23 12:05:34 +0000 | [diff] [blame] | 45 | |
| 46 | // Registers the codecs with default parameters from ACM. |
| 47 | void RegisterDefaultCodecs(); |
| 48 | |
| 49 | // Registers codecs with payload types matching the pre-encoded NetEq test |
| 50 | // files. |
| 51 | void RegisterNetEqTestCodecs(); |
| 52 | |
| 53 | // Runs the test and returns true if successful. |
| 54 | void Run(); |
| 55 | |
kwiberg | 5adaf73 | 2016-10-04 09:33:27 -0700 | [diff] [blame] | 56 | AudioCodingModule* get_acm() { return acm_.get(); } |
| 57 | |
henrik.lundin@webrtc.org | 81a7893 | 2014-10-14 10:49:58 +0000 | [diff] [blame] | 58 | protected: |
| 59 | // Method is called after each block of output audio is received from ACM. |
| 60 | virtual void AfterGetAudio() {} |
| 61 | |
henrik.lundin@webrtc.org | 0e6e4d2 | 2014-09-23 12:05:34 +0000 | [diff] [blame] | 62 | SimulatedClock clock_; |
kwiberg | 16c5a96 | 2016-02-15 02:27:22 -0800 | [diff] [blame] | 63 | std::unique_ptr<AudioCodingModule> acm_; |
henrik.lundin@webrtc.org | 0e6e4d2 | 2014-09-23 12:05:34 +0000 | [diff] [blame] | 64 | PacketSource* packet_source_; |
| 65 | AudioSink* audio_sink_; |
henrik.lundin@webrtc.org | 81a7893 | 2014-10-14 10:49:58 +0000 | [diff] [blame] | 66 | int output_freq_hz_; |
henrik.lundin@webrtc.org | 0e6e4d2 | 2014-09-23 12:05:34 +0000 | [diff] [blame] | 67 | NumOutputChannels exptected_output_channels_; |
| 68 | |
henrikg | 3c089d7 | 2015-09-16 05:37:44 -0700 | [diff] [blame] | 69 | RTC_DISALLOW_COPY_AND_ASSIGN(AcmReceiveTestOldApi); |
henrik.lundin@webrtc.org | 0e6e4d2 | 2014-09-23 12:05:34 +0000 | [diff] [blame] | 70 | }; |
| 71 | |
henrik.lundin@webrtc.org | 81a7893 | 2014-10-14 10:49:58 +0000 | [diff] [blame] | 72 | // This test toggles the output frequency every |toggle_period_ms|. The test |
| 73 | // starts with |output_freq_hz_1|. Except for the toggling, it does the same |
| 74 | // thing as AcmReceiveTestOldApi. |
| 75 | class AcmReceiveTestToggleOutputFreqOldApi : public AcmReceiveTestOldApi { |
| 76 | public: |
| 77 | AcmReceiveTestToggleOutputFreqOldApi( |
| 78 | PacketSource* packet_source, |
| 79 | AudioSink* audio_sink, |
| 80 | int output_freq_hz_1, |
| 81 | int output_freq_hz_2, |
| 82 | int toggle_period_ms, |
| 83 | NumOutputChannels exptected_output_channels); |
| 84 | |
| 85 | protected: |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 86 | void AfterGetAudio() override; |
henrik.lundin@webrtc.org | 81a7893 | 2014-10-14 10:49:58 +0000 | [diff] [blame] | 87 | |
| 88 | const int output_freq_hz_1_; |
| 89 | const int output_freq_hz_2_; |
| 90 | const int toggle_period_ms_; |
| 91 | int64_t last_toggle_time_ms_; |
| 92 | }; |
| 93 | |
henrik.lundin@webrtc.org | 0e6e4d2 | 2014-09-23 12:05:34 +0000 | [diff] [blame] | 94 | } // namespace test |
| 95 | } // namespace webrtc |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame^] | 96 | #endif // MODULES_AUDIO_CODING_ACM2_ACM_RECEIVE_TEST_H_ |