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>
39 #define I_FILE_SLASH_DIR \
40 I_DIR_OR_FOLDER( N_("File/Directory"), N_("File/Folder") )
42 SoutInputBox::SoutInputBox( QWidget
*_parent
, const QString
& mrl
) : QGroupBox( _parent
)
47 setTitle( qtr( "Source" ) );
48 QGridLayout
*sourceLayout
= new QGridLayout( this );
50 QLabel
*sourceLabel
= new QLabel( qtr( "Source:" ) );
51 sourceLayout
->addWidget( sourceLabel
, 0, 0 );
53 sourceLine
= new QLineEdit
;
54 sourceLine
->setReadOnly( true );
55 sourceLine
->setText( mrl
);
56 sourceLabel
->setBuddy( sourceLine
);
57 sourceLayout
->addWidget( sourceLine
, 0, 1 );
59 QLabel
*sourceTypeLabel
= new QLabel( qtr( "Type:" ) );
60 sourceLayout
->addWidget( sourceTypeLabel
, 1, 0 );
61 sourceValueLabel
= new QLabel
;
62 sourceLayout
->addWidget( sourceValueLabel
, 1, 1 );
65 QFrame
*line
= new QFrame
;
66 line
->setFrameStyle( QFrame::HLine
|QFrame::Sunken
);
67 sourceLayout
->addWidget( line
, 2, 0, 1, -1 );
70 void SoutInputBox::setMRL( const QString
& mrl
)
73 QString type
= uri
.scheme();
76 !mrl
.startsWith("http") &&
77 !mrl
.startsWith("ftp") &&
78 !mrl
.startsWith("/") )
80 int pos
= mrl
.indexOf("://");
83 sourceValueLabel
->setText( mrl
.left( pos
) );
84 sourceLine
->setText( mrl
);
87 else if ( type
== "window" )
89 /* QUrl mangles X11 Window identifiers so use the raw mrl */
90 sourceLine
->setText( mrl
);
95 toNativeSeparators(uri
.toDisplayString(
96 QUrl::RemovePassword
| QUrl::PreferLocalFile
| QUrl::NormalizePathSegments
98 if ( type
.isEmpty() ) type
= qtr( I_FILE_SLASH_DIR
);
99 sourceValueLabel
->setText( type
);
103 #define CT( x ) connect( x, SIGNAL(textChanged(QString)), this, SIGNAL(mrlUpdated()) );
104 #define CS( x ) connect( x, SIGNAL(valueChanged(int)), this, SIGNAL(mrlUpdated()) );
106 VirtualDestBox::VirtualDestBox( QWidget
*_parent
) : QWidget( _parent
)
108 label
= new QLabel( this );
109 label
->setWordWrap( true );
110 layout
= new QGridLayout( this );
111 layout
->addWidget( label
, 0, 0, 1, -1);
114 VirtualDestBox::~VirtualDestBox()
121 FileDestBox::FileDestBox( QWidget
*_parent
, intf_thread_t
* _p_intf
) : VirtualDestBox( _parent
)
125 QPushButton
*fileSelectButton
;
127 label
->setText( qtr( "This module writes the transcoded stream to a file.") );
129 QLabel
*fileLabel
= new QLabel( qtr( "Filename"), this );
130 layout
->addWidget(fileLabel
, 1, 0, 1, 1);
132 fileEdit
= new QLineEdit(this);
133 layout
->addWidget(fileEdit
, 1, 4, 1, 1);
135 fileSelectButton
= new QPushButton( qtr( "Browse..." ), this );
136 QSizePolicy
sizePolicy(QSizePolicy::Maximum
, QSizePolicy::Fixed
);
137 fileSelectButton
->setSizePolicy(sizePolicy
);
139 layout
->addWidget(fileSelectButton
, 1, 5, 1, 1);
141 BUTTONACT( fileSelectButton
, fileBrowse() );
144 QString
FileDestBox::getMRL( const QString
& mux
)
146 if( fileEdit
->text().isEmpty() ) return "";
150 QString outputfile
= fileEdit
->text();
153 if( outputfile
.contains( QRegExp("\\..{2,4}$")) &&
154 !outputfile
.endsWith(mux
) )
156 /* Replace the extension according to muxer */
157 outputfile
.replace(QRegExp("\\..{2,4}$"),"."+mux
);
158 } else if (!outputfile
.endsWith( mux
) )
160 m
.option( "mux", mux
);
163 m
.option( "dst", outputfile
);
164 m
.option( "no-overwrite" );
170 void FileDestBox::fileBrowse()
172 QString fileName
= QFileDialog::getSaveFileName( this, qtr( "Save file..." ),
173 p_intf
->p_sys
->filepath
, qtr( "Containers (*.ps *.ts *.mpg *.ogg *.asf *.mp4 *.mov *.wav *.raw *.flv *.webm)" ) );
174 fileEdit
->setText( toNativeSeparators( fileName
) );
180 HTTPDestBox::HTTPDestBox( QWidget
*_parent
) : VirtualDestBox( _parent
)
182 label
->setText( qtr( "This module outputs the transcoded stream to a network via HTTP.") );
184 QLabel
*HTTPLabel
= new QLabel( qtr("Path"), this );
185 QLabel
*HTTPPortLabel
= new QLabel( qtr("Port"), this );
186 layout
->addWidget(HTTPLabel
, 2, 0, 1, 1);
187 layout
->addWidget(HTTPPortLabel
, 1, 0, 1, 1);
189 HTTPEdit
= new QLineEdit(this);
190 HTTPEdit
->setText( "/" );
192 HTTPPort
= new QSpinBox(this);
193 HTTPPort
->setMaximumSize(QSize(90, 16777215));
194 HTTPPort
->setAlignment(Qt::AlignRight
|Qt::AlignTrailing
|Qt::AlignVCenter
);
195 HTTPPort
->setMinimum(1);
196 HTTPPort
->setMaximum(65535);
197 HTTPPort
->setValue(8080);
199 layout
->addWidget(HTTPEdit
, 2, 1, 1, 1);
200 layout
->addWidget(HTTPPort
, 1, 1, 1, 1);
205 QString
HTTPDestBox::getMRL( const QString
& mux
)
207 if( HTTPEdit
->text().isEmpty() ) return "";
209 QString path
= HTTPEdit
->text();
211 path
.prepend( qfu("/") );
213 port
.setNum( HTTPPort
->value() );
214 QString dst
= ":" + port
+ path
;
218 /* Path-extension is primary muxer to use if possible,
219 otherwise check for mux-choise and see that it isn't mp4
220 then fallback to flv*/
221 if ( !path
.contains(QRegExp("\\..{2,3}$") ) )
223 if( !mux
.isEmpty() && mux
.compare("mp4") )
224 m
.option( "mux", mux
);
226 m
.option( "mux", "ffmpeg{mux=flv}" );
228 m
.option( "dst", dst
);
234 MMSHDestBox::MMSHDestBox( QWidget
*_parent
) : VirtualDestBox( _parent
)
236 label
->setText( qtr( "This module outputs the transcoded stream to a network "
237 "via the mms protocol." ) );
239 QLabel
*MMSHLabel
= new QLabel( qtr("Address"), this );
240 QLabel
*MMSHPortLabel
= new QLabel( qtr("Port"), this );
241 layout
->addWidget(MMSHLabel
, 1, 0, 1, 1);
242 layout
->addWidget(MMSHPortLabel
, 2, 0, 1, 1);
244 MMSHEdit
= new QLineEdit(this);
245 MMSHEdit
->setText( "0.0.0.0" );
247 MMSHPort
= new QSpinBox(this);
248 MMSHPort
->setMaximumSize(QSize(90, 16777215));
249 MMSHPort
->setAlignment(Qt::AlignRight
|Qt::AlignTrailing
|Qt::AlignVCenter
);
250 MMSHPort
->setMinimum(1);
251 MMSHPort
->setMaximum(65535);
252 MMSHPort
->setValue(8080);
254 layout
->addWidget(MMSHEdit
, 1, 1, 1, 1);
255 layout
->addWidget(MMSHPort
, 2, 1, 1, 1);
260 QString
MMSHDestBox::getMRL( const QString
& )
262 if( MMSHEdit
->text().isEmpty() ) return "";
266 m
.option( "access", "mmsh" );
267 m
.option( "mux", "asfh" );
268 m
.option( "dst", MMSHEdit
->text(), MMSHPort
->value() );
275 RTSPDestBox::RTSPDestBox( QWidget
*_parent
) : VirtualDestBox( _parent
)
278 qtr( "This module outputs the transcoded stream to a network via RTSP." ) );
280 QLabel
*RTSPLabel
= new QLabel( qtr("Path"), this );
281 QLabel
*RTSPPortLabel
= new QLabel( qtr("Port"), this );
282 layout
->addWidget( RTSPLabel
, 2, 0, 1, 1 );
283 layout
->addWidget( RTSPPortLabel
, 1, 0, 1, 1 );
285 RTSPEdit
= new QLineEdit( this );
286 RTSPEdit
->setText( "/" );
288 RTSPPort
= new QSpinBox( this );
289 RTSPPort
->setMaximumSize( QSize( 90, 16777215 ) );
290 RTSPPort
->setAlignment( Qt::AlignRight
|Qt::AlignTrailing
|Qt::AlignVCenter
);
291 RTSPPort
->setMinimum( 1 );
292 RTSPPort
->setMaximum( 65535 );
293 RTSPPort
->setValue( 8554 );
295 layout
->addWidget( RTSPEdit
, 2, 1, 1, 1 );
296 layout
->addWidget( RTSPPort
, 1, 1, 1, 1 );
301 QString
RTSPDestBox::getMRL( const QString
& )
303 if( RTSPEdit
->text().isEmpty() ) return "";
305 QString path
= RTSPEdit
->text();
307 path
.prepend( qfu("/") );
309 port
.setNum( RTSPPort
->value() );
310 QString sdp
= "rtsp://:" + port
+ path
;
314 m
.option( "sdp", sdp
);
321 UDPDestBox::UDPDestBox( QWidget
*_parent
) : VirtualDestBox( _parent
)
324 qtr( "This module outputs the transcoded stream to a network via UDP.") );
326 QLabel
*UDPLabel
= new QLabel( qtr("Address"), this );
327 QLabel
*UDPPortLabel
= new QLabel( qtr("Port"), this );
328 layout
->addWidget(UDPLabel
, 1, 0, 1, 1);
329 layout
->addWidget(UDPPortLabel
, 2, 0, 1, 1);
331 UDPEdit
= new QLineEdit(this);
333 UDPPort
= new QSpinBox(this);
334 UDPPort
->setMaximumSize(QSize(90, 16777215));
335 UDPPort
->setAlignment(Qt::AlignRight
|Qt::AlignTrailing
|Qt::AlignVCenter
);
336 UDPPort
->setMinimum(1);
337 UDPPort
->setMaximum(65535);
338 UDPPort
->setValue(1234);
340 layout
->addWidget(UDPEdit
, 1, 1, 1, 1);
341 layout
->addWidget(UDPPort
, 2, 1, 1, 1);
346 QString
UDPDestBox::getMRL( const QString
& mux
)
348 if( UDPEdit
->text().isEmpty() ) return "";
352 /* udp output, ts-mux is really only reasonable one to use*/
353 if( !mux
.isEmpty() && !mux
.compare("ts" ) )
354 m
.option( "mux", mux
);
355 m
.option( "dst", UDPEdit
->text(), UDPPort
->value() );
363 RTPDestBox::RTPDestBox( QWidget
*_parent
, const char *_mux
)
364 : VirtualDestBox( _parent
), mux( qfu(_mux
) )
366 label
->setText( qtr( "This module outputs the transcoded stream to a network via RTP.") );
368 QLabel
*RTPLabel
= new QLabel( qtr("Address"), this );
369 RTPEdit
= new QLineEdit(this);
370 layout
->addWidget(RTPLabel
, 1, 0, 1, 1);
371 layout
->addWidget(RTPEdit
, 1, 1, 1, 1);
373 QLabel
*RTPPortLabel
= new QLabel( qtr("Base port"), this );
374 RTPPort
= new QSpinBox(this);
375 RTPPort
->setMaximumSize(QSize(90, 16777215));
376 RTPPort
->setAlignment(Qt::AlignRight
|Qt::AlignTrailing
|Qt::AlignVCenter
);
377 RTPPort
->setMinimum(1);
378 RTPPort
->setMaximum(65535);
379 RTPPort
->setValue(5004);
380 layout
->addWidget(RTPPortLabel
, 2, 0, 1, 1);
381 layout
->addWidget(RTPPort
, 2, 1, 1, 1);
383 QLabel
*SAPNameLabel
= new QLabel( qtr("Stream name"), this );
384 SAPName
= new QLineEdit(this);
385 layout
->addWidget(SAPNameLabel
, 3, 0, 1, 1);
386 layout
->addWidget(SAPName
, 3, 1, 1, 1);
393 QString
RTPDestBox::getMRL( const QString
& )
395 QString addr
= RTPEdit
->text();
396 QString name
= SAPName
->text();
398 if( addr
.isEmpty() ) return qfu("");
402 m
.option( "dst", RTPEdit
->text() );
403 m
.option( "port", RTPPort
->value() );
404 /* mp4-mux ain't usable in rtp-output either */
406 m
.option( "mux", mux
);
407 if( !name
.isEmpty() )
410 m
.option( "name", name
);
418 ICEDestBox::ICEDestBox( QWidget
*_parent
) : VirtualDestBox( _parent
)
421 qtr( "This module outputs the transcoded stream to an Icecast server.") );
423 QLabel
*ICELabel
= new QLabel( qtr("Address"), this );
424 QLabel
*ICEPortLabel
= new QLabel( qtr("Port"), this );
425 layout
->addWidget(ICELabel
, 1, 0, 1, 1);
426 layout
->addWidget(ICEPortLabel
, 2, 0, 1, 1);
428 ICEEdit
= new QLineEdit(this);
430 ICEPort
= new QSpinBox(this);
431 ICEPort
->setMaximumSize(QSize(90, 16777215));
432 ICEPort
->setAlignment(Qt::AlignRight
|Qt::AlignTrailing
|Qt::AlignVCenter
);
433 ICEPort
->setMinimum(1);
434 ICEPort
->setMaximum(65535);
435 ICEPort
->setValue(8000);
437 layout
->addWidget(ICEEdit
, 1, 1, 1, 1);
438 layout
->addWidget(ICEPort
, 2, 1, 1, 1);
440 QLabel
*IcecastMountpointLabel
= new QLabel( qtr( "Mount Point" ), this );
441 QLabel
*IcecastNameLabel
= new QLabel( qtr( "Login:pass" ), this );
442 ICEMountEdit
= new QLineEdit( this );
443 ICEPassEdit
= new QLineEdit( this );
444 layout
->addWidget(IcecastMountpointLabel
, 3, 0, 1, 1 );
445 layout
->addWidget(ICEMountEdit
, 3, 1, 1, -1 );
446 layout
->addWidget(IcecastNameLabel
, 4, 0, 1, 1 );
447 layout
->addWidget(ICEPassEdit
, 4, 1, 1, -1 );
458 QString
ICEDestBox::getMRL( const QString
& )
460 if( ICEEdit
->text().isEmpty() ) return "";
464 m
.option( "access", "shout" );
465 m
.option( "mux", "ogg" );
467 QString url
= "//" + ICEPassEdit
->text() + "@"
469 + ":" + QString::number( ICEPort
->value(), 10 )
470 + "/" + ICEMountEdit
->text();
472 m
.option( "dst", url
);