wizard.cpp 53.7 KB
Newer Older
1
2
3
4
/*****************************************************************************
 * wizard.cpp : wxWindows plugin for vlc
 *****************************************************************************
 * Copyright (C) 2000-2004 VideoLAN
5
 * $Id$
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
 *
 * Authors: Clément Stenac <zorglub@videolan.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
 *****************************************************************************/

/*****************************************************************************
 * Preamble
 *****************************************************************************/
#include <stdlib.h>                                      /* malloc(), free() */
#include <errno.h>                                                 /* ENOMEM */
#include <string.h>                                            /* strerror() */
#include <stdio.h>

#include <vlc/vlc.h>
#include <vlc/intf.h>

#include "wxwindows.h"

37
#include "streamdata.h"
38

39
#include <wx/statline.h>
40

41
42
43
44
45
46
47
48
49
class wizHelloPage;
class wizInputPage;

/*****************************************************************************
 * Define events
 *****************************************************************************/
enum
{
    ActionRadio0_Event, ActionRadio1_Event,
50
51
    MoreInfoStreaming_Event,
    MoreInfoTranscode_Event,
52

zorglub's avatar
zorglub committed
53
    Open_Event , Choose_Event ,
54
55
    ListView_Event,
    InputRadio0_Event, InputRadio1_Event,
56
    PartialEnable_Event,
57
58
59
60
61
62
63
64
65

    MethodRadio0_Event, MethodRadio1_Event,
    MethodRadio2_Event, MethodRadio3_Event,

    EncapRadio0_Event, EncapRadio1_Event,
    EncapRadio2_Event, EncapRadio3_Event,
    EncapRadio4_Event, EncapRadio5_Event,
    EncapRadio6_Event, EncapRadio7_Event,
    EncapRadio8_Event, EncapRadio9_Event,
zorglub's avatar
zorglub committed
66
    EncapRadio10_Event, EncapRadio11_Event,
67

68
69
    VideoEnable_Event, VideoCodec_Event,VideoBitrate_Event,
    AudioEnable_Event, AudioCodec_Event,AudioBitrate_Event,
70

zorglub's avatar
zorglub committed
71
72
    SAP_Event,

73
74
};

75
#define TEXTWIDTH 55
76
77
78
79
80
81
82
83
84
85
#define ACTION_STREAM 0
#define ACTION_TRANSCODE 1

BEGIN_EVENT_TABLE(WizardDialog, wxWizard)
END_EVENT_TABLE()

/*****************************************************************************
 * Wizard strings
 *****************************************************************************/

86
#define ERROR_MSG _("Error")
87
88
89
#define ITEM_NAME _("Streaming/Transcoding Wizard")

/* Hello page */
90
#define HELLO_TITLE _("Streaming/Transcoding Wizard")
91
92
#define HELLO_TEXT _("This wizard helps you to stream, transcode or" \
                     " save a stream")
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
97
98
#define HELLO_TRANSCODE_DESC _("Use this to re-encode a stream and save it to a file")
#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
100
101
#define MOREINFO_STREAM _("Use this to stream on a network")

#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
103
104
             "for file to file transcoding. You should use its transcoding " \
             "features to save network streams, for example" )

105
106
107
108
109
110
111
112
113
114
/* Input page */
#define INPUT_TITLE _("Choose input")
#define INPUT_TEXT _("Choose here your input stream")

#define INPUT_OPEN _("Select a stream" )
#define INPUT_PL _( "Existing playlist item" )

#define CHOOSE_STREAM _("You must choose a stream")
#define NO_PLAYLIST _("Uh Oh! Unable to find playlist !")

115
116
117
#define PARTIAL _("Use this to read only a part of the stream. " \
                  "You must be able to control the incoming stream " \
                  "(for example, a file or a disc, but not an UDP " \
hartman's avatar
hartman committed
118
                  "network stream.)\n" \
119
                  "Enter the starting and ending times (in seconds)")
120

121
122
123
124
#define INPUT_BUTTON _("Choose")

/* Transcode 1 */
#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).")
126
127
128
129

#define TR_VIDEO_TEXT0 _("If your stream has video and you want to " \
                         "transcode it, enable this")
#define TR_VIDEO_TEXT _("Select your video codec. Click one to get more " \
130
                        "information")
131
132
133
134
135
136
137
138
139
140
141
142
143

#define TR_AUDIO_TEXT0 _("If your stream has audio and you want to "\
                         "transcode it, enable this")
#define TR_AUDIO_TEXT _("Select your audio codec. Click one to get more " \
                        "information")

/* Streaming 1 */
#define STREAMING1_TITLE _("Streaming")
#define STREAMING1_TEXT _("In this page, you will select how your input stream will be sent.")


#define INVALID_MCAST_ADDRESS _("This does not appear to be a valid " \
                                "multicast address" )
144
#define NO_ADDRESS _("You need to enter an address" )
145
146
147
148

/* Encap  */
#define ENCAP_TITLE _("Encapsulation format")
#define ENCAP_TEXT _("In this page, you will select how the stream will be "\
149
150
                     "encapsulated. Depending on the choices you made, all "\
                     "formats won't be available." )
151
152
153
154


/* Transcode 2 */
#define EXTRATRANSCODE_TITLE _("Additional transcode options")
155
#define EXTRATRANSCODE_TEXT _("In this page, you will define a few " \
156
157
                              "additionnal parameters for your transcoding" )

zorglub's avatar
zorglub committed
158
159
#define CHOOSE_OUTFILE _("You must choose a file to save to")

160
161
/* Streaming 2 */
#define EXTRASTREAMING_TITLE _("Additional streaming options")
162
#define EXTRASTREAMING_TEXT _("In this page, you will define a few " \
163
164
                              "additionnal parameters for your stream" )

zorglub's avatar
zorglub committed
165
166
167
168
169
170
171
172
173
174
175
#define TTL _("Define the TTL (Time-To-Live) of the stream. This parameter " \
              "is the maximum number of routers your stream can go through. " \
              "If you don't know what it means, or if you want to stream on " \
              "your local network only, leave this setting to 1." )

#define SAP _("When streaming using UDP, you can announce your streams " \
              "using the SAP/SDP announcing protocol. This way, the clients " \
              "won't have to type in the multicast address, it will appear " \
              "in their playlist if they enable the SAP extra interface.\n" \
              "If you want to give a name to your stream, enter it here, " \
              "else, a default name will be used" )
176
177
178
179
180
181
182
183
184
185
186
187

/*****************************************************************************
 * All the pages of the wizard, declaration
 *****************************************************************************/

/* Declare classes */
class wizHelloPage : public wxWizardPageSimple
{
    public:
        wizHelloPage( wxWizard *parent);
        void OnActionChange(wxEvent& event);
        void OnWizardPageChanging(wxWizardEvent& event);
188
        void OnMoreInfo( wxCommandEvent& event );
189
190
191
192
193
194
195
196
197
198
    protected:
        int i_action;
        WizardDialog *p_parent;
        wxRadioButton *action_radios[2];
        DECLARE_EVENT_TABLE()
};

BEGIN_EVENT_TABLE(wizHelloPage, wxWizardPageSimple)
    EVT_RADIOBUTTON( ActionRadio0_Event, wizHelloPage::OnActionChange)
    EVT_RADIOBUTTON( ActionRadio1_Event, wizHelloPage::OnActionChange)
199
200
201
    EVT_BUTTON( MoreInfoStreaming_Event, wizHelloPage::OnMoreInfo )
    EVT_BUTTON( MoreInfoTranscode_Event, wizHelloPage::OnMoreInfo )

202
203
204
205
206
207
208
209
210
211
212
    EVT_WIZARD_PAGE_CHANGING(-1, wizHelloPage::OnWizardPageChanging)
END_EVENT_TABLE()


class wizInputPage : public wxWizardPage
{
    public:
        wizInputPage( wxWizard *, wxWizardPage *, intf_thread_t *);
        wizInputPage::~wizInputPage();
        void OnWizardPageChanging(wxWizardEvent& event);
        void OnInputChange(wxEvent& event);
213
        void OnEnablePartial(wxCommandEvent& event);
214
215
216
217
218
219
        virtual wxWizardPage *GetPrev() const;
        virtual wxWizardPage *GetNext() const;
        void SetStreamingPage( wxWizardPage *page);
        void SetTranscodePage( wxWizardPage *page);
        void SetAction( int i_action );
        void SetPintf( intf_thread_t *p_intf );
220
221
        void SetUri( char *psz_uri );
        void SetPartial( int i_from, int i_to );
222

223
224
225
226
227
228
    protected:
        bool b_chosen;
        intf_thread_t *p_intf;
        int i_action;
        int i_input;

229
230
        void OnChoose( wxCommandEvent& event );

231
232
        WizardDialog *p_parent;
        wxRadioButton *input_radios[2];
233
        wxCheckBox *enable_checkbox;
234
235
236
        wxBoxSizer *mainSizer;
        wxArrayString mrl;
        wxTextCtrl *mrl_text;
237
238
        wxTextCtrl *from_text;
        wxTextCtrl *to_text;
239
240
241
242
243
244
        OpenDialog *p_open_dialog;
        wxListView *listview;
        wxPanel *open_panel;
        wxWizardPage *p_prev;
        wxWizardPage *p_streaming_page;
        wxWizardPage *p_transcode_page;
245

246
247
248
        DECLARE_EVENT_TABLE()
};

249
BEGIN_EVENT_TABLE(wizInputPage, wxWizardPage)
250
251
    EVT_RADIOBUTTON( InputRadio0_Event, wizInputPage::OnInputChange)
    EVT_RADIOBUTTON( InputRadio1_Event, wizInputPage::OnInputChange)
252
    EVT_BUTTON( Choose_Event, wizInputPage::OnChoose)
253
    EVT_CHECKBOX( PartialEnable_Event, wizInputPage::OnEnablePartial)
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
    EVT_WIZARD_PAGE_CHANGING(-1, wizInputPage::OnWizardPageChanging)
END_EVENT_TABLE()


class wizTranscodeCodecPage : public wxWizardPage
{
public:
    wizTranscodeCodecPage( wxWizard *parent, wxWizardPage *next);
    ~wizTranscodeCodecPage();
    void wizTranscodeCodecPage::OnWizardPageChanging(wxWizardEvent& event);
    virtual wxWizardPage *GetPrev() const;
    virtual wxWizardPage *GetNext() const;
    void SetPrev( wxWizardPage *page);
protected:
    wxCheckBox *video_checkbox;
    wxComboBox *video_combo;
270
    wxComboBox *vb_combo;
271
272
273
    wxStaticText * video_text;
    wxCheckBox *audio_checkbox;
    wxComboBox *audio_combo;
274
    wxComboBox *ab_combo;
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
    wxStaticText * audio_text;

    WizardDialog *p_parent;
    int i_audio_codec;
    int i_video_codec;

    char *vcodec;
    char *acodec;

    wxWizardPage *p_prev;
    wxWizardPage *p_next;

    void OnVideoCodecChange(wxCommandEvent& event);
    void OnAudioCodecChange(wxCommandEvent& event);
    void OnEnableVideo(wxCommandEvent& event);
    void OnEnableAudio(wxCommandEvent& event);

    DECLARE_EVENT_TABLE()
};

295
BEGIN_EVENT_TABLE(wizTranscodeCodecPage, wxWizardPage)
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
   EVT_CHECKBOX( VideoEnable_Event, wizTranscodeCodecPage::OnEnableVideo)
   EVT_CHECKBOX( AudioEnable_Event, wizTranscodeCodecPage::OnEnableAudio)
   EVT_COMBOBOX( VideoCodec_Event, wizTranscodeCodecPage::OnVideoCodecChange)
   EVT_COMBOBOX( AudioCodec_Event, wizTranscodeCodecPage::OnAudioCodecChange)
   EVT_WIZARD_PAGE_CHANGING(-1, wizTranscodeCodecPage::OnWizardPageChanging)
END_EVENT_TABLE()

class wizStreamingMethodPage : public wxWizardPage
{
public:
    wizStreamingMethodPage( wxWizard *parent, wxWizardPage *next);
    void OnWizardPageChanging(wxWizardEvent& event);
    virtual wxWizardPage *GetPrev() const;
    virtual wxWizardPage *GetNext() const;
    void SetPrev( wxWizardPage *page);
protected:
    DECLARE_EVENT_TABLE()
    int i_method;
314
    wxBoxSizer *mainSizer;
315
    wxStaticBoxSizer *address_sizer;
316
317
318
319
320
321
322
323
324
    wxStaticText *address_text;
    wxTextCtrl *address_txtctrl;
    WizardDialog * p_parent;
    void OnMethodChange(wxEvent& event);
    wxRadioButton *method_radios[4];
    wxWizardPage *p_prev;
    wxWizardPage *p_next;
};

325
BEGIN_EVENT_TABLE(wizStreamingMethodPage, wxWizardPage)
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
    EVT_RADIOBUTTON( MethodRadio0_Event, wizStreamingMethodPage::OnMethodChange)
    EVT_RADIOBUTTON( MethodRadio1_Event, wizStreamingMethodPage::OnMethodChange)
    EVT_RADIOBUTTON( MethodRadio2_Event, wizStreamingMethodPage::OnMethodChange)
    EVT_RADIOBUTTON( MethodRadio3_Event, wizStreamingMethodPage::OnMethodChange)
    EVT_WIZARD_PAGE_CHANGING(-1, wizStreamingMethodPage::OnWizardPageChanging)
END_EVENT_TABLE()


class wizEncapPage : public wxWizardPage
{
public:
    wizEncapPage( wxWizard *parent);
    wizEncapPage::~wizEncapPage();
    void OnWizardPageChanging(wxWizardEvent& event);
    virtual wxWizardPage *GetPrev() const;
    virtual wxWizardPage *GetNext() const;
    void SetStreamingPage( wxWizardPage *page);
    void SetTranscodePage( wxWizardPage *page);
    void SetPrev( wxWizardPage *page);
    void SetAction( int );
    void EnableEncap( int encap );
protected:
    DECLARE_EVENT_TABLE()
    int i_encap;
    int i_mux;
    int i_action;
    void OnEncapChange(wxEvent& event);
zorglub's avatar
zorglub committed
353
    wxRadioButton *encap_radios[MUXERS_NUMBER];
354
355
356
357
358
359
    WizardDialog *p_parent;
    wxWizardPage *p_prev;
    wxWizardPage *p_streaming_page;
    wxWizardPage *p_transcode_page;
};

360
BEGIN_EVENT_TABLE(wizEncapPage, wxWizardPage)
361
362
363
364
365
366
367
368
369
370
371
    EVT_WIZARD_PAGE_CHANGING(-1, wizEncapPage::OnWizardPageChanging)
    EVT_RADIOBUTTON( EncapRadio0_Event, wizEncapPage::OnEncapChange)
    EVT_RADIOBUTTON( EncapRadio1_Event, wizEncapPage::OnEncapChange)
    EVT_RADIOBUTTON( EncapRadio2_Event, wizEncapPage::OnEncapChange)
    EVT_RADIOBUTTON( EncapRadio3_Event, wizEncapPage::OnEncapChange)
    EVT_RADIOBUTTON( EncapRadio4_Event, wizEncapPage::OnEncapChange)
    EVT_RADIOBUTTON( EncapRadio5_Event, wizEncapPage::OnEncapChange)
    EVT_RADIOBUTTON( EncapRadio6_Event, wizEncapPage::OnEncapChange)
    EVT_RADIOBUTTON( EncapRadio7_Event, wizEncapPage::OnEncapChange)
    EVT_RADIOBUTTON( EncapRadio8_Event, wizEncapPage::OnEncapChange)
    EVT_RADIOBUTTON( EncapRadio9_Event, wizEncapPage::OnEncapChange)
zorglub's avatar
zorglub committed
372
    EVT_RADIOBUTTON( EncapRadio10_Event, wizEncapPage::OnEncapChange)
373
374
375
376
377
378
379
380
381
382
END_EVENT_TABLE()

/* Additional settings for transcode */
class wizTranscodeExtraPage : public wxWizardPage
{
public:
    wizTranscodeExtraPage( wxWizard *parent, wxWizardPage *prev,
                            wxWizardPage *next);
    virtual wxWizardPage *GetPrev() const;
    virtual wxWizardPage *GetNext() const;
zorglub's avatar
zorglub committed
383
    void OnWizardPageChanging( wxWizardEvent& event );
384
385
386
protected:
    DECLARE_EVENT_TABLE()
    void wizTranscodeExtraPage::OnSelectFile(wxCommandEvent&);
zorglub's avatar
zorglub committed
387
    wxTextCtrl *file_text;
388
389
390
391
392
393
394
    WizardDialog *p_parent;
    wxWizardPage *p_prev;
    wxWizardPage *p_next;
};

BEGIN_EVENT_TABLE(wizTranscodeExtraPage, wxWizardPage)
    EVT_BUTTON( Open_Event, wizTranscodeExtraPage::OnSelectFile)
zorglub's avatar
zorglub committed
395
    EVT_WIZARD_PAGE_CHANGING(-1, wizTranscodeExtraPage::OnWizardPageChanging)
396
397
398
399
400
401
402
403
404
405
END_EVENT_TABLE()

/* Additional settings for streaming */
class wizStreamingExtraPage : public wxWizardPage
{
public:
    wizStreamingExtraPage( wxWizard *parent, wxWizardPage *prev,
                            wxWizardPage *next);
    virtual wxWizardPage *GetPrev() const;
    virtual wxWizardPage *GetNext() const;
zorglub's avatar
zorglub committed
406
407
408
409
    void OnWizardPageChanging(wxWizardEvent&);
    void OnSAP( wxCommandEvent&);
    wxCheckBox *sap_checkbox;
    wxTextCtrl *sap_text;
410
protected:
zorglub's avatar
zorglub committed
411
    friend class wizEncapPage;
412
413
414
415
    DECLARE_EVENT_TABLE()
    WizardDialog *p_parent;
    wxWizardPage *p_prev;
    wxWizardPage *p_next;
zorglub's avatar
zorglub committed
416
417

    wxSpinCtrl *ttl_spin;
418
419
420
};

BEGIN_EVENT_TABLE(wizStreamingExtraPage, wxWizardPage)
zorglub's avatar
zorglub committed
421
422
    EVT_CHECKBOX( SAP_Event, wizStreamingExtraPage::OnSAP )
    EVT_WIZARD_PAGE_CHANGING(-1, wizStreamingExtraPage::OnWizardPageChanging)
423
424
425
426
427
428
END_EVENT_TABLE()


/* Local functions */
static int ismult( char *psz_uri );

429
static void pageHeader( wxWindow *window, wxBoxSizer *sizer,
430
431
432
433
                       char *psz_title, char *psz_text);

static void pageHeader( wxWindow *window, wxBoxSizer *sizer,
                        char *psz_title, char *psz_text)
434
435
436
437
438
439
440
441
442
443
444
{
    wxStaticText *wtitle = new wxStaticText( window, -1, wxU( psz_title ) );
    wxFont font = wtitle->GetFont();
    font.SetPointSize(14);
    wtitle->SetFont(font);
    sizer->Add( wtitle, 0, wxALL, 5 );
    sizer->Add( new wxStaticText( window, -1,
                wxU( vlc_wraptext( psz_text , TEXTWIDTH, false ) ) ),
                        0, wxALL, 5 );
}

445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
/***************************************************************************
 * Implementation of the pages
 ***************************************************************************/


/***************************************************
 * First page: choose between stream and transcode *
 ***************************************************/
wizHelloPage::wizHelloPage( wxWizard *parent) : wxWizardPageSimple(parent)
{
        i_action = 0;
        p_parent = (WizardDialog *)parent;
        wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);

        /* Create the texts */
460
        pageHeader( this, mainSizer, HELLO_TITLE, HELLO_TEXT );
461
462
463

        /* Create the radio buttons with their helps */
        action_radios[0] = new wxRadioButton( this, ActionRadio0_Event,
Anil Daoud's avatar
Anil Daoud committed
464
                                              wxU( HELLO_STREAMING ) );
465
        action_radios[1] = new wxRadioButton( this, ActionRadio1_Event,
Anil Daoud's avatar
Anil Daoud committed
466
                                              wxU( HELLO_TRANSCODE ) );
467
468
        i_action = 0;

469
        mainSizer->Add( 0, 0, 1 );
470

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
476
                                wxU( _("More Info")) ), 0, 0, 0 );
        mainSizer->Add( stream_sizer, 0, wxALL | wxEXPAND , 5 );
477

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 );
484
485

        mainSizer->Add( 0, 0, 1 );
486

487
488
        mainSizer->Add( new wxStaticLine(this, -1 ), 0, wxEXPAND| wxTOP|
                        wxBOTTOM, 5 );
489
490
491
492
493
494
495
496
497

        mainSizer->Add( new wxStaticText(this, -1,
                        wxU( vlc_wraptext(HELLO_NOTICE , TEXTWIDTH , false ))),
                        0, wxALL, 5 );

        SetSizer(mainSizer);
        mainSizer->Fit(this);
    }

498
499
500
void wizHelloPage::OnMoreInfo(wxCommandEvent& event)
{
    wxString msg;
501
    msg.Printf( wxString( wxU( event.GetId() == MoreInfoStreaming_Event ?
502
503
504
505
506
507
                                    MOREINFO_STREAM :
                                    MOREINFO_TRANSCODE ) ) );
    wxMessageBox( msg, wxU(_("More information")),
                  wxOK | wxICON_INFORMATION, this->p_parent );
}

508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
void wizHelloPage::OnActionChange(wxEvent& event)
{
    i_action = event.GetId() - ActionRadio0_Event;
    ((wizInputPage *)GetNext())->SetAction( i_action );
    p_parent->SetAction( i_action );
}

void wizHelloPage::OnWizardPageChanging(wxWizardEvent& event)
{
    ((wizInputPage *)GetNext())->SetAction( i_action );
    p_parent->SetAction( i_action );
}

/************************************
 * Second page: choose input stream *
 ************************************/
wizInputPage::wizInputPage( wxWizard *parent, wxWizardPage *prev, intf_thread_t *_p_intf) :
              wxWizardPage(parent)
{
    p_prev = prev;
    p_intf = _p_intf;
    p_parent = (WizardDialog *)parent;
    b_chosen = false;
531
    p_open_dialog = NULL;
532
    listview = NULL;    
533
534
535
    mainSizer = new wxBoxSizer(wxVERTICAL);

    /* Create the texts */
536
    pageHeader( this, mainSizer, INPUT_TITLE, INPUT_TEXT );
537

538
539
    mainSizer->Add( 0,20,0 );

540
541
    /* Create the radio buttons */
    input_radios[0] = new wxRadioButton( this, InputRadio0_Event ,
Anil Daoud's avatar
Anil Daoud committed
542
                               wxU( INPUT_OPEN ) );
543
544
    mainSizer->Add( input_radios[0], 0, wxALL, 5 );
    input_radios[1] = new wxRadioButton( this, InputRadio1_Event ,
Anil Daoud's avatar
Anil Daoud committed
545
                               wxU( INPUT_PL ) );
546
547
548
549
550
551
    i_input = 0;
    mainSizer->Add( input_radios[1], 0, wxALL, 5 );

    /* Open Panel */
    open_panel = new wxPanel(this, -1);
    open_panel->SetAutoLayout( TRUE );
552
    wxBoxSizer *openSizer = new wxBoxSizer(wxHORIZONTAL);
553

554
555
    mrl_text = new wxTextCtrl( open_panel, -1, wxU( "" ), wxDefaultPosition,
                              wxSize(200,25) );
556
    openSizer->Add( mrl_text, 0 , wxALL, 5 );
557
    openSizer->Add( new wxButton( open_panel, Choose_Event, wxU(_("Choose...")) ), 0, wxALL, 5 );
558
559
560
561
562
563
    open_panel->SetSizer( openSizer );
    openSizer->Layout();
    openSizer->Fit(open_panel);

    mainSizer->Add( open_panel );

564

565
566
567
568
569
570
571
    playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,
                                       VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );

    if( p_playlist )
    {
        if( p_playlist->i_size > 0)
        {
572
573
            listview = new wxListView( this, ListView_Event,
                                       wxDefaultPosition, wxDefaultSize,
574
575
576
                                       wxLC_REPORT | wxSUNKEN_BORDER );
            listview->InsertColumn( 0, wxU(_("Name")) );
            listview->InsertColumn( 1, wxU(_("URI")) );
577
            listview->SetColumnWidth( 0, 250 );
578
            listview->SetColumnWidth( 1, 100 );
579
580
581
582
583
584
585
586
587
            for( int i=0 ; i < p_playlist->i_size ; i++ )
            {
                wxString filename = wxL2U( p_playlist->pp_items[i]->input.
                                                                    psz_name );
                listview->InsertItem( i, filename );
                listview->SetItem( i, 1, wxL2U( p_playlist->pp_items[i]->
                                                            input.psz_uri) );
            }
            listview->Select( p_playlist->i_index , TRUE);
588
            mainSizer->Add( listview, 1, wxALL|wxEXPAND, 5 );
589

590
591
            listview->Hide();
            mainSizer->Hide( listview );
592
            mainSizer->Layout();
593
594
595
596
597
598
599
600
601
602
603
604
        }
        else
        {
            input_radios[1]->Disable();
        }
        vlc_object_release( p_playlist );
    }
    else
    {
        input_radios[1]->Disable();
    }

605
    /* Partial Extract Box */
606
    mainSizer->Add( 0, 10, 0 );
607
608
    wxStaticBox *partial_box = new wxStaticBox( this, -1,
                    wxU(_("Partial Extract")) );
609

610
611
612
    wxStaticBoxSizer *partial_sizer = new wxStaticBoxSizer( partial_box,
                                                          wxVERTICAL );

613
    enable_checkbox = new wxCheckBox( this, PartialEnable_Event,
614
615
616
                                                wxU(_("Enable") ) );
    enable_checkbox->SetToolTip(wxU(_(PARTIAL) ) ) ;
    partial_sizer->Add( enable_checkbox, 0 , wxLEFT , 5 );
617

618
619
620
    wxFlexGridSizer *partial_sizer2 = new wxFlexGridSizer( 4 , 1 , 20 );
    partial_sizer2->Add( new wxStaticText(this, -1, wxU(_( "From" ) ) ),
                         0 , wxLEFT , 5 );
621
    from_text = new wxTextCtrl( this, -1, wxT(""),
622
                                wxDefaultPosition, wxSize( 80,25 ) );
623
    partial_sizer2->Add( from_text, 0 , wxALIGN_RIGHT);
624
625
    partial_sizer2->Add( new wxStaticText(this, -1, wxU(_( "To" ) ) ),
                         0 , wxLEFT , 5 );
626
    to_text = new wxTextCtrl( this, -1, wxT(""),
627
628
                                  wxDefaultPosition, wxSize( 80 , 25 ) );
    partial_sizer2->Add( to_text, 0 , wxALIGN_RIGHT );
629
630
631

    partial_sizer->Add( partial_sizer2, 0, wxALL, 0 );

632
633
634
    partial_sizer->Fit( partial_box );

    mainSizer->Add( partial_sizer, 0, 0, 0 );
635
636
637

    from_text->Disable();
    to_text->Disable();
638
639
    SetSizer(mainSizer);
    mainSizer->Fit(this);
640
    mainSizer->Layout();
641
642
643
644
645
646
647
648
649
650
651
}

wizInputPage::~wizInputPage()
{
}

void wizInputPage::OnInputChange(wxEvent& event)
{
    i_input = event.GetId() - InputRadio0_Event;
    if( i_input == 0 )
    {
652
        if( listview )
653
        {
654
655
            listview->Hide();
            mainSizer->Hide( listview );
656
657
            open_panel->Show();
            mainSizer->Show( open_panel );
658
            mainSizer->Layout();
659
660
661
662
663
664
        }
    }
    else
    {
        open_panel->Hide();
        mainSizer->Hide( open_panel );
665
666
        listview->Show();
        mainSizer->Show( listview );
667
        mainSizer->Layout();
668
669
670
    }
}

671
672
673
674
675
676
void wizInputPage::OnEnablePartial(wxCommandEvent& event)
{
   from_text->Enable( event.IsChecked() );
   to_text->Enable( event.IsChecked() );
}

677
678
679
680

void wizInputPage::OnChoose(wxCommandEvent& event)
{
    p_open_dialog = new OpenDialog( p_intf, this, -1, -1, OPEN_STREAM );
681
682
    if(  p_open_dialog->ShowModal() == wxID_OK &&
         !p_open_dialog->mrl.IsEmpty() )
683
684
685
686
687
688
689
    {
        mrl_text->SetValue(p_open_dialog->mrl[0] );
    }
    delete p_open_dialog;
    p_open_dialog = NULL;
}

690
691
692
693
void wizInputPage::OnWizardPageChanging(wxWizardEvent& event)
{
    if( i_input == 0)
    {
694
695
        if( mrl_text->GetValue().IsSameAs( wxT(""), TRUE ) &&
                        event.GetDirection() )
696
        {
697
            wxMessageBox( wxU( CHOOSE_STREAM ), wxU( ERROR_MSG ),
698
                          wxICON_WARNING | wxOK, this->p_parent );
699
            event.Veto();
700
            return;
701
702
703
        }
        else
        {
704
            p_parent->SetMrl( (const char *)mrl_text->GetValue().mb_str() );
705
706
707
708
709
710
711
712
713
714
715
716
        }
    }
    else
    {
        int i = -1;
        wxListItem listitem;
        i = listview->GetNextItem( i , wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
        if( i != -1 )
        {
            listitem.SetId( i );
            listitem.SetColumn( 1 );
            listview->GetItem( listitem );
717
            p_parent->SetMrl( (const char*) listitem.GetText().mb_str() );
718
719
        }
    }
720
721
722
723
724
725
726
727
    if( enable_checkbox->IsChecked() )
    {
        int i_from = atoi( from_text->GetValue().mb_str() );
        int i_to = atoi( to_text->GetValue().mb_str() );
        msg_Dbg( p_intf, "Partial streaming enabled, from %i to %i",
                         i_from,i_to);
        p_parent->SetPartial( i_from, i_to );
    }
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
    return;
}

wxWizardPage *wizInputPage::GetPrev() const { return p_prev; }
wxWizardPage *wizInputPage::GetNext() const
{
    if( i_action == ACTION_STREAM )
        return p_streaming_page;
    else
       return p_transcode_page;
}

void wizInputPage::SetStreamingPage( wxWizardPage *page)
{
    p_streaming_page = page;
}

void wizInputPage::SetTranscodePage( wxWizardPage *page)
{
    p_transcode_page = page;
}

void wizInputPage::SetAction( int i_action )
{
    this->i_action = i_action;
}

void wizInputPage::SetPintf( intf_thread_t *p_intf )
{
    this->p_intf = p_intf;
}

760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
void wizInputPage::SetUri( char *psz_uri )
{
    mrl_text->SetValue( wxU( psz_uri ) );
}

void wizInputPage::SetPartial( int i_from, int i_to )
{
   wxString msg;
   msg.Printf( wxString( wxT( "%i") ), i_from );
   from_text->Enable( TRUE );
   from_text->SetValue( msg );
   msg.Printf( wxString( wxT( "%i") ), i_to );
   to_text->Enable( TRUE );
   to_text->SetValue( msg );
   enable_checkbox->SetValue( TRUE );
}

777
778
779
780
781
782
783
784
785
786
787
788
789
790
/***************************************************
 * First transcode page: choose codecs             *
 ***************************************************/
wizTranscodeCodecPage::wizTranscodeCodecPage( wxWizard *parent,
                       wxWizardPage *next) : wxWizardPage(parent)
{
    p_next = next;

    acodec = NULL;
    vcodec = NULL;
    p_parent = (WizardDialog *) parent;

    wxBoxSizer *main_sizer = new wxBoxSizer(wxVERTICAL);

791
792
    /* Header */
    pageHeader( this, main_sizer,  TRANSCODE1_TITLE, TRANSCODE1_TEXT );
793
794
795
796
797
798

    /* Video Box */
    wxStaticBox *video_box = new wxStaticBox( this, -1, wxU(_("Video")) );
    wxStaticBoxSizer *video_sizer = new wxStaticBoxSizer( video_box,
                                                          wxVERTICAL );
    /* Line 1 : only the checkbox */
799
    wxFlexGridSizer *video_sizer1 = new wxFlexGridSizer( 2,3,20 );
800
    video_sizer1->Add( new wxCheckBox( this, VideoEnable_Event,
801
802
                       wxU(_("Transcode video") ) ), 0 , 0 , 5 );
    video_sizer1->Add( 0,0,1);
803
    /* Line 2 : codec */
804
    video_sizer1->Add( new wxStaticText(this, -1, wxU(_("Codec"))),0,wxLEFT ,5);
805
806
807
808
    video_combo = new wxComboBox( this, VideoCodec_Event, wxT(""),
                                  wxDefaultPosition, wxSize(200,25) );
    for( int i= 0; vcodecs_array[i].psz_display != NULL; i++ )
    {
Anil Daoud's avatar
Anil Daoud committed
809
        video_combo->Append( wxU( vcodecs_array[i].psz_display ) ,
810
811
                            (void *)&vcodecs_array[i] );
    }
812
813
814
815
816
817
818
819
820
    video_sizer1->Add( video_combo, 0 , wxALIGN_LEFT , 0 );

    video_sizer1->Add( new wxStaticText(this, -1, wxU(_("Bitrate (kb/s)"))),0,
                       wxLEFT ,5);
    vb_combo = new wxComboBox( this, VideoBitrate_Event, wxT("1024"),
                               wxDefaultPosition, wxDefaultSize,
                               WXSIZEOF(vbitrates_array), vbitrates_array );
    video_sizer1->Add( vb_combo, 0, wxALIGN_LEFT , 0 );

821
822
    /* Line 3 : text */
    video_text = new wxStaticText( this, -1,
823
                     wxU( vlc_wraptext( TR_VIDEO_TEXT, TEXTWIDTH, false) ) );
824
    /* Fill the main video sizer */
825
826
827
    video_sizer->Add( video_sizer1 , 0, wxEXPAND , 5 );
    video_sizer->Add( video_text, 0, wxLEFT|wxTOP , 5 );

828
829
830
831
832
833

    /* Audio box */
    wxStaticBox *audio_box = new wxStaticBox( this, -1, wxU(_("Audio")) );
    wxStaticBoxSizer *audio_sizer = new wxStaticBoxSizer( audio_box,
                                                          wxVERTICAL );
    /* Line1: enabler */
834
    wxFlexGridSizer *audio_sizer1 = new wxFlexGridSizer( 2,3,20);
835
836
    audio_sizer1->Add( new wxCheckBox( this, AudioEnable_Event,
                            wxU(_("Transcode audio") ) ), 0 , wxLEFT, 5 );
837
838
    audio_sizer1->Add( 0, 0, 1 );

839
    /* Line 2 : codec */
840
    audio_sizer1->Add( new wxStaticText(this, -1, wxU(_("Codec"))),0,wxLEFT,5);
841
842
843
844
    audio_combo = new wxComboBox( this, AudioCodec_Event, wxT(""),
                                  wxDefaultPosition, wxSize(200,25) );
    for( int i= 0; acodecs_array[i].psz_display != NULL; i++ )
    {
Anil Daoud's avatar
Anil Daoud committed
845
        audio_combo->Append( wxU( acodecs_array[i].psz_display ) ,
846
847
                            (void *)&acodecs_array[i] );
    }
848
849
850
851
852
853
854
855
856
    audio_sizer1->Add( audio_combo, 0 , wxALIGN_LEFT, 0 );

    audio_sizer1->Add( new wxStaticText(this, -1, wxU(_("Bitrate (kb/s)"))),0,
                       wxLEFT ,5);
    ab_combo = new wxComboBox( this, AudioBitrate_Event, wxT("192"),
                               wxDefaultPosition, wxDefaultSize,
                               WXSIZEOF(abitrates_array), abitrates_array );
    audio_sizer1->Add( ab_combo, 0, wxALIGN_LEFT, 0 );

857
858
    /* Line 3 : text */
    audio_text = new wxStaticText( this, -1,
859
                     wxU( vlc_wraptext( TR_AUDIO_TEXT, TEXTWIDTH, false) ) );
860
861

    audio_sizer->Add(audio_sizer1, 0, wxEXPAND, 5);
862
    audio_sizer->Add( audio_text, 0, wxLEFT | wxTOP, 5 );
863
864
865
866
867
868
869

    main_sizer->Add( video_sizer, 1, wxGROW, 0 );
    main_sizer->Add( audio_sizer, 1, wxGROW, 0 );
    main_sizer->Layout();
    SetSizerAndFit( main_sizer );

    /* Default disabled */
870
871
    video_combo->Disable(); video_text->Disable();vb_combo->Disable();
    audio_combo->Disable(); audio_text->Disable();ab_combo->Disable();
872
873
874
875
876
877
878
879
880
881
882
883

}

wizTranscodeCodecPage::~wizTranscodeCodecPage()
{
    if( acodec ) free( acodec );
    if( vcodec ) free( vcodec );
}

void wizTranscodeCodecPage::OnEnableVideo(wxCommandEvent& event)
{
   video_combo->Enable( event.IsChecked() );
884
   vb_combo->Enable( event.IsChecked() );
885
886
887
888
889
890
   video_text->Enable( event.IsChecked() );
}

void wizTranscodeCodecPage::OnEnableAudio(wxCommandEvent& event)
{
   audio_combo->Enable( event.IsChecked() );
891
   ab_combo->Enable( event.IsChecked() );
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
   audio_text->Enable( event.IsChecked() );
}

void wizTranscodeCodecPage::OnVideoCodecChange(wxCommandEvent& event)
{
    struct codec *c = (struct codec*)
             (video_combo->GetClientData(video_combo->GetSelection()));
    video_text->SetLabel( wxU( vlc_wraptext(c->psz_descr, TEXTWIDTH, false) ) );
    i_video_codec = video_combo->GetSelection();
    vcodec = strdup(c->psz_codec);
}

void wizTranscodeCodecPage::OnAudioCodecChange(wxCommandEvent& event)
{
    struct codec *c = (struct codec*)
             (audio_combo->GetClientData(audio_combo->GetSelection()));
    audio_text->SetLabel( wxU( vlc_wraptext(c->psz_descr, TEXTWIDTH, false) ) );
    i_audio_codec = audio_combo->GetSelection();
    acodec = strdup(c->psz_codec);

}

void wizTranscodeCodecPage::OnWizardPageChanging(wxWizardEvent& event)
{
    unsigned int i,j;

    if( !event.GetDirection() )
    {
            GetPrev()->Enable();
            return;
    }

    /* Set the dummy codec ( accept all muxers ) if needed */
    if( !video_combo->IsEnabled() )
    {
zorglub's avatar
zorglub committed
927
        i_video_codec = VCODECS_NUMBER;
928
929
930
    }
    if( !audio_combo->IsEnabled() )
    {
zorglub's avatar
zorglub committed
931
        i_audio_codec = ACODECS_NUMBER;
932
933
934
935
    }

    ((wizEncapPage *)GetNext())->SetPrev(this);

zorglub's avatar
zorglub committed
936
    for( i = 0 ; i< MUXERS_NUMBER ; i++ )
937
938
939
    {
        if( vcodecs_array[i_video_codec].muxers[i] != -1 )
        {
zorglub's avatar
zorglub committed
940
            for( j = 0 ; j<  MUXERS_NUMBER ; j++ )
941
942
943
944
945
946
947
948
949
950
951
            {
                if( acodecs_array[i_audio_codec].muxers[j] ==
                              vcodecs_array[i_video_codec].muxers[i] )
                {
                    ((wizEncapPage*)GetNext())->EnableEncap(
                               vcodecs_array[i_video_codec].muxers[i] );
                }
            }
        }
    }
    struct codec *c = (struct codec*)
952
953
             (video_combo->GetClientData( video_combo->IsEnabled() ?
                                          video_combo->GetSelection(): i_video_codec ));
954
955
    vcodec = strdup(c->psz_codec);
    c = (struct codec*)
956
957
           (audio_combo->GetClientData( audio_combo->IsEnabled() ?
                                       audio_combo->GetSelection() : i_audio_codec ));
958
959
    acodec = strdup(c->psz_codec);

960
    int vb = atoi(vb_combo->GetValue().mb_str() );
961
962
963
964
    if( vb == 0 )
    {
         vb = 1024;
    }
965
    int ab = atoi(ab_combo->GetValue().mb_str() );
966
967
968
969
    if( ab == 0)
    {
        ab = 192;
    }
970

971
    p_parent->SetTranscode( vcodec, vb , acodec, ab );
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
    ((wizEncapPage*)GetNext())->SetAction( p_parent->GetAction() );
    p_parent->SetAction( p_parent->GetAction() );

    return;
}

wxWizardPage *wizTranscodeCodecPage::GetPrev() const { return p_prev; }
wxWizardPage *wizTranscodeCodecPage::GetNext() const { return p_next; }
void wizTranscodeCodecPage::SetPrev( wxWizardPage *page) {p_prev = page; }


/***************************************************
 * First streaming page: choose method             *
 ***************************************************/
wizStreamingMethodPage::wizStreamingMethodPage( wxWizard *parent,
    wxWizardPage *next) : wxWizardPage(parent)
{
    int i;
    p_next = next;
    p_parent = (WizardDialog *)parent;

993
    mainSizer = new wxBoxSizer(wxVERTICAL);
994
995

    /* Create the texts */
996
997
    pageHeader( this, mainSizer,  STREAMING1_TITLE, STREAMING1_TEXT );

998
    mainSizer->Add( 0,50,0 );
999
1000

    i_method = 0;
For faster browsing, not all history is shown. View entire blame