]> git.sesse.net Git - vlc/blob - modules/access/dvb/dvb.h
update module LIST file.
[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     switch ( p_object->i_object_type )
101     {
102     case EN50221_MMI_ENQ:
103         FREENULL( p_object->u.enq.psz_text );
104         break;
105
106     case EN50221_MMI_ANSW:
107         if ( p_object->u.answ.b_ok )
108         {
109             FREENULL( p_object->u.answ.psz_answ );
110         }
111         break;
112
113     case EN50221_MMI_MENU:
114     case EN50221_MMI_LIST:
115         FREENULL( p_object->u.menu.psz_title );
116         FREENULL( p_object->u.menu.psz_subtitle );
117         FREENULL( p_object->u.menu.psz_bottom );
118         for ( i = 0; i < p_object->u.menu.i_choices; i++ )
119         {
120             FREENULL( p_object->u.menu.ppsz_choices[i] );
121         }
122         FREENULL( p_object->u.menu.ppsz_choices );
123         break;
124
125     default:
126         break;
127     }
128 }
129
130 #define MAX_DEMUX 256
131 #define MAX_CI_SLOTS 16
132 #define MAX_SESSIONS 32
133 #define MAX_PROGRAMS 24
134
135 struct access_sys_t
136 {
137     int i_handle, i_frontend_handle;
138     demux_handle_t p_demux_handles[MAX_DEMUX];
139     frontend_t *p_frontend;
140     vlc_bool_t b_budget_mode;
141
142     /* CA management */
143     int i_ca_handle;
144     int i_ca_type;
145     int i_nb_slots;
146     vlc_bool_t pb_active_slot[MAX_CI_SLOTS];
147     vlc_bool_t pb_tc_has_data[MAX_CI_SLOTS];
148     vlc_bool_t pb_slot_mmi_expected[MAX_CI_SLOTS];
149     vlc_bool_t pb_slot_mmi_undisplayed[MAX_CI_SLOTS];
150     en50221_session_t p_sessions[MAX_SESSIONS];
151     mtime_t i_ca_timeout, i_ca_next_event, i_frontend_timeout;
152     dvbpsi_pmt_t *pp_selected_programs[MAX_PROGRAMS];
153     int i_selected_programs;
154
155     /* */
156     int i_read_once;
157
158 #ifdef ENABLE_HTTPD
159     /* Local HTTP server */
160     httpd_host_t        *p_httpd_host;
161     httpd_file_sys_t    *p_httpd_file;
162     httpd_redirect_t    *p_httpd_redir;
163
164     vlc_mutex_t         httpd_mutex;
165     vlc_cond_t          httpd_cond;
166     mtime_t             i_httpd_timeout;
167     vlc_bool_t          b_request_frontend_info, b_request_mmi_info;
168     char                *psz_frontend_info, *psz_mmi_info;
169     char                *psz_request;
170 #endif
171 };
172
173 #define VIDEO0_TYPE     1
174 #define AUDIO0_TYPE     2
175 #define TELETEXT0_TYPE  3
176 #define SUBTITLE0_TYPE  4
177 #define PCR0_TYPE       5
178 #define TYPE_INTERVAL   5
179 #define OTHER_TYPE     21
180
181 /*****************************************************************************
182  * Prototypes
183  *****************************************************************************/
184 int  E_(FrontendOpen)( access_t * );
185 void E_(FrontendPoll)( access_t *p_access );
186 int  E_(FrontendSet)( access_t * );
187 void E_(FrontendClose)( access_t * );
188 #ifdef ENABLE_HTTPD
189 void E_(FrontendStatus)( access_t * );
190 #endif
191
192 int E_(DMXSetFilter)( access_t *, int i_pid, int * pi_fd, int i_type );
193 int E_(DMXUnsetFilter)( access_t *, int i_fd );
194
195 int  E_(DVROpen)( access_t * );
196 void E_(DVRClose)( access_t * );
197
198 int  E_(CAMOpen)( access_t * );
199 int  E_(CAMPoll)( access_t * );
200 int  E_(CAMSet)( access_t *, dvbpsi_pmt_t * );
201 void E_(CAMClose)( access_t * );
202 #ifdef ENABLE_HTTPD
203 void E_(CAMStatus)( access_t * );
204 #endif
205
206 int E_(en50221_Init)( access_t * );
207 int E_(en50221_Poll)( access_t * );
208 int E_(en50221_SetCAPMT)( access_t *, dvbpsi_pmt_t * );
209 int E_(en50221_OpenMMI)( access_t * p_access, int i_slot );
210 int E_(en50221_CloseMMI)( access_t * p_access, int i_slot );
211 en50221_mmi_object_t *E_(en50221_GetMMIObject)( access_t * p_access,
212                                                 int i_slot );
213 void E_(en50221_SendMMIObject)( access_t * p_access, int i_slot,
214                                 en50221_mmi_object_t *p_object );
215 void E_(en50221_End)( access_t * );
216
217 #ifdef ENABLE_HTTPD
218 int E_(HTTPOpen)( access_t *p_access );
219 void E_(HTTPClose)( access_t *p_access );
220 char *E_(HTTPExtractValue)( char *psz_uri, const char *psz_name,
221                             char *psz_value, int i_value_max );
222 #endif