1 /*****************************************************************************
2 * wizard.cpp : wxWindows plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000-2005 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
27 #include "dialogs/wizard.hpp"
28 #include "streamdata.h"
29 #include "dialogs/open.hpp"
31 #include <wx/listctrl.h>
32 #include <wx/statline.h>
33 #include <vlc_network.h>
34 #include <vlc_charset.h>
39 /*****************************************************************************
41 *****************************************************************************/
44 ActionRadio0_Event, ActionRadio1_Event,
45 MoreInfoStreaming_Event,
46 MoreInfoTranscode_Event,
48 Open_Event , Choose_Event ,
50 InputRadio0_Event, InputRadio1_Event,
53 MethodRadio0_Event, MethodRadio1_Event,
54 MethodRadio2_Event, MethodRadio3_Event,
56 EncapRadio0_Event, EncapRadio1_Event,
57 EncapRadio2_Event, EncapRadio3_Event,
58 EncapRadio4_Event, EncapRadio5_Event,
59 EncapRadio6_Event, EncapRadio7_Event,
60 EncapRadio8_Event, EncapRadio9_Event,
61 EncapRadio10_Event, EncapRadio11_Event,
63 VideoEnable_Event, VideoCodec_Event,VideoBitrate_Event,
64 AudioEnable_Event, AudioCodec_Event,AudioBitrate_Event,
71 #define ACTION_STREAM 0
72 #define ACTION_TRANSCODE 1
74 BEGIN_EVENT_TABLE(WizardDialog, wxWizard)
77 /*****************************************************************************
79 *****************************************************************************/
81 #define ERROR_MSG _("Error")
82 #define ITEM_NAME _("Streaming/Transcoding Wizard")
85 #define HELLO_TITLE _("Streaming/Transcoding Wizard")
86 #define HELLO_TEXT _("This wizard helps you to stream, transcode or" \
88 #define HELLO_STREAMING _("Stream to network")
89 #define HELLO_STREAMING_DESC _("Use this to stream on a network.")
90 #define HELLO_TRANSCODE _("Transcode/Save to file")
91 #define HELLO_TRANSCODE_DESC _("Use this to re-encode a stream and save it "\
93 #define HELLO_NOTICE _("This wizard only contains a small subset " \
94 "of VLC's streaming and transcoding capabilities. Use the Open "\
95 "and Stream Output dialogs to access all of them.")
97 #define MOREINFO_STREAM _("Use this to stream on a network")
99 #define MOREINFO_TRANSCODE _("Saves the stream to a file. The stream must " \
100 "be a format that VLC recognizes. If desired, the stream can also " \
101 "be transcoded to another format.\n\nPlease note that VLC is not very" \
102 " suited for file-to-file transcoding. Its transcoding " \
103 "features are more appropriate for saving network streams." )
106 #define INPUT_TITLE _("Input")
107 #define INPUT_TEXT _("Input stream")
109 #define INPUT_OPEN _("Select a stream" )
110 #define INPUT_PL _( "Existing playlist item" )
112 #define CHOOSE_STREAM _("You must choose a stream")
113 #define NO_PLAYLIST _("Unable to find playlist")
115 #define PARTIAL _("Use this to read only a part of the stream. " \
116 "To use, enter the starting and ending times (in seconds)." \
117 "\n\nNote: You must be able to control the incoming stream " \
118 "(for example, a file or a disc, but not a RTP/UDP " \
119 "network stream).\n" \
122 #define INPUT_BUTTON _("Choose")
125 #define TRANSCODE1_TITLE _("Transcode")
126 #define TRANSCODE1_TEXT _("Changes the compression format " \
127 "of the audio or video tracks. To change only the " \
128 "container format, proceed to the next page.")
130 #define TR_VIDEO_TEXT0 _("Transcode video (if available)" )
131 #define TR_VIDEO_TEXT _("Select the target video codec. Choose a codec to " \
132 "display more information about it.")
134 #define TR_AUDIO_TEXT0 _("Transcode audio (if available)"
135 #define TR_AUDIO_TEXT _("Select the target audio codec. Choose a codec to " \
136 "display more information about it.")
139 #define STREAMING1_TITLE _("Streaming")
140 #define STREAMING1_TEXT _("Determines how the input stream will be sent.")
143 #define INVALID_MCAST_ADDRESS _("This does not appear to be a valid " \
144 "multicast address" )
145 #define NO_ADDRESS_TEXT _("Please enter an address" )
148 #define ENCAP_TITLE _("Encapsulation format")
149 #define ENCAP_TEXT _("Determines how the stream will be encapsulated. " \
150 "Depending on the previous choices, some formats " \
151 "might not be available." )
155 #define EXTRATRANSCODE_TITLE _("Additional transcode options")
156 #define EXTRATRANSCODE_TEXT _("Defines a few additional parameters " \
157 "for the transcoding." )
159 #define CHOOSE_OUTFILE _("You must choose a file to save to")
162 #define EXTRASTREAMING_TITLE _("Additional streaming options")
163 #define EXTRASTREAMING_TEXT _("Defines a few additional parameters " \
166 #define TTL _("Define the TTL (Time-To-Live) of the stream. This parameter " \
167 "is the maximum number of routers your stream can go through. " \
168 "If you don't know what it means, or if you want to stream on " \
169 "your local network only, leave this setting to 1." )
171 #define SAP _("When streaming using RTP, you can announce your streams " \
172 "using the SAP/SDP announcing protocol. This way, the clients " \
173 "won't have to type in the multicast address, it will appear " \
174 "in their playlist if they enable the SAP extra interface.\n" \
175 "If you want to give a name to your stream, enter it here. " \
176 "Otherwise, a default name will be used." )
178 /*****************************************************************************
179 * All the pages of the wizard, declaration
180 *****************************************************************************/
182 /* Declare classes */
183 class wizHelloPage : public wxWizardPageSimple
186 wizHelloPage( wxWizard *parent);
187 void OnActionChange( wxCommandEvent& event );
188 void OnWizardPageChanging(wxWizardEvent& event);
189 void OnMoreInfo( wxCommandEvent& event );
192 WizardDialog *p_parent;
193 wxRadioButton *action_radios[2];
194 DECLARE_EVENT_TABLE()
197 BEGIN_EVENT_TABLE(wizHelloPage, wxWizardPageSimple)
198 EVT_RADIOBUTTON( ActionRadio0_Event, wizHelloPage::OnActionChange)
199 EVT_RADIOBUTTON( ActionRadio1_Event, wizHelloPage::OnActionChange)
200 EVT_BUTTON( MoreInfoStreaming_Event, wizHelloPage::OnMoreInfo )
201 EVT_BUTTON( MoreInfoTranscode_Event, wizHelloPage::OnMoreInfo )
203 EVT_WIZARD_PAGE_CHANGING(-1, wizHelloPage::OnWizardPageChanging)
207 class wizInputPage : public wxWizardPage
210 wizInputPage( wxWizard *, wxWizardPage *, intf_thread_t *);
212 void OnWizardPageChanging(wxWizardEvent& event);
213 void OnInputChange( wxCommandEvent& event );
214 void OnEnablePartial(wxCommandEvent& event);
215 virtual wxWizardPage *GetPrev() const;
216 virtual wxWizardPage *GetNext() const;
217 void SetStreamingPage( wxWizardPage *page);
218 void SetTranscodePage( wxWizardPage *page);
219 void SetAction( int i_action );
220 void SetPintf( intf_thread_t *p_intf );
221 void SetUri( char *psz_uri );
222 void SetPartial( int i_from, int i_to );
226 intf_thread_t *p_intf;
230 void OnChoose( wxCommandEvent& event );
232 WizardDialog *p_parent;
233 wxRadioButton *input_radios[2];
234 wxCheckBox *enable_checkbox;
235 wxBoxSizer *mainSizer;
237 wxTextCtrl *mrl_text;
238 wxTextCtrl *from_text;
240 OpenDialog *p_open_dialog;
241 wxListView *listview;
243 wxPanel *radio_panel; /* radio buttons should be in their own panel... */
244 wxWizardPage *p_prev;
245 wxWizardPage *p_streaming_page;
246 wxWizardPage *p_transcode_page;
248 DECLARE_EVENT_TABLE()
251 BEGIN_EVENT_TABLE(wizInputPage, wxWizardPage)
252 EVT_RADIOBUTTON( InputRadio0_Event, wizInputPage::OnInputChange)
253 EVT_RADIOBUTTON( InputRadio1_Event, wizInputPage::OnInputChange)
254 EVT_BUTTON( Choose_Event, wizInputPage::OnChoose)
255 EVT_CHECKBOX( PartialEnable_Event, wizInputPage::OnEnablePartial)
256 EVT_WIZARD_PAGE_CHANGING(-1, wizInputPage::OnWizardPageChanging)
260 class wizTranscodeCodecPage : public wxWizardPage
263 wizTranscodeCodecPage( wxWizard *parent, wxWizardPage *next);
264 ~wizTranscodeCodecPage();
265 void OnWizardPageChanging(wxWizardEvent& event);
266 virtual wxWizardPage *GetPrev() const;
267 virtual wxWizardPage *GetNext() const;
268 void SetPrev( wxWizardPage *page);
270 wxCheckBox *video_checkbox;
271 wxComboBox *video_combo;
272 wxComboBox *vb_combo;
273 wxStaticText * video_text;
274 wxCheckBox *audio_checkbox;
275 wxComboBox *audio_combo;
276 wxComboBox *ab_combo;
277 wxStaticText * audio_text;
279 WizardDialog *p_parent;
286 wxWizardPage *p_prev;
287 wxWizardPage *p_next;
289 void OnVideoCodecChange(wxCommandEvent& event);
290 void OnAudioCodecChange(wxCommandEvent& event);
291 void OnEnableVideo(wxCommandEvent& event);
292 void OnEnableAudio(wxCommandEvent& event);
294 DECLARE_EVENT_TABLE()
297 BEGIN_EVENT_TABLE(wizTranscodeCodecPage, wxWizardPage)
298 EVT_CHECKBOX( VideoEnable_Event, wizTranscodeCodecPage::OnEnableVideo)
299 EVT_CHECKBOX( AudioEnable_Event, wizTranscodeCodecPage::OnEnableAudio)
300 EVT_COMBOBOX( VideoCodec_Event, wizTranscodeCodecPage::OnVideoCodecChange)
301 EVT_COMBOBOX( AudioCodec_Event, wizTranscodeCodecPage::OnAudioCodecChange)
302 EVT_WIZARD_PAGE_CHANGING(-1, wizTranscodeCodecPage::OnWizardPageChanging)
305 class wizStreamingMethodPage : public wxWizardPage
308 wizStreamingMethodPage( intf_thread_t *p_this, wxWizard *parent,
309 wxWizardPage *next) ;
310 void OnWizardPageChanging(wxWizardEvent& event);
311 virtual wxWizardPage *GetPrev() const;
312 virtual wxWizardPage *GetNext() const;
313 void SetPrev( wxWizardPage *page);
315 DECLARE_EVENT_TABLE()
317 wxBoxSizer *mainSizer;
318 wxStaticBoxSizer *address_sizer;
319 wxStaticText *address_text;
320 wxTextCtrl *address_txtctrl;
321 WizardDialog * p_parent;
322 void OnMethodChange( wxCommandEvent& event );
323 wxRadioButton *method_radios[4];
324 wxWizardPage *p_prev;
325 wxWizardPage *p_next;
326 intf_thread_t *p_intf;
329 BEGIN_EVENT_TABLE(wizStreamingMethodPage, wxWizardPage)
330 EVT_RADIOBUTTON( MethodRadio0_Event, wizStreamingMethodPage::OnMethodChange)
331 EVT_RADIOBUTTON( MethodRadio1_Event, wizStreamingMethodPage::OnMethodChange)
332 EVT_RADIOBUTTON( MethodRadio2_Event, wizStreamingMethodPage::OnMethodChange)
333 EVT_RADIOBUTTON( MethodRadio3_Event, wizStreamingMethodPage::OnMethodChange)
334 EVT_WIZARD_PAGE_CHANGING(-1, wizStreamingMethodPage::OnWizardPageChanging)
338 class wizEncapPage : public wxWizardPage
341 wizEncapPage( wxWizard *parent);
343 void OnWizardPageChanging(wxWizardEvent& event);
344 virtual wxWizardPage *GetPrev() const;
345 virtual wxWizardPage *GetNext() const;
346 void SetStreamingPage( wxWizardPage *page);
347 void SetTranscodePage( wxWizardPage *page);
348 void SetPrev( wxWizardPage *page);
349 void SetAction( int );
350 void EnableEncap( int encap );
352 DECLARE_EVENT_TABLE()
356 void OnEncapChange( wxCommandEvent& event );
357 wxRadioButton *encap_radios[MUXERS_NUMBER];
358 WizardDialog *p_parent;
359 wxWizardPage *p_prev;
360 wxWizardPage *p_streaming_page;
361 wxWizardPage *p_transcode_page;
364 BEGIN_EVENT_TABLE(wizEncapPage, wxWizardPage)
365 EVT_WIZARD_PAGE_CHANGING(-1, wizEncapPage::OnWizardPageChanging)
366 EVT_RADIOBUTTON( EncapRadio0_Event, wizEncapPage::OnEncapChange)
367 EVT_RADIOBUTTON( EncapRadio1_Event, wizEncapPage::OnEncapChange)
368 EVT_RADIOBUTTON( EncapRadio2_Event, wizEncapPage::OnEncapChange)
369 EVT_RADIOBUTTON( EncapRadio3_Event, wizEncapPage::OnEncapChange)
370 EVT_RADIOBUTTON( EncapRadio4_Event, wizEncapPage::OnEncapChange)
371 EVT_RADIOBUTTON( EncapRadio5_Event, wizEncapPage::OnEncapChange)
372 EVT_RADIOBUTTON( EncapRadio6_Event, wizEncapPage::OnEncapChange)
373 EVT_RADIOBUTTON( EncapRadio7_Event, wizEncapPage::OnEncapChange)
374 EVT_RADIOBUTTON( EncapRadio8_Event, wizEncapPage::OnEncapChange)
375 EVT_RADIOBUTTON( EncapRadio9_Event, wizEncapPage::OnEncapChange)
376 EVT_RADIOBUTTON( EncapRadio10_Event, wizEncapPage::OnEncapChange)
379 /* Additional settings for transcode */
380 class wizTranscodeExtraPage : public wxWizardPage
383 wizTranscodeExtraPage( wxWizard *parent, wxWizardPage *prev,
385 virtual wxWizardPage *GetPrev() const;
386 virtual wxWizardPage *GetNext() const;
387 void OnWizardPageChanging( wxWizardEvent& event );
389 DECLARE_EVENT_TABLE()
390 void OnSelectFile(wxCommandEvent&);
391 wxTextCtrl *file_text;
392 WizardDialog *p_parent;
393 wxWizardPage *p_prev;
394 wxWizardPage *p_next;
397 BEGIN_EVENT_TABLE(wizTranscodeExtraPage, wxWizardPage)
398 EVT_BUTTON( Open_Event, wizTranscodeExtraPage::OnSelectFile)
399 EVT_WIZARD_PAGE_CHANGING(-1, wizTranscodeExtraPage::OnWizardPageChanging)
402 /* Additional settings for streaming */
403 class wizStreamingExtraPage : public wxWizardPage
406 wizStreamingExtraPage( wxWizard *parent, wxWizardPage *prev,
408 virtual wxWizardPage *GetPrev() const;
409 virtual wxWizardPage *GetNext() const;
410 void OnWizardPageChanging(wxWizardEvent&);
411 void OnSAP( wxCommandEvent&);
412 wxCheckBox *sap_checkbox;
413 wxTextCtrl *sap_text;
415 friend class wizEncapPage;
416 DECLARE_EVENT_TABLE()
417 WizardDialog *p_parent;
418 wxWizardPage *p_prev;
419 wxWizardPage *p_next;
421 wxSpinCtrl *ttl_spin;
424 BEGIN_EVENT_TABLE(wizStreamingExtraPage, wxWizardPage)
425 EVT_CHECKBOX( SAP_Event, wizStreamingExtraPage::OnSAP )
426 EVT_WIZARD_PAGE_CHANGING(-1, wizStreamingExtraPage::OnWizardPageChanging)
430 /* Local functions */
431 static void pageHeader( wxWindow *window, wxBoxSizer *sizer,
432 char *psz_title, char *psz_text);
434 static void pageHeader( wxWindow *window, wxBoxSizer *sizer,
435 char *psz_title, char *psz_text)
437 wxStaticText *wtitle = new wxStaticText( window, -1, wxU( psz_title ) );
438 wxFont font = wtitle->GetFont();
439 font.SetPointSize(14);
440 wtitle->SetFont(font);
441 sizer->Add( wtitle, 0, wxALL, 5 );
442 sizer->Add( new wxStaticText( window, -1,
443 wxU( vlc_wraptext( psz_text , TEXTWIDTH ) ) ),
447 /***************************************************************************
448 * Implementation of the pages
449 ***************************************************************************/
452 /***************************************************
453 * First page: choose between stream and transcode *
454 ***************************************************/
455 wizHelloPage::wizHelloPage( wxWizard *parent) : wxWizardPageSimple(parent)
458 p_parent = (WizardDialog *)parent;
459 wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
461 /* Create the texts */
462 pageHeader( this, mainSizer, HELLO_TITLE, HELLO_TEXT );
464 /* Create the radio buttons with their helps */
465 action_radios[0] = new wxRadioButton( this, ActionRadio0_Event,
466 wxU( HELLO_STREAMING ) );
467 action_radios[1] = new wxRadioButton( this, ActionRadio1_Event,
468 wxU( HELLO_TRANSCODE ) );
471 mainSizer->Add( 0, 0, 1 );
473 wxBoxSizer *stream_sizer = new wxBoxSizer( wxHORIZONTAL );
474 stream_sizer->Add( action_radios[0], 0, wxALL, 5 );
475 stream_sizer->Add( 0,0,1 );
476 stream_sizer->Add( new wxButton( this, MoreInfoStreaming_Event,
477 wxU( _("More Info")) ), 0, 0, 0 );
478 mainSizer->Add( stream_sizer, 0, wxALL | wxEXPAND , 5 );
480 wxBoxSizer *transcode_sizer = new wxBoxSizer( wxHORIZONTAL );
481 transcode_sizer->Add( action_radios[1], 0, wxALL, 5 );
482 transcode_sizer->Add( 0,0,1);
483 transcode_sizer->Add( new wxButton( this, MoreInfoTranscode_Event,
484 wxU( _("More Info")) ), 0 , 0 , 0 );
485 mainSizer->Add( transcode_sizer, 0, wxALL | wxEXPAND, 5 );
487 mainSizer->Add( 0, 0, 1 );
489 mainSizer->Add( new wxStaticLine(this, -1 ), 0, wxEXPAND| wxTOP|
492 mainSizer->Add( new wxStaticText(this, -1,
493 wxU( vlc_wraptext(HELLO_NOTICE , TEXTWIDTH ))),
497 mainSizer->Fit(this);
500 void wizHelloPage::OnMoreInfo(wxCommandEvent& event)
503 msg.Printf( wxString( wxU( event.GetId() == MoreInfoStreaming_Event ?
505 MOREINFO_TRANSCODE ) ) );
506 wxMessageBox( msg, wxU(_("More information")),
507 wxOK | wxICON_INFORMATION, this->p_parent );
510 void wizHelloPage::OnActionChange( wxCommandEvent& event )
512 i_action = event.GetId() - ActionRadio0_Event;
513 ((wizInputPage *)GetNext())->SetAction( i_action );
514 p_parent->SetAction( i_action );
517 void wizHelloPage::OnWizardPageChanging(wxWizardEvent& event)
519 ((wizInputPage *)GetNext())->SetAction( i_action );
520 p_parent->SetAction( i_action );
523 /************************************
524 * Second page: choose input stream *
525 ************************************/
526 wizInputPage::wizInputPage( wxWizard *parent, wxWizardPage *prev, intf_thread_t *_p_intf) :
531 p_parent = (WizardDialog *)parent;
533 p_open_dialog = NULL;
536 mainSizer = new wxBoxSizer(wxVERTICAL);
538 /* Create the texts */
539 pageHeader( this, mainSizer, INPUT_TITLE, INPUT_TEXT );
541 mainSizer->Add( 0,20,0 );
543 radio_panel = new wxPanel(this, -1);
544 radio_panel->SetAutoLayout( TRUE );
546 wxBoxSizer *radioSizer = new wxBoxSizer(wxVERTICAL);
548 /* Create the radio buttons */
549 input_radios[0] = new wxRadioButton( radio_panel, InputRadio0_Event ,
551 radioSizer->Add( input_radios[0], 0, wxALL, 5 );
552 input_radios[1] = new wxRadioButton( radio_panel, InputRadio1_Event ,
554 radioSizer->Add( input_radios[1], 0, wxALL, 5 );
556 radio_panel->SetSizer( radioSizer );
557 radioSizer->Layout();
558 radioSizer->Fit(radio_panel);
559 mainSizer->Add( radio_panel );
564 open_panel = new wxPanel(this, -1);
565 open_panel->SetAutoLayout( TRUE );
567 wxBoxSizer *openSizer = new wxBoxSizer(wxHORIZONTAL);
569 mrl_text = new wxTextCtrl( open_panel, -1, wxU( "" ), wxDefaultPosition,
572 openSizer->Add( mrl_text, 0 , wxALL, 5 );
573 openSizer->Add( new wxButton( open_panel, Choose_Event, wxU(_("Choose...")) ), 0, wxALL, 5 );
575 open_panel->SetSizer( openSizer );
577 openSizer->Fit(open_panel);
578 mainSizer->Add( open_panel );
580 playlist_t *p_playlist = pl_Hold( p_intf );
583 if( !playlist_IsEmpty( p_playlist ) )
585 listview = new wxListView( this, ListView_Event,
586 wxDefaultPosition, wxDefaultSize,
587 wxLC_REPORT | wxSUNKEN_BORDER );
588 listview->InsertColumn( 0, wxU(_("Name")) );
589 listview->InsertColumn( 1, wxU(_("URI")) );
590 listview->SetColumnWidth( 0, 250 );
591 listview->SetColumnWidth( 1, 100 );
592 mainSizer->Add( listview, 1, wxALL|wxEXPAND, 5 );
595 mainSizer->Hide( listview );
600 input_radios[1]->Disable();
602 pl_Release( p_intf );
606 input_radios[1]->Disable();
609 /* Partial Extract Box */
610 mainSizer->Add( 0, 10, 0 );
611 wxStaticBox *partial_box = new wxStaticBox( this, -1,
612 wxU(_("Partial Extract")) );
614 wxStaticBoxSizer *partial_sizer = new wxStaticBoxSizer( partial_box,
617 enable_checkbox = new wxCheckBox( this, PartialEnable_Event,
619 enable_checkbox->SetToolTip(wxU(_(PARTIAL) ) ) ;
620 partial_sizer->Add( enable_checkbox, 0 , wxALIGN_CENTER_VERTICAL|wxALL, 5 ); //wxLEFT
622 wxFlexGridSizer *partial_sizer2 = new wxFlexGridSizer( 4 , 1 , 20 );
623 partial_sizer2->Add( new wxStaticText(this, -1, wxU(_( "From" ) ) ),
625 from_text = new wxTextCtrl( this, -1, wxT(""),
626 wxDefaultPosition, wxSize( 80,25 ) );
627 partial_sizer2->Add( from_text, 0 , wxALIGN_RIGHT);
628 partial_sizer2->Add( new wxStaticText(this, -1, wxU(_( "To" ) ) ),
630 to_text = new wxTextCtrl( this, -1, wxT(""),
631 wxDefaultPosition, wxSize( 80 , 25 ) );
632 partial_sizer2->Add( to_text, 0 , wxALIGN_RIGHT );
634 partial_sizer->Add( partial_sizer2, 0, wxALL, 0 );
636 partial_sizer->Fit( partial_box );
638 mainSizer->Add( partial_sizer, 0, 0, 0 );
640 from_text->Disable();
643 mainSizer->Fit(this);
647 wizInputPage::~wizInputPage()
651 void wizInputPage::OnInputChange( wxCommandEvent& event )
653 i_input = event.GetId() - InputRadio0_Event;
659 mainSizer->Hide( listview );
661 mainSizer->Show( open_panel );
668 mainSizer->Hide( open_panel );
670 mainSizer->Show( listview );
675 void wizInputPage::OnEnablePartial(wxCommandEvent& event)
677 from_text->Enable( event.IsChecked() );
678 to_text->Enable( event.IsChecked() );
682 void wizInputPage::OnChoose(wxCommandEvent& event)
684 p_open_dialog = new OpenDialog( p_intf, this, -1, -1, OPEN_STREAM );
685 if( p_open_dialog->ShowModal() == wxID_OK &&
686 !p_open_dialog->mrl.IsEmpty() )
688 mrl_text->SetValue(p_open_dialog->mrl[0] );
690 delete p_open_dialog;
691 p_open_dialog = NULL;
694 void wizInputPage::OnWizardPageChanging(wxWizardEvent& event)
698 if( mrl_text->GetValue().IsSameAs( wxT(""), TRUE ) &&
699 event.GetDirection() )
701 wxMessageBox( wxU( CHOOSE_STREAM ), wxU( ERROR_MSG ),
702 wxICON_WARNING | wxOK, this->p_parent );
708 p_parent->SetMrl( (const char *)mrl_text->GetValue().mb_str(wxConvUTF8) );
714 i = listview->GetNextItem( i , wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
717 long data = listview->GetItemData( i );
718 playlist_t *p_playlist = pl_Hold( p_intf );
721 playlist_item_t * p_item = playlist_ItemGetById( p_playlist, (int)data, false );
724 const char *psz_uri = input_item_GetURI( p_item->p_input );
725 p_parent->SetMrl( psz_uri );
730 pl_Release( p_intf );
736 if( enable_checkbox->IsChecked() )
738 int i_from = atoi( from_text->GetValue().mb_str(wxConvUTF8) );
739 int i_to = atoi( to_text->GetValue().mb_str(wxConvUTF8) );
740 p_parent->SetPartial( i_from, i_to );
745 wxWizardPage *wizInputPage::GetPrev() const { return p_prev; }
746 wxWizardPage *wizInputPage::GetNext() const
748 if( i_action == ACTION_STREAM )
749 return p_streaming_page;
751 return p_transcode_page;
754 void wizInputPage::SetStreamingPage( wxWizardPage *page)
756 p_streaming_page = page;
759 void wizInputPage::SetTranscodePage( wxWizardPage *page)
761 p_transcode_page = page;
764 void wizInputPage::SetAction( int i_action )
766 this->i_action = i_action;
769 void wizInputPage::SetPintf( intf_thread_t *p_intf )
771 this->p_intf = p_intf;
774 void wizInputPage::SetUri( char *psz_uri )
776 mrl_text->SetValue( wxU( psz_uri ) );
779 void wizInputPage::SetPartial( int i_from, int i_to )
782 msg.Printf( wxString( wxT( "%i") ), i_from );
783 from_text->Enable( TRUE );
784 from_text->SetValue( msg );
785 msg.Printf( wxString( wxT( "%i") ), i_to );
786 to_text->Enable( TRUE );
787 to_text->SetValue( msg );
788 enable_checkbox->SetValue( TRUE );
791 /***************************************************
792 * First transcode page: choose codecs *
793 ***************************************************/
794 wizTranscodeCodecPage::wizTranscodeCodecPage( wxWizard *parent,
795 wxWizardPage *next) : wxWizardPage(parent)
803 p_parent = (WizardDialog *) parent;
805 wxBoxSizer *main_sizer = new wxBoxSizer(wxVERTICAL);
808 pageHeader( this, main_sizer, TRANSCODE1_TITLE, TRANSCODE1_TEXT );
811 wxStaticBox *video_box = new wxStaticBox( this, -1, wxU(_("Video")) );
812 wxStaticBoxSizer *video_sizer = new wxStaticBoxSizer( video_box,
814 /* Line 1 : only the checkbox */
815 wxFlexGridSizer *video_sizer1 = new wxFlexGridSizer( 2,3,20 );
816 video_sizer1->Add( new wxCheckBox( this, VideoEnable_Event,
817 wxU(_("Transcode video") ) ), 0 , wxALIGN_CENTER_VERTICAL|wxALL , 5 );
818 video_sizer1->Add( 0,0,1);
820 video_sizer1->Add( new wxStaticText(this, -1, wxU(_("Codec"))),0,wxLEFT ,5);
821 video_combo = new wxComboBox( this, VideoCodec_Event, wxT(""),
822 wxDefaultPosition, wxSize(200,25), 0, NULL,
823 wxCB_DROPDOWN| wxCB_READONLY );
824 for( i= 0; vcodecs_array[i].psz_display != NULL; i++ )
826 video_combo->Append( wxU( vcodecs_array[i].psz_display ) ,
827 (void *)&vcodecs_array[i] );
830 video_combo->SetSelection(0);
832 video_sizer1->Add( video_combo, 0 , wxALIGN_LEFT , 0 );
834 video_sizer1->Add( new wxStaticText(this, -1, wxU(_("Bitrate (kb/s)"))),0,
836 vb_combo = new wxComboBox( this, VideoBitrate_Event, wxT("1024"),
837 wxDefaultPosition, wxDefaultSize,
838 WXSIZEOF(vbitrates_array), vbitrates_array, wxCB_READONLY );
839 video_sizer1->Add( vb_combo, 0, wxALIGN_LEFT , 0 );
842 video_text = new wxStaticText( this, -1,
843 wxU( vlc_wraptext( TR_VIDEO_TEXT, TEXTWIDTH ) ) );
844 /* Fill the main video sizer */
845 video_sizer->Add( video_sizer1 , 0, wxEXPAND , 5 );
846 video_sizer->Add( video_text, 0, wxLEFT|wxTOP , 5 );
850 wxStaticBox *audio_box = new wxStaticBox( this, -1, wxU(_("Audio")) );
851 wxStaticBoxSizer *audio_sizer = new wxStaticBoxSizer( audio_box,
854 wxFlexGridSizer *audio_sizer1 = new wxFlexGridSizer( 2,3,20);
855 audio_sizer1->Add( new wxCheckBox( this, AudioEnable_Event,
856 wxU(_("Transcode audio") ) ), 0 , wxALIGN_CENTER_VERTICAL|wxALL, 5 );
857 audio_sizer1->Add( 0, 0, 1 );
860 audio_sizer1->Add( new wxStaticText(this, -1, wxU(_("Codec"))),0,wxLEFT,5);
861 audio_combo = new wxComboBox( this, AudioCodec_Event, wxT(""),
862 wxDefaultPosition, wxSize(200,25), 0, NULL,
863 wxCB_DROPDOWN| wxCB_READONLY );
864 for( i= 0; acodecs_array[i].psz_display != NULL; i++ )
866 audio_combo->Append( wxU( acodecs_array[i].psz_display ) ,
867 (void *)&acodecs_array[i] );
870 audio_combo->SetSelection(0);
871 audio_sizer1->Add( audio_combo, 0 , wxALIGN_LEFT, 0 );
873 audio_sizer1->Add( new wxStaticText(this, -1, wxU(_("Bitrate (kb/s)"))),0,
875 ab_combo = new wxComboBox( this, AudioBitrate_Event, wxT("192"),
876 wxDefaultPosition, wxDefaultSize,
877 WXSIZEOF(abitrates_array), abitrates_array, wxCB_READONLY );
878 audio_sizer1->Add( ab_combo, 0, wxALIGN_LEFT, 0 );
881 audio_text = new wxStaticText( this, -1,
882 wxU( vlc_wraptext( TR_AUDIO_TEXT, TEXTWIDTH ) ) );
884 audio_sizer->Add(audio_sizer1, 0, wxEXPAND, 5);
885 audio_sizer->Add( audio_text, 0, wxLEFT | wxTOP, 5 );
887 main_sizer->Add( video_sizer, 1, wxGROW, 0 );
888 main_sizer->Add( audio_sizer, 1, wxGROW, 0 );
889 main_sizer->Layout();
890 SetSizerAndFit( main_sizer );
892 /* Default disabled */
893 video_combo->Disable(); video_text->Disable();vb_combo->Disable();
894 audio_combo->Disable(); audio_text->Disable();ab_combo->Disable();
898 wizTranscodeCodecPage::~wizTranscodeCodecPage()
904 void wizTranscodeCodecPage::OnEnableVideo(wxCommandEvent& event)
906 video_combo->Enable( event.IsChecked() );
907 vb_combo->Enable( event.IsChecked() );
908 video_text->Enable( event.IsChecked() );
911 void wizTranscodeCodecPage::OnEnableAudio(wxCommandEvent& event)
913 audio_combo->Enable( event.IsChecked() );
914 ab_combo->Enable( event.IsChecked() );
915 audio_text->Enable( event.IsChecked() );
918 void wizTranscodeCodecPage::OnVideoCodecChange(wxCommandEvent& event)
920 struct codec *c = (struct codec*)
921 (video_combo->GetClientData(video_combo->GetSelection()));
922 video_text->SetLabel( wxU( vlc_wraptext(c->psz_descr, TEXTWIDTH ) ) );
923 i_video_codec = video_combo->GetSelection();
924 vcodec = strdup(c->psz_codec);
927 void wizTranscodeCodecPage::OnAudioCodecChange(wxCommandEvent& event)
929 struct codec *c = (struct codec*)
930 (audio_combo->GetClientData(audio_combo->GetSelection()));
931 audio_text->SetLabel( wxU( vlc_wraptext(c->psz_descr, TEXTWIDTH ) ) );
932 i_audio_codec = audio_combo->GetSelection();
933 acodec = strdup(c->psz_codec);
937 void wizTranscodeCodecPage::OnWizardPageChanging(wxWizardEvent& event)
941 if( !event.GetDirection() )
947 /* Set the dummy codec ( accept all muxers ) if needed */
948 if( !video_combo->IsEnabled() )
950 i_video_codec = VCODECS_NUMBER;
952 if( !audio_combo->IsEnabled() )
954 i_audio_codec = ACODECS_NUMBER;
957 ((wizEncapPage *)GetNext())->SetPrev(this);
959 for( i = 0 ; i< MUXERS_NUMBER ; i++ )
961 if( vcodecs_array[i_video_codec].muxers[i] != -1 )
963 for( j = 0 ; j< MUXERS_NUMBER ; j++ )
965 if( acodecs_array[i_audio_codec].muxers[j] ==
966 vcodecs_array[i_video_codec].muxers[i] )
968 ((wizEncapPage*)GetNext())->EnableEncap(
969 vcodecs_array[i_video_codec].muxers[i] );
974 struct codec *c = (struct codec*)
975 (video_combo->GetClientData( video_combo->IsEnabled() ?
976 video_combo->GetSelection(): i_video_codec ));
977 vcodec = strdup(c->psz_codec);
979 (audio_combo->GetClientData( audio_combo->IsEnabled() ?
980 audio_combo->GetSelection() : i_audio_codec ));
981 acodec = strdup(c->psz_codec);
983 int vb = atoi(vb_combo->GetValue().mb_str(wxConvUTF8) );
988 int ab = atoi(ab_combo->GetValue().mb_str(wxConvUTF8) );
994 p_parent->SetTranscode( vcodec, vb , acodec, ab );
995 ((wizEncapPage*)GetNext())->SetAction( p_parent->GetAction() );
996 p_parent->SetAction( p_parent->GetAction() );
1001 wxWizardPage *wizTranscodeCodecPage::GetPrev() const { return p_prev; }
1002 wxWizardPage *wizTranscodeCodecPage::GetNext() const { return p_next; }
1003 void wizTranscodeCodecPage::SetPrev( wxWizardPage *page) {p_prev = page; }
1006 /***************************************************
1007 * First streaming page: choose method *
1008 ***************************************************/
1009 wizStreamingMethodPage::wizStreamingMethodPage( intf_thread_t *p_this, wxWizard *parent,
1010 wxWizardPage *next) : wxWizardPage(parent), p_intf( p_this )
1014 p_parent = (WizardDialog *)parent;
1016 mainSizer = new wxBoxSizer(wxVERTICAL);
1018 /* Create the texts */
1019 pageHeader( this, mainSizer, STREAMING1_TITLE, STREAMING1_TEXT );
1021 mainSizer->Add( 0,50,0 );
1025 wxStaticBox *method_box = new wxStaticBox( this, -1,
1026 wxU(_("Streaming method")) );
1027 wxStaticBoxSizer *method_sizer = new wxStaticBoxSizer(method_box,
1029 for( i = 0 ; i< 3 ; i++ )
1031 method_radios[i] = new wxRadioButton( this, MethodRadio0_Event + i,
1032 wxU( methods_array[i].psz_method ) );
1033 method_radios[i]->SetToolTip( wxU(_( methods_array[i].psz_descr ) ) );
1034 method_sizer->Add( method_radios[i], 0, wxALL, 5 );
1037 method_sizer->Layout();
1039 wxStaticBox *address_box = new wxStaticBox( this, -1,
1040 wxU(_("Destination")) );
1042 address_sizer = new wxStaticBoxSizer(address_box,
1045 /* Big kludge, we take the longest text to get the size */
1046 address_text = new wxStaticText(this, -1,
1047 wxU( vlc_wraptext(methods_array[2].psz_address, TEXTWIDTH ) ),
1048 wxDefaultPosition, wxDefaultSize );
1050 address_txtctrl = new wxTextCtrl( this, -1, wxU(""), wxDefaultPosition,
1052 address_sizer->Add( address_text, 0, wxALL, 5 );
1053 address_sizer->Add( address_txtctrl, 0, wxALL, 5 );
1054 address_sizer->Layout();
1056 /* Set the minimum size */
1057 address_sizer->SetMinSize( address_sizer->GetSize() );
1058 address_text->SetLabel( wxU(
1059 vlc_wraptext( _(methods_array[0].psz_address), TEXTWIDTH )));
1061 mainSizer->Add( method_sizer, 0, wxALL | wxEXPAND, 5 );
1062 mainSizer->Add( address_sizer, 0, wxALL | wxEXPAND, 5 );
1064 mainSizer->Add( 0,0,1 );
1066 mainSizer->Layout();
1068 SetSizer(mainSizer);
1069 mainSizer->Fit(this);
1074 void wizStreamingMethodPage::OnWizardPageChanging(wxWizardEvent& event)
1077 if( !event.GetDirection() ) return;
1079 /* Check valid address */
1080 if( i_method == 0 && address_txtctrl->GetValue().IsEmpty() )
1082 wxMessageBox( wxU( NO_ADDRESS_TEXT ) , wxU( ERROR_MSG ),
1083 wxICON_WARNING | wxOK, this->p_parent );
1088 ((wizEncapPage *)GetNext())->SetPrev(this);
1089 for( i = 0 ; i< MUXERS_NUMBER ; i++ )
1091 if( methods_array[i_method].muxers[i] != -1 )
1093 ((wizEncapPage*)GetNext())->EnableEncap(
1094 methods_array[i_method].muxers[i] );
1097 p_parent->SetStream( methods_array[i_method].psz_access ,
1098 address_txtctrl->GetValue().mb_str(wxConvUTF8) );
1100 /* Set the action for the muxer page */
1101 ((wizEncapPage*)GetNext())->SetAction( p_parent->GetAction() );
1105 wxWizardPage *wizStreamingMethodPage::GetPrev() const { return p_prev; }
1106 wxWizardPage *wizStreamingMethodPage::GetNext() const { return p_next; }
1108 void wizStreamingMethodPage::SetPrev( wxWizardPage *page) {p_prev = page; }
1111 void wizStreamingMethodPage::OnMethodChange( wxCommandEvent& event )
1113 i_method = event.GetId() - MethodRadio0_Event;
1114 address_text->SetLabel( wxU(
1115 vlc_wraptext( _(methods_array[i_method].psz_address), TEXTWIDTH )));
1116 address_sizer->Layout();
1117 mainSizer->Layout();
1120 /***************************************************
1121 * Choose encapsulation format *
1122 ***************************************************/
1123 wizEncapPage::wizEncapPage( wxWizard *parent ) : wxWizardPage(parent)
1127 p_parent = (WizardDialog *)parent;
1128 p_streaming_page = NULL;
1129 p_transcode_page = NULL;
1131 wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
1133 /* Create the texts */
1134 pageHeader( this, mainSizer, ENCAP_TITLE, ENCAP_TEXT );
1136 mainSizer->Add( 0,0,1 );
1138 for( i = 0 ; i< MUXERS_NUMBER ; i++ )
1140 encap_radios[i] = new wxRadioButton( this, EncapRadio0_Event + i,
1141 wxU( encaps_array[i].psz_encap ) );
1142 encap_radios[i]->SetToolTip( wxU(_( encaps_array[i].psz_descr ) ) );
1143 mainSizer->Add( encap_radios[i], 0, wxLEFT, 5 );
1144 encap_radios[i]->Disable();
1147 mainSizer->Add( 0,0,1 );
1149 SetSizer(mainSizer);
1150 mainSizer->Fit(this);
1153 wizEncapPage::~wizEncapPage()
1157 void wizEncapPage::OnWizardPageChanging(wxWizardEvent& event)
1160 if( !event.GetDirection() )
1162 for( i = 0 ; i< MUXERS_NUMBER ; i++ )
1164 encap_radios[i]->Disable();
1167 p_parent->SetMux( encaps_array[i_mux].psz_mux );
1169 if( p_parent->GetAction() == ACTION_STREAM )
1171 if( strstr( p_parent->method, "rtp" ))
1173 ((wizStreamingExtraPage *)GetNext())->sap_checkbox->Enable();
1174 ((wizStreamingExtraPage *)GetNext())->sap_text->Enable(false);
1178 ((wizStreamingExtraPage *)GetNext())->sap_checkbox->Enable( false );
1179 ((wizStreamingExtraPage *)GetNext())->sap_text->Enable( false );
1187 void wizEncapPage::OnEncapChange( wxCommandEvent& event )
1189 i_mux = event.GetId() - EncapRadio0_Event;
1192 void wizEncapPage::EnableEncap( int encap )
1195 for( i = 0 ; i< MUXERS_NUMBER ; i++)
1197 if( encaps_array[i].id == encap )
1199 encap_radios[i]->Enable();
1200 encap_radios[i]->SetValue(true);
1206 void wizEncapPage::SetStreamingPage( wxWizardPage *page)
1208 p_streaming_page = page;
1211 void wizEncapPage::SetTranscodePage( wxWizardPage *page)
1213 p_transcode_page = page;
1216 wxWizardPage *wizEncapPage::GetPrev() const { return p_prev; }
1218 wxWizardPage *wizEncapPage::GetNext() const
1220 if( i_action== ACTION_STREAM )
1221 return p_streaming_page;
1223 return p_transcode_page;
1226 void wizEncapPage::SetAction( int i_act ) { i_action = i_act; }
1228 void wizEncapPage::SetPrev( wxWizardPage *page) { p_prev = page; }
1230 /***************************************************
1231 * Extra transcoding page : Select file *
1232 ***************************************************/
1233 wizTranscodeExtraPage::wizTranscodeExtraPage( wxWizard *parent,
1235 wxWizardPage *next) : wxWizardPage(parent)
1239 p_parent = (WizardDialog *) parent;
1240 wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
1242 /* Create the texts */
1243 pageHeader( this, mainSizer, EXTRATRANSCODE_TITLE, EXTRATRANSCODE_TEXT );
1245 mainSizer->Add( 0, 0, 1 );
1247 wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 2, 1 );
1248 sizer->Add( new wxStaticText( this, -1,
1249 wxU(_("Select the file to save to") ) ),
1251 sizer->Add( 0, 0, 1 );
1253 file_text = new wxTextCtrl( this, -1, wxU(""), wxDefaultPosition,
1254 wxSize( 150, -1 ) );
1256 sizer->Add( file_text, 0, wxALL, 5 );
1257 sizer->Add( new wxButton( this, Open_Event, wxU("Choose") ) );
1259 mainSizer->Add( sizer, 0, 0, 0) ;
1261 mainSizer->Add( 0, 0, 1 );
1262 SetSizer(mainSizer);
1263 mainSizer->Fit(this);
1266 void wizTranscodeExtraPage::OnSelectFile( wxCommandEvent &event)
1268 wxFileDialog *file_dialog = new wxFileDialog( this, wxU(_("Save to file")),
1269 wxT(""), wxT(""), wxT("*"), wxSAVE );
1271 if( file_dialog && file_dialog->ShowModal() == wxID_OK )
1273 if( file_dialog->GetFilename().mb_str(wxConvUTF8) )
1275 file_text->SetValue( file_dialog->GetPath() );
1280 void wizTranscodeExtraPage::OnWizardPageChanging( wxWizardEvent& event )
1282 if( event.GetDirection() && file_text->GetValue().IsEmpty() )
1284 wxMessageBox( wxU( CHOOSE_OUTFILE ), wxU( ERROR_MSG ),
1285 wxICON_WARNING | wxOK, this->p_parent );
1288 if( event.GetDirection() )
1290 p_parent->SetTranscodeOut( file_text->GetValue() );
1294 wxWizardPage *wizTranscodeExtraPage::GetPrev() const { return p_prev; }
1295 wxWizardPage *wizTranscodeExtraPage::GetNext() const {return p_next; }
1297 /***********************************************************
1298 * Extra streaming page
1299 ***********************************************************/
1300 wizStreamingExtraPage::wizStreamingExtraPage( wxWizard *parent,
1302 wxWizardPage *next) : wxWizardPage(parent)
1306 p_parent = (WizardDialog *) parent;
1307 wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
1309 /* Create the texts */
1310 pageHeader( this, mainSizer, EXTRASTREAMING_TITLE, EXTRASTREAMING_TEXT );
1312 mainSizer->Add( 0, 0, 1 );
1314 wxFlexGridSizer *sizer = new wxFlexGridSizer( 2,2,1) ;
1317 sizer->Add( new wxStaticText( this, -1, wxU(_("Time-To-Live (TTL)"))),
1319 ttl_spin = new wxSpinCtrl( this, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize,
1321 ttl_spin->SetToolTip(wxU(_(TTL) ) ) ;
1322 sizer->Add( ttl_spin, 0, wxALL , 5 );
1325 sap_checkbox = new wxCheckBox( this, SAP_Event, wxU(_("SAP Announce")) );
1326 sap_checkbox->SetToolTip( wxU(_( SAP ) ) );
1327 sizer->Add( sap_checkbox, 0, 0 , 0 );
1328 sap_text = new wxTextCtrl( this, -1, wxU(""), wxDefaultPosition,
1330 sap_text->SetToolTip( wxU(_( SAP ) ) );
1331 sizer->Add( sap_text, 0, wxALL , 5 );
1333 mainSizer->Add(sizer, 0, wxALL, 5 );
1335 mainSizer->Add( 0, 0, 1 );
1337 SetSizer(mainSizer);
1338 mainSizer->Fit(this);
1341 void wizStreamingExtraPage::OnSAP( wxCommandEvent &event )
1343 sap_text->Enable( event.IsChecked() );
1346 void wizStreamingExtraPage::OnWizardPageChanging(wxWizardEvent& event)
1348 if( sap_checkbox->IsChecked() )
1350 if( sap_text->GetValue().IsEmpty() )
1352 p_parent->SetSAP( true, NULL );
1356 p_parent->SetSAP( true,
1357 (const char *)sap_text->GetValue().mb_str(wxConvUTF8) );
1362 p_parent->SetSAP( false, NULL );
1365 p_parent->SetTTL( ttl_spin->GetValue() );
1368 wxWizardPage *wizStreamingExtraPage::GetPrev() const { return p_prev; }
1369 wxWizardPage *wizStreamingExtraPage::GetNext() const {return p_next; }
1372 /***************************************************************************
1373 * Implementation of the wizard itself
1374 ***************************************************************************/
1375 wizHelloPage *page1;
1376 wizInputPage *page2 ;
1377 wizTranscodeCodecPage *tr_page1 ;
1378 wizStreamingMethodPage *st_page1;
1379 wizTranscodeExtraPage *tr_page2 ;
1380 wizStreamingExtraPage *st_page2;
1381 wizEncapPage *encap_page;
1383 WizardDialog::WizardDialog(intf_thread_t *_p_intf, wxWindow *_p_parent,
1384 char *psz_uri, int _i_from, int _i_to ) :
1385 wxWizard( _p_parent, -1, wxU(_("Streaming/Transcoding Wizard")), wxNullBitmap, wxDefaultPosition)
1387 /* Initializations */
1389 SetPageSize(wxSize(400,420));
1391 /* Initialize structure */
1401 page1 = new wizHelloPage(this);
1402 page2 = new wizInputPage(this, page1, p_intf);
1406 page2->SetUri( psz_uri );
1408 if( i_from != 0 || i_to != 0 )
1410 page2->SetPartial( i_from, i_to );
1413 encap_page = new wizEncapPage(this );
1414 tr_page1 = new wizTranscodeCodecPage(this, encap_page );
1415 st_page1 = new wizStreamingMethodPage( p_intf, this, encap_page);
1417 tr_page2 = new wizTranscodeExtraPage(this, encap_page, NULL );
1418 st_page2 = new wizStreamingExtraPage(this, encap_page, NULL );
1421 page1->SetNext( page2 );
1422 /* 2->1 in constructor of 2 */
1425 page2->SetTranscodePage(tr_page1);
1426 page2->SetStreamingPage(st_page1);
1427 page2->SetPintf( p_intf );
1428 tr_page1->SetPrev(page2);
1429 st_page1->SetPrev(page2);
1432 encap_page->SetTranscodePage( tr_page2 );
1433 encap_page->SetStreamingPage( st_page2 );
1434 /* 3->4 in constructor of 3 */
1435 // encap_page->SetPrev(tr_page1);
1438 WizardDialog::~WizardDialog()
1450 void WizardDialog::SetMrl( const char *mrl )
1452 this->mrl = strdup( mrl );
1455 void WizardDialog::SetTTL( int i_ttl )
1457 this->i_ttl = i_ttl;
1460 void WizardDialog::SetSAP( bool b_enabled, const char *psz_text )
1462 this->b_sap = b_enabled;
1465 if( psz_text != NULL )
1467 this->psz_sap_name = strdup( psz_text );
1471 this->psz_sap_name = NULL;
1476 void WizardDialog::SetPartial( int i_from, int i_to )
1478 this->i_from = i_from;
1482 void WizardDialog::SetTranscode( char const *vcodec, int vb,
1483 char const *acodec, int ab)
1485 if( strcmp( vcodec, "dummy") )
1487 this->vcodec= strdup(vcodec);
1489 if( strcmp( acodec, "dummy" ) )
1491 this->acodec = strdup(acodec);
1497 void WizardDialog::SetStream( char const *method, char const *address )
1499 this->method = strdup( method );
1500 this->address = strdup( address );
1503 void WizardDialog::SetTranscodeOut( wxString address )
1505 char *psz_utf8 = wxFromLocale( address );
1506 this->address = strdup( psz_utf8 );
1507 wxLocaleFree( psz_utf8 );
1510 void WizardDialog::SetMux( char const *mux )
1512 this->mux = strdup( mux );
1515 void WizardDialog::SetAction( int i_action )
1517 this->i_action = i_action;
1520 int WizardDialog::GetAction()
1525 void WizardDialog::Run()
1527 if( RunWizard(page1) )
1531 if( i_action == ACTION_TRANSCODE )
1533 msg_Dbg( p_intf,"starting transcode of %s to file %s",
1535 msg_Dbg( p_intf,"using %s (%i kbps) / %s (%i kbps),encap %s",
1536 vcodec,vb,acodec,ab,mux);
1537 char *psz_transcode;
1539 if( vcodec != NULL || acodec != NULL )
1542 if( vcodec != NULL )
1543 i_tr_size += strlen( vcodec ) + 17;
1544 if( acodec != NULL )
1545 i_tr_size += strlen( acodec ) + 17;
1557 psz_transcode = (char *)malloc( i_tr_size * sizeof(char) );
1559 strcpy( psz_transcode, "transcode{" );
1560 if( vcodec != NULL )
1562 sprintf( psz_transcode + strlen( psz_transcode ),
1563 "vcodec=%s,vb=%i%s", vcodec, vb,
1564 ( acodec != NULL ) ? "," : "}:" );
1566 if( acodec != NULL )
1568 sprintf( psz_transcode + strlen( psz_transcode ),
1569 "acodec=%s,ab=%i}:", acodec, ab );
1575 asprintf( &psz_opt, ":sout=#%sstandard{mux=%s,dst=%s,"
1576 "access=file}", psz_transcode, mux, address );
1578 if( *psz_transcode )
1579 free( psz_transcode );
1583 char *psz_sap_option = NULL;
1586 msg_Dbg( p_intf, "starting stream of %s to %s using %s, encap %s",
1587 mrl, address, method, mux );
1592 asprintf( &psz_sap_option,
1593 ",sap,name=\"%s\"", psz_sap_name );
1596 psz_sap_option = strdup( ",sap" );
1600 /* Add brackets automatically for IPv6 if they are missing */
1601 v6 = ( address[0] != '[' ) && ( strchr( address, ':' ) != NULL );
1603 ":sout=#%smux=%s,dst=%s%s%s%s}", method,
1604 mux, v6 ? "[" : "", address, v6 ? "]" : "",
1605 psz_sap_option ?: "" );
1606 free( psz_sap_option );
1609 playlist_t *p_playlist = pl_Hold( p_intf );
1612 input_item_t *p_input = input_item_New( p_playlist, mrl,
1614 input_item_AddOption( p_input, psz_opt );
1618 snprintf( psz_from, 20, "start-time=%i", i_from);
1619 input_item_AddOption( p_input, psz_from );
1624 snprintf( psz_to, 20, "stop-time=%i", i_to);
1625 input_item_AddOption( p_input, psz_to );
1629 snprintf( psz_ttl, 20, "ttl=%i",i_ttl );
1630 input_item_AddOption( p_input, psz_ttl );
1632 /* FIXME: playlist_AddInput() can fail */
1633 playlist_AddInput( p_playlist, p_input,
1634 PLAYLIST_GO, PLAYLIST_END, true, pl_Unlocked );
1635 vlc_gc_decref( p_input );
1636 pl_Release( p_intf );
1640 wxMessageBox( wxU( NO_PLAYLIST ), wxU( ERROR_MSG ),
1641 wxICON_WARNING | wxOK, this );