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

Side by Side Diff: media/filters/gpu_video_decoder.cc

Issue 2064083002: media: Add Rappor reporting in MediaLog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more fixes 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/filters/gpu_video_decoder.h" 5 #include "media/filters/gpu_video_decoder.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/callback_helpers.h" 11 #include "base/callback_helpers.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/cpu.h" 13 #include "base/cpu.h"
14 #include "base/location.h" 14 #include "base/location.h"
15 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
16 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
17 #include "base/single_thread_task_runner.h" 17 #include "base/single_thread_task_runner.h"
18 #include "base/stl_util.h" 18 #include "base/stl_util.h"
19 #include "base/task_runner_util.h" 19 #include "base/task_runner_util.h"
20 #include "base/threading/thread_task_runner_handle.h" 20 #include "base/threading/thread_task_runner_handle.h"
21 #include "build/build_config.h" 21 #include "build/build_config.h"
22 #include "gpu/command_buffer/common/mailbox_holder.h" 22 #include "gpu/command_buffer/common/mailbox_holder.h"
23 #include "media/base/bind_to_current_loop.h" 23 #include "media/base/bind_to_current_loop.h"
24 #include "media/base/cdm_context.h" 24 #include "media/base/cdm_context.h"
25 #include "media/base/decoder_buffer.h" 25 #include "media/base/decoder_buffer.h"
26 #include "media/base/media_log.h"
26 #include "media/base/media_switches.h" 27 #include "media/base/media_switches.h"
27 #include "media/base/pipeline_status.h" 28 #include "media/base/pipeline_status.h"
28 #include "media/base/surface_manager.h" 29 #include "media/base/surface_manager.h"
29 #include "media/base/video_decoder_config.h" 30 #include "media/base/video_decoder_config.h"
30 #include "media/renderers/gpu_video_accelerator_factories.h" 31 #include "media/renderers/gpu_video_accelerator_factories.h"
31 #include "third_party/skia/include/core/SkBitmap.h" 32 #include "third_party/skia/include/core/SkBitmap.h"
32 33
33 namespace media { 34 namespace media {
34 35
35 const char GpuVideoDecoder::kDecoderName[] = "GpuVideoDecoder"; 36 const char GpuVideoDecoder::kDecoderName[] = "GpuVideoDecoder";
(...skipping 30 matching lines...) Expand all
66 const gfx::Rect& vr, 67 const gfx::Rect& vr,
67 const gfx::Size& ns) 68 const gfx::Size& ns)
68 : bitstream_buffer_id(bbid), 69 : bitstream_buffer_id(bbid),
69 timestamp(ts), 70 timestamp(ts),
70 visible_rect(vr), 71 visible_rect(vr),
71 natural_size(ns) {} 72 natural_size(ns) {}
72 73
73 GpuVideoDecoder::BufferData::~BufferData() {} 74 GpuVideoDecoder::BufferData::~BufferData() {}
74 75
75 GpuVideoDecoder::GpuVideoDecoder(GpuVideoAcceleratorFactories* factories, 76 GpuVideoDecoder::GpuVideoDecoder(GpuVideoAcceleratorFactories* factories,
76 const RequestSurfaceCB& request_surface_cb) 77 const RequestSurfaceCB& request_surface_cb,
78 scoped_refptr<MediaLog> media_log)
77 : needs_bitstream_conversion_(false), 79 : needs_bitstream_conversion_(false),
78 factories_(factories), 80 factories_(factories),
81 request_surface_cb_(request_surface_cb),
82 media_log_(media_log),
DaleCurtis 2016/06/15 00:33:47 Need to use std::move() if you drop const& I thoug
xhwang 2016/06/15 04:48:49 https://www.chromium.org/developers/coding-style
79 state_(kNormal), 83 state_(kNormal),
80 request_surface_cb_(request_surface_cb),
81 decoder_texture_target_(0), 84 decoder_texture_target_(0),
82 pixel_format_(PIXEL_FORMAT_UNKNOWN), 85 pixel_format_(PIXEL_FORMAT_UNKNOWN),
83 next_picture_buffer_id_(0), 86 next_picture_buffer_id_(0),
84 next_bitstream_buffer_id_(0), 87 next_bitstream_buffer_id_(0),
85 available_pictures_(0), 88 available_pictures_(0),
86 needs_all_picture_buffers_to_decode_(false), 89 needs_all_picture_buffers_to_decode_(false),
87 supports_deferred_initialization_(false), 90 supports_deferred_initialization_(false),
88 weak_factory_(this) { 91 weak_factory_(this) {
89 DCHECK(factories_); 92 DCHECK(factories_);
90 } 93 }
(...skipping 25 matching lines...) Expand all
116 const gfx::Size& max_resolution) { 119 const gfx::Size& max_resolution) {
117 return (coded_size.width() <= max_resolution.width() && 120 return (coded_size.width() <= max_resolution.width() &&
118 coded_size.height() <= max_resolution.height() && 121 coded_size.height() <= max_resolution.height() &&
119 coded_size.width() >= min_resolution.width() && 122 coded_size.width() >= min_resolution.width() &&
120 coded_size.height() >= min_resolution.height()); 123 coded_size.height() >= min_resolution.height());
121 } 124 }
122 125
123 // Report |success| to UMA and run |cb| with it. This is super-specific to the 126 // Report |success| to UMA and run |cb| with it. This is super-specific to the
124 // UMA stat reported because the UMA_HISTOGRAM_ENUMERATION API requires a 127 // UMA stat reported because the UMA_HISTOGRAM_ENUMERATION API requires a
125 // callsite to always be called with the same stat name (can't parameterize it). 128 // callsite to always be called with the same stat name (can't parameterize it).
126 static void ReportGpuVideoDecoderInitializeStatusToUMAAndRunCB( 129 static void ReportGpuVideoDecoderInitializeStatusToUMAAndRunCB(
xhwang 2016/06/15 00:19:07 Today this is called for all init cases. When a fa
DaleCurtis 2016/06/15 00:33:47 Well, the problem is we can't tell the difference
xhwang 2016/06/15 04:48:49 Yeah, I feel it's nicer if we can at least disting
127 const VideoDecoder::InitCB& cb, 130 const VideoDecoder::InitCB& cb,
131 scoped_refptr<MediaLog> media_log,
128 bool success) { 132 bool success) {
129 // TODO(xhwang): Report |success| directly. 133 // TODO(xhwang): Report |success| directly.
130 PipelineStatus status = success ? PIPELINE_OK : DECODER_ERROR_NOT_SUPPORTED; 134 PipelineStatus status = success ? PIPELINE_OK : DECODER_ERROR_NOT_SUPPORTED;
131 UMA_HISTOGRAM_ENUMERATION( 135 UMA_HISTOGRAM_ENUMERATION(
132 "Media.GpuVideoDecoderInitializeStatus", status, PIPELINE_STATUS_MAX + 1); 136 "Media.GpuVideoDecoderInitializeStatus", status, PIPELINE_STATUS_MAX + 1);
137
138 if (!success) {
139 media_log->RecordRapporWithSecurityOrigin(
140 "Media.OriginUrl.GpuVideoDecoderInitFailure");
141 }
142
133 cb.Run(success); 143 cb.Run(success);
134 } 144 }
135 145
136 // static 146 // static
137 void ReleaseMailboxTrampoline( 147 void ReleaseMailboxTrampoline(
138 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 148 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
139 const VideoFrame::ReleaseMailboxCB& release_mailbox_cb, 149 const VideoFrame::ReleaseMailboxCB& release_mailbox_cb,
140 const gpu::SyncToken& release_sync_token) { 150 const gpu::SyncToken& release_sync_token) {
141 if (task_runner->BelongsToCurrentThread()) { 151 if (task_runner->BelongsToCurrentThread()) {
142 release_mailbox_cb.Run(release_sync_token); 152 release_mailbox_cb.Run(release_sync_token);
(...skipping 12 matching lines...) Expand all
155 bool /* low_delay */, 165 bool /* low_delay */,
156 CdmContext* cdm_context, 166 CdmContext* cdm_context,
157 const InitCB& init_cb, 167 const InitCB& init_cb,
158 const OutputCB& output_cb) { 168 const OutputCB& output_cb) {
159 DVLOG(3) << "Initialize()"; 169 DVLOG(3) << "Initialize()";
160 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); 170 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
161 DCHECK(config.IsValidConfig()); 171 DCHECK(config.IsValidConfig());
162 172
163 InitCB bound_init_cb = 173 InitCB bound_init_cb =
164 base::Bind(&ReportGpuVideoDecoderInitializeStatusToUMAAndRunCB, 174 base::Bind(&ReportGpuVideoDecoderInitializeStatusToUMAAndRunCB,
165 BindToCurrentLoop(init_cb)); 175 BindToCurrentLoop(init_cb), media_log_);
166 176
167 #if !defined(OS_ANDROID) 177 #if !defined(OS_ANDROID)
168 if (config.is_encrypted()) { 178 if (config.is_encrypted()) {
169 DVLOG(1) << "Encrypted stream not supported."; 179 DVLOG(1) << "Encrypted stream not supported.";
170 bound_init_cb.Run(false); 180 bound_init_cb.Run(false);
171 return; 181 return;
172 } 182 }
173 #endif 183 #endif
174 184
175 bool previously_initialized = config_.IsValidConfig(); 185 bool previously_initialized = config_.IsValidConfig();
176 DVLOG(1) << (previously_initialized ? "Reinitializing" : "Initializing") 186 DVLOG(1) << (previously_initialized ? "Reinitializing" : "Initializing")
177 << "GVD with config: " << config.AsHumanReadableString(); 187 << " GVD with config: " << config.AsHumanReadableString();
178 188
179 // TODO(posciak): destroy and create a new VDA on codec/profile change 189 // TODO(posciak): destroy and create a new VDA on codec/profile change
180 // (http://crbug.com/260224). 190 // (http://crbug.com/260224).
181 if (previously_initialized && (config_.profile() != config.profile())) { 191 if (previously_initialized && (config_.profile() != config.profile())) {
182 DVLOG(1) << "Codec or profile changed, cannot reinitialize."; 192 DVLOG(1) << "Codec or profile changed, cannot reinitialize.";
183 bound_init_cb.Run(false); 193 bound_init_cb.Run(false);
184 return; 194 return;
185 } 195 }
186 196
187 VideoDecodeAccelerator::Capabilities capabilities = 197 VideoDecodeAccelerator::Capabilities capabilities =
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 } 801 }
792 return false; 802 return false;
793 } 803 }
794 804
795 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() 805 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent()
796 const { 806 const {
797 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); 807 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread());
798 } 808 }
799 809
800 } // namespace media 810 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698