Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(388)

Side by Side Diff: media/renderers/video_renderer_impl.cc

Issue 1409123005: Add methods for telling V8 how much memory audio/video is using. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix html viewer. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/renderers/video_renderer_impl.h ('k') | media/renderers/video_renderer_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
OLDNEW
« no previous file with comments | « media/renderers/video_renderer_impl.h ('k') | media/renderers/video_renderer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698