#include "media/capture/video/fake_video_capture_device_factory.h"
#include <array>
#include <string_view>
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_tokenizer.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
#include "gpu/ipc/common/gpu_memory_buffer_support.h"
#include "media/base/media_switches.h"
#include "media/base/video_facing.h"
#include "media/capture/capture_switches.h"
namespace {
static const float kFakeCaptureMinFrameRate = …;
static const float kFakeCaptureMaxFrameRate = …;
static const int kFakeCaptureMinDeviceCount = …;
static const int kFakeCaptureMaxDeviceCount = …;
static const int kDefaultDeviceCount = …;
constexpr char kDefaultDeviceIdMask[] = …;
static const media::FakeVideoCaptureDevice::DeliveryMode kDefaultDeliveryMode = …;
static constexpr std::array<gfx::Size, 6> kDefaultResolutions{ … };
static constexpr std::array<float, 1> kDefaultFrameRates{ … };
static const double kInitialPan = …;
static const double kInitialTilt = …;
static const double kInitialZoom = …;
static const double kInitialExposureTime = …;
static const double kInitialFocusDistance = …;
static const media::VideoPixelFormat kSupportedPixelFormats[] = …;
template <typename TElement, size_t TSize>
std::vector<TElement> ArrayToVector(const std::array<TElement, TSize>& arr) { … }
media::VideoPixelFormat GetPixelFormatFromDeviceIndex(int device_index) { … }
void AppendAllCombinationsToFormatsContainer(
const std::vector<media::VideoPixelFormat>& pixel_formats,
const std::vector<gfx::Size>& resolutions,
const std::vector<float>& frame_rates,
media::VideoCaptureFormats* output) { … }
class ErrorFakeDevice : public media::VideoCaptureDevice { … };
}
namespace media {
FakeVideoCaptureDeviceSettings::FakeVideoCaptureDeviceSettings() = default;
FakeVideoCaptureDeviceSettings::~FakeVideoCaptureDeviceSettings() = default;
FakeVideoCaptureDeviceSettings::FakeVideoCaptureDeviceSettings(
const FakeVideoCaptureDeviceSettings& other) = default;
constexpr char
FakeVideoCaptureDeviceFactory::kDeviceConfigForGetPhotoStateFails[];
constexpr char
FakeVideoCaptureDeviceFactory::kDeviceConfigForSetPhotoOptionsFails[];
constexpr char FakeVideoCaptureDeviceFactory::kDeviceConfigForTakePhotoFails[];
FakeVideoCaptureDeviceFactory::FakeVideoCaptureDeviceFactory() { … }
FakeVideoCaptureDeviceFactory::~FakeVideoCaptureDeviceFactory() = default;
std::unique_ptr<VideoCaptureDevice>
FakeVideoCaptureDeviceFactory::CreateDeviceWithSettings(
const FakeVideoCaptureDeviceSettings& settings,
std::unique_ptr<gpu::GpuMemoryBufferSupport> gmb_support) { … }
std::unique_ptr<VideoCaptureDevice>
FakeVideoCaptureDeviceFactory::CreateDeviceWithDefaultResolutions(
VideoPixelFormat pixel_format,
FakeVideoCaptureDevice::DeliveryMode delivery_mode,
float frame_rate,
std::unique_ptr<gpu::GpuMemoryBufferSupport> gmb_support) { … }
std::unique_ptr<VideoCaptureDevice>
FakeVideoCaptureDeviceFactory::CreateErrorDevice() { … }
void FakeVideoCaptureDeviceFactory::SetToDefaultDevicesConfig(
int device_count) { … }
void FakeVideoCaptureDeviceFactory::SetToCustomDevicesConfig(
const std::vector<FakeVideoCaptureDeviceSettings>& config) { … }
VideoCaptureErrorOrDevice FakeVideoCaptureDeviceFactory::CreateDevice(
const VideoCaptureDeviceDescriptor& device_descriptor) { … }
void FakeVideoCaptureDeviceFactory::GetDevicesInfo(
GetDevicesInfoCallback callback) { … }
VideoCaptureFormats FakeVideoCaptureDeviceFactory::GetSupportedFormats(
const std::string& device_id) { … }
void FakeVideoCaptureDeviceFactory::ParseFakeDevicesConfigFromOptionsString(
const std::string options_string,
std::vector<FakeVideoCaptureDeviceSettings>* config) { … }
#if BUILDFLAG(IS_WIN)
void FakeVideoCaptureDeviceFactory::OnGpuInfoUpdate(const CHROME_LUID& luid) {
luid_ = luid;
if (dxgi_device_manager_) {
dxgi_device_manager_->OnGpuInfoUpdate(luid_);
}
}
scoped_refptr<DXGIDeviceManager>
FakeVideoCaptureDeviceFactory::GetDxgiDeviceManager() {
return dxgi_device_manager_;
}
#endif
}