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

Integrated video workflow with new imem module

parent c28f514c
...@@ -30,7 +30,7 @@ Instance::Instance() ...@@ -30,7 +30,7 @@ Instance::Instance()
{ {
char const *argv[] = char const *argv[] =
{ {
// "-vvvvv", "-vvvvv",
"--no-skip-frames", "--no-skip-frames",
// "--intf", "dummy", // "--intf", "dummy",
"--text-renderer", "dummy", "--text-renderer", "dummy",
......
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
#include "WorkflowRenderer.h" #include "WorkflowRenderer.h"
#include "Timeline.h" #include "Timeline.h"
#define OUTPUT_FPS 30
WorkflowRenderer::WorkflowRenderer() : WorkflowRenderer::WorkflowRenderer() :
m_mainWorkflow( MainWorkflow::getInstance() ), m_mainWorkflow( MainWorkflow::getInstance() ),
m_stopping( false ), m_stopping( false ),
...@@ -36,29 +38,31 @@ WorkflowRenderer::WorkflowRenderer() : ...@@ -36,29 +38,31 @@ WorkflowRenderer::WorkflowRenderer() :
char buffer[64]; char buffer[64];
m_actionsLock = new QReadWriteLock; m_actionsLock = new QReadWriteLock;
m_media = new LibVLCpp::Media( "fake://" ); m_media = new LibVLCpp::Media( "imem://" );
sprintf( buffer, ":invmem-width=%i", VIDEOWIDTH ); sprintf( buffer, ":imem-width=%i", VIDEOWIDTH );
m_media->addOption( ":codec=invmem" ); m_media->addOption( buffer );
sprintf( buffer, ":imem-height=%i", VIDEOHEIGHT );
m_media->addOption( buffer );
sprintf( buffer, ":imem-get=%lld", (qint64)WorkflowRenderer::lock );
m_media->addOption( buffer );
sprintf( buffer, ":imem-release=%lld", (qint64)WorkflowRenderer::unlock );
m_media->addOption( buffer ); m_media->addOption( buffer );
sprintf( buffer, ":invmem-height=%i", VIDEOHEIGHT ); sprintf( buffer, ":imem-dar=%s", "4/3" );
m_media->addOption( buffer ); m_media->addOption( buffer );
sprintf( buffer, ":invmem-lock=%lld", (qint64)WorkflowRenderer::lock ); sprintf( buffer, ":imem-fps=%s", "25/1" );
m_media->addOption( buffer ); m_media->addOption( buffer );
sprintf( buffer, ":invmem-unlock=%lld", (qint64)WorkflowRenderer::unlock ); sprintf( buffer, ":imem-release=%lld", (qint64)WorkflowRenderer::unlock );
m_media->addOption( buffer ); m_media->addOption( buffer );
sprintf( buffer, ":invmem-data=%lld", (qint64)this ); sprintf( buffer, ":imem-data=%lld", (qint64)this );
m_media->addOption( buffer );
sprintf( buffer, ":imem-codec=%s", "RV24" );
m_media->addOption( buffer ); m_media->addOption( buffer );
sprintf( buffer, ":width=%i", VIDEOWIDTH ); sprintf( buffer, ":width=%i", VIDEOWIDTH );
m_media->addOption( buffer ); m_media->addOption( buffer );
sprintf( buffer, ":height=%i", VIDEOHEIGHT ); sprintf( buffer, ":height=%i", VIDEOHEIGHT );
m_media->addOption( buffer ); m_media->addOption( buffer );
m_media->addOption( ":imem-cat=2" );
m_media->addOption( ":no-audio" );
// sprintf( buffer, ":inamem-data=%lld", (qint64)this );
// m_media->addOption( buffer );
// sprintf( buffer, ":inamem-callback=%lld", (qint64)WorkflowRenderer::lock );
// m_media->addOption( buffer );
m_condMutex = new QMutex; m_condMutex = new QMutex;
m_waitCond = new QWaitCondition; m_waitCond = new QWaitCondition;
...@@ -93,15 +97,14 @@ WorkflowRenderer::~WorkflowRenderer() ...@@ -93,15 +97,14 @@ WorkflowRenderer::~WorkflowRenderer()
delete m_waitCond; delete m_waitCond;
} }
void* WorkflowRenderer::lockAudio( void* datas ) int WorkflowRenderer::lock( void *datas, int64_t *dts, int64_t *pts, unsigned int *flags, size_t *bufferSize, void **buffer )
{ {
WorkflowRenderer* self = reinterpret_cast<WorkflowRenderer*>( datas ); *dts = -1;
*flags = 0;
qDebug() << "Injecting audio data"; return lockVideo( datas, pts, bufferSize, buffer );
return self->m_renderAudioSample;
} }
void* WorkflowRenderer::lock( void* datas ) int WorkflowRenderer::lockVideo( void *datas, int64_t *pts, size_t *bufferSize, void **buffer )
{ {
WorkflowRenderer* self = reinterpret_cast<WorkflowRenderer*>( datas ); WorkflowRenderer* self = reinterpret_cast<WorkflowRenderer*>( datas );
...@@ -109,12 +112,28 @@ void* WorkflowRenderer::lock( void* datas ) ...@@ -109,12 +112,28 @@ void* WorkflowRenderer::lock( void* datas )
{ {
MainWorkflow::OutputBuffers* ret = self->m_mainWorkflow->getSynchroneOutput(); MainWorkflow::OutputBuffers* ret = self->m_mainWorkflow->getSynchroneOutput();
memcpy( self->m_renderVideoFrame, (*(ret->video))->frame.octets, (*(ret->video))->nboctets ); memcpy( self->m_renderVideoFrame, (*(ret->video))->frame.octets, (*(ret->video))->nboctets );
self->m_videoBuffSize = (*(ret->video))->nboctets;
self->m_renderAudioSample = ret->audio; self->m_renderAudioSample = ret->audio;
} }
return self->m_renderVideoFrame; *pts = ( self->m_mainWorkflow->getCurrentFrame() * 1000000 ) / OUTPUT_FPS;
*buffer = self->m_renderVideoFrame;
*bufferSize = self->m_videoBuffSize;
return 0;
}
int WorkflowRenderer::lockAudio( void *datas, int64_t *pts, size_t *bufferSize, void **buffer )
{
WorkflowRenderer* self = reinterpret_cast<WorkflowRenderer*>( datas );
Q_UNUSED( self );
Q_UNUSED( pts );
Q_UNUSED( bufferSize );
Q_UNUSED( buffer );
return 0;
} }
void WorkflowRenderer::unlock( void* datas ) void WorkflowRenderer::unlock( void* datas, size_t, void* )
{ {
WorkflowRenderer* self = reinterpret_cast<WorkflowRenderer*>( datas ); WorkflowRenderer* self = reinterpret_cast<WorkflowRenderer*>( datas );
self->checkActions(); self->checkActions();
......
...@@ -57,9 +57,10 @@ class WorkflowRenderer : public GenericRenderer ...@@ -57,9 +57,10 @@ class WorkflowRenderer : public GenericRenderer
virtual void previousFrame(); virtual void previousFrame();
virtual qint64 length() { return 0; } virtual qint64 length() { return 0; }
static void* lock( void* datas ); static int lock( void *data, int64_t *dts, int64_t *pts, unsigned int *flags, size_t *bufferSize, void **buffer );
static void* lockAudio( void* datas ); static int lockVideo( void *data, int64_t *pts, size_t *bufferSize, void **buffer );
static void unlock( void* datas ); static int lockAudio( void *data, int64_t *pts, size_t *bufferSize, void **buffer );
static void unlock( void *data, size_t buffSize, void *buffer );
private: private:
void internalPlayPause( bool forcePause ); void internalPlayPause( bool forcePause );
...@@ -75,6 +76,7 @@ class WorkflowRenderer : public GenericRenderer ...@@ -75,6 +76,7 @@ class WorkflowRenderer : public GenericRenderer
private: private:
unsigned char* m_renderVideoFrame; unsigned char* m_renderVideoFrame;
size_t m_videoBuffSize;
unsigned char* m_renderAudioSample; unsigned char* m_renderAudioSample;
QStack<Actions> m_actions; QStack<Actions> m_actions;
QReadWriteLock* m_actionsLock; QReadWriteLock* m_actionsLock;
......
...@@ -387,3 +387,7 @@ int MainWorkflow::getTrackCount( TrackWorkflow::TrackType trackType ) co ...@@ -387,3 +387,7 @@ int MainWorkflow::getTrackCount( TrackWorkflow::TrackType trackType ) co
return m_tracks[trackType]->getTrackCount(); return m_tracks[trackType]->getTrackCount();
} }
qint64 MainWorkflow::getCurrentFrame() const
{
return m_currentFrame;
}
...@@ -72,6 +72,11 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow> ...@@ -72,6 +72,11 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
*/ */
qint64 getLength() const; qint64 getLength() const;
/**
* \return Returns the current frame.
*/
qint64 getCurrentFrame() const;
/** /**
* Stop the workflow (including sub track workflows and clip workflows) * Stop the workflow (including sub track workflows and clip workflows)
*/ */
......
...@@ -305,7 +305,6 @@ void TrackHandler::tracksRenderCompleted( unsigned int trackId ) ...@@ -305,7 +305,6 @@ void TrackHandler::tracksRenderCompleted( unsigned int trackId )
//therefore, m_nbTracksToRender will be equal to -1 //therefore, m_nbTracksToRender will be equal to -1
if ( m_nbTracksToRender <= 0 ) if ( m_nbTracksToRender <= 0 )
{ {
qDebug() << "TrackHandler render completed";
//Just a synchronisation barriere //Just a synchronisation barriere
m_renderCompleted = true; m_renderCompleted = true;
emit allTracksRenderCompleted(); emit allTracksRenderCompleted();
......
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