1 /* 2 * Copyright (c) 2013-2014 - Mauro Carvalho Chehab <mchehab@kernel.org> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License as published by 6 * the Free Software Foundation version 2.1 of the License. 7 * 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU Lesser General Public License for more details. 12 * 13 * You should have received a copy of the GNU Lesser General Public License 14 * along with this program; if not, write to the Free Software 15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 16 * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 17 * 18 */ 19 20 /** 21 * @file desc_extension.h 22 * @ingroup descriptors 23 * @brief Provides the descriptors for the extension descriptor. 24 * The extension descriptor is used to extend the 8-bit namespace 25 * of the descriptor_tag field. 26 * @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1) 27 * @author Mauro Carvalho Chehab 28 * 29 * @par Relevant specs 30 * The descriptor described herein is defined at: 31 * 32 * @see 33 * - ETSI EN 300 468 V1.11.1 34 * 35 * @par Bug Report 36 * Please submit bug reports and patches to linux-media@vger.kernel.org 37 */ 38 39 #ifndef _EXTENSION_DESC_H 40 #define _EXTENSION_DESC_H 41 42 #include <libdvbv5/descriptors.h> 43 44 struct dvb_v5_fe_parms; 45 46 /** 47 * @enum extension_descriptors 48 * @brief List containing all extended descriptors used by Digital TV MPEG-TS 49 * as defined at ETSI EN 300 468 V1.11.1 50 * @ingroup descriptors 51 * 52 * @var image_icon_descriptor 53 * @brief image icon descriptor 54 * 55 * @var cpcm_delivery_signalling_descriptor 56 * @brief Content Protection/Copy Management (CPCM) delivery signalling 57 * descriptor 58 * 59 * @var CP_descriptor 60 * @brief Content Protection descriptor 61 * 62 * @var CP_identifier_descriptor 63 * @brief Content Protection identifier descriptor 64 * 65 * @var T2_delivery_system_descriptor 66 * @brief DVB-T2 delivery system descriptor 67 * 68 * @var SH_delivery_system_descriptor 69 * @brief DVB-SH delivery system descriptor 70 * 71 * @var supplementary_audio_descriptor 72 * @brief supplementary audio descriptor 73 * 74 * @var network_change_notify_descriptor 75 * @brief network change notify descriptor 76 * 77 * @var message_descriptor 78 * @brief message descriptor 79 * 80 * @var target_region_descriptor 81 * @brief target region descriptor 82 * 83 * @var target_region_name_descriptor 84 * @brief target region name descriptor 85 * 86 * @var service_relocated_descriptor 87 * @brief service relocated descriptor 88 */ 89 enum extension_descriptors { 90 image_icon_descriptor = 0x00, 91 cpcm_delivery_signalling_descriptor = 0x01, 92 CP_descriptor = 0x02, 93 CP_identifier_descriptor = 0x03, 94 T2_delivery_system_descriptor = 0x04, 95 SH_delivery_system_descriptor = 0x05, 96 supplementary_audio_descriptor = 0x06, 97 network_change_notify_descriptor = 0x07, 98 message_descriptor = 0x08, 99 target_region_descriptor = 0x09, 100 target_region_name_descriptor = 0x0a, 101 service_relocated_descriptor = 0x0b, 102 }; 103 104 /** 105 * @struct dvb_extension_descriptor 106 * @ingroup descriptors 107 * @brief Structure containing the extended descriptors 108 * 109 * @param type Descriptor type 110 * @param length Length of the descriptor 111 * @param next pointer to the dvb_desc descriptor 112 * @param extension_code extension code 113 * @param descriptor pointer to struct dvb_desc 114 */ 115 struct dvb_extension_descriptor { 116 uint8_t type; 117 uint8_t length; 118 struct dvb_desc *next; 119 120 uint8_t extension_code; 121 122 struct dvb_desc *descriptor; 123 } __attribute__((packed)); 124 125 126 /** 127 * @brief Function prototype for the extended descriptors parsing init code 128 * @ingroup dvb_table 129 * 130 * @param parms Struct dvb_v5_fe_parms pointer 131 * @param buf buffer with the content of the descriptor 132 * @param ext struct dvb_extension_descriptor pointer 133 * @param desc struct dvb_desc pointer 134 */ 135 typedef int (*dvb_desc_ext_init_func) (struct dvb_v5_fe_parms *parms, 136 const uint8_t *buf, 137 struct dvb_extension_descriptor *ext, 138 void *desc); 139 /** 140 * @brief Function prototype for the extended descriptors parsing print code 141 * @ingroup dvb_table 142 * 143 * @param parms Struct dvb_v5_fe_parms pointer 144 * @param ext struct dvb_extension_descriptor pointer 145 * @param desc struct dvb_desc pointer 146 */ 147 typedef void (*dvb_desc_ext_print_func)(struct dvb_v5_fe_parms *parms, 148 const struct dvb_extension_descriptor *ext, 149 const void *desc); 150 /** 151 * @brief Function prototype for the extended descriptors parsing free code 152 * @ingroup dvb_table 153 * 154 * @param desc struct dvb_desc pointer 155 */ 156 typedef void (*dvb_desc_ext_free_func) (const void *desc); 157 158 /** 159 * @struct dvb_ext_descriptor 160 * @ingroup descriptors 161 * @brief Structure that describes the parser functions for the extended 162 * descriptors. Works on a similar way as struct dvb_descriptor. 163 * 164 * @param name name of the descriptor 165 * @param init init dvb_desc_ext_init_func pointer 166 * @param print print dvb_desc_ext_print_func pointer 167 * @param free free dvb_desc_ext_free_func pointer 168 * @param size size of the descriptor 169 */ 170 struct dvb_ext_descriptor { 171 const char *name; 172 dvb_desc_ext_init_func init; 173 dvb_desc_ext_print_func print; 174 dvb_desc_ext_free_func free; 175 ssize_t size; 176 }; 177 178 179 #ifdef __cplusplus 180 extern "C" { 181 #endif 182 183 /** 184 * @brief Initializes and parses the extended descriptor 185 * @ingroup descriptors 186 * 187 * @param parms struct dvb_v5_fe_parms pointer to the opened device 188 * @param buf buffer containing the descriptor's raw data 189 * @param desc pointer to struct dvb_desc to be allocated and filled 190 * 191 * This function allocates a the descriptor and fills the fields inside 192 * the struct. It also makes sure that all fields will follow the CPU 193 * endianness. Due to that, the content of the buffer may change. 194 * 195 * @return On success, it returns the size of the allocated struct. 196 * A negative value indicates an error. 197 */ 198 int dvb_extension_descriptor_init(struct dvb_v5_fe_parms *parms, 199 const uint8_t *buf, struct dvb_desc *desc); 200 201 /** 202 * @brief Prints the content of the extended descriptor 203 * @ingroup descriptors 204 * 205 * @param parms struct dvb_v5_fe_parms pointer to the opened device 206 * @param desc pointer to struct dvb_desc 207 */ 208 void dvb_extension_descriptor_print(struct dvb_v5_fe_parms *parms, 209 const struct dvb_desc *desc); 210 211 /** 212 * @brief Frees all data allocated by the extended descriptor 213 * @ingroup descriptors 214 * 215 * @param desc pointer to struct dvb_desc to be freed 216 */ 217 void dvb_extension_descriptor_free(struct dvb_desc *desc); 218 219 #ifdef __cplusplus 220 } 221 #endif 222 223 #endif 224