[vlc-commits] dash: Reworking MPD tree building.
Hugo Beauzée-Luyssen
git at videolan.org
Tue Jan 24 23:21:57 CET 2012
vlc/vlc-1.2 | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Fri Dec 30 17:46:22 2011 +0100| [5f68d95bdd2a404c86831aa27b7be9aa1655f68c] | committer: Jean-Baptiste Kempf
dash: Reworking MPD tree building.
First build a DOM tree, then compute the MPD tree.
This should ease the pain later when implementing UrlTemplate elements.
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
(cherry picked from commit 139175ef38c4a12a1ced914dcb043206830e21c8)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.2.git/?a=commit;h=5f68d95bdd2a404c86831aa27b7be9aa1655f68c
---
modules/stream_filter/dash/DASHManager.cpp | 16 ++++++----
modules/stream_filter/dash/DASHManager.h | 6 ++-
modules/stream_filter/dash/dash.cpp | 30 ++++++++++++--------
modules/stream_filter/dash/mpd/BasicCMParser.cpp | 8 ++++-
modules/stream_filter/dash/mpd/BasicCMParser.h | 14 ++++++---
.../stream_filter/dash/mpd/MPDManagerFactory.cpp | 13 ++------
modules/stream_filter/dash/mpd/MPDManagerFactory.h | 4 +--
7 files changed, 51 insertions(+), 40 deletions(-)
diff --git a/modules/stream_filter/dash/DASHManager.cpp b/modules/stream_filter/dash/DASHManager.cpp
index cf4d133..08205cb 100644
--- a/modules/stream_filter/dash/DASHManager.cpp
+++ b/modules/stream_filter/dash/DASHManager.cpp
@@ -34,15 +34,17 @@ using namespace dash::logic;
using namespace dash::mpd;
using namespace dash::exception;
-DASHManager::DASHManager ( HTTPConnectionManager *conManager, Node *node, IAdaptationLogic::LogicType type )
+DASHManager::DASHManager ( HTTPConnectionManager *conManager, MPD *mpd,
+ IAdaptationLogic::LogicType type ) :
+ conManager( conManager ),
+ currentChunk( NULL ),
+ adaptationLogic( NULL ),
+ logicType( type ),
+ mpdManager( NULL ),
+ mpd( mpd )
{
- this->conManager = conManager;
- this->node = node;
- this->logicType = type;
- this->mpdManager = mpd::MPDManagerFactory::create(this->node);
+ this->mpdManager = mpd::MPDManagerFactory::create( mpd );
this->adaptationLogic = AdaptationLogicFactory::create( this->logicType, this->mpdManager );
- this->currentChunk = NULL;
-
this->conManager->attach(this->adaptationLogic);
}
DASHManager::~DASHManager ()
diff --git a/modules/stream_filter/dash/DASHManager.h b/modules/stream_filter/dash/DASHManager.h
index 13a3346..a1370f9 100644
--- a/modules/stream_filter/dash/DASHManager.h
+++ b/modules/stream_filter/dash/DASHManager.h
@@ -32,13 +32,15 @@
#include "mpd/IMPDManager.h"
#include "mpd/MPDManagerFactory.h"
#include "exceptions/EOFException.h"
+#include "mpd/MPD.h"
namespace dash
{
class DASHManager
{
public:
- DASHManager (http::HTTPConnectionManager *conManager, xml::Node *node, logic::IAdaptationLogic::LogicType type);
+ DASHManager( http::HTTPConnectionManager *conManager, mpd::MPD *mpd,
+ logic::IAdaptationLogic::LogicType type );
virtual ~DASHManager ();
int read (void *p_buffer, size_t len);
@@ -50,8 +52,8 @@ namespace dash
http::Chunk *currentChunk;
logic::IAdaptationLogic *adaptationLogic;
logic::IAdaptationLogic::LogicType logicType;
- xml::Node *node;
mpd::IMPDManager *mpdManager;
+ mpd::MPD *mpd;
};
}
diff --git a/modules/stream_filter/dash/dash.cpp b/modules/stream_filter/dash/dash.cpp
index 45c1905..d99fc4f 100644
--- a/modules/stream_filter/dash/dash.cpp
+++ b/modules/stream_filter/dash/dash.cpp
@@ -38,6 +38,7 @@
#include "xml/DOMParser.h"
#include "http/HTTPConnectionManager.h"
#include "adaptationlogic/IAdaptationLogic.h"
+#include "mpd/BasicCMParser.h"
#define SEEK 0
@@ -63,7 +64,7 @@ struct stream_sys_t
{
dash::DASHManager *p_dashManager;
dash::http::HTTPConnectionManager *p_conManager;
- dash::xml::Node *p_node;
+ dash::mpd::MPD *p_mpd;
int position;
bool isLive;
};
@@ -82,35 +83,40 @@ static int Open(vlc_object_t *p_obj)
if(!dash::xml::DOMParser::isDash(p_stream->p_source))
return VLC_EGENERIC;
- dash::xml::DOMParser parser(p_stream->p_source);
- if(!parser.parse())
+ //Build a XML tree
+ dash::xml::DOMParser parser(p_stream->p_source);
+ if( !parser.parse() )
{
- msg_Dbg(p_stream, "could not parse mpd file");
+ msg_Dbg( p_stream, "Could not parse mpd file." );
+ return VLC_EGENERIC;
+ }
+ //Begin the actual MPD parsing:
+ dash::mpd::BasicCMParser mpdParser( parser.getRootNode(), p_stream->p_source );
+ if ( mpdParser.parse() == false || mpdParser.getMPD() == NULL )
+ {
+ msg_Err( p_obj, "MPD file parsing failed." );
return VLC_EGENERIC;
}
- stream_sys_t *p_sys = (stream_sys_t *) malloc(sizeof(stream_sys_t));
-
+ stream_sys_t *p_sys = (stream_sys_t *) malloc(sizeof(stream_sys_t));
if (unlikely(p_sys == NULL))
return VLC_ENOMEM;
+ p_sys->p_mpd = mpdParser.getMPD();
dash::http::HTTPConnectionManager *p_conManager =
- new dash::http::HTTPConnectionManager(p_stream);
- dash::xml::Node *p_node = parser.getRootNode();
+ new dash::http::HTTPConnectionManager( p_stream );
dash::DASHManager*p_dashManager =
- new dash::DASHManager( p_conManager, p_node,
- dash::logic::IAdaptationLogic::RateBased );
+ new dash::DASHManager( p_conManager, p_sys->p_mpd,
+ dash::logic::IAdaptationLogic::RateBased );
if ( p_dashManager->getMpdManager()->getMPD() == NULL )
{
- msg_Err( p_obj, "MPD file parsing failed." );
delete p_conManager;
delete p_dashManager;
free( p_sys );
return VLC_EGENERIC;
}
p_sys->p_dashManager = p_dashManager;
- p_sys->p_node = p_node;
p_sys->p_conManager = p_conManager;
p_sys->position = 0;
p_sys->isLive = p_dashManager->getMpdManager()->getMPD()->isLive();
diff --git a/modules/stream_filter/dash/mpd/BasicCMParser.cpp b/modules/stream_filter/dash/mpd/BasicCMParser.cpp
index 7ca943a..ae7d4dc 100644
--- a/modules/stream_filter/dash/mpd/BasicCMParser.cpp
+++ b/modules/stream_filter/dash/mpd/BasicCMParser.cpp
@@ -32,13 +32,19 @@
#include <sstream>
#include <vlc_common.h>
+#include <vlc_stream.h>
#include <vlc_strings.h>
using namespace dash::mpd;
using namespace dash::xml;
-BasicCMParser::BasicCMParser (Node *root) : root(root), mpd(NULL)
+BasicCMParser::BasicCMParser( Node *root, stream_t *p_stream ) :
+ root( root ),
+ mpd( NULL )
{
+ this->url = p_stream->psz_access;
+ this->url += "://";
+ this->url += p_stream->psz_path;
}
BasicCMParser::~BasicCMParser ()
diff --git a/modules/stream_filter/dash/mpd/BasicCMParser.h b/modules/stream_filter/dash/mpd/BasicCMParser.h
index ba0d078..0d3328a 100644
--- a/modules/stream_filter/dash/mpd/BasicCMParser.h
+++ b/modules/stream_filter/dash/mpd/BasicCMParser.h
@@ -36,6 +36,8 @@
#include "mpd/SegmentInfo.h"
#include "mpd/Segment.h"
+struct stream_t;
+
namespace dash
{
namespace mpd
@@ -43,8 +45,8 @@ namespace dash
class BasicCMParser : public IMPDParser
{
public:
- BasicCMParser (dash::xml::Node *root);
- virtual ~BasicCMParser ();
+ BasicCMParser( dash::xml::Node *root, stream_t *p_stream );
+ virtual ~BasicCMParser();
bool parse ();
MPD* getMPD ();
@@ -53,9 +55,6 @@ namespace dash
void handleDependencyId( Representation* rep, const Group* group, const std::string& dependencyId );
private:
- dash::xml::Node *root;
- MPD *mpd;
-
bool setMPD ();
void setPeriods (dash::xml::Node *root);
void setGroups (dash::xml::Node *root, Period *period);
@@ -73,6 +72,11 @@ namespace dash
CommonAttributesElements *parent ) const;
bool parseSegment( Segment *seg, const std::map<std::string, std::string> &attr );
ProgramInformation* parseProgramInformation();
+
+ private:
+ dash::xml::Node *root;
+ MPD *mpd;
+ std::string url;
};
}
}
diff --git a/modules/stream_filter/dash/mpd/MPDManagerFactory.cpp b/modules/stream_filter/dash/mpd/MPDManagerFactory.cpp
index cc79f29..13e72f9 100644
--- a/modules/stream_filter/dash/mpd/MPDManagerFactory.cpp
+++ b/modules/stream_filter/dash/mpd/MPDManagerFactory.cpp
@@ -28,21 +28,14 @@
#include "mpd/MPDManagerFactory.h"
using namespace dash::mpd;
-using namespace dash::xml;
-IMPDManager* MPDManagerFactory::create( Node *root )
+IMPDManager* MPDManagerFactory::create( MPD *mpd )
{
- BasicCMParser parser(root);
-
- if ( parser.parse() == false )
- return NULL;
-
- Profile profile = parser.getMPD()->getProfile();
- switch( profile )
+ switch( mpd->getProfile() )
{
case mpd::BasicCM:
case mpd::Full2011:
- return new BasicCMManager( parser.getMPD() );
+ return new BasicCMManager( mpd );
case mpd::Basic:
case mpd::UnknownProfile:
default:
diff --git a/modules/stream_filter/dash/mpd/MPDManagerFactory.h b/modules/stream_filter/dash/mpd/MPDManagerFactory.h
index 5c8114b..317cfa9 100644
--- a/modules/stream_filter/dash/mpd/MPDManagerFactory.h
+++ b/modules/stream_filter/dash/mpd/MPDManagerFactory.h
@@ -27,8 +27,6 @@
#include "mpd/IMPDManager.h"
#include "mpd/BasicCMManager.h"
-#include "mpd/BasicCMParser.h"
-#include "xml/Node.h"
namespace dash
{
@@ -37,7 +35,7 @@ namespace dash
class MPDManagerFactory
{
public:
- static IMPDManager* create( xml::Node *root );
+ static IMPDManager* create( MPD *mpd );
};
}
}
More information about the vlc-commits
mailing list