[vlc-commits] demux: adaptive: add file restrictions for connection manager

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


vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Oct 16 19:09:14 2019 +0200| [d20128f91fc7702df1772aa3cb14017b7e0e7df6] | committer: Francois Cartegnie

demux: adaptive: add file restrictions for connection manager

because streamurl can handle files

(cherry picked from commit b8c9bfd89080b80dfc10cf8c5ed532419a483698)

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

 modules/demux/adaptive/http/ConnectionParams.cpp      |  5 +++++
 modules/demux/adaptive/http/ConnectionParams.hpp      |  1 +
 modules/demux/adaptive/http/HTTPConnectionManager.cpp | 11 ++++++++++-
 modules/demux/adaptive/http/HTTPConnectionManager.h   |  2 ++
 4 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/modules/demux/adaptive/http/ConnectionParams.cpp b/modules/demux/adaptive/http/ConnectionParams.cpp
index 8fbfc87853..6e3f221b66 100644
--- a/modules/demux/adaptive/http/ConnectionParams.cpp
+++ b/modules/demux/adaptive/http/ConnectionParams.cpp
@@ -83,6 +83,11 @@ uint16_t ConnectionParams::getPort() const
     return port;
 }
 
+bool ConnectionParams::isLocal() const
+{
+    return scheme != "http" && scheme != "https";
+}
+
 void ConnectionParams::parse()
 {
     vlc_url_t url_components;
diff --git a/modules/demux/adaptive/http/ConnectionParams.hpp b/modules/demux/adaptive/http/ConnectionParams.hpp
index e8cf5cec7c..2921f2e2d4 100644
--- a/modules/demux/adaptive/http/ConnectionParams.hpp
+++ b/modules/demux/adaptive/http/ConnectionParams.hpp
@@ -50,6 +50,7 @@ namespace adaptive
                 const std::string & getScheme() const;
                 const std::string & getHostname() const;
                 const std::string & getPath() const;
+                bool isLocal() const;
                 void setPath(const std::string &);
                 uint16_t getPort() const;
 
diff --git a/modules/demux/adaptive/http/HTTPConnectionManager.cpp b/modules/demux/adaptive/http/HTTPConnectionManager.cpp
index 12ca201df5..dd02e3a76a 100644
--- a/modules/demux/adaptive/http/HTTPConnectionManager.cpp
+++ b/modules/demux/adaptive/http/HTTPConnectionManager.cpp
@@ -60,7 +60,8 @@ void AbstractConnectionManager::setDownloadRateObserver(IDownloadRateObserver *o
 
 
 HTTPConnectionManager::HTTPConnectionManager    (vlc_object_t *p_object_, AuthStorage *storage)
-    : AbstractConnectionManager( p_object_ )
+    : AbstractConnectionManager( p_object_ ),
+      localAllowed(false)
 {
     vlc_mutex_init(&lock);
     downloader = new (std::nothrow) Downloader();
@@ -108,6 +109,9 @@ AbstractConnection * HTTPConnectionManager::getConnection(ConnectionParams &para
     if(unlikely(!factory || !downloader))
         return NULL;
 
+    if(!localAllowed && params.isLocal())
+        return NULL;
+
     vlc_mutex_lock(&lock);
     AbstractConnection *conn = reuseConnection(params);
     if(!conn)
@@ -146,3 +150,8 @@ void HTTPConnectionManager::cancel(AbstractChunkSource *source)
     if(src)
         downloader->cancel(src);
 }
+
+void HTTPConnectionManager::setLocalConnectionsAllowed()
+{
+    localAllowed = true;
+}
diff --git a/modules/demux/adaptive/http/HTTPConnectionManager.h b/modules/demux/adaptive/http/HTTPConnectionManager.h
index f4ab7d3c7a..e2441aed06 100644
--- a/modules/demux/adaptive/http/HTTPConnectionManager.h
+++ b/modules/demux/adaptive/http/HTTPConnectionManager.h
@@ -74,6 +74,7 @@ namespace adaptive
 
                 virtual void start(AbstractChunkSource *) /* impl */;
                 virtual void cancel(AbstractChunkSource *) /* impl */;
+                void         setLocalConnectionsAllowed();
 
             private:
                 void    releaseAllConnections ();
@@ -81,6 +82,7 @@ namespace adaptive
                 vlc_mutex_t                                         lock;
                 std::vector<AbstractConnection *>                   connectionPool;
                 AbstractConnectionFactory                          *factory;
+                bool                                                localAllowed;
                 AbstractConnection * reuseConnection(ConnectionParams &);
         };
     }



More information about the vlc-commits mailing list