chromium/media/capture/video/file_video_capture_device.cc

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

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "media/capture/video/file_video_capture_device.h"

#include <stddef.h>

#include <algorithm>
#include <memory>
#include <optional>
#include <string_view>
#include <utility>

#include "base/functional/bind.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/numerics/safe_conversions.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/task/single_thread_task_runner.h"
#include "media/base/video_frame.h"
#include "media/capture/mojom/image_capture_types.h"
#include "media/capture/video/blob_utils.h"
#include "media/capture/video/gpu_memory_buffer_utils.h"
#include "media/capture/video_capture_types.h"
#include "media/parsers/jpeg_parser.h"
#include "third_party/libyuv/include/libyuv.h"

namespace media {

namespace {

int gcd(int a, int b) {}

}  // namespace

static const int kY4MHeaderMaxSize =;
static const char kY4MSimpleFrameDelimiter[] =;
static const int kY4MSimpleFrameDelimiterSize =;
static const float kMJpegFrameRate =;

int ParseY4MInt(const std::string_view token) {}

// Extract numerator and denominator out of a token that must have the aspect
// numerator:denominator, both integer numbers.
void ParseY4MRational(const std::string_view token,
                      int* numerator,
                      int* denominator) {}

// This function parses the ASCII string in |header| as belonging to a Y4M file,
// returning the collected format in |video_format|. For a non authoritative
// explanation of the header format, check
// http://wiki.multimedia.cx/index.php?title=YUV4MPEG2
// Restrictions: Only interlaced I420 pixel format is supported, and pixel
// aspect ratio is ignored.
// Implementation notes: Y4M header should end with an ASCII 0x20 (whitespace)
// character, however all examples mentioned in the Y4M header description end
// with a newline character instead. Also, some headers do _not_ specify pixel
// format, in this case it means I420.
// This code was inspired by third_party/libvpx/.../y4minput.* .
void ParseY4MTags(const std::string& file_header,
                  VideoCaptureFormat* video_format) {}

class VideoFileParser {};

class Y4mFileParser final : public VideoFileParser {};

class MjpegFileParser final : public VideoFileParser {};

VideoFileParser::VideoFileParser(const base::FilePath& file_path)
    :{}

VideoFileParser::~VideoFileParser() = default;

Y4mFileParser::Y4mFileParser(const base::FilePath& file_path)
    :{}

Y4mFileParser::~Y4mFileParser() = default;

bool Y4mFileParser::Initialize(VideoCaptureFormat* capture_format) {}

base::span<const uint8_t> Y4mFileParser::GetNextFrame() {}

MjpegFileParser::MjpegFileParser(const base::FilePath& file_path)
    :{}

MjpegFileParser::~MjpegFileParser() = default;

bool MjpegFileParser::Initialize(VideoCaptureFormat* capture_format) {}

base::span<const uint8_t> MjpegFileParser::GetNextFrame() {}

// static
bool FileVideoCaptureDevice::GetVideoCaptureFormat(
    const base::FilePath& file_path,
    VideoCaptureFormat* video_format) {}

// static
std::unique_ptr<VideoFileParser> FileVideoCaptureDevice::GetVideoFileParser(
    const base::FilePath& file_path,
    VideoCaptureFormat* video_format) {}

std::vector<uint8_t> FileVideoCaptureDevice::CropPTZRegion(
    const uint8_t* frame,
    size_t frame_buffer_size,
    VideoPixelFormat* final_pixel_format) {}

FileVideoCaptureDevice::FileVideoCaptureDevice(
    const base::FilePath& file_path,
    std::unique_ptr<gpu::GpuMemoryBufferSupport> gmb_support)
    :{}

FileVideoCaptureDevice::~FileVideoCaptureDevice() {}

void FileVideoCaptureDevice::AllocateAndStart(
    const VideoCaptureParams& params,
    std::unique_ptr<VideoCaptureDevice::Client> client) {}

void FileVideoCaptureDevice::StopAndDeAllocate() {}

void FileVideoCaptureDevice::GetPhotoState(GetPhotoStateCallback callback) {}

void FileVideoCaptureDevice::OnGetPhotoState(GetPhotoStateCallback callback) {}

void FileVideoCaptureDevice::SetPhotoOptions(mojom::PhotoSettingsPtr settings,
                                             SetPhotoOptionsCallback callback) {}

void FileVideoCaptureDevice::OnSetPhotoOptions(
    mojom::PhotoSettingsPtr settings,
    SetPhotoOptionsCallback callback) {}

void FileVideoCaptureDevice::TakePhoto(TakePhotoCallback callback) {}

void FileVideoCaptureDevice::OnAllocateAndStart(
    const VideoCaptureParams& params,
    std::unique_ptr<VideoCaptureDevice::Client> client) {}

void FileVideoCaptureDevice::OnStopAndDeAllocate() {}

void FileVideoCaptureDevice::OnCaptureTask() {}

}  // namespace media