/*
* 版权所有：深圳市朗驰数字技术有限公司
* 作    者：HongJun Chen
* 设计日期: 2003-11-15
* $Id: eti_base_def.h,v 1.1.1.1 2006/06/29 12:41:28 administrator Exp $
*/
#ifndef __ETI_BASE_DEF_H__
#define __ETI_BASE_DEF_H__

#define ETI_MAX_CH_PERDSP		2
#define ETI_QCIF_CHANNELS       2

#define ETI_MAX_SUPPORTCH		16	//所有产品中支持的最大通道
#define APP_PASSWORD_LENGTH		20  //所有密码字符长度
#define APP_PTZ_STRING_LEN		60  //云台控制方法字符串长度
#define APP_TIMECHECK_LISTNUM	7	//报警、自动录象检测时间列表个数
#define APP_ZTE_TIMECHECK_LISTNUM 32//ZTE 移动侦测/输入报警时间个数
#define APP_ADDRLIST_NUM		20	//
#define APP_DECLOOP_ITEMNUM		100
#define APP_PPPOE_STRING_SIZE	20
#define APP_PHONE_NUMBER_SIZE	20
#define APP_PPPOE_STRING_SIZE	20
#define APP_PHONE_NUMBER_SIZE	20

#define APP_TITALSTRING_COUNT	4
#define APP_ALARMNAMELENGTH     32

#define ETI_CHAR_816LIB_SIZE	4096	//8*16 ANSC字库大小
#define ETI_HANZI_1616LIB_SIZE	261696  //16*16 汉字库大小

#define ETI_MP4_STREAM_AV		0       //音、视复合数据流
#define ETI_MP4_STREAM_V		1		//视频数据流

#define ETI_MP4_BITCTRL_VBR		1       //视频码率定质量控制
#define ETI_MP4_BITCTRL_CBR		0       //视频码率定码率控制

#define ETI_MP4_QUANTIZER_MIN	2       //视频最小量化系数
#define ETI_MP4_QUANTIZER_MAX	31      //视频最大量化系数

#define ETI_MP4_BITRATE_MIN		32		//视频最小码率 32K
#define ETI_MP4_BITRATE_MAX		4000	//视频最大码率 4M

#define ETI_MP4_KEYINTERVAL_MIN	12		//最小关键帧间隔
#define ETI_MP4_KEYINTERVAL_MAX	200		//最大关键帧间隔

#define ETI_AUDIO_ENCTYPE_MP3	0x55	//MP3
#define ETI_AUDIO_ENCTYPE_G722	0XFE	//G.722
#define ETI_AUDIO_ENCTYPE_G711A 0x13    //G.711A
#define ETI_AUDIO_ENCTYPE_G711U 0x14    //G.711U
#define ETI_AUDIO_ENCTYPE_G726  0x15    //G.726
#define ETI_AUDIO_ENCTYPE_AAC   0x16    //AAC
#define ETI_AUDIO_ENCTYPE_AMR   0x17    //AMR
#define ETI_AUDIO_ENCTYPE_PCM   0x18    //PCM

enum{
	ETI_VIDEOTAG_MPEG4 = 0X58564944,	//DIVX
	ETI_VIDEOTAG_H264  = 0X34363248,    //(('4'<<24) | ('6'<<16) | ('2'<<8) |'H')				//H264
	ETI_VIDEOTAG_MJPEG = 0X47504A4D     //(('G'<<24) | ('P'<<16) | ('J'<<8) |'M')				//MJPG
};

#define ETI_AUDIO_SAMPLE_RATE_48K		48000
#define ETI_AUDIO_SAMPLE_RATE_44K		44100
#define ETI_AUDIO_SAMPLE_RATE_32K		32000
#define ETI_AUDIO_SAMPLE_RATE_24K		24000
#define ETI_AUDIO_SAMPLE_RATE_22K		22050
#define ETI_AUDIO_SAMPLE_RATE_16K		16000
#define ETI_AUDIO_SAMPLE_RATE_8K		8000

#define ETI_STREAM_STATUS_START			0X00000001	//启动码流
#define ETI_STREAM_STATUS_STOP			0X00000002	//停止码流
#define ETI_STREAM_STATUS_RECV			0X00000004	//发送码流
#define ETI_STREAM_STATUS_FTPBACK		0X00000008	//FTP备份

#define ETI_ALARM_STATUS_MOTION			0X00000001	//视频移动报警
#define ETI_ALARM_STATUS_LOSTVI			0X00000002	//视频丢失报警
#define ETI_ALARM_STATUS_LOSTAI			0X00000004	//音频丢失报警
/********************** 缓冲大小***************************/
#define ETI_PREREC_BUFF_SIZE_CIF		0XA2800			//650*1024
#define ETI_PREREC_BUFF_SIZE_2CIF		0XE6000			//920*1024
#define ETI_PREREC_BUFF_SIZE_4CIF		0X14CCC0        //1024*1024*1.3(32的倍数)
/********************** 报警时间定义 ********************************/
#define ETI_ALARM_MIN_RECTIME			30			//最小报警持续(录象/备份)时间(s)
#define ETI_ALARM_MAX_RECTIME			3600		//最小报警持续(录象/备份)时间(s)
/********************** 视频格式定义 ********************************/

#define ETI_MP4_FORMAT_QCIF         0
#define ETI_MP4_FORMAT_CIF          1
#define ETI_MP4_FORMAT_2CIF         2
#define ETI_MP4_FORMAT_4CIF         3
#define ETI_MP4_FORMAT_DCIF         4
#define ETI_MP4_FORMAT_QVGA         5      //320*240
#define ETI_MP4_FORMAT_VGA_60HZ     6      //640*480
#define ETI_MP4_FORMAT_SVGA_60HZ    7      //800*600
#define ETI_MP4_FORMAT_XGA_60HZ     8      //1024*768
#define ETI_MP4_FORMAT_SXGA_60HZ    9      //1280*1024
#define ETI_MP4_FORMAT_UXGA_60HZ    10     //1600*1200
#define ETI_MP4_FORMAT_720P         11     //1280*720, no use
#define ETI_MP4_FORMAT_HDTV         12     //1920*1080, no use
#define ETI_MP4_FORMAT_SVGA_75HZ    13     //800*600
#define ETI_MP4_FORMAT_XGA_75HZ     14     //1024*768
#define ETI_MP4_FORMAT_720P_50HZ    15     //1280*720, 50HZ
#define ETI_MP4_FORMAT_720P_60HZ    16     //1280*720, 60HZ
#define ETI_MP4_FORMAT_1080P_50HZ   17     //1920*1080, 50HZ
#define ETI_MP4_FORMAT_1080P_60HZ   18     //1920*1080, 60HZ
#define ETI_MP4_FORMAT_LTF			19     //240*192
#define ETI_MP4_FORMAT_WQVGA1       20     //480*352
#define ETI_MP4_FORMAT_WQVGA2       21     //480*272
#define ETI_MP4_FORMAT_UVGA_50HZ    22     //1280*960,50HZ
#define ETI_MP4_FORMAT_UVGA_60HZ    23     //1280*960,60Hz
#define ETI_MP4_FORMAT_1080P_30HZ   24     //1920*1080, 30HZ
#define ETI_MP4_FORMAT_1080I_50HZ   25     //1920*1080, 50HZ
#define ETI_MP4_FORMAT_1080I_60HZ   26     //1920*1080, 60HZ
#define ETI_MP4_FORMAT_SXGA_75HZ    27     //1280*1024, 75HZ
#define ETI_MP4_FORMAT_WXGA_60HZ    28     //1280*800, 60HZ
#define ETI_MP4_FORMAT_WXGA_75HZ    29     //1280*800, 75HZ
#define ETI_MP4_FORMAT_SXGAP_60HZ   30     //1400*1050, 60HZ  SXGA+
#define ETI_MP4_FORMAT_SXGAP_75HZ   31     //1400*1050, 75HZ  SXGA+
#define ETI_MP4_FORMAT_WXGAP_60HZ   32     //1440*900, 60HZ  WXGA+
#define ETI_MP4_FORMAT_WSXGAP_60HZ  33     //1680*1050, 60HZ WSXGA+
#define ETI_MP4_FORMAT_WSUVGAP_60HZ 34     //1920*1080, 60HZ WSUVGA+


/********************** 视频支持格式定义 ****************************/
#define ETI_FORMAT_SUPPORT_QCIF     0X00000001
#define ETI_FORMAT_SUPPORT_CIF		0X00000002
#define ETI_FORMAT_SUPPORT_2CIF		0X00000004
#define ETI_FORMAT_SUPPORT_4CIF		0X00000008
#define ETI_FORMAT_SUPPORT_8CIF		0X00000010

#define ETI_FORMAT_VI_NTSC 0
#define ETI_FORMAT_VI_PAL  1

/************************OSD透明模式******************************/
enum{
	ETI_OSD_MODE_TRANSPARENT = 0,  //透明
	ETI_OSD_MODE_TRANSLUCENT,      //半透明
	ETI_OSD_MODE_OPAQUE            //不透明
};

/********************** 宽带接入类型 ********************************/
#define ETI_ROUTEDEV_ADSL	0	//ADSL
#define ETI_ROUTEDEV_WBN	1	//长城宽带
/********************** 视频尺寸定义 ********************************/
#define ETI_MAX_422_STIDE			1440

#define ETI_MAX_IMAGE_WIDTH			704
#define ETI_MAX_IMAGE_HEIGHT_PAL	576
#define ETI_MAX_IMAGE_HEIGHT_NTSC	480

#define ETI_IMAGE_WIDTH_QCIF		176
#define ETI_IMAGE_WIDTH_CIF         352
#define ETI_IMAGE_WIDTH_2CIF		ETI_MAX_IMAGE_WIDTH
#define ETI_IMAGE_WIDTH_DCIF		528
#define ETI_IMAGE_WIDTH_4CIF		ETI_MAX_IMAGE_WIDTH

#define ETI_IMAGE_HEIGHT_QCIF_PAL	144
#define ETI_IMAGE_HEIGHT_QCIF_NTSC	120
#define ETI_IMAGE_HEIGHT_CIF_PAL    288
#define ETI_IMAGE_HEIGHT_CIF_NTSC   240
#define ETI_IMAGE_HEIGHT_2CIF_PAL   ETI_IMAGE_HEIGHT_CIF_PAL
#define ETI_IMAGE_HEIGHT_2CIF_NTSC	ETI_IMAGE_HEIGHT_CIF_NTSC
#define ETI_IMAGE_HEIGHT_DCIF_PAL   384
#define ETI_IMAGE_HEIGHT_DCIF_NTSC	320
#define ETI_IMAGE_HEIGHT_4CIF_PAL   ETI_MAX_IMAGE_HEIGHT_PAL
#define ETI_IMAGE_HEIGHT_4CIF_NTSC  ETI_MAX_IMAGE_HEIGHT_NTSC

#define ETI_MAX_IMAGE_WIDTH_QVGA	320
#define ETI_MAX_IMAGE_HEIGHT_QVGA	240
#define ETI_MAX_IMAGE_WIDTH_VGA	    640
#define ETI_MAX_IMAGE_HEIGHT_VGA	480
#define ETI_MAX_IMAGE_WIDTH_SVGA	800
#define ETI_MAX_IMAGE_HEIGHT_SVGA	600
#define ETI_MAX_IMAGE_WIDTH_XGA     1024
#define ETI_MAX_IMAGE_HEIGHT_XGA	768
#define ETI_MAX_IMAGE_WIDTH_SXGA	1280
#define ETI_MAX_IMAGE_HEIGHT_SXGA	1024
#define ETI_MAX_IMAGE_WIDTH_UXGA	1600
#define ETI_MAX_IMAGE_HEIGHT_UXGA	1200

#define ETI_MAX_IMAGE_WIDTH_720P	1280
#define ETI_MAX_IMAGE_HEIGHT_720P	720
#define ETI_MAX_IMAGE_WIDTH_HDTV	1920
#define ETI_MAX_IMAGE_HEIGHT_HDTV	1080

/*************************最大视频帧大小**************************/
#define ETI_MAX_IMAGE_FRAMESIZE		(1024*1024)	//最大视频帧大小1MB
/*************************最大音频码率****************************/
#define ETI_MAX_AUDIO_BITRATE		64			//最大音频码率64Kb
/****************通道最大图象屏蔽块数*****************/
#define ETI_MAX_COVER_REGION 4
/******************最大图象屏蔽尺寸*******************/
#define ETI_VIDEOMASK_MAXWIDTH		352
#define ETI_VIDEOMASK_MAXHEGITH		288
/*****************************************************/
#define ETI_USER_OPERIAL		10	//操作员个数
#define ETI_DVR_USER_OPERIAL    32	//操作员个数
#define ETI_GROUP_MAXNUM        8   //8个组
/********************** 用户权限定义 ********************************/
#define ETI_USER_RIGHT_ADLOG	0		//登陆用户
#define ETI_USER_RIGHT_ADMIN	1		//管理员权限
#define ETI_USER_RIGHT_HIOPER	2		//高级操作员
#define ETI_USER_RIGHT_OPERIAL	3		//操作员

#define ETI_RIGHT_LOCALPLAY     1<<0        //本地回放
#define ETI_RIGHT_NETPLAY       1<<1        //远程回放
#define ETI_RIGHT_NETVIEW       1<<2        //远程预览
#define ETI_RIGHT_NETTALK       1<<3        //对讲
#define ETI_RIGHT_LOCALPTZ      1<<4        //本地云台控制
#define ETI_RIGHT_NETPTZ        1<<5        //远程云台控制
#define ETI_RIGHT_HANDRECORD    1<<6        //手动录象
#define ETI_RIGHT_BKFILE        1<<7        //录象文件备份
#define ETI_RIGHT_LOGMANAGE     1<<8        //日志管理
#define ETI_RIGHT_PARAMSET      1<<9       //系统参数设置
#define ETI_RIGHT_UPDATE        1<<10       //升级系统
#define ETI_RIGHT_SHUTDOWN      1<<11       //关闭设备
#define ETI_RIGHT_USERMANAGE    1<<12       //用户帐号管理
#define ETI_RIGHT_ALL           0xFFFFFFFF  //所有权限

typedef enum
{
    ETI_NETVIEW_GROUP = 0,                    //预览组
    ETI_OPERATOR_GROUP,                       //普通操作员组
    ETI_ADVANCE_OPERATOR_GROUP,               //高级操作员组
    ETI_ADMIN_GROUP                           //管理员组
}ETI_RIGHT_GROUP;

/**************************权限信息结构****************************/
typedef struct
{
    unsigned int      m_right;                //按位表示权限，由低到高依次为，本地回放、远程回放、远程预览、对讲、
                                              //本地云台控制、远程云台控制、手动录象、录象文件备份、日志管理、
                                              //系统参数设置、升级系统、关闭设备、用户帐号管理
    unsigned int      m_right1;               //保留
    unsigned int      m_netview;              //远程预览的0~31通道
    unsigned int      m_netview1;             //远程预览的32~63通道
    unsigned int      m_netplay;              //远程回放的0~31通道
    unsigned int      m_netplay1;             //远程回放的32~63通道
    unsigned int      m_localplay;            //本地回放的0~31通道
    unsigned int      m_localplay1;           //本地回放的32~63通道
}ETI_RIGHT_T;

/**************************组信息结构****************************/
typedef struct
{
    ETI_RIGHT_T	m_right;
    char       m_groupname[APP_PASSWORD_LENGTH];
}ETI_GROUP_T;

/**************************用户信息结构****************************/
typedef struct
{
    char            m_username[APP_PASSWORD_LENGTH];
    char            m_password[APP_PASSWORD_LENGTH];
    int			    m_groupnum;                         //用户所属的权限组
    ETI_RIGHT_T     m_right;
}ETI_USER_T;

/**************************用户信息参数****************************/
typedef struct
{
    int             m_usernum;                          //用户个数
    int             m_groupnum;                         //有效组个数
    ETI_GROUP_T     m_group[ETI_GROUP_MAXNUM];          //8个组，初始化4个，预留4个
    ETI_USER_T      m_user[ETI_DVR_USER_OPERIAL];       //32个用户，初始化4个
}ETI_SYSUSER_T;


/********************** user info extent(add user stauts) *********/
typedef struct
{
    char m_status[ETI_DVR_USER_OPERIAL];                 /* the status of user(0:disbale, 1:enable) */
    ETI_SYSUSER_T m_user;
}ETI_SYSUSER_EX_T;                                    /* extent user info(add the stauts of user) */

/********************** 串口属性定义***************************/
//数据位
enum{UART_DATABIT_5 = 5,UART_DATABIT_6 = 6,UART_DATABIT_7 = 7,UART_DATABIT_8 = 8};
//停止位
enum{UART_STOPBIT_0 = 0,UART_STOPBIT_1 = 1,UART_STOPBIT_2 = 2};
//校验位
enum{UART_VERIFY_NONE = 0,UART_VERIFY_ODD = 1,UART_VERIFY_EVEN = 2,UART_VERIFY_MASK1 = 3,UART_VERIFY_MASK0 = 4};
//流控
enum{UART_STREAMCTRL_NONE = 0,UART_STREAMCTRL_SOFT = 1,UART_STREAMCTRL_HARD = 2};
/**************错误代码定义***************************/
#define ETI_OK		0
#define ETI_ERROR	-1

/**************程序升级错误代码***************/
#define ETI_UDPATE_ERR_MASKID	-1
#define ETI_UPDATE_ERR_SIZE		-2
#define ETI_UPDATE_ERR_OFFSET	-3
#define ETI_UPDATE_ERR_WRITEFLASH -4
/*****************************************************/

/**************系统语言类型定义***************************/
#define ETI_SYSLANGUAGE_CHINA	1   //中文
#define ETI_SYSLANGUAGE_ENGLISH	2   //英文
/*****************************************************/

/***************云台控制协议定义********************/
#define ETI_PTZTYPE_NONE		0	//无
#define ETI_PTZTYPE_PELCOP		1
#define ETI_PTZTYPE_PELCOD		2
#define ETI_PTZTYPE_HUNTERD		3
#define ETI_PTZTYPE_YINGKE		4
#define ETI_PTZTYPE_SONY100		5

#define ETI_PTZCMDMAXSIZE		4096
#define ETI_PTZCMDMAXSIZE_EX	16384
#define ETI_LICENSEMAXSIZE      1024

/*****************************************************/

/**************网络传输类型和传输协议支持*************/
#define ETI_TRAN_TYPE_UDP	    1
#define ETI_TRAN_TYPE_MULTI	    2
#define ETI_TRAN_TYPE_TCP	    3
#define ETI_TRAN_TYPE_RTP	    4

#define LAN_NET_TRANTYPE_UDP	ETI_TRAN_TYPE_UDP
#define LAN_NET_TRANTYPE_MULTI  ETI_TRAN_TYPE_MULTI
#define LAN_NET_TRANTYPE_TCP	ETI_TRAN_TYPE_TCP
#define LAN_NET_TRANTYPE_RTP	ETI_TRAN_TYPE_RTP	

#define ETI_TRAN_SUPPROT_UDP	0X01
#define ETI_TRAN_SUPPORT_MULTI	0X02
#define ETI_TRAN_SUPPORT_TCP	0X04
#define ETI_TRAN_SUPPORT_RTP	0X08
/*****************************************************/
enum{
	ETI_VOVIEWMODE_1 = 1,
	ETI_VOVIEWMODE_2 = 2,
	ETI_VOVIEWMODE_4 = 4,
	ETI_VOVIEWMODE_6 = 6,
	ETI_VOVIEWMODE_8 = 8,
	ETI_VOVIEWMODE_9 = 9,
};
/***************移动报警、图象屏蔽********************/
/*
 * 对于PAL制式,高能被32整除
 * 对于NTSC制式,高不能被32整除,最后一行采用32*16的块大小
*/
#define ETI_MOTIONAREA_SIZE		396	//(704/32)*(576/32) = 18 * 22
/*****************************************************/

#define ETI_MAX_OSD_SIZE		32

/************报警发生时通过网络备份文件选项**************/
#define ETI_ALARM_BACK_FTP		0X01	//通过FTP备份
#define ETI_ALARM_BACK_MODEM	0X02	//通过拨号备份
/********************** 帧头定义 **********************************/
#define ETI_FRAME_CH_MASK			0X000F		//0X0001111B
#define ETI_FRAME_TIMERESET			0X0010		//0X0010000B
#define ETI_FRAME_KEY_MASK			0X0020		//0X0100000B
#define ETI_FRAME_VIDEOSIZE_MAXK	0x0040		//0X1000000B图像尺寸标志
#define ETI_FRAME_DATA_MASK			0XFF80
#define ETI_FRAME_HEAD_ID			0XB2010000  
#define ETI_BRV_FRAME_HEAD_ID		ETI_FRAME_HEAD_ID + 1		//博维帧头ID
#define ETI_DVR_FRAME_HEAD_ID		0XB3010000	//新帧头部标示	
#define ETI_FRAME_VIDEOSIZE_LEN		4//(width + height)

/************DVR视频帧类型**************/
#define	ETI_DVR_FRAME_KEY_MASK		1<<0		//视频I帧
#define ETI_DVR_FRAME_PFRAME_MASK	1<<1		//视频P帧
#define ETI_DVR_FRAME_BFRAME_MASK	1<<3		//视频B帧
#define ETI_DVR_FRAME_AUDIO			1<<4		//包含音频数据
#define ETI_DVR_FRAME_FILEHEAD		1<<5		//包含文件头

#if defined(DVR_BIG_ENDIAN)
#define ETI_DVR_FRAME_ISKEY(buff) \
	(lc_swab32(((ETI_DVR_FRMAME_HEAD*)(buff))->nVideoSize) > 0 && (lc_swab16(((ETI_DVR_FRMAME_HEAD*)(buff))->nMuxData) & ETI_FRAME_KEY_MASK))
#define ETI_DVR_FRAME_ISFRAME(buff) \
	((lc_swab32(((ETI_DVR_FRMAME_HEAD*)(buff))->nID) == ETI_DVR_FRAME_HEAD_ID) && ((lc_swab32(((ETI_DVR_FRMAME_HEAD*)(buff))->nVideoSize) + lc_swab32(((ETI_DVR_FRMAME_HEAD*)(buff))->nAudioSize) > 0)))
#define ETI_DVR_FRAME_ISVIDEO(buff) lc_swab32(((ETI_DVR_FRMAME_HEAD*)(buff))->nVideoSize) > 0 ? 1 : 0
#define ETI_DVR_FRAME_TICK(buff)    lc_swab32(((ETI_DVR_FRMAME_HEAD*)(buff))->nTimeTick)
#define ETI_DVR_FRAME_ISRESET(buff) (lc_swab16(((ETI_DVR_FRMAME_HEAD*)(buff))->nMuxData) & ETI_FRAME_TIMERESET)
#define ETI_DVR_FRAME_GMTTIME(buff) lc_swab32(((ETI_DVR_FRMAME_HEAD*)(buff))->nGMTTime)
#else
#define ETI_DVR_FRAME_ISKEY(buff) \
	( ((ETI_DVR_FRMAME_HEAD*)(buff))->nVideoSize > 0 && (((ETI_DVR_FRMAME_HEAD*)(buff))->nFrameType & ETI_DVR_FRAME_KEY_MASK))
#define ETI_DVR_FRAME_ISFRAME(buff) \
	((((ETI_DVR_FRMAME_HEAD*)(buff))->nID == ETI_DVR_FRAME_HEAD_ID) && ((((ETI_DVR_FRMAME_HEAD*)(buff))->nVideoSize + ((ETI_DVR_FRMAME_HEAD*)(buff))->nAudioSize > 0)))
#define ETI_DVR_FRAME_ISVIDEO(buff) ((ETI_DVR_FRMAME_HEAD*)(buff))->nVideoSize > 0 ? 1 : 0
#define ETI_DVR_FRAME_TICK(buff)    ((ETI_DVR_FRMAME_HEAD*)(buff))->nTimeTick
#define ETI_DVR_FRAME_ISRESET(buff) (((ETI_DVR_FRMAME_HEAD*)(buff))->nMuxData & ETI_FRAME_TIMERESET)
#define ETI_DVR_FRAME_GMTTIME(buff) ((ETI_DVR_FRMAME_HEAD*)(buff))->nGMTTime
#endif

#define ETI_FRAME_ISKEY(buff) \
	( ((ETI_FRMAME_HEAD*)(buff))->nVideoSize > 0 && ((ETI_FRMAME_HEAD*)(buff))->nMuxData & ETI_FRAME_KEY_MASK)
#define ETI_FRAME_ISFRAME(buff)	\
	((((ETI_FRMAME_HEAD*)(buff))->nID == ETI_FRAME_HEAD_ID) && ((((ETI_FRMAME_HEAD*)(buff))->nVideoSize + ((ETI_FRMAME_HEAD*)(buff))->nAudioSize > 0)))
#define ETI_FRAME_ISVIDEO(buff)     ((ETI_FRMAME_HEAD*)(buff))->nVideoSize > 0 ? 1 : 0
#define ETI_FRAME_TICK(buff)        ((ETI_FRMAME_HEAD*)(buff))->nTimeTick
#define ETI_FRAME_ISRESET(buff)     ( ((ETI_FRMAME_HEAD*)(buff))->nMuxData & ETI_FRAME_TIMERESET )

#define ETT_BRV_PACKETSEQSIZE(pframehead)	(pframehead->m_filehead.m_totalframes == 0?0:(pframehead->m_filehead.m_totalframes - 1)*sizeof(DATA_BRV_CHECK_HEND_T))

#define DVR_FILE_HEAD_SIZE(buff) (((ETI_DVR_FRMAME_HEAD*)(buff))->nFrameType & ETI_DVR_FRAME_FILEHEAD?sizeof(ETI_FILE_HEAD):0)

#define ETI_STREAMINFO_VIDEOID_DVS	0
#define ETI_STREAMINFO_VIDEOID_DVR	1

#define ETI_DVS_FILE_VERSION		1
#define ETI_DVR_FILE_VERSION		2

typedef struct
{
/*
nMuxData Format :16 bits
最大用户数据长度为1024
-----------------------------------------------------
|0--4 通道号| 5 帧类型| 6 图像尺寸标志|7---15 用户数据长度|
如果有图像尺寸标志，在nVideoSize后加上4个字节的图像宽度和高度
-----------------------------------------------------
*/
	//unsigned char  nID[4];	 //0X00,0X00,0X01,0XB2
	unsigned int   nID;			 //0XB2010000
	unsigned int   nTimeTick;    //时间戳
	int			   nVideoSize;   //视频数据长度
	unsigned short nAudioSize;   //音频数据长度
	unsigned short nMuxData;	 //复合数据：视频通道、帧类型、用户数据
}ETI_FRMAME_HEAD,*PETI_FRMAME_HEAD;

/*
1.在视频I帧或者音频格式变化时包含文件头信息,nFrameType = 0x20,文件头长度sizeof(ETI_FILE_HEAD).
2.ID定义为 ETI_DVR_FRAME_HEAD_ID,0XB3010000,此ID在MPEG4或者H264码流中不会存在.
3.如果码流中同时包含音视频数据和文件头信息,排列顺序为: 文件头信息,视频数据,音频数据,nFrameCount按视频数据进行填写.
4.nGMTTime按照GMT时间输入和输出,用于定位当前帧的绝对播放时间.
5.nFrameCount按照编码帧数进行累加,用于判断发送时是否存在丢帧,丢帧后不进行后面P帧解码,避免造成图像花屏.
6.nMuxData去掉原来功能,暂时保留,备用.
*/
typedef struct
{
	unsigned int    nID;			//ETI_DVR_FRAME_HEAD_ID,0XB3010000
	unsigned int    nTimeTick;      //时间戳,相对时间,毫秒为单位
	unsigned int    nGMTTime;       //绝对时间,自1970年1月1日 00:00:00 开始的秒数,时区按GMT时区计算.
	int             nFrameType;     //低4位表示视频帧类型: 0->I-FRAME/1->P-FRAME/3->B-FRAME
                                    //第5位表示是否包含音频: 0x10:表示有音频帧
								    //第6位表示是否包含文件头信息: 0x20: 表示有文件头信息
    int             nFrameCount;    //编码帧序号
	int             nVideoSize;     //视频数据长度
	unsigned short  nAudioSize;     //音频数据长度
	unsigned short  nMuxData;	    //复合数据
}ETI_DVR_FRMAME_HEAD,*PETI_DVR_FRMAME_HEAD;

#define ETI_FILE_MASKEND	0XABCEDF01
#define ETI_FILEMASK		"LAUNCHDIGITAL"
#define ETI_FILEMASK_NEW	"MP4RECORDFILE"
#define TARGET_DX4

typedef struct
{
    char			m_court[48];      //主机所在法院
    char			m_courtroom[48];   //主机所在法庭
    char			m_id[16];           //主机唯一识别号
    char			m_szCaseID[28];	    //case id
	char			m_szCaseExecor[28]; //case 执行人
	char			m_recv1[32];        //保留1
	char			m_recv2[32];        //保留2
	char			m_recv3[32];        //保留3
}DX_FILE_HEAD;

typedef struct
{
	char            m_filemask[16]; //文件头MASK "LAUNCHDIGITAL"
	int             m_fileversion;  //文件版本号 ETI_DVR_FILE_VERSION为结构 ETI_DVR_FILE_HEAD
                                    //           ETI_DVS_FILE_VERSION为结构 ETI_FILE_HEAD
	int             videofoucc;     //视频FOURCC
	int             videoid;        //视频ID 暂时保留 0
	short           m_width;        //图像宽度
	short           m_height;       //图像高度
	short           m_audiotag;     //音频标识
	short           m_haveaudio;    //是否包含音频标志
	short           m_auchs;        //音频通道号
	short           m_aurates;      //音频码率
	int             m_ausample;     //音频采样率
	unsigned int    m_totalframes;  //文件中包含的帧数
	unsigned int    m_firsttick;    //第一帧时间戳
	unsigned int    m_losttick;     //最后一帧时间戳
	int             maskend;        //结束标志
}ETI_FILE_HEAD;

typedef struct
{
	char            m_filemask[16]; //文件头MASK "LAUNCHDIGITAL"
	int             m_fileversion;  //文件版本号 ETI_DVR_FILE_VERSION为结构 ETI_DVR_FILE_HEAD
                                    //           ETI_DVS_FILE_VERSION为结构 ETI_FILE_HEAD
	int             videofoucc;     //视频FOURCC
	int             videoid;        //视频ID 暂时保留 0
	short           m_width;        //图像宽度
	short           m_height;       //图像高度
	short           m_audiotag;     //音频标识
	short           m_haveaudio;    //是否包含音频标志
	short           m_auchs;        //音频通道号
	short           m_aurates;      //音频码率
	int             m_ausample;     //音频采样率
	unsigned int    m_totalframes;  //文件中包含的帧数
	unsigned int    m_firsttick;    //第一帧时间戳
	unsigned int    m_losttick;     //最后一帧时间戳
    unsigned int    m_reserved;     //保留位
	unsigned int    m_firstGMTTime; //文件开始绝对时间,时区按GMT时区计算.
	unsigned int    m_lastGMTTime;  //文件结束绝对时间,时区按GMT时区计算.
	int             maskend;        //结束标志
}ETI_DVR_FILE_HEAD;

typedef struct
{
	char            m_filemask[16]; //文件头MASK "LAUNCHDIGITAL"
	int             m_fileversion;  //文件版本号 ETI_DVR_FILE_VERSION为结构 ETI_DVR_FILE_HEAD
									//           ETI_DVS_FILE_VERSION为结构 ETI_FILE_HEAD
	int             videofoucc;     //视频FOURCC
	int             videoid;        //视频ID 暂时保留 0
	short           m_width;        //图像宽度
	short           m_height;       //图像高度
	short           m_audiotag;     //音频标识
	short           m_haveaudio;    //是否包含音频标志
	short           m_auchs;        //音频通道号
	short           m_aurates;      //音频码率
	int             m_ausample;     //音频采样率
	unsigned int    m_totalframes;  //文件中包含的帧数
	unsigned int    m_firsttick;    //第一帧时间戳
	unsigned int    m_losttick;     //最后一帧时间戳
    unsigned int    m_reserved;     //保留位
	unsigned int    m_firstGMTTime; //文件开始绝对时间,时区按GMT时区计算.
	unsigned int    m_lastGMTTime;  //文件结束绝对时间,时区按GMT时区计算.
	DX_FILE_HEAD    m_dxfile;       //录像头中添加法院信息
	int             maskend;        //结束标志
}ETI_DX4_DVR_FILE_HEAD;

typedef struct
{
	unsigned int    nID;            //ETI_BRV_FRAME_HEAD_ID,0XB2010001
	unsigned int    nTimeTick;      //时间戳
	int			    nVideoSize;     //视频数据长度
	unsigned short  nAudioSize;     //音频数据长度
	unsigned short  nMuxData;	    //复合数据：视频通道、帧类型、用户数据
	ETI_FILE_HEAD   m_filehead;	    //文件头
}ETI_BRV_FRMAME_HEAD,*PETI_BRV_FRMAME_HEAD;

#define MIN_FRMAME_HEAD ETI_FRMAME_HEAD
typedef struct
{
	unsigned short	framenum;
	unsigned short	packnum;
}DATA_BRV_CHECK_HEND_T;

#define BRV_PACETSIZE		1116
/********************** 日期时间信息格式定义 ********************************/
typedef enum{
	ETI_TIME_FORMAT_OFF = 0X00,//关闭
	ETI_TIME_FORMAT_1	= 0X01,//2003-09-12 15:23:33
	ETI_TIME_FORMAT_2	= 0X02,//2003-09-12 星期五 15:23:33
	ETI_TIME_FORMAT_3	= 0X03,//09-12-2003 15:23:33
	ETI_TIME_FORMAT_4	= 0X04,//09-12-2003 星期五 15:23:33
	ETI_TIME_FORMAT_5	= 0X05,//12-09-2003 15:23:33
	ETI_TIME_FORMAT_6	= 0X06,//12-09-2003 星期五 15:23:33
	ETI_TIME_FORMAT_7	= 0X07,//2003/09/12 15:23:33
	ETI_TIME_FORMAT_8	= 0X08,//09/12/2003 15:23:33
	ETI_TIME_FORMAT_9	= 0X09,//12/09/2003 15:23:33
	ETI_TIME_FORMAT_A	= 0X0A,//2003.09.12 15:23:33
	ETI_TIME_FORMAT_B	= 0X0B,//09.12.2003 15:23:33
	ETI_TIME_FORMAT_C	= 0X0C //12..09.2003 15:23:33
}ETI_TIME_FORMAT;
/*****************************************************/

/**************时间表日期***************************/
typedef enum
{
	ETI_DAY_MONDAY		= 0,	//星期一
	ETI_DAY_TUESDAY		= 1,	//星期二
	ETI_DAY_WEDNESDAY	= 2,	//星期三
	ETI_DAY_THURSDAY	= 3,	//星期四
	ETI_DAT_FRIDAY		= 4,	//星期五
	ETI_DAY_SATURDAY	= 5,	//星期六
	ETI_DAY_SUNDAY		= 6,	//星期天
	ETI_DAY_MON_FRI		= 7,	//星期一-星期五
	ETI_DAY_SAT_SUN		= 8,	//星期六-星期天
	ETI_DAY_DAILY		= 9,	//每天
	ETI_DAY_OFF			= 10,	//关闭
}ETI_TIME_DAYTYPE;
/*****************************************************/

//码率控制模式，我公司与海思定义的RC_MODE_E不同，CBR和VBR相反(兼容以前设计)
typedef enum
{
    ETI_MODE_CBR = 0,
    ETI_MODE_VBR,
    ETI_MODE_ABR,
    ETI_MODE_FIXQP,
}ETI_MODE_E;

#endif  //__ETI_BASE_DEF_H__

