-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathRecordSplitter.cpp
More file actions
196 lines (171 loc) · 4.48 KB
/
RecordSplitter.cpp
File metadata and controls
196 lines (171 loc) · 4.48 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/**************************
2014 adocilesloth@gmail.com
***************************/
/*************************************************
Note: Will drop ~3 secs between recording switches
**************************************************/
#include "RecordSplitter.h"
#include "timer.h"
#include <fstream>
#include <string>
using namespace std;
ifstream settings;
HINSTANCE hInstance;
HANDLE RecThread;
bool active;
long int loops;
INT_PTR CALLBACK ConfigDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int hours, mins, secs;
wstring path = OBSGetPluginDataPath().Array();
settings.open(path + L"\\RecordingSplitter.ini");
settings >> active;
settings >> hours;
settings >> mins;
settings >> secs;
settings.close();
switch (message)
{
case WM_INITDIALOG:
{
SendMessage(GetDlgItem(hWnd, IDC_ENBL), BM_SETCHECK, active ? BST_CHECKED : BST_UNCHECKED, 0);
SetDlgItemInt(hWnd, IDC_EHRS, hours, NULL);
SendMessage(GetDlgItem(hWnd, IDC_SHRS), UDM_SETRANGE32, 0, 24);
SetDlgItemInt(hWnd, IDC_EMIN, mins, NULL);
SendMessage(GetDlgItem(hWnd, IDC_SMIN), UDM_SETRANGE32, 0, 60);
SetDlgItemInt(hWnd, IDC_ESEC, secs, NULL);
SendMessage(GetDlgItem(hWnd, IDC_SSEC), UDM_SETRANGE32, 0, 60);
if(active)
{
EnableWindow(GetDlgItem(hWnd, IDC_EHRS), true);
EnableWindow(GetDlgItem(hWnd, IDC_EMIN), true);
EnableWindow(GetDlgItem(hWnd, IDC_ESEC), true);
}
else
{
EnableWindow(GetDlgItem(hWnd, IDC_EHRS), false);
EnableWindow(GetDlgItem(hWnd, IDC_EMIN), false);
EnableWindow(GetDlgItem(hWnd, IDC_ESEC), false);
}
}
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
{
active = SendMessage(GetDlgItem(hWnd, IDC_ENBL), BM_GETCHECK, 0, 0) == BST_CHECKED;
hours = GetDlgItemInt(hWnd, IDC_EHRS, NULL, NULL);
mins = GetDlgItemInt(hWnd, IDC_EMIN, NULL, NULL);
secs = GetDlgItemInt(hWnd, IDC_ESEC, NULL, NULL);
if(hours == 0 && mins == 0 && secs < 10) //min splitting time is 30 secs
{
secs = 10;
}
ofstream create(path + L"\\RecordingSplitter.ini");
create << active << endl;
create << hours << endl;
create << mins << endl;
create << secs << endl;
create.close();
loops = ((hours * 60 * 60) + (mins * 60) + secs) * 10;
EndDialog(hWnd, LOWORD(wParam));
break;
}
case IDCANCEL:
EndDialog(hWnd, LOWORD(wParam));
break;
case IDC_ENBL:
{
bool benbl = SendMessage(GetDlgItem(hWnd, IDC_ENBL), BM_GETCHECK, 0, 0) == BST_CHECKED;
if(benbl)
{
EnableWindow(GetDlgItem(hWnd, IDC_EHRS), true);
EnableWindow(GetDlgItem(hWnd, IDC_EMIN), true);
EnableWindow(GetDlgItem(hWnd, IDC_ESEC), true);
}
else
{
EnableWindow(GetDlgItem(hWnd, IDC_EHRS), false);
EnableWindow(GetDlgItem(hWnd, IDC_EMIN), false);
EnableWindow(GetDlgItem(hWnd, IDC_ESEC), false);
}
}
}
}
return 0;
}
void ConfigPlugin(HWND hWnd)
{
DialogBox(hInstance, MAKEINTRESOURCE(IDD_RECCFG), hWnd, ConfigDlgProc);
}
bool LoadPlugin()
{
wstring path = OBSGetPluginDataPath().Array();
settings.open(path + L"\\RecordingSplitter.ini");
int hours, mins, secs;
if (!settings.is_open())
{
ofstream create(path + L"\\RecordingSplitter.ini");
create << "1" << endl;
create << "0" << endl; //hours
create << "30" << endl; //mins
create << "0"; //secs
create.close(); //stop using settings file
active = true;
hours = 0;
mins = 30;
secs = 0;
}
else
{
settings >> active;
settings >> hours;
settings >> mins;
settings >> secs;
settings.close();
}
loops = ((hours * 60 * 60) + (mins * 60) + secs) * 10;
AppWarning(TEXT("Record Splitter Loaded"));
return true;
}
void UnloadPlugin()
{
}
CTSTR GetPluginName()
{
return TEXT("Recording Splitter");
}
CTSTR GetPluginDescription()
{
return TEXT("Splits Recordings into smaller files\n\n NOTE: There will be around 5 seconds of lost footage between the split recordings");
}
void OnStartRecording()
{
if(active)
{
WaitForSingleObject(RecThread, INFINITE);
long int* t = new long int(loops);
RecThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)StartTimer, t, 0, 0);
}
return;
}
void OnStopRecording()
{
if(active)
{
if(!OBSGetRecording())
{
StopTimer();
WaitForSingleObject(RecThread, INFINITE);
ResetTimer();
return;
}
}
return;
}
BOOL CALLBACK DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
if (fdwReason == DLL_PROCESS_ATTACH)
hInstance = hinstDLL;
return TRUE;
}