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_DEVICE_CLIENT_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_DEVICE_CLIENT_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_DEVICE_CLIENT_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_DEVICE_CLIENT_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
12 #include "media/video/capture/video_capture_device.h" | 12 #include "media/video/capture/video_capture_device.h" |
13 | 13 |
14 namespace content { | 14 namespace content { |
15 class GpuJpegDecoder; | |
15 class VideoCaptureBufferPool; | 16 class VideoCaptureBufferPool; |
16 class VideoCaptureController; | 17 class VideoCaptureController; |
17 | 18 |
18 // Receives events from the VideoCaptureDevice and posts them to a |controller_| | 19 // Receives events from the VideoCaptureDevice and posts them to a |controller_| |
19 // on the IO thread. An instance of this class may safely outlive its target | 20 // on the IO thread. An instance of this class may safely outlive its target |
20 // VideoCaptureController. This is a shallow class meant to convert incoming | 21 // VideoCaptureController. This is a shallow class meant to convert incoming |
21 // frames and holds no significant state. | 22 // frames and holds no significant state. |
22 // | 23 // |
23 // Methods of this class may be called from any thread, and in practice will | 24 // Methods of this class may be called from any thread, and in practice will |
24 // often be called on some auxiliary thread depending on the platform and the | 25 // often be called on some auxiliary thread depending on the platform and the |
25 // device type; including, for example, the DirectShow thread on Windows, the | 26 // device type; including, for example, the DirectShow thread on Windows, the |
26 // v4l2_thread on Linux, and the UI thread for tab capture. | 27 // v4l2_thread on Linux, and the UI thread for tab capture. |
27 // | 28 // |
28 // It has an internal ref counted TextureWrapHelper class used to wrap incoming | 29 // It has an internal ref counted TextureWrapHelper class used to wrap incoming |
29 // GpuMemoryBuffers into Texture backed VideoFrames. This class creates and | 30 // GpuMemoryBuffers into Texture backed VideoFrames. This class creates and |
30 // manages the necessary entities to interact with the GPU process, notably an | 31 // manages the necessary entities to interact with the GPU process, notably an |
31 // offscreen Context to avoid janking the UI thread. | 32 // offscreen Context to avoid janking the UI thread. |
32 class CONTENT_EXPORT VideoCaptureDeviceClient | 33 class CONTENT_EXPORT VideoCaptureDeviceClient |
33 : public media::VideoCaptureDevice::Client { | 34 : public media::VideoCaptureDevice::Client, |
35 public base::SupportsWeakPtr<VideoCaptureDeviceClient> { | |
34 public: | 36 public: |
35 VideoCaptureDeviceClient( | 37 VideoCaptureDeviceClient( |
36 const base::WeakPtr<VideoCaptureController>& controller, | 38 const base::WeakPtr<VideoCaptureController>& controller, |
37 const scoped_refptr<VideoCaptureBufferPool>& buffer_pool, | 39 const scoped_refptr<VideoCaptureBufferPool>& buffer_pool, |
38 const scoped_refptr<base::SingleThreadTaskRunner>& capture_task_runner); | 40 const scoped_refptr<base::SingleThreadTaskRunner>& capture_task_runner); |
39 ~VideoCaptureDeviceClient() override; | 41 ~VideoCaptureDeviceClient() override; |
40 | 42 |
41 // VideoCaptureDevice::Client implementation. | 43 // VideoCaptureDevice::Client implementation. |
42 void OnIncomingCapturedData(const uint8* data, | 44 void OnIncomingCapturedData(const uint8* data, |
43 int length, | 45 int length, |
(...skipping 18 matching lines...) Expand all Loading... | |
62 scoped_ptr<Buffer> buffer, | 64 scoped_ptr<Buffer> buffer, |
63 const scoped_refptr<media::VideoFrame>& frame, | 65 const scoped_refptr<media::VideoFrame>& frame, |
64 const base::TimeTicks& timestamp) override; | 66 const base::TimeTicks& timestamp) override; |
65 void OnError(const std::string& reason) override; | 67 void OnError(const std::string& reason) override; |
66 void OnLog(const std::string& message) override; | 68 void OnLog(const std::string& message) override; |
67 | 69 |
68 private: | 70 private: |
69 // The controller to which we post events. | 71 // The controller to which we post events. |
70 const base::WeakPtr<VideoCaptureController> controller_; | 72 const base::WeakPtr<VideoCaptureController> controller_; |
71 | 73 |
74 // Hardware JPEG decoder. | |
75 scoped_ptr<GpuJpegDecoder> external_jpeg_decoder_; | |
76 | |
77 // Whether initialized |external_jpeg_decoder_|. | |
wuchengli
2015/05/13 15:04:06
Whether |external_jpeg_decoder_| has been initiali
kcwu
2015/05/25 18:20:35
Done.
| |
78 bool initialized_external_jpeg_decoder_; | |
wuchengli
2015/05/13 15:04:06
external_jpeg_decoder_initialized_
kcwu
2015/05/25 18:20:35
Done.
| |
79 | |
72 // The pool of shared-memory buffers used for capturing. | 80 // The pool of shared-memory buffers used for capturing. |
73 const scoped_refptr<VideoCaptureBufferPool> buffer_pool_; | 81 const scoped_refptr<VideoCaptureBufferPool> buffer_pool_; |
74 | 82 |
75 // Internal delegate for GpuMemoryBuffer-into-VideoFrame wrapping. | 83 // Internal delegate for GpuMemoryBuffer-into-VideoFrame wrapping. |
76 class TextureWrapHelper; | 84 class TextureWrapHelper; |
77 scoped_refptr<TextureWrapHelper> texture_wrap_helper_; | 85 scoped_refptr<TextureWrapHelper> texture_wrap_helper_; |
78 // Reference to Capture Thread task runner, where |texture_wrap_helper_| | 86 // Reference to Capture Thread task runner, where |texture_wrap_helper_| |
79 // lives. | 87 // lives. |
80 const scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner_; | 88 const scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner_; |
81 | 89 |
82 media::VideoPixelFormat last_captured_pixel_format_; | 90 media::VideoPixelFormat last_captured_pixel_format_; |
83 | 91 |
84 DISALLOW_COPY_AND_ASSIGN(VideoCaptureDeviceClient); | 92 DISALLOW_COPY_AND_ASSIGN(VideoCaptureDeviceClient); |
85 }; | 93 }; |
86 | 94 |
87 | 95 |
88 } // namespace content | 96 } // namespace content |
89 | 97 |
90 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_DEVICE_CLIENT_H_ | 98 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_DEVICE_CLIENT_H_ |
OLD | NEW |