Chromium Code Reviews| 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. The next packet is | |
|
ivoc
2016/06/21 07:59:58
In the first sentence when you say "next packet" y
hlundin-webrtc
2016/06/21 09:12:20
Good point. I re-wrote this.
| |
| 58 // pre-fetched in the NetEqInput object, such that future calls to | |
| 59 // NextPacketTime() or NextHeader() will return information from the next | |
| 60 // packet in line. | |
| 61 virtual std::unique_ptr<PacketData> PopPacket() = 0; | |
| 62 | |
| 63 // Move to the next output event. This will make NextOutputEventTime() return | |
| 64 // a new value (potentially the same if several output events share the same | |
| 65 // time). | |
| 66 virtual void AdvanceOutputEvent() = 0; | |
| 67 | |
| 68 // Returns true if the source has come to an end. | |
| 69 virtual bool ended() const = 0; | |
| 70 | |
| 71 // Returns the RTP header for the next packet, i.e., the packet that will be | |
| 72 // delivered next by GetPacket(). | |
|
ivoc
2016/06/21 07:59:58
GetPacket() -> PopPacket().
hlundin-webrtc
2016/06/21 09:12:20
Done.
| |
| 73 virtual rtc::Optional<RTPHeader> NextHeader() const = 0; | |
| 74 }; | |
| 75 | |
| 76 } // namespace test | |
| 77 } // namespace webrtc | |
| 78 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_INPUT_H_ | |
| OLD | NEW |