#ifndef VMF_VIDEO_BIND_H
#define VMF_VIDEO_BIND_H

#include <stdint.h>

/* Opaque bind context */
typedef struct VMF_BIND_CONTEXT_S VMF_BIND_CONTEXT_T;
typedef struct VMF_VBIND_HANDLE_S VMF_VBIND_HANDLE_T;

/*
 * Source connection info — fields accessed by Custom_Roi_BIND_Request /
 * Custom_Main_BIND_Request in kdp2_host_stream.c
 */
typedef struct {
    uint32_t bConnectIfp;
    uint32_t bDisableSharedOsd;
    uint32_t bIsSsmShared;
    uint32_t bUnregister;
    uint32_t bUseResizedSrc;
    uint32_t dwCodecType;
    uint32_t dwDataType;
    uint32_t dwSrcWidth;
    uint32_t dwSrcHeight;
    uint32_t dwSrcYStride;
    uint32_t dwSrcUVStride;
    char     szSrcPin[64];
    uint32_t _pad[8];
} VMF_SRC_CONNECT_INFO_T;

/* Function pointer types */
typedef void (*VMF_SRC_CONNECT_FUNC)(VMF_SRC_CONNECT_INFO_T *info, uint32_t w, uint32_t h);
typedef void *(*VMF_BIND_QUERY_FUNC)(void *handle, uint32_t idx, void *info);
typedef int   (*VMF_BIND_CONFIG_ISP_FUNC)(void *handle, int stream, int layer, int isp, void *opt);

/* Bind init options */
typedef struct {
    uint32_t                  dwSrcOutputIndex;
    void                     *ptSrcHandle;
    VMF_BIND_QUERY_FUNC       pfnQueryFunc;
    VMF_BIND_CONFIG_ISP_FUNC  pfnIspFunc;
    uint32_t                  _pad[8];
} VMF_BIND_INITOPT_T;

VMF_BIND_CONTEXT_T *VMF_BIND_Init(VMF_BIND_INITOPT_T *opt);
void VMF_BIND_Release(VMF_BIND_CONTEXT_T *pBind);
int  VMF_BIND_Request(VMF_BIND_CONTEXT_T *bind, uint32_t w, uint32_t h, uint32_t stride, int mode, VMF_SRC_CONNECT_INFO_T *info);

int VMF_VBIND_Bind(void *src, void *dst);
int VMF_VBIND_Unbind(void *src, void *dst);

#endif /* VMF_VIDEO_BIND_H */
