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

Francois Cartegnie git at videolan.org
Mon Mar 30 16:15:24 CEST 2020


vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Apr 26 17:03:50 2019 +0200| [362ad88ca01d4c9014fcdf666058b0624c55fc1b] | committer: Francois Cartegnie

demux: adaptive: delegate codecs string parsing to representation

(cherry picked from commit 3398c84282159a679c2456330e01344ef2623216)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=362ad88ca01d4c9014fcdf666058b0624c55fc1b
---

 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 c7dfedb943..ca047df24a 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 8060481735..f84c2de545 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     (mtime_t);
 
diff --git a/modules/demux/dash/mpd/IsoffMainParser.cpp b/modules/demux/dash/mpd/IsoffMainParser.cpp
index fe88e8f675..4739157ae9 100644
--- a/modules/demux/dash/mpd/IsoffMainParser.cpp
+++ b/modules/demux/dash/mpd/IsoffMainParser.cpp
@@ -300,18 +300,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