From patchwork Tue Mar 25 18:19:54 2014 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: 3889811 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AAD72BF540 for ; Tue, 25 Mar 2014 18:20:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CEF7D201C8 for ; Tue, 25 Mar 2014 18:20:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DE44F201BA for ; Tue, 25 Mar 2014 18:20:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754728AbaCYSUm (ORCPT ); Tue, 25 Mar 2014 14:20:42 -0400 Received: from mail-ee0-f50.google.com ([74.125.83.50]:60417 "EHLO mail-ee0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754252AbaCYSUg (ORCPT ); Tue, 25 Mar 2014 14:20:36 -0400 Received: by mail-ee0-f50.google.com with SMTP id c13so787901eek.9 for ; Tue, 25 Mar 2014 11:20:34 -0700 (PDT) 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=+Sfuy/RHaw3s6bpWrGBR2Gg/p/da1pW/cKcC0JIwKVY=; b=wdweEaW60NaYJ2VfAauND1Ba5cN1Mwum+026LT8zAulR9URpVkAPCgGQblE0+ORRMZ lgTX7SUhi3NCVqGyFCGzw75SemV0mly1vjurihYmFthfOPLdru6TE9E8d38SN2Qq395C 1yx3OJVVnAwZclOhpcberTBzpEkePEQL46uPce8+W9KOpVT1nO2NsiFXYEw8ejwcRpm3 x1MRKEfgl6zh5lHRT2zr2hU9QzsXa1K2ejpGt6iV39cQaJF7tEWk/Kl4kT+QaLs9QH++ YvTznKDpJGx8nBJydqDRBPEN0eDSD9tk6sE+Y9u+jqvwVws8eZhNPrf4yWZe1mZf2kjz o/VQ== X-Received: by 10.14.95.136 with SMTP id p8mr1307480eef.103.1395771634810; Tue, 25 Mar 2014 11:20:34 -0700 (PDT) Received: from neutrino.exnihilo (140-227.61-188.cust.bluewin.ch. [188.61.227.140]) by mx.google.com with ESMTPSA id 44sm41756278eek.30.2014.03.25.11.20.33 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Mar 2014 11:20:33 -0700 (PDT) From: =?UTF-8?q?Andr=C3=A9=20Roth?= To: LMML Cc: =?UTF-8?q?Andr=C3=A9=20Roth?= Subject: [PATCH 04/11] libdvbv5: fix EIT parsing Date: Tue, 25 Mar 2014 19:19:54 +0100 Message-Id: <1395771601-3509-4-git-send-email-neolynx@gmail.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1395771601-3509-1-git-send-email-neolynx@gmail.com> References: <1395771601-3509-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=-7.2 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 9a1a637..e0ecee3 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 64a8897..123dc91 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 ); }