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 <stdlib.h> /* malloc(), free() */
28 #include <errno.h> /* ENOMEM */
29 #include <string.h> /* strerror() */
35 #include "wxwidgets.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( wxCommandEvent& 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( wxCommandEvent& 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;
242 wxWizardPage *p_prev;
243 wxWizardPage *p_streaming_page;
244 wxWizardPage *p_transcode_page;
246 DECLARE_EVENT_TABLE()
249 BEGIN_EVENT_TABLE(wizInputPage, wxWizardPage)
250 EVT_RADIOBUTTON( InputRadio0_Event, wizInputPage::OnInputChange)
251 EVT_RADIOBUTTON( InputRadio1_Event, wizInputPage::OnInputChange)
252 EVT_BUTTON( Choose_Event, wizInputPage::OnChoose)
253 EVT_CHECKBOX( PartialEnable_Event, wizInputPage::OnEnablePartial)
254 EVT_WIZARD_PAGE_CHANGING(-1, wizInputPage::OnWizardPageChanging)
258 class wizTranscodeCodecPage : public wxWizardPage
261 wizTranscodeCodecPage( wxWizard *parent, wxWizardPage *next);
262 ~wizTranscodeCodecPage();
263 void wizTranscodeCodecPage::OnWizardPageChanging(wxWizardEvent& event);
264 virtual wxWizardPage *GetPrev() const;
265 virtual wxWizardPage *GetNext() const;
266 void SetPrev( wxWizardPage *page);
268 wxCheckBox *video_checkbox;
269 wxComboBox *video_combo;
270 wxComboBox *vb_combo;
271 wxStaticText * video_text;
272 wxCheckBox *audio_checkbox;
273 wxComboBox *audio_combo;
274 wxComboBox *ab_combo;
275 wxStaticText * audio_text;
277 WizardDialog *p_parent;
284 wxWizardPage *p_prev;
285 wxWizardPage *p_next;
287 void OnVideoCodecChange(wxCommandEvent& event);
288 void OnAudioCodecChange(wxCommandEvent& event);
289 void OnEnableVideo(wxCommandEvent& event);
290 void OnEnableAudio(wxCommandEvent& event);
292 DECLARE_EVENT_TABLE()
295 BEGIN_EVENT_TABLE(wizTranscodeCodecPage, wxWizardPage)
296 EVT_CHECKBOX( VideoEnable_Event, wizTranscodeCodecPage::OnEnableVideo)
297 EVT_CHECKBOX( AudioEnable_Event, wizTranscodeCodecPage::OnEnableAudio)
298 EVT_COMBOBOX( VideoCodec_Event, wizTranscodeCodecPage::OnVideoCodecChange)
299 EVT_COMBOBOX( AudioCodec_Event, wizTranscodeCodecPage::OnAudioCodecChange)
300 EVT_WIZARD_PAGE_CHANGING(-1, wizTranscodeCodecPage::OnWizardPageChanging)
303 class wizStreamingMethodPage : public wxWizardPage
306 wizStreamingMethodPage( wxWizard *parent, wxWizardPage *next);
307 void OnWizardPageChanging(wxWizardEvent& event);
308 virtual wxWizardPage *GetPrev() const;
309 virtual wxWizardPage *GetNext() const;
310 void SetPrev( wxWizardPage *page);
312 DECLARE_EVENT_TABLE()
314 wxBoxSizer *mainSizer;
315 wxStaticBoxSizer *address_sizer;
316 wxStaticText *address_text;
317 wxTextCtrl *address_txtctrl;
318 WizardDialog * p_parent;
319 void OnMethodChange( wxCommandEvent& event );
320 wxRadioButton *method_radios[4];
321 wxWizardPage *p_prev;
322 wxWizardPage *p_next;
325 BEGIN_EVENT_TABLE(wizStreamingMethodPage, wxWizardPage)
326 EVT_RADIOBUTTON( MethodRadio0_Event, wizStreamingMethodPage::OnMethodChange)
327 EVT_RADIOBUTTON( MethodRadio1_Event, wizStreamingMethodPage::OnMethodChange)
328 EVT_RADIOBUTTON( MethodRadio2_Event, wizStreamingMethodPage::OnMethodChange)
329 EVT_RADIOBUTTON( MethodRadio3_Event, wizStreamingMethodPage::OnMethodChange)
330 EVT_WIZARD_PAGE_CHANGING(-1, wizStreamingMethodPage::OnWizardPageChanging)
334 class wizEncapPage : public wxWizardPage
337 wizEncapPage( wxWizard *parent);
338 wizEncapPage::~wizEncapPage();
339 void OnWizardPageChanging(wxWizardEvent& event);
340 virtual wxWizardPage *GetPrev() const;
341 virtual wxWizardPage *GetNext() const;
342 void SetStreamingPage( wxWizardPage *page);
343 void SetTranscodePage( wxWizardPage *page);
344 void SetPrev( wxWizardPage *page);
345 void SetAction( int );
346 void EnableEncap( int encap );
348 DECLARE_EVENT_TABLE()
352 void OnEncapChange( wxCommandEvent& event );
353 wxRadioButton *encap_radios[MUXERS_NUMBER];
354 WizardDialog *p_parent;
355 wxWizardPage *p_prev;
356 wxWizardPage *p_streaming_page;
357 wxWizardPage *p_transcode_page;
360 BEGIN_EVENT_TABLE(wizEncapPage, wxWizardPage)
361 EVT_WIZARD_PAGE_CHANGING(-1, wizEncapPage::OnWizardPageChanging)
362 EVT_RADIOBUTTON( EncapRadio0_Event, wizEncapPage::OnEncapChange)
363 EVT_RADIOBUTTON( EncapRadio1_Event, wizEncapPage::OnEncapChange)
364 EVT_RADIOBUTTON( EncapRadio2_Event, wizEncapPage::OnEncapChange)
365 EVT_RADIOBUTTON( EncapRadio3_Event, wizEncapPage::OnEncapChange)
366 EVT_RADIOBUTTON( EncapRadio4_Event, wizEncapPage::OnEncapChange)
367 EVT_RADIOBUTTON( EncapRadio5_Event, wizEncapPage::OnEncapChange)
368 EVT_RADIOBUTTON( EncapRadio6_Event, wizEncapPage::OnEncapChange)
369 EVT_RADIOBUTTON( EncapRadio7_Event, wizEncapPage::OnEncapChange)
370 EVT_RADIOBUTTON( EncapRadio8_Event, wizEncapPage::OnEncapChange)
371 EVT_RADIOBUTTON( EncapRadio9_Event, wizEncapPage::OnEncapChange)
372 EVT_RADIOBUTTON( EncapRadio10_Event, wizEncapPage::OnEncapChange)
375 /* Additional settings for transcode */
376 class wizTranscodeExtraPage : public wxWizardPage
379 wizTranscodeExtraPage( wxWizard *parent, wxWizardPage *prev,
381 virtual wxWizardPage *GetPrev() const;
382 virtual wxWizardPage *GetNext() const;
383 void OnWizardPageChanging( wxWizardEvent& event );
385 DECLARE_EVENT_TABLE()
386 void wizTranscodeExtraPage::OnSelectFile(wxCommandEvent&);
387 wxTextCtrl *file_text;
388 WizardDialog *p_parent;
389 wxWizardPage *p_prev;
390 wxWizardPage *p_next;
393 BEGIN_EVENT_TABLE(wizTranscodeExtraPage, wxWizardPage)
394 EVT_BUTTON( Open_Event, wizTranscodeExtraPage::OnSelectFile)
395 EVT_WIZARD_PAGE_CHANGING(-1, wizTranscodeExtraPage::OnWizardPageChanging)
398 /* Additional settings for streaming */
399 class wizStreamingExtraPage : public wxWizardPage
402 wizStreamingExtraPage( wxWizard *parent, wxWizardPage *prev,
404 virtual wxWizardPage *GetPrev() const;
405 virtual wxWizardPage *GetNext() const;
406 void OnWizardPageChanging(wxWizardEvent&);
407 void OnSAP( wxCommandEvent&);
408 wxCheckBox *sap_checkbox;
409 wxTextCtrl *sap_text;
411 friend class wizEncapPage;
412 DECLARE_EVENT_TABLE()
413 WizardDialog *p_parent;
414 wxWizardPage *p_prev;
415 wxWizardPage *p_next;
417 wxSpinCtrl *ttl_spin;
420 BEGIN_EVENT_TABLE(wizStreamingExtraPage, wxWizardPage)
421 EVT_CHECKBOX( SAP_Event, wizStreamingExtraPage::OnSAP )
422 EVT_WIZARD_PAGE_CHANGING(-1, wizStreamingExtraPage::OnWizardPageChanging)
426 /* Local functions */
427 static int ismult( const char *psz_uri );
429 static void pageHeader( wxWindow *window, wxBoxSizer *sizer,
430 char *psz_title, char *psz_text);
432 static void pageHeader( wxWindow *window, wxBoxSizer *sizer,
433 char *psz_title, char *psz_text)
435 wxStaticText *wtitle = new wxStaticText( window, -1, wxU( psz_title ) );
436 wxFont font = wtitle->GetFont();
437 font.SetPointSize(14);
438 wtitle->SetFont(font);
439 sizer->Add( wtitle, 0, wxALL, 5 );
440 sizer->Add( new wxStaticText( window, -1,
441 wxU( vlc_wraptext( psz_text , TEXTWIDTH, false ) ) ),
445 /***************************************************************************
446 * Implementation of the pages
447 ***************************************************************************/
450 /***************************************************
451 * First page: choose between stream and transcode *
452 ***************************************************/
453 wizHelloPage::wizHelloPage( wxWizard *parent) : wxWizardPageSimple(parent)
456 p_parent = (WizardDialog *)parent;
457 wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
459 /* Create the texts */
460 pageHeader( this, mainSizer, HELLO_TITLE, HELLO_TEXT );
462 /* Create the radio buttons with their helps */
463 action_radios[0] = new wxRadioButton( this, ActionRadio0_Event,
464 wxU( HELLO_STREAMING ) );
465 action_radios[1] = new wxRadioButton( this, ActionRadio1_Event,
466 wxU( HELLO_TRANSCODE ) );
469 mainSizer->Add( 0, 0, 1 );
471 wxBoxSizer *stream_sizer = new wxBoxSizer( wxHORIZONTAL );
472 stream_sizer->Add( action_radios[0], 0, wxALL, 5 );
473 stream_sizer->Add( 0,0,1 );
474 stream_sizer->Add( new wxButton( this, MoreInfoStreaming_Event,
475 wxU( _("More Info")) ), 0, 0, 0 );
476 mainSizer->Add( stream_sizer, 0, wxALL | wxEXPAND , 5 );
478 wxBoxSizer *transcode_sizer = new wxBoxSizer( wxHORIZONTAL );
479 transcode_sizer->Add( action_radios[1], 0, wxALL, 5 );
480 transcode_sizer->Add( 0,0,1);
481 transcode_sizer->Add( new wxButton( this, MoreInfoTranscode_Event,
482 wxU( _("More Info")) ), 0 , 0 , 0 );
483 mainSizer->Add( transcode_sizer, 0, wxALL | wxEXPAND, 5 );
485 mainSizer->Add( 0, 0, 1 );
487 mainSizer->Add( new wxStaticLine(this, -1 ), 0, wxEXPAND| wxTOP|
490 mainSizer->Add( new wxStaticText(this, -1,
491 wxU( vlc_wraptext(HELLO_NOTICE , TEXTWIDTH , false ))),
495 mainSizer->Fit(this);
498 void wizHelloPage::OnMoreInfo(wxCommandEvent& event)
501 msg.Printf( wxString( wxU( event.GetId() == MoreInfoStreaming_Event ?
503 MOREINFO_TRANSCODE ) ) );
504 wxMessageBox( msg, wxU(_("More information")),
505 wxOK | wxICON_INFORMATION, this->p_parent );
508 void wizHelloPage::OnActionChange( wxCommandEvent& event )
510 i_action = event.GetId() - ActionRadio0_Event;
511 ((wizInputPage *)GetNext())->SetAction( i_action );
512 p_parent->SetAction( i_action );
515 void wizHelloPage::OnWizardPageChanging(wxWizardEvent& event)
517 ((wizInputPage *)GetNext())->SetAction( i_action );
518 p_parent->SetAction( i_action );
521 /************************************
522 * Second page: choose input stream *
523 ************************************/
524 wizInputPage::wizInputPage( wxWizard *parent, wxWizardPage *prev, intf_thread_t *_p_intf) :
529 p_parent = (WizardDialog *)parent;
531 p_open_dialog = NULL;
533 mainSizer = new wxBoxSizer(wxVERTICAL);
535 /* Create the texts */
536 pageHeader( this, mainSizer, INPUT_TITLE, INPUT_TEXT );
538 mainSizer->Add( 0,20,0 );
540 /* Create the radio buttons */
541 input_radios[0] = new wxRadioButton( this, InputRadio0_Event ,
543 mainSizer->Add( input_radios[0], 0, wxALL, 5 );
544 input_radios[1] = new wxRadioButton( this, InputRadio1_Event ,
547 mainSizer->Add( input_radios[1], 0, wxALL, 5 );
550 open_panel = new wxPanel(this, -1);
551 open_panel->SetAutoLayout( TRUE );
552 wxBoxSizer *openSizer = new wxBoxSizer(wxHORIZONTAL);
554 mrl_text = new wxTextCtrl( open_panel, -1, wxU( "" ), wxDefaultPosition,
556 openSizer->Add( mrl_text, 0 , wxALL, 5 );
557 openSizer->Add( new wxButton( open_panel, Choose_Event, wxU(_("Choose...")) ), 0, wxALL, 5 );
558 open_panel->SetSizer( openSizer );
560 openSizer->Fit(open_panel);
562 mainSizer->Add( open_panel );
565 playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,
566 VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
570 if( p_playlist->i_size > 0)
572 listview = new wxListView( this, ListView_Event,
573 wxDefaultPosition, wxDefaultSize,
574 wxLC_REPORT | wxSUNKEN_BORDER );
575 listview->InsertColumn( 0, wxU(_("Name")) );
576 listview->InsertColumn( 1, wxU(_("URI")) );
577 listview->SetColumnWidth( 0, 250 );
578 listview->SetColumnWidth( 1, 100 );
579 for( int i=0 ; i < p_playlist->i_size ; i++ )
581 wxString filename = wxL2U( p_playlist->pp_items[i]->input.
583 listview->InsertItem( i, filename );
584 listview->SetItem( i, 1, wxL2U( p_playlist->pp_items[i]->
587 listview->Select( p_playlist->i_index , TRUE);
588 mainSizer->Add( listview, 1, wxALL|wxEXPAND, 5 );
591 mainSizer->Hide( listview );
596 input_radios[1]->Disable();
598 vlc_object_release( p_playlist );
602 input_radios[1]->Disable();
605 /* Partial Extract Box */
606 mainSizer->Add( 0, 10, 0 );
607 wxStaticBox *partial_box = new wxStaticBox( this, -1,
608 wxU(_("Partial Extract")) );
610 wxStaticBoxSizer *partial_sizer = new wxStaticBoxSizer( partial_box,
613 enable_checkbox = new wxCheckBox( this, PartialEnable_Event,
615 enable_checkbox->SetToolTip(wxU(_(PARTIAL) ) ) ;
616 partial_sizer->Add( enable_checkbox, 0 , wxALIGN_CENTER_VERTICAL|wxALL, 5 ); //wxLEFT
618 wxFlexGridSizer *partial_sizer2 = new wxFlexGridSizer( 4 , 1 , 20 );
619 partial_sizer2->Add( new wxStaticText(this, -1, wxU(_( "From" ) ) ),
621 from_text = new wxTextCtrl( this, -1, wxT(""),
622 wxDefaultPosition, wxSize( 80,25 ) );
623 partial_sizer2->Add( from_text, 0 , wxALIGN_RIGHT);
624 partial_sizer2->Add( new wxStaticText(this, -1, wxU(_( "To" ) ) ),
626 to_text = new wxTextCtrl( this, -1, wxT(""),
627 wxDefaultPosition, wxSize( 80 , 25 ) );
628 partial_sizer2->Add( to_text, 0 , wxALIGN_RIGHT );
630 partial_sizer->Add( partial_sizer2, 0, wxALL, 0 );
632 partial_sizer->Fit( partial_box );
634 mainSizer->Add( partial_sizer, 0, 0, 0 );
636 from_text->Disable();
639 mainSizer->Fit(this);
643 wizInputPage::~wizInputPage()
647 void wizInputPage::OnInputChange( wxCommandEvent& event )
649 i_input = event.GetId() - InputRadio0_Event;
655 mainSizer->Hide( listview );
657 mainSizer->Show( open_panel );
664 mainSizer->Hide( open_panel );
666 mainSizer->Show( listview );
671 void wizInputPage::OnEnablePartial(wxCommandEvent& event)
673 from_text->Enable( event.IsChecked() );
674 to_text->Enable( event.IsChecked() );
678 void wizInputPage::OnChoose(wxCommandEvent& event)
680 p_open_dialog = new OpenDialog( p_intf, this, -1, -1, OPEN_STREAM );
681 if( p_open_dialog->ShowModal() == wxID_OK &&
682 !p_open_dialog->mrl.IsEmpty() )
684 mrl_text->SetValue(p_open_dialog->mrl[0] );
686 delete p_open_dialog;
687 p_open_dialog = NULL;
690 void wizInputPage::OnWizardPageChanging(wxWizardEvent& event)
694 if( mrl_text->GetValue().IsSameAs( wxT(""), TRUE ) &&
695 event.GetDirection() )
697 wxMessageBox( wxU( CHOOSE_STREAM ), wxU( ERROR_MSG ),
698 wxICON_WARNING | wxOK, this->p_parent );
704 p_parent->SetMrl( (const char *)mrl_text->GetValue().mb_str() );
711 i = listview->GetNextItem( i , wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
715 listitem.SetColumn( 1 );
716 listview->GetItem( listitem );
717 p_parent->SetMrl( (const char*) listitem.GetText().mb_str() );
720 if( enable_checkbox->IsChecked() )
722 int i_from = atoi( from_text->GetValue().mb_str() );
723 int i_to = atoi( to_text->GetValue().mb_str() );
724 p_parent->SetPartial( i_from, i_to );
729 wxWizardPage *wizInputPage::GetPrev() const { return p_prev; }
730 wxWizardPage *wizInputPage::GetNext() const
732 if( i_action == ACTION_STREAM )
733 return p_streaming_page;
735 return p_transcode_page;
738 void wizInputPage::SetStreamingPage( wxWizardPage *page)
740 p_streaming_page = page;
743 void wizInputPage::SetTranscodePage( wxWizardPage *page)
745 p_transcode_page = page;
748 void wizInputPage::SetAction( int i_action )
750 this->i_action = i_action;
753 void wizInputPage::SetPintf( intf_thread_t *p_intf )
755 this->p_intf = p_intf;
758 void wizInputPage::SetUri( char *psz_uri )
760 mrl_text->SetValue( wxU( psz_uri ) );
763 void wizInputPage::SetPartial( int i_from, int i_to )
766 msg.Printf( wxString( wxT( "%i") ), i_from );
767 from_text->Enable( TRUE );
768 from_text->SetValue( msg );
769 msg.Printf( wxString( wxT( "%i") ), i_to );
770 to_text->Enable( TRUE );
771 to_text->SetValue( msg );
772 enable_checkbox->SetValue( TRUE );
775 /***************************************************
776 * First transcode page: choose codecs *
777 ***************************************************/
778 wizTranscodeCodecPage::wizTranscodeCodecPage( wxWizard *parent,
779 wxWizardPage *next) : wxWizardPage(parent)
785 p_parent = (WizardDialog *) parent;
787 wxBoxSizer *main_sizer = new wxBoxSizer(wxVERTICAL);
790 pageHeader( this, main_sizer, TRANSCODE1_TITLE, TRANSCODE1_TEXT );
793 wxStaticBox *video_box = new wxStaticBox( this, -1, wxU(_("Video")) );
794 wxStaticBoxSizer *video_sizer = new wxStaticBoxSizer( video_box,
796 /* Line 1 : only the checkbox */
797 wxFlexGridSizer *video_sizer1 = new wxFlexGridSizer( 2,3,20 );
798 video_sizer1->Add( new wxCheckBox( this, VideoEnable_Event,
799 wxU(_("Transcode video") ) ), 0 , wxALIGN_CENTER_VERTICAL|wxALL , 5 );
800 video_sizer1->Add( 0,0,1);
802 video_sizer1->Add( new wxStaticText(this, -1, wxU(_("Codec"))),0,wxLEFT ,5);
803 video_combo = new wxComboBox( this, VideoCodec_Event, wxT(""),
804 wxDefaultPosition, wxSize(200,25), 0, NULL,
805 wxCB_DROPDOWN| wxCB_READONLY );
806 for( int i= 0; vcodecs_array[i].psz_display != NULL; i++ )
808 video_combo->Append( wxU( vcodecs_array[i].psz_display ) ,
809 (void *)&vcodecs_array[i] );
812 video_combo->SetSelection(0);
814 video_sizer1->Add( video_combo, 0 , wxALIGN_LEFT , 0 );
816 video_sizer1->Add( new wxStaticText(this, -1, wxU(_("Bitrate (kb/s)"))),0,
818 vb_combo = new wxComboBox( this, VideoBitrate_Event, wxT("1024"),
819 wxDefaultPosition, wxDefaultSize,
820 WXSIZEOF(vbitrates_array), vbitrates_array, wxCB_READONLY );
821 video_sizer1->Add( vb_combo, 0, wxALIGN_LEFT , 0 );
824 video_text = new wxStaticText( this, -1,
825 wxU( vlc_wraptext( TR_VIDEO_TEXT, TEXTWIDTH, false) ) );
826 /* Fill the main video sizer */
827 video_sizer->Add( video_sizer1 , 0, wxEXPAND , 5 );
828 video_sizer->Add( video_text, 0, wxLEFT|wxTOP , 5 );
832 wxStaticBox *audio_box = new wxStaticBox( this, -1, wxU(_("Audio")) );
833 wxStaticBoxSizer *audio_sizer = new wxStaticBoxSizer( audio_box,
836 wxFlexGridSizer *audio_sizer1 = new wxFlexGridSizer( 2,3,20);
837 audio_sizer1->Add( new wxCheckBox( this, AudioEnable_Event,
838 wxU(_("Transcode audio") ) ), 0 , wxALIGN_CENTER_VERTICAL|wxALL, 5 );
839 audio_sizer1->Add( 0, 0, 1 );
842 audio_sizer1->Add( new wxStaticText(this, -1, wxU(_("Codec"))),0,wxLEFT,5);
843 audio_combo = new wxComboBox( this, AudioCodec_Event, wxT(""),
844 wxDefaultPosition, wxSize(200,25), 0, NULL,
845 wxCB_DROPDOWN| wxCB_READONLY );
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] );
852 audio_combo->SetSelection(0);
853 audio_sizer1->Add( audio_combo, 0 , wxALIGN_LEFT, 0 );
855 audio_sizer1->Add( new wxStaticText(this, -1, wxU(_("Bitrate (kb/s)"))),0,
857 ab_combo = new wxComboBox( this, AudioBitrate_Event, wxT("192"),
858 wxDefaultPosition, wxDefaultSize,
859 WXSIZEOF(abitrates_array), abitrates_array, wxCB_READONLY );
860 audio_sizer1->Add( ab_combo, 0, wxALIGN_LEFT, 0 );
863 audio_text = new wxStaticText( this, -1,
864 wxU( vlc_wraptext( TR_AUDIO_TEXT, TEXTWIDTH, false) ) );
866 audio_sizer->Add(audio_sizer1, 0, wxEXPAND, 5);
867 audio_sizer->Add( audio_text, 0, wxLEFT | wxTOP, 5 );
869 main_sizer->Add( video_sizer, 1, wxGROW, 0 );
870 main_sizer->Add( audio_sizer, 1, wxGROW, 0 );
871 main_sizer->Layout();
872 SetSizerAndFit( main_sizer );
874 /* Default disabled */
875 video_combo->Disable(); video_text->Disable();vb_combo->Disable();
876 audio_combo->Disable(); audio_text->Disable();ab_combo->Disable();
880 wizTranscodeCodecPage::~wizTranscodeCodecPage()
882 if( acodec ) free( acodec );
883 if( vcodec ) free( vcodec );
886 void wizTranscodeCodecPage::OnEnableVideo(wxCommandEvent& event)
888 video_combo->Enable( event.IsChecked() );
889 vb_combo->Enable( event.IsChecked() );
890 video_text->Enable( event.IsChecked() );
893 void wizTranscodeCodecPage::OnEnableAudio(wxCommandEvent& event)
895 audio_combo->Enable( event.IsChecked() );
896 ab_combo->Enable( event.IsChecked() );
897 audio_text->Enable( event.IsChecked() );
900 void wizTranscodeCodecPage::OnVideoCodecChange(wxCommandEvent& event)
902 struct codec *c = (struct codec*)
903 (video_combo->GetClientData(video_combo->GetSelection()));
904 video_text->SetLabel( wxU( vlc_wraptext(c->psz_descr, TEXTWIDTH, false) ) );
905 i_video_codec = video_combo->GetSelection();
906 vcodec = strdup(c->psz_codec);
909 void wizTranscodeCodecPage::OnAudioCodecChange(wxCommandEvent& event)
911 struct codec *c = (struct codec*)
912 (audio_combo->GetClientData(audio_combo->GetSelection()));
913 audio_text->SetLabel( wxU( vlc_wraptext(c->psz_descr, TEXTWIDTH, false) ) );
914 i_audio_codec = audio_combo->GetSelection();
915 acodec = strdup(c->psz_codec);
919 void wizTranscodeCodecPage::OnWizardPageChanging(wxWizardEvent& event)
923 if( !event.GetDirection() )
929 /* Set the dummy codec ( accept all muxers ) if needed */
930 if( !video_combo->IsEnabled() )
932 i_video_codec = VCODECS_NUMBER;
934 if( !audio_combo->IsEnabled() )
936 i_audio_codec = ACODECS_NUMBER;
939 ((wizEncapPage *)GetNext())->SetPrev(this);
941 for( i = 0 ; i< MUXERS_NUMBER ; i++ )
943 if( vcodecs_array[i_video_codec].muxers[i] != -1 )
945 for( j = 0 ; j< MUXERS_NUMBER ; j++ )
947 if( acodecs_array[i_audio_codec].muxers[j] ==
948 vcodecs_array[i_video_codec].muxers[i] )
950 ((wizEncapPage*)GetNext())->EnableEncap(
951 vcodecs_array[i_video_codec].muxers[i] );
956 struct codec *c = (struct codec*)
957 (video_combo->GetClientData( video_combo->IsEnabled() ?
958 video_combo->GetSelection(): i_video_codec ));
959 vcodec = strdup(c->psz_codec);
961 (audio_combo->GetClientData( audio_combo->IsEnabled() ?
962 audio_combo->GetSelection() : i_audio_codec ));
963 acodec = strdup(c->psz_codec);
965 int vb = atoi(vb_combo->GetValue().mb_str() );
970 int ab = atoi(ab_combo->GetValue().mb_str() );
976 p_parent->SetTranscode( vcodec, vb , acodec, ab );
977 ((wizEncapPage*)GetNext())->SetAction( p_parent->GetAction() );
978 p_parent->SetAction( p_parent->GetAction() );
983 wxWizardPage *wizTranscodeCodecPage::GetPrev() const { return p_prev; }
984 wxWizardPage *wizTranscodeCodecPage::GetNext() const { return p_next; }
985 void wizTranscodeCodecPage::SetPrev( wxWizardPage *page) {p_prev = page; }
988 /***************************************************
989 * First streaming page: choose method *
990 ***************************************************/
991 wizStreamingMethodPage::wizStreamingMethodPage( wxWizard *parent,
992 wxWizardPage *next) : wxWizardPage(parent)
996 p_parent = (WizardDialog *)parent;
998 mainSizer = new wxBoxSizer(wxVERTICAL);
1000 /* Create the texts */
1001 pageHeader( this, mainSizer, STREAMING1_TITLE, STREAMING1_TEXT );
1003 mainSizer->Add( 0,50,0 );
1007 wxStaticBox *method_box = new wxStaticBox( this, -1,
1008 wxU(_("Streaming method")) );
1009 wxStaticBoxSizer *method_sizer = new wxStaticBoxSizer(method_box,
1011 for( i = 0 ; i< 3 ; i++ )
1013 method_radios[i] = new wxRadioButton( this, MethodRadio0_Event + i,
1014 wxU( methods_array[i].psz_method ) );
1015 method_radios[i]->SetToolTip( wxU(_( methods_array[i].psz_descr ) ) );
1016 method_sizer->Add( method_radios[i], 0, wxALL, 5 );
1019 method_sizer->Layout();
1021 wxStaticBox *address_box = new wxStaticBox( this, -1,
1022 wxU(_("Destination")) );
1024 address_sizer = new wxStaticBoxSizer(address_box,
1027 /* Big kludge, we take the longest text to get the size */
1028 address_text = new wxStaticText(this, -1,
1029 wxU( vlc_wraptext(methods_array[2].psz_address,
1030 TEXTWIDTH, false ) ),
1031 wxDefaultPosition, wxDefaultSize );
1033 address_txtctrl = new wxTextCtrl( this, -1, wxU(""), wxDefaultPosition,
1035 address_sizer->Add( address_text, 0, wxALL, 5 );
1036 address_sizer->Add( address_txtctrl, 0, wxALL, 5 );
1037 address_sizer->Layout();
1039 /* Set the minimum size */
1040 address_sizer->SetMinSize( address_sizer->GetSize() );
1041 address_text->SetLabel( wxU(
1042 vlc_wraptext( _(methods_array[0].psz_address), TEXTWIDTH, false)));
1044 mainSizer->Add( method_sizer, 0, wxALL | wxEXPAND, 5 );
1045 mainSizer->Add( address_sizer, 0, wxALL | wxEXPAND, 5 );
1047 mainSizer->Add( 0,0,1 );
1049 mainSizer->Layout();
1051 SetSizer(mainSizer);
1052 mainSizer->Fit(this);
1057 void wizStreamingMethodPage::OnWizardPageChanging(wxWizardEvent& event)
1060 if( !event.GetDirection() ) return;
1062 /* Check valid address */
1063 if( i_method == 1 && !ismult( address_txtctrl->GetValue().mb_str()) )
1065 wxMessageBox( wxU( INVALID_MCAST_ADDRESS ) , wxU( ERROR_MSG ),
1066 wxICON_WARNING | wxOK, this->p_parent );
1070 else if( i_method == 0 && address_txtctrl->GetValue().IsEmpty() )
1072 wxMessageBox( wxU( NO_ADDRESS ) , wxU( ERROR_MSG ),
1073 wxICON_WARNING | wxOK, this->p_parent );
1078 ((wizEncapPage *)GetNext())->SetPrev(this);
1079 for( i = 0 ; i< MUXERS_NUMBER ; i++ )
1081 if( methods_array[i_method].muxers[i] != -1 )
1083 ((wizEncapPage*)GetNext())->EnableEncap(
1084 methods_array[i_method].muxers[i] );
1087 p_parent->SetStream( methods_array[i_method].psz_access ,
1088 address_txtctrl->GetValue().mb_str() );
1090 /* Set the action for the muxer page */
1091 ((wizEncapPage*)GetNext())->SetAction( p_parent->GetAction() );
1095 wxWizardPage *wizStreamingMethodPage::GetPrev() const { return p_prev; }
1096 wxWizardPage *wizStreamingMethodPage::GetNext() const { return p_next; }
1098 void wizStreamingMethodPage::SetPrev( wxWizardPage *page) {p_prev = page; }
1101 void wizStreamingMethodPage::OnMethodChange( wxCommandEvent& event )
1103 i_method = event.GetId() - MethodRadio0_Event;
1104 address_text->SetLabel( wxU(
1105 vlc_wraptext( _(methods_array[i_method].psz_address), TEXTWIDTH, false)));
1106 address_sizer->Layout();
1107 mainSizer->Layout();
1110 /***************************************************
1111 * Choose encapsulation format *
1112 ***************************************************/
1113 wizEncapPage::wizEncapPage( wxWizard *parent ) : wxWizardPage(parent)
1117 p_parent = (WizardDialog *)parent;
1118 p_streaming_page = NULL;
1119 p_transcode_page = NULL;
1121 wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
1123 /* Create the texts */
1124 pageHeader( this, mainSizer, ENCAP_TITLE, ENCAP_TEXT );
1126 mainSizer->Add( 0,0,1 );
1128 for( i = 0 ; i< MUXERS_NUMBER ; i++ )
1130 encap_radios[i] = new wxRadioButton( this, EncapRadio0_Event + i,
1131 wxU( encaps_array[i].psz_encap ) );
1132 encap_radios[i]->SetToolTip( wxU(_( encaps_array[i].psz_descr ) ) );
1133 mainSizer->Add( encap_radios[i], 0, wxLEFT, 5 );
1134 encap_radios[i]->Disable();
1137 mainSizer->Add( 0,0,1 );
1139 SetSizer(mainSizer);
1140 mainSizer->Fit(this);
1143 wizEncapPage::~wizEncapPage()
1147 void wizEncapPage::OnWizardPageChanging(wxWizardEvent& event)
1150 if( !event.GetDirection() )
1152 for( i = 0 ; i< MUXERS_NUMBER ; i++ )
1154 encap_radios[i]->Disable();
1157 p_parent->SetMux( encaps_array[i_mux].psz_mux );
1159 if( p_parent->GetAction() == ACTION_STREAM )
1161 if( strstr( p_parent->method, "udp" ))
1163 ((wizStreamingExtraPage *)GetNext())->sap_checkbox->Enable();
1164 ((wizStreamingExtraPage *)GetNext())->sap_text->Enable(false);
1168 ((wizStreamingExtraPage *)GetNext())->sap_checkbox->Enable( false );
1169 ((wizStreamingExtraPage *)GetNext())->sap_text->Enable( false );
1177 void wizEncapPage::OnEncapChange( wxCommandEvent& event )
1179 i_mux = event.GetId() - EncapRadio0_Event;
1182 void wizEncapPage::EnableEncap( int encap )
1185 for( i = 0 ; i< MUXERS_NUMBER ; i++)
1187 if( encaps_array[i].id == encap )
1189 encap_radios[i]->Enable();
1190 encap_radios[i]->SetValue(true);
1196 void wizEncapPage::SetStreamingPage( wxWizardPage *page)
1198 p_streaming_page = page;
1201 void wizEncapPage::SetTranscodePage( wxWizardPage *page)
1203 p_transcode_page = page;
1206 wxWizardPage *wizEncapPage::GetPrev() const { return p_prev; }
1208 wxWizardPage *wizEncapPage::GetNext() const
1210 if( i_action== ACTION_STREAM )
1211 return p_streaming_page;
1213 return p_transcode_page;
1216 void wizEncapPage::SetAction( int i_act ) { i_action = i_act; }
1218 void wizEncapPage::SetPrev( wxWizardPage *page) { p_prev = page; }
1220 /***************************************************
1221 * Extra transcoding page : Select file *
1222 ***************************************************/
1223 wizTranscodeExtraPage::wizTranscodeExtraPage( wxWizard *parent,
1225 wxWizardPage *next) : wxWizardPage(parent)
1229 p_parent = (WizardDialog *) parent;
1230 wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
1232 /* Create the texts */
1233 pageHeader( this, mainSizer, EXTRATRANSCODE_TITLE, EXTRATRANSCODE_TEXT );
1235 mainSizer->Add( 0, 0, 1 );
1237 wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 2, 1 );
1238 sizer->Add( new wxStaticText( this, -1,
1239 wxU(_("Select the file to save to") ) ),
1241 sizer->Add( 0, 0, 1 );
1243 file_text = new wxTextCtrl( this, -1, wxU(""), wxDefaultPosition,
1244 wxSize( 150, -1 ) );
1246 sizer->Add( file_text, 0, wxALL, 5 );
1247 sizer->Add( new wxButton( this, Open_Event, wxU("Choose") ) );
1249 mainSizer->Add( sizer, 0, 0, 0) ;
1251 mainSizer->Add( 0, 0, 1 );
1252 SetSizer(mainSizer);
1253 mainSizer->Fit(this);
1256 void wizTranscodeExtraPage::OnSelectFile( wxCommandEvent &event)
1258 wxFileDialog *file_dialog = new wxFileDialog( this, wxU(_("Open File")),
1259 wxT(""), wxT(""), wxT("*"), wxSAVE );
1261 if( file_dialog && file_dialog->ShowModal() == wxID_OK )
1263 if( file_dialog->GetFilename().mb_str() )
1265 file_text->SetValue( file_dialog->GetFilename() );
1270 void wizTranscodeExtraPage::OnWizardPageChanging( wxWizardEvent& event )
1272 if( event.GetDirection() && file_text->GetValue().IsEmpty() )
1274 wxMessageBox( wxU( CHOOSE_OUTFILE ), wxU( ERROR_MSG ),
1275 wxICON_WARNING | wxOK, this->p_parent );
1278 if( event.GetDirection() )
1280 p_parent->SetTranscodeOut( file_text->GetValue().mb_str());
1284 wxWizardPage *wizTranscodeExtraPage::GetPrev() const { return p_prev; }
1285 wxWizardPage *wizTranscodeExtraPage::GetNext() const {return p_next; }
1287 /***********************************************************
1288 * Extra streaming page
1289 ***********************************************************/
1290 wizStreamingExtraPage::wizStreamingExtraPage( wxWizard *parent,
1292 wxWizardPage *next) : wxWizardPage(parent)
1296 p_parent = (WizardDialog *) parent;
1297 wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
1299 /* Create the texts */
1300 pageHeader( this, mainSizer, EXTRASTREAMING_TITLE, EXTRASTREAMING_TEXT );
1302 mainSizer->Add( 0, 0, 1 );
1304 wxFlexGridSizer *sizer = new wxFlexGridSizer( 2,2,1) ;
1307 sizer->Add( new wxStaticText( this, -1, wxU(_("Time-To-Live (TTL)"))),
1309 ttl_spin = new wxSpinCtrl( this, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize,
1311 ttl_spin->SetToolTip(wxU(_(TTL) ) ) ;
1312 sizer->Add( ttl_spin, 0, wxALL , 5 );
1315 sap_checkbox = new wxCheckBox( this, SAP_Event, wxU(_("SAP Announce")) );
1316 sap_checkbox->SetToolTip( wxU(_( SAP ) ) );
1317 sizer->Add( sap_checkbox, 0, 0 , 0 );
1318 sap_text = new wxTextCtrl( this, -1, wxU(""), wxDefaultPosition,
1320 sap_text->SetToolTip( wxU(_( SAP ) ) );
1321 sizer->Add( sap_text, 0, wxALL , 5 );
1323 mainSizer->Add(sizer, 0, wxALL, 5 );
1325 mainSizer->Add( 0, 0, 1 );
1327 SetSizer(mainSizer);
1328 mainSizer->Fit(this);
1331 void wizStreamingExtraPage::OnSAP( wxCommandEvent &event )
1333 sap_text->Enable( event.IsChecked() );
1336 void wizStreamingExtraPage::OnWizardPageChanging(wxWizardEvent& event)
1338 if( sap_checkbox->IsChecked() )
1340 if( sap_text->GetValue().IsEmpty() )
1342 p_parent->SetSAP( true, NULL );
1346 p_parent->SetSAP( true,
1347 (const char *)sap_text->GetValue().mb_str() );
1352 p_parent->SetSAP( false, NULL );
1355 p_parent->SetTTL( ttl_spin->GetValue() );
1358 wxWizardPage *wizStreamingExtraPage::GetPrev() const { return p_prev; }
1359 wxWizardPage *wizStreamingExtraPage::GetNext() const {return p_next; }
1362 /***************************************************************************
1363 * Implementation of the wizard itself
1364 ***************************************************************************/
1365 wizHelloPage *page1;
1366 wizInputPage *page2 ;
1367 wizTranscodeCodecPage *tr_page1 ;
1368 wizStreamingMethodPage *st_page1;
1369 wizTranscodeExtraPage *tr_page2 ;
1370 wizStreamingExtraPage *st_page2;
1371 wizEncapPage *encap_page;
1373 WizardDialog::WizardDialog(intf_thread_t *_p_intf, wxWindow *_p_parent,
1374 char *psz_uri, int _i_from, int _i_to ) :
1375 wxWizard( _p_parent, -1, wxU(_("Streaming/Transcoding Wizard")), wxNullBitmap, wxDefaultPosition)
1377 /* Initializations */
1379 SetPageSize(wxSize(400,420));
1381 /* Initialize structure */
1391 page1 = new wizHelloPage(this);
1392 page2 = new wizInputPage(this, page1, p_intf);
1396 page2->SetUri( psz_uri );
1398 if( i_from != 0 || i_to != 0 )
1400 page2->SetPartial( i_from, i_to );
1403 encap_page = new wizEncapPage(this );
1404 tr_page1 = new wizTranscodeCodecPage(this, encap_page );
1405 st_page1 = new wizStreamingMethodPage(this, encap_page);
1407 tr_page2 = new wizTranscodeExtraPage(this, encap_page, NULL );
1408 st_page2 = new wizStreamingExtraPage(this, encap_page, NULL );
1411 page1->SetNext( page2 );
1412 /* 2->1 in constructor of 2 */
1415 page2->SetTranscodePage(tr_page1);
1416 page2->SetStreamingPage(st_page1);
1417 page2->SetPintf( p_intf );
1418 tr_page1->SetPrev(page2);
1419 st_page1->SetPrev(page2);
1422 encap_page->SetTranscodePage( tr_page2 );
1423 encap_page->SetStreamingPage( st_page2 );
1424 /* 3->4 in constructor of 3 */
1425 // encap_page->SetPrev(tr_page1);
1428 WizardDialog::~WizardDialog()
1440 void WizardDialog::SetMrl( const char *mrl )
1442 this->mrl = strdup( mrl );
1445 void WizardDialog::SetTTL( int i_ttl )
1447 this->i_ttl = i_ttl;
1450 void WizardDialog::SetSAP( bool b_enabled, const char *psz_text )
1452 this->b_sap = b_enabled;
1455 if( psz_text != NULL )
1457 this->psz_sap_name = strdup( psz_text );
1461 this->psz_sap_name = NULL;
1466 void WizardDialog::SetPartial( int i_from, int i_to )
1468 this->i_from = i_from;
1472 void WizardDialog::SetTranscode( char const *vcodec, int vb,
1473 char const *acodec, int ab)
1475 if( strcmp( vcodec, "dummy") )
1477 this->vcodec= strdup(vcodec);
1479 if( strcmp( acodec, "dummy" ) )
1481 this->acodec = strdup(acodec);
1487 void WizardDialog::SetStream( char const *method, char const *address )
1489 this->method = strdup( method );
1490 this->address = strdup( address );
1493 void WizardDialog::SetTranscodeOut( char const *address )
1495 this->address = strdup( address );
1498 void WizardDialog::SetMux( char const *mux )
1500 this->mux = strdup( mux );
1503 void WizardDialog::SetAction( int i_action )
1505 this->i_action = i_action;
1508 int WizardDialog::GetAction()
1513 void WizardDialog::Run()
1515 if( RunWizard(page1) )
1520 if( i_action == ACTION_TRANSCODE )
1522 msg_Dbg( p_intf,"Starting transcode of %s to file %s",
1524 msg_Dbg( p_intf,"Using %s (%i kbps) / %s (%i kbps),encap %s",
1525 vcodec,vb,acodec,ab,mux);
1526 char *psz_transcode;
1528 if( vcodec != NULL || acodec != NULL )
1531 if( vcodec != NULL )
1532 i_tr_size += strlen( vcodec ) + 17;
1533 if( acodec != NULL )
1534 i_tr_size += strlen( acodec ) + 17;
1546 psz_transcode = (char *)malloc( i_tr_size * sizeof(char) );
1548 strcpy( psz_transcode, "transcode{" );
1549 if( vcodec != NULL )
1551 sprintf( psz_transcode + strlen( psz_transcode ),
1552 "vcodec=%s,vb=%i%s", vcodec, vb,
1553 ( acodec != NULL ) ? "," : "}:" );
1555 if( acodec != NULL )
1557 sprintf( psz_transcode + strlen( psz_transcode ),
1558 "acodec=%s,ab=%i}:", acodec, ab );
1564 i_size = 73 + strlen(mux) + strlen(address) + strlen(psz_transcode);
1565 psz_opt = (char *)malloc( i_size * sizeof(char) );
1566 snprintf( psz_opt, i_size, ":sout=#%sstandard{mux=%s,url=%s,"
1567 "access=file}", psz_transcode, mux, address );
1569 if( *psz_transcode )
1570 free( psz_transcode );
1574 msg_Dbg( p_intf, "Starting stream of %s to %s using %s, encap %s",
1575 mrl, address, method, mux);
1578 char *psz_sap_option = NULL;
1581 psz_sap_option = (char *) malloc( strlen( psz_sap_name )
1583 snprintf( psz_sap_option,strlen( psz_sap_name ) + 15,
1584 "sap,name=\"%s\"",psz_sap_name );
1587 psz_sap_option = strdup( "sap" );
1589 i_size = 40 + strlen(mux) + strlen(address) +
1590 strlen( psz_sap_option);
1591 psz_opt = (char *)malloc( i_size * sizeof(char) );
1592 snprintf( psz_opt, i_size,
1593 ":sout=#standard{mux=%s,url=%s,access=%s,%s}",
1594 mux, address,method, psz_sap_option);
1595 if( psz_sap_option ) free( psz_sap_option );
1599 i_size = 40 + strlen(mux) + strlen(address);
1600 psz_opt = (char *)malloc( i_size * sizeof(char) );
1601 snprintf( psz_opt, i_size,
1602 ":sout=#standard{mux=%s,url=%s,access=%s}",
1603 mux, address,method);
1607 playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,
1608 VLC_OBJECT_PLAYLIST, FIND_ANYWHERE);
1611 playlist_item_t *p_item = playlist_ItemNew( p_playlist, mrl,
1613 playlist_ItemAddOption( p_item, psz_opt);
1617 snprintf( psz_from, 20, "start-time=%i", i_from);
1618 playlist_ItemAddOption( p_item, psz_from);
1623 snprintf( psz_to, 20, "stop-time=%i", i_to);
1624 playlist_ItemAddOption( p_item, psz_to);
1628 snprintf( psz_ttl, 20, "ttl=%i",i_ttl );
1629 playlist_ItemAddOption( p_item, psz_ttl );
1631 playlist_AddItem( p_playlist, p_item, PLAYLIST_GO, PLAYLIST_END );
1632 vlc_object_release(p_playlist);
1636 wxMessageBox( wxU( NO_PLAYLIST ), wxU( ERROR_MSG ),
1637 wxICON_WARNING | wxOK, this );
1641 /****************************************************************
1642 * Local helper functions
1643 ****************************************************************/
1644 static int ismult( const char *psz_uri )
1647 unsigned long i_value;
1650 if( psz_uri[0] == '[')
1651 return strncasecmp( &psz_uri[1], "FF" , 2) ? VLC_FALSE : VLC_TRUE;
1654 i_value = strtoul( psz_uri, &psz_end, 10 );
1655 if( *psz_end != '.' ) { return( VLC_FALSE ); }
1657 return( ( i_value >= 224 && i_value < 240 ) ? VLC_TRUE : VLC_FALSE );