]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/dialogs/sout.cpp
Qt: menu, code simplification.
[vlc] / modules / gui / qt4 / dialogs / sout.cpp
index d83431229871f67c21ded3c6602cbba88d9a368c..eeb71edfdc59cf52ca9221ec87cc68831e9bfa68 100644 (file)
@@ -32,6 +32,7 @@
 #endif
 
 #include "dialogs/sout.hpp"
+#include "util/qt_dirs.hpp"
 
 #include <QString>
 #include <QFileDialog>
@@ -72,16 +73,6 @@ struct sout_gui_descr_t
     /* 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 */
@@ -95,78 +86,6 @@ struct sout_gui_descr_t
     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,
@@ -183,7 +102,7 @@ SoutDialog::SoutDialog( QWidget *parent, intf_thread_t *_p_intf,
 
 /* ADD HERE for new profiles */
 #define ADD_PROFILE( name, shortname ) ui.profileBox->addItem( qtr( name ), QVariant( QString( shortname ) ) );
-    ADD_PROFILE( "Custom" , "Custom" )
+/*    ADD_PROFILE( "Custom" , "Custom" )
     ADD_PROFILE( "Ogg / Theora", "theora" )
     ADD_PROFILE( "Ogg / Vorbis", "vorbis" )
     ADD_PROFILE( "MPEG-2", "mpeg2" )
@@ -196,41 +115,7 @@ SoutDialog::SoutDialog( QWidget *parent, intf_thread_t *_p_intf,
     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" , "DIV2" )
-    ADD_VCODEC( "DIVX 3" , "DIV3" )
-    ADD_VCODEC( "H-263", "H263" )
-    ADD_VCODEC( "H-264", "h264" )
-    ADD_VCODEC( "WMV1", "WMV1" )
-    ADD_VCODEC( "WMV2" , "WMV2" )
-    ADD_VCODEC( "M-JPEG", "MJPG" )
-    ADD_VCODEC( "Theora", "theo" )
-
-#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( "Vorbis", "vorb" )
-    ADD_ACODEC( "Flac", "flac" )
-    ADD_ACODEC( "Speex", "spx" )
-    ADD_ACODEC( "WAV", "s16l" )
-    ADD_ACODEC( "WMA", "wma" )
-
-#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.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"
@@ -247,25 +132,11 @@ SoutDialog::SoutDialog( QWidget *parent, intf_thread_t *_p_intf,
     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.profileSelect, optionsChanged(), this, updateMRL() );
     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" ) );
@@ -286,38 +157,12 @@ SoutDialog::SoutDialog( QWidget *parent, intf_thread_t *_p_intf,
 
 void SoutDialog::fileBrowse()
 {
-    QString fileName = QFileDialog::getSaveFileName( this, qtr( "Save file..." ), "",
-        qtr( "Containers (*.ps *.ts *.mpg *.ogg *.asf *.mp4 *.mov *.wav *.raw *.flv)" ) );
-    ui.fileEdit->setText( fileName );
+    QString fileName = QFileDialog::getSaveFileName( this, qtr( "Save file..." ),
+            "", qtr( "Containers (*.ps *.ts *.mpg *.ogg *.asf *.mp4 *.mov *.wav *.raw *.flv)" ) );
+    ui.fileEdit->setText( toNativeSeparators( fileName ) );
     updateMRL();
 }
 
-void SoutDialog::setVTranscodeOptions( bool 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 )
-{
-    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 )
-{
-    ui.subsCodecBox->setEnabled( b_trans );
-    ui.subsOverlay->setEnabled( b_trans );
-}
-
 void SoutDialog::setRawOptions( bool b_raw )
 {
     ui.localOutput->setEnabled( !b_raw );
@@ -328,17 +173,18 @@ void SoutDialog::setRawOptions( bool b_raw )
     ui.IcecastOutput->setEnabled( !b_raw );
     ui.UDPRTPLabel->setEnabled( !b_raw );
 
-    if( b_raw )
-        ui.tabWidget->setDisabled( true );
+    if( b_raw ) 
+        ;
+//        ui.tabWidget->setDisabled( true );
     else
         setOptions();
 }
 
 void SoutDialog::setOptions()
 {
-    QString profileString =
+/*    QString profileString =
         ui.profileBox->itemData( ui.profileBox->currentIndex() ).toString();
-    msg_Dbg( p_intf, "Profile Used: %s",  qta( profileString ));
+    msg_Dbg( p_intf, "Profile Used: %s",  qtu( profileString )); */
     int index;
 
 #define setProfile( muxName, hasVideo, vCodecName, hasAudio, aCodecName ) \
@@ -355,7 +201,7 @@ void SoutDialog::setOptions()
     }
 
     /* ADD HERE the profiles you want and need */
-    if( profileString == "IPod" ) setProfile( MP4, true, "mp4v", true, "mp4a" )
+/*    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" )
@@ -365,10 +211,10 @@ void SoutDialog::setOptions()
     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" )
+    else if( profileString == "PSP" ) setProfile( MP4, true, "mp4v", true, "mp4a" )*/
 
         /* If the profile is not a custom one, then disable the tabWidget */
-        if ( profileString == "Custom" )
+      /*  if ( profileString == "Custom" )
             ui.tabWidget->setEnabled( true );
         else
             ui.tabWidget->setDisabled( true );
@@ -475,9 +321,9 @@ void SoutDialog::updateMRL()
     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_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_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() ) );
@@ -493,10 +339,10 @@ void SoutDialog::updateMRL()
     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_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.f_scale = atof( qtu( ui.vScaleBox->currentText() ) ); */
     sout.psz_group = strdup( qtu( ui.sapGroup->text() ) );
     sout.psz_name = strdup( qtu( ui.sapName->text() ) );
 
@@ -508,58 +354,25 @@ void SoutDialog::updateMRL()
     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" );
+    sout.psz_mux = strdup( qtu( ui.profileSelect->getMux() ) );
 
     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 );
+        mrl.append( qfu( sout.psz_file ) );
+    }
+    else {
+    if( !ui.profileSelect->getTranscode().isEmpty() )
+    {
+        smrl.begin( ui.profileSelect->getTranscode() );
+        smrl.end();
     }
-    else
-
 
     /* Protocol output */
     if ( sout.b_local || sout.b_file || sout.b_http ||
@@ -592,8 +405,8 @@ void SoutDialog::updateMRL()
             m.begin( "std" );
             m.option( "access", "file" );
             if( sout.psz_mux )
-                m.option( "mux", sout.psz_mux );
-            m.option( "dst", sout.psz_file );
+                m.option( "mux", qfu( sout.psz_mux ) );
+            m.option( "dst", qfu( sout.psz_file ) );
             m.end();
 
             ADD( m );
@@ -607,8 +420,8 @@ void SoutDialog::updateMRL()
             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.option( "mux", qfu( sout.psz_mux ) );
+            m.option( "dst", qfu( sout.psz_http ), sout.i_http );
             m.end();
 
             ADD( m );
@@ -622,7 +435,7 @@ void SoutDialog::updateMRL()
             m.begin( "std" );
             m.option(  "access", "mmsh" );
             m.option( "mux", "asfh" );
-            m.option( "dst", sout.psz_mms, sout.i_mms );
+            m.option( "dst", qfu( sout.psz_mms ), sout.i_mms );
             m.end();
 
             ADD( m );
@@ -637,17 +450,17 @@ void SoutDialog::updateMRL()
                 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 );
+                    m.option( "mux", qfu( sout.psz_mux ) );
+                m.option( "dst", qfu( sout.psz_udp ), sout.i_udp );
             }
             else
             {
                 m.begin( "rtp" );
 
                 if( sout.psz_rtp && *sout.psz_rtp )
-                    m.option( "dst", sout.psz_rtp );
+                    m.option( "dst", qfu( sout.psz_rtp ) );
                 if( sout.psz_mux )
-                    m.option( "mux", sout.psz_mux );
+                    m.option( "mux", qfu( sout.psz_mux ) );
 
                 m.option( "port", sout.i_rtp );
                 if( !sout.psz_mux || strncmp( sout.psz_mux, "ts", 2 ) )
@@ -661,8 +474,8 @@ void SoutDialog::updateMRL()
             if ( sout.b_sap )
             {
                 m.option( "sap" );
-                m.option( "group", sout.psz_group );
-                m.option( "name", sout.psz_name );
+                m.option( "group", qfu( sout.psz_group ) );
+                m.option( "name", qfu( sout.psz_name ) );
             }
 
             m.end();
@@ -675,8 +488,10 @@ void SoutDialog::updateMRL()
             SoutMrl m;
             QString url;
 
-            url = QString(sout.sa_icecast.psz_username) + "@" + sout.psz_icecast + ":" +
-                  QString::number( sout.i_icecast, 10 ) + "/" + sout.psz_icecast_mountpoint;
+            url = qfu(sout.sa_icecast.psz_username) + "@"
+                + qfu( sout.psz_icecast )
+                + ":" + QString::number( sout.i_icecast, 10 )
+                + "/" + qfu( sout.psz_icecast_mountpoint );
 
             m.begin( "std" );
             m.option( "access", "shout" );
@@ -693,6 +508,7 @@ void SoutDialog::updateMRL()
 
         mrl = smrl.getMrl();
     }
+    }
 
     if ( sout.b_all_es )
         mrl.append( " :sout-all" );
@@ -701,10 +517,11 @@ void SoutDialog::updateMRL()
         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 );
 }
+
+