linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] libdvbv5: do not adjust DVB time daylight saving
@ 2018-07-07 11:20 André Roth
  2018-07-07 11:20 ` [PATCH 2/4] libdvbv5: fix double free in dvb_fe_open_fname André Roth
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: André Roth @ 2018-07-07 11:20 UTC (permalink / raw)
  To: linux-media; +Cc: André Roth

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);
-
 #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 */
+  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",
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/4] libdvbv5: fix double free in dvb_fe_open_fname
  2018-07-07 11:20 [PATCH 1/4] libdvbv5: do not adjust DVB time daylight saving André Roth
@ 2018-07-07 11:20 ` André Roth
  2018-07-07 11:20 ` [PATCH 3/4] libdvbv5: fix parsing EIT extended event descriptor André Roth
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: André Roth @ 2018-07-07 11:20 UTC (permalink / raw)
  To: linux-media; +Cc: André Roth

Since parms and fname is allocated outside of the function, do not free it.
Use dvb_v5_free for freeing parms, it will free fname if required.

Signed-off-by: André Roth <neolynx@gmail.com>
---
 lib/libdvbv5/dvb-fe.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/lib/libdvbv5/dvb-fe.c b/lib/libdvbv5/dvb-fe.c
index 7dcfa53e..5dcf492e 100644
--- a/lib/libdvbv5/dvb-fe.c
+++ b/lib/libdvbv5/dvb-fe.c
@@ -185,7 +185,7 @@ struct dvb_v5_fe_parms *dvb_fe_open_flags(int adapter, int frontend,
 
 	ret = dvb_fe_open_fname(parms, fname, flags);
 	if (ret < 0) {
-		free(parms);
+		dvb_v5_free(parms);
 		return NULL;
 	}
 
@@ -209,9 +209,7 @@ int dvb_fe_open_fname(struct dvb_v5_fe_parms_priv *parms, char *fname,
 
 	if (xioctl(fd, FE_GET_INFO, &parms->p.info) == -1) {
 		dvb_perror("FE_GET_INFO");
-		dvb_v5_free(parms);
 		close(fd);
-		free(fname);
 		return -errno;
 	}
 
@@ -293,7 +291,6 @@ int dvb_fe_open_fname(struct dvb_v5_fe_parms_priv *parms, char *fname,
 		}
 		if (!parms->p.num_systems) {
 			dvb_logerr(_("delivery system not detected"));
-			dvb_v5_free(parms);
 			close(fd);
 			return -EINVAL;
 		}
@@ -304,7 +301,6 @@ int dvb_fe_open_fname(struct dvb_v5_fe_parms_priv *parms, char *fname,
 		dtv_prop.props = parms->dvb_prop;
 		if (xioctl(fd, FE_GET_PROPERTY, &dtv_prop) == -1) {
 			dvb_perror("FE_GET_PROPERTY");
-			dvb_v5_free(parms);
 			close(fd);
 			return -errno;
 		}
@@ -314,7 +310,6 @@ int dvb_fe_open_fname(struct dvb_v5_fe_parms_priv *parms, char *fname,
 
 		if (parms->p.num_systems == 0) {
 			dvb_logerr(_("driver returned 0 supported delivery systems!"));
-			dvb_v5_free(parms);
 			close(fd);
 			return -EINVAL;
 		}
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/4] libdvbv5: fix parsing EIT extended event descriptor
  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 ` André Roth
  2018-07-07 11:20 ` [PATCH 4/4] libdvbv5: fix parsing section gaps André Roth
  2018-12-05  8:40 ` [PATCH 1/4] libdvbv5: do not adjust DVB time daylight saving Mauro Carvalho Chehab
  3 siblings, 0 replies; 5+ messages in thread
From: André Roth @ 2018-07-07 11:20 UTC (permalink / raw)
  To: linux-media; +Cc: André Roth

correctly parse, print and free the extended event descriptor list
of description/item pairs.

also fixes a typo in short event descriptor.

Signed-off-by: André Roth <neolynx@gmail.com>
---
 lib/include/libdvbv5/desc_event_extended.h     |  9 +++
 lib/libdvbv5/descriptors/desc_event_extended.c | 83 ++++++++++++++++++++------
 lib/libdvbv5/descriptors/desc_event_short.c    |  2 +-
 3 files changed, 74 insertions(+), 20 deletions(-)

diff --git a/lib/include/libdvbv5/desc_event_extended.h b/lib/include/libdvbv5/desc_event_extended.h
index 7e6ac9cd..46ef3276 100644
--- a/lib/include/libdvbv5/desc_event_extended.h
+++ b/lib/include/libdvbv5/desc_event_extended.h
@@ -39,6 +39,12 @@
 
 #include <libdvbv5/descriptors.h>
 
+struct dvb_desc_event_extended_item {
+	char *description;
+	char *description_emph;
+	char *item;
+	char *item_emph;
+};
 
 /**
  * @struct dvb_desc_event_extended
@@ -58,6 +64,7 @@
  * The emphasis text is the one that uses asterisks. For example, in the text:
  *	"the quick *fox* jumps over the lazy table" the emphasis would be "fox".
  */
+
 struct dvb_desc_event_extended {
 	uint8_t type;
 	uint8_t length;
@@ -74,6 +81,8 @@ struct dvb_desc_event_extended {
 	unsigned char language[4];
 	char *text;
 	char *text_emph;
+	struct dvb_desc_event_extended_item *items;
+	int num_items;
 } __attribute__((packed));
 
 struct dvb_v5_fe_parms;
diff --git a/lib/libdvbv5/descriptors/desc_event_extended.c b/lib/libdvbv5/descriptors/desc_event_extended.c
index 200657ad..624ac01c 100644
--- a/lib/libdvbv5/descriptors/desc_event_extended.c
+++ b/lib/libdvbv5/descriptors/desc_event_extended.c
@@ -22,57 +22,102 @@
 #include <libdvbv5/dvb-fe.h>
 #include <parse_string.h>
 
+#ifdef ENABLE_NLS
+# include "gettext.h"
+# include <libintl.h>
+# define _(string) dgettext(LIBDVBV5_DOMAIN, string)
+#else
+# define _(string) string
+#endif
+
 int dvb_desc_event_extended_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, struct dvb_desc *desc)
 {
 	struct dvb_desc_event_extended *event = (struct dvb_desc_event_extended *) desc;
-	uint8_t len;  /* the length of the string in the input data */
-	uint8_t len1; /* the lenght of the output strings */
-
-	/*dvb_hexdump(parms, "event extended desc: ", buf - 2, desc->length + 2);*/
+	uint8_t len, size_items;
+	const uint8_t *buf_start;
+	int first = 1;
+	struct dvb_desc_event_extended_item *item;
 
 	event->ids = buf[0];
+
 	event->language[0] = buf[1];
 	event->language[1] = buf[2];
 	event->language[2] = buf[3];
 	event->language[3] = '\0';
 
-	uint8_t items = buf[4];
+	size_items = buf[4];
 	buf += 5;
 
-	int i;
-	for (i = 0; i < items; i++) {
-		dvb_logwarn("dvb_desc_event_extended: items not implemented");
-		uint8_t desc_len = *buf;
+	event->items = NULL;
+	event->num_items = 0;
+	buf_start = buf;
+	while (buf - buf_start < size_items) {
+		if (first) {
+			first = 0;
+			event->num_items = 1;
+			event->items = calloc(sizeof(struct dvb_desc_event_extended_item), event->num_items);
+			if (!event->items) {
+				dvb_logerr(_("%s: out of memory"), __func__);
+				return -1;
+			}
+			item = event->items;
+		} else {
+			event->num_items++;
+			event->items = realloc(event->items, sizeof(struct dvb_desc_event_extended_item) * (event->num_items));
+			item = event->items + (event->num_items - 1);
+		}
+		len = *buf;
 		buf++;
+		item->description = NULL;
+		item->description_emph = NULL;
+		dvb_parse_string(parms, &item->description, &item->description_emph, buf, len);
+		buf += len;
 
-		buf += desc_len;
-
-		uint8_t item_len = *buf;
+		len = *buf;
 		buf++;
-
-		buf += item_len;
+		item->item = NULL;
+		item->item_emph = NULL;
+		dvb_parse_string(parms, &item->item, &item->item_emph, buf, len);
+		buf += len;
 	}
 
-	event->text = NULL;
-	event->text_emph = NULL;
+
 	len = *buf;
-	len1 = len;
 	buf++;
-	dvb_parse_string(parms, &event->text, &event->text_emph, buf, len1);
-	buf += len;
+
+	if (len) {
+		event->text = NULL;
+		event->text_emph = NULL;
+		dvb_parse_string(parms, &event->text, &event->text_emph, buf, len);
+		buf += len;
+	}
+
 	return 0;
 }
 
 void dvb_desc_event_extended_free(struct dvb_desc *desc)
 {
 	struct dvb_desc_event_extended *event = (struct dvb_desc_event_extended *) desc;
+	int i;
 	free(event->text);
 	free(event->text_emph);
+	for (i = 0; i < event->num_items; i++) {
+		free(event->items[i].description);
+		free(event->items[i].description_emph);
+		free(event->items[i].item);
+		free(event->items[i].item_emph);
+	}
+	free(event->items);
 }
 
 void dvb_desc_event_extended_print(struct dvb_v5_fe_parms *parms, const struct dvb_desc *desc)
 {
 	const struct dvb_desc_event_extended *event = (const struct dvb_desc_event_extended *) desc;
+	int i;
 	dvb_loginfo("|           '%s'", event->text);
+	for (i = 0; i < event->num_items; i++) {
+		dvb_loginfo("|              description   '%s'", event->items[i].description);
+		dvb_loginfo("|              item          '%s'", event->items[i].item);
+	}
 }
 
diff --git a/lib/libdvbv5/descriptors/desc_event_short.c b/lib/libdvbv5/descriptors/desc_event_short.c
index 3bdcb89b..881e6d45 100644
--- a/lib/libdvbv5/descriptors/desc_event_short.c
+++ b/lib/libdvbv5/descriptors/desc_event_short.c
@@ -68,6 +68,6 @@ void dvb_desc_event_short_print(struct dvb_v5_fe_parms *parms, const struct dvb_
 	const struct dvb_desc_event_short *event = (const struct dvb_desc_event_short *) desc;
 	dvb_loginfo("|           name          '%s'", event->name);
 	dvb_loginfo("|           language      '%s'", event->language);
-	dvb_loginfo("|           sescription   '%s'", event->text);
+	dvb_loginfo("|           description   '%s'", event->text);
 }
 
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 4/4] libdvbv5: fix parsing section gaps
  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 ` André Roth
  2018-12-05  8:40 ` [PATCH 1/4] libdvbv5: do not adjust DVB time daylight saving Mauro Carvalho Chehab
  3 siblings, 0 replies; 5+ messages in thread
From: André Roth @ 2018-07-07 11:20 UTC (permalink / raw)
  To: linux-media; +Cc: André Roth

use the priv->extensions list also when parsing no continuous sections.
also fixes memory allocation/initialization for the extensions list.

Signed-off-by: André Roth <neolynx@gmail.com>
---
 lib/libdvbv5/dvb-scan.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/lib/libdvbv5/dvb-scan.c b/lib/libdvbv5/dvb-scan.c
index 7ff8ba4f..5c8aca96 100644
--- a/lib/libdvbv5/dvb-scan.c
+++ b/lib/libdvbv5/dvb-scan.c
@@ -218,6 +218,7 @@ static int dvb_parse_section(struct dvb_v5_fe_parms_priv *parms,
 		ext->first_section = h.section_id;
 		ext->last_section = h.last_section;
 		priv->extensions = ext;
+		priv->num_extensions = 1;
 		new = 1;
 	} else {
 		/* search for an specific TS ID */
@@ -239,10 +240,21 @@ static int dvb_parse_section(struct dvb_v5_fe_parms_priv *parms,
 				return -1;
 			}
 			ext += i;
+			memset(ext, 0, sizeof(struct dvb_table_filter_ext_priv));
+			ext->ext_id = h.id;
+			ext->first_section = h.section_id;
+			ext->last_section = h.last_section;
+			new = 1;
 		}
 	}
 
 	if (!new) { /* Check if the table was already parsed, but not on first pass */
+		if(ext->done) {
+			if (parms->p.verbose)
+				dvb_log(_("%s: extension already done, ignoring: 0x%04x"), __func__, ext->ext_id);
+			return 0;
+		}
+
 		if (!sect->allow_section_gaps && sect->ts_id == -1) {
 			if (test_bit(h.section_id, ext->is_read_bits))
 				return 0;
@@ -252,8 +264,8 @@ static int dvb_parse_section(struct dvb_v5_fe_parms_priv *parms,
 			 * table is reached.
 			 */
 			if (parms->p.verbose)
-				dvb_log(_("%s: section repeated on table 0x%02x, extension ID 0x%04x: done"),
-					__func__, h.table_id, h.id);
+				dvb_log(_("%s: section repeated on table 0x%02x, extension ID 0x%04x, section %d/%d: done"),
+					__func__, h.table_id, ext->ext_id, h.section_id, h.last_section);
 
 			ext->done = 1;
 
@@ -287,8 +299,12 @@ static int dvb_parse_section(struct dvb_v5_fe_parms_priv *parms,
 ret:
 	/* Check if all extensions are done */
 	for (ext = priv->extensions, i = 0; i < priv->num_extensions; i++, ext++) {
-		if (!ext->done)
+		if (!ext->done) {
+			if (parms->p.verbose)
+				dvb_log(_("%s: extension not completed yet: 0x%04x"),
+						__func__, ext->ext_id);
 			return 0;
+		}
 	}
 
 	/* Section was fully parsed */
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/4] libdvbv5: do not adjust DVB time daylight saving
  2018-07-07 11:20 [PATCH 1/4] libdvbv5: do not adjust DVB time daylight saving André Roth
                   ` (2 preceding siblings ...)
  2018-07-07 11:20 ` [PATCH 4/4] libdvbv5: fix parsing section gaps André Roth
@ 2018-12-05  8:40 ` Mauro Carvalho Chehab
  3 siblings, 0 replies; 5+ messages in thread
From: Mauro Carvalho Chehab @ 2018-12-05  8:40 UTC (permalink / raw)
  To: André Roth; +Cc: linux-media

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-12-05  8:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 1/4] libdvbv5: do not adjust DVB time daylight saving Mauro Carvalho Chehab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).