1 /***************************************************************************** 2 * pmt.h 3 * Copyright (C) 2001-2011 VideoLAN 4 * $Id$ 5 * 6 * Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr> 7 * Jean-Paul Saman <jpsaman@videolan.org> 8 * 9 * This library is free software; you can redistribute it and/or 10 * modify it under the terms of the GNU Lesser General Public 11 * License as published by the Free Software Foundation; either 12 * version 2.1 of the License, or (at your option) any later version. 13 * 14 * This library is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * Lesser General Public License for more details. 18 * 19 * You should have received a copy of the GNU Lesser General Public 20 * License along with this library; if not, write to the Free Software 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 * 23 *****************************************************************************/ 24 25 /*! 26 * \file <pmt.h> 27 * \author Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr> 28 * \brief Application interface for the PMT decoder and the PMT generator. 29 * 30 * Application interface for the PMT decoder and the PMT generator. 31 * New decoded PMT tables are sent by callback to the application. 32 */ 33 34 #ifndef _DVBPSI_PMT_H_ 35 #define _DVBPSI_PMT_H_ 36 37 #ifdef __cplusplus 38 extern "C" { 39 #endif 40 41 /***************************************************************************** 42 * dvbpsi_pmt_es_t 43 *****************************************************************************/ 44 /*! 45 * \struct dvbpsi_pmt_es_s 46 * \brief PMT ES structure. 47 * 48 * This structure is used to store a decoded ES description. 49 * (ISO/IEC 13818-1 section 2.4.4.8). 50 */ 51 /*! 52 * \typedef struct dvbpsi_pmt_es_s dvbpsi_pmt_es_t 53 * \brief dvbpsi_pmt_es_t type definition. 54 */ 55 typedef struct dvbpsi_pmt_es_s 56 { 57 uint8_t i_type; /*!< stream_type */ 58 uint16_t i_pid; /*!< elementary_PID */ 59 60 dvbpsi_descriptor_t * p_first_descriptor; /*!< descriptor list */ 61 62 struct dvbpsi_pmt_es_s * p_next; /*!< next element of 63 the list */ 64 65 } dvbpsi_pmt_es_t; 66 67 /***************************************************************************** 68 * dvbpsi_pmt_t 69 *****************************************************************************/ 70 /*! 71 * \struct dvbpsi_pmt_s 72 * \brief PMT structure. 73 * 74 * This structure is used to store a decoded PMT. 75 * (ISO/IEC 13818-1 section 2.4.4.8). 76 */ 77 /*! 78 * \typedef struct dvbpsi_pmt_s dvbpsi_pmt_t 79 * \brief dvbpsi_pmt_t type definition. 80 */ 81 typedef struct dvbpsi_pmt_s 82 { 83 uint16_t i_program_number; /*!< program_number */ 84 uint8_t i_version; /*!< version_number */ 85 bool b_current_next; /*!< current_next_indicator */ 86 87 uint16_t i_pcr_pid; /*!< PCR_PID */ 88 89 dvbpsi_descriptor_t * p_first_descriptor; /*!< descriptor list */ 90 91 dvbpsi_pmt_es_t * p_first_es; /*!< ES list */ 92 93 } dvbpsi_pmt_t; 94 95 /***************************************************************************** 96 * dvbpsi_pmt_callback 97 *****************************************************************************/ 98 /*! 99 * \typedef void (* dvbpsi_pmt_callback)(void* p_cb_data, 100 dvbpsi_pmt_t* p_new_pmt) 101 * \brief Callback type definition. 102 */ 103 typedef void (* dvbpsi_pmt_callback)(void* p_cb_data, dvbpsi_pmt_t* p_new_pmt); 104 105 /***************************************************************************** 106 * dvbpsi_pmt_attach 107 *****************************************************************************/ 108 /*! 109 * \fn bool dvbpsi_pmt_attach(dvbpsi_t *p_dvbpsi, 110 uint16_t i_program_number, 111 dvbpsi_pmt_callback pf_callback, 112 void* p_cb_data) 113 * \brief Creates and initialization of a PMT decoder and attaches it to dvbpsi_t 114 * handle 115 * \param p_dvbpsi handle 116 * \param i_program_number program number 117 * \param pf_callback function to call back on new PMT 118 * \param p_cb_data private data given in argument to the callback 119 * \return true on success, false on failure 120 */ 121 bool dvbpsi_pmt_attach(dvbpsi_t *p_dvbpsi, uint16_t i_program_number, 122 dvbpsi_pmt_callback pf_callback, void* p_cb_data); 123 124 /***************************************************************************** 125 * dvbpsi_pmt_detach 126 *****************************************************************************/ 127 /*! 128 * \fn void dvbpsi_pmt_detach(dvbpsi_t *p_dvbpsi) 129 * \brief Destroy a PMT decoder. 130 * \param p_dvbpsi handle 131 * \return nothing. 132 * 133 * The handle isn't valid any more. 134 */ 135 void dvbpsi_pmt_detach(dvbpsi_t *p_dvbpsi); 136 137 /***************************************************************************** 138 * dvbpsi_pmt_init/dvbpsi_pmt_new 139 *****************************************************************************/ 140 /*! 141 * \fn void dvbpsi_pmt_init(dvbpsi_pmt_t* p_pmt, uint16_t i_program_number, 142 uint8_t i_version, bool b_current_next, 143 uint16_t i_pcr_pid) 144 * \brief Initialize a user-allocated dvbpsi_pmt_t structure. 145 * \param p_pmt pointer to the PMT structure 146 * \param i_program_number program number 147 * \param i_version PMT version 148 * \param b_current_next current next indicator 149 * \param i_pcr_pid PCR_PID 150 * \return nothing. 151 */ 152 void dvbpsi_pmt_init(dvbpsi_pmt_t* p_pmt, uint16_t i_program_number, 153 uint8_t i_version, bool b_current_next, uint16_t i_pcr_pid); 154 155 /*! 156 * \fn dvbpsi_pmt_t* dvbpsi_pmt_new(uint16_t i_program_number, 157 uint8_t i_version, bool b_current_next, 158 uint16_t i_pcr_pid) 159 * \brief Allocate and initialize a new dvbpsi_pmt_t structure. 160 * \param i_program_number program number 161 * \param i_version PMT version 162 * \param b_current_next current next indicator 163 * \param i_pcr_pid PCR_PID 164 * \return p_pmt pointer to the PMT structure 165 */ 166 dvbpsi_pmt_t* dvbpsi_pmt_new(uint16_t i_program_number, uint8_t i_version, 167 bool b_current_next, uint16_t i_pcr_pid); 168 169 /***************************************************************************** 170 * dvbpsi_pmt_empty/dvbpsi_pmt_delete 171 *****************************************************************************/ 172 /*! 173 * \fn void dvbpsi_pmt_empty(dvbpsi_pmt_t* p_pmt) 174 * \brief Clean a dvbpsi_pmt_t structure. 175 * \param p_pmt pointer to the PMT structure 176 * \return nothing. 177 */ 178 void dvbpsi_pmt_empty(dvbpsi_pmt_t* p_pmt); 179 180 /*! 181 * \fn void dvbpsi_pmt_delete(dvbpsi_pmt_t* p_pmt) 182 * \brief Clean and free a dvbpsi_pmt_t structure. 183 * \param p_pmt pointer to the PMT structure 184 * \return nothing. 185 */ 186 void dvbpsi_pmt_delete(dvbpsi_pmt_t* p_pmt); 187 188 /***************************************************************************** 189 * dvbpsi_pmt_descriptor_add 190 *****************************************************************************/ 191 /*! 192 * \fn dvbpsi_descriptor_t* dvbpsi_pmt_descriptor_add(dvbpsi_pmt_t* p_pmt, 193 uint8_t i_tag, 194 uint8_t i_length, 195 uint8_t* p_data) 196 * \brief Add a descriptor in the PMT. 197 * \param p_pmt pointer to the PMT structure 198 * \param i_tag descriptor's tag 199 * \param i_length descriptor's length 200 * \param p_data descriptor's data 201 * \return a pointer to the added descriptor. 202 */ 203 dvbpsi_descriptor_t* dvbpsi_pmt_descriptor_add(dvbpsi_pmt_t* p_pmt, 204 uint8_t i_tag, uint8_t i_length, 205 uint8_t* p_data); 206 207 /***************************************************************************** 208 * dvbpsi_pmt_es_add 209 *****************************************************************************/ 210 /*! 211 * \fn dvbpsi_pmt_es_t* dvbpsi_pmt_es_add(dvbpsi_pmt_t* p_pmt, 212 uint8_t i_type, uint16_t i_pid) 213 * \brief Add an ES in the PMT. 214 * \param p_pmt pointer to the PMT structure 215 * \param i_type type of ES 216 * \param i_pid PID of the ES 217 * \return a pointer to the added ES. 218 */ 219 dvbpsi_pmt_es_t* dvbpsi_pmt_es_add(dvbpsi_pmt_t* p_pmt, 220 uint8_t i_type, uint16_t i_pid); 221 222 /***************************************************************************** 223 * dvbpsi_pmt_es_descriptor_add 224 *****************************************************************************/ 225 /*! 226 * \fn dvbpsi_descriptor_t* dvbpsi_pmt_es_descriptor_add(dvbpsi_pmt_es_t* p_es, 227 uint8_t i_tag, 228 uint8_t i_length, 229 uint8_t* p_data) 230 * \brief Add a descriptor in the PMT ES. 231 * \param p_es pointer to the ES structure 232 * \param i_tag descriptor's tag 233 * \param i_length descriptor's length 234 * \param p_data descriptor's data 235 * \return a pointer to the added descriptor. 236 */ 237 dvbpsi_descriptor_t* dvbpsi_pmt_es_descriptor_add(dvbpsi_pmt_es_t* p_es, 238 uint8_t i_tag, uint8_t i_length, 239 uint8_t* p_data); 240 241 /***************************************************************************** 242 * dvbpsi_pmt_sections_generate 243 *****************************************************************************/ 244 /*! 245 * \fn dvbpsi_psi_section_t* dvbpsi_pmt_sections_generate(dvbpsi_t *p_dvbpsi, 246 dvbpsi_pmt_t* p_pmt) 247 * \brief PMT generator 248 * \param p_dvbpsi handle to dvbpsi with attached decoder 249 * \param p_pmt PMT structure 250 * \return a pointer to the list of generated PSI sections. 251 * 252 * Generate PMT sections based on the dvbpsi_pmt_t structure. 253 */ 254 dvbpsi_psi_section_t* dvbpsi_pmt_sections_generate(dvbpsi_t *p_dvbpsi, dvbpsi_pmt_t* p_pmt); 255 256 #ifdef __cplusplus 257 }; 258 #endif 259 260 #else 261 #error "Multiple inclusions of pmt.h" 262 #endif 263