Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
mpegts network: implement EIT time offset (extend localtime flag), fi…
…xes #3566
  • Loading branch information
perexg committed Feb 12, 2016
1 parent 49b7763 commit d419c20
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/input/mpegts/dvb.h
Expand Up @@ -212,7 +212,9 @@ struct lang_str *atsc_get_string

#define bcdtoint(i) ((((i & 0xf0) >> 4) * 10) + (i & 0x0f))

time_t dvb_convert_date(const uint8_t *dvb_buf, int local);
htsmsg_t *dvb_timezone_enum(void *p, const char *lang);

time_t dvb_convert_date(const uint8_t *dvb_buf, int tmzone);
time_t atsc_convert_gpstime(uint32_t gpstime);
void atsc_utf16_to_utf8(const uint8_t *src, int len, char *buf, int buflen);

Expand Down
59 changes: 57 additions & 2 deletions src/input/mpegts/dvb_support.c
Expand Up @@ -454,12 +454,60 @@ atsc_get_string
return ls;
}

/*
*
*/

static struct strtab dvb_timezone_strtab[] = {
{ N_("UTC"), 0 },
{ N_("Local (server) time"), 1 },
{ N_("UTC- 1"), -1*60 },
{ N_("UTC- 2"), -2*60 },
{ N_("UTC- 2:30"), -2*60-30 },
{ N_("UTC- 3"), -3*60 },
{ N_("UTC- 3:30"), -3*60-30 },
{ N_("UTC- 4"), -4*60 },
{ N_("UTC- 4:30"), -4*60-30 },
{ N_("UTC- 5"), -5*60 },
{ N_("UTC- 6"), -6*60 },
{ N_("UTC- 7"), -7*60 },
{ N_("UTC- 8"), -8*60 },
{ N_("UTC- 9"), -9*60 },
{ N_("UTC- 9:30"), -9*60-30 },
{ N_("UTC-10"), -10*60 },
{ N_("UTC-11"), -11*60 },
{ N_("UTC+ 1"), 1*60 },
{ N_("UTC+ 2"), 2*60 },
{ N_("UTC+ 3"), 3*60 },
{ N_("UTC+ 4"), 4*60 },
{ N_("UTC+ 4:30"), 4*60+30 },
{ N_("UTC+ 5"), 5*60 },
{ N_("UTC+ 5:30"), 5*60+30 },
{ N_("UTC+ 5:45"), 5*60+45 },
{ N_("UTC+ 6"), 6*60 },
{ N_("UTC+ 6:30"), 6*60+30 },
{ N_("UTC+ 7"), 7*60 },
{ N_("UTC+ 8"), 8*60 },
{ N_("UTC+ 8:45"), 8*60+45 },
{ N_("UTC+ 9"), 9*60 },
{ N_("UTC+ 9:30"), 9*60+30 },
{ N_("UTC+10"), 10*60 },
{ N_("UTC+10:30"), 10*60+30 },
{ N_("UTC+11"), 11*60 },
};

htsmsg_t *
dvb_timezone_enum ( void *p, const char *lang )
{
return strtab2htsmsg(dvb_timezone_strtab, 1, lang);
}

/*
* DVB time and date functions
*/

time_t
dvb_convert_date(const uint8_t *dvb_buf, int local)
dvb_convert_date(const uint8_t *dvb_buf, int tmzone)
{
int i;
int year, month, day, hour, min, sec;
Expand Down Expand Up @@ -495,7 +543,14 @@ dvb_convert_date(const uint8_t *dvb_buf, int local)
dvb_time.tm_isdst = -1;
dvb_time.tm_wday = 0;
dvb_time.tm_yday = 0;
return local ? mktime(&dvb_time) : timegm(&dvb_time);

if (tmzone == 0) /* UTC */
return timegm(&dvb_time);
if (tmzone == 1) /* Local time */
return mktime(&dvb_time);

/* apply offset */
return timegm(&dvb_time) + tmzone;
}

static time_t _gps_leap_seconds[17] = {
Expand Down
8 changes: 4 additions & 4 deletions src/input/mpegts/mpegts_network.c
Expand Up @@ -241,12 +241,12 @@ const idclass_t mpegts_network_class =
.opts = PO_ADVANCED,
},
{
.type = PT_BOOL,
.type = PT_INT,
.id = "localtime",
.name = N_("EIT broadcast in local time"),
.desc = N_("If EIT events use local time rather than UTC enable "
"this option."),
.name = N_("EIT time offset"),
.desc = N_("Select the time offset for EIT events."),
.off = offsetof(mpegts_network_t, mn_localtime),
.list = dvb_timezone_enum,
.opts = PO_EXPERT,
},
{
Expand Down

0 comments on commit d419c20

Please sign in to comment.