]> git.sesse.net Git - vlc/blob - modules/access/dvb/dvb.h
Update e-mail address
[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 /*****************************************************************************
28  * Devices location
29  *****************************************************************************/
30 #define DMX      "/dev/dvb/adapter%d/demux%d"
31 #define FRONTEND "/dev/dvb/adapter%d/frontend%d"
32 #define DVR      "/dev/dvb/adapter%d/dvr%d"
33 #define CA       "/dev/dvb/adapter%d/ca%d"
34
35 /*****************************************************************************
36  * Local structures
37  *****************************************************************************/
38 typedef struct demux_handle_t
39 {
40     int i_pid;
41     int i_handle;
42     int i_type;
43 } demux_handle_t;
44
45 typedef struct frontend_t frontend_t;
46
47 typedef struct en50221_session_t
48 {
49     int i_slot;
50     int i_resource_id;
51     void (* pf_handle)( access_t *, int, uint8_t *, int );
52     void (* pf_close)( access_t *, int );
53     void (* pf_manage)( access_t *, int );
54     void *p_sys;
55 } en50221_session_t;
56
57 #define EN50221_MMI_NONE 0
58 #define EN50221_MMI_ENQ 1
59 #define EN50221_MMI_ANSW 2
60 #define EN50221_MMI_MENU 3
61 #define EN50221_MMI_MENU_ANSW 4
62 #define EN50221_MMI_LIST 5
63
64 typedef struct en50221_mmi_object_t
65 {
66     int i_object_type;
67
68     union
69     {
70         struct
71         {
72             vlc_bool_t b_blind;
73             char *psz_text;
74         } enq;
75
76         struct
77         {
78             vlc_bool_t b_ok;
79             char *psz_answ;
80         } answ;
81
82         struct
83         {
84             char *psz_title, *psz_subtitle, *psz_bottom;
85             char **ppsz_choices;
86             int i_choices;
87         } menu; /* menu and list are the same */
88
89         struct
90         {
91             int i_choice;
92         } menu_answ;
93     } u;
94 } en50221_mmi_object_t;
95
96 static __inline__ void en50221_MMIFree( en50221_mmi_object_t *p_object )
97 {
98     int i;
99
100 #define FREE( x )                                                           \
101     if ( x != NULL )                                                        \
102         free( x );
103
104     switch ( p_object->i_object_type )
105     {
106     case EN50221_MMI_ENQ:
107         FREE( p_object->u.enq.psz_text );
108         break;
109
110     case EN50221_MMI_ANSW:
111         if ( p_object->u.answ.b_ok )
112         {
113             FREE( p_object->u.answ.psz_answ );
114         }
115         break;
116
117     case EN50221_MMI_MENU:
118     case EN50221_MMI_LIST:
119         FREE( p_object->u.menu.psz_title );
120         FREE( p_object->u.menu.psz_subtitle );
121         FREE( p_object->u.menu.psz_bottom );
122         for ( i = 0; i < p_object->u.menu.i_choices; i++ )
123         {
124             FREE( p_object->u.menu.ppsz_choices[i] );
125         }
126         FREE( p_object->u.menu.ppsz_choices );
127         break;
128
129     default:
130         break;
131     }
132 #undef FREE
133 }
134
135 #define MAX_DEMUX 256
136 #define MAX_CI_SLOTS 16
137 #define MAX_SESSIONS 32
138 #define MAX_PROGRAMS 24
139
140 struct access_sys_t
141 {
142     int i_handle, i_frontend_handle;
143     demux_handle_t p_demux_handles[MAX_DEMUX];
144     frontend_t *p_frontend;
145     vlc_bool_t b_budget_mode;
146
147     /* CA management */
148     int i_ca_handle;
149     int i_ca_type;
150     int i_nb_slots;
151     vlc_bool_t pb_active_slot[MAX_CI_SLOTS];
152     vlc_bool_t pb_tc_has_data[MAX_CI_SLOTS];
153     vlc_bool_t pb_slot_mmi_expected[MAX_CI_SLOTS];
154     vlc_bool_t pb_slot_mmi_undisplayed[MAX_CI_SLOTS];
155     en50221_session_t p_sessions[MAX_SESSIONS];
156     mtime_t i_ca_timeout, i_ca_next_event, i_frontend_timeout;
157     dvbpsi_pmt_t *pp_selected_programs[MAX_PROGRAMS];
158     int i_selected_programs;
159
160     /* */
161     int i_read_once;
162
163 #ifdef ENABLE_HTTPD
164     /* Local HTTP server */
165     httpd_host_t        *p_httpd_host;
166     httpd_file_sys_t    *p_httpd_file;
167     httpd_redirect_t    *p_httpd_redir;
168
169     vlc_mutex_t         httpd_mutex;
170     vlc_cond_t          httpd_cond;
171     mtime_t             i_httpd_timeout;
172     vlc_bool_t          b_request_frontend_info, b_request_mmi_info;
173     char                *psz_frontend_info, *psz_mmi_info;
174     char                *psz_request;
175 #endif
176 };
177
178 #define VIDEO0_TYPE     1
179 #define AUDIO0_TYPE     2
180 #define TELETEXT0_TYPE  3
181 #define SUBTITLE0_TYPE  4
182 #define PCR0_TYPE       5
183 #define TYPE_INTERVAL   5
184 #define OTHER_TYPE     21
185
186 /*****************************************************************************
187  * Prototypes
188  *****************************************************************************/
189 int  E_(FrontendOpen)( access_t * );
190 void E_(FrontendPoll)( access_t *p_access );
191 int  E_(FrontendSet)( access_t * );
192 void E_(FrontendClose)( access_t * );
193 #ifdef ENABLE_HTTPD
194 void E_(FrontendStatus)( access_t * );
195 #endif
196
197 int E_(DMXSetFilter)( access_t *, int i_pid, int * pi_fd, int i_type );
198 int E_(DMXUnsetFilter)( access_t *, int i_fd );
199
200 int  E_(DVROpen)( access_t * );
201 void E_(DVRClose)( access_t * );
202
203 int  E_(CAMOpen)( access_t * );
204 int  E_(CAMPoll)( access_t * );
205 int  E_(CAMSet)( access_t *, dvbpsi_pmt_t * );
206 void E_(CAMClose)( access_t * );
207 #ifdef ENABLE_HTTPD
208 void E_(CAMStatus)( access_t * );
209 #endif
210
211 int E_(en50221_Init)( access_t * );
212 int E_(en50221_Poll)( access_t * );
213 int E_(en50221_SetCAPMT)( access_t *, dvbpsi_pmt_t * );
214 int E_(en50221_OpenMMI)( access_t * p_access, int i_slot );
215 int E_(en50221_CloseMMI)( access_t * p_access, int i_slot );
216 en50221_mmi_object_t *E_(en50221_GetMMIObject)( access_t * p_access,
217                                                 int i_slot );
218 void E_(en50221_SendMMIObject)( access_t * p_access, int i_slot,
219                                 en50221_mmi_object_t *p_object );
220 void E_(en50221_End)( access_t * );
221
222 #ifdef ENABLE_HTTPD
223 int E_(HTTPOpen)( access_t *p_access );
224 void E_(HTTPClose)( access_t *p_access );
225 char *E_(HTTPExtractValue)( char *psz_uri, const char *psz_name,
226                             char *psz_value, int i_value_max );
227 #endif
228