[vlc-commits] dash: Reworking ProgramInfo parsing.
Hugo Beauzée-Luyssen
git at videolan.org
Fri Dec 30 18:15:31 CET 2011
vlc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Sun Dec 25 00:14:23 2011 +0100| [5457d47757f63d9d5716468e7148c7e4f41bf5ea] | committer: Jean-Baptiste Kempf
dash: Reworking ProgramInfo parsing.
Information are now computed once at parsing time.
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5457d47757f63d9d5716468e7148c7e4f41bf5ea
---
modules/stream_filter/dash/mpd/BasicCMParser.cpp | 24 +++++++++
modules/stream_filter/dash/mpd/BasicCMParser.h | 1 +
modules/stream_filter/dash/mpd/MPD.cpp | 6 +--
modules/stream_filter/dash/mpd/MPD.h | 6 +-
.../stream_filter/dash/mpd/ProgramInformation.cpp | 53 ++++++++------------
.../stream_filter/dash/mpd/ProgramInformation.h | 27 +++++-----
6 files changed, 64 insertions(+), 53 deletions(-)
diff --git a/modules/stream_filter/dash/mpd/BasicCMParser.cpp b/modules/stream_filter/dash/mpd/BasicCMParser.cpp
index cdab94a..fdf463c 100644
--- a/modules/stream_filter/dash/mpd/BasicCMParser.cpp
+++ b/modules/stream_filter/dash/mpd/BasicCMParser.cpp
@@ -116,6 +116,7 @@ bool BasicCMParser::setMPD()
this->setMPDBaseUrl(this->root);
this->setPeriods(this->root);
+ this->mpd->setProgramInformation( this->parseProgramInformation() );
return true;
}
void BasicCMParser::setMPDBaseUrl (Node *root)
@@ -263,6 +264,29 @@ bool BasicCMParser::parseSegment(Segment *seg, const std::map<std::string, std::
return true;
}
+ProgramInformation* BasicCMParser::parseProgramInformation()
+{
+ Node* pInfoNode = DOMHelper::getFirstChildElementByName( this->root, "ProgramInformation" );
+ if ( pInfoNode == NULL )
+ return NULL;
+ ProgramInformation *pInfo = new ProgramInformation;
+ const std::map<std::string, std::string> attr = pInfoNode->getAttributes();
+ std::map<std::string, std::string>::const_iterator it;
+ it = attr.find( "moreInformationURL" );
+ if ( it != attr.end() )
+ pInfo->setMoreInformationUrl( it->second );
+ Node* title = DOMHelper::getFirstChildElementByName( pInfoNode, "Title" );
+ if ( title )
+ pInfo->setTitle( title->getText() );
+ Node* source = DOMHelper::getFirstChildElementByName( pInfoNode, "Source" );
+ if ( source )
+ pInfo->setSource( source->getText() );
+ Node* copyright = DOMHelper::getFirstChildElementByName( pInfoNode, "copyright" );
+ if ( copyright )
+ pInfo->setCopyright( copyright->getText() );
+ return pInfo;
+}
+
void BasicCMParser::setInitSegment (Node *root, SegmentInfo *info)
{
const std::vector<Node *> initSeg = DOMHelper::getChildElementByTagName(root, "InitialisationSegmentURL");
diff --git a/modules/stream_filter/dash/mpd/BasicCMParser.h b/modules/stream_filter/dash/mpd/BasicCMParser.h
index 9b1d4ad..cfc3847 100644
--- a/modules/stream_filter/dash/mpd/BasicCMParser.h
+++ b/modules/stream_filter/dash/mpd/BasicCMParser.h
@@ -66,6 +66,7 @@ namespace dash
void setMPDBaseUrl (dash::xml::Node *root);
bool parseCommonAttributesElements( dash::xml::Node *node, CommonAttributesElements *common ) const;
bool parseSegment( Segment *seg, const std::map<std::string, std::string> &attr );
+ ProgramInformation* parseProgramInformation();
};
}
}
diff --git a/modules/stream_filter/dash/mpd/MPD.cpp b/modules/stream_filter/dash/mpd/MPD.cpp
index 40a84a3..2973787 100644
--- a/modules/stream_filter/dash/mpd/MPD.cpp
+++ b/modules/stream_filter/dash/mpd/MPD.cpp
@@ -109,13 +109,11 @@ void MPD::setTimeShiftBufferDepth(time_t depth)
this->timeShiftBufferDepth = depth;
}
-ProgramInformation* MPD::getProgramInformation () throw(ElementNotPresentException)
+const ProgramInformation* MPD::getProgramInformation () const
{
- if(this->programInfo == NULL)
- throw ElementNotPresentException();
-
return this->programInfo;
}
+
void MPD::addBaseUrl (BaseUrl *url)
{
this->baseUrls.push_back(url);
diff --git a/modules/stream_filter/dash/mpd/MPD.h b/modules/stream_filter/dash/mpd/MPD.h
index c55b534..4acd9bc 100644
--- a/modules/stream_filter/dash/mpd/MPD.h
+++ b/modules/stream_filter/dash/mpd/MPD.h
@@ -63,9 +63,9 @@ namespace dash
void setMinBufferTime( time_t time );
time_t getTimeShiftBufferDepth() const;
void setTimeShiftBufferDepth( time_t depth );
- const std::vector<BaseUrl *>& getBaseUrls () const;
- const std::vector<Period *>& getPeriods () const;
- ProgramInformation* getProgramInformation () throw(dash::exception::ElementNotPresentException);
+ const std::vector<BaseUrl *>& getBaseUrls() const;
+ const std::vector<Period *>& getPeriods() const;
+ const ProgramInformation* getProgramInformation() const;
void addPeriod (Period *period);
void addBaseUrl (BaseUrl *url);
diff --git a/modules/stream_filter/dash/mpd/ProgramInformation.cpp b/modules/stream_filter/dash/mpd/ProgramInformation.cpp
index 669ee8e..11e665e 100644
--- a/modules/stream_filter/dash/mpd/ProgramInformation.cpp
+++ b/modules/stream_filter/dash/mpd/ProgramInformation.cpp
@@ -30,52 +30,41 @@
using namespace dash::mpd;
using namespace dash::exception;
-ProgramInformation::ProgramInformation (std::map<std::string, std::string> attr)
-{
- this->attributes = attr;
-}
-ProgramInformation::~ProgramInformation ()
+const std::string &ProgramInformation::getSource() const
{
+ return this->source;
}
-std::string ProgramInformation::getTitle () throw(ElementNotPresentException)
+void ProgramInformation::setSource(const std::string &source)
{
- if(this->title.empty())
- throw ElementNotPresentException();
-
- return this->title;
+ if ( source.empty() == false )
+ this->source = source;
}
-std::string ProgramInformation::getCopyright () throw(ElementNotPresentException)
-{
- if(this->copyright.empty())
- throw ElementNotPresentException();
+const std::string &ProgramInformation::getCopyright() const
+{
return this->copyright;
}
-std::string ProgramInformation::getSource () throw(ElementNotPresentException)
-{
- if(this->source.empty())
- throw ElementNotPresentException();
- return this->source;
-}
-std::string ProgramInformation::getMoreInformationUrl () throw(AttributeNotPresentException)
+void ProgramInformation::setCopyright(const std::string ©right)
{
- if(this->attributes.find("moreInformationURL") == this->attributes.end())
- throw AttributeNotPresentException();
-
- return this->attributes["moreInformationURL"];
-
+ if ( copyright.empty() == false )
+ this->copyright = copyright;
}
-void ProgramInformation::setTitle (std::string title)
+
+void ProgramInformation::setMoreInformationUrl(const std::string &url)
{
- this->title = title;
+ if ( url.empty() == false )
+ this->moreInformationUrl = url;
}
-void ProgramInformation::setCopyright (std::string copyright)
+
+const std::string &ProgramInformation::getTitle() const
{
- this->copyright = copyright;
+ return this->title;
}
-void ProgramInformation::setSource (std::string source)
+
+void ProgramInformation::setTitle (const std::string &title)
{
- this->source = source;
+ if ( title.empty() == false )
+ this->title = title;
}
diff --git a/modules/stream_filter/dash/mpd/ProgramInformation.h b/modules/stream_filter/dash/mpd/ProgramInformation.h
index 44b22f8..04df8aa 100644
--- a/modules/stream_filter/dash/mpd/ProgramInformation.h
+++ b/modules/stream_filter/dash/mpd/ProgramInformation.h
@@ -38,23 +38,22 @@ namespace dash
class ProgramInformation
{
public:
- ProgramInformation (std::map<std::string, std::string> attr);
- virtual ~ProgramInformation ();
+ virtual ~ProgramInformation(){}
- std::string getMoreInformationUrl () throw(dash::exception::AttributeNotPresentException);
- std::string getTitle () throw(dash::exception::ElementNotPresentException);
- std::string getSource () throw(dash::exception::ElementNotPresentException);
- std::string getCopyright () throw(dash::exception::ElementNotPresentException);
-
- void setTitle (std::string title);
- void setSource (std::string source);
- void setCopyright (std::string copyright);
+ const std::string& getMoreInformationUrl() const;
+ void setMoreInformationUrl( const std::string &url );
+ const std::string& getTitle() const;
+ void setTitle( const std::string &title);
+ const std::string& getSource() const;
+ void setSource( const std::string &source);
+ const std::string& getCopyright() const;
+ void setCopyright( const std::string ©right);
private:
- std::map<std::string, std::string> attributes;
- std::string title;
- std::string source;
- std::string copyright;
+ std::string moreInformationUrl;
+ std::string title;
+ std::string source;
+ std::string copyright;
};
}
}
More information about the vlc-commits
mailing list