[vlc-commits] dash: Reworking the way MPD profile is handled
Hugo Beauzée-Luyssen
git at videolan.org
Tue Jan 24 23:21:53 CET 2012
vlc/vlc-1.2 | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Sat Dec 24 15:30:28 2011 +0100| [ce3925e9cf3fb23fe8bda6b75d464fe81bf3c8be] | committer: 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: Jean-Baptiste Kempf <jb at videolan.org>
(cherry picked from commit 04be885bb5b870d5f40b604ab0fa4d62b75040e8)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.2.git/?a=commit;h=ce3925e9cf3fb23fe8bda6b75d464fe81bf3c8be
---
modules/stream_filter/dash/DASHManager.cpp | 5 +--
modules/stream_filter/dash/DASHManager.h | 3 +-
modules/stream_filter/dash/dash.cpp | 5 +--
modules/stream_filter/dash/mpd/BasicCMParser.cpp | 8 +++++-
modules/stream_filter/dash/mpd/MPD.cpp | 22 +++++++++++++++++-
modules/stream_filter/dash/mpd/MPD.h | 5 ++++
.../stream_filter/dash/mpd/MPDManagerFactory.cpp | 24 +++++++------------
modules/stream_filter/dash/mpd/MPDManagerFactory.h | 5 +---
modules/stream_filter/dash/xml/DOMParser.cpp | 8 ------
modules/stream_filter/dash/xml/DOMParser.h | 1 -
10 files changed, 48 insertions(+), 38 deletions(-)
diff --git a/modules/stream_filter/dash/DASHManager.cpp b/modules/stream_filter/dash/DASHManager.cpp
index 3941648..cf4d133 100644
--- a/modules/stream_filter/dash/DASHManager.cpp
+++ b/modules/stream_filter/dash/DASHManager.cpp
@@ -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;
diff --git a/modules/stream_filter/dash/DASHManager.h b/modules/stream_filter/dash/DASHManager.h
index 8a60262..13a3346 100644
--- a/modules/stream_filter/dash/DASHManager.h
+++ b/modules/stream_filter/dash/DASHManager.h
@@ -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;
};
diff --git a/modules/stream_filter/dash/dash.cpp b/modules/stream_filter/dash/dash.cpp
index 896550d..68e4c95 100644
--- a/modules/stream_filter/dash/dash.cpp
+++ b/modules/stream_filter/dash/dash.cpp
@@ -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;
diff --git a/modules/stream_filter/dash/mpd/BasicCMParser.cpp b/modules/stream_filter/dash/mpd/BasicCMParser.cpp
index 786c378..7f6b273 100644
--- a/modules/stream_filter/dash/mpd/BasicCMParser.cpp
+++ b/modules/stream_filter/dash/mpd/BasicCMParser.cpp
@@ -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);
}
diff --git a/modules/stream_filter/dash/mpd/MPD.cpp b/modules/stream_filter/dash/mpd/MPD.cpp
index 309cbbd..c9060c6 100644
--- a/modules/stream_filter/dash/mpd/MPD.cpp
+++ b/modules/stream_filter/dash/mpd/MPD.cpp
@@ -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;
+}
diff --git a/modules/stream_filter/dash/mpd/MPD.h b/modules/stream_filter/dash/mpd/MPD.h
index 80ee6a9..c328af1 100644
--- a/modules/stream_filter/dash/mpd/MPD.h
+++ b/modules/stream_filter/dash/mpd/MPD.h
@@ -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;
diff --git a/modules/stream_filter/dash/mpd/MPDManagerFactory.cpp b/modules/stream_filter/dash/mpd/MPDManagerFactory.cpp
index e3cbca1..ada43b2 100644
--- a/modules/stream_filter/dash/mpd/MPDManagerFactory.cpp
+++ b/modules/stream_filter/dash/mpd/MPDManagerFactory.cpp
@@ -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;
-}
diff --git a/modules/stream_filter/dash/mpd/MPDManagerFactory.h b/modules/stream_filter/dash/mpd/MPDManagerFactory.h
index b5cf9b5..31a3ba1 100644
--- a/modules/stream_filter/dash/mpd/MPDManagerFactory.h
+++ b/modules/stream_filter/dash/mpd/MPDManagerFactory.h
@@ -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 );
};
}
}
diff --git a/modules/stream_filter/dash/xml/DOMParser.cpp b/modules/stream_filter/dash/xml/DOMParser.cpp
index f35cab9..a860236 100644
--- a/modules/stream_filter/dash/xml/DOMParser.cpp
+++ b/modules/stream_filter/dash/xml/DOMParser.cpp
@@ -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";
diff --git a/modules/stream_filter/dash/xml/DOMParser.h b/modules/stream_filter/dash/xml/DOMParser.h
index 611a783..e138efc 100644
--- a/modules/stream_filter/dash/xml/DOMParser.h
+++ b/modules/stream_filter/dash/xml/DOMParser.h
@@ -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:
More information about the vlc-commits
mailing list