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);
ATX_UInt8 transport_private_data_length
Definition: Ts2Packet.h:72
Definition: Ts2Packet.h:104
ATX_UInt32 piecewise
Definition: Ts2Packet.h:62
TS2_AfControl
Definition: Ts2Packet.h:84
ATX_UInt8 splice_countdown
Definition: Ts2Packet.h:71
ATX_UInt8 flags
Definition: Ts2Packet.h:60
void * instance
Definition: Ts2Packet.h:105
TS2_EXPORT ATX_Result TS2_PacketDispatcher_SetHandler(TS2_PacketDispatcher *self, ATX_UInt16 pid, TS2_PacketHandler handler)
ATX_UInt16 pid
Definition: Ts2Packet.h:93
ATX_Result TS2_PacketDispatcher_ResetDefaultHandler(TS2_PacketDispatcher *self)
void TS2_Packet_Destruct(TS2_Packet *packet)
ATX_Float TS2_AdaptationField_PcrInSecs(TS2_AdaptationField *self)
ATX_Result TS2_Packet_SerializeToBuffer(TS2_Packet *packet, ATX_Byte *buffer)
TS2_PACKET_SIZE bytes will be written into buffer.
struct TS2_PacketPump TS2_PacketPump
Definition: Ts2Packet.h:111
Definition: Ts2Packet.h:87
ATX_UInt8 length
Definition: Ts2Packet.h:67
ATX_UInt8 continuity_counter
Definition: Ts2Packet.h:96
#define TS2_PACKET_AF_CLOCK_REFERENCE_DATA_SIZE
Definition: Ts2Packet.h:45
Definition: Ts2Packet.h:78
Definition: Ts2Packet.h:79
Definition: Ts2Packet.h:80
TS2_EXPORT ATX_Result TS2_PacketPump_ResetStream(TS2_PacketPump *self, ATX_InputStream *stream)
ATX_UInt8 length
Definition: Ts2Packet.h:59
Definition: Ts2Packet.h:86
ATX_UInt8 flags
Definition: Ts2Packet.h:92
ATX_Result TS2_PacketDispatcher_Create(TS2_PacketDispatcher **dispatcher)
#define TS2_EXPORT
Definition: Ts2Config.h:67
Definition: Ts2Packet.h:58
TS2_EXPORT TS2_PacketDispatcher * TS2_PacketPump_GetDispatcher(TS2_PacketPump *self)
TS2_EXPORT ATX_Result TS2_PacketPump_Create(ATX_InputStream *stream, TS2_PacketDispatcher *dispatcher, TS2_PacketPump **pump)
Definition: Ts2Packet.h:66
TS2_ScramblingControl
Definition: Ts2Packet.h:77
Definition: Ts2Packet.h:88
TS2_EXPORT void TS2_PacketPump_Destroy(TS2_PacketPump *self)
Definition: Ts2Packet.h:91
void TS2_FormatPacketHeader(ATX_Byte *buffer, ATX_UInt32 transport_error_indicator, ATX_UInt32 payload_unit_start_indicator, ATX_UInt32 transport_priority, ATX_UInt16 pid, TS2_ScramblingControl scrambling_control, TS2_AfControl af_control, ATX_UInt32 continuity_counter)
void TS2_PacketDispatcher_Destroy(TS2_PacketDispatcher *self)
TS2_EXPORT ATX_Result TS2_PacketPump_Pump(TS2_PacketPump *self)
TS2_ScramblingControl scrambling_control
Definition: Ts2Packet.h:94
struct TS2_PacketDispatcher TS2_PacketDispatcher
Definition: Ts2Packet.h:102
ATX_UInt16 ltw
Definition: Ts2Packet.h:61
ATX_Result TS2_PacketDispatcher_SetDefaultHandler(TS2_PacketDispatcher *self, TS2_PacketHandler handler)
ATX_Size payload_size
Definition: Ts2Packet.h:99
TS2_AfControl af_control
Definition: Ts2Packet.h:95
ATX_Result TS2_PacketDispatcher_Dispatch(TS2_PacketDispatcher *self, TS2_Packet *packet)
ATX_Byte * transport_private_data
Definition: Ts2Packet.h:73
ATX_Result TS2_Packet_InitFromInputStream(ATX_InputStream *stream, TS2_Packet *packet)
TS2_AdaptationField_Extension * extension
Definition: Ts2Packet.h:74
#define TS2_PACKET_SIZE
Definition: Ts2Packet.h:39
ATX_Result TS2_Packet_InitFromBuffer(const ATX_Byte *buffer, TS2_Packet *packet)
#define TS2_PACKET_HEADER_SIZE
Definition: Ts2Packet.h:40
TS2_AdaptationField * adaptation_field
Definition: Ts2Packet.h:97
#define TS2_PACKET_AF_EXTENSION_SEAMLESS_SIZE
Definition: Ts2Packet.h:46
Definition: Ts2Packet.h:85
TS2_EXPORT ATX_Result TS2_PacketDispatcher_ResetHandler(TS2_PacketDispatcher *self, ATX_UInt16 pid)
ATX_Boolean TS2_PacketDispatcher_IsPidUsed(TS2_PacketDispatcher *self, ATX_UInt16 pid)
Definition: Ts2Packet.h:81
ATX_UInt16 TS2_PacketDispatcher_GetNextAvailablePid(TS2_PacketDispatcher *self)
ATX_UInt8 flags
Definition: Ts2Packet.h:68