1 /*****************************************************************************
2 * open.cpp : wxWindows plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000-2004 VideoLAN
5 * $Id: open.cpp,v 1.67 2004/01/29 17:51:08 zorglub Exp $
7 * Authors: Gildas Bazin <gbazin@netcourrier.com>
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,
79 SubsFileSettings_Event,
85 BEGIN_EVENT_TABLE(OpenDialog, wxFrame)
87 EVT_BUTTON(wxID_OK, OpenDialog::OnOk)
88 EVT_BUTTON(wxID_CANCEL, OpenDialog::OnCancel)
90 EVT_NOTEBOOK_PAGE_CHANGED(Notebook_Event, OpenDialog::OnPageChange)
92 EVT_TEXT(MRL_Event, OpenDialog::OnMRLChange)
94 /* Events generated by the file panel */
95 EVT_TEXT(FileName_Event, OpenDialog::OnFilePanelChange)
96 EVT_BUTTON(FileBrowse_Event, OpenDialog::OnFileBrowse)
98 /* Events generated by the disc panel */
99 EVT_RADIOBOX(DiscType_Event, OpenDialog::OnDiscTypeChange)
100 EVT_TEXT(DiscDevice_Event, OpenDialog::OnDiscDeviceChange)
101 EVT_TEXT(DiscDevice_Event, OpenDialog::OnDiscPanelChange)
102 EVT_TEXT(DiscTitle_Event, OpenDialog::OnDiscPanelChange)
103 EVT_SPINCTRL(DiscTitle_Event, OpenDialog::OnDiscPanelChange)
104 EVT_TEXT(DiscChapter_Event, OpenDialog::OnDiscPanelChange)
105 EVT_SPINCTRL(DiscChapter_Event, OpenDialog::OnDiscPanelChange)
107 /* Events generated by the net panel */
108 EVT_RADIOBUTTON(NetRadio1_Event, OpenDialog::OnNetTypeChange)
109 EVT_RADIOBUTTON(NetRadio2_Event, OpenDialog::OnNetTypeChange)
110 EVT_RADIOBUTTON(NetRadio3_Event, OpenDialog::OnNetTypeChange)
111 EVT_RADIOBUTTON(NetRadio4_Event, OpenDialog::OnNetTypeChange)
112 EVT_TEXT(NetPort1_Event, OpenDialog::OnNetPanelChange)
113 EVT_SPINCTRL(NetPort1_Event, OpenDialog::OnNetPanelChange)
114 EVT_TEXT(NetPort2_Event, OpenDialog::OnNetPanelChange)
115 EVT_SPINCTRL(NetPort2_Event, OpenDialog::OnNetPanelChange)
116 EVT_TEXT(NetPort3_Event, OpenDialog::OnNetPanelChange)
117 EVT_SPINCTRL(NetPort3_Event, OpenDialog::OnNetPanelChange)
118 EVT_TEXT(NetAddr2_Event, OpenDialog::OnNetPanelChange)
119 EVT_TEXT(NetAddr3_Event, OpenDialog::OnNetPanelChange)
120 EVT_TEXT(NetAddr4_Event, OpenDialog::OnNetPanelChange)
121 EVT_CHECKBOX(NetForceIPv6_Event, OpenDialog::OnNetPanelChange)
124 /* Events generated by the v4l panel */
125 EVT_RADIOBOX(VideoType_Event, OpenDialog::OnV4LTypeChange)
126 EVT_TEXT(VideoDevice_Event, OpenDialog::OnV4LPanelChange)
127 EVT_SPINCTRL(VideoChannel_Event, OpenDialog::OnV4LPanelChange)
128 EVT_BUTTON(V4LSettings_Event, OpenDialog::OnV4LSettingsChange)
131 /* Events generated by the subtitle file buttons */
132 EVT_CHECKBOX(SubsFileEnable_Event, OpenDialog::OnSubsFileEnable)
133 EVT_BUTTON(SubsFileSettings_Event, OpenDialog::OnSubsFileSettings)
135 /* Events generated by the stream output buttons */
136 EVT_CHECKBOX(SoutEnable_Event, OpenDialog::OnSoutEnable)
137 EVT_BUTTON(SoutSettings_Event, OpenDialog::OnSoutSettings)
139 /* Hide the window when the user closes the window */
140 EVT_CLOSE(OpenDialog::OnCancel)
144 /*****************************************************************************
146 *****************************************************************************/
147 WX_DEFINE_ARRAY(ConfigControl *, ArrayOfConfigControls);
149 class AutoBuiltPanel : public wxPanel
154 AutoBuiltPanel( wxWindow *, OpenDialog *, intf_thread_t *,
157 virtual ~AutoBuiltPanel() {}
160 ArrayOfConfigControls config_array;
163 intf_thread_t *p_intf;
166 void AutoBuildCallback( void *p_data )
168 ((OpenDialog *)p_data)->UpdateMRL();
171 AutoBuiltPanel::AutoBuiltPanel( wxWindow *parent, OpenDialog *dialog,
172 intf_thread_t *_p_intf,
173 const module_t *p_module )
174 : wxPanel( parent, -1, wxDefaultPosition, wxSize(200, 200) ),
175 name( wxU(p_module->psz_object_name) ), p_intf( _p_intf )
177 wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
179 module_config_t *p_item = p_module->p_config;
183 if( p_item->i_type & CONFIG_HINT || p_item->b_advanced )
186 ConfigControl *control =
187 CreateConfigControl( VLC_OBJECT(p_intf), p_item, this );
189 config_array.Add( control );
191 /* Don't add items that were not recognized */
192 if( control == NULL ) continue;
194 control->SetUpdateCallback( AutoBuildCallback, (void *)dialog );
196 sizer->Add( control, 0, wxEXPAND | wxALL, 2 );
198 while( p_item->i_type != CONFIG_HINT_END && p_item++ );
200 this->SetSizerAndFit( sizer );
203 /*****************************************************************************
205 *****************************************************************************/
206 OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
207 int i_access_method, int i_arg ):
208 wxFrame( _p_parent, -1, wxU(_("Open...")), wxDefaultPosition,
209 wxDefaultSize, wxDEFAULT_FRAME_STYLE )
211 OpenDialog( _p_intf, _p_parent, i_access_method, i_arg, OPEN_NORMAL );
214 OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
215 int i_access_method, int i_arg, int _i_method ):
216 wxFrame( _p_parent, -1, wxU(_("Open...")), wxDefaultPosition,
217 wxDefaultSize, wxDEFAULT_FRAME_STYLE )
219 /* Initializations */
220 i_method = _i_method;
222 p_parent = _p_parent;
223 SetIcon( *p_intf->p_sys->p_icon );
225 i_disc_type_selection = 0;
232 subsfile_dialog = NULL;
233 b_disc_device_changed = false;
235 /* Create a panel to put everything in */
236 wxPanel *panel = new wxPanel( this, -1 );
237 panel->SetAutoLayout( TRUE );
239 /* Create MRL combobox */
240 wxBoxSizer *mrl_sizer_sizer = new wxBoxSizer( wxHORIZONTAL );
241 wxStaticBox *mrl_box = new wxStaticBox( panel, -1,
242 wxU(_("Media Resource Locator (MRL)")) );
243 wxStaticBoxSizer *mrl_sizer = new wxStaticBoxSizer( mrl_box,
245 wxStaticText *mrl_label = new wxStaticText( panel, -1,
247 mrl_combo = new wxComboBox( panel, MRL_Event, wxT(""),
248 wxPoint(20,25), wxSize(120, -1),
250 mrl_combo->SetToolTip( wxU(_("You can use this field directly by typing "
251 "the full MRL you want to open.\n""Alternatively, the field will be "
252 "filled automatically when you use the controls below.")) );
254 mrl_sizer->Add( mrl_label, 0, wxALL | wxALIGN_CENTER, 5 );
255 mrl_sizer->Add( mrl_combo, 1, wxALL | wxALIGN_CENTER, 5 );
256 mrl_sizer_sizer->Add( mrl_sizer, 1, wxEXPAND | wxALL, 5 );
259 /* Create Static Text */
260 wxStaticText *label = new wxStaticText( panel, -1,
261 wxU(_("Alternatively, you can build an MRL using one of the "
262 "following predefined targets:")) );
264 wxFlexGridSizer *sout_sizer = NULL;
265 wxStaticLine *static_line = NULL;
267 if( i_method == OPEN_NORMAL )
269 /* Create Stream Output checkox */
270 sout_sizer = new wxFlexGridSizer( 2, 1, 20 );
273 sout_checkbox = new wxCheckBox( panel, SoutEnable_Event,
274 wxU(_("Stream output")) );
275 sout_checkbox->SetToolTip( wxU(_("Use VLC as a server of streams")) );
276 sout_sizer->Add( sout_checkbox, 0,
277 wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
278 sout_button = new wxButton( panel, SoutSettings_Event,
279 wxU(_("Settings...")) );
280 sout_button->Disable();
282 char *psz_sout = config_GetPsz( p_intf, "sout" );
283 if( psz_sout && *psz_sout )
285 sout_checkbox->SetValue(TRUE);
286 sout_button->Enable();
287 subsfile_mrl.Add( wxString(wxT("sout=")) + wxL2U(psz_sout) );
289 if( psz_sout ) free( psz_sout );
291 sout_sizer->Add( sout_button, 1, wxALIGN_LEFT |
292 wxALIGN_CENTER_VERTICAL );
295 static_line = new wxStaticLine( panel, wxID_OK );
298 /* Create the buttons */
299 wxButton *ok_button = new wxButton( panel, wxID_OK, wxU(_("OK")) );
300 ok_button->SetDefault();
301 wxButton *cancel_button = new wxButton( panel, wxID_CANCEL,
304 /* Create notebook */
305 notebook = new wxNotebook( panel, Notebook_Event );
306 wxNotebookSizer *notebook_sizer = new wxNotebookSizer( notebook );
308 notebook->AddPage( FilePanel( notebook ), wxU(_("File")),
309 i_access_method == FILE_ACCESS );
310 notebook->AddPage( DiscPanel( notebook ), wxU(_("Disc")),
311 i_access_method == DISC_ACCESS );
312 notebook->AddPage( NetPanel( notebook ), wxU(_("Network")),
313 i_access_method == NET_ACCESS );
315 notebook->AddPage( V4LPanel( notebook ), wxU(_("Video for Linux")),
316 i_access_method == V4L_ACCESS );
319 module_t *p_module = config_FindModule( VLC_OBJECT(p_intf), "dshow" );
322 AutoBuiltPanel *autopanel =
323 new AutoBuiltPanel( notebook, this, p_intf, p_module );
324 input_tab_array.Add( autopanel );
325 notebook->AddPage( autopanel, wxU( p_module->psz_longname ) );
328 /* Update Disc panel */
329 wxCommandEvent dummy_event;
330 OnDiscTypeChange( dummy_event );
332 /* Update Net panel */
333 dummy_event.SetId( NetRadio1_Event );
334 OnNetTypeChange( dummy_event );
337 /* Update v4l panel */
338 dummy_event.SetId( VideoType_Event );
339 OnV4LTypeChange( dummy_event );
343 wxNotebookEvent event( wxEVT_NULL, 0, i_access_method );
344 OnPageChange( event );
346 /* Place everything in sizers */
347 wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
348 button_sizer->Add( ok_button, 0, wxALL, 5 );
349 button_sizer->Add( cancel_button, 0, wxALL, 5 );
350 button_sizer->Layout();
351 wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
352 wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
353 panel_sizer->Add( mrl_sizer_sizer, 0, wxEXPAND, 5 );
354 panel_sizer->Add( label, 0, wxEXPAND | wxALL, 5 );
355 panel_sizer->Add( notebook_sizer, 1, wxEXPAND | wxALL, 5 );
356 if( i_method == OPEN_NORMAL)
358 panel_sizer->Add( sout_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
359 panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
361 panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
362 panel_sizer->Layout();
363 panel->SetSizerAndFit( panel_sizer );
364 main_sizer->Add( panel, 1, wxGROW, 0 );
365 main_sizer->Layout();
366 SetSizerAndFit( main_sizer );
369 OpenDialog::~OpenDialog()
372 if( file_dialog ) delete file_dialog;
374 if( v4l_dialog ) delete v4l_dialog;
376 if( sout_dialog ) delete sout_dialog;
377 if( subsfile_dialog ) delete subsfile_dialog;
380 int OpenDialog::Show( int i_access_method, int i_arg )
383 notebook->SetSelection( i_access_method );
384 i_ret = wxFrame::Show();
391 int OpenDialog::Show()
394 i_ret = wxFrame::Show();
400 /*****************************************************************************
402 *****************************************************************************/
403 wxPanel *OpenDialog::FilePanel( wxWindow* parent )
405 wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
408 wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
410 /* Create browse file line */
411 wxBoxSizer *file_sizer = new wxBoxSizer( wxHORIZONTAL );
413 file_combo = new wxComboBox( panel, FileName_Event, wxT(""),
414 wxPoint(20,25), wxSize(200, -1), 0, NULL );
415 wxButton *browse_button = new wxButton( panel, FileBrowse_Event,
416 wxU(_("Browse...")) );
417 file_sizer->Add( file_combo, 1, wxALL, 5 );
418 file_sizer->Add( browse_button, 0, wxALL, 5 );
420 /* Create Subtitles File checkox */
421 wxFlexGridSizer *subsfile_sizer = new wxFlexGridSizer( 2, 1, 20 );
422 subsfile_checkbox = new wxCheckBox( panel, SubsFileEnable_Event,
423 wxU(_("Subtitle options")) );
424 subsfile_checkbox->SetToolTip( wxU(_("Force options for seperate subtitle files.")) );
425 subsfile_sizer->Add( subsfile_checkbox, 0,
426 wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
427 subsfile_button = new wxButton( panel, SubsFileSettings_Event,
428 wxU(_("Settings...")) );
429 subsfile_button->Disable();
431 char *psz_subsfile = config_GetPsz( p_intf, "sub-file" );
432 if( psz_subsfile && *psz_subsfile )
434 subsfile_checkbox->SetValue(TRUE);
435 subsfile_button->Enable();
436 subsfile_mrl.Add( wxString(wxT("sub-file=")) + wxL2U(psz_subsfile) );
438 if( psz_subsfile ) free( psz_subsfile );
440 subsfile_sizer->Add( subsfile_button, 1,
441 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
443 sizer->Add( file_sizer, 0, wxEXPAND | wxALL, 5 );
444 sizer->Add( subsfile_sizer, 0, wxEXPAND | wxALL, 5 );
445 panel->SetSizerAndFit( sizer );
449 wxPanel *OpenDialog::DiscPanel( wxWindow* parent )
451 wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
454 wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
455 wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 3, 20 );
457 static const wxString disc_type_array[] =
459 wxU(_("DVD (menus support)")),
466 disc_type = new wxRadioBox( panel, DiscType_Event, wxU(_("Disc type")),
467 wxDefaultPosition, wxDefaultSize,
468 WXSIZEOF(disc_type_array), disc_type_array,
469 WXSIZEOF(disc_type_array), wxRA_SPECIFY_COLS );
471 sizer_row->Add( disc_type, i_disc_type_selection, wxEXPAND | wxALL, 5 );
473 wxStaticText *label = new wxStaticText( panel, -1, wxU(_("Device name")) );
474 disc_device = new wxTextCtrl( panel, DiscDevice_Event, wxT(""),
475 wxDefaultPosition, wxDefaultSize,
478 sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
479 sizer->Add( disc_device, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
481 disc_title_label = new wxStaticText( panel, -1, wxU(_("Title")) );
482 disc_title = new wxSpinCtrl( panel, DiscTitle_Event );
484 sizer->Add( disc_title_label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
485 sizer->Add( disc_title, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
487 disc_chapter_label = new wxStaticText( panel, -1, wxU(_("Chapter")) );
488 disc_chapter = new wxSpinCtrl( panel, DiscChapter_Event );
489 sizer->Add( disc_chapter_label, 0,
490 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
491 sizer->Add( disc_chapter, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
492 sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
494 panel->SetSizerAndFit( sizer_row );
498 wxPanel *OpenDialog::NetPanel( wxWindow* parent )
501 wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
504 wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
505 wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 4, 20 );
507 static const wxString net_type_array[] =
510 wxU(_("UDP/RTP Multicast")),
511 wxU(_("HTTP/FTP/MMS")),
517 net_radios[i] = new wxRadioButton( panel, NetRadio1_Event + i,
519 wxDefaultPosition, wxDefaultSize,
522 net_subpanels[i] = new wxPanel( panel, -1,
523 wxDefaultPosition, wxDefaultSize );
527 wxFlexGridSizer *subpanel_sizer;
529 i_net_ports[0] = config_GetInt( p_intf, "server-port" );
530 subpanel_sizer = new wxFlexGridSizer( 3, 1, 20 );
531 label = new wxStaticText( net_subpanels[0], -1, wxU(_("Port")) );
532 net_ports[0] = new wxSpinCtrl( net_subpanels[0], NetPort1_Event,
533 wxString::Format(wxT("%d"), i_net_ports[0]),
534 wxDefaultPosition, wxDefaultSize,
536 0, 16000, i_net_ports[0] );
538 subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
539 subpanel_sizer->Add( net_ports[0], 1,
540 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
541 net_ipv6 = new wxCheckBox( net_subpanels[0], NetForceIPv6_Event,
542 wxU(_("Force IPv6")));
543 subpanel_sizer->Add( net_ipv6, 0,
544 wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
545 net_subpanels[0]->SetSizerAndFit( subpanel_sizer );
546 net_radios[0]->SetValue( TRUE );
548 /* UDP/RTP Multicast row */
549 subpanel_sizer = new wxFlexGridSizer( 4, 1, 20 );
550 label = new wxStaticText( net_subpanels[1], -1, wxU(_("Address")) );
551 net_addrs[1] = new wxTextCtrl( net_subpanels[1], NetAddr2_Event, wxT(""),
552 wxDefaultPosition, wxDefaultSize,
554 subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
555 subpanel_sizer->Add( net_addrs[1], 1,
556 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
558 label = new wxStaticText( net_subpanels[1], -1, wxU(_("Port")) );
559 i_net_ports[1] = i_net_ports[0];
560 net_ports[1] = new wxSpinCtrl( net_subpanels[1], NetPort2_Event,
561 wxString::Format(wxT("%d"), i_net_ports[1]),
562 wxDefaultPosition, wxDefaultSize,
564 0, 16000, i_net_ports[1] );
566 subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
567 subpanel_sizer->Add( net_ports[1], 1,
568 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
569 net_subpanels[1]->SetSizerAndFit( subpanel_sizer );
571 /* HTTP and RTSP rows */
574 subpanel_sizer = new wxFlexGridSizer( 2, 1, 20 );
575 label = new wxStaticText( net_subpanels[i], -1, wxU(_("URL")) );
576 net_addrs[i] = new wxTextCtrl( net_subpanels[i], NetAddr1_Event + i,
577 (i == 2) ? wxT("") : wxT("rtsp://"),
578 wxDefaultPosition, wxSize( 200, -1 ),
580 subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
581 subpanel_sizer->Add( net_addrs[i], 1,
582 wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
583 net_subpanels[i]->SetSizerAndFit( subpanel_sizer );
586 /* Stuff everything into the main panel */
589 sizer->Add( net_radios[i], 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
591 sizer->Add( net_subpanels[i], 1, wxEXPAND | wxALIGN_LEFT |
592 wxALIGN_CENTER_VERTICAL | wxALL, 5 );
595 sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
597 panel->SetSizerAndFit( sizer_row );
602 wxPanel *OpenDialog::V4LPanel( wxWindow* parent )
604 wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
607 wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
608 wxFlexGridSizer *sizer = new wxFlexGridSizer( 1, 4, 20 );
610 static const wxString video_type_array[] =
618 video_type = new wxRadioBox( panel, VideoType_Event,
619 wxU(_("Video device type")),
620 wxDefaultPosition, wxDefaultSize,
621 WXSIZEOF(video_type_array), video_type_array,
622 WXSIZEOF(video_type_array), wxRA_SPECIFY_COLS );
624 sizer_row->Add( video_type, 0, wxEXPAND | wxALL, 5 );
628 wxFlexGridSizer *video_sizer = new wxFlexGridSizer( 4, 2, 20 );
629 wxStaticText *label = new wxStaticText( panel, -1, wxU(_("Video device")) );
630 video_device = new wxTextCtrl( panel, VideoDevice_Event, wxT(""),
631 wxDefaultPosition, wxDefaultSize,
633 video_device->SetToolTip( wxU(_("Device corresponding to your acquisition "
634 "card or your webcam")) );
635 video_sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
636 video_sizer->Add( video_device, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
638 label = new wxStaticText( panel, -1, wxU(_("Channel")) );
639 video_channel = new wxSpinCtrl( panel, VideoChannel_Event, wxT("0") );
640 video_channel->SetToolTip( wxU(_("Usually 0 is for tuner, 1 for composite "
641 "and 2 for svideo")) );
642 video_sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_HORIZONTAL );
643 video_sizer->Add( video_channel, 1, wxALIGN_LEFT | wxALIGN_CENTER_HORIZONTAL );
644 sizer->Add( video_sizer, 0, wxEXPAND | wxALL, 5 );
646 wxBoxSizer *v4lbutton_sizer = new wxBoxSizer( wxHORIZONTAL );
647 v4l_button = new wxButton( panel, V4LSettings_Event,
648 wxU(_("Advanced settings...")) );
650 v4lbutton_sizer->Add( v4l_button, 0, wxALIGN_RIGHT, 5 );
652 sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
653 sizer_row->Add( v4lbutton_sizer, 0, wxEXPAND | wxALL, 5 );
655 panel->SetSizerAndFit( sizer_row );
660 void OpenDialog::UpdateMRL()
662 UpdateMRL( i_current_access_method );
665 void OpenDialog::UpdateMRL( int i_access_method )
667 wxString demux, mrltemp;
669 i_current_access_method = i_access_method;
671 switch( i_access_method )
674 //mrltemp = wxT("file") + demux + wxT(":") + file_combo->GetValue();
675 mrltemp = file_combo->GetValue();
678 i_disc_type_selection = disc_type->GetSelection();
680 switch ( i_disc_type_selection )
683 disc_chapter->Enable();
684 disc_chapter_label->Enable();
685 mrltemp = wxT("dvd://")
686 + disc_device->GetValue()
687 + wxString::Format( wxT("@%d:%d"),
688 disc_title->GetValue(),
689 disc_chapter->GetValue() );
692 disc_chapter->Enable();
693 disc_chapter_label->Enable();
694 mrltemp = wxT("dvdsimple://")
695 + disc_device->GetValue()
696 + wxString::Format( wxT("@%d:%d"),
697 disc_title->GetValue(),
698 disc_chapter->GetValue() );
701 disc_chapter->Disable();
702 disc_chapter_label->Disable();
704 if ( disc_title->GetValue() )
705 mrltemp = wxT("vcdx://")
706 + disc_device->GetValue()
707 + wxString::Format( wxT("@%c%d"),
708 config_GetInt( p_intf, "vcdx-PBC" )
710 disc_title->GetValue()
713 mrltemp = wxT("vcdx://")
714 + disc_device->GetValue();
716 mrltemp = wxT("vcd://")
717 + disc_device->GetValue()
718 + wxString::Format( wxT("@%d"),
719 disc_title->GetValue() );
723 disc_chapter->Disable();
724 disc_chapter_label->Disable();
726 if ( disc_title->GetValue() )
727 mrltemp = wxT("cddax://")
728 + disc_device->GetValue()
729 + wxString::Format( wxT("@T%d"),
730 disc_title->GetValue() );
732 mrltemp = wxT("cddax://")
733 + disc_device->GetValue();
736 mrltemp = wxT("cdda://")
737 + disc_device->GetValue()
738 + wxString::Format( wxT("@%d"),
739 disc_title->GetValue() );
743 msg_Err( p_intf, "invalid selection (%d)",
744 disc_type->GetSelection() );
752 mrltemp = wxT("udp") + demux + wxT("://");
753 if ( net_ipv6->GetValue() )
755 mrltemp += wxT("@[::]");
757 if( i_net_ports[0] !=
758 config_GetInt( p_intf, "server-port" ) )
760 mrltemp += wxString::Format( wxT("@:%d"), i_net_ports[0] );
765 mrltemp = wxT("udp") + demux + wxT("://@");
766 if ((net_addrs[1]->GetLineText(0).Find (':') != -1)
767 && (net_addrs[1]->GetLineText(0)[0u] != '['))
769 /* automatically adds '[' and ']' to IPv6 addresses */
770 mrltemp += wxT("[") + net_addrs[1]->GetLineText(0)
775 mrltemp += net_addrs[1]->GetLineText(0);
777 if( i_net_ports[1] != config_GetInt( p_intf, "server-port" ) )
779 mrltemp += wxString::Format( wxT(":%d"), i_net_ports[1] );
785 if( net_addrs[2]->GetLineText(0).Find(wxT("http://")) )
787 mrltemp = wxT("http") + demux + wxT("://");
789 mrltemp += net_addrs[2]->GetLineText(0);
794 if( net_addrs[3]->GetLineText(0).Find(wxT("rtsp://")) != 0 )
796 mrltemp = wxT("rtsp") + demux + wxT("://");
798 mrltemp += net_addrs[3]->GetLineText(0);
805 mrltemp = ( video_type->GetSelection() == 0 ? wxT("v4l") :
806 video_type->GetSelection() == 1 ? wxT("v4l") :
807 video_type->GetSelection() == 2 ? wxT("pvr") :
810 + video_device->GetLineText( 0 );
812 if( video_type->GetSelection() == 1 )
814 mrltemp += wxString::Format( wxT(":channel=%d"),
815 video_channel->GetValue() );
818 if ( /* v4l_dialog != NULL && */ !v4l_mrl.IsEmpty() )
820 mrltemp += v4l_mrl[0];
828 int i_item = i_access_method - MAX_ACCESS;
830 if( i_item < 0 || i_item >= (int)input_tab_array.GetCount() )
833 AutoBuiltPanel *input_panel = input_tab_array.Item( i_item );
835 mrltemp = input_panel->name + wxT("://");
837 for( int i=0; i < (int)input_panel->config_array.GetCount(); i++ )
839 ConfigControl *control = input_panel->config_array.Item(i);
840 mrltemp += wxT(" :") + control->GetName() + wxT("=");
842 switch( control->GetType() )
844 case CONFIG_ITEM_STRING:
845 case CONFIG_ITEM_FILE:
846 case CONFIG_ITEM_DIRECTORY:
847 case CONFIG_ITEM_MODULE:
848 mrltemp += wxT("\"") + control->GetPszValue() + wxT("\"");
850 case CONFIG_ITEM_INTEGER:
851 case CONFIG_ITEM_BOOL:
853 wxString::Format( wxT("%i"), control->GetIntValue() );
855 case CONFIG_ITEM_FLOAT:
857 wxString::Format( wxT("%f"), control->GetFloatValue());
865 mrl_combo->SetValue( mrltemp );
868 /*****************************************************************************
870 *****************************************************************************/
871 void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
873 mrl = SeparateEntries( mrl_combo->GetValue() );
874 mrl_combo->Append( mrl_combo->GetValue() );
875 if( mrl_combo->GetCount() > 10 ) mrl_combo->Delete( 0 );
876 mrl_combo->SetSelection( mrl_combo->GetCount() - 1 );
878 if( i_method == OPEN_STREAM )
884 /* Update the playlist */
885 playlist_t *p_playlist =
886 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
888 if( p_playlist == NULL ) return;
890 for( int i = 0; i < (int)mrl.GetCount(); i++ )
893 playlist_item_t *p_item =
894 playlist_ItemNew( p_intf,
895 (const char*)mrl[i].mb_str(),
896 (const char *)mrl[i].mb_str() );
898 /* Count the input options */
899 while( i + i_options + 1 < (int)mrl.GetCount() &&
900 ((const char *)mrl[i + i_options + 1].mb_str())[0] == ':' )
906 for( int j = 0; j < i_options; j++ )
908 playlist_ItemAddOption( p_item, mrl[i + j + 1].mb_str() );
911 /* Get the options from the subtitles dialog */
912 if( subsfile_checkbox->IsChecked() && subsfile_mrl.GetCount() )
914 for( int j = 0; j < (int)subsfile_mrl.GetCount(); j++ )
916 playlist_ItemAddOption( p_item, subsfile_mrl[j].mb_str() );
920 /* Get the options from the stream output dialog */
921 if( sout_checkbox->IsChecked() && sout_mrl.GetCount() )
923 for( int j = 0; j < (int)sout_mrl.GetCount(); j++ )
925 playlist_ItemAddOption( p_item, sout_mrl[j].mb_str() );
929 int i_id = playlist_AddItem( p_playlist, p_item,
930 PLAYLIST_APPEND, PLAYLIST_END );
932 if( !i && i_open_arg )
934 int i_pos = playlist_GetPositionById( p_playlist , i_id );
935 playlist_Command( p_playlist, PLAYLIST_GOTO, i_pos );
940 //TogglePlayButton( PLAYING_S );
942 vlc_object_release( p_playlist );
947 void OpenDialog::OnCancel( wxCommandEvent& WXUNUSED(event) )
952 void OpenDialog::OnPageChange( wxNotebookEvent& event )
954 UpdateMRL( event.GetSelection() );
957 void OpenDialog::OnMRLChange( wxCommandEvent& event )
959 //mrl = SeparateEntries( event.GetString() );
962 /*****************************************************************************
963 * File panel event methods.
964 *****************************************************************************/
965 void OpenDialog::OnFilePanelChange( wxCommandEvent& WXUNUSED(event) )
967 UpdateMRL( FILE_ACCESS );
970 void OpenDialog::OnFileBrowse( wxCommandEvent& WXUNUSED(event) )
972 if( file_dialog == NULL )
973 file_dialog = new wxFileDialog( this, wxU(_("Open File")),
974 wxT(""), wxT(""), wxT("*"), wxOPEN | wxMULTIPLE );
976 if( file_dialog && file_dialog->ShowModal() == wxID_OK )
981 file_dialog->GetPaths( paths );
983 for( size_t i = 0; i < paths.GetCount(); i++ )
985 if( paths[i].Find( wxT(' ') ) >= 0 )
986 path += wxT("\"") + paths[i] + wxT("\" ");
988 path += paths[i] + wxT(" ");
991 file_combo->SetValue( path );
992 file_combo->Append( path );
993 if( file_combo->GetCount() > 10 ) file_combo->Delete( 0 );
994 UpdateMRL( FILE_ACCESS );
998 /*****************************************************************************
999 * Disc panel event methods.
1000 *****************************************************************************/
1001 void OpenDialog::OnDiscPanelChange( wxCommandEvent& event )
1003 UpdateMRL( DISC_ACCESS );
1006 void OpenDialog::OnDiscDeviceChange( wxCommandEvent& event )
1010 switch( disc_type->GetSelection() )
1013 psz_device = config_GetPsz( p_intf, "cd-audio" );
1017 psz_device = config_GetPsz( p_intf, "vcd" );
1021 psz_device = config_GetPsz( p_intf, "dvd" );
1025 if ( !psz_device ) psz_device = "";
1027 if( disc_device->GetValue().Cmp( wxL2U( psz_device ) ) )
1029 b_disc_device_changed = true;
1032 UpdateMRL( DISC_ACCESS );
1035 void OpenDialog::OnDiscTypeChange( wxCommandEvent& WXUNUSED(event) )
1037 char *psz_device = NULL;
1038 int i_selection = 1; /* Default Title/Track selection number*/
1040 switch( disc_type->GetSelection() )
1043 case 0: /* DVD with menues */
1045 /* Fall through... */
1047 case 1: /* DVD of some sort */
1049 psz_device = config_GetPsz( p_intf, "dvd" );
1050 if( !b_disc_device_changed )
1052 disc_device->SetValue( psz_device ? wxL2U(psz_device) : wxT("") );
1053 disc_title_label->SetLabel ( wxU(_("Title")) );
1055 disc_title->SetRange( i_selection, 255 );
1056 disc_title->SetValue( i_selection );
1060 case 2: /* VCD of some sort */
1061 psz_device = config_GetPsz( p_intf, "vcd" );
1062 if( !b_disc_device_changed )
1064 disc_device->SetValue( psz_device ? wxL2U(psz_device) : wxT("") );
1067 /* There are at most 98, tracks in a VCD, 999 Segments, 500 entries
1068 I don't know what the limit is for LIDs, 999 is probably safe
1071 FIXME: it would be better however to get the information for
1072 this particular Media possibly from the General Info area.
1075 disc_title_label->SetLabel ( config_GetInt( p_intf, "vcdx-PBC" )
1076 ? wxT("Playback LID") : wxT("Entry") );
1077 disc_title->SetRange( 0, 999 );
1080 disc_title_label->SetLabel ( wxU(_("Track")) );
1081 disc_title->SetRange( 1, 98 );
1083 disc_title->SetValue( i_selection );
1087 psz_device = config_GetPsz( p_intf, "cd-audio" );
1088 if( !b_disc_device_changed )
1090 disc_device->SetValue( psz_device ? wxL2U(psz_device) : wxT("") );
1092 disc_title_label->SetLabel ( wxU(_("Track")) );
1096 /* There are at most 99 tracks in a CD-DA */
1097 disc_title->SetRange( i_selection, 99 );
1098 disc_title->SetValue( i_selection );
1101 msg_Err( p_intf, "invalid Disc type selection (%d)",
1102 disc_type->GetSelection() );
1106 if( psz_device ) free( psz_device );
1108 disc_chapter->SetRange( 1, 255 );
1109 disc_chapter->SetValue( 1 );
1111 UpdateMRL( DISC_ACCESS );
1114 /*****************************************************************************
1115 * Net panel event methods.
1116 *****************************************************************************/
1117 void OpenDialog::OnNetPanelChange( wxCommandEvent& event )
1119 if( event.GetId() >= NetPort1_Event && event.GetId() <= NetPort3_Event )
1121 i_net_ports[event.GetId() - NetPort1_Event] = event.GetInt();
1124 UpdateMRL( NET_ACCESS );
1127 void OpenDialog::OnNetTypeChange( wxCommandEvent& event )
1131 i_net_type = event.GetId() - NetRadio1_Event;
1135 net_radios[i]->SetValue( event.GetId() == (NetRadio1_Event+i) );
1136 net_subpanels[i]->Enable( event.GetId() == (NetRadio1_Event+i) );
1139 UpdateMRL( NET_ACCESS );
1143 /*****************************************************************************
1144 * v4l panel event methods.
1145 *****************************************************************************/
1146 void OpenDialog::OnV4LPanelChange( wxCommandEvent& WXUNUSED(event) )
1148 UpdateMRL( V4L_ACCESS );
1151 void OpenDialog::OnV4LTypeChange( wxCommandEvent& WXUNUSED(event) )
1153 video_device->SetValue( wxT( "/dev/video" ) );
1155 v4l_button->Enable();
1156 video_channel->Disable();
1158 switch( video_type->GetSelection() )
1161 video_channel->Enable();
1162 video_channel->SetRange( 0, 255 );
1165 v4l_button->Disable();
1171 UpdateMRL( V4L_ACCESS );
1174 void OpenDialog::OnV4LSettingsChange( wxCommandEvent& WXUNUSED(event) )
1176 /* Show/hide the open dialog */
1177 if( v4l_dialog == NULL )
1178 v4l_dialog = new V4LDialog( p_intf, this );
1180 if( v4l_dialog && v4l_dialog->ShowModal() == wxID_OK )
1182 v4l_mrl = v4l_dialog->GetOptions();
1185 UpdateMRL( V4L_ACCESS );
1189 /*****************************************************************************
1190 * Subtitles file event methods.
1191 *****************************************************************************/
1192 void OpenDialog::OnSubsFileEnable( wxCommandEvent& event )
1194 subsfile_button->Enable( event.GetInt() != 0 );
1197 void OpenDialog::OnSubsFileSettings( wxCommandEvent& WXUNUSED(event) )
1199 /* Show/hide the open dialog */
1200 if( subsfile_dialog == NULL )
1201 subsfile_dialog = new SubsFileDialog( p_intf, this );
1203 if( subsfile_dialog && subsfile_dialog->ShowModal() == wxID_OK )
1205 subsfile_mrl.Empty();
1206 subsfile_mrl.Add( wxString(wxT("sub-file=")) +
1207 subsfile_dialog->file_combo->GetValue() );
1208 if( subsfile_dialog->encoding_combo )
1209 subsfile_mrl.Add( wxString(wxT("subsdec-encoding=")) +
1210 subsfile_dialog->encoding_combo->GetValue() );
1211 subsfile_mrl.Add( wxString::Format( wxT("sub-delay=%i"),
1212 subsfile_dialog->delay_spinctrl->GetValue() ) );
1213 subsfile_mrl.Add( wxString::Format( wxT("sub-fps=%i"),
1214 subsfile_dialog->fps_spinctrl->GetValue() ) );
1218 /*****************************************************************************
1219 * Stream output event methods.
1220 *****************************************************************************/
1221 void OpenDialog::OnSoutEnable( wxCommandEvent& event )
1223 sout_button->Enable( event.GetInt() != 0 );
1226 void OpenDialog::OnSoutSettings( wxCommandEvent& WXUNUSED(event) )
1228 /* Show/hide the open dialog */
1229 if( sout_dialog == NULL )
1230 sout_dialog = new SoutDialog( p_intf, this );
1232 if( sout_dialog && sout_dialog->ShowModal() == wxID_OK )
1234 sout_mrl = sout_dialog->GetOptions();
1238 /*****************************************************************************
1239 * Utility functions.
1240 *****************************************************************************/
1241 wxArrayString SeparateEntries( wxString entries )
1243 vlc_bool_t b_quotes_mode = VLC_FALSE;
1245 wxArrayString entries_array;
1248 wxStringTokenizer token( entries, wxT(" \t\r\n\""), wxTOKEN_RET_DELIMS );
1250 while( token.HasMoreTokens() )
1252 entry += token.GetNextToken();
1254 if( entry.IsEmpty() ) continue;
1256 if( !b_quotes_mode && entry.Last() == wxT('\"') )
1258 /* Enters quotes mode */
1260 b_quotes_mode = VLC_TRUE;
1262 else if( b_quotes_mode && entry.Last() == wxT('\"') )
1264 /* Finished the quotes mode */
1266 if( !entry.IsEmpty() ) entries_array.Add( entry );
1268 b_quotes_mode = VLC_FALSE;
1270 else if( !b_quotes_mode && entry.Last() != wxT('\"') )
1272 /* we found a non-quoted standalone string */
1273 if( token.HasMoreTokens() ||
1274 entry.Last() == wxT(' ') || entry.Last() == wxT('\t') ||
1275 entry.Last() == wxT('\r') || entry.Last() == wxT('\n') )
1277 if( !entry.IsEmpty() ) entries_array.Add( entry );
1284 if( !entry.IsEmpty() ) entries_array.Add( entry );
1286 return entries_array;