All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <m.chehab@samsung.com>
To: "André Roth" <neolynx@gmail.com>
Cc: linux-media@vger.kernel.org
Subject: Re: [PATCH 07/18] libdvbv5: fix EIT parsing
Date: Tue, 07 Jan 2014 15:00:41 -0200	[thread overview]
Message-ID: <20140107150041.61cbb870@samsung.com> (raw)
In-Reply-To: <1388407731-24369-7-git-send-email-neolynx@gmail.com>

Em Mon, 30 Dec 2013 13:48:40 +0100
André Roth <neolynx@gmail.com> escreveu:

> the dvb_table_eit_event now contains the service_id,
> indicating where the events belong to.
> 
> Signed-off-by: André Roth <neolynx@gmail.com>
> ---
>  lib/include/descriptors/eit.h  |  3 ++-
>  lib/libdvbv5/descriptors/eit.c | 35 ++++++++++++++++++++++++++---------
>  2 files changed, 28 insertions(+), 10 deletions(-)
> 
> diff --git a/lib/include/descriptors/eit.h b/lib/include/descriptors/eit.h
> index 2af9696..ca08fd4 100644
> --- a/lib/include/descriptors/eit.h
> +++ b/lib/include/descriptors/eit.h
> @@ -40,7 +40,7 @@
>  struct dvb_table_eit_event {
>  	uint16_t event_id;
>  	union {
> -		uint16_t bitfield;
> +		uint16_t bitfield1; /* first 2 bytes are MJD, they need to be bswapped */
>  		uint8_t dvbstart[5];
>  	} __attribute__((packed));
>  	uint8_t dvbduration[3];
> @@ -56,6 +56,7 @@ struct dvb_table_eit_event {
>  	struct dvb_table_eit_event *next;
>  	struct tm start;
>  	uint32_t duration;
> +	uint16_t service_id;
>  } __attribute__((packed));
>  
>  struct dvb_table_eit {
> diff --git a/lib/libdvbv5/descriptors/eit.c b/lib/libdvbv5/descriptors/eit.c
> index ccfe1a6..c2d01c3 100644
> --- a/lib/libdvbv5/descriptors/eit.c
> +++ b/lib/libdvbv5/descriptors/eit.c
> @@ -29,6 +29,11 @@ void dvb_table_eit_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize
>  	struct dvb_table_eit_event **head;
>  
>  	if (*table_length > 0) {
> +		memcpy(eit, p, sizeof(struct dvb_table_eit) - sizeof(eit->event));
> +
> +		bswap16(eit->transport_id);
> +		bswap16(eit->network_id);
> +
>  		/* find end of curent list */
>  		head = &eit->event;
>  		while (*head != NULL)
> @@ -48,18 +53,30 @@ void dvb_table_eit_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize
>  	struct dvb_table_eit_event *last = NULL;
>  	while ((uint8_t *) p < buf + buflen - 4) {
>  		struct dvb_table_eit_event *event = (struct dvb_table_eit_event *) malloc(sizeof(struct dvb_table_eit_event));
> -		memcpy(event, p, sizeof(struct dvb_table_eit_event) - sizeof(event->descriptor) - sizeof(event->next) - sizeof(event->start) - sizeof(event->duration));
> -		p += sizeof(struct dvb_table_eit_event) - sizeof(event->descriptor) - sizeof(event->next) - sizeof(event->start) - sizeof(event->duration);
> +		memcpy(event, p, sizeof(struct dvb_table_eit_event) -
> +				 sizeof(event->descriptor) -
> +				 sizeof(event->next) -
> +				 sizeof(event->start) -
> +				 sizeof(event->duration) -
> +				 sizeof(event->service_id));
> +		p += sizeof(struct dvb_table_eit_event) -
> +		     sizeof(event->descriptor) -
> +		     sizeof(event->next) -
> +		     sizeof(event->start) -
> +		     sizeof(event->duration) -
> +		     sizeof(event->service_id);

Please check before copy and replace those sizeof()'s by offsetof().

>  
>  		bswap16(event->event_id);
> -		bswap16(event->bitfield);
> +		bswap16(event->bitfield1);
>  		bswap16(event->bitfield2);
>  		event->descriptor = NULL;
>  		event->next = NULL;
>  		dvb_time(event->dvbstart, &event->start);
> -		event->duration = bcd(event->dvbduration[0]) * 3600 +
> -				  bcd(event->dvbduration[1]) * 60 +
> -				  bcd(event->dvbduration[2]);
> +		event->duration = bcd((uint32_t) event->dvbduration[0]) * 3600 +
> +				  bcd((uint32_t) event->dvbduration[1]) * 60 +
> +				  bcd((uint32_t) event->dvbduration[2]);
> +
> +		event->service_id = eit->header.id;
>  
>  		if(!*head)
>  			*head = event;
> @@ -102,6 +119,7 @@ void dvb_table_eit_print(struct dvb_v5_fe_parms *parms, struct dvb_table_eit *ei
>  		char start[255];
>  		strftime(start, sizeof(start), "%F %T", &event->start);
>  		dvb_log("|- %7d", event->event_id);
> +		dvb_log("|   Service               %d", event->service_id);
>  		dvb_log("|   Start                 %s UTC", start);
>  		dvb_log("|   Duration              %dh %dm %ds", event->duration / 3600, (event->duration % 3600) / 60, event->duration % 60);
>  		dvb_log("|   free CA mode          %d", event->free_CA_mode);
> @@ -137,9 +155,8 @@ void dvb_time(const uint8_t data[5], struct tm *tm)
>    tm->tm_mday  = day;
>    tm->tm_mon   = month - 1;
>    tm->tm_year  = year;
> -  tm->tm_isdst = -1;
> -  tm->tm_wday  = 0;
> -  tm->tm_yday  = 0;
> +  tm->tm_isdst = 1; /* dst in effect, do not adjust */
> +  mktime( tm );
>  }
>  
>  


-- 

Cheers,
Mauro

  reply	other threads:[~2014-01-07 17:00 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-30 12:48 [PATCH 01/18] libdvbv5: fix reading multisection tables André Roth
2013-12-30 12:48 ` [PATCH 02/18] libdvbv5: service location descriptor support André Roth
2014-01-07 16:38   ` Mauro Carvalho Chehab
2013-12-30 12:48 ` [PATCH 03/18] libdvbv5: VCT table cleanup André Roth
2013-12-30 12:48 ` [PATCH 04/18] libdvbv5: mpeg elementary stream parsers André Roth
2014-01-07 16:47   ` Mauro Carvalho Chehab
2013-12-30 12:48 ` [PATCH 05/18] libdvbv5: fix NIT structures André Roth
2013-12-30 12:48 ` [PATCH 06/18] libdvbv5: implement dvb_fe_dummy for logging André Roth
2013-12-30 12:48 ` [PATCH 07/18] libdvbv5: fix EIT parsing André Roth
2014-01-07 17:00   ` Mauro Carvalho Chehab [this message]
2013-12-30 12:48 ` [PATCH 08/18] libdvbv5: implement MGT parser André Roth
2014-01-07 17:05   ` Mauro Carvalho Chehab
2013-12-30 12:48 ` [PATCH 09/18] libdvbv5: implement ATSC EIT André Roth
2014-01-07 17:12   ` Mauro Carvalho Chehab
2014-01-08 11:09     ` André Roth
2013-12-30 12:48 ` [PATCH 10/18] libdvbv5: prefix VCT with atsc_ instead of dvb_ André Roth
2013-12-30 12:48 ` [PATCH 11/18] libdvbv5: cleanup coding style André Roth
2014-01-07 17:23   ` Mauro Carvalho Chehab
2013-12-30 12:48 ` [PATCH 12/18] libdvbv5: fix missing includes André Roth
2013-12-30 12:48 ` [PATCH 13/18] libdvbv5: improve TS parsing André Roth
2014-01-07 17:27   ` Mauro Carvalho Chehab
2013-12-30 12:48 ` [PATCH 14/18] libdvbv5: cleanup dvb_nit_transport_foreach macro André Roth
2013-12-30 12:48 ` [PATCH 15/18] libdvbv5: remove c99 comments André Roth
2014-01-07 17:29   ` Mauro Carvalho Chehab
2013-12-30 12:48 ` [PATCH 17/18] libdvbv5: remove header files from SOURCES in Makefile.am André Roth
2014-01-07 17:30   ` Mauro Carvalho Chehab
2013-12-30 12:48 ` [PATCH 18/18] libdvbv5: README updated for shared libdvbv5 André Roth
2014-01-07 18:12   ` Mauro Carvalho Chehab
2014-01-07 16:32 ` [PATCH 01/18] libdvbv5: fix reading multisection tables Mauro Carvalho Chehab

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=20140107150041.61cbb870@samsung.com \
    --to=m.chehab@samsung.com \
    --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.