Commit 5f68d95b authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen Committed by 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: default avatarJean-Baptiste Kempf <jb@videolan.org>
(cherry picked from commit 139175ef)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 356cf412
...@@ -34,15 +34,17 @@ using namespace dash::logic; ...@@ -34,15 +34,17 @@ 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 ) 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->mpdManager = mpd::MPDManagerFactory::create( mpd );
this->node = node;
this->logicType = type;
this->mpdManager = mpd::MPDManagerFactory::create(this->node);
this->adaptationLogic = AdaptationLogicFactory::create( this->logicType, this->mpdManager ); this->adaptationLogic = AdaptationLogicFactory::create( this->logicType, this->mpdManager );
this->currentChunk = NULL;
this->conManager->attach(this->adaptationLogic); this->conManager->attach(this->adaptationLogic);
} }
DASHManager::~DASHManager () DASHManager::~DASHManager ()
......
...@@ -32,13 +32,15 @@ ...@@ -32,13 +32,15 @@
#include "mpd/IMPDManager.h" #include "mpd/IMPDManager.h"
#include "mpd/MPDManagerFactory.h" #include "mpd/MPDManagerFactory.h"
#include "exceptions/EOFException.h" #include "exceptions/EOFException.h"
#include "mpd/MPD.h"
namespace dash namespace dash
{ {
class DASHManager class DASHManager
{ {
public: 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 (); virtual ~DASHManager ();
int read (void *p_buffer, size_t len); int read (void *p_buffer, size_t len);
...@@ -50,8 +52,8 @@ namespace dash ...@@ -50,8 +52,8 @@ namespace dash
http::Chunk *currentChunk; http::Chunk *currentChunk;
logic::IAdaptationLogic *adaptationLogic; logic::IAdaptationLogic *adaptationLogic;
logic::IAdaptationLogic::LogicType logicType; logic::IAdaptationLogic::LogicType logicType;
xml::Node *node;
mpd::IMPDManager *mpdManager; mpd::IMPDManager *mpdManager;
mpd::MPD *mpd;
}; };
} }
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include "xml/DOMParser.h" #include "xml/DOMParser.h"
#include "http/HTTPConnectionManager.h" #include "http/HTTPConnectionManager.h"
#include "adaptationlogic/IAdaptationLogic.h" #include "adaptationlogic/IAdaptationLogic.h"
#include "mpd/BasicCMParser.h"
#define SEEK 0 #define SEEK 0
...@@ -63,7 +64,7 @@ struct stream_sys_t ...@@ -63,7 +64,7 @@ struct stream_sys_t
{ {
dash::DASHManager *p_dashManager; dash::DASHManager *p_dashManager;
dash::http::HTTPConnectionManager *p_conManager; dash::http::HTTPConnectionManager *p_conManager;
dash::xml::Node *p_node; dash::mpd::MPD *p_mpd;
int position; int position;
bool isLive; bool isLive;
}; };
...@@ -82,35 +83,40 @@ static int Open(vlc_object_t *p_obj) ...@@ -82,35 +83,40 @@ static int Open(vlc_object_t *p_obj)
if(!dash::xml::DOMParser::isDash(p_stream->p_source)) if(!dash::xml::DOMParser::isDash(p_stream->p_source))
return VLC_EGENERIC; return VLC_EGENERIC;
dash::xml::DOMParser parser(p_stream->p_source); //Build a XML tree
if(!parser.parse()) 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; 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)) if (unlikely(p_sys == NULL))
return VLC_ENOMEM; return VLC_ENOMEM;
p_sys->p_mpd = mpdParser.getMPD();
dash::http::HTTPConnectionManager *p_conManager = dash::http::HTTPConnectionManager *p_conManager =
new dash::http::HTTPConnectionManager(p_stream); new dash::http::HTTPConnectionManager( p_stream );
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_sys->p_mpd,
dash::logic::IAdaptationLogic::RateBased ); dash::logic::IAdaptationLogic::RateBased );
if ( p_dashManager->getMpdManager()->getMPD() == NULL ) if ( p_dashManager->getMpdManager()->getMPD() == NULL )
{ {
msg_Err( p_obj, "MPD file parsing failed." );
delete p_conManager; delete p_conManager;
delete p_dashManager; delete p_dashManager;
free( p_sys ); free( p_sys );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
p_sys->p_dashManager = p_dashManager; p_sys->p_dashManager = p_dashManager;
p_sys->p_node = p_node;
p_sys->p_conManager = p_conManager; p_sys->p_conManager = p_conManager;
p_sys->position = 0; p_sys->position = 0;
p_sys->isLive = p_dashManager->getMpdManager()->getMPD()->isLive(); p_sys->isLive = p_dashManager->getMpdManager()->getMPD()->isLive();
......
...@@ -32,13 +32,19 @@ ...@@ -32,13 +32,19 @@
#include <sstream> #include <sstream>
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_stream.h>
#include <vlc_strings.h> #include <vlc_strings.h>
using namespace dash::mpd; using namespace dash::mpd;
using namespace dash::xml; 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 () BasicCMParser::~BasicCMParser ()
......
...@@ -36,6 +36,8 @@ ...@@ -36,6 +36,8 @@
#include "mpd/SegmentInfo.h" #include "mpd/SegmentInfo.h"
#include "mpd/Segment.h" #include "mpd/Segment.h"
struct stream_t;
namespace dash namespace dash
{ {
namespace mpd namespace mpd
...@@ -43,8 +45,8 @@ namespace dash ...@@ -43,8 +45,8 @@ namespace dash
class BasicCMParser : public IMPDParser class BasicCMParser : public IMPDParser
{ {
public: public:
BasicCMParser (dash::xml::Node *root); BasicCMParser( dash::xml::Node *root, stream_t *p_stream );
virtual ~BasicCMParser (); virtual ~BasicCMParser();
bool parse (); bool parse ();
MPD* getMPD (); MPD* getMPD ();
...@@ -53,9 +55,6 @@ namespace dash ...@@ -53,9 +55,6 @@ namespace dash
void handleDependencyId( Representation* rep, const Group* group, const std::string& dependencyId ); void handleDependencyId( Representation* rep, const Group* group, const std::string& dependencyId );
private: private:
dash::xml::Node *root;
MPD *mpd;
bool setMPD (); bool setMPD ();
void setPeriods (dash::xml::Node *root); void setPeriods (dash::xml::Node *root);
void setGroups (dash::xml::Node *root, Period *period); void setGroups (dash::xml::Node *root, Period *period);
...@@ -73,6 +72,11 @@ namespace dash ...@@ -73,6 +72,11 @@ namespace dash
CommonAttributesElements *parent ) const; CommonAttributesElements *parent ) const;
bool parseSegment( Segment *seg, const std::map<std::string, std::string> &attr ); bool parseSegment( Segment *seg, const std::map<std::string, std::string> &attr );
ProgramInformation* parseProgramInformation(); ProgramInformation* parseProgramInformation();
private:
dash::xml::Node *root;
MPD *mpd;
std::string url;
}; };
} }
} }
......
...@@ -28,21 +28,14 @@ ...@@ -28,21 +28,14 @@
#include "mpd/MPDManagerFactory.h" #include "mpd/MPDManagerFactory.h"
using namespace dash::mpd; using namespace dash::mpd;
using namespace dash::xml;
IMPDManager* MPDManagerFactory::create( Node *root ) IMPDManager* MPDManagerFactory::create( MPD *mpd )
{ {
BasicCMParser parser(root); switch( mpd->getProfile() )
if ( parser.parse() == false )
return NULL;
Profile profile = parser.getMPD()->getProfile();
switch( profile )
{ {
case mpd::BasicCM: case mpd::BasicCM:
case mpd::Full2011: case mpd::Full2011:
return new BasicCMManager( parser.getMPD() ); return new BasicCMManager( mpd );
case mpd::Basic: case mpd::Basic:
case mpd::UnknownProfile: case mpd::UnknownProfile:
default: default:
......
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
#include "mpd/IMPDManager.h" #include "mpd/IMPDManager.h"
#include "mpd/BasicCMManager.h" #include "mpd/BasicCMManager.h"
#include "mpd/BasicCMParser.h"
#include "xml/Node.h"
namespace dash namespace dash
{ {
...@@ -37,7 +35,7 @@ namespace dash ...@@ -37,7 +35,7 @@ namespace dash
class MPDManagerFactory class MPDManagerFactory
{ {
public: public:
static IMPDManager* create( xml::Node *root ); static IMPDManager* create( MPD *mpd );
}; };
} }
} }
......
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