Mercurial > pt1.oyama
diff recpt1/tssplitter_lite.h @ 119:4e7aaa72e158
ES out early release version.
author | Naoya OYAMA <naoya.oyama@gmail.com> |
---|---|
date | Mon, 19 Apr 2010 00:30:09 +0900 |
parents | caecbba2a76f |
children | 8e438d2a1529 |
line wrap: on
line diff
--- a/recpt1/tssplitter_lite.h Mon Apr 19 00:17:57 2010 +0900 +++ b/recpt1/tssplitter_lite.h Mon Apr 19 00:30:09 2010 +0900 @@ -36,6 +36,129 @@ #define TSS_NULL (-2) #define LENGTH_PAT_HEADER (12) #define C_CHAR_COMMA ',' +#define LENGTH_TS_HEADER (4) +#define LENGTH_PES_HEADER (9) +#define LENGTH_PTS (5) + +/* ²þÄûÈǥǥ¸¥¿¥ëÊüÁ÷¶µ²Ê½ñ(¾å) P101 ɽ1 ARIB¤Ç¤ÎPSI/SI¤Î¼ïÎà¤è¤ê»²¾È */ +#define PAT (0x0000) +//#define PMT /* PAT¤Ë¤è¤ë´ÖÀÜ»ØÄê */ +#define CAT (0x0001) +#define NIT (0x0010) +#define SDT (0x0011) +#define BAT (0x0011) +#define EIT (0x0012) /* 0x0026, 0x0027 */ +#define RST (0x0013) +#define TDT (0x0014) /* Ãϥǥ¸¤Ç¤Ï»ÈÍѤµ¤ì¤Ê¤¤ */ +#define TOT (0x0014) +#define LIT (0x0020) /* ¤Þ¤¿¤ÏPMT¤Ë¤è¤ë´ÖÀÜ»ØÄê */ +#define ERT (0x0021) /* ¤Þ¤¿¤ÏPMT¤Ë¤è¤ë´ÖÀÜ»ØÄê */ +//#define ITT /* PMT¤Ë¤è¤ë´ÖÀÜ»ØÄê */ +#define PCAT (0x0022) +#define BIT (0x0024) +#define NBIT (0x0025) +//#define ECM /* PMT¤Ë¤è¤ë´ÖÀÜ»ØÄê */ +//#define EMM /* CAT¤Ë¤è¤ë´ÖÀÜ»ØÄê */ +#define LDT (0x0025) +#define DCT (0x0017) +//#define DTL /* DCT¤Ë¤è¤ë´ÖÀÜ»ØÄê */ +#define DIT (0x001e) +#define SIT (0x001f) +#define SDTT (0x0023) +#define CDT (0x0029) +//#define DSM-CC_Section /* PMT¤Ë¤è¤ë´ÖÀÜ»ØÄê */ + +/* ¥»¥¯¥·¥ç¥ó¥Ø¥Ã¥ÀĹ */ +/* TS ¥Ñ¥±¥Ã¥È¤Ë³Æ¥»¥¯¥·¥ç¥ó¤òÀßÃÖ¤¹¤ëºÝ¡¢³ºÅöTS¥Ñ¥±¥Ã¥È¤Î»Ä¥µ¥¤¥º¤¬ + * ¤¤¤¯¤Ä°Ê¾å¤¢¤ì¤Ð½ñ¤¹þ¤á¤ë¤«¤ÎȽÄê¤Ë»ÈÍѤ¹¤ë¡£ + * ¥Ç¥³¡¼¥É¤Ë¤Ï¤¢¤Þ¤ê½ÅÍפǤÏ̵¤¤¤«¤â + */ +#define SECTION_LENGTH_PAT (8) +#define SECTION_LENGTH_PMT (8) +#define SECTION_LENGTH_CAT (8) +#define SECTION_LENGTH_NIT (8) +#define SECTION_LENGTH_BIT (8) +#define SECTION_LENGTH_SDT (11) +#define SECTION_LENGTH_EIT (14) /* H-EIT, M-EIT, L-EIT ¤ò¼¨¤¹ */ +#define SECTION_LENGTH_SDTT (15) +#define SECTION_LENGTH_CDT (13) +#define SECTION_LENGTH_TOT (10) + +enum { + PTS_FLAG = 0x80, + DTS_FLAG = 0x40, + ESCR_FLAG = 0x20, + ES_RATE_FLAG = 0x10, + DSM_TRICK_MODE_FLAG = 0x08, + COPY_INFO_FLAG = 0x04, + CRC_FLAG = 0x02, + EXTENSION_FLAG = 0x01 +}; + +enum { + PES_PRIVATE_DATA_FLAG = 0x80, + PACK_HEADER_FIELD_FLAG = 0x40, + PROGRAM_PACKET_SEQUENCE_COUNTER = 0x20, + PSTD_BUFFER_FLAG = 0x10, + PES_EXTENSION_FLAG2 = 0x01 +}; + +/* + * PCR¤«¤éSTC¤òÀ¸À®¤¹¤ë½èÍýÊý¼°(°Æ) + * 1. PCR¤òÆó¤Ä¼èÆÀ¤¹¤ë¤Þ¤Ç¥ë¡¼¥×(1.¢²4.¤Þ¤Ç¤Ï½é´ü½èÍý¤Ç¼Â»Ü¤¹¤ë¤³¤È) + * 2. ¥ë¡¼¥×³«»Ï»þ¹ï(PCR)¤È¡¢¥ë¡¼¥×È´¤±¤¿»þ¹ï(PCR)¤Îº¹Ê¬¤ò¼è¤ë + * 3. ¥ë¡¼¥×³«»Ï¡Á½ªÎ»¤Î´Ö¤Ë½èÍý¤·¤¿¥Ñ¥±¥Ã¥È¿ô¤ò¿ô¤¨¤ë + * 4. (2.¤ÎPCR¤Î¿Ê¤ó¤À»þ´Ö/3.¤Î¥Ñ¥±¥Ã¥È¿ô)¡¡¤Î·×»»¤Ë¤è¤Ã¤Æ¡¢1¥Ñ¥±¥Ã¥È¤Ë¤è¤Ã¤Æ¿Ê¤àPCR¤òÁÛÄꤹ¤ë + * 5. TS¼õ¿®»þ¤Ë¡¢1¤Ä¤Î¥Ñ¥±¥Ã¥È¤ò½èÍý¤¹¤ëÅÙ¤Ë4.¤ÎÁÛÄꤹ¤ë·Ð²á»þ¹ï¤òPCR¤Ë¤·¹þ¤ó¤ÇSTC¤È¤¹¤ë + * 6. PCR¤ò¿·µ¬¤Ë¼èÆÀ¤·¤¿¤é¡¢STC¤òÊäÀµ(¤½¤Î¤Þ¤ÞÂåÆþ)¤¹¤ë + */ +#define MAX_VIDEO (16) +#define MAX_AUDIO (32) +typedef struct _program_t +{ + int64_t stc; + int64_t cue_time; /* Ï¿²è³«»Ï»þ¹ï */ + int pmt_packet_id; /* ³ºÅöProgram(Service ID)¤ËÂбþ¤¹¤ëPMT */ + int pmt_version; /* ³ºÅöProgram(Service ID)¤ËÂбþ¤¹¤ëPMT¤ÎVersion */ + int pcr_packet_id; /* ³ºÅöProgram(Service ID)¤ÎPCR¤òÊÝ»ý¤¹¤ëPID */ + int64_t pcr1; /* PCR1 */ + int64_t pcr2; /* PCR2 */ + int packet_nb; /* PCR·×»»ÍÑ¥«¥¦¥ó¥¿ */ + int64_t pcr_incr; /* ³ºÅöProgram(Service ID)¤Ë±÷¤¤¤Æ¡¢1¤Ä¤ÎTS¥Ñ¥±¥Ã¥È¤ò½èÍý¤·¤¿»þ¤Ë·Ð²á¤¹¤ë(¤ÈÁÛÄꤹ¤ë»þ´Ö) */ + int video_start; /* VODEO0¤òÃßÀѳ«»Ï¤·¤Æ¤¤¤ë¡© */ + int video_pts; /* ºÇ¸å¤Ë½èÍý¤·¤¿VODEO0¤ÎES¤ÎPTS */ + int video_nb; /* PMT ¤Ë¸ºß¤¹¤ë¥Ó¥Ç¥ª¥¹¥È¥ê¡¼¥à¤Î¿ô */ + int audio_nb; /* PMT ¤Ë¸ºß¤¹¤ë²»À¼¥¹¥È¥ê¡¼¥à¤Î¿ô */ + int video[MAX_VIDEO]; /* PS½ÐÎϤ¹¤ë¾ì¹ç¤Ë»È¤¦¤«¤â */ + int audio[MAX_AUDIO]; /* PS½ÐÎϤ¹¤ë¾ì¹ç¤Ë»È¤¦¤«¤â */ + //splitpesbuf_t *pesbuf; + //splitesbuf_t *esbuf; +} program_t; +/* + * program_t ¤ò¥µ¡¼¥Ó¥¹IDʬ½àÈ÷¤·¤Æ¡¢»ÈÍѤ¹¤ë¥¤¥á¡¼¥¸¤Ç¤¤¤¿¤±¤É¡¢ + * ¥µ¡¼¥Ó¥¹ID¤ÎºÇÂçÃͤÏ0xFFFF¤Ç¤¢¤ë¤Î¤Ç¡¢ÀÅŪ¤Ë³ÎÊݤ¹¤ë¤È stack ¤¬´Êñ¤Ë°î¤ë¤Î¤Ç¡¢ + * ¼Â¹Ô»þ¤Ë malloc ¤È¤¹¤ë¤«¤Ê¤¡ + * ËÜÅö¤ÏɬÍפʤÀ¤±alloc¤¹¤ë¤Î¤¬¹¥¤Þ¤·¤¤¤Î¤À¤±¤É¡Ä + */ + +typedef struct _splitpesbuf_t +{ + program_t *Program; + int random_access_indicator; /* TS ¤Î random_access_indicator */ + int size; + u_char buffer[3*1024*1024]; +} splitpesbuf_t; + +typedef struct _splitesbuf_t +{ + program_t *Program; + int64_t pts; + int64_t dts; + int started; /* ³ºÅöES¤¬ÃßÀѳ«»Ï¤·¤Æ¤¤¤ë¤« */ + int random_access_indicator; /* TS ¤Î random_access_indicator */ + int size; + u_char buffer[3*1024*1024]; +} splitesbuf_t; /** * splitter¹½Â¤ÂÎ @@ -50,6 +173,15 @@ int pmt_counter; int avail_pmts[MAX_SERVICES]; int num_pmts; +// struct timespec tot_offset; +// struct timespec STC_timespec; + int64_t stc; + int64_t cue_time; + int status; + splitpesbuf_t *pesbuf[MAX_PID]; + splitesbuf_t *esbuf[MAX_PID]; + program_t *program; + int pid_sid_table[MAX_PID]; /* pid to sid ¤ÎÊÑ´¹¤ò¹Ô¤¦¤¿¤á¤Î¥Æ¡¼¥Ö¥ë */ } splitter; /* b25 decoder would hoard up large chank */