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_INPUT_H_ | |
12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_INPUT_H_ | |
13 | |
14 #include <algorithm> | |
15 #include <memory> | |
16 | |
17 #include "webrtc/base/buffer.h" | |
18 #include "webrtc/base/optional.h" | |
19 #include "webrtc/modules/audio_coding/neteq/tools/packet.h" | |
20 #include "webrtc/modules/audio_coding/neteq/tools/packet_source.h" | |
21 #include "webrtc/modules/include/module_common_types.h" | |
22 | |
23 namespace webrtc { | |
24 namespace test { | |
25 | |
26 // Interface class for input to the NetEqTest class. | |
27 class NetEqInput { | |
28 public: | |
29 struct PacketData { | |
30 WebRtcRTPHeader header; | |
31 rtc::Buffer payload; | |
32 double time_ms; | |
33 }; | |
34 | |
35 virtual ~NetEqInput() = default; | |
36 | |
37 // Returns at what time (in ms) NetEq::InsertPacket should be called next, or | |
38 // empty if the source is out of packets. | |
39 virtual rtc::Optional<int64_t> NextPacketTime() const = 0; | |
40 | |
41 // Returns at what time (in ms) NetEq::GetAudio should be called next, or | |
42 // empty if no more output events are available. | |
43 virtual rtc::Optional<int64_t> NextOutputEventTime() const = 0; | |
44 | |
45 // Returns the time (in ms) for the next event from either NextPacketTime() | |
46 // or NextOutputEventTime(), or empty if both are out of events. | |
47 rtc::Optional<int64_t> NextEventTime() const { | |
48 const auto a = NextPacketTime(); | |
49 const auto b = NextOutputEventTime(); | |
50 // Return the minimum of non-empty |a| and |b|, or empty if both are empty. | |
51 if (a) { | |
52 return b ? rtc::Optional<int64_t>(std::min(*a, *b)) : a; | |
53 } | |
54 return b ? b : rtc::Optional<int64_t>(); | |
55 } | |
56 | |
57 // Returns the next packet to be inserted into NetEq. | |
58 virtual std::unique_ptr<PacketData> GetPacket() = 0; | |
ivoc
2016/06/14 16:39:56
Does this advance to the next packet? It's not ver
hlundin-webrtc
2016/06/17 10:30:08
It does advance to the next packet. I changed to P
| |
59 | |
60 // Move to the next output event. This will make NextOutputEventTime() return | |
61 // a new value (potentially the same if several output events share the same | |
62 // time). | |
63 virtual void AdvanceOutputEvent() = 0; | |
64 | |
65 // Returns true if the source has come to an end. | |
66 virtual bool ended() const = 0; | |
67 | |
68 // Returns the RTP header for the next packet, i.e., the packet that will be | |
69 // delivered next by GetPacket(). | |
70 virtual rtc::Optional<RTPHeader> NextHeader() const = 0; | |
71 }; | |
72 | |
73 } // namespace test | |
74 } // namespace webrtc | |
75 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_INPUT_H_ | |
OLD | NEW |