[vlc-commits] dash: added bufferobserver to adaptationlogic

Christopher Mueller git at videolan.org
Mon Feb 20 18:54:07 CET 2012


vlc | branch: master | Christopher Mueller <christopher.mueller at itec.aau.at> | Mon Feb 20 13:49:21 2012 +0100| [8adb8fa8707f0f63c3b850060da66e7272a02a10] | committer: Hugo Beauzée-Luyssen

dash: added bufferobserver to adaptationlogic

Signed-off-by: Hugo Beauzée-Luyssen <beauze.h at gmail.com>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8adb8fa8707f0f63c3b850060da66e7272a02a10
---

 modules/stream_filter/dash/DASHManager.cpp         |    6 ++++--
 .../adaptationlogic/AbstractAdaptationLogic.cpp    |    9 ++++++++-
 .../dash/adaptationlogic/AbstractAdaptationLogic.h |    3 +++
 .../dash/adaptationlogic/IAdaptationLogic.h        |    3 ++-
 modules/stream_filter/dash/buffer/BlockBuffer.cpp  |    4 +++-
 5 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/modules/stream_filter/dash/DASHManager.cpp b/modules/stream_filter/dash/DASHManager.cpp
index 633bb21..a98e01a 100644
--- a/modules/stream_filter/dash/DASHManager.cpp
+++ b/modules/stream_filter/dash/DASHManager.cpp
@@ -51,10 +51,12 @@ DASHManager::DASHManager    ( HTTPConnectionManager *conManager, MPD *mpd,
     this->adaptationLogic   = AdaptationLogicFactory::create( this->logicType, this->mpdManager, this->stream);
     if ( this->adaptationLogic == NULL )
         return ;
-    this->conManager->attach(this->adaptationLogic);
 
-    this->buffer    = new BlockBuffer(this->stream);
+    this->buffer     = new BlockBuffer(this->stream);
     this->downloader = new DASHDownloader(this->conManager, this->adaptationLogic, this->buffer);
+
+    this->conManager->attach(this->adaptationLogic);
+    this->buffer->attach(this->adaptationLogic);
 }
 DASHManager::~DASHManager   ()
 {
diff --git a/modules/stream_filter/dash/adaptationlogic/AbstractAdaptationLogic.cpp b/modules/stream_filter/dash/adaptationlogic/AbstractAdaptationLogic.cpp
index 3945a9f..ebd0a74 100644
--- a/modules/stream_filter/dash/adaptationlogic/AbstractAdaptationLogic.cpp
+++ b/modules/stream_filter/dash/adaptationlogic/AbstractAdaptationLogic.cpp
@@ -36,7 +36,9 @@ AbstractAdaptationLogic::AbstractAdaptationLogic    (IMPDManager *mpdManager, st
                          bpsAvg                     (-1),
                          bpsLastChunk               (0),
                          mpdManager                 (mpdManager),
-                         stream                     (stream)
+                         stream                     (stream),
+                         bufferedMicroSec           (0),
+                         bufferedPercent            (0)
 
 {
 }
@@ -44,6 +46,11 @@ AbstractAdaptationLogic::~AbstractAdaptationLogic   ()
 {
 }
 
+void AbstractAdaptationLogic::bufferLevelChanged     (mtime_t bufferedMicroSec, int bufferedPercent)
+{
+    this->bufferedMicroSec = bufferedMicroSec;
+    this->bufferedPercent  = bufferedPercent;
+}
 void AbstractAdaptationLogic::downloadRateChanged    (long bpsAvg, long bpsLastChunk)
 {
     this->bpsAvg        = bpsAvg;
diff --git a/modules/stream_filter/dash/adaptationlogic/AbstractAdaptationLogic.h b/modules/stream_filter/dash/adaptationlogic/AbstractAdaptationLogic.h
index 7c46d14..97be099 100644
--- a/modules/stream_filter/dash/adaptationlogic/AbstractAdaptationLogic.h
+++ b/modules/stream_filter/dash/adaptationlogic/AbstractAdaptationLogic.h
@@ -48,6 +48,7 @@ namespace dash
                 virtual ~AbstractAdaptationLogic    ();
 
                 virtual void                downloadRateChanged     (long bpsAvg, long bpsLastChunk);
+                virtual void                bufferLevelChanged      (mtime_t bufferedMicroSec, int bufferedPercent);
 
                 long                        getBpsAvg               () const;
                 long                        getBpsLastChunk         () const;
@@ -57,6 +58,8 @@ namespace dash
                 long                    bpsLastChunk;
                 dash::mpd::IMPDManager  *mpdManager;
                 stream_t                *stream;
+                mtime_t                 bufferedMicroSec;
+                int                     bufferedPercent;
         };
     }
 }
diff --git a/modules/stream_filter/dash/adaptationlogic/IAdaptationLogic.h b/modules/stream_filter/dash/adaptationlogic/IAdaptationLogic.h
index 8b11d3a..92b96ed 100644
--- a/modules/stream_filter/dash/adaptationlogic/IAdaptationLogic.h
+++ b/modules/stream_filter/dash/adaptationlogic/IAdaptationLogic.h
@@ -29,12 +29,13 @@
 #include <adaptationlogic/IDownloadRateObserver.h>
 #include <exceptions/EOFException.h>
 #include "mpd/Representation.h"
+#include "buffer/IBufferObserver.h"
 
 namespace dash
 {
     namespace logic
     {
-        class IAdaptationLogic : public IDownloadRateObserver
+        class IAdaptationLogic : public IDownloadRateObserver, public dash::buffer::IBufferObserver
         {
             public:
 
diff --git a/modules/stream_filter/dash/buffer/BlockBuffer.cpp b/modules/stream_filter/dash/buffer/BlockBuffer.cpp
index 7b983d6..2b10358 100644
--- a/modules/stream_filter/dash/buffer/BlockBuffer.cpp
+++ b/modules/stream_filter/dash/buffer/BlockBuffer.cpp
@@ -105,6 +105,7 @@ int     BlockBuffer::get                  (void *p_data, unsigned int len)
 
     block_GetBytes(&this->buffer, (uint8_t *)p_data, ret);
     block_BytestreamFlush(&this->buffer);
+    this->notify();
 
     vlc_cond_signal(&this->empty);
     vlc_mutex_unlock(&this->monitorMutex);
@@ -128,6 +129,7 @@ void    BlockBuffer::put                  (block_t *block)
     this->sizeBytes     += block->i_buffer;
 
     block_BytestreamPush(&this->buffer, block);
+    this->notify();
 
     vlc_cond_signal(&this->full);
     vlc_mutex_unlock(&this->monitorMutex);
@@ -154,7 +156,7 @@ void    BlockBuffer::attach               (IBufferObserver *observer)
 void    BlockBuffer::notify               ()
 {
     for(size_t i = 0; i < this->bufferObservers.size(); i++)
-        this->bufferObservers.at(i)->bufferLevelChanged(this->sizeMicroSec, this->sizeMicroSec / this->capacityMicroSec);
+        this->bufferObservers.at(i)->bufferLevelChanged(this->sizeMicroSec, ((float)this->sizeMicroSec / this->capacityMicroSec) * 100);
 }
 void    BlockBuffer::reduceBufferMilliSec (size_t bytes)
 {



More information about the vlc-commits mailing list