// Adjust PMT table void adjust_PMT_table ( TS_PMT * packet,
char * buffer )
{
int pos =
12, len =
0;
int i =
0;
packet->table_id = buffer[
0];
packet->section_syntax_indicator = buffer[
1] >>
7;
packet->zero = buffer[
1] >>
6;
packet->reserved_1 = buffer[
1] >>
4;
packet->section_length = (buffer[
1] &
0x0F) <<
8 | buffer[
2];
packet->program_number = buffer[
3] <<
8 | buffer[
4];
packet->reserved_2 = buffer[
5] >>
6;
packet->version_number = buffer[
5] >>
1 &
0x1F;
packet->current_next_indicator = (buffer[
5] <<
7) >>
7;
packet->section_number = buffer[
6];
packet->last_section_number = buffer[
7];
packet->reserved_3 = buffer[
8] >>
5;
packet->PCR_PID = ((buffer[
8] <<
8) | buffer[
9]) &
0x1FFF;
packet->reserved_4 = buffer[
10] >>
4;
packet->program_info_length = (buffer[
10] &
0x0F) <<
8 | buffer[
11];
// Get CRC_32 len = packet->section_length +
3;
packet->CRC_32 = (buffer[len-
4] &
0x000000FF) <<
24 | (buffer[len-
3] &
0x000000FF) <<
16 | (buffer[len-
2] &
0x000000FF) <<
8 | (buffer[len-
1] &
0x000000FF);
// program info descriptor if ( packet->program_info_length !=
0 )
pos += packet->program_info_length;
// Get stream type and PID for ( ; pos <= (packet->section_length +
2 ) -
4; )
{
packet->stream_type = buffer[pos];
packet->reserved_5 = buffer[pos+
1] >>
5;
packet->elementary_PID = ((buffer[pos+
1] <<
8) | buffer[pos+
2]) &
0x1FFF;
packet->reserved_6 = buffer[pos+
3] >>
4;
packet->ES_info_length = (buffer[pos+
3] &
0x0F) <<
8 | buffer[pos+
4];
// Store in es es[i].type = packet->stream_type;
es[i].pid = packet->elementary_PID;
if ( packet->ES_info_length !=
0 )
{
pos = pos+
5;
pos += packet->ES_info_length;
}
else {
pos +=
5;
}
i++;
}
}