libdvbv5: do not adjust DVB time daylight saving
PATCH 1/4 libdvbv5: do not adjust DVB time daylight saving
This makes dvb_time available outside of EIT parsing, and struct tm to reflect the actual values received from DVB.
--- 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(-)
lib/include/libdvbv5/descriptors.h +11 -0
@@ -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
lib/include/libdvbv5/eit.h +0 -10
@@ -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
lib/libdvbv5/descriptors.c +37 -0
@@ -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 unsigndvb_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 ); +} +
lib/libdvbv5/tables/eit.c +0 -28
@@ -154,34 +154,6 @@ void dvb_table_eit_print(struct dvb_v5_fe_parms *parms, struct dvb_table_eit *eidvb_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" ,
Signature · 1 line
2.14.1
PATCH 2/4 libdvbv5: fix double free in dvb_fe_open_fname
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.
--- lib/libdvbv5/dvb-fe.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
lib/libdvbv5/dvb-fe.c +1 -6
@@ -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 ; }
Signature · 1 line
2.14.1
PATCH 3/4 libdvbv5: fix parsing EIT extended event descriptor
In reply to André Rothcorrectly parse, print and free the extended event descriptor list of description/item pairs.
also fixes a typo in short event descriptor.
--- 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(-)
lib/include/libdvbv5/desc_event_extended.h +9 -0
@@ -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 ;
lib/libdvbv5/descriptors/desc_event_extended.c +64 -19
121 lines not on this page · raw message
lib/libdvbv5/descriptors/desc_event_short.c +1 -1
@@ -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); }
Signature · 1 line
2.14.1
PATCH 4/4 libdvbv5: fix parsing section gaps
In reply to André Rothuse the priv->extensions list also when parsing no continuous sections. also fixes memory allocation/initialization for the extensions list.
--- lib/libdvbv5/dvb-scan.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)
lib/libdvbv5/dvb-scan.c +19 -3
@@ -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 */
Signature · 1 line
2.14.1
Em Sat, 7 Jul 2018 13:20:54 +0200
André Roth <[email protected]> escreveu:
Quoted 48 lines
This makes
dvb_timeavailable outside of EIT parsing, and struct tm to reflect the actual values received from DVB.Signed-off-by André Roth <[email protected]>--- 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(-)lib/include/libdvbv5/descriptors.h +11
-0@@ -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 lib/include/libdvbv5/eit.h +0
-0@@ -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);
lib/include/libdvbv5/eit.h void dvb_table_eit_free(struct dvb_table_eit *table); · line 221
Quoted 10 lines
lib/include/libdvbv5/eit.h +0
-10-/** -* @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.
Quoted 42 lines
lib/include/libdvbv5/eit.h +0
-0#ifdef __cplusplus }#endif lib/libdvbv5/descriptors.c +24
-0@@ -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 unsigndvb_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 ;
lib/libdvbv5/descriptors.c void dvb_hexdump(struct dvb_v5_fe_parms *parms, const char *prefix, const unsign · line 1427
Quoted 10 lines
lib/libdvbv5/descriptors.c +10
-0+ 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?
Quoted 32 lines
lib/libdvbv5/descriptors.c +3
-0+mktime ( tm ); +} +lib/libdvbv5/tables/eit.c +0
-21@@ -154,34 +154,6 @@ void dvb_table_eit_print(struct dvb_v5_fe_parms *parms, struct dvb_table_eit *eidvb_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;
lib/libdvbv5/tables/eit.c void dvb_table_eit_print(struct dvb_v5_fe_parms *parms, struct dvb_table_eit *ei · line 159
Quoted 10 lines
lib/libdvbv5/tables/eit.c +0
-7- 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