#ifndef _PARSE_PSI_H
#define _PARSE_PSI_H

#include "DTV.h"

#define bcdtoint(i) ((((i & 0xf0) >> 4) * 10) + (i & 0x0f))

#define bcdtochar(i,j,k) {(j = ((i & 0xf0) >> 4)); k = (i & 0x0f);}

enum table_type {
	PAT, //0
	CAT,
	PMT,
	SDT,
	NIT,
	BAT,    
	EIT, //6
	EMT, //7
	ETT, //8
	TOT,
	VCT,
	MGT,
	STT,
	RRT,
	DST,
	SLDT
};

enum stream_type {
	STREAM_UNKNOWN = 0,
	STREAM_VIDEO,
	STREAM_AUDIO,
	STREAM_TELETEXT,
	STREAM_SUBTITLE,
	STREAM_DATA
};

struct parse_info_st {
	HX_INT8 dtv;
	HX_UINT16 pid;
	HX_UINT8 table_id;
	const HX_UINT8 *buf;
	int section_length;
	int table_id_ext;
	int section_version_number;
	HX_UINT8 net_index;
	HX_UINT network_type;
};

inline time_t convert_date(char *dvb_buf);

HX_BOOL set_eit_language_code(char *letter);

void parse_section(HX_INT8 dtv, HX_UINT16 pid, HX_UINT8 * pBuf, HX_UINT32 length, HX_INT32 param1, HX_INT32 param2);

#endif // _PARSE_PSI_H
