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