From b9fa7f2fa25ee37c87077bce468c95e48fce5c18 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 5 Jul 2024 01:59:04 +0200 Subject: Separate video encoding method from capture method With this instead of kms_cuda/kms_vaapi/kms_software and xcomposite_cuda/xcomposite_vaapi/xcomposite_software there is now only kms and xcomposite. --- include/encoder/video/cuda.h | 16 ++++++++++++++++ include/encoder/video/software.h | 15 +++++++++++++++ include/encoder/video/vaapi.h | 15 +++++++++++++++ include/encoder/video/video.h | 27 +++++++++++++++++++++++++++ 4 files changed, 73 insertions(+) create mode 100644 include/encoder/video/cuda.h create mode 100644 include/encoder/video/software.h create mode 100644 include/encoder/video/vaapi.h create mode 100644 include/encoder/video/video.h (limited to 'include/encoder') diff --git a/include/encoder/video/cuda.h b/include/encoder/video/cuda.h new file mode 100644 index 0000000..802e72e --- /dev/null +++ b/include/encoder/video/cuda.h @@ -0,0 +1,16 @@ +#ifndef GSR_ENCODER_VIDEO_CUDA_H +#define GSR_ENCODER_VIDEO_CUDA_H + +#include "video.h" + +typedef struct gsr_egl gsr_egl; + +typedef struct { + gsr_egl *egl; + bool overclock; + bool hdr; +} gsr_video_encoder_cuda_params; + +gsr_video_encoder* gsr_video_encoder_cuda_create(const gsr_video_encoder_cuda_params *params); + +#endif /* GSR_ENCODER_VIDEO_CUDA_H */ diff --git a/include/encoder/video/software.h b/include/encoder/video/software.h new file mode 100644 index 0000000..e39d5f8 --- /dev/null +++ b/include/encoder/video/software.h @@ -0,0 +1,15 @@ +#ifndef GSR_ENCODER_VIDEO_SOFTWARE_H +#define GSR_ENCODER_VIDEO_SOFTWARE_H + +#include "video.h" + +typedef struct gsr_egl gsr_egl; + +typedef struct { + gsr_egl *egl; + bool hdr; +} gsr_video_encoder_software_params; + +gsr_video_encoder* gsr_video_encoder_software_create(const gsr_video_encoder_software_params *params); + +#endif /* GSR_ENCODER_VIDEO_SOFTWARE_H */ diff --git a/include/encoder/video/vaapi.h b/include/encoder/video/vaapi.h new file mode 100644 index 0000000..2981a01 --- /dev/null +++ b/include/encoder/video/vaapi.h @@ -0,0 +1,15 @@ +#ifndef GSR_ENCODER_VIDEO_VAAPI_H +#define GSR_ENCODER_VIDEO_VAAPI_H + +#include "video.h" + +typedef struct gsr_egl gsr_egl; + +typedef struct { + gsr_egl *egl; + bool hdr; +} gsr_video_encoder_vaapi_params; + +gsr_video_encoder* gsr_video_encoder_vaapi_create(const gsr_video_encoder_vaapi_params *params); + +#endif /* GSR_ENCODER_VIDEO_VAAPI_H */ diff --git a/include/encoder/video/video.h b/include/encoder/video/video.h new file mode 100644 index 0000000..21338d6 --- /dev/null +++ b/include/encoder/video/video.h @@ -0,0 +1,27 @@ +#ifndef GSR_ENCODER_VIDEO_H +#define GSR_ENCODER_VIDEO_H + +#include "../../color_conversion.h" +#include + +typedef struct gsr_video_encoder gsr_video_encoder; +typedef struct AVCodecContext AVCodecContext; +typedef struct AVFrame AVFrame; + +struct gsr_video_encoder { + bool (*start)(gsr_video_encoder *encoder, AVCodecContext *video_codec_context, AVFrame *frame); + void (*copy_textures_to_frame)(gsr_video_encoder *encoder, AVFrame *frame); /* Can be NULL */ + /* |textures| should be able to fit 2 elements */ + void (*get_textures)(gsr_video_encoder *encoder, unsigned int *textures, int *num_textures, gsr_destination_color *destination_color); + void (*destroy)(gsr_video_encoder *encoder, AVCodecContext *video_codec_context); + + void *priv; + bool started; +}; + +bool gsr_video_encoder_start(gsr_video_encoder *encoder, AVCodecContext *video_codec_context, AVFrame *frame); +void gsr_video_encoder_copy_textures_to_frame(gsr_video_encoder *encoder, AVFrame *frame); +void gsr_video_encoder_get_textures(gsr_video_encoder *encoder, unsigned int *textures, int *num_textures, gsr_destination_color *destination_color); +void gsr_video_encoder_destroy(gsr_video_encoder *encoder, AVCodecContext *video_codec_context); + +#endif /* GSR_ENCODER_VIDEO_H */ -- cgit v1.2.3