]> git.sesse.net Git - vlc/blobdiff - modules/gui/wxwindows/open.cpp
* renamed audio-channel to audio-track so ppl don't confuse it with audio-channels
[vlc] / modules / gui / wxwindows / open.cpp
index 80b35283cacb4f5c875f6f08c6df8fcc368f5473..5a96e5fd9b7b08f22b334b9c207c67cdc4a3c320 100644 (file)
@@ -1,10 +1,10 @@
 /*****************************************************************************
  * open.cpp : wxWindows plugin for vlc
  *****************************************************************************
- * Copyright (C) 2000-2001 VideoLAN
- * $Id: open.cpp,v 1.31 2003/07/24 17:31:59 gbazin Exp $
+ * Copyright (C) 2000-2004 VideoLAN
+ * $Id$
  *
- * Authors: Gildas Bazin <gbazin@netcourrier.com>
+ * Authors: Gildas Bazin <gbazin@videolan.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
 
 #include <vlc/vlc.h>
 
-#ifdef WIN32                                                 /* mingw32 hack */
-#undef Yield
-#undef CreateDialog
-#endif
-
-/* Let vlc take care of the i18n stuff */
-#define WXINTL_NO_GETTEXT_MACRO
-
-#include <wx/wxprec.h>
-#include <wx/wx.h>
-#include <wx/notebook.h>
-#include <wx/textctrl.h>
 #include <wx/combobox.h>
-#include <wx/spinctrl.h>
 #include <wx/statline.h>
 #include <wx/tokenzr.h>
 
 #include <vlc/intf.h>
 
+#include <vector>
+
 #include "wxwindows.h"
+#include "preferences_widgets.h"
 
 #ifndef wxRB_SINGLE
 #   define wxRB_SINGLE 0
@@ -73,11 +63,13 @@ enum
     DiscDevice_Event,
     DiscTitle_Event,
     DiscChapter_Event,
+    DiscSub_Event,
 
     NetType_Event,
-    NetRadio1_Event, NetRadio2_Event, NetRadio3_Event,
+    NetRadio1_Event, NetRadio2_Event, NetRadio3_Event, NetRadio4_Event,
     NetPort1_Event, NetPort2_Event, NetPort3_Event,
-    NetAddr1_Event, NetAddr2_Event, NetAddr3_Event,
+    NetAddr1_Event, NetAddr2_Event, NetAddr3_Event, NetAddr4_Event,
+    NetForceIPv6_Event,
 
     SubsFileEnable_Event,
     SubsFileSettings_Event,
@@ -85,19 +77,20 @@ enum
     SoutEnable_Event,
     SoutSettings_Event,
 
-    DemuxDump_Event,
-    DemuxDumpEnable_Event,
-    DemuxDumpBrowse_Event,
+    CachingEnable_Event,
+    CachingChange_Event,
+
+    AdvancedOptions_Event
 };
 
-BEGIN_EVENT_TABLE(OpenDialog, wxFrame)
+BEGIN_EVENT_TABLE(OpenDialog, wxDialog)
     /* Button events */
     EVT_BUTTON(wxID_OK, OpenDialog::OnOk)
     EVT_BUTTON(wxID_CANCEL, OpenDialog::OnCancel)
 
     EVT_NOTEBOOK_PAGE_CHANGED(Notebook_Event, OpenDialog::OnPageChange)
 
-    EVT_TEXT(MRL_Event, OpenDialog::OnMRLChange) 
+    EVT_TEXT(MRL_Event, OpenDialog::OnMRLChange)
 
     /* Events generated by the file panel */
     EVT_TEXT(FileName_Event, OpenDialog::OnFilePanelChange)
@@ -105,16 +98,20 @@ BEGIN_EVENT_TABLE(OpenDialog, wxFrame)
 
     /* Events generated by the disc panel */
     EVT_RADIOBOX(DiscType_Event, OpenDialog::OnDiscTypeChange)
+    EVT_TEXT(DiscDevice_Event, OpenDialog::OnDiscDeviceChange)
     EVT_TEXT(DiscDevice_Event, OpenDialog::OnDiscPanelChange)
     EVT_TEXT(DiscTitle_Event, OpenDialog::OnDiscPanelChange)
     EVT_SPINCTRL(DiscTitle_Event, OpenDialog::OnDiscPanelChange)
     EVT_TEXT(DiscChapter_Event, OpenDialog::OnDiscPanelChange)
     EVT_SPINCTRL(DiscChapter_Event, OpenDialog::OnDiscPanelChange)
+    EVT_TEXT(DiscSub_Event, OpenDialog::OnDiscPanelChange)
+    EVT_SPINCTRL(DiscSub_Event, OpenDialog::OnDiscPanelChange)
 
     /* Events generated by the net panel */
     EVT_RADIOBUTTON(NetRadio1_Event, OpenDialog::OnNetTypeChange)
     EVT_RADIOBUTTON(NetRadio2_Event, OpenDialog::OnNetTypeChange)
     EVT_RADIOBUTTON(NetRadio3_Event, OpenDialog::OnNetTypeChange)
+    EVT_RADIOBUTTON(NetRadio4_Event, OpenDialog::OnNetTypeChange)
     EVT_TEXT(NetPort1_Event, OpenDialog::OnNetPanelChange)
     EVT_SPINCTRL(NetPort1_Event, OpenDialog::OnNetPanelChange)
     EVT_TEXT(NetPort2_Event, OpenDialog::OnNetPanelChange)
@@ -123,6 +120,8 @@ BEGIN_EVENT_TABLE(OpenDialog, wxFrame)
     EVT_SPINCTRL(NetPort3_Event, OpenDialog::OnNetPanelChange)
     EVT_TEXT(NetAddr2_Event, OpenDialog::OnNetPanelChange)
     EVT_TEXT(NetAddr3_Event, OpenDialog::OnNetPanelChange)
+    EVT_TEXT(NetAddr4_Event, OpenDialog::OnNetPanelChange)
+    EVT_CHECKBOX(NetForceIPv6_Event, OpenDialog::OnNetPanelChange)
 
     /* Events generated by the subtitle file buttons */
     EVT_CHECKBOX(SubsFileEnable_Event, OpenDialog::OnSubsFileEnable)
@@ -132,32 +131,253 @@ BEGIN_EVENT_TABLE(OpenDialog, wxFrame)
     EVT_CHECKBOX(SoutEnable_Event, OpenDialog::OnSoutEnable)
     EVT_BUTTON(SoutSettings_Event, OpenDialog::OnSoutSettings)
 
-    /* Events generated by the demux dump buttons */
-    EVT_CHECKBOX(DemuxDumpEnable_Event, OpenDialog::OnDemuxDumpEnable)
-    EVT_TEXT(DemuxDump_Event, OpenDialog::OnDemuxDumpChange)
-    EVT_BUTTON(DemuxDumpBrowse_Event, OpenDialog::OnDemuxDumpBrowse)
+    /* Events generated by the caching button */
+    EVT_CHECKBOX(CachingEnable_Event, OpenDialog::OnCachingEnable)
+    EVT_TEXT(CachingChange_Event, OpenDialog::OnCachingChange)
+    EVT_SPINCTRL(CachingChange_Event, OpenDialog::OnCachingChange)
 
     /* Hide the window when the user closes the window */
     EVT_CLOSE(OpenDialog::OnCancel)
 
 END_EVENT_TABLE()
 
+/*****************************************************************************
+ * AutoBuiltPanel.
+ *****************************************************************************/
+WX_DEFINE_ARRAY(ConfigControl *, ArrayOfConfigControls);
+
+class AutoBuiltPanel : public wxPanel
+{
+public:
+
+    AutoBuiltPanel() { }
+    AutoBuiltPanel( wxWindow *, OpenDialog *, intf_thread_t *,
+                    const module_t * );
+
+    virtual ~AutoBuiltPanel() {}
+
+    void UpdateAdvancedMRL();
+
+    wxString name;
+    ArrayOfConfigControls config_array;
+    ArrayOfConfigControls advanced_config_array;
+    wxComboBox *p_advanced_mrl_combo;
+
+private:
+    intf_thread_t *p_intf;
+    OpenDialog *p_open_dialog;
+
+    void OnAdvanced( wxCommandEvent& event );
+    wxDialog *p_advanced_dialog;
+
+    DECLARE_EVENT_TABLE();
+};
+
+BEGIN_EVENT_TABLE(AutoBuiltPanel, wxPanel)
+    EVT_BUTTON(AdvancedOptions_Event, AutoBuiltPanel::OnAdvanced)
+END_EVENT_TABLE()
+
+static void AutoBuildCallback( void *p_data )
+{
+    ((OpenDialog *)p_data)->UpdateMRL();
+}
+
+static void AutoBuildAdvancedCallback( void *p_data )
+{
+    ((AutoBuiltPanel *)p_data)->UpdateAdvancedMRL();
+}
+
+AutoBuiltPanel::AutoBuiltPanel( wxWindow *parent, OpenDialog *dialog,
+                                intf_thread_t *_p_intf,
+                                const module_t *p_module )
+  : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize ),
+    name( wxU(p_module->psz_object_name) ),
+    p_advanced_mrl_combo( NULL ),
+    p_intf( _p_intf ), p_open_dialog( dialog ), p_advanced_dialog( NULL )
+{
+    wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
+    module_config_t *p_item = p_module->p_config;
+    bool b_advanced = false;
+
+    if( p_item ) do
+    {
+        if( !(p_item->i_type & CONFIG_HINT) && p_item->b_advanced )
+            b_advanced = true;
+
+        if( p_item->i_type & CONFIG_HINT || p_item->b_advanced )
+            continue;
+
+        ConfigControl *control =
+            CreateConfigControl( VLC_OBJECT(p_intf), p_item, this );
+
+        config_array.Add( control );
+
+        /* Don't add items that were not recognized */
+        if( control == NULL ) continue;
+
+        control->SetUpdateCallback( AutoBuildCallback, (void *)dialog );
+
+        sizer->Add( control, 0, wxEXPAND | wxALL, 2 );
+    }
+    while( p_item->i_type != CONFIG_HINT_END && p_item++ );
+
+    if( b_advanced )
+    {
+        wxButton *button =
+            new wxButton( this, AdvancedOptions_Event,
+                          wxU(_("Advanced options...")) );
+        sizer->Add( button, 0, wxALL, 5 );
+
+        /* Build the advanced dialog */
+        p_advanced_dialog =
+            new wxDialog( this, -1, ((wxString)wxU(_("Advanced options"))) +
+                          wxT(" (") + wxU( p_module->psz_longname ) + wxT(")"),
+                          wxDefaultPosition, wxDefaultSize,
+                          wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER );
+
+        wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
+
+        /* Create MRL combobox */
+        wxBoxSizer *mrl_sizer_sizer = new wxBoxSizer( wxHORIZONTAL );
+        wxStaticBox *mrl_box =
+            new wxStaticBox( p_advanced_dialog, -1,
+                             wxU(_("Advanced options")) );
+        wxStaticBoxSizer *mrl_sizer =
+            new wxStaticBoxSizer( mrl_box, wxHORIZONTAL );
+        wxStaticText *mrl_label =
+            new wxStaticText( p_advanced_dialog, -1, wxU(_("Options:")) );
+        p_advanced_mrl_combo =
+            new wxComboBox( p_advanced_dialog, MRL_Event, wxT(""),
+                            wxDefaultPosition, wxDefaultSize );
+        mrl_sizer->Add( mrl_label, 0, wxALL | wxALIGN_CENTER, 5 );
+        mrl_sizer->Add( p_advanced_mrl_combo, 1, wxALL | wxALIGN_CENTER, 5 );
+        mrl_sizer_sizer->Add( mrl_sizer, 1, wxEXPAND | wxALL, 5 );
+        sizer->Add( mrl_sizer_sizer, 0, wxEXPAND | wxALL, 2 );
+
+        /* Add advanced options to panel */
+        module_config_t *p_item = p_module->p_config;
+        if( p_item ) do
+        {
+            if( p_item->i_type & CONFIG_HINT || !p_item->b_advanced )
+                continue;
+
+            ConfigControl *control =
+                CreateConfigControl( VLC_OBJECT(p_intf), p_item,
+                                     p_advanced_dialog );
+
+            advanced_config_array.Add( control );
+
+            /* Don't add items that were not recognized */
+            if( control == NULL ) continue;
+
+            control->SetUpdateCallback( AutoBuildAdvancedCallback,
+                                        (void *)this );
+
+            sizer->Add( control, 0, wxEXPAND | wxALL, 2 );
+        }
+        while( p_item->i_type != CONFIG_HINT_END && p_item++ );
+
+        /* Separation */
+        wxPanel *dummy_panel = new wxPanel( p_advanced_dialog, -1 );
+        sizer->Add( dummy_panel, 1 );
+        wxStaticLine *static_line =
+            new wxStaticLine( p_advanced_dialog, wxID_OK );
+        sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
+
+        /* Create buttons */
+        wxButton *ok_button =
+            new wxButton( p_advanced_dialog, wxID_OK, wxU(_("OK")) );
+        ok_button->SetDefault();
+        wxButton *cancel_button =
+            new wxButton( p_advanced_dialog, wxID_CANCEL, wxU(_("Cancel")) );
+        wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
+        button_sizer->Add( ok_button, 0, wxALL, 5 );
+        button_sizer->Add( cancel_button, 0, wxALL, 5 );
+        button_sizer->Layout();
+        sizer->Add( button_sizer, 0, wxALL, 0 );
+
+        sizer->SetMinSize( 400, -1 );
+        p_advanced_dialog->SetSizerAndFit( sizer );
+    }
+
+    this->SetSizerAndFit( sizer );
+}
+
+void AutoBuiltPanel::OnAdvanced( wxCommandEvent& event )
+{
+    if( p_advanced_dialog->ShowModal() == wxID_OK )
+    {
+        UpdateAdvancedMRL();
+        p_open_dialog->UpdateMRL();
+    }
+}
+
+void AutoBuiltPanel::UpdateAdvancedMRL()
+{
+    wxString mrltemp;
+
+    for( int i = 0; i < (int)advanced_config_array.GetCount(); i++ )
+    {
+        ConfigControl *control = advanced_config_array.Item(i);
+
+        mrltemp += (i ? wxT(" :") : wxT(":"));
+
+        if( control->GetType() == CONFIG_ITEM_BOOL &&
+            !control->GetIntValue() ) mrltemp += wxT("no-");
+
+        mrltemp += control->GetName();
+
+        switch( control->GetType() )
+        {
+        case CONFIG_ITEM_STRING:
+        case CONFIG_ITEM_FILE:
+        case CONFIG_ITEM_DIRECTORY:
+        case CONFIG_ITEM_MODULE:
+            mrltemp += wxT("=\"") + control->GetPszValue() + wxT("\"");
+            break;
+        case CONFIG_ITEM_INTEGER:
+            mrltemp +=
+                wxString::Format( wxT("=%i"), control->GetIntValue() );
+            break;
+        case CONFIG_ITEM_FLOAT:
+            mrltemp +=
+                wxString::Format(wxT("=%f"), control->GetFloatValue());
+            break;
+        }
+    }
+
+    p_advanced_mrl_combo->SetValue( mrltemp );
+}
+
 /*****************************************************************************
  * Constructor.
  *****************************************************************************/
 OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
                         int i_access_method, int i_arg ):
-    wxFrame( _p_parent, -1, wxU(_("Open Target")), wxDefaultPosition,
+      wxDialog( _p_parent, -1, wxU(_("Open...")), wxDefaultPosition,
+             wxDefaultSize, wxDEFAULT_FRAME_STYLE )
+{
+    OpenDialog( _p_intf, _p_parent, i_access_method, i_arg, OPEN_NORMAL );
+}
+
+OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
+                        int i_access_method, int i_arg, int _i_method ):
+      wxDialog( _p_parent, -1, wxU(_("Open...")), wxDefaultPosition,
              wxDefaultSize, wxDEFAULT_FRAME_STYLE )
 {
     /* Initializations */
+    i_method = _i_method;
     p_intf = _p_intf;
     p_parent = _p_parent;
     SetIcon( *p_intf->p_sys->p_icon );
     file_dialog = NULL;
+    i_disc_type_selection = 0;
+    i_disc_title = 0;
+    i_open_arg = i_arg;
+
     sout_dialog = NULL;
     subsfile_dialog = NULL;
-    demuxdump_dialog = NULL;
+    b_disc_device_changed = false;
 
     /* Create a panel to put everything in */
     wxPanel *panel = new wxPanel( this, -1 );
@@ -170,7 +390,7 @@ OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
     wxStaticBoxSizer *mrl_sizer = new wxStaticBoxSizer( mrl_box,
                                                         wxHORIZONTAL );
     wxStaticText *mrl_label = new wxStaticText( panel, -1,
-                                                wxU(_("Open Target:")) );
+                                                wxU(_("Open:")) );
     mrl_combo = new wxComboBox( panel, MRL_Event, wxT(""),
                                 wxPoint(20,25), wxSize(120, -1),
                                 0, NULL );
@@ -188,78 +408,53 @@ OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
         wxU(_("Alternatively, you can build an MRL using one of the "
               "following predefined targets:")) );
 
-    /* Create Subtitles File checkox */
-    wxFlexGridSizer *subsfile_sizer = new wxFlexGridSizer( 2, 1, 20 );
-    subsfile_checkbox = new wxCheckBox( panel, SubsFileEnable_Event,
-                                        wxU(_("Subtitles file")) );
-    subsfile_checkbox->SetToolTip( wxU(_("Load an additional subtitles file. "
-                                   "Currently only works with AVI files.")) );
-    subsfile_sizer->Add( subsfile_checkbox, 0,
-                         wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
-    subsfile_button = new wxButton( panel, SubsFileSettings_Event,
-                                    wxU(_("Settings...")) );
-    subsfile_button->Disable();
+    wxFlexGridSizer *common_opt_sizer = new wxFlexGridSizer( 5, 1, 20 );
 
-    char *psz_subsfile = config_GetPsz( p_intf, "sub-file" );
-    if( psz_subsfile && *psz_subsfile )
+    if( i_method == OPEN_NORMAL )
     {
-        subsfile_checkbox->SetValue(TRUE);
-        subsfile_button->Enable();
-        subsfile_mrl.Add( wxString(wxT("sub-file=")) + wxU(psz_subsfile) );
-    }
-    if( psz_subsfile ) free( psz_subsfile );
+        /* Create Stream Output checkox */
+        sout_checkbox = new wxCheckBox( panel, SoutEnable_Event,
+                                         wxU(_("Stream output")) );
+        sout_checkbox->SetToolTip( wxU(_("Use VLC as a server of streams")) );
+        common_opt_sizer->Add( sout_checkbox, 0,
+                               wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
+
+        sout_button = new wxButton( panel, SoutSettings_Event,
+                                    wxU(_("Settings...")) );
+        sout_button->Disable();
 
-    subsfile_sizer->Add( subsfile_button, 1,
-                         wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
+        char *psz_sout = config_GetPsz( p_intf, "sout" );
+        if( psz_sout && *psz_sout )
+        {
+            sout_checkbox->SetValue(TRUE);
+            sout_button->Enable();
+            subsfile_mrl.Add( wxString(wxT("sout=")) + wxL2U(psz_sout) );
+        }
+        if( psz_sout ) free( psz_sout );
 
-    /* Create Stream Output checkox */
-    wxFlexGridSizer *sout_sizer = new wxFlexGridSizer( 2, 1, 20 );
-    sout_checkbox = new wxCheckBox( panel, SoutEnable_Event,
-                                    wxU(_("Stream output")) );
-    sout_checkbox->SetToolTip( wxU(_("Use VLC as a stream server")) );
-    sout_sizer->Add( sout_checkbox, 0,
-                     wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
-    sout_button = new wxButton( panel, SoutSettings_Event,
-                                wxU(_("Settings...")) );
-    sout_button->Disable();
-
-    char *psz_sout = config_GetPsz( p_intf, "sout" );
-    if( psz_sout && *psz_sout )
-    {
-        sout_checkbox->SetValue(TRUE);
-        sout_button->Enable();
-        subsfile_mrl.Add( wxString(wxT("sout=")) + wxU(psz_sout) );
-    }
-    if( psz_sout ) free( psz_sout );
-
-    sout_sizer->Add( sout_button, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
-
-    /* Create Demux Dump checkox */
-    wxBoxSizer *demuxdump_sizer = new wxBoxSizer( wxHORIZONTAL );
-    demuxdump_checkbox = new wxCheckBox( panel, DemuxDumpEnable_Event,
-                               wxU(_("Capture input stream")) );
-    demuxdump_checkbox->SetToolTip(
-        wxU(_("Capture the stream you are playing to a file")) );
-    demuxdump_textctrl = new wxTextCtrl( panel, DemuxDump_Event, wxT(""),
-                                         wxDefaultPosition, wxDefaultSize,
-                                         wxTE_PROCESS_ENTER);
-    demuxdump_button = new wxButton( panel, DemuxDumpBrowse_Event,
-                                     wxU(_("Browse...")) );
-
-    char *psz_demuxdump = config_GetPsz( p_intf, "demuxdump-file" );
-    if( psz_demuxdump && *psz_demuxdump )
-    {
-        demuxdump_textctrl->SetValue( wxU(psz_demuxdump) );
+        common_opt_sizer->Add( sout_button, 1, wxALIGN_LEFT |
+                               wxALIGN_CENTER_VERTICAL );
+
+        common_opt_sizer->Add( new wxPanel( this, -1 ), 1,
+                               wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
     }
-    if( psz_demuxdump ) free( psz_demuxdump );
 
-    demuxdump_textctrl->Disable();
-    demuxdump_button->Disable();
-    demuxdump_sizer->Add( demuxdump_checkbox, 0,
-                          wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
-    demuxdump_sizer->Add( demuxdump_button, 0,
-                          wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL, 10 );
-    demuxdump_sizer->Add( demuxdump_textctrl, 1, wxRIGHT, 10 );
+    /* Create caching options */
+    caching_checkbox = new wxCheckBox( panel, CachingEnable_Event,
+                                       wxU(_("Caching")) );
+    caching_checkbox->SetToolTip( wxU(_("Change the default caching value "
+                                        "(in milliseconds)")) );
+    common_opt_sizer->Add( caching_checkbox, 0,
+                           wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
+    caching_value = new wxSpinCtrl( panel, CachingChange_Event );
+#ifdef WIN32  /* WIN32 uses 16 bit integer */
+    caching_value->SetRange( 0, 32767 );
+#else
+    caching_value->SetRange( 0, 1000000 );
+#endif
+    caching_value->Disable();
+    common_opt_sizer->Add( caching_value, 0,
+                           wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
 
     /* Separation */
     wxStaticLine *static_line = new wxStaticLine( panel, wxID_OK );
@@ -280,10 +475,50 @@ OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
                        i_access_method == DISC_ACCESS );
     notebook->AddPage( NetPanel( notebook ), wxU(_("Network")),
                        i_access_method == NET_ACCESS );
-#ifndef WIN32
-    notebook->AddPage( SatPanel( notebook ), wxU(_("Satellite")),
-                       i_access_method == SAT_ACCESS );
-#endif
+
+    module_t *p_module = config_FindModule( VLC_OBJECT(p_intf), "v4l" );
+    if( p_module )
+    {
+        AutoBuiltPanel *autopanel =
+            new AutoBuiltPanel( notebook, this, p_intf, p_module );
+        input_tab_array.Add( autopanel );
+        notebook->AddPage( autopanel, wxU( p_module->psz_shortname ?
+                        p_module->psz_shortname : p_module->psz_object_name ),
+                           i_access_method == CAPTURE_ACCESS );
+    }
+
+    p_module = config_FindModule( VLC_OBJECT(p_intf), "pvr" );
+    if( p_module )
+    {
+        AutoBuiltPanel *autopanel =
+            new AutoBuiltPanel( notebook, this, p_intf, p_module );
+        input_tab_array.Add( autopanel );
+        notebook->AddPage( autopanel, wxU( p_module->psz_shortname ?
+                        p_module->psz_shortname : p_module->psz_object_name ),
+                           i_access_method == CAPTURE_ACCESS );
+    }
+
+    p_module = config_FindModule( VLC_OBJECT(p_intf), "dvb" );
+    if( p_module )
+    {
+        AutoBuiltPanel *autopanel =
+            new AutoBuiltPanel( notebook, this, p_intf, p_module );
+        input_tab_array.Add( autopanel );
+        notebook->AddPage( autopanel, wxU( p_module->psz_shortname ?
+                        p_module->psz_shortname : p_module->psz_object_name ),
+                           i_access_method == CAPTURE_ACCESS );
+    }
+
+    p_module = config_FindModule( VLC_OBJECT(p_intf), "dshow" );
+    if( p_module )
+    {
+        AutoBuiltPanel *autopanel =
+            new AutoBuiltPanel( notebook, this, p_intf, p_module );
+        input_tab_array.Add( autopanel );
+        notebook->AddPage( autopanel, wxU( p_module->psz_shortname ?
+                        p_module->psz_shortname : p_module->psz_object_name ),
+                           i_access_method == CAPTURE_ACCESS );
+    }
 
     /* Update Disc panel */
     wxCommandEvent dummy_event;
@@ -294,7 +529,7 @@ OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
     OnNetTypeChange( dummy_event );
 
     /* Update MRL */
-    wxNotebookEvent event = wxNotebookEvent( wxEVT_NULL, 0, i_access_method );
+    wxNotebookEvent event( wxEVT_NULL, 0, i_access_method );
     OnPageChange( event );
 
     /* Place everything in sizers */
@@ -307,9 +542,7 @@ OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
     panel_sizer->Add( mrl_sizer_sizer, 0, wxEXPAND, 5 );
     panel_sizer->Add( label, 0, wxEXPAND | wxALL, 5 );
     panel_sizer->Add( notebook_sizer, 1, wxEXPAND | wxALL, 5 );
-    panel_sizer->Add( subsfile_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
-    panel_sizer->Add( sout_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
-    panel_sizer->Add( demuxdump_sizer, 0, wxEXPAND | wxALIGN_LEFT | wxALL, 5 );
+    panel_sizer->Add( common_opt_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
     panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
     panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
     panel_sizer->Layout();
@@ -325,23 +558,21 @@ OpenDialog::~OpenDialog()
     if( file_dialog ) delete file_dialog;
     if( sout_dialog ) delete sout_dialog;
     if( subsfile_dialog ) delete subsfile_dialog;
-    if( demuxdump_dialog ) delete demuxdump_dialog;
 }
 
 int OpenDialog::Show( int i_access_method, int i_arg )
 {
-    int i_ret;
     notebook->SetSelection( i_access_method );
-    i_ret = wxFrame::Show();
+    int i_ret = wxDialog::Show();
     Raise();
     SetFocus();
+    i_open_arg = i_arg;
     return i_ret;
 }
 
 int OpenDialog::Show()
 {
-    int i_ret;
-    i_ret = wxFrame::Show();
+    int i_ret = wxDialog::Show();
     Raise();
     SetFocus();
     return i_ret;
@@ -355,15 +586,43 @@ wxPanel *OpenDialog::FilePanel( wxWindow* parent )
     wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
                                   wxSize(200, 200) );
 
-    wxBoxSizer *sizer = new wxBoxSizer( wxHORIZONTAL );
+    wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
+
+    /* Create browse file line */
+    wxBoxSizer *file_sizer = new wxBoxSizer( wxHORIZONTAL );
 
     file_combo = new wxComboBox( panel, FileName_Event, wxT(""),
                                  wxPoint(20,25), wxSize(200, -1), 0, NULL );
     wxButton *browse_button = new wxButton( panel, FileBrowse_Event,
                                             wxU(_("Browse...")) );
-    sizer->Add( file_combo, 1, wxALL, 5 );
-    sizer->Add( browse_button, 0, wxALL, 5 );
+    file_sizer->Add( file_combo, 1, wxALL, 5 );
+    file_sizer->Add( browse_button, 0, wxALL, 5 );
+
+    /* Create Subtitles File checkox */
+    wxFlexGridSizer *subsfile_sizer = new wxFlexGridSizer( 2, 1, 20 );
+    subsfile_checkbox = new wxCheckBox( panel, SubsFileEnable_Event,
+                                        wxU(_("Subtitle options")) );
+    subsfile_checkbox->SetToolTip( wxU(_("Force options for separate subtitle files.")) );
+    subsfile_sizer->Add( subsfile_checkbox, 0,
+                         wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
+    subsfile_button = new wxButton( panel, SubsFileSettings_Event,
+                                    wxU(_("Settings...")) );
+    subsfile_button->Disable();
 
+    char *psz_subsfile = config_GetPsz( p_intf, "sub-file" );
+    if( psz_subsfile && *psz_subsfile )
+    {
+        subsfile_checkbox->SetValue(TRUE);
+        subsfile_button->Enable();
+        subsfile_mrl.Add( wxString(wxT("sub-file=")) + wxL2U(psz_subsfile) );
+    }
+    if( psz_subsfile ) free( psz_subsfile );
+
+    subsfile_sizer->Add( subsfile_button, 1,
+                         wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
+
+    sizer->Add( file_sizer, 0, wxEXPAND | wxALL, 5 );
+    sizer->Add( subsfile_sizer, 0, wxEXPAND | wxALL, 5 );
     panel->SetSizerAndFit( sizer );
     return panel;
 }
@@ -378,18 +637,18 @@ wxPanel *OpenDialog::DiscPanel( wxWindow* parent )
 
     static const wxString disc_type_array[] =
     {
-        wxU(_("DVD (menus support)")),
+        wxU(_("DVD (menus)")),
         wxU(_("DVD")),
         wxU(_("VCD")),
-        wxU(_("CD Audio"))
-
+        wxU(_("Audio CD")),
     };
 
     disc_type = new wxRadioBox( panel, DiscType_Event, wxU(_("Disc type")),
                                 wxDefaultPosition, wxDefaultSize,
                                 WXSIZEOF(disc_type_array), disc_type_array,
                                 WXSIZEOF(disc_type_array), wxRA_SPECIFY_COLS );
-    sizer_row->Add( disc_type, 0, wxEXPAND | wxALL, 5 );
+
+    sizer_row->Add( disc_type, i_disc_type_selection, wxEXPAND | wxALL, 5 );
 
     wxStaticText *label = new wxStaticText( panel, -1, wxU(_("Device name")) );
     disc_device = new wxTextCtrl( panel, DiscDevice_Event, wxT(""),
@@ -399,16 +658,25 @@ wxPanel *OpenDialog::DiscPanel( wxWindow* parent )
     sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
     sizer->Add( disc_device, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
 
-    label = new wxStaticText( panel, -1, wxU(_("Title")) );
+    disc_title_label = new wxStaticText( panel, -1, wxU(_("Title")) );
     disc_title = new wxSpinCtrl( panel, DiscTitle_Event );
-
-    sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
+    sizer->Add( disc_title_label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
     sizer->Add( disc_title, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
 
-    label = new wxStaticText( panel, -1, wxU(_("Chapter")) );
+    disc_chapter_label = new wxStaticText( panel, -1, wxU(_("Chapter")) );
     disc_chapter = new wxSpinCtrl( panel, DiscChapter_Event );
-    sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
+    sizer->Add( disc_chapter_label, 0,
+                wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
     sizer->Add( disc_chapter, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
+
+    disc_sub_label = new wxStaticText( panel, -1, wxU(_("Subtitles track")) );
+    disc_sub = new wxSpinCtrl( panel, DiscSub_Event );
+    sizer->Add( disc_sub_label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
+    sizer->Add( disc_sub, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
+    disc_sub->SetRange( -1, 255 );
+    i_disc_sub = config_GetInt( p_intf, "spu-track" );
+    disc_sub->SetValue( i_disc_sub );
+
     sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
 
     panel->SetSizerAndFit( sizer_row );
@@ -422,16 +690,17 @@ wxPanel *OpenDialog::NetPanel( wxWindow* parent )
                                   wxSize(200, 200) );
 
     wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
-    wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 3, 20 );
+    wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 4, 20 );
 
     static const wxString net_type_array[] =
     {
         wxU(_("UDP/RTP")),
         wxU(_("UDP/RTP Multicast")),
-        wxU(_("HTTP/FTP/MMS"))
+        wxU(_("HTTP/FTP/MMS")),
+        wxU(_("RTSP"))
     };
 
-    for( i=0; i<3; i++ )
+    for( i=0; i<4; i++ )
     {
         net_radios[i] = new wxRadioButton( panel, NetRadio1_Event + i,
                                            net_type_array[i],
@@ -445,18 +714,22 @@ wxPanel *OpenDialog::NetPanel( wxWindow* parent )
     /* UDP/RTP row */
     wxFlexGridSizer *subpanel_sizer;
     wxStaticText *label;
-    int val = config_GetInt( p_intf, "server-port" );
-    subpanel_sizer = new wxFlexGridSizer( 2, 1, 20 );
+    i_net_ports[0] = config_GetInt( p_intf, "server-port" );
+    subpanel_sizer = new wxFlexGridSizer( 3, 1, 20 );
     label = new wxStaticText( net_subpanels[0], -1, wxU(_("Port")) );
     net_ports[0] = new wxSpinCtrl( net_subpanels[0], NetPort1_Event,
-                                   wxString::Format(wxT("%d"), val),
+                                   wxString::Format(wxT("%d"), i_net_ports[0]),
                                    wxDefaultPosition, wxDefaultSize,
                                    wxSP_ARROW_KEYS,
-                                   0, 16000, val);
+                                   0, 16000, i_net_ports[0] );
 
     subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
     subpanel_sizer->Add( net_ports[0], 1,
                          wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
+    net_ipv6 = new wxCheckBox( net_subpanels[0], NetForceIPv6_Event,
+                               wxU(_("Force IPv6")));
+    subpanel_sizer->Add( net_ipv6, 0,
+                         wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
     net_subpanels[0]->SetSizerAndFit( subpanel_sizer );
     net_radios[0]->SetValue( TRUE );
 
@@ -471,30 +744,35 @@ wxPanel *OpenDialog::NetPanel( wxWindow* parent )
                          wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
 
     label = new wxStaticText( net_subpanels[1], -1, wxU(_("Port")) );
+    i_net_ports[1] = i_net_ports[0];
     net_ports[1] = new wxSpinCtrl( net_subpanels[1], NetPort2_Event,
-                                   wxString::Format(wxT("%d"), val),
+                                   wxString::Format(wxT("%d"), i_net_ports[1]),
                                    wxDefaultPosition, wxDefaultSize,
                                    wxSP_ARROW_KEYS,
-                                   0, 16000, val);
+                                   0, 16000, i_net_ports[1] );
 
     subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
     subpanel_sizer->Add( net_ports[1], 1,
                          wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
     net_subpanels[1]->SetSizerAndFit( subpanel_sizer );
 
-    /* HTTP row */
-    subpanel_sizer = new wxFlexGridSizer( 2, 1, 20 );
-    label = new wxStaticText( net_subpanels[2], -1, wxU(_("URL")) );
-    net_addrs[2] = new wxTextCtrl( net_subpanels[2], NetAddr3_Event, wxT(""),
-                                   wxDefaultPosition, wxSize( 200, -1 ),
-                                   wxTE_PROCESS_ENTER);
-    subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
-    subpanel_sizer->Add( net_addrs[2], 1,
-                         wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
-    net_subpanels[2]->SetSizerAndFit( subpanel_sizer );
+    /* HTTP and RTSP rows */
+    for( i=2; i<4; i++ )
+    {
+        subpanel_sizer = new wxFlexGridSizer( 2, 1, 20 );
+        label = new wxStaticText( net_subpanels[i], -1, wxU(_("URL")) );
+        net_addrs[i] = new wxTextCtrl( net_subpanels[i], NetAddr1_Event + i,
+                                       (i == 2) ? wxT("") : wxT("rtsp://"),
+                                       wxDefaultPosition, wxSize( 200, -1 ),
+                                       wxTE_PROCESS_ENTER);
+        subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
+        subpanel_sizer->Add( net_addrs[i], 1,
+                             wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
+        net_subpanels[i]->SetSizerAndFit( subpanel_sizer );
+    }
 
     /* Stuff everything into the main panel */
-    for( i=0; i<3; i++ )
+    for( i=0; i<4; i++ )
     {
         sizer->Add( net_radios[i], 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
                     wxALL, 5 );
@@ -508,132 +786,224 @@ wxPanel *OpenDialog::NetPanel( wxWindow* parent )
     return panel;
 }
 
-wxPanel *OpenDialog::SatPanel( wxWindow* parent )
+void OpenDialog::UpdateMRL()
 {
-    wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
-                                  wxSize(200, 200) );
-    return panel;
+    UpdateMRL( i_current_access_method );
 }
 
 void OpenDialog::UpdateMRL( int i_access_method )
 {
-    wxString demux, mrltemp;
+    wxString mrltemp, caching_name;
 
     i_current_access_method = i_access_method;
 
-    /* Check if the user asked for demuxdump */
-    if( demuxdump_checkbox->GetValue() )
-    {
-        demux = wxT("/demuxdump");
-    }
-
     switch( i_access_method )
     {
     case FILE_ACCESS:
-        //mrltemp = wxT("file") + demux + wxT(":") + file_combo->GetValue();
         mrltemp = file_combo->GetValue();
+        caching_name = wxT("file-caching");
         break;
+
     case DISC_ACCESS:
-        mrltemp = ( disc_type->GetSelection() == 0 ? wxT("dvd") :
-                disc_type->GetSelection() == 1 ? wxT("dvdsimple") :
-                disc_type->GetSelection() == 2 ? wxT("vcd") : wxT("cdda") )
-                  + demux + wxT(":")
-                  + disc_device->GetLineText(0)
-                  + wxString::Format( wxT("@%d:%d"),
-                                      disc_title->GetValue(),
-                                      disc_chapter->GetValue() );
+        i_disc_type_selection = disc_type->GetSelection();
+
+        switch ( i_disc_type_selection )
+        {
+        case 0: /* DVD with menus */
+        case 1: /* DVD without menus */
+            if( i_disc_type_selection == 0 )
+            {
+                mrltemp = wxT("dvd://") + disc_device->GetValue();
+                caching_name = wxT("dvdnav-caching");
+            }
+            else
+            {
+                mrltemp = wxT("dvdsimple://") + disc_device->GetValue();
+                caching_name = wxT("dvdread-caching");
+            }
+
+            if( i_disc_title > 0 )
+            {
+                mrltemp += wxString::Format( wxT("@%d"), i_disc_title );
+
+                if( i_disc_chapter > 0 )
+                    mrltemp += wxString::Format( wxT(":%d"), i_disc_chapter );
+            }
+
+            if( i_disc_sub >= 0 )
+                mrltemp += wxString::Format( wxT("  :spu-track=%d"),
+                                             i_disc_sub );
+            break;
+
+        case 2:  /* VCD of some sort */
+#ifdef HAVE_VCDX
+            mrltemp = wxT("vcdx://") + disc_device->GetValue();
+            if( i_disc_title > 0 )
+                mrltemp += wxString::Format( wxT("@%c%d"),
+                                  config_GetInt( p_intf, "vcdx-PBC"  )
+                                  ? 'P' : 'E', i_disc_title );
+#else
+            mrltemp = wxT("vcd://") + disc_device->GetValue();
+            if( i_disc_title > 0 )
+                mrltemp += wxString::Format( wxT("@%d"), i_disc_title );
+#endif
+
+            if( i_disc_sub >= 0 )
+                mrltemp += wxString::Format( wxT("  :spu-track=%d"),
+                                             i_disc_sub );
+
+            caching_name = wxT("vcd-caching");
+            break;
+
+        case 3: /* CD-DA */
+            mrltemp = 
+#ifdef HAVE_CDDAX
+             wxT("cddax://") 
+#else
+             wxT("cdda://") 
+#endif
+             + disc_device->GetValue();
+            if( i_disc_title > 0 )
+                mrltemp += wxString::Format( wxT("@%d"), i_disc_title );
+
+            caching_name = wxT("cdda-caching");
+            break;
+
+        default:
+            msg_Err( p_intf, "invalid selection (%d)",
+                     disc_type->GetSelection() );
+        }
+
         break;
+
     case NET_ACCESS:
         switch( i_net_type )
         {
         case 0:
-            if( net_ports[0]->GetValue() !=
-                config_GetInt( p_intf, "server-port" ) )
+            mrltemp = wxT("udp://");
+            if ( net_ipv6->GetValue() )
             {
-                mrltemp = wxT("udp") + demux +
-                          wxString::Format( wxT("://@:%d"),
-                                            net_ports[0]->GetValue() );
+                mrltemp += wxT("@[::]");
             }
-            else
+            if( i_net_ports[0] !=
+                config_GetInt( p_intf, "server-port" ) )
             {
-                mrltemp = wxT("udp") + demux + wxT("://");
+                mrltemp += wxString::Format( wxT("@:%d"), i_net_ports[0] );
             }
+
+            caching_name = wxT("udp-caching");
             break;
 
         case 1:
-            mrltemp = wxT("udp") + demux + wxT("://@") +
-                      net_addrs[1]->GetLineText(0);
-            if( net_ports[1]->GetValue() !=
-                config_GetInt( p_intf, "server-port" ) )
+            mrltemp = wxT("udp://@");
+            if ((net_addrs[1]->GetLineText(0).Find (':') != -1)
+                && (net_addrs[1]->GetLineText(0)[0u] != '['))
+            {
+                /* automatically adds '[' and ']' to IPv6 addresses */
+                mrltemp += wxT("[") + net_addrs[1]->GetLineText(0)
+                         + wxT("]");
+            }
+            else
+            {
+                mrltemp += net_addrs[1]->GetLineText(0);
+            }
+            if( i_net_ports[1] != config_GetInt( p_intf, "server-port" ) )
             {
-                mrltemp = mrltemp + wxString::Format( wxT(":%d"),
-                                              net_ports[1]->GetValue() );
+                mrltemp += wxString::Format( wxT(":%d"), i_net_ports[1] );
             }
+
+            caching_name = wxT("udp-caching");
             break;
 
         case 2:
-            /* http access */     
-            mrltemp = wxT("http") + demux + wxT("://") +
-                      net_addrs[2]->GetLineText(0);
+            /* http access */
+            if( net_addrs[2]->GetLineText(0).Find(wxT("://")) == -1 )
+                mrltemp = wxT("http://");
+
+            mrltemp += net_addrs[2]->GetLineText(0);
+
+            caching_name = wxT("http-caching");
+            break;
+
+        case 3:
+            /* RTSP access */
+            if( net_addrs[3]->GetLineText(0).Find(wxT("rtsp://")) != 0 )
+            {
+                mrltemp = wxT("rtsp://");
+            }
+            mrltemp += net_addrs[3]->GetLineText(0);
+
+            caching_name = wxT("rtsp-caching");
             break;
         }
         break;
-    case SAT_ACCESS:
-        mrltemp = wxT("satellite") + demux + wxT("://");
-        break;
+
     default:
-        break;
-    }
+        {
+            int i_item = i_access_method - MAX_ACCESS;
 
-    mrl_combo->SetValue( mrltemp );
-}
+            if( i_item < 0 || i_item >= (int)input_tab_array.GetCount() )
+                break;
 
-wxArrayString OpenDialog::SeparateEntries( wxString entries )
-{
-    vlc_bool_t b_quotes_mode = VLC_FALSE;
+            AutoBuiltPanel *input_panel = input_tab_array.Item( i_item );
 
-    wxArrayString entries_array;
-    wxString entry;
-
-    wxStringTokenizer token( entries, wxT(" \t\r\n\""), wxTOKEN_RET_DELIMS );
+            mrltemp = input_panel->name + wxT("://");
 
-    while( token.HasMoreTokens() )
-    {
-        entry += token.GetNextToken();
+            for( int i=0; i < (int)input_panel->config_array.GetCount(); i++ )
+            {
+                ConfigControl *control = input_panel->config_array.Item(i);
+
+                mrltemp += wxT(" :");
+
+                if( control->GetType() == CONFIG_ITEM_BOOL &&
+                    !control->GetIntValue() ) mrltemp += wxT("no-");
+
+                mrltemp += control->GetName();
+
+                switch( control->GetType() )
+                {
+                case CONFIG_ITEM_STRING:
+                case CONFIG_ITEM_FILE:
+                case CONFIG_ITEM_DIRECTORY:
+                case CONFIG_ITEM_MODULE:
+                    mrltemp += wxT("=\"") + control->GetPszValue() + wxT("\"");
+                    break;
+                case CONFIG_ITEM_INTEGER:
+                    mrltemp +=
+                        wxString::Format( wxT("=%i"), control->GetIntValue() );
+                    break;
+                case CONFIG_ITEM_FLOAT:
+                    mrltemp +=
+                        wxString::Format(wxT("=%f"), control->GetFloatValue());
+                    break;
+                }
+            }
 
-        if( entry.IsEmpty() ) continue;
+            if( input_panel->p_advanced_mrl_combo &&
+                input_panel->p_advanced_mrl_combo->GetValue() )
+            {
+                mrltemp += wxT(" ") +
+                    input_panel->p_advanced_mrl_combo->GetValue();
+            }
+        }
+        break;
+    }
 
-        if( !b_quotes_mode && entry.Last() == wxT('\"') )
+    if( caching_name.size() )
+    {
+        if( caching_value->IsEnabled() )
         {
-            /* Enters quotes mode */
-            entry.RemoveLast();
-            b_quotes_mode = VLC_TRUE;
+            mrltemp += wxT("  :") + caching_name +
+                wxString::Format( wxT("=%d"), i_caching );
         }
-        else if( b_quotes_mode && entry.Last() == wxT('\"') )
-        {
-            /* Finished the quotes mode */
-            entry.RemoveLast();
-            if( !entry.IsEmpty() ) entries_array.Add( entry );
-            entry.Empty();
-            b_quotes_mode = VLC_FALSE;
-        }
-        else if( !b_quotes_mode && entry.Last() != wxT('\"') )
+        else
         {
-            /* we found a non-quoted standalone string */
-            if( token.HasMoreTokens() ||
-                entry.Last() == wxT(' ') || entry.Last() == wxT('\t') ||
-                entry.Last() == wxT('\r') || entry.Last() == wxT('\n') )
-                entry.RemoveLast();
-            if( !entry.IsEmpty() ) entries_array.Add( entry );
-            entry.Empty();
+            int i_value = config_GetInt( p_intf, caching_name.mb_str() );
+            caching_value->SetValue( i_value );
         }
-        else
-        {;}
     }
 
-    if( !entry.IsEmpty() ) entries_array.Add( entry );
-
-    return entries_array;
+    mrl_combo->SetValue( mrltemp );
 }
 
 /*****************************************************************************
@@ -646,87 +1016,73 @@ void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
     if( mrl_combo->GetCount() > 10 ) mrl_combo->Delete( 0 );
     mrl_combo->SetSelection( mrl_combo->GetCount() - 1 );
 
+    if( i_method == OPEN_STREAM )
+    {
+        if( IsModal() ) EndModal( wxID_OK );
+        Hide();
+        return;
+    }
+
     /* Update the playlist */
     playlist_t *p_playlist =
         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
-                                      FIND_ANYWHERE );
+                                       FIND_ANYWHERE );
     if( p_playlist == NULL ) return;
 
     for( int i = 0; i < (int)mrl.GetCount(); i++ )
     {
-        int i_options = 0, i_total_options;
-        char **ppsz_options = NULL;
-
-        /* Count the input options */
-        while( i + i_options + 1 < (int)mrl.GetCount() &&
-               ((const char *)mrl[i + i_options + 1].mb_str())[0] == ':' )
+        vlc_bool_t b_start = !i && i_open_arg;
+        playlist_item_t *p_item =
+            playlist_ItemNew( p_intf, (const char*)mrl[i].mb_str(),
+                              (const char *)mrl[i].mb_str() );
+
+        /* Insert options */
+        while( i + 1 < (int)mrl.GetCount() &&
+               ((const char *)mrl[i + 1].mb_str())[0] == ':' )
         {
-            i_options++;
+            playlist_ItemAddOption( p_item, mrl[i + 1].mb_str() );
+            i++;
         }
 
-        /* Allocate ppsz_options */
-        for( int j = 0; j < i_options; j++ )
-        {
-            if( !ppsz_options )
-                ppsz_options = (char **)malloc( sizeof(char *) * i_options );
-
-            ppsz_options[j] = strdup( mrl[i + j  + 1].mb_str() );
-        }
-
-       i_total_options = i_options;
-
         /* Get the options from the subtitles dialog */
         if( subsfile_checkbox->IsChecked() && subsfile_mrl.GetCount() )
         {
-            ppsz_options = (char **)realloc( ppsz_options, sizeof(char *) *
-                               (i_total_options + subsfile_mrl.GetCount()) );
-
             for( int j = 0; j < (int)subsfile_mrl.GetCount(); j++ )
             {
-                ppsz_options[i_total_options + j] =
-                    strdup( subsfile_mrl[j].mb_str() );
+                playlist_ItemAddOption( p_item, subsfile_mrl[j].mb_str() );
             }
-
-            i_total_options += subsfile_mrl.GetCount();
         }
 
         /* Get the options from the stream output dialog */
         if( sout_checkbox->IsChecked() && sout_mrl.GetCount() )
         {
-            ppsz_options = (char **)realloc( ppsz_options, sizeof(char *) *
-                               (i_total_options + sout_mrl.GetCount()) );
-
             for( int j = 0; j < (int)sout_mrl.GetCount(); j++ )
             {
-                ppsz_options[i_total_options + j] =
-                    strdup( sout_mrl[j].mb_str() );
+                playlist_ItemAddOption( p_item, sout_mrl[j].mb_str() );
             }
-
-            i_total_options += sout_mrl.GetCount();
         }
 
-        playlist_Add( p_playlist, (const char *)mrl[i].mb_str(),
-                      (const char **)ppsz_options, i_total_options,
-                      PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO), PLAYLIST_END );
+        int i_id = playlist_AddItem( p_playlist, p_item,
+                                     PLAYLIST_APPEND, PLAYLIST_END );
 
-        /* clean up */
-        for( int j = 0; j < i_total_options; j++ )
-            free( ppsz_options[j] );
-        if( ppsz_options ) free( ppsz_options );
-
-        i += i_options;
-   }
-
-    //TogglePlayButton( PLAYING_S );
+        if( b_start )
+        {
+            playlist_Control( p_playlist, PLAYLIST_ITEMPLAY , p_item );
+        }
+    }
 
     vlc_object_release( p_playlist );
 
     Hide();
+
+    if( IsModal() ) EndModal( wxID_OK );
 }
 
 void OpenDialog::OnCancel( wxCommandEvent& WXUNUSED(event) )
 {
     Hide();
+
+    if( IsModal() ) EndModal( wxID_CANCEL );
 }
 
 void OpenDialog::OnPageChange( wxNotebookEvent& event )
@@ -750,7 +1106,7 @@ void OpenDialog::OnFilePanelChange( wxCommandEvent& WXUNUSED(event) )
 void OpenDialog::OnFileBrowse( wxCommandEvent& WXUNUSED(event) )
 {
     if( file_dialog == NULL )
-        file_dialog = new wxFileDialog( this, wxU(_("Open file")),
+        file_dialog = new wxFileDialog( this, wxU(_("Open File")),
             wxT(""), wxT(""), wxT("*"), wxOPEN | wxMULTIPLE );
 
     if( file_dialog && file_dialog->ShowModal() == wxID_OK )
@@ -778,45 +1134,110 @@ void OpenDialog::OnFileBrowse( wxCommandEvent& WXUNUSED(event) )
 /*****************************************************************************
  * Disc panel event methods.
  *****************************************************************************/
-void OpenDialog::OnDiscPanelChange( wxCommandEvent& WXUNUSED(event) )
+void OpenDialog::OnDiscPanelChange( wxCommandEvent& event )
 {
+    if( event.GetId() == DiscTitle_Event ) i_disc_title = event.GetInt();
+    if( event.GetId() == DiscChapter_Event ) i_disc_chapter = event.GetInt();
+    if( event.GetId() == DiscSub_Event ) i_disc_sub = event.GetInt();
+
     UpdateMRL( DISC_ACCESS );
 }
 
-void OpenDialog::OnDiscTypeChange( wxCommandEvent& WXUNUSED(event) )
+void OpenDialog::OnDiscDeviceChange( wxCommandEvent& event )
 {
     char *psz_device;
 
     switch( disc_type->GetSelection() )
     {
-    case 2:
-        psz_device = config_GetPsz( p_intf, "vcd" );
-        disc_device->SetValue( psz_device ? wxU(psz_device) : wxT("") );
-        break;
+        case 3:
+            psz_device = config_GetPsz( p_intf, "cd-audio" );
+            break;
 
-    default:
-        psz_device = config_GetPsz( p_intf, "dvd" );
-        disc_device->SetValue( psz_device ? wxU(psz_device) : wxT("") );
-        break;
+        case 2:
+            psz_device = config_GetPsz( p_intf, "vcd" );
+            break;
+
+        default:
+            psz_device = config_GetPsz( p_intf, "dvd" );
+            break;
     }
 
-    if( psz_device ) free( psz_device );
+    if ( !psz_device ) psz_device = "";
+
+    if( disc_device->GetValue().Cmp( wxL2U( psz_device ) ) )
+    {
+        b_disc_device_changed = true;
+    }
+
+    UpdateMRL( DISC_ACCESS );
+}
+
+void OpenDialog::OnDiscTypeChange( wxCommandEvent& WXUNUSED(event) )
+{
+    char *psz_device = NULL;
 
     switch( disc_type->GetSelection() )
     {
-    case 0:
+
+    case 0: /* DVD with menus */
+    case 1: /* DVD without menus */
+        disc_sub->Enable(); disc_sub_label->Enable();
+        disc_chapter->Enable(); disc_chapter_label->Enable();
+        disc_title_label->SetLabel ( wxU(_("Title")) );
+        psz_device = config_GetPsz( p_intf, "dvd" );
+        if( !b_disc_device_changed )
+        {
+            if( psz_device ) disc_device->SetValue( wxL2U(psz_device) );
+            else disc_device->SetValue( wxT("") );
+        }
         disc_title->SetRange( 0, 255 );
-        disc_title->SetValue( 0 );
+        disc_chapter->SetRange( 0, 255 );
+        break;
+
+    case 2:  /* VCD of some sort */
+        disc_sub->Enable(); disc_sub_label->Enable();
+        disc_chapter->Disable(); disc_chapter_label->Disable();
+        psz_device = config_GetPsz( p_intf, "vcd" );
+        if( !b_disc_device_changed )
+        {
+            if( psz_device ) disc_device->SetValue( wxL2U(psz_device) );
+            else disc_device->SetValue( wxT("") );
+        }
+
+#ifdef HAVE_VCDX
+        disc_title_label->SetLabel ( config_GetInt( p_intf, "vcdx-PBC"  )
+                                     ? wxT("Playback LID") : wxT("Entry") );
+#else
+        disc_title_label->SetLabel ( wxU(_("Track")) );
+#endif
+        disc_title->SetRange( 0, 999 );
+        break;
+
+    case 3: /* CD-DA */
+        disc_sub->Disable(); disc_sub_label->Disable();
+        disc_chapter->Disable(); disc_chapter_label->Disable();
+        disc_title_label->SetLabel ( wxU(_("Track")) );
+        psz_device = config_GetPsz( p_intf, "cd-audio" );
+        if( !b_disc_device_changed )
+        {
+            if( psz_device ) disc_device->SetValue( wxL2U(psz_device) );
+            else disc_device->SetValue( wxT("") );
+        }
+
+        /* There are at most 99 tracks in a CD-DA */
+        disc_title->SetRange( 0, 99 );
         break;
 
     default:
-        disc_title->SetRange( 1, 255 );
-        disc_title->SetValue( 1 );
+        msg_Err( p_intf, "invalid Disc type selection (%d)",
+                 disc_type->GetSelection() );
         break;
     }
 
-    disc_chapter->SetRange( 1, 255 );
-    disc_chapter->SetValue( 1 );
+    disc_title->SetValue( 0 ); i_disc_title = 0;
+    disc_chapter->SetValue( 0 ); i_disc_chapter = 0;
+
+    if( psz_device ) free( psz_device );
 
     UpdateMRL( DISC_ACCESS );
 }
@@ -824,8 +1245,13 @@ void OpenDialog::OnDiscTypeChange( wxCommandEvent& WXUNUSED(event) )
 /*****************************************************************************
  * Net panel event methods.
  *****************************************************************************/
-void OpenDialog::OnNetPanelChange( wxCommandEvent& WXUNUSED(event) )
+void OpenDialog::OnNetPanelChange( wxCommandEvent& event )
 {
+    if( event.GetId() >= NetPort1_Event && event.GetId() <= NetPort3_Event )
+    {
+        i_net_ports[event.GetId() - NetPort1_Event] = event.GetInt();
+    }
+
     UpdateMRL( NET_ACCESS );
 }
 
@@ -835,7 +1261,7 @@ void OpenDialog::OnNetTypeChange( wxCommandEvent& event )
 
     i_net_type = event.GetId() - NetRadio1_Event;
 
-    for(i=0; i<3; i++)
+    for(i=0; i<4; i++)
     {
         net_radios[i]->SetValue( event.GetId() == (NetRadio1_Event+i) );
         net_subpanels[i]->Enable( event.GetId() == (NetRadio1_Event+i) );
@@ -850,13 +1276,6 @@ void OpenDialog::OnNetTypeChange( wxCommandEvent& event )
 void OpenDialog::OnSubsFileEnable( wxCommandEvent& event )
 {
     subsfile_button->Enable( event.GetInt() != 0 );
-    if( event.GetInt() && demuxdump_checkbox->IsChecked() )
-    {
-        demuxdump_checkbox->SetValue( 0 );
-        wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
-        event.SetInt( 0 );
-        OnDemuxDumpEnable( event );
-    }
 }
 
 void OpenDialog::OnSubsFileSettings( wxCommandEvent& WXUNUSED(event) )
@@ -870,10 +1289,20 @@ void OpenDialog::OnSubsFileSettings( wxCommandEvent& WXUNUSED(event) )
         subsfile_mrl.Empty();
         subsfile_mrl.Add( wxString(wxT("sub-file=")) +
                           subsfile_dialog->file_combo->GetValue() );
-        subsfile_mrl.Add( wxString::Format( wxT("sub-delay=%i"),
-                          subsfile_dialog->delay_spinctrl->GetValue() ) );
+        if( subsfile_dialog->encoding_combo )
+            subsfile_mrl.Add( wxString(wxT("subsdec-encoding=")) +
+                              subsfile_dialog->encoding_combo->GetValue() );
+        subsfile_mrl.Add( wxString::Format(wxT("subsdec-align=%i"),
+                           (int)subsfile_dialog->align_combo->GetClientData(
+                           subsfile_dialog->align_combo->GetSelection()) ) );
+
+        subsfile_mrl.Add( wxString::Format( wxT("freetype-rel-fontsize=%i"),
+                          (int)subsfile_dialog->size_combo->GetClientData(
+                          subsfile_dialog->size_combo->GetSelection()) ) );
         subsfile_mrl.Add( wxString::Format( wxT("sub-fps=%i"),
                           subsfile_dialog->fps_spinctrl->GetValue() ) );
+        subsfile_mrl.Add( wxString::Format( wxT("sub-delay=%i"),
+                          subsfile_dialog->delay_spinctrl->GetValue() ) );
     }
 }
 
@@ -883,13 +1312,6 @@ void OpenDialog::OnSubsFileSettings( wxCommandEvent& WXUNUSED(event) )
 void OpenDialog::OnSoutEnable( wxCommandEvent& event )
 {
     sout_button->Enable( event.GetInt() != 0 );
-    if( event.GetInt() && demuxdump_checkbox->IsChecked() )
-    {
-        demuxdump_checkbox->SetValue( 0 );
-        wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
-        event.SetInt( 0 );
-        OnDemuxDumpEnable( event );
-    }
 }
 
 void OpenDialog::OnSoutSettings( wxCommandEvent& WXUNUSED(event) )
@@ -900,48 +1322,71 @@ void OpenDialog::OnSoutSettings( wxCommandEvent& WXUNUSED(event) )
 
     if( sout_dialog && sout_dialog->ShowModal() == wxID_OK )
     {
-        sout_mrl.Empty();
-        sout_mrl.Add( wxString(wxT("sout=")) + sout_dialog->mrl );
+        sout_mrl = sout_dialog->GetOptions();
     }
 }
 
 /*****************************************************************************
- * Demux dump event methods.
+ * Caching event methods.
  *****************************************************************************/
-void OpenDialog::OnDemuxDumpEnable( wxCommandEvent& event )
+void OpenDialog::OnCachingEnable( wxCommandEvent& event )
 {
-    demuxdump_textctrl->Enable( event.GetInt() != 0 );
-    demuxdump_button->Enable( event.GetInt() != 0 );
-
-    if( event.GetInt() )
-    {
-        sout_checkbox->SetValue( 0 );
-        subsfile_checkbox->SetValue( 0 );
-        wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
-        event.SetInt( 0 );
-        OnSoutEnable( event );
-        OnSubsFileEnable( event );
-    }
+    caching_value->Enable( event.GetInt() != 0 );
+    i_caching = caching_value->GetValue();
+    UpdateMRL();
+}
 
-    UpdateMRL( i_current_access_method );
+void OpenDialog::OnCachingChange( wxCommandEvent& event )
+{
+    i_caching = event.GetInt();
+    UpdateMRL();
 }
 
-void OpenDialog::OnDemuxDumpBrowse( wxCommandEvent& WXUNUSED(event) )
+/*****************************************************************************
+ * Utility functions.
+ *****************************************************************************/
+wxArrayString SeparateEntries( wxString entries )
 {
-    if( demuxdump_dialog == NULL )
-        demuxdump_dialog = new wxFileDialog( this, wxU(_("Save file")),
-                               wxT(""), wxT(""), wxT("*"), wxSAVE );
+    vlc_bool_t b_quotes_mode = VLC_FALSE;
+
+    wxArrayString entries_array;
+    wxString entry;
+
+    wxStringTokenizer token( entries, wxT(" \t\r\n\""), wxTOKEN_RET_DELIMS );
 
-    if( demuxdump_dialog && demuxdump_dialog->ShowModal() == wxID_OK )
+    while( token.HasMoreTokens() )
     {
-        demuxdump_textctrl->SetValue( demuxdump_dialog->GetPath() );
-        wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
-        OnDemuxDumpChange( event );
+        entry += token.GetNextToken();
+
+        if( entry.IsEmpty() ) continue;
+
+        if( !b_quotes_mode && entry.Last() == wxT('\"') )
+        {
+            /* Enters quotes mode */
+            entry.RemoveLast();
+            b_quotes_mode = VLC_TRUE;
+        }
+        else if( b_quotes_mode && entry.Last() == wxT('\"') )
+        {
+            /* Finished the quotes mode */
+            entry.RemoveLast();
+            b_quotes_mode = VLC_FALSE;
+        }
+        else if( !b_quotes_mode && entry.Last() != wxT('\"') )
+        {
+            /* we found a non-quoted standalone string */
+            if( token.HasMoreTokens() ||
+                entry.Last() == wxT(' ') || entry.Last() == wxT('\t') ||
+                entry.Last() == wxT('\r') || entry.Last() == wxT('\n') )
+                entry.RemoveLast();
+            if( !entry.IsEmpty() ) entries_array.Add( entry );
+            entry.Empty();
+        }
+        else
+        {;}
     }
-}
 
-void OpenDialog::OnDemuxDumpChange( wxCommandEvent& WXUNUSED(event) )
-{
-    config_PutPsz( p_intf, "demuxdump-file",
-                   demuxdump_textctrl->GetValue().mb_str() );
+    if( !entry.IsEmpty() ) entries_array.Add( entry );
+
+    return entries_array;
 }