From patchwork Mon Dec 30 12:48:40 2013 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: 3419281 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A87CB9F37A for ; Mon, 30 Dec 2013 12:50:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EF7CC20109 for ; Mon, 30 Dec 2013 12:50:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2B067200ED for ; Mon, 30 Dec 2013 12:50:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755826Ab3L3Mtc (ORCPT ); Mon, 30 Dec 2013 07:49:32 -0500 Received: from mail-ea0-f169.google.com ([209.85.215.169]:63041 "EHLO mail-ea0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755764Ab3L3Mta (ORCPT ); Mon, 30 Dec 2013 07:49:30 -0500 Received: by mail-ea0-f169.google.com with SMTP id l9so4438430eaj.28 for ; Mon, 30 Dec 2013 04:49:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=hO7pCJvN7rPcSqvzXeiXOrB8I+b1LPqTeq43mE0mg/Q=; b=T651Fh2fabwJJsR6CaEKQU+LSB/cXOGRkOXasrexrbSgENBdwpe7rugkhO1ir81c26 wl8UYaqvLh47R9n0eN6jGCS5p0qL/yQFy0t+3aOIWdTKPBLrkRfL50OfvaagjLhG/U8/ jk+WCFefcdiPHZsOMCStDRpLY16Pb9kgakv+Lrbqh8xg9kE8itrQIdb6J5utprVN4gGA 39GDNv2Oh8xkAUV7yt4BedQY+D+4d24Stb+1GfeAvepZNoXHCu8G2ptb88gNHNOWZz+e CdeyyUScVgSzNS3FZTokhWoPsWbR2TZv3mVwL6eU1yCKiyUoyMbB9oVs5LqcKJeU9I+O FMYg== X-Received: by 10.15.31.196 with SMTP id y44mr1457226eeu.96.1388407768530; Mon, 30 Dec 2013 04:49:28 -0800 (PST) Received: from neutrino.exnihilo (140-227.61-188.cust.bluewin.ch. [188.61.227.140]) by mx.google.com with ESMTPSA id z42sm108428856eeo.17.2013.12.30.04.49.27 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 30 Dec 2013 04:49:28 -0800 (PST) From: =?UTF-8?q?Andr=C3=A9=20Roth?= To: linux-media@vger.kernel.org Cc: =?UTF-8?q?Andr=C3=A9=20Roth?= Subject: [PATCH 07/18] libdvbv5: fix EIT parsing Date: Mon, 30 Dec 2013 13:48:40 +0100 Message-Id: <1388407731-24369-7-git-send-email-neolynx@gmail.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1388407731-24369-1-git-send-email-neolynx@gmail.com> References: <1388407731-24369-1-git-send-email-neolynx@gmail.com> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP the dvb_table_eit_event now contains the service_id, indicating where the events belong to. Signed-off-by: André Roth --- 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); 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 ); }