Line data Source code
1 : /*
2 : * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 : *
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
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 "webrtc/modules/video_coding/session_info.h"
12 :
13 : #include "webrtc/base/logging.h"
14 : #include "webrtc/modules/video_coding/packet.h"
15 :
16 : namespace webrtc {
17 :
18 : namespace {
19 :
20 0 : uint16_t BufferToUWord16(const uint8_t* dataBuffer) {
21 0 : return (dataBuffer[0] << 8) | dataBuffer[1];
22 : }
23 :
24 : } // namespace
25 :
26 0 : VCMSessionInfo::VCMSessionInfo()
27 : : session_nack_(false),
28 : complete_(false),
29 : decodable_(false),
30 : frame_type_(kVideoFrameDelta),
31 : packets_(),
32 : empty_seq_num_low_(-1),
33 : empty_seq_num_high_(-1),
34 : first_packet_seq_num_(-1),
35 0 : last_packet_seq_num_(-1) {}
36 :
37 0 : void VCMSessionInfo::UpdateDataPointers(const uint8_t* old_base_ptr,
38 : const uint8_t* new_base_ptr) {
39 0 : for (PacketIterator it = packets_.begin(); it != packets_.end(); ++it)
40 0 : if ((*it).dataPtr != NULL) {
41 0 : assert(old_base_ptr != NULL && new_base_ptr != NULL);
42 0 : (*it).dataPtr = new_base_ptr + ((*it).dataPtr - old_base_ptr);
43 : }
44 0 : }
45 :
46 0 : int VCMSessionInfo::LowSequenceNumber() const {
47 0 : if (packets_.empty())
48 0 : return empty_seq_num_low_;
49 0 : return packets_.front().seqNum;
50 : }
51 :
52 0 : int VCMSessionInfo::HighSequenceNumber() const {
53 0 : if (packets_.empty())
54 0 : return empty_seq_num_high_;
55 0 : if (empty_seq_num_high_ == -1)
56 0 : return packets_.back().seqNum;
57 0 : return LatestSequenceNumber(packets_.back().seqNum, empty_seq_num_high_);
58 : }
59 :
60 0 : int VCMSessionInfo::PictureId() const {
61 0 : if (packets_.empty())
62 0 : return kNoPictureId;
63 0 : if (packets_.front().video_header.codec == kRtpVideoVp8) {
64 0 : return packets_.front().video_header.codecHeader.VP8.pictureId;
65 0 : } else if (packets_.front().video_header.codec == kRtpVideoVp9) {
66 0 : return packets_.front().video_header.codecHeader.VP9.picture_id;
67 : } else {
68 0 : return kNoPictureId;
69 : }
70 : }
71 :
72 0 : int VCMSessionInfo::TemporalId() const {
73 0 : if (packets_.empty())
74 0 : return kNoTemporalIdx;
75 0 : if (packets_.front().video_header.codec == kRtpVideoVp8) {
76 0 : return packets_.front().video_header.codecHeader.VP8.temporalIdx;
77 0 : } else if (packets_.front().video_header.codec == kRtpVideoVp9) {
78 0 : return packets_.front().video_header.codecHeader.VP9.temporal_idx;
79 : } else {
80 0 : return kNoTemporalIdx;
81 : }
82 : }
83 :
84 0 : bool VCMSessionInfo::LayerSync() const {
85 0 : if (packets_.empty())
86 0 : return false;
87 0 : if (packets_.front().video_header.codec == kRtpVideoVp8) {
88 0 : return packets_.front().video_header.codecHeader.VP8.layerSync;
89 0 : } else if (packets_.front().video_header.codec == kRtpVideoVp9) {
90 0 : return packets_.front().video_header.codecHeader.VP9.temporal_up_switch;
91 : } else {
92 0 : return false;
93 : }
94 : }
95 :
96 0 : int VCMSessionInfo::Tl0PicId() const {
97 0 : if (packets_.empty())
98 0 : return kNoTl0PicIdx;
99 0 : if (packets_.front().video_header.codec == kRtpVideoVp8) {
100 0 : return packets_.front().video_header.codecHeader.VP8.tl0PicIdx;
101 0 : } else if (packets_.front().video_header.codec == kRtpVideoVp9) {
102 0 : return packets_.front().video_header.codecHeader.VP9.tl0_pic_idx;
103 : } else {
104 0 : return kNoTl0PicIdx;
105 : }
106 : }
107 :
108 0 : bool VCMSessionInfo::NonReference() const {
109 0 : if (packets_.empty() || packets_.front().video_header.codec != kRtpVideoVp8)
110 0 : return false;
111 0 : return packets_.front().video_header.codecHeader.VP8.nonReference;
112 : }
113 :
114 0 : std::vector<NaluInfo> VCMSessionInfo::GetNaluInfos() const {
115 0 : if (packets_.empty() || packets_.front().video_header.codec != kRtpVideoH264)
116 0 : return std::vector<NaluInfo>();
117 0 : std::vector<NaluInfo> nalu_infos;
118 0 : for (const VCMPacket& packet : packets_) {
119 0 : for (size_t i = 0; i < packet.video_header.codecHeader.H264.nalus_length;
120 : ++i) {
121 0 : nalu_infos.push_back(packet.video_header.codecHeader.H264.nalus[i]);
122 : }
123 : }
124 0 : return nalu_infos;
125 : }
126 :
127 0 : void VCMSessionInfo::SetGofInfo(const GofInfoVP9& gof_info, size_t idx) {
128 0 : if (packets_.empty() || packets_.front().video_header.codec != kRtpVideoVp9 ||
129 0 : packets_.front().video_header.codecHeader.VP9.flexible_mode) {
130 0 : return;
131 : }
132 0 : packets_.front().video_header.codecHeader.VP9.temporal_idx =
133 0 : gof_info.temporal_idx[idx];
134 0 : packets_.front().video_header.codecHeader.VP9.temporal_up_switch =
135 0 : gof_info.temporal_up_switch[idx];
136 0 : packets_.front().video_header.codecHeader.VP9.num_ref_pics =
137 0 : gof_info.num_ref_pics[idx];
138 0 : for (uint8_t i = 0; i < gof_info.num_ref_pics[idx]; ++i) {
139 0 : packets_.front().video_header.codecHeader.VP9.pid_diff[i] =
140 0 : gof_info.pid_diff[idx][i];
141 : }
142 : }
143 :
144 0 : void VCMSessionInfo::Reset() {
145 0 : session_nack_ = false;
146 0 : complete_ = false;
147 0 : decodable_ = false;
148 0 : frame_type_ = kVideoFrameDelta;
149 0 : packets_.clear();
150 0 : empty_seq_num_low_ = -1;
151 0 : empty_seq_num_high_ = -1;
152 0 : first_packet_seq_num_ = -1;
153 0 : last_packet_seq_num_ = -1;
154 0 : }
155 :
156 0 : size_t VCMSessionInfo::SessionLength() const {
157 0 : size_t length = 0;
158 0 : for (PacketIteratorConst it = packets_.begin(); it != packets_.end(); ++it)
159 0 : length += (*it).sizeBytes;
160 0 : return length;
161 : }
162 :
163 0 : int VCMSessionInfo::NumPackets() const {
164 0 : return packets_.size();
165 : }
166 :
167 0 : size_t VCMSessionInfo::InsertBuffer(uint8_t* frame_buffer,
168 : PacketIterator packet_it) {
169 0 : VCMPacket& packet = *packet_it;
170 0 : PacketIterator it;
171 :
172 : // Calculate the offset into the frame buffer for this packet.
173 0 : size_t offset = 0;
174 0 : for (it = packets_.begin(); it != packet_it; ++it)
175 0 : offset += (*it).sizeBytes;
176 :
177 : // Set the data pointer to pointing to the start of this packet in the
178 : // frame buffer.
179 0 : const uint8_t* packet_buffer = packet.dataPtr;
180 0 : packet.dataPtr = frame_buffer + offset;
181 :
182 : // We handle H.264 STAP-A packets in a special way as we need to remove the
183 : // two length bytes between each NAL unit, and potentially add start codes.
184 : // TODO(pbos): Remove H264 parsing from this step and use a fragmentation
185 : // header supplied by the H264 depacketizer.
186 0 : const size_t kH264NALHeaderLengthInBytes = 1;
187 0 : const size_t kLengthFieldLength = 2;
188 0 : if (packet.video_header.codec == kRtpVideoH264 &&
189 0 : packet.video_header.codecHeader.H264.packetization_type == kH264StapA) {
190 0 : size_t required_length = 0;
191 0 : const uint8_t* nalu_ptr = packet_buffer + kH264NALHeaderLengthInBytes;
192 : // Must check that incoming data length doesn't extend past end of buffer.
193 : // We allow for 100 bytes of expansion due to startcodes being longer than
194 : // length fields.
195 0 : while (nalu_ptr + kLengthFieldLength <= packet_buffer + packet.sizeBytes) {
196 0 : size_t length = BufferToUWord16(nalu_ptr);
197 0 : if (nalu_ptr + kLengthFieldLength + length <= packet_buffer + packet.sizeBytes) {
198 0 : required_length +=
199 0 : length + (packet.insertStartCode ? kH264StartCodeLengthBytes : 0);
200 0 : nalu_ptr += kLengthFieldLength + length;
201 : } else {
202 : // Something is very wrong!
203 0 : LOG(LS_ERROR) << "Failed to insert packet due to corrupt H264 STAP-A";
204 0 : return 0;
205 : }
206 : }
207 0 : ShiftSubsequentPackets(packet_it, required_length);
208 0 : nalu_ptr = packet_buffer + kH264NALHeaderLengthInBytes;
209 0 : uint8_t* frame_buffer_ptr = frame_buffer + offset;
210 : // we already know we won't go past end-of-buffer
211 0 : while (nalu_ptr + kLengthFieldLength <= packet_buffer + packet.sizeBytes) {
212 0 : size_t length = BufferToUWord16(nalu_ptr);
213 0 : nalu_ptr += kLengthFieldLength;
214 0 : frame_buffer_ptr += Insert(nalu_ptr, length, packet.insertStartCode,
215 : const_cast<uint8_t*>(frame_buffer_ptr));
216 0 : nalu_ptr += length;
217 : }
218 0 : packet.sizeBytes = required_length;
219 0 : return packet.sizeBytes;
220 : }
221 0 : ShiftSubsequentPackets(
222 0 : packet_it, packet.sizeBytes +
223 0 : (packet.insertStartCode ? kH264StartCodeLengthBytes : 0));
224 :
225 0 : packet.sizeBytes =
226 0 : Insert(packet_buffer, packet.sizeBytes, packet.insertStartCode,
227 0 : const_cast<uint8_t*>(packet.dataPtr));
228 0 : return packet.sizeBytes;
229 : }
230 :
231 0 : size_t VCMSessionInfo::Insert(const uint8_t* buffer,
232 : size_t length,
233 : bool insert_start_code,
234 : uint8_t* frame_buffer) {
235 0 : if (insert_start_code) {
236 0 : const unsigned char startCode[] = {0, 0, 0, 1};
237 0 : memcpy(frame_buffer, startCode, kH264StartCodeLengthBytes);
238 : }
239 0 : memcpy(frame_buffer + (insert_start_code ? kH264StartCodeLengthBytes : 0),
240 0 : buffer, length);
241 0 : length += (insert_start_code ? kH264StartCodeLengthBytes : 0);
242 :
243 0 : return length;
244 : }
245 :
246 0 : void VCMSessionInfo::ShiftSubsequentPackets(PacketIterator it,
247 : int steps_to_shift) {
248 0 : ++it;
249 0 : if (it == packets_.end())
250 0 : return;
251 0 : uint8_t* first_packet_ptr = const_cast<uint8_t*>((*it).dataPtr);
252 0 : int shift_length = 0;
253 : // Calculate the total move length and move the data pointers in advance.
254 0 : for (; it != packets_.end(); ++it) {
255 0 : shift_length += (*it).sizeBytes;
256 0 : if ((*it).dataPtr != NULL)
257 0 : (*it).dataPtr += steps_to_shift;
258 : }
259 0 : memmove(first_packet_ptr + steps_to_shift, first_packet_ptr, shift_length);
260 : }
261 :
262 0 : void VCMSessionInfo::UpdateCompleteSession() {
263 0 : if (HaveFirstPacket() && HaveLastPacket()) {
264 : // Do we have all the packets in this session?
265 0 : bool complete_session = true;
266 0 : PacketIterator it = packets_.begin();
267 0 : PacketIterator prev_it = it;
268 0 : ++it;
269 0 : for (; it != packets_.end(); ++it) {
270 0 : if (!InSequence(it, prev_it)) {
271 0 : complete_session = false;
272 0 : break;
273 : }
274 0 : prev_it = it;
275 : }
276 0 : complete_ = complete_session;
277 : }
278 0 : }
279 :
280 0 : void VCMSessionInfo::UpdateDecodableSession(const FrameData& frame_data) {
281 : // Irrelevant if session is already complete or decodable
282 0 : if (complete_ || decodable_)
283 0 : return;
284 : // TODO(agalusza): Account for bursty loss.
285 : // TODO(agalusza): Refine these values to better approximate optimal ones.
286 : // Do not decode frames if the RTT is lower than this.
287 0 : const int64_t kRttThreshold = 100;
288 : // Do not decode frames if the number of packets is between these two
289 : // thresholds.
290 0 : const float kLowPacketPercentageThreshold = 0.2f;
291 0 : const float kHighPacketPercentageThreshold = 0.8f;
292 0 : if (frame_data.rtt_ms < kRttThreshold || frame_type_ == kVideoFrameKey ||
293 0 : !HaveFirstPacket() ||
294 0 : (NumPackets() <= kHighPacketPercentageThreshold *
295 0 : frame_data.rolling_average_packets_per_frame &&
296 0 : NumPackets() > kLowPacketPercentageThreshold *
297 0 : frame_data.rolling_average_packets_per_frame))
298 0 : return;
299 :
300 0 : decodable_ = true;
301 : }
302 :
303 0 : bool VCMSessionInfo::complete() const {
304 0 : return complete_;
305 : }
306 :
307 0 : bool VCMSessionInfo::decodable() const {
308 0 : return decodable_;
309 : }
310 :
311 : // Find the end of the NAL unit which the packet pointed to by |packet_it|
312 : // belongs to. Returns an iterator to the last packet of the frame if the end
313 : // of the NAL unit wasn't found.
314 0 : VCMSessionInfo::PacketIterator VCMSessionInfo::FindNaluEnd(
315 : PacketIterator packet_it) const {
316 0 : if ((*packet_it).completeNALU == kNaluEnd ||
317 0 : (*packet_it).completeNALU == kNaluComplete) {
318 0 : return packet_it;
319 : }
320 : // Find the end of the NAL unit.
321 0 : for (; packet_it != packets_.end(); ++packet_it) {
322 0 : if (((*packet_it).completeNALU == kNaluComplete &&
323 0 : (*packet_it).sizeBytes > 0) ||
324 : // Found next NALU.
325 0 : (*packet_it).completeNALU == kNaluStart)
326 0 : return --packet_it;
327 0 : if ((*packet_it).completeNALU == kNaluEnd)
328 0 : return packet_it;
329 : }
330 : // The end wasn't found.
331 0 : return --packet_it;
332 : }
333 :
334 0 : size_t VCMSessionInfo::DeletePacketData(PacketIterator start,
335 : PacketIterator end) {
336 0 : size_t bytes_to_delete = 0; // The number of bytes to delete.
337 0 : PacketIterator packet_after_end = end;
338 0 : ++packet_after_end;
339 :
340 : // Get the number of bytes to delete.
341 : // Clear the size of these packets.
342 0 : for (PacketIterator it = start; it != packet_after_end; ++it) {
343 0 : bytes_to_delete += (*it).sizeBytes;
344 0 : (*it).sizeBytes = 0;
345 0 : (*it).dataPtr = NULL;
346 : }
347 0 : if (bytes_to_delete > 0)
348 0 : ShiftSubsequentPackets(end, -static_cast<int>(bytes_to_delete));
349 0 : return bytes_to_delete;
350 : }
351 :
352 0 : VCMSessionInfo::PacketIterator VCMSessionInfo::FindNextPartitionBeginning(
353 : PacketIterator it) const {
354 0 : while (it != packets_.end()) {
355 0 : if ((*it).video_header.codecHeader.VP8.beginningOfPartition) {
356 0 : return it;
357 : }
358 0 : ++it;
359 : }
360 0 : return it;
361 : }
362 :
363 0 : VCMSessionInfo::PacketIterator VCMSessionInfo::FindPartitionEnd(
364 : PacketIterator it) const {
365 0 : assert((*it).codec == kVideoCodecVP8);
366 0 : PacketIterator prev_it = it;
367 0 : const int partition_id = (*it).video_header.codecHeader.VP8.partitionId;
368 0 : while (it != packets_.end()) {
369 0 : bool beginning = (*it).video_header.codecHeader.VP8.beginningOfPartition;
370 0 : int current_partition_id = (*it).video_header.codecHeader.VP8.partitionId;
371 0 : bool packet_loss_found = (!beginning && !InSequence(it, prev_it));
372 0 : if (packet_loss_found ||
373 0 : (beginning && current_partition_id != partition_id)) {
374 : // Missing packet, the previous packet was the last in sequence.
375 0 : return prev_it;
376 : }
377 0 : prev_it = it;
378 0 : ++it;
379 : }
380 0 : return prev_it;
381 : }
382 :
383 0 : bool VCMSessionInfo::InSequence(const PacketIterator& packet_it,
384 : const PacketIterator& prev_packet_it) {
385 : // If the two iterators are pointing to the same packet they are considered
386 : // to be in sequence.
387 0 : return (packet_it == prev_packet_it ||
388 0 : (static_cast<uint16_t>((*prev_packet_it).seqNum + 1) ==
389 0 : (*packet_it).seqNum));
390 : }
391 :
392 0 : size_t VCMSessionInfo::MakeDecodable() {
393 0 : size_t return_length = 0;
394 0 : if (packets_.empty()) {
395 0 : return 0;
396 : }
397 0 : PacketIterator it = packets_.begin();
398 : // Make sure we remove the first NAL unit if it's not decodable.
399 0 : if ((*it).completeNALU == kNaluIncomplete || (*it).completeNALU == kNaluEnd) {
400 0 : PacketIterator nalu_end = FindNaluEnd(it);
401 0 : return_length += DeletePacketData(it, nalu_end);
402 0 : it = nalu_end;
403 : }
404 0 : PacketIterator prev_it = it;
405 : // Take care of the rest of the NAL units.
406 0 : for (; it != packets_.end(); ++it) {
407 0 : bool start_of_nalu = ((*it).completeNALU == kNaluStart ||
408 0 : (*it).completeNALU == kNaluComplete);
409 0 : if (!start_of_nalu && !InSequence(it, prev_it)) {
410 : // Found a sequence number gap due to packet loss.
411 0 : PacketIterator nalu_end = FindNaluEnd(it);
412 0 : return_length += DeletePacketData(it, nalu_end);
413 0 : it = nalu_end;
414 : }
415 0 : prev_it = it;
416 : }
417 0 : return return_length;
418 : }
419 :
420 0 : void VCMSessionInfo::SetNotDecodableIfIncomplete() {
421 : // We don't need to check for completeness first because the two are
422 : // orthogonal. If complete_ is true, decodable_ is irrelevant.
423 0 : decodable_ = false;
424 0 : }
425 :
426 0 : bool VCMSessionInfo::HaveFirstPacket() const {
427 0 : return !packets_.empty() && (first_packet_seq_num_ != -1);
428 : }
429 :
430 0 : bool VCMSessionInfo::HaveLastPacket() const {
431 0 : return !packets_.empty() && (last_packet_seq_num_ != -1);
432 : }
433 :
434 0 : bool VCMSessionInfo::session_nack() const {
435 0 : return session_nack_;
436 : }
437 :
438 0 : int VCMSessionInfo::InsertPacket(const VCMPacket& packet,
439 : uint8_t* frame_buffer,
440 : VCMDecodeErrorMode decode_error_mode,
441 : const FrameData& frame_data) {
442 0 : if (packet.frameType == kEmptyFrame) {
443 : // Update sequence number of an empty packet.
444 : // Only media packets are inserted into the packet list.
445 0 : InformOfEmptyPacket(packet.seqNum);
446 0 : return 0;
447 : }
448 :
449 0 : if (packets_.size() == kMaxPacketsInSession) {
450 0 : LOG(LS_ERROR) << "Max number of packets per frame has been reached.";
451 0 : return -1;
452 : }
453 :
454 : // Find the position of this packet in the packet list in sequence number
455 : // order and insert it. Loop over the list in reverse order.
456 0 : ReversePacketIterator rit = packets_.rbegin();
457 0 : for (; rit != packets_.rend(); ++rit)
458 0 : if (LatestSequenceNumber(packet.seqNum, (*rit).seqNum) == packet.seqNum)
459 0 : break;
460 :
461 : // Check for duplicate packets.
462 0 : if (rit != packets_.rend() && (*rit).seqNum == packet.seqNum &&
463 0 : (*rit).sizeBytes > 0)
464 0 : return -2;
465 :
466 0 : if (packet.codec == kVideoCodecH264) {
467 : // H.264 can have leading or trailing non-VCL (Video Coding Layer)
468 : // NALUs, such as SPS/PPS/SEI and others. Also, the RTP marker bit is
469 : // not reliable for the last packet of a frame (RFC 6184 5.1 - "Decoders
470 : // [] MUST NOT rely on this property"), so allow out-of-order packets to
471 : // update the first and last seq# range. Also mark as a key frame if
472 : // any packet is of that type.
473 0 : if (frame_type_ != kVideoFrameKey) {
474 0 : frame_type_ = packet.frameType;
475 : }
476 0 : if (packet.is_first_packet_in_frame &&
477 0 : (first_packet_seq_num_ == -1 ||
478 0 : IsNewerSequenceNumber(first_packet_seq_num_, packet.seqNum))) {
479 0 : first_packet_seq_num_ = packet.seqNum;
480 : }
481 : // Note: the code does *not* currently handle the Marker bit being totally
482 : // absent from a frame. It does not, however, depend on it being on the last
483 : // packet of the 'frame'/'session'.
484 0 : if (packet.markerBit &&
485 0 : (last_packet_seq_num_ == -1 ||
486 0 : IsNewerSequenceNumber(packet.seqNum, last_packet_seq_num_))) {
487 0 : last_packet_seq_num_ = packet.seqNum;
488 : }
489 : } else {
490 : // Only insert media packets between first and last packets (when
491 : // available).
492 : // Placing check here, as to properly account for duplicate packets.
493 : // Check if this is first packet (only valid for some codecs)
494 : // Should only be set for one packet per session.
495 0 : if (packet.is_first_packet_in_frame && first_packet_seq_num_ == -1) {
496 : // The first packet in a frame signals the frame type.
497 0 : frame_type_ = packet.frameType;
498 : // Store the sequence number for the first packet.
499 0 : first_packet_seq_num_ = static_cast<int>(packet.seqNum);
500 0 : } else if (first_packet_seq_num_ != -1 &&
501 0 : IsNewerSequenceNumber(first_packet_seq_num_, packet.seqNum)) {
502 0 : LOG(LS_WARNING) << "Received packet with a sequence number which is out "
503 0 : "of frame boundaries";
504 0 : return -3;
505 0 : } else if (frame_type_ == kEmptyFrame && packet.frameType != kEmptyFrame) {
506 : // Update the frame type with the type of the first media packet.
507 : // TODO(mikhal): Can this trigger?
508 0 : frame_type_ = packet.frameType;
509 : }
510 :
511 : // Track the marker bit, should only be set for one packet per session.
512 0 : if (packet.markerBit && last_packet_seq_num_ == -1) {
513 0 : last_packet_seq_num_ = static_cast<int>(packet.seqNum);
514 0 : } else if (last_packet_seq_num_ != -1 &&
515 0 : IsNewerSequenceNumber(packet.seqNum, last_packet_seq_num_)) {
516 0 : LOG(LS_WARNING) << "Received packet with a sequence number which is out "
517 0 : "of frame boundaries";
518 0 : return -3;
519 : }
520 : }
521 :
522 : // The insert operation invalidates the iterator |rit|.
523 0 : PacketIterator packet_list_it = packets_.insert(rit.base(), packet);
524 :
525 0 : size_t returnLength = InsertBuffer(frame_buffer, packet_list_it);
526 0 : UpdateCompleteSession();
527 : // We call MakeDecodable() before decoding, which removes packets after a loss
528 : // (and which means h.264 mode 1 frames with a loss in the first packet will be
529 : // totally removed)
530 0 : if (decode_error_mode == kWithErrors)
531 0 : decodable_ = true;
532 0 : else if (decode_error_mode == kSelectiveErrors)
533 0 : UpdateDecodableSession(frame_data);
534 0 : return static_cast<int>(returnLength);
535 : }
536 :
537 0 : void VCMSessionInfo::InformOfEmptyPacket(uint16_t seq_num) {
538 : // Empty packets may be FEC or filler packets. They are sequential and
539 : // follow the data packets, therefore, we should only keep track of the high
540 : // and low sequence numbers and may assume that the packets in between are
541 : // empty packets belonging to the same frame (timestamp).
542 0 : if (empty_seq_num_high_ == -1)
543 0 : empty_seq_num_high_ = seq_num;
544 : else
545 0 : empty_seq_num_high_ = LatestSequenceNumber(seq_num, empty_seq_num_high_);
546 0 : if (empty_seq_num_low_ == -1 ||
547 0 : IsNewerSequenceNumber(empty_seq_num_low_, seq_num))
548 0 : empty_seq_num_low_ = seq_num;
549 0 : }
550 :
551 : } // namespace webrtc
|