Wasabi ExpressPlay SDK for Embedded Systems  1.23.0
Ts2Tables.h
Go to the documentation of this file.
1 /*****************************************************************
2 |
3 | MPEG2 Transport Stream - Tables
4 |
5 | $Id: Ts2Tables.h 354 2018-06-28 00:42:39Z pgirish $
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 TS2_EXPORT ATX_Result
165 TS2_PAT_GetPMTPid(const TS2_PAT* self,
166  ATX_UInt16 program_num,
167  ATX_UInt16* pmt_pid);
168 
169 /*----------------------------------------------------------------------
170 | TS2_PMT methods
171 +---------------------------------------------------------------------*/
172 TS2_EXPORT ATX_Result
174 
175 ATX_Result
177 
178 /*----------------------------------------------------------------------
179 | TS2_CAT methods
180 +---------------------------------------------------------------------*/
181 TS2_EXPORT ATX_Result
183 
184 /*----------------------------------------------------------------------
185 | helpers
186 +---------------------------------------------------------------------*/
187 #define TS2_SectionHeader_GetSize(h) \
188  (h)->section_syntax_indicator? \
189  TS2_SECTION_LONG_HEADER_SIZE: \
190  TS2_SECTION_SHORT_HEADER_SIZE
191 
192 #ifdef __cplusplus
193 }
194 #endif
195 
196 #endif /* _TS2_TABLES_H_ */
TS2_SectionHeader header
Definition: Ts2Tables.h:56
Definition: Ts2Tables.h:99
ATX_List * descriptors
Definition: Ts2Tables.h:101
Definition: Ts2Tables.h:86
ATX_UInt8 section_number
Definition: Ts2Tables.h:51
ATX_Result TS2_SectionHeader_Serialize(TS2_SectionHeader *header, ATX_Byte *buffer)
ATX_Result(* ParseSection)(TS2_Table *self)
Definition: Ts2Tables.h:76
Definition: Ts2Tables.h:81
ATX_UInt8 table_id
Definition: Ts2Tables.h:46
ATX_UInt8 private_indicator
Definition: Ts2Tables.h:48
TS2_EXPORT ATX_Result TS2_Table_AddPacket(TS2_Table *self, const TS2_Packet *packet)
same as TS2_Table_AddData where the packet payload is added
ATX_UInt8 last_section_number
Definition: Ts2Tables.h:52
ATX_Result(* CheckTableId)(ATX_UInt8 table_id)
Definition: Ts2Tables.h:75
Definition: Ts2Tables.h:55
Definition: Ts2Tables.h:45
ATX_Result TS2_Table_UpdateSectionBuffer(TS2_Table *self)
TS2_EXPORT ATX_Result TS2_PAT_Construct(TS2_PAT *self)
TS2_EXPORT ATX_Result TS2_CAT_Construct(TS2_CAT *self)
TS2_Table base
Definition: Ts2Tables.h:100
void(* Destruct)(TS2_Table *self)
Definition: Ts2Tables.h:77
ATX_List * program_info_descs
Definition: Ts2Tables.h:95
ATX_UInt16 pcr_pid
Definition: Ts2Tables.h:93
TS2_Section section
Definition: Ts2Tables.h:78
ATX_Boolean TS2_Table_IsEqual(TS2_Table *self, TS2_Table *other)
Definition: Ts2Tables.h:104
ATX_List * elementary_streams
Definition: Ts2Tables.h:96
ATX_UInt16 pid
Definition: Ts2Tables.h:83
ATX_Size TS2_Section_GetPayloadSize(TS2_Section *section)
#define TS2_EXPORT
Definition: Ts2Config.h:67
ATX_Result TS2_PMT_RemoveCADescriptors(TS2_PMT *self)
ATX_Byte * buffer
Definition: Ts2Tables.h:58
Definition: Ts2Tables.h:65
Definition: Ts2Packet.h:91
TS2_EXPORT ATX_Result TS2_PMT_Construct(TS2_PMT *self)
ATX_UInt32 specific
Definition: Ts2Tables.h:50
TS2_Table base
Definition: Ts2Tables.h:87
ATX_Boolean is_complete
Definition: Ts2Tables.h:70
ATX_Result TS2_Table_AddData(TS2_Table *self, const ATX_Byte *data, ATX_Size data_size, ATX_Boolean payload_unit_start)
Definition: Ts2Tables.h:68
TS2_EXPORT ATX_Result TS2_PAT_GetFirstPMTPid(const TS2_PAT *self, ATX_UInt16 *pmt_pid)
TS2_EXPORT ATX_Result TS2_PAT_GetPMTPid(const TS2_PAT *self, ATX_UInt16 program_num, ATX_UInt16 *pmt_pid)
ATX_UInt16 program_number
Definition: Ts2Tables.h:82
ATX_Size bytes_read
Definition: Ts2Tables.h:59
TS2_EXPORT void TS2_Table_Destruct(TS2_Table *self)
Definition: Ts2Tables.h:64
ATX_Result(* UpdateSectionBuffer)(TS2_Table *self)
Definition: Ts2Tables.h:72
ATX_Byte * payload
Definition: Ts2Tables.h:57
TS2_Table base
Definition: Ts2Tables.h:105
Definition: Ts2Tables.h:91
Definition: Ts2Tables.h:63
TS2_Table base
Definition: Ts2Tables.h:92
ATX_Result TS2_Table_SerializeToPackets(TS2_Table *self, ATX_UInt16 pid, ATX_DataBuffer *packets, ATX_UInt32 *continuity_counter)
TS2_Crc_Status
Definition: Ts2Tables.h:62
ATX_UInt16 program_info_length
Definition: Ts2Tables.h:94
ATX_UInt16 section_length
Definition: Ts2Tables.h:49
TS2_Crc_Status crc_status
Definition: Ts2Tables.h:71
ATX_List * programs_to_pids
Definition: Ts2Tables.h:88
ATX_UInt8 section_syntax_indicator
Definition: Ts2Tables.h:47