aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRainer Hochecker <fernetmenta@online.de>2016-03-20 19:36:05 +0100
committerRainer Hochecker <fernetmenta@online.de>2016-03-20 19:36:05 +0100
commita5f1c20cbe13ebf689c659ec6441574a75fa8f16 (patch)
treeb8dd17f596da1c3b8f1ee82e432a525248ad2ff2
parent610795559ef74a21d72aaa990833caf2867bf127 (diff)
VideoPlayer: inputstream changes, bump to 1.0.2
-rw-r--r--addons/kodi.inputstream/addon.xml4
-rw-r--r--xbmc/addons/InputStream.cpp54
-rw-r--r--xbmc/addons/InputStream.h9
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 @@
<?xml version="1.0" encoding="UTF-8"?>
-<addon id="kodi.inputstream" version="1.0.1" provider-name="Team Kodi">
- <backwards-compatibility abi="1.0.1"/>
+<addon id="kodi.inputstream" version="1.0.2" provider-name="Team Kodi">
+ <backwards-compatibility abi="1.0.2"/>
<requires>
<import addon="xbmc.core" version="0.1.0"/>
</requires>
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<std::string> CInputStream::m_pathList;
+CCriticalSection CInputStream::m_parentSection;
+
std::unique_ptr<CInputStream> 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 <vector>
#include <map>
@@ -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<std::string> m_fileItemProps;
- std::vector<std::string> m_pathList;
std::vector<std::string> m_extensionsList;
INPUTSTREAM_CAPABILITIES m_caps;
std::map<int, CDemuxStream*> m_streams;
+
+ static CCriticalSection m_parentSection;
+ static bool m_hasConfig;
+ static std::vector<std::string> m_pathList;
};
} /*namespace ADDON*/