]> git.sesse.net Git - vlc/blob - modules/gui/qt4/dialogs/sout.cpp
properly display translated strings in setWindowTitle in qt4 interface
[vlc] / modules / gui / qt4 / dialogs / sout.cpp
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 $
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
8  *
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.
13  *
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.
18  *
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  *****************************************************************************/
23
24 #include "dialogs/sout.hpp"
25 #include "qt4.hpp"
26 #include <vlc_streaming.h>
27
28 #include <QFileDialog>
29
30 SoutDialog::SoutDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
31 {
32     setWindowTitle( qtr( "Stream output") );
33     main = new QWidget( this );
34
35     /* UI stuff */
36     ui.setupUi( main );
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" );
50
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" );
60
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" );
69
70     /* Connect everything to the updateMRL function */
71 #define CB(x) CONNECT( ui.x, clicked(bool), this, updateMRL() );
72 #define CT(x) CONNECT( ui.x, textChanged(const QString), this, updateMRL() );
73 #define CS(x) CONNECT( ui.x, valueChanged(int), this, updateMRL() );
74 #define CC(x) CONNECT( ui.x, currentIndexChanged(int), this, updateMRL() );
75     /* Output */
76     CB( fileOutput ); CB( HTTPOutput ); CB( localOutput );
77     CB( UDPOutput ); CB( MMSHOutput ); CB( rawInput );
78     CT( fileEdit ); CT( HTTPEdit ); CT( UDPEdit ); CT( MMSHEdit );
79     CS( HTTPPort ); CS( UDPPort ); CS( MMSHPort );
80     /* Transcode */
81     CC( vCodec ); CC( sCodec ); CC( aCodec ) ;
82     CB( transcodeVideo ); CB( transcodeAudio ); CB( transcodeSubs );
83     CB( sOverlay );
84     CS( vBitrate ); CS( aBitrate ); CS( aChannels ); CC( vScale );
85     /* Mux */
86     CB( PSMux ); CB( TSMux ); CB( MPEG1Mux ); CB( OggMux ); CB( ASFMux );
87     CB( MP4Mux ); CB( MOVMux ); CB( WAVMux ); CB( RAWMux );
88     /* Misc */
89     CB( soutAll ); CS( ttl ); CT( sapName ); CT( sapGroup );
90
91     CONNECT( ui.fileSelectButton, clicked(), this, fileBrowse() );
92 }
93
94 void SoutDialog::fileBrowse()
95 {
96     QString f = QFileDialog::getOpenFileName( this, qtr("Save file"), "", "" );
97     ui.fileEdit->setText( f );
98     updateMRL();
99 }
100
101 void SoutDialog::ok()
102 {
103 }
104 void SoutDialog::cancel()
105 {
106 }
107
108 void SoutDialog::updateMRL()
109 {
110     sout_gui_descr_t pd;
111     memset( &pd, 0, sizeof( sout_gui_descr_t ) );
112
113     /* Output */
114     pd.b_dump = ui.rawInput->isChecked();
115     if( pd.b_dump ) goto end;
116
117     pd.b_local = ui.localOutput->isChecked();
118     pd.b_file = ui.fileOutput->isChecked();
119     pd.b_http = ui.HTTPOutput->isChecked();
120     pd.b_mms = ui.MMSHOutput->isChecked();
121     pd.b_udp = ui.UDPOutput->isChecked();
122
123     pd.psz_file = ui.fileOutput->isChecked() ?
124                             strdup(qtu( ui.fileEdit->text() ) ): NULL;
125     pd.psz_http = ui.HTTPOutput->isChecked() ?
126                             strdup(qtu( ui.HTTPEdit->text() ) ) : NULL;
127     pd.psz_mms = ui.MMSHOutput->isChecked() ?
128                             strdup(qtu( ui.MMSHEdit->text() ) ): NULL;
129     pd.psz_udp = ui.UDPOutput->isChecked() ?
130                             strdup( qtu( ui.UDPEdit->text() ) ): NULL;
131
132     pd.i_http = ui.HTTPPort->value();
133     pd.i_mms = ui.MMSHPort->value();
134     pd.i_udp = ui.UDPPort->value();
135
136     /* Mux */
137 #define SMUX(x, txt) if( ui.x##Mux->isChecked() ) pd.psz_mux = strdup(txt);
138     SMUX( PS, "ps" );
139     SMUX( TS, "ts" );
140     SMUX( MPEG1, "mpeg" );
141     SMUX( Ogg, "ogg" );
142     SMUX( ASF, "asf" );
143     SMUX( MP4, "mp4" );
144     SMUX( MOV, "mov" );
145     SMUX( WAV, "wav" );
146     SMUX( RAW, "raw" );
147
148     /* Transcode */
149     pd.b_soverlay = ui.sOverlay->isChecked();
150     pd.i_vb = ui.vBitrate->value();
151     pd.i_ab = ui.aBitrate->value();
152     pd.i_channels = ui.aChannels->value();
153     pd.f_scale = atof( qta( ui.vScale->currentText() ) );
154
155     pd.psz_vcodec = ui.transcodeVideo->isChecked() ?
156                      strdup( qtu( ui.vCodec->itemData(
157                             ui.vCodec->currentIndex() ). toString() ) ) : NULL;
158     pd.psz_acodec = ui.transcodeAudio->isChecked() ?
159                      strdup( qtu( ui.aCodec->itemData(
160                             ui.aCodec->currentIndex() ).toString() ) ) : NULL;
161     pd.psz_scodec = ui.transcodeSubs->isChecked() ?
162                      strdup( qtu( ui.sCodec->itemData(
163                             ui.sCodec->currentIndex() ).toString() ) ) : NULL;
164     pd.b_sap = ui.sap->isChecked();
165     pd.b_all_es = ui.soutAll->isChecked();
166     pd.psz_name = qtu( ui.sapName->text() );
167     pd.psz_group = qtu( ui.sapGroup->text() );
168     pd.i_ttl = ui.ttl->value() ;
169 end:
170     sout_chain_t* p_chain = streaming_ChainNew();
171     streaming_GuiDescToChain( VLC_OBJECT(p_intf), p_chain, &pd );
172     char *psz_mrl = streaming_ChainToPsz( p_chain );
173     ui.mrlEdit->setText( qfu( strdup(psz_mrl) ) );
174     free( pd.psz_acodec ); free( pd.psz_vcodec ); free( pd.psz_scodec );
175     free( pd.psz_file );free( pd.psz_http ); free( pd.psz_mms );
176     free( pd.psz_udp ); free( pd.psz_mux );
177 }