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