Add libcamera - dummy (for now)
This commit is contained in:
parent
2ec7347b26
commit
2e36ac9aed
17
Makefile
17
Makefile
@ -1,24 +1,30 @@
|
||||
TARGET := camera_stream
|
||||
SRC := $(wildcard **/*.c) $(wildcard **/*/*.c)
|
||||
HEADERS := $(wildcard **/*.h) $(wildcard **/*/*.h)
|
||||
SRC := $(wildcard **/*.c **/*/*.c **/*.cc **/*/*.cc)
|
||||
HEADERS := $(wildcard **/*.h **/*/*.h **/*.hh **/*/*.hh)
|
||||
HTML := $(wildcard html/*.js html/*.html)
|
||||
|
||||
CFLAGS := -Werror -g -I$(PWD)
|
||||
LDLIBS := -lpthread
|
||||
LDLIBS := -lpthread -lstdc++
|
||||
|
||||
ifneq (x,x$(shell which ccache))
|
||||
CCACHE ?= ccache
|
||||
endif
|
||||
|
||||
USE_FFMPEG ?= $(shell pkg-config libavutil libavformat libavcodec && echo 1)
|
||||
USE_LIBCAMERA ?= $(shell pkg-config libcamera && echo 1)
|
||||
|
||||
ifeq (1,$(USE_FFMPEG))
|
||||
CFLAGS += -DUSE_FFMPEG
|
||||
LDLIBS += -lavcodec -lavformat -lavutil
|
||||
endif
|
||||
|
||||
ifeq (1,$(USE_LIBCAMERA))
|
||||
CFLAGS += -DUSE_LIBCAMERA $(shell pkg-config --cflags libcamera)
|
||||
LDLIBS += $(shell pkg-config --cflags libs)
|
||||
endif
|
||||
|
||||
HTML_SRC = $(addsuffix .c,$(HTML))
|
||||
OBJS = $(subst .c,.o,$(SRC) $(HTML_SRC))
|
||||
OBJS = $(patsubst %.cc,%.o,$(patsubst %.c,%.o,$(SRC) $(HTML_SRC)))
|
||||
|
||||
.SUFFIXES:
|
||||
|
||||
@ -41,6 +47,9 @@ headers:
|
||||
%.o: %.c
|
||||
$(CCACHE) $(CC) -MMD $(CFLAGS) -c -o $@ $<
|
||||
|
||||
%.o: %.cc
|
||||
$(CCACHE) $(CXX) -std=c++17 -MMD $(CFLAGS) -c -o $@ $<
|
||||
|
||||
html/%.c: html/%
|
||||
xxd -i $< > $@.tmp
|
||||
mv $@.tmp $@
|
||||
|
@ -25,6 +25,7 @@ typedef struct buffer_s {
|
||||
union {
|
||||
struct buffer_v4l2_s *v4l2;
|
||||
struct buffer_dummy_s *dummy;
|
||||
struct buffer_libcamera_s *libcamera;
|
||||
};
|
||||
|
||||
// State
|
||||
|
@ -18,6 +18,7 @@ typedef struct buffer_list_s {
|
||||
union {
|
||||
struct buffer_list_v4l2_s *v4l2;
|
||||
struct buffer_list_dummy_s *dummy;
|
||||
struct buffer_list_libcamera_s *libcamera;
|
||||
};
|
||||
|
||||
unsigned fmt_width, fmt_height, fmt_format, fmt_bytesperline, fmt_interval_us;
|
||||
|
@ -41,6 +41,7 @@ typedef struct device_s {
|
||||
union {
|
||||
struct device_v4l2_s *v4l2;
|
||||
struct device_dummy_s *dummy;
|
||||
struct device_libcamera_s *libcamera;
|
||||
};
|
||||
|
||||
device_t *output_device;
|
||||
@ -65,3 +66,4 @@ int device_set_option_string(device_t *dev, const char *option, const char *valu
|
||||
void device_set_option_list(device_t *dev, const char *option_list);
|
||||
|
||||
device_t *device_v4l2_open(const char *name, const char *path);
|
||||
device_t *device_libcamera_open(const char *name, const char *path);
|
||||
|
35
device/libcamera/buffer.cc
Normal file
35
device/libcamera/buffer.cc
Normal file
@ -0,0 +1,35 @@
|
||||
#include "libcamera.hh"
|
||||
|
||||
extern "C" {
|
||||
#include "device/buffer.h"
|
||||
#include <stdlib.h>
|
||||
};
|
||||
|
||||
int libcamera_buffer_open(buffer_t *buf)
|
||||
{
|
||||
buf->libcamera = new buffer_libcamera_t{};
|
||||
return 0;
|
||||
}
|
||||
|
||||
void libcamera_buffer_close(buffer_t *buf)
|
||||
{
|
||||
if (buf->libcamera) {
|
||||
delete buf->libcamera;
|
||||
buf->libcamera = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int libcamera_buffer_enqueue(buffer_t *buf, const char *who)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int libcamera_buffer_list_dequeue(buffer_list_t *buf_list, buffer_t **bufp)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int libcamera_buffer_list_pollfd(buffer_list_t *buf_list, struct pollfd *pollfd, bool can_dequeue)
|
||||
{
|
||||
return -1;
|
||||
}
|
30
device/libcamera/buffer_list.cc
Normal file
30
device/libcamera/buffer_list.cc
Normal file
@ -0,0 +1,30 @@
|
||||
#include "libcamera.hh"
|
||||
|
||||
extern "C" {
|
||||
#include "device/buffer_list.h"
|
||||
#include <stdlib.h>
|
||||
};
|
||||
|
||||
int libcamera_buffer_list_open(buffer_list_t *buf_list, unsigned width, unsigned height, unsigned format, unsigned bytesperline)
|
||||
{
|
||||
buf_list->libcamera = new buffer_list_libcamera_t{};
|
||||
return 0;
|
||||
}
|
||||
|
||||
void libcamera_buffer_list_close(buffer_list_t *buf_list)
|
||||
{
|
||||
if (buf_list->libcamera) {
|
||||
delete buf_list->libcamera;
|
||||
buf_list->libcamera = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int libcamera_buffer_list_set_buffers(buffer_list_t *buf_list, int nbufs)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int libcamera_buffer_list_set_stream(buffer_list_t *buf_list, bool do_on)
|
||||
{
|
||||
return -1;
|
||||
}
|
40
device/libcamera/device.cc
Normal file
40
device/libcamera/device.cc
Normal file
@ -0,0 +1,40 @@
|
||||
#include "libcamera.hh"
|
||||
|
||||
extern "C" {
|
||||
#include "device/device.h"
|
||||
#include <stdlib.h>
|
||||
};
|
||||
|
||||
int libcamera_device_open(device_t *dev)
|
||||
{
|
||||
dev->libcamera = new device_libcamera_t{};
|
||||
return 0;
|
||||
}
|
||||
|
||||
void libcamera_device_close(device_t *dev)
|
||||
{
|
||||
if (dev->libcamera) {
|
||||
delete dev->libcamera;
|
||||
dev->libcamera = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int libcamera_device_set_decoder_start(device_t *dev, bool do_on)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int libcamera_device_video_force_key(device_t *dev)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int libcamera_device_set_fps(device_t *dev, int desired_fps)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int libcamera_device_set_option(device_t *dev, const char *key, const char *value)
|
||||
{
|
||||
return -1;
|
||||
}
|
30
device/libcamera/libcamera.cc
Normal file
30
device/libcamera/libcamera.cc
Normal file
@ -0,0 +1,30 @@
|
||||
#include "libcamera.hh"
|
||||
|
||||
extern "C" {
|
||||
#include "device/device.h"
|
||||
};
|
||||
|
||||
device_hw_t libcamera_device_hw = {
|
||||
.device_open = libcamera_device_open,
|
||||
.device_close = libcamera_device_close,
|
||||
.device_set_decoder_start = libcamera_device_set_decoder_start,
|
||||
.device_video_force_key = libcamera_device_video_force_key,
|
||||
.device_set_fps = libcamera_device_set_fps,
|
||||
.device_set_option = libcamera_device_set_option,
|
||||
|
||||
.buffer_open = libcamera_buffer_open,
|
||||
.buffer_close = libcamera_buffer_close,
|
||||
.buffer_enqueue = libcamera_buffer_enqueue,
|
||||
|
||||
.buffer_list_dequeue = libcamera_buffer_list_dequeue,
|
||||
.buffer_list_pollfd = libcamera_buffer_list_pollfd,
|
||||
.buffer_list_open = libcamera_buffer_list_open,
|
||||
.buffer_list_close = libcamera_buffer_list_close,
|
||||
.buffer_list_set_buffers = libcamera_buffer_list_set_buffers,
|
||||
.buffer_list_set_stream = libcamera_buffer_list_set_stream
|
||||
};
|
||||
|
||||
extern "C" device_t *device_libcamera_open(const char *name, const char *path)
|
||||
{
|
||||
return device_open(name, path, &libcamera_device_hw);
|
||||
}
|
52
device/libcamera/libcamera.hh
Normal file
52
device/libcamera/libcamera.hh
Normal file
@ -0,0 +1,52 @@
|
||||
#pragma once
|
||||
|
||||
extern "C" {
|
||||
#include <linux/videodev2.h>
|
||||
#include <linux/v4l2-subdev.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
};
|
||||
|
||||
#include <libcamera/controls.h>
|
||||
#include <libcamera/control_ids.h>
|
||||
#include <libcamera/property_ids.h>
|
||||
#include <libcamera/libcamera.h>
|
||||
#include <libcamera/camera.h>
|
||||
#include <libcamera/camera_manager.h>
|
||||
#include <libcamera/framebuffer_allocator.h>
|
||||
#include <libcamera/request.h>
|
||||
#include <libcamera/stream.h>
|
||||
#include <libcamera/formats.h>
|
||||
#include <libcamera/transform.h>
|
||||
|
||||
typedef struct buffer_s buffer_t;
|
||||
typedef struct buffer_list_s buffer_list_t;
|
||||
typedef struct device_s device_t;
|
||||
struct pollfd;
|
||||
|
||||
typedef struct device_libcamera_s {
|
||||
} device_libcamera_t;
|
||||
|
||||
typedef struct buffer_list_libcamera_s {
|
||||
} buffer_list_libcamera_t;
|
||||
|
||||
typedef struct buffer_libcamera_s {
|
||||
} buffer_libcamera_t;
|
||||
|
||||
int libcamera_device_open(device_t *dev);
|
||||
void libcamera_device_close(device_t *dev);
|
||||
int libcamera_device_set_decoder_start(device_t *dev, bool do_on);
|
||||
int libcamera_device_video_force_key(device_t *dev);
|
||||
int libcamera_device_set_fps(device_t *dev, int desired_fps);
|
||||
int libcamera_device_set_option(device_t *dev, const char *key, const char *value);
|
||||
|
||||
int libcamera_buffer_open(buffer_t *buf);
|
||||
void libcamera_buffer_close(buffer_t *buf);
|
||||
int libcamera_buffer_enqueue(buffer_t *buf, const char *who);
|
||||
int libcamera_buffer_list_dequeue(buffer_list_t *buf_list, buffer_t **bufp);
|
||||
int libcamera_buffer_list_pollfd(buffer_list_t *buf_list, struct pollfd *pollfd, bool can_dequeue);
|
||||
|
||||
int libcamera_buffer_list_open(buffer_list_t *buf_list, unsigned width, unsigned height, unsigned format, unsigned bytesperline);
|
||||
void libcamera_buffer_list_close(buffer_list_t *buf_list);
|
||||
int libcamera_buffer_list_set_buffers(buffer_list_t *buf_list, int nbufs);
|
||||
int libcamera_buffer_list_set_stream(buffer_list_t *buf_list, bool do_on);
|
Loading…
x
Reference in New Issue
Block a user