Mercurial > pt1.oyama
comparison 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 |
comparison
equal
deleted
inserted
replaced
118:caecbba2a76f | 119:4e7aaa72e158 |
---|---|
34 #define TSS_SUCCESS (0) | 34 #define TSS_SUCCESS (0) |
35 #define TSS_ERROR (-1) | 35 #define TSS_ERROR (-1) |
36 #define TSS_NULL (-2) | 36 #define TSS_NULL (-2) |
37 #define LENGTH_PAT_HEADER (12) | 37 #define LENGTH_PAT_HEADER (12) |
38 #define C_CHAR_COMMA ',' | 38 #define C_CHAR_COMMA ',' |
39 #define LENGTH_TS_HEADER (4) | |
40 #define LENGTH_PES_HEADER (9) | |
41 #define LENGTH_PTS (5) | |
42 | |
43 /* ²þÄûÈǥǥ¸¥¿¥ëÊüÁ÷¶µ²Ê½ñ(¾å) P101 ɽ1 ARIB¤Ç¤ÎPSI/SI¤Î¼ïÎà¤è¤ê»²¾È */ | |
44 #define PAT (0x0000) | |
45 //#define PMT /* PAT¤Ë¤è¤ë´ÖÀÜ»ØÄê */ | |
46 #define CAT (0x0001) | |
47 #define NIT (0x0010) | |
48 #define SDT (0x0011) | |
49 #define BAT (0x0011) | |
50 #define EIT (0x0012) /* 0x0026, 0x0027 */ | |
51 #define RST (0x0013) | |
52 #define TDT (0x0014) /* Ãϥǥ¸¤Ç¤Ï»ÈÍѤµ¤ì¤Ê¤¤ */ | |
53 #define TOT (0x0014) | |
54 #define LIT (0x0020) /* ¤Þ¤¿¤ÏPMT¤Ë¤è¤ë´ÖÀÜ»ØÄê */ | |
55 #define ERT (0x0021) /* ¤Þ¤¿¤ÏPMT¤Ë¤è¤ë´ÖÀÜ»ØÄê */ | |
56 //#define ITT /* PMT¤Ë¤è¤ë´ÖÀÜ»ØÄê */ | |
57 #define PCAT (0x0022) | |
58 #define BIT (0x0024) | |
59 #define NBIT (0x0025) | |
60 //#define ECM /* PMT¤Ë¤è¤ë´ÖÀÜ»ØÄê */ | |
61 //#define EMM /* CAT¤Ë¤è¤ë´ÖÀÜ»ØÄê */ | |
62 #define LDT (0x0025) | |
63 #define DCT (0x0017) | |
64 //#define DTL /* DCT¤Ë¤è¤ë´ÖÀÜ»ØÄê */ | |
65 #define DIT (0x001e) | |
66 #define SIT (0x001f) | |
67 #define SDTT (0x0023) | |
68 #define CDT (0x0029) | |
69 //#define DSM-CC_Section /* PMT¤Ë¤è¤ë´ÖÀÜ»ØÄê */ | |
70 | |
71 /* ¥»¥¯¥·¥ç¥ó¥Ø¥Ã¥ÀĹ */ | |
72 /* TS ¥Ñ¥±¥Ã¥È¤Ë³Æ¥»¥¯¥·¥ç¥ó¤òÀßÃÖ¤¹¤ëºÝ¡¢³ºÅöTS¥Ñ¥±¥Ã¥È¤Î»Ä¥µ¥¤¥º¤¬ | |
73 * ¤¤¤¯¤Ä°Ê¾å¤¢¤ì¤Ð½ñ¤¹þ¤á¤ë¤«¤ÎȽÄê¤Ë»ÈÍѤ¹¤ë¡£ | |
74 * ¥Ç¥³¡¼¥É¤Ë¤Ï¤¢¤Þ¤ê½ÅÍפǤÏ̵¤¤¤«¤â | |
75 */ | |
76 #define SECTION_LENGTH_PAT (8) | |
77 #define SECTION_LENGTH_PMT (8) | |
78 #define SECTION_LENGTH_CAT (8) | |
79 #define SECTION_LENGTH_NIT (8) | |
80 #define SECTION_LENGTH_BIT (8) | |
81 #define SECTION_LENGTH_SDT (11) | |
82 #define SECTION_LENGTH_EIT (14) /* H-EIT, M-EIT, L-EIT ¤ò¼¨¤¹ */ | |
83 #define SECTION_LENGTH_SDTT (15) | |
84 #define SECTION_LENGTH_CDT (13) | |
85 #define SECTION_LENGTH_TOT (10) | |
86 | |
87 enum { | |
88 PTS_FLAG = 0x80, | |
89 DTS_FLAG = 0x40, | |
90 ESCR_FLAG = 0x20, | |
91 ES_RATE_FLAG = 0x10, | |
92 DSM_TRICK_MODE_FLAG = 0x08, | |
93 COPY_INFO_FLAG = 0x04, | |
94 CRC_FLAG = 0x02, | |
95 EXTENSION_FLAG = 0x01 | |
96 }; | |
97 | |
98 enum { | |
99 PES_PRIVATE_DATA_FLAG = 0x80, | |
100 PACK_HEADER_FIELD_FLAG = 0x40, | |
101 PROGRAM_PACKET_SEQUENCE_COUNTER = 0x20, | |
102 PSTD_BUFFER_FLAG = 0x10, | |
103 PES_EXTENSION_FLAG2 = 0x01 | |
104 }; | |
105 | |
106 /* | |
107 * PCR¤«¤éSTC¤òÀ¸À®¤¹¤ë½èÍýÊý¼°(°Æ) | |
108 * 1. PCR¤òÆó¤Ä¼èÆÀ¤¹¤ë¤Þ¤Ç¥ë¡¼¥×(1.¢²4.¤Þ¤Ç¤Ï½é´ü½èÍý¤Ç¼Â»Ü¤¹¤ë¤³¤È) | |
109 * 2. ¥ë¡¼¥×³«»Ï»þ¹ï(PCR)¤È¡¢¥ë¡¼¥×È´¤±¤¿»þ¹ï(PCR)¤Îº¹Ê¬¤ò¼è¤ë | |
110 * 3. ¥ë¡¼¥×³«»Ï¡Á½ªÎ»¤Î´Ö¤Ë½èÍý¤·¤¿¥Ñ¥±¥Ã¥È¿ô¤ò¿ô¤¨¤ë | |
111 * 4. (2.¤ÎPCR¤Î¿Ê¤ó¤À»þ´Ö/3.¤Î¥Ñ¥±¥Ã¥È¿ô)¡¡¤Î·×»»¤Ë¤è¤Ã¤Æ¡¢1¥Ñ¥±¥Ã¥È¤Ë¤è¤Ã¤Æ¿Ê¤àPCR¤òÁÛÄꤹ¤ë | |
112 * 5. TS¼õ¿®»þ¤Ë¡¢1¤Ä¤Î¥Ñ¥±¥Ã¥È¤ò½èÍý¤¹¤ëÅÙ¤Ë4.¤ÎÁÛÄꤹ¤ë·Ð²á»þ¹ï¤òPCR¤Ë¤·¹þ¤ó¤ÇSTC¤È¤¹¤ë | |
113 * 6. PCR¤ò¿·µ¬¤Ë¼èÆÀ¤·¤¿¤é¡¢STC¤òÊäÀµ(¤½¤Î¤Þ¤ÞÂåÆþ)¤¹¤ë | |
114 */ | |
115 #define MAX_VIDEO (16) | |
116 #define MAX_AUDIO (32) | |
117 typedef struct _program_t | |
118 { | |
119 int64_t stc; | |
120 int64_t cue_time; /* Ï¿²è³«»Ï»þ¹ï */ | |
121 int pmt_packet_id; /* ³ºÅöProgram(Service ID)¤ËÂбþ¤¹¤ëPMT */ | |
122 int pmt_version; /* ³ºÅöProgram(Service ID)¤ËÂбþ¤¹¤ëPMT¤ÎVersion */ | |
123 int pcr_packet_id; /* ³ºÅöProgram(Service ID)¤ÎPCR¤òÊÝ»ý¤¹¤ëPID */ | |
124 int64_t pcr1; /* PCR1 */ | |
125 int64_t pcr2; /* PCR2 */ | |
126 int packet_nb; /* PCR·×»»ÍÑ¥«¥¦¥ó¥¿ */ | |
127 int64_t pcr_incr; /* ³ºÅöProgram(Service ID)¤Ë±÷¤¤¤Æ¡¢1¤Ä¤ÎTS¥Ñ¥±¥Ã¥È¤ò½èÍý¤·¤¿»þ¤Ë·Ð²á¤¹¤ë(¤ÈÁÛÄꤹ¤ë»þ´Ö) */ | |
128 int video_start; /* VODEO0¤òÃßÀѳ«»Ï¤·¤Æ¤¤¤ë¡© */ | |
129 int video_pts; /* ºÇ¸å¤Ë½èÍý¤·¤¿VODEO0¤ÎES¤ÎPTS */ | |
130 int video_nb; /* PMT ¤Ë¸ºß¤¹¤ë¥Ó¥Ç¥ª¥¹¥È¥ê¡¼¥à¤Î¿ô */ | |
131 int audio_nb; /* PMT ¤Ë¸ºß¤¹¤ë²»À¼¥¹¥È¥ê¡¼¥à¤Î¿ô */ | |
132 int video[MAX_VIDEO]; /* PS½ÐÎϤ¹¤ë¾ì¹ç¤Ë»È¤¦¤«¤â */ | |
133 int audio[MAX_AUDIO]; /* PS½ÐÎϤ¹¤ë¾ì¹ç¤Ë»È¤¦¤«¤â */ | |
134 //splitpesbuf_t *pesbuf; | |
135 //splitesbuf_t *esbuf; | |
136 } program_t; | |
137 /* | |
138 * program_t ¤ò¥µ¡¼¥Ó¥¹IDʬ½àÈ÷¤·¤Æ¡¢»ÈÍѤ¹¤ë¥¤¥á¡¼¥¸¤Ç¤¤¤¿¤±¤É¡¢ | |
139 * ¥µ¡¼¥Ó¥¹ID¤ÎºÇÂçÃͤÏ0xFFFF¤Ç¤¢¤ë¤Î¤Ç¡¢ÀÅŪ¤Ë³ÎÊݤ¹¤ë¤È stack ¤¬´Êñ¤Ë°î¤ë¤Î¤Ç¡¢ | |
140 * ¼Â¹Ô»þ¤Ë malloc ¤È¤¹¤ë¤«¤Ê¤¡ | |
141 * ËÜÅö¤ÏɬÍפʤÀ¤±alloc¤¹¤ë¤Î¤¬¹¥¤Þ¤·¤¤¤Î¤À¤±¤É¡Ä | |
142 */ | |
143 | |
144 typedef struct _splitpesbuf_t | |
145 { | |
146 program_t *Program; | |
147 int random_access_indicator; /* TS ¤Î random_access_indicator */ | |
148 int size; | |
149 u_char buffer[3*1024*1024]; | |
150 } splitpesbuf_t; | |
151 | |
152 typedef struct _splitesbuf_t | |
153 { | |
154 program_t *Program; | |
155 int64_t pts; | |
156 int64_t dts; | |
157 int started; /* ³ºÅöES¤¬ÃßÀѳ«»Ï¤·¤Æ¤¤¤ë¤« */ | |
158 int random_access_indicator; /* TS ¤Î random_access_indicator */ | |
159 int size; | |
160 u_char buffer[3*1024*1024]; | |
161 } splitesbuf_t; | |
39 | 162 |
40 /** | 163 /** |
41 * splitter¹½Â¤ÂÎ | 164 * splitter¹½Â¤ÂÎ |
42 */ | 165 */ |
43 typedef struct splitter { | 166 typedef struct splitter { |
48 unsigned char pat_count; | 171 unsigned char pat_count; |
49 int pmt_retain; | 172 int pmt_retain; |
50 int pmt_counter; | 173 int pmt_counter; |
51 int avail_pmts[MAX_SERVICES]; | 174 int avail_pmts[MAX_SERVICES]; |
52 int num_pmts; | 175 int num_pmts; |
176 // struct timespec tot_offset; | |
177 // struct timespec STC_timespec; | |
178 int64_t stc; | |
179 int64_t cue_time; | |
180 int status; | |
181 splitpesbuf_t *pesbuf[MAX_PID]; | |
182 splitesbuf_t *esbuf[MAX_PID]; | |
183 program_t *program; | |
184 int pid_sid_table[MAX_PID]; /* pid to sid ¤ÎÊÑ´¹¤ò¹Ô¤¦¤¿¤á¤Î¥Æ¡¼¥Ö¥ë */ | |
53 } splitter; | 185 } splitter; |
54 | 186 |
55 /* b25 decoder would hoard up large chank */ | 187 /* b25 decoder would hoard up large chank */ |
56 typedef struct _splitbuf_t | 188 typedef struct _splitbuf_t |
57 { | 189 { |