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  kServiceTypeEchoStarTV1 = 0x91,
1471  kServiceTypeEchoStarTV2 = 0x9a,
1472  kServiceTypeEchoStarTV3 = 0xa4,
1473  kServiceTypeEchoStarTV4 = 0xa6,
1474  kServiceTypeNimiqTV1 = 0x81,
1475  kServiceTypeNimiqTV2 = 0x85,
1476  kServiceTypeNimiqTV3 = 0x86,
1477  kServiceTypeNimiqTV4 = 0x89,
1478  kServiceTypeNimiqTV5 = 0x8a,
1479  kServiceTypeNimiqTV6 = 0x8d,
1480  kServiceTypeNimiqTV7 = 0x8f,
1481  kServiceTypeNimiqTV8 = 0x90,
1482  kServiceTypeNimiqTV9 = 0x96,
1483 
1484  };
1485  uint ServiceType(void) const { return m_serviceid; }
1486  bool IsDTV(void) const
1487  {
1488  return ((ServiceType() == kServiceTypeDigitalTelevision) ||
1489  (ServiceType() ==
1490  kServiceTypeAdvancedCodecSDDigitalTelevision) ||
1491  IsHDTV() ||
1492  (ServiceType() == kServiceTypeEchoStarTV1) ||
1493  (ServiceType() == kServiceTypeEchoStarTV2) ||
1494  (ServiceType() == kServiceTypeEchoStarTV3) ||
1495  (ServiceType() == kServiceTypeEchoStarTV4) ||
1496  (ServiceType() == kServiceTypeNimiqTV1) ||
1497  (ServiceType() == kServiceTypeNimiqTV2) ||
1498  (ServiceType() == kServiceTypeNimiqTV3) ||
1499  (ServiceType() == kServiceTypeNimiqTV4) ||
1500  (ServiceType() == kServiceTypeNimiqTV5) ||
1501  (ServiceType() == kServiceTypeNimiqTV6) ||
1502  (ServiceType() == kServiceTypeNimiqTV7) ||
1503  (ServiceType() == kServiceTypeNimiqTV8) ||
1504  (ServiceType() == kServiceTypeNimiqTV9));
1505  }
1506  bool IsDigitalAudio(void) const
1507  {
1508  return ((ServiceType() == kServiceTypeDigitalRadioSound) ||
1509  (ServiceType() == kServiceTypeAdvancedCodecDigitalRadioSound));
1510  }
1511  bool IsHDTV(void) const
1512  {
1513  return
1514  (ServiceType() == kServiceTypeHDTV) ||
1515  (ServiceType() == kServiceTypeAdvancedCodecHDDigitalTelevision) ||
1516  (ServiceType() == kServiceTypeAdvancedCodecFrameCompatiblePlanoStereoscopicHDTelevisionService);
1517  }
1518  bool IsTeletext(void) const
1519  {
1520  return ServiceType() == kServiceTypeDataBroadcast;
1521  }
1522  QString toString(void) const;
1523 
1524  private:
1526 };
1527 
1528 // DVB Bluebook A038 (Sept 2011) p 80
1530 {
1531  public:
1532  ServiceDescriptor(const unsigned char *data, int len = 300) :
1533  MPEGDescriptor(data, len, DescriptorID::service) { }
1534  // Name bits loc expected value
1535  // descriptor_tag 8 0.0 0x48
1536  // descriptor_length 8 1.0
1537 
1538  // service_type 8 2.0
1539  uint ServiceType(void) const { return _data[2]; }
1540  // svc_provider_name_len 8 3.0
1541  uint ServiceProviderNameLength(void) const { return _data[3]; }
1542  // for (i=0;i<N;I++) { char 8 }
1543  QString ServiceProviderName(void) const
1544  { return dvb_decode_text(_data + 4, ServiceProviderNameLength()); }
1545  QString ServiceProviderShortName(void) const
1546  {
1547  return dvb_decode_short_name(_data + 4, ServiceProviderNameLength());
1548  }
1549  // service_name_length 8
1551  { return _data[4 + ServiceProviderNameLength()]; }
1552  // for (i=0;i<N;I++) { char 8 }
1553  QString ServiceName(void) const
1554  {
1555  return dvb_decode_text(_data + 5 + ServiceProviderNameLength(),
1556  ServiceNameLength());
1557  }
1558  QString ServiceShortName(void) const
1559  {
1560  return dvb_decode_short_name(_data + 5 + ServiceProviderNameLength(),
1561  ServiceNameLength());
1562  }
1563  bool IsDTV(void) const
1564  { return ServiceDescriptorMapping(ServiceType()).IsDTV(); }
1565  bool IsDigitalAudio(void) const
1566  { return ServiceDescriptorMapping(ServiceType()).IsDigitalAudio(); }
1567  bool IsHDTV(void) const
1568  { return ServiceDescriptorMapping(ServiceType()).IsHDTV(); }
1569  bool IsTeletext(void) const
1570  { return ServiceDescriptorMapping(ServiceType()).IsTeletext(); }
1571 
1572  QString toString(void) const
1573  {
1574  return QString("ServiceDescriptor: %1 %2").arg(ServiceName())
1575  .arg(ServiceDescriptorMapping(ServiceType()).toString());
1576  }
1577 };
1578 
1579 // DVB Bluebook A038 (Sept 2011) p 82
1581 {
1582  public:
1583  ServiceAvailabilityDescriptor(const unsigned char *data, int len = 300) :
1584  MPEGDescriptor(data, len, DescriptorID::service_availability) { }
1585  // Name bits loc expected value
1586  // descriptor_tag 8 0.0 0x72
1587  // descriptor_length 8 1.0
1588 
1589  // availability_flag 1 2.0
1590  // reserved 7 2.1
1591  // for (i=0;i<N;i++) { cell_id 16 }
1592 };
1593 
1594 // DVB Bluebook A038 (Sept 2011) p 82
1596 {
1597  public:
1598  ServiceListDescriptor(const unsigned char *data, int len = 300) :
1599  MPEGDescriptor(data, len, DescriptorID::service_list) { }
1600  // Name bits loc expected value
1601  // descriptor_tag 8 0.0 0x41
1602  // descriptor_length 8 1.0
1603 
1604  // for (i=0;i<N;I++)
1605  // {
1606  // service_id 16 0.0+p
1607  // service_type 8 2.0+p
1608  // }
1609  uint ServiceCount(void) const { return DescriptorLength() / 3; }
1610 
1612  { return (_data[2+i*3] << 8) | _data[3+i*3]; }
1613 
1614  uint ServiceType(uint i) const { return _data[4+i*3]; }
1615 
1616  QString toString(void) const
1617  {
1618  QString str = QString("ServiceListDescriptor: %1 Services\n")
1619  .arg(ServiceCount());
1620  for (uint i=0; i<ServiceCount(); i++)
1621  {
1622  if (i!=0) str.append("\n");
1623  str.append(QString(" Service (%1) Type%2").arg(ServiceID(i))
1624  .arg(ServiceDescriptorMapping(ServiceType(i)).toString()));
1625  }
1626  return str;
1627  }
1628 };
1629 
1630 // DVB Bluebook A038 (Sept 2011) p 82
1632 {
1633  public:
1634  ServiceMoveDescriptor(const unsigned char *data, int len = 300) :
1635  MPEGDescriptor(data, len, DescriptorID::service_move) { }
1636  // Name bits loc expected value
1637  // descriptor_tag 8 0.0 0x60
1638  // descriptor_length 8 1.0
1639 
1640  // new_original_network_id 16 2.0
1641  // new_transport_stream_id 16 4.0
1642  // new_service_id 16 6.0
1643 };
1644 
1645 // DVB Bluebook A038 (Sept 2011) p 83
1647 {
1648  public:
1649  ShortEventDescriptor(const unsigned char *data, int len = 300) :
1650  MPEGDescriptor(data, len, DescriptorID::short_event) { }
1651  // Name bits loc expected value
1652  // descriptor_tag 8 0.0 0x4d
1653  // descriptor_length 8 1.0
1654 
1655  // ISO_639_language_code 24 2.0
1656  int LanguageKey(void) const
1657  { return iso639_str3_to_key(&_data[2]); }
1658  QString LanguageString(void) const
1659  { return iso639_key_to_str3(LanguageKey()); }
1660  int CanonicalLanguageKey(void) const
1661  { return iso639_key_to_canonical_key(LanguageKey()); }
1662  QString CanonicalLanguageString(void) const
1663  { return iso639_key_to_str3(CanonicalLanguageKey()); }
1664  // event_name_length 8 5.0
1665  uint EventNameLength(void) const { return _data[5]; }
1666  // for (i=0;i<event_name_length;i++) { event_name_char 8 }
1667  QString EventName(void) const
1668  { return dvb_decode_text(&_data[6], _data[5]); }
1669  QString EventShortName(void) const
1670  { return dvb_decode_short_name(&_data[6], _data[5]); }
1671  // text_length 8
1672  uint TextLength(void) const { return _data[6 + _data[5]]; }
1673  // for (i=0;i<text_length;i++) { text_char 8 }
1674  QString Text(void) const
1675  { return dvb_decode_text(&_data[7 + _data[5]], TextLength()); }
1676 
1677  // HACK beg -- Pro7Sat is missing encoding
1678  QString EventName(const unsigned char *encoding_override,
1679  uint encoding_length) const
1680  {
1681  return dvb_decode_text(&_data[6], _data[5],
1682  encoding_override, encoding_length);
1683  }
1684 
1685  QString Text(const unsigned char *encoding_override,
1686  uint encoding_length) const
1687  {
1688  return dvb_decode_text(&_data[7 + _data[5]], TextLength(),
1689  encoding_override, encoding_length);
1690  }
1691  // HACK end -- Pro7Sat is missing encoding
1692 
1693  QString toString(void) const
1694  { return LanguageString() + " : " + EventName() + " : " + Text(); }
1695 };
1696 
1697 // DVB Bluebook A038 (Sept 2011) p 84
1699 {
1700  public:
1701  ShortSmoothingBufferDescriptor(const unsigned char *data, int len = 300) :
1702  MPEGDescriptor(data, len, DescriptorID::short_smoothing_buffer) { }
1703  // Name bits loc expected value
1704  // descriptor_tag 8 0.0 0x61
1705  // descriptor_length 8 1.0
1706 
1707  // sb_size 2 2.0
1708  // sb_leak_rate 6 2.2
1709  // for (i=0; i<N; i++)
1710  // { DVB_reserved 8 }
1711 };
1712 
1713 // DVB Bluebook A038 (Sept 2011) p 85
1717 {
1718  public:
1719  StreamIdentifierDescriptor(const unsigned char *data, int len = 300) :
1720  MPEGDescriptor(data, len, DescriptorID::stream_identifier, 1) { }
1721  // Name bits loc expected value
1722  // descriptor_tag 8 0.0 0x52
1723  // descriptor_length 8 1.0 0x01
1724 
1725  // component_tag 8 2.0
1726  uint ComponentTag(void) const { return _data[2]; }
1727  QString toString(void) const
1728  {
1729  return QString("Stream Identifier Descriptor (0x52): ComponentTag=0x%1")
1730  .arg(ComponentTag(),1,16);
1731  }
1732 };
1733 
1734 // DVB Bluebook A038 (Sept 2011) p 86
1736 {
1737  public:
1738  StuffingDescriptor(const unsigned char *data, int len = 300) :
1739  MPEGDescriptor(data, len, DescriptorID::dvb_stuffing) { }
1740  // Name bits loc expected value
1741  // descriptor_tag 8 0.0 0x42
1742  // descriptor_length 8 1.0
1743  // stuffing_byte * 2.0
1744  QString toString(void) const
1745  {
1746  return QString("Stuffing Descriptor (0x42) length(%1)")
1747  .arg(DescriptorLength());
1748  }
1749 };
1750 
1751 // DVB Bluebook A038 (Sept 2011) p 86
1753 {
1754  public:
1755  SubtitlingDescriptor(const unsigned char *data, int len = 300) :
1756  MPEGDescriptor(data, len, DescriptorID::subtitling) { }
1757  // Name bits loc expected value
1758  // descriptor_tag 8 0.0 0x59
1759  // descriptor_length 8 1.0
1760 
1761  uint StreamCount(void) const { return DescriptorLength() >> 3; }
1762  // for (i= 0;i<N;I++)
1763  // {
1764  // ISO_639_language_code 24 0.0+(i*8)
1765  int LanguageKey(uint i) const
1766  { return iso639_str3_to_key(&_data[2 + (i<<3)]); }
1767  QString LanguageString(uint i) const
1768  { return iso639_key_to_str3(LanguageKey(i)); }
1770  { return iso639_key_to_canonical_key(LanguageKey(i)); }
1772  { return iso639_key_to_str3(CanonicalLanguageKey(i)); }
1773 
1774  // subtitling_type 8 3.0+(i*8)
1776  { return _data[5 + (i<<3)]; }
1777  // composition_page_id 16 4.0+(i*8)
1779  { return (_data[6 + (i<<3)] << 8) | _data[7 + (i<<3)]; }
1780  // ancillary_page_id 16 6.0+(i*8)
1782  { return (_data[8 + (i<<3)] << 8) | _data[9 + (i<<3)]; }
1783  // } 8.0
1784 };
1785 
1786 // DVB Bluebook A038 (Sept 2011) p 87
1788 {
1789  public:
1790  TelephoneDescriptor(const unsigned char *data, int len = 300) :
1791  MPEGDescriptor(data, len, DescriptorID::telephone) { }
1792  // Name bits loc expected value
1793  // descriptor_tag 8 0.0 0x57
1794  // descriptor_length 8 1.0
1795 
1796  // reserved_future_use 2 2.0
1797  // foreign_availability 1 2.2
1798  // connection_type 5 2.3
1799  // reserved_future_use 1 3.0
1800  // country_prefix_length 2 3.1
1801  // i18n_area_code_len 3 3.4
1802  // operator_code_length 2 3.6
1803  // reserved_future_use 1 3.7
1804  // national_area_code_len 3 4.0
1805  // core_number_length 4 4.4
1806  //
1807  // for (i=0; i<N; i++)
1808  // { country_prefix_char 8 }
1809  // for (i=0; i<N; i++)
1810  // { international_area_code_char 8 }
1811  // for (i=0; i<N; i++)
1812  // { operator_code_char 8 }
1813  // for (i=0; i<N; i++)
1814  // { national_area_code_char 8 }
1815  // for (i=0; i<N; i++)
1816  // { core_number_char 8 }
1817 };
1818 
1819 // DVB Bluebook A038 (Sept 2011) p 88
1821 {
1822  public:
1823  TeletextDescriptor(const unsigned char *data, int len = 300) :
1824  MPEGDescriptor(data, len, DescriptorID::teletext) { }
1825  // Name bits loc expected value
1826  // descriptor_tag 8 0.0 0x56
1827  // descriptor_length 8 1.0
1828 
1829  uint StreamCount(void) const { return DescriptorLength() / 5; }
1830 
1831  // for (i=0; i<N; i++)
1832  // {
1833  // ISO_639_language_code 24 0.0
1834  int LanguageKey(uint i) const
1835  { return iso639_str3_to_key(&_data[2 + (i*5)]); }
1836  QString LanguageString(uint i) const
1837  { return iso639_key_to_str3(LanguageKey(i)); }
1839  { return iso639_key_to_canonical_key(LanguageKey(i)); }
1841  { return iso639_key_to_str3(CanonicalLanguageKey(i)); }
1842  // teletext_type 5 3.0
1844  { return _data[5 + (i*5)] >> 3; }
1845  // teletext_magazine_num 3 3.5
1847  { return _data[5 + (i*5)] & 0x7; }
1848  // teletext_page_num 8 4.0
1850  { return _data[6 + (i*5)]; }
1851  // } 5.0
1852  QString toString(void) const;
1853 };
1854 
1855 // DVB Bluebook A038 (Sept 2011) p 89
1857 {
1858  public:
1859  TimeShiftedEventDescriptor(const unsigned char *data, int len = 300) :
1860  MPEGDescriptor(data, len, DescriptorID::time_shifted_event) { }
1861  // Name bits loc expected value
1862  // descriptor_tag 8 0.0 0x4f
1863  // descriptor_length 8 1.0
1864 
1865  // reference_service_id 16 2.0
1866  // reference_event_id 16 4.0
1867 };
1868 
1869 // DVB Bluebook A038 (Sept 2011) p 90
1871 {
1872  public:
1873  TimeShiftedServiceDescriptor(const unsigned char *data, int len = 300) :
1874  MPEGDescriptor(data, len, DescriptorID::dvb_time_shifted_service) { }
1875  // Name bits loc expected value
1876  // descriptor_tag 8 0.0 0x4c
1877  // descriptor_length 8 1.0
1878 
1879  // reference_service_id 16 2.0
1880 };
1881 
1882 // DVB Bluebook A038 (Sept 2011) p 90
1884 {
1885  public:
1886  TransportStreamDescriptor(const unsigned char *data, int len = 300) :
1887  MPEGDescriptor(data, len, DescriptorID::transport_stream) { }
1888  // Name bits loc expected value
1889  // descriptor_tag 8 0.0 0x67
1890  // descriptor_length 8 1.0
1891 
1892  // for (i=0; i<N; i++) { byte 8 }
1893  QString Data(void) const
1894  { return dvb_decode_text(&_data[2], DescriptorLength()); }
1895  QString toString(void) const
1896  { return QString("TransportStreamDescriptor data(%1)").arg(Data()); }
1897 };
1898 
1899 // DVB Bluebook A038 (Sept 2011) p 91
1901 {
1902  public:
1903  VBIDataDescriptor(const unsigned char *data, int len = 300) :
1904  MPEGDescriptor(data, len, DescriptorID::vbi_data) { }
1905  // Name bits loc expected value
1906  // descriptor_tag 8 0.0 0x45
1907  // descriptor_length 8 1.0
1908 
1909  // for (i=0; i<N; i++)
1910  // {
1911  // data_service_id 8 0.0+p
1912  // data_service_length 8 1.0+p
1913  // if ((data_service_id&0x7) && data_service_id!=0x3))
1914  // {
1915  // for (i=0; i<N; i++)
1916  // {
1917  // reserved 2 2.0+p2
1918  // field_parity 1 2.2+p2
1919  // line_offset 5 2.3+p2
1920  // }
1921  // }
1922  // else
1923  // {
1924  // for (i=0; i<N; i++) { reserved 8 }
1925  // }
1926  // }
1927 };
1928 
1929 // DVB Bluebook A038 (Sept 2011) p 92
1931 {
1932  public:
1933  VBITeletextDescriptor(const unsigned char *data, int len = 300) :
1934  MPEGDescriptor(data, len, DescriptorID::vbi_teletext) { }
1935  // Name bits loc expected value
1936  // descriptor_tag 8 0.0 0x46
1937  // descriptor_length 8 1.0
1938 
1939  // for (i=0;i<N;i++)
1940  // {
1941  // ISO_639_language_code 24 0.0+p
1942  // teletext_type 5 3.0+p
1943  // teletext_magazine_num 3 3.5+p
1944  // teletext_page_num 8 4.0+p
1945  // } 5.0
1946 };
1947 
1948 // DVB Bluebook A038 (Sept 2011) p 119
1950 {
1951  public:
1952  PartialTransportStreamDescriptor(const unsigned char *data, int len = 300) :
1953  MPEGDescriptor(data, len, DescriptorID::partial_transport_stream) { }
1954  // Name bits loc expected value
1955  // descriptor_tag 8 0.0 0x63
1956  // descriptor_length 8 1.0
1957 
1958  // DVB_reserved_future_use 2 2.0
1959  // peak_rate 22 2.2
1960  uint PeakRate(void) const
1961  { return (_data[2] & 0x3f) << 16 | _data[3] | _data[4]; }
1962  // DVB_reserved_future_use 2 5.0
1963  // min_overall_smooth_rate 22 5.2
1964  uint SmoothRate(void) const
1965  { return (_data[5] & 0x3f) << 16 | _data[6] | _data[7]; }
1966  // DVB_reserved_future_use 2 8.0
1967  // max_overall_smooth_buf 14 8.2
1968  uint SmoothBuf(void) const { return ((_data[8] & 0x3f) << 8) | _data[9]; }
1969  QString toString(void) const;
1970 };
1971 
1972 
1973 // a_52a.pdf p125 Table A7 (for DVB)
1975 {
1976  public:
1977  AC3Descriptor(const unsigned char *data, int len = 300) :
1978  MPEGDescriptor(data, len, DescriptorID::ac3) { }
1979  // Name bits loc expected value
1980  // descriptor_tag 8 0.0 0x6A
1981  // descriptor_length 8 1.0
1982 
1983  // component_type_flag 1 2.0
1984  bool HasComponentType(void) const { return _data[2] & 0x80; }
1985  // bsid_flag 1 2.1
1986  bool HasBSID(void) const { return _data[2] & 0x40; }
1987  // mainid_flag 1 2.2
1988  bool HasMainID(void) const { return _data[2] & 0x20; }
1989  // asvc_flag 1 2.3
1990  bool HasASVC(void) const { return _data[2] & 0x10; }
1991  // reserved_flags 4 2.4
1992  // if (component_type_flag == 1)
1993  // { component_type 8 uimsbf }
1994  uint ComponentType(void) const { return _data[3]; }
1995  // if (bsid_flag == 1)
1996  // { bsid 8 uimsbf }
1997  uint BSID(void) const
1998  { return (HasComponentType()) ? _data[4] : _data[3]; }
1999  // if (mainid_flag == 1)
2000  // { mainid 8 uimsbf }
2001  uint MainID(void) const
2002  {
2003  int offset = 3;
2004  offset += (HasComponentType()) ? 1 : 0;
2005  offset += (HasBSID()) ? 1 : 0;
2006  return _data[offset];
2007  }
2008  // if (asvc_flag==1)
2009  // { asvc 8 uimsbf }
2010  uint ASVC(void) const
2011  {
2012  int offset = 3;
2013  offset += (HasComponentType()) ? 1 : 0;
2014  offset += (HasBSID()) ? 1 : 0;
2015  offset += (HasMainID()) ? 1 : 0;
2016  return _data[offset];
2017  }
2018  // for (I=0;I<N;I++)
2019  // { additional_info[i] N*8 uimsbf }
2020  //};
2021  QString toString(void) const;
2022 };
2023 
2024 static QString coderate_inner(uint cr)
2025 {
2026  switch (cr)
2027  {
2028  case 0x0: return "auto"; // not actually defined in spec
2029  case 0x1: return "1/2";
2030  case 0x2: return "2/3";
2031  case 0x3: return "3/4";
2032  case 0x4: return "5/6";
2033  case 0x5: return "7/8";
2034  case 0x8: return "8/9";
2035  case 0xf: return "none";
2036  default: return "auto"; // not actually defined in spec
2037  }
2038 }
2039 
2049 {
2050  public:
2051  DVBLogicalChannelDescriptor(const unsigned char *data, int len = 300) :
2052  MPEGDescriptor(data, len, PrivateDescriptorID::dvb_logical_channel_descriptor) { }
2053  // Name bits loc expected value
2054  // descriptor_tag 8 0.0 0x83
2055  // descriptor_length 8 1.0
2056 
2057  uint ChannelCount(void) const { return DescriptorLength() >> 2; }
2058 
2060  { return (_data[2 + (i<<2)] << 8) | _data[3 + (i<<2)]; }
2061 
2063  { return ((_data[4 + (i<<2)] << 8) | _data[5 + (i<<2)]) & 0x3ff; }
2064 
2065  QString toString(void) const;
2066 };
2067 
2068 // ETSI TS 102 323 (TV Anytime)
2070 {
2071  public:
2072  DVBContentIdentifierDescriptor(const unsigned char *data, int len = 300) :
2073  MPEGDescriptor(data, len, DescriptorID::dvb_content_identifier)
2074  {
2075  size_t length;
2076  size_t count = 0;
2077  uint8_t position = 2;
2078 
2079  memset ((void *) m_crid, 0, sizeof(m_crid));
2080 
2081  while (_data[1] >= position)
2082  {
2083  length = _data[position+1];
2084  m_crid[count] = &_data[position];
2085  count++;
2086  position+=length+2;
2087  }
2088  m_cridCount = count;
2089  }
2090  // Name bits loc expected value
2091  // descriptor_tag 8 0.0 0x76
2092  // descriptor_length 8 1.0
2093 
2094  uint ContentType(size_t n=0) const { return m_crid[n][0] >> 2; }
2095 
2096  uint ContentEncoding(size_t n=0) const { return m_crid[n][0] & 0x03; }
2097 
2098  // A content identifier is a URI. It may contain UTF-8 encoded using %XX.
2099  QString ContentId(size_t n=0) const
2100  {
2101  int length = m_crid[n][1];
2102  int positionOfHash = length-1;
2103  while (positionOfHash >= 0) {
2104  if (m_crid[n][2 + positionOfHash] == '#') {
2105  length = positionOfHash; /* remove the hash and the following IMI */
2106  break;
2107  }
2108  positionOfHash--;
2109  }
2110  return QString::fromLatin1((const char *)&m_crid[n][2], length);
2111  }
2112 
2113  size_t CRIDCount() const
2114  {
2115  return m_cridCount;
2116  }
2117 
2118  private:
2119  size_t m_cridCount;
2120  const uint8_t *m_crid[8];
2121 };
2122 
2123 // ETSI TS 102 323 (TV Anytime)
2125 {
2126  public:
2127  DefaultAuthorityDescriptor(const unsigned char *data, int len = 300) :
2128  MPEGDescriptor(data, len, DescriptorID::default_authority) { }
2129  // Name bits loc expected value
2130  // descriptor_tag 8 0.0 0x73
2131  // descriptor_length 8 1.0
2132 
2133  QString DefaultAuthority(void) const
2134  {
2135  return QString::fromLatin1((const char *)_data+2, _data[1]);
2136  }
2137 
2138  QString toString(void) const
2139  {
2140  return QString("DefaultAuthorityDescriptor: Authority(%1)")
2141  .arg(DefaultAuthority());
2142  }
2143 };
2144 
2145 /*
2146  * private UPC Cablecom (Austria) episode descriptor for Horizon middleware
2147  */
2149 {
2150  public:
2151  PrivateUPCCablecomEpisodeTitleDescriptor(const unsigned char *data, int len = 300) :
2152  MPEGDescriptor(data, len, PrivateDescriptorID::upc_event_episode_title) { }
2153  // Name bits loc expected value
2154  // descriptor_tag 8 0.0 0xa7
2155  // descriptor_length 8 1.0
2156 
2157  // ISO_639_language_code 24 2.0
2158  int LanguageKey(void) const
2159  {
2160  return iso639_str3_to_key(&_data[2]);
2161  }
2162  QString LanguageString(void) const
2163  {
2164  return iso639_key_to_str3(LanguageKey());
2165  }
2166  int CanonicalLanguageKey(void) const
2167  {
2168  return iso639_key_to_canonical_key(LanguageKey());
2169  }
2170  QString CanonicalLanguageString(void) const
2171  {
2172  return iso639_key_to_str3(CanonicalLanguageKey());
2173  }
2174 
2175  uint TextLength(void) const
2176  {
2177  return _data[1] - 3;
2178  }
2179 
2180  QString Text(void) const
2181  {
2182  return dvb_decode_text(&_data[5], TextLength());
2183  }
2184 };
2185 
2186 #endif
uint CASystemCount(void) const
bool IsDigitalAudio(void) const
bool IsLinearPolarization(void) const
uint AdaptationFieldDataID(void) const
MYTH_GLsizeiptr const GLvoid * data
QString BouquetName(void) const
uint OriginalNetworkID() const
CellFrequencyLinkDescriptor(const unsigned char *data, int len=300)
QString ServiceName(void) const
ContentDescriptor(const unsigned char *data, int len=300)
uint TeletextType(uint i) const
QString DefaultAuthority(void) const
QString toString(void) const
MultilingualServiceNameDescriptor(const unsigned char *data, int len=300)
PrivateDataSpecifierDescriptor(const unsigned char *data, int len=300)
bool HasBSID(void) const
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)
uint DescriptorNumber(void) const
PDCDescriptor(const unsigned char *data, int len=300)
uint AncillaryPageID(uint i) const
int Rating(uint i) const
CAIdentifierDescriptor(const unsigned char *data, int len=300)
NVODReferenceDescriptor(const unsigned char *data, int len=300)
bool IsHorizontalLeftPolarization(void) const
MultilingualBouquetNameDescriptor(const unsigned char *data, int len=300)
QString Name(void) const
const unsigned char * PrivateData(void) const
bool HasASVC(void) const
BouquetNameDescriptor(const unsigned char *data, int len=300)
int LanguageKey(uint i) const
bool LocalTimeOffsetPolarity(uint i) const
-1 if true, +1 if false (behind utc, ahead of utc, resp).
ShortEventDescriptor(const unsigned char *data, int len=300)
uint TextLength(void) const
QString toString(void) const
QString LanguageString(void) const
QString Text(void) const
QString EventName(void) const
int LanguageKey(void) const
ScramblingDescriptor(const unsigned char *data, int len=300)
bool IsTimeSlicingIndicatorUsed(void) const
uint ServiceID(void) const
QString FECInnerString(void) const
uint ContentType(size_t n=0) const
uint Nibble(uint i) const
uint StreamContent(void) const
QString LanguageString(uint i) const
QString CanonicalLanguageString(uint i) const
QString CanonicalLanguageString(void) const
int CanonicalLanguageKey(void) const
QString toString(void) const
CellListDescriptor(const unsigned char *data, int len=300)
TeletextDescriptor(const unsigned char *data, int len=300)
This is used to label streams so the can be treated differently, for instance each stream may get it&#39;...
unsigned char VideoProperties(void) const
bool IsSubtitle(void) const
bool IsTeletext(void) const
DefaultAuthorityDescriptor(const unsigned char *data, int len=300)
QString toString(void) const
QString ModulationString(void) const
bool IsTeletext(void) const
unsigned char AudioProperties(void) const
uint TSID(void) const
DVB Logical Channel Descriptor.
unsigned char HEAACProperties(void) const
int CanonicalLanguageKey(void) const
bool
Definition: pxsup2dast.c:30
const unsigned char * Selector(void) const
QString toString(void) const
unsigned char AVCProperties(void) const
DSNGDescriptor(const unsigned char *data, int len=300)
ComponentDescriptor(const unsigned char *data, int len=300)
unsigned int uint
Definition: compat.h:136
int LanguageKey(void) const
ServiceDescriptor(const unsigned char *data, int len=300)
QString CanonicalLanguageString(uint i) const
PartialTransportStreamDescriptor(const unsigned char *data, int len=300)
QString CanonicalLanguageString(void) const
QString LanguageString(void) const
static int iso639_str3_to_key(const unsigned char *iso639_2)
Definition: iso639.h:63
QString toString(void) const
uint NextTimeOffset(uint i) const
int iso639_key_to_canonical_key(int iso639_2)
Definition: iso639.cpp:122
AnnouncementSupportDescriptor(const unsigned char *data, int len=300)
uint ServiceID(uint i) const
QString toString(void) const
bool IsHDTV(void) const
QString HierarchyString(void) const
CountryAvailabilityDescriptor(const unsigned char *data, int len=300)
TimeShiftedServiceDescriptor(const unsigned char *data, int len=300)
uint SubtitleType(uint i) const
ServiceMoveDescriptor(const unsigned char *data, int len=300)
QString LanguageString(void) const
QString FECOuterString(void) const
QString EventName(const unsigned char *encoding_override, uint encoding_length) const
int LanguageKey(void) const
uint Nibble1(uint i) const
uint LocalTimeOffset(uint i) const
QString LanguageString(void) const
QString toString(void) const
bool IsDTV(void) const
uint DescriptorLength(void) const
uint AncillaryDataID(void) const
uint UserNibble(uint i) const
StuffingDescriptor(const unsigned char *data, int len=300)
bool IsCircularPolarization(void) const
VBIDataDescriptor(const unsigned char *data, int len=300)
uint UserNibble1(uint i) const
uint OrbitalPosition(void) const
orbital_position 16 6.0
QString RollOffString(void) const
uint TextLength(void) const
voidpf uLong offset
Definition: ioapi.h:142
unsigned char HEVCProperties(void) const
bool IsVideo(void) const
uint TeletextMagazineNum(uint i) const
QString BouquetShortName(void) const
bool IsTargetListed(void) const
SubtitlingDescriptor(const unsigned char *data, int len=300)
TerrestrialDeliverySystemDescriptor(const unsigned char *data, int len=300)
LocalTimeOffsetDescriptor(const unsigned char *data, int len=300)
uint ServiceNameLength(void) const
unsigned char AC3Properties(void) const
uint EventNameLength(void) const
static int x2
Definition: mythsocket.cpp:61
QString Text(void) const
uint ServiceProviderNameLength(void) const
uint ProgramIdLabel(void) const
QString GuardIntervalString(void) const
uint StreamCount(void) const
unsigned long long FrequencyHz(void) const
QString Text(void) const
int CanonicalLanguageKey(void) const
int LanguageKey(uint i) const
DVBContentIdentifierDescriptor(const unsigned char *data, int len=300)
QString CountryCodeString(uint i) const
QString ModulationString(void) const
QString CountryCodeString(uint i) const
MosaicDescriptor(const unsigned char *data, int len=300)
int CASystemId(uint i) const
static QString coderate_inner(uint coderate)
unsigned long long FrequencyHz(uint i) const
PrivateUPCCablecomEpisodeTitleDescriptor(const unsigned char *data, int len=300)
int CanonicalLanguageKey(uint i) const
uint DataComponentTag(void) const
VBITeletextDescriptor(const unsigned char *data, int len=300)
bool IsVerticalRightPolarization(void) const
int CanonicalLanguageKey(void) const
uint ComponentTag(void) const
DataBroadcastDescriptor(const unsigned char *data, int len=300)
int LanguageKey(void) const
uint MobileInitialServiceID(void) const
AC3Descriptor(const unsigned char *data, int len=300)
uint Count(void) const
static volatile bool categoryDescExists
unsigned char SubtitleType(void) const
bool HasMobileNetworkID(void) const
QString toString(void) const
ExtendedEventDescriptor(const unsigned char *data, int len=300)
static QMap< uint, QString > categoryDesc
FrequencyListDescriptor(const unsigned char *data, int len=300)
QString ContentId(size_t n=0) const
bool HasComponentType(void) const
QString toString(void) const
MultilingualNetworkNameDescriptor(const unsigned char *data, int len=300)
QString Text(const unsigned char *encoding_override, uint encoding_length) const
uint FrequencyRaw(void) const
uint SelectorLength(void) const
AncillaryDataDescriptor(const unsigned char *data, int len=300)
TimeShiftedEventDescriptor(const unsigned char *data, int len=300)
uint MobileHandOverType(void) const
int LocalTimeOffsetWithPolarity(uint i) const
QString ServiceProviderName(void) const
unsigned long long Frequency(uint i) const
ServiceDescriptorMapping(const uint serviceid)
QString toString(void) const
bool HasMobileInitialServiceID(void) const
QString BandwidthString(void) const
uint BSID(void) const
uint SymbolRateHz(void) const
QString toString(void) const
AdaptationFieldDataDescriptor(const unsigned char *data, int len=300)
uint DataBroadcastId(void) const
ShortSmoothingBufferDescriptor(const unsigned char *data, int len=300)
uint ServiceType(void) const
SatelliteDeliverySystemDescriptor(const unsigned char *data, int len=300)
uint LinkageType(void) const
uint ChannelCount(void) const
QString CanonicalLanguageString(void) const
bool HasMainID(void) const
QString TransmissionModeString(void) const
uint CountryRegionId(uint i) const
static int x5
Definition: mythsocket.cpp:64
uint ComponentTag(void) const
uint OriginalNetworkId(uint i) const
uint ServiceID(uint i) const
NetworkNameDescriptor(const unsigned char *data, int len=300)
int CanonicalLanguageKey(uint i) const
uint ScramblingMode(void) const
uint Nibble2(uint i) const
QString OrbitalPositionString(void) const
bool IsEast(void) const
west_east_flag 1 8.0
uint ServiceId(uint i) const
QString ServiceProviderShortName(void) const
uint FrequencyCount() const
QString Text(const unsigned char *encoding_override, uint encoding_length) const
uint LengthOfItems(void) const
uint ContentEncoding(size_t n=0) const
uint PrivateDataLength(void) const
uint UserNibble2(uint i) const
TransportStreamDescriptor(const unsigned char *data, int len=300)
uint Count(void) const
uint TransportStreamId(uint i) const
unsigned char MP2Properties(void) const
uint ServiceCount(void) const
const unsigned char * _data
uint ServiceType(uint i) const
uint Count(void) const
QString ConstellationString(void) const
QString toString(void) const
QString Data(void) const
static QString iso639_key_to_str3(int code)
Definition: iso639.h:46
uint MainID(void) const
uint32_t PrivateDataSpecifier(void) const
uint CompositionPageID(uint i) const
QString EventShortName(void) const
QString FECInnerString(void) const
uint TeletextPageNum(uint i) const
bool IsHDTV(void) const
QString ShortName(void) const
QString dvb_decode_short_name(const unsigned char *src, uint raw_length)
QString ServiceShortName(void) const
QString toString(void) const
unsigned char MPEG2Properties(void) const
uint TextLength(void) const
QString toString(void) const
uint SymbolRateRaw(void) const
uint MobileNetworkID(void) const
DataBroadcastIdDescriptor(const unsigned char *data, int len=300)
uint LastNumber(void) const
uint DataBroadCastId(void) const
uint TargetEventID(void) const
uint StreamCount(void) const
TelephoneDescriptor(const unsigned char *data, int len=300)
uint CountryCount(void) const
ServiceAvailabilityDescriptor(const unsigned char *data, int len=300)
ServiceListDescriptor(const unsigned char *data, int len=300)
QString ModulationSystemString(void) const
uint CodingType(void) const
bool IsDigitalAudio(void) const
uint CountryCode(uint i) const
bool IsAudio(void) const
static int x3
Definition: mythsocket.cpp:62
ParentalRatingDescriptor(const unsigned char *data, int len=300)
LinkageDescriptor(const unsigned char *data, int len=300)
bool IsEventSimulcast(void) const
uint ChannelNumber(uint i) const
uint ServiceType(void) const
unsigned long long FrequencyHz(void) const
uint FrequencyRaw(void) const
frequency 32 2.0
bool IsDTV(void) const
uint ComponentType(void) const
static QMutex categoryLock
uint ComponentType(void) const
QString LanguageString(uint i) const
uint MobileOriginType(void) const
GLenum GLsizei len
uint ASVC(void) const
QString CodeRateHPString(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 CanonicalLanguageString(void) const
QString CountryNames(void) const