| 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 #include "media/video/jpeg_decode_accelerator.h" |
| 13 | 14 |
| 14 namespace content { | 15 namespace content { |
| 16 class CapturedData; |
| 17 class JpegDecodeData; |
| 15 class VideoCaptureBufferPool; | 18 class VideoCaptureBufferPool; |
| 16 class VideoCaptureController; | 19 class VideoCaptureController; |
| 17 | 20 |
| 18 // Receives events from the VideoCaptureDevice and posts them to a |controller_| | 21 // 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 | 22 // 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 | 23 // VideoCaptureController. This is a shallow class meant to convert incoming |
| 21 // frames and holds no significant state. | 24 // frames and holds no significant state. |
| 22 // | 25 // |
| 23 // Methods of this class may be called from any thread, and in practice will | 26 // Methods of this class may be called from any thread if not specified, and in |
| 24 // often be called on some auxiliary thread depending on the platform and the | 27 // practice will often be called on some auxiliary thread depending on the |
| 25 // device type; including, for example, the DirectShow thread on Windows, the | 28 // platform and the device type; including, for example, the DirectShow thread |
| 26 // v4l2_thread on Linux, and the UI thread for tab capture. | 29 // on Windows, the v4l2_thread on Linux, and the UI thread for tab capture. |
| 27 class CONTENT_EXPORT VideoCaptureDeviceClient | 30 class CONTENT_EXPORT VideoCaptureDeviceClient |
| 28 : public media::VideoCaptureDevice::Client { | 31 : public media::VideoCaptureDevice::Client, |
| 32 public media::JpegDecodeAccelerator::Client { |
| 29 public: | 33 public: |
| 30 VideoCaptureDeviceClient( | 34 VideoCaptureDeviceClient( |
| 31 const base::WeakPtr<VideoCaptureController>& controller, | 35 const base::WeakPtr<VideoCaptureController>& controller, |
| 32 const scoped_refptr<VideoCaptureBufferPool>& buffer_pool); | 36 const scoped_refptr<VideoCaptureBufferPool>& buffer_pool); |
| 33 ~VideoCaptureDeviceClient() override; | 37 ~VideoCaptureDeviceClient() override; |
| 34 | 38 |
| 35 // VideoCaptureDevice::Client implementation. | 39 // VideoCaptureDevice::Client implementation. |
| 36 void OnIncomingCapturedData(const uint8* data, | 40 void OnIncomingCapturedData(const uint8* data, |
| 37 int length, | 41 int length, |
| 38 const media::VideoCaptureFormat& frame_format, | 42 const media::VideoCaptureFormat& frame_format, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 50 scoped_refptr<Buffer> ReserveOutputBuffer( | 54 scoped_refptr<Buffer> ReserveOutputBuffer( |
| 51 media::VideoPixelFormat format, | 55 media::VideoPixelFormat format, |
| 52 const gfx::Size& dimensions) override; | 56 const gfx::Size& dimensions) override; |
| 53 void OnIncomingCapturedVideoFrame( | 57 void OnIncomingCapturedVideoFrame( |
| 54 const scoped_refptr<Buffer>& buffer, | 58 const scoped_refptr<Buffer>& buffer, |
| 55 const scoped_refptr<media::VideoFrame>& frame, | 59 const scoped_refptr<media::VideoFrame>& frame, |
| 56 const base::TimeTicks& timestamp) override; | 60 const base::TimeTicks& timestamp) override; |
| 57 void OnError(const std::string& reason) override; | 61 void OnError(const std::string& reason) override; |
| 58 void OnLog(const std::string& message) override; | 62 void OnLog(const std::string& message) override; |
| 59 | 63 |
| 64 // JpegDecodeAccelerator::Client implementation. |
| 65 // These will be called in IO thread. |
| 66 virtual void VideoFrameReady(int32_t buffer_id) override; |
| 67 virtual void NotifyError(int32_t buffer_id, |
| 68 media::JpegDecodeAccelerator::Error error) override; |
| 69 |
| 60 private: | 70 private: |
| 71 bool InitializeJpegDecoder(); |
| 72 // TODO(kcwu): better name |
| 73 void OnIncomingCapturedData2(const CapturedData& captured_data); |
| 74 |
| 61 // The controller to which we post events. | 75 // The controller to which we post events. |
| 62 const base::WeakPtr<VideoCaptureController> controller_; | 76 const base::WeakPtr<VideoCaptureController> controller_; |
| 63 | 77 |
| 78 bool jpeg_failed_; |
| 79 scoped_ptr<media::JpegDecodeAccelerator> jpeg_decoder_; |
| 80 scoped_ptr<JpegDecodeData> jpeg_decode_data_; |
| 81 |
| 64 // The pool of shared-memory buffers used for capturing. | 82 // The pool of shared-memory buffers used for capturing. |
| 65 const scoped_refptr<VideoCaptureBufferPool> buffer_pool_; | 83 const scoped_refptr<VideoCaptureBufferPool> buffer_pool_; |
| 66 | 84 |
| 67 media::VideoPixelFormat last_captured_pixel_format_; | 85 media::VideoPixelFormat last_captured_pixel_format_; |
| 68 | 86 |
| 69 DISALLOW_COPY_AND_ASSIGN(VideoCaptureDeviceClient); | 87 DISALLOW_COPY_AND_ASSIGN(VideoCaptureDeviceClient); |
| 70 }; | 88 }; |
| 71 | 89 |
| 72 | 90 |
| 73 } // namespace content | 91 } // namespace content |
| 74 | 92 |
| 75 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_DEVICE_CLIENT_H_ | 93 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_DEVICE_CLIENT_H_ |
| OLD | NEW |