Commit 6cea7749 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Image are now handled in the library.

Snapshot is working, it just misses the workflow integration.
parent 459826b8
......@@ -34,25 +34,18 @@ const QString Media::VideoExtensions = "*.mov *.avi *.mkv *.mpg *.mpeg *.wmv *
const QString Media::ImageExtensions = "*.gif *.png *.jpg";
const QString Media::AudioExtensions = "*.mp3 *.oga *.flac *.aac *.wav";
//Media::Media( const QString& mrl )
// : m_vlcMedia( NULL ), m_mrl( mrl ), m_snapshot( NULL ), m_length( 0 ),
// m_width( 0 ), m_height( 0 )
//{
// m_vlcMedia = new LibVLCpp::Media( mrl );
// m_uuid = QUuid::createUuid();
// //We avoid creating a fileInfo from the mrl since it can be "fake://" for invmem.
// m_fileInfo = NULL;
//}
Media::Media( const QFileInfo* fileInfo)
: m_vlcMedia( NULL ), m_snapshot( NULL ), m_length( 0 ),
m_width( 0 ), m_height( 0 )
{
m_mrl = "file://" + fileInfo->absoluteFilePath();
m_vlcMedia = new LibVLCpp::Media( m_mrl );
m_uuid = QUuid::createUuid();
m_fileInfo = new QFileInfo( *fileInfo );
setFileType();
if ( m_fileType == Media::Video || m_fileType == Media::Audio )
m_mrl = "file://" + fileInfo->absoluteFilePath();
else
m_mrl = "fake://" + fileInfo->absoluteFilePath();
m_vlcMedia = new LibVLCpp::Media( m_mrl );
}
Media::~Media()
......
......@@ -67,15 +67,15 @@ void MetaDataManager::run()
m_currentClip = m_mediaList.front();
m_mediaList.pop_front();
//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" );
if ( m_currentClip->getFileType() == Media::Video )
{
computeVideoMetaData();
}
else if ( m_currentClip->getFileType() == Media::Image )
{
computeImageMetaData();
}
m_mediaPlayer->setMedia( m_currentClip->getVLCMedia() );
//TODO: activate this when switching to VLC 1.1
// connect( m_mediaPlayer, SIGNAL( lengthChanged() ), this, SLOT( entrypointLengthChanged() ) );
connect( m_mediaPlayer, SIGNAL( playing() ), this, SLOT( entrypointPlaying() ) );
m_mediaPlayer->play();
}
......@@ -84,6 +84,25 @@ void MetaDataManager::run()
return;
}
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" );
//TODO: activate this when switching to VLC 1.1
// connect( m_mediaPlayer, SIGNAL( lengthChanged() ), this, SLOT( entrypointLengthChanged() ) );
}
void MetaDataManager::computeImageMetaData()
{
m_currentClip->addParam( ":access=fake" );
m_currentClip->addParam( ":fake-duration=10000" );
m_currentClip->flushParameters();
}
void MetaDataManager::getMetaData()
{
m_mediaIsPlaying = false;
......@@ -96,14 +115,21 @@ void MetaDataManager::getMetaData()
m_currentClip->setWidth( m_mediaPlayer->getWidth() );
m_currentClip->setHeight( m_mediaPlayer->getHeight() );
qDebug() << "length =" << m_currentClip->getLength();
//Setting time for snapshot :
connect( m_mediaPlayer, SIGNAL( positionChanged() ), this, SLOT( renderSnapshot() ) );
m_mediaPlayer->setTime( m_mediaPlayer->getLength() / 3 );
if ( m_currentClip->getFileType() == Media::Video )
{
connect( m_mediaPlayer, SIGNAL( positionChanged() ), this, SLOT( renderSnapshot() ) );
m_mediaPlayer->setTime( m_mediaPlayer->getLength() / 3 );
}
else
renderSnapshot();
}
void MetaDataManager::renderSnapshot()
{
disconnect( m_mediaPlayer, SIGNAL( positionChanged() ), this, SLOT( renderSnapshot() ) );
if ( m_currentClip->getFileType() == Media::Video )
disconnect( m_mediaPlayer, SIGNAL( positionChanged() ), this, SLOT( renderSnapshot() ) );
QTemporaryFile tmp;
tmp.setAutoRemove( false );
tmp.open();
......@@ -113,7 +139,7 @@ void MetaDataManager::renderSnapshot()
//The slot should be triggered in this methode
m_mediaPlayer->takeSnapshot( m_tmpSnapshotFilename.toStdString().c_str()
, 64, 64 );
, 0, 0 );
//Snapshot slot should has been called (but maybe not in next version...)
}
......
......@@ -54,6 +54,10 @@ class MetaDataManager : public QThread, public Singleton<MetaDataManager>
~MetaDataManager();
virtual void run();
void computeVideoMetaData();
void computeImageMetaData();
//AMEM part :
static void openSoundBuffer( void* datas, unsigned int* freq,
unsigned int* nbChannels, unsigned int* fourCCFormat,
......
......@@ -125,7 +125,7 @@ void LibraryWidget::newMediaLoaded( Media* media )
{
//From here, the clip is const.
addMedia( media );
m_ui.LibraryTabs->setCurrentIndex( 1 );
m_ui.LibraryTabs->setCurrentIndex( (int) media->getFileType() );
}
void LibraryWidget::insertNewMediasFromFileDialog( QString title, QString filter, Media::FileType fileType )
......
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