/*----------------------------------------------------------------------------*
 * No Warranty                                                                *
 * Except as may be otherwise agreed to in writing, no warranties of any      *
 * kind, whether express or implied, are given by MTK with respect to any MTK *
 * Deliverables or any use thereof, and MTK Deliverables are provided on an   *
 * "AS IS" basis.  MTK hereby expressly disclaims all such warranties,        *
 * including any implied warranties of merchantability, non-infringement and  *
 * fitness for a particular purpose and any warranties arising out of course  *
 * of performance, course of dealing or usage of trade.  Parties further      *
 * acknowledge that Company may, either presently and/or in the future,       *
 * instruct MTK to assist it in the development and the implementation, in    *
 * accordance with Company's designs, of certain softwares relating to        *
 * Company's product(s) (the "Services").  Except as may be otherwise agreed  *
 * to in writing, no warranties of any kind, whether express or implied, are  *
 * given by MTK with respect to the Services provided, and the Services are   *
 * provided on an "AS IS" basis.  Company further acknowledges that the       *
 * Services may contain errors, that testing is important and Company is      *
 * solely responsible for fully testing the Services and/or derivatives       *
 * thereof before they are used, sublicensed or distributed.  Should there be *
 * any third party action brought against MTK, arising out of or relating to  *
 * the Services, Company agree to fully indemnify and hold MTK harmless.      *
 * If the parties mutually agree to enter into or continue a business         *
 * relationship or other arrangement, the terms and conditions set forth      *
 * hereunder shall remain effective and, unless explicitly stated otherwise,  *
 * shall prevail in the event of a conflict in the terms in any agreements    *
 * entered into between the parties.                                          *
 *---------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------
 * Copyright (c) 2005, MediaTek, Inc.
 * All rights reserved.
 *
 * Unauthorized use, practice, perform, copy, distribution, reproduction,
 * or disclosure of this information in whole or in part is prohibited.
 *-----------------------------------------------------------------------------
 * $RCSfile: u_mux_util.h,v $
 * $Revision: #2 $
 * $Date: 2015/07/28 $
 * $Author: huaxi.qiao $
 * $CCRevision: /main/DTV_X_HQ_int/5 $
 * $SWAuthor: Clear Case Administrator $
 * $MD5HEX: e5a2644d77eac094a5d2aa1496612a57 $
 *
 * Description:
 *         This contains Record Utility exported macros, definitons,
 *         and structures.
 *---------------------------------------------------------------------------*/

#ifndef _U_MUX_UTIL_H_
#define _U_MUX_UTIL_H_

/*-----------------------------------------------------------------------------
                    include files
-----------------------------------------------------------------------------*/
#include "u_common.h"
#include "u_handle.h"

/*-----------------------------------------------------------------------------
                    macros, defines, typedefs, enums
-----------------------------------------------------------------------------*/
/* Return Values */
#define MUX_UTILR_PENDING                   ( ( INT32 )  1 )
#define MUX_UTILR_OK                        ( ( INT32 )   0 )
#define MUX_UTILR_INV_ARG                   ( ( INT32 )  -1 )
#define MUX_UTILR_INV_HANDLE                ( ( INT32 )  -2 )
#define MUX_UTILR_INV_COND                  ( ( INT32 )  -3 )
#define MUX_UTILR_COMP_NOT_FOUND            ( ( INT32 )  -4 )
#define MUX_UTILR_DRV_COMP_ERROR            ( ( INT32 )  -5 )
#define MUX_UTILR_INTERNAL_ERROR            ( ( INT32 )  -6 )
#define MUX_UTILR_ASYNC_NFY                 ( ( INT32 )  -7 )
#define MUX_UTILR_ALREADY_INIT              ( ( INT32 )  -8 )
#define MUX_UTILR_CAN_NOT_OP_IN_THIS_STATE  ( ( INT32 )  -9 )
#define MUX_UTILR_NOT_ALLOW                 ( ( INT32 )  -10 )
#define MUX_UTILR_INSUFFICIENT_MEMORY       ( ( INT32 )  -11 )
#define MUX_UTILR_OUT_OF_HANDLES            ( ( INT32 )  -12 )
#define MUX_UTILR_DRV_CONN_FAILED           ( ( INT32 )  -13 )
#define MUX_UTILR_DRV_DISCONN_FAILED        ( ( INT32 )  -14 )
#define MUX_UTILR_NOT_SUPPORT               ( ( INT32 )  -15 )

/*Mux utility state*/
typedef UINT32 MUX_UTIL_COND_T;    /**<        */
#define MUX_UTIL_COND_IGNORE                ( ( MUX_UTIL_COND_T) 0 )    /**<        */
#define MUX_UTIL_COND_OPENING               ( ( MUX_UTIL_COND_T) 1 )    /**<        */
#define MUX_UTIL_COND_OPENED                ( ( MUX_UTIL_COND_T) 2 )    /**<        */
#define MUX_UTIL_COND_STARTING              ( ( MUX_UTIL_COND_T) 3 )    /**<        */
#define MUX_UTIL_COND_STARTED               ( ( MUX_UTIL_COND_T) 4 )    /**<        */
#define MUX_UTIL_COND_STOPPING              ( ( MUX_UTIL_COND_T) 5 )     /**<        */
#define MUX_UTIL_COND_CLOSING               ( ( MUX_UTIL_COND_T) 6 )    /**<        */
#define MUX_UTIL_COND_CLOSED                ( ( MUX_UTIL_COND_T) 7 )    /**<        */
#define MUX_UTIL_COND_ERROR                 ( ( MUX_UTIL_COND_T) 8 )    /**<        */
#define MUX_UTIL_COND_LAST_ENTRY            ( ( MUX_UTIL_COND_T) 128 )    /**<        */


/* Flags */
typedef UINT16                              MUX_UTIL_TYPE_FLAG_T;
#define MUX_UTIL_TYPE_FLAG_NONE            ( ( MUX_UTIL_TYPE_FLAG_T ) 0x0000 )
#define MUX_UTIL_TYPE_FLAG_VIDEO           ( ( MUX_UTIL_TYPE_FLAG_T ) ( 0x0001 << 0 ) )
#define MUX_UTIL_TYPE_FLAG_AUDIO           ( ( MUX_UTIL_TYPE_FLAG_T ) ( 0x0001 << 1 ) )
#define MUX_UTIL_TYPE_FLAG_VBI             ( ( MUX_UTIL_TYPE_FLAG_T ) ( 0x0001 << 2 ) )
#define MUX_UTIL_TYPE_FLAG_TABLE           ( ( MUX_UTIL_TYPE_FLAG_T ) ( 0x0001 << 3 ) )

/* Get Operations */
typedef UINT16                             MUX_UTIL_GET_TYPE_T;
#define MUX_UTIL_GET_TYPE_INIT_CTRL       ( ( MUX_UTIL_GET_TYPE_T ) 0 )
#define MUX_UTIL_GET_TYPE_DATA            ( ( MUX_UTIL_GET_TYPE_T ) 1 )      /* Get Buffer Data */
#define MUX_UTIL_GET_TYPE_BUF_STATUS      ( ( MUX_UTIL_GET_TYPE_T ) 2 )      /* Get Buffer Status */
#define MUX_UTIL_GET_TYPE_BUF_INFO        ( ( MUX_UTIL_GET_TYPE_T ) 3 )      /* Get Buffer INFO */
#define MUX_UTIL_GET_TYPE_AENC_SETTING    ( ( MUX_UTIL_GET_TYPE_T ) 4 )      /* by AUD_ENC_SETTINGS_T */
#define MUX_UTIL_GET_TYPE_VENC_SETTING    ( ( MUX_UTIL_GET_TYPE_T ) 5 )      /* by VID_ENC_SETTINGS_T */

/* Set Operations */
typedef UINT16                               MUX_UTIL_SET_TYPE_T;
#define MUX_UTIL_SET_TYPE_BUF_SETTING       ( ( MUX_UTIL_SET_TYPE_T ) 0 )      /* Config Buffer Setting */
#define MUX_UTIL_SET_TYPE_FLUSH_BUF         ( ( MUX_UTIL_SET_TYPE_T ) 1 )
#define MUX_UTIL_SET_TYPE_NFY_FCT           ( ( MUX_UTIL_SET_TYPE_T ) 2 )
#define MUX_UTIL_SET_TYPE_AENC_SETTING      ( ( MUX_UTIL_SET_TYPE_T ) 3 )      /* by AUD_ENC_SETTINGS_T */
#define MUX_UTIL_SET_TYPE_VENC_SETTING      ( ( MUX_UTIL_SET_TYPE_T ) 4 )      /* by VID_ENC_SETTINGS_T */
#define MUX_UTIL_SET_TYPE_VENC_SRC_PIPE     ( ( MUX_UTIL_SET_TYPE_T ) 5 )      /* by Source Pipe Handle */
#define MUX_UTIL_SET_TYPE_UNBLOCK_BUF_DATA  ( ( MUX_UTIL_SET_TYPE_T ) 6 )      /*  */
#define MUX_UTIL_SET_TYPE_START_STRM        ( ( MUX_UTIL_SET_TYPE_T ) 7 )      /*  */
#define MUX_UTIL_SET_TYPE_STOP_STRM         ( ( MUX_UTIL_SET_TYPE_T ) 8 )      /*  */


/* Notify Type to AP or 3rd */
typedef UINT8                               MUX_UTIL_NFY_TYPE_T;
#define MUX_UTIL_NFY_TYPE_BUF_ERROR         ( ( MUX_UTIL_NFY_TYPE_T ) 0 )
#define MUX_UTIL_NFY_TYPE_BUF_DATA          ( ( MUX_UTIL_NFY_TYPE_T ) 1 )
#define MUX_UTIL_NFY_TYPE_BUF_OVERFLOW      ( ( MUX_UTIL_NFY_TYPE_T ) 2 )
#define MUX_UTIL_NFY_TYPE_NFY_EVENT         ( ( MUX_UTIL_NFY_TYPE_T ) 3 )
#define MUX_UTIL_NFY_TYPE_NFY_RANGE         ( ( MUX_UTIL_NFY_TYPE_T ) 4 )
#define MUX_UTIL_NFY_TYPE_STRG_FULL         ( ( MUX_UTIL_NFY_TYPE_T ) 5 )



typedef UINT8                          MUX_UTIL_BUF_TYPE_T;
#define MUX_UTIL_DATA_TYPE_MTK              ( ( MUX_UTIL_BUF_TYPE_T )0 )
#define MUX_UTIL_DATA_TYPE_TS               ( ( MUX_UTIL_BUF_TYPE_T )1 )
#define MUX_UTIL_DATA_TYPE_TS_192           ( ( MUX_UTIL_BUF_TYPE_T )4 )
#define MUX_UTIL_DATA_TYPE_VIDEO_ES         ( ( MUX_UTIL_BUF_TYPE_T )2 ) /*ony mux video : set to muxer */
#define MUX_UTIL_DATA_TYPE_AUDIO_ES         ( ( MUX_UTIL_BUF_TYPE_T )3 ) /*only mux audio: set to muxer */
#define MUX_UTIL_SYNC_CLOSE       1
/*-----------------------------------------------------------------------------
                        Structures
-----------------------------------------------------------------------------*/

/* for MUX_UTIL_GET_TYPE_BUF_INFO : app need do mmp for its process*/
typedef struct _MUX_UTIL_BUF_INFO_T
{
    UINT8*   pui1_buf_ptr;
    SIZE_T   z_size;
} MUX_UTIL_BUF_INFO_T;

#pragma pack(4)
typedef struct _MUX_UTIL_BUF_INFO_EX_T
{
    UNION_POINTER_T pui1_buf_ptr;
    UINT32        z_size;
} MUX_UTIL_BUF_INFO_EX_T;
#pragma pack()

/* notify function:*/
typedef INT32 (*x_mux_util_nfy_fct)( VOID*               pv_tag,
                                         MUX_UTIL_NFY_TYPE_T t_nfy_type,
                                         VOID*               pv_nfy_info );

/* for MUX_UTIL_SET_TYPE_NFY_FCT:app need set data notify for its process */
typedef struct _MUX_UTIL_NFY_FCT_INFO_T
{
    VOID*               pv_tag;
    x_mux_util_nfy_fct  pfn_nfy;
} MUX_UTIL_NFY_FCT_INFO_T;


/*APP type: Note:should one-one mapping  to x_vid_enc.h  VID_AP_TYPE_T*/
typedef enum
{
    MUX_UTIL_AP_TYPE_SKYPE = 0,
    MUX_UTIL_AP_TYPE_ATVPVR,
    MUX_UTIL_AP_TYPE_MSI,     // multi-screen interaction,for mt5396
    MUX_UTIL_AP_TYPE_BGPVR,
    MUX_UTIL_AP_TYPE_TIMESHIFT
} MUX_UTIL_AP_TYPE_T;


/******************** Video  Encoder Setting *********************/
/*refer to VID_SRC_TYPE_T*/
typedef enum
{
    MUX_UTIL_VID_ENC_SRC_TYPE_VDEC = 0, /*For Internal skype*/
    MUX_UTIL_VID_ENC_SRC_TYPE_VDP,   /*for mt5396: support MSI, ATV PVR, ATV Backgorund PVR*/
} MUX_UTIL_VID_SRC_TYPE_T;

typedef enum
{
    MUX_UTIL_VID_ENC_FMT_H264 = 0
    /* Others */
} MUX_UTIL_VID_ENC_FMT_TYPE_T;

typedef enum
{
    /* H264 */
    MUX_UTIL_VID_ENC_H264_PROFILE_BASELINE = 0,
    MUX_UTIL_VID_ENC_H264_PROFILE_MAIN
    /* Others */
} MUX_UTIL_VID_ENC_PROFILE_T;

typedef enum
{
    /* H264 */
    MUX_UTIL_VID_ENC_H264_LEVEL_21 = 0,
    MUX_UTIL_VID_ENC_H264_LEVEL_30,
    MUX_UTIL_VID_ENC_H264_LEVEL_31,
    MUX_UTIL_VID_ENC_H264_LEVEL_41
    /* Others */
} MUX_UTIL_VID_ENC_LEVEL_T;

typedef struct _MUX_UTIL_VID_FRAME_RESOLUTION_T
{
    UINT32              ui4_width;      /* Resolution: Width */
    UINT32              ui4_height;     /* Resolution: Height */
} MUX_UTIL_VID_FRAME_RESOLUTION_T;

typedef struct _MUX_UTIL_VID_ENC_COMMON_INFO_T
{
    MUX_UTIL_VID_FRAME_RESOLUTION_T  t_resolution;   /*Resolution*/
    UINT32                           ui4_fps;        /* Frame Rate */
    UINT32                           ui4_bitrate;    /* Bitrate */
    UINT32                           ui4_QP;         /*Quantization Parameter*/
} MUX_UTIL_VID_ENC_COMMON_INFO_T;

typedef struct _MUX_UTIL_VID_ENC_H264_INFO_T
{
    MUX_UTIL_VID_ENC_COMMON_INFO_T  t_vid_enc_info;
    MUX_UTIL_VID_ENC_PROFILE_T      e_profile;
    MUX_UTIL_VID_ENC_LEVEL_T        e_level;
} MUX_UTIL_VID_ENC_H264_INFO_T;

/*for VID_ENC_FLD_TYPE_T*/
typedef enum
{
    MUX_UTIL_VID_ENC_FLD_NORMAL = 0,
    MUX_UTIL_VID_ENC_TOP_FLD,
    MUX_UTIL_VID_ENC_BOTTOM_FLD
} MUX_UTIL_VID_ENC_FLD_TYPE_T;

/* for VID_ENC_SET_TYPE_SETTINGS */
typedef struct _MUX_UTIL_VID_ENC_SETTINGS_T
{
    MUX_UTIL_VID_SRC_TYPE_T              e_src_type; /* Source Type */
    MUX_UTIL_VID_ENC_FMT_TYPE_T          e_enc_fmt;  /* Encode Format Type */
    MUX_UTIL_VID_ENC_FLD_TYPE_T          e_enc_fld_type;
    /* Encoding Setting according to e_enc_fmt */
    union
    {
        MUX_UTIL_VID_ENC_H264_INFO_T     t_fmt_h264;
    }u_fmt;
} MUX_UTIL_VID_ENC_SETTINGS_T;


/******************** Audio Encoder Setting *********************/
typedef enum
{
    MUX_UTIL_AUD_ENC_SRC_TYPE_MAIN = 0,
    MUX_UTIL_AUD_ENC_SRC_TYPE_AUX,
    MUX_UTIL_AUD_ENC_SRC_TYPE_THIRD
} MUX_UTIL_AUD_SRC_TYPE_T;

typedef enum
{
    MUX_UTIL_AUD_ENC_POS_MODE_OFF = 0,
    MUX_UTIL_AUD_ENC_POS_MODE_INPUT_BEFORE_POST_PROCESSING,
    MUX_UTIL_AUD_ENC_POS_MODE_INPUT_AFTER_POST_PROCESSING,
    MUX_UTIL_AUD_ENC_POS_MODE_NUM
}   MUX_UTIL_AUD_ENC_POS_MODE_T;

typedef enum
{
    MUX_UTIL_AUD_ENC_CH_MONO        =   1,
    MUX_UTIL_AUD_ENC_CH_STEREO,
    MUX_UTIL_AUD_ENC_CH_SURROUND_2CH,
    MUX_UTIL_AUD_ENC_CH_SURROUND,
    MUX_UTIL_AUD_ENC_CH_3_0,
    MUX_UTIL_AUD_ENC_CH_4_0,
    MUX_UTIL_AUD_ENC_CH_5_0,
    MUX_UTIL_AUD_ENC_CH_5_1,
    MUX_UTIL_AUD_ENC_CH_7_1
} MUX_UTIL_AUD_ENC_CH_NUM_T;

/* Sample frequency. */
typedef enum
{
    MUX_UTIL_AUD_ENC_SAMPLE_RATE_8K   =   1,
    MUX_UTIL_AUD_ENC_SAMPLE_RATE_11K,
    MUX_UTIL_AUD_ENC_SAMPLE_RATE_11_025K,
    MUX_UTIL_AUD_ENC_SAMPLE_RATE_12K,
    MUX_UTIL_AUD_ENC_SAMPLE_RATE_16K,
    MUX_UTIL_AUD_ENC_SAMPLE_RATE_22K,
    MUX_UTIL_AUD_ENC_SAMPLE_RATE_22_050K,
    MUX_UTIL_AUD_ENC_SAMPLE_RATE_24K,

    MUX_UTIL_AUD_ENC_SAMPLE_RATE_32K,
    MUX_UTIL_AUD_ENC_SAMPLE_RATE_44K,
    MUX_UTIL_AUD_ENC_SAMPLE_RATE_44_100K,
    MUX_UTIL_AUD_ENC_SAMPLE_RATE_48K,
    MUX_UTIL_AUD_ENC_SAMPLE_RATE_96K,
    MUX_UTIL_AUD_ENC_SAMPLE_RATE_192K
}MUX_UTIL_AUD_ENC_SAMPLE_RATE_T;

/* Sample bits. */
typedef enum
{
    MUX_UTIL_AUD_ENC_PCM_BIT_DEPTH_8   =   1,
    MUX_UTIL_AUD_ENC_PCM_BIT_DEPTH_16,
    MUX_UTIL_AUD_ENC_PCM_BIT_DEPTH_18,
    MUX_UTIL_AUD_ENC_PCM_BIT_DEPTH_20,
    MUX_UTIL_AUD_ENC_PCM_BIT_DEPTH_24
} MUX_UTIL_AUD_ENC_PCM_BIT_DEPTH_T;


typedef enum
{
    MUX_UTIL_AUD_ENC_PCM_TYPE_NORMAL        =   1,
    MUX_UTIL_AUD_ENC_PCM_TYPE_MS_ADPCM,
    MUX_UTIL_AUD_ENC_PCM_TYPE_IMA_ADPCM
} MUX_UTIL_AUD_ENC_PCM_TYPE_T;


typedef enum
{
    MUX_UTIL_AUD_ENC_FMT_TYPE_UNKNOWN = 0,       /* Unknown Audio Codec Type*/
    MUX_UTIL_AUD_ENC_FMT_TYPE_MPEG,              /* MPEG1 or MPEG2 audio, layer I or layer II*/
    MUX_UTIL_AUD_ENC_FMT_TYPE_MP3,               /* MPEG1 or MPEG2 audio, layer III*/
    MUX_UTIL_AUD_ENC_FMT_TYPE_AAC,               /* AAC, or HE-AAC*/
    MUX_UTIL_AUD_ENC_FMT_TYPE_DD,                /* Dolby Digital, or Dolby Digital Plus*/
    MUX_UTIL_AUD_ENC_FMT_TYPE_TRUEHD,            /* Dolby TrueHD*/
    MUX_UTIL_AUD_ENC_FMT_TYPE_PCM,               /* PCM*/
    MUX_UTIL_AUD_ENC_FMT_TYPE_DTS,               /* DTS*/
    MUX_UTIL_AUD_ENC_FMT_TYPE_DTS_HD_HR,         /* DTS-HD High Resolution*/
    MUX_UTIL_AUD_ENC_FMT_TYPE_DTS_HD_MA,         /* DTS-HD Master Audio*/
    MUX_UTIL_AUD_ENC_FMT_TYPE_WMA,               /* WMA standard; not WMA Pro nor WMA Lossless*/
    MUX_UTIL_AUD_ENC_FMT_TYPE_COOK,              /* Cook*/
    MUX_UTIL_AUD_ENC_FMT_TYPE_VORBIS,            /* Vorbis*/
    MUX_UTIL_AUD_ENC_FMT_TYPE_FLAC,              /* Free Lossless Audio Codec*/
    MUX_UTIL_AUD_ENC_FMT_TYPE_MONKEY             /* Monkey's Audio*/
} MUX_UTIL_AUD_ENC_FMT_TYPE_T;

typedef struct
{
    MUX_UTIL_AUD_ENC_PCM_TYPE_T       e_pcm_type;           /* PCM type*/
    MUX_UTIL_AUD_ENC_CH_NUM_T         e_num_nh;             /* Channels*/
    MUX_UTIL_AUD_ENC_SAMPLE_RATE_T    e_sample_rate;        /* Sampling Frequence*/
    UINT16                            u2_block_align;       /* BLock Alignment*/
    MUX_UTIL_AUD_ENC_PCM_BIT_DEPTH_T  e_bits_per_sample;    /* Bits per Sample*/
    BOOL                              b_big_endian;         /* Big Endian PCM*/
} MUX_UTIL_AUD_ENC_PCM_INFO_T;

typedef struct
{
    MUX_UTIL_AUD_ENC_CH_NUM_T           e_num_nh;             /* Channels*/
    MUX_UTIL_AUD_ENC_PCM_BIT_DEPTH_T    e_sample_bits;
    MUX_UTIL_AUD_ENC_SAMPLE_RATE_T      e_samle_freq;
} MUX_UTIL_AUD_ENC_MP3_INFO_T;


/* for VID_ENC_SET_TYPE_SETTINGS */
typedef struct _MUX_UTIL_AUD_ENC_SETTINGS_T
{
    MUX_UTIL_AUD_SRC_TYPE_T              e_src_type; /* Source Type */
    MUX_UTIL_AUD_ENC_FMT_TYPE_T          e_enc_fmt;  /* Encode Format Type */
    MUX_UTIL_AUD_ENC_POS_MODE_T          e_pos_mode; /* position sequence*/
    /* Encoding Setting according to e_enc_fmt */
    union
    {
        MUX_UTIL_AUD_ENC_PCM_INFO_T     t_fmt_pcm;
        MUX_UTIL_AUD_ENC_MP3_INFO_T     t_fmt_mp3;
    }u_fmt;
} MUX_UTIL_AUD_ENC_SETTINGS_T;

/******************** table Encoder Setting *********************/
typedef enum
{
    MUX_UTIL_TBL_ENC_SRC_TYPE_UNKNOWN = 0,
    MUX_UTIL_TBL_ENC_SRC_TYPE_TURNER,
    MUX_UTIL_TBL_ENC_SRC_TYPE_MULTIMEDIA,
    MUX_UTIL_TBL_ENC_SRC_TYPE_TIMESHIFT,//dtv timeshift
    MUX_UTIL_TBL_ENC_SRC_TYPE_PVR
} MUX_UTIL_TBL_SRC_TYPE_T;

typedef enum _MUX_NFY_TBL_TYPE_T
{
    MUX_NFY_TBL_TYPE_UNKOWN = 0,
    MUX_NFY_TBL_TYPE_EIT_P
} MUX_NFY_TBL_TYPE_T;

typedef struct _MUX_UTIL_TBL_ENC_TURNER_INFO_T
{
    UINT16      ui2_table_id_ext;
}MUX_UTIL_TBL_ENC_TURNER_INFO_T;

typedef struct _MUX_UTIL_TBL_ENC_MULTIMEDIA_INFO_T
{

}MUX_UTIL_TBL_ENC_MULTIMEDIA_INFO_T;

typedef struct _MUX_UTIL_TBL_ENC_TIMESHIFT_INFO_T
{

}MUX_UTIL_TBL_ENC_TIMESHIFT_INFO_T;

typedef struct _MUX_UTIL_TBL_ENC_PVR_INFO_T
{

}MUX_UTIL_TBL_ENC_PVR_INFO_T;

/* for VID_ENC_SET_TYPE_SETTINGS */
typedef struct _MUX_UTIL_TBL_ENC_SETTINGS_T
{
    MUX_UTIL_TBL_SRC_TYPE_T e_tbl_src_type; /* Source Type */
    MUX_NFY_TBL_TYPE_T      e_tbl_enc_table;

    union
    {
        MUX_UTIL_TBL_ENC_TURNER_INFO_T      t_turner_info;
        MUX_UTIL_TBL_ENC_MULTIMEDIA_INFO_T  t_multimedia_info;
        MUX_UTIL_TBL_ENC_TIMESHIFT_INFO_T   t_timeshift_info;
        MUX_UTIL_TBL_ENC_PVR_INFO_T         t_pvr_info;
    }u_tbl_enc;
}MUX_UTIL_TBL_ENC_SETTINGS_T;

typedef enum _MUX_UTIL_TYPE
{
    MUX_UTIL_TYPE_VID,
    MUX_UTIL_TYPE_AUD,
    MUX_UTIL_TYPE_VBI,
    MUX_UTIL_TYPE_AV,

}MUX_UTIL_TYPE;

typedef enum _MUX_UTIL_STRM_TYPE
{
    MUX_UTIL_STRM_TYPE_VID,
    MUX_UTIL_STRM_TYPE_AUD,
    MUX_UTIL_STRM_TYPE_VBI,
    MUX_UTIL_STRM_TYPE_TBL
}MUX_UTIL_STRM_TYPE;

#pragma pack(4)
typedef struct _MUX_UTIL_NFY_FCT_INFO_EX_T
{
    UNION_POINTER_T               pv_tag;
    UNION_POINTER_T               pfn_nfy;
} MUX_UTIL_NFY_FCT_INFO_EX_T;

typedef struct _MUX_UTIL_PARAM_EX_T
{
    MUX_UTIL_NFY_FCT_INFO_EX_T     t_nfy_info;

    MUX_UTIL_TYPE_FLAG_T        t_mux_flags;
    MUX_UTIL_AP_TYPE_T          t_app;              /*which application use mux_util*/
    MUX_UTIL_TYPE               t_mux_type;         /*which stream will be muxed*/
    MUX_UTIL_BUF_TYPE_T         t_type;             /*which format will be muxed*/
    UINT32                      ui4_ms_tick_period;  /* tick period in milli-seconds */

    HANDLE_T                    h_vid_sess;          /*session handle:attach to which session*/
    HANDLE_T                    h_aud_sess;          /*session handle:attach to which session*/
    HANDLE_T                    h_vid_source;        /*soure handle*/
    HANDLE_T                    h_aud_source;        /*soure handle*/

    BOOL                         b_use_ostg;       /*video source: This is only support on Python and later*/
    BOOL                         b_encode_osd;       /*If encode OSD, This is only support on Python and later*/
    BOOL                         b_constant_quality; /*video encoder constant quality mode*/

    MUX_UTIL_VID_ENC_SETTINGS_T t_vid_enc_setting;  /*video encodere setting*/
    MUX_UTIL_AUD_ENC_SETTINGS_T t_aud_enc_setting;  /*audio encodere setting*/
    MUX_UTIL_TBL_ENC_SETTINGS_T t_tbl_enc_setting;  /*ts table encodere setting*/
} MUX_UTIL_PARAM_EX_T;
#pragma pack()

/*mux_util instance cfg*/
typedef struct _MUX_UTIL_PARAM_T
{
    MUX_UTIL_NFY_FCT_INFO_T     t_nfy_info;

    MUX_UTIL_TYPE_FLAG_T        t_mux_flags;
    MUX_UTIL_AP_TYPE_T          t_app;              /*which application use mux_util*/
    MUX_UTIL_TYPE               t_mux_type;         /*which stream will be muxed*/
    MUX_UTIL_BUF_TYPE_T         t_type;             /*which format will be muxed*/
    UINT32                      ui4_ms_tick_period;  /* tick period in milli-seconds */

    HANDLE_T                    h_vid_sess;          /*session handle:attach to which session*/
    HANDLE_T                    h_aud_sess;          /*session handle:attach to which session*/
    HANDLE_T                    h_vid_source;        /*soure handle*/
    HANDLE_T                    h_aud_source;        /*soure handle*/

    BOOL                         b_use_ostg;       /*video source: This is only support on Python and later*/
    BOOL                         b_encode_osd;       /*If encode OSD, This is only support on Python and later*/
    BOOL                         b_constant_quality; /*video encoder constant quality mode*/

    MUX_UTIL_VID_ENC_SETTINGS_T t_vid_enc_setting;  /*video encodere setting*/
    MUX_UTIL_AUD_ENC_SETTINGS_T t_aud_enc_setting;  /*audio encodere setting*/
    MUX_UTIL_TBL_ENC_SETTINGS_T t_tbl_enc_setting;  /*ts table encodere setting*/
} MUX_UTIL_PARAM_T;



/*********************system config************************/
#define  MUX_UTIL_INSTANCE_MAX_CNT      ( 3 )
typedef struct _MUX_UTIL_BUF_CFG
{
    SIZE_T                z_buf_size;
    MUX_UTIL_TYPE        e_mu_type;
}MUX_UTIL_BUF_CFG;
/* system init config for record util */
typedef struct _MUX_UTIL_SYS_CONFIG_T
{
    UINT32                          ui4_mux_instance_cnt; /*max cocurrent mux_util instance*/
    MUX_UTIL_BUF_CFG                az_buf_size[MUX_UTIL_INSTANCE_MAX_CNT];
} MUX_UTIL_SYS_CONFIG_T;



/*********************data notify  and unlock************************/
typedef struct _MUX_UTIL_TICK_T
{
    UINT8*          pui1_buf_phy;   /* kernel space address */
    SIZE_T          t_size;
    UINT64          ui8_pts;
    UINT32          ui4_flag;
} MUX_UTIL_TICK_T;

#pragma pack(4)
typedef struct _MUX_UTIL_UNLOCK_INFO_EX_T
{
    UNION_POINTER_T pui1_data_addr;
    UINT32      z_data_len;
} MUX_UTIL_UNLOCK_INFO_EX_T;
#pragma pack()

typedef struct _MUX_UTIL_UNLOCK_INFO_T
{
    UINT8*      pui1_data_addr;
    SIZE_T      z_data_len;
} MUX_UTIL_UNLOCK_INFO_T;

typedef struct _MUX_UTIL_COND_EVENT_NFY
{
    MUX_UTIL_COND_T      e_cond;
    UINT32               ui4_data;
} MUX_UTIL_COND_EVENT_NFY;

typedef struct _MUX_UTIL_STRM_INFO_T
{
    MUX_UTIL_STRM_TYPE    e_strm_type;
    HANDLE_T              h_sess;          /*session handle:attach to which session, skype need it */
    HANDLE_T              h_source;        /*soure handle, skype need it */
    union
    {
        MUX_UTIL_VID_ENC_SETTINGS_T t_vid_enc_setting;    /*video encodere setting*/
        MUX_UTIL_AUD_ENC_SETTINGS_T t_aud_enc_setting;    /*audio encodere setting*/
    } u;
} MUX_UTIL_STRM_INFO_T;

typedef enum
{
    MUX_UTIL_REC_GET_UNKNOWN = 0,
    MUX_UTIL_REC_GET_TICK_NUMBER,
    MUX_UTIL_REC_GET_REC_COND,
    MUX_UTIL_REC_GET_STRM_INFO,
    MUX_UTIL_REC_GET_TICK_TBL,
    MUX_UTIL_REC_GET_TICK_INDEX,
    MUX_UTIL_REC_GET_FILE_SIZE
}MUX_UTIL_REC_GET_TYPE;


typedef enum
{
    MUX_UTIL_REC_SET_UNKNOWN = 0,
}MUX_UTIL_REC_SET_TYPE;

typedef struct _MUX_UTIL_REC_STRM_INFO
{
    CHAR*                               pc_rec_path;

    MUX_UTIL_VID_ENC_FMT_TYPE_T         t_vid_enc;
    MUX_UTIL_AUD_ENC_FMT_TYPE_T         t_aud_enc;

    MPEG_2_PID_T                        t_v_pid;
    MPEG_2_PID_T                        t_a_pid;

    MPEG_2_PID_T                        t_pcr_pid;

}MUX_UTIL_REC_STRM_INFO;

typedef struct _MUX_UTIL_REC_CONFIG_T
{
    MUX_UTIL_TYPE_FLAG_T        t_mux_flags;
    MUX_UTIL_NFY_FCT_INFO_T     t_nfy_info;
    UINT32                      ui4_ms_tick_period;  /* tick period in milli-seconds */
    MUX_UTIL_AP_TYPE_T          t_app;
    MUX_UTIL_TYPE               t_mux_type;
    MUX_UTIL_BUF_TYPE_T         t_type;             /*which format will be muxed*/

    HANDLE_T                    h_vid_dec_comp;      /*soure handle*/
    HANDLE_T                    h_aud_dec_comp;      /*soure handle*/

    HANDLE_T                    h_vid_sess;      /*soure session  handle*/
    HANDLE_T                    h_aud_sess;      /*soure session handle*/

    CHAR*                       ps_rec_path;
    UINT64                      ui8_init_fs_pos;
    UINT32                      ui4_max_rec_sec;   /*second*/

    BOOL                        b_use_ostg;          /*MSI video source: This is only support on Python and later*/
    BOOL                        b_encode_osd;        /*MSI encode OSD, This is only support on Python and later*/

    MUX_UTIL_VID_ENC_SETTINGS_T t_vid_enc_setting;
    MUX_UTIL_AUD_ENC_SETTINGS_T t_aud_enc_setting;  /*audio encodere setting*/

} MUX_UTIL_REC_CONFIG_T;

typedef struct _MUX_UTIL_REC_OBSVR_CONFIG_T
{
    UINT32                      ui4_rec_idx;

    MUX_UTIL_NFY_FCT_INFO_T     t_nfy_info;
} MUX_UTIL_REC_OBSVR_CONFIG_T;

typedef struct _MUX_UTIL_REC_TICK_INDEX
{
    UINT32                      ui4_tick_index;
    UINT32                      ui4_tick_number;
}MUX_UTIL_REC_TICK_INFO;

typedef enum
{
    MUX_UTIL_OBSVR_GET_UNKNOWN = 0,
    MUX_UTIL_OBSVR_GET_REC_COND,
    MUX_UTIL_OBSVR_GET_REC_STRM_INFO,
    MUX_UTIL_OBSVR_GET_REC_TICK_TBL,
    MUX_UTIL_OBSVR_GET_REC_TICK_INDEX
}MUX_UTIL_OBSVR_GET_TYPE;

typedef enum
{
    MUX_UTIL_OBSVR_SET_UNKNOWN = 0,
}MUX_UTIL_OBSVR_SET_TYPE;

#endif /*end of _U_MUX_UTIL_H_ */


