struct epggrab_module_ext
{
epggrab_module_int_t ; ///< Parent object
-
+
int sock; ///< Socket descriptor
pthread_t tid; ///< Thread ID
{
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
/*
* Global variable for genre translation
*/
-extern unsigned char epggrab_ota_genre_translation[256];
+extern unsigned char *epggrab_ota_genre_translation;
#endif /* __EPGGRAB_H__ */
{
char uri[529];
char suri[529];
-
+
lang_str_t *title;
lang_str_t *subtitle;
lang_str_t *summary;
// 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
*/
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;
if ( (r = _eit_get_string_with_len(mod, ikey, sizeof(ikey),
iptr, ilen, ev->default_charset)) < 0 )
break;
-
+
ilen -= r;
iptr += r;
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.
crid = ev->suri;
clen = sizeof(ev->suri);
}
-
+
if (crid) {
if (strstr(buf, "crid://") == buf) {
strlcpy(crid, buf, clen);
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);
complete:
if (ota && !r && (tableid >= 0x50 && tableid < 0x60))
epggrab_ota_complete((epggrab_module_ota_t*)mod, ota);
-
+
return r;
}
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);
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);
save = 1;
}
}
-
+
/* Find module map */
map = epggrab_ota_find_map(ota, mod);
if (!map) {
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);
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;
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);
}
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;
}
//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
}
}
- for(int x = 0; x < 256; x++)
+ int x = 0;
+ for(x = 0; x < 256; x++)
{
if(epggrab_ota_genre_translation[x] != x)
{