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( "MS-WMSP (MMSH)" );
77 ui.destBox->addItem( "RTP / MPEG Transport Stream" );
78 ui.destBox->addItem( "RTP Audio/Video Profile" );
79 ui.destBox->addItem( "UDP (legacy)" );
80 ui.destBox->addItem( "IceCast" );
82 BUTTONACT( ui.addButton, addDest() );
84 // /* Connect everything to the updateMRL function */
85 #define CB( x ) CONNECT( ui.x, toggled( bool ), this, updateMRL() );
86 #define CT( x ) CONNECT( ui.x, textChanged( const QString& ), this, updateMRL() );
87 #define CS( x ) CONNECT( ui.x, valueChanged( int ), this, updateMRL() );
88 #define CC( x ) CONNECT( ui.x, currentIndexChanged( int ), this, updateMRL() );
91 CB( soutAll ); CS( ttl ); CT( sapName ); CT( sapGroup );
92 CB( localOutput ); CB( transcodeBox );
93 CONNECT( ui.profileSelect, optionsChanged(), this, updateMRL() );
95 okButton = new QPushButton( qtr( "&Stream" ) );
96 QPushButton *cancelButton = new QPushButton( qtr( "&Cancel" ) );
98 okButton->setDefault( true );
99 ui.acceptButtonBox->addButton( okButton, QDialogButtonBox::AcceptRole );
100 ui.acceptButtonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
102 BUTTONACT( okButton, ok() );
103 BUTTONACT( cancelButton, cancel() );
105 BUTTONACT( ui.nextButton, next() );
106 BUTTONACT( ui.nextButton2, next() );
107 BUTTONACT( ui.prevButton, prev() );
108 BUTTONACT( ui.prevButton2, prev() );
116 void SoutDialog::next()
118 ui.toolBox->setCurrentIndex( ui.toolBox->currentIndex() + 1 );
121 void SoutDialog::prev()
123 ui.toolBox->setCurrentIndex( ui.toolBox->currentIndex() - 1 );
126 void SoutDialog::tabChanged( int i )
128 closeTabButton->setVisible( (i != 0) );
131 void SoutDialog::closeTab()
133 int i = ui.destTab->currentIndex();
136 QWidget *temp = ui.destTab->currentWidget();
137 ui.destTab->removeTab( i );
142 void SoutDialog::addDest( )
147 switch( ui.destBox->currentIndex() )
150 db = new FileDestBox( this );
151 caption = qtr( "File" );
154 db = new HTTPDestBox( this );
155 caption = qfu( "HTTP" );
158 db = new MMSHDestBox( this );
159 caption = qfu( "WMSP" );
162 db = new RTPDestBox( this, "ts" );
166 db = new RTPDestBox( this );
170 db = new UDPDestBox( this );
174 db = new ICEDestBox( this );
181 int index = ui.destTab->addTab( db, caption );
182 CONNECT( db, mrlUpdated(), this, updateMRL() );
183 ui.destTab->setCurrentIndex( index );
187 void SoutDialog::ok()
189 mrl = ui.mrlEdit->toPlainText();
193 void SoutDialog::cancel()
199 void SoutDialog::updateMRL()
201 QString qs_mux = ui.profileSelect->getMux();
203 SoutMrl smrl( ":sout=#" );
204 if( !ui.profileSelect->getTranscode().isEmpty() && ui.transcodeBox->isChecked() )
206 smrl.begin( ui.profileSelect->getTranscode() );
212 if( ui.destTab->count() >= 3 ||
213 ( ui.destTab->count() == 2 && ui.localOutput->isChecked() ) )
217 smrl.begin( "duplicate" );
219 for( int i = 1; i < ui.destTab->count(); i++ )
221 VirtualDestBox *vdb = qobject_cast<VirtualDestBox *>(ui.destTab->widget( i ));
222 QString tempMRL = vdb->getMRL( qs_mux );
224 if( tempMRL.isEmpty() ) continue;
226 smrl.option( "dst", tempMRL );
229 smrl.begin( tempMRL);
233 if( ui.localOutput->isChecked() )
236 smrl.option( "dst", "display" );
239 smrl.begin( "display" );
244 if ( multi ) smrl.end();
248 if( ui.sap->isChecked() )
250 QString group = ui.sapGroup->text();
251 QString name = ui.sapName->text();
253 /* FIXME: This sucks. We should really return a QStringList instead of
254 * (mis)quoting, concatainating and split input item paramters. */
255 name = name.replace( " ", " " );
256 group = group.replace( " ", " " );
258 /* We need to add options for both standard and rtp targets */
259 /* This is inelegant but simple and functional */
260 mrl.append( qfu( " :sout-rtp-sap" ) );
261 mrl.append( qfu( " :sout-rtp-name=" ) + name );
262 mrl.append( qfu( " :sout-standard-sap" ) );
263 mrl.append( qfu( " :sout-standard-name=" ) + name );
264 mrl.append( qfu( " :sout-standard-group=" ) + group );
268 mrl.append( qfu( " :no-sout-rtp-sap" ) );
269 mrl.append( qfu( " :no-sout-standard-sap" ) );
272 if( ui.soutAll->isChecked() ) mrl.append( " :sout-all" );
274 mrl.append( " :sout-keep" );
276 ui.mrlEdit->setPlainText( mrl );