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 139175ef38c4a12a1ced914dcb043206830e21c8)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 356cf412
......@@ -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 ()
......
......@@ -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;
};
}
......
......@@ -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();
......
......@@ -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 ()
......
......@@ -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;
};
}
}
......
......@@ -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:
......
......@@ -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 );
};
}
}
......
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