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 QVLCDialog( parent, _p_intf )
33 //setWindowTitle( qtr( "Stream output") );
37 #define ADD_VCODEC( name, fcc) ui.vCodec->addItem( name, QVariant( fcc ) );
38 ADD_VCODEC( "MPEG-1", "mp1v" );
39 ADD_VCODEC( "MPEG-2", "mp2v" );
40 ADD_VCODEC( "MPEG-4", "mp4v" );
41 ADD_VCODEC( "DIVX 1" , "DIV1" );
42 ADD_VCODEC( "DIVX 2" , "DIV1" );
43 ADD_VCODEC( "DIVX 3" , "DIV1" );
44 ADD_VCODEC( "H-263", "H263" );
45 ADD_VCODEC( "H-264", "h264" );
46 ADD_VCODEC( "WMV1", "WMV1" );
47 ADD_VCODEC( "WMV2" , "WMV2" );
48 ADD_VCODEC( "M-JPEG", "MJPG" );
49 ADD_VCODEC( "Theora", "theo" );
51 #define ADD_ACODEC( name, fcc) ui.aCodec->addItem( name, QVariant( fcc ) );
52 ADD_ACODEC( "MPEG Audio", "mpga" );
53 ADD_ACODEC( "MP3", "mp3" );
54 ADD_ACODEC( "MPEG 4 Audio (AAC)", "mp4a");
55 ADD_ACODEC( "A52/AC3", "a52");
56 ADD_ACODEC( "Vorbis", "vorb" );
57 ADD_ACODEC( "Flac", "flac" );
58 ADD_ACODEC( "Speex", "spx" );
59 ADD_ACODEC( "WAV", "s16l" );
61 ui.vScale->addItem( "0.25" );
62 ui.vScale->addItem( "0.5" );
63 ui.vScale->addItem( "0.75" );
64 ui.vScale->addItem( "1" );
65 ui.vScale->addItem( "1.25" );
66 ui.vScale->addItem( "1.5" );
67 ui.vScale->addItem( "1.75" );
68 ui.vScale->addItem( "2" );
70 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." ) ) ;
72 /* Connect everything to the updateMRL function */
73 #define CB(x) CONNECT( ui.x, clicked(bool), this, updateMRL() );
74 #define CT(x) CONNECT( ui.x, textChanged(const QString), this, updateMRL() );
75 #define CS(x) CONNECT( ui.x, valueChanged(int), this, updateMRL() );
76 #define CC(x) CONNECT( ui.x, currentIndexChanged(int), this, updateMRL() );
78 CB( fileOutput ); CB( HTTPOutput ); CB( localOutput );
79 CB( UDPOutput ); CB( MMSHOutput ); CB( rawInput );
80 CT( fileEdit ); CT( HTTPEdit ); CT( UDPEdit ); CT( MMSHEdit );
81 CS( HTTPPort ); CS( UDPPort ); CS( MMSHPort );
83 CC( vCodec ); CC( sCodec ); CC( aCodec ) ;
84 CB( transcodeVideo ); CB( transcodeAudio ); CB( transcodeSubs );
86 CS( vBitrate ); CS( aBitrate ); CS( aChannels ); CC( vScale );
88 CB( PSMux ); CB( TSMux ); CB( MPEG1Mux ); CB( OggMux ); CB( ASFMux );
89 CB( MP4Mux ); CB( MOVMux ); CB( WAVMux ); CB( RAWMux );
91 CB( soutAll ); CS( ttl ); CT( sapName ); CT( sapGroup );
93 CONNECT( ui.fileSelectButton, clicked(), this, fileBrowse() );
95 BUTTONACT( ui.okButton, ok());
96 BUTTONACT( ui.cancelButton, cancel());
99 void SoutDialog::fileBrowse()
101 QString f = QFileDialog::getOpenFileName( this, qtr("Save file"), "", "" );
102 ui.fileEdit->setText( f );
106 void SoutDialog::ok()
108 mrl = ui.mrlEdit->text();
111 void SoutDialog::cancel()
113 mrl = ui.mrlEdit->text();
117 void SoutDialog::updateMRL()
120 memset( &pd, 0, sizeof( sout_gui_descr_t ) );
123 pd.b_dump = ui.rawInput->isChecked();
124 if( pd.b_dump ) goto end;
126 pd.b_local = ui.localOutput->isChecked();
127 pd.b_file = ui.fileOutput->isChecked();
128 pd.b_http = ui.HTTPOutput->isChecked();
129 pd.b_mms = ui.MMSHOutput->isChecked();
130 pd.b_udp = ui.UDPOutput->isChecked();
132 pd.psz_file = ui.fileOutput->isChecked() ?
133 strdup(qtu( ui.fileEdit->text() ) ): NULL;
134 pd.psz_http = ui.HTTPOutput->isChecked() ?
135 strdup(qtu( ui.HTTPEdit->text() ) ) : NULL;
136 pd.psz_mms = ui.MMSHOutput->isChecked() ?
137 strdup(qtu( ui.MMSHEdit->text() ) ): NULL;
138 pd.psz_udp = ui.UDPOutput->isChecked() ?
139 strdup( qtu( ui.UDPEdit->text() ) ): NULL;
141 pd.i_http = ui.HTTPPort->value();
142 pd.i_mms = ui.MMSHPort->value();
143 pd.i_udp = ui.UDPPort->value();
146 #define SMUX(x, txt) if( ui.x##Mux->isChecked() ) pd.psz_mux = strdup(txt);
149 SMUX( MPEG1, "mpeg" );
158 pd.b_soverlay = ui.sOverlay->isChecked();
159 pd.i_vb = ui.vBitrate->value();
160 pd.i_ab = ui.aBitrate->value();
161 pd.i_channels = ui.aChannels->value();
162 pd.f_scale = atof( qta( ui.vScale->currentText() ) );
164 pd.psz_vcodec = ui.transcodeVideo->isChecked() ?
165 strdup( qtu( ui.vCodec->itemData(
166 ui.vCodec->currentIndex() ). toString() ) ) : NULL;
167 pd.psz_acodec = ui.transcodeAudio->isChecked() ?
168 strdup( qtu( ui.aCodec->itemData(
169 ui.aCodec->currentIndex() ).toString() ) ) : NULL;
170 pd.psz_scodec = ui.transcodeSubs->isChecked() ?
171 strdup( qtu( ui.sCodec->itemData(
172 ui.sCodec->currentIndex() ).toString() ) ) : NULL;
173 pd.b_sap = ui.sap->isChecked();
174 pd.b_all_es = ui.soutAll->isChecked();
175 pd.psz_name = qtu( ui.sapName->text() );
176 pd.psz_group = qtu( ui.sapGroup->text() );
177 pd.i_ttl = ui.ttl->value() ;
179 sout_chain_t* p_chain = streaming_ChainNew();
180 streaming_GuiDescToChain( VLC_OBJECT(p_intf), p_chain, &pd );
181 char *psz_mrl = streaming_ChainToPsz( p_chain );
183 ui.mrlEdit->setText( qfu( strdup(psz_mrl) ) );
184 free( pd.psz_acodec ); free( pd.psz_vcodec ); free( pd.psz_scodec );
185 free( pd.psz_file );free( pd.psz_http ); free( pd.psz_mms );
186 free( pd.psz_udp ); free( pd.psz_mux );