Commit 9e190687 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Merge branch 'master' into chouquette_sound_workflow

Conflicts:
	src/EffectsEngine/LightVideoFrame.cpp
	src/Renderer/WorkflowRenderer.cpp
parents 7bc5c172 99ef5e8c
/*****************************************************************************
* Launcher.cpp : Will launch VLMC and watch for events
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Hugo Beauzee-Luyssen <hugo@vlmc.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 <QtDebug>
#include <QCoreApplication>
#include "Launcher.h"
Launcher::Launcher( int argc, char** argv, QObject* parent ) : QObject( parent )
{
m_process = new QProcess;
connect( m_process, SIGNAL( finished( int, QProcess::ExitStatus ) ),
this, SLOT( stopped( int, QProcess::ExitStatus ) ) );
for ( int i = 1; i < argc; ++i )
m_argv << argv[i];
m_process->setReadChannelMode( QProcess::ForwardedChannels );
}
void Launcher::start()
{
//If you put "vlmc" here, it will probably result in a fork bomb :)
m_process->start( "bin/vlmc", m_argv );
}
void Launcher::stopped( int exitCode, QProcess::ExitStatus )
{
switch ( exitCode )
{
case Launcher::cleanExit:
case Launcher::crashExit:
QCoreApplication::exit( exitCode );
break ;
case Launcher::crashWithRestart:
m_process->start( "bin/vlmc", m_argv );
return ;
}
}
/*****************************************************************************
* Launcher.h: Will launch vlmc and watch for events.
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Hugo Beauzee-Luyssen <hugo@vlmc.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.
*****************************************************************************/
#ifndef LAUNCHER_H
#define LAUNCHER_H
#include <QProcess>
#include <QStringList>
class Launcher : public QObject
{
Q_OBJECT
public:
static const int cleanExit = 0;
static const int crashExit = 1;
static const int crashWithRestart = 2;
Launcher( int argc, char** argv, QObject* parent = NULL );
void start();
public slots:
void stopped( int retCode, QProcess::ExitStatus exitType );
private:
QProcess* m_process;
QStringList m_argv;
};
#endif // LAUNCHER_H
# -------------------------------------------------
# Project created by QtCreator 2009-12-19T17:24:19
# -------------------------------------------------
QT -= gui
TARGET = launcher
DESTDIR = ../bin
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp \
Launcher.cpp
HEADERS += Launcher.h
/*****************************************************************************
* main.cpp: Creates the launcher
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Hugo Beauzee-Luyssen <hugo@vlmc.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 <QtCore/QCoreApplication>
#include "Launcher.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
Launcher l(argc, argv);
l.start();
return a.exec();
}
......@@ -65,19 +65,25 @@ Commands::MainWorkflow::MoveClip::MoveClip( ::MainWorkflow* workflow, const QUui
m_workflow( workflow ), m_uuid( uuid ), m_oldTrack( oldTrack ),
m_newTrack( newTrack ), m_pos( newPos ), m_trackType( trackType )
{
setText( QObject::tr( "Moving clip" ) );
if ( oldTrack != newTrack )
setText( QObject::tr( "Moving clip from track %1 to %2" ).arg(
QString::number( oldTrack ), QString::number( newTrack ) ) );
else
setText( QObject::tr( "Moving clip" ) );
m_undoRedoAction = false;
m_oldPos = m_workflow->getClipPosition( uuid, oldTrack, trackType );
}
void Commands::MainWorkflow::MoveClip::redo()
{
// qDebug() << "Moving clip from track" << m_oldTrack << "to" << m_newTrack << "at position:" << m_pos;
m_workflow->moveClip( m_uuid, m_oldTrack, m_newTrack, m_pos, m_trackType, m_undoRedoAction );
m_undoRedoAction = true;
}
void Commands::MainWorkflow::MoveClip::undo()
{
// qDebug() << "Undo moving clip from track" << m_newTrack << "to" << m_oldTrack << "at position:" << m_oldPos;
m_workflow->moveClip( m_uuid, m_newTrack, m_oldTrack, m_oldPos, m_trackType, m_undoRedoAction );
m_undoRedoAction = true;
}
......
......@@ -65,9 +65,11 @@ void SettingsManager::setValue( const QString& part , const QString& key, const
m_globalLock.lockForRead();
if ( !m_tempData.contains( part ) )
{
m_globalLock.unlock();
addNewSettingsPart( part );
}
m_globalLock.unlock();
else
m_globalLock.unlock();
QWriteLocker lock( &m_globalLock );
SettingsPart* tmp = m_tempData[part];
SettingsPart::ConfigPair::iterator it = tmp->m_data.find( key );
......@@ -94,7 +96,6 @@ void SettingsManager::saveSettings( const QString& part, QDomDocument& xmlfile,
m_globalLock.lockForRead();
if ( !m_data.contains( part ) )
{
qDebug() << "no part named" << part;
m_globalLock.unlock();
return ;
}
......@@ -166,29 +167,33 @@ void SettingsManager::addNewSettingsPart( const QString& name )
void SettingsManager::commit()
{
QWriteLocker lock( &m_globalLock );
QHash<QString, SettingsPart*>::iterator it = m_tempData.begin();
QHash<QString, SettingsPart*>::iterator ed = m_tempData.end();
for ( ; it != ed; ++it )
{
SettingsPart* sett = it.value();
QWriteLocker lock( &m_globalLock );
QHash<QString, SettingsPart*>::iterator it = m_tempData.begin();
QHash<QString, SettingsPart*>::iterator ed = m_tempData.end();
QReadLocker rLock( &sett->m_lock );
SettingsPart::ConfigPair::iterator iter = sett->m_data.begin();
SettingsPart::ConfigPair::iterator end = sett->m_data.end();
QWriteLocker wLock( &m_data[it.key()]->m_lock );
for ( ; iter != end; ++iter )
for ( ; it != ed; ++it )
{
SettingsPart::ConfigPair::iterator insert_it = m_data[it.key()]->m_data.find( iter.key() );
if ( insert_it == m_data[it.key()]->m_data.end() )
m_data[it.key()]->m_data.insert( iter.key(), new SettingValue( iter.value()->get() ) );
else
m_data[it.key()]->m_data[ iter.key() ]->set( iter.value()->get() );
SettingsPart* sett = it.value();
QString part = it.key();
QReadLocker rLock( &sett->m_lock );
SettingsPart::ConfigPair::iterator iter = sett->m_data.begin();
SettingsPart::ConfigPair::iterator end = sett->m_data.end();
QWriteLocker wLock( &m_data[part]->m_lock );
for ( ; iter != end; ++iter )
{
QString settingName = iter.key();
SettingsPart::ConfigPair::iterator insert_it = m_data[part]->m_data.find( settingName );
if ( insert_it == m_data[part]->m_data.end() )
m_data[part]->m_data.insert( settingName, new SettingValue( iter.value()->get() ) );
else
m_data[part]->m_data[ settingName ]->set( iter.value()->get() );
}
}
}
lock.unlock();
flush();
}
......
......@@ -22,6 +22,7 @@
#include <QtDebug>
#include <QVariant>
#include <QDir>
#include "VLMCSettingsDefault.h"
#include "SettingsManager.h"
......@@ -38,14 +39,20 @@ void VLMCSettingsDefault::load( const QString& part )
void VLMCSettingsDefault::loadVLMCDefaults( const QString& part )
{
SettingsManager* settingsMan = SettingsManager::getInstance();
QVariant defaultOutputPFS = "30";
QVariant defaultTrackNb = "64";
settingsMan->setValue( part,
"VLMCOutPutFPS", defaultOutputPFS );
"VLMCOutPutFPS", "30" );
settingsMan->setValue( part,
"VLMCTracksNb",
defaultTrackNb );
"64" );
settingsMan->setValue( part,
"VLMCWorkspace",
QDir::homePath() );
settingsMan->setValue( part, "AutomaticBackup", false );
settingsMan->setValue( part, "AutomaticBackupInterval", 5 );
settingsMan->setValue( "private", "LogLevel", QtWarningMsg );
settingsMan->setValue( "private", "LogFile", "vlmc.log" );
return ;
}
......@@ -92,6 +99,7 @@ void VLMCSettingsDefault::loadKeyboardShortcutDefaults( const QString& part )
ADD_SHORTCUT( "Save", QKeySequence( QKeySequence::Save ).toString().toLocal8Bit() );
ADD_SHORTCUT( "Save as", "Ctrl+Shift+S" );
ADD_SHORTCUT( "Close project", QKeySequence( QKeySequence::Close ).toString().toLocal8Bit() );
ADD_SHORTCUT( "Import media", "Ctrl+I" );
return ;
}
......
......@@ -41,15 +41,12 @@ VideoFrame::VideoFrame(VideoFrame const & tocopy) : QSharedData( tocopy )
{
if ( tocopy.frame.octets != NULL )
{
quint32 i;
nboctets = tocopy.nboctets;
nbpixels = tocopy.nboctets / Pixel::NbComposantes;
ptsDiff = tocopy.ptsDiff;
frame.octets = new quint8[tocopy.nboctets];
for ( i = 0; i < nboctets; ++i )
frame.octets[i] = tocopy.frame.octets[i];
memcpy( frame.octets, tocopy.frame.octets, nboctets );
}
else
{
......@@ -92,16 +89,13 @@ LightVideoFrame::LightVideoFrame(quint32 nboctets)
LightVideoFrame::LightVideoFrame(quint8 const * tocopy, quint32 nboctets)
{
quint32 i;
m_videoFrame = new VideoFrame;
m_videoFrame->nboctets = nboctets;
m_videoFrame->nbpixels = nboctets / Pixel::NbComposantes;
m_videoFrame->frame.octets = new quint8[nboctets];
m_videoFrame->ptsDiff = 0;
m_videoFrame = new VideoFrame;
m_videoFrame->nboctets = nboctets;
m_videoFrame->nbpixels = nboctets / Pixel::NbComposantes;
m_videoFrame->frame.octets = new quint8[nboctets];
m_videoFrame->ptsDiff = 0;
for ( i = 0; i < m_videoFrame->nboctets; ++i )
m_videoFrame->frame.octets[i] = tocopy[i];
memcpy( m_videoFrame->frame.octets, tocopy, m_videoFrame->nboctets );
};
LightVideoFrame::~LightVideoFrame()
......
......@@ -58,6 +58,7 @@
#include "KeyboardShortcut.h"
#include "SettingValue.h"
#include "SettingsManager.h"
#include "VlmcDebug.h"
MainWindow::MainWindow( QWidget *parent ) :
QMainWindow( parent ), m_renderer( NULL )
......@@ -66,11 +67,14 @@ MainWindow::MainWindow( QWidget *parent ) :
qRegisterMetaType<MainWorkflow::TrackType>( "MainWorkflow::TrackType" );
qRegisterMetaType<MainWorkflow::FrameChangedReason>( "MainWorkflow::FrameChangedReason" );
qRegisterMetaType<QVariant>( "QVariant" );
// Settings
VLMCSettingsDefault::load( "default" );
VLMCSettingsDefault::load( "VLMC" );
VLMCSettingsDefault::loadKeyboardShortcutDefaults();
//We only install message handler here cause it uses configuration.
VlmcDebug::getInstance()->setup();
// GUI
DockWidgetManager::instance( this )->setMainWindow( this );
......@@ -140,6 +144,7 @@ void MainWindow::setupLibrary()
//GUI part :
MediaLibraryWidget* mediaLibraryWidget = new MediaLibraryWidget( this );
m_importController = new ImportController( this );
DockWidgetManager::instance()->addDockedWidget( mediaLibraryWidget,
tr( "Media Library" ),
......@@ -152,6 +157,8 @@ void MainWindow::setupLibrary()
connect( Library::getInstance(), SIGNAL( mediaRemoved( const QUuid& ) ),
m_clipPreview->getGenericRenderer(), SLOT( mediaUnloaded( QUuid ) ) );
connect( mediaLibraryWidget, SIGNAL( importRequired() ), this, SLOT( on_actionImport_triggered() ) );
}
void MainWindow::on_actionSave_triggered()
......@@ -238,6 +245,7 @@ void MainWindow::createStatusBar()
void MainWindow::initializeDockWidgets( void )
{
WorkflowRenderer* workflowRenderer = new WorkflowRenderer();
workflowRenderer->initializeRenderer();
m_timeline = new Timeline( workflowRenderer, this );
m_timeline->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
m_timeline->show();
......@@ -349,6 +357,7 @@ void MainWindow::on_actionRender_triggered()
if ( m_renderer )
delete m_renderer;
m_renderer = new WorkflowFileRenderer( outputFileName );
m_renderer->initializeRenderer();
m_renderer->run();
}
}
......@@ -367,12 +376,6 @@ void MainWindow::on_actionHelp_triggered()
QDesktopServices::openUrl( QUrl( "http://vlmc.org" ) );
}
void MainWindow::on_actionImport_triggered()
{
//Import* import = new Import( );
//import->exec();
}
void MainWindow::zoomIn()
{
m_zoomSlider->setValue( m_zoomSlider->value() - 1 );
......@@ -458,6 +461,7 @@ void MainWindow::initializeMenuKeyboardShortcut()
INIT_SHORTCUT( save, "Save", actionSave );
INIT_SHORTCUT( saveAs, "Save as", actionSave_As );
INIT_SHORTCUT( closeProject, "Close project", actionClose_Project );
INIT_SHORTCUT( importProject, "Import media", actionImport );
}
#undef INIT_SHORTCUT
......@@ -483,40 +487,56 @@ void MainWindow::keyboardShortcutChanged( const QString& name, const QString&
m_ui.actionSave_As->setShortcut( val );
else if ( name == "Close project" )
m_ui.actionClose_Project->setShortcut( val );
else if ( name == "Import media" )
m_ui.actionImport->setShortcut( val );
else
qWarning() << "Unknown shortcut:" << name;
}
void MainWindow::on_actionCrash_triggered()
{
int test = 1 / 0;
//WARNING: read this part at your own risk !!
//I'm not responsible if you puke while reading this :D
QString str;
int test = 1 / str.length();
Q_UNUSED( test );
}
bool MainWindow::restoreSession()
{
QSettings s;
bool cleanQuit = s.value( "CleanQuit", false ).toBool();
bool fileCreated = false;
bool ret = false;
// Restore the geometry
restoreGeometry( s.value( "MainWindowGeometry" ).toByteArray() );
// Restore the layout
restoreState( s.value( "MainWindowState" ).toByteArray() );
if ( cleanQuit == false )
fileCreated = s.contains( "VlmcVersion" );
if ( fileCreated == true )
{
QMessageBox::StandardButton res = QMessageBox::question( this, tr( "Crash recovery" ), tr( "VLMC didn't closed nicely. Do you wan't to recover your project ?" ),
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes );
if ( res == QMessageBox::Yes )
bool cleanQuit = s.value( "CleanQuit", false ).toBool();
// Restore the geometry
restoreGeometry( s.value( "MainWindowGeometry" ).toByteArray() );
// Restore the layout
restoreState( s.value( "MainWindowState" ).toByteArray() );
if ( cleanQuit == false )
{
if ( ProjectManager::getInstance()->loadEmergencyBackup() == true )
ret = true;
else
QMessageBox::warning( this, tr( "Can't restore project" ), tr( "VLMC didn't manage to restore your project. We appology for the inconvenience" ) );
QMessageBox::StandardButton res = QMessageBox::question( this, tr( "Crash recovery" ), tr( "VLMC didn't closed nicely. Do you wan't to recover your project ?" ),
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes );
if ( res == QMessageBox::Yes )
{
if ( ProjectManager::getInstance()->loadEmergencyBackup() == true )
ret = true;
else
QMessageBox::warning( this, tr( "Can't restore project" ), tr( "VLMC didn't manage to restore your project. We appology for the inconvenience" ) );
}
}
}
s.setValue( "CleanQuit", false );
s.sync();
return ret;
}
void MainWindow::on_actionImport_triggered()
{
m_importController->exec();
}
......@@ -40,6 +40,7 @@
#include "EffectsEngine.h"
#include "MainWorkflow.h"
#include "ProjectWizard.h"
#include "ImportController.h"
class MainWindow : public QMainWindow
{
......@@ -85,6 +86,7 @@ private:
Settings* m_DefaultProjectPreferences;
Settings* m_projectPreferences;
ProjectWizard* m_pWizard;
ImportController* m_importController;
private slots:
void on_actionBypass_effects_engine_toggled(bool );
......@@ -98,11 +100,11 @@ private slots:
void on_actionLoad_Project_triggered();
void on_actionSave_triggered();
void on_actionSave_As_triggered();
void on_actionImport_triggered();
void on_actionHelp_triggered();
void on_actionProject_Preferences_triggered();
void on_actionClose_Project_triggered();
void on_actionCrash_triggered();
void on_actionImport_triggered();
void toolButtonClicked( int id );
void projectUpdated( const QString& projectName, bool savedStatus );
void keyboardShortcutChanged( const QString&, const QString& );
......
......@@ -30,7 +30,7 @@
PreviewRuler::PreviewRuler( QWidget* parent ) :
QWidget( parent ),
m_renderer( NULL ),
m_frame( NULL )
m_frame( 0 )
{
setMouseTracking( true );
m_isSliding = false;
......@@ -141,34 +141,35 @@ void PreviewRuler::paintEvent( QPaintEvent * event )
painter.drawLine( QLineF( r.left() + step * spacing, r.height() - MARK_LARGE, r.left() + step * spacing, r.bottom() ) );
}
}
}
// Draw the markers (if any)
painter.setPen( QPen( Qt::green, 2 ) );
// Draw the markers (if any)
painter.setPen( QPen( Qt::green, 2 ) );
if ( m_markerStart > MARKER_DEFAULT )
{
int markerPos = m_markerStart * width() / m_renderer->getLength();
QPolygon marker( 4 );
marker.setPoints( 4,
markerPos + 8, 1,
markerPos, 1,
markerPos, 20,
markerPos + 8, 20 );
painter.drawPolyline( marker );
}
if ( m_markerStop > MARKER_DEFAULT )
{
int markerPos = m_markerStop * width() / m_renderer->getLength();
QPolygon marker( 4 );
marker.setPoints( 4,
markerPos - 8, 1,
markerPos, 1,
markerPos, 20,
markerPos - 8, 20 );
painter.drawPolyline( marker );
if ( m_markerStart > MARKER_DEFAULT )
{
int markerPos = m_markerStart * width() / m_renderer->getLength();
QPolygon marker( 4 );
marker.setPoints( 4,
markerPos + 8, 1,
markerPos, 1,
markerPos, 20,
markerPos + 8, 20 );
painter.drawPolyline( marker );
}
if ( m_markerStop > MARKER_DEFAULT )
{
int markerPos = m_markerStop * width() / m_renderer->getLength();
QPolygon marker( 4 );
marker.setPoints( 4,
markerPos - 8, 1,
markerPos, 1,
markerPos, 20,
markerPos - 8, 20 );
painter.drawPolyline( marker );
}
}
// Draw the pointer
painter.setRenderHint( QPainter::Antialiasing );
painter.setPen( QPen( Qt::white ) );
......@@ -203,7 +204,11 @@ void PreviewRuler::mouseMoveEvent( QMouseEvent* event )
if ( m_isSliding )
{
if ( m_renderer->getLength() > 0 )
setFrame( (qreal)(event->pos().x() * m_renderer->getLength() ) / width(), true );
{
qint64 pos = event->pos().x();
pos = qBound( (qint64)0, m_renderer->getLength(), pos );
setFrame( (qreal)(pos * m_renderer->getLength() ) / width(), true );
}
}
}
......
/*****************************************************************************
* WorkflowFileRendererDialog.cpp: Display a render feedback.
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Hugo Beauzee-Luyssen <hugo@vlmc.org>
* Christophe Courtaut <christophe.courtaut@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 "WorkflowFileRendererDialog.h"
#define VIDEOWIDTH 640
#define VIDEOHEIGHT 480
WorkflowFileRendererDialog::WorkflowFileRendererDialog()
{
m_ui.setupUi( this );
m_workflow = MainWorkflow::getInstance();
connect( m_workflow, SIGNAL( frameChanged( qint64, MainWorkflow::FrameChangedReason ) ),
this, SLOT( frameChanged( qint64, MainWorkflow::FrameChangedReason ) ) );
}