OLD | NEW |
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" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
15 #include "base/threading/thread_task_runner_handle.h" | 15 #include "base/threading/thread_task_runner_handle.h" |
16 #include "base/trace_event/trace_event.h" | 16 #include "base/trace_event/trace_event.h" |
17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
18 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | 18 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
19 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
20 #include "content/public/common/content_switches.h" | 20 #include "content/public/common/content_switches.h" |
21 #include "media/base/media_switches.h" | |
22 #include "media/base/video_frame.h" | 21 #include "media/base/video_frame.h" |
23 #include "media/gpu/ipc/client/gpu_jpeg_decode_accelerator_host.h" | 22 #include "media/gpu/ipc/client/gpu_jpeg_decode_accelerator_host.h" |
24 #include "mojo/public/cpp/system/platform_handle.h" | 23 #include "mojo/public/cpp/system/platform_handle.h" |
25 | 24 |
26 namespace content { | 25 namespace content { |
27 | 26 |
28 VideoCaptureGpuJpegDecoder::VideoCaptureGpuJpegDecoder( | 27 VideoCaptureGpuJpegDecoder::VideoCaptureGpuJpegDecoder( |
29 const DecodeDoneCB& decode_done_cb) | 28 const DecodeDoneCB& decode_done_cb) |
30 : decode_done_cb_(decode_done_cb), | 29 : decode_done_cb_(decode_done_cb), |
31 next_bitstream_buffer_id_(0), | 30 next_bitstream_buffer_id_(0), |
32 in_buffer_id_(media::JpegDecodeAccelerator::kInvalidBitstreamBufferId), | 31 in_buffer_id_(media::JpegDecodeAccelerator::kInvalidBitstreamBufferId), |
33 decoder_status_(INIT_PENDING) {} | 32 decoder_status_(INIT_PENDING) {} |
34 | 33 |
35 VideoCaptureGpuJpegDecoder::~VideoCaptureGpuJpegDecoder() { | 34 VideoCaptureGpuJpegDecoder::~VideoCaptureGpuJpegDecoder() { |
36 DCHECK(CalledOnValidThread()); | 35 DCHECK(CalledOnValidThread()); |
37 | 36 |
38 // |decoder_| guarantees no more JpegDecodeAccelerator::Client callbacks | 37 // |decoder_| guarantees no more JpegDecodeAccelerator::Client callbacks |
39 // on IO thread after deletion. | 38 // on IO thread after deletion. |
40 decoder_.reset(); | 39 decoder_.reset(); |
41 | 40 |
42 // |gpu_channel_host_| should outlive |decoder_|, so |gpu_channel_host_| | 41 // |gpu_channel_host_| should outlive |decoder_|, so |gpu_channel_host_| |
43 // must be released after |decoder_| has been destroyed. | 42 // must be released after |decoder_| has been destroyed. |
44 gpu_channel_host_ = nullptr; | 43 gpu_channel_host_ = nullptr; |
45 } | 44 } |
46 | 45 |
47 void VideoCaptureGpuJpegDecoder::Initialize() { | 46 void VideoCaptureGpuJpegDecoder::Initialize() { |
48 DCHECK(CalledOnValidThread()); | 47 DCHECK(CalledOnValidThread()); |
49 | 48 |
50 base::AutoLock lock(lock_); | 49 base::AutoLock lock(lock_); |
51 bool is_platform_supported = | 50 bool is_platform_supported = false; |
52 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
53 switches::kUseFakeJpegDecodeAccelerator); | |
54 #if defined(OS_CHROMEOS) | 51 #if defined(OS_CHROMEOS) |
55 // Non-ChromeOS platforms do not support HW JPEG decode now. Do not establish | 52 // Non-ChromeOS platforms do not support HW JPEG decode now. Do not establish |
56 // gpu channel to avoid introducing overhead. | 53 // gpu channel to avoid introducing overhead. |
57 is_platform_supported = true; | 54 is_platform_supported = true; |
58 #endif | 55 #endif |
59 | 56 |
60 if (!is_platform_supported || | 57 if (!is_platform_supported || |
61 base::CommandLine::ForCurrentProcess()->HasSwitch( | 58 base::CommandLine::ForCurrentProcess()->HasSwitch( |
62 switches::kDisableAcceleratedMjpegDecode)) { | 59 switches::kDisableAcceleratedMjpegDecode)) { |
63 decoder_status_ = FAILED; | 60 decoder_status_ = FAILED; |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 lock_.AssertAcquired(); | 262 lock_.AssertAcquired(); |
266 return !decode_done_closure_.is_null(); | 263 return !decode_done_closure_.is_null(); |
267 } | 264 } |
268 | 265 |
269 void VideoCaptureGpuJpegDecoder::RecordInitDecodeUMA_Locked() { | 266 void VideoCaptureGpuJpegDecoder::RecordInitDecodeUMA_Locked() { |
270 UMA_HISTOGRAM_BOOLEAN("Media.VideoCaptureGpuJpegDecoder.InitDecodeSuccess", | 267 UMA_HISTOGRAM_BOOLEAN("Media.VideoCaptureGpuJpegDecoder.InitDecodeSuccess", |
271 decoder_status_ == INIT_PASSED); | 268 decoder_status_ == INIT_PASSED); |
272 } | 269 } |
273 | 270 |
274 } // namespace content | 271 } // namespace content |
OLD | NEW |