Commit df975712 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen Committed by Rémi Denis-Courmont

dash: Avoid multiple lookups.

Signed-off-by: default avatarRémi Denis-Courmont <remi@remlab.net>
parent dd159d08
...@@ -60,24 +60,28 @@ std::vector<BaseUrl*> MPD::getBaseUrls () ...@@ -60,24 +60,28 @@ std::vector<BaseUrl*> MPD::getBaseUrls ()
} }
std::string MPD::getMinBufferTime () throw(AttributeNotPresentException) std::string MPD::getMinBufferTime () throw(AttributeNotPresentException)
{ {
if(this->attributes.find("minBufferTime") == this->attributes.end()) AttributesMap::iterator it = this->attributes.find("minBufferTime");
if( it == this->attributes.end())
throw AttributeNotPresentException(); throw AttributeNotPresentException();
return this->attributes["minBufferTime"]; return it->second;
} }
std::string MPD::getType () throw(AttributeNotPresentException) std::string MPD::getType () throw(AttributeNotPresentException)
{ {
if(this->attributes.find("type") == this->attributes.end()) AttributesMap::iterator it = this->attributes.find( "type" );
if( it == this->attributes.end() )
throw AttributeNotPresentException(); throw AttributeNotPresentException();
return this->attributes["type"]; return it->second;
} }
std::string MPD::getDuration () throw(AttributeNotPresentException) std::string MPD::getDuration () throw(AttributeNotPresentException)
{ {
if(this->attributes.find("mediaPresentationDuration") == this->attributes.end()) AttributesMap::iterator it = this->attributes.find("mediaPresentationDuration");
if( it == this->attributes.end())
throw AttributeNotPresentException(); throw AttributeNotPresentException();
return this->attributes["mediaPresentationDuration"]; return it->second;
} }
ProgramInformation* MPD::getProgramInformation () throw(ElementNotPresentException) ProgramInformation* MPD::getProgramInformation () throw(ElementNotPresentException)
{ {
......
...@@ -41,6 +41,8 @@ namespace dash ...@@ -41,6 +41,8 @@ namespace dash
{ {
class MPD class MPD
{ {
typedef std::map<std::string, std::string> AttributesMap;
public: public:
MPD (std::map<std::string, std::string> attributes); MPD (std::map<std::string, std::string> attributes);
MPD (); MPD ();
...@@ -58,7 +60,7 @@ namespace dash ...@@ -58,7 +60,7 @@ namespace dash
void setProgramInformation (ProgramInformation *progInfo); void setProgramInformation (ProgramInformation *progInfo);
private: private:
std::map<std::string, std::string> attributes; AttributesMap attributes;
std::vector<Period *> periods; std::vector<Period *> periods;
std::vector<BaseUrl *> baseUrls; std::vector<BaseUrl *> baseUrls;
ProgramInformation *programInfo; ProgramInformation *programInfo;
......
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