Commit 1f8a07f6 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Refactored Media class, so we can have audio and video callback/datactx

parent fdabb9b4
......@@ -44,21 +44,35 @@ void Media::addOption( const char* opt )
CheckVlcppException(m_ex);
}
void Media::setLockCallback( Media::lockCallback callback )
void Media::setVideoLockCallback( void* callback )
{
char param[64];
sprintf( param, ":sout-smem-video-prerender-callback=%lld", (qint64)(intptr_t)callback );
addOption(param);
}
void Media::setUnlockCallback( Media::unlockCallback callback )
void Media::setVideoUnlockCallback( void* callback )
{
char param[64];
sprintf( param, ":sout-smem-video-postrender-callback=%lld", (qint64)(intptr_t)callback );
addOption( param );
}
void Media::setDataCtx( void* dataCtx )
void Media::setAudioLockCallback( void* callback )
{
char param[64];
sprintf( param, ":sout-smem-video-prerender-callback=%lld", (qint64)(intptr_t)callback );
addOption(param);
}
void Media::setAudioUnlockCallback( void* callback )
{
char param[64];
sprintf( param, ":sout-smem-video-postrender-callback=%lld", (qint64)(intptr_t)callback );
addOption( param );
}
void Media::setVideoDataCtx( void* dataCtx )
{
char param[64];
......@@ -66,6 +80,14 @@ void Media::setDataCtx( void* dataCtx )
addOption( param );
}
void Media::setAudioDataCtx( void* dataCtx )
{
char param[64];
sprintf( param, ":sout-smem-audio-data=%lld", (qint64)(intptr_t)dataCtx );
addOption( param );
}
void Media::outputInVmem()
{
addOption( ":vout=vmem" );
......
......@@ -37,15 +37,16 @@ namespace LibVLCpp
class Media : public Internal< libvlc_media_t >
{
public:
typedef void (*lockCallback)( void* dataCtx, void **pp_ret );
typedef void (*unlockCallback)( void* dataCtx );
Media( const QString& filename );
~Media();
void addOption( const char* opt );
void setLockCallback( Media::lockCallback );
void setUnlockCallback( Media::unlockCallback );
void setDataCtx( void* dataCtx );
void setVideoLockCallback( void* );
void setVideoUnlockCallback( void* );
void setAudioLockCallback( void* );
void setAudioUnlockCallback( void* );
void setVideoDataCtx( void* dataCtx );
void setAudioDataCtx( void* dataCtx );
void outputInVmem();
void outputInWindow();
void setPixelBuffer( uchar* buffer );
......
......@@ -39,9 +39,9 @@ void VideoClipWorkflow::initVlcOutput()
m_vlcMedia->addOption( ":no-audio" );
m_vlcMedia->addOption( ":no-sout-audio" );
m_vlcMedia->addOption( ":sout=#transcode{}:smem" );
m_vlcMedia->setDataCtx( this );
m_vlcMedia->setLockCallback( reinterpret_cast<LibVLCpp::Media::lockCallback>( getLockCallback() ) );
m_vlcMedia->setUnlockCallback( reinterpret_cast<LibVLCpp::Media::unlockCallback>( getUnlockCallback() ) );
m_vlcMedia->setVideoDataCtx( this );
m_vlcMedia->setVideoLockCallback( reinterpret_cast<void*>( getLockCallback() ) );
m_vlcMedia->setVideoUnlockCallback( reinterpret_cast<void*>( getUnlockCallback() ) );
m_vlcMedia->addOption( ":sout-transcode-vcodec=RV24" );
m_vlcMedia->addOption( ":sout-transcode-acodec=s16l" );
// m_vlcMedia->addOption( ":no-sout-keep" );
......
......@@ -37,7 +37,7 @@ class VideoClipWorkflow : public ClipWorkflow
private:
unsigned char* m_buffer;
void initVlcOutput();
virtual void initVlcOutput();
static void lock( VideoClipWorkflow* clipWorkflow, void** pp_ret, int size );
static void unlock( VideoClipWorkflow* clipWorkflow, void* buffer, int width, int height, int bpp, int size );
};
......
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