[vlc-commits] demux: adaptative: fix appending absolute path

Francois Cartegnie git at videolan.org
Mon Aug 24 22:45:42 CEST 2015


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Aug 21 02:22:19 2015 +0200| [784ea81e036e20d4d77f27f0b97f811a48d1343b] | committer: Francois Cartegnie

demux: adaptative: fix appending absolute path

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

 modules/demux/adaptative/playlist/Url.cpp |   24 +++++++++++++++++++++---
 modules/demux/adaptative/playlist/Url.hpp |    1 +
 2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/modules/demux/adaptative/playlist/Url.cpp b/modules/demux/adaptative/playlist/Url.cpp
index 56c8611..78e6037 100644
--- a/modules/demux/adaptative/playlist/Url.cpp
+++ b/modules/demux/adaptative/playlist/Url.cpp
@@ -72,6 +72,24 @@ Url & Url::prepend(const Url &url)
 
 Url & Url::append(const Url &url)
 {
+    if(!components.empty() && url.components.front().b_absolute)
+    {
+        if(components.front().b_scheme)
+        {
+            while(components.size() > 1)
+                components.pop_back();
+            std::string scheme(components.front().component);
+            std::size_t schemepos = scheme.find_first_of("://");
+            if(schemepos != std::string::npos)
+            {
+                std::size_t pathpos = scheme.find_first_of('/', schemepos + 3);
+                if(pathpos != std::string::npos)
+                    components.front().component = scheme.substr(0, pathpos);
+                /* otherwise should be domain only */
+            }
+        }
+    }
+
     if(!components.empty() && !components.back().b_dir)
         components.pop_back();
     components.insert(components.end(), url.components.begin(), url.components.end());
@@ -99,12 +117,12 @@ std::string Url::toString(size_t index, const BaseRepresentation *rep) const
 }
 
 Url::Component::Component(const std::string & str, const MediaSegmentTemplate *templ_)
- : component(str), templ(templ_), b_scheme(false), b_dir(false)
+ : component(str), templ(templ_), b_scheme(false), b_dir(false), b_absolute(false)
 {
     if(!component.empty())
     {
         b_dir = (component[component.length()-1]=='/');
-        b_scheme = !component.compare(0, 7, "http://") || !component.compare(0, 8, "https://");
+        b_scheme = (component.find_first_of("://") == (component.find_first_of('/') - 1));
+        b_absolute = (component[0] =='/');
     }
 }
-
diff --git a/modules/demux/adaptative/playlist/Url.hpp b/modules/demux/adaptative/playlist/Url.hpp
index 6763e3d..b238b7e 100644
--- a/modules/demux/adaptative/playlist/Url.hpp
+++ b/modules/demux/adaptative/playlist/Url.hpp
@@ -51,6 +51,7 @@ namespace adaptative
                     private:
                         bool b_scheme;
                         bool b_dir;
+                        bool b_absolute;
                 };
 
                 Url();



More information about the vlc-commits mailing list