[vlc-commits] dash: BasicCMParser: Handle Representation @dependencyId

Hugo Beauzée-Luyssen git at videolan.org
Fri Dec 30 18:15:29 CET 2011


vlc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Wed Dec 21 23:46:15 2011 +0100| [8f9fd197f4df09c00bd7a5d06f8cadafd09cba7d] | committer: Jean-Baptiste Kempf

dash: BasicCMParser: Handle Representation @dependencyId

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8f9fd197f4df09c00bd7a5d06f8cadafd09cba7d
---

 modules/stream_filter/dash/mpd/BasicCMParser.cpp  |   23 +++++++++++++++++++-
 modules/stream_filter/dash/mpd/BasicCMParser.h    |    3 ++
 modules/stream_filter/dash/mpd/Representation.cpp |   20 ++++++++++--------
 modules/stream_filter/dash/mpd/Representation.h   |    4 ++-
 4 files changed, 38 insertions(+), 12 deletions(-)

diff --git a/modules/stream_filter/dash/mpd/BasicCMParser.cpp b/modules/stream_filter/dash/mpd/BasicCMParser.cpp
index 33bdd5f..6c37dc8 100644
--- a/modules/stream_filter/dash/mpd/BasicCMParser.cpp
+++ b/modules/stream_filter/dash/mpd/BasicCMParser.cpp
@@ -99,7 +99,6 @@ 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 )
         {
@@ -130,11 +129,31 @@ void    BasicCMParser::setRepresentations   (Node *root, Group *group)
         if ( it != attributes.end() )
             rep->setQualityRanking( atoi( it->second.c_str() ) );
 
+        it = attributes.find( "dependencyId" );
+        if ( it != attributes.end() )
+            this->handleDependencyId( rep, group, it->second );
+
         this->setSegmentInfo(representations.at(i), rep);
         if ( rep->getSegmentInfo() && rep->getSegmentInfo()->getSegments().size() > 0 )
-            group->addRepresentation(rep);
+            group->addRepresentation(rep);        
+    }
+}
+
+void    BasicCMParser::handleDependencyId( Representation *rep, const Group *group, const std::string &dependencyId )
+{
+    if ( dependencyId.empty() == true )
+        return ;
+    std::istringstream  s( dependencyId );
+    while ( s )
+    {
+        std::string     id;
+        s >> id;
+        const Representation    *dep = group->getRepresentationById( id );
+        if ( dep )
+            rep->addDependency( dep );
     }
 }
+
 void    BasicCMParser::setSegmentInfo       (Node *root, Representation *rep)
 {
     Node    *segmentInfo = DOMHelper::getFirstChildElementByName( root, "SegmentInfo");
diff --git a/modules/stream_filter/dash/mpd/BasicCMParser.h b/modules/stream_filter/dash/mpd/BasicCMParser.h
index e8ad31e..2c867dc 100644
--- a/modules/stream_filter/dash/mpd/BasicCMParser.h
+++ b/modules/stream_filter/dash/mpd/BasicCMParser.h
@@ -51,6 +51,9 @@ namespace dash
                 MPD*    getMPD ();
 
             private:
+                void    handleDependencyId( Representation* rep, const Group* group, const std::string& dependencyId );
+
+            private:
                 dash::xml::Node *root;
                 MPD             *mpd;
 
diff --git a/modules/stream_filter/dash/mpd/Representation.cpp b/modules/stream_filter/dash/mpd/Representation.cpp
index b4774de..debd9f5 100644
--- a/modules/stream_filter/dash/mpd/Representation.cpp
+++ b/modules/stream_filter/dash/mpd/Representation.cpp
@@ -46,15 +46,6 @@ Representation::~Representation ()
     delete(this->trickModeType);
 }
 
-std::string         Representation::getDependencyId         () const throw(AttributeNotPresentException)
-{
-    std::map<std::string, std::string>::const_iterator  it = this->attributes.find("dependencyId");
-    if ( it == this->attributes.end() )
-        throw AttributeNotPresentException();
-
-    return it->second;
-}
-
 const std::string&  Representation::getId                   () const
 {
     return this->id;
@@ -116,3 +107,14 @@ void Representation::setQualityRanking( int qualityRanking )
     if ( qualityRanking > 0 )
         this->qualityRanking = qualityRanking;
 }
+
+const std::list<const Representation*>&     Representation::getDependencies() const
+{
+    return this->dependencies;
+}
+
+void Representation::addDependency(const Representation *dep)
+{
+    if ( dep != NULL )
+        this->dependencies.push_back( dep );
+}
diff --git a/modules/stream_filter/dash/mpd/Representation.h b/modules/stream_filter/dash/mpd/Representation.h
index 992f693..162384e 100644
--- a/modules/stream_filter/dash/mpd/Representation.h
+++ b/modules/stream_filter/dash/mpd/Representation.h
@@ -55,7 +55,8 @@ namespace dash
                 void                setBandwidth            ( int bandwidth );
                 int                 getQualityRanking       () const;
                 void                setQualityRanking       ( int qualityRanking );
-                std::string         getDependencyId         () const throw(dash::exception::AttributeNotPresentException);
+                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);
 
@@ -67,6 +68,7 @@ namespace dash
                 int                                 bandwidth;
                 std::string                         id;
                 int                                 qualityRanking;
+                std::list<const Representation*>    dependencies;
                 std::map<std::string, std::string>  attributes;
                 SegmentInfo                         *segmentInfo;
                 TrickModeType                       *trickModeType;



More information about the vlc-commits mailing list