Skip to content

Commit

Permalink
draft patch to add support for private data specifiers and upc privat…
Browse files Browse the repository at this point in the history
…e data

Fixes #12091
(cherry picked from commit 30df98c)

Conflicts:

	mythtv/libs/libmythtv/test/test_mpegtables/test_mpegtables.h
  • Loading branch information
dekarl committed Dec 5, 2014
1 parent c32f254 commit 86ff53a
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 0 deletions.
23 changes: 23 additions & 0 deletions mythtv/libs/libmythtv/eithelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,29 @@ void EITHelper::AddEIT(const DVBEventInformationTable *eit)
}
}

/* if we don't have a subtitle, try to parse one from private descriptors */
if (subtitle.isEmpty()) {
bool isUPC = false;
/* is this event carrying UPC private data? */
desc_list_t private_data_specifiers = MPEGDescriptor::FindAll(list, DescriptorID::private_data_specifier);
for (uint j = 0; j < private_data_specifiers.size(); j++) {
PrivateDataSpecifierDescriptor desc(private_data_specifiers[j]);
if (desc.PrivateDataSpecifier() == PrivateDataSpecifierID::UPC1) {
isUPC = true;
}
}

if (isUPC) {
desc_list_t subtitles = MPEGDescriptor::FindAll(list, PrivateDescriptorID::upc_event_episode_title);
for (uint j = 0; j < subtitles.size(); j++) {
PrivateUPCCablecomEpisodeTitleDescriptor desc(subtitles[j]);

subtitle = desc.Text();
}
}
}


QDateTime starttime = eit->StartTimeUTC(i);
// fix starttime only if the duration is a multiple of a minute
if (!(eit->DurationInSeconds(i) % 60))
Expand Down
45 changes: 45 additions & 0 deletions mythtv/libs/libmythtv/mpeg/dvbdescriptors.h
Original file line number Diff line number Diff line change
Expand Up @@ -1358,6 +1358,10 @@ class PrivateDataSpecifierDescriptor : public MPEGDescriptor
// descriptor_length 8 1.0

// private_data_specifier 32 2.0
uint32_t PrivateDataSpecifier (void) const
{
return (_data[2] << 24 | _data[3] << 16 | _data[4] << 8 | _data[5]);
}
};

// DVB Bluebook A038 (Sept 2011) p 79
Expand Down Expand Up @@ -2071,4 +2075,45 @@ class DefaultAuthorityDescriptor : public MPEGDescriptor
}
};

/*
* private UPC Cablecom (Austria) episode descriptor for Horizon middleware
*/
class PrivateUPCCablecomEpisodeTitleDescriptor : public MPEGDescriptor
{
public:
PrivateUPCCablecomEpisodeTitleDescriptor(const unsigned char *data, int len = 300) :
MPEGDescriptor(data, len, PrivateDescriptorID::upc_event_episode_title) { }
// Name bits loc expected value
// descriptor_tag 8 0.0 0xa7
// descriptor_length 8 1.0

// ISO_639_language_code 24 2.0
int LanguageKey(void) const
{
return iso639_str3_to_key(&_data[2]);
}
QString LanguageString(void) const
{
return iso639_key_to_str3(LanguageKey());
}
int CanonicalLanguageKey(void) const
{
return iso639_key_to_canonical_key(LanguageKey());
}
QString CanonicalLanguageString(void) const
{
return iso639_key_to_str3(CanonicalLanguageKey());
}

uint TextLength(void) const
{
return _data[1] - 3;
}

QString Text(void) const
{
return dvb_decode_text(&_data[5], TextLength());
}
};

#endif
16 changes: 16 additions & 0 deletions mythtv/libs/libmythtv/mpeg/mpegdescriptors.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,29 @@ class PrivateDescriptorID
dish_event_vchip = 0x95, /* implemented */
dish_event_tags = 0x96, /* implemented */

// Private -- CH UPC Cablecom
upc_event_episode_title = 0xA7,

// Private -- premiere.de
premiere_content_order = 0xF0,
premiere_parental_information = 0xF1,
premiere_content_transmission = 0xF2,
};
};

/*
* Private_Data_Specifier_ID from http://www.dvbservices.com/identifiers/private_data_spec_id
*/
class PrivateDataSpecifierID
{
public:
enum
{
/* UPC Cablecom */
UPC1 = 0x00000600,
};
};

class MTV_PUBLIC MPEGDescriptor
{
public:
Expand Down
52 changes: 52 additions & 0 deletions mythtv/libs/libmythtv/test/test_mpegtables/test_mpegtables.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,56 @@ class TestMPEGTables: public QObject
QCOMPARE (descriptor2.ContentId(), QString("eventis.nl/00000000-0000-1000-0608-000000003F9C"));
QCOMPARE (descriptor.ContentId(1), QString("eventis.nl/00000000-0000-1000-0608-000000003F9C"));
}

/* test for coverity 1047220: Incorrect deallocator used:
* Calling "PSIPTable::~PSIPTable()" frees "(&psip)->_fullbuffer"
* using "free" but it should have been freed using "operator delete[]".
*
* _allocSize should be 0 thus we are not freeing something we didn't
* allocate in the first place (false positive)
*/
void clone_test(void)
{
unsigned char *si_data = new unsigned char[8];
si_data[0] = 0x70; /* pp....37 */
si_data[1] = 0x70;
si_data[2] = 0x05;
si_data[3] = 0xdc;
si_data[4] = 0xa9;
si_data[5] = 0x12;
si_data[6] = 0x33;
si_data[7] = 0x37;

const PSIPTable si_table(si_data);

QVERIFY (!si_table.IsClone());
}

/* test PrivateDataSpecifierDescriptor */
void PrivateDataSpecifierDescriptor_test (void)
{
/* from https://code.mythtv.org/trac/ticket/12091 */
const unsigned char si_data[] = {
0x5f, 0x04, 0x00, 0x00, 0x06, 0x00
};
PrivateDataSpecifierDescriptor desc(si_data);
QCOMPARE (desc.PrivateDataSpecifier(), (uint32_t) PrivateDataSpecifierID::UPC1);
}

/* test for https://code.mythtv.org/trac/ticket/12091
* UPC Cablecom switched from standard DVB key/value set to
* custom descriptors
*/
void PrivateUPCCablecomEpisodetitleDescriptor_test (void)
{
const unsigned char si_data[] = {
0xa7, 0x13, 0x67, 0x65, 0x72, 0x05, 0x4b, 0x72, 0x61, 0x6e, 0x6b, 0x20, 0x76, 0x6f, 0x72, 0x20, /* ..ger.Krank vor */
0x4c, 0x69, 0x65, 0x62, 0x65 /* Liebe */
};

PrivateUPCCablecomEpisodeTitleDescriptor descriptor(si_data);
QCOMPARE (descriptor.CanonicalLanguageString(), QString("ger"));
QCOMPARE (descriptor.TextLength(), (uint) 16);
QCOMPARE (descriptor.Text(), QString("Krank vor Liebe"));
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ TARGET = test_mpegtables
DEPENDPATH += . ../..
INCLUDEPATH += . ../.. ../../mpeg ../../../libmythui ../../../libmyth ../../../libmythbase

LIBS += ../../dvbdescriptors.o
LIBS += ../../iso6937tables.o
LIBS += ../../freesat_huffman.o

LIBS += -L../../../libmythbase -lmythbase-$$LIBVERSION
LIBS += -L../../../libmythui -lmythui-$$LIBVERSION
LIBS += -L../../../libmythupnp -lmythupnp-$$LIBVERSION
Expand Down

0 comments on commit 86ff53a

Please sign in to comment.