5 using namespace TS::PSI;
6 using namespace TS::PSI::ARIB;
7 using namespace TS::Description;
8 using namespace TS::Description::ARIB;
10 ServiceInformation::ServiceInformation( int32_t id, DescriptorParser *des_parser)
11 : Section( id, des_parser)
13 si_id.transport_stream_id = 0x00;
15 version_number = 0x00;
16 current_next_indicator = 0x00;
17 section_number = 0x00;
18 last_section_number = 0x00;
21 ServiceInformation::~ServiceInformation()
25 ServiceInformation::STATUS ServiceInformation::parse( SectionBuffer &sec)
27 if( section_syntax_indicator != 0) {
28 if( sec.length() < SI_PARSE_SIZE) {
29 return ERROR_PARSE_SECTION;
32 si_id.transport_stream_id = (sec[ 0] << 8) + sec[ 1];
33 reserved_2 = (sec[ 2] >> 6) & 0x03;
34 version_number = (sec[ 2] >> 1) & 0x1f;
35 current_next_indicator = (sec[ 2] >> 0) & 0x01;
36 section_number = sec[ 3];
37 last_section_number = sec[ 4];
46 NIT::NIT( DescriptorParser *des_parser)
47 : ServiceInformation( -1, des_parser)
49 reserved_future_use1 = 0x00;
50 network_descriptors_length = 0x00;
51 reserved_future_use2 = 0x00;
52 transport_stream_loop_length = 0x00;
63 ServiceInformation::clear();
66 NIT::STATUS NIT::parse( SectionBuffer &sec)
73 STATUS state = ServiceInformation::parse( sec);
74 if( state != SUCCESS) {
78 if( sec.length() < 2) {
79 return ERROR_PARSE_SECTION;
81 reserved_future_use1 = (sec[ 0] >> 4) & 0x0f;
82 network_descriptors_length = ((sec[ 0] & 0x0f) << 8) + sec[ 1];
84 if( sec.length() < network_descriptors_length) {
85 return ERROR_PARSE_SECTION;
87 size = parseDescriptors( sec, network_descriptors_length, &networks);
89 return ERROR_PARSE_SECTION;
93 if( sec.length() < 2) {
94 return ERROR_PARSE_SECTION;
96 reserved_future_use2 = (sec[ 0] >> 4) & 0x0f;
97 transport_stream_loop_length = ((sec[ 0] & 0x0f) << 8) + sec[ 1];
100 while( sec.length() >= STREAM_HEADER_SIZE) {
101 s.transport_stream_id = (sec[ 0] << 8) + sec[ 1];
102 s.original_network_id = (sec[ 2] << 8) + sec[ 3];
103 s.reserved_future_use = (sec[ 4] >> 4) & 0x0f;
104 s.transport_descriptors_length = ((sec[ 4] & 0x0f) << 8) + sec[ 5];
105 sec += STREAM_HEADER_SIZE;
106 if( sec.length() < s.transport_descriptors_length) {
107 return ERROR_PARSE_SECTION;
110 size = parseDescriptors( sec, s.transport_descriptors_length, &s.descriptors);
112 return ERROR_PARSE_SECTION;
115 streams.push_back( s);
122 bool NIT::checkID( uint8_t id)
124 if( id == 0x40 || id <= 0x41) {
136 clearDescriptors( &networks);
138 for( i = streams.begin(); i != streams.end(); i++) {
139 clearDescriptors( &i->descriptors);
145 SDT::SDT( DescriptorParser *des_parser)
146 : ServiceInformation( -1, des_parser)
148 original_network_id = 0x00;
\r
149 reserved_future_use = 0x00;
\r
160 ServiceInformation::clear();
163 SDT::STATUS SDT::parse( SectionBuffer &sec)
\r
170 STATUS state = ServiceInformation::parse( sec);
\r
171 if( state != SUCCESS) {
\r
175 if( sec.length() < SD_PARSE_SIZE) {
176 return ERROR_PARSE_SECTION;
178 original_network_id = (sec[ 0] << 8) + sec[ 1];
179 reserved_future_use = sec[ 2];
\r
180 sec += SD_PARSE_SIZE;
182 while( sec.length() >= SERVICE_HEADER_SIZE) {
\r
183 s.service_id = (sec[ 0] << 8) + sec[ 1];
\r
184 s.reserved_future_use = (sec[ 2] >> 5) & 0x07;
\r
185 s.EIT_user_defined_flags = (sec[ 2] >> 2) & 0x07;
\r
186 s.EIT_schedule_flag = (sec[ 2] >> 1) & 0x01;
\r
187 s.EIT_present_following_flag = (sec[ 2] >> 0) & 0x01;
\r
188 s.running_status = (sec[ 3] >> 5) & 0x07;
\r
189 s.free_CA_mode = (sec[ 3] >> 4) & 0x01;
\r
190 s.descriptors_loop_length = ((sec[ 3] & 0x0f) << 8) + sec[ 4];
191 sec += SERVICE_HEADER_SIZE;
192 if( sec.length() < s.descriptors_loop_length) {
193 return ERROR_PARSE_SECTION;
196 size = parseDescriptors( sec, s.descriptors_loop_length, &s.descriptors);
198 return ERROR_PARSE_SECTION;
201 services.push_back( s);
204 erase_buffer = true;
\r
208 bool SDT::checkID( uint8_t id)
210 if( id == 0x42 || id <= 0x46) {
220 SERVICES::iterator i;
222 for( i = services.begin(); i != services.end(); i++) {
223 clearDescriptors( &i->descriptors);
230 EIT::EIT( DescriptorParser *des_parser)
231 : ServiceInformation( -1, des_parser)
233 transport_stream_id = 0x00;
\r
234 original_network_id = 0x00;
\r
235 segment_last_section_number = 0x00;
\r
236 last_table_id = 0x00;
\r
247 ServiceInformation::clear();
250 EIT::STATUS EIT::parse( SectionBuffer &sec)
\r
257 STATUS state = ServiceInformation::parse( sec);
\r
258 if( state != SUCCESS) {
\r
262 if( sec.length() < EI_PARSE_SIZE) {
263 return ERROR_PARSE_SECTION;
265 transport_stream_id = (sec[ 0] << 8) + sec[ 1];
\r
266 original_network_id = (sec[ 2] << 8) + sec[ 3];
\r
267 segment_last_section_number = sec[ 4];
\r
268 last_table_id = sec[ 5];
\r
269 sec += EI_PARSE_SIZE;
271 while( sec.length() >= EVENT_HEADER_SIZE) {
\r
272 e.event_id = (sec[ 0] << 8) + sec[ 1];
\r
273 e.start_time = Converter::date( &sec[ 2]);
\r
274 e.duration = Converter::time( &sec[ 7]);
\r
275 e.running_status = (sec[ 10] >> 5) & 0x07;
\r
276 e.free_CA_mode = (sec[ 10] >> 4) & 0x01;
\r
277 e.descriptors_loop_length = ((sec[ 10] & 0x0f) << 8) + sec[ 11];
278 sec += EVENT_HEADER_SIZE;
279 if( sec.length() < e.descriptors_loop_length) {
280 return ERROR_PARSE_SECTION;
283 size = parseDescriptors( sec, e.descriptors_loop_length, &e.descriptors);
285 return ERROR_PARSE_SECTION;
288 events.push_back( e);
291 erase_buffer = true;
\r
295 bool EIT::checkID( uint8_t id)
297 if( id >= 0x4E && id <= 0x6F) {
309 for( i = events.begin(); i != events.end(); i++) {
310 clearDescriptors( &i->descriptors);
317 TDT::TDT( DescriptorParser *des_parser)
\r
318 : Section( -1, des_parser)
\r
326 TDT::STATUS TDT::parse( SectionBuffer &sec)
\r
330 if( sec.length() < TD_PARSE_SIZE) {
\r
331 return ERROR_PARSE_SECTION;
\r
334 JST_time = Converter::date( &sec[ 0]);
\r
335 sec += TD_PARSE_SIZE;
\r
337 erase_buffer = true;
\r
341 bool TDT::checkID( uint8_t id)
\r
343 return (id == TDT_ID);
\r
349 TOT::TOT( DescriptorParser *des_parser)
\r
365 TOT::STATUS TOT::parse( SectionBuffer &sec)
\r
371 STATUS state = TDT::parse( sec);
\r
372 if( state != SUCCESS) {
\r
375 if( table_id == TDT_ID) {
\r
379 if( sec.length() < TO_PARSE_SIZE) {
\r
380 return ERROR_PARSE_SECTION;
\r
383 reserved_2 = (sec[ 0] >> 4) & 0x0f;
\r
384 descriptors_loop_length = ((sec[ 0] & 0x0f) << 8) + sec[ 1];
\r
385 sec += TO_PARSE_SIZE;
\r
387 size = parseDescriptors( sec, descriptors_loop_length, &descriptors);
\r
389 return ERROR_PARSE_SECTION;
\r
393 erase_buffer = true;
\r
397 bool TOT::checkID( uint8_t id)
\r
399 if( TDT::checkID( id)) {
402 else if( id == TOT_ID) {
410 void TOT::clearTOT()
\r
412 clearDescriptors( &descriptors);
\r