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, 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( 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 modules outputs to a file on your disk."), 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( 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 modules streams on the networks with the HTTP protocol."), this );
138 layout->addWidget(httpOutput, 0, 0, 1, -1);
140 QLabel *HTTPLabel = new QLabel( qtr("Address"), this );
141 QLabel *HTTPPortLabel = new QLabel( qtr("Port"), this );
142 layout->addWidget(HTTPLabel, 1, 0, 1, 1);
143 layout->addWidget(HTTPPortLabel, 2, 0, 1, 1);
145 HTTPEdit = new QLineEdit(this);
147 HTTPPort = new QSpinBox(this);
148 HTTPPort->setMaximumSize(QSize(90, 16777215));
149 HTTPPort->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
150 HTTPPort->setMinimum(1);
151 HTTPPort->setMaximum(65535);
152 HTTPPort->setValue(8080);
154 layout->addWidget(HTTPEdit, 1, 1, 1, 1);
155 layout->addWidget(HTTPPort, 2, 1, 1, 1);
160 QString HTTPDestBox::getMRL( QString mux )
162 if( HTTPEdit->text().isEmpty() ) return "";
166 m.option( "access", "http" );
168 m.option( "mux", mux );
169 m.option( "dst", HTTPEdit->text(), HTTPPort->value() );
175 MMSHDestBox::MMSHDestBox( QWidget *_parent ) : VirtualDestBox( _parent )
177 QGridLayout *layout = new QGridLayout( this );
179 QLabel *mmshOutput = new QLabel(
180 qtr( "This modules streams on the networks with the mms: protocol."), this );
181 layout->addWidget(mmshOutput, 0, 0, 1, -1);
183 QLabel *MMSHLabel = new QLabel( qtr("Address"), this );
184 QLabel *MMSHPortLabel = new QLabel( qtr("Port"), this );
185 layout->addWidget(MMSHLabel, 1, 0, 1, 1);
186 layout->addWidget(MMSHPortLabel, 2, 0, 1, 1);
188 MMSHEdit = new QLineEdit(this);
190 MMSHPort = new QSpinBox(this);
191 MMSHPort->setMaximumSize(QSize(90, 16777215));
192 MMSHPort->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
193 MMSHPort->setMinimum(1);
194 MMSHPort->setMaximum(65535);
195 MMSHPort->setValue(1234);
197 layout->addWidget(MMSHEdit, 1, 1, 1, 1);
198 layout->addWidget(MMSHPort, 2, 1, 1, 1);
203 QString MMSHDestBox::getMRL( QString mux )
205 if( MMSHEdit->text().isEmpty() ) return "";
209 m.option( "access", "mmsh" );
210 m.option( "mux", "asfh" );
211 m.option( "dst", MMSHEdit->text(), MMSHPort->value() );
218 UDPDestBox::UDPDestBox( QWidget *_parent ) : VirtualDestBox( _parent )
220 QGridLayout *layout = new QGridLayout( this );
222 QLabel *udpOutput = new QLabel(
223 qtr( "This modules streams on the networks with the UDP protocol."), this );
224 layout->addWidget(udpOutput, 0, 0, 1, -1);
226 QLabel *UDPLabel = new QLabel( qtr("Address"), this );
227 QLabel *UDPPortLabel = new QLabel( qtr("Port"), this );
228 layout->addWidget(UDPLabel, 1, 0, 1, 1);
229 layout->addWidget(UDPPortLabel, 2, 0, 1, 1);
231 UDPEdit = new QLineEdit(this);
233 UDPPort = new QSpinBox(this);
234 UDPPort->setMaximumSize(QSize(90, 16777215));
235 UDPPort->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
236 UDPPort->setMinimum(1);
237 UDPPort->setMaximum(65535);
238 UDPPort->setValue(1234);
240 layout->addWidget(UDPEdit, 1, 1, 1, 1);
241 layout->addWidget(UDPPort, 2, 1, 1, 1);
246 QString UDPDestBox::getMRL( QString mux )
248 if( UDPEdit->text().isEmpty() ) return "";
252 m.option( "access", "udp" );
254 m.option( "mux", mux );
255 m.option( "dst", UDPEdit->text(), UDPPort->value() );
263 RTPDestBox::RTPDestBox( QWidget *_parent ) : VirtualDestBox( _parent )
265 QGridLayout *layout = new QGridLayout( this );
267 QLabel *rtpOutput = new QLabel(
268 qtr( "This modules streams on the networks with the RTP protocol."), this );
269 layout->addWidget(rtpOutput, 0, 0, 1, -1);
271 QLabel *RTPLabel = new QLabel( qtr("Address"), this );
272 QLabel *RTPPortLabel = new QLabel( qtr("Port"), this );
273 layout->addWidget(RTPLabel, 1, 0, 1, 1);
274 layout->addWidget(RTPPortLabel, 2, 0, 1, 1);
276 RTPEdit = new QLineEdit(this);
278 RTPPort = new QSpinBox(this);
279 RTPPort->setMaximumSize(QSize(90, 16777215));
280 RTPPort->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
281 RTPPort->setMinimum(1);
282 RTPPort->setMaximum(65535);
283 RTPPort->setValue(1234);
285 RTPPortAudio = new QSpinBox(this);
286 RTPPortAudio->setMaximumSize(QSize(90, 16777215));
287 RTPPortAudio->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
288 RTPPortAudio->setMinimum(-1);
289 RTPPortAudio->setMaximum(65535);
290 RTPPortAudio->setValue(-1);
292 RTPPortVideo = new QSpinBox(this);
293 RTPPortVideo->setMaximumSize(QSize(90, 16777215));
294 RTPPortVideo->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
295 RTPPortVideo->setMinimum(-1);
296 RTPPortVideo->setMaximum(65535);
297 RTPPortVideo->setValue(-1);
299 layout->addWidget(RTPEdit, 1, 1, 1, 1);
300 layout->addWidget(RTPPort, 2, 1, 1, 1);
302 QLabel *RTPPortAudioLabel = new QLabel( qtr("Audio Port"), this );
303 QLabel *RTPPortVideoLabel = new QLabel( qtr("Video Port"), this );
304 layout->addWidget(RTPPortAudioLabel, 3, 0, 1, 1);
305 layout->addWidget(RTPPortAudio, 3, 1, 1, 1);
306 layout->addWidget(RTPPortVideoLabel, 3, 2, 1, 1);
307 layout->addWidget(RTPPortVideo, 3, 3, 1, 1);
316 QString RTPDestBox::getMRL( QString mux )
318 if( RTPEdit->text().isEmpty() ) return "";
322 m.option( "dst", RTPEdit->text() );
323 m.option( "port", RTPPort->value() );
325 m.option( "mux", mux );
326 if( mux.isEmpty() || mux.compare( "ts", Qt::CaseInsensitive ) )
329 m.option( "port-audio", RTPPortAudio->value() );
330 m.option( "port-video", RTPPortVideo->value() );
338 ICEDestBox::ICEDestBox( QWidget *_parent ) : VirtualDestBox( _parent )
340 QGridLayout *layout = new QGridLayout( this );
342 QLabel *iceOutput = new QLabel(
343 qtr( "This modules streams using IceCast."), this );
344 layout->addWidget(iceOutput, 0, 0, 1, -1);
346 QLabel *ICELabel = new QLabel( qtr("Address"), this );
347 QLabel *ICEPortLabel = new QLabel( qtr("Port"), this );
348 layout->addWidget(ICELabel, 1, 0, 1, 1);
349 layout->addWidget(ICEPortLabel, 2, 0, 1, 1);
351 ICEEdit = new QLineEdit(this);
353 ICEPort = new QSpinBox(this);
354 ICEPort->setMaximumSize(QSize(90, 16777215));
355 ICEPort->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
356 ICEPort->setMinimum(1);
357 ICEPort->setMaximum(65535);
358 ICEPort->setValue(1234);
360 layout->addWidget(ICEEdit, 1, 1, 1, 1);
361 layout->addWidget(ICEPort, 2, 1, 1, 1);
363 QLabel *IcecastMountpointLabel = new QLabel( qtr( "Mount Point" ), this );
364 QLabel *IcecastNameLabel = new QLabel( qtr( "Login:pass" ), this );
365 ICEMountEdit = new QLineEdit( this );
366 ICEPassEdit = new QLineEdit( this );
367 layout->addWidget(IcecastMountpointLabel, 3, 0, 1, 1 );
368 layout->addWidget(ICEMountEdit, 3, 1, 1, -1 );
369 layout->addWidget(IcecastNameLabel, 4, 0, 1, 1 );
370 layout->addWidget(ICEPassEdit, 4, 1, 1, -1 );
378 QString ICEDestBox::getMRL( QString mux )
380 if( ICEEdit->text().isEmpty() ) return "";
384 m.option( "access", "shout" );
385 m.option( "mux", "ogg" );
387 QString url = ICEPassEdit->text() + "@"
389 + ":" + QString::number( ICEPort->value(), 10 )
390 + "/" + ICEMountEdit->text();
392 m.option( "dst", url );