+/*****************************************************************************
+ * profile_selector.cpp : A small profile selector and editor
+ ****************************************************************************
+ * Copyright (C) 2009 the VideoLAN team
+ * $Id$
+ *
+ * Authors: Jean-Baptiste Kempf <jb@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 "components/sout/profile_selector.hpp"
+#include "components/sout/profiles.hpp"
#include "dialogs/sout.hpp"
#include <QHBoxLayout>
#include <QLabel>
#include <QMessageBox>
+#include <assert.h>
+
VLCProfileSelector::VLCProfileSelector( QWidget *_parent ): QWidget( _parent )
{
QHBoxLayout *layout = new QHBoxLayout( this );
layout->addWidget( deleteButton );
QToolButton *newButton = new QToolButton( this );
-// newButton->setIcon( QIcon( ":/clear" ) );
+ newButton->setIcon( QIcon( ":/new" ) );
newButton->setToolTip( qtr( "Create a new profile" ) );
layout->addWidget(newButton);
CONNECT( profileBox, activated( int ),
this, updateOptions( int ) );
+ updateOptions( 0 );
}
inline void VLCProfileSelector::fillProfilesCombo()
for( int i = 0; i < i_size; i++ )
{
settings.setArrayIndex( i );
+ if( settings.value( "Profile-Name" ).toString().isEmpty() ) continue;
profileBox->addItem( settings.value( "Profile-Name" ).toString(),
settings.value( "Profile-Value" ) );
}
+ if( i_size == 0 )
+ {
+ for( int i = 0; i < NB_PROFILE; i++ )
+ {
+ profileBox->addItem( video_profile_name_list[i],
+ video_profile_value_list[i] );
+ }
+ }
settings.endArray();
}
profileBox->itemData( profileBox->currentIndex() ).toString() );
}
-void VLCProfileSelector::editProfile( QString qs, QString value )
+void VLCProfileSelector::editProfile( const QString& qs, const QString& value )
{
+ /* Create the Profile Editor */
VLCProfileEditor *editor = new VLCProfileEditor( qs, value, this );
+ /* Show it */
if( QDialog::Accepted == editor->exec() )
{
+ /* New Profile */
if( qs.isEmpty() )
profileBox->addItem( editor->name, QVariant( editor->transcodeValue() ) );
+ /* Update old profile */
else
{
+ /* Look for the profile */
int i_profile = profileBox->findText( qs );
+ assert( i_profile != -1 );
profileBox->setItemText( i_profile, editor->name );
profileBox->setItemData( i_profile, QVariant( editor->transcodeValue() ) );
+ /* Force mrl recreation */
+ updateOptions( i_profile );
}
}
delete editor;
mux = options[0];
SoutMrl smrl;
- if( options[1].toInt() || options[2].toInt() )
+ if( options[1].toInt() || options[2].toInt() || options[3].toInt() )
{
smrl.begin( "transcode" );
if( options[1].toInt() )
{
smrl.option( "vcodec", options[4] );
- smrl.option( "vb", options[5].toInt() );
- smrl.option( "scale", options[6] );
- smrl.option( "fps", options[7] );
- smrl.option( "width", options[8].toInt() );
- smrl.option( "height", options[9].toInt() );
+ if( options[4] != "none" )
+ {
+ smrl.option( "vb", options[5].toInt() );
+ if( !options[7].isEmpty() && options[7].toInt() > 0 )
+ smrl.option( "fps", options[7] );
+ if( !options[6].isEmpty() )
+ smrl.option( "scale", options[6] );
+ if( !options[8].isEmpty() && options[8].toInt() > 0 )
+ smrl.option( "width", options[8].toInt() );
+ if( !options[9].isEmpty() && options[9].toInt() > 0 )
+ smrl.option( "height", options[9].toInt() );
+ }
}
if( options[2].toInt() )
{
smrl.option( "acodec", options[10] );
- smrl.option( "ab", options[11].toInt() );
- smrl.option( "channels", options[12].toInt() );
- smrl.option( "samplerate", options[13].toInt() );
+ if( options[10] != "none" )
+ {
+ smrl.option( "ab", options[11].toInt() );
+ smrl.option( "channels", options[12].toInt() );
+ smrl.option( "samplerate", options[13].toInt() );
+ }
}
if( options[3].toInt() )
}
else
transcode = "";
+ emit optionsChanged();
}
/**
* VLCProfileEditor
**/
-VLCProfileEditor::VLCProfileEditor( QString qs_name, QString value,
+VLCProfileEditor::VLCProfileEditor( const QString& qs_name, const QString& value,
QWidget *_parent )
: QVLCDialog( _parent, NULL )
{
inline void VLCProfileEditor::registerCodecs()
{
-
+
#define ADD_VCODEC( name, fourcc ) ui.vCodecBox->addItem( name, QVariant( fourcc ) );
ADD_VCODEC( "MPEG-1", "mp1v" )
ADD_VCODEC( "MPEG-2", "mp2v" )
ADD_VCODEC( "M-JPEG", "MJPG" )
ADD_VCODEC( "Theora", "theo" )
ADD_VCODEC( "Dirac", "drac" )
+#undef ADD_VCODEC
#define ADD_ACODEC( name, fourcc ) ui.aCodecBox->addItem( name, QVariant( fourcc ) );
ADD_ACODEC( "MPEG Audio", "mpga" )
ADD_ACODEC( "Speex", "spx" )
ADD_ACODEC( "WAV", "s16l" )
ADD_ACODEC( "WMA", "wma" )
+#undef ADD_ACODEC
#define ADD_SCALING( factor ) ui.vScaleBox->addItem( factor );
ADD_SCALING( "1" )
ADD_SCALING( "1.5" )
ADD_SCALING( "1.75" )
ADD_SCALING( "2" )
+#undef ADD_SCALING
#define ADD_SAMPLERATE( sample ) ui.aSampleBox->addItem( sample );
ADD_SAMPLERATE( "11250" )
ADD_SAMPLERATE( "22500" )
ADD_SAMPLERATE( "44100" )
ADD_SAMPLERATE( "48000" )
+#undef ADD_SAMPLERATE
#define ADD_SCODEC( name, fourcc ) ui.subsCodecBox->addItem( name, QVariant( fourcc ) );
ADD_SCODEC( "DVB subtitle", "dvbs" )
ADD_SCODEC( "T.140", "t140" )
+#undef ADD_SCODEC
}
-void VLCProfileEditor::fillProfile( QString qs )
+void VLCProfileEditor::fillProfile( const QString& qs )
{
QStringList options = qs.split( ";" );
if( options.size() < 16 )
return;
- ui.transcodeVideo->setChecked( options[1].toInt() );
- ui.transcodeAudio->setChecked( options[2].toInt() );
+ const QString mux = options[0];
+#define CHECKMUX( button, text) if( text == mux ) ui.button->setChecked( true ); else
+ CHECKMUX( PSMux, "ps" )
+ CHECKMUX( TSMux, "ts" )
+ CHECKMUX( MPEG1Mux, "mpeg1" )
+ CHECKMUX( OggMux, "ogg" )
+ CHECKMUX( ASFMux, "asf" )
+ CHECKMUX( MOVMux, "mp4" )
+ CHECKMUX( WAVMux, "wav" )
+ CHECKMUX( RAWMux, "raw" )
+ CHECKMUX( FLVMux, "flv" )
+ CHECKMUX( MKVMux, "mkv" )
+ CHECKMUX( AVIMux, "avi" )
+ CHECKMUX( MJPEGMux, "mpjpeg" ){}
+#undef CHECKMUX
+
+ ui.keepVideo->setChecked( !options[1].toInt() );
+ ui.transcodeVideo->setChecked( ( options[4] != "none" ) );
+ ui.keepAudio->setChecked( !options[2].toInt() );
+ ui.transcodeAudio->setChecked( ( options[10] != "none" ) );
ui.transcodeSubs->setChecked( options[3].toInt() );
ui.vCodecBox->setCurrentIndex( ui.vCodecBox->findData( options[4] ) );
ui.vBitrateSpin->setValue( options[5].toInt() );
ui.vScaleBox->setEditText( options[6] );
ui.vFrameBox->setValue( options[7].toDouble() );
- ui.widthBox->setValue( options[8].toInt() );
- ui.heightBox->setValue( options[9].toInt() );
+ ui.widthBox->setText( options[8] );
+ ui.heightBox->setText( options[9] );
ui.aCodecBox->setCurrentIndex( ui.aCodecBox->findData( options[10] ) );
ui.aBitrateSpin->setValue( options[11].toInt() );
ui.aChannelsSpin->setValue( options[12].toInt() );
- ui.aSampleBox->setCurrentIndex( ui.aSampleBox->findData( options[13] ) );
+ ui.aSampleBox->setCurrentIndex( ui.aSampleBox->findText( options[13] ) );
ui.subsCodecBox->setCurrentIndex( ui.subsCodecBox->findData( options[14] ) );
ui.subsOverlay->setChecked( options[15].toInt() );
ui.widthLabel->setEnabled( b_trans );
ui.vFrameBox->setEnabled( b_trans );
ui.vFrameLabel->setEnabled( b_trans );
+ ui.keepVideo->setEnabled( b_trans );
}
void VLCProfileEditor::setATranscodeOptions( bool b_trans )
ui.aChannelsSpin->setEnabled( b_trans );
ui.aSampleLabel->setEnabled( b_trans );
ui.aSampleBox->setEnabled( b_trans );
+ ui.keepAudio->setEnabled( b_trans );
}
void VLCProfileEditor::setSTranscodeOptions( bool b_trans )
SMUX( FLVMux, "flv" )
SMUX( MKVMux, "mkv" )
SMUX( AVIMux, "avi" )
- SMUX( MJPEGMux, "mjpg" );
+ SMUX( MJPEGMux, "mpjpeg" ){}
+#undef SMUX
#define currentData( box ) box->itemData( box->currentIndex() )
+ QString qs_acodec, qs_vcodec;
+
+ qs_vcodec = ( ui.transcodeVideo->isChecked() ) ? currentData( ui.vCodecBox ).toString()
+ : "none";
+ qs_acodec = ( ui.transcodeAudio->isChecked() ) ? currentData( ui.aCodecBox ).toString()
+ : "none";
QStringList transcodeMRL;
transcodeMRL
<< muxValue
- << QString::number( ui.transcodeVideo->isChecked() )
- << QString::number( ui.transcodeAudio->isChecked() )
+ << QString::number( !ui.keepVideo->isChecked() )
+ << QString::number( !ui.keepAudio->isChecked() )
<< QString::number( ui.transcodeSubs->isChecked() )
- << currentData( ui.vCodecBox ).toString()
+ << qs_vcodec
<< QString::number( ui.vBitrateSpin->value() )
- << ui.vScaleBox->currentText()
+ << ui.vScaleBox->currentText()
<< QString::number( ui.vFrameBox->value() )
- << QString::number( ui.widthBox->value() )
- << QString::number( ui.heightBox->value() )
+ << ui.widthBox->text()
+ << ui.heightBox->text()
- << currentData( ui.aCodecBox ).toString()
+ << qs_acodec
<< QString::number( ui.aBitrateSpin->value() )
<< QString::number( ui.aChannelsSpin->value() )
<< ui.aSampleBox->currentText()
<< currentData( ui.subsCodecBox ).toString()
<< QString::number( ui.subsOverlay->isChecked() );
+#undef currentData
return transcodeMRL.join( ";" );
}