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 <string> | 11 #include <string> |
12 | 12 |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
18 #include "base/single_thread_task_runner.h" | 18 #include "base/single_thread_task_runner.h" |
19 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
20 #include "content/common/content_export.h" | 20 #include "content/common/content_export.h" |
21 #include "media/capture/video/video_capture_device.h" | 21 #include "media/capture/video/video_capture_device.h" |
22 #include "media/video/jpeg_decode_accelerator.h" | 22 #include "media/video/jpeg_decode_accelerator.h" |
23 | 23 |
| 24 namespace gpu { |
| 25 class GpuChannelHost; |
| 26 } |
| 27 |
24 namespace media { | 28 namespace media { |
25 class VideoFrame; | 29 class VideoFrame; |
26 } | 30 } |
27 | 31 |
28 namespace content { | 32 namespace content { |
29 class GpuChannelHost; | |
30 | 33 |
31 // Adapter to GpuJpegDecodeAccelerator for VideoCaptureDevice::Client. It takes | 34 // Adapter to GpuJpegDecodeAccelerator for VideoCaptureDevice::Client. It takes |
32 // care of GpuJpegDecodeAccelerator creation, shared memory, and threading | 35 // care of GpuJpegDecodeAccelerator creation, shared memory, and threading |
33 // issues. | 36 // issues. |
34 // | 37 // |
35 // All public methods except JpegDecodeAccelerator::Client ones should be called | 38 // All public methods except JpegDecodeAccelerator::Client ones should be called |
36 // on the same thread. JpegDecodeAccelerator::Client methods should be called on | 39 // on the same thread. JpegDecodeAccelerator::Client methods should be called on |
37 // the IO thread. | 40 // the IO thread. |
38 class CONTENT_EXPORT VideoCaptureGpuJpegDecoder | 41 class CONTENT_EXPORT VideoCaptureGpuJpegDecoder |
39 : public media::JpegDecodeAccelerator::Client, | 42 : public media::JpegDecodeAccelerator::Client, |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 private: | 86 private: |
84 // Initialization helper, to establish GPU channel. | 87 // Initialization helper, to establish GPU channel. |
85 static void EstablishGpuChannelOnUIThread( | 88 static void EstablishGpuChannelOnUIThread( |
86 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 89 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
87 base::WeakPtr<VideoCaptureGpuJpegDecoder> weak_this); | 90 base::WeakPtr<VideoCaptureGpuJpegDecoder> weak_this); |
88 | 91 |
89 static void GpuChannelEstablishedOnUIThread( | 92 static void GpuChannelEstablishedOnUIThread( |
90 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 93 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
91 base::WeakPtr<VideoCaptureGpuJpegDecoder> weak_this); | 94 base::WeakPtr<VideoCaptureGpuJpegDecoder> weak_this); |
92 | 95 |
93 void FinishInitialization(scoped_refptr<GpuChannelHost> gpu_channel_host); | 96 void FinishInitialization( |
| 97 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host); |
94 | 98 |
95 // Returns true if the decoding of last frame is not finished yet. | 99 // Returns true if the decoding of last frame is not finished yet. |
96 bool IsDecoding_Locked() const; | 100 bool IsDecoding_Locked() const; |
97 | 101 |
98 // Records |decoder_status_| to histogram. | 102 // Records |decoder_status_| to histogram. |
99 void RecordInitDecodeUMA_Locked(); | 103 void RecordInitDecodeUMA_Locked(); |
100 | 104 |
101 scoped_refptr<GpuChannelHost> gpu_channel_host_; | 105 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host_; |
102 | 106 |
103 // The underlying JPEG decode accelerator. | 107 // The underlying JPEG decode accelerator. |
104 scoped_ptr<media::JpegDecodeAccelerator> decoder_; | 108 scoped_ptr<media::JpegDecodeAccelerator> decoder_; |
105 | 109 |
106 // The callback to run when decode succeeds. | 110 // The callback to run when decode succeeds. |
107 const DecodeDoneCB decode_done_cb_; | 111 const DecodeDoneCB decode_done_cb_; |
108 | 112 |
109 // Guards |decode_done_closure_| and |decoder_status_|. | 113 // Guards |decode_done_closure_| and |decoder_status_|. |
110 mutable base::Lock lock_; | 114 mutable base::Lock lock_; |
111 | 115 |
(...skipping 11 matching lines...) Expand all Loading... |
123 scoped_ptr<base::SharedMemory> in_shared_memory_; | 127 scoped_ptr<base::SharedMemory> in_shared_memory_; |
124 | 128 |
125 STATUS decoder_status_; | 129 STATUS decoder_status_; |
126 | 130 |
127 DISALLOW_COPY_AND_ASSIGN(VideoCaptureGpuJpegDecoder); | 131 DISALLOW_COPY_AND_ASSIGN(VideoCaptureGpuJpegDecoder); |
128 }; | 132 }; |
129 | 133 |
130 } // namespace content | 134 } // namespace content |
131 | 135 |
132 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_GPU_JPEG_DECODER_H_ | 136 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_GPU_JPEG_DECODER_H_ |
OLD | NEW |