Commit 7050701e authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Merge branch 'master' into chouquette_sound_workflow

Conflicts:
	src/Renderer/ClipRenderer.cpp
	src/Renderer/WorkflowRenderer.h
parents d6a256cc 20e26777
......@@ -21,8 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef INVERTRNBEFFECTPLUGINCREATOR_H_
#define INVERTRNBEFFECTPLUGINCREATOR_H_
#ifndef BLITINRECTANGLEEFFECTPLUGINCREATOR_H_
#define BLITINRECTANGLEEFFECTPLUGINCREATOR_H_
#include <QObject>
#include <QtPlugin>
......@@ -38,4 +38,4 @@ public:
IEffectPlugin* createIEffectPluginInstance( void );
};
#endif // INVERTRNBEFFECTPLUGINCREATOR_H_
#endif // BLITINRECTANGLEEFFECTPLUGINCREATOR_H_
/*****************************************************************************
* Import.cpp: Import menu
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Geoffroy Lacarriere <geoffroylaca@gmail.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.
*****************************************************************************/
#include <QTime>
#include "Import.h"
#include "ui_Import.h"
#include "PreviewWidget.h"
#include "TagWidget.h"
#include "ImportMediaCellView.h"
#include "Media.h"
#include "ClipRenderer.h"
#include "Library.h"
Import::Import(QWidget *parent) :
QDialog( parent ), m_ui( new Ui::Import )
{
m_ui->setupUi( this );
m_importBrowser = new ImportBrowser( m_ui->ImportBrowserWidget );
m_previewWidget = new PreviewWidget( new ClipRenderer, m_ui->PreviewWidget );
m_tagWidget = new TagWidget( m_ui->TagWidget, 6 );
connect( m_importBrowser, SIGNAL( mediaAdded( Media*, ImportMediaCellView* ) ), this, SLOT( addMedia( Media*, ImportMediaCellView* ) ) );
connect( m_importBrowser, SIGNAL( mediaRemoved() ), this, SLOT( removeMedia() ) );
connect( this, SIGNAL( mediaSelected( Media* ) ), m_previewWidget->getGenericRenderer(), SLOT( setMedia( Media* ) ) );
connect( this, SIGNAL( mediaSelected( Media* ) ), m_tagWidget, SLOT( mediaSelected( Media* ) ) );
}
Import::~Import()
{
delete m_ui;
delete m_importBrowser;
delete m_previewWidget;
delete m_tagWidget;
}
void Import::addMedia( Media* media, ImportMediaCellView* cell )
{
m_mediaList.insert( media->getUuid(), media );
connect( cell, SIGNAL( mediaSelected( QUuid ) ), this, SLOT( setUIMetaData( QUuid ) ) );
connect( cell->nextButton(), SIGNAL( clicked( QWidget*,QMouseEvent* ) ), this, SLOT( clipViewRequested( QWidget*,QMouseEvent* ) ) );
}
void Import::removeMedia()
{
m_mediaList.remove( m_currentUuid );
m_importBrowser->getMediaListView()->removeMedia( m_currentUuid );
}
void Import::setUIMetaData( QUuid uuid )
{
m_currentUuid = uuid;
//Duration
QTime duration;
duration = duration.addSecs( m_mediaList[uuid]->getLength() );
m_ui->durationValueLabel->setText( duration.toString( "hh:mm:ss" ) );
//Filename || title
m_ui->nameValueLabel->setText( m_mediaList[uuid]->getFileInfo()->fileName() );
m_ui->nameValueLabel->setWordWrap( true );
setWindowTitle( m_mediaList[uuid]->getFileInfo()->fileName() + " " + tr( "properties" ) );
//Resolution
m_ui->resolutionValueLabel->setText( QString::number( m_mediaList[uuid]->getWidth() )
+ " x " + QString::number( m_mediaList[uuid]->getHeight() ) );
//FPS
m_ui->fpsValueLabel->setText( QString::number( m_mediaList[uuid]->getFps() ) );
emit mediaSelected( m_mediaList[uuid] );
}
void Import::accept()
{
QHashIterator<QUuid, Media*> iterator( m_mediaList );
while ( iterator.hasNext() )
{
iterator.next();
Library::getInstance()->addMedia( iterator.value() );
}
done(Accepted);
}
void Import::changeEvent( QEvent *e )
{
QDialog::changeEvent( e );
switch ( e->type() )
{
case QEvent::LanguageChange:
m_ui->retranslateUi( this );
break;
default:
break;
}
}
void Import::clipViewRequested( QWidget* sender, QMouseEvent* ev )
{
MediaCellView* cell = qobject_cast<MediaCellView*>(sender->parent());
ImportMediaListController* clipListView = m_importBrowser->getClipListView();
if ( cell == NULL )
return;
clipListView->cleanAll();
Media* media = m_mediaList[cell->uuid()];
delete clipListView;
clipListView = new ImportMediaListController(m_importBrowser->getStackViewController());
m_importBrowser->getClipListView()->addClipsFromMedia( media );
m_importBrowser->getStackViewController()->pushViewController( m_importBrowser->getClipListView() );
}
/*****************************************************************************
* Import.h: Import menu
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Geoffroy Lacarriere <geoffroylaca@gmail.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.
*****************************************************************************/
#ifndef IMPORT_H
#define IMPORT_H
#include <QDialog>
class PreviewWidget;
class TagWidget;
class ImportMediaCellView;
class Media;
namespace Ui
{
class Import;
}
class Import : public QDialog
{
Q_OBJECT
public:
Import( QWidget *parent = 0 );
~Import();
protected:
void changeEvent( QEvent *e );
private:
Ui::Import* m_ui;
PreviewWidget* m_previewWidget;
TagWidget* m_tagWidget;
QHash<QUuid, Media*> m_mediaList;
QUuid m_currentUuid;
private slots:
void accept();
void addMedia( Media* media, ImportMediaCellView* cell );
void removeMedia();
void setUIMetaData( QUuid uuid );
void clipViewRequested( QWidget* sender, QMouseEvent* ev );
signals:
void mediaSelected( Media* );
};
#endif // IMPORT_H
......@@ -51,7 +51,7 @@ ImportController::ImportController(QWidget *parent) :
<< "*.ogg" << "*.ogv";
filters << "*.mp3" << "*.oga" << "*.flac" << "*.aac" << "*.wav";
filters << "*.gif" << "*.png" << "*.jpg";
m_filesModel->setFilter( QDir::AllDirs | QDir::Files | QDir::Readable |
m_filesModel->setFilter( QDir::AllDirs | QDir::Files | QDir::Readable | QDir::Drives |
QDir::NoDotAndDotDot );
m_filesModel->sort( 2, Qt::AscendingOrder );
m_filesModel->sort( 0, Qt::AscendingOrder );
......@@ -68,7 +68,7 @@ ImportController::ImportController(QWidget *parent) :
m_ui->treeView->setColumnHidden( 1, true );
m_ui->treeView->setColumnHidden( 2, true );
m_ui->treeView->setColumnHidden( 3, true );
m_ui->forwardButton->setEnabled( false );
m_ui->forwardButton->setEnabled( true );
m_fsWatcher = new QFileSystemWatcher();
m_fsWatcher->addPath( m_currentlyWatchedDir );
......@@ -297,6 +297,7 @@ ImportController::collapseAllButCurrentPath()
m_ui->treeView->setCurrentIndex( m_filesModel->index( paths.takeFirst() ) );
m_ui->treeView->setExpanded( m_ui->treeView->currentIndex() , true );
}
m_ui->forwardButton->setEnabled( true );
}
void
......
/*****************************************************************************
* ImportModel.cpp
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Geoffroy Lacarriere <geoffroylaca@gmail.com>
* Thomas Boquet <thomas.boquet@gmail.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.
*****************************************************************************/
#include <QDebug>
#include <QDir>
#include <QMessageBox>
#include "ImportModel.h"
ImportModel::ImportModel()
{
m_medias = new QHash<QUuid, Media*>();
m_progressDialog = new QProgressDialog("Importing files...", "Cancel", 0, m_loadingMedias, NULL);
m_progressDialog->setWindowModality( Qt::WindowModal );
m_progressDialog->setMinimumDuration( 1000 );
m_nbLoadedMedias = 0;
}
ImportModel::~ImportModel()
{
}
Media* ImportModel::getMedia( const QUuid& mediaId ) const
{
return m_medias->value( mediaId );
}
Clip* ImportModel::getClip( const QUuid& mediaId, const QUuid& clipId ) const
{
Media* media = m_medias->value( mediaId );
if ( !media )
return NULL;
return media->clip( clipId );
}
void ImportModel::cutMedia( const QUuid& mediaId, int frame )
{
Q_UNUSED( mediaId );
Q_UNUSED( frame );
}
void ImportModel::cutClip( const QUuid& mediaId, const QUuid& clipId, int frame )
{
Q_UNUSED( mediaId );
Q_UNUSED( clipId );
Q_UNUSED( frame );
}
void ImportModel::metaDataComputed( Media* media )
{
disconnect( media, SIGNAL( metaDataComputed( Media* ) ), this, SLOT( metaDataComputed( Media* ) ) );
if ( media->getMetadata() == Media::ParsedWithoutSnapshot )
{
m_medias->insert( media->getUuid(), media );
emit updateMediaRequested( media );
}
else
m_invalidMedias.append( media );
m_progressDialog->setValue( ++m_nbLoadedMedias );
if( m_progressDialog->wasCanceled() )
{
Media* media;
foreach( media, m_invalidMedias )
removeMedia( media->getUuid() );
//delete media;
m_nbLoadedMedias = 0;
m_invalidMedias.clear();
return;
}
if ( m_nbLoadedMedias == m_loadingMedias )
{
if ( m_invalidMedias.count() > 0 )
{
QStringList list;
Media* media;
foreach( media, m_invalidMedias )
{
list.append( media->getFileName() );
removeMedia( media->getUuid() );
//delete media;
}
QMessageBox::warning( NULL, QString( "Error!" ), QString( tr( "Error while loading media(s):\n%0" ) ).arg( list.join( QString("\n") ) ) );
m_invalidMedias.clear();
}
m_nbLoadedMedias = 0;
}
}
void ImportModel::snapshotComputed( Media *media )
{
disconnect( media, SIGNAL( snapshotComputed( Media* ) ), this, SLOT( snapshotComputed( Media* ) ) );
if ( !m_invalidMedias.contains( media ) )
emit updateMediaRequested( media );
}
void ImportModel::loadMedia( Media* media )
{
connect( media, SIGNAL( metaDataComputed( Media* ) ), this, SLOT( metaDataComputed( Media* ) ), Qt::QueuedConnection );
connect( media, SIGNAL( snapshotComputed(Media*) ), this, SLOT( snapshotComputed(Media*) ), Qt::QueuedConnection );
connect( media, SIGNAL( audioSpectrumComputed( Media* ) ), this, SLOT( audioSpectrumComputed(Media*) ) );
MetaDataManager::getInstance()->computeMediaMetadata( media );
emit newMediaLoaded( media );
}
bool ImportModel::mediaAlreadyLoaded( const QFileInfo& fileInfo )
{
QUuid id;
foreach(id, m_medias->keys())
if ( m_medias->value( id )->getFileInfo()->filePath() == fileInfo.filePath() )
return true;
return false;
}
void ImportModel::loadFile( const QFileInfo& fileInfo, int loadingMedias )
{
Media* media;
if ( !fileInfo.isDir() )
{
if ( loadingMedias == 1 )
m_progressDialog->setMaximum( 1 );
if ( !mediaAlreadyLoaded( fileInfo ) )
{
media = new Media( fileInfo.filePath() );
loadMedia( media );
}
else
m_progressDialog->setValue( ++m_nbLoadedMedias );
}
else
{
QDir dir = QDir( fileInfo.filePath() );
QFileInfoList list = dir.entryInfoList( m_filters );
QFileInfo file;
m_loadingMedias = list.count();
m_nbLoadedMedias = 0;
m_progressDialog->setValue( 0 );
m_progressDialog->setMaximum( m_loadingMedias );
foreach( file, list )
loadFile( file, m_loadingMedias );
}
}
void ImportModel::removeMedia( const QUuid& mediaId )
{
if ( m_medias->contains( mediaId ) && m_medias->value( mediaId )->getMetadata() == Media::ParsedWithAudioSpectrum )
delete m_medias->take( mediaId );
else
m_invalidMedias.append( m_medias->take( mediaId ) );
}
void ImportModel::audioSpectrumComputed( Media *media )
{
disconnect( media, SIGNAL( audioSpectrumComputed( Media* ) ), this, SLOT( audioSpectrumComputed( Media* ) ) );
if ( m_invalidMedias.contains( media ) )
{
m_invalidMedias.removeAll( media );
delete media;
}
}
void ImportModel::removeClip( const QUuid& mediaId, const QUuid& clipId )
{
if ( ! m_medias->contains( mediaId ) )
return ;
m_medias->value( mediaId )->removeClip( clipId );
}
void ImportModel::removeAllMedias()
{
QUuid id;
foreach( id, m_medias->keys() )
removeMedia( id );
}
/*****************************************************************************
* ImportModel.h
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Geoffroy Lacarriere <geoffroylaca@gmail.com>
* Thomas Boquet <thomas.boquet@gmail.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.
*****************************************************************************/
#ifndef IMPORTMODEL_H
#define IMPORTMODEL_H
#include <QObject>
#include <QHash>
#include <QFileSystemModel>
#include <QDirModel>
#include <QProgressDialog>
#include "Media.h"
#include "Clip.h"
#include "MetaDataManager.h"
class ImportModel : public QObject
{
Q_OBJECT
public:
ImportModel();
~ImportModel();
Media* getMedia( const QUuid& mediaId ) const;
Clip* getClip( const QUuid& mediaId, const QUuid& clipId ) const;
void cutMedia( const QUuid& mediaId, int frame );
void cutClip( const QUuid& mediaId, const QUuid& clipId, int frame );
void loadFile( const QFileInfo& fileInfo, int loadingMedias = 1 );
void removeMedia( const QUuid& mediaId );
void removeClip( const QUuid& mediaId, const QUuid& clipId );
QHash<QUuid, Media*>* getMedias() const { return m_medias; }
void setFilter( const QStringList& filter ) { m_filters = filter; }
void removeAllMedias();
signals:
void newMediaLoaded( Media* media );
void updateMediaRequested( Media* media );
private:
QHash<QUuid, Media*>* m_medias;
QStringList m_filters;
QList<Media*> m_invalidMedias;
int m_loadingMedias;
int m_nbLoadedMedias;
QProgressDialog* m_progressDialog;
void loadMedia( Media* media );
bool mediaAlreadyLoaded( const QFileInfo& fileInfo );
private slots:
void metaDataComputed( Media* media );
void snapshotComputed( Media* media );
void audioSpectrumComputed( Media* media );
};
#endif // IMPORTMODEL_H
......@@ -46,10 +46,8 @@ ListViewController::ListViewController( StackViewController* nav ) : m_nav( nav
ListViewController::~ListViewController()
{
delete m_title;
delete m_scrollArea;
delete m_layout;
delete m_container;
delete m_title;
}
// ViewController method implementation
......
......@@ -111,8 +111,6 @@ void MediaListViewController::showClipList( const QUuid& uuid )
Library::getInstance()->media( uuid )->clips()->size() == 0 )
return ;
m_lastUuidClipListAsked = uuid;
if ( m_clipsListView != 0 )
delete m_clipsListView;
m_clipsListView = new ClipListViewController( m_nav, uuid );
m_clipsListView->addClipsFromMedia( Library::getInstance()->media( uuid ) );
connect( m_clipsListView, SIGNAL( clipSelected( const QUuid& ) ),
......@@ -150,6 +148,7 @@ void MediaListViewController::restoreContext()
}
}
}
delete m_clipsListView;
}
void
......@@ -157,6 +156,7 @@ MediaListViewController::clipSelection( const QUuid& uuid )
{
Clip* clip;
if ( ( clip = Library::getInstance()->clip( m_currentUuid, uuid ) ) != 0 )
{
emit clipSelected( clip );
}
}
......@@ -113,7 +113,7 @@ ClipRenderer::startPreview()
m_mediaPlayer->setMedia( m_vlcMedia );
m_mediaPlayer->play();
m_mediaPlayer->setPosition( m_begin / m_selectedMedia->getNbFrames() );
m_mediaPlayer->setPosition( (double)m_begin / (double)m_selectedMedia->getNbFrames() );
m_clipLoaded = true;
m_isRendering = true;
m_paused = false;
......@@ -184,6 +184,12 @@ ClipRenderer::previousFrame()
}
}
qint64
ClipRenderer::getLength() const
{
return m_end - m_begin;
}
qint64
ClipRenderer::getLengthMs() const
{
......@@ -241,6 +247,7 @@ ClipRenderer::previewWidgetCursorChanged( qint64 newFrame )
{
if ( m_isRendering == true )
{
newFrame += m_begin;
qint64 nbSeconds = qRound64( (qreal)newFrame / m_selectedMedia->getFps() );
m_mediaPlayer->setTime( nbSeconds * 1000 );
}
......@@ -264,6 +271,12 @@ ClipRenderer::__timeChanged( qint64 time )
if ( fps < 0.1f )
fps = m_selectedMedia->getFps();
qint64 f = qRound64( (qreal)time / 1000.0 * fps );
if ( f >= m_end )
{
__endReached();
return ;
}
f = f - m_begin;
emit frameChanged( f, MainWorkflow::Renderer );
}
......
......@@ -45,6 +45,7 @@ public:
virtual void stop();
virtual void nextFrame();
virtual void previousFrame();
virtual qint64 getLength() const;
virtual qint64 getLengthMs() const;
virtual qint64 getCurrentFrame() const;
virtual float getFps() const;
......@@ -72,7 +73,14 @@ public slots:
virtual void mediaUnloaded( const QUuid& );
virtual void previewWidgetCursorChanged( qint64 newFrame );
// void __positionChanged();
/**
* \brief Triggered at every libvlc_MediaPlayerTimeChanged event.
*
* This slot will compute a frame number based on the time and the clip's FPS.
* Once computed, it will emit a frameChanged signal, with the reason Renderer.
* \warning The frame number computed may be unaccurate.
* \sa frameChanged();
*/
void __timeChanged( qint64 time );
void __endReached();
void __videoStopped();
......
......@@ -149,10 +149,7 @@ public:
* \return The length that has to be rendered in frames
* \sa getLengthMs()
*/
qint64 getLength() const
{
return qRound64( (qreal)getLengthMs() / 1000.0 * (qreal)getFps() );
}
virtual qint64 getLength() const = 0;
/**
* \brief Return true if the renderer is paused
......
......@@ -302,6 +302,11 @@ qint64 WorkflowRenderer::getCurrentFrame() const