Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
epg: try to handle the broken EPG input - add stop cut function, fixe…
…s #4076
  • Loading branch information
perexg committed Nov 19, 2016
1 parent 0d335d7 commit 3a113b6
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/config.c
Expand Up @@ -1638,6 +1638,7 @@ config_boot ( const char *path, gid_t gid, uid_t uid )
config.dscp = -1;
config.descrambler_buffer = 9000;
config.epg_compress = 1;
config.epg_cutwindow = 5*60;
config_scanfile_ok = 0;
config.theme_ui = strdup("blue");

Expand Down Expand Up @@ -2180,9 +2181,18 @@ const idclass_t config_class = {
.off = offsetof(config_t, epg_compress),
.opts = PO_EXPERT,
.def.i = 1,
.group = 1
.group = 2
},
#endif
{
.type = PT_U32,
.id = "epg_cutwindow",
.name = N_("EPG overlap cut"),
.desc = N_("The time window to cut the stop time from the overlapped event in seconds."),
.off = offsetof(config_t, epg_cutwindow),
.opts = PO_EXPERT,
.group = 2
},
{
.type = PT_STR,
.islist = 1,
Expand Down
1 change: 1 addition & 0 deletions src/config.h
Expand Up @@ -58,6 +58,7 @@ typedef struct config {
int caclient_ui;
int parser_backlog;
int epg_compress;
uint32_t epg_cutwindow;
} config_t;

extern const idclass_t config_class;
Expand Down
23 changes: 23 additions & 0 deletions src/epg.c
Expand Up @@ -26,6 +26,7 @@
#include <time.h>

#include "tvheadend.h"
#include "config.h"
#include "queue.h"
#include "channels.h"
#include "settings.h"
Expand Down Expand Up @@ -1695,6 +1696,17 @@ static epg_broadcast_t *_epg_channel_add_broadcast
_epg_channel_rem_broadcast(ch, ret, NULL);
return NULL;
}
if (config.epg_cutwindow && ebc->stop - ebc->start > config.epg_cutwindow * 2 &&
ebc->stop - ret->start <= config.epg_cutwindow) {
tvhtrace(LS_EPG, "cut stop for overlap (b) event %u (%s) on %s @ %s to %s",
ebc->id, epg_broadcast_get_title(ebc, NULL),
channel_get_name(ch),
gmtime2local(ebc->start, tm1, sizeof(tm1)),
gmtime2local(ebc->stop, tm2, sizeof(tm2)));
ebc->stop = ret->start;
_epg_object_set_updated(ebc);
continue;
}
tvhtrace(LS_EPG, "remove overlap (b) event %u (%s) on %s @ %s to %s",
ebc->id, epg_broadcast_get_title(ebc, NULL),
channel_get_name(ch),
Expand All @@ -1711,6 +1723,17 @@ static epg_broadcast_t *_epg_channel_add_broadcast
_epg_channel_rem_broadcast(ch, ret, NULL);
return NULL;
}
if (config.epg_cutwindow && ret->stop - ret->start > config.epg_cutwindow * 2 &&
ret->stop - ebc->start <= config.epg_cutwindow) {
tvhtrace(LS_EPG, "cut stop for overlap (a) event %u (%s) on %s @ %s to %s",
ebc->id, epg_broadcast_get_title(ebc, NULL),
channel_get_name(ch),
gmtime2local(ebc->start, tm1, sizeof(tm1)),
gmtime2local(ebc->stop, tm2, sizeof(tm2)));
ret->stop = ebc->start;
_epg_object_set_updated(ebc);
continue;
}
tvhtrace(LS_EPG, "remove overlap (a) event %u (%s) on %s @ %s to %s",
ebc->id, epg_broadcast_get_title(ebc, NULL),
channel_get_name(ch),
Expand Down

0 comments on commit 3a113b6

Please sign in to comment.