Commit 04be885b authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen Committed by Jean-Baptiste Kempf

dash: Reworking the way MPD profile is handled

It's not the job of the DOMParser to compute a Dash profile. Let the
dash parser handle it.
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent b996a750
......@@ -34,13 +34,12 @@ using namespace dash::logic;
using namespace dash::mpd;
using namespace dash::exception;
DASHManager::DASHManager (HTTPConnectionManager *conManager, Node *node, IAdaptationLogic::LogicType type, Profile profile)
DASHManager::DASHManager ( HTTPConnectionManager *conManager, Node *node, IAdaptationLogic::LogicType type )
{
this->conManager = conManager;
this->node = node;
this->logicType = type;
this->profile = profile;
this->mpdManager = mpd::MPDManagerFactory::create(this->profile, this->node);
this->mpdManager = mpd::MPDManagerFactory::create(this->node);
this->adaptationLogic = AdaptationLogicFactory::create( this->logicType, this->mpdManager );
this->currentChunk = NULL;
......
......@@ -38,7 +38,7 @@ namespace dash
class DASHManager
{
public:
DASHManager (http::HTTPConnectionManager *conManager, xml::Node *node, logic::IAdaptationLogic::LogicType type, mpd::Profile profile);
DASHManager (http::HTTPConnectionManager *conManager, xml::Node *node, logic::IAdaptationLogic::LogicType type);
virtual ~DASHManager ();
int read (void *p_buffer, size_t len);
......@@ -50,7 +50,6 @@ namespace dash
http::Chunk *currentChunk;
logic::IAdaptationLogic *adaptationLogic;
logic::IAdaptationLogic::LogicType logicType;
mpd::Profile profile;
xml::Node *node;
mpd::IMPDManager *mpdManager;
};
......
......@@ -98,9 +98,8 @@ static int Open(vlc_object_t *p_obj)
new dash::http::HTTPConnectionManager(p_stream);
dash::xml::Node *p_node = parser.getRootNode();
dash::DASHManager*p_dashManager =
new dash::DASHManager(p_conManager, p_node,
dash::logic::IAdaptationLogic::RateBased,
parser.getProfile(p_node));
new dash::DASHManager( p_conManager, p_node,
dash::logic::IAdaptationLogic::RateBased );
p_sys->p_dashManager = p_dashManager;
p_sys->p_node = p_node;
......
......@@ -51,7 +51,13 @@ bool BasicCMParser::parse ()
}
void BasicCMParser::setMPD ()
{
this->mpd = new MPD(this->root->getAttributes());
const std::map<std::string, std::string> attr = this->root->getAttributes();
this->mpd = new MPD( attr );
std::map<std::string, std::string>::const_iterator it;
it = attr.find( "profile" );
if ( it != attr.end() )
this->mpd->setProfile( it->second );
this->setMPDBaseUrl(this->root);
this->setPeriods(this->root);
}
......
......@@ -30,7 +30,9 @@
using namespace dash::mpd;
using namespace dash::exception;
MPD::MPD (const AttributesMap& attributes) : attributes( attributes ),
MPD::MPD (const AttributesMap& attributes) :
profile( dash::mpd::NotValid ),
attributes( attributes ),
programInfo( NULL )
{
}
......@@ -104,3 +106,21 @@ bool MPD::isLive() const
*/
return ( it != this->attributes.end() && it->second == "Live" );
}
Profile MPD::getProfile() const
{
return this->profile;
}
void MPD::setProfile(Profile profile)
{
this->profile = profile;
}
void MPD::setProfile( const std::string &strProfile )
{
if( strProfile == "urn:mpeg:mpegB:profile:dash:isoff-basic-on-demand:cm" )
this->profile = dash::mpd::BasicCM;
else
this->profile = dash::mpd::NotValid;
}
......@@ -34,6 +34,7 @@
#include "mpd/ProgramInformation.h"
#include "exceptions/AttributeNotPresentException.h"
#include "exceptions/ElementNotPresentException.h"
#include "mpd/IMPDManager.h"
namespace dash
{
......@@ -47,6 +48,9 @@ namespace dash
MPD (const AttributesMap& attributes);
virtual ~MPD();
Profile getProfile() const;
void setProfile( const std::string &strProfile );
void setProfile( Profile profile );
bool isLive() const;
const std::string& getDuration () const throw(dash::exception::AttributeNotPresentException);
const std::string& getMinBufferTime () const throw(dash::exception::AttributeNotPresentException);
......@@ -59,6 +63,7 @@ namespace dash
void setProgramInformation (ProgramInformation *progInfo);
private:
Profile profile;
AttributesMap attributes;
std::vector<Period *> periods;
std::vector<BaseUrl *> baseUrls;
......
......@@ -30,27 +30,21 @@
using namespace dash::mpd;
using namespace dash::xml;
IMPDManager* MPDManagerFactory::create (Profile profile, Node *root)
IMPDManager* MPDManagerFactory::create( Node *root )
{
switch(profile)
BasicCMParser parser(root);
if ( parser.parse() == false )
return new NullManager();
Profile profile = parser.getMPD()->getProfile();
switch( profile )
{
case mpd::Basic: return new NullManager();
case mpd::BasicCM: return createBasicCMManager(root);
case mpd::BasicCM: return new BasicCMManager( parser.getMPD() );
case mpd::Full2011: return new NullManager();
case mpd::NotValid: return new NullManager();
default: return new NullManager();
}
}
IMPDManager* MPDManagerFactory::createBasicCMManager (Node *root)
{
BasicCMParser parser(root);
if(!parser.parse())
return new NullManager();
BasicCMManager *manager = new BasicCMManager(parser.getMPD());
return manager;
}
......@@ -38,10 +38,7 @@ namespace dash
class MPDManagerFactory
{
public:
static IMPDManager* create(Profile profile, dash::xml::Node *root);
private:
static IMPDManager* createBasicCMManager(dash::xml::Node *root);
static IMPDManager* create( xml::Node *root );
};
}
}
......
......@@ -132,15 +132,7 @@ void DOMParser::print ()
{
this->print(this->root, 0);
}
Profile DOMParser::getProfile (dash::xml::Node *node)
{
std::string profile = node->getAttributeValue("profiles");
if(!profile.compare("urn:mpeg:mpegB:profile:dash:isoff-basic-on-demand:cm"))
return dash::mpd::BasicCM;
return dash::mpd::NotValid;
}
bool DOMParser::isDash (stream_t *stream)
{
const char* psz_namespace = "urn:mpeg:mpegB:schema:DASH:MPD:DIS2011";
......
......@@ -54,7 +54,6 @@ namespace dash
bool parse ();
Node* getRootNode ();
void print ();
dash::mpd::Profile getProfile (dash::xml::Node *node);
static bool isDash (stream_t *stream);
private:
......
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