1 /*****************************************************************************
2 * sout_widgets.cpp : Widgets for stream output destination boxes
3 ****************************************************************************
4 * Copyright (C) 2007-2009 the VideoLAN team
5 * Copyright (C) 2007 Société des arts technologiques
6 * Copyright (C) 2007 Savoir-faire Linux
9 * Authors: Jean-Baptiste Kempf <jb@videolan.org>
10 * Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25 *****************************************************************************/
27 #include "components/sout/sout_widgets.hpp"
28 #include "dialogs/sout.hpp"
29 #include "util/qt_dirs.hpp"
30 #include <vlc_intf_strings.h>
33 #include <QGridLayout>
36 #include <QFileDialog>
38 #define I_FILE_SLASH_DIR \
39 I_DIR_OR_FOLDER( N_("File/Directory"), N_("File/Folder") )
41 SoutInputBox::SoutInputBox( QWidget *_parent, const QString& mrl ) : QGroupBox( _parent )
46 setTitle( qtr( "Source" ) );
47 QGridLayout *sourceLayout = new QGridLayout( this );
49 QLabel *sourceLabel = new QLabel( qtr( "Source:" ) );
50 sourceLayout->addWidget( sourceLabel, 0, 0 );
52 sourceLine = new QLineEdit;
53 sourceLine->setReadOnly( true );
54 sourceLine->setText( mrl );
55 sourceLabel->setBuddy( sourceLine );
56 sourceLayout->addWidget( sourceLine, 0, 1 );
58 QLabel *sourceTypeLabel = new QLabel( qtr( "Type:" ) );
59 sourceLayout->addWidget( sourceTypeLabel, 1, 0 );
60 sourceValueLabel = new QLabel;
61 sourceLayout->addWidget( sourceValueLabel, 1, 1 );
64 QFrame *line = new QFrame;
65 line->setFrameStyle( QFrame::HLine |QFrame::Sunken );
66 sourceLayout->addWidget( line, 2, 0, 1, -1 );
69 void SoutInputBox::setMRL( const QString& mrl )
71 sourceLine->setText( mrl );
73 int i = mrl.indexOf( "://" );
79 type = qtr( I_FILE_SLASH_DIR );
80 sourceValueLabel->setText( type );
83 #define CT( x ) connect( x, SIGNAL(textChanged(QString)), this, SIGNAL(mrlUpdated()) );
84 #define CS( x ) connect( x, SIGNAL(valueChanged(int)), this, SIGNAL(mrlUpdated()) );
87 FileDestBox::FileDestBox( QWidget *_parent ) : VirtualDestBox( _parent )
89 QPushButton *fileSelectButton;
90 QGridLayout *layout = new QGridLayout( this );
92 QLabel *fileOutput = new QLabel(
93 qtr( "This module writes the transcoded stream to a file."), this );
94 layout->addWidget(fileOutput, 0, 0, 1, -1);
96 QLabel *fileLabel = new QLabel( qtr( "Filename"), this );
97 layout->addWidget(fileLabel, 1, 0, 1, 1);
99 fileEdit = new QLineEdit(this);
100 layout->addWidget(fileEdit, 1, 4, 1, 1);
102 fileSelectButton = new QPushButton( qtr( "Browse..." ), this );
103 QSizePolicy sizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
104 fileSelectButton->setSizePolicy(sizePolicy);
106 layout->addWidget(fileSelectButton, 1, 5, 1, 1);
108 BUTTONACT( fileSelectButton, fileBrowse() );
111 QString FileDestBox::getMRL( const QString& mux )
113 if( fileEdit->text().isEmpty() ) return "";
117 QString outputfile = fileEdit->text();
120 if( outputfile.contains( QRegExp("\\..{2,4}$")) &&
121 !outputfile.endsWith(mux) )
123 /* Replace the extension according to muxer */
124 outputfile.replace(QRegExp("\\..{2,4}$"),"."+mux);
125 } else if (!outputfile.endsWith( mux ) )
127 m.option( "mux", mux );
130 m.option( "dst", outputfile );
131 m.option( "no-overwrite" );
137 void FileDestBox::fileBrowse()
139 QString fileName = QFileDialog::getSaveFileName( this, qtr( "Save file..." ),
140 "", qtr( "Containers (*.ps *.ts *.mpg *.ogg *.asf *.mp4 *.mov *.wav *.raw *.flv *.webm)" ) );
141 fileEdit->setText( toNativeSeparators( fileName ) );
147 HTTPDestBox::HTTPDestBox( QWidget *_parent ) : VirtualDestBox( _parent )
149 QGridLayout *layout = new QGridLayout( this );
151 QLabel *httpOutput = new QLabel(
152 qtr( "This module outputs the transcoded stream to a network via HTTP."),
154 layout->addWidget(httpOutput, 0, 0, 1, -1);
156 QLabel *HTTPLabel = new QLabel( qtr("Path"), this );
157 QLabel *HTTPPortLabel = new QLabel( qtr("Port"), this );
158 layout->addWidget(HTTPLabel, 2, 0, 1, 1);
159 layout->addWidget(HTTPPortLabel, 1, 0, 1, 1);
161 HTTPEdit = new QLineEdit(this);
162 HTTPEdit->setText( "/" );
164 HTTPPort = new QSpinBox(this);
165 HTTPPort->setMaximumSize(QSize(90, 16777215));
166 HTTPPort->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
167 HTTPPort->setMinimum(1);
168 HTTPPort->setMaximum(65535);
169 HTTPPort->setValue(8080);
171 layout->addWidget(HTTPEdit, 2, 1, 1, 1);
172 layout->addWidget(HTTPPort, 1, 1, 1, 1);
177 QString HTTPDestBox::getMRL( const QString& mux )
179 if( HTTPEdit->text().isEmpty() ) return "";
181 QString path = HTTPEdit->text();
183 path.prepend( qfu("/") );
185 port.setNum( HTTPPort->value() );
186 QString dst = ":" + port + path;
190 /* Path-extension is primary muxer to use if possible,
191 otherwise check for mux-choise and see that it isn't mp4
192 then fallback to flv*/
193 if ( !path.contains(QRegExp("\\..{2,3}$") ) )
195 if( !mux.isEmpty() && mux.compare("mp4") )
196 m.option( "mux", mux );
198 m.option( "mux", "ffmpeg{mux=flv}" );
200 m.option( "dst", dst );
206 MMSHDestBox::MMSHDestBox( QWidget *_parent ) : VirtualDestBox( _parent )
208 QGridLayout *layout = new QGridLayout( this );
210 QLabel *mmshOutput = new QLabel(
211 qtr( "This module outputs the transcoded stream to a network "
212 "via the mms protocol." ), this );
213 layout->addWidget(mmshOutput, 0, 0, 1, -1);
215 QLabel *MMSHLabel = new QLabel( qtr("Address"), this );
216 QLabel *MMSHPortLabel = new QLabel( qtr("Port"), this );
217 layout->addWidget(MMSHLabel, 1, 0, 1, 1);
218 layout->addWidget(MMSHPortLabel, 2, 0, 1, 1);
220 MMSHEdit = new QLineEdit(this);
221 MMSHEdit->setText( "0.0.0.0" );
223 MMSHPort = new QSpinBox(this);
224 MMSHPort->setMaximumSize(QSize(90, 16777215));
225 MMSHPort->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
226 MMSHPort->setMinimum(1);
227 MMSHPort->setMaximum(65535);
228 MMSHPort->setValue(8080);
230 layout->addWidget(MMSHEdit, 1, 1, 1, 1);
231 layout->addWidget(MMSHPort, 2, 1, 1, 1);
236 QString MMSHDestBox::getMRL( const QString& )
238 if( MMSHEdit->text().isEmpty() ) return "";
242 m.option( "access", "mmsh" );
243 m.option( "mux", "asfh" );
244 m.option( "dst", MMSHEdit->text(), MMSHPort->value() );
251 RTSPDestBox::RTSPDestBox( QWidget *_parent ) : VirtualDestBox( _parent )
253 QGridLayout *layout = new QGridLayout( this );
255 QLabel *rtspOutput = new QLabel(
256 qtr( "This module outputs the transcoded stream to a network via "
258 layout->addWidget( rtspOutput, 0, 0, 1, -1 );
260 QLabel *RTSPLabel = new QLabel( qtr("Path"), this );
261 QLabel *RTSPPortLabel = new QLabel( qtr("Port"), this );
262 layout->addWidget( RTSPLabel, 2, 0, 1, 1 );
263 layout->addWidget( RTSPPortLabel, 1, 0, 1, 1 );
265 RTSPEdit = new QLineEdit( this );
266 RTSPEdit->setText( "/" );
268 RTSPPort = new QSpinBox( this );
269 RTSPPort->setMaximumSize( QSize( 90, 16777215 ) );
270 RTSPPort->setAlignment( Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter );
271 RTSPPort->setMinimum( 1 );
272 RTSPPort->setMaximum( 65535 );
273 RTSPPort->setValue( 8554 );
275 layout->addWidget( RTSPEdit, 2, 1, 1, 1 );
276 layout->addWidget( RTSPPort, 1, 1, 1, 1 );
281 QString RTSPDestBox::getMRL( const QString& )
283 if( RTSPEdit->text().isEmpty() ) return "";
285 QString path = RTSPEdit->text();
287 path.prepend( qfu("/") );
289 port.setNum( RTSPPort->value() );
290 QString sdp = "rtsp://:" + port + path;
294 m.option( "sdp", sdp );
301 UDPDestBox::UDPDestBox( QWidget *_parent ) : VirtualDestBox( _parent )
303 QGridLayout *layout = new QGridLayout( this );
305 QLabel *udpOutput = new QLabel(
306 qtr( "This module outputs the transcoded stream to a network via UDP."),
308 layout->addWidget(udpOutput, 0, 0, 1, -1);
310 QLabel *UDPLabel = new QLabel( qtr("Address"), this );
311 QLabel *UDPPortLabel = new QLabel( qtr("Port"), this );
312 layout->addWidget(UDPLabel, 1, 0, 1, 1);
313 layout->addWidget(UDPPortLabel, 2, 0, 1, 1);
315 UDPEdit = new QLineEdit(this);
317 UDPPort = new QSpinBox(this);
318 UDPPort->setMaximumSize(QSize(90, 16777215));
319 UDPPort->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
320 UDPPort->setMinimum(1);
321 UDPPort->setMaximum(65535);
322 UDPPort->setValue(1234);
324 layout->addWidget(UDPEdit, 1, 1, 1, 1);
325 layout->addWidget(UDPPort, 2, 1, 1, 1);
330 QString UDPDestBox::getMRL( const QString& mux )
332 if( UDPEdit->text().isEmpty() ) return "";
336 /* udp output, ts-mux is really only reasonable one to use*/
337 if( !mux.isEmpty() && !mux.compare("ts" ) )
338 m.option( "mux", mux );
339 m.option( "dst", UDPEdit->text(), UDPPort->value() );
347 RTPDestBox::RTPDestBox( QWidget *_parent, const char *_mux )
348 : VirtualDestBox( _parent ), mux( qfu(_mux) )
350 QGridLayout *layout = new QGridLayout( this );
352 QLabel *rtpOutput = new QLabel(
353 qtr( "This module outputs the transcoded stream to a network via RTP."),
355 layout->addWidget(rtpOutput, 0, 0, 1, -1);
357 QLabel *RTPLabel = new QLabel( qtr("Address"), this );
358 RTPEdit = new QLineEdit(this);
359 layout->addWidget(RTPLabel, 1, 0, 1, 1);
360 layout->addWidget(RTPEdit, 1, 1, 1, 1);
362 QLabel *RTPPortLabel = new QLabel( qtr("Base port"), this );
363 RTPPort = new QSpinBox(this);
364 RTPPort->setMaximumSize(QSize(90, 16777215));
365 RTPPort->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
366 RTPPort->setMinimum(1);
367 RTPPort->setMaximum(65535);
368 RTPPort->setValue(5004);
369 layout->addWidget(RTPPortLabel, 2, 0, 1, 1);
370 layout->addWidget(RTPPort, 2, 1, 1, 1);
372 QLabel *SAPNameLabel = new QLabel( qtr("Stream name"), this );
373 SAPName = new QLineEdit(this);
374 layout->addWidget(SAPNameLabel, 3, 0, 1, 1);
375 layout->addWidget(SAPName, 3, 1, 1, 1);
382 QString RTPDestBox::getMRL( const QString& )
384 QString addr = RTPEdit->text();
385 QString name = SAPName->text();
387 if( addr.isEmpty() ) return qfu("");
391 m.option( "dst", RTPEdit->text() );
392 m.option( "port", RTPPort->value() );
393 /* mp4-mux ain't usable in rtp-output either */
395 m.option( "mux", mux );
396 if( !name.isEmpty() )
399 m.option( "name", name );
407 ICEDestBox::ICEDestBox( QWidget *_parent ) : VirtualDestBox( _parent )
409 QGridLayout *layout = new QGridLayout( this );
411 QLabel *iceOutput = new QLabel(
412 qtr( "This module outputs the transcoded stream to an Icecast server."),
414 layout->addWidget(iceOutput, 0, 0, 1, -1);
416 QLabel *ICELabel = new QLabel( qtr("Address"), this );
417 QLabel *ICEPortLabel = new QLabel( qtr("Port"), this );
418 layout->addWidget(ICELabel, 1, 0, 1, 1);
419 layout->addWidget(ICEPortLabel, 2, 0, 1, 1);
421 ICEEdit = new QLineEdit(this);
423 ICEPort = new QSpinBox(this);
424 ICEPort->setMaximumSize(QSize(90, 16777215));
425 ICEPort->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
426 ICEPort->setMinimum(1);
427 ICEPort->setMaximum(65535);
428 ICEPort->setValue(8000);
430 layout->addWidget(ICEEdit, 1, 1, 1, 1);
431 layout->addWidget(ICEPort, 2, 1, 1, 1);
433 QLabel *IcecastMountpointLabel = new QLabel( qtr( "Mount Point" ), this );
434 QLabel *IcecastNameLabel = new QLabel( qtr( "Login:pass" ), this );
435 ICEMountEdit = new QLineEdit( this );
436 ICEPassEdit = new QLineEdit( this );
437 layout->addWidget(IcecastMountpointLabel, 3, 0, 1, 1 );
438 layout->addWidget(ICEMountEdit, 3, 1, 1, -1 );
439 layout->addWidget(IcecastNameLabel, 4, 0, 1, 1 );
440 layout->addWidget(ICEPassEdit, 4, 1, 1, -1 );
451 QString ICEDestBox::getMRL( const QString& )
453 if( ICEEdit->text().isEmpty() ) return "";
457 m.option( "access", "shout" );
458 m.option( "mux", "ogg" );
460 QString url = ICEPassEdit->text() + "@"
462 + ":" + QString::number( ICEPort->value(), 10 )
463 + "/" + ICEMountEdit->text();
465 m.option( "dst", url );