[vlc-commits] demux: adaptive: delegate codecs string parsing to representation

Francois Cartegnie git at videolan.org
Fri May 10 11:19:59 CEST 2019


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Apr 26 17:03:50 2019 +0200| [3398c84282159a679c2456330e01344ef2623216] | committer: Francois Cartegnie

demux: adaptive: delegate codecs string parsing to representation

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

 modules/demux/adaptive/playlist/BaseRepresentation.cpp | 14 ++++++++++++--
 modules/demux/adaptive/playlist/BaseRepresentation.h   |  2 +-
 modules/demux/dash/mpd/IsoffMainParser.cpp             | 13 +------------
 3 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/modules/demux/adaptive/playlist/BaseRepresentation.cpp b/modules/demux/adaptive/playlist/BaseRepresentation.cpp
index c632ea7f77..541319b620 100644
--- a/modules/demux/adaptive/playlist/BaseRepresentation.cpp
+++ b/modules/demux/adaptive/playlist/BaseRepresentation.cpp
@@ -32,6 +32,7 @@
 #include "SegmentTemplate.h"
 #include "SegmentTimeline.h"
 #include "../ID.hpp"
+#include "../tools/Helper.h"
 
 using namespace adaptive;
 using namespace adaptive::playlist;
@@ -73,9 +74,18 @@ const std::list<std::string> & BaseRepresentation::getCodecs() const
     return codecs;
 }
 
-void BaseRepresentation::addCodec(const std::string &codec)
+void BaseRepresentation::addCodecs(const std::string &s)
 {
-    codecs.push_back(codec);
+    std::list<std::string> list = Helper::tokenize(s, ',');
+    std::list<std::string>::const_iterator it;
+    for(it=list.begin(); it!=list.end(); ++it)
+    {
+        std::size_t pos = (*it).find_first_of('.', 0);
+        if(pos != std::string::npos)
+            codecs.push_back((*it).substr(0, pos));
+        else
+            codecs.push_back(*it);
+    }
 }
 
 bool BaseRepresentation::needsUpdate() const
diff --git a/modules/demux/adaptive/playlist/BaseRepresentation.h b/modules/demux/adaptive/playlist/BaseRepresentation.h
index 7d61a91472..089ede1299 100644
--- a/modules/demux/adaptive/playlist/BaseRepresentation.h
+++ b/modules/demux/adaptive/playlist/BaseRepresentation.h
@@ -60,7 +60,7 @@ namespace adaptive
                 uint64_t            getBandwidth            () const;
                 void                setBandwidth            ( uint64_t bandwidth );
                 const std::list<std::string> & getCodecs    () const;
-                void                addCodec                (const std::string &);
+                void                addCodecs               (const std::string &);
                 bool                consistentSegmentNumber () const;
                 virtual void        pruneByPlaybackTime     (vlc_tick_t);
 
diff --git a/modules/demux/dash/mpd/IsoffMainParser.cpp b/modules/demux/dash/mpd/IsoffMainParser.cpp
index f742dd206c..0ae75780eb 100644
--- a/modules/demux/dash/mpd/IsoffMainParser.cpp
+++ b/modules/demux/dash/mpd/IsoffMainParser.cpp
@@ -302,18 +302,7 @@ void    IsoffMainParser::parseRepresentations (Node *adaptationSetNode, Adaptati
             currentRepresentation->setMimeType(repNode->getAttributeValue("mimeType"));
 
         if(repNode->hasAttribute("codecs"))
-        {
-            std::list<std::string> list = Helper::tokenize(repNode->getAttributeValue("codecs"), ',');
-            std::list<std::string>::const_iterator it;
-            for(it=list.begin(); it!=list.end(); ++it)
-            {
-                std::size_t pos = (*it).find_first_of('.', 0);
-                if(pos != std::string::npos)
-                    currentRepresentation->addCodec((*it).substr(0, pos));
-                else
-                    currentRepresentation->addCodec(*it);
-            }
-        }
+            currentRepresentation->addCodecs(repNode->getAttributeValue("codecs"));
 
         size_t i_total = parseSegmentInformation(repNode, currentRepresentation, &nextid);
         /* Empty Representation with just baseurl (ex: subtitles) */



More information about the vlc-commits mailing list