Commit 8adb8fa8 authored by Christopher Mueller's avatar Christopher Mueller Committed by Hugo Beauzée-Luyssen

dash: added bufferobserver to adaptationlogic

Signed-off-by: default avatarHugo Beauzée-Luyssen <beauze.h@gmail.com>
parent e5fee3df
...@@ -51,10 +51,12 @@ DASHManager::DASHManager ( HTTPConnectionManager *conManager, MPD *mpd, ...@@ -51,10 +51,12 @@ DASHManager::DASHManager ( HTTPConnectionManager *conManager, MPD *mpd,
this->adaptationLogic = AdaptationLogicFactory::create( this->logicType, this->mpdManager, this->stream); this->adaptationLogic = AdaptationLogicFactory::create( this->logicType, this->mpdManager, this->stream);
if ( this->adaptationLogic == NULL ) if ( this->adaptationLogic == NULL )
return ; 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->downloader = new DASHDownloader(this->conManager, this->adaptationLogic, this->buffer);
this->conManager->attach(this->adaptationLogic);
this->buffer->attach(this->adaptationLogic);
} }
DASHManager::~DASHManager () DASHManager::~DASHManager ()
{ {
......
...@@ -36,7 +36,9 @@ AbstractAdaptationLogic::AbstractAdaptationLogic (IMPDManager *mpdManager, st ...@@ -36,7 +36,9 @@ AbstractAdaptationLogic::AbstractAdaptationLogic (IMPDManager *mpdManager, st
bpsAvg (-1), bpsAvg (-1),
bpsLastChunk (0), bpsLastChunk (0),
mpdManager (mpdManager), mpdManager (mpdManager),
stream (stream) stream (stream),
bufferedMicroSec (0),
bufferedPercent (0)
{ {
} }
...@@ -44,6 +46,11 @@ AbstractAdaptationLogic::~AbstractAdaptationLogic () ...@@ -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) void AbstractAdaptationLogic::downloadRateChanged (long bpsAvg, long bpsLastChunk)
{ {
this->bpsAvg = bpsAvg; this->bpsAvg = bpsAvg;
......
...@@ -48,6 +48,7 @@ namespace dash ...@@ -48,6 +48,7 @@ namespace dash
virtual ~AbstractAdaptationLogic (); virtual ~AbstractAdaptationLogic ();
virtual void downloadRateChanged (long bpsAvg, long bpsLastChunk); virtual void downloadRateChanged (long bpsAvg, long bpsLastChunk);
virtual void bufferLevelChanged (mtime_t bufferedMicroSec, int bufferedPercent);
long getBpsAvg () const; long getBpsAvg () const;
long getBpsLastChunk () const; long getBpsLastChunk () const;
...@@ -57,6 +58,8 @@ namespace dash ...@@ -57,6 +58,8 @@ namespace dash
long bpsLastChunk; long bpsLastChunk;
dash::mpd::IMPDManager *mpdManager; dash::mpd::IMPDManager *mpdManager;
stream_t *stream; stream_t *stream;
mtime_t bufferedMicroSec;
int bufferedPercent;
}; };
} }
} }
......
...@@ -29,12 +29,13 @@ ...@@ -29,12 +29,13 @@
#include <adaptationlogic/IDownloadRateObserver.h> #include <adaptationlogic/IDownloadRateObserver.h>
#include <exceptions/EOFException.h> #include <exceptions/EOFException.h>
#include "mpd/Representation.h" #include "mpd/Representation.h"
#include "buffer/IBufferObserver.h"
namespace dash namespace dash
{ {
namespace logic namespace logic
{ {
class IAdaptationLogic : public IDownloadRateObserver class IAdaptationLogic : public IDownloadRateObserver, public dash::buffer::IBufferObserver
{ {
public: public:
......
...@@ -105,6 +105,7 @@ int BlockBuffer::get (void *p_data, unsigned int len) ...@@ -105,6 +105,7 @@ int BlockBuffer::get (void *p_data, unsigned int len)
block_GetBytes(&this->buffer, (uint8_t *)p_data, ret); block_GetBytes(&this->buffer, (uint8_t *)p_data, ret);
block_BytestreamFlush(&this->buffer); block_BytestreamFlush(&this->buffer);
this->notify();
vlc_cond_signal(&this->empty); vlc_cond_signal(&this->empty);
vlc_mutex_unlock(&this->monitorMutex); vlc_mutex_unlock(&this->monitorMutex);
...@@ -128,6 +129,7 @@ void BlockBuffer::put (block_t *block) ...@@ -128,6 +129,7 @@ void BlockBuffer::put (block_t *block)
this->sizeBytes += block->i_buffer; this->sizeBytes += block->i_buffer;
block_BytestreamPush(&this->buffer, block); block_BytestreamPush(&this->buffer, block);
this->notify();
vlc_cond_signal(&this->full); vlc_cond_signal(&this->full);
vlc_mutex_unlock(&this->monitorMutex); vlc_mutex_unlock(&this->monitorMutex);
...@@ -154,7 +156,7 @@ void BlockBuffer::attach (IBufferObserver *observer) ...@@ -154,7 +156,7 @@ void BlockBuffer::attach (IBufferObserver *observer)
void BlockBuffer::notify () void BlockBuffer::notify ()
{ {
for(size_t i = 0; i < this->bufferObservers.size(); i++) 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) void BlockBuffer::reduceBufferMilliSec (size_t bytes)
{ {
......
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