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