libdvbv5: fix reading multisection tables
PATCH 1/18 libdvbv5: fix reading multisection tables
--- lib/libdvbv5/dvb-scan.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-)
lib/libdvbv5/dvb-scan.c +23 -13
@@ -96,9 +96,13 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,uint8_t *buf =NULL ;uint8_t *tbl =NULL ;ssize_t table_length =0 ; + +// handle sections +int start_id =-1 ; +int start_section =-1 ;int first_section =-1 ;int last_section =-1 ; -int table_id =-1 ; +/*int table_id = -1;*/ int sections =0 ;struct dmx_sct_filter_params f;struct dvb_table_header *h;
@@ -108,7 +112,6 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd, *table =NULL ;// FIXME: verify known table -memset (&f,0 ,sizeof (f)); f.pid = pid; f.filter.filter[0 ] = tid;
@@ -185,24 +188,27 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd, h = (struct dvb_table_header *)buf;dvb_table_header_init (h); + +/* dvb_logdbg( "dvb_read_section: id %d, section %d/%d, current: %d", h->id, h->section_id, h->last_section, h->current_next ); */ +if (start_id == h->id && start_section == h->section_id) { +dvb_logdbg ("dvb_read_section: section repeated, reading done" ); +break ; + } +if (start_id ==-1 ) start_id = h->id; +if (start_section ==-1 ) start_section = h->section_id; +if (id !=-1 && h->id != id) {/* search for a specific table id */ continue ; - }else { -if (table_id ==-1 ) - table_id = h->id; -else if (h->id != table_id) { -dvb_logwarn ("dvb_read_section: table ID mismatch reading multi section table: %d != %d" , h->id, table_id); -continue ; - } } +/*dvb_logerr("dvb_read_section: got section %d, last %d, filter %d", h->section_id, h->last_section, id );*/ /* handle the sections */ if (first_section ==-1 ) first_section = h->section_id; -else if (h->section_id == first_section) +else if (start_id == h->id && h->section_id == first_section)break ; -if (last_section ==-1 ) +if (last_section ==-1 || h->last_section > last_section) last_section = h->last_section;if (!tbl) {
@@ -228,10 +234,14 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,else dvb_logerr ("dvb_read_section: no initializer for table %d" , tid); -if (++sections == last_section +1 ) +if (id !=-1 && ++sections == last_section +1 ) { +dvb_logerr ("dvb_read_section: ++sections == last_section + 1" );break ; + } } -free (buf); + +if (buf) +free (buf);dvb_dmx_stop (dmx_fd);
Signature · 1 line
1.8.3.2
PATCH 2/18 libdvbv5: service location descriptor support
Implement the service location descriptor (0xa1), and small cleanups.
--- lib/include/descriptors.h | 4 +- lib/include/descriptors/desc_service_location.h | 69 +++++++++++++++++++++++ lib/libdvbv5/Makefile.am | 3 +- lib/libdvbv5/descriptors.c | 2 +- lib/libdvbv5/descriptors/desc_service_location.c | 70 ++++++++++++++++++++++++ 5 files changed, 145 insertions(+), 3 deletions(-) create mode 100644 lib/include/descriptors/desc_service_location.h create mode 100644 lib/libdvbv5/descriptors/desc_service_location.c
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 +69 -0
69 lines not on this page · raw message
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/eit.c ../include/descriptors/eit.h \ + descriptors/desc_service_location.c ../include/descriptors/desc_service_location.h libdvbv5_la_CPPFLAGS = $(ENFORCE_LIBDVBV5_STATIC) libdvbv5_la_LDFLAGS = $(LIBDVBV5_VERSION) $(ENFORCE_LIBDVBV5_STATIC) -lm
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 +70 -0
70 lines not on this page · raw message
Signature · 1 line
1.8.3.2
Re: [PATCH 02/18] libdvbv5: service location descriptor support
Em Mon, 30 Dec 2013 13:48:35 +0100
André Roth <[email protected]> escreveu:
Quoted 157 lines
Implement the service location descriptor (
0xa1), and small cleanups.Signed-off-by André Roth <[email protected]>--- lib/include/descriptors.h | 4 +- lib/include/descriptors/desc_service_location.h | 69 +++++++++++++++++++++++ lib/libdvbv5/Makefile.am | 3 +- lib/libdvbv5/descriptors.c | 2 +- lib/libdvbv5/descriptors/desc_service_location.c | 70 ++++++++++++++++++++++++ 5 files changed, 145 insertions(+), 3 deletions(-) create mode 100644 lib/include/descriptors/desc_service_location.h create mode 100644 lib/libdvbv5/descriptors/desc_service_location.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 +69
-0@@ -0,0 +1,69 @@ +/* +* 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 _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/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/eit.c ../include/descriptors/eit.h \ + descriptors/desc_service_location.c ../include/descriptors/desc_service_location.h libdvbv5_la_CPPFLAGS = $(ENFORCE_LIBDVBV5_STATIC) libdvbv5_la_LDFLAGS = $(LIBDVBV5_VERSION) $(ENFORCE_LIBDVBV5_STATIC) -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 +17
-0@@ -0,0 +1,70 @@ +/* +* 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
lib/libdvbv5/descriptors/desc_service_location.c line 27
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 blank line here.
lib/libdvbv5/descriptors/desc_service_location.c line 35
Quoted 8 lines
lib/libdvbv5/descriptors/desc_service_location.c new file +8
-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)); + buf +=sizeof (service_location->bitfield) +sizeof (service_location->elements);
Use offsetof().
lib/libdvbv5/descriptors/desc_service_location.c line 39
Quoted 4 lines
lib/libdvbv5/descriptors/desc_service_location.c new file +4
-0+ +bswap16 (service_location->bitfield); + +// FIXME: handle elements == 0
no C99 comments
lib/libdvbv5/descriptors/desc_service_location.c line 44
Quoted 5 lines
lib/libdvbv5/descriptors/desc_service_location.c new file +5
-0+ service_location->element =malloc (service_location->elements *sizeof (struct dvb_desc_service_location_element )); +int i; +struct dvb_desc_service_location_element *element = service_location->element; +for (i =0 ; i < service_location->elements; i++) { +memcpy (element, buf,sizeof (struct dvb_desc_service_location_element ) -1 );/* no \0 in lang */
Please test before copy.
lib/libdvbv5/descriptors/desc_service_location.c line 57
Quoted 13 lines
lib/libdvbv5/descriptors/desc_service_location.c new file +13
-0+ buf +=sizeof (struct dvb_desc_service_location_element ) -1 ; + element->language[3 ] ='\0' ; +bswap16 (element->bitfield); + element++; + } +} + +void dvb_desc_service_location_print (struct dvb_v5_fe_parms *parms,const struct dvb_desc *desc) +{ +const struct dvb_desc_service_location *service_location = (const struct dvb_desc_service_location *) desc; +dvb_log ("| pcr pid %d" , service_location->pcr_pid); +dvb_log ("| streams:" ); +int i;
blank line.
lib/libdvbv5/descriptors/desc_service_location.c line 58
Quoted 1 line
lib/libdvbv5/descriptors/desc_service_location.c new file +1
-0+struct dvb_desc_service_location_element *element = service_location->element;
Please reorder: variable declarations should come before the dvb_log() calls.
lib/libdvbv5/descriptors/desc_service_location.c line 59
Quoted 1 line
lib/libdvbv5/descriptors/desc_service_location.c new file +1
-0+for (i =0 ; i < service_location->elements; i++) {
Space after "for". No need for {}, as there's just one statement on this for.
lib/libdvbv5/descriptors/desc_service_location.c line 67
Quoted 8 lines
lib/libdvbv5/descriptors/desc_service_location.c new file +8
-0+dvb_log ("| pid %d, type %d: %s" , element[i].elementary_pid, element[i].stream_type, element[i].language); + } +dvb_log ("| %d elements" , service_location->elements); +} + +void dvb_desc_service_location_free (struct dvb_desc *desc) +{ +const struct dvb_desc_service_location *service_location = (const struct dvb_desc_service_location *) desc;
Please add a blank line.
Quoted 3 lines
lib/libdvbv5/descriptors/desc_service_location.c new file +3
-0+free (service_location->element); +} +
Signature · 2 lines
Cheers, Mauro
PATCH 3/18 libdvbv5: VCT table cleanup
In reply to André Roth--- lib/include/descriptors/vct.h | 10 ++++++---- lib/libdvbv5/descriptors/vct.c | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-)
lib/include/descriptors/vct.h +6 -4
@@ -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
@@ -35,14 +36,14 @@ struct dvb_table_vct_channel {uint16_t __short_name[7 ];union { -uint16_t bitfield1; +uint32_t bitfield1;struct {uint32_t modulation_mode:8 ;uint32_t minor_channel_number:10 ;uint32_t major_channel_number:10 ;uint32_t reserved1:4 ; } __attribute__((packed)); - }; + } __attribute__((packed));uint32_t carrier_frequency;uint16_t channel_tsid;
@@ -60,7 +61,8 @@ struct dvb_table_vct_channel { uint16_t ETM_location:2; } __attribute__((packed)); - }; + } __attribute__((packed)); +uint16_t source_id;union {uint16_t bitfield3;
@@ -68,7 +70,7 @@ struct dvb_table_vct_channel { uint16_t descriptors_length:10; uint16_t reserved3:6; } __attribute__((packed)); - }; + } __attribute__((packed));/* * Everything after descriptor (including it) won't be bit-mapped
lib/libdvbv5/descriptors/vct.c +2 -1
@@ -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
@@ -74,7 +75,7 @@ void dvb_table_vct_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,bswap32 (channel->carrier_frequency);bswap16 (channel->channel_tsid);bswap16 (channel->program_number); -bswap16 (channel->bitfield1); +bswap32 (channel->bitfield1);bswap16 (channel->bitfield2);bswap16 (channel->source_id);bswap16 (channel->bitfield3);
Signature · 1 line
1.8.3.2
PATCH 4/18 libdvbv5: mpeg elementary stream parsers
In reply to André RothImplement parsers for mpeg TS, PES and ES
--- lib/include/descriptors/mpeg_es.h | 109 ++++++++++++++++++++++++++++++ lib/include/descriptors/mpeg_pes.h | 111 ++++++++++++++++++++++++++++++ lib/include/descriptors/mpeg_ts.h | 78 +++++++++++++++++++++ lib/libdvbv5/Makefile.am | 5 +- lib/libdvbv5/descriptors/mpeg_es.c | 76 +++++++++++++++++++++ lib/libdvbv5/descriptors/mpeg_pes.c | 131 ++++++++++++++++++++++++++++++++++++ lib/libdvbv5/descriptors/mpeg_ts.c | 77 +++++++++++++++++++++ 7 files changed, 586 insertions(+), 1 deletion(-) create mode 100644 lib/include/descriptors/mpeg_es.h create mode 100644 lib/include/descriptors/mpeg_pes.h create mode 100644 lib/include/descriptors/mpeg_ts.h create mode 100644 lib/libdvbv5/descriptors/mpeg_es.c create mode 100644 lib/libdvbv5/descriptors/mpeg_pes.c create mode 100644 lib/libdvbv5/descriptors/mpeg_ts.c
lib/include/descriptors/mpeg_es.h new file +109 -0
@@ -0,0 +1,109 @@ +/* +* 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 _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 +111 -0
111 lines not on this page · raw message
lib/include/descriptors/mpeg_ts.h new file +78 -0
78 lines not on this page · raw message
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/eit.c ../include/descriptors/eit.h \ - descriptors/desc_service_location.c ../include/descriptors/desc_service_location.h + descriptors/desc_service_location.c ../include/descriptors/desc_service_location.h \ + descriptors/mpeg_ts.c ../include/descriptors/mpeg_ts.h \ + descriptors/mpeg_pes.c ../include/descriptors/mpeg_pes.h \ + descriptors/mpeg_es.c ../include/descriptors/mpeg_es.h libdvbv5_la_CPPFLAGS = $(ENFORCE_LIBDVBV5_STATIC) libdvbv5_la_LDFLAGS = $(LIBDVBV5_VERSION) $(ENFORCE_LIBDVBV5_STATIC) -lm
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 04/18] libdvbv5: mpeg elementary stream parsers
Em Mon, 30 Dec 2013 13:48:37 +0100
André Roth <[email protected]> escreveu:
Quoted 374 lines
Implement parsers for mpeg TS, PES and ES
Signed-off-by André Roth <[email protected]>--- lib/include/descriptors/mpeg_es.h | 109 ++++++++++++++++++++++++++++++ lib/include/descriptors/mpeg_pes.h | 111 ++++++++++++++++++++++++++++++ lib/include/descriptors/mpeg_ts.h | 78 +++++++++++++++++++++ lib/libdvbv5/Makefile.am | 5 +- lib/libdvbv5/descriptors/mpeg_es.c | 76 +++++++++++++++++++++ lib/libdvbv5/descriptors/mpeg_pes.c | 131 ++++++++++++++++++++++++++++++++++++ lib/libdvbv5/descriptors/mpeg_ts.c | 77 +++++++++++++++++++++ 7 files changed, 586 insertions(+), 1 deletion(-) create mode 100644 lib/include/descriptors/mpeg_es.h create mode 100644 lib/include/descriptors/mpeg_pes.h create mode 100644 lib/include/descriptors/mpeg_ts.h create mode 100644 lib/libdvbv5/descriptors/mpeg_es.c create mode 100644 lib/libdvbv5/descriptors/mpeg_pes.c create mode 100644 lib/libdvbv5/descriptors/mpeg_ts.clib/include/descriptors/mpeg_es.h new file +109
-0@@ -0,0 +1,109 @@ +/* +* 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 _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 +111
-0@@ -0,0 +1,111 @@ +/* +* 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 _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 +78
-0@@ -0,0 +1,78 @@ +/* +* 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 _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/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/eit.c ../include/descriptors/eit.h \ - descriptors/desc_service_location.c ../include/descriptors/desc_service_location.h + descriptors/desc_service_location.c ../include/descriptors/desc_service_location.h \ + descriptors/mpeg_ts.c ../include/descriptors/mpeg_ts.h \ + descriptors/mpeg_pes.c ../include/descriptors/mpeg_pes.h \ + descriptors/mpeg_es.c ../include/descriptors/mpeg_es.h libdvbv5_la_CPPFLAGS = $(ENFORCE_LIBDVBV5_STATIC) libdvbv5_la_LDFLAGS = $(LIBDVBV5_VERSION) $(ENFORCE_LIBDVBV5_STATIC) -lmlib/libdvbv5/descriptors/mpeg_es.c new file +17
-0@@ -0,0 +1,76 @@ +/* +* 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
lib/libdvbv5/descriptors/mpeg_es.c line 27
Quoted 10 lines
lib/libdvbv5/descriptors/mpeg_es.c new file +10
-0+* +*/ + +#include "descriptors/mpeg_es.h" +#include "descriptors.h" +#include "dvb-fe.h" + +int dvb_mpeg_es_seq_start_init (const uint8_t *buf,ssize_t buflen,struct dvb_mpeg_es_seq_start *seq_start) +{ +if (buflen <sizeof (struct dvb_mpeg_es_seq_start ))
space after "if".
Quoted 24 lines
lib/libdvbv5/descriptors/mpeg_es.c new file +24
-0+return -1 ; +memcpy (seq_start, buf,sizeof (struct dvb_mpeg_es_seq_start )); +bswap32 (seq_start->bitfield); +bswap32 (seq_start->bitfield2); +bswap32 (seq_start->bitfield3); +return 0 ; +} + +void dvb_mpeg_es_seq_start_print (struct dvb_v5_fe_parms *parms,struct dvb_mpeg_es_seq_start *seq_start) +{ +dvb_log ("MPEG ES SEQ START" ); +dvb_log (" - width %d" , seq_start->width); +dvb_log (" - height %d" , seq_start->height); +dvb_log (" - aspect %d" , seq_start->aspect); +dvb_log (" - framerate %d" , seq_start->framerate); +dvb_log (" - bitrate %d" , seq_start->bitrate); +dvb_log (" - one %d" , seq_start->one); +dvb_log (" - vbv %d" , seq_start->vbv); +dvb_log (" - constrained %d" , seq_start->constrained); +dvb_log (" - qm_intra %d" , seq_start->qm_intra); +dvb_log (" - qm_nonintra %d" , seq_start->qm_nonintra); +} + +const char *dvb_mpeg_es_frame_names[5 ] = {
lib/libdvbv5/descriptors/mpeg_es.c line 61
Quoted 10 lines
lib/libdvbv5/descriptors/mpeg_es.c new file +10
-0+"?" , +"I" , +"P" , +"B" , + "D" +}; + +int dvb_mpeg_es_pic_start_init (const uint8_t *buf,ssize_t buflen,struct dvb_mpeg_es_pic_start *pic_start) +{ +if (buflen <sizeof (struct dvb_mpeg_es_pic_start ))
space after 'if'.
Quoted 39 lines
lib/libdvbv5/descriptors/mpeg_es.c new file +15
-0+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) 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 +*
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;
blank line.
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 size before copy.
Quoted 18 lines
lib/libdvbv5/descriptors/mpeg_pes.c new file +18
-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 || + pes->stream_id == DVB_MPEG_STREAM_ECM || + pes->stream_id == DVB_MPEG_STREAM_EMM || + pes->stream_id == DVB_MPEG_STREAM_DIRECTORY ||
lib/libdvbv5/descriptors/mpeg_pes.c line 57
Quoted 10 lines
lib/libdvbv5/descriptors/mpeg_pes.c new file +10
-0+ pes->stream_id == DVB_MPEG_STREAM_DSMCC || + pes->stream_id == DVB_MPEG_STREAM_H222E ) { + dvb_logerr("mpeg pes: unsupported stream type %#04x", pes->stream_id); + } else { +memcpy (pes->optional, p,sizeof (struct dvb_mpeg_pes_optional ) - +sizeof (pes->optional->pts) - +sizeof (pes->optional->dts)); + p +=sizeof (struct dvb_mpeg_pes_optional ) - +sizeof (pes->optional->pts) - +sizeof (pes->optional->dts);
Use offsetof() and check before copy.
lib/libdvbv5/descriptors/mpeg_pes.c line 62
Quoted 5 lines
lib/libdvbv5/descriptors/mpeg_pes.c new file +5
-0+bswap16 (pes->optional->bitfield); + pes->optional->pts =0 ; + pes->optional->dts =0 ; +if (pes->optional->PTS_DTS &2 ) { +struct ts_t pts;
blank line.
lib/libdvbv5/descriptors/mpeg_pes.c line 64
Quoted 2 lines
lib/libdvbv5/descriptors/mpeg_pes.c new file +2
-0+memcpy (&pts, p,sizeof (pts)); + p +=sizeof (pts);
Please check before copy.
Quoted 26 lines
lib/libdvbv5/descriptors/mpeg_pes.c new file +26
-0+bswap16 (pts.bitfield); +bswap16 (pts.bitfield2); +if (pts.one !=1 || pts.one1 !=1 || pts.one2 !=1 ) +dvb_logwarn ("mpeg pes: invalid pts" ); +else { + pes->optional->pts |= (uint64_t ) pts.bits00; + pes->optional->pts |= (uint64_t ) pts.bits15 <<15 ; + pes->optional->pts |= (uint64_t ) pts.bits30 <<30 ; + } + } +if (pes->optional->PTS_DTS &1 ) { +struct ts_t dts; +memcpy (&dts, p,sizeof (dts)); + p +=sizeof (dts); +bswap16 (dts.bitfield); +bswap16 (dts.bitfield2); + pes->optional->dts |= (uint64_t ) dts.bits00; + pes->optional->dts |= (uint64_t ) dts.bits15 <<15 ; + pes->optional->dts |= (uint64_t ) dts.bits30 <<30 ; + } + *table_length +=sizeof (struct dvb_mpeg_pes_optional ); + } +} + +void dvb_mpeg_pes_free (struct dvb_mpeg_pes *ts) +{
lib/libdvbv5/descriptors/mpeg_pes.c line 100
Quoted 10 lines
lib/libdvbv5/descriptors/mpeg_pes.c new file +10
-0+free (ts); +} + +void dvb_mpeg_pes_print (struct dvb_v5_fe_parms *parms,struct dvb_mpeg_pes *pes) +{ +dvb_log ("MPEG PES" ); +dvb_log (" - sync %#08x" , pes->sync); +dvb_log (" - stream_id %#04x" , pes->stream_id); +dvb_log (" - length %d" , pes->length); +if (pes->stream_id ==DVB_MPEG_STREAM_PADDING ) {
Missing statement. It seems better to use a switch here.
Quoted 60 lines
lib/libdvbv5/descriptors/mpeg_pes.c new file +31
-0+ }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 +23
-0@@ -0,0 +1,77 @@ +/* +* 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 +* +*/ + +#include "descriptors/mpeg_ts.h" +#include "descriptors.h" +#include "dvb-fe.h"
lib/libdvbv5/descriptors/mpeg_ts.c line 33
Quoted 10 lines
lib/libdvbv5/descriptors/mpeg_ts.c new file +10
-0+ +void dvb_mpeg_ts_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf,ssize_t buflen,uint8_t *table,ssize_t *table_length) +{ +if (buf[0 ] !=DVB_MPEG_TS ) { +dvb_logerr ("mpeg ts invalid marker %#02x, sould be %#02x" , buf[0 ],DVB_MPEG_TS ); + *table_length =0 ; +return ; + } +struct dvb_mpeg_ts *ts = (struct dvb_mpeg_ts *) table; +const uint8_t *p = buf;
Please reorder: data declarations should come before the if.
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 before copy.
lib/libdvbv5/descriptors/mpeg_ts.c line 41
Quoted 7 lines
lib/libdvbv5/descriptors/mpeg_ts.c new file +7
-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 ));
Please check before copy.
Quoted 36 lines
lib/libdvbv5/descriptors/mpeg_ts.c new file +36
-0+ 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 5/18 libdvbv5: fix NIT structures
In reply to André Roth--- lib/include/descriptors/nit.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
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;
Signature · 1 line
1.8.3.2
PATCH 6/18 libdvbv5: implement dvb_fe_dummy for logging
In reply to André RothThe dvbv5 functions use the dvb_v5_fe_parms struct for logging. This struct is normally obtained by opening a dvb device. For situations where the opening of a dvb device is not desired, the dvb_fe_dummy can be used.
--- lib/include/descriptors.h | 6 ++++++ lib/include/dvb-fe.h | 2 ++ lib/libdvbv5/descriptors.c | 2 ++ lib/libdvbv5/dvb-fe.c | 7 +++++++ 4 files changed, 17 insertions(+)
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/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 +2 -0
@@ -69,6 +69,8 @@ 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/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) {
Signature · 1 line
1.8.3.2
PATCH 7/18 libdvbv5: fix EIT parsing
In reply to André Roththe dvb_table_eit_event now contains the service_id, indicating where the events belong to.
--- lib/include/descriptors/eit.h | 3 ++- lib/libdvbv5/descriptors/eit.c | 35 ++++++++++++++++++++++++++--------- 2 files changed, 28 insertions(+), 10 deletions(-)
lib/include/descriptors/eit.h +2 -1
@@ -40,7 +40,7 @@struct dvb_table_eit_event {uint16_t event_id;union { -uint16_t bitfield; +uint16_t bitfield1;/* first 2 bytes are MJD, they need to be bswapped */ uint8_t dvbstart[5 ]; } __attribute__((packed));uint8_t dvbduration[3 ];
@@ -56,6 +56,7 @@ struct dvb_table_eit_event {struct dvb_table_eit_event *next;struct tm start;uint32_t duration; +uint16_t service_id; } __attribute__((packed));struct dvb_table_eit {
lib/libdvbv5/descriptors/eit.c +26 -9
@@ -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,18 +53,30 @@ 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); +bswap16 (event->bitfield1);bswap16 (event->bitfield2); event->descriptor =NULL ; event->next =NULL ;dvb_time (event->dvbstart, &event->start); - event->duration =bcd (event->dvbduration[0 ]) *3600 + -bcd (event->dvbduration[1 ]) *60 + -bcd (event->dvbduration[2 ]); + event->duration =bcd ((uint32_t ) event->dvbduration[0 ]) *3600 + +bcd ((uint32_t ) event->dvbduration[1 ]) *60 + +bcd ((uint32_t ) event->dvbduration[2 ]); + + event->service_id = eit->header.id;if (!*head) *head = event;
@@ -102,6 +119,7 @@ void dvb_table_eit_print(struct dvb_v5_fe_parms *parms, struct dvb_table_eit *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);
@@ -137,9 +155,8 @@ void dvb_time(const uint8_t data[5], struct tm *tm) tm->tm_mday = day; tm->tm_mon = month -1 ; tm->tm_year = year; - tm->tm_isdst =-1 ; - tm->tm_wday =0 ; - tm->tm_yday =0 ; + tm->tm_isdst =1 ;/* dst in effect, do not adjust */ +mktime ( tm ); }
Signature · 1 line
1.8.3.2
Re: [PATCH 07/18] libdvbv5: fix EIT parsing
Em Mon, 30 Dec 2013 13:48:40 +0100
André Roth <[email protected]> escreveu:
Quoted 54 lines
the
dvb_table_eit_eventnow contains theservice_id, indicating where the events belong to.Signed-off-by André Roth <[email protected]>--- lib/include/descriptors/eit.h | 3 ++- lib/libdvbv5/descriptors/eit.c | 35 ++++++++++++++++++++++++++--------- 2 files changed, 28 insertions(+), 10 deletions(-)lib/include/descriptors/eit.h +2
-1@@ -40,7 +40,7 @@struct dvb_table_eit_event {uint16_t event_id;union { -uint16_t bitfield; +uint16_t bitfield1;/* first 2 bytes are MJD, they need to be bswapped */ uint8_t dvbstart[5 ]; } __attribute__((packed));uint8_t dvbduration[3 ];@@ -56,6 +56,7 @@ struct dvb_table_eit_event {struct dvb_table_eit_event *next;struct tm start;uint32_t duration; +uint16_t service_id; } __attribute__((packed));struct dvb_table_eit {lib/libdvbv5/descriptors/eit.c +7
-2@@ -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,18 +53,30 @@ 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) -
lib/libdvbv5/descriptors/eit.c void dvb_table_eit_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize · line 67
Quoted 10 lines
lib/libdvbv5/descriptors/eit.c +10
-0+sizeof (event->next) - +sizeof (event->start) - +sizeof (event->duration) - + sizeof(event->service_id)); + p +=sizeof (struct dvb_table_eit_event ) - +sizeof (event->descriptor) - +sizeof (event->next) - +sizeof (event->start) - +sizeof (event->duration) - +sizeof (event->service_id);
Please check before copy and replace those sizeof()'s by offsetof().
Quoted 39 lines
lib/libdvbv5/descriptors/eit.c +9
-7bswap16 (event->event_id); -bswap16 (event->bitfield); +bswap16 (event->bitfield1);bswap16 (event->bitfield2); event->descriptor =NULL ; event->next =NULL ;dvb_time (event->dvbstart, &event->start); - event->duration =bcd (event->dvbduration[0 ]) *3600 + -bcd (event->dvbduration[1 ]) *60 + -bcd (event->dvbduration[2 ]); + event->duration =bcd ((uint32_t ) event->dvbduration[0 ]) *3600 + +bcd ((uint32_t ) event->dvbduration[1 ]) *60 + +bcd ((uint32_t ) event->dvbduration[2 ]); + + event->service_id = eit->header.id;if (!*head) *head = event;@@ -102,6 +119,7 @@ void dvb_table_eit_print(struct dvb_v5_fe_parms *parms, struct dvb_table_eit *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);@@ -137,9 +155,8 @@ void dvb_time(const uint8_t data[5], struct tm *tm) tm->tm_mday = day; tm->tm_mon = month -1 ; tm->tm_year = year; - tm->tm_isdst =-1 ; - tm->tm_wday =0 ; - tm->tm_yday =0 ; + tm->tm_isdst =1 ;/* dst in effect, do not adjust */ +mktime ( tm ); }
Signature · 2 lines
Cheers, Mauro
PATCH 8/18 libdvbv5: implement MGT parser
In reply to André Roth--- lib/include/descriptors/mgt.h | 80 ++++++++++++++++++++++++++++ lib/libdvbv5/Makefile.am | 1 + lib/libdvbv5/descriptors.c | 2 + lib/libdvbv5/descriptors/mgt.c | 117 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 200 insertions(+) create mode 100644 lib/include/descriptors/mgt.h create mode 100644 lib/libdvbv5/descriptors/mgt.c
lib/include/descriptors/mgt.h new file +80 -0
@@ -0,0 +1,80 @@ +/* +* 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/atsc_header.h" +#include "descriptors.h" + +#define ATSC_TABLE_MGT 0xC7 + +struct atsc_table_mgt_table { +uint16_t type; +union { +uint16_t bitfield; +struct { +uint16_t pid:13 ; +uint16_t one:3 ; + } __attribute__((packed)); + } __attribute__((packed)); +uint8_t type_version:5 ; +uint8_t one2:3 ; +uint32_t size; +union { +uint16_t bitfield2; +struct { +uint16_t desc_length:12 ; +uint16_t one3:4 ; + } __attribute__((packed)); + } __attribute__((packed)); +struct dvb_desc *descriptor; +struct atsc_table_mgt_table *next; +} __attribute__((packed)); + +struct atsc_table_mgt { +struct atsc_table_header header; +uint16_t tables; +struct atsc_table_mgt_table *table; +struct dvb_desc *descriptor; +} __attribute__((packed)); + + +#define atsc_mgt_table_foreach ( _tran, _mgt ) \ + for( struct atsc_table_mgt_table *_tran = _mgt->table; _tran; _tran = _tran->next ) \ + +struct dvb_v5_fe_parms ; + +#ifdef __cplusplus +extern "C" { +#endif + +void atsc_table_mgt_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf,ssize_t buflen,uint8_t *table,ssize_t *table_length); +void atsc_table_mgt_free (struct atsc_table_mgt *mgt); +void atsc_table_mgt_print (struct dvb_v5_fe_parms *parms,struct atsc_table_mgt *mgt); + +#ifdef __cplusplus +} +#endif + +#endif
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/eit.c ../include/descriptors/eit.h \ + descriptors/mgt.c ../include/descriptors/mgt.h \ descriptors/desc_service_location.c ../include/descriptors/desc_service_location.h \ descriptors/mpeg_ts.c ../include/descriptors/mpeg_ts.h \ descriptors/mpeg_pes.c ../include/descriptors/mpeg_pes.h \
lib/libdvbv5/descriptors.c +2 -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"
@@ -84,6 +85,7 @@ const struct dvb_table_init dvb_table_initializers[] = { [DVB_TABLE_TVCT] = { dvb_table_vct_init, sizeof(struct dvb_table_vct) }, [DVB_TABLE_CVCT] = { dvb_table_vct_init, sizeof(struct dvb_table_vct) }, [DVB_TABLE_EIT_SCHEDULE] = { dvb_table_eit_init, sizeof(struct dvb_table_eit) }, + [ATSC_TABLE_MGT] = { atsc_table_mgt_init, sizeof(struct atsc_table_mgt) }, };char *default_charset ="iso-8859-1" ;
lib/libdvbv5/descriptors/mgt.c new file +117 -0
117 lines not on this page · raw message
Signature · 1 line
1.8.3.2
Re: [PATCH 08/18] libdvbv5: implement MGT parser
Em Mon, 30 Dec 2013 13:48:41 +0100
André Roth <[email protected]> escreveu:
Quoted 154 lines
Signed-off-by André Roth <[email protected]>--- lib/include/descriptors/mgt.h | 80 ++++++++++++++++++++++++++++ lib/libdvbv5/Makefile.am | 1 + lib/libdvbv5/descriptors.c | 2 + lib/libdvbv5/descriptors/mgt.c | 117 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 200 insertions(+) create mode 100644 lib/include/descriptors/mgt.h create mode 100644 lib/libdvbv5/descriptors/mgt.clib/include/descriptors/mgt.h new file +80
-0@@ -0,0 +1,80 @@ +/* +* 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/atsc_header.h" +#include "descriptors.h" + +#define ATSC_TABLE_MGT 0xC7 + +struct atsc_table_mgt_table { +uint16_t type; +union { +uint16_t bitfield; +struct { +uint16_t pid:13 ; +uint16_t one:3 ; + } __attribute__((packed)); + } __attribute__((packed)); +uint8_t type_version:5 ; +uint8_t one2:3 ; +uint32_t size; +union { +uint16_t bitfield2; +struct { +uint16_t desc_length:12 ; +uint16_t one3:4 ; + } __attribute__((packed)); + } __attribute__((packed)); +struct dvb_desc *descriptor; +struct atsc_table_mgt_table *next; +} __attribute__((packed)); + +struct atsc_table_mgt { +struct atsc_table_header header; +uint16_t tables; +struct atsc_table_mgt_table *table; +struct dvb_desc *descriptor; +} __attribute__((packed)); + + +#define atsc_mgt_table_foreach ( _tran, _mgt ) \ + for( struct atsc_table_mgt_table *_tran = _mgt->table; _tran; _tran = _tran->next ) \ + +struct dvb_v5_fe_parms ; + +#ifdef __cplusplus +extern "C" { +#endif + +void atsc_table_mgt_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf,ssize_t buflen,uint8_t *table,ssize_t *table_length); +void atsc_table_mgt_free (struct atsc_table_mgt *mgt); +void atsc_table_mgt_print (struct dvb_v5_fe_parms *parms,struct atsc_table_mgt *mgt); + +#ifdef __cplusplus +} +#endif + +#endif 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/eit.c ../include/descriptors/eit.h \ + descriptors/mgt.c ../include/descriptors/mgt.h \ descriptors/desc_service_location.c ../include/descriptors/desc_service_location.h \ descriptors/mpeg_ts.c ../include/descriptors/mpeg_ts.h \ descriptors/mpeg_pes.c ../include/descriptors/mpeg_pes.h \lib/libdvbv5/descriptors.c +2
-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" @@ -84,6 +85,7 @@ const struct dvb_table_init dvb_table_initializers[] = { [DVB_TABLE_TVCT] = { dvb_table_vct_init, sizeof(struct dvb_table_vct) }, [DVB_TABLE_CVCT] = { dvb_table_vct_init, sizeof(struct dvb_table_vct) }, [DVB_TABLE_EIT_SCHEDULE] = { dvb_table_eit_init, sizeof(struct dvb_table_eit) }, + [ATSC_TABLE_MGT] = { atsc_table_mgt_init, sizeof(struct atsc_table_mgt) }, };char *default_charset ="iso-8859-1" ;lib/libdvbv5/descriptors/mgt.c new file +20
-0@@ -0,0 +1,117 @@ +/* +* 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 +* +*/ +
lib/libdvbv5/descriptors/mgt.c line 30
Quoted 10 lines
lib/libdvbv5/descriptors/mgt.c new file +10
-0+#include "descriptors/mgt.h" +#include "dvb-fe.h" + +void atsc_table_mgt_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf,ssize_t buflen,uint8_t *table,ssize_t *table_length) +{ +const uint8_t *p = buf; +struct atsc_table_mgt *mgt = (struct atsc_table_mgt *) table; +struct dvb_desc **head_desc; +struct atsc_table_mgt_table **head; +/*int desc_length;*/
If you don't need a line, just don't add it, instead of adding it commented.
lib/libdvbv5/descriptors/mgt.c line 41
Quoted 11 lines
lib/libdvbv5/descriptors/mgt.c new file +11
-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 atsc_table_mgt ) -sizeof (mgt->descriptor) -sizeof (mgt->table));
Test before copy and use offsetof().
lib/libdvbv5/descriptors/mgt.c line 50
Quoted 9 lines
lib/libdvbv5/descriptors/mgt.c new file +9
-0+ *table_length =sizeof (struct atsc_table_mgt ); + + mgt->descriptor =NULL ; + mgt->table =NULL ; + head_desc = &mgt->descriptor; + head = &mgt->table; +bswap16 (mgt->tables); + } + p +=sizeof (struct atsc_table_mgt ) -sizeof (mgt->descriptor) -sizeof (mgt->table);
Use offsetof().
lib/libdvbv5/descriptors/mgt.c line 53
Quoted 3 lines
lib/libdvbv5/descriptors/mgt.c new file +3
-0+ +/*dvb_parse_descriptors(parms, p, desc_length, head_desc);*/ +/*p += desc_length;*/
If not needed, don't add.
lib/libdvbv5/descriptors/mgt.c line 54
Quoted 1 line
lib/libdvbv5/descriptors/mgt.c new file +1
-0+int i =0 ;
Please use tab, not spaces.
lib/libdvbv5/descriptors/mgt.c line 55
Quoted 1 line
lib/libdvbv5/descriptors/mgt.c new file +1
-0+struct atsc_table_mgt_table *last =NULL ;
Please put data declaration at the beginning of the function.
lib/libdvbv5/descriptors/mgt.c line 57
Quoted 2 lines
lib/libdvbv5/descriptors/mgt.c new file +2
-0+while (i++ < mgt->tables && (uint8_t *) p < buf + buflen -4 ) { +struct atsc_table_mgt_table *table = (struct atsc_table_mgt_table *)malloc (sizeof (struct atsc_table_mgt_table ));
Please add a blank line.
lib/libdvbv5/descriptors/mgt.c line 59
Quoted 2 lines
lib/libdvbv5/descriptors/mgt.c new file +2
-0+memcpy (table, p,sizeof (struct atsc_table_mgt_table ) -sizeof (table->descriptor) -sizeof (table->next)); + p +=sizeof (struct atsc_table_mgt_table ) -sizeof (table->descriptor) -sizeof (table->next);
Please use offsetof().
Quoted 15 lines
lib/libdvbv5/descriptors/mgt.c new file +15
-0+ +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;
lib/libdvbv5/descriptors/mgt.c line 84
Quoted 10 lines
lib/libdvbv5/descriptors/mgt.c new file +10
-0+dvb_parse_descriptors (parms, p, table->desc_length, head_desc); + + p += table->desc_length; + last = table; + } +} + +void atsc_table_mgt_free (struct atsc_table_mgt *mgt) +{ +struct atsc_table_mgt_table *table = mgt->table;
blank line.
Quoted 8 lines
lib/libdvbv5/descriptors/mgt.c new file +8
-0+dvb_free_descriptors ((struct dvb_desc **) &mgt->descriptor); +while (table) { +dvb_free_descriptors ((struct dvb_desc **) &table->descriptor); +struct atsc_table_mgt_table *tmp = table; + table = table->next; +free (tmp); + } +free (mgt);
lib/libdvbv5/descriptors/mgt.c line 102
Quoted 10 lines
lib/libdvbv5/descriptors/mgt.c new file +10
-0+} + +void atsc_table_mgt_print (struct dvb_v5_fe_parms *parms,struct atsc_table_mgt *mgt) +{ +dvb_log ("MGT" ); +atsc_table_header_print (parms, &mgt->header); +dvb_log ("| tables %d" , mgt->tables); +/*dvb_print_descriptors(parms, mgt->descriptor);*/ +const struct atsc_table_mgt_table *table = mgt->table; +uint16_t tables =0 ;
data declarations at the beginning of the function.
lib/libdvbv5/descriptors/mgt.c line 103
Quoted 1 line
lib/libdvbv5/descriptors/mgt.c new file +1
-0+while (table) {
space after while.
Quoted 14 lines
lib/libdvbv5/descriptors/mgt.c new file +14
-0+dvb_log ("|- type %04x %d" , table->type, table->pid); +dvb_log ("| one %d" , table->one); +dvb_log ("| one2 %d" , table->one2); +dvb_log ("| type version %d" , table->type_version); +dvb_log ("| size %d" , table->size); +dvb_log ("| one3 %d" , table->one3); +dvb_log ("| desc_length %d" , table->desc_length); +dvb_print_descriptors (parms, table->descriptor); + table = table->next; + tables++; + } +dvb_log ("|_ %d tables" , tables); +} +
Signature · 2 lines
Cheers, Mauro
PATCH 9/18 libdvbv5: implement ATSC EIT
In reply to André Roth--- lib/include/descriptors/atsc_eit.h | 90 +++++++++++++++++++++ lib/include/descriptors/atsc_header.h | 63 +++++++++++++++ lib/libdvbv5/Makefile.am | 4 +- lib/libdvbv5/descriptors.c | 2 + lib/libdvbv5/descriptors/atsc_eit.c | 142 +++++++++++++++++++++++++++++++++ lib/libdvbv5/descriptors/atsc_header.c | 47 +++++++++++ 6 files changed, 347 insertions(+), 1 deletion(-) create mode 100644 lib/include/descriptors/atsc_eit.h create mode 100644 lib/include/descriptors/atsc_header.h create mode 100644 lib/libdvbv5/descriptors/atsc_eit.c create mode 100644 lib/libdvbv5/descriptors/atsc_header.c
lib/include/descriptors/atsc_eit.h new file +90 -0
@@ -0,0 +1,90 @@ +/* +* 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 _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 +63 -0
63 lines not on this page · raw message
lib/libdvbv5/Makefile.am +3 -1
@@ -48,8 +48,10 @@ libdvbv5_la_SOURCES = \ descriptors/nit.c ../include/descriptors/nit.h \ descriptors/sdt.c ../include/descriptors/sdt.h \ descriptors/vct.c ../include/descriptors/vct.h \ - descriptors/eit.c ../include/descriptors/eit.h \ + descriptors/atsc_header.c ../include/descriptors/atsc_header.h \ descriptors/mgt.c ../include/descriptors/mgt.h \ + descriptors/eit.c ../include/descriptors/eit.h \ + descriptors/atsc_eit.c ../include/descriptors/atsc_eit.h \ descriptors/desc_service_location.c ../include/descriptors/desc_service_location.h \ descriptors/mpeg_ts.c ../include/descriptors/mpeg_ts.h \ descriptors/mpeg_pes.c ../include/descriptors/mpeg_pes.h \
lib/libdvbv5/descriptors.c +2 -0
@@ -37,6 +37,7 @@#include "descriptors/eit.h" #include "descriptors/vct.h" #include "descriptors/mgt.h" +#include "descriptors/atsc_eit.h" #include "descriptors/desc_language.h" #include "descriptors/desc_network_name.h" #include "descriptors/desc_cable_delivery.h"
@@ -86,6 +87,7 @@ const struct dvb_table_init dvb_table_initializers[] = { [DVB_TABLE_CVCT] = { dvb_table_vct_init, sizeof(struct dvb_table_vct) }, [DVB_TABLE_EIT_SCHEDULE] = { dvb_table_eit_init, sizeof(struct dvb_table_eit) }, [ATSC_TABLE_MGT] = { atsc_table_mgt_init, sizeof(struct atsc_table_mgt) }, + [ATSC_TABLE_EIT] = { atsc_table_eit_init, sizeof(struct atsc_table_eit) }, };char *default_charset ="iso-8859-1" ;
lib/libdvbv5/descriptors/atsc_eit.c new file +142 -0
142 lines not on this page · raw message
lib/libdvbv5/descriptors/atsc_header.c new file +47 -0
47 lines not on this page · raw message
Signature · 1 line
1.8.3.2
Re: [PATCH 09/18] libdvbv5: implement ATSC EIT
Em Mon, 30 Dec 2013 13:48:42 +0100
André Roth <[email protected]> escreveu:
Quoted 242 lines
Signed-off-by André Roth <[email protected]>--- lib/include/descriptors/atsc_eit.h | 90 +++++++++++++++++++++ lib/include/descriptors/atsc_header.h | 63 +++++++++++++++ lib/libdvbv5/Makefile.am | 4 +- lib/libdvbv5/descriptors.c | 2 + lib/libdvbv5/descriptors/atsc_eit.c | 142 +++++++++++++++++++++++++++++++++ lib/libdvbv5/descriptors/atsc_header.c | 47 +++++++++++ 6 files changed, 347 insertions(+), 1 deletion(-) create mode 100644 lib/include/descriptors/atsc_eit.h create mode 100644 lib/include/descriptors/atsc_header.h create mode 100644 lib/libdvbv5/descriptors/atsc_eit.c create mode 100644 lib/libdvbv5/descriptors/atsc_header.clib/include/descriptors/atsc_eit.h new file +90
-0@@ -0,0 +1,90 @@ +/* +* 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 _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 +63
-0@@ -0,0 +1,63 @@ +/* +* 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 _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/libdvbv5/Makefile.am +3
-1@@ -48,8 +48,10 @@ libdvbv5_la_SOURCES = \ descriptors/nit.c ../include/descriptors/nit.h \ descriptors/sdt.c ../include/descriptors/sdt.h \ descriptors/vct.c ../include/descriptors/vct.h \ - descriptors/eit.c ../include/descriptors/eit.h \ + descriptors/atsc_header.c ../include/descriptors/atsc_header.h \ descriptors/mgt.c ../include/descriptors/mgt.h \ + descriptors/eit.c ../include/descriptors/eit.h \ + descriptors/atsc_eit.c ../include/descriptors/atsc_eit.h \ descriptors/desc_service_location.c ../include/descriptors/desc_service_location.h \ descriptors/mpeg_ts.c ../include/descriptors/mpeg_ts.h \ descriptors/mpeg_pes.c ../include/descriptors/mpeg_pes.h \lib/libdvbv5/descriptors.c +2
-0@@ -37,6 +37,7 @@#include "descriptors/eit.h" #include "descriptors/vct.h" #include "descriptors/mgt.h" +#include "descriptors/atsc_eit.h" #include "descriptors/desc_language.h" #include "descriptors/desc_network_name.h" #include "descriptors/desc_cable_delivery.h" @@ -86,6 +87,7 @@ const struct dvb_table_init dvb_table_initializers[] = { [DVB_TABLE_CVCT] = { dvb_table_vct_init, sizeof(struct dvb_table_vct) }, [DVB_TABLE_EIT_SCHEDULE] = { dvb_table_eit_init, sizeof(struct dvb_table_eit) }, [ATSC_TABLE_MGT] = { atsc_table_mgt_init, sizeof(struct atsc_table_mgt) }, + [ATSC_TABLE_EIT] = { atsc_table_eit_init, sizeof(struct atsc_table_eit) }, };char *default_charset ="iso-8859-1" ;lib/libdvbv5/descriptors/atsc_eit.c new file +21
-0@@ -0,0 +1,142 @@ +/* +* 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 +* +*/ + +#include "descriptors/atsc_eit.h"
lib/libdvbv5/descriptors/atsc_eit.c line 31
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));
Hmm... on some patches, when the table already exists, nothing is copied.
Just the pointer 'p' is incremented.
We should standardize this. Not sure what's the better.
lib/libdvbv5/descriptors/atsc_eit.c line 39
Quoted 8 lines
lib/libdvbv5/descriptors/atsc_eit.c new file +8
-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)); + *table_length =sizeof (struct atsc_table_eit );
For both memcpy(): please test before copy, and use offsetof().
lib/libdvbv5/descriptors/atsc_eit.c line 44
Quoted 5 lines
lib/libdvbv5/descriptors/atsc_eit.c new file +5
-0+ + eit->event =NULL ; + head = &eit->event; + } + p +=sizeof (struct atsc_table_eit ) -sizeof (eit->event);
Please use offsetof().
lib/libdvbv5/descriptors/atsc_eit.c line 48
Quoted 4 lines
lib/libdvbv5/descriptors/atsc_eit.c new file +4
-0+ +hexdump (parms,"eit" , p,64 ); + +int i =0 ;
Use tabs.
lib/libdvbv5/descriptors/atsc_eit.c line 49
Quoted 1 line
lib/libdvbv5/descriptors/atsc_eit.c new file +1
-0+struct atsc_table_eit_event *last =NULL ;
Please move to the beginning of the function.
lib/libdvbv5/descriptors/atsc_eit.c line 61
Quoted 12 lines
lib/libdvbv5/descriptors/atsc_eit.c new file +12
-0+while (i++ < eit->events && (uint8_t *) p < buf + buflen -4 ) { +struct atsc_table_eit_event *event = (struct atsc_table_eit_event *)malloc (sizeof (struct atsc_table_eit_event )); +memcpy (event, p,sizeof (struct atsc_table_eit_event ) - +sizeof (event->descriptor) - +sizeof (event->next) - +sizeof (event->start) - +sizeof (event->source_id)); + p +=sizeof (struct atsc_table_eit_event ) - +sizeof (event->descriptor) - +sizeof (event->next) - +sizeof (event->start) - +sizeof (event->source_id);
Use offsetof().
lib/libdvbv5/descriptors/atsc_eit.c line 68
Quoted 7 lines
lib/libdvbv5/descriptors/atsc_eit.c new file +7
-0+ +bswap16 (event->bitfield); +bswap32 (event->start_time); +bswap32 (event->bitfield2); + event->descriptor =NULL ; + event->next =NULL ; +atsc_time (event->start_time, &event->start);
Use tabs.
lib/libdvbv5/descriptors/atsc_eit.c line 71
Quoted 3 lines
lib/libdvbv5/descriptors/atsc_eit.c new file +3
-0+ event->source_id = eit->header.id; + +//FIXME: title
Don't use c99 comments. Use tabs.
lib/libdvbv5/descriptors/atsc_eit.c line 80
Quoted 9 lines
lib/libdvbv5/descriptors/atsc_eit.c new file +9
-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;
Move to the beginning of the function or to the beginning of the braces.
lib/libdvbv5/descriptors/atsc_eit.c line 81
Quoted 1 line
lib/libdvbv5/descriptors/atsc_eit.c new file +1
-0+union atsc_table_eit_desc_length dl = *(union atsc_table_eit_desc_length *) p;
Same here: declare 'dl' at the beginning of a block.
lib/libdvbv5/descriptors/atsc_eit.c line 93
Quoted 12 lines
lib/libdvbv5/descriptors/atsc_eit.c new file +12
-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;
please add a blank line here.
Quoted 5 lines
lib/libdvbv5/descriptors/atsc_eit.c new file +5
-0+while (event) { +dvb_free_descriptors ((struct dvb_desc **) &event->descriptor); +struct atsc_table_eit_event *tmp = event; + event = event->next; +free (tmp);
lib/libdvbv5/descriptors/atsc_eit.c line 108
Quoted 10 lines
lib/libdvbv5/descriptors/atsc_eit.c new file +10
-0+ } +free (eit); +} + +void atsc_table_eit_print (struct dvb_v5_fe_parms *parms,struct atsc_table_eit *eit) +{ +dvb_log ("EIT" ); +atsc_table_header_print (parms, &eit->header); +const struct atsc_table_eit_event *event = eit->event; +uint16_t events =0 ;
Data declarations first.
Quoted 87 lines
lib/libdvbv5/descriptors/atsc_eit.c new file +34
-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 +47
-0@@ -0,0 +1,47 @@ +/* +* 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 +* +*/ + +#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); +} +
Signature · 2 lines
Cheers, Mauro
Re: [PATCH 09/18] libdvbv5: implement ATSC EIT
Quoted 12 lines
lib/libdvbv5/descriptors/atsc_eit.c line 31
Quoted 9 lines
lib/libdvbv5/descriptors/atsc_eit.c new file +8
-0+void atsc_table_eit_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf,ssize_t buflen,uint8_t *table,ssize_t *table_length) +{ +const uint8_t *p = buf; +struct atsc_table_eit *eit = (struct atsc_table_eit *) table; +struct atsc_table_eit_event **head; + +if (*table_length >0 ) { +memcpy (eit, p,sizeof (struct atsc_table_eit ) -sizeof (eit->event));Hmm... on some patches, when the table already exists, nothing is copied.
Quoted 3 lines
Just the pointer 'p' is incremented.
We should standardize this. Not sure what's the better.
agree. the first implementations were ok not copying already existing table bodies. but tables like the EIT need info from the table body in every section, so we need to parse that...
I will fix this for all tables in a later patch.
Regards,
andré
PATCH 10/18 libdvbv5: prefix VCT with atsc_ instead of dvb_
In reply to André Roth--- lib/include/descriptors/vct.h | 30 +++++++++++++++--------------- lib/include/dvb-scan.h | 2 +- lib/libdvbv5/descriptors.c | 16 ++++++++-------- lib/libdvbv5/descriptors/vct.c | 37 ++++++++++++++++++------------------- lib/libdvbv5/dvb-file.c | 2 +- lib/libdvbv5/dvb-scan.c | 10 +++++----- 6 files changed, 48 insertions(+), 49 deletions(-)
lib/include/descriptors/vct.h +15 -15
@@ -25,14 +25,14 @@#include <stdint.h> #include <unistd.h> /* ssize_t */ -#include "descriptors/header.h" +#include "descriptors/atsc_header.h" #include "descriptors.h" -#define DVB_TABLE_TVCT 0xc8 -#define DVB_TABLE_CVCT 0xc9 -#define DVB_TABLE_VCT_PID 0x1ffb +#define ATSC_TABLE_TVCT 0xc8 +#define ATSC_TABLE_CVCT 0xc9 +#define ATSC_TABLE_VCT_PID 0x1ffb -struct dvb_table_vct_channel { +struct atsc_table_vct_channel {uint16_t __short_name[7 ];union {
@@ -77,15 +77,15 @@ struct dvb_table_vct_channel {* to the data parsed from the MPEG TS. So, metadata are added there */ struct dvb_desc *descriptor; -struct dvb_table_vct_channel *next; +struct atsc_table_vct_channel *next;/* The channel_short_name is converted to locale charset by vct.c */ char short_name[32 ]; } __attribute__((packed)); -struct dvb_table_vct { -struct dvb_table_header header; +struct atsc_table_vct { +struct atsc_table_header header;uint8_t ATSC_protocol_version;uint8_t num_channels_in_section;
@@ -94,12 +94,12 @@ struct dvb_table_vct {* Everything after descriptor (including it) won't be bit-mapped * to the data parsed from the MPEG TS. So, metadata are added there */ -struct dvb_table_vct_channel *channel; +struct atsc_table_vct_channel *channel;struct dvb_desc *descriptor; } __attribute__((packed)); -union dvb_table_vct_descriptor_length { +union atsc_table_vct_descriptor_length {uint16_t bitfield;struct {uint16_t descriptor_length:10 ;
@@ -107,8 +107,8 @@ union dvb_table_vct_descriptor_length { }; }; -#define dvb_vct_channel_foreach (_channel, _vct) \ - for (struct dvb_table_vct_channel *_channel = _vct->channel; _channel; _channel = _channel->next) \ +#define atsc_vct_channel_foreach (_channel, _vct) \ + for (struct atsc_table_vct_channel *_channel = _vct->channel; _channel; _channel = _channel->next) \struct dvb_v5_fe_parms ;
@@ -116,9 +116,9 @@ struct dvb_v5_fe_parms;extern "C" {#endif -void dvb_table_vct_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf,ssize_t buflen,uint8_t *table,ssize_t *table_length); -void dvb_table_vct_free (struct dvb_table_vct *vct); -void dvb_table_vct_print (struct dvb_v5_fe_parms *parms,struct dvb_table_vct *vct); +void atsc_table_vct_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf,ssize_t buflen,uint8_t *table,ssize_t *table_length); +void atsc_table_vct_free (struct atsc_table_vct *vct); +void atsc_table_vct_print (struct dvb_v5_fe_parms *parms,struct atsc_table_vct *vct); #ifdef __cplusplus }
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/descriptors.c +8 -8
@@ -78,16 +78,16 @@ void dvb_desc_default_print(struct dvb_v5_fe_parms *parms, const struct dvb_desc }const struct dvb_table_init dvb_table_initializers[] = { - [DVB_TABLE_PAT ] = { dvb_table_pat_init,sizeof (struct dvb_table_pat ) }, - [DVB_TABLE_PMT ] = { dvb_table_pmt_init,sizeof (struct dvb_table_pmt ) }, - [DVB_TABLE_NIT ] = { dvb_table_nit_init,sizeof (struct dvb_table_nit ) }, - [DVB_TABLE_SDT ] = { dvb_table_sdt_init,sizeof (struct dvb_table_sdt ) }, - [DVB_TABLE_EIT ] = { dvb_table_eit_init,sizeof (struct dvb_table_eit ) }, - [DVB_TABLE_TVCT ] = { dvb_table_vct_init,sizeof (struct dvb_table_vct ) }, - [DVB_TABLE_CVCT ] = { dvb_table_vct_init,sizeof (struct dvb_table_vct ) }, + [DVB_TABLE_PAT ] = { dvb_table_pat_init,sizeof (struct dvb_table_pat ) }, + [DVB_TABLE_PMT ] = { dvb_table_pmt_init,sizeof (struct dvb_table_pmt ) }, + [DVB_TABLE_NIT ] = { dvb_table_nit_init,sizeof (struct dvb_table_nit ) }, + [DVB_TABLE_SDT ] = { dvb_table_sdt_init,sizeof (struct dvb_table_sdt ) }, + [DVB_TABLE_EIT ] = { dvb_table_eit_init,sizeof (struct dvb_table_eit ) }, [DVB_TABLE_EIT_SCHEDULE ] = { dvb_table_eit_init,sizeof (struct dvb_table_eit ) }, [ATSC_TABLE_MGT ] = { atsc_table_mgt_init,sizeof (struct atsc_table_mgt ) }, [ATSC_TABLE_EIT ] = { atsc_table_eit_init,sizeof (struct atsc_table_eit ) }, + [ATSC_TABLE_TVCT ] = { atsc_table_vct_init,sizeof (struct atsc_table_vct ) }, + [ATSC_TABLE_CVCT ] = { atsc_table_vct_init,sizeof (struct atsc_table_vct ) }, };char *default_charset ="iso-8859-1" ;
@@ -1359,6 +1359,6 @@ void hexdump(struct dvb_v5_fe_parms *parms, const char *prefix, const unsigned 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/vct.c +18 -19
@@ -23,14 +23,14 @@#include "dvb-fe.h" #include "parse_string.h" -void dvb_table_vct_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf, +void atsc_table_vct_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf,ssize_t buflen,uint8_t *table,ssize_t *table_length) {const uint8_t *p = buf, *endbuf = buf + buflen -4 ; -struct dvb_table_vct *vct = (void *)table; -struct dvb_table_vct_channel **head = &vct->channel; +struct atsc_table_vct *vct = (void *)table; +struct atsc_table_vct_channel **head = &vct->channel;int i, n; -size_t size = offsetof(struct dvb_table_vct , channel); +size_t size = offsetof(struct atsc_table_vct , channel);if (p + size > endbuf) { dvb_logerr("VCT table was truncated. Need %zu bytes, but has only %zu.",
@@ -45,16 +45,16 @@ void dvb_table_vct_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, }else {memcpy (vct, p, size); - *table_length =sizeof (struct dvb_table_vct ); + *table_length =sizeof (struct atsc_table_vct ); vct->channel =NULL ; vct->descriptor =NULL ; } p += size; - size = offsetof(struct dvb_table_vct_channel , descriptor); + size = offsetof(struct atsc_table_vct_channel , descriptor);for (n =0 ; n < vct->num_channels_in_section; n++) { -struct dvb_table_vct_channel *channel; +struct atsc_table_vct_channel *channel;if (p + size > endbuf) { dvb_logerr("VCT channel table is missing %d elements",
@@ -63,7 +63,7 @@ void dvb_table_vct_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,break ; } - channel =malloc (sizeof (struct dvb_table_vct_channel )); + channel =malloc (sizeof (struct atsc_table_vct_channel ));memcpy (channel, p, size); p += size;
@@ -104,9 +104,9 @@ void dvb_table_vct_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, }/* Get extra descriptors */ - size =sizeof (union dvb_table_vct_descriptor_length ); + size =sizeof (union atsc_table_vct_descriptor_length );while (p + size <= endbuf) { -union dvb_table_vct_descriptor_length *d = (void *)p; +union atsc_table_vct_descriptor_length *d = (void *)p;bswap16 (d->descriptor_length); p += size; dvb_parse_descriptors(parms, p, d->descriptor_length,
@@ -117,12 +117,12 @@ void dvb_table_vct_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, endbuf - p); } -void dvb_table_vct_free (struct dvb_table_vct *vct) +void atsc_table_vct_free (struct atsc_table_vct *vct) { -struct dvb_table_vct_channel *channel = vct->channel; +struct atsc_table_vct_channel *channel = vct->channel;while (channel) {dvb_free_descriptors ((struct dvb_desc **) &channel->descriptor); -struct dvb_table_vct_channel *tmp = channel; +struct atsc_table_vct_channel *tmp = channel; channel = channel->next;free (tmp); }
@@ -131,19 +131,19 @@ void dvb_table_vct_free(struct dvb_table_vct *vct)free (vct); } -void dvb_table_vct_print (struct dvb_v5_fe_parms *parms,struct dvb_table_vct *vct) +void atsc_table_vct_print (struct dvb_v5_fe_parms *parms,struct atsc_table_vct *vct) { -if (vct->header.table_id ==DVB_TABLE_CVCT ) +if (vct->header.table_id ==ATSC_TABLE_CVCT )dvb_log ("CVCT" );else dvb_log ("TVCT" ); -dvb_table_header_print (parms, &vct->header); +atsc_table_header_print (parms, &vct->header);dvb_log ("|- Protocol version %d" , vct->ATSC_protocol_version);dvb_log ("|- #channels %d" , vct->num_channels_in_section);dvb_log ("|\\ channel_id" ); -const struct dvb_table_vct_channel *channel = vct->channel; +const struct atsc_table_vct_channel *channel = vct->channel;uint16_t channels =0 ;while (channel) { dvb_log("|- Channel %d.%d: %s",
@@ -159,7 +159,7 @@ void dvb_table_vct_print(struct dvb_v5_fe_parms *parms, struct dvb_table_vct *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
PATCH 11/18 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
@@ -1359,6 +1359,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 11/18] libdvbv5: cleanup coding style
Em Mon, 30 Dec 2013 13:48:44 +0100
André Roth <[email protected]> escreveu:
Quoted 23 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@@ -1359,6 +1359,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 +0
-0
lib/libdvbv5/descriptors/mpeg_pes.c void dvb_mpeg_pes_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_ · line 39
Quoted 8 lines
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 ; }
Please merge this one with the patches that introduced the changes, if they weren't merged yet. The second hunk doesn't apply, as I requested changes on the patch that added the PES parser.
Signature · 2 lines
Cheers, Mauro
PATCH 12/18 libdvbv5: fix missing includes
In reply to André Roth--- lib/libdvbv5/dvb-file.c | 1 + lib/libdvbv5/dvb-sat.c | 3 ++- lib/libdvbv5/dvb-scan.c | 1 + lib/libdvbv5/parse_string.c | 1 + 4 files changed, 5 insertions(+), 1 deletion(-)
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 +2 -1
@@ -21,6 +21,7 @@#include <stdio.h> #include <stdlib.h> #include <unistd.h> +#include <strings.h> /* strcasecmp */ #include "dvb-fe.h" #include "dvb-v5-std.h"
@@ -302,7 +303,7 @@ static int dvbsat_diseqc_set_input(struct dvb_v5_fe_parms *parms, uint16_t t) rc =dvb_fe_sec_voltage (parms,1 , vol_high);if (rc)return rc; - +if (parms->sat_number >0 ) { rc =dvb_fe_sec_tone (parms,SEC_TONE_OFF );if (rc)
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
PATCH 13/18 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
@@ -38,7 +38,7 @@ struct dvb_mpeg_ts_adaption { uint8_t random_access:1; uint8_t discontinued:1; } __attribute__((packed)); - +uint8_t data[]; } __attribute__((packed));struct dvb_mpeg_ts {
@@ -67,7 +67,7 @@ struct dvb_v5_fe_parms;extern "C" {#endif -void dvb_mpeg_ts_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf,ssize_t buflen,uint8_t *table,ssize_t *table_length); +ssize_t dvb_mpeg_ts_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf,ssize_t buflen,uint8_t *table,ssize_t *table_length);void dvb_mpeg_ts_free (struct dvb_mpeg_ts *ts);void dvb_mpeg_ts_print (struct dvb_v5_fe_parms *parms,struct dvb_mpeg_ts *ts);
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/18] libdvbv5: improve TS parsing
Em Mon, 30 Dec 2013 13:48:46 +0100
André Roth <[email protected]> escreveu:
description?
Quoted 38 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@@ -38,7 +38,7 @@ struct dvb_mpeg_ts_adaption { uint8_t random_access:1; uint8_t discontinued:1; } __attribute__((packed)); - +uint8_t data[]; } __attribute__((packed));struct dvb_mpeg_ts {@@ -67,7 +67,7 @@ struct dvb_v5_fe_parms;extern "C" {#endif -void dvb_mpeg_ts_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf,ssize_t buflen,uint8_t *table,ssize_t *table_length); +ssize_t dvb_mpeg_ts_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf,ssize_t buflen,uint8_t *table,ssize_t *table_length);void dvb_mpeg_ts_free (struct dvb_mpeg_ts *ts);void dvb_mpeg_ts_print (struct dvb_v5_fe_parms *parms,struct dvb_mpeg_ts *ts);lib/libdvbv5/descriptors/mpeg_ts.c +1
-1@@ -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)
lib/libdvbv5/descriptors/mpeg_ts.c line 34
Quoted 10 lines
lib/libdvbv5/descriptors/mpeg_ts.c +2
-1{if (buf[0 ] !=DVB_MPEG_TS ) {dvb_logerr ("mpeg ts invalid marker %#02x, sould be %#02x" , buf[0 ],DVB_MPEG_TS ); *table_length =0 ; -return ; +return 0 ; } +ssize_t bytes_read =0 ;struct dvb_mpeg_ts *ts = (struct dvb_mpeg_ts *) table;const uint8_t *p = buf;
Please move declarations to the begining.
Quoted 4 lines
lib/libdvbv5/descriptors/mpeg_ts.c +1
-0memcpy (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 */
typo; length
lib/libdvbv5/descriptors/mpeg_ts.c line 53
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)
Doesn't apply yet. Please either merge with the original patch or resubmit on a next series.
Signature · 2 lines
Cheers, Mauro
PATCH 14/18 libdvbv5: cleanup dvb_nit_transport_foreach macro
In reply to André Roth--- lib/include/descriptors/nit.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/include/descriptors/nit.h +2 -2
@@ -76,8 +76,8 @@ typedef void nit_tran_handler_callback_t(struct dvb_table_nit *nit,struct dvb_desc *desc, void *priv); -#define dvb_nit_transport_foreach ( tran, nit ) \ - for (struct dvb_table_nit_transport *tran = nit->transport; tran; tran = tran->next) \ +#define dvb_nit_transport_foreach ( _tran, _nit ) \ + for (struct dvb_table_nit_transport *_tran = _nit->transport; _tran; _tran = _tran->next) \struct dvb_v5_fe_parms ;
Signature · 1 line
1.8.3.2
PATCH 15/18 libdvbv5: remove c99 comments
In reply to André Roth--- lib/libdvbv5/descriptors/atsc_eit.c | 2 +- lib/libdvbv5/descriptors/desc_service_list.c | 4 +++- lib/libdvbv5/descriptors/desc_service_location.c | 2 +- lib/libdvbv5/dvb-file.c | 21 +++++++++++---------- lib/libdvbv5/dvb-log.c | 2 +- lib/libdvbv5/dvb-sat.c | 2 -- lib/libdvbv5/dvb-scan.c | 4 ++-- 7 files changed, 19 insertions(+), 18 deletions(-)
lib/libdvbv5/descriptors/atsc_eit.c +1 -1
@@ -68,7 +68,7 @@ void atsc_table_eit_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssizatsc_time (event->start_time, &event->start); event->source_id = eit->header.id; -//FIXME: title +/* FIXME: title */ p += event->title_length -1 ;if (!*head)
lib/libdvbv5/descriptors/desc_service_list.c +3 -1
@@ -23,6 +23,8 @@#include "descriptors.h" #include "dvb-fe.h" +/* FIXME: implement */ +void dvb_desc_service_list_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf,struct dvb_desc *desc) {/*struct dvb_desc_service_list *slist = (struct dvb_desc_service_list *) desc;*/
@@ -38,7 +40,7 @@ void dvb_desc_service_list_init(struct dvb_v5_fe_parms *parms, const uint8_t *bu/*}*/ /*return sizeof(struct dvb_desc_service_list) + slist->length + sizeof(struct dvb_desc_service_list_table);*/ -//FIXME: make linked list +/* FIXME: make linked list */ }void dvb_desc_service_list_print (struct dvb_v5_fe_parms *parms,const struct dvb_desc *desc)
lib/libdvbv5/descriptors/desc_service_location.c +1 -1
@@ -36,7 +36,7 @@ void dvb_desc_service_location_init(struct dvb_v5_fe_parms *parms, const uint8_tbswap16 (service_location->bitfield); -// FIXME: handle elements == 0 +/* FIXME: handle elements == 0 */ service_location->element =malloc (service_location->elements *sizeof (struct dvb_desc_service_location_element ));int i;struct dvb_desc_service_location_element *element = service_location->element;
lib/libdvbv5/dvb-file.c +11 -10
@@ -784,20 +784,21 @@ static char *dvb_vchannel(struct dvb_table_nit *nit, uint16_t service_id)if (!nit)return NULL ; -for (struct dvb_desc_logical_channel *desc = (struct dvb_desc_logical_channel *) nit->descriptor; desc; desc = (struct dvb_desc_logical_channel *) desc->next ) \ +/* FIXME: use dvb_desc_find(struct dvb_desc_logical_channel, desc, nit, logical_channel_number_descriptor) { */ +for (struct dvb_desc_logical_channel *desc = (struct dvb_desc_logical_channel *) nit->descriptor; desc; desc = (struct dvb_desc_logical_channel *) desc->next ) {if (desc->type == logical_channel_number_descriptor) { -// dvb_desc_find(struct dvb_desc_logical_channel, desc, nit, logical_channel_number_descriptor) { -struct dvb_desc_logical_channel *d = (void *)desc; +struct dvb_desc_logical_channel *d = (void *)desc; -size_t len; +size_t len; - len = d->length /sizeof (d->lcn); + len = d->length /sizeof (d->lcn); -for (i =0 ; i < len; i++) { -if (service_id == d->lcn[i].service_id) { -asprintf (&buf,"%d.%d" , - d->lcn[i].logical_channel_number, i); -return buf; +for (i =0 ; i < len; i++) { +if (service_id == d->lcn[i].service_id) { +asprintf (&buf,"%d.%d" , + d->lcn[i].logical_channel_number, i); +return buf; + } } } }
lib/libdvbv5/dvb-log.c +1 -1
@@ -44,7 +44,7 @@ static const struct loglevel {void dvb_default_log (int level,const char *fmt, ...) { -if (level >sizeof (loglevels) /sizeof (struct loglevel ) -2 )// ignore LOG_COLOROFF as well +if (level >sizeof (loglevels) /sizeof (struct loglevel ) -2 )/* ignore LOG_COLOROFF as well */ level =LOG_INFO ;va_list ap;va_start (ap, fmt);
lib/libdvbv5/dvb-sat.c +0 -2
@@ -214,8 +214,6 @@ static void dvbsat_diseqc_prep_frame_addr(struct diseqc_cmd *cmd, cmd->address = diseqc_addr[type]; } -//struct dvb_v5_fe_parms *parms; // legacy code, used for parms->fd, FIXME anyway -/* Inputs are numbered from 1 to 16, according with the spec */ static int dvbsat_diseqc_write_to_port_group(struct dvb_v5_fe_parms *parms, struct diseqc_cmd *cmd, int high_band,
lib/libdvbv5/dvb-scan.c +2 -2
@@ -98,7 +98,7 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,uint8_t *tbl =NULL ;ssize_t table_length =0 ; -// handle sections +/* handle sections */ int start_id =-1 ;int start_section =-1 ;int first_section =-1 ;
@@ -112,7 +112,7 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,return -4 ; *table =NULL ; -// FIXME: verify known table +/* FIXME: verify known table */ memset (&f,0 ,sizeof (f)); f.pid = pid; f.filter.filter[0 ] = tid;
Signature · 1 line
1.8.3.2
Re: [PATCH 15/18] libdvbv5: remove c99 comments
Em Mon, 30 Dec 2013 13:48:48 +0100
André Roth <[email protected]> escreveu:
Quoted 135 lines
Signed-off-by André Roth <[email protected]>--- lib/libdvbv5/descriptors/atsc_eit.c | 2 +- lib/libdvbv5/descriptors/desc_service_list.c | 4 +++- lib/libdvbv5/descriptors/desc_service_location.c | 2 +- lib/libdvbv5/dvb-file.c | 21 +++++++++++---------- lib/libdvbv5/dvb-log.c | 2 +- lib/libdvbv5/dvb-sat.c | 2 -- lib/libdvbv5/dvb-scan.c | 4 ++-- 7 files changed, 19 insertions(+), 18 deletions(-)lib/libdvbv5/descriptors/atsc_eit.c +1
-1@@ -68,7 +68,7 @@ void atsc_table_eit_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssizatsc_time (event->start_time, &event->start); event->source_id = eit->header.id; -//FIXME: title +/* FIXME: title */ p += event->title_length -1 ;if (!*head)lib/libdvbv5/descriptors/desc_service_list.c +3
-1@@ -23,6 +23,8 @@#include "descriptors.h" #include "dvb-fe.h" +/* FIXME: implement */ +void dvb_desc_service_list_init (struct dvb_v5_fe_parms *parms,const uint8_t *buf,struct dvb_desc *desc) {/*struct dvb_desc_service_list *slist = (struct dvb_desc_service_list *) desc;*/ @@ -38,7 +40,7 @@ void dvb_desc_service_list_init(struct dvb_v5_fe_parms *parms, const uint8_t *bu/*}*/ /*return sizeof(struct dvb_desc_service_list) + slist->length + sizeof(struct dvb_desc_service_list_table);*/ -//FIXME: make linked list +/* FIXME: make linked list */ }void dvb_desc_service_list_print (struct dvb_v5_fe_parms *parms,const struct dvb_desc *desc)lib/libdvbv5/descriptors/desc_service_location.c +1
-1@@ -36,7 +36,7 @@ void dvb_desc_service_location_init(struct dvb_v5_fe_parms *parms, const uint8_tbswap16 (service_location->bitfield); -// FIXME: handle elements == 0 +/* FIXME: handle elements == 0 */ service_location->element =malloc (service_location->elements *sizeof (struct dvb_desc_service_location_element ));int i;struct dvb_desc_service_location_element *element = service_location->element;lib/libdvbv5/dvb-file.c +11
-10@@ -784,20 +784,21 @@ static char *dvb_vchannel(struct dvb_table_nit *nit, uint16_t service_id)if (!nit)return NULL ; -for (struct dvb_desc_logical_channel *desc = (struct dvb_desc_logical_channel *) nit->descriptor; desc; desc = (struct dvb_desc_logical_channel *) desc->next ) \ +/* FIXME: use dvb_desc_find(struct dvb_desc_logical_channel, desc, nit, logical_channel_number_descriptor) { */ +for (struct dvb_desc_logical_channel *desc = (struct dvb_desc_logical_channel *) nit->descriptor; desc; desc = (struct dvb_desc_logical_channel *) desc->next ) {if (desc->type == logical_channel_number_descriptor) { -// dvb_desc_find(struct dvb_desc_logical_channel, desc, nit, logical_channel_number_descriptor) { -struct dvb_desc_logical_channel *d = (void *)desc; +struct dvb_desc_logical_channel *d = (void *)desc; -size_t len; +size_t len; - len = d->length /sizeof (d->lcn); + len = d->length /sizeof (d->lcn); -for (i =0 ; i < len; i++) { -if (service_id == d->lcn[i].service_id) { -asprintf (&buf,"%d.%d" , - d->lcn[i].logical_channel_number, i); -return buf; +for (i =0 ; i < len; i++) { +if (service_id == d->lcn[i].service_id) { +asprintf (&buf,"%d.%d" , + d->lcn[i].logical_channel_number, i); +return buf; + } } } }lib/libdvbv5/dvb-log.c +1
-1@@ -44,7 +44,7 @@ static const struct loglevel {void dvb_default_log (int level,const char *fmt, ...) { -if (level >sizeof (loglevels) /sizeof (struct loglevel ) -2 )// ignore LOG_COLOROFF as well +if (level >sizeof (loglevels) /sizeof (struct loglevel ) -2 )/* ignore LOG_COLOROFF as well */ level =LOG_INFO ;va_list ap;va_start (ap, fmt);lib/libdvbv5/dvb-sat.c +0
-2@@ -214,8 +214,6 @@ static void dvbsat_diseqc_prep_frame_addr(struct diseqc_cmd *cmd, cmd->address = diseqc_addr[type]; } -//struct dvb_v5_fe_parms *parms; // legacy code, used for parms->fd, FIXME anyway -/* Inputs are numbered from 1 to 16, according with the spec */ static int dvbsat_diseqc_write_to_port_group(struct dvb_v5_fe_parms *parms, struct diseqc_cmd *cmd, int high_band,lib/libdvbv5/dvb-scan.c +1
-1@@ -98,7 +98,7 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,uint8_t *tbl =NULL ;ssize_t table_length =0 ; -// handle sections +/* handle sections */ int start_id =-1 ;int start_section =-1 ;int first_section =-1 ;
lib/libdvbv5/dvb-scan.c int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd, · line 118
Quoted 8 lines
lib/libdvbv5/dvb-scan.c +1
-1@@ -112,7 +112,7 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,return -4 ; *table =NULL ; -// FIXME: verify known table +/* FIXME: verify known table */ memset (&f,0 ,sizeof (f)); f.pid = pid; f.filter.filter[0 ] = tid;
Only partially applies (as some patches introducing those comments weren't applied).
Signature · 2 lines
Cheers, Mauro
PATCH 17/18 libdvbv5: remove header files from SOURCES in Makefile.am
In reply to André Roth--- lib/libdvbv5/Makefile.am | 87 ++++++++++++++++++++++++------------------------ 1 file changed, 43 insertions(+), 44 deletions(-)
lib/libdvbv5/Makefile.am +43 -44
@@ -52,52 +52,51 @@ noinst_LTLIBRARIES = libdvbv5.la endif libdvbv5_la_SOURCES = \ - crc32.c crc32.h \ - ../include/dvb-frontend.h \ + crc32.c \ dvb-legacy-channel-format.c \ dvb-zap-format.c \ - dvb-v5.c dvb-v5.h \ - parse_string.c parse_string.h \ - dvb-demux.c ../include/dvb-demux.h \ - dvb-fe.c ../include/dvb-fe.h \ - dvb-log.c ../include/dvb-log.h \ - dvb-file.c ../include/dvb-file.h \ - dvb-v5-std.c ../include/dvb-v5-std.h \ - dvb-sat.c ../include/dvb-sat.h \ - dvb-scan.c ../include/dvb-scan.h \ - descriptors.c ../include/descriptors.h \ - descriptors/header.c ../include/libdvbv5/header.h \ - descriptors/atsc_header.c ../include/libdvbv5/atsc_header.h \ - descriptors/pat.c ../include/libdvbv5/pat.h \ - descriptors/pmt.c ../include/libdvbv5/pmt.h \ - descriptors/nit.c ../include/libdvbv5/nit.h \ - descriptors/sdt.c ../include/libdvbv5/sdt.h \ - descriptors/vct.c ../include/libdvbv5/vct.h \ - descriptors/mgt.c ../include/libdvbv5/mgt.h \ - descriptors/eit.c ../include/libdvbv5/eit.h \ - descriptors/atsc_eit.c ../include/libdvbv5/atsc_eit.h \ - descriptors/desc_language.c ../include/libdvbv5/desc_language.h \ - descriptors/desc_network_name.c ../include/libdvbv5/desc_network_name.h \ - descriptors/desc_cable_delivery.c ../include/libdvbv5/desc_cable_delivery.h \ - descriptors/desc_sat.c ../include/libdvbv5/desc_sat.h \ - descriptors/desc_terrestrial_delivery.c ../include/libdvbv5/desc_terrestrial_delivery.h \ - descriptors/desc_t2_delivery.c ../include/libdvbv5/desc_t2_delivery.h \ - descriptors/desc_service.c ../include/libdvbv5/desc_service.h \ - descriptors/desc_frequency_list.c ../include/libdvbv5/desc_frequency_list.h \ - descriptors/desc_service_list.c ../include/libdvbv5/desc_service_list.h \ - descriptors/desc_event_short.c ../include/libdvbv5/desc_event_short.h \ - descriptors/desc_event_extended.c ../include/libdvbv5/desc_event_extended.h \ - descriptors/desc_atsc_service_location.c ../include/libdvbv5/desc_atsc_service_location.h \ - descriptors/desc_hierarchy.c ../include/libdvbv5/desc_hierarchy.h \ - descriptors/desc_extension.c ../include/libdvbv5/desc_extension.h \ - descriptors/desc_isdbt_delivery.c ../include/libdvbv5/desc_isdbt_delivery.h \ - descriptors/desc_logical_channel.c ../include/libdvbv5/desc_logical_channel.h \ - descriptors/desc_ts_info.c ../include/libdvbv5/desc_ts_info.h \ - descriptors/desc_partial_reception.c ../include/libdvbv5/desc_partial_reception.h \ - descriptors/desc_service_location.c ../include/libdvbv5/desc_service_location.h \ - descriptors/mpeg_ts.c ../include/libdvbv5/mpeg_ts.h \ - descriptors/mpeg_pes.c ../include/libdvbv5/mpeg_pes.h \ - descriptors/mpeg_es.c ../include/libdvbv5/mpeg_es.h + dvb-v5.c \ + parse_string.c \ + dvb-demux.c \ + dvb-fe.c \ + dvb-log.c \ + dvb-file.c \ + dvb-v5-std.c \ + dvb-sat.c \ + dvb-scan.c \ + descriptors.c \ + descriptors/header.c \ + descriptors/atsc_header.c \ + descriptors/pat.c \ + descriptors/pmt.c \ + descriptors/nit.c \ + descriptors/sdt.c \ + descriptors/vct.c \ + descriptors/mgt.c \ + descriptors/eit.c \ + descriptors/atsc_eit.c \ + descriptors/desc_language.c \ + descriptors/desc_network_name.c \ + descriptors/desc_cable_delivery.c \ + descriptors/desc_sat.c \ + descriptors/desc_terrestrial_delivery.c \ + descriptors/desc_t2_delivery.c \ + descriptors/desc_service.c \ + descriptors/desc_frequency_list.c \ + descriptors/desc_service_list.c \ + descriptors/desc_event_short.c \ + descriptors/desc_event_extended.c \ + descriptors/desc_atsc_service_location.c \ + descriptors/desc_hierarchy.c \ + descriptors/desc_extension.c \ + descriptors/desc_isdbt_delivery.c \ + descriptors/desc_logical_channel.c \ + descriptors/desc_ts_info.c \ + descriptors/desc_partial_reception.c \ + descriptors/desc_service_location.c \ + descriptors/mpeg_ts.c \ + descriptors/mpeg_pes.c \ + descriptors/mpeg_es.c libdvbv5_la_CPPFLAGS = -I../.. $(ENFORCE_LIBDVBV5_STATIC) libdvbv5_la_LDFLAGS = $(LIBDVBV5_VERSION) $(ENFORCE_LIBDVBV5_STATIC) -lm
Signature · 1 line
1.8.3.2
Re: [PATCH 17/18] libdvbv5: remove header files from SOURCES in Makefile.am
Em Mon, 30 Dec 2013 13:48:50 +0100
André Roth <[email protected]> escreveu:
description?
I'm not sure if this is ok. If you remove the headers, wouldn't it remove the C source dependencies from the .h headers?
Quoted 105 lines
Signed-off-by André Roth <[email protected]>--- lib/libdvbv5/Makefile.am | 87 ++++++++++++++++++++++++------------------------ 1 file changed, 43 insertions(+), 44 deletions(-)lib/libdvbv5/Makefile.am +43
-44@@ -52,52 +52,51 @@ noinst_LTLIBRARIES = libdvbv5.la endif libdvbv5_la_SOURCES = \ - crc32.c crc32.h \ - ../include/dvb-frontend.h \ + crc32.c \ dvb-legacy-channel-format.c \ dvb-zap-format.c \ - dvb-v5.c dvb-v5.h \ - parse_string.c parse_string.h \ - dvb-demux.c ../include/dvb-demux.h \ - dvb-fe.c ../include/dvb-fe.h \ - dvb-log.c ../include/dvb-log.h \ - dvb-file.c ../include/dvb-file.h \ - dvb-v5-std.c ../include/dvb-v5-std.h \ - dvb-sat.c ../include/dvb-sat.h \ - dvb-scan.c ../include/dvb-scan.h \ - descriptors.c ../include/descriptors.h \ - descriptors/header.c ../include/libdvbv5/header.h \ - descriptors/atsc_header.c ../include/libdvbv5/atsc_header.h \ - descriptors/pat.c ../include/libdvbv5/pat.h \ - descriptors/pmt.c ../include/libdvbv5/pmt.h \ - descriptors/nit.c ../include/libdvbv5/nit.h \ - descriptors/sdt.c ../include/libdvbv5/sdt.h \ - descriptors/vct.c ../include/libdvbv5/vct.h \ - descriptors/mgt.c ../include/libdvbv5/mgt.h \ - descriptors/eit.c ../include/libdvbv5/eit.h \ - descriptors/atsc_eit.c ../include/libdvbv5/atsc_eit.h \ - descriptors/desc_language.c ../include/libdvbv5/desc_language.h \ - descriptors/desc_network_name.c ../include/libdvbv5/desc_network_name.h \ - descriptors/desc_cable_delivery.c ../include/libdvbv5/desc_cable_delivery.h \ - descriptors/desc_sat.c ../include/libdvbv5/desc_sat.h \ - descriptors/desc_terrestrial_delivery.c ../include/libdvbv5/desc_terrestrial_delivery.h \ - descriptors/desc_t2_delivery.c ../include/libdvbv5/desc_t2_delivery.h \ - descriptors/desc_service.c ../include/libdvbv5/desc_service.h \ - descriptors/desc_frequency_list.c ../include/libdvbv5/desc_frequency_list.h \ - descriptors/desc_service_list.c ../include/libdvbv5/desc_service_list.h \ - descriptors/desc_event_short.c ../include/libdvbv5/desc_event_short.h \ - descriptors/desc_event_extended.c ../include/libdvbv5/desc_event_extended.h \ - descriptors/desc_atsc_service_location.c ../include/libdvbv5/desc_atsc_service_location.h \ - descriptors/desc_hierarchy.c ../include/libdvbv5/desc_hierarchy.h \ - descriptors/desc_extension.c ../include/libdvbv5/desc_extension.h \ - descriptors/desc_isdbt_delivery.c ../include/libdvbv5/desc_isdbt_delivery.h \ - descriptors/desc_logical_channel.c ../include/libdvbv5/desc_logical_channel.h \ - descriptors/desc_ts_info.c ../include/libdvbv5/desc_ts_info.h \ - descriptors/desc_partial_reception.c ../include/libdvbv5/desc_partial_reception.h \ - descriptors/desc_service_location.c ../include/libdvbv5/desc_service_location.h \ - descriptors/mpeg_ts.c ../include/libdvbv5/mpeg_ts.h \ - descriptors/mpeg_pes.c ../include/libdvbv5/mpeg_pes.h \ - descriptors/mpeg_es.c ../include/libdvbv5/mpeg_es.h + dvb-v5.c \ + parse_string.c \ + dvb-demux.c \ + dvb-fe.c \ + dvb-log.c \ + dvb-file.c \ + dvb-v5-std.c \ + dvb-sat.c \ + dvb-scan.c \ + descriptors.c \ + descriptors/header.c \ + descriptors/atsc_header.c \ + descriptors/pat.c \ + descriptors/pmt.c \ + descriptors/nit.c \ + descriptors/sdt.c \ + descriptors/vct.c \ + descriptors/mgt.c \ + descriptors/eit.c \ + descriptors/atsc_eit.c \ + descriptors/desc_language.c \ + descriptors/desc_network_name.c \ + descriptors/desc_cable_delivery.c \ + descriptors/desc_sat.c \ + descriptors/desc_terrestrial_delivery.c \ + descriptors/desc_t2_delivery.c \ + descriptors/desc_service.c \ + descriptors/desc_frequency_list.c \ + descriptors/desc_service_list.c \ + descriptors/desc_event_short.c \ + descriptors/desc_event_extended.c \ + descriptors/desc_atsc_service_location.c \ + descriptors/desc_hierarchy.c \ + descriptors/desc_extension.c \ + descriptors/desc_isdbt_delivery.c \ + descriptors/desc_logical_channel.c \ + descriptors/desc_ts_info.c \ + descriptors/desc_partial_reception.c \ + descriptors/desc_service_location.c \ + descriptors/mpeg_ts.c \ + descriptors/mpeg_pes.c \ + descriptors/mpeg_es.c libdvbv5_la_CPPFLAGS = -I../.. $(ENFORCE_LIBDVBV5_STATIC) libdvbv5_la_LDFLAGS = $(LIBDVBV5_VERSION) $(ENFORCE_LIBDVBV5_STATIC) -lm
Signature · 2 lines
Cheers, Mauro
PATCH 18/18 libdvbv5: README updated for shared libdvbv5
In reply to André Roth--- README | 8 ++++---- README.libv4l | 12 ++++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-)
README +4 -4
@@ -3,13 +3,13 @@ v4l-utils Linux V4L2 and DVB API utilities and v4l libraries (libv4l). You can always find the latest development v4l-utils in the git repo: -http://git.linuxtv.org/v4l-utils.git +http://git.linuxtv.org/v4l-utils.git -v4l libraries (libv4l) ----------------------- +v4l libraries (libv4l, libdvbv5) +-------------------------------- -See README.lib for more information on libv4l, libv4l is released +See README.libv4l for more information on libv4l, libv4l is released under the GNU Lesser General Public License.
README.libv4l +12 -0
@@ -59,6 +59,18 @@ hardware can _really_ do it should use ENUM_FMT, not randomly try a bunch of S_FMT's). For more details on the v4l2_ functions see libv4l2.h . +libdvbv5 +-------- + +This library provides the DVBv5 API to userspace programs. It can be used to +open DVB adapters, tune transponders and read PES and other data streams. +There are as well several parsers for DVB, ATSC, ISBT formats. + +The API is currently EXPERIMENTAL and likely to change. +Run configure with --enable-libdvbv5 in order to build a shared lib and +install the header files. + + wrappers --------
Signature · 1 line
1.8.3.2
Re: [PATCH 18/18] libdvbv5: README updated for shared libdvbv5
Em Mon, 30 Dec 2013 13:48:51 +0100
André Roth <[email protected]> escreveu:
Quoted 12 lines
Signed-off-by André Roth <[email protected]>--- README | 8 ++++---- README.libv4l | 12 ++++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-)README +0
-0@@ -3,13 +3,13 @@ v4l-utils
README v4l-utils · line 10
Quoted 10 lines
README +3
-3Linux V4L2 and DVB API utilities and v4l libraries (libv4l). You can always find the latest development v4l-utils in the git repo: -http://git.linuxtv.org/v4l-utils.git +http://git.linuxtv.org/v4l-utils.git -v4l libraries (libv4l) ----------------------- +v4l libraries (libv4l, libdvbv5) +--------------------------------
No, libdvbv5 is not a V4L library. It is a DVB one.
Quoted 14 lines
README +1
-1-See README.lib for more information on libv4l, libv4l is released +See README.libv4l for more information on libv4l, libv4l is released under the GNU Lesser General Public License.README.libv4l +0
-0@@ -59,6 +59,18 @@ hardware can _really_ do it should use ENUM_FMT, not randomly try a bunch of S_FMT's). For more details on the v4l2_ functions see libv4l2.h .
README.libv4l hardware can _really_ do it should use ENUM_FMT, not randomly try a bunch of · line 71
Quoted 10 lines
README.libv4l +10
-0+libdvbv5 +-------- + +This library provides the DVBv5 API to userspace programs. It can be used to +open DVB adapters, tune transponders and read PES and other data streams. +There are as well several parsers for DVB, ATSC, ISBT formats. + +The API is currently EXPERIMENTAL and likely to change. +Run configure with --enable-libdvbv5 in order to build a shared lib and +install the header files.
Seem OK to me, provided that this patch comes after or together one that adds --enable-libdvbv5 to the autotools config files.
Quoted 5 lines
README.libv4l +2
-0+ + wrappers --------
Signature · 2 lines
Cheers, Mauro
Em Mon, 30 Dec 2013 13:48:34 +0100
André Roth <[email protected]> escreveu:
description?
What bug are you trying to fix?
Quoted 10 lines
Signed-off-by André Roth <[email protected]>--- lib/libdvbv5/dvb-scan.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-)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 100
Quoted 5 lines
lib/libdvbv5/dvb-scan.c +2
-0@@ -96,9 +96,13 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,uint8_t *buf =NULL ;uint8_t *tbl =NULL ;ssize_t table_length =0 ; + +// handle sections
No C99 comments.
lib/libdvbv5/dvb-scan.c int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd, · line 105
Quoted 6 lines
lib/libdvbv5/dvb-scan.c +3
-1+int start_id =-1 ; +int start_section =-1 ;int first_section =-1 ;int last_section =-1 ; -int table_id =-1 ; +/*int table_id = -1;*/
Why to comment? If it is buggy, just remove it.
Quoted 13 lines
lib/libdvbv5/dvb-scan.c +0
-1int sections =0 ;struct dmx_sct_filter_params f;struct dvb_table_header *h;@@ -108,7 +112,6 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd, *table =NULL ;// FIXME: verify known table -memset (&f,0 ,sizeof (f)); f.pid = pid; f.filter.filter[0 ] = tid;@@ -185,24 +188,27 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,
lib/libdvbv5/dvb-scan.c int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd, · line 198
Quoted 10 lines
lib/libdvbv5/dvb-scan.c +8
-0h = (struct dvb_table_header *)buf;dvb_table_header_init (h); + +/* dvb_logdbg( "dvb_read_section: id %d, section %d/%d, current: %d", h->id, h->section_id, h->last_section, h->current_next ); */ +if (start_id == h->id && start_section == h->section_id) { +dvb_logdbg ("dvb_read_section: section repeated, reading done" ); +break ; + } +if (start_id ==-1 ) start_id = h->id; +if (start_section ==-1 ) start_section = h->section_id;
One statement per line, please.
lib/libdvbv5/dvb-scan.c int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd, · line 204
Quoted 13 lines
lib/libdvbv5/dvb-scan.c +2
-7+if (id !=-1 && h->id != id) {/* search for a specific table id */ continue ; - }else { -if (table_id ==-1 ) - table_id = h->id; -else if (h->id != table_id) { -dvb_logwarn ("dvb_read_section: table ID mismatch reading multi section table: %d != %d" , h->id, table_id); -continue ; - } } +/*dvb_logerr("dvb_read_section: got section %d, last %d, filter %d", h->section_id, h->last_section, id );*/
Why are you adding a commented line?
Quoted 16 lines
lib/libdvbv5/dvb-scan.c +2
-2/* handle the sections */ if (first_section ==-1 ) first_section = h->section_id; -else if (h->section_id == first_section) +else if (start_id == h->id && h->section_id == first_section)break ; -if (last_section ==-1 ) +if (last_section ==-1 || h->last_section > last_section) last_section = h->last_section;if (!tbl) {@@ -228,10 +234,14 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,else dvb_logerr ("dvb_read_section: no initializer for table %d" , tid);
lib/libdvbv5/dvb-scan.c int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd, · line 244
Quoted 10 lines
lib/libdvbv5/dvb-scan.c +6
-2-if (++sections == last_section +1 ) +if (id !=-1 && ++sections == last_section +1 ) { +dvb_logerr ("dvb_read_section: ++sections == last_section + 1" );break ; + } } -free (buf); + +if (buf) +free (buf);
Buffer is always allocated at this point. No need to test before free.
Quoted 3 lines
lib/libdvbv5/dvb-scan.c +0
-0dvb_dmx_stop (dmx_fd);
Signature · 2 lines
Cheers, Mauro