| 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 VideoCaptureBufferPool; | 15 class VideoCaptureBufferPool; |
| 16 class VideoCaptureController; | 16 class VideoCaptureController; |
| 17 class VideoCaptureGpuJpegDecoder; |
| 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 21 matching lines...) Expand all Loading... |
| 65 const scoped_refptr<media::VideoFrame>& frame, | 67 const scoped_refptr<media::VideoFrame>& frame, |
| 66 const base::TimeTicks& timestamp) override; | 68 const base::TimeTicks& timestamp) override; |
| 67 void OnError(const std::string& reason) override; | 69 void OnError(const std::string& reason) override; |
| 68 void OnLog(const std::string& message) override; | 70 void OnLog(const std::string& message) override; |
| 69 double GetBufferPoolUtilization() const override; | 71 double GetBufferPoolUtilization() const override; |
| 70 | 72 |
| 71 private: | 73 private: |
| 72 // The controller to which we post events. | 74 // The controller to which we post events. |
| 73 const base::WeakPtr<VideoCaptureController> controller_; | 75 const base::WeakPtr<VideoCaptureController> controller_; |
| 74 | 76 |
| 77 // Hardware JPEG decoder. |
| 78 scoped_ptr<VideoCaptureGpuJpegDecoder> external_jpeg_decoder_; |
| 79 |
| 80 // Whether |external_jpeg_decoder_| has been initialized. |
| 81 bool external_jpeg_decoder_initialized_; |
| 82 |
| 75 // The pool of shared-memory buffers used for capturing. | 83 // The pool of shared-memory buffers used for capturing. |
| 76 const scoped_refptr<VideoCaptureBufferPool> buffer_pool_; | 84 const scoped_refptr<VideoCaptureBufferPool> buffer_pool_; |
| 77 | 85 |
| 78 // Internal delegate for GpuMemoryBuffer-into-VideoFrame wrapping. | 86 // Internal delegate for GpuMemoryBuffer-into-VideoFrame wrapping. |
| 79 class TextureWrapHelper; | 87 class TextureWrapHelper; |
| 80 scoped_refptr<TextureWrapHelper> texture_wrap_helper_; | 88 scoped_refptr<TextureWrapHelper> texture_wrap_helper_; |
| 81 // Reference to Capture Thread task runner, where |texture_wrap_helper_| | 89 // Reference to Capture Thread task runner, where |texture_wrap_helper_| |
| 82 // lives. | 90 // lives. |
| 83 const scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner_; | 91 const scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner_; |
| 84 | 92 |
| 85 media::VideoPixelFormat last_captured_pixel_format_; | 93 media::VideoPixelFormat last_captured_pixel_format_; |
| 86 | 94 |
| 87 DISALLOW_COPY_AND_ASSIGN(VideoCaptureDeviceClient); | 95 DISALLOW_COPY_AND_ASSIGN(VideoCaptureDeviceClient); |
| 88 }; | 96 }; |
| 89 | 97 |
| 90 | 98 |
| 91 } // namespace content | 99 } // namespace content |
| 92 | 100 |
| 93 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_DEVICE_CLIENT_H_ | 101 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_DEVICE_CLIENT_H_ |
| OLD | NEW |