Issue #9: Option to show last frame as blank

This commit is contained in:
Devaev Maxim
2019-09-13 03:22:17 +03:00
parent 433e884fad
commit b7d8c5bfa6
3 changed files with 11 additions and 2 deletions

View File

@@ -893,7 +893,9 @@ static bool _expose_blank_picture(struct http_server_t *server) {
EXPOSED(expose_cmp_time) = EXPOSED(expose_begin_time);
if (EXPOSED(online) || EXPOSED(picture->used) == 0) {
picture_copy(server->run->blank, EXPOSED(picture));
if (!(server->last_as_blank && EXPOSED(picture->used) > 0)) {
picture_copy(server->run->blank, EXPOSED(picture));
}
EXPOSED(captured_fps) = 0;
EXPOSED(online) = false;
goto updated;

View File

@@ -96,6 +96,7 @@ struct http_server_t {
char *static_path;
char *blank_path;
bool last_as_blank;
unsigned drop_same_frames;
bool slowdown;
unsigned fake_width;

View File

@@ -67,6 +67,7 @@ enum _OPT_VALUES {
_O_UNIX_RM = 'D',
_O_UNIX_MODE = 'M',
_O_BLANK = 'k',
_O_LAST_AS_BLANK = 'K',
_O_DROP_SAME_FRAMES = 'e',
_O_SLOWDOWN = 'l',
_O_FAKE_RESOLUTION = 'R',
@@ -156,6 +157,7 @@ static const struct option _LONG_OPTS[] = {
{"passwd", required_argument, NULL, _O_PASSWD},
{"static", required_argument, NULL, _O_STATIC},
{"blank", required_argument, NULL, _O_BLANK},
{"last-as-blank", no_argument, NULL, _O_LAST_AS_BLANK},
{"drop-same-frames", required_argument, NULL, _O_DROP_SAME_FRAMES},
{"slowdown", no_argument, NULL, _O_SLOWDOWN},
{"fake-resolution", required_argument, NULL, _O_FAKE_RESOLUTION},
@@ -317,6 +319,7 @@ int parse_options(int argc, char *argv[], struct device_t *dev, struct encoder_t
case _O_PASSWD: OPT_SET(server->passwd, optarg);
case _O_STATIC: OPT_SET(server->static_path, optarg);
case _O_BLANK: OPT_SET(server->blank_path, optarg);
case _O_LAST_AS_BLANK: OPT_SET(server->last_as_blank, true);
case _O_DROP_SAME_FRAMES: OPT_NUMBER("--drop-same-frames", server->drop_same_frames, 0, VIDEO_MAX_FPS, 0);
case _O_SLOWDOWN: OPT_SET(server->slowdown, true);
case _O_FAKE_RESOLUTION: OPT_RESOLUTION("--fake-resolution", server->fake_width, server->fake_height, false);
@@ -512,8 +515,11 @@ static void _help(struct device_t *dev, struct encoder_t *encoder, struct http_s
printf(" --passwd <str> ───────────── HTTP basic auth passwd. Default: empty.\n\n");
printf(" --static <path> ───────────── Path to dir with static files instead of embedded root index page.\n");
printf(" Symlinks are not supported for security reasons. Default: disabled.\n\n");
printf(" -k|--blank <path> ────────── Path to JPEG file that will be shown when the device is disconnected\n");
printf(" -k|--blank <path> ────────── Path to JPEG file that will be shown when the device is disconnected\n");
printf(" during the streaming. Default: black screen 640x480 with 'NO SIGNAL'.\n\n");
printf(" -K|--last-as-blank ───────── Show the last frame received from the camera after it was disconnected.\n");
printf(" If the device has not yet been online, display 'NO SIGNAL' or the image\n");
printf(" specified by option --blank. Default: disabled.\n\n");
printf(" -e|--drop-same-frames <N> ── Don't send identical frames to clients, but no more than specified number.\n");
printf(" It can significantly reduce the outgoing traffic, but will increase\n");
printf(" the CPU loading. Don't use this option with analog signal sources\n");