1 /*****************************************************************************
2 * profile_selector.cpp : A small profile selector and editor
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"
32 #include <QGridLayout>
35 #include <QFileDialog>
37 SoutInputBox::SoutInputBox( QWidget *_parent, const QString& mrl ) : QGroupBox( _parent )
42 setTitle( qtr( "Source" ) );
43 QGridLayout *sourceLayout = new QGridLayout( this );
45 QLabel *sourceLabel = new QLabel( qtr( "Source:" ) );
46 sourceLayout->addWidget( sourceLabel, 0, 0 );
48 sourceLine = new QLineEdit;
49 sourceLine->setReadOnly( true );
50 sourceLine->setText( mrl );
51 sourceLabel->setBuddy( sourceLine );
52 sourceLayout->addWidget( sourceLine, 0, 1 );
54 QLabel *sourceTypeLabel = new QLabel( qtr( "Type:" ) );
55 sourceLayout->addWidget( sourceTypeLabel, 1, 0 );
56 sourceValueLabel = new QLabel;
57 sourceLayout->addWidget( sourceValueLabel, 1, 1 );
60 QFrame *line = new QFrame;
61 line->setFrameStyle( QFrame::HLine |QFrame::Sunken );
62 sourceLayout->addWidget( line, 2, 0, 1, -1 );
65 void SoutInputBox::setMRL( const QString& mrl )
67 sourceLine->setText( mrl );
69 int i = mrl.indexOf( "://" );
75 type = qtr( "File/Directory" );
76 sourceValueLabel->setText( type );
79 #define CT( x ) connect( x, SIGNAL( textChanged( const QString& ) ), this, SIGNAL( mrlUpdated() ) );
80 #define CS( x ) connect( x, SIGNAL( valueChanged( int ) ), this, SIGNAL( mrlUpdated() ) );
83 FileDestBox::FileDestBox( QWidget *_parent ) : VirtualDestBox( _parent )
85 QPushButton *fileSelectButton;
86 QGridLayout *layout = new QGridLayout( this );
88 QLabel *fileOutput = new QLabel(
89 qtr( "This module writes the transcoded stream to a file."), this );
90 layout->addWidget(fileOutput, 0, 0, 1, -1);
92 QLabel *fileLabel = new QLabel( qtr( "Filename"), this );
93 layout->addWidget(fileLabel, 1, 0, 1, 1);
95 fileEdit = new QLineEdit(this);
96 layout->addWidget(fileEdit, 1, 4, 1, 1);
98 fileSelectButton = new QPushButton( qtr( "Browse..." ), this );
99 QSizePolicy sizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
100 fileSelectButton->setSizePolicy(sizePolicy);
102 layout->addWidget(fileSelectButton, 1, 5, 1, 1);
104 BUTTONACT( fileSelectButton, fileBrowse() );
107 QString FileDestBox::getMRL( const QString& mux )
109 if( fileEdit->text().isEmpty() ) return "";
113 m.option( "access", "file" );
115 m.option( "mux", mux ); //FIXME: alert if ext doesn't match
116 m.option( "dst", fileEdit->text() );
122 void FileDestBox::fileBrowse()
124 QString fileName = QFileDialog::getSaveFileName( this, qtr( "Save file..." ),
125 "", qtr( "Containers (*.ps *.ts *.mpg *.ogg *.asf *.mp4 *.mov *.wav *.raw *.flv)" ) );
126 fileEdit->setText( toNativeSeparators( fileName ) );
132 HTTPDestBox::HTTPDestBox( QWidget *_parent ) : VirtualDestBox( _parent )
134 QGridLayout *layout = new QGridLayout( this );
136 QLabel *httpOutput = new QLabel(
137 qtr( "This module outputs the transcoded stream to a network via HTTP."),
139 layout->addWidget(httpOutput, 0, 0, 1, -1);
141 QLabel *HTTPLabel = new QLabel( qtr("Path"), this );
142 QLabel *HTTPPortLabel = new QLabel( qtr("Port"), this );
143 layout->addWidget(HTTPLabel, 2, 0, 1, 1);
144 layout->addWidget(HTTPPortLabel, 1, 0, 1, 1);
146 HTTPEdit = new QLineEdit(this);
147 HTTPEdit->setText( "/" );
149 HTTPPort = new QSpinBox(this);
150 HTTPPort->setMaximumSize(QSize(90, 16777215));
151 HTTPPort->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
152 HTTPPort->setMinimum(1);
153 HTTPPort->setMaximum(65535);
154 HTTPPort->setValue(8080);
156 layout->addWidget(HTTPEdit, 2, 1, 1, 1);
157 layout->addWidget(HTTPPort, 1, 1, 1, 1);
162 QString HTTPDestBox::getMRL( const QString& mux )
164 if( HTTPEdit->text().isEmpty() ) return "";
166 QString path = HTTPEdit->text();
168 path.prepend( qfu("/") );
170 port.setNum( HTTPPort->value() );
171 QString dst = ":" + port + path;
175 m.option( "access", "http" );
177 m.option( "mux", mux );
178 m.option( "dst", dst );
184 MMSHDestBox::MMSHDestBox( QWidget *_parent ) : VirtualDestBox( _parent )
186 QGridLayout *layout = new QGridLayout( this );
188 QLabel *mmshOutput = new QLabel(
189 qtr( "This module outputs the transcoded stream to a network "
190 " via the mms protocol." ), this );
191 layout->addWidget(mmshOutput, 0, 0, 1, -1);
193 QLabel *MMSHLabel = new QLabel( qtr("Address"), this );
194 QLabel *MMSHPortLabel = new QLabel( qtr("Port"), this );
195 layout->addWidget(MMSHLabel, 1, 0, 1, 1);
196 layout->addWidget(MMSHPortLabel, 2, 0, 1, 1);
198 MMSHEdit = new QLineEdit(this);
199 MMSHEdit->setText( "0.0.0.0" );
201 MMSHPort = new QSpinBox(this);
202 MMSHPort->setMaximumSize(QSize(90, 16777215));
203 MMSHPort->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
204 MMSHPort->setMinimum(1);
205 MMSHPort->setMaximum(65535);
206 MMSHPort->setValue(8080);
208 layout->addWidget(MMSHEdit, 1, 1, 1, 1);
209 layout->addWidget(MMSHPort, 2, 1, 1, 1);
214 QString MMSHDestBox::getMRL( const QString& mux )
216 if( MMSHEdit->text().isEmpty() ) return "";
220 m.option( "access", "mmsh" );
221 m.option( "mux", "asfh" );
222 m.option( "dst", MMSHEdit->text(), MMSHPort->value() );
229 UDPDestBox::UDPDestBox( QWidget *_parent ) : VirtualDestBox( _parent )
231 QGridLayout *layout = new QGridLayout( this );
233 QLabel *udpOutput = new QLabel(
234 qtr( "This module outputs the transcoded stream to a network via UDP."),
236 layout->addWidget(udpOutput, 0, 0, 1, -1);
238 QLabel *UDPLabel = new QLabel( qtr("Address"), this );
239 QLabel *UDPPortLabel = new QLabel( qtr("Port"), this );
240 layout->addWidget(UDPLabel, 1, 0, 1, 1);
241 layout->addWidget(UDPPortLabel, 2, 0, 1, 1);
243 UDPEdit = new QLineEdit(this);
245 UDPPort = new QSpinBox(this);
246 UDPPort->setMaximumSize(QSize(90, 16777215));
247 UDPPort->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
248 UDPPort->setMinimum(1);
249 UDPPort->setMaximum(65535);
250 UDPPort->setValue(1234);
252 layout->addWidget(UDPEdit, 1, 1, 1, 1);
253 layout->addWidget(UDPPort, 2, 1, 1, 1);
258 QString UDPDestBox::getMRL( const QString& mux )
260 if( UDPEdit->text().isEmpty() ) return "";
264 m.option( "access", "udp" );
266 m.option( "mux", mux );
267 m.option( "dst", UDPEdit->text(), UDPPort->value() );
275 RTPDestBox::RTPDestBox( QWidget *_parent, const char *_mux )
276 : VirtualDestBox( _parent ), mux( _mux )
278 QGridLayout *layout = new QGridLayout( this );
280 QLabel *rtpOutput = new QLabel(
281 qtr( "This module outputs the transcoded stream to a network via RTP."),
283 layout->addWidget(rtpOutput, 0, 0, 1, -1);
285 QLabel *RTPLabel = new QLabel( qtr("Address"), this );
286 QLabel *RTPPortLabel = new QLabel( qtr("Base port"), this );
287 layout->addWidget(RTPLabel, 1, 0, 1, 1);
288 layout->addWidget(RTPPortLabel, 2, 0, 1, 1);
290 RTPEdit = new QLineEdit(this);
292 RTPPort = new QSpinBox(this);
293 RTPPort->setMaximumSize(QSize(90, 16777215));
294 RTPPort->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
295 RTPPort->setMinimum(1);
296 RTPPort->setMaximum(65535);
297 RTPPort->setValue(5004);
299 layout->addWidget(RTPEdit, 1, 1, 1, 1);
300 layout->addWidget(RTPPort, 2, 1, 1, 1);
306 QString RTPDestBox::getMRL( const QString& )
308 if( RTPEdit->text().isEmpty() ) return "";
312 m.option( "dst", RTPEdit->text() );
313 m.option( "port", RTPPort->value() );
315 m.option( "mux", qfu( mux ) );
322 ICEDestBox::ICEDestBox( QWidget *_parent ) : VirtualDestBox( _parent )
324 QGridLayout *layout = new QGridLayout( this );
326 QLabel *iceOutput = new QLabel(
327 qtr( "This module outputs the transcoded stream to an Icecast server."),
329 layout->addWidget(iceOutput, 0, 0, 1, -1);
331 QLabel *ICELabel = new QLabel( qtr("Address"), this );
332 QLabel *ICEPortLabel = new QLabel( qtr("Port"), this );
333 layout->addWidget(ICELabel, 1, 0, 1, 1);
334 layout->addWidget(ICEPortLabel, 2, 0, 1, 1);
336 ICEEdit = new QLineEdit(this);
338 ICEPort = new QSpinBox(this);
339 ICEPort->setMaximumSize(QSize(90, 16777215));
340 ICEPort->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
341 ICEPort->setMinimum(1);
342 ICEPort->setMaximum(65535);
343 ICEPort->setValue(8000);
345 layout->addWidget(ICEEdit, 1, 1, 1, 1);
346 layout->addWidget(ICEPort, 2, 1, 1, 1);
348 QLabel *IcecastMountpointLabel = new QLabel( qtr( "Mount Point" ), this );
349 QLabel *IcecastNameLabel = new QLabel( qtr( "Login:pass" ), this );
350 ICEMountEdit = new QLineEdit( this );
351 ICEPassEdit = new QLineEdit( this );
352 layout->addWidget(IcecastMountpointLabel, 3, 0, 1, 1 );
353 layout->addWidget(ICEMountEdit, 3, 1, 1, -1 );
354 layout->addWidget(IcecastNameLabel, 4, 0, 1, 1 );
355 layout->addWidget(ICEPassEdit, 4, 1, 1, -1 );
366 QString ICEDestBox::getMRL( const QString& mux )
368 if( ICEEdit->text().isEmpty() ) return "";
372 m.option( "access", "shout" );
373 m.option( "mux", "ogg" );
375 QString url = ICEPassEdit->text() + "@"
377 + ":" + QString::number( ICEPort->value(), 10 )
378 + "/" + ICEMountEdit->text();
380 m.option( "dst", url );