Print links pipeline (for informational purposes)

This commit is contained in:
Kamil Trzcinski 2022-04-12 08:49:19 +02:00
parent d688f7127f
commit 887b88fdda
4 changed files with 48 additions and 6 deletions

View File

@ -20,6 +20,8 @@ camera_t *camera_open(camera_options_t *options)
goto error;
}
links_dump(camera->links);
return camera;
error:

View File

@ -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;
}
}

View File

@ -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;
}
}
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);
}

View File

@ -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);