From patchwork Wed Jan 8 22:12:47 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: 3456151 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 8A11FC02DC for ; Wed, 8 Jan 2014 22:13:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 893242016D for ; Wed, 8 Jan 2014 22:13:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 44D002015F for ; Wed, 8 Jan 2014 22:13:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932528AbaAHWNN (ORCPT ); Wed, 8 Jan 2014 17:13:13 -0500 Received: from mail-ea0-f173.google.com ([209.85.215.173]:54147 "EHLO mail-ea0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932525AbaAHWNK (ORCPT ); Wed, 8 Jan 2014 17:13:10 -0500 Received: by mail-ea0-f173.google.com with SMTP id o10so1078683eaj.32 for ; Wed, 08 Jan 2014 14:13:09 -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=dr5+6PTJLcxfrUGU+UVeiszJB0MulCpbPddmI4p//mc=; b=aoadoqQvLa7Yg4lAMY3jsL3UQhC1ozHHQ3XI83IeRMUZW1QwaTbynQcKDBwpvrXOxV 4jRc6HYHZ8tgOimLtcGtmiQ6NDovBA08DoaJTkZ3xjAnnMnkb18E/jIlD2zifShAMRmO HnIkG9NWa2P2Uwy4QzFHhtxphApTniD3bP+ZEE2cixB8e2CYf+l8+tbtVNGtXRNQFOc+ coQanAxD5s/bJMIgSVkIMlzFgtUEczs5909ut8JCJvY1i8jSlu7a2dEGRL379LJIeh2j HzDHdLBo4gfWwHNbwk0lg5fprVx9DFeMMdA1N/FDjThSXrod3JXPJW4AQOlRypKq39HS cL6w== X-Received: by 10.14.149.139 with SMTP id x11mr47338712eej.35.1389219187932; Wed, 08 Jan 2014 14:13:07 -0800 (PST) Received: from neutrino.exnihilo (140-227.61-188.cust.bluewin.ch. [188.61.227.140]) by mx.google.com with ESMTPSA id e3sm193265067eeg.11.2014.01.08.14.13.07 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 08 Jan 2014 14:13:07 -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 2/2] libdvbv5: service location descriptor support Date: Wed, 8 Jan 2014 23:12:47 +0100 Message-Id: <1389219167-23293-2-git-send-email-neolynx@gmail.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1389219167-23293-1-git-send-email-neolynx@gmail.com> References: <1389219167-23293-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 - implement the service location descriptor (0xa1) - small cleanups Signed-off-by: André Roth --- lib/include/descriptors.h | 4 +- lib/include/descriptors/desc_service_location.h | 68 ++++++++++++++++++++ lib/libdvbv5/descriptors/desc_service_location.c | 79 ++++++++++++++++++++++++ 3 files changed, 150 insertions(+), 1 deletion(-) 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 35eab1c..6f89aeb 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 @@ -222,6 +222,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..78490bd --- /dev/null +++ b/lib/include/descriptors/desc_service_location.h @@ -0,0 +1,68 @@ +/* + * 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 + * 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 + +struct dvb_desc_service_location_element { + uint8_t stream_type; + union { + uint16_t bitfield; + struct { + uint16_t elementary_pid:13; + uint16_t reserved:3; + } __attribute__((packed)); + } __attribute__((packed)); + 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; + } __attribute__((packed)); + } __attribute__((packed)); + 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/libdvbv5/descriptors/desc_service_location.c b/lib/libdvbv5/descriptors/desc_service_location.c new file mode 100644 index 0000000..187a8ac --- /dev/null +++ b/lib/libdvbv5/descriptors/desc_service_location.c @@ -0,0 +1,79 @@ +/* + * 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 + * 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 "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; + uint8_t *endbuf = buf + desc->length; + ssize_t size = sizeof(struct dvb_desc_service_location) - sizeof(struct dvb_desc); + struct dvb_desc_service_location_element *element; + int i; + + if (buf + size > endbuf) { + dvb_logerr("%s: short read %d/%zd bytes", __FUNCTION__, endbuf - buf, size); + return; + } + + memcpy(desc->data, buf, size); + bswap16(service_location->bitfield); + buf += size; + + if (service_location->elements == 0) + return; + + size = service_location->elements * sizeof(struct dvb_desc_service_location_element); + if (buf + size > endbuf) { + dvb_logerr("%s: short read %d/%zd bytes", __FUNCTION__, endbuf - buf, size); + return; + } + service_location->element = malloc(size); + 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; + struct dvb_desc_service_location_element *element = service_location->element; + int i; + + dvb_log("| pcr pid %d", service_location->pcr_pid); + dvb_log("| streams:"); + 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); +} +