17 #ifndef _TS2_PACKET_H_
18 #define _TS2_PACKET_H_
30 #define TS2_NULL_PACKET_PID 0x1FFF
31 #define TS2_INVALID_PID 0xFFFF
34 #define TS2_SYSTEM_CLOCK_FREQUENCY 27000000.0
35 #define TS2_INVALID_PCR_IN_SECS -1.0
36 #define TS2_MAX_PCR_IN_SECS 95443.717696703708
39 #define TS2_PACKET_SIZE 188
40 #define TS2_PACKET_HEADER_SIZE 4
41 #define TS2_PACKET_PAYLOAD_SIZE (TS2_PACKET_SIZE - TS2_PACKET_HEADER_SIZE)
43 #define TS2_PACKET_SYNC_BYTE 0x47
45 #define TS2_PACKET_AF_CLOCK_REFERENCE_DATA_SIZE 6
46 #define TS2_PACKET_AF_EXTENSION_SEAMLESS_SIZE 5
48 #define TS2_STUFFING_BYTE 0xFF
51 #define TS2_PACKET_TRANSPORT_ERROR_INDICATOR_FLAG_MASK 0x04
52 #define TS2_PACKET_PAYLOAD_UNIT_START_INDICATOR_FLAG_MASK 0x02
53 #define TS2_PACKET_TRANSPORT_PRIORITY_FLAG_MASK 0x01
106 ATX_Result (*HandlePacket)(
void* handler_instance,
123 #define TS2_AF_Flags_DiscontinuityIndicator(flags) ((flags) & 0x80)
124 #define TS2_AF_Flags_RandomAccessIndicator(flags) ((flags) & 0x40)
125 #define TS2_AF_Flags_EsPriorityIndicator(flags) ((flags) & 0x20)
126 #define TS2_AF_Flags_PcrFlag(flags) ((flags) & 0x10)
127 #define TS2_AF_Flags_OpcrFlag(flags) ((flags) & 0x08)
128 #define TS2_AF_Flags_SplicingPointFlag(flags) ((flags) & 0x04)
129 #define TS2_AF_Flags_TransportPrivateDataFlag(flags) ((flags) & 0x02)
130 #define TS2_AF_Flags_ExtensionFlag(flags) ((flags) & 0x01)
132 #define TS2_AF_Extension_Flags_LtwFlag(flags) ((flags) & 0x80)
133 #define TS2_AF_Extension_Flags_PiecewiseRateFlag(flags) ((flags) & 0x40)
134 #define TS2_AF_Extension_Flags_SeamlessSpliceFlag(flags) ((flags) & 0x20)
157 ATX_UInt32 transport_error_indicator,
158 ATX_UInt32 payload_unit_start_indicator,
159 ATX_UInt32 transport_priority,
163 ATX_UInt32 continuity_counter);
166 #define TS2_Packet_HasAdaptationField(packet) ((packet)->af_control & 0x02)
167 #define TS2_Packet_HasPayload(packet) ((packet)->af_control & 0x01)
168 #define TS2_Packet_HasPcr(packet) ( \
169 TS2_Packet_HasAdaptationField(packet) && \
170 packet->adaptation_field != NULL && \
171 TS2_AF_Flags_PcrFlag(packet->adaptation_field->flags) \
174 #define TS2_Packet_Flags_TransportError(pflags) (((pflags) & 0x04) >> 2)
175 #define TS2_Packet_Flags_PayloadUnitStart(pflags) (((pflags) & 0x02) >> 1)
176 #define TS2_Packet_Flags_TransportPriority(pflags) (((pflags) & 0x01) )
229 ATX_InputStream* stream);