]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/dialogs/sout.cpp
Try to fix Sout Dialog ( Part 1 )
[vlc] / modules / gui / qt4 / dialogs / sout.cpp
index 0d2df801d75e035de9c95257901533a96cac230c..551fbc1d7edf82bc1cc583c27db7c8a231cabaee 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * 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
  *
  * 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 <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_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 */
+    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 */
+};
+
+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 );
 
-    ui.UDPEdit->hide(); ui.UDPLabel->hide();
-    ui.UDPPort->hide(); ui.UDPPortLabel->hide();
+    changeUDPandRTPmess( false );
+
 /* ADD HERE for new profiles */
 #define ADD_PROFILE( name, shortname ) ui.profileBox->addItem( qtr( name ), QVariant( QString( shortname ) ) );
     ADD_PROFILE( "Custom" , "Custom" )
@@ -60,8 +120,8 @@ SoutDialog::SoutDialog( QWidget *parent, intf_thread_t *_p_intf,
     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" )
@@ -90,8 +150,10 @@ SoutDialog::SoutDialog( QWidget *parent, intf_thread_t *_p_intf,
     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 update it manually." ) ) ;
 
 //     /* Connect everything to the updateMRL function */
  #define CB( x ) CONNECT( ui.x, toggled( bool ), this, updateMRL() );
@@ -133,16 +195,11 @@ SoutDialog::SoutDialog( QWidget *parent, intf_thread_t *_p_intf,
     BUTTONACT( cancelButton, cancel() );
 
     if( b_transcode_only ) toggleSout();
-}
 
-QString SoutDialog::getMrl()
-{
-    return mrl;
-}
+    CONNECT( ui.UDPOutput, toggled( bool ), this, changeUDPandRTPmess( bool ) );}
 
 void SoutDialog::fileBrowse()
 {
-    ui.tabWidget->setTabEnabled( 0,false );
     QString fileName = QFileDialog::getSaveFileName( this, qtr( "Save file" ), "",
         qtr( "Containers (*.ps *.ts *.mpg *.ogg *.asf *.mp4 *.mov *.wav *.raw *.flv)" ) );
     ui.fileEdit->setText( fileName );
@@ -177,19 +234,16 @@ void SoutDialog::setSTranscodeOptions( bool b_trans )
 
 void SoutDialog::setRawOptions( bool b_raw )
 {
-    if ( b_raw )
-    {
+    if( b_raw )
         ui.tabWidget->setDisabled( true );
-    }
     else
-    {
         SoutDialog::setOptions();
-    }
 }
 
 void SoutDialog::setOptions()
 {
-    QString profileString = ui.profileBox->itemData( ui.profileBox->currentIndex() ).toString();
+    QString profileString =
+        ui.profileBox->itemData( ui.profileBox->currentIndex() ).toString();
     msg_Dbg( p_intf, "Profile Used: %s",  qta( profileString ));
     int index;
 
@@ -207,23 +261,21 @@ void SoutDialog::setOptions()
     }
 
     /* ADD HERE the profiles you want and need */
+    /* FIXME */
     if( profileString == "IPod" ) setProfile( MP4, true, "mp4a", true, "mp4v" )
     else if( profileString == "XBox" ) setProfile( ASF, true, "wma", true, "WMV2" )
 
         /* 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();
 }
 
+//FIXME
 void SoutDialog::toggleSout()
 {
     //Toggle all the streaming options.
@@ -243,14 +295,27 @@ void SoutDialog::toggleSout()
     updateGeometry();
 }
 
+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( "Video Port:" ) );
+    ui.RTPPortLabel->setText( b_udp ? qtr( "Port:") : qtr( "Audio Port:" ) );
+}
+
 void SoutDialog::ok()
 {
     mrl = ui.mrlEdit->text();
     accept();
 }
+
 void SoutDialog::cancel()
 {
-    mrl = ui.mrlEdit->text();
+    mrl.clear();
     reject();
 }
 
@@ -299,7 +364,7 @@ void SoutDialog::updateMRL()
     if ( sout.b_mms ) counter++ ;
     if ( sout.b_rtp ) counter++ ;
     if ( sout.b_udp ) counter ++;
-    if ( sout.b_icecast ) counter ++; 
+    if ( sout.b_icecast ) counter ++;
 
 #define SMUX( x, txt ) if( ui.x->isChecked() ) sout.psz_mux = strdup( txt );
     SMUX( PSMux, "ps" );
@@ -312,6 +377,7 @@ void SoutDialog::updateMRL()
     SMUX( WAVMux, "wav" );
     SMUX( RAWMux, "raw" );
     SMUX( FLVMux, "flv" );
+    SMUX( MKVMux, "mkv" );
 
     bool trans = false;
     bool more = false;
@@ -355,11 +421,12 @@ void SoutDialog::updateMRL()
         mrl.append( "}" );
     }
 
-    if ( sout.b_local || sout.b_file || sout.b_http || sout.b_mms || sout.b_rtp || sout.b_udp )
+    if ( sout.b_local || sout.b_file || sout.b_http ||
+         sout.b_mms || sout.b_rtp || sout.b_udp )
     {
 
 #define ISMORE() if ( more ) mrl.append( "," );
-#define ATLEASTONE() if ( counter ) mrl.append( "dst=" ); 
+#define ATLEASTONE() if ( counter ) mrl.append( "dst=" );
 
 #define CHECKMUX() \
        if( sout.psz_mux ) \
@@ -472,7 +539,7 @@ void SoutDialog::updateMRL()
         {
             // TODO
         }
-        
+
         if ( counter )
         {
             mrl.append( "}" );