]> git.sesse.net Git - vlc/blob - modules/gui/qt4/dialogs/sout.cpp
Fix some Sout dialog resizing issues.
[vlc] / modules / gui / qt4 / dialogs / sout.cpp
1 /*****************************************************************************
2  * sout.cpp : Stream output dialog ( old-style )
3  ****************************************************************************
4  * Copyright (C) 2007-2008 the VideoLAN team
5  * Copyright (C) 2007 Société des arts technologiques
6  * Copyright (C) 2007 Savoir-faire Linux
7  *
8  * $Id$
9  *
10  * Authors: Clément Stenac <zorglub@videolan.org>
11  *          Jean-Baptiste Kempf <jb@videolan.org>
12  *          Jean-François Massol <jf.massol -at- gmail.com>
13  *          Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com>
14  *
15  * This program is free software; you can redistribute it and/or modify
16  * it under the terms of the GNU General Public License as published by
17  * the Free Software Foundation; either version 2 of the License, or
18  * ( at your option ) any later version.
19  *
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with this program; if not, write to the Free Software
27  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
28  *****************************************************************************/
29
30 #ifdef HAVE_CONFIG_H
31 # include "config.h"
32 #endif
33
34 #include "dialogs/sout.hpp"
35
36 #include <QString>
37 #include <QFileDialog>
38
39 struct streaming_account_t
40 {
41     char *psz_username; /*< username of account */
42     char *psz_password; /*< password of account */
43 };
44
45 struct sout_gui_descr_t
46 {
47     /* Access types */
48     bool b_local;   /*< local access module */
49     bool b_file;    /*< file access module */
50     bool b_http;    /*< http access module */
51     bool b_mms;     /*< mms access module */
52     bool b_rtp;     /*< rtp access module */
53     bool b_udp;     /*< udp access module */
54     bool b_dump;    /*< dump access module */
55     bool b_icecast; /*< icecast access module */
56
57     char *psz_file;     /*< filename */
58     char *psz_http;     /*< HTTP servername or ipaddress */
59     char *psz_mms;      /*< MMS servername or ipaddress */
60     char *psz_rtp;      /*< RTP servername or ipaddress */
61     char *psz_udp;      /*< UDP servername or ipaddress */
62     char *psz_icecast;  /*< Icecast servername or ipaddress*/
63
64     int32_t i_http;     /*< http port number */
65     int32_t i_mms;      /*< mms port number */
66     int32_t i_rtp;      /*< rtp port number */
67     int32_t i_rtp_audio;      /*< rtp port number */
68     int32_t i_rtp_video;      /*< rtp port number */
69     int32_t i_udp;      /*< udp port number */
70     int32_t i_icecast;  /*< icecast port number */
71
72     /* Mux */
73     char *psz_mux;      /*< name of muxer to use in streaming */
74
75     /* Transcode */
76     bool b_soverlay; /*< enable burning overlay in the video */
77     char *psz_vcodec;   /*< video codec to use in transcoding */
78     char *psz_acodec;   /*< audio codec to use in transcoding */
79     char *psz_scodec;   /*< subtitle codec to use in transcoding */
80     int32_t i_vb;       /*< video bitrate to use in transcoding */
81     int32_t i_ab;       /*< audio bitrate to use in transcoding */
82     int32_t i_channels; /*< number of audio channels to use in transcoding */
83     float f_scale;      /*< scaling factor to use in transcoding */
84
85     /* Misc */
86     bool b_sap;   /*< send SAP announcement */
87     bool b_all_es;/*< send all elementary streams from source stream */
88     char *psz_group;    /*< SAP Group name */
89     char *psz_name;     /*< SAP name */
90     int32_t i_ttl;      /*< Time To Live (TTL) for network traversal */
91
92     /* Icecast */
93     char *psz_icecast_mountpoint;/*< path to Icecast mountpoint */
94     struct streaming_account_t sa_icecast;  /*< Icecast account information */
95 };
96
97 SoutDialog* SoutDialog::instance = NULL;
98
99 SoutDialog::SoutDialog( QWidget *parent, intf_thread_t *_p_intf,
100                      bool _transcode_only ) : QVLCDialog( parent,  _p_intf )
101 {
102     setWindowTitle( qtr( "Stream Output" ) );
103
104     b_transcode_only = _transcode_only;
105
106     /* UI stuff */
107     ui.setupUi( this );
108
109     changeUDPandRTPmess( false );
110
111 /* ADD HERE for new profiles */
112 #define ADD_PROFILE( name, shortname ) ui.profileBox->addItem( qtr( name ), QVariant( QString( shortname ) ) );
113     ADD_PROFILE( "Custom" , "Custom" )
114     ADD_PROFILE( "IPod (mp4/aac)", "IPod" )
115     ADD_PROFILE( "XBox", "XBox" )
116     ADD_PROFILE( "Windows (wmv/asf)", "Windows" )
117     ADD_PROFILE( "PSP", "PSP")
118     ADD_PROFILE( "GSM", "GSM" )
119
120 #define ADD_VCODEC( name, fourcc ) ui.vCodecBox->addItem( name, QVariant( fourcc ) );
121     ADD_VCODEC( "MPEG-1", "mp1v" )
122     ADD_VCODEC( "MPEG-2", "mp2v" )
123     ADD_VCODEC( "MPEG-4", "mp4v" )
124     ADD_VCODEC( "DIVX 1" , "DIV1" )
125     ADD_VCODEC( "DIVX 2" , "DIV2" )
126     ADD_VCODEC( "DIVX 3" , "DIV3" )
127     ADD_VCODEC( "H-263", "H263" )
128     ADD_VCODEC( "H-264", "h264" )
129     ADD_VCODEC( "WMV1", "WMV1" )
130     ADD_VCODEC( "WMV2" , "WMV2" )
131     ADD_VCODEC( "M-JPEG", "MJPG" )
132     ADD_VCODEC( "Theora", "theo" )
133
134 #define ADD_ACODEC( name, fourcc ) ui.aCodecBox->addItem( name, QVariant( fourcc ) );
135     ADD_ACODEC( "MPEG Audio", "mpga" )
136     ADD_ACODEC( "MP3", "mp3" )
137     ADD_ACODEC( "MPEG 4 Audio ( AAC )", "mp4a" )
138     ADD_ACODEC( "A52/AC-3", "a52" )
139     ADD_ACODEC( "Vorbis", "vorb" )
140     ADD_ACODEC( "Flac", "flac" )
141     ADD_ACODEC( "Speex", "spx" )
142     ADD_ACODEC( "WAV", "s16l" )
143     ADD_ACODEC( "WMA", "wma" )
144
145 #define ADD_SCALING( factor ) ui.vScaleBox->addItem( factor );
146     ADD_SCALING( "0.25" )
147     ADD_SCALING( "0.5" )
148     ADD_SCALING( "0.75" )
149     ADD_SCALING( "1" )
150     ADD_SCALING( "1.25" )
151     ADD_SCALING( "1.5" )
152     ADD_SCALING( "1.75" )
153     ADD_SCALING( "2" )
154
155     ui.mrlEdit->setToolTip ( qtr( "Stream output string.\n"
156                 "This is automatically generated "
157                  "when you change the above settings,\n"
158                  "but you can update it manually." ) ) ;
159
160 //     /* Connect everything to the updateMRL function */
161  #define CB( x ) CONNECT( ui.x, toggled( bool ), this, updateMRL() );
162  #define CT( x ) CONNECT( ui.x, textChanged( const QString ), this, updateMRL() );
163  #define CS( x ) CONNECT( ui.x, valueChanged( int ), this, updateMRL() );
164  #define CC( x ) CONNECT( ui.x, currentIndexChanged( int ), this, updateMRL() );
165     /* Output */
166     CB( fileOutput ); CB( HTTPOutput ); CB( localOutput );
167     CB( RTPOutput ); CB( MMSHOutput ); CB( rawInput ); CB( UDPOutput );
168     CT( fileEdit ); CT( HTTPEdit ); CT( RTPEdit ); CT( MMSHEdit ); CT( UDPEdit );
169     CT( IcecastEdit ); CT( IcecastMountpointEdit ); CT( IcecastNamePassEdit );
170     CS( HTTPPort ); CS( RTPPort ); CS( RTPPort2 ); CS( MMSHPort ); CS( UDPPort );
171     /* Transcode */
172     CC( vCodecBox ); CC( subsCodecBox ); CC( aCodecBox ) ;
173     CB( transcodeVideo ); CB( transcodeAudio ); CB( transcodeSubs );
174     /*   CB( sOverlay ); */
175     CS( vBitrateSpin ); CS( aBitrateSpin ); CS( aChannelsSpin ); CC( vScaleBox );
176     /* Mux */
177     CB( PSMux ); CB( TSMux ); CB( MPEG1Mux ); CB( OggMux ); CB( ASFMux );
178     CB( MP4Mux ); CB( MOVMux ); CB( WAVMux ); CB( RAWMux ); CB( FLVMux );
179     /* Misc */
180     CB( soutAll ); CS( ttl ); CT( sapName ); CT( sapGroup );
181
182     CONNECT( ui.profileBox, activated( const QString & ), this, setOptions() );
183     CONNECT( ui.fileSelectButton, clicked() , this, fileBrowse()  );
184     CONNECT( ui.transcodeVideo, toggled( bool ),
185             this, setVTranscodeOptions( bool ) );
186     CONNECT( ui.transcodeAudio, toggled( bool ),
187             this, setATranscodeOptions( bool ) );
188     CONNECT( ui.transcodeSubs, toggled( bool ),
189             this, setSTranscodeOptions( bool ) );
190     CONNECT( ui.rawInput, toggled( bool ), this, setRawOptions( bool ) );
191
192     okButton = new QPushButton( qtr( "&Stream" ) );
193     QPushButton *cancelButton = new QPushButton( qtr( "&Cancel" ) );
194
195     okButton->setDefault( true );
196     ui.acceptButtonBox->addButton( okButton, QDialogButtonBox::AcceptRole );
197     ui.acceptButtonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
198
199     BUTTONACT( okButton, ok() );
200     BUTTONACT( cancelButton, cancel() );
201
202     CONNECT( ui.UDPOutput, toggled( bool ), this, changeUDPandRTPmess( bool ) );
203     CONNECT( ui.RTPOutput, clicked(bool), this, RTPtoggled( bool ) );
204
205     if( b_transcode_only ) toggleSout();
206 }
207
208 void SoutDialog::fileBrowse()
209 {
210     QString fileName = QFileDialog::getSaveFileName( this, qtr( "Save file" ), "",
211         qtr( "Containers (*.ps *.ts *.mpg *.ogg *.asf *.mp4 *.mov *.wav *.raw *.flv)" ) );
212     ui.fileEdit->setText( fileName );
213     updateMRL();
214 }
215
216 void SoutDialog::setVTranscodeOptions( bool b_trans )
217 {
218     ui.vCodecLabel->setEnabled( b_trans );
219     ui.vCodecBox->setEnabled( b_trans );
220     ui.vBitrateLabel->setEnabled( b_trans );
221     ui.vBitrateSpin->setEnabled( b_trans );
222     ui.vScaleLabel->setEnabled( b_trans );
223     ui.vScaleBox->setEnabled( b_trans );
224 }
225
226 void SoutDialog::setATranscodeOptions( bool b_trans )
227 {
228     ui.aCodecLabel->setEnabled( b_trans );
229     ui.aCodecBox->setEnabled( b_trans );
230     ui.aBitrateLabel->setEnabled( b_trans );
231     ui.aBitrateSpin->setEnabled( b_trans );
232     ui.aChannelsLabel->setEnabled( b_trans );
233     ui.aChannelsSpin->setEnabled( b_trans );
234 }
235
236 void SoutDialog::setSTranscodeOptions( bool b_trans )
237 {
238     ui.subsCodecBox->setEnabled( b_trans );
239     ui.subsOverlay->setEnabled( b_trans );
240 }
241
242 void SoutDialog::setRawOptions( bool b_raw )
243 {
244     if( b_raw )
245         ui.tabWidget->setDisabled( true );
246     else
247         SoutDialog::setOptions();
248 }
249
250 void SoutDialog::setOptions()
251 {
252     QString profileString =
253         ui.profileBox->itemData( ui.profileBox->currentIndex() ).toString();
254     msg_Dbg( p_intf, "Profile Used: %s",  qta( profileString ));
255     int index;
256
257 #define setProfile( muxName, hasVideo, vCodecName, hasAudio, aCodecName ) \
258     { \
259         ui.muxName ##Mux->setChecked( true ); \
260         \
261         ui.transcodeAudio->setChecked( hasAudio ); \
262         index = ui.aCodecBox->findText( vCodecName );  \
263         if( index >= 0 ) ui.aCodecBox->setCurrentIndex( index ); \
264         \
265         ui.transcodeVideo->setChecked( hasVideo ); \
266         index = ui.aCodecBox->findText( vCodecName );  \
267         if( index >=0 ) ui.vCodecBox->setCurrentIndex( index ); \
268     }
269
270     /* ADD HERE the profiles you want and need */
271     /* FIXME */
272     if( profileString == "IPod" ) setProfile( MP4, true, "mp4a", true, "mp4v" )
273     else if( profileString == "XBox" ) setProfile( ASF, true, "wma", true, "WMV2" )
274
275         /* If the profile is not a custom one, then disable the tabWidget */
276         if ( profileString == "Custom" )
277             ui.tabWidget->setEnabled( true );
278         else
279             ui.tabWidget->setDisabled( true );
280
281     /* Update the MRL !! */
282     updateMRL();
283 }
284
285 void SoutDialog::toggleSout()
286 {
287     //Toggle all the streaming options.
288 #define HIDEORSHOW(x) if( b_transcode_only ) x->hide(); else x->show();
289     HIDEORSHOW( ui.HTTPOutput ) ; HIDEORSHOW( ui.RTPOutput ) ; HIDEORSHOW( ui.MMSHOutput ) ; HIDEORSHOW( ui.UDPOutput ) ;
290     HIDEORSHOW( ui.HTTPEdit ) ; HIDEORSHOW( ui.RTPEdit ) ; HIDEORSHOW( ui.MMSHEdit ) ; HIDEORSHOW( ui.UDPEdit ) ;
291     HIDEORSHOW( ui.HTTPLabel ) ; HIDEORSHOW( ui.RTPLabel ) ; HIDEORSHOW( ui.MMSHLabel ) ; HIDEORSHOW( ui.UDPLabel ) ;
292     HIDEORSHOW( ui.HTTPPortLabel ) ; HIDEORSHOW( ui.RTPPortLabel ) ; HIDEORSHOW( ui.MMSHPortLabel ) ; HIDEORSHOW( ui.UDPPortLabel )
293     HIDEORSHOW( ui.HTTPPort ) ; HIDEORSHOW( ui.RTPPort ) ; HIDEORSHOW( ui.MMSHPort ) ; HIDEORSHOW( ui.UDPPort ) ; HIDEORSHOW( ui.RTPPortLabel2 ); HIDEORSHOW( ui.RTPPort2 ); HIDEORSHOW( ui.UDPRTPLabel )
294
295     HIDEORSHOW( ui.sap ); HIDEORSHOW( ui.sapName );
296     HIDEORSHOW( ui.sapGroup ); HIDEORSHOW( ui.sapGroupLabel );
297     HIDEORSHOW( ui.ttlLabel ); HIDEORSHOW( ui.ttl );
298
299     HIDEORSHOW( ui.IcecastOutput ); HIDEORSHOW( ui.IcecastEdit );
300     HIDEORSHOW( ui.IcecastNamePassEdit ); HIDEORSHOW( ui.IcecastMountpointEdit );
301     HIDEORSHOW( ui.IcecastPort ); HIDEORSHOW( ui.IcecastLabel );
302     HIDEORSHOW( ui.IcecastPortLabel );
303     HIDEORSHOW( ui.IcecastMountpointLabel ); HIDEORSHOW( ui.IcecastNameLabel );
304 #undef HIDEORSHOW
305
306     if( b_transcode_only ) okButton->setText( "&Save" );
307     else okButton->setText( "&Stream" );
308
309     setMinimumHeight( 500 );
310     resize( width(), sizeHint().height() );
311 }
312
313 void SoutDialog::changeUDPandRTPmess( bool b_udp )
314 {
315     ui.RTPEdit->setVisible( !b_udp );
316     ui.RTPLabel->setVisible( !b_udp );
317     ui.RTPPort->setVisible( !b_udp );
318     ui.RTPPortLabel->setVisible( !b_udp );
319     ui.UDPEdit->setVisible( b_udp );
320     ui.UDPLabel->setVisible( b_udp );
321     ui.UDPPortLabel->setText( b_udp ? qtr( "Port:") : qtr( "Audio Port:" ) );
322     ui.RTPPort2->setVisible( !b_udp );
323     ui.RTPPortLabel2->setVisible( !b_udp );
324 }
325
326 void SoutDialog::RTPtoggled( bool b_en )
327 {
328     if( !b_en )
329     {
330         if( ui.RTPPort->value() == ui.UDPPort->value() )
331         {
332             ui.UDPPort->setValue( ui.UDPPort->value() + 1 );
333         }
334
335         while( ui.RTPPort2->value() == ui.UDPPort->value() ||
336                 ui.RTPPort2->value() == ui.RTPPort->value() )
337         {
338             ui.RTPPort2->setValue( ui.RTPPort2->value() + 1 );
339         }
340     }
341     ui.sap->setEnabled( b_en );
342     ui.RTPLabel->setEnabled( b_en );
343     ui.RTPEdit->setEnabled( b_en );
344     ui.UDPOutput->setEnabled( b_en );
345     ui.UDPPort->setEnabled( b_en );
346     ui.UDPPortLabel->setEnabled( b_en );
347     ui.RTPPort2->setEnabled( b_en );
348     ui.RTPPortLabel2->setEnabled( b_en );
349 }
350
351 void SoutDialog::ok()
352 {
353     mrl = ui.mrlEdit->text();
354     accept();
355 }
356
357 void SoutDialog::cancel()
358 {
359     mrl.clear();
360     reject();
361 }
362
363 void SoutDialog::updateMRL()
364 {
365     sout_gui_descr_t sout;
366     memset( &sout, 0, sizeof( sout_gui_descr_t ) );
367     unsigned int counter = 0;
368
369     sout.b_local = ui.localOutput->isChecked();
370     sout.b_file = ui.fileOutput->isChecked();
371     sout.b_http = ui.HTTPOutput->isChecked();
372     sout.b_mms = ui.MMSHOutput->isChecked();
373     sout.b_icecast = ui.IcecastOutput->isChecked();
374     sout.b_rtp = ui.RTPOutput->isChecked();
375     sout.b_udp = ui.UDPOutput->isChecked();
376     sout.b_sap = ui.sap->isChecked();
377     sout.b_all_es = ui.soutAll->isChecked();
378     sout.psz_vcodec = strdup( qtu( ui.vCodecBox->itemData( ui.vCodecBox->currentIndex() ).toString() ) );
379     sout.psz_acodec = strdup( qtu( ui.aCodecBox->itemData( ui.aCodecBox->currentIndex() ).toString() ) );
380     sout.psz_scodec = strdup( qtu( ui.subsCodecBox->itemData( ui.subsCodecBox->currentIndex() ).toString() ) );
381     sout.psz_file = strdup( qtu( ui.fileEdit->text() ) );
382     sout.psz_http = strdup( qtu( ui.HTTPEdit->text() ) );
383     sout.psz_mms = strdup( qtu( ui.MMSHEdit->text() ) );
384     sout.psz_rtp = strdup( qtu( ui.RTPEdit->text() ) );
385     sout.psz_udp = strdup( qtu( ui.UDPEdit->text() ) );
386     sout.psz_icecast = strdup( qtu( ui.IcecastEdit->text() ) );
387     sout.sa_icecast.psz_username = strdup( qtu( ui.IcecastNamePassEdit->text() ) );
388     sout.sa_icecast.psz_password = strdup( qtu( ui.IcecastNamePassEdit->text() ) );
389     sout.psz_icecast_mountpoint = strdup( qtu( ui.IcecastMountpointEdit->text() ) );
390     sout.i_http = ui.HTTPPort->value();
391     sout.i_mms = ui.MMSHPort->value();
392     sout.i_rtp = ui.RTPPort->value();
393     sout.i_rtp_audio = sout.i_udp = ui.UDPPort->value();
394     sout.i_rtp_video = ui.RTPPort2->value();
395     sout.i_icecast = ui.IcecastPort->value();
396     sout.i_ab = ui.aBitrateSpin->value();
397     sout.i_vb = ui.vBitrateSpin->value();
398     sout.i_channels = ui.aChannelsSpin->value();
399     sout.f_scale = atof( qta( ui.vScaleBox->currentText() ) );
400     sout.psz_group = strdup( qtu( ui.sapGroup->text() ) );
401     sout.psz_name = strdup( qtu( ui.sapName->text() ) );
402
403     if ( sout.b_local ) counter++ ;
404     if ( sout.b_file ) counter++ ;
405     if ( sout.b_http ) counter++ ;
406     if ( sout.b_mms ) counter++ ;
407     if ( sout.b_rtp ) counter++ ;
408     if ( sout.b_udp ) counter ++;
409     if ( sout.b_icecast ) counter ++;
410
411 #define SMUX( x, txt ) if( ui.x->isChecked() ) sout.psz_mux = strdup( txt );
412     SMUX( PSMux, "ps" );
413     SMUX( TSMux, "ts" );
414     SMUX( MPEG1Mux, "mpeg" );
415     SMUX( OggMux, "ogg" );
416     SMUX( ASFMux, "asf" );
417     SMUX( MP4Mux, "mp4" );
418     SMUX( MOVMux, "mov" );
419     SMUX( WAVMux, "wav" );
420     SMUX( RAWMux, "raw" );
421     SMUX( FLVMux, "flv" );
422     SMUX( MKVMux, "mkv" );
423
424     bool trans = false;
425     bool more = false;
426
427     if ( ui.transcodeVideo->isChecked() || ui.transcodeAudio->isChecked() )
428     {
429         if ( ui.transcodeVideo->isChecked() )
430         {
431             mrl = ":sout=#transcode{";
432             mrl.append( "vcodec=" );
433             mrl.append( sout.psz_vcodec );
434             mrl.append( "," );
435             mrl.append( "vb=" );
436             mrl.append( QString::number( sout.i_vb,10 ) );
437             mrl.append( "," );
438             mrl.append( "scale=" );
439             mrl.append( QString::number( sout.f_scale ) );
440             trans = true;
441         }
442
443         if ( ui.transcodeAudio->isChecked() )
444         {
445             if ( trans )
446             {
447                 mrl.append( "," );
448             }
449             else
450             {
451                 mrl = ":sout=#transcode{";
452             }
453             mrl.append( "acodec=" );
454             mrl.append( sout.psz_acodec );
455             mrl.append( "," );
456             mrl.append( "ab=" );
457             mrl.append( QString::number( sout.i_ab,10 ) );
458             mrl.append( "," );
459             mrl.append( "channels=" );
460             mrl.append( QString::number( sout.i_channels,10 ) );
461             trans = true;
462         }
463         mrl.append( "}" );
464     }
465
466     /* Protocol output */
467     if ( sout.b_local || sout.b_file || sout.b_http ||
468          sout.b_mms || sout.b_rtp || sout.b_udp || sout.b_icecast )
469     {
470
471 #define ISMORE() if ( more ) mrl.append( "," )
472 #define ATLEASTONE() if ( counter ) mrl.append( "dst=" )
473
474 #define CHECKMUX() \
475        if( sout.psz_mux ) \
476        {                  \
477          mrl.append( ",mux=");\
478          mrl.append( sout.psz_mux ); \
479        }
480
481         if ( trans )
482             mrl.append( ":" );
483         else
484             mrl = ":sout=#";
485
486         if ( counter )
487             mrl.append( "duplicate{" );
488
489         if ( sout.b_local )
490         {
491             ISMORE();
492             ATLEASTONE();
493             mrl.append( "display" );
494             more = true;
495         }
496
497         if ( sout.b_file )
498         {
499             ISMORE();
500             ATLEASTONE();
501             mrl.append( "std{access=file" );
502             CHECKMUX();
503             mrl.append( ",dst=" );
504             mrl.append( sout.psz_file );
505             mrl.append( "}" );
506             more = true;
507         }
508
509         if ( sout.b_http )
510         {
511             ISMORE();
512             ATLEASTONE();
513             mrl.append( "std{access=http" );
514             CHECKMUX();
515             mrl.append( ",dst=" );
516             mrl.append( sout.psz_http );
517             mrl.append( ":" );
518             mrl.append( QString::number( sout.i_http,10 ) );
519             mrl.append( "}" );
520             more = true;
521         }
522
523         if ( sout.b_mms )
524         {
525             ISMORE();
526             ATLEASTONE();
527             mrl.append( "std{access=mmsh" );
528             CHECKMUX();
529             mrl.append( ",dst=" );
530             mrl.append( sout.psz_mms );
531             mrl.append( ":" );
532             mrl.append( QString::number( sout.i_mms,10 ) );
533             mrl.append( "}" );
534             more = true;
535         }
536
537         if ( sout.b_rtp )
538         {
539             ISMORE();
540             ATLEASTONE();
541             if ( sout.b_udp )
542             {
543                 mrl.append( "std{access=udp" );
544                 CHECKMUX();
545                 mrl.append( ",dst=" );
546                 mrl.append( sout.psz_udp );
547                 mrl.append( ":" );
548                 mrl.append( QString::number( sout.i_udp,10 ) );
549             }
550             else
551             {
552                 mrl.append( "rtp{" );
553                 mrl.append( "dst=" );
554                 mrl.append( sout.psz_rtp );
555                 CHECKMUX();
556                 mrl.append( ",port=" );
557                 mrl.append( QString::number( sout.i_rtp,10 ) );
558                 if( !sout.psz_mux || strncmp( sout.psz_mux, "ts", 2 ) )
559                 {
560                     mrl.append( ",port-audio=" );
561                     mrl.append( QString::number( sout.i_rtp_audio, 10 ) );
562                     mrl.append( ",port-video=" );
563                     mrl.append( QString::number( sout.i_rtp_video, 10 ) );
564                 }
565             }
566
567             /* SAP */
568             if ( sout.b_sap )
569             {
570                 mrl.append( ",sap," );
571                 mrl.append( "group=\"" );
572                 mrl.append( sout.psz_group );
573                 mrl.append( "\"," );
574                 mrl.append( "name=\"" );
575                 mrl.append( sout.psz_name );
576                 mrl.append( "\"" );
577             }
578
579             mrl.append( "}" );
580             more = true;
581         }
582
583         if( sout.b_icecast )
584         {
585             ISMORE();
586             ATLEASTONE();
587             mrl.append( "std{access=shout,mux=ogg" );
588             mrl.append( ",dst=" );
589             mrl.append( sout.sa_icecast.psz_username );
590             mrl.append( "@" );
591             mrl.append( sout.psz_icecast );
592             mrl.append( ":" );
593             mrl.append( QString::number( sout.i_icecast, 10 ) );
594             mrl.append( "/" );
595             mrl.append( sout.psz_icecast_mountpoint );
596             mrl.append( "}" );
597             more = true;
598         }
599
600         if ( counter )
601         {
602             mrl.append( "}" );
603         }
604     }
605
606 #undef CHECKMUX
607
608     if ( sout.b_all_es )
609         mrl.append( ":sout-all" );
610
611     ui.mrlEdit->setText( mrl );
612     free( sout.psz_acodec ); free( sout.psz_vcodec ); free( sout.psz_scodec );
613     free( sout.psz_file );free( sout.psz_http ); free( sout.psz_mms );
614     free( sout.psz_rtp ); free( sout.psz_udp ); free( sout.psz_mux );
615     free( sout.psz_name ); free( sout.psz_group );
616     free( sout.psz_icecast ); free( sout.psz_icecast_mountpoint );
617     free( sout.sa_icecast.psz_password ); free( sout.sa_icecast.psz_username );
618 }