niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
mflodman@webrtc.org | c80d9d9 | 2012-02-06 10:11:25 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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 | |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 11 | #include "webrtc/modules/video_coding/frame_buffer.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 12 | |
pbos@webrtc.org | 12dc1a3 | 2013-08-05 16:22:53 +0000 | [diff] [blame] | 13 | #include <assert.h> |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 14 | #include <string.h> |
| 15 | |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 16 | #include "webrtc/modules/video_coding/packet.h" |
Edward Lemur | c20978e | 2017-07-06 19:44:34 +0200 | [diff] [blame] | 17 | #include "webrtc/rtc_base/checks.h" |
| 18 | #include "webrtc/rtc_base/logging.h" |
| 19 | #include "webrtc/rtc_base/trace_event.h" |
agalusza@google.com | d818dcb | 2013-07-29 21:48:11 +0000 | [diff] [blame] | 20 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 21 | namespace webrtc { |
| 22 | |
stefan@webrtc.org | c3d8910 | 2011-09-08 06:50:28 +0000 | [diff] [blame] | 23 | VCMFrameBuffer::VCMFrameBuffer() |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 24 | : _state(kStateEmpty), _nackCount(0), _latestPacketTimeMs(-1) {} |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 25 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 26 | VCMFrameBuffer::~VCMFrameBuffer() {} |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 27 | |
agalusza@google.com | d818dcb | 2013-07-29 21:48:11 +0000 | [diff] [blame] | 28 | VCMFrameBuffer::VCMFrameBuffer(const VCMFrameBuffer& rhs) |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 29 | : VCMEncodedFrame(rhs), |
| 30 | _state(rhs._state), |
| 31 | _sessionInfo(), |
| 32 | _nackCount(rhs._nackCount), |
| 33 | _latestPacketTimeMs(rhs._latestPacketTimeMs) { |
| 34 | _sessionInfo = rhs._sessionInfo; |
| 35 | _sessionInfo.UpdateDataPointers(rhs._buffer, _buffer); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 36 | } |
| 37 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 38 | webrtc::FrameType VCMFrameBuffer::FrameType() const { |
| 39 | return _sessionInfo.FrameType(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 40 | } |
| 41 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 42 | int32_t VCMFrameBuffer::GetLowSeqNum() const { |
| 43 | return _sessionInfo.LowSequenceNumber(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 44 | } |
| 45 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 46 | int32_t VCMFrameBuffer::GetHighSeqNum() const { |
| 47 | return _sessionInfo.HighSequenceNumber(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 48 | } |
| 49 | |
stefan@webrtc.org | ffd28f9 | 2011-10-19 15:55:39 +0000 | [diff] [blame] | 50 | int VCMFrameBuffer::PictureId() const { |
| 51 | return _sessionInfo.PictureId(); |
| 52 | } |
| 53 | |
mikhal@webrtc.org | f5ee1dc | 2011-12-08 19:04:47 +0000 | [diff] [blame] | 54 | int VCMFrameBuffer::TemporalId() const { |
| 55 | return _sessionInfo.TemporalId(); |
| 56 | } |
| 57 | |
henrik.lundin@webrtc.org | eda86dc | 2011-12-13 14:11:06 +0000 | [diff] [blame] | 58 | bool VCMFrameBuffer::LayerSync() const { |
| 59 | return _sessionInfo.LayerSync(); |
| 60 | } |
| 61 | |
mikhal@webrtc.org | f5ee1dc | 2011-12-08 19:04:47 +0000 | [diff] [blame] | 62 | int VCMFrameBuffer::Tl0PicId() const { |
| 63 | return _sessionInfo.Tl0PicId(); |
| 64 | } |
| 65 | |
mikhal@webrtc.org | ea71440 | 2011-12-12 02:29:34 +0000 | [diff] [blame] | 66 | bool VCMFrameBuffer::NonReference() const { |
| 67 | return _sessionInfo.NonReference(); |
| 68 | } |
| 69 | |
stefan | a669a3a | 2016-10-06 05:04:52 -0700 | [diff] [blame] | 70 | std::vector<NaluInfo> VCMFrameBuffer::GetNaluInfos() const { |
| 71 | return _sessionInfo.GetNaluInfos(); |
| 72 | } |
| 73 | |
asapersson | 9a4cd87 | 2015-10-23 00:27:14 -0700 | [diff] [blame] | 74 | void VCMFrameBuffer::SetGofInfo(const GofInfoVP9& gof_info, size_t idx) { |
tommi | db23ea6 | 2017-03-03 07:21:18 -0800 | [diff] [blame] | 75 | TRACE_EVENT0("webrtc", "VCMFrameBuffer::SetGofInfo"); |
asapersson | 9a4cd87 | 2015-10-23 00:27:14 -0700 | [diff] [blame] | 76 | _sessionInfo.SetGofInfo(gof_info, idx); |
| 77 | // TODO(asapersson): Consider adding hdr->VP9.ref_picture_id for testing. |
| 78 | _codecSpecificInfo.codecSpecific.VP9.temporal_idx = |
| 79 | gof_info.temporal_idx[idx]; |
| 80 | _codecSpecificInfo.codecSpecific.VP9.temporal_up_switch = |
| 81 | gof_info.temporal_up_switch[idx]; |
| 82 | } |
| 83 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 84 | bool VCMFrameBuffer::IsSessionComplete() const { |
tommi | db23ea6 | 2017-03-03 07:21:18 -0800 | [diff] [blame] | 85 | TRACE_EVENT0("webrtc", "VCMFrameBuffer::IsSessionComplete"); |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 86 | return _sessionInfo.complete(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | // Insert packet |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 90 | VCMFrameBufferEnum VCMFrameBuffer::InsertPacket( |
| 91 | const VCMPacket& packet, |
| 92 | int64_t timeInMs, |
| 93 | VCMDecodeErrorMode decode_error_mode, |
| 94 | const FrameData& frame_data) { |
tommi | db23ea6 | 2017-03-03 07:21:18 -0800 | [diff] [blame] | 95 | TRACE_EVENT0("webrtc", "VCMFrameBuffer::InsertPacket"); |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 96 | assert(!(NULL == packet.dataPtr && packet.sizeBytes > 0)); |
| 97 | if (packet.dataPtr != NULL) { |
| 98 | _payloadType = packet.payloadType; |
| 99 | } |
| 100 | |
| 101 | if (kStateEmpty == _state) { |
| 102 | // First packet (empty and/or media) inserted into this frame. |
| 103 | // store some info and set some initial values. |
| 104 | _timeStamp = packet.timestamp; |
| 105 | // We only take the ntp timestamp of the first packet of a frame. |
| 106 | ntp_time_ms_ = packet.ntp_time_ms_; |
| 107 | _codec = packet.codec; |
| 108 | if (packet.frameType != kEmptyFrame) { |
| 109 | // first media packet |
| 110 | SetState(kStateIncomplete); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 111 | } |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 112 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 113 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 114 | uint32_t requiredSizeBytes = |
| 115 | Length() + packet.sizeBytes + |
hbos | d664836 | 2016-01-21 05:43:11 -0800 | [diff] [blame] | 116 | (packet.insertStartCode ? kH264StartCodeLengthBytes : 0) + |
| 117 | EncodedImage::GetBufferPaddingBytes(packet.codec); |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 118 | if (requiredSizeBytes >= _size) { |
| 119 | const uint8_t* prevBuffer = _buffer; |
| 120 | const uint32_t increments = |
| 121 | requiredSizeBytes / kBufferIncStepSizeBytes + |
| 122 | (requiredSizeBytes % kBufferIncStepSizeBytes > 0); |
| 123 | const uint32_t newSize = _size + increments * kBufferIncStepSizeBytes; |
| 124 | if (newSize > kMaxJBFrameSizeBytes) { |
| 125 | LOG(LS_ERROR) << "Failed to insert packet due to frame being too " |
| 126 | "big."; |
| 127 | return kSizeError; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 128 | } |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 129 | VerifyAndAllocate(newSize); |
| 130 | _sessionInfo.UpdateDataPointers(prevBuffer, _buffer); |
| 131 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 132 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 133 | if (packet.width > 0 && packet.height > 0) { |
| 134 | _encodedWidth = packet.width; |
| 135 | _encodedHeight = packet.height; |
| 136 | } |
henrik.lundin@webrtc.org | 473bac8 | 2011-08-17 09:47:33 +0000 | [diff] [blame] | 137 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 138 | // Don't copy payload specific data for empty packets (e.g padding packets). |
| 139 | if (packet.sizeBytes > 0) |
isheriff | 6b4b5f3 | 2016-06-08 00:24:21 -0700 | [diff] [blame] | 140 | CopyCodecSpecific(&packet.video_header); |
stefan@webrtc.org | 3417eb4 | 2013-05-21 15:25:53 +0000 | [diff] [blame] | 141 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 142 | int retVal = |
| 143 | _sessionInfo.InsertPacket(packet, _buffer, decode_error_mode, frame_data); |
| 144 | if (retVal == -1) { |
| 145 | return kSizeError; |
| 146 | } else if (retVal == -2) { |
| 147 | return kDuplicatePacket; |
| 148 | } else if (retVal == -3) { |
| 149 | return kOutOfBoundsPacket; |
| 150 | } |
| 151 | // update length |
| 152 | _length = Length() + static_cast<uint32_t>(retVal); |
henrik.lundin@webrtc.org | 473bac8 | 2011-08-17 09:47:33 +0000 | [diff] [blame] | 153 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 154 | _latestPacketTimeMs = timeInMs; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 155 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 156 | // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ |
| 157 | // ts_126114v120700p.pdf Section 7.4.5. |
| 158 | // The MTSI client shall add the payload bytes as defined in this clause |
| 159 | // onto the last RTP packet in each group of packets which make up a key |
| 160 | // frame (I-frame or IDR frame in H.264 (AVC), or an IRAP picture in H.265 |
| 161 | // (HEVC)). |
| 162 | if (packet.markerBit) { |
| 163 | RTC_DCHECK(!_rotation_set); |
perkj | 414dda1 | 2016-07-04 01:45:23 -0700 | [diff] [blame] | 164 | rotation_ = packet.video_header.rotation; |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 165 | _rotation_set = true; |
ilnik | 00d802b | 2017-04-11 10:34:31 -0700 | [diff] [blame] | 166 | content_type_ = packet.video_header.content_type; |
sprang | ba050a6 | 2017-08-18 02:51:12 -0700 | [diff] [blame^] | 167 | if (packet.video_header.video_timing.flags != TimingFrameFlags::kInvalid) { |
ilnik | 04f4d12 | 2017-06-19 07:18:55 -0700 | [diff] [blame] | 168 | timing_.encode_start_ms = |
| 169 | ntp_time_ms_ + packet.video_header.video_timing.encode_start_delta_ms; |
| 170 | timing_.encode_finish_ms = |
| 171 | ntp_time_ms_ + |
| 172 | packet.video_header.video_timing.encode_finish_delta_ms; |
| 173 | timing_.packetization_finish_ms = |
| 174 | ntp_time_ms_ + |
| 175 | packet.video_header.video_timing.packetization_finish_delta_ms; |
| 176 | timing_.pacer_exit_ms = |
| 177 | ntp_time_ms_ + packet.video_header.video_timing.pacer_exit_delta_ms; |
| 178 | timing_.network_timestamp_ms = |
| 179 | ntp_time_ms_ + |
| 180 | packet.video_header.video_timing.network_timstamp_delta_ms; |
| 181 | timing_.network2_timestamp_ms = |
| 182 | ntp_time_ms_ + |
| 183 | packet.video_header.video_timing.network2_timstamp_delta_ms; |
ilnik | 04f4d12 | 2017-06-19 07:18:55 -0700 | [diff] [blame] | 184 | } |
sprang | ba050a6 | 2017-08-18 02:51:12 -0700 | [diff] [blame^] | 185 | timing_.flags = packet.video_header.video_timing.flags; |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 186 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 187 | |
johan | 0d1b2b6 | 2017-01-10 04:21:35 -0800 | [diff] [blame] | 188 | if (packet.is_first_packet_in_frame) { |
isheriff | 6b4b5f3 | 2016-06-08 00:24:21 -0700 | [diff] [blame] | 189 | playout_delay_ = packet.video_header.playout_delay; |
| 190 | } |
| 191 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 192 | if (_sessionInfo.complete()) { |
| 193 | SetState(kStateComplete); |
| 194 | return kCompleteSession; |
| 195 | } else if (_sessionInfo.decodable()) { |
| 196 | SetState(kStateDecodable); |
| 197 | return kDecodableSession; |
| 198 | } |
| 199 | return kIncomplete; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 200 | } |
| 201 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 202 | int64_t VCMFrameBuffer::LatestPacketTimeMs() const { |
tommi | db23ea6 | 2017-03-03 07:21:18 -0800 | [diff] [blame] | 203 | TRACE_EVENT0("webrtc", "VCMFrameBuffer::LatestPacketTimeMs"); |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 204 | return _latestPacketTimeMs; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 205 | } |
| 206 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 207 | void VCMFrameBuffer::IncrementNackCount() { |
tommi | db23ea6 | 2017-03-03 07:21:18 -0800 | [diff] [blame] | 208 | TRACE_EVENT0("webrtc", "VCMFrameBuffer::IncrementNackCount"); |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 209 | _nackCount++; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 210 | } |
| 211 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 212 | int16_t VCMFrameBuffer::GetNackCount() const { |
tommi | db23ea6 | 2017-03-03 07:21:18 -0800 | [diff] [blame] | 213 | TRACE_EVENT0("webrtc", "VCMFrameBuffer::GetNackCount"); |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 214 | return _nackCount; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 215 | } |
| 216 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 217 | bool VCMFrameBuffer::HaveFirstPacket() const { |
tommi | db23ea6 | 2017-03-03 07:21:18 -0800 | [diff] [blame] | 218 | TRACE_EVENT0("webrtc", "VCMFrameBuffer::HaveFirstPacket"); |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 219 | return _sessionInfo.HaveFirstPacket(); |
stefan@webrtc.org | 885cd13 | 2013-04-16 09:38:26 +0000 | [diff] [blame] | 220 | } |
| 221 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 222 | bool VCMFrameBuffer::HaveLastPacket() const { |
tommi | db23ea6 | 2017-03-03 07:21:18 -0800 | [diff] [blame] | 223 | TRACE_EVENT0("webrtc", "VCMFrameBuffer::HaveLastPacket"); |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 224 | return _sessionInfo.HaveLastPacket(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 225 | } |
| 226 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 227 | int VCMFrameBuffer::NumPackets() const { |
tommi | db23ea6 | 2017-03-03 07:21:18 -0800 | [diff] [blame] | 228 | TRACE_EVENT0("webrtc", "VCMFrameBuffer::NumPackets"); |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 229 | return _sessionInfo.NumPackets(); |
agalusza@google.com | d818dcb | 2013-07-29 21:48:11 +0000 | [diff] [blame] | 230 | } |
| 231 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 232 | void VCMFrameBuffer::Reset() { |
tommi | db23ea6 | 2017-03-03 07:21:18 -0800 | [diff] [blame] | 233 | TRACE_EVENT0("webrtc", "VCMFrameBuffer::Reset"); |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 234 | _length = 0; |
| 235 | _timeStamp = 0; |
| 236 | _sessionInfo.Reset(); |
| 237 | _payloadType = 0; |
| 238 | _nackCount = 0; |
| 239 | _latestPacketTimeMs = -1; |
| 240 | _state = kStateEmpty; |
| 241 | VCMEncodedFrame::Reset(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 242 | } |
| 243 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 244 | // Set state of frame |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 245 | void VCMFrameBuffer::SetState(VCMFrameBufferStateEnum state) { |
tommi | db23ea6 | 2017-03-03 07:21:18 -0800 | [diff] [blame] | 246 | TRACE_EVENT0("webrtc", "VCMFrameBuffer::SetState"); |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 247 | if (_state == state) { |
| 248 | return; |
| 249 | } |
| 250 | switch (state) { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 251 | case kStateIncomplete: |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 252 | // we can go to this state from state kStateEmpty |
| 253 | assert(_state == kStateEmpty); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 254 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 255 | // Do nothing, we received a packet |
| 256 | break; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 257 | |
| 258 | case kStateComplete: |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 259 | assert(_state == kStateEmpty || _state == kStateIncomplete || |
| 260 | _state == kStateDecodable); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 261 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 262 | break; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 263 | |
| 264 | case kStateEmpty: |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 265 | // Should only be set to empty through Reset(). |
| 266 | assert(false); |
| 267 | break; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 268 | |
| 269 | case kStateDecodable: |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 270 | assert(_state == kStateEmpty || _state == kStateIncomplete); |
| 271 | break; |
| 272 | } |
| 273 | _state = state; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 274 | } |
| 275 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 276 | // Get current state of frame |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 277 | VCMFrameBufferStateEnum VCMFrameBuffer::GetState() const { |
| 278 | return _state; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | // Get current state of frame |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 282 | VCMFrameBufferStateEnum VCMFrameBuffer::GetState(uint32_t& timeStamp) const { |
tommi | db23ea6 | 2017-03-03 07:21:18 -0800 | [diff] [blame] | 283 | TRACE_EVENT0("webrtc", "VCMFrameBuffer::GetState"); |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 284 | timeStamp = TimeStamp(); |
| 285 | return GetState(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 286 | } |
| 287 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 288 | bool VCMFrameBuffer::IsRetransmitted() const { |
| 289 | return _sessionInfo.session_nack(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 290 | } |
| 291 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 292 | void VCMFrameBuffer::PrepareForDecode(bool continuous) { |
tommi | db23ea6 | 2017-03-03 07:21:18 -0800 | [diff] [blame] | 293 | TRACE_EVENT0("webrtc", "VCMFrameBuffer::PrepareForDecode"); |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 294 | size_t bytes_removed = _sessionInfo.MakeDecodable(); |
| 295 | _length -= bytes_removed; |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 296 | // Transfer frame information to EncodedFrame and create any codec |
| 297 | // specific information. |
| 298 | _frameType = _sessionInfo.FrameType(); |
| 299 | _completeFrame = _sessionInfo.complete(); |
| 300 | _missingFrame = !continuous; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 301 | } |
| 302 | |
agalusza@google.com | d818dcb | 2013-07-29 21:48:11 +0000 | [diff] [blame] | 303 | } // namespace webrtc |