| 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 MEDIA_CAPTURE_VIDEO_LINUX_V4L2_CAPTURE_DELEGATE_H_ | 5 #ifndef DEVICE_CAPTURE_VIDEO_LINUX_V4L2_CAPTURE_DELEGATE_H_ |
| 6 #define MEDIA_CAPTURE_VIDEO_LINUX_V4L2_CAPTURE_DELEGATE_H_ | 6 #define DEVICE_CAPTURE_VIDEO_LINUX_V4L2_CAPTURE_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include "base/files/scoped_file.h" | 11 #include "base/files/scoped_file.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "media/capture/video/video_capture_device.h" | 15 #include "device/capture/video/video_capture_device.h" |
| 16 | 16 |
| 17 #if defined(OS_OPENBSD) | 17 #if defined(OS_OPENBSD) |
| 18 #include <sys/videoio.h> | 18 #include <sys/videoio.h> |
| 19 #else | 19 #else |
| 20 #include <linux/videodev2.h> | 20 #include <linux/videodev2.h> |
| 21 #endif | 21 #endif |
| 22 | 22 |
| 23 namespace tracked_objects { | 23 namespace tracked_objects { |
| 24 class Location; | 24 class Location; |
| 25 } // namespace tracked_objects | 25 } // namespace tracked_objects |
| 26 | 26 |
| 27 namespace media { | 27 namespace device { |
| 28 | 28 |
| 29 // Class doing the actual Linux capture using V4L2 API. V4L2 SPLANE/MPLANE | 29 // Class doing the actual Linux capture using V4L2 API. V4L2 SPLANE/MPLANE |
| 30 // capture specifics are implemented in derived classes. Created and destroyed | 30 // capture specifics are implemented in derived classes. Created and destroyed |
| 31 // on the owner's thread, otherwise living and operating on |v4l2_task_runner_|. | 31 // on the owner's thread, otherwise living and operating on |v4l2_task_runner_|. |
| 32 // TODO(mcasas): Make this class a non-ref-counted. | 32 // TODO(mcasas): Make this class a non-ref-counted. |
| 33 class V4L2CaptureDelegate final | 33 class V4L2CaptureDelegate final |
| 34 : public base::RefCountedThreadSafe<V4L2CaptureDelegate> { | 34 : public base::RefCountedThreadSafe<V4L2CaptureDelegate> { |
| 35 public: | 35 public: |
| 36 // Retrieves the #planes for a given |fourcc|, or 0 if unknown. | 36 // Retrieves the #planes for a given |fourcc|, or 0 if unknown. |
| 37 static size_t GetNumPlanesForFourCc(uint32_t fourcc); | 37 static size_t GetNumPlanesForFourCc(uint32_t fourcc); |
| 38 // Returns the Chrome pixel format for |v4l2_fourcc| or PIXEL_FORMAT_UNKNOWN. | 38 // Returns the Chrome pixel format for |v4l2_fourcc| or |
| 39 // media::PIXEL_FORMAT_UNKNOWN. |
| 39 static VideoPixelFormat V4l2FourCcToChromiumPixelFormat( | 40 static VideoPixelFormat V4l2FourCcToChromiumPixelFormat( |
| 40 uint32_t v4l2_fourcc); | 41 uint32_t v4l2_fourcc); |
| 41 | 42 |
| 42 // Composes a list of usable and supported pixel formats, in order of | 43 // Composes a list of usable and supported pixel formats, in order of |
| 43 // preference, with MJPEG prioritised depending on |prefer_mjpeg|. | 44 // preference, with MJPEG prioritised depending on |prefer_mjpeg|. |
| 44 static std::list<uint32_t> GetListOfUsableFourCcs(bool prefer_mjpeg); | 45 static std::list<uint32_t> GetListOfUsableFourCcs(bool prefer_mjpeg); |
| 45 | 46 |
| 46 V4L2CaptureDelegate( | 47 V4L2CaptureDelegate( |
| 47 const VideoCaptureDeviceDescriptor& device_descriptor, | 48 const VideoCaptureDeviceDescriptor& device_descriptor, |
| 48 const scoped_refptr<base::SingleThreadTaskRunner>& v4l2_task_runner, | 49 const scoped_refptr<base::SingleThreadTaskRunner>& v4l2_task_runner, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 87 |
| 87 bool is_capturing_; | 88 bool is_capturing_; |
| 88 int timeout_count_; | 89 int timeout_count_; |
| 89 | 90 |
| 90 // Clockwise rotation in degrees. This value should be 0, 90, 180, or 270. | 91 // Clockwise rotation in degrees. This value should be 0, 90, 180, or 270. |
| 91 int rotation_; | 92 int rotation_; |
| 92 | 93 |
| 93 DISALLOW_COPY_AND_ASSIGN(V4L2CaptureDelegate); | 94 DISALLOW_COPY_AND_ASSIGN(V4L2CaptureDelegate); |
| 94 }; | 95 }; |
| 95 | 96 |
| 96 } // namespace media | 97 } // namespace device |
| 97 | 98 |
| 98 #endif // MEDIA_CAPTURE_VIDEO_LINUX_V4L2_CAPTURE_DELEGATE_H_ | 99 #endif // DEVICE_CAPTURE_VIDEO_LINUX_V4L2_CAPTURE_DELEGATE_H_ |
| OLD | NEW |