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

dash: Adding some basic getters to Representation

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