TSDuck v3.40-4033
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
tsTS.h File Reference

Common definitions for MPEG Transport Stream layer. More...

Namespaces

namespace  ts
 TSDuck namespace, containing all TSDuck classes and functions.
 

Typedefs

using ts::DTS = cn::duration< std::intmax_t, std::ratio< 1, SYSTEM_CLOCK_SUBFREQ > >
 Definition of a number of DTS units as a std::chrono::duration type.
 
using ts::PacketCounter = uint64_t
 Number of Transport Stream packets.
 
using ts::PCR = cn::duration< std::intmax_t, std::ratio< 1, SYSTEM_CLOCK_FREQ > >
 Definition of a number of PCR units as a std::chrono::duration type.
 
using ts::PID = uint16_t
 PID value (13 bits).
 
using ts::PIDSet = std::bitset< PID_MAX >
 A bit mask for PID values.
 
using ts::PTS = cn::duration< std::intmax_t, std::ratio< 1, SYSTEM_CLOCK_SUBFREQ > >
 Definition of a number of PTS units as a std::chrono::duration type.
 
using ts::SectionCounter = uint64_t
 Number of sections.
 

Enumerations

enum  : uint8_t {
  ts::SC_CLEAR = 0 ,
  ts::SC_DVB_RESERVED = 1 ,
  ts::SC_EVEN_KEY = 2 ,
  ts::SC_ODD_KEY = 3
}
 Scrambling_control values (used in TS and PES packets headers) More...
 
enum  : PID {
  ts::PID_PAT = 0x0000 ,
  ts::PID_CAT = 0x0001 ,
  ts::PID_TSDT = 0x0002 ,
  ts::PID_MPEG_LAST = 0x000F ,
  ts::PID_DVB_FIRST = 0x0010 ,
  ts::PID_NIT = 0x0010 ,
  ts::PID_SDT = 0x0011 ,
  ts::PID_BAT = 0x0011 ,
  ts::PID_EIT = 0x0012 ,
  ts::PID_CIT = 0x0012 ,
  ts::PID_RST = 0x0013 ,
  ts::PID_TDT = 0x0014 ,
  ts::PID_TOT = 0x0014 ,
  ts::PID_NETSYNC = 0x0015 ,
  ts::PID_RNT = 0x0016 ,
  ts::PID_SAT = 0x001B ,
  ts::PID_INBSIGN = 0x001C ,
  ts::PID_MEASURE = 0x001D ,
  ts::PID_DIT = 0x001E ,
  ts::PID_SIT = 0x001F ,
  ts::PID_DVB_LAST = 0x001F ,
  ts::PID_DCT = 0x0017 ,
  ts::PID_ISDB_FIRST = 0x0020 ,
  ts::PID_LIT = 0x0020 ,
  ts::PID_ERT = 0x0021 ,
  ts::PID_PCAT = 0x0022 ,
  ts::PID_SDTT = 0x0023 ,
  ts::PID_BIT = 0x0024 ,
  ts::PID_NBIT = 0x0025 ,
  ts::PID_LDT = 0x0025 ,
  ts::PID_ISDB_EIT_2 = 0x0026 ,
  ts::PID_ISDB_EIT_3 = 0x0027 ,
  ts::PID_SDTT_TER = 0x0028 ,
  ts::PID_CDT = 0x0029 ,
  ts::PID_AMT = 0x002E ,
  ts::PID_ISDB_LAST = 0x002F ,
  ts::PID_IIP = 0x1FF0 ,
  ts::PID_ATSC_FIRST = 0x1FF0 ,
  ts::PID_ATSC_PAT_E = 0x1FF7 ,
  ts::PID_PSIP_TS_E = 0x1FF9 ,
  ts::PID_PSIP = 0x1FFB ,
  ts::PID_ATSC_LAST = 0x1FFE ,
  ts::PID_NULL = 0x1FFF
}
 Predefined PID values. More...
 
enum  : uint8_t {
  ts::AFDID_TIMELINE = 0x04 ,
  ts::AFDID_LOCATION = 0x05 ,
  ts::AFDID_BASEURL = 0x06 ,
  ts::AFDID_CETS_BRANGE = 0x07 ,
  ts::AFDID_3DA_EXTSTREAM = 0x08 ,
  ts::AFDID_3DA_MULTISTREAM = 0x09 ,
  ts::AFDID_3DA_COMMAND = 0x0A ,
  ts::AFDID_BOUNDARY = 0x0B ,
  ts::AFDID_LABELING = 0x0C ,
  ts::AFDID_HEVC_TILE = 0x0D
}
 Adaptation field descriptor tags. More...
 
enum class  ts::BitRateConfidence {
  ts::LOW ,
  ts::PCR_CONTINUOUS ,
  ts::PCR_AVERAGE ,
  ts::CLOCK ,
  ts::HARDWARE ,
  ts::OVERRIDE
}
 Confidence in a bitrate value. More...
 
enum class  ts::PIDClass {
  ts::UNDEFINED ,
  ts::PSI ,
  ts::EMM ,
  ts::ECM ,
  ts::VIDEO ,
  ts::AUDIO ,
  ts::SUBTITLES ,
  ts::DATA ,
  ts::PCR_ONLY ,
  ts::STUFFING
}
 Classification of PID's. More...
 

Functions

uint64_t ts::AbsDiffPCR (uint64_t pcr1, uint64_t pcr2)
 Compute the absolute value of the difference between two PCR's, regardless of their order.
 
uint64_t ts::AddPCR (uint64_t pcr, int64_t offset)
 Add a signed offset to a PCR.
 
template<class Rep , class Period >
int64_t ts::BitDistance (size_t bits, const BitRate &bitrate, const cn::duration< Rep, Period > &duration)
 Compute the number of "data structures" (bytes, packets, etc) transmitted during a given duration.
 
template<class Rep , class Period >
int64_t ts::ByteDistance (const BitRate &bitrate, const cn::duration< Rep, Period > &duration)
 Compute the number of bytes transmitted during a given duration.
 
template<class DURATION = cn::milliseconds>
requires std::integral<typename DURATION::rep>
DURATION ts::ByteInterval (const BitRate &bitrate, std::intmax_t distance)
 Compute the interval, in duration, between two bytes in the transport stream.
 
template<class Rep , class Period >
BitRate ts::BytesBitRate (uint64_t bytes, const cn::duration< Rep, Period > &duration)
 Compute the bitrate from a number of bytes transmitted during a given duration.
 
uint64_t ts::DiffPCR (uint64_t pcr1, uint64_t pcr2)
 Compute the difference between PCR2 and PCR1.
 
uint64_t ts::DiffPTS (uint64_t pts1, uint64_t pts2)
 Compute the difference between PTS2 and PTS1.
 
uint64_t ts::NextPCR (uint64_t last_pcr, PacketCounter distance, const BitRate &bitrate)
 Compute the PCR of a packet, based on the PCR of a previous packet.
 
template<class Rep , class Period >
BitRate ts::PacketBitRate (PacketCounter packets, const cn::duration< Rep, Period > &duration)
 Compute the bitrate from a number of packets transmitted during a given duration.
 
template<class Rep , class Period >
PacketCounter ts::PacketDistance (const BitRate &bitrate, const cn::duration< Rep, Period > &duration)
 Compute the number of packets transmitted during a given duration.
 
template<class DURATION = cn::milliseconds>
requires std::integral<typename DURATION::rep>
DURATION ts::PacketInterval (const BitRate &bitrate, PacketCounter distance)
 Compute the interval, in duration, between two packets.
 
UString ts::PCRToString (uint64_t pcr, bool hexa=true, bool decimal=true, bool ms=true)
 Convert a PCR value to a string.
 
UString ts::PTSToString (uint64_t pts, bool hexa=true, bool decimal=true, bool ms=true)
 Convert a PTS or DTS value to a string.
 
PacketCounter ts::SectionPacketCount (size_t section_size)
 Compute the minimum number of TS packets required to transport a section.
 
BitRate ts::SelectBitrate (const BitRate &bitrate1, BitRateConfidence brc1, const BitRate &bitrate2, BitRateConfidence brc2)
 Select a bitrate from two input values with potentially different levels of confidence.
 
bool ts::SequencedPTS (uint64_t pts1, uint64_t pts2)
 Check if two Presentation Time Stamps are in sequence.
 
BitRate ts::ToBitrate188 (const BitRate &bitrate204)
 Convert 204-byte packet bitrate into 188-byte packet bitrate.
 
BitRate ts::ToBitrate204 (const BitRate &bitrate188)
 Convert 188-byte packet bitrate into 204-byte packet bitrate.
 
bool ts::WrapUpPCR (uint64_t pcr1, uint64_t pcr2)
 Check if PCR2 follows PCR1 after wrap up.
 
bool ts::WrapUpPTS (uint64_t pts1, uint64_t pts2)
 Check if PTS2 follows PTS1 after wrap up.
 

Variables

const PIDSet ts::AllPIDs
 PIDSet constant with all PID's set.
 
constexpr size_t ts::CC_BITS = 4
 Size (in bits) of a Continuity Counter (CC) field.
 
constexpr uint8_t ts::CC_MASK = 0x0F
 Mask to wrap a Continuity Counter (CC) value.
 
constexpr uint8_t ts::CC_MAX = 1 << CC_BITS
 Maximum value of a Continuity Counter (CC).
 
constexpr uint8_t ts::INVALID_CC = 0xFF
 An invalid Continuity Counter (CC) value, typically meaning "undefined".
 
constexpr uint64_t ts::INVALID_DTS = 0xFFFFFFFFFFFFFFFF
 An invalid DTS value, can be used as a marker.
 
constexpr PacketCounter ts::INVALID_PACKET_COUNTER = std::numeric_limits<PacketCounter>::max()
 A impossible value for PacketCounter, meaning "undefined".
 
constexpr uint64_t ts::INVALID_PCR = 0xFFFFFFFFFFFFFFFF
 An invalid PCR (Program Clock Reference) value, can be used as a marker.
 
constexpr uint64_t ts::INVALID_PTS = 0xFFFFFFFFFFFFFFFF
 An invalid PTS value, can be used as a marker.
 
constexpr size_t ts::M2TS_HEADER_SIZE = 4
 Size in bytes of a timestamp preceeding a TS packet in M2TS files (Blu-ray disc).
 
constexpr uint64_t ts::MAX_PCR = PCR_SCALE - 1
 The maximum value possible for a PCR (Program Clock Reference) value.
 
constexpr uint64_t ts::MAX_PTS_DTS = PTS_DTS_SCALE - 1
 The maximum value possible for a PTS/DTS value.
 
const PIDSet ts::NoPID
 PIDSet constant with no PID set.
 
constexpr size_t ts::PCR_BIT_SIZE = 42
 Size in bits of a PCR (Program Clock Reference).
 
constexpr uint64_t ts::PCR_SCALE = PTS_DTS_SCALE * SYSTEM_CLOCK_SUBFACTOR
 Scale factor for PCR values.
 
constexpr size_t ts::PID_BITS = 13
 Size (in bits) of a PID field.
 
constexpr PID ts::PID_MAX = 1 << PID_BITS
 Maximum number of PID's (8192).
 
const PIDClassEnumWrapper ts::PIDClassEnum
 Enumeration description of ts::PIDClass.
 
constexpr size_t ts::PKT_HEADER_SIZE = 4
 MPEG TS packet header size in bytes.
 
constexpr size_t ts::PKT_M2TS_SIZE = M2TS_HEADER_SIZE + PKT_SIZE
 Size in bytes of an TS packet in M2TS files (Blu-ray disc).
 
constexpr size_t ts::PKT_MAX_PAYLOAD_SIZE = PKT_SIZE - PKT_HEADER_SIZE
 MPEG TS packet maximum payload size in bytes.
 
constexpr size_t ts::PKT_RS_SIZE = PKT_SIZE + RS_SIZE
 Size in bytes of a TS packet with trailing Reed-Solomon outer FEC.
 
constexpr size_t ts::PKT_RS_SIZE_BITS = 8 * PKT_RS_SIZE
 Size in bits of a TS packet with trailing Reed-Solomon outer FEC.
 
constexpr size_t ts::PKT_SIZE = 188
 MPEG TS packet size in bytes.
 
constexpr size_t ts::PKT_SIZE_BITS = 8 * PKT_SIZE
 MPEG TS packet size in bits.
 
constexpr size_t ts::PTS_DTS_BIT_SIZE = 33
 Size in bits of a PTS (Presentation Time Stamp) or DTS (Decoding Time Stamp).
 
constexpr uint64_t ts::PTS_DTS_MASK = PTS_DTS_SCALE - 1
 Mask for PTS and DTS values (wrap up at 2^33).
 
constexpr uint64_t ts::PTS_DTS_SCALE = 1LL << PTS_DTS_BIT_SIZE
 Scale factor for PTS and DTS values (wrap up at 2^33).
 
constexpr size_t ts::RS_SIZE = 16
 Size in bytes of a Reed-Solomon outer FEC.
 
constexpr uint8_t ts::SYNC_BYTE = 0x47
 Value of a sync byte (first byte in a TS packet).
 
constexpr uint32_t ts::SYSTEM_CLOCK_FREQ = 27000000
 MPEG-2 System Clock frequency in Hz, used by PCR (27 Mb/s).
 
constexpr uint32_t ts::SYSTEM_CLOCK_SUBFACTOR = 300
 Subfactor of MPEG-2 System Clock subfrequency, used by PTS and DTS.
 
constexpr uint32_t ts::SYSTEM_CLOCK_SUBFREQ = SYSTEM_CLOCK_FREQ / SYSTEM_CLOCK_SUBFACTOR
 MPEG-2 System Clock subfrequency in Hz, used by PTS and DTS (90 Kb/s).
 

Detailed Description

Common definitions for MPEG Transport Stream layer.