A C++ library for handling Transport Stream (TS) packets with texture data transmission functionality.
This library provides functionality to:
- Create and manipulate TS packet headers according to MPEG-2 Transport Stream standard
- Split large texture data into multiple TS packets for transmission
- Receive and reassemble TS packets back into complete texture data
- Manage packet ordering and continuity
- Packet Size: 188 bytes total
- Header Size: 4 bytes
- Payload Size: 184 bytes
- Default PID: 0x40
- Sync Byte: 0x47
The library provides getter/setter functions for all TS packet header fields:
- Sync byte
- Transport error indicator
- Payload unit start indicator
- Transport priority
- PID (Packet Identifier)
- Transport scrambling control
- Adaptation field control
- Continuity counter
Structure for outgoing packets containing:
- 4-byte header
- Frame number (4 bytes)
- Packet counter (1 byte)
- Texture data (179 bytes)
Structure for incoming packets containing:
- Frame number
- Received packet count
- Total texture size
- Expected packet count
- Texture data buffer
Index management structure for packet ordering:
- Array index reference
- Usage flag
// Calculate number of packets needed for texture data
int calcSizeSplitTextureSendInformation(int sizeTextureSend);
// Split texture data into multiple TS packets
int splitTextureSendInformation(SEND_PACKET* sendPacket,
const char* textureSendBuf,
int sizeTextureSend,
int frame,
int* counterHeader);
// Copy packet structure to buffer for transmission
void copySendPacketToBuffer(unsigned char* dist, SEND_PACKET* sendPacket);
// Initialize receive packet list and index management
void initReceivePacketList(RECEIVE_PACKET* receivePacketList,
std::list<RECEIVE_INDEX>* indexList,
int rcvTextureBufSize);
// Process received packets and reassemble texture data
int concatTextureReceiveInformation(RECEIVE_PACKET* receivePacketList,
unsigned char* textureReceiveBuf,
std::list<RECEIVE_INDEX>* indexList,
unsigned char* rcvBuffer);
Code | Description |
---|---|
-1 | ERR_CONCAT_LIST_SIZE - List size verification error |
-2 | ERR_CONCAT_PID - PID is not 0x40 |
-3 | ERR_CONCAT_PAYLOAD - Payload flag error |
-4 | ERR_CONCAT_FRAME_SKIP - Frame skip detected |
-5 | ERR_CONCAT_INDEX - Index error |
- Calculate required packet count
- Initialize send packet list
- Split texture data into packets
- Copy packets to transmission buffer
- Initialize receive packet list and index management
- Process incoming packets with
concatTextureReceiveInformation
- Function returns positive value when complete texture is reassembled
- Clean up with
finalReceivePacketList
- Receive packet list size: 10 packets (configurable via SIZE_OF_RECEIVEPACKET_LIST)
- Debug output: Enable/disable via DEBUG_OUTPUT_SEND_RECEIVE_TEXTURE_ERROR macro
- Standard C++ library
<string.h>
for memory operations<list>
for STL list container