OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 |
11 #ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_PACKET_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_PACKET_H_ |
12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_PACKET_H_ | 12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_PACKET_H_ |
13 | 13 |
14 #include <list> | 14 #include <list> |
15 #include <memory> | 15 #include <memory> |
16 | 16 |
17 #include "webrtc/base/buffer.h" | 17 #include "webrtc/base/buffer.h" |
| 18 #include "webrtc/modules/audio_coding/codecs/audio_decoder.h" |
18 #include "webrtc/modules/audio_coding/neteq/tick_timer.h" | 19 #include "webrtc/modules/audio_coding/neteq/tick_timer.h" |
19 #include "webrtc/modules/include/module_common_types.h" | 20 #include "webrtc/modules/include/module_common_types.h" |
20 #include "webrtc/typedefs.h" | 21 #include "webrtc/typedefs.h" |
21 | 22 |
22 namespace webrtc { | 23 namespace webrtc { |
23 | 24 |
24 // Struct for holding RTP packets. | 25 // Struct for holding RTP packets. |
25 struct Packet { | 26 struct Packet { |
26 RTPHeader header; | 27 RTPHeader header; |
27 // Datagram excluding RTP header and header extension. | 28 // Datagram excluding RTP header and header extension. |
28 rtc::Buffer payload; | 29 rtc::Buffer payload; |
29 bool primary = true; // Primary, i.e., not redundant payload. | 30 bool primary = true; // Primary, i.e., not redundant payload. |
30 std::unique_ptr<TickTimer::Stopwatch> waiting_time; | 31 std::unique_ptr<TickTimer::Stopwatch> waiting_time; |
| 32 std::unique_ptr<AudioDecoder::EncodedAudioFrame> frame; |
31 | 33 |
32 Packet(); | 34 Packet(); |
33 ~Packet(); | 35 ~Packet(); |
34 | 36 |
35 // Comparison operators. Establish a packet ordering based on (1) timestamp, | 37 // Comparison operators. Establish a packet ordering based on (1) timestamp, |
36 // (2) sequence number and (3) redundancy. | 38 // (2) sequence number and (3) redundancy. |
37 // Timestamp and sequence numbers are compared taking wrap-around into | 39 // Timestamp and sequence numbers are compared taking wrap-around into |
38 // account. For two packets with the same sequence number and timestamp a | 40 // account. For two packets with the same sequence number and timestamp a |
39 // primary payload is considered "smaller" than a secondary. | 41 // primary payload is considered "smaller" than a secondary. |
40 bool operator==(const Packet& rhs) const { | 42 bool operator==(const Packet& rhs) const { |
(...skipping 12 matching lines...) Expand all Loading... |
53 } | 55 } |
54 return (static_cast<uint16_t>(rhs.header.sequenceNumber | 56 return (static_cast<uint16_t>(rhs.header.sequenceNumber |
55 - this->header.sequenceNumber) < 0xFFFF / 2); | 57 - this->header.sequenceNumber) < 0xFFFF / 2); |
56 } | 58 } |
57 return (static_cast<uint32_t>(rhs.header.timestamp | 59 return (static_cast<uint32_t>(rhs.header.timestamp |
58 - this->header.timestamp) < 0xFFFFFFFF / 2); | 60 - this->header.timestamp) < 0xFFFFFFFF / 2); |
59 } | 61 } |
60 bool operator>(const Packet& rhs) const { return rhs.operator<(*this); } | 62 bool operator>(const Packet& rhs) const { return rhs.operator<(*this); } |
61 bool operator<=(const Packet& rhs) const { return !operator>(rhs); } | 63 bool operator<=(const Packet& rhs) const { return !operator>(rhs); } |
62 bool operator>=(const Packet& rhs) const { return !operator<(rhs); } | 64 bool operator>=(const Packet& rhs) const { return !operator<(rhs); } |
| 65 |
| 66 bool empty() const { return !frame && payload.empty(); } |
63 }; | 67 }; |
64 | 68 |
65 // A list of packets. | 69 // A list of packets. |
66 typedef std::list<Packet*> PacketList; | 70 typedef std::list<Packet*> PacketList; |
67 | 71 |
68 } // namespace webrtc | 72 } // namespace webrtc |
69 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_PACKET_H_ | 73 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_PACKET_H_ |
OLD | NEW |