Updating XTBs based on .GRDs from branch master
[chromium-blink-merge.git] / media / capture / video / linux / video_capture_device_linux.h
blob2eb2eafac5c02d6571942c1ba963de7df371694c
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
3 // found in the LICENSE file.
5 // Linux specific implementation of VideoCaptureDevice.
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
8 // from V4L2.
10 #ifndef MEDIA_VIDEO_CAPTURE_LINUX_VIDEO_CAPTURE_DEVICE_LINUX_H_
11 #define MEDIA_VIDEO_CAPTURE_LINUX_VIDEO_CAPTURE_DEVICE_LINUX_H_
13 #include <string>
15 #include "base/files/file_util.h"
16 #include "base/files/scoped_file.h"
17 #include "base/threading/thread.h"
18 #include "media/base/video_capture_types.h"
19 #include "media/capture/video/video_capture_device.h"
21 namespace media {
23 class V4L2CaptureDelegate;
25 // Linux V4L2 implementation of VideoCaptureDevice.
26 class VideoCaptureDeviceLinux : public VideoCaptureDevice {
27 public:
28 static VideoCapturePixelFormat V4l2FourCcToChromiumPixelFormat(
29 uint32 v4l2_fourcc);
30 static std::list<uint32_t> GetListOfUsableFourCCs(bool favour_mjpeg);
32 explicit VideoCaptureDeviceLinux(const Name& device_name);
33 ~VideoCaptureDeviceLinux() override;
35 // VideoCaptureDevice implementation.
36 void AllocateAndStart(const VideoCaptureParams& params,
37 scoped_ptr<Client> client) override;
38 void StopAndDeAllocate() override;
40 protected:
41 void SetRotation(int rotation);
43 private:
44 static int TranslatePowerLineFrequencyToV4L2(int frequency);
46 // Internal delegate doing the actual capture setting, buffer allocation and
47 // circulacion with the V4L2 API. Created and deleted in the thread where
48 // VideoCaptureDeviceLinux lives but otherwise operating on |v4l2_thread_|.
49 scoped_refptr<V4L2CaptureDelegate> capture_impl_;
51 base::Thread v4l2_thread_; // Thread used for reading data from the device.
53 const Name device_name_;
55 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceLinux);
58 } // namespace media
60 #endif // MEDIA_VIDEO_CAPTURE_LINUX_VIDEO_CAPTURE_DEVICE_LINUX_H_