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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 pending_read_(false), | 47 pending_read_(false), |
48 drop_frames_(drop_frames), | 48 drop_frames_(drop_frames), |
49 buffering_state_(BUFFERING_HAVE_NOTHING), | 49 buffering_state_(BUFFERING_HAVE_NOTHING), |
50 frames_decoded_(0), | 50 frames_decoded_(0), |
51 frames_dropped_(0), | 51 frames_dropped_(0), |
52 tick_clock_(new base::DefaultTickClock()), | 52 tick_clock_(new base::DefaultTickClock()), |
53 was_background_rendering_(false), | 53 was_background_rendering_(false), |
54 time_progressing_(false), | 54 time_progressing_(false), |
55 render_first_frame_and_stop_(false), | 55 render_first_frame_and_stop_(false), |
56 posted_maybe_stop_after_first_paint_(false), | 56 posted_maybe_stop_after_first_paint_(false), |
| 57 last_video_memory_usage_(0), |
57 weak_factory_(this) { | 58 weak_factory_(this) { |
58 if (gpu_factories && | 59 if (gpu_factories && |
59 gpu_factories->ShouldUseGpuMemoryBuffersForVideoFrames()) { | 60 gpu_factories->ShouldUseGpuMemoryBuffersForVideoFrames()) { |
60 gpu_memory_buffer_pool_.reset(new GpuMemoryBufferVideoFramePool( | 61 gpu_memory_buffer_pool_.reset(new GpuMemoryBufferVideoFramePool( |
61 media_task_runner, worker_task_runner, gpu_factories)); | 62 media_task_runner, worker_task_runner, gpu_factories)); |
62 } | 63 } |
63 } | 64 } |
64 | 65 |
65 VideoRendererImpl::~VideoRendererImpl() { | 66 VideoRendererImpl::~VideoRendererImpl() { |
66 DCHECK(task_runner_->BelongsToCurrentThread()); | 67 DCHECK(task_runner_->BelongsToCurrentThread()); |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 | 544 |
544 void VideoRendererImpl::UpdateStats_Locked() { | 545 void VideoRendererImpl::UpdateStats_Locked() { |
545 lock_.AssertAcquired(); | 546 lock_.AssertAcquired(); |
546 DCHECK_GE(frames_decoded_, 0); | 547 DCHECK_GE(frames_decoded_, 0); |
547 DCHECK_GE(frames_dropped_, 0); | 548 DCHECK_GE(frames_dropped_, 0); |
548 | 549 |
549 if (frames_decoded_ || frames_dropped_) { | 550 if (frames_decoded_ || frames_dropped_) { |
550 PipelineStatistics statistics; | 551 PipelineStatistics statistics; |
551 statistics.video_frames_decoded = frames_decoded_; | 552 statistics.video_frames_decoded = frames_decoded_; |
552 statistics.video_frames_dropped = frames_dropped_; | 553 statistics.video_frames_dropped = frames_dropped_; |
| 554 |
| 555 const size_t memory_usage = algorithm_->GetMemoryUsage(); |
| 556 statistics.video_memory_usage = memory_usage - last_video_memory_usage_; |
| 557 |
553 task_runner_->PostTask(FROM_HERE, base::Bind(statistics_cb_, statistics)); | 558 task_runner_->PostTask(FROM_HERE, base::Bind(statistics_cb_, statistics)); |
554 | |
555 frames_decoded_ = 0; | 559 frames_decoded_ = 0; |
556 frames_dropped_ = 0; | 560 frames_dropped_ = 0; |
| 561 last_video_memory_usage_ = memory_usage; |
557 } | 562 } |
558 } | 563 } |
559 | 564 |
560 void VideoRendererImpl::MaybeStopSinkAfterFirstPaint() { | 565 void VideoRendererImpl::MaybeStopSinkAfterFirstPaint() { |
561 DCHECK(task_runner_->BelongsToCurrentThread()); | 566 DCHECK(task_runner_->BelongsToCurrentThread()); |
562 | 567 |
563 if (!time_progressing_ && sink_started_) | 568 if (!time_progressing_ && sink_started_) |
564 StopSink(); | 569 StopSink(); |
565 | 570 |
566 base::AutoLock auto_lock(lock_); | 571 base::AutoLock auto_lock(lock_); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 base::TimeTicks VideoRendererImpl::ConvertMediaTimestamp( | 630 base::TimeTicks VideoRendererImpl::ConvertMediaTimestamp( |
626 base::TimeDelta media_time) { | 631 base::TimeDelta media_time) { |
627 std::vector<base::TimeDelta> media_times(1, media_time); | 632 std::vector<base::TimeDelta> media_times(1, media_time); |
628 std::vector<base::TimeTicks> wall_clock_times; | 633 std::vector<base::TimeTicks> wall_clock_times; |
629 if (!wall_clock_time_cb_.Run(media_times, &wall_clock_times)) | 634 if (!wall_clock_time_cb_.Run(media_times, &wall_clock_times)) |
630 return base::TimeTicks(); | 635 return base::TimeTicks(); |
631 return wall_clock_times[0]; | 636 return wall_clock_times[0]; |
632 } | 637 } |
633 | 638 |
634 } // namespace media | 639 } // namespace media |
OLD | NEW |