summaryrefslogtreecommitdiff
path: root/src/core/frontend/camera
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/frontend/camera')
-rw-r--r--src/core/frontend/camera/blank_camera.cpp31
-rw-r--r--src/core/frontend/camera/blank_camera.h28
-rw-r--r--src/core/frontend/camera/factory.cpp32
-rw-r--r--src/core/frontend/camera/factory.h41
-rw-r--r--src/core/frontend/camera/interface.cpp11
-rw-r--r--src/core/frontend/camera/interface.h61
6 files changed, 0 insertions, 204 deletions
diff --git a/src/core/frontend/camera/blank_camera.cpp b/src/core/frontend/camera/blank_camera.cpp
deleted file mode 100644
index 7995abcbd..000000000
--- a/src/core/frontend/camera/blank_camera.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
1// Copyright 2016 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include "core/frontend/camera/blank_camera.h"
6
7namespace Camera {
8
9void BlankCamera::StartCapture() {}
10
11void BlankCamera::StopCapture() {}
12
13void BlankCamera::SetFormat(Service::CAM::OutputFormat output_format) {
14 output_rgb = output_format == Service::CAM::OutputFormat::RGB565;
15}
16
17void BlankCamera::SetResolution(const Service::CAM::Resolution& resolution) {
18 width = resolution.width;
19 height = resolution.height;
20};
21
22void BlankCamera::SetFlip(Service::CAM::Flip) {}
23
24void BlankCamera::SetEffect(Service::CAM::Effect) {}
25
26std::vector<u16> BlankCamera::ReceiveFrame() const {
27 // Note: 0x80008000 stands for two black pixels in YUV422
28 return std::vector<u16>(width * height, output_rgb ? 0 : 0x8000);
29}
30
31} // namespace Camera
diff --git a/src/core/frontend/camera/blank_camera.h b/src/core/frontend/camera/blank_camera.h
deleted file mode 100644
index c6619bd88..000000000
--- a/src/core/frontend/camera/blank_camera.h
+++ /dev/null
@@ -1,28 +0,0 @@
1// Copyright 2016 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include "core/frontend/camera/factory.h"
8#include "core/frontend/camera/interface.h"
9
10namespace Camera {
11
12class BlankCamera final : public CameraInterface {
13public:
14 void StartCapture() override;
15 void StopCapture() override;
16 void SetResolution(const Service::CAM::Resolution&) override;
17 void SetFlip(Service::CAM::Flip) override;
18 void SetEffect(Service::CAM::Effect) override;
19 void SetFormat(Service::CAM::OutputFormat) override;
20 std::vector<u16> ReceiveFrame() const override;
21
22private:
23 int width = 0;
24 int height = 0;
25 bool output_rgb = false;
26};
27
28} // namespace Camera
diff --git a/src/core/frontend/camera/factory.cpp b/src/core/frontend/camera/factory.cpp
deleted file mode 100644
index 4b4da50dd..000000000
--- a/src/core/frontend/camera/factory.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
1// Copyright 2016 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include <unordered_map>
6#include "common/logging/log.h"
7#include "core/frontend/camera/blank_camera.h"
8#include "core/frontend/camera/factory.h"
9
10namespace Camera {
11
12static std::unordered_map<std::string, std::unique_ptr<CameraFactory>> factories;
13
14CameraFactory::~CameraFactory() = default;
15
16void RegisterFactory(const std::string& name, std::unique_ptr<CameraFactory> factory) {
17 factories[name] = std::move(factory);
18}
19
20std::unique_ptr<CameraInterface> CreateCamera(const std::string& name, const std::string& config) {
21 auto pair = factories.find(name);
22 if (pair != factories.end()) {
23 return pair->second->Create(config);
24 }
25
26 if (name != "blank") {
27 LOG_ERROR(Service_CAM, "Unknown camera \"%s\"", name.c_str());
28 }
29 return std::make_unique<BlankCamera>();
30}
31
32} // namespace Camera
diff --git a/src/core/frontend/camera/factory.h b/src/core/frontend/camera/factory.h
deleted file mode 100644
index f46413fa7..000000000
--- a/src/core/frontend/camera/factory.h
+++ /dev/null
@@ -1,41 +0,0 @@
1// Copyright 2016 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <memory>
8#include <string>
9#include "core/frontend/camera/interface.h"
10
11namespace Camera {
12
13class CameraFactory {
14public:
15 virtual ~CameraFactory();
16
17 /**
18 * Creates a camera object based on the configuration string.
19 * @param config Configuration string to create the camera. The implementation can decide the
20 * meaning of this string.
21 * @returns a unique_ptr to the created camera object.
22 */
23 virtual std::unique_ptr<CameraInterface> Create(const std::string& config) const = 0;
24};
25
26/**
27 * Registers an external camera factory.
28 * @param name Identifier of the camera factory.
29 * @param factory Camera factory to register.
30 */
31void RegisterFactory(const std::string& name, std::unique_ptr<CameraFactory> factory);
32
33/**
34 * Creates a camera from the factory.
35 * @param name Identifier of the camera factory.
36 * @param config Configuration string to create the camera. The meaning of this string is
37 * defined by the factory.
38 */
39std::unique_ptr<CameraInterface> CreateCamera(const std::string& name, const std::string& config);
40
41} // namespace Camera
diff --git a/src/core/frontend/camera/interface.cpp b/src/core/frontend/camera/interface.cpp
deleted file mode 100644
index 9aec9e7f1..000000000
--- a/src/core/frontend/camera/interface.cpp
+++ /dev/null
@@ -1,11 +0,0 @@
1// Copyright 2016 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include "core/frontend/camera/interface.h"
6
7namespace Camera {
8
9CameraInterface::~CameraInterface() = default;
10
11} // namespace Camera
diff --git a/src/core/frontend/camera/interface.h b/src/core/frontend/camera/interface.h
deleted file mode 100644
index a55a495c9..000000000
--- a/src/core/frontend/camera/interface.h
+++ /dev/null
@@ -1,61 +0,0 @@
1// Copyright 2016 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <vector>
8#include "common/common_types.h"
9#include "core/hle/service/cam/cam.h"
10
11namespace Camera {
12
13/// An abstract class standing for a camera. All camera implementations should inherit from this.
14class CameraInterface {
15public:
16 virtual ~CameraInterface();
17
18 /// Starts the camera for video capturing.
19 virtual void StartCapture() = 0;
20
21 /// Stops the camera for video capturing.
22 virtual void StopCapture() = 0;
23
24 /**
25 * Sets the video resolution from raw CAM service parameters.
26 * For the meaning of the parameters, please refer to Service::CAM::Resolution. Note that the
27 * actual camera implementation doesn't need to respect all the parameters. However, the width
28 * and the height parameters must be respected and be used to determine the size of output
29 * frames.
30 * @param resolution The resolution parameters to set
31 */
32 virtual void SetResolution(const Service::CAM::Resolution& resolution) = 0;
33
34 /**
35 * Configures how received frames should be flipped by the camera.
36 * @param flip Flip applying to the frame
37 */
38 virtual void SetFlip(Service::CAM::Flip flip) = 0;
39
40 /**
41 * Configures what effect should be applied to received frames by the camera.
42 * @param effect Effect applying to the frame
43 */
44 virtual void SetEffect(Service::CAM::Effect effect) = 0;
45
46 /**
47 * Sets the output format of the all frames received after this function is called.
48 * @param format Output format of the frame
49 */
50 virtual void SetFormat(Service::CAM::OutputFormat format) = 0;
51
52 /**
53 * Receives a frame from the camera.
54 * This function should be only called between a StartCapture call and a StopCapture call.
55 * @returns A std::vector<u16> containing pixels. The total size of the vector is width * height
56 * where width and height are set by a call to SetResolution.
57 */
58 virtual std::vector<u16> ReceiveFrame() const = 0;
59};
60
61} // namespace Camera