build: check build no video
This commit is contained in:
@@ -18,6 +18,17 @@ jobs:
|
|||||||
- name: gcc
|
- name: gcc
|
||||||
run: mkdir -p build && gcc -v -Wall -Wextra -Werror -Wno-format-truncation src/*.c src/*.h -lglfw -lGL -lm -lasound -lbsd -Iinclude hashmap.c/hashmap.c log.c/src/log.c -DGLFW_INCLUDE_NONE -DGLFW_EXPOSE_NATIVE_EGL -DGLFW_NATIVE_INCLUDE_NONE -DVIDEO_IN
|
run: mkdir -p build && gcc -v -Wall -Wextra -Werror -Wno-format-truncation src/*.c src/*.h -lglfw -lGL -lm -lasound -lbsd -Iinclude hashmap.c/hashmap.c log.c/src/log.c -DGLFW_INCLUDE_NONE -DGLFW_EXPOSE_NATIVE_EGL -DGLFW_NATIVE_INCLUDE_NONE -DVIDEO_IN
|
||||||
|
|
||||||
|
build-no-video:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: 'true'
|
||||||
|
- name: install libs
|
||||||
|
run: sudo apt install -y libglfw3-dev libgl-dev libasound2-dev libbsd-dev
|
||||||
|
- name: gcc
|
||||||
|
run: mkdir -p build && gcc -v -Werror src/*.c src/*.h -lglfw -lGL -lm -lasound -lbsd -Iinclude hashmap.c/hashmap.c log.c/src/log.c -DGLFW_INCLUDE_NONE -DGLFW_EXPOSE_NATIVE_EGL -DGLFW_NATIVE_INCLUDE_NONE
|
||||||
|
|
||||||
build-release:
|
build-release:
|
||||||
needs: lint
|
needs: lint
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
@@ -14,11 +14,15 @@
|
|||||||
#define GLAD_GL_IMPLEMENTATION
|
#define GLAD_GL_IMPLEMENTATION
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
|
|
||||||
|
#ifdef VIDEO_IN
|
||||||
#define GLAD_EGL_IMPLEMENTATION
|
#define GLAD_EGL_IMPLEMENTATION
|
||||||
#include <glad/egl.h>
|
#include <glad/egl.h>
|
||||||
|
#endif /* VIDEO_IN */
|
||||||
|
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
#ifdef VIDEO_IN
|
||||||
#include <GLFW/glfw3native.h>
|
#include <GLFW/glfw3native.h>
|
||||||
|
#endif /* VIDEO_IN */
|
||||||
|
|
||||||
static const GLuint unused_uniform = (GLuint)-1;
|
static const GLuint unused_uniform = (GLuint)-1;
|
||||||
|
|
||||||
@@ -38,6 +42,7 @@ bool check_glerror(ShaderProgram *program) {
|
|||||||
static void init_gl(ShaderProgram *program) {
|
static void init_gl(ShaderProgram *program) {
|
||||||
gladLoadGL(glfwGetProcAddress);
|
gladLoadGL(glfwGetProcAddress);
|
||||||
|
|
||||||
|
#ifdef VIDEO_IN
|
||||||
program->egl_display = glfwGetEGLDisplay();
|
program->egl_display = glfwGetEGLDisplay();
|
||||||
if (program->egl_display == EGL_NO_DISPLAY) {
|
if (program->egl_display == EGL_NO_DISPLAY) {
|
||||||
log_error("error: glfwGetEGLDisplay no EGLDisplay returned");
|
log_error("error: glfwGetEGLDisplay no EGLDisplay returned");
|
||||||
@@ -46,6 +51,7 @@ static void init_gl(ShaderProgram *program) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
gladLoadEGL(program->egl_display, glfwGetProcAddress);
|
gladLoadEGL(program->egl_display, glfwGetProcAddress);
|
||||||
|
#endif /* VIDEO_IN */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init_textures(ShaderProgram *program,
|
static void init_textures(ShaderProgram *program,
|
||||||
@@ -80,6 +86,7 @@ static void rebind_textures(const ShaderProgram *program) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef VIDEO_IN
|
||||||
static void link_input_to_texture(ShaderProgram *program, VideoCapture *input,
|
static void link_input_to_texture(ShaderProgram *program, VideoCapture *input,
|
||||||
unsigned int texture_index) {
|
unsigned int texture_index) {
|
||||||
input->dma_image = EGL_NO_IMAGE_KHR;
|
input->dma_image = EGL_NO_IMAGE_KHR;
|
||||||
@@ -136,6 +143,7 @@ static void init_input(ShaderProgram *program, const ConfigFile *config,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* VIDEO_IN */
|
||||||
|
|
||||||
static void init_framebuffers(ShaderProgram *program,
|
static void init_framebuffers(ShaderProgram *program,
|
||||||
const ConfigFile *config) {
|
const ConfigFile *config) {
|
||||||
@@ -598,11 +606,13 @@ void shaders_init(ShaderProgram *program, const Project *project,
|
|||||||
|
|
||||||
void shaders_link_inputs(ShaderProgram *program, const Project *project,
|
void shaders_link_inputs(ShaderProgram *program, const Project *project,
|
||||||
VideoCaptureArray *inputs) {
|
VideoCaptureArray *inputs) {
|
||||||
|
#ifdef VIDEO_IN
|
||||||
init_input(program, &project->config, inputs);
|
init_input(program, &project->config, inputs);
|
||||||
|
|
||||||
if (check_glerror(program)) {
|
if (check_glerror(program)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif /* VIDEO_IN */
|
||||||
}
|
}
|
||||||
|
|
||||||
void shaders_update(ShaderProgram *program, const File *fragment_shader,
|
void shaders_update(ShaderProgram *program, const File *fragment_shader,
|
||||||
@@ -659,7 +669,9 @@ void shaders_free_window(const ShaderProgram *program, bool secondary) {
|
|||||||
|
|
||||||
void shaders_free_input(const ShaderProgram *program,
|
void shaders_free_input(const ShaderProgram *program,
|
||||||
const VideoCapture *input) {
|
const VideoCapture *input) {
|
||||||
|
#ifdef VIDEO_IN
|
||||||
if (!input->error && input->dma_image != EGL_NO_IMAGE_KHR) {
|
if (!input->error && input->dma_image != EGL_NO_IMAGE_KHR) {
|
||||||
eglDestroyImageKHR(program->egl_display, input->dma_image);
|
eglDestroyImageKHR(program->egl_display, input->dma_image);
|
||||||
}
|
}
|
||||||
|
#endif /* VIDEO_IN */
|
||||||
}
|
}
|
||||||
+7
-8
@@ -1,12 +1,12 @@
|
|||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
#include <alsa/asoundlib.h>
|
#include <alsa/asoundlib.h>
|
||||||
|
#ifdef VIDEO_IN
|
||||||
#include <glad/egl.h>
|
#include <glad/egl.h>
|
||||||
|
#include <linux/videodev2.h>
|
||||||
|
#endif /* VIDEO_IN */
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
#include <hashmap.h>
|
#include <hashmap.h>
|
||||||
#include <linmath.h>
|
#include <linmath.h>
|
||||||
#ifdef VIDEO_IN
|
|
||||||
#include <linux/videodev2.h>
|
|
||||||
#endif /* VIDEO_IN */
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
@@ -127,15 +127,13 @@ typedef struct ShaderProgram {
|
|||||||
unsigned int active_count;
|
unsigned int active_count;
|
||||||
|
|
||||||
unsigned int in_count;
|
unsigned int in_count;
|
||||||
|
#ifdef VIDEO_IN
|
||||||
EGLDisplay egl_display;
|
EGLDisplay egl_display;
|
||||||
|
#endif /* VIDEO_IN */
|
||||||
} ShaderProgram;
|
} ShaderProgram;
|
||||||
|
|
||||||
// video.c
|
// video.c
|
||||||
|
|
||||||
#ifndef VIDEO_IN
|
|
||||||
struct v4l2_buffer {};
|
|
||||||
#endif /* VIDEO_IN */
|
|
||||||
|
|
||||||
typedef struct VideoCapture {
|
typedef struct VideoCapture {
|
||||||
char name[STR_LEN];
|
char name[STR_LEN];
|
||||||
bool error;
|
bool error;
|
||||||
@@ -145,9 +143,10 @@ typedef struct VideoCapture {
|
|||||||
unsigned int height;
|
unsigned int height;
|
||||||
unsigned int pixelformat;
|
unsigned int pixelformat;
|
||||||
unsigned int bytesperline;
|
unsigned int bytesperline;
|
||||||
bool output;
|
#ifdef VIDEO_IN
|
||||||
struct v4l2_buffer buf;
|
struct v4l2_buffer buf;
|
||||||
EGLImageKHR dma_image;
|
EGLImageKHR dma_image;
|
||||||
|
#endif /* VIDEO_IN */
|
||||||
} VideoCapture;
|
} VideoCapture;
|
||||||
|
|
||||||
typedef ARRAY(VideoCaptureArray, VideoCapture);
|
typedef ARRAY(VideoCaptureArray, VideoCapture);
|
||||||
|
|||||||
+10
-20
@@ -17,6 +17,9 @@
|
|||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
#include "video.h"
|
#include "video.h"
|
||||||
|
|
||||||
|
static const unsigned int pixel_format = V4L2_PIX_FMT_YUYV;
|
||||||
|
static const enum v4l2_buf_type buf_type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||||
|
|
||||||
static void ioctl_error(VideoCapture *video_capture, const char *operation,
|
static void ioctl_error(VideoCapture *video_capture, const char *operation,
|
||||||
const char *default_msg) {
|
const char *default_msg) {
|
||||||
if (errno == EINVAL) {
|
if (errno == EINVAL) {
|
||||||
@@ -116,7 +119,7 @@ static bool get_available_sizes(VideoCapture *video_capture,
|
|||||||
|
|
||||||
index = 0;
|
index = 0;
|
||||||
fmt_enum.index = index;
|
fmt_enum.index = index;
|
||||||
fmt_enum.pixel_format = V4L2_PIX_FMT_YUYV;
|
fmt_enum.pixel_format = pixel_format;
|
||||||
|
|
||||||
found = false;
|
found = false;
|
||||||
video_capture->width = 0;
|
video_capture->width = 0;
|
||||||
@@ -148,7 +151,7 @@ static bool get_available_sizes(VideoCapture *video_capture,
|
|||||||
|
|
||||||
memset(&fmt_enum, 0, sizeof(fmt_enum));
|
memset(&fmt_enum, 0, sizeof(fmt_enum));
|
||||||
fmt_enum.index = ++index;
|
fmt_enum.index = ++index;
|
||||||
fmt_enum.pixel_format = V4L2_PIX_FMT_YUYV;
|
fmt_enum.pixel_format = pixel_format;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (video_capture->height == 0) {
|
if (video_capture->height == 0) {
|
||||||
@@ -163,27 +166,19 @@ static bool get_available_sizes(VideoCapture *video_capture,
|
|||||||
static bool set_format(VideoCapture *video_capture) {
|
static bool set_format(VideoCapture *video_capture) {
|
||||||
struct v4l2_format fmt;
|
struct v4l2_format fmt;
|
||||||
|
|
||||||
video_capture->output = false;
|
|
||||||
|
|
||||||
memset(&fmt, 0, sizeof(fmt));
|
memset(&fmt, 0, sizeof(fmt));
|
||||||
|
|
||||||
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
fmt.type = buf_type;
|
||||||
fmt.fmt.pix.width = video_capture->width;
|
fmt.fmt.pix.width = video_capture->width;
|
||||||
fmt.fmt.pix.height = video_capture->height;
|
fmt.fmt.pix.height = video_capture->height;
|
||||||
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV;
|
fmt.fmt.pix.pixelformat = pixel_format;
|
||||||
fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
|
fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
|
||||||
|
|
||||||
if (ioctl(video_capture->fd, VIDIOC_S_FMT, &fmt) == -1) {
|
|
||||||
fmt.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
|
|
||||||
|
|
||||||
video_capture->output = true;
|
|
||||||
|
|
||||||
if (ioctl(video_capture->fd, VIDIOC_S_FMT, &fmt) == -1) {
|
if (ioctl(video_capture->fd, VIDIOC_S_FMT, &fmt) == -1) {
|
||||||
ioctl_error(video_capture, "VIDIOC_S_FMT",
|
ioctl_error(video_capture, "VIDIOC_S_FMT",
|
||||||
"Requested buffer type not supported");
|
"Requested buffer type not supported");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
video_capture->width = fmt.fmt.pix.width;
|
video_capture->width = fmt.fmt.pix.width;
|
||||||
video_capture->height = fmt.fmt.pix.height;
|
video_capture->height = fmt.fmt.pix.height;
|
||||||
@@ -204,8 +199,7 @@ static bool request_buffers(VideoCapture *video_capture) {
|
|||||||
|
|
||||||
memset(&reqbuf, 0, sizeof(reqbuf));
|
memset(&reqbuf, 0, sizeof(reqbuf));
|
||||||
|
|
||||||
reqbuf.type = video_capture->output ? V4L2_BUF_TYPE_VIDEO_OUTPUT
|
reqbuf.type = buf_type;
|
||||||
: V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
||||||
reqbuf.memory = V4L2_MEMORY_MMAP;
|
reqbuf.memory = V4L2_MEMORY_MMAP;
|
||||||
reqbuf.count = 1;
|
reqbuf.count = 1;
|
||||||
|
|
||||||
@@ -227,8 +221,7 @@ static bool export_buffer(VideoCapture *video_capture) {
|
|||||||
|
|
||||||
memset(&expbuf, 0, sizeof(expbuf));
|
memset(&expbuf, 0, sizeof(expbuf));
|
||||||
|
|
||||||
expbuf.type = video_capture->output ? V4L2_BUF_TYPE_VIDEO_OUTPUT
|
expbuf.type = buf_type;
|
||||||
: V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
||||||
expbuf.index = 0;
|
expbuf.index = 0;
|
||||||
expbuf.flags = O_RDONLY;
|
expbuf.flags = O_RDONLY;
|
||||||
|
|
||||||
@@ -244,8 +237,6 @@ static bool export_buffer(VideoCapture *video_capture) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const enum v4l2_buf_type buf_type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
||||||
|
|
||||||
static bool open_stream(VideoCapture *video_capture) {
|
static bool open_stream(VideoCapture *video_capture) {
|
||||||
if (ioctl(video_capture->fd, VIDIOC_STREAMON, &buf_type) == -1) {
|
if (ioctl(video_capture->fd, VIDIOC_STREAMON, &buf_type) == -1) {
|
||||||
ioctl_error(
|
ioctl_error(
|
||||||
@@ -260,8 +251,7 @@ static bool open_stream(VideoCapture *video_capture) {
|
|||||||
static void create_image_buffer(VideoCapture *video_capture) {
|
static void create_image_buffer(VideoCapture *video_capture) {
|
||||||
memset(&video_capture->buf, 0, sizeof(video_capture->buf));
|
memset(&video_capture->buf, 0, sizeof(video_capture->buf));
|
||||||
|
|
||||||
video_capture->buf.type = video_capture->output ? V4L2_BUF_TYPE_VIDEO_OUTPUT
|
video_capture->buf.type = buf_type;
|
||||||
: V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
||||||
video_capture->buf.memory = V4L2_MEMORY_MMAP;
|
video_capture->buf.memory = V4L2_MEMORY_MMAP;
|
||||||
video_capture->buf.index = 0;
|
video_capture->buf.index = 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user