Commit 0c4baed4 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Workflow is plugged with render preview, and it kinda works

There's still a size/chroma/pitch/something_else problem, but this should work
soon :)
parent f32eecd9
......@@ -63,10 +63,6 @@ void Media::setDataCtx( void* dataCtx )
{
char param[64];
// m_dataCtx = new Media::DataCtx;
// m_dataCtx->mutex = new QMutex();
// m_dataCtx->media = this;
sprintf( param, ":vmem-data=%lld", (qint64)(intptr_t)dataCtx );
addOption( param );
}
......
......@@ -48,7 +48,7 @@ bool ClipWorkflow::renderComplete() const
return m_renderComplete;
}
const unsigned char* ClipWorkflow::getOutput() const
unsigned char* ClipWorkflow::getOutput()
{
return m_buffer;
}
......@@ -58,17 +58,22 @@ void ClipWorkflow::lock( ClipWorkflow* clipWorkflow, void** pp_ret )
//It doesn't seems necessary to lock anything here, since the scheduler
//will wait until the frame is ready to use it, and doesn't use it after
//it has asked for a new one.
qDebug() << "Locking in ClipWorkflow::lock";
*pp_ret = clipWorkflow->m_buffer;
}
void ClipWorkflow::unlock( ClipWorkflow* clipWorkflow )
{
qDebug() << "Outputing debug image";
QImage dbgImg( clipWorkflow->m_buffer, VIDEOWIDTH, VIDEOHEIGHT, QImage::Format_RGB32);
qDebug() << dbgImg.isNull() << "<<<<<<<<<<";
dbgImg.save( "/home/chouquette/Desktop/test.png" );
QMutexLocker lock( clipWorkflow->m_condMutex );
{
QWriteLocker lock2( clipWorkflow->m_mutex );
clipWorkflow->m_renderComplete = true;
}
//qDebug() << "Frame rendered, sleeping mode";
qDebug() << "Frame rendered, sleeping mode";
clipWorkflow->m_waitCond->wait( clipWorkflow->m_condMutex );
}
......@@ -82,6 +87,7 @@ void ClipWorkflow::initialize()
m_clip->getParent()->getVLCMedia()->setLockCallback( reinterpret_cast<LibVLCpp::Media::lockCallback>( &ClipWorkflow::lock ) );
m_clip->getParent()->getVLCMedia()->setUnlockCallback( reinterpret_cast<LibVLCpp::Media::unlockCallback>( &ClipWorkflow::unlock ) );
m_clip->getParent()->getVLCMedia()->addOption( ":vmem-chroma=RV32" );
m_clip->getParent()->getVLCMedia()->addOption( ":vmem-pitch=4" );
sprintf(buffer, ":vmem-width=%i", VIDEOWIDTH);
m_clip->getParent()->getVLCMedia()->addOption( buffer );
......
......@@ -46,7 +46,7 @@ class ClipWorkflow : public QObject
virtual ~ClipWorkflow();
bool renderComplete() const;
const unsigned char* getOutput() const;
unsigned char* getOutput();
void startRender( LibVLCpp::MediaPlayer* mediaPlayer );
private:
static void lock( ClipWorkflow* clipWorkflow, void** pp_ret );
......
......@@ -40,3 +40,13 @@ void MainWorkflow::addClip( Clip* clip, unsigned int trackId )
qDebug() << "MainWorkflow: Adding clip" << clip->getUuid() << "to track" << trackId;
m_tracks[trackId]->addClip( clip );
}
void MainWorkflow::startRender()
{
m_tracks[0]->startRender();
}
unsigned char* MainWorkflow::getOutput()
{
return m_tracks[0]->getOutput();
}
......@@ -39,6 +39,8 @@ class MainWorkflow : public QObject
MainWorkflow();
void addClip( Clip* clip, unsigned int trackId );
void startRender();
unsigned char* getOutput();
private:
TrackWorkflow** m_tracks;
};
......
......@@ -41,7 +41,7 @@ void TrackWorkflow::startRender()
m_currentClipWorkflow->startRender( m_mediaPlayer );
}
const unsigned char* TrackWorkflow::getOutput() const
unsigned char* TrackWorkflow::getOutput()
{
// qDebug() << "Awaking all renderers";
m_waitCondition->wakeAll();
......
......@@ -40,7 +40,7 @@ class TrackWorkflow : public QObject
TrackWorkflow();
void startRender();
const unsigned char* getOutput() const;
unsigned char* getOutput();
private:
ClipWorkflow* m_currentClipWorkflow;
QMutex* m_condMutex;
......
......@@ -27,15 +27,51 @@
RenderPreviewWidget::RenderPreviewWidget( MainWorkflow* mainWorkflow, QWidget* renderWidget ) :
GenericPreviewWidget( renderWidget ), m_mainWorkflow( mainWorkflow )
{
m_media = new LibVLCpp::Media( "fake://" );
// --invmem-width <integer> Width
// --invmem-height <integer> Height
// --invmem-lock <string> Lock function
// --invmem-unlock <string> Unlock function
// --invmem-data <string> Callback data
char buffer[64];
sprintf( buffer, ":invmem-width=%i", VIDEOWIDTH );
m_media->addOption( ":codec=invmem" );
m_media->addOption( buffer );
sprintf( buffer, ":invmem-height=%i", VIDEOHEIGHT );
m_media->addOption( buffer );
sprintf( buffer, ":invmem-lock=%lld", (qint64)RenderPreviewWidget::lock );
m_media->addOption( buffer );
sprintf( buffer, ":invmem-unlock=%lld", (qint64)RenderPreviewWidget::unlock );
m_media->addOption( buffer );
sprintf( buffer, ":invmem-data=%lld", (qint64)this );
m_media->addOption( buffer );
m_mediaPlayer->setMedia( m_media );
}
RenderPreviewWidget::~RenderPreviewWidget()
{
delete m_media;
}
void* RenderPreviewWidget::lock( void* datas )
{
qDebug() << "Locking invmem";
RenderPreviewWidget* self = reinterpret_cast<RenderPreviewWidget*>( datas);
return self->m_mainWorkflow->getOutput();
}
void RenderPreviewWidget::unlock( void* )
{
qDebug() << "Unlocking invmem";
}
void RenderPreviewWidget::startPreview( Media* )
{
qDebug() << "Starting render preview";
m_mainWorkflow->startRender();
m_mediaPlayer->play();
}
void RenderPreviewWidget::setPosition( float /*newPos*/ )
......@@ -44,7 +80,7 @@ void RenderPreviewWidget::setPosition( float /*newPos*/ )
void RenderPreviewWidget::togglePlayPause( bool /*forcePause*/ )
{
startPreview( NULL );
}
/////////////////////////////////////////////////////////////////////
......
......@@ -44,8 +44,12 @@ class RenderPreviewWidget : public GenericPreviewWidget
virtual void setPosition( float newPos );
virtual void togglePlayPause( bool forcePause );
static void* lock( void* datas );
static void unlock( void* datas );
private:
MainWorkflow* m_mainWorkflow;
LibVLCpp::Media* m_media;
public slots:
void __positionChanged();
......
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