From patchwork Sat Jul 7 11:20:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Roth?= X-Patchwork-Id: 10512847 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 914A0603D7 for ; Sat, 7 Jul 2018 11:21:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69BA028864 for ; Sat, 7 Jul 2018 11:21:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 45AF528874; Sat, 7 Jul 2018 11:21:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9E2F2884A for ; Sat, 7 Jul 2018 11:21:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753587AbeGGLVK (ORCPT ); Sat, 7 Jul 2018 07:21:10 -0400 Received: from mail-ed1-f46.google.com ([209.85.208.46]:34033 "EHLO mail-ed1-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753358AbeGGLVJ (ORCPT ); Sat, 7 Jul 2018 07:21:09 -0400 Received: by mail-ed1-f46.google.com with SMTP id d3-v6so10474825edi.1 for ; Sat, 07 Jul 2018 04:21:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=usY81SR4x6W7JyUbVMNJuorjyAMdn89kYtEcxEqCEQs=; b=aebUkaehDlkd620MYcO8XAVSiolgyMxp/R4UF237a5sf+CUPxWnOt58jHlAddi7cHC egLLX4roEyFRS6kG0opUgnQx/eeUQ1K3/AnNKOwqcW27c5vaDlnNV5z7mtJ20Vji3zyS sxsWo0blhvIWh4syPwkp2617rE3m3u8wwzDj1qU1pj5AGO/BZtvkhoRoJsC832kfgWIH GNjKZxu322UXYk7bbnbBsxyp5AFq1PBCMuTSYcNriPUSWNx4bgly2dvS6xK5A6f1EEZv OT0Q1oya8a/LNgmXbv/Wy7OHMEaxrMxQyTqFFQ5xrXEYpv/DabFv6nYPxMSMiTxEgQJM C6CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=usY81SR4x6W7JyUbVMNJuorjyAMdn89kYtEcxEqCEQs=; b=G+e1J6q4UUQvCmArZgeGTxcOv34V6Lbd1zb9+EU7h8MMdPGZjsPn3KwS7Eo2oE4/tf xlwFmNrt7VeFlm91YfDz/IEjuQx1w8MTPA46TzSoVXUrT0UnfJO/BO9YR70n38Tcpte2 Z+D2aD8EyLzJGtG0RnWunmJOJxI+jEutjDd0iQLWM1jL7euYBQOo/+YxPOvTi7xBse58 5kr2bstqmoEKUfVkC8NGLeSXspudTB9tQMUW/ZylSFEKKimAnwl5k62Ww4VMnsKaRWQp 2N6I7hwIgd32P2TgUNHc+fBSGlKxDw0O9toGiILEZ82Ijlkm28lqQUbJnBDOSsufUM6V 4xlQ== X-Gm-Message-State: APt69E1F/NJUhD1rygjT6bwqL/eSUKhW7qtX4mqyQCnIiJndAitTSO91 CdMMzTovsi96Ad52s5H+2KfBfw== X-Google-Smtp-Source: AAOMgpfPn/Wai+dnG882IgjqHFvfkEAb3pS/1ldlPxjr8Efc7HsdEKRiHGhnnkBte3zhSq63PfnqxA== X-Received: by 2002:a50:b86f:: with SMTP id k44-v6mr13999253ede.310.1530962467731; Sat, 07 Jul 2018 04:21:07 -0700 (PDT) Received: from localhost.localdomain (247.88.107.92.dynamic.wline.res.cust.swisscom.ch. [92.107.88.247]) by smtp.gmail.com with ESMTPSA id q2-v6sm2239641edl.42.2018.07.07.04.21.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 07 Jul 2018 04:21:07 -0700 (PDT) From: =?UTF-8?q?Andr=C3=A9=20Roth?= To: linux-media@vger.kernel.org Cc: =?UTF-8?q?Andr=C3=A9=20Roth?= Subject: [PATCH 1/4] libdvbv5: do not adjust DVB time daylight saving Date: Sat, 7 Jul 2018 13:20:54 +0200 Message-Id: <20180707112057.7235-1-neolynx@gmail.com> X-Mailer: git-send-email 2.14.1 MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 #include #include +#include /** * @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); - #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 #include +#ifdef ENABLE_NLS +# include "gettext.h" +# include +# 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 */ + 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",