libdvbv5: add parser for TS information descriptor
authorMauro Carvalho Chehab <m.chehab@samsung.com>
Fri, 15 Nov 2013 18:27:20 +0000 (16:27 -0200)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Wed, 27 Nov 2013 11:24:40 +0000 (09:24 -0200)
This descriptor is used on ISDB-T.

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

diff --git a/lib/include/descriptors/desc_ts_info.h b/lib/include/descriptors/desc_ts_info.h
new file mode 100644 (file)
index 0000000..6514a46
--- /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 ARIB STD-B10 as TS information descriptor
+ */
+
+#ifndef _TS_INFO_H
+#define _TS_INFO_H
+
+#include <stdint.h>
+#include <unistd.h> /* ssize_t */
+
+struct dvb_desc_ts_info_transmission_type {
+       uint8_t transmission_type_info;
+       uint8_t num_of_service;
+} __attribute__((packed));
+
+struct dvb_desc_ts_info {
+       uint8_t type;
+       uint8_t length;
+       struct dvb_desc *next;
+
+       char *ts_name, *ts_name_emph;
+       struct dvb_desc_ts_info_transmission_type transmission_type;
+       uint16_t *service_id;
+
+       uint8_t remote_control_key_id;
+       union {
+               uint8_t bitfield;
+               struct {
+                       uint8_t transmission_type_count:2;
+                       uint8_t length_of_ts_name:6;
+               } __attribute__((packed));
+       };
+} __attribute__((packed));
+
+struct dvb_v5_fe_parms;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void dvb_desc_ts_info_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, struct dvb_desc *desc);
+void dvb_desc_ts_info_print(struct dvb_v5_fe_parms *parms, const struct dvb_desc *desc);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
index c30fef1..48ef4df 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_ts_info.c  ../include/descriptors/desc_ts_info.h \
   descriptors/nit.c  ../include/descriptors/nit.h \
   descriptors/sdt.c  ../include/descriptors/sdt.h \
   descriptors/vct.c  ../include/descriptors/vct.h \
index 45fa70b..a9f4df7 100644 (file)
@@ -49,6 +49,7 @@
 #include "descriptors/desc_event_extended.h"
 #include "descriptors/desc_atsc_service_location.h"
 #include "descriptors/desc_hierarchy.h"
+#include "descriptors/desc_ts_info.h"
 #include "descriptors/desc_extension.h"
 
 ssize_t dvb_desc_init(const uint8_t *buf, struct dvb_desc *desc)
@@ -988,10 +989,10 @@ const struct dvb_descriptor dvb_descriptors[] = {
        },
        [TS_Information_descriptior] = {
                .name  = "TS_Information_descriptior",
-               .init  = NULL,
-               .print = NULL,
+               .init  = dvb_desc_ts_info_init,
+               .print = dvb_desc_ts_info_print,
                .free  = NULL,
-               .size  = 0,
+               .size  = sizeof(struct dvb_desc_ts_info),
        },
        [extended_broadcaster_descriptor] = {
                .name  = "extended_broadcaster_descriptor",
index 82008f9..086cf1b 100644 (file)
@@ -27,7 +27,7 @@ void atsc_desc_service_location_init(struct dvb_v5_fe_parms *parms,
 {
        struct atsc_desc_service_location *s_loc = (struct atsc_desc_service_location *)desc;
        struct atsc_desc_service_location_elementary *el;
-       const uint8_t *p = buf;
+       unsigned char *p = (unsigned char *)buf;
        int i;
        size_t len;
 
@@ -82,4 +82,4 @@ void atsc_desc_service_location_free(struct dvb_desc *desc)
 
        if (s_loc->elementary)
                free(s_loc->elementary);
-}
+}
\ No newline at end of file
diff --git a/lib/libdvbv5/descriptors/desc_ts_info.c b/lib/libdvbv5/descriptors/desc_ts_info.c
new file mode 100644 (file)
index 0000000..b68582c
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * 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 ARIB STD-B10 as TS information descriptor
+ */
+
+#include "descriptors.h"
+#include "descriptors/desc_ts_info.h"
+#include "dvb-fe.h"
+#include "parse_string.h"
+
+void dvb_desc_ts_info_init(struct dvb_v5_fe_parms *parms,
+                             const uint8_t *buf, struct dvb_desc *desc)
+{
+       struct dvb_desc_ts_info *d = (void *)desc;
+       unsigned char *p = (unsigned char *)buf;
+       struct dvb_desc_ts_info_transmission_type *t;
+       size_t len;
+       int i;
+
+       len = sizeof(*d) - offsetof(struct dvb_desc_ts_info, remote_control_key_id);
+       memcpy(&d->remote_control_key_id, p, len);
+       p += len;
+
+       len = d->length_of_ts_name;
+       d->ts_name = NULL;
+       d->ts_name_emph = NULL;
+       parse_string(parms, &d->ts_name, &d->ts_name_emph, buf, len,
+                    default_charset, output_charset);
+       p += len;
+
+       memcpy(&d->transmission_type, p, sizeof(d->transmission_type));
+       p += sizeof(d->transmission_type);
+
+       t = &d->transmission_type;
+
+       d->service_id = malloc(sizeof(*d->service_id) * t->num_of_service);
+       if (!d->service_id)
+               dvb_perror("Out of memory!");
+
+       memcpy(d->service_id, p, sizeof(*d->service_id) * t->num_of_service);
+
+       for (i = 0; i < t->num_of_service; i++)
+               bswap16(d->service_id[i]);
+
+       p += sizeof(*d->service_id) * t->num_of_service;
+}
+
+void dvb_desc_ts_info_print(struct dvb_v5_fe_parms *parms, const struct dvb_desc *desc)
+{
+       const struct dvb_desc_ts_info *d = (const void *) desc;
+       const struct dvb_desc_ts_info_transmission_type *t;
+       int i;
+
+       t = &d->transmission_type;
+
+       dvb_log("|        TS Information");
+       dvb_log("|           remote key ID     %d", d->remote_control_key_id);
+       dvb_log("|           name              %s", d->ts_name);
+       dvb_log("|           emphasis name     %s", d->ts_name_emph);
+       dvb_log("|           transmission type %s", d->ts_name_emph);
+
+       for (i = 0; i < t->num_of_service; i++)
+               dvb_log("|           service ID[%d]     %d", i, d->service_id[i]);
+}