]> git.sesse.net Git - vlc/blob - modules/gui/wxwindows/streamout.cpp
all:
[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.37 2003/11/27 10:34:51 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 #include <vlc/intf.h>
34
35 #include "wxwindows.h"
36 #include <wx/notebook.h>
37 #include <wx/textctrl.h>
38 #include <wx/combobox.h>
39 #include <wx/spinctrl.h>
40 #include <wx/statline.h>
41
42 #ifndef wxRB_SINGLE
43 #   define wxRB_SINGLE 0
44 #endif
45
46 /*****************************************************************************
47  * Event Table.
48  *****************************************************************************/
49
50 /* IDs for the controls and the menu commands */
51 enum
52 {
53     Notebook_Event = wxID_HIGHEST,
54     MRL_Event,
55
56     FileBrowse_Event,
57     FileName_Event,
58     FileDump_Event,
59
60     AccessType1_Event, AccessType2_Event, AccessType3_Event,
61     AccessType4_Event, AccessType5_Event, AccessType6_Event,
62     NetPort1_Event, NetPort2_Event, NetPort3_Event, NetPort4_Event,
63     NetAddr1_Event, NetAddr2_Event, NetAddr3_Event, NetAddr4_Event,
64
65     EncapsulationRadio1_Event, EncapsulationRadio2_Event,
66     EncapsulationRadio3_Event, EncapsulationRadio4_Event,
67     EncapsulationRadio5_Event, EncapsulationRadio6_Event,
68     EncapsulationRadio7_Event, EncapsulationRadio8_Event,
69
70     VideoTranscEnable_Event, VideoTranscCodec_Event, VideoTranscBitrate_Event,
71     AudioTranscEnable_Event, AudioTranscCodec_Event, AudioTranscBitrate_Event,
72     AudioTranscChans_Event,
73
74     SAPMisc_Event, SLPMisc_Event, AnnounceAddr_Event
75 };
76
77 BEGIN_EVENT_TABLE(SoutDialog, wxDialog)
78     /* Button events */
79     EVT_BUTTON(wxID_OK, SoutDialog::OnOk)
80     EVT_BUTTON(wxID_CANCEL, SoutDialog::OnCancel)
81
82     /* Events generated by the access output panel */
83     EVT_CHECKBOX(AccessType1_Event, SoutDialog::OnAccessTypeChange)
84     EVT_CHECKBOX(AccessType2_Event, SoutDialog::OnAccessTypeChange)
85     EVT_CHECKBOX(AccessType3_Event, SoutDialog::OnAccessTypeChange)
86     EVT_CHECKBOX(AccessType4_Event, SoutDialog::OnAccessTypeChange)
87     EVT_CHECKBOX(AccessType5_Event, SoutDialog::OnAccessTypeChange)
88     EVT_CHECKBOX(AccessType6_Event, SoutDialog::OnAccessTypeChange)
89     EVT_TEXT(FileName_Event, SoutDialog::OnFileChange)
90     EVT_BUTTON(FileBrowse_Event, SoutDialog::OnFileBrowse)
91     EVT_CHECKBOX(FileDump_Event, SoutDialog::OnFileDump)
92
93     EVT_TEXT(NetPort1_Event, SoutDialog::OnNetChange)
94     EVT_TEXT(NetAddr1_Event, SoutDialog::OnNetChange)
95     EVT_TEXT(NetPort2_Event, SoutDialog::OnNetChange)
96     EVT_TEXT(NetAddr2_Event, SoutDialog::OnNetChange)
97     EVT_TEXT(NetPort3_Event, SoutDialog::OnNetChange)
98     EVT_TEXT(NetAddr3_Event, SoutDialog::OnNetChange)
99     EVT_TEXT(NetPort4_Event, SoutDialog::OnNetChange)
100     EVT_TEXT(NetAddr4_Event, SoutDialog::OnNetChange)
101
102     /* Events generated by the encapsulation panel */
103     EVT_RADIOBUTTON(EncapsulationRadio1_Event,
104                     SoutDialog::OnEncapsulationChange)
105     EVT_RADIOBUTTON(EncapsulationRadio2_Event,
106                     SoutDialog::OnEncapsulationChange)
107     EVT_RADIOBUTTON(EncapsulationRadio3_Event,
108                     SoutDialog::OnEncapsulationChange)
109     EVT_RADIOBUTTON(EncapsulationRadio4_Event,
110                     SoutDialog::OnEncapsulationChange)
111     EVT_RADIOBUTTON(EncapsulationRadio5_Event,
112                     SoutDialog::OnEncapsulationChange)
113     EVT_RADIOBUTTON(EncapsulationRadio6_Event,
114                     SoutDialog::OnEncapsulationChange)
115     EVT_RADIOBUTTON(EncapsulationRadio7_Event,
116                     SoutDialog::OnEncapsulationChange)
117     EVT_RADIOBUTTON(EncapsulationRadio8_Event,
118                     SoutDialog::OnEncapsulationChange)
119
120     /* Events generated by the transcoding panel */
121     EVT_CHECKBOX(VideoTranscEnable_Event, SoutDialog::OnTranscodingEnable)
122     EVT_CHECKBOX(AudioTranscEnable_Event, SoutDialog::OnTranscodingEnable)
123     EVT_COMBOBOX(VideoTranscCodec_Event, SoutDialog::OnTranscodingChange)
124     EVT_TEXT(VideoTranscCodec_Event, SoutDialog::OnTranscodingChange)
125     EVT_COMBOBOX(AudioTranscCodec_Event, SoutDialog::OnTranscodingChange)
126     EVT_TEXT(AudioTranscCodec_Event, SoutDialog::OnTranscodingChange)
127     EVT_COMBOBOX(VideoTranscBitrate_Event, SoutDialog::OnTranscodingChange)
128     EVT_TEXT(VideoTranscBitrate_Event, SoutDialog::OnTranscodingChange)
129     EVT_COMBOBOX(AudioTranscBitrate_Event, SoutDialog::OnTranscodingChange)
130     EVT_TEXT(AudioTranscBitrate_Event, SoutDialog::OnTranscodingChange)
131     EVT_COMBOBOX(AudioTranscChans_Event, SoutDialog::OnTranscodingChange)
132     EVT_TEXT(AudioTranscChans_Event, SoutDialog::OnTranscodingChange)
133
134     /* Events generated by the misc panel */
135     EVT_CHECKBOX(SAPMisc_Event, SoutDialog::OnSAPMiscChange)
136     EVT_CHECKBOX(SLPMisc_Event, SoutDialog::OnSLPMiscChange)
137     EVT_TEXT(AnnounceAddr_Event, SoutDialog::OnAnnounceAddrChange)
138
139 END_EVENT_TABLE()
140
141 /*****************************************************************************
142  * Constructor.
143  *****************************************************************************/
144 SoutDialog::SoutDialog( intf_thread_t *_p_intf, wxWindow* _p_parent ):
145     wxDialog( _p_parent, -1, wxU(_("Stream output")),
146              wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE )
147 {
148     /* Initializations */
149     p_intf = _p_intf;
150     p_parent = _p_parent;
151     SetIcon( *p_intf->p_sys->p_icon );
152
153     /* Create a panel to put everything in */
154     wxPanel *panel = new wxPanel( this, -1 );
155     panel->SetAutoLayout( TRUE );
156
157     /* Create MRL combobox */
158     wxBoxSizer *mrl_sizer_sizer = new wxBoxSizer( wxHORIZONTAL );
159     wxStaticBox *mrl_box = new wxStaticBox( panel, -1,
160                                wxU(_("Stream output MRL")) );
161     wxStaticBoxSizer *mrl_sizer = new wxStaticBoxSizer( mrl_box,
162                                                         wxHORIZONTAL );
163     wxStaticText *mrl_label = new wxStaticText( panel, -1,
164                                                 wxU(_("Destination Target:")));
165     mrl_combo = new wxComboBox( panel, MRL_Event, wxT(""),
166                                 wxPoint(20,25), wxSize(120, -1), 0, NULL );
167     mrl_combo->SetToolTip( wxU(_("You can use this field directly by typing "
168         "the full MRL you want to open.\n""Alternatively, the field will be "
169         "filled automatically when you use the controls below")) );
170
171     mrl_sizer->Add( mrl_label, 0, wxALL | wxALIGN_CENTER, 5 );
172     mrl_sizer->Add( mrl_combo, 1, wxALL | wxALIGN_CENTER, 5 );
173     mrl_sizer_sizer->Add( mrl_sizer, 1, wxEXPAND | wxALL, 5 );
174
175     /* Create the output encapsulation panel */
176     encapsulation_panel = EncapsulationPanel( panel );
177
178     /* Create the access output panel */
179     access_panel = AccessPanel( panel );
180
181     /* Create the transcoding panel */
182     transcoding_panel = TranscodingPanel( panel );
183
184     /* Create the Misc panel */
185     misc_panel = MiscPanel( panel );
186
187     /* Separation */
188     wxStaticLine *static_line = new wxStaticLine( panel, wxID_OK );
189
190     /* Create the buttons */
191     wxButton *ok_button = new wxButton( panel, wxID_OK, wxU(_("OK")) );
192     ok_button->SetDefault();
193     wxButton *cancel_button = new wxButton( panel, wxID_CANCEL,
194                                             wxU(_("Cancel")) );
195
196     /* Place everything in sizers */
197     wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
198     button_sizer->Add( ok_button, 0, wxALL, 5 );
199     button_sizer->Add( cancel_button, 0, wxALL, 5 );
200     button_sizer->Layout();
201     wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
202     wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
203     panel_sizer->Add( mrl_sizer_sizer, 0, wxEXPAND, 5 );
204     panel_sizer->Add( access_panel, 1, wxEXPAND | wxALL, 5 );
205     panel_sizer->Add( encapsulation_panel, 0, wxEXPAND | wxALL, 5 );
206     panel_sizer->Add( transcoding_panel, 0, wxEXPAND | wxALL, 5 );
207     panel_sizer->Add( misc_panel, 0, wxEXPAND | wxALL, 5 );
208     panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
209     panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALIGN_BOTTOM |
210                       wxALL, 5 );
211     panel_sizer->Layout();
212     panel->SetSizerAndFit( panel_sizer );
213     main_sizer->Add( panel, 1, wxGROW, 0 );
214     main_sizer->Layout();
215     SetSizerAndFit( main_sizer );
216 }
217
218 SoutDialog::~SoutDialog()
219 {
220 }
221
222 wxArrayString SoutDialog::GetOptions()
223 {
224    return SeparateEntries( mrl_combo->GetValue() );
225 }
226
227 /*****************************************************************************
228  * Private methods.
229  *****************************************************************************/
230 void SoutDialog::UpdateMRL()
231 {
232     /* Check the demux dump option */
233     if( dump_checkbox->IsChecked() )
234     {
235         wxString dumpfile;
236
237         if( file_combo->GetValue().size() )
238             dumpfile = wxT(" :demuxdump-file=\"") +
239                        file_combo->GetValue() + wxT("\"");
240         mrl_combo->SetValue( wxT(":demux=demuxdump") + dumpfile );
241
242         return;
243     }
244
245     /* Let's start with the transcode options */
246     wxString transcode;
247     if( video_transc_checkbox->IsChecked() ||
248         audio_transc_checkbox->IsChecked() )
249     {
250         transcode = wxT("transcode{");
251         if( video_transc_checkbox->IsChecked() )
252         {
253             transcode += wxT("vcodec=") + video_codec_combo->GetValue();
254             transcode += wxT(",vb=") + video_bitrate_combo->GetValue();
255             if( audio_transc_checkbox->IsChecked() ) transcode += wxT(",");
256         }
257         if( audio_transc_checkbox->IsChecked() )
258         {
259             transcode += wxT("acodec=") + audio_codec_combo->GetValue();
260             transcode += wxT(",ab=") + audio_bitrate_combo->GetValue();
261             transcode += wxT(",channels=") + audio_channels_combo->GetValue();
262         }
263         transcode += wxT("}");
264     }
265
266     /* Encapsulation */
267     wxString encapsulation;
268     switch( i_encapsulation_type )
269     {
270     case PS_ENCAPSULATION:
271         encapsulation = wxT("ps");
272         break;
273     case MPEG1_ENCAPSULATION:
274         encapsulation = wxT("mpeg1");
275         break;
276     case AVI_ENCAPSULATION:
277         encapsulation = wxT("avi");
278         break;
279     case OGG_ENCAPSULATION:
280         encapsulation = wxT("ogg");
281         break;
282     case MP4_ENCAPSULATION:
283         encapsulation = wxT("mp4");
284         break;
285     case MOV_ENCAPSULATION:
286         encapsulation = wxT("mov");
287         break;
288     case ASF_ENCAPSULATION:
289         encapsulation = wxT("asf");
290         break;
291     case TS_ENCAPSULATION:
292     default:
293         encapsulation = wxT("ts");
294         break;
295     }
296
297     /* Now continue with the duplicate option */
298     wxString dup_opts;
299     if( access_checkboxes[PLAY_ACCESS_OUT]->IsChecked() )
300     {
301         dup_opts += wxT("dst=display");
302     }
303     if( access_checkboxes[FILE_ACCESS_OUT]->IsChecked() )
304     {
305         if( !dup_opts.IsEmpty() ) dup_opts += wxT(",");
306         dup_opts += wxT("dst=std{access=file,mux=");
307         dup_opts += encapsulation + wxT(",url=\"");
308         dup_opts += file_combo->GetValue() + wxT("\"}");
309     }
310     if( access_checkboxes[HTTP_ACCESS_OUT]->IsChecked() )
311     {
312         if( !dup_opts.IsEmpty() ) dup_opts += wxT(",");
313         dup_opts += wxT("dst=std{access=http,mux=");
314         dup_opts += encapsulation + wxT(",url=");
315         dup_opts += net_addrs[HTTP_ACCESS_OUT]->GetLineText(0);
316         dup_opts += wxString::Format( wxT(":%d"),
317                                       net_ports[HTTP_ACCESS_OUT]->GetValue() );
318         dup_opts += wxT("}");
319     }
320     if( access_checkboxes[MMSH_ACCESS_OUT]->IsChecked() )
321     {
322         if( !dup_opts.IsEmpty() ) dup_opts += wxT(",");
323         dup_opts += wxT("dst=std{access=mmsh,mux=");
324         dup_opts += encapsulation;
325         if( i_encapsulation_type == ASF_ENCAPSULATION ) dup_opts += wxT("h");
326         dup_opts += wxT(",url=");
327         dup_opts += net_addrs[HTTP_ACCESS_OUT]->GetLineText(0);
328         dup_opts += wxString::Format( wxT(":%d"),
329                                       net_ports[MMSH_ACCESS_OUT]->GetValue() );
330         dup_opts += wxT("}");
331     }
332     if( access_checkboxes[UDP_ACCESS_OUT]->IsChecked() )
333     {
334         if( !dup_opts.IsEmpty() ) dup_opts += wxT(",");
335         dup_opts += wxT("dst=std{access=udp,mux=");
336         dup_opts += encapsulation + wxT(",url=");
337         dup_opts += net_addrs[UDP_ACCESS_OUT]->GetLineText(0);
338         dup_opts += wxString::Format( wxT(":%d"),
339                                       net_ports[UDP_ACCESS_OUT]->GetValue() );
340
341         /* SAP only if UDP */
342         if( sap_checkbox->IsChecked() )
343         {
344             dup_opts += wxT(",sap=\"");
345             dup_opts += announce_addr->GetLineText(0);
346             dup_opts += wxT("\"");
347         }
348
349         /* SLP only if UDP */
350         if( slp_checkbox->IsChecked() )
351         {
352             dup_opts += wxT(",slp=\"");
353             dup_opts += announce_addr->GetLineText(0);
354             dup_opts += wxT("\"");
355         }
356
357         dup_opts += wxT("}");
358     }
359     if( access_checkboxes[RTP_ACCESS_OUT]->IsChecked() )
360     {
361         if( !dup_opts.IsEmpty() ) dup_opts += wxT(",");
362         dup_opts += wxT("dst=std{access=rtp,mux=");
363         dup_opts += encapsulation + wxT(",url=");
364         dup_opts += net_addrs[RTP_ACCESS_OUT]->GetLineText(0);
365         dup_opts += wxString::Format( wxT(":%d"),
366                                       net_ports[RTP_ACCESS_OUT]->GetValue() );
367         dup_opts += wxT("}");
368     }
369
370     wxString duplicate;
371     if( !dup_opts.IsEmpty() )
372     {
373         if( !transcode.IsEmpty() ) duplicate = wxT(":");
374         duplicate += wxT("duplicate{") + dup_opts + wxT("}");
375     }
376
377     if( !transcode.IsEmpty() || !duplicate.IsEmpty() )
378         mrl_combo->SetValue( wxT(":sout=#") + transcode + duplicate );
379     else
380         mrl_combo->SetValue( wxT("") );
381 }
382
383 wxPanel *SoutDialog::AccessPanel( wxWindow* parent )
384 {
385     int i;
386     wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
387                                   wxSize(200, 200) );
388
389     wxStaticBox *panel_box = new wxStaticBox( panel, -1,
390                                               wxU(_("Output Methods")) );
391     wxStaticBoxSizer *panel_sizer = new wxStaticBoxSizer( panel_box,
392                                                           wxVERTICAL );
393
394     wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 4, 20 );
395     static const wxString access_output_array[] =
396     {
397         wxU(_("Play locally")),
398         wxU(_("File")),
399         wxU(_("HTTP")),
400         wxU(_("MMSH")),
401         wxU(_("UDP")),
402         wxU(_("RTP"))
403     };
404
405     for( i=0; i < ACCESS_OUT_NUM; i++ )
406     {
407         access_checkboxes[i] = new wxCheckBox( panel, AccessType1_Event + i,
408                                                access_output_array[i] );
409         access_subpanels[i] = new wxPanel( panel, -1 );
410     }
411
412     /* Play locally row */
413     wxFlexGridSizer *subpanel_sizer;
414     wxStaticText *label;
415     label = new wxStaticText( access_subpanels[0], -1, wxT("") );
416     subpanel_sizer = new wxFlexGridSizer( 1, 1, 20 );
417     subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
418     access_subpanels[0]->SetSizerAndFit( subpanel_sizer );
419     access_subpanels[0]->Hide();
420
421     /* File row */
422     subpanel_sizer = new wxFlexGridSizer( 3, 2, 20 );
423     label = new wxStaticText( access_subpanels[1], -1, wxU(_("Filename")) );
424     file_combo = new wxComboBox( access_subpanels[1], FileName_Event, wxT(""),
425                                  wxPoint(20,25), wxSize(200, -1), 0, NULL );
426     wxButton *browse_button = new wxButton( access_subpanels[1],
427                                   FileBrowse_Event, wxU(_("Browse...")) );
428     subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
429     subpanel_sizer->Add( file_combo, 1,
430                          wxEXPAND | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
431     subpanel_sizer->Add( browse_button, 0,
432                          wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
433     subpanel_sizer->Add( new wxPanel(access_subpanels[1], -1), 0,
434                          wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
435     dump_checkbox = new wxCheckBox( access_subpanels[1], FileDump_Event,
436                                     wxU(_("Dump raw input")) );
437     subpanel_sizer->Add( dump_checkbox, 0,
438                          wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxTOP, 5 );
439
440     access_subpanels[1]->SetSizerAndFit( subpanel_sizer );
441
442     /* Net rows */
443     for( i = HTTP_ACCESS_OUT; i < ACCESS_OUT_NUM; i++ )
444     {
445         subpanel_sizer = new wxFlexGridSizer( 4, 1, 20 );
446         label = new wxStaticText( access_subpanels[i], -1, wxU(_("Address")) );
447         net_addrs[i] = new wxTextCtrl( access_subpanels[i],
448                                    NetAddr1_Event + i - HTTP_ACCESS_OUT,
449                                    wxT(""), wxDefaultPosition,
450                                    wxSize( 200, -1 ), wxTE_PROCESS_ENTER);
451         subpanel_sizer->Add( label, 0,
452                              wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
453         subpanel_sizer->Add( net_addrs[i], 1, wxEXPAND |
454                              wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
455
456         int val = config_GetInt( p_intf, "server-port" );
457         label = new wxStaticText( access_subpanels[i], -1, wxU(_("Port")) );
458         net_ports[i] = new wxSpinCtrl( access_subpanels[i],
459                                    NetPort1_Event + i - HTTP_ACCESS_OUT,
460                                    wxString::Format(wxT("%d"), val),
461                                    wxDefaultPosition, wxDefaultSize,
462                                    wxSP_ARROW_KEYS,
463                                    0, 16000, val );
464
465         subpanel_sizer->Add( label, 0,
466                              wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
467         subpanel_sizer->Add( net_ports[i], 0,
468                              wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
469
470         access_subpanels[i]->SetSizerAndFit( subpanel_sizer );
471     }
472
473
474     /* Stuff everything into the main panel */
475     for( i=1; i < ACCESS_OUT_NUM; i++ )
476     {
477         sizer->Add( access_checkboxes[i], 0,
478                     wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL  | wxALL, 5 );
479         sizer->Add( access_subpanels[i], 1, wxEXPAND | wxALIGN_CENTER_VERTICAL
480                     | wxALIGN_LEFT  | wxALL, 5 );
481     }
482
483     panel_sizer->Add( access_checkboxes[0], 0,
484                       wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL  | wxALL, 5 );
485     panel_sizer->Add( sizer, 1, wxEXPAND | wxTOP, 3 );
486
487     panel->SetSizerAndFit( panel_sizer );
488
489     /* Update access type panel */
490     for( i=1; i < ACCESS_OUT_NUM; i++ )
491     {
492         access_subpanels[i]->Disable();
493     }
494
495     return panel;
496 }
497
498 wxPanel *SoutDialog::MiscPanel( wxWindow* parent )
499 {
500     wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
501                                   wxSize(200, 200) );
502
503     wxStaticBox *panel_box = new wxStaticBox( panel, -1,
504                                    wxU(_("Miscellaneous Options")) );
505     wxStaticBoxSizer *panel_sizer = new wxStaticBoxSizer( panel_box,
506                                                           wxVERTICAL );
507
508     /* Announce Row */
509     misc_subpanels[ANN_MISC_SOUT] = new wxPanel( panel, -1 );
510     wxFlexGridSizer *subpanel_sizer = new wxFlexGridSizer( 4, 4, 20 );
511
512     sap_checkbox = new wxCheckBox( misc_subpanels[ANN_MISC_SOUT],SAPMisc_Event,
513                                    wxU(_("SAP Announce")) );
514     slp_checkbox = new wxCheckBox( misc_subpanels[ANN_MISC_SOUT],SLPMisc_Event,
515                                    wxU(_("SLP Announce")) );
516
517     wxStaticText *label = new wxStaticText( misc_subpanels[ANN_MISC_SOUT], -1,
518                                             wxU(_("Channel Name")) );
519     announce_addr = new wxTextCtrl( misc_subpanels[ANN_MISC_SOUT],
520                                     AnnounceAddr_Event,
521                                     wxT(""), wxDefaultPosition,
522                                     wxSize( 200, -1 ), wxTE_PROCESS_ENTER);
523
524     subpanel_sizer->Add( sap_checkbox, 0,
525                          wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
526     subpanel_sizer->Add( slp_checkbox, 0,
527                          wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
528     subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
529     subpanel_sizer->Add( announce_addr, 1, wxEXPAND |
530                          wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
531
532     misc_subpanels[ANN_MISC_SOUT]->SetSizerAndFit( subpanel_sizer );
533
534     /* Stuff everything into the main panel */
535     panel_sizer->Add( misc_subpanels[ANN_MISC_SOUT], 1,
536                       wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 5 );
537
538     panel->SetSizerAndFit( panel_sizer );
539
540     /* Update misc panel */
541     misc_subpanels[ANN_MISC_SOUT]->Disable();
542     announce_addr->Disable();
543
544     return panel;
545 }
546
547 wxPanel *SoutDialog::EncapsulationPanel( wxWindow* parent )
548 {
549     int i;
550     wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
551                                   wxSize(200, 200) );
552
553     wxStaticBox *panel_box = new wxStaticBox( panel, -1,
554                                               wxU(_("Encapsulation Method")) );
555     wxStaticBoxSizer *panel_sizer = new wxStaticBoxSizer( panel_box,
556                                                           wxHORIZONTAL );
557
558     static const wxString encapsulation_array[] =
559     {
560         wxT("MPEG TS"),
561         wxT("MPEG PS"),
562         wxT("MPEG 1"),
563         wxT("Ogg"),
564         wxT("ASF"),
565         wxT("AVI"),
566         wxT("MP4"),
567         wxT("MOV")
568     };
569
570     /* Stuff everything into the main panel */
571     for( i=0; i < ENCAPS_NUM; i++ )
572     {
573         encapsulation_radios[i] =
574             new wxRadioButton( panel, EncapsulationRadio1_Event + i,
575                                encapsulation_array[i] );
576         panel_sizer->Add( encapsulation_radios[i], 0,
577                           wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
578                           wxALL, 4 );
579     }
580
581     panel->SetSizerAndFit( panel_sizer );
582
583     /* Update encapsulation panel */
584     encapsulation_radios[TS_ENCAPSULATION]->SetValue(true);
585     i_encapsulation_type = TS_ENCAPSULATION;
586
587     return panel;
588 }
589
590 wxPanel *SoutDialog::TranscodingPanel( wxWindow* parent )
591 {
592     wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
593                                   wxSize(200, 200) );
594
595     wxStaticBox *panel_box = new wxStaticBox( panel, -1,
596                                               wxU(_("Transcoding options")) );
597     wxStaticBoxSizer *panel_sizer = new wxStaticBoxSizer( panel_box,
598                                                           wxVERTICAL );
599
600     /* Create video transcoding checkox */
601     static const wxString vcodecs_array[] =
602     {
603         wxT("mp1v"),
604         wxT("mp2v"),
605         wxT("mp4v"),
606         wxT("DIV1"),
607         wxT("DIV2"),
608         wxT("DIV3"),
609         wxT("H263"),
610         wxT("I263"),
611         wxT("WMV1"),
612         wxT("WMV2"),
613         wxT("MJPG"),
614         wxT("theo")
615     };
616     static const wxString vbitrates_array[] =
617     {
618         wxT("3072"),
619         wxT("2048"),
620         wxT("1024"),
621         wxT("768"),
622         wxT("512"),
623         wxT("384"),
624         wxT("256"),
625         wxT("192"),
626         wxT("128"),
627         wxT("96"),
628         wxT("64"),
629         wxT("32"),
630         wxT("16")
631     };
632
633     wxFlexGridSizer *video_sizer = new wxFlexGridSizer( 4, 1, 20 );
634     video_transc_checkbox =
635         new wxCheckBox( panel, VideoTranscEnable_Event, wxU(_("Video codec")));
636     video_codec_combo =
637         new wxComboBox( panel, VideoTranscCodec_Event, wxT(""),
638                         wxPoint(20,25), wxDefaultSize, WXSIZEOF(vcodecs_array),
639                         vcodecs_array, wxCB_READONLY );
640     video_codec_combo->SetSelection(2);
641     wxStaticText *bitrate_label =
642         new wxStaticText( panel, -1, wxU(_("Bitrate (kb/s)")));
643     video_bitrate_combo =
644         new wxComboBox( panel, VideoTranscBitrate_Event, wxT("1024"),
645                         wxPoint(20,25), wxDefaultSize,
646                         WXSIZEOF(vbitrates_array), vbitrates_array );
647     video_sizer->Add( video_transc_checkbox, 0,
648                       wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
649     video_sizer->Add( video_codec_combo, 1,
650                       wxEXPAND | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
651     video_sizer->Add( bitrate_label, 0,
652                       wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
653     video_sizer->Add( video_bitrate_combo, 1,
654                       wxEXPAND | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
655
656     /* Create audio transcoding checkox */
657     static const wxString acodecs_array[] =
658     {
659         wxT("mpga"),
660         wxT("mp3"),
661         wxT("a52"),
662         wxT("vorb"),
663         wxT("flac"),
664         wxT("spx")
665     };
666     static const wxString abitrates_array[] =
667     {
668         wxT("512"),
669         wxT("256"),
670         wxT("192"),
671         wxT("128"),
672         wxT("96"),
673         wxT("64"),
674         wxT("32"),
675         wxT("16")
676     };
677     static const wxString achannels_array[] =
678     {
679         wxT("1"),
680         wxT("2"),
681         wxT("4"),
682         wxT("6")
683     };
684
685     wxFlexGridSizer *audio_sizer = new wxFlexGridSizer( 3, 1, 20 );
686     audio_transc_checkbox =
687         new wxCheckBox( panel, AudioTranscEnable_Event, wxU(_("Audio codec")));
688     audio_codec_combo =
689         new wxComboBox( panel, AudioTranscCodec_Event, wxT(""),
690                         wxPoint(10,25), wxDefaultSize, WXSIZEOF(acodecs_array),
691                         acodecs_array, wxCB_READONLY );
692     audio_codec_combo->SetSelection(0);
693 #if defined( __WXMSW__ )
694     wxFlexGridSizer *audio_sub_sizer = new wxFlexGridSizer( 4, 5, 20 );
695 #else
696     wxFlexGridSizer *audio_sub_sizer = new wxFlexGridSizer( 2, 5, 20 );
697 #endif
698     bitrate_label =
699         new wxStaticText( panel, -1, wxU(_("Bitrate (kb/s)")));
700     audio_bitrate_combo =
701         new wxComboBox( panel, AudioTranscBitrate_Event, wxT("192"),
702                         wxPoint(10,25), wxDefaultSize,
703                         WXSIZEOF(abitrates_array), abitrates_array );
704     wxStaticText *channels_label =
705         new wxStaticText( panel, -1, wxU(_("Channels")));
706     audio_channels_combo =
707         new wxComboBox( panel, AudioTranscChans_Event, wxT(""),
708                         wxPoint(10,25), wxDefaultSize,
709                         WXSIZEOF(achannels_array), achannels_array );
710     audio_channels_combo->SetSelection(1);
711     audio_sub_sizer->Add( bitrate_label, 0,
712                       wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
713     audio_sub_sizer->Add( audio_bitrate_combo, 1,
714                       wxEXPAND | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
715     audio_sub_sizer->Add( channels_label, 0,
716                       wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
717     audio_sub_sizer->Add( audio_channels_combo, 1,
718                       wxEXPAND | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
719
720     audio_sizer->Add( audio_transc_checkbox, 0,
721                       wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
722     audio_sizer->Add( audio_codec_combo, 1,
723                       wxEXPAND | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
724     audio_sizer->Add( audio_sub_sizer, 1,
725                       wxEXPAND | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
726
727     /* Stuff everything into the main panel */
728     panel_sizer->Add( video_sizer, 0,
729                       wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 5 );
730     panel_sizer->Add( audio_sizer, 0,
731                       wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 5 );
732
733     panel->SetSizerAndFit( panel_sizer );
734
735     /* Update transcoding panel */
736     wxCommandEvent event( 0, VideoTranscEnable_Event );
737     event.SetInt( 0 );
738     OnTranscodingEnable( event );
739     event.SetId( AudioTranscEnable_Event );
740     OnTranscodingEnable( event );
741
742     return panel;
743 }
744
745 /*****************************************************************************
746  * Events methods.
747  *****************************************************************************/
748 void SoutDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
749 {
750     mrl_combo->Append( mrl_combo->GetValue() );
751     EndModal( wxID_OK );
752 }
753
754 void SoutDialog::OnCancel( wxCommandEvent& WXUNUSED(event) )
755 {
756     EndModal( wxID_CANCEL );
757 }
758
759 void SoutDialog::OnMRLChange( wxCommandEvent& event )
760 {
761     //mrl = event.GetString();
762 }
763
764 /*****************************************************************************
765  * Access output panel event methods.
766  *****************************************************************************/
767 void SoutDialog::OnAccessTypeChange( wxCommandEvent& event )
768 {
769     int i;
770     i_access_type = event.GetId() - AccessType1_Event;
771
772     access_subpanels[i_access_type]->Enable( event.GetInt() );
773
774     switch( i_access_type )
775     {
776     case UDP_ACCESS_OUT:
777         misc_subpanels[ANN_MISC_SOUT]->Enable( event.GetInt() );
778
779     case RTP_ACCESS_OUT:
780         for( i = 1; i < ENCAPS_NUM; i++ )
781         {
782             encapsulation_radios[i]->Enable( !event.GetInt() );
783         }
784         if( event.GetInt() )
785         {
786             encapsulation_radios[TS_ENCAPSULATION]->SetValue(true);
787             i_encapsulation_type = TS_ENCAPSULATION;
788         }
789         break;
790     }
791     UpdateMRL();
792 }
793
794 /*****************************************************************************
795  * AnnounceMisc panel event methods.
796  *****************************************************************************/
797 void SoutDialog::OnSAPMiscChange( wxCommandEvent& event )
798 {
799     if( !slp_checkbox->IsChecked() )
800     {
801         announce_addr->Enable( event.GetInt() );
802     }
803     UpdateMRL();
804 }
805
806 void SoutDialog::OnSLPMiscChange( wxCommandEvent& event )
807 {
808     if( !sap_checkbox->IsChecked() )
809     {
810         announce_addr->Enable( event.GetInt() );
811     }
812     UpdateMRL();
813 }
814
815 /*****************************************************************************
816  * SAPAddr panel event methods.
817  *****************************************************************************/
818 void SoutDialog::OnAnnounceAddrChange( wxCommandEvent& WXUNUSED(event) )
819 {
820     UpdateMRL();
821 }
822
823 /*****************************************************************************
824  * File access output event methods.
825  *****************************************************************************/
826 void SoutDialog::OnFileChange( wxCommandEvent& WXUNUSED(event) )
827 {
828     UpdateMRL();
829 }
830
831 void SoutDialog::OnFileBrowse( wxCommandEvent& WXUNUSED(event) )
832 {
833     wxFileDialog dialog( this, wxU(_("Save file")), wxT(""), wxT(""), wxT("*"),
834                          wxSAVE | wxOVERWRITE_PROMPT );
835
836     if( dialog.ShowModal() == wxID_OK )
837     {
838         file_combo->SetValue( dialog.GetPath() );
839         UpdateMRL();
840     }
841 }
842
843 void SoutDialog::OnFileDump( wxCommandEvent& event )
844 {
845     misc_panel->Enable( !event.GetInt() );
846     encapsulation_panel->Enable( !event.GetInt() );
847     transcoding_panel->Enable( !event.GetInt() );
848
849     for( int i = 0; i < ACCESS_OUT_NUM; i++ )
850     {
851         if( i != FILE_ACCESS_OUT )
852         {
853             access_checkboxes[i]->Enable( !event.GetInt() );
854             access_subpanels[i]->Enable( !event.GetInt() &&
855                                          access_checkboxes[i]->IsChecked() );
856         }
857     }
858
859     UpdateMRL();
860 }
861
862 /*****************************************************************************
863  * Net access output event methods.
864  *****************************************************************************/
865 void SoutDialog::OnNetChange( wxCommandEvent& WXUNUSED(event) )
866 {
867     UpdateMRL();
868 }
869
870 /*****************************************************************************
871  * Encapsulation panel event methods.
872  *****************************************************************************/
873 void SoutDialog::OnEncapsulationChange( wxCommandEvent& event )
874 {
875     i_encapsulation_type = event.GetId() - EncapsulationRadio1_Event;
876     UpdateMRL();
877 }
878
879 /*****************************************************************************
880  * Transcoding panel event methods.
881  *****************************************************************************/
882 void SoutDialog::OnTranscodingEnable( wxCommandEvent& event )
883 {
884     switch( event.GetId() )
885     {
886     case VideoTranscEnable_Event:
887         video_codec_combo->Enable( event.GetInt() );
888         video_bitrate_combo->Enable( event.GetInt() );
889         break;
890     case AudioTranscEnable_Event:
891         audio_codec_combo->Enable( event.GetInt() );
892         audio_bitrate_combo->Enable( event.GetInt() );
893         audio_channels_combo->Enable( event.GetInt() );
894         break;
895     }
896
897     UpdateMRL();
898 }
899
900 void SoutDialog::OnTranscodingChange( wxCommandEvent& event )
901 {
902     UpdateMRL();
903 }