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  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(_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  LinkageDescriptor(const unsigned char *data, int len = 300) :
90  MPEGDescriptor(data, len, DescriptorID::linkage)
91  {
92  if (!_data)
93  return;
94  if (DescriptorLength() < 7)
95  {
96  _data = nullptr;
97  }
98  else if (kMobileHandOver == LinkageType())
99  {
100  uint end = 8;
101  if (DescriptorLength() < end)
102  {
103  _data = nullptr;
104  return;
105  }
106  end += (HasMobileNetworkID()) ? 2 : 0;
107  end += (HasMobileInitialServiceID()) ? 2 : 0;
108  if (DescriptorLength() < end)
109  _data = nullptr;
110  m_offset = end + 2;
111  }
112  else if (kEventLinkage == LinkageType())
113  {
114  if (DescriptorLength() < 10)
115  _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 (_data[2]<<8) | _data[3]; }
124  // original_network_id 16 4.0
125  uint OriginalNetworkID() const { return (_data[4]<<8) | _data[5]; }
126  // service_id 16 6.0
127  uint ServiceID(void) const { return (_data[6]<<8) | _data[7]; }
128  // linkage_type 8 8.0
129  enum
130  {
132  kEPGService = 0x02,
137  kRCSMap = 0x07,
144  };
145  uint LinkageType(void) const { return _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 _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 _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 (_data[10]<<8) | _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  ((_data[12]<<8) | _data[13]) : ((_data[10]<<8) | _data[11]);
182  }
183  // }
184  // if (linkage_type == 0x0D)
185  // {
186  // target_event_id 16 9.0
187  uint TargetEventID(void) const { return (_data[9]<<8) | _data[10]; }
188  // target_listed 1 11.0
189  bool IsTargetListed(void) const { return ( _data[11]&0x80 ) != 0; }
190  // event_simulcast 1 11.1
191  bool IsEventSimulcast(void) const { return ( _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 &_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  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 _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  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 _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  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  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(_data+2, _data[1]); }
280  QString BouquetShortName(void) const
281  { return dvb_decode_short_name(_data+2, _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  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 (_data[2 + i*2] << 8) | _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  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  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  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 _data[2] & 0xf; }
370  // component_type 8 3.0
371  uint ComponentType(void) const { return _data[3]; }
372  // component_tag 8 4.0
373  uint ComponentTag(void) const { return _data[4]; }
374  // ISO_639_language_code 24 5.0
375  int LanguageKey(void) const
376  { return iso639_str3_to_key(&_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  case 0x0: case 0x1:
460  case 0x2: case 0x3:
461  return VID_HDTV;
462  case 0x5:
463  return VID_HDTV; // | VID_UHDTV;
464  default:
465  return VID_UNKNOWN;
466  }
467  }
468 
469  unsigned char AudioProperties(void) const
470  {
471  switch (StreamContent())
472  {
473  case 0x2:
474  return MP2Properties();
475  case 0x04:
476  return AC3Properties();
477  case 0x06:
478  return HEAACProperties();
479  default:
480  return AUD_UNKNOWN;
481  }
482  }
483 
484  unsigned char MP2Properties(void) const
485  {
486  switch (ComponentType())
487  {
488  case 0x1:
489  return AUD_MONO;
490  case 0x3:
491  return AUD_STEREO;
492  case 0x5:
493  return AUD_SURROUND;
494  case 0x40:
495  return AUD_VISUALIMPAIR;
496  case 0x41:
497  return AUD_HARDHEAR;
498  default:
499  return AUD_UNKNOWN;
500  }
501  }
502 
503  unsigned char AC3Properties(void) const
504  {
505  unsigned char properties = AUD_UNKNOWN;
506 
507  switch (ComponentType() & 0x7)
508  {
509  case 0x0:
510  properties |= AUD_MONO;
511  break;
512  case 0x2:
513  properties |= AUD_STEREO;
514  break;
515  case 0x3:
516  properties |= AUD_DOLBY;
517  break;
518  case 0x4: case 0x5:
519  properties |= AUD_SURROUND;
520  break;
521  }
522 
523  if (((ComponentType() >> 3) & 0x7) == 0x2)
524  properties |= AUD_VISUALIMPAIR;
525 
526  if (((ComponentType() >> 3) & 0x7) == 0x3)
527  properties |= AUD_HARDHEAR;
528 
529  return properties;
530  }
531 
532  unsigned char HEAACProperties(void) const
533  {
534  switch (ComponentType())
535  {
536  case 0x1:
537  return AUD_MONO;
538  case 0x3:
539  case 0x43:
540  return AUD_STEREO;
541  case 0x5:
542  return AUD_SURROUND;
543  case 0x40:
544  case 0x44:
545  return AUD_VISUALIMPAIR;
546  case 0x41:
547  case 0x45:
548  return AUD_HARDHEAR;
549  default:
550  return AUD_UNKNOWN;
551  }
552  }
553 
554  unsigned char SubtitleType(void) const
555  {
556  if (!IsSubtitle())
557  return SUB_UNKNOWN;
558 
559  switch (ComponentType())
560  {
561  case 0x1:
562  case 0x3:
563  case 0x10: case 0x11: case 0x12: case 0x13:
564  return SUB_NORMAL;
565  case 0x20: case 0x21: case 0x22: case 0x23:
566  return SUB_HARDHEAR;
567  default:
568  return SUB_UNKNOWN;
569  }
570  }
571 
572  QString toString(void) const override // MPEGDescriptor
573  {
574  return QString("ComponentDescriptor(stream_content: 0x%1, "
575  "component_type: 0x%2)").arg(StreamContent(), 0, 16)
576  .arg(ComponentType(), 0, 16);
577  }
578 };
579 
580 // DVB Bluebook A038 (Sept 2011) p 46
582 {
583  public:
584  ContentDescriptor(const unsigned char *data, int len = 300) :
585  MPEGDescriptor(data, len, DescriptorID::content) { }
586  // Name bits loc expected value
587  // descriptor_tag 8 0.0 0x54
588  // descriptor_length 8 1.0
589 
590  uint Count(void) const { return DescriptorLength() >> 1; }
591  // for (i=0;i<N;i++)
592  // {
593  // content_nibble_level_1 4 0.0+p
594  uint Nibble1(uint i) const { return _data[2 + (i<<1)] >> 4; }
595  // content_nibble_level_2 4 0.4+p
596  uint Nibble2(uint i) const { return _data[2 + (i<<1)] & 0xf; }
597 
598  uint Nibble(uint i) const { return _data[2 + (i<<1)]; }
599 
600  // user_nibble 4 1.0+p
601  uint UserNibble1(uint i) const { return _data[3 + (i<<1)] >> 4; }
602  // user_nibble 4 1.4+p
603  uint UserNibble2(uint i) const { return _data[3 + (i<<1)] & 0xf; }
604  uint UserNibble(uint i) const { return _data[3 + (i<<1)]; }
605  // } 2.0
606 
608  QString GetDescription(uint i) const;
609  QString toString(void) const override; // MPEGDescriptor
610 
611  protected:
612  static void Init(void);
613 
614  protected:
615  static QMutex categoryLock;
616  static QMap<uint,QString> categoryDesc;
617  static volatile bool categoryDescExists;
618 };
619 
620 // DVB Bluebook A038 (Sept 2011) p 49
622 {
623  public:
624  CountryAvailabilityDescriptor(const unsigned char *data, int len = 300) :
625  MPEGDescriptor(data, len, DescriptorID::country_availability) { }
626  // Name bits loc expected value
627  // descriptor_tag 8 0.0 0x49
628  // descriptor_length 8 1.0
629 
630  uint CountryCount(void) const { return ((DescriptorLength() - 1) / 3); }
631 
632  // country_avail_flag 1 2.0
633  bool IsAvailable(void) const { return (_data[2] & 0x1); }
634  // reserved_future_use 7 2.1
635  //
636  // for (i=0; i<N; i++)
637  // { country_code 24 }
638  QString CountryNames(void) const
639  {
640  QString countries="";
641  for (uint i=0; i<CountryCount(); i++)
642  {
643  if (i!=0) countries.append(" ");
644  countries.append(QString::fromLatin1(
645  (const char *)_data+(3*(i+1)), 3));
646  };
647  return countries;
648  }
649 
650  QString toString(void) const override // MPEGDescriptor
651  {
652  return QString("CountryAvailabilityDescriptor: Available(%1) in (%2)")
653  .arg(IsAvailable()).arg(CountryNames());
654  }
655 };
656 
657 // DVB Bluebook A038 (Sept 2011) p 50
659 {
660  public:
661  DataBroadcastDescriptor(const unsigned char *data, int len = 300) :
662  MPEGDescriptor(data, len, DescriptorID::data_broadcast) { }
663  // Name bits loc expected value
664  // descriptor_tag 8 0.0 0x64
665  // descriptor_length 8 1.0
666 
667  // data_broadcast_id 16 2.0
668  uint DataBroadcastId(void) const { return _data[2] << 8 | _data[3]; }
669  // component_tag 8 4.0
670  uint DataComponentTag(void) const { return _data[4]; }
671  // selector_length 8 5.0
672  uint SelectorLength(void) const { return _data[5]; }
673  // for (i=0; i<selector_length; i++)
674  // {
675  // selector_byte 8
676  const unsigned char *Selector(void) const { return &_data[6]; }
677  // }
678  // ISO_639_language_code 24
679  int LanguageKey(void) const
680  { return iso639_str3_to_key(&_data[6 + SelectorLength()]); }
681  QString LanguageString(void) const
682  { return iso639_key_to_str3(LanguageKey()); }
683  int CanonicalLanguageKey(void) const
685  QString CanonicalLanguageString(void) const
687  // text_length 8
688  uint TextLength(void) const { return _data[6 + SelectorLength() + 3]; }
689  // for (i=0; i<text_length; i++) { text_char 8 }
690  QString Text(void) const
691  {
692  return dvb_decode_text(&_data[6 + SelectorLength() + 4], TextLength());
693  }
694 
695  QString toString(void) const override; // MPEGDescriptor
696 };
697 
698 // DVB Bluebook A038 (Sept 2011) p 51
700 {
701  public:
702  DataBroadcastIdDescriptor(const unsigned char *data, int len = 300) :
703  MPEGDescriptor(data, len, DescriptorID::data_broadcast_id) { }
704  // Name bits loc expected value
705  // descriptor_tag 8 0.0 0x66
706  // descriptor_length 8 1.0
707 
708  // data_broadcast_id 16 2.0
709  uint DataBroadCastId(void) const { return _data[2] << 8 | _data[3]; }
710  // for(i=0; i < N;i++ )
711  // { id_selector_byte 8 }
712 };
713 
714 // DVB Bluebook A038 (Sept 2011) p 51
716 {
717  public:
718  CableDeliverySystemDescriptor(const unsigned char *data, int len = 300) :
719  MPEGDescriptor(data, len, DescriptorID::cable_delivery_system) { }
720  // Name bits loc expected value
721  // descriptor_tag 8 0.0 0x44
722  // descriptor_length 8 1.0
723 
724  // frequency 32 2.0
725  uint FrequencyRaw(void) const
726  {
727  return ((_data[2]<<24) | (_data[3]<<16) |
728  (_data[4]<<8) | (_data[5]));
729  }
730  unsigned long long FrequencyHz(void) const
731  {
732  return byte4BCD2int(_data[2], _data[3], _data[4], _data[5]) * 100;
733  }
734  // reserved_future_use 12 6.0
735  // FEC_outer 4 7.4
736  enum
737  {
740  };
741  uint FECOuter(void) const { return _data[7] & 0xf; }
742  QString FECOuterString(void) const
743  {
744  return (FECOuter() == kOuterFEC_None) ? "None" :
745  ((FECOuter() == kOuterFEC_RS204_RS188) ? "RS(204/188)" : "unknown");
746  }
747  // modulation 8 8.0
748  enum
749  {
755  };
756  uint Modulation(void) const { return _data[8]; }
757  QString ModulationString(void) const
758  {
759  static QString ms[] =
760  { "auto", "qam_16", "qam_32", "qam_64", "qam_128", "qam_256" };
761  return (Modulation() <= kModulationQAM256) ?
762  ms[Modulation()] : QString("auto");
763  }
764  // symbol_rate 28 9.0
765  uint SymbolRateRaw(void) const
766  {
767  return ((_data[9]<<20) | (_data[10]<<12) |
768  (_data[11]<<4) | (_data[12]>>4));
769  }
770  uint SymbolRateHz(void) const
771  {
772  return ((byte3BCD2int(_data[9], _data[10], _data[11]) * 1000) +
773  (byteBCDH2int(_data[12]) * 100));
774  }
775  // FEC_inner 4 12.4
776  enum
777  {
785  };
786  uint FECInner(void) const { return _data[12] & 0xf; }
787  QString FECInnerString(void) const { return coderate_inner(FECInner()); }
788  QString toString(void) const override; // MPEGDescriptor
789 };
790 
791 // DVB Bluebook A038 (Sept 2011) p 53
793 {
794  public:
796  const unsigned char *data, int len = 300) :
797  MPEGDescriptor(data, len, DescriptorID::satellite_delivery_system) { }
798  // Name bits loc expected value
799  // descriptor_tag 8 0.0 0x43
800  // descriptor_length 8 1.0
801 
803  uint FrequencyRaw(void) const
804  {
805  return ((_data[2]<<24) | (_data[3]<<16) |
806  (_data[4]<<8) | (_data[5]));
807  }
808  unsigned long long FrequencyHz(void) const
809  {
810  return byte4BCD2int(_data[2], _data[3], _data[4], _data[5]) * 10;
811  }
813  uint OrbitalPosition(void) const
814  { return byte2BCD2int(_data[6], _data[7]); }
815  QString OrbitalPositionString(void) const
816  {
817  uint num = OrbitalPosition();
818  return QString("%1.%2 %3").arg(num / 10).arg(num % 10)
819  .arg((IsEast()) ? "East" : "West");
820  }
821  double OrbitalPositionFloat() const
822  { return ((double) OrbitalPosition()) / 10.0; }
824  bool IsEast(void) const { return ( (_data[8]&0x80) ) != 0; }
825  bool IsWest(void) const { return !IsEast(); }
826  // polarization 2 8.1
827  uint Polarization(void) const { return (_data[8]>>5)&0x3; }
828  QString PolarizationString() const
829  {
830  static QString ps[] = { "h", "v", "l", "r" };
831  return ps[Polarization()];
832  }
833  bool IsCircularPolarization(void) const { return (_data[8]>>6)&0x1; }
834  bool IsLinearPolarization(void) const { return !((_data[8]>>6)&0x1); }
835  bool IsHorizontalLeftPolarization(void) const { return (_data[8]>>5)&0x1; }
837  { return !((_data[8]>>5)&0x1); }
838  // roll off 2 8.3
839  enum
840  {
845  };
846  uint RollOff(void) const { return (_data[8]>>3)&0x3; }
847  QString RollOffString(void) const
848  {
849  static QString ro[] = { "0.35", "0.20", "0.25", "auto" };
850  return ro[RollOff()];
851  }
852  // modulation system 1 8.5
853  uint ModulationSystem(void) const { return (_data[8]>>2)&0x1; }
854  QString ModulationSystemString(void) const
855  {
856  return ModulationSystem() ? "DVB-S2" : "DVB-S";
857  }
858  // modulation 2 8.6
859  enum
860  {
861  kModulationQPSK_NS = 0x0, // Non standard QPSK for Bell ExpressVu
862  // should be "auto" according to DVB SI standard
866  };
867  uint Modulation(void) const { return _data[8]&0x03; }
868  QString ModulationString(void) const
869  {
870  static QString ms[] = { "qpsk", "qpsk", "8psk", "qam_16" };
871  return ms[Modulation()];
872  }
873  // symbol_rate 28 9.0
874  uint SymbolRate(void) const
875  {
876  return ((_data[9]<<20) | (_data[10]<<12) |
877  (_data[11]<<4) | (_data[12]>>4));
878  }
879  uint SymbolRateHz(void) const
880  {
881  return ((byte3BCD2int(_data[9], _data[10], _data[11]) * 1000) +
882  (byteBCDH2int(_data[12]) * 100));
883  }
884  // FEC_inner 4 12.4
885  enum
886  {
894  };
895  uint FECInner(void) const { return _data[12] & 0xf; }
896  QString FECInnerString(void) const { return coderate_inner(FECInner()); }
897 
898  QString toString(void) const override; // MPEGDescriptor
899 };
900 
901 // DVB Bluebook A038 (Sept 2011) p 55
903 {
904  public:
906  const unsigned char *data, int len = 300) :
907  MPEGDescriptor(data, len, DescriptorID::terrestrial_delivery_system) { }
908  // Name bits loc expected value
909  // descriptor_tag 8 0.0 0x5a
910  // descriptor_length 8 1.0
911 
912  // centre_frequency 32 2.0
913  uint Frequency(void) const
914  {
915  return ((_data[2]<<24) | (_data[3]<<16) |
916  (_data[4]<<8) | (_data[5]));
917  }
918  uint64_t FrequencyHz(void) const { return uint64_t(Frequency()) * 10ULL; }
919 
920  // bandwidth 3 6.0
921  enum
922  {
927  };
928  uint Bandwidth(void) const { return _data[6]>>5; }
929  uint BandwidthHz(void) const { return (8 - Bandwidth()) * 1000000; }
930  QString BandwidthString(void) const
931  {
932  static QString bs[] = { "8", "7", "6", "5" };
933  return (Bandwidth() <= kBandwidth5Mhz) ? bs[Bandwidth()] : "auto";
934  }
935  // priority 1 6.3
936  bool HighPriority(void) const { return ( _data[6] & 0x10 ) != 0; }
937  // time_slicing_indicator 1 6.4
938  bool IsTimeSlicingIndicatorUsed(void) const { return !(_data[6] & 0x08); }
939  // MPE-FEC_indicator 1 6.5
940  bool IsMPE_FECUsed(void) const { return !(_data[6] & 0x04); }
941  // reserved_future_use 2 6.6
942  // constellation 2 7.0
943  enum
944  {
949  };
950  uint Constellation(void) const { return _data[7]>>6; }
951  QString ConstellationString(void) const
952  {
953  static QString cs[] = { "qpsk", "qam_16", "qam_64", "qam_256" };
954  return (Constellation() <= kConstellationQAM256) ?
955  cs[Constellation()] : "auto";
956  }
957  // hierarchy_information 3 7.2
958  enum
959  {
968  };
969  uint Hierarchy(void) const { return (_data[7]>>3) & 0x7; }
970 
972  QString HierarchyString(void) const
973  {
974  static QString hs[] = { "n", "1", "2", "4", "a", "a", "a", "a" };
975  return hs[Hierarchy()];
976  }
977  bool NativeInterleaver(void) const { return ( _data[7] & 0x20 ) != 0; }
978  uint Alpha(void) const
979  {
980  uint i = (_data[7]>>3) & 0x3;
981  return (0x2 == i) ? 4 : i;
982  }
983  // code_rate-HP_stream 3 7.5
984  enum
985  {
991  };
992  uint CodeRateHP(void) const { return _data[7] & 0x7; }
993  QString CodeRateHPString(void) const
994  {
995  static QString cr[] = {
996  "1/2", "2/3", "3/4", "5/6", "7/8", "auto", "auto", "auto"
997  };
998  return cr[CodeRateHP()];
999  }
1000  // code_rate-LP_stream 3 8.0
1001  uint CodeRateLP(void) const { return (_data[8]>>5) & 0x7; }
1002  QString CodeRateLPString(void) const
1003  {
1004  static QString cr[] = {
1005  "1/2", "2/3", "3/4", "5/6", "7/8", "auto", "auto", "auto"
1006  };
1007  return cr[CodeRateLP()];
1008  }
1009  // guard_interval 2 8.3
1010  enum
1011  {
1016  };
1017  uint GuardInterval(void) const { return (_data[8]>>3) & 0x3; }
1018  QString GuardIntervalString(void) const
1019  {
1020  static QString gi[] = { "1/32", "1/16", "1/8", "1/4" };
1021  return gi[GuardInterval()];
1022  }
1023  // transmission_mode 2 8.5
1024  enum
1025  {
1029  };
1030  uint TransmissionMode(void) const { return (_data[8]>>1) & 0x3; }
1031  QString TransmissionModeString(void) const
1032  {
1033  static QString tm[] = { "2", "8", "4", "auto" };
1034  return tm[TransmissionMode()];
1035  }
1036  // other_frequency_flag 1 8.7
1037  bool OtherFrequencyInUse(void) const { return _data[8] & 0x1; }
1038  // reserved_future_use 32 9.0
1039 
1040  QString toString(void) const override; // MPEGDescriptor
1041 };
1042 
1043 // DVB Bluebook A038 (Sept 2011) p 58
1045 {
1046  public:
1047  DSNGDescriptor(const unsigned char *data, int len = 300) :
1048  MPEGDescriptor(data, len, DescriptorID::dsng) { }
1049  // Name bits loc expected value
1050  // descriptor_tag 8 0.0 0x68
1051  // descriptor_length 8 1.0
1052  // for (i=0;i<N;i++) { byte 8 }
1053 };
1054 
1055 // DVB Bluebook A038 (Sept 2011) p 58
1057 {
1058  public:
1059  ExtendedEventDescriptor(const unsigned char *data, int len = 300) :
1060  MPEGDescriptor(data, len, DescriptorID::extended_event) { }
1061  // Name bits loc expected value
1062  // descriptor_tag 8 0.0 0x4e
1063  // descriptor_length 8 1.0
1064 
1065  // descriptor_number 4 2.0
1066  uint DescriptorNumber(void) const { return _data[2] >> 4; }
1067  // last_number 4 2.4
1068  uint LastNumber(void) const { return _data[2] & 0xf; }
1069  // ISO_639_language_code 24 3.0
1070  int LanguageKey(void) const
1071  { return iso639_str3_to_key(&_data[3]); }
1072  QString LanguageString(void) const
1073  { return iso639_key_to_str3(LanguageKey()); }
1074  int CanonicalLanguageKey(void) const
1076  QString CanonicalLanguageString(void) const
1078  // length_of_items 8 6.0
1079  uint LengthOfItems(void) const { return _data[6]; }
1080  // for ( i=0;i<N;i++)
1081  // {
1082  // item_description_len 8 0.0+p
1083  // for (j=0;j<N;j++) { item_desc_char 8 }
1084  // item_length 8 1.0+p2
1085  // for (j=0;j<N;j++) { item_char 8 }
1086  // }
1087  QMap<QString,QString> Items(void) const;
1088  // text_length 8
1089  uint TextLength(void) const { return _data[7 + LengthOfItems()]; }
1090  // for (i=0; i<N; i++) { text_char 8 }
1091  QString Text(void) const
1092  { return dvb_decode_text(&_data[8 + LengthOfItems()], TextLength()); }
1093 
1094  // HACK beg -- Pro7Sat is missing encoding
1095  QString Text(const unsigned char *encoding_override,
1096  uint encoding_length) const
1097  {
1098  return dvb_decode_text(&_data[8 + LengthOfItems()], TextLength(),
1099  encoding_override, encoding_length);
1100  }
1101  // HACK end -- Pro7Sat is missing encoding
1102 };
1103 
1104 // DVB Bluebook A038 (Sept 2011) p 60
1106 {
1107  public:
1108  FrequencyListDescriptor(const unsigned char *data, int len = 300) :
1109  MPEGDescriptor(data, len, DescriptorID::frequency_list) { }
1110  // Name bits loc expected value
1111  // descriptor_tag 8 0.0 0x62
1112  // descriptor_length 8 1.0
1113 
1114  // reserved_future_use 6 2.0
1115  // coding_type 2 2.6
1116  enum
1117  {
1122  };
1123  uint CodingType(void) const { return _data[2] & 0x3; }
1124  // for (i=0;I<N;i++)
1125  // {
1126  // centre_frequency 32
1127  // }
1128  uint FrequencyCount() const { return DescriptorLength()>>2; }
1129  unsigned long long Frequency(uint i) const
1130  {
1132  return (((unsigned long long)_data[i*4+3]<<24) |
1133  (_data[i*4+4]<<16) |
1134  (_data[i*4+5]<<8) |
1135  (_data[i*4+6]));
1136  else
1137  return byte4BCD2int(_data[i*4+3], _data[i*4+4],
1138  _data[i*4+5], _data[i*4+6]);
1139  }
1140  unsigned long long FrequencyHz(uint i) const
1141  {
1142  return Frequency(i) *
1143  ((kCodingTypeTerrestrial == CodingType()) ? 10 : 100);
1144  }
1145 
1146  QString toString(void) const override; // MPEGDescriptor
1147 };
1148 
1149 // DVB Bluebook A038 (Sept 2011) p 70
1150 // ETSI EN 300 468 p 58
1152 {
1153  public:
1154  LocalTimeOffsetDescriptor(const unsigned char *data, int len = 300) :
1155  MPEGDescriptor(data, len, DescriptorID::local_time_offset) { }
1156  // Name bits loc expected value
1157  // descriptor_tag 8 0.0 0x58
1158  // descriptor_length 8 1.0
1159  uint Count(void) const { return DescriptorLength() / 13; }
1160  // for(i=0;i<N;i++)
1161  // {
1162  // country_code 24 0.0+p
1164  {
1165  int o = 2 + i*13;
1166  return ((_data[o] << 16) | (_data[o+1] << 8) | _data[o+2]);
1167  }
1168  QString CountryCodeString(uint i) const
1169  {
1170  int o = 2 + i*13;
1171  return QString(_data[o]) + QChar(_data[o+1]) + QChar(_data[o+2]);
1172  }
1173  // country_region_id 6 3.0+p
1174  uint CountryRegionId(uint i) const { return _data[2 + i*13 + 3] >> 2; }
1175  // reserved 1 3.6+p
1176  // local_time_off_polarity 1 3.7+p
1179  { return _data[2 + i*13 + 3] & 0x01; }
1180  // local_time_offset 16 4.0+p
1182  { return (_data[2 + i*13 + 4] << 8) | _data[2 + i*13 + 5]; }
1184  { return (LocalTimeOffsetPolarity(i) ? -1 : +1) * LocalTimeOffset(i); }
1185  // time_of_change 40 6.0+p
1186  // TODO decode this
1187  // next_time_offset 16 11.0+p
1189  { return (_data[2 + i*13 + 11]<<8) | _data[2 + i*13 + 12]; }
1190  // } 13.0
1191  QString toString(void) const override; // MPEGDescriptor
1192 };
1193 
1194 // DVB Bluebook A038 (Sept 2011) p 71
1196 {
1197  public:
1198  MosaicDescriptor(const unsigned char *data, int len = 300) :
1199  MPEGDescriptor(data, len, DescriptorID::mosaic) { }
1200  // Name bits loc expected value
1201  // descriptor_tag 8 0.0 0x51
1202  // descriptor_length 8 1.0
1203 
1204  // mosaic_entry_point 1 2.0
1205  // num_horiz_elem_cells 3 2.1
1206  // reserved_future_use 1 2.4
1207  // num_vert_elem_cells 3 2.5
1208  // for (i=0;i<N; i++)
1209  // {
1210  // logical_cell_id 6 0.0+p
1211  // reserved_future_use 7 0.6+p
1212  // logical_cell_pres_info 3 1.5+p
1213  // elem_cell_field_len 8 2.0+p
1214  // for (i=0; j<elementary_cell_field_length; j++)
1215  // {
1216  // reserved_future_use 2
1217  // elementary_cell_id 6
1218  // }
1219  // cell_linkage_info 8
1220  // if (cell_linkage_info == 0x01)
1221  // {
1222  // bouquet_id 16
1223  // }
1224  // if (cell_linkage_info == 0x02)
1225  // {
1226  // original_network_id 16
1227  // transport_stream_id 16
1228  // service_id 16
1229  // }
1230  // if (cell_linkage_info == 0x03)
1231  // {
1232  // original_network_id 16
1233  // transport_stream_id 16
1234  // service_id 16
1235  // }
1236  // if (cell_linkage_info == 0x04)
1237  // {
1238  // original_network_id 16
1239  // transport_stream_id 16
1240  // service_id 16
1241  // event_id 16
1242  // }
1243  // }
1244 };
1245 
1246 // DVB Bluebook A038 (Sept 2011) p 74
1248 {
1249  public:
1251  const unsigned char *data, int len = 300) :
1252  MPEGDescriptor(data, len, DescriptorID::multilingual_bouquet_name) { }
1253  // Name bits loc expected value
1254  // descriptor_tag 8 0.0 0x5c
1255  // descriptor_length 8 1.0
1256 
1257  // for (i=0;i<N;i++)
1258  // {
1259  // ISO_639_language_code 24
1260  // bouquet_name_length 8
1261  // for (j=0;j<N;j++) { char 8 }
1262  // }
1263 };
1264 
1265 // DVB Bluebook A038 (Sept 2011) p 75
1267 {
1268  public:
1270  const unsigned char *data, int len = 300) :
1271  MPEGDescriptor(data, len, DescriptorID::multilingual_network_name)
1272  {
1273  // Name bits loc expected value
1274  // descriptor_tag 8 0.0 0x5b
1275  // descriptor_length 8 1.0
1276  }
1277 
1278  // for (i=0;i<N;i++)
1279  // {
1280  // ISO_639_language_code 24
1281  // network_name_length 8
1282  // for (j=0;j<N;j++) { char 8 }
1283  // }
1284 };
1285 
1286 // DVB Bluebook A038 (Sept 2011) p 76
1288 {
1289  public:
1291  const unsigned char *data, int len = 300) :
1292  MPEGDescriptor(data, len, DescriptorID::multilingual_service_name) { }
1293  // Name bits loc expected value
1294  // descriptor_tag 8 0.0 0x5d
1295  // descriptor_length 8 1.0
1296 
1297  // for (i=0;i<N;i++)
1298  // {
1299  // ISO_639_language_code 24
1300  // service_provider_name_length 8
1301  // for (j=0;j<N;j++) { char 8 }
1302  // service_name_length 8
1303  // for (j=0;j<N;j++) { char 8 }
1304  // }
1305 };
1306 
1307 // DVB Bluebook A038 (Sept 2011) p 76
1309 {
1310  public:
1311  NVODReferenceDescriptor(const unsigned char *data, int len = 300) :
1312  MPEGDescriptor(data, len, DescriptorID::nvod_reference) { }
1313  // Name bits loc expected value
1314  // descriptor_tag 8 0.0 0x4b
1315  // descriptor_length 8 1.0
1316  uint Count(void) const { return DescriptorLength() / 6; }
1317 
1318  // for (i=0;i<N;i++)
1319  // {
1320  // transport_stream_id 16
1322  { return (_data[i * 6 + 2] << 8) | _data[i * 6 + 3]; }
1323  // original_network_id 16
1325  { return (_data[i * 6 + 4] << 8) | _data[i * 6 + 5]; }
1326  // service_id 16
1328  { return (_data[i * 6 + 6] << 8) | _data[i * 6 + 7]; }
1329  // }
1330  QString toString(void) const override; // MPEGDescriptor
1331 };
1332 
1333 // DVB Bluebook A038 (Sept 2011) p 78
1334 // ETSI EN 300 468
1336 {
1337  public:
1338  ParentalRatingDescriptor(const unsigned char *data, int len = 300) :
1339  MPEGDescriptor(data, len, DescriptorID::parental_rating) { }
1340  // Name bits loc expected value
1341  // descriptor_tag 8 0.0 0x55
1342  // descriptor_length 8 1.0
1343  uint Count(void) const { return DescriptorLength() / 4; }
1344 
1345  // for (i=0; i<N; i++)
1346  // {
1347  // country_code 24
1348  // rating 8
1349  // }
1350  QString CountryCodeString(uint i) const
1351  {
1352  int o = 2 + i*4;
1353  if (i < Count())
1354  {
1355  return QString(_data[o]) + QChar(_data[o+1]) + QChar(_data[o+2]);
1356  }
1357  else
1358  {
1359  return QString("");
1360  }
1361  }
1362  int Rating(uint i) const
1363  {
1364  if (i >= Count())
1365  {
1366  return -1;
1367  }
1368 
1369  unsigned char rawRating = _data[2 + 3 + i*4];
1370  if (rawRating == 0)
1371  {
1372  // 0x00 - undefined
1373  return -1;
1374  }
1375  else if ((rawRating >= 0x01) && (rawRating <= 0x0F))
1376  {
1377  // 0x01 to 0x0F - minumum age = rating + 3 years
1378  return rawRating + 3;
1379  }
1380  else
1381  {
1382  // 0x10 to 0xFF - defined by the broadcaster
1383  return -1;
1384  }
1385  }
1386 };
1387 
1388 // DVB Bluebook A038 (Sept 2011) p 78 (see also ETSI EN 300 231 PDC)
1390 {
1391  public:
1392  PDCDescriptor(const unsigned char *data, int len = 300) :
1393  MPEGDescriptor(data, len, DescriptorID::pdc, 3) { }
1394  // Name bits loc expected value
1395  // descriptor_tag 8 0.0 0x69
1396  // descriptor_length 8 1.0
1397 
1398  // reserved_future_use 4 2.0
1399  // program_id_label 20 2.4
1400  uint ProgramIdLabel(void) const
1401  { return (_data[2] & 0x0F) << 16 | _data[3] << 8 | _data[4]; }
1402  QString toString(void) const override // MPEGDescriptor
1403  {
1404  return QString("PDCDescriptor program_id_label(%1)")
1405  .arg(ProgramIdLabel());
1406  }
1407 };
1408 
1409 // DVB Bluebook A038 (Sept 2011) p 79 (see also ETSI TS 101 162)
1411 {
1412  public:
1413  PrivateDataSpecifierDescriptor(const unsigned char *data, int len = 300) :
1414  MPEGDescriptor(data, len, DescriptorID::private_data_specifier) { }
1415  // Name bits loc expected value
1416  // descriptor_tag 8 0.0 0x5f
1417  // descriptor_length 8 1.0
1418 
1419  // private_data_specifier 32 2.0
1420  uint32_t PrivateDataSpecifier (void) const
1421  {
1422  return (_data[2] << 24 | _data[3] << 16 | _data[4] << 8 | _data[5]);
1423  }
1424 };
1425 
1426 // DVB Bluebook A038 (Sept 2011) p 79
1428 {
1429  public:
1430  ScramblingDescriptor(const unsigned char *data, int len = 300) :
1431  MPEGDescriptor(data, len, DescriptorID::scrambling, 1) { }
1432  // Name bits loc expected value
1433  // descriptor_tag 8 0.0 0x65
1434  // descriptor_length 8 1.0
1435 
1436  // scrambling_mode 8 2.0
1437  uint ScramblingMode(void) const { return _data[2]; }
1438  QString toString(void) const override // MPEGDescriptor
1439  {
1440  return QString("ScramblingDescriptor scrambling_mode(%1)")
1441  .arg(ScramblingMode());
1442  }
1443 };
1444 
1445 // DVB Bluebook A038 (Feb 2019) p 83, Table 89: Service type coding
1446 // Map serviceid's to their types
1448 {
1449  public:
1450  explicit ServiceDescriptorMapping(const uint serviceid) { m_serviceid = serviceid; }
1451  enum
1452  {
1461  // reserved for future use = 0x09,
1470  // reserved for future use = 0x12 to 0x15
1482  // reserved for future use = 0x21 to 0x7F
1483  // user defined = 0x80 to 0xFE
1484  // reserved for future use = 0xFF
1485  // User Defined descriptors for Dish network
1499 
1500  };
1501  uint ServiceType(void) const { return m_serviceid; }
1502  bool IsDTV(void) const
1503  {
1504  return ((ServiceType() == kServiceTypeDigitalTelevision) ||
1506  IsHDTV() ||
1507  IsUHDTV() ||
1521  }
1522  bool IsDigitalAudio(void) const
1523  {
1524  return
1527  }
1528  bool IsHDTV(void) const
1529  {
1530  return
1534  }
1535  bool IsUHDTV(void) const
1536  {
1537  return
1540  }
1541  bool IsTeletext(void) const
1542  {
1544  }
1545  QString toString(void) const;
1546 
1547  private:
1549 };
1550 
1551 // DVB Bluebook A038 (Sept 2011) p 80
1553 {
1554  public:
1555  ServiceDescriptor(const unsigned char *data, int len = 300) :
1556  MPEGDescriptor(data, len, DescriptorID::service) { }
1557  // Name bits loc expected value
1558  // descriptor_tag 8 0.0 0x48
1559  // descriptor_length 8 1.0
1560 
1561  // service_type 8 2.0
1562  uint ServiceType(void) const { return _data[2]; }
1563  // svc_provider_name_len 8 3.0
1564  uint ServiceProviderNameLength(void) const { return _data[3]; }
1565  // for (i=0;i<N;I++) { char 8 }
1566  QString ServiceProviderName(void) const
1567  { return dvb_decode_text(_data + 4, ServiceProviderNameLength()); }
1568  QString ServiceProviderShortName(void) const
1569  {
1571  }
1572  // service_name_length 8
1574  { return _data[4 + ServiceProviderNameLength()]; }
1575  // for (i=0;i<N;I++) { char 8 }
1576  QString ServiceName(void) const
1577  {
1579  ServiceNameLength());
1580  }
1581  QString ServiceShortName(void) const
1582  {
1584  ServiceNameLength());
1585  }
1586  bool IsDTV(void) const
1587  { return ServiceDescriptorMapping(ServiceType()).IsDTV(); }
1588  bool IsDigitalAudio(void) const
1590  bool IsHDTV(void) const
1592  bool IsTeletext(void) const
1594 
1595  QString toString(void) const override // MPEGDescriptor
1596  {
1597  return QString("ServiceDescriptor: %1 %2(0x%3)")
1598  .arg(ServiceName())
1600  .arg(ServiceType(),2,16,QChar('0'));
1601  }
1602 };
1603 
1604 // DVB Bluebook A038 (Sept 2011) p 82
1606 {
1607  public:
1608  ServiceAvailabilityDescriptor(const unsigned char *data, int len = 300) :
1609  MPEGDescriptor(data, len, DescriptorID::service_availability) { }
1610  // Name bits loc expected value
1611  // descriptor_tag 8 0.0 0x72
1612  // descriptor_length 8 1.0
1613 
1614  // availability_flag 1 2.0
1615  // reserved 7 2.1
1616  // for (i=0;i<N;i++) { cell_id 16 }
1617 };
1618 
1619 // DVB Bluebook A038 (Sept 2011) p 82
1621 {
1622  public:
1623  ServiceListDescriptor(const unsigned char *data, int len = 300) :
1624  MPEGDescriptor(data, len, DescriptorID::service_list) { }
1625  // Name bits loc expected value
1626  // descriptor_tag 8 0.0 0x41
1627  // descriptor_length 8 1.0
1628 
1629  // for (i=0;i<N;I++)
1630  // {
1631  // service_id 16 0.0+p
1632  // service_type 8 2.0+p
1633  // }
1634  uint ServiceCount(void) const { return DescriptorLength() / 3; }
1635 
1637  { return (_data[2+i*3] << 8) | _data[3+i*3]; }
1638 
1639  uint ServiceType(uint i) const { return _data[4+i*3]; }
1640 
1641  QString toString(void) const override // MPEGDescriptor
1642  {
1643  QString str = QString("ServiceListDescriptor: %1 Services\n")
1644  .arg(ServiceCount());
1645  for (uint i=0; i<ServiceCount(); i++)
1646  {
1647  if (i!=0) str.append("\n");
1648  str.append(QString(" Service (%1) Type%2").arg(ServiceID(i))
1650  }
1651  return str;
1652  }
1653 };
1654 
1655 // DVB Bluebook A038 (Sept 2011) p 82
1657 {
1658  public:
1659  ServiceMoveDescriptor(const unsigned char *data, int len = 300) :
1660  MPEGDescriptor(data, len, DescriptorID::service_move) { }
1661  // Name bits loc expected value
1662  // descriptor_tag 8 0.0 0x60
1663  // descriptor_length 8 1.0
1664 
1665  // new_original_network_id 16 2.0
1666  // new_transport_stream_id 16 4.0
1667  // new_service_id 16 6.0
1668 };
1669 
1670 // DVB Bluebook A038 (Sept 2011) p 83
1672 {
1673  public:
1674  ShortEventDescriptor(const unsigned char *data, int len = 300) :
1675  MPEGDescriptor(data, len, DescriptorID::short_event) { }
1676  // Name bits loc expected value
1677  // descriptor_tag 8 0.0 0x4d
1678  // descriptor_length 8 1.0
1679 
1680  // ISO_639_language_code 24 2.0
1681  int LanguageKey(void) const
1682  { return iso639_str3_to_key(&_data[2]); }
1683  QString LanguageString(void) const
1684  { return iso639_key_to_str3(LanguageKey()); }
1685  int CanonicalLanguageKey(void) const
1687  QString CanonicalLanguageString(void) const
1689  // event_name_length 8 5.0
1690  uint EventNameLength(void) const { return _data[5]; }
1691  // for (i=0;i<event_name_length;i++) { event_name_char 8 }
1692  QString EventName(void) const
1693  { return dvb_decode_text(&_data[6], _data[5]); }
1694  QString EventShortName(void) const
1695  { return dvb_decode_short_name(&_data[6], _data[5]); }
1696  // text_length 8
1697  uint TextLength(void) const { return _data[6 + _data[5]]; }
1698  // for (i=0;i<text_length;i++) { text_char 8 }
1699  QString Text(void) const
1700  { return dvb_decode_text(&_data[7 + _data[5]], TextLength()); }
1701 
1702  // HACK beg -- Pro7Sat is missing encoding
1703  QString EventName(const unsigned char *encoding_override,
1704  uint encoding_length) const
1705  {
1706  return dvb_decode_text(&_data[6], _data[5],
1707  encoding_override, encoding_length);
1708  }
1709 
1710  QString Text(const unsigned char *encoding_override,
1711  uint encoding_length) const
1712  {
1713  return dvb_decode_text(&_data[7 + _data[5]], TextLength(),
1714  encoding_override, encoding_length);
1715  }
1716  // HACK end -- Pro7Sat is missing encoding
1717 
1718  QString toString(void) const override // MPEGDescriptor
1719  { return LanguageString() + " : " + EventName() + " : " + Text(); }
1720 };
1721 
1722 // DVB Bluebook A038 (Sept 2011) p 84
1724 {
1725  public:
1726  ShortSmoothingBufferDescriptor(const unsigned char *data, int len = 300) :
1727  MPEGDescriptor(data, len, DescriptorID::short_smoothing_buffer) { }
1728  // Name bits loc expected value
1729  // descriptor_tag 8 0.0 0x61
1730  // descriptor_length 8 1.0
1731 
1732  // sb_size 2 2.0
1733  // sb_leak_rate 6 2.2
1734  // for (i=0; i<N; i++)
1735  // { DVB_reserved 8 }
1736 };
1737 
1738 // DVB Bluebook A038 (Sept 2011) p 85
1742 {
1743  public:
1744  StreamIdentifierDescriptor(const unsigned char *data, int len = 300) :
1745  MPEGDescriptor(data, len, DescriptorID::stream_identifier, 1) { }
1746  // Name bits loc expected value
1747  // descriptor_tag 8 0.0 0x52
1748  // descriptor_length 8 1.0 0x01
1749 
1750  // component_tag 8 2.0
1751  uint ComponentTag(void) const { return _data[2]; }
1752  QString toString(void) const override // MPEGDescriptor
1753  {
1754  return QString("Stream Identifier Descriptor (0x52): ComponentTag=0x%1")
1755  .arg(ComponentTag(),1,16);
1756  }
1757 };
1758 
1759 // DVB Bluebook A038 (Sept 2011) p 86
1761 {
1762  public:
1763  StuffingDescriptor(const unsigned char *data, int len = 300) :
1764  MPEGDescriptor(data, len, DescriptorID::dvb_stuffing) { }
1765  // Name bits loc expected value
1766  // descriptor_tag 8 0.0 0x42
1767  // descriptor_length 8 1.0
1768  // stuffing_byte * 2.0
1769  QString toString(void) const override // MPEGDescriptor
1770  {
1771  return QString("Stuffing Descriptor (0x42) length(%1)")
1772  .arg(DescriptorLength());
1773  }
1774 };
1775 
1776 // DVB Bluebook A038 (Sept 2011) p 86
1778 {
1779  public:
1780  SubtitlingDescriptor(const unsigned char *data, int len = 300) :
1781  MPEGDescriptor(data, len, DescriptorID::subtitling) { }
1782  // Name bits loc expected value
1783  // descriptor_tag 8 0.0 0x59
1784  // descriptor_length 8 1.0
1785 
1786  uint StreamCount(void) const { return DescriptorLength() >> 3; }
1787  // for (i= 0;i<N;I++)
1788  // {
1789  // ISO_639_language_code 24 0.0+(i*8)
1790  int LanguageKey(uint i) const
1791  { return iso639_str3_to_key(&_data[2 + (i<<3)]); }
1792  QString LanguageString(uint i) const
1793  { return iso639_key_to_str3(LanguageKey(i)); }
1798 
1799  // subtitling_type 8 3.0+(i*8)
1801  { return _data[5 + (i<<3)]; }
1802  // composition_page_id 16 4.0+(i*8)
1804  { return (_data[6 + (i<<3)] << 8) | _data[7 + (i<<3)]; }
1805  // ancillary_page_id 16 6.0+(i*8)
1807  { return (_data[8 + (i<<3)] << 8) | _data[9 + (i<<3)]; }
1808  // } 8.0
1809 };
1810 
1811 // DVB Bluebook A038 (Sept 2011) p 87
1813 {
1814  public:
1815  TelephoneDescriptor(const unsigned char *data, int len = 300) :
1816  MPEGDescriptor(data, len, DescriptorID::telephone) { }
1817  // Name bits loc expected value
1818  // descriptor_tag 8 0.0 0x57
1819  // descriptor_length 8 1.0
1820 
1821  // reserved_future_use 2 2.0
1822  // foreign_availability 1 2.2
1823  // connection_type 5 2.3
1824  // reserved_future_use 1 3.0
1825  // country_prefix_length 2 3.1
1826  // i18n_area_code_len 3 3.4
1827  // operator_code_length 2 3.6
1828  // reserved_future_use 1 3.7
1829  // national_area_code_len 3 4.0
1830  // core_number_length 4 4.4
1831  //
1832  // for (i=0; i<N; i++)
1833  // { country_prefix_char 8 }
1834  // for (i=0; i<N; i++)
1835  // { international_area_code_char 8 }
1836  // for (i=0; i<N; i++)
1837  // { operator_code_char 8 }
1838  // for (i=0; i<N; i++)
1839  // { national_area_code_char 8 }
1840  // for (i=0; i<N; i++)
1841  // { core_number_char 8 }
1842 };
1843 
1844 // DVB Bluebook A038 (Sept 2011) p 88
1846 {
1847  public:
1848  TeletextDescriptor(const unsigned char *data, int len = 300) :
1849  MPEGDescriptor(data, len, DescriptorID::teletext) { }
1850  // Name bits loc expected value
1851  // descriptor_tag 8 0.0 0x56
1852  // descriptor_length 8 1.0
1853 
1854  uint StreamCount(void) const { return DescriptorLength() / 5; }
1855 
1856  // for (i=0; i<N; i++)
1857  // {
1858  // ISO_639_language_code 24 0.0
1859  int LanguageKey(uint i) const
1860  { return iso639_str3_to_key(&_data[2 + (i*5)]); }
1861  QString LanguageString(uint i) const
1862  { return iso639_key_to_str3(LanguageKey(i)); }
1867  // teletext_type 5 3.0
1869  { return _data[5 + (i*5)] >> 3; }
1870  // teletext_magazine_num 3 3.5
1872  { return _data[5 + (i*5)] & 0x7; }
1873  // teletext_page_num 8 4.0
1875  { return _data[6 + (i*5)]; }
1876  // } 5.0
1877  QString toString(void) const override; // MPEGDescriptor
1878 };
1879 
1880 // DVB Bluebook A038 (Sept 2011) p 89
1882 {
1883  public:
1884  TimeShiftedEventDescriptor(const unsigned char *data, int len = 300) :
1885  MPEGDescriptor(data, len, DescriptorID::time_shifted_event) { }
1886  // Name bits loc expected value
1887  // descriptor_tag 8 0.0 0x4f
1888  // descriptor_length 8 1.0
1889 
1890  // reference_service_id 16 2.0
1891  // reference_event_id 16 4.0
1892 };
1893 
1894 // DVB Bluebook A038 (Sept 2011) p 90
1896 {
1897  public:
1898  TimeShiftedServiceDescriptor(const unsigned char *data, int len = 300) :
1899  MPEGDescriptor(data, len, DescriptorID::dvb_time_shifted_service) { }
1900  // Name bits loc expected value
1901  // descriptor_tag 8 0.0 0x4c
1902  // descriptor_length 8 1.0
1903 
1904  // reference_service_id 16 2.0
1905 };
1906 
1907 // DVB Bluebook A038 (Sept 2011) p 90
1909 {
1910  public:
1911  TransportStreamDescriptor(const unsigned char *data, int len = 300) :
1912  MPEGDescriptor(data, len, DescriptorID::transport_stream) { }
1913  // Name bits loc expected value
1914  // descriptor_tag 8 0.0 0x67
1915  // descriptor_length 8 1.0
1916 
1917  // for (i=0; i<N; i++) { byte 8 }
1918  QString Data(void) const
1919  { return dvb_decode_text(&_data[2], DescriptorLength()); }
1920  QString toString(void) const override // MPEGDescriptor
1921  { return QString("TransportStreamDescriptor data(%1)").arg(Data()); }
1922 };
1923 
1924 // DVB Bluebook A038 (Sept 2011) p 91
1926 {
1927  public:
1928  VBIDataDescriptor(const unsigned char *data, int len = 300) :
1929  MPEGDescriptor(data, len, DescriptorID::vbi_data) { }
1930  // Name bits loc expected value
1931  // descriptor_tag 8 0.0 0x45
1932  // descriptor_length 8 1.0
1933 
1934  // for (i=0; i<N; i++)
1935  // {
1936  // data_service_id 8 0.0+p
1937  // data_service_length 8 1.0+p
1938  // if ((data_service_id&0x7) && data_service_id!=0x3))
1939  // {
1940  // for (i=0; i<N; i++)
1941  // {
1942  // reserved 2 2.0+p2
1943  // field_parity 1 2.2+p2
1944  // line_offset 5 2.3+p2
1945  // }
1946  // }
1947  // else
1948  // {
1949  // for (i=0; i<N; i++) { reserved 8 }
1950  // }
1951  // }
1952 };
1953 
1954 // DVB Bluebook A038 (Sept 2011) p 92
1956 {
1957  public:
1958  VBITeletextDescriptor(const unsigned char *data, int len = 300) :
1959  MPEGDescriptor(data, len, DescriptorID::vbi_teletext) { }
1960  // Name bits loc expected value
1961  // descriptor_tag 8 0.0 0x46
1962  // descriptor_length 8 1.0
1963 
1964  // for (i=0;i<N;i++)
1965  // {
1966  // ISO_639_language_code 24 0.0+p
1967  // teletext_type 5 3.0+p
1968  // teletext_magazine_num 3 3.5+p
1969  // teletext_page_num 8 4.0+p
1970  // } 5.0
1971 };
1972 
1973 // DVB Bluebook A038 (Sept 2011) p 119
1975 {
1976  public:
1977  PartialTransportStreamDescriptor(const unsigned char *data, int len = 300) :
1978  MPEGDescriptor(data, len, DescriptorID::partial_transport_stream) { }
1979  // Name bits loc expected value
1980  // descriptor_tag 8 0.0 0x63
1981  // descriptor_length 8 1.0
1982 
1983  // DVB_reserved_future_use 2 2.0
1984  // peak_rate 22 2.2
1985  uint PeakRate(void) const
1986  { return (_data[2] & 0x3f) << 16 | _data[3] | _data[4]; }
1987  // DVB_reserved_future_use 2 5.0
1988  // min_overall_smooth_rate 22 5.2
1989  uint SmoothRate(void) const
1990  { return (_data[5] & 0x3f) << 16 | _data[6] | _data[7]; }
1991  // DVB_reserved_future_use 2 8.0
1992  // max_overall_smooth_buf 14 8.2
1993  uint SmoothBuf(void) const { return ((_data[8] & 0x3f) << 8) | _data[9]; }
1994  QString toString(void) const override; // MPEGDescriptor
1995 };
1996 
1997 
1998 // a_52a.pdf p125 Table A7 (for DVB)
2000 {
2001  public:
2002  AC3Descriptor(const unsigned char *data, int len = 300) :
2003  MPEGDescriptor(data, len, DescriptorID::ac3) { }
2004  // Name bits loc expected value
2005  // descriptor_tag 8 0.0 0x6A
2006  // descriptor_length 8 1.0
2007 
2008  // component_type_flag 1 2.0
2009  bool HasComponentType(void) const { return ( _data[2] & 0x80 ) != 0; }
2010  // bsid_flag 1 2.1
2011  bool HasBSID(void) const { return ( _data[2] & 0x40 ) != 0; }
2012  // mainid_flag 1 2.2
2013  bool HasMainID(void) const { return ( _data[2] & 0x20 ) != 0; }
2014  // asvc_flag 1 2.3
2015  bool HasASVC(void) const { return ( _data[2] & 0x10 ) != 0; }
2016  // reserved_flags 4 2.4
2017  // if (component_type_flag == 1)
2018  // { component_type 8 uimsbf }
2019  uint ComponentType(void) const { return _data[3]; }
2020  // if (bsid_flag == 1)
2021  // { bsid 8 uimsbf }
2022  uint BSID(void) const
2023  { return (HasComponentType()) ? _data[4] : _data[3]; }
2024  // if (mainid_flag == 1)
2025  // { mainid 8 uimsbf }
2026  uint MainID(void) const
2027  {
2028  int offset = 3;
2029  offset += (HasComponentType()) ? 1 : 0;
2030  offset += (HasBSID()) ? 1 : 0;
2031  return _data[offset];
2032  }
2033  // if (asvc_flag==1)
2034  // { asvc 8 uimsbf }
2035  uint ASVC(void) const
2036  {
2037  int offset = 3;
2038  offset += (HasComponentType()) ? 1 : 0;
2039  offset += (HasBSID()) ? 1 : 0;
2040  offset += (HasMainID()) ? 1 : 0;
2041  return _data[offset];
2042  }
2043  // for (I=0;I<N;I++)
2044  // { additional_info[i] N*8 uimsbf }
2045  //};
2046  QString toString(void) const override; // MPEGDescriptor
2047 };
2048 
2049 static QString coderate_inner(uint cr)
2050 {
2051  switch (cr)
2052  {
2053  case 0x0: return "auto"; // not actually defined in spec
2054  case 0x1: return "1/2";
2055  case 0x2: return "2/3";
2056  case 0x3: return "3/4";
2057  case 0x4: return "5/6";
2058  case 0x5: return "7/8";
2059  case 0x8: return "8/9";
2060  case 0xf: return "none";
2061  default: return "auto"; // not actually defined in spec
2062  }
2063 }
2064 
2074 {
2075  public:
2076  DVBLogicalChannelDescriptor(const unsigned char *data, int len = 300) :
2077  MPEGDescriptor(data, len, PrivateDescriptorID::dvb_logical_channel_descriptor) { }
2078  // Name bits loc expected value
2079  // descriptor_tag 8 0.0 0x83
2080  // descriptor_length 8 1.0
2081 
2082  uint ChannelCount(void) const { return DescriptorLength() >> 2; }
2083 
2085  { return (_data[2 + (i<<2)] << 8) | _data[3 + (i<<2)]; }
2086 
2088  { return ((_data[4 + (i<<2)] << 8) | _data[5 + (i<<2)]) & 0x3ff; }
2089 
2090  QString toString(void) const override; // MPEGDescriptor
2091 };
2092 
2102 {
2103  public:
2104  DVBSimulcastChannelDescriptor(const unsigned char *data, int len = 300) :
2105  MPEGDescriptor(data, len, PrivateDescriptorID::dvb_simulcast_channel_descriptor) { }
2106  // Name bits loc expected value
2107  // descriptor_tag 8 0.0 0x88
2108  // descriptor_length 8 1.0
2109 
2110  uint ChannelCount(void) const { return DescriptorLength() >> 2; }
2111 
2113  { return (_data[2 + (i<<2)] << 8) | _data[3 + (i<<2)]; }
2114 
2116  { return ((_data[4 + (i<<2)] << 8) | _data[5 + (i<<2)]) & 0x3ff; }
2117 
2118  QString toString(void) const override; // MPEGDescriptor
2119 };
2120 
2132 {
2133  public:
2134  FreesatLCNDescriptor(const unsigned char *data, int len = 300) :
2135  MPEGDescriptor(data, len, PrivateDescriptorID::freesat_lcn_table)
2136  {
2138 
2139  const unsigned char *payload = &data[2];
2140 
2141  uint offset = 0;
2142  while ((offset + 5 < DescriptorLength()) &&
2143  (offset + 5 + payload[offset+4] <= DescriptorLength()))
2144  {
2145  entries.push_back(&payload[offset]);
2146  offset += 5 + payload[offset+4];
2147  }
2148  }
2149  // Name bits loc expected value
2150  // descriptor_tag 8 0.0 0xd3
2151  // descriptor_length 8 1.0
2152  // for (i=0;i<N;i++) {
2153  // service_id 16 0.0+p
2154  // chan_id 15 2.1+p
2155  // length 8 4.0+p
2156  // for (j=0;j<N;j++) {
2157  // unknown 4 0.0+p2
2158  // logical_channel_number 12 0.4+p2
2159  // region_id 16 2.0+p2
2160  // }
2161  // }
2162 
2163  uint ServiceCount(void) const
2164  { return entries.size(); }
2165 
2166  uint ServiceID(int i) const
2167  { return *entries[i] << 8 | *(entries[i]+1); }
2168 
2169  uint ChanID(int i) const
2170  { return (*(entries[i] + 2) << 8 | *(entries[i] + 3)) & 0x7FFF; }
2171 
2172  uint LCNCount(int i) const
2173  { return *(entries[i] + 4) / 4; }
2174 
2175  uint LogicalChannelNumber(int i, int j) const
2176  { return (*(entries[i] + 5 + j*4) << 8 | *(entries[i] + 5 + j*4 + 1)) & 0xFFF; }
2177 
2178  uint RegionID(int i, int j) const
2179  { return *(entries[i] + 5 + j*4 + 2) << 8 | *(entries[i] + 5 + j*4 + 3); }
2180 
2181  QString toString(void) const override; // MPEGDescriptor
2182 
2183  private:
2185 };
2186 
2197 {
2198  public:
2199  FreesatRegionDescriptor(const unsigned char *data, int len = 300) :
2200  MPEGDescriptor(data, len, PrivateDescriptorID::freesat_region_table)
2201  {
2203 
2204  const unsigned char *payload = &data[2];
2205 
2206  uint offset = 0;
2207  while ((offset + 6 < DescriptorLength()) &&
2208  (offset + 6 + payload[offset+5] <= DescriptorLength()))
2209  {
2210  entries.push_back(&payload[offset]);
2211  offset += 6 + payload[offset+5];
2212  }
2213  }
2214  // Name bits loc expected value
2215  // descriptor_tag 8 0.0 0xd4
2216  // descriptor_length 8 1.0
2217  // for (i=0;i<N;i++) {
2218  // region_id 16 0.0+p
2219  // language_code 24 2.0+p eng
2220  // text_length 8 5.0+p
2221  // for (j=0;j<N;j++) {
2222  // text_char 8
2223  // }
2224  // }
2225 
2226  uint RegionCount(void) const
2227  { return entries.size(); }
2228 
2229  int RegionID(uint i) const
2230  { return *entries[i] << 8 | *(entries[i]+1); }
2231 
2232  const QString Language(uint i) const
2233  { return QString::fromLatin1((char *) entries[i] + 2, 3); }
2234 
2235  const QString RegionName(uint i) const
2236  { return QString::fromLatin1((char *) entries[i] + 6, *(entries[i] + 5)); }
2237 
2238  QString toString(void) const override; // MPEGDescriptor
2239 
2240  private:
2242 };
2243 
2252 {
2253  public:
2254  FreesatCallsignDescriptor(const unsigned char *data, int len = 300) :
2255  MPEGDescriptor(data, len, PrivateDescriptorID::freesat_callsign)
2256  {
2258  }
2259 
2260  // Name bits loc expected value
2261  // descriptor_tag 8 0.0 0xd8
2262  // descriptor_length 8 1.0
2263 
2264  // ISO_639_language_code 24 2.0
2265  // callsign_length 8 5.0
2266  // for (j=0;j<N;j++) {
2267  // callsign_char 8
2268 
2269  const QString Language(void) const
2270  { return QString::fromLatin1((char *) _data +2, 3); }
2271 
2272  QString Callsign(void) const
2273  { return dvb_decode_short_name(&_data[6], _data[5]); }
2274 
2275  QString toString(void) const override; // MPEGDescriptor
2276 };
2277 
2290 {
2291  public:
2292  BSkyBLCNDescriptor(const unsigned char *data, int len = 300) :
2293  MPEGDescriptor(data, len, PrivateDescriptorID::bskyb_lcn_table)
2294  {
2296  }
2297  // Name bits loc expected value
2298  // descriptor_tag 8 0.0 0xd3
2299  // descriptor_length 8 1.0
2300  // region_id 16 2.0
2301  // for (i=0;i<N;i++) {
2302  // service_id 16 0.0+p
2303  // service_type 8 2.0+p
2304  // unknown 16 3.0+p
2305  // logical_channel_number 16 5.0+p2
2306  // unknown 16 7.0+p2
2307  // }
2308 
2309  uint RegionID(void) const
2310  { return (*(_data + 3) != 0xFF) ? *(_data + 3) : 0xFFFF;}
2311 
2312  uint RegionRaw(void) const
2313  { return *(_data + 2) << 8 | *(_data + 3);}
2314 
2315  uint ServiceCount(void) const
2316  { return (DescriptorLength() - 2) / 9; }
2317 
2318  uint ServiceID(int i) const
2319  { return *(_data + 4 + i*9) << 8 | *(_data + 5 + i*9); }
2320 
2321  uint ServiceType(int i) const
2322  { return *(_data + 6 + i*9); }
2323 
2324  uint Unknown1(int i) const
2325  { return *(_data + 7 + i*9) << 8 | *(_data + 8 + i*9); }
2326 
2328  { return *(_data + 9 + i*9) << 8 | *(_data + 10 + i*9); }
2329 
2330  uint Unknown2(int i) const
2331  { return *(_data + 11 + i*9) << 8 | *(_data + 12 + i*9); }
2332 
2333  QString toString(void) const override; // MPEGDescriptor
2334 };
2335 
2336 // ETSI TS 102 323 (TV Anytime)
2338 {
2339  public:
2340  DVBContentIdentifierDescriptor(const unsigned char *data, int len = 300) :
2341  MPEGDescriptor(data, len, DescriptorID::dvb_content_identifier)
2342  {
2343  size_t count = 0;
2344 
2345  memset ((void *) m_crid, 0, sizeof(m_crid));
2346 
2347  if (IsValid())
2348  {
2349  uint8_t position = 2;
2350  while (_data[1] >= position)
2351  {
2352  size_t length = _data[position+1];
2353  m_crid[count] = &_data[position];
2354  count++;
2355  position+=length+2;
2356  }
2357  }
2358  m_cridCount = count;
2359  }
2360  // Name bits loc expected value
2361  // descriptor_tag 8 0.0 0x76
2362  // descriptor_length 8 1.0
2363 
2364  uint ContentType(size_t n=0) const { return m_crid[n][0] >> 2; }
2365 
2366  uint ContentEncoding(size_t n=0) const { return m_crid[n][0] & 0x03; }
2367 
2368  // A content identifier is a URI. It may contain UTF-8 encoded using %XX.
2369  QString ContentId(size_t n=0) const
2370  {
2371  int length = m_crid[n][1];
2372  int positionOfHash = length-1;
2373  while (positionOfHash >= 0) {
2374  if (m_crid[n][2 + positionOfHash] == '#') {
2375  length = positionOfHash; /* remove the hash and the following IMI */
2376  break;
2377  }
2378  positionOfHash--;
2379  }
2380  return QString::fromLatin1((const char *)&m_crid[n][2], length);
2381  }
2382 
2383  size_t CRIDCount() const
2384  {
2385  return m_cridCount;
2386  }
2387 
2388  private:
2389  size_t m_cridCount;
2390  const uint8_t *m_crid[8];
2391 };
2392 
2393 // ETSI TS 102 323 (TV Anytime)
2395 {
2396  public:
2397  DefaultAuthorityDescriptor(const unsigned char *data, int len = 300) :
2398  MPEGDescriptor(data, len, DescriptorID::default_authority) { }
2399  // Name bits loc expected value
2400  // descriptor_tag 8 0.0 0x73
2401  // descriptor_length 8 1.0
2402 
2403  QString DefaultAuthority(void) const
2404  {
2405  return QString::fromLatin1((const char *)_data+2, _data[1]);
2406  }
2407 
2408  QString toString(void) const override // MPEGDescriptor
2409  {
2410  return QString("DefaultAuthorityDescriptor: Authority(%1)")
2411  .arg(DefaultAuthority());
2412  }
2413 };
2414 
2415 /*
2416  * private UPC Cablecom (Austria) episode descriptor for Horizon middleware
2417  */
2419 {
2420  public:
2421  PrivateUPCCablecomEpisodeTitleDescriptor(const unsigned char *data, int len = 300) :
2422  MPEGDescriptor(data, len, PrivateDescriptorID::upc_event_episode_title) { }
2423  // Name bits loc expected value
2424  // descriptor_tag 8 0.0 0xa7
2425  // descriptor_length 8 1.0
2426 
2427  // ISO_639_language_code 24 2.0
2428  int LanguageKey(void) const
2429  {
2430  return iso639_str3_to_key(&_data[2]);
2431  }
2432  QString LanguageString(void) const
2433  {
2434  return iso639_key_to_str3(LanguageKey());
2435  }
2436  int CanonicalLanguageKey(void) const
2437  {
2439  }
2440  QString CanonicalLanguageString(void) const
2441  {
2443  }
2444 
2445  uint TextLength(void) const
2446  {
2447  return _data[1] - 3;
2448  }
2449 
2450  QString Text(void) const
2451  {
2452  return dvb_decode_text(&_data[5], TextLength());
2453  }
2454 };
2455 
2456 #endif
uint ServiceCount(void) const
uint ChanID(int i) const
int CanonicalLanguageKey(void) const
bool IsTargetListed(void) const
unsigned long long FrequencyHz(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
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
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
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 ServiceCount(void) const
int CASystemId(uint i) const
uint SubtitleType(uint i) const
uint UserNibble(uint i) const
uint DataBroadCastId(void) const
const QString Language(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)
unsigned char VideoProperties(void) const
uint PrivateDataLength(void) const
unsigned int uint
Definition: compat.h:140
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
vector< const unsigned char * > desc_list_t
uint RegionID(void) const
QString toString(void) const override
uint ScramblingMode(void) const
int iso639_key_to_canonical_key(int iso639_2)
Definition: iso639.cpp:121
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)
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
const QString RegionName(uint i) const
#define byte4BCD2int(i, j, k, l)
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 LogicalChannelNumber(int i, int j) const
QString ServiceProviderShortName(void) const
uint ASVC(void) const
uint DescriptorNumber(void) const
QString toString(void) const override
uint RegionCount(void) const
QString toString(void) const override
uint ServiceID(int i) const
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
QString toString(void) const override
QString Text(void) const
DVBContentIdentifierDescriptor(const unsigned char *data, int len=300)
uint Unknown2(int i) const
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
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)
static volatile bool categoryDescExists
QString ConstellationString(void) const
QString toString(void) const override
uint EventNameLength(void) const
uint TSID(void) const
ExtendedEventDescriptor(const unsigned char *data, int len=300)
bool IsDigitalAudio(void) const
bool IsHorizontalLeftPolarization(void) const
uint TextLength(void) const
uint TeletextPageNum(uint i) const
int LocalTimeOffsetWithPolarity(uint i) const
uint MobileInitialServiceID(void) const
static QMap< uint, QString > categoryDesc
int LanguageKey(uint i) const
BSkyB Logical Channel Number descriptor.
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
BSkyBLCNDescriptor(const unsigned char *data, int len=300)
QString ServiceShortName(void) const
bool IsDigitalAudio(void) const
int LanguageKey(uint i) const
TimeShiftedEventDescriptor(const unsigned char *data, int len=300)
uint DescriptorLength(void) const
#define byteBCDH2int(i)
uint ServiceID(int i) const
ServiceDescriptorMapping(const uint serviceid)
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
uint RegionRaw(void) const
bool IsTeletext(void) const
uint TargetEventID(void) const
uint TeletextMagazineNum(uint i) const
uint OriginalNetworkId(uint i) const
static int x5
Definition: mythsocket.cpp:64
uint ServiceType(int i) const
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
const unsigned char * _data
bool HasMainID(void) const
QString LinkageTypeString(void) const
int CanonicalLanguageKey(void) const
QString CountryCodeString(uint i) const
QString ShortName(void) const
uint ServiceProviderNameLength(void) const
int CanonicalLanguageKey(uint i) const
int LanguageKey(void) const
QString CanonicalLanguageString(uint i) const
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
uint Unknown1(int i) const
QString toString(void) const override
uint LCNCount(int i) const
int RegionID(uint i) const
QString toString(void) const override
uint LogicalChannelNumber(int i) const
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)
uint BSID(void) const
DataBroadcastIdDescriptor(const unsigned char *data, int len=300)
int CanonicalLanguageKey(uint i) const
const QString Language(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 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
QString toString(void) const override
static QMutex categoryLock
uint Nibble1(uint i) const
QString CanonicalLanguageString(void) const
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