From: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
To: "André Roth" <neolynx@gmail.com>
Cc: linux-media@vger.kernel.org
Subject: Re: [PATCH 1/4] libdvbv5: do not adjust DVB time daylight saving
Date: Wed, 5 Dec 2018 06:40:44 -0200 [thread overview]
Message-ID: <20181205064044.37e44059@coco.lan> (raw)
In-Reply-To: <20180707112057.7235-1-neolynx@gmail.com>
Em Sat, 7 Jul 2018 13:20:54 +0200
André Roth <neolynx@gmail.com> escreveu:
> This makes dvb_time available outside of EIT parsing, and
> struct tm to reflect the actual values received from DVB.
>
> Signed-off-by: André Roth <neolynx@gmail.com>
> ---
> lib/include/libdvbv5/descriptors.h | 11 +++++++++++
> lib/include/libdvbv5/eit.h | 10 ----------
> lib/libdvbv5/descriptors.c | 37 +++++++++++++++++++++++++++++++++++++
> lib/libdvbv5/tables/eit.c | 28 ----------------------------
> 4 files changed, 48 insertions(+), 38 deletions(-)
>
> diff --git a/lib/include/libdvbv5/descriptors.h b/lib/include/libdvbv5/descriptors.h
> index cb21470c..31f4c73f 100644
> --- a/lib/include/libdvbv5/descriptors.h
> +++ b/lib/include/libdvbv5/descriptors.h
> @@ -47,6 +47,7 @@
> #include <unistd.h>
> #include <stdint.h>
> #include <arpa/inet.h>
> +#include <time.h>
>
> /**
> * @brief Maximum size of a table session to be parsed
> @@ -159,6 +160,16 @@ uint32_t dvb_bcd(uint32_t bcd);
> void dvb_hexdump(struct dvb_v5_fe_parms *parms, const char *prefix,
> const unsigned char *buf, int len);
>
> +/**
> + * @brief Converts a DVB formatted timestamp into struct tm
> + * @ingroup dvb_table
> + *
> + * @param data event on DVB time format
> + * @param tm pointer to struct tm where the converted timestamp will
> + * be stored.
> + */
> +void dvb_time(const uint8_t data[5], struct tm *tm);
> +
> /**
> * @brief parse MPEG-TS descriptors
> * @ingroup dvb_table
> diff --git a/lib/include/libdvbv5/eit.h b/lib/include/libdvbv5/eit.h
> index 9129861e..5af266b1 100644
> --- a/lib/include/libdvbv5/eit.h
> +++ b/lib/include/libdvbv5/eit.h
> @@ -209,16 +209,6 @@ void dvb_table_eit_free(struct dvb_table_eit *table);
> void dvb_table_eit_print(struct dvb_v5_fe_parms *parms,
> struct dvb_table_eit *table);
>
> -/**
> - * @brief Converts a DVB EIT formatted timestamp into struct tm
> - * @ingroup dvb_table
> - *
> - * @param data event on DVB EIT time format
> - * @param tm pointer to struct tm where the converted timestamp will
> - * be stored.
> - */
> -void dvb_time(const uint8_t data[5], struct tm *tm);
> -
This seems to break the existing ABI.
> #ifdef __cplusplus
> }
> #endif
> diff --git a/lib/libdvbv5/descriptors.c b/lib/libdvbv5/descriptors.c
> index 0683dc1b..ccec503c 100644
> --- a/lib/libdvbv5/descriptors.c
> +++ b/lib/libdvbv5/descriptors.c
> @@ -56,6 +56,14 @@
> #include <libdvbv5/desc_ca_identifier.h>
> #include <libdvbv5/desc_extension.h>
>
> +#ifdef ENABLE_NLS
> +# include "gettext.h"
> +# include <libintl.h>
> +# define _(string) dgettext(LIBDVBV5_DOMAIN, string)
> +#else
> +# define _(string) string
> +#endif
> +
> static void dvb_desc_init(uint8_t type, uint8_t length, struct dvb_desc *desc)
> {
> desc->type = type;
> @@ -1391,3 +1399,32 @@ void dvb_hexdump(struct dvb_v5_fe_parms *parms, const char *prefix, const unsign
> dvb_loginfo("%s%s %s %s", prefix, hex, spaces, ascii);
> }
> }
> +
> +void dvb_time(const uint8_t data[5], struct tm *tm)
> +{
> + /* ETSI EN 300 468 V1.4.1 */
> + int year, month, day, hour, min, sec;
> + int k = 0;
> + uint16_t mjd;
> +
> + mjd = *(uint16_t *) data;
> + hour = dvb_bcd(data[2]);
> + min = dvb_bcd(data[3]);
> + sec = dvb_bcd(data[4]);
> + year = ((mjd - 15078.2) / 365.25);
> + month = ((mjd - 14956.1 - (int) (year * 365.25)) / 30.6001);
> + day = mjd - 14956 - (int) (year * 365.25) - (int) (month * 30.6001);
> + if (month == 14 || month == 15) k = 1;
> + year += k;
> + month = month - 1 - k * 12;
> +
> + tm->tm_sec = sec;
> + tm->tm_min = min;
> + tm->tm_hour = hour;
> + tm->tm_mday = day;
> + tm->tm_mon = month - 1;
> + tm->tm_year = year;
> + tm->tm_isdst = -1; /* do not adjust */
It seems that the only real change here is that you replaced 1 by -1 here,
in order for the mktime() to not handle daylight saving time.
Why are you also moving this out of eit.c/eit.h?
> + mktime( tm );
> +}
> +
> diff --git a/lib/libdvbv5/tables/eit.c b/lib/libdvbv5/tables/eit.c
> index a6ba566a..799e4c9a 100644
> --- a/lib/libdvbv5/tables/eit.c
> +++ b/lib/libdvbv5/tables/eit.c
> @@ -154,34 +154,6 @@ void dvb_table_eit_print(struct dvb_v5_fe_parms *parms, struct dvb_table_eit *ei
> dvb_loginfo("|_ %d events", events);
> }
>
> -void dvb_time(const uint8_t data[5], struct tm *tm)
> -{
> - /* ETSI EN 300 468 V1.4.1 */
> - int year, month, day, hour, min, sec;
> - int k = 0;
> - uint16_t mjd;
> -
> - mjd = *(uint16_t *) data;
> - hour = dvb_bcd(data[2]);
> - min = dvb_bcd(data[3]);
> - sec = dvb_bcd(data[4]);
> - year = ((mjd - 15078.2) / 365.25);
> - month = ((mjd - 14956.1 - (int) (year * 365.25)) / 30.6001);
> - day = mjd - 14956 - (int) (year * 365.25) - (int) (month * 30.6001);
> - if (month == 14 || month == 15) k = 1;
> - year += k;
> - month = month - 1 - k * 12;
> -
> - tm->tm_sec = sec;
> - tm->tm_min = min;
> - tm->tm_hour = hour;
> - tm->tm_mday = day;
> - tm->tm_mon = month - 1;
> - tm->tm_year = year;
> - tm->tm_isdst = 1; /* dst in effect, do not adjust */
> - mktime( tm );
> -}
> -
>
> const char *dvb_eit_running_status_name[8] = {
> [0] = "Undefined",
Thanks,
Mauro
prev parent reply other threads:[~2018-12-05 8:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-07 11:20 [PATCH 1/4] libdvbv5: do not adjust DVB time daylight saving André Roth
2018-07-07 11:20 ` [PATCH 2/4] libdvbv5: fix double free in dvb_fe_open_fname André Roth
2018-07-07 11:20 ` [PATCH 3/4] libdvbv5: fix parsing EIT extended event descriptor André Roth
2018-07-07 11:20 ` [PATCH 4/4] libdvbv5: fix parsing section gaps André Roth
2018-12-05 8:40 ` Mauro Carvalho Chehab [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181205064044.37e44059@coco.lan \
--to=mchehab+samsung@kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=neolynx@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.