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

dash: added buffer and downloader to manager

Signed-off-by: default avatarHugo Beauzée-Luyssen <beauze.h@gmail.com>
parent 2ef51274
...@@ -32,17 +32,18 @@ using namespace dash::http; ...@@ -32,17 +32,18 @@ using namespace dash::http;
using namespace dash::xml; using namespace dash::xml;
using namespace dash::logic; using namespace dash::logic;
using namespace dash::mpd; using namespace dash::mpd;
using namespace dash::buffer;
using namespace dash::exception; using namespace dash::exception;
DASHManager::DASHManager ( HTTPConnectionManager *conManager, MPD *mpd, DASHManager::DASHManager ( HTTPConnectionManager *conManager, MPD *mpd,
IAdaptationLogic::LogicType type, stream_t *stream) : IAdaptationLogic::LogicType type, stream_t *stream) :
conManager( conManager ), conManager ( conManager ),
currentChunk( NULL ), currentChunk ( NULL ),
adaptationLogic( NULL ), adaptationLogic( NULL ),
logicType( type ), logicType ( type ),
mpdManager( NULL ), mpdManager ( NULL ),
mpd( mpd ), mpd ( mpd ),
stream(stream) stream (stream)
{ {
this->mpdManager = mpd::MPDManagerFactory::create( mpd ); this->mpdManager = mpd::MPDManagerFactory::create( mpd );
if ( this->mpdManager == NULL ) if ( this->mpdManager == NULL )
...@@ -51,54 +52,30 @@ DASHManager::DASHManager ( HTTPConnectionManager *conManager, MPD *mpd, ...@@ -51,54 +52,30 @@ DASHManager::DASHManager ( HTTPConnectionManager *conManager, MPD *mpd,
if ( this->adaptationLogic == NULL ) if ( this->adaptationLogic == NULL )
return ; return ;
this->conManager->attach(this->adaptationLogic); this->conManager->attach(this->adaptationLogic);
this->buffer = new BlockBuffer(this->stream);
this->downloader = new DASHDownloader(this->conManager, this->adaptationLogic, this->buffer);
} }
DASHManager::~DASHManager () DASHManager::~DASHManager ()
{ {
delete this->downloader;
delete this->buffer;
delete this->adaptationLogic; delete this->adaptationLogic;
delete this->mpdManager; delete this->mpdManager;
} }
bool DASHManager::start()
{
return this->downloader->start();
}
int DASHManager::read( void *p_buffer, size_t len ) int DASHManager::read( void *p_buffer, size_t len )
{ {
if ( this->currentChunk == NULL ) return this->buffer->get(p_buffer, len);
{
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;
} }
int DASHManager::peek( const uint8_t **pp_peek, size_t i_peek ) int DASHManager::peek( const uint8_t **pp_peek, size_t i_peek )
{ {
if ( this->currentChunk == NULL ) return this->buffer->peek(pp_peek, i_peek);
{
try
{
this->currentChunk = this->adaptationLogic->getNextChunk();
}
catch(EOFException &e)
{
return 0;
}
}
int ret = this->conManager->peek( this->currentChunk, pp_peek, i_peek );
return ret;
} }
const mpd::IMPDManager* DASHManager::getMpdManager() const const mpd::IMPDManager* DASHManager::getMpdManager() const
......
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
#include "adaptationlogic/AdaptationLogicFactory.h" #include "adaptationlogic/AdaptationLogicFactory.h"
#include "mpd/IMPDManager.h" #include "mpd/IMPDManager.h"
#include "mpd/MPDManagerFactory.h" #include "mpd/MPDManagerFactory.h"
#include "buffer/BlockBuffer.h"
#include "DASHDownloader.h"
#include "exceptions/EOFException.h" #include "exceptions/EOFException.h"
#include "mpd/MPD.h" #include "mpd/MPD.h"
...@@ -43,9 +45,11 @@ namespace dash ...@@ -43,9 +45,11 @@ namespace dash
logic::IAdaptationLogic::LogicType type, stream_t *stream); logic::IAdaptationLogic::LogicType type, stream_t *stream);
virtual ~DASHManager (); virtual ~DASHManager ();
int read( void *p_buffer, size_t len ); bool start ();
int peek( const uint8_t **pp_peek, size_t i_peek ); int read ( void *p_buffer, size_t len );
const mpd::IMPDManager* getMpdManager() const; int peek ( const uint8_t **pp_peek, size_t i_peek );
const mpd::IMPDManager* getMpdManager () const;
const logic::IAdaptationLogic* getAdaptionLogic() const; const logic::IAdaptationLogic* getAdaptionLogic() const;
const http::Chunk *getCurrentChunk() const; const http::Chunk *getCurrentChunk() const;
...@@ -57,6 +61,8 @@ namespace dash ...@@ -57,6 +61,8 @@ namespace dash
mpd::IMPDManager *mpdManager; mpd::IMPDManager *mpdManager;
mpd::MPD *mpd; mpd::MPD *mpd;
stream_t *stream; stream_t *stream;
DASHDownloader *downloader;
buffer::BlockBuffer *buffer;
}; };
} }
......
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