[vlc-commits] dash: Adding support for Representation's TrickMode element
Hugo Beauzée-Luyssen
git at videolan.org
Tue Jan 24 23:21:56 CET 2012
vlc/vlc-1.2 | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Thu Dec 29 11:27:02 2011 +0100| [6f07eccd8d2d91de927d5cc69b64ac65a2ab060f] | committer: Jean-Baptiste Kempf
dash: Adding support for Representation's TrickMode element
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
(cherry picked from commit 3319c47e0e13ecec81ea527c70d0ad71033a17c1)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.2.git/?a=commit;h=6f07eccd8d2d91de927d5cc69b64ac65a2ab060f
---
modules/stream_filter/dash/mpd/BasicCMParser.cpp | 24 +++++++++++++++++++-
modules/stream_filter/dash/mpd/BasicCMParser.h | 1 +
modules/stream_filter/dash/mpd/Representation.cpp | 13 +++-------
modules/stream_filter/dash/mpd/Representation.h | 11 ++++-----
modules/stream_filter/dash/mpd/TrickModeType.cpp | 12 ++++++++-
modules/stream_filter/dash/mpd/TrickModeType.h | 6 ++--
6 files changed, 45 insertions(+), 22 deletions(-)
diff --git a/modules/stream_filter/dash/mpd/BasicCMParser.cpp b/modules/stream_filter/dash/mpd/BasicCMParser.cpp
index 3c9bacd..9b8655c 100644
--- a/modules/stream_filter/dash/mpd/BasicCMParser.cpp
+++ b/modules/stream_filter/dash/mpd/BasicCMParser.cpp
@@ -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;
}
diff --git a/modules/stream_filter/dash/mpd/BasicCMParser.h b/modules/stream_filter/dash/mpd/BasicCMParser.h
index fbf808d..ba0d078 100644
--- a/modules/stream_filter/dash/mpd/BasicCMParser.h
+++ b/modules/stream_filter/dash/mpd/BasicCMParser.h
@@ -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);
diff --git a/modules/stream_filter/dash/mpd/Representation.cpp b/modules/stream_filter/dash/mpd/Representation.cpp
index f2dc348..535599c 100644
--- a/modules/stream_filter/dash/mpd/Representation.cpp
+++ b/modules/stream_filter/dash/mpd/Representation.cpp
@@ -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;
}
diff --git a/modules/stream_filter/dash/mpd/Representation.h b/modules/stream_filter/dash/mpd/Representation.h
index 9ee0765..9b44a8c 100644
--- a/modules/stream_filter/dash/mpd/Representation.h
+++ b/modules/stream_filter/dash/mpd/Representation.h
@@ -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;
diff --git a/modules/stream_filter/dash/mpd/TrickModeType.cpp b/modules/stream_filter/dash/mpd/TrickModeType.cpp
index 8e4a587..ff1cbeb 100644
--- a/modules/stream_filter/dash/mpd/TrickModeType.cpp
+++ b/modules/stream_filter/dash/mpd/TrickModeType.cpp
@@ -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;
}
+
diff --git a/modules/stream_filter/dash/mpd/TrickModeType.h b/modules/stream_filter/dash/mpd/TrickModeType.h
index 9f61d0a..9439e87 100644
--- a/modules/stream_filter/dash/mpd/TrickModeType.h
+++ b/modules/stream_filter/dash/mpd/TrickModeType.h
@@ -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;
};
}
}
More information about the vlc-commits
mailing list