* modules/gui/wxwindows/*: added demuxdump support to the open dialog.
[vlc.git] / modules / gui / wxwindows / open.cpp
index 8983100..da8055a 100644 (file)
@@ -2,7 +2,7 @@
  * open.cpp : wxWindows plugin for vlc
  *****************************************************************************
  * Copyright (C) 2000-2001 VideoLAN
- * $Id: open.cpp,v 1.6 2003/03/22 03:14:34 gbazin Exp $
+ * $Id: open.cpp,v 1.7 2003/03/29 01:50:12 gbazin Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *
@@ -80,6 +80,10 @@ enum
 
     SoutEnable_Event,
     SoutSettings_Event,
+
+    DemuxDump_Event,
+    DemuxDumpEnable_Event,
+    DemuxDumpBrowse_Event,
 };
 
 BEGIN_EVENT_TABLE(OpenDialog, wxDialog)
@@ -121,6 +125,12 @@ BEGIN_EVENT_TABLE(OpenDialog, wxDialog)
     /* Events generated by the stream output buttons */
     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)
+
 END_EVENT_TABLE()
 
 /*****************************************************************************
@@ -175,23 +185,51 @@ OpenDialog::OpenDialog( intf_thread_t *_p_intf, Interface *_p_main_interface,
 
     /* Create Stream Output checkox */
     wxFlexGridSizer *sout_sizer = new wxFlexGridSizer( 2, 1, 20 );
-    wxCheckBox *checkbox = new wxCheckBox( panel, SoutEnable_Event,
+    sout_checkbox = new wxCheckBox( panel, SoutEnable_Event,
                                            _("Stream Output") );
-    checkbox->SetToolTip( _("Use VLC has a stream server") );
-    sout_sizer->Add( checkbox, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
+    sout_checkbox->SetToolTip( _("Use VLC has a stream server") );
+    sout_sizer->Add( sout_checkbox, 0,
+                     wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
     sout_button = new wxButton( panel, SoutSettings_Event, _("Settings...") );
     sout_button->Disable();
 
     char *psz_sout = config_GetPsz( p_intf, "sout" );
     if( psz_sout && *psz_sout )
     {
-        checkbox->SetValue(TRUE);
+        sout_checkbox->SetValue(TRUE);
         sout_button->Enable();
     }
     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,
+                               _("Capture input stream") );
+    demuxdump_checkbox->SetToolTip(
+                           _("Capture the stream you are playing to a file") );
+    demuxdump_textctrl = new wxTextCtrl( panel, DemuxDump_Event,
+                                         "", wxDefaultPosition, wxDefaultSize,
+                                         wxTE_PROCESS_ENTER);
+    demuxdump_button = new wxButton( panel, DemuxDumpBrowse_Event,
+                                     _("Browse...") );
+
+    char *psz_demuxdump = config_GetPsz( p_intf, "demuxdump-file" );
+    if( psz_demuxdump && *psz_demuxdump )
+    {
+        demuxdump_textctrl->SetValue( psz_demuxdump );
+    }
+    if( psz_demuxdump ) free( psz_demuxdump );
+
+    demuxdump_textctrl->Disable();
+    demuxdump_button->Disable();
+    demuxdump_sizer->Add( demuxdump_checkbox, 0,
+                          wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 10 );
+    demuxdump_sizer->Add( demuxdump_button, 0,
+                          wxALL | wxALIGN_CENTER_VERTICAL, 10 );
+    demuxdump_sizer->Add( demuxdump_textctrl, 1, wxALL, 10 );
+
     /* Separation */
     wxStaticLine *static_line = new wxStaticLine( panel, wxID_OK );
 
@@ -201,6 +239,10 @@ OpenDialog::OpenDialog( intf_thread_t *_p_intf, Interface *_p_main_interface,
     wxButton *cancel_button = new wxButton( panel, wxID_CANCEL, _("Cancel") );
 
 
+    /* Update Disc panel */
+    wxCommandEvent dummy_event;
+    OnDiscTypeChange( dummy_event );
+
     /* Update MRL */
     wxNotebookEvent event = wxNotebookEvent( wxEVT_NULL, 0, i_access_method );
     OnPageChange( event );
@@ -216,6 +258,7 @@ OpenDialog::OpenDialog( intf_thread_t *_p_intf, Interface *_p_main_interface,
     panel_sizer->Add( label, 0, wxEXPAND | wxALL, 5 );
     panel_sizer->Add( notebook_sizer, 1, wxEXPAND | 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( static_line, 0, wxEXPAND | wxALL, 5 );
     panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
     panel_sizer->Layout();
@@ -247,7 +290,6 @@ wxPanel *OpenDialog::FilePanel( wxWindow* parent )
     sizer->Add( browse_button, 0, wxALL, 5 );
 
     panel->SetSizerAndFit( sizer );
-
     return panel;
 }
 
@@ -293,11 +335,6 @@ wxPanel *OpenDialog::DiscPanel( wxWindow* parent )
     sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
 
     panel->SetSizerAndFit( sizer_row );
-
-    /* Update Disc panel */
-    wxCommandEvent dummy_event;
-    OnDiscTypeChange( dummy_event );
-
     return panel;
 }
 
@@ -413,13 +450,6 @@ wxPanel *OpenDialog::NetPanel( wxWindow* parent )
     sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
 
     panel->SetSizerAndFit( sizer_row );
-
-    /* Update Net panel */
-    net_addrs[3]->SetValue( "http://" );
-    wxCommandEvent dummy_event;
-    dummy_event.SetId( NetRadio1_Event );
-    OnNetTypeChange( dummy_event );
-
     return panel;
 }
 
@@ -432,14 +462,25 @@ wxPanel *OpenDialog::SatPanel( wxWindow* parent )
 
 void OpenDialog::UpdateMRL( int i_access_method )
 {
+    wxString demux;
+
+    i_current_access_method = i_access_method;
+
+    /* Check if the user asked for demuxdump */
+    if( demuxdump_checkbox->GetValue() )
+    {
+        demux = "/demuxdump";
+    }
+
     switch( i_access_method )
     {
     case FILE_ACCESS:
-        mrl = "file://" + file_combo->GetValue();
+        mrl = "file" + demux + "://" + file_combo->GetValue();
         break;
     case DISC_ACCESS:
-        mrl = ( disc_type->GetSelection() == 0 ? "dvdold://" :
-                disc_type->GetSelection() == 1 ? "dvd://" : "vcd://" )
+        mrl = ( disc_type->GetSelection() == 0 ? "dvdold" :
+                disc_type->GetSelection() == 1 ? "dvd" : "vcd" )
+                  + demux + "://"
                   + disc_device->GetLineText(0)
                   + wxString::Format( "@%d:%d",
                                       disc_title->GetValue(),
@@ -452,17 +493,17 @@ void OpenDialog::UpdateMRL( int i_access_method )
             if( net_ports[0]->GetValue() !=
                 config_GetInt( p_intf, "server-port" ) )
             {
-                mrl = wxString::Format( "udp://@:%d",
-                                        net_ports[0]->GetValue() );
+                mrl = "udp" + demux +
+                       wxString::Format( "://@:%d", net_ports[0]->GetValue() );
             }
             else
             {
-                mrl = "udp://";
+                mrl = "udp" + demux + "://";
             }
             break;
 
         case 1:
-            mrl = "udp://@" + net_addrs[1]->GetLineText(0);
+            mrl = "udp" + demux + "://@" + net_addrs[1]->GetLineText(0);
             if( net_ports[1]->GetValue() !=
                 config_GetInt( p_intf, "server-port" ) )
             {
@@ -472,17 +513,17 @@ void OpenDialog::UpdateMRL( int i_access_method )
             break;
 
         case 2:
-            mrl = "udp://";
+            mrl = "udp" + demux + "://";
             break;
 
         case 3:
             /* http access */     
-            mrl = net_addrs[3]->GetLineText(0);
+            mrl = "http" + demux + "://" + net_addrs[3]->GetLineText(0);
             break;
         }
         break;
     case SAT_ACCESS:
-        mrl = "satellite://";
+        mrl = "satellite" + demux + "://";
         break;
     default:
         break;
@@ -613,6 +654,13 @@ void OpenDialog::OnSoutEnable( wxCommandEvent& event )
     {
         config_PutPsz( p_intf, "sout", "" );
     }
+    else
+    {
+        demuxdump_checkbox->SetValue( 0 );
+        wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
+        event.SetInt( 0 );
+        OnDemuxDumpEnable( event );
+    }
 }
 
 void OpenDialog::OnSoutSettings( wxCommandEvent& WXUNUSED(event) )
@@ -625,3 +673,40 @@ void OpenDialog::OnSoutSettings( wxCommandEvent& WXUNUSED(event) )
         config_PutPsz( p_intf, "sout", (char *)dialog.mrl.c_str() );
     }
 }
+
+/*****************************************************************************
+ * Demux dump event methods.
+ *****************************************************************************/
+void OpenDialog::OnDemuxDumpEnable( wxCommandEvent& event )
+{
+    demuxdump_textctrl->Enable( event.GetInt() != 0 );
+    demuxdump_button->Enable( event.GetInt() != 0 );
+
+    if( event.GetInt() )
+    {
+        sout_checkbox->SetValue( 0 );
+        wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
+        event.SetInt( 0 );
+        OnSoutEnable( event );
+    }
+
+    UpdateMRL( i_current_access_method );
+}
+
+void OpenDialog::OnDemuxDumpBrowse( wxCommandEvent& WXUNUSED(event) )
+{
+    wxFileDialog dialog( this, _("Save file"), "", "", "*.*", wxSAVE );
+
+    if( dialog.ShowModal() == wxID_OK )
+    {
+        demuxdump_textctrl->SetValue( dialog.GetPath() );
+        wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
+        OnDemuxDumpChange( event );
+    }
+}
+
+void OpenDialog::OnDemuxDumpChange( wxCommandEvent& WXUNUSED(event) )
+{
+    config_PutPsz( p_intf, "demuxdump-file",
+                   demuxdump_textctrl->GetValue() );
+}