]> git.sesse.net Git - vlc/blob - modules/mux/mpeg/dvbpsi_compat.h
dvbpsi: handle all message types
[vlc] / modules / mux / mpeg / dvbpsi_compat.h
1 /*****************************************************************************
2  * dvbpsi_compat.h: Compatibility headerfile
3  *****************************************************************************
4  * Copyright (C) 2013 VideoLAN Association
5  *
6  * Authors: Jean-Paul Saman <jpsaman@videolan.org>
7  *
8  * This program is free software; you can redistribute it and/or modify it
9  * under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation; either version 2.1 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this program; if not, write to the Free Software Foundation,
20  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21  *****************************************************************************/
22
23 #ifndef DVBPSI_COMPAT_H
24 #define DVBPSI_COMPAT_H
25
26 /*
27  * dvbpsi compatibility macros:
28  * dvbpsi version 1.0.0 and above returns a struct 'dvbpsi_t' as handle
29  */
30 #define DVBPSI_VERSION_WANTED(major,minor,bugfix) (((major)<<16)+((minor)<<8)+(bugfix))
31
32 #if (DVBPSI_VERSION_INT >= DVBPSI_VERSION_WANTED(1,0,0))
33 # define dvbpsi_handle dvbpsi_t*
34 # define dvbpsi_PushPacket(handle,data) dvbpsi_packet_push((handle),(data))
35 /* PAT */
36 # define dvbpsi_InitPAT(pat,id,version,next) dvbpsi_pat_init((pat),(id),(version),(bool)(next))
37 # define dvbpsi_PATAddProgram(pat,nr,pid)    dvbpsi_pat_program_add((pat),(nr),(pid))
38 # define dvbpsi_EmptyPAT(pat)                dvbpsi_pat_empty((pat))
39 # define dvbpsi_DeletePAT(table)             dvbpsi_pat_delete((table))
40 # define dvbpsi_DetachPAT(pat)               dvbpsi_pat_detach((pat))
41 /* PMT */
42 # define dvbpsi_InitPMT(pmt,program,version,next,pcr) \
43          dvbpsi_pmt_init((pmt),(program),(version),(bool)(next),(pcr))
44 # define dvbpsi_PMTAddDescriptor(pmt,tag,length,data) \
45          dvbpsi_pmt_descriptor_add((pmt),(tag),(length),(data))
46 # define dvbpsi_PMTAddES(pmt,type,pid) \
47          dvbpsi_pmt_es_add((pmt),(type),(pid))
48 # define dvbpsi_PMTESAddDescriptor(es,tag,length,data) \
49          dvbpsi_pmt_es_descriptor_add((es),(tag),(length),(data))
50 # define dvbpsi_EmptyPMT(pmt) dvbpsi_pmt_empty((pmt))
51 # define dvbpsi_DeletePMT(table)        dvbpsi_pmt_delete((table))
52 # define dvbpsi_DetachPMT(pmt)          dvbpsi_pmt_detach((pmt))
53 /* SDT */
54 # define dvbpsi_InitSDT(sdt,id,version,curnext,netid) \
55          dvbpsi_sdt_init((sdt),(id),(0),(version),(bool)(curnext),(netid))
56 # define dvbpsi_SDTAddService(sdt,id,schedule,present,status,ca) \
57          dvbpsi_sdt_service_add((sdt),(id),(bool)(schedule),(bool)(present),(status),(bool)(ca))
58 # define dvbpsi_EmptySDT(sdt) dvbpsi_sdt_empty((sdt))
59 # define dvbpsi_DeleteSDT(table)        dvbpsi_sdt_delete((table))
60 /* TOT */
61 # define dvbpsi_DeleteTOT(table)        dvbpsi_tot_delete((table))
62 /* EIT */
63 # define dvbpsi_DeleteEIT(table)        dvbpsi_eit_delete((table))
64 /* NIT */
65 # define dvbpsi_DeleteNIT(table)        dvbpsi_nit_delete((table))
66
67 static void dvbpsi_messages(dvbpsi_t *p_dvbpsi, const dvbpsi_msg_level_t level, const char* msg)
68 {
69     vlc_object_t *obj = (vlc_object_t *)p_dvbpsi->p_sys;
70
71     /* See dvbpsi.h for the definition of these log levels.*/
72     switch(level)
73     {
74         case DVBPSI_MSG_ERROR: msg_Err( obj, "%s", msg ); break;
75         case DVBPSI_MSG_WARN:  msg_Warn( obj, "%s", msg ); break;
76         case DVBPSI_MSG_NONE:
77         case DVBPSI_MSG_DEBUG:
78 #ifdef DVBPSI_DEBUG
79             msg_Dbg( obj, "%s", msg );
80 #endif
81             break;
82     }
83 }
84 #endif
85
86 #endif