#ifndef _VENC_INTERNAL_H_
#define _VENC_INTERNAL_H_
#ifndef _GNU_SOURCE
# define _GNU_SOURCE
#endif
#include <h264/h264.h>
#include <inttypes.h>
#include <video-streaming/vstrm.h>
#include <video-encode/venc_core.h>
#include <video-metadata/vmeta.h>
#ifdef __cplusplus
extern "C" {
#endif
struct venc_ops {
int (*get_supported_encodings)(const enum vdef_encoding **encodings);
int (*get_supported_input_formats)(
const struct vdef_raw_format **formats);
int (*create)(struct venc_encoder *base);
int (*flush)(struct venc_encoder *base, int discard);
int (*stop)(struct venc_encoder *base);
int (*destroy)(struct venc_encoder *base);
struct mbuf_pool *(*get_input_buffer_pool)(struct venc_encoder *base);
struct mbuf_raw_video_frame_queue *(*get_input_buffer_queue)(
struct venc_encoder *base);
int (*get_dyn_config)(struct venc_encoder *base,
struct venc_dyn_config *config);
int (*set_dyn_config)(struct venc_encoder *base,
const struct venc_dyn_config *config);
int (*get_input_buffer_constraints)(
const struct vdef_raw_format *format,
struct venc_input_buffer_constraints *constraints);
int (*request_idr)(struct venc_encoder *base);
};
struct venc_encoder {
void *derived;
const struct venc_ops *ops;
struct pomp_loop *loop;
struct venc_cbs cbs;
void *userdata;
struct venc_config config;
union {
struct {
struct h264_ctx *ctx;
uint8_t *sps;
size_t sps_size;
uint8_t *pps;
size_t pps_size;
} h264;
struct {
struct h265_ctx *ctx;
uint8_t *vps;
size_t vps_size;
uint8_t *sps;
size_t sps_size;
uint8_t *pps;
size_t pps_size;
} h265;
};
unsigned int mb_width;
unsigned int mb_height;
unsigned int slice_count;
unsigned int slice_mb_count;
unsigned int slice_mb_count_recovery_point;
unsigned int recovery_frame_cnt;
uint64_t last_timestamp;
};
VENC_API bool venc_default_input_filter(struct mbuf_raw_video_frame *frame,
void *userdata);
VENC_API bool venc_default_input_filter_internal(
struct venc_encoder *encoder,
struct mbuf_raw_video_frame *frame,
struct vdef_raw_frame *frame_info,
const struct vdef_raw_format *supported_formats,
unsigned int nb_supported_formats);
VENC_API void venc_default_input_filter_internal_confirm_frame(
struct venc_encoder *encoder,
struct mbuf_raw_video_frame *frame,
struct vdef_raw_frame *frame_info);
VENC_API struct venc_config_impl *
venc_config_get_specific(struct venc_config *config,
enum venc_encoder_implem implem);
VENC_API int
venc_copy_raw_frame_as_metadata(struct mbuf_raw_video_frame *frame,
struct mbuf_mem *mem,
struct mbuf_raw_video_frame **ret_obj);
#ifdef __cplusplus
}
#endif
#endif