stream_filter/dash/mpd/ContentDescription.h \
stream_filter/dash/mpd/IMPDManager.h \
stream_filter/dash/mpd/IMPDManager.cpp \
+ stream_filter/dash/mpd/IMPDParser.cpp \
stream_filter/dash/mpd/IMPDParser.h \
stream_filter/dash/mpd/IsoffMainParser.cpp \
stream_filter/dash/mpd/IsoffMainParser.h \
#include "mpd/SegmentInfoDefault.h"
#include "mpd/SegmentTemplate.h"
#include "mpd/SegmentTimeline.h"
+#include "xml/DOMHelper.h"
#include <cstdlib>
#include <sstream>
-#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, stream_t *p_stream ) :
- root( root ),
- mpd( NULL ),
- p_stream( p_stream ),
- currentRepresentation( NULL )
+BasicCMParser::BasicCMParser( Node *root_, stream_t *p_stream ) :
+ IMPDParser( root_, NULL, p_stream, NULL )
{
this->url = p_stream->psz_access;
this->url += "://";
}
bool BasicCMParser::parse ()
-{
- return this->setMPD();
-}
-bool BasicCMParser::setMPD()
{
const std::map<std::string, std::string> attr = this->root->getAttributes();
this->mpd = new MPD;
this->mpd->setProgramInformation( this->parseProgramInformation() );
return true;
}
-void BasicCMParser::setMPDBaseUrl (Node *root)
-{
- std::vector<Node *> baseUrls = DOMHelper::getChildElementByTagName(root, "BaseURL");
-
- for(size_t i = 0; i < baseUrls.size(); i++)
- {
- BaseUrl *url = new BaseUrl(baseUrls.at(i)->getText());
- this->mpd->addBaseUrl(url);
- }
-}
-
-void BasicCMParser::setPeriods (Node *root)
-{
- std::vector<Node *> periods = DOMHelper::getElementByTagName(root, "Period", false);
-
- for(size_t i = 0; i < periods.size(); i++)
- {
- Period *period = new Period();
- this->setAdaptationSet(periods.at(i), period);
- this->mpd->addPeriod(period);
- }
-}
void BasicCMParser::parseSegmentTimeline(Node *node, SegmentInfoCommon *segmentInfo)
{
}
}
-void BasicCMParser::setAdaptationSet (Node *root, Period *period)
+void BasicCMParser::setAdaptationSets(Node *root, Period *period)
{
std::vector<Node *> adaptSets = DOMHelper::getElementByTagName(root, "AdaptationSet", false);
if ( adaptSets.size() == 0 ) //In some old file, AdaptationSet may still be called Group
return true;
}
-MPD* BasicCMParser::getMPD()
-{
- return this->mpd;
-}
-
void BasicCMParser::parseContentDescriptor(Node *node, const std::string &name, void (CommonAttributesElements::*addPtr)(ContentDescription *), CommonAttributesElements *self) const
{
std::vector<Node*> descriptors = DOMHelper::getChildElementByTagName( node, name );
#define BASICCMPARSER_H_
#include "xml/Node.h"
-#include "xml/DOMHelper.h"
#include "mpd/IMPDParser.h"
-#include "mpd/MPD.h"
-#include "mpd/Period.h"
#include "mpd/AdaptationSet.h"
-#include "mpd/Representation.h"
#include "mpd/BaseUrl.h"
#include "mpd/SegmentInfo.h"
#include "mpd/Segment.h"
virtual ~BasicCMParser();
bool parse ();
- MPD* getMPD ();
private:
void handleDependencyId( Representation* rep, const AdaptationSet* adaptationSet, const std::string& dependencyId );
private:
- bool setMPD ();
- void setPeriods (dash::xml::Node *root);
void parseSegmentTimeline( xml::Node* node, SegmentInfoCommon *segmentInfo );
void parseSegmentInfoCommon( xml::Node* node, SegmentInfoCommon *segmentInfo );
void parseSegmentInfoDefault( xml::Node* node, AdaptationSet* group );
- void setAdaptationSet (dash::xml::Node *root, Period *period);
+ void setAdaptationSets (dash::xml::Node *root, Period *period);
void parseTrickMode( dash::xml::Node *node, Representation *repr );
void setRepresentations (dash::xml::Node *root, AdaptationSet *group);
bool setSegmentInfo (dash::xml::Node *root, Representation *rep);
void setInitSegment (dash::xml::Node *root, SegmentInfoCommon *info);
bool setSegments (dash::xml::Node *root, SegmentInfo *info );
bool resolveUrlTemplates( std::string &url, bool &containRuntimeToken );
- void setMPDBaseUrl (dash::xml::Node *root);
void parseContentDescriptor( xml::Node *node, const std::string &name,
void (CommonAttributesElements::*addPtr)(ContentDescription*),
CommonAttributesElements *self ) const;
ProgramInformation* parseProgramInformation();
private:
- dash::xml::Node *root;
- MPD *mpd;
std::string url;
- stream_t *p_stream;
- Representation *currentRepresentation;
};
}
}
--- /dev/null
+/*
+ * IMPDParser.cpp
+ *****************************************************************************
+ * Copyright (C) 2010 - 2014 VideoLAN Authors
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+#include "IMPDParser.h"
+#include "xml/DOMHelper.h"
+
+using namespace dash::mpd;
+using namespace dash::xml;
+
+IMPDParser::IMPDParser(Node *root_, MPD *mpd_, stream_t *stream, Representation *rep)
+{
+ root = root_;
+ mpd = mpd_;
+ currentRepresentation = rep;
+ p_stream = stream;
+}
+
+void IMPDParser::setMPDBaseUrl(Node *root)
+{
+ std::vector<Node *> baseUrls = DOMHelper::getChildElementByTagName(root, "BaseURL");
+
+ for(size_t i = 0; i < baseUrls.size(); i++)
+ {
+ BaseUrl *url = new BaseUrl(baseUrls.at(i)->getText());
+ mpd->addBaseUrl(url);
+ }
+}
+
+void IMPDParser::setPeriods(Node *root_)
+{
+ std::vector<Node *> periods = DOMHelper::getElementByTagName(root_, "Period", false);
+
+ for(size_t i = 0; i < periods.size(); i++)
+ {
+ Period *period = new Period();
+ setAdaptationSets(periods.at(i), period);
+ mpd->addPeriod(period);
+ }
+}
+
+MPD* IMPDParser::getMPD()
+{
+ return mpd;
+}
#define IMPDPARSER_H_
#include "mpd/MPD.h"
+#include "xml/DOMParser.h"
+
+#include <vlc_common.h>
namespace dash
{
class IMPDParser
{
public:
- virtual bool parse () = 0;
- virtual MPD* getMPD () = 0;
+ IMPDParser(dash::xml::Node *, MPD*, stream_t*, Representation*);
virtual ~IMPDParser(){}
+ virtual bool parse () = 0;
+ virtual MPD* getMPD ();
+ virtual void setMPDBaseUrl(dash::xml::Node *root);
+ virtual void setAdaptationSets(dash::xml::Node *periodNode, Period *period) = 0;
+ virtual void setPeriods(dash::xml::Node *root);
+
+ protected:
+ dash::xml::Node *root;
+ MPD *mpd;
+ stream_t *p_stream;
+ Representation *currentRepresentation;
};
}
}
#endif
#include "IsoffMainParser.h"
+#include "xml/DOMHelper.h"
+#include <vlc_strings.h>
using namespace dash::mpd;
using namespace dash::xml;
IsoffMainParser::IsoffMainParser (Node *root, stream_t *p_stream) :
- root (root),
- p_stream (p_stream),
- mpd (NULL),
- currentRepresentation( NULL )
+ IMPDParser(root, NULL, p_stream, NULL)
{
}
IsoffMainParser::~IsoffMainParser ()
bool IsoffMainParser::parse ()
{
- this->mpd = new MPD();
-
- this->setMPDAttributes();
- this->setMPDBaseUrl();
- this->setPeriods();
- this->print();
-
+ mpd = new MPD();
+ setMPDAttributes();
+ setMPDBaseUrl(root);
+ setPeriods(root);
+ print();
return true;
}
-MPD* IsoffMainParser::getMPD ()
-{
- return this->mpd;
-}
+
void IsoffMainParser::setMPDAttributes ()
{
const std::map<std::string, std::string> attr = this->root->getAttributes();
this->mpd->setMinBufferTime(str_duration( it->second.c_str()));
}
-void IsoffMainParser::setMPDBaseUrl ()
-{
- std::vector<Node *> baseUrls = DOMHelper::getChildElementByTagName(this->root, "BaseURL");
-
- for(size_t i = 0; i < baseUrls.size(); i++)
- {
- BaseUrl *url = new BaseUrl(baseUrls.at(i)->getText());
- this->mpd->addBaseUrl(url);
- }
-}
-void IsoffMainParser::setPeriods ()
-{
- std::vector<Node *> periods = DOMHelper::getElementByTagName(this->root, "Period", false);
- for(size_t i = 0; i < periods.size(); i++)
- {
- Period *period = new Period();
- this->setAdaptationSets(periods.at(i), period);
- this->mpd->addPeriod(period);
- }
-}
void IsoffMainParser::setAdaptationSets (Node *periodNode, Period *period)
{
std::vector<Node *> adaptationSets = DOMHelper::getElementByTagName(periodNode, "AdaptationSet", false);
#define ISOFFMAINPARSER_H_
#include "xml/Node.h"
-#include "xml/DOMHelper.h"
#include "mpd/IMPDParser.h"
-#include "mpd/MPD.h"
-#include "mpd/Period.h"
#include "mpd/AdaptationSet.h"
-#include "mpd/Representation.h"
#include "mpd/BaseUrl.h"
#include "mpd/SegmentBase.h"
#include "mpd/SegmentList.h"
#include <cstdlib>
#include <sstream>
-#include <vlc_common.h>
-#include <vlc_stream.h>
-#include <vlc_strings.h>
-
namespace dash
{
namespace mpd
virtual ~IsoffMainParser ();
bool parse ();
- MPD* getMPD ();
void print ();
private:
- dash::xml::Node *root;
- stream_t *p_stream;
- MPD *mpd;
- Representation *currentRepresentation;
-
void setMPDAttributes ();
- void setMPDBaseUrl ();
- void setPeriods ();
void setAdaptationSets (dash::xml::Node *periodNode, Period *period);
void setRepresentations (dash::xml::Node *adaptationSetNode, AdaptationSet *adaptationSet);
void setSegmentBase (dash::xml::Node *repNode, Representation *rep);