Commit 7f744a81 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Correcting length stuff for both clip and media

Added some doc
parent 934e3c8a
......@@ -26,7 +26,7 @@
#include "Clip.h"
Clip::Clip( Media* parent ) : m_parent( parent ), m_begin( 0.0f ), m_end( Clip::UntilEndOfMedia )
Clip::Clip( Media* parent ) : m_parent( parent ), m_begin( 0.0f ), m_end( 1.0f )
{
init();
}
......@@ -68,10 +68,8 @@ qint64 Clip::getLength() const
void Clip::computeLength()
{
if ( m_end == Clip::UntilEndOfMedia )
m_length = m_parent->getLength() - m_begin;
else
m_length = m_end - m_begin;
qint64 nbMs = (qint64)( ( m_end - m_begin ) * (float)m_parent->getLength() );
m_length = (nbMs / 1000) * FPS;
}
const QUuid& Clip::getUuid() const
......
......@@ -33,21 +33,53 @@
#include "Media.h"
//TODO: REMOVE THIS
#ifndef FPS
#define FPS 30
#endif
class Clip : public QObject
{
Q_OBJECT
public:
static const float UntilEndOfMedia = -1;
Clip( Media* parent );
Clip( Clip* creator, qint64 begin, qint64 end );
virtual ~Clip();
/**
\brief Returns the clip starting point. This value will be in
vlc positition units (0 to 1)
\return A value between 0 and 1, where 0 is the real Media begin,
and 1 the real Media end.
*/
float getBegin() const;
/**
\brief Returns the clip ending point. This value will be in
vlc positition units (0 to 1)
\return A value between 0 and 1, where 0 is the real Media end,
and 1 the real Media end.
*/
float getEnd() const;
/**
\return Returns the clip length in frame.
*/
qint64 getLength() const;
/**
\return Returns the Media that the clip was basep uppon.
*/
Media* getParent();
/**
\brief Returns an unique Uuid for this clip (which is NOT the
parent's Uuid).
\return The Clip's Uuid as a QUuid
*/
const QUuid& getUuid() const;
private:
......
......@@ -73,7 +73,17 @@ public:
const QFileInfo* getFileInfo() const;
/**
\return Returns the length of this media (ie the
video duration) in milliseconds.
*/
qint64 getLength() const;
/**
\brief This methods is most of an entry point for the
MetadataManager than enything else.
If you use it to set a inconsistant media length
you'll just have to blame yourself !
*/
void setLength( qint64 length );
int getWidth() const;
......
......@@ -82,8 +82,7 @@ void ClipWorkflow::unlock( ClipWorkflow* clipWorkflow )
clipWorkflow->m_renderComplete = true;
}
if ( clipWorkflow->m_clip->getEnd() != Clip::UntilEndOfMedia
&& clipWorkflow->m_mediaPlayer->getPosition() > clipWorkflow->m_clip->getEnd() )
if ( clipWorkflow->m_mediaPlayer->getPosition() > clipWorkflow->m_clip->getEnd() )
{
QWriteLocker lock2( clipWorkflow->m_endReachedLock );
clipWorkflow->m_endReached = true;
......@@ -180,3 +179,8 @@ void ClipWorkflow::endReached()
QWriteLocker lock2( m_endReachedLock );
m_endReached = true;
}
const Clip* ClipWorkflow::getClip() const
{
return m_clip;
}
......@@ -51,6 +51,12 @@ class ClipWorkflow : public QObject
bool isReady() const;
bool isEndReached() const;
void startRender();
/**
\brief Returns the Clip this workflow instance is based
uppon, so that you can query information on it.
\return A pointer to a constant clip instance.
*/
const Clip* getClip() const;
private:
static void lock( ClipWorkflow* clipWorkflow, void** pp_ret );
......
......@@ -100,6 +100,15 @@ bool TrackWorkflow::checkNextClip( qint64 currentFrame )
return true;
}
qint64 TrackWorkflow::getLength() const
{
if ( m_clips.count() == 0 )
return 0;
QMap<qint64, ClipWorkflow*>::const_iterator it = m_clips.end() - 1;
qDebug() << "Last clip Uuid : " << it.value()->getClip()->getUuid();
return ( it.key() + it.value()->getClip()->getLength() );
}
unsigned char* TrackWorkflow::getOutput( qint64 currentFrame )
{
unsigned char* ret = TrackWorkflow::blackOutput;
......
......@@ -31,7 +31,10 @@
#include "ClipWorkflow.h"
#include "VLCMediaPlayer.h"
//TODO: REMOVE THIS
#ifndef FPS
#define FPS 30
#endif
class TrackWorkflow : public QObject
{
......@@ -42,8 +45,10 @@ class TrackWorkflow : public QObject
void startRender();
unsigned char* getOutput( qint64 currentFrame );
qint64 getLength() const;
//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 const unsigned int nbFrameBeforePreload = 60;
static unsigned char* blackOutput;
private:
......
......@@ -79,7 +79,6 @@ void RenderPreviewWidget::unlock( void* )
void RenderPreviewWidget::startPreview( Media* )
{
qDebug() << "Starting render preview";
m_mainWorkflow->startRender();
m_mediaPlayer->play();
m_isRendering = true;
......
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