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

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

Issue 2079923002: Combine bytes-decoded notification with memory usage and frame count. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 months 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') | no next file » | 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 <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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 media_log)), 44 media_log)),
45 gpu_memory_buffer_pool_(nullptr), 45 gpu_memory_buffer_pool_(nullptr),
46 media_log_(media_log), 46 media_log_(media_log),
47 low_delay_(false), 47 low_delay_(false),
48 received_end_of_stream_(false), 48 received_end_of_stream_(false),
49 rendered_end_of_stream_(false), 49 rendered_end_of_stream_(false),
50 state_(kUninitialized), 50 state_(kUninitialized),
51 pending_read_(false), 51 pending_read_(false),
52 drop_frames_(drop_frames), 52 drop_frames_(drop_frames),
53 buffering_state_(BUFFERING_HAVE_NOTHING), 53 buffering_state_(BUFFERING_HAVE_NOTHING),
54 bytes_decoded_(0),
54 frames_decoded_(0), 55 frames_decoded_(0),
55 frames_dropped_(0), 56 frames_dropped_(0),
56 tick_clock_(new base::DefaultTickClock()), 57 tick_clock_(new base::DefaultTickClock()),
57 was_background_rendering_(false), 58 was_background_rendering_(false),
58 time_progressing_(false), 59 time_progressing_(false),
59 last_video_memory_usage_(0), 60 last_video_memory_usage_(0),
60 have_renderered_frames_(false), 61 have_renderered_frames_(false),
61 last_frame_opaque_(false), 62 last_frame_opaque_(false),
62 weak_factory_(this), 63 weak_factory_(this),
63 frame_callback_weak_factory_(this) { 64 frame_callback_weak_factory_(this) {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 // failed. 151 // failed.
151 init_cb_ = BindToCurrentLoop(init_cb); 152 init_cb_ = BindToCurrentLoop(init_cb);
152 153
153 client_ = client; 154 client_ = client;
154 wall_clock_time_cb_ = wall_clock_time_cb; 155 wall_clock_time_cb_ = wall_clock_time_cb;
155 state_ = kInitializing; 156 state_ = kInitializing;
156 157
157 video_frame_stream_->Initialize( 158 video_frame_stream_->Initialize(
158 stream, base::Bind(&VideoRendererImpl::OnVideoFrameStreamInitialized, 159 stream, base::Bind(&VideoRendererImpl::OnVideoFrameStreamInitialized,
159 weak_factory_.GetWeakPtr()), 160 weak_factory_.GetWeakPtr()),
160 cdm_context, base::Bind(&VideoRendererImpl::OnStatisticsUpdate, 161 cdm_context,
161 weak_factory_.GetWeakPtr()), 162 base::Bind(&VideoRendererImpl::BytesDecoded, weak_factory_.GetWeakPtr()),
DaleCurtis 2016/06/17 23:03:17 This is only returned when a frame is decoded, so
alokp 2016/06/18 04:18:06 We could do that, but what do you want to do for A
162 base::Bind(&VideoRendererImpl::OnWaitingForDecryptionKey, 163 base::Bind(&VideoRendererImpl::OnWaitingForDecryptionKey,
163 weak_factory_.GetWeakPtr())); 164 weak_factory_.GetWeakPtr()));
164 } 165 }
165 166
166 scoped_refptr<VideoFrame> VideoRendererImpl::Render( 167 scoped_refptr<VideoFrame> VideoRendererImpl::Render(
167 base::TimeTicks deadline_min, 168 base::TimeTicks deadline_min,
168 base::TimeTicks deadline_max, 169 base::TimeTicks deadline_max,
169 bool background_rendering) { 170 bool background_rendering) {
170 base::AutoLock auto_lock(lock_); 171 base::AutoLock auto_lock(lock_);
171 DCHECK_EQ(state_, kPlaying); 172 DCHECK_EQ(state_, kPlaying);
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 311
311 // Make sure we expire everything we can if we can't read anymore currently, 312 // Make sure we expire everything we can if we can't read anymore currently,
312 // otherwise playback may hang indefinitely. Note: There are no effective 313 // otherwise playback may hang indefinitely. Note: There are no effective
313 // frames queued at this point, otherwise FrameReady() would have canceled 314 // frames queued at this point, otherwise FrameReady() would have canceled
314 // the underflow state before reaching this point. 315 // the underflow state before reaching this point.
315 if (buffering_state_ == BUFFERING_HAVE_NOTHING) 316 if (buffering_state_ == BUFFERING_HAVE_NOTHING)
316 RemoveFramesForUnderflowOrBackgroundRendering(); 317 RemoveFramesForUnderflowOrBackgroundRendering();
317 } 318 }
318 } 319 }
319 320
321 void VideoRendererImpl::BytesDecoded(uint64_t bytes) {
322 DCHECK(task_runner_->BelongsToCurrentThread());
323 base::AutoLock auto_lock(lock_);
324 bytes_decoded_ += bytes;
325 }
326
320 void VideoRendererImpl::FrameReadyForCopyingToGpuMemoryBuffers( 327 void VideoRendererImpl::FrameReadyForCopyingToGpuMemoryBuffers(
321 VideoFrameStream::Status status, 328 VideoFrameStream::Status status,
322 const scoped_refptr<VideoFrame>& frame) { 329 const scoped_refptr<VideoFrame>& frame) {
323 if (status != VideoFrameStream::OK || IsBeforeStartTime(frame->timestamp())) { 330 if (status != VideoFrameStream::OK || IsBeforeStartTime(frame->timestamp())) {
324 VideoRendererImpl::FrameReady(status, frame); 331 VideoRendererImpl::FrameReady(status, frame);
325 return; 332 return;
326 } 333 }
327 334
328 DCHECK(frame); 335 DCHECK(frame);
329 gpu_memory_buffer_pool_->MaybeCreateHardwareFrame( 336 gpu_memory_buffer_pool_->MaybeCreateHardwareFrame(
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 base::ResetAndReturn(&flush_cb_).Run(); 533 base::ResetAndReturn(&flush_cb_).Run();
527 } 534 }
528 535
529 void VideoRendererImpl::UpdateStats_Locked() { 536 void VideoRendererImpl::UpdateStats_Locked() {
530 lock_.AssertAcquired(); 537 lock_.AssertAcquired();
531 DCHECK_GE(frames_decoded_, 0); 538 DCHECK_GE(frames_decoded_, 0);
532 DCHECK_GE(frames_dropped_, 0); 539 DCHECK_GE(frames_dropped_, 0);
533 540
534 if (frames_decoded_ || frames_dropped_) { 541 if (frames_decoded_ || frames_dropped_) {
535 PipelineStatistics statistics; 542 PipelineStatistics statistics;
543 statistics.video_bytes_decoded = bytes_decoded_;
536 statistics.video_frames_decoded = frames_decoded_; 544 statistics.video_frames_decoded = frames_decoded_;
537 statistics.video_frames_dropped = frames_dropped_; 545 statistics.video_frames_dropped = frames_dropped_;
538 546
539 const size_t memory_usage = algorithm_->GetMemoryUsage(); 547 const size_t memory_usage = algorithm_->GetMemoryUsage();
540 statistics.video_memory_usage = memory_usage - last_video_memory_usage_; 548 statistics.video_memory_usage = memory_usage - last_video_memory_usage_;
541 549
542 task_runner_->PostTask(FROM_HERE, 550 task_runner_->PostTask(FROM_HERE,
543 base::Bind(&VideoRendererImpl::OnStatisticsUpdate, 551 base::Bind(&VideoRendererImpl::OnStatisticsUpdate,
544 weak_factory_.GetWeakPtr(), statistics)); 552 weak_factory_.GetWeakPtr(), statistics));
553 bytes_decoded_ = 0;
545 frames_decoded_ = 0; 554 frames_decoded_ = 0;
546 frames_dropped_ = 0; 555 frames_dropped_ = 0;
547 last_video_memory_usage_ = memory_usage; 556 last_video_memory_usage_ = memory_usage;
548 } 557 }
549 } 558 }
550 559
551 bool VideoRendererImpl::HaveReachedBufferingCap() { 560 bool VideoRendererImpl::HaveReachedBufferingCap() {
552 DCHECK(task_runner_->BelongsToCurrentThread()); 561 DCHECK(task_runner_->BelongsToCurrentThread());
553 const size_t kMaxVideoFrames = limits::kMaxVideoFrames; 562 const size_t kMaxVideoFrames = limits::kMaxVideoFrames;
554 563
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 696
688 void VideoRendererImpl::AttemptReadAndCheckForMetadataChanges( 697 void VideoRendererImpl::AttemptReadAndCheckForMetadataChanges(
689 VideoPixelFormat pixel_format, 698 VideoPixelFormat pixel_format,
690 const gfx::Size& natural_size) { 699 const gfx::Size& natural_size) {
691 base::AutoLock auto_lock(lock_); 700 base::AutoLock auto_lock(lock_);
692 CheckForMetadataChanges(pixel_format, natural_size); 701 CheckForMetadataChanges(pixel_format, natural_size);
693 AttemptRead_Locked(); 702 AttemptRead_Locked();
694 } 703 }
695 704
696 } // namespace media 705 } // namespace media
OLDNEW
« no previous file with comments | « media/renderers/video_renderer_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698