forked from micsthepick/cfg-cam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
89 lines (77 loc) · 2.71 KB
/
main.cpp
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
//#include <dshow.h>
#include <string>
#include "loginfo.h"
#include "camset.h"
int verbLevel = VERB_NORMAL; //display messages
//int verbLevel = VERB_FULL; //display debug messages
bool ignoreFriendlyName = false;
void helpme() {
logMe(LOG_INFO, "");
logMe(LOG_INFO, "CamCfg.Date.2017.version.1.0");
logMe(LOG_INFO, "To save and apply DirectShow webcam settings");
logMe(LOG_INFO, "");
logMe(LOG_INFO, "Usage: WebCameraConfig.exe [options]");
logMe(LOG_INFO, "");
logMe(LOG_INFO, "Options:");
logMe(LOG_INFO, "--readdev : Read and print all devices short info.");
logMe(LOG_INFO, "--savedev : Save devices current settings into .cfg file.");
logMe(LOG_INFO, "--profile [string] : Uses string as filename to save/load settings.");
logMe(LOG_INFO, "--ignorefn : Ignore FriendlyName when looking for devices.");
logMe(LOG_INFO, "--help : Display this help info.");
logMe(LOG_INFO, "");
logMe(LOG_INFO, "Without [options], it reads existing cam_sett.cfg file and applies settings");
logMe(LOG_INFO, "to all available devices.");
logMe(LOG_INFO, "It doesn't build new graph, only uses existing one.");
}
int main(int argc, char *argv[])
{
//test
//argc = 2;
//argv[0] = (char *)"WebCameraConfig.exe";
//argv[1] = (char *)"--readdev";
//argv[1] = (char *)"--savedev";
//argv[1] = (char *)"--ignorefn";
string ProfStr;
bool readVideoDevices = false, saveVideoDevices = false;
int i = 1;
for(; i < argc; i++) {
string arg(argv[i]);
if (arg == "--readdev") {
readVideoDevices = true;
} else if (arg == "--savedev") {
saveVideoDevices = true;
} else if (arg == "--profile") {
if (++i < argc) ProfStr = argv[i];
} else if (arg == "--ignorefn") {
ignoreFriendlyName = true;
} else if (arg == "--help") {
helpme();
return 0;
} else
break; //for
} //for
//by default no keys required
if (argc != i) {
helpme();
return -1;
}
if (ProfStr.empty())
ProfStr = "cam_sett"; //default file name
CamSetAll camupd;
try {
if (readVideoDevices) {
camupd.displayFoundDevices();
return 0; //all OK
}
if (saveVideoDevices) {
camupd.saveSett(ProfStr + ".cfg");
return 0; //all OK
}
//default behavior is to load/apply settings from the .cfg file
camupd.loadSett(ProfStr + ".cfg");
} catch(string e) {
logMe(LOG_ERR, e);
return -1;
}
return 0;
}