| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 |
| 11 | #include "modules/video_coding/packet_buffer.h" |
| 12 |
| 13 | #include <string.h> |
| 14 |
| 15 | #include <algorithm> |
| 16 | #include <cstdint> |
| 17 | #include <limits> |
| 18 | #include <utility> |
| 19 | #include <vector> |
| 20 |
| 21 | #include "absl/types/variant.h" |
| 22 | #include "api/array_view.h" |
| 23 | #include "api/rtp_packet_info.h" |
| 24 | #include "api/video/video_frame_type.h" |
| 25 | #include "common_video/h264/h264_common.h" |
| 26 | #ifndef DISABLE_H265 |
| 27 | #include "common_video/h265/h265_common.h" |
| 28 | #endif |
| 29 | #include "modules/rtp_rtcp/source/rtp_header_extensions.h" |
| 30 | #include "modules/rtp_rtcp/source/rtp_packet_received.h" |
| 31 | #include "modules/rtp_rtcp/source/rtp_video_header.h" |
| 32 | #include "modules/video_coding/codecs/h264/include/h264_globals.h" |
| 33 | #ifndef DISABLE_H265 |
| 34 | #include "modules/video_coding/codecs/h265/include/h265_globals.h" |
| 35 | #endif |
| 36 | #include "rtc_base/checks.h" |
| 37 | #include "rtc_base/logging.h" |
| 38 | #include "rtc_base/numerics/mod_ops.h" |
| 39 | #include "system_wrappers/include/clock.h" |
| 40 |
| 41 | namespace webrtc { |
| 42 | namespace video_coding { |
| 43 |
| 44 | PacketBuffer::Packet::Packet(const RtpPacketReceived& rtp_packet, |
| 45 | const RTPVideoHeader& video_header, |
| 46 | int64_t ntp_time_ms, |
| 47 | int64_t receive_time_ms) |
| 48 | : marker_bit(rtp_packet.Marker()), |
| 49 | payload_type(rtp_packet.PayloadType()), |
| 50 | seq_num(rtp_packet.SequenceNumber()), |
| 51 | timestamp(rtp_packet.Timestamp()), |
| 52 | ntp_time_ms(ntp_time_ms), |
| 53 | times_nacked(-1), |
| 54 | video_header(video_header), |
| 55 | packet_info(rtp_packet.Ssrc(), |
| 56 | rtp_packet.Csrcs(), |
| 57 | rtp_packet.Timestamp(), |
| 58 | /*audio_level=*/absl::nullopt, |
| 59 | rtp_packet.GetExtension<AbsoluteCaptureTimeExtension>(), |
| 60 | receive_time_ms) {} |
| 61 |
| 62 | PacketBuffer::PacketBuffer(Clock* clock, |
| 63 | size_t start_buffer_size, |
| 64 | size_t max_buffer_size) |
| 65 | : clock_(clock), |
| 66 | max_size_(max_buffer_size), |
| 67 | first_seq_num_(0), |
| 68 | first_packet_received_(false), |
| 69 | is_cleared_to_first_seq_num_(false), |
| 70 | buffer_(start_buffer_size), |
| 71 | sps_pps_idr_is_h264_keyframe_(false) { |
| 72 | RTC_DCHECK_LE(start_buffer_size, max_buffer_size); |
| 73 | // Buffer size must always be a power of 2. |
| 74 | RTC_DCHECK((start_buffer_size & (start_buffer_size - 1)) == 0); |
| 75 | RTC_DCHECK((max_buffer_size & (max_buffer_size - 1)) == 0); |
| 76 | } |
| 77 |
| 78 | PacketBuffer::~PacketBuffer() { |
| 79 | Clear(); |
| 80 | } |
| 81 |
| 82 | PacketBuffer::InsertResult PacketBuffer::InsertPacket( |
| 83 | std::unique_ptr<PacketBuffer::Packet> packet) { |
| 84 | PacketBuffer::InsertResult result; |
| 85 | MutexLock lock(&mutex_); |
| 86 |
| 87 | uint16_t seq_num = packet->seq_num; |
| 88 | size_t index = seq_num % buffer_.size(); |
| 89 |
| 90 | if (!first_packet_received_) { |
| 91 | first_seq_num_ = seq_num; |
| 92 | first_packet_received_ = true; |
| 93 | } else if (AheadOf(first_seq_num_, seq_num)) { |
| 94 | // If we have explicitly cleared past this packet then it's old, |
| 95 | // don't insert it, just silently ignore it. |
| 96 | if (is_cleared_to_first_seq_num_) { |
| 97 | return result; |
| 98 | } |
| 99 |
| 100 | first_seq_num_ = seq_num; |
| 101 | } |
| 102 |
| 103 | if (buffer_[index] != nullptr) { |
| 104 | // Duplicate packet, just delete the payload. |
| 105 | if (buffer_[index]->seq_num == packet->seq_num) { |
| 106 | return result; |
| 107 | } |
| 108 |
| 109 | // The packet buffer is full, try to expand the buffer. |
| 110 | while (ExpandBufferSize() && buffer_[seq_num % buffer_.size()] != nullptr) { |
| 111 | } |
| 112 | index = seq_num % buffer_.size(); |
| 113 |
| 114 | // Packet buffer is still full since we were unable to expand the buffer. |
| 115 | if (buffer_[index] != nullptr) { |
| 116 | // Clear the buffer, delete payload, and return false to signal that a |
| 117 | // new keyframe is needed. |
| 118 | RTC_LOG(LS_WARNING) << "Clear PacketBuffer and request key frame."; |
| 119 | ClearInternal(); |
| 120 | result.buffer_cleared = true; |
| 121 | return result; |
| 122 | } |
| 123 | } |
| 124 |
| 125 | int64_t now_ms = clock_->TimeInMilliseconds(); |
| 126 | last_received_packet_ms_ = now_ms; |
| 127 | if (packet->video_header.frame_type == VideoFrameType::kVideoFrameKey || |
| 128 | last_received_keyframe_rtp_timestamp_ == packet->timestamp) { |
| 129 | last_received_keyframe_packet_ms_ = now_ms; |
| 130 | last_received_keyframe_rtp_timestamp_ = packet->timestamp; |
| 131 | } |
| 132 |
| 133 | packet->continuous = false; |
| 134 | buffer_[index] = std::move(packet); |
| 135 |
| 136 | UpdateMissingPackets(seq_num); |
| 137 |
| 138 | result.packets = FindFrames(seq_num); |
| 139 | return result; |
| 140 | } |
| 141 |
| 142 | void PacketBuffer::ClearTo(uint16_t seq_num) { |
| 143 | MutexLock lock(&mutex_); |
| 144 | // We have already cleared past this sequence number, no need to do anything. |
| 145 | if (is_cleared_to_first_seq_num_ && |
| 146 | AheadOf<uint16_t>(first_seq_num_, seq_num)) { |
| 147 | return; |
| 148 | } |
| 149 |
| 150 | // If the packet buffer was cleared between a frame was created and returned. |
| 151 | if (!first_packet_received_) |
| 152 | return; |
| 153 |
| 154 | // Avoid iterating over the buffer more than once by capping the number of |
| 155 | // iterations to the |size_| of the buffer. |
| 156 | ++seq_num; |
| 157 | size_t diff = ForwardDiff<uint16_t>(first_seq_num_, seq_num); |
| 158 | size_t iterations = std::min(diff, buffer_.size()); |
| 159 | for (size_t i = 0; i < iterations; ++i) { |
| 160 | auto& stored = buffer_[first_seq_num_ % buffer_.size()]; |
| 161 | if (stored != nullptr && AheadOf<uint16_t>(seq_num, stored->seq_num)) { |
| 162 | stored = nullptr; |
| 163 | } |
| 164 | ++first_seq_num_; |
| 165 | } |
| 166 |
| 167 | // If |diff| is larger than |iterations| it means that we don't increment |
| 168 | // |first_seq_num_| until we reach |seq_num|, so we set it here. |
| 169 | first_seq_num_ = seq_num; |
| 170 |
| 171 | is_cleared_to_first_seq_num_ = true; |
| 172 | auto clear_to_it = missing_packets_.upper_bound(seq_num); |
| 173 | if (clear_to_it != missing_packets_.begin()) { |
| 174 | --clear_to_it; |
| 175 | missing_packets_.erase(missing_packets_.begin(), clear_to_it); |
| 176 | } |
| 177 | } |
| 178 |
| 179 | void PacketBuffer::Clear() { |
| 180 | MutexLock lock(&mutex_); |
| 181 | ClearInternal(); |
| 182 | } |
| 183 |
| 184 | PacketBuffer::InsertResult PacketBuffer::InsertPadding(uint16_t seq_num) { |
| 185 | PacketBuffer::InsertResult result; |
| 186 | MutexLock lock(&mutex_); |
| 187 | UpdateMissingPackets(seq_num); |
| 188 | result.packets = FindFrames(static_cast<uint16_t>(seq_num + 1)); |
| 189 | return result; |
| 190 | } |
| 191 |
| 192 | absl::optional<int64_t> PacketBuffer::LastReceivedPacketMs() const { |
| 193 | MutexLock lock(&mutex_); |
| 194 | return last_received_packet_ms_; |
| 195 | } |
| 196 |
| 197 | absl::optional<int64_t> PacketBuffer::LastReceivedKeyframePacketMs() const { |
| 198 | MutexLock lock(&mutex_); |
| 199 | return last_received_keyframe_packet_ms_; |
| 200 | } |
| 201 | void PacketBuffer::ForceSpsPpsIdrIsH264Keyframe() { |
| 202 | sps_pps_idr_is_h264_keyframe_ = true; |
| 203 | } |
| 204 | void PacketBuffer::ClearInternal() { |
| 205 | for (auto& entry : buffer_) { |
| 206 | entry = nullptr; |
| 207 | } |
| 208 |
| 209 | first_packet_received_ = false; |
| 210 | is_cleared_to_first_seq_num_ = false; |
| 211 | last_received_packet_ms_.reset(); |
| 212 | last_received_keyframe_packet_ms_.reset(); |
| 213 | newest_inserted_seq_num_.reset(); |
| 214 | missing_packets_.clear(); |
| 215 | } |
| 216 |
| 217 | bool PacketBuffer::ExpandBufferSize() { |
| 218 | if (buffer_.size() == max_size_) { |
| 219 | RTC_LOG(LS_WARNING) << "PacketBuffer is already at max size (" << max_size_ |
| 220 | << "), failed to increase size."; |
| 221 | return false; |
| 222 | } |
| 223 |
| 224 | size_t new_size = std::min(max_size_, 2 * buffer_.size()); |
| 225 | std::vector<std::unique_ptr<Packet>> new_buffer(new_size); |
| 226 | for (std::unique_ptr<Packet>& entry : buffer_) { |
| 227 | if (entry != nullptr) { |
| 228 | new_buffer[entry->seq_num % new_size] = std::move(entry); |
| 229 | } |
| 230 | } |
| 231 | buffer_ = std::move(new_buffer); |
| 232 | RTC_LOG(LS_INFO) << "PacketBuffer size expanded to " << new_size; |
| 233 | return true; |
| 234 | } |
| 235 |
| 236 | bool PacketBuffer::PotentialNewFrame(uint16_t seq_num) const { |
| 237 | size_t index = seq_num % buffer_.size(); |
| 238 | int prev_index = index > 0 ? index - 1 : buffer_.size() - 1; |
| 239 | const auto& entry = buffer_[index]; |
| 240 | const auto& prev_entry = buffer_[prev_index]; |
| 241 |
| 242 | if (entry == nullptr) |
| 243 | return false; |
| 244 | if (entry->seq_num != seq_num) |
| 245 | return false; |
| 246 | if (entry->is_first_packet_in_frame()) |
| 247 | return true; |
| 248 | if (prev_entry == nullptr) |
| 249 | return false; |
| 250 | if (prev_entry->seq_num != static_cast<uint16_t>(entry->seq_num - 1)) |
| 251 | return false; |
| 252 | if (prev_entry->timestamp != entry->timestamp) |
| 253 | return false; |
| 254 | if (prev_entry->continuous) |
| 255 | return true; |
| 256 |
| 257 | return false; |
| 258 | } |
| 259 |
| 260 | std::vector<std::unique_ptr<PacketBuffer::Packet>> PacketBuffer::FindFrames( |
| 261 | uint16_t seq_num) { |
| 262 | std::vector<std::unique_ptr<PacketBuffer::Packet>> found_frames; |
| 263 | for (size_t i = 0; i < buffer_.size() && PotentialNewFrame(seq_num); ++i) { |
| 264 | size_t index = seq_num % buffer_.size(); |
| 265 | buffer_[index]->continuous = true; |
| 266 |
| 267 | // If all packets of the frame is continuous, find the first packet of the |
| 268 | // frame and add all packets of the frame to the returned packets. |
| 269 | if (buffer_[index]->is_last_packet_in_frame()) { |
| 270 | uint16_t start_seq_num = seq_num; |
| 271 |
| 272 | // Find the start index by searching backward until the packet with |
| 273 | // the |frame_begin| flag is set. |
| 274 | int start_index = index; |
| 275 | size_t tested_packets = 0; |
| 276 | int64_t frame_timestamp = buffer_[start_index]->timestamp; |
| 277 |
| 278 | // Identify H.264 keyframes by means of SPS, PPS, and IDR. |
| 279 | bool is_h264 = buffer_[start_index]->codec() == kVideoCodecH264; |
| 280 | bool has_h264_sps = false; |
| 281 | bool has_h264_pps = false; |
| 282 | bool has_h264_idr = false; |
| 283 | bool is_h264_keyframe = false; |
| 284 |
| 285 | bool is_h265 = false; |
| 286 | #ifndef DISABLE_H265 |
| 287 | is_h265 = buffer_[start_index]->codec() == kVideoCodecH265; |
| 288 | bool has_h265_sps = false; |
| 289 | bool has_h265_pps = false; |
| 290 | bool has_h265_idr = false; |
| 291 | bool is_h265_keyframe = false; |
| 292 | #endif |
| 293 |
| 294 | int idr_width = -1; |
| 295 | int idr_height = -1; |
| 296 | while (true) { |
| 297 | ++tested_packets; |
| 298 |
| 299 | if (!is_h264 && !is_h265 && buffer_[start_index]->is_first_packet_in_frame()) |
| 300 | break; |
| 301 |
| 302 | if (is_h264) { |
| 303 | const auto* h264_header = absl::get_if<RTPVideoHeaderH264>( |
| 304 | &buffer_[start_index]->video_header.video_type_header); |
| 305 | if (!h264_header || h264_header->nalus_length >= kMaxNalusPerPacket) |
| 306 | return found_frames; |
| 307 |
| 308 | for (size_t j = 0; j < h264_header->nalus_length; ++j) { |
| 309 | if (h264_header->nalus[j].type == H264::NaluType::kSps) { |
| 310 | has_h264_sps = true; |
| 311 | } else if (h264_header->nalus[j].type == H264::NaluType::kPps) { |
| 312 | has_h264_pps = true; |
| 313 | } else if (h264_header->nalus[j].type == H264::NaluType::kIdr) { |
| 314 | has_h264_idr = true; |
| 315 | } |
| 316 | } |
| 317 | if ((sps_pps_idr_is_h264_keyframe_ && has_h264_idr && has_h264_sps && |
| 318 | has_h264_pps) || |
| 319 | (!sps_pps_idr_is_h264_keyframe_ && has_h264_idr)) { |
| 320 | is_h264_keyframe = true; |
| 321 | // Store the resolution of key frame which is the packet with |
| 322 | // smallest index and valid resolution; typically its IDR or SPS |
| 323 | // packet; there may be packet preceeding this packet, IDR's |
| 324 | // resolution will be applied to them. |
| 325 | if (buffer_[start_index]->width() > 0 && |
| 326 | buffer_[start_index]->height() > 0) { |
| 327 | idr_width = buffer_[start_index]->width(); |
| 328 | idr_height = buffer_[start_index]->height(); |
| 329 | } |
| 330 | } |
| 331 | } |
| 332 | #ifndef DISABLE_H265 |
| 333 | if (is_h265 && !is_h265_keyframe) { |
| 334 | const auto* h265_header = absl::get_if<RTPVideoHeaderH265>( |
| 335 | &buffer_[start_index]->video_header.video_type_header); |
| 336 | if (!h265_header || h265_header->nalus_length >= kMaxNalusPerPacket) |
| 337 | return found_frames; |
| 338 | for (size_t j = 0; j < h265_header->nalus_length; ++j) { |
| 339 | if (h265_header->nalus[j].type == H265::NaluType::kSps) { |
| 340 | has_h265_sps = true; |
| 341 | } else if (h265_header->nalus[j].type == H265::NaluType::kPps) { |
| 342 | has_h265_pps = true; |
| 343 | } else if (h265_header->nalus[j].type == H265::NaluType::kIdrWRadl |
| 344 | || h265_header->nalus[j].type == H265::NaluType::kIdrNLp |
| 345 | || h265_header->nalus[j].type == H265::NaluType::kCra) { |
| 346 | has_h265_idr = true; |
| 347 | } |
| 348 | } |
| 349 | if ((has_h265_sps && has_h265_pps) || has_h265_idr) { |
| 350 | is_h265_keyframe = true; |
| 351 | if (buffer_[start_index]->width() > 0 && |
| 352 | buffer_[start_index]->height() > 0) { |
| 353 | idr_width = buffer_[start_index]->width(); |
| 354 | idr_height = buffer_[start_index]->height(); |
| 355 | } |
| 356 | } |
| 357 | } |
| 358 | #endif |
| 359 |
| 360 | if (tested_packets == buffer_.size()) |
| 361 | break; |
| 362 |
| 363 | start_index = start_index > 0 ? start_index - 1 : buffer_.size() - 1; |
| 364 |
| 365 | // In the case of H264 we don't have a frame_begin bit (yes, |
| 366 | // |frame_begin| might be set to true but that is a lie). So instead |
| 367 | // we traverese backwards as long as we have a previous packet and |
| 368 | // the timestamp of that packet is the same as this one. This may cause |
| 369 | // the PacketBuffer to hand out incomplete frames. |
| 370 | // See: https://bugs.chromium.org/p/webrtc/issues/detail?id=7106 |
| 371 | if ((is_h264 || is_h265) && (buffer_[start_index] == nullptr || |
| 372 | buffer_[start_index]->timestamp != frame_timestamp)) { |
| 373 | break; |
| 374 | } |
| 375 |
| 376 | --start_seq_num; |
| 377 | } |
| 378 |
| 379 | if (is_h264) { |
| 380 | // Warn if this is an unsafe frame. |
| 381 | if (has_h264_idr && (!has_h264_sps || !has_h264_pps)) { |
| 382 | RTC_LOG(LS_WARNING) |
| 383 | << "Received H.264-IDR frame " |
| 384 | "(SPS: " |
| 385 | << has_h264_sps << ", PPS: " << has_h264_pps << "). Treating as " |
| 386 | << (sps_pps_idr_is_h264_keyframe_ ? "delta" : "key") |
| 387 | << " frame since WebRTC-SpsPpsIdrIsH264Keyframe is " |
| 388 | << (sps_pps_idr_is_h264_keyframe_ ? "enabled." : "disabled"); |
| 389 | } |
| 390 |
| 391 | // Now that we have decided whether to treat this frame as a key frame |
| 392 | // or delta frame in the frame buffer, we update the field that |
| 393 | // determines if the RtpFrameObject is a key frame or delta frame. |
| 394 | const size_t first_packet_index = start_seq_num % buffer_.size(); |
| 395 | if (is_h264_keyframe) { |
| 396 | buffer_[first_packet_index]->video_header.frame_type = |
| 397 | VideoFrameType::kVideoFrameKey; |
| 398 | if (idr_width > 0 && idr_height > 0) { |
| 399 | // IDR frame was finalized and we have the correct resolution for |
| 400 | // IDR; update first packet to have same resolution as IDR. |
| 401 | buffer_[first_packet_index]->video_header.width = idr_width; |
| 402 | buffer_[first_packet_index]->video_header.height = idr_height; |
| 403 | } |
| 404 | } else { |
| 405 | buffer_[first_packet_index]->video_header.frame_type = |
| 406 | VideoFrameType::kVideoFrameDelta; |
| 407 | } |
| 408 |
| 409 | // If this is not a keyframe, make sure there are no gaps in the packet |
| 410 | // sequence numbers up until this point. |
| 411 | if (!is_h264_keyframe && missing_packets_.upper_bound(start_seq_num) != |
| 412 | missing_packets_.begin()) { |
| 413 | return found_frames; |
| 414 | } |
| 415 | } |
| 416 |
| 417 | #ifndef DISABLE_H265 |
| 418 | if (is_h265) { |
| 419 | // Warn if this is an unsafe frame. |
| 420 | if (has_h265_idr && (!has_h265_sps || !has_h265_pps)) { |
| 421 | RTC_LOG(LS_WARNING) |
| 422 | << "Received H.265-IDR frame " |
| 423 | << "(SPS: " << has_h265_sps << ", PPS: " << has_h265_pps << "). " |
| 424 | << "Treating as delta frame since " |
| 425 | << "WebRTC-SpsPpsIdrIsH265Keyframe is always enabled."; |
| 426 | } |
| 427 |
| 428 | // Now that we have decided whether to treat this frame as a key frame |
| 429 | // or delta frame in the frame buffer, we update the field that |
| 430 | // determines if the RtpFrameObject is a key frame or delta frame. |
| 431 | const size_t first_packet_index = start_seq_num % buffer_.size(); |
| 432 | if (is_h265_keyframe) { |
| 433 | buffer_[first_packet_index]->video_header.frame_type = |
| 434 | VideoFrameType::kVideoFrameKey; |
| 435 | if (idr_width > 0 && idr_height > 0) { |
| 436 | // IDR frame was finalized and we have the correct resolution for |
| 437 | // IDR; update first packet to have same resolution as IDR. |
| 438 | buffer_[first_packet_index]->video_header.width = idr_width; |
| 439 | buffer_[first_packet_index]->video_header.height = idr_height; |
| 440 | } |
| 441 | } else { |
| 442 | buffer_[first_packet_index]->video_header.frame_type = |
| 443 | VideoFrameType::kVideoFrameDelta; |
| 444 | } |
| 445 |
| 446 | // If this is not a key frame, make sure there are no gaps in the |
| 447 | // packet sequence numbers up until this point. |
| 448 | if (!is_h265_keyframe && missing_packets_.upper_bound(start_seq_num) != |
| 449 | missing_packets_.begin()) { |
| 450 | return found_frames; |
| 451 | } |
| 452 | } |
| 453 | #endif |
| 454 | const uint16_t end_seq_num = seq_num + 1; |
| 455 | // Use uint16_t type to handle sequence number wrap around case. |
| 456 | uint16_t num_packets = end_seq_num - start_seq_num; |
| 457 | found_frames.reserve(found_frames.size() + num_packets); |
| 458 | for (uint16_t i = start_seq_num; i != end_seq_num; ++i) { |
| 459 | std::unique_ptr<Packet>& packet = buffer_[i % buffer_.size()]; |
| 460 | RTC_DCHECK(packet); |
| 461 | RTC_DCHECK_EQ(i, packet->seq_num); |
| 462 | // Ensure frame boundary flags are properly set. |
| 463 | packet->video_header.is_first_packet_in_frame = (i == start_seq_num); |
| 464 | packet->video_header.is_last_packet_in_frame = (i == seq_num); |
| 465 | found_frames.push_back(std::move(packet)); |
| 466 | } |
| 467 |
| 468 | missing_packets_.erase(missing_packets_.begin(), |
| 469 | missing_packets_.upper_bound(seq_num)); |
| 470 | } |
| 471 | ++seq_num; |
| 472 | } |
| 473 | return found_frames; |
| 474 | } |
| 475 |
| 476 | void PacketBuffer::UpdateMissingPackets(uint16_t seq_num) { |
| 477 | if (!newest_inserted_seq_num_) |
| 478 | newest_inserted_seq_num_ = seq_num; |
| 479 |
| 480 | const int kMaxPaddingAge = 1000; |
| 481 | if (AheadOf(seq_num, *newest_inserted_seq_num_)) { |
| 482 | uint16_t old_seq_num = seq_num - kMaxPaddingAge; |
| 483 | auto erase_to = missing_packets_.lower_bound(old_seq_num); |
| 484 | missing_packets_.erase(missing_packets_.begin(), erase_to); |
| 485 |
| 486 | // Guard against inserting a large amount of missing packets if there is a |
| 487 | // jump in the sequence number. |
| 488 | if (AheadOf(old_seq_num, *newest_inserted_seq_num_)) |
| 489 | *newest_inserted_seq_num_ = old_seq_num; |
| 490 |
| 491 | ++*newest_inserted_seq_num_; |
| 492 | while (AheadOf(seq_num, *newest_inserted_seq_num_)) { |
| 493 | missing_packets_.insert(*newest_inserted_seq_num_); |
| 494 | ++*newest_inserted_seq_num_; |
| 495 | } |
| 496 | } else { |
| 497 | missing_packets_.erase(seq_num); |
| 498 | } |
| 499 | } |
| 500 |
| 501 | } // namespace video_coding |
| 502 | } // namespace webrtc |
| 503 |