#include "media/capture/video/linux/fake_v4l2_impl.h"
#include <string.h>
#include <sys/mman.h>
#include <sys/time.h>
#include <unistd.h>
#include <bit>
#include <queue>
#include <vector>
#include "base/bits.h"
#include "base/containers/flat_set.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/ranges/algorithm.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/thread.h"
#include "base/time/time.h"
#include "media/base/test_data_util.h"
#include "media/base/video_frame.h"
#include "testing/gtest/include/gtest/gtest.h"
#ifndef KERNEL_VERSION
#define KERNEL_VERSION(a, b, c) …
#endif
namespace media {
constexpr char kMjpegFrameFile[] = …;
constexpr unsigned int kMjpegFrameWidth = …;
constexpr unsigned int kMjpegFrameHeight = …;
static const int kInvalidId = …;
static const int kSuccessReturnValue = …;
static const int kErrorReturnValue = …;
static const uint32_t kMaxBufferCount = …;
static const int kDefaultWidth = …;
static const int kDefaultHeight = …;
static const unsigned int kMaxWidth = …;
static const unsigned int kMaxHeight = …;
static const int kDefaultFrameInternvalNumerator = …;
static const int kDefaultFrameInternvalDenominator = …;
namespace {
int Error(int error_code) { … }
__u32 RoundUpToMultipleOfPageSize(__u32 size) { … }
struct FakeV4L2Buffer { … };
VideoPixelFormat V4L2FourccToPixelFormat(uint32_t fourcc) { … }
size_t GetV4L2FrameSize(uint32_t pixelformat,
unsigned int width,
unsigned int height) { … }
}
class FakeV4L2Impl::OpenedDevice { … };
FakeV4L2Impl::FakeV4L2Impl() : … { … }
FakeV4L2Impl::~FakeV4L2Impl() = default;
void FakeV4L2Impl::AddDevice(const std::string& device_name,
const FakeV4L2DeviceConfig& config) { … }
int FakeV4L2Impl::open(const char* device_name, int flags) { … }
int FakeV4L2Impl::close(int fd) { … }
int FakeV4L2Impl::ioctl(int fd, int request, void* argp) { … }
void* FakeV4L2Impl::mmap(void* ,
size_t length,
int prot,
int flags,
int fd,
off_t offset) { … }
int FakeV4L2Impl::munmap(void* start, size_t length) { … }
int FakeV4L2Impl::poll(struct pollfd* ufds, unsigned int nfds, int timeout) { … }
}