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