Go to the documentation of this file.
49 PictureStartCode = 0x00,
50 SliceStartCodeBegin = 0x01,
51 SliceStartCodeEnd = 0xaf,
56 SequenceStartCode = 0xb3,
59 MPEG2ExtensionStartCode = 0xb5,
60 MPEGReservedB6 = 0xb6,
66 ProgramEndCode = 0xb9,
69 ProgramStreamMap = 0xbc,
71 NonMPEGAudioVideo = 0xbd,
76 MPEGAudioStreamBegin = 0xc0,
78 MPEGAudioStreamEnd = 0xdf,
80 MPEGVideoStreamBegin = 0xe0,
82 MPEGVideoStreamEnd = 0xef,
89 DataH2221Begin = 0xf4,
93 MPEGReservedFA = 0xfa,
95 MPEGReservedFC = 0xfc,
96 MPEGReservedFD = 0xfd,
97 MPEGReservedFE = 0xfe,
98 ProgramStreamDirectory = 0xff,
120 OpenCableVideo = 0x80,
126 MPEG2AACAudio = 0x0f,
127 MPEG2AudioAmd1 = 0x11,
163 AnyMask = 0xFFFF0000,
164 AnyVideo = 0xFFFF0001,
165 AnyAudio = 0xFFFF0002,
198 const QString &sistandard);
200 static QString GetDescription(
uint stream_id);
398 OTV_EIT_TITbeg = 0xA0,
399 OTV_EIT_TITend = 0xA3,
400 OTV_EIT_SUMbeg = 0xA8,
401 OTV_EIT_SUMend = 0xAB,
412 void InitPESPacket(
TSPacket& tspacket);
419 m_fullBuffer =
nullptr;
422 InitPESPacket(
const_cast<TSPacket&
>(tspacket));
423 m_fullBuffer =
const_cast<unsigned char*
>(tspacket.
data());
430 const unsigned char *pesdata,
uint pes_size)
433 m_pesDataSize = pes_size;
434 InitPESPacket(
const_cast<TSPacket&
>(tspacket));
435 int len = pes_size+4;
437 m_allocSize = ((len+m_psiOffset+187)/188)*188;
439 m_pesData = m_fullBuffer + m_psiOffset + 1;
440 memcpy(m_fullBuffer, tspacket.
data(), 188);
441 memcpy(m_pesData, pesdata, pes_size-1);
450 m_pesDataSize = SectionLength();
456 m_pesDataSize = SectionLength();
477 InitPESPacket(
const_cast<TSPacket&
>(table));
479 int len = (4*1024) - 256;
482 m_pesData = m_fullBuffer + m_psiOffset + 1;
488 {
return {tspacket,
false}; }
542 {
return pesdata() + kPsipOffset; }
544 {
return pesdata() + kPsipOffset; }
553 pesdata()[3] = (len>>8) & 0xff;
566 bool HasCRC(
void)
const override;
567 bool HasSectionNumber(
void)
const;
569 bool VerifyPSIP(
bool verify_crc)
const;
571 virtual QString
toString(
void)
const;
572 virtual QString toStringXML(
uint indent_level)
const;
574 static const uint kPsipOffset = 8;
577 QString XMLValues(
uint indent_level)
const;
614 const std::vector<uint>& pnum,
615 const std::vector<uint>& pid);
631 return (((
psipdata()[(i<<2) + 2] & 0x1f) << 8) |
640 for (
uint i = 0; i < ProgramCount(); i++)
641 if (progNum==ProgramNumber(i))
642 return ProgramPID(i);
647 for (
uint i = 0; i < ProgramCount(); i++)
648 if (0!=ProgramNumber(i))
649 return ProgramPID(i);
654 for (
uint i = 0; i < ProgramCount(); i++)
655 if (pid==ProgramPID(i))
656 return ProgramNumber(i);
660 QString
toString(
void)
const override;
667 friend class TestMPEGTables;
699 std::vector<uint> pids, std::vector<uint>
types);
704 const std::vector<uint> &pids,
705 const std::vector<uint> &
types,
706 const std::vector<desc_list_t> &prog_desc);
722 {
return m_ptrs[i][0]; }
725 {
return ((m_ptrs[i][1] << 8) | m_ptrs[i][2]) & 0x1fff; }
728 {
return ((m_ptrs[i][3] << 8) | m_ptrs[i][4]) & 0x0fff; }
731 {
return m_ptrs[i] + 5; }
734 {
return (!m_ptrs.empty()) ? m_ptrs.size()-1 : 0; }
747 m_ptrs[i][1] = ((pid>>8) & 0x1f) | (m_ptrs[i][1] & 0xe0);
748 m_ptrs[i][2] = pid & 0xff;
752 { m_ptrs[i][0] =
type; }
755 bool IsVideo(
uint i,
const QString& sistandard)
const;
756 bool IsAudio(
uint i,
const QString& sistandard)
const;
757 bool IsEncrypted(
const QString& sistandard)
const;
758 bool IsProgramEncrypted(
void)
const;
759 bool IsStreamEncrypted(
uint pid)
const;
761 bool IsStillPicture(
const QString& sistandard)
const;
767 QString StreamDescription(
uint i,
const QString& sistandard)
const;
769 QString GetLanguage(
uint i)
const;
774 const QString &sistandard)
const;
776 const QString &sistandard,
bool normalize)
const;
782 for (
uint i = 0; i < StreamCount(); i++)
783 if (pid == StreamPID(i))
787 uint FindUnusedPID(
uint desired_pid = 0x20)
const;
791 memset(
psipdata(), 0xff, kPmtHeaderMinOffset);
792 SetProgramInfoLength(0);
795 void AppendStream(
uint pid,
uint type,
unsigned char* streamInfo =
nullptr,
uint infoLength = 0);
797 void Parse(
void)
const;
798 QString
toString(
void)
const override;
804 m_ptrs[i][3] = ((length>>8) & 0x0f) | (m_ptrs[i][3] & 0xf0);
805 m_ptrs[i][4] = length & 0xff;
811 SetStreamInfoLength(i, infoLength);
812 if ((streamInfo !=
nullptr) && (infoLength > 0))
813 memcpy(m_ptrs[i] + 5, streamInfo, infoLength);
824 SetProgramInfoLength(infoLength);
825 memcpy(
psipdata() + 4, streamInfo, infoLength);
830 static const uint kPmtHeaderMinOffset = 4;
831 mutable std::vector<unsigned char*>
m_ptrs;
865 QString
toString(
void)
const override;
882 return ((uint64_t(m_data[0] & 0
x1) << 32) |
883 (uint64_t(m_data[1]) << 24) |
884 (uint64_t(m_data[2]) << 16) |
885 (uint64_t(m_data[3]) << 8) |
886 (uint64_t(m_data[4])));
891 virtual QString
toString(int64_t first, int64_t last)
const;
892 virtual QString toStringXML(
893 uint indent_level, int64_t first, int64_t last)
const;
895 uint size(
void)
const {
return IsTimeSpecified() ? 1 : 5; }
904 std::vector<const unsigned char*> ptrs1) :
905 m_ptrs0(std::move(ptrs0)), m_ptrs1(std::move(ptrs1))
914 return ((m_ptrs0[i][0] << 24) | (m_ptrs0[i][1] << 16) |
915 (m_ptrs0[i][2] << 8) | (m_ptrs0[i][3]));
952 std::vector<const unsigned char*> ptrs1) :
953 m_ptrs0(std::move(ptrs0)), m_ptrs1(std::move(ptrs1))
960 return ((m_ptrs1[0][0] << 24) | (m_ptrs1[0][1] << 16) |
961 (m_ptrs1[0][2] << 8) | (m_ptrs1[0][3]));
972 bool IsDuration(
void)
const {
return ( m_ptrs1[0][5] & 0x20 ) != 0; }
994 {
return (m_ptrs1[2][0]<<8) | m_ptrs1[2][1]; }
1001 virtual QString
toString(int64_t first, int64_t last)
const;
1002 virtual QString toStringXML(
1003 uint indent_level, int64_t first, int64_t last)
const;
1058 QString EncryptionAlgorithmString(
void)
const;
1062 pesdata()[4] |= ((val&0x3f) << 1);
1067 return ((uint64_t(
pesdata()[4] & 0
x1) << 32) |
1068 (uint64_t(
pesdata()[5]) << 24) |
1069 (uint64_t(
pesdata()[6]) << 16) |
1070 (uint64_t(
pesdata()[7]) << 8) |
1077 pesdata()[5] = ((val>>24) & 0xff);
1078 pesdata()[6] = ((val>>16) & 0xff);
1079 pesdata()[7] = ((val>>8 ) & 0xff);
1080 pesdata()[8] = ((val ) & 0xff);
1094 pesdata()[11] |= (len >> 8) & 0xf;
1098 enum : std::uint8_t {
1100 kSCTReserved0 = 0x01,
1101 kSCTReserved1 = 0x02,
1102 kSCTReserved2 = 0x03,
1103 kSCTSpliceSchedule = 0x04,
1104 kSCTSpliceInsert = 0x05,
1105 kSCTTimeSignal = 0x06,
1106 kSCTBandwidthReservation = 0x07,
1108 kSCTPrivateCommand = 0xff,
1111 QString SpliceCommandTypeString(
void)
const;
1124 {
return {m_ptrs0, m_ptrs1}; }
1130 {
return {m_ptrs0, m_ptrs1}; }
1157 return (m_epilog[0] << 8) | m_epilog[1];
1164 return (m_epilog) ? m_epilog + 2 :
nullptr;
1180 QString
toString(int64_t first, int64_t last)
const;
1181 QString
toStringXML(
uint indent_level, int64_t first, int64_t last)
const;
1186 const unsigned char *m_epilog {
nullptr};
1216 bool Priority(
void)
const {
return ( m_data[1] & 0x20 ) != 0; }
1223 bool PCR(
void)
const {
return ( m_data[1] & 0x10 ) != 0; }
1227 bool OPCR(
void)
const {
return ( m_data[1] & 0x08 ) != 0; }
1245 bool LTW(
void)
const {
return ( m_data[3] & 0x80 ) != 0; }
1256 #endif // MPEG_TABLES_H
const unsigned char * ProgramInfo(void) const
uint FindAnyPID(void) const
@ DSMCC_B
ISO 13818-6 type B Std DSMCC Data.
uint ProgramPID(uint i) const
uint UniqueProgramID(void) const
QString toString(const QDateTime &raw_dt, uint format)
Returns formatted string representing the time.
@ DSMCC_A
ISO 13818-6 type A Multi-protocol Encap.
@ OpenCableVideo
Always MPEG-2??
ProgramAssociationTable(const PSIPTable &table)
bool SplicingPoint(void) const
splicing_point_flag 1 1.5 (adds 1 byte) (we have splice point data) Splice data is packets until a go...
void SetTableIDExtension(uint len)
uint StreamCount(void) const
SpliceTimeView SpliceTime(void) const
SpliceScheduleView(std::vector< const unsigned char * > ptrs0, std::vector< const unsigned char * > ptrs1)
@ DSMCC_C
ISO 13818-6 type C NPT DSMCC Data.
const unsigned char * Descriptors(void) const
uint Length(void) const
adaptation header length (after which is payload data) 8 0.0
bool IsCurrent(void) const
void SetStreamInfoLength(uint i, uint length)
void SetProgramInfo(unsigned char *streamInfo, uint infoLength)
const unsigned char * StreamInfo(uint i) const
SpliceTimeView(const unsigned char *data)
void SetTranportStreamID(uint gtsid)
ConditionalAccessTable(const PSIPTable &table)
const unsigned char * pesdata() const
uint FindProgram(uint pid) const
A PMT table maps a program described in the ProgramAssociationTable to various PID's which describe t...
@ MPEG2AudioAmd1
ISO 13818-3/AMD-1 Audio using LATM syntax.
int FindPID(uint pid) const
Locates stream index of pid.
uint PCRPID(void) const
stream that contains program clock reference.
uint ExtensionLength(void) const
static const struct wl_interface * types[]
PSIPTable(const TSPacket &tspacket, const unsigned char *pesdata, uint pes_size)
uint ProgramNumber(void) const
std::vector< const unsigned char * > m_ptrs0
uint ProgramCount(void) const
uint ATSCProtocolVersion(void) const
void SetVersionNumber(uint ver)
bool OPCR(void) const
OPCR flag (we have OPCR data) 1 1.4 (adds 6 bytes) ((Original) Program Clock Reference; used to time ...
static constexpr uint8_t GPS_LEAP_SECONDS
Leap seconds as of June 30th, 2022.
uint SectionLengthRaw(void) const
void SetATSCProtocolVersion(int ver)
static const uint kPsipOffset
QString StreamTypeString(uint i) const
Returns a string representation of type at stream index i.
void SetCurrent(bool cur)
static bool IsVideo(uint type)
Returns true iff video is an MPEG1/2/3, H264 or open cable video stream.
bool PrivateIndicator(void) const
uint DescriptorsLength(void) const
bool Discontinuity(void) const
discontinuity_indicator (time base may change) 1 1.0
AdaptationFieldControl(const unsigned char *packet)
@ MPEG_NULL_PID
The all-ones PID value 0x1FFF indicates a Null TS Packet introduced to maintain a constant bit rate o...
Contains listing of PMT Stream ID's for various A/V Stream types.
uint SpliceEventID(void) const
PSIPTable(const TSPacket &table)
A PSIP table is a variant of a PES packet containing an MPEG, ATSC or DVB table.
SpliceInsertView(std::vector< const unsigned char * > ptrs0, std::vector< const unsigned char * > ptrs1)
@ MPEG2AACAudio
ISO 13818-7 Audio w/ADTS syntax.
virtual QString toString(void) const
void RemoveAllStreams(void)
bool SeamlessSplice(void) const
bool PrivateTransportData(void) const
bool IsSpliceImmediate(void) const
uint SpliceCount(void) const
uint TransportStreamID(void) const
uint ProgramNumber(uint i) const
void SetLastSection(uint num)
@ VC1Video
SMPTE 421M video codec (aka VC1) in Blu-Ray.
static bool IsAudio(uint type)
Returns true iff audio is MPEG1/2, AAC, AC3 or DTS audio stream.
@ DSMCC_D
ISO 13818-6 type D Any DSMCC Data.
Used to access the data of a Transport Stream packet.
uint StreamType(uint i) const
PSIPTable(const unsigned char *pesdata)
Constructor for viewing a section, does not create it's own data.
PSIPTable(const TSPacket &tspacket, bool)
@ PREMIERE_EIT_DIREKT_PID
std::vector< const unsigned char * > desc_list_t
ProgramMapTable(const PSIPTable &table)
uint AvailsExpected(void) const
virtual QString toStringXML(uint indent_level) const
bool IsOutOfNetwork(void) const
@ H264Video
ISO 14492-10 & ITU H.264 (aka MPEG-4-AVC)
@ H265Video
ISO 23008-2 & ITU H.265 (aka HEVC, Ultra HD)
void SetStreamPID(uint i, uint pid)
void SetSectionLength(uint length)
Contains Packet Identifier numeric values.
const unsigned char * m_data
The Program Association Table lists all the programs in a stream, and is always found on PID 0.
@ MPEG4Video
ISO 14492-2 (aka MPEG-4)
uint LastSection(void) const
std::vector< const unsigned char * > m_ptrs1
bool IsSpliceEventCancel(void) const
Contains listing of Table ID's for various tables (PAT=0,PMT=2,etc).
void SetStreamProgramInfo(uint i, unsigned char *streamInfo, uint infoLength)
Allows us to transform TS packets to PES packets, which are used to hold multimedia streams and very ...
uint SectionLength(void) const
uint ProgramInfoLength(void) const
bool RandomAccess(void) const
unsigned char * pes_alloc(uint size)
static PSIPTable View(const TSPacket &tspacket)
static constexpr qint64 GPS_EPOCH
Seconds between start of GPS time and the start of UNIX time.
bool IsProgramSplice(void) const
void SetProgramNumber(uint num)
static const char * toString(uint streamID)
void SetStreamID(uint id)
ProgramAssociationTable(const ProgramAssociationTable &table)
@ AC3Audio
A/53 Part 3:2009 6.7.1.
uint AvailNum(void) const
uint TableIDExtension(void) const
void SetSection(uint num)
uint64_t PTSTime(void) const
The CAT is used to transmit additional ConditionalAccessDescriptor instances, in addition to the ones...
PSIPTable(const std::vector< uint8_t > &pesdata)
AdaptationFieldControl is used to transmit various important stream attributes.
static ProgramMapTable ViewData(const unsigned char *pesdata)
@ MPEG2Video
ISO 13818-2 & ITU H.262 (aka MPEG-2)
void SetStreamType(uint i, uint type)
uint FindPID(uint progNum) const
uint SpliceEventID(uint i) const
virtual bool HasCRC() const
1 bit Cyclic Redundancy Check present
static bool IsObjectCarousel(uint type)
Returns true iff stream contains DSMCC Object Carousel.
unsigned char * m_fullBuffer
Pointer to allocated data.
std::vector< const unsigned char * > m_ptrs1
unsigned char * psipdata(void)
static PSIPTable ViewData(const unsigned char *pesdata)
Contains a listing of PES Stream ID's for various PES Packet types.
std::vector< const unsigned char * > m_ptrs0
std::vector< unsigned char * > m_ptrs
uint StreamInfoLength(uint i) const
bool IsTimeSpecified(void) const
@ MPEG1Video
ISO 11172-2 (aka MPEG-1)
bool IsDuration(void) const
uint StreamPID(uint i) const
bool PCR(void) const
PCR flag (we have PCR data) 1 1.3 (adds 6 bytes after adaptation header)
bool Priority(void) const
void SetProgramInfoLength(uint length)
const unsigned char * m_data
ProgramMapTable(const ProgramMapTable &table)
@ EAC3Audio
A/53 Part 3:2009 6.7.3.
bool SectionSyntaxIndicator(void) const
const unsigned char * psipdata(void) const
PSIPTable(const PESPacket &table)
static constexpr unsigned int kSize
uint m_psiOffset
AFCOffset + StartOfFieldPointer.
bool PiecewiseRate(void) const
bool FieldExtension(void) const