sout.cpp 7.83 KB
Newer Older
zorglub's avatar
zorglub committed
1
/*****************************************************************************
2
 * sout.cpp : Stream output dialog ( old-style )
zorglub's avatar
zorglub committed
3
 ****************************************************************************
4
 * Copyright (C) 2007-2009 the VideoLAN team
5
 *
6
 * $Id$
zorglub's avatar
zorglub committed
7
8
 *
 * Authors: Clément Stenac <zorglub@videolan.org>
9
 *          Jean-Baptiste Kempf <jb@videolan.org>
zorglub's avatar
zorglub committed
10
11
12
13
 *
 * 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
14
 * ( at your option ) any later version.
zorglub's avatar
zorglub committed
15
16
17
18
19
20
21
22
23
24
 *
 * 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.
 *****************************************************************************/
25

26
27
28
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
zorglub's avatar
zorglub committed
29
30

#include "dialogs/sout.hpp"
31
#include "util/qt_dirs.hpp"
32
#include "components/sout/sout_widgets.hpp"
zorglub's avatar
zorglub committed
33

34
#include <QString>
zorglub's avatar
zorglub committed
35
#include <QFileDialog>
36
#include <QToolButton>
37
#include <assert.h>
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
38

39
SoutDialog::SoutDialog( QWidget *parent, intf_thread_t *_p_intf, const QString& inputMRL )
40
           : QVLCDialog( parent,  _p_intf )
zorglub's avatar
zorglub committed
41
{
42
    setWindowTitle( qtr( "Stream Output" ) );
43

zorglub's avatar
zorglub committed
44
    /* UI stuff */
45
    ui.setupUi( this );
46
    ui.inputBox->setMRL( inputMRL );
Eric Lassauge's avatar
Eric Lassauge committed
47
    ui.helpEdit->setPlainText( qtr("This dialog will allow you to stream or "
48
49
50
51
            "convert your media for use locally, on your private network, "
            "or on the Internet.\n"
            "You should start by checking that source matches what you want "
            "your input to be and then press the \"Next\" "
Eric Lassauge's avatar
Eric Lassauge committed
52
            "button to continue.\n") );
53

54
55
56
    ui.mrlEdit->setToolTip ( qtr( "Stream output string.\n"
                "This is automatically generated "
                 "when you change the above settings,\n"
57
                 "but you can change it manually." ) ) ;
58

59
60
61
62
63
64
65
66
#if 0
    /* This needs Qt4.5 to be cool */
    ui.destTab->setTabsClosable( true );
#else
    closeTabButton = new QToolButton( this );
    ui.destTab->setCornerWidget( closeTabButton );
    closeTabButton->hide();
    closeTabButton->setAutoRaise( true );
67
    closeTabButton->setIcon( QIcon( ":/toolbar/clear" ) );
68
69
70
    BUTTONACT( closeTabButton, closeTab() );
#endif
    CONNECT( ui.destTab, currentChanged( int ), this, tabChanged( int ) );
71
    ui.destTab->setTabIcon( 0, QIcon( ":/buttons/playlist/playlist_add" ) );
72
73
74
75
76
77
78
79
80
81

    ui.destBox->addItem( qtr( "File" ) );
    ui.destBox->addItem( "HTTP" );
    ui.destBox->addItem( "MMS" );
    ui.destBox->addItem( "UDP" );
    ui.destBox->addItem( "RTP" );
    ui.destBox->addItem( "IceCast" );

    BUTTONACT( ui.addButton, addDest() );

82
//     /* Connect everything to the updateMRL function */
ivoire's avatar
ivoire committed
83
84
85
86
#define CB( x ) CONNECT( ui.x, toggled( 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() );
87

88
    /* Misc */
89
    CB( soutAll ); CB( soutKeep );  CS( ttl ); CT( sapName ); CT( sapGroup );
90
91
    CB( localOutput );
    CONNECT( ui.profileSelect, optionsChanged(), this, updateMRL() );
zorglub's avatar
zorglub committed
92

93
    okButton = new QPushButton( qtr( "&Stream" ) );
94
95
96
97
98
99
    QPushButton *cancelButton = new QPushButton( qtr( "&Cancel" ) );

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

100
101
    BUTTONACT( okButton, ok() );
    BUTTONACT( cancelButton, cancel() );
102

103
104
    BUTTONACT( ui.nextButton, next() );
    BUTTONACT( ui.nextButton2, next() );
105
106
    BUTTONACT( ui.prevButton, prev() );
    BUTTONACT( ui.prevButton2, prev() );
ivoire's avatar
ivoire committed
107
108
109
110
111

#undef CC
#undef CS
#undef CT
#undef CB
112
113
114
115
116
}

void SoutDialog::next()
{
    ui.toolBox->setCurrentIndex( ui.toolBox->currentIndex() + 1 );
117
}
zorglub's avatar
zorglub committed
118

119
120
121
122
123
void SoutDialog::prev()
{
    ui.toolBox->setCurrentIndex( ui.toolBox->currentIndex() - 1 );
}

124
void SoutDialog::tabChanged( int i )
125
{
126
    closeTabButton->setVisible( (i != 0) );
127
128
}

129
void SoutDialog::closeTab()
130
{
131
132
    int i = ui.destTab->currentIndex();
    if( i == 0 ) return;
133

134
135
136
    QWidget *temp = ui.destTab->currentWidget();
    ui.destTab->removeTab( i );
    delete temp;
137
    updateMRL();
138
139
}

140
void SoutDialog::addDest( )
141
{
142
143
    int index;
    switch( ui.destBox->currentIndex() )
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
182
183
184
185
        case 0:
            {
                FileDestBox *fdb = new FileDestBox( this );
                index = ui.destTab->addTab( fdb, "File" );
                CONNECT( fdb, mrlUpdated(), this, updateMRL() );
            }
            break;
        case 1:
            {
                HTTPDestBox *hdb = new HTTPDestBox( this );
                index = ui.destTab->addTab( hdb, "HTTP" );
                CONNECT( hdb, mrlUpdated(), this, updateMRL() );
            }
            break;
        case 2:
            {
                MMSHDestBox *mdb = new MMSHDestBox( this );
                index = ui.destTab->addTab( mdb, "MMSH" );
                CONNECT( mdb, mrlUpdated(), this, updateMRL() );
            }
            break;
        case 3:
            {
                UDPDestBox *udb = new UDPDestBox( this );
                index = ui.destTab->addTab( udb, "UDP" );
                CONNECT( udb, mrlUpdated(), this, updateMRL() );
            }
            break;
        case 4:
            {
                RTPDestBox *rdb = new RTPDestBox( this );
                index = ui.destTab->addTab( rdb, "RTP" );
                CONNECT( rdb, mrlUpdated(), this, updateMRL() );
            }
            break;
        case 5:
            {
                ICEDestBox *idb = new ICEDestBox( this );
                index = ui.destTab->addTab( idb, "Icecast" );
                CONNECT( idb, mrlUpdated(), this, updateMRL() );
            }
186
187
188
            break;
        default:
            assert(0);
189
    }
190
191
192

    ui.destTab->setCurrentIndex( index );
    updateMRL();
193
194
}

zorglub's avatar
zorglub committed
195
196
void SoutDialog::ok()
{
197
    mrl = ui.mrlEdit->toPlainText();
zorglub's avatar
zorglub committed
198
    accept();
zorglub's avatar
zorglub committed
199
}
200

zorglub's avatar
zorglub committed
201
202
void SoutDialog::cancel()
{
203
    mrl.clear();
zorglub's avatar
zorglub committed
204
    reject();
zorglub's avatar
zorglub committed
205
206
207
208
}

void SoutDialog::updateMRL()
{
209
    QString qs_mux = ui.profileSelect->getMux();
210

211
    SoutMrl smrl( ":sout=#" );
212
    if( !ui.profileSelect->getTranscode().isEmpty() && ui.transcodeBox->isChecked() )
213
214
215
216
    {
        smrl.begin( ui.profileSelect->getTranscode() );
        smrl.end();
    }
217

218
    bool multi = false;
219

220
221
222
    if( ui.destTab->count() >= 3 ||
        ( ui.destTab->count() == 2 && ui.localOutput->isChecked() ) )
        multi = true;
223

224
225
    if( multi )
        smrl.begin( "duplicate" );
226

227
228
229
230
    for( int i = 1; i < ui.destTab->count(); i++ )
    {
        VirtualDestBox *vdb = qobject_cast<VirtualDestBox *>(ui.destTab->widget( i ));
        QString tempMRL = vdb->getMRL( qs_mux );
231

232
233
234
235
        if( tempMRL.isEmpty() ) continue;
        if( multi )
            smrl.option( "dst", tempMRL );
        else
236
        {
237
238
            smrl.begin( tempMRL);
            smrl.end();
239
        }
240
241
242
243
244
245
    }
    if( ui.localOutput->isChecked() )
    {
        if( multi )
            smrl.option( "dst", "display" );
        else
246
        {
247
248
            smrl.begin( "display" );
            smrl.end();
249
        }
250
    }
251

252
    if ( multi ) smrl.end();
253

254
    mrl = smrl.getMrl();
255

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
256
    /* FIXME, deal with SAP
257
258
259
    sout.b_sap = ui.sap->isChecked();
    sout.psz_group = strdup( qtu( ui.sapGroup->text() ) );
    sout.psz_name = strdup( qtu( ui.sapName->text() ) ); */
260

261
    if( ui.soutAll->isChecked() )  mrl.append( " :sout-all" );
262

263
    if( ui.soutKeep->isChecked() ) mrl.append( " :sout-keep" );
264

265
    ui.mrlEdit->setPlainText( mrl );
266
}
267