From b7d8c5bfa6aaf95c958b763d28ba7bc96e547776 Mon Sep 17 00:00:00 2001 From: Devaev Maxim Date: Fri, 13 Sep 2019 03:22:17 +0300 Subject: [PATCH] Issue #9: Option to show last frame as blank --- src/http/server.c | 4 +++- src/http/server.h | 1 + src/options.c | 8 +++++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/http/server.c b/src/http/server.c index d3e14e5..d62b260 100644 --- a/src/http/server.c +++ b/src/http/server.c @@ -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; diff --git a/src/http/server.h b/src/http/server.h index 4ba71f1..aa85fb7 100644 --- a/src/http/server.h +++ b/src/http/server.h @@ -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; diff --git a/src/options.c b/src/options.c index f250861..271b78c 100644 --- a/src/options.c +++ b/src/options.c @@ -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 ───────────── HTTP basic auth passwd. Default: empty.\n\n"); printf(" --static ───────────── 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 to JPEG file that will be shown when the device is disconnected\n"); + printf(" -k|--blank ────────── 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 ── 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");