OLD | NEW |
| (Empty) |
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 | |
11 #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_RECEIVE_TEST_H_ | |
12 #define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_RECEIVE_TEST_H_ | |
13 | |
14 #include "webrtc/base/constructormagic.h" | |
15 #include "webrtc/base/scoped_ptr.h" | |
16 #include "webrtc/system_wrappers/include/clock.h" | |
17 | |
18 namespace webrtc { | |
19 class AudioCodingModule; | |
20 class AudioDecoder; | |
21 struct CodecInst; | |
22 | |
23 namespace test { | |
24 class AudioSink; | |
25 class PacketSource; | |
26 | |
27 class AcmReceiveTestOldApi { | |
28 public: | |
29 enum NumOutputChannels { | |
30 kArbitraryChannels = 0, | |
31 kMonoOutput = 1, | |
32 kStereoOutput = 2 | |
33 }; | |
34 | |
35 AcmReceiveTestOldApi(PacketSource* packet_source, | |
36 AudioSink* audio_sink, | |
37 int output_freq_hz, | |
38 NumOutputChannels exptected_output_channels); | |
39 virtual ~AcmReceiveTestOldApi() {} | |
40 | |
41 // Registers the codecs with default parameters from ACM. | |
42 void RegisterDefaultCodecs(); | |
43 | |
44 // Registers codecs with payload types matching the pre-encoded NetEq test | |
45 // files. | |
46 void RegisterNetEqTestCodecs(); | |
47 | |
48 int RegisterExternalReceiveCodec(int rtp_payload_type, | |
49 AudioDecoder* external_decoder, | |
50 int sample_rate_hz, | |
51 int num_channels); | |
52 | |
53 // Runs the test and returns true if successful. | |
54 void Run(); | |
55 | |
56 protected: | |
57 // Method is called after each block of output audio is received from ACM. | |
58 virtual void AfterGetAudio() {} | |
59 | |
60 SimulatedClock clock_; | |
61 rtc::scoped_ptr<AudioCodingModule> acm_; | |
62 PacketSource* packet_source_; | |
63 AudioSink* audio_sink_; | |
64 int output_freq_hz_; | |
65 NumOutputChannels exptected_output_channels_; | |
66 | |
67 RTC_DISALLOW_COPY_AND_ASSIGN(AcmReceiveTestOldApi); | |
68 }; | |
69 | |
70 // This test toggles the output frequency every |toggle_period_ms|. The test | |
71 // starts with |output_freq_hz_1|. Except for the toggling, it does the same | |
72 // thing as AcmReceiveTestOldApi. | |
73 class AcmReceiveTestToggleOutputFreqOldApi : public AcmReceiveTestOldApi { | |
74 public: | |
75 AcmReceiveTestToggleOutputFreqOldApi( | |
76 PacketSource* packet_source, | |
77 AudioSink* audio_sink, | |
78 int output_freq_hz_1, | |
79 int output_freq_hz_2, | |
80 int toggle_period_ms, | |
81 NumOutputChannels exptected_output_channels); | |
82 | |
83 protected: | |
84 void AfterGetAudio() override; | |
85 | |
86 const int output_freq_hz_1_; | |
87 const int output_freq_hz_2_; | |
88 const int toggle_period_ms_; | |
89 int64_t last_toggle_time_ms_; | |
90 }; | |
91 | |
92 } // namespace test | |
93 } // namespace webrtc | |
94 #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_RECEIVE_TEST_H_ | |
OLD | NEW |