📄 sout.cpp
字号:
/***************************************************************************** * sout.cpp : Stream output dialog ( old-style ) **************************************************************************** * Copyright (C) 2007-2008 the VideoLAN team * Copyright (C) 2007 Société des arts technologiques * Copyright (C) 2007 Savoir-faire Linux * * $Id: 699bd48f8f838f7cad9f30f8d32b305e0f890a7b $ * * Authors: Clément Stenac <zorglub@videolan.org> * Jean-Baptiste Kempf <jb@videolan.org> * Jean-François Massol <jf.massol -at- gmail.com> * Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com> * * 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. *****************************************************************************/#ifdef HAVE_CONFIG_H# include "config.h"#endif#include "dialogs/sout.hpp"#include <QString>#include <QFileDialog>struct streaming_account_t{ char *psz_username; /*< username of account */ char *psz_password; /*< password of account */};struct sout_gui_descr_t{ /* Access types */ bool b_local; /*< local access module */ bool b_file; /*< file access module */ bool b_http; /*< http access module */ bool b_mms; /*< mms access module */ bool b_rtp; /*< rtp access module */ bool b_udp; /*< udp access module */ bool b_dump; /*< dump access module */ bool b_icecast; /*< icecast access module */ char *psz_file; /*< filename */ char *psz_http; /*< HTTP servername or ipaddress */ char *psz_mms; /*< MMS servername or ipaddress */ char *psz_rtp; /*< RTP servername or ipaddress */ char *psz_udp; /*< UDP servername or ipaddress */ char *psz_icecast; /*< Icecast servername or ipaddress*/ int32_t i_http; /*< http port number */ int32_t i_mms; /*< mms port number */ int32_t i_rtp; /*< rtp port number */ int32_t i_rtp_audio; /*< rtp port number */ int32_t i_rtp_video; /*< rtp port number */ int32_t i_udp; /*< udp port number */ int32_t i_icecast; /*< icecast port number */ /* Mux */ char *psz_mux; /*< name of muxer to use in streaming */ /* Transcode */ bool b_soverlay; /*< enable burning overlay in the video */ char *psz_vcodec; /*< video codec to use in transcoding */ char *psz_acodec; /*< audio codec to use in transcoding */ char *psz_scodec; /*< subtitle codec to use in transcoding */ int32_t i_vb; /*< video bitrate to use in transcoding */ int32_t i_ab; /*< audio bitrate to use in transcoding */ int32_t i_channels; /*< number of audio channels to use in transcoding */ float f_scale; /*< scaling factor to use in transcoding */ /* Misc */ bool b_sap; /*< send SAP announcement */ bool b_all_es;/*< send all elementary streams from source stream */ bool b_sout_keep; char *psz_group; /*< SAP Group name */ char *psz_name; /*< SAP name */ int32_t i_ttl; /*< Time To Live (TTL) for network traversal */ /* Icecast */ char *psz_icecast_mountpoint;/*< path to Icecast mountpoint */ struct streaming_account_t sa_icecast; /*< Icecast account information */};SoutDialog* SoutDialog::instance = NULL;SoutDialog::SoutDialog( QWidget *parent, intf_thread_t *_p_intf, bool _transcode_only ) : QVLCDialog( parent, _p_intf ){ setWindowTitle( qtr( "Stream Output" ) ); b_transcode_only = _transcode_only; /* UI stuff */ ui.setupUi( this ); changeUDPandRTPmess( false );/* ADD HERE for new profiles */#define ADD_PROFILE( name, shortname ) ui.profileBox->addItem( qtr( name ), QVariant( QString( shortname ) ) ); ADD_PROFILE( "Custom" , "Custom" ) ADD_PROFILE( "Ogg / Theora", "theora" ) ADD_PROFILE( "Ogg / Vorbis", "vorbis" ) ADD_PROFILE( "MPEG-2", "mpeg2" ) ADD_PROFILE( "MP3", "mp3" ) ADD_PROFILE( "MPEG-4 audio AAC", "aac" ) ADD_PROFILE( "MPEG-4 / DivX", "mp4" ) ADD_PROFILE( "H264", "h264" ) ADD_PROFILE( "IPod (mp4/aac)", "IPod" ) ADD_PROFILE( "XBox", "XBox" ) ADD_PROFILE( "Windows (wmv/asf)", "Windows" ) ADD_PROFILE( "PSP", "PSP")#define ADD_VCODEC( name, fourcc ) ui.vCodecBox->addItem( name, QVariant( fourcc ) ); ADD_VCODEC( "MPEG-1", "mp1v" ) ADD_VCODEC( "MPEG-2", "mp2v" ) ADD_VCODEC( "MPEG-4", "mp4v" ) ADD_VCODEC( "DIVX 1" , "DIV1" ) ADD_VCODEC( "DIVX 2" , "DIV2" ) ADD_VCODEC( "DIVX 3" , "DIV3" ) 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, fourcc ) ui.aCodecBox->addItem( name, QVariant( fourcc ) ); ADD_ACODEC( "MPEG Audio", "mpga" ) ADD_ACODEC( "MP3", "mp3" ) ADD_ACODEC( "MPEG 4 Audio ( AAC )", "mp4a" ) ADD_ACODEC( "A52/AC-3", "a52" ) ADD_ACODEC( "Vorbis", "vorb" ) ADD_ACODEC( "Flac", "flac" ) ADD_ACODEC( "Speex", "spx" ) ADD_ACODEC( "WAV", "s16l" ) ADD_ACODEC( "WMA", "wma" )#define ADD_SCALING( factor ) ui.vScaleBox->addItem( factor ); ADD_SCALING( "1" ) ADD_SCALING( "0.25" ) ADD_SCALING( "0.5" ) ADD_SCALING( "0.75" ) ADD_SCALING( "1.25" ) ADD_SCALING( "1.5" ) ADD_SCALING( "1.75" ) ADD_SCALING( "2" ) 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." ) ) ;// /* Connect everything to the updateMRL function */ #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() ); /* Output */ CB( fileOutput ); CB( HTTPOutput ); CB( localOutput ); CB( RTPOutput ); CB( MMSHOutput ); CB( rawInput ); CB( UDPOutput ); CT( fileEdit ); CT( HTTPEdit ); CT( RTPEdit ); CT( MMSHEdit ); CT( UDPEdit ); CT( IcecastEdit ); CT( IcecastMountpointEdit ); CT( IcecastNamePassEdit ); CS( HTTPPort ); CS( RTPPort ); CS( RTPPort2 ); CS( MMSHPort ); CS( UDPPort ); /* Transcode */ CC( vCodecBox ); CC( subsCodecBox ); CC( aCodecBox ) ; CB( transcodeVideo ); CB( transcodeAudio ); CB( transcodeSubs ); /* CB( sOverlay ); */ CS( vBitrateSpin ); CS( aBitrateSpin ); CS( aChannelsSpin ); CC( vScaleBox ); /* Mux */ CB( PSMux ); CB( TSMux ); CB( MPEG1Mux ); CB( OggMux ); CB( ASFMux ); CB( MP4Mux ); CB( MOVMux ); CB( WAVMux ); CB( RAWMux ); CB( FLVMux ); /* Misc */ CB( soutAll ); CB( soutKeep ); CS( ttl ); CT( sapName ); CT( sapGroup ); CONNECT( ui.profileBox, activated( const QString & ), this, setOptions() ); CONNECT( ui.fileSelectButton, clicked() , this, fileBrowse() ); CONNECT( ui.transcodeVideo, toggled( bool ), this, setVTranscodeOptions( bool ) ); CONNECT( ui.transcodeAudio, toggled( bool ), this, setATranscodeOptions( bool ) ); CONNECT( ui.transcodeSubs, toggled( bool ), this, setSTranscodeOptions( bool ) ); CONNECT( ui.rawInput, toggled( bool ), this, setRawOptions( bool ) ); 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() ); CONNECT( ui.UDPOutput, toggled( bool ), this, changeUDPandRTPmess( bool ) ); CONNECT( ui.RTPOutput, clicked(bool), this, RTPtoggled( bool ) ); if( b_transcode_only ) toggleSout();}void SoutDialog::fileBrowse(){ QString fileName = QFileDialog::getSaveFileName( this, qtr( "Save file" ), "", qtr( "Containers (*.ps *.ts *.mpg *.ogg *.asf *.mp4 *.mov *.wav *.raw *.flv)" ) ); ui.fileEdit->setText( fileName ); updateMRL();}void SoutDialog::setVTranscodeOptions( bool b_trans ){ ui.vCodecLabel->setEnabled( b_trans ); ui.vCodecBox->setEnabled( b_trans ); ui.vBitrateLabel->setEnabled( b_trans ); ui.vBitrateSpin->setEnabled( b_trans ); ui.vScaleLabel->setEnabled( b_trans ); ui.vScaleBox->setEnabled( b_trans );}void SoutDialog::setATranscodeOptions( bool b_trans ){ ui.aCodecLabel->setEnabled( b_trans ); ui.aCodecBox->setEnabled( b_trans ); ui.aBitrateLabel->setEnabled( b_trans ); ui.aBitrateSpin->setEnabled( b_trans ); ui.aChannelsLabel->setEnabled( b_trans ); ui.aChannelsSpin->setEnabled( b_trans );}void SoutDialog::setSTranscodeOptions( bool b_trans ){ ui.subsCodecBox->setEnabled( b_trans ); ui.subsOverlay->setEnabled( b_trans );}void SoutDialog::setRawOptions( bool b_raw ){ ui.localOutput->setEnabled( !b_raw ); ui.HTTPOutput->setEnabled( !b_raw ); ui.MMSHOutput->setEnabled( !b_raw ); ui.UDPOutput->setEnabled( !b_raw ); ui.RTPOutput->setEnabled( !b_raw ); ui.IcecastOutput->setEnabled( !b_raw ); ui.UDPRTPLabel->setEnabled( !b_raw ); if( b_raw ) ui.tabWidget->setDisabled( true ); else setOptions();}void SoutDialog::setOptions(){ QString profileString = ui.profileBox->itemData( ui.profileBox->currentIndex() ).toString(); msg_Dbg( p_intf, "Profile Used: %s", qta( profileString )); int index;#define setProfile( muxName, hasVideo, vCodecName, hasAudio, aCodecName ) \ { \ ui.muxName ##Mux->setChecked( true ); \ \ ui.transcodeAudio->setChecked( hasAudio ); \ index = ui.aCodecBox->findData( aCodecName ); \ if( index >= 0 ) ui.aCodecBox->setCurrentIndex( index ); \ \ ui.transcodeVideo->setChecked( hasVideo ); \ index = ui.vCodecBox->findData( vCodecName ); \ if( index >=0 ) ui.vCodecBox->setCurrentIndex( index ); \ } /* ADD HERE the profiles you want and need */ if( profileString == "IPod" ) setProfile( MP4, true, "mp4v", true, "mp4a" ) else if( profileString == "theora" ) setProfile( Ogg, true, "theo", true, "vorb" ) else if( profileString == "vorbis" ) setProfile( Ogg, false, "", true, "vorb" ) else if( profileString == "mpeg2" ) setProfile( TS, true, "mp2v", true, "mpga" ) else if( profileString == "mp3" ) setProfile( RAW, false, "", true, "mp3" ) else if( profileString == "aac" ) setProfile( MP4, false, "", true, "mp4a" ) else if( profileString == "mp4" ) setProfile( MP4, true, "mp4v", true, "mp4a" ) else if( profileString == "h264" ) setProfile( TS, true, "h264", true, "mp4a" ) else if( profileString == "XBox" ) setProfile( ASF, true, "WMV2", true, "wma" ) else if( profileString == "Windows" ) setProfile( ASF, true, "WMV2", true, "wma" ) else if( profileString == "PSP" ) setProfile( Ogg, true, "DIV3", true, "vorb" ) /* If the profile is not a custom one, then disable the tabWidget */ if ( profileString == "Custom" ) ui.tabWidget->setEnabled( true ); else ui.tabWidget->setDisabled( true ); /* Update the MRL !! */ updateMRL();}void SoutDialog::toggleSout(){ //Toggle all the streaming options.#define HIDEORSHOW(x) if( b_transcode_only ) x->hide(); else x->show(); HIDEORSHOW( ui.HTTPOutput ) ; HIDEORSHOW( ui.RTPOutput ) ; HIDEORSHOW( ui.MMSHOutput ) ; HIDEORSHOW( ui.UDPOutput ) ; HIDEORSHOW( ui.HTTPEdit ) ; HIDEORSHOW( ui.RTPEdit ) ; HIDEORSHOW( ui.MMSHEdit ) ; HIDEORSHOW( ui.UDPEdit ) ; HIDEORSHOW( ui.HTTPLabel ) ; HIDEORSHOW( ui.RTPLabel ) ; HIDEORSHOW( ui.MMSHLabel ) ; HIDEORSHOW( ui.UDPLabel ) ; HIDEORSHOW( ui.HTTPPortLabel ) ; HIDEORSHOW( ui.RTPPortLabel ) ; HIDEORSHOW( ui.MMSHPortLabel ) ; HIDEORSHOW( ui.UDPPortLabel ) HIDEORSHOW( ui.HTTPPort ) ; HIDEORSHOW( ui.RTPPort ) ; HIDEORSHOW( ui.MMSHPort ) ; HIDEORSHOW( ui.UDPPort ) ; HIDEORSHOW( ui.RTPPortLabel2 ); HIDEORSHOW( ui.RTPPort2 ); HIDEORSHOW( ui.UDPRTPLabel ) HIDEORSHOW( ui.sap ); HIDEORSHOW( ui.sapName ); HIDEORSHOW( ui.sapGroup ); HIDEORSHOW( ui.sapGroupLabel ); HIDEORSHOW( ui.ttlLabel ); HIDEORSHOW( ui.ttl ); HIDEORSHOW( ui.soutKeep ); HIDEORSHOW( ui.IcecastOutput ); HIDEORSHOW( ui.IcecastEdit ); HIDEORSHOW( ui.IcecastNamePassEdit ); HIDEORSHOW( ui.IcecastMountpointEdit ); HIDEORSHOW( ui.IcecastPort ); HIDEORSHOW( ui.IcecastLabel ); HIDEORSHOW( ui.IcecastPortLabel ); HIDEORSHOW( ui.IcecastMountpointLabel ); HIDEORSHOW( ui.IcecastNameLabel );#undef HIDEORSHOW if( b_transcode_only ) okButton->setText( "&Save" );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -