Commit ce3925e9 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>
(cherry picked from commit 04be885bb5b870d5f40b604ab0fa4d62b75040e8)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 227e3c35
...@@ -34,13 +34,12 @@ using namespace dash::logic; ...@@ -34,13 +34,12 @@ using namespace dash::logic;
using namespace dash::mpd; using namespace dash::mpd;
using namespace dash::exception; 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->conManager = conManager;
this->node = node; this->node = node;
this->logicType = type; this->logicType = type;
this->profile = profile; this->mpdManager = mpd::MPDManagerFactory::create(this->node);
this->mpdManager = mpd::MPDManagerFactory::create(this->profile, this->node);
this->adaptationLogic = AdaptationLogicFactory::create( this->logicType, this->mpdManager ); this->adaptationLogic = AdaptationLogicFactory::create( this->logicType, this->mpdManager );
this->currentChunk = NULL; this->currentChunk = NULL;
......
...@@ -38,7 +38,7 @@ namespace dash ...@@ -38,7 +38,7 @@ namespace dash
class DASHManager class DASHManager
{ {
public: 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 (); virtual ~DASHManager ();
int read (void *p_buffer, size_t len); int read (void *p_buffer, size_t len);
...@@ -50,7 +50,6 @@ namespace dash ...@@ -50,7 +50,6 @@ namespace dash
http::Chunk *currentChunk; http::Chunk *currentChunk;
logic::IAdaptationLogic *adaptationLogic; logic::IAdaptationLogic *adaptationLogic;
logic::IAdaptationLogic::LogicType logicType; logic::IAdaptationLogic::LogicType logicType;
mpd::Profile profile;
xml::Node *node; xml::Node *node;
mpd::IMPDManager *mpdManager; mpd::IMPDManager *mpdManager;
}; };
......
...@@ -98,9 +98,8 @@ static int Open(vlc_object_t *p_obj) ...@@ -98,9 +98,8 @@ static int Open(vlc_object_t *p_obj)
new dash::http::HTTPConnectionManager(p_stream); new dash::http::HTTPConnectionManager(p_stream);
dash::xml::Node *p_node = parser.getRootNode(); dash::xml::Node *p_node = parser.getRootNode();
dash::DASHManager*p_dashManager = dash::DASHManager*p_dashManager =
new dash::DASHManager(p_conManager, p_node, new dash::DASHManager( p_conManager, p_node,
dash::logic::IAdaptationLogic::RateBased, dash::logic::IAdaptationLogic::RateBased );
parser.getProfile(p_node));
p_sys->p_dashManager = p_dashManager; p_sys->p_dashManager = p_dashManager;
p_sys->p_node = p_node; p_sys->p_node = p_node;
......
...@@ -51,7 +51,13 @@ bool BasicCMParser::parse () ...@@ -51,7 +51,13 @@ bool BasicCMParser::parse ()
} }
void BasicCMParser::setMPD () 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->setMPDBaseUrl(this->root);
this->setPeriods(this->root); this->setPeriods(this->root);
} }
......
...@@ -30,7 +30,9 @@ ...@@ -30,7 +30,9 @@
using namespace dash::mpd; using namespace dash::mpd;
using namespace dash::exception; using namespace dash::exception;
MPD::MPD (const AttributesMap& attributes) : attributes( attributes ), MPD::MPD (const AttributesMap& attributes) :
profile( dash::mpd::NotValid ),
attributes( attributes ),
programInfo( NULL ) programInfo( NULL )
{ {
} }
...@@ -104,3 +106,21 @@ bool MPD::isLive() const ...@@ -104,3 +106,21 @@ bool MPD::isLive() const
*/ */
return ( it != this->attributes.end() && it->second == "Live" ); 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 @@ ...@@ -34,6 +34,7 @@
#include "mpd/ProgramInformation.h" #include "mpd/ProgramInformation.h"
#include "exceptions/AttributeNotPresentException.h" #include "exceptions/AttributeNotPresentException.h"
#include "exceptions/ElementNotPresentException.h" #include "exceptions/ElementNotPresentException.h"
#include "mpd/IMPDManager.h"
namespace dash namespace dash
{ {
...@@ -47,6 +48,9 @@ namespace dash ...@@ -47,6 +48,9 @@ namespace dash
MPD (const AttributesMap& attributes); MPD (const AttributesMap& attributes);
virtual ~MPD(); virtual ~MPD();
Profile getProfile() const;
void setProfile( const std::string &strProfile );
void setProfile( Profile profile );
bool isLive() const; bool isLive() const;
const std::string& getDuration () const throw(dash::exception::AttributeNotPresentException); const std::string& getDuration () const throw(dash::exception::AttributeNotPresentException);
const std::string& getMinBufferTime () const throw(dash::exception::AttributeNotPresentException); const std::string& getMinBufferTime () const throw(dash::exception::AttributeNotPresentException);
...@@ -59,6 +63,7 @@ namespace dash ...@@ -59,6 +63,7 @@ namespace dash
void setProgramInformation (ProgramInformation *progInfo); void setProgramInformation (ProgramInformation *progInfo);
private: private:
Profile profile;
AttributesMap attributes; AttributesMap attributes;
std::vector<Period *> periods; std::vector<Period *> periods;
std::vector<BaseUrl *> baseUrls; std::vector<BaseUrl *> baseUrls;
......
...@@ -30,27 +30,21 @@ ...@@ -30,27 +30,21 @@
using namespace dash::mpd; using namespace dash::mpd;
using namespace dash::xml; 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::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::Full2011: return new NullManager();
case mpd::NotValid: return new NullManager(); case mpd::NotValid: return new NullManager();
default: 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 ...@@ -38,10 +38,7 @@ namespace dash
class MPDManagerFactory class MPDManagerFactory
{ {
public: public:
static IMPDManager* create(Profile profile, dash::xml::Node *root); static IMPDManager* create( xml::Node *root );
private:
static IMPDManager* createBasicCMManager(dash::xml::Node *root);
}; };
} }
} }
......
...@@ -132,15 +132,7 @@ void DOMParser::print () ...@@ -132,15 +132,7 @@ void DOMParser::print ()
{ {
this->print(this->root, 0); 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) bool DOMParser::isDash (stream_t *stream)
{ {
const char* psz_namespace = "urn:mpeg:mpegB:schema:DASH:MPD:DIS2011"; const char* psz_namespace = "urn:mpeg:mpegB:schema:DASH:MPD:DIS2011";
......
...@@ -54,7 +54,6 @@ namespace dash ...@@ -54,7 +54,6 @@ namespace dash
bool parse (); bool parse ();
Node* getRootNode (); Node* getRootNode ();
void print (); void print ();
dash::mpd::Profile getProfile (dash::xml::Node *node);
static bool isDash (stream_t *stream); static bool isDash (stream_t *stream);
private: 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