OpenTvTitle::OpenTvTitle(const uint8_t * const buffer, uint16_t startMjd)
{
uint8_t descriptor_tag = buffer[0];
if (descriptor_tag == OPENTV_EVENT_TITLE_DESCRIPTOR)
{
uint8_t descriptor_length = buffer[1];
uint8_t titleLength = descriptor_length > 7 ? descriptor_length-7 : 0;
uint32_t startSecond = (UINT16(&buffer[2]) << 1); //BB
startTimeBcd = ((startMjd - 40587) * 86400) + startSecond; //BB
duration = UINT16(&buffer[4]) << 1;
//genre content
//uint8_t flag1 = buffer[6];
//uint8_t flag2 = buffer[7];
//uint8_t flag3 = buffer[8];
char tmp[OPENTV_EVENT_TITLE_LENGTH];
memset(tmp, '\0', OPENTV_EVENT_TITLE_LENGTH);
if (!huffman_decode (buffer + 9, titleLength, tmp, OPENTV_EVENT_TITLE_LENGTH * 2, false))
tmp[0] = '\0';
title = convertDVBUTF8(tmp, sizeof(tmp), 5);
eDebug("[OpenTV] +titl:\"%s\" SMJD:%i Ss:%i SBD:%i len:%i", tmp, startMjd, startSecond, startTimeBcd, duration); //BB
/* storing all the crc unique titles in the title reader phase,
would give us a titles reduction of 155,000 down to 13,000!
we currently add/delete as we go with reduction size ~5000 */
uint8_t *otvt = new uint8_t[titleLength];
memcpy(otvt, buffer + 9, titleLength);
crc32 = opentv_crc(otvt, titleLength);
delete [] otvt;
}
}