#ifndef VMF_VIDEO_ENCODER_H
#define VMF_VIDEO_ENCODER_H

#include <stdint.h>
#include <vmf/video_bind.h>

typedef struct VMF_VENC_HANDLE_S VMF_VENC_HANDLE_T;

typedef enum {
    VMF_VENC_CODEC_TYPE_H264 = 0,
    VMF_VENC_CODEC_TYPE_H265 = 1,
    VMF_VENC_CODEC_TYPE_MJPG = 2,
} VMF_VENC_CODEC_TYPE;

typedef enum {
    VMF_H4E_PROFILE_HIGH = 0,
    VMF_H4E_PROFILE_MAIN = 1,
    VMF_H4E_PROFILE_BASE = 2,
} VMF_H4E_PROFILE_E;

typedef enum {
    VMF_ADMODE_MEET_FPS = 0,
    VMF_ADMODE_CBR      = 1,
} VMF_ADMODE_E;

/* H.264 encoder config — positional init: dwQp,dwBitrate,dbFps,dwGop,eProfile,iSQS,eAdMode,dwMinQp,dwMaxQp,dwMinFps,dwVirtI,dwPIQ */
typedef struct {
    uint32_t          dwQp;
    uint32_t          dwBitrate;
    double            dbFps;
    uint32_t          dwGop;
    VMF_H4E_PROFILE_E eProfile;
    int32_t           iSliceQualityStrategy;
    VMF_ADMODE_E      eAdMode;
    uint32_t          dwMinQp;
    uint32_t          dwMaxQp;
    uint32_t          dwMinFps;
    uint32_t          dwVirtIFrameInterval;
    uint32_t          dwPIQ;
} VMF_H4E_CONFIG_T;

/* H.265 encoder config — positional init: dwQp,dwBitrate,dwFps,dwGop,iSQS,dwMinQp,dwMaxQp,dwVirtI,dwPIQ,eAdMode,dwComplexMapCtrl */
typedef struct {
    uint32_t     dwQp;
    uint32_t     dwBitrate;
    uint32_t     dwFps;
    uint32_t     dwGop;
    int32_t      iSliceQualityStrategy;
    uint32_t     dwMinQp;
    uint32_t     dwMaxQp;
    uint32_t     dwVirtIFrameInterval;
    uint32_t     dwPIQ;
    VMF_ADMODE_E eAdMode;
    uint32_t     dwComplexMapCtrl;
} VMF_H5E_CONFIG_T;

/* MJPEG encoder config — positional init: dwQp,bEnableThumbnail,dwThumbnailQp,bJfifHdr,dwBitrate,dwFps */
typedef struct {
    uint32_t dwQp;
    uint32_t bEnableThumbnail;
    uint32_t dwThumbnailQp;
    uint32_t bJfifHdr;
    uint32_t dwBitrate;
    uint32_t dwFps;
} VMF_JE_CONFIG_T;

/* Video encoder config */
typedef struct {
    uint32_t              dwEncWidth;
    uint32_t              dwEncHeight;
    uint32_t              dwFps;
    uint32_t              bConnectIfp;
    VMF_VENC_CODEC_TYPE   eCodecType;
    void                 *pCodecConfig;
    void                 *pBind;
    VMF_SRC_CONNECT_FUNC  fnSrcConnectFunc;
    uint32_t              bKeepRatio;
    uint32_t              _pad[8];
} VMF_VENC_CONFIG_T;

VMF_VENC_HANDLE_T *VMF_VENC_Init(VMF_VENC_CONFIG_T *cfg);
void VMF_VENC_Release(VMF_VENC_HANDLE_T *h);
void VMF_VENC_ProduceStreamHdr(VMF_VENC_HANDLE_T *h);
int  VMF_VENC_Start(VMF_VENC_HANDLE_T *h);
int  VMF_VENC_Stop(VMF_VENC_HANDLE_T *h);
int  VMF_VENC_SetIntra(VMF_VENC_HANDLE_T *h);
int  VMF_VENC_Suspend(VMF_VENC_HANDLE_T *h);
int  VMF_VENC_Resume(VMF_VENC_HANDLE_T *h);

#endif /* VMF_VIDEO_ENCODER_H */
