Commit 967fdaa4 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen Committed by Jean-Baptiste Kempf
Browse files

dash: Adding some basic getters to Representation


Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent 4a23e2fb
......@@ -73,6 +73,7 @@ void BasicCMParser::setPeriods (Node *root)
this->mpd->addPeriod(period);
}
}
void BasicCMParser::setGroups (Node *root, Period *period)
{
std::vector<Node *> groups = DOMHelper::getElementByTagName(root, "Group", false);
......@@ -89,6 +90,7 @@ void BasicCMParser::setGroups (Node *root, Period *period)
period->addGroup(group);
}
}
void BasicCMParser::setRepresentations (Node *root, Group *group)
{
std::vector<Node *> representations = DOMHelper::getElementByTagName(root, "Representation", false);
......@@ -97,6 +99,7 @@ void BasicCMParser::setRepresentations (Node *root, Group *group)
{
const std::map<std::string, std::string> attributes = representations.at(i)->getAttributes();
//FIXME: handle @dependencyId afterward
Representation *rep = new Representation( attributes );
if ( this->parseCommonAttributesElements( representations.at( i ), rep ) == false )
{
......
......@@ -33,6 +33,7 @@ using namespace dash::mpd;
using namespace dash::exception;
Representation::Representation (const std::map<std::string, std::string>& attributes) :
qualityRanking( -1 ),
attributes( attributes ),
segmentInfo( NULL ),
trickModeType( NULL )
......@@ -52,26 +53,28 @@ std::string Representation::getDependencyId () const throw(Attri
throw AttributeNotPresentException();
return it->second;
}
std::string Representation::getId () const throw(AttributeNotPresentException)
{
std::map<std::string, std::string>::const_iterator it = this->attributes.find("id");
if ( it == this->attributes.end())
throw AttributeNotPresentException();
return it->second;
const std::string& Representation::getId () const
{
return this->id;
}
void Representation::setId(const std::string &id)
{
if ( id.empty() == false )
this->id = id;
}
int Representation::getBandwidth () const
{
std::map<std::string, std::string>::const_iterator it = this->attributes.find("bandwidth");
if ( it == this->attributes.end())
return -1;
return atoi( it->second.c_str() ) / 8;
return this->bandwidth;
}
void Representation::setBandwidth( int bandwidth )
{
if ( bandwidth >= 0 )
this->bandwidth = bandwidth;
}
SegmentInfo* Representation::getSegmentInfo () const throw(ElementNotPresentException)
......@@ -101,3 +104,15 @@ void Representation::setSegmentInfo (SegmentInfo *info)
{
this->segmentInfo = info;
}
int Representation::getQualityRanking() const
{
return this->qualityRanking;
}
void Representation::setQualityRanking( int qualityRanking )
{
if ( qualityRanking > 0 )
this->qualityRanking = qualityRanking;
}
......@@ -44,13 +44,17 @@ namespace dash
Representation ( const std::map<std::string, std::string>& attributes);
virtual ~Representation ();
std::string getId () const throw(dash::exception::AttributeNotPresentException);
const std::string& getId () const;
void setId ( const std::string &id );
/*
* @return The bitrate required for this representation
* in Bytes per seconds.
* -1 if an error occurs.
*/
int getBandwidth () const;
void setBandwidth ( int bandwidth );
int getQualityRanking () const;
void setQualityRanking ( int qualityRanking );
std::string getDependencyId () const throw(dash::exception::AttributeNotPresentException);
SegmentInfo* getSegmentInfo () const throw(dash::exception::ElementNotPresentException);
TrickModeType* getTrickModeType () const throw(dash::exception::ElementNotPresentException);
......@@ -60,10 +64,12 @@ namespace dash
void setContentProtection (ContentProtection *protection);
private:
int bandwidth;
std::string id;
int qualityRanking;
std::map<std::string, std::string> attributes;
SegmentInfo *segmentInfo;
TrickModeType *trickModeType;
};
}
}
......
Supports Markdown
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