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