Commit d38bc3a0 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen Committed by Jean-Baptiste Kempf

dash: BasicCMParser: Check for attributes at parsing time.

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
(cherry picked from commit d2b3b80413ed152f77d376ffea9aa7605857ed29)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 1ea33a1f
...@@ -27,6 +27,9 @@ ...@@ -27,6 +27,9 @@
#include "BasicCMParser.h" #include "BasicCMParser.h"
#include <cstdlib>
#include <sstream>
using namespace dash::mpd; using namespace dash::mpd;
using namespace dash::xml; using namespace dash::xml;
...@@ -87,7 +90,14 @@ void BasicCMParser::setRepresentations (Node *root, Group *group) ...@@ -87,7 +90,14 @@ void BasicCMParser::setRepresentations (Node *root, Group *group)
for(size_t i = 0; i < representations.size(); i++) 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); this->setSegmentInfo(representations.at(i), rep);
if ( rep->getSegmentInfo() && rep->getSegmentInfo()->getSegments().size() > 0 ) if ( rep->getSegmentInfo() && rep->getSegmentInfo()->getSegments().size() > 0 )
group->addRepresentation(rep); group->addRepresentation(rep);
...@@ -131,3 +141,70 @@ MPD* BasicCMParser::getMPD () ...@@ -131,3 +141,70 @@ MPD* BasicCMParser::getMPD ()
{ {
return this->mpd; 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;
}
...@@ -62,6 +62,7 @@ namespace dash ...@@ -62,6 +62,7 @@ namespace dash
void setInitSegment (dash::xml::Node *root, SegmentInfo *info); void setInitSegment (dash::xml::Node *root, SegmentInfo *info);
void setSegments (dash::xml::Node *root, SegmentInfo *info); void setSegments (dash::xml::Node *root, SegmentInfo *info);
void setMPDBaseUrl (dash::xml::Node *root); void setMPDBaseUrl (dash::xml::Node *root);
bool parseCommonAttributesElements( dash::xml::Node *node, CommonAttributesElements *common ) const;
}; };
} }
} }
......
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