1
/*****************************************************************************
2
* open.cpp : wxWindows plugin for vlc
3
*****************************************************************************
4
* Copyright (C) 2000-2004 VideoLAN
5
* $Id: open.cpp 7728 2004-05-20 10:16:52Z gbazin $
7
* Authors: Gildas Bazin <gbazin@videolan.org>
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.
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.
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
*****************************************************************************/
24
/*****************************************************************************
26
*****************************************************************************/
27
#include <stdlib.h> /* malloc(), free() */
28
#include <errno.h> /* ENOMEM */
29
#include <string.h> /* strerror() */
34
#include <wx/combobox.h>
35
#include <wx/statline.h>
36
#include <wx/tokenzr.h>
40
#include "wxwindows.h"
41
#include "preferences_widgets.h"
44
# define wxRB_SINGLE 0
47
/*****************************************************************************
49
*****************************************************************************/
51
/* IDs for the controls and the menu commands */
54
Notebook_Event = wxID_HIGHEST,
66
NetRadio1_Event, NetRadio2_Event, NetRadio3_Event, NetRadio4_Event,
67
NetPort1_Event, NetPort2_Event, NetPort3_Event,
68
NetAddr1_Event, NetAddr2_Event, NetAddr3_Event, NetAddr4_Event,
72
SubsFileSettings_Event,
80
BEGIN_EVENT_TABLE(OpenDialog, wxDialog)
82
EVT_BUTTON(wxID_OK, OpenDialog::OnOk)
83
EVT_BUTTON(wxID_CANCEL, OpenDialog::OnCancel)
85
EVT_NOTEBOOK_PAGE_CHANGED(Notebook_Event, OpenDialog::OnPageChange)
87
EVT_TEXT(MRL_Event, OpenDialog::OnMRLChange)
89
/* Events generated by the file panel */
90
EVT_TEXT(FileName_Event, OpenDialog::OnFilePanelChange)
91
EVT_BUTTON(FileBrowse_Event, OpenDialog::OnFileBrowse)
93
/* Events generated by the disc panel */
94
EVT_RADIOBOX(DiscType_Event, OpenDialog::OnDiscTypeChange)
95
EVT_TEXT(DiscDevice_Event, OpenDialog::OnDiscDeviceChange)
96
EVT_TEXT(DiscDevice_Event, OpenDialog::OnDiscPanelChange)
97
EVT_TEXT(DiscTitle_Event, OpenDialog::OnDiscPanelChange)
98
EVT_SPINCTRL(DiscTitle_Event, OpenDialog::OnDiscPanelChange)
99
EVT_TEXT(DiscChapter_Event, OpenDialog::OnDiscPanelChange)
100
EVT_SPINCTRL(DiscChapter_Event, OpenDialog::OnDiscPanelChange)
102
/* Events generated by the net panel */
103
EVT_RADIOBUTTON(NetRadio1_Event, OpenDialog::OnNetTypeChange)
104
EVT_RADIOBUTTON(NetRadio2_Event, OpenDialog::OnNetTypeChange)
105
EVT_RADIOBUTTON(NetRadio3_Event, OpenDialog::OnNetTypeChange)
106
EVT_RADIOBUTTON(NetRadio4_Event, OpenDialog::OnNetTypeChange)
107
EVT_TEXT(NetPort1_Event, OpenDialog::OnNetPanelChange)
108
EVT_SPINCTRL(NetPort1_Event, OpenDialog::OnNetPanelChange)
109
EVT_TEXT(NetPort2_Event, OpenDialog::OnNetPanelChange)
110
EVT_SPINCTRL(NetPort2_Event, OpenDialog::OnNetPanelChange)
111
EVT_TEXT(NetPort3_Event, OpenDialog::OnNetPanelChange)
112
EVT_SPINCTRL(NetPort3_Event, OpenDialog::OnNetPanelChange)
113
EVT_TEXT(NetAddr2_Event, OpenDialog::OnNetPanelChange)
114
EVT_TEXT(NetAddr3_Event, OpenDialog::OnNetPanelChange)
115
EVT_TEXT(NetAddr4_Event, OpenDialog::OnNetPanelChange)
116
EVT_CHECKBOX(NetForceIPv6_Event, OpenDialog::OnNetPanelChange)
118
/* Events generated by the subtitle file buttons */
119
EVT_CHECKBOX(SubsFileEnable_Event, OpenDialog::OnSubsFileEnable)
120
EVT_BUTTON(SubsFileSettings_Event, OpenDialog::OnSubsFileSettings)
122
/* Events generated by the stream output buttons */
123
EVT_CHECKBOX(SoutEnable_Event, OpenDialog::OnSoutEnable)
124
EVT_BUTTON(SoutSettings_Event, OpenDialog::OnSoutSettings)
126
/* Hide the window when the user closes the window */
127
EVT_CLOSE(OpenDialog::OnCancel)
131
/*****************************************************************************
133
*****************************************************************************/
134
WX_DEFINE_ARRAY(ConfigControl *, ArrayOfConfigControls);
136
class AutoBuiltPanel : public wxPanel
141
AutoBuiltPanel( wxWindow *, OpenDialog *, intf_thread_t *,
144
virtual ~AutoBuiltPanel() {}
146
void UpdateAdvancedMRL();
149
ArrayOfConfigControls config_array;
150
ArrayOfConfigControls advanced_config_array;
151
wxComboBox *p_advanced_mrl_combo;
154
intf_thread_t *p_intf;
155
OpenDialog *p_open_dialog;
157
void OnAdvanced( wxCommandEvent& event );
158
wxDialog *p_advanced_dialog;
160
DECLARE_EVENT_TABLE();
163
BEGIN_EVENT_TABLE(AutoBuiltPanel, wxPanel)
164
EVT_BUTTON(AdvancedOptions_Event, AutoBuiltPanel::OnAdvanced)
167
static void AutoBuildCallback( void *p_data )
169
((OpenDialog *)p_data)->UpdateMRL();
172
static void AutoBuildAdvancedCallback( void *p_data )
174
((AutoBuiltPanel *)p_data)->UpdateAdvancedMRL();
177
AutoBuiltPanel::AutoBuiltPanel( wxWindow *parent, OpenDialog *dialog,
178
intf_thread_t *_p_intf,
179
const module_t *p_module )
180
: wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize ),
181
name( wxU(p_module->psz_object_name) ),
182
p_advanced_mrl_combo( NULL ),
183
p_intf( _p_intf ), p_open_dialog( dialog ), p_advanced_dialog( NULL )
185
wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
186
module_config_t *p_item = p_module->p_config;
187
bool b_advanced = false;
191
if( !(p_item->i_type & CONFIG_HINT) && p_item->b_advanced )
194
if( p_item->i_type & CONFIG_HINT || p_item->b_advanced )
197
ConfigControl *control =
198
CreateConfigControl( VLC_OBJECT(p_intf), p_item, this );
200
config_array.Add( control );
202
/* Don't add items that were not recognized */
203
if( control == NULL ) continue;
205
control->SetUpdateCallback( AutoBuildCallback, (void *)dialog );
207
sizer->Add( control, 0, wxEXPAND | wxALL, 2 );
209
while( p_item->i_type != CONFIG_HINT_END && p_item++ );
213
wxPanel *dummy_panel = new wxPanel( this, -1 );
214
sizer->Add( dummy_panel, 1 );
217
new wxButton( this, AdvancedOptions_Event,
218
wxU(_("Advanced options...")) );
219
sizer->Add( button, 0, wxALL, 5 );
221
/* Build the advanced dialog */
223
new wxDialog( this, -1, ((wxString)wxU(_("Advanced options"))) +
224
wxT(" (") + wxU( p_module->psz_longname ) + wxT(")"),
225
wxDefaultPosition, wxDefaultSize,
226
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER );
228
wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
230
/* Create MRL combobox */
231
wxBoxSizer *mrl_sizer_sizer = new wxBoxSizer( wxHORIZONTAL );
232
wxStaticBox *mrl_box =
233
new wxStaticBox( p_advanced_dialog, -1,
234
wxU(_("Advanced options")) );
235
wxStaticBoxSizer *mrl_sizer =
236
new wxStaticBoxSizer( mrl_box, wxHORIZONTAL );
237
wxStaticText *mrl_label =
238
new wxStaticText( p_advanced_dialog, -1, wxU(_("Options:")) );
239
p_advanced_mrl_combo =
240
new wxComboBox( p_advanced_dialog, MRL_Event, wxT(""),
241
wxDefaultPosition, wxDefaultSize );
242
mrl_sizer->Add( mrl_label, 0, wxALL | wxALIGN_CENTER, 5 );
243
mrl_sizer->Add( p_advanced_mrl_combo, 1, wxALL | wxALIGN_CENTER, 5 );
244
mrl_sizer_sizer->Add( mrl_sizer, 1, wxEXPAND | wxALL, 5 );
245
sizer->Add( mrl_sizer_sizer, 0, wxEXPAND | wxALL, 2 );
247
/* Add advanced options to panel */
248
module_config_t *p_item = p_module->p_config;
251
if( p_item->i_type & CONFIG_HINT || !p_item->b_advanced )
254
ConfigControl *control =
255
CreateConfigControl( VLC_OBJECT(p_intf), p_item,
258
advanced_config_array.Add( control );
260
/* Don't add items that were not recognized */
261
if( control == NULL ) continue;
263
control->SetUpdateCallback( AutoBuildAdvancedCallback,
266
sizer->Add( control, 0, wxEXPAND | wxALL, 2 );
268
while( p_item->i_type != CONFIG_HINT_END && p_item++ );
271
dummy_panel = new wxPanel( p_advanced_dialog, -1 );
272
sizer->Add( dummy_panel, 1 );
273
wxStaticLine *static_line =
274
new wxStaticLine( p_advanced_dialog, wxID_OK );
275
sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
278
wxButton *ok_button =
279
new wxButton( p_advanced_dialog, wxID_OK, wxU(_("OK")) );
280
ok_button->SetDefault();
281
wxButton *cancel_button =
282
new wxButton( p_advanced_dialog, wxID_CANCEL, wxU(_("Cancel")) );
283
wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
284
button_sizer->Add( ok_button, 0, wxALL, 5 );
285
button_sizer->Add( cancel_button, 0, wxALL, 5 );
286
button_sizer->Layout();
287
sizer->Add( button_sizer, 0, wxALL, 0 );
289
sizer->SetMinSize( 400, -1 );
290
p_advanced_dialog->SetSizerAndFit( sizer );
293
this->SetSizerAndFit( sizer );
296
void AutoBuiltPanel::OnAdvanced( wxCommandEvent& event )
298
if( p_advanced_dialog->ShowModal() == wxID_OK )
301
p_open_dialog->UpdateMRL();
305
void AutoBuiltPanel::UpdateAdvancedMRL()
309
for( int i = 0; i < (int)advanced_config_array.GetCount(); i++ )
311
ConfigControl *control = advanced_config_array.Item(i);
313
mrltemp += (i ? wxT(" :") : wxT(":"));
315
if( control->GetType() == CONFIG_ITEM_BOOL &&
316
!control->GetIntValue() ) mrltemp += wxT("no-");
318
mrltemp += control->GetName();
320
switch( control->GetType() )
322
case CONFIG_ITEM_STRING:
323
case CONFIG_ITEM_FILE:
324
case CONFIG_ITEM_DIRECTORY:
325
case CONFIG_ITEM_MODULE:
326
mrltemp += wxT("=\"") + control->GetPszValue() + wxT("\"");
328
case CONFIG_ITEM_INTEGER:
330
wxString::Format( wxT("=%i"), control->GetIntValue() );
332
case CONFIG_ITEM_FLOAT:
334
wxString::Format(wxT("=%f"), control->GetFloatValue());
339
p_advanced_mrl_combo->SetValue( mrltemp );
342
/*****************************************************************************
344
*****************************************************************************/
345
OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
346
int i_access_method, int i_arg ):
347
wxDialog( _p_parent, -1, wxU(_("Open...")), wxDefaultPosition,
348
wxDefaultSize, wxDEFAULT_FRAME_STYLE )
350
OpenDialog( _p_intf, _p_parent, i_access_method, i_arg, OPEN_NORMAL );
353
OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
354
int i_access_method, int i_arg, int _i_method ):
355
wxDialog( _p_parent, -1, wxU(_("Open...")), wxDefaultPosition,
356
wxDefaultSize, wxDEFAULT_FRAME_STYLE )
358
/* Initializations */
359
i_method = _i_method;
361
p_parent = _p_parent;
362
SetIcon( *p_intf->p_sys->p_icon );
364
i_disc_type_selection = 0;
368
subsfile_dialog = NULL;
369
b_disc_device_changed = false;
371
/* Create a panel to put everything in */
372
wxPanel *panel = new wxPanel( this, -1 );
373
panel->SetAutoLayout( TRUE );
375
/* Create MRL combobox */
376
wxBoxSizer *mrl_sizer_sizer = new wxBoxSizer( wxHORIZONTAL );
377
wxStaticBox *mrl_box = new wxStaticBox( panel, -1,
378
wxU(_("Media Resource Locator (MRL)")) );
379
wxStaticBoxSizer *mrl_sizer = new wxStaticBoxSizer( mrl_box,
381
wxStaticText *mrl_label = new wxStaticText( panel, -1,
383
mrl_combo = new wxComboBox( panel, MRL_Event, wxT(""),
384
wxPoint(20,25), wxSize(120, -1),
386
mrl_combo->SetToolTip( wxU(_("You can use this field directly by typing "
387
"the full MRL you want to open.\n""Alternatively, the field will be "
388
"filled automatically when you use the controls below.")) );
390
mrl_sizer->Add( mrl_label, 0, wxALL | wxALIGN_CENTER, 5 );
391
mrl_sizer->Add( mrl_combo, 1, wxALL | wxALIGN_CENTER, 5 );
392
mrl_sizer_sizer->Add( mrl_sizer, 1, wxEXPAND | wxALL, 5 );
395
/* Create Static Text */
396
wxStaticText *label = new wxStaticText( panel, -1,
397
wxU(_("Alternatively, you can build an MRL using one of the "
398
"following predefined targets:")) );
400
wxFlexGridSizer *sout_sizer = NULL;
401
wxStaticLine *static_line = NULL;
403
if( i_method == OPEN_NORMAL )
405
/* Create Stream Output checkox */
406
sout_sizer = new wxFlexGridSizer( 2, 1, 20 );
409
sout_checkbox = new wxCheckBox( panel, SoutEnable_Event,
410
wxU(_("Stream output")) );
411
sout_checkbox->SetToolTip( wxU(_("Use VLC as a server of streams")) );
412
sout_sizer->Add( sout_checkbox, 0,
413
wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
414
sout_button = new wxButton( panel, SoutSettings_Event,
415
wxU(_("Settings...")) );
416
sout_button->Disable();
418
char *psz_sout = config_GetPsz( p_intf, "sout" );
419
if( psz_sout && *psz_sout )
421
sout_checkbox->SetValue(TRUE);
422
sout_button->Enable();
423
subsfile_mrl.Add( wxString(wxT("sout=")) + wxL2U(psz_sout) );
425
if( psz_sout ) free( psz_sout );
427
sout_sizer->Add( sout_button, 1, wxALIGN_LEFT |
428
wxALIGN_CENTER_VERTICAL );
431
static_line = new wxStaticLine( panel, wxID_OK );
434
/* Create the buttons */
435
wxButton *ok_button = new wxButton( panel, wxID_OK, wxU(_("OK")) );
436
ok_button->SetDefault();
437
wxButton *cancel_button = new wxButton( panel, wxID_CANCEL,
440
/* Create notebook */
441
notebook = new wxNotebook( panel, Notebook_Event );
442
wxNotebookSizer *notebook_sizer = new wxNotebookSizer( notebook );
444
notebook->AddPage( FilePanel( notebook ), wxU(_("File")),
445
i_access_method == FILE_ACCESS );
446
notebook->AddPage( DiscPanel( notebook ), wxU(_("Disc")),
447
i_access_method == DISC_ACCESS );
448
notebook->AddPage( NetPanel( notebook ), wxU(_("Network")),
449
i_access_method == NET_ACCESS );
451
module_t *p_module = config_FindModule( VLC_OBJECT(p_intf), "v4l" );
454
AutoBuiltPanel *autopanel =
455
new AutoBuiltPanel( notebook, this, p_intf, p_module );
456
input_tab_array.Add( autopanel );
457
notebook->AddPage( autopanel, wxU( p_module->psz_shortname ),
458
i_access_method == CAPTURE_ACCESS );
461
p_module = config_FindModule( VLC_OBJECT(p_intf), "pvr" );
464
AutoBuiltPanel *autopanel =
465
new AutoBuiltPanel( notebook, this, p_intf, p_module );
466
input_tab_array.Add( autopanel );
467
notebook->AddPage( autopanel, wxU( p_module->psz_shortname ),
468
i_access_method == CAPTURE_ACCESS );
471
p_module = config_FindModule( VLC_OBJECT(p_intf), "dvb" );
474
AutoBuiltPanel *autopanel =
475
new AutoBuiltPanel( notebook, this, p_intf, p_module );
476
input_tab_array.Add( autopanel );
477
notebook->AddPage( autopanel, wxU( p_module->psz_shortname ),
478
i_access_method == CAPTURE_ACCESS );
481
p_module = config_FindModule( VLC_OBJECT(p_intf), "dshow" );
484
AutoBuiltPanel *autopanel =
485
new AutoBuiltPanel( notebook, this, p_intf, p_module );
486
input_tab_array.Add( autopanel );
487
notebook->AddPage( autopanel, wxU( p_module->psz_shortname ),
488
i_access_method == CAPTURE_ACCESS );
491
/* Update Disc panel */
492
wxCommandEvent dummy_event;
493
OnDiscTypeChange( dummy_event );
495
/* Update Net panel */
496
dummy_event.SetId( NetRadio1_Event );
497
OnNetTypeChange( dummy_event );
500
wxNotebookEvent event( wxEVT_NULL, 0, i_access_method );
501
OnPageChange( event );
503
/* Place everything in sizers */
504
wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
505
button_sizer->Add( ok_button, 0, wxALL, 5 );
506
button_sizer->Add( cancel_button, 0, wxALL, 5 );
507
button_sizer->Layout();
508
wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
509
wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
510
panel_sizer->Add( mrl_sizer_sizer, 0, wxEXPAND, 5 );
511
panel_sizer->Add( label, 0, wxEXPAND | wxALL, 5 );
512
panel_sizer->Add( notebook_sizer, 1, wxEXPAND | wxALL, 5 );
513
if( i_method == OPEN_NORMAL)
515
panel_sizer->Add( sout_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
516
panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
518
panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
519
panel_sizer->Layout();
520
panel->SetSizerAndFit( panel_sizer );
521
main_sizer->Add( panel, 1, wxGROW, 0 );
522
main_sizer->Layout();
523
SetSizerAndFit( main_sizer );
526
OpenDialog::~OpenDialog()
529
if( file_dialog ) delete file_dialog;
530
if( sout_dialog ) delete sout_dialog;
531
if( subsfile_dialog ) delete subsfile_dialog;
534
int OpenDialog::Show( int i_access_method, int i_arg )
536
notebook->SetSelection( i_access_method );
537
int i_ret = wxDialog::Show();
544
int OpenDialog::Show()
546
int i_ret = wxDialog::Show();
552
/*****************************************************************************
554
*****************************************************************************/
555
wxPanel *OpenDialog::FilePanel( wxWindow* parent )
557
wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
560
wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
562
/* Create browse file line */
563
wxBoxSizer *file_sizer = new wxBoxSizer( wxHORIZONTAL );
565
file_combo = new wxComboBox( panel, FileName_Event, wxT(""),
566
wxPoint(20,25), wxSize(200, -1), 0, NULL );
567
wxButton *browse_button = new wxButton( panel, FileBrowse_Event,
568
wxU(_("Browse...")) );
569
file_sizer->Add( file_combo, 1, wxALL, 5 );
570
file_sizer->Add( browse_button, 0, wxALL, 5 );
572
/* Create Subtitles File checkox */
573
wxFlexGridSizer *subsfile_sizer = new wxFlexGridSizer( 2, 1, 20 );
574
subsfile_checkbox = new wxCheckBox( panel, SubsFileEnable_Event,
575
wxU(_("Subtitle options")) );
576
subsfile_checkbox->SetToolTip( wxU(_("Force options for separate subtitle files.")) );
577
subsfile_sizer->Add( subsfile_checkbox, 0,
578
wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
579
subsfile_button = new wxButton( panel, SubsFileSettings_Event,
580
wxU(_("Settings...")) );
581
subsfile_button->Disable();
583
char *psz_subsfile = config_GetPsz( p_intf, "sub-file" );
584
if( psz_subsfile && *psz_subsfile )
586
subsfile_checkbox->SetValue(TRUE);
587
subsfile_button->Enable();
588
subsfile_mrl.Add( wxString(wxT("sub-file=")) + wxL2U(psz_subsfile) );
590
if( psz_subsfile ) free( psz_subsfile );
592
subsfile_sizer->Add( subsfile_button, 1,
593
wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
595
sizer->Add( file_sizer, 0, wxEXPAND | wxALL, 5 );
596
sizer->Add( subsfile_sizer, 0, wxEXPAND | wxALL, 5 );
597
panel->SetSizerAndFit( sizer );
601
wxPanel *OpenDialog::DiscPanel( wxWindow* parent )
603
wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
606
wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
607
wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 3, 20 );
609
static const wxString disc_type_array[] =
611
wxU(_("DVD (menus)")),
618
disc_type = new wxRadioBox( panel, DiscType_Event, wxU(_("Disc type")),
619
wxDefaultPosition, wxDefaultSize,
620
WXSIZEOF(disc_type_array), disc_type_array,
621
WXSIZEOF(disc_type_array), wxRA_SPECIFY_COLS );
623
sizer_row->Add( disc_type, i_disc_type_selection, wxEXPAND | wxALL, 5 );
625
wxStaticText *label = new wxStaticText( panel, -1, wxU(_("Device name")) );
626
disc_device = new wxTextCtrl( panel, DiscDevice_Event, wxT(""),
627
wxDefaultPosition, wxDefaultSize,
630
sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
631
sizer->Add( disc_device, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
633
disc_title_label = new wxStaticText( panel, -1, wxU(_("Title")) );
634
disc_title = new wxSpinCtrl( panel, DiscTitle_Event );
636
sizer->Add( disc_title_label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
637
sizer->Add( disc_title, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
639
disc_chapter_label = new wxStaticText( panel, -1, wxU(_("Chapter")) );
640
disc_chapter = new wxSpinCtrl( panel, DiscChapter_Event );
641
sizer->Add( disc_chapter_label, 0,
642
wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
643
sizer->Add( disc_chapter, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
644
sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
646
panel->SetSizerAndFit( sizer_row );
650
wxPanel *OpenDialog::NetPanel( wxWindow* parent )
653
wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
656
wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
657
wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 4, 20 );
659
static const wxString net_type_array[] =
662
wxU(_("UDP/RTP Multicast")),
663
wxU(_("HTTP/FTP/MMS")),
669
net_radios[i] = new wxRadioButton( panel, NetRadio1_Event + i,
671
wxDefaultPosition, wxDefaultSize,
674
net_subpanels[i] = new wxPanel( panel, -1,
675
wxDefaultPosition, wxDefaultSize );
679
wxFlexGridSizer *subpanel_sizer;
681
i_net_ports[0] = config_GetInt( p_intf, "server-port" );
682
subpanel_sizer = new wxFlexGridSizer( 3, 1, 20 );
683
label = new wxStaticText( net_subpanels[0], -1, wxU(_("Port")) );
684
net_ports[0] = new wxSpinCtrl( net_subpanels[0], NetPort1_Event,
685
wxString::Format(wxT("%d"), i_net_ports[0]),
686
wxDefaultPosition, wxDefaultSize,
688
0, 16000, i_net_ports[0] );
690
subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
691
subpanel_sizer->Add( net_ports[0], 1,
692
wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
693
net_ipv6 = new wxCheckBox( net_subpanels[0], NetForceIPv6_Event,
694
wxU(_("Force IPv6")));
695
subpanel_sizer->Add( net_ipv6, 0,
696
wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
697
net_subpanels[0]->SetSizerAndFit( subpanel_sizer );
698
net_radios[0]->SetValue( TRUE );
700
/* UDP/RTP Multicast row */
701
subpanel_sizer = new wxFlexGridSizer( 4, 1, 20 );
702
label = new wxStaticText( net_subpanels[1], -1, wxU(_("Address")) );
703
net_addrs[1] = new wxTextCtrl( net_subpanels[1], NetAddr2_Event, wxT(""),
704
wxDefaultPosition, wxDefaultSize,
706
subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
707
subpanel_sizer->Add( net_addrs[1], 1,
708
wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
710
label = new wxStaticText( net_subpanels[1], -1, wxU(_("Port")) );
711
i_net_ports[1] = i_net_ports[0];
712
net_ports[1] = new wxSpinCtrl( net_subpanels[1], NetPort2_Event,
713
wxString::Format(wxT("%d"), i_net_ports[1]),
714
wxDefaultPosition, wxDefaultSize,
716
0, 16000, i_net_ports[1] );
718
subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
719
subpanel_sizer->Add( net_ports[1], 1,
720
wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
721
net_subpanels[1]->SetSizerAndFit( subpanel_sizer );
723
/* HTTP and RTSP rows */
726
subpanel_sizer = new wxFlexGridSizer( 2, 1, 20 );
727
label = new wxStaticText( net_subpanels[i], -1, wxU(_("URL")) );
728
net_addrs[i] = new wxTextCtrl( net_subpanels[i], NetAddr1_Event + i,
729
(i == 2) ? wxT("") : wxT("rtsp://"),
730
wxDefaultPosition, wxSize( 200, -1 ),
732
subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
733
subpanel_sizer->Add( net_addrs[i], 1,
734
wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
735
net_subpanels[i]->SetSizerAndFit( subpanel_sizer );
738
/* Stuff everything into the main panel */
741
sizer->Add( net_radios[i], 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
743
sizer->Add( net_subpanels[i], 1, wxEXPAND | wxALIGN_LEFT |
744
wxALIGN_CENTER_VERTICAL | wxALL, 5 );
747
sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
749
panel->SetSizerAndFit( sizer_row );
753
void OpenDialog::UpdateMRL()
755
UpdateMRL( i_current_access_method );
758
void OpenDialog::UpdateMRL( int i_access_method )
760
wxString demux, mrltemp;
762
i_current_access_method = i_access_method;
764
switch( i_access_method )
767
//mrltemp = wxT("file") + demux + wxT(":") + file_combo->GetValue();
768
mrltemp = file_combo->GetValue();
771
i_disc_type_selection = disc_type->GetSelection();
773
switch ( i_disc_type_selection )
775
case 0: /* DVD with menues */
776
disc_chapter->Enable();
777
disc_chapter_label->Enable();
778
mrltemp = wxT("dvd://")
779
+ disc_device->GetValue()
780
+ wxString::Format( wxT("@%d:%d"),
781
disc_title->GetValue(),
782
disc_chapter->GetValue() );
785
case 1: /* DVD of some sort */
786
disc_chapter->Enable();
787
disc_chapter_label->Enable();
788
mrltemp = wxT("dvdsimple://")
789
+ disc_device->GetValue()
790
+ wxString::Format( wxT("@%d:%d"),
791
disc_title->GetValue(),
792
disc_chapter->GetValue() );
795
case 2: /* VCD of some sort */
797
/* The chapter object is used for subtitles */
799
int i_subtitle = disc_chapter->GetValue();
800
config_PutInt( p_intf, "spu-channel", i_subtitle );
802
disc_chapter->Enable();
803
disc_chapter_label->Enable();
805
if ( disc_title->GetValue() )
806
mrltemp = wxT("vcdx://")
807
+ disc_device->GetValue()
808
+ wxString::Format( wxT("@%c%d"),
809
config_GetInt( p_intf, "vcdx-PBC" )
811
disc_title->GetValue()
814
mrltemp = wxT("vcdx://")
815
+ disc_device->GetValue();
817
mrltemp = wxT("vcd://")
818
+ disc_device->GetValue()
819
+ wxString::Format( wxT("@%d"),
820
disc_title->GetValue() );
827
disc_chapter->Disable();
828
disc_chapter_label->Disable();
830
if ( disc_title->GetValue() )
831
mrltemp = wxT("cddax://")
832
+ disc_device->GetValue()
833
+ wxString::Format( wxT("@T%d"),
834
disc_title->GetValue() );
836
mrltemp = wxT("cddax://")
837
+ disc_device->GetValue();
840
mrltemp = wxT("cdda://")
841
+ disc_device->GetValue()
842
+ wxString::Format( wxT("@%d"),
843
disc_title->GetValue() );
847
case 4: /* DVD of some sort */
848
disc_chapter->Enable();
849
disc_chapter_label->Enable();
850
mrltemp = wxT("dvdnav://")
851
+ disc_device->GetValue()
852
+ wxString::Format( wxT("@%d:%d"),
853
disc_title->GetValue(),
854
disc_chapter->GetValue() );
858
msg_Err( p_intf, "invalid selection (%d)",
859
disc_type->GetSelection() );
867
mrltemp = wxT("udp") + demux + wxT("://");
868
if ( net_ipv6->GetValue() )
870
mrltemp += wxT("@[::]");
872
if( i_net_ports[0] !=
873
config_GetInt( p_intf, "server-port" ) )
875
mrltemp += wxString::Format( wxT("@:%d"), i_net_ports[0] );
880
mrltemp = wxT("udp") + demux + wxT("://@");
881
if ((net_addrs[1]->GetLineText(0).Find (':') != -1)
882
&& (net_addrs[1]->GetLineText(0)[0u] != '['))
884
/* automatically adds '[' and ']' to IPv6 addresses */
885
mrltemp += wxT("[") + net_addrs[1]->GetLineText(0)
890
mrltemp += net_addrs[1]->GetLineText(0);
892
if( i_net_ports[1] != config_GetInt( p_intf, "server-port" ) )
894
mrltemp += wxString::Format( wxT(":%d"), i_net_ports[1] );
900
if( net_addrs[2]->GetLineText(0).Find(wxT("http://")) )
902
mrltemp = wxT("http") + demux + wxT("://");
904
mrltemp += net_addrs[2]->GetLineText(0);
909
if( net_addrs[3]->GetLineText(0).Find(wxT("rtsp://")) != 0 )
911
mrltemp = wxT("rtsp") + demux + wxT("://");
913
mrltemp += net_addrs[3]->GetLineText(0);
920
int i_item = i_access_method - MAX_ACCESS;
922
if( i_item < 0 || i_item >= (int)input_tab_array.GetCount() )
925
AutoBuiltPanel *input_panel = input_tab_array.Item( i_item );
927
mrltemp = input_panel->name + wxT("://");
929
for( int i=0; i < (int)input_panel->config_array.GetCount(); i++ )
931
ConfigControl *control = input_panel->config_array.Item(i);
933
mrltemp += wxT(" :");
935
if( control->GetType() == CONFIG_ITEM_BOOL &&
936
!control->GetIntValue() ) mrltemp += wxT("no-");
938
mrltemp += control->GetName();
940
switch( control->GetType() )
942
case CONFIG_ITEM_STRING:
943
case CONFIG_ITEM_FILE:
944
case CONFIG_ITEM_DIRECTORY:
945
case CONFIG_ITEM_MODULE:
946
mrltemp += wxT("=\"") + control->GetPszValue() + wxT("\"");
948
case CONFIG_ITEM_INTEGER:
950
wxString::Format( wxT("=%i"), control->GetIntValue() );
952
case CONFIG_ITEM_FLOAT:
954
wxString::Format(wxT("=%f"), control->GetFloatValue());
959
if( input_panel->p_advanced_mrl_combo &&
960
input_panel->p_advanced_mrl_combo->GetValue() )
962
mrltemp += wxT(" ") +
963
input_panel->p_advanced_mrl_combo->GetValue();
969
mrl_combo->SetValue( mrltemp );
972
/*****************************************************************************
974
*****************************************************************************/
975
void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
977
mrl = SeparateEntries( mrl_combo->GetValue() );
978
mrl_combo->Append( mrl_combo->GetValue() );
979
if( mrl_combo->GetCount() > 10 ) mrl_combo->Delete( 0 );
980
mrl_combo->SetSelection( mrl_combo->GetCount() - 1 );
982
if( i_method == OPEN_STREAM )
985
if( IsModal() ) EndModal( wxID_OK );
989
/* Update the playlist */
990
playlist_t *p_playlist =
991
(playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
993
if( p_playlist == NULL ) return;
995
for( int i = 0; i < (int)mrl.GetCount(); i++ )
997
vlc_bool_t b_start = !i && i_open_arg;
998
playlist_item_t *p_item =
999
playlist_ItemNew( p_intf, (const char*)mrl[i].mb_str(),
1000
(const char *)mrl[i].mb_str() );
1002
/* Insert options */
1003
while( i + 1 < (int)mrl.GetCount() &&
1004
((const char *)mrl[i + 1].mb_str())[0] == ':' )
1006
playlist_ItemAddOption( p_item, mrl[i + 1].mb_str() );
1010
/* Get the options from the subtitles dialog */
1011
if( subsfile_checkbox->IsChecked() && subsfile_mrl.GetCount() )
1013
for( int j = 0; j < (int)subsfile_mrl.GetCount(); j++ )
1015
playlist_ItemAddOption( p_item, subsfile_mrl[j].mb_str() );
1019
/* Get the options from the stream output dialog */
1020
if( sout_checkbox->IsChecked() && sout_mrl.GetCount() )
1022
for( int j = 0; j < (int)sout_mrl.GetCount(); j++ )
1024
playlist_ItemAddOption( p_item, sout_mrl[j].mb_str() );
1028
int i_id = playlist_AddItem( p_playlist, p_item,
1029
PLAYLIST_APPEND, PLAYLIST_END );
1033
int i_pos = playlist_GetPositionById( p_playlist , i_id );
1034
playlist_Command( p_playlist, PLAYLIST_GOTO, i_pos );
1038
vlc_object_release( p_playlist );
1042
if( IsModal() ) EndModal( wxID_OK );
1045
void OpenDialog::OnCancel( wxCommandEvent& WXUNUSED(event) )
1049
if( IsModal() ) EndModal( wxID_CANCEL );
1052
void OpenDialog::OnPageChange( wxNotebookEvent& event )
1054
UpdateMRL( event.GetSelection() );
1057
void OpenDialog::OnMRLChange( wxCommandEvent& event )
1059
//mrl = SeparateEntries( event.GetString() );
1062
/*****************************************************************************
1063
* File panel event methods.
1064
*****************************************************************************/
1065
void OpenDialog::OnFilePanelChange( wxCommandEvent& WXUNUSED(event) )
1067
UpdateMRL( FILE_ACCESS );
1070
void OpenDialog::OnFileBrowse( wxCommandEvent& WXUNUSED(event) )
1072
if( file_dialog == NULL )
1073
file_dialog = new wxFileDialog( this, wxU(_("Open File")),
1074
wxT(""), wxT(""), wxT("*"), wxOPEN | wxMULTIPLE );
1076
if( file_dialog && file_dialog->ShowModal() == wxID_OK )
1078
wxArrayString paths;
1081
file_dialog->GetPaths( paths );
1083
for( size_t i = 0; i < paths.GetCount(); i++ )
1085
if( paths[i].Find( wxT(' ') ) >= 0 )
1086
path += wxT("\"") + paths[i] + wxT("\" ");
1088
path += paths[i] + wxT(" ");
1091
file_combo->SetValue( path );
1092
file_combo->Append( path );
1093
if( file_combo->GetCount() > 10 ) file_combo->Delete( 0 );
1094
UpdateMRL( FILE_ACCESS );
1098
/*****************************************************************************
1099
* Disc panel event methods.
1100
*****************************************************************************/
1101
void OpenDialog::OnDiscPanelChange( wxCommandEvent& event )
1103
UpdateMRL( DISC_ACCESS );
1106
void OpenDialog::OnDiscDeviceChange( wxCommandEvent& event )
1110
switch( disc_type->GetSelection() )
1113
psz_device = config_GetPsz( p_intf, "cd-audio" );
1117
psz_device = config_GetPsz( p_intf, "vcd" );
1121
psz_device = config_GetPsz( p_intf, "dvd" );
1125
if ( !psz_device ) psz_device = "";
1127
if( disc_device->GetValue().Cmp( wxL2U( psz_device ) ) )
1129
b_disc_device_changed = true;
1132
UpdateMRL( DISC_ACCESS );
1135
void OpenDialog::OnDiscTypeChange( wxCommandEvent& WXUNUSED(event) )
1137
char *psz_device = NULL;
1138
int i_selection = 1; /* Default Title/Track selection number*/
1140
switch( disc_type->GetSelection() )
1143
case 0: /* DVD with menus */
1144
case 4: /* DVD with menus (dvdnav) */
1146
/* Fall through... */
1148
case 1: /* DVD of some sort */
1149
psz_device = config_GetPsz( p_intf, "dvd" );
1150
if( !b_disc_device_changed )
1153
disc_device->SetValue( wxL2U(psz_device) );
1155
disc_device->SetValue( wxT("") );
1157
disc_title_label->SetLabel ( wxU(_("Title")) );
1159
disc_title->SetRange( i_selection, 255 );
1160
disc_title->SetValue( i_selection );
1162
disc_chapter->SetRange( 1, 255 );
1163
disc_chapter->SetValue( 1 );
1164
disc_chapter_label->SetLabel ( wxU(_("Chapter")) );
1168
case 2: /* VCD of some sort */
1169
psz_device = config_GetPsz( p_intf, "vcd" );
1170
if( !b_disc_device_changed )
1173
disc_device->SetValue( wxL2U(psz_device) );
1175
disc_device->SetValue( wxT("") );
1178
/* There are at most 98, tracks in a VCD, 999 Segments, 500 entries
1179
I don't know what the limit is for LIDs, 999 is probably safe
1182
FIXME: it would be better however to get the information for
1183
this particular Media possibly from the General Info area.
1186
disc_title_label->SetLabel ( config_GetInt( p_intf, "vcdx-PBC" )
1187
? wxT("Playback LID") : wxT("Entry") );
1188
disc_title->SetRange( 0, 999 );
1191
disc_title_label->SetLabel ( wxU(_("Track")) );
1192
disc_title->SetRange( 1, 98 );
1194
disc_title->SetValue( i_selection );
1196
/* We use the chapter to set subtitle number */
1197
disc_chapter_label->SetLabel ( wxU(_("Subtitle")) );
1198
disc_chapter->SetRange( -1, 4 );
1199
disc_chapter->SetValue( config_GetInt( p_intf, "spu-channel" ) );
1203
psz_device = config_GetPsz( p_intf, "cd-audio" );
1204
if( !b_disc_device_changed )
1207
disc_device->SetValue( wxL2U(psz_device) );
1209
disc_device->SetValue( wxT("") );
1211
disc_title_label->SetLabel ( wxU(_("Track")) );
1215
/* There are at most 99 tracks in a CD-DA */
1216
disc_title->SetRange( i_selection, 99 );
1217
disc_title->SetValue( i_selection );
1220
msg_Err( p_intf, "invalid Disc type selection (%d)",
1221
disc_type->GetSelection() );
1225
if( psz_device ) free( psz_device );
1227
UpdateMRL( DISC_ACCESS );
1230
/*****************************************************************************
1231
* Net panel event methods.
1232
*****************************************************************************/
1233
void OpenDialog::OnNetPanelChange( wxCommandEvent& event )
1235
if( event.GetId() >= NetPort1_Event && event.GetId() <= NetPort3_Event )
1237
i_net_ports[event.GetId() - NetPort1_Event] = event.GetInt();
1240
UpdateMRL( NET_ACCESS );
1243
void OpenDialog::OnNetTypeChange( wxCommandEvent& event )
1247
i_net_type = event.GetId() - NetRadio1_Event;
1251
net_radios[i]->SetValue( event.GetId() == (NetRadio1_Event+i) );
1252
net_subpanels[i]->Enable( event.GetId() == (NetRadio1_Event+i) );
1255
UpdateMRL( NET_ACCESS );
1258
/*****************************************************************************
1259
* Subtitles file event methods.
1260
*****************************************************************************/
1261
void OpenDialog::OnSubsFileEnable( wxCommandEvent& event )
1263
subsfile_button->Enable( event.GetInt() != 0 );
1266
void OpenDialog::OnSubsFileSettings( wxCommandEvent& WXUNUSED(event) )
1268
/* Show/hide the open dialog */
1269
if( subsfile_dialog == NULL )
1270
subsfile_dialog = new SubsFileDialog( p_intf, this );
1272
if( subsfile_dialog && subsfile_dialog->ShowModal() == wxID_OK )
1274
subsfile_mrl.Empty();
1275
subsfile_mrl.Add( wxString(wxT("sub-file=")) +
1276
subsfile_dialog->file_combo->GetValue() );
1277
if( subsfile_dialog->encoding_combo )
1278
subsfile_mrl.Add( wxString(wxT("subsdec-encoding=")) +
1279
subsfile_dialog->encoding_combo->GetValue() );
1280
subsfile_mrl.Add( wxString::Format( wxT("sub-delay=%i"),
1281
subsfile_dialog->delay_spinctrl->GetValue() ) );
1282
subsfile_mrl.Add( wxString::Format( wxT("sub-fps=%i"),
1283
subsfile_dialog->fps_spinctrl->GetValue() ) );
1287
/*****************************************************************************
1288
* Stream output event methods.
1289
*****************************************************************************/
1290
void OpenDialog::OnSoutEnable( wxCommandEvent& event )
1292
sout_button->Enable( event.GetInt() != 0 );
1295
void OpenDialog::OnSoutSettings( wxCommandEvent& WXUNUSED(event) )
1297
/* Show/hide the open dialog */
1298
if( sout_dialog == NULL )
1299
sout_dialog = new SoutDialog( p_intf, this );
1301
if( sout_dialog && sout_dialog->ShowModal() == wxID_OK )
1303
sout_mrl = sout_dialog->GetOptions();
1307
/*****************************************************************************
1308
* Utility functions.
1309
*****************************************************************************/
1310
wxArrayString SeparateEntries( wxString entries )
1312
vlc_bool_t b_quotes_mode = VLC_FALSE;
1314
wxArrayString entries_array;
1317
wxStringTokenizer token( entries, wxT(" \t\r\n\""), wxTOKEN_RET_DELIMS );
1319
while( token.HasMoreTokens() )
1321
entry += token.GetNextToken();
1323
if( entry.IsEmpty() ) continue;
1325
if( !b_quotes_mode && entry.Last() == wxT('\"') )
1327
/* Enters quotes mode */
1329
b_quotes_mode = VLC_TRUE;
1331
else if( b_quotes_mode && entry.Last() == wxT('\"') )
1333
/* Finished the quotes mode */
1335
b_quotes_mode = VLC_FALSE;
1337
else if( !b_quotes_mode && entry.Last() != wxT('\"') )
1339
/* we found a non-quoted standalone string */
1340
if( token.HasMoreTokens() ||
1341
entry.Last() == wxT(' ') || entry.Last() == wxT('\t') ||
1342
entry.Last() == wxT('\r') || entry.Last() == wxT('\n') )
1344
if( !entry.IsEmpty() ) entries_array.Add( entry );
1351
if( !entry.IsEmpty() ) entries_array.Add( entry );
1353
return entries_array;