From 887b88fddae6051027055699323d0e077c33f8f7 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Tue, 12 Apr 2022 08:49:19 +0200 Subject: [PATCH] Print links pipeline (for informational purposes) --- device/camera/camera.c | 2 ++ device/camera/camera_output.c | 10 ++++----- device/links.c | 40 ++++++++++++++++++++++++++++++++++- device/links.h | 2 ++ 4 files changed, 48 insertions(+), 6 deletions(-) diff --git a/device/camera/camera.c b/device/camera/camera.c index c01e83c..3a4da7e 100644 --- a/device/camera/camera.c +++ b/device/camera/camera.c @@ -20,6 +20,8 @@ camera_t *camera_open(camera_options_t *options) goto error; } + links_dump(camera->links); + return camera; error: diff --git a/device/camera/camera_output.c b/device/camera/camera_output.c index 4e3d2dc..1fb4f55 100644 --- a/device/camera/camera_output.c +++ b/device/camera/camera_output.c @@ -15,8 +15,8 @@ static const char *jpeg_names[2] = { }; static link_callbacks_t jpeg_callbacks[2] = { - { http_jpeg_capture, http_jpeg_needs_buffer }, - { http_jpeg_lowres_capture, http_jpeg_needs_buffer } + { "JPEG-CAPTURE", http_jpeg_capture, http_jpeg_needs_buffer }, + { "JPEG-LOW-CAPTURE", http_jpeg_lowres_capture, http_jpeg_needs_buffer } }; static const char *h264_names[2] = { @@ -25,8 +25,8 @@ static const char *h264_names[2] = { }; static link_callbacks_t h264_callbacks[2] = { - { http_h264_capture, http_h264_needs_buffer }, - { http_h264_lowres_capture, http_h264_needs_buffer } + { "H264-CAPTURE", http_h264_capture, http_h264_needs_buffer }, + { "H264-LOW-CAPTURE", http_h264_lowres_capture, http_h264_needs_buffer } }; static int camera_configure_h264_output(camera_t *camera, buffer_list_t *src_capture, int res) @@ -100,4 +100,4 @@ int camera_configure_output_rescaler(camera_t *camera, buffer_list_t *src_captur } return 0; -} \ No newline at end of file +} diff --git a/device/links.c b/device/links.c index 5cb870a..8697125 100644 --- a/device/links.c +++ b/device/links.c @@ -3,6 +3,7 @@ #include "device/buffer.h" #include "device/buffer_list.h" #include "opts/log.h" +#include "opts/fourcc.h" #define N_FDS 50 #define QUEUE_ON_CAPTURE // seems to provide better latency @@ -272,4 +273,41 @@ int links_loop(link_t *all_links, bool *running) links_stream(all_links, false); return 0; -} \ No newline at end of file +} + +static void links_dump_buf_list(char *output, buffer_list_t *buf_list) +{ + sprintf(output + strlen(output), "%s[%dx%d/%s/%d]", \ + buf_list->name, buf_list->fmt.width, buf_list->fmt.height, \ + fourcc_to_string(buf_list->fmt.format).buf, buf_list->fmt.nbufs); +} + +void links_dump(link_t *all_links) +{ + char line[4096]; + int n; + + for (n = 0; all_links[n].source; n++) { + link_t *link = &all_links[n]; + + line[0] = 0; + links_dump_buf_list(line, link->source); + strcat(line, " => ["); + for (int j = 0; link->sinks[j]; j++) { + if (j > 0) + strcat(line, ", "); + links_dump_buf_list(line, link->sinks[j]); + } + + if (link->callbacks.callback_name) { + if (link->sinks[0]) + strcat(line, ", "); + strcat(line, link->callbacks.callback_name); + } + strcat(line, "]"); + + LOG_INFO(NULL, "Link %d: %s", n, line); + } + + LOG_INFO(NULL, "%d links.", n); +} diff --git a/device/links.h b/device/links.h index d21f624..f750544 100644 --- a/device/links.h +++ b/device/links.h @@ -14,6 +14,7 @@ typedef bool (*link_check_streaming)(); typedef bool (*link_validate_buffer)(struct link_s *link, buffer_t *buf); typedef struct link_callbacks_s { + const char *callback_name; link_on_buffer on_buffer; link_check_streaming check_streaming; link_validate_buffer validate_buffer; @@ -28,3 +29,4 @@ typedef struct link_s { int links_init(link_t *all_links); int links_step(link_t *all_links, int timeout_now_ms, int *timeout_next_ms); int links_loop(link_t *all_links, bool *running); +void links_dump(link_t *all_links);