Please note that this file is a draft, and is not written by the primary author.
The MPEG-TS stream consists of 204-byte packets.
Observed on HAMTV Samples, every ~38ms (~47 packets), a packet containing a 42-bit PCR timestamp is present. The PCR timestamp is generated by the transmitter on the ISS and so is common across all receiver stations. The most significant 33 bits are based on a 90KHz clock, and so cycle every ~26.5h. The least-significant 9 bits are based on a 27MHz clock.
The TS Merger switches in 'segments' consisting of 'PCR packet ... ... ... PCR packet', this allows each selected segment to be seamlessly aligned with adjacent segments from other receivers.
Also, every packet contains a continuity counter which cycles 0->15 and then repeats.
The TS Merger will attempt to score the received segments by the number of missing packets, detected by processing the continuity counter values in the intervening packets. It is known that this won't be reliable when 15 or more consecutive packets are missing. The best scoring segment available will then be selected to be output.
The segment is chosen by setting 2 index values in the merger data, the first pointing to the station in the stations array, and the second being the station's MX counter id (described below) in the data field, at which the chosen segment starts.
The MX protocol used by 'tspush' to send the files to the merger server also uses an additional 16-bit counter on network packets, allowing us to independently detect network loss, as well as reliably assembling received UDP packets into order.