[vlc-commits] demux: adaptive: add file restrictions for connection manager
Francois Cartegnie
git at videolan.org
Wed Oct 16 20:21:12 CEST 2019
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Oct 16 19:09:14 2019 +0200| [b8c9bfd89080b80dfc10cf8c5ed532419a483698] | committer: Francois Cartegnie
demux: adaptive: add file restrictions for connection manager
because streamurl can handle files
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b8c9bfd89080b80dfc10cf8c5ed532419a483698
---
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 5730ba9c63..fb9f9d9af1 100644
--- a/modules/demux/adaptive/http/ConnectionParams.hpp
+++ b/modules/demux/adaptive/http/ConnectionParams.hpp
@@ -59,6 +59,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 31d8b17740..4ad8e9f361 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 ¶
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 9b25d3e176..39d276d28e 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