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>
38 SoutDialog::SoutDialog( QWidget *parent, intf_thread_t *_p_intf, const QString& inputMRL )
39 : QVLCDialog( parent, _p_intf )
41 setWindowTitle( qtr( "Stream Output" ) );
45 ui.inputBox->setMRL( inputMRL );
46 ui.helpEdit->setPlainText( qtr("This dialog will allow you to stream or "
47 "convert your media for use locally, on your private network, "
48 "or on the Internet.\n"
49 "You should start by checking that source matches what you want "
50 "your input to be and then press the \"Next\" "
51 "button to continue.\n") );
53 ui.mrlEdit->setToolTip ( qtr( "Stream output string.\n"
54 "This is automatically generated "
55 "when you change the above settings,\n"
56 "but you can change it manually." ) ) ;
59 /* This needs Qt4.5 to be cool */
60 ui.destTab->setTabsClosable( true );
62 closeTabButton = new QToolButton( this );
63 ui.destTab->setCornerWidget( closeTabButton );
64 closeTabButton->hide();
65 closeTabButton->setAutoRaise( true );
66 closeTabButton->setIcon( QIcon( ":/clear" ) );
67 BUTTONACT( closeTabButton, closeTab() );
69 CONNECT( ui.destTab, currentChanged( int ), this, tabChanged( int ) );
70 ui.destTab->setTabIcon( 0, QIcon( ":/playlist_add" ) );
72 ui.destBox->addItem( qtr( "File" ) );
73 ui.destBox->addItem( "HTTP" );
74 ui.destBox->addItem( "MMS" );
75 ui.destBox->addItem( "UDP" );
76 ui.destBox->addItem( "RTP" );
77 ui.destBox->addItem( "IceCast" );
79 BUTTONACT( ui.addButton, addDest() );
81 // /* Connect everything to the updateMRL function */
82 #define CB( x ) CONNECT( ui.x, toggled( bool ), this, updateMRL() );
83 #define CT( x ) CONNECT( ui.x, textChanged( const QString& ), this, updateMRL() );
84 #define CS( x ) CONNECT( ui.x, valueChanged( int ), this, updateMRL() );
85 #define CC( x ) CONNECT( ui.x, currentIndexChanged( int ), this, updateMRL() );
88 CB( soutAll ); CB( soutKeep ); CS( ttl ); CT( sapName ); CT( sapGroup );
90 CONNECT( ui.profileSelect, optionsChanged(), this, updateMRL() );
92 okButton = new QPushButton( qtr( "&Stream" ) );
93 QPushButton *cancelButton = new QPushButton( qtr( "&Cancel" ) );
95 okButton->setDefault( true );
96 ui.acceptButtonBox->addButton( okButton, QDialogButtonBox::AcceptRole );
97 ui.acceptButtonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
99 BUTTONACT( okButton, ok() );
100 BUTTONACT( cancelButton, cancel() );
102 BUTTONACT( ui.nextButton, next() );
103 BUTTONACT( ui.nextButton2, next() );
104 BUTTONACT( ui.prevButton, prev() );
105 BUTTONACT( ui.prevButton2, prev() );
113 void SoutDialog::next()
115 ui.toolBox->setCurrentIndex( ui.toolBox->currentIndex() + 1 );
118 void SoutDialog::prev()
120 ui.toolBox->setCurrentIndex( ui.toolBox->currentIndex() - 1 );
123 void SoutDialog::tabChanged( int i )
125 closeTabButton->setVisible( (i != 0) );
128 void SoutDialog::closeTab()
130 int i = ui.destTab->currentIndex();
133 QWidget *temp = ui.destTab->currentWidget();
134 ui.destTab->removeTab( i );
139 void SoutDialog::addDest( )
142 switch( ui.destBox->currentIndex() )
146 FileDestBox *fdb = new FileDestBox( this );
147 index = ui.destTab->addTab( fdb, "File" );
148 CONNECT( fdb, mrlUpdated(), this, updateMRL() );
153 HTTPDestBox *hdb = new HTTPDestBox( this );
154 index = ui.destTab->addTab( hdb, "HTTP" );
155 CONNECT( hdb, mrlUpdated(), this, updateMRL() );
160 MMSHDestBox *mdb = new MMSHDestBox( this );
161 index = ui.destTab->addTab( mdb, "MMSH" );
162 CONNECT( mdb, mrlUpdated(), this, updateMRL() );
167 UDPDestBox *udb = new UDPDestBox( this );
168 index = ui.destTab->addTab( udb, "UDP" );
169 CONNECT( udb, mrlUpdated(), this, updateMRL() );
174 RTPDestBox *rdb = new RTPDestBox( this );
175 index = ui.destTab->addTab( rdb, "RTP" );
176 CONNECT( rdb, mrlUpdated(), this, updateMRL() );
181 ICEDestBox *idb = new ICEDestBox( this );
182 index = ui.destTab->addTab( idb, "Icecast" );
183 CONNECT( idb, mrlUpdated(), this, updateMRL() );
187 ui.destTab->setCurrentIndex( index );
191 void SoutDialog::ok()
193 mrl = ui.mrlEdit->toPlainText();
197 void SoutDialog::cancel()
203 void SoutDialog::updateMRL()
205 QString qs_mux = ui.profileSelect->getMux();
207 SoutMrl smrl( ":sout=#" );
208 if( !ui.profileSelect->getTranscode().isEmpty() && ui.transcodeBox->isChecked() )
210 smrl.begin( ui.profileSelect->getTranscode() );
216 if( ui.destTab->count() >= 3 ||
217 ( ui.destTab->count() == 2 && ui.localOutput->isChecked() ) )
221 smrl.begin( "duplicate" );
223 for( int i = 1; i < ui.destTab->count(); i++ )
225 VirtualDestBox *vdb = qobject_cast<VirtualDestBox *>(ui.destTab->widget( i ));
226 QString tempMRL = vdb->getMRL( qs_mux );
228 if( tempMRL.isEmpty() ) continue;
230 smrl.option( "dst", tempMRL );
233 smrl.begin( tempMRL);
237 if( ui.localOutput->isChecked() )
240 smrl.option( "dst", "display" );
243 smrl.begin( "display" );
248 if ( multi ) smrl.end();
252 /* FIXME, deal with SAP
253 sout.b_sap = ui.sap->isChecked();
254 sout.psz_group = strdup( qtu( ui.sapGroup->text() ) );
255 sout.psz_name = strdup( qtu( ui.sapName->text() ) ); */
257 if( ui.soutAll->isChecked() ) mrl.append( " :sout-all" );
259 if( ui.soutKeep->isChecked() ) mrl.append( " :sout-keep" );
261 ui.mrlEdit->setPlainText( mrl );