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
DescriptorID
Definition: mpegdescriptors.h:21
CueIdentifierDescriptor::kTieredSplicing
@ kTieredSplicing
outside scope of SCTE 35
Definition: sctedescriptors.h:170
iso639_key_to_canonical_key
int iso639_key_to_canonical_key(int iso639_2)
Definition: iso639.cpp:121
FrequencySpecificationDescriptor::FrequencyUnitHz
uint FrequencyUnitHz(void) const
Definition: sctedescriptors.h:192
SCTEComponentNameDescriptor::loc
uint loc(uint number) const
Definition: sctedescriptors.h:142
SCTEComponentNameDescriptor::CanonicalLanguageKey
int CanonicalLanguageKey(uint i) const
Definition: sctedescriptors.h:128
mpegdescriptors.h
CueIdentifierDescriptor::CueIdentifierDescriptor
CueIdentifierDescriptor(const unsigned char *data, uint len)
Definition: sctedescriptors.h:159
FrameRateDescriptor::MultipleFrameRates
bool MultipleFrameRates(void) const
Definition: sctedescriptors.h:41
RevisionDetectionDescriptor::LastSectionNumber
uint LastSectionNumber(void) const
Definition: sctedescriptors.h:271
FrameRateDescriptor::FrameRateDescriptor
FrameRateDescriptor(const unsigned char *data, uint len)
Definition: sctedescriptors.h:35
CueIdentifierDescriptor::kAllCommands
@ kAllCommands
Carries all commands.
Definition: sctedescriptors.h:168
TransportStreamIdDescriptor::toString
QString toString(void) const override
Definition: sctedescriptors.h:249
RevisionDetectionDescriptor::TableVersionNumber
uint TableVersionNumber(void) const
Definition: sctedescriptors.h:267
RevisionDetectionDescriptor::RevisionDetectionDescriptor
RevisionDetectionDescriptor(const unsigned char *data, uint len)
Definition: sctedescriptors.h:260
CueIdentifierDescriptor
This descriptor is used to identify streams with SpliceInformationTable data in them.
Definition: sctedescriptors.h:157
ModulationParamsDescriptor
Definition: sctedescriptors.h:211
CueIdentifierDescriptor::kTieredSegmentation
@ kTieredSegmentation
outside scope of SCTE 35
Definition: sctedescriptors.h:171
FrameRateDescriptor::FrameRate
double FrameRate(void) const
returns maximum frame rate in video
Definition: sctedescriptors.h:45
SCTEComponentNameDescriptor::SCTEComponentNameDescriptor
SCTEComponentNameDescriptor(const unsigned char *data, uint len)
Definition: sctedescriptors.h:109
TransportStreamIdDescriptor::TargetTransportStreamId
uint TargetTransportStreamId(void) const
Definition: sctedescriptors.h:246
FrameRateDescriptor
SCTE Descriptors.
Definition: sctedescriptors.h:33
SCTEComponentNameDescriptor::NameString
QString NameString(uint i) const
SCTE Descriptors.
Definition: sctedescriptors.cpp:25
CueIdentifierDescriptor::kLimited
@ kLimited
Only splice null, insert, and schedule.
Definition: sctedescriptors.h:167
ExtendedVideoDescriptor::toString
QString toString(void) const override
Definition: sctedescriptors.h:96
RevisionDetectionDescriptor::SectionNumber
uint SectionNumber(void) const
Definition: sctedescriptors.h:269
FrequencySpecificationDescriptor::FrequencySpecificationDescriptor
FrequencySpecificationDescriptor(const unsigned char *data, uint len)
Definition: sctedescriptors.h:184
MPEGDescriptor
Definition: mpegdescriptors.h:296
MPEGDescriptor::m_data
const unsigned char * m_data
Definition: mpegdescriptors.h:350
CueIdentifierDescriptor::kSegmentation
@ kSegmentation
Carries time signal w/ segmentation desc.
Definition: sctedescriptors.h:169
ExtendedVideoDescriptor
Definition: sctedescriptors.h:83
ModulationParamsDescriptor::InnerCodingMode
uint InnerCodingMode(void) const
Definition: sctedescriptors.h:221
ExtendedVideoDescriptor::CatalogModeFlag
bool CatalogModeFlag(void) const
Definition: sctedescriptors.h:91
ModulationParamsDescriptor::ModulationFormat
uint ModulationFormat(void) const
Definition: sctedescriptors.h:226
hardwareprofile.smolt.long
long
Definition: smolt.py:76
TransportStreamIdDescriptor
Definition: sctedescriptors.h:238
SCTEComponentNameDescriptor::toString
QString toString(void) const override
Definition: sctedescriptors.cpp:30
RevisionDetectionDescriptor::toString
QString toString(void) const override
Definition: sctedescriptors.cpp:70
iso639_key_to_str3
static QString iso639_key_to_str3(int code)
Definition: iso639.h:46
uint
unsigned int uint
Definition: compat.h:140
FrequencySpecificationDescriptor::CarrierFrequency
uint CarrierFrequency(void) const
Definition: sctedescriptors.h:195
ExtendedVideoDescriptor::VideoIncludesSetup
bool VideoIncludesSetup(void) const
Definition: sctedescriptors.h:93
ExtendedVideoDescriptor::ExtendedVideoDescriptor
ExtendedVideoDescriptor(const unsigned char *data, uint len)
Definition: sctedescriptors.h:85
FrequencySpecificationDescriptor::FrequencyUnit
bool FrequencyUnit(void) const
Definition: sctedescriptors.h:191
FrameRateDescriptor::toString
QString toString(void) const override
Definition: sctedescriptors.h:72
FrameRateDescriptor::FrameRateCode
uint FrameRateCode(void) const
Definition: sctedescriptors.h:43
FrequencySpecificationDescriptor::toString
QString toString(void) const override
Definition: sctedescriptors.h:202
ModulationParamsDescriptor::TransmissionSystem
uint TransmissionSystem(void) const
Definition: sctedescriptors.h:219
SCTEComponentNameDescriptor
Definition: sctedescriptors.h:107
RevisionDetectionDescriptor
Definition: sctedescriptors.h:258
ModulationParamsDescriptor::SymbolRate
uint SymbolRate(void) const
Definition: sctedescriptors.h:229
TransportStreamIdDescriptor::TransportStreamIdDescriptor
TransportStreamIdDescriptor(const unsigned char *data, uint len)
Definition: sctedescriptors.h:240
SCTEComponentNameDescriptor::LanguageKey
int LanguageKey(uint i) const
Definition: sctedescriptors.h:124
SCTEComponentNameDescriptor::CanonicalLanguageString
QString CanonicalLanguageString(uint i) const
Definition: sctedescriptors.h:130
SCTEComponentNameDescriptor::StringLength
uint StringLength(uint i) const
Definition: sctedescriptors.h:133
ModulationParamsDescriptor::SplitBitstreamMode
bool SplitBitstreamMode(void) const
Definition: sctedescriptors.h:223
CueIdentifierDescriptor::CueStreamType
uint CueStreamType(void) const
Definition: sctedescriptors.h:175
FrequencySpecificationDescriptor
Definition: sctedescriptors.h:182
SCTEComponentNameDescriptor::StringCount
uint StringCount(void) const
Definition: sctedescriptors.h:119
iso639_str3_to_key
static int iso639_str3_to_key(const unsigned char *iso639_2)
Definition: iso639.h:63
ModulationParamsDescriptor::ModulationParamsDescriptor
ModulationParamsDescriptor(const unsigned char *data, uint len)
Definition: sctedescriptors.h:213
CueIdentifierDescriptor::CueStreamTypeString
QString CueStreamTypeString(void) const
Definition: sctedescriptors.cpp:42
CueIdentifierDescriptor::toString
QString toString(void) const override
Definition: sctedescriptors.cpp:64
FrequencySpecificationDescriptor::CarrierFrequnecyHz
unsigned long long CarrierFrequnecyHz(void) const
Definition: sctedescriptors.h:197
SCTEComponentNameDescriptor::LanguageString
QString LanguageString(uint i) const
Definition: sctedescriptors.h:126