[vlc-commits] dash: BasicCMParser: Check for attributes at parsing time.
Hugo Beauzée-Luyssen
git at videolan.org
Tue Jan 24 23:21:51 CET 2012
vlc/vlc-1.2 | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Mon Dec 19 23:57:02 2011 +0100| [d38bc3a09f450959c1171f1754c44e2d6fccd40f] | committer: Jean-Baptiste Kempf
dash: BasicCMParser: Check for attributes at parsing time.
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
(cherry picked from commit d2b3b80413ed152f77d376ffea9aa7605857ed29)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.2.git/?a=commit;h=d38bc3a09f450959c1171f1754c44e2d6fccd40f
---
modules/stream_filter/dash/mpd/BasicCMParser.cpp | 79 +++++++++++++++++++++-
modules/stream_filter/dash/mpd/BasicCMParser.h | 1 +
2 files changed, 79 insertions(+), 1 deletions(-)
diff --git a/modules/stream_filter/dash/mpd/BasicCMParser.cpp b/modules/stream_filter/dash/mpd/BasicCMParser.cpp
index feb12ca..7d162e3 100644
--- a/modules/stream_filter/dash/mpd/BasicCMParser.cpp
+++ b/modules/stream_filter/dash/mpd/BasicCMParser.cpp
@@ -27,6 +27,9 @@
#include "BasicCMParser.h"
+#include <cstdlib>
+#include <sstream>
+
using namespace dash::mpd;
using namespace dash::xml;
@@ -87,7 +90,14 @@ void BasicCMParser::setRepresentations (Node *root, Group *group)
for(size_t i = 0; i < representations.size(); i++)
{
- Representation *rep = new Representation(representations.at(i)->getAttributes());
+ const std::map<std::string, std::string> attributes = representations.at(i)->getAttributes();
+
+ Representation *rep = new Representation( attributes );
+ if ( this->parseCommonAttributesElements( representations.at( i ), rep ) == false )
+ {
+ delete rep;
+ continue ;
+ }
this->setSegmentInfo(representations.at(i), rep);
if ( rep->getSegmentInfo() && rep->getSegmentInfo()->getSegments().size() > 0 )
group->addRepresentation(rep);
@@ -131,3 +141,70 @@ MPD* BasicCMParser::getMPD ()
{
return this->mpd;
}
+
+bool BasicCMParser::parseCommonAttributesElements( Node *node, CommonAttributesElements *common) const
+{
+ const std::map<std::string, std::string> &attr = node->getAttributes();
+ std::map<std::string, std::string>::const_iterator it;
+ //Parse mandatory elements first.
+ it = attr.find( "mimeType" );
+ if ( it == attr.end() )
+ {
+ std::cerr << "Missing mandatory attribute: @mimeType" << std::endl;
+ return false;
+ }
+ common->setMimeType( it->second );
+ //Everything else is optionnal.
+ it = attr.find( "width" );
+ if ( it != attr.end() )
+ common->setWidth( atoi( it->second.c_str() ) );
+ it = attr.find( "height" );
+ if ( it != attr.end() )
+ common->setHeight( atoi( it->second.c_str() ) );
+ it = attr.find( "parx" );
+ if ( it != attr.end() )
+ common->setParX( atoi( it->second.c_str() ) );
+ it = attr.find( "pary" );
+ if ( it != attr.end() )
+ common->setParY( atoi( it->second.c_str() ) );
+ it = attr.find( "frameRate" );
+ if ( it != attr.end() )
+ common->setFrameRate( atoi( it->second.c_str() ) );
+ it = attr.find( "lang" );
+
+ if ( it != attr.end() && it->second.empty() == false )
+ {
+ std::istringstream s( it->second );
+ while ( s )
+ {
+ std::string lang;
+ s >> lang;
+ common->addLang( lang );
+ }
+ }
+ it = attr.find( "numberOfChannels" );
+ if ( it != attr.end() )
+ {
+ std::istringstream s( it->second );
+ while ( s )
+ {
+ std::string channel;
+ s >> channel;
+ common->addChannel( channel );
+ }
+ }
+ it = attr.find( "samplingRate" );
+ if ( it != attr.end() )
+ {
+ std::istringstream s( it->second );
+ while ( s )
+ {
+ int rate;
+ s >> rate;
+ common->addSampleRate( rate );
+ }
+ }
+ //FIXME: Handle : group, maximumRAPPeriod startWithRAP attributes
+ //FIXME: Handle : ContentProtection Accessibility Rating Viewpoing MultipleViews elements
+ return true;
+}
diff --git a/modules/stream_filter/dash/mpd/BasicCMParser.h b/modules/stream_filter/dash/mpd/BasicCMParser.h
index 5813b91..e8ad31e 100644
--- a/modules/stream_filter/dash/mpd/BasicCMParser.h
+++ b/modules/stream_filter/dash/mpd/BasicCMParser.h
@@ -62,6 +62,7 @@ namespace dash
void setInitSegment (dash::xml::Node *root, SegmentInfo *info);
void setSegments (dash::xml::Node *root, SegmentInfo *info);
void setMPDBaseUrl (dash::xml::Node *root);
+ bool parseCommonAttributesElements( dash::xml::Node *node, CommonAttributesElements *common ) const;
};
}
}
More information about the vlc-commits
mailing list