sout.cpp 7.71 KB
Newer Older
zorglub's avatar
zorglub committed
1
2
3
4
/*****************************************************************************
 * sout.cpp : Stream output dialog (old-style)
 ****************************************************************************
 * Copyright (C) 2006 the VideoLAN team
5
 * $Id$
zorglub's avatar
zorglub committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 *
 * Authors: Clément Stenac <zorglub@videolan.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

#include "dialogs/sout.hpp"
#include "qt4.hpp"
#include <vlc_streaming.h>

#include <QFileDialog>

30
31
SoutDialog::SoutDialog( QWidget *parent, intf_thread_t *_p_intf,
                     bool _transcode_only ) : QVLCDialog( parent,  _p_intf )
zorglub's avatar
zorglub committed
32
{
33
    setWindowTitle( qtr( "Stream output") );
34

zorglub's avatar
zorglub committed
35
    /* UI stuff */
36
    ui.setupUi( this );
37

zorglub's avatar
zorglub committed
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#define ADD_VCODEC( name, fcc) ui.vCodec->addItem( name, QVariant( fcc ) );
    ADD_VCODEC( "MPEG-1", "mp1v" );
    ADD_VCODEC( "MPEG-2", "mp2v" );
    ADD_VCODEC( "MPEG-4", "mp4v" );
    ADD_VCODEC( "DIVX 1" , "DIV1" );
    ADD_VCODEC( "DIVX 2" , "DIV1" );
    ADD_VCODEC( "DIVX 3" , "DIV1" );
    ADD_VCODEC( "H-263", "H263" );
    ADD_VCODEC( "H-264", "h264" );
    ADD_VCODEC( "WMV1", "WMV1" );
    ADD_VCODEC( "WMV2" , "WMV2" );
    ADD_VCODEC( "M-JPEG", "MJPG" );
    ADD_VCODEC( "Theora", "theo" );

#define ADD_ACODEC( name, fcc) ui.aCodec->addItem( name, QVariant( fcc ) );
    ADD_ACODEC( "MPEG Audio", "mpga" );
    ADD_ACODEC( "MP3", "mp3" );
    ADD_ACODEC( "MPEG 4 Audio (AAC)", "mp4a");
56
    ADD_ACODEC( "A52/AC-3", "a52");
zorglub's avatar
zorglub committed
57
58
59
60
    ADD_ACODEC( "Vorbis", "vorb" );
    ADD_ACODEC( "Flac", "flac" );
    ADD_ACODEC( "Speex", "spx" );
    ADD_ACODEC( "WAV", "s16l" );
61
    ADD_ACODEC( "WMA", "wma" );
zorglub's avatar
zorglub committed
62
63
64
65
66
67
68
69
70
71

    ui.vScale->addItem( "0.25" );
    ui.vScale->addItem( "0.5" );
    ui.vScale->addItem( "0.75" );
    ui.vScale->addItem( "1" );
    ui.vScale->addItem( "1.25" );
    ui.vScale->addItem( "1.5" );
    ui.vScale->addItem( "1.75" );
    ui.vScale->addItem( "2" );

72
73
    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." ) ) ;

zorglub's avatar
zorglub committed
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
    /* Connect everything to the updateMRL function */
#define CB(x) CONNECT( ui.x, clicked(bool), this, updateMRL() );
#define CT(x) CONNECT( ui.x, textChanged(const QString), this, updateMRL() );
#define CS(x) CONNECT( ui.x, valueChanged(int), this, updateMRL() );
#define CC(x) CONNECT( ui.x, currentIndexChanged(int), this, updateMRL() );
    /* Output */
    CB( fileOutput ); CB( HTTPOutput ); CB( localOutput );
    CB( UDPOutput ); CB( MMSHOutput ); CB( rawInput );
    CT( fileEdit ); CT( HTTPEdit ); CT( UDPEdit ); CT( MMSHEdit );
    CS( HTTPPort ); CS( UDPPort ); CS( MMSHPort );
    /* Transcode */
    CC( vCodec ); CC( sCodec ); CC( aCodec ) ;
    CB( transcodeVideo ); CB( transcodeAudio ); CB( transcodeSubs );
    CB( sOverlay );
    CS( vBitrate ); CS( aBitrate ); CS( aChannels ); CC( vScale );
    /* Mux */
    CB( PSMux ); CB( TSMux ); CB( MPEG1Mux ); CB( OggMux ); CB( ASFMux );
91
    CB( MP4Mux ); CB( MOVMux ); CB( WAVMux ); CB( RAWMux ); CB( FLVMux );
zorglub's avatar
zorglub committed
92
93
94
95
    /* Misc */
    CB( soutAll ); CS( ttl ); CT( sapName ); CT( sapGroup );

    CONNECT( ui.fileSelectButton, clicked(), this, fileBrowse() );
zorglub's avatar
zorglub committed
96

97
98
99
100
101
102
103
104
105
    QPushButton *okButton = new QPushButton( qtr( "&Stream" ) );
    QPushButton *cancelButton = new QPushButton( qtr( "&Cancel" ) );

    okButton->setDefault( true );
    ui.acceptButtonBox->addButton( okButton, QDialogButtonBox::AcceptRole );
    ui.acceptButtonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );

    BUTTONACT( okButton, ok());
    BUTTONACT( cancelButton, cancel());
106
107

    if( _transcode_only ) toggleSout();
zorglub's avatar
zorglub committed
108
109
110
111
112
113
114
115
116
}

void SoutDialog::fileBrowse()
{
    QString f = QFileDialog::getOpenFileName( this, qtr("Save file"), "", "" );
    ui.fileEdit->setText( f );
    updateMRL();
}

117
118
119
120
121
122
123
124
125
126
127
128
void SoutDialog::toggleSout()
{
#define TGV(x) { \
     if( (x->isHidden()) )  \
        x->show();          \
     else  x->hide();\
}
 TGV( ui.HTTPOutput ) ; TGV( ui.UDPOutput ) ; TGV( ui.MMSHOutput ) ;
 TGV( ui.HTTPEdit ) ; TGV( ui.UDPEdit ) ; TGV( ui.MMSHEdit ) ;
 TGV( ui.HTTPLabel ) ; TGV( ui.UDPLabel ) ; TGV( ui.MMSHLabel ) ;
 TGV( ui.HTTPPortLabel ) ; TGV( ui.UDPPortLabel ) ; TGV( ui.MMSHPortLabel ) ;
 TGV( ui.HTTPPort ) ; TGV( ui.UDPPort ) ; TGV( ui.MMSHPort ) ;
129
 updateGeometry();
130
131
}

zorglub's avatar
zorglub committed
132
133
void SoutDialog::ok()
{
zorglub's avatar
zorglub committed
134
135
    mrl = ui.mrlEdit->text();
    accept();
zorglub's avatar
zorglub committed
136
137
138
}
void SoutDialog::cancel()
{
zorglub's avatar
zorglub committed
139
140
    mrl = ui.mrlEdit->text();
    reject();
zorglub's avatar
zorglub committed
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
}

void SoutDialog::updateMRL()
{
    sout_gui_descr_t pd;
    memset( &pd, 0, sizeof( sout_gui_descr_t ) );

    /* Output */
    pd.b_dump = ui.rawInput->isChecked();
    if( pd.b_dump ) goto end;

    pd.b_local = ui.localOutput->isChecked();
    pd.b_file = ui.fileOutput->isChecked();
    pd.b_http = ui.HTTPOutput->isChecked();
    pd.b_mms = ui.MMSHOutput->isChecked();
    pd.b_udp = ui.UDPOutput->isChecked();

    pd.psz_file = ui.fileOutput->isChecked() ?
                            strdup(qtu( ui.fileEdit->text() ) ): NULL;
    pd.psz_http = ui.HTTPOutput->isChecked() ?
                            strdup(qtu( ui.HTTPEdit->text() ) ) : NULL;
    pd.psz_mms = ui.MMSHOutput->isChecked() ?
                            strdup(qtu( ui.MMSHEdit->text() ) ): NULL;
    pd.psz_udp = ui.UDPOutput->isChecked() ?
                            strdup( qtu( ui.UDPEdit->text() ) ): NULL;

    pd.i_http = ui.HTTPPort->value();
    pd.i_mms = ui.MMSHPort->value();
    pd.i_udp = ui.UDPPort->value();

    /* Mux */
#define SMUX(x, txt) if( ui.x##Mux->isChecked() ) pd.psz_mux = strdup(txt);
    SMUX( PS, "ps" );
    SMUX( TS, "ts" );
    SMUX( MPEG1, "mpeg" );
    SMUX( Ogg, "ogg" );
    SMUX( ASF, "asf" );
    SMUX( MP4, "mp4" );
    SMUX( MOV, "mov" );
    SMUX( WAV, "wav" );
    SMUX( RAW, "raw" );
182
    SMUX( FLV, "flv" );
zorglub's avatar
zorglub committed
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208

    /* Transcode */
    pd.b_soverlay = ui.sOverlay->isChecked();
    pd.i_vb = ui.vBitrate->value();
    pd.i_ab = ui.aBitrate->value();
    pd.i_channels = ui.aChannels->value();
    pd.f_scale = atof( qta( ui.vScale->currentText() ) );

    pd.psz_vcodec = ui.transcodeVideo->isChecked() ?
                     strdup( qtu( ui.vCodec->itemData(
                            ui.vCodec->currentIndex() ). toString() ) ) : NULL;
    pd.psz_acodec = ui.transcodeAudio->isChecked() ?
                     strdup( qtu( ui.aCodec->itemData(
                            ui.aCodec->currentIndex() ).toString() ) ) : NULL;
    pd.psz_scodec = ui.transcodeSubs->isChecked() ?
                     strdup( qtu( ui.sCodec->itemData(
                            ui.sCodec->currentIndex() ).toString() ) ) : NULL;
    pd.b_sap = ui.sap->isChecked();
    pd.b_all_es = ui.soutAll->isChecked();
    pd.psz_name = qtu( ui.sapName->text() );
    pd.psz_group = qtu( ui.sapGroup->text() );
    pd.i_ttl = ui.ttl->value() ;
end:
    sout_chain_t* p_chain = streaming_ChainNew();
    streaming_GuiDescToChain( VLC_OBJECT(p_intf), p_chain, &pd );
    char *psz_mrl = streaming_ChainToPsz( p_chain );
zorglub's avatar
zorglub committed
209

zorglub's avatar
zorglub committed
210
211
212
213
214
    ui.mrlEdit->setText( qfu( strdup(psz_mrl) ) );
    free( pd.psz_acodec ); free( pd.psz_vcodec ); free( pd.psz_scodec );
    free( pd.psz_file );free( pd.psz_http ); free( pd.psz_mms );
    free( pd.psz_udp ); free( pd.psz_mux );
}