libdvbpsi  2.0.0-git
MPEG Transport Stream PSI table parser
dvbpsi.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * dvbpsi.h
3  * Copyright (C) 2001-2012 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 
35 #ifndef _DVBPSI_DVBPSI_H_
36 #define _DVBPSI_DVBPSI_H_
37 
38 #define DVBPSI_VERSION 2.0.0
39 #define DVBPSI_VERSION_INT ((2<<16)+(0<<8)+0)
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 /*****************************************************************************
46  * Helper for GCC version checks borrowed from VLC.
47  *****************************************************************************/
52 #ifdef __GNUC__
53 # define DVBPSI_GCC_VERSION(maj,min) \
54  ((__GNUC__ > (maj)) || (__GNUC__ == (maj) && __GNUC_MINOR__ >= (min)))
55 #else
56 # define DVBPSI_GCC_VERSION(maj,min) (0)
57 #endif
58 
59 /*****************************************************************************
60  * dvbpsi_t
61  *****************************************************************************/
66 typedef struct dvbpsi_s dvbpsi_t;
67 
73 {
78 };
84 
85 /*****************************************************************************
86  * dvbpsi_message_cb
87  *****************************************************************************/
94 typedef void (* dvbpsi_message_cb)(dvbpsi_t *handle,
95  const dvbpsi_msg_level_t level,
96  const char* msg);
97 
98 /*****************************************************************************
99  * dvbpsi_decoder_t
100  *****************************************************************************/
105 typedef struct dvbpsi_decoder_s dvbpsi_decoder_t;
106 
111 /* Clever cast borrowed from VLC */
112 #if DVBPSI_GCC_VERSION(4,0)
113 # ifndef __cplusplus
114 # define DVBPSI_DECODER( x ) \
115  __builtin_choose_expr( \
116  __builtin_offsetof(__typeof__(*(x)), i_magic), \
117  (void)0, \
118  (dvbpsi_decoder_t *)(x))
119 # else
120 # define DVBPSI_DECODER( x ) \
121  ((dvbpsi_decoder_t *)(x) \
122  + 0 * __builtin_offsetof(__typeof__(*(x)), i_magic))
123 # endif
124 #else
125 # define DVBPSI_DECODER(x) ((dvbpsi_decoder_t *)(x))
126 #endif
127 
128 /*****************************************************************************
129  * dvbpsi_t
130  *****************************************************************************/
142 struct dvbpsi_s
143 {
146  /* Messages callback */
150  /* private data pointer for use by caller, not by libdvbpsi itself ! */
151  void *p_sys;
155 };
156 
157 /*****************************************************************************
158  * dvbpsi_new
159  *****************************************************************************/
172 
173 /*****************************************************************************
174  * dvbpsi_delete
175  *****************************************************************************/
185 void dvbpsi_delete(dvbpsi_t *p_dvbpsi);
186 
187 /*****************************************************************************
188  * dvbpsi_packet_push
189  *****************************************************************************/
199 bool dvbpsi_packet_push(dvbpsi_t *p_dvbpsi, const uint8_t* p_data);
200 
201 /*****************************************************************************
202  * dvbpsi_psi_section_t
203  *****************************************************************************/
204 
210 
211 /*****************************************************************************
212  * dvbpsi_callback_gather_t
213  *****************************************************************************/
219 typedef void (* dvbpsi_callback_gather_t)(dvbpsi_t *p_dvbpsi,
220  dvbpsi_psi_section_t* p_section);
222 /*****************************************************************************
223  * dvbpsi_callback_new_t
224  *****************************************************************************/
230 typedef void (*dvbpsi_callback_new_t)(dvbpsi_t *p_dvbpsi,
231  uint8_t i_table_id,
232  uint16_t i_extension,
233  void *p_data);
235 /*****************************************************************************
236  * dvbpsi_callback_del_t
237  *****************************************************************************/
243 typedef void (*dvbpsi_callback_del_t)(dvbpsi_t *p_dvbpsi,
244  uint8_t i_table_id,
245  uint16_t i_extension);
247 /*****************************************************************************
248  * DVBPSI_DECODER_COMMON
249  *****************************************************************************/
256 #define DVBPSI_DECODER_COMMON \
257  \
261  \
262  uint8_t i_magic[3]; \
263  bool b_complete_header; \
264  bool b_discontinuity; \
265  bool b_current_valid; \
266  uint8_t i_continuity_counter; \
267  uint8_t prevpacket[188]; \
268  uint8_t i_last_section_number; \
269  dvbpsi_psi_section_t *p_current_section; \
270  dvbpsi_psi_section_t *p_sections; \
271  dvbpsi_callback_gather_t pf_gather; \
272  int i_section_max_size; \
273  int i_need; \
274  /* since version 2.0.0 */ \
275  uint16_t i_table_id; \
276  uint16_t i_extension; \
277  /* Subtables creation and deletion Callbacks */ \
278  dvbpsi_callback_new_t pf_new; \
279  dvbpsi_callback_del_t pf_del; \
280  void *p_priv; \
281  /* pointer to next decoder in list */ \
282  dvbpsi_decoder_t *p_next;
285 /*****************************************************************************
286  * struct dvbpsi_decoder_s
287  *****************************************************************************/
295 struct dvbpsi_decoder_s
296 {
298 };
299 
300 /*****************************************************************************
301  * dvbpsi_decoder_new
302  *****************************************************************************/
320  const int i_section_max_size,
321  const bool b_discontinuity,
322  const size_t psi_size);
323 
324 /*****************************************************************************
325  * dvbpsi_decoder_delete
326  *****************************************************************************/
338 void dvbpsi_decoder_delete(dvbpsi_decoder_t *p_decoder);
339 
340 /*****************************************************************************
341  * dvbpsi_decoder_reset
342  *****************************************************************************/
351 void dvbpsi_decoder_reset(dvbpsi_decoder_t* p_decoder, const bool b_force);
352 
353 /*****************************************************************************
354  * dvbpsi_decoder_psi_sections_completed
355  *****************************************************************************/
363 
364 /*****************************************************************************
365  * dvbpsi_decoder_psi_section_add
366  *****************************************************************************/
375 
376 /*****************************************************************************
377  * dvbpsi_decoder_present
378  *****************************************************************************/
390 __attribute__((deprecated,unused))
391 bool dvbpsi_decoder_present(dvbpsi_t *p_dvbpsi);
392 
393 #ifdef __cplusplus
394 };
395 #endif
396 
397 #else
398 #error "Multiple inclusions of dvbpsi.h"
399 #endif
void dvbpsi_decoder_reset(dvbpsi_decoder_t *p_decoder, const bool b_force)
Resets a decoder internal state.
void(* dvbpsi_callback_new_t)(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extension, void *p_data)
Callback used in case of a new PSI table is detected.
Definition: dvbpsi.h:230
bool dvbpsi_decoder_psi_sections_completed(dvbpsi_decoder_t *p_decoder)
Have all sections for this decoder been received?
#define DVBPSI_DECODER_COMMON
Common members for all dvbpsi table decoders. These should be the first members of a table decoder st...
Definition: dvbpsi.h:256
void(* dvbpsi_callback_del_t)(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extension)
Callback used to delete PSI table.
Definition: dvbpsi.h:243
void dvbpsi_decoder_delete(dvbpsi_decoder_t *p_decoder)
Deletes decoder struct and frees any associated PSI section memory. Any memory attached to the dvbpsi...
__attribute__((deprecated, unused)) bool dvbpsi_decoder_present(dvbpsi_t *p_dvbpsi)
dvbpsi_atsc_DetachEIT is deprecated use
Definition: atsc_eit.h:257
bool dvbpsi_decoder_psi_section_add(dvbpsi_decoder_t *p_decoder, dvbpsi_psi_section_t *p_section)
Add a section to the dvbpsi_decoder_t::p_sections list.
void * dvbpsi_decoder_new(dvbpsi_callback_gather_t pf_gather, const int i_section_max_size, const bool b_discontinuity, const size_t psi_size)
Create a new (private) dvbpsi decoder.
void dvbpsi_delete(dvbpsi_t *p_dvbpsi)
Deletes a dvbpsi_t handle created with dvbpsi_new.
enum dvbpsi_msg_level dvbpsi_msg_level_t
DVBPSI message level enumeration type definition.
Definition: dvbpsi.h:83
void(* dvbpsi_message_cb)(dvbpsi_t *handle, const dvbpsi_msg_level_t level, const char *msg)
Callback type definition.
Definition: dvbpsi.h:94
dvbpsi_msg_level
DVBPSI message level enumeration type.
Definition: dvbpsi.h:73
@ DVBPSI_MSG_ERROR
Definition: dvbpsi.h:75
@ DVBPSI_MSG_NONE
Definition: dvbpsi.h:74
@ DVBPSI_MSG_DEBUG
Definition: dvbpsi.h:77
@ DVBPSI_MSG_WARN
Definition: dvbpsi.h:76
dvbpsi_t * dvbpsi_new(dvbpsi_message_cb callback, enum dvbpsi_msg_level level)
Create a new dvbpsi_t handle to be used by PSI decoders or encoders.
void(* dvbpsi_callback_gather_t)(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t *p_section)
Callback used for gathering psi sections on behalf of PSI decoders.
Definition: dvbpsi.h:219
PSI decoder structure.
Definition: dvbpsi.h:293
PSI section structure.
Definition: psi.h:69
uint16_t i_extension
Definition: psi.h:77
uint8_t * p_data
Definition: psi.h:87
uint8_t i_table_id
Definition: psi.h:71
DVBPSI handle structure.
Definition: dvbpsi.h:143
void * p_sys
Definition: dvbpsi.h:151
dvbpsi_decoder_t * p_decoder
Definition: dvbpsi.h:144
enum dvbpsi_msg_level i_msg_level
Definition: dvbpsi.h:148
dvbpsi_message_cb pf_message
Definition: dvbpsi.h:147