1 /*****************************************************************************
2 * sout.cpp : Stream output dialog ( old-style )
3 ****************************************************************************
4 * Copyright (C) 2007-2009 the VideoLAN team
8 * Authors: Clément Stenac <zorglub@videolan.org>
9 * Jean-Baptiste Kempf <jb@videolan.org>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * ( at your option ) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24 *****************************************************************************/
30 #include "dialogs/sout.hpp"
31 #include "util/qt_dirs.hpp"
32 #include "components/sout/sout_widgets.hpp"
35 #include <QFileDialog>
36 #include <QToolButton>
39 SoutDialog::SoutDialog( QWidget *parent, intf_thread_t *_p_intf, const QString& inputMRL )
40 : QVLCDialog( parent, _p_intf )
42 setWindowTitle( qtr( "Stream Output" ) );
43 setWindowRole( "vlc-stream-output" );
47 ui.inputBox->setMRL( inputMRL );
48 ui.helpEdit->setPlainText( qtr("This dialog will allow you to stream or "
49 "convert your media for use locally, on your private network, "
50 "or on the Internet.\n"
51 "You should start by checking that source matches what you want "
52 "your input to be and then press the \"Next\" "
53 "button to continue.\n") );
55 ui.mrlEdit->setToolTip ( qtr( "Stream output string.\n"
56 "This is automatically generated "
57 "when you change the above settings,\n"
58 "but you can change it manually." ) ) ;
61 /* This needs Qt4.5 to be cool */
62 ui.destTab->setTabsClosable( true );
64 closeTabButton = new QToolButton( this );
65 ui.destTab->setCornerWidget( closeTabButton );
66 closeTabButton->hide();
67 closeTabButton->setAutoRaise( true );
68 closeTabButton->setIcon( QIcon( ":/toolbar/clear" ) );
69 BUTTONACT( closeTabButton, closeTab() );
71 CONNECT( ui.destTab, currentChanged( int ), this, tabChanged( int ) );
72 ui.destTab->setTabIcon( 0, QIcon( ":/buttons/playlist/playlist_add" ) );
74 ui.destBox->addItem( qtr( "File" ) );
75 ui.destBox->addItem( "HTTP" );
76 ui.destBox->addItem( "MMS" );
77 ui.destBox->addItem( "UDP" );
78 ui.destBox->addItem( "RTP" );
79 ui.destBox->addItem( "IceCast" );
81 BUTTONACT( ui.addButton, addDest() );
83 // /* Connect everything to the updateMRL function */
84 #define CB( x ) CONNECT( ui.x, toggled( bool ), this, updateMRL() );
85 #define CT( x ) CONNECT( ui.x, textChanged( const QString& ), this, updateMRL() );
86 #define CS( x ) CONNECT( ui.x, valueChanged( int ), this, updateMRL() );
87 #define CC( x ) CONNECT( ui.x, currentIndexChanged( int ), this, updateMRL() );
90 CB( soutAll ); CB( soutKeep ); CS( ttl ); CT( sapName ); CT( sapGroup );
92 CONNECT( ui.profileSelect, optionsChanged(), this, updateMRL() );
94 okButton = new QPushButton( qtr( "&Stream" ) );
95 QPushButton *cancelButton = new QPushButton( qtr( "&Cancel" ) );
97 okButton->setDefault( true );
98 ui.acceptButtonBox->addButton( okButton, QDialogButtonBox::AcceptRole );
99 ui.acceptButtonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
101 BUTTONACT( okButton, ok() );
102 BUTTONACT( cancelButton, cancel() );
104 BUTTONACT( ui.nextButton, next() );
105 BUTTONACT( ui.nextButton2, next() );
106 BUTTONACT( ui.prevButton, prev() );
107 BUTTONACT( ui.prevButton2, prev() );
115 void SoutDialog::next()
117 ui.toolBox->setCurrentIndex( ui.toolBox->currentIndex() + 1 );
120 void SoutDialog::prev()
122 ui.toolBox->setCurrentIndex( ui.toolBox->currentIndex() - 1 );
125 void SoutDialog::tabChanged( int i )
127 closeTabButton->setVisible( (i != 0) );
130 void SoutDialog::closeTab()
132 int i = ui.destTab->currentIndex();
135 QWidget *temp = ui.destTab->currentWidget();
136 ui.destTab->removeTab( i );
141 void SoutDialog::addDest( )
144 switch( ui.destBox->currentIndex() )
148 FileDestBox *fdb = new FileDestBox( this );
149 index = ui.destTab->addTab( fdb, "File" );
150 CONNECT( fdb, mrlUpdated(), this, updateMRL() );
155 HTTPDestBox *hdb = new HTTPDestBox( this );
156 index = ui.destTab->addTab( hdb, "HTTP" );
157 CONNECT( hdb, mrlUpdated(), this, updateMRL() );
162 MMSHDestBox *mdb = new MMSHDestBox( this );
163 index = ui.destTab->addTab( mdb, "MMSH" );
164 CONNECT( mdb, mrlUpdated(), this, updateMRL() );
169 UDPDestBox *udb = new UDPDestBox( this );
170 index = ui.destTab->addTab( udb, "UDP" );
171 CONNECT( udb, mrlUpdated(), this, updateMRL() );
176 RTPDestBox *rdb = new RTPDestBox( this );
177 index = ui.destTab->addTab( rdb, "RTP" );
178 CONNECT( rdb, mrlUpdated(), this, updateMRL() );
183 ICEDestBox *idb = new ICEDestBox( this );
184 index = ui.destTab->addTab( idb, "Icecast" );
185 CONNECT( idb, mrlUpdated(), this, updateMRL() );
192 ui.destTab->setCurrentIndex( index );
196 void SoutDialog::ok()
198 mrl = ui.mrlEdit->toPlainText();
202 void SoutDialog::cancel()
208 void SoutDialog::updateMRL()
210 QString qs_mux = ui.profileSelect->getMux();
212 SoutMrl smrl( ":sout=#" );
213 if( !ui.profileSelect->getTranscode().isEmpty() && ui.transcodeBox->isChecked() )
215 smrl.begin( ui.profileSelect->getTranscode() );
221 if( ui.destTab->count() >= 3 ||
222 ( ui.destTab->count() == 2 && ui.localOutput->isChecked() ) )
226 smrl.begin( "duplicate" );
228 for( int i = 1; i < ui.destTab->count(); i++ )
230 VirtualDestBox *vdb = qobject_cast<VirtualDestBox *>(ui.destTab->widget( i ));
231 QString tempMRL = vdb->getMRL( qs_mux );
233 if( tempMRL.isEmpty() ) continue;
235 smrl.option( "dst", tempMRL );
238 smrl.begin( tempMRL);
242 if( ui.localOutput->isChecked() )
245 smrl.option( "dst", "display" );
248 smrl.begin( "display" );
253 if ( multi ) smrl.end();
257 /* FIXME, deal with SAP
258 sout.b_sap = ui.sap->isChecked();
259 sout.psz_group = strdup( qtu( ui.sapGroup->text() ) );
260 sout.psz_name = strdup( qtu( ui.sapName->text() ) ); */
262 if( ui.soutAll->isChecked() ) mrl.append( " :sout-all" );
264 if( ui.soutKeep->isChecked() ) mrl.append( " :sout-keep" );
266 ui.mrlEdit->setPlainText( mrl );