libdvbv5: Add descriptors for virtual channel number
authorMauro Carvalho Chehab <m.chehab@samsung.com>
Fri, 15 Nov 2013 19:15:39 +0000 (17:15 -0200)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Wed, 27 Nov 2013 11:24:40 +0000 (09:24 -0200)
Those descriptors are present in some european countries and
in Brazil.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
lib/include/descriptors/desc_logical_channel.h [new file with mode: 0644]
lib/libdvbv5/Makefile.am
lib/libdvbv5/descriptors.c
lib/libdvbv5/descriptors/desc_isdbt_delivery.c
lib/libdvbv5/descriptors/desc_logical_channel.c [new file with mode: 0644]

diff --git a/lib/include/descriptors/desc_logical_channel.h b/lib/include/descriptors/desc_logical_channel.h
new file mode 100644 (file)
index 0000000..5605ea2
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2013 - Mauro Carvalho Chehab <m.chehab@samsung.com>
+ *
+ * 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 _LCN_DESC_H
+#define _LCN_DESC_H
+
+#include <stdint.h>
+#include <unistd.h> /* ssize_t */
+
+struct dvb_desc_logical_channel_number {
+       uint16_t service_id;
+       union {
+               uint16_t bitfield;
+               struct {
+                       uint16_t logical_channel_number:10;
+                       uint16_t reserved:5;
+                       uint16_t visible_service_flag:1;
+               };
+       };
+} __attribute__((packed));
+
+struct dvb_desc_logical_channel {
+       uint8_t type;
+       uint8_t length;
+       struct dvb_desc *next;
+
+       struct dvb_desc_logical_channel_number *lcn;
+} __attribute__((packed));
+
+struct dvb_v5_fe_parms;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void dvb_desc_logical_channel_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, struct dvb_desc *desc);
+void dvb_desc_logical_channel_print(struct dvb_v5_fe_parms *parms, const struct dvb_desc *desc);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
index 48ef4df..4fc69a2 100644 (file)
@@ -42,6 +42,7 @@ libdvbv5_la_SOURCES = \
   descriptors/desc_hierarchy.c  ../include/descriptors/desc_hierarchy.h \
   descriptors/desc_extension.c  ../include/descriptors/desc_extension.h \
   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/nit.c  ../include/descriptors/nit.h \
   descriptors/sdt.c  ../include/descriptors/sdt.h \
index a9f4df7..1e63d9d 100644 (file)
@@ -50,6 +50,7 @@
 #include "descriptors/desc_atsc_service_location.h"
 #include "descriptors/desc_hierarchy.h"
 #include "descriptors/desc_ts_info.h"
+#include "descriptors/desc_logical_channel.h"
 #include "descriptors/desc_extension.h"
 
 ssize_t dvb_desc_init(const uint8_t *buf, struct dvb_desc *desc)
@@ -868,10 +869,10 @@ const struct dvb_descriptor dvb_descriptors[] = {
        },
        [logical_channel_number_descriptor] = {
                .name  = "logical_channel_number_descriptor",
-               .init  = NULL,
-               .print = NULL,
+               .init  = dvb_desc_logical_channel_init,
+               .print = dvb_desc_logical_channel_print,
                .free  = NULL,
-               .size  = 0,
+               .size  = sizeof(struct dvb_desc_logical_channel_number),
        },
 
        [carousel_id_descriptor] = {
index ac0dcd5..be1c16a 100644 (file)
@@ -75,6 +75,6 @@ void isdbt_desc_delivery_print(struct dvb_v5_fe_parms *parms, const struct dvb_d
        dvb_log("|           area code         %d", d->area_code);
 
        for (i = 0; i < d->num_freqs; i++) {
-               dvb_log("|           frequency[%d]      %d Hz", i, d->frequency[i] * 1000000l / 7);
+               dvb_log("|           frequency[%d]      %ld Hz", i, d->frequency[i] * 1000000l / 7);
        }
 }
diff --git a/lib/libdvbv5/descriptors/desc_logical_channel.c b/lib/libdvbv5/descriptors/desc_logical_channel.c
new file mode 100644 (file)
index 0000000..3ca6ae0
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2013 - Mauro Carvalho Chehab <m.chehab@samsung.com>
+ *
+ * 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
+ */
+
+#include "descriptors.h"
+#include "descriptors/desc_logical_channel.h"
+#include "dvb-fe.h"
+#include "parse_string.h"
+
+void dvb_desc_logical_channel_init(struct dvb_v5_fe_parms *parms,
+                             const uint8_t *buf, struct dvb_desc *desc)
+{
+       struct dvb_desc_logical_channel *d = (void *)desc;
+       unsigned char *p = (unsigned char *)buf;
+       size_t len;
+       int i;
+
+       d->lcn = malloc(d->length);
+       if (!d->lcn)
+               dvb_perror("Out of memory!");
+
+       memcpy(d->lcn, p, d->length);
+
+       len = d->length / sizeof(d->lcn);
+
+       for (i = 0; i < len; i++) {
+               bswap16(d->lcn[i].service_id);
+               bswap16(d->lcn[i].bitfield);
+       }
+}
+
+void dvb_desc_logical_channel_print(struct dvb_v5_fe_parms *parms, const struct dvb_desc *desc)
+{
+       struct dvb_desc_logical_channel *d = (void *)desc;
+       int i;
+       size_t len;
+
+       len = d->length / sizeof(d->lcn);
+
+       for (i = 0; i < len; i++) {
+               dvb_log("|           service ID[%d]     %d", i, d->lcn[i].service_id);
+               dvb_log("|           LCN             %d", d->lcn[i].logical_channel_number);
+               dvb_log("|           visible service %d", d->lcn[i].visible_service_flag);
+       }
+}