7 #include <QCoreApplication>
23 for (
uint i = 0; (i < length) && buf[i]; i++)
68 size_t length = (raw_length - 1) / 2;
69 auto *to =
new QChar[length];
70 for (
size_t i=0; i<length; i++)
71 to[i] = (src[1 + i*2] << 8) + src[1 + i*2 + 1];
72 QString to2(to, length);
77 if (((0x11 < src[0]) && (src[0] < 0x15)) ||
78 ((0x15 < src[0]) && (src[0] < 0x1f)))
81 LOG(VB_SIPARSER, LOG_ERR,
82 "dvb_decode_text: Multi-byte coded text is not yet supported.");
88 auto *dst =
new unsigned char[raw_length + encoding_override.size()];
91 if (!encoding_override.empty() && (src[0] >= 0x20)) {
92 std::copy(encoding_override.cbegin(), encoding_override.cend(), dst);
93 length = encoding_override.size();
97 for (
uint i = 0; i < raw_length; i++)
99 if ((src[i] < 0x80) || (src[i] > 0x9F))
101 dst[length++] = src[i];
104 else if (src[i] == 0x8A)
106 dst[length++] = 0x20;
112 QString sStr = (!length) ?
"" :
decode_text(dst, length);
123 static const std::array<QTextCodec *,16>s_iso8859Codecs
125 QTextCodec::codecForName(
"Latin1"),
126 QTextCodec::codecForName(
"ISO8859-1"),
127 QTextCodec::codecForName(
"ISO8859-2"),
128 QTextCodec::codecForName(
"ISO8859-3"),
129 QTextCodec::codecForName(
"ISO8859-4"),
130 QTextCodec::codecForName(
"ISO8859-5"),
131 QTextCodec::codecForName(
"ISO8859-6"),
132 QTextCodec::codecForName(
"ISO8859-7"),
133 QTextCodec::codecForName(
"ISO8859-8"),
134 QTextCodec::codecForName(
"ISO8859-9"),
135 QTextCodec::codecForName(
"ISO8859-10"),
136 QTextCodec::codecForName(
"ISO8859-11"),
137 QTextCodec::codecForName(
"ISO8859-12"),
138 QTextCodec::codecForName(
"ISO8859-13"),
139 QTextCodec::codecForName(
"ISO8859-14"),
140 QTextCodec::codecForName(
"ISO8859-15"),
148 if ((buf[0] >= 0x01) && (buf[0] <= 0x0B))
150 return s_iso8859Codecs[4 + buf[0]]->toUnicode((
char*)(buf + 1), length - 1);
160 uint code = buf[1] << 8 | buf[2];
162 return s_iso8859Codecs[code]->toUnicode((
char*)(buf + 3), length - 3);
163 return QString::fromLocal8Bit((
char*)(buf + 3), length - 3);
167 return QString::fromUtf8((
char*)(buf + 1), length - 1);
171 return QString::fromLocal8Bit((
char*)(buf + 1), length - 1);
179 LOG(VB_SIPARSER, LOG_WARNING,
180 QString(
"dvb_decode_short_name: name is %1 chars "
181 "long. Unlikely to be a short name.")
186 if (((0x10 < src[0]) && (src[0] < 0x15)) ||
187 ((0x15 < src[0]) && (src[0] < 0x20)))
190 LOG(VB_SIPARSER, LOG_ERR,
"dvb_decode_short_name: "
191 "Multi-byte coded text is not yet supported.");
195 auto *dst =
new unsigned char[raw_length];
199 for (
uint i = 0; i < raw_length; i++)
203 while ((++i < raw_length) && (src[i] != 0x87))
205 if ((src[i] < 0x80) || (src[i] > 0x9F))
207 dst[length++] = src[i];
210 else if (src[i] == 0x8A)
212 dst[length++] = 0x20;
242 "Information Service",
244 "CA Replacement Service",
245 "TS Containing Complete Network/Bouquet SI",
246 "Service Replacement Service",
247 "Data Broadcast Service",
250 "System Software Update Service",
251 "TS Containing SSU, BAT or NIT",
252 "IP/MAC Notification Service",
253 "TS Containing INT, BAT or NIT",
263 return QString(
"Reserved(0x%1)").arg(
LinkageType(),2,16,QChar(
'0'));
264 return QString(
"User Defined(0x%1)").arg(
LinkageType(),2,16,QChar(
'0'));
270 return "Hand-Over to an Identical Service";
272 return "Hand-Over to a Local Variation";
274 return "Hand-over to an Associated Service";
301 QString
tmp(
"ContentDescriptor: ");
315 QString subCatStr = QCoreApplication::translate(
"(Categories)",
316 "%1 - %2",
"Category with subcategory display");
318 s_categoryDesc[0x10] = QCoreApplication::translate(
"(Categories)",
"Movie");
320 .arg(QCoreApplication::translate(
"(Categories)",
"Movie"))
321 .arg(QCoreApplication::translate(
"(Categories)",
"Detective/Thriller"));
323 .arg(QCoreApplication::translate(
"(Categories)",
"Movie"))
324 .arg(QCoreApplication::translate(
"(Categories)",
325 "Adventure/Western/War"));
327 .arg(QCoreApplication::translate(
"(Categories)",
"Movie"))
328 .arg(QCoreApplication::translate(
"(Categories)",
329 "Science Fiction/Fantasy/Horror"));
331 .arg(QCoreApplication::translate(
"(Categories)",
"Movie"))
332 .arg(QCoreApplication::translate(
"(Categories)",
"Comedy"));
334 .arg(QCoreApplication::translate(
"(Categories)",
"Movie"))
335 .arg(QCoreApplication::translate(
"(Categories)",
336 "Soap/melodrama/folkloric"));
338 .arg(QCoreApplication::translate(
"(Categories)",
"Movie"))
339 .arg(QCoreApplication::translate(
"(Categories)",
"Romance"));
341 .arg(QCoreApplication::translate(
"(Categories)",
"Movie"))
342 .arg(QCoreApplication::translate(
"(Categories)",
343 "Serious/Classical/Religious/Historical Movie/Drama"));
345 .arg(QCoreApplication::translate(
"(Categories)",
"Movie"))
346 .arg(QCoreApplication::translate(
"(Categories)",
"Adult",
349 s_categoryDesc[0x20] = QCoreApplication::translate(
"(Categories)",
"News");
350 s_categoryDesc[0x21] = QCoreApplication::translate(
"(Categories)",
351 "News/weather report");
352 s_categoryDesc[0x22] = QCoreApplication::translate(
"(Categories)",
354 s_categoryDesc[0x23] = QCoreApplication::translate(
"(Categories)",
356 s_categoryDesc[0x24] = QCoreApplication::translate(
"(Categories)",
357 "Intelligent Programs");
359 s_categoryDesc[0x30] = QCoreApplication::translate(
"(Categories)",
361 s_categoryDesc[0x31] = QCoreApplication::translate(
"(Categories)",
363 s_categoryDesc[0x32] = QCoreApplication::translate(
"(Categories)",
365 s_categoryDesc[0x33] = QCoreApplication::translate(
"(Categories)",
368 s_categoryDesc[0x40] = QCoreApplication::translate(
"(Categories)",
370 s_categoryDesc[0x41] = QCoreApplication::translate(
"(Categories)",
371 "Special Events (World Cup, World Series, etc)");
372 s_categoryDesc[0x42] = QCoreApplication::translate(
"(Categories)",
374 s_categoryDesc[0x43] = QCoreApplication::translate(
"(Categories)",
375 "Football (Soccer)");
376 s_categoryDesc[0x44] = QCoreApplication::translate(
"(Categories)",
378 s_categoryDesc[0x45] = QCoreApplication::translate(
"(Categories)",
379 "Misc. Team Sports");
381 s_categoryDesc[0x46] = QCoreApplication::translate(
"(Categories)",
383 s_categoryDesc[0x47] = QCoreApplication::translate(
"(Categories)",
385 s_categoryDesc[0x48] = QCoreApplication::translate(
"(Categories)",
387 s_categoryDesc[0x49] = QCoreApplication::translate(
"(Categories)",
389 s_categoryDesc[0x4A] = QCoreApplication::translate(
"(Categories)",
391 s_categoryDesc[0x4B] = QCoreApplication::translate(
"(Categories)",
394 s_categoryDesc[0x50] = QCoreApplication::translate(
"(Categories)",
"Kids");
395 s_categoryDesc[0x51] = QCoreApplication::translate(
"(Categories)",
396 "Pre-School Children's Programs");
397 s_categoryDesc[0x52] = QCoreApplication::translate(
"(Categories)",
398 "Entertainment Programs for 6 to 14");
399 s_categoryDesc[0x53] = QCoreApplication::translate(
"(Categories)",
400 "Entertainment Programs for 10 to 16");
401 s_categoryDesc[0x54] = QCoreApplication::translate(
"(Categories)",
402 "Informational/Educational");
403 s_categoryDesc[0x55] = QCoreApplication::translate(
"(Categories)",
406 s_categoryDesc[0x60] = QCoreApplication::translate(
"(Categories)",
407 "Music/Ballet/Dance");
408 s_categoryDesc[0x61] = QCoreApplication::translate(
"(Categories)",
410 s_categoryDesc[0x62] = QCoreApplication::translate(
"(Categories)",
412 s_categoryDesc[0x63] = QCoreApplication::translate(
"(Categories)",
414 s_categoryDesc[0x64] = QCoreApplication::translate(
"(Categories)",
416 s_categoryDesc[0x65] = QCoreApplication::translate(
"(Categories)",
418 s_categoryDesc[0x66] = QCoreApplication::translate(
"(Categories)",
421 s_categoryDesc[0x70] = QCoreApplication::translate(
"(Categories)",
423 s_categoryDesc[0x71] = QCoreApplication::translate(
"(Categories)",
425 s_categoryDesc[0x72] = QCoreApplication::translate(
"(Categories)",
427 s_categoryDesc[0x73] = QCoreApplication::translate(
"(Categories)",
429 s_categoryDesc[0x74] = QCoreApplication::translate(
"(Categories)",
430 "Popular Culture/Traditional Arts");
431 s_categoryDesc[0x75] = QCoreApplication::translate(
"(Categories)",
433 s_categoryDesc[0x76] = QCoreApplication::translate(
"(Categories)",
435 s_categoryDesc[0x77] = QCoreApplication::translate(
"(Categories)",
436 "Experimental Film/Video");
437 s_categoryDesc[0x78] = QCoreApplication::translate(
"(Categories)",
438 "Broadcasting/Press");
439 s_categoryDesc[0x79] = QCoreApplication::translate(
"(Categories)",
441 s_categoryDesc[0x7A] = QCoreApplication::translate(
"(Categories)",
442 "Arts/Culture Magazines");
443 s_categoryDesc[0x7B] = QCoreApplication::translate(
"(Categories)",
"Fashion");
445 s_categoryDesc[0x80] = QCoreApplication::translate(
"(Categories)",
446 "Social/Policical/Economics");
447 s_categoryDesc[0x81] = QCoreApplication::translate(
"(Categories)",
448 "Magazines/Reports/Documentary");
449 s_categoryDesc[0x82] = QCoreApplication::translate(
"(Categories)",
450 "Economics/Social Advisory");
451 s_categoryDesc[0x83] = QCoreApplication::translate(
"(Categories)",
452 "Remarkable People");
454 s_categoryDesc[0x90] = QCoreApplication::translate(
"(Categories)",
455 "Education/Science/Factual");
456 s_categoryDesc[0x91] = QCoreApplication::translate(
"(Categories)",
457 "Nature/animals/Environment");
458 s_categoryDesc[0x92] = QCoreApplication::translate(
"(Categories)",
459 "Technology/Natural Sciences");
460 s_categoryDesc[0x93] = QCoreApplication::translate(
"(Categories)",
461 "Medicine/Physiology/Psychology");
462 s_categoryDesc[0x94] = QCoreApplication::translate(
"(Categories)",
463 "Foreign Countries/Expeditions");
464 s_categoryDesc[0x95] = QCoreApplication::translate(
"(Categories)",
465 "Social/Spiritual Sciences");
466 s_categoryDesc[0x96] = QCoreApplication::translate(
"(Categories)",
467 "Further Education");
468 s_categoryDesc[0x97] = QCoreApplication::translate(
"(Categories)",
471 s_categoryDesc[0xA0] = QCoreApplication::translate(
"(Categories)",
473 s_categoryDesc[0xA1] = QCoreApplication::translate(
"(Categories)",
475 s_categoryDesc[0xA2] = QCoreApplication::translate(
"(Categories)",
477 s_categoryDesc[0xA3] = QCoreApplication::translate(
"(Categories)",
479 s_categoryDesc[0xA4] = QCoreApplication::translate(
"(Categories)",
481 s_categoryDesc[0xA5] = QCoreApplication::translate(
"(Categories)",
"Cooking");
482 s_categoryDesc[0xA6] = QCoreApplication::translate(
"(Categories)",
483 "Advertizement/Shopping");
484 s_categoryDesc[0xA7] = QCoreApplication::translate(
"(Categories)",
487 s_categoryDesc[0xB0] = QCoreApplication::translate(
"(Categories)",
488 "Original Language");
489 s_categoryDesc[0xB1] = QCoreApplication::translate(
"(Categories)",
491 s_categoryDesc[0xB2] = QCoreApplication::translate(
"(Categories)",
492 "\"Unpublished\" Programs");
493 s_categoryDesc[0xB3] = QCoreApplication::translate(
"(Categories)",
496 s_categoryDesc[0xF0] = QCoreApplication::translate(
"(Categories)",
504 QString str =
"FrequencyListDescriptor: frequencies: ";
509 str += (i+1 <
FrequencyCount()) ? ((i+4)%10) ?
", " :
",\n " :
"";
522 str.append(
" (Radio)");
524 str.append(
" (HDTV)");
526 str.append(
" (UHDTV)");
528 str.append(
" (Teletext)");
530 str.append(QString(
" (Unknown 0x%1)").
arg(
ServiceType(),2,16,QChar(
'0')));
537 QString str = QString(
"Teletext Descriptor: %1 pages")
545 str.append(QString(
" type(%1) mag(%2) page(%3) lang(%4)")
557 QString str = QString(
"CableDeliverySystemDescriptor: ");
560 str.append(QString(
" Mod=%1, SymbR=%2, FECInner=%3, FECOuter=%4")
571 QString str = QString(
"SatelliteDeliverySystemDescriptor: ");
575 str.append(QString(
" Mod=%1, SymbR=%2, FECInner=%3, Orbit=%4, Pol=%5")
587 QString str = QString(
"TerrestrialDeliverySystemDescriptor: ");
590 str.append(QString(
" BW=%1MHz C=%2 HP=%3 LP=%4 GI=%5 TransMode=%6k")
604 QString str = QString(
"ImageIconDescriptor ");
605 str += QString(
"(0x%1 ").arg(
DescriptorTag(),2,16,QChar(
'0'));
612 str.append(
" Dumping\n");
623 const unsigned char *cp =
m_data + 8;
635 QString str = QString(
"T2DeliverySystemDescriptor ");
636 str += QString(
"(0x%1 ").arg(
DescriptorTag(),2,16,QChar(
'0'));
639 str += QString(
"plp_id(%1) ").arg(
PlpID());
640 str += QString(
"T2_system_id(%1)").arg(
T2SystemID());
648 str += QString(
"TFS=%1 ").arg(
TFSFlag());
654 str += QString(
"\n ");
655 str += QString(
"cell_id:%1 ").arg(
CellID(i));
656 str += QString(
"centre_frequency:");
670 str += QString(
"\n ");
676 str.append(
" Dumping\n");
684 QString str = QString(
"SHDeliverySystemDescriptor ");
685 str += QString(
"(0x%1 ").arg(
DescriptorTag(),2,16,QChar(
'0'));
691 str.append(
" Dumping\n");
699 QString str = QString(
"SupplementaryAudioDescriptor ");
700 str += QString(
"(0x%1 ").arg(
DescriptorTag(),2,16,QChar(
'0'));
703 str += QString(
"\n ");
704 str += QString(
"mix_type(%1) ").arg(
MixType());
706 str += QString(
"\n ");
713 str.append(
" Dumping\n");
721 QString str = QString(
"NetworkChangeNotiyDescriptor ");
722 str += QString(
"(0x%1 ").arg(
DescriptorTag(),2,16,QChar(
'0'));
725 str.append(
" Dumping\n");
733 QString str = QString(
"MessageDescriptor ");
734 str += QString(
"(0x%1 ").arg(
DescriptorTag(),2,16,QChar(
'0'));
737 str += QString(
"\n ");
738 str += QString(
"message_id(%1) ").arg(
MessageID());
740 str += QString(
"\n ");
741 str += QString(
"text_char(\"%1\")").arg(
Message());
743 str.append(
" Dumping\n");
751 QString str = QString(
"TargetRegionDescriptor ");
752 str += QString(
"(0x%1 ").arg(
DescriptorTag(),2,16,QChar(
'0'));
755 str += QString(
"\n ");
760 str.append(
" Dumping\n");
768 QString str = QString(
"TargetRegionNameDescriptor ");
769 str += QString(
"(0x%1 ").arg(
DescriptorTag(),2,16,QChar(
'0'));
772 str += QString(
"\n ");
778 str.append(
" Dumping\n");
786 QString str = QString(
"ServiceRelocatedDescriptor ");
787 str += QString(
"(0x%1 ").arg(
DescriptorTag(),2,16,QChar(
'0'));
790 str += QString(
"\n ");
793 str += QString(
"old_service_id(%1) ").arg(
OldServiceID());
795 str.append(
" Dumping\n");
803 QString str = QString(
"C2DeliverySystemDescriptor ");
804 str += QString(
"(0x%1 ").arg(
DescriptorTag(),2,16,QChar(
'0'));
810 str.append(
" Dumping\n");
818 QString str = QString(
"S2XSatelliteDeliverySystemDescriptor ");
819 str += QString(
"(0x%1 ").arg(
DescriptorTag(),2,16,QChar(
'0'));
825 str.append(
" Dumping\n");
832 QString ret =
"UKChannelListDescriptor sid->chan_num: ";
836 ret += (i+1 <
ChannelCount()) ? ((i+4)%10) ?
", " :
",\n " :
"";
843 QString ret =
"DVBSimulcastChannelDescriptor sid->chan_num: ";
847 ret += (i+1 <
ChannelCount()) ? ((i+3)%10) ?
", " :
",\n " :
"";
854 QString ret =
"Sky Logical Channel Number Descriptor ";
855 ret += QString(
"(0x%1) ").arg(
DescriptorTag(),2,16,QChar(
'0'));
858 ret += QString(
"\n RegionID (%1) (0x%2) Raw (0x%3)")
863 ret += QString(
"\n ServiceID (%1) (0x%2) ").arg(
ServiceID(i)).arg(
ServiceID(i),4,16,QChar(
'0'));
864 ret += QString(
"ServiceType (0x%1) ").arg(
ServiceType(i),2,16,QChar(
'0'));
866 ret += QString(
"ChannelID(0x%1) ").arg(
ChannelID(i),4,16,QChar(
'0'));
867 ret += QString(
"Flags(0x%1) ").arg(
Flags(i),4,16,QChar(
'0'));
875 QString ret =
"Freesat Logical Channel Number Descriptor ";
876 ret += QString(
"(0x%1)").arg(
DescriptorTag(),2,16,QChar(
'0'));
881 ret += QString(
"\n ServiceID (%1) (0x%2) ").arg(
ServiceID(i)).arg(
ServiceID(i),4,16,QChar(
'0'));
882 ret += QString(
"ChanID (0x%1)").arg(
ChanID(i), 4, 16, QChar(
'0'));
893 QString ret =
"Freesat Region Descriptor ";
894 ret += QString(
"(0x%1)").arg(
DescriptorTag(),2,16,QChar(
'0'));
902 ret += QString(
"\n Region (%1) (%2) '%3'")
903 .arg(region_id,2).arg(language).arg(region_name);
910 QString ret = QString(
"Freesat Callsign Descriptor ");
911 ret += QString(
"(0x%1)").arg(
DescriptorTag(),2,16,QChar(
'0'));
919 QString ret = QString(
"OpenTV ChannelList Descriptor region: %1 sid->chan_num(id): ").arg(
RegionID());
930 QString ret = QString(
"CAIdentifierDescriptor ");
933 ret += QString(
"ca_system_id(0x%1) ")
941 QString ret = QString(
"DataBroadcastDescriptor: "
942 "data_broadcast_id(%1) "
943 "component_tag(%1) ")
947 ret += QString(
"selector(0x ");
949 ret += QString(
"%1 ").arg(
Selector()[i], 0, 16);
952 ret += QString(
"ISO_639_language_code(%1) ")
955 ret += QString(
"text(%1) ") +
Text();
962 QString ret = QString(
"LocalTimeOffsetDescriptor ");
964 for (
uint i = 0; i < count; ++i)
966 ret += QString(
"country_code(%1) country_region_id(0x%2) "
967 "local_time_offset_with_polarity(%3) "
968 "time_of_change(TODO)")
979 QString ret = QString(
"NVODReferenceDescriptor ");
982 ret += QString(
"transport_stream_id(0x%1) original_network_id(0x%2) "
993 return QString(
"PartialTransportStreamDescriptor peak_rate(%1) "
994 "min_overall_smooth_rate(%2) max_overall_smooth_buf(3)")
1000 QString ret = QString(
"AC3DescriptorDescriptor ");
1002 ret += QString(
"component_type(%1) ")
1005 ret += QString(
"bsid(0x%1) ").arg(
BSID(),0,16);
1007 ret += QString(
"mainid(0x%1) ").arg(
MainID(),0,16);
1009 ret += QString(
"asvc(%1) ").arg(
ASVC());
1015 QMultiMap<QString, QString> ret;
1025 index += 1 +
m_data[7 + index];
1027 index += 1 +
m_data[7 + index];
1028 ret.insert (item_description, item);