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/codecs/audio_decoder.h" |
19 #include "webrtc/modules/audio_coding/neteq/tick_timer.h" | 19 #include "webrtc/modules/audio_coding/neteq/tick_timer.h" |
20 #include "webrtc/modules/include/module_common_types.h" | 20 #include "webrtc/modules/include/module_common_types.h" |
hlundin-webrtc
2016/10/12 20:39:57
Can you ditch module_common_types.h now?
ossu
2016/10/12 21:46:02
Yes, but I'll have to put it in packet_buffer.h in
hlundin-webrtc
2016/10/13 07:54:18
Acknowledged.
| |
21 #include "webrtc/typedefs.h" | 21 #include "webrtc/typedefs.h" |
22 | 22 |
23 namespace webrtc { | 23 namespace webrtc { |
24 | 24 |
25 // Struct for holding RTP packets. | 25 // Struct for holding RTP packets. |
26 struct Packet { | 26 struct Packet { |
27 struct Priority { | 27 struct Priority { |
28 Priority() : codec_level(0), red_level(0) {} | 28 Priority() : codec_level(0), red_level(0) {} |
29 Priority(int codec_level, int red_level) | 29 Priority(int codec_level, int red_level) |
30 : codec_level(codec_level), red_level(red_level) { | 30 : codec_level(codec_level), red_level(red_level) { |
(...skipping 28 matching lines...) Expand all Loading... | |
59 bool operator<=(const Priority& b) const { return !(b > *this); } | 59 bool operator<=(const Priority& b) const { return !(b > *this); } |
60 bool operator>=(const Priority& b) const { return !(b < *this); } | 60 bool operator>=(const Priority& b) const { return !(b < *this); } |
61 | 61 |
62 private: | 62 private: |
63 void CheckInvariant() const { | 63 void CheckInvariant() const { |
64 RTC_DCHECK_GE(codec_level, 0); | 64 RTC_DCHECK_GE(codec_level, 0); |
65 RTC_DCHECK_GE(red_level, 0); | 65 RTC_DCHECK_GE(red_level, 0); |
66 } | 66 } |
67 }; | 67 }; |
68 | 68 |
69 RTPHeader header; | 69 uint32_t timestamp; |
70 uint16_t sequenceNumber; | |
hlundin-webrtc
2016/10/12 20:39:58
Please, make the member names follow the style gui
ossu
2016/10/12 21:46:02
Payload types are uint8_t in so many other places,
hlundin-webrtc
2016/10/13 07:54:18
Acknowledged.
| |
71 uint8_t payloadType; | |
70 // Datagram excluding RTP header and header extension. | 72 // Datagram excluding RTP header and header extension. |
71 rtc::Buffer payload; | 73 rtc::Buffer payload; |
72 Priority priority; | 74 Priority priority; |
73 std::unique_ptr<TickTimer::Stopwatch> waiting_time; | 75 std::unique_ptr<TickTimer::Stopwatch> waiting_time; |
74 std::unique_ptr<AudioDecoder::EncodedAudioFrame> frame; | 76 std::unique_ptr<AudioDecoder::EncodedAudioFrame> frame; |
75 | 77 |
76 Packet(); | 78 Packet(); |
77 ~Packet(); | 79 ~Packet(); |
78 | 80 |
79 // Comparison operators. Establish a packet ordering based on (1) timestamp, | 81 // Comparison operators. Establish a packet ordering based on (1) timestamp, |
80 // (2) sequence number and (3) redundancy. | 82 // (2) sequence number and (3) redundancy. |
81 // Timestamp and sequence numbers are compared taking wrap-around into | 83 // Timestamp and sequence numbers are compared taking wrap-around into |
82 // account. For two packets with the same sequence number and timestamp a | 84 // account. For two packets with the same sequence number and timestamp a |
83 // primary payload is considered "smaller" than a secondary. | 85 // primary payload is considered "smaller" than a secondary. |
84 bool operator==(const Packet& rhs) const { | 86 bool operator==(const Packet& rhs) const { |
85 return (this->header.timestamp == rhs.header.timestamp && | 87 return (this->timestamp == rhs.timestamp && |
86 this->header.sequenceNumber == rhs.header.sequenceNumber && | 88 this->sequenceNumber == rhs.sequenceNumber && |
87 this->priority == rhs.priority); | 89 this->priority == rhs.priority); |
88 } | 90 } |
89 bool operator!=(const Packet& rhs) const { return !operator==(rhs); } | 91 bool operator!=(const Packet& rhs) const { return !operator==(rhs); } |
90 bool operator<(const Packet& rhs) const { | 92 bool operator<(const Packet& rhs) const { |
91 if (this->header.timestamp == rhs.header.timestamp) { | 93 if (this->timestamp == rhs.timestamp) { |
92 if (this->header.sequenceNumber == rhs.header.sequenceNumber) { | 94 if (this->sequenceNumber == rhs.sequenceNumber) { |
93 // Timestamp and sequence numbers are identical - deem the left hand | 95 // Timestamp and sequence numbers are identical - deem the left hand |
94 // side to be "smaller" (i.e., "earlier") if it has higher priority. | 96 // side to be "smaller" (i.e., "earlier") if it has higher priority. |
95 return this->priority < rhs.priority; | 97 return this->priority < rhs.priority; |
96 } | 98 } |
97 return (static_cast<uint16_t>(rhs.header.sequenceNumber | 99 return (static_cast<uint16_t>(rhs.sequenceNumber - this->sequenceNumber) < |
98 - this->header.sequenceNumber) < 0xFFFF / 2); | 100 0xFFFF / 2); |
99 } | 101 } |
100 return (static_cast<uint32_t>(rhs.header.timestamp | 102 return (static_cast<uint32_t>(rhs.timestamp - this->timestamp) < |
101 - this->header.timestamp) < 0xFFFFFFFF / 2); | 103 0xFFFFFFFF / 2); |
102 } | 104 } |
103 bool operator>(const Packet& rhs) const { return rhs.operator<(*this); } | 105 bool operator>(const Packet& rhs) const { return rhs.operator<(*this); } |
104 bool operator<=(const Packet& rhs) const { return !operator>(rhs); } | 106 bool operator<=(const Packet& rhs) const { return !operator>(rhs); } |
105 bool operator>=(const Packet& rhs) const { return !operator<(rhs); } | 107 bool operator>=(const Packet& rhs) const { return !operator<(rhs); } |
106 | 108 |
107 bool empty() const { return !frame && payload.empty(); } | 109 bool empty() const { return !frame && payload.empty(); } |
108 }; | 110 }; |
109 | 111 |
110 // A list of packets. | 112 // A list of packets. |
111 typedef std::list<Packet*> PacketList; | 113 typedef std::list<Packet*> PacketList; |
112 | 114 |
113 } // namespace webrtc | 115 } // namespace webrtc |
114 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_PACKET_H_ | 116 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_PACKET_H_ |
OLD | NEW |