OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (c) 2016 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_NETEQ_TOOLS_NETEQ_TEST_H_ | |
12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_TEST_H_ | |
13 | |
14 #include <memory> | |
15 #include <map> | |
ivoc
2016/06/14 16:39:57
Wrong order.
hlundin-webrtc
2016/06/17 10:30:09
Done.
| |
16 #include <string> | |
17 #include <utility> | |
18 | |
19 #include "webrtc/modules/audio_coding/neteq/include/neteq.h" | |
20 #include "webrtc/modules/audio_coding/neteq/tools/audio_sink.h" | |
21 #include "webrtc/modules/audio_coding/neteq/tools/neteq_input.h" | |
22 | |
23 namespace webrtc { | |
24 namespace test { | |
25 | |
26 class NetEqTestErrorCallback { | |
27 public: | |
28 virtual ~NetEqTestErrorCallback() = default; | |
ivoc
2016/06/14 16:39:57
Is this needed?
hlundin-webrtc
2016/06/17 10:30:09
Compiler says yes. If I omit the explicit dtor, th
| |
29 virtual void OnInsertPacketError(int error_code, | |
30 const NetEqInput::PacketData& packet) {} | |
31 virtual void OnGetAudioError(int error_code) {} | |
32 }; | |
33 | |
34 class DefaultNetEqTestErrorCallback : public NetEqTestErrorCallback { | |
35 void OnInsertPacketError(int error_code, | |
36 const NetEqInput::PacketData& packet) override; | |
37 void OnGetAudioError(int error_code) override; | |
38 }; | |
39 | |
40 // Class that provides an input--output test for NetEq. The input (both packets | |
41 // and output events) is provided by a NetEqInput object, while the output is | |
42 // directed to an AudioSink object. | |
43 class NetEqTest { | |
44 public: | |
45 using DecoderMap = std::map<int, std::pair<NetEqDecoder, std::string> >; | |
46 | |
47 struct ExternalDecoderInfo { | |
48 AudioDecoder* decoder; | |
49 NetEqDecoder codec; | |
50 std::string codec_name; | |
51 int sample_rate_hz; | |
52 }; | |
53 | |
54 using ExtDecoderMap = std::map<int, ExternalDecoderInfo>; | |
55 | |
56 // Sets up the test with given configuration, codec mappings, input, ouput, | |
57 // and callback objects for error reporting. | |
58 NetEqTest(const NetEq::Config& config, | |
59 const DecoderMap& codecs, | |
60 const ExtDecoderMap& ext_codecs, | |
61 std::unique_ptr<NetEqInput> input, | |
62 std::unique_ptr<AudioSink> output, | |
63 NetEqTestErrorCallback* error_callback); | |
64 | |
65 ~NetEqTest() = default; | |
66 | |
67 // Runs the test. Returns the duration of the produced audio in ms. | |
68 int64_t Run(); | |
69 | |
70 // Returns the statistics from NetEq. | |
71 NetEqNetworkStatistics SimulationStats(); | |
72 | |
73 private: | |
74 void RegisterDecoders(const DecoderMap& codecs); | |
75 void RegisterExternalDecoders(const ExtDecoderMap& codecs); | |
76 | |
77 std::unique_ptr<NetEq> neteq_; | |
78 std::unique_ptr<NetEqInput> input_; | |
79 std::unique_ptr<AudioSink> output_; | |
80 NetEqTestErrorCallback* error_callback_ = nullptr; | |
81 int sample_rate_hz_; | |
82 }; | |
83 | |
84 } // namespace test | |
85 } // namespace webrtc | |
86 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_TEST_H_ | |
OLD | NEW |