Commit 2b66487b authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Improvements in option handling

Now media isn't cloned from on vlcmedia to another, since they share
options. A new one is creater from scratch.
parent d05d676c
......@@ -56,8 +56,8 @@ void Media::clone( const Media& toClone )
void Media::addOption( const char* opt )
{
//libvlc_media_add_option_non_unique( m_internalPtr, opt, m_ex);
libvlc_media_add_option( m_internalPtr, opt, m_ex);
libvlc_media_add_option_unused( m_internalPtr, opt, m_ex);
// libvlc_media_add_option( m_internalPtr, opt, m_ex);
CheckVlcppException(m_ex);
}
......
......@@ -78,18 +78,28 @@ void Media::loadMedia( const QString& mrl )
m_vlcMedia = new LibVLCpp::Media( mrl );
}
void Media::flushParameters()
void Media::flushVolatileParameters()
{
//Flushing the args into the media :
QString param;
foreach ( param, m_parameters )
m_vlcMedia->addOption( param.toStdString().c_str() );
m_parameters.clear();
QString defaultValue;
foreach ( defaultValue, m_volatileParameters )
{
qDebug() << "Restoring volatile parameter" << defaultValue;
m_vlcMedia->addOption( defaultValue.toStdString().c_str() );
}
m_volatileParameters.clear();
}
void Media::addVolatileParam( const QString& param, const QString& defaultValue )
{
qDebug() << "Adding volatile parameter:" << param << ". Will be restored to:" << defaultValue;
m_vlcMedia->addOption( param.toStdString().c_str() );
m_volatileParameters.append( defaultValue );
}
void Media::addParam( const QString& param )
void Media::addConstantParam( const QString& param )
{
m_parameters.append( param );
qDebug() << "Adding constant parameter:" << param;
m_vlcMedia->addOption( param.toStdString().c_str() );
}
void Media::setSnapshot( QPixmap* snapshot )
......
......@@ -74,8 +74,15 @@ public:
virtual ~Media();
void loadMedia( const QString& mrl );
void addParam( const QString& param );
void flushParameters();
/**
* \brief This method adds a parameter that will stay constant though the whole life of this media (unless it is explicitely overided), even if it is cloned.
*/
void addConstantParam( const QString& param );
/**
* \brief This method will add a parameter that will be restored to defaultValue when the flushVolatileParameter is called
*/
void addVolatileParam( const QString& param, const QString& defaultValue );
void flushVolatileParameters();
LibVLCpp::Media* getVLCMedia() { return m_vlcMedia; }
void setSnapshot( QPixmap* snapshot );
......@@ -124,7 +131,7 @@ protected:
LibVLCpp::Media* m_vlcMedia;
QString m_mrl;
QList<QString> m_parameters;
QList<QString> m_volatileParameters;
QPixmap* m_snapshot;
QUuid m_uuid;
QFileInfo* m_fileInfo;
......
......@@ -78,6 +78,7 @@ void MetaDataManager::run()
m_mediaPlayer->setMedia( m_currentClip->getVLCMedia() );
connect( m_mediaPlayer, SIGNAL( playing() ), this, SLOT( entrypointPlaying() ) );
m_mediaPlayer->play();
m_currentClip->flushVolatileParameters();
}
usleep( 10000 );
}
......@@ -87,10 +88,7 @@ void MetaDataManager::run()
void MetaDataManager::computeVideoMetaData()
{
//Disabling audio for this specific use of the media
m_currentClip->addParam( ":no-audio" );
m_currentClip->flushParameters();
//And re-enable it to prevent the audio to be disabled anywhere else.
m_currentClip->addParam( ":audio" );
m_currentClip->addVolatileParam( ":no-audio", ":audio" );
//TODO: activate this when switching to VLC 1.1
// connect( m_mediaPlayer, SIGNAL( lengthChanged() ), this, SLOT( entrypointLengthChanged() ) );
......@@ -98,9 +96,8 @@ void MetaDataManager::computeVideoMetaData()
void MetaDataManager::computeImageMetaData()
{
m_currentClip->addParam( ":access=fake" );
m_currentClip->addParam( ":fake-duration=10000" );
m_currentClip->flushParameters();
m_currentClip->addVolatileParam( ":access=fake", ":access=''" );
m_currentClip->addVolatileParam( ":fake-duration=10000", ":fake-duration=''" );
}
void MetaDataManager::getMetaData()
......@@ -176,23 +173,20 @@ void MetaDataManager::startAudioDataParsing()
sprintf( csb, ":amem-closesb=%lld", (long long int)(intptr_t) &MetaDataManager::closeSoundBuffer);
sprintf( iph, ":amem-iph=%lld", (long long int)(intptr_t) &MetaDataManager::instanceParameterHandler);
sprintf( data, ":amem-data=%lld", (long long int)(intptr_t) this);
m_currentClip->addParam( ":no-video" );
m_currentClip->addParam( ":audio" );
m_currentClip->addParam( ":aout=amem" );
m_currentClip->addParam( osb );
m_currentClip->addParam( psb );
m_currentClip->addParam( csb );
m_currentClip->addParam( iph );
m_currentClip->addParam( data );
m_currentClip->flushParameters();
m_currentClip->addVolatileParam( ":no-video", ":video" );
m_currentClip->addConstantParam( ":audio" );
m_currentClip->addVolatileParam( ":aout=amem", ":aout=''" ); //I'm really not sure about this one...
m_currentClip->addConstantParam( osb );
m_currentClip->addConstantParam( psb );
m_currentClip->addConstantParam( csb );
m_currentClip->addConstantParam( iph );
m_currentClip->addConstantParam( data );
m_mediaPlayer->setMedia( m_currentClip->getVLCMedia() );
m_currentClip->flushVolatileParameters();
connect( m_mediaPlayer, SIGNAL( endReached() ), this, SLOT( stopAudioDataParsing() ) );
qDebug() << "Starting playback again";
m_mediaPlayer->play();
//Restoring the clip at a correct value.
m_currentClip->addParam( ":video" );
}
void MetaDataManager::stopAudioDataParsing()
......
......@@ -118,21 +118,21 @@ void ClipWorkflow::setVmem()
{
char buffer[32];
//TODO: it would be good if we somehow backup the old media parameters to restore it later.
m_clip->getParent()->getVLCMedia()->addOption( ":vout=vmem" );
m_clip->getParent()->addVolatileParam( ":no-audio", ":audio" );
m_clip->getParent()->addVolatileParam( ":vout=vmem", ":vout=''" );
m_clip->getParent()->getVLCMedia()->setDataCtx( this );
m_clip->getParent()->getVLCMedia()->setLockCallback( reinterpret_cast<LibVLCpp::Media::lockCallback>( &ClipWorkflow::lock ) );
m_clip->getParent()->getVLCMedia()->setUnlockCallback( reinterpret_cast<LibVLCpp::Media::unlockCallback>( &ClipWorkflow::unlock ) );
m_clip->getParent()->getVLCMedia()->addOption( ":vmem-chroma=RV24" );
m_clip->getParent()->addConstantParam( ":vmem-chroma=RV24" );
sprintf( buffer, ":vmem-width=%i", VIDEOWIDTH );
m_clip->getParent()->getVLCMedia()->addOption( buffer );
m_clip->getParent()->addConstantParam( buffer );
sprintf( buffer, ":vmem-height=%i", VIDEOHEIGHT );
m_clip->getParent()->getVLCMedia()->addOption( buffer );
m_clip->getParent()->addConstantParam( buffer );
sprintf( buffer, "vmem-pitch=%i", VIDEOWIDTH * 3 );
m_clip->getParent()->getVLCMedia()->addOption( buffer );
m_clip->getParent()->addConstantParam( buffer );
}
void ClipWorkflow::initialize( LibVLCpp::MediaPlayer* mediaPlayer )
......@@ -145,6 +145,7 @@ void ClipWorkflow::initialize( LibVLCpp::MediaPlayer* mediaPlayer )
connect( m_mediaPlayer, SIGNAL( playing() ), this, SLOT( setPositionAfterPlayback() ), Qt::DirectConnection );
connect( m_mediaPlayer, SIGNAL( endReached() ), this, SLOT( clipEndReached() ), Qt::DirectConnection );
m_mediaPlayer->play();
//m_clip->getParent()->flushVolatileParameters();
}
void ClipWorkflow::setPositionAfterPlayback()
......
......@@ -72,7 +72,7 @@ void WorkflowFileRenderer::stop()
void WorkflowFileRenderer::positionChanged( float newPos )
{
m_ui.progressBar->setValue( newPos * 100 );
m_ui.progressBar->setValue( static_cast<int>( newPos * 100 ) );
}
void WorkflowFileRenderer::on_cancelButton_clicked()
......
......@@ -38,7 +38,7 @@ void ClipPreviewWidget::startPreview( Media* media )
{
if ( m_vlcMedia != NULL )
delete m_vlcMedia;
m_vlcMedia = new LibVLCpp::Media( media->getVLCMedia() );
m_vlcMedia = new LibVLCpp::Media( media->getFileInfo()->absoluteFilePath() );
m_mediaPlayer->setMedia( m_vlcMedia );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment