MythTV  master
dvbdescriptors.h
Go to the documentation of this file.
1 // -*- Mode: c++ -*-
2 // Copyright (c) 2003-2004, Daniel Thor Kristjansson
3 #ifndef _DVB_DESCRIPTORS_H_
4 #define _DVB_DESCRIPTORS_H_
5 
6 #include <cassert>
7 
8 #include <QMutex>
9 #include <QString>
10 
11 #include "mythtvexp.h" // MTV_PUBLIC - Symbol Visibility
12 #include "mpegdescriptors.h"
13 #include "programinfo.h" // for subtitle types and audio and video properties
14 
15 /*
16 // needed for scanning
17  conditional_access = 0x09, // maybe
18  satellite_delivery_system = 0x43,*
19  cable_delivery_system = 0x44,*
20  service = 0x48,*
21  terrestrial_delivery_system = 0x5A,*
22  frequency_list = 0x62,*
23 
24 // needed for captions
25  teletext = 0x56,
26  subtitling = 0x59,
27 
28 // needed for sound
29  registration = 0x05,
30  AC3 = 0x6A,
31 
32 // needed for eit
33  short_event = 0x4D,
34  extended_event = 0x4E,
35  content = 0x54,
36 */
37 
38 static QString coderate_inner(uint coderate);
39 
40 extern QString dvb_decode_text(const unsigned char *src, uint length,
41  const unsigned char *encoding_override,
42  uint encoding_override_length);
43 
44 inline QString dvb_decode_text(const unsigned char *src, uint length)
45 {
46  return dvb_decode_text(src, length, nullptr, 0);
47 }
48 
49 QString dvb_decode_short_name(const unsigned char *src, uint raw_length);
50 
51 #define byteBCDH2int(i) ((i) >> 4)
52 #define byteBCDL2int(i) ((i) & 0x0f)
53 #define byteBCD2int(i) (byteBCDH2int(i) * 10 + byteBCDL2int(i))
54 #define byte2BCD2int(i, j) \
55  (byteBCDH2int(i) * 1000 + byteBCDL2int(i) * 100 + \
56  byteBCDH2int(j) * 10 + byteBCDL2int(j))
57 #define byte3BCD2int(i, j, k) \
58  (byteBCDH2int(i) * 100000 + byteBCDL2int(i) * 10000 + \
59  byteBCDH2int(j) * 1000 + byteBCDL2int(j) * 100 + \
60  byteBCDH2int(k) * 10 + byteBCDL2int(k))
61 #define byte4BCD2int(i, j, k, l) \
62  (byteBCDH2int(i) * 10000000LL + byteBCDL2int(i) * 1000000 + \
63  byteBCDH2int(j) * 100000 + byteBCDL2int(j) * 10000 + \
64  byteBCDH2int(k) * 1000 + byteBCDL2int(k) * 100 + \
65  byteBCDH2int(l) * 10 + byteBCDL2int(l))
66 
67 // DVB Bluebook A038 (Sept 2011) p 77
69 {
70  public:
71  explicit NetworkNameDescriptor(const unsigned char *data, int len = 300) :
72  MPEGDescriptor(data, len, DescriptorID::network_name) { }
73  // Name bits loc expected value
74  // descriptor_tag 8 0.0 0x40
75  // descriptor_length 8 1.0
76  // for (i=0;i<N;i++){ char 8 uimsbf }
77  QString Name(void) const
78  { return dvb_decode_text(m_data+2, DescriptorLength()); }
79  QString ShortName(void) const
81  QString toString(void) const override // MPEGDescriptor
82  { return QString("NetworkNameDescriptor: ")+Name(); }
83 };
84 
85 // DVB Bluebook A038 (Sept 2011) p 63
87 {
88  public:
89  explicit LinkageDescriptor(const unsigned char *data, int len = 300) :
90  MPEGDescriptor(data, len, DescriptorID::linkage)
91  {
92  if (!m_data)
93  return;
94  if (DescriptorLength() < 7)
95  {
96  m_data = nullptr;
97  }
98  else if (kMobileHandOver == LinkageType())
99  {
100  uint end = 8;
101  if (DescriptorLength() < end)
102  {
103  m_data = nullptr;
104  return;
105  }
106  end += (HasMobileNetworkID()) ? 2 : 0;
107  end += (HasMobileInitialServiceID()) ? 2 : 0;
108  if (DescriptorLength() < end)
109  m_data = nullptr;
110  m_offset = end + 2;
111  }
112  else if (kEventLinkage == LinkageType())
113  {
114  if (DescriptorLength() < 10)
115  m_data = nullptr;
116  m_offset = 12;
117  }
118  }
119  // Name bits loc expected value
120  // descriptor_tag 8 0.0 0x4A
121  // descriptor_length 8 1.0
122  // transport_stream_id 16 2.0
123  uint TSID(void) const { return (m_data[2]<<8) | m_data[3]; }
124  // original_network_id 16 4.0
125  uint OriginalNetworkID() const { return (m_data[4]<<8) | m_data[5]; }
126  // service_id 16 6.0
127  uint ServiceID(void) const { return (m_data[6]<<8) | m_data[7]; }
128  // linkage_type 8 8.0
129  enum
130  {
132  kEPGService = 0x02,
137  kRCSMap = 0x07,
144  };
145  uint LinkageType(void) const { return m_data[8]; }
146  QString LinkageTypeString(void) const;
147 
148  // if (linkage_type == 0x08)
149  // {
150  // hand-over_type 4 9.0
151  enum
152  {
156  };
157  uint MobileHandOverType(void) const { return m_data[9]>>4; }
158  QString MobileHandOverTypeString(void) const;
159  // reserved_future_use 3 9.4
160  // origin_type 1 9.7
161  enum
162  {
163  kOriginNIT = 0x0,
164  kOriginSDT = 0x1,
165  };
166  uint MobileOriginType(void) const { return m_data[9]&0x1; }
167  QString MobileOriginTypeString(void) const;
168  // if (hand-over_type == 0x01 || hand-over_type == 0x02 ||
169  // hand-over_type == 0x03)
170  // { network_id 16 10.0 }
171  bool HasMobileNetworkID(void) const
172  { return bool(MobileHandOverType() & 0x3); }
173  uint MobileNetworkID(void) const { return (m_data[10]<<8) | m_data[11]; }
174  // if (origin_type ==0x00)
175  // { initial_service_id 16 HasNetworkID()?10.0:12.0 }
176  bool HasMobileInitialServiceID(void) const
177  { return kOriginNIT == MobileOriginType(); }
179  {
180  return HasMobileNetworkID() ?
181  ((m_data[12]<<8) | m_data[13]) : ((m_data[10]<<8) | m_data[11]);
182  }
183  // }
184  // if (linkage_type == 0x0D)
185  // {
186  // target_event_id 16 9.0
187  uint TargetEventID(void) const { return (m_data[9]<<8) | m_data[10]; }
188  // target_listed 1 11.0
189  bool IsTargetListed(void) const { return ( m_data[11]&0x80 ) != 0; }
190  // event_simulcast 1 11.1
191  bool IsEventSimulcast(void) const { return ( m_data[11]&0x40 ) != 0; }
192  // reserved 6 11.2
193  // }
194  // for (i=0;i<N;i++)
195  // { private_data_byte 8 bslbf }
196  const unsigned char *PrivateData(void) const
197  { return &m_data[m_offset]; }
199  { return DescriptorLength() + 2 - m_offset; }
200 
201  private:
203 };
204 
205 // DVB Bluebook A038 (Sept 2011) p 38
207 {
208  public:
209  explicit AdaptationFieldDataDescriptor(const unsigned char *data, int len = 300) :
210  MPEGDescriptor(data, len, DescriptorID::adaptation_field_data, 1) { }
211  // Name bits loc expected value
212  // descriptor_tag 8 0.0 0x70
213  // descriptor_length 8 1.0
214  // adapt_field_data_id 8 2.0
215  uint AdaptationFieldDataID(void) const { return m_data[2]; }
216  QString toString(void) const override // MPEGDescriptor
217  {
218  return QString("AdaptationFieldDataDescriptor "
219  "adaptation_field_data_identifier(%1)")
220  .arg(AdaptationFieldDataID());
221  }
222 };
223 
224 // DVB Bluebook A038 (Sept 2011) p 38
226 {
227  public:
228  explicit AncillaryDataDescriptor(const unsigned char *data, int len = 300) :
229  MPEGDescriptor(data, len, DescriptorID::ancillary_data, 1) { }
230  // Name bits loc expected value
231  // descriptor_tag 8 0.0 0x6b
232  // descriptor_length 8 1.0
233  // ancillary_data_id 8 2.0
234  uint AncillaryDataID(void) const { return m_data[2]; }
235  QString toString(void) const override // MPEGDescriptor
236  {
237  return QString("AncillaryDataDescriptor "
238  "ancillary_data_identifier(%1)")
239  .arg(AncillaryDataID());
240  }
241 };
242 
243 // DVB Bluebook A038 (Sept 2011) p 39
245 {
246  public:
247  explicit AnnouncementSupportDescriptor(const unsigned char *data, int len = 300) :
248  MPEGDescriptor(data, len, DescriptorID::announcement_support) { }
249  // Name bits loc expected value
250  // descriptor_tag 8 0.0 0x6e
251  // descriptor_length 8 1.0
252  // announcmnt_supprt_indic 16 2.0
253  // for (i=0; i<N; i++)
254  // {
255  // announcement_type 4 0.0+p
256  // reserved_future_use 1 0.4+p
257  // reference_type 3 0.5+p
258  // if (reference_type & 0x3)
259  // {
260  // original_network_id 16 0.0+p
261  // transport_stream_id 16 2.0+p
262  // service_id 16 4.0+p
263  // component_tag 8 6.0+p
264  // } 7.0
265  // }
266 };
267 
268 // DVB Bluebook A038 (Sept 2011) p 41
270 {
271  public:
272  explicit BouquetNameDescriptor(const unsigned char *data, int len = 300) :
273  MPEGDescriptor(data, len, DescriptorID::bouquet_name) { }
274  // Name bits loc expected value
275  // descriptor_tag 8 0.0 0x47
276  // descriptor_length 8 1.0
277  // for(i=0;i<N;i++) { char 8 }
278  QString BouquetName(void) const
279  { return dvb_decode_text(m_data+2, m_data[1]); }
280  QString BouquetShortName(void) const
281  { return dvb_decode_short_name(m_data+2, m_data[1]); }
282 
283  QString toString(void) const override // MPEGDescriptor
284  {
285  return QString("BouquetNameDescriptor: Bouquet Name(%1)")
286  .arg(BouquetName());
287  }
288 };
289 
290 // DVB Bluebook A038 (Sept 2011) p 41
292 {
293  public:
294  explicit CAIdentifierDescriptor(const unsigned char *data, int len = 300) :
295  MPEGDescriptor(data, len, DescriptorID::ca_identifier) { }
296  // Name bits loc expected value
297  // descriptor_tag 8 0.0 0x53
298  // descriptor_length 8 1.0
299  //
300  uint CASystemCount(void) const { return DescriptorLength() >> 1; }
301  // for (i=0; i<N; i++)
302  // { CA_system_id 16 }
303  int CASystemId(uint i) const
304  { return (m_data[2 + i*2] << 8) | m_data[3 + i*2]; }
305  QString toString(void) const override; // MPEGDescriptor
306 };
307 
308 // DVB Bluebook A038 (Sept 2011) p 42
310 {
311  public:
312  explicit CellFrequencyLinkDescriptor(const unsigned char *data, int len = 300) :
313  MPEGDescriptor(data, len, DescriptorID::cell_frequency_link) { }
314  // Name bits loc expected value
315  // descriptor_tag 8 0.0 0x6d
316  // descriptor_length 8 1.0
317  // for (i=0; i<N; i++)
318  // {
319  // cell_id 16 0.0+p
320  // frequency 32 2.0+p
321  // subcell_info_loop_len 8 6.0+p
322  // for (j=0;j<N;j++)
323  // {
324  // cell_id_extension 8 0.0+p2
325  // transposer_freq 32 1.0+p2
326  // } 5.0
327  // }
328 };
329 
330 // DVB Bluebook A038 (Sept 2011) p 42
332 {
333  public:
334  explicit CellListDescriptor(const unsigned char *data, int len = 300) :
335  MPEGDescriptor(data, len, DescriptorID::cell_list) { }
336  // Name bits loc expected value
337  // descriptor_tag 8 0.0 0x6c
338  // descriptor_length 8 1.0
339  // for (i=0; i<N; i++)
340  // {
341  // cell_id 16 0.0+p
342  // cell_latitude 16 2.0+p
343  // cell_longitude 16 4.0+p
344  // cell_extent_of_lat 12 6.0+p
345  // cell_extent_of_longit 12 7.4+p
346  // subcell_info_loop_len 8 9.0+p
347  // for (j=0;j<N;j++)
348  // {
349  // cell_id_extension 8 0.0+p2
350  // subcell_latitude 16 1.0+p2
351  // subcell_longitude 16 3.0+p2
352  // subcell_ext_of_lat 12 4.0+p2
353  // subcell_ext_of_long 12 5.4+p2
354  // } 7.0
355  // }
356 };
357 
358 // DVB Bluebook A038 (Sept 2011) p 44
360 {
361  public:
362  explicit ComponentDescriptor(const unsigned char *data, int len = 300) :
363  MPEGDescriptor(data, len, DescriptorID::component) { }
364  // Name bits loc expected value
365  // descriptor_tag 8 0.0 0x50
366  // descriptor_length 8 1.0
367  // reserved_future_use 4 2.0
368  // stream_content 4 2.4
369  uint StreamContent(void) const { return m_data[2] & 0xf; }
370  // component_type 8 3.0
371  uint ComponentType(void) const { return m_data[3]; }
372  // component_tag 8 4.0
373  uint ComponentTag(void) const { return m_data[4]; }
374  // ISO_639_language_code 24 5.0
375  int LanguageKey(void) const
376  { return iso639_str3_to_key(&m_data[5]); }
377  QString LanguageString(void) const
378  { return iso639_key_to_str3(LanguageKey()); }
379  int CanonicalLanguageKey(void) const
381  QString CanonicalLanguageString(void) const
383  //
384  // for (i=0; i<N; i++) { text_char 8 }
385 
386  bool IsVideo(void) const
387  {
388  return 0x1 == StreamContent() || // MPEG-2
389  0x5 == StreamContent() || // H.264
390  0x9 == StreamContent(); // HEVC
391  }
392  bool IsAudio(void) const
393  {
394  switch(StreamContent())
395  {
396  case 0x02:
397  case 0x04:
398  case 0x06:
399  case 0x07:
400  return true;
401  default:
402  return false;
403  }
404  }
405  bool IsSubtitle(void) const { return 0x3 == StreamContent(); }
406 
407  unsigned char VideoProperties(void) const
408  {
409  if (0x1 == StreamContent())
410  return MPEG2Properties();
411  if (0x5 == StreamContent())
412  return VID_AVC | AVCProperties();
413  if (0x9 == StreamContent())
414  return /* VID_HEVC | */ HEVCProperties();
415 
416  return VID_UNKNOWN;
417  }
418 
419  unsigned char MPEG2Properties(void) const
420  {
421  switch(ComponentType())
422  {
423  case 0x2: case 0x3: case 0x4:
424  case 0x6: case 0x7: case 0x8:
425  return VID_WIDESCREEN;
426  case 0x09:
427  case 0x0D:
428  return VID_HDTV;
429  case 0x0A: case 0x0B: case 0x0C:
430  case 0x0E: case 0x0F: case 0x10:
431  return VID_WIDESCREEN | VID_HDTV;
432  default:
433  return VID_UNKNOWN;
434  }
435  }
436 
437  unsigned char AVCProperties(void) const
438  {
439  switch(ComponentType())
440  {
441  case 0x3: case 0x4:
442  case 0x7: case 0x8:
443  return VID_WIDESCREEN;
444  case 0x0B: case 0x0C:
445  case 0x0F: case 0x10:
446  return VID_WIDESCREEN | VID_HDTV;
447  case 0x80: case 0x81:
448  case 0x82: case 0x83:
449  return VID_WIDESCREEN | VID_HDTV | VID_3DTV;
450  default:
451  return VID_UNKNOWN;
452  }
453  }
454 
455  unsigned char HEVCProperties(void) const
456  {
457  switch(ComponentType())
458  {
459  // NOLINTNEXTLINE(bugprone-branch-clone)
460  case 0x0: case 0x1:
461  case 0x2: case 0x3:
462  return VID_HDTV;
463  case 0x5:
464  return VID_HDTV; // | VID_UHDTV;
465  default:
466  return VID_UNKNOWN;
467  }
468  }
469 
470  unsigned char AudioProperties(void) const
471  {
472  switch (StreamContent())
473  {
474  case 0x2:
475  return MP2Properties();
476  case 0x04:
477  return AC3Properties();
478  case 0x06:
479  return HEAACProperties();
480  default:
481  return AUD_UNKNOWN;
482  }
483  }
484 
485  unsigned char MP2Properties(void) const
486  {
487  switch (ComponentType())
488  {
489  case 0x1:
490  return AUD_MONO;
491  case 0x3:
492  return AUD_STEREO;
493  case 0x5:
494  return AUD_SURROUND;
495  case 0x40:
496  return AUD_VISUALIMPAIR;
497  case 0x41:
498  return AUD_HARDHEAR;
499  default:
500  return AUD_UNKNOWN;
501  }
502  }
503 
504  unsigned char AC3Properties(void) const
505  {
506  unsigned char properties = AUD_UNKNOWN;
507 
508  switch (ComponentType() & 0x7)
509  {
510  case 0x0:
511  properties |= AUD_MONO;
512  break;
513  case 0x2:
514  properties |= AUD_STEREO;
515  break;
516  case 0x3:
517  properties |= AUD_DOLBY;
518  break;
519  case 0x4: case 0x5:
520  properties |= AUD_SURROUND;
521  break;
522  }
523 
524  if (((ComponentType() >> 3) & 0x7) == 0x2)
525  properties |= AUD_VISUALIMPAIR;
526 
527  if (((ComponentType() >> 3) & 0x7) == 0x3)
528  properties |= AUD_HARDHEAR;
529 
530  return properties;
531  }
532 
533  unsigned char HEAACProperties(void) const
534  {
535  switch (ComponentType())
536  {
537  case 0x1:
538  return AUD_MONO;
539  case 0x3:
540  case 0x43:
541  return AUD_STEREO;
542  case 0x5:
543  return AUD_SURROUND;
544  case 0x40:
545  case 0x44:
546  return AUD_VISUALIMPAIR;
547  case 0x41:
548  case 0x45:
549  return AUD_HARDHEAR;
550  default:
551  return AUD_UNKNOWN;
552  }
553  }
554 
555  unsigned char SubtitleType(void) const
556  {
557  if (!IsSubtitle())
558  return SUB_UNKNOWN;
559 
560  switch (ComponentType())
561  {
562  case 0x1:
563  case 0x3:
564  case 0x10: case 0x11: case 0x12: case 0x13:
565  return SUB_NORMAL;
566  case 0x20: case 0x21: case 0x22: case 0x23:
567  return SUB_HARDHEAR;
568  default:
569  return SUB_UNKNOWN;
570  }
571  }
572 
573  QString toString(void) const override // MPEGDescriptor
574  {
575  return QString("ComponentDescriptor(stream_content: 0x%1, "
576  "component_type: 0x%2)").arg(StreamContent(), 0, 16)
577  .arg(ComponentType(), 0, 16);
578  }
579 };
580 
581 // DVB Bluebook A038 (Sept 2011) p 46
583 {
584  public:
585  explicit ContentDescriptor(const unsigned char *data, int len = 300) :
586  MPEGDescriptor(data, len, DescriptorID::content) { }
587  // Name bits loc expected value
588  // descriptor_tag 8 0.0 0x54
589  // descriptor_length 8 1.0
590 
591  uint Count(void) const { return DescriptorLength() >> 1; }
592  // for (i=0;i<N;i++)
593  // {
594  // content_nibble_level_1 4 0.0+p
595  uint Nibble1(uint i) const { return m_data[2 + (i<<1)] >> 4; }
596  // content_nibble_level_2 4 0.4+p
597  uint Nibble2(uint i) const { return m_data[2 + (i<<1)] & 0xf; }
598 
599  uint Nibble(uint i) const { return m_data[2 + (i<<1)]; }
600 
601  // user_nibble 4 1.0+p
602  uint UserNibble1(uint i) const { return m_data[3 + (i<<1)] >> 4; }
603  // user_nibble 4 1.4+p
604  uint UserNibble2(uint i) const { return m_data[3 + (i<<1)] & 0xf; }
605  uint UserNibble(uint i) const { return m_data[3 + (i<<1)]; }
606  // } 2.0
607 
609  QString GetDescription(uint i) const;
610  QString toString(void) const override; // MPEGDescriptor
611 
612  protected:
613  static void Init(void);
614 
615  protected:
616  static QMutex s_categoryLock;
617  static QMap<uint,QString> s_categoryDesc;
618  static volatile bool s_categoryDescExists;
619 };
620 
621 // DVB Bluebook A038 (Sept 2011) p 49
623 {
624  public:
625  explicit CountryAvailabilityDescriptor(const unsigned char *data, int len = 300) :
626  MPEGDescriptor(data, len, DescriptorID::country_availability) { }
627  // Name bits loc expected value
628  // descriptor_tag 8 0.0 0x49
629  // descriptor_length 8 1.0
630 
631  uint CountryCount(void) const { return ((DescriptorLength() - 1) / 3); }
632 
633  // country_avail_flag 1 2.0
634  bool IsAvailable(void) const { return (m_data[2] & 0x1); }
635  // reserved_future_use 7 2.1
636  //
637  // for (i=0; i<N; i++)
638  // { country_code 24 }
639  QString CountryNames(void) const
640  {
641  QString countries="";
642  for (uint i=0; i<CountryCount(); i++)
643  {
644  if (i!=0) countries.append(" ");
645  countries.append(QString::fromLatin1(
646  (const char *)m_data+(3*(i+1)), 3));
647  };
648  return countries;
649  }
650 
651  QString toString(void) const override // MPEGDescriptor
652  {
653  return QString("CountryAvailabilityDescriptor: Available(%1) in (%2)")
654  .arg(IsAvailable()).arg(CountryNames());
655  }
656 };
657 
658 // DVB Bluebook A038 (Sept 2011) p 50
660 {
661  public:
662  explicit DataBroadcastDescriptor(const unsigned char *data, int len = 300) :
663  MPEGDescriptor(data, len, DescriptorID::data_broadcast) { }
664  // Name bits loc expected value
665  // descriptor_tag 8 0.0 0x64
666  // descriptor_length 8 1.0
667 
668  // data_broadcast_id 16 2.0
669  uint DataBroadcastId(void) const { return m_data[2] << 8 | m_data[3]; }
670  // component_tag 8 4.0
671  uint DataComponentTag(void) const { return m_data[4]; }
672  // selector_length 8 5.0
673  uint SelectorLength(void) const { return m_data[5]; }
674  // for (i=0; i<selector_length; i++)
675  // {
676  // selector_byte 8
677  const unsigned char *Selector(void) const { return &m_data[6]; }
678  // }
679  // ISO_639_language_code 24
680  int LanguageKey(void) const
681  { return iso639_str3_to_key(&m_data[6 + SelectorLength()]); }
682  QString LanguageString(void) const
683  { return iso639_key_to_str3(LanguageKey()); }
684  int CanonicalLanguageKey(void) const
686  QString CanonicalLanguageString(void) const
688  // text_length 8
689  uint TextLength(void) const { return m_data[6 + SelectorLength() + 3]; }
690  // for (i=0; i<text_length; i++) { text_char 8 }
691  QString Text(void) const
692  {
693  return dvb_decode_text(&m_data[6 + SelectorLength() + 4], TextLength());
694  }
695 
696  QString toString(void) const override; // MPEGDescriptor
697 };
698 
699 // DVB Bluebook A038 (Sept 2011) p 51
701 {
702  public:
703  explicit DataBroadcastIdDescriptor(const unsigned char *data, int len = 300) :
704  MPEGDescriptor(data, len, DescriptorID::data_broadcast_id) { }
705  // Name bits loc expected value
706  // descriptor_tag 8 0.0 0x66
707  // descriptor_length 8 1.0
708 
709  // data_broadcast_id 16 2.0
710  uint DataBroadCastId(void) const { return m_data[2] << 8 | m_data[3]; }
711  // for(i=0; i < N;i++ )
712  // { id_selector_byte 8 }
713 };
714 
715 // DVB Bluebook A038 (Sept 2011) p 51
717 {
718  public:
719  explicit CableDeliverySystemDescriptor(const unsigned char *data, int len = 300) :
720  MPEGDescriptor(data, len, DescriptorID::cable_delivery_system) { }
721  // Name bits loc expected value
722  // descriptor_tag 8 0.0 0x44
723  // descriptor_length 8 1.0
724 
725  // frequency 32 2.0
726  uint FrequencyRaw(void) const
727  {
728  return ((m_data[2]<<24) | (m_data[3]<<16) |
729  (m_data[4]<<8) | (m_data[5]));
730  }
731  unsigned long long FrequencyHz(void) const
732  {
733  return byte4BCD2int(m_data[2], m_data[3], m_data[4], m_data[5]) * 100;
734  }
735  // reserved_future_use 12 6.0
736  // FEC_outer 4 7.4
737  enum
738  {
741  };
742  uint FECOuter(void) const { return m_data[7] & 0xf; }
743  QString FECOuterString(void) const
744  {
745  return (FECOuter() == kOuterFEC_None) ? "None" :
746  ((FECOuter() == kOuterFEC_RS204_RS188) ? "RS(204/188)" : "unknown");
747  }
748  // modulation 8 8.0
749  enum
750  {
756  };
757  uint Modulation(void) const { return m_data[8]; }
758  QString ModulationString(void) const
759  {
760  static QString ms[] =
761  { "auto", "qam_16", "qam_32", "qam_64", "qam_128", "qam_256" };
762  return (Modulation() <= kModulationQAM256) ?
763  ms[Modulation()] : QString("auto");
764  }
765  // symbol_rate 28 9.0
766  uint SymbolRateRaw(void) const
767  {
768  return ((m_data[9]<<20) | (m_data[10]<<12) |
769  (m_data[11]<<4) | (m_data[12]>>4));
770  }
771  uint SymbolRateHz(void) const
772  {
773  return ((byte3BCD2int(m_data[9], m_data[10], m_data[11]) * 1000) +
774  (byteBCDH2int(m_data[12]) * 100));
775  }
776  // FEC_inner 4 12.4
777  enum
778  {
786  };
787  uint FECInner(void) const { return m_data[12] & 0xf; }
788  QString FECInnerString(void) const { return coderate_inner(FECInner()); }
789  QString toString(void) const override; // MPEGDescriptor
790 };
791 
792 // DVB Bluebook A038 (Sept 2011) p 53
794 {
795  public:
797  const unsigned char *data, int len = 300) :
798  MPEGDescriptor(data, len, DescriptorID::satellite_delivery_system) { }
799  // Name bits loc expected value
800  // descriptor_tag 8 0.0 0x43
801  // descriptor_length 8 1.0
802 
804  uint FrequencyRaw(void) const
805  {
806  return ((m_data[2]<<24) | (m_data[3]<<16) |
807  (m_data[4]<<8) | (m_data[5]));
808  }
809  unsigned long long FrequencykHz(void) const
810  {
811  return byte4BCD2int(m_data[2], m_data[3], m_data[4], m_data[5]) * 10;
812  }
814  uint OrbitalPosition(void) const
815  { return byte2BCD2int(m_data[6], m_data[7]); }
816  QString OrbitalPositionString(void) const
817  {
818  uint num = OrbitalPosition();
819  return QString("%1.%2 %3").arg(num / 10).arg(num % 10)
820  .arg((IsEast()) ? "East" : "West");
821  }
822  double OrbitalPositionFloat() const
823  { return ((double) OrbitalPosition()) / 10.0; }
825  bool IsEast(void) const { return ( (m_data[8]&0x80) ) != 0; }
826  bool IsWest(void) const { return !IsEast(); }
827  // polarization 2 8.1
828  uint Polarization(void) const { return (m_data[8]>>5)&0x3; }
829  QString PolarizationString() const
830  {
831  static QString ps[] = { "h", "v", "l", "r" };
832  return ps[Polarization()];
833  }
834  bool IsCircularPolarization(void) const { return (m_data[8]>>6)&0x1; }
835  bool IsLinearPolarization(void) const { return !((m_data[8]>>6)&0x1); }
836  bool IsHorizontalLeftPolarization(void) const { return (m_data[8]>>5)&0x1; }
838  { return !((m_data[8]>>5)&0x1); }
839  // roll off 2 8.3
840  enum
841  {
846  };
847  uint RollOff(void) const { return (m_data[8]>>3)&0x3; }
848  QString RollOffString(void) const
849  {
850  static QString ro[] = { "0.35", "0.20", "0.25", "auto" };
851  return ro[RollOff()];
852  }
853  // modulation system 1 8.5
854  uint ModulationSystem(void) const { return (m_data[8]>>2)&0x1; }
855  QString ModulationSystemString(void) const
856  {
857  return ModulationSystem() ? "DVB-S2" : "DVB-S";
858  }
859  // modulation 2 8.6
860  enum
861  {
862  kModulationQPSK_NS = 0x0, // Non standard QPSK for Bell ExpressVu
863  // should be "auto" according to DVB SI standard
867  };
868  uint Modulation(void) const { return m_data[8]&0x03; }
869  QString ModulationString(void) const
870  {
871  static QString ms[] = { "qpsk", "qpsk", "8psk", "qam_16" };
872  return ms[Modulation()];
873  }
874  // symbol_rate 28 9.0
875  uint SymbolRate(void) const
876  {
877  return ((m_data[9]<<20) | (m_data[10]<<12) |
878  (m_data[11]<<4) | (m_data[12]>>4));
879  }
880  uint SymbolRateHz(void) const
881  {
882  return ((byte3BCD2int(m_data[9], m_data[10], m_data[11]) * 1000) +
883  (byteBCDH2int(m_data[12]) * 100));
884  }
885  // FEC_inner 4 12.4
886  enum
887  {
895  };
896  uint FECInner(void) const { return m_data[12] & 0xf; }
897  QString FECInnerString(void) const { return coderate_inner(FECInner()); }
898 
899  QString toString(void) const override; // MPEGDescriptor
900 };
901 
902 // DVB Bluebook A038 (Sept 2011) p 55
904 {
905  public:
907  const unsigned char *data, int len = 300) :
908  MPEGDescriptor(data, len, DescriptorID::terrestrial_delivery_system) { }
909  // Name bits loc expected value
910  // descriptor_tag 8 0.0 0x5a
911  // descriptor_length 8 1.0
912 
913  // centre_frequency 32 2.0
914  uint Frequency(void) const
915  {
916  return ((m_data[2]<<24) | (m_data[3]<<16) |
917  (m_data[4]<<8) | (m_data[5]));
918  }
919  uint64_t FrequencyHz(void) const { return uint64_t(Frequency()) * 10ULL; }
920 
921  // bandwidth 3 6.0
922  enum
923  {
928  };
929  uint Bandwidth(void) const { return m_data[6]>>5; }
930  uint BandwidthHz(void) const { return (8 - Bandwidth()) * 1000000; }
931  QString BandwidthString(void) const
932  {
933  static QString bs[] = { "8", "7", "6", "5" };
934  return (Bandwidth() <= kBandwidth5Mhz) ? bs[Bandwidth()] : "auto";
935  }
936  // priority 1 6.3
937  bool HighPriority(void) const { return ( m_data[6] & 0x10 ) != 0; }
938  // time_slicing_indicator 1 6.4
939  bool IsTimeSlicingIndicatorUsed(void) const { return !(m_data[6] & 0x08); }
940  // MPE-FEC_indicator 1 6.5
941  bool IsMPE_FECUsed(void) const { return !(m_data[6] & 0x04); }
942  // reserved_future_use 2 6.6
943  // constellation 2 7.0
944  enum
945  {
950  };
951  uint Constellation(void) const { return m_data[7]>>6; }
952  QString ConstellationString(void) const
953  {
954  static QString cs[] = { "qpsk", "qam_16", "qam_64", "qam_256" };
955  return (Constellation() <= kConstellationQAM256) ?
956  cs[Constellation()] : "auto";
957  }
958  // hierarchy_information 3 7.2
959  enum
960  {
969  };
970  uint Hierarchy(void) const { return (m_data[7]>>3) & 0x7; }
971 
973  QString HierarchyString(void) const
974  {
975  static QString hs[] = { "n", "1", "2", "4", "a", "a", "a", "a" };
976  return hs[Hierarchy()];
977  }
978  bool NativeInterleaver(void) const { return ( m_data[7] & 0x20 ) != 0; }
979  uint Alpha(void) const
980  {
981  uint i = (m_data[7]>>3) & 0x3;
982  return (0x2 == i) ? 4 : i;
983  }
984  // code_rate-HP_stream 3 7.5
985  enum
986  {
992  };
993  uint CodeRateHP(void) const { return m_data[7] & 0x7; }
994  QString CodeRateHPString(void) const
995  {
996  static QString cr[] = {
997  "1/2", "2/3", "3/4", "5/6", "7/8", "auto", "auto", "auto"
998  };
999  return cr[CodeRateHP()];
1000  }
1001  // code_rate-LP_stream 3 8.0
1002  uint CodeRateLP(void) const { return (m_data[8]>>5) & 0x7; }
1003  QString CodeRateLPString(void) const
1004  {
1005  static QString cr[] = {
1006  "1/2", "2/3", "3/4", "5/6", "7/8", "auto", "auto", "auto"
1007  };
1008  return cr[CodeRateLP()];
1009  }
1010  // guard_interval 2 8.3
1011  enum
1012  {
1017  };
1018  uint GuardInterval(void) const { return (m_data[8]>>3) & 0x3; }
1019  QString GuardIntervalString(void) const
1020  {
1021  static QString gi[] = { "1/32", "1/16", "1/8", "1/4" };
1022  return gi[GuardInterval()];
1023  }
1024  // transmission_mode 2 8.5
1025  enum
1026  {
1030  };
1031  uint TransmissionMode(void) const { return (m_data[8]>>1) & 0x3; }
1032  QString TransmissionModeString(void) const
1033  {
1034  static QString tm[] = { "2", "8", "4", "auto" };
1035  return tm[TransmissionMode()];
1036  }
1037  // other_frequency_flag 1 8.7
1038  bool OtherFrequencyInUse(void) const { return m_data[8] & 0x1; }
1039  // reserved_future_use 32 9.0
1040 
1041  QString toString(void) const override; // MPEGDescriptor
1042 };
1043 
1044 // DVB Bluebook A038 (Sept 2011) p 58
1046 {
1047  public:
1048  explicit DSNGDescriptor(const unsigned char *data, int len = 300) :
1049  MPEGDescriptor(data, len, DescriptorID::dsng) { }
1050  // Name bits loc expected value
1051  // descriptor_tag 8 0.0 0x68
1052  // descriptor_length 8 1.0
1053  // for (i=0;i<N;i++) { byte 8 }
1054 };
1055 
1056 // DVB Bluebook A038 (Sept 2011) p 58
1058 {
1059  public:
1060  explicit ExtendedEventDescriptor(const unsigned char *data, int len = 300) :
1061  MPEGDescriptor(data, len, DescriptorID::extended_event) { }
1062  // Name bits loc expected value
1063  // descriptor_tag 8 0.0 0x4e
1064  // descriptor_length 8 1.0
1065 
1066  // descriptor_number 4 2.0
1067  uint DescriptorNumber(void) const { return m_data[2] >> 4; }
1068  // last_number 4 2.4
1069  uint LastNumber(void) const { return m_data[2] & 0xf; }
1070  // ISO_639_language_code 24 3.0
1071  int LanguageKey(void) const
1072  { return iso639_str3_to_key(&m_data[3]); }
1073  QString LanguageString(void) const
1074  { return iso639_key_to_str3(LanguageKey()); }
1075  int CanonicalLanguageKey(void) const
1077  QString CanonicalLanguageString(void) const
1079  // length_of_items 8 6.0
1080  uint LengthOfItems(void) const { return m_data[6]; }
1081  // for ( i=0;i<N;i++)
1082  // {
1083  // item_description_len 8 0.0+p
1084  // for (j=0;j<N;j++) { item_desc_char 8 }
1085  // item_length 8 1.0+p2
1086  // for (j=0;j<N;j++) { item_char 8 }
1087  // }
1088  QMap<QString,QString> Items(void) const;
1089  // text_length 8
1090  uint TextLength(void) const { return m_data[7 + LengthOfItems()]; }
1091  // for (i=0; i<N; i++) { text_char 8 }
1092  QString Text(void) const
1093  { return dvb_decode_text(&m_data[8 + LengthOfItems()], TextLength()); }
1094 
1095  // HACK beg -- Pro7Sat is missing encoding
1096  QString Text(const unsigned char *encoding_override,
1097  uint encoding_length) const
1098  {
1099  return dvb_decode_text(&m_data[8 + LengthOfItems()], TextLength(),
1100  encoding_override, encoding_length);
1101  }
1102  // HACK end -- Pro7Sat is missing encoding
1103 };
1104 
1105 // DVB Bluebook A038 (Sept 2011) p 60
1107 {
1108  public:
1109  explicit FrequencyListDescriptor(const unsigned char *data, int len = 300) :
1110  MPEGDescriptor(data, len, DescriptorID::frequency_list) { }
1111  // Name bits loc expected value
1112  // descriptor_tag 8 0.0 0x62
1113  // descriptor_length 8 1.0
1114 
1115  // reserved_future_use 6 2.0
1116  // coding_type 2 2.6
1117  enum
1118  {
1123  };
1124  uint CodingType(void) const { return m_data[2] & 0x3; }
1125  // for (i=0;I<N;i++)
1126  // {
1127  // centre_frequency 32
1128  // }
1129  uint FrequencyCount() const { return DescriptorLength()>>2; }
1130  unsigned long long Frequency(uint i) const
1131  {
1133  {
1134  return (((unsigned long long)m_data[i*4+3]<<24) |
1135  (m_data[i*4+4]<<16) |
1136  (m_data[i*4+5]<<8) |
1137  (m_data[i*4+6]));
1138  }
1139  return byte4BCD2int(m_data[i*4+3], m_data[i*4+4],
1140  m_data[i*4+5], m_data[i*4+6]);
1141  }
1142  unsigned long long FrequencyHz(uint i) const
1143  {
1144  return Frequency(i) *
1145  ((kCodingTypeTerrestrial == CodingType()) ? 10 : 100);
1146  }
1147 
1148  QString toString(void) const override; // MPEGDescriptor
1149 };
1150 
1151 // DVB Bluebook A038 (Sept 2011) p 70
1152 // ETSI EN 300 468 p 58
1154 {
1155  public:
1156  explicit LocalTimeOffsetDescriptor(const unsigned char *data, int len = 300) :
1157  MPEGDescriptor(data, len, DescriptorID::local_time_offset) { }
1158  // Name bits loc expected value
1159  // descriptor_tag 8 0.0 0x58
1160  // descriptor_length 8 1.0
1161  uint Count(void) const { return DescriptorLength() / 13; }
1162  // for(i=0;i<N;i++)
1163  // {
1164  // country_code 24 0.0+p
1166  {
1167  int o = 2 + i*13;
1168  return ((m_data[o] << 16) | (m_data[o+1] << 8) | m_data[o+2]);
1169  }
1170  QString CountryCodeString(uint i) const
1171  {
1172  int o = 2 + i*13;
1173  return QString(m_data[o]) + QChar(m_data[o+1]) + QChar(m_data[o+2]);
1174  }
1175  // country_region_id 6 3.0+p
1176  uint CountryRegionId(uint i) const { return m_data[2 + i*13 + 3] >> 2; }
1177  // reserved 1 3.6+p
1178  // local_time_off_polarity 1 3.7+p
1181  { return m_data[2 + i*13 + 3] & 0x01; }
1182  // local_time_offset 16 4.0+p
1184  { return (m_data[2 + i*13 + 4] << 8) | m_data[2 + i*13 + 5]; }
1186  { return (LocalTimeOffsetPolarity(i) ? -1 : +1) * LocalTimeOffset(i); }
1187  // time_of_change 40 6.0+p
1188  // TODO decode this
1189  // next_time_offset 16 11.0+p
1191  { return (m_data[2 + i*13 + 11]<<8) | m_data[2 + i*13 + 12]; }
1192  // } 13.0
1193  QString toString(void) const override; // MPEGDescriptor
1194 };
1195 
1196 // DVB Bluebook A038 (Sept 2011) p 71
1198 {
1199  public:
1200  explicit MosaicDescriptor(const unsigned char *data, int len = 300) :
1201  MPEGDescriptor(data, len, DescriptorID::mosaic) { }
1202  // Name bits loc expected value
1203  // descriptor_tag 8 0.0 0x51
1204  // descriptor_length 8 1.0
1205 
1206  // mosaic_entry_point 1 2.0
1207  // num_horiz_elem_cells 3 2.1
1208  // reserved_future_use 1 2.4
1209  // num_vert_elem_cells 3 2.5
1210  // for (i=0;i<N; i++)
1211  // {
1212  // logical_cell_id 6 0.0+p
1213  // reserved_future_use 7 0.6+p
1214  // logical_cell_pres_info 3 1.5+p
1215  // elem_cell_field_len 8 2.0+p
1216  // for (i=0; j<elementary_cell_field_length; j++)
1217  // {
1218  // reserved_future_use 2
1219  // elementary_cell_id 6
1220  // }
1221  // cell_linkage_info 8
1222  // if (cell_linkage_info == 0x01)
1223  // {
1224  // bouquet_id 16
1225  // }
1226  // if (cell_linkage_info == 0x02)
1227  // {
1228  // original_network_id 16
1229  // transport_stream_id 16
1230  // service_id 16
1231  // }
1232  // if (cell_linkage_info == 0x03)
1233  // {
1234  // original_network_id 16
1235  // transport_stream_id 16
1236  // service_id 16
1237  // }
1238  // if (cell_linkage_info == 0x04)
1239  // {
1240  // original_network_id 16
1241  // transport_stream_id 16
1242  // service_id 16
1243  // event_id 16
1244  // }
1245  // }
1246 };
1247 
1248 // DVB Bluebook A038 (Sept 2011) p 74
1250 {
1251  public:
1253  const unsigned char *data, int len = 300) :
1254  MPEGDescriptor(data, len, DescriptorID::multilingual_bouquet_name) { }
1255  // Name bits loc expected value
1256  // descriptor_tag 8 0.0 0x5c
1257  // descriptor_length 8 1.0
1258 
1259  // for (i=0;i<N;i++)
1260  // {
1261  // ISO_639_language_code 24
1262  // bouquet_name_length 8
1263  // for (j=0;j<N;j++) { char 8 }
1264  // }
1265 };
1266 
1267 // DVB Bluebook A038 (Sept 2011) p 75
1269 {
1270  public:
1272  const unsigned char *data, int len = 300) :
1273  MPEGDescriptor(data, len, DescriptorID::multilingual_network_name)
1274  {
1275  // Name bits loc expected value
1276  // descriptor_tag 8 0.0 0x5b
1277  // descriptor_length 8 1.0
1278  }
1279 
1280  // for (i=0;i<N;i++)
1281  // {
1282  // ISO_639_language_code 24
1283  // network_name_length 8
1284  // for (j=0;j<N;j++) { char 8 }
1285  // }
1286 };
1287 
1288 // DVB Bluebook A038 (Sept 2011) p 76
1290 {
1291  public:
1293  const unsigned char *data, int len = 300) :
1294  MPEGDescriptor(data, len, DescriptorID::multilingual_service_name) { }
1295  // Name bits loc expected value
1296  // descriptor_tag 8 0.0 0x5d
1297  // descriptor_length 8 1.0
1298 
1299  // for (i=0;i<N;i++)
1300  // {
1301  // ISO_639_language_code 24
1302  // service_provider_name_length 8
1303  // for (j=0;j<N;j++) { char 8 }
1304  // service_name_length 8
1305  // for (j=0;j<N;j++) { char 8 }
1306  // }
1307 };
1308 
1309 // DVB Bluebook A038 (Sept 2011) p 76
1311 {
1312  public:
1313  explicit NVODReferenceDescriptor(const unsigned char *data, int len = 300) :
1314  MPEGDescriptor(data, len, DescriptorID::nvod_reference) { }
1315  // Name bits loc expected value
1316  // descriptor_tag 8 0.0 0x4b
1317  // descriptor_length 8 1.0
1318  uint Count(void) const { return DescriptorLength() / 6; }
1319 
1320  // for (i=0;i<N;i++)
1321  // {
1322  // transport_stream_id 16
1324  { return (m_data[i * 6 + 2] << 8) | m_data[i * 6 + 3]; }
1325  // original_network_id 16
1327  { return (m_data[i * 6 + 4] << 8) | m_data[i * 6 + 5]; }
1328  // service_id 16
1330  { return (m_data[i * 6 + 6] << 8) | m_data[i * 6 + 7]; }
1331  // }
1332  QString toString(void) const override; // MPEGDescriptor
1333 };
1334 
1335 // DVB Bluebook A038 (Sept 2011) p 78
1336 // ETSI EN 300 468
1338 {
1339  public:
1340  explicit ParentalRatingDescriptor(const unsigned char *data, int len = 300) :
1341  MPEGDescriptor(data, len, DescriptorID::parental_rating) { }
1342  // Name bits loc expected value
1343  // descriptor_tag 8 0.0 0x55
1344  // descriptor_length 8 1.0
1345  uint Count(void) const { return DescriptorLength() / 4; }
1346 
1347  // for (i=0; i<N; i++)
1348  // {
1349  // country_code 24
1350  // rating 8
1351  // }
1352  QString CountryCodeString(uint i) const
1353  {
1354  int o = 2 + i*4;
1355  if (i < Count())
1356  return QString(m_data[o]) + QChar(m_data[o+1]) + QChar(m_data[o+2]);
1357  return QString("");
1358  }
1359  int Rating(uint i) const
1360  {
1361  if (i >= Count())
1362  {
1363  return -1;
1364  }
1365 
1366  unsigned char rawRating = m_data[2 + 3 + i*4];
1367  if (rawRating == 0)
1368  {
1369  // 0x00 - undefined
1370  return -1;
1371  }
1372  if ((rawRating >= 0x01) && (rawRating <= 0x0F))
1373  {
1374  // 0x01 to 0x0F - minumum age = rating + 3 years
1375  return rawRating + 3;
1376  }
1377 
1378  // 0x10 to 0xFF - defined by the broadcaster
1379  return -1;
1380  }
1381 };
1382 
1383 // DVB Bluebook A038 (Sept 2011) p 78 (see also ETSI EN 300 231 PDC)
1385 {
1386  public:
1387  explicit PDCDescriptor(const unsigned char *data, int len = 300) :
1388  MPEGDescriptor(data, len, DescriptorID::pdc, 3) { }
1389  // Name bits loc expected value
1390  // descriptor_tag 8 0.0 0x69
1391  // descriptor_length 8 1.0
1392 
1393  // reserved_future_use 4 2.0
1394  // program_id_label 20 2.4
1395  uint ProgramIdLabel(void) const
1396  { return (m_data[2] & 0x0F) << 16 | m_data[3] << 8 | m_data[4]; }
1397  QString toString(void) const override // MPEGDescriptor
1398  {
1399  return QString("PDCDescriptor program_id_label(%1)")
1400  .arg(ProgramIdLabel());
1401  }
1402 };
1403 
1404 // DVB Bluebook A038 (Sept 2011) p 79 (see also ETSI TS 101 162)
1406 {
1407  public:
1408  explicit PrivateDataSpecifierDescriptor(const unsigned char *data, int len = 300) :
1409  MPEGDescriptor(data, len, DescriptorID::private_data_specifier) { }
1410  // Name bits loc expected value
1411  // descriptor_tag 8 0.0 0x5f
1412  // descriptor_length 8 1.0
1413 
1414  // private_data_specifier 32 2.0
1415  uint32_t PrivateDataSpecifier (void) const
1416  {
1417  return (m_data[2] << 24 | m_data[3] << 16 | m_data[4] << 8 | m_data[5]);
1418  }
1419 };
1420 
1421 // DVB Bluebook A038 (Sept 2011) p 79
1423 {
1424  public:
1425  explicit ScramblingDescriptor(const unsigned char *data, int len = 300) :
1426  MPEGDescriptor(data, len, DescriptorID::scrambling, 1) { }
1427  // Name bits loc expected value
1428  // descriptor_tag 8 0.0 0x65
1429  // descriptor_length 8 1.0
1430 
1431  // scrambling_mode 8 2.0
1432  uint ScramblingMode(void) const { return m_data[2]; }
1433  QString toString(void) const override // MPEGDescriptor
1434  {
1435  return QString("ScramblingDescriptor scrambling_mode(%1)")
1436  .arg(ScramblingMode());
1437  }
1438 };
1439 
1440 // DVB Bluebook A038 (Feb 2019) p 83, Table 89: Service type coding
1442 {
1443  public:
1444  explicit ServiceDescriptorMapping(const uint service_type) { m_serviceType = service_type; }
1445  enum
1446  {
1455  // reserved for future use = 0x09,
1464  // reserved for future use = 0x12 to 0x15
1476  // reserved for future use = 0x21 to 0x7F
1477  // user defined = 0x80 to 0xFE
1478  // reserved for future use = 0xFF
1479  // User Defined descriptors for Dish network
1493 
1494  };
1495  uint ServiceType(void) const { return m_serviceType; }
1496  bool IsDTV(void) const
1497  {
1498  return ((ServiceType() == kServiceTypeDigitalTelevision) ||
1500  IsHDTV() ||
1501  IsUHDTV() ||
1515  }
1516  bool IsDigitalAudio(void) const
1517  {
1518  return
1521  }
1522  bool IsHDTV(void) const
1523  {
1524  return
1528  }
1529  bool IsUHDTV(void) const
1530  {
1531  return
1534  }
1535  bool IsTeletext(void) const
1536  {
1538  }
1539  QString toString(void) const;
1540 
1541  private:
1543 };
1544 
1545 // DVB Bluebook A038 (Sept 2011) p 80
1547 {
1548  public:
1549  explicit ServiceDescriptor(const unsigned char *data, int len = 300) :
1550  MPEGDescriptor(data, len, DescriptorID::service) { }
1551  // Name bits loc expected value
1552  // descriptor_tag 8 0.0 0x48
1553  // descriptor_length 8 1.0
1554 
1555  // service_type 8 2.0
1556  uint ServiceType(void) const { return m_data[2]; }
1557  // svc_provider_name_len 8 3.0
1558  uint ServiceProviderNameLength(void) const { return m_data[3]; }
1559  // for (i=0;i<N;I++) { char 8 }
1560  QString ServiceProviderName(void) const
1562  QString ServiceProviderShortName(void) const
1563  {
1565  }
1566  // service_name_length 8
1568  { return m_data[4 + ServiceProviderNameLength()]; }
1569  // for (i=0;i<N;I++) { char 8 }
1570  QString ServiceName(void) const
1571  {
1573  ServiceNameLength());
1574  }
1575  QString ServiceShortName(void) const
1576  {
1578  ServiceNameLength());
1579  }
1580  bool IsDTV(void) const
1581  { return ServiceDescriptorMapping(ServiceType()).IsDTV(); }
1582  bool IsDigitalAudio(void) const
1584  bool IsHDTV(void) const
1586  bool IsTeletext(void) const
1588 
1589  QString toString(void) const override // MPEGDescriptor
1590  {
1591  return QString("ServiceDescriptor: %1 %2(0x%3)")
1592  .arg(ServiceName())
1594  .arg(ServiceType(),2,16,QChar('0'));
1595  }
1596 };
1597 
1598 // DVB Bluebook A038 (Sept 2011) p 82
1600 {
1601  public:
1602  explicit ServiceAvailabilityDescriptor(const unsigned char *data, int len = 300) :
1603  MPEGDescriptor(data, len, DescriptorID::service_availability) { }
1604  // Name bits loc expected value
1605  // descriptor_tag 8 0.0 0x72
1606  // descriptor_length 8 1.0
1607 
1608  // availability_flag 1 2.0
1609  // reserved 7 2.1
1610  // for (i=0;i<N;i++) { cell_id 16 }
1611 };
1612 
1613 // DVB Bluebook A038 (Sept 2011) p 82
1615 {
1616  public:
1617  explicit ServiceListDescriptor(const unsigned char *data, int len = 300) :
1618  MPEGDescriptor(data, len, DescriptorID::service_list) { }
1619  // Name bits loc expected value
1620  // descriptor_tag 8 0.0 0x41
1621  // descriptor_length 8 1.0
1622 
1623  // for (i=0;i<N;I++)
1624  // {
1625  // service_id 16 0.0+p
1626  // service_type 8 2.0+p
1627  // }
1628  uint ServiceCount(void) const { return DescriptorLength() / 3; }
1629 
1631  { return (m_data[2+i*3] << 8) | m_data[3+i*3]; }
1632 
1633  uint ServiceType(uint i) const { return m_data[4+i*3]; }
1634 
1635  QString toString(void) const override // MPEGDescriptor
1636  {
1637  QString str = QString("ServiceListDescriptor: %1 Services\n")
1638  .arg(ServiceCount());
1639  for (uint i=0; i<ServiceCount(); i++)
1640  {
1641  if (i!=0) str.append("\n");
1642  str.append(QString(" Service (%1) Type%2").arg(ServiceID(i))
1644  }
1645  return str;
1646  }
1647 };
1648 
1649 // DVB Bluebook A038 (Sept 2011) p 82
1651 {
1652  public:
1653  explicit ServiceMoveDescriptor(const unsigned char *data, int len = 300) :
1654  MPEGDescriptor(data, len, DescriptorID::service_move) { }
1655  // Name bits loc expected value
1656  // descriptor_tag 8 0.0 0x60
1657  // descriptor_length 8 1.0
1658 
1659  // new_original_network_id 16 2.0
1660  // new_transport_stream_id 16 4.0
1661  // new_service_id 16 6.0
1662 };
1663 
1664 // DVB Bluebook A038 (Sept 2011) p 83
1666 {
1667  public:
1668  explicit ShortEventDescriptor(const unsigned char *data, int len = 300) :
1669  MPEGDescriptor(data, len, DescriptorID::short_event) { }
1670  // Name bits loc expected value
1671  // descriptor_tag 8 0.0 0x4d
1672  // descriptor_length 8 1.0
1673 
1674  // ISO_639_language_code 24 2.0
1675  int LanguageKey(void) const
1676  { return iso639_str3_to_key(&m_data[2]); }
1677  QString LanguageString(void) const
1678  { return iso639_key_to_str3(LanguageKey()); }
1679  int CanonicalLanguageKey(void) const
1681  QString CanonicalLanguageString(void) const
1683  // event_name_length 8 5.0
1684  uint EventNameLength(void) const { return m_data[5]; }
1685  // for (i=0;i<event_name_length;i++) { event_name_char 8 }
1686  QString EventName(void) const
1687  { return dvb_decode_text(&m_data[6], m_data[5]); }
1688  QString EventShortName(void) const
1689  { return dvb_decode_short_name(&m_data[6], m_data[5]); }
1690  // text_length 8
1691  uint TextLength(void) const { return m_data[6 + m_data[5]]; }
1692  // for (i=0;i<text_length;i++) { text_char 8 }
1693  QString Text(void) const
1694  { return dvb_decode_text(&m_data[7 + m_data[5]], TextLength()); }
1695 
1696  // HACK beg -- Pro7Sat is missing encoding
1697  QString EventName(const unsigned char *encoding_override,
1698  uint encoding_length) const
1699  {
1700  return dvb_decode_text(&m_data[6], m_data[5],
1701  encoding_override, encoding_length);
1702  }
1703 
1704  QString Text(const unsigned char *encoding_override,
1705  uint encoding_length) const
1706  {
1707  return dvb_decode_text(&m_data[7 + m_data[5]], TextLength(),
1708  encoding_override, encoding_length);
1709  }
1710  // HACK end -- Pro7Sat is missing encoding
1711 
1712  QString toString(void) const override // MPEGDescriptor
1713  { return LanguageString() + " : " + EventName() + " : " + Text(); }
1714 };
1715 
1716 // DVB Bluebook A038 (Sept 2011) p 84
1718 {
1719  public:
1720  explicit ShortSmoothingBufferDescriptor(const unsigned char *data, int len = 300) :
1721  MPEGDescriptor(data, len, DescriptorID::short_smoothing_buffer) { }
1722  // Name bits loc expected value
1723  // descriptor_tag 8 0.0 0x61
1724  // descriptor_length 8 1.0
1725 
1726  // sb_size 2 2.0
1727  // sb_leak_rate 6 2.2
1728  // for (i=0; i<N; i++)
1729  // { DVB_reserved 8 }
1730 };
1731 
1732 // DVB Bluebook A038 (Sept 2011) p 85
1736 {
1737  public:
1738  explicit StreamIdentifierDescriptor(const unsigned char *data, int len = 300) :
1739  MPEGDescriptor(data, len, DescriptorID::stream_identifier, 1) { }
1740  // Name bits loc expected value
1741  // descriptor_tag 8 0.0 0x52
1742  // descriptor_length 8 1.0 0x01
1743 
1744  // component_tag 8 2.0
1745  uint ComponentTag(void) const { return m_data[2]; }
1746  QString toString(void) const override // MPEGDescriptor
1747  {
1748  return QString("Stream Identifier Descriptor (0x52): ComponentTag=0x%1")
1749  .arg(ComponentTag(),1,16);
1750  }
1751 };
1752 
1753 // DVB Bluebook A038 (Sept 2011) p 86
1755 {
1756  public:
1757  explicit StuffingDescriptor(const unsigned char *data, int len = 300) :
1758  MPEGDescriptor(data, len, DescriptorID::dvb_stuffing) { }
1759  // Name bits loc expected value
1760  // descriptor_tag 8 0.0 0x42
1761  // descriptor_length 8 1.0
1762  // stuffing_byte * 2.0
1763  QString toString(void) const override // MPEGDescriptor
1764  {
1765  return QString("Stuffing Descriptor (0x42) length(%1)")
1766  .arg(DescriptorLength());
1767  }
1768 };
1769 
1770 // DVB Bluebook A038 (Sept 2011) p 86
1772 {
1773  public:
1774  explicit SubtitlingDescriptor(const unsigned char *data, int len = 300) :
1775  MPEGDescriptor(data, len, DescriptorID::subtitling) { }
1776  // Name bits loc expected value
1777  // descriptor_tag 8 0.0 0x59
1778  // descriptor_length 8 1.0
1779 
1780  uint StreamCount(void) const { return DescriptorLength() >> 3; }
1781  // for (i= 0;i<N;I++)
1782  // {
1783  // ISO_639_language_code 24 0.0+(i*8)
1784  int LanguageKey(uint i) const
1785  { return iso639_str3_to_key(&m_data[2 + (i<<3)]); }
1786  QString LanguageString(uint i) const
1787  { return iso639_key_to_str3(LanguageKey(i)); }
1792 
1793  // subtitling_type 8 3.0+(i*8)
1795  { return m_data[5 + (i<<3)]; }
1796  // composition_page_id 16 4.0+(i*8)
1798  { return (m_data[6 + (i<<3)] << 8) | m_data[7 + (i<<3)]; }
1799  // ancillary_page_id 16 6.0+(i*8)
1801  { return (m_data[8 + (i<<3)] << 8) | m_data[9 + (i<<3)]; }
1802  // } 8.0
1803 };
1804 
1805 // DVB Bluebook A038 (Sept 2011) p 87
1807 {
1808  public:
1809  explicit TelephoneDescriptor(const unsigned char *data, int len = 300) :
1810  MPEGDescriptor(data, len, DescriptorID::telephone) { }
1811  // Name bits loc expected value
1812  // descriptor_tag 8 0.0 0x57
1813  // descriptor_length 8 1.0
1814 
1815  // reserved_future_use 2 2.0
1816  // foreign_availability 1 2.2
1817  // connection_type 5 2.3
1818  // reserved_future_use 1 3.0
1819  // country_prefix_length 2 3.1
1820  // i18n_area_code_len 3 3.4
1821  // operator_code_length 2 3.6
1822  // reserved_future_use 1 3.7
1823  // national_area_code_len 3 4.0
1824  // core_number_length 4 4.4
1825  //
1826  // for (i=0; i<N; i++)
1827  // { country_prefix_char 8 }
1828  // for (i=0; i<N; i++)
1829  // { international_area_code_char 8 }
1830  // for (i=0; i<N; i++)
1831  // { operator_code_char 8 }
1832  // for (i=0; i<N; i++)
1833  // { national_area_code_char 8 }
1834  // for (i=0; i<N; i++)
1835  // { core_number_char 8 }
1836 };
1837 
1838 // DVB Bluebook A038 (Sept 2011) p 88
1840 {
1841  public:
1842  explicit TeletextDescriptor(const unsigned char *data, int len = 300) :
1843  MPEGDescriptor(data, len, DescriptorID::teletext) { }
1844  // Name bits loc expected value
1845  // descriptor_tag 8 0.0 0x56
1846  // descriptor_length 8 1.0
1847 
1848  uint StreamCount(void) const { return DescriptorLength() / 5; }
1849 
1850  // for (i=0; i<N; i++)
1851  // {
1852  // ISO_639_language_code 24 0.0
1853  int LanguageKey(uint i) const
1854  { return iso639_str3_to_key(&m_data[2 + (i*5)]); }
1855  QString LanguageString(uint i) const
1856  { return iso639_key_to_str3(LanguageKey(i)); }
1861  // teletext_type 5 3.0
1863  { return m_data[5 + (i*5)] >> 3; }
1864  // teletext_magazine_num 3 3.5
1866  { return m_data[5 + (i*5)] & 0x7; }
1867  // teletext_page_num 8 4.0
1869  { return m_data[6 + (i*5)]; }
1870  // } 5.0
1871  QString toString(void) const override; // MPEGDescriptor
1872 };
1873 
1874 // DVB Bluebook A038 (Sept 2011) p 89
1876 {
1877  public:
1878  explicit TimeShiftedEventDescriptor(const unsigned char *data, int len = 300) :
1879  MPEGDescriptor(data, len, DescriptorID::time_shifted_event) { }
1880  // Name bits loc expected value
1881  // descriptor_tag 8 0.0 0x4f
1882  // descriptor_length 8 1.0
1883 
1884  // reference_service_id 16 2.0
1885  // reference_event_id 16 4.0
1886 };
1887 
1888 // DVB Bluebook A038 (Sept 2011) p 90
1890 {
1891  public:
1892  explicit TimeShiftedServiceDescriptor(const unsigned char *data, int len = 300) :
1893  MPEGDescriptor(data, len, DescriptorID::dvb_time_shifted_service) { }
1894  // Name bits loc expected value
1895  // descriptor_tag 8 0.0 0x4c
1896  // descriptor_length 8 1.0
1897 
1898  // reference_service_id 16 2.0
1899 };
1900 
1901 // DVB Bluebook A038 (Sept 2011) p 90
1903 {
1904  public:
1905  explicit TransportStreamDescriptor(const unsigned char *data, int len = 300) :
1906  MPEGDescriptor(data, len, DescriptorID::transport_stream) { }
1907  // Name bits loc expected value
1908  // descriptor_tag 8 0.0 0x67
1909  // descriptor_length 8 1.0
1910 
1911  // for (i=0; i<N; i++) { byte 8 }
1912  QString Data(void) const
1913  { return dvb_decode_text(&m_data[2], DescriptorLength()); }
1914  QString toString(void) const override // MPEGDescriptor
1915  { return QString("TransportStreamDescriptor data(%1)").arg(Data()); }
1916 };
1917 
1918 // DVB Bluebook A038 (Sept 2011) p 91
1920 {
1921  public:
1922  explicit VBIDataDescriptor(const unsigned char *data, int len = 300) :
1923  MPEGDescriptor(data, len, DescriptorID::vbi_data) { }
1924  // Name bits loc expected value
1925  // descriptor_tag 8 0.0 0x45
1926  // descriptor_length 8 1.0
1927 
1928  // for (i=0; i<N; i++)
1929  // {
1930  // data_service_id 8 0.0+p
1931  // data_service_length 8 1.0+p
1932  // if ((data_service_id&0x7) && data_service_id!=0x3))
1933  // {
1934  // for (i=0; i<N; i++)
1935  // {
1936  // reserved 2 2.0+p2
1937  // field_parity 1 2.2+p2
1938  // line_offset 5 2.3+p2
1939  // }
1940  // }
1941  // else
1942  // {
1943  // for (i=0; i<N; i++) { reserved 8 }
1944  // }
1945  // }
1946 };
1947 
1948 // DVB Bluebook A038 (Sept 2011) p 92
1950 {
1951  public:
1952  explicit VBITeletextDescriptor(const unsigned char *data, int len = 300) :
1953  MPEGDescriptor(data, len, DescriptorID::vbi_teletext) { }
1954  // Name bits loc expected value
1955  // descriptor_tag 8 0.0 0x46
1956  // descriptor_length 8 1.0
1957 
1958  // for (i=0;i<N;i++)
1959  // {
1960  // ISO_639_language_code 24 0.0+p
1961  // teletext_type 5 3.0+p
1962  // teletext_magazine_num 3 3.5+p
1963  // teletext_page_num 8 4.0+p
1964  // } 5.0
1965 };
1966 
1967 // DVB Bluebook A038 (Sept 2011) p 119
1969 {
1970  public:
1971  explicit PartialTransportStreamDescriptor(const unsigned char *data, int len = 300) :
1972  MPEGDescriptor(data, len, DescriptorID::partial_transport_stream) { }
1973  // Name bits loc expected value
1974  // descriptor_tag 8 0.0 0x63
1975  // descriptor_length 8 1.0
1976 
1977  // DVB_reserved_future_use 2 2.0
1978  // peak_rate 22 2.2
1979  uint PeakRate(void) const
1980  { return (m_data[2] & 0x3f) << 16 | m_data[3] | m_data[4]; }
1981  // DVB_reserved_future_use 2 5.0
1982  // min_overall_smooth_rate 22 5.2
1983  uint SmoothRate(void) const
1984  { return (m_data[5] & 0x3f) << 16 | m_data[6] | m_data[7]; }
1985  // DVB_reserved_future_use 2 8.0
1986  // max_overall_smooth_buf 14 8.2
1987  uint SmoothBuf(void) const { return ((m_data[8] & 0x3f) << 8) | m_data[9]; }
1988  QString toString(void) const override; // MPEGDescriptor
1989 };
1990 
1991 
1992 // a_52a.pdf p125 Table A7 (for DVB)
1994 {
1995  public:
1996  explicit AC3Descriptor(const unsigned char *data, int len = 300) :
1997  MPEGDescriptor(data, len, DescriptorID::ac3) { }
1998  // Name bits loc expected value
1999  // descriptor_tag 8 0.0 0x6A
2000  // descriptor_length 8 1.0
2001 
2002  // component_type_flag 1 2.0
2003  bool HasComponentType(void) const { return ( m_data[2] & 0x80 ) != 0; }
2004  // bsid_flag 1 2.1
2005  bool HasBSID(void) const { return ( m_data[2] & 0x40 ) != 0; }
2006  // mainid_flag 1 2.2
2007  bool HasMainID(void) const { return ( m_data[2] & 0x20 ) != 0; }
2008  // asvc_flag 1 2.3
2009  bool HasASVC(void) const { return ( m_data[2] & 0x10 ) != 0; }
2010  // reserved_flags 4 2.4
2011  // if (component_type_flag == 1)
2012  // { component_type 8 uimsbf }
2013  uint ComponentType(void) const { return m_data[3]; }
2014  // if (bsid_flag == 1)
2015  // { bsid 8 uimsbf }
2016  uint BSID(void) const
2017  { return (HasComponentType()) ? m_data[4] : m_data[3]; }
2018  // if (mainid_flag == 1)
2019  // { mainid 8 uimsbf }
2020  uint MainID(void) const
2021  {
2022  int offset = 3;
2023  offset += (HasComponentType()) ? 1 : 0;
2024  offset += (HasBSID()) ? 1 : 0;
2025  return m_data[offset];
2026  }
2027  // if (asvc_flag==1)
2028  // { asvc 8 uimsbf }
2029  uint ASVC(void) const
2030  {
2031  int offset = 3;
2032  offset += (HasComponentType()) ? 1 : 0;
2033  offset += (HasBSID()) ? 1 : 0;
2034  offset += (HasMainID()) ? 1 : 0;
2035  return m_data[offset];
2036  }
2037  // for (I=0;I<N;I++)
2038  // { additional_info[i] N*8 uimsbf }
2039  //};
2040  QString toString(void) const override; // MPEGDescriptor
2041 };
2042 
2043 static QString coderate_inner(uint coderate)
2044 {
2045  switch (coderate)
2046  {
2047  case 0x0: return "auto"; // not actually defined in spec
2048  case 0x1: return "1/2";
2049  case 0x2: return "2/3";
2050  case 0x3: return "3/4";
2051  case 0x4: return "5/6";
2052  case 0x5: return "7/8";
2053  case 0x8: return "8/9";
2054  case 0xf: return "none";
2055  default: return "auto"; // not actually defined in spec
2056  }
2057 }
2058 
2068 {
2069  public:
2070  explicit DVBLogicalChannelDescriptor(const unsigned char *data, int len = 300) :
2071  MPEGDescriptor(data, len, PrivateDescriptorID::dvb_logical_channel_descriptor) { }
2072  // Name bits loc expected value
2073  // descriptor_tag 8 0.0 0x83
2074  // descriptor_length 8 1.0
2075 
2076  uint ChannelCount(void) const { return DescriptorLength() >> 2; }
2077 
2079  { return (m_data[2 + (i<<2)] << 8) | m_data[3 + (i<<2)]; }
2080 
2082  { return ((m_data[4 + (i<<2)] << 8) | m_data[5 + (i<<2)]) & 0x3ff; }
2083 
2084  QString toString(void) const override; // MPEGDescriptor
2085 };
2086 
2096 {
2097  public:
2098  explicit DVBSimulcastChannelDescriptor(const unsigned char *data, int len = 300) :
2099  MPEGDescriptor(data, len, PrivateDescriptorID::dvb_simulcast_channel_descriptor) { }
2100  // Name bits loc expected value
2101  // descriptor_tag 8 0.0 0x88
2102  // descriptor_length 8 1.0
2103 
2104  uint ChannelCount(void) const { return DescriptorLength() >> 2; }
2105 
2107  { return (m_data[2 + (i<<2)] << 8) | m_data[3 + (i<<2)]; }
2108 
2110  { return ((m_data[4 + (i<<2)] << 8) | m_data[5 + (i<<2)]) & 0x3ff; }
2111 
2112  QString toString(void) const override; // MPEGDescriptor
2113 };
2114 
2126 {
2127  public:
2128  explicit FreesatLCNDescriptor(const unsigned char *data, int len = 300) :
2129  MPEGDescriptor(data, len, PrivateDescriptorID::freesat_lcn_table)
2130  {
2132 
2133  const unsigned char *payload = &data[2];
2134 
2135  uint offset = 0;
2136  while ((offset + 5 < DescriptorLength()) &&
2137  (offset + 5 + payload[offset+4] <= DescriptorLength()))
2138  {
2139  m_entries.push_back(&payload[offset]);
2140  offset += 5 + payload[offset+4];
2141  }
2142  }
2143  // Name bits loc expected value
2144  // descriptor_tag 8 0.0 0xd3
2145  // descriptor_length 8 1.0
2146  // for (i=0;i<N;i++) {
2147  // service_id 16 0.0+p
2148  // chan_id 15 2.1+p
2149  // length 8 4.0+p
2150  // for (j=0;j<N;j++) {
2151  // unknown 4 0.0+p2
2152  // logical_channel_number 12 0.4+p2
2153  // region_id 16 2.0+p2
2154  // }
2155  // }
2156 
2157  uint ServiceCount(void) const
2158  { return m_entries.size(); }
2159 
2160  uint ServiceID(int i) const
2161  { return *m_entries[i] << 8 | *(m_entries[i]+1); }
2162 
2163  uint ChanID(int i) const
2164  { return (*(m_entries[i] + 2) << 8 | *(m_entries[i] + 3)) & 0x7FFF; }
2165 
2166  uint LCNCount(int i) const
2167  { return *(m_entries[i] + 4) / 4; }
2168 
2169  uint LogicalChannelNumber(int i, int j) const
2170  { return (*(m_entries[i] + 5 + j*4) << 8 | *(m_entries[i] + 5 + j*4 + 1)) & 0xFFF; }
2171 
2172  uint RegionID(int i, int j) const
2173  { return *(m_entries[i] + 5 + j*4 + 2) << 8 | *(m_entries[i] + 5 + j*4 + 3); }
2174 
2175  QString toString(void) const override; // MPEGDescriptor
2176 
2177  private:
2179 };
2180 
2191 {
2192  public:
2193  explicit FreesatRegionDescriptor(const unsigned char *data, int len = 300) :
2194  MPEGDescriptor(data, len, PrivateDescriptorID::freesat_region_table)
2195  {
2197 
2198  const unsigned char *payload = &data[2];
2199 
2200  uint offset = 0;
2201  while ((offset + 6 < DescriptorLength()) &&
2202  (offset + 6 + payload[offset+5] <= DescriptorLength()))
2203  {
2204  m_entries.push_back(&payload[offset]);
2205  offset += 6 + payload[offset+5];
2206  }
2207  }
2208  // Name bits loc expected value
2209  // descriptor_tag 8 0.0 0xd4
2210  // descriptor_length 8 1.0
2211  // for (i=0;i<N;i++) {
2212  // region_id 16 0.0+p
2213  // language_code 24 2.0+p eng
2214  // text_length 8 5.0+p
2215  // for (j=0;j<N;j++) {
2216  // text_char 8
2217  // }
2218  // }
2219 
2220  uint RegionCount(void) const
2221  { return m_entries.size(); }
2222 
2223  int RegionID(uint i) const
2224  { return *m_entries[i] << 8 | *(m_entries[i]+1); }
2225 
2226  QString Language(uint i) const
2227  { return QString::fromLatin1((char *) m_entries[i] + 2, 3); }
2228 
2229  QString RegionName(uint i) const
2230  { return QString::fromLatin1((char *) m_entries[i] + 6, *(m_entries[i] + 5)); }
2231 
2232  QString toString(void) const override; // MPEGDescriptor
2233 
2234  private:
2236 };
2237 
2246 {
2247  public:
2248  explicit FreesatCallsignDescriptor(const unsigned char *data, int len = 300) :
2249  MPEGDescriptor(data, len, PrivateDescriptorID::freesat_callsign)
2250  {
2252  }
2253 
2254  // Name bits loc expected value
2255  // descriptor_tag 8 0.0 0xd8
2256  // descriptor_length 8 1.0
2257 
2258  // ISO_639_language_code 24 2.0
2259  // callsign_length 8 5.0
2260  // for (j=0;j<N;j++) {
2261  // callsign_char 8
2262 
2263  QString Language(void) const
2264  { return QString::fromLatin1((char *) m_data +2, 3); }
2265 
2266  QString Callsign(void) const
2267  { return dvb_decode_short_name(&m_data[6], m_data[5]); }
2268 
2269  QString toString(void) const override; // MPEGDescriptor
2270 };
2271 
2284 {
2285  public:
2286  explicit SkyLCNDescriptor(const unsigned char *data, int len = 300) :
2287  MPEGDescriptor(data, len, PrivateDescriptorID::sky_lcn_table)
2288  {
2290  }
2291  // Name bits loc expected value
2292  // descriptor_tag 8 0.0 0xd3
2293  // descriptor_length 8 1.0
2294  // region_id 16 2.0
2295  // for (i=0;i<N;i++) {
2296  // service_id 16 0.0+p
2297  // service_type 8 2.0+p
2298  // unknown 16 3.0+p
2299  // logical_channel_number 16 5.0+p2
2300  // unknown 16 7.0+p2
2301  // }
2302 
2303  uint RegionID(void) const
2304  { return (*(m_data + 3) != 0xFF) ? *(m_data + 3) : 0xFFFF;}
2305 
2306  uint RegionRaw(void) const
2307  { return *(m_data + 2) << 8 | *(m_data + 3);}
2308 
2309  uint ServiceCount(void) const
2310  { return (DescriptorLength() - 2) / 9; }
2311 
2312  uint ServiceID(int i) const
2313  { return *(m_data + 4 + i*9) << 8 | *(m_data + 5 + i*9); }
2314 
2315  uint ServiceType(int i) const
2316  { return *(m_data + 6 + i*9); }
2317 
2318  uint ChannelID(int i) const
2319  { return *(m_data + 7 + i*9) << 8 | *(m_data + 8 + i*9); }
2320 
2322  { return *(m_data + 9 + i*9) << 8 | *(m_data + 10 + i*9); }
2323 
2324  uint Flags(int i) const
2325  { return *(m_data + 11 + i*9) << 8 | *(m_data + 12 + i*9); }
2326 
2327  QString toString(void) const override; // MPEGDescriptor
2328 };
2329 
2330 // Descriptor layout similar to SkyLCNDescriptor
2332 {
2333  public:
2334  OpenTVChannelListDescriptor(const unsigned char *data, int len = 300) :
2335  MPEGDescriptor(data, len, PrivateDescriptorID::opentv_channel_list) { }
2336  // Name bits loc expected value
2337  // descriptor_tag 8 0.0 0xB1
2338  // descriptor_length 8 1.0
2339 
2340  uint ChannelCount(void) const { return (DescriptorLength() - 2)/9; }
2341 
2342  uint RegionID() const
2343  { return (m_data[2] << 8) | m_data[3]; }
2344 
2346  { return (m_data[4 + 0 + (i*9)] << 8) | m_data[4 + 1 + (i*9)]; }
2347 
2349  { return m_data[4 + 2 + (i*9)]; }
2350 
2352  { return ((m_data[4 + 3 + (i*9)] << 8) | m_data[4 + 4 + (i*9)]); }
2353 
2355  { return ((m_data[4 + 5 + (i*9)] << 8) | m_data[4 + 6 + (i*9)]); }
2356 
2357  uint Flags(uint i) const
2358  { return ((m_data[4 + 7 + (i*9)] << 8) | m_data[4 + 8 + (i*9)]) & 0xf; }
2359 
2360  QString toString(void) const override; // MPEGDescriptor
2361 };
2362 
2363 // ETSI TS 102 323 (TV Anytime)
2365 {
2366  public:
2367  explicit DVBContentIdentifierDescriptor(const unsigned char *data, int len = 300) :
2368  MPEGDescriptor(data, len, DescriptorID::dvb_content_identifier)
2369  {
2370  size_t count = 0;
2371 
2372  memset ((void *) m_crid, 0, sizeof(m_crid));
2373 
2374  if (IsValid())
2375  {
2376  uint8_t position = 2;
2377  while (m_data[1] >= position)
2378  {
2379  size_t length = m_data[position+1];
2380  m_crid[count] = &m_data[position];
2381  count++;
2382  position+=length+2;
2383  }
2384  }
2385  m_cridCount = count;
2386  }
2387  // Name bits loc expected value
2388  // descriptor_tag 8 0.0 0x76
2389  // descriptor_length 8 1.0
2390 
2391  uint ContentType(size_t n=0) const { return m_crid[n][0] >> 2; }
2392 
2393  uint ContentEncoding(size_t n=0) const { return m_crid[n][0] & 0x03; }
2394 
2395  // A content identifier is a URI. It may contain UTF-8 encoded using %XX.
2396  QString ContentId(size_t n=0) const
2397  {
2398  int length = m_crid[n][1];
2399  int positionOfHash = length-1;
2400  while (positionOfHash >= 0) {
2401  if (m_crid[n][2 + positionOfHash] == '#') {
2402  length = positionOfHash; /* remove the hash and the following IMI */
2403  break;
2404  }
2405  positionOfHash--;
2406  }
2407  return QString::fromLatin1((const char *)&m_crid[n][2], length);
2408  }
2409 
2410  size_t CRIDCount() const
2411  {
2412  return m_cridCount;
2413  }
2414 
2415  private:
2416  size_t m_cridCount;
2417  const uint8_t *m_crid[8] {};
2418 };
2419 
2420 // ETSI TS 102 323 (TV Anytime)
2422 {
2423  public:
2424  explicit DefaultAuthorityDescriptor(const unsigned char *data, int len = 300) :
2425  MPEGDescriptor(data, len, DescriptorID::default_authority) { }
2426  // Name bits loc expected value
2427  // descriptor_tag 8 0.0 0x73
2428  // descriptor_length 8 1.0
2429 
2430  QString DefaultAuthority(void) const
2431  {
2432  return QString::fromLatin1((const char *)m_data+2, m_data[1]);
2433  }
2434 
2435  QString toString(void) const override // MPEGDescriptor
2436  {
2437  return QString("DefaultAuthorityDescriptor: Authority(%1)")
2438  .arg(DefaultAuthority());
2439  }
2440 };
2441 
2442 /*
2443  * private UPC Cablecom (Austria) episode descriptor for Horizon middleware
2444  */
2446 {
2447  public:
2448  explicit PrivateUPCCablecomEpisodeTitleDescriptor(const unsigned char *data, int len = 300) :
2449  MPEGDescriptor(data, len, PrivateDescriptorID::upc_event_episode_title) { }
2450  // Name bits loc expected value
2451  // descriptor_tag 8 0.0 0xa7
2452  // descriptor_length 8 1.0
2453 
2454  // ISO_639_language_code 24 2.0
2455  int LanguageKey(void) const
2456  {
2457  return iso639_str3_to_key(&m_data[2]);
2458  }
2459  QString LanguageString(void) const
2460  {
2461  return iso639_key_to_str3(LanguageKey());
2462  }
2463  int CanonicalLanguageKey(void) const
2464  {
2466  }
2467  QString CanonicalLanguageString(void) const
2468  {
2470  }
2471 
2472  uint TextLength(void) const
2473  {
2474  return m_data[1] - 3;
2475  }
2476 
2477  QString Text(void) const
2478  {
2479  return dvb_decode_text(&m_data[5], TextLength());
2480  }
2481 };
2482 
2483 #endif
uint ChanID(int i) const
QString toString(void) const override
int CanonicalLanguageKey(void) const
bool IsTargetListed(void) const
bool HasASVC(void) const
uint Count(void) const
CellFrequencyLinkDescriptor(const unsigned char *data, int len=300)
ProgramInfo::CategoryType GetMythCategory(uint i) const
QMap< QString, QString > Items(void) const
QString BouquetName(void) const
QString RegionName(uint i) const
ContentDescriptor(const unsigned char *data, int len=300)
DVB HD Simulcast Logical Channel Descriptor.
uint AncillaryPageID(uint i) const
MultilingualServiceNameDescriptor(const unsigned char *data, int len=300)
PrivateDataSpecifierDescriptor(const unsigned char *data, int len=300)
DVBLogicalChannelDescriptor(const unsigned char *data, int len=300)
QString dvb_decode_text(const unsigned char *src, uint length, const unsigned char *encoding_override, uint encoding_override_length)
int Rating(uint i) const
PDCDescriptor(const unsigned char *data, int len=300)
QString LanguageString(uint i) const
CAIdentifierDescriptor(const unsigned char *data, int len=300)
QString toString(void) const override
NVODReferenceDescriptor(const unsigned char *data, int len=300)
MultilingualBouquetNameDescriptor(const unsigned char *data, int len=300)
uint ServiceNameLength(void) const
DVBSimulcastChannelDescriptor(const unsigned char *data, int len=300)
BouquetNameDescriptor(const unsigned char *data, int len=300)
QString toString(void) const override
QString EventName(void) const
SkyLCNDescriptor(const unsigned char *data, int len=300)
QString LanguageString(void) const
ShortEventDescriptor(const unsigned char *data, int len=300)
bool IsDTV(void) const
bool HasMobileNetworkID(void) const
unsigned char AVCProperties(void) const
bool HasComponentType(void) const
unsigned long long FrequencyHz(uint i) const
int LanguageKey(void) const
QString ServiceProviderName(void) const
unsigned char SubtitleType(void) const
static QMutex s_categoryLock
Freesat Region descriptor.
ScramblingDescriptor(const unsigned char *data, int len=300)
QString BouquetShortName(void) const
int LanguageKey(void) const
QString toString(void) const override
uint ProgramIdLabel(void) const
unsigned long long Frequency(uint i) const
unsigned char AC3Properties(void) const
QString toString(void) const override
uint ChannelID(int i) const
uint ServiceCount(void) const
int CASystemId(uint i) const
uint SubtitleType(uint i) const
uint UserNibble(uint i) const
uint DataBroadCastId(void) const
QString MobileOriginTypeString(void) const
QString Text(const unsigned char *encoding_override, uint encoding_length) const
uint ComponentTag(void) const
int CanonicalLanguageKey(void) const
CellListDescriptor(const unsigned char *data, int len=300)
uint ComponentType(void) const
TeletextDescriptor(const unsigned char *data, int len=300)
unsigned char MPEG2Properties(void) const
This is used to label streams so the can be treated differently, for instance each stream may get it'...
QString LanguageString(void) const
DefaultAuthorityDescriptor(const unsigned char *data, int len=300)
QString CountryNames(void) const
bool IsUHDTV(void) const
QString toString(void) const override
QString FECInnerString(void) const
uint DescriptorTag(void) const
DVB Logical Channel Descriptor.
QString ContentId(size_t n=0) const
uint OrbitalPosition(void) const
orbital_position 16 6.0
QString EventName(const unsigned char *encoding_override, uint encoding_length) const
uint ServiceId(uint i) const
bool
Definition: pxsup2dast.c:30
QString Name(void) const
DSNGDescriptor(const unsigned char *data, int len=300)
ComponentDescriptor(const unsigned char *data, int len=300)
uint RegionID(void) const
unsigned char VideoProperties(void) const
uint PrivateDataLength(void) const
ServiceDescriptor(const unsigned char *data, int len=300)
PartialTransportStreamDescriptor(const unsigned char *data, int len=300)
QString toString(void) const override
static int iso639_str3_to_key(const unsigned char *iso639_2)
Definition: iso639.h:63
bool IsVerticalRightPolarization(void) const
const unsigned char * PrivateData(void) const
unsigned char MP2Properties(void) const
uint ServiceID(uint i) const
uint ChannelType(uint i) const
QString toString(void) const override
uint ScramblingMode(void) const
int iso639_key_to_canonical_key(int iso639_2)
Definition: iso639.cpp:120
ServiceDescriptorMapping(const uint service_type)
AnnouncementSupportDescriptor(const unsigned char *data, int len=300)
uint ServiceType(uint i) const
bool IsSubtitle(void) const
QString toString(void) const override
CountryAvailabilityDescriptor(const unsigned char *data, int len=300)
uint ServiceID(uint i) const
TimeShiftedServiceDescriptor(const unsigned char *data, int len=300)
uint MainID(void) const
Freesat Channel Callsign descriptor.
uint CountryRegionId(uint i) const
QString Data(void) const
ServiceMoveDescriptor(const unsigned char *data, int len=300)
uint ServiceID(void) const
#define byte4BCD2int(i, j, k, l)
vector< const unsigned char * > desc_list_t
uint ServiceCount(void) const
StuffingDescriptor(const unsigned char *data, int len=300)
QString Text(void) const
uint StreamCount(void) const
uint TransportStreamId(uint i) const
VBIDataDescriptor(const unsigned char *data, int len=300)
uint ChannelNumber(uint i) const
uint LogicalChannelNumber(int i, int j) const
QString ServiceProviderShortName(void) const
uint ASVC(void) const
const unsigned char * m_data
uint DescriptorNumber(void) const
QString toString(void) const override
uint ChannelID(uint i) const
uint RegionCount(void) const
QString toString(void) const override
QString toString(void) const override
SubtitlingDescriptor(const unsigned char *data, int len=300)
TerrestrialDeliverySystemDescriptor(const unsigned char *data, int len=300)
FreesatRegionDescriptor(const unsigned char *data, int len=300)
uint StreamCount(void) const
int LanguageKey(void) const
LocalTimeOffsetDescriptor(const unsigned char *data, int len=300)
static void Init(void)
uint Count(void) const
static int x2
Definition: mythsocket.cpp:61
uint TeletextType(uint i) const
bool IsTeletext(void) const
#define byte3BCD2int(i, j, k)
QString toString(void) const override
uint RegionRaw(void) const
QString toString(void) const override
QString Text(void) const
DVBContentIdentifierDescriptor(const unsigned char *data, int len=300)
uint ChannelNumber(uint i) const
bool IsVideo(void) const
FreesatLCNDescriptor(const unsigned char *data, int len=300)
uint SelectorLength(void) const
uint TextLength(void) const
QString toString(void) const
uint LengthOfItems(void) const
uint Flags(int i) const
MosaicDescriptor(const unsigned char *data, int len=300)
uint MobileNetworkID(void) const
static QString coderate_inner(uint coderate)
PrivateUPCCablecomEpisodeTitleDescriptor(const unsigned char *data, int len=300)
FreesatCallsignDescriptor(const unsigned char *data, int len=300)
VBITeletextDescriptor(const unsigned char *data, int len=300)
QString toString(void) const override
QString toString(void) const override
QString ModulationString(void) const
Freesat Logical Channel Number descriptor.
uint NextTimeOffset(uint i) const
DataBroadcastDescriptor(const unsigned char *data, int len=300)
AC3Descriptor(const unsigned char *data, int len=300)
QString ConstellationString(void) const
QString toString(void) const override
uint ServiceType(int i) const
uint EventNameLength(void) const
uint TSID(void) const
ExtendedEventDescriptor(const unsigned char *data, int len=300)
bool IsDigitalAudio(void) const
unsigned int uint
Definition: compat.h:140
bool IsHorizontalLeftPolarization(void) const
uint TextLength(void) const
uint TeletextPageNum(uint i) const
int LocalTimeOffsetWithPolarity(uint i) const
uint MobileInitialServiceID(void) const
int LanguageKey(uint i) const
FrequencyListDescriptor(const unsigned char *data, int len=300)
QString GetDescription(uint i) const
uint UserNibble1(uint i) const
bool HasBSID(void) const
MultilingualNetworkNameDescriptor(const unsigned char *data, int len=300)
QString Callsign(void) const
uint ComponentTag(void) const
uint DataBroadcastId(void) const
AncillaryDataDescriptor(const unsigned char *data, int len=300)
QString CanonicalLanguageString(uint i) const
uint ServiceType(void) const
QString Language(uint i) const
QString ServiceShortName(void) const
bool IsDigitalAudio(void) const
int LanguageKey(uint i) const
static volatile bool s_categoryDescExists
TimeShiftedEventDescriptor(const unsigned char *data, int len=300)
uint DescriptorLength(void) const
#define byteBCDH2int(i)
uint ServiceID(int i) const
QString Language(void) const
QString toString(void) const override
QString CountryCodeString(uint i) const
bool IsEast(void) const
west_east_flag 1 8.0
#define byte2BCD2int(i, j)
AdaptationFieldDataDescriptor(const unsigned char *data, int len=300)
QString DefaultAuthority(void) const
uint Nibble2(uint i) const
ShortSmoothingBufferDescriptor(const unsigned char *data, int len=300)
QString CanonicalLanguageString(void) const
SatelliteDeliverySystemDescriptor(const unsigned char *data, int len=300)
QString toString(void) const override
QString toString(void) const override
QString Text(void) const
QString toString(void) const override
bool IsTeletext(void) const
uint TargetEventID(void) const
static QMap< uint, QString > s_categoryDesc
uint TeletextMagazineNum(uint i) const
uint OriginalNetworkId(uint i) const
static int x5
Definition: mythsocket.cpp:64
uint AncillaryDataID(void) const
QString EventShortName(void) const
bool LocalTimeOffsetPolarity(uint i) const
-1 if true, +1 if false (behind utc, ahead of utc, resp).
uint32_t PrivateDataSpecifier(void) const
bool IsEventSimulcast(void) const
uint CompositionPageID(uint i) const
NetworkNameDescriptor(const unsigned char *data, int len=300)
uint TextLength(void) const
uint RegionID(int i, int j) const
#define assert(x)
QString toString(void) const override
QString toString(void) const override
bool HasMobileInitialServiceID(void) const
QString TransmissionModeString(void) const
QString MobileHandOverTypeString(void) const
uint LastNumber(void) const
QString toString(void) const override
uint OriginalNetworkID() const
QString toString(void) const override
QString FECOuterString(void) const
QString LanguageString(void) const
QString toString(void) const override
QString toString(void) const override
uint ContentType(size_t n=0) const
QString FECInnerString(void) const
uint Nibble(uint i) const
TransportStreamDescriptor(const unsigned char *data, int len=300)
unsigned long long FrequencyHz(void) const
uint UserNibble2(uint i) const
bool HasMainID(void) const
QString LinkageTypeString(void) const
int CanonicalLanguageKey(void) const
uint ServiceID(int i) const
QString CountryCodeString(uint i) const
Sky Logical Channel Number descriptor.
QString ShortName(void) const
uint ServiceProviderNameLength(void) const
int CanonicalLanguageKey(uint i) const
int LanguageKey(void) const
QString CanonicalLanguageString(uint i) const
OpenTVChannelListDescriptor(const unsigned char *data, int len=300)
QString LanguageString(uint i) const
uint ContentEncoding(size_t n=0) const
QString ModulationSystemString(void) const
QString CanonicalLanguageString(void) const
QString toString(void) const override
static QString iso639_key_to_str3(int code)
Definition: iso639.h:46
uint MobileOriginType(void) const
QString toString(void) const override
uint LCNCount(int i) const
int RegionID(uint i) const
QString toString(void) const override
bool IsValid(void) const
const unsigned char * Selector(void) const
bool IsAudio(void) const
QString CanonicalLanguageString(void) const
unsigned char HEVCProperties(void) const
uint ServiceID(uint i) const
QString dvb_decode_short_name(const unsigned char *src, uint raw_length)
unsigned long long FrequencykHz(void) const
uint BSID(void) const
DataBroadcastIdDescriptor(const unsigned char *data, int len=300)
int CanonicalLanguageKey(uint i) const
uint ServiceType(void) const
QString Text(const unsigned char *encoding_override, uint encoding_length) const
unsigned char HEAACProperties(void) const
QString ModulationString(void) const
TelephoneDescriptor(const unsigned char *data, int len=300)
uint ComponentType(void) const
uint StreamContent(void) const
uint DataComponentTag(void) const
ServiceAvailabilityDescriptor(const unsigned char *data, int len=300)
ServiceListDescriptor(const unsigned char *data, int len=300)
uint LogicalChannelNumber(int i) const
uint LinkageType(void) const
int CanonicalLanguageKey(void) const
QString toString(void) const override
uint ServiceCount(void) const
QString toString(void) const override
QString toString(void) const override
uint MobileHandOverType(void) const
uint ChannelNumber(uint i) const
static int x3
Definition: mythsocket.cpp:62
ParentalRatingDescriptor(const unsigned char *data, int len=300)
unsigned char AudioProperties(void) const
uint AdaptationFieldDataID(void) const
LinkageDescriptor(const unsigned char *data, int len=300)
uint CountryCode(uint i) const
uint CASystemCount(void) const
uint CodingType(void) const
QString OrbitalPositionString(void) const
uint LocalTimeOffset(uint i) const
uint Nibble1(uint i) const
QString CanonicalLanguageString(void) const
QString toString(void) const override
QString ServiceName(void) const
bool IsHDTV(void) const
static int x1
Definition: mythsocket.cpp:60
CableDeliverySystemDescriptor(const unsigned char *data, int len=300)
StreamIdentifierDescriptor(const unsigned char *data, int len=300)
QString LanguageString(void) const
uint FrequencyRaw(void) const
frequency 32 2.0