mirror of
https://github.com/aler9/rtsp-simple-server
synced 2025-12-24 11:51:18 +08:00
rpicamera: fix compatibility with latest version of libcamera (#1195)
This commit is contained in:
4
Makefile
4
Makefile
@@ -1,8 +1,8 @@
|
||||
BASE_IMAGE = golang:1.18-alpine3.15
|
||||
LINT_IMAGE = golangci/golangci-lint:v1.49.0
|
||||
NODE_IMAGE = node:16-alpine3.15
|
||||
RPI32_IMAGE = balenalib/raspberrypi3:buster-run
|
||||
RPI64_IMAGE = balenalib/raspberrypi3-64:buster-run
|
||||
RPI32_IMAGE = balenalib/raspberrypi3:bullseye-run
|
||||
RPI64_IMAGE = balenalib/raspberrypi3-64:bullseye-run
|
||||
|
||||
.PHONY: $(shell ls)
|
||||
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
CC = gcc
|
||||
CXX = g++
|
||||
|
||||
CFLAGS = \
|
||||
-Ofast \
|
||||
-Werror \
|
||||
@@ -39,4 +36,4 @@ all: exe
|
||||
$(CXX) $(CXXFLAGS) -c $< -o $@
|
||||
|
||||
exe: $(OBJS)
|
||||
$(CXX) $(LDFLAGS) -o $@ $^
|
||||
$(CXX) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
@@ -33,8 +33,9 @@ using libcamera::Transform;
|
||||
|
||||
namespace controls = libcamera::controls;
|
||||
namespace formats = libcamera::formats;
|
||||
namespace properties = libcamera::properties;
|
||||
|
||||
char errbuf[256];
|
||||
static char errbuf[256];
|
||||
|
||||
static void set_error(const char *format, ...) {
|
||||
va_list args;
|
||||
@@ -49,12 +50,12 @@ const char *camera_get_error() {
|
||||
// https://github.com/raspberrypi/libcamera-apps/blob/dd97618a25523c2c4aa58f87af5f23e49aa6069c/core/libcamera_app.cpp#L42
|
||||
static libcamera::PixelFormat mode_to_pixel_format(sensor_mode_t *mode) {
|
||||
static std::vector<std::pair<std::pair<int, bool>, libcamera::PixelFormat>> table = {
|
||||
{ {8, false}, libcamera::formats::SBGGR8 },
|
||||
{ {8, true}, libcamera::formats::SBGGR8 },
|
||||
{ {10, false}, libcamera::formats::SBGGR10 },
|
||||
{ {10, true}, libcamera::formats::SBGGR10_CSI2P },
|
||||
{ {12, false}, libcamera::formats::SBGGR12 },
|
||||
{ {12, true}, libcamera::formats::SBGGR12_CSI2P },
|
||||
{ {8, false}, formats::SBGGR8 },
|
||||
{ {8, true}, formats::SBGGR8 },
|
||||
{ {10, false}, formats::SBGGR10 },
|
||||
{ {10, true}, formats::SBGGR10_CSI2P },
|
||||
{ {12, false}, formats::SBGGR12 },
|
||||
{ {12, true}, formats::SBGGR12_CSI2P },
|
||||
};
|
||||
|
||||
auto it = std::find_if(table.begin(), table.end(), [&mode] (auto &m) {
|
||||
@@ -63,7 +64,7 @@ static libcamera::PixelFormat mode_to_pixel_format(sensor_mode_t *mode) {
|
||||
return it->second;
|
||||
}
|
||||
|
||||
return libcamera::formats::SBGGR12_CSI2P;
|
||||
return formats::SBGGR12_CSI2P;
|
||||
}
|
||||
|
||||
struct CameraPriv {
|
||||
@@ -304,7 +305,15 @@ bool camera_start(camera_t *cam) {
|
||||
ctrls.set(controls::ExposureValue, camp->params->ev);
|
||||
|
||||
if (camp->params->roi != NULL) {
|
||||
Rectangle sensor_area = camp->camera->properties().get(libcamera::properties::ScalerCropMaximum);
|
||||
std::optional<Rectangle> opt = camp->camera->properties().get(properties::ScalerCropMaximum);
|
||||
Rectangle sensor_area;
|
||||
try {
|
||||
sensor_area = opt.value();
|
||||
} catch(const std::bad_optional_access& exc) {
|
||||
set_error("get(ScalerCropMaximum) failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
Rectangle crop(
|
||||
camp->params->roi->x * sensor_area.width,
|
||||
camp->params->roi->y * sensor_area.height,
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#define DEVICE "/dev/video11"
|
||||
#define POLL_TIMEOUT_MS 200
|
||||
|
||||
char errbuf[256];
|
||||
static char errbuf[256];
|
||||
|
||||
static void set_error(const char *format, ...) {
|
||||
va_list args;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "parameters.h"
|
||||
|
||||
char errbuf[256];
|
||||
static char errbuf[256];
|
||||
|
||||
static void set_error(const char *format, ...) {
|
||||
va_list args;
|
||||
|
||||
Reference in New Issue
Block a user