X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fqt4%2Fdialogs%2Fsout.cpp;h=d900e771c046cac79b19ed4750d6746efea452d0;hb=02abb732f80e3dd24ec8e0ab751d6b11f12102dd;hp=5ed388472ea357a6d916e7f52f2e869c57211bd1;hpb=bb727b7f3e315828597bcb5e45d066bc01d4a606;p=vlc diff --git a/modules/gui/qt4/dialogs/sout.cpp b/modules/gui/qt4/dialogs/sout.cpp index 5ed388472e..d900e771c0 100644 --- a/modules/gui/qt4/dialogs/sout.cpp +++ b/modules/gui/qt4/dialogs/sout.cpp @@ -1,15 +1,17 @@ /***************************************************************************** - * sout.cpp : Stream output dialog (old-style) + * sout.cpp : Stream output dialog ( old-style ) **************************************************************************** - * Copyright (C) 2006 the VideoLAN team - * $Id: Errors.cpp 16024 2006-07-13 13:51:05Z xtophe $ + * Copyright (C) 2007-2009 the VideoLAN team + * + * $Id$ * * Authors: Clément Stenac + * Jean-Baptiste Kempf * * 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 @@ -21,157 +23,236 @@ * 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 +#include "util/qt_dirs.hpp" +#include "components/sout/sout_widgets.hpp" +#include #include +#include -SoutDialog::SoutDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf ) +SoutDialog::SoutDialog( QWidget *parent, intf_thread_t *_p_intf, QString inputMRL ) + : QVLCDialog( parent, _p_intf ) { - setWindowTitle( qtr( "Stream output") ); - main = new QWidget( this ); + setWindowTitle( qtr( "Stream Output" ) ); /* UI stuff */ - ui.setupUi( main ); -#define ADD_VCODEC( name, fcc) ui.vCodec->addItem( name, QVariant( fcc ) ); - 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( "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, fcc) ui.aCodec->addItem( name, QVariant( fcc ) ); - ADD_ACODEC( "MPEG Audio", "mpga" ); - ADD_ACODEC( "MP3", "mp3" ); - ADD_ACODEC( "MPEG 4 Audio (AAC)", "mp4a"); - ADD_ACODEC( "A52/AC3", "a52"); - ADD_ACODEC( "Vorbis", "vorb" ); - ADD_ACODEC( "Flac", "flac" ); - ADD_ACODEC( "Speex", "spx" ); - ADD_ACODEC( "WAV", "s16l" ); - - ui.vScale->addItem( "0.25" ); - ui.vScale->addItem( "0.5" ); - ui.vScale->addItem( "0.75" ); - ui.vScale->addItem( "1" ); - ui.vScale->addItem( "1.25" ); - ui.vScale->addItem( "1.5" ); - ui.vScale->addItem( "1.75" ); - ui.vScale->addItem( "2" ); - - /* 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 ); CC( sCodec ); CC( aCodec ) ; - CB( transcodeVideo ); CB( transcodeAudio ); CB( transcodeSubs ); - CB( sOverlay ); - CS( vBitrate ); CS( aBitrate ); CS( aChannels ); CC( vScale ); - /* Mux */ - CB( PSMux ); CB( TSMux ); CB( MPEG1Mux ); CB( OggMux ); CB( ASFMux ); - CB( MP4Mux ); CB( MOVMux ); CB( WAVMux ); CB( RAWMux ); + ui.setupUi( this ); + ui.inputBox->setMRL( inputMRL ); + ui.helpEdit->setPlainText( "This dialog will allow you to stream or " + "convert your media for use locally, on your private network, " + "or on the Internet.\n" + "You should start by checking that source matches what you want " + "your input to be and then press the \"Next\" " + "button to continue.\n" ); + + 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." ) ) ; + +#if 0 + /* This needs Qt4.5 to be cool */ + ui.destTab->setTabsClosable( true ); +#else + closeTabButton = new QToolButton( this ); + ui.destTab->setCornerWidget( closeTabButton ); + closeTabButton->hide(); + closeTabButton->setAutoRaise( true ); + closeTabButton->setIcon( QIcon( ":/clear" ) ); + BUTTONACT( closeTabButton, closeTab() ); +#endif + CONNECT( ui.destTab, currentChanged( int ), this, tabChanged( int ) ); + ui.destTab->setTabIcon( 0, QIcon( ":/playlist_add" ) ); + + ui.destBox->addItem( qtr( "File" ) ); + ui.destBox->addItem( "HTTP" ); + ui.destBox->addItem( "MMS" ); + ui.destBox->addItem( "UDP" ); + ui.destBox->addItem( "RTP" ); + ui.destBox->addItem( "IceCast" ); + + BUTTONACT( ui.addButton, addDest() ); + +// /* Connect everything to the updateMRL function */ + #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() ); + /* Misc */ - CB( soutAll ); CS( ttl ); CT( sapName ); CT( sapGroup ); + CB( soutAll ); CB( soutKeep ); CS( ttl ); CT( sapName ); CT( sapGroup ); + CB( localOutput ); + CONNECT( ui.profileSelect, optionsChanged(), this, updateMRL() ); + + 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( ui.nextButton, next() ); + BUTTONACT( ui.nextButton2, next() ); + BUTTONACT( ui.prevButton, prev() ); + BUTTONACT( ui.prevButton2, prev() ); +} + +void SoutDialog::next() +{ + ui.toolBox->setCurrentIndex( ui.toolBox->currentIndex() + 1 ); +} + +void SoutDialog::prev() +{ + ui.toolBox->setCurrentIndex( ui.toolBox->currentIndex() - 1 ); +} + +void SoutDialog::tabChanged( int i ) +{ + closeTabButton->setVisible( (i != 0) ); +} - CONNECT( ui.fileSelectButton, clicked(), this, fileBrowse() ); +void SoutDialog::closeTab() +{ + int i = ui.destTab->currentIndex(); + if( i == 0 ) return; + + QWidget *temp = ui.destTab->currentWidget(); + ui.destTab->removeTab( i ); + delete temp; + updateMRL(); } -void SoutDialog::fileBrowse() +void SoutDialog::addDest( ) { - QString f = QFileDialog::getOpenFileName( this, qtr("Save file"), "", "" ); - ui.fileEdit->setText( f ); + int index; + switch( ui.destBox->currentIndex() ) + { + case 0: + { + FileDestBox *fdb = new FileDestBox( this ); + index = ui.destTab->addTab( fdb, "File" ); + CONNECT( fdb, mrlUpdated(), this, updateMRL() ); + } + break; + case 1: + { + HTTPDestBox *hdb = new HTTPDestBox( this ); + index = ui.destTab->addTab( hdb, "HTTP" ); + CONNECT( hdb, mrlUpdated(), this, updateMRL() ); + } + break; + case 2: + { + MMSHDestBox *mdb = new MMSHDestBox( this ); + index = ui.destTab->addTab( mdb, "MMSH" ); + CONNECT( mdb, mrlUpdated(), this, updateMRL() ); + } + break; + case 3: + { + UDPDestBox *udb = new UDPDestBox( this ); + index = ui.destTab->addTab( udb, "UDP" ); + CONNECT( udb, mrlUpdated(), this, updateMRL() ); + } + break; + case 4: + { + RTPDestBox *rdb = new RTPDestBox( this ); + index = ui.destTab->addTab( rdb, "RTP" ); + CONNECT( rdb, mrlUpdated(), this, updateMRL() ); + } + break; + case 5: + { + ICEDestBox *idb = new ICEDestBox( this ); + index = ui.destTab->addTab( idb, "Icecast" ); + CONNECT( idb, mrlUpdated(), this, updateMRL() ); + } + } + + ui.destTab->setCurrentIndex( index ); updateMRL(); } void SoutDialog::ok() { + mrl = ui.mrlEdit->toPlainText(); + accept(); } + void SoutDialog::cancel() { + mrl.clear(); + reject(); } 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" ); - - /* 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 ); + QString qs_mux = ui.profileSelect->getMux(); + + SoutMrl smrl( ":sout=#" ); + if( !ui.profileSelect->getTranscode().isEmpty() && ui.transcodeBox->isChecked() ) + { + smrl.begin( ui.profileSelect->getTranscode() ); + smrl.end(); + } + + bool multi = false; + + if( ui.destTab->count() >= 3 || + ( ui.destTab->count() == 2 && ui.localOutput->isChecked() ) ) + multi = true; + + if( multi ) + smrl.begin( "duplicate" ); + + for( int i = 1; i < ui.destTab->count(); i++ ) + { + VirtualDestBox *vdb = qobject_cast(ui.destTab->widget( i )); + QString tempMRL = vdb->getMRL( qs_mux ); + + if( tempMRL.isEmpty() ) continue; + if( multi ) + smrl.option( "dst", tempMRL ); + else + { + smrl.begin( tempMRL); + smrl.end(); + } + } + if( ui.localOutput->isChecked() ) + { + if( multi ) + smrl.option( "dst", "display" ); + else + { + smrl.begin( "display" ); + smrl.end(); + } + } + + if ( multi ) smrl.end(); + + mrl = smrl.getMrl(); + + /* FIXME, deal with SAP + sout.b_sap = ui.sap->isChecked(); + sout.psz_group = strdup( qtu( ui.sapGroup->text() ) ); + sout.psz_name = strdup( qtu( ui.sapName->text() ) ); */ + + if( ui.soutAll->isChecked() ) mrl.append( " :sout-all" ); + + if( ui.soutKeep->isChecked() ) mrl.append( " :sout-keep" ); + + ui.mrlEdit->setPlainText( mrl ); } +