1 /*****************************************************************************
2 * open.cpp : wxWindows plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000-2001 VideoLAN
5 * $Id: open.cpp,v 1.38 2003/08/22 14:03:40 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,
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 /* Initializations */
170 p_parent = _p_parent;
171 SetIcon( *p_intf->p_sys->p_icon );
177 subsfile_dialog = NULL;
178 demuxdump_dialog = NULL;
180 /* Create a panel to put everything in */
181 wxPanel *panel = new wxPanel( this, -1 );
182 panel->SetAutoLayout( TRUE );
184 /* Create MRL combobox */
185 wxBoxSizer *mrl_sizer_sizer = new wxBoxSizer( wxHORIZONTAL );
186 wxStaticBox *mrl_box = new wxStaticBox( panel, -1,
187 wxU(_("Media Resource Locator (MRL)")) );
188 wxStaticBoxSizer *mrl_sizer = new wxStaticBoxSizer( mrl_box,
190 wxStaticText *mrl_label = new wxStaticText( panel, -1,
191 wxU(_("Open Target:")) );
192 mrl_combo = new wxComboBox( panel, MRL_Event, wxT(""),
193 wxPoint(20,25), wxSize(120, -1),
195 mrl_combo->SetToolTip( wxU(_("You can use this field directly by typing "
196 "the full MRL you want to open.\n""Alternatively, the field will be "
197 "filled automatically when you use the controls below.")) );
199 mrl_sizer->Add( mrl_label, 0, wxALL | wxALIGN_CENTER, 5 );
200 mrl_sizer->Add( mrl_combo, 1, wxALL | wxALIGN_CENTER, 5 );
201 mrl_sizer_sizer->Add( mrl_sizer, 1, wxEXPAND | wxALL, 5 );
204 /* Create Static Text */
205 wxStaticText *label = new wxStaticText( panel, -1,
206 wxU(_("Alternatively, you can build an MRL using one of the "
207 "following predefined targets:")) );
209 /* Create Stream Output checkox */
210 wxFlexGridSizer *sout_sizer = new wxFlexGridSizer( 2, 1, 20 );
211 sout_checkbox = new wxCheckBox( panel, SoutEnable_Event,
212 wxU(_("Stream output")) );
213 sout_checkbox->SetToolTip( wxU(_("Use VLC as a stream server")) );
214 sout_sizer->Add( sout_checkbox, 0,
215 wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
216 sout_button = new wxButton( panel, SoutSettings_Event,
217 wxU(_("Settings...")) );
218 sout_button->Disable();
220 char *psz_sout = config_GetPsz( p_intf, "sout" );
221 if( psz_sout && *psz_sout )
223 sout_checkbox->SetValue(TRUE);
224 sout_button->Enable();
225 subsfile_mrl.Add( wxString(wxT("sout=")) + wxU(psz_sout) );
227 if( psz_sout ) free( psz_sout );
229 sout_sizer->Add( sout_button, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
231 /* Create Demux Dump checkox */
232 wxBoxSizer *demuxdump_sizer = new wxBoxSizer( wxHORIZONTAL );
233 demuxdump_checkbox = new wxCheckBox( panel, DemuxDumpEnable_Event,
234 wxU(_("Capture input stream")) );
235 demuxdump_checkbox->SetToolTip(
236 wxU(_("Capture the stream you are playing to a file")) );
237 demuxdump_textctrl = new wxTextCtrl( panel, DemuxDump_Event, wxT(""),
238 wxDefaultPosition, wxDefaultSize,
239 wxTE_PROCESS_ENTER );
240 demuxdump_button = new wxButton( panel, DemuxDumpBrowse_Event,
241 wxU(_("Browse...")) );
243 char *psz_demuxdump = config_GetPsz( p_intf, "demuxdump-file" );
244 if( psz_demuxdump && *psz_demuxdump )
246 demuxdump_textctrl->SetValue( wxU(psz_demuxdump) );
248 if( psz_demuxdump ) free( psz_demuxdump );
250 demuxdump_textctrl->Disable();
251 demuxdump_button->Disable();
252 demuxdump_sizer->Add( demuxdump_checkbox, 0,
253 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
254 demuxdump_sizer->Add( demuxdump_button, 0,
255 wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL, 10 );
256 demuxdump_sizer->Add( demuxdump_textctrl, 1, wxRIGHT, 10 );
259 wxStaticLine *static_line = new wxStaticLine( panel, wxID_OK );
261 /* Create the buttons */
262 wxButton *ok_button = new wxButton( panel, wxID_OK, wxU(_("OK")) );
263 ok_button->SetDefault();
264 wxButton *cancel_button = new wxButton( panel, wxID_CANCEL,
267 /* Create notebook */
268 notebook = new wxNotebook( panel, Notebook_Event );
269 wxNotebookSizer *notebook_sizer = new wxNotebookSizer( notebook );
271 notebook->AddPage( FilePanel( notebook ), wxU(_("File")),
272 i_access_method == FILE_ACCESS );
273 notebook->AddPage( DiscPanel( notebook ), wxU(_("Disc")),
274 i_access_method == DISC_ACCESS );
275 notebook->AddPage( NetPanel( notebook ), wxU(_("Network")),
276 i_access_method == NET_ACCESS );
278 notebook->AddPage( SatPanel( notebook ), wxU(_("Satellite")),
279 i_access_method == SAT_ACCESS );
281 notebook->AddPage( V4LPanel( notebook ), wxU(_("Video For Linux")),
282 i_access_method == V4L_ACCESS );
285 /* Update Disc panel */
286 wxCommandEvent dummy_event;
287 OnDiscTypeChange( dummy_event );
289 /* Update Net panel */
290 dummy_event.SetId( NetRadio1_Event );
291 OnNetTypeChange( dummy_event );
294 /* Update v4l panel */
295 dummy_event.SetId( VideoType_Event );
296 OnV4LTypeChange( dummy_event );
300 wxNotebookEvent event( wxEVT_NULL, 0, i_access_method );
301 OnPageChange( event );
303 /* Place everything in sizers */
304 wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
305 button_sizer->Add( ok_button, 0, wxALL, 5 );
306 button_sizer->Add( cancel_button, 0, wxALL, 5 );
307 button_sizer->Layout();
308 wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
309 wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
310 panel_sizer->Add( mrl_sizer_sizer, 0, wxEXPAND, 5 );
311 panel_sizer->Add( label, 0, wxEXPAND | wxALL, 5 );
312 panel_sizer->Add( notebook_sizer, 1, wxEXPAND | wxALL, 5 );
313 panel_sizer->Add( sout_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
314 panel_sizer->Add( demuxdump_sizer, 0, wxEXPAND | wxALIGN_LEFT | wxALL, 5 );
315 panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
316 panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
317 panel_sizer->Layout();
318 panel->SetSizerAndFit( panel_sizer );
319 main_sizer->Add( panel, 1, wxGROW, 0 );
320 main_sizer->Layout();
321 SetSizerAndFit( main_sizer );
324 OpenDialog::~OpenDialog()
327 if( file_dialog ) delete file_dialog;
329 if( v4l_dialog ) delete v4l_dialog;
331 if( sout_dialog ) delete sout_dialog;
332 if( subsfile_dialog ) delete subsfile_dialog;
333 if( demuxdump_dialog ) delete demuxdump_dialog;
336 int OpenDialog::Show( int i_access_method, int i_arg )
339 notebook->SetSelection( i_access_method );
340 i_ret = wxFrame::Show();
346 int OpenDialog::Show()
349 i_ret = wxFrame::Show();
355 /*****************************************************************************
357 *****************************************************************************/
358 wxPanel *OpenDialog::FilePanel( wxWindow* parent )
360 wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
363 wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
365 /* Create browse file line */
366 wxBoxSizer *file_sizer = new wxBoxSizer( wxHORIZONTAL );
368 file_combo = new wxComboBox( panel, FileName_Event, wxT(""),
369 wxPoint(20,25), wxSize(200, -1), 0, NULL );
370 wxButton *browse_button = new wxButton( panel, FileBrowse_Event,
371 wxU(_("Browse...")) );
372 file_sizer->Add( file_combo, 1, wxALL, 5 );
373 file_sizer->Add( browse_button, 0, wxALL, 5 );
375 /* Create Subtitles File checkox */
376 wxFlexGridSizer *subsfile_sizer = new wxFlexGridSizer( 2, 1, 20 );
377 subsfile_checkbox = new wxCheckBox( panel, SubsFileEnable_Event,
378 wxU(_("Subtitles file")) );
379 subsfile_checkbox->SetToolTip( wxU(_("Load an additional subtitles file. "
380 "Currently only works with AVI files.")) );
381 subsfile_sizer->Add( subsfile_checkbox, 0,
382 wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
383 subsfile_button = new wxButton( panel, SubsFileSettings_Event,
384 wxU(_("Settings...")) );
385 subsfile_button->Disable();
387 char *psz_subsfile = config_GetPsz( p_intf, "sub-file" );
388 if( psz_subsfile && *psz_subsfile )
390 subsfile_checkbox->SetValue(TRUE);
391 subsfile_button->Enable();
392 subsfile_mrl.Add( wxString(wxT("sub-file=")) + wxU(psz_subsfile) );
394 if( psz_subsfile ) free( psz_subsfile );
396 subsfile_sizer->Add( subsfile_button, 1,
397 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
399 sizer->Add( file_sizer, 0, wxEXPAND | wxALL, 5 );
400 sizer->Add( subsfile_sizer, 0, wxEXPAND | wxALL, 5 );
401 panel->SetSizerAndFit( sizer );
405 wxPanel *OpenDialog::DiscPanel( wxWindow* parent )
407 wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
410 wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
411 wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 3, 20 );
413 static const wxString disc_type_array[] =
415 wxU(_("DVD (menus support)")),
422 disc_type = new wxRadioBox( panel, DiscType_Event, wxU(_("Disc type")),
423 wxDefaultPosition, wxDefaultSize,
424 WXSIZEOF(disc_type_array), disc_type_array,
425 WXSIZEOF(disc_type_array), wxRA_SPECIFY_COLS );
426 sizer_row->Add( disc_type, 0, wxEXPAND | wxALL, 5 );
428 wxStaticText *label = new wxStaticText( panel, -1, wxU(_("Device name")) );
429 disc_device = new wxTextCtrl( panel, DiscDevice_Event, wxT(""),
430 wxDefaultPosition, wxDefaultSize,
433 sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
434 sizer->Add( disc_device, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
436 label = new wxStaticText( panel, -1, wxU(_("Title")) );
437 disc_title = new wxSpinCtrl( panel, DiscTitle_Event );
439 sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
440 sizer->Add( disc_title, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
442 label = new wxStaticText( panel, -1, wxU(_("Chapter")) );
443 disc_chapter = new wxSpinCtrl( panel, DiscChapter_Event );
444 sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
445 sizer->Add( disc_chapter, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
446 sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
448 panel->SetSizerAndFit( sizer_row );
452 wxPanel *OpenDialog::NetPanel( wxWindow* parent )
455 wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
458 wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
459 wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 3, 20 );
461 static const wxString net_type_array[] =
464 wxU(_("UDP/RTP Multicast")),
465 wxU(_("HTTP/FTP/MMS"))
470 net_radios[i] = new wxRadioButton( panel, NetRadio1_Event + i,
472 wxDefaultPosition, wxDefaultSize,
475 net_subpanels[i] = new wxPanel( panel, -1,
476 wxDefaultPosition, wxDefaultSize );
480 wxFlexGridSizer *subpanel_sizer;
482 i_net_ports[0] = config_GetInt( p_intf, "server-port" );
483 subpanel_sizer = new wxFlexGridSizer( 2, 1, 20 );
484 label = new wxStaticText( net_subpanels[0], -1, wxU(_("Port")) );
485 net_ports[0] = new wxSpinCtrl( net_subpanels[0], NetPort1_Event,
486 wxString::Format(wxT("%d"), i_net_ports[0]),
487 wxDefaultPosition, wxDefaultSize,
489 0, 16000, i_net_ports[0] );
491 subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
492 subpanel_sizer->Add( net_ports[0], 1,
493 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
494 net_subpanels[0]->SetSizerAndFit( subpanel_sizer );
495 net_radios[0]->SetValue( TRUE );
497 /* UDP/RTP Multicast row */
498 subpanel_sizer = new wxFlexGridSizer( 4, 1, 20 );
499 label = new wxStaticText( net_subpanels[1], -1, wxU(_("Address")) );
500 net_addrs[1] = new wxTextCtrl( net_subpanels[1], NetAddr2_Event, wxT(""),
501 wxDefaultPosition, wxDefaultSize,
503 subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
504 subpanel_sizer->Add( net_addrs[1], 1,
505 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
507 label = new wxStaticText( net_subpanels[1], -1, wxU(_("Port")) );
508 i_net_ports[1] = i_net_ports[0];
509 net_ports[1] = new wxSpinCtrl( net_subpanels[1], NetPort2_Event,
510 wxString::Format(wxT("%d"), i_net_ports[1]),
511 wxDefaultPosition, wxDefaultSize,
513 0, 16000, i_net_ports[1] );
515 subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
516 subpanel_sizer->Add( net_ports[1], 1,
517 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
518 net_subpanels[1]->SetSizerAndFit( subpanel_sizer );
521 subpanel_sizer = new wxFlexGridSizer( 2, 1, 20 );
522 label = new wxStaticText( net_subpanels[2], -1, wxU(_("URL")) );
523 net_addrs[2] = new wxTextCtrl( net_subpanels[2], NetAddr3_Event, wxT(""),
524 wxDefaultPosition, wxSize( 200, -1 ),
526 subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
527 subpanel_sizer->Add( net_addrs[2], 1,
528 wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
529 net_subpanels[2]->SetSizerAndFit( subpanel_sizer );
531 /* Stuff everything into the main panel */
534 sizer->Add( net_radios[i], 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
536 sizer->Add( net_subpanels[i], 1, wxEXPAND | wxALIGN_LEFT |
537 wxALIGN_CENTER_VERTICAL | wxALL, 5 );
540 sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
542 panel->SetSizerAndFit( sizer_row );
547 wxPanel *OpenDialog::V4LPanel( wxWindow* parent )
549 wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
552 wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
553 wxFlexGridSizer *sizer = new wxFlexGridSizer( 1, 4, 20 );
555 static const wxString video_type_array[] =
563 video_type = new wxRadioBox( panel, VideoType_Event,
564 wxU(_("Video Device Type")),
565 wxDefaultPosition, wxDefaultSize,
566 WXSIZEOF(video_type_array), video_type_array,
567 WXSIZEOF(video_type_array), wxRA_SPECIFY_COLS );
569 sizer_row->Add( video_type, 0, wxEXPAND | wxALL, 5 );
573 wxFlexGridSizer *video_sizer = new wxFlexGridSizer( 4, 2, 20 );
574 wxStaticText *label = new wxStaticText( panel, -1, wxU(_("Video Device")) );
575 video_device = new wxTextCtrl( panel, VideoDevice_Event, wxT(""),
576 wxDefaultPosition, wxDefaultSize,
579 video_sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
580 video_sizer->Add( video_device, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
582 label = new wxStaticText( panel, -1, wxU(_("Channel")) );
583 video_channel = new wxSpinCtrl( panel, VideoChannel_Event );
585 video_sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_HORIZONTAL );
586 video_sizer->Add( video_channel, 1, wxALIGN_LEFT | wxALIGN_CENTER_HORIZONTAL );
587 sizer->Add( video_sizer, 0, wxEXPAND | wxALL, 5 );
589 wxBoxSizer *v4lbutton_sizer = new wxBoxSizer( wxHORIZONTAL );
590 v4l_button = new wxButton( panel, V4LSettings_Event,
591 wxU(_("Advanced Settings...")) );
593 v4lbutton_sizer->Add( v4l_button, 0, wxALIGN_RIGHT, 5 );
595 sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
596 sizer_row->Add( v4lbutton_sizer, 0, wxEXPAND | wxALL, 5 );
598 panel->SetSizerAndFit( sizer_row );
603 wxPanel *OpenDialog::SatPanel( wxWindow* parent )
605 wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
610 void OpenDialog::UpdateMRL( int i_access_method )
612 wxString demux, mrltemp;
614 i_current_access_method = i_access_method;
616 /* Check if the user asked for demuxdump */
617 if( demuxdump_checkbox->GetValue() )
619 demux = wxT("/demuxdump");
622 switch( i_access_method )
625 //mrltemp = wxT("file") + demux + wxT(":") + file_combo->GetValue();
626 mrltemp = file_combo->GetValue();
629 mrltemp = ( disc_type->GetSelection() == 0 ? wxT("dvd") :
630 disc_type->GetSelection() == 1 ? wxT("dvdsimple") :
631 disc_type->GetSelection() == 2 ? wxT("vcd") : wxT("cdda") )
633 + disc_device->GetLineText(0)
634 + wxString::Format( wxT("@%d:%d"),
635 i_disc_title, i_disc_chapter );
641 if( i_net_ports[0] !=
642 config_GetInt( p_intf, "server-port" ) )
644 mrltemp = wxT("udp") + demux +
645 wxString::Format( wxT("://@:%d"),
650 mrltemp = wxT("udp") + demux + wxT("://");
655 mrltemp = wxT("udp") + demux + wxT("://@") +
656 net_addrs[1]->GetLineText(0);
657 if( i_net_ports[1] !=
658 config_GetInt( p_intf, "server-port" ) )
660 mrltemp = mrltemp + wxString::Format( wxT(":%d"),
667 mrltemp = wxT("http") + demux + wxT("://") +
668 net_addrs[2]->GetLineText(0);
673 mrltemp = wxT("satellite") + demux + wxT("://");
678 mrltemp = ( video_type->GetSelection() == 0 ? wxT("v4l") :
679 video_type->GetSelection() == 1 ? wxT("v4l") :
680 video_type->GetSelection() == 2 ? wxT("pvr") :
683 + video_device->GetLineText( 0 );
685 if( video_type->GetSelection() == 1 )
687 mrltemp += wxString::Format( wxT(":channel=%d"),
688 video_channel->GetValue() );
691 if ( /* v4l_dialog != NULL && */ !v4l_mrl.IsEmpty() )
693 mrltemp += v4l_mrl[0];
703 mrl_combo->SetValue( mrltemp );
706 /*****************************************************************************
708 *****************************************************************************/
709 void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
711 mrl = SeparateEntries( mrl_combo->GetValue() );
712 mrl_combo->Append( mrl_combo->GetValue() );
713 if( mrl_combo->GetCount() > 10 ) mrl_combo->Delete( 0 );
714 mrl_combo->SetSelection( mrl_combo->GetCount() - 1 );
716 /* Update the playlist */
717 playlist_t *p_playlist =
718 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
720 if( p_playlist == NULL ) return;
722 for( int i = 0; i < (int)mrl.GetCount(); i++ )
724 int i_options = 0, i_total_options;
725 char **ppsz_options = NULL;
727 /* Count the input options */
728 while( i + i_options + 1 < (int)mrl.GetCount() &&
729 ((const char *)mrl[i + i_options + 1].mb_str())[0] == ':' )
734 /* Allocate ppsz_options */
735 for( int j = 0; j < i_options; j++ )
738 ppsz_options = (char **)malloc( sizeof(char *) * i_options );
740 ppsz_options[j] = strdup( mrl[i + j + 1].mb_str() );
743 i_total_options = i_options;
745 /* Get the options from the subtitles dialog */
746 if( subsfile_checkbox->IsChecked() && subsfile_mrl.GetCount() )
748 ppsz_options = (char **)realloc( ppsz_options, sizeof(char *) *
749 (i_total_options + subsfile_mrl.GetCount()) );
751 for( int j = 0; j < (int)subsfile_mrl.GetCount(); j++ )
753 ppsz_options[i_total_options + j] =
754 strdup( subsfile_mrl[j].mb_str() );
757 i_total_options += subsfile_mrl.GetCount();
760 /* Get the options from the stream output dialog */
761 if( sout_checkbox->IsChecked() && sout_mrl.GetCount() )
763 ppsz_options = (char **)realloc( ppsz_options, sizeof(char *) *
764 (i_total_options + sout_mrl.GetCount()) );
766 for( int j = 0; j < (int)sout_mrl.GetCount(); j++ )
768 ppsz_options[i_total_options + j] =
769 strdup( sout_mrl[j].mb_str() );
772 i_total_options += sout_mrl.GetCount();
776 playlist_Add( p_playlist, (const char *)mrl[i].mb_str(),
777 (const char **)ppsz_options, i_total_options,
778 PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO), PLAYLIST_END );
781 for( int j = 0; j < i_total_options; j++ )
782 free( ppsz_options[j] );
783 if( ppsz_options ) free( ppsz_options );
788 //TogglePlayButton( PLAYING_S );
790 vlc_object_release( p_playlist );
795 void OpenDialog::OnCancel( wxCommandEvent& WXUNUSED(event) )
800 void OpenDialog::OnPageChange( wxNotebookEvent& event )
802 UpdateMRL( event.GetSelection() );
805 void OpenDialog::OnMRLChange( wxCommandEvent& event )
807 //mrl = SeparateEntries( event.GetString() );
810 /*****************************************************************************
811 * File panel event methods.
812 *****************************************************************************/
813 void OpenDialog::OnFilePanelChange( wxCommandEvent& WXUNUSED(event) )
815 UpdateMRL( FILE_ACCESS );
818 void OpenDialog::OnFileBrowse( wxCommandEvent& WXUNUSED(event) )
820 if( file_dialog == NULL )
821 file_dialog = new wxFileDialog( this, wxU(_("Open file")),
822 wxT(""), wxT(""), wxT("*"), wxOPEN | wxMULTIPLE );
824 if( file_dialog && file_dialog->ShowModal() == wxID_OK )
829 file_dialog->GetPaths( paths );
831 for( size_t i = 0; i < paths.GetCount(); i++ )
833 if( paths[i].Find( wxT(' ') ) >= 0 )
834 path += wxT("\"") + paths[i] + wxT("\" ");
836 path += paths[i] + wxT(" ");
839 file_combo->SetValue( path );
840 file_combo->Append( path );
841 if( file_combo->GetCount() > 10 ) file_combo->Delete( 0 );
842 UpdateMRL( FILE_ACCESS );
846 /*****************************************************************************
847 * Disc panel event methods.
848 *****************************************************************************/
849 void OpenDialog::OnDiscPanelChange( wxCommandEvent& event )
851 if( event.GetId() == DiscTitle_Event )
852 i_disc_title = event.GetInt();
853 else if( event.GetId() == DiscChapter_Event )
854 i_disc_chapter = event.GetInt();
856 UpdateMRL( DISC_ACCESS );
859 void OpenDialog::OnDiscTypeChange( wxCommandEvent& WXUNUSED(event) )
863 switch( disc_type->GetSelection() )
866 psz_device = config_GetPsz( p_intf, "vcd" );
867 disc_device->SetValue( psz_device ? wxU(psz_device) : wxT("") );
871 psz_device = config_GetPsz( p_intf, "dvd" );
872 disc_device->SetValue( psz_device ? wxU(psz_device) : wxT("") );
876 if( psz_device ) free( psz_device );
878 switch( disc_type->GetSelection() )
881 disc_title->SetRange( 0, 255 );
882 disc_title->SetValue( 0 );
887 disc_title->SetRange( 1, 255 );
888 disc_title->SetValue( 1 );
894 disc_chapter->SetRange( 1, 255 );
895 disc_chapter->SetValue( 1 );
897 UpdateMRL( DISC_ACCESS );
900 /*****************************************************************************
901 * Net panel event methods.
902 *****************************************************************************/
903 void OpenDialog::OnNetPanelChange( wxCommandEvent& event )
905 if( event.GetId() >= NetPort1_Event && event.GetId() <= NetPort3_Event )
907 i_net_ports[event.GetId() - NetPort1_Event] = event.GetInt();
910 UpdateMRL( NET_ACCESS );
913 void OpenDialog::OnNetTypeChange( wxCommandEvent& event )
917 i_net_type = event.GetId() - NetRadio1_Event;
921 net_radios[i]->SetValue( event.GetId() == (NetRadio1_Event+i) );
922 net_subpanels[i]->Enable( event.GetId() == (NetRadio1_Event+i) );
925 UpdateMRL( NET_ACCESS );
929 /*****************************************************************************
930 * v4l panel event methods.
931 *****************************************************************************/
932 void OpenDialog::OnV4LPanelChange( wxCommandEvent& WXUNUSED(event) )
934 UpdateMRL( V4L_ACCESS );
937 void OpenDialog::OnV4LTypeChange( wxCommandEvent& WXUNUSED(event) )
939 video_device->SetValue( wxU( "/dev/video" ) );
941 v4l_button->Enable();
942 video_channel->Disable();
944 switch( video_type->GetSelection() )
947 video_channel->Enable();
948 video_channel->SetRange( 0, 255 );
949 video_channel->SetValue( 0 );
952 v4l_button->Disable();
958 UpdateMRL( V4L_ACCESS );
961 void OpenDialog::OnV4LSettingsChange( wxCommandEvent& WXUNUSED(event) )
963 /* Show/hide the open dialog */
964 if( v4l_dialog == NULL )
965 v4l_dialog = new V4LDialog( p_intf, this );
967 if( v4l_dialog && v4l_dialog->ShowModal() == wxID_OK )
969 v4l_mrl = v4l_dialog->GetOptions();
972 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;