]> git.sesse.net Git - vlc/blobdiff - modules/access/dvb/access.c
DVB scan: re-enable the old plugin
[vlc] / modules / access / dvb / access.c
index c45696f9268d48717fc73e71ea17ac23e1032616..8bda64edb54e4e1de8d3d167802d6d328cea9cb1 100644 (file)
@@ -1,11 +1,13 @@
 /*****************************************************************************
  * access.c: DVB card input v4l2 only
  *****************************************************************************
- * Copyright (C) 1998-2004 VideoLAN
+ * Copyright (C) 1998-2010 the VideoLAN team
  *
  * Authors: Johan Bilien <jobi@via.ecp.fr>
- *          Jean-Paul Saman <jpsaman@wxs.nl>
+ *          Jean-Paul Saman <jpsaman _at_ videolan _dot_ org>
  *          Christophe Massiot <massiot@via.ecp.fr>
+ *          Laurent Aimar <fenrir@via.ecp.fr>
+ *          David Kaplan <david@2of1.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <vlc/vlc.h>
-#include <vlc/input.h>
-
-#include "../../demux/mpeg/system.h"
-
-#ifdef HAVE_UNISTD_H
-#   include <unistd.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
 #endif
 
-#include <fcntl.h>
+#include <vlc_common.h>
+#include <vlc_plugin.h>
+#include <vlc_access.h>
+#include <vlc_input.h>
+
 #include <sys/types.h>
+#include <poll.h>
 
-#ifdef HAVE_ERRNO_H
-#    include <string.h>
-#    include <errno.h>
-#endif
+#include <errno.h>
 
-#ifdef STRNCASECMP_IN_STRINGS_H
-#   include <strings.h>
-#endif
+/* Include dvbpsi headers */
+# include <dvbpsi/dvbpsi.h>
+# include <dvbpsi/descriptor.h>
+# include <dvbpsi/pat.h>
+# include <dvbpsi/pmt.h>
+# include <dvbpsi/dr.h>
+# include <dvbpsi/psi.h>
+# include <dvbpsi/demux.h>
+# include <dvbpsi/sdt.h>
 
 #include "dvb.h"
-
-#define SATELLITE_READ_ONCE 3
-
-/*****************************************************************************
- * Local prototypes
- *****************************************************************************/
-static int     Open( vlc_object_t *p_this );
-static void    Close( vlc_object_t *p_this );
-static ssize_t Read( input_thread_t * p_input, byte_t * p_buffer,
-                              size_t i_len);
-static int     SetArea    ( input_thread_t *, input_area_t * );
-static int     SetProgram ( input_thread_t *, pgrm_descriptor_t * );
-static void    Seek       ( input_thread_t *, off_t );
-static void    AllocateDemux( input_thread_t * p_input, int i_pid,
-                              int i_type );
-static void    CloseProgram( input_thread_t * p_input );
+#include "scan.h"
 
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
-#define CACHING_TEXT N_("Caching value in ms")
-#define CACHING_LONGTEXT N_( \
-    "Allows you to modify the default caching value for dvb streams. This " \
-    "value should be set in millisecond units." )
+static int  Open( vlc_object_t *p_this );
+static void Close( vlc_object_t *p_this );
 
-#define PROGRAM_TEXT N_("Program to decode")
-#define PROGRAM_LONGTEXT N_("This is a workaround for a bug in the input")
+#define PROBE_TEXT N_("Probe DVB card for capabilities")
+#define PROBE_LONGTEXT N_("Some DVB cards do not like to be probed for their capabilities, you can disable this feature if you experience some trouble.")
 
-#define ADAPTER_TEXT N_("Adapter card to tune")
-#define ADAPTER_LONGTEXT N_("Adapter cards have a device file in directory named /dev/dvb/adapter[n] with n>=0.")
+/* Satellite */
+#define SATELLITE_TEXT N_("Satellite scanning config")
+#define SATELLITE_LONGTEXT N_("filename of config file in share/dvb/dvb-s")
 
-#define DEVICE_TEXT N_("Device number to use on adapter")
-#define DEVICE_LONGTEXT ""
+vlc_module_begin ()
+    set_shortname( N_("DVB") )
+    set_description( N_("DVB input with v4l2 support") )
+    set_category( CAT_INPUT )
+    set_subcategory( SUBCAT_INPUT_ACCESS )
 
-#define FREQ_TEXT N_("Transponder/multiplex frequency")
-#define FREQ_LONGTEXT N_("In kHz for DVB-S or Hz for DVB-C/T")
+    add_bool( "dvb-probe", true, PROBE_TEXT, PROBE_LONGTEXT, true )
+    /* DVB-S (satellite) */
+    add_string( "dvb-satellite", NULL, SATELLITE_TEXT, SATELLITE_LONGTEXT,
+                true )
 
-#define INVERSION_TEXT N_("Inversion mode")
-#define INVERSION_LONGTEXT N_("Inversion mode [0=off, 1=on, 2=auto]")
+    set_capability( "access", 0 )
+    add_shortcut( "dvb",                        /* Generic name */
+                  "dvb-s", "qpsk", "satellite", /* Satellite */
+                  "dvb-c", "cable",             /* Cable */
+                  "dvb-t", "terrestrial" )      /* Terrestrial */
 
-#define PROBE_TEXT N_("Probe DVB card for capabilities")
-#define PROBE_LONGTEXT N_("Some DVB cards do not like to be probed for their capabilities.")
+    set_callbacks( Open, Close )
 
-#define LNB_LOF1_TEXT N_("Antenna lnb_lof1 (kHz)")
-#define LNB_LOF1_LONGTEXT ""
+vlc_module_end ()
 
-#define LNB_LOF2_TEXT N_("Antenna lnb_lof2 (kHz)")
-#define LNB_LOF2_LONGTEXT ""
 
-#define LNB_SLOF_TEXT N_("Antenna lnb_slof (kHz)")
-#define LNB_SLOF_LONGTEXT ""
+/*****************************************************************************
+ * Local prototypes
+ *****************************************************************************/
+static int Control( access_t *, int, va_list );
 
-/* Satellite */
-#define BUDGET_TEXT N_("Budget mode")
-#define BUDGET_LONGTEXT N_("This allows you to stream an entire transponder with a budget card. Budget mode is compatible with the ts2 demux.")
-
-#define SATNO_TEXT N_("Satellite number in the Diseqc system")
-#define SATNO_LONGTEXT N_("[0=no diseqc, 1-4=normal diseqc, -1=A, -2=B simple diseqc")
-
-#define VOLTAGE_TEXT N_("LNB voltage")
-#define VOLTAGE_LONGTEXT N_("In Volts [0, 13=vertical, 18=horizontal]")
-
-#define TONE_TEXT N_("22 kHz tone")
-#define TONE_LONGTEXT N_("[0=off, 1=on, -1=auto]")
-
-#define FEC_TEXT N_("Transponder FEC")
-#define FEC_LONGTEXT N_("FEC=Forward Error Correction mode [9=auto]")
-
-#define SRATE_TEXT N_("Transponder symbol rate in kHz")
-#define SRATE_LONGTEXT ""
-
-/* Cable */
-#define MODULATION_TEXT N_("Modulation type")
-#define MODULATION_LONGTEXT N_("Modulation type for front-end device.")
-
-/* Terrestrial */
-#define CODE_RATE_HP_TEXT N_("Terrestrial high priority stream code rate (FEC)")
-#define CODE_RATE_HP_LONGTEXT ""
-
-#define CODE_RATE_LP_TEXT N_("Terrestrial low priority stream code rate (FEC)")
-#define CODE_RATE_LP_LONGTEXT ""
-
-#define BANDWIDTH_TEXT N_("Terrestrial bandwidth")
-#define BANDWIDTH_LONGTEXT N_("Terrestrial bandwidth [0=auto,6,7,8 in MHz]")
-
-#define GUARD_TEXT N_("Terrestrial guard interval")
-#define GUARD_LONGTEXT ""
-
-#define TRANSMISSION_TEXT N_("Terrestrial transmission mode")
-#define TRANSMISSION_LONGTEXT ""
-
-#define HIERARCHY_TEXT N_("Terrestrial hierarchy mode")
-#define HIERARCHY_LONGTEXT ""
-
-vlc_module_begin();
-    set_shortname( _("DVB") );
-    set_description( N_("DVB input with v4l2 support") );
-
-    add_integer( "dvb-caching", DEFAULT_PTS_DELAY / 1000, NULL, CACHING_TEXT,
-                 CACHING_LONGTEXT, VLC_TRUE );
-    add_integer( "dvb-adapter", 0, NULL, ADAPTER_TEXT, ADAPTER_LONGTEXT,
-                 VLC_FALSE );
-    add_integer( "dvb-device", 0, NULL, DEVICE_TEXT, DEVICE_LONGTEXT,
-                 VLC_TRUE );
-    add_integer( "dvb-frequency", 11954000, NULL, FREQ_TEXT, FREQ_LONGTEXT,
-                 VLC_FALSE );
-    add_integer( "dvb-inversion", 2, NULL, INVERSION_TEXT, INVERSION_LONGTEXT,
-                 VLC_TRUE );
-    add_bool( "dvb-probe", 1, NULL, PROBE_TEXT, PROBE_LONGTEXT, VLC_TRUE );
-    add_integer( "dvb-lnb-lof1", 9750000, NULL, LNB_LOF1_TEXT,
-                 LNB_LOF1_LONGTEXT, VLC_TRUE );
-    add_integer( "dvb-lnb-lof2", 10600000, NULL, LNB_LOF2_TEXT,
-                 LNB_LOF2_LONGTEXT, VLC_TRUE );
-    add_integer( "dvb-lnb-slof", 11700000, NULL, LNB_SLOF_TEXT,
-                 LNB_SLOF_LONGTEXT, VLC_TRUE );
-    /* DVB-S (satellite) */
-    add_bool( "dvb-budget-mode", 0, NULL, BUDGET_TEXT, BUDGET_LONGTEXT,
-              VLC_TRUE );
-    add_integer( "dvb-satno", 0, NULL, SATNO_TEXT, SATNO_LONGTEXT,
-                 VLC_TRUE );
-    add_integer( "dvb-voltage", 13, NULL, VOLTAGE_TEXT, VOLTAGE_LONGTEXT,
-                 VLC_TRUE );
-    add_integer( "dvb-tone", -1, NULL, TONE_TEXT, TONE_LONGTEXT,
-                 VLC_TRUE );
-    add_integer( "dvb-fec", 9, NULL, FEC_TEXT, FEC_LONGTEXT, VLC_TRUE );
-    add_integer( "dvb-srate", 27500000, NULL, SRATE_TEXT, SRATE_LONGTEXT,
-                 VLC_FALSE );
-    /* DVB-T (terrestrial) */
-    add_integer( "dvb-modulation", 0, NULL, MODULATION_TEXT,
-                 MODULATION_LONGTEXT, VLC_TRUE );
-    /* DVB-T (terrestrial) */
-    add_integer( "dvb-code-rate-hp", 9, NULL, CODE_RATE_HP_TEXT,
-                 CODE_RATE_HP_LONGTEXT, VLC_TRUE );
-    add_integer( "dvb-code-rate-lp", 9, NULL, CODE_RATE_LP_TEXT,
-                 CODE_RATE_LP_LONGTEXT, VLC_TRUE );
-    add_integer( "dvb-bandwidth", 0, NULL, BANDWIDTH_TEXT, BANDWIDTH_LONGTEXT,
-                 VLC_TRUE );
-    add_integer( "dvb-guard", 0, NULL, GUARD_TEXT, GUARD_LONGTEXT, VLC_TRUE );
-    add_integer( "dvb-transmission", 0, NULL, TRANSMISSION_TEXT,
-                 TRANSMISSION_LONGTEXT, VLC_TRUE );
-    add_integer( "dvb-hierarchy", 0, NULL, HIERARCHY_TEXT, HIERARCHY_LONGTEXT,
-                 VLC_TRUE );
-
-    set_capability( "access", 0 );
-    add_shortcut( "dvb" );
-    add_shortcut( "dvb-s" );
-    add_shortcut( "qpsk" );
-    add_shortcut( "dvb-c" );
-    add_shortcut( "cable" );
-    add_shortcut( "dvb-t" );
-    add_shortcut( "terrestrial" );
-    add_shortcut( "satellite" );    /* compatibility with the interface. */
-    set_callbacks( Open, Close );
-vlc_module_end();
+static block_t *BlockScan( access_t * );
+
+#define DVB_READ_ONCE 20
+#define DVB_READ_ONCE_START 2
+#define DVB_READ_ONCE_SCAN 1
+#define TS_PACKET_SIZE 188
+
+#define DVB_SCAN_MAX_SIGNAL_TIME (1000*1000)
+#define DVB_SCAN_MAX_LOCK_TIME (5000*1000)
+#define DVB_SCAN_MAX_PROBE_TIME (45000*1000)
+
+static void FilterUnset( access_t *, int i_max );
+static void FilterSet( access_t *, int i_pid, int i_type );
+
+static void VarInit( access_t * );
+static int  ParseMRL( access_t * );
 
 /*****************************************************************************
  * Open: open the frontend device
  *****************************************************************************/
-#define GET_OPTION_INT( option )                                            \
-    if ( !strncmp( psz_parser, option "=", strlen(option "=") ) )           \
-    {                                                                       \
-        val.i_int = strtol( psz_parser + strlen(option "="), &psz_parser,   \
-                            0 );                                            \
-        var_Set( p_input, "dvb-" option, val );                             \
-    }
-
-#define GET_OPTION_BOOL( option )                                           \
-    if ( !strncmp( psz_parser, option "=", strlen(option "=") ) )           \
-    {                                                                       \
-        val.b_bool = strtol( psz_parser + strlen(option "="), &psz_parser,  \
-                             0 );                                           \
-        var_Set( p_input, "dvb-" option, val );                             \
-    }
-
 static int Open( vlc_object_t *p_this )
 {
-    input_thread_t *    p_input = (input_thread_t *)p_this;
-    thread_dvb_data_t * p_dvb;
-    char *              psz_parser;
-    char *              psz_next;
-    vlc_value_t         val;
-    int                 i_test;
+    access_t     *p_access = (access_t*)p_this;
+    access_sys_t *p_sys;
 
-    /* Initialize structure */
-    p_dvb = (thread_dvb_data_t *)malloc( sizeof( thread_dvb_data_t ) );
-    if( p_dvb == NULL )
-    {
-        msg_Err( p_input, "out of memory" );
-        return -1;
-    }
-    memset( p_dvb, 0, sizeof(thread_dvb_data_t) );
-    p_input->p_access_data = (void *)p_dvb;
+    /* Only if selected */
+    if( *p_access->psz_access == '\0' )
+        return VLC_EGENERIC;
 
-    /* Register callback functions */
-    p_input->pf_read = Read;
-    p_input->pf_set_program = SetProgram;
-    p_input->pf_set_area = SetArea;
-    p_input->pf_seek = Seek;
+    p_access->p_sys = p_sys = calloc( 1, sizeof( access_sys_t ) );
+    if( !p_sys )
+        return VLC_ENOMEM;
 
-    /* Parse the options passed in command line */
+    /* Create all variables */
+    VarInit( p_access );
 
-    psz_parser = strdup( p_input->psz_name );
-    if ( !psz_parser )
+    /* Parse the command line */
+    if( ParseMRL( p_access ) )
     {
-        free( p_dvb );
-        return( -1 );
+        free( p_sys );
+        var_Destroy( p_access, "dvb-modulation" );
+        var_Destroy( p_access, "dvb-fec" );
+        var_Destroy( p_access, "dvb-code-rate-hp" );
+        var_Destroy( p_access, "dvb-code-rate-lp" );
+        var_Destroy( p_access, "dvb-guard" );
+        return VLC_EGENERIC;
     }
 
-    var_Create( p_input, "dvb-caching", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
-    var_Get( p_input, "dvb-caching", &val );
-    p_input->i_pts_delay = val.i_int * 1000;
-
-    var_Create( p_input, "dvb-adapter", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
-    var_Create( p_input, "dvb-device", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
-    var_Create( p_input, "dvb-frequency", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
-    var_Create( p_input, "dvb-inversion", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
-    var_Create( p_input, "dvb-probe", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
-    var_Create( p_input, "dvb-lnb-lof1", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
-    var_Create( p_input, "dvb-lnb-lof2", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
-    var_Create( p_input, "dvb-lnb-slof", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
-
-    var_Create( p_input, "dvb-budget-mode", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
-    var_Create( p_input, "dvb-satno", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
-    var_Create( p_input, "dvb-voltage", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
-    var_Create( p_input, "dvb-tone", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
-    var_Create( p_input, "dvb-fec", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
-    var_Create( p_input, "dvb-srate", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
-
-    var_Create( p_input, "dvb-modulation", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
-
-    var_Create( p_input, "dvb-code-rate-hp", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
-    var_Create( p_input, "dvb-code-rate-lp", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
-    var_Create( p_input, "dvb-bandwidth", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
-    var_Create( p_input, "dvb-transmission", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
-    var_Create( p_input, "dvb-guard", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
-    var_Create( p_input, "dvb-hierarchy", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
-
-    i_test = strtol( psz_parser, &psz_next, 10 );
-    if ( psz_next == psz_parser )
+    bool b_scan_mode = var_GetInteger( p_access, "dvb-frequency" ) == 0;
+    if( b_scan_mode )
     {
-        for ( ; ; )
-        {
-            GET_OPTION_INT("adapter")
-            else GET_OPTION_INT("device")
-            else GET_OPTION_INT("frequency")
-            else GET_OPTION_INT("inversion")
-            else GET_OPTION_BOOL("probe")
-            else GET_OPTION_INT("lnb-lof1")
-            else GET_OPTION_INT("lnb-lof2")
-            else GET_OPTION_INT("lnb-slof")
-
-            else GET_OPTION_BOOL("budget-mode")
-            else GET_OPTION_INT("voltage")
-            else GET_OPTION_INT("tone")
-            else GET_OPTION_INT("fec")
-            else GET_OPTION_INT("srate")
-
-            else GET_OPTION_INT("modulation")
-
-            else GET_OPTION_INT("code-rate-hp")
-            else GET_OPTION_INT("code-rate-lp")
-            else GET_OPTION_INT("bandwidth")
-            else GET_OPTION_INT("transmission")
-            else GET_OPTION_INT("guard")
-            else GET_OPTION_INT("hierarchy")
-
-            else if( !strncmp( psz_parser, "satno=",
-                               strlen( "satno=" ) ) )
-            {
-                psz_parser += strlen( "satno=" );
-                if ( *psz_parser == 'A' || *psz_parser == 'a' )
-                    val.i_int = -1;
-                else if ( *psz_parser == 'B' || *psz_parser == 'b' )
-                    val.i_int = -2;
-                else
-                    val.i_int = strtol( psz_parser, &psz_parser, 0 );
-                var_Set( p_input, "dvb-satno", val );
-            }
-            /* Redundant with voltage but much easier to use */
-            else if( !strncmp( psz_parser, "polarization=",
-                               strlen( "polarization=" ) ) )
-            {
-                psz_parser += strlen( "polarization=" );
-                if ( *psz_parser == 'V' || *psz_parser == 'v' )
-                    val.i_int = 13;
-                else if ( *psz_parser == 'H' || *psz_parser == 'h' )
-                    val.i_int = 18;
-                else
-                {
-                    msg_Err( p_input, "illegal polarization %c", *psz_parser );
-                    free( p_dvb );
-                    return -1;
-                }
-                var_Set( p_input, "dvb-voltage", val );
-            }
-            if ( *psz_parser )
-                psz_parser++;
-            else
-                break;
-        }
+        msg_Dbg( p_access, "DVB scan mode selected" );
+        p_access->pf_block = BlockScan;
     }
     else
-    {
-        msg_Err( p_input, "the DVB input old syntax is deprecated, use vlc " \
-                 "-p dvb to see an explanation of the new syntax" );
-        free( p_dvb );
-        return -1;
-    }
+        return VLC_EGENERIC; /* let the DTV plugin do the work */
 
     /* Getting frontend info */
-    if ( E_(FrontendOpen)( p_input ) < 0 )
+    if( FrontendOpen( p_access) )
     {
-        free( p_dvb );
-        return -1;
+        free( p_sys );
+        return VLC_EGENERIC;
     }
 
-    /* Setting frontend parameters for tuning the hardware */      
-    msg_Dbg( p_input, "trying to tune the frontend...");
-    if ( E_(FrontendSet)( p_input ) < 0 )
+    /* Opening DVR device */
+    if( DVROpen( p_access ) < 0 )
     {
-        E_(FrontendClose)( p_input );
-        free( p_dvb );
-        return -1;
+        FrontendClose( p_access );
+        free( p_sys );
+        return VLC_EGENERIC;
     }
 
-    /* Opening DVR device */      
-    if ( E_(DVROpen)( p_input ) < 0 )
     {
-        E_(FrontendClose)( p_input );
-        free( p_dvb );
-        return -1;
-    }
+        scan_parameter_t parameter;
+        scan_t *p_scan;
 
-    var_Get( p_input, "dvb-budget-mode", &val );
-    p_dvb->b_budget_mode = val.b_bool;
-    if ( val.b_bool )
-    {
-        msg_Dbg( p_input, "setting filter on all PIDs" );
-        AllocateDemux( p_input, 0x2000, OTHER_TYPE );
-    }
-    else
-    {
-        msg_Dbg( p_input, "setting filter on PAT" );
-        AllocateDemux( p_input, 0x0, OTHER_TYPE );
-    }
+        msg_Dbg( p_access, "setting filter on PAT/NIT/SDT (DVB only)" );
+        FilterSet( p_access, 0x00, OTHER_TYPE );    // PAT
+        FilterSet( p_access, 0x10, OTHER_TYPE );    // NIT
+        FilterSet( p_access, 0x11, OTHER_TYPE );    // SDT
 
-    if( input_InitStream( p_input, sizeof( stream_ts_data_t ) ) == -1 )
-    {
-        msg_Err( p_input, "could not initialize stream structure" );
-       E_(FrontendClose)( p_input );
-        close( p_dvb->i_handle );
-        free( p_dvb );
-        return( -1 );
+        if( FrontendGetScanParameter( p_access, &parameter ) ||
+            (p_scan = scan_New( VLC_OBJECT(p_access), &parameter )) == NULL )
+        {
+            Close( VLC_OBJECT(p_access) );
+            return VLC_EGENERIC;
+        }
+        p_sys->scan = p_scan;
+        p_sys->i_read_once = DVB_READ_ONCE_SCAN;
     }
 
-    vlc_mutex_lock( &p_input->stream.stream_lock );
-
-    p_input->stream.b_pace_control = 0;
-    p_input->stream.b_seekable = 0;
-    p_input->stream.p_selected_area->i_tell = 0;
+    /* Set up access */
+    free( p_access->psz_demux );
+    p_access->psz_demux = strdup( "m3u8" );
+    p_access->pf_read = NULL;
+    p_access->pf_control = Control;
+    p_access->pf_seek = NULL;
+    access_InitFields( p_access );
 
-    vlc_mutex_unlock( &p_input->stream.stream_lock );
-
-    p_input->i_mtu = SATELLITE_READ_ONCE * TS_PACKET_SIZE;
-    p_input->stream.i_method = INPUT_METHOD_SATELLITE;
-
-    return 0;
+    return VLC_SUCCESS;
 }
 
 /*****************************************************************************
@@ -425,261 +202,428 @@ static int Open( vlc_object_t *p_this )
  *****************************************************************************/
 static void Close( vlc_object_t *p_this )
 {
-    input_thread_t *    p_input = (input_thread_t *)p_this;
-    thread_dvb_data_t * p_dvb = (thread_dvb_data_t *)p_input->p_access_data;
+    access_t     *p_access = (access_t*)p_this;
+    access_sys_t *p_sys = p_access->p_sys;
 
-    if ( !p_dvb->b_budget_mode )
-    {
-        CloseProgram( p_input );
-    }
-    if ( p_dvb->p_demux_handles[0].i_type )
-    {
-        E_(DMXUnsetFilter)( p_input, p_dvb->p_demux_handles[0].i_handle );
-        p_dvb->p_demux_handles[0].i_type = 0;
-    }
-    E_(DVRClose)( p_input );
-    E_(FrontendClose)( p_input );
-    free( p_dvb );
+    FilterUnset( p_access, MAX_DEMUX );
+
+    DVRClose( p_access );
+    FrontendClose( p_access );
+    scan_Destroy( p_sys->scan );
+
+    free( p_sys );
 }
 
 /*****************************************************************************
- * Read: reads data from the satellite card
+ * BlockScan:
  *****************************************************************************/
-static ssize_t Read( input_thread_t * p_input, byte_t * p_buffer,
-                     size_t i_len )
+static block_t *BlockScan( access_t *p_access )
 {
-    thread_dvb_data_t * p_dvb = (thread_dvb_data_t *)p_input->p_access_data;
-    ssize_t i_ret;
-    vlc_value_t val;
-    struct timeval timeout;
-    fd_set fds;
+    access_sys_t *p_sys = p_access->p_sys;
+    scan_t *p_scan = p_sys->scan;
+    scan_configuration_t cfg;
 
-    if ( !p_dvb->b_budget_mode && !p_dvb->p_demux_handles[1].i_type )
+    /* */
+    if( scan_Next( p_scan, &cfg ) )
     {
-        int i_program;
-        unsigned int i;
-        var_Get( p_input, "program", &val );
-        i_program = val.i_int;
+        const bool b_first_eof = !p_access->info.b_eof;
 
-        /* FIXME : this is not demux2-compatible */
-        for ( i = 0; i < p_input->stream.i_pgrm_number; i++ )
-        {
-            /* Only set a filter on the selected program : some boards
-             * (read: Dreambox) only have 8 filters, so you don't want to
-             * spend them on unwanted PMTs. --Meuuh */
-            if ( !i_program
-                   || p_input->stream.pp_programs[i]->i_number == i_program )
-            {
-                msg_Dbg( p_input, "setting filter on PMT pid %d",
-                         p_input->stream.pp_programs[i]->pp_es[0]->i_id );
-                AllocateDemux( p_input,
-                        p_input->stream.pp_programs[i]->pp_es[0]->i_id,
-                        OTHER_TYPE );
-            }
-        }
+        if( b_first_eof )
+            msg_Warn( p_access, "Scanning finished" );
+
+        /* */
+        p_access->info.b_eof = true;
+        return b_first_eof ? scan_GetM3U( p_scan ) : NULL;
     }
 
-    /* Find if some data is available. This won't work under Windows. */
+    /* */
+    scan_session_t *session = scan_session_New( VLC_OBJECT(p_access), &cfg );
+    if( session == NULL )
+        return NULL;
+
+    /* */
+    msg_Dbg( p_access, "Scanning frequency %d", cfg.i_frequency );
+    var_SetInteger( p_access, "dvb-frequency", cfg.i_frequency );
+    msg_Dbg( p_access, " bandwidth %d", cfg.i_bandwidth );
+    var_SetInteger( p_access, "dvb-bandwidth", cfg.i_bandwidth );
+    if ( cfg.i_fec )
+    {
+        msg_Dbg( p_access, " FEC %d", cfg.i_fec );
+        var_SetInteger( p_access, "dvb-fec", cfg.i_fec );
+    }
+    if ( cfg.c_polarization )
+        var_SetInteger( p_access, "dvb-voltage", cfg.c_polarization == 'H' ? 18 : 13 );
 
-    /* Initialize file descriptor set */
-    FD_ZERO( &fds );
-    FD_SET( p_dvb->i_handle, &fds );
+    if ( cfg.i_modulation )
+        var_SetInteger( p_access, "dvb-modulation", cfg.i_modulation );
 
-    /* We'll wait 0.5 second if nothing happens */
-    timeout.tv_sec = 0;
-    timeout.tv_usec = 500000;
+    if ( cfg.i_symbolrate )
+        var_SetInteger( p_access, "dvb-srate", cfg.i_symbolrate );
 
-    /* Find if some data is available */
-    while ( (i_ret = select( p_dvb->i_handle + 1, &fds,
-                             NULL, NULL, &timeout )) == 0
-             || (i_ret < 0 && errno == EINTR) )
+    /* Setting frontend parameters for tuning the hardware */
+    if( FrontendSet( p_access ) < 0 )
     {
-        FD_ZERO( &fds );
-        FD_SET( p_dvb->i_handle, &fds );
-        timeout.tv_sec = 0;
-        timeout.tv_usec = 500000;
-
-        if ( p_input->b_die || p_input->b_error )
-        {
-            return 0;
-        }
+        msg_Err( p_access, "Failed to tune the frontend" );
+        p_access->info.b_eof = true;
+        scan_session_Destroy( p_scan, session );
+        return NULL;
     }
 
-    if ( i_ret < 0 )
-    {
-#ifdef HAVE_ERRNO_H
-        msg_Err( p_input, "select error (%s)", strerror(errno) );
-#else
-        msg_Err( p_input, "select error" );
-#endif
-        return -1;
-    }
+    /* */
+    int64_t i_scan_start = mdate();
+
+    bool b_has_dvb_signal = false;
+    bool b_has_lock = false;
+    int i_best_snr = -1;
 
-    i_ret = read( p_dvb->i_handle, p_buffer, i_len );
-    if( i_ret < 0 )
+    for ( ; ; )
     {
-#ifdef HAVE_ERRNO_H
-        msg_Err( p_input, "read failed (%s)", strerror(errno) );
-#else
-        msg_Err( p_input, "read failed" );
-#endif
-    }
+        struct pollfd ufds[2];
+        int i_ret;
 
-    return i_ret;
-}
+        /* Initialize file descriptor sets */
+        memset (ufds, 0, sizeof (ufds));
+        ufds[0].fd = p_sys->i_handle;
+        ufds[0].events = POLLIN;
+        ufds[1].fd = p_sys->i_frontend_handle;
+        ufds[1].events = POLLPRI;
 
-/*****************************************************************************
- * SetArea : Does nothing
- *****************************************************************************/
-static int SetArea( input_thread_t * p_input, input_area_t * p_area )
-{
-    return -1;
-}
+        /* We'll wait 0.1 second if nothing happens */
+        /* Find if some data is available */
+        i_ret = poll( ufds, 2, 100 );
 
-/*****************************************************************************
- * SetProgram : Sets the card filters according to the selected program,
- *              and makes the appropriate changes to stream structure.
- *****************************************************************************/
-static int SetProgram( input_thread_t    * p_input,
-                       pgrm_descriptor_t * p_new_prg )
-{
-    thread_dvb_data_t * p_dvb = (thread_dvb_data_t *)p_input->p_access_data;
-    unsigned int i_es_index;
-    vlc_value_t val;
-    int i_video_type = VIDEO0_TYPE;
-    int i_audio_type = AUDIO0_TYPE;
+        if( !vlc_object_alive (p_access) || scan_IsCancelled( p_scan ) )
+            break;
 
-    if ( p_input->stream.p_selected_program )
-    {
-        for ( i_es_index = 0; /* 0 should be the PMT */
-                i_es_index < p_input->stream.p_selected_program->i_es_number;
-                i_es_index ++ )
+        if( i_ret <= 0 )
         {
-#define p_es p_input->stream.p_selected_program->pp_es[i_es_index]
-            if ( p_es->p_dec )
+            const mtime_t i_scan_time = mdate() - i_scan_start;
+            frontend_status_t status;
+
+            FrontendGetStatus( p_access, &status );
+
+            b_has_dvb_signal |= status.b_has_carrier;
+            b_has_lock |= status.b_has_lock;
+
+            if( ( !b_has_dvb_signal && i_scan_time > DVB_SCAN_MAX_SIGNAL_TIME ) ||
+                ( !b_has_lock && i_scan_time > DVB_SCAN_MAX_LOCK_TIME ) ||
+                ( i_scan_time > DVB_SCAN_MAX_PROBE_TIME ) )
             {
-                input_UnselectES( p_input , p_es );
+                msg_Dbg( p_access, "timed out scanning current frequency (s=%d l=%d)", b_has_dvb_signal, b_has_lock );
+                break;
             }
-#undef p_es
         }
-    }
 
-    if ( !p_dvb->b_budget_mode )
-    {
-        msg_Dbg( p_input, "unsetting filters on all pids" );
-        CloseProgram( p_input );
-        msg_Dbg( p_input, "setting filter on PMT pid %d",
-                 p_new_prg->pp_es[0]->i_id );
-        AllocateDemux( p_input, p_new_prg->pp_es[0]->i_id, OTHER_TYPE );
-    }
+        if( i_ret < 0 )
+        {
+            if( errno == EINTR )
+                continue;
 
-    for ( i_es_index = 1; i_es_index < p_new_prg->i_es_number;
-          i_es_index++ )
-    {
-#define p_es p_new_prg->pp_es[i_es_index]
-        switch( p_es->i_cat )
+            msg_Err( p_access, "poll error: %m" );
+            scan_session_Destroy( p_scan, session );
+
+            p_access->info.b_eof = true;
+            return NULL;
+        }
+
+        if( ufds[1].revents )
         {
-        case VIDEO_ES:
-            if ( !p_dvb->b_budget_mode )
+            frontend_statistic_t stat;
+
+            FrontendPoll( p_access );
+
+            if( !FrontendGetStatistic( p_access, &stat ) )
             {
-                msg_Dbg(p_input, "setting filter on video ES 0x%x",
-                        p_es->i_id);
-                /* Always set the filter. This may seem a little odd, but
-                 * it allows you to stream the video with demuxstream
-                 * without having a decoder or a stream output behind.
-                 * The result is you'll sometimes filter a PID which you
-                 * don't really want, but in the most common cases it
-                 * should be OK. --Meuuh */
-                AllocateDemux( p_input, p_es->i_id, i_video_type );
-                i_video_type += TYPE_INTERVAL;
+                if( stat.i_snr > i_best_snr )
+                    i_best_snr = stat.i_snr;
             }
-            input_SelectES( p_input, p_es );
-            break;
+        }
+
+        if ( p_sys->i_frontend_timeout && mdate() > p_sys->i_frontend_timeout )
+        {
+            msg_Warn( p_access, "no lock, tuning again" );
+            FrontendSet( p_access );
+        }
+
+        if ( ufds[0].revents )
+        {
+            const int i_read_once = 1;
+            block_t *p_block = block_New( p_access, i_read_once * TS_PACKET_SIZE );
 
-        case AUDIO_ES:
-            if ( !p_dvb->b_budget_mode )
+            if( ( i_ret = read( p_sys->i_handle, p_block->p_buffer,
+                                i_read_once * TS_PACKET_SIZE ) ) <= 0 )
             {
-                msg_Dbg(p_input, "setting filter on audio ES 0x%x",
-                        p_es->i_id);
-                AllocateDemux( p_input, p_es->i_id, i_audio_type );
-                i_audio_type += TYPE_INTERVAL;
+                msg_Warn( p_access, "read failed (%m)" );
+                block_Release( p_block );
+                continue;
             }
-            input_SelectES( p_input, p_es );
-            break;
-        default:
-            if ( !p_dvb->b_budget_mode )
+            p_block->i_buffer = i_ret;
+
+            /* */
+            if( scan_session_Push( session, p_block ) )
             {
-                msg_Dbg(p_input, "setting filter on other ES 0x%x",
-                        p_es->i_id);
-                AllocateDemux( p_input, p_es->i_id, OTHER_TYPE );
+                msg_Dbg( p_access, "finished scanning current frequency" );
+                break;
             }
-            input_SelectES( p_input, p_es );
-            break;
         }
-#undef p_es
     }
 
-    p_input->stream.p_selected_program = p_new_prg;
+    /* */
+    if( i_best_snr > 0 )
+        scan_service_SetSNR( session, i_best_snr );
 
-    /* Update the navigation variables without triggering a callback */
-    val.i_int = p_new_prg->i_number;
-    var_Change( p_input, "program", VLC_VAR_SETVALUE, &val, NULL );
-
-    return 0;
+    scan_session_Destroy( p_scan, session );
+    return NULL;
 }
 
 /*****************************************************************************
- * Seek: does nothing (not a seekable stream
+ * Control:
  *****************************************************************************/
-static void Seek( input_thread_t * p_input, off_t i_off )
+static int Control( access_t *p_access, int i_query, va_list args )
 {
-    ;
+    bool         *pb_bool;
+    int64_t      *pi_64;
+    double       *pf1, *pf2;
+    frontend_statistic_t stat;
+
+    switch( i_query )
+    {
+        /* */
+        case ACCESS_CAN_SEEK:
+        case ACCESS_CAN_FASTSEEK:
+        case ACCESS_CAN_PAUSE:
+        case ACCESS_CAN_CONTROL_PACE:
+            pb_bool = (bool*)va_arg( args, bool* );
+            *pb_bool = false;
+            break;
+        /* */
+        case ACCESS_GET_PTS_DELAY:
+            pi_64 = (int64_t*)va_arg( args, int64_t * );
+            *pi_64 = DEFAULT_PTS_DELAY;
+            break;
+
+        /* */
+        case ACCESS_SET_PAUSE_STATE:
+        case ACCESS_GET_TITLE_INFO:
+        case ACCESS_SET_TITLE:
+        case ACCESS_SET_SEEKPOINT:
+        case ACCESS_GET_CONTENT_TYPE:
+            return VLC_EGENERIC;
+
+        case ACCESS_GET_SIGNAL:
+            pf1 = (double*)va_arg( args, double * );
+            pf2 = (double*)va_arg( args, double * );
+
+            *pf1 = *pf2 = 0;
+            if( !FrontendGetStatistic( p_access, &stat ) )
+            {
+                *pf1 = (double)stat.i_snr / 65535.0;
+                *pf2 = (double)stat.i_signal_strenth / 65535.0;
+            }
+            return VLC_SUCCESS;
+
+        case ACCESS_SET_PRIVATE_ID_STATE:
+        case ACCESS_SET_PRIVATE_ID_CA:
+            return VLC_EGENERIC;
+
+        default:
+            msg_Warn( p_access, "unimplemented query in control" );
+            return VLC_EGENERIC;
+
+    }
+    return VLC_SUCCESS;
 }
 
 /*****************************************************************************
- * AllocateDemux:
+ * FilterSet/FilterUnset:
  *****************************************************************************/
-static void AllocateDemux( input_thread_t * p_input, int i_pid,
-                           int i_type )
+static void FilterSet( access_t *p_access, int i_pid, int i_type )
 {
-    thread_dvb_data_t * p_dvb = (thread_dvb_data_t *)p_input->p_access_data;
-    int                 i;
+    access_sys_t *p_sys = p_access->p_sys;
+    int i;
 
     /* Find first free slot */
-    for ( i = 0; i < MAX_DEMUX; i++ )
+    for( i = 0; i < MAX_DEMUX; i++ )
     {
-        if ( !p_dvb->p_demux_handles[i].i_type )
-        {
-            if ( E_(DMXSetFilter)( p_input, i_pid,
-                                   &p_dvb->p_demux_handles[i].i_handle,
-                                   i_type ) < 0 )
-            {
-                break;
-            }
-            p_dvb->p_demux_handles[i].i_type = i_type;
-            p_dvb->p_demux_handles[i].i_pid = i_pid;
+        if( !p_sys->p_demux_handles[i].i_type )
             break;
+
+        if( p_sys->p_demux_handles[i].i_pid == i_pid )
+            return; /* Already set */
+    }
+
+    if( i >= MAX_DEMUX )
+    {
+        msg_Err( p_access, "no free p_demux_handles !" );
+        return;
+    }
+
+    if( DMXSetFilter( p_access, i_pid,
+                           &p_sys->p_demux_handles[i].i_handle, i_type ) )
+    {
+        msg_Err( p_access, "DMXSetFilter failed" );
+        return;
+    }
+    p_sys->p_demux_handles[i].i_type = i_type;
+    p_sys->p_demux_handles[i].i_pid = i_pid;
+
+    if( p_sys->i_read_once < DVB_READ_ONCE )
+        p_sys->i_read_once++;
+}
+
+static void FilterUnset( access_t *p_access, int i_max )
+{
+    access_sys_t *p_sys = p_access->p_sys;
+    int i;
+
+    for( i = 0; i < i_max; i++ )
+    {
+        if( p_sys->p_demux_handles[i].i_type )
+        {
+            DMXUnsetFilter( p_access, p_sys->p_demux_handles[i].i_handle );
+            p_sys->p_demux_handles[i].i_type = 0;
         }
     }
 }
 
 /*****************************************************************************
- * CloseProgram:
+ * VarInit/ParseMRL:
  *****************************************************************************/
-static void CloseProgram( input_thread_t * p_input )
+static void VarInit( access_t *p_access )
 {
-    thread_dvb_data_t * p_dvb = (thread_dvb_data_t *)p_input->p_access_data;
-    int                 i;
+    var_Destroy( p_access, "dvb-modulation" );
+    var_Destroy( p_access, "dvb-fec" );
+    var_Destroy( p_access, "dvb-code-rate-hp" );
+    var_Destroy( p_access, "dvb-code-rate-lp" );
+    var_Destroy( p_access, "dvb-guard" );
+
+    /* */
+    var_Create( p_access, "dvb-adapter", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
+    var_Create( p_access, "dvb-device", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
+    var_Create( p_access, "dvb-frequency", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
+    var_Create( p_access, "dvb-inversion", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
+    var_Create( p_access, "dvb-probe", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
+
+    /* */
+    var_Create( p_access, "dvb-satellite", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
+    var_Create( p_access, "dvb-satno", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
+    var_Create( p_access, "dvb-voltage", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
+    var_Create( p_access, "dvb-high-voltage", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
+    var_Create( p_access, "dvb-tone", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
+    var_Create( p_access, "dvb-fec", VLC_VAR_INTEGER );
+    var_Create( p_access, "dvb-srate", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
+    var_Create( p_access, "dvb-lnb-lof1", VLC_VAR_INTEGER );
+    var_Create( p_access, "dvb-lnb-lof2", VLC_VAR_INTEGER );
+    var_Create( p_access, "dvb-lnb-slof", VLC_VAR_INTEGER );
+
+    /* */
+    var_Create( p_access, "dvb-modulation", VLC_VAR_INTEGER );
+
+    /* */
+    var_Create( p_access, "dvb-code-rate-hp", VLC_VAR_INTEGER );
+    var_Create( p_access, "dvb-code-rate-lp", VLC_VAR_INTEGER );
+    var_Create( p_access, "dvb-bandwidth", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
+    var_Create( p_access, "dvb-transmission", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
+    var_Create( p_access, "dvb-guard", VLC_VAR_INTEGER );
+    var_Create( p_access, "dvb-hierarchy", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
+}
+
+/* */
+static int ParseMRL( access_t *p_access )
+{
+    char *psz_dup = strdup( p_access->psz_location );
+    char *psz_parser = psz_dup;
+    vlc_value_t         val;
+
+#define GET_OPTION_INT( option )                                            \
+    if ( !strncmp( psz_parser, option "=", strlen(option "=") ) )           \
+    {                                                                       \
+        val.i_int = strtol( psz_parser + strlen(option "="), &psz_parser,   \
+                            0 );                                            \
+        var_Set( p_access, "dvb-" option, val );                            \
+    }
+
+#define GET_OPTION_BOOL( option )                                           \
+    if ( !strncmp( psz_parser, option "=", strlen(option "=") ) )           \
+    {                                                                       \
+        val.b_bool = strtol( psz_parser + strlen(option "="), &psz_parser,  \
+                             0 );                                           \
+        var_Set( p_access, "dvb-" option, val );                            \
+    }
 
-    for ( i = 1; i < MAX_DEMUX; i++ )
+#define GET_OPTION_STRING( option )                                         \
+    if ( !strncmp( psz_parser, option "=", strlen( option "=" ) ) )         \
+    {                                                                       \
+        psz_parser += strlen( option "=" );                                 \
+        val.psz_string = psz_parser;                                        \
+        char *p_save;                                                       \
+        char *tok = strtok_r(val.psz_string, ":", &p_save);                 \
+        val.psz_string[tok - val.psz_string - 1] = 0;                       \
+        var_Set( p_access, "dvb-" option, val );                            \
+        psz_parser += strlen( val.psz_string );                             \
+    }
+
+    while( *psz_parser )
     {
-        if ( p_dvb->p_demux_handles[i].i_type )
+        GET_OPTION_INT("adapter")
+        else GET_OPTION_INT("device")
+        else GET_OPTION_INT("frequency")
+        else GET_OPTION_INT("inversion")
+        else GET_OPTION_BOOL("probe")
+        else GET_OPTION_BOOL("budget-mode")
+
+        else GET_OPTION_STRING("satellite")
+        else GET_OPTION_INT("voltage")
+        else GET_OPTION_BOOL("high-voltage")
+        else GET_OPTION_INT("tone")
+        else GET_OPTION_INT("satno")
+        else GET_OPTION_INT("fec")
+        else GET_OPTION_INT("srate")
+        else GET_OPTION_INT("lnb-lof1")
+        else GET_OPTION_INT("lnb-lof2")
+        else GET_OPTION_INT("lnb-slof")
+
+        else GET_OPTION_INT("modulation")
+
+        else GET_OPTION_INT("code-rate-hp")
+        else GET_OPTION_INT("code-rate-lp")
+        else GET_OPTION_INT("bandwidth")
+        else GET_OPTION_INT("transmission")
+        else GET_OPTION_INT("guard")
+        else GET_OPTION_INT("hierarchy")
+
+        /* Redundant with voltage but much easier to use */
+        else if( !strncmp( psz_parser, "polarization=",
+                           strlen( "polarization=" ) ) )
         {
-            E_(DMXUnsetFilter)( p_input, p_dvb->p_demux_handles[i].i_handle );
-            p_dvb->p_demux_handles[i].i_type = 0;
+            psz_parser += strlen( "polarization=" );
+            if ( *psz_parser == 'V' || *psz_parser == 'v' )
+                val.i_int = 13;
+            else if ( *psz_parser == 'H' || *psz_parser == 'h' )
+                val.i_int = 18;
+            else
+            {
+                msg_Err( p_access, "illegal polarization %c", *psz_parser );
+                free( psz_dup );
+                return VLC_EGENERIC;
+            }
+            var_Set( p_access, "dvb-voltage", val );
         }
+        else
+        {
+            msg_Err( p_access, "unknown option (%s)", psz_parser );
+            free( psz_dup );
+            return VLC_EGENERIC;
+        }
+
+        if ( *psz_parser )
+            psz_parser++;
     }
-}
+#undef GET_OPTION_INT
+#undef GET_OPTION_BOOL
+#undef GET_OPTION_STRING
 
+    free( psz_dup );
+    return VLC_SUCCESS;
+}