/*****************************************************************************
* extended_panels.cpp : Extended controls panels
****************************************************************************
- * Copyright ( C ) 2006-2007 the VideoLAN team
+ * Copyright (C) 2006-2007 the VideoLAN team
* $Id$
*
* Authors: Clément Stenac <zorglub@videolan.org>
#include "dialogs/preferences.hpp"
#include "dialogs_provider.hpp"
#include "qt4.hpp"
+#include "input_manager.hpp"
#include "../../audio_filter/equalizer_presets.h"
#include <vlc_aout.h>
if( !psz_parser )
{
psz_parser = psz_string;
- asprintf( &psz_string, ( *psz_string ) ? "%s:%s" : "%s%s",
- psz_string, psz_name );
+ if( asprintf( &psz_string, ( *psz_string ) ? "%s:%s" : "%s%s",
+ psz_string, psz_name ) == -1 )
+ return;
free( psz_parser );
}
else
if( !combobox ) return;
QString option = OptionFromWidgetName( widget );
module_config_t *p_item = config_FindConfig( VLC_OBJECT( p_intf ),
- option.toStdString().c_str() );
+ qtu( option ) );
if( p_item )
{
int i_type = p_item->i_type & CONFIG_ITEM;
else
{
msg_Err( p_intf, "Couldn't find option \"%s\".",
- option.toStdString().c_str() );
+ qtu( option ) );
}
}
vlc_object_t *p_obj = ( vlc_object_t * )
vlc_object_find_name( p_intf->p_libvlc,
- module.toStdString().c_str(),
+ qtu( module ),
FIND_CHILD );
int i_type;
vlc_value_t val;
#if 0
msg_Dbg( p_intf,
"Module instance %s not found, looking in config values.",
- module.toStdString().c_str() );
+ qtu( module ) );
#endif
- i_type = config_GetType( p_intf, option.toStdString().c_str() ) & 0xf0;
+ i_type = config_GetType( p_intf, qtu( option ) ) & 0xf0;
switch( i_type )
{
case VLC_VAR_INTEGER:
case VLC_VAR_BOOL:
- val.i_int = config_GetInt( p_intf, option.toStdString().c_str() );
+ val.i_int = config_GetInt( p_intf, qtu( option ) );
break;
case VLC_VAR_FLOAT:
- val.f_float = config_GetFloat( p_intf, option.toStdString().c_str() );
+ val.f_float = config_GetFloat( p_intf, qtu( option ) );
break;
case VLC_VAR_STRING:
- val.psz_string = config_GetPsz( p_intf, option.toStdString().c_str() );
+ val.psz_string = config_GetPsz( p_intf, qtu( option ) );
break;
}
}
else
{
- i_type = var_Type( p_obj, option.toStdString().c_str() ) & 0xf0;
- var_Get( p_obj, option.toStdString().c_str(), &val );
+ i_type = var_Type( p_obj, qtu( option ) ) & 0xf0;
+ var_Get( p_obj, qtu( option ), &val );
vlc_object_release( p_obj );
}
else
msg_Err( p_intf,
"Module %s's %s variable is of an unsupported type ( %d )",
- module.toStdString().c_str(),
- option.toStdString().c_str(),
+ qtu( module ),
+ qtu( option ),
i_type );
}
vlc_object_t *p_obj = ( vlc_object_t * )
vlc_object_find_name( p_intf->p_libvlc,
- module.toStdString().c_str(),
+ qtu( module ),
FIND_CHILD );
if( !p_obj )
{
- msg_Err( p_intf, "Module %s not found.", module.toStdString().c_str() );
+ msg_Err( p_intf, "Module %s not found.", qtu( module ) );
return;
}
- int i_type = var_Type( p_obj, option.toStdString().c_str() );
+ int i_type = var_Type( p_obj, qtu( option ) );
bool b_is_command = ( i_type & VLC_VAR_ISCOMMAND );
if( !b_is_command )
{
msg_Warn( p_intf, "Module %s's %s variable isn't a command. You'll need to restart the filter to take change into account.",
- module.toStdString().c_str(),
- option.toStdString().c_str() );
+ qtu( module ),
+ qtu( option ) );
/* FIXME: restart automatically somewhere near the end of this function */
}
else if( lineedit ) i_int = lineedit->text().toInt( NULL,16 );
else if( combobox ) i_int = combobox->itemData( combobox->currentIndex() ).toInt();
else msg_Warn( p_intf, "Oops %s %s %d", __FILE__, __func__, __LINE__ );
- config_PutInt( p_intf, option.toStdString().c_str(), i_int );
+ config_PutInt( p_intf, qtu( option ), i_int );
if( b_is_command )
{
if( i_type == VLC_VAR_INTEGER )
- var_SetInteger( p_obj, option.toStdString().c_str(), i_int );
+ var_SetInteger( p_obj, qtu( option ), i_int );
else
- var_SetBool( p_obj, option.toStdString().c_str(), i_int );
+ var_SetBool( p_obj, qtu( option ), i_int );
}
}
else if( i_type == VLC_VAR_FLOAT )
else if( doublespinbox ) f_float = doublespinbox->value();
else if( lineedit ) f_float = lineedit->text().toDouble();
else msg_Warn( p_intf, "Oops %s %s %d", __FILE__, __func__, __LINE__ );
- config_PutFloat( p_intf, option.toStdString().c_str(), f_float );
+ config_PutFloat( p_intf, qtu( option ), f_float );
if( b_is_command )
- var_SetFloat( p_obj, option.toStdString().c_str(), f_float );
+ var_SetFloat( p_obj, qtu( option ), f_float );
}
else if( i_type == VLC_VAR_STRING )
{
char *psz_string = NULL;
if( lineedit ) psz_string = strdup( qtu( lineedit->text() ) );
else if( combobox ) psz_string = strdup( qtu( combobox->itemData(
- combobox->currentIndex() ).toString() ) );
+ combobox->currentIndex() ).toString() ) );
else msg_Warn( p_intf, "Oops %s %s %d", __FILE__, __func__, __LINE__ );
- config_PutPsz( p_intf, option.toStdString().c_str(), psz_string );
+ config_PutPsz( p_intf, qtu( option ), psz_string );
if( b_is_command )
- var_SetString( p_obj, option.toStdString().c_str(), psz_string );
+ var_SetString( p_obj, qtu( option ), psz_string );
free( psz_string );
}
else
msg_Err( p_intf,
"Module %s's %s variable is of an unsupported type ( %d )",
- module.toStdString().c_str(),
- option.toStdString().c_str(),
+ qtu( module ),
+ qtu( option ),
i_type );
vlc_object_release( p_obj );
vlc_object_t *p_obj = (vlc_object_t*)vlc_object_find_name( p_intf, "v4l2", FIND_ANYWHERE );
if( p_obj )
{
- char *psz_var = strdup( s->objectName().toStdString().c_str() );
+ char *psz_var = strdup( qtu( s->objectName() ) );
int i_type = var_Type( p_obj, psz_var );
switch( i_type & VLC_VAR_TYPE )
{
}
else
{
- psz_af = config_GetPsz( p_aout, "audio-filter" );
+ psz_af = config_GetPsz( p_intf, "audio-filter" );
for( int i = 0; i < NUM_SP_CTRL ; i++ )
{
controlVars[i] = config_GetFloat( p_intf, psz_control_names[i] );
// var_AddCallback( p_aout, "Spatializer-preamp", EqzCallback, this );
}
+#include <QToolButton>
+#include <QGridLayout>
+
+SyncControls::SyncControls( intf_thread_t *_p_intf, QWidget *_parent ) :
+ QWidget( _parent ) , p_intf( _p_intf )
+{
+ QGroupBox *AVBox, *subsBox;
+
+ QToolButton *moinsAV, *plusAV;
+ QToolButton *moinssubs, *plussubs;
+ QToolButton *moinssubSpeed, *plussubSpeed;
+
+ QToolButton *updateButton;
+
+ QGridLayout *mainLayout = new QGridLayout( this );
+
+ /* AV sync */
+ AVBox = new QGroupBox( qtr( "Audio/Video" ) );
+ QGridLayout *AVLayout = new QGridLayout( AVBox );
+
+ moinsAV = new QToolButton;
+ moinsAV->setToolButtonStyle( Qt::ToolButtonTextOnly );
+ moinsAV->setAutoRaise( true );
+ moinsAV->setText( "-" );
+ AVLayout->addWidget( moinsAV, 0, 1, 1, 1 );
+
+ plusAV = new QToolButton;
+ plusAV->setToolButtonStyle( Qt::ToolButtonTextOnly );
+ plusAV->setAutoRaise( true );
+ plusAV->setText( "+" );
+ AVLayout->addWidget( plusAV, 0, 3, 1, 1 );
+
+ QLabel *AVLabel = new QLabel;
+ AVLabel->setText( qtr( "Advance of audio over video:" ) );
+ AVLayout->addWidget( AVLabel, 0, 0, 1, 1 );
+
+ AVSpin = new QDoubleSpinBox;
+ AVSpin->setAlignment( Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter );
+ AVSpin->setDecimals( 3 );
+ AVSpin->setMinimum( -100 );
+ AVSpin->setMaximum( 100 );
+ AVSpin->setSingleStep( 0.1 );
+ AVSpin->setToolTip( qtr( "A positive value means that\n"
+ "the audio is ahead of the video" ) );
+ AVSpin->setSuffix( "s" );
+ AVLayout->addWidget( AVSpin, 0, 2, 1, 1 );
+ mainLayout->addWidget( AVBox, 1, 0, 1, 5 );
+
+
+ /* Subs */
+ subsBox = new QGroupBox( qtr( "Subtitles/Video" ) );
+ QGridLayout *subsLayout = new QGridLayout( subsBox );
+
+ moinssubs = new QToolButton;
+ moinssubs->setToolButtonStyle( Qt::ToolButtonTextOnly );
+ moinssubs->setAutoRaise( true );
+ moinssubs->setText( "-" );
+ subsLayout->addWidget( moinssubs, 0, 1, 1, 1 );
+
+ plussubs = new QToolButton;
+ plussubs->setToolButtonStyle( Qt::ToolButtonTextOnly );
+ plussubs->setAutoRaise( true );
+ plussubs->setText( "+" );
+ subsLayout->addWidget( plussubs, 0, 3, 1, 1 );
+
+ QLabel *subsLabel = new QLabel;
+ subsLabel->setText( qtr( "Advance of subtitles over video:" ) );
+ subsLayout->addWidget( subsLabel, 0, 0, 1, 1 );
+
+ subsSpin = new QDoubleSpinBox;
+ subsSpin->setAlignment( Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter );
+ subsSpin->setDecimals( 3 );
+ subsSpin->setMinimum( -100 );
+ subsSpin->setMaximum( 100 );
+ subsSpin->setSingleStep( 0.1 );
+ subsSpin->setToolTip( qtr( "A positive value means that\n"
+ "the subtitles are ahead of the video" ) );
+ subsSpin->setSuffix( "s" );
+ subsLayout->addWidget( subsSpin, 0, 2, 1, 1 );
+
+
+ moinssubSpeed = new QToolButton;
+ moinssubSpeed->setToolButtonStyle( Qt::ToolButtonTextOnly );
+ moinssubSpeed->setAutoRaise( true );
+ moinssubSpeed->setText( "-" );
+ subsLayout->addWidget( moinssubSpeed, 1, 1, 1, 1 );
+
+ plussubSpeed = new QToolButton;
+ plussubSpeed->setToolButtonStyle( Qt::ToolButtonTextOnly );
+ plussubSpeed->setAutoRaise( true );
+ plussubSpeed->setText( "+" );
+ subsLayout->addWidget( plussubSpeed, 1, 3, 1, 1 );
+
+ QLabel *subSpeedLabel = new QLabel;
+ subSpeedLabel->setText( qtr( "Speed of the subtitles:" ) );
+ subsLayout->addWidget( subSpeedLabel, 1, 0, 1, 3 );
+
+ subSpeedSpin = new QDoubleSpinBox;
+ subSpeedSpin->setAlignment( Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter );
+ subSpeedSpin->setDecimals( 3 );
+ subSpeedSpin->setMinimum( 1 );
+ subSpeedSpin->setMaximum( 100 );
+ subSpeedSpin->setSingleStep( 0.2 );
+ subsLayout->addWidget( subSpeedSpin, 1, 2, 1, 1 );
+
+ mainLayout->addWidget( subsBox, 2, 0, 2, 5 );
+
+ updateButton = new QToolButton;
+ updateButton->setAutoRaise( true );
+ updateButton->setText( "u" );
+ updateButton->setToolTip( qtr( "Force update of the values in this dialog" ) );
+ mainLayout->addWidget( updateButton, 0, 4, 1, 1 );
+
+
+ /* Various Connects */
+ CONNECT( moinsAV, clicked(), AVSpin, stepDown () );
+ CONNECT( plusAV, clicked(), AVSpin, stepUp () );
+ CONNECT( moinssubs, clicked(), subsSpin, stepDown () );
+ CONNECT( plussubs, clicked(), subsSpin, stepUp () );
+ CONNECT( moinssubSpeed, clicked(), subSpeedSpin, stepDown () );
+ CONNECT( plussubSpeed, clicked(), subSpeedSpin, stepUp () );
+ CONNECT( AVSpin, valueChanged ( double ), this, advanceAudio( double ) ) ;
+ CONNECT( subsSpin, valueChanged ( double ), this, advanceSubs( double ) ) ;
+ CONNECT( subSpeedSpin, valueChanged ( double ),
+ this, adjustSubsSpeed( double ) );
+ BUTTONACT( updateButton, update() );
+
+ /* Set it */
+ update();
+}
+
+void SyncControls::update()
+{
+ int64_t i_delay;
+ if( THEMIM->getInput() )
+ {
+ i_delay = var_GetTime( THEMIM->getInput(), "spu-delay" );
+ AVSpin->setValue( ( (double)i_delay ) / 1000000 );
+ i_delay = var_GetTime( THEMIM->getInput(), "audio-delay" );
+ subsSpin->setValue( ( (double)i_delay ) / 1000000 );
+ subSpeedSpin->setValue( var_GetFloat( THEMIM->getInput(), "sub-fps" ) );
+ }
+}
+
+void SyncControls::advanceAudio( double f_advance )
+{
+ if( THEMIM->getInput() )
+ {
+ int64_t i_delay = var_GetTime( THEMIM->getInput(), "audio-delay" );
+ i_delay += f_advance * 1000000;
+ var_SetTime( THEMIM->getInput(), "audio-delay", i_delay );
+ msg_Dbg( p_intf, "I am advancing Audio %d", f_advance );
+ }
+}
+
+void SyncControls::advanceSubs( double f_advance )
+{
+ if( THEMIM->getInput() )
+ {
+ int64_t i_delay = var_GetTime( THEMIM->getInput(), "spu-delay" );
+ i_delay += f_advance * 1000000;
+ var_SetTime( THEMIM->getInput(), "spu-delay", i_delay );
+ msg_Dbg( p_intf, "I am advancing subtitles %d", f_advance );
+ }
+}
+
+void SyncControls::adjustSubsSpeed( double f_fps )
+{
+ if( THEMIM->getInput() )
+ {
+ var_SetFloat( THEMIM->getInput(), "sub-fps", f_fps );
+ }
+}
+
/**********************************************************************
* Video filters / Adjust
**********************************************************************/