blob: 23e48a00ee2c97ff61bbd35184fe3e1ee2b2e2f3 [file] [log] [blame]
henrik.lundin@webrtc.org0e6e4d22014-09-23 12:05:34 +00001/*
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 Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_AUDIO_CODING_ACM2_ACM_RECEIVE_TEST_H_
12#define MODULES_AUDIO_CODING_ACM2_ACM_RECEIVE_TEST_H_
henrik.lundin@webrtc.org0e6e4d22014-09-23 12:05:34 +000013
Yves Gerey665174f2018-06-19 15:03:05 +020014#include <stddef.h> // for size_t
kwiberg16c5a962016-02-15 02:27:22 -080015#include <memory>
henrik.lundin4cf61dd2015-12-09 06:20:58 -080016#include <string>
17
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020018#include "api/audio_codecs/audio_decoder_factory.h"
Steve Anton10542f22019-01-11 09:11:00 -080019#include "rtc_base/constructor_magic.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020020#include "rtc_base/scoped_ref_ptr.h"
21#include "system_wrappers/include/clock.h"
henrik.lundin@webrtc.org0e6e4d22014-09-23 12:05:34 +000022
23namespace webrtc {
24class AudioCodingModule;
kwiberg4e14f092015-08-24 05:27:22 -070025class AudioDecoder;
henrik.lundin@webrtc.org0e6e4d22014-09-23 12:05:34 +000026
27namespace test {
28class AudioSink;
29class PacketSource;
30
31class AcmReceiveTestOldApi {
32 public:
Oleh Prypinfd7df982017-12-21 16:25:19 +010033 enum NumOutputChannels : size_t {
henrik.lundin@webrtc.org0e6e4d22014-09-23 12:05:34 +000034 kArbitraryChannels = 0,
35 kMonoOutput = 1,
36 kStereoOutput = 2
37 };
38
39 AcmReceiveTestOldApi(PacketSource* packet_source,
40 AudioSink* audio_sink,
41 int output_freq_hz,
kwiberg5adaf732016-10-04 09:33:27 -070042 NumOutputChannels exptected_output_channels,
43 rtc::scoped_refptr<AudioDecoderFactory> decoder_factory);
kwibergb8e56ee2016-08-29 06:37:33 -070044 virtual ~AcmReceiveTestOldApi();
henrik.lundin@webrtc.org0e6e4d22014-09-23 12:05:34 +000045
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
kwiberg5adaf732016-10-04 09:33:27 -070056 AudioCodingModule* get_acm() { return acm_.get(); }
57
henrik.lundin@webrtc.org81a78932014-10-14 10:49:58 +000058 protected:
59 // Method is called after each block of output audio is received from ACM.
60 virtual void AfterGetAudio() {}
61
henrik.lundin@webrtc.org0e6e4d22014-09-23 12:05:34 +000062 SimulatedClock clock_;
kwiberg16c5a962016-02-15 02:27:22 -080063 std::unique_ptr<AudioCodingModule> acm_;
henrik.lundin@webrtc.org0e6e4d22014-09-23 12:05:34 +000064 PacketSource* packet_source_;
65 AudioSink* audio_sink_;
henrik.lundin@webrtc.org81a78932014-10-14 10:49:58 +000066 int output_freq_hz_;
henrik.lundin@webrtc.org0e6e4d22014-09-23 12:05:34 +000067 NumOutputChannels exptected_output_channels_;
68
henrikg3c089d72015-09-16 05:37:44 -070069 RTC_DISALLOW_COPY_AND_ASSIGN(AcmReceiveTestOldApi);
henrik.lundin@webrtc.org0e6e4d22014-09-23 12:05:34 +000070};
71
henrik.lundin@webrtc.org81a78932014-10-14 10:49:58 +000072// 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.
75class 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.org14665ff2015-03-04 12:58:35 +000086 void AfterGetAudio() override;
henrik.lundin@webrtc.org81a78932014-10-14 10:49:58 +000087
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.org0e6e4d22014-09-23 12:05:34 +000094} // namespace test
95} // namespace webrtc
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020096#endif // MODULES_AUDIO_CODING_ACM2_ACM_RECEIVE_TEST_H_