|
|
|
|
@ -8,6 +8,18 @@
|
|
|
|
|
#include "miniwebcam.h"
|
|
|
|
|
#include "configuration.h"
|
|
|
|
|
|
|
|
|
|
int get_resolution(const char *text, int *width, int *height) {
|
|
|
|
|
char *c;
|
|
|
|
|
|
|
|
|
|
if ((c = strchr ((char *)text, 'X')) == NULL)
|
|
|
|
|
if ((c = strchr ((char *)text, 'x')) == NULL) return 0;
|
|
|
|
|
|
|
|
|
|
*width = atoi (text);
|
|
|
|
|
*height = atoi (c+1);
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Configuration config;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
@ -54,11 +66,9 @@ int Configuration::PrintConfig() {
|
|
|
|
|
jp.AddObject("ssl-cert-file", ssl_cert);
|
|
|
|
|
jp.AddObject("vdev-iomode", vdev_iomode);
|
|
|
|
|
jp.AddObject("vdev-device", vdev_device);
|
|
|
|
|
jp.AddObject("vdev-height", vdev_height);
|
|
|
|
|
jp.AddObject("vdev-width", vdev_width);
|
|
|
|
|
jp.AddObject("vdev-size", to_string(vdev_width) + "x" + to_string(vdev_height));
|
|
|
|
|
jp.AddObject("vdev-format", vdev_format);
|
|
|
|
|
jp.AddObject("web-height", web_height);
|
|
|
|
|
jp.AddObject("web-width", web_width);
|
|
|
|
|
jp.AddObject("web-size" , to_string(web_width) + "x" + to_string(web_height));
|
|
|
|
|
jp.AddObject("web-refresh", web_imagerefresh);
|
|
|
|
|
jp.AddObject("vdev-dumpath", vdev_dumppath);
|
|
|
|
|
|
|
|
|
|
@ -74,6 +84,7 @@ int Configuration::PrintConfig() {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Configuration::LoadFile(std::string fn) {
|
|
|
|
|
JSONParse jp;
|
|
|
|
|
int i;
|
|
|
|
|
@ -86,7 +97,6 @@ int Configuration::LoadFile(std::string fn) {
|
|
|
|
|
|
|
|
|
|
// read from file
|
|
|
|
|
if (jp.LoadFromFile(fn) != 0) {
|
|
|
|
|
fprintf (stderr, "Could not read json file '%s'. Error: %s\n", fn.c_str(), strerror(errno));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -94,16 +104,21 @@ int Configuration::LoadFile(std::string fn) {
|
|
|
|
|
if (jp.GetValueInt("https_port", &i)) https_port = i;
|
|
|
|
|
if (jp.GetValueString("ssl-key-file", &s)) ssl_key = s;
|
|
|
|
|
if (jp.GetValueString("ssl-cert-file", &s)) ssl_cert = s;
|
|
|
|
|
if (jp.GetValueInt("web-height", &i)) web_height = i;
|
|
|
|
|
if (jp.GetValueInt("web-width", &i)) web_width = i;
|
|
|
|
|
if (jp.GetValueString("web-size", &s))
|
|
|
|
|
if (get_resolution(s.c_str(), &web_width, &web_height) == 0) {
|
|
|
|
|
debug ("Configfile: %s Wrong web-size: %s", fn.c_str(), s.c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (jp.GetValueInt("web-refresh", &i)) web_imagerefresh = i;
|
|
|
|
|
|
|
|
|
|
if (jp.GetValueString("vdev-device", &s)) vdev_device = s;
|
|
|
|
|
if (jp.GetValueString("vdev-format", &s)) vdev_format = s;
|
|
|
|
|
if (jp.GetValueString("vdev-dumppath", &s)) vdev_dumppath = s;
|
|
|
|
|
if (jp.GetValueInt("vdev-iomode", &i)) vdev_iomode = i;
|
|
|
|
|
if (jp.GetValueInt("vdev-height", &i)) vdev_height = i;
|
|
|
|
|
if (jp.GetValueInt("vdev-width", &i)) vdev_width = i;
|
|
|
|
|
if (jp.GetValueString("vdev-size", &s))
|
|
|
|
|
if (get_resolution(s.c_str(), &vdev_width, &vdev_height) == 0) {
|
|
|
|
|
debug ("Configfile: %s Wrong vdev-size: %s", fn.c_str(), s.c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// restore language
|
|
|
|
|
@ -151,21 +166,21 @@ int Configuration::LoadArgs(int argc, char **argv) {
|
|
|
|
|
ErrorExit("missing ms refresh time", -1);
|
|
|
|
|
}
|
|
|
|
|
if (strcmp(argv[i], "-websize") == 0) {
|
|
|
|
|
if ((i=i+2) < argc) {
|
|
|
|
|
web_width = atoi(argv[i-1]);
|
|
|
|
|
web_height = atoi(argv[i]);
|
|
|
|
|
if (++i < argc) {
|
|
|
|
|
if (get_resolution(argv[i], &web_width, &web_height) == 0)
|
|
|
|
|
ErrorExit("wrong web resolution parameter", -1);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
ErrorExit("missing web resolution parameter", -1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strcmp(argv[i], "-vdevsize") == 0) {
|
|
|
|
|
if ((i=i+2) < argc) {
|
|
|
|
|
vdev_width = atoi(argv[i-1]);
|
|
|
|
|
vdev_height = atoi(argv[i]);
|
|
|
|
|
if (++i < argc) {
|
|
|
|
|
if (get_resolution(argv[i], &vdev_width, &vdev_height) == 0)
|
|
|
|
|
ErrorExit("wrong video resolution parameter", -1);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
ErrorExit("missing video device resolution parameter", -1);
|
|
|
|
|
ErrorExit("missing video resolution parameter", -1);
|
|
|
|
|
}
|
|
|
|
|
if (strcmp(argv[i], "-vdeviomode") == 0) {
|
|
|
|
|
if (++i < argc) {
|
|
|
|
|
@ -232,12 +247,12 @@ void Configuration::Help() {
|
|
|
|
|
printf (" -sslkey FILE ssl key file\n");
|
|
|
|
|
printf (" -sslcert FILE ssl certfile\n");
|
|
|
|
|
printf ("\n");
|
|
|
|
|
printf (" -websize INT INT define the web output resolution\n");
|
|
|
|
|
printf (" -websize INTxINT define the web output resolution\n");
|
|
|
|
|
printf (" -webrefresh INT refresh rate for the snapshot\n");
|
|
|
|
|
printf ("\n");
|
|
|
|
|
printf (" -vdeviomode INT IOMode to read the video data, 0-read, 1-MMap\n");
|
|
|
|
|
printf (" -vdevdevice FILE Device File i.e. /dev/video2\n");
|
|
|
|
|
printf (" -vdevsize INT INT define video input resolution\n");
|
|
|
|
|
printf (" -vdevsize INTxINT define video input resolution\n");
|
|
|
|
|
printf (" -vdevformat FORMAT 4 Char Format code - see v4l2 documentation (videodev2.h)\n");
|
|
|
|
|
printf (" -vdevdumpfile FILE file to read raw image data\n");
|
|
|
|
|
printf (" -vdevdumppath PATH path to save dump data to\n");
|
|
|
|
|
|