MythTV master
mpegdescriptors.cpp
Go to the documentation of this file.
1// -*- Mode: c++ -*-
2// Copyright (c) 2005, Daniel Thor Kristjansson
3
4#include <climits>
5
7
8#include "sctedescriptors.h"
9#include "atscdescriptors.h"
10#include "dvbdescriptors.h"
11
14QMap<QString,QString> RegistrationDescriptor::description_map;
15
17 const unsigned char *data, uint len)
18{
20 uint off = 0;
21 while (off < len)
22 {
23 tmp.push_back(data+off);
24 MPEGDescriptor desc(data+off, len-off);
25 if (!desc.IsValid())
26 {
27 tmp.pop_back();
28 break;
29 }
30 off += desc.size();
31 }
32 return tmp;
33}
34
36 const unsigned char *data, uint len, int excluded_descid)
37{
39 uint off = 0;
40 while (off < len)
41 {
42 if ((data+off)[0] != excluded_descid)
43 tmp.push_back(data+off);
44 MPEGDescriptor desc(data+off, len-off);
45 if (!desc.IsValid())
46 {
47 if ((data+off)[0] != excluded_descid)
48 tmp.pop_back();
49 break;
50 }
51 off += desc.size();
52 }
53 return tmp;
54}
55
57 const unsigned char *data, uint len, int excluded_descid)
58{
60 uint off = 0;
61 while (off < len)
62 {
63 if ((data+off)[0] == excluded_descid)
64 tmp.push_back(data+off);
65 MPEGDescriptor desc(data+off, len-off);
66 if (!desc.IsValid())
67 {
68 if ((data+off)[0] == excluded_descid)
69 tmp.pop_back();
70 break;
71 }
72 off += desc.size();
73 }
74 return tmp;
75}
76
77const unsigned char *MPEGDescriptor::Find(const desc_list_t &parsed,
78 uint desc_tag)
79{
80 auto sametag = [desc_tag](const auto *item){ return item[0] == desc_tag; };
81 auto it = std::find_if(parsed.cbegin(), parsed.cend(), sametag);
82 return (it != parsed.cend()) ? *it : nullptr;
83}
84
85const unsigned char *MPEGDescriptor::FindExtension(const desc_list_t &parsed,
86 uint desc_tag)
87{
88 auto sametag = [desc_tag](const auto *item)
89 { return item[0] == DescriptorID::extension &&
90 item[1] > 1 &&
91 item[2] == desc_tag; };
92 auto it = std::find_if(parsed.cbegin(), parsed.cend(), sametag);
93 return (it != parsed.cend()) ? *it : nullptr;
94}
95
97{
99 auto sametag = [desc_tag](const auto *item){ return item[0] == desc_tag; };
100 std::copy_if(parsed.cbegin(), parsed.cend(), std::back_inserter(tmp), sametag);
101 return tmp;
102}
103
104static uint maxPriority(const QMap<uint,uint> &langPrefs)
105{
106 uint max_pri = 0;
107 for (uint pref : langPrefs)
108 max_pri = std::max(max_pri, pref);
109 return max_pri;
110}
111
112const unsigned char *MPEGDescriptor::FindBestMatch(
113 const desc_list_t &parsed, uint desc_tag, QMap<uint,uint> &langPrefs)
114{
115 uint match_idx = 0;
116 uint match_pri = UINT_MAX;
117 int unmatched_idx = -1;
118
119 size_t i = (desc_tag == DescriptorID::short_event) ? 0 : parsed.size();
120 for (; i < parsed.size(); i++)
121 {
122 if (DescriptorID::short_event == parsed[i][0])
123 {
124 ShortEventDescriptor sed(parsed[i]);
125 if (!sed.IsValid())
126 continue;
127 QMap<uint,uint>::const_iterator it =
128 langPrefs.constFind(sed.CanonicalLanguageKey());
129
130 if ((it != langPrefs.constEnd()) && (*it < match_pri))
131 {
132 match_idx = i;
133 match_pri = *it;
134 }
135
136 if (unmatched_idx < 0)
137 unmatched_idx = i;
138 }
139 }
140
141 if (match_pri != UINT_MAX)
142 return parsed[match_idx];
143
144 if ((desc_tag == DescriptorID::short_event) && (unmatched_idx >= 0))
145 {
146 ShortEventDescriptor sed(parsed[unmatched_idx]);
147 if (sed.IsValid())
148 {
149 langPrefs[sed.CanonicalLanguageKey()] = maxPriority(langPrefs) + 1;
150 return parsed[unmatched_idx];
151 }
152 }
153
154 return nullptr;
155}
156
158 const desc_list_t &parsed, uint desc_tag, QMap<uint,uint> &langPrefs)
159{
160 uint match_pri = UINT_MAX;
161 int match_key = 0;
162 int unmatched_idx = -1;
163
164 size_t i = (desc_tag == DescriptorID::extended_event) ? 0 : parsed.size();
165 for (; i < parsed.size(); i++)
166 {
167 if (DescriptorID::extended_event == parsed[i][0])
168 {
169 ExtendedEventDescriptor eed(parsed[i]);
170 if (!eed.IsValid())
171 continue;
172 QMap<uint,uint>::const_iterator it =
173 langPrefs.constFind(eed.CanonicalLanguageKey());
174
175 if ((it != langPrefs.constEnd()) && (*it < match_pri))
176 {
177 match_key = eed.LanguageKey();
178 match_pri = *it;
179 }
180
181 if (unmatched_idx < 0)
182 unmatched_idx = i;
183 }
184 }
185
186 if ((desc_tag == DescriptorID::extended_event) &&
187 (match_key == 0) && (unmatched_idx >= 0))
188 {
189 ExtendedEventDescriptor eed(parsed[unmatched_idx]);
190 if (eed.IsValid())
191 {
192 langPrefs[eed.CanonicalLanguageKey()] = maxPriority(langPrefs) + 1;
193 match_key = eed.LanguageKey();
194 }
195 }
196
198 if (match_pri == UINT_MAX)
199 return tmp;
200
201 for (const auto *j : parsed)
202 {
203 if ((DescriptorID::extended_event == desc_tag) &&
205 {
207 if (eed.IsValid() && (eed.LanguageKey() == match_key))
208 tmp.push_back(j);
209 }
210 }
211
212 return tmp;
213}
214
215#define EMPTY_STR_16 "","","","", "","","","", "","","","", "","","","",
216
217const std::array<const std::string,256> descriptor_tag_strings
218{
219 /* 0x00 */ "", /* 0x01 */ "",
220 /* 0x02 */ "Video", /* 0x03 */ "Audio",
221 /* 0x04 */ "Hierarchy", /* 0x05 */ "Registration",
222 /* 0x06 */ "Data Stream Alignment", /* 0x07 */ "Target Background Grid",
223 /* 0x08 */ "Video Window", /* 0x09 */ "Conditional Access",
224 /* 0x0A */ "ISO-639 Language", /* 0x0B */ "System Clock",
225 /* 0x0C */ "Multiplex Buffer Utilization", /* 0x0D */ "Copyright",
226 /* 0x0E */ "Maximum Bitrate", /* 0x0F */ "Private Data Indicator",
227
228 /* 0x10 */ "Smoothing Buffer", /* 0x11 */ "STD",
229 /* 0x12 */ "IBP", /* 0x13 */ "DSM-CC Carousel Identifier",
230 /* 0x14 */ "DSM-CC Association Tag",
231 /* 0x15 */ "DSM-CC Deferred Association Tag",
232 /* 0x16 */ "Reserved(0x16)", /* 0x17 */ "DSM-CC NPT Reference",
233 /* 0x18 */ "DSM-CC NPT Endpoint", /* 0x19 */ "DSM-CC Stream Mode",
234 /* 0x1A */ "DSM-CC Stream Event", /* 0x1B */ "MPEG-4 Video",
235 /* 0x1C */ "MPEG-4 Audio", /* 0x1D */ "IOD",
236 /* 0x1E */ "SL", /* 0x1F */ "FMC",
237
238 /* 0x20 */ "External ES ID", /* 0x21 */ "Multimpex Code",
239 /* 0x22 */ "FMX buffer Size", /* 0x23 */ "Multiplex Buffer",
240 /* 0x24 */ "Content Labeling", /* 0x25 */ "Metadata Pointer",
241 /* 0x26 */ "Metadata", /* 0x27 */ "Metadata Std",
242 /* 0x28 */ "AVC Video", /* 0x29 */ "IPMP DRM",
243 /* 0x2A */ "AVC Timing & HRD", /* 0x2B */ "AAC Audio",
244 /* 0x2C */ "Flex Mux Timing", /* 0x2D */ "",
245 /* 0x2E */ "", /* 0x2F */ "",
246
247 /* 0x30-0x3F */ EMPTY_STR_16
248
249 /* 0x40 */ "Network Name", /* 0x41 */ "Service List",
250 /* 0x42 */ "DVB Stuffing", /* 0x43 */ "Satellite Delivery System",
251 /* 0x44 */ "Cable Delivery System", /* 0x45 */ "VBI Data",
252 /* 0x46 */ "VBI Teletext", /* 0x47 */ "Bouquet Name",
253 /* 0x48 */ "Service", /* 0x49 */ "Country Availability",
254 /* 0x4A */ "Linkage", /* 0x4B */ "NVOD Reference",
255 /* 0x4C */ "DVB Time-shifted Service",/* 0x4D */ "Short Event",
256 /* 0x4E */ "Extended Event", /* 0x4F */ "Time-shifted Event",
257
258 /* 0x50 */ "Component", /* 0x51 */ "Mosaic",
259 /* 0x52 */ "Stream Identifier",
260 /* 0x53 */ "Conditional Access Identifier",
261 /* 0x54 */ "Content", /* 0x55 */ "Parental Rating",
262 /* 0x56 */ "Teletext", /* 0x57 */ "Telephone",
263 /* 0x58 */ "Local Time Offset", /* 0x59 */ "Subtitling",
264 /* 0x5A */ "Terrestrial Delivery System",
265 /* 0x5B */ "Multilingual Network Name",
266 /* 0x5C */ "Multilingual Bouquet Name",
267 /* 0x5D */ "Multilingual Service Name",
268 /* 0x5E */ "Multilingual Component",
269 /* 0x5F */ "Private Data Specifier",
270
271 /* 0x60 */ "Service Move", /* 0x61 */ "Short Smoothing Buffer",
272 /* 0x62 */ "Frequency List", /* 0x63 */ "Partial Transport Stream",
273 /* 0x64 */ "Data Broadcast", /* 0x65 */ "Scrambling",
274 /* 0x66 */ "Data Broadcast ID", /* 0x67 */ "Transport Stream",
275 /* 0x68 */ "DSNG", /* 0x69 */ "PDC",
276 /* 0x6A */ "AC-3", /* 0x6B */ "Ancillary Data",
277 /* 0x6C */ "Cell List", /* 0x6D */ "Cell Frequency Link",
278 /* 0x6E */ "Announcement Support", /* 0x6F */ "Application Signalling",
279
280 /* 0x70 */ "Adaptation Field Data", /* 0x71 */ "Service Identifier",
281 /* 0x72 */ "Service Availability", /* 0x73 */ "Default Authority",
282 /* 0x74 */ "Related Content", /* 0x75 */ "TVA ID",
283 /* 0x76 */ "DVB Content Identifier",/* 0x77 */ "Time Slice FEC Identifier",
284 /* 0x78 */ "ECM Repetition Rate", /* 0x79 */ "DVB-S2 Delivery Identifier",
285 /* 0x7A */ "E-AC-3", /* 0x7B */ "DTS",
286 /* 0x7C */ "AAC", /* 0x7D */ "XAIT location",
287 /* 0x7E */ "FTA content management",/* 0x7F */ "Extension",
288
289 /* 0x80 */ "ATSC Stuffing", /* 0x81 */ "AC-3 Audio",
290 /* 0x82 */ "SCTE Frame Rate", /* 0x83 */ "SCTE Extended Video",
291 /* 0x84 */ "SCTE Component Name", /* 0x85 */ "ATSC Program Identifier",
292 /* 0x86 */ "Caption Service", /* 0x87 */ "Content Advisory",
293 /* 0x88 */ "ATSC CA", /* 0x89 */ "ATSC Descriptor Tag",
294 /* 0x8A */ "SCTE CUE Identifier", /* 0x8B */ "",
295 /* 0x8C */ "TimeStamp", /* 0x8D */ "",
296 /* 0x8E */ "", /* 0x8F */ "",
297
298 /* 0x90 */ "SCTE Frequency Spec", /* 0x91 */ "SCTE Modulation Params",
299 /* 0x92 */ "SCTE TSID", /* 0x93 */ "SCTE Revision Detection",
300 /* 0x94 */ "SCTE Two part channel", /* 0x95 */ "SCTE Channel Properties",
301 /* 0x96 */ "SCTE Daylight Savings", /* 0x97 */ "SCTE AFD",
302 /* 0x98 */ "", /* 0x99 */ "",
303 /* 0x9A */ "", /* 0x9B */ "",
304 /* 0x9C */ "", /* 0x9D */ "",
305 /* 0x9E */ "", /* 0x9F */ "",
306
307 /* 0xA0 */ "Extended Channel Name", /* 0xA1 */ "Service Location",
308 /* 0xA2 */ "ATSC Time-shifted Service",/*0xA3*/"Component Name",
309 /* 0xA4 */ "ATSC Data Service", /* 0xA5 */ "ATSC PID Count",
310 /* 0xA6 */ "ATSC Download",
311 /* 0xA7 */ "ATSC Multiprotocol Encapsulation",
312 /* 0xA8 */ "DCC Departing Request", /* 0xA9 */ "DCC Arriving Request",
313 /* 0xAA */ "ATSC Restrictions Control",/*0xAB*/"ATSC Genre",
314 /* 0xAC */ "SCTE MAC Address List", /* 0xAD */ "ATSC Private Information",
315 /* 0xAE */ "ATSC Compatibility Wrap",/* 0xAF */"ATSC Broadcaster Policy",
316
317 /* 0xB0 */ "", /* 0xB1 */ "",
318 /* 0xB2 */ "", /* 0xB3 */ "",
319 /* 0xB4 */ "", /* 0xB5 */ "",
320 /* 0xB6 */ "ATSC Content ID", /* 0xB7 */ "",
321 /* 0xB8 */ "", /* 0xB9 */ "",
322 /* 0xBA */ "", /* 0xBB */ "",
323 /* 0xBC */ "", /* 0xBD */ "",
324 /* 0xBE */ "", /* 0xBF */ "",
325
326 /* 0xC0-0xCF */ EMPTY_STR_16
327 /* 0xD0-0xDF */ EMPTY_STR_16
328 /* 0xE0-0xEF */ EMPTY_STR_16
329 /* 0xF0-0xFF */ EMPTY_STR_16
330};
331
332static void comma_list_append(QString &str, const QString& extra)
333{
334 if (str.isEmpty())
335 str = extra;
336 else
337 str = str + ", " + extra;
338}
339
341{
342 QString str = QString::fromStdString(descriptor_tag_strings[DescriptorTag()]);
343
344 switch (DescriptorTag())
345 {
347 comma_list_append(str, "Possibly DVB Logical Channel Descriptor");
348 break;
350 comma_list_append(str, "Possibly Dishnet Rights");
351 break;
353 comma_list_append(str, "Possibly Dishnet MPAA");
354 break;
356 comma_list_append(str, "Possibly Dishnet EIT Name");
357 break;
359 comma_list_append(str, "Possibly Dishnet EIT Description");
360 break;
362 comma_list_append(str, "Possibly Dishnet Properties");
363 break;
365 comma_list_append(str, "Possibly Dishnet V-Chip");
366 break;
368 comma_list_append(str, "Possibly Dishnet Tag");
369 break;
371 comma_list_append(str, "Possibly DVB Sky/OpenTV Channel List");
372 break;
374 comma_list_append(str, "Possibly Premiere DE Content Order");
375 break;
377 comma_list_append(str, "Possibly Premiere DE Parental Information");
378 break;
380 comma_list_append(str, "Possibly Premiere DE Content Transmission");
381 break;
382 }
383
384 if (str.isEmpty())
385 str = QString("Unknown");
386
387 return str;
388}
389
390QString MPEGDescriptor::descrDump(const QString &name) const
391{
392 QString str;
393 str = QString("%1 Descriptor tag(0x%2) length(%3)")
394 .arg(name)
395 .arg(DescriptorTag(),2,16,QChar('0'))
396 .arg(DescriptorLength());
397 if (DescriptorLength() > 0)
398 {
399 str.append(" Dumping\n");
400 str.append(hexdump());
401 }
402 return str;
403}
404
405QString MPEGDescriptor::toString(void) const
406{
407 return toStringPD(0);
408}
409
410QString MPEGDescriptor::toStringPD(uint priv_dsid) const
411{
412 QString str;
413
414 if (!IsValid())
415 {
416 str = "Invalid Descriptor";
417 }
419 {
420 str = descrToString<VideoStreamDescriptor>();
421 }
423 {
424 str = descrToString<AudioStreamDescriptor>();
425 }
427 {
428 str = descrToString<RegistrationDescriptor>();
429 }
431 {
432 str = descrToString<DataStreamAlignmentDescriptor>();
433 }
435 {
436 str = descrToString<ConditionalAccessDescriptor>();
437 }
439 {
440 str = descrToString<ISO639LanguageDescriptor>();
441 }
443 {
444 str = descrToString<SystemClockDescriptor>();
445 }
447 {
448 str = descrToString<MaximumBitrateDescriptor>();
449 }
451 {
452 str = descrToString<SmoothingBufferDescriptor>();
453 }
455 {
456 str = descrToString<AVCVideoDescriptor>();
457 }
459 {
460 str = descrToString<HEVCVideoDescriptor>();
461 }
463 {
464 str = descrToString<NetworkNameDescriptor>();
465 }
467 {
468 str = descrToString<ServiceListDescriptor>();
469 }
471 {
472 str = descrToString<SatelliteDeliverySystemDescriptor>();
473 }
475 {
476 str = descrToString<CableDeliverySystemDescriptor>();
477 }
479 {
480 str = descrToString<BouquetNameDescriptor>();
481 }
483 {
484 str = descrToString<ServiceDescriptor>();
485 }
487 {
488 str = descrToString<CountryAvailabilityDescriptor>();
489 }
490 //else if (DescriptorID::linkage == DescriptorTag())
491 //{
492 // str = descrToString<LinkageDescriptor>();
493 //}
495 {
496 str = descrToString<StreamIdentifierDescriptor>();
497 }
499 {
500 str = descrToString<TeletextDescriptor>();
501 }
503 {
504 str = descrToString<SubtitlingDescriptor>();
505 }
507 {
508 str = descrToString<TerrestrialDeliverySystemDescriptor>();
509 }
511 {
512 str = descrToString<FrequencyListDescriptor>();
513 }
515 {
516 str = descrToString<ScramblingDescriptor>();
517 }
518 else if (DescriptorID::ac3 == DescriptorTag())
519 {
520 str = descrToString<AC3Descriptor>();
521 }
522 //else if (DescriptorID::ancillary_data == DescriptorTag())
523 //{
524 // str = descrToString<AncillaryDataDescriptor>();
525 //}
527 {
528 str = descrToString<ApplicationSignallingDescriptor>();
529 }
531 {
532 str = descrToString<AdaptationFieldDataDescriptor>();
533 }
535 {
536 str = descrToString<DefaultAuthorityDescriptor>();
537 }
539 {
540 str = descrToString<S2SatelliteDeliverySystemDescriptor>();
541 }
542 //
543 // Extension descriptors for extension 0x7F
546 {
547 str = descrToString<ImageIconDescriptor>();
548 }
551 {
552 str = descrToString<T2DeliverySystemDescriptor>();
553 }
556 {
557 str = descrToString<SHDeliverySystemDescriptor>();
558 }
561 {
562 str = descrToString<SupplementaryAudioDescriptor>();
563 }
566 {
567 str = descrToString<NetworkChangeNotifyDescriptor>();
568 }
571 {
572 str = descrToString<MessageDescriptor>();
573 }
576 {
577 str = descrToString<TargetRegionDescriptor>();
578 }
581 {
582 str = descrToString<TargetRegionNameDescriptor>();
583 }
586 {
587 str = descrToString<ServiceRelocatedDescriptor>();
588 }
591 {
592 str = descrToString<C2DeliverySystemDescriptor>();
593 }
596 {
597 str = descrToString<S2XSatelliteDeliverySystemDescriptor>();
598 }
599 //
600 // User Defined DVB descriptors, range 0x80-0xFE
601 else if (priv_dsid == PrivateDataSpecifierID::SES &&
603 {
604 str = descrDump("NorDig Content Protection");
605 }
606 else if (priv_dsid == PrivateDataSpecifierID::OTV &&
607 0x80 <= DescriptorTag() && DescriptorTag() < 0xFF)
608 {
609 str = descrDump("OpenTV Private ");
610 }
611 else if (priv_dsid == PrivateDataSpecifierID::BSB1 &&
613 {
614 str = descrToString<SkyLCNDescriptor>();
615 }
616 else if (priv_dsid == PrivateDataSpecifierID::FSAT &&
618 {
619 str = descrToString<FreesatRegionDescriptor>();
620 }
621 else if (priv_dsid == PrivateDataSpecifierID::FSAT &&
623 {
624 str = descrToString<FreesatLCNDescriptor>();
625 }
626 else if (priv_dsid == PrivateDataSpecifierID::FSAT &&
628 {
629 str = descrToString<FreesatCallsignDescriptor>();
630 }
631 else if (priv_dsid == PrivateDataSpecifierID::CASEMA &&
633 {
634 str = descrDump("Video on Demand");
635 }
636 else if (priv_dsid == PrivateDataSpecifierID::CASEMA &&
638 {
639 str = descrDump("Ziggo Package");
640 }
641 else if ((priv_dsid == PrivateDataSpecifierID::EACEM ||
642 priv_dsid == PrivateDataSpecifierID::NORDIG ||
643 priv_dsid == PrivateDataSpecifierID::ITC ) &&
645 {
646 str = descrToString<DVBSimulcastChannelDescriptor>();
647 }
648 else if ((priv_dsid == PrivateDataSpecifierID::EACEM ||
649 priv_dsid == PrivateDataSpecifierID::NORDIG ||
650 priv_dsid == PrivateDataSpecifierID::ITC ) &&
652 {
653 str = descrToString<DVBLogicalChannelDescriptor>();
654 }
655 else if (priv_dsid == PrivateDataSpecifierID::CIPLUS &&
657 {
658 str = descrDump("CI Protection");
659 }
660 // All not otherwise specified private descriptors
661 else if (priv_dsid > 0 && DescriptorTag() > 0x80)
662 {
663 str = descrDump("User Defined");
664 }
665 //
666 // POSSIBLY UNSAFE ! -- begin
667 // ATSC/SCTE descriptors, range 0x80-0xFE
669 {
670 str = descrToString<AC3AudioStreamDescriptor>();
671 }
673 {
674 str = descrToString<CaptionServiceDescriptor>();
675 }
677 {
678 str = descrToString<CueIdentifierDescriptor>();
679 }
681 {
682 str = descrToString<RevisionDetectionDescriptor>();
683 }
685 {
686 str = descrToString<ExtendedChannelNameDescriptor>();
687 }
688 else if (priv_dsid == 0 &&
690 {
691 str = descrToString<ComponentNameDescriptor>();
692 }
693 // POSSIBLY UNSAFE ! -- end
694 else
695 {
697 }
698 return str;
699}
700
704{
705 QString indent_0 = StringUtil::indentSpaces(level);
706 QString indent_1 = StringUtil::indentSpaces(level+1);
707 QString str;
708
709 str += indent_0 + "<Descriptor>\n";
710 str += indent_1 + QString("<Tag>0x%1</Tag>\n")
711 .arg(DescriptorTag(),2,16,QChar('0'));
712 str += indent_1 + QString("<Description>%1</Description>\n")
713 .arg(DescriptorTagString());
714
715 str += indent_1 + "<Data>";
716 for (uint i = 0; i < DescriptorLength(); i++)
717 {
718 if (((i%8) == 0) && i)
719 str += "\n" + indent_1 + " ";
720 str += QString("0x%1 ").arg(m_data[i+2],2,16,QChar('0'));
721 }
722
723 str += "\n" + indent_1 + "</Data>\n";
724 str += indent_1 + "<Decoded>" + toString().toHtmlEscaped() + "</Decoded>\n";
725 str += indent_0 + "</Descriptor>";
726
727 return str;
728}
729
730// Dump the descriptor in the same format as hexdump -C
731QString MPEGDescriptor::hexdump(void) const
732{
733 uint i = 0;
734 QString str;
735 QString hex;
736 QString prt;
737 for (i=0; i<DescriptorLength(); i++)
738 {
739 uint ch = m_data[i+2];
740 hex.append(QString(" %1").arg(ch, 2, 16, QChar('0')));
741 prt.append(QString("%1").arg(isprint(ch) ? QChar(ch) : '.'));
742 if (((i+1) % 8) == 0)
743 hex.append(" ");
744 if (((i+1) % 16) == 0)
745 {
746 str.append(QString(" %1 %2 |%3|")
747 .arg(i - (i % 16),3,16,QChar('0'))
748 .arg(hex, prt));
749 hex.clear();
750 prt.clear();
751 if (i < (DescriptorLength() - 1))
752 {
753 str.append("\n");
754 }
755 }
756 }
757 if (!hex.isEmpty())
758 {
759 str.append(QString(" %1 %2 |%3|")
760 .arg(i - (i % 16),3,16,QChar('0'))
761 .arg(hex,-50,' ').arg(prt));
762 }
763 return str;
764}
765
767{
768 QString str = QString("Video Stream Descriptor: frame_rate(%1) MPEG-1(%2)")
769 .arg(FrameRateCode())
770 .arg(MPEG1OnlyFlag());
771 if (!MPEG1OnlyFlag())
772 {
773 str.append(QString(" still_picture(%1) profile(%2)")
774 .arg(StillPictureFlag())
776 }
777 return str;
778}
779
781{
782 return QString("Audio Stream Descriptor: free_format(%1) ID(%2) layer(%3) variable_rate(%4)")
783 .arg(FreeFormatFlag())
784 .arg(ID())
785 .arg(Layer())
787}
788
790{
791 QMutexLocker locker(&description_map_lock);
793 return;
794
795 description_map["AC-3"] = "ATSC audio stream A/52";
796 description_map["AVSV"] = "China A/V Working Group";
797 description_map["BDC0"] = "Broadcast Data Corporation Software Data Service";
798 description_map["BSSD"] = "SMPTE 302M-1998 Audio data as specified in (AES3)";
799 description_map["CAPO"] = "SMPTE 315M-1999 Camera Positioning Information";
800 description_map["CUEI"] = "SCTE 35 2003, Cable Digital Program Insertion Cueing Message";
801 description_map["DDED"] = "LGEUS Digital Delivery with encryption and decryption";
802 description_map["DISH"] = "EchoStar MPEG streams";
803 description_map["DRA1"] = "Chinese EIS SJ/T11368-2006 DRA digital audio";
804 description_map["DTS1"] = "DTS Frame size of 512 bytes";
805 description_map["DTS2"] = "DTS Frame size of 1024 bytes";
806 description_map["DTS3"] = "DTS Frame size of 2048";
807 description_map["DVDF"] = "DVD compatible MPEG2-TS";
808 description_map["ETV1"] = "CableLabs ETV info is present";
809 description_map["GA94"] = "ATSC program ID A/53";
810 description_map["GWKS"] = "GuideWorks EPG info";
811 description_map["HDMV"] = "Blu-Ray A/V for read-only media (H.264 TS)";
812 description_map["HDMX"] = "Matsushita-TS";
813 description_map["KLVA"] = "SMPTE RP 217-2001 MXF KLV packets present";
814 description_map["LU-A"] = "SMPTE RDD-11 HDSDI HD serial/video data";
815 description_map["MTRM"] = "D-VHS compatible MPEG2-TS";
816 description_map["NMR1"] = "Nielsen content identifier";
817 description_map["PAUX"] = "Philips ES containing low-speed data";
818 description_map["PMSF"] = "MPEG-TS stream modified by STB";
819 description_map["PRMC"] = "Philips ES containing remote control data";
820 description_map["SCTE"] = "SCTE 54 2003 Digital Video Service Multiplex and TS for Cable";
821 description_map["SEN1"] = "ATSC Private Information identifies source of stream";
822 description_map["SESF"] = "Blu-Ray A/V for ReWritable media (H.264 TS)";
823 description_map["SPLC"] = "SMPTE Proposed 312M Splice Point compatible TS";
824 description_map["SVMD"] = "SMPTE Proposed Video Metatdata Dictionary for MPEG2-TS";
825 description_map["SZMI"] = "ATSC Private Info from Building B";
826 description_map["TRIV"] = "ATSC Private Info from Triveni Digital";
827 description_map["TSBV"] = "Toshiba self-encoded H.264 TS";
828 description_map["TSHV"] = "Sony self-encoded MPEG-TS and private data";
829 description_map["TSMV"] = "Sony self-encoded MPEG-TS and private data";
830 description_map["TVG1"] = "TV Guide EPG Data";
831 description_map["TVG2"] = "TV Guide EPG Data";
832 description_map["TVG3"] = "TV Guide EPG Data";
833 description_map["ULE1"] = "IETF RFC4326 compatible MPEG2-TS";
834 description_map["VC-1"] = "SMPTE Draft RP 227 VC-1 Bitstream Transport Encodings";
835
836 for (uint i = 0; i <= 99; i++)
837 {
838 description_map[QString("US%1").arg(i, 2, 16, QLatin1Char('0'))] =
839 "NIMA, Unspecified military application";
840 }
841
843}
844
845QString RegistrationDescriptor::GetDescription(const QString &fmt)
846{
848
849 QString ret;
850 {
851 QMutexLocker locker(&description_map_lock);
852 QMap<QString,QString>::const_iterator it = description_map.constFind(fmt);
853 if (it != description_map.constEnd())
854 ret = *it;
855 }
856
857 return ret;
858}
859
861{
862 QString fmt = FormatIdentifierString();
863 QString msg = QString("Registration Descriptor: '%1' ").arg(fmt);
864
865 QString msg2 = GetDescription(fmt);
866 if (msg2.isEmpty())
867 msg2 = "Unknown, see http://www.smpte-ra.org/mpegreg/mpegreg.html";
868
869 return msg + msg2;
870}
871
873{
874 return QString("Data Stream Alignment Descriptor: alignment_type(%1)")
875 .arg(AlignmentType());
876}
877
879{
880 return QString("Conditional Access: sid(0x%1) pid(0x%2) data_size(%3)")
881 .arg(SystemID(),0,16).arg(PID(),0,16).arg(DataSize());
882}
883
885{
886 return QString("ISO-639 Language: code(%1) canonical(%2) eng(%3)")
889}
890
892{
893 return QString("System Clock Descriptor: extref(%1) accuracy(%2e-%3 ppm)")
896 .arg(ClockAccuracyExponent());
897}
898
900{
901 return QString("Maximum Bitrate Descriptor: maximum_bitrate(0x%1) %2 Mbit/s")
902 .arg(MaximumBitrate(),6,16,QChar('0'))
903 .arg(MaximumBitrate() * 1.0 * 50 * 8 / 1e6);
904}
905
907{
908 QString str = QString("Smoothing Buffer Descriptor ");
909 str += QString("tag(0x%1) ").arg(DescriptorTag(),2,16,QChar('0'));
910 str += QString("length(%1) ").arg(DescriptorLength());
911
912 str +=
913 QString("sb_leak_rate(0x%1) %2 kB/s ")
914 .arg(SBLeakRate(),6,16,QChar('0'))
915 .arg(SBLeakRate() * 400.0 / (8 * 1e3)) +
916 QString("sb_size(0x%1) %2 kB")
917 .arg(SBSize(),6,16,QChar('0'))
918 .arg(SBSize() / 1e3);
919 return str;
920}
921
923{
924 return QString("AVC Video: IDC prof(%1) IDC level(%2) sets(%3%4%5) "
925 "compat(%6) still(%7) 24hr(%8) FramePacking(%9)")
926 .arg(ProfileIDC()).arg(LevelIDC())
927 .arg(static_cast<int>(ConstraintSet0()))
928 .arg(static_cast<int>(ConstraintSet1()))
929 .arg(static_cast<int>(ConstraintSet2()))
930 .arg(AVCCompatible())
931 .arg(static_cast<int>(AVCStill()))
932 .arg(static_cast<int>(AVC24HourPicture()))
933 .arg(static_cast<int>(FramePackingSEINotPresentFlag()));
934}
935
937{
938 QString str = QString("HEVC Video: ProfileSpace(%1) Tier(%2) ProfileIDC(%3)")
939 .arg(ProfileSpace()).arg(Tier()).arg(ProfileIDC());
940 str.append(" Dumping\n");
941 str.append(hexdump());
942 return str;
943}
bool AVCStill(void) const
uint LevelIDC(void) const
bool FramePackingSEINotPresentFlag(void) const
QString toString() const override
bool ConstraintSet1(void) const
bool ConstraintSet2(void) const
bool AVC24HourPicture(void) const
bool ConstraintSet0(void) const
uint AVCCompatible(void) const
uint ProfileIDC(void) const
bool FreeFormatFlag(void) const
QString toString() const override
bool ID(void) const
uint Layer(void) const
bool VariableRateAudioIndicator(void) const
QString toString() const override
QString toString() const override
@ terrestrial_delivery_system
@ s2x_satellite_delivery_system
@ s2_satellite_delivery_system
int LanguageKey(void) const
int CanonicalLanguageKey(void) const
QString toString() const override
uint ProfileSpace(void) const
uint ProfileIDC(void) const
bool Tier(void) const
QString LanguageString(void) const
QString CanonicalLanguageString(void) const
int CanonicalLanguageKey(void) const
QString toString() const override
static desc_list_t FindAll(const desc_list_t &parsed, uint desc_tag)
uint DescriptorLength(void) const
static const unsigned char * FindExtension(const desc_list_t &parsed, uint desc_tag)
static desc_list_t Parse(const unsigned char *data, uint len)
static desc_list_t ParseAndExclude(const unsigned char *data, uint len, int excluded_descid)
QString hexdump(void) const
uint DescriptorTag(void) const
bool IsValid(void) const
static desc_list_t ParseOnlyInclude(const unsigned char *data, uint len, int excluded_descid)
uint size(void) const
uint DescriptorTagExtension(void) const
QString descrDump(const QString &name) const
static desc_list_t FindBestMatches(const desc_list_t &parsed, uint desc_tag, QMap< uint, uint > &langPref)
static const unsigned char * FindBestMatch(const desc_list_t &parsed, uint desc_tag, QMap< uint, uint > &langPref)
virtual QString toStringPD(uint priv_dsid) const
QString DescriptorTagString(void) const
static const unsigned char * Find(const desc_list_t &parsed, uint desc_tag)
virtual QString toStringXML(uint indent_level) const
Returns XML representation of string the TS Reader XML format.
virtual QString toString(void) const
const unsigned char * m_data
uint MaximumBitrate(void) const
QString toString() const override
static QMap< QString, QString > description_map
static void InitializeDescriptionMap(void)
static QMutex description_map_lock
static QString GetDescription(const QString &fmt)
static bool description_map_initialized
QString toString() const override
QString FormatIdentifierString(void) const
int CanonicalLanguageKey(void) const
QString toString(void) const override
uint SBLeakRate(void) const
uint ClockAccuracyExponent(void) const
bool ExternalClockReferenceIndicator(void) const
uint ClockAccuracyInteger(void) const
QString toString() const override
QString toString() const override
uint ProfileAndLevelIndication(void) const
uint FrameRateCode(void) const
bool MPEG1OnlyFlag(void) const
bool StillPictureFlag(void) const
unsigned int uint
Definition: compat.h:68
static guint32 * tmp
Definition: goom_core.cpp:26
QString iso639_key_toName(int iso639_2)
Converts a canonical key to language name in English.
Definition: iso639.cpp:109
const std::array< const std::string, 256 > descriptor_tag_strings
static uint maxPriority(const QMap< uint, uint > &langPrefs)
static void comma_list_append(QString &str, const QString &extra)
#define EMPTY_STR_16
std::vector< const unsigned char * > desc_list_t
QString indentSpaces(unsigned int level, unsigned int size=4)
Definition: stringutil.h:36