[vlc-commits] dash: Adding some basic getters to Representation

Hugo Beauzée-Luyssen git at videolan.org
Tue Jan 24 23:21:51 CET 2012


vlc/vlc-1.2 | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Wed Dec 21 23:20:18 2011 +0100| [93049b0934584adb0d6e6aa7c3449a409020f85c] | committer: Jean-Baptiste Kempf

dash: Adding some basic getters to Representation

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
(cherry picked from commit 967fdaa471d565e2795e06f4b478389fa314c455)

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

> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.2.git/?a=commit;h=93049b0934584adb0d6e6aa7c3449a409020f85c
---

 modules/stream_filter/dash/mpd/BasicCMParser.cpp  |    3 ++
 modules/stream_filter/dash/mpd/Representation.cpp |   39 ++++++++++++++------
 modules/stream_filter/dash/mpd/Representation.h   |   10 ++++-
 3 files changed, 38 insertions(+), 14 deletions(-)

diff --git a/modules/stream_filter/dash/mpd/BasicCMParser.cpp b/modules/stream_filter/dash/mpd/BasicCMParser.cpp
index 071dc49..3fa36b6 100644
--- a/modules/stream_filter/dash/mpd/BasicCMParser.cpp
+++ b/modules/stream_filter/dash/mpd/BasicCMParser.cpp
@@ -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 )
         {
diff --git a/modules/stream_filter/dash/mpd/Representation.cpp b/modules/stream_filter/dash/mpd/Representation.cpp
index 91bb1e7..b4774de 100644
--- a/modules/stream_filter/dash/mpd/Representation.cpp
+++ b/modules/stream_filter/dash/mpd/Representation.cpp
@@ -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;
+}
diff --git a/modules/stream_filter/dash/mpd/Representation.h b/modules/stream_filter/dash/mpd/Representation.h
index eea176d..992f693 100644
--- a/modules/stream_filter/dash/mpd/Representation.h
+++ b/modules/stream_filter/dash/mpd/Representation.h
@@ -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;
-
         };
     }
 }



More information about the vlc-commits mailing list