-
Notifications
You must be signed in to change notification settings - Fork 0
/
QRetroCamera.h
80 lines (61 loc) · 1.9 KB
/
QRetroCamera.h
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
71
72
73
74
75
76
77
78
79
80
#ifndef QRETRO_CAMERA_H
#define QRETRO_CAMERA_H
#include <QImage>
#include <libretro.h>
#if QRETRO_HAVE_CAMERA
#include <QAbstractVideoSurface>
QT_FORWARD_DECLARE_CLASS(QCamera);
QT_FORWARD_DECLARE_CLASS(QVideoFrame);
class QRetroCameraSurface : public QAbstractVideoSurface
{
Q_OBJECT
public:
/*QRetroCameraSurface(const retro_camera_callback &cb, QObject *parent = nullptr) :
QAbstractVideoSurface(parent)
{
m_RawCb = cb.frame_raw_framebuffer;
m_OpenGlCb = cb.frame_opengl_texture;
}*/
QRetroCameraSurface(QObject *parent) : QAbstractVideoSurface{parent} {}
bool present(const QVideoFrame &frame) override;
QList<QVideoFrame::PixelFormat> supportedPixelFormats(
QAbstractVideoBuffer::HandleType type) const override;
QImage *image(void) { return &m_Image; }
bool start(const QVideoSurfaceFormat& format) override { return QAbstractVideoSurface::start(format); }
void stop() override { QAbstractVideoSurface::stop(); }
private:
retro_camera_frame_raw_framebuffer_t m_RawCb = nullptr;
retro_camera_frame_opengl_texture_t m_OpenGlCb = nullptr;
QImage m_Image;
};
#endif
class QRetroCamera
{
public:
~QRetroCamera();
void init(const retro_camera_callback* cb);
bool start(void);
void stop(void);
/**
* Called every frame before retro_run to update the spoofed camera, if
* available.
*/
void update(void);
/**
* Sets an image to be used as a virtual camera feed to the libretro core.
*/
bool setImage(const QImage &image, bool quiet = false);
bool spoofing(void) { return m_Spoofing; }
private:
retro_camera_callback m_Callback = { 0, 0, 0, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr };
bool m_Initted = false;
bool m_Spoofing = false;
QImage m_SpoofImage;
#if QRETRO_HAVE_CAMERA
QRetroCameraSurface *m_Surface = nullptr;
QCamera *m_Camera = nullptr;
QVideoFrame m_Frame;
#endif
};
#endif