[vlc-commits] demux: adaptative: don't append over filenames

Francois Cartegnie git at videolan.org
Thu May 7 23:44:07 CEST 2015


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu May  7 18:52:38 2015 +0200| [0335f63454e202bf285fa8b99db94fa08531d800] | committer: Francois Cartegnie

demux: adaptative: don't append over filenames

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

 modules/demux/adaptative/playlist/Url.cpp |   16 ++++++++++------
 modules/demux/adaptative/playlist/Url.hpp |    4 ++++
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/modules/demux/adaptative/playlist/Url.cpp b/modules/demux/adaptative/playlist/Url.cpp
index cec9f81..e84937e 100644
--- a/modules/demux/adaptative/playlist/Url.cpp
+++ b/modules/demux/adaptative/playlist/Url.cpp
@@ -42,12 +42,7 @@ bool Url::hasScheme() const
     if(components.empty())
         return false;
 
-    const Component *comp = &components[0];
-    if(comp->component.compare(0, 7, "http://") &&
-       comp->component.compare(0, 8, "https://"))
-        return false;
-
-    return true;
+    return components[0].b_scheme;
 }
 
 Url & Url::prepend(const Component & comp)
@@ -58,6 +53,8 @@ Url & Url::prepend(const Component & comp)
 
 Url & Url::append(const Component & comp)
 {
+    if(!components.empty() && !components.back().b_dir)
+        components.pop_back();
     components.push_back(comp);
     return *this;
 }
@@ -70,6 +67,8 @@ Url & Url::prepend(const Url &url)
 
 Url & Url::append(const Url &url)
 {
+    if(!components.empty() && !components.back().b_dir)
+        components.pop_back();
     components.insert(components.end(), url.components.begin(), url.components.end());
     return *this;
 }
@@ -98,5 +97,10 @@ Url::Component::Component(const std::string & str, const MediaSegmentTemplate *t
 {
     component = str;
     templ = templ_;
+    if(!component.empty())
+    {
+        b_dir = (component.back()=='/');
+        b_scheme = !component.compare(0, 7, "http://") || !component.compare(0, 8, "https://");
+    }
 }
 
diff --git a/modules/demux/adaptative/playlist/Url.hpp b/modules/demux/adaptative/playlist/Url.hpp
index d2b36b7..e40ccf9 100644
--- a/modules/demux/adaptative/playlist/Url.hpp
+++ b/modules/demux/adaptative/playlist/Url.hpp
@@ -47,6 +47,10 @@ namespace adaptative
                     protected:
                         std::string component;
                         const MediaSegmentTemplate *templ;
+
+                    private:
+                        bool b_scheme;
+                        bool b_dir;
                 };
 
                 Url();



More information about the vlc-commits mailing list