[vlc-commits] dash: CommonAttributesElements: When applicable, convert attributes to integers

Hugo Beauzée-Luyssen git at videolan.org
Thu Dec 8 17:20:31 CET 2011


vlc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Thu Dec  1 15:57:59 2011 +0100| [d314c4f4cac6d055e23a387f6aa2b741aec237da] | committer: Jean-Baptiste Kempf

dash: CommonAttributesElements: When applicable, convert attributes to integers

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d314c4f4cac6d055e23a387f6aa2b741aec237da
---

 .../dash/mpd/CommonAttributesElements.cpp          |   35 ++++++++++---------
 .../dash/mpd/CommonAttributesElements.h            |   10 +++---
 2 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/modules/stream_filter/dash/mpd/CommonAttributesElements.cpp b/modules/stream_filter/dash/mpd/CommonAttributesElements.cpp
index 37aa2a3..7c56376 100644
--- a/modules/stream_filter/dash/mpd/CommonAttributesElements.cpp
+++ b/modules/stream_filter/dash/mpd/CommonAttributesElements.cpp
@@ -23,6 +23,8 @@
 
 #include "CommonAttributesElements.h"
 
+#include <cstdlib>
+
 using namespace dash::mpd;
 using namespace dash::exception;
 
@@ -37,43 +39,43 @@ CommonAttributesElements::~CommonAttributesElements()
     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");
     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");
     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");
-    if ( it == this->attributes.end())
-        throw AttributeNotPresentException();
+    if ( it == this->attributes.end() )
+        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");
     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
         throw AttributeNotPresentException();
 
     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");
     if ( it == this->attributes.end())
-        throw AttributeNotPresentException();
+        return -1;
 
-    return it->second;
+    return atoi( it->second.c_str() );
 
 }
 
diff --git a/modules/stream_filter/dash/mpd/CommonAttributesElements.h b/modules/stream_filter/dash/mpd/CommonAttributesElements.h
index 9248e20..7f69adc 100644
--- a/modules/stream_filter/dash/mpd/CommonAttributesElements.h
+++ b/modules/stream_filter/dash/mpd/CommonAttributesElements.h
@@ -41,12 +41,12 @@ namespace dash
             public:
                 CommonAttributesElements( const std::map<std::string, std::string>& attributes );
                 virtual ~CommonAttributesElements();
-                std::string         getWidth                () const throw(dash::exception::AttributeNotPresentException);
-                std::string         getHeight               () const throw(dash::exception::AttributeNotPresentException);
-                std::string         getParX                 () const throw(dash::exception::AttributeNotPresentException);
-                std::string         getParY                 () const throw(dash::exception::AttributeNotPresentException);
+                int                 getWidth                () const;
+                int                 getHeight               () const;
+                int                 getParX                 () const;
+                int                 getParY                 () const;
                 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         getSamplingRate         () const throw(dash::exception::AttributeNotPresentException);
                 ContentProtection*  getContentProtection    () const throw(dash::exception::ElementNotPresentException);



More information about the vlc-commits mailing list