OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 30 matching lines...) Expand all Loading... |
41 class PacketBuffer { | 41 class PacketBuffer { |
42 public: | 42 public: |
43 static rtc::scoped_refptr<PacketBuffer> Create( | 43 static rtc::scoped_refptr<PacketBuffer> Create( |
44 Clock* clock, | 44 Clock* clock, |
45 size_t start_buffer_size, | 45 size_t start_buffer_size, |
46 size_t max_buffer_size, | 46 size_t max_buffer_size, |
47 OnReceivedFrameCallback* frame_callback); | 47 OnReceivedFrameCallback* frame_callback); |
48 | 48 |
49 virtual ~PacketBuffer(); | 49 virtual ~PacketBuffer(); |
50 | 50 |
51 // Made virtual for testing. | 51 // Returns true if |packet| is inserted into the packet buffer, |
| 52 // false otherwise. Made virtual for testing. |
52 virtual bool InsertPacket(const VCMPacket& packet); | 53 virtual bool InsertPacket(const VCMPacket& packet); |
53 void ClearTo(uint16_t seq_num); | 54 void ClearTo(uint16_t seq_num); |
54 void Clear(); | 55 void Clear(); |
55 | 56 |
56 int AddRef() const; | 57 int AddRef() const; |
57 int Release() const; | 58 int Release() const; |
58 | 59 |
59 protected: | 60 protected: |
60 // Both |start_buffer_size| and |max_buffer_size| must be a power of 2. | 61 // Both |start_buffer_size| and |max_buffer_size| must be a power of 2. |
61 PacketBuffer(Clock* clock, | 62 PacketBuffer(Clock* clock, |
(...skipping 25 matching lines...) Expand all Loading... |
87 // If this packet has been used to create a frame already. | 88 // If this packet has been used to create a frame already. |
88 bool frame_created = false; | 89 bool frame_created = false; |
89 }; | 90 }; |
90 | 91 |
91 Clock* const clock_; | 92 Clock* const clock_; |
92 | 93 |
93 // Tries to expand the buffer. | 94 // Tries to expand the buffer. |
94 bool ExpandBufferSize() EXCLUSIVE_LOCKS_REQUIRED(crit_); | 95 bool ExpandBufferSize() EXCLUSIVE_LOCKS_REQUIRED(crit_); |
95 | 96 |
96 // Test if all previous packets has arrived for the given sequence number. | 97 // Test if all previous packets has arrived for the given sequence number. |
97 bool IsContinuous(uint16_t seq_num) const EXCLUSIVE_LOCKS_REQUIRED(crit_); | 98 bool PotentialNewFrame(uint16_t seq_num) const |
| 99 EXCLUSIVE_LOCKS_REQUIRED(crit_); |
98 | 100 |
99 // Test if all packets of a frame has arrived, and if so, creates a frame. | 101 // Test if all packets of a frame has arrived, and if so, creates a frame. |
100 // May create multiple frames per invocation. | 102 // May create multiple frames per invocation. |
101 void FindFrames(uint16_t seq_num) EXCLUSIVE_LOCKS_REQUIRED(crit_); | 103 void FindFrames(uint16_t seq_num) EXCLUSIVE_LOCKS_REQUIRED(crit_); |
102 | 104 |
103 // Copy the bitstream for |frame| to |destination|. | 105 // Copy the bitstream for |frame| to |destination|. |
104 // Virtual for testing. | 106 // Virtual for testing. |
105 virtual bool GetBitstream(const RtpFrameObject& frame, uint8_t* destination); | 107 virtual bool GetBitstream(const RtpFrameObject& frame, uint8_t* destination); |
106 | 108 |
107 // Get the packet with sequence number |seq_num|. | 109 // Get the packet with sequence number |seq_num|. |
(...skipping 12 matching lines...) Expand all Loading... |
120 | 122 |
121 // The fist sequence number currently in the buffer. | 123 // The fist sequence number currently in the buffer. |
122 uint16_t first_seq_num_ GUARDED_BY(crit_); | 124 uint16_t first_seq_num_ GUARDED_BY(crit_); |
123 | 125 |
124 // The last sequence number currently in the buffer. | 126 // The last sequence number currently in the buffer. |
125 uint16_t last_seq_num_ GUARDED_BY(crit_); | 127 uint16_t last_seq_num_ GUARDED_BY(crit_); |
126 | 128 |
127 // If the packet buffer has received its first packet. | 129 // If the packet buffer has received its first packet. |
128 bool first_packet_received_ GUARDED_BY(crit_); | 130 bool first_packet_received_ GUARDED_BY(crit_); |
129 | 131 |
| 132 // If the buffer is cleared to |first_seq_num_|. |
| 133 bool is_cleared_to_first_seq_num_ GUARDED_BY(crit_); |
| 134 |
130 // Buffer that holds the inserted packets. | 135 // Buffer that holds the inserted packets. |
131 std::vector<VCMPacket> data_buffer_ GUARDED_BY(crit_); | 136 std::vector<VCMPacket> data_buffer_ GUARDED_BY(crit_); |
132 | 137 |
133 // Buffer that holds the information about which slot that is currently in use | 138 // Buffer that holds the information about which slot that is currently in use |
134 // and information needed to determine the continuity between packets. | 139 // and information needed to determine the continuity between packets. |
135 std::vector<ContinuityInfo> sequence_buffer_ GUARDED_BY(crit_); | 140 std::vector<ContinuityInfo> sequence_buffer_ GUARDED_BY(crit_); |
136 | 141 |
137 // Called when a received frame is found. | 142 // Called when a received frame is found. |
138 OnReceivedFrameCallback* const received_frame_callback_; | 143 OnReceivedFrameCallback* const received_frame_callback_; |
139 | 144 |
140 mutable volatile int ref_count_ = 0; | 145 mutable volatile int ref_count_ = 0; |
141 }; | 146 }; |
142 | 147 |
143 } // namespace video_coding | 148 } // namespace video_coding |
144 } // namespace webrtc | 149 } // namespace webrtc |
145 | 150 |
146 #endif // WEBRTC_MODULES_VIDEO_CODING_PACKET_BUFFER_H_ | 151 #endif // WEBRTC_MODULES_VIDEO_CODING_PACKET_BUFFER_H_ |
OLD | NEW |