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

dash: CommonAttributesElements: When applicable, convert attributes to integers

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 7972dbae
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
#include "CommonAttributesElements.h" #include "CommonAttributesElements.h"
#include <cstdlib>
using namespace dash::mpd; using namespace dash::mpd;
using namespace dash::exception; using namespace dash::exception;
...@@ -37,43 +39,43 @@ CommonAttributesElements::~CommonAttributesElements() ...@@ -37,43 +39,43 @@ CommonAttributesElements::~CommonAttributesElements()
delete this->contentProtection; delete this->contentProtection;
} }
std::string CommonAttributesElements::getWidth () const throw(AttributeNotPresentException) int CommonAttributesElements::getWidth () const
{ {
std::map<std::string, std::string>::const_iterator it = this->attributes.find("width"); std::map<std::string, std::string>::const_iterator it = this->attributes.find("width");
if ( it == this->attributes.end()) if ( it == this->attributes.end())
throw AttributeNotPresentException(); return -1;
return it->second; return atoi( it->second.c_str() );
} }
std::string CommonAttributesElements::getHeight () const throw(AttributeNotPresentException) int CommonAttributesElements::getHeight () const
{ {
std::map<std::string, std::string>::const_iterator it = this->attributes.find("height"); std::map<std::string, std::string>::const_iterator it = this->attributes.find("height");
if ( it == this->attributes.end() ) if ( it == this->attributes.end() )
throw AttributeNotPresentException(); return -1;
return it->second; return atoi( it->second.c_str() );
} }
std::string CommonAttributesElements::getParX () const throw(AttributeNotPresentException) int CommonAttributesElements::getParX () const
{ {
std::map<std::string, std::string>::const_iterator it = this->attributes.find("parx"); std::map<std::string, std::string>::const_iterator it = this->attributes.find("parx");
if ( it == this->attributes.end()) if ( it == this->attributes.end() )
throw AttributeNotPresentException(); return 1; //Default value is defined in standard's §5.4.3.2.2
return it->second; return atoi( it->second.c_str() );
} }
std::string CommonAttributesElements::getParY () const throw(AttributeNotPresentException) int CommonAttributesElements::getParY () const
{ {
std::map<std::string, std::string>::const_iterator it = this->attributes.find("pary"); std::map<std::string, std::string>::const_iterator it = this->attributes.find("pary");
if ( it == this->attributes.end() ) if ( it == this->attributes.end() )
throw AttributeNotPresentException(); return 1; //Default value is defined in standard's §5.4.3.2.2
return it->second; return atoi( it->second.c_str() );
} }
...@@ -84,16 +86,15 @@ std::string CommonAttributesElements::getLang () const t ...@@ -84,16 +86,15 @@ std::string CommonAttributesElements::getLang () const t
throw AttributeNotPresentException(); throw AttributeNotPresentException();
return it->second; return it->second;
} }
std::string CommonAttributesElements::getFrameRate () const throw(AttributeNotPresentException) int CommonAttributesElements::getFrameRate () const
{ {
std::map<std::string, std::string>::const_iterator it = this->attributes.find("frameRate"); std::map<std::string, std::string>::const_iterator it = this->attributes.find("frameRate");
if ( it == this->attributes.end()) if ( it == this->attributes.end())
throw AttributeNotPresentException(); return -1;
return it->second; return atoi( it->second.c_str() );
} }
......
...@@ -41,12 +41,12 @@ namespace dash ...@@ -41,12 +41,12 @@ namespace dash
public: public:
CommonAttributesElements( const std::map<std::string, std::string>& attributes ); CommonAttributesElements( const std::map<std::string, std::string>& attributes );
virtual ~CommonAttributesElements(); virtual ~CommonAttributesElements();
std::string getWidth () const throw(dash::exception::AttributeNotPresentException); int getWidth () const;
std::string getHeight () const throw(dash::exception::AttributeNotPresentException); int getHeight () const;
std::string getParX () const throw(dash::exception::AttributeNotPresentException); int getParX () const;
std::string getParY () const throw(dash::exception::AttributeNotPresentException); int getParY () const;
std::string getLang () const throw(dash::exception::AttributeNotPresentException); std::string getLang () const throw(dash::exception::AttributeNotPresentException);
std::string getFrameRate () const throw(dash::exception::AttributeNotPresentException); int getFrameRate () const;
std::string getNumberOfChannels () const throw(dash::exception::AttributeNotPresentException); std::string getNumberOfChannels () const throw(dash::exception::AttributeNotPresentException);
std::string getSamplingRate () const throw(dash::exception::AttributeNotPresentException); std::string getSamplingRate () const throw(dash::exception::AttributeNotPresentException);
ContentProtection* getContentProtection () const throw(dash::exception::ElementNotPresentException); ContentProtection* getContentProtection () const throw(dash::exception::ElementNotPresentException);
......
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