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

dash: Adding support for Representation's TrickMode element

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
(cherry picked from commit 3319c47e0e13ecec81ea527c70d0ad71033a17c1)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 18e70595
......@@ -150,7 +150,7 @@ void BasicCMParser::setGroups (Node *root, Period *period)
for(size_t i = 0; i < groups.size(); i++)
{
const std::map<std::string, std::string> attr = groups.at(i)->getAttributes();
Group *group = new Group();
Group *group = new Group;
if ( this->parseCommonAttributesElements( groups.at( i ), group, NULL ) == false )
{
delete group;
......@@ -164,6 +164,25 @@ void BasicCMParser::setGroups (Node *root, Period *period)
}
}
void BasicCMParser::parseTrickMode(Node *node, Representation *repr)
{
std::vector<Node *> trickModes = DOMHelper::getElementByTagName(node, "TrickMode", false);
if ( trickModes.size() == 0 )
return ;
if ( trickModes.size() > 1 )
std::cerr << "More than 1 TrickMode element. Only the first one will be used." << std::endl;
Node* trickModeNode = trickModes[0];
TrickModeType *trickMode = new TrickModeType;
const std::map<std::string, std::string> attr = trickModeNode->getAttributes();
std::map<std::string, std::string>::const_iterator it = attr.find( "alternatePlayoutRate" );
if ( it != attr.end() )
trickMode->setAlternatePlayoutRate( atoi( it->second.c_str() ) );
repr->setTrickMode( trickMode );
}
void BasicCMParser::setRepresentations (Node *root, Group *group)
{
std::vector<Node *> representations = DOMHelper::getElementByTagName(root, "Representation", false);
......@@ -249,9 +268,10 @@ bool BasicCMParser::setSegmentInfo (Node *root, Representation *rep)
if ( it != attr.end() )
info->setDuration( str_duration( it->second.c_str() ) );
rep->setSegmentInfo(info);
rep->setSegmentInfo( info );
return true;
}
std::cerr << "Missing mandatory element: Representation/SegmentInfo" << std::endl;
return false;
}
......
......@@ -59,6 +59,7 @@ namespace dash
bool setMPD ();
void setPeriods (dash::xml::Node *root);
void setGroups (dash::xml::Node *root, Period *period);
void parseTrickMode( dash::xml::Node *node, Representation *repr );
void setRepresentations (dash::xml::Node *root, Group *group);
bool setSegmentInfo (dash::xml::Node *root, Representation *rep);
void setInitSegment (dash::xml::Node *root, SegmentInfo *info);
......
......@@ -68,22 +68,17 @@ void Representation::setBandwidth( int bandwidth )
this->bandwidth = bandwidth;
}
SegmentInfo* Representation::getSegmentInfo () const throw(ElementNotPresentException)
SegmentInfo* Representation::getSegmentInfo() const
{
if(this->segmentInfo == NULL)
throw ElementNotPresentException();
return this->segmentInfo;
}
TrickModeType* Representation::getTrickModeType () const throw(ElementNotPresentException)
{
if(this->segmentInfo == NULL)
throw ElementNotPresentException();
TrickModeType* Representation::getTrickModeType () const
{
return this->trickModeType;
}
void Representation::setTrickModeType (TrickModeType *trickModeType)
void Representation::setTrickMode (TrickModeType *trickModeType)
{
this->trickModeType = trickModeType;
}
......
......@@ -55,16 +55,15 @@ namespace dash
void setQualityRanking ( int qualityRanking );
const std::list<const Representation*>& getDependencies() const;
void addDependency ( const Representation* dep );
SegmentInfo* getSegmentInfo () const throw(dash::exception::ElementNotPresentException);
TrickModeType* getTrickModeType () const throw(dash::exception::ElementNotPresentException);
SegmentInfo* getSegmentInfo () const;
TrickModeType* getTrickModeType () const;
void setSegmentInfo (SegmentInfo *info);
void setTrickModeType (TrickModeType *trickModeType);
void setSegmentInfo( SegmentInfo *info );
void setTrickMode( TrickModeType *trickModeType );
private:
int bandwidth;
std::string id;
int qualityRanking;
std::string id; int qualityRanking;
std::list<const Representation*> dependencies;
std::map<std::string, std::string> attributes;
SegmentInfo *segmentInfo;
......
......@@ -29,10 +29,18 @@
using namespace dash::mpd;
TrickModeType::TrickModeType ()
TrickModeType::TrickModeType() :
alternatePlayoutRate( 1 )
{
}
int TrickModeType::getAlternatePlayoutRate() const
{
return this->alternatePlayoutRate;
}
TrickModeType::~TrickModeType ()
void TrickModeType::setAlternatePlayoutRate(int playoutRate)
{
this->alternatePlayoutRate = playoutRate;
}
......@@ -36,12 +36,12 @@ namespace dash
{
public:
TrickModeType ();
virtual ~TrickModeType ();
std::string getAlternatePlayoutRate();
int getAlternatePlayoutRate() const;
void setAlternatePlayoutRate( int playoutRate );
private:
std::map<std::string, std::string> attributes;
int alternatePlayoutRate;
};
}
}
......
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