libdvbv5  1.4.0
Library to work with Digital TV streams
descriptors.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2012 - Mauro Carvalho Chehab
3  * Copyright (c) 2012-2014 - Andre Roth <neolynx@gmail.com>
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation version 2
8  * of the License.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  */
20 
42 #ifndef _DESCRIPTORS_H
43 #define _DESCRIPTORS_H
44 
45 #include <unistd.h>
46 #include <stdint.h>
47 #include <arpa/inet.h>
48 
50 #define DVB_MAX_PAYLOAD_PACKET_SIZE 4096
51 
53 #define DVB_CRC_SIZE 4
54 
55 
56 #ifndef _DOXYGEN
57 struct dvb_v5_fe_parms;
58 #endif
59 
61 typedef void (*dvb_table_init_func)(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, void **table);
62 
65 
66 #ifndef _DOXYGEN
67 #define bswap16(b) do {\
68  b = ntohs(b); \
69 } while (0)
70 
71 #define bswap32(b) do {\
72  b = ntohl(b); \
73 } while (0)
74 
75 #define DVB_DESC_HEADER() \
76  uint8_t type; \
77  uint8_t length; \
78  struct dvb_desc *next
79 
80 #endif /* _DOXYGEN */
81 
93 struct dvb_desc {
94  DVB_DESC_HEADER();
95 
96  uint8_t data[];
97 } __attribute__((packed));
98 
99 #ifndef _DOXYGEN
100 
101 #define dvb_desc_foreach( _desc, _tbl ) \
102  for( struct dvb_desc *_desc = _tbl->descriptor; _desc; _desc = _desc->next ) \
103 
104 #define dvb_desc_find(_struct, _desc, _tbl, _type) \
105  for( _struct *_desc = (_struct *) _tbl->descriptor; _desc; _desc = (_struct *) _desc->next ) \
106  if(_desc->type == _type) \
107 
108 #endif /* _DOXYGEN */
109 
110 #ifdef __cplusplus
111 extern "C" {
112 #endif
113 
119 uint32_t dvb_bcd(uint32_t bcd);
120 
129 void dvb_hexdump(struct dvb_v5_fe_parms *parms, const char *prefix,
130  const unsigned char *buf, int len);
131 
152 int dvb_desc_parse(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
153  uint16_t buflen, struct dvb_desc **head_desc);
154 
160 void dvb_desc_free (struct dvb_desc **list);
161 
168 void dvb_desc_print(struct dvb_v5_fe_parms *parms, struct dvb_desc *desc);
169 
170 #ifdef __cplusplus
171 }
172 #endif
173 
175 typedef int (*dvb_desc_init_func) (struct dvb_v5_fe_parms *parms, const uint8_t *buf, struct dvb_desc *desc);
176 
178 typedef void (*dvb_desc_print_func)(struct dvb_v5_fe_parms *parms, const struct dvb_desc *desc);
179 
181 typedef void (*dvb_desc_free_func) (struct dvb_desc *desc);
182 
196  const char *name;
200  ssize_t size;
201 };
202 
206 extern const struct dvb_descriptor dvb_descriptors[];
207 
212  /* ISO/IEC 13818-1 */
230 
249 
250  /* ETSI EN 300 468 V1.11.1 (2010-04) */
251 
316 
317  /* SCTE 35 2004 */
319 
322  /* From http://www.etherguidesystems.com/Help/SDOs/ATSC/Semantics/Descriptors/Default.aspx */
324 
325  /* From http://www.coolstf.com/tsreader/descriptors.html */
327 
328  /* ISDB Descriptors, as defined on ABNT NBR 15603-1 2007 */
329 
333 
373 
374  /* ATSC descriptors - ATSC A/65:2009 spec */
388 };
389 
390 /* Please see desc_extension.h for extension_descriptor types */
391 
392 #endif
void dvb_desc_free(struct dvb_desc **list)
frees a dvb_desc linked list
dvb_desc_free_func free
Definition: descriptors.h:199
const dvb_table_init_func dvb_table_initializers[256]
Table with all possible descriptors.
void dvb_hexdump(struct dvb_v5_fe_parms *parms, const char *prefix, const unsigned char *buf, int len)
dumps data into the logs in hexadecimal format
dvb_desc_init_func init
Definition: descriptors.h:197
const char * name
Definition: descriptors.h:196
dvb_desc_print_func print
Definition: descriptors.h:198
int(* dvb_desc_init_func)(struct dvb_v5_fe_parms *parms, const uint8_t *buf, struct dvb_desc *desc)
Function prototype for the descriptors parsing init code.
Definition: descriptors.h:175
uint8_t data[]
Definition: descriptors.h:94
const struct dvb_descriptor dvb_descriptors[]
Contains the parsers for the several descriptors.
void(* dvb_table_init_func)(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, void **table)
Function prototype for a function that initializes the descriptors parsing.
Definition: descriptors.h:61
Keeps data needed to handle the DVB frontend.
Definition: dvb-fe.h:113
descriptors
List containing all descriptors used by Digital TV MPEG-TS.
Definition: descriptors.h:211
void dvb_desc_print(struct dvb_v5_fe_parms *parms, struct dvb_desc *desc)
prints the contents of a struct dvb_desc linked list
Contains the parser information for the MPEG-TS parser code.
Definition: descriptors.h:195
void(* dvb_desc_print_func)(struct dvb_v5_fe_parms *parms, const struct dvb_desc *desc)
Function prototype for the descriptors parsing print code.
Definition: descriptors.h:178
Linked list containing the several descriptors found on a MPEG-TS table.
Definition: descriptors.h:93
void(* dvb_desc_free_func)(struct dvb_desc *desc)
Function prototype for the descriptors memory free code.
Definition: descriptors.h:181
int dvb_desc_parse(struct dvb_v5_fe_parms *parms, const uint8_t *buf, uint16_t buflen, struct dvb_desc **head_desc)
parse MPEG-TS descriptors
uint32_t dvb_bcd(uint32_t bcd)
Converts from BCD to CPU integer internal representation.