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 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_GPU_JPEG_DECODER_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_GPU_JPEG_DECODER_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_GPU_JPEG_DECODER_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_GPU_JPEG_DECODER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <memory> | 11 #include <memory> |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
18 #include "base/sequence_checker.h" | 18 #include "base/sequence_checker.h" |
19 #include "base/single_thread_task_runner.h" | 19 #include "base/single_thread_task_runner.h" |
20 #include "base/threading/thread.h" | 20 #include "base/threading/thread.h" |
21 #include "content/common/content_export.h" | 21 #include "content/common/content_export.h" |
22 #include "media/capture/video/video_capture_jpeg_decoder.h" | 22 #include "media/capture/video/video_capture_jpeg_decoder.h" |
23 #include "media/video/jpeg_decode_accelerator.h" | 23 #include "media/gpu/mojo/client/gpu_jpeg_decode_accelerator_host.h" |
24 | |
25 namespace gpu { | |
26 class GpuChannelHost; | |
27 } | |
28 | 24 |
29 namespace content { | 25 namespace content { |
30 | 26 |
31 // Adapter to GpuJpegDecodeAccelerator for VideoCaptureDevice::Client. It takes | 27 // Adapter to GpuJpegDecodeAccelerator for VideoCaptureDevice::Client. It takes |
32 // care of GpuJpegDecodeAccelerator creation, shared memory, and threading | 28 // care of GpuJpegDecodeAccelerator creation, shared memory, and threading |
33 // issues. | 29 // issues. |
34 // | 30 // |
35 // All public methods except JpegDecodeAccelerator::Client ones should be called | 31 // All public methods except JpegDecodeAccelerator::Client ones should be called |
36 // on the same thread. JpegDecodeAccelerator::Client methods should be called on | 32 // on the same thread. JpegDecodeAccelerator::Client methods should be called on |
37 // the IO thread. | 33 // the IO thread. |
(...skipping 21 matching lines...) Expand all Loading... |
59 base::TimeDelta timestamp, | 55 base::TimeDelta timestamp, |
60 media::VideoCaptureDevice::Client::Buffer out_buffer) override; | 56 media::VideoCaptureDevice::Client::Buffer out_buffer) override; |
61 | 57 |
62 // JpegDecodeAccelerator::Client implementation. | 58 // JpegDecodeAccelerator::Client implementation. |
63 // These will be called on IO thread. | 59 // These will be called on IO thread. |
64 void VideoFrameReady(int32_t buffer_id) override; | 60 void VideoFrameReady(int32_t buffer_id) override; |
65 void NotifyError(int32_t buffer_id, | 61 void NotifyError(int32_t buffer_id, |
66 media::JpegDecodeAccelerator::Error error) override; | 62 media::JpegDecodeAccelerator::Error error) override; |
67 | 63 |
68 private: | 64 private: |
69 // Initialization helper, to establish GPU channel. | 65 // Initialization helper, to connect to GpuJpegDecodeAccelerator in GPU |
70 static void EstablishGpuChannelOnUIThread( | 66 // process. |
| 67 static void ConnectToGpuJpegDecodeAcceleratorOnIOThread( |
71 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 68 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
72 base::WeakPtr<VideoCaptureGpuJpegDecoder> weak_this); | 69 base::WeakPtr<VideoCaptureGpuJpegDecoder> weak_this); |
73 | 70 |
74 static void GpuChannelEstablishedOnUIThread( | |
75 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | |
76 base::WeakPtr<VideoCaptureGpuJpegDecoder> weak_this, | |
77 scoped_refptr<gpu::GpuChannelHost> established_channel_host); | |
78 | |
79 void FinishInitialization( | 71 void FinishInitialization( |
80 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host); | 72 media::mojom::GpuJpegDecodeAcceleratorPtrInfo remote_decoder_info); |
81 | 73 |
82 // Returns true if the decoding of last frame is not finished yet. | 74 // Returns true if the decoding of last frame is not finished yet. |
83 bool IsDecoding_Locked() const; | 75 bool IsDecoding_Locked() const; |
84 | 76 |
85 // Records |decoder_status_| to histogram. | 77 // Records |decoder_status_| to histogram. |
86 void RecordInitDecodeUMA_Locked(); | 78 void RecordInitDecodeUMA_Locked(); |
87 | 79 |
88 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host_; | |
89 | |
90 // The underlying JPEG decode accelerator. | 80 // The underlying JPEG decode accelerator. |
91 std::unique_ptr<media::JpegDecodeAccelerator> decoder_; | 81 std::unique_ptr<media::JpegDecodeAccelerator> decoder_; |
92 | 82 |
93 // The callback to run when decode succeeds. | 83 // The callback to run when decode succeeds. |
94 const DecodeDoneCB decode_done_cb_; | 84 const DecodeDoneCB decode_done_cb_; |
95 | 85 |
96 const base::Callback<void(const std::string&)> send_log_message_cb_; | 86 const base::Callback<void(const std::string&)> send_log_message_cb_; |
97 bool has_received_decoded_frame_; | 87 bool has_received_decoded_frame_; |
98 | 88 |
99 // Guards |decode_done_closure_| and |decoder_status_|. | 89 // Guards |decode_done_closure_| and |decoder_status_|. |
(...skipping 15 matching lines...) Expand all Loading... |
115 STATUS decoder_status_; | 105 STATUS decoder_status_; |
116 | 106 |
117 SEQUENCE_CHECKER(sequence_checker_); | 107 SEQUENCE_CHECKER(sequence_checker_); |
118 | 108 |
119 DISALLOW_COPY_AND_ASSIGN(VideoCaptureGpuJpegDecoder); | 109 DISALLOW_COPY_AND_ASSIGN(VideoCaptureGpuJpegDecoder); |
120 }; | 110 }; |
121 | 111 |
122 } // namespace content | 112 } // namespace content |
123 | 113 |
124 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_GPU_JPEG_DECODER_H_ | 114 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_GPU_JPEG_DECODER_H_ |
OLD | NEW |