Skip to contentSkip to conversation

libdvbv5: Fix dvb-file USER CMD

PATCH New André Roth 1 participant 5 messages Jul 6, 2012 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 libdvbv5: Fix dvb-file USER CMD

---
 lib/libdvbv5/dvb-file.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
lib/libdvbv5/dvb-file.c +2 -2
index 5ab0d97..ea9caa0 100644
@@ -387,7 +387,7 @@ static int fill_entry(struct dvb_entry *entry, char *key, char *value)
 			break;
 	}
 	if (i < ARRAY_SIZE(dvb_v5_name)) {
-		const char * const *attr_name = dvb_v5_attr_names[i];
+		const char * const *attr_name = dvb_attr_names(i);
 		n_prop = entry->n_props;
 		entry->props[n_prop].cmd = i;
 		if (!attr_name || !*attr_name)
@@ -412,7 +412,7 @@ static int fill_entry(struct dvb_entry *entry, char *key, char *value)
 			break;
 	}
 	if (i < ARRAY_SIZE(dvb_user_name)) {
-		const char * const *attr_name = dvb_user_attr_names[i];
+		const char * const *attr_name = dvb_attr_names(i);
 		n_prop = entry->n_props;
 		entry->props[n_prop].cmd = i + DTV_USER_COMMAND_START;
 		if (!attr_name || !*attr_name)
Signature · 1 line
1.7.2.5
#1 lore raw

PATCH 2/5 libdvbv5: Fix set delsys other than current

---
 lib/libdvbv5/dvb-fe.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
lib/libdvbv5/dvb-fe.c +1 -1
index 4fb927a..9b18226 100644
@@ -392,8 +392,8 @@ int dvb_set_compat_delivery_system(struct dvb_v5_fe_parms *parms,
 	for (i = 0; i < parms->num_systems; i++) {
 		if (parms->systems[i] == desired_system) {
 			dvb_set_sys(parms, desired_system);
+			return 0;
 		}
-		return 0;
 	}
 
 	/*
Signature · 1 line
1.7.2.5
#2 lore raw

PATCH 3/5 libdvbv5: New DVB table parsing

In reply to André Roth
---
 lib/include/descriptors.h                          |  393 ++++++++
 lib/include/descriptors/desc_cable_delivery.h      |   64 ++
 lib/include/descriptors/desc_frequency_list.h      |   57 ++
 lib/include/descriptors/desc_language.h            |   50 +
 lib/include/descriptors/desc_network_name.h        |   49 +
 lib/include/descriptors/desc_sat.h                 |   62 ++
 lib/include/descriptors/desc_service.h             |   51 ++
 lib/include/descriptors/desc_service_list.h        |   54 ++
 .../descriptors/desc_terrestrial_delivery.h        |   62 ++
 lib/include/descriptors/header.h                   |   62 ++
 lib/include/descriptors/nit.h                      |   86 ++
 lib/include/descriptors/pat.h                      |   63 ++
 lib/include/descriptors/pmt.h                      |   90 ++
 lib/include/descriptors/sdt.h                      |   74 ++
 lib/include/dvb-demux.h                            |   11 +
 lib/include/dvb-fe.h                               |   32 +-
 lib/include/dvb-file.h                             |    6 +-
 lib/include/dvb-log.h                              |   49 +
 lib/include/dvb-scan.h                             |  120 +---
 lib/libdvbv5/Makefile.am                           |   20 +-
 lib/libdvbv5/crc32.c                               |   76 ++
 lib/libdvbv5/crc32.h                               |   31 +
 lib/libdvbv5/descriptors.c                         |  946 +++++++++++---------
 lib/libdvbv5/descriptors.h                         |  214 -----
 lib/libdvbv5/descriptors/desc_cable_delivery.c     |   53 ++
 lib/libdvbv5/descriptors/desc_frequency_list.c     |   63 ++
 lib/libdvbv5/descriptors/desc_language.c           |   44 +
 lib/libdvbv5/descriptors/desc_network_name.c       |   41 +
 lib/libdvbv5/descriptors/desc_sat.c                |   69 ++
 lib/libdvbv5/descriptors/desc_service.c            |   56 ++
 lib/libdvbv5/descriptors/desc_service_list.c       |   53 ++
 .../descriptors/desc_terrestrial_delivery.c        |   57 ++
 lib/libdvbv5/descriptors/header.c                  |   48 +
 lib/libdvbv5/descriptors/nit.c                     |  100 ++
 lib/libdvbv5/descriptors/pat.c                     |   57 ++
 lib/libdvbv5/descriptors/pmt.c                     |  103 +++
 lib/libdvbv5/descriptors/sdt.c                     |   88 ++
 lib/libdvbv5/dvb-demux.c                           |   18 +-
 lib/libdvbv5/dvb-fe.c                              |   54 +-
 lib/libdvbv5/dvb-file.c                            |   10 +-
 lib/libdvbv5/dvb-log.c                             |   63 ++
 lib/libdvbv5/dvb-scan.c                            |  328 ++++---
 utils/dvb/dvb-fe-tool.c                            |    2 +-
 utils/dvb/dvbv5-scan.c                             |    8 +-
 utils/v4l2-compliance/v4l2-test-formats.cpp        |   10 +-
 45 files changed, 3057 insertions(+), 990 deletions(-)
 create mode 100644 lib/include/descriptors.h
 create mode 100644 lib/include/descriptors/desc_cable_delivery.h
 create mode 100644 lib/include/descriptors/desc_frequency_list.h
 create mode 100644 lib/include/descriptors/desc_language.h
 create mode 100644 lib/include/descriptors/desc_network_name.h
 create mode 100644 lib/include/descriptors/desc_sat.h
 create mode 100644 lib/include/descriptors/desc_service.h
 create mode 100644 lib/include/descriptors/desc_service_list.h
 create mode 100644 lib/include/descriptors/desc_terrestrial_delivery.h
 create mode 100644 lib/include/descriptors/header.h
 create mode 100644 lib/include/descriptors/nit.h
 create mode 100644 lib/include/descriptors/pat.h
 create mode 100644 lib/include/descriptors/pmt.h
 create mode 100644 lib/include/descriptors/sdt.h
 create mode 100644 lib/include/dvb-log.h
 create mode 100644 lib/libdvbv5/crc32.c
 create mode 100644 lib/libdvbv5/crc32.h
 delete mode 100644 lib/libdvbv5/descriptors.h
 create mode 100644 lib/libdvbv5/descriptors/desc_cable_delivery.c
 create mode 100644 lib/libdvbv5/descriptors/desc_frequency_list.c
 create mode 100644 lib/libdvbv5/descriptors/desc_language.c
 create mode 100644 lib/libdvbv5/descriptors/desc_network_name.c
 create mode 100644 lib/libdvbv5/descriptors/desc_sat.c
 create mode 100644 lib/libdvbv5/descriptors/desc_service.c
 create mode 100644 lib/libdvbv5/descriptors/desc_service_list.c
 create mode 100644 lib/libdvbv5/descriptors/desc_terrestrial_delivery.c
 create mode 100644 lib/libdvbv5/descriptors/header.c
 create mode 100644 lib/libdvbv5/descriptors/nit.c
 create mode 100644 lib/libdvbv5/descriptors/pat.c
 create mode 100644 lib/libdvbv5/descriptors/pmt.c
 create mode 100644 lib/libdvbv5/descriptors/sdt.c
 create mode 100644 lib/libdvbv5/dvb-log.c
lib/include/descriptors.h new file +393 -0
new file mode 100644
index 0000000..8ecb13d
@@ -0,0 +1,393 @@
+  /*
+ * Copyright (c) 2011-2012 - Mauro Carvalho Chehab <[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
+ */
+
+/*
+ * Descriptors, as defined on ETSI EN 300 468 V1.11.1 (2010-04)
+ */
+
+
+#ifndef _DESCRIPTORS_H
+#define _DESCRIPTORS_H
+
+#include <endian.h>
+#include <unistd.h>
+#include <stdint.h>
+
+#define DVB_MAX_PAYLOAD_PACKET_SIZE 4096
+#define DVB_PID_SDT      17
+#define DVB_PMT_TABLE_ID 2
+
+struct dvb_v5_fe_parms;
+
+typedef void *(*dvb_table_init_func)(struct dvb_v5_fe_parms *parms, const uint8_t *ptr, ssize_t size);
+
+struct dvb_table_init {
+	dvb_table_init_func init;
+};
+
+extern const struct dvb_table_init dvb_table_initializers[];
+
+#define bswap16(b) do {\
+	b = be16toh(b); \
+} while (0)
+
+#define bswap32(b) do {\
+	b = be32toh(b); \
+} while (0)
+
+struct dvb_desc {
+	uint8_t type;
+	struct dvb_desc *next;
+	uint8_t length;
+	uint8_t data[];
+} __attribute__((packed));
+
+#define dvb_desc_foreach( _desc, _tbl ) \
+	for( struct dvb_desc *_desc = _tbl->descriptor; _desc; _desc = _desc->next ) \
+
+#define dvb_desc_find(_struct, _desc, _tbl, _type) \
+	for( _struct *_desc = (_struct *) _tbl->descriptor; _desc; _desc = (_struct *) _desc->next ) \
+		if(_desc->type == _type) \
+
+ssize_t dvb_desc_init(const uint8_t *buf, struct dvb_desc *desc);
+
+uint32_t bcd(uint32_t bcd);
+
+ssize_t dvb_parse_descriptors(struct dvb_v5_fe_parms *parms, const uint8_t *buf, uint8_t *dest, uint16_t section_length, struct dvb_desc **head_desc);
+
+struct dvb_v5_fe_parms;
+
+typedef ssize_t (*dvb_desc_init_func)(struct dvb_v5_fe_parms *parms, const uint8_t *buf, struct dvb_desc *desc);
+typedef void (*dvb_desc_print_func)(struct dvb_v5_fe_parms *parms, const struct dvb_desc *desc);
+
+struct dvb_descriptor {
+	const char *name;
+	dvb_desc_init_func init;
+	dvb_desc_print_func print;
+	ssize_t desc_size;
+};
+
+extern const struct dvb_descriptor dvb_descriptors[];
+
+enum dvb_tables {
+	PAT,
+	PMT,
+	NIT,
+	SDT,
+};
+
+enum descriptors {
+	/* ISO/IEC 13818-1 */
+	video_stream_descriptor				= 0x02,
+	audio_stream_descriptor				= 0x03,
+	hierarchy_descriptor				= 0x04,
+	dvbpsi_registration_descriptor			= 0x05,
+	ds_alignment_descriptor				= 0x06,
+	target_background_grid_descriptor		= 0x07,
+	video_window_descriptor				= 0x08,
+	conditional_access_descriptor			= 0x09,
+	iso639_language_descriptor			= 0x0a,
+	system_clock_descriptor				= 0x0b,
+	multiplex_buffer_utilization_descriptor		= 0x0c,
+	copyright_descriptor				= 0x0d,
+	maximum_bitrate_descriptor			= 0x0e,
+	private_data_indicator_descriptor		= 0x0f,
+	smoothing_buffer_descriptor			= 0x10,
+	std_descriptor					= 0x11,
+	ibp_descriptor					= 0x12,
+
+	mpeg4_video_descriptor				= 0x1b,
+	mpeg4_audio_descriptor				= 0x1c,
+	iod_descriptor					= 0x1d,
+	sl_descriptor					= 0x1e,
+	fmc_descriptor					= 0x1f,
+	external_es_id_descriptor			= 0x20,
+	muxcode_descriptor				= 0x21,
+	fmxbuffersize_descriptor			= 0x22,
+	multiplexbuffer_descriptor			= 0x23,
+	content_labeling_descriptor			= 0x24,
+	metadata_pointer_descriptor			= 0x25,
+	metadata_descriptor				= 0x26,
+	metadata_std_descriptor				= 0x27,
+	AVC_video_descriptor				= 0x28,
+	ipmp_descriptor					= 0x29,
+	AVC_timing_and_HRD_descriptor			= 0x2a,
+	mpeg2_aac_audio_descriptor			= 0x2b,
+	flexmux_timing_descriptor			= 0x2c,
+
+	/* ETSI EN 300 468 V1.11.1 (2010-04) */
+
+	network_name_descriptor				= 0x40,
+	service_list_descriptor				= 0x41,
+	stuffing_descriptor				= 0x42,
+	satellite_delivery_system_descriptor		= 0x43,
+	cable_delivery_system_descriptor		= 0x44,
+	VBI_data_descriptor				= 0x45,
+	VBI_teletext_descriptor				= 0x46,
+	bouquet_name_descriptor				= 0x47,
+	service_descriptor				= 0x48,
+	country_availability_descriptor			= 0x49,
+	linkage_descriptor				= 0x4a,
+	NVOD_reference_descriptor			= 0x4b,
+	time_shifted_service_descriptor			= 0x4c,
+	short_event_descriptor				= 0x4d,
+	extended_event_descriptor			= 0x4e,
+	time_shifted_event_descriptor			= 0x4f,
+	component_descriptor				= 0x50,
+	mosaic_descriptor				= 0x51,
+	stream_identifier_descriptor			= 0x52,
+	CA_identifier_descriptor			= 0x53,
+	content_descriptor				= 0x54,
+	parental_rating_descriptor			= 0x55,
+	teletext_descriptor				= 0x56,
+	telephone_descriptor				= 0x57,
+	local_time_offset_descriptor			= 0x58,
+	subtitling_descriptor				= 0x59,
+	terrestrial_delivery_system_descriptor		= 0x5a,
+	multilingual_network_name_descriptor		= 0x5b,
+	multilingual_bouquet_name_descriptor		= 0x5c,
+	multilingual_service_name_descriptor		= 0x5d,
+	multilingual_component_descriptor		= 0x5e,
+	private_data_specifier_descriptor		= 0x5f,
+	service_move_descriptor				= 0x60,
+	short_smoothing_buffer_descriptor		= 0x61,
+	frequency_list_descriptor			= 0x62,
+	partial_transport_stream_descriptor		= 0x63,
+	data_broadcast_descriptor			= 0x64,
+	scrambling_descriptor				= 0x65,
+	data_broadcast_id_descriptor			= 0x66,
+	transport_stream_descriptor			= 0x67,
+	DSNG_descriptor					= 0x68,
+	PDC_descriptor					= 0x69,
+	AC_3_descriptor					= 0x6a,
+	ancillary_data_descriptor			= 0x6b,
+	cell_list_descriptor				= 0x6c,
+	cell_frequency_link_descriptor			= 0x6d,
+	announcement_support_descriptor			= 0x6e,
+	application_signalling_descriptor		= 0x6f,
+	adaptation_field_data_descriptor		= 0x70,
+	service_identifier_descriptor			= 0x71,
+	service_availability_descriptor			= 0x72,
+	default_authority_descriptor			= 0x73,
+	related_content_descriptor			= 0x74,
+	TVA_id_descriptor				= 0x75,
+	content_identifier_descriptor			= 0x76,
+	time_slice_fec_identifier_descriptor		= 0x77,
+	ECM_repetition_rate_descriptor			= 0x78,
+	S2_satellite_delivery_system_descriptor		= 0x79,
+	enhanced_AC_3_descriptor			= 0x7a,
+	DTS_descriptor					= 0x7b,
+	AAC_descriptor					= 0x7c,
+	XAIT_location_descriptor			= 0x7d,
+	FTA_content_management_descriptor		= 0x7e,
+	extension_descriptor				= 0x7f,
+
+	/* SCTE 35 2004 */
+	CUE_identifier_descriptor			= 0x8a,
+
+	/* From http://www.etherguidesystems.com/Help/SDOs/ATSC/Semantics/Descriptors/Default.aspx */
+	component_name_descriptor			= 0xa3,
+
+	/* From http://www.coolstf.com/tsreader/descriptors.html */
+	logical_channel_number_descriptor		= 0x83,
+
+	/* ISDB Descriptors, as defined on ABNT NBR 15603-1 2007 */
+
+	carousel_id_descriptor				= 0x13,
+	association_tag_descriptor			= 0x14,
+	deferred_association_tags_descriptor		= 0x15,
+
+	hierarchical_transmission_descriptor		= 0xc0,
+	digital_copy_control_descriptor			= 0xc1,
+	network_identifier_descriptor			= 0xc2,
+	partial_transport_stream_time_descriptor	= 0xc3,
+	audio_component_descriptor			= 0xc4,
+	hyperlink_descriptor				= 0xc5,
+	target_area_descriptor				= 0xc6,
+	data_contents_descriptor			= 0xc7,
+	video_decode_control_descriptor			= 0xc8,
+	download_content_descriptor			= 0xc9,
+	CA_EMM_TS_descriptor				= 0xca,
+	CA_contract_information_descriptor		= 0xcb,
+	CA_service_descriptor				= 0xcc,
+	TS_Information_descriptior			= 0xcd,
+	extended_broadcaster_descriptor			= 0xce,
+	logo_transmission_descriptor			= 0xcf,
+	basic_local_event_descriptor			= 0xd0,
+	reference_descriptor				= 0xd1,
+	node_relation_descriptor			= 0xd2,
+	short_node_information_descriptor		= 0xd3,
+	STC_reference_descriptor			= 0xd4,
+	series_descriptor				= 0xd5,
+	event_group_descriptor				= 0xd6,
+	SI_parameter_descriptor				= 0xd7,
+	broadcaster_Name_Descriptor			= 0xd8,
+	component_group_descriptor			= 0xd9,
+	SI_prime_TS_descriptor				= 0xda,
+	board_information_descriptor			= 0xdb,
+	LDT_linkage_descriptor				= 0xdc,
+	connected_transmission_descriptor		= 0xdd,
+	content_availability_descriptor			= 0xde,
+	service_group_descriptor			= 0xe0,
+	carousel_compatible_composite_Descriptor	= 0xf7,
+	conditional_playback_descriptor			= 0xf8,
+	ISDBT_delivery_system_descriptor		= 0xfa,
+	partial_reception_descriptor			= 0xfb,
+	emergency_information_descriptor		= 0xfc,
+	data_component_descriptor			= 0xfd,
+	system_management_descriptor			= 0xfe,
+};
+
+
+enum extension_descriptors {
+	image_icon_descriptor				= 0x00,
+	cpcm_delivery_signalling_descriptor		= 0x01,
+	CP_descriptor					= 0x02,
+	CP_identifier_descriptor			= 0x03,
+	T2_delivery_system_descriptor			= 0x04,
+	SH_delivery_system_descriptor			= 0x05,
+	supplementary_audio_descriptor			= 0x06,
+	network_change_notify_descriptor		= 0x07,
+	message_descriptor				= 0x08,
+	target_region_descriptor			= 0x09,
+	target_region_name_descriptor			= 0x0a,
+	service_relocated_descriptor			= 0x0b,
+};
+
+struct pmt_table {
+	uint16_t program_number, pcr_pid;
+	unsigned char version;
+};
+
+struct el_pid {
+	uint8_t  type;
+	uint16_t pid;
+};
+
+struct pid_table {
+	uint16_t service_id;
+	uint16_t pid;
+	struct pmt_table pmt_table;
+	unsigned video_pid_len, audio_pid_len, other_el_pid_len;
+	uint16_t *video_pid;
+	uint16_t *audio_pid;
+	struct el_pid *other_el_pid;
+};
+
+struct pat_table {
+	uint16_t  ts_id;
+	unsigned char version;
+	struct pid_table *pid_table;
+	unsigned pid_table_len;
+};
+
+struct transport_table {
+	uint16_t tr_id;
+};
+
+struct lcn_table {
+	uint16_t service_id;
+	uint16_t lcn;
+};
+
+struct nit_table {
+	uint16_t network_id;
+	unsigned char version;
+	char *network_name, *network_alias;
+	struct transport_table *tr_table;
+	unsigned tr_table_len;
+	unsigned virtual_channel;
+	unsigned area_code;
+
+	/* Network Parameters */
+	uint32_t delivery_system;
+	uint32_t guard_interval;
+	uint32_t fec_inner, fec_outer;
+	uint32_t pol;
+	uint32_t modulation;
+	uint32_t rolloff;
+	uint32_t symbol_rate;
+	uint32_t bandwidth;
+	uint32_t code_rate_hp;
+	uint32_t code_rate_lp;
+	uint32_t transmission_mode;
+	uint32_t hierarchy;
+	uint32_t plp_id;
+	uint32_t system_id;
+
+	unsigned has_dvbt:1;
+	unsigned is_hp:1;
+	unsigned has_time_slicing:1;
+	unsigned has_mpe_fec:1;
+	unsigned has_other_frequency:1;
+	unsigned is_in_depth_interleaver:1;
+
+	char *orbit;
+	uint32_t *frequency;
+	unsigned frequency_len;
+
+	uint32_t *other_frequency;
+	unsigned other_frequency_len;
+
+	uint16_t *partial_reception;
+	unsigned partial_reception_len;
+
+	struct lcn_table *lcn;
+	unsigned lcn_len;
+};
+
+struct service_table {
+	uint16_t service_id;
+	char running;
+	char scrambled;
+	unsigned char type;
+	char *service_name, *service_alias;
+	char *provider_name, *provider_alias;
+};
+
+struct sdt_table {
+	unsigned char version;
+	uint16_t ts_id;
+	struct service_table *service_table;
+	unsigned service_table_len;
+};
+struct dvb_v5_descriptors {
+	int verbose;
+	uint32_t delivery_system;
+
+	struct pat_table pat_table;
+	struct nit_table nit_table;
+	struct sdt_table sdt_table;
+
+	/* Used by descriptors to know where to update a PMT/Service/TS */
+	unsigned cur_pmt;
+	unsigned cur_service;
+	unsigned cur_ts;
+};
+
+void parse_descriptor(enum dvb_tables type,
+		struct dvb_v5_descriptors *dvb_desc,
+		const unsigned char *buf, int len);
+
+int has_descriptor(struct dvb_v5_descriptors *dvb_desc,
+		unsigned char needed_descriptor,
+		const unsigned char *buf, int len);
+
+
+#endif
lib/include/descriptors/desc_cable_delivery.h new file +64 -0

64 lines not on this page · raw message

lib/include/descriptors/desc_frequency_list.h new file +57 -0

57 lines not on this page · raw message

lib/include/descriptors/desc_language.h new file +50 -0

50 lines not on this page · raw message

lib/include/descriptors/desc_network_name.h new file +49 -0

49 lines not on this page · raw message

lib/include/descriptors/desc_sat.h new file +62 -0

62 lines not on this page · raw message

lib/include/descriptors/desc_service.h new file +51 -0

51 lines not on this page · raw message

lib/include/descriptors/desc_service_list.h new file +54 -0

54 lines not on this page · raw message

lib/include/descriptors/desc_terrestrial_delivery.h new file +62 -0

62 lines not on this page · raw message

lib/include/descriptors/header.h new file +62 -0

62 lines not on this page · raw message

lib/include/descriptors/nit.h new file +86 -0

86 lines not on this page · raw message

lib/include/descriptors/pat.h new file +63 -0

63 lines not on this page · raw message

lib/include/descriptors/pmt.h new file +90 -0

90 lines not on this page · raw message

lib/include/descriptors/sdt.h new file +74 -0

74 lines not on this page · raw message

lib/include/dvb-demux.h +11 -0
index ec50d6b..240d471 100644
@@ -29,8 +29,19 @@
 #ifndef _DVB_DEMUX_H
 #define _DVB_DEMUX_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int dvb_dmx_open(int adapter, int demux, unsigned verbose);
+void dvb_dmx_close(int dmx_fd);
+
 int set_pesfilter(int dmxfd, int pid, int pes_type, int dvr);
 
 int get_pmt_pid(const char *dmxdev, int sid);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
lib/include/dvb-fe.h +17 -15
index 939260f..a91a627 100644
@@ -29,20 +29,9 @@
 #include <fcntl.h>
 #include <sys/ioctl.h>
 #include <string.h>
-#include <syslog.h>
 #include "dvb-frontend.h"
 #include "dvb-sat.h"
-
-#define dvb_log(fmt, arg...) do {\
-	parms->logfunc(LOG_INFO, fmt, ##arg); \
-} while (0)
-#define dvb_logerr(fmt, arg...) do {\
-	parms->logfunc(LOG_ERR, fmt, ##arg); \
-} while (0)
-
-#define dvb_perror(msg) do {\
-	parms->logfunc(LOG_ERR, "%s: %s", msg, strerror(errno)); \
-} while (0)
+#include "dvb-log.h"
 
 #define ARRAY_SIZE(x)	(sizeof(x)/sizeof((x)[0]))
 
@@ -73,7 +62,6 @@ struct dvb_v5_stats {
 	struct dtv_property		prop[DTV_MAX_STATS];
 };
 
-typedef void (*dvb_logfunc)(int level, const char *fmt, ...);
 
 struct dvb_v5_fe_parms {
 	int				fd;
@@ -119,6 +107,9 @@ void dvb_fe_close(struct dvb_v5_fe_parms *parms);
 
 /* Get/set delivery system parameters */
 
+const char *dvb_cmd_name(int cmd);
+const char *const *dvb_attr_names(int cmd);
+
 int dvb_fe_retrieve_parm(const struct dvb_v5_fe_parms *parms,
 			unsigned cmd, uint32_t *value);
 int dvb_fe_store_parm(struct dvb_v5_fe_parms *parms,
@@ -130,8 +121,8 @@ int dvb_add_parms_for_sys(struct dtv_property *dvb_prop,
 			  fe_delivery_system_t sys);
 int dvb_set_compat_delivery_system(struct dvb_v5_fe_parms *parms,
 				   uint32_t desired_system);
-const char *dvb_cmd_name(int cmd);
-void dvb_fe_prt_parms(FILE *fp, const struct dvb_v5_fe_parms *parms);
+
+void dvb_fe_prt_parms(const struct dvb_v5_fe_parms *parms);
 int dvb_fe_set_parms(struct dvb_v5_fe_parms *parms);
 int dvb_fe_get_parms(struct dvb_v5_fe_parms *parms);
 
@@ -193,5 +184,16 @@ extern const unsigned fe_bandwidth_name[8];
 extern const char *dvb_v5_name[61];
 extern const void *dvb_v5_attr_names[];
 extern const char *delivery_system_name[20];
+extern const char *fe_code_rate_name[13];
+extern const char *fe_modulation_name[14];
+extern const char *fe_transmission_mode_name[8];
+extern const unsigned fe_bandwidth_name[8];
+extern const char *fe_guard_interval_name[9];
+extern const char *fe_hierarchy_name[6];
+extern const char *fe_voltage_name[4];
+extern const char *fe_tone_name[3];
+extern const char *fe_inversion_name[4];
+extern const char *fe_pilot_name[4];
+extern const char *fe_rolloff_name[5];
 
 #endif
lib/include/dvb-file.h +3 -3
index 7a605b3..3609c7d 100644
@@ -79,7 +79,7 @@ enum file_formats {
 #define PTABLE(a) .table = a, .size=ARRAY_SIZE(a)
 
 
-struct dvb_descriptors;
+struct dvb_v5_descriptors;
 
 #ifdef __cplusplus
 extern "C" {
@@ -130,12 +130,12 @@ struct dvb_file *read_dvb_file(const char *fname);
 
 int write_dvb_file(const char *fname, struct dvb_file *dvb_file);
 
-char *dvb_vchannel(struct dvb_descriptors *dvb_desc,
+char *dvb_vchannel(struct dvb_v5_descriptors *dvb_desc,
 	           int service);
 
 int store_dvb_channel(struct dvb_file **dvb_file,
 		      struct dvb_v5_fe_parms *parms,
-		      struct dvb_descriptors *dvb_desc,
+		      struct dvb_v5_descriptors *dvb_desc,
 		      int get_detected, int get_nit);
 int parse_delsys(const char *name);
 enum file_formats parse_format(const char *name);
lib/include/dvb-log.h new file +49 -0

49 lines not on this page · raw message

lib/include/dvb-scan.h +7 -113

137 lines not on this page · raw message

lib/libdvbv5/Makefile.am +18 -2
index d14cc13..1943ff2 100644
@@ -11,16 +11,32 @@ endif
 libdvbv5_la_SOURCES = \
   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 \
   ../include/dvb-frontend.h \
   dvb-v5.h dvb-v5.c \
   ../include/dvb-v5-std.h dvb-v5-std.c \
   dvb-legacy-channel-format.c \
   dvb-zap-format.c \
-  descriptors.c descriptors.h \
   dvb-sat.c ../include/dvb-sat.h \
   dvb-scan.c ../include/dvb-scan.h \
-  parse_string.c parse_string.h
+  parse_string.c parse_string.h \
+  crc32.c crc32.h \
+  descriptors.c descriptors.h \
+  descriptors/header.c ../include/descriptors/header.h \
+  descriptors/pat.c  ../include/descriptors/pat.h \
+  descriptors/pmt.c  ../include/descriptors/pmt.h \
+  descriptors/desc_language.c  ../include/descriptors/desc_language.h \
+  descriptors/desc_network_name.c  ../include/descriptors/desc_network_name.h \
+  descriptors/desc_cable_delivery.c  ../include/descriptors/desc_cable_delivery.h \
+  descriptors/desc_sat.c  ../include/descriptors/desc_sat.h \
+  descriptors/desc_terrestrial_delivery.c  ../include/descriptors/desc_terrestrial_delivery.h \
+  descriptors/desc_service.c  ../include/descriptors/desc_service.h \
+  descriptors/desc_frequency_list.c  ../include/descriptors/desc_frequency_list.h \
+  descriptors/desc_service_list.c  ../include/descriptors/desc_service_list.h \
+  descriptors/nit.c  ../include/descriptors/nit.h \
+  descriptors/sdt.c  ../include/descriptors/sdt.h
+
 libdvbv5_la_CPPFLAGS = $(ENFORCE_LIBDVBV5_STATIC)
 libdvbv5_la_LDFLAGS = -version-info 0 $(ENFORCE_LIBDVBV5_STATIC)
 libdvbv5_la_LIBADD = $(LTLIBICONV)
lib/libdvbv5/crc32.c new file +76 -0

76 lines not on this page · raw message

lib/libdvbv5/crc32.h new file +31 -0
new file mode 100644
index 0000000..69af116
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2011-2012 - Mauro Carvalho Chehab <[email protected]>
+ * Copyright (c) 2012 - Andre Roth <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation version 2
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+ *
+ */
+
+#ifndef _CRC32_H
+#define _CRC32_H
+
+#include <stdint.h>
+#include <unistd.h> /* size_t */
+
+uint32_t crc32(uint8_t *data, size_t datalen, uint32_t crc);
+
+#endif
+
lib/libdvbv5/descriptors.c +506 -440

1,150 lines not on this page · raw message

lib/libdvbv5/descriptors.h deleted +0 -214

202 lines not on this page · raw message

lib/libdvbv5/descriptors/desc_cable_delivery.c new file +53 -0

53 lines not on this page · raw message

lib/libdvbv5/descriptors/desc_frequency_list.c new file +63 -0

63 lines not on this page · raw message

lib/libdvbv5/descriptors/desc_language.c new file +44 -0

44 lines not on this page · raw message

lib/libdvbv5/descriptors/desc_network_name.c new file +41 -0

41 lines not on this page · raw message

lib/libdvbv5/descriptors/desc_sat.c new file +69 -0

69 lines not on this page · raw message

lib/libdvbv5/descriptors/desc_service.c new file +56 -0

56 lines not on this page · raw message

lib/libdvbv5/descriptors/desc_service_list.c new file +53 -0

53 lines not on this page · raw message

lib/libdvbv5/descriptors/desc_terrestrial_delivery.c new file +57 -0

57 lines not on this page · raw message

lib/libdvbv5/descriptors/header.c new file +48 -0

48 lines not on this page · raw message

lib/libdvbv5/descriptors/nit.c new file +100 -0

100 lines not on this page · raw message

lib/libdvbv5/descriptors/pat.c new file +57 -0

57 lines not on this page · raw message

lib/libdvbv5/descriptors/pmt.c new file +103 -0

103 lines not on this page · raw message

lib/libdvbv5/descriptors/sdt.c new file +88 -0

88 lines not on this page · raw message

lib/libdvbv5/dvb-demux.c +17 -1
index f7157d7..7ece976 100644

Lines of this file are not shown. View the raw message.

lib/libdvbv5/dvb-fe.c +8 -46

54 lines not on this page · raw message

lib/libdvbv5/dvb-file.c +5 -5
index ea9caa0..2c8905e 100644

Lines of this file are not shown. View the raw message.

lib/libdvbv5/dvb-log.c new file +63 -0

63 lines not on this page · raw message

lib/libdvbv5/dvb-scan.c +187 -141

328 lines not on this page · raw message

utils/dvb/dvb-fe-tool.c +1 -1
index 0292199..4c88afd 100644

Lines of this file are not shown. View the raw message.

utils/dvb/dvbv5-scan.c +4 -4
index 7ab5edd..33032a9 100644

Lines of this file are not shown. View the raw message.

utils/v4l2-compliance/v4l2-test-formats.cpp +5 -5
index c86c697..2f0269e 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.7.2.5

Part of the diff is not shown here. View the raw message.

#3 lore raw

PATCH 4/5 libdvbv5: Fix DiSEqC and LNB handling

In reply to André Roth
---
 lib/include/dvb-fe.h      |    2 +-
 lib/libdvbv5/dvb-fe.c     |   61 +++++++++++++++++++++++++--------------------
 lib/libdvbv5/dvb-sat.c    |   13 +++++----
 lib/libdvbv5/dvb-v5-std.c |    8 +++---
 4 files changed, 46 insertions(+), 38 deletions(-)
lib/include/dvb-fe.h +1 -1
index a91a627..8b795cb 100644
@@ -166,7 +166,7 @@ const char * const *dvb_attr_names(int cmd);
  */
 
 int dvb_fe_sec_voltage(struct dvb_v5_fe_parms *parms, int on, int v18);
-int dvb_fe_sec_tone(struct dvb_v5_fe_parms *parms, int on);
+int dvb_fe_sec_tone(struct dvb_v5_fe_parms *parms, fe_sec_tone_mode_t tone);
 int dvb_fe_lnb_high_voltage(struct dvb_v5_fe_parms *parms, int on);
 int dvb_fe_diseqc_burst(struct dvb_v5_fe_parms *parms, int mini_b);
 int dvb_fe_diseqc_cmd(struct dvb_v5_fe_parms *parms, const unsigned len,
lib/libdvbv5/dvb-fe.c +34 -27

132 lines not on this page · raw message

lib/libdvbv5/dvb-sat.c +7 -6
index 25995fb..d00a09e 100644
@@ -304,8 +304,8 @@ static int dvbsat_diseqc_set_input(struct dvb_v5_fe_parms *parms, uint16_t t)
 
 		/* Adjust voltage/tone accordingly */
 		if (parms->sat_number < 2) {
-			vol_high = high_band;
-			tone_on = pol_v ? 0 : 1;
+			vol_high = pol_v ? 0 : 1;
+			tone_on = high_band;
 			mini_b = parms->sat_number & 1;
 		}
 	}
@@ -326,8 +326,10 @@ static int dvbsat_diseqc_set_input(struct dvb_v5_fe_parms *parms, uint16_t t)
 		rc = dvbsat_scr_odu_channel_change(parms, &cmd, high_band,
 						   pol_v, sat_number, t);
 
-	if (rc)
+	if (rc) {
+		dvb_logerr("sending diseq failed");
 		return rc;
+	}
 	usleep((15 + parms->diseqc_wait) * 1000);
 
 	rc = dvb_fe_diseqc_burst(parms, mini_b);
@@ -335,7 +337,7 @@ static int dvbsat_diseqc_set_input(struct dvb_v5_fe_parms *parms, uint16_t t)
 		return rc;
 	usleep(15 * 1000);
 
-	rc = dvb_fe_sec_tone(parms, tone_on);
+	rc = dvb_fe_sec_tone(parms, tone_on ? SEC_TONE_ON : SEC_TONE_OFF);
 
 	return rc;
 }
@@ -352,7 +354,7 @@ int dvb_sat_set_parms(struct dvb_v5_fe_parms *parms)
 	dvb_fe_retrieve_parm(parms, DTV_POLARIZATION, &pol);
 	uint32_t freq;
 	uint16_t t = 0;
-	uint32_t voltage = SEC_VOLTAGE_13;
+	/*uint32_t voltage = SEC_VOLTAGE_18;*/
 	int rc;
 
 	dvb_fe_retrieve_parm(parms, DTV_FREQUENCY, &freq);
@@ -396,7 +398,6 @@ ret:
 	rc = dvbsat_diseqc_set_input(parms, t);
 
 	freq = abs(freq - parms->freq_offset);
-	dvb_fe_store_parm(parms, DTV_VOLTAGE, voltage);
 	dvb_fe_store_parm(parms, DTV_FREQUENCY, freq);
 
 	return rc;
lib/libdvbv5/dvb-v5-std.c +4 -4
index 1396e5f..362eb25 100644
@@ -125,8 +125,8 @@ const unsigned int sys_dvbs_props[] = {
 	DTV_INVERSION,
 	DTV_SYMBOL_RATE,
 	DTV_INNER_FEC,
-	DTV_VOLTAGE,
-	DTV_TONE,
+	/*DTV_VOLTAGE,*/
+	/*DTV_TONE,*/
         DTV_POLARIZATION,
 	0
 };
@@ -136,8 +136,8 @@ const unsigned int sys_dvbs2_props[] = {
 	DTV_INVERSION,
 	DTV_SYMBOL_RATE,
 	DTV_INNER_FEC,
-	DTV_VOLTAGE,
-	DTV_TONE,
+	/*DTV_VOLTAGE,*/
+	/*DTV_TONE,*/
 	DTV_MODULATION,
 	DTV_PILOT,
 	DTV_ROLLOFF,
Signature · 1 line
1.7.2.5
#4 lore raw

PATCH 5/5 libdvbv5: Support multi section DVB tables, string parsing

In reply to André Roth
---
 lib/include/descriptors.h                          |   15 ++-
 lib/include/descriptors/desc_cable_delivery.h      |    2 +-
 lib/include/descriptors/desc_frequency_list.h      |    2 +-
 lib/include/descriptors/desc_language.h            |    2 +-
 lib/include/descriptors/desc_network_name.h        |    2 +-
 lib/include/descriptors/desc_sat.h                 |    2 +-
 lib/include/descriptors/desc_service.h             |    2 +-
 lib/include/descriptors/desc_service_list.h        |    2 +-
 .../descriptors/desc_terrestrial_delivery.h        |    2 +-
 lib/include/descriptors/nit.h                      |    2 +-
 lib/include/descriptors/pat.h                      |    2 +-
 lib/include/descriptors/pmt.h                      |   12 +-
 lib/include/descriptors/sdt.h                      |    2 +-
 lib/include/dvb-scan.h                             |    2 +-
 lib/libdvbv5/descriptors.c                         |   88 +++++++++----
 lib/libdvbv5/descriptors/desc_network_name.c       |   24 +++-
 lib/libdvbv5/descriptors/desc_service.c            |   46 +++++-
 lib/libdvbv5/descriptors/nit.c                     |   65 ++++++----
 lib/libdvbv5/descriptors/pat.c                     |   37 +++---
 lib/libdvbv5/descriptors/pmt.c                     |   87 ++++++------
 lib/libdvbv5/descriptors/sdt.c                     |   57 +++++---
 lib/libdvbv5/dvb-scan.c                            |  143 +++++++++++--------
 lib/libdvbv5/parse_string.c                        |   16 ++-
 lib/libdvbv5/parse_string.h                        |    4 +-
 utils/dvb/dvbv5-scan.c                             |    2 +-
 25 files changed, 391 insertions(+), 229 deletions(-)
lib/include/descriptors.h +12 -3
index 8ecb13d..0493e80 100644
@@ -35,13 +35,15 @@
 
 struct dvb_v5_fe_parms;
 
-typedef void *(*dvb_table_init_func)(struct dvb_v5_fe_parms *parms, const uint8_t *ptr, ssize_t size);
+typedef void (*dvb_table_init_func)(struct dvb_v5_fe_parms *parms, const uint8_t *ptr, ssize_t size, uint8_t **buf, ssize_t *buflen);
 
 struct dvb_table_init {
 	dvb_table_init_func init;
 };
 
 extern const struct dvb_table_init dvb_table_initializers[];
+extern char *default_charset;
+extern char *output_charset;
 
 #define bswap16(b) do {\
 	b = be16toh(b); \
@@ -53,11 +55,15 @@ extern const struct dvb_table_init dvb_table_initializers[];
 
 struct dvb_desc {
 	uint8_t type;
-	struct dvb_desc *next;
 	uint8_t length;
+	struct dvb_desc *next;
+
 	uint8_t data[];
 } __attribute__((packed));
 
+ssize_t dvb_desc_default_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, struct dvb_desc *desc);
+void dvb_desc_default_print  (struct dvb_v5_fe_parms *parms, const struct dvb_desc *desc);
+
 #define dvb_desc_foreach( _desc, _tbl ) \
 	for( struct dvb_desc *_desc = _tbl->descriptor; _desc; _desc = _desc->next ) \
 
@@ -69,7 +75,10 @@ ssize_t dvb_desc_init(const uint8_t *buf, struct dvb_desc *desc);
 
 uint32_t bcd(uint32_t bcd);
 
+void hexdump(struct dvb_v5_fe_parms *parms, const char *prefix, const unsigned char *buf, int len);
+
 ssize_t dvb_parse_descriptors(struct dvb_v5_fe_parms *parms, const uint8_t *buf, uint8_t *dest, uint16_t section_length, struct dvb_desc **head_desc);
+void dvb_print_descriptors(struct dvb_v5_fe_parms *parms, struct dvb_desc *desc);
 
 struct dvb_v5_fe_parms;
 
@@ -381,7 +390,7 @@ struct dvb_v5_descriptors {
 	unsigned cur_ts;
 };
 
-void parse_descriptor(enum dvb_tables type,
+void parse_descriptor(struct dvb_v5_fe_parms *parms, enum dvb_tables type,
 		struct dvb_v5_descriptors *dvb_desc,
 		const unsigned char *buf, int len);
 
lib/include/descriptors/desc_cable_delivery.h +1 -1
index 4d10a29..bdbe706 100644
@@ -27,8 +27,8 @@
 
 struct dvb_desc_cable_delivery {
 	uint8_t type;
-	struct dvb_desc *next;
 	uint8_t length;
+	struct dvb_desc *next;
 
 	uint32_t frequency;
 	union {
lib/include/descriptors/desc_frequency_list.h +1 -1
index 21f0256..80a7fb9 100644
@@ -27,8 +27,8 @@
 
 struct dvb_desc_frequency_list {
 	uint8_t type;
-	struct dvb_desc *next;
 	uint8_t length;
+	struct dvb_desc *next;
 
 	union {
 		uint8_t bitfield;
lib/include/descriptors/desc_language.h +1 -1
index 321a948..eca9cdb 100644
@@ -27,8 +27,8 @@
 
 struct dvb_desc_language {
 	uint8_t type;
-	struct dvb_desc *next;
 	uint8_t length;
+	struct dvb_desc *next;
 
 	unsigned char language[4];
 	uint8_t audio_type;
lib/include/descriptors/desc_network_name.h +1 -1
index 011cba9..706b36c 100644
@@ -27,8 +27,8 @@
 
 struct dvb_desc_network_name {
 	uint8_t type;
-	struct dvb_desc *next;
 	uint8_t length;
+	struct dvb_desc *next;
 
 	unsigned char network_name[];
 } __attribute__((packed));
lib/include/descriptors/desc_sat.h +1 -1
index a287685..820d8f1 100644
@@ -27,8 +27,8 @@
 
 struct dvb_desc_sat {
 	uint8_t type;
-	struct dvb_desc *next;
 	uint8_t length;
+	struct dvb_desc *next;
 
 	uint32_t frequency;
 	uint16_t orbit;
lib/include/descriptors/desc_service.h +1 -1
index c5b01cb..a89b3ed 100644
@@ -27,8 +27,8 @@
 
 struct dvb_desc_service {
 	uint8_t type;
-	struct dvb_desc *next;
 	uint8_t length;
+	struct dvb_desc *next;
 
 	uint8_t service_type;
 	char *name;
lib/include/descriptors/desc_service_list.h +1 -1
index cb60eb5..919623f 100644
@@ -32,8 +32,8 @@ struct dvb_desc_service_list_table {
 
 struct dvb_desc_service_list {
 	uint8_t type;
-	struct dvb_desc *next;
 	uint8_t length;
+	struct dvb_desc *next;
 
 	struct dvb_desc_service_list_table services[];
 } __attribute__((packed));
lib/include/descriptors/desc_terrestrial_delivery.h +1 -1
index da86cb4..482f4b0 100644
@@ -27,8 +27,8 @@
 
 struct dvb_desc_terrestrial_delivery {
 	uint8_t type;
-	struct dvb_desc *next;
 	uint8_t length;
+	struct dvb_desc *next;
 
 	uint32_t centre_frequency;
 	uint8_t reserved_future_use1:2;
lib/include/descriptors/nit.h +1 -1
index 6a7e472..013a842 100644
@@ -76,7 +76,7 @@ struct dvb_v5_fe_parms;
 extern "C" {
 #endif
 
-void *dvb_table_nit_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t size);
+void dvb_table_nit_init (struct dvb_v5_fe_parms *parms, const uint8_t *ptr, ssize_t size, uint8_t **buf, ssize_t *buflen);
 void dvb_table_nit_print(struct dvb_v5_fe_parms *parms, struct dvb_table_nit *nit);
 
 #ifdef __cplusplus
lib/include/descriptors/pat.h +1 -1
index 8a7cd60..69e1956 100644
@@ -53,7 +53,7 @@ struct dvb_v5_fe_parms;
 extern "C" {
 #endif
 
-void *dvb_table_pat_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t size);
+void dvb_table_pat_init (struct dvb_v5_fe_parms *parms, const uint8_t *ptr, ssize_t size, uint8_t **buf, ssize_t *buflen);
 void dvb_table_pat_print(struct dvb_v5_fe_parms *parms, struct dvb_table_pat *t);
 
 #ifdef __cplusplus
lib/include/descriptors/pmt.h +6 -6
index d1cad30..b923677 100644
@@ -35,15 +35,15 @@ struct dvb_table_pmt_stream {
 		uint16_t bitfield;
 		struct {
 			uint16_t elementary_pid:13;
-			uint16_t  reserved:3;
+			uint16_t reserved:3;
 		};
 	};
 	union {
 		uint16_t bitfield2;
 		struct {
 			uint16_t section_length:10;
-			uint16_t  zero:2;
-			uint16_t  reserved2:4;
+			uint16_t zero:2;
+			uint16_t reserved2:4;
 		};
 	};
 	struct dvb_desc *descriptor;
@@ -64,8 +64,8 @@ struct dvb_table_pmt {
 		uint16_t bitfield2;
 		struct {
 			uint16_t prog_length:10;
-			uint16_t  zero3:2;
-			uint16_t  reserved3:4;
+			uint16_t zero3:2;
+			uint16_t reserved3:4;
 		};
 	};
 	struct dvb_table_pmt_stream *stream;
@@ -80,7 +80,7 @@ struct dvb_v5_fe_parms;
 extern "C" {
 #endif
 
-void *dvb_table_pmt_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t size);
+void dvb_table_pmt_init (struct dvb_v5_fe_parms *parms, const uint8_t *ptr, ssize_t size, uint8_t **buf, ssize_t *buflen);
 void dvb_table_pmt_print(struct dvb_v5_fe_parms *parms, const struct dvb_table_pmt *pmt);
 
 #ifdef __cplusplus
lib/include/descriptors/sdt.h +1 -1
index 5cea2d8..877442a 100644
@@ -64,7 +64,7 @@ struct dvb_v5_fe_parms;
 extern "C" {
 #endif
 
-void *dvb_table_sdt_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t size);
+void dvb_table_sdt_init(struct dvb_v5_fe_parms *parms, const uint8_t *ptr, ssize_t size, uint8_t **buf, ssize_t *buflen);
 void dvb_table_sdt_print(struct dvb_v5_fe_parms *parms, struct dvb_table_sdt *sdt);
 
 #ifdef __cplusplus
lib/include/dvb-scan.h +1 -1
index 284a9b6..9f4b914 100644
@@ -34,7 +34,7 @@ extern "C" {
 int dvb_read_section(struct dvb_v5_fe_parms *parms, int dmx_fd, unsigned char table, uint16_t pid, unsigned char **buf,
 		unsigned *length, unsigned timeout);
 
-struct dvb_v5_descriptors *dvb_get_ts_tables(int dmx_fd,
+struct dvb_v5_descriptors *dvb_get_ts_tables(struct dvb_v5_fe_parms *parms, int dmx_fd,
 					  uint32_t delivery_system,
 					  unsigned other_nit,
 					  unsigned timeout_multiply,
lib/libdvbv5/descriptors.c +63 -25

160 lines not on this page · raw message

lib/libdvbv5/descriptors/desc_network_name.c +21 -3
index 10e18c3..e89bd2d 100644
@@ -22,15 +22,33 @@
 #include "descriptors/desc_network_name.h"
 #include "descriptors.h"
 #include "dvb-fe.h"
+#include "parse_string.h"
 
 ssize_t dvb_desc_network_name_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, struct dvb_desc *desc)
 {
 	struct dvb_desc_network_name *net = (struct dvb_desc_network_name *) desc;
+	char *name, *emph;
+	uint8_t len;  /* the length of the string in the input data */
+	uint8_t len1; /* the lenght of the output strings */
 
-	memcpy(net->network_name, buf, net->length);
-	net->network_name[net->length] = '\0';
+	len = desc->length;
+	len1 = len;
+	name = NULL;
+	emph = NULL;
+	parse_string(parms, &name, &emph, buf, len1, default_charset, output_charset);
+	buf += len;
+	if (emph)
+		free(emph);
+	if (name) {
+		len1 = strlen(name);
+		memcpy(net->network_name, name, len1);
+		free(name);
+	} else {
+		memcpy(net->network_name, buf, len1);
+	}
+	net->network_name[len1] = '\0';
 
-	return sizeof(struct dvb_desc_network_name) + net->length + sizeof(net->network_name[0]);
+	return sizeof(struct dvb_desc_network_name) + len1 + 1;
 }
 
 void dvb_desc_network_name_print(struct dvb_v5_fe_parms *parms, const struct dvb_desc *desc)
lib/libdvbv5/descriptors/desc_service.c +38 -8

71 lines not on this page · raw message

lib/libdvbv5/descriptors/nit.c +41 -24

98 lines not on this page · raw message

lib/libdvbv5/descriptors/pat.c +21 -16
index d1fb30b..eb076fd 100644
@@ -23,25 +23,30 @@
 #include "descriptors.h"
 #include "dvb-fe.h"
 
-void *dvb_table_pat_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t size)
+void dvb_table_pat_init(struct dvb_v5_fe_parms *parms, const uint8_t *ptr, ssize_t size, uint8_t **buf, ssize_t *buflen)
 {
-	struct dvb_table_pat *pat = malloc(size + sizeof(uint16_t));
-	memcpy(pat, buf, sizeof(struct dvb_table_pat) - sizeof(uint16_t));
+	uint8_t *d;
+	struct dvb_table_pat *pat;
+	if (!*buf) {
+		d = malloc(size + sizeof(uint16_t));
+		*buf = d;
+		*buflen = size + sizeof(uint16_t);
+		pat = (struct dvb_table_pat *) d;
+		memcpy(pat, ptr, sizeof(struct dvb_table_pat) - sizeof(uint16_t));
 
-	dvb_table_header_init(&pat->header);
-
-	struct dvb_table_pat_program *p = (struct dvb_table_pat_program *)
-		                          (buf + sizeof(struct dvb_table_pat) - sizeof(uint16_t));
-	int i = 0;
-	while ((uint8_t *) p < buf + size - 4) {
-		memcpy(pat->program + i, p, sizeof(struct dvb_table_pat_program));
-		bswap16(pat->program[i].program_id);
-		bswap16(pat->program[i].bitfield);
-		p++;
-		i++;
+		struct dvb_table_pat_program *p = (struct dvb_table_pat_program *)
+			                          (ptr + sizeof(struct dvb_table_pat) - sizeof(uint16_t));
+		pat->programs = 0;
+		while ((uint8_t *) p < ptr + size - 4) {
+			memcpy(pat->program + pat->programs, p, sizeof(struct dvb_table_pat_program));
+			bswap16(pat->program[pat->programs].program_id);
+			bswap16(pat->program[pat->programs].bitfield);
+			p++;
+			pat->programs++;
+		}
+	} else {
+		dvb_logerr("multisecttion PAT table not implemented");
 	}
-	pat->programs = i;
-	return pat;
 }
 
 void dvb_table_pat_print(struct dvb_v5_fe_parms *parms, struct dvb_table_pat *t)
lib/libdvbv5/descriptors/pmt.c +44 -43

109 lines not on this page · raw message

lib/libdvbv5/descriptors/sdt.c +35 -22

85 lines not on this page · raw message

lib/libdvbv5/dvb-scan.c +83 -60

281 lines not on this page · raw message

lib/libdvbv5/parse_string.c +11 -5
index fc8d5f3..21368b6 100644
@@ -29,6 +29,8 @@
 #include <string.h>
 
 #include "parse_string.h"
+#include "dvb-log.h"
+#include "dvb-fe.h"
 
 #define CS_OPTIONS "//TRANSLIT"
 
@@ -297,7 +299,7 @@ static struct charset_conv en300468_latin_00_to_utf8[256] = {
 	[0xff] = { 2, {0xc2, 0xad, } },
 };
 
-static void charset_conversion(char **dest, const unsigned char *s,
+static void charset_conversion(struct dvb_v5_fe_parms *parms, char **dest, const unsigned char *s,
 			       size_t len,
 			       char *type, char *output_charset)
 {
@@ -342,7 +344,7 @@ static void charset_conversion(char **dest, const unsigned char *s,
 		if (cd == (iconv_t)(-1)) {
 			memcpy(p, s, len);
 			p[len] = '\0';
-			fprintf(stderr, "Conversion from %s to %s not supported\n",
+			dvb_logerr("Conversion from %s to %s not supported\n",
 				 type, output_charset);
 		} else {
 			iconv(cd, (ICONV_CONST char **)&s, &len, &p, &destlen);
@@ -352,7 +354,7 @@ static void charset_conversion(char **dest, const unsigned char *s,
 	}
 }
 
-void parse_string(char **dest, char **emph,
+void parse_string(struct dvb_v5_fe_parms *parms, char **dest, char **emph,
 		  const unsigned char *src, size_t len,
 		  char *default_charset, char *output_charset)
 {
@@ -392,6 +394,8 @@ void parse_string(char **dest, char **emph,
 		case 0x14:	type = "BIG5";			break;
 		case 0x15:	type = "ISO-10646/UTF-8";	break;
 		case 0x10: /* ISO8859 */
+			if (len < 2)
+				break;
 			if ((*(src + 1) != 0) || *(src + 2) > 0x0f)
 				break;
 			src+=2;
@@ -452,6 +456,7 @@ void parse_string(char **dest, char **emph,
 		len = p - (char *)tmp1;
 		len2 = p2 - (char *)tmp2;
 	} else {
+		dvb_logerr("charset %s not implemented", type);
 		/*
 		 * FIXME: need to handle the ISO/IEC 10646 2-byte control codes
 		 * (EN 300 468 v1.11.1 Table A.2)
@@ -463,7 +468,7 @@ void parse_string(char **dest, char **emph,
 	else
 		s = src;
 
-	charset_conversion(dest, s, len, type, output_charset);
+	charset_conversion(parms, dest, s, len, type, output_charset);
 	/* The code had over-sized the space. Fix it. */
 	if (*dest)
 		*dest = realloc(*dest, strlen(*dest) + 1);
@@ -473,10 +478,11 @@ void parse_string(char **dest, char **emph,
 		free (*emph);
 		*emph = NULL;
 	} else {
-		charset_conversion(emph, tmp2, len2, type, output_charset);
+		charset_conversion(parms, emph, tmp2, len2, type, output_charset);
 		*emph = realloc(*emph, strlen(*emph) + 1);
 	}
 
 	if (tmp1)
 		free(tmp1);
 }
+
lib/libdvbv5/parse_string.h +3 -1
index ca30a23..15dd5ce 100644
@@ -17,6 +17,8 @@
  * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  */
 
-void parse_string(char **dest, char **emph,
+struct dvb_v5_fe_parms;
+
+void parse_string(struct dvb_v5_fe_parms *parms, char **dest, char **emph,
 		  const unsigned char *src, size_t len,
 		  char *default_charset, char *output_charset);
utils/dvb/dvbv5-scan.c +1 -1
index 33032a9..937b9dd 100644
@@ -412,7 +412,7 @@ static int run_scan(struct arguments *args,
 		if (rc < 0)
 			continue;
 
-		dvb_desc = dvb_get_ts_tables(dmx_fd,
+		dvb_desc = dvb_get_ts_tables(parms, dmx_fd,
 					     parms->current_sys,
 					     args->other_nit,
 					     args->timeout_multiply,
Signature · 1 line
1.7.2.5