Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Linux specific implementation of VideoCaptureDevice. | 5 // Linux specific implementation of VideoCaptureDevice. |
| 6 // V4L2 is used for capturing. V4L2 does not provide its own thread for | 6 // V4L2 is used for capturing. V4L2 does not provide its own thread for |
| 7 // capturing so this implementation uses a Chromium thread for fetching frames | 7 // capturing so this implementation uses a Chromium thread for fetching frames |
| 8 // from V4L2. | 8 // from V4L2. |
| 9 | 9 |
| 10 #ifndef MEDIA_CAPTURE_VIDEO_LINUX_VIDEO_CAPTURE_DEVICE_LINUX_H_ | 10 #ifndef MEDIA_CAPTURE_VIDEO_LINUX_VIDEO_CAPTURE_DEVICE_LINUX_H_ |
| 11 #define MEDIA_CAPTURE_VIDEO_LINUX_VIDEO_CAPTURE_DEVICE_LINUX_H_ | 11 #define MEDIA_CAPTURE_VIDEO_LINUX_VIDEO_CAPTURE_DEVICE_LINUX_H_ |
| 12 | 12 |
| 13 #include <stdint.h> | 13 #include <stdint.h> |
| 14 | 14 |
| 15 #include <string> | 15 #include <string> |
| 16 | 16 |
| 17 #include "base/files/file_util.h" | 17 #include "base/files/file_util.h" |
| 18 #include "base/files/scoped_file.h" | 18 #include "base/files/scoped_file.h" |
| 19 #include "base/lazy_instance.h" | |
|
kcwu
2016/11/28 10:11:37
unused
shenghao
2016/11/29 10:22:27
Done.
| |
| 19 #include "base/macros.h" | 20 #include "base/macros.h" |
| 20 #include "base/threading/thread.h" | 21 #include "base/threading/thread.h" |
| 22 #include "media/capture/video/linux/camera_characteristics.h" | |
| 21 #include "media/capture/video/video_capture_device.h" | 23 #include "media/capture/video/video_capture_device.h" |
| 22 #include "media/capture/video_capture_types.h" | 24 #include "media/capture/video_capture_types.h" |
| 23 | 25 |
| 24 namespace media { | 26 namespace media { |
| 25 | 27 |
| 26 class V4L2CaptureDelegate; | 28 class V4L2CaptureDelegate; |
| 27 | 29 |
| 28 // Linux V4L2 implementation of VideoCaptureDevice. | 30 // Linux V4L2 implementation of VideoCaptureDevice. |
| 29 class VideoCaptureDeviceLinux : public VideoCaptureDevice { | 31 class VideoCaptureDeviceLinux : public VideoCaptureDevice { |
| 30 public: | 32 public: |
| 31 static VideoPixelFormat V4l2FourCcToChromiumPixelFormat(uint32_t v4l2_fourcc); | 33 static VideoPixelFormat V4l2FourCcToChromiumPixelFormat(uint32_t v4l2_fourcc); |
| 32 static std::list<uint32_t> GetListOfUsableFourCCs(bool favour_mjpeg); | 34 static std::list<uint32_t> GetListOfUsableFourCCs(bool favour_mjpeg); |
| 33 | 35 |
| 34 explicit VideoCaptureDeviceLinux( | 36 explicit VideoCaptureDeviceLinux( |
| 35 const VideoCaptureDeviceDescriptor& device_descriptor); | 37 const VideoCaptureDeviceDescriptor& device_descriptor); |
| 36 ~VideoCaptureDeviceLinux() override; | 38 ~VideoCaptureDeviceLinux() override; |
| 37 | 39 |
| 38 // VideoCaptureDevice implementation. | 40 // VideoCaptureDevice implementation. |
| 39 void AllocateAndStart(const VideoCaptureParams& params, | 41 void AllocateAndStart(const VideoCaptureParams& params, |
| 40 std::unique_ptr<Client> client) override; | 42 std::unique_ptr<Client> client) override; |
| 41 void StopAndDeAllocate() override; | 43 void StopAndDeAllocate() override; |
| 42 void TakePhoto(TakePhotoCallback callback) override; | 44 void TakePhoto(TakePhotoCallback callback) override; |
| 43 void GetPhotoCapabilities(GetPhotoCapabilitiesCallback callback) override; | 45 void GetPhotoCapabilities(GetPhotoCapabilitiesCallback callback) override; |
| 44 void SetPhotoOptions(mojom::PhotoSettingsPtr settings, | 46 void SetPhotoOptions(mojom::PhotoSettingsPtr settings, |
| 45 SetPhotoOptionsCallback callback) override; | 47 SetPhotoOptionsCallback callback) override; |
| 46 | 48 |
| 47 protected: | 49 protected: |
| 48 void SetRotation(int rotation); | 50 virtual void SetRotation(int rotation); |
| 51 | |
| 52 const VideoCaptureDeviceDescriptor device_descriptor_; | |
| 49 | 53 |
| 50 private: | 54 private: |
| 51 static int TranslatePowerLineFrequencyToV4L2(PowerLineFrequency frequency); | 55 static int TranslatePowerLineFrequencyToV4L2(PowerLineFrequency frequency); |
| 52 | 56 |
| 57 base::Thread v4l2_thread_; // Thread used for reading data from the device. | |
|
kcwu
2016/11/28 10:11:37
move to line 64 (keep it on original line)
shenghao
2016/11/29 10:22:27
Done.
| |
| 58 | |
| 53 // Internal delegate doing the actual capture setting, buffer allocation and | 59 // Internal delegate doing the actual capture setting, buffer allocation and |
| 54 // circulation with the V4L2 API. Created and deleted in the thread where | 60 // circulation with the V4L2 API. Created and deleted in the thread where |
| 55 // VideoCaptureDeviceLinux lives but otherwise operating on |v4l2_thread_|. | 61 // VideoCaptureDeviceLinux lives but otherwise operating on |v4l2_thread_|. |
| 56 scoped_refptr<V4L2CaptureDelegate> capture_impl_; | 62 scoped_refptr<V4L2CaptureDelegate> capture_impl_; |
| 57 | 63 |
| 58 base::Thread v4l2_thread_; // Thread used for reading data from the device. | |
| 59 | |
| 60 const VideoCaptureDeviceDescriptor device_descriptor_; | |
| 61 | |
| 62 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceLinux); | 64 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceLinux); |
| 63 }; | 65 }; |
| 64 | 66 |
| 65 } // namespace media | 67 } // namespace media |
| 66 | 68 |
| 67 #endif // MEDIA_CAPTURE_VIDEO_LINUX_VIDEO_CAPTURE_DEVICE_LINUX_H_ | 69 #endif // MEDIA_CAPTURE_VIDEO_LINUX_VIDEO_CAPTURE_DEVICE_LINUX_H_ |
| OLD | NEW |