OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... | |
30 const NetEqInput::PacketData& packet) {} | 30 const NetEqInput::PacketData& packet) {} |
31 virtual void OnGetAudioError(int error_code) {} | 31 virtual void OnGetAudioError(int error_code) {} |
32 }; | 32 }; |
33 | 33 |
34 class DefaultNetEqTestErrorCallback : public NetEqTestErrorCallback { | 34 class DefaultNetEqTestErrorCallback : public NetEqTestErrorCallback { |
35 void OnInsertPacketError(int error_code, | 35 void OnInsertPacketError(int error_code, |
36 const NetEqInput::PacketData& packet) override; | 36 const NetEqInput::PacketData& packet) override; |
37 void OnGetAudioError(int error_code) override; | 37 void OnGetAudioError(int error_code) override; |
38 }; | 38 }; |
39 | 39 |
40 class NetEqPostInsertPacket { | |
41 public: | |
42 virtual ~NetEqPostInsertPacket() = default; | |
43 virtual void AfterInsertPacket(const NetEqInput::PacketData& packet, | |
ivoc
2017/05/02 11:31:42
Why no BeforeInsertPacket? Not useful?
hlundin-webrtc
2017/05/04 12:50:07
Not at the moment. Easy enough to add if needed.
| |
44 NetEq* neteq) = 0; | |
ivoc
2017/05/02 11:31:42
Shouldn't this be a const reference as well? Or is
hlundin-webrtc
2017/05/04 12:50:07
The callback object may want to poll NetEq for sta
| |
45 }; | |
46 | |
47 class NetEqGetAudioCallback { | |
48 public: | |
49 virtual ~NetEqGetAudioCallback() = default; | |
50 virtual void BeforeGetAudio(NetEq* neteq) = 0; | |
51 virtual void AfterGetAudio(int64_t time_now_ms, | |
52 const AudioFrame& audio_frame, | |
53 bool muted, | |
54 NetEq* neteq) = 0; | |
55 }; | |
56 | |
40 // Class that provides an input--output test for NetEq. The input (both packets | 57 // 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 | 58 // and output events) is provided by a NetEqInput object, while the output is |
42 // directed to an AudioSink object. | 59 // directed to an AudioSink object. |
43 class NetEqTest { | 60 class NetEqTest { |
44 public: | 61 public: |
45 using DecoderMap = std::map<int, std::pair<NetEqDecoder, std::string> >; | 62 using DecoderMap = std::map<int, std::pair<NetEqDecoder, std::string> >; |
46 | 63 |
47 struct ExternalDecoderInfo { | 64 struct ExternalDecoderInfo { |
48 AudioDecoder* decoder; | 65 AudioDecoder* decoder; |
49 NetEqDecoder codec; | 66 NetEqDecoder codec; |
50 std::string codec_name; | 67 std::string codec_name; |
51 }; | 68 }; |
52 | 69 |
53 using ExtDecoderMap = std::map<int, ExternalDecoderInfo>; | 70 using ExtDecoderMap = std::map<int, ExternalDecoderInfo>; |
54 | 71 |
72 struct Callbacks { | |
73 NetEqTestErrorCallback* error_callback = nullptr; | |
74 NetEqPostInsertPacket* post_insert_packet = nullptr; | |
75 NetEqGetAudioCallback* get_audio_callback = nullptr; | |
76 }; | |
77 | |
55 // Sets up the test with given configuration, codec mappings, input, ouput, | 78 // Sets up the test with given configuration, codec mappings, input, ouput, |
56 // and callback objects for error reporting. | 79 // and callback objects for error reporting. |
57 NetEqTest(const NetEq::Config& config, | 80 NetEqTest(const NetEq::Config& config, |
58 const DecoderMap& codecs, | 81 const DecoderMap& codecs, |
59 const ExtDecoderMap& ext_codecs, | 82 const ExtDecoderMap& ext_codecs, |
60 std::unique_ptr<NetEqInput> input, | 83 std::unique_ptr<NetEqInput> input, |
61 std::unique_ptr<AudioSink> output, | 84 std::unique_ptr<AudioSink> output, |
62 NetEqTestErrorCallback* error_callback); | 85 Callbacks callbacks); |
AleBzk
2017/05/02 10:36:55
Copying callbacks is fine because it's just 3 poin
hlundin-webrtc
2017/05/04 12:50:07
Yes.
| |
63 | 86 |
64 ~NetEqTest() = default; | 87 ~NetEqTest() = default; |
65 | 88 |
66 // Runs the test. Returns the duration of the produced audio in ms. | 89 // Runs the test. Returns the duration of the produced audio in ms. |
67 int64_t Run(); | 90 int64_t Run(); |
68 | 91 |
69 // Returns the statistics from NetEq. | 92 // Returns the statistics from NetEq. |
70 NetEqNetworkStatistics SimulationStats(); | 93 NetEqNetworkStatistics SimulationStats(); |
71 | 94 |
72 private: | 95 private: |
73 void RegisterDecoders(const DecoderMap& codecs); | 96 void RegisterDecoders(const DecoderMap& codecs); |
74 void RegisterExternalDecoders(const ExtDecoderMap& codecs); | 97 void RegisterExternalDecoders(const ExtDecoderMap& codecs); |
75 | 98 |
76 std::unique_ptr<NetEq> neteq_; | 99 std::unique_ptr<NetEq> neteq_; |
77 std::unique_ptr<NetEqInput> input_; | 100 std::unique_ptr<NetEqInput> input_; |
78 std::unique_ptr<AudioSink> output_; | 101 std::unique_ptr<AudioSink> output_; |
79 NetEqTestErrorCallback* error_callback_ = nullptr; | 102 Callbacks callbacks_; |
80 int sample_rate_hz_; | 103 int sample_rate_hz_; |
81 }; | 104 }; |
82 | 105 |
83 } // namespace test | 106 } // namespace test |
84 } // namespace webrtc | 107 } // namespace webrtc |
85 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_TEST_H_ | 108 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_TEST_H_ |
OLD | NEW |