]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/dialogs/sout.cpp
Qt4 - VLM improvements... Classing for the three kind of objects, more property editi...
[vlc] / modules / gui / qt4 / dialogs / sout.cpp
index e62a656dc332a9d642fc2ba009262af458b4daec..bfc619c44019fa2e66901a09b1e1a32d35c420d3 100644 (file)
@@ -2,11 +2,15 @@
  * sout.cpp : Stream output dialog ( old-style )
  ****************************************************************************
  * Copyright ( C ) 2006 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
@@ -24,7 +28,6 @@
  *****************************************************************************/
 
 #include "dialogs/sout.hpp"
-#include "qt4.hpp"
 #include <vlc_streaming.h>
 
 #include <iostream>
@@ -96,20 +99,21 @@ SoutDialog::SoutDialog( QWidget *parent, intf_thread_t *_p_intf,
  #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 );
-     CS( HTTPPort ); CS( RTPPort ); CS( MMSHPort ); CS( UDPPort );
+    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( MMSHPort ); CS( UDPPort );
 //     /* Transcode */
-     CC( vCodecBox ); CC( subsCodecBox ); CC( aCodecBox ) ;
-     CB( transcodeVideo ); CB( transcodeAudio ); CB( transcodeSubs );
+    CC( vCodecBox ); CC( subsCodecBox ); CC( aCodecBox ) ;
+    CB( transcodeVideo ); CB( transcodeAudio ); CB( transcodeSubs );
 //     CB( sOverlay );
-     CS( vBitrateSpin ); CS( aBitrateSpin ); CS( aChannelsSpin ); CC( vScaleBox );
+    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 );
+    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 );
+    CB( soutAll ); CS( ttl ); CT( sapName ); CT( sapGroup );
 //
     CONNECT( ui.profileBox, activated( const QString & ), this, setOptions() );
     CONNECT( ui.fileSelectButton, clicked() , this, fileBrowse()  );
@@ -139,7 +143,7 @@ QString SoutDialog::getMrl()
 void SoutDialog::fileBrowse()
 {
     ui.tabWidget->setTabEnabled( 0,false );
-    QString fileName = QFileDialog::getOpenFileName( this, qtr( "Save file" ), "",
+    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();
@@ -173,7 +177,7 @@ void SoutDialog::setSTranscodeOptions( bool b_trans )
 
 void SoutDialog::setRawOptions( bool b_raw )
 {
-    if ( b_raw )
+    if( b_raw )
     {
         ui.tabWidget->setDisabled( true );
     }
@@ -183,15 +187,6 @@ void SoutDialog::setRawOptions( bool b_raw )
     }
 }
 
-int indexFromItemData( QComboBox *aCombo, QString aString )
-{
-    for( int i=0; i < aCombo->count(); i++ )
-    {
-        if( aCombo->itemData( i ).toString() == aString ) return i;
-    }
-    return -1;
-}
-
 void SoutDialog::setOptions()
 {
     QString profileString = ui.profileBox->itemData( ui.profileBox->currentIndex() ).toString();
@@ -203,15 +198,16 @@ void SoutDialog::setOptions()
         ui.muxName ##Mux->setChecked( true ); \
         \
         ui.transcodeAudio->setChecked( hasAudio ); \
-        index = indexFromItemData( ui.aCodecBox, vCodecName );  \
+        index = ui.aCodecBox->findText( vCodecName );  \
         if( index >= 0 ) ui.aCodecBox->setCurrentIndex( index ); \
         \
         ui.transcodeVideo->setChecked( hasVideo ); \
-        index = indexFromItemData( ui.aCodecBox, vCodecName );  \
+        index = ui.aCodecBox->findText( vCodecName );  \
         if( index >=0 ) ui.vCodecBox->setCurrentIndex( index ); \
     }
 
     /* 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" )
 
@@ -263,12 +259,13 @@ void SoutDialog::updateMRL()
 {
     sout_gui_descr_t sout;
     memset( &sout, 0, sizeof( sout_gui_descr_t ) );
-    int counter = 0;
+    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_sap = ui.sap->isChecked();
@@ -281,10 +278,15 @@ void SoutDialog::updateMRL()
     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_udp = ui.UDPPort->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();
@@ -292,23 +294,13 @@ void SoutDialog::updateMRL()
     sout.psz_group = strdup( qtu( ui.sapGroup->text() ) );
     sout.psz_name = strdup( qtu( ui.sapName->text() ) );
 
-#define COUNT() \
-    { \
-        if ( sout.b_local ) \
-        counter += 1; \
-        if ( sout.b_file ) \
-        counter += 1; \
-        if ( sout.b_http ) \
-        counter += 1; \
-        if ( sout.b_mms ) \
-        counter += 1; \
-        if ( sout.b_rtp ) \
-        counter += 1; \
-        if ( sout.b_udp ) \
-        counter += 1; \
-    }
-
-COUNT()
+    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" );
@@ -321,6 +313,7 @@ COUNT()
     SMUX( WAVMux, "wav" );
     SMUX( RAWMux, "raw" );
     SMUX( FLVMux, "flv" );
+    SMUX( MKVMux, "mkv" );
 
     bool trans = false;
     bool more = false;
@@ -368,13 +361,14 @@ COUNT()
     {
 
 #define ISMORE() if ( more ) mrl.append( "," );
+#define ATLEASTONE() if ( counter ) mrl.append( "dst=" );
 
-#define ATLEASTONE() \
-        if ( counter > 1 ) \
-        { \
-            mrl.append( "dst=" ); \
-        }
-
+#define CHECKMUX() \
+       if( sout.psz_mux ) \
+       {                  \
+         mrl.append( ",mux=");\
+         mrl.append( sout.psz_mux ); \
+       }
 
         if ( trans )
         {
@@ -385,7 +379,7 @@ COUNT()
             mrl = ":sout=#";
         }
 
-        if ( counter > 1 )
+        if ( counter )
         {
             mrl.append( "duplicate{" );
         }
@@ -402,8 +396,8 @@ COUNT()
         {
             ISMORE();
             ATLEASTONE()
-                mrl.append( "std{access=file,mux=" );
-            mrl.append( sout.psz_mux );
+                mrl.append( "std{access=file" );
+            CHECKMUX();
             mrl.append( ",dst=" );
             mrl.append( sout.psz_file );
             mrl.append( "}" );
@@ -414,8 +408,8 @@ COUNT()
         {
             ISMORE();
             ATLEASTONE()
-                mrl.append( "std{access=http,mux=" );
-            mrl.append( sout.psz_mux );
+                mrl.append( "std{access=http" );
+            CHECKMUX();
             mrl.append( ",dst=" );
             mrl.append( sout.psz_http );
             mrl.append( ":" );
@@ -428,8 +422,8 @@ COUNT()
         {
             ISMORE();
             ATLEASTONE()
-                mrl.append( "std{access=mmsh,mux=" );
-            mrl.append( sout.psz_mux );
+                mrl.append( "std{access=mmsh" );
+            CHECKMUX();
             mrl.append( ",dst=" );
             mrl.append( sout.psz_mms );
             mrl.append( ":" );
@@ -442,8 +436,8 @@ COUNT()
         {
             ISMORE();
             ATLEASTONE()
-                mrl.append( "rtp{mux=" );
-            mrl.append( sout.psz_mux );
+                mrl.append( "rtp{" );
+            CHECKMUX();
             mrl.append( ",dst=" );
             mrl.append( sout.psz_rtp );
             mrl.append( ":" );
@@ -456,8 +450,8 @@ COUNT()
         {
             ISMORE();
             ATLEASTONE()
-            mrl.append( "std{access=udp,mux=" );
-            mrl.append( sout.psz_mux );
+            mrl.append( "std{access=udp" );
+            CHECKMUX();
             mrl.append( ",dst=" );
             mrl.append( sout.psz_udp );
             mrl.append( ":" );
@@ -476,12 +470,19 @@ COUNT()
             more = true;
         }
 
-        if ( counter > 1 )
+        if( sout.b_icecast )
+        {
+            // TODO
+        }
+
+        if ( counter )
         {
             mrl.append( "}" );
         }
     }
 
+#undef CHECKMUX
+
     if ( sout.b_all_es )
         mrl.append( ":sout-all" );
 
@@ -490,4 +491,6 @@ COUNT()
     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 );
 }