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,
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 ()
{
......
......@@ -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;
......
......@@ -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;
};
}
}
......
......@@ -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:
......
......@@ -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)
{
......
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