MythTV  master
mpegtables.cpp
Go to the documentation of this file.
1 // -*- Mode: c++ -*-
2 // Copyright (c) 2003-2004, Daniel Thor Kristjansson
3 
4 #include "splicedescriptors.h"
5 #include "atscdescriptors.h"
6 #include "mythmiscutil.h" // for xml_indent
7 #include "mythlogging.h"
8 #include "mpegtables.h"
9 
10 const unsigned char DEFAULT_PAT_HEADER[8] =
11 {
12  0x00, // TableID::PAT
13  0xb0, // Syntax indicator
14  0x00, // Length (set separately)
15  0x00, // Transport stream ID top bits
16 
17  0x00, // Transport stream ID bottom bits
18  0xc1, // current | reserved
19  0x00, // Current Section
20  0x00, // Last Section
21 };
22 
23 const unsigned char DEFAULT_PMT_HEADER[12] =
24 {
25  0x02, // TableID::PMT
26  0xb0, // Syntax indicator
27  0x00, // Length (set separately)
28  0x00, // MPEG Program number top bits (set separately)
29 
30  0x00, // MPEG Program number bottom bits (set separately)
31  0xc1, // Version + Current/Next
32  0x00, // Current Section
33  0x00, // Last Section
34  0xff, 0xff, // PCR pid
35  0x00, 0x00, // Program Info Length
36 };
37 
38 static const uint len_for_alloc[] =
39 {
41  - 1 /* for start of field pointer */
42  - 3 /* for data before data last byte of pes length */,
43  4000,
44 };
45 
46 uint StreamID::Normalize(uint stream_id, const desc_list_t &desc,
47  const QString &sistandard)
48 {
49  if ((sistandard != "dvb") && (OpenCableVideo == stream_id))
50  return MPEG2Video;
51 
52  /* normalize DVB style signalling to ATSC style signalling to make
53  * IsAudio work with either, see A/52:2010 A4 vs A5 */
55  return AC3Audio;
56 
57  /* normalize DVB style signalling to ATSC style signalling to make
58  * IsAudio work with either */
60  return EAC3Audio;
61 
62  QString reg;
63  const unsigned char *d = MPEGDescriptor::Find(
65  if (d)
66  {
68  if (rd.IsValid())
69  reg = rd.FormatIdentifierString();
70  }
71 
72  /* normalize all three DTS frame sizes, via http://www.smpte-ra.org/mpegreg/mpegreg.html */
73  if ((reg == "DTS1") || (reg == "DTS2") || (reg == "DTS3"))
74  return DTSAudio;
75 
76  /* normalize AC-3 signalling according to A/52:2010 A4 */
77  if (reg == "AC-3")
78  return AC3Audio;
79 
80  /* normalize E-AC-3 signalling with guesswork via http://www.smpte-ra.org/mpegreg/mpegreg.html */
81  if (reg == "EAC3")
82  return EAC3Audio;
83 
84 #if 0
85  // not needed while there is no specific stream id for these
88  return stream_id;
89 #endif
90 
91  return stream_id;
92 }
93 
94 bool PSIPTable::HasCRC(void) const
95 {
96  // default is false, but gets set to true for 0x80-0xfe at the end!
97  bool has_crc = false;
98 
99  switch (TableID())
100  {
101  // MPEG
102  case TableID::PAT: // NOLINT(bugprone-branch-clone)
103  case TableID::CAT:
104  case TableID::PMT:
105  has_crc = true;
106  break;
107 // case TableID::TSDT
108 
109  // DVB manditory
110  case TableID::NIT:
111  case TableID::SDT:
112  case TableID::PF_EIT:
113  has_crc = true;
114  break;
115  case TableID::TDT:
116  has_crc = false;
117  break;
118 
119  // DVB optional
120  case TableID::NITo:
121  case TableID::SDTo:
122  case TableID::BAT:
123  case TableID::PF_EITo:
124  has_crc = true;
125  break;
126  case TableID::RST:
127  case TableID::ST:
128  has_crc = false;
129  break;
130  case TableID::TOT:
131  has_crc = true;
132  break;
133 // case TableID::RNT:
134 // case TableID::CT:
135 // case TableID::RCT:
136 // case TableID::CIT:
137 // case TableID::MPEFEC:
138  case TableID::DIT:
139  has_crc = false;
140  break;
141  case TableID::SIT: // NOLINT(bugprone-branch-clone)
142  has_crc = true;
143  break;
144 
145  // SCTE
146  case TableID::NITscte:
147  case TableID::NTT:
148  case TableID::SVCTscte:
149  case TableID::STTscte:
150  case TableID::SITscte:
151  has_crc = true;
152  break;
153  case TableID::ADET:
154  has_crc = false;
155  break;
156 
157  // ATSC
158  case TableID::MGT:
159  case TableID::TVCT:
160  case TableID::CVCT:
161  case TableID::RRT:
162  case TableID::EIT:
163  case TableID::ETT:
164  case TableID::STT:
165  case TableID::DET:
166  case TableID::DST:
167 
168  //case TableID::PIT:
169  case TableID::NRT:
170  case TableID::LTST:
171  case TableID::DCCT:
172  case TableID::DCCSCT:
173  //case TableID::SITatsc:
174  case TableID::AEIT:
175  case TableID::AETT:
176  case TableID::SVCT:
177  has_crc = true;
178  break;
179 
180  default:
181  {
182  // DVB Longterm EIT data
183  if (TableID::SC_EITbeg <= TableID() &&
185  {
186  has_crc = true;
187  }
188 
189  // FIXME Dishnet Longterm EIT data, only on PID 0x300! Forces
190  // table_id 0x80-0xfe to true, unless handled before or after!
191  if (TableID::DN_EITbego <= TableID() &&
193  {
194  has_crc = true;
195  }
196 
197  // ATSC/DVB conditional access ECM/EMM, reset to false after Dishnet
198  if (TableID::ECM0 <= TableID() &&
200  {
201  has_crc = false;
202  }
203  }
204  break;
205  }
206 
207  return has_crc;
208 }
209 
211 {
212  bool has_sn = false;
213  switch (TableID())
214  {
215  // MPEG
216  case TableID::PAT:
217  case TableID::CAT:
218  case TableID::PMT:
219  // ATSC
220  case TableID::MGT:
221  case TableID::TVCT:
222  case TableID::CVCT:
223  case TableID::RRT:
224  case TableID::EIT:
225  case TableID::ETT:
226  case TableID::STT:
227  case TableID::DET:
228  case TableID::DST:
229  has_sn = true;
230  break;
231  }
232 
233  return has_sn;
234 }
235 
236 bool PSIPTable::VerifyPSIP(bool verify_crc) const
237 {
238  if (verify_crc && (CalcCRC() != CRC()))
239  {
240  LOG(VB_SIPARSER, LOG_ERR,
241  QString("PSIPTable: Failed CRC check 0x%1 != 0x%2 "
242  "for StreamID = 0x%3")
243  .arg(CRC(),0,16).arg(CalcCRC(),0,16).arg(StreamID(),0,16));
244  return false;
245  }
246 
247  unsigned char *bufend = m_fullBuffer + m_allocSize;
248 
249  if ((m_pesData + 2) >= bufend)
250  return false; // can't query length
251 
252  if (psipdata() >= bufend)
253  return false; // data outside buffer
254 
255  if (TableID::PAT == TableID())
256  {
257  uint pcnt = (SectionLength() - kPsipOffset - 2) >> 2;
258  bool ok = (psipdata() + (pcnt << 2) + 3 < bufend);
259  if (!ok)
260  {
261  LOG(VB_SIPARSER, LOG_ERR,
262  "PSIPTable: PAT: program list extends past end of buffer");
263  return false;
264  }
265 
266  if ((Length() == 0xfff) && (TableIDExtension() == 0xffff) &&
267  (Section() == 0xff) && (LastSection() == 0xff))
268  {
269  LOG(VB_SIPARSER, LOG_ERR, "PSIPTable: PAT: All values at maximums");
270  return false;
271  }
272 
273  return true;
274  }
275 
276  if (TableID::PMT == TableID())
277  {
278  if (psipdata() + 3 >= bufend)
279  {
280  LOG(VB_SIPARSER, LOG_ERR,
281  "PSIPTable: PMT: can't query program info length");
282  return false;
283  }
284 
285  if (psipdata() + Length() - 9 > bufend)
286  {
287  LOG(VB_SIPARSER, LOG_ERR,
288  "PSIPTable: PMT: reported length too large");
289  return false;
290  }
291 
292  uint proginfolen = ((psipdata()[2]<<8) | psipdata()[3]) & 0x0fff;
293  const unsigned char *proginfo = psipdata() + 4;
294  const unsigned char *cpos = proginfo + proginfolen;
295  if (cpos > bufend)
296  {
297  LOG(VB_SIPARSER, LOG_ERR,
298  "PSIPTable: PMT: program info extends past end of buffer");
299  return false;
300  }
301 
302  const unsigned char *pos = cpos;
303  uint i = 0;
304  for (; pos < psipdata() + Length() - 9; i++)
305  {
306  const unsigned char *ptr = pos;
307  if (pos + 4 > bufend)
308  {
309  LOG(VB_SIPARSER, LOG_ERR,
310  QString("PSIPTable: PMT: stream info %1 extends "
311  "past end of buffer").arg(i));
312  return false;
313  }
314  pos += 5 + (((ptr[3] << 8) | ptr[4]) & 0x0fff);
315  }
316  if (pos > bufend)
317  {
318  LOG(VB_SIPARSER, LOG_ERR,
319  QString("PSIPTable: PMT: last stream info %1 extends "
320  "past end of buffer").arg(i));
321  return false;
322  }
323 
324  return true;
325  }
326 
327  return true;
328 }
329 
331 {
332  (void) smallPacket; // currently always a small packet..
334  memcpy(tspacket->data() + sizeof(TSHeader) + 1/* start of field pointer */,
336  PSIPTable psip = PSIPTable::View(*tspacket);
337  psip.SetLength(TSPacket::kPayloadSize
338  - 1 /* for start of field pointer */
339  - 3 /* for data before data last byte of pes length */);
340  auto *pat = new ProgramAssociationTable(psip);
341  pat->SetTotalLength(sizeof(DEFAULT_PAT_HEADER));
342  delete tspacket;
343  return pat;
344 }
345 
347  uint tsid, uint version,
348  const vector<uint>& pnum, const vector<uint>& pid)
349 {
350  const uint count = min(pnum.size(), pid.size());
352  pat->SetVersionNumber(version);
353  pat->SetTranportStreamID(tsid);
354  pat->SetTotalLength(kPsipOffset + (count * 4));
355 
356  // create PAT data
357  if ((count * 4) >= (184 - (kPsipOffset+1)))
358  { // old PAT must be in single TS for this create function
359  LOG(VB_GENERAL, LOG_ERR,
360  "PAT::Create: Error, old PAT size exceeds maximum PAT size.");
361  delete pat;
362  return nullptr;
363  }
364 
365  uint offset = kPsipOffset;
366  for (uint i = 0; i < count; i++)
367  {
368  // pnum
369  pat->pesdata()[offset++] = pnum[i]>>8;
370  pat->pesdata()[offset++] = pnum[i] & 0xff;
371  // pid
372  pat->pesdata()[offset++] = ((pid[i]>>8) & 0x1f) | 0xe0;
373  pat->pesdata()[offset++] = pid[i] & 0xff;
374  }
375 
376  pat->Finalize();
377 
378  return pat;
379 }
380 
382 {
383  ProgramMapTable *pmt = nullptr;
385  memcpy(tspacket->data() + sizeof(TSHeader) + 1/* start of field pointer */,
387 
388  if (smallPacket)
389  {
390  PSIPTable psip = PSIPTable::View(*tspacket);
391  psip.SetLength(len_for_alloc[0]);
392  pmt = new ProgramMapTable(psip);
393  }
394  else
395  {
396  PSIPTable psip(*tspacket);
397  psip.SetLength(len_for_alloc[1]);
398  pmt = new ProgramMapTable(psip);
399  }
400 
401  pmt->SetTotalLength(sizeof(DEFAULT_PMT_HEADER));
402  delete tspacket;
403  return pmt;
404 }
405 
407  uint programNumber, uint basepid, uint pcrpid, uint version,
408  vector<uint> pids, vector<uint> types)
409 {
410  const uint count = min(pids.size(), types.size());
411  ProgramMapTable* pmt = CreateBlank(false);
412  pmt->tsheader()->SetPID(basepid);
413 
414  pmt->RemoveAllStreams();
415  pmt->SetProgramNumber(programNumber);
416  pmt->SetPCRPID(pcrpid);
417  pmt->SetVersionNumber(version);
418 
419  for (uint i=0; i<count; i++)
420  pmt->AppendStream(pids[i], types[i]);
421  pmt->Finalize();
422 
423  return pmt;
424 }
425 
427  uint programNumber, uint basepid, uint pcrpid, uint version,
428  const desc_list_t &global_desc,
429  const vector<uint> &pids,
430  const vector<uint> &types,
431  const vector<desc_list_t> &prog_desc)
432 {
433  const uint count = min(pids.size(), types.size());
434  ProgramMapTable* pmt = CreateBlank(false);
435  pmt->tsheader()->SetPID(basepid);
436 
437  pmt->RemoveAllStreams();
438  pmt->SetProgramNumber(programNumber);
439  pmt->SetPCRPID(pcrpid);
440  pmt->SetVersionNumber(version);
441 
442  vector<unsigned char> gdesc;
443  for (auto gd : global_desc)
444  {
445  uint len = gd[1] + 2;
446  gdesc.insert(gdesc.end(), gd, gd + len);
447  }
448  pmt->SetProgramInfo(gdesc.data(), gdesc.size());
449 
450  for (uint i = 0; i < count; i++)
451  {
452  vector<unsigned char> pdesc;
453  for (auto pd : prog_desc[i])
454  {
455  uint len = pd[1] + 2;
456  pdesc.insert(pdesc.end(), pd, pd + len);
457  }
458 
459  pmt->AppendStream(pids[i], types[i], pdesc.data(), pdesc.size());
460  }
461  pmt->Finalize();
462 
463  LOG(VB_SIPARSER, LOG_INFO, "Created PMT \n" + pmt->toString());
464 
465  return pmt;
466 }
467 
469 {
470  m_ptrs.clear();
471  const unsigned char *cpos = psipdata() + kPmtHeaderMinOffset + ProgramInfoLength();
472  auto *pos = const_cast<unsigned char*>(cpos);
473  for (uint i = 0; pos < psipdata() + Length() - 9; i++)
474  {
475  m_ptrs.push_back(pos);
476  pos += 5 + StreamInfoLength(i);
477 #if 0
478  LOG(VB_SIPARSER, LOG_DEBUG, QString("Parsing PMT(0x%1) i(%2) len(%3)")
479  .arg((uint64_t)this, 0, 16) .arg(i) .arg(StreamInfoLength(i)));
480 #endif
481  }
482  m_ptrs.push_back(pos);
483 #if 0
484  LOG(VB_SIPARSER, LOG_DEBUG, QString("Parsed PMT(0x%1)\n%2")
485  .arg((uint64_t)this, 0, 16) .arg(toString()));
486 #endif
487 }
488 
490  uint pid, uint type,
491  unsigned char* streamInfo, uint infoLength)
492 {
493  if (!StreamCount())
495  memset(m_ptrs[StreamCount()], 0xff, 5);
496  SetStreamPID(StreamCount(), pid);
498  SetStreamProgramInfo(StreamCount(), streamInfo, infoLength);
501 }
502 
513 bool ProgramMapTable::IsVideo(uint i, const QString& sistandard) const
514 {
516  return true;
517 
520  uint stream_id = StreamID::Normalize(StreamType(i), list, sistandard);
521 
522  return StreamID::IsVideo(stream_id);
523 }
524 
535 bool ProgramMapTable::IsAudio(uint i, const QString& sistandard) const
536 {
538  return true;
539 
542  uint stream_id = StreamID::Normalize(StreamType(i), list, sistandard);
543 
544  return StreamID::IsAudio(stream_id);
545 }
546 
551 bool ProgramMapTable::IsEncrypted(const QString& sistandard) const
552 {
553  bool encrypted = IsProgramEncrypted();
554 
555  for (uint i = 0; !encrypted && i < StreamCount(); i++) {
556  /* Only check audio/video streams */
557  if (IsAudio(i,sistandard) || IsVideo(i,sistandard))
558  encrypted |= IsStreamEncrypted(i);
559  }
560 
561  return encrypted;
562 }
563 
568 {
571 
572  uint encrypted = 0;
573  QMap<uint,uint> encryption_system;
574  for (auto & desc : descs)
575  {
576  ConditionalAccessDescriptor cad(desc);
577  if (!cad.IsValid())
578  continue;
579  encryption_system[cad.PID()] = cad.SystemID();
580  encrypted |= cad.SystemID();
581 
582 #if 0
583  LOG(VB_GENERAL, LOG_INFO, "DTVsm: " + cad.toString());
584 #endif
585  }
586 
587  return encrypted != 0;
588 }
589 
596 {
599 
600  uint encrypted = 0;
601  QMap<uint,uint> encryption_system;
602  for (auto & desc : descs)
603  {
604  ConditionalAccessDescriptor cad(desc);
605  if (!cad.IsValid())
606  continue;
607  encryption_system[cad.PID()] = cad.SystemID();
608  encrypted |= cad.SystemID();
609 #if 0
610  LOG(VB_GENERAL, LOG_INFO, "DTVsm: " + cad.toString());
611 #endif
612  }
613 
614  return encrypted != 0;
615 }
616 
617 bool ProgramMapTable::IsStillPicture(const QString& sistandard) const
618 {
619  static constexpr unsigned char kStillPictureFlag = 0x01;
620 
621  for (uint i = 0; i < StreamCount(); i++)
622  {
623  if (IsVideo(i, sistandard))
624  {
625  return StreamInfoLength(i) > 2 &&
626  ((StreamInfo(i)[2] & kStillPictureFlag) != 0);
627  }
628  }
629  return false;
630 }
631 
632 
642  vector<uint> &pids,
643  const QString &sistandard) const
644 {
646  {
647  for (uint i=0; i < StreamCount(); i++)
648  if (type == StreamType(i))
649  pids.push_back(StreamPID(i));
650  }
651  else if (StreamID::AnyVideo == type)
652  {
653  for (uint i=0; i < StreamCount(); i++)
654  if (IsVideo(i, sistandard))
655  pids.push_back(StreamPID(i));
656  }
657  else if (StreamID::AnyAudio == type)
658  {
659  for (uint i=0; i < StreamCount(); i++)
660  if (IsAudio(i, sistandard))
661  pids.push_back(StreamPID(i));
662  }
663 
664  return pids.size();
665 }
666 
678  vector<uint> &pids,
679  vector<uint> &types,
680  const QString &sistandard,
681  bool normalize) const
682 {
683  uint pids_start = pids.size();
684 
686  {
687  for (uint i=0; i < StreamCount(); i++)
688  {
689  if (type == StreamType(i))
690  {
691  pids.push_back(StreamPID(i));
692  types.push_back(StreamType(i));
693  }
694  }
695  }
696  else if (StreamID::AnyVideo == type)
697  {
698  for (uint i=0; i < StreamCount(); i++)
699  {
700  if (IsVideo(i, sistandard))
701  {
702  pids.push_back(StreamPID(i));
703  types.push_back(StreamType(i));
704  }
705  }
706  }
707  else if (StreamID::AnyAudio == type)
708  {
709  for (uint i=0; i < StreamCount(); i++)
710  {
711  if (IsAudio(i, sistandard))
712  {
713  pids.push_back(StreamPID(i));
714  types.push_back(StreamType(i));
715  }
716  }
717  }
718 
719  if (!normalize)
720  return pids.size();
721 
722  for (size_t i = pids_start; i < pids.size(); i++)
723  {
724  int index = FindPID(pids[i]);
725  if (index >= 0)
726  {
729  types[i] = StreamID::Normalize(types[i], desc, sistandard);
730  }
731  }
732 
733  return pids.size();
734 }
735 
737 {
738  uint pid = desired_pid;
739  if (pid >= MPEG_NULL_PID)
740  pid = 0x20;
741 
742  while (FindPID(pid) != -1)
743  pid += 0x10;
744 
745  if (pid < MPEG_NULL_PID)
746  return pid;
747 
748  pid = desired_pid;
749  while (FindPID(pid) != -1)
750  pid += 1;
751 
752  if (pid < MPEG_NULL_PID)
753  return pid;
754 
755  pid = 0x20;
756  while (FindPID(pid) != -1)
757  pid += 1;
758 
759  return pid & 0x1fff;
760 }
761 
762 QString PSIPTable::toString(void) const
763 {
764  QString str;
765  str.append(QString(" PSIP tableID(0x%1) length(%2) extension(0x%3)\n")
766  .arg(TableID(), 0, 16).arg(Length())
767  .arg(TableIDExtension(), 0, 16));
768  str.append(QString(" version(%1) current(%2) "
769  "section(%3) last_section(%4)\n")
770  .arg(Version()).arg(IsCurrent())
771  .arg(Section()).arg(LastSection()));
772  if ((TableID() >= TableID::MGT) && (TableID() <= TableID::SRM))
773  {
774  str.append(QString(" atsc_protocol_version(%1)\n")
775  .arg(ATSCProtocolVersion()));
776  }
777  return str;
778 }
779 
780 QString PSIPTable::toStringXML(uint indent_level) const
781 {
782  QString indent = xml_indent(indent_level);
783  return indent + "<PSIPSection " + XMLValues(indent_level + 1) + " />";
784 }
785 
786 QString PSIPTable::XMLValues(uint indent_level) const
787 {
788  QString indent = xml_indent(indent_level);
789 
790  QString str = QString(
791  "table_id=\"0x%1\" length=\"%2\"")
792  .arg(TableID(), 2, 16, QChar('0'))
793  .arg(Length());
794 
795  if (HasSectionNumber())
796  {
797  str += QString(" section=\"%4\" last_section=\"%5\"")
798  .arg(Section()).arg(LastSection());
799  }
800 
801  if ((TableID() >= TableID::MGT) && (TableID() <= TableID::SRM))
802  {
803  str += QString("\n%1version=\"%2\" current=\"%3\" "
804  "protocol_version=\"%4\" extension=\"0x%5\"")
805  .arg(indent)
806  .arg(Version()).arg(xml_bool_to_string(IsCurrent()))
807  .arg(ATSCProtocolVersion())
808  .arg(TableIDExtension(), 0, 16);
809  }
810 
811  return str;
812 }
813 
815 {
816  QString str;
817  str.append(QString("Program Association Section\n"));
818  str.append(PSIPTable::toString());
819  str.append(QString(" tsid(%1) ").arg(TransportStreamID()));
820  str.append(QString("programCount(%1)\n").arg(ProgramCount()));
821 
822  uint cnt0 = 0;
823  uint cnt1fff = 0;
824  for (uint i = 0; i < ProgramCount(); i++)
825  {
826  if (0x1fff == ProgramPID(i))
827  {
828  cnt1fff++;
829  continue;
830  }
831 
832  if (0x0 == ProgramPID(i))
833  {
834  cnt0++;
835  continue;
836  }
837 
838  str += QString(" program number %1 has PID 0x%2\n")
839  .arg(ProgramNumber(i),5)
840  .arg(ProgramPID(i),4,16,QChar('0'));
841  }
842 
843  if (cnt0 || cnt1fff)
844  {
845  str.append(QString(" also contains %1 dummy programs\n")
846  .arg(cnt0 + cnt1fff));
847  }
848 
849  return str;
850 }
851 
852 QString ProgramAssociationTable::toStringXML(uint indent_level) const
853 {
854  QString indent_0 = xml_indent(indent_level);
855  QString indent_1 = xml_indent(indent_level + 1);
856 
857  QString str = QString(
858  "%1<ProgramAssociationSection tsid=\"0x%2\" program_count=\"%3\""
859  "\n%4%5>\n")
860  .arg(indent_0)
861  .arg(TransportStreamID(),4,16,QChar('0'))
862  .arg(ProgramCount())
863  .arg(indent_1)
864  .arg(PSIPTable::XMLValues(indent_level + 1));
865 
866  for (uint i = 0; i < ProgramCount(); i++)
867  {
868  bool dummy = (0x1fff == ProgramPID(i)) || (0x0 == ProgramPID(i));
869  str += QString("%1<Program number=\"%2\" pid=\"0x%3\" %4/>\n")
870  .arg(indent_1)
871  .arg(ProgramNumber(i))
872  .arg(ProgramPID(i),4,16,QChar('0'))
873  .arg(dummy ? "comment=\"Dummy Program\" " : "");
874  }
875 
876  return str + indent_0 + "</ProgramAssociationSection>";
877 }
878 
879 QString ProgramMapTable::toString(void) const
880 {
881  QString str =
882  QString("Program Map Section"
883  "\n%1"
884  " pnum(%2) pid(0x%3) pcrpid(0x%4)\n")
885  .arg(PSIPTable::toString())
886  .arg(ProgramNumber())
887  .arg(tsheader()->PID(),0,16)
888  .arg(PCRPID(),0,16);
889 
890  vector<const unsigned char*> desc =
892  for (auto & d : desc)
893  {
894  str.append(QString(" %1\n")
895  .arg(MPEGDescriptor(d, 300).toString()));
896  }
897 
898  for (uint i = 0; i < StreamCount(); i++)
899  {
900  str.append(QString(" Stream #%1 pid(0x%2) type(0x%3 %4)\n")
901  .arg(i).arg(StreamPID(i), 0, 16)
902  .arg(StreamType(i), 2, 16, QChar('0'))
903  .arg(StreamTypeString(i)));
905  for (auto & d : desc)
906  {
907  str.append(QString(" %1\n")
908  .arg(MPEGDescriptor(d, 300).toString()));
909  }
910  }
911  return str;
912 }
913 
914 QString ProgramMapTable::toStringXML(uint indent_level) const
915 {
916  QString indent_0 = xml_indent(indent_level);
917  QString indent_1 = xml_indent(indent_level + 1);
918 
919  QString str = QString(
920  "%1<ProgramMapSection pcr_pid=\"0x%2\" program_number=\"%3\"\n"
921  "%4program_info_length=\"%5\" stream_count=\"%7\"%8>\n")
922  .arg(indent_0)
923  .arg(PCRPID(),0,16)
924  .arg(ProgramNumber())
925  .arg(indent_1)
926  .arg(ProgramInfoLength())
927  .arg(StreamCount())
928  .arg(PSIPTable::XMLValues(indent_level + 1));
929 
930  vector<const unsigned char*> gdesc =
932  for (auto & gd : gdesc)
933  {
934  str += MPEGDescriptor(gd, 300)
935  .toStringXML(indent_level + 1) + "\n";
936  }
937 
938  for (uint i = 0; i < StreamCount(); i++)
939  {
940  str += QString("%1<Stream pid=\"0x%2\" type=\"0x%3\" "
941  "type_desc=\"%4\" stream_info_length=\"%5\"")
942  .arg(indent_1)
943  .arg(StreamPID(i),2,16,QChar('0'))
944  .arg(StreamType(i),2,16,QChar('0'))
945  .arg(StreamTypeString(i))
946  .arg(StreamInfoLength(i));
947  vector<const unsigned char*> ldesc =
949  str += (ldesc.empty()) ? " />\n" : ">\n";
950  for (auto & ld : ldesc)
951  {
952  str += MPEGDescriptor(ld, 300)
953  .toStringXML(indent_level + 2) + "\n";
954  }
955  if (!ldesc.empty())
956  str += indent_1 + "</Stream>\n";
957  }
958 
959  return str + indent_0 + "</ProgramMapSection>";
960 }
961 
962 const char *StreamID::toString(uint streamID)
963 {
964  // valid for some ATSC/DVB stuff too
965  switch (streamID)
966  {
968  return "video-mpeg2";
970  return "video-mpeg1";
972  return "video-mpeg4";
973  case StreamID::H264Video:
974  return "video-h264";
975  case StreamID::H265Video:
976  return "video-h265";
978  return "video-opencable";
979 
980  // audio
981  case StreamID::AC3Audio:
982  return "audio-ac3"; // EIT, PMT
983  case StreamID::EAC3Audio:
984  return "audio-eac3"; // EIT, PMT
986  return "audio-mp2-layer[1,2,3]"; // EIT, PMT
988  return "audio-mp1-layer[1,2,3]"; // EIT, PMT
990  return "audio-aac-latm"; // EIT, PMT
992  return "audio-aac"; // EIT, PMT
993  case StreamID::DTSAudio:
994  return "audio-dts"; // EIT, PMT
995 
996  // other
997  case StreamID::PrivSec:
998  return "private-sec";
999  case StreamID::PrivData:
1000  return "private-data";
1001 
1002  // DSMCC Object Carousel
1003  case StreamID::DSMCC_A:
1004  return "dsmcc-a encap";
1005  case StreamID::DSMCC_B:
1006  return "dsmcc-b std data";
1007  case StreamID::DSMCC_C:
1008  return "dsmcc-c NPD data";
1009  case StreamID::DSMCC_D:
1010  return "dsmcc-d data";
1011 
1012  // Can be in any MPEG stream ATSC, DVB, or ARIB ; but defined in SCTE 35
1013  case StreamID::Splice:
1014  return "splice"; // PMT
1015 
1016  //case TableID::STUFFING: XXX: Duplicate?
1017  // return "stuffing"; // optionally in any
1018  //case TableID::CENSOR: FIXME collides with StreamID::EAC3Audio
1019  // return "censor"; // EIT, optionally in PMT
1020  case TableID::ECN:
1021  return "extended channel name";
1022  case TableID::SRVLOC:
1023  return "service location"; // required in VCT
1024  case TableID::TSS: // other channels with same stuff
1025  return "time-shifted service";
1026  case TableID::CMPNAME:
1027  return "component name"; //??? PMT
1028  }
1029  return "unknown";
1030 }
1031 
1032 QString StreamID::GetDescription(uint stream_id)
1033 {
1034  // valid for some ATSC/DVB stuff too
1035  switch (stream_id)
1036  {
1037  // video
1038  case StreamID::MPEG1Video:
1039  return "11172-2 MPEG-1 Video";
1040  case StreamID::MPEG2Video:
1041  return "13818-2 MPEG-2 Video";
1042  case StreamID::MPEG4Video:
1043  return "14492-2 MPEG-4 Video";
1044  case StreamID::H264Video:
1045  return "H.264 Video";
1046  case StreamID::H265Video:
1047  return "H.265 Video";
1049  return "OpenCable Video";
1050  case StreamID::VC1Video:
1051  return "VC-1 Video";
1052 
1053  // audio
1054  case StreamID::MPEG1Audio:
1055  return "11172-2 MPEG-1 Audio";
1056  case StreamID::MPEG2Audio:
1057  return "13818-3 MPEG-2 Audio";
1059  return "13818-7 AAC MPEG-2 Audio";
1061  return "13818-3 AAC LATM MPEG-2 Audio";
1062  case StreamID::AC3Audio:
1063  return "AC3 Audio";
1064  case StreamID::EAC3Audio:
1065  return "E-AC3 Audio";
1066  case StreamID::DTSAudio:
1067  return "DTS Audio";
1068 
1069  // DSMCC Object Carousel
1070  case StreamID::DSMCC:
1071  return "13818-1 DSM-CC";
1072  case StreamID::DSMCC_A:
1073  return "13818-6 DSM-CC Type A";
1074  case StreamID::DSMCC_B:
1075  return "13818-6 DSM-CC Type B";
1076  case StreamID::DSMCC_C:
1077  return "13818-6 DSM-CC Type C";
1078  case StreamID::DSMCC_D:
1079  return "13818-6 DSM-CC Type D";
1080  case StreamID::DSMCC_DL:
1081  return "13818-6 Download";
1082  case StreamID::MetaDataPES:
1083  return "13818-6 Metadata in PES";
1084  case StreamID::MetaDataSec:
1085  return "13818-6 Metadata in Sections";
1086  case StreamID::MetaDataDC:
1087  return "13818-6 Metadata in Data Carousel";
1088  case StreamID::MetaDataOC:
1089  return "13818-6 Metadata in Obj Carousel";
1090  case StreamID::MetaDataDL:
1091  return "13818-6 Metadata in Download";
1092 
1093  // other
1094  case StreamID::PrivSec:
1095  return "13818-1 Private Sections";
1096  case StreamID::PrivData:
1097  return "13818-3 Private Data";
1098  case StreamID::MHEG:
1099  return "13522 MHEG";
1100  case StreamID::H222_1:
1101  return "ITU H.222.1";
1102  case StreamID::MPEG2Aux:
1103  return "13818-1 Aux & ITU H.222.0";
1104  case StreamID::FlexMuxPES:
1105  return "14496-1 SL/FlexMux in PES";
1106  case StreamID::FlexMuxSec:
1107  return "14496-1 SL/FlexMux in Sections";
1108  case StreamID::MPEG2IPMP:
1109  return "13818-10 IPMP";
1110  case StreamID::MPEG2IPMP2:
1111  return "13818-10 IPMP2";
1112 
1113  case AnyMask: return QString();
1114  case AnyVideo: return "video";
1115  case AnyAudio: return "audio";
1116  }
1117 
1118  return QString();
1119 }
1120 
1122 {
1123  const desc_list_t list = MPEGDescriptor::Parse(
1124  StreamInfo(i), StreamInfoLength(i));
1125  const unsigned char *lang_desc = MPEGDescriptor::Find(
1127 
1128  if (!lang_desc)
1129  return QString();
1130 
1131  ISO639LanguageDescriptor iso_lang(lang_desc);
1132  if (!iso_lang.IsValid())
1133  return "";
1134  return iso_lang.CanonicalLanguageString();
1135 }
1136 
1138 {
1139  const desc_list_t list = MPEGDescriptor::Parse(
1140  StreamInfo(i), StreamInfoLength(i));
1141  const unsigned char *lang_desc = MPEGDescriptor::Find(
1143 
1144  if (!lang_desc)
1145  return 0;
1146 
1147  ISO639LanguageDescriptor iso_lang(lang_desc);
1148  if (!iso_lang.IsValid())
1149  return 0;
1150 
1151  // Hack for non-standard AD labelling on UK Satellite and Irish DTTV
1152  // Language string of 'nar' for narrative indicates an AD track
1153  if (iso_lang.AudioType() == 0x0 &&
1154  iso_lang.LanguageString() == "nar")
1155  return 0x03;
1156 
1157  return iso_lang.AudioType();
1158 }
1159 
1160 QString ProgramMapTable::StreamDescription(uint i, const QString& sistandard) const
1161 {
1162  desc_list_t list;
1163 
1165  uint type = StreamID::Normalize(StreamType(i), list, sistandard);
1166  QString desc = StreamID::toString(type);
1167  QString lang = GetLanguage(i);
1168 
1169  if (!lang.isEmpty())
1170  desc += QString(" (%1)").arg(lang);
1171 
1172  return desc;
1173 }
1174 
1176 {
1177  QString str =
1178  QString("Condiditional Access Section %1")
1179  .arg(PSIPTable::toString());
1180 
1181  vector<const unsigned char*> gdesc =
1183  for (auto & gd : gdesc)
1184  str += " " + MPEGDescriptor(gd, 300).toString() + "\n";
1185 
1186  str += "\n";
1187 
1188  return str;
1189 }
1190 
1191 QString ConditionalAccessTable::toStringXML(uint indent_level) const
1192 {
1193  QString indent_0 = xml_indent(indent_level);
1194 
1195  QString str =
1196  QString("%1<ConditionalAccessSection %3")
1197  .arg(indent_0)
1198  .arg(PSIPTable::XMLValues(indent_level + 1));
1199 
1200  vector<const unsigned char*> gdesc =
1202  str += (gdesc.empty()) ? " />\n" : ">\n";
1203  for (auto & gd : gdesc)
1204  {
1205  str += MPEGDescriptor(gd, 300)
1206  .toStringXML(indent_level + 1) + "\n";
1207  }
1208  if (!gdesc.empty())
1209  str += indent_0 + "</ConditionalAccessSection>\n";
1210 
1211  return str;
1212 }
1213 
1214 QString SpliceTimeView::toString(int64_t first, int64_t last) const
1215 {
1216  if (!IsTimeSpecified())
1217  return QString("splice_time(N/A)");
1218 
1219  int64_t abs_pts_time = PTSTime();
1220  if ((first > 0) && (last > 0))
1221  {
1222  int64_t elapsed = abs_pts_time - first;
1223  elapsed = (elapsed < 0) ? elapsed + 0x1000000000LL : elapsed;
1224  QTime abs = QTime(0,0,0,0).addMSecs(elapsed/90);
1225 
1226  elapsed = abs_pts_time - last; /* rel_pts_time */
1227  elapsed = (elapsed < 0) ? elapsed + 0x1000000000LL : elapsed;
1228  QTime rel = QTime(0,0,0,0).addMSecs(elapsed/90);
1229 
1230  return QString("splice_time(pts: %1 abs: %2, rel: +%3)")
1231  .arg(abs_pts_time)
1232  .arg(abs.toString("hh:mm:ss.zzz"))
1233  .arg(rel.toString("hh:mm:ss.zzz"));
1234  }
1235 
1236  return QString("splice_time(pts: %1)").arg(abs_pts_time);
1237 }
1238 
1240  uint indent_level, int64_t first, int64_t last) const
1241 {
1242  QString indent = xml_indent(indent_level);
1243 
1244  if (!IsTimeSpecified())
1245  return indent + "<SpliceTime />";
1246 
1247  int64_t abs_pts_time = PTSTime();
1248 
1249  QString abs_str;
1250  if (first > 0)
1251  {
1252  int64_t elapsed = abs_pts_time - first;
1253  elapsed = (elapsed < 0) ? elapsed + 0x1000000000LL : elapsed;
1254  QTime abs = QTime(0,0,0,0).addMSecs(elapsed/90);
1255  abs_str = QString("absolute=\"%1\" ")
1256  .arg(abs.toString("hh:mm:ss.zzz"));
1257  }
1258 
1259  QString rel_str;
1260  if (last > 0)
1261  {
1262  int64_t elapsed = abs_pts_time - last; /* rel_pts_time */
1263  elapsed = (elapsed < 0) ? elapsed + 0x1000000000LL : elapsed;
1264  QTime rel = QTime(0,0,0,0).addMSecs(elapsed/90);
1265  rel_str = QString("relative=\"+%1\" ")
1266  .arg(rel.toString("hh:mm:ss.zzz"));
1267  }
1268 
1269  return QString("%1<SpliceTime pts=\"%2\" %3%4/>")
1270  .arg(indent).arg(abs_pts_time).arg(abs_str).arg(rel_str);
1271 }
1272 
1275  const QString &/*codeWord*/)
1276 {
1277  // TODO
1278  return nullptr;
1279 }
1280 
1282 {
1283  m_epilog = nullptr;
1284  m_ptrs0.clear();
1285  m_ptrs1.clear();
1286 
1287  if (TableID::SITscte != TableID())
1288  return false;
1289 
1290  if (SpliceProtocolVersion() != 0)
1291  return false;
1292 
1293  if (IsEncryptedPacket())
1294  return true; // it's "parsed" but you can't read encrypted portion
1295 
1298  {
1299  m_epilog = pesdata() + 14;
1300  }
1301  else if (kSCTTimeSignal == type)
1302  {
1303  m_epilog = pesdata() + 14 + TimeSignal().size();
1304  }
1305  else if (kSCTSpliceSchedule == type)
1306  {
1307  uint splice_count = pesdata()[14];
1308  const unsigned char *cur = pesdata() + 15;
1309  for (uint i = 0; i < splice_count; i++)
1310  {
1311  m_ptrs0.push_back(cur);
1312  bool event_cancel = (cur[4] & 0x80) != 0;
1313  if (event_cancel)
1314  {
1315  m_ptrs1.push_back(nullptr);
1316  cur += 5;
1317  continue;
1318  }
1319  bool program_slice = (cur[5] & 0x40) != 0;
1320  uint component_count = cur[6];
1321  m_ptrs1.push_back(cur + (program_slice ? 10 : 7 * component_count));
1322  }
1323  if (splice_count)
1324  {
1325  bool duration = (m_ptrs0.back()[5] & 0x2) != 0;
1326  m_epilog = m_ptrs1.back() + ((duration) ? 9 : 4);
1327  }
1328  else
1329  {
1330  m_epilog = cur;
1331  }
1332  }
1333  else if (kSCTSpliceInsert == type)
1334  {
1335  m_ptrs1.push_back(pesdata() + 14);
1336  bool splice_cancel = (pesdata()[18] & 0x80) != 0;
1337  if (splice_cancel)
1338  {
1339  m_epilog = pesdata() + 19;
1340  }
1341  else
1342  {
1343  bool program_splice = (pesdata()[19] & 0x40) != 0;
1344  bool duration = (pesdata()[19] & 0x20) != 0;
1345  bool splice_immediate = (pesdata()[19] & 0x10) != 0;
1346  const unsigned char *cur = pesdata() + 20;
1347  if (program_splice && !splice_immediate)
1348  {
1349  cur += SpliceTimeView(cur).size();
1350  }
1351  else if (!program_splice)
1352  {
1353  uint component_count = pesdata()[20];
1354  cur = pesdata() + 21;
1355  for (uint i = 0; i < component_count; i++)
1356  {
1357  m_ptrs0.push_back(cur);
1358  cur += (splice_immediate) ?
1359  1 : 1 + SpliceTimeView(cur).size();
1360  }
1361  }
1362  m_ptrs1.push_back(cur);
1363  m_ptrs1.push_back(cur + (duration ? 5 : 0));
1364  }
1365  }
1366  else
1367  {
1368  m_epilog = nullptr;
1369  }
1370 
1371  return m_epilog != nullptr;
1372 }
1373 
1375 {
1376  uint alg = EncryptionAlgorithm();
1377  switch (alg)
1378  {
1379  case kNoEncryption: return "None";
1380  case kECB: return "DES-ECB";
1381  case kCBC: return "DES-CBC";
1382  case k3DES: return "3DES";
1383  default:
1384  return QString((alg<32) ? "Reserved(%1)" : "Private(%1)").arg(alg);
1385  }
1386 }
1387 
1389 {
1391  switch (type)
1392  {
1393  case kSCTNull:
1394  return "Null";
1395  case kSCTSpliceSchedule:
1396  return "SpliceSchedule";
1397  case kSCTSpliceInsert:
1398  return "SpliceInsert";
1399  case kSCTTimeSignal:
1400  return "TimeSignal";
1402  return "BandwidthReservation";
1403  case kSCTPrivateCommand:
1404  return "Private";
1405  default:
1406  return QString("Reserved(%1)").arg(type);
1407  };
1408 }
1409 
1410 QString SpliceInformationTable::toString(int64_t first, int64_t last) const
1411 {
1412  QString str =
1413  QString("SpliceInformationSection enc_alg(%1) pts_adj(%2)")
1415  .arg(PTSAdjustment());
1416  str += IsEncryptedPacket() ? QString(" cw_index(%1)") : QString("");
1417  str += QString(" command_len(%1) command_type(%2) scte_pid(0x%3)")
1418  .arg(SpliceCommandLength())
1420  .arg(getSCTEPID(), 0, 16));
1421 
1422  if (IsEncryptedPacket())
1423  return str;
1424 
1425  switch (SpliceCommandType())
1426  {
1427  case kSCTSpliceSchedule:
1428  break;
1429  case kSCTSpliceInsert:
1430  {
1431  str += "\n " + SpliceInsert().toString(first, last);
1432  break;
1433  }
1434  case kSCTTimeSignal:
1435  break;
1436  }
1437 
1438  return str;
1439 }
1440 
1441 QString SpliceInsertView::toString(int64_t first, int64_t last) const
1442 {
1443  QString str =
1444  QString("eventid(0x%1) cancel(%2) "
1445  "out_of_network(%3) program_splice(%4) "
1446  "duration(%5) immediate(%6)\n ")
1447  .arg(SpliceEventID(),0,16)
1448  .arg(IsSpliceEventCancel()?"yes":"no")
1449  .arg(IsOutOfNetwork()?"yes":"no")
1450  .arg(IsProgramSplice()?"yes":"no")
1451  .arg(IsDuration()?"yes":"no")
1452  .arg(IsSpliceImmediate()?"yes":"no");
1453 
1454  if (IsProgramSplice() && !IsSpliceImmediate())
1455  str += SpliceTime().toString(first, last);
1456 
1457  str += QString(" unique_program_id(%1)")
1458  .arg(UniqueProgramID());
1459 
1460  str += QString(" avail(%1/%2)")
1461  .arg(AvailNum()).arg(AvailsExpected());
1462 
1463  return str;
1464 }
1465 
1467  uint indent_level, int64_t first, int64_t last) const
1468 {
1469  QString indent = xml_indent(indent_level);
1470 
1471  QString cap_time = "";
1472  if (first >= 0)
1473  {
1474  cap_time = QString("pts=\"%1\" ").arg(first);
1475  if (last >= 0)
1476  {
1477  QTime abs = QTime(0,0,0,0).addMSecs((last - first)/90);
1478  cap_time += QString("capture_time=\"%1\" ")
1479  .arg(abs.toString("hh:mm:ss.zzz"));
1480  }
1481  }
1482 
1483  QString str = QString(
1484  "%1<SpliceInformationSection %2 encryption_algorithm=\"%3\" "
1485  "pts_adjustment=\"%4\" code_word_index=\"%5\" command_type=\"%6\" scte_pid=\"0x%7\" >\n")
1486  .arg(indent)
1487  .arg(cap_time)
1489  .arg(PTSAdjustment())
1490  .arg(CodeWordIndex())
1491  .arg(SpliceCommandTypeString())
1492  .arg(getSCTEPID(), 0 ,16);
1493 
1494  if (IsEncryptedPacket())
1495  return str + indent + "</SpliceInformationSection>";
1496 
1497  switch (SpliceCommandType())
1498  {
1499  case kSCTSpliceSchedule:
1500  break;
1501  case kSCTSpliceInsert:
1502  {
1503  str += SpliceInsert().toStringXML(indent_level + 1, first, last);
1504  str += "\n";
1505  break;
1506  }
1507  case kSCTTimeSignal:
1508  break;
1509  }
1510 
1511  str += indent + "</SpliceInformationSection>";
1512  return str;
1513 }
1514 
1516  uint indent_level, int64_t first, int64_t last) const
1517 {
1518  QString indent_0 = xml_indent(indent_level);
1519  QString indent_1 = xml_indent(indent_level + 1);
1520  QString str = QString(
1521  "%1<SpliceInsert eventid=\"0x%2\" cancel=\"%3\"\n")
1522  .arg(indent_0)
1523  .arg(SpliceEventID(),0,16)
1525 
1526  str += QString(
1527  "%1out_of_network=\"%2\" program_splice=\"%3\" duration=\"%4\"\n")
1528  .arg(indent_1)
1531  .arg(xml_bool_to_string(IsDuration()));
1532 
1533  str += QString(
1534  "%1immediate=\"%2\" unique_program_id=\"%3\"\n"
1535  "%4avail_num=\"%5\" avails_expected=\"%6\">\n")
1536  .arg(indent_1)
1538  .arg(UniqueProgramID())
1539  .arg(indent_1)
1540  .arg(AvailNum())
1541  .arg(AvailsExpected());
1542 
1543  if (IsProgramSplice() && !IsSpliceImmediate())
1544  {
1545  str += SpliceTime().toStringXML(indent_level + 1, first, last) + "\n";
1546  }
1547 
1548  str += indent_0 + "</SpliceInsert>";
1549  return str;
1550 }
const unsigned char DEFAULT_PMT_HEADER[12]
Definition: mpegtables.cpp:23
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
static uint Normalize(uint stream_id, const desc_list_t &desc, const QString &sistandard)
Definition: mpegtables.cpp:46
const unsigned char * psipdata(void) const
Definition: mpegtables.h:532
const TSHeader * tsheader() const
Definition: pespacket.h:84
uint Version(void) const
Definition: mpegtables.h:513
const unsigned char DEFAULT_PAT_HEADER[8]
Definition: mpegtables.cpp:10
ISO 13818-3/AMD-1 Audio using LATM syntax.
Definition: mpegtables.h:127
uint Length() const
Definition: pespacket.h:93
unsigned char * m_fullBuffer
Pointer to allocated data.
Definition: pespacket.h:213
QString SpliceCommandTypeString(void) const
void SetLength(uint len)
Definition: pespacket.h:165
static TSPacket * CreatePayloadOnlyPacket(void)
Definition: tspacket.h:174
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
ISO 13818-1 auxiliary & ITU H.222.0.
Definition: mpegtables.h:152
uint FindUnusedPID(uint desired_pid=0x20)
Definition: mpegtables.cpp:736
ProgramAssociationTable(const ProgramAssociationTable &table)
Definition: mpegtables.h:592
QString toString() const override
void Parse(void) const
Definition: mpegtables.cpp:468
Meta data in PES packets.
Definition: mpegtables.h:139
uint TableIDExtension(void) const
Definition: mpegtables.h:506
QString CanonicalLanguageString(void) const
QString EncryptionAlgorithmString(void) const
bool IsEncrypted(const QString &sistandard) const
Returns true iff PMT contains CA descriptor for a vid/aud stream.
Definition: mpegtables.cpp:551
uint SectionLength(void) const
Definition: mpegtables.h:500
QString toString(void) const override
Definition: mpegtables.cpp:879
uint AvailsExpected(void) const
Definition: mpegtables.h:988
bool IsOutOfNetwork(void) const
Definition: mpegtables.h:958
uint EncryptionAlgorithm(void) const
Definition: mpegtables.h:1047
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
uint LastSection(void) const
Definition: mpegtables.h:525
ISO 13818-7 Audio w/ADTS syntax.
Definition: mpegtables.h:126
bool IsEncryptedPacket(void) const
Definition: mpegtables.h:1032
bool IsStillPicture(const QString &sistandard) const
Returns true iff PMT contains a still-picture video stream.
Definition: mpegtables.cpp:617
ISO 13818-1 private tables & ITU H.222.0.
Definition: mpegtables.h:146
virtual QString toString(void) const
ISO 13818-6 type C NPT DSMCC Data.
Definition: mpegtables.h:136
const unsigned char * Descriptors(void) const
Definition: mpegtables.h:853
vector< const unsigned char * > m_ptrs1
Definition: mpegtables.h:1175
int getSCTEPID(void) const
Definition: mpegtables.h:1018
virtual QString toString(int64_t first, int64_t last) const
bool IsCurrent(void) const
Definition: mpegtables.h:519
ANSI/SCTE 35 2007.
Definition: mpegtables.h:160
uint m_allocSize
Total number of bytes we allocated.
Definition: pespacket.h:218
uint CalcCRC(void) const
Definition: pespacket.cpp:145
uint SpliceCommandType(void) const
Definition: mpegtables.h:1100
uint PCRPID(void) const
stream that contains program clock reference.
Definition: mpegtables.h:700
Used to access header of a TSPacket.
Definition: tspacket.h:24
static const uint kPsipOffset
Definition: mpegtables.h:565
static QString GetDescription(uint stream_id)
ISO 14496-1 SL/FlexMux in PES packets.
Definition: mpegtables.h:154
uint Section(void) const
Definition: mpegtables.h:522
bool IsSpliceEventCancel(void) const
Definition: mpegtables.h:954
QString GetLanguage(uint i) const
Returns the canonical language if we find the iso639 descriptor.
static const unsigned int kPayloadSize
Definition: tspacket.h:221
vector< const unsigned char * > desc_list_t
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
Meta data in metadata_section's.
Definition: mpegtables.h:140
uint StreamInfoLength(uint i) const
Definition: mpegtables.h:718
uint StreamType(uint i) const
Definition: mpegtables.h:712
const unsigned char * m_epilog
Definition: mpegtables.h:1176
static ProgramAssociationTable * Create(uint tsid, uint version, const vector< uint > &pnum, const vector< uint > &pid)
Definition: mpegtables.cpp:346
void SetTotalLength(uint len)
Definition: pespacket.h:170
static ProgramMapTable * Create(uint programNumber, uint basepid, uint pcrpid, uint version, vector< uint > pids, vector< uint > types)
Definition: mpegtables.cpp:406
A PSIP table is a variant of a PES packet containing an MPEG, ATSC or DVB table.
Definition: mpegtables.h:386
ISO 13818-1 PES private data & ITU H.222.0.
Definition: mpegtables.h:147
uint StreamPID(uint i) const
Definition: mpegtables.h:715
bool IsProgramSplice(void) const
Definition: mpegtables.h:960
uint StreamID() const
Definition: pespacket.h:92
QString toStringXML(uint indent_level) const override
Definition: mpegtables.cpp:914
ISO 13818-6 Metadata in Download Protocol.
Definition: mpegtables.h:143
virtual QString toStringXML(uint indent_level, int64_t first, int64_t last) const
uint StreamCount(void) const
Definition: mpegtables.h:724
const unsigned char * StreamInfo(uint i) const
Definition: mpegtables.h:721
SpliceTimeView SpliceTime(void) const
Definition: mpegtables.h:968
SMPTE 421M video codec (aka VC1) in Blu-Ray.
Definition: mpegtables.h:121
ISO 11172-3.
Definition: mpegtables.h:124
static const uint16_t * d
QString toStringXML(uint indent_level) const override
Definition: mpegtables.cpp:852
static ProgramAssociationTable * CreateBlank(bool smallPacket=true)
Definition: mpegtables.cpp:330
ISO 23008-2 & ITU H.265 (aka HEVC, Ultra HD)
Definition: mpegtables.h:119
uint SpliceCommandLength(void) const
Definition: mpegtables.h:1077
static const uint len_for_alloc[]
Definition: mpegtables.cpp:38
unsigned char * m_pesData
Pointer to PES data in full buffer.
Definition: pespacket.h:212
uint GetAudioType(uint i) const
Returns the audio type from the iso 639 descriptor.
vector< const unsigned char * > m_ptrs0
Definition: mpegtables.h:1174
uint FindPIDs(uint type, vector< uint > &pids, const QString &sistandard) const
Finds all pids matching type.
Definition: mpegtables.cpp:641
uint DescriptorsLength(void) const
Definition: mpegtables.h:851
ISO 14496-1 SL/FlexMux in 14496_sections.
Definition: mpegtables.h:155
static QString indent(uint level)
ISO 13818-10 Digital Restrictions Mangment.
Definition: mpegtables.h:158
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
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
static const uint kPmtHeaderMinOffset
Definition: mpegtables.h:820
static const unsigned char * Find(const desc_list_t &parsed, uint desc_tag)
uint TransportStreamID(void) const
Definition: mpegtables.h:608
ISO 13818-6 type D Any DSMCC Data.
Definition: mpegtables.h:137
QString toString(void) const override
void SetStreamPID(uint i, uint pid)
Definition: mpegtables.h:736
uint CRC(void) const
Definition: pespacket.h:183
const unsigned char * data(void) const
Definition: tspacket.h:152
ISO 14492-2 (aka MPEG-4)
Definition: mpegtables.h:117
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
QString FormatIdentifierString(void) const
ISO 13818-6 Metadata in Object Carousel.
Definition: mpegtables.h:142
uint TableID(void) const
Definition: mpegtables.h:489
ISO 14492-10 & ITU H.264 (aka MPEG-4-AVC)
Definition: mpegtables.h:118
ISO 13818-6 Download Protocol.
Definition: mpegtables.h:138
#define LOG(_MASK_, _LEVEL_, _STRING_)
Definition: mythlogging.h:41
virtual QString toString(int64_t first, int64_t last) const
QString StreamDescription(uint i, const QString &sistandard) const
Returns a better (and more expensive) string representation of type at stream index i than StreamType...
int FindPID(uint pid) const
Locates stream index of pid.
Definition: mpegtables.h:771
static int x0
Definition: mythsocket.cpp:59
bool VerifyPSIP(bool verify_crc) const
Definition: mpegtables.cpp:236
vector< unsigned char * > m_ptrs
Definition: mpegtables.h:821
QString toString(void) const override
Definition: mpegtables.cpp:814
static ProgramMapTable * CreateBlank(bool smallPacket=true)
Definition: mpegtables.cpp:381
QString XMLValues(uint indent_level) const
Definition: mpegtables.cpp:786
uint ProgramNumber(void) const
Definition: mpegtables.h:703
ISO 13818-1 Annex A DSM-CC & ITU H.222.0.
Definition: mpegtables.h:133
void AppendStream(uint pid, uint type, unsigned char *streamInfo=nullptr, uint infoLength=0)
Definition: mpegtables.cpp:489
ISO 13818-6 Metadata in Data Carousel.
Definition: mpegtables.h:141
uint ProgramInfoLength(void) const
Definition: mpegtables.h:706
static const char * toString(uint streamID)
Definition: mpegtables.cpp:962
static PSIPTable View(const TSPacket &tspacket)
Definition: mpegtables.h:477
bool IsSpliceImmediate(void) const
Definition: mpegtables.h:964
static SpliceInformationTable * GetDecrypted(const QString &codeWord)
Returns decrypted version of this packet.
virtual QString toString(void) const
Definition: mpegtables.cpp:762
ISO 13522 MHEG.
Definition: mpegtables.h:149
uint64_t PTSTime(void) const
Definition: mpegtables.h:870
ISO 13818-10 Digital Restrictions Mangment.
Definition: mpegtables.h:157
QString toStringXML(uint indent_level) const override
Definition: mpegtables.h:1167
uint64_t PTSAdjustment(void) const
Definition: mpegtables.h:1055
static QString xml_bool_to_string(bool val)
Definition: mythmiscutil.h:60
bool HasSectionNumber(void) const
Definition: mpegtables.cpp:210
bool IsValid(void) const
bool IsVideo(uint i, const QString &sistandard) const
Returns true iff the stream at index i is a video stream.
Definition: mpegtables.cpp:513
The all-ones PID value 0x1FFF indicates a Null TS Packet introduced to maintain a constant bit rate o...
Definition: mpegtables.h:236
QString LanguageString(void) const
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
virtual QString toStringXML(uint indent_level) const
Returns XML representation of string the TS Reader XML format.
ISO 13818-6 type A Multi-protocol Encap.
Definition: mpegtables.h:134
A/53 Part 3:2009 6.7.3.
Definition: mpegtables.h:129
bool HasCRC(void) const override
1 bit Cyclic Redundancy Check present
Definition: mpegtables.cpp:94
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
static desc_list_t Parse(const unsigned char *data, uint len)
bool IsStreamEncrypted(uint pid) const
Returns true iff PMT contains CA descriptor.
Definition: mpegtables.cpp:595
const unsigned char * ProgramInfo(void) const
Definition: mpegtables.h:709
static desc_list_t ParseOnlyInclude(const unsigned char *data, uint len, int excluded_descid)
QString toStringXML(uint indent_level) const override
ISO 11172-2 (aka MPEG-1)
Definition: mpegtables.h:115
ISO 13818-6 type B Std DSMCC Data.
Definition: mpegtables.h:135
QString xml_indent(uint level)
bool IsAudio(uint i, const QString &sistandard) const
Returns true iff the stream at index i is an audio stream.
Definition: mpegtables.cpp:535
virtual QString toStringXML(uint indent_level, int64_t first, int64_t last) const
bool IsProgramEncrypted(void) const
Returns true iff PMT's ProgramInfo contains CA descriptor.
Definition: mpegtables.cpp:567
ITU H.222.1.
Definition: mpegtables.h:150
SpliceTimeView TimeSignal(void) const
Definition: mpegtables.h:1125
uint ProgramPID(uint i) const
Definition: mpegtables.h:620
Always MPEG-2??
Definition: mpegtables.h:120