adding refresh time

main
Steffen Pohle 3 months ago
parent f1676893eb
commit 8056850214

@ -30,6 +30,7 @@ Configuration::Configuration() {
vdev_width = DEFAULT_VDEV_WIDTH;
web_height = DEFAULT_WEB_HEIGHT;
web_width = DEFAULT_WEB_WIDTH;
web_imagerefresh = 250;
};
Configuration::~Configuration() {
@ -58,6 +59,7 @@ int Configuration::PrintConfig() {
jp.AddObject("vdev-format", vdev_format);
jp.AddObject("web-height", web_height);
jp.AddObject("web-width", web_width);
jp.AddObject("web-refresh", web_imagerefresh);
jp.AddObject("vdev-dumpath", vdev_dumppath);
//
@ -94,6 +96,7 @@ int Configuration::LoadFile(std::string fn) {
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.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;
@ -140,6 +143,13 @@ int Configuration::LoadArgs(int argc, char **argv) {
else
ErrorExit("missing port parameter", -1);
}
if (strcmp(argv[i], "-webrefresh") == 0) {
if (++i < argc) {
web_imagerefresh = atoi(argv[i]);
}
else
ErrorExit("missing ms refresh time", -1);
}
if (strcmp(argv[i], "-websize") == 0) {
if ((i=i+2) < argc) {
web_width = atoi(argv[i-1]);
@ -223,6 +233,7 @@ void Configuration::Help() {
printf (" -sslcert FILE ssl certfile\n");
printf ("\n");
printf (" -websize INT INT 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");

@ -36,6 +36,7 @@ public:
int web_height;
int web_width;
int web_imagerefresh;
int vdev_height;
int vdev_width;

@ -50,7 +50,7 @@ std::string GenerateHtmlFile() {
res += " src = src + '?' + new Date().getTime();\n";
res += " img.src = src;\n";
res += "}\n\n";
res += "setInterval(reloadImage, 5000);\n";
res += "setInterval(reloadImage, "+to_string(config.web_imagerefresh)+");\n";
res += "\n\n";
res += "</script>\n";
res += "</body></html>";

Loading…
Cancel
Save