Commit 3a3e44f3 authored by Francois Cartegnie's avatar Francois Cartegnie

demux: adaptative: move xml stuff out of dash specific code

parent 65433f09
......@@ -325,7 +325,13 @@ libadaptative_plugin_la_SOURCES = \
demux/adaptative/tools/Helper.h \
demux/adaptative/tools/Properties.hpp \
demux/adaptative/tools/Retrieve.cpp \
demux/adaptative/tools/Retrieve.hpp
demux/adaptative/tools/Retrieve.hpp \
demux/adaptative/xml/DOMHelper.cpp \
demux/adaptative/xml/DOMHelper.h \
demux/adaptative/xml/DOMParser.cpp \
demux/adaptative/xml/DOMParser.h \
demux/adaptative/xml/Node.cpp \
demux/adaptative/xml/Node.h
libadaptative_dash_SOURCES = \
demux/dash/mpd/AdaptationSet.cpp \
......@@ -354,12 +360,6 @@ libadaptative_dash_SOURCES = \
demux/dash/mpd/TrickModeType.h \
demux/dash/mp4/AtomsReader.cpp \
demux/dash/mp4/AtomsReader.hpp \
demux/dash/xml/DOMHelper.cpp \
demux/dash/xml/DOMHelper.h \
demux/dash/xml/DOMParser.cpp \
demux/dash/xml/DOMParser.h \
demux/dash/xml/Node.cpp \
demux/dash/xml/Node.h \
demux/dash/DASHManager.cpp \
demux/dash/DASHManager.h \
demux/dash/DASHStream.cpp \
......
......@@ -33,8 +33,8 @@
#include <vlc_demux.h>
#include "playlist/BasePeriod.h"
#include "xml/DOMParser.h"
#include "../dash/xml/DOMParser.h"
#include "../dash/mpd/MPDFactory.h"
#include "../dash/DASHManager.h"
#include "../dash/DASHStream.hpp"
......@@ -47,8 +47,8 @@
using namespace adaptative::logic;
using namespace adaptative::playlist;
using namespace adaptative::xml;
using namespace dash::mpd;
using namespace dash::xml;
using namespace dash;
using namespace hls;
using namespace hls::playlist;
......@@ -130,8 +130,7 @@ static int Open(vlc_object_t *p_obj)
}
//Begin the actual MPD parsing:
MPD *p_playlist = MPDFactory::create(parser.getRootNode(), p_demux->s,
playlisturl, parser.getProfile());
MPD *p_playlist = MPDFactory::create(parser.getRootNode(), p_demux->s, playlisturl);
if(p_playlist == NULL)
{
msg_Err( p_demux, "Cannot create/unknown MPD for profile");
......
......@@ -27,7 +27,7 @@
#include "DOMHelper.h"
using namespace dash::xml;
using namespace adaptative::xml;
std::vector<Node *> DOMHelper::getElementByTagName (Node *root, const std::string& name, bool selfContain)
{
......
......@@ -30,7 +30,7 @@
#include "Node.h"
namespace dash
namespace adaptative
{
namespace xml
{
......
......@@ -31,8 +31,7 @@
#include <stack>
#include <vlc_xml.h>
using namespace dash::xml;
using namespace dash::mpd;
using namespace adaptative::xml;
DOMParser::DOMParser (stream_t *stream) :
root( NULL ),
......@@ -165,26 +164,4 @@ void DOMParser::print ()
this->print(this->root, 0);
}
Profile DOMParser::getProfile() const
{
Profile res(Profile::Unknown);
if(this->root == NULL)
return res;
std::string urn = this->root->getAttributeValue("profiles");
if ( urn.length() == 0 )
urn = this->root->getAttributeValue("profile"); //The standard spells it the both ways...
size_t pos;
size_t nextpos = -1;
do
{
pos = nextpos + 1;
nextpos = urn.find_first_of(",", pos);
res = Profile(urn.substr(pos, nextpos - pos));
}
while (nextpos != std::string::npos && res == Profile::Unknown);
return res;
}
......@@ -33,9 +33,8 @@
#include <vlc_stream.h>
#include "Node.h"
#include "../mpd/Profile.hpp"
namespace dash
namespace adaptative
{
namespace xml
{
......@@ -48,7 +47,6 @@ namespace dash
bool parse ();
Node* getRootNode ();
void print ();
mpd::Profile getProfile () const;
private:
Node *root;
......
......@@ -31,7 +31,7 @@
#include <vlc_common.h>
#include <vlc_xml.h>
using namespace dash::xml;
using namespace adaptative::xml;
const std::string Node::EmptyString = "";
......
......@@ -29,7 +29,7 @@
#include <string>
#include <map>
namespace dash
namespace adaptative
{
namespace xml
{
......
......@@ -104,8 +104,7 @@ bool DASHManager::updatePlaylist()
}
MPD *newmpd = MPDFactory::create(parser.getRootNode(), mpdstream,
Helper::getDirectoryPath(url).append("/"),
parser.getProfile());
Helper::getDirectoryPath(url).append("/"));
if(newmpd)
{
playlist->mergeWith(newmpd, minsegmentTime);
......
......@@ -39,7 +39,7 @@
#include "AdaptationSet.h"
#include "ProgramInformation.h"
#include "DASHSegment.h"
#include "../xml/DOMHelper.h"
#include "../adaptative/xml/DOMHelper.h"
#include "../adaptative/tools/Helper.h"
#include "../adaptative/tools/Debug.hpp"
#include <vlc_strings.h>
......@@ -47,7 +47,7 @@
#include <cstdio>
using namespace dash::mpd;
using namespace dash::xml;
using namespace adaptative::xml;
using namespace adaptative::playlist;
IsoffMainParser::IsoffMainParser (Node *root_, stream_t *stream, std::string & streambaseurl_)
......@@ -503,6 +503,29 @@ void IsoffMainParser::parseProgramInformation(Node * node, MPD *mpd)
}
}
Profile IsoffMainParser::getProfile() const
{
Profile res(Profile::Unknown);
if(this->root == NULL)
return res;
std::string urn = root->getAttributeValue("profiles");
if ( urn.length() == 0 )
urn = root->getAttributeValue("profile"); //The standard spells it the both ways...
size_t pos;
size_t nextpos = -1;
do
{
pos = nextpos + 1;
nextpos = urn.find_first_of(",", pos);
res = Profile(urn.substr(pos, nextpos - pos));
}
while (nextpos != std::string::npos && res == Profile::Unknown);
return res;
}
IsoTime::IsoTime(const std::string &str)
{
time = str_duration(str.c_str());
......
......@@ -44,15 +44,14 @@ namespace adaptative
class SegmentInformation;
class MediaSegmentTemplate;
}
}
namespace dash
{
namespace xml
{
class Node;
}
}
namespace dash
{
namespace mpd
{
class Period;
......@@ -60,6 +59,7 @@ namespace dash
class MPD;
using namespace adaptative::playlist;
using namespace adaptative;
class IsoffMainParser
{
......@@ -70,6 +70,7 @@ namespace dash
bool parse (Profile profile);
virtual MPD* getMPD ();
virtual void setMPDBaseUrl(xml::Node *root);
mpd::Profile getProfile() const;
private:
void setMPDAttributes ();
......
......@@ -29,28 +29,18 @@
#include "MPDFactory.h"
#include "IsoffMainParser.h"
using namespace dash::xml;
using namespace dash::mpd;
using namespace adaptative::xml;
MPD* MPDFactory::create(Node *root, stream_t *p_stream,
std::string & playlisturl, Profile profile)
MPD* MPDFactory::create(Node *root, stream_t *p_stream, std::string & playlisturl)
{
IsoffMainParser *parser = NULL;
switch( profile )
{
case Profile::Unknown:
break;
default:
parser = new (std::nothrow) IsoffMainParser(root, p_stream, playlisturl);
break;
}
IsoffMainParser *parser = new (std::nothrow) IsoffMainParser(root, p_stream, playlisturl);
if(!parser)
return NULL;
MPD* mpd = NULL;
if(parser->parse(profile))
Profile profile = parser->getProfile();
if(!(profile == Profile::Unknown) && parser->parse(profile))
mpd = parser->getMPD();
delete parser;
......
......@@ -27,20 +27,24 @@
#include "MPD.h"
#include "Profile.hpp"
namespace dash
namespace adaptative
{
namespace xml
{
class Node;
}
}
namespace dash
{
namespace mpd
{
using namespace adaptative;
class MPDFactory
{
public:
static MPD* create(xml::Node *root, stream_t *p_stream,
std::string &, Profile profile);
static MPD* create(xml::Node *root, stream_t *p_stream, std::string &);
};
}
}
......
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