Rework links handling to create a complete pipeline
This commit is contained in:
parent
a4d6f35004
commit
80b69bd3eb
@ -70,34 +70,24 @@ error:
|
||||
|
||||
int camera_set_params(camera_t *camera)
|
||||
{
|
||||
// Set some defaults
|
||||
device_set_option_string(camera->codec_jpeg, "compression_quality", "80");
|
||||
device_set_option_string(camera->codec_jpeg_lowres, "compression_quality", "80");
|
||||
|
||||
device_set_option_string(camera->codec_h264, "video_bitrate_mode", "0");
|
||||
device_set_option_string(camera->codec_h264, "video_bitrate", "5000000");
|
||||
device_set_option_string(camera->codec_h264, "repeat_sequence_header", "1");
|
||||
device_set_option_string(camera->codec_h264, "h264_i_frame_period", "30");
|
||||
device_set_option_string(camera->codec_h264, "h264_level", "11");
|
||||
device_set_option_string(camera->codec_h264, "h264_profile", "4");
|
||||
device_set_option_string(camera->codec_h264, "h264_minimum_qp_value", "16");
|
||||
device_set_option_string(camera->codec_h264, "h264_maximum_qp_value", "32");
|
||||
device_set_option_string(camera->codec_h264_lowres, "video_bitrate_mode", "0");
|
||||
device_set_option_string(camera->codec_h264_lowres, "video_bitrate", "5000000");
|
||||
device_set_option_string(camera->codec_h264_lowres, "repeat_sequence_header", "1");
|
||||
device_set_option_string(camera->codec_h264_lowres, "h264_i_frame_period", "30");
|
||||
device_set_option_string(camera->codec_h264_lowres, "h264_level", "11");
|
||||
device_set_option_string(camera->codec_h264_lowres, "h264_profile", "4");
|
||||
device_set_option_string(camera->codec_h264_lowres, "h264_minimum_qp_value", "16");
|
||||
device_set_option_string(camera->codec_h264_lowres, "h264_maximum_qp_value", "32");
|
||||
|
||||
device_set_fps(camera->camera, camera->options.fps);
|
||||
device_set_option_list(camera->camera, camera->options.options);
|
||||
device_set_option_list(camera->isp, camera->options.isp.options);
|
||||
device_set_option_list(camera->codec_h264, camera->options.h264.options);
|
||||
device_set_option_list(camera->codec_h264_lowres, camera->options.h264.options);
|
||||
device_set_option_list(camera->codec_jpeg, camera->options.jpeg.options);
|
||||
device_set_option_list(camera->codec_jpeg_lowres, camera->options.jpeg.options);
|
||||
|
||||
// Set some defaults
|
||||
for (int i = 0; i < 2; i++) {
|
||||
device_set_option_string(camera->codec_jpeg[i], "compression_quality", "80");
|
||||
device_set_option_string(camera->codec_h264[i], "video_bitrate_mode", "0");
|
||||
device_set_option_string(camera->codec_h264[i], "video_bitrate", "5000000");
|
||||
device_set_option_string(camera->codec_h264[i], "repeat_sequence_header", "1");
|
||||
device_set_option_string(camera->codec_h264[i], "h264_i_frame_period", "30");
|
||||
device_set_option_string(camera->codec_h264[i], "h264_level", "11");
|
||||
device_set_option_string(camera->codec_h264[i], "h264_profile", "4");
|
||||
device_set_option_string(camera->codec_h264[i], "h264_minimum_qp_value", "16");
|
||||
device_set_option_string(camera->codec_h264[i], "h264_maximum_qp_value", "32");
|
||||
device_set_option_list(camera->codec_jpeg[i], camera->options.jpeg.options);
|
||||
device_set_option_list(camera->codec_h264[i], camera->options.h264.options);
|
||||
}
|
||||
|
||||
// DEVICE_SET_OPTION(camera->camera, EXPOSURE, 2684);
|
||||
// DEVICE_SET_OPTION(camera->camera, ANALOGUE_GAIN, 938);
|
||||
|
@ -49,10 +49,9 @@ typedef struct camera_s {
|
||||
device_t *camera;
|
||||
device_t *decoder; // decode JPEG/H264 into YUVU
|
||||
device_t *isp;
|
||||
device_t *codec_jpeg; // encode YUVU into JPEG
|
||||
device_t *codec_h264; // encode YUVU into H264
|
||||
device_t *codec_jpeg_lowres; // encode YUVU into JPEG
|
||||
device_t *codec_h264_lowres; // encode YUVU into H264
|
||||
device_t *legacy_isp;
|
||||
device_t *codec_jpeg[2]; // encode YUVU into JPEG
|
||||
device_t *codec_h264[2]; // encode YUVU into H264
|
||||
};
|
||||
};
|
||||
|
||||
@ -67,9 +66,14 @@ int camera_set_params(camera_t *camera);
|
||||
void camera_close(camera_t *camera);
|
||||
int camera_run(camera_t *camera);
|
||||
|
||||
link_t *camera_ensure_capture(camera_t *camera, buffer_list_t *capture);
|
||||
void camera_capture_add_output(camera_t *camera, buffer_list_t *capture, buffer_list_t *output);
|
||||
void camera_capture_set_callbacks(camera_t *camera, buffer_list_t *capture, link_callbacks_t callbacks);
|
||||
|
||||
int camera_configure_output(camera_t *camera, buffer_list_t *src_capture, int res);
|
||||
int camera_configure_decoder(camera_t *camera, buffer_list_t *src_capture);
|
||||
|
||||
int camera_configure_v4l2(camera_t *camera);
|
||||
int camera_configure_libcamera(camera_t *camera);
|
||||
int camera_configure_isp(camera_t *camera, buffer_list_t *src, float high_div, float low_div);
|
||||
int camera_configure_legacy_isp(camera_t *camera, buffer_list_t *src, float div);
|
||||
int camera_configure_direct(camera_t *camera, buffer_list_t *src);
|
||||
int camera_configure_decoder(camera_t *camera, buffer_list_t *src);
|
||||
|
@ -9,56 +9,21 @@
|
||||
#include "device/buffer_list.h"
|
||||
#include "http/http.h"
|
||||
|
||||
int camera_configure_decoder(camera_t *camera, buffer_list_t *camera_capture)
|
||||
int camera_configure_decoder(camera_t *camera, buffer_list_t *src_capture)
|
||||
{
|
||||
buffer_list_t *src = camera_capture;
|
||||
device_video_force_key(camera->camera);
|
||||
|
||||
camera->decoder = device_v4l2_open("DECODER", "/dev/video10");
|
||||
|
||||
buffer_list_t *decoder_output = device_open_buffer_list_output(camera->decoder, src);
|
||||
buffer_list_t *decoder_capture = device_open_buffer_list_capture(camera->decoder, decoder_output, 1.0, 0, true);
|
||||
buffer_list_t *decoder_output = device_open_buffer_list_output(
|
||||
camera->decoder, src_capture);
|
||||
buffer_list_t *decoder_capture = device_open_buffer_list_capture(
|
||||
camera->decoder, decoder_output, 1.0, 0, true);
|
||||
|
||||
link_t *links = camera->links;
|
||||
link_t *camera_link = &*links++;
|
||||
link_t *decoder_link = &*links++;
|
||||
camera_capture_add_output(camera, src_capture, decoder_output);
|
||||
|
||||
*camera_link = (link_t){ camera_capture, { decoder_output }, {} };
|
||||
*decoder_link = (link_t){ decoder_capture, { }, { } };
|
||||
buffer_list_t **decoder_sinks = &decoder_link->sinks[0];
|
||||
|
||||
if (camera_capture->fmt.format == V4L2_PIX_FMT_MJPEG || camera_capture->fmt.format == V4L2_PIX_FMT_JPEG) {
|
||||
camera_link->callbacks.on_buffer = http_jpeg_capture;
|
||||
camera_link->callbacks.validate_buffer = http_jpeg_needs_buffer;
|
||||
} else {
|
||||
camera->codec_jpeg = device_v4l2_open("JPEG", "/dev/video31");
|
||||
|
||||
buffer_list_t *jpeg_output = device_open_buffer_list_output(camera->codec_jpeg, decoder_capture);
|
||||
buffer_list_t *jpeg_capture = device_open_buffer_list_capture(camera->codec_jpeg, jpeg_output, 1.0, V4L2_PIX_FMT_JPEG, true);
|
||||
|
||||
if (!jpeg_capture) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
*decoder_sinks++ = jpeg_output;
|
||||
*links++ = (link_t){ jpeg_capture, { }, { http_jpeg_capture, http_jpeg_needs_buffer } };
|
||||
}
|
||||
|
||||
if (camera_capture->fmt.format == V4L2_PIX_FMT_H264) {
|
||||
camera_link->callbacks.on_buffer = http_h264_capture;
|
||||
camera_link->callbacks.validate_buffer = http_h264_needs_buffer;
|
||||
} else {
|
||||
camera->codec_h264 = device_v4l2_open("H264", "/dev/video11");
|
||||
|
||||
buffer_list_t *h264_output = device_open_buffer_list_output(camera->codec_jpeg, decoder_capture);
|
||||
buffer_list_t *h264_capture = device_open_buffer_list_capture(camera->codec_jpeg, h264_output, 1.0, V4L2_PIX_FMT_H264, true);
|
||||
|
||||
if (!h264_output) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
*decoder_sinks++ = h264_output;
|
||||
*links++ = (link_t){ h264_capture, { }, { http_h264_capture, http_h264_needs_buffer } };
|
||||
if (camera_configure_output(camera, decoder_capture, 0) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (device_set_decoder_start(camera->decoder, true) < 0) {
|
||||
|
@ -1,32 +0,0 @@
|
||||
#include "camera.h"
|
||||
|
||||
#include "device/buffer.h"
|
||||
#include "device/buffer_list.h"
|
||||
#include "device/device.h"
|
||||
#include "device/links.h"
|
||||
#include "opts/log.h"
|
||||
#include "opts/fourcc.h"
|
||||
#include "device/buffer_list.h"
|
||||
#include "http/http.h"
|
||||
|
||||
int camera_configure_direct(camera_t *camera, buffer_list_t *camera_capture)
|
||||
{
|
||||
camera->codec_jpeg = device_v4l2_open("JPEG", "/dev/video31");
|
||||
camera->codec_h264 = device_v4l2_open("H264", "/dev/video11");
|
||||
|
||||
buffer_list_t *jpeg_output = device_open_buffer_list_output(camera->codec_jpeg, camera_capture);
|
||||
buffer_list_t *jpeg_capture = device_open_buffer_list_capture(camera->codec_jpeg, jpeg_output, 1.0, V4L2_PIX_FMT_JPEG, true);
|
||||
|
||||
buffer_list_t *h264_output = device_open_buffer_list_output(camera->codec_h264, camera_capture);
|
||||
buffer_list_t *h264_capture = device_open_buffer_list_capture(camera->codec_h264, h264_output, 1.0, V4L2_PIX_FMT_H264, true);
|
||||
|
||||
if (!jpeg_capture || !h264_capture) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
link_t *links = camera->links;
|
||||
*links++ = (link_t){ camera_capture, { jpeg_output, h264_output} };
|
||||
*links++ = (link_t){ jpeg_capture, { }, { http_jpeg_capture, http_jpeg_needs_buffer } };
|
||||
*links++ = (link_t){ h264_capture, { }, { http_h264_capture, http_h264_needs_buffer } };
|
||||
return 0;
|
||||
}
|
@ -9,57 +9,29 @@
|
||||
#include "device/buffer_list.h"
|
||||
#include "http/http.h"
|
||||
|
||||
void write_yuvu(buffer_t *buffer);
|
||||
|
||||
int camera_configure_isp(camera_t *camera, buffer_list_t *camera_capture, float high_div, float low_div)
|
||||
int camera_configure_isp(camera_t *camera, buffer_list_t *src_capture, float high_div, float low_div)
|
||||
{
|
||||
link_t *links = camera->links;
|
||||
|
||||
camera->isp = device_v4l2_open("ISP", "/dev/video13");
|
||||
camera->codec_jpeg = device_v4l2_open("JPEG", "/dev/video31");
|
||||
camera->codec_h264 = device_v4l2_open("H264", "/dev/video11");
|
||||
|
||||
buffer_list_t *isp_output = device_open_buffer_list_output(camera->isp, camera_capture);
|
||||
buffer_list_t *isp_capture = device_open_buffer_list_capture2(camera->isp, "/dev/video14", isp_output, high_div, V4L2_PIX_FMT_YUYV, true);
|
||||
buffer_list_t *isp_output = device_open_buffer_list_output(
|
||||
camera->isp, src_capture);
|
||||
buffer_list_t *isp_capture = device_open_buffer_list_capture2(
|
||||
camera->isp, "/dev/video14", isp_output, high_div, V4L2_PIX_FMT_YUYV, true);
|
||||
|
||||
*links++ = (link_t){ camera_capture, { isp_output } };
|
||||
camera_capture_add_output(camera, src_capture, isp_output);
|
||||
|
||||
buffer_list_t *jpeg_output = device_open_buffer_list_output(camera->codec_jpeg, isp_capture);
|
||||
buffer_list_t *jpeg_capture = device_open_buffer_list_capture(camera->codec_jpeg, jpeg_output, 1.0, V4L2_PIX_FMT_JPEG, true);
|
||||
|
||||
buffer_list_t *h264_output = device_open_buffer_list_output(camera->codec_h264, isp_capture);
|
||||
buffer_list_t *h264_capture = device_open_buffer_list_capture(camera->codec_h264, h264_output, 1.0, V4L2_PIX_FMT_H264, true);
|
||||
|
||||
if (!jpeg_capture || !h264_capture) {
|
||||
if (camera_configure_output(camera, isp_capture, 0) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
*links++ = (link_t){ isp_capture, { jpeg_output, h264_output }, { write_yuvu } };
|
||||
*links++ = (link_t){ jpeg_capture, { }, { http_jpeg_capture, http_jpeg_needs_buffer } };
|
||||
*links++ = (link_t){ h264_capture, { }, { http_h264_capture, http_h264_needs_buffer } };
|
||||
if (low_div > 1) {
|
||||
buffer_list_t *isp_lowres_capture = device_open_buffer_list_capture2(
|
||||
camera->isp, "/dev/video15", isp_output, low_div, V4L2_PIX_FMT_YUYV, true);
|
||||
|
||||
// all done
|
||||
if (low_div < 1) {
|
||||
return 0;
|
||||
if (camera_configure_output(camera, isp_lowres_capture, 1) < 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
camera->codec_jpeg_lowres = device_v4l2_open("JPEG-LOW", "/dev/video31");
|
||||
camera->codec_h264_lowres = device_v4l2_open("H264-LOW", "/dev/video11");
|
||||
|
||||
buffer_list_t *isp_lowres_capture = device_open_buffer_list_capture2(camera->isp, "/dev/video15", isp_output, low_div, V4L2_PIX_FMT_YUYV, true);
|
||||
|
||||
buffer_list_t *jpeg_lowres_output = device_open_buffer_list_output(camera->codec_jpeg_lowres, isp_lowres_capture);
|
||||
buffer_list_t *jpeg_lowres_capture = device_open_buffer_list_capture(camera->codec_jpeg_lowres, jpeg_lowres_output, 1.0, V4L2_PIX_FMT_JPEG, true);
|
||||
|
||||
buffer_list_t *h264_lowres_output = device_open_buffer_list_output(camera->codec_h264_lowres, isp_lowres_capture);
|
||||
buffer_list_t *h264_lowres_capture = device_open_buffer_list_capture(camera->codec_h264_lowres, h264_lowres_output, 1.0, V4L2_PIX_FMT_H264, true);
|
||||
|
||||
if (!jpeg_lowres_capture || !h264_lowres_capture) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
*links++ = (link_t){ isp_capture, { jpeg_lowres_output, h264_lowres_output }, { write_yuvu } };
|
||||
*links++ = (link_t){ jpeg_lowres_capture, { }, { http_jpeg_lowres_capture, http_jpeg_needs_buffer } };
|
||||
*links++ = (link_t){ h264_lowres_capture, { }, { http_h264_lowres_capture, http_h264_needs_buffer } };
|
||||
return 0;
|
||||
}
|
||||
|
@ -9,41 +9,20 @@
|
||||
#include "device/buffer_list.h"
|
||||
#include "http/http.h"
|
||||
|
||||
void write_yuvu(buffer_t *buffer)
|
||||
int camera_configure_legacy_isp(camera_t *camera, buffer_list_t *src_capture, float div)
|
||||
{
|
||||
#if 0
|
||||
FILE *fp = fopen("/tmp/capture-yuyv.raw.tmp", "wb");
|
||||
if (fp) {
|
||||
fwrite(buffer->start, 1, buffer->used, fp);
|
||||
fclose(fp);
|
||||
}
|
||||
rename("/tmp/capture-yuyv.raw.tmp", "/tmp/capture-yuyv.raw");
|
||||
#endif
|
||||
}
|
||||
camera->legacy_isp = device_v4l2_open("ISP", "/dev/video12");
|
||||
|
||||
int camera_configure_legacy_isp(camera_t *camera, buffer_list_t *camera_capture, float div)
|
||||
{
|
||||
camera->isp = device_v4l2_open("ISP", "/dev/video12");
|
||||
camera->codec_jpeg = device_v4l2_open("JPEG", "/dev/video31");
|
||||
camera->codec_h264 = device_v4l2_open("H264", "/dev/video11");
|
||||
buffer_list_t *isp_output = device_open_buffer_list_output(
|
||||
camera->legacy_isp, src_capture);
|
||||
buffer_list_t *isp_capture = device_open_buffer_list_capture(
|
||||
camera->legacy_isp, isp_output, div, V4L2_PIX_FMT_YUYV, true);
|
||||
|
||||
buffer_list_t *isp_output = device_open_buffer_list_output(camera->isp, camera_capture);
|
||||
buffer_list_t *isp_capture = device_open_buffer_list_capture(camera->isp, isp_output, div, V4L2_PIX_FMT_YUYV, true);
|
||||
camera_capture_add_output(camera, src_capture, isp_output);
|
||||
|
||||
buffer_list_t *jpeg_output = device_open_buffer_list_output(camera->codec_jpeg, isp_capture);
|
||||
buffer_list_t *jpeg_capture = device_open_buffer_list_capture(camera->codec_jpeg, jpeg_output, 1.0, V4L2_PIX_FMT_JPEG, true);
|
||||
|
||||
buffer_list_t *h264_output = device_open_buffer_list_output(camera->codec_h264, isp_capture);
|
||||
buffer_list_t *h264_capture = device_open_buffer_list_capture(camera->codec_h264, h264_output, 1.0, V4L2_PIX_FMT_H264, true);
|
||||
|
||||
if (!jpeg_capture || !h264_capture) {
|
||||
if (camera_configure_output(camera, isp_capture, 0) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
link_t *links = camera->links;
|
||||
*links++ = (link_t){ camera_capture, { isp_output } };
|
||||
*links++ = (link_t){ isp_capture, { jpeg_output, h264_output }, { write_yuvu, NULL } };
|
||||
*links++ = (link_t){ jpeg_capture, { }, { http_jpeg_capture, http_jpeg_needs_buffer } };
|
||||
*links++ = (link_t){ h264_capture, { }, { http_h264_capture, http_h264_needs_buffer } };
|
||||
return 0;
|
||||
}
|
||||
|
@ -16,7 +16,8 @@ int camera_configure_libcamera(camera_t *camera)
|
||||
|
||||
camera->camera->opts.allow_dma = camera->options.allow_dma;
|
||||
|
||||
buffer_list_t *camera_capture = device_open_buffer_list(camera->camera, true, camera->options.width / camera->options.high_res_factor, camera->options.height / camera->options.high_res_factor, camera->options.format, 0, camera->options.nbufs, true);
|
||||
buffer_list_t *camera_capture = device_open_buffer_list(
|
||||
camera->camera, true, camera->options.width / camera->options.high_res_factor, camera->options.height / camera->options.high_res_factor, camera->options.format, 0, camera->options.nbufs, true);
|
||||
if (!camera_capture) {
|
||||
goto error;
|
||||
}
|
||||
@ -26,7 +27,7 @@ int camera_configure_libcamera(camera_t *camera)
|
||||
camera_capture->fmt.interval_us = 1000 * 1000 / camera->options.fps;
|
||||
}
|
||||
|
||||
if (camera_configure_direct(camera, camera_capture) < 0) {
|
||||
if (camera_configure_output(camera, camera_capture, 0) < 0) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
38
device/camera/camera_links.c
Normal file
38
device/camera/camera_links.c
Normal file
@ -0,0 +1,38 @@
|
||||
#include "camera.h"
|
||||
|
||||
#include "device/buffer.h"
|
||||
#include "device/buffer_list.h"
|
||||
#include "device/device.h"
|
||||
#include "device/links.h"
|
||||
#include "opts/log.h"
|
||||
#include "opts/fourcc.h"
|
||||
#include "device/buffer_list.h"
|
||||
#include "http/http.h"
|
||||
|
||||
link_t *camera_ensure_capture(camera_t *camera, buffer_list_t *capture)
|
||||
{
|
||||
for (int i = 0; i < camera->nlinks; i++) {
|
||||
if (camera->links[i].source == capture) {
|
||||
return &camera->links[i];
|
||||
}
|
||||
}
|
||||
|
||||
link_t *link = &camera->links[camera->nlinks++];
|
||||
link->source = capture;
|
||||
return link;
|
||||
}
|
||||
|
||||
void camera_capture_add_output(camera_t *camera, buffer_list_t *capture, buffer_list_t *output)
|
||||
{
|
||||
link_t *link = camera_ensure_capture(camera, capture);
|
||||
|
||||
int nsinks;
|
||||
for (nsinks = 0; link->sinks[nsinks]; nsinks++);
|
||||
link->sinks[nsinks] = output;
|
||||
}
|
||||
|
||||
void camera_capture_set_callbacks(camera_t *camera, buffer_list_t *capture, link_callbacks_t callbacks)
|
||||
{
|
||||
link_t *link = camera_ensure_capture(camera, capture);
|
||||
link->callbacks = callbacks;
|
||||
}
|
78
device/camera/camera_output.c
Normal file
78
device/camera/camera_output.c
Normal file
@ -0,0 +1,78 @@
|
||||
#include "camera.h"
|
||||
|
||||
#include "device/buffer.h"
|
||||
#include "device/buffer_list.h"
|
||||
#include "device/device.h"
|
||||
#include "device/links.h"
|
||||
#include "opts/log.h"
|
||||
#include "opts/fourcc.h"
|
||||
#include "device/buffer_list.h"
|
||||
#include "http/http.h"
|
||||
|
||||
static const char *jpeg_names[2] = {
|
||||
"JPEG",
|
||||
"JPEG-LOW"
|
||||
};
|
||||
|
||||
static link_callbacks_t jpeg_callbacks[2] = {
|
||||
{ http_jpeg_capture, http_jpeg_needs_buffer },
|
||||
{ http_jpeg_lowres_capture, http_jpeg_needs_buffer }
|
||||
};
|
||||
|
||||
static const char *h264_names[2] = {
|
||||
"H264",
|
||||
"H264-LOW"
|
||||
};
|
||||
|
||||
static link_callbacks_t h264_callbacks[2] = {
|
||||
{ http_h264_capture, http_h264_needs_buffer },
|
||||
{ http_h264_lowres_capture, http_h264_needs_buffer }
|
||||
};
|
||||
|
||||
static int camera_configure_h264_output(camera_t *camera, buffer_list_t *src_capture, int res)
|
||||
{
|
||||
if (src_capture->fmt.format == V4L2_PIX_FMT_H264) {
|
||||
camera_capture_set_callbacks(camera, src_capture, h264_callbacks[res]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
camera->codec_h264[res] = device_v4l2_open(h264_names[res], "/dev/video11");
|
||||
|
||||
buffer_list_t *output = device_open_buffer_list_output(camera->codec_h264[res], src_capture);
|
||||
buffer_list_t *capture = device_open_buffer_list_capture(camera->codec_h264[res], output, 1.0, V4L2_PIX_FMT_H264, true);
|
||||
|
||||
if (!capture) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
camera_capture_add_output(camera, src_capture, output);
|
||||
camera_capture_set_callbacks(camera, capture, h264_callbacks[res]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int camera_configure_jpeg_output(camera_t *camera, buffer_list_t *src_capture, int res)
|
||||
{
|
||||
if (src_capture->fmt.format == V4L2_PIX_FMT_MJPEG || src_capture->fmt.format == V4L2_PIX_FMT_JPEG) {
|
||||
camera_capture_set_callbacks(camera, src_capture, jpeg_callbacks[res]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
camera->codec_jpeg[res] = device_v4l2_open(jpeg_names[res], "/dev/video31");
|
||||
|
||||
buffer_list_t *output = device_open_buffer_list_output(camera->codec_jpeg[res], src_capture);
|
||||
buffer_list_t *capture = device_open_buffer_list_capture(camera->codec_jpeg[res], output, 1.0, V4L2_PIX_FMT_JPEG, true);
|
||||
|
||||
if (!capture) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
camera_capture_add_output(camera, src_capture, output);
|
||||
camera_capture_set_callbacks(camera, capture, jpeg_callbacks[res]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int camera_configure_output(camera_t *camera, buffer_list_t *src_capture, int res)
|
||||
{
|
||||
return camera_configure_h264_output(camera, src_capture, res) == 0 &&
|
||||
camera_configure_jpeg_output(camera, src_capture, res) == 0;
|
||||
}
|
@ -39,7 +39,7 @@ int camera_configure_v4l2(camera_t *camera)
|
||||
case V4L2_PIX_FMT_YUV420:
|
||||
case V4L2_PIX_FMT_RGB565:
|
||||
case V4L2_PIX_FMT_RGB24:
|
||||
if (camera_configure_direct(camera, camera_capture) < 0) {
|
||||
if (camera_configure_output(camera, camera_capture, 0) < 0) {
|
||||
goto error;
|
||||
}
|
||||
break;
|
||||
|
@ -13,14 +13,16 @@ typedef void (*link_on_buffer)(buffer_t *buf);
|
||||
typedef bool (*link_check_streaming)();
|
||||
typedef bool (*link_validate_buffer)(struct link_s *link, buffer_t *buf);
|
||||
|
||||
typedef struct link_callbacks_s {
|
||||
link_on_buffer on_buffer;
|
||||
link_check_streaming check_streaming;
|
||||
link_validate_buffer validate_buffer;
|
||||
} link_callbacks_t;
|
||||
|
||||
typedef struct link_s {
|
||||
struct buffer_list_s *source; // capture_list
|
||||
struct buffer_list_s *sinks[10];
|
||||
struct {
|
||||
link_on_buffer on_buffer;
|
||||
link_check_streaming check_streaming;
|
||||
link_validate_buffer validate_buffer;
|
||||
} callbacks;
|
||||
buffer_list_t *source; // capture_list
|
||||
buffer_list_t *sinks[10];
|
||||
link_callbacks_t callbacks;
|
||||
} link_t;
|
||||
|
||||
int links_init(link_t *all_links);
|
||||
|
Loading…
x
Reference in New Issue
Block a user