-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathMiSTerCast.cpp
More file actions
106 lines (88 loc) · 2.08 KB
/
MiSTerCast.cpp
File metadata and controls
106 lines (88 loc) · 2.08 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#pragma once
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files
#include <windows.h>
// C RunTime Header Files
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <stdint.h>
#include <string>
#include <functional>
#include <vector>
#include <d3d11.h>
#include <dxgi1_2.h>
#include <atomic>
#include "MiSTerCastLib.h"
#define BUFFER_COUNT 3
typedef std::string Error;
// BGRA U8 Bitmap
struct Bitmap {
int Width = 0;
int Height = 0;
std::vector<uint8_t> Buf;
};
enum Alignment : int
{
Center,
TopLeft,
Top,
TopRight,
Right,
BottomRight,
Bottom,
BottomLeft,
Left
};
enum CropMode : int
{
Custom,
X1,
X2,
X3,
X4,
X5,
Full43,
Full54,
};
struct SourceOptions {
bool syncrefresh;
int framedelay;
int display;
bool audio;
bool preview;
Alignment alignment;
CropMode cropmode;
int width;
int height;
int xoffset;
int yoffset;
int rotation;
};
// WinDesktopDup hides the gory details of capturing the screen using the
// Windows Desktop Duplication API
class WinDesktopDup {
public:
std::atomic_uint LastCaptureIndex = 0;
Bitmap Captures[BUFFER_COUNT];
int OutputNumber = 0;
WinDesktopDup(int outputNumber, log_function fnLog, capture_image_function fnCapture);
~WinDesktopDup();
Error Initialize();
void Close();
bool CaptureNext();
void SetSourceOptions(const SourceOptions* sourceOptions);
private:
void LogMessage(std::string message, bool error);
ID3D11Device* D3DDevice = nullptr;
ID3D11DeviceContext* D3DDeviceContext = nullptr;
IDXGIOutputDuplication* DeskDupl = nullptr;
DXGI_OUTPUT_DESC OutputDesc;
bool HaveFrameLock = false;
log_function logFunction;
capture_image_function captureFunction;
std::atomic_bool hasNewSourceOptions;
SourceOptions currentSourceOptions;
SourceOptions newSourceOptions;
};