[vlmc-devel] commit: WorkflowRenderer: Updating code to work with modified imem. ( Hugo Beauzee-Luyssen )

git at videolan.org git at videolan.org
Wed Apr 7 15:22:47 CEST 2010


vlmc | branch: master | Hugo Beauzee-Luyssen <beauze.h at gmail.com> | Wed Apr  7 14:47:13 2010 +0200| [68d60a4f77258b1442d7e6988988b230ac633ea5] | committer: Hugo Beauzee-Luyssen 

WorkflowRenderer: Updating code to work with modified imem.

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=68d60a4f77258b1442d7e6988988b230ac633ea5
---

 src/Renderer/WorkflowFileRenderer.cpp |    6 ++--
 src/Renderer/WorkflowFileRenderer.h   |    2 +-
 src/Renderer/WorkflowRenderer.cpp     |   57 ++++++++++++++++-----------------
 src/Renderer/WorkflowRenderer.h       |   10 +++--
 4 files changed, 38 insertions(+), 37 deletions(-)

diff --git a/src/Renderer/WorkflowFileRenderer.cpp b/src/Renderer/WorkflowFileRenderer.cpp
index f464902..89f4a01 100644
--- a/src/Renderer/WorkflowFileRenderer.cpp
+++ b/src/Renderer/WorkflowFileRenderer.cpp
@@ -97,10 +97,10 @@ float   WorkflowFileRenderer::getFps() const
 }
 
 int
-WorkflowFileRenderer::lock( void *datas, qint64 *dts, qint64 *pts, quint32 *flags,
-                            size_t *bufferSize, void **buffer )
+WorkflowFileRenderer::lock( void *datas, const char* cookie, qint64 *dts, qint64 *pts,
+                            quint32 *flags, size_t *bufferSize, void **buffer )
 {
-    int         ret = WorkflowRenderer::lock( datas, dts, pts, flags, bufferSize, buffer );
+    int         ret = WorkflowRenderer::lock( datas, cookie, dts, pts, flags, bufferSize, buffer );
     EsHandler*  handler = reinterpret_cast<EsHandler*>( datas );
     WorkflowFileRenderer* self = static_cast<WorkflowFileRenderer*>( handler->self );
 
diff --git a/src/Renderer/WorkflowFileRenderer.h b/src/Renderer/WorkflowFileRenderer.h
index e76af15..afd6293 100644
--- a/src/Renderer/WorkflowFileRenderer.h
+++ b/src/Renderer/WorkflowFileRenderer.h
@@ -45,7 +45,7 @@ public:
     void                        run(const QString& outputFileName, quint32 width,
                                     quint32 height, double fps, quint32 vbitrate,
                                     quint32 abitrate);
-    static int                  lock( void* datas, qint64 *dts, qint64 *pts,
+    static int                  lock( void* datas, const char* cookie, qint64 *dts, qint64 *pts,
                                       quint32 *flags, size_t *bufferSize, void **buffer );
     virtual float               getFps() const;
 
diff --git a/src/Renderer/WorkflowRenderer.cpp b/src/Renderer/WorkflowRenderer.cpp
index dda3447..d714324 100644
--- a/src/Renderer/WorkflowRenderer.cpp
+++ b/src/Renderer/WorkflowRenderer.cpp
@@ -42,8 +42,7 @@ WorkflowRenderer::WorkflowRenderer() :
             m_mainWorkflow( MainWorkflow::getInstance() ),
             m_stopping( false ),
             m_outputFps( 0.0f ),
-            m_videoEsHandler( NULL ),
-            m_audioEsHandler( NULL ),
+            m_esHandler( NULL ),
             m_oldLength( 0 ),
             m_media( NULL ),
             m_width( 0 ),
@@ -54,12 +53,8 @@ WorkflowRenderer::WorkflowRenderer() :
 
 void    WorkflowRenderer::initializeRenderer()
 {
-    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_esHandler = new EsHandler;
+    m_esHandler->self = this;
 
     m_nbChannels = 2;
     m_rate = 48000;
@@ -76,10 +71,8 @@ WorkflowRenderer::~WorkflowRenderer()
 {
     killRenderer();
 
-    if ( m_videoEsHandler )
-        delete m_videoEsHandler;
-    if ( m_audioEsHandler )
-        delete m_audioEsHandler;
+    if ( m_esHandler )
+        delete m_esHandler;
     if ( m_media )
         delete m_media;
     if ( m_silencedAudioBuffer )
@@ -92,17 +85,15 @@ WorkflowRenderer::setupRenderer( quint32 width, quint32 height, double fps )
     char        videoString[512];
     char        inputSlave[256];
     char        audioParameters[256];
-    char        callbacks[64];
+    char        buffer[64];
 
-    m_audioEsHandler->fps = fps;
-    m_videoEsHandler->fps = fps;
+    m_esHandler->fps = fps;
     //Clean any previous render.
 
-    sprintf( videoString, "width=%i:height=%i:dar=%s:fps=%s:data=%" PRId64 ":codec=%s:cat=2:caching=0",
-             width, height, "16/9", "30/1",
-             (qint64)m_videoEsHandler, "RV24" );
-    sprintf( audioParameters, "data=%"PRId64":cat=1:codec=f32l:samplerate=%u:channels=%u:caching=0",
-             (qint64)m_audioEsHandler, m_rate, m_nbChannels );
+    sprintf( videoString, "width=%i:height=%i:dar=%s:fps=%s:cookie=0:codec=%s:cat=2:caching=0",
+             width, height, "16/9", "30/1", "RV24" );
+    sprintf( audioParameters, "cookie=1:cat=1:codec=f32l:samplerate=%u:channels=%u:caching=0",
+                m_rate, m_nbChannels );
     strcpy( inputSlave, ":input-slave=imem://" );
     strcat( inputSlave, audioParameters );
 
@@ -111,16 +102,18 @@ WorkflowRenderer::setupRenderer( quint32 width, quint32 height, double fps )
     m_media = new LibVLCpp::Media( "imem://" + QString( videoString ) );
     m_media->addOption( inputSlave );
 
-    sprintf( callbacks, "imem-get=%lld", (qint64)getLockCallback() );
-    m_media->addOption( callbacks );
-    sprintf( callbacks, ":imem-release=%lld", (qint64)getUnlockCallback() );
-    m_media->addOption( callbacks );
+    sprintf( buffer, "imem-get=%"PRId64, (qint64)getLockCallback() );
+    m_media->addOption( buffer );
+    sprintf( buffer, ":imem-release=%"PRId64, (qint64)getUnlockCallback() );
+    m_media->addOption( buffer );
+    sprintf( buffer, ":imem-data=%"PRId64, (qint64)m_esHandler );
+    m_media->addOption( buffer );
     m_media->addOption( ":text-renderer dummy" );
 }
 
 int
-WorkflowRenderer::lock( void *datas, qint64 *dts, qint64 *pts, quint32 *flags,
-                        size_t *bufferSize, void **buffer )
+WorkflowRenderer::lock( void *datas, const char* cookie, qint64 *dts, qint64 *pts,
+                        quint32 *flags, size_t *bufferSize, void **buffer )
 {
     int             ret = 1;
     EsHandler*      handler = reinterpret_cast<EsHandler*>( datas );
@@ -128,20 +121,26 @@ WorkflowRenderer::lock( void *datas, qint64 *dts, qint64 *pts, quint32 *flags,
 
     *dts = -1;
     *flags = 0;
-    if ( handler->type == Video )
+    if ( cookie == NULL || ( cookie[0] != WorkflowRenderer::VideoCookie &&
+                             cookie[0] != WorkflowRenderer::AudioCookie ) )
+    {
+        qCritical() << "Invalid imem input cookie";
+        return ret;
+    }
+    if ( cookie[0] == WorkflowRenderer::VideoCookie )
     {
         ret = handler->self->lockVideo( handler, pts, bufferSize, buffer );
         if ( paused == false )
             handler->self->m_mainWorkflow->nextFrame( MainWorkflow::VideoTrack );
     }
-    else if ( handler->type == Audio )
+    else if ( cookie[0] == WorkflowRenderer::AudioCookie )
     {
         ret = handler->self->lockAudio( handler, pts, bufferSize, buffer );
         if ( paused == false )
             handler->self->m_mainWorkflow->nextFrame( MainWorkflow::AudioTrack );
     }
     else
-        qCritical() << "Invalid ES type";
+        qCritical() << "Invalid imem cookie";
     return ret;
 }
 
diff --git a/src/Renderer/WorkflowRenderer.h b/src/Renderer/WorkflowRenderer.h
index 9ffa851..c42c944 100644
--- a/src/Renderer/WorkflowRenderer.h
+++ b/src/Renderer/WorkflowRenderer.h
@@ -53,6 +53,8 @@ class   WorkflowRenderer : public GenericRenderer
             Video, ///< Video type
             Subtitle ///< This is clearly not used by VLMC, but it fits imem module's model
         };
+        static const quint8     VideoCookie = '0';
+        static const quint8     AudioCookie = '1';
         /**
          *  \brief  This struct will be the type of the callback parameter
          *          in the lock / unlock callbacks
@@ -60,7 +62,7 @@ class   WorkflowRenderer : public GenericRenderer
         struct  EsHandler
         {
             WorkflowRenderer*   self; ///< The 'this' pointer will be passed in this field
-            EsType              type; ///< The elementary stream type
+            //Fixme: this should go away I guess...
             double              fps; ///< The fps to use for this rendering session.
         };
 
@@ -178,13 +180,14 @@ class   WorkflowRenderer : public GenericRenderer
          *
          *  This callback will query the MainWorkflow for a frame or an audio sample
          *  \param  data        The callback data, this is most likely to be an EsHandler
+         *  \param  cookie      The input identifier.
          *  \param  dts         Unused, but provided by imem
          *  \param  pts         The pts for the buffer that will be provided
          *  \param  flags       Unused but provided by imem
          *  \param  bufferSize  The size of the buffer that will be provided
          *  \param  buffer      The buffer itself.
          */
-        static int          lock( void *data, qint64 *dts, qint64 *pts,
+        static int          lock( void *data, const char* cookie, qint64 *dts, qint64 *pts,
                                 quint32 *flags, size_t *bufferSize, void **buffer );
         /**
          *  \brief  "Subcallback", for video frame injection
@@ -273,8 +276,7 @@ class   WorkflowRenderer : public GenericRenderer
          */
         quint8              *m_silencedAudioBuffer;
         size_t              m_videoBuffSize;
-        EsHandler*          m_videoEsHandler;
-        EsHandler*          m_audioEsHandler;
+        EsHandler*          m_esHandler;
         quint32             m_nbChannels;
         quint32             m_rate;
         /**



More information about the Vlmc-devel mailing list