From: DeltaMikeCharlie <127641886+DeltaMikeCharlie@users.noreply.github.com> Date: Wed, 9 Aug 2023 06:19:47 +0000 (+1000) Subject: Fix bug #6293 – Missing EIT EPG Content Type X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=76ca76761693eb7c1f347e79d271618f08ec3824;p=thirdparty%2Ftvheadend.git Fix bug #6293 – Missing EIT EPG Content Type --- diff --git a/src/epggrab.h b/src/epggrab.h index 90346fdca..5b33696e7 100644 --- a/src/epggrab.h +++ b/src/epggrab.h @@ -212,7 +212,7 @@ struct epggrab_module_int struct epggrab_module_ext { epggrab_module_int_t ; ///< Parent object - + int sock; ///< Socket descriptor pthread_t tid; ///< Thread ID @@ -239,7 +239,7 @@ struct epggrab_ota_mux { tvh_uuid_t om_mux_uuid; ///< Soft-link to mux LIST_HEAD(,epggrab_ota_map) om_modules; ///< List of linked mods - + uint8_t om_done; ///< The full completion mark for this round uint8_t om_complete; ///< Has completed a scan uint8_t om_requeue; ///< Requeue when stolen @@ -403,7 +403,7 @@ const char *epggrab_ota_check_module_id( const char *id ); /* * Global variable for genre translation */ -extern unsigned char epggrab_ota_genre_translation[256]; +extern unsigned char *epggrab_ota_genre_translation; #endif /* __EPGGRAB_H__ */ diff --git a/src/epggrab/module/eit.c b/src/epggrab/module/eit.c index 4ae2b126f..63df1b154 100644 --- a/src/epggrab/module/eit.c +++ b/src/epggrab/module/eit.c @@ -113,7 +113,7 @@ typedef struct eit_event { char uri[529]; char suri[529]; - + lang_str_t *title; lang_str_t *subtitle; lang_str_t *summary; @@ -155,7 +155,7 @@ static void _eit_done(void *mod); // Dump a descriptor tag for debug (looking for new tags etc...) static void -_eit_dtag_dump +_eit_dtag_dump ( epggrab_module_t *mod, uint8_t dtag, uint8_t dlen, const uint8_t *buf ) { #if APS_DEBUG @@ -187,7 +187,7 @@ static dvb_string_conv_t _eit_freesat_conv[2] = { */ static int _eit_get_string_with_len ( epggrab_module_t *mod, - char *dst, size_t dstlen, + char *dst, size_t dstlen, const uint8_t *src, size_t srclen, const char *charset ) { epggrab_module_ota_t *m = (epggrab_module_ota_t *)mod; @@ -284,7 +284,7 @@ static int _eit_desc_ext_event if ( (r = _eit_get_string_with_len(mod, ikey, sizeof(ikey), iptr, ilen, ev->default_charset)) < 0 ) break; - + ilen -= r; iptr += r; @@ -394,13 +394,17 @@ static int _eit_desc_content uint8_t tempPtr = 0; //Temporary variable to hold a (potentially) changed *ptr value. tempPtr = *ptr; while (len > 1) { - //Get the potentially new genre value. - tempPtr = epggrab_ota_genre_translation[*ptr]; - //If we did get a translation, write a trace for debugging. - if(tempPtr != *ptr) - { - tvhtrace(LS_TBL_EIT, "Translating '%d' to '%d'", *ptr, tempPtr); - } + //If the genre translation table has been loaded, it will not be a null pointer. + if (epggrab_ota_genre_translation){ + //Get the potentially new genre value. + tempPtr = epggrab_ota_genre_translation[*ptr]; + //If we did get a translation, write a trace for debugging. + if(tempPtr != *ptr) + { + tvhtrace(LS_TBL_EIT, "Translating '%d' (0x%02x) to '%d' (0x%02x)", *ptr, *ptr, tempPtr, tempPtr); + } + }//END genre translation table loaded. + if (tempPtr == 0xb1) //0xB1 is the genre code for 'Black and White' ev->bw = 1; else if (tempPtr < 0xb0) { //0xB0 is the start of the 'Special Characteristics' block. @@ -470,7 +474,7 @@ static int _eit_desc_crid crid = ev->suri; clen = sizeof(ev->suri); } - + if (crid) { if (strstr(buf, "crid://") == buf) { strlcpy(crid, buf, clen); @@ -1004,8 +1008,8 @@ _eit_callback mask <<= (24 - (sa % 32)); st->sections[sa/32] &= ~mask; } - - /* UK Cable Virgin: EPG data for services in other transponders is transmitted + + /* UK Cable Virgin: EPG data for services in other transponders is transmitted // in the 'actual' transpoder table IDs */ if ((hacks & EIT_HACK_EXTRAMUXLOOKUP) != 0 && (tableid == 0x50 || tableid == 0x4E)) { mm = mpegts_network_find_mux(mm->mm_network, onid, tsid, 1); @@ -1106,7 +1110,7 @@ done: complete: if (ota && !r && (tableid >= 0x50 && tableid < 0x60)) epggrab_ota_complete((epggrab_module_ota_t*)mod, ota); - + return r; } @@ -1249,7 +1253,7 @@ static int _eit_tune return 1; /* Check if any services are mapped */ - // TODO: using indirect ref's like this is inefficient, should + // TODO: using indirect ref's like this is inefficient, should // consider changeing it? for (osl = RB_FIRST(&map->om_svcs); osl != NULL; osl = nxt) { nxt = RB_NEXT(osl, link); diff --git a/src/epggrab/otamux.c b/src/epggrab/otamux.c index 953009479..aa7d94c81 100644 --- a/src/epggrab/otamux.c +++ b/src/epggrab/otamux.c @@ -56,7 +56,8 @@ int epggrab_ota_pending_flag; tvh_mutex_t epggrab_ota_mutex; -unsigned char epggrab_ota_genre_translation[256]; +//If the pointer is not null, translation values have also been loaded. +unsigned char *epggrab_ota_genre_translation = NULL; SKEL_DECLARE(epggrab_ota_mux_skel, epggrab_ota_mux_t); SKEL_DECLARE(epggrab_svc_link_skel, epggrab_ota_svc_link_t); @@ -423,7 +424,7 @@ epggrab_ota_register save = 1; } } - + /* Find module map */ map = epggrab_ota_find_map(ota, mod); if (!map) { @@ -869,7 +870,7 @@ epggrab_ota_load_one epggrab_ota_mux_t *ota; epggrab_ota_map_t *map; const char *id; - + mm = mpegts_mux_find(uuid); if (!mm) { hts_settings_remove("epggrab/otamux/%s", uuid); @@ -885,14 +886,14 @@ epggrab_ota_load_one return; } ota->om_complete = htsmsg_get_u32_or_default(c, "complete", 0) != 0; - + if (!(l = htsmsg_get_list(c, "modules"))) return; HTSMSG_FOREACH(f, l) { if (!(e = htsmsg_field_get_map(f))) continue; if (!(id = htsmsg_get_str(e, "id"))) continue; if (!(mod = (epggrab_module_ota_t*)epggrab_module_find_by_id(id))) continue; - + map = calloc(1, sizeof(epggrab_ota_map_t)); RB_INIT(&map->om_svcs); map->om_module = mod; @@ -941,12 +942,12 @@ epggrab_ota_init ( void ) hts_settings_remove("epggrab/otamux"); atomic_set(&epggrab_ota_running, 1); - + /* Load config */ if ((c = hts_settings_load_r(1, "epggrab/otamux"))) { HTSMSG_FOREACH(f, c) { if (!(m = htsmsg_field_get_map(f))) continue; - epggrab_ota_load_one(htsmsg_field_name(f), m); + epggrab_ota_load_one(htsmsg_field_name(f), m); } htsmsg_destroy(c); } @@ -1052,8 +1053,24 @@ epggrab_ota_set_genre_translation ( void ) lock_assert(&global_lock); tvh_mutex_lock(&epggrab_ota_mutex); + //Allocate storage for the translation table. + //The pointer is initialised as NULL. If this function is not triggered + //(no setting in the file), the pointer will not be set and the EIT code + //where the actual translation ccurs can check for a null pointer before + //trying to translate. + epggrab_ota_genre_translation = calloc(sizeof(unsigned char) * 256, 1); + + //Test to see if the translation table got space allocated, if not, + //complain and then exit the function. + if (!epggrab_ota_genre_translation){ + tvherror(LS_EPGGRAB, "Unable to allocate memory, genre translations disabled."); + tvh_mutex_unlock(&epggrab_ota_mutex); + return; + } + //Reset the translation table to 1:1 here before proceeding. - for(int i = 0; i < 256; i++) + int i = 0; //Bugfix, some platforms don't like the variable declaration within the FOR. + for(i = 0; i < 256; i++) { epggrab_ota_genre_translation[i] = i; } @@ -1098,7 +1115,7 @@ epggrab_ota_set_genre_translation ( void ) //Test that the to/from values are sane before proceeding. if(tempFrom > -1 && tempFrom < 256 && tempTo > -1 && tempTo < 256) { - tvhtrace(LS_EPGGRAB, "Valid translation from '%d' to '%d'.", tempFrom, tempTo); + tvhtrace(LS_EPGGRAB, "Valid translation from '%d' (0x%02x) to '%d' (0x%02x).", tempFrom, tempFrom, tempTo, tempTo); epggrab_ota_genre_translation[tempFrom] = tempTo; } else @@ -1111,7 +1128,8 @@ epggrab_ota_set_genre_translation ( void ) } } - for(int x = 0; x < 256; x++) + int x = 0; + for(x = 0; x < 256; x++) { if(epggrab_ota_genre_translation[x] != x) {