* [PATCH 01/13] libdvbv5: fix reading multisection tables
@ 2013-12-28 15:45 André Roth
2013-12-28 15:45 ` [PATCH 02/13] libdvbv5: ATSC VCT table support André Roth
` (12 more replies)
0 siblings, 13 replies; 26+ messages in thread
From: André Roth @ 2013-12-28 15:45 UTC (permalink / raw)
To: Linux Media Mailing List; +Cc: André Roth
Signed-off-by: André Roth <neolynx@gmail.com>
---
lib/libdvbv5/dvb-scan.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/lib/libdvbv5/dvb-scan.c b/lib/libdvbv5/dvb-scan.c
index e9ccc72..af3a052 100644
--- a/lib/libdvbv5/dvb-scan.c
+++ b/lib/libdvbv5/dvb-scan.c
@@ -187,15 +187,19 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,
dvb_table_header_init(h);
if (id != -1 && h->id != id) { /* search for a specific table id */
continue;
- } else {
- if (table_id == -1)
- table_id = h->id;
- else if (h->id != table_id) {
- dvb_logwarn("dvb_read_section: table ID mismatch reading multi section table: %d != %d", h->id, table_id);
- continue;
- }
}
+ /*if (id != -1) {*/
+ /*if (table_id == -1)*/
+ /*table_id = h->id;*/
+ /*else if (h->id != table_id) {*/
+ /*dvb_logwarn("dvb_read_section: table ID mismatch reading multi section table: %d != %d", h->id, table_id);*/
+ /*free(buf);*/
+ /*continue;*/
+ /*}*/
+ /*}*/
+
+ dvb_logerr("dvb_read_section: got section %d, last %di, filter %d", h->section_id, h->last_section, id );
/* handle the sections */
if (first_section == -1)
first_section = h->section_id;
--
1.8.3.2
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH 02/13] libdvbv5: ATSC VCT table support
2013-12-28 15:45 [PATCH 01/13] libdvbv5: fix reading multisection tables André Roth
@ 2013-12-28 15:45 ` André Roth
2013-12-29 3:04 ` Mauro Carvalho Chehab
2013-12-28 15:45 ` [PATCH 03/13] libdvbv5: mpeg elementary stream parsers André Roth
` (11 subsequent siblings)
12 siblings, 1 reply; 26+ messages in thread
From: André Roth @ 2013-12-28 15:45 UTC (permalink / raw)
To: Linux Media Mailing List; +Cc: André Roth
Signed-off-by: André Roth <neolynx@gmail.com>
---
lib/include/descriptors.h | 4 +-
lib/include/descriptors/desc_service_location.h | 70 +++++++++++++++++++++++
lib/include/descriptors/vct.h | 5 +-
lib/libdvbv5/Makefile.am | 3 +-
lib/libdvbv5/descriptors.c | 2 +-
lib/libdvbv5/descriptors/desc_service_location.c | 71 ++++++++++++++++++++++++
lib/libdvbv5/descriptors/vct.c | 1 +
lib/libdvbv5/dvb-scan.c | 12 +++-
8 files changed, 162 insertions(+), 6 deletions(-)
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 2e614f0..5ab29a0 100644
--- a/lib/include/descriptors.h
+++ b/lib/include/descriptors.h
@@ -1,4 +1,4 @@
- /*
+/*
* Copyright (c) 2011-2012 - Mauro Carvalho Chehab <mchehab@redhat.com>
*
* This program is free software; you can redistribute it and/or
@@ -216,6 +216,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..2e11cff
--- /dev/null
+++ b/lib/include/descriptors/desc_service_location.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2011-2012 - Mauro Carvalho Chehab <mchehab@redhat.com>
+ * Copyright (c) 2012 - 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 _SERVICE_LOCATION_H
+#define _SERVICE_LOCATION_H
+
+#include <stdint.h>
+#include <unistd.h> /* ssize_t */
+
+struct dvb_desc_service_location_element {
+ uint8_t stream_type;
+ union {
+ uint16_t bitfield;
+ struct {
+ uint16_t elementary_pid:13;
+ uint16_t reserved:3;
+ };
+ };
+ 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;
+ };
+ };
+ 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/include/descriptors/vct.h b/lib/include/descriptors/vct.h
index 6272b43..505a407 100644
--- a/lib/include/descriptors/vct.h
+++ b/lib/include/descriptors/vct.h
@@ -1,5 +1,6 @@
/*
- * Copyright (c) 2013 - Mauro Carvalho Chehab <m.chehab@samsung.com>
+ * Copyright (c) 2012 - Andre Roth <neolynx@gmail.com>
+ * 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
@@ -35,7 +36,7 @@ struct dvb_table_vct_channel {
uint16_t __short_name[7];
union {
- uint16_t bitfield1;
+ uint32_t bitfield;
struct {
uint32_t modulation_mode:8;
uint32_t minor_channel_number:10;
diff --git a/lib/libdvbv5/Makefile.am b/lib/libdvbv5/Makefile.am
index 2ad5902..400af39 100644
--- a/lib/libdvbv5/Makefile.am
+++ b/lib/libdvbv5/Makefile.am
@@ -48,7 +48,8 @@ libdvbv5_la_SOURCES = \
descriptors/nit.c ../include/descriptors/nit.h \
descriptors/sdt.c ../include/descriptors/sdt.h \
descriptors/vct.c ../include/descriptors/vct.h \
- descriptors/eit.c ../include/descriptors/eit.h
+ descriptors/vct.c ../include/descriptors/vct.h \
+ descriptors/desc_service_location.c ../include/descriptors/desc_service_location.h
libdvbv5_la_CPPFLAGS = $(ENFORCE_LIBDVBV5_STATIC)
libdvbv5_la_LDFLAGS = $(LIBDVBV5_VERSION) $(ENFORCE_LIBDVBV5_STATIC) -lm
diff --git a/lib/libdvbv5/descriptors.c b/lib/libdvbv5/descriptors.c
index 5ce9241..437b2f4 100644
--- a/lib/libdvbv5/descriptors.c
+++ b/lib/libdvbv5/descriptors.c
@@ -69,7 +69,7 @@ void dvb_desc_default_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, st
void dvb_desc_default_print(struct dvb_v5_fe_parms *parms, const struct dvb_desc *desc)
{
- dvb_log("| %s (0x%02x)", dvb_descriptors[desc->type].name, desc->type);
+ dvb_log("| %s (%#02x)", dvb_descriptors[desc->type].name, desc->type);
hexdump(parms, "| ", desc->data, desc->length);
}
diff --git a/lib/libdvbv5/descriptors/desc_service_location.c b/lib/libdvbv5/descriptors/desc_service_location.c
new file mode 100644
index 0000000..94c34fa
--- /dev/null
+++ b/lib/libdvbv5/descriptors/desc_service_location.c
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2011-2012 - Mauro Carvalho Chehab <mchehab@redhat.com>
+ * Copyright (c) 2012 - 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 "descriptors/desc_service_location.h"
+#include "descriptors.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;
+ /* copy from .next */
+ memcpy(((uint8_t *) service_location )
+ + sizeof(service_location->type)
+ + sizeof(service_location->length)
+ + sizeof(service_location->next),
+ buf,
+ sizeof(service_location->bitfield) + sizeof(service_location->elements));
+ buf += sizeof(service_location->bitfield) + sizeof(service_location->elements);
+
+ bswap16(service_location->bitfield);
+
+ // FIXME: handle elements == 0
+ service_location->element = malloc(service_location->elements * sizeof(struct dvb_desc_service_location_element));
+ int i;
+ struct dvb_desc_service_location_element *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;
+ dvb_log("| pcr pid %d", service_location->pcr_pid);
+ dvb_log("| streams:");
+ int i;
+ struct dvb_desc_service_location_element *element = service_location->element;
+ 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);
+}
+
diff --git a/lib/libdvbv5/descriptors/vct.c b/lib/libdvbv5/descriptors/vct.c
index e703c52..e567f7a 100644
--- a/lib/libdvbv5/descriptors/vct.c
+++ b/lib/libdvbv5/descriptors/vct.c
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2013 - Mauro Carvalho Chehab <m.chehab@samsung.com>
+ * 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
diff --git a/lib/libdvbv5/dvb-scan.c b/lib/libdvbv5/dvb-scan.c
index af3a052..76712d4 100644
--- a/lib/libdvbv5/dvb-scan.c
+++ b/lib/libdvbv5/dvb-scan.c
@@ -185,6 +185,15 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,
h = (struct dvb_table_header *)buf;
dvb_table_header_init(h);
+
+ /* dvb_logdbg( "dvb_read_section: id %d, section %d/%d, current: %d", h->id, h->section_id, h->last_section, h->current_next ); */
+ if (start_id == h->id && start_section == h->section_id) {
+ dvb_logdbg( "dvb_read_section: section repeated, reading done" );
+ break;
+ }
+ if (start_id == -1) start_id = h->id;
+ if (start_section == -1) start_section = h->section_id;
+
if (id != -1 && h->id != id) { /* search for a specific table id */
continue;
}
@@ -232,7 +241,8 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,
else
dvb_logerr("dvb_read_section: no initializer for table %d", tid);
- if (++sections == last_section + 1)
+ if (id != -1 && ++sections == last_section + 1) {
+ dvb_logerr("dvb_read_section: ++sections == last_section + 1");
break;
}
free(buf);
--
1.8.3.2
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH 03/13] libdvbv5: mpeg elementary stream parsers
2013-12-28 15:45 [PATCH 01/13] libdvbv5: fix reading multisection tables André Roth
2013-12-28 15:45 ` [PATCH 02/13] libdvbv5: ATSC VCT table support André Roth
@ 2013-12-28 15:45 ` André Roth
2013-12-29 3:34 ` Mauro Carvalho Chehab
2013-12-28 15:45 ` [PATCH 04/13] libdvbv5: fix deadlock on missing table sections André Roth
` (10 subsequent siblings)
12 siblings, 1 reply; 26+ messages in thread
From: André Roth @ 2013-12-28 15:45 UTC (permalink / raw)
To: Linux Media Mailing List; +Cc: André Roth
Signed-off-by: André Roth <neolynx@gmail.com>
---
lib/include/descriptors/mpeg_es.h | 109 ++++++++++++++++++++++++++++++
lib/include/descriptors/mpeg_pes.h | 112 ++++++++++++++++++++++++++++++
lib/include/descriptors/mpeg_ts.h | 79 ++++++++++++++++++++++
lib/include/descriptors/nit.h | 4 +-
lib/libdvbv5/Makefile.am | 5 +-
lib/libdvbv5/descriptors/mpeg_es.c | 76 +++++++++++++++++++++
lib/libdvbv5/descriptors/mpeg_pes.c | 131 ++++++++++++++++++++++++++++++++++++
lib/libdvbv5/descriptors/mpeg_ts.c | 77 +++++++++++++++++++++
8 files changed, 590 insertions(+), 3 deletions(-)
create mode 100644 lib/include/descriptors/mpeg_es.h
create mode 100644 lib/include/descriptors/mpeg_pes.h
create mode 100644 lib/include/descriptors/mpeg_ts.h
create mode 100644 lib/libdvbv5/descriptors/mpeg_es.c
create mode 100644 lib/libdvbv5/descriptors/mpeg_pes.c
create mode 100644 lib/libdvbv5/descriptors/mpeg_ts.c
diff --git a/lib/include/descriptors/mpeg_es.h b/lib/include/descriptors/mpeg_es.h
new file mode 100644
index 0000000..1a74c90
--- /dev/null
+++ b/lib/include/descriptors/mpeg_es.h
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2012 - 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 _MPEG_ES_H
+#define _MPEG_ES_H
+
+#include <stdint.h>
+#include <unistd.h> /* ssize_t */
+
+#define DVB_MPEG_ES_PIC_START 0x00
+#define DVB_MPEG_ES_USER_DATA 0xb2
+#define DVB_MPEG_ES_SEQ_START 0xb3
+#define DVB_MPEG_ES_SEQ_EXT 0xb5
+#define DVB_MPEG_ES_GOP 0xb8
+#define DVB_MPEG_ES_SLICES 0x01 ... 0xaf
+
+struct dvb_mpeg_es_seq_start {
+ union {
+ uint32_t bitfield;
+ struct {
+ uint32_t type:8;
+ uint32_t sync:24;
+ } __attribute__((packed));
+ } __attribute__((packed));
+ union {
+ uint32_t bitfield2;
+ struct {
+ uint32_t framerate:4;
+ uint32_t aspect:4;
+ uint32_t height:12;
+ uint32_t width:12;
+ } __attribute__((packed));
+ };
+ union {
+ uint32_t bitfield3;
+ struct {
+ uint32_t qm_nonintra:1;
+ uint32_t qm_intra:1;
+ uint32_t constrained:1;
+ uint32_t vbv:10; // Size of video buffer verifier = 16*1024*vbv buf size
+ uint32_t one:1;
+ uint32_t bitrate:18;
+ } __attribute__((packed));
+ };
+} __attribute__((packed));
+
+struct dvb_mpeg_es_pic_start {
+ union {
+ uint32_t bitfield;
+ struct {
+ uint32_t type:8;
+ uint32_t sync:24;
+ } __attribute__((packed));
+ } __attribute__((packed));
+ union {
+ uint32_t bitfield2;
+ struct {
+ uint32_t dummy:3;
+ uint32_t vbv_delay:16;
+ uint32_t coding_type:3;
+ uint32_t temporal_ref:10;
+ } __attribute__((packed));
+ };
+} __attribute__((packed));
+
+enum dvb_mpeg_es_frame_t
+{
+ DVB_MPEG_ES_FRAME_UNKNOWN,
+ DVB_MPEG_ES_FRAME_I,
+ DVB_MPEG_ES_FRAME_P,
+ DVB_MPEG_ES_FRAME_B,
+ DVB_MPEG_ES_FRAME_D
+};
+extern const char *dvb_mpeg_es_frame_names[5];
+
+struct dvb_v5_fe_parms;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int dvb_mpeg_es_seq_start_init (const uint8_t *buf, ssize_t buflen, struct dvb_mpeg_es_seq_start *seq_start);
+void dvb_mpeg_es_seq_start_print(struct dvb_v5_fe_parms *parms, struct dvb_mpeg_es_seq_start *seq_start);
+
+int dvb_mpeg_es_pic_start_init (const uint8_t *buf, ssize_t buflen, struct dvb_mpeg_es_pic_start *pic_start);
+void dvb_mpeg_es_pic_start_print(struct dvb_v5_fe_parms *parms, struct dvb_mpeg_es_pic_start *pic_start);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/lib/include/descriptors/mpeg_pes.h b/lib/include/descriptors/mpeg_pes.h
new file mode 100644
index 0000000..e495f44
--- /dev/null
+++ b/lib/include/descriptors/mpeg_pes.h
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2011-2012 - Mauro Carvalho Chehab <mchehab@redhat.com>
+ * Copyright (c) 2012 - 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 _MPEG_PES_H
+#define _MPEG_PES_H
+
+#include <stdint.h>
+#include <unistd.h> /* ssize_t */
+
+#define DVB_MPEG_PES 0x00001
+#define DVB_MPEG_PES_VIDEO 0xe0 ... 0xef
+
+#define DVB_MPEG_STREAM_MAP 0xBC
+#define DVB_MPEG_STREAM_PADDING 0xBE
+#define DVB_MPEG_STREAM_PRIVATE_2 0x5F
+#define DVB_MPEG_STREAM_ECM 0x70
+#define DVB_MPEG_STREAM_EMM 0x71
+#define DVB_MPEG_STREAM_DIRECTORY 0xFF
+#define DVB_MPEG_STREAM_DSMCC 0x7A
+#define DVB_MPEG_STREAM_H222E 0xF8
+
+struct ts_t {
+ uint8_t one:1;
+ uint8_t bits30:3;
+ uint8_t tag:4;
+
+ union {
+ uint16_t bitfield;
+ struct {
+ uint16_t one1:1;
+ uint16_t bits15:15;
+ } __attribute__((packed));
+ } __attribute__((packed));
+
+ union {
+ uint16_t bitfield2;
+ struct {
+ uint16_t one2:1;
+ uint16_t bits00:15;
+ } __attribute__((packed));
+ } __attribute__((packed));
+} __attribute__((packed));
+
+struct dvb_mpeg_pes_optional {
+ union {
+ uint16_t bitfield;
+ struct {
+ uint16_t PES_extension:1;
+ uint16_t PES_CRC:1;
+ uint16_t additional_copy_info:1;
+ uint16_t DSM_trick_mode:1;
+ uint16_t ES_rate:1;
+ uint16_t ESCR:1;
+ uint16_t PTS_DTS:2;
+ uint16_t original_or_copy:1;
+ uint16_t copyright:1;
+ uint16_t data_alignment_indicator:1;
+ uint16_t PES_priority:1;
+ uint16_t PES_scrambling_control:2;
+ uint16_t two:2;
+ } __attribute__((packed));
+ } __attribute__((packed));
+ uint8_t length;
+ uint64_t pts;
+ uint64_t dts;
+} __attribute__((packed));
+
+struct dvb_mpeg_pes {
+ union {
+ uint32_t bitfield;
+ struct {
+ uint32_t stream_id:8;
+ uint32_t sync:24;
+ } __attribute__((packed));
+ } __attribute__((packed));
+ uint16_t length;
+ struct dvb_mpeg_pes_optional optional[];
+} __attribute__((packed));
+
+struct dvb_v5_fe_parms;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void dvb_mpeg_pes_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length);
+void dvb_mpeg_pes_free(struct dvb_mpeg_pes *ts);
+void dvb_mpeg_pes_print(struct dvb_v5_fe_parms *parms, struct dvb_mpeg_pes *ts);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/lib/include/descriptors/mpeg_ts.h b/lib/include/descriptors/mpeg_ts.h
new file mode 100644
index 0000000..2bb570b
--- /dev/null
+++ b/lib/include/descriptors/mpeg_ts.h
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2011-2012 - Mauro Carvalho Chehab <mchehab@redhat.com>
+ * Copyright (c) 2012 - 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 _MPEG_TS_H
+#define _MPEG_TS_H
+
+#include <stdint.h>
+#include <unistd.h> /* ssize_t */
+
+#define DVB_MPEG_TS 0x47
+
+struct dvb_mpeg_ts_adaption {
+ uint8_t length;
+ struct {
+ uint8_t extension:1;
+ uint8_t private_data:1;
+ uint8_t splicing_point:1;
+ uint8_t OPCR:1;
+ uint8_t PCR:1;
+ uint8_t priority:1;
+ uint8_t random_access:1;
+ uint8_t discontinued:1;
+ } __attribute__((packed));
+
+} __attribute__((packed));
+
+struct dvb_mpeg_ts {
+ uint8_t sync_byte; // DVB_MPEG_TS
+ union {
+ uint16_t bitfield;
+ struct {
+ uint16_t pid:13;
+ uint16_t priority:1;
+ uint16_t payload_start:1;
+ uint16_t tei:1;
+ } __attribute__((packed));
+ };
+ struct {
+ uint8_t continuity_counter:4;
+ uint8_t adaptation_field:2;
+ uint8_t scrambling:2;
+ } __attribute__((packed));
+ struct dvb_mpeg_ts_adaption adaption[];
+
+} __attribute__((packed));
+
+struct dvb_v5_fe_parms;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void dvb_mpeg_ts_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length);
+void dvb_mpeg_ts_free(struct dvb_mpeg_ts *ts);
+void dvb_mpeg_ts_print(struct dvb_v5_fe_parms *parms, struct dvb_mpeg_ts *ts);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/lib/include/descriptors/nit.h b/lib/include/descriptors/nit.h
index f2f6163..d71a762 100644
--- a/lib/include/descriptors/nit.h
+++ b/lib/include/descriptors/nit.h
@@ -48,7 +48,7 @@ struct dvb_table_nit_transport {
struct {
uint16_t section_length:12;
uint16_t reserved:4;
- };
+ } __attribute__((packed));
};
struct dvb_desc *descriptor;
struct dvb_table_nit_transport *next;
@@ -61,7 +61,7 @@ struct dvb_table_nit {
struct {
uint16_t desc_length:12;
uint16_t reserved:4;
- };
+ } __attribute__((packed));
};
struct dvb_desc *descriptor;
struct dvb_table_nit_transport *transport;
diff --git a/lib/libdvbv5/Makefile.am b/lib/libdvbv5/Makefile.am
index 400af39..795f30c 100644
--- a/lib/libdvbv5/Makefile.am
+++ b/lib/libdvbv5/Makefile.am
@@ -49,7 +49,10 @@ libdvbv5_la_SOURCES = \
descriptors/sdt.c ../include/descriptors/sdt.h \
descriptors/vct.c ../include/descriptors/vct.h \
descriptors/vct.c ../include/descriptors/vct.h \
- descriptors/desc_service_location.c ../include/descriptors/desc_service_location.h
+ descriptors/desc_service_location.c ../include/descriptors/desc_service_location.h \
+ descriptors/mpeg_ts.c ../include/descriptors/mpeg_ts.h \
+ descriptors/mpeg_pes.c ../include/descriptors/mpeg_pes.h \
+ descriptors/mpeg_es.c ../include/descriptors/mpeg_es.h
libdvbv5_la_CPPFLAGS = $(ENFORCE_LIBDVBV5_STATIC)
libdvbv5_la_LDFLAGS = $(LIBDVBV5_VERSION) $(ENFORCE_LIBDVBV5_STATIC) -lm
diff --git a/lib/libdvbv5/descriptors/mpeg_es.c b/lib/libdvbv5/descriptors/mpeg_es.c
new file mode 100644
index 0000000..b081af4
--- /dev/null
+++ b/lib/libdvbv5/descriptors/mpeg_es.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2012 - 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 "descriptors/mpeg_es.h"
+#include "descriptors.h"
+#include "dvb-fe.h"
+
+int dvb_mpeg_es_seq_start_init(const uint8_t *buf, ssize_t buflen, struct dvb_mpeg_es_seq_start *seq_start)
+{
+ if(buflen < sizeof(struct dvb_mpeg_es_seq_start))
+ return -1;
+ memcpy(seq_start, buf, sizeof(struct dvb_mpeg_es_seq_start));
+ bswap32(seq_start->bitfield);
+ bswap32(seq_start->bitfield2);
+ bswap32(seq_start->bitfield3);
+ return 0;
+}
+
+void dvb_mpeg_es_seq_start_print(struct dvb_v5_fe_parms *parms, struct dvb_mpeg_es_seq_start *seq_start)
+{
+ dvb_log("MPEG ES SEQ START");
+ dvb_log(" - width %d", seq_start->width);
+ dvb_log(" - height %d", seq_start->height);
+ dvb_log(" - aspect %d", seq_start->aspect);
+ dvb_log(" - framerate %d", seq_start->framerate);
+ dvb_log(" - bitrate %d", seq_start->bitrate);
+ dvb_log(" - one %d", seq_start->one);
+ dvb_log(" - vbv %d", seq_start->vbv);
+ dvb_log(" - constrained %d", seq_start->constrained);
+ dvb_log(" - qm_intra %d", seq_start->qm_intra);
+ dvb_log(" - qm_nonintra %d", seq_start->qm_nonintra);
+}
+
+const char *dvb_mpeg_es_frame_names[5] = {
+ "?",
+ "I",
+ "P",
+ "B",
+ "D"
+};
+
+int dvb_mpeg_es_pic_start_init(const uint8_t *buf, ssize_t buflen, struct dvb_mpeg_es_pic_start *pic_start)
+{
+ if(buflen < sizeof(struct dvb_mpeg_es_pic_start))
+ return -1;
+ memcpy(pic_start, buf, sizeof(struct dvb_mpeg_es_pic_start));
+ bswap32(pic_start->bitfield);
+ bswap32(pic_start->bitfield2);
+ return 0;
+}
+
+void dvb_mpeg_es_pic_start_print(struct dvb_v5_fe_parms *parms, struct dvb_mpeg_es_pic_start *pic_start)
+{
+ dvb_log("MPEG ES PIC START");
+ dvb_log(" - temporal_ref %d", pic_start->temporal_ref);
+ dvb_log(" - coding_type %d (%s-frame)", pic_start->coding_type, dvb_mpeg_es_frame_names[pic_start->coding_type]);
+ dvb_log(" - vbv_delay %d", pic_start->vbv_delay);
+}
+
diff --git a/lib/libdvbv5/descriptors/mpeg_pes.c b/lib/libdvbv5/descriptors/mpeg_pes.c
new file mode 100644
index 0000000..c717297
--- /dev/null
+++ b/lib/libdvbv5/descriptors/mpeg_pes.c
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2012 - 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 "descriptors/mpeg_pes.h"
+#include "descriptors.h"
+#include "dvb-fe.h"
+
+void dvb_mpeg_pes_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length)
+{
+ struct dvb_mpeg_pes *pes = (struct dvb_mpeg_pes *) (table + *table_length);
+ const uint8_t *p = buf;
+ memcpy(table + *table_length, p, sizeof(struct dvb_mpeg_pes));
+ p += sizeof(struct dvb_mpeg_pes);
+ *table_length += sizeof(struct dvb_mpeg_pes);
+
+ bswap32(pes->bitfield);
+ bswap16(pes->length);
+
+ if (pes->sync != 0x000001 ) {
+ dvb_logerr("mpeg pes invalid");
+ return;
+ }
+
+ if (pes->stream_id == DVB_MPEG_STREAM_PADDING) {
+ dvb_logwarn("mpeg pes padding stream ignored");
+ } else if (pes->stream_id == DVB_MPEG_STREAM_MAP ||
+ pes->stream_id == DVB_MPEG_STREAM_PRIVATE_2 ||
+ pes->stream_id == DVB_MPEG_STREAM_ECM ||
+ pes->stream_id == DVB_MPEG_STREAM_EMM ||
+ pes->stream_id == DVB_MPEG_STREAM_DIRECTORY ||
+ pes->stream_id == DVB_MPEG_STREAM_DSMCC ||
+ pes->stream_id == DVB_MPEG_STREAM_H222E ) {
+ dvb_logerr("mpeg pes: unsupported stream type %#04x", pes->stream_id);
+ } else {
+ memcpy(pes->optional, p, sizeof(struct dvb_mpeg_pes_optional) -
+ sizeof(pes->optional->pts) -
+ sizeof(pes->optional->dts));
+ p += sizeof(struct dvb_mpeg_pes_optional) -
+ sizeof(pes->optional->pts) -
+ sizeof(pes->optional->dts);
+ bswap16(pes->optional->bitfield);
+ pes->optional->pts = 0;
+ pes->optional->dts = 0;
+ if (pes->optional->PTS_DTS & 2) {
+ struct ts_t pts;
+ memcpy(&pts, p, sizeof(pts));
+ p += sizeof(pts);
+ bswap16(pts.bitfield);
+ bswap16(pts.bitfield2);
+ if (pts.one != 1 || pts.one1 != 1 || pts.one2 != 1)
+ dvb_logwarn("mpeg pes: invalid pts");
+ else {
+ pes->optional->pts |= (uint64_t) pts.bits00;
+ pes->optional->pts |= (uint64_t) pts.bits15 << 15;
+ pes->optional->pts |= (uint64_t) pts.bits30 << 30;
+ }
+ }
+ if (pes->optional->PTS_DTS & 1) {
+ struct ts_t dts;
+ memcpy(&dts, p, sizeof(dts));
+ p += sizeof(dts);
+ bswap16(dts.bitfield);
+ bswap16(dts.bitfield2);
+ pes->optional->dts |= (uint64_t) dts.bits00;
+ pes->optional->dts |= (uint64_t) dts.bits15 << 15;
+ pes->optional->dts |= (uint64_t) dts.bits30 << 30;
+ }
+ *table_length += sizeof(struct dvb_mpeg_pes_optional);
+ }
+}
+
+void dvb_mpeg_pes_free(struct dvb_mpeg_pes *ts)
+{
+ free(ts);
+}
+
+void dvb_mpeg_pes_print(struct dvb_v5_fe_parms *parms, struct dvb_mpeg_pes *pes)
+{
+ dvb_log("MPEG PES");
+ dvb_log(" - sync %#08x", pes->sync);
+ dvb_log(" - stream_id %#04x", pes->stream_id);
+ dvb_log(" - length %d", pes->length);
+ if (pes->stream_id == DVB_MPEG_STREAM_PADDING) {
+ } else if (pes->stream_id == DVB_MPEG_STREAM_MAP ||
+ pes->stream_id == DVB_MPEG_STREAM_PRIVATE_2 ||
+ pes->stream_id == DVB_MPEG_STREAM_ECM ||
+ pes->stream_id == DVB_MPEG_STREAM_EMM ||
+ pes->stream_id == DVB_MPEG_STREAM_DIRECTORY ||
+ pes->stream_id == DVB_MPEG_STREAM_DSMCC ||
+ pes->stream_id == DVB_MPEG_STREAM_H222E ) {
+ dvb_log(" mpeg pes unsupported stream type %#04x", pes->stream_id);
+ } else {
+ dvb_log(" mpeg pes optional");
+ dvb_log(" - two %d", pes->optional->two);
+ dvb_log(" - PES_scrambling_control %d", pes->optional->PES_scrambling_control);
+ dvb_log(" - PES_priority %d", pes->optional->PES_priority);
+ dvb_log(" - data_alignment_indicator %d", pes->optional->data_alignment_indicator);
+ dvb_log(" - copyright %d", pes->optional->copyright);
+ dvb_log(" - original_or_copy %d", pes->optional->original_or_copy);
+ dvb_log(" - PTS_DTS %d", pes->optional->PTS_DTS);
+ dvb_log(" - ESCR %d", pes->optional->ESCR);
+ dvb_log(" - ES_rate %d", pes->optional->ES_rate);
+ dvb_log(" - DSM_trick_mode %d", pes->optional->DSM_trick_mode);
+ dvb_log(" - additional_copy_info %d", pes->optional->additional_copy_info);
+ dvb_log(" - PES_CRC %d", pes->optional->PES_CRC);
+ dvb_log(" - PES_extension %d", pes->optional->PES_extension);
+ dvb_log(" - length %d", pes->optional->length);
+ if (pes->optional->PTS_DTS & 2)
+ dvb_log(" - pts %lx (%fs)", pes->optional->pts, (float) pes->optional->pts / 90000.0);
+ if (pes->optional->PTS_DTS & 1)
+ dvb_log(" - dts %lx (%fs)", pes->optional->dts, (float) pes->optional->dts/ 90000.0);
+ }
+}
+
diff --git a/lib/libdvbv5/descriptors/mpeg_ts.c b/lib/libdvbv5/descriptors/mpeg_ts.c
new file mode 100644
index 0000000..c1d1293
--- /dev/null
+++ b/lib/libdvbv5/descriptors/mpeg_ts.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2012 - 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 "descriptors/mpeg_ts.h"
+#include "descriptors.h"
+#include "dvb-fe.h"
+
+void dvb_mpeg_ts_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length)
+{
+ if (buf[0] != DVB_MPEG_TS) {
+ dvb_logerr("mpeg ts invalid marker %#02x, sould be %#02x", buf[0], DVB_MPEG_TS);
+ *table_length = 0;
+ return;
+ }
+ struct dvb_mpeg_ts *ts = (struct dvb_mpeg_ts *) table;
+ const uint8_t *p = buf;
+ memcpy(table, p, sizeof(struct dvb_mpeg_ts));
+ p += sizeof(struct dvb_mpeg_ts);
+ *table_length = sizeof(struct dvb_mpeg_ts);
+
+ bswap16(ts->bitfield);
+
+ if (ts->adaptation_field & 0x2) {
+ memcpy(table + *table_length, p, sizeof(struct dvb_mpeg_ts_adaption));
+ p += sizeof(struct dvb_mpeg_ts);
+ *table_length += ts->adaption->length + 1;
+ }
+ /*hexdump(parms, "TS: ", buf, buflen);*/
+}
+
+void dvb_mpeg_ts_free(struct dvb_mpeg_ts *ts)
+{
+ free(ts);
+}
+
+void dvb_mpeg_ts_print(struct dvb_v5_fe_parms *parms, struct dvb_mpeg_ts *ts)
+{
+ dvb_log("MPEG TS");
+ dvb_log(" - sync byte %#02x", ts->sync_byte);
+ dvb_log(" - tei %d", ts->tei);
+ dvb_log(" - payload_start %d", ts->payload_start);
+ dvb_log(" - priority %d", ts->priority);
+ dvb_log(" - pid %d", ts->pid);
+ dvb_log(" - scrambling %d", ts->scrambling);
+ dvb_log(" - adaptation_field %d", ts->adaptation_field);
+ dvb_log(" - continuity_counter %d", ts->continuity_counter);
+ if (ts->adaptation_field & 0x2) {
+ dvb_log(" Adaption Field");
+ dvb_log(" - length %d", ts->adaption->length);
+ dvb_log(" - discontinued %d", ts->adaption->discontinued);
+ dvb_log(" - random_access %d", ts->adaption->random_access);
+ dvb_log(" - priority %d", ts->adaption->priority);
+ dvb_log(" - PCR %d", ts->adaption->PCR);
+ dvb_log(" - OPCR %d", ts->adaption->OPCR);
+ dvb_log(" - splicing_point %d", ts->adaption->splicing_point);
+ dvb_log(" - private_data %d", ts->adaption->private_data);
+ dvb_log(" - extension %d", ts->adaption->extension);
+ }
+}
+
--
1.8.3.2
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH 04/13] libdvbv5: fix deadlock on missing table sections
2013-12-28 15:45 [PATCH 01/13] libdvbv5: fix reading multisection tables André Roth
2013-12-28 15:45 ` [PATCH 02/13] libdvbv5: ATSC VCT table support André Roth
2013-12-28 15:45 ` [PATCH 03/13] libdvbv5: mpeg elementary stream parsers André Roth
@ 2013-12-28 15:45 ` André Roth
2013-12-29 3:25 ` Mauro Carvalho Chehab
2013-12-28 15:45 ` [PATCH 05/13] libdvbv5: eit parsing updated André Roth
` (9 subsequent siblings)
12 siblings, 1 reply; 26+ messages in thread
From: André Roth @ 2013-12-28 15:45 UTC (permalink / raw)
To: Linux Media Mailing List; +Cc: André Roth
Signed-off-by: André Roth <neolynx@gmail.com>
---
lib/libdvbv5/dvb-scan.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lib/libdvbv5/dvb-scan.c b/lib/libdvbv5/dvb-scan.c
index 76712d4..9751f9d 100644
--- a/lib/libdvbv5/dvb-scan.c
+++ b/lib/libdvbv5/dvb-scan.c
@@ -96,6 +96,10 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,
uint8_t *buf = NULL;
uint8_t *tbl = NULL;
ssize_t table_length = 0;
+
+ // handle sections
+ int start_id = -1;
+ int start_section = -1;
int first_section = -1;
int last_section = -1;
int table_id = -1;
--
1.8.3.2
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH 05/13] libdvbv5: eit parsing updated
2013-12-28 15:45 [PATCH 01/13] libdvbv5: fix reading multisection tables André Roth
` (2 preceding siblings ...)
2013-12-28 15:45 ` [PATCH 04/13] libdvbv5: fix deadlock on missing table sections André Roth
@ 2013-12-28 15:45 ` André Roth
2013-12-29 3:40 ` Mauro Carvalho Chehab
2013-12-28 15:45 ` [PATCH 06/13] libdvbv5: fix eit times André Roth
` (8 subsequent siblings)
12 siblings, 1 reply; 26+ messages in thread
From: André Roth @ 2013-12-28 15:45 UTC (permalink / raw)
To: Linux Media Mailing List; +Cc: André Roth
Signed-off-by: André Roth <neolynx@gmail.com>
---
lib/include/descriptors.h | 6 ++++++
lib/include/descriptors/eit.h | 1 +
lib/include/dvb-fe.h | 2 ++
lib/libdvbv5/descriptors.c | 1 +
lib/libdvbv5/descriptors/eit.c | 28 +++++++++++++++++++++++-----
lib/libdvbv5/dvb-fe.c | 7 +++++++
lib/libdvbv5/dvb-scan.c | 22 +++++++---------------
7 files changed, 47 insertions(+), 20 deletions(-)
diff --git a/lib/include/descriptors.h b/lib/include/descriptors.h
index 5ab29a0..6f89aeb 100644
--- a/lib/include/descriptors.h
+++ b/lib/include/descriptors.h
@@ -63,7 +63,13 @@ struct dvb_desc {
} __attribute__((packed));
void dvb_desc_default_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, struct dvb_desc *desc);
+#ifdef __cplusplus
+extern "C" {
+#endif
void dvb_desc_default_print (struct dvb_v5_fe_parms *parms, const struct dvb_desc *desc);
+#ifdef __cplusplus
+}
+#endif
#define dvb_desc_foreach( _desc, _tbl ) \
for( struct dvb_desc *_desc = _tbl->descriptor; _desc; _desc = _desc->next ) \
diff --git a/lib/include/descriptors/eit.h b/lib/include/descriptors/eit.h
index 2af9696..d2ebdb4 100644
--- a/lib/include/descriptors/eit.h
+++ b/lib/include/descriptors/eit.h
@@ -56,6 +56,7 @@ struct dvb_table_eit_event {
struct dvb_table_eit_event *next;
struct tm start;
uint32_t duration;
+ uint16_t service_id;
} __attribute__((packed));
struct dvb_table_eit {
diff --git a/lib/include/dvb-fe.h b/lib/include/dvb-fe.h
index b0e2bf9..8cf2697 100644
--- a/lib/include/dvb-fe.h
+++ b/lib/include/dvb-fe.h
@@ -119,6 +119,8 @@ struct dvb_v5_fe_parms {
extern "C" {
#endif
+struct dvb_v5_fe_parms *dvb_fe_dummy();
+
struct dvb_v5_fe_parms *dvb_fe_open(int adapter, int frontend,
unsigned verbose, unsigned use_legacy_call);
struct dvb_v5_fe_parms *dvb_fe_open2(int adapter, int frontend,
diff --git a/lib/libdvbv5/descriptors.c b/lib/libdvbv5/descriptors.c
index 437b2f4..18884b0 100644
--- a/lib/libdvbv5/descriptors.c
+++ b/lib/libdvbv5/descriptors.c
@@ -69,6 +69,7 @@ void dvb_desc_default_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, st
void dvb_desc_default_print(struct dvb_v5_fe_parms *parms, const struct dvb_desc *desc)
{
+ if (!parms) parms = dvb_fe_dummy();
dvb_log("| %s (%#02x)", dvb_descriptors[desc->type].name, desc->type);
hexdump(parms, "| ", desc->data, desc->length);
}
diff --git a/lib/libdvbv5/descriptors/eit.c b/lib/libdvbv5/descriptors/eit.c
index ccfe1a6..d13b14c 100644
--- a/lib/libdvbv5/descriptors/eit.c
+++ b/lib/libdvbv5/descriptors/eit.c
@@ -29,6 +29,11 @@ void dvb_table_eit_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize
struct dvb_table_eit_event **head;
if (*table_length > 0) {
+ memcpy(eit, p, sizeof(struct dvb_table_eit) - sizeof(eit->event));
+
+ bswap16(eit->transport_id);
+ bswap16(eit->network_id);
+
/* find end of curent list */
head = &eit->event;
while (*head != NULL)
@@ -48,8 +53,18 @@ void dvb_table_eit_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize
struct dvb_table_eit_event *last = NULL;
while ((uint8_t *) p < buf + buflen - 4) {
struct dvb_table_eit_event *event = (struct dvb_table_eit_event *) malloc(sizeof(struct dvb_table_eit_event));
- memcpy(event, p, sizeof(struct dvb_table_eit_event) - sizeof(event->descriptor) - sizeof(event->next) - sizeof(event->start) - sizeof(event->duration));
- p += sizeof(struct dvb_table_eit_event) - sizeof(event->descriptor) - sizeof(event->next) - sizeof(event->start) - sizeof(event->duration);
+ memcpy(event, p, sizeof(struct dvb_table_eit_event) -
+ sizeof(event->descriptor) -
+ sizeof(event->next) -
+ sizeof(event->start) -
+ sizeof(event->duration) -
+ sizeof(event->service_id));
+ p += sizeof(struct dvb_table_eit_event) -
+ sizeof(event->descriptor) -
+ sizeof(event->next) -
+ sizeof(event->start) -
+ sizeof(event->duration) -
+ sizeof(event->service_id);
bswap16(event->event_id);
bswap16(event->bitfield);
@@ -57,9 +72,11 @@ void dvb_table_eit_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize
event->descriptor = NULL;
event->next = NULL;
dvb_time(event->dvbstart, &event->start);
- event->duration = bcd(event->dvbduration[0]) * 3600 +
- bcd(event->dvbduration[1]) * 60 +
- bcd(event->dvbduration[2]);
+ event->duration = bcd((uint32_t) event->dvbduration[0]) * 3600 +
+ bcd((uint32_t) event->dvbduration[1]) * 60 +
+ bcd((uint32_t) event->dvbduration[2]);
+
+ event->service_id = eit->header.id;
if(!*head)
*head = event;
@@ -102,6 +119,7 @@ void dvb_table_eit_print(struct dvb_v5_fe_parms *parms, struct dvb_table_eit *ei
char start[255];
strftime(start, sizeof(start), "%F %T", &event->start);
dvb_log("|- %7d", event->event_id);
+ dvb_log("| Service %d", event->service_id);
dvb_log("| Start %s UTC", start);
dvb_log("| Duration %dh %dm %ds", event->duration / 3600, (event->duration % 3600) / 60, event->duration % 60);
dvb_log("| free CA mode %d", event->free_CA_mode);
diff --git a/lib/libdvbv5/dvb-fe.c b/lib/libdvbv5/dvb-fe.c
index cc32ec0..4672267 100644
--- a/lib/libdvbv5/dvb-fe.c
+++ b/lib/libdvbv5/dvb-fe.c
@@ -35,6 +35,13 @@ static void dvb_v5_free(struct dvb_v5_fe_parms *parms)
free(parms);
}
+struct dvb_v5_fe_parms dummy_fe;
+struct dvb_v5_fe_parms *dvb_fe_dummy()
+{
+ dummy_fe.logfunc = dvb_default_log;
+ return &dummy_fe;
+}
+
struct dvb_v5_fe_parms *dvb_fe_open(int adapter, int frontend, unsigned verbose,
unsigned use_legacy_call)
{
diff --git a/lib/libdvbv5/dvb-scan.c b/lib/libdvbv5/dvb-scan.c
index 9751f9d..421434e 100644
--- a/lib/libdvbv5/dvb-scan.c
+++ b/lib/libdvbv5/dvb-scan.c
@@ -102,7 +102,7 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,
int start_section = -1;
int first_section = -1;
int last_section = -1;
- int table_id = -1;
+ /*int table_id = -1;*/
int sections = 0;
struct dmx_sct_filter_params f;
struct dvb_table_header *h;
@@ -112,7 +112,6 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,
*table = NULL;
// FIXME: verify known table
-
memset(&f, 0, sizeof(f));
f.pid = pid;
f.filter.filter[0] = tid;
@@ -202,21 +201,11 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,
continue;
}
- /*if (id != -1) {*/
- /*if (table_id == -1)*/
- /*table_id = h->id;*/
- /*else if (h->id != table_id) {*/
- /*dvb_logwarn("dvb_read_section: table ID mismatch reading multi section table: %d != %d", h->id, table_id);*/
- /*free(buf);*/
- /*continue;*/
- /*}*/
- /*}*/
-
- dvb_logerr("dvb_read_section: got section %d, last %di, filter %d", h->section_id, h->last_section, id );
+ /*dvb_logerr("dvb_read_section: got section %d, last %d, filter %d", h->section_id, h->last_section, id );*/
/* handle the sections */
if (first_section == -1)
first_section = h->section_id;
- else if (h->section_id == first_section)
+ else if (start_id == h->id && h->section_id == first_section)
break;
if (last_section == -1)
@@ -248,8 +237,11 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,
if (id != -1 && ++sections == last_section + 1) {
dvb_logerr("dvb_read_section: ++sections == last_section + 1");
break;
+ }
}
- free(buf);
+
+ if (buf)
+ free(buf);
dvb_dmx_stop(dmx_fd);
--
1.8.3.2
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH 06/13] libdvbv5: fix eit times
2013-12-28 15:45 [PATCH 01/13] libdvbv5: fix reading multisection tables André Roth
` (3 preceding siblings ...)
2013-12-28 15:45 ` [PATCH 05/13] libdvbv5: eit parsing updated André Roth
@ 2013-12-28 15:45 ` André Roth
2013-12-29 3:42 ` Mauro Carvalho Chehab
2013-12-28 15:45 ` [PATCH 07/13] libdvbv5: MGT parser André Roth
` (7 subsequent siblings)
12 siblings, 1 reply; 26+ messages in thread
From: André Roth @ 2013-12-28 15:45 UTC (permalink / raw)
To: Linux Media Mailing List; +Cc: André Roth
Signed-off-by: André Roth <neolynx@gmail.com>
---
lib/libdvbv5/descriptors/eit.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/lib/libdvbv5/descriptors/eit.c b/lib/libdvbv5/descriptors/eit.c
index d13b14c..e70cf3b 100644
--- a/lib/libdvbv5/descriptors/eit.c
+++ b/lib/libdvbv5/descriptors/eit.c
@@ -155,9 +155,8 @@ void dvb_time(const uint8_t data[5], struct tm *tm)
tm->tm_mday = day;
tm->tm_mon = month - 1;
tm->tm_year = year;
- tm->tm_isdst = -1;
- tm->tm_wday = 0;
- tm->tm_yday = 0;
+ tm->tm_isdst = 1; // dst in effect, do not adjust
+ mktime( tm );
}
--
1.8.3.2
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH 07/13] libdvbv5: MGT parser
2013-12-28 15:45 [PATCH 01/13] libdvbv5: fix reading multisection tables André Roth
` (4 preceding siblings ...)
2013-12-28 15:45 ` [PATCH 06/13] libdvbv5: fix eit times André Roth
@ 2013-12-28 15:45 ` André Roth
2013-12-29 3:49 ` Mauro Carvalho Chehab
2013-12-28 15:45 ` [PATCH 08/13] libdvbv5: ATSC EIT André Roth
` (6 subsequent siblings)
12 siblings, 1 reply; 26+ messages in thread
From: André Roth @ 2013-12-28 15:45 UTC (permalink / raw)
To: Linux Media Mailing List; +Cc: André Roth
Signed-off-by: André Roth <neolynx@gmail.com>
---
lib/include/descriptors/mgt.h | 82 ++++++++++++++++++++++++++++++
lib/libdvbv5/Makefile.am | 1 +
lib/libdvbv5/descriptors.c | 1 +
lib/libdvbv5/descriptors/mgt.c | 113 +++++++++++++++++++++++++++++++++++++++++
4 files changed, 197 insertions(+)
create mode 100644 lib/include/descriptors/mgt.h
create mode 100644 lib/libdvbv5/descriptors/mgt.c
diff --git a/lib/include/descriptors/mgt.h b/lib/include/descriptors/mgt.h
new file mode 100644
index 0000000..4a68f2c
--- /dev/null
+++ b/lib/include/descriptors/mgt.h
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2011-2012 - Mauro Carvalho Chehab <mchehab@redhat.com>
+ * 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 _MGT_H
+#define _MGT_H
+
+#include <stdint.h>
+#include <unistd.h> /* ssize_t */
+
+#include "descriptors/header.h"
+#include "descriptors.h"
+
+#define DVB_TABLE_MGT 0xC7
+
+struct dvb_table_mgt_table {
+ uint16_t type;
+ union {
+ uint16_t bitfield;
+ struct {
+ uint16_t pid:13;
+ uint16_t one:3;
+ } __attribute__((packed));
+ } __attribute__((packed));
+ uint8_t type_version:5;
+ uint8_t one2:3;
+ uint32_t size;
+ union {
+ uint16_t bitfield2;
+ struct {
+ uint16_t desc_length:12;
+ uint16_t one3:4;
+ } __attribute__((packed));
+ } __attribute__((packed));
+ struct dvb_desc *descriptor;
+ struct dvb_table_mgt_table *next;
+} __attribute__((packed));
+
+struct dvb_table_mgt {
+ struct dvb_table_header header;
+ uint8_t protocol_version;
+ uint16_t tables;
+ struct dvb_table_mgt_table *table;
+ struct dvb_desc *descriptor;
+} __attribute__((packed));
+
+
+#define dvb_mgt_transport_foreach( tran, mgt ) \
+ for( struct dvb_table_mgt_transport *tran = mgt->transport; tran; tran = tran->next ) \
+
+struct dvb_v5_fe_parms;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void dvb_table_mgt_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length);
+void dvb_table_mgt_free(struct dvb_table_mgt *mgt);
+void dvb_table_mgt_print(struct dvb_v5_fe_parms *parms, struct dvb_table_mgt *mgt);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/lib/libdvbv5/Makefile.am b/lib/libdvbv5/Makefile.am
index 795f30c..9d4b6b9 100644
--- a/lib/libdvbv5/Makefile.am
+++ b/lib/libdvbv5/Makefile.am
@@ -49,6 +49,7 @@ libdvbv5_la_SOURCES = \
descriptors/sdt.c ../include/descriptors/sdt.h \
descriptors/vct.c ../include/descriptors/vct.h \
descriptors/vct.c ../include/descriptors/vct.h \
+ descriptors/mgt.c ../include/descriptors/mgt.h \
descriptors/desc_service_location.c ../include/descriptors/desc_service_location.h \
descriptors/mpeg_ts.c ../include/descriptors/mpeg_ts.h \
descriptors/mpeg_pes.c ../include/descriptors/mpeg_pes.h \
diff --git a/lib/libdvbv5/descriptors.c b/lib/libdvbv5/descriptors.c
index 18884b0..bd1bc03 100644
--- a/lib/libdvbv5/descriptors.c
+++ b/lib/libdvbv5/descriptors.c
@@ -36,6 +36,7 @@
#include "descriptors/sdt.h"
#include "descriptors/eit.h"
#include "descriptors/vct.h"
+#include "descriptors/mgt.h"
#include "descriptors/desc_language.h"
#include "descriptors/desc_network_name.h"
#include "descriptors/desc_cable_delivery.h"
diff --git a/lib/libdvbv5/descriptors/mgt.c b/lib/libdvbv5/descriptors/mgt.c
new file mode 100644
index 0000000..272d9d7
--- /dev/null
+++ b/lib/libdvbv5/descriptors/mgt.c
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2011-2012 - Mauro Carvalho Chehab <mchehab@redhat.com>
+ * Copyright (c) 2012 - 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 "descriptors/mgt.h"
+#include "dvb-fe.h"
+
+void dvb_table_mgt_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length)
+{
+ const uint8_t *p = buf;
+ struct dvb_table_mgt *mgt = (struct dvb_table_mgt *) table;
+ struct dvb_desc **head_desc;
+ struct dvb_table_mgt_table **head;
+ /*int desc_length;*/
+
+ if (*table_length > 0) {
+ /* find end of curent lists */
+ head_desc = &mgt->descriptor;
+ while (*head_desc != NULL)
+ head_desc = &(*head_desc)->next;
+ head = &mgt->table;
+ while (*head != NULL)
+ head = &(*head)->next;
+ } else {
+ memcpy(table, p, sizeof(struct dvb_table_mgt) - sizeof(mgt->descriptor) - sizeof(mgt->table));
+ *table_length = sizeof(struct dvb_table_mgt);
+
+ mgt->descriptor = NULL;
+ mgt->table = NULL;
+ head_desc = &mgt->descriptor;
+ head = &mgt->table;
+ bswap16(mgt->tables);
+ }
+ p += sizeof(struct dvb_table_mgt) - sizeof(mgt->descriptor) - sizeof(mgt->table);
+
+ /*dvb_parse_descriptors(parms, p, desc_length, head_desc);*/
+ /*p += desc_length;*/
+ int i = 0;
+ struct dvb_table_mgt_table *last = NULL;
+ while (i++ < mgt->tables && (uint8_t *) p < buf + buflen - 4) {
+ struct dvb_table_mgt_table *table = (struct dvb_table_mgt_table *) malloc(sizeof(struct dvb_table_mgt_table));
+ memcpy(table, p, sizeof(struct dvb_table_mgt_table) - sizeof(table->descriptor) - sizeof(table->next));
+ p += sizeof(struct dvb_table_mgt_table) - sizeof(table->descriptor) - sizeof(table->next);
+
+ bswap16(table->type);
+ bswap16(table->bitfield);
+ bswap16(table->bitfield2);
+ bswap32(table->size);
+ table->descriptor = NULL;
+ table->next = NULL;
+
+ if(!*head)
+ *head = table;
+ if(last)
+ last->next = table;
+
+ /* get the descriptors for each table */
+ struct dvb_desc **head_desc = &table->descriptor;
+ dvb_parse_descriptors(parms, p, table->desc_length, head_desc);
+
+ p += table->desc_length;
+ last = table;
+ }
+}
+
+void dvb_table_mgt_free(struct dvb_table_mgt *mgt)
+{
+ struct dvb_table_mgt_table *table = mgt->table;
+ dvb_free_descriptors((struct dvb_desc **) &mgt->descriptor);
+ while(table) {
+ dvb_free_descriptors((struct dvb_desc **) &table->descriptor);
+ struct dvb_table_mgt_table *tmp = table;
+ table = table->next;
+ free(tmp);
+ }
+ free(mgt);
+}
+
+void dvb_table_mgt_print(struct dvb_v5_fe_parms *parms, struct dvb_table_mgt *mgt)
+{
+ dvb_log("MGT");
+ dvb_table_header_print(parms, &mgt->header);
+ dvb_log("| protocol_version %d", mgt->protocol_version);
+ dvb_log("| tables %d", mgt->tables);
+ /*dvb_print_descriptors(parms, mgt->descriptor);*/
+ const struct dvb_table_mgt_table *table = mgt->table;
+ uint16_t tables = 0;
+ while(table) {
+ dvb_log("|- type %04x %d", table->type, table->pid);
+ dvb_print_descriptors(parms, table->descriptor);
+ table = table->next;
+ tables++;
+ }
+ dvb_log("|_ %d tables", tables);
+}
+
--
1.8.3.2
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH 08/13] libdvbv5: ATSC EIT
2013-12-28 15:45 [PATCH 01/13] libdvbv5: fix reading multisection tables André Roth
` (5 preceding siblings ...)
2013-12-28 15:45 ` [PATCH 07/13] libdvbv5: MGT parser André Roth
@ 2013-12-28 15:45 ` André Roth
2013-12-29 3:58 ` Mauro Carvalho Chehab
2013-12-28 15:45 ` [PATCH 09/13] libdvbv5: fix section counting André Roth
` (5 subsequent siblings)
12 siblings, 1 reply; 26+ messages in thread
From: André Roth @ 2013-12-28 15:45 UTC (permalink / raw)
To: Linux Media Mailing List; +Cc: André Roth
Signed-off-by: André Roth <neolynx@gmail.com>
---
lib/include/descriptors/atsc_eit.h | 91 +++++++++++++++++++++
| 64 +++++++++++++++
lib/include/descriptors/mgt.h | 25 +++---
lib/include/descriptors/vct.h | 39 ++++-----
lib/include/dvb-scan.h | 2 +-
lib/libdvbv5/Makefile.am | 3 +
lib/libdvbv5/descriptors.c | 19 +++--
lib/libdvbv5/descriptors/atsc_eit.c | 143 +++++++++++++++++++++++++++++++++
| 48 +++++++++++
lib/libdvbv5/descriptors/eit.c | 2 +-
lib/libdvbv5/descriptors/mgt.c | 41 +++++-----
lib/libdvbv5/descriptors/vct.c | 39 +++++----
lib/libdvbv5/dvb-file.c | 2 +-
lib/libdvbv5/dvb-scan.c | 10 +--
14 files changed, 442 insertions(+), 86 deletions(-)
create mode 100644 lib/include/descriptors/atsc_eit.h
create mode 100644 lib/include/descriptors/atsc_header.h
create mode 100644 lib/libdvbv5/descriptors/atsc_eit.c
create mode 100644 lib/libdvbv5/descriptors/atsc_header.c
diff --git a/lib/include/descriptors/atsc_eit.h b/lib/include/descriptors/atsc_eit.h
new file mode 100644
index 0000000..ded7a64
--- /dev/null
+++ b/lib/include/descriptors/atsc_eit.h
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2011-2012 - Mauro Carvalho Chehab <mchehab@redhat.com>
+ * Copyright (c) 2012 - 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 _ATSC_EIT_H
+#define _ATSC_EIT_H
+
+#include <stdint.h>
+#include <unistd.h> /* ssize_t */
+#include <time.h>
+
+#include "descriptors/atsc_header.h"
+#include "descriptors.h"
+
+#define ATSC_TABLE_EIT 0xCB
+
+struct atsc_table_eit_event {
+ union {
+ uint16_t bitfield;
+ struct {
+ uint16_t event_id:14;
+ uint16_t one:2;
+ } __attribute__((packed));
+ } __attribute__((packed));
+ uint32_t start_time;
+ union {
+ uint32_t bitfield2;
+ struct {
+ uint32_t title_length:8;
+ uint32_t duration:20;
+ uint32_t etm:2;
+ uint32_t one2:2;
+ uint32_t :2;
+ } __attribute__((packed));
+ } __attribute__((packed));
+ struct dvb_desc *descriptor;
+ struct atsc_table_eit_event *next;
+ struct tm start;
+ uint16_t source_id;
+} __attribute__((packed));
+
+union atsc_table_eit_desc_length {
+ uint16_t bitfield;
+ struct {
+ uint16_t desc_length:12;
+ uint16_t reserved:4;
+ } __attribute__((packed));
+} __attribute__((packed));
+
+struct atsc_table_eit {
+ struct atsc_table_header header;
+ uint8_t events;
+ struct atsc_table_eit_event *event;
+} __attribute__((packed));
+
+#define atsc_eit_event_foreach(_event, _eit) \
+ for( struct atsc_table_eit_event *_event = _eit->event; _event; _event = _event->next ) \
+
+struct dvb_v5_fe_parms;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void atsc_table_eit_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length);
+void atsc_table_eit_free(struct atsc_table_eit *eit);
+void atsc_table_eit_print(struct dvb_v5_fe_parms *parms, struct atsc_table_eit *eit);
+void atsc_time(const uint32_t start_time, struct tm *tm);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--git a/lib/include/descriptors/atsc_header.h b/lib/include/descriptors/atsc_header.h
new file mode 100644
index 0000000..481d15f
--- /dev/null
+++ b/lib/include/descriptors/atsc_header.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2011-2012 - Mauro Carvalho Chehab <mchehab@redhat.com>
+ * Copyright (c) 2012 - 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 _ATSC_HEADER_H
+#define _ATSC_HEADER_H
+
+#include <stdint.h>
+#include <unistd.h> /* ssize_t */
+
+#define ATSC_BASE_PID 0x1FFB
+
+struct atsc_table_header {
+ uint8_t table_id;
+ union {
+ uint16_t bitfield;
+ struct {
+ uint16_t section_length:12;
+ uint16_t one:2;
+ uint16_t priv:1;
+ uint16_t syntax:1;
+ } __attribute__((packed));
+ };
+ uint16_t id;
+ uint8_t current_next:1;
+ uint8_t version:5;
+ uint8_t one2:2;
+
+ uint8_t section_id;
+ uint8_t last_section;
+ uint8_t protocol_version;
+} __attribute__((packed));
+
+struct dvb_v5_fe_parms;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int atsc_table_header_init (struct atsc_table_header *t);
+void atsc_table_header_print(struct dvb_v5_fe_parms *parms, const struct atsc_table_header *t);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/lib/include/descriptors/mgt.h b/lib/include/descriptors/mgt.h
index 4a68f2c..889d026 100644
--- a/lib/include/descriptors/mgt.h
+++ b/lib/include/descriptors/mgt.h
@@ -25,12 +25,12 @@
#include <stdint.h>
#include <unistd.h> /* ssize_t */
-#include "descriptors/header.h"
+#include "descriptors/atsc_header.h"
#include "descriptors.h"
-#define DVB_TABLE_MGT 0xC7
+#define ATSC_TABLE_MGT 0xC7
-struct dvb_table_mgt_table {
+struct atsc_table_mgt_table {
uint16_t type;
union {
uint16_t bitfield;
@@ -50,20 +50,19 @@ struct dvb_table_mgt_table {
} __attribute__((packed));
} __attribute__((packed));
struct dvb_desc *descriptor;
- struct dvb_table_mgt_table *next;
+ struct atsc_table_mgt_table *next;
} __attribute__((packed));
-struct dvb_table_mgt {
- struct dvb_table_header header;
- uint8_t protocol_version;
+struct atsc_table_mgt {
+ struct atsc_table_header header;
uint16_t tables;
- struct dvb_table_mgt_table *table;
+ struct atsc_table_mgt_table *table;
struct dvb_desc *descriptor;
} __attribute__((packed));
-#define dvb_mgt_transport_foreach( tran, mgt ) \
- for( struct dvb_table_mgt_transport *tran = mgt->transport; tran; tran = tran->next ) \
+#define dvb_mgt_table_foreach( tran, mgt ) \
+ for( struct dvb_table_mgt_table *tran = mgt->table; tran; tran = tran->next ) \
struct dvb_v5_fe_parms;
@@ -71,9 +70,9 @@ struct dvb_v5_fe_parms;
extern "C" {
#endif
-void dvb_table_mgt_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length);
-void dvb_table_mgt_free(struct dvb_table_mgt *mgt);
-void dvb_table_mgt_print(struct dvb_v5_fe_parms *parms, struct dvb_table_mgt *mgt);
+void atsc_table_mgt_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length);
+void atsc_table_mgt_free(struct atsc_table_mgt *mgt);
+void atsc_table_mgt_print(struct dvb_v5_fe_parms *parms, struct atsc_table_mgt *mgt);
#ifdef __cplusplus
}
diff --git a/lib/include/descriptors/vct.h b/lib/include/descriptors/vct.h
index 505a407..8afd0b8 100644
--- a/lib/include/descriptors/vct.h
+++ b/lib/include/descriptors/vct.h
@@ -25,25 +25,25 @@
#include <stdint.h>
#include <unistd.h> /* ssize_t */
-#include "descriptors/header.h"
+#include "descriptors/atsc_header.h"
#include "descriptors.h"
-#define DVB_TABLE_TVCT 0xc8
-#define DVB_TABLE_CVCT 0xc9
-#define DVB_TABLE_VCT_PID 0x1ffb
+#define ATSC_TABLE_TVCT 0xc8
+#define ATSC_TABLE_CVCT 0xc9
+#define ATSC_TABLE_VCT_PID 0x1ffb
-struct dvb_table_vct_channel {
+struct atsc_table_vct_channel {
uint16_t __short_name[7];
union {
- uint32_t bitfield;
+ uint32_t bitfield1;
struct {
uint32_t modulation_mode:8;
uint32_t minor_channel_number:10;
uint32_t major_channel_number:10;
uint32_t reserved1:4;
} __attribute__((packed));
- };
+ } __attribute__((packed));
uint32_t carrier_frequency;
uint16_t channel_tsid;
@@ -61,7 +61,8 @@ struct dvb_table_vct_channel {
uint16_t ETM_location:2;
} __attribute__((packed));
- };
+ } __attribute__((packed));
+
uint16_t source_id;
union {
uint16_t bitfield3;
@@ -69,22 +70,22 @@ struct dvb_table_vct_channel {
uint16_t descriptors_length:10;
uint16_t reserved3:6;
} __attribute__((packed));
- };
+ } __attribute__((packed));
/*
* Everything after descriptor (including it) won't be bit-mapped
* to the data parsed from the MPEG TS. So, metadata are added there
*/
struct dvb_desc *descriptor;
- struct dvb_table_vct_channel *next;
+ struct atsc_table_vct_channel *next;
/* The channel_short_name is converted to locale charset by vct.c */
char short_name[32];
} __attribute__((packed));
-struct dvb_table_vct {
- struct dvb_table_header header;
+struct atsc_table_vct {
+ struct atsc_table_header header;
uint8_t ATSC_protocol_version;
uint8_t num_channels_in_section;
@@ -93,12 +94,12 @@ struct dvb_table_vct {
* Everything after descriptor (including it) won't be bit-mapped
* to the data parsed from the MPEG TS. So, metadata are added there
*/
- struct dvb_table_vct_channel *channel;
+ struct atsc_table_vct_channel *channel;
struct dvb_desc *descriptor;
} __attribute__((packed));
-union dvb_table_vct_descriptor_length {
+union atsc_table_vct_descriptor_length {
uint16_t bitfield;
struct {
uint16_t descriptor_length:10;
@@ -106,8 +107,8 @@ union dvb_table_vct_descriptor_length {
};
};
-#define dvb_vct_channel_foreach(_channel, _vct) \
- for (struct dvb_table_vct_channel *_channel = _vct->channel; _channel; _channel = _channel->next) \
+#define atsc_vct_channel_foreach(_channel, _vct) \
+ for (struct atsc_table_vct_channel *_channel = _vct->channel; _channel; _channel = _channel->next) \
struct dvb_v5_fe_parms;
@@ -115,9 +116,9 @@ struct dvb_v5_fe_parms;
extern "C" {
#endif
-void dvb_table_vct_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length);
-void dvb_table_vct_free(struct dvb_table_vct *vct);
-void dvb_table_vct_print(struct dvb_v5_fe_parms *parms, struct dvb_table_vct *vct);
+void atsc_table_vct_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length);
+void atsc_table_vct_free(struct atsc_table_vct *vct);
+void atsc_table_vct_print(struct dvb_v5_fe_parms *parms, struct atsc_table_vct *vct);
#ifdef __cplusplus
}
diff --git a/lib/include/dvb-scan.h b/lib/include/dvb-scan.h
index b5dbfa9..9aef531 100644
--- a/lib/include/dvb-scan.h
+++ b/lib/include/dvb-scan.h
@@ -49,7 +49,7 @@ struct dvb_v5_descriptors {
unsigned num_entry;
struct dvb_table_pat *pat;
- struct dvb_table_vct *vct;
+ struct atsc_table_vct *vct;
struct dvb_v5_descriptors_program *program;
struct dvb_table_nit *nit;
struct dvb_table_sdt *sdt;
diff --git a/lib/libdvbv5/Makefile.am b/lib/libdvbv5/Makefile.am
index 9d4b6b9..368baf8 100644
--- a/lib/libdvbv5/Makefile.am
+++ b/lib/libdvbv5/Makefile.am
@@ -48,8 +48,11 @@ libdvbv5_la_SOURCES = \
descriptors/nit.c ../include/descriptors/nit.h \
descriptors/sdt.c ../include/descriptors/sdt.h \
descriptors/vct.c ../include/descriptors/vct.h \
+ descriptors/atsc_header.c ../include/descriptors/atsc_header.h \
descriptors/vct.c ../include/descriptors/vct.h \
descriptors/mgt.c ../include/descriptors/mgt.h \
+ descriptors/eit.c ../include/descriptors/eit.h \
+ descriptors/atsc_eit.c ../include/descriptors/atsc_eit.h \
descriptors/desc_service_location.c ../include/descriptors/desc_service_location.h \
descriptors/mpeg_ts.c ../include/descriptors/mpeg_ts.h \
descriptors/mpeg_pes.c ../include/descriptors/mpeg_pes.h \
diff --git a/lib/libdvbv5/descriptors.c b/lib/libdvbv5/descriptors.c
index bd1bc03..6df8b8b 100644
--- a/lib/libdvbv5/descriptors.c
+++ b/lib/libdvbv5/descriptors.c
@@ -37,6 +37,7 @@
#include "descriptors/eit.h"
#include "descriptors/vct.h"
#include "descriptors/mgt.h"
+#include "descriptors/atsc_eit.h"
#include "descriptors/desc_language.h"
#include "descriptors/desc_network_name.h"
#include "descriptors/desc_cable_delivery.h"
@@ -76,14 +77,16 @@ void dvb_desc_default_print(struct dvb_v5_fe_parms *parms, const struct dvb_desc
}
const struct dvb_table_init dvb_table_initializers[] = {
- [DVB_TABLE_PAT] = { dvb_table_pat_init, sizeof(struct dvb_table_pat) },
- [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) },
- [DVB_TABLE_EIT] = { dvb_table_eit_init, sizeof(struct dvb_table_eit) },
- [DVB_TABLE_TVCT] = { dvb_table_vct_init, sizeof(struct dvb_table_vct) },
- [DVB_TABLE_CVCT] = { dvb_table_vct_init, sizeof(struct dvb_table_vct) },
+ [DVB_TABLE_PAT] = { dvb_table_pat_init, sizeof(struct dvb_table_pat) },
+ [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) },
+ [DVB_TABLE_EIT] = { dvb_table_eit_init, sizeof(struct dvb_table_eit) },
[DVB_TABLE_EIT_SCHEDULE] = { dvb_table_eit_init, sizeof(struct dvb_table_eit) },
+ [ATSC_TABLE_TVCT] = { atsc_table_vct_init, sizeof(struct atsc_table_vct) },
+ [ATSC_TABLE_CVCT] = { atsc_table_vct_init, sizeof(struct atsc_table_vct) },
+ [ATSC_TABLE_MGT] = { atsc_table_mgt_init, sizeof(struct atsc_table_mgt) },
+ [ATSC_TABLE_EIT] = { atsc_table_eit_init, sizeof(struct atsc_table_eit) },
};
char *default_charset = "iso-8859-1";
@@ -1355,6 +1358,6 @@ void hexdump(struct dvb_v5_fe_parms *parms, const char *prefix, const unsigned c
for (i = strlen(hex); i < 49; i++)
strncat(spaces, " ", sizeof(spaces));
ascii[j] = '\0';
- dvb_log("%s%s %s %s", prefix, hex, spaces, ascii);
+ dvb_log("%s %s %s %s", prefix, hex, spaces, ascii);
}
}
diff --git a/lib/libdvbv5/descriptors/atsc_eit.c b/lib/libdvbv5/descriptors/atsc_eit.c
new file mode 100644
index 0000000..b827ecb
--- /dev/null
+++ b/lib/libdvbv5/descriptors/atsc_eit.c
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2011-2012 - Mauro Carvalho Chehab <mchehab@redhat.com>
+ * Copyright (c) 2012 - 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 "descriptors/atsc_eit.h"
+#include "dvb-fe.h"
+
+void atsc_table_eit_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length)
+{
+ const uint8_t *p = buf;
+ struct atsc_table_eit *eit = (struct atsc_table_eit *) table;
+ struct atsc_table_eit_event **head;
+
+ if (*table_length > 0) {
+ memcpy(eit, p, sizeof(struct atsc_table_eit) - sizeof(eit->event));
+
+ /* find end of curent list */
+ head = &eit->event;
+ while (*head != NULL)
+ head = &(*head)->next;
+ } else {
+ memcpy(eit, p, sizeof(struct atsc_table_eit) - sizeof(eit->event));
+ *table_length = sizeof(struct atsc_table_eit);
+
+ eit->event = NULL;
+ head = &eit->event;
+ }
+ p += sizeof(struct atsc_table_eit) - sizeof(eit->event);
+
+ hexdump(parms, "eit", p, 64 );
+
+ int i = 0;
+ struct atsc_table_eit_event *last = NULL;
+ while (i++ < eit->events && (uint8_t *) p < buf + buflen - 4) {
+ struct atsc_table_eit_event *event = (struct atsc_table_eit_event *) malloc(sizeof(struct atsc_table_eit_event));
+ memcpy(event, p, sizeof(struct atsc_table_eit_event) -
+ sizeof(event->descriptor) -
+ sizeof(event->next) -
+ sizeof(event->start) -
+ sizeof(event->source_id));
+ p += sizeof(struct atsc_table_eit_event) -
+ sizeof(event->descriptor) -
+ sizeof(event->next) -
+ sizeof(event->start) -
+ sizeof(event->source_id);
+
+ bswap16(event->bitfield);
+ bswap32(event->start_time);
+ bswap32(event->bitfield2);
+ event->descriptor = NULL;
+ event->next = NULL;
+ atsc_time(event->start_time, &event->start);
+ event->source_id = eit->header.id;
+
+ //FIXME: title
+ p += event->title_length - 1;
+
+ if(!*head)
+ *head = event;
+ if(last)
+ last->next = event;
+
+ /* get the descriptors for each program */
+ struct dvb_desc **head_desc = &event->descriptor;
+ union atsc_table_eit_desc_length dl = *(union atsc_table_eit_desc_length *) p;
+ bswap16(dl.bitfield);
+ p += sizeof(union atsc_table_eit_desc_length);
+ dvb_parse_descriptors(parms, p, dl.desc_length, head_desc);
+
+ p += dl.desc_length;
+ last = event;
+ }
+}
+
+void atsc_table_eit_free(struct atsc_table_eit *eit)
+{
+ struct atsc_table_eit_event *event = eit->event;
+ while (event) {
+ dvb_free_descriptors((struct dvb_desc **) &event->descriptor);
+ struct atsc_table_eit_event *tmp = event;
+ event = event->next;
+ free(tmp);
+ }
+ free(eit);
+}
+
+void atsc_table_eit_print(struct dvb_v5_fe_parms *parms, struct atsc_table_eit *eit)
+{
+ dvb_log("EIT");
+ atsc_table_header_print(parms, &eit->header);
+ const struct atsc_table_eit_event *event = eit->event;
+ uint16_t events = 0;
+ while (event) {
+ char start[255];
+ strftime(start, sizeof(start), "%F %T", &event->start);
+ dvb_log("|- event %7d", event->event_id);
+ dvb_log("| Source %d", event->source_id);
+ dvb_log("| Starttime %d", event->start_time);
+ dvb_log("| Start %s UTC", start);
+ dvb_log("| Duration %dh %dm %ds", event->duration / 3600, (event->duration % 3600) / 60, event->duration % 60);
+ dvb_log("| ETM %d", event->etm);
+ dvb_log("| title length %d", event->title_length);
+ dvb_print_descriptors(parms, event->descriptor);
+ event = event->next;
+ events++;
+ }
+ dvb_log("|_ %d events", events);
+}
+
+void atsc_time(const uint32_t start_time, struct tm *tm)
+{
+ tm->tm_sec = 0;
+ tm->tm_min = 0;
+ tm->tm_hour = 0;
+ tm->tm_mday = 6;
+ tm->tm_mon = 0;
+ tm->tm_year = 80;
+ tm->tm_isdst = -1;
+ tm->tm_wday = 0;
+ tm->tm_yday = 0;
+ mktime(tm);
+ tm->tm_sec += start_time;
+ mktime(tm);
+}
+
+
--git a/lib/libdvbv5/descriptors/atsc_header.c b/lib/libdvbv5/descriptors/atsc_header.c
new file mode 100644
index 0000000..7b31fa1
--- /dev/null
+++ b/lib/libdvbv5/descriptors/atsc_header.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2011-2012 - Mauro Carvalho Chehab <mchehab@redhat.com>
+ * Copyright (c) 2012 - 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 "descriptors/atsc_header.h"
+#include "descriptors.h"
+#include "dvb-fe.h"
+
+int atsc_table_header_init(struct atsc_table_header *t)
+{
+ bswap16(t->bitfield);
+ bswap16(t->id);
+ return 0;
+}
+
+void atsc_table_header_print(struct dvb_v5_fe_parms *parms, const struct atsc_table_header *t)
+{
+ dvb_log("| table_id %02x", t->table_id);
+ dvb_log("| section_length %d", t->section_length);
+ dvb_log("| syntax %d", t->syntax);
+ dvb_log("| priv %d", t->priv);
+ dvb_log("| one %d", t->one);
+ dvb_log("| id %d", t->id);
+ dvb_log("| one2 %d", t->one2);
+ dvb_log("| version %d", t->version);
+ dvb_log("| current_next %d", t->current_next);
+ dvb_log("| section_id %d", t->section_id);
+ dvb_log("| last_section %d", t->last_section);
+ dvb_log("| protocol_version %d", t->protocol_version);
+}
+
diff --git a/lib/libdvbv5/descriptors/eit.c b/lib/libdvbv5/descriptors/eit.c
index e70cf3b..5ecfc00 100644
--- a/lib/libdvbv5/descriptors/eit.c
+++ b/lib/libdvbv5/descriptors/eit.c
@@ -67,7 +67,7 @@ void dvb_table_eit_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize
sizeof(event->service_id);
bswap16(event->event_id);
- bswap16(event->bitfield);
+ bswap16(event->bitfield); // FIXME: needed?
bswap16(event->bitfield2);
event->descriptor = NULL;
event->next = NULL;
diff --git a/lib/libdvbv5/descriptors/mgt.c b/lib/libdvbv5/descriptors/mgt.c
index 272d9d7..b362d51 100644
--- a/lib/libdvbv5/descriptors/mgt.c
+++ b/lib/libdvbv5/descriptors/mgt.c
@@ -22,12 +22,12 @@
#include "descriptors/mgt.h"
#include "dvb-fe.h"
-void dvb_table_mgt_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length)
+void atsc_table_mgt_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length)
{
const uint8_t *p = buf;
- struct dvb_table_mgt *mgt = (struct dvb_table_mgt *) table;
+ struct atsc_table_mgt *mgt = (struct atsc_table_mgt *) table;
struct dvb_desc **head_desc;
- struct dvb_table_mgt_table **head;
+ struct atsc_table_mgt_table **head;
/*int desc_length;*/
if (*table_length > 0) {
@@ -39,8 +39,8 @@ void dvb_table_mgt_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize
while (*head != NULL)
head = &(*head)->next;
} else {
- memcpy(table, p, sizeof(struct dvb_table_mgt) - sizeof(mgt->descriptor) - sizeof(mgt->table));
- *table_length = sizeof(struct dvb_table_mgt);
+ memcpy(table, p, sizeof(struct atsc_table_mgt) - sizeof(mgt->descriptor) - sizeof(mgt->table));
+ *table_length = sizeof(struct atsc_table_mgt);
mgt->descriptor = NULL;
mgt->table = NULL;
@@ -48,16 +48,16 @@ void dvb_table_mgt_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize
head = &mgt->table;
bswap16(mgt->tables);
}
- p += sizeof(struct dvb_table_mgt) - sizeof(mgt->descriptor) - sizeof(mgt->table);
+ p += sizeof(struct atsc_table_mgt) - sizeof(mgt->descriptor) - sizeof(mgt->table);
/*dvb_parse_descriptors(parms, p, desc_length, head_desc);*/
/*p += desc_length;*/
int i = 0;
- struct dvb_table_mgt_table *last = NULL;
+ struct atsc_table_mgt_table *last = NULL;
while (i++ < mgt->tables && (uint8_t *) p < buf + buflen - 4) {
- struct dvb_table_mgt_table *table = (struct dvb_table_mgt_table *) malloc(sizeof(struct dvb_table_mgt_table));
- memcpy(table, p, sizeof(struct dvb_table_mgt_table) - sizeof(table->descriptor) - sizeof(table->next));
- p += sizeof(struct dvb_table_mgt_table) - sizeof(table->descriptor) - sizeof(table->next);
+ struct atsc_table_mgt_table *table = (struct atsc_table_mgt_table *) malloc(sizeof(struct atsc_table_mgt_table));
+ memcpy(table, p, sizeof(struct atsc_table_mgt_table) - sizeof(table->descriptor) - sizeof(table->next));
+ p += sizeof(struct atsc_table_mgt_table) - sizeof(table->descriptor) - sizeof(table->next);
bswap16(table->type);
bswap16(table->bitfield);
@@ -80,30 +80,35 @@ void dvb_table_mgt_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize
}
}
-void dvb_table_mgt_free(struct dvb_table_mgt *mgt)
+void atsc_table_mgt_free(struct atsc_table_mgt *mgt)
{
- struct dvb_table_mgt_table *table = mgt->table;
+ struct atsc_table_mgt_table *table = mgt->table;
dvb_free_descriptors((struct dvb_desc **) &mgt->descriptor);
while(table) {
dvb_free_descriptors((struct dvb_desc **) &table->descriptor);
- struct dvb_table_mgt_table *tmp = table;
+ struct atsc_table_mgt_table *tmp = table;
table = table->next;
free(tmp);
}
free(mgt);
}
-void dvb_table_mgt_print(struct dvb_v5_fe_parms *parms, struct dvb_table_mgt *mgt)
+void atsc_table_mgt_print(struct dvb_v5_fe_parms *parms, struct atsc_table_mgt *mgt)
{
dvb_log("MGT");
- dvb_table_header_print(parms, &mgt->header);
- dvb_log("| protocol_version %d", mgt->protocol_version);
+ atsc_table_header_print(parms, &mgt->header);
dvb_log("| tables %d", mgt->tables);
/*dvb_print_descriptors(parms, mgt->descriptor);*/
- const struct dvb_table_mgt_table *table = mgt->table;
+ const struct atsc_table_mgt_table *table = mgt->table;
uint16_t tables = 0;
while(table) {
- dvb_log("|- type %04x %d", table->type, table->pid);
+ dvb_log("|- type %04x %d", table->type, table->pid);
+ dvb_log("| one %d", table->one);
+ dvb_log("| one2 %d", table->one2);
+ dvb_log("| type version %d", table->type_version);
+ dvb_log("| size %d", table->size);
+ dvb_log("| one3 %d", table->one3);
+ dvb_log("| desc_length %d", table->desc_length);
dvb_print_descriptors(parms, table->descriptor);
table = table->next;
tables++;
diff --git a/lib/libdvbv5/descriptors/vct.c b/lib/libdvbv5/descriptors/vct.c
index e567f7a..493f184 100644
--- a/lib/libdvbv5/descriptors/vct.c
+++ b/lib/libdvbv5/descriptors/vct.c
@@ -23,14 +23,14 @@
#include "dvb-fe.h"
#include "parse_string.h"
-void dvb_table_vct_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
+void atsc_table_vct_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
ssize_t buflen, uint8_t *table, ssize_t *table_length)
{
const uint8_t *p = buf, *endbuf = buf + buflen - 4;
- struct dvb_table_vct *vct = (void *)table;
- struct dvb_table_vct_channel **head = &vct->channel;
+ struct atsc_table_vct *vct = (void *)table;
+ struct atsc_table_vct_channel **head = &vct->channel;
int i, n;
- size_t size = offsetof(struct dvb_table_vct, channel);
+ size_t size = offsetof(struct atsc_table_vct, channel);
if (p + size > endbuf) {
dvb_logerr("VCT table was truncated. Need %zu bytes, but has only %zu.",
@@ -45,16 +45,16 @@ void dvb_table_vct_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
} else {
memcpy(vct, p, size);
- *table_length = sizeof(struct dvb_table_vct);
+ *table_length = sizeof(struct atsc_table_vct);
vct->channel = NULL;
vct->descriptor = NULL;
}
p += size;
- size = offsetof(struct dvb_table_vct_channel, descriptor);
+ size = offsetof(struct atsc_table_vct_channel, descriptor);
for (n = 0; n < vct->num_channels_in_section; n++) {
- struct dvb_table_vct_channel *channel;
+ struct atsc_table_vct_channel *channel;
if (p + size > endbuf) {
dvb_logerr("VCT channel table is missing %d elements",
@@ -63,7 +63,7 @@ void dvb_table_vct_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
break;
}
- channel = malloc(sizeof(struct dvb_table_vct_channel));
+ channel = malloc(sizeof(struct atsc_table_vct_channel));
memcpy(channel, p, size);
p += size;
@@ -75,7 +75,7 @@ void dvb_table_vct_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
bswap32(channel->carrier_frequency);
bswap16(channel->channel_tsid);
bswap16(channel->program_number);
- bswap16(channel->bitfield1);
+ bswap32(channel->bitfield1);
bswap16(channel->bitfield2);
bswap16(channel->source_id);
bswap16(channel->bitfield3);
@@ -104,9 +104,9 @@ void dvb_table_vct_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
}
/* Get extra descriptors */
- size = sizeof(union dvb_table_vct_descriptor_length);
+ size = sizeof(union atsc_table_vct_descriptor_length);
while (p + size <= endbuf) {
- union dvb_table_vct_descriptor_length *d = (void *)p;
+ union atsc_table_vct_descriptor_length *d = (void *)p;
bswap16(d->descriptor_length);
p += size;
dvb_parse_descriptors(parms, p, d->descriptor_length,
@@ -117,12 +117,12 @@ void dvb_table_vct_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
endbuf - p);
}
-void dvb_table_vct_free(struct dvb_table_vct *vct)
+void atsc_table_vct_free(struct atsc_table_vct *vct)
{
- struct dvb_table_vct_channel *channel = vct->channel;
+ struct atsc_table_vct_channel *channel = vct->channel;
while(channel) {
dvb_free_descriptors((struct dvb_desc **) &channel->descriptor);
- struct dvb_table_vct_channel *tmp = channel;
+ struct atsc_table_vct_channel *tmp = channel;
channel = channel->next;
free(tmp);
}
@@ -131,19 +131,19 @@ void dvb_table_vct_free(struct dvb_table_vct *vct)
free(vct);
}
-void dvb_table_vct_print(struct dvb_v5_fe_parms *parms, struct dvb_table_vct *vct)
+void atsc_table_vct_print(struct dvb_v5_fe_parms *parms, struct atsc_table_vct *vct)
{
- if (vct->header.table_id == DVB_TABLE_CVCT)
+ if (vct->header.table_id == ATSC_TABLE_CVCT)
dvb_log("CVCT");
else
dvb_log("TVCT");
- dvb_table_header_print(parms, &vct->header);
+ atsc_table_header_print(parms, &vct->header);
dvb_log("|- Protocol version %d", vct->ATSC_protocol_version);
dvb_log("|- #channels %d", vct->num_channels_in_section);
dvb_log("|\\ channel_id");
- const struct dvb_table_vct_channel *channel = vct->channel;
+ const struct atsc_table_vct_channel *channel = vct->channel;
uint16_t channels = 0;
while(channel) {
dvb_log("|- Channel %d.%d: %s",
@@ -159,7 +159,7 @@ void dvb_table_vct_print(struct dvb_v5_fe_parms *parms, struct dvb_table_vct *vc
dvb_log("| access controlled %d", channel->access_controlled);
dvb_log("| hidden %d", channel->hidden);
- if (vct->header.table_id == DVB_TABLE_CVCT) {
+ if (vct->header.table_id == ATSC_TABLE_CVCT) {
dvb_log("| path select %d", channel->path_select);
dvb_log("| out of band %d", channel->out_of_band);
}
@@ -173,4 +173,3 @@ void dvb_table_vct_print(struct dvb_v5_fe_parms *parms, struct dvb_table_vct *vc
}
dvb_log("|_ %d channels", channels);
}
-
diff --git a/lib/libdvbv5/dvb-file.c b/lib/libdvbv5/dvb-file.c
index b6fdc04..9abb1f7 100644
--- a/lib/libdvbv5/dvb-file.c
+++ b/lib/libdvbv5/dvb-file.c
@@ -1027,7 +1027,7 @@ int store_dvb_channel(struct dvb_file **dvb_file,
}
if (dvb_scan_handler->vct) {
- dvb_vct_channel_foreach(d, dvb_scan_handler->vct) {
+ atsc_vct_channel_foreach(d, dvb_scan_handler->vct) {
char *channel = NULL;
char *vchannel = NULL;
diff --git a/lib/libdvbv5/dvb-scan.c b/lib/libdvbv5/dvb-scan.c
index 421434e..bd9d2fb 100644
--- a/lib/libdvbv5/dvb-scan.c
+++ b/lib/libdvbv5/dvb-scan.c
@@ -271,7 +271,7 @@ void dvb_scan_free_handler_table(struct dvb_v5_descriptors *dvb_scan_handler)
if (dvb_scan_handler->pat)
dvb_table_pat_free(dvb_scan_handler->pat);
if (dvb_scan_handler->vct)
- dvb_table_vct_free(dvb_scan_handler->vct);
+ atsc_table_vct_free(dvb_scan_handler->vct);
if (dvb_scan_handler->nit)
dvb_table_nit_free(dvb_scan_handler->nit);
if (dvb_scan_handler->sdt)
@@ -329,14 +329,14 @@ struct dvb_v5_descriptors *dvb_get_ts_tables(struct dvb_v5_fe_parms *parms,
nit_time = 12;
break;
case SYS_ATSC:
- atsc_filter = DVB_TABLE_TVCT;
+ atsc_filter = ATSC_TABLE_TVCT;
pat_pmt_time = 2;
vct_time = 2;
sdt_time = 5;
nit_time = 5;
break;
case SYS_DVBC_ANNEX_B:
- atsc_filter = DVB_TABLE_CVCT;
+ atsc_filter = ATSC_TABLE_CVCT;
pat_pmt_time = 2;
vct_time = 2;
sdt_time = 5;
@@ -367,7 +367,7 @@ struct dvb_v5_descriptors *dvb_get_ts_tables(struct dvb_v5_fe_parms *parms,
/* ATSC-specific VCT table */
if (atsc_filter) {
rc = dvb_read_section(parms, dmx_fd,
- atsc_filter, DVB_TABLE_VCT_PID,
+ atsc_filter, ATSC_TABLE_VCT_PID,
(uint8_t **)&dvb_scan_handler->vct,
vct_time * timeout_multiply);
if (parms->abort)
@@ -375,7 +375,7 @@ struct dvb_v5_descriptors *dvb_get_ts_tables(struct dvb_v5_fe_parms *parms,
if (rc < 0)
dvb_logerr("error while waiting for VCT table");
else if (parms->verbose)
- dvb_table_vct_print(parms, dvb_scan_handler->vct);
+ atsc_table_vct_print(parms, dvb_scan_handler->vct);
}
/* PMT tables */
--
1.8.3.2
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH 09/13] libdvbv5: fix section counting
2013-12-28 15:45 [PATCH 01/13] libdvbv5: fix reading multisection tables André Roth
` (6 preceding siblings ...)
2013-12-28 15:45 ` [PATCH 08/13] libdvbv5: ATSC EIT André Roth
@ 2013-12-28 15:45 ` André Roth
2013-12-29 3:42 ` Mauro Carvalho Chehab
2013-12-28 15:45 ` [PATCH 10/13] libdvbv5: cleanup coding style André Roth
` (4 subsequent siblings)
12 siblings, 1 reply; 26+ messages in thread
From: André Roth @ 2013-12-28 15:45 UTC (permalink / raw)
To: Linux Media Mailing List; +Cc: André Roth
Signed-off-by: André Roth <neolynx@gmail.com>
---
lib/libdvbv5/dvb-scan.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/libdvbv5/dvb-scan.c b/lib/libdvbv5/dvb-scan.c
index bd9d2fb..6f3def6 100644
--- a/lib/libdvbv5/dvb-scan.c
+++ b/lib/libdvbv5/dvb-scan.c
@@ -208,7 +208,7 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,
else if (start_id == h->id && h->section_id == first_section)
break;
- if (last_section == -1)
+ if (last_section == -1 || h->last_section > last_section)
last_section = h->last_section;
if (!tbl) {
--
1.8.3.2
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH 10/13] libdvbv5: cleanup coding style
2013-12-28 15:45 [PATCH 01/13] libdvbv5: fix reading multisection tables André Roth
` (7 preceding siblings ...)
2013-12-28 15:45 ` [PATCH 09/13] libdvbv5: fix section counting André Roth
@ 2013-12-28 15:45 ` André Roth
2013-12-29 3:44 ` Mauro Carvalho Chehab
2013-12-28 15:45 ` [PATCH 11/13] libdvbv5: fix double entry in Makefile.am André Roth
` (3 subsequent siblings)
12 siblings, 1 reply; 26+ messages in thread
From: André Roth @ 2013-12-28 15:45 UTC (permalink / raw)
To: Linux Media Mailing List; +Cc: André Roth
Signed-off-by: André Roth <neolynx@gmail.com>
---
lib/libdvbv5/descriptors.c | 2 +-
lib/libdvbv5/descriptors/mpeg_pes.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/libdvbv5/descriptors.c b/lib/libdvbv5/descriptors.c
index 6df8b8b..b5bc9b2 100644
--- a/lib/libdvbv5/descriptors.c
+++ b/lib/libdvbv5/descriptors.c
@@ -1358,6 +1358,6 @@ void hexdump(struct dvb_v5_fe_parms *parms, const char *prefix, const unsigned c
for (i = strlen(hex); i < 49; i++)
strncat(spaces, " ", sizeof(spaces));
ascii[j] = '\0';
- dvb_log("%s %s %s %s", prefix, hex, spaces, ascii);
+ dvb_log("%s%s %s %s", prefix, hex, spaces, ascii);
}
}
diff --git a/lib/libdvbv5/descriptors/mpeg_pes.c b/lib/libdvbv5/descriptors/mpeg_pes.c
index c717297..0f0cde0 100644
--- a/lib/libdvbv5/descriptors/mpeg_pes.c
+++ b/lib/libdvbv5/descriptors/mpeg_pes.c
@@ -33,7 +33,7 @@ void dvb_mpeg_pes_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_
bswap32(pes->bitfield);
bswap16(pes->length);
- if (pes->sync != 0x000001 ) {
+ if (pes->sync != 0x000001) {
dvb_logerr("mpeg pes invalid");
return;
}
--
1.8.3.2
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH 11/13] libdvbv5: fix double entry in Makefile.am
2013-12-28 15:45 [PATCH 01/13] libdvbv5: fix reading multisection tables André Roth
` (8 preceding siblings ...)
2013-12-28 15:45 ` [PATCH 10/13] libdvbv5: cleanup coding style André Roth
@ 2013-12-28 15:45 ` André Roth
2013-12-29 3:45 ` Mauro Carvalho Chehab
2013-12-28 15:46 ` [PATCH 12/13] libdvbv5: fix missing includes André Roth
` (2 subsequent siblings)
12 siblings, 1 reply; 26+ messages in thread
From: André Roth @ 2013-12-28 15:45 UTC (permalink / raw)
To: Linux Media Mailing List; +Cc: André Roth
Signed-off-by: André Roth <neolynx@gmail.com>
---
lib/libdvbv5/Makefile.am | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/lib/libdvbv5/Makefile.am b/lib/libdvbv5/Makefile.am
index 368baf8..dc5005f 100644
--- a/lib/libdvbv5/Makefile.am
+++ b/lib/libdvbv5/Makefile.am
@@ -47,7 +47,6 @@ libdvbv5_la_SOURCES = \
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 \
descriptors/atsc_header.c ../include/descriptors/atsc_header.h \
descriptors/vct.c ../include/descriptors/vct.h \
descriptors/mgt.c ../include/descriptors/mgt.h \
@@ -58,7 +57,7 @@ libdvbv5_la_SOURCES = \
descriptors/mpeg_pes.c ../include/descriptors/mpeg_pes.h \
descriptors/mpeg_es.c ../include/descriptors/mpeg_es.h
-libdvbv5_la_CPPFLAGS = $(ENFORCE_LIBDVBV5_STATIC)
+libdvbv5_la_CPPFLAGS = $(ENFORCE_LIBDVBV5_STATIC) -std=c99
libdvbv5_la_LDFLAGS = $(LIBDVBV5_VERSION) $(ENFORCE_LIBDVBV5_STATIC) -lm
libdvbv5_la_LIBADD = $(LTLIBICONV)
--
1.8.3.2
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH 12/13] libdvbv5: fix missing includes
2013-12-28 15:45 [PATCH 01/13] libdvbv5: fix reading multisection tables André Roth
` (9 preceding siblings ...)
2013-12-28 15:45 ` [PATCH 11/13] libdvbv5: fix double entry in Makefile.am André Roth
@ 2013-12-28 15:46 ` André Roth
2013-12-29 3:44 ` Mauro Carvalho Chehab
2013-12-28 15:46 ` [PATCH 13/13] libdvbv5: improve TS parsing André Roth
2013-12-29 2:53 ` [PATCH 01/13] libdvbv5: fix reading multisection tables Mauro Carvalho Chehab
12 siblings, 1 reply; 26+ messages in thread
From: André Roth @ 2013-12-28 15:46 UTC (permalink / raw)
To: Linux Media Mailing List; +Cc: André Roth
Signed-off-by: André Roth <neolynx@gmail.com>
---
lib/libdvbv5/dvb-file.c | 1 +
lib/libdvbv5/dvb-sat.c | 1 +
lib/libdvbv5/dvb-scan.c | 1 +
lib/libdvbv5/parse_string.c | 1 +
4 files changed, 4 insertions(+)
diff --git a/lib/libdvbv5/dvb-file.c b/lib/libdvbv5/dvb-file.c
index 9abb1f7..d5b00e2 100644
--- a/lib/libdvbv5/dvb-file.c
+++ b/lib/libdvbv5/dvb-file.c
@@ -21,6 +21,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <strings.h> // strcasecmp
#include <unistd.h>
#include "dvb-file.h"
diff --git a/lib/libdvbv5/dvb-sat.c b/lib/libdvbv5/dvb-sat.c
index 3cbcf03..c35e3d7 100644
--- a/lib/libdvbv5/dvb-sat.c
+++ b/lib/libdvbv5/dvb-sat.c
@@ -21,6 +21,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include <strings.h> // strcasecmp
#include "dvb-fe.h"
#include "dvb-v5-std.h"
diff --git a/lib/libdvbv5/dvb-scan.c b/lib/libdvbv5/dvb-scan.c
index 6f3def6..d0f0b39 100644
--- a/lib/libdvbv5/dvb-scan.c
+++ b/lib/libdvbv5/dvb-scan.c
@@ -35,6 +35,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <stdlib.h>
+#include <sys/time.h>
#include "dvb-scan.h"
#include "dvb-frontend.h"
diff --git a/lib/libdvbv5/parse_string.c b/lib/libdvbv5/parse_string.c
index f7b745e..8bd56f3 100644
--- a/lib/libdvbv5/parse_string.c
+++ b/lib/libdvbv5/parse_string.c
@@ -27,6 +27,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <strings.h> // strcasecmp
#include "parse_string.h"
#include "dvb-log.h"
--
1.8.3.2
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH 13/13] libdvbv5: improve TS parsing
2013-12-28 15:45 [PATCH 01/13] libdvbv5: fix reading multisection tables André Roth
` (10 preceding siblings ...)
2013-12-28 15:46 ` [PATCH 12/13] libdvbv5: fix missing includes André Roth
@ 2013-12-28 15:46 ` André Roth
2013-12-29 3:47 ` Mauro Carvalho Chehab
2013-12-29 2:53 ` [PATCH 01/13] libdvbv5: fix reading multisection tables Mauro Carvalho Chehab
12 siblings, 1 reply; 26+ messages in thread
From: André Roth @ 2013-12-28 15:46 UTC (permalink / raw)
To: Linux Media Mailing List; +Cc: André Roth
Signed-off-by: André Roth <neolynx@gmail.com>
---
lib/include/descriptors/mpeg_ts.h | 4 ++--
lib/libdvbv5/descriptors/mpeg_ts.c | 11 ++++++++---
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/lib/include/descriptors/mpeg_ts.h b/lib/include/descriptors/mpeg_ts.h
index 2bb570b..f332a58 100644
--- a/lib/include/descriptors/mpeg_ts.h
+++ b/lib/include/descriptors/mpeg_ts.h
@@ -39,7 +39,7 @@ struct dvb_mpeg_ts_adaption {
uint8_t random_access:1;
uint8_t discontinued:1;
} __attribute__((packed));
-
+ uint8_t data[];
} __attribute__((packed));
struct dvb_mpeg_ts {
@@ -68,7 +68,7 @@ struct dvb_v5_fe_parms;
extern "C" {
#endif
-void dvb_mpeg_ts_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length);
+ssize_t dvb_mpeg_ts_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length);
void dvb_mpeg_ts_free(struct dvb_mpeg_ts *ts);
void dvb_mpeg_ts_print(struct dvb_v5_fe_parms *parms, struct dvb_mpeg_ts *ts);
diff --git a/lib/libdvbv5/descriptors/mpeg_ts.c b/lib/libdvbv5/descriptors/mpeg_ts.c
index c1d1293..e55f590 100644
--- a/lib/libdvbv5/descriptors/mpeg_ts.c
+++ b/lib/libdvbv5/descriptors/mpeg_ts.c
@@ -22,27 +22,32 @@
#include "descriptors.h"
#include "dvb-fe.h"
-void dvb_mpeg_ts_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length)
+ssize_t dvb_mpeg_ts_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length)
{
if (buf[0] != DVB_MPEG_TS) {
dvb_logerr("mpeg ts invalid marker %#02x, sould be %#02x", buf[0], DVB_MPEG_TS);
*table_length = 0;
- return;
+ return 0;
}
+ ssize_t bytes_read = 0;
struct dvb_mpeg_ts *ts = (struct dvb_mpeg_ts *) table;
const uint8_t *p = buf;
memcpy(table, p, sizeof(struct dvb_mpeg_ts));
p += sizeof(struct dvb_mpeg_ts);
+ bytes_read += sizeof(struct dvb_mpeg_ts);
*table_length = sizeof(struct dvb_mpeg_ts);
bswap16(ts->bitfield);
if (ts->adaptation_field & 0x2) {
memcpy(table + *table_length, p, sizeof(struct dvb_mpeg_ts_adaption));
- p += sizeof(struct dvb_mpeg_ts);
+ p += sizeof(struct dvb_mpeg_ts_adaption);
+ bytes_read += sizeof(struct dvb_mpeg_ts_adaption);
*table_length += ts->adaption->length + 1;
+ // FIXME: copy adaption->lenght bytes
}
/*hexdump(parms, "TS: ", buf, buflen);*/
+ return bytes_read;
}
void dvb_mpeg_ts_free(struct dvb_mpeg_ts *ts)
--
1.8.3.2
^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [PATCH 01/13] libdvbv5: fix reading multisection tables
2013-12-28 15:45 [PATCH 01/13] libdvbv5: fix reading multisection tables André Roth
` (11 preceding siblings ...)
2013-12-28 15:46 ` [PATCH 13/13] libdvbv5: improve TS parsing André Roth
@ 2013-12-29 2:53 ` Mauro Carvalho Chehab
12 siblings, 0 replies; 26+ messages in thread
From: Mauro Carvalho Chehab @ 2013-12-29 2:53 UTC (permalink / raw)
To: André Roth; +Cc: Linux Media Mailing List
Em Sat, 28 Dec 2013 16:45:49 +0100
André Roth <neolynx@gmail.com> escreveu:
> Signed-off-by: André Roth <neolynx@gmail.com>
> ---
> lib/libdvbv5/dvb-scan.c | 18 +++++++++++-------
> 1 file changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/lib/libdvbv5/dvb-scan.c b/lib/libdvbv5/dvb-scan.c
> index e9ccc72..af3a052 100644
> --- a/lib/libdvbv5/dvb-scan.c
> +++ b/lib/libdvbv5/dvb-scan.c
> @@ -187,15 +187,19 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,
> dvb_table_header_init(h);
> if (id != -1 && h->id != id) { /* search for a specific table id */
> continue;
> - } else {
> - if (table_id == -1)
> - table_id = h->id;
> - else if (h->id != table_id) {
> - dvb_logwarn("dvb_read_section: table ID mismatch reading multi section table: %d != %d", h->id, table_id);
> - continue;
> - }
> }
>
> + /*if (id != -1) {*/
> + /*if (table_id == -1)*/
> + /*table_id = h->id;*/
> + /*else if (h->id != table_id) {*/
> + /*dvb_logwarn("dvb_read_section: table ID mismatch reading multi section table: %d != %d", h->id, table_id);*/
> + /*free(buf);*/
> + /*continue;*/
> + /*}*/
> + /*}*/
> +
Could you please better describe this patch? What but is it supposed to
fix?
If this is a bug fix, why are you commenting all lines instead of dropping?
> + dvb_logerr("dvb_read_section: got section %d, last %di, filter %d", h->section_id, h->last_section, id );
> /* handle the sections */
> if (first_section == -1)
> first_section = h->section_id;
--
Cheers,
Mauro
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 02/13] libdvbv5: ATSC VCT table support
2013-12-28 15:45 ` [PATCH 02/13] libdvbv5: ATSC VCT table support André Roth
@ 2013-12-29 3:04 ` Mauro Carvalho Chehab
0 siblings, 0 replies; 26+ messages in thread
From: Mauro Carvalho Chehab @ 2013-12-29 3:04 UTC (permalink / raw)
To: André Roth; +Cc: Linux Media Mailing List
Em Sat, 28 Dec 2013 16:45:50 +0100
André Roth <neolynx@gmail.com> escreveu:
> Signed-off-by: André Roth <neolynx@gmail.com>
> ---
> lib/include/descriptors.h | 4 +-
> lib/include/descriptors/desc_service_location.h | 70 +++++++++++++++++++++++
> lib/include/descriptors/vct.h | 5 +-
> lib/libdvbv5/Makefile.am | 3 +-
> lib/libdvbv5/descriptors.c | 2 +-
> lib/libdvbv5/descriptors/desc_service_location.c | 71 ++++++++++++++++++++++++
> lib/libdvbv5/descriptors/vct.c | 1 +
> lib/libdvbv5/dvb-scan.c | 12 +++-
> 8 files changed, 162 insertions(+), 6 deletions(-)
> 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 2e614f0..5ab29a0 100644
> --- a/lib/include/descriptors.h
> +++ b/lib/include/descriptors.h
> @@ -1,4 +1,4 @@
> - /*
> +/*
> * Copyright (c) 2011-2012 - Mauro Carvalho Chehab <mchehab@redhat.com>
> *
> * This program is free software; you can redistribute it and/or
> @@ -216,6 +216,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..2e11cff
> --- /dev/null
> +++ b/lib/include/descriptors/desc_service_location.h
> @@ -0,0 +1,70 @@
> +/*
> + * Copyright (c) 2011-2012 - Mauro Carvalho Chehab <mchehab@redhat.com>
I didn't wrote this code...
> + * Copyright (c) 2012 - 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 _SERVICE_LOCATION_H
> +#define _SERVICE_LOCATION_H
> +
> +#include <stdint.h>
> +#include <unistd.h> /* ssize_t */
> +
> +struct dvb_desc_service_location_element {
> + uint8_t stream_type;
> + union {
> + uint16_t bitfield;
> + struct {
> + uint16_t elementary_pid:13;
> + uint16_t reserved:3;
> + };
> + };
> + 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;
> + };
> + };
> + 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/include/descriptors/vct.h b/lib/include/descriptors/vct.h
> index 6272b43..505a407 100644
> --- a/lib/include/descriptors/vct.h
> +++ b/lib/include/descriptors/vct.h
> @@ -1,5 +1,6 @@
> /*
> - * Copyright (c) 2013 - Mauro Carvalho Chehab <m.chehab@samsung.com>
...but I wrote this one. Please don't remove my copyright here.
> + * Copyright (c) 2012 - Andre Roth <neolynx@gmail.com>
> + * 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
> @@ -35,7 +36,7 @@ struct dvb_table_vct_channel {
> uint16_t __short_name[7];
>
> union {
> - uint16_t bitfield1;
> + uint32_t bitfield;
> struct {
> uint32_t modulation_mode:8;
> uint32_t minor_channel_number:10;
Huh? You're adding your copyright just due to this one line trival change?
> diff --git a/lib/libdvbv5/Makefile.am b/lib/libdvbv5/Makefile.am
> index 2ad5902..400af39 100644
> --- a/lib/libdvbv5/Makefile.am
> +++ b/lib/libdvbv5/Makefile.am
> @@ -48,7 +48,8 @@ libdvbv5_la_SOURCES = \
> descriptors/nit.c ../include/descriptors/nit.h \
> descriptors/sdt.c ../include/descriptors/sdt.h \
> descriptors/vct.c ../include/descriptors/vct.h \
> - descriptors/eit.c ../include/descriptors/eit.h
> + descriptors/vct.c ../include/descriptors/vct.h \
> + descriptors/desc_service_location.c ../include/descriptors/desc_service_location.h
>
> libdvbv5_la_CPPFLAGS = $(ENFORCE_LIBDVBV5_STATIC)
> libdvbv5_la_LDFLAGS = $(LIBDVBV5_VERSION) $(ENFORCE_LIBDVBV5_STATIC) -lm
> diff --git a/lib/libdvbv5/descriptors.c b/lib/libdvbv5/descriptors.c
> index 5ce9241..437b2f4 100644
> --- a/lib/libdvbv5/descriptors.c
> +++ b/lib/libdvbv5/descriptors.c
> @@ -69,7 +69,7 @@ void dvb_desc_default_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, st
>
> void dvb_desc_default_print(struct dvb_v5_fe_parms *parms, const struct dvb_desc *desc)
> {
> - dvb_log("| %s (0x%02x)", dvb_descriptors[desc->type].name, desc->type);
> + dvb_log("| %s (%#02x)", dvb_descriptors[desc->type].name, desc->type);
> hexdump(parms, "| ", desc->data, desc->length);
> }
>
> diff --git a/lib/libdvbv5/descriptors/desc_service_location.c b/lib/libdvbv5/descriptors/desc_service_location.c
> new file mode 100644
> index 0000000..94c34fa
> --- /dev/null
> +++ b/lib/libdvbv5/descriptors/desc_service_location.c
> @@ -0,0 +1,71 @@
> +/*
> + * Copyright (c) 2011-2012 - Mauro Carvalho Chehab <mchehab@redhat.com>
Again, I didn't write this parser. No need to add my copyright to it.
> + * Copyright (c) 2012 - 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 "descriptors/desc_service_location.h"
> +#include "descriptors.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;
Please add a space here, to split data declaration from code.
> + /* copy from .next */
> + memcpy(((uint8_t *) service_location )
> + + sizeof(service_location->type)
> + + sizeof(service_location->length)
> + + sizeof(service_location->next),
> + buf,
> + sizeof(service_location->bitfield) + sizeof(service_location->elements));
Before copying any data, please verify if are there enough data at the TS
stream.
Take a look on the patches I wrote, since I fixed several such issues
already.
> + buf += sizeof(service_location->bitfield) + sizeof(service_location->elements);
> +
> + bswap16(service_location->bitfield);
> +
> + // FIXME: handle elements == 0
Don't use CC99 comments.
> + service_location->element = malloc(service_location->elements * sizeof(struct dvb_desc_service_location_element));
> + int i;
> + struct dvb_desc_service_location_element *element = service_location->element;
Please don't mix data initialization with code. Move the above to the
beginning of the function.
> + for(i = 0; i < service_location->elements; i++) {
> + memcpy(element, buf, sizeof(struct dvb_desc_service_location_element) - 1); /* no \0 in lang */
Again, please check before copy.
> + 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;
> + dvb_log("| pcr pid %d", service_location->pcr_pid);
> + dvb_log("| streams:");
> + int i;
> + struct dvb_desc_service_location_element *element = service_location->element;
Don't mix code with data.
> + 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;
Add a blank line to split data declarations from code.
> + free(service_location->element);
> +}
> +
> diff --git a/lib/libdvbv5/descriptors/vct.c b/lib/libdvbv5/descriptors/vct.c
> index e703c52..e567f7a 100644
> --- a/lib/libdvbv5/descriptors/vct.c
> +++ b/lib/libdvbv5/descriptors/vct.c
> @@ -1,5 +1,6 @@
> /*
> * Copyright (c) 2013 - Mauro Carvalho Chehab <m.chehab@samsung.com>
> + * 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
> diff --git a/lib/libdvbv5/dvb-scan.c b/lib/libdvbv5/dvb-scan.c
> index af3a052..76712d4 100644
> --- a/lib/libdvbv5/dvb-scan.c
> +++ b/lib/libdvbv5/dvb-scan.c
> @@ -185,6 +185,15 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,
>
> h = (struct dvb_table_header *)buf;
> dvb_table_header_init(h);
> +
> + /* dvb_logdbg( "dvb_read_section: id %d, section %d/%d, current: %d", h->id, h->section_id, h->last_section, h->current_next ); */
Why to add a commented line?
> + if (start_id == h->id && start_section == h->section_id) {
> + dvb_logdbg( "dvb_read_section: section repeated, reading done" );
> + break;
> + }
> + if (start_id == -1) start_id = h->id;
> + if (start_section == -1) start_section = h->section_id;
> +
> if (id != -1 && h->id != id) { /* search for a specific table id */
> continue;
> }
Hmm... you're re-adding the code you've removed on patch 01?
Please don't mix ATSC VCT descriptors with this changeset.
> @@ -232,7 +241,8 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,
> else
> dvb_logerr("dvb_read_section: no initializer for table %d", tid);
>
> - if (++sections == last_section + 1)
> + if (id != -1 && ++sections == last_section + 1) {
> + dvb_logerr("dvb_read_section: ++sections == last_section + 1");
Same here: don't mix duplicate section fixups with the ATSC VCT descriptor patch.
> break;
> }
> free(buf);
--
Cheers,
Mauro
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 04/13] libdvbv5: fix deadlock on missing table sections
2013-12-28 15:45 ` [PATCH 04/13] libdvbv5: fix deadlock on missing table sections André Roth
@ 2013-12-29 3:25 ` Mauro Carvalho Chehab
0 siblings, 0 replies; 26+ messages in thread
From: Mauro Carvalho Chehab @ 2013-12-29 3:25 UTC (permalink / raw)
To: André Roth; +Cc: Linux Media Mailing List
Em Sat, 28 Dec 2013 16:45:52 +0100
André Roth <neolynx@gmail.com> escreveu:
> Signed-off-by: André Roth <neolynx@gmail.com>
> ---
> lib/libdvbv5/dvb-scan.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/lib/libdvbv5/dvb-scan.c b/lib/libdvbv5/dvb-scan.c
> index 76712d4..9751f9d 100644
> --- a/lib/libdvbv5/dvb-scan.c
> +++ b/lib/libdvbv5/dvb-scan.c
> @@ -96,6 +96,10 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,
> uint8_t *buf = NULL;
> uint8_t *tbl = NULL;
> ssize_t table_length = 0;
> +
> + // handle sections
> + int start_id = -1;
> + int start_section = -1;
Again, this seems to be part of patch 1.
> int first_section = -1;
> int last_section = -1;
> int table_id = -1;
--
Cheers,
Mauro
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 03/13] libdvbv5: mpeg elementary stream parsers
2013-12-28 15:45 ` [PATCH 03/13] libdvbv5: mpeg elementary stream parsers André Roth
@ 2013-12-29 3:34 ` Mauro Carvalho Chehab
0 siblings, 0 replies; 26+ messages in thread
From: Mauro Carvalho Chehab @ 2013-12-29 3:34 UTC (permalink / raw)
To: André Roth; +Cc: Linux Media Mailing List
Em Sat, 28 Dec 2013 16:45:51 +0100
André Roth <neolynx@gmail.com> escreveu:
> Signed-off-by: André Roth <neolynx@gmail.com>
> ---
> lib/include/descriptors/mpeg_es.h | 109 ++++++++++++++++++++++++++++++
> lib/include/descriptors/mpeg_pes.h | 112 ++++++++++++++++++++++++++++++
> lib/include/descriptors/mpeg_ts.h | 79 ++++++++++++++++++++++
> lib/include/descriptors/nit.h | 4 +-
> lib/libdvbv5/Makefile.am | 5 +-
> lib/libdvbv5/descriptors/mpeg_es.c | 76 +++++++++++++++++++++
> lib/libdvbv5/descriptors/mpeg_pes.c | 131 ++++++++++++++++++++++++++++++++++++
> lib/libdvbv5/descriptors/mpeg_ts.c | 77 +++++++++++++++++++++
> 8 files changed, 590 insertions(+), 3 deletions(-)
> create mode 100644 lib/include/descriptors/mpeg_es.h
> create mode 100644 lib/include/descriptors/mpeg_pes.h
> create mode 100644 lib/include/descriptors/mpeg_ts.h
> create mode 100644 lib/libdvbv5/descriptors/mpeg_es.c
> create mode 100644 lib/libdvbv5/descriptors/mpeg_pes.c
> create mode 100644 lib/libdvbv5/descriptors/mpeg_ts.c
>
> diff --git a/lib/include/descriptors/mpeg_es.h b/lib/include/descriptors/mpeg_es.h
> new file mode 100644
> index 0000000..1a74c90
> --- /dev/null
> +++ b/lib/include/descriptors/mpeg_es.h
> @@ -0,0 +1,109 @@
> +/*
> + * Copyright (c) 2012 - 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 _MPEG_ES_H
> +#define _MPEG_ES_H
> +
> +#include <stdint.h>
> +#include <unistd.h> /* ssize_t */
> +
> +#define DVB_MPEG_ES_PIC_START 0x00
> +#define DVB_MPEG_ES_USER_DATA 0xb2
> +#define DVB_MPEG_ES_SEQ_START 0xb3
> +#define DVB_MPEG_ES_SEQ_EXT 0xb5
> +#define DVB_MPEG_ES_GOP 0xb8
> +#define DVB_MPEG_ES_SLICES 0x01 ... 0xaf
> +
> +struct dvb_mpeg_es_seq_start {
> + union {
> + uint32_t bitfield;
> + struct {
> + uint32_t type:8;
> + uint32_t sync:24;
> + } __attribute__((packed));
> + } __attribute__((packed));
> + union {
> + uint32_t bitfield2;
> + struct {
> + uint32_t framerate:4;
> + uint32_t aspect:4;
> + uint32_t height:12;
> + uint32_t width:12;
> + } __attribute__((packed));
> + };
> + union {
> + uint32_t bitfield3;
> + struct {
> + uint32_t qm_nonintra:1;
> + uint32_t qm_intra:1;
> + uint32_t constrained:1;
> + uint32_t vbv:10; // Size of video buffer verifier = 16*1024*vbv buf size
> + uint32_t one:1;
> + uint32_t bitrate:18;
> + } __attribute__((packed));
> + };
> +} __attribute__((packed));
> +
> +struct dvb_mpeg_es_pic_start {
> + union {
> + uint32_t bitfield;
> + struct {
> + uint32_t type:8;
> + uint32_t sync:24;
> + } __attribute__((packed));
> + } __attribute__((packed));
> + union {
> + uint32_t bitfield2;
> + struct {
> + uint32_t dummy:3;
> + uint32_t vbv_delay:16;
> + uint32_t coding_type:3;
> + uint32_t temporal_ref:10;
> + } __attribute__((packed));
> + };
> +} __attribute__((packed));
> +
> +enum dvb_mpeg_es_frame_t
> +{
> + DVB_MPEG_ES_FRAME_UNKNOWN,
> + DVB_MPEG_ES_FRAME_I,
> + DVB_MPEG_ES_FRAME_P,
> + DVB_MPEG_ES_FRAME_B,
> + DVB_MPEG_ES_FRAME_D
> +};
> +extern const char *dvb_mpeg_es_frame_names[5];
> +
> +struct dvb_v5_fe_parms;
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +int dvb_mpeg_es_seq_start_init (const uint8_t *buf, ssize_t buflen, struct dvb_mpeg_es_seq_start *seq_start);
> +void dvb_mpeg_es_seq_start_print(struct dvb_v5_fe_parms *parms, struct dvb_mpeg_es_seq_start *seq_start);
> +
> +int dvb_mpeg_es_pic_start_init (const uint8_t *buf, ssize_t buflen, struct dvb_mpeg_es_pic_start *pic_start);
> +void dvb_mpeg_es_pic_start_print(struct dvb_v5_fe_parms *parms, struct dvb_mpeg_es_pic_start *pic_start);
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif
> diff --git a/lib/include/descriptors/mpeg_pes.h b/lib/include/descriptors/mpeg_pes.h
> new file mode 100644
> index 0000000..e495f44
> --- /dev/null
> +++ b/lib/include/descriptors/mpeg_pes.h
> @@ -0,0 +1,112 @@
> +/*
> + * Copyright (c) 2011-2012 - Mauro Carvalho Chehab <mchehab@redhat.com>
Thanks, but I'm not the author of this code ;)
> + * Copyright (c) 2012 - 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 _MPEG_PES_H
> +#define _MPEG_PES_H
> +
> +#include <stdint.h>
> +#include <unistd.h> /* ssize_t */
> +
> +#define DVB_MPEG_PES 0x00001
> +#define DVB_MPEG_PES_VIDEO 0xe0 ... 0xef
> +
> +#define DVB_MPEG_STREAM_MAP 0xBC
> +#define DVB_MPEG_STREAM_PADDING 0xBE
> +#define DVB_MPEG_STREAM_PRIVATE_2 0x5F
> +#define DVB_MPEG_STREAM_ECM 0x70
> +#define DVB_MPEG_STREAM_EMM 0x71
> +#define DVB_MPEG_STREAM_DIRECTORY 0xFF
> +#define DVB_MPEG_STREAM_DSMCC 0x7A
> +#define DVB_MPEG_STREAM_H222E 0xF8
> +
> +struct ts_t {
> + uint8_t one:1;
> + uint8_t bits30:3;
> + uint8_t tag:4;
> +
> + union {
> + uint16_t bitfield;
> + struct {
> + uint16_t one1:1;
> + uint16_t bits15:15;
> + } __attribute__((packed));
> + } __attribute__((packed));
> +
> + union {
> + uint16_t bitfield2;
> + struct {
> + uint16_t one2:1;
> + uint16_t bits00:15;
> + } __attribute__((packed));
> + } __attribute__((packed));
> +} __attribute__((packed));
> +
> +struct dvb_mpeg_pes_optional {
> + union {
> + uint16_t bitfield;
> + struct {
> + uint16_t PES_extension:1;
> + uint16_t PES_CRC:1;
> + uint16_t additional_copy_info:1;
> + uint16_t DSM_trick_mode:1;
> + uint16_t ES_rate:1;
> + uint16_t ESCR:1;
> + uint16_t PTS_DTS:2;
> + uint16_t original_or_copy:1;
> + uint16_t copyright:1;
> + uint16_t data_alignment_indicator:1;
> + uint16_t PES_priority:1;
> + uint16_t PES_scrambling_control:2;
> + uint16_t two:2;
> + } __attribute__((packed));
> + } __attribute__((packed));
> + uint8_t length;
> + uint64_t pts;
> + uint64_t dts;
> +} __attribute__((packed));
> +
> +struct dvb_mpeg_pes {
> + union {
> + uint32_t bitfield;
> + struct {
> + uint32_t stream_id:8;
> + uint32_t sync:24;
> + } __attribute__((packed));
> + } __attribute__((packed));
> + uint16_t length;
> + struct dvb_mpeg_pes_optional optional[];
> +} __attribute__((packed));
> +
> +struct dvb_v5_fe_parms;
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +void dvb_mpeg_pes_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length);
> +void dvb_mpeg_pes_free(struct dvb_mpeg_pes *ts);
> +void dvb_mpeg_pes_print(struct dvb_v5_fe_parms *parms, struct dvb_mpeg_pes *ts);
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif
> diff --git a/lib/include/descriptors/mpeg_ts.h b/lib/include/descriptors/mpeg_ts.h
> new file mode 100644
> index 0000000..2bb570b
> --- /dev/null
> +++ b/lib/include/descriptors/mpeg_ts.h
> @@ -0,0 +1,79 @@
> +/*
> + * Copyright (c) 2011-2012 - Mauro Carvalho Chehab <mchehab@redhat.com>
I'm not the author ;)
> + * Copyright (c) 2012 - 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 _MPEG_TS_H
> +#define _MPEG_TS_H
> +
> +#include <stdint.h>
> +#include <unistd.h> /* ssize_t */
> +
> +#define DVB_MPEG_TS 0x47
> +
> +struct dvb_mpeg_ts_adaption {
> + uint8_t length;
> + struct {
> + uint8_t extension:1;
> + uint8_t private_data:1;
> + uint8_t splicing_point:1;
> + uint8_t OPCR:1;
> + uint8_t PCR:1;
> + uint8_t priority:1;
> + uint8_t random_access:1;
> + uint8_t discontinued:1;
> + } __attribute__((packed));
> +
> +} __attribute__((packed));
> +
> +struct dvb_mpeg_ts {
> + uint8_t sync_byte; // DVB_MPEG_TS
> + union {
> + uint16_t bitfield;
> + struct {
> + uint16_t pid:13;
> + uint16_t priority:1;
> + uint16_t payload_start:1;
> + uint16_t tei:1;
> + } __attribute__((packed));
> + };
> + struct {
> + uint8_t continuity_counter:4;
> + uint8_t adaptation_field:2;
> + uint8_t scrambling:2;
> + } __attribute__((packed));
> + struct dvb_mpeg_ts_adaption adaption[];
> +
> +} __attribute__((packed));
> +
> +struct dvb_v5_fe_parms;
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +void dvb_mpeg_ts_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length);
> +void dvb_mpeg_ts_free(struct dvb_mpeg_ts *ts);
> +void dvb_mpeg_ts_print(struct dvb_v5_fe_parms *parms, struct dvb_mpeg_ts *ts);
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif
> diff --git a/lib/include/descriptors/nit.h b/lib/include/descriptors/nit.h
> index f2f6163..d71a762 100644
> --- a/lib/include/descriptors/nit.h
> +++ b/lib/include/descriptors/nit.h
> @@ -48,7 +48,7 @@ struct dvb_table_nit_transport {
> struct {
> uint16_t section_length:12;
> uint16_t reserved:4;
> - };
> + } __attribute__((packed));
> };
> struct dvb_desc *descriptor;
> struct dvb_table_nit_transport *next;
> @@ -61,7 +61,7 @@ struct dvb_table_nit {
> struct {
> uint16_t desc_length:12;
> uint16_t reserved:4;
> - };
> + } __attribute__((packed));
> };
> struct dvb_desc *descriptor;
> struct dvb_table_nit_transport *transport;
Those changes on nit would be better on a separate fixup patch.
> diff --git a/lib/libdvbv5/Makefile.am b/lib/libdvbv5/Makefile.am
> index 400af39..795f30c 100644
> --- a/lib/libdvbv5/Makefile.am
> +++ b/lib/libdvbv5/Makefile.am
> @@ -49,7 +49,10 @@ libdvbv5_la_SOURCES = \
> descriptors/sdt.c ../include/descriptors/sdt.h \
> descriptors/vct.c ../include/descriptors/vct.h \
> descriptors/vct.c ../include/descriptors/vct.h \
> - descriptors/desc_service_location.c ../include/descriptors/desc_service_location.h
> + descriptors/desc_service_location.c ../include/descriptors/desc_service_location.h \
> + descriptors/mpeg_ts.c ../include/descriptors/mpeg_ts.h \
> + descriptors/mpeg_pes.c ../include/descriptors/mpeg_pes.h \
> + descriptors/mpeg_es.c ../include/descriptors/mpeg_es.h
>
> libdvbv5_la_CPPFLAGS = $(ENFORCE_LIBDVBV5_STATIC)
> libdvbv5_la_LDFLAGS = $(LIBDVBV5_VERSION) $(ENFORCE_LIBDVBV5_STATIC) -lm
> diff --git a/lib/libdvbv5/descriptors/mpeg_es.c b/lib/libdvbv5/descriptors/mpeg_es.c
> new file mode 100644
> index 0000000..b081af4
> --- /dev/null
> +++ b/lib/libdvbv5/descriptors/mpeg_es.c
> @@ -0,0 +1,76 @@
> +/*
> + * Copyright (c) 2012 - 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 "descriptors/mpeg_es.h"
> +#include "descriptors.h"
> +#include "dvb-fe.h"
> +
> +int dvb_mpeg_es_seq_start_init(const uint8_t *buf, ssize_t buflen, struct dvb_mpeg_es_seq_start *seq_start)
> +{
> + if(buflen < sizeof(struct dvb_mpeg_es_seq_start))
> + return -1;
> + memcpy(seq_start, buf, sizeof(struct dvb_mpeg_es_seq_start));
> + bswap32(seq_start->bitfield);
> + bswap32(seq_start->bitfield2);
> + bswap32(seq_start->bitfield3);
> + return 0;
> +}
> +
> +void dvb_mpeg_es_seq_start_print(struct dvb_v5_fe_parms *parms, struct dvb_mpeg_es_seq_start *seq_start)
> +{
> + dvb_log("MPEG ES SEQ START");
> + dvb_log(" - width %d", seq_start->width);
> + dvb_log(" - height %d", seq_start->height);
> + dvb_log(" - aspect %d", seq_start->aspect);
> + dvb_log(" - framerate %d", seq_start->framerate);
> + dvb_log(" - bitrate %d", seq_start->bitrate);
> + dvb_log(" - one %d", seq_start->one);
> + dvb_log(" - vbv %d", seq_start->vbv);
> + dvb_log(" - constrained %d", seq_start->constrained);
> + dvb_log(" - qm_intra %d", seq_start->qm_intra);
> + dvb_log(" - qm_nonintra %d", seq_start->qm_nonintra);
It seems that you're using spaces to indent. Please use tabs instead, where
a tab means 8 positions.
> +}
> +
> +const char *dvb_mpeg_es_frame_names[5] = {
> + "?",
> + "I",
> + "P",
> + "B",
> + "D"
> +};
> +
> +int dvb_mpeg_es_pic_start_init(const uint8_t *buf, ssize_t buflen, struct dvb_mpeg_es_pic_start *pic_start)
> +{
> + if(buflen < sizeof(struct dvb_mpeg_es_pic_start))
> + return -1;
> + memcpy(pic_start, buf, sizeof(struct dvb_mpeg_es_pic_start));
> + bswap32(pic_start->bitfield);
> + bswap32(pic_start->bitfield2);
> + return 0;
> +}
> +
> +void dvb_mpeg_es_pic_start_print(struct dvb_v5_fe_parms *parms, struct dvb_mpeg_es_pic_start *pic_start)
> +{
> + dvb_log("MPEG ES PIC START");
> + dvb_log(" - temporal_ref %d", pic_start->temporal_ref);
> + dvb_log(" - coding_type %d (%s-frame)", pic_start->coding_type, dvb_mpeg_es_frame_names[pic_start->coding_type]);
> + dvb_log(" - vbv_delay %d", pic_start->vbv_delay);
> +}
> +
> diff --git a/lib/libdvbv5/descriptors/mpeg_pes.c b/lib/libdvbv5/descriptors/mpeg_pes.c
> new file mode 100644
> index 0000000..c717297
> --- /dev/null
> +++ b/lib/libdvbv5/descriptors/mpeg_pes.c
> @@ -0,0 +1,131 @@
> +/*
> + * Copyright (c) 2012 - 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 "descriptors/mpeg_pes.h"
> +#include "descriptors.h"
> +#include "dvb-fe.h"
> +
> +void dvb_mpeg_pes_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length)
> +{
> + struct dvb_mpeg_pes *pes = (struct dvb_mpeg_pes *) (table + *table_length);
> + const uint8_t *p = buf;
Add a blank line here.
> + memcpy(table + *table_length, p, sizeof(struct dvb_mpeg_pes));
Please check for buflen before copying.
> + p += sizeof(struct dvb_mpeg_pes);
> + *table_length += sizeof(struct dvb_mpeg_pes);
> +
> + bswap32(pes->bitfield);
> + bswap16(pes->length);
> +
> + if (pes->sync != 0x000001 ) {
> + dvb_logerr("mpeg pes invalid");
> + return;
> + }
> +
> + if (pes->stream_id == DVB_MPEG_STREAM_PADDING) {
> + dvb_logwarn("mpeg pes padding stream ignored");
> + } else if (pes->stream_id == DVB_MPEG_STREAM_MAP ||
> + pes->stream_id == DVB_MPEG_STREAM_PRIVATE_2 ||
> + pes->stream_id == DVB_MPEG_STREAM_ECM ||
> + pes->stream_id == DVB_MPEG_STREAM_EMM ||
> + pes->stream_id == DVB_MPEG_STREAM_DIRECTORY ||
> + pes->stream_id == DVB_MPEG_STREAM_DSMCC ||
> + pes->stream_id == DVB_MPEG_STREAM_H222E ) {
> + dvb_logerr("mpeg pes: unsupported stream type %#04x", pes->stream_id);
> + } else {
> + memcpy(pes->optional, p, sizeof(struct dvb_mpeg_pes_optional) -
> + sizeof(pes->optional->pts) -
> + sizeof(pes->optional->dts));
Please use offset_of() instead of those ugly sizeof().
> + p += sizeof(struct dvb_mpeg_pes_optional) -
> + sizeof(pes->optional->pts) -
> + sizeof(pes->optional->dts);
> + bswap16(pes->optional->bitfield);
> + pes->optional->pts = 0;
> + pes->optional->dts = 0;
> + if (pes->optional->PTS_DTS & 2) {
> + struct ts_t pts;
> + memcpy(&pts, p, sizeof(pts));
Please verify buflen before copy.
I suggest you to take a look on how I did at the NIT table parser,
for an example.
> + p += sizeof(pts);
> + bswap16(pts.bitfield);
> + bswap16(pts.bitfield2);
> + if (pts.one != 1 || pts.one1 != 1 || pts.one2 != 1)
> + dvb_logwarn("mpeg pes: invalid pts");
> + else {
> + pes->optional->pts |= (uint64_t) pts.bits00;
> + pes->optional->pts |= (uint64_t) pts.bits15 << 15;
> + pes->optional->pts |= (uint64_t) pts.bits30 << 30;
> + }
> + }
> + if (pes->optional->PTS_DTS & 1) {
> + struct ts_t dts;
> + memcpy(&dts, p, sizeof(dts));
Again, please check before copying.
> + p += sizeof(dts);
> + bswap16(dts.bitfield);
> + bswap16(dts.bitfield2);
> + pes->optional->dts |= (uint64_t) dts.bits00;
> + pes->optional->dts |= (uint64_t) dts.bits15 << 15;
> + pes->optional->dts |= (uint64_t) dts.bits30 << 30;
> + }
> + *table_length += sizeof(struct dvb_mpeg_pes_optional);
> + }
> +}
> +
> +void dvb_mpeg_pes_free(struct dvb_mpeg_pes *ts)
> +{
> + free(ts);
> +}
> +
> +void dvb_mpeg_pes_print(struct dvb_v5_fe_parms *parms, struct dvb_mpeg_pes *pes)
> +{
> + dvb_log("MPEG PES");
> + dvb_log(" - sync %#08x", pes->sync);
> + dvb_log(" - stream_id %#04x", pes->stream_id);
> + dvb_log(" - length %d", pes->length);
> + if (pes->stream_id == DVB_MPEG_STREAM_PADDING) {
> + } else if (pes->stream_id == DVB_MPEG_STREAM_MAP ||
> + pes->stream_id == DVB_MPEG_STREAM_PRIVATE_2 ||
> + pes->stream_id == DVB_MPEG_STREAM_ECM ||
> + pes->stream_id == DVB_MPEG_STREAM_EMM ||
> + pes->stream_id == DVB_MPEG_STREAM_DIRECTORY ||
> + pes->stream_id == DVB_MPEG_STREAM_DSMCC ||
> + pes->stream_id == DVB_MPEG_STREAM_H222E ) {
> + dvb_log(" mpeg pes unsupported stream type %#04x", pes->stream_id);
> + } else {
> + dvb_log(" mpeg pes optional");
> + dvb_log(" - two %d", pes->optional->two);
> + dvb_log(" - PES_scrambling_control %d", pes->optional->PES_scrambling_control);
> + dvb_log(" - PES_priority %d", pes->optional->PES_priority);
> + dvb_log(" - data_alignment_indicator %d", pes->optional->data_alignment_indicator);
> + dvb_log(" - copyright %d", pes->optional->copyright);
> + dvb_log(" - original_or_copy %d", pes->optional->original_or_copy);
> + dvb_log(" - PTS_DTS %d", pes->optional->PTS_DTS);
> + dvb_log(" - ESCR %d", pes->optional->ESCR);
> + dvb_log(" - ES_rate %d", pes->optional->ES_rate);
> + dvb_log(" - DSM_trick_mode %d", pes->optional->DSM_trick_mode);
> + dvb_log(" - additional_copy_info %d", pes->optional->additional_copy_info);
> + dvb_log(" - PES_CRC %d", pes->optional->PES_CRC);
> + dvb_log(" - PES_extension %d", pes->optional->PES_extension);
> + dvb_log(" - length %d", pes->optional->length);
> + if (pes->optional->PTS_DTS & 2)
> + dvb_log(" - pts %lx (%fs)", pes->optional->pts, (float) pes->optional->pts / 90000.0);
> + if (pes->optional->PTS_DTS & 1)
> + dvb_log(" - dts %lx (%fs)", pes->optional->dts, (float) pes->optional->dts/ 90000.0);
> + }
> +}
> +
> diff --git a/lib/libdvbv5/descriptors/mpeg_ts.c b/lib/libdvbv5/descriptors/mpeg_ts.c
> new file mode 100644
> index 0000000..c1d1293
> --- /dev/null
> +++ b/lib/libdvbv5/descriptors/mpeg_ts.c
> @@ -0,0 +1,77 @@
> +/*
> + * Copyright (c) 2012 - 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 "descriptors/mpeg_ts.h"
> +#include "descriptors.h"
> +#include "dvb-fe.h"
> +
> +void dvb_mpeg_ts_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length)
> +{
> + if (buf[0] != DVB_MPEG_TS) {
Please check buflen before assuming that it contains 1 element.
> + dvb_logerr("mpeg ts invalid marker %#02x, sould be %#02x", buf[0], DVB_MPEG_TS);
> + *table_length = 0;
> + return;
> + }
> + struct dvb_mpeg_ts *ts = (struct dvb_mpeg_ts *) table;
> + const uint8_t *p = buf;
Please move data declarations to the beginning.
> + memcpy(table, p, sizeof(struct dvb_mpeg_ts));
Please check bufsize.
> + p += sizeof(struct dvb_mpeg_ts);
> + *table_length = sizeof(struct dvb_mpeg_ts);
> +
> + bswap16(ts->bitfield);
> +
> + if (ts->adaptation_field & 0x2) {
> + memcpy(table + *table_length, p, sizeof(struct dvb_mpeg_ts_adaption));
> + p += sizeof(struct dvb_mpeg_ts);
> + *table_length += ts->adaption->length + 1;
> + }
> + /*hexdump(parms, "TS: ", buf, buflen);*/
> +}
> +
> +void dvb_mpeg_ts_free(struct dvb_mpeg_ts *ts)
> +{
> + free(ts);
> +}
> +
> +void dvb_mpeg_ts_print(struct dvb_v5_fe_parms *parms, struct dvb_mpeg_ts *ts)
> +{
> + dvb_log("MPEG TS");
> + dvb_log(" - sync byte %#02x", ts->sync_byte);
> + dvb_log(" - tei %d", ts->tei);
> + dvb_log(" - payload_start %d", ts->payload_start);
> + dvb_log(" - priority %d", ts->priority);
> + dvb_log(" - pid %d", ts->pid);
> + dvb_log(" - scrambling %d", ts->scrambling);
> + dvb_log(" - adaptation_field %d", ts->adaptation_field);
> + dvb_log(" - continuity_counter %d", ts->continuity_counter);
> + if (ts->adaptation_field & 0x2) {
> + dvb_log(" Adaption Field");
> + dvb_log(" - length %d", ts->adaption->length);
> + dvb_log(" - discontinued %d", ts->adaption->discontinued);
> + dvb_log(" - random_access %d", ts->adaption->random_access);
> + dvb_log(" - priority %d", ts->adaption->priority);
> + dvb_log(" - PCR %d", ts->adaption->PCR);
> + dvb_log(" - OPCR %d", ts->adaption->OPCR);
> + dvb_log(" - splicing_point %d", ts->adaption->splicing_point);
> + dvb_log(" - private_data %d", ts->adaption->private_data);
> + dvb_log(" - extension %d", ts->adaption->extension);
> + }
> +}
> +
--
Cheers,
Mauro
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 05/13] libdvbv5: eit parsing updated
2013-12-28 15:45 ` [PATCH 05/13] libdvbv5: eit parsing updated André Roth
@ 2013-12-29 3:40 ` Mauro Carvalho Chehab
0 siblings, 0 replies; 26+ messages in thread
From: Mauro Carvalho Chehab @ 2013-12-29 3:40 UTC (permalink / raw)
To: André Roth; +Cc: Linux Media Mailing List
Em Sat, 28 Dec 2013 16:45:53 +0100
André Roth <neolynx@gmail.com> escreveu:
> Signed-off-by: André Roth <neolynx@gmail.com>
> ---
> lib/include/descriptors.h | 6 ++++++
> lib/include/descriptors/eit.h | 1 +
> lib/include/dvb-fe.h | 2 ++
> lib/libdvbv5/descriptors.c | 1 +
> lib/libdvbv5/descriptors/eit.c | 28 +++++++++++++++++++++++-----
> lib/libdvbv5/dvb-fe.c | 7 +++++++
> lib/libdvbv5/dvb-scan.c | 22 +++++++---------------
> 7 files changed, 47 insertions(+), 20 deletions(-)
>
> diff --git a/lib/include/descriptors.h b/lib/include/descriptors.h
> index 5ab29a0..6f89aeb 100644
> --- a/lib/include/descriptors.h
> +++ b/lib/include/descriptors.h
> @@ -63,7 +63,13 @@ struct dvb_desc {
> } __attribute__((packed));
>
> void dvb_desc_default_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, struct dvb_desc *desc);
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> void dvb_desc_default_print (struct dvb_v5_fe_parms *parms, const struct dvb_desc *desc);
> +#ifdef __cplusplus
> +}
> +#endif
>
> #define dvb_desc_foreach( _desc, _tbl ) \
> for( struct dvb_desc *_desc = _tbl->descriptor; _desc; _desc = _desc->next ) \
> diff --git a/lib/include/descriptors/eit.h b/lib/include/descriptors/eit.h
> index 2af9696..d2ebdb4 100644
> --- a/lib/include/descriptors/eit.h
> +++ b/lib/include/descriptors/eit.h
> @@ -56,6 +56,7 @@ struct dvb_table_eit_event {
> struct dvb_table_eit_event *next;
> struct tm start;
> uint32_t duration;
> + uint16_t service_id;
> } __attribute__((packed));
>
> struct dvb_table_eit {
> diff --git a/lib/include/dvb-fe.h b/lib/include/dvb-fe.h
> index b0e2bf9..8cf2697 100644
> --- a/lib/include/dvb-fe.h
> +++ b/lib/include/dvb-fe.h
> @@ -119,6 +119,8 @@ struct dvb_v5_fe_parms {
> extern "C" {
> #endif
>
> +struct dvb_v5_fe_parms *dvb_fe_dummy();
> +
Not sure if I understood or liked this. Please add a description on the
patch, explaining what you're doing and why a dvb_fe_dummy() function
is needed.
> struct dvb_v5_fe_parms *dvb_fe_open(int adapter, int frontend,
> unsigned verbose, unsigned use_legacy_call);
> struct dvb_v5_fe_parms *dvb_fe_open2(int adapter, int frontend,
> diff --git a/lib/libdvbv5/descriptors.c b/lib/libdvbv5/descriptors.c
> index 437b2f4..18884b0 100644
> --- a/lib/libdvbv5/descriptors.c
> +++ b/lib/libdvbv5/descriptors.c
> @@ -69,6 +69,7 @@ void dvb_desc_default_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, st
>
> void dvb_desc_default_print(struct dvb_v5_fe_parms *parms, const struct dvb_desc *desc)
> {
> + if (!parms) parms = dvb_fe_dummy();
Please put the set statement on a different line.
> dvb_log("| %s (%#02x)", dvb_descriptors[desc->type].name, desc->type);
> hexdump(parms, "| ", desc->data, desc->length);
> }
> diff --git a/lib/libdvbv5/descriptors/eit.c b/lib/libdvbv5/descriptors/eit.c
> index ccfe1a6..d13b14c 100644
> --- a/lib/libdvbv5/descriptors/eit.c
> +++ b/lib/libdvbv5/descriptors/eit.c
> @@ -29,6 +29,11 @@ void dvb_table_eit_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize
> struct dvb_table_eit_event **head;
>
> if (*table_length > 0) {
> + memcpy(eit, p, sizeof(struct dvb_table_eit) - sizeof(eit->event));
Check for size before copying.
> +
> + bswap16(eit->transport_id);
> + bswap16(eit->network_id);
> +
> /* find end of curent list */
> head = &eit->event;
> while (*head != NULL)
> @@ -48,8 +53,18 @@ void dvb_table_eit_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize
> struct dvb_table_eit_event *last = NULL;
> while ((uint8_t *) p < buf + buflen - 4) {
> struct dvb_table_eit_event *event = (struct dvb_table_eit_event *) malloc(sizeof(struct dvb_table_eit_event));
> - memcpy(event, p, sizeof(struct dvb_table_eit_event) - sizeof(event->descriptor) - sizeof(event->next) - sizeof(event->start) - sizeof(event->duration));
> - p += sizeof(struct dvb_table_eit_event) - sizeof(event->descriptor) - sizeof(event->next) - sizeof(event->start) - sizeof(event->duration);
> + memcpy(event, p, sizeof(struct dvb_table_eit_event) -
> + sizeof(event->descriptor) -
> + sizeof(event->next) -
> + sizeof(event->start) -
> + sizeof(event->duration) -
> + sizeof(event->service_id));
Please replace those ugly sizeof() by offset_of(). Makes the code more
readable and easier to analize.
Also, please check for buf size before copying.
> + p += sizeof(struct dvb_table_eit_event) -
> + sizeof(event->descriptor) -
> + sizeof(event->next) -
> + sizeof(event->start) -
> + sizeof(event->duration) -
> + sizeof(event->service_id);
>
> bswap16(event->event_id);
> bswap16(event->bitfield);
> @@ -57,9 +72,11 @@ void dvb_table_eit_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize
> event->descriptor = NULL;
> event->next = NULL;
> dvb_time(event->dvbstart, &event->start);
> - event->duration = bcd(event->dvbduration[0]) * 3600 +
> - bcd(event->dvbduration[1]) * 60 +
> - bcd(event->dvbduration[2]);
> + event->duration = bcd((uint32_t) event->dvbduration[0]) * 3600 +
> + bcd((uint32_t) event->dvbduration[1]) * 60 +
> + bcd((uint32_t) event->dvbduration[2]);
> +
> + event->service_id = eit->header.id;
>
> if(!*head)
> *head = event;
> @@ -102,6 +119,7 @@ void dvb_table_eit_print(struct dvb_v5_fe_parms *parms, struct dvb_table_eit *ei
> char start[255];
> strftime(start, sizeof(start), "%F %T", &event->start);
> dvb_log("|- %7d", event->event_id);
> + dvb_log("| Service %d", event->service_id);
> dvb_log("| Start %s UTC", start);
> dvb_log("| Duration %dh %dm %ds", event->duration / 3600, (event->duration % 3600) / 60, event->duration % 60);
> dvb_log("| free CA mode %d", event->free_CA_mode);
> diff --git a/lib/libdvbv5/dvb-fe.c b/lib/libdvbv5/dvb-fe.c
> index cc32ec0..4672267 100644
> --- a/lib/libdvbv5/dvb-fe.c
> +++ b/lib/libdvbv5/dvb-fe.c
> @@ -35,6 +35,13 @@ static void dvb_v5_free(struct dvb_v5_fe_parms *parms)
> free(parms);
> }
>
> +struct dvb_v5_fe_parms dummy_fe;
> +struct dvb_v5_fe_parms *dvb_fe_dummy()
> +{
> + dummy_fe.logfunc = dvb_default_log;
> + return &dummy_fe;
> +}
> +
> struct dvb_v5_fe_parms *dvb_fe_open(int adapter, int frontend, unsigned verbose,
> unsigned use_legacy_call)
> {
> diff --git a/lib/libdvbv5/dvb-scan.c b/lib/libdvbv5/dvb-scan.c
> index 9751f9d..421434e 100644
> --- a/lib/libdvbv5/dvb-scan.c
> +++ b/lib/libdvbv5/dvb-scan.c
> @@ -102,7 +102,7 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,
> int start_section = -1;
> int first_section = -1;
> int last_section = -1;
> - int table_id = -1;
> + /*int table_id = -1;*/
> int sections = 0;
> struct dmx_sct_filter_params f;
> struct dvb_table_header *h;
> @@ -112,7 +112,6 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,
> *table = NULL;
>
> // FIXME: verify known table
> -
> memset(&f, 0, sizeof(f));
> f.pid = pid;
> f.filter.filter[0] = tid;
> @@ -202,21 +201,11 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,
> continue;
> }
>
> - /*if (id != -1) {*/
> - /*if (table_id == -1)*/
> - /*table_id = h->id;*/
> - /*else if (h->id != table_id) {*/
> - /*dvb_logwarn("dvb_read_section: table ID mismatch reading multi section table: %d != %d", h->id, table_id);*/
> - /*free(buf);*/
> - /*continue;*/
> - /*}*/
> - /*}*/
> -
> - dvb_logerr("dvb_read_section: got section %d, last %di, filter %d", h->section_id, h->last_section, id );
> + /*dvb_logerr("dvb_read_section: got section %d, last %d, filter %d", h->section_id, h->last_section, id );*/
> /* handle the sections */
> if (first_section == -1)
> first_section = h->section_id;
> - else if (h->section_id == first_section)
> + else if (start_id == h->id && h->section_id == first_section)
> break;
>
> if (last_section == -1)
> @@ -248,8 +237,11 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,
> if (id != -1 && ++sections == last_section + 1) {
> dvb_logerr("dvb_read_section: ++sections == last_section + 1");
> break;
> + }
> }
> - free(buf);
> +
> + if (buf)
> + free(buf);
>
> dvb_dmx_stop(dmx_fd);
>
The above should be at patch 1. It is being really confusing to
understand what you're doing with all those changes to the
table sequencing parser.
--
Cheers,
Mauro
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 06/13] libdvbv5: fix eit times
2013-12-28 15:45 ` [PATCH 06/13] libdvbv5: fix eit times André Roth
@ 2013-12-29 3:42 ` Mauro Carvalho Chehab
0 siblings, 0 replies; 26+ messages in thread
From: Mauro Carvalho Chehab @ 2013-12-29 3:42 UTC (permalink / raw)
To: André Roth; +Cc: Linux Media Mailing List
Em Sat, 28 Dec 2013 16:45:54 +0100
André Roth <neolynx@gmail.com> escreveu:
> Signed-off-by: André Roth <neolynx@gmail.com>
> ---
> lib/libdvbv5/descriptors/eit.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/lib/libdvbv5/descriptors/eit.c b/lib/libdvbv5/descriptors/eit.c
> index d13b14c..e70cf3b 100644
> --- a/lib/libdvbv5/descriptors/eit.c
> +++ b/lib/libdvbv5/descriptors/eit.c
> @@ -155,9 +155,8 @@ void dvb_time(const uint8_t data[5], struct tm *tm)
> tm->tm_mday = day;
> tm->tm_mon = month - 1;
> tm->tm_year = year;
> - tm->tm_isdst = -1;
> - tm->tm_wday = 0;
> - tm->tm_yday = 0;
> + tm->tm_isdst = 1; // dst in effect, do not adjust
Please don't use c99 comments.
> + mktime( tm );
Please remove the extra spaces.
> }
>
>
--
Cheers,
Mauro
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 09/13] libdvbv5: fix section counting
2013-12-28 15:45 ` [PATCH 09/13] libdvbv5: fix section counting André Roth
@ 2013-12-29 3:42 ` Mauro Carvalho Chehab
0 siblings, 0 replies; 26+ messages in thread
From: Mauro Carvalho Chehab @ 2013-12-29 3:42 UTC (permalink / raw)
To: André Roth; +Cc: Linux Media Mailing List
Em Sat, 28 Dec 2013 16:45:57 +0100
André Roth <neolynx@gmail.com> escreveu:
> Signed-off-by: André Roth <neolynx@gmail.com>
> ---
> lib/libdvbv5/dvb-scan.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/libdvbv5/dvb-scan.c b/lib/libdvbv5/dvb-scan.c
> index bd9d2fb..6f3def6 100644
> --- a/lib/libdvbv5/dvb-scan.c
> +++ b/lib/libdvbv5/dvb-scan.c
> @@ -208,7 +208,7 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,
> else if (start_id == h->id && h->section_id == first_section)
> break;
>
> - if (last_section == -1)
> + if (last_section == -1 || h->last_section > last_section)
Patch 1.
> last_section = h->last_section;
>
> if (!tbl) {
--
Cheers,
Mauro
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 10/13] libdvbv5: cleanup coding style
2013-12-28 15:45 ` [PATCH 10/13] libdvbv5: cleanup coding style André Roth
@ 2013-12-29 3:44 ` Mauro Carvalho Chehab
0 siblings, 0 replies; 26+ messages in thread
From: Mauro Carvalho Chehab @ 2013-12-29 3:44 UTC (permalink / raw)
To: André Roth; +Cc: Linux Media Mailing List
Em Sat, 28 Dec 2013 16:45:58 +0100
André Roth <neolynx@gmail.com> escreveu:
Please merge it with the original patch. That makes easier to review.
> Signed-off-by: André Roth <neolynx@gmail.com>
> ---
> lib/libdvbv5/descriptors.c | 2 +-
> lib/libdvbv5/descriptors/mpeg_pes.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lib/libdvbv5/descriptors.c b/lib/libdvbv5/descriptors.c
> index 6df8b8b..b5bc9b2 100644
> --- a/lib/libdvbv5/descriptors.c
> +++ b/lib/libdvbv5/descriptors.c
> @@ -1358,6 +1358,6 @@ void hexdump(struct dvb_v5_fe_parms *parms, const char *prefix, const unsigned c
> for (i = strlen(hex); i < 49; i++)
> strncat(spaces, " ", sizeof(spaces));
> ascii[j] = '\0';
> - dvb_log("%s %s %s %s", prefix, hex, spaces, ascii);
> + dvb_log("%s%s %s %s", prefix, hex, spaces, ascii);
> }
> }
> diff --git a/lib/libdvbv5/descriptors/mpeg_pes.c b/lib/libdvbv5/descriptors/mpeg_pes.c
> index c717297..0f0cde0 100644
> --- a/lib/libdvbv5/descriptors/mpeg_pes.c
> +++ b/lib/libdvbv5/descriptors/mpeg_pes.c
> @@ -33,7 +33,7 @@ void dvb_mpeg_pes_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_
> bswap32(pes->bitfield);
> bswap16(pes->length);
>
> - if (pes->sync != 0x000001 ) {
> + if (pes->sync != 0x000001) {
> dvb_logerr("mpeg pes invalid");
> return;
> }
--
Cheers,
Mauro
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 12/13] libdvbv5: fix missing includes
2013-12-28 15:46 ` [PATCH 12/13] libdvbv5: fix missing includes André Roth
@ 2013-12-29 3:44 ` Mauro Carvalho Chehab
0 siblings, 0 replies; 26+ messages in thread
From: Mauro Carvalho Chehab @ 2013-12-29 3:44 UTC (permalink / raw)
To: André Roth; +Cc: Linux Media Mailing List
Em Sat, 28 Dec 2013 16:46:00 +0100
André Roth <neolynx@gmail.com> escreveu:
> Signed-off-by: André Roth <neolynx@gmail.com>
> ---
> lib/libdvbv5/dvb-file.c | 1 +
> lib/libdvbv5/dvb-sat.c | 1 +
> lib/libdvbv5/dvb-scan.c | 1 +
> lib/libdvbv5/parse_string.c | 1 +
> 4 files changed, 4 insertions(+)
>
> diff --git a/lib/libdvbv5/dvb-file.c b/lib/libdvbv5/dvb-file.c
> index 9abb1f7..d5b00e2 100644
> --- a/lib/libdvbv5/dvb-file.c
> +++ b/lib/libdvbv5/dvb-file.c
> @@ -21,6 +21,7 @@
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> +#include <strings.h> // strcasecmp
> #include <unistd.h>
>
> #include "dvb-file.h"
> diff --git a/lib/libdvbv5/dvb-sat.c b/lib/libdvbv5/dvb-sat.c
> index 3cbcf03..c35e3d7 100644
> --- a/lib/libdvbv5/dvb-sat.c
> +++ b/lib/libdvbv5/dvb-sat.c
> @@ -21,6 +21,7 @@
> #include <stdio.h>
> #include <stdlib.h>
> #include <unistd.h>
> +#include <strings.h> // strcasecmp
>
> #include "dvb-fe.h"
> #include "dvb-v5-std.h"
> diff --git a/lib/libdvbv5/dvb-scan.c b/lib/libdvbv5/dvb-scan.c
> index 6f3def6..d0f0b39 100644
> --- a/lib/libdvbv5/dvb-scan.c
> +++ b/lib/libdvbv5/dvb-scan.c
> @@ -35,6 +35,7 @@
> #include <sys/stat.h>
> #include <sys/types.h>
> #include <stdlib.h>
> +#include <sys/time.h>
>
> #include "dvb-scan.h"
> #include "dvb-frontend.h"
> diff --git a/lib/libdvbv5/parse_string.c b/lib/libdvbv5/parse_string.c
> index f7b745e..8bd56f3 100644
> --- a/lib/libdvbv5/parse_string.c
> +++ b/lib/libdvbv5/parse_string.c
> @@ -27,6 +27,7 @@
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> +#include <strings.h> // strcasecmp
Don't use C99 comments.
>
> #include "parse_string.h"
> #include "dvb-log.h"
--
Cheers,
Mauro
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 11/13] libdvbv5: fix double entry in Makefile.am
2013-12-28 15:45 ` [PATCH 11/13] libdvbv5: fix double entry in Makefile.am André Roth
@ 2013-12-29 3:45 ` Mauro Carvalho Chehab
0 siblings, 0 replies; 26+ messages in thread
From: Mauro Carvalho Chehab @ 2013-12-29 3:45 UTC (permalink / raw)
To: André Roth; +Cc: Linux Media Mailing List
Em Sat, 28 Dec 2013 16:45:59 +0100
André Roth <neolynx@gmail.com> escreveu:
> Signed-off-by: André Roth <neolynx@gmail.com>
> ---
> lib/libdvbv5/Makefile.am | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/lib/libdvbv5/Makefile.am b/lib/libdvbv5/Makefile.am
> index 368baf8..dc5005f 100644
> --- a/lib/libdvbv5/Makefile.am
> +++ b/lib/libdvbv5/Makefile.am
> @@ -47,7 +47,6 @@ libdvbv5_la_SOURCES = \
> 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 \
> descriptors/atsc_header.c ../include/descriptors/atsc_header.h \
> descriptors/vct.c ../include/descriptors/vct.h \
> descriptors/mgt.c ../include/descriptors/mgt.h \
> @@ -58,7 +57,7 @@ libdvbv5_la_SOURCES = \
> descriptors/mpeg_pes.c ../include/descriptors/mpeg_pes.h \
> descriptors/mpeg_es.c ../include/descriptors/mpeg_es.h
>
> -libdvbv5_la_CPPFLAGS = $(ENFORCE_LIBDVBV5_STATIC)
> +libdvbv5_la_CPPFLAGS = $(ENFORCE_LIBDVBV5_STATIC) -std=c99
No. We don't want c99 style.
> libdvbv5_la_LDFLAGS = $(LIBDVBV5_VERSION) $(ENFORCE_LIBDVBV5_STATIC) -lm
> libdvbv5_la_LIBADD = $(LTLIBICONV)
>
--
Cheers,
Mauro
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 13/13] libdvbv5: improve TS parsing
2013-12-28 15:46 ` [PATCH 13/13] libdvbv5: improve TS parsing André Roth
@ 2013-12-29 3:47 ` Mauro Carvalho Chehab
0 siblings, 0 replies; 26+ messages in thread
From: Mauro Carvalho Chehab @ 2013-12-29 3:47 UTC (permalink / raw)
To: André Roth; +Cc: Linux Media Mailing List
Em Sat, 28 Dec 2013 16:46:01 +0100
André Roth <neolynx@gmail.com> escreveu:
> Signed-off-by: André Roth <neolynx@gmail.com>
> ---
> lib/include/descriptors/mpeg_ts.h | 4 ++--
> lib/libdvbv5/descriptors/mpeg_ts.c | 11 ++++++++---
> 2 files changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/lib/include/descriptors/mpeg_ts.h b/lib/include/descriptors/mpeg_ts.h
> index 2bb570b..f332a58 100644
> --- a/lib/include/descriptors/mpeg_ts.h
> +++ b/lib/include/descriptors/mpeg_ts.h
> @@ -39,7 +39,7 @@ struct dvb_mpeg_ts_adaption {
> uint8_t random_access:1;
> uint8_t discontinued:1;
> } __attribute__((packed));
> -
> + uint8_t data[];
> } __attribute__((packed));
>
> struct dvb_mpeg_ts {
> @@ -68,7 +68,7 @@ struct dvb_v5_fe_parms;
> extern "C" {
> #endif
>
> -void dvb_mpeg_ts_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length);
> +ssize_t dvb_mpeg_ts_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length);
> void dvb_mpeg_ts_free(struct dvb_mpeg_ts *ts);
> void dvb_mpeg_ts_print(struct dvb_v5_fe_parms *parms, struct dvb_mpeg_ts *ts);
>
> diff --git a/lib/libdvbv5/descriptors/mpeg_ts.c b/lib/libdvbv5/descriptors/mpeg_ts.c
> index c1d1293..e55f590 100644
> --- a/lib/libdvbv5/descriptors/mpeg_ts.c
> +++ b/lib/libdvbv5/descriptors/mpeg_ts.c
> @@ -22,27 +22,32 @@
> #include "descriptors.h"
> #include "dvb-fe.h"
>
> -void dvb_mpeg_ts_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length)
> +ssize_t dvb_mpeg_ts_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length)
> {
> if (buf[0] != DVB_MPEG_TS) {
> dvb_logerr("mpeg ts invalid marker %#02x, sould be %#02x", buf[0], DVB_MPEG_TS);
> *table_length = 0;
> - return;
> + return 0;
> }
> + ssize_t bytes_read = 0;
> struct dvb_mpeg_ts *ts = (struct dvb_mpeg_ts *) table;
> const uint8_t *p = buf;
> memcpy(table, p, sizeof(struct dvb_mpeg_ts));
> p += sizeof(struct dvb_mpeg_ts);
> + bytes_read += sizeof(struct dvb_mpeg_ts);
> *table_length = sizeof(struct dvb_mpeg_ts);
>
> bswap16(ts->bitfield);
>
> if (ts->adaptation_field & 0x2) {
> memcpy(table + *table_length, p, sizeof(struct dvb_mpeg_ts_adaption));
> - p += sizeof(struct dvb_mpeg_ts);
> + p += sizeof(struct dvb_mpeg_ts_adaption);
> + bytes_read += sizeof(struct dvb_mpeg_ts_adaption);
> *table_length += ts->adaption->length + 1;
> + // FIXME: copy adaption->lenght bytes
don't use c99 comments.
> }
> /*hexdump(parms, "TS: ", buf, buflen);*/
> + return bytes_read;
> }
>
> void dvb_mpeg_ts_free(struct dvb_mpeg_ts *ts)
--
Cheers,
Mauro
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 07/13] libdvbv5: MGT parser
2013-12-28 15:45 ` [PATCH 07/13] libdvbv5: MGT parser André Roth
@ 2013-12-29 3:49 ` Mauro Carvalho Chehab
0 siblings, 0 replies; 26+ messages in thread
From: Mauro Carvalho Chehab @ 2013-12-29 3:49 UTC (permalink / raw)
To: André Roth; +Cc: Linux Media Mailing List
Em Sat, 28 Dec 2013 16:45:55 +0100
André Roth <neolynx@gmail.com> escreveu:
> Signed-off-by: André Roth <neolynx@gmail.com>
> ---
> lib/include/descriptors/mgt.h | 82 ++++++++++++++++++++++++++++++
> lib/libdvbv5/Makefile.am | 1 +
> lib/libdvbv5/descriptors.c | 1 +
> lib/libdvbv5/descriptors/mgt.c | 113 +++++++++++++++++++++++++++++++++++++++++
> 4 files changed, 197 insertions(+)
> create mode 100644 lib/include/descriptors/mgt.h
> create mode 100644 lib/libdvbv5/descriptors/mgt.c
>
> diff --git a/lib/include/descriptors/mgt.h b/lib/include/descriptors/mgt.h
> new file mode 100644
> index 0000000..4a68f2c
> --- /dev/null
> +++ b/lib/include/descriptors/mgt.h
> @@ -0,0 +1,82 @@
> +/*
> + * Copyright (c) 2011-2012 - Mauro Carvalho Chehab <mchehab@redhat.com>
I'm not the author.
> + * 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 _MGT_H
> +#define _MGT_H
> +
> +#include <stdint.h>
> +#include <unistd.h> /* ssize_t */
> +
> +#include "descriptors/header.h"
> +#include "descriptors.h"
> +
> +#define DVB_TABLE_MGT 0xC7
> +
> +struct dvb_table_mgt_table {
> + uint16_t type;
> + union {
> + uint16_t bitfield;
> + struct {
> + uint16_t pid:13;
> + uint16_t one:3;
> + } __attribute__((packed));
> + } __attribute__((packed));
> + uint8_t type_version:5;
> + uint8_t one2:3;
> + uint32_t size;
> + union {
> + uint16_t bitfield2;
> + struct {
> + uint16_t desc_length:12;
> + uint16_t one3:4;
> + } __attribute__((packed));
> + } __attribute__((packed));
> + struct dvb_desc *descriptor;
> + struct dvb_table_mgt_table *next;
> +} __attribute__((packed));
> +
> +struct dvb_table_mgt {
> + struct dvb_table_header header;
> + uint8_t protocol_version;
> + uint16_t tables;
> + struct dvb_table_mgt_table *table;
> + struct dvb_desc *descriptor;
> +} __attribute__((packed));
> +
> +
> +#define dvb_mgt_transport_foreach( tran, mgt ) \
> + for( struct dvb_table_mgt_transport *tran = mgt->transport; tran; tran = tran->next ) \
> +
> +struct dvb_v5_fe_parms;
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +void dvb_table_mgt_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length);
> +void dvb_table_mgt_free(struct dvb_table_mgt *mgt);
> +void dvb_table_mgt_print(struct dvb_v5_fe_parms *parms, struct dvb_table_mgt *mgt);
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif
> diff --git a/lib/libdvbv5/Makefile.am b/lib/libdvbv5/Makefile.am
> index 795f30c..9d4b6b9 100644
> --- a/lib/libdvbv5/Makefile.am
> +++ b/lib/libdvbv5/Makefile.am
> @@ -49,6 +49,7 @@ libdvbv5_la_SOURCES = \
> descriptors/sdt.c ../include/descriptors/sdt.h \
> descriptors/vct.c ../include/descriptors/vct.h \
> descriptors/vct.c ../include/descriptors/vct.h \
> + descriptors/mgt.c ../include/descriptors/mgt.h \
> descriptors/desc_service_location.c ../include/descriptors/desc_service_location.h \
> descriptors/mpeg_ts.c ../include/descriptors/mpeg_ts.h \
> descriptors/mpeg_pes.c ../include/descriptors/mpeg_pes.h \
> diff --git a/lib/libdvbv5/descriptors.c b/lib/libdvbv5/descriptors.c
> index 18884b0..bd1bc03 100644
> --- a/lib/libdvbv5/descriptors.c
> +++ b/lib/libdvbv5/descriptors.c
> @@ -36,6 +36,7 @@
> #include "descriptors/sdt.h"
> #include "descriptors/eit.h"
> #include "descriptors/vct.h"
> +#include "descriptors/mgt.h"
> #include "descriptors/desc_language.h"
> #include "descriptors/desc_network_name.h"
> #include "descriptors/desc_cable_delivery.h"
> diff --git a/lib/libdvbv5/descriptors/mgt.c b/lib/libdvbv5/descriptors/mgt.c
> new file mode 100644
> index 0000000..272d9d7
> --- /dev/null
> +++ b/lib/libdvbv5/descriptors/mgt.c
> @@ -0,0 +1,113 @@
> +/*
> + * Copyright (c) 2011-2012 - Mauro Carvalho Chehab <mchehab@redhat.com>
I'm not the author.
> + * Copyright (c) 2012 - 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 "descriptors/mgt.h"
> +#include "dvb-fe.h"
> +
> +void dvb_table_mgt_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length)
> +{
> + const uint8_t *p = buf;
> + struct dvb_table_mgt *mgt = (struct dvb_table_mgt *) table;
> + struct dvb_desc **head_desc;
> + struct dvb_table_mgt_table **head;
> + /*int desc_length;*/
> +
> + if (*table_length > 0) {
> + /* find end of curent lists */
> + head_desc = &mgt->descriptor;
> + while (*head_desc != NULL)
> + head_desc = &(*head_desc)->next;
> + head = &mgt->table;
> + while (*head != NULL)
> + head = &(*head)->next;
> + } else {
> + memcpy(table, p, sizeof(struct dvb_table_mgt) - sizeof(mgt->descriptor) - sizeof(mgt->table));
Check before copy. Use offset_of().
> + *table_length = sizeof(struct dvb_table_mgt);
> +
> + mgt->descriptor = NULL;
> + mgt->table = NULL;
> + head_desc = &mgt->descriptor;
> + head = &mgt->table;
> + bswap16(mgt->tables);
> + }
> + p += sizeof(struct dvb_table_mgt) - sizeof(mgt->descriptor) - sizeof(mgt->table);
> +
> + /*dvb_parse_descriptors(parms, p, desc_length, head_desc);*/
> + /*p += desc_length;*/
> + int i = 0;
> + struct dvb_table_mgt_table *last = NULL;
Data at beginning of the function.
> + while (i++ < mgt->tables && (uint8_t *) p < buf + buflen - 4) {
> + struct dvb_table_mgt_table *table = (struct dvb_table_mgt_table *) malloc(sizeof(struct dvb_table_mgt_table));
> + memcpy(table, p, sizeof(struct dvb_table_mgt_table) - sizeof(table->descriptor) - sizeof(table->next));
> + p += sizeof(struct dvb_table_mgt_table) - sizeof(table->descriptor) - sizeof(table->next);
> +
> + bswap16(table->type);
> + bswap16(table->bitfield);
> + bswap16(table->bitfield2);
> + bswap32(table->size);
> + table->descriptor = NULL;
> + table->next = NULL;
> +
> + if(!*head)
> + *head = table;
> + if(last)
> + last->next = table;
> +
> + /* get the descriptors for each table */
> + struct dvb_desc **head_desc = &table->descriptor;
> + dvb_parse_descriptors(parms, p, table->desc_length, head_desc);
> +
> + p += table->desc_length;
> + last = table;
> + }
> +}
> +
> +void dvb_table_mgt_free(struct dvb_table_mgt *mgt)
> +{
> + struct dvb_table_mgt_table *table = mgt->table;
> + dvb_free_descriptors((struct dvb_desc **) &mgt->descriptor);
> + while(table) {
> + dvb_free_descriptors((struct dvb_desc **) &table->descriptor);
> + struct dvb_table_mgt_table *tmp = table;
> + table = table->next;
> + free(tmp);
> + }
> + free(mgt);
> +}
> +
> +void dvb_table_mgt_print(struct dvb_v5_fe_parms *parms, struct dvb_table_mgt *mgt)
> +{
> + dvb_log("MGT");
> + dvb_table_header_print(parms, &mgt->header);
> + dvb_log("| protocol_version %d", mgt->protocol_version);
> + dvb_log("| tables %d", mgt->tables);
> + /*dvb_print_descriptors(parms, mgt->descriptor);*/
> + const struct dvb_table_mgt_table *table = mgt->table;
> + uint16_t tables = 0;
> + while(table) {
> + dvb_log("|- type %04x %d", table->type, table->pid);
> + dvb_print_descriptors(parms, table->descriptor);
> + table = table->next;
> + tables++;
> + }
> + dvb_log("|_ %d tables", tables);
> +}
> +
--
Cheers,
Mauro
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 08/13] libdvbv5: ATSC EIT
2013-12-28 15:45 ` [PATCH 08/13] libdvbv5: ATSC EIT André Roth
@ 2013-12-29 3:58 ` Mauro Carvalho Chehab
0 siblings, 0 replies; 26+ messages in thread
From: Mauro Carvalho Chehab @ 2013-12-29 3:58 UTC (permalink / raw)
To: André Roth; +Cc: Linux Media Mailing List
Em Sat, 28 Dec 2013 16:45:56 +0100
André Roth <neolynx@gmail.com> escreveu:
> Signed-off-by: André Roth <neolynx@gmail.com>
> ---
> lib/include/descriptors/atsc_eit.h | 91 +++++++++++++++++++++
> lib/include/descriptors/atsc_header.h | 64 +++++++++++++++
> lib/include/descriptors/mgt.h | 25 +++---
> lib/include/descriptors/vct.h | 39 ++++-----
> lib/include/dvb-scan.h | 2 +-
> lib/libdvbv5/Makefile.am | 3 +
> lib/libdvbv5/descriptors.c | 19 +++--
> lib/libdvbv5/descriptors/atsc_eit.c | 143 +++++++++++++++++++++++++++++++++
> lib/libdvbv5/descriptors/atsc_header.c | 48 +++++++++++
> lib/libdvbv5/descriptors/eit.c | 2 +-
> lib/libdvbv5/descriptors/mgt.c | 41 +++++-----
> lib/libdvbv5/descriptors/vct.c | 39 +++++----
> lib/libdvbv5/dvb-file.c | 2 +-
> lib/libdvbv5/dvb-scan.c | 10 +--
> 14 files changed, 442 insertions(+), 86 deletions(-)
> create mode 100644 lib/include/descriptors/atsc_eit.h
> create mode 100644 lib/include/descriptors/atsc_header.h
> create mode 100644 lib/libdvbv5/descriptors/atsc_eit.c
> create mode 100644 lib/libdvbv5/descriptors/atsc_header.c
>
> diff --git a/lib/include/descriptors/atsc_eit.h b/lib/include/descriptors/atsc_eit.h
> new file mode 100644
> index 0000000..ded7a64
> --- /dev/null
> +++ b/lib/include/descriptors/atsc_eit.h
> @@ -0,0 +1,91 @@
> +/*
> + * Copyright (c) 2011-2012 - Mauro Carvalho Chehab <mchehab@redhat.com>
I'm not the author.
> + * Copyright (c) 2012 - 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 _ATSC_EIT_H
> +#define _ATSC_EIT_H
> +
> +#include <stdint.h>
> +#include <unistd.h> /* ssize_t */
> +#include <time.h>
> +
> +#include "descriptors/atsc_header.h"
> +#include "descriptors.h"
> +
> +#define ATSC_TABLE_EIT 0xCB
> +
> +struct atsc_table_eit_event {
> + union {
> + uint16_t bitfield;
> + struct {
> + uint16_t event_id:14;
> + uint16_t one:2;
> + } __attribute__((packed));
> + } __attribute__((packed));
> + uint32_t start_time;
> + union {
> + uint32_t bitfield2;
> + struct {
> + uint32_t title_length:8;
> + uint32_t duration:20;
> + uint32_t etm:2;
> + uint32_t one2:2;
> + uint32_t :2;
> + } __attribute__((packed));
> + } __attribute__((packed));
> + struct dvb_desc *descriptor;
> + struct atsc_table_eit_event *next;
> + struct tm start;
> + uint16_t source_id;
> +} __attribute__((packed));
> +
> +union atsc_table_eit_desc_length {
> + uint16_t bitfield;
> + struct {
> + uint16_t desc_length:12;
> + uint16_t reserved:4;
> + } __attribute__((packed));
> +} __attribute__((packed));
> +
> +struct atsc_table_eit {
> + struct atsc_table_header header;
> + uint8_t events;
> + struct atsc_table_eit_event *event;
> +} __attribute__((packed));
> +
> +#define atsc_eit_event_foreach(_event, _eit) \
> + for( struct atsc_table_eit_event *_event = _eit->event; _event; _event = _event->next ) \
> +
> +struct dvb_v5_fe_parms;
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +void atsc_table_eit_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length);
> +void atsc_table_eit_free(struct atsc_table_eit *eit);
> +void atsc_table_eit_print(struct dvb_v5_fe_parms *parms, struct atsc_table_eit *eit);
> +void atsc_time(const uint32_t start_time, struct tm *tm);
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif
> diff --git a/lib/include/descriptors/atsc_header.h b/lib/include/descriptors/atsc_header.h
> new file mode 100644
> index 0000000..481d15f
> --- /dev/null
> +++ b/lib/include/descriptors/atsc_header.h
> @@ -0,0 +1,64 @@
> +/*
> + * Copyright (c) 2011-2012 - Mauro Carvalho Chehab <mchehab@redhat.com>
I'm not the author.
> + * Copyright (c) 2012 - 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 _ATSC_HEADER_H
> +#define _ATSC_HEADER_H
> +
> +#include <stdint.h>
> +#include <unistd.h> /* ssize_t */
> +
> +#define ATSC_BASE_PID 0x1FFB
> +
> +struct atsc_table_header {
> + uint8_t table_id;
> + union {
> + uint16_t bitfield;
> + struct {
> + uint16_t section_length:12;
> + uint16_t one:2;
> + uint16_t priv:1;
> + uint16_t syntax:1;
> + } __attribute__((packed));
> + };
> + uint16_t id;
> + uint8_t current_next:1;
> + uint8_t version:5;
> + uint8_t one2:2;
> +
> + uint8_t section_id;
> + uint8_t last_section;
> + uint8_t protocol_version;
> +} __attribute__((packed));
> +
> +struct dvb_v5_fe_parms;
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +int atsc_table_header_init (struct atsc_table_header *t);
> +void atsc_table_header_print(struct dvb_v5_fe_parms *parms, const struct atsc_table_header *t);
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif
> diff --git a/lib/include/descriptors/mgt.h b/lib/include/descriptors/mgt.h
> index 4a68f2c..889d026 100644
> --- a/lib/include/descriptors/mgt.h
> +++ b/lib/include/descriptors/mgt.h
> @@ -25,12 +25,12 @@
> #include <stdint.h>
> #include <unistd.h> /* ssize_t */
>
> -#include "descriptors/header.h"
> +#include "descriptors/atsc_header.h"
> #include "descriptors.h"
>
> -#define DVB_TABLE_MGT 0xC7
> +#define ATSC_TABLE_MGT 0xC7
>
> -struct dvb_table_mgt_table {
> +struct atsc_table_mgt_table {
> uint16_t type;
> union {
> uint16_t bitfield;
> @@ -50,20 +50,19 @@ struct dvb_table_mgt_table {
> } __attribute__((packed));
> } __attribute__((packed));
> struct dvb_desc *descriptor;
> - struct dvb_table_mgt_table *next;
> + struct atsc_table_mgt_table *next;
> } __attribute__((packed));
>
> -struct dvb_table_mgt {
> - struct dvb_table_header header;
> - uint8_t protocol_version;
> +struct atsc_table_mgt {
> + struct atsc_table_header header;
> uint16_t tables;
> - struct dvb_table_mgt_table *table;
> + struct atsc_table_mgt_table *table;
> struct dvb_desc *descriptor;
> } __attribute__((packed));
>
>
> -#define dvb_mgt_transport_foreach( tran, mgt ) \
> - for( struct dvb_table_mgt_transport *tran = mgt->transport; tran; tran = tran->next ) \
> +#define dvb_mgt_table_foreach( tran, mgt ) \
> + for( struct dvb_table_mgt_table *tran = mgt->table; tran; tran = tran->next ) \
>
> struct dvb_v5_fe_parms;
>
> @@ -71,9 +70,9 @@ struct dvb_v5_fe_parms;
> extern "C" {
> #endif
>
> -void dvb_table_mgt_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length);
> -void dvb_table_mgt_free(struct dvb_table_mgt *mgt);
> -void dvb_table_mgt_print(struct dvb_v5_fe_parms *parms, struct dvb_table_mgt *mgt);
> +void atsc_table_mgt_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length);
> +void atsc_table_mgt_free(struct atsc_table_mgt *mgt);
> +void atsc_table_mgt_print(struct dvb_v5_fe_parms *parms, struct atsc_table_mgt *mgt);
>
> #ifdef __cplusplus
> }
> diff --git a/lib/include/descriptors/vct.h b/lib/include/descriptors/vct.h
> index 505a407..8afd0b8 100644
> --- a/lib/include/descriptors/vct.h
> +++ b/lib/include/descriptors/vct.h
> @@ -25,25 +25,25 @@
> #include <stdint.h>
> #include <unistd.h> /* ssize_t */
>
> -#include "descriptors/header.h"
> +#include "descriptors/atsc_header.h"
> #include "descriptors.h"
>
> -#define DVB_TABLE_TVCT 0xc8
> -#define DVB_TABLE_CVCT 0xc9
> -#define DVB_TABLE_VCT_PID 0x1ffb
> +#define ATSC_TABLE_TVCT 0xc8
> +#define ATSC_TABLE_CVCT 0xc9
> +#define ATSC_TABLE_VCT_PID 0x1ffb
>
> -struct dvb_table_vct_channel {
> +struct atsc_table_vct_channel {
> uint16_t __short_name[7];
>
> union {
> - uint32_t bitfield;
> + uint32_t bitfield1;
I think you're touching here again, reverting what you've done on a
previous patch.
> struct {
> uint32_t modulation_mode:8;
> uint32_t minor_channel_number:10;
> uint32_t major_channel_number:10;
> uint32_t reserved1:4;
> } __attribute__((packed));
> - };
> + } __attribute__((packed));
>
> uint32_t carrier_frequency;
> uint16_t channel_tsid;
> @@ -61,7 +61,8 @@ struct dvb_table_vct_channel {
> uint16_t ETM_location:2;
>
> } __attribute__((packed));
> - };
> + } __attribute__((packed));
> +
> uint16_t source_id;
> union {
> uint16_t bitfield3;
> @@ -69,22 +70,22 @@ struct dvb_table_vct_channel {
> uint16_t descriptors_length:10;
> uint16_t reserved3:6;
> } __attribute__((packed));
> - };
> + } __attribute__((packed));
>
> /*
> * Everything after descriptor (including it) won't be bit-mapped
> * to the data parsed from the MPEG TS. So, metadata are added there
> */
> struct dvb_desc *descriptor;
> - struct dvb_table_vct_channel *next;
> + struct atsc_table_vct_channel *next;
>
> /* The channel_short_name is converted to locale charset by vct.c */
>
> char short_name[32];
> } __attribute__((packed));
>
> -struct dvb_table_vct {
> - struct dvb_table_header header;
> +struct atsc_table_vct {
> + struct atsc_table_header header;
>
> uint8_t ATSC_protocol_version;
> uint8_t num_channels_in_section;
> @@ -93,12 +94,12 @@ struct dvb_table_vct {
> * Everything after descriptor (including it) won't be bit-mapped
> * to the data parsed from the MPEG TS. So, metadata are added there
> */
> - struct dvb_table_vct_channel *channel;
> + struct atsc_table_vct_channel *channel;
> struct dvb_desc *descriptor;
> } __attribute__((packed));
>
>
> -union dvb_table_vct_descriptor_length {
> +union atsc_table_vct_descriptor_length {
> uint16_t bitfield;
> struct {
> uint16_t descriptor_length:10;
> @@ -106,8 +107,8 @@ union dvb_table_vct_descriptor_length {
> };
> };
>
> -#define dvb_vct_channel_foreach(_channel, _vct) \
> - for (struct dvb_table_vct_channel *_channel = _vct->channel; _channel; _channel = _channel->next) \
> +#define atsc_vct_channel_foreach(_channel, _vct) \
> + for (struct atsc_table_vct_channel *_channel = _vct->channel; _channel; _channel = _channel->next) \
>
> struct dvb_v5_fe_parms;
>
> @@ -115,9 +116,9 @@ struct dvb_v5_fe_parms;
> extern "C" {
> #endif
>
> -void dvb_table_vct_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length);
> -void dvb_table_vct_free(struct dvb_table_vct *vct);
> -void dvb_table_vct_print(struct dvb_v5_fe_parms *parms, struct dvb_table_vct *vct);
> +void atsc_table_vct_init (struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length);
> +void atsc_table_vct_free(struct atsc_table_vct *vct);
> +void atsc_table_vct_print(struct dvb_v5_fe_parms *parms, struct atsc_table_vct *vct);
>
> #ifdef __cplusplus
> }
> diff --git a/lib/include/dvb-scan.h b/lib/include/dvb-scan.h
> index b5dbfa9..9aef531 100644
> --- a/lib/include/dvb-scan.h
> +++ b/lib/include/dvb-scan.h
> @@ -49,7 +49,7 @@ struct dvb_v5_descriptors {
> unsigned num_entry;
>
> struct dvb_table_pat *pat;
> - struct dvb_table_vct *vct;
> + struct atsc_table_vct *vct;
> struct dvb_v5_descriptors_program *program;
> struct dvb_table_nit *nit;
> struct dvb_table_sdt *sdt;
> diff --git a/lib/libdvbv5/Makefile.am b/lib/libdvbv5/Makefile.am
> index 9d4b6b9..368baf8 100644
> --- a/lib/libdvbv5/Makefile.am
> +++ b/lib/libdvbv5/Makefile.am
> @@ -48,8 +48,11 @@ libdvbv5_la_SOURCES = \
> descriptors/nit.c ../include/descriptors/nit.h \
> descriptors/sdt.c ../include/descriptors/sdt.h \
> descriptors/vct.c ../include/descriptors/vct.h \
> + descriptors/atsc_header.c ../include/descriptors/atsc_header.h \
> descriptors/vct.c ../include/descriptors/vct.h \
> descriptors/mgt.c ../include/descriptors/mgt.h \
> + descriptors/eit.c ../include/descriptors/eit.h \
> + descriptors/atsc_eit.c ../include/descriptors/atsc_eit.h \
> descriptors/desc_service_location.c ../include/descriptors/desc_service_location.h \
> descriptors/mpeg_ts.c ../include/descriptors/mpeg_ts.h \
> descriptors/mpeg_pes.c ../include/descriptors/mpeg_pes.h \
> diff --git a/lib/libdvbv5/descriptors.c b/lib/libdvbv5/descriptors.c
> index bd1bc03..6df8b8b 100644
> --- a/lib/libdvbv5/descriptors.c
> +++ b/lib/libdvbv5/descriptors.c
> @@ -37,6 +37,7 @@
> #include "descriptors/eit.h"
> #include "descriptors/vct.h"
> #include "descriptors/mgt.h"
> +#include "descriptors/atsc_eit.h"
> #include "descriptors/desc_language.h"
> #include "descriptors/desc_network_name.h"
> #include "descriptors/desc_cable_delivery.h"
> @@ -76,14 +77,16 @@ void dvb_desc_default_print(struct dvb_v5_fe_parms *parms, const struct dvb_desc
> }
>
> const struct dvb_table_init dvb_table_initializers[] = {
> - [DVB_TABLE_PAT] = { dvb_table_pat_init, sizeof(struct dvb_table_pat) },
> - [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) },
> - [DVB_TABLE_EIT] = { dvb_table_eit_init, sizeof(struct dvb_table_eit) },
> - [DVB_TABLE_TVCT] = { dvb_table_vct_init, sizeof(struct dvb_table_vct) },
> - [DVB_TABLE_CVCT] = { dvb_table_vct_init, sizeof(struct dvb_table_vct) },
> + [DVB_TABLE_PAT] = { dvb_table_pat_init, sizeof(struct dvb_table_pat) },
> + [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) },
> + [DVB_TABLE_EIT] = { dvb_table_eit_init, sizeof(struct dvb_table_eit) },
> [DVB_TABLE_EIT_SCHEDULE] = { dvb_table_eit_init, sizeof(struct dvb_table_eit) },
> + [ATSC_TABLE_TVCT] = { atsc_table_vct_init, sizeof(struct atsc_table_vct) },
> + [ATSC_TABLE_CVCT] = { atsc_table_vct_init, sizeof(struct atsc_table_vct) },
> + [ATSC_TABLE_MGT] = { atsc_table_mgt_init, sizeof(struct atsc_table_mgt) },
> + [ATSC_TABLE_EIT] = { atsc_table_eit_init, sizeof(struct atsc_table_eit) },
> };
>
> char *default_charset = "iso-8859-1";
> @@ -1355,6 +1358,6 @@ void hexdump(struct dvb_v5_fe_parms *parms, const char *prefix, const unsigned c
> for (i = strlen(hex); i < 49; i++)
> strncat(spaces, " ", sizeof(spaces));
> ascii[j] = '\0';
> - dvb_log("%s%s %s %s", prefix, hex, spaces, ascii);
> + dvb_log("%s %s %s %s", prefix, hex, spaces, ascii);
> }
> }
> diff --git a/lib/libdvbv5/descriptors/atsc_eit.c b/lib/libdvbv5/descriptors/atsc_eit.c
> new file mode 100644
> index 0000000..b827ecb
> --- /dev/null
> +++ b/lib/libdvbv5/descriptors/atsc_eit.c
> @@ -0,0 +1,143 @@
> +/*
> + * Copyright (c) 2011-2012 - Mauro Carvalho Chehab <mchehab@redhat.com>
I'm not the author.
> + * Copyright (c) 2012 - 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 "descriptors/atsc_eit.h"
> +#include "dvb-fe.h"
> +
> +void atsc_table_eit_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length)
> +{
> + const uint8_t *p = buf;
> + struct atsc_table_eit *eit = (struct atsc_table_eit *) table;
> + struct atsc_table_eit_event **head;
> +
> + if (*table_length > 0) {
> + memcpy(eit, p, sizeof(struct atsc_table_eit) - sizeof(eit->event));
Check before copy. Use offset_of().
> +
> + /* find end of curent list */
> + head = &eit->event;
> + while (*head != NULL)
> + head = &(*head)->next;
> + } else {
> + memcpy(eit, p, sizeof(struct atsc_table_eit) - sizeof(eit->event));
check before copy. Use offset_of().
> + *table_length = sizeof(struct atsc_table_eit);
> +
> + eit->event = NULL;
> + head = &eit->event;
> + }
> + p += sizeof(struct atsc_table_eit) - sizeof(eit->event);
> +
> + hexdump(parms, "eit", p, 64 );
> +
> + int i = 0;
> + struct atsc_table_eit_event *last = NULL;
> + while (i++ < eit->events && (uint8_t *) p < buf + buflen - 4) {
> + struct atsc_table_eit_event *event = (struct atsc_table_eit_event *) malloc(sizeof(struct atsc_table_eit_event));
> + memcpy(event, p, sizeof(struct atsc_table_eit_event) -
> + sizeof(event->descriptor) -
> + sizeof(event->next) -
> + sizeof(event->start) -
> + sizeof(event->source_id));
> + p += sizeof(struct atsc_table_eit_event) -
> + sizeof(event->descriptor) -
> + sizeof(event->next) -
> + sizeof(event->start) -
> + sizeof(event->source_id);
Please use offset_of().
> +
> + bswap16(event->bitfield);
> + bswap32(event->start_time);
> + bswap32(event->bitfield2);
> + event->descriptor = NULL;
> + event->next = NULL;
> + atsc_time(event->start_time, &event->start);
> + event->source_id = eit->header.id;
> +
> + //FIXME: title
> + p += event->title_length - 1;
> +
> + if(!*head)
> + *head = event;
> + if(last)
> + last->next = event;
> +
> + /* get the descriptors for each program */
> + struct dvb_desc **head_desc = &event->descriptor;
> + union atsc_table_eit_desc_length dl = *(union atsc_table_eit_desc_length *) p;
data declarations at the beginning.
> + bswap16(dl.bitfield);
> + p += sizeof(union atsc_table_eit_desc_length);
> + dvb_parse_descriptors(parms, p, dl.desc_length, head_desc);
> +
> + p += dl.desc_length;
> + last = event;
> + }
> +}
> +
> +void atsc_table_eit_free(struct atsc_table_eit *eit)
> +{
> + struct atsc_table_eit_event *event = eit->event;
> + while (event) {
> + dvb_free_descriptors((struct dvb_desc **) &event->descriptor);
> + struct atsc_table_eit_event *tmp = event;
> + event = event->next;
> + free(tmp);
> + }
> + free(eit);
> +}
> +
> +void atsc_table_eit_print(struct dvb_v5_fe_parms *parms, struct atsc_table_eit *eit)
> +{
> + dvb_log("EIT");
> + atsc_table_header_print(parms, &eit->header);
> + const struct atsc_table_eit_event *event = eit->event;
> + uint16_t events = 0;
> + while (event) {
> + char start[255];
> + strftime(start, sizeof(start), "%F %T", &event->start);
> + dvb_log("|- event %7d", event->event_id);
> + dvb_log("| Source %d", event->source_id);
> + dvb_log("| Starttime %d", event->start_time);
> + dvb_log("| Start %s UTC", start);
> + dvb_log("| Duration %dh %dm %ds", event->duration / 3600, (event->duration % 3600) / 60, event->duration % 60);
> + dvb_log("| ETM %d", event->etm);
> + dvb_log("| title length %d", event->title_length);
> + dvb_print_descriptors(parms, event->descriptor);
> + event = event->next;
> + events++;
> + }
> + dvb_log("|_ %d events", events);
> +}
> +
> +void atsc_time(const uint32_t start_time, struct tm *tm)
> +{
> + tm->tm_sec = 0;
> + tm->tm_min = 0;
> + tm->tm_hour = 0;
> + tm->tm_mday = 6;
> + tm->tm_mon = 0;
> + tm->tm_year = 80;
> + tm->tm_isdst = -1;
> + tm->tm_wday = 0;
> + tm->tm_yday = 0;
> + mktime(tm);
> + tm->tm_sec += start_time;
> + mktime(tm);
> +}
> +
> +
> diff --git a/lib/libdvbv5/descriptors/atsc_header.c b/lib/libdvbv5/descriptors/atsc_header.c
> new file mode 100644
> index 0000000..7b31fa1
> --- /dev/null
> +++ b/lib/libdvbv5/descriptors/atsc_header.c
> @@ -0,0 +1,48 @@
> +/*
> + * Copyright (c) 2011-2012 - Mauro Carvalho Chehab <mchehab@redhat.com>
I'm not the author.
> + * Copyright (c) 2012 - 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 "descriptors/atsc_header.h"
> +#include "descriptors.h"
> +#include "dvb-fe.h"
> +
> +int atsc_table_header_init(struct atsc_table_header *t)
> +{
> + bswap16(t->bitfield);
> + bswap16(t->id);
> + return 0;
> +}
> +
> +void atsc_table_header_print(struct dvb_v5_fe_parms *parms, const struct atsc_table_header *t)
> +{
> + dvb_log("| table_id %02x", t->table_id);
> + dvb_log("| section_length %d", t->section_length);
> + dvb_log("| syntax %d", t->syntax);
> + dvb_log("| priv %d", t->priv);
> + dvb_log("| one %d", t->one);
> + dvb_log("| id %d", t->id);
> + dvb_log("| one2 %d", t->one2);
> + dvb_log("| version %d", t->version);
> + dvb_log("| current_next %d", t->current_next);
> + dvb_log("| section_id %d", t->section_id);
> + dvb_log("| last_section %d", t->last_section);
> + dvb_log("| protocol_version %d", t->protocol_version);
> +}
> +
> diff --git a/lib/libdvbv5/descriptors/eit.c b/lib/libdvbv5/descriptors/eit.c
> index e70cf3b..5ecfc00 100644
> --- a/lib/libdvbv5/descriptors/eit.c
> +++ b/lib/libdvbv5/descriptors/eit.c
> @@ -67,7 +67,7 @@ void dvb_table_eit_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize
> sizeof(event->service_id);
>
> bswap16(event->event_id);
> - bswap16(event->bitfield);
> + bswap16(event->bitfield); // FIXME: needed?
Why not needed?
> bswap16(event->bitfield2);
> event->descriptor = NULL;
> event->next = NULL;
> diff --git a/lib/libdvbv5/descriptors/mgt.c b/lib/libdvbv5/descriptors/mgt.c
> index 272d9d7..b362d51 100644
> --- a/lib/libdvbv5/descriptors/mgt.c
> +++ b/lib/libdvbv5/descriptors/mgt.c
> @@ -22,12 +22,12 @@
> #include "descriptors/mgt.h"
> #include "dvb-fe.h"
>
> -void dvb_table_mgt_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length)
> +void atsc_table_mgt_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table, ssize_t *table_length)
> {
> const uint8_t *p = buf;
> - struct dvb_table_mgt *mgt = (struct dvb_table_mgt *) table;
> + struct atsc_table_mgt *mgt = (struct atsc_table_mgt *) table;
> struct dvb_desc **head_desc;
> - struct dvb_table_mgt_table **head;
> + struct atsc_table_mgt_table **head;
> /*int desc_length;*/
>
> if (*table_length > 0) {
> @@ -39,8 +39,8 @@ void dvb_table_mgt_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize
> while (*head != NULL)
> head = &(*head)->next;
> } else {
> - memcpy(table, p, sizeof(struct dvb_table_mgt) - sizeof(mgt->descriptor) - sizeof(mgt->table));
> - *table_length = sizeof(struct dvb_table_mgt);
> + memcpy(table, p, sizeof(struct atsc_table_mgt) - sizeof(mgt->descriptor) - sizeof(mgt->table));
> + *table_length = sizeof(struct atsc_table_mgt);
Please check before copy. Also, use offset_of().
>
> mgt->descriptor = NULL;
> mgt->table = NULL;
> @@ -48,16 +48,16 @@ void dvb_table_mgt_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize
> head = &mgt->table;
> bswap16(mgt->tables);
> }
> - p += sizeof(struct dvb_table_mgt) - sizeof(mgt->descriptor) - sizeof(mgt->table);
> + p += sizeof(struct atsc_table_mgt) - sizeof(mgt->descriptor) - sizeof(mgt->table);
>
Offset_of()
> /*dvb_parse_descriptors(parms, p, desc_length, head_desc);*/
> /*p += desc_length;*/
> int i = 0;
> - struct dvb_table_mgt_table *last = NULL;
> + struct atsc_table_mgt_table *last = NULL;
Data declaration at the beginning.
> while (i++ < mgt->tables && (uint8_t *) p < buf + buflen - 4) {
> - struct dvb_table_mgt_table *table = (struct dvb_table_mgt_table *) malloc(sizeof(struct dvb_table_mgt_table));
> - memcpy(table, p, sizeof(struct dvb_table_mgt_table) - sizeof(table->descriptor) - sizeof(table->next));
> - p += sizeof(struct dvb_table_mgt_table) - sizeof(table->descriptor) - sizeof(table->next);
> + struct atsc_table_mgt_table *table = (struct atsc_table_mgt_table *) malloc(sizeof(struct atsc_table_mgt_table));
> + memcpy(table, p, sizeof(struct atsc_table_mgt_table) - sizeof(table->descriptor) - sizeof(table->next));
> + p += sizeof(struct atsc_table_mgt_table) - sizeof(table->descriptor) - sizeof(table->next);
>
Same as above: data declaration at beginning, offset_of() and check before copy.
> bswap16(table->type);
> bswap16(table->bitfield);
> @@ -80,30 +80,35 @@ void dvb_table_mgt_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize
> }
> }
>
> -void dvb_table_mgt_free(struct dvb_table_mgt *mgt)
> +void atsc_table_mgt_free(struct atsc_table_mgt *mgt)
> {
> - struct dvb_table_mgt_table *table = mgt->table;
> + struct atsc_table_mgt_table *table = mgt->table;
> dvb_free_descriptors((struct dvb_desc **) &mgt->descriptor);
> while(table) {
> dvb_free_descriptors((struct dvb_desc **) &table->descriptor);
> - struct dvb_table_mgt_table *tmp = table;
> + struct atsc_table_mgt_table *tmp = table;
Data declaration at the beginning.
> table = table->next;
> free(tmp);
> }
> free(mgt);
> }
>
> -void dvb_table_mgt_print(struct dvb_v5_fe_parms *parms, struct dvb_table_mgt *mgt)
> +void atsc_table_mgt_print(struct dvb_v5_fe_parms *parms, struct atsc_table_mgt *mgt)
> {
> dvb_log("MGT");
> - dvb_table_header_print(parms, &mgt->header);
> - dvb_log("| protocol_version %d", mgt->protocol_version);
> + atsc_table_header_print(parms, &mgt->header);
> dvb_log("| tables %d", mgt->tables);
> /*dvb_print_descriptors(parms, mgt->descriptor);*/
> - const struct dvb_table_mgt_table *table = mgt->table;
> + const struct atsc_table_mgt_table *table = mgt->table;
> uint16_t tables = 0;
> while(table) {
> - dvb_log("|- type %04x %d", table->type, table->pid);
> + dvb_log("|- type %04x %d", table->type, table->pid);
> + dvb_log("| one %d", table->one);
> + dvb_log("| one2 %d", table->one2);
> + dvb_log("| type version %d", table->type_version);
> + dvb_log("| size %d", table->size);
> + dvb_log("| one3 %d", table->one3);
> + dvb_log("| desc_length %d", table->desc_length);
> dvb_print_descriptors(parms, table->descriptor);
> table = table->next;
> tables++;
> diff --git a/lib/libdvbv5/descriptors/vct.c b/lib/libdvbv5/descriptors/vct.c
> index e567f7a..493f184 100644
> --- a/lib/libdvbv5/descriptors/vct.c
> +++ b/lib/libdvbv5/descriptors/vct.c
> @@ -23,14 +23,14 @@
> #include "dvb-fe.h"
> #include "parse_string.h"
>
> -void dvb_table_vct_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
> +void atsc_table_vct_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
> ssize_t buflen, uint8_t *table, ssize_t *table_length)
> {
> const uint8_t *p = buf, *endbuf = buf + buflen - 4;
> - struct dvb_table_vct *vct = (void *)table;
> - struct dvb_table_vct_channel **head = &vct->channel;
> + struct atsc_table_vct *vct = (void *)table;
> + struct atsc_table_vct_channel **head = &vct->channel;
> int i, n;
> - size_t size = offsetof(struct dvb_table_vct, channel);
> + size_t size = offsetof(struct atsc_table_vct, channel);
>
> if (p + size > endbuf) {
> dvb_logerr("VCT table was truncated. Need %zu bytes, but has only %zu.",
> @@ -45,16 +45,16 @@ void dvb_table_vct_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
> } else {
> memcpy(vct, p, size);
>
> - *table_length = sizeof(struct dvb_table_vct);
> + *table_length = sizeof(struct atsc_table_vct);
>
> vct->channel = NULL;
> vct->descriptor = NULL;
> }
> p += size;
>
> - size = offsetof(struct dvb_table_vct_channel, descriptor);
> + size = offsetof(struct atsc_table_vct_channel, descriptor);
> for (n = 0; n < vct->num_channels_in_section; n++) {
> - struct dvb_table_vct_channel *channel;
> + struct atsc_table_vct_channel *channel;
>
> if (p + size > endbuf) {
> dvb_logerr("VCT channel table is missing %d elements",
> @@ -63,7 +63,7 @@ void dvb_table_vct_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
> break;
> }
>
> - channel = malloc(sizeof(struct dvb_table_vct_channel));
> + channel = malloc(sizeof(struct atsc_table_vct_channel));
>
> memcpy(channel, p, size);
> p += size;
> @@ -75,7 +75,7 @@ void dvb_table_vct_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
> bswap32(channel->carrier_frequency);
> bswap16(channel->channel_tsid);
> bswap16(channel->program_number);
> - bswap16(channel->bitfield1);
> + bswap32(channel->bitfield1);
> bswap16(channel->bitfield2);
> bswap16(channel->source_id);
> bswap16(channel->bitfield3);
> @@ -104,9 +104,9 @@ void dvb_table_vct_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
> }
>
> /* Get extra descriptors */
> - size = sizeof(union dvb_table_vct_descriptor_length);
> + size = sizeof(union atsc_table_vct_descriptor_length);
> while (p + size <= endbuf) {
> - union dvb_table_vct_descriptor_length *d = (void *)p;
> + union atsc_table_vct_descriptor_length *d = (void *)p;
> bswap16(d->descriptor_length);
> p += size;
> dvb_parse_descriptors(parms, p, d->descriptor_length,
> @@ -117,12 +117,12 @@ void dvb_table_vct_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
> endbuf - p);
> }
>
> -void dvb_table_vct_free(struct dvb_table_vct *vct)
> +void atsc_table_vct_free(struct atsc_table_vct *vct)
> {
> - struct dvb_table_vct_channel *channel = vct->channel;
> + struct atsc_table_vct_channel *channel = vct->channel;
> while(channel) {
> dvb_free_descriptors((struct dvb_desc **) &channel->descriptor);
> - struct dvb_table_vct_channel *tmp = channel;
> + struct atsc_table_vct_channel *tmp = channel;
> channel = channel->next;
> free(tmp);
> }
> @@ -131,19 +131,19 @@ void dvb_table_vct_free(struct dvb_table_vct *vct)
> free(vct);
> }
>
> -void dvb_table_vct_print(struct dvb_v5_fe_parms *parms, struct dvb_table_vct *vct)
> +void atsc_table_vct_print(struct dvb_v5_fe_parms *parms, struct atsc_table_vct *vct)
> {
> - if (vct->header.table_id == DVB_TABLE_CVCT)
> + if (vct->header.table_id == ATSC_TABLE_CVCT)
> dvb_log("CVCT");
> else
> dvb_log("TVCT");
>
> - dvb_table_header_print(parms, &vct->header);
> + atsc_table_header_print(parms, &vct->header);
>
> dvb_log("|- Protocol version %d", vct->ATSC_protocol_version);
> dvb_log("|- #channels %d", vct->num_channels_in_section);
> dvb_log("|\\ channel_id");
> - const struct dvb_table_vct_channel *channel = vct->channel;
> + const struct atsc_table_vct_channel *channel = vct->channel;
> uint16_t channels = 0;
> while(channel) {
> dvb_log("|- Channel %d.%d: %s",
> @@ -159,7 +159,7 @@ void dvb_table_vct_print(struct dvb_v5_fe_parms *parms, struct dvb_table_vct *vc
> dvb_log("| access controlled %d", channel->access_controlled);
> dvb_log("| hidden %d", channel->hidden);
>
> - if (vct->header.table_id == DVB_TABLE_CVCT) {
> + if (vct->header.table_id == ATSC_TABLE_CVCT) {
> dvb_log("| path select %d", channel->path_select);
> dvb_log("| out of band %d", channel->out_of_band);
> }
> @@ -173,4 +173,3 @@ void dvb_table_vct_print(struct dvb_v5_fe_parms *parms, struct dvb_table_vct *vc
> }
> dvb_log("|_ %d channels", channels);
> }
> -
> diff --git a/lib/libdvbv5/dvb-file.c b/lib/libdvbv5/dvb-file.c
> index b6fdc04..9abb1f7 100644
> --- a/lib/libdvbv5/dvb-file.c
> +++ b/lib/libdvbv5/dvb-file.c
> @@ -1027,7 +1027,7 @@ int store_dvb_channel(struct dvb_file **dvb_file,
> }
>
> if (dvb_scan_handler->vct) {
> - dvb_vct_channel_foreach(d, dvb_scan_handler->vct) {
> + atsc_vct_channel_foreach(d, dvb_scan_handler->vct) {
> char *channel = NULL;
> char *vchannel = NULL;
>
> diff --git a/lib/libdvbv5/dvb-scan.c b/lib/libdvbv5/dvb-scan.c
> index 421434e..bd9d2fb 100644
> --- a/lib/libdvbv5/dvb-scan.c
> +++ b/lib/libdvbv5/dvb-scan.c
> @@ -271,7 +271,7 @@ void dvb_scan_free_handler_table(struct dvb_v5_descriptors *dvb_scan_handler)
> if (dvb_scan_handler->pat)
> dvb_table_pat_free(dvb_scan_handler->pat);
> if (dvb_scan_handler->vct)
> - dvb_table_vct_free(dvb_scan_handler->vct);
> + atsc_table_vct_free(dvb_scan_handler->vct);
> if (dvb_scan_handler->nit)
> dvb_table_nit_free(dvb_scan_handler->nit);
> if (dvb_scan_handler->sdt)
> @@ -329,14 +329,14 @@ struct dvb_v5_descriptors *dvb_get_ts_tables(struct dvb_v5_fe_parms *parms,
> nit_time = 12;
> break;
> case SYS_ATSC:
> - atsc_filter = DVB_TABLE_TVCT;
> + atsc_filter = ATSC_TABLE_TVCT;
> pat_pmt_time = 2;
> vct_time = 2;
> sdt_time = 5;
> nit_time = 5;
> break;
> case SYS_DVBC_ANNEX_B:
> - atsc_filter = DVB_TABLE_CVCT;
> + atsc_filter = ATSC_TABLE_CVCT;
> pat_pmt_time = 2;
> vct_time = 2;
> sdt_time = 5;
> @@ -367,7 +367,7 @@ struct dvb_v5_descriptors *dvb_get_ts_tables(struct dvb_v5_fe_parms *parms,
> /* ATSC-specific VCT table */
> if (atsc_filter) {
> rc = dvb_read_section(parms, dmx_fd,
> - atsc_filter, DVB_TABLE_VCT_PID,
> + atsc_filter, ATSC_TABLE_VCT_PID,
> (uint8_t **)&dvb_scan_handler->vct,
> vct_time * timeout_multiply);
> if (parms->abort)
> @@ -375,7 +375,7 @@ struct dvb_v5_descriptors *dvb_get_ts_tables(struct dvb_v5_fe_parms *parms,
> if (rc < 0)
> dvb_logerr("error while waiting for VCT table");
> else if (parms->verbose)
> - dvb_table_vct_print(parms, dvb_scan_handler->vct);
> + atsc_table_vct_print(parms, dvb_scan_handler->vct);
> }
>
> /* PMT tables */
The better is to split the data renames on a separate patch.
I don't like to rename it at the library, as others might be using
the library with the old names. So, we may need to add a compat code
for those using the legacy names.
--
Cheers,
Mauro
^ permalink raw reply [flat|nested] 26+ messages in thread
end of thread, other threads:[~2013-12-29 4:12 UTC | newest]
Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-28 15:45 [PATCH 01/13] libdvbv5: fix reading multisection tables André Roth
2013-12-28 15:45 ` [PATCH 02/13] libdvbv5: ATSC VCT table support André Roth
2013-12-29 3:04 ` Mauro Carvalho Chehab
2013-12-28 15:45 ` [PATCH 03/13] libdvbv5: mpeg elementary stream parsers André Roth
2013-12-29 3:34 ` Mauro Carvalho Chehab
2013-12-28 15:45 ` [PATCH 04/13] libdvbv5: fix deadlock on missing table sections André Roth
2013-12-29 3:25 ` Mauro Carvalho Chehab
2013-12-28 15:45 ` [PATCH 05/13] libdvbv5: eit parsing updated André Roth
2013-12-29 3:40 ` Mauro Carvalho Chehab
2013-12-28 15:45 ` [PATCH 06/13] libdvbv5: fix eit times André Roth
2013-12-29 3:42 ` Mauro Carvalho Chehab
2013-12-28 15:45 ` [PATCH 07/13] libdvbv5: MGT parser André Roth
2013-12-29 3:49 ` Mauro Carvalho Chehab
2013-12-28 15:45 ` [PATCH 08/13] libdvbv5: ATSC EIT André Roth
2013-12-29 3:58 ` Mauro Carvalho Chehab
2013-12-28 15:45 ` [PATCH 09/13] libdvbv5: fix section counting André Roth
2013-12-29 3:42 ` Mauro Carvalho Chehab
2013-12-28 15:45 ` [PATCH 10/13] libdvbv5: cleanup coding style André Roth
2013-12-29 3:44 ` Mauro Carvalho Chehab
2013-12-28 15:45 ` [PATCH 11/13] libdvbv5: fix double entry in Makefile.am André Roth
2013-12-29 3:45 ` Mauro Carvalho Chehab
2013-12-28 15:46 ` [PATCH 12/13] libdvbv5: fix missing includes André Roth
2013-12-29 3:44 ` Mauro Carvalho Chehab
2013-12-28 15:46 ` [PATCH 13/13] libdvbv5: improve TS parsing André Roth
2013-12-29 3:47 ` Mauro Carvalho Chehab
2013-12-29 2:53 ` [PATCH 01/13] libdvbv5: fix reading multisection tables Mauro Carvalho Chehab
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).