]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/dialogs/sout.cpp
String updates from tonsofpcs
[vlc] / modules / gui / qt4 / dialogs / sout.cpp
index 63f1260906e4061bc3e10e767222841793452165..d83431229871f67c21ded3c6602cbba88d9a368c 100644 (file)
@@ -1,15 +1,21 @@
 /*****************************************************************************
- * sout.cpp : Stream output dialog (old-style)
+ * sout.cpp : Stream output dialog ( old-style )
  ****************************************************************************
- * Copyright (C) 2006 the VideoLAN team
+ * Copyright (C) 2007-2008 the VideoLAN team
+ * Copyright (C) 2007 Société des arts technologiques
+ * Copyright (C) 2007 Savoir-faire Linux
+ *
  * $Id$
  *
  * Authors: Clément Stenac <zorglub@videolan.org>
+ *          Jean-Baptiste Kempf <jb@videolan.org>
+ *          Jean-François Massol <jf.massol -at- gmail.com>
+ *          Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * ( at your option ) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include "dialogs/sout.hpp"
-#include "qt4.hpp"
-#include <vlc_streaming.h>
 
-#include <iostream>
 #include <QString>
 #include <QFileDialog>
 
+struct streaming_account_t
+{
+    char *psz_username; /*< username of account */
+    char *psz_password; /*< password of account */
+};
+
+struct sout_gui_descr_t
+{
+    /* Access types */
+    bool b_local;   /*< local access module */
+    bool b_file;    /*< file access module */
+    bool b_http;    /*< http access module */
+    bool b_mms;     /*< mms access module */
+    bool b_rtp;     /*< rtp access module */
+    bool b_udp;     /*< udp access module */
+    bool b_dump;    /*< dump access module */
+    bool b_icecast; /*< icecast access module */
+
+    char *psz_file;     /*< filename */
+    char *psz_http;     /*< HTTP servername or ipaddress */
+    char *psz_mms;      /*< MMS servername or ipaddress */
+    char *psz_rtp;      /*< RTP servername or ipaddress */
+    char *psz_udp;      /*< UDP servername or ipaddress */
+    char *psz_icecast;  /*< Icecast servername or ipaddress*/
+
+    int32_t i_http;     /*< http port number */
+    int32_t i_mms;      /*< mms port number */
+    int32_t i_rtp;      /*< rtp port number */
+    int32_t i_rtp_audio;      /*< rtp port number */
+    int32_t i_rtp_video;      /*< rtp port number */
+    int32_t i_udp;      /*< udp port number */
+    int32_t i_icecast;  /*< icecast port number */
+
+    /* Mux */
+    char *psz_mux;      /*< name of muxer to use in streaming */
+
+    /* Transcode */
+    bool b_soverlay; /*< enable burning overlay in the video */
+    char *psz_vcodec;   /*< video codec to use in transcoding */
+    char *psz_acodec;   /*< audio codec to use in transcoding */
+    char *psz_scodec;   /*< subtitle codec to use in transcoding */
+    int32_t i_vb;       /*< video bitrate to use in transcoding */
+    int32_t i_ab;       /*< audio bitrate to use in transcoding */
+    int32_t i_channels; /*< number of audio channels to use in transcoding */
+    float f_scale;      /*< scaling factor to use in transcoding */
+
+    /* Misc */
+    bool b_sap;   /*< send SAP announcement */
+    bool b_all_es;/*< send all elementary streams from source stream */
+    bool b_sout_keep;
+    char *psz_group;    /*< SAP Group name */
+    char *psz_name;     /*< SAP name */
+    int32_t i_ttl;      /*< Time To Live (TTL) for network traversal */
+
+    /* Icecast */
+    char *psz_icecast_mountpoint;/*< path to Icecast mountpoint */
+    struct streaming_account_t sa_icecast;  /*< Icecast account information */
+};
+
+class SoutMrl
+{
+public:
+    SoutMrl( const QString head = "")
+    {
+        mrl = head;
+        b_first = true;
+        b_has_bracket = false;
+    }
+
+    QString getMrl()
+    {
+        return mrl;
+    }
+
+    void begin( QString module )
+    {
+        if( !b_first )
+            mrl += ":";
+        b_first = false;
+
+        mrl += module;
+        b_has_bracket = false;
+    }
+    void end()
+    {
+        if( b_has_bracket )
+            mrl += "}";
+    }
+    void option( const QString option, const QString value = "" )
+    {
+        if( !b_has_bracket )
+            mrl += "{";
+        else
+            mrl += ",";
+        b_has_bracket = true;
+
+        mrl += option;
+
+        if( !value.isEmpty() )
+        {
+            char *psz = config_StringEscape( qta(value) );
+            if( psz )
+            {
+                QString v = QString( psz );
+
+                mrl += "=\"" + v + "\"";
+
+                free( psz );
+            }
+        }
+    }
+    void option( const QString name, const int i_value, const int i_precision = 10 )
+    {
+        option( name, QString::number( i_value, i_precision ) );
+    }
+    void option( const QString name, const double f_value )
+    {
+        option( name, QString::number( f_value ) );
+    }
+
+    void option( const QString name, const QString base, const int i_value, const int i_precision = 10 )
+    {
+        option( name, base + ":" + QString::number( i_value, i_precision ) );
+    }
+
+private:
+    QString mrl;
+    bool b_has_bracket;
+    bool b_first;
+};
+
+SoutDialog* SoutDialog::instance = NULL;
+
 SoutDialog::SoutDialog( QWidget *parent, intf_thread_t *_p_intf,
                      bool _transcode_only ) : QVLCDialog( parent,  _p_intf )
 {
-    setWindowTitle( qtr( "Stream output") );
+    setWindowTitle( qtr( "Stream Output" ) );
+
+    b_transcode_only = _transcode_only;
 
     /* UI stuff */
     ui.setupUi( this );
 
-#define ADD_PROFILE(name) ui.comboBox->addItem( name );
-       ADD_PROFILE("Ipod")
-       ADD_PROFILE("PSP")
-       ADD_PROFILE("GSM")
-       ADD_PROFILE("Custom")
-
-#define ADD_VCODEC( name, fourcc) ui.vCodec_2->addItem( name, QVariant( fourcc ) );
+    changeUDPandRTPmess( false );
+
+/* ADD HERE for new profiles */
+#define ADD_PROFILE( name, shortname ) ui.profileBox->addItem( qtr( name ), QVariant( QString( shortname ) ) );
+    ADD_PROFILE( "Custom" , "Custom" )
+    ADD_PROFILE( "Ogg / Theora", "theora" )
+    ADD_PROFILE( "Ogg / Vorbis", "vorbis" )
+    ADD_PROFILE( "MPEG-2", "mpeg2" )
+    ADD_PROFILE( "MP3", "mp3" )
+    ADD_PROFILE( "MPEG-4 audio AAC", "aac" )
+    ADD_PROFILE( "MPEG-4 / DivX", "mp4" )
+    ADD_PROFILE( "H264", "h264" )
+    ADD_PROFILE( "IPod (mp4/aac)", "IPod" )
+    ADD_PROFILE( "XBox", "XBox" )
+    ADD_PROFILE( "Windows (wmv/asf)", "Windows" )
+    ADD_PROFILE( "PSP", "PSP")
+
+#define ADD_VCODEC( name, fourcc ) ui.vCodecBox->addItem( name, QVariant( fourcc ) );
     ADD_VCODEC( "MPEG-1", "mp1v" )
     ADD_VCODEC( "MPEG-2", "mp2v" )
     ADD_VCODEC( "MPEG-4", "mp4v" )
     ADD_VCODEC( "DIVX 1" , "DIV1" )
-    ADD_VCODEC( "DIVX 2" , "DIV1" )
-    ADD_VCODEC( "DIVX 3" , "DIV1" )
+    ADD_VCODEC( "DIVX 2" , "DIV2" )
+    ADD_VCODEC( "DIVX 3" , "DIV3" )
     ADD_VCODEC( "H-263", "H263" )
     ADD_VCODEC( "H-264", "h264" )
     ADD_VCODEC( "WMV1", "WMV1" )
@@ -57,142 +210,240 @@ SoutDialog::SoutDialog( QWidget *parent, intf_thread_t *_p_intf,
     ADD_VCODEC( "M-JPEG", "MJPG" )
     ADD_VCODEC( "Theora", "theo" )
 
-#define ADD_ACODEC( name, fourcc) ui.aCodec_2->addItem( name, QVariant( fourcc ) );
+#define ADD_ACODEC( name, fourcc ) ui.aCodecBox->addItem( name, QVariant( fourcc ) );
     ADD_ACODEC( "MPEG Audio", "mpga" )
     ADD_ACODEC( "MP3", "mp3" )
-    ADD_ACODEC( "MPEG 4 Audio (AAC)", "mp4a")
-    ADD_ACODEC( "A52/AC-3", "a52")
+    ADD_ACODEC( "MPEG 4 Audio ( AAC )", "mp4a" )
+    ADD_ACODEC( "A52/AC-3", "a52" )
     ADD_ACODEC( "Vorbis", "vorb" )
     ADD_ACODEC( "Flac", "flac" )
     ADD_ACODEC( "Speex", "spx" )
     ADD_ACODEC( "WAV", "s16l" )
     ADD_ACODEC( "WMA", "wma" )
 
-#define ADD_SCALING( factor ) ui.vScale_2->addItem( factor ); 
+#define ADD_SCALING( factor ) ui.vScaleBox->addItem( factor );
+    ADD_SCALING( "1" )
     ADD_SCALING( "0.25" )
     ADD_SCALING( "0.5" )
     ADD_SCALING( "0.75" )
-    ADD_SCALING( "1" )
     ADD_SCALING( "1.25" )
     ADD_SCALING( "1.5" )
     ADD_SCALING( "1.75" )
     ADD_SCALING( "2" )
 
-     ui.mrlEdit->setToolTip ( qtr("Stream output string.\n This is automatically generated when you change the above settings,\n but you can update it manually." ) ) ;
+    ui.mrlEdit->setToolTip ( qtr( "Stream output string.\n"
+                "This is automatically generated "
+                 "when you change the above settings,\n"
+                 "but you can change it manually." ) ) ;
 
 //     /* Connect everything to the updateMRL function */
- #define CB(x) CONNECT( ui.x, clicked(bool), this, updateMRL() );
- #define CT(x) CONNECT( ui.x, textChanged(const QString), this, updateMRL() );
- #define CS(x) CONNECT( ui.x, valueChanged(int), this, updateMRL() );
- #define CC(x) CONNECT( ui.x, currentIndexChanged(int), this, updateMRL() );
-//     /* Output */
-     CB( fileOutput ); CB( HTTPOutput ); CB( localOutput );
-     CB( UDPOutput ); CB( MMSHOutput ); CB( rawInput );
-     CT( fileEdit ); CT( HTTPEdit ); CT( UDPEdit ); CT( MMSHEdit );
-     CS( HTTPPort ); CS( UDPPort ); CS( MMSHPort );
-//     /* Transcode */
-     CC( vCodec_2 ); CC( sCodec_2 ); CC( aCodec_2 ) ;
-     CB( transcodeVideo_2 ); CB( transcodeAudio_2 ); CB( transcodeSubs_2 );
-//     CB( sOverlay );
-     CS( vBitrate_2 ); CS( aBitrate_2 ); CS( aChannels_2 ); CC( vScale_2 );
-//     /* Mux */
-     CB( PSMux ); CB( TSMux ); CB( MPEG1Mux ); CB( OggMux ); CB( ASFMux );
-     CB( MP4Mux ); CB( MOVMux ); CB( WAVMux ); CB( RAWMux ); CB( FLVMux );
-//     /* Misc */
-     CB( soutAll ); CS( ttl ); CT( sapName ); CT( sapGroup );
-// 
-    connect( ui.comboBox, SIGNAL(activated(const QString &)), this, SLOT(setOptions()) );
-    connect( ui.fileSelectButton, SIGNAL(clicked()), this, SLOT(fileBrowse()) );
-    connect(ui.transcodeVideo_2,SIGNAL(toggled(bool)),this,SLOT(setVTranscodeOptions(bool)));
-    connect(ui.transcodeAudio_2,SIGNAL(toggled(bool)),this,SLOT(setATranscodeOptions(bool)));
-    connect(ui.transcodeSubs_2,SIGNAL(toggled(bool)),this,SLOT(setSTranscodeOptions(bool)));
-    connect(ui.rawInput,SIGNAL(toggled(bool)),this,SLOT(setRawOptions(bool)));
-
-    QPushButton *okButton = new QPushButton( qtr( "&Stream" ) );
+ #define CB( x ) CONNECT( ui.x, toggled( bool ), this, updateMRL() );
+ #define CT( x ) CONNECT( ui.x, textChanged( const QString ), this, updateMRL() );
+ #define CS( x ) CONNECT( ui.x, valueChanged( int ), this, updateMRL() );
+ #define CC( x ) CONNECT( ui.x, currentIndexChanged( int ), this, updateMRL() );
+    /* Output */
+    CB( fileOutput ); CB( HTTPOutput ); CB( localOutput );
+    CB( RTPOutput ); CB( MMSHOutput ); CB( rawInput ); CB( UDPOutput );
+    CT( fileEdit ); CT( HTTPEdit ); CT( RTPEdit ); CT( MMSHEdit ); CT( UDPEdit );
+    CT( IcecastEdit ); CT( IcecastMountpointEdit ); CT( IcecastNamePassEdit );
+    CS( HTTPPort ); CS( RTPPort ); CS( RTPPort2 ); CS( MMSHPort ); CS( UDPPort );
+    /* Transcode */
+    CC( vCodecBox ); CC( subsCodecBox ); CC( aCodecBox ) ;
+    CB( transcodeVideo ); CB( transcodeAudio ); CB( transcodeSubs );
+    /*   CB( sOverlay ); */
+    CS( vBitrateSpin ); CS( aBitrateSpin ); CS( aChannelsSpin ); CC( vScaleBox );
+    /* Mux */
+    CB( PSMux ); CB( TSMux ); CB( MPEG1Mux ); CB( OggMux ); CB( ASFMux );
+    CB( MP4Mux ); CB( MOVMux ); CB( WAVMux ); CB( RAWMux ); CB( FLVMux );
+    /* Misc */
+    CB( soutAll ); CB( soutKeep );  CS( ttl ); CT( sapName ); CT( sapGroup );
+
+    CONNECT( ui.profileBox, activated( const QString & ), this, setOptions() );
+    CONNECT( ui.fileSelectButton, clicked() , this, fileBrowse()  );
+    CONNECT( ui.transcodeVideo, toggled( bool ),
+            this, setVTranscodeOptions( bool ) );
+    CONNECT( ui.transcodeAudio, toggled( bool ),
+            this, setATranscodeOptions( bool ) );
+    CONNECT( ui.transcodeSubs, toggled( bool ),
+            this, setSTranscodeOptions( bool ) );
+    CONNECT( ui.rawInput, toggled( bool ), this, setRawOptions( bool ) );
+
+    okButton = new QPushButton( qtr( "&Stream" ) );
     QPushButton *cancelButton = new QPushButton( qtr( "&Cancel" ) );
 
     okButton->setDefault( true );
     ui.acceptButtonBox->addButton( okButton, QDialogButtonBox::AcceptRole );
     ui.acceptButtonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
 
-    BUTTONACT( okButton, ok());
-    BUTTONACT( cancelButton, cancel());
+    BUTTONACT( okButton, ok() );
+    BUTTONACT( cancelButton, cancel() );
+
+    CONNECT( ui.UDPOutput, toggled( bool ), this, changeUDPandRTPmess( bool ) );
+    CONNECT( ui.RTPOutput, clicked(bool), this, RTPtoggled( bool ) );
 
-    if( _transcode_only ) toggleSout();
+    if( b_transcode_only ) toggleSout();
 }
 
 void SoutDialog::fileBrowse()
-{ui.tabWidget->setTabEnabled(0,false);
-    QString f = QFileDialog::getOpenFileName( this, qtr("Save file"), "", "" );
-    ui.fileEdit->setText( f );
+{
+    QString fileName = QFileDialog::getSaveFileName( this, qtr( "Save file..." ), "",
+        qtr( "Containers (*.ps *.ts *.mpg *.ogg *.asf *.mp4 *.mov *.wav *.raw *.flv)" ) );
+    ui.fileEdit->setText( fileName );
     updateMRL();
 }
 
-void SoutDialog::setVTranscodeOptions(bool b_trans)
+void SoutDialog::setVTranscodeOptions( bool b_trans )
 {
-       ui.label_2->setEnabled(b_trans);
-       ui.vCodec_2->setEnabled(b_trans);
-       ui.vBitrateLabel_2->setEnabled(b_trans);
-       ui.vScaleLabel_2->setEnabled(b_trans);
-       ui.vBitrate_2->setEnabled(b_trans);
-       ui.vScaleLabel_2->setEnabled(b_trans);
-       ui.vScale_2->setEnabled(b_trans);
+    ui.vCodecLabel->setEnabled( b_trans );
+    ui.vCodecBox->setEnabled( b_trans );
+    ui.vBitrateLabel->setEnabled( b_trans );
+    ui.vBitrateSpin->setEnabled( b_trans );
+    ui.vScaleLabel->setEnabled( b_trans );
+    ui.vScaleBox->setEnabled( b_trans );
 }
 
-void SoutDialog::setATranscodeOptions(bool b_trans)
+void SoutDialog::setATranscodeOptions( bool b_trans )
 {
-       ui.label->setEnabled(b_trans);
-       ui.aCodec_2->setEnabled(b_trans);
-       ui.aBitrateLabel_2->setEnabled(b_trans);
-       ui.aBitrate_2->setEnabled(b_trans);
-       ui.s_3->setEnabled(b_trans);
-       ui.aChannels_2->setEnabled(b_trans);
+    ui.aCodecLabel->setEnabled( b_trans );
+    ui.aCodecBox->setEnabled( b_trans );
+    ui.aBitrateLabel->setEnabled( b_trans );
+    ui.aBitrateSpin->setEnabled( b_trans );
+    ui.aChannelsLabel->setEnabled( b_trans );
+    ui.aChannelsSpin->setEnabled( b_trans );
 }
 
-void SoutDialog::setSTranscodeOptions(bool b_trans)
+void SoutDialog::setSTranscodeOptions( bool b_trans )
 {
-       ui.sCodec_2->setEnabled(b_trans);
-       ui.sOverlay_2->setEnabled(b_trans);
+    ui.subsCodecBox->setEnabled( b_trans );
+    ui.subsOverlay->setEnabled( b_trans );
 }
 
-void SoutDialog::setRawOptions(bool b_raw)
+void SoutDialog::setRawOptions( bool b_raw )
 {
-       if (b_raw)
-       {
-               ui.tabWidget->setDisabled(true);
-       }
-       else
-       {
-               SoutDialog::setOptions();
-       }
+    ui.localOutput->setEnabled( !b_raw );
+    ui.HTTPOutput->setEnabled( !b_raw );
+    ui.MMSHOutput->setEnabled( !b_raw );
+    ui.UDPOutput->setEnabled( !b_raw );
+    ui.RTPOutput->setEnabled( !b_raw );
+    ui.IcecastOutput->setEnabled( !b_raw );
+    ui.UDPRTPLabel->setEnabled( !b_raw );
+
+    if( b_raw )
+        ui.tabWidget->setDisabled( true );
+    else
+        setOptions();
 }
 
 void SoutDialog::setOptions()
 {
-       /* The test is currently done with a QString, it could be done with the index, it'd depend how translation works */
-       if (ui.comboBox->currentText() == "Custom")
-       {
-               ui.tabWidget->setEnabled(true);
-       }
-       else
-       {
-               ui.tabWidget->setDisabled(true);
-       }
+    QString profileString =
+        ui.profileBox->itemData( ui.profileBox->currentIndex() ).toString();
+    msg_Dbg( p_intf, "Profile Used: %s",  qta( profileString ));
+    int index;
+
+#define setProfile( muxName, hasVideo, vCodecName, hasAudio, aCodecName ) \
+    { \
+        ui.muxName ##Mux->setChecked( true ); \
+        \
+        ui.transcodeAudio->setChecked( hasAudio ); \
+        index = ui.aCodecBox->findData( aCodecName );  \
+        if( index >= 0 ) ui.aCodecBox->setCurrentIndex( index ); \
+        \
+        ui.transcodeVideo->setChecked( hasVideo ); \
+        index = ui.vCodecBox->findData( vCodecName );  \
+        if( index >=0 ) ui.vCodecBox->setCurrentIndex( index ); \
+    }
+
+    /* ADD HERE the profiles you want and need */
+    if( profileString == "IPod" ) setProfile( MP4, true, "mp4v", true, "mp4a" )
+    else if( profileString == "theora" ) setProfile( Ogg, true, "theo", true, "vorb" )
+    else if( profileString == "vorbis" ) setProfile( Ogg, false, "", true, "vorb" )
+    else if( profileString == "mpeg2" ) setProfile( TS, true, "mp2v", true, "mpga" )
+    else if( profileString == "mp3" ) setProfile( RAW, false, "", true, "mp3" )
+    else if( profileString == "aac" ) setProfile( MP4, false, "", true, "mp4a" )
+    else if( profileString == "mp4" ) setProfile( MP4, true, "mp4v", true, "mp4a" )
+    else if( profileString == "h264" ) setProfile( TS, true, "h264", true, "mp4a" )
+    else if( profileString == "XBox" ) setProfile( ASF, true, "WMV2", true, "wma" )
+    else if( profileString == "Windows" ) setProfile( ASF, true, "WMV2", true, "wma" )
+    else if( profileString == "PSP" ) setProfile( Ogg, true, "DIV3", true, "vorb" )
+
+        /* If the profile is not a custom one, then disable the tabWidget */
+        if ( profileString == "Custom" )
+            ui.tabWidget->setEnabled( true );
+        else
+            ui.tabWidget->setDisabled( true );
+
+    /* Update the MRL !! */
+    updateMRL();
 }
 
 void SoutDialog::toggleSout()
 {
-#define TGV(x) { \
-     if( (x->isHidden()) )  \
-        x->show();          \
-     else  x->hide();\
+    //Toggle all the streaming options.
+#define HIDEORSHOW(x) if( b_transcode_only ) x->hide(); else x->show();
+    HIDEORSHOW( ui.HTTPOutput ) ; HIDEORSHOW( ui.RTPOutput ) ; HIDEORSHOW( ui.MMSHOutput ) ; HIDEORSHOW( ui.UDPOutput ) ;
+    HIDEORSHOW( ui.HTTPEdit ) ; HIDEORSHOW( ui.RTPEdit ) ; HIDEORSHOW( ui.MMSHEdit ) ; HIDEORSHOW( ui.UDPEdit ) ;
+    HIDEORSHOW( ui.HTTPLabel ) ; HIDEORSHOW( ui.RTPLabel ) ; HIDEORSHOW( ui.MMSHLabel ) ; HIDEORSHOW( ui.UDPLabel ) ;
+    HIDEORSHOW( ui.HTTPPortLabel ) ; HIDEORSHOW( ui.RTPPortLabel ) ; HIDEORSHOW( ui.MMSHPortLabel ) ; HIDEORSHOW( ui.UDPPortLabel )
+    HIDEORSHOW( ui.HTTPPort ) ; HIDEORSHOW( ui.RTPPort ) ; HIDEORSHOW( ui.MMSHPort ) ; HIDEORSHOW( ui.UDPPort ) ; HIDEORSHOW( ui.RTPPortLabel2 ); HIDEORSHOW( ui.RTPPort2 ); HIDEORSHOW( ui.UDPRTPLabel )
+
+    HIDEORSHOW( ui.sap ); HIDEORSHOW( ui.sapName );
+    HIDEORSHOW( ui.sapGroup ); HIDEORSHOW( ui.sapGroupLabel );
+    HIDEORSHOW( ui.ttlLabel ); HIDEORSHOW( ui.ttl );
+    HIDEORSHOW( ui.soutKeep );
+
+    HIDEORSHOW( ui.IcecastOutput ); HIDEORSHOW( ui.IcecastEdit );
+    HIDEORSHOW( ui.IcecastNamePassEdit ); HIDEORSHOW( ui.IcecastMountpointEdit );
+    HIDEORSHOW( ui.IcecastPort ); HIDEORSHOW( ui.IcecastLabel );
+    HIDEORSHOW( ui.IcecastPortLabel );
+    HIDEORSHOW( ui.IcecastMountpointLabel ); HIDEORSHOW( ui.IcecastNameLabel );
+#undef HIDEORSHOW
+
+    if( b_transcode_only ) okButton->setText( "&Save" );
+    else okButton->setText( "&Stream" );
+
+    setMinimumHeight( 500 );
+    resize( width(), sizeHint().height() );
+}
+
+void SoutDialog::changeUDPandRTPmess( bool b_udp )
+{
+    ui.RTPEdit->setVisible( !b_udp );
+    ui.RTPLabel->setVisible( !b_udp );
+    ui.RTPPort->setVisible( !b_udp );
+    ui.RTPPortLabel->setVisible( !b_udp );
+    ui.UDPEdit->setVisible( b_udp );
+    ui.UDPLabel->setVisible( b_udp );
+    ui.UDPPortLabel->setText( b_udp ? qtr( "Port:") : qtr( "Audio Port:" ) );
+    ui.RTPPort2->setVisible( !b_udp );
+    ui.RTPPortLabel2->setVisible( !b_udp );
 }
- TGV( ui.HTTPOutput ) ; TGV( ui.UDPOutput ) ; TGV( ui.MMSHOutput ) ;
- TGV( ui.HTTPEdit ) ; TGV( ui.UDPEdit ) ; TGV( ui.MMSHEdit ) ;
- TGV( ui.HTTPLabel ) ; TGV( ui.UDPLabel ) ; TGV( ui.MMSHLabel ) ;
- TGV( ui.HTTPPortLabel ) ; TGV( ui.UDPPortLabel ) ; TGV( ui.MMSHPortLabel ) ;
- TGV( ui.HTTPPort ) ; TGV( ui.UDPPort ) ; TGV( ui.MMSHPort ) ;
- updateGeometry();
+
+void SoutDialog::RTPtoggled( bool b_en )
+{
+    if( !b_en )
+    {
+        if( ui.RTPPort->value() == ui.UDPPort->value() )
+        {
+            ui.UDPPort->setValue( ui.UDPPort->value() + 1 );
+        }
+
+        while( ui.RTPPort2->value() == ui.UDPPort->value() ||
+                ui.RTPPort2->value() == ui.RTPPort->value() )
+        {
+            ui.RTPPort2->setValue( ui.RTPPort2->value() + 1 );
+        }
+    }
+    ui.sap->setEnabled( b_en );
+    ui.RTPLabel->setEnabled( b_en );
+    ui.RTPEdit->setEnabled( b_en );
+    ui.UDPOutput->setEnabled( b_en );
+    ui.UDPRTPLabel->setEnabled( b_en );
+    ui.UDPEdit->setEnabled( b_en );
+    ui.UDPPort->setEnabled( b_en );
+    ui.UDPPortLabel->setEnabled( b_en );
+    ui.RTPPort2->setEnabled( b_en );
+    ui.RTPPortLabel2->setEnabled( b_en );
 }
 
 void SoutDialog::ok()
@@ -200,264 +451,260 @@ void SoutDialog::ok()
     mrl = ui.mrlEdit->text();
     accept();
 }
+
 void SoutDialog::cancel()
 {
-    mrl = ui.mrlEdit->text();
+    mrl.clear();
     reject();
 }
 
 void SoutDialog::updateMRL()
 {
-       sout_gui_descr_t sout;
-       memset( &sout, 0, sizeof( sout_gui_descr_t ) );
-
-       sout.b_local = ui.localOutput->isChecked();
-       sout.b_file = ui.fileOutput->isChecked();
-       sout.b_http = ui.HTTPOutput->isChecked();
-       sout.b_mms = ui.MMSHOutput->isChecked();
-       sout.b_udp = ui.UDPOutput->isChecked();
-       sout.b_sap = ui.sap->isChecked();
-       sout.b_all_es = ui.soutAll->isChecked();
-       sout.psz_vcodec = strdup(qtu(ui.vCodec_2->itemData(ui.vCodec_2->currentIndex()).toString()));
-       sout.psz_acodec = strdup(qtu(ui.aCodec_2->itemData(ui.vCodec_2->currentIndex()).toString()));
-       sout.psz_scodec = strdup(qtu(ui.sCodec_2->itemData(ui.vCodec_2->currentIndex()).toString()));
-       sout.psz_file = strdup(qtu(ui.fileEdit->text()));
-       sout.psz_http = strdup(qtu(ui.HTTPEdit->text()));
-       sout.psz_mms = strdup(qtu(ui.MMSHEdit->text()));
-       sout.psz_udp = strdup(qtu(ui.UDPEdit->text()));
-       sout.i_http = ui.HTTPPort->value();
-       sout.i_mms = ui.MMSHPort->value();
-       sout.i_udp = ui.UDPPort->value();
-       sout.i_ab = ui.aBitrate_2->value();
-       sout.i_vb = ui.vBitrate_2->value();
-       sout.i_channels = ui.aChannels_2->value();
-       sout.f_scale = atof(qta(ui.vScale_2->currentText()));
-       sout.psz_group = strdup(qtu(ui.sapGroup->text()));
-       sout.psz_name = strdup(qtu(ui.sapName->text()));
-
-#define SMUX(x, txt) if( ui.x->isChecked() ) sout.psz_mux = strdup(txt);
-       SMUX( PSMux, "ps" );
-       SMUX( TSMux, "ts" );
-       SMUX( MPEG1Mux, "mpeg" );
-       SMUX( OggMux, "ogg" );
-       SMUX( ASFMux, "asf" );
-       SMUX( MP4Mux, "mp4" );
-       SMUX( MOVMux, "mov" );
-       SMUX( WAVMux, "wav" );
-       SMUX( RAWMux, "raw" );
-       SMUX( FLVMux, "flv" );
-
-       bool trans = false;
-       bool more = false;
-
-if (ui.transcodeVideo_2->isChecked() || ui.transcodeAudio_2->isChecked())
-{
-       if (ui.transcodeVideo_2->isChecked())
-       {
-               mrl = ":sout=#transcode{";
-               mrl.append("vcodec=");
-               mrl.append(sout.psz_vcodec);
-               mrl.append(",");
-               mrl.append("vb=");
-               mrl.append(QString::number(sout.i_vb,10));
-               mrl.append(",");
-               mrl.append("scale=");
-               mrl.append(QString::number(sout.f_scale));
-               trans = true;
-       }
-
-       if (ui.transcodeAudio_2->isChecked())
-       {
-               if (trans)
-               {
-                       mrl.append(",");
-               }
-               else
-               {
-                       mrl = ":sout=#transcode{";
-               }
-               mrl.append("acodec=");
-               mrl.append(sout.psz_acodec);
-               mrl.append(",");
-               mrl.append("ab=");
-               mrl.append(QString::number(sout.i_ab,10));
-               mrl.append(",");
-               mrl.append("channels=");
-               mrl.append(QString::number(sout.i_channels,10));
-               trans = true;
-       }
-       mrl.append("}");
+    sout_gui_descr_t sout;
+    memset( &sout, 0, sizeof( sout_gui_descr_t ) );
+    unsigned int counter = 0;
+
+    sout.b_local = ui.localOutput->isChecked();
+    sout.b_file = ui.fileOutput->isChecked();
+    sout.b_http = ui.HTTPOutput->isChecked();
+    sout.b_mms = ui.MMSHOutput->isChecked();
+    sout.b_icecast = ui.IcecastOutput->isChecked();
+    sout.b_rtp = ui.RTPOutput->isChecked();
+    sout.b_udp = ui.UDPOutput->isChecked();
+    sout.b_dump = ui.rawInput->isChecked();
+    sout.b_sap = ui.sap->isChecked();
+    sout.b_all_es = ui.soutAll->isChecked();
+    sout.b_sout_keep = ui.soutKeep->isChecked();
+    sout.psz_vcodec = strdup( qtu( ui.vCodecBox->itemData( ui.vCodecBox->currentIndex() ).toString() ) );
+    sout.psz_acodec = strdup( qtu( ui.aCodecBox->itemData( ui.aCodecBox->currentIndex() ).toString() ) );
+    sout.psz_scodec = strdup( qtu( ui.subsCodecBox->itemData( ui.subsCodecBox->currentIndex() ).toString() ) );
+    sout.psz_file = strdup( qtu( ui.fileEdit->text() ) );
+    sout.psz_http = strdup( qtu( ui.HTTPEdit->text() ) );
+    sout.psz_mms = strdup( qtu( ui.MMSHEdit->text() ) );
+    sout.psz_rtp = strdup( qtu( ui.RTPEdit->text() ) );
+    sout.psz_udp = strdup( qtu( ui.UDPEdit->text() ) );
+    sout.psz_icecast = strdup( qtu( ui.IcecastEdit->text() ) );
+    sout.sa_icecast.psz_username = strdup( qtu( ui.IcecastNamePassEdit->text() ) );
+    sout.sa_icecast.psz_password = strdup( qtu( ui.IcecastNamePassEdit->text() ) );
+    sout.psz_icecast_mountpoint = strdup( qtu( ui.IcecastMountpointEdit->text() ) );
+    sout.i_http = ui.HTTPPort->value();
+    sout.i_mms = ui.MMSHPort->value();
+    sout.i_rtp = ui.RTPPort->value();
+    sout.i_rtp_audio = sout.i_udp = ui.UDPPort->value();
+    sout.i_rtp_video = ui.RTPPort2->value();
+    sout.i_icecast = ui.IcecastPort->value();
+    sout.i_ab = ui.aBitrateSpin->value();
+    sout.i_vb = ui.vBitrateSpin->value();
+    sout.i_channels = ui.aChannelsSpin->value();
+    sout.f_scale = atof( qta( ui.vScaleBox->currentText() ) );
+    sout.psz_group = strdup( qtu( ui.sapGroup->text() ) );
+    sout.psz_name = strdup( qtu( ui.sapName->text() ) );
+
+    if ( sout.b_local ) counter++ ;
+    if ( sout.b_file ) counter++ ;
+    if ( sout.b_http ) counter++ ;
+    if ( sout.b_mms ) counter++ ;
+    if ( sout.b_rtp ) counter++ ;
+    if ( sout.b_udp ) counter ++;
+    if ( sout.b_icecast ) counter ++;
+
+#define SMUX( x, txt ) if( ui.x->isChecked() ) sout.psz_mux = strdup( txt );
+    SMUX( PSMux, "ps" );
+    SMUX( TSMux, "ts" );
+    SMUX( MPEG1Mux, "mpeg" );
+    SMUX( OggMux, "ogg" );
+    SMUX( ASFMux, "asf" );
+    SMUX( MP4Mux, "mp4" );
+    SMUX( MOVMux, "mov" );
+    SMUX( WAVMux, "wav" );
+    SMUX( RAWMux, "raw" );
+    SMUX( FLVMux, "flv" );
+    SMUX( MKVMux, "mkv" );
+
+    bool trans = false;
+    bool more = false;
+
+    SoutMrl smrl( ":sout=#" );
+
+    if ( ui.transcodeVideo->isChecked() || ui.transcodeAudio->isChecked()
+         && !ui.rawInput->isChecked() /*demuxdump speciality*/ )
+    {
+        smrl.begin( "transcode" );
+
+        if ( ui.transcodeVideo->isChecked() )
+        {
+            smrl.option( "vcodec", sout.psz_vcodec );
+            smrl.option( "vb", sout.i_vb );
+            smrl.option( "scale", sout.f_scale );
+            trans = true;
+        }
+
+        if ( ui.transcodeAudio->isChecked() )
+        {
+            smrl.option( "acodec", sout.psz_acodec );
+            smrl.option( "ab", sout.i_ab );
+            smrl.option( "channels", sout.i_channels );
+            trans = true;
+        }
+
+        smrl.end();
+
+        mrl = smrl.getMrl();
+    }
+
+    /* Special case for demuxdump */
+    if ( sout.b_file && sout.b_dump )
+    {
+        mrl = ":demux=dump :demuxdump-file=";
+        mrl.append( sout.psz_file );
+    }
+    else
+
+
+    /* Protocol output */
+    if ( sout.b_local || sout.b_file || sout.b_http ||
+         sout.b_mms || sout.b_rtp || sout.b_udp || sout.b_icecast )
+    {
+        if( counter > 1 )
+            smrl.begin( "duplicate" );
+
+#define ADD(m) do { if( counter > 1 ) { \
+                smrl.option( "dst", m.getMrl() ); \
+            } else { \
+                smrl.begin( m.getMrl() ); \
+                smrl.end(); \
+            } } while(0)
+
+        if ( sout.b_local )
+        {
+            SoutMrl m;
+            m.begin( "display" );
+            m.end();
+
+            ADD( m );
+            more = true;
+        }
+
+        if ( sout.b_file )
+        {
+            SoutMrl m;
+
+            m.begin( "std" );
+            m.option( "access", "file" );
+            if( sout.psz_mux )
+                m.option( "mux", sout.psz_mux );
+            m.option( "dst", sout.psz_file );
+            m.end();
+
+            ADD( m );
+            more = true;
+        }
+
+        if ( sout.b_http )
+        {
+            SoutMrl m;
+
+            m.begin( "std" );
+            m.option(  "access", "http" );
+            if( sout.psz_mux )
+                m.option( "mux", sout.psz_mux );
+            m.option( "dst", sout.psz_http, sout.i_http );
+            m.end();
+
+            ADD( m );
+            more = true;
+        }
+
+        if ( sout.b_mms )
+        {
+            SoutMrl m;
+
+            m.begin( "std" );
+            m.option(  "access", "mmsh" );
+            m.option( "mux", "asfh" );
+            m.option( "dst", sout.psz_mms, sout.i_mms );
+            m.end();
+
+            ADD( m );
+            more = true;
+        }
+
+        if ( sout.b_rtp )
+        {
+            SoutMrl m;
+            if ( sout.b_udp )
+            {
+                m.begin( "std" );
+                m.option(  "access", "udp" );
+                if( sout.psz_mux )
+                    m.option( "mux", sout.psz_mux );
+                m.option( "dst", sout.psz_udp, sout.i_udp );
+            }
+            else
+            {
+                m.begin( "rtp" );
+
+                if( sout.psz_rtp && *sout.psz_rtp )
+                    m.option( "dst", sout.psz_rtp );
+                if( sout.psz_mux )
+                    m.option( "mux", sout.psz_mux );
+
+                m.option( "port", sout.i_rtp );
+                if( !sout.psz_mux || strncmp( sout.psz_mux, "ts", 2 ) )
+                {
+                    m.option( "port-audio", sout.i_rtp_audio );
+                    m.option( "port-video", sout.i_rtp_video );
+                }
+            }
+
+            /* SAP */
+            if ( sout.b_sap )
+            {
+                m.option( "sap" );
+                m.option( "group", sout.psz_group );
+                m.option( "name", sout.psz_name );
+            }
+
+            m.end();
+            ADD( m );
+            more = true;
+        }
+
+        if( sout.b_icecast )
+        {
+            SoutMrl m;
+            QString url;
+
+            url = QString(sout.sa_icecast.psz_username) + "@" + sout.psz_icecast + ":" +
+                  QString::number( sout.i_icecast, 10 ) + "/" + sout.psz_icecast_mountpoint;
+
+            m.begin( "std" );
+            m.option( "access", "shout" );
+            m.option( "mux", "ogg" );
+            m.option( "dst", url );
+            m.end();
+
+            ADD( m );
+            more = true;
+        }
+
+        if ( counter )
+            smrl.end();
+
+        mrl = smrl.getMrl();
+    }
+
+    if ( sout.b_all_es )
+        mrl.append( " :sout-all" );
+
+    if ( sout.b_sout_keep )
+        mrl.append( " :sout-keep" );
+
+    ui.mrlEdit->setText( mrl );
+    free( sout.psz_acodec ); free( sout.psz_vcodec ); free( sout.psz_scodec );
+    free( sout.psz_file );free( sout.psz_http ); free( sout.psz_mms );
+    free( sout.psz_rtp ); free( sout.psz_udp ); free( sout.psz_mux );
+    free( sout.psz_name ); free( sout.psz_group );
+    free( sout.psz_icecast ); free( sout.psz_icecast_mountpoint );
+    free( sout.sa_icecast.psz_password ); free( sout.sa_icecast.psz_username );
 }
-
-       if (sout.b_local || sout.b_file || sout.b_http || sout.b_mms || sout.b_udp)
-       {
-               
-#define ISMORE() if ( more ) mrl.append(",");
-
-               if ( trans )
-               {
-                       mrl.append(":duplicate{");
-               }
-               else
-               {
-                       mrl = ":sout=#";
-               }
-
-               if ( sout.b_local )
-               {
-                       ISMORE();
-                       mrl.append("dst=display");
-                       more = true;
-               }
-
-               if ( sout.b_file )
-               {
-                       ISMORE();
-                       mrl.append("dst=std{access=file,mux=");
-                       mrl.append(sout.psz_mux);
-                       mrl.append(",dst=");
-                       mrl.append(sout.psz_file);
-                       mrl.append("}");
-                       more = true;
-               }
-
-               if ( sout.b_http)
-               {
-                       ISMORE();
-                       mrl.append("dst=std{access=http,mux=");
-                       mrl.append(sout.psz_mux);
-                       mrl.append(",dst=");
-                       mrl.append(sout.psz_http);
-                       mrl.append(":");
-                       mrl.append(QString::number(sout.i_http,10));
-                       mrl.append("}");
-                       more = true;
-               }
-
-               if ( sout.b_mms )
-               {
-                       ISMORE();
-                       mrl.append("dst=std{access=mmsh,mux=");
-                       mrl.append(sout.psz_mux);
-                       mrl.append(",dst=");
-                       mrl.append(sout.psz_mms);
-                       mrl.append(":");
-                       mrl.append(QString::number(sout.i_mms,10));
-                       mrl.append("}");
-                       more = true;
-               }
-
-               if ( sout.b_udp )
-               {
-                       ISMORE();
-                       mrl.append("dst=std{access=udp,mux=");
-                       mrl.append(sout.psz_mux);
-                       mrl.append(",dst=");
-                       mrl.append(sout.psz_udp);
-                       mrl.append(":");
-                       mrl.append(QString::number(sout.i_udp,10));
-                       if (sout.b_sap)
-                       {
-                               mrl.append(",sap,");
-                               mrl.append("group=\"");
-                               mrl.append(sout.psz_group);
-                               mrl.append("\",");
-                               mrl.append("name=\"");
-                               mrl.append(sout.psz_name);
-                               mrl.append("\"");
-                       }
-                       mrl.append("}");
-                       more = true;
-               }
-               
-               if (trans)
-               {
-                       mrl.append("}");
-               }       
-       }
-
-       if (sout.b_all_es)
-                       mrl.append(":sout-all");
-
-       
-       ui.mrlEdit->setText(mrl);
-       free( sout.psz_acodec ); free( sout.psz_vcodec ); free( sout.psz_scodec );
-       free( sout.psz_file );free( sout.psz_http ); free( sout.psz_mms );
-       free( sout.psz_udp ); free( sout.psz_mux ); 
-       free( sout.psz_name ); free( sout.psz_group );
-}
-
-// void SoutDialog::updateMRL()
-// {
-//     sout_gui_descr_t pd;
-//     memset( &pd, 0, sizeof( sout_gui_descr_t ) );
-// 
-//     /* Output */
-//     pd.b_dump = ui.rawInput->isChecked();
-//     if( pd.b_dump ) goto end;
-// 
-//     pd.b_local = ui.localOutput->isChecked();
-//     pd.b_file = ui.fileOutput->isChecked();
-//     pd.b_http = ui.HTTPOutput->isChecked();
-//     pd.b_mms = ui.MMSHOutput->isChecked();
-//     pd.b_udp = ui.UDPOutput->isChecked();
-// 
-//     pd.psz_file = ui.fileOutput->isChecked() ?
-//                             strdup(qtu( ui.fileEdit->text() ) ): NULL;
-//     pd.psz_http = ui.HTTPOutput->isChecked() ?
-//                             strdup(qtu( ui.HTTPEdit->text() ) ) : NULL;
-//     pd.psz_mms = ui.MMSHOutput->isChecked() ?
-//                             strdup(qtu( ui.MMSHEdit->text() ) ): NULL;
-//     pd.psz_udp = ui.UDPOutput->isChecked() ?
-//                             strdup( qtu( ui.UDPEdit->text() ) ): NULL;
-// 
-//     pd.i_http = ui.HTTPPort->value();
-//     pd.i_mms = ui.MMSHPort->value();
-//     pd.i_udp = ui.UDPPort->value();
-// 
-//     /* Mux */
-// #define SMUX(x, txt) if( ui.x##Mux->isChecked() ) pd.psz_mux = strdup(txt);
-//     SMUX( PS, "ps" );
-//     SMUX( TS, "ts" );
-//     SMUX( MPEG1, "mpeg" );
-//     SMUX( Ogg, "ogg" );
-//     SMUX( ASF, "asf" );
-//     SMUX( MP4, "mp4" );
-//     SMUX( MOV, "mov" );
-//     SMUX( WAV, "wav" );
-//     SMUX( RAW, "raw" );
-//     SMUX( FLV, "flv" );
-// 
-// 
-// 
-//     /* Transcode */
-// //     pd.b_soverlay = ui.sOverlay->isChecked();
-// //     pd.i_vb = ui.vBitrate->value();
-// //     pd.i_ab = ui.aBitrate->value();
-// //     pd.i_channels = ui.aChannels->value();
-// //     pd.f_scale = atof( qta( ui.vScale->currentText() ) );
-// // 
-// //     pd.psz_vcodec = ui.transcodeVideo->isChecked() ?
-// //                      strdup( qtu( ui.vCodec->itemData(
-// //                             ui.vCodec->currentIndex() ). toString() ) ) : NULL;
-// //     pd.psz_acodec = ui.transcodeAudio->isChecked() ?
-// //                      strdup( qtu( ui.aCodec->itemData(
-// //                             ui.aCodec->currentIndex() ).toString() ) ) : NULL;
-// //     pd.psz_scodec = ui.transcodeSubs->isChecked() ?
-// //                      strdup( qtu( ui.sCodec->itemData(
-// //                             ui.sCodec->currentIndex() ).toString() ) ) : NULL;
-// //     pd.b_sap = ui.sap->isChecked();
-// //     pd.b_all_es = ui.soutAll->isChecked();
-// //     pd.psz_name = qtu( ui.sapName->text() );
-// //     pd.psz_group = qtu( ui.sapGroup->text() );
-// //     pd.i_ttl = ui.ttl->value() ;
-// end:
-//     sout_chain_t* p_chain = streaming_ChainNew();
-//     streaming_GuiDescToChain( VLC_OBJECT(p_intf), p_chain, &pd );
-//     char *psz_mrl = streaming_ChainToPsz( p_chain );
-// 
-//     ui.mrlEdit->setText( qfu( strdup(psz_mrl) ) );
-//     free( pd.psz_acodec ); free( pd.psz_vcodec ); free( pd.psz_scodec );
-//     free( pd.psz_file );free( pd.psz_http ); free( pd.psz_mms );
-//     free( pd.psz_udp ); free( pd.psz_mux );
-// }