1 /*****************************************************************************
2 * sout.cpp : Stream output dialog (old-style)
3 ****************************************************************************
4 * Copyright (C) 2006 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #include "dialogs/sout.hpp"
26 #include <vlc_streaming.h>
30 #include <QFileDialog>
32 SoutDialog::SoutDialog( QWidget *parent, intf_thread_t *_p_intf,
33 bool _transcode_only ) : QVLCDialog( parent, _p_intf )
35 setWindowTitle( qtr( "Stream output") );
40 #define ADD_PROFILE(name) ui.comboBox->addItem( name );
46 #define ADD_VCODEC( name, fourcc) ui.vCodec_2->addItem( name, QVariant( fourcc ) );
47 ADD_VCODEC( "MPEG-1", "mp1v" )
48 ADD_VCODEC( "MPEG-2", "mp2v" )
49 ADD_VCODEC( "MPEG-4", "mp4v" )
50 ADD_VCODEC( "DIVX 1" , "DIV1" )
51 ADD_VCODEC( "DIVX 2" , "DIV1" )
52 ADD_VCODEC( "DIVX 3" , "DIV1" )
53 ADD_VCODEC( "H-263", "H263" )
54 ADD_VCODEC( "H-264", "h264" )
55 ADD_VCODEC( "WMV1", "WMV1" )
56 ADD_VCODEC( "WMV2" , "WMV2" )
57 ADD_VCODEC( "M-JPEG", "MJPG" )
58 ADD_VCODEC( "Theora", "theo" )
60 #define ADD_ACODEC( name, fourcc) ui.aCodec_2->addItem( name, QVariant( fourcc ) );
61 ADD_ACODEC( "MPEG Audio", "mpga" )
62 ADD_ACODEC( "MP3", "mp3" )
63 ADD_ACODEC( "MPEG 4 Audio (AAC)", "mp4a")
64 ADD_ACODEC( "A52/AC-3", "a52")
65 ADD_ACODEC( "Vorbis", "vorb" )
66 ADD_ACODEC( "Flac", "flac" )
67 ADD_ACODEC( "Speex", "spx" )
68 ADD_ACODEC( "WAV", "s16l" )
69 ADD_ACODEC( "WMA", "wma" )
71 #define ADD_SCALING( factor ) ui.vScale_2->addItem( factor );
81 ui.mrlEdit->setToolTip ( qtr("Stream output string.\n This is automatically generated when you change the above settings,\n but you can update it manually." ) ) ;
83 // /* Connect everything to the updateMRL function */
84 #define CB(x) CONNECT( ui.x, clicked(bool), this, updateMRL() );
85 #define CT(x) CONNECT( ui.x, textChanged(const QString), this, updateMRL() );
86 #define CS(x) CONNECT( ui.x, valueChanged(int), this, updateMRL() );
87 #define CC(x) CONNECT( ui.x, currentIndexChanged(int), this, updateMRL() );
89 CB( fileOutput ); CB( HTTPOutput ); CB( localOutput );
90 CB( UDPOutput ); CB( MMSHOutput ); CB( rawInput );
91 CT( fileEdit ); CT( HTTPEdit ); CT( UDPEdit ); CT( MMSHEdit );
92 CS( HTTPPort ); CS( UDPPort ); CS( MMSHPort );
94 CC( vCodec_2 ); CC( sCodec_2 ); CC( aCodec_2 ) ;
95 CB( transcodeVideo_2 ); CB( transcodeAudio_2 ); CB( transcodeSubs_2 );
97 CS( vBitrate_2 ); CS( aBitrate_2 ); CS( aChannels_2 ); CC( vScale_2 );
99 CB( PSMux ); CB( TSMux ); CB( MPEG1Mux ); CB( OggMux ); CB( ASFMux );
100 CB( MP4Mux ); CB( MOVMux ); CB( WAVMux ); CB( RAWMux ); CB( FLVMux );
102 CB( soutAll ); CS( ttl ); CT( sapName ); CT( sapGroup );
104 connect( ui.comboBox, SIGNAL(activated(const QString &)), this, SLOT(setOptions()) );
105 connect( ui.fileSelectButton, SIGNAL(clicked()), this, SLOT(fileBrowse()) );
106 connect(ui.transcodeVideo_2,SIGNAL(toggled(bool)),this,SLOT(setVTranscodeOptions(bool)));
107 connect(ui.transcodeAudio_2,SIGNAL(toggled(bool)),this,SLOT(setATranscodeOptions(bool)));
108 connect(ui.transcodeSubs_2,SIGNAL(toggled(bool)),this,SLOT(setSTranscodeOptions(bool)));
109 connect(ui.rawInput,SIGNAL(toggled(bool)),this,SLOT(setRawOptions(bool)));
111 QPushButton *okButton = new QPushButton( qtr( "&Stream" ) );
112 QPushButton *cancelButton = new QPushButton( qtr( "&Cancel" ) );
114 okButton->setDefault( true );
115 ui.acceptButtonBox->addButton( okButton, QDialogButtonBox::AcceptRole );
116 ui.acceptButtonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
118 BUTTONACT( okButton, ok());
119 BUTTONACT( cancelButton, cancel());
121 if( _transcode_only ) toggleSout();
124 void SoutDialog::fileBrowse()
125 {ui.tabWidget->setTabEnabled(0,false);
126 QString f = QFileDialog::getOpenFileName( this, qtr("Save file"), "", "" );
127 ui.fileEdit->setText( f );
131 void SoutDialog::setVTranscodeOptions(bool b_trans)
133 ui.label_2->setEnabled(b_trans);
134 ui.vCodec_2->setEnabled(b_trans);
135 ui.vBitrateLabel_2->setEnabled(b_trans);
136 ui.vScaleLabel_2->setEnabled(b_trans);
137 ui.vBitrate_2->setEnabled(b_trans);
138 ui.vScaleLabel_2->setEnabled(b_trans);
139 ui.vScale_2->setEnabled(b_trans);
142 void SoutDialog::setATranscodeOptions(bool b_trans)
144 ui.label->setEnabled(b_trans);
145 ui.aCodec_2->setEnabled(b_trans);
146 ui.aBitrateLabel_2->setEnabled(b_trans);
147 ui.aBitrate_2->setEnabled(b_trans);
148 ui.s_3->setEnabled(b_trans);
149 ui.aChannels_2->setEnabled(b_trans);
152 void SoutDialog::setSTranscodeOptions(bool b_trans)
154 ui.sCodec_2->setEnabled(b_trans);
155 ui.sOverlay_2->setEnabled(b_trans);
158 void SoutDialog::setRawOptions(bool b_raw)
162 ui.tabWidget->setDisabled(true);
166 SoutDialog::setOptions();
170 void SoutDialog::setOptions()
172 /* The test is currently done with a QString, it could be done with the index, it'd depend how translation works */
173 if (ui.comboBox->currentText() == "Custom")
175 ui.tabWidget->setEnabled(true);
179 ui.tabWidget->setDisabled(true);
183 void SoutDialog::toggleSout()
186 if( (x->isHidden()) ) \
190 TGV( ui.HTTPOutput ) ; TGV( ui.UDPOutput ) ; TGV( ui.MMSHOutput ) ;
191 TGV( ui.HTTPEdit ) ; TGV( ui.UDPEdit ) ; TGV( ui.MMSHEdit ) ;
192 TGV( ui.HTTPLabel ) ; TGV( ui.UDPLabel ) ; TGV( ui.MMSHLabel ) ;
193 TGV( ui.HTTPPortLabel ) ; TGV( ui.UDPPortLabel ) ; TGV( ui.MMSHPortLabel ) ;
194 TGV( ui.HTTPPort ) ; TGV( ui.UDPPort ) ; TGV( ui.MMSHPort ) ;
198 void SoutDialog::ok()
200 mrl = ui.mrlEdit->text();
203 void SoutDialog::cancel()
205 mrl = ui.mrlEdit->text();
209 void SoutDialog::updateMRL()
211 sout_gui_descr_t sout;
212 memset( &sout, 0, sizeof( sout_gui_descr_t ) );
214 sout.b_local = ui.localOutput->isChecked();
215 sout.b_file = ui.fileOutput->isChecked();
216 sout.b_http = ui.HTTPOutput->isChecked();
217 sout.b_mms = ui.MMSHOutput->isChecked();
218 sout.b_udp = ui.UDPOutput->isChecked();
219 sout.b_sap = ui.sap->isChecked();
220 sout.b_all_es = ui.soutAll->isChecked();
221 sout.psz_vcodec = strdup(qtu(ui.vCodec_2->itemData(ui.vCodec_2->currentIndex()).toString()));
222 sout.psz_acodec = strdup(qtu(ui.aCodec_2->itemData(ui.vCodec_2->currentIndex()).toString()));
223 sout.psz_scodec = strdup(qtu(ui.sCodec_2->itemData(ui.vCodec_2->currentIndex()).toString()));
224 sout.psz_file = strdup(qtu(ui.fileEdit->text()));
225 sout.psz_http = strdup(qtu(ui.HTTPEdit->text()));
226 sout.psz_mms = strdup(qtu(ui.MMSHEdit->text()));
227 sout.psz_udp = strdup(qtu(ui.UDPEdit->text()));
228 sout.i_http = ui.HTTPPort->value();
229 sout.i_mms = ui.MMSHPort->value();
230 sout.i_udp = ui.UDPPort->value();
231 sout.i_ab = ui.aBitrate_2->value();
232 sout.i_vb = ui.vBitrate_2->value();
233 sout.i_channels = ui.aChannels_2->value();
234 sout.f_scale = atof(qta(ui.vScale_2->currentText()));
235 sout.psz_group = strdup(qtu(ui.sapGroup->text()));
236 sout.psz_name = strdup(qtu(ui.sapName->text()));
238 #define SMUX(x, txt) if( ui.x->isChecked() ) sout.psz_mux = strdup(txt);
241 SMUX( MPEG1Mux, "mpeg" );
242 SMUX( OggMux, "ogg" );
243 SMUX( ASFMux, "asf" );
244 SMUX( MP4Mux, "mp4" );
245 SMUX( MOVMux, "mov" );
246 SMUX( WAVMux, "wav" );
247 SMUX( RAWMux, "raw" );
248 SMUX( FLVMux, "flv" );
253 if (ui.transcodeVideo_2->isChecked() || ui.transcodeAudio_2->isChecked())
255 if (ui.transcodeVideo_2->isChecked())
257 mrl = ":sout=#transcode{";
258 mrl.append("vcodec=");
259 mrl.append(sout.psz_vcodec);
262 mrl.append(QString::number(sout.i_vb,10));
264 mrl.append("scale=");
265 mrl.append(QString::number(sout.f_scale));
269 if (ui.transcodeAudio_2->isChecked())
277 mrl = ":sout=#transcode{";
279 mrl.append("acodec=");
280 mrl.append(sout.psz_acodec);
283 mrl.append(QString::number(sout.i_ab,10));
285 mrl.append("channels=");
286 mrl.append(QString::number(sout.i_channels,10));
292 if (sout.b_local || sout.b_file || sout.b_http || sout.b_mms || sout.b_udp)
295 #define ISMORE() if ( more ) mrl.append(",");
299 mrl.append(":duplicate{");
309 mrl.append("dst=display");
316 mrl.append("dst=std{access=file,mux=");
317 mrl.append(sout.psz_mux);
319 mrl.append(sout.psz_file);
327 mrl.append("dst=std{access=http,mux=");
328 mrl.append(sout.psz_mux);
330 mrl.append(sout.psz_http);
332 mrl.append(QString::number(sout.i_http,10));
340 mrl.append("dst=std{access=mmsh,mux=");
341 mrl.append(sout.psz_mux);
343 mrl.append(sout.psz_mms);
345 mrl.append(QString::number(sout.i_mms,10));
353 mrl.append("dst=std{access=udp,mux=");
354 mrl.append(sout.psz_mux);
356 mrl.append(sout.psz_udp);
358 mrl.append(QString::number(sout.i_udp,10));
362 mrl.append("group=\"");
363 mrl.append(sout.psz_group);
365 mrl.append("name=\"");
366 mrl.append(sout.psz_name);
380 mrl.append(":sout-all");
383 ui.mrlEdit->setText(mrl);
384 free( sout.psz_acodec ); free( sout.psz_vcodec ); free( sout.psz_scodec );
385 free( sout.psz_file );free( sout.psz_http ); free( sout.psz_mms );
386 free( sout.psz_udp ); free( sout.psz_mux );
387 free( sout.psz_name ); free( sout.psz_group );
390 // void SoutDialog::updateMRL()
392 // sout_gui_descr_t pd;
393 // memset( &pd, 0, sizeof( sout_gui_descr_t ) );
396 // pd.b_dump = ui.rawInput->isChecked();
397 // if( pd.b_dump ) goto end;
399 // pd.b_local = ui.localOutput->isChecked();
400 // pd.b_file = ui.fileOutput->isChecked();
401 // pd.b_http = ui.HTTPOutput->isChecked();
402 // pd.b_mms = ui.MMSHOutput->isChecked();
403 // pd.b_udp = ui.UDPOutput->isChecked();
405 // pd.psz_file = ui.fileOutput->isChecked() ?
406 // strdup(qtu( ui.fileEdit->text() ) ): NULL;
407 // pd.psz_http = ui.HTTPOutput->isChecked() ?
408 // strdup(qtu( ui.HTTPEdit->text() ) ) : NULL;
409 // pd.psz_mms = ui.MMSHOutput->isChecked() ?
410 // strdup(qtu( ui.MMSHEdit->text() ) ): NULL;
411 // pd.psz_udp = ui.UDPOutput->isChecked() ?
412 // strdup( qtu( ui.UDPEdit->text() ) ): NULL;
414 // pd.i_http = ui.HTTPPort->value();
415 // pd.i_mms = ui.MMSHPort->value();
416 // pd.i_udp = ui.UDPPort->value();
419 // #define SMUX(x, txt) if( ui.x##Mux->isChecked() ) pd.psz_mux = strdup(txt);
422 // SMUX( MPEG1, "mpeg" );
423 // SMUX( Ogg, "ogg" );
424 // SMUX( ASF, "asf" );
425 // SMUX( MP4, "mp4" );
426 // SMUX( MOV, "mov" );
427 // SMUX( WAV, "wav" );
428 // SMUX( RAW, "raw" );
429 // SMUX( FLV, "flv" );
434 // // pd.b_soverlay = ui.sOverlay->isChecked();
435 // // pd.i_vb = ui.vBitrate->value();
436 // // pd.i_ab = ui.aBitrate->value();
437 // // pd.i_channels = ui.aChannels->value();
438 // // pd.f_scale = atof( qta( ui.vScale->currentText() ) );
440 // // pd.psz_vcodec = ui.transcodeVideo->isChecked() ?
441 // // strdup( qtu( ui.vCodec->itemData(
442 // // ui.vCodec->currentIndex() ). toString() ) ) : NULL;
443 // // pd.psz_acodec = ui.transcodeAudio->isChecked() ?
444 // // strdup( qtu( ui.aCodec->itemData(
445 // // ui.aCodec->currentIndex() ).toString() ) ) : NULL;
446 // // pd.psz_scodec = ui.transcodeSubs->isChecked() ?
447 // // strdup( qtu( ui.sCodec->itemData(
448 // // ui.sCodec->currentIndex() ).toString() ) ) : NULL;
449 // // pd.b_sap = ui.sap->isChecked();
450 // // pd.b_all_es = ui.soutAll->isChecked();
451 // // pd.psz_name = qtu( ui.sapName->text() );
452 // // pd.psz_group = qtu( ui.sapGroup->text() );
453 // // pd.i_ttl = ui.ttl->value() ;
455 // sout_chain_t* p_chain = streaming_ChainNew();
456 // streaming_GuiDescToChain( VLC_OBJECT(p_intf), p_chain, &pd );
457 // char *psz_mrl = streaming_ChainToPsz( p_chain );
459 // ui.mrlEdit->setText( qfu( strdup(psz_mrl) ) );
460 // free( pd.psz_acodec ); free( pd.psz_vcodec ); free( pd.psz_scodec );
461 // free( pd.psz_file );free( pd.psz_http ); free( pd.psz_mms );
462 // free( pd.psz_udp ); free( pd.psz_mux );