MythTV  0.28pre
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 <QMutex>
7 #include <QString>
8 
9 #include "mythtvexp.h" // MTV_PUBLIC - Symbol Visibility
10 #include "mpegdescriptors.h"
11 #include "programinfo.h" // for subtitle types and audio and video properties
12 
13 /*
14 // needed for scanning
15  conditional_access = 0x09, // maybe
16  satellite_delivery_system = 0x43,*
17  cable_delivery_system = 0x44,*
18  service = 0x48,*
19  terrestrial_delivery_system = 0x5A,*
20  frequency_list = 0x62,*
21 
22 // needed for captions
23  teletext = 0x56,
24  subtitling = 0x59,
25 
26 // needed for sound
27  registration = 0x05,
28  AC3 = 0x6A,
29 
30 // needed for eit
31  short_event = 0x4D,
32  extended_event = 0x4E,
33  content = 0x54,
34 */
35 
36 static QString coderate_inner(uint coderate);
37 
38 extern QString dvb_decode_text(const unsigned char *src, uint length,
39  const unsigned char *encoding_override,
40  uint encoding_override_length);
41 
42 inline QString dvb_decode_text(const unsigned char *src, uint length)
43 {
44  return dvb_decode_text(src, length, NULL, 0);
45 }
46 
47 QString dvb_decode_short_name(const unsigned char *src, uint raw_length);
48 
49 #define byteBCDH2int(i) (i >> 4)
50 #define byteBCDL2int(i) (i & 0x0f)
51 #define byteBCD2int(i) (byteBCDH2int(i) * 10 + byteBCDL2int(i))
52 #define byte2BCD2int(i, j) \
53  (byteBCDH2int(i) * 1000 + byteBCDL2int(i) * 100 + \
54  byteBCDH2int(j) * 10 + byteBCDL2int(j))
55 #define byte3BCD2int(i, j, k) \
56  (byteBCDH2int(i) * 100000 + byteBCDL2int(i) * 10000 + \
57  byteBCDH2int(j) * 1000 + byteBCDL2int(j) * 100 + \
58  byteBCDH2int(k) * 10 + byteBCDL2int(k))
59 #define byte4BCD2int(i, j, k, l) \
60  (byteBCDH2int(i) * 10000000LL + byteBCDL2int(i) * 1000000 + \
61  byteBCDH2int(j) * 100000 + byteBCDL2int(j) * 10000 + \
62  byteBCDH2int(k) * 1000 + byteBCDL2int(k) * 100 + \
63  byteBCDH2int(l) * 10 + byteBCDL2int(l))
64 
65 // DVB Bluebook A038 (Sept 2011) p 77
67 {
68  public:
69  NetworkNameDescriptor(const unsigned char *data, int len = 300) :
70  MPEGDescriptor(data, len, DescriptorID::network_name) { }
71  // Name bits loc expected value
72  // descriptor_tag 8 0.0 0x40
73  // descriptor_length 8 1.0
74  // for (i=0;i<N;i++){ char 8 uimsbf }
75  QString Name(void) const
76  { return dvb_decode_text(_data+2, DescriptorLength()); }
77  QString ShortName(void) const
79  QString toString(void) const
80  { return QString("NetworkNameDescriptor: ")+Name(); }
81 };
82 
83 // DVB Bluebook A038 (Sept 2011) p 63
85 {
86  public:
87  LinkageDescriptor(const unsigned char *data, int len = 300) :
88  MPEGDescriptor(data, len, DescriptorID::linkage)
89  {
90  if (!_data)
91  return;
92  if (DescriptorLength() < 7)
93  {
94  _data = NULL;
95  }
96  else if (kMobileHandOver == LinkageType())
97  {
98  uint end = 8;
99  if (DescriptorLength() < end)
100  {
101  _data = NULL;
102  return;
103  }
104  end += (HasMobileNetworkID()) ? 2 : 0;
105  end += (HasMobileInitialServiceID()) ? 2 : 0;
106  if (DescriptorLength() < end)
107  _data = NULL;
108  m_offset = end + 2;
109  }
110  else if (kEventLinkage == LinkageType())
111  {
112  if (DescriptorLength() < 10)
113  _data = NULL;
114  m_offset = 12;
115  }
116  }
117  // Name bits loc expected value
118  // descriptor_tag 8 0.0 0x4A
119  // descriptor_length 8 1.0
120  // transport_stream_id 16 2.0
121  uint TSID(void) const { return (_data[2]<<8) | _data[3]; }
122  // original_network_id 16 4.0
123  uint OriginalNetworkID() const { return (_data[4]<<8) | _data[5]; }
124  // service_id 16 6.0
125  uint ServiceID(void) const { return (_data[6]<<8) | _data[7]; }
126  // linkage_type 8 8.0
127  enum
128  {
129  kInformationService = 0x01,
130  kEPGService = 0x02,
131  kCAReplacementService = 0x03,
132  kTSContainingCompleteNetworkBouquetSI = 0x04,
133  kServiceReplacementService = 0x05,
134  kDataBroadcastService = 0x06,
135  kRCSMap = 0x07,
136  kMobileHandOver = 0x08,
137  kSystemSoftwareUpdateService = 0x09,
138  kTSContaining_SSU_BAT_NIT = 0x0A,
139  kIP_MACNotificationService = 0x0B,
140  kTSContaining_INT_BAT_NIT = 0x0C,
141  kEventLinkage = 0x0D,
142  };
143  uint LinkageType(void) const { return _data[8]; }
144  QString LinkageTypeString(void) const;
145 
146  // if (linkage_type == 0x08)
147  // {
148  // hand-over_type 4 9.0
149  enum
150  {
151  kHandOverIdentical = 0x01,
152  kHandOverLocalVariation = 0x02,
153  kHandOverAssociatedService = 0x03,
154  };
155  uint MobileHandOverType(void) const { return _data[9]>>4; }
156  QString MobileHandOverTypeString(void) const;
157  // reserved_future_use 3 9.4
158  // origin_type 1 9.7
159  enum
160  {
161  kOriginNIT = 0x0,
162  kOriginSDT = 0x1,
163  };
164  uint MobileOriginType(void) const { return _data[9]&0x1; }
165  QString MobileOriginTypeString(void) const;
166  // if (hand-over_type == 0x01 || hand-over_type == 0x02 ||
167  // hand-over_type == 0x03)
168  // { network_id 16 10.0 }
169  bool HasMobileNetworkID(void) const
170  { return bool(MobileHandOverType() & 0x3); }
171  uint MobileNetworkID(void) const { return (_data[10]<<8) | _data[11]; }
172  // if (origin_type ==0x00)
173  // { initial_service_id 16 HasNetworkID()?10.0:12.0 }
174  bool HasMobileInitialServiceID(void) const
175  { return kOriginNIT == MobileOriginType(); }
177  {
178  return HasMobileNetworkID() ?
179  ((_data[12]<<8) | _data[13]) : ((_data[10]<<8) | _data[11]);
180  }
181  // }
182  // if (linkage_type == 0x0D)
183  // {
184  // target_event_id 16 9.0
185  uint TargetEventID(void) const { return (_data[9]<<8) | _data[10]; }
186  // target_listed 1 11.0
187  bool IsTargetListed(void) const { return _data[11]&0x80; }
188  // event_simulcast 1 11.1
189  bool IsEventSimulcast(void) const { return _data[11]&0x40; }
190  // reserved 6 11.2
191  // }
192  // for (i=0;i<N;i++)
193  // { private_data_byte 8 bslbf }
194  const unsigned char *PrivateData(void) const
195  { return &_data[m_offset]; }
197  { return DescriptorLength() + 2 - m_offset; }
198 
199  private:
201 };
202 
203 // DVB Bluebook A038 (Sept 2011) p 38
205 {
206  public:
207  AdaptationFieldDataDescriptor(const unsigned char *data, int len = 300) :
208  MPEGDescriptor(data, len, DescriptorID::adaptation_field_data, 1) { }
209  // Name bits loc expected value
210  // descriptor_tag 8 0.0 0x70
211  // descriptor_length 8 1.0
212  // adapt_field_data_id 8 2.0
213  uint AdaptationFieldDataID(void) const { return _data[2]; }
214  QString toString(void) const
215  {
216  return QString("AdaptationFieldDataDescriptor "
217  "adaptation_field_data_identifier(%1)")
218  .arg(AdaptationFieldDataID());
219  }
220 };
221 
222 // DVB Bluebook A038 (Sept 2011) p 38
224 {
225  public:
226  AncillaryDataDescriptor(const unsigned char *data, int len = 300) :
227  MPEGDescriptor(data, len, DescriptorID::ancillary_data, 1) { }
228  // Name bits loc expected value
229  // descriptor_tag 8 0.0 0x6b
230  // descriptor_length 8 1.0
231  // ancillary_data_id 8 2.0
232  uint AncillaryDataID(void) const { return _data[2]; }
233  QString toString(void) const
234  {
235  return QString("AncillaryDataDescriptor "
236  "ancillary_data_identifier(%1)")
237  .arg(AncillaryDataID());
238  }
239 };
240 
241 // DVB Bluebook A038 (Sept 2011) p 39
243 {
244  public:
245  AnnouncementSupportDescriptor(const unsigned char *data, int len = 300) :
246  MPEGDescriptor(data, len, DescriptorID::announcement_support) { }
247  // Name bits loc expected value
248  // descriptor_tag 8 0.0 0x6e
249  // descriptor_length 8 1.0
250  // announcmnt_supprt_indic 16 2.0
251  // for (i=0; i<N; i++)
252  // {
253  // announcement_type 4 0.0+p
254  // reserved_future_use 1 0.4+p
255  // reference_type 3 0.5+p
256  // if (reference_type & 0x3)
257  // {
258  // original_network_id 16 0.0+p
259  // transport_stream_id 16 2.0+p
260  // service_id 16 4.0+p
261  // component_tag 8 6.0+p
262  // } 7.0
263  // }
264 };
265 
266 // DVB Bluebook A038 (Sept 2011) p 41
268 {
269  public:
270  BouquetNameDescriptor(const unsigned char *data, int len = 300) :
271  MPEGDescriptor(data, len, DescriptorID::bouquet_name) { }
272  // Name bits loc expected value
273  // descriptor_tag 8 0.0 0x47
274  // descriptor_length 8 1.0
275  // for(i=0;i<N;i++) { char 8 }
276  QString BouquetName(void) const
277  { return dvb_decode_text(_data+2, _data[1]); }
278  QString BouquetShortName(void) const
279  { return dvb_decode_short_name(_data+2, _data[1]); }
280 
281  QString toString(void) const
282  {
283  return QString("BouquetNameDescriptor: Bouquet Name(%1)")
284  .arg(BouquetName());
285  }
286 };
287 
288 // DVB Bluebook A038 (Sept 2011) p 41
290 {
291  public:
292  CAIdentifierDescriptor(const unsigned char *data, int len = 300) :
293  MPEGDescriptor(data, len, DescriptorID::ca_identifier) { }
294  // Name bits loc expected value
295  // descriptor_tag 8 0.0 0x53
296  // descriptor_length 8 1.0
297  //
298  uint CASystemCount(void) const { return DescriptorLength() >> 1; }
299  // for (i=0; i<N; i++)
300  // { CA_system_id 16 }
301  int CASystemId(uint i) const
302  { return (_data[2 + i*2] << 8) | _data[3 + i*2]; }
303  QString toString(void) const;
304 };
305 
306 // DVB Bluebook A038 (Sept 2011) p 42
308 {
309  public:
310  CellFrequencyLinkDescriptor(const unsigned char *data, int len = 300) :
311  MPEGDescriptor(data, len, DescriptorID::cell_frequency_link) { }
312  // Name bits loc expected value
313  // descriptor_tag 8 0.0 0x6d
314  // descriptor_length 8 1.0
315  // for (i=0; i<N; i++)
316  // {
317  // cell_id 16 0.0+p
318  // frequency 32 2.0+p
319  // subcell_info_loop_len 8 6.0+p
320  // for (j=0;j<N;j++)
321  // {
322  // cell_id_extension 8 0.0+p2
323  // transposer_freq 32 1.0+p2
324  // } 5.0
325  // }
326 };
327 
328 // DVB Bluebook A038 (Sept 2011) p 42
330 {
331  public:
332  CellListDescriptor(const unsigned char *data, int len = 300) :
333  MPEGDescriptor(data, len, DescriptorID::cell_list) { }
334  // Name bits loc expected value
335  // descriptor_tag 8 0.0 0x6c
336  // descriptor_length 8 1.0
337  // for (i=0; i<N; i++)
338  // {
339  // cell_id 16 0.0+p
340  // cell_latitude 16 2.0+p
341  // cell_longitude 16 4.0+p
342  // cell_extent_of_lat 12 6.0+p
343  // cell_extent_of_longit 12 7.4+p
344  // subcell_info_loop_len 8 9.0+p
345  // for (j=0;j<N;j++)
346  // {
347  // cell_id_extension 8 0.0+p2
348  // subcell_latitude 16 1.0+p2
349  // subcell_longitude 16 3.0+p2
350  // subcell_ext_of_lat 12 4.0+p2
351  // subcell_ext_of_long 12 5.4+p2
352  // } 7.0
353  // }
354 };
355 
356 // DVB Bluebook A038 (Sept 2011) p 44
358 {
359  public:
360  ComponentDescriptor(const unsigned char *data, int len = 300) :
361  MPEGDescriptor(data, len, DescriptorID::component) { }
362  // Name bits loc expected value
363  // descriptor_tag 8 0.0 0x50
364  // descriptor_length 8 1.0
365  // reserved_future_use 4 2.0
366  // stream_content 4 2.4
367  uint StreamContent(void) const { return _data[2] & 0xf; }
368  // component_type 8 3.0
369  uint ComponentType(void) const { return _data[3]; }
370  // component_tag 8 4.0
371  uint ComponentTag(void) const { return _data[4]; }
372  // ISO_639_language_code 24 5.0
373  int LanguageKey(void) const
374  { return iso639_str3_to_key(&_data[5]); }
375  QString LanguageString(void) const
376  { return iso639_key_to_str3(LanguageKey()); }
377  int CanonicalLanguageKey(void) const
378  { return iso639_key_to_canonical_key(LanguageKey()); }
379  QString CanonicalLanguageString(void) const
380  { return iso639_key_to_str3(CanonicalLanguageKey()); }
381  //
382  // for (i=0; i<N; i++) { text_char 8 }
383 
384  bool IsVideo(void) const
385  {
386  return 0x1 == StreamContent() || // MPEG-2
387  0x5 == StreamContent() || // H.264
388  0x9 == StreamContent(); // HEVC
389  }
390  bool IsAudio(void) const
391  {
392  switch(StreamContent())
393  {
394  case 0x02:
395  case 0x04:
396  case 0x06:
397  case 0x07:
398  return true;
399  default:
400  return false;
401  }
402  }
403  bool IsSubtitle(void) const { return 0x3 == StreamContent(); }
404 
405  unsigned char VideoProperties(void) const
406  {
407  if (0x1 == StreamContent())
408  return MPEG2Properties();
409  if (0x5 == StreamContent())
410  return VID_AVC | AVCProperties();
411  if (0x9 == StreamContent())
412  return /* VID_HEVC | */ HEVCProperties();
413 
414  return VID_UNKNOWN;
415  }
416 
417  unsigned char MPEG2Properties(void) const
418  {
419  switch(ComponentType())
420  {
421  case 0x2: case 0x3: case 0x4:
422  case 0x6: case 0x7: case 0x8:
423  return VID_WIDESCREEN;
424  case 0x09:
425  case 0x0D:
426  return VID_HDTV;
427  case 0x0A: case 0x0B: case 0x0C:
428  case 0x0E: case 0x0F: case 0x10:
429  return VID_WIDESCREEN | VID_HDTV;
430  default:
431  return VID_UNKNOWN;
432  }
433  }
434 
435  unsigned char AVCProperties(void) const
436  {
437  switch(ComponentType())
438  {
439  case 0x3: case 0x4:
440  case 0x7: case 0x8:
441  return VID_WIDESCREEN;
442  case 0x0B: case 0x0C:
443  case 0x0F: case 0x10:
444  return VID_WIDESCREEN | VID_HDTV;
445  case 0x80: case 0x81:
446  case 0x82: case 0x83:
447  return VID_WIDESCREEN | VID_HDTV | VID_3DTV;
448  default:
449  return VID_UNKNOWN;
450  }
451  }
452 
453  unsigned char HEVCProperties(void) const
454  {
455  switch(ComponentType())
456  {
457  case 0x0: case 0x1:
458  case 0x2: case 0x3:
459  return VID_HDTV;
460  case 0x5:
461  return VID_HDTV; // | VID_UHDTV;
462  default:
463  return VID_UNKNOWN;
464  }
465  }
466 
467  unsigned char AudioProperties(void) const
468  {
469  switch (StreamContent())
470  {
471  case 0x2:
472  return MP2Properties();
473  case 0x04:
474  return AC3Properties();
475  case 0x06:
476  return HEAACProperties();
477  default:
478  return AUD_UNKNOWN;
479  }
480  }
481 
482  unsigned char MP2Properties(void) const
483  {
484  switch (ComponentType())
485  {
486  case 0x1:
487  return AUD_MONO;
488  case 0x3:
489  return AUD_STEREO;
490  case 0x5:
491  return AUD_SURROUND;
492  case 0x40:
493  return AUD_VISUALIMPAIR;
494  case 0x41:
495  return AUD_HARDHEAR;
496  default:
497  return AUD_UNKNOWN;
498  }
499  }
500 
501  unsigned char AC3Properties(void) const
502  {
503  unsigned char properties = AUD_UNKNOWN;
504 
505  switch (ComponentType() & 0x7)
506  {
507  case 0x0:
508  properties |= AUD_MONO;
509  break;
510  case 0x2:
511  properties |= AUD_STEREO;
512  break;
513  case 0x3:
514  properties |= AUD_DOLBY;
515  break;
516  case 0x4: case 0x5:
517  properties |= AUD_SURROUND;
518  break;
519  }
520 
521  if (((ComponentType() >> 3) & 0x7) == 0x2)
522  properties |= AUD_VISUALIMPAIR;
523 
524  if (((ComponentType() >> 3) & 0x7) == 0x3)
525  properties |= AUD_HARDHEAR;
526 
527  return properties;
528  }
529 
530  unsigned char HEAACProperties(void) const
531  {
532  switch (ComponentType())
533  {
534  case 0x1:
535  return AUD_MONO;
536  case 0x3:
537  case 0x43:
538  return AUD_STEREO;
539  case 0x5:
540  return AUD_SURROUND;
541  case 0x40:
542  case 0x44:
543  return AUD_VISUALIMPAIR;
544  case 0x41:
545  case 0x45:
546  return AUD_HARDHEAR;
547  default:
548  return AUD_UNKNOWN;
549  }
550  }
551 
552  unsigned char SubtitleType(void) const
553  {
554  if (!IsSubtitle())
555  return SUB_UNKNOWN;
556 
557  switch (ComponentType())
558  {
559  case 0x1:
560  case 0x3:
561  case 0x10: case 0x11: case 0x12: case 0x13:
562  return SUB_NORMAL;
563  case 0x20: case 0x21: case 0x22: case 0x23:
564  return SUB_HARDHEAR;
565  default:
566  return SUB_UNKNOWN;
567  }
568  }
569 
570  QString toString(void) const
571  {
572  return QString("ComponentDescriptor(stream_content: 0x%1, "
573  "component_type: 0x%2)").arg(StreamContent(), 0, 16)
574  .arg(ComponentType(), 0, 16);
575  }
576 };
577 
578 // DVB Bluebook A038 (Sept 2011) p 46
580 {
581  public:
582  ContentDescriptor(const unsigned char *data, int len = 300) :
583  MPEGDescriptor(data, len, DescriptorID::content) { }
584  // Name bits loc expected value
585  // descriptor_tag 8 0.0 0x54
586  // descriptor_length 8 1.0
587 
588  uint Count(void) const { return DescriptorLength() >> 1; }
589  // for (i=0;i<N;i++)
590  // {
591  // content_nibble_level_1 4 0.0+p
592  uint Nibble1(uint i) const { return _data[2 + (i<<1)] >> 4; }
593  // content_nibble_level_2 4 0.4+p
594  uint Nibble2(uint i) const { return _data[2 + (i<<1)] & 0xf; }
595 
596  uint Nibble(uint i) const { return _data[2 + (i<<1)]; }
597 
598  // user_nibble 4 1.0+p
599  uint UserNibble1(uint i) const { return _data[3 + (i<<1)] >> 4; }
600  // user_nibble 4 1.4+p
601  uint UserNibble2(uint i) const { return _data[3 + (i<<1)] & 0xf; }
602  uint UserNibble(uint i) const { return _data[3 + (i<<1)]; }
603  // } 2.0
604 
605  ProgramInfo::CategoryType GetMythCategory(uint i) const;
606  QString GetDescription(uint i) const;
607  QString toString(void) const;
608 
609  protected:
610  static void Init(void);
611 
612  protected:
613  static QMutex categoryLock;
614  static QMap<uint,QString> categoryDesc;
615  static volatile bool categoryDescExists;
616 };
617 
618 // DVB Bluebook A038 (Sept 2011) p 49
620 {
621  public:
622  CountryAvailabilityDescriptor(const unsigned char *data, int len = 300) :
623  MPEGDescriptor(data, len, DescriptorID::country_availability) { }
624  // Name bits loc expected value
625  // descriptor_tag 8 0.0 0x49
626  // descriptor_length 8 1.0
627 
628  uint CountryCount(void) const { return ((DescriptorLength() - 1) / 3); }
629 
630  // country_avail_flag 1 2.0
631  bool IsAvailable(void) const { return (_data[2] & 0x1); }
632  // reserved_future_use 7 2.1
633  //
634  // for (i=0; i<N; i++)
635  // { country_code 24 }
636  QString CountryNames(void) const
637  {
638  QString countries="";
639  for (uint i=0; i<CountryCount(); i++)
640  {
641  if (i!=0) countries.append(" ");
642  countries.append(QString::fromLatin1(
643  (const char *)_data+(3*(i+1)), 3));
644  };
645  return countries;
646  }
647 
648  QString toString(void) const
649  {
650  return QString("CountryAvailabilityDescriptor: Available(%1) in (%2)")
651  .arg(IsAvailable()).arg(CountryNames());
652  }
653 };
654 
655 // DVB Bluebook A038 (Sept 2011) p 50
657 {
658  public:
659  DataBroadcastDescriptor(const unsigned char *data, int len = 300) :
660  MPEGDescriptor(data, len, DescriptorID::data_broadcast) { }
661  // Name bits loc expected value
662  // descriptor_tag 8 0.0 0x64
663  // descriptor_length 8 1.0
664 
665  // data_broadcast_id 16 2.0
666  uint DataBroadcastId(void) const { return _data[2] << 8 | _data[3]; }
667  // component_tag 8 4.0
668  uint DataComponentTag(void) const { return _data[4]; }
669  // selector_length 8 5.0
670  uint SelectorLength(void) const { return _data[5]; }
671  // for (i=0; i<selector_length; i++)
672  // {
673  // selector_byte 8
674  const unsigned char *Selector(void) const { return &_data[6]; }
675  // }
676  // ISO_639_language_code 24
677  int LanguageKey(void) const
678  { return iso639_str3_to_key(&_data[6 + SelectorLength()]); }
679  QString LanguageString(void) const
680  { return iso639_key_to_str3(LanguageKey()); }
681  int CanonicalLanguageKey(void) const
682  { return iso639_key_to_canonical_key(LanguageKey()); }
683  QString CanonicalLanguageString(void) const
684  { return iso639_key_to_str3(CanonicalLanguageKey()); }
685  // text_length 8
686  uint TextLength(void) const { return _data[6 + SelectorLength() + 3]; }
687  // for (i=0; i<text_length; i++) { text_char 8 }
688  QString Text(void) const
689  {
690  return dvb_decode_text(&_data[6 + SelectorLength() + 4], TextLength());
691  }
692 
693  QString toString(void) const;
694 };
695 
696 // DVB Bluebook A038 (Sept 2011) p 51
698 {
699  public:
700  DataBroadcastIdDescriptor(const unsigned char *data, int len = 300) :
701  MPEGDescriptor(data, len, DescriptorID::data_broadcast_id) { }
702  // Name bits loc expected value
703  // descriptor_tag 8 0.0 0x66
704  // descriptor_length 8 1.0
705 
706  // data_broadcast_id 16 2.0
707  uint DataBroadCastId(void) const { return _data[2] << 8 | _data[3]; }
708  // for(i=0; i < N;i++ )
709  // { id_selector_byte 8 }
710 };
711 
712 // DVB Bluebook A038 (Sept 2011) p 51
714 {
715  public:
716  CableDeliverySystemDescriptor(const unsigned char *data, int len = 300) :
717  MPEGDescriptor(data, len, DescriptorID::cable_delivery_system) { }
718  // Name bits loc expected value
719  // descriptor_tag 8 0.0 0x44
720  // descriptor_length 8 1.0
721 
722  // frequency 32 2.0
723  uint FrequencyRaw(void) const
724  {
725  return ((_data[2]<<24) | (_data[3]<<16) |
726  (_data[4]<<8) | (_data[5]));
727  }
728  unsigned long long FrequencyHz(void) const
729  {
730  return byte4BCD2int(_data[2], _data[3], _data[4], _data[5]) * 100;
731  }
732  // reserved_future_use 12 6.0
733  // FEC_outer 4 7.4
734  enum
735  {
736  kOuterFEC_None = 0x1,
737  kOuterFEC_RS204_RS188 = 0x2,
738  };
739  uint FECOuter(void) const { return _data[7] & 0xf; }
740  QString FECOuterString(void) const
741  {
742  return (FECOuter() == kOuterFEC_None) ? "None" :
743  ((FECOuter() == kOuterFEC_RS204_RS188) ? "RS(204/188)" : "unknown");
744  }
745  // modulation 8 8.0
746  enum
747  {
748  kModulationQAM16 = 0x01,
749  kModulationQAM32 = 0x02,
750  kModulationQAM64 = 0x03,
751  kModulationQAM128 = 0x04,
752  kModulationQAM256 = 0x05,
753  };
754  uint Modulation(void) const { return _data[8]; }
755  QString ModulationString(void) const
756  {
757  static QString ms[] =
758  { "auto", "qam_16", "qam_32", "qam_64", "qam_128", "qam_256" };
759  return (Modulation() <= kModulationQAM256) ?
760  ms[Modulation()] : QString("auto");
761  }
762  // symbol_rate 28 9.0
763  uint SymbolRateRaw(void) const
764  {
765  return ((_data[9]<<20) | (_data[10]<<12) |
766  (_data[11]<<4) | (_data[12]>>4));
767  }
768  uint SymbolRateHz(void) const
769  {
770  return ((byte3BCD2int(_data[9], _data[10], _data[11]) * 1000) +
771  (byteBCDH2int(_data[12]) * 100));
772  }
773  // FEC_inner 4 12.4
774  enum
775  {
776  kInnerFEC_1_2_ConvolutionCodeRate = 0x1,
777  kInnerFEC_2_3_ConvolutionCodeRate = 0x2,
778  kInnerFEC_3_4_ConvolutionCodeRate = 0x3,
779  kInnerFEC_5_6_ConvolutionCodeRate = 0x4,
780  kInnerFEC_7_8_ConvolutionCodeRate = 0x5,
781  kInnerFEC_8_9_ConvolutionCodeRate = 0x6,
782  kInnerFEC_None = 0xF,
783  };
784  uint FECInner(void) const { return _data[12] & 0xf; }
785  QString FECInnerString(void) const { return coderate_inner(FECInner()); }
786  QString toString(void) const;
787 };
788 
789 // DVB Bluebook A038 (Sept 2011) p 53
791 {
792  public:
794  const unsigned char *data, int len = 300) :
795  MPEGDescriptor(data, len, DescriptorID::satellite_delivery_system) { }
796  // Name bits loc expected value
797  // descriptor_tag 8 0.0 0x43
798  // descriptor_length 8 1.0
799 
801  uint FrequencyRaw(void) const
802  {
803  return ((_data[2]<<24) | (_data[3]<<16) |
804  (_data[4]<<8) | (_data[5]));
805  }
806  unsigned long long FrequencyHz(void) const
807  {
808  return byte4BCD2int(_data[2], _data[3], _data[4], _data[5]) * 10;
809  }
811  uint OrbitalPosition(void) const
812  { return byte2BCD2int(_data[6], _data[7]); }
813  QString OrbitalPositionString(void) const
814  {
815  uint num = OrbitalPosition();
816  return QString("%1.%2 %3").arg(num / 10).arg(num % 10)
817  .arg((IsEast()) ? "East" : "West");
818  }
819  double OrbitalPositionFloat() const
820  { return ((double) OrbitalPosition()) / 10.0; }
822  bool IsEast(void) const { return (_data[8]&0x80); }
823  bool IsWest(void) const { return !IsEast(); }
824  // polarization 2 8.1
825  uint Polarization(void) const { return (_data[8]>>5)&0x3; }
826  QString PolarizationString() const
827  {
828  static QString ps[] = { "h", "v", "l", "r" };
829  return ps[Polarization()];
830  }
831  bool IsCircularPolarization(void) const { return (_data[8]>>6)&0x1; }
832  bool IsLinearPolarization(void) const { return !((_data[8]>>6)&0x1); }
833  bool IsHorizontalLeftPolarization(void) const { return (_data[8]>>5)&0x1; }
835  { return !((_data[8]>>5)&0x1); }
836  // roll off 2 8.3
837  enum
838  {
843  };
844  uint RollOff(void) const { return (_data[8]>>3)&0x3; }
845  QString RollOffString(void) const
846  {
847  static QString ro[] = { "0.35", "0.20", "0.25", "auto" };
848  return ro[RollOff()];
849  }
850  // modulation system 1 8.5
851  uint ModulationSystem(void) const { return (_data[8]>>2)&0x1; }
852  QString ModulationSystemString(void) const
853  {
854  return ModulationSystem() ? "DVB-S2" : "DVB-S";
855  }
856  // modulation 2 8.6
857  enum
858  {
859  kModulationQPSK_NS = 0x0, // Non standard QPSK for Bell ExpressVu
860  // should be "auto" according to DVB SI standard
861  kModulationQPSK = 0x1,
862  kModulation8PSK = 0x2,
863  kModulationQAM16 = 0x3,
864  };
865  uint Modulation(void) const { return _data[8]&0x03; }
866  QString ModulationString(void) const
867  {
868  static QString ms[] = { "qpsk", "qpsk", "8psk", "qam_16" };
869  return ms[Modulation()];
870  }
871  // symbol_rate 28 9.0
872  uint SymbolRate(void) const
873  {
874  return ((_data[9]<<20) | (_data[10]<<12) |
875  (_data[11]<<4) | (_data[12]>>4));
876  }
877  uint SymbolRateHz(void) const
878  {
879  return ((byte3BCD2int(_data[9], _data[10], _data[11]) * 1000) +
880  (byteBCDH2int(_data[12]) * 100));
881  }
882  // FEC_inner 4 12.4
883  enum
884  {
885  kInnerFEC_1_2_ConvolutionCodeRate = 0x1,
886  kInnerFEC_2_3_ConvolutionCodeRate = 0x2,
887  kInnerFEC_3_4_ConvolutionCodeRate = 0x3,
888  kInnerFEC_5_6_ConvolutionCodeRate = 0x4,
889  kInnerFEC_7_8_ConvolutionCodeRate = 0x5,
890  kInnerFEC_8_9_ConvolutionCodeRate = 0x6,
891  kInnerFEC_None = 0xF,
892  };
893  uint FECInner(void) const { return _data[12] & 0xf; }
894  QString FECInnerString(void) const { return coderate_inner(FECInner()); }
895 
896  QString toString(void) const;
897 };
898 
899 // DVB Bluebook A038 (Sept 2011) p 55
901 {
902  public:
904  const unsigned char *data, int len = 300) :
905  MPEGDescriptor(data, len, DescriptorID::terrestrial_delivery_system) { }
906  // Name bits loc expected value
907  // descriptor_tag 8 0.0 0x5a
908  // descriptor_length 8 1.0
909 
910  // centre_frequency 32 2.0
911  uint Frequency(void) const
912  {
913  return ((_data[2]<<24) | (_data[3]<<16) |
914  (_data[4]<<8) | (_data[5]));
915  }
916  uint64_t FrequencyHz(void) const { return uint64_t(Frequency()) * 10ULL; }
917 
918  // bandwidth 3 6.0
919  enum
920  {
921  kBandwidth8Mhz = 0x0,
922  kBandwidth7Mhz = 0x1,
923  kBandwidth6Mhz = 0x2,
924  kBandwidth5Mhz = 0x3,
925  };
926  uint Bandwidth(void) const { return _data[6]>>5; }
927  uint BandwidthHz(void) const { return (8 - Bandwidth()) * 1000000; }
928  QString BandwidthString(void) const
929  {
930  static QString bs[] = { "8", "7", "6", "5" };
931  return (Bandwidth() <= kBandwidth5Mhz) ? bs[Bandwidth()] : "auto";
932  }
933  // priority 1 6.3
934  bool HighPriority(void) const { return _data[6] & 0x10; }
935  // time_slicing_indicator 1 6.4
936  bool IsTimeSlicingIndicatorUsed(void) const { return !(_data[6] & 0x08); }
937  // MPE-FEC_indicator 1 6.5
938  bool IsMPE_FECUsed(void) const { return !(_data[6] & 0x04); }
939  // reserved_future_use 2 6.6
940  // constellation 2 7.0
941  enum
942  {
943  kConstellationQPSK = 0x0,
944  kConstellationQAM16 = 0x1,
945  kConstellationQAM64 = 0x2,
946  kConstellationQAM256 = 0x3,
947  };
948  uint Constellation(void) const { return _data[7]>>6; }
949  QString ConstellationString(void) const
950  {
951  static QString cs[] = { "qpsk", "qam_16", "qam_64", "qam_256" };
952  return (Constellation() <= kConstellationQAM256) ?
953  cs[Constellation()] : "auto";
954  }
955  // hierarchy_information 3 7.2
956  enum
957  {
958  kHierarchyInfoNonHierarchicalNativeInterleaver = 0x0,
959  kHierarchyInfoAlpha1NativeInterleaver = 0x1,
960  kHierarchyInfoAlpha2NativeInterleaver = 0x2,
961  kHierarchyInfoAlpha4NativeInterleaver = 0x3,
962  kHierarchyInfoNonHierarchicalInDepthInterleaver = 0x4,
963  kHierarchyInfoAlpha1InDepthInterleaver = 0x5,
964  kHierarchyInfoAlpha2InDepthInterleaver = 0x6,
965  kHierarchyInfoAlpha4InDepthInterleaver = 0x7,
966  };
967  uint Hierarchy(void) const { return (_data[7]>>3) & 0x7; }
968 
970  QString HierarchyString(void) const
971  {
972  static QString hs[] = { "n", "1", "2", "4", "a", "a", "a", "a" };
973  return hs[Hierarchy()];
974  }
975  bool NativeInterleaver(void) const { return _data[7] & 0x20; }
976  uint Alpha(void) const
977  {
978  uint i = (_data[7]>>3) & 0x3;
979  return (0x2 == i) ? 4 : i;
980  }
981  // code_rate-HP_stream 3 7.5
982  enum
983  {
984  kCodeRate_1_2 = 0x0,
985  kCodeRate_2_3 = 0x1,
986  kCodeRate_3_4 = 0x2,
987  kCodeRate_5_6 = 0x3,
988  kCodeRate_7_8 = 0x4,
989  };
990  uint CodeRateHP(void) const { return _data[7] & 0x7; }
991  QString CodeRateHPString(void) const
992  {
993  static QString cr[] = {
994  "1/2", "2/3", "3/4", "5/6", "7/8", "auto", "auto", "auto"
995  };
996  return cr[CodeRateHP()];
997  }
998  // code_rate-LP_stream 3 8.0
999  uint CodeRateLP(void) const { return (_data[8]>>5) & 0x7; }
1000  QString CodeRateLPString(void) const
1001  {
1002  static QString cr[] = {
1003  "1/2", "2/3", "3/4", "5/6", "7/8", "auto", "auto", "auto"
1004  };
1005  return cr[CodeRateLP()];
1006  }
1007  // guard_interval 2 8.3
1008  enum
1009  {
1010  kGuardInterval_1_32 = 0x0,
1011  kGuardInterval_1_16 = 0x1,
1012  kGuardInterval_1_8 = 0x2,
1013  kGuardInterval_1_4 = 0x3,
1014  };
1015  uint GuardInterval(void) const { return (_data[8]>>3) & 0x3; }
1016  QString GuardIntervalString(void) const
1017  {
1018  static QString gi[] = { "1/32", "1/16", "1/8", "1/4" };
1019  return gi[GuardInterval()];
1020  }
1021  // transmission_mode 2 8.5
1022  enum
1023  {
1024  kTransmissionMode2k = 0x00,
1025  kTransmissionMode8k = 0x01,
1026  kTransmissionMode4k = 0x02,
1027  };
1028  uint TransmissionMode(void) const { return (_data[8]>>1) & 0x3; }
1029  QString TransmissionModeString(void) const
1030  {
1031  static QString tm[] = { "2", "8", "4", "auto" };
1032  return tm[TransmissionMode()];
1033  }
1034  // other_frequency_flag 1 8.7
1035  bool OtherFrequencyInUse(void) const { return _data[8] & 0x1; }
1036  // reserved_future_use 32 9.0
1037 
1038  QString toString(void) const;
1039 };
1040 
1041 // DVB Bluebook A038 (Sept 2011) p 58
1043 {
1044  public:
1045  DSNGDescriptor(const unsigned char *data, int len = 300) :
1046  MPEGDescriptor(data, len, DescriptorID::dsng) { }
1047  // Name bits loc expected value
1048  // descriptor_tag 8 0.0 0x68
1049  // descriptor_length 8 1.0
1050  // for (i=0;i<N;i++) { byte 8 }
1051 };
1052 
1053 // DVB Bluebook A038 (Sept 2011) p 58
1055 {
1056  public:
1057  ExtendedEventDescriptor(const unsigned char *data, int len = 300) :
1058  MPEGDescriptor(data, len, DescriptorID::extended_event) { }
1059  // Name bits loc expected value
1060  // descriptor_tag 8 0.0 0x4e
1061  // descriptor_length 8 1.0
1062 
1063  // descriptor_number 4 2.0
1064  uint DescriptorNumber(void) const { return _data[2] >> 4; }
1065  // last_number 4 2.4
1066  uint LastNumber(void) const { return _data[2] & 0xf; }
1067  // ISO_639_language_code 24 3.0
1068  int LanguageKey(void) const
1069  { return iso639_str3_to_key(&_data[3]); }
1070  QString LanguageString(void) const
1071  { return iso639_key_to_str3(LanguageKey()); }
1072  int CanonicalLanguageKey(void) const
1073  { return iso639_key_to_canonical_key(LanguageKey()); }
1074  QString CanonicalLanguageString(void) const
1075  { return iso639_key_to_str3(CanonicalLanguageKey()); }
1076  // length_of_items 8 6.0
1077  uint LengthOfItems(void) const { return _data[6]; }
1078  // for ( i=0;i<N;i++)
1079  // {
1080  // item_description_len 8 0.0+p
1081  // for (j=0;j<N;j++) { item_desc_char 8 }
1082  // item_length 8 1.0+p2
1083  // for (j=0;j<N;j++) { item_char 8 }
1084  // }
1085  QMap<QString,QString> Items(void) const;
1086  // text_length 8
1087  uint TextLength(void) const { return _data[7 + LengthOfItems()]; }
1088  // for (i=0; i<N; i++) { text_char 8 }
1089  QString Text(void) const
1090  { return dvb_decode_text(&_data[8 + LengthOfItems()], TextLength()); }
1091 
1092  // HACK beg -- Pro7Sat is missing encoding
1093  QString Text(const unsigned char *encoding_override,
1094  uint encoding_length) const
1095  {
1096  return dvb_decode_text(&_data[8 + LengthOfItems()], TextLength(),
1097  encoding_override, encoding_length);
1098  }
1099  // HACK end -- Pro7Sat is missing encoding
1100 };
1101 
1102 // DVB Bluebook A038 (Sept 2011) p 60
1104 {
1105  public:
1106  FrequencyListDescriptor(const unsigned char *data, int len = 300) :
1107  MPEGDescriptor(data, len, DescriptorID::frequency_list) { }
1108  // Name bits loc expected value
1109  // descriptor_tag 8 0.0 0x62
1110  // descriptor_length 8 1.0
1111 
1112  // reserved_future_use 6 2.0
1113  // coding_type 2 2.6
1114  enum
1115  {
1116  kCodingTypeNotDefined = 0x0,
1117  kCodingTypeSatellite = 0x1,
1118  kCodingTypeCable = 0x2,
1119  kCodingTypeTerrestrial = 0x3,
1120  };
1121  uint CodingType(void) const { return _data[2] & 0x3; }
1122  // for (i=0;I<N;i++)
1123  // {
1124  // centre_frequency 32
1125  // }
1126  uint FrequencyCount() const { return DescriptorLength()>>2; }
1127  unsigned long long Frequency(uint i) const
1128  {
1129  if (kCodingTypeTerrestrial == CodingType())
1130  return (((unsigned long long)_data[i*4+3]<<24) |
1131  (_data[i*4+4]<<16) |
1132  (_data[i*4+5]<<8) |
1133  (_data[i*4+6]));
1134  else
1135  return byte4BCD2int(_data[i*4+3], _data[i*4+4],
1136  _data[i*4+5], _data[i*4+6]);
1137  }
1138  unsigned long long FrequencyHz(uint i) const
1139  {
1140  return Frequency(i) *
1141  ((kCodingTypeTerrestrial == CodingType()) ? 10 : 100);
1142  }
1143 
1144  QString toString(void) const;
1145 };
1146 
1147 // DVB Bluebook A038 (Sept 2011) p 70
1148 // ETSI EN 300 468 p 58
1150 {
1151  public:
1152  LocalTimeOffsetDescriptor(const unsigned char *data, int len = 300) :
1153  MPEGDescriptor(data, len, DescriptorID::local_time_offset) { }
1154  // Name bits loc expected value
1155  // descriptor_tag 8 0.0 0x58
1156  // descriptor_length 8 1.0
1157  uint Count(void) const { return DescriptorLength() / 13; }
1158  // for(i=0;i<N;i++)
1159  // {
1160  // country_code 24 0.0+p
1162  {
1163  int o = 2 + i*13;
1164  return ((_data[o] << 16) | (_data[o+1] << 8) | _data[o+2]);
1165  }
1166  QString CountryCodeString(uint i) const
1167  {
1168  int o = 2 + i*13;
1169  return QString(_data[o]) + QChar(_data[o+1]) + QChar(_data[o+2]);
1170  }
1171  // country_region_id 6 3.0+p
1172  uint CountryRegionId(uint i) const { return _data[2 + i*13 + 3] >> 2; }
1173  // reserved 1 3.6+p
1174  // local_time_off_polarity 1 3.7+p
1177  { return _data[2 + i*13 + 3] & 0x01; }
1178  // local_time_offset 16 4.0+p
1180  { return (_data[2 + i*13 + 4] << 8) | _data[2 + i*13 + 5]; }
1182  { return (LocalTimeOffsetPolarity(i) ? -1 : +1) * LocalTimeOffset(i); }
1183  // time_of_change 40 6.0+p
1184  // TODO decode this
1185  // next_time_offset 16 11.0+p
1187  { return (_data[2 + i*13 + 11]<<8) | _data[2 + i*13 + 12]; }
1188  // } 13.0
1189  QString toString(void) const;
1190 };
1191 
1192 // DVB Bluebook A038 (Sept 2011) p 71
1194 {
1195  public:
1196  MosaicDescriptor(const unsigned char *data, int len = 300) :
1197  MPEGDescriptor(data, len, DescriptorID::mosaic) { }
1198  // Name bits loc expected value
1199  // descriptor_tag 8 0.0 0x51
1200  // descriptor_length 8 1.0
1201 
1202  // mosaic_entry_point 1 2.0
1203  // num_horiz_elem_cells 3 2.1
1204  // reserved_future_use 1 2.4
1205  // num_vert_elem_cells 3 2.5
1206  // for (i=0;i<N; i++)
1207  // {
1208  // logical_cell_id 6 0.0+p
1209  // reserved_future_use 7 0.6+p
1210  // logical_cell_pres_info 3 1.5+p
1211  // elem_cell_field_len 8 2.0+p
1212  // for (i=0; j<elementary_cell_field_length; j++)
1213  // {
1214  // reserved_future_use 2
1215  // elementary_cell_id 6
1216  // }
1217  // cell_linkage_info 8
1218  // if (cell_linkage_info == 0x01)
1219  // {
1220  // bouquet_id 16
1221  // }
1222  // if (cell_linkage_info == 0x02)
1223  // {
1224  // original_network_id 16
1225  // transport_stream_id 16
1226  // service_id 16
1227  // }
1228  // if (cell_linkage_info == 0x03)
1229  // {
1230  // original_network_id 16
1231  // transport_stream_id 16
1232  // service_id 16
1233  // }
1234  // if (cell_linkage_info == 0x04)
1235  // {
1236  // original_network_id 16
1237  // transport_stream_id 16
1238  // service_id 16
1239  // event_id 16
1240  // }
1241  // }
1242 };
1243 
1244 // DVB Bluebook A038 (Sept 2011) p 74
1246 {
1247  public:
1249  const unsigned char *data, int len = 300) :
1250  MPEGDescriptor(data, len, DescriptorID::multilingual_bouquet_name) { }
1251  // Name bits loc expected value
1252  // descriptor_tag 8 0.0 0x5c
1253  // descriptor_length 8 1.0
1254 
1255  // for (i=0;i<N;i++)
1256  // {
1257  // ISO_639_language_code 24
1258  // bouquet_name_length 8
1259  // for (j=0;j<N;j++) { char 8 }
1260  // }
1261 };
1262 
1263 // DVB Bluebook A038 (Sept 2011) p 75
1265 {
1266  public:
1268  const unsigned char *data, int len = 300) :
1269  MPEGDescriptor(data, len, DescriptorID::multilingual_network_name)
1270  {
1271  // Name bits loc expected value
1272  // descriptor_tag 8 0.0 0x5b
1273  // descriptor_length 8 1.0
1274  }
1275 
1276  // for (i=0;i<N;i++)
1277  // {
1278  // ISO_639_language_code 24
1279  // network_name_length 8
1280  // for (j=0;j<N;j++) { char 8 }
1281  // }
1282 };
1283 
1284 // DVB Bluebook A038 (Sept 2011) p 76
1286 {
1287  public:
1289  const unsigned char *data, int len = 300) :
1290  MPEGDescriptor(data, len, DescriptorID::multilingual_service_name) { }
1291  // Name bits loc expected value
1292  // descriptor_tag 8 0.0 0x5d
1293  // descriptor_length 8 1.0
1294 
1295  // for (i=0;i<N;i++)
1296  // {
1297  // ISO_639_language_code 24
1298  // service_provider_name_length 8
1299  // for (j=0;j<N;j++) { char 8 }
1300  // service_name_length 8
1301  // for (j=0;j<N;j++) { char 8 }
1302  // }
1303 };
1304 
1305 // DVB Bluebook A038 (Sept 2011) p 76
1307 {
1308  public:
1309  NVODReferenceDescriptor(const unsigned char *data, int len = 300) :
1310  MPEGDescriptor(data, len, DescriptorID::nvod_reference) { }
1311  // Name bits loc expected value
1312  // descriptor_tag 8 0.0 0x4b
1313  // descriptor_length 8 1.0
1314  uint Count(void) const { return DescriptorLength() / 6; }
1315 
1316  // for (i=0;i<N;i++)
1317  // {
1318  // transport_stream_id 16
1320  { return (_data[i * 6 + 2] << 8) | _data[i * 6 + 3]; }
1321  // original_network_id 16
1323  { return (_data[i * 6 + 4] << 8) | _data[i * 6 + 5]; }
1324  // service_id 16
1326  { return (_data[i * 6 + 6] << 8) | _data[i * 6 + 7]; }
1327  // }
1328  QString toString(void) const;
1329 };
1330 
1331 // DVB Bluebook A038 (Sept 2011) p 78
1332 // ETSI EN 300 468
1334 {
1335  public:
1336  ParentalRatingDescriptor(const unsigned char *data, int len = 300) :
1337  MPEGDescriptor(data, len, DescriptorID::parental_rating) { }
1338  // Name bits loc expected value
1339  // descriptor_tag 8 0.0 0x55
1340  // descriptor_length 8 1.0
1341  uint Count(void) const { return DescriptorLength() / 4; }
1342 
1343  // for (i=0; i<N; i++)
1344  // {
1345  // country_code 24
1346  // rating 8
1347  // }
1348  QString CountryCodeString(uint i) const
1349  {
1350  int o = 2 + i*4;
1351  if (i < Count())
1352  {
1353  return QString(_data[o]) + QChar(_data[o+1]) + QChar(_data[o+2]);
1354  }
1355  else
1356  {
1357  return QString("");
1358  }
1359  }
1360  int Rating(uint i) const
1361  {
1362  if (i >= Count())
1363  {
1364  return -1;
1365  }
1366 
1367  unsigned char rawRating = _data[2 + 3 + i*4];
1368  if (rawRating == 0)
1369  {
1370  // 0x00 - undefined
1371  return -1;
1372  }
1373  else if ((rawRating >= 0x01) && (rawRating <= 0x0F))
1374  {
1375  // 0x01 to 0x0F - minumum age = rating + 3 years
1376  return rawRating + 3;
1377  }
1378  else
1379  {
1380  // 0x10 to 0xFF - defined by the broadcaster
1381  return -1;
1382  }
1383  }
1384 };
1385 
1386 // DVB Bluebook A038 (Sept 2011) p 78 (see also ETSI EN 300 231 PDC)
1388 {
1389  public:
1390  PDCDescriptor(const unsigned char *data, int len = 300) :
1391  MPEGDescriptor(data, len, DescriptorID::pdc, 3) { }
1392  // Name bits loc expected value
1393  // descriptor_tag 8 0.0 0x69
1394  // descriptor_length 8 1.0
1395 
1396  // reserved_future_use 4 2.0
1397  // program_id_label 20 2.4
1398  uint ProgramIdLabel(void) const
1399  { return (_data[2] & 0x0F) << 16 | _data[3] << 8 | _data[4]; }
1400  QString toString(void) const
1401  {
1402  return QString("PDCDescriptor program_id_label(%1)")
1403  .arg(ProgramIdLabel());
1404  }
1405 };
1406 
1407 // DVB Bluebook A038 (Sept 2011) p 79 (see also ETSI TS 101 162)
1409 {
1410  public:
1411  PrivateDataSpecifierDescriptor(const unsigned char *data, int len = 300) :
1412  MPEGDescriptor(data, len, DescriptorID::private_data_specifier) { }
1413  // Name bits loc expected value
1414  // descriptor_tag 8 0.0 0x5f
1415  // descriptor_length 8 1.0
1416 
1417  // private_data_specifier 32 2.0
1418  uint32_t PrivateDataSpecifier (void) const
1419  {
1420  return (_data[2] << 24 | _data[3] << 16 | _data[4] << 8 | _data[5]);
1421  }
1422 };
1423 
1424 // DVB Bluebook A038 (Sept 2011) p 79
1426 {
1427  public:
1428  ScramblingDescriptor(const unsigned char *data, int len = 300) :
1429  MPEGDescriptor(data, len, DescriptorID::scrambling, 1) { }
1430  // Name bits loc expected value
1431  // descriptor_tag 8 0.0 0x65
1432  // descriptor_length 8 1.0
1433 
1434  // scrambling_mode 8 2.0
1435  uint ScramblingMode(void) const { return _data[2]; }
1436  QString toString(void) const
1437  {
1438  return QString("ScramblingDescriptor scrambling_mode(%1)")
1439  .arg(ScramblingMode());
1440  }
1441 };
1442 
1443 // Map serviceid's to their types
1445 {
1446  public:
1447  ServiceDescriptorMapping(const uint serviceid) { m_serviceid = serviceid; }
1448  enum
1449  {
1450  kServiceTypeDigitalTelevision = 0x01,
1451  kServiceTypeDigitalRadioSound = 0x02,
1452  kServiceTypeTeletext = 0x03,
1453  kServiceTypeNVODReference = 0x04,
1454  kServiceTypeNVODTimeShifted = 0x05,
1455  kServiceTypeMosaic = 0x06,
1456  kServiceTypePALCodedSignal = 0x07,
1457  kServiceTypeSECAMCodedSignal = 0x08,
1458  kServiceTypeD_D2_MAC = 0x09,
1459  kServiceTypeAdvancedCodecDigitalRadioSound = 0x0A,
1460  kServiceTypeNTSCCodedSignal = 0x0B,
1461  kServiceTypeDataBroadcast = 0x0C,
1462  kServiceTypeCommonInterface = 0x0D,
1463  kServiceTypeRCS_Map = 0x0E,
1464  kServiceTypeRCS_FLS = 0x0F,
1465  kServiceTypeDVB_MHP = 0x10,
1466  kServiceTypeHDTV = 0x11,
1467  kServiceTypeAdvancedCodecSDDigitalTelevision = 0x16,
1468  kServiceTypeAdvancedCodecHDDigitalTelevision = 0x19,
1469  kServiceTypeAdvancedCodecFrameCompatiblePlanoStereoscopicHDTelevisionService = 0x1c,
1470  kServiceTypeUltraHD = 0x1f,
1471  kServiceTypeEchoStarTV1 = 0x91,
1472  kServiceTypeEchoStarTV2 = 0x9a,
1473  kServiceTypeEchoStarTV3 = 0xa4,
1474  kServiceTypeEchoStarTV4 = 0xa6,
1475  kServiceTypeNimiqTV1 = 0x81,
1476  kServiceTypeNimiqTV2 = 0x85,
1477  kServiceTypeNimiqTV3 = 0x86,
1478  kServiceTypeNimiqTV4 = 0x89,
1479  kServiceTypeNimiqTV5 = 0x8a,
1480  kServiceTypeNimiqTV6 = 0x8d,
1481  kServiceTypeNimiqTV7 = 0x8f,
1482  kServiceTypeNimiqTV8 = 0x90,
1483  kServiceTypeNimiqTV9 = 0x96,
1484 
1485  };
1486  uint ServiceType(void) const { return m_serviceid; }
1487  bool IsDTV(void) const
1488  {
1489  return ((ServiceType() == kServiceTypeDigitalTelevision) ||
1490  (ServiceType() ==
1491  kServiceTypeAdvancedCodecSDDigitalTelevision) ||
1492  IsHDTV() || IsUHDTV() ||
1493  (ServiceType() == kServiceTypeEchoStarTV1) ||
1494  (ServiceType() == kServiceTypeEchoStarTV2) ||
1495  (ServiceType() == kServiceTypeEchoStarTV3) ||
1496  (ServiceType() == kServiceTypeEchoStarTV4) ||
1497  (ServiceType() == kServiceTypeNimiqTV1) ||
1498  (ServiceType() == kServiceTypeNimiqTV2) ||
1499  (ServiceType() == kServiceTypeNimiqTV3) ||
1500  (ServiceType() == kServiceTypeNimiqTV4) ||
1501  (ServiceType() == kServiceTypeNimiqTV5) ||
1502  (ServiceType() == kServiceTypeNimiqTV6) ||
1503  (ServiceType() == kServiceTypeNimiqTV7) ||
1504  (ServiceType() == kServiceTypeNimiqTV8) ||
1505  (ServiceType() == kServiceTypeNimiqTV9));
1506  }
1507  bool IsDigitalAudio(void) const
1508  {
1509  return ((ServiceType() == kServiceTypeDigitalRadioSound) ||
1510  (ServiceType() == kServiceTypeAdvancedCodecDigitalRadioSound));
1511  }
1512  bool IsHDTV(void) const
1513  {
1514  return
1515  (ServiceType() == kServiceTypeHDTV) ||
1516  (ServiceType() == kServiceTypeAdvancedCodecHDDigitalTelevision) ||
1517  (ServiceType() == kServiceTypeAdvancedCodecFrameCompatiblePlanoStereoscopicHDTelevisionService);
1518  }
1519  bool IsUHDTV(void) const
1520  {
1521  return
1522  (ServiceType() == kServiceTypeUltraHD);
1523  }
1524  bool IsTeletext(void) const
1525  {
1526  return ServiceType() == kServiceTypeDataBroadcast;
1527  }
1528  QString toString(void) const;
1529 
1530  private:
1532 };
1533 
1534 // DVB Bluebook A038 (Sept 2011) p 80
1536 {
1537  public:
1538  ServiceDescriptor(const unsigned char *data, int len = 300) :
1539  MPEGDescriptor(data, len, DescriptorID::service) { }
1540  // Name bits loc expected value
1541  // descriptor_tag 8 0.0 0x48
1542  // descriptor_length 8 1.0
1543 
1544  // service_type 8 2.0
1545  uint ServiceType(void) const { return _data[2]; }
1546  // svc_provider_name_len 8 3.0
1547  uint ServiceProviderNameLength(void) const { return _data[3]; }
1548  // for (i=0;i<N;I++) { char 8 }
1549  QString ServiceProviderName(void) const
1550  { return dvb_decode_text(_data + 4, ServiceProviderNameLength()); }
1551  QString ServiceProviderShortName(void) const
1552  {
1553  return dvb_decode_short_name(_data + 4, ServiceProviderNameLength());
1554  }
1555  // service_name_length 8
1557  { return _data[4 + ServiceProviderNameLength()]; }
1558  // for (i=0;i<N;I++) { char 8 }
1559  QString ServiceName(void) const
1560  {
1561  return dvb_decode_text(_data + 5 + ServiceProviderNameLength(),
1562  ServiceNameLength());
1563  }
1564  QString ServiceShortName(void) const
1565  {
1566  return dvb_decode_short_name(_data + 5 + ServiceProviderNameLength(),
1567  ServiceNameLength());
1568  }
1569  bool IsDTV(void) const
1570  { return ServiceDescriptorMapping(ServiceType()).IsDTV(); }
1571  bool IsDigitalAudio(void) const
1572  { return ServiceDescriptorMapping(ServiceType()).IsDigitalAudio(); }
1573  bool IsHDTV(void) const
1574  { return ServiceDescriptorMapping(ServiceType()).IsHDTV(); }
1575  bool IsTeletext(void) const
1576  { return ServiceDescriptorMapping(ServiceType()).IsTeletext(); }
1577 
1578  QString toString(void) const
1579  {
1580  return QString("ServiceDescriptor: %1 %2").arg(ServiceName())
1581  .arg(ServiceDescriptorMapping(ServiceType()).toString());
1582  }
1583 };
1584 
1585 // DVB Bluebook A038 (Sept 2011) p 82
1587 {
1588  public:
1589  ServiceAvailabilityDescriptor(const unsigned char *data, int len = 300) :
1590  MPEGDescriptor(data, len, DescriptorID::service_availability) { }
1591  // Name bits loc expected value
1592  // descriptor_tag 8 0.0 0x72
1593  // descriptor_length 8 1.0
1594 
1595  // availability_flag 1 2.0
1596  // reserved 7 2.1
1597  // for (i=0;i<N;i++) { cell_id 16 }
1598 };
1599 
1600 // DVB Bluebook A038 (Sept 2011) p 82
1602 {
1603  public:
1604  ServiceListDescriptor(const unsigned char *data, int len = 300) :
1605  MPEGDescriptor(data, len, DescriptorID::service_list) { }
1606  // Name bits loc expected value
1607  // descriptor_tag 8 0.0 0x41
1608  // descriptor_length 8 1.0
1609 
1610  // for (i=0;i<N;I++)
1611  // {
1612  // service_id 16 0.0+p
1613  // service_type 8 2.0+p
1614  // }
1615  uint ServiceCount(void) const { return DescriptorLength() / 3; }
1616 
1618  { return (_data[2+i*3] << 8) | _data[3+i*3]; }
1619 
1620  uint ServiceType(uint i) const { return _data[4+i*3]; }
1621 
1622  QString toString(void) const
1623  {
1624  QString str = QString("ServiceListDescriptor: %1 Services\n")
1625  .arg(ServiceCount());
1626  for (uint i=0; i<ServiceCount(); i++)
1627  {
1628  if (i!=0) str.append("\n");
1629  str.append(QString(" Service (%1) Type%2").arg(ServiceID(i))
1630  .arg(ServiceDescriptorMapping(ServiceType(i)).toString()));
1631  }
1632  return str;
1633  }
1634 };
1635 
1636 // DVB Bluebook A038 (Sept 2011) p 82
1638 {
1639  public:
1640  ServiceMoveDescriptor(const unsigned char *data, int len = 300) :
1641  MPEGDescriptor(data, len, DescriptorID::service_move) { }
1642  // Name bits loc expected value
1643  // descriptor_tag 8 0.0 0x60
1644  // descriptor_length 8 1.0
1645 
1646  // new_original_network_id 16 2.0
1647  // new_transport_stream_id 16 4.0
1648  // new_service_id 16 6.0
1649 };
1650 
1651 // DVB Bluebook A038 (Sept 2011) p 83
1653 {
1654  public:
1655  ShortEventDescriptor(const unsigned char *data, int len = 300) :
1656  MPEGDescriptor(data, len, DescriptorID::short_event) { }
1657  // Name bits loc expected value
1658  // descriptor_tag 8 0.0 0x4d
1659  // descriptor_length 8 1.0
1660 
1661  // ISO_639_language_code 24 2.0
1662  int LanguageKey(void) const
1663  { return iso639_str3_to_key(&_data[2]); }
1664  QString LanguageString(void) const
1665  { return iso639_key_to_str3(LanguageKey()); }
1666  int CanonicalLanguageKey(void) const
1667  { return iso639_key_to_canonical_key(LanguageKey()); }
1668  QString CanonicalLanguageString(void) const
1669  { return iso639_key_to_str3(CanonicalLanguageKey()); }
1670  // event_name_length 8 5.0
1671  uint EventNameLength(void) const { return _data[5]; }
1672  // for (i=0;i<event_name_length;i++) { event_name_char 8 }
1673  QString EventName(void) const
1674  { return dvb_decode_text(&_data[6], _data[5]); }
1675  QString EventShortName(void) const
1676  { return dvb_decode_short_name(&_data[6], _data[5]); }
1677  // text_length 8
1678  uint TextLength(void) const { return _data[6 + _data[5]]; }
1679  // for (i=0;i<text_length;i++) { text_char 8 }
1680  QString Text(void) const
1681  { return dvb_decode_text(&_data[7 + _data[5]], TextLength()); }
1682 
1683  // HACK beg -- Pro7Sat is missing encoding
1684  QString EventName(const unsigned char *encoding_override,
1685  uint encoding_length) const
1686  {
1687  return dvb_decode_text(&_data[6], _data[5],
1688  encoding_override, encoding_length);
1689  }
1690 
1691  QString Text(const unsigned char *encoding_override,
1692  uint encoding_length) const
1693  {
1694  return dvb_decode_text(&_data[7 + _data[5]], TextLength(),
1695  encoding_override, encoding_length);
1696  }
1697  // HACK end -- Pro7Sat is missing encoding
1698 
1699  QString toString(void) const
1700  { return LanguageString() + " : " + EventName() + " : " + Text(); }
1701 };
1702 
1703 // DVB Bluebook A038 (Sept 2011) p 84
1705 {
1706  public:
1707  ShortSmoothingBufferDescriptor(const unsigned char *data, int len = 300) :
1708  MPEGDescriptor(data, len, DescriptorID::short_smoothing_buffer) { }
1709  // Name bits loc expected value
1710  // descriptor_tag 8 0.0 0x61
1711  // descriptor_length 8 1.0
1712 
1713  // sb_size 2 2.0
1714  // sb_leak_rate 6 2.2
1715  // for (i=0; i<N; i++)
1716  // { DVB_reserved 8 }
1717 };
1718 
1719 // DVB Bluebook A038 (Sept 2011) p 85
1723 {
1724  public:
1725  StreamIdentifierDescriptor(const unsigned char *data, int len = 300) :
1726  MPEGDescriptor(data, len, DescriptorID::stream_identifier, 1) { }
1727  // Name bits loc expected value
1728  // descriptor_tag 8 0.0 0x52
1729  // descriptor_length 8 1.0 0x01
1730 
1731  // component_tag 8 2.0
1732  uint ComponentTag(void) const { return _data[2]; }
1733  QString toString(void) const
1734  {
1735  return QString("Stream Identifier Descriptor (0x52): ComponentTag=0x%1")
1736  .arg(ComponentTag(),1,16);
1737  }
1738 };
1739 
1740 // DVB Bluebook A038 (Sept 2011) p 86
1742 {
1743  public:
1744  StuffingDescriptor(const unsigned char *data, int len = 300) :
1745  MPEGDescriptor(data, len, DescriptorID::dvb_stuffing) { }
1746  // Name bits loc expected value
1747  // descriptor_tag 8 0.0 0x42
1748  // descriptor_length 8 1.0
1749  // stuffing_byte * 2.0
1750  QString toString(void) const
1751  {
1752  return QString("Stuffing Descriptor (0x42) length(%1)")
1753  .arg(DescriptorLength());
1754  }
1755 };
1756 
1757 // DVB Bluebook A038 (Sept 2011) p 86
1759 {
1760  public:
1761  SubtitlingDescriptor(const unsigned char *data, int len = 300) :
1762  MPEGDescriptor(data, len, DescriptorID::subtitling) { }
1763  // Name bits loc expected value
1764  // descriptor_tag 8 0.0 0x59
1765  // descriptor_length 8 1.0
1766 
1767  uint StreamCount(void) const { return DescriptorLength() >> 3; }
1768  // for (i= 0;i<N;I++)
1769  // {
1770  // ISO_639_language_code 24 0.0+(i*8)
1771  int LanguageKey(uint i) const
1772  { return iso639_str3_to_key(&_data[2 + (i<<3)]); }
1773  QString LanguageString(uint i) const
1774  { return iso639_key_to_str3(LanguageKey(i)); }
1776  { return iso639_key_to_canonical_key(LanguageKey(i)); }
1778  { return iso639_key_to_str3(CanonicalLanguageKey(i)); }
1779 
1780  // subtitling_type 8 3.0+(i*8)
1782  { return _data[5 + (i<<3)]; }
1783  // composition_page_id 16 4.0+(i*8)
1785  { return (_data[6 + (i<<3)] << 8) | _data[7 + (i<<3)]; }
1786  // ancillary_page_id 16 6.0+(i*8)
1788  { return (_data[8 + (i<<3)] << 8) | _data[9 + (i<<3)]; }
1789  // } 8.0
1790 };
1791 
1792 // DVB Bluebook A038 (Sept 2011) p 87
1794 {
1795  public:
1796  TelephoneDescriptor(const unsigned char *data, int len = 300) :
1797  MPEGDescriptor(data, len, DescriptorID::telephone) { }
1798  // Name bits loc expected value
1799  // descriptor_tag 8 0.0 0x57
1800  // descriptor_length 8 1.0
1801 
1802  // reserved_future_use 2 2.0
1803  // foreign_availability 1 2.2
1804  // connection_type 5 2.3
1805  // reserved_future_use 1 3.0
1806  // country_prefix_length 2 3.1
1807  // i18n_area_code_len 3 3.4
1808  // operator_code_length 2 3.6
1809  // reserved_future_use 1 3.7
1810  // national_area_code_len 3 4.0
1811  // core_number_length 4 4.4
1812  //
1813  // for (i=0; i<N; i++)
1814  // { country_prefix_char 8 }
1815  // for (i=0; i<N; i++)
1816  // { international_area_code_char 8 }
1817  // for (i=0; i<N; i++)
1818  // { operator_code_char 8 }
1819  // for (i=0; i<N; i++)
1820  // { national_area_code_char 8 }
1821  // for (i=0; i<N; i++)
1822  // { core_number_char 8 }
1823 };
1824 
1825 // DVB Bluebook A038 (Sept 2011) p 88
1827 {
1828  public:
1829  TeletextDescriptor(const unsigned char *data, int len = 300) :
1830  MPEGDescriptor(data, len, DescriptorID::teletext) { }
1831  // Name bits loc expected value
1832  // descriptor_tag 8 0.0 0x56
1833  // descriptor_length 8 1.0
1834 
1835  uint StreamCount(void) const { return DescriptorLength() / 5; }
1836 
1837  // for (i=0; i<N; i++)
1838  // {
1839  // ISO_639_language_code 24 0.0
1840  int LanguageKey(uint i) const
1841  { return iso639_str3_to_key(&_data[2 + (i*5)]); }
1842  QString LanguageString(uint i) const
1843  { return iso639_key_to_str3(LanguageKey(i)); }
1845  { return iso639_key_to_canonical_key(LanguageKey(i)); }
1847  { return iso639_key_to_str3(CanonicalLanguageKey(i)); }
1848  // teletext_type 5 3.0
1850  { return _data[5 + (i*5)] >> 3; }
1851  // teletext_magazine_num 3 3.5
1853  { return _data[5 + (i*5)] & 0x7; }
1854  // teletext_page_num 8 4.0
1856  { return _data[6 + (i*5)]; }
1857  // } 5.0
1858  QString toString(void) const;
1859 };
1860 
1861 // DVB Bluebook A038 (Sept 2011) p 89
1863 {
1864  public:
1865  TimeShiftedEventDescriptor(const unsigned char *data, int len = 300) :
1866  MPEGDescriptor(data, len, DescriptorID::time_shifted_event) { }
1867  // Name bits loc expected value
1868  // descriptor_tag 8 0.0 0x4f
1869  // descriptor_length 8 1.0
1870 
1871  // reference_service_id 16 2.0
1872  // reference_event_id 16 4.0
1873 };
1874 
1875 // DVB Bluebook A038 (Sept 2011) p 90
1877 {
1878  public:
1879  TimeShiftedServiceDescriptor(const unsigned char *data, int len = 300) :
1880  MPEGDescriptor(data, len, DescriptorID::dvb_time_shifted_service) { }
1881  // Name bits loc expected value
1882  // descriptor_tag 8 0.0 0x4c
1883  // descriptor_length 8 1.0
1884 
1885  // reference_service_id 16 2.0
1886 };
1887 
1888 // DVB Bluebook A038 (Sept 2011) p 90
1890 {
1891  public:
1892  TransportStreamDescriptor(const unsigned char *data, int len = 300) :
1893  MPEGDescriptor(data, len, DescriptorID::transport_stream) { }
1894  // Name bits loc expected value
1895  // descriptor_tag 8 0.0 0x67
1896  // descriptor_length 8 1.0
1897 
1898  // for (i=0; i<N; i++) { byte 8 }
1899  QString Data(void) const
1900  { return dvb_decode_text(&_data[2], DescriptorLength()); }
1901  QString toString(void) const
1902  { return QString("TransportStreamDescriptor data(%1)").arg(Data()); }
1903 };
1904 
1905 // DVB Bluebook A038 (Sept 2011) p 91
1907 {
1908  public:
1909  VBIDataDescriptor(const unsigned char *data, int len = 300) :
1910  MPEGDescriptor(data, len, DescriptorID::vbi_data) { }
1911  // Name bits loc expected value
1912  // descriptor_tag 8 0.0 0x45
1913  // descriptor_length 8 1.0
1914 
1915  // for (i=0; i<N; i++)
1916  // {
1917  // data_service_id 8 0.0+p
1918  // data_service_length 8 1.0+p
1919  // if ((data_service_id&0x7) && data_service_id!=0x3))
1920  // {
1921  // for (i=0; i<N; i++)
1922  // {
1923  // reserved 2 2.0+p2
1924  // field_parity 1 2.2+p2
1925  // line_offset 5 2.3+p2
1926  // }
1927  // }
1928  // else
1929  // {
1930  // for (i=0; i<N; i++) { reserved 8 }
1931  // }
1932  // }
1933 };
1934 
1935 // DVB Bluebook A038 (Sept 2011) p 92
1937 {
1938  public:
1939  VBITeletextDescriptor(const unsigned char *data, int len = 300) :
1940  MPEGDescriptor(data, len, DescriptorID::vbi_teletext) { }
1941  // Name bits loc expected value
1942  // descriptor_tag 8 0.0 0x46
1943  // descriptor_length 8 1.0
1944 
1945  // for (i=0;i<N;i++)
1946  // {
1947  // ISO_639_language_code 24 0.0+p
1948  // teletext_type 5 3.0+p
1949  // teletext_magazine_num 3 3.5+p
1950  // teletext_page_num 8 4.0+p
1951  // } 5.0
1952 };
1953 
1954 // DVB Bluebook A038 (Sept 2011) p 119
1956 {
1957  public:
1958  PartialTransportStreamDescriptor(const unsigned char *data, int len = 300) :
1959  MPEGDescriptor(data, len, DescriptorID::partial_transport_stream) { }
1960  // Name bits loc expected value
1961  // descriptor_tag 8 0.0 0x63
1962  // descriptor_length 8 1.0
1963 
1964  // DVB_reserved_future_use 2 2.0
1965  // peak_rate 22 2.2
1966  uint PeakRate(void) const
1967  { return (_data[2] & 0x3f) << 16 | _data[3] | _data[4]; }
1968  // DVB_reserved_future_use 2 5.0
1969  // min_overall_smooth_rate 22 5.2
1970  uint SmoothRate(void) const
1971  { return (_data[5] & 0x3f) << 16 | _data[6] | _data[7]; }
1972  // DVB_reserved_future_use 2 8.0
1973  // max_overall_smooth_buf 14 8.2
1974  uint SmoothBuf(void) const { return ((_data[8] & 0x3f) << 8) | _data[9]; }
1975  QString toString(void) const;
1976 };
1977 
1978 
1979 // a_52a.pdf p125 Table A7 (for DVB)
1981 {
1982  public:
1983  AC3Descriptor(const unsigned char *data, int len = 300) :
1984  MPEGDescriptor(data, len, DescriptorID::ac3) { }
1985  // Name bits loc expected value
1986  // descriptor_tag 8 0.0 0x6A
1987  // descriptor_length 8 1.0
1988 
1989  // component_type_flag 1 2.0
1990  bool HasComponentType(void) const { return _data[2] & 0x80; }
1991  // bsid_flag 1 2.1
1992  bool HasBSID(void) const { return _data[2] & 0x40; }
1993  // mainid_flag 1 2.2
1994  bool HasMainID(void) const { return _data[2] & 0x20; }
1995  // asvc_flag 1 2.3
1996  bool HasASVC(void) const { return _data[2] & 0x10; }
1997  // reserved_flags 4 2.4
1998  // if (component_type_flag == 1)
1999  // { component_type 8 uimsbf }
2000  uint ComponentType(void) const { return _data[3]; }
2001  // if (bsid_flag == 1)
2002  // { bsid 8 uimsbf }
2003  uint BSID(void) const
2004  { return (HasComponentType()) ? _data[4] : _data[3]; }
2005  // if (mainid_flag == 1)
2006  // { mainid 8 uimsbf }
2007  uint MainID(void) const
2008  {
2009  int offset = 3;
2010  offset += (HasComponentType()) ? 1 : 0;
2011  offset += (HasBSID()) ? 1 : 0;
2012  return _data[offset];
2013  }
2014  // if (asvc_flag==1)
2015  // { asvc 8 uimsbf }
2016  uint ASVC(void) const
2017  {
2018  int offset = 3;
2019  offset += (HasComponentType()) ? 1 : 0;
2020  offset += (HasBSID()) ? 1 : 0;
2021  offset += (HasMainID()) ? 1 : 0;
2022  return _data[offset];
2023  }
2024  // for (I=0;I<N;I++)
2025  // { additional_info[i] N*8 uimsbf }
2026  //};
2027  QString toString(void) const;
2028 };
2029 
2030 static QString coderate_inner(uint cr)
2031 {
2032  switch (cr)
2033  {
2034  case 0x0: return "auto"; // not actually defined in spec
2035  case 0x1: return "1/2";
2036  case 0x2: return "2/3";
2037  case 0x3: return "3/4";
2038  case 0x4: return "5/6";
2039  case 0x5: return "7/8";
2040  case 0x8: return "8/9";
2041  case 0xf: return "none";
2042  default: return "auto"; // not actually defined in spec
2043  }
2044 }
2045 
2055 {
2056  public:
2057  DVBLogicalChannelDescriptor(const unsigned char *data, int len = 300) :
2058  MPEGDescriptor(data, len, PrivateDescriptorID::dvb_logical_channel_descriptor) { }
2059  // Name bits loc expected value
2060  // descriptor_tag 8 0.0 0x83
2061  // descriptor_length 8 1.0
2062 
2063  uint ChannelCount(void) const { return DescriptorLength() >> 2; }
2064 
2066  { return (_data[2 + (i<<2)] << 8) | _data[3 + (i<<2)]; }
2067 
2069  { return ((_data[4 + (i<<2)] << 8) | _data[5 + (i<<2)]) & 0x3ff; }
2070 
2071  QString toString(void) const;
2072 };
2073 
2074 // ETSI TS 102 323 (TV Anytime)
2076 {
2077  public:
2078  DVBContentIdentifierDescriptor(const unsigned char *data, int len = 300) :
2079  MPEGDescriptor(data, len, DescriptorID::dvb_content_identifier)
2080  {
2081  size_t length;
2082  size_t count = 0;
2083  uint8_t position = 2;
2084 
2085  memset ((void *) m_crid, 0, sizeof(m_crid));
2086 
2087  while (_data[1] >= position)
2088  {
2089  length = _data[position+1];
2090  m_crid[count] = &_data[position];
2091  count++;
2092  position+=length+2;
2093  }
2094  m_cridCount = count;
2095  }
2096  // Name bits loc expected value
2097  // descriptor_tag 8 0.0 0x76
2098  // descriptor_length 8 1.0
2099 
2100  uint ContentType(size_t n=0) const { return m_crid[n][0] >> 2; }
2101 
2102  uint ContentEncoding(size_t n=0) const { return m_crid[n][0] & 0x03; }
2103 
2104  // A content identifier is a URI. It may contain UTF-8 encoded using %XX.
2105  QString ContentId(size_t n=0) const
2106  {
2107  int length = m_crid[n][1];
2108  int positionOfHash = length-1;
2109  while (positionOfHash >= 0) {
2110  if (m_crid[n][2 + positionOfHash] == '#') {
2111  length = positionOfHash; /* remove the hash and the following IMI */
2112  break;
2113  }
2114  positionOfHash--;
2115  }
2116  return QString::fromLatin1((const char *)&m_crid[n][2], length);
2117  }
2118 
2119  size_t CRIDCount() const
2120  {
2121  return m_cridCount;
2122  }
2123 
2124  private:
2125  size_t m_cridCount;
2126  const uint8_t *m_crid[8];
2127 };
2128 
2129 // ETSI TS 102 323 (TV Anytime)
2131 {
2132  public:
2133  DefaultAuthorityDescriptor(const unsigned char *data, int len = 300) :
2134  MPEGDescriptor(data, len, DescriptorID::default_authority) { }
2135  // Name bits loc expected value
2136  // descriptor_tag 8 0.0 0x73
2137  // descriptor_length 8 1.0
2138 
2139  QString DefaultAuthority(void) const
2140  {
2141  return QString::fromLatin1((const char *)_data+2, _data[1]);
2142  }
2143 
2144  QString toString(void) const
2145  {
2146  return QString("DefaultAuthorityDescriptor: Authority(%1)")
2147  .arg(DefaultAuthority());
2148  }
2149 };
2150 
2151 /*
2152  * private UPC Cablecom (Austria) episode descriptor for Horizon middleware
2153  */
2155 {
2156  public:
2157  PrivateUPCCablecomEpisodeTitleDescriptor(const unsigned char *data, int len = 300) :
2158  MPEGDescriptor(data, len, PrivateDescriptorID::upc_event_episode_title) { }
2159  // Name bits loc expected value
2160  // descriptor_tag 8 0.0 0xa7
2161  // descriptor_length 8 1.0
2162 
2163  // ISO_639_language_code 24 2.0
2164  int LanguageKey(void) const
2165  {
2166  return iso639_str3_to_key(&_data[2]);
2167  }
2168  QString LanguageString(void) const
2169  {
2170  return iso639_key_to_str3(LanguageKey());
2171  }
2172  int CanonicalLanguageKey(void) const
2173  {
2174  return iso639_key_to_canonical_key(LanguageKey());
2175  }
2176  QString CanonicalLanguageString(void) const
2177  {
2178  return iso639_key_to_str3(CanonicalLanguageKey());
2179  }
2180 
2181  uint TextLength(void) const
2182  {
2183  return _data[1] - 3;
2184  }
2185 
2186  QString Text(void) const
2187  {
2188  return dvb_decode_text(&_data[5], TextLength());
2189  }
2190 };
2191 
2192 #endif
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)
QString BouquetName(void) const
QString toString(void) const
ContentDescriptor(const unsigned char *data, int len=300)
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)
NVODReferenceDescriptor(const unsigned char *data, int len=300)
MultilingualBouquetNameDescriptor(const unsigned char *data, int len=300)
uint ServiceNameLength(void) const
BouquetNameDescriptor(const unsigned char *data, int len=300)
QString EventName(void) const
QString toString(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
QString toString(void) const
ScramblingDescriptor(const unsigned char *data, int len=300)
QString BouquetShortName(void) const
int LanguageKey(void) const
uint ProgramIdLabel(void) const
unsigned long long Frequency(uint i) const
unsigned char AC3Properties(void) const
int CASystemId(uint i) const
uint SubtitleType(uint i) const
uint UserNibble(uint i) const
uint DataBroadCastId(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&#39;...
QString LanguageString(void) const
DefaultAuthorityDescriptor(const unsigned char *data, int len=300)
QString CountryNames(void) const
bool IsUHDTV(void) const
QString FECInnerString(void) const
DVB Logical Channel Descriptor.
QString toString(void) const
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:136
ServiceDescriptor(const unsigned char *data, int len=300)
PartialTransportStreamDescriptor(const unsigned char *data, int len=300)
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
QString toString(void) const
unsigned char MP2Properties(void) const
uint ServiceID(uint i) const
QString toString(void) const
uint ScramblingMode(void) const
int iso639_key_to_canonical_key(int iso639_2)
Definition: iso639.cpp:122
AnnouncementSupportDescriptor(const unsigned char *data, int len=300)
uint ServiceType(uint i) const
bool IsSubtitle(void) const
CountryAvailabilityDescriptor(const unsigned char *data, int len=300)
TimeShiftedServiceDescriptor(const unsigned char *data, int len=300)
uint MainID(void) const
uint CountryRegionId(uint i) const
QString Data(void) const
ServiceMoveDescriptor(const unsigned char *data, int len=300)
uint ServiceID(void) const
__u8 data[42]
Definition: videodev2.h:1039
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)
QString ServiceProviderShortName(void) const
voidpf uLong offset
Definition: ioapi.h:142
uint ASVC(void) const
uint DescriptorNumber(void) const
SubtitlingDescriptor(const unsigned char *data, int len=300)
TerrestrialDeliverySystemDescriptor(const unsigned char *data, int len=300)
uint StreamCount(void) const
int LanguageKey(void) const
LocalTimeOffsetDescriptor(const unsigned char *data, int len=300)
uint Count(void) const
static int x2
Definition: mythsocket.cpp:61
uint TeletextType(uint i) const
bool IsTeletext(void) const
QString toString(void) const
QString Text(void) const
DVBContentIdentifierDescriptor(const unsigned char *data, int len=300)
uint ChannelNumber(uint i) const
bool IsVideo(void) const
uint SelectorLength(void) const
uint TextLength(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)
VBITeletextDescriptor(const unsigned char *data, int len=300)
QString ModulationString(void) const
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
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
FrequencyListDescriptor(const unsigned char *data, int len=300)
uint UserNibble1(uint i) const
bool HasBSID(void) const
MultilingualNetworkNameDescriptor(const unsigned char *data, int len=300)
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 toString(void) const
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
QString toString(void) const
QString toString(void) const
ServiceDescriptorMapping(const uint serviceid)
QString CountryCodeString(uint i) const
bool IsEast(void) const
west_east_flag 1 8.0
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 Text(void) const
bool IsTeletext(void) const
uint TargetEventID(void) const
uint TeletextMagazineNum(uint i) const
QString toString(void) 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
QString toString(void) const
bool IsEventSimulcast(void) const
uint CompositionPageID(uint i) const
NetworkNameDescriptor(const unsigned char *data, int len=300)
uint TextLength(void) const
bool HasMobileInitialServiceID(void) const
QString TransmissionModeString(void) const
uint LastNumber(void) const
uint OriginalNetworkID() const
QString FECOuterString(void) const
QString LanguageString(void) const
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
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
static QString iso639_key_to_str3(int code)
Definition: iso639.h:46
uint MobileOriginType(void) const
QString toString(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)
QString toString(void) const
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
QString toString(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
uint ServiceCount(void) const
uint MobileHandOverType(void) 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
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