1 /* 2 * Copyright (c) 2013 - Andre Roth <neolynx@gmail.com> 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 cat.h 22 * @ingroup dvb_table 23 * @brief Provides the table parser for the CAT (Conditional Access Table) 24 * @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1) 25 * @author Andre Roth 26 * 27 * @par Bug Report 28 * Please submit bug reports and patches to linux-media@vger.kernel.org 29 */ 30 31 #ifndef _CAT_H 32 #define _CAT_H 33 34 #include <stdint.h> 35 #include <unistd.h> /* ssize_t */ 36 37 #include <libdvbv5/header.h> 38 39 /** 40 * @def DVB_TABLE_CAT 41 * @brief ATSC CAT table ID 42 * @ingroup dvb_table 43 * @def DVB_TABLE_CAT_PID 44 * @brief ATSC PID table ID 45 * @ingroup dvb_table 46 */ 47 #define DVB_TABLE_CAT 0x01 48 #define DVB_TABLE_CAT_PID 0x0001 49 50 /** 51 * @struct dvb_table_cat 52 * @brief ATSC CAT table 53 * 54 * @param header struct dvb_table_header content 55 * @param descriptor pointer to struct dvb_desc 56 */ 57 struct dvb_table_cat { 58 struct dvb_table_header header; 59 struct dvb_desc *descriptor; 60 } __attribute__((packed)); 61 62 struct dvb_v5_fe_parms; 63 64 #ifdef __cplusplus 65 extern "C" { 66 #endif 67 68 /** 69 * @brief Initializes and parses CAT table 70 * 71 * @param parms struct dvb_v5_fe_parms pointer to the opened device 72 * @param buf buffer containing the CAT raw data 73 * @param buflen length of the buffer 74 * @param table pointer to struct dvb_table_cat to be allocated and filled 75 * 76 * This function allocates an CAT table and fills the fields inside 77 * the struct. It also makes sure that all fields will follow the CPU 78 * endianness. Due to that, the content of the buffer may change. 79 * 80 * @return On success, it returns the size of the allocated struct. 81 * A negative value indicates an error. 82 */ 83 ssize_t dvb_table_cat_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, 84 ssize_t buflen, struct dvb_table_cat **table); 85 86 /** 87 * @brief Frees all data allocated by the CAT table parser 88 * 89 * @param table pointer to struct dvb_table_cat to be freed 90 */ 91 void dvb_table_cat_free(struct dvb_table_cat *table); 92 93 /** 94 * @brief Prints the content of the CAT table 95 * 96 * @param parms struct dvb_v5_fe_parms pointer to the opened device 97 * @param table pointer to struct dvb_table_cat 98 */ 99 void dvb_table_cat_print(struct dvb_v5_fe_parms *parms, 100 struct dvb_table_cat *table); 101 102 #ifdef __cplusplus 103 } 104 #endif 105 106 #endif 107