From a5f1c20cbe13ebf689c659ec6441574a75fa8f16 Mon Sep 17 00:00:00 2001 From: Rainer Hochecker Date: Sun, 20 Mar 2016 19:36:05 +0100 Subject: VideoPlayer: inputstream changes, bump to 1.0.2 --- addons/kodi.inputstream/addon.xml | 4 +-- xbmc/addons/InputStream.cpp | 54 +++++++++++++++++++++++++-------------- xbmc/addons/InputStream.h | 9 ++++++- 3 files changed, 45 insertions(+), 22 deletions(-) diff --git a/addons/kodi.inputstream/addon.xml b/addons/kodi.inputstream/addon.xml index e5eedbf8ed..90df359ee9 100644 --- a/addons/kodi.inputstream/addon.xml +++ b/addons/kodi.inputstream/addon.xml @@ -1,6 +1,6 @@ - - + + diff --git a/xbmc/addons/InputStream.cpp b/xbmc/addons/InputStream.cpp index 570728e52f..998d24a75a 100644 --- a/xbmc/addons/InputStream.cpp +++ b/xbmc/addons/InputStream.cpp @@ -20,12 +20,17 @@ #include "utils/StringUtils.h" #include "utils/log.h" #include "cores/VideoPlayer/DVDDemuxers/DVDDemux.h" +#include "threads/SingleLock.h" #include "utils/RegExp.h" #include "utils/URIUtils.h" namespace ADDON { +bool CInputStream::m_hasConfig = false; +std::vector CInputStream::m_pathList; +CCriticalSection CInputStream::m_parentSection; + std::unique_ptr CInputStream::FromExtension(AddonProps props, const cp_extension_t* ext) { std::string listitemprops = CAddonMgr::GetInstance().GetExtValue(ext->configuration, "@listitemprops"); @@ -52,27 +57,22 @@ CInputStream::CInputStream(AddonProps props, std::string name, std::string listi { StringUtils::Trim(ext); } + + if (!m_bIsChild && !m_hasConfig) + UpdateConfig(); } -bool CInputStream::Supports(CFileItem &fileitem) +void CInputStream::SaveSettings() { - std::string extension = URIUtils::GetExtension(fileitem.GetPath()); - bool match = false; - for (auto &ext : m_extensionsList) - { - if (ext == extension) - { - match = true; - break; - } - } - if (!match) - return false; - - if (!m_pStruct) - return true; + CAddon::SaveSettings(); + if (!m_bIsChild) + UpdateConfig(); +} +void CInputStream::UpdateConfig() +{ std::string pathList; + Create(); try { pathList = m_pStruct->GetPathList(); @@ -80,23 +80,39 @@ bool CInputStream::Supports(CFileItem &fileitem) catch (std::exception &e) { CLog::Log(LOGERROR, "CInputStream::Supports - could not get a list of paths. Reason: %s", e.what()); - return false; } + Destroy(); + CSingleLock lock(m_parentSection); m_pathList = StringUtils::Tokenize(pathList, "|"); for (auto &path : m_pathList) { StringUtils::Trim(path); } + m_hasConfig = true; +} + +bool CInputStream::Supports(CFileItem &fileitem) +{ + // check if a specific inputstream addon is requested + CVariant addon = fileitem.GetProperty("inputstreamaddon"); + if (!addon.isNull()) + { + if (addon.asString() != Name()) + return false; + } + + // check paths + CSingleLock lock(m_parentSection); - match = false; + bool match = false; for (auto &path : m_pathList) { if (path.empty()) continue; CRegExp r(true, CRegExp::asciiOnly, path.c_str()); - if (r.RegFind(path.c_str()) == 0 && r.GetFindLen() > 5) + if (r.RegFind(fileitem.GetPath().c_str()) == 0 && r.GetFindLen() > 5) { match = true; break; diff --git a/xbmc/addons/InputStream.h b/xbmc/addons/InputStream.h index 4ee9fee342..9e0a30a3b5 100644 --- a/xbmc/addons/InputStream.h +++ b/xbmc/addons/InputStream.h @@ -21,6 +21,7 @@ #include "AddonDll.h" #include "addons/kodi-addon-dev-kit/include/kodi/kodi_inputstream_types.h" #include "FileItem.h" +#include "threads/CriticalSection.h" #include #include @@ -44,6 +45,8 @@ namespace ADDON CInputStream(AddonProps props, std::string name, std::string listitemprops, std::string extensions); virtual ~CInputStream() {} + virtual void SaveSettings() override; + bool Supports(CFileItem &fileitem); bool Open(CFileItem &fileitem); void Close(); @@ -85,12 +88,16 @@ namespace ADDON protected: void UpdateStreams(); void DisposeStreams(); + void UpdateConfig(); std::vector m_fileItemProps; - std::vector m_pathList; std::vector m_extensionsList; INPUTSTREAM_CAPABILITIES m_caps; std::map m_streams; + + static CCriticalSection m_parentSection; + static bool m_hasConfig; + static std::vector m_pathList; }; } /*namespace ADDON*/ -- cgit v1.2.3