[vlc-devel] [PATCH 7/8] dash: added buffer and downloader to manager

Christopher Mueller christopher.mueller at itec.aau.at
Sun Feb 5 10:34:55 CET 2012


---
 modules/stream_filter/dash/DASHManager.cpp |   60 ++++++++-------------------
 modules/stream_filter/dash/DASHManager.h   |   12 ++++-
 2 files changed, 27 insertions(+), 45 deletions(-)

diff --git a/modules/stream_filter/dash/DASHManager.cpp b/modules/stream_filter/dash/DASHManager.cpp
index 7060d3e..3c5cc08 100644
--- a/modules/stream_filter/dash/DASHManager.cpp
+++ b/modules/stream_filter/dash/DASHManager.cpp
@@ -32,17 +32,18 @@ using namespace dash::http;
 using namespace dash::xml;
 using namespace dash::logic;
 using namespace dash::mpd;
+using namespace dash::buffer;
 using namespace dash::exception;
 
 DASHManager::DASHManager    ( HTTPConnectionManager *conManager, MPD *mpd,
                               IAdaptationLogic::LogicType type, stream_t *stream) :
-    conManager( conManager ),
-    currentChunk( NULL ),
-    adaptationLogic( NULL ),
-    logicType( type ),
-    mpdManager( NULL ),
-    mpd( mpd ),
-    stream(stream)
+             conManager     ( conManager ),
+             currentChunk   ( NULL ),
+             adaptationLogic( NULL ),
+             logicType      ( type ),
+             mpdManager     ( NULL ),
+             mpd            ( mpd ),
+             stream         (stream)
 {
     this->mpdManager        = mpd::MPDManagerFactory::create( mpd );
     if ( this->mpdManager == NULL )
@@ -51,54 +52,29 @@ DASHManager::DASHManager    ( HTTPConnectionManager *conManager, MPD *mpd,
     if ( this->adaptationLogic == NULL )
         return ;
     this->conManager->attach(this->adaptationLogic);
+
+    this->buffer    = new BlockBuffer(this->stream);
+    this->downloader = new DASHDownloader(this->conManager, this->adaptationLogic, this->buffer);
 }
 DASHManager::~DASHManager   ()
 {
+    delete this->downloader;
     delete this->adaptationLogic;
     delete this->mpdManager;
 }
 
+bool    DASHManager::start()
+{
+    return this->downloader->start();
+}
 int     DASHManager::read( void *p_buffer, size_t len )
 {
-    if ( this->currentChunk == NULL )
-    {
-        try
-        {
-            this->currentChunk = this->adaptationLogic->getNextChunk();
-        }
-        catch(EOFException &e)
-        {
-            this->currentChunk = NULL;
-            return 0;
-        }
-    }
-
-    int ret = this->conManager->read( this->currentChunk, p_buffer, len );
-    if ( ret == 0 )
-    {
-        this->currentChunk = NULL;
-        return this->read(p_buffer, len );
-    }
-
-    return ret;
+    return this->buffer->get(p_buffer, len);
 }
 
 int     DASHManager::peek( const uint8_t **pp_peek, size_t i_peek )
 {
-    if ( this->currentChunk == NULL )
-    {
-        try
-        {
-            this->currentChunk = this->adaptationLogic->getNextChunk();
-        }
-        catch(EOFException &e)
-        {
-            return 0;
-        }
-    }
-
-    int ret = this->conManager->peek( this->currentChunk, pp_peek, i_peek );
-    return ret;
+    return this->buffer->peek(pp_peek, i_peek);
 }
 
 const mpd::IMPDManager*         DASHManager::getMpdManager() const
diff --git a/modules/stream_filter/dash/DASHManager.h b/modules/stream_filter/dash/DASHManager.h
index 8fc1c56..6c9d16a 100644
--- a/modules/stream_filter/dash/DASHManager.h
+++ b/modules/stream_filter/dash/DASHManager.h
@@ -31,6 +31,8 @@
 #include "adaptationlogic/AdaptationLogicFactory.h"
 #include "mpd/IMPDManager.h"
 #include "mpd/MPDManagerFactory.h"
+#include "buffer/BlockBuffer.h"
+#include "DASHDownloader.h"
 #include "exceptions/EOFException.h"
 #include "mpd/MPD.h"
 
@@ -43,9 +45,11 @@ namespace dash
                          logic::IAdaptationLogic::LogicType type, stream_t *stream);
             virtual ~DASHManager    ();
 
-            int read( void *p_buffer, size_t len );
-            int peek( const uint8_t **pp_peek, size_t i_peek );
-            const mpd::IMPDManager*         getMpdManager() const;
+            bool    start   ();
+            int     read    ( void *p_buffer, size_t len );
+            int     peek    ( const uint8_t **pp_peek, size_t i_peek );
+
+            const mpd::IMPDManager*         getMpdManager   () const;
             const logic::IAdaptationLogic*  getAdaptionLogic() const;
             const http::Chunk *getCurrentChunk() const;
 
@@ -57,6 +61,8 @@ namespace dash
             mpd::IMPDManager                    *mpdManager;
             mpd::MPD                            *mpd;
             stream_t                            *stream;
+            DASHDownloader                      *downloader;
+            buffer::BlockBuffer                 *buffer;
     };
 }
 
-- 
1.7.0.4




More information about the vlc-devel mailing list