From 11de43ad048478ebc7718d72f71486d4bf1242c4 Mon Sep 17 00:00:00 2001 From: Karl Dietz Date: Sun, 18 Aug 2013 11:34:11 +0200 Subject: [PATCH] strip IMI from CRID to unbreak duplicate matching Refs #11757 --- mythtv/libs/libmythtv/mpeg/dvbdescriptors.h | 11 ++++- mythtv/libs/libmythtv/mpeg/mpegdescriptors.h | 3 +- .../test/test_mpegtables/test_mpegtables.h | 45 +++++++++++++++++++ 3 files changed, 57 insertions(+), 2 deletions(-) diff --git a/mythtv/libs/libmythtv/mpeg/dvbdescriptors.h b/mythtv/libs/libmythtv/mpeg/dvbdescriptors.h index 543ce946662..e4a55c1f829 100644 --- a/mythtv/libs/libmythtv/mpeg/dvbdescriptors.h +++ b/mythtv/libs/libmythtv/mpeg/dvbdescriptors.h @@ -2012,7 +2012,16 @@ class DVBContentIdentifierDescriptor : public MPEGDescriptor // A content identifier is a URI. It may contain UTF-8 encoded using %XX. QString ContentId(void) const { - return QString::fromLatin1((const char *)_data+4, _data[3]); + int length = _data[3]; + int positionOfHash = length-1; + while (positionOfHash >= 0) { + if (_data[4 + positionOfHash] == '#') { + length = positionOfHash; /* remove the hash and the following IMI */ + break; + } + positionOfHash--; + } + return QString::fromLatin1((const char *)&_data[4], length); } }; diff --git a/mythtv/libs/libmythtv/mpeg/mpegdescriptors.h b/mythtv/libs/libmythtv/mpeg/mpegdescriptors.h index 39ac1451d1d..b5ef049dbf7 100644 --- a/mythtv/libs/libmythtv/mpeg/mpegdescriptors.h +++ b/mythtv/libs/libmythtv/mpeg/mpegdescriptors.h @@ -13,6 +13,7 @@ using namespace std; // MythTV #include "iso639.h" +#include "mythtvexp.h" typedef vector desc_list_t; @@ -197,7 +198,7 @@ class PrivateDescriptorID }; }; -class MPEGDescriptor +class MTV_PUBLIC MPEGDescriptor { public: operator const unsigned char*() const { return _data; } diff --git a/mythtv/libs/libmythtv/test/test_mpegtables/test_mpegtables.h b/mythtv/libs/libmythtv/test/test_mpegtables/test_mpegtables.h index 1119480b63f..f63e6ffcf38 100644 --- a/mythtv/libs/libmythtv/test/test_mpegtables/test_mpegtables.h +++ b/mythtv/libs/libmythtv/test/test_mpegtables/test_mpegtables.h @@ -147,4 +147,49 @@ class TestMPEGTables: public QObject QCOMPARE (tdt.UTCUnix(), (time_t) 1373978017); QCOMPARE (tdt.UTC(), MythDate::fromString("2013-07-16 12:33:37 Z")); } + + void ContentIdentifierDescriptor_test(void) + { + const unsigned char eit_data[] = { + 0x4f, 0xf2, 0x17, 0x42, 0xd8, 0xdb, 0x00, 0x01, 0x00, 0xab, 0x27, 0x0f, 0x01, 0x4f, 0x30, 0x17, /* O..B......'..O0. */ + 0xdc, 0xc9, 0x07, 0x15, 0x00, 0x00, 0x25, 0x00, 0x81, 0xfc, 0x4d, 0xb2, 0x65, 0x6e, 0x67, 0x0d, /* ......%...M.eng. */ + 0x05, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x62, 0x72, 0x6f, 0x74, 0x68, 0x65, 0x72, 0xa0, 0x05, 0x44, /* .Moneybrother..D */ + 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x72, 0x79, 0x20, 0x73, 0x65, 0x72, 0x69, 0x65, /* ocumentary serie */ + 0x73, 0x20, 0x6f, 0x6e, 0x20, 0x53, 0x77, 0x65, 0x64, 0x65, 0x6e, 0x27, 0x73, 0x20, 0x41, 0x6e, /* s on Sweden's An */ + 0x64, 0x65, 0x72, 0x73, 0x20, 0x57, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x20, 0x61, 0x6e, 0x64, 0x20, /* ders Wendin and */ + 0x74, 0x68, 0x65, 0x20, 0x6d, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x20, 0x6f, 0x66, 0x20, 0x68, 0x69, /* the making of hi */ + 0x73, 0x20, 0x6e, 0x65, 0x77, 0x20, 0x61, 0x6c, 0x62, 0x75, 0x6d, 0x2e, 0x20, 0x54, 0x68, 0x69, /* s new album. Thi */ + 0x73, 0x20, 0x65, 0x70, 0x69, 0x73, 0x6f, 0x64, 0x65, 0x20, 0x73, 0x68, 0x6f, 0x77, 0x73, 0x20, /* s episode shows */ + 0x74, 0x68, 0x65, 0x20, 0x70, 0x72, 0x65, 0x70, 0x61, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, /* the preparation */ + 0x69, 0x6e, 0x20, 0x53, 0x74, 0x6f, 0x63, 0x6b, 0x68, 0x6f, 0x6c, 0x6d, 0x20, 0x61, 0x6e, 0x64, /* in Stockholm and */ + 0x20, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x20, 0x69, 0x6e, 0x20, 0x43, /* recordings in C */ + 0x68, 0x69, 0x63, 0x61, 0x67, 0x6f, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x4c, 0x41, 0x2e, 0x4d, 0xc7, /* hicago and LA.M. */ + 0x67, 0x65, 0x72, 0x0d, 0x05, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x62, 0x72, 0x6f, 0x74, 0x68, 0x65, /* ger..Moneybrothe */ + 0x72, 0xb5, 0x05, 0x44, 0x69, 0x65, 0x73, 0x65, 0x20, 0x46, 0x6f, 0x6c, 0x67, 0x65, 0x20, 0x64, /* r..Diese Folge d */ + 0x65, 0x73, 0x20, 0x4d, 0x75, 0x73, 0x69, 0x6b, 0x6d, 0x61, 0x67, 0x61, 0x7a, 0x69, 0x6e, 0x73, /* es Musikmagazins */ + 0x20, 0x6d, 0x69, 0x74, 0x20, 0x64, 0x65, 0x6d, 0x20, 0x73, 0x63, 0x68, 0x77, 0x65, 0x64, 0x69, /* mit dem schwedi */ + 0x73, 0x63, 0x68, 0x65, 0x6e, 0x20, 0x4d, 0x75, 0x73, 0x69, 0x6b, 0x65, 0x72, 0x20, 0x41, 0x6e, /* schen Musiker An */ + 0x64, 0x65, 0x72, 0x73, 0x20, 0x57, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x20, 0x61, 0x2e, 0x6b, 0x2e, /* ders Wendin a.k. */ + 0x61, 0x2e, 0x20, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x62, 0x72, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x20, /* a. Moneybrother */ + 0x7a, 0x65, 0x69, 0x67, 0x74, 0x20, 0x64, 0x69, 0x65, 0x20, 0x56, 0x6f, 0x72, 0x62, 0x65, 0x72, /* zeigt die Vorber */ + 0x65, 0x69, 0x74, 0x75, 0x6e, 0x67, 0x65, 0x6e, 0x20, 0x69, 0x6e, 0x20, 0x53, 0x74, 0x6f, 0x63, /* eitungen in Stoc */ + 0x6b, 0x68, 0x6f, 0x6c, 0x6d, 0x20, 0x75, 0x6e, 0x64, 0x20, 0x64, 0x69, 0x65, 0x20, 0x65, 0x72, /* kholm und die er */ + 0x73, 0x74, 0x65, 0x6e, 0x20, 0x41, 0x75, 0x66, 0x6e, 0x61, 0x68, 0x6d, 0x65, 0x6e, 0x20, 0x43, /* sten Aufnahmen C */ + 0x68, 0x69, 0x63, 0x61, 0x67, 0x6f, 0x20, 0x75, 0x6e, 0x64, 0x20, 0x4c, 0x6f, 0x73, 0x20, 0x41, /* hicago und Los A */ + 0x6e, 0x67, 0x65, 0x6c, 0x65, 0x73, 0x2e, 0x76, 0x73, 0x04, 0x40, 0x65, 0x76, 0x65, 0x6e, 0x74, /* ngeles.vs.@event */ + 0x69, 0x73, 0x2e, 0x6e, 0x6c, 0x2f, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x2d, 0x30, /* is.nl/00000000-0 */ + 0x30, 0x30, 0x30, 0x2d, 0x31, 0x30, 0x30, 0x30, 0x2d, 0x30, 0x36, 0x30, 0x34, 0x2d, 0x30, 0x30, /* 000-1000-0604-00 */ + 0x30, 0x30, 0x30, 0x30, 0x30, 0x45, 0x30, 0x37, 0x31, 0x31, 0x23, 0x30, 0x30, 0x31, 0x30, 0x33, /* 00000E0711#00103 */ + 0x38, 0x39, 0x39, 0x30, 0x30, 0x30, 0x30, 0x32, 0x30, 0x31, 0x37, 0x08, 0x2f, 0x65, 0x76, 0x65, /* 89900002017./eve */ + 0x6e, 0x74, 0x69, 0x73, 0x2e, 0x6e, 0x6c, 0x2f, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, /* ntis.nl/00000000 */ + 0x2d, 0x30, 0x30, 0x30, 0x30, 0x2d, 0x31, 0x30, 0x30, 0x30, 0x2d, 0x30, 0x36, 0x30, 0x38, 0x2d, /* -0000-1000-0608- */ + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, 0x46, 0x39, 0x43, 0x55, 0x04, 0x44, 0x45, /* 000000003F9CU.DE */ + 0x55, 0x00, 0x54, 0x02, 0x23, 0x00, 0x3b, 0xf9, 0x94, 0xa5 /* U.T.#.;... */ + }; + + /* pick just the ContentIdentifierDescriptor from the event_information_section */ + DVBContentIdentifierDescriptor descriptor(&eit_data[407]); + + QCOMPARE (descriptor.ContentId(), QString("eventis.nl/00000000-0000-1000-0604-0000000E0711")); + } };