MythTV  master
mpegtables.h
Go to the documentation of this file.
1 // -*- Mode: c++ -*-
2 // Copyright (c) 2003-2004, Daniel Thor Kristjansson
3 #ifndef MPEG_TABLES_H
4 #define MPEG_TABLES_H
5 
6 #include <cassert>
7 #include <utility>
8 
9 // MythTV headers
10 #include "libmythbase/stringutil.h" // for xml_indent
13 #include "libmythtv/mythtvexp.h"
14 
31 static constexpr qint64 GPS_EPOCH { 315964800 };
32 
34 static constexpr uint8_t GPS_LEAP_SECONDS { 18 };
35 // Note: You can obtain this number by adding one
36 // for every leap second added to UTC since Jan 6th, 1980
37 // and subtracting one for every leap second removed.
38 // See http://en.wikipedia.org/wiki/Leap_second
39 
40 
45 {
46  public:
47  enum
48  {
49  PictureStartCode = 0x00,
50  SliceStartCodeBegin = 0x01,
51  SliceStartCodeEnd = 0xaf,
52  DVBECMData = 0xb0,
53  DVBEMMData = 0xb1,
54  UserData = 0xb2,
56  SequenceStartCode = 0xb3,
57  SequenceError = 0xb4,
59  MPEG2ExtensionStartCode = 0xb5,
60  MPEGReservedB6 = 0xb6,
61  SEQEndCode = 0xb7,
65  GOPStartCode = 0xb8,
66  ProgramEndCode = 0xb9,
67  PackHeader = 0xba,
68  SystemHeader = 0xbb,
69  ProgramStreamMap = 0xbc,
71  NonMPEGAudioVideo = 0xbd,
72  PaddingStream = 0xbe,
74  DVDNavigation = 0xbf,
76  MPEGAudioStreamBegin = 0xc0,
78  MPEGAudioStreamEnd = 0xdf,
80  MPEGVideoStreamBegin = 0xe0,
82  MPEGVideoStreamEnd = 0xef,
83  ECMData = 0xf0,
84  EMMData = 0xf1,
85  DSMCCData = 0xf2,
87  Data13522 = 0xf3,
89  DataH2221Begin = 0xf4,
91  DataH2221End = 0xf8,
92  AncillaryData = 0xf9,
93  MPEGReservedFA = 0xfa,
94  FlexMux = 0xfb, // MPEG-2 13818-1
95  MPEGReservedFC = 0xfc,
96  MPEGReservedFD = 0xfd,
97  MPEGReservedFE = 0xfe,
98  ProgramStreamDirectory = 0xff, // MPEG-2 13818-1
99  };
100 };
101 
102 
110 {
111  public:
112  enum
113  {
114  // video
115  MPEG1Video = 0x01,
116  MPEG2Video = 0x02,
117  MPEG4Video = 0x10,
118  H264Video = 0x1b,
119  H265Video = 0x24,
120  OpenCableVideo = 0x80,
121  VC1Video = 0xea,
122 
123  // audio
124  MPEG1Audio = 0x03,
125  MPEG2Audio = 0x04,
126  MPEG2AACAudio = 0x0f,
127  MPEG2AudioAmd1 = 0x11,
128  AC3Audio = 0x81,
129  EAC3Audio = 0x87,
130  DTSAudio = 0x8a,
131 
132  // DSM-CC Object Carousel
133  DSMCC = 0x08,
134  DSMCC_A = 0x0a,
135  DSMCC_B = 0x0b,
136  DSMCC_C = 0x0c,
137  DSMCC_D = 0x0d,
138  DSMCC_DL = 0x14,
139  MetaDataPES = 0x15,
140  MetaDataSec = 0x16,
141  MetaDataDC = 0x17,
142  MetaDataOC = 0x18,
143  MetaDataDL = 0x19,
144 
145  // other
146  PrivSec = 0x05,
147  PrivData = 0x06,
148 
149  MHEG = 0x07,
150  H222_1 = 0x09,
151 
152  MPEG2Aux = 0x0e,
153 
154  FlexMuxPES = 0x12,
155  FlexMuxSec = 0x13,
156 
157  MPEG2IPMP = 0x1a,
158  MPEG2IPMP2 = 0x7f,
159 
160  Splice = 0x86,
161 
162  // special id's, not actually ID's but can be used in FindPIDs
163  AnyMask = 0xFFFF0000,
164  AnyVideo = 0xFFFF0001,
165  AnyAudio = 0xFFFF0002,
166  };
168  static bool IsVideo(uint type)
169  {
170  return ((StreamID::MPEG1Video == type) ||
171  (StreamID::MPEG2Video == type) ||
172  (StreamID::MPEG4Video == type) ||
173  (StreamID::H264Video == type) ||
174  (StreamID::H265Video == type) ||
175  (StreamID::VC1Video == type) ||
177  }
179  static bool IsAudio(uint type)
180  {
181  return ((StreamID::MPEG1Audio == type) ||
182  (StreamID::MPEG2Audio == type) ||
185  (StreamID::AC3Audio == type) ||
186  (StreamID::EAC3Audio == type) ||
187  (StreamID::DTSAudio == type));
188  }
191  {
192  return ((StreamID::DSMCC_A == type) ||
193  (StreamID::DSMCC_B == type) ||
194  (StreamID::DSMCC_C == type) ||
195  (StreamID::DSMCC_D == type));
196  }
197  static uint Normalize(uint stream_id, const desc_list_t &desc,
198  const QString &sistandard);
199  static const char* toString(uint streamID);
200  static QString GetDescription(uint stream_id);
201 };
202 
206 class PID
207 {
208  public:
209  enum
210  {
211  MPEG_PAT_PID = 0x0000,
212  MPEG_CAT_PID = 0x0001,
213  MPEG_TSDT_PID = 0x0002,
214 
215  DVB_NIT_PID = 0x0010,
216  DVB_SDT_PID = 0x0011,
217  DVB_EIT_PID = 0x0012,
218  DVB_RST_PID = 0x0013,
219  DVB_TDT_PID = 0x0014,
220 
221  // Dishnet longterm EIT is on pid 0x300
223 
224  // Bell longterm EIT is on pid 0x441
226 
227  // MCA
228  MCA_EIT_PID = 0x03fa, // 1018
229 
230  // Premiere EIT for Direkt/Sport PPV
233 
234 
235  ATSC_PSIP_PID = 0x1ffb,
236 
237  SCTE_PSIP_PID = 0x1ffc,
238 
239  // UK Freesat PIDs: SDTo/BAT, longterm EIT, shortterm EIT
240  FREESAT_SI_PID = 0x0f01,
241  FREESAT_EIT_PID = 0x0f02, // 3842
243 
246  MPEG_NULL_PID = 0x1fff,
247 
248  // OpenTV EIT PIDs
253  };
254 };
255 
260 {
261  public:
262  enum
263  {
264  PAT = 0x00, // always on pid 0x00
265  CAT = 0x01, // always on pid 0x01
266  PMT = 0x02,
267  TSDT = 0x03, // always on pid 0x02
268 
269  // DVB mandatory
270  NIT = 0x40, // always on pid 0x10
271  SDT = 0x42, // always on pid 0x11
272  PF_EIT = 0x4e, // always on pid 0x12
273  TDT = 0x70, // always on pid 0x14
274 
275  // DVB optional
276  NITo = 0x41, // always on pid 0x10
277  SDTo = 0x46, // always on pid 0x11
278  BAT = 0x4a, // always on pid 0x11
279  PF_EITo = 0x4f, // always on pid 0x12
280  SC_EITbeg = 0x50, // always on pid 0x12
281  SC_EITend = 0x5f, // always on pid 0x12
282  SC_EITbego = 0x60, // always on pid 0x12
283  SC_EITendo = 0x6f, // always on pid 0x12
284  RST = 0x71, // always on pid 0x13
285  ST = 0x72, // any pid 0x10-0x14
286  TOT = 0x73, // always on pid 0x14
287  RNT = 0x74, // always on pid 0x16
288  CT = 0x75,
289  RCT = 0x76,
290  CIT = 0x77, // always on pid 0x12
291  MPEFEC = 0x78,
292  DIT = 0x7e, // always on pid 0x1e
293  SIT = 0x7f, // always on pid 0x1f
294 
295  // DVB Conditional Access
296  DVBCAbeg = 0x80,
297  DVBCA_81 = 0x81,
298  DVBCA_82 = 0x82,
299  DVBCA_83 = 0x83,
300  DVBCA_84 = 0x84,
301  DVBCA_85 = 0x85,
302  DVBCA_86 = 0x86,
303  DVBCA_87 = 0x87,
304  DVBCA_88 = 0x88,
305  DVBCA_89 = 0x89,
306  DVBCA_8a = 0x8a,
307  DVBCA_8b = 0x8b,
308  DVBCA_8c = 0x8c,
309  DVBCA_8d = 0x8d,
310  DVBCA_8e = 0x8e,
311  DVBCAend = 0x8f,
312 
313  // Dishnet Longterm EIT data
314  DN_EITbego = 0x80, // always on pid 0x300
315  DN_EITendo = 0xfe, // always on pid 0x300
316 
317  // ARIB
318  ARIBbeg = 0x80,
319  ARIBend = 0x8f,
320 
321  // SCTE 57 -- old depreciated standard
322  PIM = 0xC0, // Program Information Message (57 2003) PMT PID
323  PNM = 0xC1, // Program Name Message (57 2003) PMT PID
324  // The PIM and PNM do not have SCTE 65 equivalents.
325 
326  // Under SCTE 57 -- NIM, NTM, VCM, and STM were carried on the
327  // network PID (Table ID 0x0) as defined in the PAT, but under
328  // SCTE 65 the equivalent tables are carried on 0x1FFC
329 
330  NIM = 0xC2, // Network Information Message (57 2003)
331  NTM = 0xC3, // Network Text Message (57 2003)
332  // The NTM is like the SCTE 65 NTT table, except that it
333  // carries more subtable types and the id for the source name
334  // subtable they both share is type 5 rather than 6 which can
335  // cause calimity if not dealt with properly.
336  VCM = 0xC4, // Virtual Channel Message (57 2003)
337  STM = 0xC5, // System Time Message (57 2003)
338 
339  // SCTE 65 -- Current US Cable TV standard
340  NITscte = 0xC2, // Network Information Table (NIT) (65 2002) on 0x1FFC
341  NTT = 0xC3, // Network Text Table (NTT) (65 2002) on 0x1FFC
342  SVCTscte = 0xC4, // Short Virtual Channel Table (65 2002) on 0x1FFC
343  STTscte = 0xC5, // System Time Table (STT) (65 2002) on 0x1FFC
344 
345  // Other SCTE
346  SM = 0xC6, // subtitle_message (27 2003)
347  CEA = 0xD8, // Cable Emergency Alert (18 2002)
348  ADET = 0xD9, // Aggregate Data Event Table (80 2002)
349 
350  // SCTE 35
351  SITscte = 0xFC, // SCTE 35 Splice Info Table (Cueing messages)
352 
353  // ATSC Conditional Access (A/70)
354  // DVB Conditional Access (TS 100 289)
355  ECM0 = 0x80,
356  ECM1 = 0x81,
357  ECMbeg = 0x82, // ECM begin private data
358  ECMend = 0x8f, // ECM end private data
359 
360  // ATSC main
361  MGT = 0xC7, // Master Guide Table A/65 on 0x1ffb
362  TVCT = 0xC8, // Terrestrial Virtual Channel Table A/65 on 0x1ffb
363  CVCT = 0xC9, // Cable Virtual Channel Table A/65 on 0x1ffb
364  RRT = 0xCA, // Region Rating Table A/65 on 0x1ffb
365  EIT = 0xCB, // Event Information Table A/65 (per MGT)
366  ETT = 0xCC, // Extended Text Table A/65 (per MGT)
367  STT = 0xCD, // System Time Table A/65
368  DET = 0xCE, // Data Event Table A/90 (per MGT)
369  DST = 0xCF, // Data Service Table A/90
370 
371  PIT = 0xD0, // Program ID Table ???
372  NRT = 0xD1, // Network Resources Table A/90
373  LTST = 0xD2, // Long Term Service Table A/90
374  DCCT = 0xD3, // Directed Channel Change Table A/57 on 0x1ffb
375  DCCSCT = 0xD4, // DCC Selection Code Table A/57 on 0x1ffb
376  SITatsc = 0xD5, // Selection Information Table (EIA-775.2 2000)
377  AEIT = 0xD6, // Aggregate Event Information Table A/81, SCTE 65
378  AETT = 0xD7, // Aggregate Extended Text Table A/81, SCTE 65
379  SVCT = 0xDA, // Satellite VCT A/81
380 
381  SRM = 0xE0, // System Renewability Message (ATSC TSG-717r0)
382 
383  // Unknown
384  STUFFING = 0x80,
385  CAPTION = 0x86,
386  CENSOR = 0x87,
387 
388  // Private premiere.de
389  PREMIERE_CIT = 0xA0,
390  PREMIERE_CPT = 0xA1,
391 
392  ECN = 0xA0,
393  SRVLOC = 0xA1,
394  TSS = 0xA2,
395  CMPNAME = 0xA3,
396 
397  // OpenTV
398  OTV_EIT_TITbeg = 0xA0, // always on pids config (0x30-0x37)
399  OTV_EIT_TITend = 0xA3, // always on pids config (0x30-0x37)
400  OTV_EIT_SUMbeg = 0xA8, // always on pids config (0x40-0x47)
401  OTV_EIT_SUMend = 0xAB, // always on pids config (0x40-0x47)
402  };
403 };
404 
410 {
412  void InitPESPacket(TSPacket& tspacket)
413  {
414  if (tspacket.PayloadStart())
415  m_psiOffset = tspacket.AFCOffset() + tspacket.StartOfFieldPointer();
416  else
417  {
418  LOG(VB_GENERAL, LOG_ERR, "Started PESPacket, but !payloadStart()");
419  m_psiOffset = tspacket.AFCOffset();
420  }
421  m_pesData = tspacket.data() + m_psiOffset + 1;
422 
423  m_badPacket = true;
424  // first check if Length() will return something useful and
425  // then check if the packet ends in the first TSPacket
426  if ((m_pesData - tspacket.data()) <= (188-3) &&
427  (m_pesData + Length() - tspacket.data()) <= (188-3))
428  {
429  m_badPacket = !VerifyCRC();
430  }
431  }
432 
433  protected:
434  // does not create it's own data
435  PSIPTable(const TSPacket& tspacket, bool /*unused*/)
436  {
437  m_pesData = nullptr;
438  m_fullBuffer = nullptr;
439  m_ccLast = tspacket.ContinuityCounter();
440  m_allocSize = 0;
441  InitPESPacket(const_cast<TSPacket&>(tspacket));
442  m_fullBuffer = const_cast<unsigned char*>(tspacket.data());
443  m_pesDataSize = TSPacket::kSize - (m_pesData - m_fullBuffer);
444  }
445 
446  public:
447  // may be modified
448  PSIPTable(const TSPacket &tspacket,
449  const unsigned char *pesdata, uint pes_size)
450  { // clone
451  m_ccLast = tspacket.ContinuityCounter();
452  m_pesDataSize = pes_size;
453  InitPESPacket(const_cast<TSPacket&>(tspacket)); // sets m_psiOffset
454  int len = pes_size+4;
455  /* make alloc size multiple of 188 */
456  m_allocSize = ((len+m_psiOffset+187)/188)*188;
457  m_fullBuffer = pes_alloc(m_allocSize);
458  m_pesData = m_fullBuffer + m_psiOffset + 1;
459  memcpy(m_fullBuffer, tspacket.data(), 188);
460  memcpy(m_pesData, pesdata, pes_size-1);
461  }
462 
463  public:
465  explicit PSIPTable(const unsigned char *pesdata)
466  : PESPacket(pesdata)
467  {
468  // fixup wrong assumption about length for sections without CRC
469  m_pesDataSize = SectionLength();
470  }
471  explicit PSIPTable(const std::vector<uint8_t> &pesdata)
472  : PESPacket(pesdata)
473  {
474  // fixup wrong assumption about length for sections without CRC
475  m_pesDataSize = SectionLength();
476  }
477  public:
478  PSIPTable(const PSIPTable&) = default;
479  // section_syntax_ind 1 1.0 8 should always be 1
480  // private_indicator 1 1.1 9 should always be 1
481  explicit PSIPTable(const PESPacket& table) : PESPacket(table)
482  {
483  // section_syntax_ind 1 1.0 8 should always be 1
484  // private_indicator 1 1.1 9 should always be 1
485  }
486  // may be modified
487  explicit PSIPTable(const TSPacket& table)
488  {
489  // section_syntax_ind 1 1.0 8 should always be 1
490  // private_indicator 1 1.1 9 should always be 1
491 
492  m_ccLast = table.ContinuityCounter();
493  m_pesDataSize = 188;
494 
495  // clone
496  InitPESPacket(const_cast<TSPacket&>(table)); // sets m_psiOffset
497 
498  int len = (4*1024) - 256; /* ~4KB */
499  m_allocSize = len + m_psiOffset;
500  m_fullBuffer = pes_alloc(m_allocSize);
501  m_pesData = m_fullBuffer + m_psiOffset + 1;
502  memcpy(m_fullBuffer, table.data(), TSPacket::kSize);
503  }
504 
505 
506  static PSIPTable View(const TSPacket& tspacket)
507  { return {tspacket, false}; }
508 
509  static PSIPTable ViewData(const unsigned char* pesdata)
510  { return PSIPTable(pesdata); }
511 
512  // Section Bits Start Byte sbit
513  // -----------------------------------------
514  // table_id 8 0.0 0
515  uint TableID(void) const { return StreamID(); }
516 
517  // section_syntax_ind 1 1.0 8 ATSC -- should always be 1
518  bool SectionSyntaxIndicator(void) const { return ( pesdata()[1] & 0x80 ) != 0; }
519  // private_indicator 1 1.1 9
520  bool PrivateIndicator(void) const { return ( pesdata()[1] & 0x40 ) != 0; }
521  // reserved 2 1.2 10
522 
523  // section_length 12 1.4 12 always less than 0x3fd
524  // adds 3 to the total section length to account for 3 bytes
525  // before the end of the section length field.
526  uint SectionLength(void) const { return Length() + 3; }
527  uint SectionLengthRaw(void) const
528  { return ((pesdata()[1]<<8) | pesdata()[2]) & 0x0fff; }
529 
531  // Things below this line may not apply to SCTE/DVB tables.
532 
533  // table_id_extension 16 3.0 24 table dependent
534  uint TableIDExtension(void) const
535  { return (pesdata()[3]<<8) | pesdata()[4]; }
536 
537  // reserved 2 5.0 40
538 
539  // version_number 5 5.2 42
540  // incremented modulo 32 when table info changes
541  uint Version(void) const { return (pesdata()[5]>>1) & 0x1f; }
542 
543  // current_next_ind 1 5.7 47
544  // if 0 this table is not yet valid, but will be the next psip
545  // table with the same sectionNumber(), tableIDExtension() and
546  // tableID() to become valid.
547  bool IsCurrent(void) const { return bool(pesdata()[5]&1); }
548 
549  // section_number 8 6.0 48
550  uint Section(void) const { return pesdata()[6]; }
551 
552  // last_section_number 8 7.0 56
553  uint LastSection(void) const { return pesdata()[7]; }
554 
555  // Protocol Version for ATSC PSIP tables
556  // protocol_version 8 8.0 64 should always be 0 for now
557  uint ATSCProtocolVersion(void) const { return pesdata()[8]; }
558 
559  // PSIP_table_data x 8.0 72 (incl. protocolVersion)
560  const unsigned char* psipdata(void) const
561  { return pesdata() + kPsipOffset; }
562  unsigned char* psipdata(void)
563  { return pesdata() + kPsipOffset; }
564 
565  // sets
566  void SetTableID(uint id) { SetStreamID(id); }
567  // subtracts 3 from total section length to account for 3 bytes
568  // before the end of the section length field.
569  void SetSectionLength(uint length) { SetLength(length-3); }
571  {
572  pesdata()[3] = (len>>8) & 0xff;
573  pesdata()[4] = len & 0xff;
574  }
576  { pesdata()[5] = (pesdata()[5] & 0xc1) | ((ver & 0x1f)<<1); }
577  void SetCurrent(bool cur)
578  { pesdata()[5] = (pesdata()[5] & 0xfe) | (cur ? 1 : 0); }
579  void SetSection(uint num) { pesdata()[6] = num; }
580  void SetLastSection(uint num) { pesdata()[7] = num; }
581 
582  // Only for real ATSC PSIP tables.
583  void SetATSCProtocolVersion(int ver) { pesdata()[8] = ver; }
584 
585  bool HasCRC(void) const override; // PESPacket
586  bool HasSectionNumber(void) const;
587 
588  bool VerifyPSIP(bool verify_crc) const;
589 
590  virtual QString toString(void) const;
591  virtual QString toStringXML(uint indent_level) const;
592 
593  static const uint kPsipOffset = 8; // general PSIP header offset
594 
595  protected:
596  QString XMLValues(uint indent_level) const;
597 };
598 
618 {
619  public:
621  : PSIPTable(table)
622  {
624  }
625 
626  explicit ProgramAssociationTable(const PSIPTable &table) : PSIPTable(table)
627  {
629  }
630 
631  // transport stream ID, program ID, count
632  static ProgramAssociationTable* Create(uint tsid, uint version,
633  const std::vector<uint>& pnum,
634  const std::vector<uint>& pid);
635 
636  uint TransportStreamID(void) const { return TableIDExtension(); }
637 
638  uint ProgramCount(void) const
639  {
640  if (SectionLength() > (kPsipOffset+2))
641  return (SectionLength()-kPsipOffset-2)>>2;
642  return 0;
643  }
644 
646  { return (psipdata()[(i<<2)] << 8) | psipdata()[(i<<2) + 1]; }
647 
649  {
650  return (((psipdata()[(i<<2) + 2] & 0x1f) << 8) |
651  psipdata()[(i<<2) + 3]);
652  }
653 
655 
656  // helper function
657  uint FindPID(uint progNum) const
658  {
659  for (uint i = 0; i < ProgramCount(); i++)
660  if (progNum==ProgramNumber(i))
661  return ProgramPID(i);
662  return 0;
663  }
664  uint FindAnyPID(void) const
665  {
666  for (uint i = 0; i < ProgramCount(); i++)
667  if (0!=ProgramNumber(i))
668  return ProgramPID(i);
669  return 0;
670  }
671  uint FindProgram(uint pid) const
672  {
673  for (uint i = 0; i < ProgramCount(); i++)
674  if (pid==ProgramPID(i))
675  return ProgramNumber(i);
676  return 0;
677  }
678 
679  QString toString(void) const override; // PSIPTable
680  QString toStringXML(uint indent_level) const override; // PSIPTable
681 
682  private:
683  static ProgramAssociationTable* CreateBlank(bool smallPacket = true);
684 
685  // for testing if CreateBlank create a table with invalid CRC
686  friend class TestMPEGTables;
687 };
688 
695 {
696  public:
697 
699  {
701  Parse();
702  }
703 
704  explicit ProgramMapTable(const PSIPTable& table) : PSIPTable(table)
705  {
707  Parse();
708  }
709 
710  static ProgramMapTable ViewData(const unsigned char* pesdata)
711  {
712  /* needed to call Parse() */
713  return ProgramMapTable(PSIPTable::ViewData(pesdata));
714  }
715 
716  static ProgramMapTable* Create(uint programNumber, uint basepid,
717  uint pcrpid, uint version,
718  std::vector<uint> pids, std::vector<uint> types);
719 
720  static ProgramMapTable* Create(uint programNumber, uint basepid,
721  uint pcrpid, uint version,
722  const desc_list_t &global_desc,
723  const std::vector<uint> &pids,
724  const std::vector<uint> &types,
725  const std::vector<desc_list_t> &prog_desc);
726 
728  uint PCRPID(void) const
729  { return ((psipdata()[0] << 8) | psipdata()[1]) & 0x1fff; }
730 
731  uint ProgramNumber(void) const
732  { return TableIDExtension(); }
733 
735  { return ((psipdata()[2]<<8) | psipdata()[3]) & 0x0fff; }
736 
737  const unsigned char* ProgramInfo(void) const
738  { return psipdata() + 4; }
739 
741  { return m_ptrs[i][0]; }
742 
743  uint StreamPID(uint i) const
744  { return ((m_ptrs[i][1] << 8) | m_ptrs[i][2]) & 0x1fff; }
745 
747  { return ((m_ptrs[i][3] << 8) | m_ptrs[i][4]) & 0x0fff; }
748 
749  const unsigned char* StreamInfo(uint i) const
750  { return m_ptrs[i] + 5; }
751 
752  uint StreamCount(void) const
753  { return (!m_ptrs.empty()) ? m_ptrs.size()-1 : 0; }
754 
755  // sets
756  void SetPCRPID(uint pid)
757  {
758  psipdata()[0] = ((pid >> 8) & 0x1F) | (psipdata()[0] & 0xE0);
759  psipdata()[1] = (pid & 0xFF);
760  }
761 
763 
764  void SetStreamPID(uint i, uint pid)
765  {
766  m_ptrs[i][1] = ((pid>>8) & 0x1f) | (m_ptrs[i][1] & 0xe0);
767  m_ptrs[i][2] = pid & 0xff;
768  }
769 
771  { m_ptrs[i][0] = type; }
772 
773  // helper methods
774  bool IsVideo(uint i, const QString& sistandard) const;
775  bool IsAudio(uint i, const QString& sistandard) const;
776  bool IsEncrypted(const QString& sistandard) const;
777  bool IsProgramEncrypted(void) const;
778  bool IsStreamEncrypted(uint pid) const;
780  bool IsStillPicture(const QString& sistandard) const;
782  QString StreamTypeString(uint i) const
783  { return StreamID::toString(StreamType(i)); }
786  QString StreamDescription(uint i, const QString& sistandard) const;
788  QString GetLanguage(uint i) const;
790  uint GetAudioType(uint i) const;
791 
792  uint FindPIDs(uint type, std::vector<uint> &pids,
793  const QString &sistandard) const;
794  uint FindPIDs(uint type, std::vector<uint> &pids, std::vector<uint> &types,
795  const QString &sistandard, bool normalize) const;
796 
799  int FindPID(uint pid) const
800  {
801  for (uint i = 0; i < StreamCount(); i++)
802  if (pid == StreamPID(i))
803  return i;
804  return -1;
805  }
806  uint FindUnusedPID(uint desired_pid = 0x20) const;
807 
808  void RemoveAllStreams(void)
809  {
810  memset(psipdata(), 0xff, kPmtHeaderMinOffset);
811  SetProgramInfoLength(0);
812  m_ptrs.clear();
813  }
814  void AppendStream(uint pid, uint type, unsigned char* streamInfo = nullptr, uint infoLength = 0);
815 
816  void Parse(void) const;
817  QString toString(void) const override; // PSIPTable
818  QString toStringXML(uint indent_level) const override; // PSIPTable
819  // unsafe sets
820  private:
821  void SetStreamInfoLength(uint i, uint length)
822  {
823  m_ptrs[i][3] = ((length>>8) & 0x0f) | (m_ptrs[i][3] & 0xf0);
824  m_ptrs[i][4] = length & 0xff;
825  }
826 
827  void SetStreamProgramInfo(uint i, unsigned char* streamInfo,
828  uint infoLength)
829  {
830  SetStreamInfoLength(i, infoLength);
831  if ((streamInfo != nullptr) && (infoLength > 0))
832  memcpy(m_ptrs[i] + 5, streamInfo, infoLength);
833  }
834 
836  {
837  psipdata()[2] = ((length>>8) & 0x0f) | (psipdata()[2] & 0xf0);
838  psipdata()[3] = length & 0xff;
839  }
840 
841  void SetProgramInfo(unsigned char *streamInfo, uint infoLength)
842  {
843  SetProgramInfoLength(infoLength);
844  memcpy(psipdata() + 4, streamInfo, infoLength);
845  }
846 
847  static ProgramMapTable* CreateBlank(bool smallPacket = true);
848 
849  static const uint kPmtHeaderMinOffset = 4; // minimum PMT header offset
850  mutable std::vector<unsigned char*> m_ptrs; // used to parse
851 };
852 
858 {
859  public:
860  explicit ConditionalAccessTable(const PSIPTable &table) : PSIPTable(table)
861  {
862  // Section Bits Start Byte sbit
863  // -----------------------------------------
864  // table_id 8 0.0 0
866  // section_syntax_ind 1 1.0 8 should always be 1
867  // private_indicator 1 1.1 9 should always be 0
868  // reserved 2 1.2 10
869  // section_length 12 1.4 12 always less than 0x3fd
870  // table_id_extension 16 3.0 24 unused
871  // reserved 2 5.0 40
872  // version_number 5 5.2 42
873  // current_next_ind 1 5.3 47
874  // section_numben 8 6.0 48
875  // last_section_number 8 7.0 56
876  }
877 
878  // for (i = 0; i < N; i++) 8.0 64
879  // { descriptor() }
881  { return SectionLength() - kPsipOffset; }
882  const unsigned char *Descriptors(void) const { return psipdata(); }
883 
884  QString toString(void) const override; // PSIPTable
885  QString toStringXML(uint indent_level) const override; // PSIPTable
886 
887  // CRC_32 32 rpchof
888 };
889 
891 {
892  public:
893  explicit SpliceTimeView(const unsigned char *data) : m_data(data) { }
894  // time_specified_flag 1 0.0
895  bool IsTimeSpecified(void) const { return ( m_data[0] & 0x80 ) != 0; }
896  // if (time_specified_flag == 1)
897  // reserved 6 0.1
898  // pts_time 33 0.6
899  uint64_t PTSTime(void) const
900  {
901  return ((uint64_t(m_data[0] & 0x1) << 32) |
902  (uint64_t(m_data[1]) << 24) |
903  (uint64_t(m_data[2]) << 16) |
904  (uint64_t(m_data[3]) << 8) |
905  (uint64_t(m_data[4])));
906  }
907  // else
908  // reserved 7 0.1
909  // }
910  virtual QString toString(int64_t first, int64_t last) const;
911  virtual QString toStringXML(
912  uint indent_level, int64_t first, int64_t last) const;
913 
914  uint size(void) const { return IsTimeSpecified() ? 1 : 5; }
915  private:
916  const unsigned char *m_data;
917 };
918 
920 {
921  public:
922  SpliceScheduleView(std::vector<const unsigned char*> ptrs0,
923  std::vector<const unsigned char*> ptrs1) :
924  m_ptrs0(std::move(ptrs0)), m_ptrs1(std::move(ptrs1))
925  {
926  }
927  // splice_count 8 14.0
928  uint SpliceCount(void) const { return std::min(m_ptrs0.size(), m_ptrs1.size()); }
929 
930  // splice_event_id 32 0.0 + m_ptrs0[i]
932  {
933  return ((m_ptrs0[i][0] << 24) | (m_ptrs0[i][1] << 16) |
934  (m_ptrs0[i][2] << 8) | (m_ptrs0[i][3]));
935  }
936  // splice_event_cancel_indicator 1 4.0 + m_ptrs0[i]
937  // reserved 7 4.1 + m_ptrs0[i]
938  // if (splice_event_cancel_indicator == ‘0’) {
939  // out_of_network_indicator 1 5.0 + m_ptrs0[i]
940  // program_splice_flag 1 5.1 + m_ptrs0[i]
941  // duration_flag 1 5.2 + m_ptrs0[i]
942  // reserved 5 5.3 + m_ptrs0[i]
943  // if (program_splice_flag == ‘1’)
944  // utc_splice_time 32 6.0 + m_ptrs0[i]
945  // else {
946  // component_count 8 6.0 + m_ptrs0[i]
947  // for(j = 0; j < component_count; j++) {
948  // component_tag 8 7.0 + m_ptrs0[i]+j*5
949  // utc_splice_time 32 8.0 + m_ptrs0[i]+j*5
950  // }
951  // }
952  // if (duration_flag) {
953  // auto_return 1 0.0 + m_ptrs1[i]
954  // reserved 6 0.1 + m_ptrs1[i]
955  // duration 33 0.7 + m_ptrs1[i]
956  // }
957  // unique_program_id 16 0.0 + m_ptrs1[i] + (duration_flag)?5:0
958  // avail_num 8 2.0 + m_ptrs1[i] + (duration_flag)?5:0
959  // avails_expected 8 3.0 + m_ptrs1[i] + (duration_flag)?5:0
960  // }
961 
962  private:
963  std::vector<const unsigned char*> m_ptrs0;
964  std::vector<const unsigned char*> m_ptrs1;
965 };
966 
968 {
969  public:
970  SpliceInsertView(std::vector<const unsigned char*> ptrs0,
971  std::vector<const unsigned char*> ptrs1) :
972  m_ptrs0(std::move(ptrs0)), m_ptrs1(std::move(ptrs1))
973  {
974  }
975 
976  // splice_event_id 32 0.0 + m_ptrs1[0]
977  uint SpliceEventID(void) const
978  {
979  return ((m_ptrs1[0][0] << 24) | (m_ptrs1[0][1] << 16) |
980  (m_ptrs1[0][2] << 8) | (m_ptrs1[0][3]));
981  }
982  // splice_event_cancel 1 4.0 + m_ptrs1[0]
983  bool IsSpliceEventCancel(void) const { return ( m_ptrs1[0][4] & 0x80 ) != 0; }
984  // reserved 7 4.1 + m_ptrs1[0]
985  // if (splice_event_cancel_indicator == 0) {
986  // out_of_network_flag 1 5.0 + m_ptrs1[0]
987  bool IsOutOfNetwork(void) const { return ( m_ptrs1[0][5] & 0x80 ) != 0; }
988  // program_splice_flag 1 5.1 + m_ptrs1[0]
989  bool IsProgramSplice(void) const { return ( m_ptrs1[0][5] & 0x40 ) != 0; }
990  // duration_flag 1 5.2 + m_ptrs1[0]
991  bool IsDuration(void) const { return ( m_ptrs1[0][5] & 0x20 ) != 0; }
992  // splice_immediate_flag 1 5.3 + m_ptrs1[0]
993  bool IsSpliceImmediate(void) const { return ( m_ptrs1[0][5] & 0x20 ) != 0; }
994  // reserved 4 5.4 + m_ptrs1[0]
995  // if ((program_splice_flag == 1) && (splice_immediate_flag == ‘0’))
996  // splice_time() 8-38 6.0 + m_ptrs1[0]
998  { return SpliceTimeView(m_ptrs1[0]+6); }
999  // if (program_splice_flag == 0) {
1000  // component_count 8 6.0 + m_ptrs1[0]
1001  // for (i = 0; i < component_count; i++) {
1002  // component_tag 8 0.0 + m_ptrs0[i]
1003  // if (splice_immediate_flag == ‘0’)
1004  // splice_time() 8-38 1.0 + m_ptrs0[i]
1005  // }
1006  // }
1007  // if (duration_flag == ‘1’)
1008  // auto_return 1 0.0 + m_ptrs1[1]
1009  // reserved 6 0.1 + m_ptrs1[1]
1010  // duration 33 0.7 + m_ptrs1[1]
1011  // unique_program_id 16 0.0 + m_ptrs1[2]
1012  uint UniqueProgramID(void) const
1013  { return (m_ptrs1[2][0]<<8) | m_ptrs1[2][1]; }
1014  // avail_num 8 2.0 + m_ptrs1[2]
1015  uint AvailNum(void) const { return m_ptrs1[2][2]; }
1016  // avails_expected 8 3.0 + m_ptrs1[2]
1017  uint AvailsExpected(void) const { return m_ptrs1[2][3]; }
1018  // }
1019 
1020  virtual QString toString(int64_t first, int64_t last) const;
1021  virtual QString toStringXML(
1022  uint indent_level, int64_t first, int64_t last) const;
1023 
1024  private:
1025  std::vector<const unsigned char*> m_ptrs0;
1026  std::vector<const unsigned char*> m_ptrs1;
1027 };
1028 
1030 {
1031  public:
1033  PSIPTable(table)
1034  {
1036  Parse();
1037  }
1038  explicit SpliceInformationTable(const PSIPTable &table) :
1039  PSIPTable(table)
1040  {
1042  Parse();
1043  }
1044  ~SpliceInformationTable() override { ; }
1045 
1046  void setSCTEPID(int ts_pid){m_sctePid = ts_pid;}
1047  int getSCTEPID(void) const {return m_sctePid;}
1048 
1049  // ANCE/SCTE 35 2007
1050  // Name bits loc expected value
1051  // table_id 8 0.0 0xFC
1052  // section_syntax_indicator 1 1.0 1
1053  // private_indicator 1 1.1 0
1054  // reserved 2 1.2 3
1055  // section_length 12 1.4
1056  // ^^^ All above this line provided by PSIPTable
1057  // protocol_version 8 3.0 0
1058  uint SpliceProtocolVersion(void) const { return pesdata()[3]; }
1059  void SetSpliceProtocolVersion(uint ver) { pesdata()[3] = ver; }
1060  // encrypted_packet 1 4.0
1061  bool IsEncryptedPacket(void) const { return ( pesdata()[4] & 0x80 ) != 0; }
1062  void SetEncryptedPacket(bool val)
1063  {
1064  pesdata()[4] = (pesdata()[4] & ~0x80) | ((val) ? 0x80 : 0);
1065  }
1066  // encryption_algorithm 6 4.1
1067  enum
1068  {
1069  kNoEncryption = 0,
1070  kECB = 1, // DES - ECB mode, FIPS PUB 81 (8 byte blocks)
1071  kCBC = 2, // DES - CBC mode, FIPS PUB 81 (8 byte blocks)
1072  k3DES = 3, // 3 DES - TDEA, FIPS PUB 46-3 (8 byte blocks)
1073  // values 4-31 are reserved for future extension
1074  // values 32-63 are user private
1075  };
1076  uint EncryptionAlgorithm(void) const { return (pesdata()[4] >> 1) & 0x3f; }
1077  QString EncryptionAlgorithmString(void) const;
1079  {
1080  pesdata()[4] &= 0x81;
1081  pesdata()[4] |= ((val&0x3f) << 1);
1082  }
1083  // pts_adjustment 33 4.7
1084  uint64_t PTSAdjustment(void) const
1085  {
1086  return ((uint64_t(pesdata()[4] & 0x1) << 32) |
1087  (uint64_t(pesdata()[5]) << 24) |
1088  (uint64_t(pesdata()[6]) << 16) |
1089  (uint64_t(pesdata()[7]) << 8) |
1090  (uint64_t(pesdata()[8])));
1091  }
1092  void SetPTSAdjustment(uint64_t val)
1093  {
1094  pesdata()[4] &= ~0x1;
1095  pesdata()[4] |= (val>>32) & 0x1;
1096  pesdata()[5] = ((val>>24) & 0xff);
1097  pesdata()[6] = ((val>>16) & 0xff);
1098  pesdata()[7] = ((val>>8 ) & 0xff);
1099  pesdata()[8] = ((val ) & 0xff);
1100  }
1101  // cw_index (enc key) 8 9.0
1102  uint CodeWordIndex(void) const { return pesdata()[9]; }
1103  void SetCodeWordIndex(uint val) { pesdata()[9] = val; }
1104  // reserved 12 10.0
1105  // splice_command_length 12 11.4
1107  {
1108  return ((pesdata()[11] & 0xf) << 8) | pesdata()[12];
1109  }
1111  {
1112  pesdata()[11] &= ~0xf;
1113  pesdata()[11] |= (len >> 8) & 0xf;
1114  pesdata()[12] = len & 0xff;
1115  }
1116  // splice_command_type 8 13.0
1117  enum {
1118  kSCTNull = 0x00,
1119  kSCTReserved0 = 0x01,
1120  kSCTReserved1 = 0x02,
1121  kSCTReserved2 = 0x03,
1122  kSCTSpliceSchedule = 0x04,
1123  kSCTSpliceInsert = 0x05,
1124  kSCTTimeSignal = 0x06,
1125  kSCTBandwidthReservation = 0x07,
1126  // 0x08-0xfe reserved
1127  kSCTPrivateCommand = 0xff,
1128  };
1129  uint SpliceCommandType(void) const { return pesdata()[13]; }
1130  QString SpliceCommandTypeString(void) const;
1131  void SetSpliceCommandType(uint type) { pesdata()[13] = type & 0xff; }
1132 
1133  // ALL BELOW THIS LINE OTHER THAN CRC_32 ARE ENCRYPTED IF FLAG SET
1134 
1136 
1137  // nothing here, info in descriptors
1138 
1140 
1141  // if (splice_command_type == 0x04) splice_schedule()
1143  { return {m_ptrs0, m_ptrs1}; }
1144 
1146 
1147  // if (splice_command_type == 0x05) splice_insert()
1149  { return {m_ptrs0, m_ptrs1}; }
1150 
1152 
1153  // if (splice_command_type == 0x06) splice_time()
1155  { return SpliceTimeView(pesdata()+14); }
1156 
1158 
1159  // nothing here, info in descriptors
1160 
1162 
1163  // if (splice_command_type == 0xff) private_command()
1164  // identifier 32 14.0
1165  // for (i = 0; i < N; i++)
1166  // private_byte 8 ??.0
1167  //
1168 
1170  // NOTE: Aside from CRC's we can not interpret things below
1171  // this comment with private or reserved commands.
1172 
1173  // descriptor_loop_length 16 0.0 + m_epilog
1175  {
1176  return (m_epilog[0] << 8) | m_epilog[1];
1177  }
1178 
1179  // for (i = 0; i < ? ; i++)
1180  // splice_descriptor() ?? ??.?
1181  const unsigned char *SpliceDescriptors(void) const
1182  {
1183  return (m_epilog) ? m_epilog + 2 : nullptr;
1184  }
1185  // for (i = 0; i < ?; i++)
1186  // alignment_stuffing 8 ??.0
1187  // if (encrypted_packet())
1188  // E_CRC_32 32 ??.0
1189  // CRC_32 32 ??.0
1190 
1191  static SpliceInformationTable *GetDecrypted(const QString &codeWord);
1192  bool Parse(void);
1193 
1194  QString toString(void) const override // PSIPTable
1195  { return toString(-1LL, -1LL); }
1196  QString toStringXML(uint indent_level) const override // PSIPTable
1197  { return toStringXML(indent_level, -1LL, -1LL); }
1198 
1199  QString toString(int64_t first, int64_t last) const;
1200  QString toStringXML(uint indent_level, int64_t first, int64_t last) const;
1201 
1202  private:
1203  std::vector<const unsigned char*> m_ptrs0;
1204  std::vector<const unsigned char*> m_ptrs1;
1205  const unsigned char *m_epilog {nullptr};
1206  int m_sctePid {0};
1207 };
1208 
1219 {
1220  public:
1221  explicit AdaptationFieldControl(const unsigned char* packet) : m_data(packet) { ; }
1222 
1226  uint Length(void) const { return m_data[0]; }
1227 
1231  bool Discontinuity(void) const { return ( m_data[1] & 0x80 ) != 0; }
1232  // random_access_indicator (?) 1 1.1
1233  bool RandomAccess(void) const { return ( m_data[1] & 0x40 ) != 0; }
1234  // elementary_stream_priority_indicator 1 1.2
1235  bool Priority(void) const { return ( m_data[1] & 0x20 ) != 0; }
1236 
1237 // Each of the following extends the adaptation header. In order:
1238 
1242  bool PCR(void) const { return ( m_data[1] & 0x10 ) != 0; }
1246  bool OPCR(void) const { return ( m_data[1] & 0x08 ) != 0; }
1254  bool SplicingPoint(void) const { return ( m_data[1] & 0x04 ) != 0; }
1255  // transport_private_data_flag 1 1.6
1256  // (adds 1 byte)
1257  bool PrivateTransportData(void) const { return ( m_data[1] & 0x02 ) != 0; }
1258  // adaptation_field_extension_flag 1 1.7
1259  bool FieldExtension(void) const { return ( m_data[1] & 0x01 ) != 0; }
1260  // extension length 8 2.0
1261  uint ExtensionLength(void) const { return m_data[2]; }
1262  // ltw flag 1 3.0
1263  // (adds 2 bytes)
1264  bool LTW(void) const { return ( m_data[3] & 0x80 ) != 0; }
1265  // piecewise_rate_flag (adds 3 bytes) 1 3.1
1266  bool PiecewiseRate(void) const { return ( m_data[3] & 0x40 ) != 0; }
1267  // seamless_splice_flag (adds 5 bytes) 1 3.2
1268  bool SeamlessSplice(void) const { return ( m_data[3] & 0x20 ) != 0; }
1269  // unused flags 5 3.3
1270 
1271  private:
1272  const unsigned char* m_data;
1273 };
1274 
1275 #endif // MPEG_TABLES_H
ProgramMapTable::ProgramInfo
const unsigned char * ProgramInfo(void) const
Definition: mpegtables.h:737
StreamID::H264Video
@ H264Video
ISO 14492-10 & ITU H.264 (aka MPEG-4-AVC)
Definition: mpegtables.h:118
ProgramAssociationTable::FindAnyPID
uint FindAnyPID(void) const
Definition: mpegtables.h:664
PID::OTV_EIT_SUP_PID_START
@ OTV_EIT_SUP_PID_START
Definition: mpegtables.h:251
ProgramAssociationTable::ProgramPID
uint ProgramPID(uint i) const
Definition: mpegtables.h:648
SpliceInsertView::UniqueProgramID
uint UniqueProgramID(void) const
Definition: mpegtables.h:1012
bool
bool
Definition: pxsup2dast.c:30
SpliceInformationTable::m_ptrs1
std::vector< const unsigned char * > m_ptrs1
Definition: mpegtables.h:1204
TSHeader::PayloadStart
bool PayloadStart(void) const
Definition: tspacket.h:87
PSIPTable::SetTableID
void SetTableID(uint id)
Definition: mpegtables.h:566
MythDate::toString
QString toString(const QDateTime &raw_dt, uint format)
Returns formatted string representing the time.
Definition: mythdate.cpp:84
SpliceInformationTable::TimeSignal
SpliceTimeView TimeSignal(void) const
Definition: mpegtables.h:1154
PSIPTable::InitPESPacket
void InitPESPacket(TSPacket &tspacket)
Only handles single TS packet PES packets, for PMT/PAT tables basically.
Definition: mpegtables.h:412
SpliceInformationTable::SetEncryptionAlgorithm
void SetEncryptionAlgorithm(uint val)
Definition: mpegtables.h:1078
StreamID::H265Video
@ H265Video
ISO 23008-2 & ITU H.265 (aka HEVC, Ultra HD)
Definition: mpegtables.h:119
TSPacket::StartOfFieldPointer
unsigned int StartOfFieldPointer(void) const
Definition: tspacket.h:252
PID::SCTE_PSIP_PID
@ SCTE_PSIP_PID
Definition: mpegtables.h:237
PID::DVB_DNLONG_EIT_PID
@ DVB_DNLONG_EIT_PID
Definition: mpegtables.h:222
ProgramAssociationTable::ProgramAssociationTable
ProgramAssociationTable(const PSIPTable &table)
Definition: mpegtables.h:626
AdaptationFieldControl::SplicingPoint
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...
Definition: mpegtables.h:1254
PSIPTable::SetTableIDExtension
void SetTableIDExtension(uint len)
Definition: mpegtables.h:570
ProgramMapTable::StreamCount
uint StreamCount(void) const
Definition: mpegtables.h:752
mpegdescriptors.h
SpliceInsertView::SpliceTime
SpliceTimeView SpliceTime(void) const
Definition: mpegtables.h:997
SpliceInformationTable::toStringXML
QString toStringXML(uint indent_level) const override
Definition: mpegtables.h:1196
SpliceScheduleView::SpliceScheduleView
SpliceScheduleView(std::vector< const unsigned char * > ptrs0, std::vector< const unsigned char * > ptrs1)
Definition: mpegtables.h:922
SpliceInformationTable::SetPTSAdjustment
void SetPTSAdjustment(uint64_t val)
Definition: mpegtables.h:1092
ConditionalAccessTable::Descriptors
const unsigned char * Descriptors(void) const
Definition: mpegtables.h:882
PID::DVB_SDT_PID
@ DVB_SDT_PID
Definition: mpegtables.h:216
AdaptationFieldControl::Length
uint Length(void) const
adaptation header length (after which is payload data) 8 0.0
Definition: mpegtables.h:1226
PSIPTable::IsCurrent
bool IsCurrent(void) const
Definition: mpegtables.h:547
ProgramMapTable::SetStreamInfoLength
void SetStreamInfoLength(uint i, uint length)
Definition: mpegtables.h:821
SpliceInformationTable::SetCodeWordIndex
void SetCodeWordIndex(uint val)
Definition: mpegtables.h:1103
ProgramMapTable::SetProgramInfo
void SetProgramInfo(unsigned char *streamInfo, uint infoLength)
Definition: mpegtables.h:841
StreamID::MPEG2Audio
@ MPEG2Audio
ISO 13818-3.
Definition: mpegtables.h:125
ProgramMapTable::StreamInfo
const unsigned char * StreamInfo(uint i) const
Definition: mpegtables.h:749
SpliceTimeView::SpliceTimeView
SpliceTimeView(const unsigned char *data)
Definition: mpegtables.h:893
mythtvexp.h
ProgramAssociationTable::SetTranportStreamID
void SetTranportStreamID(uint gtsid)
Definition: mpegtables.h:654
SpliceInformationTable::EncryptionAlgorithm
uint EncryptionAlgorithm(void) const
Definition: mpegtables.h:1076
ConditionalAccessTable::ConditionalAccessTable
ConditionalAccessTable(const PSIPTable &table)
Definition: mpegtables.h:860
PESPacket::pesdata
const unsigned char * pesdata() const
Definition: pespacket.h:166
ProgramAssociationTable::FindProgram
uint FindProgram(uint pid) const
Definition: mpegtables.h:671
ProgramMapTable
A PMT table maps a program described in the ProgramAssociationTable to various PID's which describe t...
Definition: mpegtables.h:694
ProgramMapTable::FindPID
int FindPID(uint pid) const
Locates stream index of pid.
Definition: mpegtables.h:799
ProgramMapTable::PCRPID
uint PCRPID(void) const
stream that contains program clock reference.
Definition: mpegtables.h:728
SpliceInformationTable::SpliceSchedule
SpliceScheduleView SpliceSchedule(void) const
Definition: mpegtables.h:1142
SpliceInformationTable
Definition: mpegtables.h:1029
PID::DVB_EIT_PID
@ DVB_EIT_PID
Definition: mpegtables.h:217
TSPacket::AFCOffset
unsigned int AFCOffset(void) const
Definition: tspacket.h:247
AdaptationFieldControl::ExtensionLength
uint ExtensionLength(void) const
Definition: mpegtables.h:1261
SpliceScheduleView
Definition: mpegtables.h:919
types
static const struct wl_interface * types[]
Definition: idle_inhibit_unstable_v1.c:39
PSIPTable::PSIPTable
PSIPTable(const TSPacket &tspacket, const unsigned char *pesdata, uint pes_size)
Definition: mpegtables.h:448
ProgramMapTable::ProgramNumber
uint ProgramNumber(void) const
Definition: mpegtables.h:731
SpliceInformationTable::toString
QString toString(void) const override
Definition: mpegtables.h:1194
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
StreamID::VC1Video
@ VC1Video
SMPTE 421M video codec (aka VC1) in Blu-Ray.
Definition: mpegtables.h:121
SpliceScheduleView::m_ptrs0
std::vector< const unsigned char * > m_ptrs0
Definition: mpegtables.h:963
ProgramAssociationTable::ProgramCount
uint ProgramCount(void) const
Definition: mpegtables.h:638
PESPacket::StreamID
uint StreamID() const
Definition: pespacket.h:100
PSIPTable::ATSCProtocolVersion
uint ATSCProtocolVersion(void) const
Definition: mpegtables.h:557
PSIPTable::SetVersionNumber
void SetVersionNumber(uint ver)
Definition: mpegtables.h:575
AdaptationFieldControl::OPCR
bool OPCR(void) const
OPCR flag (we have OPCR data) 1 1.4 (adds 6 bytes) ((Original) Program Clock Reference; used to time ...
Definition: mpegtables.h:1246
GPS_LEAP_SECONDS
static constexpr uint8_t GPS_LEAP_SECONDS
Leap seconds as of June 30th, 2022.
Definition: mpegtables.h:34
PSIPTable::SectionLengthRaw
uint SectionLengthRaw(void) const
Definition: mpegtables.h:527
StreamID::DSMCC_D
@ DSMCC_D
ISO 13818-6 type D Any DSMCC Data.
Definition: mpegtables.h:137
PSIPTable::SetATSCProtocolVersion
void SetATSCProtocolVersion(int ver)
Definition: mpegtables.h:583
PSIPTable::kPsipOffset
static const uint kPsipOffset
Definition: mpegtables.h:593
ProgramMapTable::StreamTypeString
QString StreamTypeString(uint i) const
Returns a string representation of type at stream index i.
Definition: mpegtables.h:782
StreamID::MPEG2AACAudio
@ MPEG2AACAudio
ISO 13818-7 Audio w/ADTS syntax.
Definition: mpegtables.h:126
PSIPTable::SetCurrent
void SetCurrent(bool cur)
Definition: mpegtables.h:577
PSIPTable::Section
uint Section(void) const
Definition: mpegtables.h:550
SpliceInformationTable::getSCTEPID
int getSCTEPID(void) const
Definition: mpegtables.h:1047
StreamID::IsVideo
static bool IsVideo(uint type)
Returns true iff video is an MPEG1/2/3, H264 or open cable video stream.
Definition: mpegtables.h:168
SpliceInformationTable::SetSpliceProtocolVersion
void SetSpliceProtocolVersion(uint ver)
Definition: mpegtables.h:1059
TSHeader::ContinuityCounter
unsigned int ContinuityCounter(void) const
Definition: tspacket.h:107
PSIPTable::PrivateIndicator
bool PrivateIndicator(void) const
Definition: mpegtables.h:520
ConditionalAccessTable::DescriptorsLength
uint DescriptorsLength(void) const
Definition: mpegtables.h:880
SpliceInformationTable::SpliceProtocolVersion
uint SpliceProtocolVersion(void) const
Definition: mpegtables.h:1058
AdaptationFieldControl::Discontinuity
bool Discontinuity(void) const
discontinuity_indicator (time base may change) 1 1.0
Definition: mpegtables.h:1231
Parse
Definition: rssparse.h:188
AdaptationFieldControl::AdaptationFieldControl
AdaptationFieldControl(const unsigned char *packet)
Definition: mpegtables.h:1221
PID::MPEG_CAT_PID
@ MPEG_CAT_PID
Definition: mpegtables.h:212
StreamID
Contains listing of PMT Stream ID's for various A/V Stream types.
Definition: mpegtables.h:109
SpliceInsertView::SpliceEventID
uint SpliceEventID(void) const
Definition: mpegtables.h:977
PSIPTable::PSIPTable
PSIPTable(const TSPacket &table)
Definition: mpegtables.h:487
PSIPTable
A PSIP table is a variant of a PES packet containing an MPEG, ATSC or DVB table.
Definition: mpegtables.h:409
StreamID::MPEG4Video
@ MPEG4Video
ISO 14492-2 (aka MPEG-4)
Definition: mpegtables.h:117
SpliceInsertView::SpliceInsertView
SpliceInsertView(std::vector< const unsigned char * > ptrs0, std::vector< const unsigned char * > ptrs1)
Definition: mpegtables.h:970
PSIPTable::toString
virtual QString toString(void) const
Definition: mpegtables.cpp:763
PID::DVB_TDT_PID
@ DVB_TDT_PID
Definition: mpegtables.h:219
TableID::PAT
@ PAT
Definition: mpegtables.h:264
ProgramMapTable::RemoveAllStreams
void RemoveAllStreams(void)
Definition: mpegtables.h:808
AdaptationFieldControl::SeamlessSplice
bool SeamlessSplice(void) const
Definition: mpegtables.h:1268
AdaptationFieldControl::PrivateTransportData
bool PrivateTransportData(void) const
Definition: mpegtables.h:1257
SpliceInsertView::IsSpliceImmediate
bool IsSpliceImmediate(void) const
Definition: mpegtables.h:993
SpliceScheduleView::SpliceCount
uint SpliceCount(void) const
Definition: mpegtables.h:928
ProgramAssociationTable::TransportStreamID
uint TransportStreamID(void) const
Definition: mpegtables.h:636
ProgramAssociationTable::ProgramNumber
uint ProgramNumber(uint i) const
Definition: mpegtables.h:645
PSIPTable::SetLastSection
void SetLastSection(uint num)
Definition: mpegtables.h:580
StreamID::DSMCC_C
@ DSMCC_C
ISO 13818-6 type C NPT DSMCC Data.
Definition: mpegtables.h:136
TableID::PMT
@ PMT
Definition: mpegtables.h:266
PID::MPEG_NULL_PID
@ MPEG_NULL_PID
The all-ones PID value 0x1FFF indicates a Null TS Packet introduced to maintain a constant bit rate o...
Definition: mpegtables.h:246
SpliceInformationTable::m_ptrs0
std::vector< const unsigned char * > m_ptrs0
Definition: mpegtables.h:1203
SpliceInformationTable::SetEncryptedPacket
void SetEncryptedPacket(bool val)
Definition: mpegtables.h:1062
StreamID::IsAudio
static bool IsAudio(uint type)
Returns true iff audio is MPEG1/2, AAC, AC3 or DTS audio stream.
Definition: mpegtables.h:179
TSPacket
Used to access the data of a Transport Stream packet.
Definition: tspacket.h:205
ProgramMapTable::StreamType
uint StreamType(uint i) const
Definition: mpegtables.h:740
x1
static int x1
Definition: mythsocket.cpp:50
PSIPTable::PSIPTable
PSIPTable(const unsigned char *pesdata)
Constructor for viewing a section, does not create it's own data.
Definition: mpegtables.h:465
SpliceInformationTable::SetSpliceCommandType
void SetSpliceCommandType(uint type)
Definition: mpegtables.h:1131
PSIPTable::PSIPTable
PSIPTable(const TSPacket &tspacket, bool)
Definition: mpegtables.h:435
desc_list_t
std::vector< const unsigned char * > desc_list_t
Definition: mpegdescriptors.h:18
ProgramMapTable::ProgramMapTable
ProgramMapTable(const PSIPTable &table)
Definition: mpegtables.h:704
StreamID::MPEG2AudioAmd1
@ MPEG2AudioAmd1
ISO 13818-3/AMD-1 Audio using LATM syntax.
Definition: mpegtables.h:127
AdaptationFieldControl::LTW
bool LTW(void) const
Definition: mpegtables.h:1264
stringutil.h
PID::DVB_NIT_PID
@ DVB_NIT_PID
Definition: mpegtables.h:215
SpliceInsertView::AvailsExpected
uint AvailsExpected(void) const
Definition: mpegtables.h:1017
PSIPTable::toStringXML
virtual QString toStringXML(uint indent_level) const
Definition: mpegtables.cpp:781
SpliceInsertView::IsOutOfNetwork
bool IsOutOfNetwork(void) const
Definition: mpegtables.h:987
PID::FREESAT_ST_EIT_PID
@ FREESAT_ST_EIT_PID
Definition: mpegtables.h:242
SpliceInformationTable::CodeWordIndex
uint CodeWordIndex(void) const
Definition: mpegtables.h:1102
PESPacket::Length
uint Length() const
Definition: pespacket.h:101
StreamID::OpenCableVideo
@ OpenCableVideo
Always MPEG-2??
Definition: mpegtables.h:120
ProgramMapTable::SetStreamPID
void SetStreamPID(uint i, uint pid)
Definition: mpegtables.h:764
PSIPTable::SetSectionLength
void SetSectionLength(uint length)
Definition: mpegtables.h:569
PESPacket::VerifyCRC
bool VerifyCRC(void) const
Definition: pespacket.cpp:169
PID
Contains Packet Identifier numeric values.
Definition: mpegtables.h:206
SpliceInformationTable::SpliceCommandType
uint SpliceCommandType(void) const
Definition: mpegtables.h:1129
RST
@ RST
Definition: cc708decoder.cpp:101
uint
unsigned int uint
Definition: compat.h:81
SpliceTimeView::m_data
const unsigned char * m_data
Definition: mpegtables.h:916
StreamID::MPEG1Audio
@ MPEG1Audio
ISO 11172-3.
Definition: mpegtables.h:124
ProgramAssociationTable
The Program Association Table lists all the programs in a stream, and is always found on PID 0.
Definition: mpegtables.h:617
PSIPTable::LastSection
uint LastSection(void) const
Definition: mpegtables.h:553
PID::ATSC_PSIP_PID
@ ATSC_PSIP_PID
Definition: mpegtables.h:235
SpliceScheduleView::m_ptrs1
std::vector< const unsigned char * > m_ptrs1
Definition: mpegtables.h:964
SpliceInsertView::IsSpliceEventCancel
bool IsSpliceEventCancel(void) const
Definition: mpegtables.h:983
SpliceInformationTable::~SpliceInformationTable
~SpliceInformationTable() override
Definition: mpegtables.h:1044
TableID
Contains listing of Table ID's for various tables (PAT=0,PMT=2,etc).
Definition: mpegtables.h:259
ProgramMapTable::SetStreamProgramInfo
void SetStreamProgramInfo(uint i, unsigned char *streamInfo, uint infoLength)
Definition: mpegtables.h:827
pespacket.h
MTV_PUBLIC
#define MTV_PUBLIC
Definition: mythtvexp.h:15
PESPacket
Allows us to transform TS packets to PES packets, which are used to hold multimedia streams and very ...
Definition: pespacket.h:27
PSIPTable::SectionLength
uint SectionLength(void) const
Definition: mpegtables.h:526
SpliceInformationTable::SpliceCommandLength
uint SpliceCommandLength(void) const
Definition: mpegtables.h:1106
ProgramMapTable::ProgramInfoLength
uint ProgramInfoLength(void) const
Definition: mpegtables.h:734
AdaptationFieldControl::RandomAccess
bool RandomAccess(void) const
Definition: mpegtables.h:1233
PID::OTV_EIT_TIT_PID_START
@ OTV_EIT_TIT_PID_START
Definition: mpegtables.h:249
pes_alloc
unsigned char * pes_alloc(uint size)
Definition: pespacket.cpp:357
SpliceInformationTable::SetSpliceCommandLength
void SetSpliceCommandLength(uint len)
Definition: mpegtables.h:1110
assert
#define assert(x)
Definition: audiooutputalsa.cpp:16
PSIPTable::View
static PSIPTable View(const TSPacket &tspacket)
Definition: mpegtables.h:506
GPS_EPOCH
static constexpr qint64 GPS_EPOCH
Seconds between start of GPS time and the start of UNIX time.
Definition: mpegtables.h:31
ProgramMapTable::SetPCRPID
void SetPCRPID(uint pid)
Definition: mpegtables.h:756
SpliceInsertView::IsProgramSplice
bool IsProgramSplice(void) const
Definition: mpegtables.h:989
ProgramMapTable::SetProgramNumber
void SetProgramNumber(uint num)
Definition: mpegtables.h:762
PID::PREMIERE_EIT_DIREKT_PID
@ PREMIERE_EIT_DIREKT_PID
Definition: mpegtables.h:231
StreamID::toString
static const char * toString(uint streamID)
Definition: mpegtables.cpp:963
PESPacket::SetStreamID
void SetStreamID(uint id)
Definition: pespacket.h:172
ProgramAssociationTable::ProgramAssociationTable
ProgramAssociationTable(const ProgramAssociationTable &table)
Definition: mpegtables.h:620
SpliceInsertView::AvailNum
uint AvailNum(void) const
Definition: mpegtables.h:1015
PSIPTable::TableID
uint TableID(void) const
Definition: mpegtables.h:515
SpliceInformationTable::SpliceInformationTable
SpliceInformationTable(const SpliceInformationTable &table)
Definition: mpegtables.h:1032
PSIPTable::TableIDExtension
uint TableIDExtension(void) const
Definition: mpegtables.h:534
std
Definition: mythchrono.h:23
StreamID::DSMCC_B
@ DSMCC_B
ISO 13818-6 type B Std DSMCC Data.
Definition: mpegtables.h:135
PSIPTable::SetSection
void SetSection(uint num)
Definition: mpegtables.h:579
SpliceTimeView::PTSTime
uint64_t PTSTime(void) const
Definition: mpegtables.h:899
StreamID::MPEG2Video
@ MPEG2Video
ISO 13818-2 & ITU H.262 (aka MPEG-2)
Definition: mpegtables.h:116
PID::DVB_RST_PID
@ DVB_RST_PID
Definition: mpegtables.h:218
ConditionalAccessTable
The CAT is used to transmit additional ConditionalAccessDescriptor instances, in addition to the ones...
Definition: mpegtables.h:857
PESPacket::SetLength
void SetLength(uint len)
Definition: pespacket.h:173
PSIPTable::PSIPTable
PSIPTable(const std::vector< uint8_t > &pesdata)
Definition: mpegtables.h:471
SpliceInformationTable::PTSAdjustment
uint64_t PTSAdjustment(void) const
Definition: mpegtables.h:1084
SpliceInformationTable::SpliceInformationTable
SpliceInformationTable(const PSIPTable &table)
Definition: mpegtables.h:1038
AdaptationFieldControl
AdaptationFieldControl is used to transmit various important stream attributes.
Definition: mpegtables.h:1218
PID::MPEG_TSDT_PID
@ MPEG_TSDT_PID
Definition: mpegtables.h:213
TableID::CAT
@ CAT
Definition: mpegtables.h:265
SpliceInformationTable::SpliceDescriptors
const unsigned char * SpliceDescriptors(void) const
Definition: mpegtables.h:1181
ProgramMapTable::ViewData
static ProgramMapTable ViewData(const unsigned char *pesdata)
Definition: mpegtables.h:710
SpliceInsertView
Definition: mpegtables.h:967
PID::PREMIERE_EIT_SPORT_PID
@ PREMIERE_EIT_SPORT_PID
Definition: mpegtables.h:232
StreamID::EAC3Audio
@ EAC3Audio
A/53 Part 3:2009 6.7.3.
Definition: mpegtables.h:129
ProgramMapTable::SetStreamType
void SetStreamType(uint i, uint type)
Definition: mpegtables.h:770
SpliceInformationTable::setSCTEPID
void setSCTEPID(int ts_pid)
Definition: mpegtables.h:1046
MHEG
Definition: freemheg.h:54
ProgramAssociationTable::FindPID
uint FindPID(uint progNum) const
Definition: mpegtables.h:657
StreamID::AC3Audio
@ AC3Audio
A/53 Part 3:2009 6.7.1.
Definition: mpegtables.h:128
SpliceScheduleView::SpliceEventID
uint SpliceEventID(uint i) const
Definition: mpegtables.h:931
PESPacket::HasCRC
virtual bool HasCRC() const
1 bit Cyclic Redundancy Check present
Definition: pespacket.h:132
SpliceTimeView
Definition: mpegtables.h:890
StreamID::IsObjectCarousel
static bool IsObjectCarousel(uint type)
Returns true iff stream contains DSMCC Object Carousel.
Definition: mpegtables.h:190
PESPacket::m_fullBuffer
unsigned char * m_fullBuffer
Pointer to allocated data.
Definition: pespacket.h:222
SpliceInsertView::m_ptrs1
std::vector< const unsigned char * > m_ptrs1
Definition: mpegtables.h:1026
StreamID::DSMCC_A
@ DSMCC_A
ISO 13818-6 type A Multi-protocol Encap.
Definition: mpegtables.h:134
PSIPTable::psipdata
unsigned char * psipdata(void)
Definition: mpegtables.h:562
PSIPTable::ViewData
static PSIPTable ViewData(const unsigned char *pesdata)
Definition: mpegtables.h:509
PESStreamID
Contains a listing of PES Stream ID's for various PES Packet types.
Definition: mpegtables.h:44
SpliceInsertView::m_ptrs0
std::vector< const unsigned char * > m_ptrs0
Definition: mpegtables.h:1025
PID::FREESAT_SI_PID
@ FREESAT_SI_PID
Definition: mpegtables.h:240
ProgramMapTable::m_ptrs
std::vector< unsigned char * > m_ptrs
Definition: mpegtables.h:850
PID::DVB_BVLONG_EIT_PID
@ DVB_BVLONG_EIT_PID
Definition: mpegtables.h:225
ProgramMapTable::StreamInfoLength
uint StreamInfoLength(uint i) const
Definition: mpegtables.h:746
PID::MPEG_PAT_PID
@ MPEG_PAT_PID
Definition: mpegtables.h:211
PID::FREESAT_EIT_PID
@ FREESAT_EIT_PID
Definition: mpegtables.h:241
SpliceTimeView::IsTimeSpecified
bool IsTimeSpecified(void) const
Definition: mpegtables.h:895
SpliceInformationTable::SpliceDescriptorsLength
uint SpliceDescriptorsLength(uint) const
Definition: mpegtables.h:1174
SpliceInformationTable::SpliceInsert
SpliceInsertView SpliceInsert(void) const
Definition: mpegtables.h:1148
SpliceInsertView::IsDuration
bool IsDuration(void) const
Definition: mpegtables.h:991
SpliceTimeView::size
uint size(void) const
Definition: mpegtables.h:914
StreamID::DTSAudio
@ DTSAudio
Definition: mpegtables.h:130
ProgramMapTable::StreamPID
uint StreamPID(uint i) const
Definition: mpegtables.h:743
AdaptationFieldControl::PCR
bool PCR(void) const
PCR flag (we have PCR data) 1 1.3 (adds 6 bytes after adaptation header)
Definition: mpegtables.h:1242
AdaptationFieldControl::Priority
bool Priority(void) const
Definition: mpegtables.h:1235
nv_python_libs.bbciplayer.bbciplayer_api.version
string version
Definition: bbciplayer_api.py:77
TSHeader::data
const unsigned char * data(void) const
Definition: tspacket.h:172
ProgramMapTable::SetProgramInfoLength
void SetProgramInfoLength(uint length)
Definition: mpegtables.h:835
AdaptationFieldControl::m_data
const unsigned char * m_data
Definition: mpegtables.h:1272
ProgramMapTable::ProgramMapTable
ProgramMapTable(const ProgramMapTable &table)
Definition: mpegtables.h:698
SpliceInformationTable::IsEncryptedPacket
bool IsEncryptedPacket(void) const
Definition: mpegtables.h:1061
PSIPTable::Version
uint Version(void) const
Definition: mpegtables.h:541
PID::OTV_EIT_SUP_PID_END
@ OTV_EIT_SUP_PID_END
Definition: mpegtables.h:252
PID::MCA_EIT_PID
@ MCA_EIT_PID
Definition: mpegtables.h:228
PSIPTable::SectionSyntaxIndicator
bool SectionSyntaxIndicator(void) const
Definition: mpegtables.h:518
StreamID::MPEG1Video
@ MPEG1Video
ISO 11172-2 (aka MPEG-1)
Definition: mpegtables.h:115
PID::OTV_EIT_TIT_PID_END
@ OTV_EIT_TIT_PID_END
Definition: mpegtables.h:250
PSIPTable::psipdata
const unsigned char * psipdata(void) const
Definition: mpegtables.h:560
PSIPTable::PSIPTable
PSIPTable(const PESPacket &table)
Definition: mpegtables.h:481
TSPacket::kSize
static constexpr unsigned int kSize
Definition: tspacket.h:259
PESPacket::m_psiOffset
uint m_psiOffset
AFCOffset + StartOfFieldPointer.
Definition: pespacket.h:224
TableID::SITscte
@ SITscte
Definition: mpegtables.h:351
AdaptationFieldControl::PiecewiseRate
bool PiecewiseRate(void) const
Definition: mpegtables.h:1266
AdaptationFieldControl::FieldExtension
bool FieldExtension(void) const
Definition: mpegtables.h:1259