From patchwork Sat Dec 28 15:45:50 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: 3414061 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 2D1ADC02DC for ; Sat, 28 Dec 2013 15:46:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E3E9A20120 for ; Sat, 28 Dec 2013 15:46:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6A90320103 for ; Sat, 28 Dec 2013 15:46:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755301Ab3L1Pqn (ORCPT ); Sat, 28 Dec 2013 10:46:43 -0500 Received: from mail-ea0-f180.google.com ([209.85.215.180]:43717 "EHLO mail-ea0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755270Ab3L1PqV (ORCPT ); Sat, 28 Dec 2013 10:46:21 -0500 Received: by mail-ea0-f180.google.com with SMTP id f15so4450870eak.11 for ; Sat, 28 Dec 2013 07:46:18 -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=+JBYFaOewmAxuTbGjcYEVvAMECHx5AL3tFKmCdIqUu0=; b=rYZuUJLQhse+oHxmAW9fVc8d9kAjNk0EsPvEw/AEcGjeMq6YrRlp0tyQD0gDLkNfmD 61oww9oD4e882UN1ChUCXz/Gq5r2bFTvW8CKi4xDYUuIksMdqXNW3+H4d2f8AjxbQNyF IUWyxoGU3emwJEhPhg9Hcir1gxfXnB60bNXrq9ZqvUO0/UhLhItxMivPpy25rSqoumhl ud6zRIZ3DfT4Dw0wyvG7VNddmzWM350VWr/wEfub52J+jBp/7z3r1ZvB6VfzTBUkLtz4 oTYfxgzKGMGXAe3IH3oEGtnOiCm896wuaePlZdtiTuZHkBpIi1Z3WkTwxb5lyKmJQ4JA hDQg== X-Received: by 10.14.3.130 with SMTP id 2mr2878259eeh.36.1388245578334; Sat, 28 Dec 2013 07:46:18 -0800 (PST) Received: from neutrino.exnihilo (140-227.61-188.cust.bluewin.ch. [188.61.227.140]) by mx.google.com with ESMTPSA id n1sm91594131eep.20.2013.12.28.07.46.17 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 28 Dec 2013 07:46:17 -0800 (PST) From: =?UTF-8?q?Andr=C3=A9=20Roth?= To: Linux Media Mailing List Cc: =?UTF-8?q?Andr=C3=A9=20Roth?= Subject: [PATCH 02/13] libdvbv5: ATSC VCT table support Date: Sat, 28 Dec 2013 16:45:50 +0100 Message-Id: <1388245561-8751-2-git-send-email-neolynx@gmail.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1388245561-8751-1-git-send-email-neolynx@gmail.com> References: <1388245561-8751-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.4 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 Signed-off-by: André Roth --- lib/include/descriptors.h | 4 +- lib/include/descriptors/desc_service_location.h | 70 +++++++++++++++++++++++ lib/include/descriptors/vct.h | 5 +- lib/libdvbv5/Makefile.am | 3 +- lib/libdvbv5/descriptors.c | 2 +- lib/libdvbv5/descriptors/desc_service_location.c | 71 ++++++++++++++++++++++++ lib/libdvbv5/descriptors/vct.c | 1 + lib/libdvbv5/dvb-scan.c | 12 +++- 8 files changed, 162 insertions(+), 6 deletions(-) create mode 100644 lib/include/descriptors/desc_service_location.h create mode 100644 lib/libdvbv5/descriptors/desc_service_location.c diff --git a/lib/include/descriptors.h b/lib/include/descriptors.h index 2e614f0..5ab29a0 100644 --- a/lib/include/descriptors.h +++ b/lib/include/descriptors.h @@ -1,4 +1,4 @@ - /* +/* * Copyright (c) 2011-2012 - Mauro Carvalho Chehab * * This program is free software; you can redistribute it and/or @@ -216,6 +216,8 @@ enum descriptors { /* SCTE 35 2004 */ CUE_identifier_descriptor = 0x8a, + extended_channel_name = 0xa0, + service_location = 0xa1, /* From http://www.etherguidesystems.com/Help/SDOs/ATSC/Semantics/Descriptors/Default.aspx */ component_name_descriptor = 0xa3, diff --git a/lib/include/descriptors/desc_service_location.h b/lib/include/descriptors/desc_service_location.h new file mode 100644 index 0000000..2e11cff --- /dev/null +++ b/lib/include/descriptors/desc_service_location.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2011-2012 - Mauro Carvalho Chehab + * Copyright (c) 2012 - Andre Roth + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation version 2 + * of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + */ + +#ifndef _SERVICE_LOCATION_H +#define _SERVICE_LOCATION_H + +#include +#include /* ssize_t */ + +struct dvb_desc_service_location_element { + uint8_t stream_type; + union { + uint16_t bitfield; + struct { + uint16_t elementary_pid:13; + uint16_t reserved:3; + }; + }; + uint8_t language[4]; +} __attribute__((packed)); + +struct dvb_desc_service_location { + uint8_t type; + uint8_t length; + struct dvb_desc *next; + + union { + uint16_t bitfield; + struct { + uint16_t pcr_pid:13; + uint16_t reserved:3; + }; + }; + uint8_t elements; + struct dvb_desc_service_location_element *element; +} __attribute__((packed)); + +struct dvb_v5_fe_parms; + +#ifdef __cplusplus +extern "C" { +#endif + +void dvb_desc_service_location_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf, struct dvb_desc *desc); +void dvb_desc_service_location_print(struct dvb_v5_fe_parms *parms, const struct dvb_desc *desc); +void dvb_desc_service_location_free (struct dvb_desc *desc); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/lib/include/descriptors/vct.h b/lib/include/descriptors/vct.h index 6272b43..505a407 100644 --- a/lib/include/descriptors/vct.h +++ b/lib/include/descriptors/vct.h @@ -1,5 +1,6 @@ /* - * Copyright (c) 2013 - Mauro Carvalho Chehab + * Copyright (c) 2012 - Andre Roth + * Copyright (c) 2013 - Andre Roth * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -35,7 +36,7 @@ struct dvb_table_vct_channel { uint16_t __short_name[7]; union { - uint16_t bitfield1; + uint32_t bitfield; struct { uint32_t modulation_mode:8; uint32_t minor_channel_number:10; diff --git a/lib/libdvbv5/Makefile.am b/lib/libdvbv5/Makefile.am index 2ad5902..400af39 100644 --- a/lib/libdvbv5/Makefile.am +++ b/lib/libdvbv5/Makefile.am @@ -48,7 +48,8 @@ libdvbv5_la_SOURCES = \ descriptors/nit.c ../include/descriptors/nit.h \ descriptors/sdt.c ../include/descriptors/sdt.h \ descriptors/vct.c ../include/descriptors/vct.h \ - descriptors/eit.c ../include/descriptors/eit.h + descriptors/vct.c ../include/descriptors/vct.h \ + descriptors/desc_service_location.c ../include/descriptors/desc_service_location.h libdvbv5_la_CPPFLAGS = $(ENFORCE_LIBDVBV5_STATIC) libdvbv5_la_LDFLAGS = $(LIBDVBV5_VERSION) $(ENFORCE_LIBDVBV5_STATIC) -lm diff --git a/lib/libdvbv5/descriptors.c b/lib/libdvbv5/descriptors.c index 5ce9241..437b2f4 100644 --- a/lib/libdvbv5/descriptors.c +++ b/lib/libdvbv5/descriptors.c @@ -69,7 +69,7 @@ void dvb_desc_default_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, st void dvb_desc_default_print(struct dvb_v5_fe_parms *parms, const struct dvb_desc *desc) { - dvb_log("| %s (0x%02x)", dvb_descriptors[desc->type].name, desc->type); + dvb_log("| %s (%#02x)", dvb_descriptors[desc->type].name, desc->type); hexdump(parms, "| ", desc->data, desc->length); } diff --git a/lib/libdvbv5/descriptors/desc_service_location.c b/lib/libdvbv5/descriptors/desc_service_location.c new file mode 100644 index 0000000..94c34fa --- /dev/null +++ b/lib/libdvbv5/descriptors/desc_service_location.c @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2011-2012 - Mauro Carvalho Chehab + * Copyright (c) 2012 - Andre Roth + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation version 2 + * of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + */ + +#include "descriptors/desc_service_location.h" +#include "descriptors.h" +#include "dvb-fe.h" + +void dvb_desc_service_location_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, struct dvb_desc *desc) +{ + struct dvb_desc_service_location *service_location = (struct dvb_desc_service_location *) desc; + /* copy from .next */ + memcpy(((uint8_t *) service_location ) + + sizeof(service_location->type) + + sizeof(service_location->length) + + sizeof(service_location->next), + buf, + sizeof(service_location->bitfield) + sizeof(service_location->elements)); + buf += sizeof(service_location->bitfield) + sizeof(service_location->elements); + + bswap16(service_location->bitfield); + + // FIXME: handle elements == 0 + service_location->element = malloc(service_location->elements * sizeof(struct dvb_desc_service_location_element)); + int i; + struct dvb_desc_service_location_element *element = service_location->element; + for(i = 0; i < service_location->elements; i++) { + memcpy(element, buf, sizeof(struct dvb_desc_service_location_element) - 1); /* no \0 in lang */ + buf += sizeof(struct dvb_desc_service_location_element) - 1; + element->language[3] = '\0'; + bswap16(element->bitfield); + element++; + } +} + +void dvb_desc_service_location_print(struct dvb_v5_fe_parms *parms, const struct dvb_desc *desc) +{ + const struct dvb_desc_service_location *service_location = (const struct dvb_desc_service_location *) desc; + dvb_log("| pcr pid %d", service_location->pcr_pid); + dvb_log("| streams:"); + int i; + struct dvb_desc_service_location_element *element = service_location->element; + for(i = 0; i < service_location->elements; i++) { + dvb_log("| pid %d, type %d: %s", element[i].elementary_pid, element[i].stream_type, element[i].language); + } + dvb_log("| %d elements", service_location->elements); +} + +void dvb_desc_service_location_free(struct dvb_desc *desc) +{ + const struct dvb_desc_service_location *service_location = (const struct dvb_desc_service_location *) desc; + free(service_location->element); +} + diff --git a/lib/libdvbv5/descriptors/vct.c b/lib/libdvbv5/descriptors/vct.c index e703c52..e567f7a 100644 --- a/lib/libdvbv5/descriptors/vct.c +++ b/lib/libdvbv5/descriptors/vct.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2013 - Mauro Carvalho Chehab + * Copyright (c) 2013 - Andre Roth * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/lib/libdvbv5/dvb-scan.c b/lib/libdvbv5/dvb-scan.c index af3a052..76712d4 100644 --- a/lib/libdvbv5/dvb-scan.c +++ b/lib/libdvbv5/dvb-scan.c @@ -185,6 +185,15 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd, h = (struct dvb_table_header *)buf; dvb_table_header_init(h); + + /* dvb_logdbg( "dvb_read_section: id %d, section %d/%d, current: %d", h->id, h->section_id, h->last_section, h->current_next ); */ + if (start_id == h->id && start_section == h->section_id) { + dvb_logdbg( "dvb_read_section: section repeated, reading done" ); + break; + } + if (start_id == -1) start_id = h->id; + if (start_section == -1) start_section = h->section_id; + if (id != -1 && h->id != id) { /* search for a specific table id */ continue; } @@ -232,7 +241,8 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd, else dvb_logerr("dvb_read_section: no initializer for table %d", tid); - if (++sections == last_section + 1) + if (id != -1 && ++sections == last_section + 1) { + dvb_logerr("dvb_read_section: ++sections == last_section + 1"); break; } free(buf);