blob: fa7e3424bc7d5f68bbcb5e215a5fee89118a1098 [file] [log] [blame]
philipelbe7a9e52016-05-19 12:19:35 +02001/*
2 * Copyright (c) 2016 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/frame_buffer2.h"
12
13#include <algorithm>
philipele0b2f152016-09-28 10:23:49 +020014#include <cstring>
15#include <queue>
philipelbe7a9e52016-05-19 12:19:35 +020016
tommi0a735642017-03-14 06:23:57 -070017#include "webrtc/base/atomicops.h"
philipelbe7a9e52016-05-19 12:19:35 +020018#include "webrtc/base/checks.h"
philipele0b2f152016-09-28 10:23:49 +020019#include "webrtc/base/logging.h"
tommidb23ea62017-03-03 07:21:18 -080020#include "webrtc/base/trace_event.h"
philipela45102f2017-02-22 05:30:39 -080021#include "webrtc/modules/video_coding/include/video_coding_defines.h"
philipelbe7a9e52016-05-19 12:19:35 +020022#include "webrtc/modules/video_coding/jitter_estimator.h"
philipelbe7a9e52016-05-19 12:19:35 +020023#include "webrtc/modules/video_coding/timing.h"
24#include "webrtc/system_wrappers/include/clock.h"
philipel266f0a42016-11-28 08:49:07 -080025#include "webrtc/system_wrappers/include/metrics.h"
philipelbe7a9e52016-05-19 12:19:35 +020026
27namespace webrtc {
28namespace video_coding {
29
30namespace {
philipele0b2f152016-09-28 10:23:49 +020031// Max number of frames the buffer will hold.
32constexpr int kMaxFramesBuffered = 600;
philipelbe7a9e52016-05-19 12:19:35 +020033
philipele0b2f152016-09-28 10:23:49 +020034// Max number of decoded frame info that will be saved.
philipelfd5a20f2016-11-15 00:57:57 -080035constexpr int kMaxFramesHistory = 50;
philipelbe7a9e52016-05-19 12:19:35 +020036} // namespace
37
philipelbe7a9e52016-05-19 12:19:35 +020038FrameBuffer::FrameBuffer(Clock* clock,
39 VCMJitterEstimator* jitter_estimator,
philipela45102f2017-02-22 05:30:39 -080040 VCMTiming* timing,
41 VCMReceiveStatisticsCallback* stats_callback)
philipelbe7a9e52016-05-19 12:19:35 +020042 : clock_(clock),
tommi0a735642017-03-14 06:23:57 -070043 new_continuous_frame_event_(false, false),
philipelbe7a9e52016-05-19 12:19:35 +020044 jitter_estimator_(jitter_estimator),
45 timing_(timing),
philipel4f6cd6a2016-08-03 10:59:32 +020046 inter_frame_delay_(clock_->TimeInMilliseconds()),
philipele0b2f152016-09-28 10:23:49 +020047 last_decoded_frame_it_(frames_.end()),
48 last_continuous_frame_it_(frames_.end()),
49 num_frames_history_(0),
50 num_frames_buffered_(0),
tommi0a735642017-03-14 06:23:57 -070051 stopped_(0),
philipela45102f2017-02-22 05:30:39 -080052 protection_mode_(kProtectionNack),
53 stats_callback_(stats_callback) {}
philipel266f0a42016-11-28 08:49:07 -080054
philipela45102f2017-02-22 05:30:39 -080055FrameBuffer::~FrameBuffer() {}
philipelbe7a9e52016-05-19 12:19:35 +020056
philipel75562822016-09-05 10:57:41 +020057FrameBuffer::ReturnReason FrameBuffer::NextFrame(
58 int64_t max_wait_time_ms,
59 std::unique_ptr<FrameObject>* frame_out) {
tommidb23ea62017-03-03 07:21:18 -080060 TRACE_EVENT0("webrtc", "FrameBuffer::NextFrame");
philipel1c056252017-01-31 09:53:12 -080061 int64_t latest_return_time_ms =
62 clock_->TimeInMilliseconds() + max_wait_time_ms;
philipel504c47d2016-06-30 17:33:02 +020063 int64_t wait_ms = max_wait_time_ms;
philipele0b2f152016-09-28 10:23:49 +020064
65 do {
tommi0a735642017-03-14 06:23:57 -070066 if (rtc::AtomicOps::AcquireLoad(&stopped_))
67 return kStopped;
68
philipele0b2f152016-09-28 10:23:49 +020069 int64_t now_ms = clock_->TimeInMilliseconds();
tommi0a735642017-03-14 06:23:57 -070070 wait_ms = max_wait_time_ms;
philipel504c47d2016-06-30 17:33:02 +020071 {
72 rtc::CritScope lock(&crit_);
tommi0a735642017-03-14 06:23:57 -070073 new_continuous_frame_event_.Reset();
philipele0b2f152016-09-28 10:23:49 +020074 // Need to hold |crit_| in order to use |frames_|, therefore we
75 // set it here in the loop instead of outside the loop in order to not
76 // acquire the lock unnecesserily.
philipel1c056252017-01-31 09:53:12 -080077 next_frame_it_ = frames_.end();
philipelbe7a9e52016-05-19 12:19:35 +020078
philipele0b2f152016-09-28 10:23:49 +020079 // |frame_it| points to the first frame after the
80 // |last_decoded_frame_it_|.
81 auto frame_it = frames_.end();
82 if (last_decoded_frame_it_ == frames_.end()) {
83 frame_it = frames_.begin();
philipelbe7a9e52016-05-19 12:19:35 +020084 } else {
philipele0b2f152016-09-28 10:23:49 +020085 frame_it = last_decoded_frame_it_;
86 ++frame_it;
philipelbe7a9e52016-05-19 12:19:35 +020087 }
philipele0b2f152016-09-28 10:23:49 +020088
89 // |continuous_end_it| points to the first frame after the
90 // |last_continuous_frame_it_|.
91 auto continuous_end_it = last_continuous_frame_it_;
92 if (continuous_end_it != frames_.end())
93 ++continuous_end_it;
94
95 for (; frame_it != continuous_end_it; ++frame_it) {
philipel93e451b2016-10-06 12:25:13 +020096 if (!frame_it->second.continuous ||
97 frame_it->second.num_missing_decodable > 0) {
philipele0b2f152016-09-28 10:23:49 +020098 continue;
philipel93e451b2016-10-06 12:25:13 +020099 }
philipele0b2f152016-09-28 10:23:49 +0200100
101 FrameObject* frame = frame_it->second.frame.get();
philipel1c056252017-01-31 09:53:12 -0800102 next_frame_it_ = frame_it;
philipele0b2f152016-09-28 10:23:49 +0200103 if (frame->RenderTime() == -1)
104 frame->SetRenderTime(timing_->RenderTimeMs(frame->timestamp, now_ms));
105 wait_ms = timing_->MaxWaitingTime(frame->RenderTime(), now_ms);
106
107 // This will cause the frame buffer to prefer high framerate rather
108 // than high resolution in the case of the decoder not decoding fast
109 // enough and the stream has multiple spatial and temporal layers.
110 if (wait_ms == 0)
111 continue;
112
113 break;
114 }
115 } // rtc::Critscope lock(&crit_);
116
philipel1c056252017-01-31 09:53:12 -0800117 wait_ms = std::min<int64_t>(wait_ms, latest_return_time_ms - now_ms);
philipele0b2f152016-09-28 10:23:49 +0200118 wait_ms = std::max<int64_t>(wait_ms, 0);
tommi0a735642017-03-14 06:23:57 -0700119 } while (new_continuous_frame_event_.Wait(wait_ms));
philipele0b2f152016-09-28 10:23:49 +0200120
121 rtc::CritScope lock(&crit_);
philipel1c056252017-01-31 09:53:12 -0800122 int64_t now_ms = clock_->TimeInMilliseconds();
123 if (next_frame_it_ != frames_.end()) {
124 std::unique_ptr<FrameObject> frame =
125 std::move(next_frame_it_->second.frame);
philipele0b2f152016-09-28 10:23:49 +0200126
philipele0754302017-01-25 08:56:23 -0800127 if (!frame->delayed_by_retransmission()) {
128 int64_t frame_delay;
129
130 if (inter_frame_delay_.CalculateDelay(frame->timestamp, &frame_delay,
131 frame->ReceivedTime())) {
132 jitter_estimator_->UpdateEstimate(frame_delay, frame->size());
133 }
134
135 float rtt_mult = protection_mode_ == kProtectionNackFEC ? 0.0 : 1.0;
136 timing_->SetJitterDelay(jitter_estimator_->GetJitterEstimate(rtt_mult));
philipel1c056252017-01-31 09:53:12 -0800137 timing_->UpdateCurrentDelay(frame->RenderTime(), now_ms);
philipelbe7a9e52016-05-19 12:19:35 +0200138 }
philipele0b2f152016-09-28 10:23:49 +0200139
philipelbe742702016-11-30 01:31:40 -0800140 UpdateJitterDelay();
141
philipel1c056252017-01-31 09:53:12 -0800142 PropagateDecodability(next_frame_it_->second);
143 AdvanceLastDecodedFrame(next_frame_it_);
philipelfcc60062017-01-18 05:35:20 -0800144 last_decoded_frame_timestamp_ = frame->timestamp;
philipele0b2f152016-09-28 10:23:49 +0200145 *frame_out = std::move(frame);
146 return kFrameFound;
tommi0a735642017-03-14 06:23:57 -0700147 }
148
149 if (latest_return_time_ms - now_ms > 0) {
philipel1c056252017-01-31 09:53:12 -0800150 // If |next_frame_it_ == frames_.end()| and there is still time left, it
151 // means that the frame buffer was cleared as the thread in this function
152 // was waiting to acquire |crit_| in order to return. Wait for the
153 // remaining time and then return.
154 return NextFrame(latest_return_time_ms - now_ms, frame_out);
philipelbe7a9e52016-05-19 12:19:35 +0200155 }
tommi0a735642017-03-14 06:23:57 -0700156
157 return kTimeout;
philipelbe7a9e52016-05-19 12:19:35 +0200158}
159
philipel4f6cd6a2016-08-03 10:59:32 +0200160void FrameBuffer::SetProtectionMode(VCMVideoProtection mode) {
tommidb23ea62017-03-03 07:21:18 -0800161 TRACE_EVENT0("webrtc", "FrameBuffer::SetProtectionMode");
philipel4f6cd6a2016-08-03 10:59:32 +0200162 rtc::CritScope lock(&crit_);
163 protection_mode_ = mode;
164}
165
tommi0a735642017-03-14 06:23:57 -0700166// Start() and Stop() must be called on the same thread.
167// The value of stopped_ can only be changed on this thread.
philipel504c47d2016-06-30 17:33:02 +0200168void FrameBuffer::Start() {
tommidb23ea62017-03-03 07:21:18 -0800169 TRACE_EVENT0("webrtc", "FrameBuffer::Start");
tommi0a735642017-03-14 06:23:57 -0700170 rtc::AtomicOps::ReleaseStore(&stopped_, 0);
philipel504c47d2016-06-30 17:33:02 +0200171}
172
173void FrameBuffer::Stop() {
tommidb23ea62017-03-03 07:21:18 -0800174 TRACE_EVENT0("webrtc", "FrameBuffer::Stop");
tommi0a735642017-03-14 06:23:57 -0700175 // TODO(tommi,philipel): Previously, we grabbed the |crit_| lock when decoding
176 // was being stopped. On Android, with captured frames being delivered on the
177 // decoder thread, this consistently caused the 'busy loop' checks in the
178 // PlatformThread to trigger on "VoiceProcessThread", "ModuleProcessThread"
179 // and occasionally on "PacerThread".
180 // Look into what was going on and why |Stop()| wasn't able to grab the lock
181 // and stop the FrameBuffer while that happened.
182 // See bug: https://bugs.chromium.org/p/webrtc/issues/detail?id=7331
183 rtc::AtomicOps::Increment(&stopped_);
184 new_continuous_frame_event_.Set();
philipel504c47d2016-06-30 17:33:02 +0200185}
186
philipele0b2f152016-09-28 10:23:49 +0200187int FrameBuffer::InsertFrame(std::unique_ptr<FrameObject> frame) {
tommidb23ea62017-03-03 07:21:18 -0800188 TRACE_EVENT0("webrtc", "FrameBuffer::InsertFrame");
philipel93e451b2016-10-06 12:25:13 +0200189 RTC_DCHECK(frame);
190
tommi0a735642017-03-14 06:23:57 -0700191 if (rtc::AtomicOps::AcquireLoad(&stopped_))
192 return -1;
193
philipela45102f2017-02-22 05:30:39 -0800194 if (stats_callback_)
195 stats_callback_->OnCompleteFrame(frame->num_references == 0, frame->size());
philipel266f0a42016-11-28 08:49:07 -0800196
philipelbe7a9e52016-05-19 12:19:35 +0200197 FrameKey key(frame->picture_id, frame->spatial_layer);
tommi0a735642017-03-14 06:23:57 -0700198
199 rtc::CritScope lock(&crit_);
philipele0b2f152016-09-28 10:23:49 +0200200 int last_continuous_picture_id =
201 last_continuous_frame_it_ == frames_.end()
202 ? -1
203 : last_continuous_frame_it_->first.picture_id;
204
205 if (num_frames_buffered_ >= kMaxFramesBuffered) {
206 LOG(LS_WARNING) << "Frame with (picture_id:spatial_id) (" << key.picture_id
207 << ":" << static_cast<int>(key.spatial_layer)
208 << ") could not be inserted due to the frame "
209 << "buffer being full, dropping frame.";
210 return last_continuous_picture_id;
211 }
212
213 if (frame->inter_layer_predicted && frame->spatial_layer == 0) {
214 LOG(LS_WARNING) << "Frame with (picture_id:spatial_id) (" << key.picture_id
215 << ":" << static_cast<int>(key.spatial_layer)
216 << ") is marked as inter layer predicted, dropping frame.";
217 return last_continuous_picture_id;
218 }
219
220 if (last_decoded_frame_it_ != frames_.end() &&
221 key < last_decoded_frame_it_->first) {
philipelfcc60062017-01-18 05:35:20 -0800222 if (AheadOf(frame->timestamp, last_decoded_frame_timestamp_) &&
223 frame->num_references == 0) {
224 // If this frame has a newer timestamp but an earlier picture id then we
225 // assume there has been a jump in the picture id due to some encoder
226 // reconfiguration or some other reason. Even though this is not according
227 // to spec we can still continue to decode from this frame if it is a
228 // keyframe.
229 LOG(LS_WARNING) << "A jump in picture id was detected, clearing buffer.";
230 ClearFramesAndHistory();
231 last_continuous_picture_id = -1;
232 } else {
233 LOG(LS_WARNING) << "Frame with (picture_id:spatial_id) ("
234 << key.picture_id << ":"
235 << static_cast<int>(key.spatial_layer)
236 << ") inserted after frame ("
237 << last_decoded_frame_it_->first.picture_id << ":"
238 << static_cast<int>(
239 last_decoded_frame_it_->first.spatial_layer)
240 << ") was handed off for decoding, dropping frame.";
241 return last_continuous_picture_id;
242 }
philipele0b2f152016-09-28 10:23:49 +0200243 }
244
245 auto info = frames_.insert(std::make_pair(key, FrameInfo())).first;
246
philipel93e451b2016-10-06 12:25:13 +0200247 if (info->second.frame) {
248 LOG(LS_WARNING) << "Frame with (picture_id:spatial_id) (" << key.picture_id
249 << ":" << static_cast<int>(key.spatial_layer)
250 << ") already inserted, dropping frame.";
philipele0b2f152016-09-28 10:23:49 +0200251 return last_continuous_picture_id;
252 }
253
philipel93e451b2016-10-06 12:25:13 +0200254 if (!UpdateFrameInfoWithIncomingFrame(*frame, info))
255 return last_continuous_picture_id;
256
philipele0b2f152016-09-28 10:23:49 +0200257 info->second.frame = std::move(frame);
258 ++num_frames_buffered_;
259
260 if (info->second.num_missing_continuous == 0) {
261 info->second.continuous = true;
262 PropagateContinuity(info);
263 last_continuous_picture_id = last_continuous_frame_it_->first.picture_id;
264
265 // Since we now have new continuous frames there might be a better frame
266 // to return from NextFrame. Signal that thread so that it again can choose
267 // which frame to return.
tommi0a735642017-03-14 06:23:57 -0700268 new_continuous_frame_event_.Set();
philipele0b2f152016-09-28 10:23:49 +0200269 }
270
271 return last_continuous_picture_id;
philipelbe7a9e52016-05-19 12:19:35 +0200272}
273
philipele0b2f152016-09-28 10:23:49 +0200274void FrameBuffer::PropagateContinuity(FrameMap::iterator start) {
tommidb23ea62017-03-03 07:21:18 -0800275 TRACE_EVENT0("webrtc", "FrameBuffer::PropagateContinuity");
philipele0b2f152016-09-28 10:23:49 +0200276 RTC_DCHECK(start->second.continuous);
277 if (last_continuous_frame_it_ == frames_.end())
278 last_continuous_frame_it_ = start;
279
280 std::queue<FrameMap::iterator> continuous_frames;
281 continuous_frames.push(start);
282
283 // A simple BFS to traverse continuous frames.
284 while (!continuous_frames.empty()) {
285 auto frame = continuous_frames.front();
286 continuous_frames.pop();
287
288 if (last_continuous_frame_it_->first < frame->first)
289 last_continuous_frame_it_ = frame;
290
291 // Loop through all dependent frames, and if that frame no longer has
292 // any unfulfilled dependencies then that frame is continuous as well.
293 for (size_t d = 0; d < frame->second.num_dependent_frames; ++d) {
294 auto frame_ref = frames_.find(frame->second.dependent_frames[d]);
295 --frame_ref->second.num_missing_continuous;
296
297 if (frame_ref->second.num_missing_continuous == 0) {
298 frame_ref->second.continuous = true;
299 continuous_frames.push(frame_ref);
300 }
301 }
302 }
303}
304
305void FrameBuffer::PropagateDecodability(const FrameInfo& info) {
tommidb23ea62017-03-03 07:21:18 -0800306 TRACE_EVENT0("webrtc", "FrameBuffer::PropagateDecodability");
philipele0b2f152016-09-28 10:23:49 +0200307 for (size_t d = 0; d < info.num_dependent_frames; ++d) {
308 auto ref_info = frames_.find(info.dependent_frames[d]);
philipel93e451b2016-10-06 12:25:13 +0200309 RTC_DCHECK(ref_info != frames_.end());
philipele0b2f152016-09-28 10:23:49 +0200310 RTC_DCHECK_GT(ref_info->second.num_missing_decodable, 0U);
311 --ref_info->second.num_missing_decodable;
312 }
313}
314
315void FrameBuffer::AdvanceLastDecodedFrame(FrameMap::iterator decoded) {
tommidb23ea62017-03-03 07:21:18 -0800316 TRACE_EVENT0("webrtc", "FrameBuffer::AdvanceLastDecodedFrame");
philipele0b2f152016-09-28 10:23:49 +0200317 if (last_decoded_frame_it_ == frames_.end()) {
318 last_decoded_frame_it_ = frames_.begin();
319 } else {
320 RTC_DCHECK(last_decoded_frame_it_->first < decoded->first);
321 ++last_decoded_frame_it_;
322 }
323 --num_frames_buffered_;
324 ++num_frames_history_;
325
326 // First, delete non-decoded frames from the history.
327 while (last_decoded_frame_it_ != decoded) {
328 if (last_decoded_frame_it_->second.frame)
329 --num_frames_buffered_;
330 last_decoded_frame_it_ = frames_.erase(last_decoded_frame_it_);
philipelbe7a9e52016-05-19 12:19:35 +0200331 }
332
philipele0b2f152016-09-28 10:23:49 +0200333 // Then remove old history if we have too much history saved.
334 if (num_frames_history_ > kMaxFramesHistory) {
335 frames_.erase(frames_.begin());
336 --num_frames_history_;
337 }
338}
339
340bool FrameBuffer::UpdateFrameInfoWithIncomingFrame(const FrameObject& frame,
341 FrameMap::iterator info) {
tommidb23ea62017-03-03 07:21:18 -0800342 TRACE_EVENT0("webrtc", "FrameBuffer::UpdateFrameInfoWithIncomingFrame");
philipele0b2f152016-09-28 10:23:49 +0200343 FrameKey key(frame.picture_id, frame.spatial_layer);
344 info->second.num_missing_continuous = frame.num_references;
345 info->second.num_missing_decodable = frame.num_references;
346
347 RTC_DCHECK(last_decoded_frame_it_ == frames_.end() ||
348 last_decoded_frame_it_->first < info->first);
349
350 // Check how many dependencies that have already been fulfilled.
351 for (size_t i = 0; i < frame.num_references; ++i) {
352 FrameKey ref_key(frame.references[i], frame.spatial_layer);
353 auto ref_info = frames_.find(ref_key);
354
355 // Does |frame| depend on a frame earlier than the last decoded frame?
356 if (last_decoded_frame_it_ != frames_.end() &&
357 ref_key <= last_decoded_frame_it_->first) {
358 if (ref_info == frames_.end()) {
359 LOG(LS_WARNING) << "Frame with (picture_id:spatial_id) ("
360 << key.picture_id << ":"
361 << static_cast<int>(key.spatial_layer)
362 << " depends on a non-decoded frame more previous than "
363 << "the last decoded frame, dropping frame.";
364 return false;
365 }
366
367 --info->second.num_missing_continuous;
368 --info->second.num_missing_decodable;
369 } else {
370 if (ref_info == frames_.end())
371 ref_info = frames_.insert(std::make_pair(ref_key, FrameInfo())).first;
372
373 if (ref_info->second.continuous)
374 --info->second.num_missing_continuous;
375
376 // Add backwards reference so |frame| can be updated when new
377 // frames are inserted or decoded.
378 ref_info->second.dependent_frames[ref_info->second.num_dependent_frames] =
379 key;
380 ++ref_info->second.num_dependent_frames;
381 }
philipel93e451b2016-10-06 12:25:13 +0200382 RTC_DCHECK_LE(ref_info->second.num_missing_continuous,
383 ref_info->second.num_missing_decodable);
philipelbe7a9e52016-05-19 12:19:35 +0200384 }
385
philipele0b2f152016-09-28 10:23:49 +0200386 // Check if we have the lower spatial layer frame.
philipelbe7a9e52016-05-19 12:19:35 +0200387 if (frame.inter_layer_predicted) {
philipele0b2f152016-09-28 10:23:49 +0200388 ++info->second.num_missing_continuous;
389 ++info->second.num_missing_decodable;
390
philipelbe7a9e52016-05-19 12:19:35 +0200391 FrameKey ref_key(frame.picture_id, frame.spatial_layer - 1);
philipele0b2f152016-09-28 10:23:49 +0200392 // Gets or create the FrameInfo for the referenced frame.
393 auto ref_info = frames_.insert(std::make_pair(ref_key, FrameInfo())).first;
394 if (ref_info->second.continuous)
395 --info->second.num_missing_continuous;
396
397 if (ref_info == last_decoded_frame_it_) {
398 --info->second.num_missing_decodable;
399 } else {
400 ref_info->second.dependent_frames[ref_info->second.num_dependent_frames] =
401 key;
402 ++ref_info->second.num_dependent_frames;
403 }
philipel93e451b2016-10-06 12:25:13 +0200404 RTC_DCHECK_LE(ref_info->second.num_missing_continuous,
405 ref_info->second.num_missing_decodable);
philipelbe7a9e52016-05-19 12:19:35 +0200406 }
407
philipel93e451b2016-10-06 12:25:13 +0200408 RTC_DCHECK_LE(info->second.num_missing_continuous,
409 info->second.num_missing_decodable);
410
philipelbe7a9e52016-05-19 12:19:35 +0200411 return true;
412}
413
philipelbe742702016-11-30 01:31:40 -0800414void FrameBuffer::UpdateJitterDelay() {
tommidb23ea62017-03-03 07:21:18 -0800415 TRACE_EVENT0("webrtc", "FrameBuffer::UpdateJitterDelay");
philipela45102f2017-02-22 05:30:39 -0800416 if (!stats_callback_)
417 return;
philipelbe742702016-11-30 01:31:40 -0800418
philipela45102f2017-02-22 05:30:39 -0800419 int decode_ms;
420 int max_decode_ms;
421 int current_delay_ms;
422 int target_delay_ms;
423 int jitter_buffer_ms;
424 int min_playout_delay_ms;
425 int render_delay_ms;
426 if (timing_->GetTimings(&decode_ms, &max_decode_ms, &current_delay_ms,
427 &target_delay_ms, &jitter_buffer_ms,
428 &min_playout_delay_ms, &render_delay_ms)) {
429 stats_callback_->OnFrameBufferTimingsUpdated(
430 decode_ms, max_decode_ms, current_delay_ms, target_delay_ms,
431 jitter_buffer_ms, min_playout_delay_ms, render_delay_ms);
philipelbe742702016-11-30 01:31:40 -0800432 }
philipel266f0a42016-11-28 08:49:07 -0800433}
434
philipelfcc60062017-01-18 05:35:20 -0800435void FrameBuffer::ClearFramesAndHistory() {
tommidb23ea62017-03-03 07:21:18 -0800436 TRACE_EVENT0("webrtc", "FrameBuffer::UpdateJitterDelay");
philipelfcc60062017-01-18 05:35:20 -0800437 frames_.clear();
438 last_decoded_frame_it_ = frames_.end();
439 last_continuous_frame_it_ = frames_.end();
philipel1c056252017-01-31 09:53:12 -0800440 next_frame_it_ = frames_.end();
philipelfcc60062017-01-18 05:35:20 -0800441 num_frames_history_ = 0;
442 num_frames_buffered_ = 0;
443}
444
philipelbe7a9e52016-05-19 12:19:35 +0200445} // namespace video_coding
446} // namespace webrtc