]> git.sesse.net Git - vlc/blob - modules/access/dvb/dvb.h
57ccfbf4aee515c212d2bf19af5067fa7bc02dab
[vlc] / modules / access / dvb / dvb.h
1 /*****************************************************************************
2  * dvb.h : functions to control a DVB card under Linux with v4l2
3  *****************************************************************************
4  * Copyright (C) 1998-2005 the VideoLAN team
5  *
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>
10  *
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.
15  *
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.
20  *
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  *****************************************************************************/
25
26
27 #include "scan.h"
28
29 /*****************************************************************************
30  * Local structures
31  *****************************************************************************/
32 typedef struct demux_handle_t
33 {
34     int i_pid;
35     int i_handle;
36     int i_type;
37 } demux_handle_t;
38
39 typedef struct frontend_t frontend_t;
40 typedef struct
41 {
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;
46
47 typedef struct
48 {
49     bool b_has_signal;
50     bool b_has_carrier;
51     bool b_has_lock;
52 } frontend_status_t;
53
54 typedef struct en50221_session_t
55 {
56     int i_slot;
57     int i_resource_id;
58     void (* pf_handle)( access_t *, int, uint8_t *, int );
59     void (* pf_close)( access_t *, int );
60     void (* pf_manage)( access_t *, int );
61     void *p_sys;
62 } en50221_session_t;
63
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
70
71 typedef struct en50221_mmi_object_t
72 {
73     int i_object_type;
74
75     union
76     {
77         struct
78         {
79             bool b_blind;
80             char *psz_text;
81         } enq;
82
83         struct
84         {
85             bool b_ok;
86             char *psz_answ;
87         } answ;
88
89         struct
90         {
91             char *psz_title, *psz_subtitle, *psz_bottom;
92             char **ppsz_choices;
93             int i_choices;
94         } menu; /* menu and list are the same */
95
96         struct
97         {
98             int i_choice;
99         } menu_answ;
100     } u;
101 } en50221_mmi_object_t;
102
103 static inline void en50221_MMIFree( en50221_mmi_object_t *p_object )
104 {
105     int i;
106
107     switch ( p_object->i_object_type )
108     {
109     case EN50221_MMI_ENQ:
110         FREENULL( p_object->u.enq.psz_text );
111         break;
112
113     case EN50221_MMI_ANSW:
114         if ( p_object->u.answ.b_ok )
115         {
116             FREENULL( p_object->u.answ.psz_answ );
117         }
118         break;
119
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++ )
126         {
127             free( p_object->u.menu.ppsz_choices[i] );
128         }
129         FREENULL( p_object->u.menu.ppsz_choices );
130         break;
131
132     default:
133         break;
134     }
135 }
136
137 #define MAX_DEMUX 256
138 #define MAX_CI_SLOTS 16
139 #define MAX_SESSIONS 32
140 #define MAX_PROGRAMS 24
141
142 struct access_sys_t
143 {
144     int i_handle, i_frontend_handle;
145     demux_handle_t p_demux_handles[MAX_DEMUX];
146     frontend_t *p_frontend;
147     bool b_budget_mode;
148     bool b_scan_mode;
149
150     /* CA management */
151     int i_ca_handle;
152     int i_ca_type;
153     int i_nb_slots;
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;
162
163     /* */
164     int i_read_once;
165
166     int i_stat_counter;
167
168 #ifdef ENABLE_HTTPD
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;
173
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;
179     char                *psz_request;
180 #endif
181
182     /* Scan */
183     scan_t scan;
184 };
185
186 #define VIDEO0_TYPE     1
187 #define AUDIO0_TYPE     2
188 #define TELETEXT0_TYPE  3
189 #define SUBTITLE0_TYPE  4
190 #define PCR0_TYPE       5
191 #define TYPE_INTERVAL   5
192 #define OTHER_TYPE     21
193
194 /*****************************************************************************
195  * Prototypes
196  *****************************************************************************/
197
198 int  FrontendOpen( access_t * );
199 void FrontendPoll( access_t *p_access );
200 int  FrontendSet( access_t * );
201 void FrontendClose( access_t * );
202 #ifdef ENABLE_HTTPD
203 void FrontendStatus( access_t * );
204 #endif
205
206 int  FrontendGetStatistic( access_t *, frontend_statistic_t * );
207 void FrontendGetStatus( access_t *, frontend_status_t * );
208 int  FrontendGetScanParameter( access_t *, scan_parameter_t * );
209
210 int DMXSetFilter( access_t *, int i_pid, int * pi_fd, int i_type );
211 int DMXUnsetFilter( access_t *, int i_fd );
212
213 int  DVROpen( access_t * );
214 void DVRClose( access_t * );
215
216 int  CAMOpen( access_t * );
217 int  CAMPoll( access_t * );
218 int  CAMSet( access_t *, dvbpsi_pmt_t * );
219 void CAMClose( access_t * );
220 #ifdef ENABLE_HTTPD
221 void CAMStatus( access_t * );
222 #endif
223
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,
230                                                 int i_slot );
231 void en50221_SendMMIObject( access_t * p_access, int i_slot,
232                                 en50221_mmi_object_t *p_object );
233 void en50221_End( access_t * );
234
235 char *dvbsi_to_utf8( const char *psz_instring, size_t i_length );
236
237 #ifdef ENABLE_HTTPD
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 );
242 #endif
243 /*****************************************************************************
244  * Hacks
245  *****************************************************************************/
246 #define STRINGIFY( z )   UGLY_KLUDGE( z )
247 #define UGLY_KLUDGE( z ) #z
248