Commit 59c560fb authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Solved many problems, added debug

Still not functionnal, I think something was lost in the merge...
parent 1450ed17
......@@ -39,7 +39,7 @@ WorkflowRenderer::WorkflowRenderer() :
m_media = new LibVLCpp::Media( "fake://" );
sprintf( buffer, ":invmem-width=%i", VIDEOWIDTH );
m_media->addOption( ":codec=invmem,inamem" );
m_media->addOption( ":codec=invmem" );
m_media->addOption( buffer );
sprintf( buffer, ":invmem-height=%i", VIDEOHEIGHT );
m_media->addOption( buffer );
......
......@@ -39,17 +39,19 @@ MainWorkflow::MainWorkflow( int trackCount ) :
m_renderMutex = new QMutex;
m_synchroneRenderWaitCondition = new QWaitCondition;
m_synchroneRenderWaitConditionMutex = new QMutex;
m_tracks = new TrackHandler*[2];
m_effectEngine = new EffectsEngine;
m_effectEngine->disable();
m_tracks = new TrackHandler*[TrackWorkflow::NbType];
for ( unsigned int i = 0; i < TrackWorkflow::NbType; ++i )
{
TrackWorkflow::TrackType trackType = (i == 0 ? TrackWorkflow::Video : TrackWorkflow::Audio );
m_tracks[i] = new TrackHandler( trackCount, trackType );
m_tracks[i] = new TrackHandler( trackCount, trackType, m_effectEngine );
connect( m_tracks[i], SIGNAL( tracksPaused() ), this, SLOT( tracksPaused() ) );
connect( m_tracks[i], SIGNAL( allTracksRenderCompleted() ), this, SLOT( tracksRenderCompleted() ) );
}
m_outputBuffers = new OutputBuffers;
m_effectEngine = new EffectsEngine;
m_effectEngine->disable();
}
MainWorkflow::~MainWorkflow()
......@@ -212,6 +214,7 @@ MainWorkflow::OutputBuffers* MainWorkflow::getSynchroneOutput()
m_synchroneRenderWaitConditionMutex->unlock();
m_outputBuffers->video = reinterpret_cast<LightVideoFrame*>( m_tracks[TrackWorkflow::Video]->getSynchroneOutput() );
m_outputBuffers->audio = reinterpret_cast<unsigned char*>( m_tracks[TrackWorkflow::Audio]->getSynchroneOutput() );
qDebug() << "video ptr:" << (void*) m_outputBuffers->video;
return m_outputBuffers;
}
......
......@@ -22,11 +22,16 @@
#include "TrackHandler.h"
TrackHandler::TrackHandler( unsigned int nbTracks, TrackWorkflow::TrackType trackType ) :
LightVideoFrame* TrackHandler::nullOutput = NULL;
TrackHandler::TrackHandler( unsigned int nbTracks, TrackWorkflow::TrackType trackType, EffectsEngine* effectsEngine ) :
m_trackCount( nbTracks ),
m_trackType( trackType ),
m_length( 0 )
m_length( 0 ),
m_effectEngine( effectsEngine )
{
TrackHandler::nullOutput = new LightVideoFrame();
m_tracks = new Toggleable<TrackWorkflow*>[nbTracks];
for ( unsigned int i = 0; i < nbTracks; ++i )
{
......@@ -38,11 +43,11 @@ TrackHandler::TrackHandler( unsigned int nbTracks, TrackWorkflow::TrackType trac
}
m_highestTrackNumberMutex = new QMutex;
m_nbTracksToRenderMutex = new QMutex;
}
TrackHandler::~TrackHandler()
{
delete nullOutput;
delete m_highestTrackNumberMutex;
delete m_nbTracksToRenderMutex;
......@@ -288,11 +293,20 @@ void TrackHandler::tracksRenderCompleted( unsigned int trackId )
{
QMutexLocker lock( m_highestTrackNumberMutex );
unsigned char* buff = m_tracks[trackId]->getSynchroneOutput();
if ( m_highestTrackNumber <= trackId && buff != NULL )
if ( m_trackType == TrackWorkflow::Video )
{
LightVideoFrame* buff = reinterpret_cast<LightVideoFrame*>( m_tracks[trackId]->getSynchroneOutput() );
if ( buff == NULL )
m_effectEngine->setInputFrame( *TrackHandler::nullOutput, trackId );
else
{
qDebug() << "About to feed effect engine with frame" << (void*)buff;
m_effectEngine->setInputFrame( *buff, trackId );
}
}
else
{
m_highestTrackNumber = trackId;
m_synchroneRenderingBuffer = buff;;
qDebug() << "Audio isn't implemented yet !";
}
}
//We check for minus or equal, since we can have 0 frame to compute,
......
......@@ -26,13 +26,13 @@
#include <QObject>
#include "Toggleable.hpp"
#include "TrackWorkflow.h"
#include "EffectsEngine.h"
class TrackHandler : public QObject
{
Q_OBJECT
public:
TrackHandler( unsigned int nbTracks, TrackWorkflow::TrackType trackType );
TrackHandler( unsigned int nbTracks, TrackWorkflow::TrackType trackType, EffectsEngine* effectsEngine );
~TrackHandler();
void addClip( Clip* clip, unsigned int trackId, qint64 start );
......@@ -66,6 +66,7 @@ class TrackHandler : public QObject
void activateTrack( unsigned int tracKId );
private:
static LightVideoFrame* nullOutput;
Toggleable<TrackWorkflow*>* m_tracks;
unsigned int m_trackCount;
QAtomicInt m_nbTracksToPause;
......@@ -84,6 +85,7 @@ class TrackHandler : public QObject
* This is for internal synchronisation only.
*/
bool m_renderCompleted;
EffectsEngine* m_effectEngine;
private slots:
......
......@@ -461,7 +461,7 @@ void TrackWorkflow::clipWorkflowRenderCompleted( ClipWorkflow* cw )
// qDebug() << "Clip [" << QObject::sender() << "] render is completed on track" << m_trackId;
if ( cw != NULL )
{
m_synchroneRenderBuffer = reinterpret_cast<unsigned char*>( cw->getOutput() );
m_synchroneRenderBuffer = cw->getOutput();
}
else
{
......@@ -479,7 +479,7 @@ void TrackWorkflow::clipWorkflowRenderCompleted( ClipWorkflow* cw )
// qDebug() << "Track render not completed yet";
}
unsigned char* TrackWorkflow::getSynchroneOutput()
void* TrackWorkflow::getSynchroneOutput()
{
return m_synchroneRenderBuffer;
}
......
......@@ -73,7 +73,7 @@ class TrackWorkflow : public QObject
/**
* Returns the output that has been computed in synchrone mode.
*/
unsigned char* getSynchroneOutput();
void* getSynchroneOutput();
//FIXME: this won't be reliable as soon as we change the fps from the configuration
static const unsigned int nbFrameBeforePreload = 60;
......@@ -120,7 +120,7 @@ class TrackWorkflow : public QObject
QAtomicInt m_nbClipToUnpause;
QAtomicInt m_nbClipToRender;
unsigned char* m_synchroneRenderBuffer;
void* m_synchroneRenderBuffer;
TrackType m_trackType;
......
......@@ -81,7 +81,11 @@ void* VideoClipWorkflow::getOutput()
QMutexLocker lock( m_renderLock );
if ( isEndReached() == true )
{
qDebug()<< "End reached is true, returning NULL";
return NULL;
}
qDebug() << "ptr:" << (void*)m_buffer;
return m_buffer;
}
......@@ -90,7 +94,7 @@ void VideoClipWorkflow::lock( VideoClipWorkflow* cw, void** pp_ret, int size
Q_UNUSED( size );
cw->m_renderLock->lock();
*pp_ret = (*(cw->m_buffer))->frame.pixels;
// qDebug() << '[' << (void*)cw << "] ClipWorkflow::lock";
qDebug() << '[' << (void*)cw << "] ClipWorkflow::lock";
}
void VideoClipWorkflow::unlock( VideoClipWorkflow* cw, void* buffer, int width, int height, int bpp, int size )
......@@ -115,7 +119,7 @@ void VideoClipWorkflow::unlock( VideoClipWorkflow* cw, void* buffer, int widt
cw->m_renderWaitCond->wake();
}
cw->emit renderComplete( cw );
// qDebug() << "Emmiting render completed";
qDebug() << "Emmiting render completed";
// qDebug() << "Entering cond wait";
cw->m_waitCond->wait( cw->m_condMutex );
......
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