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

Side by Side Diff: content/browser/renderer_host/media/video_capture_gpu_jpeg_decoder.cc

Issue 2911063002: Deprecate NonThreadSafe in content/browser/renderer_host/media/video_capture_gpu_jpeg_decoder.h in … (Closed)
Patch Set: merge .cc in same CL Created 3 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 | « content/browser/renderer_host/media/video_capture_gpu_jpeg_decoder.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "content/browser/renderer_host/media/video_capture_gpu_jpeg_decoder.h" 5 #include "content/browser/renderer_host/media/video_capture_gpu_jpeg_decoder.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 18 matching lines...) Expand all
29 DecodeDoneCB decode_done_cb, 29 DecodeDoneCB decode_done_cb,
30 base::Callback<void(const std::string&)> send_log_message_cb) 30 base::Callback<void(const std::string&)> send_log_message_cb)
31 : decode_done_cb_(std::move(decode_done_cb)), 31 : decode_done_cb_(std::move(decode_done_cb)),
32 send_log_message_cb_(std::move(send_log_message_cb)), 32 send_log_message_cb_(std::move(send_log_message_cb)),
33 has_received_decoded_frame_(false), 33 has_received_decoded_frame_(false),
34 next_bitstream_buffer_id_(0), 34 next_bitstream_buffer_id_(0),
35 in_buffer_id_(media::JpegDecodeAccelerator::kInvalidBitstreamBufferId), 35 in_buffer_id_(media::JpegDecodeAccelerator::kInvalidBitstreamBufferId),
36 decoder_status_(INIT_PENDING) {} 36 decoder_status_(INIT_PENDING) {}
37 37
38 VideoCaptureGpuJpegDecoder::~VideoCaptureGpuJpegDecoder() { 38 VideoCaptureGpuJpegDecoder::~VideoCaptureGpuJpegDecoder() {
39 DCHECK(CalledOnValidThread()); 39 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
40 40
41 // |decoder_| guarantees no more JpegDecodeAccelerator::Client callbacks 41 // |decoder_| guarantees no more JpegDecodeAccelerator::Client callbacks
42 // on IO thread after deletion. 42 // on IO thread after deletion.
43 decoder_.reset(); 43 decoder_.reset();
44 44
45 // |gpu_channel_host_| should outlive |decoder_|, so |gpu_channel_host_| 45 // |gpu_channel_host_| should outlive |decoder_|, so |gpu_channel_host_|
46 // must be released after |decoder_| has been destroyed. 46 // must be released after |decoder_| has been destroyed.
47 gpu_channel_host_ = nullptr; 47 gpu_channel_host_ = nullptr;
48 } 48 }
49 49
50 void VideoCaptureGpuJpegDecoder::Initialize() { 50 void VideoCaptureGpuJpegDecoder::Initialize() {
51 DCHECK(CalledOnValidThread()); 51 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
52 52
53 base::AutoLock lock(lock_); 53 base::AutoLock lock(lock_);
54 bool is_platform_supported = 54 bool is_platform_supported =
55 base::CommandLine::ForCurrentProcess()->HasSwitch( 55 base::CommandLine::ForCurrentProcess()->HasSwitch(
56 switches::kUseFakeJpegDecodeAccelerator); 56 switches::kUseFakeJpegDecodeAccelerator);
57 #if defined(OS_CHROMEOS) 57 #if defined(OS_CHROMEOS)
58 // Non-ChromeOS platforms do not support HW JPEG decode now. Do not establish 58 // Non-ChromeOS platforms do not support HW JPEG decode now. Do not establish
59 // gpu channel to avoid introducing overhead. 59 // gpu channel to avoid introducing overhead.
60 is_platform_supported = true; 60 is_platform_supported = true;
61 #endif 61 #endif
62 62
63 if (!is_platform_supported || 63 if (!is_platform_supported ||
64 base::CommandLine::ForCurrentProcess()->HasSwitch( 64 base::CommandLine::ForCurrentProcess()->HasSwitch(
65 switches::kDisableAcceleratedMjpegDecode)) { 65 switches::kDisableAcceleratedMjpegDecode)) {
66 decoder_status_ = FAILED; 66 decoder_status_ = FAILED;
67 RecordInitDecodeUMA_Locked(); 67 RecordInitDecodeUMA_Locked();
68 return; 68 return;
69 } 69 }
70 70
71 const scoped_refptr<base::SingleThreadTaskRunner> current_task_runner( 71 const scoped_refptr<base::SingleThreadTaskRunner> current_task_runner(
72 base::ThreadTaskRunnerHandle::Get()); 72 base::ThreadTaskRunnerHandle::Get());
73 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 73 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
74 base::Bind(&EstablishGpuChannelOnUIThread, 74 base::Bind(&EstablishGpuChannelOnUIThread,
75 current_task_runner, AsWeakPtr())); 75 current_task_runner, AsWeakPtr()));
76 } 76 }
77 77
78 VideoCaptureGpuJpegDecoder::STATUS VideoCaptureGpuJpegDecoder::GetStatus() 78 VideoCaptureGpuJpegDecoder::STATUS VideoCaptureGpuJpegDecoder::GetStatus()
79 const { 79 const {
80 DCHECK(CalledOnValidThread()); 80 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
81 base::AutoLock lock(lock_); 81 base::AutoLock lock(lock_);
82 return decoder_status_; 82 return decoder_status_;
83 } 83 }
84 84
85 void VideoCaptureGpuJpegDecoder::DecodeCapturedData( 85 void VideoCaptureGpuJpegDecoder::DecodeCapturedData(
86 const uint8_t* data, 86 const uint8_t* data,
87 size_t in_buffer_size, 87 size_t in_buffer_size,
88 const media::VideoCaptureFormat& frame_format, 88 const media::VideoCaptureFormat& frame_format,
89 base::TimeTicks reference_time, 89 base::TimeTicks reference_time,
90 base::TimeDelta timestamp, 90 base::TimeDelta timestamp,
91 media::VideoCaptureDevice::Client::Buffer out_buffer) { 91 media::VideoCaptureDevice::Client::Buffer out_buffer) {
92 DCHECK(CalledOnValidThread()); 92 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
93 DCHECK(decoder_); 93 DCHECK(decoder_);
94 94
95 TRACE_EVENT_ASYNC_BEGIN0("jpeg", "VideoCaptureGpuJpegDecoder decoding", 95 TRACE_EVENT_ASYNC_BEGIN0("jpeg", "VideoCaptureGpuJpegDecoder decoding",
96 next_bitstream_buffer_id_); 96 next_bitstream_buffer_id_);
97 TRACE_EVENT0("jpeg", "VideoCaptureGpuJpegDecoder::DecodeCapturedData"); 97 TRACE_EVENT0("jpeg", "VideoCaptureGpuJpegDecoder::DecodeCapturedData");
98 98
99 // TODO(kcwu): enqueue decode requests in case decoding is not fast enough 99 // TODO(kcwu): enqueue decode requests in case decoding is not fast enough
100 // (say, if decoding time is longer than 16ms for 60fps 4k image) 100 // (say, if decoding time is longer than 16ms for 60fps 4k image)
101 { 101 {
102 base::AutoLock lock(lock_); 102 base::AutoLock lock(lock_);
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 DCHECK_CURRENTLY_ON(BrowserThread::UI); 236 DCHECK_CURRENTLY_ON(BrowserThread::UI);
237 237
238 task_runner->PostTask( 238 task_runner->PostTask(
239 FROM_HERE, base::Bind(&VideoCaptureGpuJpegDecoder::FinishInitialization, 239 FROM_HERE, base::Bind(&VideoCaptureGpuJpegDecoder::FinishInitialization,
240 weak_this, std::move(gpu_channel_host))); 240 weak_this, std::move(gpu_channel_host)));
241 } 241 }
242 242
243 void VideoCaptureGpuJpegDecoder::FinishInitialization( 243 void VideoCaptureGpuJpegDecoder::FinishInitialization(
244 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host) { 244 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host) {
245 TRACE_EVENT0("gpu", "VideoCaptureGpuJpegDecoder::FinishInitialization"); 245 TRACE_EVENT0("gpu", "VideoCaptureGpuJpegDecoder::FinishInitialization");
246 DCHECK(CalledOnValidThread()); 246 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
247 base::AutoLock lock(lock_); 247 base::AutoLock lock(lock_);
248 if (!gpu_channel_host) { 248 if (!gpu_channel_host) {
249 LOG(ERROR) << "Failed to establish GPU channel for JPEG decoder"; 249 LOG(ERROR) << "Failed to establish GPU channel for JPEG decoder";
250 } else if (gpu_channel_host->gpu_info().jpeg_decode_accelerator_supported) { 250 } else if (gpu_channel_host->gpu_info().jpeg_decode_accelerator_supported) {
251 gpu_channel_host_ = std::move(gpu_channel_host); 251 gpu_channel_host_ = std::move(gpu_channel_host);
252 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner = 252 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner =
253 BrowserGpuChannelHostFactory::instance()->GetIOThreadTaskRunner(); 253 BrowserGpuChannelHostFactory::instance()->GetIOThreadTaskRunner();
254 254
255 int32_t route_id = gpu_channel_host_->GenerateRouteID(); 255 int32_t route_id = gpu_channel_host_->GenerateRouteID();
256 std::unique_ptr<media::GpuJpegDecodeAcceleratorHost> decoder( 256 std::unique_ptr<media::GpuJpegDecodeAcceleratorHost> decoder(
(...skipping 15 matching lines...) Expand all
272 lock_.AssertAcquired(); 272 lock_.AssertAcquired();
273 return !decode_done_closure_.is_null(); 273 return !decode_done_closure_.is_null();
274 } 274 }
275 275
276 void VideoCaptureGpuJpegDecoder::RecordInitDecodeUMA_Locked() { 276 void VideoCaptureGpuJpegDecoder::RecordInitDecodeUMA_Locked() {
277 UMA_HISTOGRAM_BOOLEAN("Media.VideoCaptureGpuJpegDecoder.InitDecodeSuccess", 277 UMA_HISTOGRAM_BOOLEAN("Media.VideoCaptureGpuJpegDecoder.InitDecodeSuccess",
278 decoder_status_ == INIT_PASSED); 278 decoder_status_ == INIT_PASSED);
279 } 279 }
280 280
281 } // namespace content 281 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/media/video_capture_gpu_jpeg_decoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698