Commit 5d71c5cc authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

The track cursor now follows the render progression

Removed useless Track.cpp/h
parent 3fcab3d0
/*****************************************************************************
* Track.cpp: Object Representation of Track
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: 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 "Track.h"
Track::Track()
{
}
/*****************************************************************************
* Track.h: Object Representation of Track
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: 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.
*****************************************************************************/
#ifndef TRACK_H
#define TRACK_H
#include <QObject>
class Track : public QObject
{
Q_OBJECT
public:
Track();
};
#endif // TRACK_H
......@@ -43,10 +43,15 @@ void MainWorkflow::addClip( Clip* clip, unsigned int trackId, qint64 start )
void MainWorkflow::startRender()
{
m_currentFrame = 0;
emit frameChanged( 0 );
m_tracks[0]->startRender();
}
unsigned char* MainWorkflow::getOutput()
{
return m_tracks[0]->getOutput();
unsigned char* ret = m_tracks[0]->getOutput( m_currentFrame );
++m_currentFrame;
emit frameChanged( m_currentFrame );
return ret;
}
......@@ -44,6 +44,10 @@ class MainWorkflow : public QObject
private:
TrackWorkflow** m_tracks;
qint64 m_currentFrame;
signals:
void frameChanged( qint64 currentFrame );
};
#endif // MAINWORKFLOW_H
......@@ -26,7 +26,7 @@
unsigned char* TrackWorkflow::blackOutput = NULL;
TrackWorkflow::TrackWorkflow() : m_currentFrame( 0 ), m_isRendering( false )
TrackWorkflow::TrackWorkflow() : m_isRendering( false )
{
m_condMutex = new QMutex;
m_waitCondition = new QWaitCondition;
......@@ -47,7 +47,6 @@ void TrackWorkflow::addClip( Clip* clip, qint64 start )
void TrackWorkflow::startRender()
{
m_currentFrame = 0;
m_current = m_clips.end();
//If the first frame is to be render soon, we should play it now.
if ( m_clips.begin().key() < TrackWorkflow::nbFrameBeforePreload )
......@@ -67,7 +66,7 @@ void TrackWorkflow::startRender()
}
}
bool TrackWorkflow::checkNextClip()
bool TrackWorkflow::checkNextClip( qint64 currentFrame )
{
QMap<qint64, ClipWorkflow*>::iterator next;
......@@ -84,12 +83,12 @@ bool TrackWorkflow::checkNextClip()
}
//If it's about to be used, initialize it
if ( next.key() == m_currentFrame + TrackWorkflow::nbFrameBeforePreload )
if ( next.key() == currentFrame + TrackWorkflow::nbFrameBeforePreload )
{
// qDebug() << "Initializing next clipWorkflow";
next.value()->initialize( m_mediaPlayer );
}
else if ( next.key() == m_currentFrame )
else if ( next.key() == currentFrame )
{
//It should have been initialized now, however, this ain't very safe :/
Q_ASSERT( next.value()->isReady() );
......@@ -101,17 +100,16 @@ bool TrackWorkflow::checkNextClip()
return true;
}
unsigned char* TrackWorkflow::getOutput()
unsigned char* TrackWorkflow::getOutput( qint64 currentFrame )
{
unsigned char* ret = TrackWorkflow::blackOutput;
bool clipsRemaining;
// qDebug() << "Frame nb" << m_currentFrame;
clipsRemaining = checkNextClip();
clipsRemaining = checkNextClip( currentFrame );
if ( m_current == m_clips.end() )
{
// qDebug() << "Stil no clip at this time, going to the next frame";
++m_currentFrame;
return ret;
}
m_waitCondition->wakeAll();
......@@ -128,6 +126,5 @@ unsigned char* TrackWorkflow::getOutput()
return NULL;
}
}
++m_currentFrame;
return ret;
}
......@@ -41,7 +41,7 @@ class TrackWorkflow : public QObject
TrackWorkflow();
void startRender();
unsigned char* getOutput();
unsigned char* getOutput( qint64 currentFrame );
//FIXME: this won't be reliable as soon as we change the fps from the configuration
static const unsigned int nbFrameBeforePreload = 60; //We load aproximatively 2s before the frame has to render.
static unsigned char* blackOutput;
......@@ -50,13 +50,11 @@ class TrackWorkflow : public QObject
/**
* \return true if at least one video remains, false otherwise (IE end of this track)
*/
bool checkNextClip();
bool checkNextClip( qint64 currentFrame );
private:
QMap<qint64, ClipWorkflow*> m_clips;
QMap<qint64, ClipWorkflow*>::iterator m_current;
//TODO: this MUST be in the MainWorkflow, and passed as a parameter to the getOutput method.
qint64 m_currentFrame;
QMutex* m_condMutex;
QWaitCondition* m_waitCondition;
LibVLCpp::MediaPlayer* m_mediaPlayer;
......
......@@ -40,3 +40,8 @@ void GraphicsCursorItem::setCursorPos( int position )
{
setPos( position, pos().y() );
}
void GraphicsCursorItem::updateCursorPos( qint64 position )
{
setCursorPos( (qint64) position );
}
......@@ -29,6 +29,9 @@ private:
signals:
void cursorPositionChanged( int pos );
public slots:
void updateCursorPos( qint64 pos );
};
#endif // GRAPHICSCURSORITEM_H
......@@ -55,6 +55,7 @@ Timeline::Timeline( QWidget *parent ) :
setDuration( 0 );
connect( m_tracksView->horizontalScrollBar(), SIGNAL( valueChanged( int ) ), m_tracksRuler, SLOT( moveRuler( int ) ) );
connect( m_tracksView, SIGNAL( durationChanged(int) ), this, SLOT( setDuration(int) ) );
connect( m_mainWorkflow, SIGNAL( frameChanged(qint64) ), m_tracksView->tracksCursor(), SLOT( updateCursorPos( qint64 ) ) );
}
void Timeline::changeEvent( QEvent *e )
......
......@@ -38,7 +38,6 @@ SOURCES += src/main.cpp \
src/gui/FileBrowser.cpp \
src/gui/GraphicsCursorItem.cpp \
src/TimelineBackend.cpp \
src/Track.cpp \
src/Workflow/ClipWorkflow.cpp \
src/Workflow/TrackWorkflow.cpp \
src/Workflow/MainWorkflow.cpp \
......@@ -74,7 +73,6 @@ HEADERS += src/gui/MainWindow.h \
src/gui/FileBrowser.h \
src/gui/GraphicsCursorItem.h \
src/TimelineBackend.h \
src/Track.h \
src/Workflow/ClipWorkflow.h \
src/Workflow/TrackWorkflow.h \
src/Workflow/MainWorkflow.h \
......
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