Change capture to source
This commit is contained in:
parent
e52a2326c3
commit
6234e0706d
@ -44,18 +44,18 @@ int camera_configure_decoder(camera_t *camera)
|
|||||||
link_t *links = camera->links;
|
link_t *links = camera->links;
|
||||||
|
|
||||||
if (camera->options.format == V4L2_PIX_FMT_MJPEG || camera->options.format == V4L2_PIX_FMT_JPEG) {
|
if (camera->options.format == V4L2_PIX_FMT_MJPEG || camera->options.format == V4L2_PIX_FMT_JPEG) {
|
||||||
*links++ = (link_t){ camera->camera, { camera->decoder->output_list }, { http_jpeg_capture, http_jpeg_needs_buffer } };
|
*links++ = (link_t){ camera->camera->capture_list, { camera->decoder->output_list }, { http_jpeg_capture, http_jpeg_needs_buffer } };
|
||||||
*links++ = (link_t){ camera->decoder, { camera->codec_h264->output_list } };
|
*links++ = (link_t){ camera->decoder->capture_list, { camera->codec_h264->output_list } };
|
||||||
*links++ = (link_t){ camera->codec_h264, { }, { http_h264_capture, http_h264_needs_buffer } };
|
*links++ = (link_t){ camera->codec_h264->capture_list, { }, { http_h264_capture, http_h264_needs_buffer } };
|
||||||
} else if (camera->options.format != V4L2_PIX_FMT_H264) {
|
} else if (camera->options.format != V4L2_PIX_FMT_H264) {
|
||||||
*links++ = (link_t){ camera->camera, { camera->decoder->output_list }, { http_h264_capture, http_h264_needs_buffer }};
|
*links++ = (link_t){ camera->camera->capture_list, { camera->decoder->output_list }, { http_h264_capture, http_h264_needs_buffer }};
|
||||||
*links++ = (link_t){ camera->decoder, { camera->codec_jpeg->output_list } };
|
*links++ = (link_t){ camera->decoder->capture_list, { camera->codec_jpeg->output_list } };
|
||||||
*links++ = (link_t){ camera->codec_jpeg, { }, { http_jpeg_capture, http_jpeg_needs_buffer } };
|
*links++ = (link_t){ camera->codec_jpeg->capture_list, { }, { http_jpeg_capture, http_jpeg_needs_buffer } };
|
||||||
} else {
|
} else {
|
||||||
*links++ = (link_t){ camera->camera, { camera->decoder->output_list } };
|
*links++ = (link_t){ camera->camera->capture_list, { camera->decoder->output_list } };
|
||||||
*links++ = (link_t){ camera->decoder, { camera->codec_jpeg->output_list, camera->codec_h264->output_list } };
|
*links++ = (link_t){ camera->decoder->capture_list, { camera->codec_jpeg->output_list, camera->codec_h264->output_list } };
|
||||||
*links++ = (link_t){ camera->codec_jpeg, { }, { http_jpeg_capture, http_jpeg_needs_buffer } };
|
*links++ = (link_t){ camera->codec_jpeg->capture_list, { }, { http_jpeg_capture, http_jpeg_needs_buffer } };
|
||||||
*links++ = (link_t){ camera->codec_h264, { }, { http_h264_capture, http_h264_needs_buffer } };
|
*links++ = (link_t){ camera->codec_h264->capture_list, { }, { http_h264_capture, http_h264_needs_buffer } };
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -27,8 +27,8 @@ int camera_configure_direct(camera_t *camera)
|
|||||||
|
|
||||||
link_t *links = camera->links;
|
link_t *links = camera->links;
|
||||||
|
|
||||||
*links++ = (link_t){ camera->camera, { camera->codec_jpeg->output_list, camera->codec_h264->output_list } };
|
*links++ = (link_t){ camera->camera->capture_list, { camera->codec_jpeg->output_list, camera->codec_h264->output_list } };
|
||||||
*links++ = (link_t){ camera->codec_jpeg, { }, { http_jpeg_capture, http_jpeg_needs_buffer } };
|
*links++ = (link_t){ camera->codec_jpeg->capture_list, { }, { http_jpeg_capture, http_jpeg_needs_buffer } };
|
||||||
*links++ = (link_t){ camera->codec_h264, { }, { http_h264_capture, http_h264_needs_buffer } };
|
*links++ = (link_t){ camera->codec_h264->capture_list, { }, { http_h264_capture, http_h264_needs_buffer } };
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -54,16 +54,16 @@ int camera_configure_isp(camera_t *camera, float high_div, float low_div)
|
|||||||
|
|
||||||
link_t *links = camera->links;
|
link_t *links = camera->links;
|
||||||
|
|
||||||
*links++ = (link_t){ camera->camera, { camera->isp_srgb->output_list } };
|
*links++ = (link_t){ camera->camera->capture_list, { camera->isp_srgb->output_list } };
|
||||||
|
|
||||||
if (camera->isp_yuuv_low) {
|
if (camera->isp_yuuv_low) {
|
||||||
*links++ = (link_t){ camera->isp_yuuv, { } };
|
*links++ = (link_t){ camera->isp_yuuv->capture_list, { } };
|
||||||
*links++ = (link_t){ camera->isp_yuuv_low, { camera->codec_jpeg->output_list, camera->codec_h264->output_list }, { write_yuvu } };
|
*links++ = (link_t){ camera->isp_yuuv_low->capture_list, { camera->codec_jpeg->output_list, camera->codec_h264->output_list }, { write_yuvu } };
|
||||||
} else {
|
} else {
|
||||||
*links++ = (link_t){ camera->isp_yuuv, { camera->codec_jpeg->output_list, camera->codec_h264->output_list }, { write_yuvu } };
|
*links++ = (link_t){ camera->isp_yuuv->capture_list, { camera->codec_jpeg->output_list, camera->codec_h264->output_list }, { write_yuvu } };
|
||||||
}
|
}
|
||||||
|
|
||||||
*links++ = (link_t){ camera->codec_jpeg, { }, { http_jpeg_capture, http_jpeg_needs_buffer } };
|
*links++ = (link_t){ camera->codec_jpeg->capture_list, { }, { http_jpeg_capture, http_jpeg_needs_buffer } };
|
||||||
*links++ = (link_t){ camera->codec_h264, { }, { http_h264_capture, http_h264_needs_buffer } };
|
*links++ = (link_t){ camera->codec_h264->capture_list, { }, { http_h264_capture, http_h264_needs_buffer } };
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -47,9 +47,9 @@ int camera_configure_legacy_isp(camera_t *camera, float div)
|
|||||||
|
|
||||||
link_t *links = camera->links;
|
link_t *links = camera->links;
|
||||||
|
|
||||||
*links++ = (link_t){ camera->camera, { camera->legacy_isp->output_list } };
|
*links++ = (link_t){ camera->camera->capture_list, { camera->legacy_isp->output_list } };
|
||||||
*links++ = (link_t){ camera->legacy_isp, { camera->codec_jpeg->output_list, camera->codec_h264->output_list }, { write_yuvu, NULL } };
|
*links++ = (link_t){ camera->legacy_isp->capture_list, { camera->codec_jpeg->output_list, camera->codec_h264->output_list }, { write_yuvu, NULL } };
|
||||||
*links++ = (link_t){ camera->codec_jpeg, { }, { http_jpeg_capture, http_jpeg_needs_buffer } };
|
*links++ = (link_t){ camera->codec_jpeg->capture_list, { }, { http_jpeg_capture, http_jpeg_needs_buffer } };
|
||||||
*links++ = (link_t){ camera->codec_h264, { }, { http_h264_capture, http_h264_needs_buffer } };
|
*links++ = (link_t){ camera->codec_h264->capture_list, { }, { http_h264_capture, http_h264_needs_buffer } };
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
42
hw/links.c
42
hw/links.c
@ -9,12 +9,13 @@ void _update_paused(link_t *all_links)
|
|||||||
{
|
{
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
|
||||||
for (n = 0; all_links[n].capture; n++);
|
for (n = 0; all_links[n].source; n++);
|
||||||
|
|
||||||
for (int i = n; i-- > 0; ) {
|
for (int i = n; i-- > 0; ) {
|
||||||
link_t *link = &all_links[i];
|
link_t *link = &all_links[i];
|
||||||
|
buffer_list_t *source = link->source;
|
||||||
|
|
||||||
if (!link->capture->capture_list->streaming) {
|
if (!source->streaming) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,10 +41,10 @@ void _update_paused(link_t *all_links)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
link->capture->paused = paused;
|
source->device->paused = paused;
|
||||||
|
|
||||||
if (link->capture->output_device) {
|
if (source->device->output_device) {
|
||||||
link->capture->output_device->paused = paused;
|
source->device->output_device->paused = paused;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -52,16 +53,17 @@ int _build_fds(link_t *all_links, struct pollfd *fds, link_t **links, buffer_lis
|
|||||||
{
|
{
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
|
||||||
for (int i = 0; all_links[i].capture; i++) {
|
for (int i = 0; all_links[i].source; i++) {
|
||||||
link_t *link = &all_links[i];
|
link_t *link = &all_links[i];
|
||||||
|
buffer_list_t *source = link->source;
|
||||||
|
|
||||||
if (!link->capture || !link->capture->capture_list || n >= max_n) {
|
if (n >= max_n) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
if (!link->capture->capture_list->do_mmap) {
|
if (!source->do_mmap) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!link->capture->capture_list->streaming) {
|
if (!source->streaming) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,10 +91,10 @@ int _build_fds(link_t *all_links, struct pollfd *fds, link_t **links, buffer_lis
|
|||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!link->capture->paused) {
|
if (!source->device->paused) {
|
||||||
struct pollfd fd = {link->capture->fd, POLLIN};
|
struct pollfd fd = {source->device->fd, POLLIN};
|
||||||
fds[n] = fd;
|
fds[n] = fd;
|
||||||
buf_lists[n] = link->capture->capture_list;
|
buf_lists[n] = source;
|
||||||
links[n] = link;
|
links[n] = link;
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
@ -122,7 +124,7 @@ int links_step(link_t *all_links, int timeout)
|
|||||||
link_t *link = links[i];
|
link_t *link = links[i];
|
||||||
|
|
||||||
E_LOG_DEBUG(buf_list, "pool i=%d revents=%08x streaming=%d enqueued=%d/%d paused=%d", i, fds[i].revents, buf_list->streaming,
|
E_LOG_DEBUG(buf_list, "pool i=%d revents=%08x streaming=%d enqueued=%d/%d paused=%d", i, fds[i].revents, buf_list->streaming,
|
||||||
buffer_list_count_enqueued(buf_list), buf_list->nbufs, link->capture->paused);
|
buffer_list_count_enqueued(buf_list), buf_list->nbufs, link->source->device->paused);
|
||||||
|
|
||||||
if (fds[i].revents & POLLIN) {
|
if (fds[i].revents & POLLIN) {
|
||||||
E_LOG_DEBUG(buf_list, "POLLIN");
|
E_LOG_DEBUG(buf_list, "POLLIN");
|
||||||
@ -162,20 +164,12 @@ int links_step(link_t *all_links, int timeout)
|
|||||||
|
|
||||||
int links_stream(link_t *all_links, bool do_stream)
|
int links_stream(link_t *all_links, bool do_stream)
|
||||||
{
|
{
|
||||||
int n;
|
for (int i = 0; all_links[i].source; i++) {
|
||||||
|
|
||||||
for (n = 0; all_links[n].capture; n++);
|
|
||||||
|
|
||||||
for (int i = n; --i >= 0; ) {
|
|
||||||
bool streaming = true;
|
bool streaming = true;
|
||||||
link_t *link = &all_links[i];
|
link_t *link = &all_links[i];
|
||||||
|
|
||||||
if (buffer_list_stream(link->capture->capture_list, streaming) < 0) {
|
if (buffer_list_stream(link->source, streaming) < 0) {
|
||||||
E_LOG_ERROR(link->capture, "Failed to start streaming");
|
E_LOG_ERROR(link->source, "Failed to start streaming");
|
||||||
}
|
|
||||||
|
|
||||||
if (device_set_stream(link->capture, streaming) < 0) {
|
|
||||||
E_LOG_ERROR(link->capture, "Failed to start streaming");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j = 0; link->sinks[j]; j++) {
|
for (int j = 0; link->sinks[j]; j++) {
|
||||||
|
@ -9,7 +9,7 @@ typedef void (*link_on_buffer)(buffer_t *buf);
|
|||||||
typedef bool (*link_check_streaming)();
|
typedef bool (*link_check_streaming)();
|
||||||
|
|
||||||
typedef struct link_s {
|
typedef struct link_s {
|
||||||
struct device_s *capture; // capture_list
|
struct buffer_list_s *source; // capture_list
|
||||||
struct buffer_list_s *sinks[10];
|
struct buffer_list_s *sinks[10];
|
||||||
struct {
|
struct {
|
||||||
link_on_buffer on_buffer;
|
link_on_buffer on_buffer;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user