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

Adding a EsHandler to know which Es type is beeing rendered in the lock callback.

parent 71ee79d6
......@@ -38,6 +38,15 @@ WorkflowRenderer::WorkflowRenderer() :
char buffer[64];
m_actionsLock = new QReadWriteLock;
m_videoEsHandler = new EsHandler;
m_videoEsHandler->self = this;
m_videoEsHandler->type = Video;
m_audioEsHandler = new EsHandler;
m_audioEsHandler->self = this;
m_audioEsHandler->type = Audio;
m_media = new LibVLCpp::Media( "imem://" );
sprintf( buffer, ":imem-width=%i", VIDEOWIDTH );
......@@ -54,7 +63,7 @@ WorkflowRenderer::WorkflowRenderer() :
m_media->addOption( buffer );
sprintf( buffer, ":imem-release=%lld", (qint64)WorkflowRenderer::unlock );
m_media->addOption( buffer );
sprintf( buffer, ":imem-data=%lld", (qint64)this );
sprintf( buffer, ":imem-data=%lld", (qint64)m_videoEsHandler );
m_media->addOption( buffer );
sprintf( buffer, ":imem-codec=%s", "RV24" );
m_media->addOption( buffer );
......@@ -92,6 +101,8 @@ WorkflowRenderer::~WorkflowRenderer()
disconnect( m_mainWorkflow, SIGNAL( mainWorkflowEndReached() ), this, SLOT( __endReached() ) );
disconnect( m_mainWorkflow, SIGNAL( positionChanged( float ) ), this, SLOT( __positionChanged( float ) ) );
delete m_videoEsHandler;
delete m_audioEsHandler;
delete m_actionsLock;
delete m_media;
delete m_condMutex;
......@@ -100,15 +111,19 @@ WorkflowRenderer::~WorkflowRenderer()
int WorkflowRenderer::lock( void *datas, int64_t *dts, int64_t *pts, unsigned int *flags, size_t *bufferSize, void **buffer )
{
EsHandler* handler = reinterpret_cast<EsHandler*>( datas );
*dts = -1;
*flags = 0;
return lockVideo( datas, pts, bufferSize, buffer );
if ( handler->type == Video )
return lockVideo( handler->self, pts, bufferSize, buffer );
else if ( handler->type == Audio )
return lockAudio( handler->self, pts, bufferSize, buffer );
qWarning() << "Invalid ES type";
return 1;
}
int WorkflowRenderer::lockVideo( void *datas, int64_t *pts, size_t *bufferSize, void **buffer )
int WorkflowRenderer::lockVideo( WorkflowRenderer* self, int64_t *pts, size_t *bufferSize, void **buffer )
{
WorkflowRenderer* self = reinterpret_cast<WorkflowRenderer*>( datas );
if ( self->m_stopping == false )
{
MainWorkflow::OutputBuffers* ret = self->m_mainWorkflow->getSynchroneOutput();
......@@ -124,10 +139,8 @@ int WorkflowRenderer::lockVideo( void *datas, int64_t *pts, size_t *bufferSi
}
int WorkflowRenderer::lockAudio( void *datas, int64_t *pts, size_t *bufferSize, void **buffer )
int WorkflowRenderer::lockAudio( WorkflowRenderer* self, int64_t *pts, size_t *bufferSize, void **buffer )
{
WorkflowRenderer* self = reinterpret_cast<WorkflowRenderer*>( datas );
Q_UNUSED( self );
Q_UNUSED( pts );
Q_UNUSED( bufferSize );
......@@ -137,8 +150,8 @@ int WorkflowRenderer::lockAudio( void *datas, int64_t *pts, size_t *bufferSi
void WorkflowRenderer::unlock( void* datas, size_t, void* )
{
WorkflowRenderer* self = reinterpret_cast<WorkflowRenderer*>( datas );
self->checkActions();
EsHandler* handler = reinterpret_cast<EsHandler*>( datas );
handler->self->checkActions();
}
void WorkflowRenderer::checkActions()
......
......@@ -42,6 +42,18 @@ class WorkflowRenderer : public GenericRenderer
Pause,
//Unpause,
};
enum EsType
{
Unknown,
Audio,
Video,
Subtitle //This is clearly not used by VLMC, but it fits imem module's model
};
struct EsHandler
{
WorkflowRenderer* self;
EsType type;
};
WorkflowRenderer();
~WorkflowRenderer();
......@@ -58,8 +70,8 @@ class WorkflowRenderer : public GenericRenderer
virtual qint64 length() { return 0; }
static int lock( void *data, int64_t *dts, int64_t *pts, unsigned int *flags, size_t *bufferSize, void **buffer );
static int lockVideo( void *data, int64_t *pts, size_t *bufferSize, void **buffer );
static int lockAudio( void *data, int64_t *pts, size_t *bufferSize, void **buffer );
static int lockVideo( WorkflowRenderer* self, int64_t *pts, size_t *bufferSize, void **buffer );
static int lockAudio( WorkflowRenderer* self, int64_t *pts, size_t *bufferSize, void **buffer );
static void unlock( void *data, size_t buffSize, void *buffer );
private:
......@@ -84,6 +96,8 @@ class WorkflowRenderer : public GenericRenderer
bool m_unpauseAsked;
QMutex* m_condMutex;
QWaitCondition* m_waitCond;
EsHandler* m_videoEsHandler;
EsHandler* m_audioEsHandler;
/**
* \brief This isn't exactly the current PTS.
* It's the number of frame rendered since the render has started.
......
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