MythTV  master
sctedescriptors.h
Go to the documentation of this file.
1 // -*- Mode: c++ -*-
22 #ifndef SCTE_TABLES_H
23 #define SCTE_TABLES_H
24 
25 // Qt headers
26 #include <QString>
27 
28 // MythTV
29 #include "mpegdescriptors.h"
30 
31 // SCTE 57 p 83
33 {
34  public:
35  FrameRateDescriptor(const unsigned char *data, uint len) :
36  MPEGDescriptor(data, len, DescriptorID::scte_frame_rate, 1) { }
37  // Name bits loc expected value
38  // descriptor_tag 8 0.0 0x82
39  // descriptor_length 8 1.0
40  // multiple_frame_rate_flag 1 2.0
41  bool MultipleFrameRates(void) const { return ( m_data[2] & 0x80 ) != 0; }
42  // frame_rate_code 4 2.1
43  uint FrameRateCode(void) const { return (m_data[2] >> 3) & 0xF; }
45  double FrameRate(void) const
46  {
47  switch (FrameRateCode())
48  {
49  case 0x1 :
50  return 24.0 / 1.001;
51  case 0x2 :
52  return 24.0;
53  case 0x3 :
54  return 25.0;
55  case 0x4 :
56  return 30.0 / 1.001;
57  case 0x5:
58  return 30.0;
59  case 0x6:
60  return 50.0;
61  case 0x7:
62  return 60.0 / 1.001;
63  case 0x8:
64  return 60.0;
65  default:
66  //invalid
67  return 0.0;
68  }
69  }
70  // reserved 3 2.5
71 
72  QString toString(void) const override // MPEGDescriptor
73  {
74  return QString("FrameRateDescriptor: "
75  "MultipleFrameRates(%1) MaximumFrameRate(%2)")
76  .arg(static_cast<int>(MultipleFrameRates()))
77  .arg(FrameRate());
78  }
79 };
80 
81 // SCTE 57 p 84
83 {
84  public:
85  ExtendedVideoDescriptor(const unsigned char *data, uint len) :
86  MPEGDescriptor(data, len, DescriptorID::scte_extended_video, 1) { }
87  // Name bits loc expected value
88  // descriptor_tag 8 0.0 0x83
89  // descriptor_length 8 1.0
90  // catalog_mode_flag 1 2.0
91  bool CatalogModeFlag(void) const { return ( m_data[2] & 0x80 ) != 0; }
92  // video_includes_setup 1 2.1
93  bool VideoIncludesSetup(void) const { return ( m_data[2] & 0x40 ) != 0; }
94  // reserved 6 2.2
95 
96  QString toString(void) const override // MPEGDescriptor
97  {
98  return QString("ExtendedVideoDescriptor: "
99  "CatalogModeFlag(%1) VideoIncludesSetup(%2)")
100  .arg(static_cast<int>(CatalogModeFlag()))
101  .arg(static_cast<int>(VideoIncludesSetup()));
102  }
103 };
104 
105 // SCTE 57 p 85
107 {
108  public:
109  SCTEComponentNameDescriptor(const unsigned char *data, uint len) :
110  MPEGDescriptor(data, len, DescriptorID::scte_component_name)
111  {
112  // TODO make sure descriptor is long enough.. set _data NULL otherwise
113  }
114  // Name bits loc expected value
115  // descriptor_tag 8 0.0 0x84
116  // descriptor_length 8 1.0
117  // reserved 2 2.0
118  // string_count 6 2.2
119  uint StringCount(void) const { return m_data[2] & 0x3F; }
120 
121  // for (i = 0; i < string_count; i++)
122  // {
123  // ISO_639_language_code 24 loc(i)
124  int LanguageKey(uint i) const
125  { return iso639_str3_to_key(&m_data[loc(i)]); }
126  QString LanguageString(uint i) const
127  { return iso639_key_to_str3(LanguageKey(loc(i))); }
130  QString CanonicalLanguageString(uint i) const
132  // string_length 8 loc(i)+3
134  { return m_data[loc(i) + 3]; }
135  // name_string * loc(i)+4
136  QString NameString(uint i) const;
137  // }
138 
139  QString toString(void) const override; // MPEGDescriptor
140 
141  private:
142  uint loc(uint number) const
143  {
144  uint place = 3;
145  for (uint i = 0; i < number; ++i)
146  place += 4 + m_data[place + 3];
147  return place;
148  }
149 };
150 
157 {
158  public:
159  CueIdentifierDescriptor(const unsigned char *data, uint len) :
160  MPEGDescriptor(data, len, DescriptorID::scte_cue_identifier, 1) { }
161  // Name bits loc expected value
162  // descriptor_tag 8 0.0 0x8A
163  // descriptor_length 8 1.0 0x01
164  // cue_stream_type 8 2.0
165  enum // Table 6.3 Cue Stream Types
166  {
167  kLimited = 0x0,
168  kAllCommands = 0x1,
172  // 0x05-0x7f are reserved for future use
173  // 0x80-0xff user defined range
174  };
175  uint CueStreamType(void) const { return m_data[2]; }
176  QString CueStreamTypeString(void) const;
177  QString toString(void) const override; // MPEGDescriptor
178 };
179 
180 // See SCTE 57 p 80
182 {
183  public:
184  FrequencySpecificationDescriptor(const unsigned char *data, uint len) :
185  MPEGDescriptor(data, len, DescriptorID::scte_frequency_spec, 2)
186  { }
187  // Name bits loc expected value
188  // descriptor_tag 8 0.0 0x90
189  // descriptor_length 8 1.0
190  // frequency_unit 1 2.0
191  bool FrequencyUnit(void) const { return ( m_data[2] & 0x80 ) != 0; }
192  uint FrequencyUnitHz(void) const
193  { return FrequencyUnit() ? 10000 : 125000; }
194  // carrier_frequency 15 2.1
195  uint CarrierFrequency(void) const
196  { return ((m_data[2] << 8) | m_data[3]) & 0x7fff; }
197  unsigned long long CarrierFrequnecyHz(void) const
198  {
199  return FrequencyUnitHz() * ((unsigned long long) CarrierFrequency());
200  }
201 
202  QString toString(void) const override // MPEGDescriptor
203  {
204  return QString("FrequencySpecificationDescriptor: %2 Hz")
205  .arg(CarrierFrequnecyHz());
206  }
207 };
208 
209 // SCTE 57 p 81
211 {
212  public:
213  ModulationParamsDescriptor(const unsigned char *data, uint len) :
214  MPEGDescriptor(data, len, DescriptorID::scte_modulation_params, 6) { }
215  // Name bits loc expected value
216  // descriptor_tag 8 0.0 0x91
217  // descriptor_length 8 1.0
218  // transmissionSystem 4 2.0
219  uint TransmissionSystem(void) const { return m_data[2] >> 4; }
220  // inner_coding_mode 4 2.4
221  uint InnerCodingMode(void) const { return m_data[2] & 0x0f; }
222  // split_bitstream_mode 1 3.0
223  bool SplitBitstreamMode(void) const { return (m_data[3] >> 7) != 0; }
224  //reserved 2 3.1
225  //modulation_format 5 3.3
226  uint ModulationFormat(void) const { return m_data[3] & 0x1F; }
227  // reserved 4 4.0
228  // symbol_rate 28 4.4
229  uint SymbolRate(void) const
230  {
231  return ((m_data[4] << 24) | (m_data[5] << 16) |
232  (m_data[6] << 8) | m_data[7]) & 0x7FFF;
233  }
234 };
235 
236 // SCTE 57 p 82
238 {
239  public:
240  TransportStreamIdDescriptor(const unsigned char *data, uint len) :
241  MPEGDescriptor(data, len, DescriptorID::scte_transport_stream_id, 2) { }
242  // Name bits loc expected value
243  // descriptor_tag 8 0.0 0x92
244  // descriptor_length 8 1.0
245  // target_transport_stream_id 16 2.0
247  { return (m_data[2] << 8) | m_data[3]; }
248 
249  QString toString(void) const override // MPEGDescriptor
250  {
251  return QString("TransportStreamIdDescriptor: 0x%1")
252  .arg(TargetTransportStreamId(),0,16);
253  }
254 };
255 
256 // See SCTE 65 p 55 -- optional descriptor
258 {
259  public:
260  RevisionDetectionDescriptor(const unsigned char *data, uint len) :
261  MPEGDescriptor(data, len, DescriptorID::scte_revision_detection, 3) { }
262  // Name bits loc expected value
263  // descriptor_tag 8 0.0 0x93
264  // descriptor_length 8 1.0 0x01
265  // reserved 3 2.0
266  // table_version_number 5 2.3
267  uint TableVersionNumber(void) const { return m_data[2] & 0x1f; }
268  // section_number 8 3.0
269  uint SectionNumber(void) const { return m_data[3]; }
270  // last_section_number 8 4.0
271  uint LastSectionNumber(void) const { return m_data[4]; }
272 
273  QString toString(void) const override; // MPEGDescriptor
274 };
275 
276 #endif // SCTE_TABLES_H
QString toString(void) const override
Only splice null, insert, and schedule.
QString toString(void) const override
unsigned long long CarrierFrequnecyHz(void) const
This descriptor is used to identify streams with SpliceInformationTable data in them.
uint CueStreamType(void) const
bool CatalogModeFlag(void) const
ExtendedVideoDescriptor(const unsigned char *data, uint len)
Carries time signal w/ segmentation desc.
ModulationParamsDescriptor(const unsigned char *data, uint len)
FrequencySpecificationDescriptor(const unsigned char *data, uint len)
QString LanguageString(uint i) const
SCTEComponentNameDescriptor(const unsigned char *data, uint len)
CueIdentifierDescriptor(const unsigned char *data, uint len)
static int iso639_str3_to_key(const unsigned char *iso639_2)
Definition: iso639.h:63
int iso639_key_to_canonical_key(int iso639_2)
Definition: iso639.cpp:120
QString CanonicalLanguageString(uint i) const
SCTE Descriptors.
QString toString(void) const override
double FrameRate(void) const
returns maximum frame rate in video
bool VideoIncludesSetup(void) const
QString toString(void) const override
const unsigned char * m_data
bool SplitBitstreamMode(void) const
QString toString(void) const override
bool MultipleFrameRates(void) const
RevisionDetectionDescriptor(const unsigned char *data, uint len)
QString toString(void) const override
TransportStreamIdDescriptor(const unsigned char *data, uint len)
int CanonicalLanguageKey(uint i) const
unsigned int uint
Definition: compat.h:140
uint StringLength(uint i) const
QString NameString(uint i) const
SCTE Descriptors.
FrameRateDescriptor(const unsigned char *data, uint len)
QString CueStreamTypeString(void) const
uint TargetTransportStreamId(void) const
static QString iso639_key_to_str3(int code)
Definition: iso639.h:46
uint loc(uint number) const
uint SectionNumber(void) const
uint LastSectionNumber(void) const
QString toString(void) const override
uint InnerCodingMode(void) const
uint ModulationFormat(void) const
int LanguageKey(uint i) const
uint FrameRateCode(void) const
uint TableVersionNumber(void) const
uint TransmissionSystem(void) const