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>
40 SoutDialog::SoutDialog( QWidget *parent, intf_thread_t *_p_intf, const QString& inputMRL )
45 setWindowTitle( qtr( "Stream Output" ) );
46 setWindowRole( "vlc-stream-output" );
50 ui.inputBox->setMRL( inputMRL );
51 ui.helpEdit->setPlainText( qtr("This wizard will allow you to stream or "
52 "convert your media for use locally, on your private network, "
53 "or on the Internet.\n"
54 "You should start by checking that source matches what you want "
55 "your input to be and then press the \"Next\" "
56 "button to continue.\n") );
58 ui.mrlEdit->setToolTip ( qtr( "Stream output string.\n"
59 "This is automatically generated "
60 "when you change the above settings,\n"
61 "but you can change it manually." ) ) ;
63 ui.destTab->setTabsClosable( true );
64 QTabBar* tb = ui.destTab->findChild<QTabBar*>();
65 if( tb != NULL ) tb->tabButton(0, QTabBar::RightSide)->hide();
66 CONNECT( ui.destTab, tabCloseRequested( int ), this, closeTab( int ) );
67 ui.destTab->setTabIcon( 0, QIcon( ":/buttons/playlist/playlist_add" ) );
69 ui.destBox->addItem( qtr( "File" ) );
70 ui.destBox->addItem( "HTTP" );
71 ui.destBox->addItem( "MS-WMSP (MMSH)" );
72 ui.destBox->addItem( "RTSP" );
73 ui.destBox->addItem( "RTP / MPEG Transport Stream" );
74 ui.destBox->addItem( "RTP Audio/Video Profile" );
75 ui.destBox->addItem( "UDP (legacy)" );
76 ui.destBox->addItem( "IceCast" );
78 BUTTONACT( ui.addButton, addDest() );
80 // /* Connect everything to the updateMRL function */
81 #define CB( x ) CONNECT( ui.x, toggled( bool ), this, updateMRL() );
82 #define CT( x ) CONNECT( ui.x, textChanged( const QString& ), this, updateMRL() );
83 #define CS( x ) CONNECT( ui.x, valueChanged( int ), this, updateMRL() );
84 #define CC( x ) CONNECT( ui.x, currentIndexChanged( int ), this, updateMRL() );
88 CB( localOutput ); CB( transcodeBox );
89 CONNECT( ui.profileSelect, optionsChanged(), this, updateMRL() );
91 setButtonText( QWizard::FinishButton, "Stream" );
99 void SoutDialog::closeTab( int i )
103 QWidget* temp = ui.destTab->widget( i );
104 ui.destTab->removeTab( i );
109 void SoutDialog::addDest( )
114 switch( ui.destBox->currentIndex() )
117 db = new FileDestBox( this );
118 caption = qtr( "File" );
121 db = new HTTPDestBox( this );
122 caption = qfu( "HTTP" );
125 db = new MMSHDestBox( this );
126 caption = qfu( "WMSP" );
129 db = new RTSPDestBox( this );
130 caption = qfu( "RTSP" );
133 db = new RTPDestBox( this, "ts" );
137 db = new RTPDestBox( this );
141 db = new UDPDestBox( this );
145 db = new ICEDestBox( this );
152 int index = ui.destTab->addTab( db, caption );
153 CONNECT( db, mrlUpdated(), this, updateMRL() );
154 ui.destTab->setCurrentIndex( index );
158 void SoutDialog::ok()
160 mrl = ui.mrlEdit->toPlainText();
164 void SoutDialog::cancel()
170 void SoutDialog::updateMRL()
172 QString qs_mux = ui.profileSelect->getMux();
174 SoutMrl smrl( ":sout=#" );
175 if( !ui.profileSelect->getTranscode().isEmpty() && ui.transcodeBox->isChecked() )
177 smrl.begin( ui.profileSelect->getTranscode() );
183 if( ui.destTab->count() >= 3 ||
184 ( ui.destTab->count() == 2 && ui.localOutput->isChecked() ) )
188 smrl.begin( "duplicate" );
190 for( int i = 1; i < ui.destTab->count(); i++ )
192 VirtualDestBox *vdb = qobject_cast<VirtualDestBox *>(ui.destTab->widget( i ));
196 QString tempMRL = vdb->getMRL( qs_mux );
197 if( tempMRL.isEmpty() ) continue;
200 smrl.option( "dst", tempMRL );
203 smrl.begin( tempMRL);
207 if( ui.localOutput->isChecked() )
210 smrl.option( "dst", "display" );
213 smrl.begin( "display" );
218 if ( multi ) smrl.end();
222 if( ui.soutAll->isChecked() ) mrl.append( " :sout-all" );
224 mrl.append( " :sout-keep" );
226 ui.mrlEdit->setPlainText( mrl );