]> git.sesse.net Git - vlc/blob - modules/access/bda/bda.c
Auto probe BDA tuner when using dvb://
[vlc] / modules / access / bda / bda.c
1 /*****************************************************************************
2  * bda.c : BDA access module for vlc
3  *****************************************************************************
4  * Copyright (C) 2007 the VideoLAN team
5  *
6  * Author: Ken Self <kenself(at)optusnet(dot)com(dot)au>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21  *****************************************************************************/
22
23 /*****************************************************************************
24  * Preamble
25  *****************************************************************************/
26 #include "bda.h"
27 #include <vlc_plugin.h>
28
29 /*****************************************************************************
30  * Access: local prototypes
31  *****************************************************************************/
32 static int  Open( vlc_object_t *p_this );
33 static int  ParsePath( access_t *p_access, const char* psz_module,
34     const int i_param_count, const char** psz_param, const int* i_type );
35 static void Close( vlc_object_t *p_this );
36 static block_t *Block( access_t * );
37 static int Control( access_t *, int, va_list );
38
39 #define CACHING_TEXT N_("Caching value in ms")
40 #define CACHING_LONGTEXT N_( \
41     "Caching value for DVB streams. This " \
42     "value should be set in milliseconds." )
43
44 #define ADAPTER_TEXT N_("Adapter card to tune")
45 #define ADAPTER_LONGTEXT N_("Adapter cards have a device file in directory " \
46     "named /dev/dvb/adapter[n] with n>=0.")
47
48 #define DEVICE_TEXT N_("Device number to use on adapter")
49 #define DEVICE_LONGTEXT ""
50
51 #define FREQ_TEXT N_("Transponder/multiplex frequency")
52 #if defined(WIN32) || defined(WINCE)
53 #    define FREQ_LONGTEXT N_("In kHz for DVB-S or Hz for DVB-C/T")
54 #else
55 #    define FREQ_LONGTEXT N_("In kHz for DVB-C/S/T")
56 #endif
57
58 #define INVERSION_TEXT N_("Inversion mode")
59 #define INVERSION_LONGTEXT N_("Inversion mode [0=off, 1=on, 2=auto]")
60 static const int i_inversion_list[] = { -1, 0, 1, 2 };
61 static const char *const ppsz_inversion_text[] = { N_("Undefined"), N_("Off"),
62     N_("On"), N_("Auto") };
63
64 #define PROBE_TEXT N_("Probe DVB card for capabilities")
65 #define PROBE_LONGTEXT N_("Some DVB cards do not like to be probed for their " \
66     "capabilities, you can disable this feature if you experience some " \
67     "trouble.")
68
69 #define BUDGET_TEXT N_("Budget mode")
70 #define BUDGET_LONGTEXT N_("This allows you to stream an entire transponder " \
71     "with a \"budget\" card.")
72
73 /* Satellite */
74 #if defined(WIN32) || defined(WINCE)
75 #    define NETID_TEXT N_("Network Identifier")
76 #    define NETID_LONGTEXT ""
77 #else
78 #    define SATNO_TEXT N_("Satellite number in the Diseqc system")
79 #    define SATNO_LONGTEXT N_("[0=no diseqc, 1-4=satellite number].")
80 #endif
81
82 #define VOLTAGE_TEXT N_("LNB voltage")
83 #define VOLTAGE_LONGTEXT N_("In Volts [0, 13=vertical, 18=horizontal].")
84
85 #define HIGH_VOLTAGE_TEXT N_("High LNB voltage")
86 #define HIGH_VOLTAGE_LONGTEXT N_("Enable high voltage if your cables are " \
87     "particularly long. This is not supported by all frontends.")
88
89 #define TONE_TEXT N_("22 kHz tone")
90 #define TONE_LONGTEXT N_("[0=off, 1=on, -1=auto].")
91
92 #define FEC_TEXT N_("Transponder FEC")
93 #define FEC_LONGTEXT N_("FEC=Forward Error Correction mode [9=auto].")
94
95 #define SRATE_TEXT N_("Transponder symbol rate in kHz")
96 #define SRATE_LONGTEXT ""
97
98 #define LNB_LOF1_TEXT N_("Antenna lnb_lof1 (kHz)")
99 #define LNB_LOF1_LONGTEXT N_("Low Band Local Osc Freq in kHz (usually 9.75GHz)")
100
101 #define LNB_LOF2_TEXT N_("Antenna lnb_lof2 (kHz)")
102 #define LNB_LOF2_LONGTEXT N_("High Band Local Osc Freq in kHz (usually 10.6GHz)")
103
104 #define LNB_SLOF_TEXT N_("Antenna lnb_slof (kHz)")
105 #define LNB_SLOF_LONGTEXT N_( \
106     "Low Noise Block switch freq in kHz (usually 11.7GHz)")
107
108 /* Cable */
109 #define MODULATION_TEXT N_("Modulation type")
110 #define MODULATION_LONGTEXT N_("QAM, PSK or VSB modulation method")
111 static const int i_mod_list[] = { -1, 16, 32, 64, 128, 256,
112     10002, 10004, 20008, 20016 };
113 static const char *const ppsz_mod_text[] = {
114     N_("Undefined"), N_("QAM16"), N_("QAM32"), N_("QAM64"), N_("QAM128"), N_("QAM256"),
115     N_("BPSK"), N_("QPSK"), N_("8VSB"), N_("16VSB") };
116
117 /* ATSC */
118 #define MAJOR_CHANNEL_TEXT N_("ATSC Major Channel")
119 #define MAJOR_CHANNEL_LONGTEXT N_("ATSC Major Channel")
120 #define MINOR_CHANNEL_TEXT N_("ATSC Minor Channel")
121 #define MINOR_CHANNEL_LONGTEXT N_("ATSC Minor Channel")
122 #define PHYSICAL_CHANNEL_TEXT N_("ATSC Physical Channel")
123 #define PHYSICAL_CHANNEL_LONGTEXT N_("ATSC Physical Channel")
124
125 /* Terrestrial */
126 #define CODE_RATE_HP_TEXT N_("FEC rate")
127 #define CODE_RATE_HP_LONGTEXT N_("FEC rate includes " \
128     "DVB-T high priority stream FEC Rate")
129 static const int i_hp_fec_list[] = { -1, 1, 2, 3, 4, 5 };
130 static const char *const ppsz_hp_fec_text[] = {
131     N_("Undefined"), N_("1/2"), N_("2/3"), N_("3/4"), N_("5/6"), N_("7/8") };
132
133 #define CODE_RATE_LP_TEXT N_("Terrestrial low priority stream code rate (FEC)")
134 #define CODE_RATE_LP_LONGTEXT N_("Low Priority FEC Rate " \
135     "[Undefined,1/2,2/3,3/4,5/6,7/8]")
136 static const int i_lp_fec_list[] = { -1, 1, 2, 3, 4, 5 };
137 static const char *const ppsz_lp_fec_text[] = {
138     N_("Undefined"), N_("1/2"), N_("2/3"), N_("3/4"), N_("5/6"), N_("7/8") };
139
140 #define BANDWIDTH_TEXT N_("Terrestrial bandwidth")
141 #define BANDWIDTH_LONGTEXT N_("Terrestrial bandwidth [0=auto,6,7,8 in MHz]")
142 static const int i_band_list[] = { -1, 6, 7, 8 };
143 static const char *const ppsz_band_text[] = {
144     N_("Undefined"), N_("6 MHz"), N_("7 MHz"), N_("8 MHz") };
145
146 #define GUARD_TEXT N_("Terrestrial guard interval")
147 #define GUARD_LONGTEXT N_("Guard interval [Undefined,1/4,1/8,1/16,1/32]")
148 static const int i_guard_list[] = { -1, 4, 8, 16, 32 };
149 static const char *const ppsz_guard_text[] = {
150     N_("Undefined"), N_("1/4"), N_("1/8"), N_("1/16"), N_("1/32") };
151
152 #define TRANSMISSION_TEXT N_("Terrestrial transmission mode")
153 #define TRANSMISSION_LONGTEXT N_("Transmission mode [Undefined,2k,8k]")
154 static const int i_transmission_list[] = { -1, 2, 8 };
155 static const char *const ppsz_transmission_text[] = {
156     N_("Undefined"), N_("2k"), N_("8k") };
157
158 #define HIERARCHY_TEXT N_("Terrestrial hierarchy mode")
159 #define HIERARCHY_LONGTEXT N_("Hierarchy alpha value [Undefined,1,2,4]")
160 static const int i_hierarchy_list[] = { -1, 1, 2, 4 };
161 static const char *const ppsz_hierarchy_text[] = {
162     N_("Undefined"), N_("1"), N_("2"), N_("4") };
163
164 /* BDA module additional DVB-S Parameters */
165 #define AZIMUTH_TEXT N_("Satellite Azimuth")
166 #define AZIMUTH_LONGTEXT N_("Satellite Azimuth in tenths of degree")
167 #define ELEVATION_TEXT N_("Satellite Elevation")
168 #define ELEVATION_LONGTEXT N_("Satellite Elevation in tenths of degree")
169 #define LONGITUDE_TEXT N_("Satellite Longitude")
170 #define LONGITUDE_LONGTEXT N_( \
171     "Satellite Longitude in 10ths of degree, -ve=West")
172 #define POLARISATION_TEXT N_("Satellite Polarisation")
173 #define POLARISATION_LONGTEXT N_("Satellite Polarisation [H/V/L/R]")
174 static const char *const ppsz_polar_list[] = { "H", "V", "L", "R" };
175 static const char *const ppsz_polar_text[] = {
176     N_("Horizontal"), N_("Vertical"),
177     N_("Circular Left"), N_("Circular Right") };
178 #define RANGE_TEXT N_("Satellite Range Code")
179 #define RANGE_LONGTEXT N_("Satellite Range Code as defined by manufacturer " \
180    "e.g. DISEqC switch code")
181 #define NAME_TEXT N_("Network Name")
182 #define NAME_LONGTEXT N_("Unique network name in the System Tuning Spaces")
183 #define CREATE_TEXT N_("Network Name to Create")
184 #define CREATE_LONGTEXT N_("Create Unique name in the System Tuning Spaces")
185
186 vlc_module_begin ()
187     set_shortname( N_("DVB") )
188     set_description( N_("DirectShow DVB input") )
189     set_category( CAT_INPUT )
190     set_subcategory( SUBCAT_INPUT_ACCESS )
191
192     add_integer( "dvb-caching", DEFAULT_PTS_DELAY / 1000, NULL, CACHING_TEXT,
193                  CACHING_LONGTEXT, true )
194     add_integer( "dvb-frequency", 0, NULL, FREQ_TEXT, FREQ_LONGTEXT,
195                  false )
196 #   if defined(WIN32) || defined(WINCE)
197         add_string( "dvb-network-name", NULL, NULL, NAME_TEXT, NAME_LONGTEXT,
198                     true )
199         add_string( "dvb-create-name", NULL, NULL, CREATE_TEXT,
200                     CREATE_LONGTEXT, true )
201         add_integer( "dvb-adapter", -1, NULL, ADAPTER_TEXT, ADAPTER_LONGTEXT,
202                      true )
203 #   else
204         /* dvb-device refers to a frontend within an adapter */
205         add_integer( "dvb-device", 0, NULL, DEVICE_TEXT, DEVICE_LONGTEXT,
206                      true )
207         add_bool( "dvb-probe", 1, NULL, PROBE_TEXT, PROBE_LONGTEXT, true )
208         add_bool( "dvb-budget-mode", 0, NULL, BUDGET_TEXT, BUDGET_LONGTEXT,
209                   true )
210 #   endif
211
212     /* DVB-S (satellite) */
213     add_integer( "dvb-inversion", 2, NULL, INVERSION_TEXT,
214         INVERSION_LONGTEXT, true )
215         change_integer_list( i_inversion_list, ppsz_inversion_text, NULL )
216 #   if defined(WIN32) || defined(WINCE)
217         add_string( "dvb-polarisation", NULL, NULL, POLARISATION_TEXT,
218             POLARISATION_LONGTEXT, false )
219             change_string_list( ppsz_polar_list, ppsz_polar_text, 0 )
220             /* Note: Polaristion H = voltage 18; V = voltage 13; */
221         add_integer( "dvb-network-id", 0, NULL, NETID_TEXT, NETID_LONGTEXT,
222             true )
223         add_integer( "dvb-azimuth", 0, NULL, AZIMUTH_TEXT, AZIMUTH_LONGTEXT,
224             true )
225         add_integer( "dvb-elevation", 0, NULL, ELEVATION_TEXT,
226             ELEVATION_LONGTEXT, true )
227         add_integer( "dvb-longitude", 0, NULL, LONGITUDE_TEXT,
228             LONGITUDE_LONGTEXT, true )
229         add_string( "dvb-range", NULL, NULL, RANGE_TEXT,
230             RANGE_LONGTEXT, true )
231         /* dvb-range corresponds to the BDA InputRange parameter which is
232          * used by some drivers to control the diseqc */
233 #   else
234         add_integer( "dvb-satno", 0, NULL, SATNO_TEXT, SATNO_LONGTEXT,
235             true )
236         add_integer( "dvb-voltage", 13, NULL, VOLTAGE_TEXT, VOLTAGE_LONGTEXT,
237             true )
238         add_bool( "dvb-high-voltage", 0, NULL, HIGH_VOLTAGE_TEXT,
239             HIGH_VOLTAGE_LONGTEXT, true )
240         add_integer( "dvb-tone", -1, NULL, TONE_TEXT, TONE_LONGTEXT,
241             true )
242         add_integer( "dvb-fec", 9, NULL, FEC_TEXT, FEC_LONGTEXT, true )
243 #   endif
244     add_integer( "dvb-lnb-lof1", 0, NULL, LNB_LOF1_TEXT,
245         LNB_LOF1_LONGTEXT, true )
246     add_integer( "dvb-lnb-lof2", 0, NULL, LNB_LOF2_TEXT,
247         LNB_LOF2_LONGTEXT, true )
248     add_integer( "dvb-lnb-slof", 0, NULL, LNB_SLOF_TEXT,
249         LNB_SLOF_LONGTEXT, true )
250     add_integer( "dvb-srate", 27500, NULL, SRATE_TEXT, SRATE_LONGTEXT,
251         false )
252
253     /* DVB-C (cable) */
254     add_integer( "dvb-modulation", -1, NULL, MODULATION_TEXT,
255         MODULATION_LONGTEXT, true )
256         change_integer_list( i_mod_list, ppsz_mod_text, NULL )
257
258     /* ATSC */
259     add_integer( "dvb-major-channel", 0, NULL, MAJOR_CHANNEL_TEXT,
260         MAJOR_CHANNEL_LONGTEXT, true )
261      add_integer( "dvb-minor-channel", 0, NULL, MINOR_CHANNEL_TEXT,
262         MINOR_CHANNEL_LONGTEXT, true )
263      add_integer( "dvb-physical-channel", 0, NULL, PHYSICAL_CHANNEL_TEXT,
264         PHYSICAL_CHANNEL_LONGTEXT, true )
265
266     /* DVB-T (terrestrial) */
267     add_integer( "dvb-code-rate-hp", -1, NULL, CODE_RATE_HP_TEXT,
268         CODE_RATE_HP_LONGTEXT, true )
269         change_integer_list( i_hp_fec_list, ppsz_hp_fec_text, NULL )
270     add_integer( "dvb-code-rate-lp", -1, NULL, CODE_RATE_LP_TEXT,
271         CODE_RATE_LP_LONGTEXT, true )
272         change_integer_list( i_lp_fec_list, ppsz_lp_fec_text, NULL )
273     add_integer( "dvb-bandwidth", 0, NULL, BANDWIDTH_TEXT, BANDWIDTH_LONGTEXT,
274         false )
275         change_integer_list( i_band_list, ppsz_band_text, NULL )
276     add_integer( "dvb-guard", -1, NULL, GUARD_TEXT, GUARD_LONGTEXT, true )
277         change_integer_list( i_guard_list, ppsz_guard_text, NULL )
278     add_integer( "dvb-transmission", -1, NULL, TRANSMISSION_TEXT,
279         TRANSMISSION_LONGTEXT, true )
280         change_integer_list( i_transmission_list, ppsz_transmission_text, NULL )
281     add_integer( "dvb-hierarchy", -1, NULL, HIERARCHY_TEXT, HIERARCHY_LONGTEXT,
282         true )
283         change_integer_list( i_hierarchy_list, ppsz_hierarchy_text, NULL )
284
285     set_capability( "access", 0 )
286     add_shortcut( "dvb" )      /* Generic name */
287
288     add_shortcut( "dvb-s" )    /* Satellite */
289     add_shortcut( "dvbs" )
290     add_shortcut( "qpsk" )
291     add_shortcut( "satellite" )
292
293     add_shortcut( "dvb-c" )    /* Cable */
294     add_shortcut( "dvbc" )
295     add_shortcut( "qam" )
296     add_shortcut( "cable" )
297
298     add_shortcut( "dvbt" )    /* Terrestrial */
299     add_shortcut( "dvb-t" )
300     add_shortcut( "ofdm" )
301     add_shortcut( "terrestrial" )
302
303     add_shortcut( "atsc" )     /* Atsc */
304     add_shortcut( "usdigital" )
305
306     set_callbacks( Open, Close )
307 vlc_module_end ()
308
309 /*****************************************************************************
310  * Open: open direct show device as an access module
311  *****************************************************************************/
312 static int Open( vlc_object_t *p_this )
313 {
314     access_t     *p_access = (access_t*)p_this;
315     access_sys_t *p_sys;
316     const char* psz_module  = "dvb";
317     const int   i_param_count = 26;
318     const char* psz_param[] = { "frequency", "bandwidth",
319         "srate", "azimuth", "elevation", "longitude", "polarisation",
320         "modulation", "caching", "lnb-lof1", "lnb-lof2", "lnb-slof",
321         "inversion", "network-id", "code-rate-hp", "code-rate-lp",
322         "guard", "transmission", "hierarchy", "range", "network-name",
323         "create-name", "major-channel", "minor-channel", "physical-channel",
324         "adapter" };
325
326     const int   i_type[] = { VLC_VAR_INTEGER, VLC_VAR_INTEGER,
327         VLC_VAR_INTEGER, VLC_VAR_INTEGER, VLC_VAR_INTEGER, VLC_VAR_INTEGER,
328         VLC_VAR_STRING, VLC_VAR_INTEGER, VLC_VAR_INTEGER, VLC_VAR_INTEGER,
329         VLC_VAR_INTEGER, VLC_VAR_INTEGER, VLC_VAR_INTEGER, VLC_VAR_INTEGER,
330         VLC_VAR_INTEGER, VLC_VAR_INTEGER, VLC_VAR_INTEGER, VLC_VAR_INTEGER,
331         VLC_VAR_INTEGER, VLC_VAR_STRING, VLC_VAR_STRING, VLC_VAR_STRING,
332         VLC_VAR_INTEGER, VLC_VAR_INTEGER, VLC_VAR_INTEGER, VLC_VAR_INTEGER };
333
334     char  psz_full_name[128];
335     int i_ret;
336
337    /* Only if selected */
338     if( *p_access->psz_access == '\0' )
339         return VLC_EGENERIC;
340
341     /* Setup Access */
342     p_access->pf_read = NULL;
343     p_access->pf_block = Block;     /* Function to read compressed data */
344     p_access->pf_control = Control; /* Function to control the module */
345     p_access->pf_seek = NULL;
346     p_access->info.i_update = 0;
347     p_access->info.i_size = 0;
348     p_access->info.i_pos = 0;
349     p_access->info.b_eof = false;
350     p_access->info.i_title = 0;
351     p_access->info.i_seekpoint = 0;
352     p_access->p_sys = p_sys = calloc( 1, sizeof( access_sys_t ) );
353     if( !p_sys )
354         return VLC_ENOMEM;
355
356     for( int i = 0; i < i_param_count; i++ )
357     {
358         snprintf( psz_full_name, 128, "%s-%s\0", psz_module,
359                   psz_param[i] );
360         var_Create( p_access, psz_full_name, i_type[i] | VLC_VAR_DOINHERIT );
361     }
362
363     /* Parse the command line */
364     if( ParsePath( p_access, psz_module, i_param_count, psz_param, i_type ) )
365     {
366         free( p_sys );
367         return VLC_EGENERIC;
368     }
369
370     /* Build directshow graph */
371     dvb_newBDAGraph( p_access );
372
373     i_ret = VLC_EGENERIC;
374
375     if( strncmp( p_access->psz_access, "qpsk", 4 ) == 0 ||
376         strncmp( p_access->psz_access, "dvb-s", 5 ) == 0 ||
377         strncmp( p_access->psz_access, "dvbs", 4 ) == 0 ||
378         strncmp( p_access->psz_access, "satellite", 9 ) == 0 )
379     {
380         i_ret = dvb_SubmitDVBSTuneRequest( p_access );
381     }
382     if( strncmp( p_access->psz_access, "cable", 5 ) == 0 ||
383         strncmp( p_access->psz_access, "dvb-c", 5 ) == 0  ||
384         strncmp( p_access->psz_access, "dvbc", 4 ) == 0  ||
385         strncmp( p_access->psz_access, "qam", 3 ) == 0 )
386     {
387         i_ret = dvb_SubmitDVBCTuneRequest( p_access );
388     }
389     if( strncmp( p_access->psz_access, "terrestrial", 11 ) == 0 ||
390         strncmp( p_access->psz_access, "dvb-t", 5 ) == 0 ||
391         strncmp( p_access->psz_access, "ofdm", 4 ) == 0 ||
392         strncmp( p_access->psz_access, "dvbt", 4 ) == 0 )
393     {
394         i_ret = dvb_SubmitDVBTTuneRequest( p_access );
395     }
396     if( strncmp( p_access->psz_access, "usdigital", 9 ) == 0 ||
397         strncmp( p_access->psz_access, "atsc", 4 ) == 0 )
398     {
399         i_ret = dvb_SubmitATSCTuneRequest( p_access );
400     }
401     if( !strcmp( p_access->psz_access, "dvb" ) )
402     {
403         /* Try to auto detect */
404         if( i_ret )
405             i_ret = dvb_SubmitDVBSTuneRequest( p_access );
406         if( i_ret )
407             i_ret = dvb_SubmitDVBCTuneRequest( p_access );
408         if( i_ret )
409             i_ret = dvb_SubmitDVBTTuneRequest( p_access );
410         if( i_ret )
411             i_ret = dvb_SubmitATSCTuneRequest( p_access );
412     }
413
414     if( !i_ret )
415         p_access->psz_demux = strdup( "ts" );
416     else
417         msg_Warn( p_access, "DVB_Open: Unsupported Network %s",
418                   p_access->psz_access);
419     return i_ret;
420 }
421
422 /*****************************************************************************
423  * ParsePath:
424  * Parses the path passed to VLC treating it as a MRL which
425  * is organized as a sequence of <key>=<value> pairs separated by a colon
426  * e.g. :key1=value1:key2=value2:key3=value3.
427  * Each <key> is matched to one of the parameters passed in psz_param using
428  * whatever characters are provided. e.g. fr = fre = frequency
429  *****************************************************************************/
430 static int ParsePath( access_t *p_access, const char* psz_module,
431     const int i_param_count, const char** psz_param, const int* i_type )
432 {
433     const int   MAXPARAM = 40;
434     bool        b_used[MAXPARAM];
435     char*       psz_parser;
436     char*       psz_token;
437     char*       psz_value;
438     vlc_value_t v_value;
439     size_t      i_token_len, i_param_len;
440     int         i_this_param;
441     char        psz_full_name[128];
442
443     if( i_param_count > MAXPARAM )
444     {
445         msg_Warn( p_access, "ParsePath: Too many parameters: %d > %d",
446             i_param_count, MAXPARAM );
447             return VLC_EGENERIC;
448     }
449     for( int i = 0; i < i_param_count; i++ )
450         b_used[i] = false;
451     psz_parser = p_access->psz_path;
452     if( strlen( psz_parser ) <= 0 )
453         return VLC_SUCCESS;
454
455     i_token_len = strcspn( psz_parser, ":" );
456     if( i_token_len <= 0 )
457         i_token_len  = strcspn( ++psz_parser, ":" );
458
459     do
460     {
461         psz_token = strndup( psz_parser, i_token_len );
462         i_param_len  = strcspn( psz_token, "=" );
463         if( i_param_len <= 0 )
464         {
465             msg_Warn( p_access, "ParsePath: Unspecified parameter %s",
466                 psz_token );
467             free( psz_token );
468             return VLC_EGENERIC;
469         }
470         i_this_param = -1;
471         for( int i = 0; i < i_param_count; i++ )
472         {
473             if( strncmp( psz_token, psz_param[i], i_param_len ) == 0 )
474             {
475                 i_this_param = i;
476                 break;
477             }
478         }
479         if( i_this_param < 0 )
480         {
481             msg_Warn( p_access, "ParsePath: Unknown parameter %s", psz_token );
482             free( psz_token );
483             return VLC_EGENERIC;
484         }
485         if( b_used[i_this_param] )
486         {
487             msg_Warn( p_access, "ParsePath: Duplicate parameter %s",
488                 psz_token );
489             free( psz_token );
490             return VLC_EGENERIC;
491         }
492         b_used[i_this_param] = true;
493
494         /* if "=" was found in token then value starts at
495          * psz_token + i_paramlen + 1
496          * else there is no value specified so we use an empty string */
497         psz_value = psz_token + i_param_len + 1;
498         if( i_param_len >= i_token_len )
499             psz_value--;
500         if( i_type[i_this_param] == VLC_VAR_STRING )
501              v_value.psz_string = strdup( psz_value );
502         if( i_type[i_this_param] == VLC_VAR_INTEGER )
503              v_value.i_int = atol( psz_value );
504         snprintf( psz_full_name, 128, "%s-%s\0", psz_module,
505             psz_param[i_this_param] );
506         var_Set( p_access, psz_full_name, v_value );
507
508         free( psz_token );
509         if( i_token_len >= strlen( psz_parser ) )
510             break;
511         psz_parser += i_token_len + 1;
512         i_token_len = strcspn( psz_parser, ":" );
513     }
514     while( true );
515     return VLC_SUCCESS;
516 }
517
518 /*****************************************************************************
519  * AccessClose: close device
520  *****************************************************************************/
521 static void Close( vlc_object_t *p_this )
522 {
523     access_t     *p_access = (access_t *)p_this;
524     access_sys_t *p_sys    = p_access->p_sys;
525
526     dvb_deleteBDAGraph( p_access );
527
528     free( p_sys );
529 }
530
531 /*****************************************************************************
532  * Control:
533  *****************************************************************************/
534 static int Control( access_t *p_access, int i_query, va_list args )
535 {
536     bool   *pb_bool, b_bool;
537     int          *pi_int, i_int;
538     int64_t      *pi_64;
539
540     switch( i_query )
541     {
542     case ACCESS_CAN_SEEK:           /* 0 */
543     case ACCESS_CAN_FASTSEEK:       /* 1 */
544     case ACCESS_CAN_PAUSE:          /* 2 */
545     case ACCESS_CAN_CONTROL_PACE:   /* 3 */
546         pb_bool = (bool*)va_arg( args, bool* );
547         *pb_bool = false;
548         break;
549     case ACCESS_GET_PTS_DELAY:      /* 5 */
550         pi_64 = (int64_t*)va_arg( args, int64_t * );
551         *pi_64 = var_GetInteger( p_access, "dvb-caching" ) * 1000;
552         break;
553         /* */
554     case ACCESS_GET_TITLE_INFO:     /* 6 */
555     case ACCESS_GET_META:           /* 7 */
556     case ACCESS_SET_PAUSE_STATE:    /* 8 */
557     case ACCESS_SET_TITLE:          /* 9 */
558     case ACCESS_SET_SEEKPOINT:      /* 10 */
559     case ACCESS_GET_CONTENT_TYPE:
560         return VLC_EGENERIC;
561
562     case ACCESS_SET_PRIVATE_ID_STATE: /* 11 */
563         i_int  = (int)va_arg( args, int );
564         b_bool = (bool)va_arg( args, int );
565         break;
566     case ACCESS_SET_PRIVATE_ID_CA:  /* 12 -From Demux */
567         break;
568     default:
569         msg_Warn( p_access,
570                   "DVB_Control: Unimplemented query in control %d", i_query );
571         return VLC_EGENERIC;
572     }
573
574     return VLC_SUCCESS;
575 }
576
577 /*****************************************************************************
578  * Block:
579  *****************************************************************************/
580 static block_t *Block( access_t *p_access )
581 {
582     return dvb_Pop( p_access );
583 }