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 #define DMX "/dev/dvb/adapter%d/demux%d"
33 #define FRONTEND "/dev/dvb/adapter%d/frontend%d"
34 #define DVR "/dev/dvb/adapter%d/dvr%d"
35 #define CA "/dev/dvb/adapter%d/ca%d"
37 /*****************************************************************************
39 *****************************************************************************/
40 typedef struct demux_handle_t
47 typedef struct frontend_t frontend_t;
50 int i_snr; /**< Signal Noise ratio */
51 int i_ber; /**< Bitrate error ratio */
52 int i_signal_strenth; /**< Signal strength */
53 } frontend_statistic_t;
62 typedef struct en50221_session_t
66 void (* pf_handle)( access_t *, int, uint8_t *, int );
67 void (* pf_close)( access_t *, int );
68 void (* pf_manage)( access_t *, int );
72 #define EN50221_MMI_NONE 0
73 #define EN50221_MMI_ENQ 1
74 #define EN50221_MMI_ANSW 2
75 #define EN50221_MMI_MENU 3
76 #define EN50221_MMI_MENU_ANSW 4
77 #define EN50221_MMI_LIST 5
79 typedef struct en50221_mmi_object_t
99 char *psz_title, *psz_subtitle, *psz_bottom;
102 } menu; /* menu and list are the same */
109 } en50221_mmi_object_t;
111 static __inline__ void en50221_MMIFree( en50221_mmi_object_t *p_object )
115 switch ( p_object->i_object_type )
117 case EN50221_MMI_ENQ:
118 FREENULL( p_object->u.enq.psz_text );
121 case EN50221_MMI_ANSW:
122 if ( p_object->u.answ.b_ok )
124 FREENULL( p_object->u.answ.psz_answ );
128 case EN50221_MMI_MENU:
129 case EN50221_MMI_LIST:
130 FREENULL( p_object->u.menu.psz_title );
131 FREENULL( p_object->u.menu.psz_subtitle );
132 FREENULL( p_object->u.menu.psz_bottom );
133 for ( i = 0; i < p_object->u.menu.i_choices; i++ )
135 free( p_object->u.menu.ppsz_choices[i] );
137 FREENULL( p_object->u.menu.ppsz_choices );
145 #define MAX_DEMUX 256
146 #define MAX_CI_SLOTS 16
147 #define MAX_SESSIONS 32
148 #define MAX_PROGRAMS 24
152 int i_handle, i_frontend_handle;
153 demux_handle_t p_demux_handles[MAX_DEMUX];
154 frontend_t *p_frontend;
162 bool pb_active_slot[MAX_CI_SLOTS];
163 bool pb_tc_has_data[MAX_CI_SLOTS];
164 bool pb_slot_mmi_expected[MAX_CI_SLOTS];
165 bool pb_slot_mmi_undisplayed[MAX_CI_SLOTS];
166 en50221_session_t p_sessions[MAX_SESSIONS];
167 mtime_t i_ca_timeout, i_ca_next_event, i_frontend_timeout;
168 dvbpsi_pmt_t *pp_selected_programs[MAX_PROGRAMS];
169 int i_selected_programs;
177 /* Local HTTP server */
178 httpd_host_t *p_httpd_host;
179 httpd_file_sys_t *p_httpd_file;
180 httpd_redirect_t *p_httpd_redir;
182 vlc_mutex_t httpd_mutex;
183 vlc_cond_t httpd_cond;
184 mtime_t i_httpd_timeout;
185 bool b_request_frontend_info, b_request_mmi_info;
186 char *psz_frontend_info, *psz_mmi_info;
194 #define VIDEO0_TYPE 1
195 #define AUDIO0_TYPE 2
196 #define TELETEXT0_TYPE 3
197 #define SUBTITLE0_TYPE 4
199 #define TYPE_INTERVAL 5
200 #define OTHER_TYPE 21
202 /*****************************************************************************
204 *****************************************************************************/
206 int FrontendOpen( access_t * );
207 void FrontendPoll( access_t *p_access );
208 int FrontendSet( access_t * );
209 void FrontendClose( access_t * );
211 void FrontendStatus( access_t * );
214 int FrontendGetStatistic( access_t *, frontend_statistic_t * );
215 void FrontendGetStatus( access_t *, frontend_status_t * );
216 int FrontendGetScanParameter( access_t *, scan_parameter_t * );
218 int DMXSetFilter( access_t *, int i_pid, int * pi_fd, int i_type );
219 int DMXUnsetFilter( access_t *, int i_fd );
221 int DVROpen( access_t * );
222 void DVRClose( access_t * );
224 int CAMOpen( access_t * );
225 int CAMPoll( access_t * );
226 int CAMSet( access_t *, dvbpsi_pmt_t * );
227 void CAMClose( access_t * );
229 void CAMStatus( access_t * );
232 int en50221_Init( access_t * );
233 int en50221_Poll( access_t * );
234 int en50221_SetCAPMT( access_t *, dvbpsi_pmt_t * );
235 int en50221_OpenMMI( access_t * p_access, int i_slot );
236 int en50221_CloseMMI( access_t * p_access, int i_slot );
237 en50221_mmi_object_t *en50221_GetMMIObject( access_t * p_access,
239 void en50221_SendMMIObject( access_t * p_access, int i_slot,
240 en50221_mmi_object_t *p_object );
241 void en50221_End( access_t * );
243 char *dvbsi_to_utf8( const char *psz_instring, size_t i_length );
246 int HTTPOpen( access_t *p_access );
247 void HTTPClose( access_t *p_access );
248 const char *HTTPExtractValue( const char *psz_uri, const char *psz_name,
249 char *psz_value, int i_value_max );
251 /*****************************************************************************
253 *****************************************************************************/
254 #define STRINGIFY( z ) UGLY_KLUDGE( z )
255 #define UGLY_KLUDGE( z ) #z