aboutsummaryrefslogtreecommitdiff
path: root/src/core/frontend/camera/factory.h
blob: ca1ea2a094efec280d6dd7f125d404c3c2a7ffbd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright 2016 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.

#pragma once

#include <memory>
#include <string>
#include "core/frontend/camera/interface.h"

namespace Camera {

class CameraFactory {
public:
    virtual ~CameraFactory();

    /**
     * Creates a camera object based on the configuration string.
     * @param config Configuration string to create the camera. The implementation can decide the
     *               meaning of this string.
     * @param flip The image flip to apply
     * @returns a unique_ptr to the created camera object.
     */
    virtual std::unique_ptr<CameraInterface> Create(const std::string& config,
                                                    const Service::CAM::Flip& flip) = 0;

    /**
     * Creates a camera object for preview based on the configuration string.
     * @param config Configuration string to create the camera. The implementation can decide the
     *               meaning of this string.
     * @param flip The image flip to apply
     * @returns a unique_ptr to the created camera object.
     * Note: The default implementation for this is to call Create(). Derived classes may have other
     *       Implementations. For example, A dialog may be used instead of LOG_ERROR when error
     * occurs.
     */
    virtual std::unique_ptr<CameraInterface> CreatePreview(const std::string& config, int width,
                                                           int height,
                                                           const Service::CAM::Flip& flip) {
        return Create(config, flip);
    }
};

/**
 * Registers an external camera factory.
 * @param name Identifier of the camera factory.
 * @param factory Camera factory to register.
 */
void RegisterFactory(const std::string& name, std::unique_ptr<CameraFactory> factory);

/**
 * Creates a camera from the factory.
 * @param name Identifier of the camera factory.
 * @param config Configuration string to create the camera. The meaning of this string is
 *     defined by the factory.
 */
std::unique_ptr<CameraInterface> CreateCamera(const std::string& name, const std::string& config,
                                              const Service::CAM::Flip& flip);

/**
 * Creates a camera from the factory for previewing.
 * @param name Identifier of the camera factory.
 * @param config Configuration string to create the camera. The meaning of this string is
 *     defined by the factory.
 */
std::unique_ptr<CameraInterface> CreateCameraPreview(const std::string& name,
                                                     const std::string& config, int width,
                                                     int height, const Service::CAM::Flip& flip);

} // namespace Camera