* modules/gui/wxwindows/*: added demuxdump support to the open dialog.
[vlc.git] / modules / gui / wxwindows / open.cpp
1 /*****************************************************************************
2  * open.cpp : wxWindows plugin for vlc
3  *****************************************************************************
4  * Copyright (C) 2000-2001 VideoLAN
5  * $Id: open.cpp,v 1.7 2003/03/29 01:50:12 gbazin Exp $
6  *
7  * Authors: Gildas Bazin <gbazin@netcourrier.com>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27 #include <stdlib.h>                                      /* malloc(), free() */
28 #include <errno.h>                                                 /* ENOMEM */
29 #include <string.h>                                            /* strerror() */
30 #include <stdio.h>
31
32 #include <vlc/vlc.h>
33
34 #ifdef WIN32                                                 /* mingw32 hack */
35 #undef Yield
36 #undef CreateDialog
37 #endif
38
39 /* Let vlc take care of the i18n stuff */
40 #define WXINTL_NO_GETTEXT_MACRO
41
42 #include <wx/wxprec.h>
43 #include <wx/wx.h>
44 #include <wx/notebook.h>
45 #include <wx/textctrl.h>
46 #include <wx/combobox.h>
47 #include <wx/spinctrl.h>
48 #include <wx/statline.h>
49
50 #include <vlc/intf.h>
51
52 #include "wxwindows.h"
53
54 #ifndef wxRB_SINGLE
55 #   define wxRB_SINGLE 0
56 #endif
57
58 /*****************************************************************************
59  * Event Table.
60  *****************************************************************************/
61
62 /* IDs for the controls and the menu commands */
63 enum
64 {
65     Notebook_Event = wxID_HIGHEST,
66     MRL_Event,
67
68     FileBrowse_Event,
69     FileName_Event,
70
71     DiscType_Event,
72     DiscDevice_Event,
73     DiscTitle_Event,
74     DiscChapter_Event,
75
76     NetType_Event,
77     NetRadio1_Event, NetRadio2_Event, NetRadio3_Event, NetRadio4_Event,
78     NetPort1_Event, NetPort2_Event, NetPort3_Event, NetPort4_Event,
79     NetAddr1_Event, NetAddr2_Event, NetAddr3_Event, NetAddr4_Event,
80
81     SoutEnable_Event,
82     SoutSettings_Event,
83
84     DemuxDump_Event,
85     DemuxDumpEnable_Event,
86     DemuxDumpBrowse_Event,
87 };
88
89 BEGIN_EVENT_TABLE(OpenDialog, wxDialog)
90     /* Button events */
91     EVT_BUTTON(wxID_OK, OpenDialog::OnOk)
92     EVT_BUTTON(wxID_CANCEL, OpenDialog::OnCancel)
93
94     EVT_NOTEBOOK_PAGE_CHANGED(Notebook_Event, OpenDialog::OnPageChange)
95
96     EVT_TEXT(MRL_Event, OpenDialog::OnMRLChange) 
97
98     /* Events generated by the file panel */
99     EVT_TEXT(FileName_Event, OpenDialog::OnFilePanelChange)
100     EVT_BUTTON(FileBrowse_Event, OpenDialog::OnFileBrowse)
101
102     /* Events generated by the disc panel */
103     EVT_RADIOBOX(DiscType_Event, OpenDialog::OnDiscTypeChange)
104     EVT_TEXT(DiscDevice_Event, OpenDialog::OnDiscPanelChange)
105     EVT_TEXT(DiscTitle_Event, OpenDialog::OnDiscPanelChange)
106     EVT_SPINCTRL(DiscTitle_Event, OpenDialog::OnDiscPanelChange)
107     EVT_TEXT(DiscChapter_Event, OpenDialog::OnDiscPanelChange)
108     EVT_SPINCTRL(DiscChapter_Event, OpenDialog::OnDiscPanelChange)
109
110     /* Events generated by the net panel */
111     EVT_RADIOBUTTON(NetRadio1_Event, OpenDialog::OnNetTypeChange)
112     EVT_RADIOBUTTON(NetRadio2_Event, OpenDialog::OnNetTypeChange)
113     EVT_RADIOBUTTON(NetRadio3_Event, OpenDialog::OnNetTypeChange)
114     EVT_RADIOBUTTON(NetRadio4_Event, OpenDialog::OnNetTypeChange)
115     EVT_TEXT(NetPort1_Event, OpenDialog::OnNetPanelChange)
116     EVT_SPINCTRL(NetPort1_Event, OpenDialog::OnNetPanelChange)
117     EVT_TEXT(NetPort2_Event, OpenDialog::OnNetPanelChange)
118     EVT_SPINCTRL(NetPort2_Event, OpenDialog::OnNetPanelChange)
119     EVT_TEXT(NetPort3_Event, OpenDialog::OnNetPanelChange)
120     EVT_SPINCTRL(NetPort3_Event, OpenDialog::OnNetPanelChange)
121     EVT_TEXT(NetAddr2_Event, OpenDialog::OnNetPanelChange)
122     EVT_TEXT(NetAddr3_Event, OpenDialog::OnNetPanelChange)
123     EVT_TEXT(NetAddr4_Event, OpenDialog::OnNetPanelChange)
124
125     /* Events generated by the stream output buttons */
126     EVT_CHECKBOX(SoutEnable_Event, OpenDialog::OnSoutEnable)
127     EVT_BUTTON(SoutSettings_Event, OpenDialog::OnSoutSettings)
128
129     /* Events generated by the demux dump buttons */
130     EVT_CHECKBOX(DemuxDumpEnable_Event, OpenDialog::OnDemuxDumpEnable)
131     EVT_TEXT(DemuxDump_Event, OpenDialog::OnDemuxDumpChange)
132     EVT_BUTTON(DemuxDumpBrowse_Event, OpenDialog::OnDemuxDumpBrowse)
133
134 END_EVENT_TABLE()
135
136 /*****************************************************************************
137  * Constructor.
138  *****************************************************************************/
139 OpenDialog::OpenDialog( intf_thread_t *_p_intf, Interface *_p_main_interface,
140                         int i_access_method ):
141     wxDialog( _p_main_interface, -1, _("Open Target"), wxDefaultPosition,
142              wxDefaultSize, wxDEFAULT_FRAME_STYLE )
143 {
144     /* Initializations */
145     p_intf = _p_intf;
146     p_main_interface = _p_main_interface;
147
148     /* Create a panel to put everything in */
149     wxPanel *panel = new wxPanel( this, -1 );
150     panel->SetAutoLayout( TRUE );
151
152     /* Create MRL combobox */
153     wxBoxSizer *mrl_sizer_sizer = new wxBoxSizer( wxHORIZONTAL );
154     wxStaticBox *mrl_box = new wxStaticBox( panel, -1,
155                                _("Media Resource Locator (MRL)") );
156     wxStaticBoxSizer *mrl_sizer = new wxStaticBoxSizer( mrl_box,
157                                                         wxHORIZONTAL );
158     wxStaticText *mrl_label = new wxStaticText( panel, -1,
159                                                 _("Open Target:") );
160     mrl_combo = new wxComboBox( panel, MRL_Event, mrl,
161                                 wxPoint(20,25), wxSize(120, -1),
162                                 0, NULL );
163     mrl_sizer->Add( mrl_label, 0, wxEXPAND | wxALL, 5 );
164     mrl_sizer->Add( mrl_combo, 1, wxEXPAND | wxALL, 5 );
165     mrl_sizer_sizer->Add( mrl_sizer, 1, wxEXPAND | wxALL, 5 );
166
167
168     /* Create Static Text */
169     wxStaticText *label = new wxStaticText( panel, -1,
170         _("Alternatively, you can build an MRL using one of the "
171           "following predefined targets:") );
172
173     /* Create notebook */
174     wxNotebook *notebook = new wxNotebook( panel, Notebook_Event );
175     wxNotebookSizer *notebook_sizer = new wxNotebookSizer( notebook );
176
177     notebook->AddPage( FilePanel( notebook ), _("File"),
178                        i_access_method == FILE_ACCESS );
179     notebook->AddPage( DiscPanel( notebook ), _("Disc"),
180                        i_access_method == DISC_ACCESS );
181     notebook->AddPage( NetPanel( notebook ), _("Network"),
182                        i_access_method == NET_ACCESS );
183     notebook->AddPage( SatPanel( notebook ), _("Satellite"),
184                        i_access_method == SAT_ACCESS );
185
186     /* Create Stream Output checkox */
187     wxFlexGridSizer *sout_sizer = new wxFlexGridSizer( 2, 1, 20 );
188     sout_checkbox = new wxCheckBox( panel, SoutEnable_Event,
189                                            _("Stream Output") );
190     sout_checkbox->SetToolTip( _("Use VLC has a stream server") );
191     sout_sizer->Add( sout_checkbox, 0,
192                      wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
193     sout_button = new wxButton( panel, SoutSettings_Event, _("Settings...") );
194     sout_button->Disable();
195
196     char *psz_sout = config_GetPsz( p_intf, "sout" );
197     if( psz_sout && *psz_sout )
198     {
199         sout_checkbox->SetValue(TRUE);
200         sout_button->Enable();
201     }
202     if( psz_sout ) free( psz_sout );
203
204     sout_sizer->Add( sout_button, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
205
206     /* Create Demux Dump checkox */
207     wxBoxSizer *demuxdump_sizer = new wxBoxSizer( wxHORIZONTAL );
208     demuxdump_checkbox = new wxCheckBox( panel, DemuxDumpEnable_Event,
209                                _("Capture input stream") );
210     demuxdump_checkbox->SetToolTip(
211                            _("Capture the stream you are playing to a file") );
212     demuxdump_textctrl = new wxTextCtrl( panel, DemuxDump_Event,
213                                          "", wxDefaultPosition, wxDefaultSize,
214                                          wxTE_PROCESS_ENTER);
215     demuxdump_button = new wxButton( panel, DemuxDumpBrowse_Event,
216                                      _("Browse...") );
217
218     char *psz_demuxdump = config_GetPsz( p_intf, "demuxdump-file" );
219     if( psz_demuxdump && *psz_demuxdump )
220     {
221         demuxdump_textctrl->SetValue( psz_demuxdump );
222     }
223     if( psz_demuxdump ) free( psz_demuxdump );
224
225     demuxdump_textctrl->Disable();
226     demuxdump_button->Disable();
227     demuxdump_sizer->Add( demuxdump_checkbox, 0,
228                           wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 10 );
229     demuxdump_sizer->Add( demuxdump_button, 0,
230                           wxALL | wxALIGN_CENTER_VERTICAL, 10 );
231     demuxdump_sizer->Add( demuxdump_textctrl, 1, wxALL, 10 );
232
233     /* Separation */
234     wxStaticLine *static_line = new wxStaticLine( panel, wxID_OK );
235
236     /* Create the buttons */
237     wxButton *ok_button = new wxButton( panel, wxID_OK, _("OK") );
238     ok_button->SetDefault();
239     wxButton *cancel_button = new wxButton( panel, wxID_CANCEL, _("Cancel") );
240
241
242     /* Update Disc panel */
243     wxCommandEvent dummy_event;
244     OnDiscTypeChange( dummy_event );
245
246     /* Update MRL */
247     wxNotebookEvent event = wxNotebookEvent( wxEVT_NULL, 0, i_access_method );
248     OnPageChange( event );
249
250     /* Place everything in sizers */
251     wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
252     button_sizer->Add( ok_button, 0, wxALL, 5 );
253     button_sizer->Add( cancel_button, 0, wxALL, 5 );
254     button_sizer->Layout();
255     wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
256     wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
257     panel_sizer->Add( mrl_sizer_sizer, 0, wxEXPAND, 5 );
258     panel_sizer->Add( label, 0, wxEXPAND | wxALL, 5 );
259     panel_sizer->Add( notebook_sizer, 1, wxEXPAND | wxALL, 5 );
260     panel_sizer->Add( sout_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
261     panel_sizer->Add( demuxdump_sizer, 0, wxEXPAND | wxALIGN_LEFT | wxALL, 5 );
262     panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
263     panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
264     panel_sizer->Layout();
265     panel->SetSizerAndFit( panel_sizer );
266     main_sizer->Add( panel, 1, wxGROW, 0 );
267     main_sizer->Layout();
268     SetSizerAndFit( main_sizer );
269 }
270
271 OpenDialog::~OpenDialog()
272 {
273 }
274
275 /*****************************************************************************
276  * Private methods.
277  *****************************************************************************/
278 wxPanel *OpenDialog::FilePanel( wxWindow* parent )
279 {
280     wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
281                                   wxSize(200, 200) );
282
283     wxBoxSizer *sizer = new wxBoxSizer( wxHORIZONTAL );
284
285     file_combo = new wxComboBox( panel, FileName_Event, "",
286                                  wxPoint(20,25), wxSize(200, -1), 0, NULL );
287     wxButton *browse_button = new wxButton( panel, FileBrowse_Event,
288                                             _("Browse...") );
289     sizer->Add( file_combo, 1, wxALL, 5 );
290     sizer->Add( browse_button, 0, wxALL, 5 );
291
292     panel->SetSizerAndFit( sizer );
293     return panel;
294 }
295
296 wxPanel *OpenDialog::DiscPanel( wxWindow* parent )
297 {
298     wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
299                                   wxSize(200, 200) );
300
301     wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
302     wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 3, 20 );
303
304     static const wxString disc_type_array[] =
305     {
306         _("DVD"),
307         _("DVD (menus support)"),
308         _("VCD")
309     };
310
311     disc_type = new wxRadioBox( panel, DiscType_Event, _("Disc type"),
312                                 wxDefaultPosition, wxDefaultSize,
313                                 WXSIZEOF(disc_type_array), disc_type_array,
314                                 WXSIZEOF(disc_type_array), wxRA_SPECIFY_COLS );
315     sizer_row->Add( disc_type, 0, wxEXPAND | wxALL, 5 );
316
317     wxStaticText *label = new wxStaticText( panel, -1, _("Device Name") );
318     disc_device = new wxTextCtrl( panel, DiscDevice_Event, "",
319                                   wxDefaultPosition, wxDefaultSize,
320                                   wxTE_PROCESS_ENTER);
321
322     sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
323     sizer->Add( disc_device, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
324
325     label = new wxStaticText( panel, -1, _("Title") );
326     disc_title = new wxSpinCtrl( panel, DiscTitle_Event );
327
328     sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
329     sizer->Add( disc_title, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
330
331     label = new wxStaticText( panel, -1, _("Chapter") );
332     disc_chapter = new wxSpinCtrl( panel, DiscChapter_Event );
333     sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
334     sizer->Add( disc_chapter, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
335     sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
336
337     panel->SetSizerAndFit( sizer_row );
338     return panel;
339 }
340
341 wxPanel *OpenDialog::NetPanel( wxWindow* parent )
342 {
343     int i;
344     wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
345                                   wxSize(200, 200) );
346
347     wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
348     wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 4, 20 );
349
350     static const wxString net_type_array[] =
351     {
352         _("UDP/RTP"),
353         _("UDP/RTP Multicast"),
354         _("Channel server"),
355         _("HTTP/FTP/MMS")
356     };
357
358     for( i=0; i<4; i++ )
359     {
360         net_radios[i] = new wxRadioButton( panel, NetRadio1_Event + i,
361                                            net_type_array[i],
362                                            wxDefaultPosition, wxDefaultSize,
363                                            wxRB_SINGLE );
364
365         net_subpanels[i] = new wxPanel( panel, -1,
366                                         wxDefaultPosition, wxDefaultSize );
367     }
368
369     /* UDP/RTP row */
370     wxFlexGridSizer *subpanel_sizer;
371     wxStaticText *label;
372     int val = config_GetInt( p_intf, "server-port" );
373     subpanel_sizer = new wxFlexGridSizer( 2, 1, 20 );
374     label = new wxStaticText( net_subpanels[0], -1, _("Port") );
375     net_ports[0] = new wxSpinCtrl( net_subpanels[0], NetPort1_Event,
376                                    wxString::Format(_("%d"), val),
377                                    wxDefaultPosition, wxDefaultSize,
378                                    wxSP_ARROW_KEYS,
379                                    0, 16000, val);
380
381     subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
382     subpanel_sizer->Add( net_ports[0], 1,
383                          wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
384     net_subpanels[0]->SetSizerAndFit( subpanel_sizer );
385     net_radios[0]->SetValue( TRUE );
386
387     /* UDP/RTP Multicast row */
388     subpanel_sizer = new wxFlexGridSizer( 4, 1, 20 );
389     label = new wxStaticText( net_subpanels[1], -1, _("Address") );
390     net_addrs[1] = new wxTextCtrl( net_subpanels[1], NetAddr2_Event, "",
391                                    wxDefaultPosition, wxDefaultSize,
392                                    wxTE_PROCESS_ENTER);
393     subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
394     subpanel_sizer->Add( net_addrs[1], 1,
395                          wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
396
397     label = new wxStaticText( net_subpanels[1], -1, _("Port") );
398     net_ports[1] = new wxSpinCtrl( net_subpanels[1], NetPort2_Event,
399                                    wxString::Format(_("%d"), val),
400                                    wxDefaultPosition, wxDefaultSize,
401                                    wxSP_ARROW_KEYS,
402                                    0, 16000, val);
403
404     subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
405     subpanel_sizer->Add( net_ports[1], 1,
406                          wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
407     net_subpanels[1]->SetSizerAndFit( subpanel_sizer );
408
409     /* Channel server row */
410     subpanel_sizer = new wxFlexGridSizer( 4, 1, 20 );
411     label = new wxStaticText( net_subpanels[2], -1, _("Address") );
412     net_addrs[2] = new wxTextCtrl( net_subpanels[2], NetAddr3_Event, "",
413                                    wxDefaultPosition, wxDefaultSize,
414                                    wxTE_PROCESS_ENTER);
415     subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
416     subpanel_sizer->Add( net_addrs[2], 1,
417                          wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
418
419     label = new wxStaticText( net_subpanels[2], -1, _("Port") );
420     net_ports[2] = new wxSpinCtrl( net_subpanels[2], NetPort3_Event,
421                                    wxString::Format(_("%d"), val),
422                                    wxDefaultPosition, wxDefaultSize,
423                                    wxSP_ARROW_KEYS,
424                                    0, 16000, val);
425
426     subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
427     subpanel_sizer->Add( net_ports[2], 1,
428                          wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
429     net_subpanels[2]->SetSizerAndFit( subpanel_sizer );
430
431     /* HTTP row */
432     subpanel_sizer = new wxFlexGridSizer( 2, 1, 20 );
433     label = new wxStaticText( net_subpanels[3], -1, _("URL") );
434     net_addrs[3] = new wxTextCtrl( net_subpanels[3], NetAddr4_Event, "",
435                                    wxDefaultPosition, wxSize( 200, -1 ),
436                                    wxTE_PROCESS_ENTER);
437     subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
438     subpanel_sizer->Add( net_addrs[3], 1,
439                          wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
440     net_subpanels[3]->SetSizerAndFit( subpanel_sizer );
441
442     /* Stuff everything into the main panel */
443     for( i=0; i<4; i++ )
444     {
445         sizer->Add( net_radios[i], 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
446         sizer->Add( net_subpanels[i], 1,
447                     wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
448     }
449
450     sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
451
452     panel->SetSizerAndFit( sizer_row );
453     return panel;
454 }
455
456 wxPanel *OpenDialog::SatPanel( wxWindow* parent )
457 {
458     wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
459                                   wxSize(200, 200) );
460     return panel;
461 }
462
463 void OpenDialog::UpdateMRL( int i_access_method )
464 {
465     wxString demux;
466
467     i_current_access_method = i_access_method;
468
469     /* Check if the user asked for demuxdump */
470     if( demuxdump_checkbox->GetValue() )
471     {
472         demux = "/demuxdump";
473     }
474
475     switch( i_access_method )
476     {
477     case FILE_ACCESS:
478         mrl = "file" + demux + "://" + file_combo->GetValue();
479         break;
480     case DISC_ACCESS:
481         mrl = ( disc_type->GetSelection() == 0 ? "dvdold" :
482                 disc_type->GetSelection() == 1 ? "dvd" : "vcd" )
483                   + demux + "://"
484                   + disc_device->GetLineText(0)
485                   + wxString::Format( "@%d:%d",
486                                       disc_title->GetValue(),
487                                       disc_chapter->GetValue() );
488         break;
489     case NET_ACCESS:
490         switch( i_net_type )
491         {
492         case 0:
493             if( net_ports[0]->GetValue() !=
494                 config_GetInt( p_intf, "server-port" ) )
495             {
496                 mrl = "udp" + demux +
497                        wxString::Format( "://@:%d", net_ports[0]->GetValue() );
498             }
499             else
500             {
501                 mrl = "udp" + demux + "://";
502             }
503             break;
504
505         case 1:
506             mrl = "udp" + demux + "://@" + net_addrs[1]->GetLineText(0);
507             if( net_ports[1]->GetValue() !=
508                 config_GetInt( p_intf, "server-port" ) )
509             {
510                 mrl = mrl + wxString::Format( ":%d",
511                                               net_ports[1]->GetValue() );
512             }
513             break;
514
515         case 2:
516             mrl = "udp" + demux + "://";
517             break;
518
519         case 3:
520             /* http access */     
521             mrl = "http" + demux + "://" + net_addrs[3]->GetLineText(0);
522             break;
523         }
524         break;
525     case SAT_ACCESS:
526         mrl = "satellite" + demux + "://";
527         break;
528     default:
529         break;
530     }
531
532     mrl_combo->SetValue( mrl );
533 }
534
535 /*****************************************************************************
536  * Events methods.
537  *****************************************************************************/
538 void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
539 {
540     EndModal( wxID_OK );
541 }
542
543 void OpenDialog::OnCancel( wxCommandEvent& WXUNUSED(event) )
544 {
545     EndModal( wxID_CANCEL );
546 }
547
548 void OpenDialog::OnPageChange( wxNotebookEvent& event )
549 {
550     UpdateMRL( event.GetSelection() );
551 }
552
553 void OpenDialog::OnMRLChange( wxCommandEvent& event )
554 {
555     mrl = event.GetString();
556 }
557
558 /*****************************************************************************
559  * File panel event methods.
560  *****************************************************************************/
561 void OpenDialog::OnFilePanelChange( wxCommandEvent& WXUNUSED(event) )
562 {
563     UpdateMRL( FILE_ACCESS );
564 }
565
566 void OpenDialog::OnFileBrowse( wxCommandEvent& WXUNUSED(event) )
567 {
568     wxFileDialog dialog( this, _("Open file"), "", "", "*.*",
569                          wxOPEN );
570
571     if( dialog.ShowModal() == wxID_OK )
572     {
573         file_combo->SetValue( dialog.GetPath() );      
574         UpdateMRL( FILE_ACCESS );
575     }
576 }
577
578 /*****************************************************************************
579  * Disc panel event methods.
580  *****************************************************************************/
581 void OpenDialog::OnDiscPanelChange( wxCommandEvent& WXUNUSED(event) )
582 {
583     UpdateMRL( DISC_ACCESS );
584 }
585
586 void OpenDialog::OnDiscTypeChange( wxCommandEvent& WXUNUSED(event) )
587 {
588     char *psz_device;
589
590     switch( disc_type->GetSelection() )
591     {
592     case 2:
593         psz_device = config_GetPsz( p_intf, "vcd" );
594         disc_device->SetValue( psz_device ? psz_device : "" );
595         break;
596
597     default:
598         psz_device = config_GetPsz( p_intf, "dvd" );
599         disc_device->SetValue( psz_device ? psz_device : "" );
600         break;
601     }
602
603     if( psz_device ) free( psz_device );
604
605     switch( disc_type->GetSelection() )
606     {
607     case 1:
608         disc_title->SetRange( 0, 255 );
609         disc_title->SetValue( 0 );
610         break;
611
612     default:
613         disc_title->SetRange( 1, 255 );
614         disc_title->SetValue( 1 );
615         break;
616     }
617
618     disc_chapter->SetRange( 1, 255 );
619     disc_chapter->SetValue( 1 );
620
621     UpdateMRL( DISC_ACCESS );
622 }
623
624 /*****************************************************************************
625  * Net panel event methods.
626  *****************************************************************************/
627 void OpenDialog::OnNetPanelChange( wxCommandEvent& WXUNUSED(event) )
628 {
629     UpdateMRL( NET_ACCESS );
630 }
631
632 void OpenDialog::OnNetTypeChange( wxCommandEvent& event )
633 {
634     int i;
635
636     i_net_type = event.GetId() - NetRadio1_Event;
637
638     for(i=0; i<4; i++)
639     {
640         net_radios[i]->SetValue( event.GetId() == (NetRadio1_Event+i) );
641         net_subpanels[i]->Enable( event.GetId() == (NetRadio1_Event+i) );
642     }
643
644     UpdateMRL( NET_ACCESS );
645 }
646
647 /*****************************************************************************
648  * Stream output event methods.
649  *****************************************************************************/
650 void OpenDialog::OnSoutEnable( wxCommandEvent& event )
651 {
652     sout_button->Enable( event.GetInt() != 0 );
653     if( !event.GetInt() )
654     {
655         config_PutPsz( p_intf, "sout", "" );
656     }
657     else
658     {
659         demuxdump_checkbox->SetValue( 0 );
660         wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
661         event.SetInt( 0 );
662         OnDemuxDumpEnable( event );
663     }
664 }
665
666 void OpenDialog::OnSoutSettings( wxCommandEvent& WXUNUSED(event) )
667 {
668     /* Show/hide the open dialog */
669     SoutDialog dialog( p_intf, p_main_interface );
670
671     if( dialog.ShowModal() == wxID_OK )
672     {
673         config_PutPsz( p_intf, "sout", (char *)dialog.mrl.c_str() );
674     }
675 }
676
677 /*****************************************************************************
678  * Demux dump event methods.
679  *****************************************************************************/
680 void OpenDialog::OnDemuxDumpEnable( wxCommandEvent& event )
681 {
682     demuxdump_textctrl->Enable( event.GetInt() != 0 );
683     demuxdump_button->Enable( event.GetInt() != 0 );
684
685     if( event.GetInt() )
686     {
687         sout_checkbox->SetValue( 0 );
688         wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
689         event.SetInt( 0 );
690         OnSoutEnable( event );
691     }
692
693     UpdateMRL( i_current_access_method );
694 }
695
696 void OpenDialog::OnDemuxDumpBrowse( wxCommandEvent& WXUNUSED(event) )
697 {
698     wxFileDialog dialog( this, _("Save file"), "", "", "*.*", wxSAVE );
699
700     if( dialog.ShowModal() == wxID_OK )
701     {
702         demuxdump_textctrl->SetValue( dialog.GetPath() );
703         wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
704         OnDemuxDumpChange( event );
705     }
706 }
707
708 void OpenDialog::OnDemuxDumpChange( wxCommandEvent& WXUNUSED(event) )
709 {
710     config_PutPsz( p_intf, "demuxdump-file",
711                    demuxdump_textctrl->GetValue() );
712 }