Wasabi ExpressPlay SDK for Embedded Systems  1.10
Ts2Tables.h
Go to the documentation of this file.
1 /*****************************************************************
2 |
3 | MPEG2 Transport Stream - Tables
4 |
5 | $Id: Ts2Tables.h 296 2014-06-25 11:20:09Z jebaseelir $
6 | Original author: Julien Boeuf
7 |
8 | This software is provided to you pursuant to your agreement
9 | with Intertrust Technologies Corporation ("Intertrust").
10 | This software may be used only in accordance with the terms
11 | of the agreement.
12 |
13 | Copyright (c) 2005-2014 by Intertrust. All rights reserved.
14 |
15 ****************************************************************/
16 
17 #ifndef _TS2_TABLES_H_
18 #define _TS2_TABLES_H_
19 
20 /*----------------------------------------------------------------------
21 | includes
22 +---------------------------------------------------------------------*/
23 #include "Atomix.h"
24 #include "Ts2Packet.h"
25 #include "Ts2Utils.h"
26 
27 /*----------------------------------------------------------------------
28 | constants
29 +---------------------------------------------------------------------*/
30 #define TS2_PAT_PID 0
31 #define TS2_CAT_PID 1
32 
33 #define TS2_PAT_TABLE_ID 0x00
34 #define TS2_CAT_TABLE_ID 0x01
35 #define TS2_PMT_TABLE_ID 0x02
36 
37 #define TS2_SECTION_CRC_SIZE 4
38 #define TS2_SECTION_LONG_HEADER_SIZE 8
39 #define TS2_SECTION_SHORT_HEADER_SIZE 3
40 
41 /*----------------------------------------------------------------------
42 | types
43 +---------------------------------------------------------------------*/
44 typedef struct TS2_Table TS2_Table;
45 typedef struct {
46  ATX_UInt8 table_id;
48  ATX_UInt8 private_indicator; /* constant in all tables other than Private tables */
49  ATX_UInt16 section_length;
50  ATX_UInt32 specific; /* data specific to the table type */
51  ATX_UInt8 section_number;
54 
55 typedef struct {
57  ATX_Byte* payload; /* to be used in ParseSection */
58  ATX_Byte* buffer; /* contains the whole section (with header and crc) */
59  ATX_Size bytes_read;
60 } TS2_Section;
61 
62 typedef enum {
67 
68 struct TS2_Table {
69  /* public */
70  ATX_Boolean is_complete;
72  ATX_Result (*UpdateSectionBuffer)(TS2_Table* self); /* only support 1 section for now */
73 
74  /* internal */
75  ATX_Result (*CheckTableId)(ATX_UInt8 table_id);
76  ATX_Result (*ParseSection)(TS2_Table* self);
77  void (*Destruct)(TS2_Table* self);
79 };
80 
81 typedef struct {
82  ATX_UInt16 program_number;
83  ATX_UInt16 pid;
85 
86 typedef struct {
88  ATX_List* programs_to_pids;
89 } TS2_PAT;
90 
91 typedef struct {
93  ATX_UInt16 pcr_pid;
94  ATX_UInt16 program_info_length;
95  ATX_List* program_info_descs; /* List of TS2_Descriptor */
96  ATX_List* elementary_streams; /* List of TS2_ElementaryStream */
97 } TS2_PMT;
98 
99 typedef struct {
101  ATX_List* descriptors;
102 } TS2_CAT;
103 
104 typedef struct {
107 
108 #ifdef __cplusplus
109 extern "C" {
110 #endif
111 
112 /*----------------------------------------------------------------------
113 | TS2_Section methods
114 +---------------------------------------------------------------------*/
115 ATX_Size
117 
118 ATX_Result
120  ATX_Byte* buffer);
121 
122 /*----------------------------------------------------------------------
123 | TS2_Table methods
124 +---------------------------------------------------------------------*/
125 ATX_Result
127  const ATX_Byte* data,
128  ATX_Size data_size,
129  ATX_Boolean payload_unit_start);
130 
134 TS2_EXPORT ATX_Result
136  const TS2_Packet* packet);
137 
138 ATX_Result
140  ATX_UInt16 pid,
141  ATX_DataBuffer* packets,
142  ATX_UInt32* continuity_counter);
143 
144 ATX_Result
146 
147 ATX_Boolean
149  TS2_Table* other);
150 
151 TS2_EXPORT void
153 
154 /*----------------------------------------------------------------------
155 | TS2_PAT methods
156 +---------------------------------------------------------------------*/
157 TS2_EXPORT ATX_Result
159 
160 TS2_EXPORT ATX_Result
161 TS2_PAT_GetFirstPMTPid(const TS2_PAT* self,
162  ATX_UInt16* pmt_pid);
163 
164 /*----------------------------------------------------------------------
165 | TS2_PMT methods
166 +---------------------------------------------------------------------*/
167 TS2_EXPORT ATX_Result
169 
170 ATX_Result
172 
173 /*----------------------------------------------------------------------
174 | TS2_CAT methods
175 +---------------------------------------------------------------------*/
176 TS2_EXPORT ATX_Result
178 
179 /*----------------------------------------------------------------------
180 | helpers
181 +---------------------------------------------------------------------*/
182 #define TS2_SectionHeader_GetSize(h) \
183  (h)->section_syntax_indicator? \
184  TS2_SECTION_LONG_HEADER_SIZE: \
185  TS2_SECTION_SHORT_HEADER_SIZE
186 
187 #ifdef __cplusplus
188 }
189 #endif
190 
191 #endif /* _TS2_TABLES_H_ */