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