/ src / core / frontend / camera / interface.h
interface.h
 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_params.h"
10  
11  namespace Service::CAM {
12  struct Resolution;
13  } // namespace Service::CAM
14  
15  namespace Camera {
16  
17  /// An abstract class standing for a camera. All camera implementations should inherit from this.
18  class CameraInterface {
19  public:
20      virtual ~CameraInterface();
21  
22      /// Starts the camera for video capturing.
23      virtual void StartCapture() = 0;
24  
25      /// Stops the camera for video capturing.
26      virtual void StopCapture() = 0;
27  
28      /**
29       * Sets the video resolution from raw CAM service parameters.
30       * For the meaning of the parameters, please refer to Service::CAM::Resolution. Note that the
31       * actual camera implementation doesn't need to respect all the parameters. However, the width
32       * and the height parameters must be respected and be used to determine the size of output
33       * frames.
34       * @param resolution The resolution parameters to set
35       */
36      virtual void SetResolution(const Service::CAM::Resolution& resolution) = 0;
37  
38      /**
39       * Configures how received frames should be flipped by the camera.
40       * @param flip Flip applying to the frame
41       */
42      virtual void SetFlip(Service::CAM::Flip flip) = 0;
43  
44      /**
45       * Configures what effect should be applied to received frames by the camera.
46       * @param effect Effect applying to the frame
47       */
48      virtual void SetEffect(Service::CAM::Effect effect) = 0;
49  
50      /**
51       * Sets the output format of the all frames received after this function is called.
52       * @param format Output format of the frame
53       */
54      virtual void SetFormat(Service::CAM::OutputFormat format) = 0;
55  
56      /**
57       * Sets the recommended framerate of the camera.
58       * @param frame_rate Recommended framerate
59       */
60      virtual void SetFrameRate(Service::CAM::FrameRate frame_rate) = 0;
61  
62      /**
63       * Receives a frame from the camera.
64       * This function should be only called between a StartCapture call and a StopCapture call.
65       * @returns A std::vector<u16> containing pixels. The total size of the vector is width * height
66       *     where width and height are set by a call to SetResolution.
67       */
68      virtual std::vector<u16> ReceiveFrame() = 0;
69  
70      /**
71       * Test if the camera is opened successfully and can receive a preview frame. Only used for
72       * preview. This function should be only called between a StartCapture call and a StopCapture
73       * call.
74       * @returns true if the camera is opened successfully and false otherwise
75       */
76      virtual bool IsPreviewAvailable() = 0;
77  };
78  
79  } // namespace Camera