2016-12-21 20:05:56 +02:00
|
|
|
// Copyright 2016 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include <unordered_map>
|
|
|
|
#include "common/logging/log.h"
|
|
|
|
#include "core/frontend/camera/blank_camera.h"
|
|
|
|
#include "core/frontend/camera/factory.h"
|
|
|
|
|
|
|
|
namespace Camera {
|
|
|
|
|
|
|
|
static std::unordered_map<std::string, std::unique_ptr<CameraFactory>> factories;
|
|
|
|
|
|
|
|
CameraFactory::~CameraFactory() = default;
|
|
|
|
|
|
|
|
void RegisterFactory(const std::string& name, std::unique_ptr<CameraFactory> factory) {
|
|
|
|
factories[name] = std::move(factory);
|
|
|
|
}
|
|
|
|
|
2018-05-20 09:07:37 +08:00
|
|
|
std::unique_ptr<CameraInterface> CreateCamera(const std::string& name, const std::string& config,
|
|
|
|
const Service::CAM::Flip& flip) {
|
2016-12-21 20:05:56 +02:00
|
|
|
auto pair = factories.find(name);
|
|
|
|
if (pair != factories.end()) {
|
2018-05-20 09:07:37 +08:00
|
|
|
return pair->second->Create(config, flip);
|
2016-12-21 20:05:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (name != "blank") {
|
2018-06-29 14:18:07 +03:00
|
|
|
LOG_ERROR(Service_CAM, "Unknown camera {}", name);
|
2016-12-21 20:05:56 +02:00
|
|
|
}
|
|
|
|
return std::make_unique<BlankCamera>();
|
|
|
|
}
|
|
|
|
|
2018-05-12 01:42:23 +08:00
|
|
|
std::unique_ptr<CameraInterface> CreateCameraPreview(const std::string& name,
|
|
|
|
const std::string& config, int width,
|
2018-05-20 09:07:37 +08:00
|
|
|
int height, const Service::CAM::Flip& flip) {
|
2018-05-12 01:42:23 +08:00
|
|
|
auto pair = factories.find(name);
|
|
|
|
if (pair != factories.end()) {
|
2018-05-20 09:07:37 +08:00
|
|
|
return pair->second->CreatePreview(config, width, height, flip);
|
2018-05-12 01:42:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (name != "blank") {
|
2018-06-29 14:18:07 +03:00
|
|
|
LOG_ERROR(Service_CAM, "Unknown camera {}", name);
|
2018-05-12 01:42:23 +08:00
|
|
|
}
|
|
|
|
return std::make_unique<BlankCamera>();
|
|
|
|
}
|
|
|
|
|
2016-12-21 20:05:56 +02:00
|
|
|
} // namespace Camera
|