vlc | branch: master | Francois Cartegnie <[email protected]> | Thu Dec 24 12:44:07 2020 +0100| [5357940b0eb4feeb39a4ad1847f3ae5a4601a705] | committer: Francois Cartegnie
demux: adaptive: allow to override default resources > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5357940b0eb4feeb39a4ad1847f3ae5a4601a705 --- modules/demux/adaptive/SharedResources.cpp | 35 +++++++++++++++++------------- modules/demux/adaptive/SharedResources.hpp | 5 ++++- modules/demux/adaptive/adaptive.cpp | 19 +++++----------- 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/modules/demux/adaptive/SharedResources.cpp b/modules/demux/adaptive/SharedResources.cpp index 21606a3e1b..66e23bda24 100644 --- a/modules/demux/adaptive/SharedResources.cpp +++ b/modules/demux/adaptive/SharedResources.cpp @@ -27,24 +27,14 @@ #include "http/HTTPConnection.hpp" #include "encryption/Keyring.hpp" -#include <vlc_common.h> - using namespace adaptive; -SharedResources::SharedResources(vlc_object_t *obj, bool local) +SharedResources::SharedResources(AuthStorage *auth, Keyring *ring, + AbstractConnectionManager *conn) { - authStorage = new AuthStorage(obj); - encryptionKeyring = new Keyring(obj); - HTTPConnectionManager *m = new HTTPConnectionManager(obj); - if(m) - { - if(!var_InheritBool(obj, "adaptive-use-access")) /* only use http from access */ - m->addFactory(new NativeConnectionFactory(authStorage)); - m->addFactory(new StreamUrlConnectionFactory()); - if(local) - m->setLocalConnectionsAllowed(); - } - connManager = m; + authStorage = auth; + encryptionKeyring = ring; + connManager = conn; } SharedResources::~SharedResources() @@ -68,3 +58,18 @@ AbstractConnectionManager * SharedResources::getConnManager() { return connManager; } + +SharedResources * SharedResources::createDefault(vlc_object_t *obj, + const std::string & playlisturl) +{ + AuthStorage *auth = new AuthStorage(obj); + Keyring *keyring = new Keyring(obj); + HTTPConnectionManager *m = new HTTPConnectionManager(obj); + if(!var_InheritBool(obj, "adaptive-use-access")) /* only use http from access */ + m->addFactory(new NativeConnectionFactory(auth)); + m->addFactory(new StreamUrlConnectionFactory()); + ConnectionParams params(playlisturl); + if(params.isLocal()) + m->setLocalConnectionsAllowed(); + return new SharedResources(auth, keyring, m); +} diff --git a/modules/demux/adaptive/SharedResources.hpp b/modules/demux/adaptive/SharedResources.hpp index 0ef5256da5..13917601e8 100644 --- a/modules/demux/adaptive/SharedResources.hpp +++ b/modules/demux/adaptive/SharedResources.hpp @@ -21,6 +21,7 @@ #define SHAREDRESOURCES_H_ #include <vlc_common.h> +#include <string> namespace adaptive { @@ -41,11 +42,13 @@ namespace adaptive class SharedResources { public: - SharedResources(vlc_object_t *, bool = false); + SharedResources(AuthStorage *, Keyring *, AbstractConnectionManager *); ~SharedResources(); AuthStorage *getAuthStorage(); Keyring *getKeyring(); AbstractConnectionManager *getConnManager(); + /* Helper */ + static SharedResources * createDefault(vlc_object_t *, const std::string &); private: AuthStorage *authStorage; diff --git a/modules/demux/adaptive/adaptive.cpp b/modules/demux/adaptive/adaptive.cpp index f4aae7dc14..2f4016e112 100644 --- a/modules/demux/adaptive/adaptive.cpp +++ b/modules/demux/adaptive/adaptive.cpp @@ -280,13 +280,6 @@ static void Close(vlc_object_t *p_obj) /***************************************************************************** * *****************************************************************************/ -static bool IsLocalResource(const std::string & url) -{ - ConnectionParams params(url); - return params.isLocal(); -} - - static PlaylistManager * HandleDash(demux_t *p_demux, DOMParser &xmlParser, const std::string & playlisturl, AbstractAdaptationLogic::LogicType logic) @@ -305,8 +298,8 @@ static PlaylistManager * HandleDash(demux_t *p_demux, DOMParser &xmlParser, return NULL; } - SharedResources *resources = new (std::nothrow) SharedResources(VLC_OBJECT(p_demux), - IsLocalResource(playlisturl)); + SharedResources *resources = + SharedResources::createDefault(VLC_OBJECT(p_demux), playlisturl); DASHStreamFactory *factory = new (std::nothrow) DASHStreamFactory; DASHManager *manager = NULL; if(!resources || !factory || @@ -338,8 +331,8 @@ static PlaylistManager * HandleSmooth(demux_t *p_demux, DOMParser &xmlParser, return NULL; } - SharedResources *resources = new (std::nothrow) SharedResources(VLC_OBJECT(p_demux), - IsLocalResource(playlisturl)); + SharedResources *resources = + SharedResources::createDefault(VLC_OBJECT(p_demux), playlisturl); SmoothStreamFactory *factory = new (std::nothrow) SmoothStreamFactory; SmoothManager *manager = NULL; if(!resources || !factory || @@ -357,8 +350,8 @@ static PlaylistManager * HandleHLS(demux_t *p_demux, const std::string & playlisturl, AbstractAdaptationLogic::LogicType logic) { - SharedResources *resources = new SharedResources(VLC_OBJECT(p_demux), - IsLocalResource(playlisturl)); + SharedResources *resources = + SharedResources::createDefault(VLC_OBJECT(p_demux), playlisturl); if(!resources) return NULL; _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
