OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/renderers/video_renderer_impl.h" | 5 #include "media/renderers/video_renderer_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
203 } | 203 } |
204 | 204 |
205 // We don't count dropped frames in the background to avoid skewing the count | 205 // We don't count dropped frames in the background to avoid skewing the count |
206 // and impacting JavaScript visible metrics used by web developers. | 206 // and impacting JavaScript visible metrics used by web developers. |
207 // | 207 // |
208 // Just after resuming from background rendering, we also don't count the | 208 // Just after resuming from background rendering, we also don't count the |
209 // dropped frames since they are likely just dropped due to being too old. | 209 // dropped frames since they are likely just dropped due to being too old. |
210 if (!background_rendering && !was_background_rendering_) | 210 if (!background_rendering && !was_background_rendering_) |
211 frames_dropped_ += frames_dropped; | 211 frames_dropped_ += frames_dropped; |
212 UpdateStats_Locked(); | 212 UpdateStats_Locked(); |
213 | |
214 if (was_background_rendering_ && !background_rendering) | |
215 shown_timestamp_ = tick_clock_->NowTicks(); | |
DaleCurtis
2016/12/03 01:26:34
Does this actually capture what you want? When vid
whywhat
2016/12/06 22:01:12
That seems to be the right place to detect when th
DaleCurtis
2016/12/06 23:26:58
This isn't called until playback starts. It's okay
whywhat
2016/12/08 00:23:17
Hm, seems like we'd be better off using the time_c
DaleCurtis
2016/12/08 19:04:46
I don't follow your suggestion? Are you suggesting
| |
216 | |
213 was_background_rendering_ = background_rendering; | 217 was_background_rendering_ = background_rendering; |
214 | 218 |
215 // Always post this task, it will acquire new frames if necessary and since it | 219 // Always post this task, it will acquire new frames if necessary and since it |
216 // happens on another thread, even if we don't have room in the queue now, by | 220 // happens on another thread, even if we don't have room in the queue now, by |
217 // the time it runs (may be delayed up to 50ms for complex decodes!) we might. | 221 // the time it runs (may be delayed up to 50ms for complex decodes!) we might. |
218 task_runner_->PostTask( | 222 task_runner_->PostTask( |
219 FROM_HERE, | 223 FROM_HERE, |
220 base::Bind(&VideoRendererImpl::AttemptReadAndCheckForMetadataChanges, | 224 base::Bind(&VideoRendererImpl::AttemptReadAndCheckForMetadataChanges, |
221 weak_factory_.GetWeakPtr(), result->format(), | 225 weak_factory_.GetWeakPtr(), result->format(), |
222 result->natural_size())); | 226 result->natural_size())); |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
415 // prerolling frames before the actual start time that will be dropped. | 419 // prerolling frames before the actual start time that will be dropped. |
416 if (algorithm_->frames_queued() > 1 || received_end_of_stream_ || | 420 if (algorithm_->frames_queued() > 1 || received_end_of_stream_ || |
417 frame->timestamp() >= start_timestamp_ || low_delay_ || | 421 frame->timestamp() >= start_timestamp_ || low_delay_ || |
418 !video_frame_stream_->CanReadWithoutStalling()) { | 422 !video_frame_stream_->CanReadWithoutStalling()) { |
419 scoped_refptr<VideoFrame> first_frame = | 423 scoped_refptr<VideoFrame> first_frame = |
420 algorithm_->Render(base::TimeTicks(), base::TimeTicks(), nullptr); | 424 algorithm_->Render(base::TimeTicks(), base::TimeTicks(), nullptr); |
421 CheckForMetadataChanges(first_frame->format(), | 425 CheckForMetadataChanges(first_frame->format(), |
422 first_frame->natural_size()); | 426 first_frame->natural_size()); |
423 sink_->PaintSingleFrame(first_frame); | 427 sink_->PaintSingleFrame(first_frame); |
424 painted_first_frame_ = true; | 428 painted_first_frame_ = true; |
429 | |
430 if (!shown_timestamp_.is_null()) { | |
431 UMA_HISTOGRAM_MEDIUM_TIMES("Media.Video.TimeFromShownToFirstFrame", | |
432 tick_clock_->NowTicks() - shown_timestamp_); | |
433 shown_timestamp_ = base::TimeTicks(); | |
434 } | |
425 } | 435 } |
426 } | 436 } |
427 | 437 |
428 // Signal buffering state if we've met our conditions. | 438 // Signal buffering state if we've met our conditions. |
429 if (buffering_state_ == BUFFERING_HAVE_NOTHING && HaveEnoughData_Locked()) | 439 if (buffering_state_ == BUFFERING_HAVE_NOTHING && HaveEnoughData_Locked()) |
430 TransitionToHaveEnough_Locked(); | 440 TransitionToHaveEnough_Locked(); |
431 | 441 |
432 // Always request more decoded video if we have capacity. | 442 // Always request more decoded video if we have capacity. |
433 AttemptRead_Locked(); | 443 AttemptRead_Locked(); |
434 } | 444 } |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
710 | 720 |
711 void VideoRendererImpl::AttemptReadAndCheckForMetadataChanges( | 721 void VideoRendererImpl::AttemptReadAndCheckForMetadataChanges( |
712 VideoPixelFormat pixel_format, | 722 VideoPixelFormat pixel_format, |
713 const gfx::Size& natural_size) { | 723 const gfx::Size& natural_size) { |
714 base::AutoLock auto_lock(lock_); | 724 base::AutoLock auto_lock(lock_); |
715 CheckForMetadataChanges(pixel_format, natural_size); | 725 CheckForMetadataChanges(pixel_format, natural_size); |
716 AttemptRead_Locked(); | 726 AttemptRead_Locked(); |
717 } | 727 } |
718 | 728 |
719 } // namespace media | 729 } // namespace media |
OLD | NEW |