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

dash: Representation: Return a usable bandwith value.

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
(cherry picked from commit dce9c498c06e1c2bd4907dda58ebde3f6331814f)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 4fec43cf
...@@ -80,7 +80,7 @@ Representation* BasicCMManager::getBestRepresentation (Period *period) ...@@ -80,7 +80,7 @@ Representation* BasicCMManager::getBestRepresentation (Period *period)
{ {
try try
{ {
long currentBitrate = atol(reps.at(j)->getBandwidth().c_str()); long currentBitrate = reps.at(j)->getBandwidth();
if(currentBitrate > bitrate) if(currentBitrate > bitrate)
{ {
bitrate = currentBitrate; bitrate = currentBitrate;
...@@ -119,7 +119,7 @@ Representation* BasicCMManager::getRepresentation (Period *period, ...@@ -119,7 +119,7 @@ Representation* BasicCMManager::getRepresentation (Period *period,
{ {
try try
{ {
long currentBitrate = atol(reps.at(j)->getBandwidth().c_str()); long currentBitrate = reps.at(j)->getBandwidth();
long dif = bitrate - currentBitrate; long dif = bitrate - currentBitrate;
if(bestDif == -1) if(bestDif == -1)
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
# include "config.h" # include "config.h"
#endif #endif
#include <cstdlib>
#include "Representation.h" #include "Representation.h"
using namespace dash::mpd; using namespace dash::mpd;
...@@ -126,13 +128,13 @@ std::string Representation::getWidth () const throw(Attri ...@@ -126,13 +128,13 @@ std::string Representation::getWidth () const throw(Attri
return it->second; 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"); std::map<std::string, std::string>::const_iterator it = this->attributes.find("bandwidth");
if ( it == this->attributes.end()) 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) std::string Representation::getNumberOfChannels () const throw(AttributeNotPresentException)
......
...@@ -52,7 +52,12 @@ namespace dash ...@@ -52,7 +52,12 @@ namespace dash
std::string getLang () const throw(dash::exception::AttributeNotPresentException); std::string getLang () const throw(dash::exception::AttributeNotPresentException);
std::string getFrameRate () const throw(dash::exception::AttributeNotPresentException); std::string getFrameRate () const throw(dash::exception::AttributeNotPresentException);
std::string getId () 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 getDependencyId () const throw(dash::exception::AttributeNotPresentException);
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);
......
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