3. psi/si Table
The Psi/si table is composed of one or more child tables, which are identified by table_id, and different child tables are distinguished by table_id and table_id_extension (with the same table_id and different table_id_ extension); A child table is composed of one or more segments (with the same table_id and table_id_extension, different section_number to differentiate); Each segment consists of data from multiple TS packets. Each segment has a complete data structure, and the important parameter of the table----descriptor is transmitted in the paragraph. 3.1 PSI
PSI: (programspecial information) program-specific information sheet.
The PSI information is composed of the program relevance table PAT, the condition receiving table cat, and the Program mapping Table Pmt. The PSI information is used to describe the component structure of TS ; The PSI provides initialization information for delivering programs in a transport flow packet that specifies how to find the specified program from a transport stream carrying multiple programs.
Table name |
Standard |
PID |
table_id |
Details |
PAT (Program correlation table) |
MPEG-2 |
0x0000 |
0x00 |
Defines all the programs in Ts, is the root node of the PSI information, and contains all the programs corresponding to the PMT PID |
PMT (Program mapping table) |
MPEG-2 |
Get from Pat |
0x02 |
Provides a mapping between the program number and the original stream that makes up them, which fully describes which pes the program is composed of and their PID |
CAT (conditional receive table) |
MPEG-2 |
0x0001 |
0x01 |
Provides one or more CA systems and their authorization information, and if the clean stream is disturbed, there must be a cat table containing details of the scrambling system; The PID value of the transport package for conditional access management and authorization information |
3.2 SI
Si:service information. Business Information table
Si information content is described in the hierarchical Order of the Network (network) →transport Strem (Transmission stream) →service (business) →event (event). Si data information is stored according to a certain data structure. Si data mainly include: network information, transmission flow information, business information, business event information, and a large number of information are transmitted through descriptors.
In order to extract all kinds of information in a TS stream, a lot of identities are used in the Psi/si table.
network_id, original_network_id, transport_stream_id, Service ID, event_id, bouquet_id
NETWORK_ID can locate a network
network_id, original_network_id, transport_stream_id can locate a TS stream from which original network is currently playing in which network
network_id, original_network_id, transport_stream_id, Service ID can locate a program, this is the content of SDT table
network_id, original_network_id, transport_stream_id, Service ID, event_id can locate an event within the program, which is the EIT table
network_id, original_network_id, transport_stream_id, bouquet_id can be grouped below a bat, with service_id to locate all the programs in the group.
Table name |
PID |
table_id |
Details |
NIT (Network information table) |
Default 0x0010 Generally obtained from the PAT table |
Current Network: 0x40 Other networks: 0x41 |
Conveys information related to the physical structure of TS streams transmitted through a given network, as well as information related to the characteristics of the network itself. |
SDT (Business description form) |
0x11 |
Current ts:0x42 Other ts:0x46 |
Describes the business that is contained in a particular transport stream. The business may be part of the current transport stream, or it may be part of another transport stream, which can be determined according to TABLE_ID. |
BAT (Business Group table) |
0x11 |
0x4a |
Provides information about the business group. A business group is defined as a set of business, and may span across different networks. |
EIT (Program section information table) |
0x12 |
Current TS:PF 0x4e schedule:0x50-0x5f Other TS:PF 0x4f schedule:0x60-0x6f |
The Event Information table EIT provides information about the events that each business contains in chronological order. According to different table_id, there are four classes of EIT: Current TS PF and schedule information, other TS PF information and sechedule information. |
Analysis of 3.3 tables
After the section, you should follow the PID and table_id to filter the section to the corresponding table of the parsing module to resolve, section_length, such as only the use of parsing variables can be defined as local variables do not save, the other necessary information can be defined in the structure of the body, Save when parsing.
Parsing the table, as long as the table structure of the data one by one can be resolved, the general request data will use a char pointer or array storage, parsing can use the Char *pdata pointer to read the data, each read enough bytes, will pdata+= the last read the number of bytes, This way, you don't have to calculate where the data is read in real time, and writing code is more efficient. Note that if the pdata to the function, the function after the end of the pdata value is still passed that a value, even if the function of the pdata operation will not affect the value of the pdata outside the function, so parsing the descriptor can be pdata down to the child function inside to parse, But when parsing completes, remember to move the pdata back to the length of the descriptor. analysis of 3.3.1 Pat and PMT table
The PAT structural body can be defined as
/*PAT Table Structure * *
typedef struct CSTSPATSECTION_S
{
DWORD m_dwtransport_stream_id;
int m_nloopnum; Number of Programnumber of Pat table
Patprogram *m_pstpatprogram;
struct CSTSPATSECTION_S *m_pstnext;//stores the Pat table in the form of a linked list, which is the next pointer
}patsection;
Pat Table Programnumber 0 of the PID is the NIT table PID, if there is no Programnumber 0 PID, then the default 0x10 for the NIT table PID;
The Parse Pat table only needs to store TSID, Programnumber and PID; If the Pat table has more than one section (typically one), you need to store the information in a linked list
The PMT table must be parsed after the Pat table parsing, get all current program number (Programnumber) and its PID, can request the PMT table, so the PMT table may have many, can be stored in the form of a linked list, also can use the form of the structure body array, In order to be compatible with SDT and other tables, the form of the linked list is finally adopted. Each PMT table can parse out the audio and video PID information, the following can be based on these PID to request audio and video data.
analysis of 3.3.2 NIT, SDT and Bat table
The structure of the three tables, as above, parsing is still in accordance with the PAT, PMT table of the way to parse it, if there are multiple loops on the use of multiple while statements to resolve, the basic can solve the first heavy, followed by more than a few cycles is to write a few of the same child functions.
These tables are likely to have multiple child tables, many of the table also need to be judged, because unlike the Pat table, a frequency point will only have a table, as long as the section to find the full table on the full, and PMT table each PID will have a section, as long as a number of programs corresponding to the PID received all OK. NIT table is divided into actual and other, the table represents the current network and other networks, a network will have more than one ts_id, each ts_id represents a frequency point, each frequency point inside service_id, service_name and other information, So SDT can be judged according to NIT. If it is nit Actual and SDT Actual, just search the current frequency point can be, the sentence is all just to determine whether the section is collected, if it is SDT other table, there may be more than the table, to determine the elimination of the frequency point ts_id, the other ts_id frequency points whether the collection of all, To fully determine whether SDT is fully collected. BAT personal Understanding there is no way to determine in advance how many bouquet_id method, but the number of bouquet_id has a limit, so the bat is a few child tables to collect a few
Analysis of 3.3.3EIT tables
First of all, the EIT table for each child table is not the same, this part should be distinguished from the other tables, EIT table each section of the Section_length upper limit is 4096, and has the concept of segment, Each segment has a maximum of 8 section, so EIT not only to a single section of the whole, but also to segment inside a number of section for the whole, the project analysis inside is the use of Segment_last_section_ Number 8 to take the rest plus one, the result is segment inside a section.
For the EIT child table, must use SDT table, SDT table inside each serviceid has two EIT related fields, respectively, Eit_schedule_flag, Eit_present_following_flag, if two marked 1, This means that the service_id has a corresponding EIT child table, according to which can be sentenced to the full EIT child table.
parsing of 3.3.4 descriptor
Descriptors are present in the section and can be parsed with other important fields of the table, with similar parsing methods.
For psi/si tables, some descriptors are more important, and are generally parsed as follows:
Table name |
Descriptor |
Tag |
Description |
|
Network_name_descriptor |
0x40 |
Provide the name of the network |
|
Service_list_descriptor |
0x41 |
Provide a list of programs under the network |
Nit |
Satellite_delivery_system_descriptor |
0x43 |
Provide information such as satellite related frequency points |
|
Cable_delivery_system_descriptor |
0x44 |
Provide cable related frequency points and other information |
|
Terrestrial_delivery_system_descriptor |
0x5a |
Provide ground-related frequency points and other information |
BAT |
Bouquet_name_descriptor |
0x47 |
Provide group name information |
|
Service_list_descriptor |
0x41 |
Provides a list of programs under a group |
SDT |
Service_descriptor |
0x48 |
Provide program Description information |
Eit |
Short_event_descriptor |
0x4d |
Short Event Descriptor |
|
Extended_event_descriptor |
0x4e |
Expand Information Event Descriptor |