streamout.cpp
上传用户:riyaled888
上传日期:2009-03-27
资源大小:7338k
文件大小:35k
源码类别:

多媒体

开发平台:

MultiPlatform

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