OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 } | 128 } |
129 float rtt_mult = protection_mode_ == kProtectionNackFEC ? 0.0 : 1.0; | 129 float rtt_mult = protection_mode_ == kProtectionNackFEC ? 0.0 : 1.0; |
130 timing_->SetJitterDelay(jitter_estimator_->GetJitterEstimate(rtt_mult)); | 130 timing_->SetJitterDelay(jitter_estimator_->GetJitterEstimate(rtt_mult)); |
131 timing_->UpdateCurrentDelay(frame->RenderTime(), | 131 timing_->UpdateCurrentDelay(frame->RenderTime(), |
132 clock_->TimeInMilliseconds()); | 132 clock_->TimeInMilliseconds()); |
133 | 133 |
134 UpdateJitterDelay(); | 134 UpdateJitterDelay(); |
135 | 135 |
136 PropagateDecodability(next_frame_it->second); | 136 PropagateDecodability(next_frame_it->second); |
137 AdvanceLastDecodedFrame(next_frame_it); | 137 AdvanceLastDecodedFrame(next_frame_it); |
| 138 last_decoded_frame_timestamp_ = frame->timestamp; |
138 *frame_out = std::move(frame); | 139 *frame_out = std::move(frame); |
139 return kFrameFound; | 140 return kFrameFound; |
140 } else { | 141 } else { |
141 return kTimeout; | 142 return kTimeout; |
142 } | 143 } |
143 } | 144 } |
144 | 145 |
145 void FrameBuffer::SetProtectionMode(VCMVideoProtection mode) { | 146 void FrameBuffer::SetProtectionMode(VCMVideoProtection mode) { |
146 rtc::CritScope lock(&crit_); | 147 rtc::CritScope lock(&crit_); |
147 protection_mode_ = mode; | 148 protection_mode_ = mode; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 | 183 |
183 if (frame->inter_layer_predicted && frame->spatial_layer == 0) { | 184 if (frame->inter_layer_predicted && frame->spatial_layer == 0) { |
184 LOG(LS_WARNING) << "Frame with (picture_id:spatial_id) (" << key.picture_id | 185 LOG(LS_WARNING) << "Frame with (picture_id:spatial_id) (" << key.picture_id |
185 << ":" << static_cast<int>(key.spatial_layer) | 186 << ":" << static_cast<int>(key.spatial_layer) |
186 << ") is marked as inter layer predicted, dropping frame."; | 187 << ") is marked as inter layer predicted, dropping frame."; |
187 return last_continuous_picture_id; | 188 return last_continuous_picture_id; |
188 } | 189 } |
189 | 190 |
190 if (last_decoded_frame_it_ != frames_.end() && | 191 if (last_decoded_frame_it_ != frames_.end() && |
191 key < last_decoded_frame_it_->first) { | 192 key < last_decoded_frame_it_->first) { |
192 LOG(LS_WARNING) << "Frame with (picture_id:spatial_id) (" << key.picture_id | 193 if (AheadOf(frame->timestamp, last_decoded_frame_timestamp_) && |
193 << ":" << static_cast<int>(key.spatial_layer) | 194 frame->num_references == 0) { |
194 << ") inserted after frame (" | 195 // If this frame has a newer timestamp but an earlier picture id then we |
195 << last_decoded_frame_it_->first.picture_id << ":" | 196 // assume there has been a jump in the picture id due to some encoder |
196 << static_cast<int>( | 197 // reconfiguration or some other reason. Even though this is not according |
197 last_decoded_frame_it_->first.spatial_layer) | 198 // to spec we can still continue to decode from this frame if it is a |
198 << ") was handed off for decoding, dropping frame."; | 199 // keyframe. |
199 return last_continuous_picture_id; | 200 LOG(LS_WARNING) << "A jump in picture id was detected, clearing buffer."; |
| 201 ClearFramesAndHistory(); |
| 202 last_continuous_picture_id = -1; |
| 203 } else { |
| 204 LOG(LS_WARNING) << "Frame with (picture_id:spatial_id) (" |
| 205 << key.picture_id << ":" |
| 206 << static_cast<int>(key.spatial_layer) |
| 207 << ") inserted after frame (" |
| 208 << last_decoded_frame_it_->first.picture_id << ":" |
| 209 << static_cast<int>( |
| 210 last_decoded_frame_it_->first.spatial_layer) |
| 211 << ") was handed off for decoding, dropping frame."; |
| 212 return last_continuous_picture_id; |
| 213 } |
200 } | 214 } |
201 | 215 |
202 auto info = frames_.insert(std::make_pair(key, FrameInfo())).first; | 216 auto info = frames_.insert(std::make_pair(key, FrameInfo())).first; |
203 | 217 |
204 if (info->second.frame) { | 218 if (info->second.frame) { |
205 LOG(LS_WARNING) << "Frame with (picture_id:spatial_id) (" << key.picture_id | 219 LOG(LS_WARNING) << "Frame with (picture_id:spatial_id) (" << key.picture_id |
206 << ":" << static_cast<int>(key.spatial_layer) | 220 << ":" << static_cast<int>(key.spatial_layer) |
207 << ") already inserted, dropping frame."; | 221 << ") already inserted, dropping frame."; |
208 return last_continuous_picture_id; | 222 return last_continuous_picture_id; |
209 } | 223 } |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 RTC_HISTOGRAM_COUNTS_1000("WebRTC.Video.KeyFramesReceivedInPermille", | 397 RTC_HISTOGRAM_COUNTS_1000("WebRTC.Video.KeyFramesReceivedInPermille", |
384 key_frames_permille); | 398 key_frames_permille); |
385 } | 399 } |
386 | 400 |
387 if (accumulated_delay_samples_ > 0) { | 401 if (accumulated_delay_samples_ > 0) { |
388 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.JitterBufferDelayInMs", | 402 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.JitterBufferDelayInMs", |
389 accumulated_delay_ / accumulated_delay_samples_); | 403 accumulated_delay_ / accumulated_delay_samples_); |
390 } | 404 } |
391 } | 405 } |
392 | 406 |
| 407 void FrameBuffer::ClearFramesAndHistory() { |
| 408 frames_.clear(); |
| 409 last_decoded_frame_it_ = frames_.end(); |
| 410 last_continuous_frame_it_ = frames_.end(); |
| 411 num_frames_history_ = 0; |
| 412 num_frames_buffered_ = 0; |
| 413 } |
| 414 |
393 } // namespace video_coding | 415 } // namespace video_coding |
394 } // namespace webrtc | 416 } // namespace webrtc |
OLD | NEW |