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 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 // Returns nullptr if packet is not found. | 42 // Returns nullptr if packet is not found. |
43 // |min_elapsed_time_ms| is the minimum time that must have elapsed since | 43 // |min_elapsed_time_ms| is the minimum time that must have elapsed since |
44 // the last time the packet was resent (parameter is ignored if set to zero). | 44 // the last time the packet was resent (parameter is ignored if set to zero). |
45 // If the packet is found but the minimum time has not elapsed, returns | 45 // If the packet is found but the minimum time has not elapsed, returns |
46 // nullptr. | 46 // nullptr. |
47 std::unique_ptr<RtpPacketToSend> GetPacketAndSetSendTime( | 47 std::unique_ptr<RtpPacketToSend> GetPacketAndSetSendTime( |
48 uint16_t sequence_number, | 48 uint16_t sequence_number, |
49 int64_t min_elapsed_time_ms, | 49 int64_t min_elapsed_time_ms, |
50 bool retransmit); | 50 bool retransmit); |
51 | 51 |
| 52 // Gets the packet, of which the size is closest to |packet_size|. |
52 std::unique_ptr<RtpPacketToSend> GetBestFittingPacket( | 53 std::unique_ptr<RtpPacketToSend> GetBestFittingPacket( |
53 size_t packet_size) const; | 54 size_t packet_size) const { |
| 55 return GetBestFittingPacket(packet_size, true); |
| 56 } |
| 57 |
| 58 // Gets the best fitting packet. When |include_header| is true, it gets the |
| 59 // packet of which the total size is closest to |packet_size|, otherwise, it |
| 60 // fits the payload size. |
| 61 // TODO(minyue): Remove this method when we start to always include header. |
| 62 std::unique_ptr<RtpPacketToSend> GetBestFittingPacket( |
| 63 size_t packet_size, |
| 64 bool include_header) const; |
54 | 65 |
55 bool HasRtpPacket(uint16_t sequence_number) const; | 66 bool HasRtpPacket(uint16_t sequence_number) const; |
56 | 67 |
57 private: | 68 private: |
58 struct StoredPacket { | 69 struct StoredPacket { |
59 uint16_t sequence_number = 0; | 70 uint16_t sequence_number = 0; |
60 int64_t send_time = 0; | 71 int64_t send_time = 0; |
61 StorageType storage_type = kDontRetransmit; | 72 StorageType storage_type = kDontRetransmit; |
62 bool has_been_retransmitted = false; | 73 bool has_been_retransmitted = false; |
63 | 74 |
64 std::unique_ptr<RtpPacketToSend> packet; | 75 std::unique_ptr<RtpPacketToSend> packet; |
65 }; | 76 }; |
66 | 77 |
67 std::unique_ptr<RtpPacketToSend> GetPacket(int index) const | 78 std::unique_ptr<RtpPacketToSend> GetPacket(int index) const |
68 EXCLUSIVE_LOCKS_REQUIRED(critsect_); | 79 EXCLUSIVE_LOCKS_REQUIRED(critsect_); |
69 void Allocate(size_t number_to_store) EXCLUSIVE_LOCKS_REQUIRED(critsect_); | 80 void Allocate(size_t number_to_store) EXCLUSIVE_LOCKS_REQUIRED(critsect_); |
70 void Free() EXCLUSIVE_LOCKS_REQUIRED(critsect_); | 81 void Free() EXCLUSIVE_LOCKS_REQUIRED(critsect_); |
71 bool FindSeqNum(uint16_t sequence_number, int* index) const | 82 bool FindSeqNum(uint16_t sequence_number, int* index) const |
72 EXCLUSIVE_LOCKS_REQUIRED(critsect_); | 83 EXCLUSIVE_LOCKS_REQUIRED(critsect_); |
73 int FindBestFittingPacket(size_t size) const | 84 int FindBestFittingPacket(size_t size, bool include_header) const |
74 EXCLUSIVE_LOCKS_REQUIRED(critsect_); | 85 EXCLUSIVE_LOCKS_REQUIRED(critsect_); |
75 | 86 |
76 Clock* clock_; | 87 Clock* clock_; |
77 rtc::CriticalSection critsect_; | 88 rtc::CriticalSection critsect_; |
78 bool store_ GUARDED_BY(critsect_); | 89 bool store_ GUARDED_BY(critsect_); |
79 uint32_t prev_index_ GUARDED_BY(critsect_); | 90 uint32_t prev_index_ GUARDED_BY(critsect_); |
80 std::vector<StoredPacket> stored_packets_ GUARDED_BY(critsect_); | 91 std::vector<StoredPacket> stored_packets_ GUARDED_BY(critsect_); |
81 | 92 |
82 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RtpPacketHistory); | 93 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RtpPacketHistory); |
83 }; | 94 }; |
84 } // namespace webrtc | 95 } // namespace webrtc |
85 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_PACKET_HISTORY_H_ | 96 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_PACKET_HISTORY_H_ |
OLD | NEW |