cvs20080628 - trunk
[gitenigma.git] / include / lib / dvb / lowlevel / ts.h
blob9c68bf0a9762941396fa953e04f9d6b0da96a8ee
2 /*
3 * TRANSPORT STREAM
5 * Copyright (C) 1998, 1999 Thomas Mirlacher
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * The author may be reached as dent@cosy.sbg.ac.at, or
22 * Thomas Mirlacher, Jakob-Haringerstr. 2, A-5020 Salzburg,
23 * Austria
25 *------------------------------------------------------------
29 #ifndef __TS_H__
30 #define __TS_H__
32 #include <sys/types.h>
34 #define TS_SYNC_BYTE 0x47
36 #define TS_LEN 188
37 #define TS_HDR_LEN 4
38 #define TS_DATA_LEN (TS_LEN - TS_HDR_LEN)
40 typedef struct {
41 u_char sync_byte : 8; /* should be 0x47 */
43 #if BYTE_ORDER == BIG_ENDIAN
44 u_char transport_error_indicator : 1;
45 u_char payload_unit_start_indicator : 1;
46 u_char transport_priority : 1;
47 u_char PID_hi : 5;
48 #else
49 u_char PID_hi : 5;
50 u_char transport_priority : 1;
51 u_char payload_unit_start_indicator : 1;
52 u_char transport_error_indicator : 1;
53 #endif
54 u_char PID_lo : 8;
56 #if BYTE_ORDER == BIG_ENDIAN
57 u_char transport_scrambling_control : 2;
58 u_char adaptation_field_control : 2;
59 u_char continuity_counter : 4;
60 #else
61 u_char continuity_counter : 4;
62 u_char adaptation_field_control : 2;
63 u_char transport_scrambling_control : 2;
64 #endif
65 } ts_hdr_t;
67 #define TS_ADAPTATION_FIELD_LEN 1
69 typedef struct {
70 #if BYTE_ORDER == BIG_ENDIAN
71 u_char discontinuity_indicator : 1;
72 u_char random_access_indicator : 1;
73 u_char elementary_stream_priority_indicator : 1;
74 u_char pcr_flag : 1;
75 u_char opcr_flag : 1;
76 u_char splicing_point_flag : 1;
77 u_char transport_private_data_flag : 1;
78 u_char adaptation_field_extension_flag : 1;
79 #else
80 u_char adaptation_field_extension_flag : 1;
81 u_char transport_private_data_flag : 1;
82 u_char splicing_point_flag : 1;
83 u_char opcr_flag : 1;
84 u_char pcr_flag : 1;
85 u_char elementary_stream_priority_indicator : 1;
86 u_char random_access_indicator : 1;
87 u_char discontinuity_indicator : 1;
88 #endif
89 } ts_adapt_fld_t;
91 #define TS_PCR_LEN 6
93 typedef struct {
94 u_char program_clock_reference_base_1 : 8;
96 u_char program_clock_reference_base_2 : 8;
98 u_char program_clock_reference_base_3 : 8;
100 u_char program_clock_reference_base_4 : 8;
102 #if BYTE_ORDER == BIG_ENDIAN
103 u_char program_clock_reference_base_5 : 1;
104 u_char : 6;
105 u_char program_clock_reference_extension_hi : 1;
106 #else
107 u_char program_clock_reference_extension_hi : 1;
108 u_char : 6;
109 u_char program_clock_reference_base_5 : 1;
110 #endif
112 u_char program_clock_reference_extension_lo : 8;
113 } ts_pcr_t;
115 struct ts_opcr_struct {
116 unsigned long long original_program_clock_reference_base: 33;
117 u_char reserved : 6;
118 u_short original_program_clock_reference_extension: 9;
121 struct ts_splicing_point_struct {
122 u_char splice_countdown : 8;
125 struct ts_transport_private_data_struct {
126 u_char transport_private_data_length : 8;
129 struct ts_adaptation_field_extension_struct {
130 #if BYTE_ORDER == BIG_ENDIAN
131 u_char reserved : 5;
132 u_char seamless_splice_flag : 1;
133 u_char piecewise_rate_flag : 1;
134 u_char ltw_flag : 1;
135 u_char adaptation_field_extension_length : 8;
136 #else
137 u_char adaptation_field_extension_length : 8;
138 u_char ltw_flag : 1;
139 u_char piecewise_rate_flag : 1;
140 u_char seamless_splice_flag : 1;
141 u_char reserved : 5;
142 #endif
145 // TODO: CHECK DOWN HERE
147 struct ts_ltw_struct {
148 u_char ltw_calid_flag : 1;
149 u_short ltw_offset : 15;
152 struct ts_piecewise_rate_struct {
153 u_char reserved : 2;
154 u_int piecewise_rate : 22;
157 struct ts_seamless_splice_struct {
158 u_char splice_type : 4;
159 u_char DTS_next_AU_32_30 : 3;
160 u_char marker_bit0 : 1;
161 u_short DTS_next_AU_29_15 : 15;
162 u_char marker_bit1 : 1;
163 u_short DTS_next_AU_14_0 : 15;
164 u_char marker_bit2 : 1;
167 #define TS_PAYLEN 184
168 #define TS_NOSYNC -1 /* no valid sync byte */
169 #define TS_NODATA -2 /* no payload */
170 #define TS_SCRAMBLED -3 /* scrambled - and we can't descramble it */
171 #define TS_INPKT -4 /* doing our reassembling task */
172 #define TS_UNKNOWN -5 /* an unknown error appeared */
174 #endif