[vlc-commits] dash: Representation: Return a usable bandwith value.

Hugo Beauzée-Luyssen git at videolan.org
Thu Dec 1 22:10:41 CET 2011


vlc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Wed Nov 30 18:25:58 2011 +0100| [dce9c498c06e1c2bd4907dda58ebde3f6331814f] | committer: Jean-Baptiste Kempf

dash: Representation: Return a usable bandwith value.

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

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

 modules/stream_filter/dash/mpd/BasicCMManager.cpp |    4 ++--
 modules/stream_filter/dash/mpd/Representation.cpp |    8 +++++---
 modules/stream_filter/dash/mpd/Representation.h   |    7 ++++++-
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/modules/stream_filter/dash/mpd/BasicCMManager.cpp b/modules/stream_filter/dash/mpd/BasicCMManager.cpp
index fd1fee1..4a488c6 100644
--- a/modules/stream_filter/dash/mpd/BasicCMManager.cpp
+++ b/modules/stream_filter/dash/mpd/BasicCMManager.cpp
@@ -80,7 +80,7 @@ Representation*         BasicCMManager::getBestRepresentation   (Period *period)
         {
             try
             {
-                long currentBitrate = atol(reps.at(j)->getBandwidth().c_str());
+                long currentBitrate = reps.at(j)->getBandwidth();
                 if(currentBitrate > bitrate)
                 {
                     bitrate = currentBitrate;
@@ -119,7 +119,7 @@ Representation*         BasicCMManager::getRepresentation       (Period *period,
         {
             try
             {
-                long currentBitrate = atol(reps.at(j)->getBandwidth().c_str());
+                long currentBitrate = reps.at(j)->getBandwidth();
                 long dif = bitrate - currentBitrate;
 
                 if(bestDif == -1)
diff --git a/modules/stream_filter/dash/mpd/Representation.cpp b/modules/stream_filter/dash/mpd/Representation.cpp
index 17fd248..0a8a4dc 100644
--- a/modules/stream_filter/dash/mpd/Representation.cpp
+++ b/modules/stream_filter/dash/mpd/Representation.cpp
@@ -25,6 +25,8 @@
 # include "config.h"
 #endif
 
+#include <cstdlib>
+
 #include "Representation.h"
 
 using namespace dash::mpd;
@@ -126,13 +128,13 @@ std::string         Representation::getWidth                () const throw(Attri
     return it->second;
 
 }
-std::string         Representation::getBandwidth            () const throw(AttributeNotPresentException)
+int     Representation::getBandwidth            () const
 {
     std::map<std::string, std::string>::const_iterator  it = this->attributes.find("bandwidth");
     if ( it == this->attributes.end())
-        throw AttributeNotPresentException();
+        return -1;
 
-    return it->second;
+    return atoi( it->second.c_str() ) / 8;
 
 }
 std::string         Representation::getNumberOfChannels     () const throw(AttributeNotPresentException)
diff --git a/modules/stream_filter/dash/mpd/Representation.h b/modules/stream_filter/dash/mpd/Representation.h
index 0a2668c..a47d867 100644
--- a/modules/stream_filter/dash/mpd/Representation.h
+++ b/modules/stream_filter/dash/mpd/Representation.h
@@ -52,7 +52,12 @@ namespace dash
                 std::string         getLang                 () const throw(dash::exception::AttributeNotPresentException);
                 std::string         getFrameRate            () const throw(dash::exception::AttributeNotPresentException);
                 std::string         getId                   () const throw(dash::exception::AttributeNotPresentException);
-                std::string         getBandwidth            () const throw(dash::exception::AttributeNotPresentException);
+                /*
+                 *  @return The bitrate required for this representation
+                 *          in Bytes per seconds.
+                 *          -1 if an error occurs.
+                 */
+                int                 getBandwidth            () const;
                 std::string         getDependencyId         () const throw(dash::exception::AttributeNotPresentException);
                 std::string         getNumberOfChannels     () const throw(dash::exception::AttributeNotPresentException);
                 std::string         getSamplingRate         () const throw(dash::exception::AttributeNotPresentException);



More information about the vlc-commits mailing list