1 /*****************************************************************************
2 * wizard.cpp : wxWindows plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000-2004 VideoLAN
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 <stdlib.h> /* malloc(), free() */
28 #include <errno.h> /* ENOMEM */
29 #include <string.h> /* strerror() */
35 #include "wxwindows.h"
37 #include "streamdata.h"
39 #include <wx/statline.h>
44 /*****************************************************************************
46 *****************************************************************************/
49 ActionRadio0_Event, ActionRadio1_Event,
50 MoreInfoStreaming_Event,
51 MoreInfoTranscode_Event,
53 Open_Event , Choose_Event ,
55 InputRadio0_Event, InputRadio1_Event,
58 MethodRadio0_Event, MethodRadio1_Event,
59 MethodRadio2_Event, MethodRadio3_Event,
61 EncapRadio0_Event, EncapRadio1_Event,
62 EncapRadio2_Event, EncapRadio3_Event,
63 EncapRadio4_Event, EncapRadio5_Event,
64 EncapRadio6_Event, EncapRadio7_Event,
65 EncapRadio8_Event, EncapRadio9_Event,
66 EncapRadio10_Event, EncapRadio11_Event,
68 VideoEnable_Event, VideoCodec_Event,VideoBitrate_Event,
69 AudioEnable_Event, AudioCodec_Event,AudioBitrate_Event,
76 #define ACTION_STREAM 0
77 #define ACTION_TRANSCODE 1
79 BEGIN_EVENT_TABLE(WizardDialog, wxWizard)
82 /*****************************************************************************
84 *****************************************************************************/
86 #define ERROR_MSG _("Error")
87 #define ITEM_NAME _("Streaming/Transcoding Wizard")
90 #define HELLO_TITLE _("Streaming/Transcoding Wizard")
91 #define HELLO_TEXT _("This wizard helps you to stream, transcode or" \
93 #define HELLO_STREAMING _("Stream to network")
94 #define HELLO_STREAMING_DESC _("Use this to stream on a network")
95 #define HELLO_TRANSCODE _("Transcode/Save to file")
96 #define HELLO_TRANSCODE_DESC _("Use this to re-encode a stream and save it to a file")
97 #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")
99 #define MOREINFO_STREAM _("Use this to stream on a network")
101 #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 " \
102 "for file to file transcoding. You should use its transcoding " \
103 "features to save network streams, for example" )
106 #define INPUT_TITLE _("Choose input")
107 #define INPUT_TEXT _("Choose here your 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 _("Uh Oh! Unable to find playlist !")
115 #define PARTIAL _("Use this to read only a part of the stream. " \
116 "You must be able to control the incoming stream " \
117 "(for example, a file or a disc, but not an UDP " \
118 "network stream.)\n" \
119 "Enter the starting and ending times (in seconds)")
121 #define INPUT_BUTTON _("Choose")
124 #define TRANSCODE1_TITLE _("Transcode")
125 #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).")
127 #define TR_VIDEO_TEXT0 _("If your stream has video and you want to " \
128 "transcode it, enable this")
129 #define TR_VIDEO_TEXT _("Select your video codec. Click one to get more " \
132 #define TR_AUDIO_TEXT0 _("If your stream has audio and you want to "\
133 "transcode it, enable this")
134 #define TR_AUDIO_TEXT _("Select your audio codec. Click one to get more " \
138 #define STREAMING1_TITLE _("Streaming")
139 #define STREAMING1_TEXT _("In this page, you will select how your input stream will be sent.")
142 #define INVALID_MCAST_ADDRESS _("This does not appear to be a valid " \
143 "multicast address" )
144 #define NO_ADDRESS _("You need to enter an address" )
147 #define ENCAP_TITLE _("Encapsulation format")
148 #define ENCAP_TEXT _("In this page, you will select how the stream will be "\
149 "encapsulated. Depending on the choices you made, all "\
150 "formats won't be available." )
154 #define EXTRATRANSCODE_TITLE _("Additional transcode options")
155 #define EXTRATRANSCODE_TEXT _("In this page, you will define a few " \
156 "additionnal parameters for your transcoding" )
158 #define CHOOSE_OUTFILE _("You must choose a file to save to")
161 #define EXTRASTREAMING_TITLE _("Additional streaming options")
162 #define EXTRASTREAMING_TEXT _("In this page, you will define a few " \
163 "additionnal parameters for your stream" )
165 #define TTL _("Define the TTL (Time-To-Live) of the stream. This parameter " \
166 "is the maximum number of routers your stream can go through. " \
167 "If you don't know what it means, or if you want to stream on " \
168 "your local network only, leave this setting to 1." )
170 #define SAP _("When streaming using UDP, you can announce your streams " \
171 "using the SAP/SDP announcing protocol. This way, the clients " \
172 "won't have to type in the multicast address, it will appear " \
173 "in their playlist if they enable the SAP extra interface.\n" \
174 "If you want to give a name to your stream, enter it here, " \
175 "else, a default name will be used" )
177 /*****************************************************************************
178 * All the pages of the wizard, declaration
179 *****************************************************************************/
181 /* Declare classes */
182 class wizHelloPage : public wxWizardPageSimple
185 wizHelloPage( wxWizard *parent);
186 void OnActionChange(wxEvent& event);
187 void OnWizardPageChanging(wxWizardEvent& event);
188 void OnMoreInfo( wxCommandEvent& event );
191 WizardDialog *p_parent;
192 wxRadioButton *action_radios[2];
193 DECLARE_EVENT_TABLE()
196 BEGIN_EVENT_TABLE(wizHelloPage, wxWizardPageSimple)
197 EVT_RADIOBUTTON( ActionRadio0_Event, wizHelloPage::OnActionChange)
198 EVT_RADIOBUTTON( ActionRadio1_Event, wizHelloPage::OnActionChange)
199 EVT_BUTTON( MoreInfoStreaming_Event, wizHelloPage::OnMoreInfo )
200 EVT_BUTTON( MoreInfoTranscode_Event, wizHelloPage::OnMoreInfo )
202 EVT_WIZARD_PAGE_CHANGING(-1, wizHelloPage::OnWizardPageChanging)
206 class wizInputPage : public wxWizardPage
209 wizInputPage( wxWizard *, wxWizardPage *, intf_thread_t *);
210 wizInputPage::~wizInputPage();
211 void OnWizardPageChanging(wxWizardEvent& event);
212 void OnInputChange(wxEvent& event);
213 void OnEnablePartial(wxCommandEvent& event);
214 virtual wxWizardPage *GetPrev() const;
215 virtual wxWizardPage *GetNext() const;
216 void SetStreamingPage( wxWizardPage *page);
217 void SetTranscodePage( wxWizardPage *page);
218 void SetAction( int i_action );
219 void SetPintf( intf_thread_t *p_intf );
220 void SetUri( char *psz_uri );
221 void SetPartial( int i_from, int i_to );
225 intf_thread_t *p_intf;
229 void OnChoose( wxCommandEvent& event );
231 WizardDialog *p_parent;
232 wxRadioButton *input_radios[2];
233 wxCheckBox *enable_checkbox;
234 wxBoxSizer *mainSizer;
236 wxTextCtrl *mrl_text;
237 wxTextCtrl *from_text;
239 OpenDialog *p_open_dialog;
240 wxListView *listview;
243 wxWizardPage *p_prev;
244 wxWizardPage *p_streaming_page;
245 wxWizardPage *p_transcode_page;
247 DECLARE_EVENT_TABLE()
250 BEGIN_EVENT_TABLE(wizInputPage, wxWizardPage)
251 EVT_RADIOBUTTON( InputRadio0_Event, wizInputPage::OnInputChange)
252 EVT_RADIOBUTTON( InputRadio1_Event, wizInputPage::OnInputChange)
253 EVT_BUTTON( Choose_Event, wizInputPage::OnChoose)
254 EVT_CHECKBOX( PartialEnable_Event, wizInputPage::OnEnablePartial)
255 EVT_WIZARD_PAGE_CHANGING(-1, wizInputPage::OnWizardPageChanging)
259 class wizTranscodeCodecPage : public wxWizardPage
262 wizTranscodeCodecPage( wxWizard *parent, wxWizardPage *next);
263 ~wizTranscodeCodecPage();
264 void wizTranscodeCodecPage::OnWizardPageChanging(wxWizardEvent& event);
265 virtual wxWizardPage *GetPrev() const;
266 virtual wxWizardPage *GetNext() const;
267 void SetPrev( wxWizardPage *page);
269 wxCheckBox *video_checkbox;
270 wxComboBox *video_combo;
271 wxComboBox *vb_combo;
272 wxStaticText * video_text;
273 wxCheckBox *audio_checkbox;
274 wxComboBox *audio_combo;
275 wxComboBox *ab_combo;
276 wxStaticText * audio_text;
278 WizardDialog *p_parent;
285 wxWizardPage *p_prev;
286 wxWizardPage *p_next;
288 void OnVideoCodecChange(wxCommandEvent& event);
289 void OnAudioCodecChange(wxCommandEvent& event);
290 void OnEnableVideo(wxCommandEvent& event);
291 void OnEnableAudio(wxCommandEvent& event);
293 DECLARE_EVENT_TABLE()
296 BEGIN_EVENT_TABLE(wizTranscodeCodecPage, wxWizardPage)
297 EVT_CHECKBOX( VideoEnable_Event, wizTranscodeCodecPage::OnEnableVideo)
298 EVT_CHECKBOX( AudioEnable_Event, wizTranscodeCodecPage::OnEnableAudio)
299 EVT_COMBOBOX( VideoCodec_Event, wizTranscodeCodecPage::OnVideoCodecChange)
300 EVT_COMBOBOX( AudioCodec_Event, wizTranscodeCodecPage::OnAudioCodecChange)
301 EVT_WIZARD_PAGE_CHANGING(-1, wizTranscodeCodecPage::OnWizardPageChanging)
304 class wizStreamingMethodPage : public wxWizardPage
307 wizStreamingMethodPage( wxWizard *parent, wxWizardPage *next);
308 void OnWizardPageChanging(wxWizardEvent& event);
309 virtual wxWizardPage *GetPrev() const;
310 virtual wxWizardPage *GetNext() const;
311 void SetPrev( wxWizardPage *page);
313 DECLARE_EVENT_TABLE()
315 wxBoxSizer *mainSizer;
316 wxStaticBoxSizer *address_sizer;
317 wxStaticText *address_text;
318 wxTextCtrl *address_txtctrl;
319 WizardDialog * p_parent;
320 void OnMethodChange(wxEvent& event);
321 wxRadioButton *method_radios[4];
322 wxWizardPage *p_prev;
323 wxWizardPage *p_next;
326 BEGIN_EVENT_TABLE(wizStreamingMethodPage, wxWizardPage)
327 EVT_RADIOBUTTON( MethodRadio0_Event, wizStreamingMethodPage::OnMethodChange)
328 EVT_RADIOBUTTON( MethodRadio1_Event, wizStreamingMethodPage::OnMethodChange)
329 EVT_RADIOBUTTON( MethodRadio2_Event, wizStreamingMethodPage::OnMethodChange)
330 EVT_RADIOBUTTON( MethodRadio3_Event, wizStreamingMethodPage::OnMethodChange)
331 EVT_WIZARD_PAGE_CHANGING(-1, wizStreamingMethodPage::OnWizardPageChanging)
335 class wizEncapPage : public wxWizardPage
338 wizEncapPage( wxWizard *parent);
339 wizEncapPage::~wizEncapPage();
340 void OnWizardPageChanging(wxWizardEvent& event);
341 virtual wxWizardPage *GetPrev() const;
342 virtual wxWizardPage *GetNext() const;
343 void SetStreamingPage( wxWizardPage *page);
344 void SetTranscodePage( wxWizardPage *page);
345 void SetPrev( wxWizardPage *page);
346 void SetAction( int );
347 void EnableEncap( int encap );
349 DECLARE_EVENT_TABLE()
353 void OnEncapChange(wxEvent& event);
354 wxRadioButton *encap_radios[MUXERS_NUMBER];
355 WizardDialog *p_parent;
356 wxWizardPage *p_prev;
357 wxWizardPage *p_streaming_page;
358 wxWizardPage *p_transcode_page;
361 BEGIN_EVENT_TABLE(wizEncapPage, wxWizardPage)
362 EVT_WIZARD_PAGE_CHANGING(-1, wizEncapPage::OnWizardPageChanging)
363 EVT_RADIOBUTTON( EncapRadio0_Event, wizEncapPage::OnEncapChange)
364 EVT_RADIOBUTTON( EncapRadio1_Event, wizEncapPage::OnEncapChange)
365 EVT_RADIOBUTTON( EncapRadio2_Event, wizEncapPage::OnEncapChange)
366 EVT_RADIOBUTTON( EncapRadio3_Event, wizEncapPage::OnEncapChange)
367 EVT_RADIOBUTTON( EncapRadio4_Event, wizEncapPage::OnEncapChange)
368 EVT_RADIOBUTTON( EncapRadio5_Event, wizEncapPage::OnEncapChange)
369 EVT_RADIOBUTTON( EncapRadio6_Event, wizEncapPage::OnEncapChange)
370 EVT_RADIOBUTTON( EncapRadio7_Event, wizEncapPage::OnEncapChange)
371 EVT_RADIOBUTTON( EncapRadio8_Event, wizEncapPage::OnEncapChange)
372 EVT_RADIOBUTTON( EncapRadio9_Event, wizEncapPage::OnEncapChange)
373 EVT_RADIOBUTTON( EncapRadio10_Event, wizEncapPage::OnEncapChange)
376 /* Additional settings for transcode */
377 class wizTranscodeExtraPage : public wxWizardPage
380 wizTranscodeExtraPage( wxWizard *parent, wxWizardPage *prev,
382 virtual wxWizardPage *GetPrev() const;
383 virtual wxWizardPage *GetNext() const;
384 void OnWizardPageChanging( wxWizardEvent& event );
386 DECLARE_EVENT_TABLE()
387 void wizTranscodeExtraPage::OnSelectFile(wxCommandEvent&);
388 wxTextCtrl *file_text;
389 WizardDialog *p_parent;
390 wxWizardPage *p_prev;
391 wxWizardPage *p_next;
394 BEGIN_EVENT_TABLE(wizTranscodeExtraPage, wxWizardPage)
395 EVT_BUTTON( Open_Event, wizTranscodeExtraPage::OnSelectFile)
396 EVT_WIZARD_PAGE_CHANGING(-1, wizTranscodeExtraPage::OnWizardPageChanging)
399 /* Additional settings for streaming */
400 class wizStreamingExtraPage : public wxWizardPage
403 wizStreamingExtraPage( wxWizard *parent, wxWizardPage *prev,
405 virtual wxWizardPage *GetPrev() const;
406 virtual wxWizardPage *GetNext() const;
407 void OnWizardPageChanging(wxWizardEvent&);
408 void OnSAP( wxCommandEvent&);
409 wxCheckBox *sap_checkbox;
410 wxTextCtrl *sap_text;
412 friend class wizEncapPage;
413 DECLARE_EVENT_TABLE()
414 WizardDialog *p_parent;
415 wxWizardPage *p_prev;
416 wxWizardPage *p_next;
418 wxSpinCtrl *ttl_spin;
421 BEGIN_EVENT_TABLE(wizStreamingExtraPage, wxWizardPage)
422 EVT_CHECKBOX( SAP_Event, wizStreamingExtraPage::OnSAP )
423 EVT_WIZARD_PAGE_CHANGING(-1, wizStreamingExtraPage::OnWizardPageChanging)
427 /* Local functions */
428 static int ismult( char *psz_uri );
430 static void pageHeader( wxWindow *window, wxBoxSizer *sizer,
431 char *psz_title, char *psz_text);
433 static void pageHeader( wxWindow *window, wxBoxSizer *sizer,
434 char *psz_title, char *psz_text)
436 wxStaticText *wtitle = new wxStaticText( window, -1, wxU( psz_title ) );
437 wxFont font = wtitle->GetFont();
438 font.SetPointSize(14);
439 wtitle->SetFont(font);
440 sizer->Add( wtitle, 0, wxALL, 5 );
441 sizer->Add( new wxStaticText( window, -1,
442 wxU( vlc_wraptext( psz_text , TEXTWIDTH, false ) ) ),
446 /***************************************************************************
447 * Implementation of the pages
448 ***************************************************************************/
451 /***************************************************
452 * First page: choose between stream and transcode *
453 ***************************************************/
454 wizHelloPage::wizHelloPage( wxWizard *parent) : wxWizardPageSimple(parent)
457 p_parent = (WizardDialog *)parent;
458 wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
460 /* Create the texts */
461 pageHeader( this, mainSizer, HELLO_TITLE, HELLO_TEXT );
463 /* Create the radio buttons with their helps */
464 action_radios[0] = new wxRadioButton( this, ActionRadio0_Event,
465 wxU( HELLO_STREAMING ) );
466 action_radios[1] = new wxRadioButton( this, ActionRadio1_Event,
467 wxU( HELLO_TRANSCODE ) );
470 mainSizer->Add( 0, 0, 1 );
472 wxBoxSizer *stream_sizer = new wxBoxSizer( wxHORIZONTAL );
473 stream_sizer->Add( action_radios[0], 0, wxALL, 5 );
474 stream_sizer->Add( 0,0,1 );
475 stream_sizer->Add( new wxButton( this, MoreInfoStreaming_Event,
476 wxU( _("More Info")) ), 0, 0, 0 );
477 mainSizer->Add( stream_sizer, 0, wxALL | wxEXPAND , 5 );
479 wxBoxSizer *transcode_sizer = new wxBoxSizer( wxHORIZONTAL );
480 transcode_sizer->Add( action_radios[1], 0, wxALL, 5 );
481 transcode_sizer->Add( 0,0,1);
482 transcode_sizer->Add( new wxButton( this, MoreInfoTranscode_Event,
483 wxU( _("More Info")) ), 0 , 0 , 0 );
484 mainSizer->Add( transcode_sizer, 0, wxALL | wxEXPAND, 5 );
486 mainSizer->Add( 0, 0, 1 );
488 mainSizer->Add( new wxStaticLine(this, -1 ), 0, wxEXPAND| wxTOP|
491 mainSizer->Add( new wxStaticText(this, -1,
492 wxU( vlc_wraptext(HELLO_NOTICE , TEXTWIDTH , false ))),
496 mainSizer->Fit(this);
499 void wizHelloPage::OnMoreInfo(wxCommandEvent& event)
502 msg.Printf( wxString( wxU( event.GetId() == MoreInfoStreaming_Event ?
504 MOREINFO_TRANSCODE ) ) );
505 wxMessageBox( msg, wxU(_("More information")),
506 wxOK | wxICON_INFORMATION, this->p_parent );
509 void wizHelloPage::OnActionChange(wxEvent& event)
511 i_action = event.GetId() - ActionRadio0_Event;
512 ((wizInputPage *)GetNext())->SetAction( i_action );
513 p_parent->SetAction( i_action );
516 void wizHelloPage::OnWizardPageChanging(wxWizardEvent& event)
518 ((wizInputPage *)GetNext())->SetAction( i_action );
519 p_parent->SetAction( i_action );
522 /************************************
523 * Second page: choose input stream *
524 ************************************/
525 wizInputPage::wizInputPage( wxWizard *parent, wxWizardPage *prev, intf_thread_t *_p_intf) :
530 p_parent = (WizardDialog *)parent;
532 p_open_dialog = NULL;
534 mainSizer = new wxBoxSizer(wxVERTICAL);
536 /* Create the texts */
537 pageHeader( this, mainSizer, INPUT_TITLE, INPUT_TEXT );
539 /* Create the radio buttons */
540 input_radios[0] = new wxRadioButton( this, InputRadio0_Event ,
542 mainSizer->Add( input_radios[0], 0, wxALL, 5 );
543 input_radios[1] = new wxRadioButton( this, InputRadio1_Event ,
546 mainSizer->Add( input_radios[1], 0, wxALL, 5 );
549 open_panel = new wxPanel(this, -1);
550 open_panel->SetAutoLayout( TRUE );
551 wxBoxSizer *openSizer = new wxBoxSizer(wxHORIZONTAL);
553 mrl_text = new wxTextCtrl( open_panel, -1, wxU( "" ), wxDefaultPosition,
555 openSizer->Add( mrl_text, 0 , wxALL, 5 );
556 openSizer->Add( new wxButton( open_panel, Choose_Event, wxU(_("Choose...")) ), 0, wxALL, 5 );
557 open_panel->SetSizer( openSizer );
559 openSizer->Fit(open_panel);
561 mainSizer->Add( open_panel );
564 playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,
565 VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
569 if( p_playlist->i_size > 0)
571 pl_panel = new wxPanel(this, -1);
572 wxBoxSizer *plSizer = new wxBoxSizer( wxHORIZONTAL );
573 listview = new wxListView( pl_panel, ListView_Event,
574 wxDefaultPosition, wxSize(300,300),
575 wxLC_REPORT | wxSUNKEN_BORDER );
576 listview->InsertColumn( 0, wxU(_("Name")) );
577 listview->InsertColumn( 1, wxU(_("URI")) );
578 listview->SetColumnWidth( 0, 250 );
579 listview->SetColumnWidth( 1, 100 );
580 for( int i=0 ; i < p_playlist->i_size ; i++ )
582 wxString filename = wxL2U( p_playlist->pp_items[i]->input.
584 listview->InsertItem( i, filename );
585 listview->SetItem( i, 1, wxL2U( p_playlist->pp_items[i]->
588 listview->Select( p_playlist->i_index , TRUE);
589 plSizer->Add( listview, 1, wxALL | wxEXPAND , 5 );
590 pl_panel->SetSizer( plSizer );
592 mainSizer->Add( pl_panel, 1, wxALL|wxEXPAND, 5 );
595 mainSizer->Hide( pl_panel );
600 input_radios[1]->Disable();
602 vlc_object_release( p_playlist );
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 , wxLEFT , 5 );
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(wxEvent& event)
653 i_input = event.GetId() - InputRadio0_Event;
659 mainSizer->Hide( pl_panel );
661 mainSizer->Show( open_panel );
668 mainSizer->Hide( open_panel );
670 mainSizer->Show( pl_panel );
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 )
687 mrl_text->SetValue(p_open_dialog->mrl[0] );
689 delete p_open_dialog;
690 p_open_dialog = NULL;
693 void wizInputPage::OnWizardPageChanging(wxWizardEvent& event)
697 if( mrl_text->GetValue().IsSameAs( wxT(""), TRUE ) &&
698 event.GetDirection() )
700 wxMessageBox( wxU( CHOOSE_STREAM ), wxU( ERROR_MSG ),
701 wxICON_WARNING | wxOK, this->p_parent );
707 p_parent->SetMrl( (const char *)mrl_text->GetValue().mb_str() );
714 i = listview->GetNextItem( i , wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
718 listitem.SetColumn( 1 );
719 listview->GetItem( listitem );
720 p_parent->SetMrl( (const char*) listitem.GetText().mb_str() );
723 if( enable_checkbox->IsChecked() )
725 int i_from = atoi( from_text->GetValue().mb_str() );
726 int i_to = atoi( to_text->GetValue().mb_str() );
727 msg_Dbg( p_intf, "Partial streaming enabled, from %i to %i",
729 p_parent->SetPartial( i_from, i_to );
734 wxWizardPage *wizInputPage::GetPrev() const { return p_prev; }
735 wxWizardPage *wizInputPage::GetNext() const
737 if( i_action == ACTION_STREAM )
738 return p_streaming_page;
740 return p_transcode_page;
743 void wizInputPage::SetStreamingPage( wxWizardPage *page)
745 p_streaming_page = page;
748 void wizInputPage::SetTranscodePage( wxWizardPage *page)
750 p_transcode_page = page;
753 void wizInputPage::SetAction( int i_action )
755 this->i_action = i_action;
758 void wizInputPage::SetPintf( intf_thread_t *p_intf )
760 this->p_intf = p_intf;
763 void wizInputPage::SetUri( char *psz_uri )
765 mrl_text->SetValue( wxU( psz_uri ) );
768 void wizInputPage::SetPartial( int i_from, int i_to )
771 msg.Printf( wxString( wxT( "%i") ), i_from );
772 from_text->Enable( TRUE );
773 from_text->SetValue( msg );
774 msg.Printf( wxString( wxT( "%i") ), i_to );
775 to_text->Enable( TRUE );
776 to_text->SetValue( msg );
777 enable_checkbox->SetValue( TRUE );
780 /***************************************************
781 * First transcode page: choose codecs *
782 ***************************************************/
783 wizTranscodeCodecPage::wizTranscodeCodecPage( wxWizard *parent,
784 wxWizardPage *next) : wxWizardPage(parent)
790 p_parent = (WizardDialog *) parent;
792 wxBoxSizer *main_sizer = new wxBoxSizer(wxVERTICAL);
795 pageHeader( this, main_sizer, TRANSCODE1_TITLE, TRANSCODE1_TEXT );
798 wxStaticBox *video_box = new wxStaticBox( this, -1, wxU(_("Video")) );
799 wxStaticBoxSizer *video_sizer = new wxStaticBoxSizer( video_box,
801 /* Line 1 : only the checkbox */
802 wxFlexGridSizer *video_sizer1 = new wxFlexGridSizer( 2,3,20 );
803 video_sizer1->Add( new wxCheckBox( this, VideoEnable_Event,
804 wxU(_("Transcode video") ) ), 0 , 0 , 5 );
805 video_sizer1->Add( 0,0,1);
807 video_sizer1->Add( new wxStaticText(this, -1, wxU(_("Codec"))),0,wxLEFT ,5);
808 video_combo = new wxComboBox( this, VideoCodec_Event, wxT(""),
809 wxDefaultPosition, wxSize(200,25) );
810 for( int i= 0; vcodecs_array[i].psz_display != NULL; i++ )
812 video_combo->Append( wxU( vcodecs_array[i].psz_display ) ,
813 (void *)&vcodecs_array[i] );
815 video_sizer1->Add( video_combo, 0 , wxALIGN_LEFT , 0 );
817 video_sizer1->Add( new wxStaticText(this, -1, wxU(_("Bitrate (kb/s)"))),0,
819 vb_combo = new wxComboBox( this, VideoBitrate_Event, wxT("1024"),
820 wxDefaultPosition, wxDefaultSize,
821 WXSIZEOF(vbitrates_array), vbitrates_array );
822 video_sizer1->Add( vb_combo, 0, wxALIGN_LEFT , 0 );
825 video_text = new wxStaticText( this, -1,
826 wxU( vlc_wraptext( TR_VIDEO_TEXT, TEXTWIDTH, false) ) );
827 /* Fill the main video sizer */
828 video_sizer->Add( video_sizer1 , 0, wxEXPAND , 5 );
829 video_sizer->Add( video_text, 0, wxLEFT|wxTOP , 5 );
833 wxStaticBox *audio_box = new wxStaticBox( this, -1, wxU(_("Audio")) );
834 wxStaticBoxSizer *audio_sizer = new wxStaticBoxSizer( audio_box,
837 wxFlexGridSizer *audio_sizer1 = new wxFlexGridSizer( 2,3,20);
838 audio_sizer1->Add( new wxCheckBox( this, AudioEnable_Event,
839 wxU(_("Transcode audio") ) ), 0 , wxLEFT, 5 );
840 audio_sizer1->Add( 0, 0, 1 );
843 audio_sizer1->Add( new wxStaticText(this, -1, wxU(_("Codec"))),0,wxLEFT,5);
844 audio_combo = new wxComboBox( this, AudioCodec_Event, wxT(""),
845 wxDefaultPosition, wxSize(200,25) );
846 for( int i= 0; acodecs_array[i].psz_display != NULL; i++ )
848 audio_combo->Append( wxU( acodecs_array[i].psz_display ) ,
849 (void *)&acodecs_array[i] );
851 audio_sizer1->Add( audio_combo, 0 , wxALIGN_LEFT, 0 );
853 audio_sizer1->Add( new wxStaticText(this, -1, wxU(_("Bitrate (kb/s)"))),0,
855 ab_combo = new wxComboBox( this, AudioBitrate_Event, wxT("192"),
856 wxDefaultPosition, wxDefaultSize,
857 WXSIZEOF(abitrates_array), abitrates_array );
858 audio_sizer1->Add( ab_combo, 0, wxALIGN_LEFT, 0 );
861 audio_text = new wxStaticText( this, -1,
862 wxU( vlc_wraptext( TR_AUDIO_TEXT, TEXTWIDTH, false) ) );
864 audio_sizer->Add(audio_sizer1, 0, wxEXPAND, 5);
865 audio_sizer->Add( audio_text, 0, wxLEFT | wxTOP, 5 );
867 main_sizer->Add( video_sizer, 1, wxGROW, 0 );
868 main_sizer->Add( audio_sizer, 1, wxGROW, 0 );
869 main_sizer->Layout();
870 SetSizerAndFit( main_sizer );
872 /* Default disabled */
873 video_combo->Disable(); video_text->Disable();vb_combo->Disable();
874 audio_combo->Disable(); audio_text->Disable();ab_combo->Disable();
878 wizTranscodeCodecPage::~wizTranscodeCodecPage()
880 if( acodec ) free( acodec );
881 if( vcodec ) free( vcodec );
884 void wizTranscodeCodecPage::OnEnableVideo(wxCommandEvent& event)
886 video_combo->Enable( event.IsChecked() );
887 vb_combo->Enable( event.IsChecked() );
888 video_text->Enable( event.IsChecked() );
891 void wizTranscodeCodecPage::OnEnableAudio(wxCommandEvent& event)
893 audio_combo->Enable( event.IsChecked() );
894 ab_combo->Enable( event.IsChecked() );
895 audio_text->Enable( event.IsChecked() );
898 void wizTranscodeCodecPage::OnVideoCodecChange(wxCommandEvent& event)
900 struct codec *c = (struct codec*)
901 (video_combo->GetClientData(video_combo->GetSelection()));
902 video_text->SetLabel( wxU( vlc_wraptext(c->psz_descr, TEXTWIDTH, false) ) );
903 i_video_codec = video_combo->GetSelection();
904 vcodec = strdup(c->psz_codec);
907 void wizTranscodeCodecPage::OnAudioCodecChange(wxCommandEvent& event)
909 struct codec *c = (struct codec*)
910 (audio_combo->GetClientData(audio_combo->GetSelection()));
911 audio_text->SetLabel( wxU( vlc_wraptext(c->psz_descr, TEXTWIDTH, false) ) );
912 i_audio_codec = audio_combo->GetSelection();
913 acodec = strdup(c->psz_codec);
917 void wizTranscodeCodecPage::OnWizardPageChanging(wxWizardEvent& event)
921 if( !event.GetDirection() )
927 /* Set the dummy codec ( accept all muxers ) if needed */
928 if( !video_combo->IsEnabled() )
930 i_video_codec = VCODECS_NUMBER;
932 if( !audio_combo->IsEnabled() )
934 i_audio_codec = ACODECS_NUMBER;
937 ((wizEncapPage *)GetNext())->SetPrev(this);
939 for( i = 0 ; i< MUXERS_NUMBER ; i++ )
941 if( vcodecs_array[i_video_codec].muxers[i] != -1 )
943 for( j = 0 ; j< MUXERS_NUMBER ; j++ )
945 if( acodecs_array[i_audio_codec].muxers[j] ==
946 vcodecs_array[i_video_codec].muxers[i] )
948 ((wizEncapPage*)GetNext())->EnableEncap(
949 vcodecs_array[i_video_codec].muxers[i] );
954 struct codec *c = (struct codec*)
955 (video_combo->GetClientData( video_combo->IsEnabled() ?
956 video_combo->GetSelection(): i_video_codec ));
957 vcodec = strdup(c->psz_codec);
959 (audio_combo->GetClientData( audio_combo->IsEnabled() ?
960 audio_combo->GetSelection() : i_audio_codec ));
961 acodec = strdup(c->psz_codec);
963 int vb = atoi(vb_combo->GetValue().mb_str() );
968 int ab = atoi(ab_combo->GetValue().mb_str() );
974 p_parent->SetTranscode( vcodec, vb , acodec, ab );
975 ((wizEncapPage*)GetNext())->SetAction( p_parent->GetAction() );
976 p_parent->SetAction( p_parent->GetAction() );
981 wxWizardPage *wizTranscodeCodecPage::GetPrev() const { return p_prev; }
982 wxWizardPage *wizTranscodeCodecPage::GetNext() const { return p_next; }
983 void wizTranscodeCodecPage::SetPrev( wxWizardPage *page) {p_prev = page; }
986 /***************************************************
987 * First streaming page: choose method *
988 ***************************************************/
989 wizStreamingMethodPage::wizStreamingMethodPage( wxWizard *parent,
990 wxWizardPage *next) : wxWizardPage(parent)
994 p_parent = (WizardDialog *)parent;
996 mainSizer = new wxBoxSizer(wxVERTICAL);
998 /* Create the texts */
999 pageHeader( this, mainSizer, STREAMING1_TITLE, STREAMING1_TEXT );
1001 mainSizer->Add( 0,0,1 );
1005 wxStaticBox *method_box = new wxStaticBox( this, -1,
1006 wxU(_("Streaming method")) );
1007 wxStaticBoxSizer *method_sizer = new wxStaticBoxSizer(method_box,
1009 for( i = 0 ; i< 3 ; i++ )
1011 method_radios[i] = new wxRadioButton( this, MethodRadio0_Event + i,
1012 wxU( methods_array[i].psz_method ) );
1013 method_radios[i]->SetToolTip( wxU(_( methods_array[i].psz_descr ) ) );
1014 method_sizer->Add( method_radios[i], 0, wxALL, 5 );
1017 method_sizer->Layout();
1019 wxStaticBox *address_box = new wxStaticBox( this, -1,
1020 wxU(_("Destination")) );
1022 address_sizer = new wxStaticBoxSizer(address_box,
1025 /* Big kludge, we take the longest text to get the size */
1026 address_text = new wxStaticText(this, -1,
1027 wxU( vlc_wraptext(methods_array[2].psz_address,
1028 TEXTWIDTH, false ) ),
1029 wxDefaultPosition, wxDefaultSize );
1031 address_txtctrl = new wxTextCtrl( this, -1, wxU(""), wxDefaultPosition,
1033 address_sizer->Add( address_text, 0, wxALL, 5 );
1034 address_sizer->Add( address_txtctrl, 0, wxALL, 5 );
1035 address_sizer->Layout();
1037 /* Set the minimum size */
1038 address_sizer->SetMinSize( address_sizer->GetSize() );
1039 address_text->SetLabel( wxU(
1040 vlc_wraptext( _(methods_array[0].psz_address), TEXTWIDTH, false)));
1042 mainSizer->Add( method_sizer, 0, wxALL | wxEXPAND, 5 );
1043 mainSizer->Add( address_sizer, 0, wxALL | wxEXPAND, 5 );
1045 mainSizer->Add( 0,0,1 );
1047 mainSizer->Layout();
1049 SetSizer(mainSizer);
1050 mainSizer->Fit(this);
1055 void wizStreamingMethodPage::OnWizardPageChanging(wxWizardEvent& event)
1058 if( !event.GetDirection() ) return;
1060 /* Check valid address */
1061 if( i_method == 1 && !ismult((char *) address_txtctrl->GetValue().c_str()) )
1063 wxMessageBox( wxU( INVALID_MCAST_ADDRESS ) , wxU( ERROR_MSG ),
1064 wxICON_WARNING | wxOK, this->p_parent );
1068 else if( i_method == 0 && address_txtctrl->GetValue().IsEmpty() )
1070 wxMessageBox( wxU( NO_ADDRESS ) , wxU( ERROR_MSG ),
1071 wxICON_WARNING | wxOK, this->p_parent );
1076 ((wizEncapPage *)GetNext())->SetPrev(this);
1077 for( i = 0 ; i< MUXERS_NUMBER ; i++ )
1079 if( methods_array[i_method].muxers[i] != -1 )
1081 ((wizEncapPage*)GetNext())->EnableEncap(
1082 methods_array[i_method].muxers[i] );
1085 p_parent->SetStream( methods_array[i_method].psz_access ,
1086 (char *)address_txtctrl->GetValue().c_str() );
1088 /* Set the action for the muxer page */
1089 ((wizEncapPage*)GetNext())->SetAction( p_parent->GetAction() );
1093 wxWizardPage *wizStreamingMethodPage::GetPrev() const { return p_prev; }
1094 wxWizardPage *wizStreamingMethodPage::GetNext() const { return p_next; }
1096 void wizStreamingMethodPage::SetPrev( wxWizardPage *page) {p_prev = page; }
1099 void wizStreamingMethodPage::OnMethodChange(wxEvent& event)
1101 i_method = event.GetId() - MethodRadio0_Event;
1102 address_text->SetLabel( wxU(
1103 vlc_wraptext( _(methods_array[i_method].psz_address), TEXTWIDTH, false)));
1106 /***************************************************
1107 * Choose encapsulation format *
1108 ***************************************************/
1109 wizEncapPage::wizEncapPage( wxWizard *parent ) : wxWizardPage(parent)
1113 p_parent = (WizardDialog *)parent;
1114 p_streaming_page = NULL;
1115 p_transcode_page = NULL;
1117 wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
1119 /* Create the texts */
1120 pageHeader( this, mainSizer, ENCAP_TITLE, ENCAP_TEXT );
1122 mainSizer->Add( 0,0,1 );
1124 for( i = 0 ; i< MUXERS_NUMBER ; i++ )
1126 encap_radios[i] = new wxRadioButton( this, EncapRadio0_Event + i,
1127 wxU( encaps_array[i].psz_encap ) );
1128 encap_radios[i]->SetToolTip( wxU(_( encaps_array[i].psz_descr ) ) );
1129 mainSizer->Add( encap_radios[i], 0, wxLEFT, 5 );
1130 encap_radios[i]->Disable();
1133 mainSizer->Add( 0,0,1 );
1135 SetSizer(mainSizer);
1136 mainSizer->Fit(this);
1139 wizEncapPage::~wizEncapPage()
1143 void wizEncapPage::OnWizardPageChanging(wxWizardEvent& event)
1146 if( !event.GetDirection() )
1148 for( i = 0 ; i< MUXERS_NUMBER ; i++ )
1150 encap_radios[i]->Disable();
1153 p_parent->SetMux( encaps_array[i_mux].psz_mux );
1155 if( p_parent->GetAction() == ACTION_STREAM )
1157 if( strstr( p_parent->method, "udp" ))
1159 ((wizStreamingExtraPage *)GetNext())->sap_checkbox->Enable();
1160 ((wizStreamingExtraPage *)GetNext())->sap_text->Enable(false);
1164 ((wizStreamingExtraPage *)GetNext())->sap_checkbox->Enable( false );
1165 ((wizStreamingExtraPage *)GetNext())->sap_text->Enable( false );
1173 void wizEncapPage::OnEncapChange(wxEvent& event)
1175 i_mux = event.GetId() - EncapRadio0_Event;
1178 void wizEncapPage::EnableEncap( int encap )
1181 for( i = 0 ; i< MUXERS_NUMBER ; i++)
1183 if( encaps_array[i].id == encap )
1185 encap_radios[i]->Enable();
1186 encap_radios[i]->SetValue(true);
1192 void wizEncapPage::SetStreamingPage( wxWizardPage *page)
1194 p_streaming_page = page;
1197 void wizEncapPage::SetTranscodePage( wxWizardPage *page)
1199 p_transcode_page = page;
1202 wxWizardPage *wizEncapPage::GetPrev() const { return p_prev; }
1204 wxWizardPage *wizEncapPage::GetNext() const
1206 if( i_action== ACTION_STREAM )
1207 return p_streaming_page;
1209 return p_transcode_page;
1212 void wizEncapPage::SetAction( int i_act ) { i_action = i_act; }
1214 void wizEncapPage::SetPrev( wxWizardPage *page) { p_prev = page; }
1216 /***************************************************
1217 * Extra transcoding page : Select file *
1218 ***************************************************/
1219 wizTranscodeExtraPage::wizTranscodeExtraPage( wxWizard *parent,
1221 wxWizardPage *next) : wxWizardPage(parent)
1225 p_parent = (WizardDialog *) parent;
1226 wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
1228 /* Create the texts */
1229 pageHeader( this, mainSizer, EXTRATRANSCODE_TITLE, EXTRATRANSCODE_TEXT );
1231 mainSizer->Add( 0, 0, 1 );
1233 wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 2, 1 );
1234 sizer->Add( new wxStaticText( this, -1,
1235 wxU(_("Select the file to save to") ) ),
1237 sizer->Add( 0, 0, 1 );
1239 file_text = new wxTextCtrl( this, -1, wxU(""), wxDefaultPosition,
1240 wxSize( 150, -1 ) );
1242 sizer->Add( file_text, 0, wxALL, 5 );
1243 sizer->Add( new wxButton( this, Open_Event, wxU("Choose") ) );
1245 mainSizer->Add( sizer, 0, 0, 0) ;
1247 mainSizer->Add( 0, 0, 1 );
1248 SetSizer(mainSizer);
1249 mainSizer->Fit(this);
1252 void wizTranscodeExtraPage::OnSelectFile( wxCommandEvent &event)
1254 wxFileDialog *file_dialog = new wxFileDialog( this, wxU(_("Open File")),
1255 wxT(""), wxT(""), wxT("*"), wxSAVE );
1257 if( file_dialog && file_dialog->ShowModal() == wxID_OK )
1259 if( file_dialog->GetFilename().mb_str() )
1261 file_text->SetValue( file_dialog->GetFilename() );
1266 void wizTranscodeExtraPage::OnWizardPageChanging( wxWizardEvent& event )
1268 if( event.GetDirection() && file_text->GetValue().IsEmpty() )
1270 wxMessageBox( wxU( CHOOSE_OUTFILE ), wxU( ERROR_MSG ),
1271 wxICON_WARNING | wxOK, this->p_parent );
1274 if( event.GetDirection() )
1276 p_parent->SetTranscodeOut( (char *)file_text->GetValue().mb_str());
1280 wxWizardPage *wizTranscodeExtraPage::GetPrev() const { return p_prev; }
1281 wxWizardPage *wizTranscodeExtraPage::GetNext() const {return p_next; }
1283 /***********************************************************
1284 * Extra streaming page
1285 ***********************************************************/
1286 wizStreamingExtraPage::wizStreamingExtraPage( wxWizard *parent,
1288 wxWizardPage *next) : wxWizardPage(parent)
1292 p_parent = (WizardDialog *) parent;
1293 wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
1295 /* Create the texts */
1296 pageHeader( this, mainSizer, EXTRASTREAMING_TITLE, EXTRASTREAMING_TEXT );
1298 mainSizer->Add( 0, 0, 1 );
1300 wxFlexGridSizer *sizer = new wxFlexGridSizer( 2,2,1) ;
1303 sizer->Add( new wxStaticText( this, -1, wxU(_("Time-To-Live (TTL)"))),
1305 ttl_spin = new wxSpinCtrl( this, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize,
1307 ttl_spin->SetToolTip(wxU(_(TTL) ) ) ;
1308 sizer->Add( ttl_spin, 0, wxALL , 5 );
1311 sap_checkbox = new wxCheckBox( this, SAP_Event, wxU(_("SAP Announce")) );
1312 sap_checkbox->SetToolTip( wxU(_( SAP ) ) );
1313 sizer->Add( sap_checkbox, 0, 0 , 0 );
1314 sap_text = new wxTextCtrl( this, -1, wxU(""), wxDefaultPosition,
1316 sap_text->SetToolTip( wxU(_( SAP ) ) );
1317 sizer->Add( sap_text, 0, wxALL , 5 );
1319 mainSizer->Add(sizer, 0, wxALL, 5 );
1321 mainSizer->Add( 0, 0, 1 );
1323 SetSizer(mainSizer);
1324 mainSizer->Fit(this);
1327 void wizStreamingExtraPage::OnSAP( wxCommandEvent &event )
1329 sap_text->Enable( event.IsChecked() );
1332 void wizStreamingExtraPage::OnWizardPageChanging(wxWizardEvent& event)
1334 if( sap_checkbox->IsChecked() )
1336 if( sap_text->GetValue().IsEmpty() )
1338 p_parent->SetSAP( true, NULL );
1342 p_parent->SetSAP( true,
1343 (const char *)sap_text->GetValue().mb_str() );
1348 p_parent->SetSAP( false, NULL );
1351 p_parent->SetTTL( ttl_spin->GetValue() );
1354 wxWizardPage *wizStreamingExtraPage::GetPrev() const { return p_prev; }
1355 wxWizardPage *wizStreamingExtraPage::GetNext() const {return p_next; }
1358 /***************************************************************************
1359 * Implementation of the wizard itself
1360 ***************************************************************************/
1361 wizHelloPage *page1;
1362 wizInputPage *page2 ;
1363 wizTranscodeCodecPage *tr_page1 ;
1364 wizStreamingMethodPage *st_page1;
1365 wizTranscodeExtraPage *tr_page2 ;
1366 wizStreamingExtraPage *st_page2;
1367 wizEncapPage *encap_page;
1369 WizardDialog::WizardDialog(intf_thread_t *_p_intf, wxWindow *_p_parent,
1370 char *psz_uri, int _i_from, int _i_to ) :
1371 wxWizard( _p_parent, -1, wxU(_("Streaming/Transcoding Wizard")), wxNullBitmap, wxDefaultPosition)
1373 /* Initializations */
1375 SetPageSize(wxSize(400,420));
1377 /* Initialize structure */
1387 page1 = new wizHelloPage(this);
1388 page2 = new wizInputPage(this, page1, p_intf);
1392 page2->SetUri( psz_uri );
1394 if( i_from != 0 || i_to != 0 )
1396 page2->SetPartial( i_from, i_to );
1399 encap_page = new wizEncapPage(this );
1400 tr_page1 = new wizTranscodeCodecPage(this, encap_page );
1401 st_page1 = new wizStreamingMethodPage(this, encap_page);
1403 tr_page2 = new wizTranscodeExtraPage(this, encap_page, NULL );
1404 st_page2 = new wizStreamingExtraPage(this, encap_page, NULL );
1407 page1->SetNext( page2 );
1408 /* 2->1 in constructor of 2 */
1411 page2->SetTranscodePage(tr_page1);
1412 page2->SetStreamingPage(st_page1);
1413 page2->SetPintf( p_intf );
1414 tr_page1->SetPrev(page2);
1415 st_page1->SetPrev(page2);
1418 encap_page->SetTranscodePage( tr_page2 );
1419 encap_page->SetStreamingPage( st_page2 );
1420 /* 3->4 in constructor of 3 */
1421 // encap_page->SetPrev(tr_page1);
1424 WizardDialog::~WizardDialog()
1436 void WizardDialog::SetMrl( const char *mrl )
1438 this->mrl = strdup( mrl );
1441 void WizardDialog::SetTTL( int i_ttl )
1443 this->i_ttl = i_ttl;
1446 void WizardDialog::SetSAP( bool b_enabled, const char *psz_text )
1448 this->b_sap = b_enabled;
1451 if( psz_text != NULL )
1453 this->psz_sap_name = strdup( psz_text );
1457 this->psz_sap_name = NULL;
1462 void WizardDialog::SetPartial( int i_from, int i_to )
1464 this->i_from = i_from;
1468 void WizardDialog::SetTranscode( char *vcodec, int vb, char *acodec,int ab)
1470 if( strcmp( vcodec, "dummy") )
1472 this->vcodec= strdup(vcodec);
1474 if( strcmp( acodec, "dummy" ) )
1476 this->acodec = strdup(acodec);
1482 void WizardDialog::SetStream( char *method, char *address )
1484 this->method = strdup( method );
1485 this->address = strdup( address );
1488 void WizardDialog::SetTranscodeOut( char *address )
1490 this->address = strdup( address );
1493 void WizardDialog::SetMux( char *mux )
1495 this->mux = strdup( mux );
1498 void WizardDialog::SetAction( int i_action )
1500 this->i_action = i_action;
1503 int WizardDialog::GetAction()
1508 void WizardDialog::Run()
1510 msg_Dbg( p_intf,"starting wizard");
1511 if( RunWizard(page1) )
1515 msg_Dbg( p_intf,"wizard completed");
1517 if( i_action == ACTION_TRANSCODE )
1519 msg_Dbg( p_intf,"Starting transcode of %s to file %s",
1521 msg_Dbg( p_intf,"Using %s (%i kbps) / %s (%i kbps),encap %s",
1522 vcodec,vb,acodec,ab,mux);
1523 int i_tr_size = 0 ; /* 10 = ab + vb */
1524 i_tr_size += vcodec ? strlen(vcodec) + strlen("vcodec=") +strlen("vb="): 0;
1525 i_tr_size += acodec ? strlen(acodec) + strlen("acodec=") +strlen("ab=") : 0;
1527 char *psz_transcode = (char *)malloc( i_tr_size * sizeof(char));
1528 if( vcodec || acodec )
1530 sprintf( psz_transcode, "transcode{" );
1534 snprintf( psz_transcode, 1 , "%c", 0 );
1538 i_tr_size += 5 + strlen(vcodec);
1539 snprintf( psz_transcode, i_tr_size , "%svcodec=%s,vb=%i",
1540 psz_transcode, vcodec, vb );
1544 i_tr_size += 6 + strlen(acodec);
1546 sprintf( psz_transcode, "%s%cacodec=%s,ab=%i",
1547 psz_transcode, vcodec ? ',' : ' ', acodec, ab );
1549 if( vcodec || acodec )
1552 sprintf( psz_transcode , "%s}:", psz_transcode );
1554 i_size = 73 + strlen(mux) + strlen(address) + strlen(psz_transcode);
1555 psz_opt = (char *)malloc( i_size * sizeof(char) );
1556 snprintf( psz_opt, i_size, ":sout=#%sstandard{mux=%s,url=%s,"
1558 psz_transcode, mux, address );
1562 msg_Dbg( p_intf, "Starting stream of %s to %s using %s, encap %s",
1563 mrl, address, method, mux);
1566 char *psz_sap_option = NULL;
1569 psz_sap_option = (char *) malloc( strlen( psz_sap_name )
1571 snprintf( psz_sap_option,strlen( psz_sap_name ) + 15,
1572 "sap,name=\"%s\"",psz_sap_name );
1576 psz_sap_option = (char *) malloc( 5 );
1577 snprintf( psz_sap_option, 5, "sap" );
1579 i_size = 40 + strlen(mux) + strlen(address) +
1580 strlen( psz_sap_option);
1581 psz_opt = (char *)malloc( i_size * sizeof(char) );
1582 snprintf( psz_opt, i_size,
1583 ":sout=#standard{mux=%s,url=%s,access=%s,%s}",
1584 mux, address,method, psz_sap_option);
1585 msg_Dbg( p_intf, "Sap enabled: %s", psz_sap_option);
1586 if( psz_sap_option ) free( psz_sap_option );
1590 i_size = 40 + strlen(mux) + strlen(address);
1591 psz_opt = (char *)malloc( i_size * sizeof(char) );
1592 snprintf( psz_opt, i_size,
1593 ":sout=#standard{mux=%s,url=%s,access=%s}",
1594 mux, address,method);
1598 playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,
1599 VLC_OBJECT_PLAYLIST, FIND_ANYWHERE);
1602 playlist_item_t *p_item = playlist_ItemNew( p_playlist, mrl,
1604 playlist_ItemAddOption( p_item, psz_opt);
1608 msg_Dbg( p_intf, "Setting starttime");
1609 snprintf( psz_from, 20, "start-time=%i", i_from);
1610 playlist_ItemAddOption( p_item, psz_from);
1615 snprintf( psz_to, 20, "stop-time=%i", i_to);
1616 playlist_ItemAddOption( p_item, psz_to);
1620 snprintf( psz_ttl, 20, "ttl=%i",i_ttl );
1621 playlist_ItemAddOption( p_item, psz_ttl );
1623 playlist_AddItem( p_playlist, p_item, PLAYLIST_GO, PLAYLIST_END );
1624 vlc_object_release(p_playlist);
1628 wxMessageBox( wxU( NO_PLAYLIST ), wxU( ERROR_MSG ),
1629 wxICON_WARNING | wxOK, this );
1634 msg_Dbg( p_intf, "wizard was cancelled");
1637 /****************************************************************
1638 * Local helper functions
1639 ****************************************************************/
1640 static int ismult( char *psz_uri )
1645 i_value = strtol( psz_uri, &psz_end, 0 );
1647 if( psz_uri[0] == '[')
1649 if( strncasecmp( &psz_uri[1], "FF0" , 3) ||
1650 strncasecmp( &psz_uri[2], "FF0" , 3))
1653 return( VLC_FALSE );
1655 if( *psz_end != '.' ) { return( VLC_FALSE ); }
1657 return( i_value < 224 ? VLC_FALSE : VLC_TRUE );