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