aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Schulze <max.schulze@posteo.de>2021-01-27 12:00:05 +0100
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2021-01-28 14:59:13 +0100
commit6106163155d873331fbcbcfcf0ac6c48cfd8e278 (patch)
treec652d29b2bcee399f3359bdfd88b9414ac7e2194
parent50b900640bab942f4f2504223680ac7d72d16e8b (diff)
v4l2-ctl: print delta to current clock in verbose mode
If the Buffer Timestamp Clock is _MONOTONIC, print the delta to the current clock time needs --stream-show-delta-now together with --verbose Signed-off-by: Max Schuze <max.schulze@posteo.de> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> [hverkuil: fix coding style issues] [hverkuil: dropped the 'delta' to 'delta last' change]
-rw-r--r--utils/v4l2-ctl/v4l2-ctl-streaming.cpp13
-rw-r--r--utils/v4l2-ctl/v4l2-ctl.cpp1
-rw-r--r--utils/v4l2-ctl/v4l2-ctl.h1
3 files changed, 15 insertions, 0 deletions
diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
index 50c7fd03..b8dc30fb 100644
--- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
@@ -268,6 +268,10 @@ void streaming_usage()
#endif
" --stream-poll use non-blocking mode and select() to stream.\n"
" --stream-buf-caps show capture buffer capabilities\n"
+ "  --stream-show-delta-now\n"
+ "                     output the difference between the buffer timestamp and current\n"
+ "                     clock, if the buffer timestamp source is the monotonic clock.\n"
+ "                     Requires --verbose as well.\n"
" --stream-mmap <count>\n"
" capture video using mmap() [VIDIOC_(D)QBUF]\n"
" count: the number of buffers to allocate. The default is 3.\n"
@@ -557,6 +561,15 @@ static void print_concise_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt,
fprintf(f, " ts: %.06f", ts);
if (last_ts != 0.0)
fprintf(f, " delta: %.03f ms", (ts - last_ts) * 1000.0);
+ if (options[OptStreamShowDeltaNow] &&
+ (buf.g_flags() & V4L2_BUF_FLAG_TIMESTAMP_MASK) ==
+ V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC) {
+ timespec ts_clock;
+
+ clock_gettime(CLOCK_MONOTONIC, &ts_clock);
+ fprintf(f, " delta now: %+.03f ms",
+ ((ts_clock.tv_sec + ts_clock.tv_nsec / 1000000000.0) - ts) * 1000.0);
+ }
last_ts = ts;
if (fps_ts.has_fps(true))
diff --git a/utils/v4l2-ctl/v4l2-ctl.cpp b/utils/v4l2-ctl/v4l2-ctl.cpp
index 6da4698a..9b70be56 100644
--- a/utils/v4l2-ctl/v4l2-ctl.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl.cpp
@@ -242,6 +242,7 @@ static struct option long_options[] = {
{"stream-to-host", required_argument, nullptr, OptStreamToHost},
#endif
{"stream-buf-caps", no_argument, nullptr, OptStreamBufCaps},
+ {"stream-show-delta-now", no_argument, nullptr, OptStreamShowDeltaNow},
{"stream-mmap", optional_argument, nullptr, OptStreamMmap},
{"stream-user", optional_argument, nullptr, OptStreamUser},
{"stream-dmabuf", no_argument, nullptr, OptStreamDmaBuf},
diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h
index a4f193cc..74cf7c83 100644
--- a/utils/v4l2-ctl/v4l2-ctl.h
+++ b/utils/v4l2-ctl/v4l2-ctl.h
@@ -221,6 +221,7 @@ enum Option {
OptStreamToHdr,
OptStreamToHost,
OptStreamLossless,
+ OptStreamShowDeltaNow,
OptStreamBufCaps,
OptStreamMmap,
OptStreamUser,

Privacy Policy