1 /*****************************************************************************
2 * sout.cpp : Stream output dialog (old-style)
3 ****************************************************************************
4 * Copyright (C) 2006 the VideoLAN team
5 * $Id: Errors.cpp 16024 2006-07-13 13:51:05Z xtophe $
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>
28 #include <QFileDialog>
30 SoutDialog::SoutDialog( QWidget *parent, intf_thread_t *_p_intf,
31 bool _transcode_only ) : QVLCDialog( parent, _p_intf )
33 setWindowTitle( qtr( "Stream output") );
38 #define ADD_VCODEC( name, fcc) ui.vCodec->addItem( name, QVariant( fcc ) );
39 ADD_VCODEC( "MPEG-1", "mp1v" );
40 ADD_VCODEC( "MPEG-2", "mp2v" );
41 ADD_VCODEC( "MPEG-4", "mp4v" );
42 ADD_VCODEC( "DIVX 1" , "DIV1" );
43 ADD_VCODEC( "DIVX 2" , "DIV1" );
44 ADD_VCODEC( "DIVX 3" , "DIV1" );
45 ADD_VCODEC( "H-263", "H263" );
46 ADD_VCODEC( "H-264", "h264" );
47 ADD_VCODEC( "WMV1", "WMV1" );
48 ADD_VCODEC( "WMV2" , "WMV2" );
49 ADD_VCODEC( "M-JPEG", "MJPG" );
50 ADD_VCODEC( "Theora", "theo" );
52 #define ADD_ACODEC( name, fcc) ui.aCodec->addItem( name, QVariant( fcc ) );
53 ADD_ACODEC( "MPEG Audio", "mpga" );
54 ADD_ACODEC( "MP3", "mp3" );
55 ADD_ACODEC( "MPEG 4 Audio (AAC)", "mp4a");
56 ADD_ACODEC( "A52/AC3", "a52");
57 ADD_ACODEC( "Vorbis", "vorb" );
58 ADD_ACODEC( "Flac", "flac" );
59 ADD_ACODEC( "Speex", "spx" );
60 ADD_ACODEC( "WAV", "s16l" );
62 ui.vScale->addItem( "0.25" );
63 ui.vScale->addItem( "0.5" );
64 ui.vScale->addItem( "0.75" );
65 ui.vScale->addItem( "1" );
66 ui.vScale->addItem( "1.25" );
67 ui.vScale->addItem( "1.5" );
68 ui.vScale->addItem( "1.75" );
69 ui.vScale->addItem( "2" );
71 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." ) ) ;
73 /* Connect everything to the updateMRL function */
74 #define CB(x) CONNECT( ui.x, clicked(bool), this, updateMRL() );
75 #define CT(x) CONNECT( ui.x, textChanged(const QString), this, updateMRL() );
76 #define CS(x) CONNECT( ui.x, valueChanged(int), this, updateMRL() );
77 #define CC(x) CONNECT( ui.x, currentIndexChanged(int), this, updateMRL() );
79 CB( fileOutput ); CB( HTTPOutput ); CB( localOutput );
80 CB( UDPOutput ); CB( MMSHOutput ); CB( rawInput );
81 CT( fileEdit ); CT( HTTPEdit ); CT( UDPEdit ); CT( MMSHEdit );
82 CS( HTTPPort ); CS( UDPPort ); CS( MMSHPort );
84 CC( vCodec ); CC( sCodec ); CC( aCodec ) ;
85 CB( transcodeVideo ); CB( transcodeAudio ); CB( transcodeSubs );
87 CS( vBitrate ); CS( aBitrate ); CS( aChannels ); CC( vScale );
89 CB( PSMux ); CB( TSMux ); CB( MPEG1Mux ); CB( OggMux ); CB( ASFMux );
90 CB( MP4Mux ); CB( MOVMux ); CB( WAVMux ); CB( RAWMux ); CB( FLVMux );
92 CB( soutAll ); CS( ttl ); CT( sapName ); CT( sapGroup );
94 CONNECT( ui.fileSelectButton, clicked(), this, fileBrowse() );
96 QPushButton *okButton = new QPushButton( qtr( "&Stream" ) );
97 QPushButton *cancelButton = new QPushButton( qtr( "&Cancel" ) );
99 okButton->setDefault( true );
100 ui.acceptButtonBox->addButton( okButton, QDialogButtonBox::AcceptRole );
101 ui.acceptButtonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
103 BUTTONACT( okButton, ok());
104 BUTTONACT( cancelButton, cancel());
106 if( _transcode_only ) toggleSout();
109 void SoutDialog::fileBrowse()
111 QString f = QFileDialog::getOpenFileName( this, qtr("Save file"), "", "" );
112 ui.fileEdit->setText( f );
116 void SoutDialog::toggleSout()
119 if( (x->isHidden()) ) \
123 TGV( ui.HTTPOutput ) ; TGV( ui.UDPOutput ) ; TGV( ui.MMSHOutput ) ;
124 TGV( ui.HTTPEdit ) ; TGV( ui.UDPEdit ) ; TGV( ui.MMSHEdit ) ;
125 TGV( ui.HTTPLabel ) ; TGV( ui.UDPLabel ) ; TGV( ui.MMSHLabel ) ;
126 TGV( ui.HTTPPortLabel ) ; TGV( ui.UDPPortLabel ) ; TGV( ui.MMSHPortLabel ) ;
127 TGV( ui.HTTPPort ) ; TGV( ui.UDPPort ) ; TGV( ui.MMSHPort ) ;
131 void SoutDialog::ok()
133 mrl = ui.mrlEdit->text();
136 void SoutDialog::cancel()
138 mrl = ui.mrlEdit->text();
142 void SoutDialog::updateMRL()
145 memset( &pd, 0, sizeof( sout_gui_descr_t ) );
148 pd.b_dump = ui.rawInput->isChecked();
149 if( pd.b_dump ) goto end;
151 pd.b_local = ui.localOutput->isChecked();
152 pd.b_file = ui.fileOutput->isChecked();
153 pd.b_http = ui.HTTPOutput->isChecked();
154 pd.b_mms = ui.MMSHOutput->isChecked();
155 pd.b_udp = ui.UDPOutput->isChecked();
157 pd.psz_file = ui.fileOutput->isChecked() ?
158 strdup(qtu( ui.fileEdit->text() ) ): NULL;
159 pd.psz_http = ui.HTTPOutput->isChecked() ?
160 strdup(qtu( ui.HTTPEdit->text() ) ) : NULL;
161 pd.psz_mms = ui.MMSHOutput->isChecked() ?
162 strdup(qtu( ui.MMSHEdit->text() ) ): NULL;
163 pd.psz_udp = ui.UDPOutput->isChecked() ?
164 strdup( qtu( ui.UDPEdit->text() ) ): NULL;
166 pd.i_http = ui.HTTPPort->value();
167 pd.i_mms = ui.MMSHPort->value();
168 pd.i_udp = ui.UDPPort->value();
171 #define SMUX(x, txt) if( ui.x##Mux->isChecked() ) pd.psz_mux = strdup(txt);
174 SMUX( MPEG1, "mpeg" );
184 pd.b_soverlay = ui.sOverlay->isChecked();
185 pd.i_vb = ui.vBitrate->value();
186 pd.i_ab = ui.aBitrate->value();
187 pd.i_channels = ui.aChannels->value();
188 pd.f_scale = atof( qta( ui.vScale->currentText() ) );
190 pd.psz_vcodec = ui.transcodeVideo->isChecked() ?
191 strdup( qtu( ui.vCodec->itemData(
192 ui.vCodec->currentIndex() ). toString() ) ) : NULL;
193 pd.psz_acodec = ui.transcodeAudio->isChecked() ?
194 strdup( qtu( ui.aCodec->itemData(
195 ui.aCodec->currentIndex() ).toString() ) ) : NULL;
196 pd.psz_scodec = ui.transcodeSubs->isChecked() ?
197 strdup( qtu( ui.sCodec->itemData(
198 ui.sCodec->currentIndex() ).toString() ) ) : NULL;
199 pd.b_sap = ui.sap->isChecked();
200 pd.b_all_es = ui.soutAll->isChecked();
201 pd.psz_name = qtu( ui.sapName->text() );
202 pd.psz_group = qtu( ui.sapGroup->text() );
203 pd.i_ttl = ui.ttl->value() ;
205 sout_chain_t* p_chain = streaming_ChainNew();
206 streaming_GuiDescToChain( VLC_OBJECT(p_intf), p_chain, &pd );
207 char *psz_mrl = streaming_ChainToPsz( p_chain );
209 ui.mrlEdit->setText( qfu( strdup(psz_mrl) ) );
210 free( pd.psz_acodec ); free( pd.psz_vcodec ); free( pd.psz_scodec );
211 free( pd.psz_file );free( pd.psz_http ); free( pd.psz_mms );
212 free( pd.psz_udp ); free( pd.psz_mux );