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 
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
222  DVB_DNLONG_EIT_PID = 0x0300,
223 
224  // Bell longterm EIT is on pid 0x441
225  DVB_BVLONG_EIT_PID = 0x0441,
226 
227  // MCA
228  MCA_EIT_PID = 0x03fa, // 1018
229 
230  // Premiere EIT for Direkt/Sport PPV
231  PREMIERE_EIT_DIREKT_PID = 0x0b11,
232  PREMIERE_EIT_SPORT_PID = 0x0b12,
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
242  FREESAT_ST_EIT_PID = 0x0f03,
243 
246  MPEG_NULL_PID = 0x1fff,
247 
248  // OpenTV EIT PIDs
249  OTV_EIT_TIT_PID_START = 0x30,
250  OTV_EIT_TIT_PID_END = 0x37,
251  OTV_EIT_SUP_PID_START = 0x40,
252  OTV_EIT_SUP_PID_END = 0x47,
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 PSIPTable(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 
529  // Things below this line may not apply to SCTE/DVB tables.
530 
531  // table_id_extension 16 3.0 24 table dependent
532  uint TableIDExtension(void) const
533  { return (pesdata()[3]<<8) | pesdata()[4]; }
534 
535  // reserved 2 5.0 40
536 
537  // version_number 5 5.2 42
538  // incremented modulo 32 when table info changes
539  uint Version(void) const { return (pesdata()[5]>>1) & 0x1f; }
540 
541  // current_next_ind 1 5.7 47
542  // if 0 this table is not yet valid, but will be the next psip
543  // table with the same sectionNumber(), tableIDExtension() and
544  // tableID() to become valid.
545  bool IsCurrent(void) const { return bool(pesdata()[5]&1); }
546 
547  // section_number 8 6.0 48
548  uint Section(void) const { return pesdata()[6]; }
549 
550  // last_section_number 8 7.0 56
551  uint LastSection(void) const { return pesdata()[7]; }
552 
553  // Protocol Version for ATSC PSIP tables
554  // protocol_version 8 8.0 64 should always be 0 for now
555  uint ATSCProtocolVersion(void) const { return pesdata()[8]; }
556 
557  // PSIP_table_data x 8.0 72 (incl. protocolVersion)
558  const unsigned char* psipdata(void) const
559  { return pesdata() + kPsipOffset; }
560  unsigned char* psipdata(void)
561  { return pesdata() + kPsipOffset; }
562 
563  // sets
564  void SetTableID(uint id) { SetStreamID(id); }
565  // subtracts 3 from total section length to account for 3 bytes
566  // before the end of the section length field.
567  void SetSectionLength(uint length) { SetLength(length-3); }
569  {
570  pesdata()[3] = (len>>8) & 0xff;
571  pesdata()[4] = len & 0xff;
572  }
574  { pesdata()[5] = (pesdata()[5] & 0xc1) | ((ver & 0x1f)<<1); }
575  void SetCurrent(bool cur)
576  { pesdata()[5] = (pesdata()[5] & 0xfe) | (cur ? 1 : 0); }
577  void SetSection(uint num) { pesdata()[6] = num; }
578  void SetLastSection(uint num) { pesdata()[7] = num; }
579 
580  // Only for real ATSC PSIP tables.
581  void SetATSCProtocolVersion(int ver) { pesdata()[8] = ver; }
582 
583  bool HasCRC(void) const override; // PESPacket
584  bool HasSectionNumber(void) const;
585 
586  bool VerifyPSIP(bool verify_crc) const;
587 
588  virtual QString toString(void) const;
589  virtual QString toStringXML(uint indent_level) const;
590 
591  static const uint kPsipOffset = 8; // general PSIP header offset
592 
593  protected:
594  QString XMLValues(uint indent_level) const;
595 };
596 
616 {
617  public:
619  : PSIPTable(table)
620  {
622  }
623 
624  explicit ProgramAssociationTable(const PSIPTable &table) : PSIPTable(table)
625  {
627  }
628 
629  // transport stream ID, program ID, count
630  static ProgramAssociationTable* Create(uint tsid, uint version,
631  const std::vector<uint>& pnum,
632  const std::vector<uint>& pid);
633 
634  uint TransportStreamID(void) const { return TableIDExtension(); }
635 
636  uint ProgramCount(void) const
637  {
638  if (SectionLength() > (kPsipOffset+2))
639  return (SectionLength()-kPsipOffset-2)>>2;
640  return 0;
641  }
642 
644  { return (psipdata()[(i<<2)] << 8) | psipdata()[(i<<2) + 1]; }
645 
647  {
648  return (((psipdata()[(i<<2) + 2] & 0x1f) << 8) |
649  psipdata()[(i<<2) + 3]);
650  }
651 
653 
654  // helper function
655  uint FindPID(uint progNum) const
656  {
657  for (uint i = 0; i < ProgramCount(); i++)
658  if (progNum==ProgramNumber(i))
659  return ProgramPID(i);
660  return 0;
661  }
662  uint FindAnyPID(void) const
663  {
664  for (uint i = 0; i < ProgramCount(); i++)
665  if (0!=ProgramNumber(i))
666  return ProgramPID(i);
667  return 0;
668  }
669  uint FindProgram(uint pid) const
670  {
671  for (uint i = 0; i < ProgramCount(); i++)
672  if (pid==ProgramPID(i))
673  return ProgramNumber(i);
674  return 0;
675  }
676 
677  QString toString(void) const override; // PSIPTable
678  QString toStringXML(uint indent_level) const override; // PSIPTable
679 
680  private:
681  static ProgramAssociationTable* CreateBlank(bool smallPacket = true);
682 
683  // for testing if CreateBlank create a table with invalid CRC
684  friend class TestMPEGTables;
685 };
686 
693 {
694  public:
695 
697  {
699  Parse();
700  }
701 
702  explicit ProgramMapTable(const PSIPTable& table) : PSIPTable(table)
703  {
705  Parse();
706  }
707 
708  static ProgramMapTable ViewData(const unsigned char* pesdata)
709  {
710  /* needed to call Parse() */
711  return ProgramMapTable(PSIPTable::ViewData(pesdata));
712  }
713 
714  static ProgramMapTable* Create(uint programNumber, uint basepid,
715  uint pcrpid, uint version,
716  std::vector<uint> pids, std::vector<uint> types);
717 
718  static ProgramMapTable* Create(uint programNumber, uint basepid,
719  uint pcrpid, uint version,
720  const desc_list_t &global_desc,
721  const std::vector<uint> &pids,
722  const std::vector<uint> &types,
723  const std::vector<desc_list_t> &prog_desc);
724 
726  uint PCRPID(void) const
727  { return ((psipdata()[0] << 8) | psipdata()[1]) & 0x1fff; }
728 
729  uint ProgramNumber(void) const
730  { return TableIDExtension(); }
731 
733  { return ((psipdata()[2]<<8) | psipdata()[3]) & 0x0fff; }
734 
735  const unsigned char* ProgramInfo(void) const
736  { return psipdata() + 4; }
737 
739  { return m_ptrs[i][0]; }
740 
741  uint StreamPID(uint i) const
742  { return ((m_ptrs[i][1] << 8) | m_ptrs[i][2]) & 0x1fff; }
743 
745  { return ((m_ptrs[i][3] << 8) | m_ptrs[i][4]) & 0x0fff; }
746 
747  const unsigned char* StreamInfo(uint i) const
748  { return m_ptrs[i] + 5; }
749 
750  uint StreamCount(void) const
751  { return (m_ptrs.size()) ? m_ptrs.size()-1 : 0; }
752 
753  // sets
754  void SetPCRPID(uint pid)
755  {
756  psipdata()[0] = ((pid >> 8) & 0x1F) | (psipdata()[0] & 0xE0);
757  psipdata()[1] = (pid & 0xFF);
758  }
759 
761 
762  void SetStreamPID(uint i, uint pid)
763  {
764  m_ptrs[i][1] = ((pid>>8) & 0x1f) | (m_ptrs[i][1] & 0xe0);
765  m_ptrs[i][2] = pid & 0xff;
766  }
767 
769  { m_ptrs[i][0] = type; }
770 
771  // helper methods
772  bool IsVideo(uint i, const QString& sistandard) const;
773  bool IsAudio(uint i, const QString& sistandard) const;
774  bool IsEncrypted(const QString& sistandard) const;
775  bool IsProgramEncrypted(void) const;
776  bool IsStreamEncrypted(uint pid) const;
778  bool IsStillPicture(const QString& sistandard) const;
780  QString StreamTypeString(uint i) const
781  { return StreamID::toString(StreamType(i)); }
784  QString StreamDescription(uint i, const QString& sistandard) const;
786  QString GetLanguage(uint i) const;
788  uint GetAudioType(uint i) const;
789 
790  uint FindPIDs(uint type, std::vector<uint> &pids,
791  const QString &sistandard) const;
792  uint FindPIDs(uint type, std::vector<uint> &pids, std::vector<uint> &types,
793  const QString &sistandard, bool normalize) const;
794 
797  int FindPID(uint pid) const
798  {
799  for (uint i = 0; i < StreamCount(); i++)
800  if (pid == StreamPID(i))
801  return i;
802  return -1;
803  }
804  uint FindUnusedPID(uint desired_pid = 0x20) const;
805 
806  void RemoveAllStreams(void)
807  {
808  memset(psipdata(), 0xff, kPmtHeaderMinOffset);
809  SetProgramInfoLength(0);
810  m_ptrs.clear();
811  }
812  void AppendStream(uint pid, uint type, unsigned char* streamInfo = nullptr, uint infoLength = 0);
813 
814  void Parse(void) const;
815  QString toString(void) const override; // PSIPTable
816  QString toStringXML(uint indent_level) const override; // PSIPTable
817  // unsafe sets
818  private:
819  void SetStreamInfoLength(uint i, uint length)
820  {
821  m_ptrs[i][3] = ((length>>8) & 0x0f) | (m_ptrs[i][3] & 0xf0);
822  m_ptrs[i][4] = length & 0xff;
823  }
824 
825  void SetStreamProgramInfo(uint i, unsigned char* streamInfo,
826  uint infoLength)
827  {
828  SetStreamInfoLength(i, infoLength);
829  if ((streamInfo != nullptr) && (infoLength > 0))
830  memcpy(m_ptrs[i] + 5, streamInfo, infoLength);
831  }
832 
834  {
835  psipdata()[2] = ((length>>8) & 0x0f) | (psipdata()[2] & 0xf0);
836  psipdata()[3] = length & 0xff;
837  }
838 
839  void SetProgramInfo(unsigned char *streamInfo, uint infoLength)
840  {
841  SetProgramInfoLength(infoLength);
842  memcpy(psipdata() + 4, streamInfo, infoLength);
843  }
844 
845  static ProgramMapTable* CreateBlank(bool smallPacket = true);
846 
847  static const uint kPmtHeaderMinOffset = 4; // minimum PMT header offset
848  mutable std::vector<unsigned char*> m_ptrs; // used to parse
849 };
850 
856 {
857  public:
858  explicit ConditionalAccessTable(const PSIPTable &table) : PSIPTable(table)
859  {
860  // Section Bits Start Byte sbit
861  // -----------------------------------------
862  // table_id 8 0.0 0
864  // section_syntax_ind 1 1.0 8 should always be 1
865  // private_indicator 1 1.1 9 should always be 0
866  // reserved 2 1.2 10
867  // section_length 12 1.4 12 always less than 0x3fd
868  // table_id_extension 16 3.0 24 unused
869  // reserved 2 5.0 40
870  // version_number 5 5.2 42
871  // current_next_ind 1 5.3 47
872  // section_numben 8 6.0 48
873  // last_section_number 8 7.0 56
874  }
875 
876  // for (i = 0; i < N; i++) 8.0 64
877  // { descriptor() }
879  { return SectionLength() - kPsipOffset; }
880  const unsigned char *Descriptors(void) const { return psipdata(); }
881 
882  QString toString(void) const override; // PSIPTable
883  QString toStringXML(uint indent_level) const override; // PSIPTable
884 
885  // CRC_32 32 rpchof
886 };
887 
889 {
890  public:
891  explicit SpliceTimeView(const unsigned char *data) : m_data(data) { }
892  // time_specified_flag 1 0.0
893  bool IsTimeSpecified(void) const { return ( m_data[0] & 0x80 ) != 0; }
894  // if (time_specified_flag == 1)
895  // reserved 6 0.1
896  // pts_time 33 0.6
897  uint64_t PTSTime(void) const
898  {
899  return ((uint64_t(m_data[0] & 0x1) << 32) |
900  (uint64_t(m_data[1]) << 24) |
901  (uint64_t(m_data[2]) << 16) |
902  (uint64_t(m_data[3]) << 8) |
903  (uint64_t(m_data[4])));
904  }
905  // else
906  // reserved 7 0.1
907  // }
908  virtual QString toString(int64_t first, int64_t last) const;
909  virtual QString toStringXML(
910  uint indent_level, int64_t first, int64_t last) const;
911 
912  uint size(void) const { return IsTimeSpecified() ? 1 : 5; }
913  private:
914  const unsigned char *m_data;
915 };
916 
918 {
919  public:
920  SpliceScheduleView(std::vector<const unsigned char*> ptrs0,
921  std::vector<const unsigned char*> ptrs1) :
922  m_ptrs0(std::move(ptrs0)), m_ptrs1(std::move(ptrs1))
923  {
924  }
925  // splice_count 8 14.0
926  uint SpliceCount(void) const { return std::min(m_ptrs0.size(), m_ptrs1.size()); }
927 
928  // splice_event_id 32 0.0 + m_ptrs0[i]
930  {
931  return ((m_ptrs0[i][0] << 24) | (m_ptrs0[i][1] << 16) |
932  (m_ptrs0[i][2] << 8) | (m_ptrs0[i][3]));
933  }
934  // splice_event_cancel_indicator 1 4.0 + m_ptrs0[i]
935  // reserved 7 4.1 + m_ptrs0[i]
936  // if (splice_event_cancel_indicator == ‘0’) {
937  // out_of_network_indicator 1 5.0 + m_ptrs0[i]
938  // program_splice_flag 1 5.1 + m_ptrs0[i]
939  // duration_flag 1 5.2 + m_ptrs0[i]
940  // reserved 5 5.3 + m_ptrs0[i]
941  // if (program_splice_flag == ‘1’)
942  // utc_splice_time 32 6.0 + m_ptrs0[i]
943  // else {
944  // component_count 8 6.0 + m_ptrs0[i]
945  // for(j = 0; j < component_count; j++) {
946  // component_tag 8 7.0 + m_ptrs0[i]+j*5
947  // utc_splice_time 32 8.0 + m_ptrs0[i]+j*5
948  // }
949  // }
950  // if (duration_flag) {
951  // auto_return 1 0.0 + m_ptrs1[i]
952  // reserved 6 0.1 + m_ptrs1[i]
953  // duration 33 0.7 + m_ptrs1[i]
954  // }
955  // unique_program_id 16 0.0 + m_ptrs1[i] + (duration_flag)?5:0
956  // avail_num 8 2.0 + m_ptrs1[i] + (duration_flag)?5:0
957  // avails_expected 8 3.0 + m_ptrs1[i] + (duration_flag)?5:0
958  // }
959 
960  private:
961  std::vector<const unsigned char*> m_ptrs0;
962  std::vector<const unsigned char*> m_ptrs1;
963 };
964 
966 {
967  public:
968  SpliceInsertView(std::vector<const unsigned char*> ptrs0,
969  std::vector<const unsigned char*> ptrs1) :
970  m_ptrs0(std::move(ptrs0)), m_ptrs1(std::move(ptrs1))
971  {
972  }
973 
974  // splice_event_id 32 0.0 + m_ptrs1[0]
975  uint SpliceEventID(void) const
976  {
977  return ((m_ptrs1[0][0] << 24) | (m_ptrs1[0][1] << 16) |
978  (m_ptrs1[0][2] << 8) | (m_ptrs1[0][3]));
979  }
980  // splice_event_cancel 1 4.0 + m_ptrs1[0]
981  bool IsSpliceEventCancel(void) const { return ( m_ptrs1[0][4] & 0x80 ) != 0; }
982  // reserved 7 4.1 + m_ptrs1[0]
983  // if (splice_event_cancel_indicator == 0) {
984  // out_of_network_flag 1 5.0 + m_ptrs1[0]
985  bool IsOutOfNetwork(void) const { return ( m_ptrs1[0][5] & 0x80 ) != 0; }
986  // program_splice_flag 1 5.1 + m_ptrs1[0]
987  bool IsProgramSplice(void) const { return ( m_ptrs1[0][5] & 0x40 ) != 0; }
988  // duration_flag 1 5.2 + m_ptrs1[0]
989  bool IsDuration(void) const { return ( m_ptrs1[0][5] & 0x20 ) != 0; }
990  // splice_immediate_flag 1 5.3 + m_ptrs1[0]
991  bool IsSpliceImmediate(void) const { return ( m_ptrs1[0][5] & 0x20 ) != 0; }
992  // reserved 4 5.4 + m_ptrs1[0]
993  // if ((program_splice_flag == 1) && (splice_immediate_flag == ‘0’))
994  // splice_time() 8-38 6.0 + m_ptrs1[0]
996  { return SpliceTimeView(m_ptrs1[0]+6); }
997  // if (program_splice_flag == 0) {
998  // component_count 8 6.0 + m_ptrs1[0]
999  // for (i = 0; i < component_count; i++) {
1000  // component_tag 8 0.0 + m_ptrs0[i]
1001  // if (splice_immediate_flag == ‘0’)
1002  // splice_time() 8-38 1.0 + m_ptrs0[i]
1003  // }
1004  // }
1005  // if (duration_flag == ‘1’)
1006  // auto_return 1 0.0 + m_ptrs1[1]
1007  // reserved 6 0.1 + m_ptrs1[1]
1008  // duration 33 0.7 + m_ptrs1[1]
1009  // unique_program_id 16 0.0 + m_ptrs1[2]
1010  uint UniqueProgramID(void) const
1011  { return (m_ptrs1[2][0]<<8) | m_ptrs1[2][1]; }
1012  // avail_num 8 2.0 + m_ptrs1[2]
1013  uint AvailNum(void) const { return m_ptrs1[2][2]; }
1014  // avails_expected 8 3.0 + m_ptrs1[2]
1015  uint AvailsExpected(void) const { return m_ptrs1[2][3]; }
1016  // }
1017 
1018  virtual QString toString(int64_t first, int64_t last) const;
1019  virtual QString toStringXML(
1020  uint indent_level, int64_t first, int64_t last) const;
1021 
1022  private:
1023  std::vector<const unsigned char*> m_ptrs0;
1024  std::vector<const unsigned char*> m_ptrs1;
1025 };
1026 
1028 {
1029  public:
1031  PSIPTable(table)
1032  {
1034  Parse();
1035  }
1036  explicit SpliceInformationTable(const PSIPTable &table) :
1037  PSIPTable(table)
1038  {
1040  Parse();
1041  }
1042  ~SpliceInformationTable() override { ; }
1043 
1044  void setSCTEPID(int ts_pid){m_sctePid = ts_pid;}
1045  int getSCTEPID(void) const {return m_sctePid;}
1046 
1047  // ANCE/SCTE 35 2007
1048  // Name bits loc expected value
1049  // table_id 8 0.0 0xFC
1050  // section_syntax_indicator 1 1.0 1
1051  // private_indicator 1 1.1 0
1052  // reserved 2 1.2 3
1053  // section_length 12 1.4
1054  // ^^^ All above this line provided by PSIPTable
1055  // protocol_version 8 3.0 0
1056  uint SpliceProtocolVersion(void) const { return pesdata()[3]; }
1057  void SetSpliceProtocolVersion(uint ver) { pesdata()[3] = ver; }
1058  // encrypted_packet 1 4.0
1059  bool IsEncryptedPacket(void) const { return ( pesdata()[4] & 0x80 ) != 0; }
1060  void SetEncryptedPacket(bool val)
1061  {
1062  pesdata()[4] = (pesdata()[4] & ~0x80) | ((val) ? 0x80 : 0);
1063  }
1064  // encryption_algorithm 6 4.1
1065  enum
1066  {
1067  kNoEncryption = 0,
1068  kECB = 1, // DES - ECB mode, FIPS PUB 81 (8 byte blocks)
1069  kCBC = 2, // DES - CBC mode, FIPS PUB 81 (8 byte blocks)
1070  k3DES = 3, // 3 DES - TDEA, FIPS PUB 46-3 (8 byte blocks)
1071  // values 4-31 are reserved for future extension
1072  // values 32-63 are user private
1073  };
1074  uint EncryptionAlgorithm(void) const { return (pesdata()[4] >> 1) & 0x3f; }
1075  QString EncryptionAlgorithmString(void) const;
1077  {
1078  pesdata()[4] &= 0x81;
1079  pesdata()[4] |= ((val&0x3f) << 1);
1080  }
1081  // pts_adjustment 33 4.7
1082  uint64_t PTSAdjustment(void) const
1083  {
1084  return ((uint64_t(pesdata()[4] & 0x1) << 32) |
1085  (uint64_t(pesdata()[5]) << 24) |
1086  (uint64_t(pesdata()[6]) << 16) |
1087  (uint64_t(pesdata()[7]) << 8) |
1088  (uint64_t(pesdata()[8])));
1089  }
1090  void SetPTSAdjustment(uint64_t val)
1091  {
1092  pesdata()[4] &= ~0x1;
1093  pesdata()[4] |= (val>>32) & 0x1;
1094  pesdata()[5] = ((val>>24) & 0xff);
1095  pesdata()[6] = ((val>>16) & 0xff);
1096  pesdata()[7] = ((val>>8 ) & 0xff);
1097  pesdata()[8] = ((val ) & 0xff);
1098  }
1099  // cw_index (enc key) 8 9.0
1100  uint CodeWordIndex(void) const { return pesdata()[9]; }
1101  void SetCodeWordIndex(uint val) { pesdata()[9] = val; }
1102  // reserved 12 10.0
1103  // splice_command_length 12 11.4
1105  {
1106  return ((pesdata()[11] & 0xf) << 8) | pesdata()[12];
1107  }
1109  {
1110  pesdata()[11] &= ~0xf;
1111  pesdata()[11] |= (len >> 8) & 0xf;
1112  pesdata()[12] = len & 0xff;
1113  }
1114  // splice_command_type 8 13.0
1115  enum {
1116  kSCTNull = 0x00,
1117  kSCTReserved0 = 0x01,
1118  kSCTReserved1 = 0x02,
1119  kSCTReserved2 = 0x03,
1120  kSCTSpliceSchedule = 0x04,
1121  kSCTSpliceInsert = 0x05,
1122  kSCTTimeSignal = 0x06,
1123  kSCTBandwidthReservation = 0x07,
1124  // 0x08-0xfe reserved
1125  kSCTPrivateCommand = 0xff,
1126  };
1127  uint SpliceCommandType(void) const { return pesdata()[13]; }
1128  QString SpliceCommandTypeString(void) const;
1129  void SetSpliceCommandType(uint type) { pesdata()[13] = type & 0xff; }
1130 
1131  // ALL BELOW THIS LINE OTHER THAN CRC_32 ARE ENCRYPTED IF FLAG SET
1132 
1134 
1135  // nothing here, info in descriptors
1136 
1138 
1139  // if (splice_command_type == 0x04) splice_schedule()
1141  { return SpliceScheduleView(m_ptrs0, m_ptrs1); }
1142 
1144 
1145  // if (splice_command_type == 0x05) splice_insert()
1147  { return SpliceInsertView(m_ptrs0, m_ptrs1); }
1148 
1150 
1151  // if (splice_command_type == 0x06) splice_time()
1153  { return SpliceTimeView(pesdata()+14); }
1154 
1156 
1157  // nothing here, info in descriptors
1158 
1160 
1161  // if (splice_command_type == 0xff) private_command()
1162  // identifier 32 14.0
1163  // for (i = 0; i < N; i++)
1164  // private_byte 8 ??.0
1165  //
1166 
1168  // NOTE: Aside from CRC's we can not interpret things below
1169  // this comment with private or reserved commands.
1170 
1171  // descriptor_loop_length 16 0.0 + m_epilog
1173  {
1174  return (m_epilog[0] << 8) | m_epilog[1];
1175  }
1176 
1177  // for (i = 0; i < ? ; i++)
1178  // splice_descriptor() ?? ??.?
1179  const unsigned char *SpliceDescriptors(void) const
1180  {
1181  return (m_epilog) ? m_epilog + 2 : nullptr;
1182  }
1183  // for (i = 0; i < ?; i++)
1184  // alignment_stuffing 8 ??.0
1185  // if (encrypted_packet())
1186  // E_CRC_32 32 ??.0
1187  // CRC_32 32 ??.0
1188 
1189  static SpliceInformationTable *GetDecrypted(const QString &codeWord);
1190  bool Parse(void);
1191 
1192  QString toString(void) const override // PSIPTable
1193  { return toString(-1LL, -1LL); }
1194  QString toStringXML(uint indent_level) const override // PSIPTable
1195  { return toStringXML(indent_level, -1LL, -1LL); }
1196 
1197  QString toString(int64_t first, int64_t last) const;
1198  QString toStringXML(uint indent_level, int64_t first, int64_t last) const;
1199 
1200  private:
1201  std::vector<const unsigned char*> m_ptrs0;
1202  std::vector<const unsigned char*> m_ptrs1;
1203  const unsigned char *m_epilog {nullptr};
1204  int m_sctePid {0};
1205 };
1206 
1217 {
1218  public:
1219  explicit AdaptationFieldControl(const unsigned char* packet) : m_data(packet) { ; }
1220 
1224  uint Length(void) const { return m_data[0]; }
1225 
1229  bool Discontinuity(void) const { return ( m_data[1] & 0x80 ) != 0; }
1230  // random_access_indicator (?) 1 1.1
1231  bool RandomAccess(void) const { return bool(m_data[1] & 0x40); }
1232  // elementary_stream_priority_indicator 1 1.2
1233  bool Priority(void) const { return bool(m_data[1] & 0x20); }
1234 
1235 // Each of the following extends the adaptation header. In order:
1236 
1240  bool PCR(void) const { return bool(m_data[1] & 0x10); }
1244  bool OPCR(void) const { return bool(m_data[1] & 0x08); }
1252  bool SplicingPoint(void) const { return bool(m_data[1] & 0x04); }
1253  // transport_private_data_flag 1 1.6
1254  // (adds 1 byte)
1255  bool PrivateTransportData(void) const { return bool(m_data[1] & 0x02); }
1256  // adaptation_field_extension_flag 1 1.7
1257  bool FieldExtension(void) const { return bool(m_data[1] & 0x1); }
1258  // extension length 8 2.0
1259  uint ExtensionLength(void) const { return m_data[2]; }
1260  // ltw flag 1 3.0
1261  // (adds 2 bytes)
1262  bool LTW(void) const { return bool(m_data[3] & 0x80); }
1263  // piecewise_rate_flag (adds 3 bytes) 1 3.1
1264  bool PiecewiseRate(void) const { return bool(m_data[3] & 0x40); }
1265  // seamless_splice_flag (adds 5 bytes) 1 3.2
1266  bool SeamlessSplice(void) const { return bool(m_data[3] & 0x20); }
1267  // unused flags 5 3.3
1268 
1269  private:
1270  const unsigned char* m_data;
1271 };
1272 
1273 #endif // MPEG_TABLES_H
ProgramMapTable::ProgramInfo
const unsigned char * ProgramInfo(void) const
Definition: mpegtables.h:735
StreamID::VC1Video
@ VC1Video
SMPTE 421M video codec (aka VC1) in Blu-Ray.
Definition: mpegtables.h:121
TableID::SITscte
@ SITscte
Definition: mpegtables.h:351
ProgramAssociationTable::FindAnyPID
uint FindAnyPID(void) const
Definition: mpegtables.h:662
ProgramAssociationTable::ProgramPID
uint ProgramPID(uint i) const
Definition: mpegtables.h:646
SpliceInsertView::UniqueProgramID
uint UniqueProgramID(void) const
Definition: mpegtables.h:1010
bool
bool
Definition: pxsup2dast.c:30
SpliceInformationTable::m_ptrs1
std::vector< const unsigned char * > m_ptrs1
Definition: mpegtables.h:1202
TSHeader::PayloadStart
bool PayloadStart(void) const
Definition: tspacket.h:70
PSIPTable::SetTableID
void SetTableID(uint id)
Definition: mpegtables.h:564
SpliceInformationTable::TimeSignal
SpliceTimeView TimeSignal(void) const
Definition: mpegtables.h:1152
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:1076
TSPacket::StartOfFieldPointer
unsigned int StartOfFieldPointer(void) const
Definition: tspacket.h:216
ProgramAssociationTable::ProgramAssociationTable
ProgramAssociationTable(const PSIPTable &table)
Definition: mpegtables.h:624
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:1252
PSIPTable::SetTableIDExtension
void SetTableIDExtension(uint len)
Definition: mpegtables.h:568
ProgramMapTable::StreamCount
uint StreamCount(void) const
Definition: mpegtables.h:750
mpegdescriptors.h
SpliceInsertView::SpliceTime
SpliceTimeView SpliceTime(void) const
Definition: mpegtables.h:995
SpliceInformationTable::toStringXML
QString toStringXML(uint indent_level) const override
Definition: mpegtables.h:1194
SpliceScheduleView::SpliceScheduleView
SpliceScheduleView(std::vector< const unsigned char * > ptrs0, std::vector< const unsigned char * > ptrs1)
Definition: mpegtables.h:920
SpliceInformationTable::SetPTSAdjustment
void SetPTSAdjustment(uint64_t val)
Definition: mpegtables.h:1090
StreamID::DTSAudio
@ DTSAudio
Definition: mpegtables.h:130
ConditionalAccessTable::Descriptors
const unsigned char * Descriptors(void) const
Definition: mpegtables.h:880
AdaptationFieldControl::Length
uint Length(void) const
adaptation header length (after which is payload data) 8 0.0
Definition: mpegtables.h:1224
StreamID::MPEG2AudioAmd1
@ MPEG2AudioAmd1
ISO 13818-3/AMD-1 Audio using LATM syntax.
Definition: mpegtables.h:127
PSIPTable::IsCurrent
bool IsCurrent(void) const
Definition: mpegtables.h:545
ProgramMapTable::SetStreamInfoLength
void SetStreamInfoLength(uint i, uint length)
Definition: mpegtables.h:819
SpliceInformationTable::SetCodeWordIndex
void SetCodeWordIndex(uint val)
Definition: mpegtables.h:1101
ProgramMapTable::SetProgramInfo
void SetProgramInfo(unsigned char *streamInfo, uint infoLength)
Definition: mpegtables.h:839
ProgramMapTable::StreamInfo
const unsigned char * StreamInfo(uint i) const
Definition: mpegtables.h:747
SpliceTimeView::SpliceTimeView
SpliceTimeView(const unsigned char *data)
Definition: mpegtables.h:891
mythtvexp.h
ProgramAssociationTable::SetTranportStreamID
void SetTranportStreamID(uint gtsid)
Definition: mpegtables.h:652
SpliceInformationTable::EncryptionAlgorithm
uint EncryptionAlgorithm(void) const
Definition: mpegtables.h:1074
ConditionalAccessTable::ConditionalAccessTable
ConditionalAccessTable(const PSIPTable &table)
Definition: mpegtables.h:858
PESPacket::pesdata
const unsigned char * pesdata() const
Definition: pespacket.h:165
ProgramAssociationTable::FindProgram
uint FindProgram(uint pid) const
Definition: mpegtables.h:669
ProgramMapTable
A PMT table maps a program described in the ProgramAssociationTable to various PID's which describe t...
Definition: mpegtables.h:692
StreamID::DSMCC_C
@ DSMCC_C
ISO 13818-6 type C NPT DSMCC Data.
Definition: mpegtables.h:136
ProgramMapTable::FindPID
int FindPID(uint pid) const
Locates stream index of pid.
Definition: mpegtables.h:797
ProgramMapTable::PCRPID
uint PCRPID(void) const
stream that contains program clock reference.
Definition: mpegtables.h:726
SpliceInformationTable::SpliceSchedule
SpliceScheduleView SpliceSchedule(void) const
Definition: mpegtables.h:1140
SpliceInformationTable
Definition: mpegtables.h:1027
TSPacket::AFCOffset
unsigned int AFCOffset(void) const
Definition: tspacket.h:211
AdaptationFieldControl::ExtensionLength
uint ExtensionLength(void) const
Definition: mpegtables.h:1259
SpliceScheduleView
Definition: mpegtables.h:917
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:729
SpliceInformationTable::toString
QString toString(void) const override
Definition: mpegtables.h:1192
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
StreamID::MPEG2Video
@ MPEG2Video
ISO 13818-2 & ITU H.262 (aka MPEG-2)
Definition: mpegtables.h:116
SpliceScheduleView::m_ptrs0
std::vector< const unsigned char * > m_ptrs0
Definition: mpegtables.h:961
ProgramAssociationTable::ProgramCount
uint ProgramCount(void) const
Definition: mpegtables.h:636
PESPacket::StreamID
uint StreamID() const
Definition: pespacket.h:99
PSIPTable::ATSCProtocolVersion
uint ATSCProtocolVersion(void) const
Definition: mpegtables.h:555
PSIPTable::SetVersionNumber
void SetVersionNumber(uint ver)
Definition: mpegtables.h:573
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:1244
PSIPTable::SetATSCProtocolVersion
void SetATSCProtocolVersion(int ver)
Definition: mpegtables.h:581
PSIPTable::kPsipOffset
static const uint kPsipOffset
Definition: mpegtables.h:591
ProgramMapTable::StreamTypeString
QString StreamTypeString(uint i) const
Returns a string representation of type at stream index i.
Definition: mpegtables.h:780
PSIPTable::SetCurrent
void SetCurrent(bool cur)
Definition: mpegtables.h:575
PSIPTable::Section
uint Section(void) const
Definition: mpegtables.h:548
SpliceInformationTable::getSCTEPID
int getSCTEPID(void) const
Definition: mpegtables.h:1045
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:1057
StreamID::H265Video
@ H265Video
ISO 23008-2 & ITU H.265 (aka HEVC, Ultra HD)
Definition: mpegtables.h:119
TSHeader::ContinuityCounter
unsigned int ContinuityCounter(void) const
Definition: tspacket.h:90
PSIPTable::PrivateIndicator
bool PrivateIndicator(void) const
Definition: mpegtables.h:520
ConditionalAccessTable::DescriptorsLength
uint DescriptorsLength(void) const
Definition: mpegtables.h:878
SpliceInformationTable::SpliceProtocolVersion
uint SpliceProtocolVersion(void) const
Definition: mpegtables.h:1056
AdaptationFieldControl::Discontinuity
bool Discontinuity(void) const
discontinuity_indicator (time base may change) 1 1.0
Definition: mpegtables.h:1229
Parse
Definition: rssparse.h:188
AdaptationFieldControl::AdaptationFieldControl
AdaptationFieldControl(const unsigned char *packet)
Definition: mpegtables.h:1219
StreamID::MPEG1Video
@ MPEG1Video
ISO 11172-2 (aka MPEG-1)
Definition: mpegtables.h:115
StreamID::EAC3Audio
@ EAC3Audio
A/53 Part 3:2009 6.7.3.
Definition: mpegtables.h:129
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:975
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
SpliceInsertView::SpliceInsertView
SpliceInsertView(std::vector< const unsigned char * > ptrs0, std::vector< const unsigned char * > ptrs1)
Definition: mpegtables.h:968
PSIPTable::toString
virtual QString toString(void) const
Definition: mpegtables.cpp:762
toString
QString toString(MarkTypes type)
Definition: programtypes.cpp:26
ProgramMapTable::RemoveAllStreams
void RemoveAllStreams(void)
Definition: mpegtables.h:806
AdaptationFieldControl::SeamlessSplice
bool SeamlessSplice(void) const
Definition: mpegtables.h:1266
AdaptationFieldControl::PrivateTransportData
bool PrivateTransportData(void) const
Definition: mpegtables.h:1255
SpliceInsertView::IsSpliceImmediate
bool IsSpliceImmediate(void) const
Definition: mpegtables.h:991
SpliceScheduleView::SpliceCount
uint SpliceCount(void) const
Definition: mpegtables.h:926
ProgramAssociationTable::TransportStreamID
uint TransportStreamID(void) const
Definition: mpegtables.h:634
ProgramAssociationTable::ProgramNumber
uint ProgramNumber(uint i) const
Definition: mpegtables.h:643
PSIPTable::SetLastSection
void SetLastSection(uint num)
Definition: mpegtables.h:578
SpliceInformationTable::m_ptrs0
std::vector< const unsigned char * > m_ptrs0
Definition: mpegtables.h:1201
SpliceInformationTable::SetEncryptedPacket
void SetEncryptedPacket(bool val)
Definition: mpegtables.h:1060
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:169
ProgramMapTable::StreamType
uint StreamType(uint i) const
Definition: mpegtables.h:738
StreamID::MPEG2Audio
@ MPEG2Audio
ISO 13818-3.
Definition: mpegtables.h:125
x1
static int x1
Definition: mythsocket.cpp:57
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:1129
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:702
AdaptationFieldControl::LTW
bool LTW(void) const
Definition: mpegtables.h:1262
StreamID::DSMCC_B
@ DSMCC_B
ISO 13818-6 type B Std DSMCC Data.
Definition: mpegtables.h:135
StreamID::MPEG1Audio
@ MPEG1Audio
ISO 11172-3.
Definition: mpegtables.h:124
SpliceInsertView::AvailsExpected
uint AvailsExpected(void) const
Definition: mpegtables.h:1015
PSIPTable::toStringXML
virtual QString toStringXML(uint indent_level) const
Definition: mpegtables.cpp:780
SpliceInsertView::IsOutOfNetwork
bool IsOutOfNetwork(void) const
Definition: mpegtables.h:985
SpliceInformationTable::CodeWordIndex
uint CodeWordIndex(void) const
Definition: mpegtables.h:1100
PESPacket::Length
uint Length() const
Definition: pespacket.h:100
ProgramMapTable::SetStreamPID
void SetStreamPID(uint i, uint pid)
Definition: mpegtables.h:762
PSIPTable::SetSectionLength
void SetSectionLength(uint length)
Definition: mpegtables.h:567
PESPacket::VerifyCRC
bool VerifyCRC(void) const
Definition: pespacket.cpp:170
PID
Contains Packet Identifier numeric values.
Definition: mpegtables.h:206
StreamID::AC3Audio
@ AC3Audio
A/53 Part 3:2009 6.7.1.
Definition: mpegtables.h:128
SpliceInformationTable::SpliceCommandType
uint SpliceCommandType(void) const
Definition: mpegtables.h:1127
RST
@ RST
Definition: cc708decoder.cpp:100
StreamID::MPEG4Video
@ MPEG4Video
ISO 14492-2 (aka MPEG-4)
Definition: mpegtables.h:117
StreamID::H264Video
@ H264Video
ISO 14492-10 & ITU H.264 (aka MPEG-4-AVC)
Definition: mpegtables.h:118
uint
unsigned int uint
Definition: compat.h:140
SpliceTimeView::m_data
const unsigned char * m_data
Definition: mpegtables.h:914
StreamID::DSMCC_A
@ DSMCC_A
ISO 13818-6 type A Multi-protocol Encap.
Definition: mpegtables.h:134
ProgramAssociationTable
The Program Association Table lists all the programs in a stream, and is always found on PID 0.
Definition: mpegtables.h:615
PSIPTable::LastSection
uint LastSection(void) const
Definition: mpegtables.h:551
SpliceScheduleView::m_ptrs1
std::vector< const unsigned char * > m_ptrs1
Definition: mpegtables.h:962
SpliceInsertView::IsSpliceEventCancel
bool IsSpliceEventCancel(void) const
Definition: mpegtables.h:981
SpliceInformationTable::~SpliceInformationTable
~SpliceInformationTable() override
Definition: mpegtables.h:1042
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:825
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:26
PSIPTable::SectionLength
uint SectionLength(void) const
Definition: mpegtables.h:526
SpliceInformationTable::SpliceCommandLength
uint SpliceCommandLength(void) const
Definition: mpegtables.h:1104
TableID::CAT
@ CAT
Definition: mpegtables.h:265
ProgramMapTable::ProgramInfoLength
uint ProgramInfoLength(void) const
Definition: mpegtables.h:732
AdaptationFieldControl::RandomAccess
bool RandomAccess(void) const
Definition: mpegtables.h:1231
pes_alloc
unsigned char * pes_alloc(uint size)
Definition: pespacket.cpp:360
SpliceInformationTable::SetSpliceCommandLength
void SetSpliceCommandLength(uint len)
Definition: mpegtables.h:1108
assert
#define assert(x)
Definition: audiooutputalsa.cpp:18
mythmiscutil.h
PSIPTable::View
static PSIPTable View(const TSPacket &tspacket)
Definition: mpegtables.h:506
ProgramMapTable::SetPCRPID
void SetPCRPID(uint pid)
Definition: mpegtables.h:754
SpliceInsertView::IsProgramSplice
bool IsProgramSplice(void) const
Definition: mpegtables.h:987
ProgramMapTable::SetProgramNumber
void SetProgramNumber(uint num)
Definition: mpegtables.h:760
StreamID::MPEG2AACAudio
@ MPEG2AACAudio
ISO 13818-7 Audio w/ADTS syntax.
Definition: mpegtables.h:126
StreamID::toString
static const char * toString(uint streamID)
Definition: mpegtables.cpp:962
PESPacket::SetStreamID
void SetStreamID(uint id)
Definition: pespacket.h:171
ProgramAssociationTable::ProgramAssociationTable
ProgramAssociationTable(const ProgramAssociationTable &table)
Definition: mpegtables.h:618
SpliceInsertView::AvailNum
uint AvailNum(void) const
Definition: mpegtables.h:1013
PSIPTable::TableID
uint TableID(void) const
Definition: mpegtables.h:515
SpliceInformationTable::SpliceInformationTable
SpliceInformationTable(const SpliceInformationTable &table)
Definition: mpegtables.h:1030
PSIPTable::TableIDExtension
uint TableIDExtension(void) const
Definition: mpegtables.h:532
std
Definition: mythchrono.h:23
PSIPTable::SetSection
void SetSection(uint num)
Definition: mpegtables.h:577
SpliceTimeView::PTSTime
uint64_t PTSTime(void) const
Definition: mpegtables.h:897
ConditionalAccessTable
The CAT is used to transmit additional ConditionalAccessDescriptor instances, in addition to the ones...
Definition: mpegtables.h:855
PESPacket::SetLength
void SetLength(uint len)
Definition: pespacket.h:172
PSIPTable::PSIPTable
PSIPTable(const std::vector< uint8_t > &pesdata)
Definition: mpegtables.h:471
SpliceInformationTable::PTSAdjustment
uint64_t PTSAdjustment(void) const
Definition: mpegtables.h:1082
SpliceInformationTable::SpliceInformationTable
SpliceInformationTable(const PSIPTable &table)
Definition: mpegtables.h:1036
AdaptationFieldControl
AdaptationFieldControl is used to transmit various important stream attributes.
Definition: mpegtables.h:1216
TableID::PMT
@ PMT
Definition: mpegtables.h:266
SpliceInformationTable::SpliceDescriptors
const unsigned char * SpliceDescriptors(void) const
Definition: mpegtables.h:1179
ProgramMapTable::ViewData
static ProgramMapTable ViewData(const unsigned char *pesdata)
Definition: mpegtables.h:708
SpliceInsertView
Definition: mpegtables.h:965
TableID::PAT
@ PAT
Definition: mpegtables.h:264
ProgramMapTable::SetStreamType
void SetStreamType(uint i, uint type)
Definition: mpegtables.h:768
SpliceInformationTable::setSCTEPID
void setSCTEPID(int ts_pid)
Definition: mpegtables.h:1044
StreamID::OpenCableVideo
@ OpenCableVideo
Always MPEG-2??
Definition: mpegtables.h:120
MHEG
Definition: freemheg.h:54
ProgramAssociationTable::FindPID
uint FindPID(uint progNum) const
Definition: mpegtables.h:655
SpliceScheduleView::SpliceEventID
uint SpliceEventID(uint i) const
Definition: mpegtables.h:929
PESPacket::HasCRC
virtual bool HasCRC() const
1 bit Cyclic Redundancy Check present
Definition: pespacket.h:131
SpliceTimeView
Definition: mpegtables.h:888
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
SpliceInsertView::m_ptrs1
std::vector< const unsigned char * > m_ptrs1
Definition: mpegtables.h:1024
PSIPTable::psipdata
unsigned char * psipdata(void)
Definition: mpegtables.h:560
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:1023
ProgramMapTable::m_ptrs
std::vector< unsigned char * > m_ptrs
Definition: mpegtables.h:848
ProgramMapTable::StreamInfoLength
uint StreamInfoLength(uint i) const
Definition: mpegtables.h:744
SpliceTimeView::IsTimeSpecified
bool IsTimeSpecified(void) const
Definition: mpegtables.h:893
SpliceInformationTable::SpliceDescriptorsLength
uint SpliceDescriptorsLength(uint) const
Definition: mpegtables.h:1172
SpliceInformationTable::SpliceInsert
SpliceInsertView SpliceInsert(void) const
Definition: mpegtables.h:1146
SpliceInsertView::IsDuration
bool IsDuration(void) const
Definition: mpegtables.h:989
SpliceTimeView::size
uint size(void) const
Definition: mpegtables.h:912
ProgramMapTable::StreamPID
uint StreamPID(uint i) const
Definition: mpegtables.h:741
AdaptationFieldControl::PCR
bool PCR(void) const
PCR flag (we have PCR data) 1 1.3 (adds 6 bytes after adaptation header)
Definition: mpegtables.h:1240
AdaptationFieldControl::Priority
bool Priority(void) const
Definition: mpegtables.h:1233
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:833
AdaptationFieldControl::m_data
const unsigned char * m_data
Definition: mpegtables.h:1270
ProgramMapTable::ProgramMapTable
ProgramMapTable(const ProgramMapTable &table)
Definition: mpegtables.h:696
SpliceInformationTable::IsEncryptedPacket
bool IsEncryptedPacket(void) const
Definition: mpegtables.h:1059
PSIPTable::Version
uint Version(void) const
Definition: mpegtables.h:539
PSIPTable::SectionSyntaxIndicator
bool SectionSyntaxIndicator(void) const
Definition: mpegtables.h:518
PSIPTable::psipdata
const unsigned char * psipdata(void) const
Definition: mpegtables.h:558
PSIPTable::PSIPTable
PSIPTable(const PESPacket &table)
Definition: mpegtables.h:481
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:1264
AdaptationFieldControl::FieldExtension
bool FieldExtension(void) const
Definition: mpegtables.h:1257
StreamID::DSMCC_D
@ DSMCC_D
ISO 13818-6 type D Any DSMCC Data.
Definition: mpegtables.h:137