1 /*****************************************************************************
2 * dvb.h : functions to control a DVB card under Linux with v4l2
3 *****************************************************************************
4 * Copyright (C) 1998-2005 the VideoLAN team
6 * Authors: Johan Bilien <jobi@via.ecp.fr>
7 * Jean-Paul Saman <jpsaman _at_ videolan _dot_ org>
8 * Christopher Ross <chris@tebibyte.org>
9 * Christophe Massiot <massiot@via.ecp.fr>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
24 *****************************************************************************/
29 /*****************************************************************************
31 *****************************************************************************/
32 typedef struct demux_handle_t
39 typedef struct frontend_t frontend_t;
42 int i_snr; /**< Signal Noise ratio */
43 int i_ber; /**< Bitrate error ratio */
44 int i_signal_strenth; /**< Signal strength */
45 } frontend_statistic_t;
54 typedef struct en50221_session_t
58 void (* pf_handle)( access_t *, int, uint8_t *, int );
59 void (* pf_close)( access_t *, int );
60 void (* pf_manage)( access_t *, int );
64 #define EN50221_MMI_NONE 0
65 #define EN50221_MMI_ENQ 1
66 #define EN50221_MMI_ANSW 2
67 #define EN50221_MMI_MENU 3
68 #define EN50221_MMI_MENU_ANSW 4
69 #define EN50221_MMI_LIST 5
71 typedef struct en50221_mmi_object_t
91 char *psz_title, *psz_subtitle, *psz_bottom;
94 } menu; /* menu and list are the same */
101 } en50221_mmi_object_t;
103 static inline void en50221_MMIFree( en50221_mmi_object_t *p_object )
107 switch ( p_object->i_object_type )
109 case EN50221_MMI_ENQ:
110 FREENULL( p_object->u.enq.psz_text );
113 case EN50221_MMI_ANSW:
114 if ( p_object->u.answ.b_ok )
116 FREENULL( p_object->u.answ.psz_answ );
120 case EN50221_MMI_MENU:
121 case EN50221_MMI_LIST:
122 FREENULL( p_object->u.menu.psz_title );
123 FREENULL( p_object->u.menu.psz_subtitle );
124 FREENULL( p_object->u.menu.psz_bottom );
125 for ( i = 0; i < p_object->u.menu.i_choices; i++ )
127 free( p_object->u.menu.ppsz_choices[i] );
129 FREENULL( p_object->u.menu.ppsz_choices );
137 #define MAX_DEMUX 256
138 #define MAX_CI_SLOTS 16
139 #define MAX_SESSIONS 32
140 #define MAX_PROGRAMS 24
144 int i_handle, i_frontend_handle;
145 demux_handle_t p_demux_handles[MAX_DEMUX];
146 frontend_t *p_frontend;
154 bool pb_active_slot[MAX_CI_SLOTS];
155 bool pb_tc_has_data[MAX_CI_SLOTS];
156 bool pb_slot_mmi_expected[MAX_CI_SLOTS];
157 bool pb_slot_mmi_undisplayed[MAX_CI_SLOTS];
158 en50221_session_t p_sessions[MAX_SESSIONS];
159 mtime_t i_ca_timeout, i_ca_next_event, i_frontend_timeout;
160 dvbpsi_pmt_t *pp_selected_programs[MAX_PROGRAMS];
161 int i_selected_programs;
169 /* Local HTTP server */
170 httpd_host_t *p_httpd_host;
171 httpd_file_sys_t *p_httpd_file;
172 httpd_redirect_t *p_httpd_redir;
174 vlc_mutex_t httpd_mutex;
175 vlc_cond_t httpd_cond;
176 mtime_t i_httpd_timeout;
177 bool b_request_frontend_info, b_request_mmi_info;
178 char *psz_frontend_info, *psz_mmi_info;
186 #define VIDEO0_TYPE 1
187 #define AUDIO0_TYPE 2
188 #define TELETEXT0_TYPE 3
189 #define SUBTITLE0_TYPE 4
191 #define TYPE_INTERVAL 5
192 #define OTHER_TYPE 21
194 /*****************************************************************************
196 *****************************************************************************/
198 int FrontendOpen( access_t * );
199 void FrontendPoll( access_t *p_access );
200 int FrontendSet( access_t * );
201 void FrontendClose( access_t * );
203 void FrontendStatus( access_t * );
206 int FrontendGetStatistic( access_t *, frontend_statistic_t * );
207 void FrontendGetStatus( access_t *, frontend_status_t * );
208 int FrontendGetScanParameter( access_t *, scan_parameter_t * );
210 int DMXSetFilter( access_t *, int i_pid, int * pi_fd, int i_type );
211 int DMXUnsetFilter( access_t *, int i_fd );
213 int DVROpen( access_t * );
214 void DVRClose( access_t * );
216 int CAMOpen( access_t * );
217 int CAMPoll( access_t * );
218 int CAMSet( access_t *, dvbpsi_pmt_t * );
219 void CAMClose( access_t * );
221 void CAMStatus( access_t * );
224 int en50221_Init( access_t * );
225 int en50221_Poll( access_t * );
226 int en50221_SetCAPMT( access_t *, dvbpsi_pmt_t * );
227 int en50221_OpenMMI( access_t * p_access, int i_slot );
228 int en50221_CloseMMI( access_t * p_access, int i_slot );
229 en50221_mmi_object_t *en50221_GetMMIObject( access_t * p_access,
231 void en50221_SendMMIObject( access_t * p_access, int i_slot,
232 en50221_mmi_object_t *p_object );
233 void en50221_End( access_t * );
235 char *dvbsi_to_utf8( const char *psz_instring, size_t i_length );
238 int HTTPOpen( access_t *p_access );
239 void HTTPClose( access_t *p_access );
240 const char *HTTPExtractValue( const char *psz_uri, const char *psz_name,
241 char *psz_value, int i_value_max );
243 /*****************************************************************************
245 *****************************************************************************/
246 #define STRINGIFY( z ) UGLY_KLUDGE( z )
247 #define UGLY_KLUDGE( z ) #z