libdvbv5: fix reading multisection tables
PATCH 1/13 libdvbv5: fix reading multisection tables
--- lib/libdvbv5/dvb-scan.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
lib/libdvbv5/dvb-scan.c +11 -7
@@ -187,15 +187,19 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,dvb_table_header_init (h);if (id !=-1 && h->id != id) {/* search for a specific table id */ continue ; - }else { -if (table_id ==-1 ) - table_id = h->id; -else if (h->id != table_id) { -dvb_logwarn ("dvb_read_section: table ID mismatch reading multi section table: %d != %d" , h->id, table_id); -continue ; - } } +/*if (id != -1) {*/ +/*if (table_id == -1)*/ +/*table_id = h->id;*/ +/*else if (h->id != table_id) {*/ +/*dvb_logwarn("dvb_read_section: table ID mismatch reading multi section table: %d != %d", h->id, table_id);*/ +/*free(buf);*/ +/*continue;*/ +/*}*/ +/*}*/ + +dvb_logerr ("dvb_read_section: got section %d, last %di, filter %d" , h->section_id, h->last_section, id );/* handle the sections */ if (first_section ==-1 ) first_section = h->section_id;
Signature · 1 line
1.8.3.2
PATCH 2/13 libdvbv5: ATSC VCT table support
--- lib/include/descriptors.h | 4 +- lib/include/descriptors/desc_service_location.h | 70 +++++++++++++++++++++++ lib/include/descriptors/vct.h | 5 +- lib/libdvbv5/Makefile.am | 3 +- lib/libdvbv5/descriptors.c | 2 +- lib/libdvbv5/descriptors/desc_service_location.c | 71 ++++++++++++++++++++++++ lib/libdvbv5/descriptors/vct.c | 1 + lib/libdvbv5/dvb-scan.c | 12 +++- 8 files changed, 162 insertions(+), 6 deletions(-) create mode 100644 lib/include/descriptors/desc_service_location.h create mode 100644 lib/libdvbv5/descriptors/desc_service_location.c
lib/include/descriptors.h +3 -1
@@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2011-2012 - Mauro Carvalho Chehab <[email protected]> * * 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,
lib/include/descriptors/desc_service_location.h new file +70 -0
70 lines not on this page · raw message
lib/include/descriptors/vct.h +3 -2
@@ -1,5 +1,6 @@/* -* Copyright (c) 2013 - Mauro Carvalho Chehab <[email protected]> +* Copyright (c) 2012 - Andre Roth <[email protected]> +* Copyright (c) 2013 - Andre Roth <[email protected]> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License
@@ -35,7 +36,7 @@ struct dvb_table_vct_channel {uint16_t __short_name[7 ];union { -uint16_t bitfield1; +uint32_t bitfield;struct {uint32_t modulation_mode:8 ;uint32_t minor_channel_number:10 ;
lib/libdvbv5/Makefile.am +2 -1
@@ -48,7 +48,8 @@ libdvbv5_la_SOURCES = \ descriptors/nit.c ../include/descriptors/nit.h \ descriptors/sdt.c ../include/descriptors/sdt.h \ descriptors/vct.c ../include/descriptors/vct.h \ - descriptors/eit.c ../include/descriptors/eit.h + descriptors/vct.c ../include/descriptors/vct.h \ + descriptors/desc_service_location.c ../include/descriptors/desc_service_location.h libdvbv5_la_CPPFLAGS = $(ENFORCE_LIBDVBV5_STATIC) libdvbv5_la_LDFLAGS = $(LIBDVBV5_VERSION) $(ENFORCE_LIBDVBV5_STATIC) -lm
lib/libdvbv5/descriptors.c +1 -1
@@ -69,7 +69,7 @@ void dvb_desc_default_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, stvoid 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); }
lib/libdvbv5/descriptors/desc_service_location.c new file +71 -0
71 lines not on this page · raw message
lib/libdvbv5/descriptors/vct.c +1 -0
@@ -1,5 +1,6 @@/* * Copyright (c) 2013 - Mauro Carvalho Chehab <[email protected]> +* Copyright (c) 2013 - Andre Roth <[email protected]> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License
lib/libdvbv5/dvb-scan.c +11 -1
@@ -185,6 +185,15 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd, h = (struct dvb_table_header *)buf;dvb_table_header_init (h); + +/* dvb_logdbg( "dvb_read_section: id %d, section %d/%d, current: %d", h->id, h->section_id, h->last_section, h->current_next ); */ +if (start_id == h->id && start_section == h->section_id) { +dvb_logdbg ("dvb_read_section: section repeated, reading done" ); +break ; + } +if (start_id ==-1 ) start_id = h->id; +if (start_section ==-1 ) start_section = h->section_id; +if (id !=-1 && h->id != id) {/* search for a specific table id */ continue ; }
@@ -232,7 +241,8 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,else dvb_logerr ("dvb_read_section: no initializer for table %d" , tid); -if (++sections == last_section +1 ) +if (id !=-1 && ++sections == last_section +1 ) { +dvb_logerr ("dvb_read_section: ++sections == last_section + 1" );break ; }free (buf);
Signature · 1 line
1.8.3.2
Re: [PATCH 02/13] libdvbv5: ATSC VCT table support
Em Sat, 28 Dec 2013 16:45:50 +0100
André Roth <[email protected]> escreveu:
Quoted 39 lines
Signed-off-by André Roth <[email protected]>--- lib/include/descriptors.h | 4 +- lib/include/descriptors/desc_service_location.h | 70 +++++++++++++++++++++++ lib/include/descriptors/vct.h | 5 +- lib/libdvbv5/Makefile.am | 3 +- lib/libdvbv5/descriptors.c | 2 +- lib/libdvbv5/descriptors/desc_service_location.c | 71 ++++++++++++++++++++++++ lib/libdvbv5/descriptors/vct.c | 1 + lib/libdvbv5/dvb-scan.c | 12 +++- 8 files changed, 162 insertions(+), 6 deletions(-) create mode 100644 lib/include/descriptors/desc_service_location.h create mode 100644 lib/libdvbv5/descriptors/desc_service_location.clib/include/descriptors.h +3
-1@@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2011-2012 - Mauro Carvalho Chehab <[email protected]> * * 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,lib/include/descriptors/desc_service_location.h new file +0
-0
lib/include/descriptors/desc_service_location.h line 2
Quoted 2 lines
lib/include/descriptors/desc_service_location.h new file +2
-0@@ -0,0 +1,70 @@ +/* +* Copyright (c) 2011-2012 - Mauro Carvalho Chehab <[email protected]>
I didn't wrote this code...
Quoted 73 lines
lib/include/descriptors/desc_service_location.h new file +68
-0+* Copyright (c) 2012 - Andre Roth <[email protected]> +* +* 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 lib/include/descriptors/vct.h +0
-0
lib/include/descriptors/vct.h line 2
Quoted 2 lines
lib/include/descriptors/vct.h +0
-1@@ -1,5 +1,6 @@/* -* Copyright (c) 2013 - Mauro Carvalho Chehab <[email protected]>
...but I wrote this one. Please don't remove my copyright here.
Quoted 6 lines
lib/include/descriptors/vct.h +2
-0+* Copyright (c) 2012 - Andre Roth <[email protected]> +* Copyright (c) 2013 - Andre Roth <[email protected]> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License
lib/include/descriptors/vct.h struct dvb_table_vct_channel { · line 42
Quoted 8 lines
lib/include/descriptors/vct.h +1
-1@@ -35,7 +36,7 @@ struct dvb_table_vct_channel {uint16_t __short_name[7 ];union { -uint16_t bitfield1; +uint32_t bitfield;struct {uint32_t modulation_mode:8 ;uint32_t minor_channel_number:10 ;
Huh? You're adding your copyright just due to this one line trival change?
Quoted 33 lines
lib/libdvbv5/Makefile.am +2
-1@@ -48,7 +48,8 @@ libdvbv5_la_SOURCES = \ descriptors/nit.c ../include/descriptors/nit.h \ descriptors/sdt.c ../include/descriptors/sdt.h \ descriptors/vct.c ../include/descriptors/vct.h \ - descriptors/eit.c ../include/descriptors/eit.h + descriptors/vct.c ../include/descriptors/vct.h \ + descriptors/desc_service_location.c ../include/descriptors/desc_service_location.h libdvbv5_la_CPPFLAGS = $(ENFORCE_LIBDVBV5_STATIC) libdvbv5_la_LDFLAGS = $(LIBDVBV5_VERSION) $(ENFORCE_LIBDVBV5_STATIC) -lmlib/libdvbv5/descriptors.c +1
-1@@ -69,7 +69,7 @@ void dvb_desc_default_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, stvoid 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); }lib/libdvbv5/descriptors/desc_service_location.c new file +0
-0
lib/libdvbv5/descriptors/desc_service_location.c line 2
Quoted 2 lines
lib/libdvbv5/descriptors/desc_service_location.c new file +2
-0@@ -0,0 +1,71 @@ +/* +* Copyright (c) 2011-2012 - Mauro Carvalho Chehab <[email protected]>
Again, I didn't write this parser. No need to add my copyright to it.
Quoted 16 lines
lib/libdvbv5/descriptors/desc_service_location.c new file +16
-0+* Copyright (c) 2012 - Andre Roth <[email protected]> +* +* 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
lib/libdvbv5/descriptors/desc_service_location.c line 28
Quoted 10 lines
lib/libdvbv5/descriptors/desc_service_location.c new file +10
-0+* +*/ + +#include "descriptors/desc_service_location.h" +#include "descriptors.h" +#include "dvb-fe.h" + +void dvb_desc_service_location_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf,struct dvb_desc *desc) +{ +struct dvb_desc_service_location *service_location = (struct dvb_desc_service_location *) desc;
Please add a space here, to split data declaration from code.
lib/libdvbv5/descriptors/desc_service_location.c line 35
Quoted 7 lines
lib/libdvbv5/descriptors/desc_service_location.c new file +7
-0+/* copy from .next */ +memcpy (((uint8_t *) service_location ) + +sizeof (service_location->type) + +sizeof (service_location->length) + +sizeof (service_location->next), + buf, +sizeof (service_location->bitfield) +sizeof (service_location->elements));
Before copying any data, please verify if are there enough data at the TS stream.
Take a look on the patches I wrote, since I fixed several such issues already.
lib/libdvbv5/descriptors/desc_service_location.c line 40
Quoted 5 lines
lib/libdvbv5/descriptors/desc_service_location.c new file +5
-0+ buf +=sizeof (service_location->bitfield) +sizeof (service_location->elements); + +bswap16 (service_location->bitfield); + +// FIXME: handle elements == 0
Don't use CC99 comments.
lib/libdvbv5/descriptors/desc_service_location.c line 43
Quoted 4 lines
lib/libdvbv5/descriptors/desc_service_location.c new file +3
-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;
Please don't mix data initialization with code. Move the above to the beginning of the function.
lib/libdvbv5/descriptors/desc_service_location.c line 45
Quoted 2 lines
lib/libdvbv5/descriptors/desc_service_location.c new file +2
-0+for (i =0 ; i < service_location->elements; i++) { +memcpy (element, buf,sizeof (struct dvb_desc_service_location_element ) -1 );/* no \0 in lang */
Again, please check before copy.
Quoted 4 lines
lib/libdvbv5/descriptors/desc_service_location.c new file +4
-0+ buf +=sizeof (struct dvb_desc_service_location_element ) -1 ; + element->language[3 ] ='\0' ; +bswap16 (element->bitfield); + element++;
lib/libdvbv5/descriptors/desc_service_location.c line 59
Quoted 10 lines
lib/libdvbv5/descriptors/desc_service_location.c new file +10
-0+ } +} + +void dvb_desc_service_location_print (struct dvb_v5_fe_parms *parms,const struct dvb_desc *desc) +{ +const struct dvb_desc_service_location *service_location = (const struct dvb_desc_service_location *) desc; +dvb_log ("| pcr pid %d" , service_location->pcr_pid); +dvb_log ("| streams:" ); +int i; +struct dvb_desc_service_location_element *element = service_location->element;
Don't mix code with data.
lib/libdvbv5/descriptors/desc_service_location.c line 68
Quoted 9 lines
lib/libdvbv5/descriptors/desc_service_location.c new file +9
-0+for (i =0 ; i < service_location->elements; i++) { +dvb_log ("| pid %d, type %d: %s" , element[i].elementary_pid, element[i].stream_type, element[i].language); + } +dvb_log ("| %d elements" , service_location->elements); +} + +void dvb_desc_service_location_free (struct dvb_desc *desc) +{ +const struct dvb_desc_service_location *service_location = (const struct dvb_desc_service_location *) desc;
Add a blank line to split data declarations from code.
Quoted 19 lines
lib/libdvbv5/descriptors/desc_service_location.c new file +3
-0+free (service_location->element); +} +lib/libdvbv5/descriptors/vct.c +1
-0@@ -1,5 +1,6 @@/* * Copyright (c) 2013 - Mauro Carvalho Chehab <[email protected]> +* Copyright (c) 2013 - Andre Roth <[email protected]> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License lib/libdvbv5/dvb-scan.c +0
-0
lib/libdvbv5/dvb-scan.c int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd, · line 189
Quoted 5 lines
lib/libdvbv5/dvb-scan.c +2
-0@@ -185,6 +185,15 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd, h = (struct dvb_table_header *)buf;dvb_table_header_init (h); + +/* dvb_logdbg( "dvb_read_section: id %d, section %d/%d, current: %d", h->id, h->section_id, h->last_section, h->current_next ); */
Why to add a commented line?
lib/libdvbv5/dvb-scan.c int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd, · line 199
Quoted 10 lines
lib/libdvbv5/dvb-scan.c +7
-0+if (start_id == h->id && start_section == h->section_id) { +dvb_logdbg ("dvb_read_section: section repeated, reading done" ); +break ; + } +if (start_id ==-1 ) start_id = h->id; +if (start_section ==-1 ) start_section = h->section_id; +if (id !=-1 && h->id != id) {/* search for a specific table id */ continue ; }
Hmm... you're re-adding the code you've removed on patch 01?
Please don't mix ATSC VCT descriptors with this changeset.
lib/libdvbv5/dvb-scan.c int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd, · line 245
Quoted 7 lines
lib/libdvbv5/dvb-scan.c +2
-1@@ -232,7 +241,8 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,else dvb_logerr ("dvb_read_section: no initializer for table %d" , tid); -if (++sections == last_section +1 ) +if (id !=-1 && ++sections == last_section +1 ) { +dvb_logerr ("dvb_read_section: ++sections == last_section + 1" );
Same here: don't mix duplicate section fixups with the ATSC VCT descriptor patch.
Quoted 3 lines
lib/libdvbv5/dvb-scan.c +0
-0break ; }free (buf);
Signature · 2 lines
Cheers, Mauro
PATCH 3/13 libdvbv5: mpeg elementary stream parsers
In reply to André Roth--- lib/include/descriptors/mpeg_es.h | 109 ++++++++++++++++++++++++++++++ lib/include/descriptors/mpeg_pes.h | 112 ++++++++++++++++++++++++++++++ lib/include/descriptors/mpeg_ts.h | 79 ++++++++++++++++++++++ lib/include/descriptors/nit.h | 4 +- lib/libdvbv5/Makefile.am | 5 +- lib/libdvbv5/descriptors/mpeg_es.c | 76 +++++++++++++++++++++ lib/libdvbv5/descriptors/mpeg_pes.c | 131 ++++++++++++++++++++++++++++++++++++ lib/libdvbv5/descriptors/mpeg_ts.c | 77 +++++++++++++++++++++ 8 files changed, 590 insertions(+), 3 deletions(-) create mode 100644 lib/include/descriptors/mpeg_es.h create mode 100644 lib/include/descriptors/mpeg_pes.h create mode 100644 lib/include/descriptors/mpeg_ts.h create mode 100644 lib/libdvbv5/descriptors/mpeg_es.c create mode 100644 lib/libdvbv5/descriptors/mpeg_pes.c create mode 100644 lib/libdvbv5/descriptors/mpeg_ts.c
lib/include/descriptors/mpeg_es.h new file +109 -0
@@ -0,0 +1,109 @@ +/* +* Copyright (c) 2012 - Andre Roth <[email protected]> +* +* 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
lib/include/descriptors/mpeg_pes.h new file +112 -0
112 lines not on this page · raw message
lib/include/descriptors/mpeg_ts.h new file +79 -0
79 lines not on this page · raw message
lib/include/descriptors/nit.h +2 -2
@@ -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;
lib/libdvbv5/Makefile.am +4 -1
@@ -49,7 +49,10 @@ libdvbv5_la_SOURCES = \ descriptors/sdt.c ../include/descriptors/sdt.h \ descriptors/vct.c ../include/descriptors/vct.h \ descriptors/vct.c ../include/descriptors/vct.h \ - descriptors/desc_service_location.c ../include/descriptors/desc_service_location.h + descriptors/desc_service_location.c ../include/descriptors/desc_service_location.h \ + descriptors/mpeg_ts.c ../include/descriptors/mpeg_ts.h \ + descriptors/mpeg_pes.c ../include/descriptors/mpeg_pes.h \ + descriptors/mpeg_es.c ../include/descriptors/mpeg_es.h libdvbv5_la_CPPFLAGS = $(ENFORCE_LIBDVBV5_STATIC) libdvbv5_la_LDFLAGS = $(LIBDVBV5_VERSION) $(ENFORCE_LIBDVBV5_STATIC) -lm
lib/libdvbv5/descriptors/mpeg_es.c new file +76 -0
76 lines not on this page · raw message
lib/libdvbv5/descriptors/mpeg_pes.c new file +131 -0
131 lines not on this page · raw message
lib/libdvbv5/descriptors/mpeg_ts.c new file +77 -0
77 lines not on this page · raw message
Signature · 1 line
1.8.3.2
Re: [PATCH 03/13] libdvbv5: mpeg elementary stream parsers
Em Sat, 28 Dec 2013 16:45:51 +0100
André Roth <[email protected]> escreveu:
Quoted 139 lines
Signed-off-by André Roth <[email protected]>--- lib/include/descriptors/mpeg_es.h | 109 ++++++++++++++++++++++++++++++ lib/include/descriptors/mpeg_pes.h | 112 ++++++++++++++++++++++++++++++ lib/include/descriptors/mpeg_ts.h | 79 ++++++++++++++++++++++ lib/include/descriptors/nit.h | 4 +- lib/libdvbv5/Makefile.am | 5 +- lib/libdvbv5/descriptors/mpeg_es.c | 76 +++++++++++++++++++++ lib/libdvbv5/descriptors/mpeg_pes.c | 131 ++++++++++++++++++++++++++++++++++++ lib/libdvbv5/descriptors/mpeg_ts.c | 77 +++++++++++++++++++++ 8 files changed, 590 insertions(+), 3 deletions(-) create mode 100644 lib/include/descriptors/mpeg_es.h create mode 100644 lib/include/descriptors/mpeg_pes.h create mode 100644 lib/include/descriptors/mpeg_ts.h create mode 100644 lib/libdvbv5/descriptors/mpeg_es.c create mode 100644 lib/libdvbv5/descriptors/mpeg_pes.c create mode 100644 lib/libdvbv5/descriptors/mpeg_ts.clib/include/descriptors/mpeg_es.h new file +109
-0@@ -0,0 +1,109 @@ +/* +* Copyright (c) 2012 - Andre Roth <[email protected]> +* +* 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 lib/include/descriptors/mpeg_pes.h new file +0
-0
lib/include/descriptors/mpeg_pes.h line 2
Quoted 2 lines
lib/include/descriptors/mpeg_pes.h new file +2
-0@@ -0,0 +1,112 @@ +/* +* Copyright (c) 2011-2012 - Mauro Carvalho Chehab <[email protected]>
Thanks, but I'm not the author of this code ;)
Quoted 116 lines
lib/include/descriptors/mpeg_pes.h new file +110
-0+* Copyright (c) 2012 - Andre Roth <[email protected]> +* +* 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 lib/include/descriptors/mpeg_ts.h new file +0
-0
lib/include/descriptors/mpeg_ts.h line 2
Quoted 2 lines
lib/include/descriptors/mpeg_ts.h new file +2
-0@@ -0,0 +1,79 @@ +/* +* Copyright (c) 2011-2012 - Mauro Carvalho Chehab <[email protected]>
I'm not the author ;)
Quoted 91 lines
lib/include/descriptors/mpeg_ts.h new file +77
-0+* Copyright (c) 2012 - Andre Roth <[email protected]> +* +* 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 lib/include/descriptors/nit.h +1
-1@@ -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;
lib/include/descriptors/nit.h struct dvb_table_nit { · line 67
Quoted 8 lines
lib/include/descriptors/nit.h +1
-1@@ -61,7 +61,7 @@ struct dvb_table_nit {struct {uint16_t desc_length:12 ;uint16_t reserved:4 ; - }; + } __attribute__((packed)); };struct dvb_desc *descriptor;struct dvb_table_nit_transport *transport;
Those changes on nit would be better on a separate fixup patch.
Quoted 60 lines
lib/libdvbv5/Makefile.am +4
-1@@ -49,7 +49,10 @@ libdvbv5_la_SOURCES = \ descriptors/sdt.c ../include/descriptors/sdt.h \ descriptors/vct.c ../include/descriptors/vct.h \ descriptors/vct.c ../include/descriptors/vct.h \ - descriptors/desc_service_location.c ../include/descriptors/desc_service_location.h + descriptors/desc_service_location.c ../include/descriptors/desc_service_location.h \ + descriptors/mpeg_ts.c ../include/descriptors/mpeg_ts.h \ + descriptors/mpeg_pes.c ../include/descriptors/mpeg_pes.h \ + descriptors/mpeg_es.c ../include/descriptors/mpeg_es.h libdvbv5_la_CPPFLAGS = $(ENFORCE_LIBDVBV5_STATIC) libdvbv5_la_LDFLAGS = $(LIBDVBV5_VERSION) $(ENFORCE_LIBDVBV5_STATIC) -lmlib/libdvbv5/descriptors/mpeg_es.c new file +38
-0@@ -0,0 +1,76 @@ +/* +* Copyright (c) 2012 - Andre Roth <[email protected]> +* +* 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" );
lib/libdvbv5/descriptors/mpeg_es.c line 48
Quoted 10 lines
lib/libdvbv5/descriptors/mpeg_es.c new file +10
-0+dvb_log (" - width %d" , seq_start->width); +dvb_log (" - height %d" , seq_start->height); +dvb_log (" - aspect %d" , seq_start->aspect); +dvb_log (" - framerate %d" , seq_start->framerate); +dvb_log (" - bitrate %d" , seq_start->bitrate); +dvb_log (" - one %d" , seq_start->one); +dvb_log (" - vbv %d" , seq_start->vbv); +dvb_log (" - constrained %d" , seq_start->constrained); +dvb_log (" - qm_intra %d" , seq_start->qm_intra); +dvb_log (" - qm_nonintra %d" , seq_start->qm_nonintra);
It seems that you're using spaces to indent. Please use tabs instead, where a tab means 8 positions.
Quoted 52 lines
lib/libdvbv5/descriptors/mpeg_es.c new file +28
-0+} + +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); +} +lib/libdvbv5/descriptors/mpeg_pes.c new file +18
-0@@ -0,0 +1,131 @@ +/* +* Copyright (c) 2012 - Andre Roth <[email protected]> +* +* 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 +*
lib/libdvbv5/descriptors/mpeg_pes.c line 28
Quoted 10 lines
lib/libdvbv5/descriptors/mpeg_pes.c new file +10
-0+*/ + +#include "descriptors/mpeg_pes.h" +#include "descriptors.h" +#include "dvb-fe.h" + +void dvb_mpeg_pes_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf,ssize_t buflen,uint8_t *table,ssize_t *table_length) +{ +struct dvb_mpeg_pes *pes = (struct dvb_mpeg_pes *) (table + *table_length); +const uint8_t *p = buf;
Add a blank line here.
lib/libdvbv5/descriptors/mpeg_pes.c line 29
Quoted 1 line
lib/libdvbv5/descriptors/mpeg_pes.c new file +1
-0+memcpy (table + *table_length, p,sizeof (struct dvb_mpeg_pes ));
Please check for buflen before copying.
Quoted 15 lines
lib/libdvbv5/descriptors/mpeg_pes.c new file +15
-0+ 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 ||
lib/libdvbv5/descriptors/mpeg_pes.c line 54
Quoted 10 lines
lib/libdvbv5/descriptors/mpeg_pes.c new file +10
-0+ pes->stream_id == DVB_MPEG_STREAM_ECM || + pes->stream_id == DVB_MPEG_STREAM_EMM || + pes->stream_id == DVB_MPEG_STREAM_DIRECTORY || + pes->stream_id == DVB_MPEG_STREAM_DSMCC || + pes->stream_id == DVB_MPEG_STREAM_H222E ) { + dvb_logerr("mpeg pes: unsupported stream type %#04x", pes->stream_id); + } else { +memcpy (pes->optional, p,sizeof (struct dvb_mpeg_pes_optional ) - +sizeof (pes->optional->pts) - +sizeof (pes->optional->dts));
Please use offset_of() instead of those ugly sizeof().
lib/libdvbv5/descriptors/mpeg_pes.c line 63
Quoted 9 lines
lib/libdvbv5/descriptors/mpeg_pes.c new file +9
-0+ p +=sizeof (struct dvb_mpeg_pes_optional ) - +sizeof (pes->optional->pts) - +sizeof (pes->optional->dts); +bswap16 (pes->optional->bitfield); + pes->optional->pts =0 ; + pes->optional->dts =0 ; +if (pes->optional->PTS_DTS &2 ) { +struct ts_t pts; +memcpy (&pts, p,sizeof (pts));
Please verify buflen before copy.
I suggest you to take a look on how I did at the NIT table parser, for an example.
Quoted 4 lines
lib/libdvbv5/descriptors/mpeg_pes.c new file +4
-0+ p +=sizeof (pts); +bswap16 (pts.bitfield); +bswap16 (pts.bitfield2); +if (pts.one !=1 || pts.one1 !=1 || pts.one2 !=1 )
lib/libdvbv5/descriptors/mpeg_pes.c line 77
Quoted 10 lines
lib/libdvbv5/descriptors/mpeg_pes.c new file +10
-0+dvb_logwarn ("mpeg pes: invalid pts" ); + else { + pes->optional->pts |= (uint64_t ) pts.bits00; + pes->optional->pts |= (uint64_t ) pts.bits15 <<15 ; + pes->optional->pts |= (uint64_t ) pts.bits30 <<30 ; + } + } +if (pes->optional->PTS_DTS &1 ) { +struct ts_t dts; +memcpy (&dts, p,sizeof (dts));
Again, please check before copying.
Quoted 77 lines
lib/libdvbv5/descriptors/mpeg_pes.c new file +54
-0+ 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 ); + } +} +lib/libdvbv5/descriptors/mpeg_ts.c new file +17
-0@@ -0,0 +1,77 @@ +/* +* Copyright (c) 2012 - Andre Roth <[email protected]> +* +* 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
lib/libdvbv5/descriptors/mpeg_ts.c line 27
Quoted 10 lines
lib/libdvbv5/descriptors/mpeg_ts.c new file +10
-0+* +*/ + +#include "descriptors/mpeg_ts.h" +#include "descriptors.h" +#include "dvb-fe.h" + +void dvb_mpeg_ts_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf,ssize_t buflen,uint8_t *table,ssize_t *table_length) +{ +if (buf[0 ] !=DVB_MPEG_TS ) {
Please check buflen before assuming that it contains 1 element.
lib/libdvbv5/descriptors/mpeg_ts.c line 33
Quoted 6 lines
lib/libdvbv5/descriptors/mpeg_ts.c new file +6
-0+dvb_logerr ("mpeg ts invalid marker %#02x, sould be %#02x" , buf[0 ],DVB_MPEG_TS ); + *table_length =0 ; +return ; + } +struct dvb_mpeg_ts *ts = (struct dvb_mpeg_ts *) table; +const uint8_t *p = buf;
Please move data declarations to the beginning.
lib/libdvbv5/descriptors/mpeg_ts.c line 34
Quoted 1 line
lib/libdvbv5/descriptors/mpeg_ts.c new file +1
-0+memcpy (table, p,sizeof (struct dvb_mpeg_ts ));
Please check bufsize.
Quoted 43 lines
lib/libdvbv5/descriptors/mpeg_ts.c new file +43
-0+ 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); + } +} +
Signature · 2 lines
Cheers, Mauro
PATCH 4/13 libdvbv5: fix deadlock on missing table sections
In reply to André Roth--- lib/libdvbv5/dvb-scan.c | 4 ++++ 1 file changed, 4 insertions(+)
lib/libdvbv5/dvb-scan.c +4 -0
@@ -96,6 +96,10 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,uint8_t *buf =NULL ;uint8_t *tbl =NULL ;ssize_t table_length =0 ; + +// handle sections +int start_id =-1 ; +int start_section =-1 ;int first_section =-1 ;int last_section =-1 ;int table_id =-1 ;
Signature · 1 line
1.8.3.2
Re: [PATCH 04/13] libdvbv5: fix deadlock on missing table sections
Em Sat, 28 Dec 2013 16:45:52 +0100
André Roth <[email protected]> escreveu:
Quoted 10 lines
Signed-off-by André Roth <[email protected]>--- lib/libdvbv5/dvb-scan.c | 4 ++++ 1 file changed, 4 insertions(+)lib/libdvbv5/dvb-scan.c +0
-0
lib/libdvbv5/dvb-scan.c int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd, · line 102
Quoted 7 lines
lib/libdvbv5/dvb-scan.c +4
-0@@ -96,6 +96,10 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,uint8_t *buf =NULL ;uint8_t *tbl =NULL ;ssize_t table_length =0 ; + +// handle sections +int start_id =-1 ; +int start_section =-1 ;
Again, this seems to be part of patch 1.
Quoted 3 lines
lib/libdvbv5/dvb-scan.c +0
-0int first_section =-1 ;int last_section =-1 ;int table_id =-1 ;
Signature · 2 lines
Cheers, Mauro
PATCH 5/13 libdvbv5: eit parsing updated
In reply to André Roth--- lib/include/descriptors.h | 6 ++++++ lib/include/descriptors/eit.h | 1 + lib/include/dvb-fe.h | 2 ++ lib/libdvbv5/descriptors.c | 1 + lib/libdvbv5/descriptors/eit.c | 28 +++++++++++++++++++++++----- lib/libdvbv5/dvb-fe.c | 7 +++++++ lib/libdvbv5/dvb-scan.c | 22 +++++++--------------- 7 files changed, 47 insertions(+), 20 deletions(-)
lib/include/descriptors.h +6 -0
@@ -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 ) \
lib/include/descriptors/eit.h +1 -0
@@ -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 {
lib/include/dvb-fe.h +2 -0
@@ -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,
lib/libdvbv5/descriptors.c +1 -0
@@ -69,6 +69,7 @@ void dvb_desc_default_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, stvoid 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); }
lib/libdvbv5/descriptors/eit.c +23 -5
@@ -29,6 +29,11 @@ void dvb_table_eit_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssizestruct dvb_table_eit_event **head;if (*table_length >0 ) { +memcpy (eit, p,sizeof (struct dvb_table_eit ) -sizeof (eit->event)); + +bswap16 (eit->transport_id); +bswap16 (eit->network_id); +/* find end of curent list */ head = &eit->event;while (*head !=NULL )
@@ -48,8 +53,18 @@ void dvb_table_eit_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssizestruct dvb_table_eit_event *last =NULL ;while ((uint8_t *) p < buf + buflen -4 ) {struct dvb_table_eit_event *event = (struct dvb_table_eit_event *)malloc (sizeof (struct dvb_table_eit_event )); -memcpy (event, p,sizeof (struct dvb_table_eit_event ) -sizeof (event->descriptor) -sizeof (event->next) -sizeof (event->start) -sizeof (event->duration)); - p +=sizeof (struct dvb_table_eit_event ) -sizeof (event->descriptor) -sizeof (event->next) -sizeof (event->start) -sizeof (event->duration); +memcpy (event, p,sizeof (struct dvb_table_eit_event ) - +sizeof (event->descriptor) - +sizeof (event->next) - +sizeof (event->start) - +sizeof (event->duration) - +sizeof (event->service_id)); + p +=sizeof (struct dvb_table_eit_event ) - +sizeof (event->descriptor) - +sizeof (event->next) - +sizeof (event->start) - +sizeof (event->duration) - +sizeof (event->service_id);bswap16 (event->event_id);bswap16 (event->bitfield);
@@ -57,9 +72,11 @@ void dvb_table_eit_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize event->descriptor =NULL ; event->next =NULL ;dvb_time (event->dvbstart, &event->start); - event->duration =bcd (event->dvbduration[0 ]) *3600 + -bcd (event->dvbduration[1 ]) *60 + -bcd (event->dvbduration[2 ]); + event->duration =bcd ((uint32_t ) event->dvbduration[0 ]) *3600 + +bcd ((uint32_t ) event->dvbduration[1 ]) *60 + +bcd ((uint32_t ) event->dvbduration[2 ]); + + event->service_id = eit->header.id;if (!*head) *head = event;
@@ -102,6 +119,7 @@ void dvb_table_eit_print(struct dvb_v5_fe_parms *parms, struct dvb_table_eit *eichar 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);
lib/libdvbv5/dvb-fe.c +7 -0
@@ -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) {
lib/libdvbv5/dvb-scan.c +7 -15
@@ -102,7 +102,7 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,int start_section =-1 ;int first_section =-1 ;int last_section =-1 ; -int table_id =-1 ; +/*int table_id = -1;*/ int sections =0 ;struct dmx_sct_filter_params f;struct dvb_table_header *h;
@@ -112,7 +112,6 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd, *table =NULL ;// FIXME: verify known table -memset (&f,0 ,sizeof (f)); f.pid = pid; f.filter.filter[0 ] = tid;
@@ -202,21 +201,11 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,continue ; } -/*if (id != -1) {*/ -/*if (table_id == -1)*/ -/*table_id = h->id;*/ -/*else if (h->id != table_id) {*/ -/*dvb_logwarn("dvb_read_section: table ID mismatch reading multi section table: %d != %d", h->id, table_id);*/ -/*free(buf);*/ -/*continue;*/ -/*}*/ -/*}*/ - -dvb_logerr ("dvb_read_section: got section %d, last %di, filter %d" , h->section_id, h->last_section, id ); +/*dvb_logerr("dvb_read_section: got section %d, last %d, filter %d", h->section_id, h->last_section, id );*/ /* handle the sections */ if (first_section ==-1 ) first_section = h->section_id; -else if (h->section_id == first_section) +else if (start_id == h->id && h->section_id == first_section)break ;if (last_section ==-1 )
@@ -248,8 +237,11 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,if (id !=-1 && ++sections == last_section +1 ) {dvb_logerr ("dvb_read_section: ++sections == last_section + 1" );break ; + } } -free (buf); + +if (buf) +free (buf);dvb_dmx_stop (dmx_fd);
Signature · 1 line
1.8.3.2
Re: [PATCH 05/13] libdvbv5: eit parsing updated
Em Sat, 28 Dec 2013 16:45:53 +0100
André Roth <[email protected]> escreveu:
Quoted 46 lines
Signed-off-by André Roth <[email protected]>--- lib/include/descriptors.h | 6 ++++++ lib/include/descriptors/eit.h | 1 + lib/include/dvb-fe.h | 2 ++ lib/libdvbv5/descriptors.c | 1 + lib/libdvbv5/descriptors/eit.c | 28 +++++++++++++++++++++++----- lib/libdvbv5/dvb-fe.c | 7 +++++++ lib/libdvbv5/dvb-scan.c | 22 +++++++--------------- 7 files changed, 47 insertions(+), 20 deletions(-)lib/include/descriptors.h +6
-0@@ -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 ) \lib/include/descriptors/eit.h +1
-0@@ -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 {lib/include/dvb-fe.h +0
-0
lib/include/dvb-fe.h struct dvb_v5_fe_parms { · line 123
Quoted 5 lines
lib/include/dvb-fe.h +2
-0@@ -119,6 +119,8 @@ struct dvb_v5_fe_parms {extern "C" {#endif +struct dvb_v5_fe_parms *dvb_fe_dummy (); +
Not sure if I understood or liked this. Please add a description on the patch, explaining what you're doing and why a dvb_fe_dummy() function is needed.
lib/libdvbv5/descriptors.c void dvb_desc_default_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, st · line 72
Quoted 12 lines
lib/include/dvb-fe.h +0
-0struct 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,lib/libdvbv5/descriptors.c +1
-0@@ -69,6 +69,7 @@ void dvb_desc_default_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, stvoid dvb_desc_default_print (struct dvb_v5_fe_parms *parms,const struct dvb_desc *desc) { +if (!parms) parms =dvb_fe_dummy ();
Please put the set statement on a different line.
lib/libdvbv5/descriptors/eit.c void dvb_table_eit_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize · line 32
Quoted 12 lines
lib/libdvbv5/descriptors.c +0
-0dvb_log ("| %s (%#02x)" , dvb_descriptors[desc->type].name, desc->type);hexdump (parms,"| " , desc->data, desc->length); }lib/libdvbv5/descriptors/eit.c +1
-0@@ -29,6 +29,11 @@ void dvb_table_eit_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssizestruct dvb_table_eit_event **head;if (*table_length >0 ) { +memcpy (eit, p,sizeof (struct dvb_table_eit ) -sizeof (eit->event));
Check for size before copying.
Quoted 9 lines
lib/libdvbv5/descriptors/eit.c +4
-0+ +bswap16 (eit->transport_id); +bswap16 (eit->network_id); +/* find end of curent list */ head = &eit->event;while (*head !=NULL )@@ -48,8 +53,18 @@ void dvb_table_eit_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssizestruct dvb_table_eit_event *last =NULL ;
lib/libdvbv5/descriptors/eit.c void dvb_table_eit_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize · line 61
Quoted 10 lines
lib/libdvbv5/descriptors/eit.c +6
-2while ((uint8_t *) p < buf + buflen -4 ) {struct dvb_table_eit_event *event = (struct dvb_table_eit_event *)malloc (sizeof (struct dvb_table_eit_event )); -memcpy (event, p,sizeof (struct dvb_table_eit_event ) -sizeof (event->descriptor) -sizeof (event->next) -sizeof (event->start) -sizeof (event->duration)); - p +=sizeof (struct dvb_table_eit_event ) -sizeof (event->descriptor) -sizeof (event->next) -sizeof (event->start) -sizeof (event->duration); +memcpy (event, p,sizeof (struct dvb_table_eit_event ) - +sizeof (event->descriptor) - +sizeof (event->next) - +sizeof (event->start) - +sizeof (event->duration) - +sizeof (event->service_id));
Please replace those ugly sizeof() by offset_of(). Makes the code more readable and easier to analize.
Also, please check for buf size before copying.
Quoted 100 lines
lib/libdvbv5/descriptors/eit.c +12
-3+ p +=sizeof (struct dvb_table_eit_event ) - +sizeof (event->descriptor) - +sizeof (event->next) - +sizeof (event->start) - +sizeof (event->duration) - +sizeof (event->service_id);bswap16 (event->event_id);bswap16 (event->bitfield);@@ -57,9 +72,11 @@ void dvb_table_eit_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize event->descriptor =NULL ; event->next =NULL ;dvb_time (event->dvbstart, &event->start); - event->duration =bcd (event->dvbduration[0 ]) *3600 + -bcd (event->dvbduration[1 ]) *60 + -bcd (event->dvbduration[2 ]); + event->duration =bcd ((uint32_t ) event->dvbduration[0 ]) *3600 + +bcd ((uint32_t ) event->dvbduration[1 ]) *60 + +bcd ((uint32_t ) event->dvbduration[2 ]); + + event->service_id = eit->header.id;if (!*head) *head = event;@@ -102,6 +119,7 @@ void dvb_table_eit_print(struct dvb_v5_fe_parms *parms, struct dvb_table_eit *eichar 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);lib/libdvbv5/dvb-fe.c +7
-0@@ -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) {lib/libdvbv5/dvb-scan.c +3
-14@@ -102,7 +102,7 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,int start_section =-1 ;int first_section =-1 ;int last_section =-1 ; -int table_id =-1 ; +/*int table_id = -1;*/ int sections =0 ;struct dmx_sct_filter_params f;struct dvb_table_header *h;@@ -112,7 +112,6 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd, *table =NULL ;// FIXME: verify known table -memset (&f,0 ,sizeof (f)); f.pid = pid; f.filter.filter[0 ] = tid;@@ -202,21 +201,11 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,continue ; } -/*if (id != -1) {*/ -/*if (table_id == -1)*/ -/*table_id = h->id;*/ -/*else if (h->id != table_id) {*/ -/*dvb_logwarn("dvb_read_section: table ID mismatch reading multi section table: %d != %d", h->id, table_id);*/ -/*free(buf);*/ -/*continue;*/ -/*}*/ -/*}*/ - -dvb_logerr ("dvb_read_section: got section %d, last %di, filter %d" , h->section_id, h->last_section, id ); +/*dvb_logerr("dvb_read_section: got section %d, last %d, filter %d", h->section_id, h->last_section, id );*/ /* handle the sections */ if (first_section ==-1 ) first_section = h->section_id; -else if (h->section_id == first_section) +else if (start_id == h->id && h->section_id == first_section)break ;if (last_section ==-1 )@@ -248,8 +237,11 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,if (id !=-1 && ++sections == last_section +1 ) {dvb_logerr ("dvb_read_section: ++sections == last_section + 1" );
lib/libdvbv5/dvb-scan.c int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd, · line 247
Quoted 10 lines
lib/libdvbv5/dvb-scan.c +4
-1break ; + } } -free (buf); + +if (buf) +free (buf);dvb_dmx_stop (dmx_fd);
The above should be at patch 1. It is being really confusing to understand what you're doing with all those changes to the table sequencing parser.
Signature · 2 lines
Cheers, Mauro
PATCH 6/13 libdvbv5: fix eit times
In reply to André Roth--- lib/libdvbv5/descriptors/eit.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
lib/libdvbv5/descriptors/eit.c +2 -3
@@ -155,9 +155,8 @@ void dvb_time(const uint8_t data[5], struct tm *tm) tm->tm_mday = day; tm->tm_mon = month -1 ; tm->tm_year = year; - tm->tm_isdst =-1 ; - tm->tm_wday =0 ; - tm->tm_yday =0 ; + tm->tm_isdst =1 ;// dst in effect, do not adjust +mktime ( tm ); }
Signature · 1 line
1.8.3.2
Re: [PATCH 06/13] libdvbv5: fix eit times
Em Sat, 28 Dec 2013 16:45:54 +0100
André Roth <[email protected]> escreveu:
Quoted 10 lines
Signed-off-by André Roth <[email protected]>--- lib/libdvbv5/descriptors/eit.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)lib/libdvbv5/descriptors/eit.c +0
-0
lib/libdvbv5/descriptors/eit.c void dvb_time(const uint8_t data[5], struct tm *tm) · line 158
Quoted 7 lines
lib/libdvbv5/descriptors/eit.c +1
-3@@ -155,9 +155,8 @@ void dvb_time(const uint8_t data[5], struct tm *tm) tm->tm_mday = day; tm->tm_mon = month -1 ; tm->tm_year = year; - tm->tm_isdst =-1 ; - tm->tm_wday =0 ; - tm->tm_yday =0 ; + tm->tm_isdst =1 ;// dst in effect, do not adjust
Please don't use c99 comments.
lib/libdvbv5/descriptors/eit.c void dvb_time(const uint8_t data[5], struct tm *tm) · line 159
Quoted 1 line
lib/libdvbv5/descriptors/eit.c +1
-0+mktime ( tm );
Please remove the extra spaces.
Quoted 3 lines
lib/libdvbv5/descriptors/eit.c +0
-0}
Signature · 2 lines
Cheers, Mauro
PATCH 7/13 libdvbv5: MGT parser
In reply to André Roth--- lib/include/descriptors/mgt.h | 82 ++++++++++++++++++++++++++++++ lib/libdvbv5/Makefile.am | 1 + lib/libdvbv5/descriptors.c | 1 + lib/libdvbv5/descriptors/mgt.c | 113 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 197 insertions(+) create mode 100644 lib/include/descriptors/mgt.h create mode 100644 lib/libdvbv5/descriptors/mgt.c
lib/include/descriptors/mgt.h new file +82 -0
@@ -0,0 +1,82 @@ +/* +* Copyright (c) 2011-2012 - Mauro Carvalho Chehab <[email protected]> +* Copyright (c) 2013 - Andre Roth <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation version 2 +* of the License. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html +* +*/ + +#ifndef _MGT_H +#define _MGT_H + +#include <stdint.h> +#include <unistd.h> /* ssize_t */ + +#include "descriptors/header.h" +#include "descriptors.h" + +#define DVB_TABLE_MGT 0xC7 + +struct dvb_table_mgt_table { +uint16_t type; +union { +uint16_t bitfield; +struct { +uint16_t pid:13 ; +uint16_t one:3 ; + } __attribute__((packed)); + } __attribute__((packed)); +uint8_t type_version:5 ; +uint8_t one2:3 ; +uint32_t size; +union { +uint16_t bitfield2; +struct { +uint16_t desc_length:12 ; +uint16_t one3:4 ; + } __attribute__((packed)); + } __attribute__((packed)); +struct dvb_desc *descriptor; +struct dvb_table_mgt_table *next; +} __attribute__((packed)); + +struct dvb_table_mgt { +struct dvb_table_header header; +uint8_t protocol_version; +uint16_t tables; +struct dvb_table_mgt_table *table; +struct dvb_desc *descriptor; +} __attribute__((packed)); + + +#define dvb_mgt_transport_foreach ( tran, mgt ) \ + for( struct dvb_table_mgt_transport *tran = mgt->transport; tran; tran = tran->next ) \ + +struct dvb_v5_fe_parms ; + +#ifdef __cplusplus +extern "C" { +#endif + +void dvb_table_mgt_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf,ssize_t buflen,uint8_t *table,ssize_t *table_length); +void dvb_table_mgt_free (struct dvb_table_mgt *mgt); +void dvb_table_mgt_print (struct dvb_v5_fe_parms *parms,struct dvb_table_mgt *mgt); + +#ifdef __cplusplus +} +#endif + +#endif
lib/libdvbv5/Makefile.am +1 -0
@@ -49,6 +49,7 @@ libdvbv5_la_SOURCES = \ descriptors/sdt.c ../include/descriptors/sdt.h \ descriptors/vct.c ../include/descriptors/vct.h \ descriptors/vct.c ../include/descriptors/vct.h \ + descriptors/mgt.c ../include/descriptors/mgt.h \ descriptors/desc_service_location.c ../include/descriptors/desc_service_location.h \ descriptors/mpeg_ts.c ../include/descriptors/mpeg_ts.h \ descriptors/mpeg_pes.c ../include/descriptors/mpeg_pes.h \
lib/libdvbv5/descriptors.c +1 -0
@@ -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"
lib/libdvbv5/descriptors/mgt.c new file +113 -0
113 lines not on this page · raw message
Signature · 1 line
1.8.3.2
Re: [PATCH 07/13] libdvbv5: MGT parser
Em Sat, 28 Dec 2013 16:45:55 +0100
André Roth <[email protected]> escreveu:
Quoted 16 lines
Signed-off-by André Roth <[email protected]>--- lib/include/descriptors/mgt.h | 82 ++++++++++++++++++++++++++++++ lib/libdvbv5/Makefile.am | 1 + lib/libdvbv5/descriptors.c | 1 + lib/libdvbv5/descriptors/mgt.c | 113 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 197 insertions(+) create mode 100644 lib/include/descriptors/mgt.h create mode 100644 lib/libdvbv5/descriptors/mgt.clib/include/descriptors/mgt.h new file +0
-0
lib/include/descriptors/mgt.h line 2
Quoted 2 lines
lib/include/descriptors/mgt.h new file +2
-0@@ -0,0 +1,82 @@ +/* +* Copyright (c) 2011-2012 - Mauro Carvalho Chehab <[email protected]>
I'm not the author.
Quoted 110 lines
lib/include/descriptors/mgt.h new file +80
-0+* Copyright (c) 2013 - Andre Roth <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation version 2 +* of the License. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html +* +*/ + +#ifndef _MGT_H +#define _MGT_H + +#include <stdint.h> +#include <unistd.h> /* ssize_t */ + +#include "descriptors/header.h" +#include "descriptors.h" + +#define DVB_TABLE_MGT 0xC7 + +struct dvb_table_mgt_table { +uint16_t type; +union { +uint16_t bitfield; +struct { +uint16_t pid:13 ; +uint16_t one:3 ; + } __attribute__((packed)); + } __attribute__((packed)); +uint8_t type_version:5 ; +uint8_t one2:3 ; +uint32_t size; +union { +uint16_t bitfield2; +struct { +uint16_t desc_length:12 ; +uint16_t one3:4 ; + } __attribute__((packed)); + } __attribute__((packed)); +struct dvb_desc *descriptor; +struct dvb_table_mgt_table *next; +} __attribute__((packed)); + +struct dvb_table_mgt { +struct dvb_table_header header; +uint8_t protocol_version; +uint16_t tables; +struct dvb_table_mgt_table *table; +struct dvb_desc *descriptor; +} __attribute__((packed)); + + +#define dvb_mgt_transport_foreach ( tran, mgt ) \ + for( struct dvb_table_mgt_transport *tran = mgt->transport; tran; tran = tran->next ) \ + +struct dvb_v5_fe_parms ; + +#ifdef __cplusplus +extern "C" { +#endif + +void dvb_table_mgt_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf,ssize_t buflen,uint8_t *table,ssize_t *table_length); +void dvb_table_mgt_free (struct dvb_table_mgt *mgt); +void dvb_table_mgt_print (struct dvb_v5_fe_parms *parms,struct dvb_table_mgt *mgt); + +#ifdef __cplusplus +} +#endif + +#endif lib/libdvbv5/Makefile.am +1
-0@@ -49,6 +49,7 @@ libdvbv5_la_SOURCES = \ descriptors/sdt.c ../include/descriptors/sdt.h \ descriptors/vct.c ../include/descriptors/vct.h \ descriptors/vct.c ../include/descriptors/vct.h \ + descriptors/mgt.c ../include/descriptors/mgt.h \ descriptors/desc_service_location.c ../include/descriptors/desc_service_location.h \ descriptors/mpeg_ts.c ../include/descriptors/mpeg_ts.h \ descriptors/mpeg_pes.c ../include/descriptors/mpeg_pes.h \lib/libdvbv5/descriptors.c +1
-0@@ -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" lib/libdvbv5/descriptors/mgt.c new file +0
-0
lib/libdvbv5/descriptors/mgt.c line 2
Quoted 2 lines
lib/libdvbv5/descriptors/mgt.c new file +2
-0@@ -0,0 +1,113 @@ +/* +* Copyright (c) 2011-2012 - Mauro Carvalho Chehab <[email protected]>
I'm not the author.
Quoted 30 lines
lib/libdvbv5/descriptors/mgt.c new file +30
-0+* Copyright (c) 2012 - Andre Roth <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation version 2 +* of the License. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html +* +*/ + +#include "descriptors/mgt.h" +#include "dvb-fe.h" + +void dvb_table_mgt_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf,ssize_t buflen,uint8_t *table,ssize_t *table_length) +{ +const uint8_t *p = buf; +struct dvb_table_mgt *mgt = (struct dvb_table_mgt *) table; +struct dvb_desc **head_desc; +struct dvb_table_mgt_table **head; +/*int desc_length;*/ +
lib/libdvbv5/descriptors/mgt.c line 42
Quoted 10 lines
lib/libdvbv5/descriptors/mgt.c new file +10
-0+if (*table_length >0 ) { +/* find end of curent lists */ + head_desc = &mgt->descriptor; +while (*head_desc !=NULL ) + head_desc = &(*head_desc)->next; + head = &mgt->table; +while (*head !=NULL ) + head = &(*head)->next; + }else { +memcpy (table, p,sizeof (struct dvb_table_mgt ) -sizeof (mgt->descriptor) -sizeof (mgt->table));
Check before copy. Use offset_of().
Quoted 4 lines
lib/libdvbv5/descriptors/mgt.c new file +4
-0+ *table_length =sizeof (struct dvb_table_mgt ); + + mgt->descriptor =NULL ; + mgt->table =NULL ;
lib/libdvbv5/descriptors/mgt.c line 56
Quoted 10 lines
lib/libdvbv5/descriptors/mgt.c new file +10
-0+ head_desc = &mgt->descriptor; + head = &mgt->table; +bswap16 (mgt->tables); + } + p +=sizeof (struct dvb_table_mgt ) -sizeof (mgt->descriptor) -sizeof (mgt->table); + +/*dvb_parse_descriptors(parms, p, desc_length, head_desc);*/ +/*p += desc_length;*/ +int i =0 ; +struct dvb_table_mgt_table *last =NULL ;
Data at beginning of the function.
Quoted 57 lines
lib/libdvbv5/descriptors/mgt.c new file +57
-0+while (i++ < mgt->tables && (uint8_t *) p < buf + buflen -4 ) { +struct dvb_table_mgt_table *table = (struct dvb_table_mgt_table *)malloc (sizeof (struct dvb_table_mgt_table )); +memcpy (table, p,sizeof (struct dvb_table_mgt_table ) -sizeof (table->descriptor) -sizeof (table->next)); + p +=sizeof (struct dvb_table_mgt_table ) -sizeof (table->descriptor) -sizeof (table->next); + +bswap16 (table->type); +bswap16 (table->bitfield); +bswap16 (table->bitfield2); +bswap32 (table->size); + table->descriptor =NULL ; + table->next =NULL ; + +if (!*head) + *head = table; +if (last) + last->next = table; + +/* get the descriptors for each table */ +struct dvb_desc **head_desc = &table->descriptor; +dvb_parse_descriptors (parms, p, table->desc_length, head_desc); + + p += table->desc_length; + last = table; + } +} + +void dvb_table_mgt_free (struct dvb_table_mgt *mgt) +{ +struct dvb_table_mgt_table *table = mgt->table; +dvb_free_descriptors ((struct dvb_desc **) &mgt->descriptor); +while (table) { +dvb_free_descriptors ((struct dvb_desc **) &table->descriptor); +struct dvb_table_mgt_table *tmp = table; + table = table->next; +free (tmp); + } +free (mgt); +} + +void dvb_table_mgt_print (struct dvb_v5_fe_parms *parms,struct dvb_table_mgt *mgt) +{ +dvb_log ("MGT" ); +dvb_table_header_print (parms, &mgt->header); +dvb_log ("| protocol_version %d" , mgt->protocol_version); +dvb_log ("| tables %d" , mgt->tables); +/*dvb_print_descriptors(parms, mgt->descriptor);*/ +const struct dvb_table_mgt_table *table = mgt->table; +uint16_t tables =0 ; +while (table) { +dvb_log ("|- type %04x %d" , table->type, table->pid); +dvb_print_descriptors (parms, table->descriptor); + table = table->next; + tables++; + } +dvb_log ("|_ %d tables" , tables); +} +
Signature · 2 lines
Cheers, Mauro
PATCH 8/13 libdvbv5: ATSC EIT
In reply to André Roth--- lib/include/descriptors/atsc_eit.h | 91 +++++++++++++++++++++ lib/include/descriptors/atsc_header.h | 64 +++++++++++++++ lib/include/descriptors/mgt.h | 25 +++--- lib/include/descriptors/vct.h | 39 ++++----- lib/include/dvb-scan.h | 2 +- lib/libdvbv5/Makefile.am | 3 + lib/libdvbv5/descriptors.c | 19 +++-- lib/libdvbv5/descriptors/atsc_eit.c | 143 +++++++++++++++++++++++++++++++++ lib/libdvbv5/descriptors/atsc_header.c | 48 +++++++++++ lib/libdvbv5/descriptors/eit.c | 2 +- lib/libdvbv5/descriptors/mgt.c | 41 +++++----- lib/libdvbv5/descriptors/vct.c | 39 +++++---- lib/libdvbv5/dvb-file.c | 2 +- lib/libdvbv5/dvb-scan.c | 10 +-- 14 files changed, 442 insertions(+), 86 deletions(-) create mode 100644 lib/include/descriptors/atsc_eit.h create mode 100644 lib/include/descriptors/atsc_header.h create mode 100644 lib/libdvbv5/descriptors/atsc_eit.c create mode 100644 lib/libdvbv5/descriptors/atsc_header.c
lib/include/descriptors/atsc_eit.h new file +91 -0
@@ -0,0 +1,91 @@ +/* +* Copyright (c) 2011-2012 - Mauro Carvalho Chehab <[email protected]> +* Copyright (c) 2012 - Andre Roth <[email protected]> +* +* 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
lib/include/descriptors/atsc_header.h new file +64 -0
64 lines not on this page · raw message
lib/include/descriptors/mgt.h +12 -13
@@ -25,12 +25,12 @@#include <stdint.h> #include <unistd.h> /* ssize_t */ -#include "descriptors/header.h" +#include "descriptors/atsc_header.h" #include "descriptors.h" -#define DVB_TABLE_MGT 0xC7 +#define ATSC_TABLE_MGT 0xC7 -struct dvb_table_mgt_table { +struct atsc_table_mgt_table {uint16_t type;union {uint16_t bitfield;
@@ -50,20 +50,19 @@ struct dvb_table_mgt_table { } __attribute__((packed)); } __attribute__((packed));struct dvb_desc *descriptor; -struct dvb_table_mgt_table *next; +struct atsc_table_mgt_table *next; } __attribute__((packed)); -struct dvb_table_mgt { -struct dvb_table_header header; -uint8_t protocol_version; +struct atsc_table_mgt { +struct atsc_table_header header;uint16_t tables; -struct dvb_table_mgt_table *table; +struct atsc_table_mgt_table *table;struct dvb_desc *descriptor; } __attribute__((packed)); -#define dvb_mgt_transport_foreach ( tran, mgt ) \ - for( struct dvb_table_mgt_transport *tran = mgt->transport; tran; tran = tran->next ) \ +#define dvb_mgt_table_foreach ( tran, mgt ) \ + for( struct dvb_table_mgt_table *tran = mgt->table; tran; tran = tran->next ) \struct dvb_v5_fe_parms ;
@@ -71,9 +70,9 @@ struct dvb_v5_fe_parms;extern "C" {#endif -void dvb_table_mgt_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf,ssize_t buflen,uint8_t *table,ssize_t *table_length); -void dvb_table_mgt_free (struct dvb_table_mgt *mgt); -void dvb_table_mgt_print (struct dvb_v5_fe_parms *parms,struct dvb_table_mgt *mgt); +void atsc_table_mgt_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf,ssize_t buflen,uint8_t *table,ssize_t *table_length); +void atsc_table_mgt_free (struct atsc_table_mgt *mgt); +void atsc_table_mgt_print (struct dvb_v5_fe_parms *parms,struct atsc_table_mgt *mgt); #ifdef __cplusplus }
lib/include/descriptors/vct.h +20 -19
@@ -25,25 +25,25 @@#include <stdint.h> #include <unistd.h> /* ssize_t */ -#include "descriptors/header.h" +#include "descriptors/atsc_header.h" #include "descriptors.h" -#define DVB_TABLE_TVCT 0xc8 -#define DVB_TABLE_CVCT 0xc9 -#define DVB_TABLE_VCT_PID 0x1ffb +#define ATSC_TABLE_TVCT 0xc8 +#define ATSC_TABLE_CVCT 0xc9 +#define ATSC_TABLE_VCT_PID 0x1ffb -struct dvb_table_vct_channel { +struct atsc_table_vct_channel {uint16_t __short_name[7 ];union { -uint32_t bitfield; +uint32_t bitfield1;struct {uint32_t modulation_mode:8 ;uint32_t minor_channel_number:10 ;uint32_t major_channel_number:10 ;uint32_t reserved1:4 ; } __attribute__((packed)); - }; + } __attribute__((packed));uint32_t carrier_frequency;uint16_t channel_tsid;
@@ -61,7 +61,8 @@ struct dvb_table_vct_channel { uint16_t ETM_location:2; } __attribute__((packed)); - }; + } __attribute__((packed)); +uint16_t source_id;union {uint16_t bitfield3;
@@ -69,22 +70,22 @@ struct dvb_table_vct_channel { uint16_t descriptors_length:10; uint16_t reserved3:6; } __attribute__((packed)); - }; + } __attribute__((packed));/* * Everything after descriptor (including it) won't be bit-mapped * to the data parsed from the MPEG TS. So, metadata are added there */ struct dvb_desc *descriptor; -struct dvb_table_vct_channel *next; +struct atsc_table_vct_channel *next;/* The channel_short_name is converted to locale charset by vct.c */ char short_name[32 ]; } __attribute__((packed)); -struct dvb_table_vct { -struct dvb_table_header header; +struct atsc_table_vct { +struct atsc_table_header header;uint8_t ATSC_protocol_version;uint8_t num_channels_in_section;
@@ -93,12 +94,12 @@ struct dvb_table_vct {* Everything after descriptor (including it) won't be bit-mapped * to the data parsed from the MPEG TS. So, metadata are added there */ -struct dvb_table_vct_channel *channel; +struct atsc_table_vct_channel *channel;struct dvb_desc *descriptor; } __attribute__((packed)); -union dvb_table_vct_descriptor_length { +union atsc_table_vct_descriptor_length {uint16_t bitfield;struct {uint16_t descriptor_length:10 ;
@@ -106,8 +107,8 @@ union dvb_table_vct_descriptor_length { }; }; -#define dvb_vct_channel_foreach (_channel, _vct) \ - for (struct dvb_table_vct_channel *_channel = _vct->channel; _channel; _channel = _channel->next) \ +#define atsc_vct_channel_foreach (_channel, _vct) \ + for (struct atsc_table_vct_channel *_channel = _vct->channel; _channel; _channel = _channel->next) \struct dvb_v5_fe_parms ;
@@ -115,9 +116,9 @@ struct dvb_v5_fe_parms;extern "C" {#endif -void dvb_table_vct_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf,ssize_t buflen,uint8_t *table,ssize_t *table_length); -void dvb_table_vct_free (struct dvb_table_vct *vct); -void dvb_table_vct_print (struct dvb_v5_fe_parms *parms,struct dvb_table_vct *vct); +void atsc_table_vct_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf,ssize_t buflen,uint8_t *table,ssize_t *table_length); +void atsc_table_vct_free (struct atsc_table_vct *vct); +void atsc_table_vct_print (struct dvb_v5_fe_parms *parms,struct atsc_table_vct *vct); #ifdef __cplusplus }
lib/include/dvb-scan.h +1 -1
@@ -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;
lib/libdvbv5/Makefile.am +3 -0
@@ -48,8 +48,11 @@ libdvbv5_la_SOURCES = \ descriptors/nit.c ../include/descriptors/nit.h \ descriptors/sdt.c ../include/descriptors/sdt.h \ descriptors/vct.c ../include/descriptors/vct.h \ + descriptors/atsc_header.c ../include/descriptors/atsc_header.h \ descriptors/vct.c ../include/descriptors/vct.h \ descriptors/mgt.c ../include/descriptors/mgt.h \ + descriptors/eit.c ../include/descriptors/eit.h \ + descriptors/atsc_eit.c ../include/descriptors/atsc_eit.h \ descriptors/desc_service_location.c ../include/descriptors/desc_service_location.h \ descriptors/mpeg_ts.c ../include/descriptors/mpeg_ts.h \ descriptors/mpeg_pes.c ../include/descriptors/mpeg_pes.h \
lib/libdvbv5/descriptors.c +11 -8
@@ -37,6 +37,7 @@#include "descriptors/eit.h" #include "descriptors/vct.h" #include "descriptors/mgt.h" +#include "descriptors/atsc_eit.h" #include "descriptors/desc_language.h" #include "descriptors/desc_network_name.h" #include "descriptors/desc_cable_delivery.h"
@@ -76,14 +77,16 @@ void dvb_desc_default_print(struct dvb_v5_fe_parms *parms, const struct dvb_desc }const struct dvb_table_init dvb_table_initializers[] = { - [DVB_TABLE_PAT ] = { dvb_table_pat_init,sizeof (struct dvb_table_pat ) }, - [DVB_TABLE_PMT ] = { dvb_table_pmt_init,sizeof (struct dvb_table_pmt ) }, - [DVB_TABLE_NIT ] = { dvb_table_nit_init,sizeof (struct dvb_table_nit ) }, - [DVB_TABLE_SDT ] = { dvb_table_sdt_init,sizeof (struct dvb_table_sdt ) }, - [DVB_TABLE_EIT ] = { dvb_table_eit_init,sizeof (struct dvb_table_eit ) }, - [DVB_TABLE_TVCT ] = { dvb_table_vct_init,sizeof (struct dvb_table_vct ) }, - [DVB_TABLE_CVCT ] = { dvb_table_vct_init,sizeof (struct dvb_table_vct ) }, + [DVB_TABLE_PAT ] = { dvb_table_pat_init,sizeof (struct dvb_table_pat ) }, + [DVB_TABLE_PMT ] = { dvb_table_pmt_init,sizeof (struct dvb_table_pmt ) }, + [DVB_TABLE_NIT ] = { dvb_table_nit_init,sizeof (struct dvb_table_nit ) }, + [DVB_TABLE_SDT ] = { dvb_table_sdt_init,sizeof (struct dvb_table_sdt ) }, + [DVB_TABLE_EIT ] = { dvb_table_eit_init,sizeof (struct dvb_table_eit ) }, [DVB_TABLE_EIT_SCHEDULE ] = { dvb_table_eit_init,sizeof (struct dvb_table_eit ) }, + [ATSC_TABLE_TVCT ] = { atsc_table_vct_init,sizeof (struct atsc_table_vct ) }, + [ATSC_TABLE_CVCT ] = { atsc_table_vct_init,sizeof (struct atsc_table_vct ) }, + [ATSC_TABLE_MGT ] = { atsc_table_mgt_init,sizeof (struct atsc_table_mgt ) }, + [ATSC_TABLE_EIT ] = { atsc_table_eit_init,sizeof (struct atsc_table_eit ) }, };char *default_charset ="iso-8859-1" ;
@@ -1355,6 +1358,6 @@ void hexdump(struct dvb_v5_fe_parms *parms, const char *prefix, const unsigned cfor (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); } }
lib/libdvbv5/descriptors/atsc_eit.c new file +143 -0
143 lines not on this page · raw message
lib/libdvbv5/descriptors/atsc_header.c new file +48 -0
48 lines not on this page · raw message
lib/libdvbv5/descriptors/eit.c +1 -1
@@ -67,7 +67,7 @@ void dvb_table_eit_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssizesizeof (event->service_id);bswap16 (event->event_id); -bswap16 (event->bitfield); +bswap16 (event->bitfield);// FIXME: needed? bswap16 (event->bitfield2); event->descriptor =NULL ; event->next =NULL ;
lib/libdvbv5/descriptors/mgt.c +23 -18
89 lines not on this page · raw message
lib/libdvbv5/descriptors/vct.c +19 -20
@@ -23,14 +23,14 @@#include "dvb-fe.h" #include "parse_string.h" -void dvb_table_vct_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf, +void atsc_table_vct_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf,ssize_t buflen,uint8_t *table,ssize_t *table_length) {const uint8_t *p = buf, *endbuf = buf + buflen -4 ; -struct dvb_table_vct *vct = (void *)table; -struct dvb_table_vct_channel **head = &vct->channel; +struct atsc_table_vct *vct = (void *)table; +struct atsc_table_vct_channel **head = &vct->channel;int i, n; -size_t size = offsetof(struct dvb_table_vct , channel); +size_t size = offsetof(struct atsc_table_vct , channel);if (p + size > endbuf) { dvb_logerr("VCT table was truncated. Need %zu bytes, but has only %zu.",
@@ -45,16 +45,16 @@ void dvb_table_vct_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, }else {memcpy (vct, p, size); - *table_length =sizeof (struct dvb_table_vct ); + *table_length =sizeof (struct atsc_table_vct ); vct->channel =NULL ; vct->descriptor =NULL ; } p += size; - size = offsetof(struct dvb_table_vct_channel , descriptor); + size = offsetof(struct atsc_table_vct_channel , descriptor);for (n =0 ; n < vct->num_channels_in_section; n++) { -struct dvb_table_vct_channel *channel; +struct atsc_table_vct_channel *channel;if (p + size > endbuf) { dvb_logerr("VCT channel table is missing %d elements",
@@ -63,7 +63,7 @@ void dvb_table_vct_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,break ; } - channel =malloc (sizeof (struct dvb_table_vct_channel )); + channel =malloc (sizeof (struct atsc_table_vct_channel ));memcpy (channel, p, size); p += size;
@@ -75,7 +75,7 @@ void dvb_table_vct_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,bswap32 (channel->carrier_frequency);bswap16 (channel->channel_tsid);bswap16 (channel->program_number); -bswap16 (channel->bitfield1); +bswap32 (channel->bitfield1);bswap16 (channel->bitfield2);bswap16 (channel->source_id);bswap16 (channel->bitfield3);
@@ -104,9 +104,9 @@ void dvb_table_vct_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, }/* Get extra descriptors */ - size =sizeof (union dvb_table_vct_descriptor_length ); + size =sizeof (union atsc_table_vct_descriptor_length );while (p + size <= endbuf) { -union dvb_table_vct_descriptor_length *d = (void *)p; +union atsc_table_vct_descriptor_length *d = (void *)p;bswap16 (d->descriptor_length); p += size; dvb_parse_descriptors(parms, p, d->descriptor_length,
@@ -117,12 +117,12 @@ void dvb_table_vct_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, endbuf - p); } -void dvb_table_vct_free (struct dvb_table_vct *vct) +void atsc_table_vct_free (struct atsc_table_vct *vct) { -struct dvb_table_vct_channel *channel = vct->channel; +struct atsc_table_vct_channel *channel = vct->channel;while (channel) {dvb_free_descriptors ((struct dvb_desc **) &channel->descriptor); -struct dvb_table_vct_channel *tmp = channel; +struct atsc_table_vct_channel *tmp = channel; channel = channel->next;free (tmp); }
@@ -131,19 +131,19 @@ void dvb_table_vct_free(struct dvb_table_vct *vct)free (vct); } -void dvb_table_vct_print (struct dvb_v5_fe_parms *parms,struct dvb_table_vct *vct) +void atsc_table_vct_print (struct dvb_v5_fe_parms *parms,struct atsc_table_vct *vct) { -if (vct->header.table_id ==DVB_TABLE_CVCT ) +if (vct->header.table_id ==ATSC_TABLE_CVCT )dvb_log ("CVCT" );else dvb_log ("TVCT" ); -dvb_table_header_print (parms, &vct->header); +atsc_table_header_print (parms, &vct->header);dvb_log ("|- Protocol version %d" , vct->ATSC_protocol_version);dvb_log ("|- #channels %d" , vct->num_channels_in_section);dvb_log ("|\\ channel_id" ); -const struct dvb_table_vct_channel *channel = vct->channel; +const struct atsc_table_vct_channel *channel = vct->channel;uint16_t channels =0 ;while (channel) { dvb_log("|- Channel %d.%d: %s",
@@ -159,7 +159,7 @@ void dvb_table_vct_print(struct dvb_v5_fe_parms *parms, struct dvb_table_vct *vcdvb_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); } -
lib/libdvbv5/dvb-file.c +1 -1
@@ -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 ;
lib/libdvbv5/dvb-scan.c +5 -5
@@ -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 */
Signature · 1 line
1.8.3.2
Re: [PATCH 08/13] libdvbv5: ATSC EIT
Em Sat, 28 Dec 2013 16:45:56 +0100
André Roth <[email protected]> escreveu:
Quoted 28 lines
Signed-off-by André Roth <[email protected]>--- lib/include/descriptors/atsc_eit.h | 91 +++++++++++++++++++++ lib/include/descriptors/atsc_header.h | 64 +++++++++++++++ lib/include/descriptors/mgt.h | 25 +++--- lib/include/descriptors/vct.h | 39 ++++----- lib/include/dvb-scan.h | 2 +- lib/libdvbv5/Makefile.am | 3 + lib/libdvbv5/descriptors.c | 19 +++-- lib/libdvbv5/descriptors/atsc_eit.c | 143 +++++++++++++++++++++++++++++++++ lib/libdvbv5/descriptors/atsc_header.c | 48 +++++++++++ lib/libdvbv5/descriptors/eit.c | 2 +- lib/libdvbv5/descriptors/mgt.c | 41 +++++----- lib/libdvbv5/descriptors/vct.c | 39 +++++---- lib/libdvbv5/dvb-file.c | 2 +- lib/libdvbv5/dvb-scan.c | 10 +-- 14 files changed, 442 insertions(+), 86 deletions(-) create mode 100644 lib/include/descriptors/atsc_eit.h create mode 100644 lib/include/descriptors/atsc_header.h create mode 100644 lib/libdvbv5/descriptors/atsc_eit.c create mode 100644 lib/libdvbv5/descriptors/atsc_header.clib/include/descriptors/atsc_eit.h new file +0
-0
lib/include/descriptors/atsc_eit.h line 2
Quoted 2 lines
lib/include/descriptors/atsc_eit.h new file +2
-0@@ -0,0 +1,91 @@ +/* +* Copyright (c) 2011-2012 - Mauro Carvalho Chehab <[email protected]>
I'm not the author.
Quoted 95 lines
lib/include/descriptors/atsc_eit.h new file +89
-0+* Copyright (c) 2012 - Andre Roth <[email protected]> +* +* 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 lib/include/descriptors/atsc_header.h new file +0
-0
lib/include/descriptors/atsc_header.h line 2
Quoted 2 lines
lib/include/descriptors/atsc_header.h new file +2
-0@@ -0,0 +1,64 @@ +/* +* Copyright (c) 2011-2012 - Mauro Carvalho Chehab <[email protected]>
I'm not the author.
Quoted 138 lines
lib/include/descriptors/atsc_header.h new file +62
-0+* Copyright (c) 2012 - Andre Roth <[email protected]> +* +* 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 lib/include/descriptors/mgt.h +12
-13@@ -25,12 +25,12 @@#include <stdint.h> #include <unistd.h> /* ssize_t */ -#include "descriptors/header.h" +#include "descriptors/atsc_header.h" #include "descriptors.h" -#define DVB_TABLE_MGT 0xC7 +#define ATSC_TABLE_MGT 0xC7 -struct dvb_table_mgt_table { +struct atsc_table_mgt_table {uint16_t type;union {uint16_t bitfield;@@ -50,20 +50,19 @@ struct dvb_table_mgt_table { } __attribute__((packed)); } __attribute__((packed));struct dvb_desc *descriptor; -struct dvb_table_mgt_table *next; +struct atsc_table_mgt_table *next; } __attribute__((packed)); -struct dvb_table_mgt { -struct dvb_table_header header; -uint8_t protocol_version; +struct atsc_table_mgt { +struct atsc_table_header header;uint16_t tables; -struct dvb_table_mgt_table *table; +struct atsc_table_mgt_table *table;struct dvb_desc *descriptor; } __attribute__((packed)); -#define dvb_mgt_transport_foreach ( tran, mgt ) \ - for( struct dvb_table_mgt_transport *tran = mgt->transport; tran; tran = tran->next ) \ +#define dvb_mgt_table_foreach ( tran, mgt ) \ + for( struct dvb_table_mgt_table *tran = mgt->table; tran; tran = tran->next ) \struct dvb_v5_fe_parms ;@@ -71,9 +70,9 @@ struct dvb_v5_fe_parms;extern "C" {#endif -void dvb_table_mgt_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf,ssize_t buflen,uint8_t *table,ssize_t *table_length); -void dvb_table_mgt_free (struct dvb_table_mgt *mgt); -void dvb_table_mgt_print (struct dvb_v5_fe_parms *parms,struct dvb_table_mgt *mgt); +void atsc_table_mgt_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf,ssize_t buflen,uint8_t *table,ssize_t *table_length); +void atsc_table_mgt_free (struct atsc_table_mgt *mgt); +void atsc_table_mgt_print (struct dvb_v5_fe_parms *parms,struct atsc_table_mgt *mgt); #ifdef __cplusplus }lib/include/descriptors/vct.h +2
-4@@ -25,25 +25,25 @@#include <stdint.h> #include <unistd.h> /* ssize_t */ -#include "descriptors/header.h" +#include "descriptors/atsc_header.h" #include "descriptors.h" -#define DVB_TABLE_TVCT 0xc8 -#define DVB_TABLE_CVCT 0xc9 -#define DVB_TABLE_VCT_PID 0x1ffb +#define ATSC_TABLE_TVCT 0xc8
lib/include/descriptors/vct.h line 39
Quoted 10 lines
lib/include/descriptors/vct.h +4
-2+#define ATSC_TABLE_CVCT 0xc9 +#define ATSC_TABLE_VCT_PID 0x1ffb -struct dvb_table_vct_channel { +struct atsc_table_vct_channel {uint16_t __short_name[7 ];union { -uint32_t bitfield; +uint32_t bitfield1;
I think you're touching here again, reverting what you've done on a previous patch.
Quoted 166 lines
lib/include/descriptors/vct.h +14
-13struct {uint32_t modulation_mode:8 ;uint32_t minor_channel_number:10 ;uint32_t major_channel_number:10 ;uint32_t reserved1:4 ; } __attribute__((packed)); - }; + } __attribute__((packed));uint32_t carrier_frequency;uint16_t channel_tsid;@@ -61,7 +61,8 @@ struct dvb_table_vct_channel { uint16_t ETM_location:2; } __attribute__((packed)); - }; + } __attribute__((packed)); +uint16_t source_id;union {uint16_t bitfield3;@@ -69,22 +70,22 @@ struct dvb_table_vct_channel { uint16_t descriptors_length:10; uint16_t reserved3:6; } __attribute__((packed)); - }; + } __attribute__((packed));/* * Everything after descriptor (including it) won't be bit-mapped * to the data parsed from the MPEG TS. So, metadata are added there */ struct dvb_desc *descriptor; -struct dvb_table_vct_channel *next; +struct atsc_table_vct_channel *next;/* The channel_short_name is converted to locale charset by vct.c */ char short_name[32 ]; } __attribute__((packed)); -struct dvb_table_vct { -struct dvb_table_header header; +struct atsc_table_vct { +struct atsc_table_header header;uint8_t ATSC_protocol_version;uint8_t num_channels_in_section;@@ -93,12 +94,12 @@ struct dvb_table_vct {* Everything after descriptor (including it) won't be bit-mapped * to the data parsed from the MPEG TS. So, metadata are added there */ -struct dvb_table_vct_channel *channel; +struct atsc_table_vct_channel *channel;struct dvb_desc *descriptor; } __attribute__((packed)); -union dvb_table_vct_descriptor_length { +union atsc_table_vct_descriptor_length {uint16_t bitfield;struct {uint16_t descriptor_length:10 ;@@ -106,8 +107,8 @@ union dvb_table_vct_descriptor_length { }; }; -#define dvb_vct_channel_foreach (_channel, _vct) \ - for (struct dvb_table_vct_channel *_channel = _vct->channel; _channel; _channel = _channel->next) \ +#define atsc_vct_channel_foreach (_channel, _vct) \ + for (struct atsc_table_vct_channel *_channel = _vct->channel; _channel; _channel = _channel->next) \struct dvb_v5_fe_parms ;@@ -115,9 +116,9 @@ struct dvb_v5_fe_parms;extern "C" {#endif -void dvb_table_vct_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf,ssize_t buflen,uint8_t *table,ssize_t *table_length); -void dvb_table_vct_free (struct dvb_table_vct *vct); -void dvb_table_vct_print (struct dvb_v5_fe_parms *parms,struct dvb_table_vct *vct); +void atsc_table_vct_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf,ssize_t buflen,uint8_t *table,ssize_t *table_length); +void atsc_table_vct_free (struct atsc_table_vct *vct); +void atsc_table_vct_print (struct dvb_v5_fe_parms *parms,struct atsc_table_vct *vct); #ifdef __cplusplus }lib/include/dvb-scan.h +1
-1@@ -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;lib/libdvbv5/Makefile.am +3
-0@@ -48,8 +48,11 @@ libdvbv5_la_SOURCES = \ descriptors/nit.c ../include/descriptors/nit.h \ descriptors/sdt.c ../include/descriptors/sdt.h \ descriptors/vct.c ../include/descriptors/vct.h \ + descriptors/atsc_header.c ../include/descriptors/atsc_header.h \ descriptors/vct.c ../include/descriptors/vct.h \ descriptors/mgt.c ../include/descriptors/mgt.h \ + descriptors/eit.c ../include/descriptors/eit.h \ + descriptors/atsc_eit.c ../include/descriptors/atsc_eit.h \ descriptors/desc_service_location.c ../include/descriptors/desc_service_location.h \ descriptors/mpeg_ts.c ../include/descriptors/mpeg_ts.h \ descriptors/mpeg_pes.c ../include/descriptors/mpeg_pes.h \lib/libdvbv5/descriptors.c +11
-8@@ -37,6 +37,7 @@#include "descriptors/eit.h" #include "descriptors/vct.h" #include "descriptors/mgt.h" +#include "descriptors/atsc_eit.h" #include "descriptors/desc_language.h" #include "descriptors/desc_network_name.h" #include "descriptors/desc_cable_delivery.h" @@ -76,14 +77,16 @@ void dvb_desc_default_print(struct dvb_v5_fe_parms *parms, const struct dvb_desc }const struct dvb_table_init dvb_table_initializers[] = { - [DVB_TABLE_PAT ] = { dvb_table_pat_init,sizeof (struct dvb_table_pat ) }, - [DVB_TABLE_PMT ] = { dvb_table_pmt_init,sizeof (struct dvb_table_pmt ) }, - [DVB_TABLE_NIT ] = { dvb_table_nit_init,sizeof (struct dvb_table_nit ) }, - [DVB_TABLE_SDT ] = { dvb_table_sdt_init,sizeof (struct dvb_table_sdt ) }, - [DVB_TABLE_EIT ] = { dvb_table_eit_init,sizeof (struct dvb_table_eit ) }, - [DVB_TABLE_TVCT ] = { dvb_table_vct_init,sizeof (struct dvb_table_vct ) }, - [DVB_TABLE_CVCT ] = { dvb_table_vct_init,sizeof (struct dvb_table_vct ) }, + [DVB_TABLE_PAT ] = { dvb_table_pat_init,sizeof (struct dvb_table_pat ) }, + [DVB_TABLE_PMT ] = { dvb_table_pmt_init,sizeof (struct dvb_table_pmt ) }, + [DVB_TABLE_NIT ] = { dvb_table_nit_init,sizeof (struct dvb_table_nit ) }, + [DVB_TABLE_SDT ] = { dvb_table_sdt_init,sizeof (struct dvb_table_sdt ) }, + [DVB_TABLE_EIT ] = { dvb_table_eit_init,sizeof (struct dvb_table_eit ) }, [DVB_TABLE_EIT_SCHEDULE ] = { dvb_table_eit_init,sizeof (struct dvb_table_eit ) }, + [ATSC_TABLE_TVCT ] = { atsc_table_vct_init,sizeof (struct atsc_table_vct ) }, + [ATSC_TABLE_CVCT ] = { atsc_table_vct_init,sizeof (struct atsc_table_vct ) }, + [ATSC_TABLE_MGT ] = { atsc_table_mgt_init,sizeof (struct atsc_table_mgt ) }, + [ATSC_TABLE_EIT ] = { atsc_table_eit_init,sizeof (struct atsc_table_eit ) }, };char *default_charset ="iso-8859-1" ;@@ -1355,6 +1358,6 @@ void hexdump(struct dvb_v5_fe_parms *parms, const char *prefix, const unsigned cfor (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); } }lib/libdvbv5/descriptors/atsc_eit.c new file +0
-0
lib/libdvbv5/descriptors/atsc_eit.c line 2
Quoted 2 lines
lib/libdvbv5/descriptors/atsc_eit.c new file +2
-0@@ -0,0 +1,143 @@ +/* +* Copyright (c) 2011-2012 - Mauro Carvalho Chehab <[email protected]>
I'm not the author.
Quoted 20 lines
lib/libdvbv5/descriptors/atsc_eit.c new file +20
-0+* Copyright (c) 2012 - Andre Roth <[email protected]> +* +* 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"
lib/libdvbv5/descriptors/atsc_eit.c line 32
Quoted 10 lines
lib/libdvbv5/descriptors/atsc_eit.c new file +10
-0+#include "dvb-fe.h" + +void atsc_table_eit_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf,ssize_t buflen,uint8_t *table,ssize_t *table_length) +{ +const uint8_t *p = buf; +struct atsc_table_eit *eit = (struct atsc_table_eit *) table; +struct atsc_table_eit_event **head; + +if (*table_length >0 ) { +memcpy (eit, p,sizeof (struct atsc_table_eit ) -sizeof (eit->event));
Check before copy. Use offset_of().
lib/libdvbv5/descriptors/atsc_eit.c line 39
Quoted 7 lines
lib/libdvbv5/descriptors/atsc_eit.c new file +7
-0+ +/* find end of curent list */ + head = &eit->event; +while (*head !=NULL ) + head = &(*head)->next; + }else { +memcpy (eit, p,sizeof (struct atsc_table_eit ) -sizeof (eit->event));
check before copy. Use offset_of().
Quoted 13 lines
lib/libdvbv5/descriptors/atsc_eit.c new file +13
-0+ *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 ));
lib/libdvbv5/descriptors/atsc_eit.c line 62
Quoted 10 lines
lib/libdvbv5/descriptors/atsc_eit.c new file +10
-0+memcpy (event, p,sizeof (struct atsc_table_eit_event ) - +sizeof (event->descriptor) - +sizeof (event->next) - +sizeof (event->start) - +sizeof (event->source_id)); + p +=sizeof (struct atsc_table_eit_event ) - +sizeof (event->descriptor) - +sizeof (event->next) - +sizeof (event->start) - +sizeof (event->source_id);
Please use offset_of().
Quoted 10 lines
lib/libdvbv5/descriptors/atsc_eit.c new file +10
-0+ +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
lib/libdvbv5/descriptors/atsc_eit.c line 82
Quoted 10 lines
lib/libdvbv5/descriptors/atsc_eit.c new file +10
-0+ p += event->title_length -1 ; + +if (!*head) + *head = event; +if (last) + last->next = event; + +/* get the descriptors for each program */ +struct dvb_desc **head_desc = &event->descriptor; +union atsc_table_eit_desc_length dl = *(union atsc_table_eit_desc_length *) p;
data declarations at the beginning.
Quoted 67 lines
lib/libdvbv5/descriptors/atsc_eit.c new file +61
-0+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); +} + +lib/libdvbv5/descriptors/atsc_header.c new file +0
-0
lib/libdvbv5/descriptors/atsc_header.c line 2
Quoted 2 lines
lib/libdvbv5/descriptors/atsc_header.c new file +2
-0@@ -0,0 +1,48 @@ +/* +* Copyright (c) 2011-2012 - Mauro Carvalho Chehab <[email protected]>
I'm not the author.
Quoted 51 lines
lib/libdvbv5/descriptors/atsc_header.c new file +46
-0+* Copyright (c) 2012 - Andre Roth <[email protected]> +* +* 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); +} +lib/libdvbv5/descriptors/eit.c +0
-0
lib/libdvbv5/descriptors/eit.c void dvb_table_eit_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize · line 70
Quoted 5 lines
lib/libdvbv5/descriptors/eit.c +1
-1@@ -67,7 +67,7 @@ void dvb_table_eit_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssizesizeof (event->service_id);bswap16 (event->event_id); -bswap16 (event->bitfield); +bswap16 (event->bitfield);// FIXME: needed?
Why not needed?
Quoted 24 lines
lib/libdvbv5/descriptors/eit.c +0
-0bswap16 (event->bitfield2); event->descriptor =NULL ; event->next =NULL ;lib/libdvbv5/descriptors/mgt.c +3
-3@@ -22,12 +22,12 @@#include "descriptors/mgt.h" #include "dvb-fe.h" -void dvb_table_mgt_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf,ssize_t buflen,uint8_t *table,ssize_t *table_length) +void atsc_table_mgt_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf,ssize_t buflen,uint8_t *table,ssize_t *table_length) {const uint8_t *p = buf; -struct dvb_table_mgt *mgt = (struct dvb_table_mgt *) table; +struct atsc_table_mgt *mgt = (struct atsc_table_mgt *) table;struct dvb_desc **head_desc; -struct dvb_table_mgt_table **head; +struct atsc_table_mgt_table **head;/*int desc_length;*/ if (*table_length >0 ) {
lib/libdvbv5/descriptors/mgt.c void dvb_table_mgt_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize · line 43
Quoted 7 lines
lib/libdvbv5/descriptors/mgt.c +2
-2@@ -39,8 +39,8 @@ void dvb_table_mgt_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssizewhile (*head !=NULL ) head = &(*head)->next; }else { -memcpy (table, p,sizeof (struct dvb_table_mgt ) -sizeof (mgt->descriptor) -sizeof (mgt->table)); - *table_length =sizeof (struct dvb_table_mgt ); +memcpy (table, p,sizeof (struct atsc_table_mgt ) -sizeof (mgt->descriptor) -sizeof (mgt->table)); + *table_length =sizeof (struct atsc_table_mgt );
Please check before copy. Also, use offset_of().
lib/libdvbv5/descriptors/mgt.c void dvb_table_mgt_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize · line 52
Quoted 10 lines
lib/libdvbv5/descriptors/mgt.c +1
-1mgt->descriptor =NULL ; mgt->table =NULL ;@@ -48,16 +48,16 @@ void dvb_table_mgt_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize head = &mgt->table;bswap16 (mgt->tables); } - p +=sizeof (struct dvb_table_mgt ) -sizeof (mgt->descriptor) -sizeof (mgt->table); + p +=sizeof (struct atsc_table_mgt ) -sizeof (mgt->descriptor) -sizeof (mgt->table);
Offset_of()
lib/libdvbv5/descriptors/mgt.c void dvb_table_mgt_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize · line 56
Quoted 5 lines
lib/libdvbv5/descriptors/mgt.c +1
-1/*dvb_parse_descriptors(parms, p, desc_length, head_desc);*/ /*p += desc_length;*/ int i =0 ; -struct dvb_table_mgt_table *last =NULL ; +struct atsc_table_mgt_table *last =NULL ;
Data declaration at the beginning.
lib/libdvbv5/descriptors/mgt.c void dvb_table_mgt_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize · line 61
Quoted 8 lines
lib/libdvbv5/descriptors/mgt.c +3
-3while (i++ < mgt->tables && (uint8_t *) p < buf + buflen -4 ) { -struct dvb_table_mgt_table *table = (struct dvb_table_mgt_table *)malloc (sizeof (struct dvb_table_mgt_table )); -memcpy (table, p,sizeof (struct dvb_table_mgt_table ) -sizeof (table->descriptor) -sizeof (table->next)); - p +=sizeof (struct dvb_table_mgt_table ) -sizeof (table->descriptor) -sizeof (table->next); +struct atsc_table_mgt_table *table = (struct atsc_table_mgt_table *)malloc (sizeof (struct atsc_table_mgt_table )); +memcpy (table, p,sizeof (struct atsc_table_mgt_table ) -sizeof (table->descriptor) -sizeof (table->next)); + p +=sizeof (struct atsc_table_mgt_table ) -sizeof (table->descriptor) -sizeof (table->next);
Same as above: data declaration at beginning, offset_of() and check before copy.
Quoted 6 lines
lib/libdvbv5/descriptors/mgt.c +0
-0bswap16 (table->type);bswap16 (table->bitfield);@@ -80,30 +80,35 @@ void dvb_table_mgt_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize } }
lib/libdvbv5/descriptors/mgt.c void dvb_table_mgt_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize · line 89
Quoted 10 lines
lib/libdvbv5/descriptors/mgt.c +3
-3-void dvb_table_mgt_free (struct dvb_table_mgt *mgt) +void atsc_table_mgt_free (struct atsc_table_mgt *mgt) { -struct dvb_table_mgt_table *table = mgt->table; +struct atsc_table_mgt_table *table = mgt->table;dvb_free_descriptors ((struct dvb_desc **) &mgt->descriptor);while (table) {dvb_free_descriptors ((struct dvb_desc **) &table->descriptor); -struct dvb_table_mgt_table *tmp = table; +struct atsc_table_mgt_table *tmp = table;
Data declaration at the beginning.
Quoted 210 lines
lib/libdvbv5/descriptors/mgt.c +10
-5table = table->next;free (tmp); }free (mgt); } -void dvb_table_mgt_print (struct dvb_v5_fe_parms *parms,struct dvb_table_mgt *mgt) +void atsc_table_mgt_print (struct dvb_v5_fe_parms *parms,struct atsc_table_mgt *mgt) {dvb_log ("MGT" ); -dvb_table_header_print (parms, &mgt->header); -dvb_log ("| protocol_version %d" , mgt->protocol_version); +atsc_table_header_print (parms, &mgt->header);dvb_log ("| tables %d" , mgt->tables);/*dvb_print_descriptors(parms, mgt->descriptor);*/ -const struct dvb_table_mgt_table *table = mgt->table; +const struct atsc_table_mgt_table *table = mgt->table;uint16_t tables =0 ;while (table) { -dvb_log ("|- type %04x %d" , table->type, table->pid); +dvb_log ("|- type %04x %d" , table->type, table->pid); +dvb_log ("| one %d" , table->one); +dvb_log ("| one2 %d" , table->one2); +dvb_log ("| type version %d" , table->type_version); +dvb_log ("| size %d" , table->size); +dvb_log ("| one3 %d" , table->one3); +dvb_log ("| desc_length %d" , table->desc_length);dvb_print_descriptors (parms, table->descriptor); table = table->next; tables++;lib/libdvbv5/descriptors/vct.c +19
-20@@ -23,14 +23,14 @@#include "dvb-fe.h" #include "parse_string.h" -void dvb_table_vct_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf, +void atsc_table_vct_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf,ssize_t buflen,uint8_t *table,ssize_t *table_length) {const uint8_t *p = buf, *endbuf = buf + buflen -4 ; -struct dvb_table_vct *vct = (void *)table; -struct dvb_table_vct_channel **head = &vct->channel; +struct atsc_table_vct *vct = (void *)table; +struct atsc_table_vct_channel **head = &vct->channel;int i, n; -size_t size = offsetof(struct dvb_table_vct , channel); +size_t size = offsetof(struct atsc_table_vct , channel);if (p + size > endbuf) { dvb_logerr("VCT table was truncated. Need %zu bytes, but has only %zu.",@@ -45,16 +45,16 @@ void dvb_table_vct_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, }else {memcpy (vct, p, size); - *table_length =sizeof (struct dvb_table_vct ); + *table_length =sizeof (struct atsc_table_vct ); vct->channel =NULL ; vct->descriptor =NULL ; } p += size; - size = offsetof(struct dvb_table_vct_channel , descriptor); + size = offsetof(struct atsc_table_vct_channel , descriptor);for (n =0 ; n < vct->num_channels_in_section; n++) { -struct dvb_table_vct_channel *channel; +struct atsc_table_vct_channel *channel;if (p + size > endbuf) { dvb_logerr("VCT channel table is missing %d elements",@@ -63,7 +63,7 @@ void dvb_table_vct_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,break ; } - channel =malloc (sizeof (struct dvb_table_vct_channel )); + channel =malloc (sizeof (struct atsc_table_vct_channel ));memcpy (channel, p, size); p += size;@@ -75,7 +75,7 @@ void dvb_table_vct_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,bswap32 (channel->carrier_frequency);bswap16 (channel->channel_tsid);bswap16 (channel->program_number); -bswap16 (channel->bitfield1); +bswap32 (channel->bitfield1);bswap16 (channel->bitfield2);bswap16 (channel->source_id);bswap16 (channel->bitfield3);@@ -104,9 +104,9 @@ void dvb_table_vct_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, }/* Get extra descriptors */ - size =sizeof (union dvb_table_vct_descriptor_length ); + size =sizeof (union atsc_table_vct_descriptor_length );while (p + size <= endbuf) { -union dvb_table_vct_descriptor_length *d = (void *)p; +union atsc_table_vct_descriptor_length *d = (void *)p;bswap16 (d->descriptor_length); p += size; dvb_parse_descriptors(parms, p, d->descriptor_length,@@ -117,12 +117,12 @@ void dvb_table_vct_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, endbuf - p); } -void dvb_table_vct_free (struct dvb_table_vct *vct) +void atsc_table_vct_free (struct atsc_table_vct *vct) { -struct dvb_table_vct_channel *channel = vct->channel; +struct atsc_table_vct_channel *channel = vct->channel;while (channel) {dvb_free_descriptors ((struct dvb_desc **) &channel->descriptor); -struct dvb_table_vct_channel *tmp = channel; +struct atsc_table_vct_channel *tmp = channel; channel = channel->next;free (tmp); }@@ -131,19 +131,19 @@ void dvb_table_vct_free(struct dvb_table_vct *vct)free (vct); } -void dvb_table_vct_print (struct dvb_v5_fe_parms *parms,struct dvb_table_vct *vct) +void atsc_table_vct_print (struct dvb_v5_fe_parms *parms,struct atsc_table_vct *vct) { -if (vct->header.table_id ==DVB_TABLE_CVCT ) +if (vct->header.table_id ==ATSC_TABLE_CVCT )dvb_log ("CVCT" );else dvb_log ("TVCT" ); -dvb_table_header_print (parms, &vct->header); +atsc_table_header_print (parms, &vct->header);dvb_log ("|- Protocol version %d" , vct->ATSC_protocol_version);dvb_log ("|- #channels %d" , vct->num_channels_in_section);dvb_log ("|\\ channel_id" ); -const struct dvb_table_vct_channel *channel = vct->channel; +const struct atsc_table_vct_channel *channel = vct->channel;uint16_t channels =0 ;while (channel) { dvb_log("|- Channel %d.%d: %s",@@ -159,7 +159,7 @@ void dvb_table_vct_print(struct dvb_v5_fe_parms *parms, struct dvb_table_vct *vcdvb_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); } -lib/libdvbv5/dvb-file.c +1
-1@@ -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 ;lib/libdvbv5/dvb-scan.c +4
-4@@ -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)
lib/libdvbv5/dvb-scan.c struct dvb_v5_descriptors *dvb_get_ts_tables(struct dvb_v5_fe_parms *parms, · line 381
Quoted 8 lines
lib/libdvbv5/dvb-scan.c +1
-1@@ -375,7 +375,7 @@ struct dvb_v5_descriptors *dvb_get_ts_tables(struct dvb_v5_fe_parms *parms,if (rc <0 )dvb_logerr ("error while waiting for VCT table" );else if (parms->verbose) -dvb_table_vct_print (parms, dvb_scan_handler->vct); +atsc_table_vct_print (parms, dvb_scan_handler->vct); }/* PMT tables */
The better is to split the data renames on a separate patch. I don't like to rename it at the library, as others might be using the library with the old names. So, we may need to add a compat code for those using the legacy names.
Signature · 2 lines
Cheers, Mauro
PATCH 9/13 libdvbv5: fix section counting
In reply to André Roth--- lib/libdvbv5/dvb-scan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/libdvbv5/dvb-scan.c +1 -1
@@ -208,7 +208,7 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,else if (start_id == h->id && h->section_id == first_section)break ; -if (last_section ==-1 ) +if (last_section ==-1 || h->last_section > last_section) last_section = h->last_section;if (!tbl) {
Signature · 1 line
1.8.3.2
Re: [PATCH 09/13] libdvbv5: fix section counting
Em Sat, 28 Dec 2013 16:45:57 +0100
André Roth <[email protected]> escreveu:
Quoted 10 lines
Signed-off-by André Roth <[email protected]>--- lib/libdvbv5/dvb-scan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/libdvbv5/dvb-scan.c +0
-0
lib/libdvbv5/dvb-scan.c int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd, · line 211
Quoted 5 lines
lib/libdvbv5/dvb-scan.c +1
-1@@ -208,7 +208,7 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,else if (start_id == h->id && h->section_id == first_section)break ; -if (last_section ==-1 ) +if (last_section ==-1 || h->last_section > last_section)
Patch 1.
Quoted 3 lines
lib/libdvbv5/dvb-scan.c +0
-0last_section = h->last_section;if (!tbl) {
Signature · 2 lines
Cheers, Mauro
PATCH 10/13 libdvbv5: cleanup coding style
In reply to André Roth--- lib/libdvbv5/descriptors.c | 2 +- lib/libdvbv5/descriptors/mpeg_pes.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
lib/libdvbv5/descriptors.c +1 -1
@@ -1358,6 +1358,6 @@ void hexdump(struct dvb_v5_fe_parms *parms, const char *prefix, const unsigned cfor (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); } }
lib/libdvbv5/descriptors/mpeg_pes.c +1 -1
@@ -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 ; }
Signature · 1 line
1.8.3.2
Re: [PATCH 10/13] libdvbv5: cleanup coding style
Em Sat, 28 Dec 2013 16:45:58 +0100
André Roth <[email protected]> escreveu:
Please merge it with the original patch. That makes easier to review.
Quoted 31 lines
Signed-off-by André Roth <[email protected]>--- lib/libdvbv5/descriptors.c | 2 +- lib/libdvbv5/descriptors/mpeg_pes.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)lib/libdvbv5/descriptors.c +1
-1@@ -1358,6 +1358,6 @@ void hexdump(struct dvb_v5_fe_parms *parms, const char *prefix, const unsigned cfor (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); } }lib/libdvbv5/descriptors/mpeg_pes.c +1
-1@@ -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 ; }
Signature · 2 lines
Cheers, Mauro
PATCH 11/13 libdvbv5: fix double entry in Makefile.am
In reply to André Roth--- lib/libdvbv5/Makefile.am | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
lib/libdvbv5/Makefile.am +1 -2
@@ -47,7 +47,6 @@ libdvbv5_la_SOURCES = \ descriptors/desc_partial_reception.c ../include/descriptors/desc_partial_reception.h \ descriptors/nit.c ../include/descriptors/nit.h \ descriptors/sdt.c ../include/descriptors/sdt.h \ - descriptors/vct.c ../include/descriptors/vct.h \ descriptors/atsc_header.c ../include/descriptors/atsc_header.h \ descriptors/vct.c ../include/descriptors/vct.h \ descriptors/mgt.c ../include/descriptors/mgt.h \
@@ -58,7 +57,7 @@ libdvbv5_la_SOURCES = \ descriptors/mpeg_pes.c ../include/descriptors/mpeg_pes.h \ descriptors/mpeg_es.c ../include/descriptors/mpeg_es.h -libdvbv5_la_CPPFLAGS = $(ENFORCE_LIBDVBV5_STATIC) +libdvbv5_la_CPPFLAGS = $(ENFORCE_LIBDVBV5_STATIC) -std=c99 libdvbv5_la_LDFLAGS = $(LIBDVBV5_VERSION) $(ENFORCE_LIBDVBV5_STATIC) -lm libdvbv5_la_LIBADD = $(LTLIBICONV)
Signature · 1 line
1.8.3.2
Re: [PATCH 11/13] libdvbv5: fix double entry in Makefile.am
Em Sat, 28 Dec 2013 16:45:59 +0100
André Roth <[email protected]> escreveu:
Quoted 18 lines
Signed-off-by André Roth <[email protected]>--- lib/libdvbv5/Makefile.am | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)lib/libdvbv5/Makefile.am +0
-1@@ -47,7 +47,6 @@ libdvbv5_la_SOURCES = \ descriptors/desc_partial_reception.c ../include/descriptors/desc_partial_reception.h \ descriptors/nit.c ../include/descriptors/nit.h \ descriptors/sdt.c ../include/descriptors/sdt.h \ - descriptors/vct.c ../include/descriptors/vct.h \ descriptors/atsc_header.c ../include/descriptors/atsc_header.h \ descriptors/vct.c ../include/descriptors/vct.h \ descriptors/mgt.c ../include/descriptors/mgt.h \
lib/libdvbv5/Makefile.am libdvbv5_la_SOURCES = \ · line 60
Quoted 5 lines
lib/libdvbv5/Makefile.am +1
-1@@ -58,7 +57,7 @@ libdvbv5_la_SOURCES = \ descriptors/mpeg_pes.c ../include/descriptors/mpeg_pes.h \ descriptors/mpeg_es.c ../include/descriptors/mpeg_es.h -libdvbv5_la_CPPFLAGS = $(ENFORCE_LIBDVBV5_STATIC) +libdvbv5_la_CPPFLAGS = $(ENFORCE_LIBDVBV5_STATIC) -std=c99
No. We don't want c99 style.
Quoted 3 lines
lib/libdvbv5/Makefile.am +0
-0libdvbv5_la_LDFLAGS = $(LIBDVBV5_VERSION) $(ENFORCE_LIBDVBV5_STATIC) -lm libdvbv5_la_LIBADD = $(LTLIBICONV)
Signature · 2 lines
Cheers, Mauro
PATCH 12/13 libdvbv5: fix missing includes
In reply to André Roth--- lib/libdvbv5/dvb-file.c | 1 + lib/libdvbv5/dvb-sat.c | 1 + lib/libdvbv5/dvb-scan.c | 1 + lib/libdvbv5/parse_string.c | 1 + 4 files changed, 4 insertions(+)
lib/libdvbv5/dvb-file.c +1 -0
@@ -21,6 +21,7 @@#include <stdio.h> #include <stdlib.h> #include <string.h> +#include <strings.h> // strcasecmp #include <unistd.h> #include "dvb-file.h"
lib/libdvbv5/dvb-sat.c +1 -0
@@ -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"
lib/libdvbv5/dvb-scan.c +1 -0
@@ -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"
lib/libdvbv5/parse_string.c +1 -0
@@ -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"
Signature · 1 line
1.8.3.2
Re: [PATCH 12/13] libdvbv5: fix missing includes
Em Sat, 28 Dec 2013 16:46:00 +0100
André Roth <[email protected]> escreveu:
Quoted 49 lines
Signed-off-by André Roth <[email protected]>--- lib/libdvbv5/dvb-file.c | 1 + lib/libdvbv5/dvb-sat.c | 1 + lib/libdvbv5/dvb-scan.c | 1 + lib/libdvbv5/parse_string.c | 1 + 4 files changed, 4 insertions(+)lib/libdvbv5/dvb-file.c +1
-0@@ -21,6 +21,7 @@#include <stdio.h> #include <stdlib.h> #include <string.h> +#include <strings.h> // strcasecmp #include <unistd.h> #include "dvb-file.h" lib/libdvbv5/dvb-sat.c +1
-0@@ -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" lib/libdvbv5/dvb-scan.c +1
-0@@ -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" lib/libdvbv5/parse_string.c +0
-0
lib/libdvbv5/parse_string.c line 30
Quoted 4 lines
lib/libdvbv5/parse_string.c +1
-0@@ -27,6 +27,7 @@#include <stdio.h> #include <stdlib.h> #include <string.h> +#include <strings.h> // strcasecmp
Don't use C99 comments.
Quoted 3 lines
lib/libdvbv5/parse_string.c +0
-0#include "parse_string.h" #include "dvb-log.h"
Signature · 2 lines
Cheers, Mauro
PATCH 13/13 libdvbv5: improve TS parsing
In reply to André Roth--- lib/include/descriptors/mpeg_ts.h | 4 ++-- lib/libdvbv5/descriptors/mpeg_ts.c | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-)
lib/include/descriptors/mpeg_ts.h +2 -2
@@ -39,7 +39,7 @@ struct dvb_mpeg_ts_adaption { uint8_t random_access:1; uint8_t discontinued:1; } __attribute__((packed)); - +uint8_t data[]; } __attribute__((packed));struct dvb_mpeg_ts {
@@ -68,7 +68,7 @@ struct dvb_v5_fe_parms;extern "C" {#endif -void dvb_mpeg_ts_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf,ssize_t buflen,uint8_t *table,ssize_t *table_length); +ssize_t dvb_mpeg_ts_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf,ssize_t buflen,uint8_t *table,ssize_t *table_length);void dvb_mpeg_ts_free (struct dvb_mpeg_ts *ts);void dvb_mpeg_ts_print (struct dvb_v5_fe_parms *parms,struct dvb_mpeg_ts *ts);
lib/libdvbv5/descriptors/mpeg_ts.c +8 -3
@@ -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)
Signature · 1 line
1.8.3.2
Re: [PATCH 13/13] libdvbv5: improve TS parsing
Em Sat, 28 Dec 2013 16:46:01 +0100
André Roth <[email protected]> escreveu:
Quoted 52 lines
Signed-off-by André Roth <[email protected]>--- lib/include/descriptors/mpeg_ts.h | 4 ++-- lib/libdvbv5/descriptors/mpeg_ts.c | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-)lib/include/descriptors/mpeg_ts.h +2
-2@@ -39,7 +39,7 @@ struct dvb_mpeg_ts_adaption { uint8_t random_access:1; uint8_t discontinued:1; } __attribute__((packed)); - +uint8_t data[]; } __attribute__((packed));struct dvb_mpeg_ts {@@ -68,7 +68,7 @@ struct dvb_v5_fe_parms;extern "C" {#endif -void dvb_mpeg_ts_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf,ssize_t buflen,uint8_t *table,ssize_t *table_length); +ssize_t dvb_mpeg_ts_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf,ssize_t buflen,uint8_t *table,ssize_t *table_length);void dvb_mpeg_ts_free (struct dvb_mpeg_ts *ts);void dvb_mpeg_ts_print (struct dvb_v5_fe_parms *parms,struct dvb_mpeg_ts *ts);lib/libdvbv5/descriptors/mpeg_ts.c +4
-2@@ -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 );
lib/libdvbv5/descriptors/mpeg_ts.c line 47
Quoted 10 lines
lib/libdvbv5/descriptors/mpeg_ts.c +3
-1bswap16 (ts->bitfield);if (ts->adaptation_field &0x2 ) {memcpy (table + *table_length, p,sizeof (struct dvb_mpeg_ts_adaption )); - p +=sizeof (struct dvb_mpeg_ts ); + p +=sizeof (struct dvb_mpeg_ts_adaption ); + bytes_read +=sizeof (struct dvb_mpeg_ts_adaption ); *table_length += ts->adaption->length +1 ; +// FIXME: copy adaption->lenght bytes
don't use c99 comments.
Quoted 6 lines
lib/libdvbv5/descriptors/mpeg_ts.c +1
-0}/*hexdump(parms, "TS: ", buf, buflen);*/ +return bytes_read; }void dvb_mpeg_ts_free (struct dvb_mpeg_ts *ts)
Signature · 2 lines
Cheers, Mauro
Em Sat, 28 Dec 2013 16:45:49 +0100
André Roth <[email protected]> escreveu:
Quoted 22 lines
Signed-off-by André Roth <[email protected]>--- lib/libdvbv5/dvb-scan.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)lib/libdvbv5/dvb-scan.c +0
-7@@ -187,15 +187,19 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,dvb_table_header_init (h);if (id !=-1 && h->id != id) {/* search for a specific table id */ continue ; - }else { -if (table_id ==-1 ) - table_id = h->id; -else if (h->id != table_id) { -dvb_logwarn ("dvb_read_section: table ID mismatch reading multi section table: %d != %d" , h->id, table_id); -continue ; - } }
lib/libdvbv5/dvb-scan.c int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd, · line 201
Quoted 10 lines
lib/libdvbv5/dvb-scan.c +10
-0+/*if (id != -1) {*/ +/*if (table_id == -1)*/ +/*table_id = h->id;*/ +/*else if (h->id != table_id) {*/ +/*dvb_logwarn("dvb_read_section: table ID mismatch reading multi section table: %d != %d", h->id, table_id);*/ +/*free(buf);*/ +/*continue;*/ +/*}*/ +/*}*/ +
Could you please better describe this patch? What but is it supposed to fix?
If this is a bug fix, why are you commenting all lines instead of dropping?
Quoted 4 lines
lib/libdvbv5/dvb-scan.c +1
-0+dvb_logerr ("dvb_read_section: got section %d, last %di, filter %d" , h->section_id, h->last_section, id );/* handle the sections */ if (first_section ==-1 ) first_section = h->section_id;
Signature · 2 lines
Cheers, Mauro