]> git.sesse.net Git - vlc/blob - modules/gui/wxwindows/streamout.cpp
* modules/gui/wxwindows/streamout.cpp: disabled mp4 muxer.
[vlc] / modules / gui / wxwindows / streamout.cpp
1 /*****************************************************************************
2  * streamout.cpp : wxWindows plugin for vlc
3  *****************************************************************************
4  * Copyright (C) 2000-2001 VideoLAN
5  * $Id: streamout.cpp,v 1.17 2003/06/22 15:43:54 gbazin Exp $
6  *
7  * Authors: Gildas Bazin <gbazin@netcourrier.com>
8  *
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.
13  *
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.
18  *
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  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27 #include <stdlib.h>                                      /* malloc(), free() */
28 #include <errno.h>                                                 /* ENOMEM */
29 #include <string.h>                                            /* strerror() */
30 #include <stdio.h>
31
32 #include <vlc/vlc.h>
33
34 #ifdef WIN32                                                 /* mingw32 hack */
35 #undef Yield
36 #undef CreateDialog
37 #endif
38
39 /* Let vlc take care of the i18n stuff */
40 #define WXINTL_NO_GETTEXT_MACRO
41
42 #include <wx/wxprec.h>
43 #include <wx/wx.h>
44 #include <wx/notebook.h>
45 #include <wx/textctrl.h>
46 #include <wx/combobox.h>
47 #include <wx/spinctrl.h>
48 #include <wx/statline.h>
49
50 #include <vlc/intf.h>
51
52 #if defined MODULE_NAME_IS_skins
53 #   include "../skins/src/skin_common.h"
54 #endif
55
56 #include "wxwindows.h"
57
58 #ifndef wxRB_SINGLE
59 #   define wxRB_SINGLE 0
60 #endif
61
62 enum
63 {
64     PLAY_ACCESS_OUT = 0,
65     FILE_ACCESS_OUT,
66     HTTP_ACCESS_OUT,
67     UDP_ACCESS_OUT,
68     RTP_ACCESS_OUT,
69     ACCESS_OUT_NUM
70 };
71
72 enum
73 {
74     TS_ENCAPSULATION = 0,
75     PS_ENCAPSULATION,
76     AVI_ENCAPSULATION,
77     OGG_ENCAPSULATION,
78     ENCAPS_NUM,
79     MP4_ENCAPSULATION
80 };
81
82 /*****************************************************************************
83  * Event Table.
84  *****************************************************************************/
85
86 /* IDs for the controls and the menu commands */
87 enum
88 {
89     Notebook_Event = wxID_HIGHEST,
90     MRL_Event,
91
92     FileBrowse_Event,
93     FileName_Event,
94
95     AccessType1_Event, AccessType2_Event, AccessType3_Event,
96     AccessType4_Event, AccessType5_Event,
97     NetPort1_Event, NetPort2_Event, NetPort3_Event,
98     NetAddr1_Event, NetAddr2_Event, NetAddr3_Event,
99
100     EncapsulationRadio1_Event, EncapsulationRadio2_Event,
101     EncapsulationRadio3_Event, EncapsulationRadio4_Event,
102     EncapsulationRadio5_Event,
103
104     VideoTranscEnable_Event, VideoTranscCodec_Event, VideoTranscBitrate_Event,
105     AudioTranscEnable_Event, AudioTranscCodec_Event, AudioTranscBitrate_Event,
106 };
107
108 BEGIN_EVENT_TABLE(SoutDialog, wxDialog)
109     /* Button events */
110     EVT_BUTTON(wxID_OK, SoutDialog::OnOk)
111     EVT_BUTTON(wxID_CANCEL, SoutDialog::OnCancel)
112
113     /* Events generated by the access output panel */
114     EVT_CHECKBOX(AccessType1_Event, SoutDialog::OnAccessTypeChange)
115     EVT_CHECKBOX(AccessType2_Event, SoutDialog::OnAccessTypeChange)
116     EVT_CHECKBOX(AccessType3_Event, SoutDialog::OnAccessTypeChange)
117     EVT_CHECKBOX(AccessType4_Event, SoutDialog::OnAccessTypeChange)
118     EVT_CHECKBOX(AccessType5_Event, SoutDialog::OnAccessTypeChange)
119     EVT_TEXT(FileName_Event, SoutDialog::OnFileChange)
120     EVT_BUTTON(FileBrowse_Event, SoutDialog::OnFileBrowse)
121
122     EVT_TEXT(NetPort1_Event, SoutDialog::OnNetChange)
123     EVT_TEXT(NetAddr1_Event, SoutDialog::OnNetChange)
124     EVT_TEXT(NetPort2_Event, SoutDialog::OnNetChange)
125     EVT_TEXT(NetAddr2_Event, SoutDialog::OnNetChange)
126     EVT_TEXT(NetPort3_Event, SoutDialog::OnNetChange)
127     EVT_TEXT(NetAddr3_Event, SoutDialog::OnNetChange)
128  
129     /* Events generated by the encapsulation panel */
130     EVT_RADIOBUTTON(EncapsulationRadio1_Event,
131                     SoutDialog::OnEncapsulationChange)
132     EVT_RADIOBUTTON(EncapsulationRadio2_Event,
133                     SoutDialog::OnEncapsulationChange)
134     EVT_RADIOBUTTON(EncapsulationRadio3_Event,
135                     SoutDialog::OnEncapsulationChange)
136     EVT_RADIOBUTTON(EncapsulationRadio4_Event,
137                     SoutDialog::OnEncapsulationChange)
138     EVT_RADIOBUTTON(EncapsulationRadio5_Event,
139                     SoutDialog::OnEncapsulationChange)
140
141     /* Events generated by the transcoding panel */
142     EVT_CHECKBOX(VideoTranscEnable_Event, SoutDialog::OnTranscodingEnable)
143     EVT_CHECKBOX(AudioTranscEnable_Event, SoutDialog::OnTranscodingEnable)
144     EVT_COMBOBOX(VideoTranscCodec_Event, SoutDialog::OnTranscodingChange)
145     EVT_COMBOBOX(AudioTranscCodec_Event, SoutDialog::OnTranscodingChange)
146     EVT_COMBOBOX(VideoTranscBitrate_Event, SoutDialog::OnTranscodingChange)
147     EVT_COMBOBOX(AudioTranscBitrate_Event, SoutDialog::OnTranscodingChange)
148
149 END_EVENT_TABLE()
150
151 /*****************************************************************************
152  * Constructor.
153  *****************************************************************************/
154 SoutDialog::SoutDialog( intf_thread_t *_p_intf, wxWindow* _p_parent ):
155     wxDialog( _p_parent, -1, wxU(_("Stream output")),
156              wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE )
157 {
158     /* Initializations */
159     p_intf = _p_intf;
160     p_parent = _p_parent;
161     SetIcon( *p_intf->p_sys->p_icon );
162
163     /* Create a panel to put everything in */
164     wxPanel *panel = new wxPanel( this, -1 );
165     panel->SetAutoLayout( TRUE );
166
167     /* Create MRL combobox */
168     wxBoxSizer *mrl_sizer_sizer = new wxBoxSizer( wxHORIZONTAL );
169     wxStaticBox *mrl_box = new wxStaticBox( panel, -1,
170                                wxU(_("Stream output MRL")) );
171     wxStaticBoxSizer *mrl_sizer = new wxStaticBoxSizer( mrl_box,
172                                                         wxHORIZONTAL );
173     wxStaticText *mrl_label = new wxStaticText( panel, -1,
174                                                 wxU(_("Destination Target:")));
175     mrl_combo = new wxComboBox( panel, MRL_Event, wxT(""),
176                                 wxPoint(20,25), wxSize(120, -1), 0, NULL );
177     mrl_combo->SetToolTip( wxU(_("You can use this field directly by typing "
178         "the full MRL you want to open.\n""Alternatively, the field will be "
179         "filled automatically when you use the controls below")) );
180
181     mrl_sizer->Add( mrl_label, 0, wxALL | wxALIGN_CENTER, 5 );
182     mrl_sizer->Add( mrl_combo, 1, wxALL | wxALIGN_CENTER, 5 );
183     mrl_sizer_sizer->Add( mrl_sizer, 1, wxEXPAND | wxALL, 5 );
184
185     /* Create the output encapsulation panel */
186     wxPanel *encapsulation_panel = EncapsulationPanel( panel );
187
188     /* Create the access output panel */
189     wxPanel *access_panel = AccessPanel( panel );
190
191     /* Create the transcoding panel */
192     wxPanel *transcoding_panel = TranscodingPanel( panel );
193
194     /* Separation */
195     wxStaticLine *static_line = new wxStaticLine( panel, wxID_OK );
196
197     /* Create the buttons */
198     wxButton *ok_button = new wxButton( panel, wxID_OK, wxU(_("OK")) );
199     ok_button->SetDefault();
200     wxButton *cancel_button = new wxButton( panel, wxID_CANCEL,
201                                             wxU(_("Cancel")) );
202
203     /* Place everything in sizers */
204     wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
205     button_sizer->Add( ok_button, 0, wxALL, 5 );
206     button_sizer->Add( cancel_button, 0, wxALL, 5 );
207     button_sizer->Layout();
208     wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
209     wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
210     panel_sizer->Add( mrl_sizer_sizer, 0, wxEXPAND, 5 );
211     panel_sizer->Add( access_panel, 1, wxEXPAND | wxALL, 5 );
212     panel_sizer->Add( encapsulation_panel, 0, wxEXPAND | wxALL, 5 );
213     panel_sizer->Add( transcoding_panel, 0, wxEXPAND | wxALL, 5 );
214     panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
215     panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALIGN_BOTTOM |
216                       wxALL, 5 );
217     panel_sizer->Layout();
218     panel->SetSizerAndFit( panel_sizer );
219     main_sizer->Add( panel, 1, wxGROW, 0 );
220     main_sizer->Layout();
221     SetSizerAndFit( main_sizer );
222 }
223
224 SoutDialog::~SoutDialog()
225 {
226 }
227
228 /*****************************************************************************
229  * Private methods.
230  *****************************************************************************/
231 void SoutDialog::UpdateMRL()
232 {
233     /* Let's start with the transcode options */
234     wxString transcode;
235     if( video_transc_checkbox->IsChecked() ||
236         audio_transc_checkbox->IsChecked() )
237     {
238         transcode = wxT("transcode{");
239         if( video_transc_checkbox->IsChecked() )
240         {
241             transcode += wxT("vcodec=") + video_codec_combo->GetValue();
242             transcode += wxT(",vb=") + video_bitrate_combo->GetValue();
243             if( audio_transc_checkbox->IsChecked() ) transcode += wxT(",");
244         }
245         if( audio_transc_checkbox->IsChecked() )
246         {
247             transcode += wxT("acodec=") + audio_codec_combo->GetValue();
248             transcode += wxT(",ab=") + audio_bitrate_combo->GetValue();
249         }
250         transcode += wxT("}");
251     }
252
253     /* Encapsulation */
254     wxString encapsulation;
255     switch( i_encapsulation_type )
256     {
257     case PS_ENCAPSULATION:
258         encapsulation = wxT("ps");
259         break;
260     case AVI_ENCAPSULATION:
261         encapsulation = wxT("avi");
262         break;
263     case OGG_ENCAPSULATION:
264         encapsulation = wxT("ogg");
265         break;
266     case MP4_ENCAPSULATION:
267         encapsulation = wxT("mp4");
268         break;
269     case TS_ENCAPSULATION:
270     default:
271         encapsulation = wxT("ts");
272         break;
273     }
274
275     /* Now continue with the duplicate option */
276     wxString dup_opts;
277     if( access_checkboxes[PLAY_ACCESS_OUT]->IsChecked() )
278     {
279         dup_opts += wxT("dst=display");
280     }
281     if( access_checkboxes[FILE_ACCESS_OUT]->IsChecked() )
282     {
283         if( !dup_opts.IsEmpty() ) dup_opts += wxT(",");
284         dup_opts += wxT("dst=std{access=file,mux=");
285         dup_opts += encapsulation + wxT(",url=");
286         dup_opts += file_combo->GetValue() + wxT("}");
287     }
288     if( access_checkboxes[HTTP_ACCESS_OUT]->IsChecked() )
289     {
290         if( !dup_opts.IsEmpty() ) dup_opts += wxT(",");
291         dup_opts += wxT("dst=std{access=http,mux=");
292         dup_opts += encapsulation + wxT(",url=");
293         dup_opts += net_addrs[HTTP_ACCESS_OUT]->GetLineText(0);
294         dup_opts += wxString::Format( wxT(":%d"),
295                                       net_ports[HTTP_ACCESS_OUT]->GetValue() );
296         dup_opts += wxT("}");
297     }
298     if( access_checkboxes[UDP_ACCESS_OUT]->IsChecked() )
299     {
300         if( !dup_opts.IsEmpty() ) dup_opts += wxT(",");
301         dup_opts += wxT("dst=std{access=udp,mux=");
302         dup_opts += encapsulation + wxT(",url=");
303         dup_opts += net_addrs[UDP_ACCESS_OUT]->GetLineText(0);
304         dup_opts += wxString::Format( wxT(":%d"),
305                                       net_ports[UDP_ACCESS_OUT]->GetValue() );
306         dup_opts += wxT("}");
307     }
308     if( access_checkboxes[RTP_ACCESS_OUT]->IsChecked() )
309     {
310         if( !dup_opts.IsEmpty() ) dup_opts += wxT(",");
311         dup_opts += wxT("dst=std{access=rtp,mux=");
312         dup_opts += encapsulation + wxT(",url=");
313         dup_opts += net_addrs[RTP_ACCESS_OUT]->GetLineText(0);
314         dup_opts += wxString::Format( wxT(":%d"),
315                                       net_ports[RTP_ACCESS_OUT]->GetValue() );
316         dup_opts += wxT("}");
317     }
318
319     wxString duplicate;
320     if( !dup_opts.IsEmpty() )
321     {
322         if( !transcode.IsEmpty() ) duplicate = wxT(":");
323         duplicate += wxT("duplicate{") + dup_opts + wxT("}");
324     }
325
326     if( !transcode.IsEmpty() || !duplicate.IsEmpty() )
327         mrl_combo->SetValue( wxT("#") + transcode + duplicate );
328     else
329         mrl_combo->SetValue( wxT("") );
330 }
331
332 wxPanel *SoutDialog::AccessPanel( wxWindow* parent )
333 {
334     int i;
335     wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
336                                   wxSize(200, 200) );
337
338     wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 4, 20 );
339     wxStaticBox *panel_box = new wxStaticBox( panel, -1,
340                                               wxU(_("Output Methods")) );
341     wxStaticBoxSizer *panel_sizer = new wxStaticBoxSizer( panel_box,
342                                                           wxVERTICAL );
343
344     static const wxString access_output_array[] =
345     {
346         wxU(_("Play locally")),
347         wxU(_("File")),
348         wxU(_("HTTP")),
349         wxU(_("UDP")),
350         wxU(_("RTP"))
351     };
352
353     for( i=0; i < ACCESS_OUT_NUM; i++ )
354     {
355         access_checkboxes[i] = new wxCheckBox( panel, AccessType1_Event + i,
356                                                access_output_array[i] );
357         access_subpanels[i] = new wxPanel( panel, -1 );
358     }
359
360     /* Play locally row */
361     wxFlexGridSizer *subpanel_sizer;
362     wxStaticText *label;
363     label = new wxStaticText( access_subpanels[0], -1, wxT("") );
364     subpanel_sizer = new wxFlexGridSizer( 1, 1, 20 );
365     subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
366     access_subpanels[0]->SetSizerAndFit( subpanel_sizer );
367
368     /* File row */
369     subpanel_sizer = new wxFlexGridSizer( 3, 1, 20 );
370     label = new wxStaticText( access_subpanels[1], -1, wxU(_("Filename")) );
371     file_combo = new wxComboBox( access_subpanels[1], FileName_Event, wxT(""),
372                                  wxPoint(20,25), wxSize(200, -1), 0, NULL );
373     wxButton *browse_button = new wxButton( access_subpanels[1],
374                                   FileBrowse_Event, wxU(_("Browse...")) );
375     subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
376     subpanel_sizer->Add( file_combo, 1,
377                          wxEXPAND | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
378     subpanel_sizer->Add( browse_button, 0,
379                          wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
380
381     access_subpanels[1]->SetSizerAndFit( subpanel_sizer );
382
383     /* Net rows */
384     for( i = HTTP_ACCESS_OUT; i < ACCESS_OUT_NUM; i++ )
385     {
386         subpanel_sizer = new wxFlexGridSizer( 4, 1, 20 );
387         label = new wxStaticText( access_subpanels[i], -1, wxU(_("Address")) );
388         net_addrs[i] = new wxTextCtrl( access_subpanels[i],
389                                    NetAddr1_Event + i - HTTP_ACCESS_OUT,
390                                    wxT(""), wxDefaultPosition,
391                                    wxSize( 200, -1 ), wxTE_PROCESS_ENTER);
392         subpanel_sizer->Add( label, 0,
393                              wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
394         subpanel_sizer->Add( net_addrs[i], 1, wxEXPAND |
395                              wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
396
397         int val = config_GetInt( p_intf, "server-port" );
398         label = new wxStaticText( access_subpanels[i], -1, wxU(_("Port")) );
399         net_ports[i] = new wxSpinCtrl( access_subpanels[i],
400                                    NetPort1_Event + i - HTTP_ACCESS_OUT,
401                                    wxString::Format(wxT("%d"), val),
402                                    wxDefaultPosition, wxDefaultSize,
403                                    wxSP_ARROW_KEYS,
404                                    0, 16000, val );
405
406         subpanel_sizer->Add( label, 0,
407                              wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
408         subpanel_sizer->Add( net_ports[i], 0,
409                              wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
410
411         access_subpanels[i]->SetSizerAndFit( subpanel_sizer );
412     }
413
414
415     /* Stuff everything into the main panel */
416     for( i=1; i < ACCESS_OUT_NUM; i++ )
417     {
418         sizer->Add( access_checkboxes[i], 0,
419                     wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL  | wxALL, 5 );
420         sizer->Add( access_subpanels[i], 1, wxEXPAND | wxALIGN_CENTER_VERTICAL
421                     | wxALIGN_LEFT  | wxALL, 5 );
422     }
423
424     panel_sizer->Add( access_checkboxes[0], 0,
425                       wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL  | wxALL, 5 );
426     panel_sizer->Add( sizer, 1, wxEXPAND | wxTOP, 3 );
427
428     panel->SetSizerAndFit( panel_sizer );
429
430     /* Update access type panel */
431     for( i=1; i < ACCESS_OUT_NUM; i++ )
432     {
433         access_subpanels[i]->Disable();
434     }
435
436     return panel;
437 }
438
439 wxPanel *SoutDialog::EncapsulationPanel( wxWindow* parent )
440 {
441     int i;
442     wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
443                                   wxSize(200, 200) );
444
445     wxStaticBox *panel_box = new wxStaticBox( panel, -1,
446                                               wxU(_("Encapsulation Method")) );
447     wxStaticBoxSizer *panel_sizer = new wxStaticBoxSizer( panel_box,
448                                                           wxHORIZONTAL );
449
450     static const wxString encapsulation_array[] =
451     {
452         wxT("MPEG TS"),
453         wxT("MPEG PS"),
454         wxT("AVI"),
455         wxT("Ogg"),
456         wxT("MP4/MOV")
457     };
458
459     /* Stuff everything into the main panel */
460     for( i=0; i < ENCAPS_NUM; i++ )
461     {
462         encapsulation_radios[i] =
463             new wxRadioButton( panel, EncapsulationRadio1_Event + i,
464                                encapsulation_array[i] );
465         panel_sizer->Add( encapsulation_radios[i], 0,
466                           wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 8 );
467     }
468
469     panel->SetSizerAndFit( panel_sizer );
470
471     /* Update encapsulation panel */
472     encapsulation_radios[TS_ENCAPSULATION]->SetValue(true);
473     i_encapsulation_type = TS_ENCAPSULATION;
474
475     return panel;
476 }
477
478 wxPanel *SoutDialog::TranscodingPanel( wxWindow* parent )
479 {
480     wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
481                                   wxSize(200, 200) );
482
483     wxStaticBox *panel_box = new wxStaticBox( panel, -1,
484                                               wxU(_("Transcoding options")) );
485     wxStaticBoxSizer *panel_sizer = new wxStaticBoxSizer( panel_box,
486                                                           wxVERTICAL );
487
488     /* Create video transcoding checkox */
489     static const wxString vcodecs_array[] =
490     {
491         wxT("mpgv"),
492         wxT("mp4v"),
493         wxT("DIV1"),
494         wxT("DIV2"),
495         wxT("DIV3"),
496         wxT("H263"),
497         wxT("I263"),
498         wxT("WMV1"),
499     };
500     static const wxString vbitrates_array[] =
501     {
502         wxT("3000"),
503         wxT("2000"),
504         wxT("1000"),
505         wxT("750"),
506         wxT("500"),
507         wxT("400"),
508         wxT("200"),
509         wxT("150"),
510         wxT("100")
511     };
512
513     wxFlexGridSizer *video_sizer = new wxFlexGridSizer( 4, 1, 20 );
514     video_transc_checkbox =
515         new wxCheckBox( panel, VideoTranscEnable_Event, wxU(_("Video codec")));
516     video_codec_combo =
517         new wxComboBox( panel, VideoTranscCodec_Event, wxT("mp4v"),
518                         wxPoint(20,25), wxDefaultSize, WXSIZEOF(vcodecs_array),
519                         vcodecs_array, wxCB_READONLY );
520     wxStaticText *bitrate_label =
521         new wxStaticText( panel, -1, wxU(_("Bitrate (kb/s)")));
522     video_bitrate_combo =
523         new wxComboBox( panel, VideoTranscBitrate_Event, wxT("1000"),
524                         wxPoint(20,25), wxDefaultSize,
525                         WXSIZEOF(vbitrates_array), vbitrates_array );
526     video_sizer->Add( video_transc_checkbox, 0,
527                       wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
528     video_sizer->Add( video_codec_combo, 1,
529                       wxEXPAND | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
530     video_sizer->Add( bitrate_label, 0,
531                       wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
532     video_sizer->Add( video_bitrate_combo, 1,
533                       wxEXPAND | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
534
535     /* Create audio transcoding checkox */
536     static const wxString acodecs_array[] =
537     {
538         wxT("mpga"),
539         wxT("a52")
540     };
541     static const wxString abitrates_array[] =
542     {
543         wxT("512"),
544         wxT("256"),
545         wxT("192"),
546         wxT("128"),
547         wxT("96")
548     };
549
550     wxFlexGridSizer *audio_sizer = new wxFlexGridSizer( 4, 1, 20 );
551     audio_transc_checkbox =
552         new wxCheckBox( panel, AudioTranscEnable_Event, wxU(_("Audio codec")));
553     audio_codec_combo =
554         new wxComboBox( panel, AudioTranscCodec_Event, wxT("mpga"),
555                         wxPoint(20,25), wxDefaultSize, WXSIZEOF(acodecs_array),
556                         acodecs_array, wxCB_READONLY );
557     bitrate_label =
558         new wxStaticText( panel, -1, wxU(_("Bitrate (kb/s)")));
559     audio_bitrate_combo =
560         new wxComboBox( panel, AudioTranscBitrate_Event, wxT("192"),
561                         wxPoint(20,25), wxDefaultSize,
562                         WXSIZEOF(abitrates_array), abitrates_array );
563     audio_sizer->Add( audio_transc_checkbox, 0,
564                       wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
565     audio_sizer->Add( audio_codec_combo, 1,
566                       wxEXPAND | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
567     audio_sizer->Add( bitrate_label, 0,
568                       wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
569     audio_sizer->Add( audio_bitrate_combo, 1,
570                       wxEXPAND | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
571
572     /* Stuff everything into the main panel */
573     panel_sizer->Add( video_sizer, 0,
574                       wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 5 );
575     panel_sizer->Add( audio_sizer, 0,
576                       wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 5 );
577
578     panel->SetSizerAndFit( panel_sizer );
579
580     /* Update transcoding panel */
581     wxCommandEvent event( 0, VideoTranscEnable_Event );
582     event.SetInt( 0 );
583     OnTranscodingEnable( event );
584     event.SetId( AudioTranscEnable_Event );
585     OnTranscodingEnable( event );
586
587     return panel;
588 }
589
590 /*****************************************************************************
591  * Events methods.
592  *****************************************************************************/
593 void SoutDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
594 {
595     mrl_combo->Append( mrl_combo->GetValue() );
596     mrl = mrl_combo->GetValue();
597     EndModal( wxID_OK );
598 }
599
600 void SoutDialog::OnCancel( wxCommandEvent& WXUNUSED(event) )
601 {
602     EndModal( wxID_CANCEL );
603 }
604
605 void SoutDialog::OnMRLChange( wxCommandEvent& event )
606 {
607     //mrl = event.GetString();
608 }
609
610 /*****************************************************************************
611  * Access output panel event methods.
612  *****************************************************************************/
613 void SoutDialog::OnAccessTypeChange( wxCommandEvent& event )
614 {
615     int i;
616     i_access_type = event.GetId() - AccessType1_Event;
617
618     access_subpanels[i_access_type]->Enable( event.GetInt() );
619
620     switch( i_access_type )
621     {
622     case UDP_ACCESS_OUT:
623     case RTP_ACCESS_OUT:
624         for( i = 1; i < ENCAPS_NUM; i++ )
625         {
626             encapsulation_radios[i]->Enable( !event.GetInt() );
627         }
628         if( event.GetInt() )
629         {
630             encapsulation_radios[TS_ENCAPSULATION]->SetValue(true);
631             i_encapsulation_type = TS_ENCAPSULATION;
632         }
633         break;
634     }
635
636     UpdateMRL();
637 }
638
639 /*****************************************************************************
640  * File access output event methods.
641  *****************************************************************************/
642 void SoutDialog::OnFileChange( wxCommandEvent& WXUNUSED(event) )
643 {
644     UpdateMRL();
645 }
646
647 void SoutDialog::OnFileBrowse( wxCommandEvent& WXUNUSED(event) )
648 {
649     wxFileDialog dialog( this, wxU(_("Save file")),
650                          wxT(""), wxT(""), wxT("*"), wxSAVE );
651
652     if( dialog.ShowModal() == wxID_OK )
653     {
654         file_combo->SetValue( dialog.GetPath() );
655         UpdateMRL();
656     }
657 }
658
659 /*****************************************************************************
660  * Net access output event methods.
661  *****************************************************************************/
662 void SoutDialog::OnNetChange( wxCommandEvent& WXUNUSED(event) )
663 {
664     UpdateMRL();
665 }
666
667 /*****************************************************************************
668  * Encapsulation panel event methods.
669  *****************************************************************************/
670 void SoutDialog::OnEncapsulationChange( wxCommandEvent& event )
671 {
672     i_encapsulation_type = event.GetId() - EncapsulationRadio1_Event;
673     UpdateMRL();
674 }
675
676 /*****************************************************************************
677  * Transcoding panel event methods.
678  *****************************************************************************/
679 void SoutDialog::OnTranscodingEnable( wxCommandEvent& event )
680 {
681     switch( event.GetId() )
682     {
683     case VideoTranscEnable_Event:
684         video_codec_combo->Enable( event.GetInt() );
685         video_bitrate_combo->Enable( event.GetInt() );
686         break;
687     case AudioTranscEnable_Event:
688         audio_codec_combo->Enable( event.GetInt() );
689         audio_bitrate_combo->Enable( event.GetInt() );
690         break;
691     }
692
693     UpdateMRL();
694 }
695
696 void SoutDialog::OnTranscodingChange( wxCommandEvent& event )
697 {
698     UpdateMRL();
699 }