From 15ab5cde0afb262682baf08a6c795f49012b2707 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 15 Nov 2013 17:43:54 -0200 Subject: [PATCH] libdvbv5: Add support for partial reception Partial reception is a feature for ISDB streams. Add support for its descriptor. Signed-off-by: Mauro Carvalho Chehab --- lib/include/descriptors/desc_partial_reception.h | 56 ++++++++++++++++++++++ lib/libdvbv5/Makefile.am | 1 + lib/libdvbv5/descriptors.c | 7 +-- lib/libdvbv5/descriptors/desc_partial_reception.c | 58 +++++++++++++++++++++++ 4 files changed, 119 insertions(+), 3 deletions(-) create mode 100644 lib/include/descriptors/desc_partial_reception.h create mode 100644 lib/libdvbv5/descriptors/desc_partial_reception.c diff --git a/lib/include/descriptors/desc_partial_reception.h b/lib/include/descriptors/desc_partial_reception.h new file mode 100644 index 0000000..37eaf13 --- /dev/null +++ b/lib/include/descriptors/desc_partial_reception.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2013 - Mauro Carvalho Chehab + * + * 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 + * + * Described on IEC/CENELEC DS/EN 62216-1:2011 + * + * I couldn't find the original version, so I used what's there at: + * http://tdt.telecom.pt/recursos/apresentacoes/Signalling Specifications for DTT deployment in Portugal.pdf + */ + +#ifndef _PARTIAL_RECEPTION_H +#define _PARTIAL_RECEPTION_H + +#include +#include /* ssize_t */ + +struct isdb_partial_reception_service_id { + uint16_t service_id; +} __attribute__((packed)); + +struct isdb_desc_partial_reception { + uint8_t type; + uint8_t length; + struct dvb_desc *next; + + struct isdb_partial_reception_service_id *partial_reception; +} __attribute__((packed)); + +struct dvb_v5_fe_parms; + +#ifdef __cplusplus +extern "C" { +#endif + +void isdb_desc_partial_reception_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, struct dvb_desc *desc); +void isdb_desc_partial_reception_print(struct dvb_v5_fe_parms *parms, const struct dvb_desc *desc); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/lib/libdvbv5/Makefile.am b/lib/libdvbv5/Makefile.am index 4fc69a2..da04a3d 100644 --- a/lib/libdvbv5/Makefile.am +++ b/lib/libdvbv5/Makefile.am @@ -44,6 +44,7 @@ libdvbv5_la_SOURCES = \ descriptors/desc_isdbt_delivery.c ../include/descriptors/desc_isdbt_delivery.h \ descriptors/desc_logical_channel.c ../include/descriptors/desc_logical_channel.h \ descriptors/desc_ts_info.c ../include/descriptors/desc_ts_info.h \ + descriptors/desc_partial_reception.c ../include/descriptors/desc_partial_reception.h \ descriptors/nit.c ../include/descriptors/nit.h \ descriptors/sdt.c ../include/descriptors/sdt.h \ descriptors/vct.c ../include/descriptors/vct.h \ diff --git a/lib/libdvbv5/descriptors.c b/lib/libdvbv5/descriptors.c index 1e63d9d..875fceb 100644 --- a/lib/libdvbv5/descriptors.c +++ b/lib/libdvbv5/descriptors.c @@ -51,6 +51,7 @@ #include "descriptors/desc_hierarchy.h" #include "descriptors/desc_ts_info.h" #include "descriptors/desc_logical_channel.h" +#include "descriptors/desc_partial_reception.h" #include "descriptors/desc_extension.h" ssize_t dvb_desc_init(const uint8_t *buf, struct dvb_desc *desc) @@ -1144,10 +1145,10 @@ const struct dvb_descriptor dvb_descriptors[] = { }, [partial_reception_descriptor] = { .name = "partial_reception_descriptor", - .init = NULL, - .print = NULL, + .init = isdb_desc_partial_reception_init, + .print = isdb_desc_partial_reception_print, .free = NULL, - .size = 0, + .size = sizeof(struct isdb_desc_partial_reception), }, [emergency_information_descriptor] = { .name = "emergency_information_descriptor", diff --git a/lib/libdvbv5/descriptors/desc_partial_reception.c b/lib/libdvbv5/descriptors/desc_partial_reception.c new file mode 100644 index 0000000..41bf428 --- /dev/null +++ b/lib/libdvbv5/descriptors/desc_partial_reception.c @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2013 - Mauro Carvalho Chehab + * + * 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 + * + * Described on ARIB STD-B10 as Partial reception descriptor + */ + +#include "descriptors.h" +#include "descriptors/desc_partial_reception.h" +#include "dvb-fe.h" +#include "parse_string.h" + +void isdb_desc_partial_reception_init(struct dvb_v5_fe_parms *parms, + const uint8_t *buf, struct dvb_desc *desc) +{ + struct isdb_desc_partial_reception *d = (void *)desc; + unsigned char *p = (unsigned char *)buf; + size_t len; + int i; + + d->partial_reception = malloc(d->length); + if (!d->partial_reception) + dvb_perror("Out of memory!"); + + memcpy(d->partial_reception, p, d->length); + + len = d->length / sizeof(d->partial_reception); + + for (i = 0; i < len; i++) + bswap16(d->partial_reception[i].service_id); +} + +void isdb_desc_partial_reception_print(struct dvb_v5_fe_parms *parms, const struct dvb_desc *desc) +{ + struct isdb_desc_partial_reception *d = (void *)desc; + int i; + size_t len; + + len = d->length / sizeof(d->partial_reception); + + for (i = 0; i < len; i++) { + dvb_log("| service ID[%d] %d", i, d->partial_reception[i].service_id); + } +} -- 2.7.4