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 #ifndef _ATSC_SERVICE_LOCATION_H 21 #define _ATSC_SERVICE_LOCATION_H 22 23 #include <libdvbv5/descriptors.h> 24 25 /** 26 * @file desc_atsc_service_location.h 27 * @ingroup descriptors 28 * @brief Provides the descriptors for ATSC service location 29 * @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1) 30 * @author Mauro Carvalho Chehab 31 * 32 * @par Relevant specs 33 * The descriptor described herein is defined at: 34 * - ATSC A/53 35 * 36 * @see http://www.etherguidesystems.com/help/sdos/atsc/semantics/descriptors/ServiceLocation.aspx 37 * 38 * @par Bug Report 39 * Please submit bug reports and patches to linux-media@vger.kernel.org 40 */ 41 42 /** 43 * @struct atsc_desc_service_location_elementary 44 * @ingroup descriptors 45 * @brief service location elementary descriptors 46 * 47 * @param stream_type stream type 48 * @param elementary_pid elementary pid 49 * @param ISO_639_language_code ISO 639 language code 50 */ 51 struct atsc_desc_service_location_elementary { 52 uint8_t stream_type; 53 union { 54 uint16_t bitfield; 55 struct { 56 uint16_t elementary_pid:13; 57 uint16_t reserved:3; 58 } __attribute__((packed)); 59 } __attribute__((packed)); 60 unsigned char ISO_639_language_code[3]; 61 } __attribute__((packed)); 62 63 /** 64 * @struct atsc_desc_service_location 65 * @ingroup descriptors 66 * @brief Describes the elementary streams inside a PAT table for ATSC 67 * 68 * @param type descriptor tag 69 * @param length descriptor length 70 * @param next pointer to struct dvb_desc 71 * @param elementary pointer to struct atsc_desc_service_location_elementary 72 * @param pcr_pid PCR pid 73 * @param number_elements number elements 74 */ 75 struct atsc_desc_service_location { 76 uint8_t type; 77 uint8_t length; 78 struct dvb_desc *next; 79 80 struct atsc_desc_service_location_elementary *elementary; 81 82 union { 83 uint16_t bitfield; 84 struct { 85 uint16_t pcr_pid:13; 86 uint16_t reserved:3; 87 } __attribute__((packed)); 88 } __attribute__((packed)); 89 90 uint8_t number_elements; 91 } __attribute__((packed)); 92 93 struct dvb_v5_fe_parms; 94 95 #ifdef __cplusplus 96 extern "C" { 97 #endif 98 99 /** 100 * @brief Initializes and parses the service location descriptor 101 * @ingroup descriptors 102 * 103 * @param parms struct dvb_v5_fe_parms pointer to the opened device 104 * @param buf buffer containing the descriptor's raw data 105 * @param desc pointer to struct dvb_desc to be allocated and filled 106 * 107 * This function allocates a the descriptor and fills the fields inside 108 * the struct. It also makes sure that all fields will follow the CPU 109 * endianness. Due to that, the content of the buffer may change. 110 * 111 * @return On success, it returns the size of the allocated struct. 112 * A negative value indicates an error. 113 */ 114 int atsc_desc_service_location_init(struct dvb_v5_fe_parms *parms, 115 const uint8_t *buf, 116 struct dvb_desc *desc); 117 118 /** 119 * @brief Prints the content of the service location descriptor 120 * @ingroup descriptors 121 * 122 * @param parms struct dvb_v5_fe_parms pointer to the opened device 123 * @param desc pointer to struct dvb_desc 124 */ 125 void atsc_desc_service_location_print(struct dvb_v5_fe_parms *parms, 126 const struct dvb_desc *desc); 127 128 /** 129 * @brief Frees all data allocated by the service location descriptor 130 * @ingroup descriptors 131 * 132 * @param desc pointer to struct dvb_desc to be freed 133 */ 134 void atsc_desc_service_location_free(struct dvb_desc *desc); 135 136 #ifdef __cplusplus 137 } 138 #endif 139 140 #endif 141