Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Side by Side Diff: webrtc/modules/audio_coding/neteq/packet.h

Issue 2309303002: Removed sync packet support from NetEq. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/neteq/tick_timer.h" 18 #include "webrtc/modules/audio_coding/neteq/tick_timer.h"
19 #include "webrtc/modules/include/module_common_types.h" 19 #include "webrtc/modules/include/module_common_types.h"
20 #include "webrtc/typedefs.h" 20 #include "webrtc/typedefs.h"
21 21
22 namespace webrtc { 22 namespace webrtc {
23 23
24 // Struct for holding RTP packets. 24 // Struct for holding RTP packets.
25 struct Packet { 25 struct Packet {
26 RTPHeader header; 26 RTPHeader header;
27 // Datagram excluding RTP header and header extension. 27 // Datagram excluding RTP header and header extension.
28 rtc::Buffer payload; 28 rtc::Buffer payload;
29 bool primary = true; // Primary, i.e., not redundant payload. 29 bool primary = true; // Primary, i.e., not redundant payload.
30 bool sync_packet = false;
31 std::unique_ptr<TickTimer::Stopwatch> waiting_time; 30 std::unique_ptr<TickTimer::Stopwatch> waiting_time;
32 31
33 Packet(); 32 Packet();
34 ~Packet(); 33 ~Packet();
35 34
36 // Comparison operators. Establish a packet ordering based on (1) timestamp, 35 // Comparison operators. Establish a packet ordering based on (1) timestamp,
37 // (2) sequence number, (3) regular packet vs sync-packet and (4) redundancy. 36 // (2) sequence number and (3) redundancy.
38 // Timestamp and sequence numbers are compared taking wrap-around into 37 // Timestamp and sequence numbers are compared taking wrap-around into
39 // account. If both timestamp and sequence numbers are identical and one of 38 // account. For two packets with the same sequence number and timestamp a
40 // the packets is sync-packet, the regular packet is considered earlier. For 39 // primary payload is considered "smaller" than a secondary.
41 // two regular packets with the same sequence number and timestamp a primary
42 // payload is considered "smaller" than a secondary.
43 bool operator==(const Packet& rhs) const { 40 bool operator==(const Packet& rhs) const {
44 return (this->header.timestamp == rhs.header.timestamp && 41 return (this->header.timestamp == rhs.header.timestamp &&
45 this->header.sequenceNumber == rhs.header.sequenceNumber && 42 this->header.sequenceNumber == rhs.header.sequenceNumber &&
46 this->primary == rhs.primary && 43 this->primary == rhs.primary);
47 this->sync_packet == rhs.sync_packet);
48 } 44 }
49 bool operator!=(const Packet& rhs) const { return !operator==(rhs); } 45 bool operator!=(const Packet& rhs) const { return !operator==(rhs); }
50 bool operator<(const Packet& rhs) const { 46 bool operator<(const Packet& rhs) const {
51 if (this->header.timestamp == rhs.header.timestamp) { 47 if (this->header.timestamp == rhs.header.timestamp) {
52 if (this->header.sequenceNumber == rhs.header.sequenceNumber) { 48 if (this->header.sequenceNumber == rhs.header.sequenceNumber) {
53 // Timestamp and sequence numbers are identical. A sync packet should 49 // Timestamp and sequence numbers are identical - deem the left
54 // be recognized "larger" (i.e. "later") compared to a "network packet" 50 // hand side to be "smaller" (i.e., "earlier") if it is primary, and
55 // (regular packet from network not sync-packet). If none of the packets 51 // right hand side is not.
56 // are sync-packets, then deem the left hand side to be "smaller"
57 // (i.e., "earlier") if it is primary, and right hand side is not.
58 //
59 // The condition on sync packets to be larger than "network packets,"
60 // given same RTP sequence number and timestamp, guarantees that a
61 // "network packet" to be inserted in an earlier position into
62 // |packet_buffer_| compared to a sync packet of same timestamp and
63 // sequence number.
64 if (rhs.sync_packet)
65 return true;
66 if (this->sync_packet)
67 return false;
68 return (this->primary && !rhs.primary); 52 return (this->primary && !rhs.primary);
69 } 53 }
70 return (static_cast<uint16_t>(rhs.header.sequenceNumber 54 return (static_cast<uint16_t>(rhs.header.sequenceNumber
71 - this->header.sequenceNumber) < 0xFFFF / 2); 55 - this->header.sequenceNumber) < 0xFFFF / 2);
72 } 56 }
73 return (static_cast<uint32_t>(rhs.header.timestamp 57 return (static_cast<uint32_t>(rhs.header.timestamp
74 - this->header.timestamp) < 0xFFFFFFFF / 2); 58 - this->header.timestamp) < 0xFFFFFFFF / 2);
75 } 59 }
76 bool operator>(const Packet& rhs) const { return rhs.operator<(*this); } 60 bool operator>(const Packet& rhs) const { return rhs.operator<(*this); }
77 bool operator<=(const Packet& rhs) const { return !operator>(rhs); } 61 bool operator<=(const Packet& rhs) const { return !operator>(rhs); }
78 bool operator>=(const Packet& rhs) const { return !operator<(rhs); } 62 bool operator>=(const Packet& rhs) const { return !operator<(rhs); }
79 }; 63 };
80 64
81 // A list of packets. 65 // A list of packets.
82 typedef std::list<Packet*> PacketList; 66 typedef std::list<Packet*> PacketList;
83 67
84 } // namespace webrtc 68 } // namespace webrtc
85 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_PACKET_H_ 69 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_PACKET_H_
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/neteq/neteq_unittest.cc ('k') | webrtc/modules/audio_coding/neteq/packet_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698