--- /dev/null
+/*
+ * Copyright (c) 2013 - Andre Roth <neolynx@gmail.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
+ *
+ */
+
+#ifndef _CAT_H
+#define _CAT_H
+
+#include <stdint.h>
+#include <unistd.h> /* ssize_t */
+
+#include <libdvbv5/header.h>
+
+#define DVB_TABLE_CAT 0x01
+#define DVB_TABLE_CAT_PID 0x0001
+
+struct dvb_table_cat {
+ struct dvb_table_header header;
+ struct dvb_desc *descriptor;
+} __attribute__((packed));
+
+struct dvb_v5_fe_parms;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void dvb_table_cat_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length);
+void dvb_table_cat_free(struct dvb_table_cat *cat);
+void dvb_table_cat_print(struct dvb_v5_fe_parms *parms, struct dvb_table_cat *t);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
../include/libdvbv5/atsc_header.h \
../include/libdvbv5/mgt.h \
../include/libdvbv5/eit.h \
+ ../include/libdvbv5/cat.h \
../include/libdvbv5/atsc_eit.h \
../include/libdvbv5/desc_service_location.h \
../include/libdvbv5/mpeg_ts.h \
descriptors/vct.c \
descriptors/mgt.c \
descriptors/eit.c \
+ descriptors/cat.c \
descriptors/atsc_eit.c \
descriptors/desc_language.c \
descriptors/desc_network_name.c \
#include <libdvbv5/dvb-log.h>
#include <libdvbv5/pat.h>
+#include <libdvbv5/cat.h>
#include <libdvbv5/pmt.h>
#include <libdvbv5/nit.h>
#include <libdvbv5/sdt.h>
const struct dvb_table_init dvb_table_initializers[] = {
[DVB_TABLE_PAT] = { dvb_table_pat_init, sizeof(struct dvb_table_pat) },
+ [DVB_TABLE_CAT] = { dvb_table_cat_init, sizeof(struct dvb_table_cat) },
[DVB_TABLE_PMT] = { dvb_table_pmt_init, sizeof(struct dvb_table_pmt) },
[DVB_TABLE_NIT] = { dvb_table_nit_init, sizeof(struct dvb_table_nit) },
[DVB_TABLE_SDT] = { dvb_table_sdt_init, sizeof(struct dvb_table_sdt) },
--- /dev/null
+/*
+ * Copyright (c) 2013 - Andre Roth <neolynx@gmail.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
+ *
+ */
+
+#include <libdvbv5/cat.h>
+#include <libdvbv5/descriptors.h>
+#include <libdvbv5/dvb-fe.h>
+
+void dvb_table_cat_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
+ ssize_t buflen, uint8_t *table, ssize_t *table_length)
+{
+ struct dvb_table_cat *cat = (void *)table;
+ struct dvb_desc **head_desc = &cat->descriptor;
+ const uint8_t *p = buf, *endbuf = buf + buflen - 4;
+ size_t size;
+
+ if (buf[0] != DVB_TABLE_CAT) {
+ dvb_logerr("%s: invalid marker 0x%02x, sould be 0x%02x", __func__, buf[0], DVB_TABLE_CAT);
+ *table_length = 0;
+ return;
+ }
+
+ if (*table_length > 0) {
+ /* find end of current lists */
+ while (*head_desc != NULL)
+ head_desc = &(*head_desc)->next;
+ }
+
+ size = offsetof(struct dvb_table_cat, descriptor);
+ if (p + size > endbuf) {
+ dvb_logerr("CAT table was truncated while filling dvb_table_cat. Need %zu bytes, but has only %zu.",
+ size, buflen);
+ return;
+ }
+
+ memcpy(table, p, size);
+ p += size;
+ *table_length = sizeof(struct dvb_table_cat);
+
+ size = endbuf - p;
+ dvb_parse_descriptors(parms, p, size, head_desc);
+}
+
+void dvb_table_cat_free(struct dvb_table_cat *cat)
+{
+ dvb_free_descriptors((struct dvb_desc **) &cat->descriptor);
+ free(cat);
+}
+
+void dvb_table_cat_print(struct dvb_v5_fe_parms *parms, struct dvb_table_cat *cat)
+{
+ dvb_log("cat");
+ dvb_table_header_print(parms, &cat->header);
+ dvb_print_descriptors(parms, cat->descriptor);
+}
+