1 /*****************************************************************************
2 * open.cpp : wxWindows plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000-2001 VideoLAN
5 * $Id: open.cpp,v 1.39 2003/10/29 17:32:54 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 #ifdef WIN32 /* mingw32 hack */
39 /* Let vlc take care of the i18n stuff */
40 #define WXINTL_NO_GETTEXT_MACRO
42 #include <wx/wxprec.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 #include <wx/tokenzr.h>
53 #include "wxwindows.h"
56 # define wxRB_SINGLE 0
59 /*****************************************************************************
61 *****************************************************************************/
63 /* IDs for the controls and the menu commands */
66 Notebook_Event = wxID_HIGHEST,
78 NetRadio1_Event, NetRadio2_Event, NetRadio3_Event,
79 NetPort1_Event, NetPort2_Event, NetPort3_Event,
80 NetAddr1_Event, NetAddr2_Event, NetAddr3_Event,
90 SubsFileSettings_Event,
96 DemuxDumpEnable_Event,
97 DemuxDumpBrowse_Event,
100 BEGIN_EVENT_TABLE(OpenDialog, wxFrame)
102 EVT_BUTTON(wxID_OK, OpenDialog::OnOk)
103 EVT_BUTTON(wxID_CANCEL, OpenDialog::OnCancel)
105 EVT_NOTEBOOK_PAGE_CHANGED(Notebook_Event, OpenDialog::OnPageChange)
107 EVT_TEXT(MRL_Event, OpenDialog::OnMRLChange)
109 /* Events generated by the file panel */
110 EVT_TEXT(FileName_Event, OpenDialog::OnFilePanelChange)
111 EVT_BUTTON(FileBrowse_Event, OpenDialog::OnFileBrowse)
113 /* Events generated by the disc panel */
114 EVT_RADIOBOX(DiscType_Event, OpenDialog::OnDiscTypeChange)
115 EVT_TEXT(DiscDevice_Event, OpenDialog::OnDiscPanelChange)
116 EVT_TEXT(DiscTitle_Event, OpenDialog::OnDiscPanelChange)
117 EVT_SPINCTRL(DiscTitle_Event, OpenDialog::OnDiscPanelChange)
118 EVT_TEXT(DiscChapter_Event, OpenDialog::OnDiscPanelChange)
119 EVT_SPINCTRL(DiscChapter_Event, OpenDialog::OnDiscPanelChange)
121 /* Events generated by the net panel */
122 EVT_RADIOBUTTON(NetRadio1_Event, OpenDialog::OnNetTypeChange)
123 EVT_RADIOBUTTON(NetRadio2_Event, OpenDialog::OnNetTypeChange)
124 EVT_RADIOBUTTON(NetRadio3_Event, OpenDialog::OnNetTypeChange)
125 EVT_TEXT(NetPort1_Event, OpenDialog::OnNetPanelChange)
126 EVT_SPINCTRL(NetPort1_Event, OpenDialog::OnNetPanelChange)
127 EVT_TEXT(NetPort2_Event, OpenDialog::OnNetPanelChange)
128 EVT_SPINCTRL(NetPort2_Event, OpenDialog::OnNetPanelChange)
129 EVT_TEXT(NetPort3_Event, OpenDialog::OnNetPanelChange)
130 EVT_SPINCTRL(NetPort3_Event, OpenDialog::OnNetPanelChange)
131 EVT_TEXT(NetAddr2_Event, OpenDialog::OnNetPanelChange)
132 EVT_TEXT(NetAddr3_Event, OpenDialog::OnNetPanelChange)
135 /* Events generated by the v4l panel */
136 EVT_RADIOBOX(VideoType_Event, OpenDialog::OnV4LTypeChange)
137 EVT_TEXT(VideoDevice_Event, OpenDialog::OnV4LPanelChange)
138 EVT_SPINCTRL(VideoChannel_Event, OpenDialog::OnV4LPanelChange)
139 EVT_BUTTON(V4LSettings_Event, OpenDialog::OnV4LSettingsChange)
142 /* Events generated by the subtitle file buttons */
143 EVT_CHECKBOX(SubsFileEnable_Event, OpenDialog::OnSubsFileEnable)
144 EVT_BUTTON(SubsFileSettings_Event, OpenDialog::OnSubsFileSettings)
146 /* Events generated by the stream output buttons */
147 EVT_CHECKBOX(SoutEnable_Event, OpenDialog::OnSoutEnable)
148 EVT_BUTTON(SoutSettings_Event, OpenDialog::OnSoutSettings)
150 /* Events generated by the demux dump buttons */
151 EVT_CHECKBOX(DemuxDumpEnable_Event, OpenDialog::OnDemuxDumpEnable)
152 EVT_TEXT(DemuxDump_Event, OpenDialog::OnDemuxDumpChange)
153 EVT_BUTTON(DemuxDumpBrowse_Event, OpenDialog::OnDemuxDumpBrowse)
155 /* Hide the window when the user closes the window */
156 EVT_CLOSE(OpenDialog::OnCancel)
160 /*****************************************************************************
162 *****************************************************************************/
163 OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
164 int i_access_method, int i_arg ):
165 wxFrame( _p_parent, -1, wxU(_("Open Target")), wxDefaultPosition,
166 wxDefaultSize, wxDEFAULT_FRAME_STYLE )
168 OpenDialog( _p_intf, _p_parent, i_access_method, i_arg, OPEN_NORMAL );
171 OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
172 int i_access_method, int i_arg, int _i_method ):
173 wxFrame( _p_parent, -1, wxU(_("Open Target")), wxDefaultPosition,
174 wxDefaultSize, wxDEFAULT_FRAME_STYLE )
176 /* Initializations */
177 i_method = _i_method;
179 p_parent = _p_parent;
180 SetIcon( *p_intf->p_sys->p_icon );
186 subsfile_dialog = NULL;
187 demuxdump_dialog = NULL;
189 /* Create a panel to put everything in */
190 wxPanel *panel = new wxPanel( this, -1 );
191 panel->SetAutoLayout( TRUE );
193 /* Create MRL combobox */
194 wxBoxSizer *mrl_sizer_sizer = new wxBoxSizer( wxHORIZONTAL );
195 wxStaticBox *mrl_box = new wxStaticBox( panel, -1,
196 wxU(_("Media Resource Locator (MRL)")) );
197 wxStaticBoxSizer *mrl_sizer = new wxStaticBoxSizer( mrl_box,
199 wxStaticText *mrl_label = new wxStaticText( panel, -1,
200 wxU(_("Open Target:")) );
201 mrl_combo = new wxComboBox( panel, MRL_Event, wxT(""),
202 wxPoint(20,25), wxSize(120, -1),
204 mrl_combo->SetToolTip( wxU(_("You can use this field directly by typing "
205 "the full MRL you want to open.\n""Alternatively, the field will be "
206 "filled automatically when you use the controls below.")) );
208 mrl_sizer->Add( mrl_label, 0, wxALL | wxALIGN_CENTER, 5 );
209 mrl_sizer->Add( mrl_combo, 1, wxALL | wxALIGN_CENTER, 5 );
210 mrl_sizer_sizer->Add( mrl_sizer, 1, wxEXPAND | wxALL, 5 );
213 /* Create Static Text */
214 wxStaticText *label = new wxStaticText( panel, -1,
215 wxU(_("Alternatively, you can build an MRL using one of the "
216 "following predefined targets:")) );
218 wxFlexGridSizer *sout_sizer = NULL;
219 wxBoxSizer *demuxdump_sizer = NULL;
220 wxStaticLine *static_line = NULL;
222 demuxdump_checkbox = NULL;
223 demuxdump_textctrl = NULL;
225 if( i_method == OPEN_NORMAL )
227 /* Create Stream Output checkox */
228 sout_sizer = new wxFlexGridSizer( 2, 1, 20 );
231 sout_checkbox = new wxCheckBox( panel, SoutEnable_Event,
232 wxU(_("Stream output")) );
233 sout_checkbox->SetToolTip( wxU(_("Use VLC as a stream server")) );
234 sout_sizer->Add( sout_checkbox, 0,
235 wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
236 sout_button = new wxButton( panel, SoutSettings_Event,
237 wxU(_("Settings...")) );
238 sout_button->Disable();
240 char *psz_sout = config_GetPsz( p_intf, "sout" );
241 if( psz_sout && *psz_sout )
243 sout_checkbox->SetValue(TRUE);
244 sout_button->Enable();
245 subsfile_mrl.Add( wxString(wxT("sout=")) + wxU(psz_sout) );
247 if( psz_sout ) free( psz_sout );
249 sout_sizer->Add( sout_button, 1, wxALIGN_LEFT |
250 wxALIGN_CENTER_VERTICAL );
252 /* Create Demux Dump checkox */
253 demuxdump_sizer = new wxBoxSizer( wxHORIZONTAL );
254 demuxdump_checkbox = new wxCheckBox( panel, DemuxDumpEnable_Event,
255 wxU(_("Capture input stream")) );
256 demuxdump_checkbox->SetToolTip(
257 wxU(_("Capture the stream you are playing to a file")) );
258 demuxdump_textctrl = new wxTextCtrl( panel, DemuxDump_Event, wxT(""),
259 wxDefaultPosition, wxDefaultSize,
260 wxTE_PROCESS_ENTER );
261 demuxdump_button = new wxButton( panel, DemuxDumpBrowse_Event,
262 wxU(_("Browse...")) );
264 char *psz_demuxdump = config_GetPsz( p_intf, "demuxdump-file" );
265 if( psz_demuxdump && *psz_demuxdump )
267 demuxdump_textctrl->SetValue( wxU(psz_demuxdump) );
269 if( psz_demuxdump ) free( psz_demuxdump );
271 demuxdump_textctrl->Disable();
272 demuxdump_button->Disable();
273 demuxdump_sizer->Add( demuxdump_checkbox, 0,
274 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
275 demuxdump_sizer->Add( demuxdump_button, 0,
276 wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL, 10 );
277 demuxdump_sizer->Add( demuxdump_textctrl, 1, wxRIGHT, 10 );
280 static_line = new wxStaticLine( panel, wxID_OK );
283 /* Create the buttons */
284 wxButton *ok_button = new wxButton( panel, wxID_OK, wxU(_("OK")) );
285 ok_button->SetDefault();
286 wxButton *cancel_button = new wxButton( panel, wxID_CANCEL,
289 /* Create notebook */
290 notebook = new wxNotebook( panel, Notebook_Event );
291 wxNotebookSizer *notebook_sizer = new wxNotebookSizer( notebook );
293 notebook->AddPage( FilePanel( notebook ), wxU(_("File")),
294 i_access_method == FILE_ACCESS );
295 notebook->AddPage( DiscPanel( notebook ), wxU(_("Disc")),
296 i_access_method == DISC_ACCESS );
297 notebook->AddPage( NetPanel( notebook ), wxU(_("Network")),
298 i_access_method == NET_ACCESS );
300 notebook->AddPage( SatPanel( notebook ), wxU(_("Satellite")),
301 i_access_method == SAT_ACCESS );
303 notebook->AddPage( V4LPanel( notebook ), wxU(_("Video For Linux")),
304 i_access_method == V4L_ACCESS );
307 /* Update Disc panel */
308 wxCommandEvent dummy_event;
309 OnDiscTypeChange( dummy_event );
311 /* Update Net panel */
312 dummy_event.SetId( NetRadio1_Event );
313 OnNetTypeChange( dummy_event );
316 /* Update v4l panel */
317 dummy_event.SetId( VideoType_Event );
318 OnV4LTypeChange( dummy_event );
322 wxNotebookEvent event( wxEVT_NULL, 0, i_access_method );
323 OnPageChange( event );
325 /* Place everything in sizers */
326 wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
327 button_sizer->Add( ok_button, 0, wxALL, 5 );
328 button_sizer->Add( cancel_button, 0, wxALL, 5 );
329 button_sizer->Layout();
330 wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
331 wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
332 panel_sizer->Add( mrl_sizer_sizer, 0, wxEXPAND, 5 );
333 panel_sizer->Add( label, 0, wxEXPAND | wxALL, 5 );
334 panel_sizer->Add( notebook_sizer, 1, wxEXPAND | wxALL, 5 );
335 if( i_method == OPEN_NORMAL)
337 panel_sizer->Add( sout_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
338 panel_sizer->Add( demuxdump_sizer, 0, wxEXPAND | wxALIGN_LEFT
340 panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
342 panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
343 panel_sizer->Layout();
344 panel->SetSizerAndFit( panel_sizer );
345 main_sizer->Add( panel, 1, wxGROW, 0 );
346 main_sizer->Layout();
347 SetSizerAndFit( main_sizer );
350 OpenDialog::~OpenDialog()
353 if( file_dialog ) delete file_dialog;
355 if( v4l_dialog ) delete v4l_dialog;
357 if( sout_dialog ) delete sout_dialog;
358 if( subsfile_dialog ) delete subsfile_dialog;
359 if( demuxdump_dialog ) delete demuxdump_dialog;
362 int OpenDialog::Show( int i_access_method, int i_arg )
365 notebook->SetSelection( i_access_method );
366 i_ret = wxFrame::Show();
372 int OpenDialog::Show()
375 i_ret = wxFrame::Show();
381 /*****************************************************************************
383 *****************************************************************************/
384 wxPanel *OpenDialog::FilePanel( wxWindow* parent )
386 wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
389 wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
391 /* Create browse file line */
392 wxBoxSizer *file_sizer = new wxBoxSizer( wxHORIZONTAL );
394 file_combo = new wxComboBox( panel, FileName_Event, wxT(""),
395 wxPoint(20,25), wxSize(200, -1), 0, NULL );
396 wxButton *browse_button = new wxButton( panel, FileBrowse_Event,
397 wxU(_("Browse...")) );
398 file_sizer->Add( file_combo, 1, wxALL, 5 );
399 file_sizer->Add( browse_button, 0, wxALL, 5 );
401 /* Create Subtitles File checkox */
402 wxFlexGridSizer *subsfile_sizer = new wxFlexGridSizer( 2, 1, 20 );
403 subsfile_checkbox = new wxCheckBox( panel, SubsFileEnable_Event,
404 wxU(_("Subtitles file")) );
405 subsfile_checkbox->SetToolTip( wxU(_("Load an additional subtitles file. "
406 "Currently only works with AVI files.")) );
407 subsfile_sizer->Add( subsfile_checkbox, 0,
408 wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
409 subsfile_button = new wxButton( panel, SubsFileSettings_Event,
410 wxU(_("Settings...")) );
411 subsfile_button->Disable();
413 char *psz_subsfile = config_GetPsz( p_intf, "sub-file" );
414 if( psz_subsfile && *psz_subsfile )
416 subsfile_checkbox->SetValue(TRUE);
417 subsfile_button->Enable();
418 subsfile_mrl.Add( wxString(wxT("sub-file=")) + wxU(psz_subsfile) );
420 if( psz_subsfile ) free( psz_subsfile );
422 subsfile_sizer->Add( subsfile_button, 1,
423 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
425 sizer->Add( file_sizer, 0, wxEXPAND | wxALL, 5 );
426 sizer->Add( subsfile_sizer, 0, wxEXPAND | wxALL, 5 );
427 panel->SetSizerAndFit( sizer );
431 wxPanel *OpenDialog::DiscPanel( wxWindow* parent )
433 wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
436 wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
437 wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 3, 20 );
439 static const wxString disc_type_array[] =
441 wxU(_("DVD (menus support)")),
448 disc_type = new wxRadioBox( panel, DiscType_Event, wxU(_("Disc type")),
449 wxDefaultPosition, wxDefaultSize,
450 WXSIZEOF(disc_type_array), disc_type_array,
451 WXSIZEOF(disc_type_array), wxRA_SPECIFY_COLS );
452 sizer_row->Add( disc_type, 0, wxEXPAND | wxALL, 5 );
454 wxStaticText *label = new wxStaticText( panel, -1, wxU(_("Device name")) );
455 disc_device = new wxTextCtrl( panel, DiscDevice_Event, wxT(""),
456 wxDefaultPosition, wxDefaultSize,
459 sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
460 sizer->Add( disc_device, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
462 label = new wxStaticText( panel, -1, wxU(_("Title")) );
463 disc_title = new wxSpinCtrl( panel, DiscTitle_Event );
465 sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
466 sizer->Add( disc_title, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
468 label = new wxStaticText( panel, -1, wxU(_("Chapter")) );
469 disc_chapter = new wxSpinCtrl( panel, DiscChapter_Event );
470 sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
471 sizer->Add( disc_chapter, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
472 sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
474 panel->SetSizerAndFit( sizer_row );
478 wxPanel *OpenDialog::NetPanel( wxWindow* parent )
481 wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
484 wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
485 wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 3, 20 );
487 static const wxString net_type_array[] =
490 wxU(_("UDP/RTP Multicast")),
491 wxU(_("HTTP/FTP/MMS"))
496 net_radios[i] = new wxRadioButton( panel, NetRadio1_Event + i,
498 wxDefaultPosition, wxDefaultSize,
501 net_subpanels[i] = new wxPanel( panel, -1,
502 wxDefaultPosition, wxDefaultSize );
506 wxFlexGridSizer *subpanel_sizer;
508 i_net_ports[0] = config_GetInt( p_intf, "server-port" );
509 subpanel_sizer = new wxFlexGridSizer( 2, 1, 20 );
510 label = new wxStaticText( net_subpanels[0], -1, wxU(_("Port")) );
511 net_ports[0] = new wxSpinCtrl( net_subpanels[0], NetPort1_Event,
512 wxString::Format(wxT("%d"), i_net_ports[0]),
513 wxDefaultPosition, wxDefaultSize,
515 0, 16000, i_net_ports[0] );
517 subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
518 subpanel_sizer->Add( net_ports[0], 1,
519 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
520 net_subpanels[0]->SetSizerAndFit( subpanel_sizer );
521 net_radios[0]->SetValue( TRUE );
523 /* UDP/RTP Multicast row */
524 subpanel_sizer = new wxFlexGridSizer( 4, 1, 20 );
525 label = new wxStaticText( net_subpanels[1], -1, wxU(_("Address")) );
526 net_addrs[1] = new wxTextCtrl( net_subpanels[1], NetAddr2_Event, wxT(""),
527 wxDefaultPosition, wxDefaultSize,
529 subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
530 subpanel_sizer->Add( net_addrs[1], 1,
531 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
533 label = new wxStaticText( net_subpanels[1], -1, wxU(_("Port")) );
534 i_net_ports[1] = i_net_ports[0];
535 net_ports[1] = new wxSpinCtrl( net_subpanels[1], NetPort2_Event,
536 wxString::Format(wxT("%d"), i_net_ports[1]),
537 wxDefaultPosition, wxDefaultSize,
539 0, 16000, i_net_ports[1] );
541 subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
542 subpanel_sizer->Add( net_ports[1], 1,
543 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
544 net_subpanels[1]->SetSizerAndFit( subpanel_sizer );
547 subpanel_sizer = new wxFlexGridSizer( 2, 1, 20 );
548 label = new wxStaticText( net_subpanels[2], -1, wxU(_("URL")) );
549 net_addrs[2] = new wxTextCtrl( net_subpanels[2], NetAddr3_Event, wxT(""),
550 wxDefaultPosition, wxSize( 200, -1 ),
552 subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
553 subpanel_sizer->Add( net_addrs[2], 1,
554 wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
555 net_subpanels[2]->SetSizerAndFit( subpanel_sizer );
557 /* Stuff everything into the main panel */
560 sizer->Add( net_radios[i], 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
562 sizer->Add( net_subpanels[i], 1, wxEXPAND | wxALIGN_LEFT |
563 wxALIGN_CENTER_VERTICAL | wxALL, 5 );
566 sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
568 panel->SetSizerAndFit( sizer_row );
573 wxPanel *OpenDialog::V4LPanel( wxWindow* parent )
575 wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
578 wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
579 wxFlexGridSizer *sizer = new wxFlexGridSizer( 1, 4, 20 );
581 static const wxString video_type_array[] =
589 video_type = new wxRadioBox( panel, VideoType_Event,
590 wxU(_("Video Device Type")),
591 wxDefaultPosition, wxDefaultSize,
592 WXSIZEOF(video_type_array), video_type_array,
593 WXSIZEOF(video_type_array), wxRA_SPECIFY_COLS );
595 sizer_row->Add( video_type, 0, wxEXPAND | wxALL, 5 );
599 wxFlexGridSizer *video_sizer = new wxFlexGridSizer( 4, 2, 20 );
600 wxStaticText *label = new wxStaticText( panel, -1, wxU(_("Video Device")) );
601 video_device = new wxTextCtrl( panel, VideoDevice_Event, wxT(""),
602 wxDefaultPosition, wxDefaultSize,
605 video_sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
606 video_sizer->Add( video_device, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
608 label = new wxStaticText( panel, -1, wxU(_("Channel")) );
609 video_channel = new wxSpinCtrl( panel, VideoChannel_Event );
611 video_sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_HORIZONTAL );
612 video_sizer->Add( video_channel, 1, wxALIGN_LEFT | wxALIGN_CENTER_HORIZONTAL );
613 sizer->Add( video_sizer, 0, wxEXPAND | wxALL, 5 );
615 wxBoxSizer *v4lbutton_sizer = new wxBoxSizer( wxHORIZONTAL );
616 v4l_button = new wxButton( panel, V4LSettings_Event,
617 wxU(_("Advanced Settings...")) );
619 v4lbutton_sizer->Add( v4l_button, 0, wxALIGN_RIGHT, 5 );
621 sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
622 sizer_row->Add( v4lbutton_sizer, 0, wxEXPAND | wxALL, 5 );
624 panel->SetSizerAndFit( sizer_row );
629 wxPanel *OpenDialog::SatPanel( wxWindow* parent )
631 wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
636 void OpenDialog::UpdateMRL( int i_access_method )
638 wxString demux, mrltemp;
640 i_current_access_method = i_access_method;
642 /* Check if the user asked for demuxdump */
643 if( demuxdump_checkbox )
645 if( demuxdump_checkbox->GetValue() )
647 demux = wxT("/demuxdump");
650 switch( i_access_method )
653 //mrltemp = wxT("file") + demux + wxT(":") + file_combo->GetValue();
654 mrltemp = file_combo->GetValue();
657 mrltemp = ( disc_type->GetSelection() == 0 ? wxT("dvd") :
658 disc_type->GetSelection() == 1 ? wxT("dvdsimple") :
659 disc_type->GetSelection() == 2 ? wxT("vcd") : wxT("cdda") )
661 + disc_device->GetLineText(0)
662 + wxString::Format( wxT("@%d:%d"),
663 i_disc_title, i_disc_chapter );
669 if( i_net_ports[0] !=
670 config_GetInt( p_intf, "server-port" ) )
672 mrltemp = wxT("udp") + demux +
673 wxString::Format( wxT("://@:%d"),
678 mrltemp = wxT("udp") + demux + wxT("://");
683 mrltemp = wxT("udp") + demux + wxT("://@") +
684 net_addrs[1]->GetLineText(0);
685 if( i_net_ports[1] !=
686 config_GetInt( p_intf, "server-port" ) )
688 mrltemp = mrltemp + wxString::Format( wxT(":%d"),
695 mrltemp = wxT("http") + demux + wxT("://") +
696 net_addrs[2]->GetLineText(0);
701 mrltemp = wxT("satellite") + demux + wxT("://");
706 mrltemp = ( video_type->GetSelection() == 0 ? wxT("v4l") :
707 video_type->GetSelection() == 1 ? wxT("v4l") :
708 video_type->GetSelection() == 2 ? wxT("pvr") :
711 + video_device->GetLineText( 0 );
713 if( video_type->GetSelection() == 1 )
715 mrltemp += wxString::Format( wxT(":channel=%d"),
716 video_channel->GetValue() );
719 if ( /* v4l_dialog != NULL && */ !v4l_mrl.IsEmpty() )
721 mrltemp += v4l_mrl[0];
731 mrl_combo->SetValue( mrltemp );
734 /*****************************************************************************
736 *****************************************************************************/
737 void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
739 mrl = SeparateEntries( mrl_combo->GetValue() );
740 mrl_combo->Append( mrl_combo->GetValue() );
741 if( mrl_combo->GetCount() > 10 ) mrl_combo->Delete( 0 );
742 mrl_combo->SetSelection( mrl_combo->GetCount() - 1 );
744 if( i_method == OPEN_STREAM )
750 /* Update the playlist */
751 playlist_t *p_playlist =
752 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
754 if( p_playlist == NULL ) return;
756 for( int i = 0; i < (int)mrl.GetCount(); i++ )
758 int i_options = 0, i_total_options;
759 char **ppsz_options = NULL;
761 /* Count the input options */
762 while( i + i_options + 1 < (int)mrl.GetCount() &&
763 ((const char *)mrl[i + i_options + 1].mb_str())[0] == ':' )
768 /* Allocate ppsz_options */
769 for( int j = 0; j < i_options; j++ )
772 ppsz_options = (char **)malloc( sizeof(char *) * i_options );
774 ppsz_options[j] = strdup( mrl[i + j + 1].mb_str() );
777 i_total_options = i_options;
779 /* Get the options from the subtitles dialog */
780 if( subsfile_checkbox->IsChecked() && subsfile_mrl.GetCount() )
782 ppsz_options = (char **)realloc( ppsz_options, sizeof(char *) *
783 (i_total_options + subsfile_mrl.GetCount()) );
785 for( int j = 0; j < (int)subsfile_mrl.GetCount(); j++ )
787 ppsz_options[i_total_options + j] =
788 strdup( subsfile_mrl[j].mb_str() );
791 i_total_options += subsfile_mrl.GetCount();
794 /* Get the options from the stream output dialog */
795 if( sout_checkbox->IsChecked() && sout_mrl.GetCount() )
797 ppsz_options = (char **)realloc( ppsz_options, sizeof(char *) *
798 (i_total_options + sout_mrl.GetCount()) );
800 for( int j = 0; j < (int)sout_mrl.GetCount(); j++ )
802 ppsz_options[i_total_options + j] =
803 strdup( sout_mrl[j].mb_str() );
806 i_total_options += sout_mrl.GetCount();
810 playlist_Add( p_playlist, (const char *)mrl[i].mb_str(),
811 (const char **)ppsz_options, i_total_options,
812 PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO), PLAYLIST_END );
815 for( int j = 0; j < i_total_options; j++ )
816 free( ppsz_options[j] );
817 if( ppsz_options ) free( ppsz_options );
822 //TogglePlayButton( PLAYING_S );
824 vlc_object_release( p_playlist );
829 void OpenDialog::OnCancel( wxCommandEvent& WXUNUSED(event) )
834 void OpenDialog::OnPageChange( wxNotebookEvent& event )
836 UpdateMRL( event.GetSelection() );
839 void OpenDialog::OnMRLChange( wxCommandEvent& event )
841 //mrl = SeparateEntries( event.GetString() );
844 /*****************************************************************************
845 * File panel event methods.
846 *****************************************************************************/
847 void OpenDialog::OnFilePanelChange( wxCommandEvent& WXUNUSED(event) )
849 UpdateMRL( FILE_ACCESS );
852 void OpenDialog::OnFileBrowse( wxCommandEvent& WXUNUSED(event) )
854 if( file_dialog == NULL )
855 file_dialog = new wxFileDialog( this, wxU(_("Open file")),
856 wxT(""), wxT(""), wxT("*"), wxOPEN | wxMULTIPLE );
858 if( file_dialog && file_dialog->ShowModal() == wxID_OK )
863 file_dialog->GetPaths( paths );
865 for( size_t i = 0; i < paths.GetCount(); i++ )
867 if( paths[i].Find( wxT(' ') ) >= 0 )
868 path += wxT("\"") + paths[i] + wxT("\" ");
870 path += paths[i] + wxT(" ");
873 file_combo->SetValue( path );
874 file_combo->Append( path );
875 if( file_combo->GetCount() > 10 ) file_combo->Delete( 0 );
876 UpdateMRL( FILE_ACCESS );
880 /*****************************************************************************
881 * Disc panel event methods.
882 *****************************************************************************/
883 void OpenDialog::OnDiscPanelChange( wxCommandEvent& event )
885 if( event.GetId() == DiscTitle_Event )
886 i_disc_title = event.GetInt();
887 else if( event.GetId() == DiscChapter_Event )
888 i_disc_chapter = event.GetInt();
890 UpdateMRL( DISC_ACCESS );
893 void OpenDialog::OnDiscTypeChange( wxCommandEvent& WXUNUSED(event) )
897 switch( disc_type->GetSelection() )
900 psz_device = config_GetPsz( p_intf, "vcd" );
901 disc_device->SetValue( psz_device ? wxU(psz_device) : wxT("") );
905 psz_device = config_GetPsz( p_intf, "dvd" );
906 disc_device->SetValue( psz_device ? wxU(psz_device) : wxT("") );
910 if( psz_device ) free( psz_device );
912 switch( disc_type->GetSelection() )
915 disc_title->SetRange( 0, 255 );
916 disc_title->SetValue( 0 );
921 disc_title->SetRange( 1, 255 );
922 disc_title->SetValue( 1 );
928 disc_chapter->SetRange( 1, 255 );
929 disc_chapter->SetValue( 1 );
931 UpdateMRL( DISC_ACCESS );
934 /*****************************************************************************
935 * Net panel event methods.
936 *****************************************************************************/
937 void OpenDialog::OnNetPanelChange( wxCommandEvent& event )
939 if( event.GetId() >= NetPort1_Event && event.GetId() <= NetPort3_Event )
941 i_net_ports[event.GetId() - NetPort1_Event] = event.GetInt();
944 UpdateMRL( NET_ACCESS );
947 void OpenDialog::OnNetTypeChange( wxCommandEvent& event )
951 i_net_type = event.GetId() - NetRadio1_Event;
955 net_radios[i]->SetValue( event.GetId() == (NetRadio1_Event+i) );
956 net_subpanels[i]->Enable( event.GetId() == (NetRadio1_Event+i) );
959 UpdateMRL( NET_ACCESS );
963 /*****************************************************************************
964 * v4l panel event methods.
965 *****************************************************************************/
966 void OpenDialog::OnV4LPanelChange( wxCommandEvent& WXUNUSED(event) )
968 UpdateMRL( V4L_ACCESS );
971 void OpenDialog::OnV4LTypeChange( wxCommandEvent& WXUNUSED(event) )
973 video_device->SetValue( wxU( "/dev/video" ) );
975 v4l_button->Enable();
976 video_channel->Disable();
978 switch( video_type->GetSelection() )
981 video_channel->Enable();
982 video_channel->SetRange( 0, 255 );
983 video_channel->SetValue( 0 );
986 v4l_button->Disable();
992 UpdateMRL( V4L_ACCESS );
995 void OpenDialog::OnV4LSettingsChange( wxCommandEvent& WXUNUSED(event) )
997 /* Show/hide the open dialog */
998 if( v4l_dialog == NULL )
999 v4l_dialog = new V4LDialog( p_intf, this );
1001 if( v4l_dialog && v4l_dialog->ShowModal() == wxID_OK )
1003 v4l_mrl = v4l_dialog->GetOptions();
1006 UpdateMRL( V4L_ACCESS );
1010 /*****************************************************************************
1011 * Subtitles file event methods.
1012 *****************************************************************************/
1013 void OpenDialog::OnSubsFileEnable( wxCommandEvent& event )
1015 subsfile_button->Enable( event.GetInt() != 0 );
1016 if( demuxdump_checkbox )
1018 if( event.GetInt() && demuxdump_checkbox->IsChecked() )
1020 demuxdump_checkbox->SetValue( 0 );
1021 wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
1023 OnDemuxDumpEnable( event );
1028 void OpenDialog::OnSubsFileSettings( wxCommandEvent& WXUNUSED(event) )
1030 /* Show/hide the open dialog */
1031 if( subsfile_dialog == NULL )
1032 subsfile_dialog = new SubsFileDialog( p_intf, this );
1034 if( subsfile_dialog && subsfile_dialog->ShowModal() == wxID_OK )
1036 subsfile_mrl.Empty();
1037 subsfile_mrl.Add( wxString(wxT("sub-file=")) +
1038 subsfile_dialog->file_combo->GetValue() );
1039 if( subsfile_dialog->encoding_combo )
1040 subsfile_mrl.Add( wxString(wxT("subsdec-encoding=")) +
1041 subsfile_dialog->encoding_combo->GetValue() );
1042 subsfile_mrl.Add( wxString::Format( wxT("sub-delay=%i"),
1043 subsfile_dialog->delay_spinctrl->GetValue() ) );
1044 subsfile_mrl.Add( wxString::Format( wxT("sub-fps=%i"),
1045 subsfile_dialog->fps_spinctrl->GetValue() ) );
1049 /*****************************************************************************
1050 * Stream output event methods.
1051 *****************************************************************************/
1052 void OpenDialog::OnSoutEnable( wxCommandEvent& event )
1054 sout_button->Enable( event.GetInt() != 0 );
1055 if( event.GetInt() && demuxdump_checkbox->IsChecked() )
1057 demuxdump_checkbox->SetValue( 0 );
1058 wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
1060 OnDemuxDumpEnable( event );
1064 void OpenDialog::OnSoutSettings( wxCommandEvent& WXUNUSED(event) )
1066 /* Show/hide the open dialog */
1067 if( sout_dialog == NULL )
1068 sout_dialog = new SoutDialog( p_intf, this );
1070 if( sout_dialog && sout_dialog->ShowModal() == wxID_OK )
1072 sout_mrl = sout_dialog->GetOptions();
1076 /*****************************************************************************
1077 * Demux dump event methods.
1078 *****************************************************************************/
1079 void OpenDialog::OnDemuxDumpEnable( wxCommandEvent& event )
1081 demuxdump_textctrl->Enable( event.GetInt() != 0 );
1082 demuxdump_button->Enable( event.GetInt() != 0 );
1084 if( event.GetInt() )
1086 sout_checkbox->SetValue( 0 );
1087 subsfile_checkbox->SetValue( 0 );
1088 wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
1090 OnSoutEnable( event );
1091 OnSubsFileEnable( event );
1094 UpdateMRL( i_current_access_method );
1097 void OpenDialog::OnDemuxDumpBrowse( wxCommandEvent& WXUNUSED(event) )
1099 if( demuxdump_dialog == NULL )
1100 demuxdump_dialog = new wxFileDialog( this, wxU(_("Save file")),
1101 wxT(""), wxT(""), wxT("*"), wxSAVE );
1103 if( demuxdump_dialog && demuxdump_dialog->ShowModal() == wxID_OK )
1105 demuxdump_textctrl->SetValue( demuxdump_dialog->GetPath() );
1106 wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
1107 OnDemuxDumpChange( event );
1111 void OpenDialog::OnDemuxDumpChange( wxCommandEvent& WXUNUSED(event) )
1113 config_PutPsz( p_intf, "demuxdump-file",
1114 demuxdump_textctrl->GetValue().mb_str() );
1117 /*****************************************************************************
1118 * Utility functions.
1119 *****************************************************************************/
1120 wxArrayString SeparateEntries( wxString entries )
1122 vlc_bool_t b_quotes_mode = VLC_FALSE;
1124 wxArrayString entries_array;
1127 wxStringTokenizer token( entries, wxT(" \t\r\n\""), wxTOKEN_RET_DELIMS );
1129 while( token.HasMoreTokens() )
1131 entry += token.GetNextToken();
1133 if( entry.IsEmpty() ) continue;
1135 if( !b_quotes_mode && entry.Last() == wxT('\"') )
1137 /* Enters quotes mode */
1139 b_quotes_mode = VLC_TRUE;
1141 else if( b_quotes_mode && entry.Last() == wxT('\"') )
1143 /* Finished the quotes mode */
1145 if( !entry.IsEmpty() ) entries_array.Add( entry );
1147 b_quotes_mode = VLC_FALSE;
1149 else if( !b_quotes_mode && entry.Last() != wxT('\"') )
1151 /* we found a non-quoted standalone string */
1152 if( token.HasMoreTokens() ||
1153 entry.Last() == wxT(' ') || entry.Last() == wxT('\t') ||
1154 entry.Last() == wxT('\r') || entry.Last() == wxT('\n') )
1156 if( !entry.IsEmpty() ) entries_array.Add( entry );
1163 if( !entry.IsEmpty() ) entries_array.Add( entry );
1165 return entries_array;