#pragma once
/******************************************************************************
						SYSTEM DEFINE
******************************************************************************/
#define		RELAY_MODE_LOOPBACK					0
#define		RELAY_MODE_NORMAL					1

#define		VIDEO_MODE_NTSC						0
#define		VIDEO_MODE_PAL						1

#define		VIDEO_INPUT_UNLOCKED				0
#define		VIDEO_INPUT_LOCKED					1

#define		VIDEO_BUFFER_STATUS_NORMAL			0
#define		VIDEO_BUFFER_STATUS_EMPTY			1
#define		VIDEO_BUFFER_STATUS_FULL			2

#define		AUDIO_BUFFER_STATUS_NORMAL			0
#define		AUDIO_BUFFER_STATUS_EMPTY			1
#define		AUDIO_BUFFER_STATUS_FULL			2

#define		VIDEO_FRAME_TYPE_YUY2				0
#define		VIDEO_FRAME_TYPE_ARGB32				1
#define		VIDEO_FRAME_TYPE_ARGB32_UPSIDEDOWN	2//采集或者播放的视频是上下颠倒的
#define		VIDEO_FRAME_TYPE_KEY				3//键模式，输出字幕的键信号。
#define		MAX_CHANNEL_ID					16

#define		VIDEO_CHANNEL_ID_0				0
#define		VIDEO_CHANNEL_ID_1				1
#define		VIDEO_CHANNEL_ID_2				2
#define		VIDEO_CHANNEL_ID_3				3

#define		AUDIO_CHANNEL_ID_0				0
#define		AUDIO_CHANNEL_ID_1				1
#define		AUDIO_CHANNEL_ID_2				2
#define		AUDIO_CHANNEL_ID_3				3

//ExternCard type definitions
#define		NO_PLUG_IN						0x00
#define		SDI_PLUG_IN						0x10
#define		ASI_PLUG_IN						0x20
#define		ERROR_PLUG_IN					0xff

#define		ASI_PACKET_188					0
#define		ASI_PACKET_204					1
#define		ASI_OUTPUT_NORMAL				0
#define		ASI_OUTPUT_LOOPBACK				1
#define		ASI_MAX_FLUSH_BUFFER_NUMBER		3240
#define		ASI_MIN_FLUSH_BUFFER_NUMBER		810
#define     ASI_TRACKING_INPUT_RATE 1
#define     ASI_SOFTWARE_INSTALLED_RATE 0
#define		SDI_DATASOURCE_INPUT1			0x1
#define		SDI_DATASOURCE_INPUT2			0x2

/******************************************************************************
						PLAY DEFINE
******************************************************************************/

#define		MEDIA_STATUS_EMPTY					0
#define		MEDIA_STATUS_PAUSE					1
#define		MEDIA_STATUS_PLAY					2
#define		MEDIA_STATUS_STOP					3

#define		MEDIA_NEXT_STATUS_EMPTY				0
#define		MEDIA_NEXT_STATUS_OPENED			1

#define		AUDIO_CHANNEL_STEREO				0
#define		AUDIO_CHANNEL_LEFT					1
#define		AUDIO_CHANNEL_RIGHT					2
#define		AUDIO_CHANNEL_BLEND					3

#define		AUDIO_VOLUMN_LEFT					1
#define		AUDIO_VOLUMN_RIGHT					2

#define		VOLUMN_NO_SHOW_MODE					0
#define		VOLUMN_WINDOW_VERTICAL_UP_MODE		1
#define		VOLUMN_WINDOW_VERTICAL_DOWN_MODE	2
#define		VOLUMN_OVERLAY_VERTICAL_UP_MODE		5
#define		VOLUMN_OVERLAY_VERTICAL_DOWN_MODE	6

#define		INVALIDMEDIA		0	
#define		MPEG1VCD			1
#define		MPEG1SYSTEM			2
#define		MPEG1VIDEO			3
#define		MPEG2PROGRAM		11
#define		REALMEDIA			21
#define		WINDOWSMEDIAVIDEO	31
#define		MPEG4VIDEO			41
#define		ASFVIDEO			51
#define		AVIVIDEO			61

#define		NORMALPCM			1
#define		DOLBYAC3			100
#define		DVDLPCM				101
#define		MPEG1AUDIO			111
#define		MPEG1AUDIOPAYLOAD	112
#define		MPEG1LAYER3			113
#define		MPEG2AUDIO			121
#define		REALMEDIAAUDIO		131

#define		HD_VIDEO_WIDTH		1920
#define		HD_VIDEO_HEIGHT		1080

#define		VIDEO_OVERLAY_MEDIA_OVER_CAPTURE			01
#define		VIDEO_OVERLAY_CAPTURE_OVER_MEDIA			02
#define		VIDEO_OVERLAY_MATTING_PROCESS				03
#define		VIDEO_OVERLAY_KEYING_PROCESS				04

#define		AUDIO_PLAYBACK_AUTO_MODE					01
#define		AUDIO_PLAYBACK_MANUAL_MODE					02

#define		AUDIO_PLAYBACK_CAPTURE_SOURCE				01
#define		AUDIO_PLAYBACK_MEDIA_SOURCE					02
//EFFECT DEFINE			
#define		CAPTURE_TRANSFORM_TO_CAPTURE_MODE			01 //same cap channel
#define		CAPTURE_TRANSFORM_TO_PLAYBACK_MODE			02 //cap playback

//ENCODER
#define		RECORDER_FILE_TYPE_MPEG				1						
#define		RECORDER_FILE_TYPE_AVI				2
#define		RECORDER_FILE_TYPE_WMV				3

#define		FMT_YUV420							0
#define		FMT_YUV422							1
#define		VIDEO_ASPECT_RATIO_4_3				1
#define		VIDEO_ASPECT_RATIO_16_9				2

#define		VIDEO_MATTING_NORMAL_MODE			0
#define		VIDEO_MATTING_FOREGROUND_MODE		1
#define		VIDEO_MATTING_BACKGROUND_MODE		2
#define		VIDEO_MATTING_SYMMETRY_MODE			3

#define		VIDEO_MATTING_BLUE_BACKGROUND		0
#define		VIDEO_MATTING_GREEN_BACKGROUND		1

#define		TRANSFORM_EFFECT_NO							00
#define		TRANSFORM_EFFECT_FADE_IN_OUT				10

//TS DEF
#define		TS_CAPTURE_WORKMODE_RAWDATA			0//采集的数据，不做任何处理
#define		TS_CAPTURE_WORKMODE_FILTER			1//采集的数据经过过滤，选择特定节目流

//TS 采集数据源

#define     TS_INPUT_SOURCE_ASI                 0 // 板卡采集 ASI输入
#define     TS_INPUT_SOURCE_IP                  1 // IP采集udp/rtp输入

#define		TSTOPS_MAX_SERVICE_NUMBER 12
#define		TS_MAX_SERVICE_NUMBER				60	
#define		TS_MAX_SERVICE_NAME_LEN				32

#define		TS_SEARCH_PROGRAM_NULL				0
#define		TS_SEARCH_PROGRAM_ING				1
#define		TS_SEARCH_PROGRAM_OK				2
#define		TS_SEARCH_PROGRAM_DISCONTINUOUS	    3
#define		TS_SEARCH_PROGRAM_ERROR				255

#define		TS_STREAM_TYPE_MEPG2				0
#define		TS_STREAM_TYPE_H264					10
#define		MAX_NIT_REPLACE_NUM               128

#define STREAMTYPE_VIDEO		2
#define STREAMTYPE_AUDIO11172	3
#define STREAMTYPE_AUDIO13818	4
#define STREAMTYPE_PRIVATESECTION 5

#define MAX_CA_ON_ONE_PMT				4
#define MAX_CA_ON_ONE_CAT				20
#define MAX_TRANSPORTSTREAM_ON_ONE_NETWORK	128
#define SERVICE_NAME_MAX_LEN    128
/******************************************************************************
							RECORDER DEFINE
******************************************************************************/
#define		RECORDER_CAPTURE_STREAM				1//录制模拟采集
#define		RECORDER_PLAYBACK_STREAM			2//录制播出
#define		RECORDER_CAPTURE_TS_STREAM			3//录制ts采集

typedef enum VideoPixelFormat {
	VIDEO_FMT_YUY2,   ///< Packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
	VIDEO_FMT_BGRA,   ///< Packed B G R A B G R A	
	VIDEO_FMT_NONE,
}VIDEO_PIXEL_FORMAT;
struct MEDIA_TIME_CODE
{
	UINT uiHour;
	UINT uiMinute;
	UINT uiSecond;
	UINT uiFrame;
};

typedef struct
{
	UINT uiOutputNumber;
	UINT aOutputIds[16];
}OUTPUT_ARRAY;

struct MEDIA_FILE_INFORMATION
{
	ULONG ulTimeDuration;

	UINT uiVideoWidth;
	UINT uiVideoHeight;
	FLOAT fVideoFrameRate;
	FLOAT fVideoAvgTimePerFrame;
	UINT uiAudioType;
	UINT uiVideoType;
	UINT uiDvdAudioNumber;
	UINT uiDvdSubPictureNumber;
	UINT uiDemultiNumber;
};

struct MOSAIC_RECTANGLE
{
	//整块范围
	UINT uiStartX;
	UINT uiStartY;
	UINT uiWidth;
	UINT uiHeight;
	//子块的大小，0-255
	UINT uiParticleSize;
};
typedef struct RECORDER_ENCODER_PARAM
{
	UINT uiFileType;
	UINT uiBitRate;//1 ~ 15000  录制码率
	UINT uiPixelFormat;
	UINT uiVideoAspect;
	UINT uiVbrQuality;    //1~100 仅对Wmv 录制有效（控制码率） 设置值为0时码率控制模式为CBR 非0为VBR
	UINT uiVideoHeight;     //WMV 录制高
	UINT uiVideoWidth;     //WMV 录制宽
}RECORDER_ENCODER_PARAM;

//TS
typedef struct VideoKeyParam {
	float _p0_bg_h; 
	float _p0_bg_v; 
	float _p0_bg_lh; 
	float _p0_bg_lv; 
	float _p1_a0; 
	float _p2_a1; 
	float _pn_r0;
	float _pn_r1; 
	float _pn_r2;
	float _pn_r3;
	float _pn_r4;
	float _pn_r5; 
	float _pn_r6; 
	float _pn_r7; 
}VIDEO_KEY_PARAM;
typedef struct  
{

	short pmtid;
	BOOL bScrambling;
	unsigned char  ca_num;
	 struct
	{
		unsigned short CaSysPid;
		unsigned short CaPid;
	}ca_info[MAX_CA_ON_ONE_PMT];
	unsigned char es_num;
	 struct
	{
		unsigned char stream_type;
		unsigned short elementary_pid;
		unsigned char reserved;
	} es_info[TS_MAX_SERVICE_NAME_LEN];

	INT nServiceId;
	UCHAR  aServiceName[TS_MAX_SERVICE_NAME_LEN];
	UCHAR  service_provider_name[TS_MAX_SERVICE_NAME_LEN];
	
}TS_SERVICE_INFO;
typedef struct  
{
	INT nMaxServiceInfoNum;//valid serviceinfo num

	TS_SERVICE_INFO  aServiceInfo[TS_MAX_SERVICE_NUMBER];
}TS_SERVICE_DESCRIBE_TABLE;
typedef struct  
{	
	unsigned char  ca_num;
	struct
	{
		unsigned short CaSysPid;
		unsigned short CaPid;
	}ca_info[MAX_CA_ON_ONE_CAT];
	DOUBLE dbMinRate;
	DOUBLE dbMaxRate;
	DOUBLE dbCurRate;
	DOUBLE dbCurEffectRate;
	UINT uiTsID;
	UINT uiOnNetID;
	TS_SERVICE_DESCRIBE_TABLE sdtServiceTable;	

}TS_PROGRAM_INFO;

typedef struct  
{
	unsigned int   service_id ;
	unsigned short service_type ;
	unsigned int   pmtid;
	unsigned char  running_status;
	unsigned char  free_CA_mode;
	unsigned char es_num;
	struct
	{
		unsigned char stream_type;
		unsigned short elementary_pid;
		unsigned char reserved;
	} es_info[TS_MAX_SERVICE_NAME_LEN];
	UCHAR  aServiceName[TS_MAX_SERVICE_NAME_LEN];
	UCHAR service_provider_name[TS_MAX_SERVICE_NAME_LEN];
}SERVICE_LISTINFO;

typedef struct
{
	unsigned short transport_stream_id;
	unsigned short original_network_id;
	unsigned int freq;		//khz
	unsigned int symrate;	//kbps
	enum QAM_TYPE qam;
	unsigned short FEC_outer  ;
	unsigned short FEC_inner;
	unsigned int service_num ;
	bool bCurrent;
	SERVICE_LISTINFO serviceinfo[TS_MAX_SERVICE_NUMBER];
} TRANSPORTSTREAMINFO;

enum QAM_TYPE
{
	QPSK = 0,
	QAM16,
	QAM32,
	QAM64,
	QAM128,
	QAM256
};

typedef struct
{
	unsigned short network_id;
	unsigned char  version_number;
	unsigned char  tsinfo_num;
	unsigned char  network_name[SERVICE_NAME_MAX_LEN];
	TRANSPORTSTREAMINFO		tsinfo[MAX_TRANSPORTSTREAM_ON_ONE_NETWORK];
}NIT_NETWORKINFO;


//用户要删除的pid信息


typedef struct
{
	unsigned short pid;
	unsigned short pmtpid;
	unsigned short pidtype;
}TS_DEL;
typedef struct
{
	unsigned short piddelnum;
	TS_DEL     piddel[TS_MAX_SERVICE_NUMBER];
}TS_DEL_INFO;



//用户选择的ts节目列表
typedef struct  
{
	INT nProgramId;//
	//UINT uiServiceId;
	LPCTSTR szRecorderFileName;
}RECORDER_PROGRAM_INFO;
typedef struct  
{
	INT nProgramNum;//总共的节目数量。
	RECORDER_PROGRAM_INFO aProgramList[TS_MAX_SERVICE_NUMBER];
}RECORDER_PROGRAM_LIST;
typedef struct
{
	UINT uiStreamType;
	UINT uiMuxRate;					//总码率，单位：kbps
	UINT uiTsId;						//流ID	
	UINT uiServiceId;					//serviceID
	UINT uiPmtPid;					//PMTID
	UINT uiVideoPid;					//视频流ID
	UINT uiAudioPid;					//音频流ID
	LPCTSTR strProviderName;			//提供商名称
	LPCTSTR strServiceName;				//服务名称
	UINT uiVideoRate;					//总码率，单位：kbps
	UINT uiOnNetId;					//流网络ID
}TS_ENCODER_PARAM;

//VIDEO MATTING
typedef struct VIDEO_MATTING_PARAM
{
	INT maxk;
	INT mink;
	INT x1;
	INT x2;
	INT y1;
	INT y2;
	INT mattingMode;//state
	INT backgroudColor;
	INT keyValueAdjustment;
	
	//扣像后微调值
	INT rAdjust;
	INT gAdjust;
	INT bAdjust;
	
	int edgewith;
	int edgequality;
	int edgecolore;
	//噪声调整
	INT noiseAdjust;

	//特效处理
	LPCTSTR tgafilename1;//与字幕tga文件合成，保存特效
	LPCTSTR tgafilename2;//备用
	INT tem1;//备用
	INT tem2;//备用
	INT tem3;//备用
	INT tem4;//备用
}VIDEO_MATTING_PARAM;
typedef struct
{
	unsigned short transport_stream_id;
	unsigned short original_network_id;
	unsigned int freq;		//khz
	unsigned int symrate;	//kbps
	enum QAM_TYPE qam;
	unsigned short FEC_outer  ;
	unsigned short FEC_inner;
}TS_NIT_INFO;

typedef struct  
{
	unsigned int  uiTsNitNum;
	TS_NIT_INFO  tnInfo[MAX_NIT_REPLACE_NUM];
}NIT_BASE_INFO;

typedef struct  
{
	UINT nProgramPid;                 //节目流ID
	UINT uiVideoPid;					//视频流ID
	UINT uiAudioPid;					//音频流ID
	UINT uiAudioStreamType;           //音频流类型
	LPCTSTR  szRecorderFileName ;      //文件存储名称
	UINT nProgramItem;                //节目序号
}RECORDER_PROGRAM_MULTI_INFO;
typedef struct  
{
	INT nProgramNum;//总共的节目数量。
	RECORDER_PROGRAM_MULTI_INFO aProgramList[TSTOPS_MAX_SERVICE_NUMBER];
}RECORDER_PROGRAM_MULTI_LIST;


typedef struct
{
	LPCTSTR strDestIp;
	UINT uiDestUdpPort;
	UINT uiTsBitRate;
	UINT uiTsPacketLength;
	BOOL bRtpEnable;
	BOOL bFECEnable;
}TS_OVER_IP_MULTICAST_PARAM;

typedef struct
{
	UINT uiCCErrorCount;
	UINT uiSyncErrorConut;
}TSTOPS_ETR_290_ERROR;