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& table) = 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);
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  memcpy(m_ptrs[i] + 5, streamInfo, infoLength);
804  }
805 
807  {
808  psipdata()[2] = ((length>>8) & 0x0f) | (psipdata()[2] & 0xf0);
809  psipdata()[3] = length & 0xff;
810  }
811 
812  void SetProgramInfo(unsigned char *streamInfo, uint infoLength)
813  {
814  SetProgramInfoLength(infoLength);
815  memcpy(psipdata() + 4, streamInfo, infoLength);
816  }
817 
818  static ProgramMapTable* CreateBlank(bool smallPacket = true);
819 
820  static const uint kPmtHeaderMinOffset = 4; // minimum PMT header offset
821  mutable vector<unsigned char*> m_ptrs; // used to parse
822 };
823 
829 {
830  public:
831  explicit ConditionalAccessTable(const PSIPTable &table) : PSIPTable(table)
832  {
833  // Section Bits Start Byte sbit
834  // -----------------------------------------
835  // table_id 8 0.0 0
837  // section_syntax_ind 1 1.0 8 should always be 1
838  // private_indicator 1 1.1 9 should always be 0
839  // reserved 2 1.2 10
840  // section_length 12 1.4 12 always less than 0x3fd
841  // table_id_extension 16 3.0 24 unused
842  // reserved 2 5.0 40
843  // version_number 5 5.2 42
844  // current_next_ind 1 5.3 47
845  // section_numben 8 6.0 48
846  // last_section_number 8 7.0 56
847  }
848 
849  // for (i = 0; i < N; i++) 8.0 64
850  // { descriptor() }
852  { return SectionLength() - kPsipOffset; }
853  const unsigned char *Descriptors(void) const { return psipdata(); }
854 
855  QString toString(void) const override; // PSIPTable
856  QString toStringXML(uint indent_level) const override; // PSIPTable
857 
858  // CRC_32 32 rpchof
859 };
860 
862 {
863  public:
864  explicit SpliceTimeView(const unsigned char *data) : m_data(data) { }
865  // time_specified_flag 1 0.0
866  bool IsTimeSpecified(void) const { return ( m_data[0] & 0x80 ) != 0; }
867  // if (time_specified_flag == 1)
868  // reserved 6 0.1
869  // pts_time 33 0.6
870  uint64_t PTSTime(void) const
871  {
872  return ((uint64_t(m_data[0] & 0x1) << 32) |
873  (uint64_t(m_data[1]) << 24) |
874  (uint64_t(m_data[2]) << 16) |
875  (uint64_t(m_data[3]) << 8) |
876  (uint64_t(m_data[4])));
877  }
878  // else
879  // reserved 7 0.1
880  // }
881  virtual QString toString(int64_t first, int64_t last) const;
882  virtual QString toStringXML(
883  uint indent_level, int64_t first, int64_t last) const;
884 
885  uint size(void) const { return IsTimeSpecified() ? 1 : 5; }
886  private:
887  const unsigned char *m_data;
888 };
889 
891 {
892  public:
893  SpliceScheduleView(vector<const unsigned char*> ptrs0,
894  vector<const unsigned char*> ptrs1) :
895  m_ptrs0(std::move(ptrs0)), m_ptrs1(std::move(ptrs1))
896  {
897  }
898  // splice_count 8 14.0
899  uint SpliceCount(void) const { return min(m_ptrs0.size(), m_ptrs1.size()); }
900 
901  // splice_event_id 32 0.0 + m_ptrs0[i]
903  {
904  return ((m_ptrs0[i][0] << 24) | (m_ptrs0[i][1] << 16) |
905  (m_ptrs0[i][2] << 8) | (m_ptrs0[i][3]));
906  }
907  // splice_event_cancel_indicator 1 4.0 + m_ptrs0[i]
908  // reserved 7 4.1 + m_ptrs0[i]
909  // if (splice_event_cancel_indicator == ‘0’) {
910  // out_of_network_indicator 1 5.0 + m_ptrs0[i]
911  // program_splice_flag 1 5.1 + m_ptrs0[i]
912  // duration_flag 1 5.2 + m_ptrs0[i]
913  // reserved 5 5.3 + m_ptrs0[i]
914  // if (program_splice_flag == ‘1’)
915  // utc_splice_time 32 6.0 + m_ptrs0[i]
916  // else {
917  // component_count 8 6.0 + m_ptrs0[i]
918  // for(j = 0; j < component_count; j++) {
919  // component_tag 8 7.0 + m_ptrs0[i]+j*5
920  // utc_splice_time 32 8.0 + m_ptrs0[i]+j*5
921  // }
922  // }
923  // if (duration_flag) {
924  // auto_return 1 0.0 + m_ptrs1[i]
925  // reserved 6 0.1 + m_ptrs1[i]
926  // duration 33 0.7 + m_ptrs1[i]
927  // }
928  // unique_program_id 16 0.0 + m_ptrs1[i] + (duration_flag)?5:0
929  // avail_num 8 2.0 + m_ptrs1[i] + (duration_flag)?5:0
930  // avails_expected 8 3.0 + m_ptrs1[i] + (duration_flag)?5:0
931  // }
932 
933  private:
934  vector<const unsigned char*> m_ptrs0;
935  vector<const unsigned char*> m_ptrs1;
936 };
937 
939 {
940  public:
941  SpliceInsertView(vector<const unsigned char*> ptrs0,
942  vector<const unsigned char*> ptrs1) :
943  m_ptrs0(std::move(ptrs0)), m_ptrs1(std::move(ptrs1))
944  {
945  }
946 
947  // splice_event_id 32 0.0 + m_ptrs1[0]
948  uint SpliceEventID(void) const
949  {
950  return ((m_ptrs1[0][0] << 24) | (m_ptrs1[0][1] << 16) |
951  (m_ptrs1[0][2] << 8) | (m_ptrs1[0][3]));
952  }
953  // splice_event_cancel 1 4.0 + m_ptrs1[0]
954  bool IsSpliceEventCancel(void) const { return ( m_ptrs1[0][4] & 0x80 ) != 0; }
955  // reserved 7 4.1 + m_ptrs1[0]
956  // if (splice_event_cancel_indicator == 0) {
957  // out_of_network_flag 1 5.0 + m_ptrs1[0]
958  bool IsOutOfNetwork(void) const { return ( m_ptrs1[0][5] & 0x80 ) != 0; }
959  // program_splice_flag 1 5.1 + m_ptrs1[0]
960  bool IsProgramSplice(void) const { return ( m_ptrs1[0][5] & 0x40 ) != 0; }
961  // duration_flag 1 5.2 + m_ptrs1[0]
962  bool IsDuration(void) const { return ( m_ptrs1[0][5] & 0x20 ) != 0; }
963  // splice_immediate_flag 1 5.3 + m_ptrs1[0]
964  bool IsSpliceImmediate(void) const { return ( m_ptrs1[0][5] & 0x20 ) != 0; }
965  // reserved 4 5.4 + m_ptrs1[0]
966  // if ((program_splice_flag == 1) && (splice_immediate_flag == ‘0’))
967  // splice_time() 8-38 6.0 + m_ptrs1[0]
969  { return SpliceTimeView(m_ptrs1[0]+6); }
970  // if (program_splice_flag == 0) {
971  // component_count 8 6.0 + m_ptrs1[0]
972  // for (i = 0; i < component_count; i++) {
973  // component_tag 8 0.0 + m_ptrs0[i]
974  // if (splice_immediate_flag == ‘0’)
975  // splice_time() 8-38 1.0 + m_ptrs0[i]
976  // }
977  // }
978  // if (duration_flag == ‘1’)
979  // auto_return 1 0.0 + m_ptrs1[1]
980  // reserved 6 0.1 + m_ptrs1[1]
981  // duration 33 0.7 + m_ptrs1[1]
982  // unique_program_id 16 0.0 + m_ptrs1[2]
983  uint UniqueProgramID(void) const
984  { return (m_ptrs1[2][0]<<8) | m_ptrs1[2][1]; }
985  // avail_num 8 2.0 + m_ptrs1[2]
986  uint AvailNum(void) const { return m_ptrs1[2][2]; }
987  // avails_expected 8 3.0 + m_ptrs1[2]
988  uint AvailsExpected(void) const { return m_ptrs1[2][3]; }
989  // }
990 
991  virtual QString toString(int64_t first, int64_t last) const;
992  virtual QString toStringXML(
993  uint indent_level, int64_t first, int64_t last) const;
994 
995  private:
996  vector<const unsigned char*> m_ptrs0;
997  vector<const unsigned char*> m_ptrs1;
998 };
999 
1001 {
1002  public:
1004  PSIPTable(table)
1005  {
1007  Parse();
1008  }
1009  explicit SpliceInformationTable(const PSIPTable &table) :
1010  PSIPTable(table)
1011  {
1013  Parse();
1014  }
1015  ~SpliceInformationTable() override { ; }
1016 
1017  void setSCTEPID(int ts_pid){m_sctePid = ts_pid;}
1018  int getSCTEPID(void) const {return m_sctePid;}
1019 
1020  // ANCE/SCTE 35 2007
1021  // Name bits loc expected value
1022  // table_id 8 0.0 0xFC
1023  // section_syntax_indicator 1 1.0 1
1024  // private_indicator 1 1.1 0
1025  // reserved 2 1.2 3
1026  // section_length 12 1.4
1027  // ^^^ All above this line provided by PSIPTable
1028  // protocol_version 8 3.0 0
1029  uint SpliceProtocolVersion(void) const { return pesdata()[3]; }
1030  void SetSpliceProtocolVersion(uint ver) { pesdata()[3] = ver; }
1031  // encrypted_packet 1 4.0
1032  bool IsEncryptedPacket(void) const { return ( pesdata()[4] & 0x80 ) != 0; }
1033  void SetEncryptedPacket(bool val)
1034  {
1035  pesdata()[4] = (pesdata()[4] & ~0x80) | ((val) ? 0x80 : 0);
1036  }
1037  // encryption_algorithm 6 4.1
1038  enum
1039  {
1040  kNoEncryption = 0,
1041  kECB = 1, // DES - ECB mode, FIPS PUB 81 (8 byte blocks)
1042  kCBC = 2, // DES - CBC mode, FIPS PUB 81 (8 byte blocks)
1043  k3DES = 3, // 3 DES - TDEA, FIPS PUB 46-3 (8 byte blocks)
1044  // values 4-31 are reserved for future extension
1045  // values 32-63 are user private
1046  };
1047  uint EncryptionAlgorithm(void) const { return (pesdata()[4] >> 1) & 0x3f; }
1048  QString EncryptionAlgorithmString(void) const;
1050  {
1051  pesdata()[4] &= 0x81;
1052  pesdata()[4] |= ((val&0x3f) << 1);
1053  }
1054  // pts_adjustment 33 4.7
1055  uint64_t PTSAdjustment(void) const
1056  {
1057  return ((uint64_t(pesdata()[4] & 0x1) << 32) |
1058  (uint64_t(pesdata()[5]) << 24) |
1059  (uint64_t(pesdata()[6]) << 16) |
1060  (uint64_t(pesdata()[7]) << 8) |
1061  (uint64_t(pesdata()[8])));
1062  }
1063  void SetPTSAdjustment(uint64_t val)
1064  {
1065  pesdata()[4] &= ~0x1;
1066  pesdata()[4] |= (val>>32) & 0x1;
1067  pesdata()[5] = ((val>>24) & 0xff);
1068  pesdata()[6] = ((val>>16) & 0xff);
1069  pesdata()[7] = ((val>>8 ) & 0xff);
1070  pesdata()[8] = ((val ) & 0xff);
1071  }
1072  // cw_index (enc key) 8 9.0
1073  uint CodeWordIndex(void) const { return pesdata()[9]; }
1074  void SetCodeWordIndex(uint val) { pesdata()[9] = val; }
1075  // reserved 12 10.0
1076  // splice_command_length 12 11.4
1078  {
1079  return ((pesdata()[11] & 0xf) << 8) | pesdata()[12];
1080  }
1082  {
1083  pesdata()[11] &= ~0xf;
1084  pesdata()[11] |= (len >> 8) & 0xf;
1085  pesdata()[12] = len & 0xff;
1086  }
1087  // splice_command_type 8 13.0
1088  enum {
1089  kSCTNull = 0x00,
1090  kSCTReserved0 = 0x01,
1091  kSCTReserved1 = 0x02,
1092  kSCTReserved2 = 0x03,
1093  kSCTSpliceSchedule = 0x04,
1094  kSCTSpliceInsert = 0x05,
1095  kSCTTimeSignal = 0x06,
1096  kSCTBandwidthReservation = 0x07,
1097  // 0x08-0xfe reserved
1098  kSCTPrivateCommand = 0xff,
1099  };
1100  uint SpliceCommandType(void) const { return pesdata()[13]; }
1101  QString SpliceCommandTypeString(void) const;
1102  void SetSpliceCommandType(uint type) { pesdata()[13] = type & 0xff; }
1103 
1104  // ALL BELOW THIS LINE OTHER THAN CRC_32 ARE ENCRYPTED IF FLAG SET
1105 
1107 
1108  // nothing here, info in descriptors
1109 
1111 
1112  // if (splice_command_type == 0x04) splice_schedule()
1114  { return SpliceScheduleView(m_ptrs0, m_ptrs1); }
1115 
1117 
1118  // if (splice_command_type == 0x05) splice_insert()
1120  { return SpliceInsertView(m_ptrs0, m_ptrs1); }
1121 
1123 
1124  // if (splice_command_type == 0x06) splice_time()
1126  { return SpliceTimeView(pesdata()+14); }
1127 
1129 
1130  // nothing here, info in descriptors
1131 
1133 
1134  // if (splice_command_type == 0xff) private_command()
1135  // identifier 32 14.0
1136  // for (i = 0; i < N; i++)
1137  // private_byte 8 ??.0
1138  //
1139 
1141  // NOTE: Aside from CRC's we can not interpret things below
1142  // this comment with private or reserved commands.
1143 
1144  // descriptor_loop_length 16 0.0 + m_epilog
1146  {
1147  return (m_epilog[0] << 8) | m_epilog[1];
1148  }
1149 
1150  // for (i = 0; i < ? ; i++)
1151  // splice_descriptor() ?? ??.?
1152  const unsigned char *SpliceDescriptors(void) const
1153  {
1154  return (m_epilog) ? m_epilog + 2 : nullptr;
1155  }
1156  // for (i = 0; i < ?; i++)
1157  // alignment_stuffing 8 ??.0
1158  // if (encrypted_packet())
1159  // E_CRC_32 32 ??.0
1160  // CRC_32 32 ??.0
1161 
1162  static SpliceInformationTable *GetDecrypted(const QString &codeWord);
1163  bool Parse(void);
1164 
1165  QString toString(void) const override // PSIPTable
1166  { return toString(-1LL, -1LL); }
1167  QString toStringXML(uint indent_level) const override // PSIPTable
1168  { return toStringXML(indent_level, -1LL, -1LL); }
1169 
1170  QString toString(int64_t first, int64_t last) const;
1171  QString toStringXML(uint indent_level, int64_t first, int64_t last) const;
1172 
1173  private:
1174  vector<const unsigned char*> m_ptrs0;
1175  vector<const unsigned char*> m_ptrs1;
1176  const unsigned char *m_epilog {nullptr};
1177  int m_sctePid {0};
1178 };
1179 
1190 {
1191  public:
1192  explicit AdaptationFieldControl(const unsigned char* packet) : m_data(packet) { ; }
1193 
1197  uint Length(void) const { return m_data[0]; }
1198 
1202  bool Discontinuity(void) const { return ( m_data[1] & 0x80 ) != 0; }
1203  // random_access_indicator (?) 1 1.1
1204  bool RandomAccess(void) const { return bool(m_data[1] & 0x40); }
1205  // elementary_stream_priority_indicator 1 1.2
1206  bool Priority(void) const { return bool(m_data[1] & 0x20); }
1207 
1208 // Each of the following extends the adaptation header. In order:
1209 
1213  bool PCR(void) const { return bool(m_data[1] & 0x10); }
1217  bool OPCR(void) const { return bool(m_data[1] & 0x08); }
1225  bool SplicingPoint(void) const { return bool(m_data[1] & 0x04); }
1226  // transport_private_data_flag 1 1.6
1227  // (adds 1 byte)
1228  bool PrivateTransportData(void) const { return bool(m_data[1] & 0x02); }
1229  // adaptation_field_extension_flag 1 1.7
1230  bool FieldExtension(void) const { return bool(m_data[1] & 0x1); }
1231  // extension length 8 2.0
1232  uint ExtensionLength(void) const { return m_data[2]; }
1233  // ltw flag 1 3.0
1234  // (adds 2 bytes)
1235  bool LTW(void) const { return bool(m_data[3] & 0x80); }
1236  // piecewise_rate_flag (adds 3 bytes) 1 3.1
1237  bool PiecewiseRate(void) const { return bool(m_data[3] & 0x40); }
1238  // seamless_splice_flag (adds 5 bytes) 1 3.2
1239  bool SeamlessSplice(void) const { return bool(m_data[3] & 0x20); }
1240  // unused flags 5 3.3
1241 
1242  private:
1243  const unsigned char* m_data;
1244 };
1245 
1246 #endif
uint SpliceEventID(void) const
Definition: mpegtables.h:948
Used to access the data of a Transport Stream packet.
Definition: tspacket.h:166
uint AvailNum(void) const
Definition: mpegtables.h:986
const unsigned char * pesdata() const
Definition: pespacket.h:158
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:1225
const unsigned char * psipdata(void) const
Definition: mpegtables.h:532
uint Version(void) const
Definition: mpegtables.h:513
ISO 13818-3/AMD-1 Audio using LATM syntax.
Definition: mpegtables.h:127
unsigned char * m_fullBuffer
Pointer to allocated data.
Definition: pespacket.h:213
uint Length() const
Definition: pespacket.h:93
void SetPTSAdjustment(uint64_t val)
Definition: mpegtables.h:1063
SpliceInformationTable(const PSIPTable &table)
Definition: mpegtables.h:1009
void SetLength(uint len)
Definition: pespacket.h:165
void SetPCRPID(uint pid)
Definition: mpegtables.h:728
ProgramMapTable(const ProgramMapTable &table)
Definition: mpegtables.h:670
uint ProgramCount(void) const
Definition: mpegtables.h:610
uint SpliceProtocolVersion(void) const
Definition: mpegtables.h:1029
QString toString(void) const override
Definition: mpegtables.h:1165
SpliceTimeView(const unsigned char *data)
Definition: mpegtables.h:864
ConditionalAccessTable(const PSIPTable &table)
Definition: mpegtables.h:831
void SetCodeWordIndex(uint val)
Definition: mpegtables.h:1074
PSIPTable(const PESPacket &table)
Definition: mpegtables.h:452
ProgramAssociationTable(const ProgramAssociationTable &table)
Definition: mpegtables.h:592
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:1217
QString toString(MarkTypes type)
void SetLastSection(uint num)
Definition: mpegtables.h:552
uint TableIDExtension(void) const
Definition: mpegtables.h:506
virtual bool HasCRC() const
1 bit Cyclic Redundancy Check present
Definition: pespacket.h:124
bool FieldExtension(void) const
Definition: mpegtables.h:1230
uint SectionLength(void) const
Definition: mpegtables.h:500
uint AvailsExpected(void) const
Definition: mpegtables.h:988
uint SpliceDescriptorsLength(uint) const
Definition: mpegtables.h:1145
bool IsOutOfNetwork(void) const
Definition: mpegtables.h:958
static PSIPTable ViewData(const unsigned char *pesdata)
Definition: mpegtables.h:483
PSIPTable(const unsigned char *pesdata)
Constructor for viewing a section, does not create it's own data.
Definition: mpegtables.h:442
uint EncryptionAlgorithm(void) const
Definition: mpegtables.h:1047
void InitPESPacket(TSPacket &tspacket)
Only handles single TS packet PES packets, for PMT/PAT tables basically.
Definition: mpegtables.h:389
static bool IsAudio(uint type)
Returns true iff audio is MPEG1/2, AAC, AC3 or DTS audio stream.
Definition: mpegtables.h:179
void SetStreamType(uint i, uint type)
Definition: mpegtables.h:742
uint ProgramNumber(uint i) const
Definition: mpegtables.h:617
AdaptationFieldControl is used to transmit various important stream attributes.
Definition: mpegtables.h:1189
uint LastSection(void) const
Definition: mpegtables.h:525
bool PrivateIndicator(void) const
Definition: mpegtables.h:494
void SetProgramNumber(uint num)
Definition: mpegtables.h:734
ISO 13818-7 Audio w/ADTS syntax.
Definition: mpegtables.h:126
bool IsEncryptedPacket(void) const
Definition: mpegtables.h:1032
uint FindAnyPID(void) const
Definition: mpegtables.h:636
PSIPTable(const TSPacket &table)
Definition: mpegtables.h:458
bool
Definition: pxsup2dast.c:30
void SetStreamID(uint id)
Definition: pespacket.h:164
const unsigned char * m_data
Definition: mpegtables.h:887
unsigned int ContinuityCounter(void) const
Definition: tspacket.h:87
void SetStreamInfoLength(uint i, uint length)
Definition: mpegtables.h:793
void SetATSCProtocolVersion(int ver)
Definition: mpegtables.h:555
ISO 13818-6 type C NPT DSMCC Data.
Definition: mpegtables.h:136
const unsigned char * Descriptors(void) const
Definition: mpegtables.h:853
void RemoveAllStreams(void)
Definition: mpegtables.h:780
vector< const unsigned char * > m_ptrs1
Definition: mpegtables.h:1175
int getSCTEPID(void) const
Definition: mpegtables.h:1018
void SetSection(uint num)
Definition: mpegtables.h:551
uint ExtensionLength(void) const
Definition: mpegtables.h:1232
bool IsCurrent(void) const
Definition: mpegtables.h:519
unsigned char * pes_alloc(uint size)
Definition: pespacket.cpp:330
SpliceScheduleView(vector< const unsigned char * > ptrs0, vector< const unsigned char * > ptrs1)
Definition: mpegtables.h:893
SpliceInsertView(vector< const unsigned char * > ptrs0, vector< const unsigned char * > ptrs1)
Definition: mpegtables.h:941
ProgramAssociationTable(const PSIPTable &table)
Definition: mpegtables.h:598
void SetProgramInfoLength(uint length)
Definition: mpegtables.h:806
vector< const unsigned char * > m_ptrs1
Definition: mpegtables.h:935
uint SpliceCommandType(void) const
Definition: mpegtables.h:1100
uint PCRPID(void) const
stream that contains program clock reference.
Definition: mpegtables.h:700
bool SeamlessSplice(void) const
Definition: mpegtables.h:1239
static const uint kPsipOffset
Definition: mpegtables.h:565
uint Section(void) const
Definition: mpegtables.h:522
bool IsSpliceEventCancel(void) const
Definition: mpegtables.h:954
vector< const unsigned char * > desc_list_t
unsigned int StartOfFieldPointer(void) const
Definition: tspacket.h:213
void SetSpliceProtocolVersion(uint ver)
Definition: mpegtables.h:1030
unsigned int AFCOffset(void) const
Definition: tspacket.h:208
bool PayloadStart(void) const
Definition: tspacket.h:67
unsigned char * psipdata(void)
Definition: mpegtables.h:534
uint UniqueProgramID(void) const
Definition: mpegtables.h:983
static bool IsVideo(uint type)
Returns true iff video is an MPEG1/2/3, H264 or open cable video stream.
Definition: mpegtables.h:168
uint StreamInfoLength(uint i) const
Definition: mpegtables.h:718
uint StreamType(uint i) const
Definition: mpegtables.h:712
void SetEncryptedPacket(bool val)
Definition: mpegtables.h:1033
void SetSpliceCommandType(uint type)
Definition: mpegtables.h:1102
Definition: freemheg.h:48
A PSIP table is a variant of a PES packet containing an MPEG, ATSC or DVB table.
Definition: mpegtables.h:386
vector< const unsigned char * > m_ptrs1
Definition: mpegtables.h:997
void SetSpliceCommandLength(uint len)
Definition: mpegtables.h:1081
uint StreamPID(uint i) const
Definition: mpegtables.h:715
bool LTW(void) const
Definition: mpegtables.h:1235
bool IsProgramSplice(void) const
Definition: mpegtables.h:960
uint StreamID() const
Definition: pespacket.h:92
#define MTV_PUBLIC
Definition: mythtvexp.h:15
The CAT is used to transmit additional ConditionalAccessDescriptor instances, in addition to the ones...
Definition: mpegtables.h:828
uint StreamCount(void) const
Definition: mpegtables.h:724
bool PrivateTransportData(void) const
Definition: mpegtables.h:1228
const unsigned char * StreamInfo(uint i) const
Definition: mpegtables.h:721
SpliceTimeView SpliceTime(void) const
Definition: mpegtables.h:968
SpliceScheduleView SpliceSchedule(void) const
Definition: mpegtables.h:1113
SMPTE 421M video codec (aka VC1) in Blu-Ray.
Definition: mpegtables.h:121
ISO 11172-3.
Definition: mpegtables.h:124
bool SectionSyntaxIndicator(void) const
Definition: mpegtables.h:492
void SetSectionLength(uint length)
Definition: mpegtables.h:541
ISO 23008-2 & ITU H.265 (aka HEVC, Ultra HD)
Definition: mpegtables.h:119
uint SpliceCommandLength(void) const
Definition: mpegtables.h:1077
bool Discontinuity(void) const
discontinuity_indicator (time base may change) 1 1.0
Definition: mpegtables.h:1202
Contains listing of Table ID's for various tables (PAT=0,PMT=2,etc).
Definition: mpegtables.h:248
vector< const unsigned char * > m_ptrs0
Definition: mpegtables.h:1174
uint DescriptorsLength(void) const
Definition: mpegtables.h:851
AdaptationFieldControl(const unsigned char *packet)
Definition: mpegtables.h:1192
uint CodeWordIndex(void) const
Definition: mpegtables.h:1073
void SetStreamProgramInfo(uint i, unsigned char *streamInfo, uint infoLength)
Definition: mpegtables.h:799
ISO 13818-3.
Definition: mpegtables.h:125
unsigned int uint
Definition: compat.h:140
Contains a listing of PES Stream ID's for various PES Packet types.
Definition: mpegtables.h:44
A/53 Part 3:2009 6.7.1.
Definition: mpegtables.h:128
bool IsTimeSpecified(void) const
Definition: mpegtables.h:866
The Program Association Table lists all the programs in a stream, and is always found on PID 0.
Definition: mpegtables.h:589
void SetTableIDExtension(uint len)
Definition: mpegtables.h:542
void SetCurrent(bool cur)
Definition: mpegtables.h:549
uint TransportStreamID(void) const
Definition: mpegtables.h:608
ProgramMapTable(const PSIPTable &table)
Definition: mpegtables.h:676
ISO 13818-6 type D Any DSMCC Data.
Definition: mpegtables.h:137
void SetStreamPID(uint i, uint pid)
Definition: mpegtables.h:736
const unsigned char * data(void) const
Definition: tspacket.h:152
ISO 14492-2 (aka MPEG-4)
Definition: mpegtables.h:117
void SetTranportStreamID(uint gtsid)
Definition: mpegtables.h:626
bool IsDuration(void) const
Definition: mpegtables.h:962
QString StreamTypeString(uint i) const
Returns a string representation of type at stream index i.
Definition: mpegtables.h:754
SpliceInformationTable(const SpliceInformationTable &table)
Definition: mpegtables.h:1003
uint TableID(void) const
Definition: mpegtables.h:489
ISO 14492-10 & ITU H.264 (aka MPEG-4-AVC)
Definition: mpegtables.h:118
#define LOG(_MASK_, _LEVEL_, _STRING_)
Definition: mythlogging.h:41
int FindPID(uint pid) const
Locates stream index of pid.
Definition: mpegtables.h:771
static const unsigned int kSize
Definition: tspacket.h:220
vector< unsigned char * > m_ptrs
Definition: mpegtables.h:821
#define assert(x)
uint ProgramNumber(void) const
Definition: mpegtables.h:703
vector< const unsigned char * > m_ptrs0
Definition: mpegtables.h:934
static bool IsObjectCarousel(uint type)
Returns true iff stream contains DSMCC Object Carousel.
Definition: mpegtables.h:190
uint ProgramInfoLength(void) const
Definition: mpegtables.h:706
static ProgramMapTable ViewData(const unsigned char *pesdata)
Definition: mpegtables.h:682
static const char * toString(uint streamID)
Definition: mpegtables.cpp:962
static PSIPTable View(const TSPacket &tspacket)
Definition: mpegtables.h:477
bool Priority(void) const
Definition: mpegtables.h:1206
bool IsSpliceImmediate(void) const
Definition: mpegtables.h:964
const unsigned char * m_data
Definition: mpegtables.h:1243
uint FindPID(uint progNum) const
Definition: mpegtables.h:629
virtual QString toString(void) const
Definition: mpegtables.cpp:762
void SetVersionNumber(uint ver)
Definition: mpegtables.h:547
void SetProgramInfo(unsigned char *streamInfo, uint infoLength)
Definition: mpegtables.h:812
Allows us to transform TS packets to PES packets, which are used to hold multimedia streams and very ...
Definition: pespacket.h:25
void setSCTEPID(int ts_pid)
Definition: mpegtables.h:1017
uint64_t PTSTime(void) const
Definition: mpegtables.h:870
PSIPTable(const TSPacket &tspacket, const unsigned char *pesdata, uint pes_size)
Definition: mpegtables.h:425
uint SpliceCount(void) const
Definition: mpegtables.h:899
bool PiecewiseRate(void) const
Definition: mpegtables.h:1237
QString toStringXML(uint indent_level) const override
Definition: mpegtables.h:1167
const unsigned char * SpliceDescriptors(void) const
Definition: mpegtables.h:1152
bool RandomAccess(void) const
Definition: mpegtables.h:1204
uint64_t PTSAdjustment(void) const
Definition: mpegtables.h:1055
uint m_psiOffset
AFCOffset + StartOfFieldPointer.
Definition: pespacket.h:215
bool VerifyCRC(void) const
Definition: pespacket.cpp:153
bool PCR(void) const
PCR flag (we have PCR data) 1 1.3 (adds 6 bytes after adaptation header)
Definition: mpegtables.h:1213
~SpliceInformationTable() override
Definition: mpegtables.h:1015
vector< const unsigned char * > m_ptrs0
Definition: mpegtables.h:996
PSIPTable(const TSPacket &tspacket, bool)
Definition: mpegtables.h:412
The all-ones PID value 0x1FFF indicates a Null TS Packet introduced to maintain a constant bit rate o...
Definition: mpegtables.h:236
uint FindProgram(uint pid) const
Definition: mpegtables.h:643
static PSIPTable View(TSPacket &tspacket)
Definition: mpegtables.h:480
uint size(void) const
Definition: mpegtables.h:885
uint ATSCProtocolVersion(void) const
Definition: mpegtables.h:529
ISO 13818-2 & ITU H.262 (aka MPEG-2)
Definition: mpegtables.h:116
SpliceInsertView SpliceInsert(void) const
Definition: mpegtables.h:1119
Contains listing of PMT Stream ID's for various A/V Stream types.
Definition: mpegtables.h:109
ISO 13818-6 type A Multi-protocol Encap.
Definition: mpegtables.h:134
A/53 Part 3:2009 6.7.3.
Definition: mpegtables.h:129
void SetEncryptionAlgorithm(uint val)
Definition: mpegtables.h:1049
virtual QString toStringXML(uint indent_level) const
Definition: mpegtables.cpp:780
A PMT table maps a program described in the ProgramAssociationTable to various PID's which describe t...
Definition: mpegtables.h:666
const unsigned char * ProgramInfo(void) const
Definition: mpegtables.h:709
uint Length(void) const
adaptation header length (after which is payload data) 8 0.0
Definition: mpegtables.h:1197
ISO 11172-2 (aka MPEG-1)
Definition: mpegtables.h:115
ISO 13818-6 type B Std DSMCC Data.
Definition: mpegtables.h:135
uint SpliceEventID(uint i) const
Definition: mpegtables.h:902
static int x1
Definition: mythsocket.cpp:60
SpliceTimeView TimeSignal(void) const
Definition: mpegtables.h:1125
uint ProgramPID(uint i) const
Definition: mpegtables.h:620
void SetTableID(uint id)
Definition: mpegtables.h:538
Always MPEG-2??
Definition: mpegtables.h:120