1 /*****************************************************************************
2 * wizard.cpp : wxWindows plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000-2004 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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
27 #include "dialogs/wizard.hpp"
28 #include "streamdata.h"
29 #include "dialogs/open.hpp"
31 #include <wx/statline.h>
37 /*****************************************************************************
39 *****************************************************************************/
42 ActionRadio0_Event, ActionRadio1_Event,
43 MoreInfoStreaming_Event,
44 MoreInfoTranscode_Event,
46 Open_Event , Choose_Event ,
48 InputRadio0_Event, InputRadio1_Event,
51 MethodRadio0_Event, MethodRadio1_Event,
52 MethodRadio2_Event, MethodRadio3_Event,
54 EncapRadio0_Event, EncapRadio1_Event,
55 EncapRadio2_Event, EncapRadio3_Event,
56 EncapRadio4_Event, EncapRadio5_Event,
57 EncapRadio6_Event, EncapRadio7_Event,
58 EncapRadio8_Event, EncapRadio9_Event,
59 EncapRadio10_Event, EncapRadio11_Event,
61 VideoEnable_Event, VideoCodec_Event,VideoBitrate_Event,
62 AudioEnable_Event, AudioCodec_Event,AudioBitrate_Event,
69 #define ACTION_STREAM 0
70 #define ACTION_TRANSCODE 1
72 BEGIN_EVENT_TABLE(WizardDialog, wxWizard)
75 /*****************************************************************************
77 *****************************************************************************/
79 #define ERROR_MSG _("Error")
80 #define ITEM_NAME _("Streaming/Transcoding Wizard")
83 #define HELLO_TITLE _("Streaming/Transcoding Wizard")
84 #define HELLO_TEXT _("This wizard helps you to stream, transcode or" \
86 #define HELLO_STREAMING _("Stream to network")
87 #define HELLO_STREAMING_DESC _("Use this to stream on a network.")
88 #define HELLO_TRANSCODE _("Transcode/Save to file")
89 #define HELLO_TRANSCODE_DESC _("Use this to re-encode a stream and save it to a file.")
90 #define HELLO_NOTICE _("This wizard only gives access to a small subset of VLC's streaming and transcoding capabilities. Use the Open and Stream Output dialogs to get all of them.")
92 #define MOREINFO_STREAM _("Use this to stream on a network")
94 #define MOREINFO_TRANSCODE _("Use this to save a stream to a file. You have the possibility to reencode the stream. You can save whatever VLC can read.\nPlease notice that VLC is not very suited " \
95 "for file to file transcoding. You should use its transcoding " \
96 "features to save network streams, for example." )
99 #define INPUT_TITLE _("Choose input")
100 #define INPUT_TEXT _("Choose here your input stream.")
102 #define INPUT_OPEN _("Select a stream" )
103 #define INPUT_PL _( "Existing playlist item" )
105 #define CHOOSE_STREAM _("You must choose a stream")
106 #define NO_PLAYLIST _("Uh Oh! Unable to find playlist !")
108 #define PARTIAL _("Use this to read only a part of the stream. " \
109 "You must be able to control the incoming stream " \
110 "(for example, a file or a disc, but not a RTP/UDP " \
111 "network stream.)\n" \
112 "Enter the starting and ending times (in seconds).")
114 #define INPUT_BUTTON _("Choose")
117 #define TRANSCODE1_TITLE _("Transcode")
118 #define TRANSCODE1_TEXT _("If you want to change the compression format of the audio or video tracks, fill in this page. (If you only want to change the container format, proceed to next page.)")
120 #define TR_VIDEO_TEXT0 _("If your stream has video and you want to " \
121 "transcode it, enable this.")
122 #define TR_VIDEO_TEXT _("Select your video codec. Click one to get more " \
125 #define TR_AUDIO_TEXT0 _("If your stream has audio and you want to "\
126 "transcode it, enable this.")
127 #define TR_AUDIO_TEXT _("Select your audio codec. Click one to get more " \
131 #define STREAMING1_TITLE _("Streaming")
132 #define STREAMING1_TEXT _("In this page, you will select how your input stream will be sent.")
135 #define INVALID_MCAST_ADDRESS _("This does not appear to be a valid " \
136 "multicast address" )
137 #define NO_ADDRESS_TEXT _("You need to enter an address" )
140 #define ENCAP_TITLE _("Encapsulation format")
141 #define ENCAP_TEXT _("In this page, you will select how the stream will be "\
142 "encapsulated. Depending on the choices you made, all "\
143 "formats won't be available." )
147 #define EXTRATRANSCODE_TITLE _("Additional transcode options")
148 #define EXTRATRANSCODE_TEXT _("In this page, you will define a few " \
149 "additionnal parameters for your transcoding" )
151 #define CHOOSE_OUTFILE _("You must choose a file to save to")
154 #define EXTRASTREAMING_TITLE _("Additional streaming options")
155 #define EXTRASTREAMING_TEXT _("In this page, you will define a few " \
156 "additionnal parameters for your stream" )
158 #define TTL _("Define the TTL (Time-To-Live) of the stream. This parameter " \
159 "is the maximum number of routers your stream can go through. " \
160 "If you don't know what it means, or if you want to stream on " \
161 "your local network only, leave this setting to 1." )
163 #define SAP _("When streaming using RTP, you can announce your streams " \
164 "using the SAP/SDP announcing protocol. This way, the clients " \
165 "won't have to type in the multicast address, it will appear " \
166 "in their playlist if they enable the SAP extra interface.\n" \
167 "If you want to give a name to your stream, enter it here, " \
168 "else, a default name will be used" )
170 /*****************************************************************************
171 * All the pages of the wizard, declaration
172 *****************************************************************************/
174 /* Declare classes */
175 class wizHelloPage : public wxWizardPageSimple
178 wizHelloPage( wxWizard *parent);
179 void OnActionChange( wxCommandEvent& event );
180 void OnWizardPageChanging(wxWizardEvent& event);
181 void OnMoreInfo( wxCommandEvent& event );
184 WizardDialog *p_parent;
185 wxRadioButton *action_radios[2];
186 DECLARE_EVENT_TABLE()
189 BEGIN_EVENT_TABLE(wizHelloPage, wxWizardPageSimple)
190 EVT_RADIOBUTTON( ActionRadio0_Event, wizHelloPage::OnActionChange)
191 EVT_RADIOBUTTON( ActionRadio1_Event, wizHelloPage::OnActionChange)
192 EVT_BUTTON( MoreInfoStreaming_Event, wizHelloPage::OnMoreInfo )
193 EVT_BUTTON( MoreInfoTranscode_Event, wizHelloPage::OnMoreInfo )
195 EVT_WIZARD_PAGE_CHANGING(-1, wizHelloPage::OnWizardPageChanging)
199 class wizInputPage : public wxWizardPage
202 wizInputPage( wxWizard *, wxWizardPage *, intf_thread_t *);
203 wizInputPage::~wizInputPage();
204 void OnWizardPageChanging(wxWizardEvent& event);
205 void OnInputChange( wxCommandEvent& event );
206 void OnEnablePartial(wxCommandEvent& event);
207 virtual wxWizardPage *GetPrev() const;
208 virtual wxWizardPage *GetNext() const;
209 void SetStreamingPage( wxWizardPage *page);
210 void SetTranscodePage( wxWizardPage *page);
211 void SetAction( int i_action );
212 void SetPintf( intf_thread_t *p_intf );
213 void SetUri( char *psz_uri );
214 void SetPartial( int i_from, int i_to );
218 intf_thread_t *p_intf;
222 void OnChoose( wxCommandEvent& event );
224 WizardDialog *p_parent;
225 wxRadioButton *input_radios[2];
226 wxCheckBox *enable_checkbox;
227 wxBoxSizer *mainSizer;
229 wxTextCtrl *mrl_text;
230 wxTextCtrl *from_text;
232 OpenDialog *p_open_dialog;
233 wxListView *listview;
235 wxPanel *radio_panel; /* radio buttons should be in their own panel... */
236 wxWizardPage *p_prev;
237 wxWizardPage *p_streaming_page;
238 wxWizardPage *p_transcode_page;
240 DECLARE_EVENT_TABLE()
243 BEGIN_EVENT_TABLE(wizInputPage, wxWizardPage)
244 EVT_RADIOBUTTON( InputRadio0_Event, wizInputPage::OnInputChange)
245 EVT_RADIOBUTTON( InputRadio1_Event, wizInputPage::OnInputChange)
246 EVT_BUTTON( Choose_Event, wizInputPage::OnChoose)
247 EVT_CHECKBOX( PartialEnable_Event, wizInputPage::OnEnablePartial)
248 EVT_WIZARD_PAGE_CHANGING(-1, wizInputPage::OnWizardPageChanging)
252 class wizTranscodeCodecPage : public wxWizardPage
255 wizTranscodeCodecPage( wxWizard *parent, wxWizardPage *next);
256 ~wizTranscodeCodecPage();
257 void wizTranscodeCodecPage::OnWizardPageChanging(wxWizardEvent& event);
258 virtual wxWizardPage *GetPrev() const;
259 virtual wxWizardPage *GetNext() const;
260 void SetPrev( wxWizardPage *page);
262 wxCheckBox *video_checkbox;
263 wxComboBox *video_combo;
264 wxComboBox *vb_combo;
265 wxStaticText * video_text;
266 wxCheckBox *audio_checkbox;
267 wxComboBox *audio_combo;
268 wxComboBox *ab_combo;
269 wxStaticText * audio_text;
271 WizardDialog *p_parent;
278 wxWizardPage *p_prev;
279 wxWizardPage *p_next;
281 void OnVideoCodecChange(wxCommandEvent& event);
282 void OnAudioCodecChange(wxCommandEvent& event);
283 void OnEnableVideo(wxCommandEvent& event);
284 void OnEnableAudio(wxCommandEvent& event);
286 DECLARE_EVENT_TABLE()
289 BEGIN_EVENT_TABLE(wizTranscodeCodecPage, wxWizardPage)
290 EVT_CHECKBOX( VideoEnable_Event, wizTranscodeCodecPage::OnEnableVideo)
291 EVT_CHECKBOX( AudioEnable_Event, wizTranscodeCodecPage::OnEnableAudio)
292 EVT_COMBOBOX( VideoCodec_Event, wizTranscodeCodecPage::OnVideoCodecChange)
293 EVT_COMBOBOX( AudioCodec_Event, wizTranscodeCodecPage::OnAudioCodecChange)
294 EVT_WIZARD_PAGE_CHANGING(-1, wizTranscodeCodecPage::OnWizardPageChanging)
297 class wizStreamingMethodPage : public wxWizardPage
300 wizStreamingMethodPage( intf_thread_t *p_this, wxWizard *parent,
301 wxWizardPage *next) ;
302 void OnWizardPageChanging(wxWizardEvent& event);
303 virtual wxWizardPage *GetPrev() const;
304 virtual wxWizardPage *GetNext() const;
305 void SetPrev( wxWizardPage *page);
307 DECLARE_EVENT_TABLE()
309 wxBoxSizer *mainSizer;
310 wxStaticBoxSizer *address_sizer;
311 wxStaticText *address_text;
312 wxTextCtrl *address_txtctrl;
313 WizardDialog * p_parent;
314 void OnMethodChange( wxCommandEvent& event );
315 wxRadioButton *method_radios[4];
316 wxWizardPage *p_prev;
317 wxWizardPage *p_next;
318 intf_thread_t *p_intf;
321 BEGIN_EVENT_TABLE(wizStreamingMethodPage, wxWizardPage)
322 EVT_RADIOBUTTON( MethodRadio0_Event, wizStreamingMethodPage::OnMethodChange)
323 EVT_RADIOBUTTON( MethodRadio1_Event, wizStreamingMethodPage::OnMethodChange)
324 EVT_RADIOBUTTON( MethodRadio2_Event, wizStreamingMethodPage::OnMethodChange)
325 EVT_RADIOBUTTON( MethodRadio3_Event, wizStreamingMethodPage::OnMethodChange)
326 EVT_WIZARD_PAGE_CHANGING(-1, wizStreamingMethodPage::OnWizardPageChanging)
330 class wizEncapPage : public wxWizardPage
333 wizEncapPage( wxWizard *parent);
334 wizEncapPage::~wizEncapPage();
335 void OnWizardPageChanging(wxWizardEvent& event);
336 virtual wxWizardPage *GetPrev() const;
337 virtual wxWizardPage *GetNext() const;
338 void SetStreamingPage( wxWizardPage *page);
339 void SetTranscodePage( wxWizardPage *page);
340 void SetPrev( wxWizardPage *page);
341 void SetAction( int );
342 void EnableEncap( int encap );
344 DECLARE_EVENT_TABLE()
348 void OnEncapChange( wxCommandEvent& event );
349 wxRadioButton *encap_radios[MUXERS_NUMBER];
350 WizardDialog *p_parent;
351 wxWizardPage *p_prev;
352 wxWizardPage *p_streaming_page;
353 wxWizardPage *p_transcode_page;
356 BEGIN_EVENT_TABLE(wizEncapPage, wxWizardPage)
357 EVT_WIZARD_PAGE_CHANGING(-1, wizEncapPage::OnWizardPageChanging)
358 EVT_RADIOBUTTON( EncapRadio0_Event, wizEncapPage::OnEncapChange)
359 EVT_RADIOBUTTON( EncapRadio1_Event, wizEncapPage::OnEncapChange)
360 EVT_RADIOBUTTON( EncapRadio2_Event, wizEncapPage::OnEncapChange)
361 EVT_RADIOBUTTON( EncapRadio3_Event, wizEncapPage::OnEncapChange)
362 EVT_RADIOBUTTON( EncapRadio4_Event, wizEncapPage::OnEncapChange)
363 EVT_RADIOBUTTON( EncapRadio5_Event, wizEncapPage::OnEncapChange)
364 EVT_RADIOBUTTON( EncapRadio6_Event, wizEncapPage::OnEncapChange)
365 EVT_RADIOBUTTON( EncapRadio7_Event, wizEncapPage::OnEncapChange)
366 EVT_RADIOBUTTON( EncapRadio8_Event, wizEncapPage::OnEncapChange)
367 EVT_RADIOBUTTON( EncapRadio9_Event, wizEncapPage::OnEncapChange)
368 EVT_RADIOBUTTON( EncapRadio10_Event, wizEncapPage::OnEncapChange)
371 /* Additional settings for transcode */
372 class wizTranscodeExtraPage : public wxWizardPage
375 wizTranscodeExtraPage( wxWizard *parent, wxWizardPage *prev,
377 virtual wxWizardPage *GetPrev() const;
378 virtual wxWizardPage *GetNext() const;
379 void OnWizardPageChanging( wxWizardEvent& event );
381 DECLARE_EVENT_TABLE()
382 void wizTranscodeExtraPage::OnSelectFile(wxCommandEvent&);
383 wxTextCtrl *file_text;
384 WizardDialog *p_parent;
385 wxWizardPage *p_prev;
386 wxWizardPage *p_next;
389 BEGIN_EVENT_TABLE(wizTranscodeExtraPage, wxWizardPage)
390 EVT_BUTTON( Open_Event, wizTranscodeExtraPage::OnSelectFile)
391 EVT_WIZARD_PAGE_CHANGING(-1, wizTranscodeExtraPage::OnWizardPageChanging)
394 /* Additional settings for streaming */
395 class wizStreamingExtraPage : public wxWizardPage
398 wizStreamingExtraPage( wxWizard *parent, wxWizardPage *prev,
400 virtual wxWizardPage *GetPrev() const;
401 virtual wxWizardPage *GetNext() const;
402 void OnWizardPageChanging(wxWizardEvent&);
403 void OnSAP( wxCommandEvent&);
404 wxCheckBox *sap_checkbox;
405 wxTextCtrl *sap_text;
407 friend class wizEncapPage;
408 DECLARE_EVENT_TABLE()
409 WizardDialog *p_parent;
410 wxWizardPage *p_prev;
411 wxWizardPage *p_next;
413 wxSpinCtrl *ttl_spin;
416 BEGIN_EVENT_TABLE(wizStreamingExtraPage, wxWizardPage)
417 EVT_CHECKBOX( SAP_Event, wizStreamingExtraPage::OnSAP )
418 EVT_WIZARD_PAGE_CHANGING(-1, wizStreamingExtraPage::OnWizardPageChanging)
422 /* Local functions */
423 static void pageHeader( wxWindow *window, wxBoxSizer *sizer,
424 char *psz_title, char *psz_text);
426 static void pageHeader( wxWindow *window, wxBoxSizer *sizer,
427 char *psz_title, char *psz_text)
429 wxStaticText *wtitle = new wxStaticText( window, -1, wxU( psz_title ) );
430 wxFont font = wtitle->GetFont();
431 font.SetPointSize(14);
432 wtitle->SetFont(font);
433 sizer->Add( wtitle, 0, wxALL, 5 );
434 sizer->Add( new wxStaticText( window, -1,
435 wxU( vlc_wraptext( psz_text , TEXTWIDTH, false ) ) ),
439 /***************************************************************************
440 * Implementation of the pages
441 ***************************************************************************/
444 /***************************************************
445 * First page: choose between stream and transcode *
446 ***************************************************/
447 wizHelloPage::wizHelloPage( wxWizard *parent) : wxWizardPageSimple(parent)
450 p_parent = (WizardDialog *)parent;
451 wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
453 /* Create the texts */
454 pageHeader( this, mainSizer, HELLO_TITLE, HELLO_TEXT );
456 /* Create the radio buttons with their helps */
457 action_radios[0] = new wxRadioButton( this, ActionRadio0_Event,
458 wxU( HELLO_STREAMING ) );
459 action_radios[1] = new wxRadioButton( this, ActionRadio1_Event,
460 wxU( HELLO_TRANSCODE ) );
463 mainSizer->Add( 0, 0, 1 );
465 wxBoxSizer *stream_sizer = new wxBoxSizer( wxHORIZONTAL );
466 stream_sizer->Add( action_radios[0], 0, wxALL, 5 );
467 stream_sizer->Add( 0,0,1 );
468 stream_sizer->Add( new wxButton( this, MoreInfoStreaming_Event,
469 wxU( _("More Info")) ), 0, 0, 0 );
470 mainSizer->Add( stream_sizer, 0, wxALL | wxEXPAND , 5 );
472 wxBoxSizer *transcode_sizer = new wxBoxSizer( wxHORIZONTAL );
473 transcode_sizer->Add( action_radios[1], 0, wxALL, 5 );
474 transcode_sizer->Add( 0,0,1);
475 transcode_sizer->Add( new wxButton( this, MoreInfoTranscode_Event,
476 wxU( _("More Info")) ), 0 , 0 , 0 );
477 mainSizer->Add( transcode_sizer, 0, wxALL | wxEXPAND, 5 );
479 mainSizer->Add( 0, 0, 1 );
481 mainSizer->Add( new wxStaticLine(this, -1 ), 0, wxEXPAND| wxTOP|
484 mainSizer->Add( new wxStaticText(this, -1,
485 wxU( vlc_wraptext(HELLO_NOTICE , TEXTWIDTH , false ))),
489 mainSizer->Fit(this);
492 void wizHelloPage::OnMoreInfo(wxCommandEvent& event)
495 msg.Printf( wxString( wxU( event.GetId() == MoreInfoStreaming_Event ?
497 MOREINFO_TRANSCODE ) ) );
498 wxMessageBox( msg, wxU(_("More information")),
499 wxOK | wxICON_INFORMATION, this->p_parent );
502 void wizHelloPage::OnActionChange( wxCommandEvent& event )
504 i_action = event.GetId() - ActionRadio0_Event;
505 ((wizInputPage *)GetNext())->SetAction( i_action );
506 p_parent->SetAction( i_action );
509 void wizHelloPage::OnWizardPageChanging(wxWizardEvent& event)
511 ((wizInputPage *)GetNext())->SetAction( i_action );
512 p_parent->SetAction( i_action );
515 /************************************
516 * Second page: choose input stream *
517 ************************************/
518 wizInputPage::wizInputPage( wxWizard *parent, wxWizardPage *prev, intf_thread_t *_p_intf) :
523 p_parent = (WizardDialog *)parent;
525 p_open_dialog = NULL;
528 mainSizer = new wxBoxSizer(wxVERTICAL);
530 /* Create the texts */
531 pageHeader( this, mainSizer, INPUT_TITLE, INPUT_TEXT );
533 mainSizer->Add( 0,20,0 );
535 radio_panel = new wxPanel(this, -1);
536 radio_panel->SetAutoLayout( TRUE );
538 wxBoxSizer *radioSizer = new wxBoxSizer(wxVERTICAL);
540 /* Create the radio buttons */
541 input_radios[0] = new wxRadioButton( radio_panel, InputRadio0_Event ,
543 radioSizer->Add( input_radios[0], 0, wxALL, 5 );
544 input_radios[1] = new wxRadioButton( radio_panel, InputRadio1_Event ,
546 radioSizer->Add( input_radios[1], 0, wxALL, 5 );
548 radio_panel->SetSizer( radioSizer );
549 radioSizer->Layout();
550 radioSizer->Fit(radio_panel);
551 mainSizer->Add( radio_panel );
556 open_panel = new wxPanel(this, -1);
557 open_panel->SetAutoLayout( TRUE );
559 wxBoxSizer *openSizer = new wxBoxSizer(wxHORIZONTAL);
561 mrl_text = new wxTextCtrl( open_panel, -1, wxU( "" ), wxDefaultPosition,
564 openSizer->Add( mrl_text, 0 , wxALL, 5 );
565 openSizer->Add( new wxButton( open_panel, Choose_Event, wxU(_("Choose...")) ), 0, wxALL, 5 );
567 open_panel->SetSizer( openSizer );
569 openSizer->Fit(open_panel);
570 mainSizer->Add( open_panel );
572 playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,
573 VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
577 if( p_playlist->i_size > 0)
579 listview = new wxListView( this, ListView_Event,
580 wxDefaultPosition, wxDefaultSize,
581 wxLC_REPORT | wxSUNKEN_BORDER );
582 listview->InsertColumn( 0, wxU(_("Name")) );
583 listview->InsertColumn( 1, wxU(_("URI")) );
584 listview->SetColumnWidth( 0, 250 );
585 listview->SetColumnWidth( 1, 100 );
586 for( int i=0 ; i < p_playlist->i_size ; i++ )
588 wxString filename = wxL2U( p_playlist->pp_items[i]->input.
590 listview->InsertItem( i, filename );
591 listview->SetItem( i, 1, wxL2U( p_playlist->pp_items[i]->
594 listview->Select( p_playlist->i_index , TRUE);
595 mainSizer->Add( listview, 1, wxALL|wxEXPAND, 5 );
598 mainSizer->Hide( listview );
603 input_radios[1]->Disable();
605 vlc_object_release( p_playlist );
609 input_radios[1]->Disable();
612 /* Partial Extract Box */
613 mainSizer->Add( 0, 10, 0 );
614 wxStaticBox *partial_box = new wxStaticBox( this, -1,
615 wxU(_("Partial Extract")) );
617 wxStaticBoxSizer *partial_sizer = new wxStaticBoxSizer( partial_box,
620 enable_checkbox = new wxCheckBox( this, PartialEnable_Event,
622 enable_checkbox->SetToolTip(wxU(_(PARTIAL) ) ) ;
623 partial_sizer->Add( enable_checkbox, 0 , wxALIGN_CENTER_VERTICAL|wxALL, 5 ); //wxLEFT
625 wxFlexGridSizer *partial_sizer2 = new wxFlexGridSizer( 4 , 1 , 20 );
626 partial_sizer2->Add( new wxStaticText(this, -1, wxU(_( "From" ) ) ),
628 from_text = new wxTextCtrl( this, -1, wxT(""),
629 wxDefaultPosition, wxSize( 80,25 ) );
630 partial_sizer2->Add( from_text, 0 , wxALIGN_RIGHT);
631 partial_sizer2->Add( new wxStaticText(this, -1, wxU(_( "To" ) ) ),
633 to_text = new wxTextCtrl( this, -1, wxT(""),
634 wxDefaultPosition, wxSize( 80 , 25 ) );
635 partial_sizer2->Add( to_text, 0 , wxALIGN_RIGHT );
637 partial_sizer->Add( partial_sizer2, 0, wxALL, 0 );
639 partial_sizer->Fit( partial_box );
641 mainSizer->Add( partial_sizer, 0, 0, 0 );
643 from_text->Disable();
646 mainSizer->Fit(this);
650 wizInputPage::~wizInputPage()
654 void wizInputPage::OnInputChange( wxCommandEvent& event )
656 i_input = event.GetId() - InputRadio0_Event;
662 mainSizer->Hide( listview );
664 mainSizer->Show( open_panel );
671 mainSizer->Hide( open_panel );
673 mainSizer->Show( listview );
678 void wizInputPage::OnEnablePartial(wxCommandEvent& event)
680 from_text->Enable( event.IsChecked() );
681 to_text->Enable( event.IsChecked() );
685 void wizInputPage::OnChoose(wxCommandEvent& event)
687 p_open_dialog = new OpenDialog( p_intf, this, -1, -1, OPEN_STREAM );
688 if( p_open_dialog->ShowModal() == wxID_OK &&
689 !p_open_dialog->mrl.IsEmpty() )
691 mrl_text->SetValue(p_open_dialog->mrl[0] );
693 delete p_open_dialog;
694 p_open_dialog = NULL;
697 void wizInputPage::OnWizardPageChanging(wxWizardEvent& event)
701 if( mrl_text->GetValue().IsSameAs( wxT(""), TRUE ) &&
702 event.GetDirection() )
704 wxMessageBox( wxU( CHOOSE_STREAM ), wxU( ERROR_MSG ),
705 wxICON_WARNING | wxOK, this->p_parent );
711 p_parent->SetMrl( (const char *)mrl_text->GetValue().mb_str() );
718 i = listview->GetNextItem( i , wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
722 listitem.SetColumn( 1 );
723 listview->GetItem( listitem );
724 p_parent->SetMrl( (const char*) listitem.GetText().mb_str() );
727 if( enable_checkbox->IsChecked() )
729 int i_from = atoi( from_text->GetValue().mb_str() );
730 int i_to = atoi( to_text->GetValue().mb_str() );
731 p_parent->SetPartial( i_from, i_to );
736 wxWizardPage *wizInputPage::GetPrev() const { return p_prev; }
737 wxWizardPage *wizInputPage::GetNext() const
739 if( i_action == ACTION_STREAM )
740 return p_streaming_page;
742 return p_transcode_page;
745 void wizInputPage::SetStreamingPage( wxWizardPage *page)
747 p_streaming_page = page;
750 void wizInputPage::SetTranscodePage( wxWizardPage *page)
752 p_transcode_page = page;
755 void wizInputPage::SetAction( int i_action )
757 this->i_action = i_action;
760 void wizInputPage::SetPintf( intf_thread_t *p_intf )
762 this->p_intf = p_intf;
765 void wizInputPage::SetUri( char *psz_uri )
767 mrl_text->SetValue( wxU( psz_uri ) );
770 void wizInputPage::SetPartial( int i_from, int i_to )
773 msg.Printf( wxString( wxT( "%i") ), i_from );
774 from_text->Enable( TRUE );
775 from_text->SetValue( msg );
776 msg.Printf( wxString( wxT( "%i") ), i_to );
777 to_text->Enable( TRUE );
778 to_text->SetValue( msg );
779 enable_checkbox->SetValue( TRUE );
782 /***************************************************
783 * First transcode page: choose codecs *
784 ***************************************************/
785 wizTranscodeCodecPage::wizTranscodeCodecPage( wxWizard *parent,
786 wxWizardPage *next) : wxWizardPage(parent)
794 p_parent = (WizardDialog *) parent;
796 wxBoxSizer *main_sizer = new wxBoxSizer(wxVERTICAL);
799 pageHeader( this, main_sizer, TRANSCODE1_TITLE, TRANSCODE1_TEXT );
802 wxStaticBox *video_box = new wxStaticBox( this, -1, wxU(_("Video")) );
803 wxStaticBoxSizer *video_sizer = new wxStaticBoxSizer( video_box,
805 /* Line 1 : only the checkbox */
806 wxFlexGridSizer *video_sizer1 = new wxFlexGridSizer( 2,3,20 );
807 video_sizer1->Add( new wxCheckBox( this, VideoEnable_Event,
808 wxU(_("Transcode video") ) ), 0 , wxALIGN_CENTER_VERTICAL|wxALL , 5 );
809 video_sizer1->Add( 0,0,1);
811 video_sizer1->Add( new wxStaticText(this, -1, wxU(_("Codec"))),0,wxLEFT ,5);
812 video_combo = new wxComboBox( this, VideoCodec_Event, wxT(""),
813 wxDefaultPosition, wxSize(200,25), 0, NULL,
814 wxCB_DROPDOWN| wxCB_READONLY );
815 for( i= 0; vcodecs_array[i].psz_display != NULL; i++ )
817 video_combo->Append( wxU( vcodecs_array[i].psz_display ) ,
818 (void *)&vcodecs_array[i] );
821 video_combo->SetSelection(0);
823 video_sizer1->Add( video_combo, 0 , wxALIGN_LEFT , 0 );
825 video_sizer1->Add( new wxStaticText(this, -1, wxU(_("Bitrate (kb/s)"))),0,
827 vb_combo = new wxComboBox( this, VideoBitrate_Event, wxT("1024"),
828 wxDefaultPosition, wxDefaultSize,
829 WXSIZEOF(vbitrates_array), vbitrates_array, wxCB_READONLY );
830 video_sizer1->Add( vb_combo, 0, wxALIGN_LEFT , 0 );
833 video_text = new wxStaticText( this, -1,
834 wxU( vlc_wraptext( TR_VIDEO_TEXT, TEXTWIDTH, false) ) );
835 /* Fill the main video sizer */
836 video_sizer->Add( video_sizer1 , 0, wxEXPAND , 5 );
837 video_sizer->Add( video_text, 0, wxLEFT|wxTOP , 5 );
841 wxStaticBox *audio_box = new wxStaticBox( this, -1, wxU(_("Audio")) );
842 wxStaticBoxSizer *audio_sizer = new wxStaticBoxSizer( audio_box,
845 wxFlexGridSizer *audio_sizer1 = new wxFlexGridSizer( 2,3,20);
846 audio_sizer1->Add( new wxCheckBox( this, AudioEnable_Event,
847 wxU(_("Transcode audio") ) ), 0 , wxALIGN_CENTER_VERTICAL|wxALL, 5 );
848 audio_sizer1->Add( 0, 0, 1 );
851 audio_sizer1->Add( new wxStaticText(this, -1, wxU(_("Codec"))),0,wxLEFT,5);
852 audio_combo = new wxComboBox( this, AudioCodec_Event, wxT(""),
853 wxDefaultPosition, wxSize(200,25), 0, NULL,
854 wxCB_DROPDOWN| wxCB_READONLY );
855 for( i= 0; acodecs_array[i].psz_display != NULL; i++ )
857 audio_combo->Append( wxU( acodecs_array[i].psz_display ) ,
858 (void *)&acodecs_array[i] );
861 audio_combo->SetSelection(0);
862 audio_sizer1->Add( audio_combo, 0 , wxALIGN_LEFT, 0 );
864 audio_sizer1->Add( new wxStaticText(this, -1, wxU(_("Bitrate (kb/s)"))),0,
866 ab_combo = new wxComboBox( this, AudioBitrate_Event, wxT("192"),
867 wxDefaultPosition, wxDefaultSize,
868 WXSIZEOF(abitrates_array), abitrates_array, wxCB_READONLY );
869 audio_sizer1->Add( ab_combo, 0, wxALIGN_LEFT, 0 );
872 audio_text = new wxStaticText( this, -1,
873 wxU( vlc_wraptext( TR_AUDIO_TEXT, TEXTWIDTH, false) ) );
875 audio_sizer->Add(audio_sizer1, 0, wxEXPAND, 5);
876 audio_sizer->Add( audio_text, 0, wxLEFT | wxTOP, 5 );
878 main_sizer->Add( video_sizer, 1, wxGROW, 0 );
879 main_sizer->Add( audio_sizer, 1, wxGROW, 0 );
880 main_sizer->Layout();
881 SetSizerAndFit( main_sizer );
883 /* Default disabled */
884 video_combo->Disable(); video_text->Disable();vb_combo->Disable();
885 audio_combo->Disable(); audio_text->Disable();ab_combo->Disable();
889 wizTranscodeCodecPage::~wizTranscodeCodecPage()
891 if( acodec ) free( acodec );
892 if( vcodec ) free( vcodec );
895 void wizTranscodeCodecPage::OnEnableVideo(wxCommandEvent& event)
897 video_combo->Enable( event.IsChecked() );
898 vb_combo->Enable( event.IsChecked() );
899 video_text->Enable( event.IsChecked() );
902 void wizTranscodeCodecPage::OnEnableAudio(wxCommandEvent& event)
904 audio_combo->Enable( event.IsChecked() );
905 ab_combo->Enable( event.IsChecked() );
906 audio_text->Enable( event.IsChecked() );
909 void wizTranscodeCodecPage::OnVideoCodecChange(wxCommandEvent& event)
911 struct codec *c = (struct codec*)
912 (video_combo->GetClientData(video_combo->GetSelection()));
913 video_text->SetLabel( wxU( vlc_wraptext(c->psz_descr, TEXTWIDTH, false) ) );
914 i_video_codec = video_combo->GetSelection();
915 vcodec = strdup(c->psz_codec);
918 void wizTranscodeCodecPage::OnAudioCodecChange(wxCommandEvent& event)
920 struct codec *c = (struct codec*)
921 (audio_combo->GetClientData(audio_combo->GetSelection()));
922 audio_text->SetLabel( wxU( vlc_wraptext(c->psz_descr, TEXTWIDTH, false) ) );
923 i_audio_codec = audio_combo->GetSelection();
924 acodec = strdup(c->psz_codec);
928 void wizTranscodeCodecPage::OnWizardPageChanging(wxWizardEvent& event)
932 if( !event.GetDirection() )
938 /* Set the dummy codec ( accept all muxers ) if needed */
939 if( !video_combo->IsEnabled() )
941 i_video_codec = VCODECS_NUMBER;
943 if( !audio_combo->IsEnabled() )
945 i_audio_codec = ACODECS_NUMBER;
948 ((wizEncapPage *)GetNext())->SetPrev(this);
950 for( i = 0 ; i< MUXERS_NUMBER ; i++ )
952 if( vcodecs_array[i_video_codec].muxers[i] != -1 )
954 for( j = 0 ; j< MUXERS_NUMBER ; j++ )
956 if( acodecs_array[i_audio_codec].muxers[j] ==
957 vcodecs_array[i_video_codec].muxers[i] )
959 ((wizEncapPage*)GetNext())->EnableEncap(
960 vcodecs_array[i_video_codec].muxers[i] );
965 struct codec *c = (struct codec*)
966 (video_combo->GetClientData( video_combo->IsEnabled() ?
967 video_combo->GetSelection(): i_video_codec ));
968 vcodec = strdup(c->psz_codec);
970 (audio_combo->GetClientData( audio_combo->IsEnabled() ?
971 audio_combo->GetSelection() : i_audio_codec ));
972 acodec = strdup(c->psz_codec);
974 int vb = atoi(vb_combo->GetValue().mb_str() );
979 int ab = atoi(ab_combo->GetValue().mb_str() );
985 p_parent->SetTranscode( vcodec, vb , acodec, ab );
986 ((wizEncapPage*)GetNext())->SetAction( p_parent->GetAction() );
987 p_parent->SetAction( p_parent->GetAction() );
992 wxWizardPage *wizTranscodeCodecPage::GetPrev() const { return p_prev; }
993 wxWizardPage *wizTranscodeCodecPage::GetNext() const { return p_next; }
994 void wizTranscodeCodecPage::SetPrev( wxWizardPage *page) {p_prev = page; }
997 /***************************************************
998 * First streaming page: choose method *
999 ***************************************************/
1000 wizStreamingMethodPage::wizStreamingMethodPage( intf_thread_t *p_this, wxWizard *parent,
1001 wxWizardPage *next) : wxWizardPage(parent), p_intf( p_this )
1005 p_parent = (WizardDialog *)parent;
1007 mainSizer = new wxBoxSizer(wxVERTICAL);
1009 /* Create the texts */
1010 pageHeader( this, mainSizer, STREAMING1_TITLE, STREAMING1_TEXT );
1012 mainSizer->Add( 0,50,0 );
1016 wxStaticBox *method_box = new wxStaticBox( this, -1,
1017 wxU(_("Streaming method")) );
1018 wxStaticBoxSizer *method_sizer = new wxStaticBoxSizer(method_box,
1020 for( i = 0 ; i< 3 ; i++ )
1022 method_radios[i] = new wxRadioButton( this, MethodRadio0_Event + i,
1023 wxU( methods_array[i].psz_method ) );
1024 method_radios[i]->SetToolTip( wxU(_( methods_array[i].psz_descr ) ) );
1025 method_sizer->Add( method_radios[i], 0, wxALL, 5 );
1028 method_sizer->Layout();
1030 wxStaticBox *address_box = new wxStaticBox( this, -1,
1031 wxU(_("Destination")) );
1033 address_sizer = new wxStaticBoxSizer(address_box,
1036 /* Big kludge, we take the longest text to get the size */
1037 address_text = new wxStaticText(this, -1,
1038 wxU( vlc_wraptext(methods_array[2].psz_address,
1039 TEXTWIDTH, false ) ),
1040 wxDefaultPosition, wxDefaultSize );
1042 address_txtctrl = new wxTextCtrl( this, -1, wxU(""), wxDefaultPosition,
1044 address_sizer->Add( address_text, 0, wxALL, 5 );
1045 address_sizer->Add( address_txtctrl, 0, wxALL, 5 );
1046 address_sizer->Layout();
1048 /* Set the minimum size */
1049 address_sizer->SetMinSize( address_sizer->GetSize() );
1050 address_text->SetLabel( wxU(
1051 vlc_wraptext( _(methods_array[0].psz_address), TEXTWIDTH, false)));
1053 mainSizer->Add( method_sizer, 0, wxALL | wxEXPAND, 5 );
1054 mainSizer->Add( address_sizer, 0, wxALL | wxEXPAND, 5 );
1056 mainSizer->Add( 0,0,1 );
1058 mainSizer->Layout();
1060 SetSizer(mainSizer);
1061 mainSizer->Fit(this);
1066 void wizStreamingMethodPage::OnWizardPageChanging(wxWizardEvent& event)
1069 if( !event.GetDirection() ) return;
1071 /* Check valid address */
1073 && !net_AddressIsMulticast( (vlc_object_t *)p_intf,
1074 address_txtctrl->GetValue().mb_str()) )
1076 wxMessageBox( wxU( INVALID_MCAST_ADDRESS ) , wxU( ERROR_MSG ),
1077 wxICON_WARNING | wxOK, this->p_parent );
1081 else if( i_method == 0 && address_txtctrl->GetValue().IsEmpty() )
1083 wxMessageBox( wxU( NO_ADDRESS_TEXT ) , wxU( ERROR_MSG ),
1084 wxICON_WARNING | wxOK, this->p_parent );
1089 ((wizEncapPage *)GetNext())->SetPrev(this);
1090 for( i = 0 ; i< MUXERS_NUMBER ; i++ )
1092 if( methods_array[i_method].muxers[i] != -1 )
1094 ((wizEncapPage*)GetNext())->EnableEncap(
1095 methods_array[i_method].muxers[i] );
1098 p_parent->SetStream( methods_array[i_method].psz_access ,
1099 address_txtctrl->GetValue().mb_str() );
1101 /* Set the action for the muxer page */
1102 ((wizEncapPage*)GetNext())->SetAction( p_parent->GetAction() );
1106 wxWizardPage *wizStreamingMethodPage::GetPrev() const { return p_prev; }
1107 wxWizardPage *wizStreamingMethodPage::GetNext() const { return p_next; }
1109 void wizStreamingMethodPage::SetPrev( wxWizardPage *page) {p_prev = page; }
1112 void wizStreamingMethodPage::OnMethodChange( wxCommandEvent& event )
1114 i_method = event.GetId() - MethodRadio0_Event;
1115 address_text->SetLabel( wxU(
1116 vlc_wraptext( _(methods_array[i_method].psz_address), TEXTWIDTH, false)));
1117 address_sizer->Layout();
1118 mainSizer->Layout();
1121 /***************************************************
1122 * Choose encapsulation format *
1123 ***************************************************/
1124 wizEncapPage::wizEncapPage( wxWizard *parent ) : wxWizardPage(parent)
1128 p_parent = (WizardDialog *)parent;
1129 p_streaming_page = NULL;
1130 p_transcode_page = NULL;
1132 wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
1134 /* Create the texts */
1135 pageHeader( this, mainSizer, ENCAP_TITLE, ENCAP_TEXT );
1137 mainSizer->Add( 0,0,1 );
1139 for( i = 0 ; i< MUXERS_NUMBER ; i++ )
1141 encap_radios[i] = new wxRadioButton( this, EncapRadio0_Event + i,
1142 wxU( encaps_array[i].psz_encap ) );
1143 encap_radios[i]->SetToolTip( wxU(_( encaps_array[i].psz_descr ) ) );
1144 mainSizer->Add( encap_radios[i], 0, wxLEFT, 5 );
1145 encap_radios[i]->Disable();
1148 mainSizer->Add( 0,0,1 );
1150 SetSizer(mainSizer);
1151 mainSizer->Fit(this);
1154 wizEncapPage::~wizEncapPage()
1158 void wizEncapPage::OnWizardPageChanging(wxWizardEvent& event)
1161 if( !event.GetDirection() )
1163 for( i = 0 ; i< MUXERS_NUMBER ; i++ )
1165 encap_radios[i]->Disable();
1168 p_parent->SetMux( encaps_array[i_mux].psz_mux );
1170 if( p_parent->GetAction() == ACTION_STREAM )
1172 if( strstr( p_parent->method, "rtp" ))
1174 ((wizStreamingExtraPage *)GetNext())->sap_checkbox->Enable();
1175 ((wizStreamingExtraPage *)GetNext())->sap_text->Enable(false);
1179 ((wizStreamingExtraPage *)GetNext())->sap_checkbox->Enable( false );
1180 ((wizStreamingExtraPage *)GetNext())->sap_text->Enable( false );
1188 void wizEncapPage::OnEncapChange( wxCommandEvent& event )
1190 i_mux = event.GetId() - EncapRadio0_Event;
1193 void wizEncapPage::EnableEncap( int encap )
1196 for( i = 0 ; i< MUXERS_NUMBER ; i++)
1198 if( encaps_array[i].id == encap )
1200 encap_radios[i]->Enable();
1201 encap_radios[i]->SetValue(true);
1207 void wizEncapPage::SetStreamingPage( wxWizardPage *page)
1209 p_streaming_page = page;
1212 void wizEncapPage::SetTranscodePage( wxWizardPage *page)
1214 p_transcode_page = page;
1217 wxWizardPage *wizEncapPage::GetPrev() const { return p_prev; }
1219 wxWizardPage *wizEncapPage::GetNext() const
1221 if( i_action== ACTION_STREAM )
1222 return p_streaming_page;
1224 return p_transcode_page;
1227 void wizEncapPage::SetAction( int i_act ) { i_action = i_act; }
1229 void wizEncapPage::SetPrev( wxWizardPage *page) { p_prev = page; }
1231 /***************************************************
1232 * Extra transcoding page : Select file *
1233 ***************************************************/
1234 wizTranscodeExtraPage::wizTranscodeExtraPage( wxWizard *parent,
1236 wxWizardPage *next) : wxWizardPage(parent)
1240 p_parent = (WizardDialog *) parent;
1241 wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
1243 /* Create the texts */
1244 pageHeader( this, mainSizer, EXTRATRANSCODE_TITLE, EXTRATRANSCODE_TEXT );
1246 mainSizer->Add( 0, 0, 1 );
1248 wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 2, 1 );
1249 sizer->Add( new wxStaticText( this, -1,
1250 wxU(_("Select the file to save to") ) ),
1252 sizer->Add( 0, 0, 1 );
1254 file_text = new wxTextCtrl( this, -1, wxU(""), wxDefaultPosition,
1255 wxSize( 150, -1 ) );
1257 sizer->Add( file_text, 0, wxALL, 5 );
1258 sizer->Add( new wxButton( this, Open_Event, wxU("Choose") ) );
1260 mainSizer->Add( sizer, 0, 0, 0) ;
1262 mainSizer->Add( 0, 0, 1 );
1263 SetSizer(mainSizer);
1264 mainSizer->Fit(this);
1267 void wizTranscodeExtraPage::OnSelectFile( wxCommandEvent &event)
1269 wxFileDialog *file_dialog = new wxFileDialog( this, wxU(_("Save to file")),
1270 wxT(""), wxT(""), wxT("*"), wxSAVE );
1272 if( file_dialog && file_dialog->ShowModal() == wxID_OK )
1274 if( file_dialog->GetFilename().mb_str() )
1276 file_text->SetValue( file_dialog->GetPath() );
1281 void wizTranscodeExtraPage::OnWizardPageChanging( wxWizardEvent& event )
1283 if( event.GetDirection() && file_text->GetValue().IsEmpty() )
1285 wxMessageBox( wxU( CHOOSE_OUTFILE ), wxU( ERROR_MSG ),
1286 wxICON_WARNING | wxOK, this->p_parent );
1289 if( event.GetDirection() )
1291 p_parent->SetTranscodeOut( file_text->GetValue().mb_str());
1295 wxWizardPage *wizTranscodeExtraPage::GetPrev() const { return p_prev; }
1296 wxWizardPage *wizTranscodeExtraPage::GetNext() const {return p_next; }
1298 /***********************************************************
1299 * Extra streaming page
1300 ***********************************************************/
1301 wizStreamingExtraPage::wizStreamingExtraPage( wxWizard *parent,
1303 wxWizardPage *next) : wxWizardPage(parent)
1307 p_parent = (WizardDialog *) parent;
1308 wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
1310 /* Create the texts */
1311 pageHeader( this, mainSizer, EXTRASTREAMING_TITLE, EXTRASTREAMING_TEXT );
1313 mainSizer->Add( 0, 0, 1 );
1315 wxFlexGridSizer *sizer = new wxFlexGridSizer( 2,2,1) ;
1318 sizer->Add( new wxStaticText( this, -1, wxU(_("Time-To-Live (TTL)"))),
1320 ttl_spin = new wxSpinCtrl( this, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize,
1322 ttl_spin->SetToolTip(wxU(_(TTL) ) ) ;
1323 sizer->Add( ttl_spin, 0, wxALL , 5 );
1326 sap_checkbox = new wxCheckBox( this, SAP_Event, wxU(_("SAP Announce")) );
1327 sap_checkbox->SetToolTip( wxU(_( SAP ) ) );
1328 sizer->Add( sap_checkbox, 0, 0 , 0 );
1329 sap_text = new wxTextCtrl( this, -1, wxU(""), wxDefaultPosition,
1331 sap_text->SetToolTip( wxU(_( SAP ) ) );
1332 sizer->Add( sap_text, 0, wxALL , 5 );
1334 mainSizer->Add(sizer, 0, wxALL, 5 );
1336 mainSizer->Add( 0, 0, 1 );
1338 SetSizer(mainSizer);
1339 mainSizer->Fit(this);
1342 void wizStreamingExtraPage::OnSAP( wxCommandEvent &event )
1344 sap_text->Enable( event.IsChecked() );
1347 void wizStreamingExtraPage::OnWizardPageChanging(wxWizardEvent& event)
1349 if( sap_checkbox->IsChecked() )
1351 if( sap_text->GetValue().IsEmpty() )
1353 p_parent->SetSAP( true, NULL );
1357 p_parent->SetSAP( true,
1358 (const char *)sap_text->GetValue().mb_str() );
1363 p_parent->SetSAP( false, NULL );
1366 p_parent->SetTTL( ttl_spin->GetValue() );
1369 wxWizardPage *wizStreamingExtraPage::GetPrev() const { return p_prev; }
1370 wxWizardPage *wizStreamingExtraPage::GetNext() const {return p_next; }
1373 /***************************************************************************
1374 * Implementation of the wizard itself
1375 ***************************************************************************/
1376 wizHelloPage *page1;
1377 wizInputPage *page2 ;
1378 wizTranscodeCodecPage *tr_page1 ;
1379 wizStreamingMethodPage *st_page1;
1380 wizTranscodeExtraPage *tr_page2 ;
1381 wizStreamingExtraPage *st_page2;
1382 wizEncapPage *encap_page;
1384 WizardDialog::WizardDialog(intf_thread_t *_p_intf, wxWindow *_p_parent,
1385 char *psz_uri, int _i_from, int _i_to ) :
1386 wxWizard( _p_parent, -1, wxU(_("Streaming/Transcoding Wizard")), wxNullBitmap, wxDefaultPosition)
1388 /* Initializations */
1390 SetPageSize(wxSize(400,420));
1392 /* Initialize structure */
1402 page1 = new wizHelloPage(this);
1403 page2 = new wizInputPage(this, page1, p_intf);
1407 page2->SetUri( psz_uri );
1409 if( i_from != 0 || i_to != 0 )
1411 page2->SetPartial( i_from, i_to );
1414 encap_page = new wizEncapPage(this );
1415 tr_page1 = new wizTranscodeCodecPage(this, encap_page );
1416 st_page1 = new wizStreamingMethodPage( p_intf, this, encap_page);
1418 tr_page2 = new wizTranscodeExtraPage(this, encap_page, NULL );
1419 st_page2 = new wizStreamingExtraPage(this, encap_page, NULL );
1422 page1->SetNext( page2 );
1423 /* 2->1 in constructor of 2 */
1426 page2->SetTranscodePage(tr_page1);
1427 page2->SetStreamingPage(st_page1);
1428 page2->SetPintf( p_intf );
1429 tr_page1->SetPrev(page2);
1430 st_page1->SetPrev(page2);
1433 encap_page->SetTranscodePage( tr_page2 );
1434 encap_page->SetStreamingPage( st_page2 );
1435 /* 3->4 in constructor of 3 */
1436 // encap_page->SetPrev(tr_page1);
1439 WizardDialog::~WizardDialog()
1451 void WizardDialog::SetMrl( const char *mrl )
1453 this->mrl = strdup( mrl );
1456 void WizardDialog::SetTTL( int i_ttl )
1458 this->i_ttl = i_ttl;
1461 void WizardDialog::SetSAP( bool b_enabled, const char *psz_text )
1463 this->b_sap = b_enabled;
1466 if( psz_text != NULL )
1468 this->psz_sap_name = strdup( psz_text );
1472 this->psz_sap_name = NULL;
1477 void WizardDialog::SetPartial( int i_from, int i_to )
1479 this->i_from = i_from;
1483 void WizardDialog::SetTranscode( char const *vcodec, int vb,
1484 char const *acodec, int ab)
1486 if( strcmp( vcodec, "dummy") )
1488 this->vcodec= strdup(vcodec);
1490 if( strcmp( acodec, "dummy" ) )
1492 this->acodec = strdup(acodec);
1498 void WizardDialog::SetStream( char const *method, char const *address )
1500 this->method = strdup( method );
1501 this->address = strdup( address );
1504 void WizardDialog::SetTranscodeOut( char const *address )
1506 char *psz_utf8 = FromLocale( address );
1507 this->address = strdup( psz_utf8 );
1508 LocaleFree( psz_utf8 );
1511 void WizardDialog::SetMux( char const *mux )
1513 this->mux = strdup( mux );
1516 void WizardDialog::SetAction( int i_action )
1518 this->i_action = i_action;
1521 int WizardDialog::GetAction()
1526 void WizardDialog::Run()
1528 if( RunWizard(page1) )
1533 if( i_action == ACTION_TRANSCODE )
1535 msg_Dbg( p_intf,"Starting transcode of %s to file %s",
1537 msg_Dbg( p_intf,"Using %s (%i kbps) / %s (%i kbps),encap %s",
1538 vcodec,vb,acodec,ab,mux);
1539 char *psz_transcode;
1541 if( vcodec != NULL || acodec != NULL )
1544 if( vcodec != NULL )
1545 i_tr_size += strlen( vcodec ) + 17;
1546 if( acodec != NULL )
1547 i_tr_size += strlen( acodec ) + 17;
1559 psz_transcode = (char *)malloc( i_tr_size * sizeof(char) );
1561 strcpy( psz_transcode, "transcode{" );
1562 if( vcodec != NULL )
1564 sprintf( psz_transcode + strlen( psz_transcode ),
1565 "vcodec=%s,vb=%i%s", vcodec, vb,
1566 ( acodec != NULL ) ? "," : "}:" );
1568 if( acodec != NULL )
1570 sprintf( psz_transcode + strlen( psz_transcode ),
1571 "acodec=%s,ab=%i}:", acodec, ab );
1577 i_size = 73 + strlen(mux) + strlen(address) + strlen(psz_transcode);
1578 psz_opt = (char *)malloc( i_size * sizeof(char) );
1579 snprintf( psz_opt, i_size, ":sout=#%sstandard{mux=%s,url=%s,"
1580 "access=file}", psz_transcode, mux, address );
1582 if( *psz_transcode )
1583 free( psz_transcode );
1587 msg_Dbg( p_intf, "Starting stream of %s to %s using %s, encap %s",
1588 mrl, address, method, mux);
1591 char *psz_sap_option = NULL;
1594 psz_sap_option = (char *) malloc( strlen( psz_sap_name )
1596 snprintf( psz_sap_option,strlen( psz_sap_name ) + 15,
1597 "sap,name=\"%s\"",psz_sap_name );
1600 psz_sap_option = strdup( "sap" );
1602 i_size = 40 + strlen(mux) + strlen(address) +
1603 strlen( psz_sap_option);
1604 psz_opt = (char *)malloc( i_size * sizeof(char) );
1605 snprintf( psz_opt, i_size,
1606 ":sout=#standard{mux=%s,url=%s,access=%s,%s}",
1607 mux, address,method, psz_sap_option);
1608 if( psz_sap_option ) free( psz_sap_option );
1612 i_size = 40 + strlen(mux) + strlen(address);
1613 psz_opt = (char *)malloc( i_size * sizeof(char) );
1614 snprintf( psz_opt, i_size,
1615 ":sout=#standard{mux=%s,url=%s,access=%s}",
1616 mux, address,method);
1620 playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,
1621 VLC_OBJECT_PLAYLIST, FIND_ANYWHERE);
1624 playlist_item_t *p_item = playlist_ItemNew( p_playlist, mrl,
1626 playlist_ItemAddOption( p_item, psz_opt);
1630 snprintf( psz_from, 20, "start-time=%i", i_from);
1631 playlist_ItemAddOption( p_item, psz_from);
1636 snprintf( psz_to, 20, "stop-time=%i", i_to);
1637 playlist_ItemAddOption( p_item, psz_to);
1641 snprintf( psz_ttl, 20, "ttl=%i",i_ttl );
1642 playlist_ItemAddOption( p_item, psz_ttl );
1644 playlist_AddItem( p_playlist, p_item, PLAYLIST_GO, PLAYLIST_END );
1645 vlc_object_release(p_playlist);
1649 wxMessageBox( wxU( NO_PLAYLIST ), wxU( ERROR_MSG ),
1650 wxICON_WARNING | wxOK, this );