OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (c) 2011 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_TEST_TESTVADDTX_H_ | |
12 #define WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_TESTVADDTX_H_ | |
13 | |
14 | |
15 #include "webrtc/base/scoped_ptr.h" | |
16 #include "webrtc/common_types.h" | |
17 #include "webrtc/modules/audio_coding/main/include/audio_coding_module.h" | |
18 #include "webrtc/modules/audio_coding/main/include/audio_coding_module_typedefs.
h" | |
19 #include "webrtc/modules/audio_coding/main/test/ACMTest.h" | |
20 #include "webrtc/modules/audio_coding/main/test/Channel.h" | |
21 | |
22 namespace webrtc { | |
23 | |
24 class ActivityMonitor : public ACMVADCallback { | |
25 public: | |
26 ActivityMonitor(); | |
27 int32_t InFrameType(FrameType frame_type); | |
28 void PrintStatistics(); | |
29 void ResetStatistics(); | |
30 void GetStatistics(uint32_t* stats); | |
31 private: | |
32 // 0 - kEmptyFrame | |
33 // 1 - kAudioFrameSpeech | |
34 // 2 - kAudioFrameCN | |
35 // 3 - kVideoFrameKey (not used by audio) | |
36 // 4 - kVideoFrameDelta (not used by audio) | |
37 uint32_t counter_[5]; | |
38 }; | |
39 | |
40 | |
41 // TestVadDtx is to verify that VAD/DTX perform as they should. It runs through | |
42 // an audio file and check if the occurrence of various packet types follows | |
43 // expectation. TestVadDtx needs its derived class to implement the Perform() | |
44 // to put the test together. | |
45 class TestVadDtx : public ACMTest { | |
46 public: | |
47 static const int kOutputFreqHz = 16000; | |
48 | |
49 TestVadDtx(); | |
50 | |
51 virtual void Perform() = 0; | |
52 | |
53 protected: | |
54 void RegisterCodec(CodecInst codec_param); | |
55 | |
56 // Encoding a file and see if the numbers that various packets occur follow | |
57 // the expectation. Saves result to a file. | |
58 // expects[x] means | |
59 // -1 : do not care, | |
60 // 0 : there have been no packets of type |x|, | |
61 // 1 : there have been packets of type |x|, | |
62 // with |x| indicates the following packet types | |
63 // 0 - kEmptyFrame | |
64 // 1 - kAudioFrameSpeech | |
65 // 2 - kAudioFrameCN | |
66 // 3 - kVideoFrameKey (not used by audio) | |
67 // 4 - kVideoFrameDelta (not used by audio) | |
68 void Run(std::string in_filename, int frequency, int channels, | |
69 std::string out_filename, bool append, const int* expects); | |
70 | |
71 rtc::scoped_ptr<AudioCodingModule> acm_send_; | |
72 rtc::scoped_ptr<AudioCodingModule> acm_receive_; | |
73 rtc::scoped_ptr<Channel> channel_; | |
74 rtc::scoped_ptr<ActivityMonitor> monitor_; | |
75 }; | |
76 | |
77 // TestWebRtcVadDtx is to verify that the WebRTC VAD/DTX perform as they should. | |
78 class TestWebRtcVadDtx final : public TestVadDtx { | |
79 public: | |
80 TestWebRtcVadDtx(); | |
81 | |
82 void Perform() override; | |
83 | |
84 private: | |
85 void RunTestCases(); | |
86 void Test(bool new_outfile); | |
87 void SetVAD(bool enable_dtx, bool enable_vad, ACMVADMode vad_mode); | |
88 | |
89 bool vad_enabled_; | |
90 bool dtx_enabled_; | |
91 int output_file_num_; | |
92 }; | |
93 | |
94 // TestOpusDtx is to verify that the Opus DTX performs as it should. | |
95 class TestOpusDtx final : public TestVadDtx { | |
96 public: | |
97 void Perform() override; | |
98 }; | |
99 | |
100 } // namespace webrtc | |
101 | |
102 #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_TESTVADDTX_H_ | |
OLD | NEW |