chromium/media/capture/video/linux/video_capture_device_factory_v4l2.cc

// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "media/capture/video/linux/video_capture_device_factory_v4l2.h"

#include <errno.h>
#include <fcntl.h>
#include <stdint.h>
#include <sys/ioctl.h>

#include <algorithm>
#include <utility>

#include "base/containers/contains.h"
#include "base/files/file_enumerator.h"
#include "base/files/file_util.h"
#include "base/posix/eintr_wrapper.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/task/single_thread_task_runner.h"
#include "build/build_config.h"
#include "media/capture/video/linux/scoped_v4l2_device_fd.h"
#include "media/capture/video/linux/video_capture_device_linux.h"

#if BUILDFLAG(IS_OPENBSD)
#include <sys/videoio.h>
#else
#include <linux/videodev2.h>
#endif

namespace media {

namespace {

bool CompareCaptureDevices(const VideoCaptureDeviceInfo& a,
                           const VideoCaptureDeviceInfo& b) {}

// USB VID and PID are both 4 bytes long.
const size_t kVidPidSize =;
const size_t kMaxInterfaceNameSize =;

// /sys/class/video4linux/video{N}/device is a symlink to the corresponding
// USB device info directory.
const char kVidPathTemplate[] =;
const char kPidPathTemplate[] =;
const char kInterfacePathTemplate[] =;

bool ReadIdFile(const std::string& path, std::string* id) {}

std::string ExtractFileNameFromDeviceId(const std::string& device_id) {}

class DevVideoFilePathsDeviceProvider
    : public VideoCaptureDeviceFactoryV4L2::DeviceProvider {};

}  // namespace

VideoCaptureDeviceFactoryV4L2::VideoCaptureDeviceFactoryV4L2(
    scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner)
    :{}

VideoCaptureDeviceFactoryV4L2::~VideoCaptureDeviceFactoryV4L2() = default;

void VideoCaptureDeviceFactoryV4L2::SetV4L2EnvironmentForTesting(
    scoped_refptr<V4L2CaptureDevice> v4l2,
    std::unique_ptr<VideoCaptureDeviceFactoryV4L2::DeviceProvider>
        device_provider) {}

VideoCaptureErrorOrDevice VideoCaptureDeviceFactoryV4L2::CreateDevice(
    const VideoCaptureDeviceDescriptor& device_descriptor) {}

void VideoCaptureDeviceFactoryV4L2::GetDevicesInfo(
    GetDevicesInfoCallback callback) {}

int VideoCaptureDeviceFactoryV4L2::DoIoctl(int fd, int request, void* argp) {}

// Check if the video capture device supports pan, tilt and zoom controls.
VideoCaptureControlSupport VideoCaptureDeviceFactoryV4L2::GetControlSupport(
    int fd) {}

bool VideoCaptureDeviceFactoryV4L2::GetControlSupport(int fd, int control_id) {}

bool VideoCaptureDeviceFactoryV4L2::HasUsableFormats(int fd,
                                                     uint32_t capabilities) {}

std::vector<float> VideoCaptureDeviceFactoryV4L2::GetFrameRateList(
    int fd,
    uint32_t fourcc,
    uint32_t width,
    uint32_t height) {}

void VideoCaptureDeviceFactoryV4L2::GetSupportedFormatsForV4L2BufferType(
    int fd,
    VideoCaptureFormats* supported_formats) {}

}  // namespace media