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