1 /*****************************************************************************
2 * open.cpp : wxWindows plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000-2001 VideoLAN
5 * $Id: open.cpp,v 1.37 2003/08/19 21:16:09 adn 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,
88 SubsFileSettings_Event,
94 DemuxDumpEnable_Event,
95 DemuxDumpBrowse_Event,
98 BEGIN_EVENT_TABLE(OpenDialog, wxFrame)
100 EVT_BUTTON(wxID_OK, OpenDialog::OnOk)
101 EVT_BUTTON(wxID_CANCEL, OpenDialog::OnCancel)
103 EVT_NOTEBOOK_PAGE_CHANGED(Notebook_Event, OpenDialog::OnPageChange)
105 EVT_TEXT(MRL_Event, OpenDialog::OnMRLChange)
107 /* Events generated by the file panel */
108 EVT_TEXT(FileName_Event, OpenDialog::OnFilePanelChange)
109 EVT_BUTTON(FileBrowse_Event, OpenDialog::OnFileBrowse)
111 /* Events generated by the disc panel */
112 EVT_RADIOBOX(DiscType_Event, OpenDialog::OnDiscTypeChange)
113 EVT_TEXT(DiscDevice_Event, OpenDialog::OnDiscPanelChange)
114 EVT_TEXT(DiscTitle_Event, OpenDialog::OnDiscPanelChange)
115 EVT_SPINCTRL(DiscTitle_Event, OpenDialog::OnDiscPanelChange)
116 EVT_TEXT(DiscChapter_Event, OpenDialog::OnDiscPanelChange)
117 EVT_SPINCTRL(DiscChapter_Event, OpenDialog::OnDiscPanelChange)
119 /* Events generated by the net panel */
120 EVT_RADIOBUTTON(NetRadio1_Event, OpenDialog::OnNetTypeChange)
121 EVT_RADIOBUTTON(NetRadio2_Event, OpenDialog::OnNetTypeChange)
122 EVT_RADIOBUTTON(NetRadio3_Event, OpenDialog::OnNetTypeChange)
123 EVT_TEXT(NetPort1_Event, OpenDialog::OnNetPanelChange)
124 EVT_SPINCTRL(NetPort1_Event, OpenDialog::OnNetPanelChange)
125 EVT_TEXT(NetPort2_Event, OpenDialog::OnNetPanelChange)
126 EVT_SPINCTRL(NetPort2_Event, OpenDialog::OnNetPanelChange)
127 EVT_TEXT(NetPort3_Event, OpenDialog::OnNetPanelChange)
128 EVT_SPINCTRL(NetPort3_Event, OpenDialog::OnNetPanelChange)
129 EVT_TEXT(NetAddr2_Event, OpenDialog::OnNetPanelChange)
130 EVT_TEXT(NetAddr3_Event, OpenDialog::OnNetPanelChange)
132 /* Events generated by the v4l panel */
133 EVT_RADIOBOX(VideoType_Event, OpenDialog::OnV4LTypeChange)
134 EVT_TEXT(VideoDevice_Event, OpenDialog::OnV4LPanelChange)
135 EVT_SPINCTRL(VideoChannel_Event, OpenDialog::OnV4LPanelChange)
136 EVT_BUTTON(V4LSettings_Event, OpenDialog::OnV4LSettingsChange)
138 /* Events generated by the subtitle file buttons */
139 EVT_CHECKBOX(SubsFileEnable_Event, OpenDialog::OnSubsFileEnable)
140 EVT_BUTTON(SubsFileSettings_Event, OpenDialog::OnSubsFileSettings)
142 /* Events generated by the stream output buttons */
143 EVT_CHECKBOX(SoutEnable_Event, OpenDialog::OnSoutEnable)
144 EVT_BUTTON(SoutSettings_Event, OpenDialog::OnSoutSettings)
146 /* Events generated by the demux dump buttons */
147 EVT_CHECKBOX(DemuxDumpEnable_Event, OpenDialog::OnDemuxDumpEnable)
148 EVT_TEXT(DemuxDump_Event, OpenDialog::OnDemuxDumpChange)
149 EVT_BUTTON(DemuxDumpBrowse_Event, OpenDialog::OnDemuxDumpBrowse)
151 /* Hide the window when the user closes the window */
152 EVT_CLOSE(OpenDialog::OnCancel)
156 /*****************************************************************************
158 *****************************************************************************/
159 OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
160 int i_access_method, int i_arg ):
161 wxFrame( _p_parent, -1, wxU(_("Open Target")), wxDefaultPosition,
162 wxDefaultSize, wxDEFAULT_FRAME_STYLE )
164 /* Initializations */
166 p_parent = _p_parent;
167 SetIcon( *p_intf->p_sys->p_icon );
171 subsfile_dialog = NULL;
172 demuxdump_dialog = NULL;
174 /* Create a panel to put everything in */
175 wxPanel *panel = new wxPanel( this, -1 );
176 panel->SetAutoLayout( TRUE );
178 /* Create MRL combobox */
179 wxBoxSizer *mrl_sizer_sizer = new wxBoxSizer( wxHORIZONTAL );
180 wxStaticBox *mrl_box = new wxStaticBox( panel, -1,
181 wxU(_("Media Resource Locator (MRL)")) );
182 wxStaticBoxSizer *mrl_sizer = new wxStaticBoxSizer( mrl_box,
184 wxStaticText *mrl_label = new wxStaticText( panel, -1,
185 wxU(_("Open Target:")) );
186 mrl_combo = new wxComboBox( panel, MRL_Event, wxT(""),
187 wxPoint(20,25), wxSize(120, -1),
189 mrl_combo->SetToolTip( wxU(_("You can use this field directly by typing "
190 "the full MRL you want to open.\n""Alternatively, the field will be "
191 "filled automatically when you use the controls below.")) );
193 mrl_sizer->Add( mrl_label, 0, wxALL | wxALIGN_CENTER, 5 );
194 mrl_sizer->Add( mrl_combo, 1, wxALL | wxALIGN_CENTER, 5 );
195 mrl_sizer_sizer->Add( mrl_sizer, 1, wxEXPAND | wxALL, 5 );
198 /* Create Static Text */
199 wxStaticText *label = new wxStaticText( panel, -1,
200 wxU(_("Alternatively, you can build an MRL using one of the "
201 "following predefined targets:")) );
203 /* Create Stream Output checkox */
204 wxFlexGridSizer *sout_sizer = new wxFlexGridSizer( 2, 1, 20 );
205 sout_checkbox = new wxCheckBox( panel, SoutEnable_Event,
206 wxU(_("Stream output")) );
207 sout_checkbox->SetToolTip( wxU(_("Use VLC as a stream server")) );
208 sout_sizer->Add( sout_checkbox, 0,
209 wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
210 sout_button = new wxButton( panel, SoutSettings_Event,
211 wxU(_("Settings...")) );
212 sout_button->Disable();
214 char *psz_sout = config_GetPsz( p_intf, "sout" );
215 if( psz_sout && *psz_sout )
217 sout_checkbox->SetValue(TRUE);
218 sout_button->Enable();
219 subsfile_mrl.Add( wxString(wxT("sout=")) + wxU(psz_sout) );
221 if( psz_sout ) free( psz_sout );
223 sout_sizer->Add( sout_button, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
225 /* Create Demux Dump checkox */
226 wxBoxSizer *demuxdump_sizer = new wxBoxSizer( wxHORIZONTAL );
227 demuxdump_checkbox = new wxCheckBox( panel, DemuxDumpEnable_Event,
228 wxU(_("Capture input stream")) );
229 demuxdump_checkbox->SetToolTip(
230 wxU(_("Capture the stream you are playing to a file")) );
231 demuxdump_textctrl = new wxTextCtrl( panel, DemuxDump_Event, wxT(""),
232 wxDefaultPosition, wxDefaultSize,
233 wxTE_PROCESS_ENTER );
234 demuxdump_button = new wxButton( panel, DemuxDumpBrowse_Event,
235 wxU(_("Browse...")) );
237 char *psz_demuxdump = config_GetPsz( p_intf, "demuxdump-file" );
238 if( psz_demuxdump && *psz_demuxdump )
240 demuxdump_textctrl->SetValue( wxU(psz_demuxdump) );
242 if( psz_demuxdump ) free( psz_demuxdump );
244 demuxdump_textctrl->Disable();
245 demuxdump_button->Disable();
246 demuxdump_sizer->Add( demuxdump_checkbox, 0,
247 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
248 demuxdump_sizer->Add( demuxdump_button, 0,
249 wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL, 10 );
250 demuxdump_sizer->Add( demuxdump_textctrl, 1, wxRIGHT, 10 );
253 wxStaticLine *static_line = new wxStaticLine( panel, wxID_OK );
255 /* Create the buttons */
256 wxButton *ok_button = new wxButton( panel, wxID_OK, wxU(_("OK")) );
257 ok_button->SetDefault();
258 wxButton *cancel_button = new wxButton( panel, wxID_CANCEL,
261 /* Create notebook */
262 notebook = new wxNotebook( panel, Notebook_Event );
263 wxNotebookSizer *notebook_sizer = new wxNotebookSizer( notebook );
265 notebook->AddPage( FilePanel( notebook ), wxU(_("File")),
266 i_access_method == FILE_ACCESS );
267 notebook->AddPage( DiscPanel( notebook ), wxU(_("Disc")),
268 i_access_method == DISC_ACCESS );
269 notebook->AddPage( NetPanel( notebook ), wxU(_("Network")),
270 i_access_method == NET_ACCESS );
272 notebook->AddPage( SatPanel( notebook ), wxU(_("Satellite")),
273 i_access_method == SAT_ACCESS );
276 notebook->AddPage( V4LPanel( notebook ), wxU(_("Video For Linux")),
277 i_access_method == V4L_ACCESS );
279 /* Update Disc panel */
280 wxCommandEvent dummy_event;
281 OnDiscTypeChange( dummy_event );
283 /* Update Net panel */
284 dummy_event.SetId( NetRadio1_Event );
285 OnNetTypeChange( dummy_event );
287 /* Update v4l panel */
288 dummy_event.SetId( VideoType_Event );
289 OnV4LTypeChange( dummy_event );
292 wxNotebookEvent event( wxEVT_NULL, 0, i_access_method );
293 OnPageChange( event );
295 /* Place everything in sizers */
296 wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
297 button_sizer->Add( ok_button, 0, wxALL, 5 );
298 button_sizer->Add( cancel_button, 0, wxALL, 5 );
299 button_sizer->Layout();
300 wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
301 wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
302 panel_sizer->Add( mrl_sizer_sizer, 0, wxEXPAND, 5 );
303 panel_sizer->Add( label, 0, wxEXPAND | wxALL, 5 );
304 panel_sizer->Add( notebook_sizer, 1, wxEXPAND | wxALL, 5 );
305 panel_sizer->Add( sout_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
306 panel_sizer->Add( demuxdump_sizer, 0, wxEXPAND | wxALIGN_LEFT | wxALL, 5 );
307 panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
308 panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
309 panel_sizer->Layout();
310 panel->SetSizerAndFit( panel_sizer );
311 main_sizer->Add( panel, 1, wxGROW, 0 );
312 main_sizer->Layout();
313 SetSizerAndFit( main_sizer );
316 OpenDialog::~OpenDialog()
319 if( file_dialog ) delete file_dialog;
320 if( v4l_dialog ) delete v4l_dialog;
321 if( sout_dialog ) delete sout_dialog;
322 if( subsfile_dialog ) delete subsfile_dialog;
323 if( demuxdump_dialog ) delete demuxdump_dialog;
326 int OpenDialog::Show( int i_access_method, int i_arg )
329 notebook->SetSelection( i_access_method );
330 i_ret = wxFrame::Show();
336 int OpenDialog::Show()
339 i_ret = wxFrame::Show();
345 /*****************************************************************************
347 *****************************************************************************/
348 wxPanel *OpenDialog::FilePanel( wxWindow* parent )
350 wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
353 wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
355 /* Create browse file line */
356 wxBoxSizer *file_sizer = new wxBoxSizer( wxHORIZONTAL );
358 file_combo = new wxComboBox( panel, FileName_Event, wxT(""),
359 wxPoint(20,25), wxSize(200, -1), 0, NULL );
360 wxButton *browse_button = new wxButton( panel, FileBrowse_Event,
361 wxU(_("Browse...")) );
362 file_sizer->Add( file_combo, 1, wxALL, 5 );
363 file_sizer->Add( browse_button, 0, wxALL, 5 );
365 /* Create Subtitles File checkox */
366 wxFlexGridSizer *subsfile_sizer = new wxFlexGridSizer( 2, 1, 20 );
367 subsfile_checkbox = new wxCheckBox( panel, SubsFileEnable_Event,
368 wxU(_("Subtitles file")) );
369 subsfile_checkbox->SetToolTip( wxU(_("Load an additional subtitles file. "
370 "Currently only works with AVI files.")) );
371 subsfile_sizer->Add( subsfile_checkbox, 0,
372 wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
373 subsfile_button = new wxButton( panel, SubsFileSettings_Event,
374 wxU(_("Settings...")) );
375 subsfile_button->Disable();
377 char *psz_subsfile = config_GetPsz( p_intf, "sub-file" );
378 if( psz_subsfile && *psz_subsfile )
380 subsfile_checkbox->SetValue(TRUE);
381 subsfile_button->Enable();
382 subsfile_mrl.Add( wxString(wxT("sub-file=")) + wxU(psz_subsfile) );
384 if( psz_subsfile ) free( psz_subsfile );
386 subsfile_sizer->Add( subsfile_button, 1,
387 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
389 sizer->Add( file_sizer, 0, wxEXPAND | wxALL, 5 );
390 sizer->Add( subsfile_sizer, 0, wxEXPAND | wxALL, 5 );
391 panel->SetSizerAndFit( sizer );
395 wxPanel *OpenDialog::DiscPanel( wxWindow* parent )
397 wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
400 wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
401 wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 3, 20 );
403 static const wxString disc_type_array[] =
405 wxU(_("DVD (menus support)")),
412 disc_type = new wxRadioBox( panel, DiscType_Event, wxU(_("Disc type")),
413 wxDefaultPosition, wxDefaultSize,
414 WXSIZEOF(disc_type_array), disc_type_array,
415 WXSIZEOF(disc_type_array), wxRA_SPECIFY_COLS );
416 sizer_row->Add( disc_type, 0, wxEXPAND | wxALL, 5 );
418 wxStaticText *label = new wxStaticText( panel, -1, wxU(_("Device name")) );
419 disc_device = new wxTextCtrl( panel, DiscDevice_Event, wxT(""),
420 wxDefaultPosition, wxDefaultSize,
423 sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
424 sizer->Add( disc_device, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
426 label = new wxStaticText( panel, -1, wxU(_("Title")) );
427 disc_title = new wxSpinCtrl( panel, DiscTitle_Event );
429 sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
430 sizer->Add( disc_title, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
432 label = new wxStaticText( panel, -1, wxU(_("Chapter")) );
433 disc_chapter = new wxSpinCtrl( panel, DiscChapter_Event );
434 sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
435 sizer->Add( disc_chapter, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
436 sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
438 panel->SetSizerAndFit( sizer_row );
442 wxPanel *OpenDialog::NetPanel( wxWindow* parent )
445 wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
448 wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
449 wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 3, 20 );
451 static const wxString net_type_array[] =
454 wxU(_("UDP/RTP Multicast")),
455 wxU(_("HTTP/FTP/MMS"))
460 net_radios[i] = new wxRadioButton( panel, NetRadio1_Event + i,
462 wxDefaultPosition, wxDefaultSize,
465 net_subpanels[i] = new wxPanel( panel, -1,
466 wxDefaultPosition, wxDefaultSize );
470 wxFlexGridSizer *subpanel_sizer;
472 i_net_ports[0] = config_GetInt( p_intf, "server-port" );
473 subpanel_sizer = new wxFlexGridSizer( 2, 1, 20 );
474 label = new wxStaticText( net_subpanels[0], -1, wxU(_("Port")) );
475 net_ports[0] = new wxSpinCtrl( net_subpanels[0], NetPort1_Event,
476 wxString::Format(wxT("%d"), i_net_ports[0]),
477 wxDefaultPosition, wxDefaultSize,
479 0, 16000, i_net_ports[0] );
481 subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
482 subpanel_sizer->Add( net_ports[0], 1,
483 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
484 net_subpanels[0]->SetSizerAndFit( subpanel_sizer );
485 net_radios[0]->SetValue( TRUE );
487 /* UDP/RTP Multicast row */
488 subpanel_sizer = new wxFlexGridSizer( 4, 1, 20 );
489 label = new wxStaticText( net_subpanels[1], -1, wxU(_("Address")) );
490 net_addrs[1] = new wxTextCtrl( net_subpanels[1], NetAddr2_Event, wxT(""),
491 wxDefaultPosition, wxDefaultSize,
493 subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
494 subpanel_sizer->Add( net_addrs[1], 1,
495 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
497 label = new wxStaticText( net_subpanels[1], -1, wxU(_("Port")) );
498 i_net_ports[1] = i_net_ports[0];
499 net_ports[1] = new wxSpinCtrl( net_subpanels[1], NetPort2_Event,
500 wxString::Format(wxT("%d"), i_net_ports[1]),
501 wxDefaultPosition, wxDefaultSize,
503 0, 16000, i_net_ports[1] );
505 subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
506 subpanel_sizer->Add( net_ports[1], 1,
507 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
508 net_subpanels[1]->SetSizerAndFit( subpanel_sizer );
511 subpanel_sizer = new wxFlexGridSizer( 2, 1, 20 );
512 label = new wxStaticText( net_subpanels[2], -1, wxU(_("URL")) );
513 net_addrs[2] = new wxTextCtrl( net_subpanels[2], NetAddr3_Event, wxT(""),
514 wxDefaultPosition, wxSize( 200, -1 ),
516 subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
517 subpanel_sizer->Add( net_addrs[2], 1,
518 wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
519 net_subpanels[2]->SetSizerAndFit( subpanel_sizer );
521 /* Stuff everything into the main panel */
524 sizer->Add( net_radios[i], 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
526 sizer->Add( net_subpanels[i], 1, wxEXPAND | wxALIGN_LEFT |
527 wxALIGN_CENTER_VERTICAL | wxALL, 5 );
530 sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
532 panel->SetSizerAndFit( sizer_row );
536 wxPanel *OpenDialog::V4LPanel( wxWindow* parent )
538 wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
541 wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
542 wxFlexGridSizer *sizer = new wxFlexGridSizer( 1, 4, 20 );
544 static const wxString video_type_array[] =
552 video_type = new wxRadioBox( panel, VideoType_Event,
553 wxU(_("Video Device Type")),
554 wxDefaultPosition, wxDefaultSize,
555 WXSIZEOF(video_type_array), video_type_array,
556 WXSIZEOF(video_type_array), wxRA_SPECIFY_COLS );
558 sizer_row->Add( video_type, 0, wxEXPAND | wxALL, 5 );
562 wxFlexGridSizer *video_sizer = new wxFlexGridSizer( 4, 2, 20 );
563 wxStaticText *label = new wxStaticText( panel, -1, wxU(_("Video Device")) );
564 video_device = new wxTextCtrl( panel, VideoDevice_Event, wxT(""),
565 wxDefaultPosition, wxDefaultSize,
568 video_sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
569 video_sizer->Add( video_device, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
571 label = new wxStaticText( panel, -1, wxU(_("Channel")) );
572 video_channel = new wxSpinCtrl( panel, VideoChannel_Event );
574 video_sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_HORIZONTAL );
575 video_sizer->Add( video_channel, 1, wxALIGN_LEFT | wxALIGN_CENTER_HORIZONTAL );
576 sizer->Add( video_sizer, 0, wxEXPAND | wxALL, 5 );
578 wxBoxSizer *v4lbutton_sizer = new wxBoxSizer( wxHORIZONTAL );
579 v4l_button = new wxButton( panel, V4LSettings_Event,
580 wxU(_("Advanced Settings...")) );
582 v4lbutton_sizer->Add( v4l_button, 0, wxALIGN_RIGHT, 5 );
584 sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
585 sizer_row->Add( v4lbutton_sizer, 0, wxEXPAND | wxALL, 5 );
587 panel->SetSizerAndFit( sizer_row );
591 wxPanel *OpenDialog::SatPanel( wxWindow* parent )
593 wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
598 void OpenDialog::UpdateMRL( int i_access_method )
600 wxString demux, mrltemp;
602 i_current_access_method = i_access_method;
604 /* Check if the user asked for demuxdump */
605 if( demuxdump_checkbox->GetValue() )
607 demux = wxT("/demuxdump");
610 switch( i_access_method )
613 //mrltemp = wxT("file") + demux + wxT(":") + file_combo->GetValue();
614 mrltemp = file_combo->GetValue();
617 mrltemp = ( disc_type->GetSelection() == 0 ? wxT("dvd") :
618 disc_type->GetSelection() == 1 ? wxT("dvdsimple") :
619 disc_type->GetSelection() == 2 ? wxT("vcd") : wxT("cdda") )
621 + disc_device->GetLineText(0)
622 + wxString::Format( wxT("@%d:%d"),
623 i_disc_title, i_disc_chapter );
629 if( i_net_ports[0] !=
630 config_GetInt( p_intf, "server-port" ) )
632 mrltemp = wxT("udp") + demux +
633 wxString::Format( wxT("://@:%d"),
638 mrltemp = wxT("udp") + demux + wxT("://");
643 mrltemp = wxT("udp") + demux + wxT("://@") +
644 net_addrs[1]->GetLineText(0);
645 if( i_net_ports[1] !=
646 config_GetInt( p_intf, "server-port" ) )
648 mrltemp = mrltemp + wxString::Format( wxT(":%d"),
655 mrltemp = wxT("http") + demux + wxT("://") +
656 net_addrs[2]->GetLineText(0);
661 mrltemp = wxT("satellite") + demux + wxT("://");
665 mrltemp = ( video_type->GetSelection() == 0 ? wxT("v4l") :
666 video_type->GetSelection() == 1 ? wxT("v4l") :
667 video_type->GetSelection() == 2 ? wxT("pvr") :
670 + video_device->GetLineText( 0 );
672 if( video_type->GetSelection() == 1 )
674 mrltemp += wxString::Format( wxT(":channel=%d"),
675 video_channel->GetValue() );
678 if ( /* v4l_dialog != NULL && */ !v4l_mrl.IsEmpty() )
680 mrltemp += v4l_mrl[0];
689 mrl_combo->SetValue( mrltemp );
692 /*****************************************************************************
694 *****************************************************************************/
695 void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
697 mrl = SeparateEntries( mrl_combo->GetValue() );
698 mrl_combo->Append( mrl_combo->GetValue() );
699 if( mrl_combo->GetCount() > 10 ) mrl_combo->Delete( 0 );
700 mrl_combo->SetSelection( mrl_combo->GetCount() - 1 );
702 /* Update the playlist */
703 playlist_t *p_playlist =
704 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
706 if( p_playlist == NULL ) return;
708 for( int i = 0; i < (int)mrl.GetCount(); i++ )
710 int i_options = 0, i_total_options;
711 char **ppsz_options = NULL;
713 /* Count the input options */
714 while( i + i_options + 1 < (int)mrl.GetCount() &&
715 ((const char *)mrl[i + i_options + 1].mb_str())[0] == ':' )
720 /* Allocate ppsz_options */
721 for( int j = 0; j < i_options; j++ )
724 ppsz_options = (char **)malloc( sizeof(char *) * i_options );
726 ppsz_options[j] = strdup( mrl[i + j + 1].mb_str() );
729 i_total_options = i_options;
731 /* Get the options from the subtitles dialog */
732 if( subsfile_checkbox->IsChecked() && subsfile_mrl.GetCount() )
734 ppsz_options = (char **)realloc( ppsz_options, sizeof(char *) *
735 (i_total_options + subsfile_mrl.GetCount()) );
737 for( int j = 0; j < (int)subsfile_mrl.GetCount(); j++ )
739 ppsz_options[i_total_options + j] =
740 strdup( subsfile_mrl[j].mb_str() );
743 i_total_options += subsfile_mrl.GetCount();
746 /* Get the options from the v4l dialog */
747 /* if( v4l_mrl.GetCount() )
749 ppsz_options = (char **)realloc( ppsz_options, sizeof(char *) *
750 (i_total_options + v4l_mrl.GetCount()) );
752 for( int j = 0; j < (int)v4l_mrl.GetCount(); j++ )
754 ppsz_options[i_total_options + j] =
755 strdup( v4l_mrl[j].mb_str() );
758 i_total_options += v4l_mrl.GetCount();
762 /* Get the options from the stream output dialog */
763 if( sout_checkbox->IsChecked() && sout_mrl.GetCount() )
765 ppsz_options = (char **)realloc( ppsz_options, sizeof(char *) *
766 (i_total_options + sout_mrl.GetCount()) );
768 for( int j = 0; j < (int)sout_mrl.GetCount(); j++ )
770 ppsz_options[i_total_options + j] =
771 strdup( sout_mrl[j].mb_str() );
774 i_total_options += sout_mrl.GetCount();
778 playlist_Add( p_playlist, (const char *)mrl[i].mb_str(),
779 (const char **)ppsz_options, i_total_options,
780 PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO), PLAYLIST_END );
783 for( int j = 0; j < i_total_options; j++ )
784 free( ppsz_options[j] );
785 if( ppsz_options ) free( ppsz_options );
790 //TogglePlayButton( PLAYING_S );
792 vlc_object_release( p_playlist );
797 void OpenDialog::OnCancel( wxCommandEvent& WXUNUSED(event) )
802 void OpenDialog::OnPageChange( wxNotebookEvent& event )
804 UpdateMRL( event.GetSelection() );
807 void OpenDialog::OnMRLChange( wxCommandEvent& event )
809 //mrl = SeparateEntries( event.GetString() );
812 /*****************************************************************************
813 * File panel event methods.
814 *****************************************************************************/
815 void OpenDialog::OnFilePanelChange( wxCommandEvent& WXUNUSED(event) )
817 UpdateMRL( FILE_ACCESS );
820 void OpenDialog::OnFileBrowse( wxCommandEvent& WXUNUSED(event) )
822 if( file_dialog == NULL )
823 file_dialog = new wxFileDialog( this, wxU(_("Open file")),
824 wxT(""), wxT(""), wxT("*"), wxOPEN | wxMULTIPLE );
826 if( file_dialog && file_dialog->ShowModal() == wxID_OK )
831 file_dialog->GetPaths( paths );
833 for( size_t i = 0; i < paths.GetCount(); i++ )
835 if( paths[i].Find( wxT(' ') ) >= 0 )
836 path += wxT("\"") + paths[i] + wxT("\" ");
838 path += paths[i] + wxT(" ");
841 file_combo->SetValue( path );
842 file_combo->Append( path );
843 if( file_combo->GetCount() > 10 ) file_combo->Delete( 0 );
844 UpdateMRL( FILE_ACCESS );
848 /*****************************************************************************
849 * Disc panel event methods.
850 *****************************************************************************/
851 void OpenDialog::OnDiscPanelChange( wxCommandEvent& event )
853 if( event.GetId() == DiscTitle_Event )
854 i_disc_title = event.GetInt();
855 else if( event.GetId() == DiscChapter_Event )
856 i_disc_chapter = event.GetInt();
858 UpdateMRL( DISC_ACCESS );
861 void OpenDialog::OnDiscTypeChange( wxCommandEvent& WXUNUSED(event) )
865 switch( disc_type->GetSelection() )
868 psz_device = config_GetPsz( p_intf, "vcd" );
869 disc_device->SetValue( psz_device ? wxU(psz_device) : wxT("") );
873 psz_device = config_GetPsz( p_intf, "dvd" );
874 disc_device->SetValue( psz_device ? wxU(psz_device) : wxT("") );
878 if( psz_device ) free( psz_device );
880 switch( disc_type->GetSelection() )
883 disc_title->SetRange( 0, 255 );
884 disc_title->SetValue( 0 );
889 disc_title->SetRange( 1, 255 );
890 disc_title->SetValue( 1 );
896 disc_chapter->SetRange( 1, 255 );
897 disc_chapter->SetValue( 1 );
899 UpdateMRL( DISC_ACCESS );
902 /*****************************************************************************
903 * Net panel event methods.
904 *****************************************************************************/
905 void OpenDialog::OnNetPanelChange( wxCommandEvent& event )
907 if( event.GetId() >= NetPort1_Event && event.GetId() <= NetPort3_Event )
909 i_net_ports[event.GetId() - NetPort1_Event] = event.GetInt();
912 UpdateMRL( NET_ACCESS );
915 void OpenDialog::OnNetTypeChange( wxCommandEvent& event )
919 i_net_type = event.GetId() - NetRadio1_Event;
923 net_radios[i]->SetValue( event.GetId() == (NetRadio1_Event+i) );
924 net_subpanels[i]->Enable( event.GetId() == (NetRadio1_Event+i) );
927 UpdateMRL( NET_ACCESS );
930 /*****************************************************************************
931 * v4l panel event methods.
932 *****************************************************************************/
933 void OpenDialog::OnV4LPanelChange( wxCommandEvent& WXUNUSED(event) )
935 UpdateMRL( V4L_ACCESS );
938 void OpenDialog::OnV4LTypeChange( wxCommandEvent& WXUNUSED(event) )
940 video_device->SetValue( wxU( "/dev/video" ) );
942 v4l_button->Enable();
943 video_channel->Disable();
945 switch( video_type->GetSelection() )
948 video_channel->Enable();
949 video_channel->SetRange( 0, 255 );
950 video_channel->SetValue( 0 );
953 v4l_button->Disable();
959 UpdateMRL( V4L_ACCESS );
962 void OpenDialog::OnV4LSettingsChange( wxCommandEvent& WXUNUSED(event) )
964 /* Show/hide the open dialog */
965 if( v4l_dialog == NULL )
966 v4l_dialog = new V4LDialog( p_intf, this );
968 if( v4l_dialog && v4l_dialog->ShowModal() == wxID_OK )
970 v4l_mrl = v4l_dialog->GetOptions();
973 UpdateMRL( V4L_ACCESS );
976 /*****************************************************************************
977 * Subtitles file event methods.
978 *****************************************************************************/
979 void OpenDialog::OnSubsFileEnable( wxCommandEvent& event )
981 subsfile_button->Enable( event.GetInt() != 0 );
982 if( event.GetInt() && demuxdump_checkbox->IsChecked() )
984 demuxdump_checkbox->SetValue( 0 );
985 wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
987 OnDemuxDumpEnable( event );
991 void OpenDialog::OnSubsFileSettings( wxCommandEvent& WXUNUSED(event) )
993 /* Show/hide the open dialog */
994 if( subsfile_dialog == NULL )
995 subsfile_dialog = new SubsFileDialog( p_intf, this );
997 if( subsfile_dialog && subsfile_dialog->ShowModal() == wxID_OK )
999 subsfile_mrl.Empty();
1000 subsfile_mrl.Add( wxString(wxT("sub-file=")) +
1001 subsfile_dialog->file_combo->GetValue() );
1002 if( subsfile_dialog->encoding_combo )
1003 subsfile_mrl.Add( wxString(wxT("subsdec-encoding=")) +
1004 subsfile_dialog->encoding_combo->GetValue() );
1005 subsfile_mrl.Add( wxString::Format( wxT("sub-delay=%i"),
1006 subsfile_dialog->delay_spinctrl->GetValue() ) );
1007 subsfile_mrl.Add( wxString::Format( wxT("sub-fps=%i"),
1008 subsfile_dialog->fps_spinctrl->GetValue() ) );
1012 /*****************************************************************************
1013 * Stream output event methods.
1014 *****************************************************************************/
1015 void OpenDialog::OnSoutEnable( wxCommandEvent& event )
1017 sout_button->Enable( event.GetInt() != 0 );
1018 if( event.GetInt() && demuxdump_checkbox->IsChecked() )
1020 demuxdump_checkbox->SetValue( 0 );
1021 wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
1023 OnDemuxDumpEnable( event );
1027 void OpenDialog::OnSoutSettings( wxCommandEvent& WXUNUSED(event) )
1029 /* Show/hide the open dialog */
1030 if( sout_dialog == NULL )
1031 sout_dialog = new SoutDialog( p_intf, this );
1033 if( sout_dialog && sout_dialog->ShowModal() == wxID_OK )
1035 sout_mrl = sout_dialog->GetOptions();
1039 /*****************************************************************************
1040 * Demux dump event methods.
1041 *****************************************************************************/
1042 void OpenDialog::OnDemuxDumpEnable( wxCommandEvent& event )
1044 demuxdump_textctrl->Enable( event.GetInt() != 0 );
1045 demuxdump_button->Enable( event.GetInt() != 0 );
1047 if( event.GetInt() )
1049 sout_checkbox->SetValue( 0 );
1050 subsfile_checkbox->SetValue( 0 );
1051 wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
1053 OnSoutEnable( event );
1054 OnSubsFileEnable( event );
1057 UpdateMRL( i_current_access_method );
1060 void OpenDialog::OnDemuxDumpBrowse( wxCommandEvent& WXUNUSED(event) )
1062 if( demuxdump_dialog == NULL )
1063 demuxdump_dialog = new wxFileDialog( this, wxU(_("Save file")),
1064 wxT(""), wxT(""), wxT("*"), wxSAVE );
1066 if( demuxdump_dialog && demuxdump_dialog->ShowModal() == wxID_OK )
1068 demuxdump_textctrl->SetValue( demuxdump_dialog->GetPath() );
1069 wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
1070 OnDemuxDumpChange( event );
1074 void OpenDialog::OnDemuxDumpChange( wxCommandEvent& WXUNUSED(event) )
1076 config_PutPsz( p_intf, "demuxdump-file",
1077 demuxdump_textctrl->GetValue().mb_str() );
1080 /*****************************************************************************
1081 * Utility functions.
1082 *****************************************************************************/
1083 wxArrayString SeparateEntries( wxString entries )
1085 vlc_bool_t b_quotes_mode = VLC_FALSE;
1087 wxArrayString entries_array;
1090 wxStringTokenizer token( entries, wxT(" \t\r\n\""), wxTOKEN_RET_DELIMS );
1092 while( token.HasMoreTokens() )
1094 entry += token.GetNextToken();
1096 if( entry.IsEmpty() ) continue;
1098 if( !b_quotes_mode && entry.Last() == wxT('\"') )
1100 /* Enters quotes mode */
1102 b_quotes_mode = VLC_TRUE;
1104 else if( b_quotes_mode && entry.Last() == wxT('\"') )
1106 /* Finished the quotes mode */
1108 if( !entry.IsEmpty() ) entries_array.Add( entry );
1110 b_quotes_mode = VLC_FALSE;
1112 else if( !b_quotes_mode && entry.Last() != wxT('\"') )
1114 /* we found a non-quoted standalone string */
1115 if( token.HasMoreTokens() ||
1116 entry.Last() == wxT(' ') || entry.Last() == wxT('\t') ||
1117 entry.Last() == wxT('\r') || entry.Last() == wxT('\n') )
1119 if( !entry.IsEmpty() ) entries_array.Add( entry );
1126 if( !entry.IsEmpty() ) entries_array.Add( entry );
1128 return entries_array;