* [PATCH 01/18] libdvbv5: fix reading multisection tables
@ 2013-12-30 12:48 André Roth
2013-12-30 12:48 ` [PATCH 02/18] libdvbv5: service location descriptor support André Roth
` (16 more replies)
0 siblings, 17 replies; 29+ messages in thread
From: André Roth @ 2013-12-30 12:48 UTC (permalink / raw)
To: linux-media; +Cc: André Roth
Signed-off-by: André Roth <neolynx@gmail.com>
---
lib/libdvbv5/dvb-scan.c | 36 +++++++++++++++++++++++-------------
1 file changed, 23 insertions(+), 13 deletions(-)
diff --git a/lib/libdvbv5/dvb-scan.c b/lib/libdvbv5/dvb-scan.c
index e9ccc72..520bf9c 100644
--- a/lib/libdvbv5/dvb-scan.c
+++ b/lib/libdvbv5/dvb-scan.c
@@ -96,9 +96,13 @@ 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;
+ /*int table_id = -1;*/
int sections = 0;
struct dmx_sct_filter_params f;
struct dvb_table_header *h;
@@ -108,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;
@@ -185,24 +188,27 @@ 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;
- } 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;
- }
}
+ /*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)
+ if (last_section == -1 || h->last_section > last_section)
last_section = h->last_section;
if (!tbl) {
@@ -228,10 +234,14 @@ 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);
+
+ if (buf)
+ free(buf);
dvb_dmx_stop(dmx_fd);
--
1.8.3.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 02/18] libdvbv5: service location descriptor support
2013-12-30 12:48 [PATCH 01/18] libdvbv5: fix reading multisection tables André Roth
@ 2013-12-30 12:48 ` André Roth
2014-01-07 16:38 ` Mauro Carvalho Chehab
2013-12-30 12:48 ` [PATCH 03/18] libdvbv5: VCT table cleanup André Roth
` (15 subsequent siblings)
16 siblings, 1 reply; 29+ messages in thread
From: André Roth @ 2013-12-30 12:48 UTC (permalink / raw)
To: linux-media; +Cc: André Roth
Implement the service location descriptor (0xa1), and small cleanups.
Signed-off-by: André Roth <neolynx@gmail.com>
---
lib/include/descriptors.h | 4 +-
lib/include/descriptors/desc_service_location.h | 69 +++++++++++++++++++++++
lib/libdvbv5/Makefile.am | 3 +-
lib/libdvbv5/descriptors.c | 2 +-
lib/libdvbv5/descriptors/desc_service_location.c | 70 ++++++++++++++++++++++++
5 files changed, 145 insertions(+), 3 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..89ed055
--- /dev/null
+++ b/lib/include/descriptors/desc_service_location.h
@@ -0,0 +1,69 @@
+/*
+ * 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 _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/libdvbv5/Makefile.am b/lib/libdvbv5/Makefile.am
index 2ad5902..80e8adb 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/eit.c ../include/descriptors/eit.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..3759665
--- /dev/null
+++ b/lib/libdvbv5/descriptors/desc_service_location.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013 - Andre Roth <neolynx@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation version 2
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+ *
+ */
+
+#include "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);
+}
+
--
1.8.3.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 03/18] libdvbv5: VCT table cleanup
2013-12-30 12:48 [PATCH 01/18] libdvbv5: fix reading multisection tables André Roth
2013-12-30 12:48 ` [PATCH 02/18] libdvbv5: service location descriptor support André Roth
@ 2013-12-30 12:48 ` André Roth
2013-12-30 12:48 ` [PATCH 04/18] libdvbv5: mpeg elementary stream parsers André Roth
` (14 subsequent siblings)
16 siblings, 0 replies; 29+ messages in thread
From: André Roth @ 2013-12-30 12:48 UTC (permalink / raw)
To: linux-media; +Cc: André Roth
Signed-off-by: André Roth <neolynx@gmail.com>
---
lib/include/descriptors/vct.h | 10 ++++++----
lib/libdvbv5/descriptors/vct.c | 3 ++-
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/lib/include/descriptors/vct.h b/lib/include/descriptors/vct.h
index 6272b43..2d269dc 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) 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,14 +36,14 @@ struct dvb_table_vct_channel {
uint16_t __short_name[7];
union {
- uint16_t bitfield1;
+ 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;
@@ -60,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;
@@ -68,7 +70,7 @@ 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
diff --git a/lib/libdvbv5/descriptors/vct.c b/lib/libdvbv5/descriptors/vct.c
index e703c52..c1578ad 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
@@ -74,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);
--
1.8.3.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 04/18] libdvbv5: mpeg elementary stream parsers
2013-12-30 12:48 [PATCH 01/18] libdvbv5: fix reading multisection tables André Roth
2013-12-30 12:48 ` [PATCH 02/18] libdvbv5: service location descriptor support André Roth
2013-12-30 12:48 ` [PATCH 03/18] libdvbv5: VCT table cleanup André Roth
@ 2013-12-30 12:48 ` André Roth
2014-01-07 16:47 ` Mauro Carvalho Chehab
2013-12-30 12:48 ` [PATCH 05/18] libdvbv5: fix NIT structures André Roth
` (13 subsequent siblings)
16 siblings, 1 reply; 29+ messages in thread
From: André Roth @ 2013-12-30 12:48 UTC (permalink / raw)
To: linux-media; +Cc: André Roth
Implement parsers for mpeg TS, PES and ES
Signed-off-by: André Roth <neolynx@gmail.com>
---
lib/include/descriptors/mpeg_es.h | 109 ++++++++++++++++++++++++++++++
lib/include/descriptors/mpeg_pes.h | 111 ++++++++++++++++++++++++++++++
lib/include/descriptors/mpeg_ts.h | 78 +++++++++++++++++++++
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 +++++++++++++++++++++
7 files changed, 586 insertions(+), 1 deletion(-)
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..4c6a862
--- /dev/null
+++ b/lib/include/descriptors/mpeg_es.h
@@ -0,0 +1,109 @@
+/*
+ * 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 _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..3a3f8e4
--- /dev/null
+++ b/lib/include/descriptors/mpeg_pes.h
@@ -0,0 +1,111 @@
+/*
+ * 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 _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..54fee69
--- /dev/null
+++ b/lib/include/descriptors/mpeg_ts.h
@@ -0,0 +1,78 @@
+/*
+ * 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 _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/libdvbv5/Makefile.am b/lib/libdvbv5/Makefile.am
index 80e8adb..33693cc 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/eit.c ../include/descriptors/eit.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..9fcb5ca
--- /dev/null
+++ b/lib/libdvbv5/descriptors/mpeg_es.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013 - Andre Roth <neolynx@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation version 2
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+ *
+ */
+
+#include "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..1b518a3
--- /dev/null
+++ b/lib/libdvbv5/descriptors/mpeg_pes.c
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2013 - Andre Roth <neolynx@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation version 2
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+ *
+ */
+
+#include "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..d7ec2c4
--- /dev/null
+++ b/lib/libdvbv5/descriptors/mpeg_ts.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013 - Andre Roth <neolynx@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation version 2
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+ *
+ */
+
+#include "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] 29+ messages in thread
* [PATCH 05/18] libdvbv5: fix NIT structures
2013-12-30 12:48 [PATCH 01/18] libdvbv5: fix reading multisection tables André Roth
` (2 preceding siblings ...)
2013-12-30 12:48 ` [PATCH 04/18] libdvbv5: mpeg elementary stream parsers André Roth
@ 2013-12-30 12:48 ` André Roth
2013-12-30 12:48 ` [PATCH 06/18] libdvbv5: implement dvb_fe_dummy for logging André Roth
` (12 subsequent siblings)
16 siblings, 0 replies; 29+ messages in thread
From: André Roth @ 2013-12-30 12:48 UTC (permalink / raw)
To: linux-media; +Cc: André Roth
Signed-off-by: André Roth <neolynx@gmail.com>
---
lib/include/descriptors/nit.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
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;
--
1.8.3.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 06/18] libdvbv5: implement dvb_fe_dummy for logging
2013-12-30 12:48 [PATCH 01/18] libdvbv5: fix reading multisection tables André Roth
` (3 preceding siblings ...)
2013-12-30 12:48 ` [PATCH 05/18] libdvbv5: fix NIT structures André Roth
@ 2013-12-30 12:48 ` André Roth
2013-12-30 12:48 ` [PATCH 07/18] libdvbv5: fix EIT parsing André Roth
` (11 subsequent siblings)
16 siblings, 0 replies; 29+ messages in thread
From: André Roth @ 2013-12-30 12:48 UTC (permalink / raw)
To: linux-media; +Cc: André Roth
The dvbv5 functions use the dvb_v5_fe_parms struct for logging.
This struct is normally obtained by opening a dvb device. For
situations where the opening of a dvb device is not desired,
the dvb_fe_dummy can be used.
Signed-off-by: André Roth <neolynx@gmail.com>
---
lib/include/descriptors.h | 6 ++++++
lib/include/dvb-fe.h | 2 ++
lib/libdvbv5/descriptors.c | 2 ++
lib/libdvbv5/dvb-fe.c | 7 +++++++
4 files changed, 17 insertions(+)
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/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..bc3d51a 100644
--- a/lib/libdvbv5/descriptors.c
+++ b/lib/libdvbv5/descriptors.c
@@ -69,6 +69,8 @@ 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/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)
{
--
1.8.3.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 07/18] libdvbv5: fix EIT parsing
2013-12-30 12:48 [PATCH 01/18] libdvbv5: fix reading multisection tables André Roth
` (4 preceding siblings ...)
2013-12-30 12:48 ` [PATCH 06/18] libdvbv5: implement dvb_fe_dummy for logging André Roth
@ 2013-12-30 12:48 ` André Roth
2014-01-07 17:00 ` Mauro Carvalho Chehab
2013-12-30 12:48 ` [PATCH 08/18] libdvbv5: implement MGT parser André Roth
` (10 subsequent siblings)
16 siblings, 1 reply; 29+ messages in thread
From: André Roth @ 2013-12-30 12:48 UTC (permalink / raw)
To: linux-media; +Cc: André Roth
the dvb_table_eit_event now contains the service_id,
indicating where the events belong to.
Signed-off-by: André Roth <neolynx@gmail.com>
---
lib/include/descriptors/eit.h | 3 ++-
lib/libdvbv5/descriptors/eit.c | 35 ++++++++++++++++++++++++++---------
2 files changed, 28 insertions(+), 10 deletions(-)
diff --git a/lib/include/descriptors/eit.h b/lib/include/descriptors/eit.h
index 2af9696..ca08fd4 100644
--- a/lib/include/descriptors/eit.h
+++ b/lib/include/descriptors/eit.h
@@ -40,7 +40,7 @@
struct dvb_table_eit_event {
uint16_t event_id;
union {
- uint16_t bitfield;
+ uint16_t bitfield1; /* first 2 bytes are MJD, they need to be bswapped */
uint8_t dvbstart[5];
} __attribute__((packed));
uint8_t dvbduration[3];
@@ -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/libdvbv5/descriptors/eit.c b/lib/libdvbv5/descriptors/eit.c
index ccfe1a6..c2d01c3 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,18 +53,30 @@ 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);
+ bswap16(event->bitfield1);
bswap16(event->bitfield2);
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);
@@ -137,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] 29+ messages in thread
* [PATCH 08/18] libdvbv5: implement MGT parser
2013-12-30 12:48 [PATCH 01/18] libdvbv5: fix reading multisection tables André Roth
` (5 preceding siblings ...)
2013-12-30 12:48 ` [PATCH 07/18] libdvbv5: fix EIT parsing André Roth
@ 2013-12-30 12:48 ` André Roth
2014-01-07 17:05 ` Mauro Carvalho Chehab
2013-12-30 12:48 ` [PATCH 09/18] libdvbv5: implement ATSC EIT André Roth
` (9 subsequent siblings)
16 siblings, 1 reply; 29+ messages in thread
From: André Roth @ 2013-12-30 12:48 UTC (permalink / raw)
To: linux-media; +Cc: André Roth
Signed-off-by: André Roth <neolynx@gmail.com>
---
lib/include/descriptors/mgt.h | 80 ++++++++++++++++++++++++++++
lib/libdvbv5/Makefile.am | 1 +
lib/libdvbv5/descriptors.c | 2 +
lib/libdvbv5/descriptors/mgt.c | 117 +++++++++++++++++++++++++++++++++++++++++
4 files changed, 200 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..9eaac02
--- /dev/null
+++ b/lib/include/descriptors/mgt.h
@@ -0,0 +1,80 @@
+/*
+ * 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/atsc_header.h"
+#include "descriptors.h"
+
+#define ATSC_TABLE_MGT 0xC7
+
+struct atsc_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 atsc_table_mgt_table *next;
+} __attribute__((packed));
+
+struct atsc_table_mgt {
+ struct atsc_table_header header;
+ uint16_t tables;
+ struct atsc_table_mgt_table *table;
+ struct dvb_desc *descriptor;
+} __attribute__((packed));
+
+
+#define atsc_mgt_table_foreach( _tran, _mgt ) \
+ for( struct atsc_table_mgt_table *_tran = _mgt->table; _tran; _tran = _tran->next ) \
+
+struct dvb_v5_fe_parms;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+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
+}
+#endif
+
+#endif
diff --git a/lib/libdvbv5/Makefile.am b/lib/libdvbv5/Makefile.am
index 33693cc..7755e05 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/eit.c ../include/descriptors/eit.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 bc3d51a..7b9e9d0 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"
@@ -84,6 +85,7 @@ const struct dvb_table_init dvb_table_initializers[] = {
[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_EIT_SCHEDULE] = { dvb_table_eit_init, sizeof(struct dvb_table_eit) },
+ [ATSC_TABLE_MGT] = { atsc_table_mgt_init, sizeof(struct atsc_table_mgt) },
};
char *default_charset = "iso-8859-1";
diff --git a/lib/libdvbv5/descriptors/mgt.c b/lib/libdvbv5/descriptors/mgt.c
new file mode 100644
index 0000000..09d1cf2
--- /dev/null
+++ b/lib/libdvbv5/descriptors/mgt.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2013 - Andre Roth <neolynx@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation version 2
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+ *
+ */
+
+#include "descriptors/mgt.h"
+#include "dvb-fe.h"
+
+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 atsc_table_mgt *mgt = (struct atsc_table_mgt *) table;
+ struct dvb_desc **head_desc;
+ struct atsc_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 atsc_table_mgt) - sizeof(mgt->descriptor) - sizeof(mgt->table));
+ *table_length = sizeof(struct atsc_table_mgt);
+
+ mgt->descriptor = NULL;
+ mgt->table = NULL;
+ head_desc = &mgt->descriptor;
+ head = &mgt->table;
+ bswap16(mgt->tables);
+ }
+ 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 atsc_table_mgt_table *last = NULL;
+ while (i++ < mgt->tables && (uint8_t *) p < buf + buflen - 4) {
+ 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);
+ 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 atsc_table_mgt_free(struct atsc_table_mgt *mgt)
+{
+ 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 atsc_table_mgt_table *tmp = table;
+ table = table->next;
+ free(tmp);
+ }
+ free(mgt);
+}
+
+void atsc_table_mgt_print(struct dvb_v5_fe_parms *parms, struct atsc_table_mgt *mgt)
+{
+ dvb_log("MGT");
+ atsc_table_header_print(parms, &mgt->header);
+ dvb_log("| tables %d", mgt->tables);
+ /*dvb_print_descriptors(parms, mgt->descriptor);*/
+ 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("| 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++;
+ }
+ dvb_log("|_ %d tables", tables);
+}
+
--
1.8.3.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 09/18] libdvbv5: implement ATSC EIT
2013-12-30 12:48 [PATCH 01/18] libdvbv5: fix reading multisection tables André Roth
` (6 preceding siblings ...)
2013-12-30 12:48 ` [PATCH 08/18] libdvbv5: implement MGT parser André Roth
@ 2013-12-30 12:48 ` André Roth
2014-01-07 17:12 ` Mauro Carvalho Chehab
2013-12-30 12:48 ` [PATCH 10/18] libdvbv5: prefix VCT with atsc_ instead of dvb_ André Roth
` (8 subsequent siblings)
16 siblings, 1 reply; 29+ messages in thread
From: André Roth @ 2013-12-30 12:48 UTC (permalink / raw)
To: linux-media; +Cc: André Roth
Signed-off-by: André Roth <neolynx@gmail.com>
---
lib/include/descriptors/atsc_eit.h | 90 +++++++++++++++++++++
| 63 +++++++++++++++
lib/libdvbv5/Makefile.am | 4 +-
lib/libdvbv5/descriptors.c | 2 +
lib/libdvbv5/descriptors/atsc_eit.c | 142 +++++++++++++++++++++++++++++++++
| 47 +++++++++++
6 files changed, 347 insertions(+), 1 deletion(-)
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..3bc5df6
--- /dev/null
+++ b/lib/include/descriptors/atsc_eit.h
@@ -0,0 +1,90 @@
+/*
+ * 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 _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..1e7148e
--- /dev/null
+++ b/lib/include/descriptors/atsc_header.h
@@ -0,0 +1,63 @@
+/*
+ * 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 _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/libdvbv5/Makefile.am b/lib/libdvbv5/Makefile.am
index 7755e05..6771d24 100644
--- a/lib/libdvbv5/Makefile.am
+++ b/lib/libdvbv5/Makefile.am
@@ -48,8 +48,10 @@ 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/atsc_header.c ../include/descriptors/atsc_header.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 7b9e9d0..737acfa 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"
@@ -86,6 +87,7 @@ const struct dvb_table_init dvb_table_initializers[] = {
[DVB_TABLE_CVCT] = { dvb_table_vct_init, sizeof(struct dvb_table_vct) },
[DVB_TABLE_EIT_SCHEDULE] = { dvb_table_eit_init, sizeof(struct dvb_table_eit) },
[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";
diff --git a/lib/libdvbv5/descriptors/atsc_eit.c b/lib/libdvbv5/descriptors/atsc_eit.c
new file mode 100644
index 0000000..4ee38ae
--- /dev/null
+++ b/lib/libdvbv5/descriptors/atsc_eit.c
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2013 - Andre Roth <neolynx@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation version 2
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+ *
+ */
+
+#include "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..ed152ce
--- /dev/null
+++ b/lib/libdvbv5/descriptors/atsc_header.c
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2013 - Andre Roth <neolynx@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation version 2
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+ *
+ */
+
+#include "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);
+}
+
--
1.8.3.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 10/18] libdvbv5: prefix VCT with atsc_ instead of dvb_
2013-12-30 12:48 [PATCH 01/18] libdvbv5: fix reading multisection tables André Roth
` (7 preceding siblings ...)
2013-12-30 12:48 ` [PATCH 09/18] libdvbv5: implement ATSC EIT André Roth
@ 2013-12-30 12:48 ` André Roth
2013-12-30 12:48 ` [PATCH 11/18] libdvbv5: cleanup coding style André Roth
` (7 subsequent siblings)
16 siblings, 0 replies; 29+ messages in thread
From: André Roth @ 2013-12-30 12:48 UTC (permalink / raw)
To: linux-media; +Cc: André Roth
Signed-off-by: André Roth <neolynx@gmail.com>
---
lib/include/descriptors/vct.h | 30 +++++++++++++++---------------
lib/include/dvb-scan.h | 2 +-
lib/libdvbv5/descriptors.c | 16 ++++++++--------
lib/libdvbv5/descriptors/vct.c | 37 ++++++++++++++++++-------------------
lib/libdvbv5/dvb-file.c | 2 +-
lib/libdvbv5/dvb-scan.c | 10 +++++-----
6 files changed, 48 insertions(+), 49 deletions(-)
diff --git a/lib/include/descriptors/vct.h b/lib/include/descriptors/vct.h
index 2d269dc..f3dad6c 100644
--- a/lib/include/descriptors/vct.h
+++ b/lib/include/descriptors/vct.h
@@ -25,14 +25,14 @@
#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 {
@@ -77,15 +77,15 @@ struct dvb_table_vct_channel {
* 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;
@@ -94,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;
@@ -107,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;
@@ -116,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/descriptors.c b/lib/libdvbv5/descriptors.c
index 737acfa..226349e 100644
--- a/lib/libdvbv5/descriptors.c
+++ b/lib/libdvbv5/descriptors.c
@@ -78,16 +78,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_MGT] = { atsc_table_mgt_init, sizeof(struct atsc_table_mgt) },
[ATSC_TABLE_EIT] = { atsc_table_eit_init, sizeof(struct atsc_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) },
};
char *default_charset = "iso-8859-1";
@@ -1359,6 +1359,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/vct.c b/lib/libdvbv5/descriptors/vct.c
index c1578ad..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;
@@ -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 520bf9c..6f3def6 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] 29+ messages in thread
* [PATCH 11/18] libdvbv5: cleanup coding style
2013-12-30 12:48 [PATCH 01/18] libdvbv5: fix reading multisection tables André Roth
` (8 preceding siblings ...)
2013-12-30 12:48 ` [PATCH 10/18] libdvbv5: prefix VCT with atsc_ instead of dvb_ André Roth
@ 2013-12-30 12:48 ` André Roth
2014-01-07 17:23 ` Mauro Carvalho Chehab
2013-12-30 12:48 ` [PATCH 12/18] libdvbv5: fix missing includes André Roth
` (6 subsequent siblings)
16 siblings, 1 reply; 29+ messages in thread
From: André Roth @ 2013-12-30 12:48 UTC (permalink / raw)
To: linux-media; +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 226349e..f46aa4a 100644
--- a/lib/libdvbv5/descriptors.c
+++ b/lib/libdvbv5/descriptors.c
@@ -1359,6 +1359,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 1b518a3..98364a3 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] 29+ messages in thread
* [PATCH 12/18] libdvbv5: fix missing includes
2013-12-30 12:48 [PATCH 01/18] libdvbv5: fix reading multisection tables André Roth
` (9 preceding siblings ...)
2013-12-30 12:48 ` [PATCH 11/18] libdvbv5: cleanup coding style André Roth
@ 2013-12-30 12:48 ` André Roth
2013-12-30 12:48 ` [PATCH 13/18] libdvbv5: improve TS parsing André Roth
` (5 subsequent siblings)
16 siblings, 0 replies; 29+ messages in thread
From: André Roth @ 2013-12-30 12:48 UTC (permalink / raw)
To: linux-media; +Cc: André Roth
Signed-off-by: André Roth <neolynx@gmail.com>
---
lib/libdvbv5/dvb-file.c | 1 +
lib/libdvbv5/dvb-sat.c | 3 ++-
lib/libdvbv5/dvb-scan.c | 1 +
lib/libdvbv5/parse_string.c | 1 +
4 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/lib/libdvbv5/dvb-file.c b/lib/libdvbv5/dvb-file.c
index 9abb1f7..1e41fbb 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..09eb4d1 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"
@@ -302,7 +303,7 @@ static int dvbsat_diseqc_set_input(struct dvb_v5_fe_parms *parms, uint16_t t)
rc = dvb_fe_sec_voltage(parms, 1, vol_high);
if (rc)
return rc;
-
+
if (parms->sat_number > 0) {
rc = dvb_fe_sec_tone(parms, SEC_TONE_OFF);
if (rc)
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..5ae5a18 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] 29+ messages in thread
* [PATCH 13/18] libdvbv5: improve TS parsing
2013-12-30 12:48 [PATCH 01/18] libdvbv5: fix reading multisection tables André Roth
` (10 preceding siblings ...)
2013-12-30 12:48 ` [PATCH 12/18] libdvbv5: fix missing includes André Roth
@ 2013-12-30 12:48 ` André Roth
2014-01-07 17:27 ` Mauro Carvalho Chehab
2013-12-30 12:48 ` [PATCH 14/18] libdvbv5: cleanup dvb_nit_transport_foreach macro André Roth
` (4 subsequent siblings)
16 siblings, 1 reply; 29+ messages in thread
From: André Roth @ 2013-12-30 12:48 UTC (permalink / raw)
To: linux-media; +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 54fee69..de4fc3f 100644
--- a/lib/include/descriptors/mpeg_ts.h
+++ b/lib/include/descriptors/mpeg_ts.h
@@ -38,7 +38,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 {
@@ -67,7 +67,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 d7ec2c4..b06cdf7 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] 29+ messages in thread
* [PATCH 14/18] libdvbv5: cleanup dvb_nit_transport_foreach macro
2013-12-30 12:48 [PATCH 01/18] libdvbv5: fix reading multisection tables André Roth
` (11 preceding siblings ...)
2013-12-30 12:48 ` [PATCH 13/18] libdvbv5: improve TS parsing André Roth
@ 2013-12-30 12:48 ` André Roth
2013-12-30 12:48 ` [PATCH 15/18] libdvbv5: remove c99 comments André Roth
` (3 subsequent siblings)
16 siblings, 0 replies; 29+ messages in thread
From: André Roth @ 2013-12-30 12:48 UTC (permalink / raw)
To: linux-media; +Cc: André Roth
Signed-off-by: André Roth <neolynx@gmail.com>
---
lib/include/descriptors/nit.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/include/descriptors/nit.h b/lib/include/descriptors/nit.h
index d71a762..4f19c5e 100644
--- a/lib/include/descriptors/nit.h
+++ b/lib/include/descriptors/nit.h
@@ -76,8 +76,8 @@ typedef void nit_tran_handler_callback_t(struct dvb_table_nit *nit,
struct dvb_desc *desc,
void *priv);
- #define dvb_nit_transport_foreach( tran, nit ) \
- for (struct dvb_table_nit_transport *tran = nit->transport; tran; tran = tran->next) \
+#define dvb_nit_transport_foreach( _tran, _nit ) \
+ for (struct dvb_table_nit_transport *_tran = _nit->transport; _tran; _tran = _tran->next) \
struct dvb_v5_fe_parms;
--
1.8.3.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 15/18] libdvbv5: remove c99 comments
2013-12-30 12:48 [PATCH 01/18] libdvbv5: fix reading multisection tables André Roth
` (12 preceding siblings ...)
2013-12-30 12:48 ` [PATCH 14/18] libdvbv5: cleanup dvb_nit_transport_foreach macro André Roth
@ 2013-12-30 12:48 ` André Roth
2014-01-07 17:29 ` Mauro Carvalho Chehab
2013-12-30 12:48 ` [PATCH 17/18] libdvbv5: remove header files from SOURCES in Makefile.am André Roth
` (2 subsequent siblings)
16 siblings, 1 reply; 29+ messages in thread
From: André Roth @ 2013-12-30 12:48 UTC (permalink / raw)
To: linux-media; +Cc: André Roth
Signed-off-by: André Roth <neolynx@gmail.com>
---
lib/libdvbv5/descriptors/atsc_eit.c | 2 +-
lib/libdvbv5/descriptors/desc_service_list.c | 4 +++-
lib/libdvbv5/descriptors/desc_service_location.c | 2 +-
lib/libdvbv5/dvb-file.c | 21 +++++++++++----------
lib/libdvbv5/dvb-log.c | 2 +-
lib/libdvbv5/dvb-sat.c | 2 --
lib/libdvbv5/dvb-scan.c | 4 ++--
7 files changed, 19 insertions(+), 18 deletions(-)
diff --git a/lib/libdvbv5/descriptors/atsc_eit.c b/lib/libdvbv5/descriptors/atsc_eit.c
index 4ee38ae..8d3791d 100644
--- a/lib/libdvbv5/descriptors/atsc_eit.c
+++ b/lib/libdvbv5/descriptors/atsc_eit.c
@@ -68,7 +68,7 @@ void atsc_table_eit_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssiz
atsc_time(event->start_time, &event->start);
event->source_id = eit->header.id;
- //FIXME: title
+ /* FIXME: title */
p += event->title_length - 1;
if(!*head)
diff --git a/lib/libdvbv5/descriptors/desc_service_list.c b/lib/libdvbv5/descriptors/desc_service_list.c
index ab91622..18aa313 100644
--- a/lib/libdvbv5/descriptors/desc_service_list.c
+++ b/lib/libdvbv5/descriptors/desc_service_list.c
@@ -23,6 +23,8 @@
#include "descriptors.h"
#include "dvb-fe.h"
+/* FIXME: implement */
+
void dvb_desc_service_list_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, struct dvb_desc *desc)
{
/*struct dvb_desc_service_list *slist = (struct dvb_desc_service_list *) desc;*/
@@ -38,7 +40,7 @@ void dvb_desc_service_list_init(struct dvb_v5_fe_parms *parms, const uint8_t *bu
/*}*/
/*return sizeof(struct dvb_desc_service_list) + slist->length + sizeof(struct dvb_desc_service_list_table);*/
- //FIXME: make linked list
+ /* FIXME: make linked list */
}
void dvb_desc_service_list_print(struct dvb_v5_fe_parms *parms, const struct dvb_desc *desc)
diff --git a/lib/libdvbv5/descriptors/desc_service_location.c b/lib/libdvbv5/descriptors/desc_service_location.c
index 3759665..b205428 100644
--- a/lib/libdvbv5/descriptors/desc_service_location.c
+++ b/lib/libdvbv5/descriptors/desc_service_location.c
@@ -36,7 +36,7 @@ void dvb_desc_service_location_init(struct dvb_v5_fe_parms *parms, const uint8_t
bswap16(service_location->bitfield);
- // FIXME: handle elements == 0
+ /* 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;
diff --git a/lib/libdvbv5/dvb-file.c b/lib/libdvbv5/dvb-file.c
index 1e41fbb..de19dc5 100644
--- a/lib/libdvbv5/dvb-file.c
+++ b/lib/libdvbv5/dvb-file.c
@@ -784,20 +784,21 @@ static char *dvb_vchannel(struct dvb_table_nit *nit, uint16_t service_id)
if (!nit)
return NULL;
-for( struct dvb_desc_logical_channel *desc = (struct dvb_desc_logical_channel *) nit->descriptor; desc; desc = (struct dvb_desc_logical_channel *) desc->next ) \
+ /* FIXME: use dvb_desc_find(struct dvb_desc_logical_channel, desc, nit, logical_channel_number_descriptor) { */
+ for( struct dvb_desc_logical_channel *desc = (struct dvb_desc_logical_channel *) nit->descriptor; desc; desc = (struct dvb_desc_logical_channel *) desc->next ) {
if(desc->type == logical_channel_number_descriptor) {
-// dvb_desc_find(struct dvb_desc_logical_channel, desc, nit, logical_channel_number_descriptor) {
- struct dvb_desc_logical_channel *d = (void *)desc;
+ struct dvb_desc_logical_channel *d = (void *)desc;
- size_t len;
+ size_t len;
- len = d->length / sizeof(d->lcn);
+ len = d->length / sizeof(d->lcn);
- for (i = 0; i < len; i++) {
- if (service_id == d->lcn[i].service_id) {
- asprintf(&buf, "%d.%d",
- d->lcn[i].logical_channel_number, i);
- return buf;
+ for (i = 0; i < len; i++) {
+ if (service_id == d->lcn[i].service_id) {
+ asprintf(&buf, "%d.%d",
+ d->lcn[i].logical_channel_number, i);
+ return buf;
+ }
}
}
}
diff --git a/lib/libdvbv5/dvb-log.c b/lib/libdvbv5/dvb-log.c
index 7fa811f..2be056a 100644
--- a/lib/libdvbv5/dvb-log.c
+++ b/lib/libdvbv5/dvb-log.c
@@ -44,7 +44,7 @@ static const struct loglevel {
void dvb_default_log(int level, const char *fmt, ...)
{
- if(level > sizeof(loglevels) / sizeof(struct loglevel) - 2) // ignore LOG_COLOROFF as well
+ if(level > sizeof(loglevels) / sizeof(struct loglevel) - 2) /* ignore LOG_COLOROFF as well */
level = LOG_INFO;
va_list ap;
va_start(ap, fmt);
diff --git a/lib/libdvbv5/dvb-sat.c b/lib/libdvbv5/dvb-sat.c
index 09eb4d1..ea3e2c1 100644
--- a/lib/libdvbv5/dvb-sat.c
+++ b/lib/libdvbv5/dvb-sat.c
@@ -214,8 +214,6 @@ static void dvbsat_diseqc_prep_frame_addr(struct diseqc_cmd *cmd,
cmd->address = diseqc_addr[type];
}
-//struct dvb_v5_fe_parms *parms; // legacy code, used for parms->fd, FIXME anyway
-
/* Inputs are numbered from 1 to 16, according with the spec */
static int dvbsat_diseqc_write_to_port_group(struct dvb_v5_fe_parms *parms, struct diseqc_cmd *cmd,
int high_band,
diff --git a/lib/libdvbv5/dvb-scan.c b/lib/libdvbv5/dvb-scan.c
index d0f0b39..5f8596e 100644
--- a/lib/libdvbv5/dvb-scan.c
+++ b/lib/libdvbv5/dvb-scan.c
@@ -98,7 +98,7 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,
uint8_t *tbl = NULL;
ssize_t table_length = 0;
- // handle sections
+ /* handle sections */
int start_id = -1;
int start_section = -1;
int first_section = -1;
@@ -112,7 +112,7 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,
return -4;
*table = NULL;
- // FIXME: verify known table
+ /* FIXME: verify known table */
memset(&f, 0, sizeof(f));
f.pid = pid;
f.filter.filter[0] = tid;
--
1.8.3.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 17/18] libdvbv5: remove header files from SOURCES in Makefile.am
2013-12-30 12:48 [PATCH 01/18] libdvbv5: fix reading multisection tables André Roth
` (13 preceding siblings ...)
2013-12-30 12:48 ` [PATCH 15/18] libdvbv5: remove c99 comments André Roth
@ 2013-12-30 12:48 ` André Roth
2014-01-07 17:30 ` Mauro Carvalho Chehab
2013-12-30 12:48 ` [PATCH 18/18] libdvbv5: README updated for shared libdvbv5 André Roth
2014-01-07 16:32 ` [PATCH 01/18] libdvbv5: fix reading multisection tables Mauro Carvalho Chehab
16 siblings, 1 reply; 29+ messages in thread
From: André Roth @ 2013-12-30 12:48 UTC (permalink / raw)
To: linux-media; +Cc: André Roth
Signed-off-by: André Roth <neolynx@gmail.com>
---
lib/libdvbv5/Makefile.am | 87 ++++++++++++++++++++++++------------------------
1 file changed, 43 insertions(+), 44 deletions(-)
diff --git a/lib/libdvbv5/Makefile.am b/lib/libdvbv5/Makefile.am
index ddf9ea1..8f89531 100644
--- a/lib/libdvbv5/Makefile.am
+++ b/lib/libdvbv5/Makefile.am
@@ -52,52 +52,51 @@ noinst_LTLIBRARIES = libdvbv5.la
endif
libdvbv5_la_SOURCES = \
- crc32.c crc32.h \
- ../include/dvb-frontend.h \
+ crc32.c \
dvb-legacy-channel-format.c \
dvb-zap-format.c \
- dvb-v5.c dvb-v5.h \
- parse_string.c parse_string.h \
- dvb-demux.c ../include/dvb-demux.h \
- dvb-fe.c ../include/dvb-fe.h \
- dvb-log.c ../include/dvb-log.h \
- dvb-file.c ../include/dvb-file.h \
- dvb-v5-std.c ../include/dvb-v5-std.h \
- dvb-sat.c ../include/dvb-sat.h \
- dvb-scan.c ../include/dvb-scan.h \
- descriptors.c ../include/descriptors.h \
- descriptors/header.c ../include/libdvbv5/header.h \
- descriptors/atsc_header.c ../include/libdvbv5/atsc_header.h \
- descriptors/pat.c ../include/libdvbv5/pat.h \
- descriptors/pmt.c ../include/libdvbv5/pmt.h \
- descriptors/nit.c ../include/libdvbv5/nit.h \
- descriptors/sdt.c ../include/libdvbv5/sdt.h \
- descriptors/vct.c ../include/libdvbv5/vct.h \
- descriptors/mgt.c ../include/libdvbv5/mgt.h \
- descriptors/eit.c ../include/libdvbv5/eit.h \
- descriptors/atsc_eit.c ../include/libdvbv5/atsc_eit.h \
- descriptors/desc_language.c ../include/libdvbv5/desc_language.h \
- descriptors/desc_network_name.c ../include/libdvbv5/desc_network_name.h \
- descriptors/desc_cable_delivery.c ../include/libdvbv5/desc_cable_delivery.h \
- descriptors/desc_sat.c ../include/libdvbv5/desc_sat.h \
- descriptors/desc_terrestrial_delivery.c ../include/libdvbv5/desc_terrestrial_delivery.h \
- descriptors/desc_t2_delivery.c ../include/libdvbv5/desc_t2_delivery.h \
- descriptors/desc_service.c ../include/libdvbv5/desc_service.h \
- descriptors/desc_frequency_list.c ../include/libdvbv5/desc_frequency_list.h \
- descriptors/desc_service_list.c ../include/libdvbv5/desc_service_list.h \
- descriptors/desc_event_short.c ../include/libdvbv5/desc_event_short.h \
- descriptors/desc_event_extended.c ../include/libdvbv5/desc_event_extended.h \
- descriptors/desc_atsc_service_location.c ../include/libdvbv5/desc_atsc_service_location.h \
- descriptors/desc_hierarchy.c ../include/libdvbv5/desc_hierarchy.h \
- descriptors/desc_extension.c ../include/libdvbv5/desc_extension.h \
- descriptors/desc_isdbt_delivery.c ../include/libdvbv5/desc_isdbt_delivery.h \
- descriptors/desc_logical_channel.c ../include/libdvbv5/desc_logical_channel.h \
- descriptors/desc_ts_info.c ../include/libdvbv5/desc_ts_info.h \
- descriptors/desc_partial_reception.c ../include/libdvbv5/desc_partial_reception.h \
- descriptors/desc_service_location.c ../include/libdvbv5/desc_service_location.h \
- descriptors/mpeg_ts.c ../include/libdvbv5/mpeg_ts.h \
- descriptors/mpeg_pes.c ../include/libdvbv5/mpeg_pes.h \
- descriptors/mpeg_es.c ../include/libdvbv5/mpeg_es.h
+ dvb-v5.c \
+ parse_string.c \
+ dvb-demux.c \
+ dvb-fe.c \
+ dvb-log.c \
+ dvb-file.c \
+ dvb-v5-std.c \
+ dvb-sat.c \
+ dvb-scan.c \
+ descriptors.c \
+ descriptors/header.c \
+ descriptors/atsc_header.c \
+ descriptors/pat.c \
+ descriptors/pmt.c \
+ descriptors/nit.c \
+ descriptors/sdt.c \
+ descriptors/vct.c \
+ descriptors/mgt.c \
+ descriptors/eit.c \
+ descriptors/atsc_eit.c \
+ descriptors/desc_language.c \
+ descriptors/desc_network_name.c \
+ descriptors/desc_cable_delivery.c \
+ descriptors/desc_sat.c \
+ descriptors/desc_terrestrial_delivery.c \
+ descriptors/desc_t2_delivery.c \
+ descriptors/desc_service.c \
+ descriptors/desc_frequency_list.c \
+ descriptors/desc_service_list.c \
+ descriptors/desc_event_short.c \
+ descriptors/desc_event_extended.c \
+ descriptors/desc_atsc_service_location.c \
+ descriptors/desc_hierarchy.c \
+ descriptors/desc_extension.c \
+ descriptors/desc_isdbt_delivery.c \
+ descriptors/desc_logical_channel.c \
+ descriptors/desc_ts_info.c \
+ descriptors/desc_partial_reception.c \
+ descriptors/desc_service_location.c \
+ descriptors/mpeg_ts.c \
+ descriptors/mpeg_pes.c \
+ descriptors/mpeg_es.c
libdvbv5_la_CPPFLAGS = -I../.. $(ENFORCE_LIBDVBV5_STATIC)
libdvbv5_la_LDFLAGS = $(LIBDVBV5_VERSION) $(ENFORCE_LIBDVBV5_STATIC) -lm
--
1.8.3.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 18/18] libdvbv5: README updated for shared libdvbv5
2013-12-30 12:48 [PATCH 01/18] libdvbv5: fix reading multisection tables André Roth
` (14 preceding siblings ...)
2013-12-30 12:48 ` [PATCH 17/18] libdvbv5: remove header files from SOURCES in Makefile.am André Roth
@ 2013-12-30 12:48 ` André Roth
2014-01-07 18:12 ` Mauro Carvalho Chehab
2014-01-07 16:32 ` [PATCH 01/18] libdvbv5: fix reading multisection tables Mauro Carvalho Chehab
16 siblings, 1 reply; 29+ messages in thread
From: André Roth @ 2013-12-30 12:48 UTC (permalink / raw)
To: linux-media; +Cc: André Roth
Signed-off-by: André Roth <neolynx@gmail.com>
---
README | 8 ++++----
README.libv4l | 12 ++++++++++++
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/README b/README
index 0cccc00..a9f8089 100644
--- a/README
+++ b/README
@@ -3,13 +3,13 @@ v4l-utils
Linux V4L2 and DVB API utilities and v4l libraries (libv4l).
You can always find the latest development v4l-utils in the git repo:
-http://git.linuxtv.org/v4l-utils.git
+http://git.linuxtv.org/v4l-utils.git
-v4l libraries (libv4l)
-----------------------
+v4l libraries (libv4l, libdvbv5)
+--------------------------------
-See README.lib for more information on libv4l, libv4l is released
+See README.libv4l for more information on libv4l, libv4l is released
under the GNU Lesser General Public License.
diff --git a/README.libv4l b/README.libv4l
index 0be503f..7170801 100644
--- a/README.libv4l
+++ b/README.libv4l
@@ -59,6 +59,18 @@ hardware can _really_ do it should use ENUM_FMT, not randomly try a bunch of
S_FMT's). For more details on the v4l2_ functions see libv4l2.h .
+libdvbv5
+--------
+
+This library provides the DVBv5 API to userspace programs. It can be used to
+open DVB adapters, tune transponders and read PES and other data streams.
+There are as well several parsers for DVB, ATSC, ISBT formats.
+
+The API is currently EXPERIMENTAL and likely to change.
+Run configure with --enable-libdvbv5 in order to build a shared lib and
+install the header files.
+
+
wrappers
--------
--
1.8.3.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [PATCH 01/18] libdvbv5: fix reading multisection tables
2013-12-30 12:48 [PATCH 01/18] libdvbv5: fix reading multisection tables André Roth
` (15 preceding siblings ...)
2013-12-30 12:48 ` [PATCH 18/18] libdvbv5: README updated for shared libdvbv5 André Roth
@ 2014-01-07 16:32 ` Mauro Carvalho Chehab
16 siblings, 0 replies; 29+ messages in thread
From: Mauro Carvalho Chehab @ 2014-01-07 16:32 UTC (permalink / raw)
To: André Roth; +Cc: linux-media
Em Mon, 30 Dec 2013 13:48:34 +0100
André Roth <neolynx@gmail.com> escreveu:
description?
What bug are you trying to fix?
> Signed-off-by: André Roth <neolynx@gmail.com>
> ---
> lib/libdvbv5/dvb-scan.c | 36 +++++++++++++++++++++++-------------
> 1 file changed, 23 insertions(+), 13 deletions(-)
>
> diff --git a/lib/libdvbv5/dvb-scan.c b/lib/libdvbv5/dvb-scan.c
> index e9ccc72..520bf9c 100644
> --- a/lib/libdvbv5/dvb-scan.c
> +++ b/lib/libdvbv5/dvb-scan.c
> @@ -96,9 +96,13 @@ 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
No C99 comments.
> + int start_id = -1;
> + int start_section = -1;
> int first_section = -1;
> int last_section = -1;
> - int table_id = -1;
> + /*int table_id = -1;*/
Why to comment? If it is buggy, just remove it.
> int sections = 0;
> struct dmx_sct_filter_params f;
> struct dvb_table_header *h;
> @@ -108,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;
> @@ -185,24 +188,27 @@ 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;
One statement per line, please.
> +
> 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;
> - }
> }
>
> + /*dvb_logerr("dvb_read_section: got section %d, last %d, filter %d", h->section_id, h->last_section, id );*/
Why are you adding a commented line?
> /* 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)
> + if (last_section == -1 || h->last_section > last_section)
> last_section = h->last_section;
>
> if (!tbl) {
> @@ -228,10 +234,14 @@ 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);
> +
> + if (buf)
> + free(buf);
Buffer is always allocated at this point. No need to test before free.
>
> dvb_dmx_stop(dmx_fd);
>
--
Cheers,
Mauro
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 02/18] libdvbv5: service location descriptor support
2013-12-30 12:48 ` [PATCH 02/18] libdvbv5: service location descriptor support André Roth
@ 2014-01-07 16:38 ` Mauro Carvalho Chehab
0 siblings, 0 replies; 29+ messages in thread
From: Mauro Carvalho Chehab @ 2014-01-07 16:38 UTC (permalink / raw)
To: André Roth; +Cc: linux-media
Em Mon, 30 Dec 2013 13:48:35 +0100
André Roth <neolynx@gmail.com> escreveu:
> Implement the service location descriptor (0xa1), and small cleanups.
>
> Signed-off-by: André Roth <neolynx@gmail.com>
> ---
> lib/include/descriptors.h | 4 +-
> lib/include/descriptors/desc_service_location.h | 69 +++++++++++++++++++++++
> lib/libdvbv5/Makefile.am | 3 +-
> lib/libdvbv5/descriptors.c | 2 +-
> lib/libdvbv5/descriptors/desc_service_location.c | 70 ++++++++++++++++++++++++
> 5 files changed, 145 insertions(+), 3 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..89ed055
> --- /dev/null
> +++ b/lib/include/descriptors/desc_service_location.h
> @@ -0,0 +1,69 @@
> +/*
> + * 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 _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/libdvbv5/Makefile.am b/lib/libdvbv5/Makefile.am
> index 2ad5902..80e8adb 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/eit.c ../include/descriptors/eit.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..3759665
> --- /dev/null
> +++ b/lib/libdvbv5/descriptors/desc_service_location.c
> @@ -0,0 +1,70 @@
> +/*
> + * Copyright (c) 2013 - Andre Roth <neolynx@gmail.com>
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation version 2
> + * of the License.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
> + *
> + */
> +
> +#include "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 blank line here.
> + /* 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);
Use offsetof().
> +
> + bswap16(service_location->bitfield);
> +
> + // FIXME: handle elements == 0
no C99 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;
> + for(i = 0; i < service_location->elements; i++) {
> + memcpy(element, buf, sizeof(struct dvb_desc_service_location_element) - 1); /* no \0 in lang */
Please test 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;
blank line.
> + struct dvb_desc_service_location_element *element = service_location->element;
Please reorder: variable declarations should come before the dvb_log() calls.
> + for(i = 0; i < service_location->elements; i++) {
Space after "for". No need for {}, as there's just one statement on this for.
> + 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;
Please add a blank line.
> + free(service_location->element);
> +}
> +
--
Cheers,
Mauro
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 04/18] libdvbv5: mpeg elementary stream parsers
2013-12-30 12:48 ` [PATCH 04/18] libdvbv5: mpeg elementary stream parsers André Roth
@ 2014-01-07 16:47 ` Mauro Carvalho Chehab
0 siblings, 0 replies; 29+ messages in thread
From: Mauro Carvalho Chehab @ 2014-01-07 16:47 UTC (permalink / raw)
To: André Roth; +Cc: linux-media
Em Mon, 30 Dec 2013 13:48:37 +0100
André Roth <neolynx@gmail.com> escreveu:
> Implement parsers for mpeg TS, PES and ES
>
> Signed-off-by: André Roth <neolynx@gmail.com>
> ---
> lib/include/descriptors/mpeg_es.h | 109 ++++++++++++++++++++++++++++++
> lib/include/descriptors/mpeg_pes.h | 111 ++++++++++++++++++++++++++++++
> lib/include/descriptors/mpeg_ts.h | 78 +++++++++++++++++++++
> 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 +++++++++++++++++++++
> 7 files changed, 586 insertions(+), 1 deletion(-)
> 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..4c6a862
> --- /dev/null
> +++ b/lib/include/descriptors/mpeg_es.h
> @@ -0,0 +1,109 @@
> +/*
> + * 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 _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..3a3f8e4
> --- /dev/null
> +++ b/lib/include/descriptors/mpeg_pes.h
> @@ -0,0 +1,111 @@
> +/*
> + * 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 _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..54fee69
> --- /dev/null
> +++ b/lib/include/descriptors/mpeg_ts.h
> @@ -0,0 +1,78 @@
> +/*
> + * 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 _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/libdvbv5/Makefile.am b/lib/libdvbv5/Makefile.am
> index 80e8adb..33693cc 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/eit.c ../include/descriptors/eit.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..9fcb5ca
> --- /dev/null
> +++ b/lib/libdvbv5/descriptors/mpeg_es.c
> @@ -0,0 +1,76 @@
> +/*
> + * Copyright (c) 2013 - Andre Roth <neolynx@gmail.com>
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation version 2
> + * of the License.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
> + *
> + */
> +
> +#include "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))
space after "if".
> + 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))
space after 'if'.
> + 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..1b518a3
> --- /dev/null
> +++ b/lib/libdvbv5/descriptors/mpeg_pes.c
> @@ -0,0 +1,131 @@
> +/*
> + * Copyright (c) 2013 - Andre Roth <neolynx@gmail.com>
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation version 2
> + * of the License.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
> + *
> + */
> +
> +#include "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;
blank line.
> + memcpy(table + *table_length, p, sizeof(struct dvb_mpeg_pes));
Please check size before copy.
> + 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);
Use offsetof() and check before copy.
> + bswap16(pes->optional->bitfield);
> + pes->optional->pts = 0;
> + pes->optional->dts = 0;
> + if (pes->optional->PTS_DTS & 2) {
> + struct ts_t pts;
blank line.
> + memcpy(&pts, p, sizeof(pts));
> + p += sizeof(pts);
Please check before copy.
> + 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) {
Missing statement. It seems better to use a switch here.
> + } 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..d7ec2c4
> --- /dev/null
> +++ b/lib/libdvbv5/descriptors/mpeg_ts.c
> @@ -0,0 +1,77 @@
> +/*
> + * Copyright (c) 2013 - Andre Roth <neolynx@gmail.com>
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation version 2
> + * of the License.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
> + *
> + */
> +
> +#include "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;
Please reorder: data declarations should come before the if.
> + memcpy(table, p, sizeof(struct dvb_mpeg_ts));
Please check before copy.
> + 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));
Please check before copy.
> + 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] 29+ messages in thread
* Re: [PATCH 07/18] libdvbv5: fix EIT parsing
2013-12-30 12:48 ` [PATCH 07/18] libdvbv5: fix EIT parsing André Roth
@ 2014-01-07 17:00 ` Mauro Carvalho Chehab
0 siblings, 0 replies; 29+ messages in thread
From: Mauro Carvalho Chehab @ 2014-01-07 17:00 UTC (permalink / raw)
To: André Roth; +Cc: linux-media
Em Mon, 30 Dec 2013 13:48:40 +0100
André Roth <neolynx@gmail.com> escreveu:
> the dvb_table_eit_event now contains the service_id,
> indicating where the events belong to.
>
> Signed-off-by: André Roth <neolynx@gmail.com>
> ---
> lib/include/descriptors/eit.h | 3 ++-
> lib/libdvbv5/descriptors/eit.c | 35 ++++++++++++++++++++++++++---------
> 2 files changed, 28 insertions(+), 10 deletions(-)
>
> diff --git a/lib/include/descriptors/eit.h b/lib/include/descriptors/eit.h
> index 2af9696..ca08fd4 100644
> --- a/lib/include/descriptors/eit.h
> +++ b/lib/include/descriptors/eit.h
> @@ -40,7 +40,7 @@
> struct dvb_table_eit_event {
> uint16_t event_id;
> union {
> - uint16_t bitfield;
> + uint16_t bitfield1; /* first 2 bytes are MJD, they need to be bswapped */
> uint8_t dvbstart[5];
> } __attribute__((packed));
> uint8_t dvbduration[3];
> @@ -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/libdvbv5/descriptors/eit.c b/lib/libdvbv5/descriptors/eit.c
> index ccfe1a6..c2d01c3 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,18 +53,30 @@ 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);
Please check before copy and replace those sizeof()'s by offsetof().
>
> bswap16(event->event_id);
> - bswap16(event->bitfield);
> + bswap16(event->bitfield1);
> bswap16(event->bitfield2);
> 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);
> @@ -137,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 );
> }
>
>
--
Cheers,
Mauro
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 08/18] libdvbv5: implement MGT parser
2013-12-30 12:48 ` [PATCH 08/18] libdvbv5: implement MGT parser André Roth
@ 2014-01-07 17:05 ` Mauro Carvalho Chehab
0 siblings, 0 replies; 29+ messages in thread
From: Mauro Carvalho Chehab @ 2014-01-07 17:05 UTC (permalink / raw)
To: André Roth; +Cc: linux-media
Em Mon, 30 Dec 2013 13:48:41 +0100
André Roth <neolynx@gmail.com> escreveu:
> Signed-off-by: André Roth <neolynx@gmail.com>
> ---
> lib/include/descriptors/mgt.h | 80 ++++++++++++++++++++++++++++
> lib/libdvbv5/Makefile.am | 1 +
> lib/libdvbv5/descriptors.c | 2 +
> lib/libdvbv5/descriptors/mgt.c | 117 +++++++++++++++++++++++++++++++++++++++++
> 4 files changed, 200 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..9eaac02
> --- /dev/null
> +++ b/lib/include/descriptors/mgt.h
> @@ -0,0 +1,80 @@
> +/*
> + * 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/atsc_header.h"
> +#include "descriptors.h"
> +
> +#define ATSC_TABLE_MGT 0xC7
> +
> +struct atsc_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 atsc_table_mgt_table *next;
> +} __attribute__((packed));
> +
> +struct atsc_table_mgt {
> + struct atsc_table_header header;
> + uint16_t tables;
> + struct atsc_table_mgt_table *table;
> + struct dvb_desc *descriptor;
> +} __attribute__((packed));
> +
> +
> +#define atsc_mgt_table_foreach( _tran, _mgt ) \
> + for( struct atsc_table_mgt_table *_tran = _mgt->table; _tran; _tran = _tran->next ) \
> +
> +struct dvb_v5_fe_parms;
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +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
> +}
> +#endif
> +
> +#endif
> diff --git a/lib/libdvbv5/Makefile.am b/lib/libdvbv5/Makefile.am
> index 33693cc..7755e05 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/eit.c ../include/descriptors/eit.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 bc3d51a..7b9e9d0 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"
> @@ -84,6 +85,7 @@ const struct dvb_table_init dvb_table_initializers[] = {
> [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_EIT_SCHEDULE] = { dvb_table_eit_init, sizeof(struct dvb_table_eit) },
> + [ATSC_TABLE_MGT] = { atsc_table_mgt_init, sizeof(struct atsc_table_mgt) },
> };
>
> char *default_charset = "iso-8859-1";
> diff --git a/lib/libdvbv5/descriptors/mgt.c b/lib/libdvbv5/descriptors/mgt.c
> new file mode 100644
> index 0000000..09d1cf2
> --- /dev/null
> +++ b/lib/libdvbv5/descriptors/mgt.c
> @@ -0,0 +1,117 @@
> +/*
> + * Copyright (c) 2013 - Andre Roth <neolynx@gmail.com>
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation version 2
> + * of the License.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
> + *
> + */
> +
> +#include "descriptors/mgt.h"
> +#include "dvb-fe.h"
> +
> +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 atsc_table_mgt *mgt = (struct atsc_table_mgt *) table;
> + struct dvb_desc **head_desc;
> + struct atsc_table_mgt_table **head;
> + /*int desc_length;*/
If you don't need a line, just don't add it, instead of adding it
commented.
> +
> + 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 atsc_table_mgt) - sizeof(mgt->descriptor) - sizeof(mgt->table));
Test before copy and use offsetof().
> + *table_length = sizeof(struct atsc_table_mgt);
> +
> + mgt->descriptor = NULL;
> + mgt->table = NULL;
> + head_desc = &mgt->descriptor;
> + head = &mgt->table;
> + bswap16(mgt->tables);
> + }
> + p += sizeof(struct atsc_table_mgt) - sizeof(mgt->descriptor) - sizeof(mgt->table);
Use offsetof().
> +
> + /*dvb_parse_descriptors(parms, p, desc_length, head_desc);*/
> + /*p += desc_length;*/
If not needed, don't add.
> + int i = 0;
Please use tab, not spaces.
> + struct atsc_table_mgt_table *last = NULL;
Please put data declaration at the beginning of the function.
> + while (i++ < mgt->tables && (uint8_t *) p < buf + buflen - 4) {
> + struct atsc_table_mgt_table *table = (struct atsc_table_mgt_table *) malloc(sizeof(struct atsc_table_mgt_table));
Please add a blank line.
> + 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);
Please use offsetof().
> +
> + 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 atsc_table_mgt_free(struct atsc_table_mgt *mgt)
> +{
> + struct atsc_table_mgt_table *table = mgt->table;
blank line.
> + dvb_free_descriptors((struct dvb_desc **) &mgt->descriptor);
> + while(table) {
> + dvb_free_descriptors((struct dvb_desc **) &table->descriptor);
> + struct atsc_table_mgt_table *tmp = table;
> + table = table->next;
> + free(tmp);
> + }
> + free(mgt);
> +}
> +
> +void atsc_table_mgt_print(struct dvb_v5_fe_parms *parms, struct atsc_table_mgt *mgt)
> +{
> + dvb_log("MGT");
> + atsc_table_header_print(parms, &mgt->header);
> + dvb_log("| tables %d", mgt->tables);
> + /*dvb_print_descriptors(parms, mgt->descriptor);*/
> + const struct atsc_table_mgt_table *table = mgt->table;
> + uint16_t tables = 0;
data declarations at the beginning of the function.
> + while(table) {
space after while.
> + 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++;
> + }
> + dvb_log("|_ %d tables", tables);
> +}
> +
--
Cheers,
Mauro
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 09/18] libdvbv5: implement ATSC EIT
2013-12-30 12:48 ` [PATCH 09/18] libdvbv5: implement ATSC EIT André Roth
@ 2014-01-07 17:12 ` Mauro Carvalho Chehab
2014-01-08 11:09 ` André Roth
0 siblings, 1 reply; 29+ messages in thread
From: Mauro Carvalho Chehab @ 2014-01-07 17:12 UTC (permalink / raw)
To: André Roth; +Cc: linux-media
Em Mon, 30 Dec 2013 13:48:42 +0100
André Roth <neolynx@gmail.com> escreveu:
> Signed-off-by: André Roth <neolynx@gmail.com>
> ---
> lib/include/descriptors/atsc_eit.h | 90 +++++++++++++++++++++
> lib/include/descriptors/atsc_header.h | 63 +++++++++++++++
> lib/libdvbv5/Makefile.am | 4 +-
> lib/libdvbv5/descriptors.c | 2 +
> lib/libdvbv5/descriptors/atsc_eit.c | 142 +++++++++++++++++++++++++++++++++
> lib/libdvbv5/descriptors/atsc_header.c | 47 +++++++++++
> 6 files changed, 347 insertions(+), 1 deletion(-)
> 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..3bc5df6
> --- /dev/null
> +++ b/lib/include/descriptors/atsc_eit.h
> @@ -0,0 +1,90 @@
> +/*
> + * 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 _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..1e7148e
> --- /dev/null
> +++ b/lib/include/descriptors/atsc_header.h
> @@ -0,0 +1,63 @@
> +/*
> + * 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 _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/libdvbv5/Makefile.am b/lib/libdvbv5/Makefile.am
> index 7755e05..6771d24 100644
> --- a/lib/libdvbv5/Makefile.am
> +++ b/lib/libdvbv5/Makefile.am
> @@ -48,8 +48,10 @@ 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/atsc_header.c ../include/descriptors/atsc_header.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 7b9e9d0..737acfa 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"
> @@ -86,6 +87,7 @@ const struct dvb_table_init dvb_table_initializers[] = {
> [DVB_TABLE_CVCT] = { dvb_table_vct_init, sizeof(struct dvb_table_vct) },
> [DVB_TABLE_EIT_SCHEDULE] = { dvb_table_eit_init, sizeof(struct dvb_table_eit) },
> [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";
> diff --git a/lib/libdvbv5/descriptors/atsc_eit.c b/lib/libdvbv5/descriptors/atsc_eit.c
> new file mode 100644
> index 0000000..4ee38ae
> --- /dev/null
> +++ b/lib/libdvbv5/descriptors/atsc_eit.c
> @@ -0,0 +1,142 @@
> +/*
> + * Copyright (c) 2013 - Andre Roth <neolynx@gmail.com>
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation version 2
> + * of the License.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
> + *
> + */
> +
> +#include "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));
Hmm... on some patches, when the table already exists, nothing is copied.
Just the pointer 'p' is incremented.
We should standardize this. Not sure what's the better.
> +
> + /* 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);
For both memcpy(): please test before copy, and use offsetof().
> +
> + eit->event = NULL;
> + head = &eit->event;
> + }
> + p += sizeof(struct atsc_table_eit) - sizeof(eit->event);
Please use offsetof().
> +
> + hexdump(parms, "eit", p, 64 );
> +
> + int i = 0;
Use tabs.
> + struct atsc_table_eit_event *last = NULL;
Please move to the beginning of the function.
> + 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);
Use offsetof().
> +
> + bswap16(event->bitfield);
> + bswap32(event->start_time);
> + bswap32(event->bitfield2);
> + event->descriptor = NULL;
> + event->next = NULL;
> + atsc_time(event->start_time, &event->start);
Use tabs.
> + event->source_id = eit->header.id;
> +
> + //FIXME: title
Don't use c99 comments. Use tabs.
> + 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;
Move to the beginning of the function or to the beginning of the braces.
> + union atsc_table_eit_desc_length dl = *(union atsc_table_eit_desc_length *) p;
Same here: declare 'dl' at the beginning of a block.
> + 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;
please add a blank line here.
> + 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;
Data declarations first.
> + 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..ed152ce
> --- /dev/null
> +++ b/lib/libdvbv5/descriptors/atsc_header.c
> @@ -0,0 +1,47 @@
> +/*
> + * Copyright (c) 2013 - Andre Roth <neolynx@gmail.com>
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation version 2
> + * of the License.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
> + *
> + */
> +
> +#include "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);
> +}
> +
--
Cheers,
Mauro
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 11/18] libdvbv5: cleanup coding style
2013-12-30 12:48 ` [PATCH 11/18] libdvbv5: cleanup coding style André Roth
@ 2014-01-07 17:23 ` Mauro Carvalho Chehab
0 siblings, 0 replies; 29+ messages in thread
From: Mauro Carvalho Chehab @ 2014-01-07 17:23 UTC (permalink / raw)
To: André Roth; +Cc: linux-media
Em Mon, 30 Dec 2013 13:48:44 +0100
André Roth <neolynx@gmail.com> escreveu:
> 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 226349e..f46aa4a 100644
> --- a/lib/libdvbv5/descriptors.c
> +++ b/lib/libdvbv5/descriptors.c
> @@ -1359,6 +1359,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 1b518a3..98364a3 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;
> }
Please merge this one with the patches that introduced the changes,
if they weren't merged yet. The second hunk doesn't apply, as I
requested changes on the patch that added the PES parser.
--
Cheers,
Mauro
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 13/18] libdvbv5: improve TS parsing
2013-12-30 12:48 ` [PATCH 13/18] libdvbv5: improve TS parsing André Roth
@ 2014-01-07 17:27 ` Mauro Carvalho Chehab
0 siblings, 0 replies; 29+ messages in thread
From: Mauro Carvalho Chehab @ 2014-01-07 17:27 UTC (permalink / raw)
To: André Roth; +Cc: linux-media
Em Mon, 30 Dec 2013 13:48:46 +0100
André Roth <neolynx@gmail.com> escreveu:
description?
> 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 54fee69..de4fc3f 100644
> --- a/lib/include/descriptors/mpeg_ts.h
> +++ b/lib/include/descriptors/mpeg_ts.h
> @@ -38,7 +38,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 {
> @@ -67,7 +67,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 d7ec2c4..b06cdf7 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;
Please move declarations to the begining.
> 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 */
typo; length
> }
> /*hexdump(parms, "TS: ", buf, buflen);*/
> + return bytes_read;
> }
>
> void dvb_mpeg_ts_free(struct dvb_mpeg_ts *ts)
Doesn't apply yet. Please either merge with the original patch or
resubmit on a next series.
--
Cheers,
Mauro
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 15/18] libdvbv5: remove c99 comments
2013-12-30 12:48 ` [PATCH 15/18] libdvbv5: remove c99 comments André Roth
@ 2014-01-07 17:29 ` Mauro Carvalho Chehab
0 siblings, 0 replies; 29+ messages in thread
From: Mauro Carvalho Chehab @ 2014-01-07 17:29 UTC (permalink / raw)
To: André Roth; +Cc: linux-media
Em Mon, 30 Dec 2013 13:48:48 +0100
André Roth <neolynx@gmail.com> escreveu:
> Signed-off-by: André Roth <neolynx@gmail.com>
> ---
> lib/libdvbv5/descriptors/atsc_eit.c | 2 +-
> lib/libdvbv5/descriptors/desc_service_list.c | 4 +++-
> lib/libdvbv5/descriptors/desc_service_location.c | 2 +-
> lib/libdvbv5/dvb-file.c | 21 +++++++++++----------
> lib/libdvbv5/dvb-log.c | 2 +-
> lib/libdvbv5/dvb-sat.c | 2 --
> lib/libdvbv5/dvb-scan.c | 4 ++--
> 7 files changed, 19 insertions(+), 18 deletions(-)
>
> diff --git a/lib/libdvbv5/descriptors/atsc_eit.c b/lib/libdvbv5/descriptors/atsc_eit.c
> index 4ee38ae..8d3791d 100644
> --- a/lib/libdvbv5/descriptors/atsc_eit.c
> +++ b/lib/libdvbv5/descriptors/atsc_eit.c
> @@ -68,7 +68,7 @@ void atsc_table_eit_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssiz
> atsc_time(event->start_time, &event->start);
> event->source_id = eit->header.id;
>
> - //FIXME: title
> + /* FIXME: title */
> p += event->title_length - 1;
>
> if(!*head)
> diff --git a/lib/libdvbv5/descriptors/desc_service_list.c b/lib/libdvbv5/descriptors/desc_service_list.c
> index ab91622..18aa313 100644
> --- a/lib/libdvbv5/descriptors/desc_service_list.c
> +++ b/lib/libdvbv5/descriptors/desc_service_list.c
> @@ -23,6 +23,8 @@
> #include "descriptors.h"
> #include "dvb-fe.h"
>
> +/* FIXME: implement */
> +
> void dvb_desc_service_list_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, struct dvb_desc *desc)
> {
> /*struct dvb_desc_service_list *slist = (struct dvb_desc_service_list *) desc;*/
> @@ -38,7 +40,7 @@ void dvb_desc_service_list_init(struct dvb_v5_fe_parms *parms, const uint8_t *bu
> /*}*/
>
> /*return sizeof(struct dvb_desc_service_list) + slist->length + sizeof(struct dvb_desc_service_list_table);*/
> - //FIXME: make linked list
> + /* FIXME: make linked list */
> }
>
> void dvb_desc_service_list_print(struct dvb_v5_fe_parms *parms, const struct dvb_desc *desc)
> diff --git a/lib/libdvbv5/descriptors/desc_service_location.c b/lib/libdvbv5/descriptors/desc_service_location.c
> index 3759665..b205428 100644
> --- a/lib/libdvbv5/descriptors/desc_service_location.c
> +++ b/lib/libdvbv5/descriptors/desc_service_location.c
> @@ -36,7 +36,7 @@ void dvb_desc_service_location_init(struct dvb_v5_fe_parms *parms, const uint8_t
>
> bswap16(service_location->bitfield);
>
> - // FIXME: handle elements == 0
> + /* 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;
> diff --git a/lib/libdvbv5/dvb-file.c b/lib/libdvbv5/dvb-file.c
> index 1e41fbb..de19dc5 100644
> --- a/lib/libdvbv5/dvb-file.c
> +++ b/lib/libdvbv5/dvb-file.c
> @@ -784,20 +784,21 @@ static char *dvb_vchannel(struct dvb_table_nit *nit, uint16_t service_id)
> if (!nit)
> return NULL;
>
> -for( struct dvb_desc_logical_channel *desc = (struct dvb_desc_logical_channel *) nit->descriptor; desc; desc = (struct dvb_desc_logical_channel *) desc->next ) \
> + /* FIXME: use dvb_desc_find(struct dvb_desc_logical_channel, desc, nit, logical_channel_number_descriptor) { */
> + for( struct dvb_desc_logical_channel *desc = (struct dvb_desc_logical_channel *) nit->descriptor; desc; desc = (struct dvb_desc_logical_channel *) desc->next ) {
> if(desc->type == logical_channel_number_descriptor) {
> -// dvb_desc_find(struct dvb_desc_logical_channel, desc, nit, logical_channel_number_descriptor) {
> - struct dvb_desc_logical_channel *d = (void *)desc;
> + struct dvb_desc_logical_channel *d = (void *)desc;
>
> - size_t len;
> + size_t len;
>
> - len = d->length / sizeof(d->lcn);
> + len = d->length / sizeof(d->lcn);
>
> - for (i = 0; i < len; i++) {
> - if (service_id == d->lcn[i].service_id) {
> - asprintf(&buf, "%d.%d",
> - d->lcn[i].logical_channel_number, i);
> - return buf;
> + for (i = 0; i < len; i++) {
> + if (service_id == d->lcn[i].service_id) {
> + asprintf(&buf, "%d.%d",
> + d->lcn[i].logical_channel_number, i);
> + return buf;
> + }
> }
> }
> }
> diff --git a/lib/libdvbv5/dvb-log.c b/lib/libdvbv5/dvb-log.c
> index 7fa811f..2be056a 100644
> --- a/lib/libdvbv5/dvb-log.c
> +++ b/lib/libdvbv5/dvb-log.c
> @@ -44,7 +44,7 @@ static const struct loglevel {
>
> void dvb_default_log(int level, const char *fmt, ...)
> {
> - if(level > sizeof(loglevels) / sizeof(struct loglevel) - 2) // ignore LOG_COLOROFF as well
> + if(level > sizeof(loglevels) / sizeof(struct loglevel) - 2) /* ignore LOG_COLOROFF as well */
> level = LOG_INFO;
> va_list ap;
> va_start(ap, fmt);
> diff --git a/lib/libdvbv5/dvb-sat.c b/lib/libdvbv5/dvb-sat.c
> index 09eb4d1..ea3e2c1 100644
> --- a/lib/libdvbv5/dvb-sat.c
> +++ b/lib/libdvbv5/dvb-sat.c
> @@ -214,8 +214,6 @@ static void dvbsat_diseqc_prep_frame_addr(struct diseqc_cmd *cmd,
> cmd->address = diseqc_addr[type];
> }
>
> -//struct dvb_v5_fe_parms *parms; // legacy code, used for parms->fd, FIXME anyway
> -
> /* Inputs are numbered from 1 to 16, according with the spec */
> static int dvbsat_diseqc_write_to_port_group(struct dvb_v5_fe_parms *parms, struct diseqc_cmd *cmd,
> int high_band,
> diff --git a/lib/libdvbv5/dvb-scan.c b/lib/libdvbv5/dvb-scan.c
> index d0f0b39..5f8596e 100644
> --- a/lib/libdvbv5/dvb-scan.c
> +++ b/lib/libdvbv5/dvb-scan.c
> @@ -98,7 +98,7 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,
> uint8_t *tbl = NULL;
> ssize_t table_length = 0;
>
> - // handle sections
> + /* handle sections */
> int start_id = -1;
> int start_section = -1;
> int first_section = -1;
> @@ -112,7 +112,7 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,
> return -4;
> *table = NULL;
>
> - // FIXME: verify known table
> + /* FIXME: verify known table */
> memset(&f, 0, sizeof(f));
> f.pid = pid;
> f.filter.filter[0] = tid;
Only partially applies (as some patches introducing those comments weren't applied).
--
Cheers,
Mauro
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 17/18] libdvbv5: remove header files from SOURCES in Makefile.am
2013-12-30 12:48 ` [PATCH 17/18] libdvbv5: remove header files from SOURCES in Makefile.am André Roth
@ 2014-01-07 17:30 ` Mauro Carvalho Chehab
0 siblings, 0 replies; 29+ messages in thread
From: Mauro Carvalho Chehab @ 2014-01-07 17:30 UTC (permalink / raw)
To: André Roth; +Cc: linux-media
Em Mon, 30 Dec 2013 13:48:50 +0100
André Roth <neolynx@gmail.com> escreveu:
description?
I'm not sure if this is ok. If you remove the headers, wouldn't it remove the
C source dependencies from the .h headers?
> Signed-off-by: André Roth <neolynx@gmail.com>
> ---
> lib/libdvbv5/Makefile.am | 87 ++++++++++++++++++++++++------------------------
> 1 file changed, 43 insertions(+), 44 deletions(-)
>
> diff --git a/lib/libdvbv5/Makefile.am b/lib/libdvbv5/Makefile.am
> index ddf9ea1..8f89531 100644
> --- a/lib/libdvbv5/Makefile.am
> +++ b/lib/libdvbv5/Makefile.am
> @@ -52,52 +52,51 @@ noinst_LTLIBRARIES = libdvbv5.la
> endif
>
> libdvbv5_la_SOURCES = \
> - crc32.c crc32.h \
> - ../include/dvb-frontend.h \
> + crc32.c \
> dvb-legacy-channel-format.c \
> dvb-zap-format.c \
> - dvb-v5.c dvb-v5.h \
> - parse_string.c parse_string.h \
> - dvb-demux.c ../include/dvb-demux.h \
> - dvb-fe.c ../include/dvb-fe.h \
> - dvb-log.c ../include/dvb-log.h \
> - dvb-file.c ../include/dvb-file.h \
> - dvb-v5-std.c ../include/dvb-v5-std.h \
> - dvb-sat.c ../include/dvb-sat.h \
> - dvb-scan.c ../include/dvb-scan.h \
> - descriptors.c ../include/descriptors.h \
> - descriptors/header.c ../include/libdvbv5/header.h \
> - descriptors/atsc_header.c ../include/libdvbv5/atsc_header.h \
> - descriptors/pat.c ../include/libdvbv5/pat.h \
> - descriptors/pmt.c ../include/libdvbv5/pmt.h \
> - descriptors/nit.c ../include/libdvbv5/nit.h \
> - descriptors/sdt.c ../include/libdvbv5/sdt.h \
> - descriptors/vct.c ../include/libdvbv5/vct.h \
> - descriptors/mgt.c ../include/libdvbv5/mgt.h \
> - descriptors/eit.c ../include/libdvbv5/eit.h \
> - descriptors/atsc_eit.c ../include/libdvbv5/atsc_eit.h \
> - descriptors/desc_language.c ../include/libdvbv5/desc_language.h \
> - descriptors/desc_network_name.c ../include/libdvbv5/desc_network_name.h \
> - descriptors/desc_cable_delivery.c ../include/libdvbv5/desc_cable_delivery.h \
> - descriptors/desc_sat.c ../include/libdvbv5/desc_sat.h \
> - descriptors/desc_terrestrial_delivery.c ../include/libdvbv5/desc_terrestrial_delivery.h \
> - descriptors/desc_t2_delivery.c ../include/libdvbv5/desc_t2_delivery.h \
> - descriptors/desc_service.c ../include/libdvbv5/desc_service.h \
> - descriptors/desc_frequency_list.c ../include/libdvbv5/desc_frequency_list.h \
> - descriptors/desc_service_list.c ../include/libdvbv5/desc_service_list.h \
> - descriptors/desc_event_short.c ../include/libdvbv5/desc_event_short.h \
> - descriptors/desc_event_extended.c ../include/libdvbv5/desc_event_extended.h \
> - descriptors/desc_atsc_service_location.c ../include/libdvbv5/desc_atsc_service_location.h \
> - descriptors/desc_hierarchy.c ../include/libdvbv5/desc_hierarchy.h \
> - descriptors/desc_extension.c ../include/libdvbv5/desc_extension.h \
> - descriptors/desc_isdbt_delivery.c ../include/libdvbv5/desc_isdbt_delivery.h \
> - descriptors/desc_logical_channel.c ../include/libdvbv5/desc_logical_channel.h \
> - descriptors/desc_ts_info.c ../include/libdvbv5/desc_ts_info.h \
> - descriptors/desc_partial_reception.c ../include/libdvbv5/desc_partial_reception.h \
> - descriptors/desc_service_location.c ../include/libdvbv5/desc_service_location.h \
> - descriptors/mpeg_ts.c ../include/libdvbv5/mpeg_ts.h \
> - descriptors/mpeg_pes.c ../include/libdvbv5/mpeg_pes.h \
> - descriptors/mpeg_es.c ../include/libdvbv5/mpeg_es.h
> + dvb-v5.c \
> + parse_string.c \
> + dvb-demux.c \
> + dvb-fe.c \
> + dvb-log.c \
> + dvb-file.c \
> + dvb-v5-std.c \
> + dvb-sat.c \
> + dvb-scan.c \
> + descriptors.c \
> + descriptors/header.c \
> + descriptors/atsc_header.c \
> + descriptors/pat.c \
> + descriptors/pmt.c \
> + descriptors/nit.c \
> + descriptors/sdt.c \
> + descriptors/vct.c \
> + descriptors/mgt.c \
> + descriptors/eit.c \
> + descriptors/atsc_eit.c \
> + descriptors/desc_language.c \
> + descriptors/desc_network_name.c \
> + descriptors/desc_cable_delivery.c \
> + descriptors/desc_sat.c \
> + descriptors/desc_terrestrial_delivery.c \
> + descriptors/desc_t2_delivery.c \
> + descriptors/desc_service.c \
> + descriptors/desc_frequency_list.c \
> + descriptors/desc_service_list.c \
> + descriptors/desc_event_short.c \
> + descriptors/desc_event_extended.c \
> + descriptors/desc_atsc_service_location.c \
> + descriptors/desc_hierarchy.c \
> + descriptors/desc_extension.c \
> + descriptors/desc_isdbt_delivery.c \
> + descriptors/desc_logical_channel.c \
> + descriptors/desc_ts_info.c \
> + descriptors/desc_partial_reception.c \
> + descriptors/desc_service_location.c \
> + descriptors/mpeg_ts.c \
> + descriptors/mpeg_pes.c \
> + descriptors/mpeg_es.c
>
> libdvbv5_la_CPPFLAGS = -I../.. $(ENFORCE_LIBDVBV5_STATIC)
> libdvbv5_la_LDFLAGS = $(LIBDVBV5_VERSION) $(ENFORCE_LIBDVBV5_STATIC) -lm
--
Cheers,
Mauro
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 18/18] libdvbv5: README updated for shared libdvbv5
2013-12-30 12:48 ` [PATCH 18/18] libdvbv5: README updated for shared libdvbv5 André Roth
@ 2014-01-07 18:12 ` Mauro Carvalho Chehab
0 siblings, 0 replies; 29+ messages in thread
From: Mauro Carvalho Chehab @ 2014-01-07 18:12 UTC (permalink / raw)
To: André Roth; +Cc: linux-media
Em Mon, 30 Dec 2013 13:48:51 +0100
André Roth <neolynx@gmail.com> escreveu:
> Signed-off-by: André Roth <neolynx@gmail.com>
> ---
> README | 8 ++++----
> README.libv4l | 12 ++++++++++++
> 2 files changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/README b/README
> index 0cccc00..a9f8089 100644
> --- a/README
> +++ b/README
> @@ -3,13 +3,13 @@ v4l-utils
>
> Linux V4L2 and DVB API utilities and v4l libraries (libv4l).
> You can always find the latest development v4l-utils in the git repo:
> -http://git.linuxtv.org/v4l-utils.git
> +http://git.linuxtv.org/v4l-utils.git
>
>
> -v4l libraries (libv4l)
> -----------------------
> +v4l libraries (libv4l, libdvbv5)
> +--------------------------------
No, libdvbv5 is not a V4L library. It is a DVB one.
>
> -See README.lib for more information on libv4l, libv4l is released
> +See README.libv4l for more information on libv4l, libv4l is released
> under the GNU Lesser General Public License.
>
>
> diff --git a/README.libv4l b/README.libv4l
> index 0be503f..7170801 100644
> --- a/README.libv4l
> +++ b/README.libv4l
> @@ -59,6 +59,18 @@ hardware can _really_ do it should use ENUM_FMT, not randomly try a bunch of
> S_FMT's). For more details on the v4l2_ functions see libv4l2.h .
>
>
> +libdvbv5
> +--------
> +
> +This library provides the DVBv5 API to userspace programs. It can be used to
> +open DVB adapters, tune transponders and read PES and other data streams.
> +There are as well several parsers for DVB, ATSC, ISBT formats.
> +
> +The API is currently EXPERIMENTAL and likely to change.
> +Run configure with --enable-libdvbv5 in order to build a shared lib and
> +install the header files.
Seem OK to me, provided that this patch comes after or together one
that adds --enable-libdvbv5 to the autotools config files.
> +
> +
> wrappers
> --------
>
--
Cheers,
Mauro
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 09/18] libdvbv5: implement ATSC EIT
2014-01-07 17:12 ` Mauro Carvalho Chehab
@ 2014-01-08 11:09 ` André Roth
0 siblings, 0 replies; 29+ messages in thread
From: André Roth @ 2014-01-08 11:09 UTC (permalink / raw)
To: Mauro Carvalho Chehab; +Cc: linux-media
> > +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));
>
> Hmm... on some patches, when the table already exists, nothing is copied.
>
> Just the pointer 'p' is incremented.
>
> We should standardize this. Not sure what's the better.
agree. the first implementations were ok not copying already existing
table bodies. but tables like the EIT need info from the table body in
every section, so we need to parse that...
I will fix this for all tables in a later patch.
Regards,
andré
^ permalink raw reply [flat|nested] 29+ messages in thread
end of thread, other threads:[~2014-01-08 11:09 UTC | newest]
Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-30 12:48 [PATCH 01/18] libdvbv5: fix reading multisection tables André Roth
2013-12-30 12:48 ` [PATCH 02/18] libdvbv5: service location descriptor support André Roth
2014-01-07 16:38 ` Mauro Carvalho Chehab
2013-12-30 12:48 ` [PATCH 03/18] libdvbv5: VCT table cleanup André Roth
2013-12-30 12:48 ` [PATCH 04/18] libdvbv5: mpeg elementary stream parsers André Roth
2014-01-07 16:47 ` Mauro Carvalho Chehab
2013-12-30 12:48 ` [PATCH 05/18] libdvbv5: fix NIT structures André Roth
2013-12-30 12:48 ` [PATCH 06/18] libdvbv5: implement dvb_fe_dummy for logging André Roth
2013-12-30 12:48 ` [PATCH 07/18] libdvbv5: fix EIT parsing André Roth
2014-01-07 17:00 ` Mauro Carvalho Chehab
2013-12-30 12:48 ` [PATCH 08/18] libdvbv5: implement MGT parser André Roth
2014-01-07 17:05 ` Mauro Carvalho Chehab
2013-12-30 12:48 ` [PATCH 09/18] libdvbv5: implement ATSC EIT André Roth
2014-01-07 17:12 ` Mauro Carvalho Chehab
2014-01-08 11:09 ` André Roth
2013-12-30 12:48 ` [PATCH 10/18] libdvbv5: prefix VCT with atsc_ instead of dvb_ André Roth
2013-12-30 12:48 ` [PATCH 11/18] libdvbv5: cleanup coding style André Roth
2014-01-07 17:23 ` Mauro Carvalho Chehab
2013-12-30 12:48 ` [PATCH 12/18] libdvbv5: fix missing includes André Roth
2013-12-30 12:48 ` [PATCH 13/18] libdvbv5: improve TS parsing André Roth
2014-01-07 17:27 ` Mauro Carvalho Chehab
2013-12-30 12:48 ` [PATCH 14/18] libdvbv5: cleanup dvb_nit_transport_foreach macro André Roth
2013-12-30 12:48 ` [PATCH 15/18] libdvbv5: remove c99 comments André Roth
2014-01-07 17:29 ` Mauro Carvalho Chehab
2013-12-30 12:48 ` [PATCH 17/18] libdvbv5: remove header files from SOURCES in Makefile.am André Roth
2014-01-07 17:30 ` Mauro Carvalho Chehab
2013-12-30 12:48 ` [PATCH 18/18] libdvbv5: README updated for shared libdvbv5 André Roth
2014-01-07 18:12 ` Mauro Carvalho Chehab
2014-01-07 16:32 ` [PATCH 01/18] 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).