-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathWebCam.h
277 lines (247 loc) · 7.68 KB
/
WebCam.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
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
/*
Copyright (c) 2001-2004 Chris Lundie
http://lundie.ca/
This file is part of Fwink.
Fwink is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Fwink is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fwink; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef WEBCAM_H
#define WEBCAM_H
#pragma warning(disable : 4995)
class WebCam;
#include <windows.h>
#include <streams.h>
#include <objbase.h>
#include <prsht.h>
#include <shellapi.h>
#include <gdiplus.h>
#include <wininet.h>
#include <commctrl.h>
#include <ras.h>
#include <raserror.h>
#include <dshow.h>
#include <qedit.h>
#include <exception>
#include <string>
#include <dvdmedia.h>
#include <commdlg.h>
#include <vector>
#include <assert.h>
#include "resource.h"
#include "dllversion.h"
#include "crossbar.h"
#include "VideoDevice.h"
using std::wstring;
using std::vector;
using namespace Gdiplus;
class WebCam
{
public:
void CropPreview();
static const int _expireTime;
enum
timeunit_t
{
timeunit_seconds = 0,
timeunit_minutes = 1,
timeunit_hours = 2
};
enum
smooth_t
{
smooth_none = 0,
smooth_standard = 1,
smooth_cleartype = 2
};
enum
ovlscale_t
{
ovlscale_original = 0,
ovlscale_bestfit = 1,
ovlscale_percentage = 2
};
enum
textposition_t
{
textposition_upperleft = 0,
textposition_top = 1,
textposition_upperright = 2,
textposition_left = 3,
textposition_centre = 4,
textposition_right = 5,
textposition_lowerleft = 6,
textposition_bottom = 7,
textposition_lowerright = 8
};
enum textbackground_t
{
textbackground_solid = 0,
textbackground_translucent = 1,
textbackground_none = 2
};
enum deviceType_t
{
deviceType_camera = 0,
deviceType_file = 1
};
static const unsigned uMinDeviceType, uMaxDeviceType;
WebCam();
~WebCam();
void Start(void);
void StartOneShot(void);
void InitImageFile(void);
void HandleCaptureMessage(WebCam* cam, HWND hwndDlg);
static INT_PTR CALLBACK DialogProcMain(HWND, UINT, WPARAM, LPARAM);
static INT_PTR CALLBACK DialogProcVideo(HWND, UINT, WPARAM, LPARAM);
static INT_PTR CALLBACK DialogProcFTP(HWND, UINT, WPARAM, LPARAM);
static INT_PTR CALLBACK DialogProcEffects(HWND, UINT, WPARAM, LPARAM);
static INT_PTR CALLBACK DialogProcOverlay(HWND, UINT, WPARAM, LPARAM);
static INT_PTR CALLBACK DialogProcChooseVideoDevice(HWND, UINT, WPARAM, LPARAM);
void EnumerateVideoDevicesForComboBox(HWND hwndComboBox);
void ShowChooseVideoDeviceDialog(HWND hwndParent);
void ShowMainDialog(void);
void CreateNotificationIcon(void);
void CreateMainDialog(void);
void ChangeVideoFormat(const HWND, const bool);
void ChangeVidcapProperties(const HWND, const bool);
void CaptureFrame(void);
static int GetEncoderClsid(const WCHAR* format, CLSID* pClsid);
void SetStatus(int);
static void CALLBACK InternetStatusCallback(HINTERNET, DWORD_PTR, DWORD, LPVOID, DWORD);
void SaveSettings(void);
void SaveEffectsSettings(void);
void SaveVideoSettings(void);
void SaveFTPSettings(void);
void SaveOverlaySettings(void);
void StartTimer(void);
void StopTimer(void);
bool ConnectedToInternet(void);
HRESULT GetPinCategory(IPin* pPin, GUID* pPinCategory);
IPin* GetPin(IBaseFilter *pFilter, PIN_DIRECTION PinDir, const GUID& pPinCategory);
IPin* GetPin(IBaseFilter *pFilter, PIN_DIRECTION PinDir, unsigned iIndex);
void UploadImage(void);
void InitDirectShow(void);
void ShutdownDirectShow(void);
void AddText(Image*);
void DeleteTempFile(void);
void ApplyImageSize(void);
void ShowSettingsDialog(void);
void NukeDownstream(IBaseFilter*);
void UnNuke(void);
void StartCapture(void);
void StopCapture(void);
void GetCaptureSize(void);
void SetCaptureSize(void);
void TVTunerProperties(const HWND, const bool);
void InitFTPControls(HWND hwndDlg, BOOL bEnable);
void InitTimerControls(HWND hwndDlg, BOOL bEnable);
void InitFileControls(HWND hwndDlg, BOOL bEnable);
void AddOverlay(
Image* imBase, Image* imOverlay = NULL,
bool bLowQuality = false,
unsigned uOpacity = 100,
unsigned uScale = ovlscale_original,
float fScaleX = 100.0f, float fScaleY = 100.0f,
bool bColourKey = false,
unsigned uKeyR = 255, unsigned uKeyG = 255, unsigned uKeyB = 255,
unsigned pos = textposition_lowerleft
);
static bool LoadSetting(const WCHAR* name, wstring& value);
static bool LoadSetting(const WCHAR* name, unsigned* pValue);
static bool LoadSetting(const WCHAR* name, int* pValue);
static bool LoadSetting(const WCHAR* name, bool* pValue);
static bool SaveSetting(const WCHAR* name, const TCHAR* value);
static bool SaveSetting(const WCHAR* name, const unsigned value);
static bool SaveSetting(const WCHAR* name, const int value);
static bool SaveSetting(const WCHAR* name, const bool value);
HWND hwndMain;
HICON hIconIdle;
static const UINT uNotifyIconMessage;
static const UINT uNotifyIconID;
static const UINT uTaskbarRestart;
ULONG_PTR uGDIPlusToken;
unsigned uImageWidth, uImageHeight;
HINTERNET hInternet;
HINTERNET hFTP;
int iStatus;
WCHAR szwFilenameJPEG[MAX_PATH];
bool bTempFile;
bool bReadyToUpload;
static const wstring sRegKey;
wstring sServer,sUsername,sPassword,sDirectory,sFilename,sWisdom;
unsigned uTimeValue, uTimeUnit;
bool bDialup;
bool bTimestamp, bDatestamp;
bool bPassiveFTP;
static const unsigned uMaxTimeValue, uMinTimeValue;
static const unsigned uMinTimeUnit, uMaxTimeUnit;
const UINT_PTR uTimerID, uCancelFtpTimerID;
UINT uCancelFtpTimerMilliseconds;
bool bBalloonTips;
bool bRunAtStartup;
static const UINT uCaptureMessage;
static const UINT uRemoteCaptureMessage;
static void FreeMediaType(AM_MEDIA_TYPE&);
bool bOKToDeleteTempFile;
unsigned uImageSize;
static const unsigned uMaxImageSize, uMinImageSize;
bool bCustomImageSize;
unsigned uCustomSizeX, uCustomSizeY;
TCHAR szAppname[512];
static const unsigned uMaxFontSize, uMinFontSize;
unsigned uFontSize;
wstring sFontname;
unsigned uSmoothType;
static const unsigned uMinSmooth, uMaxSmooth;
bool bClearTypeAvailable;
bool bFontBold, bFontItalic, bFontUnderline, bFontStrikeout;
bool bFlipHorizontal, bFlipVertical;
unsigned uCrossbarInput;
int iCaptureWidth, iCaptureHeight;
HBRUSH hbrSampleBackground;
COLORREF rgbForeground, rgbBackground;
unsigned uTextPosition;
bool bDropShadow;
unsigned uTextBackground;
unsigned uJPEGQuality;
bool bOneShot;
static const UINT uQuitMessage;
static const TCHAR szHomePageURL[];
bool bDisableFTP;
bool bDisableTimer;
bool bSaveToFile;
wstring sLocalFilename;
wstring sOverlayImageFile;
unsigned uOverlayScale;
unsigned uOverlayScalePercent;
unsigned uOverlayPosition;
unsigned uOverlayOpacity;
bool bOverlayColourKey;
COLORREF rgbColourKey;
bool bCrop;
unsigned uCropWidth, uCropHeight,
uCropX, uCropY;
wstring sDeviceName;
wstring sDevicePath;
unsigned uDeviceType;
vector<VideoDevice> videoDevices;
std::auto_ptr<Gdiplus::Image> imageFile;
std::auto_ptr<Gdiplus::Bitmap> imageFilePreview;
// DirectShow stuff
//
IGraphBuilder* pGraph;
ICaptureGraphBuilder2* pBuilder;
IBaseFilter* pVidcap;
IBaseFilter* pSampleGrabber;
IBaseFilter* pNullRenderer;
};
#endif // WEBCAM_H