Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MediaPortal pvr addon: update to v1.2.2.111 (ffmpeg version only)

  • Loading branch information...
commit a76f5d4124a9f4d7d91fc7a7456ef729fe4fe500 1 parent d465c04
@margro margro authored committed
Showing with 846 additions and 431 deletions.
  1. +1 −1  addons/pvr.team-mediaportal.tvserver/addon.xml
  2. +25 −0 addons/pvr.team-mediaportal.tvserver/changelog.txt
  3. +21 −2 addons/pvr.team-mediaportal.tvserver/resources/language/Dutch/strings.xml
  4. +21 −2 addons/pvr.team-mediaportal.tvserver/resources/language/English/strings.xml
  5. +4 −0 addons/pvr.team-mediaportal.tvserver/resources/language/German/strings.xml
  6. +25 −0 addons/pvr.team-mediaportal.tvserver/resources/language/Italian/strings.xml
  7. +2 −2 addons/pvr.team-mediaportal.tvserver/resources/settings.xml
  8. +0 −4 project/VS2010Express/XBMC for Windows.sln
  9. +0 −34 xbmc/pvrclients/MediaPortal/AutoLock.cpp
  10. +0 −29 xbmc/pvrclients/MediaPortal/AutoLock.h
  11. +0 −64 xbmc/pvrclients/MediaPortal/CriticalSection.cpp
  12. +10 −0 xbmc/pvrclients/MediaPortal/FileUtils.h
  13. +143 −0 xbmc/pvrclients/MediaPortal/GenreTable.cpp
  14. +23 −12 xbmc/pvrclients/MediaPortal/{CriticalSection.h → GenreTable.h}
  15. +5 −7 xbmc/pvrclients/MediaPortal/Makefile.in
  16. +2 −2 xbmc/pvrclients/MediaPortal/README
  17. +12 −9 xbmc/pvrclients/MediaPortal/Socket.cpp
  18. +9 −8 xbmc/pvrclients/MediaPortal/Socket.h
  19. +7 −4 xbmc/pvrclients/MediaPortal/client.cpp
  20. +3 −3 xbmc/pvrclients/MediaPortal/client.h
  21. +5 −37 xbmc/pvrclients/MediaPortal/epg.cpp
  22. +3 −11 xbmc/pvrclients/MediaPortal/epg.h
  23. +2 −3 xbmc/pvrclients/MediaPortal/os-dependent.h
  24. +7 −6 xbmc/pvrclients/MediaPortal/project/VS2010Express/XBMC_MPTV.vcxproj
  25. +15 −9 xbmc/pvrclients/MediaPortal/project/VS2010Express/XBMC_MPTV.vcxproj.filters
  26. +155 −131 xbmc/pvrclients/MediaPortal/pvrclient-mediaportal.cpp
  27. +7 −5 xbmc/pvrclients/MediaPortal/pvrclient-mediaportal.h
  28. +75 −41 xbmc/pvrclients/MediaPortal/recordings.cpp
  29. +16 −0 xbmc/pvrclients/MediaPortal/recordings.h
  30. +2 −2 xbmc/pvrclients/MediaPortal/timers.cpp
  31. +14 −1 xbmc/pvrclients/MediaPortal/utils.cpp
  32. +9 −0 xbmc/pvrclients/MediaPortal/utils.h
  33. +91 −0 xbmc/pvrclients/MediaPortal/windows/FileUtils.cpp
  34. +104 −0 xbmc/pvrclients/MediaPortal/windows/WindowsUtils.cpp
  35. +27 −0 xbmc/pvrclients/MediaPortal/windows/WindowsUtils.h
  36. +1 −2  xbmc/pvrclients/MediaPortal/windows/os_windows.h
View
2  addons/pvr.team-mediaportal.tvserver/addon.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="pvr.team-mediaportal.tvserver"
- version="1.1.3.107"
+ version="1.2.2.111"
name="MediaPortal PVR Client (ffmpeg)"
provider-name="Marcel Groothuis">
<requires>
View
25 addons/pvr.team-mediaportal.tvserver/changelog.txt
@@ -1,3 +1,28 @@
+v1.2.2.11:
+- Fixed: Day of the week mismatch for timers between MePo and XBMC. Credits: jajoflo
+- Added: Trigger recording update on timer retrieval so the recording list is kept up to date when there is a new recording. Credits: jajoflo
+- Fixed: tv group retrieval requested radio groups
+- Added: add support for recording genre field
+- Fixed: fixes for recording filepath split-up
+- Added: show an error message when the recording filename or playback URL is empty
+
+v1.2.2.110:
+- Added: use channel icons from MediaPortal (Windows, localhost only)
+- Changed: switch from libPlatform + libTcpSocket to platform library
+
+v1.2.2.109:
+- Fixed: fix mimetype for tv channels
+- Fixed: make sure that OpenLiveStream does not return true due to m_iCurrentChannel when the TSReader fails in a later stage
+- Fixed: compilation IOS/OSX/Linux
+- Fixed: compile fixes for API move into ADDON namespace
+- Added: show localized error messages when OpenLiveStream fails
+- Added: signal status support
+- Fixed: Don't return encrypted channels as group members when FTA only option is turned on
+- Added: add more debug log information about the addon settings and status
+- Added: add support for direct recording playback from network shares (smb, Windows only)
+- Added: implement support for recording subdirectories
+- Fixed: don't return radio channels/channelgroup/channelgroup mappings when radio support is disabled
+
v1.1.3.107:
- Added: add additional checks for communication errors
- Fixed: trigger also a recording list update on timer changes
View
23 addons/pvr.team-mediaportal.tvserver/resources/language/Dutch/strings.xml
@@ -20,6 +20,25 @@
<string id="30041">MediaPortal</string>
<!-- on-screen error messages -->
- <string id="30050">Uw TVServerXBMC plugin v%s is te oud. U heeft minimaal versie v%s of nieuwer nodig!</string>
- <string id="30050">Uw TVServerXBMC plugin is te oud. U heeft minimaal versie v%s of nieuwer nodig!</string>
+ <string id="30050">Uw TVServerXBMC plugin '%s' is te oud. U heeft minimaal versie '%s' of nieuwer nodig!</string>
+ <string id="30051">Uw TVServerXBMC plugin is te oud. U heeft minimaal versie '%s' of nieuwer nodig!</string>
+ <string id="30052">Afspelen opname mislukt. Lege URL of bestandsnaam.</string>
+
+ <!-- Status message strings corresponding to the MediaPortal TvResult enum -->
+ <string id="30060">Alle kaarten zijn bezet</string>
+ <string id="30061">Kanaal is gecodeerd</string>
+ <string id="30062">Geen video of audio gedetecteerd</string>
+ <string id="30063">Geen signaal</string>
+ <string id="30064">Onbekende fout</string>
+ <string id="30065">Graph starten mislukt</string>
+ <string id="30066">Onbekend kanaal</string>
+ <string id="30067">Geen tuning details</string>
+ <string id="30068">Kanaal is niet gekoppeld aan een kaart</string>
+ <string id="30069">Kaart is uitgeschakeld</string>
+ <string id="30070">Verbinding met slave verbroken</string>
+ <string id="30071">Niet de eigenaar</string>
+ <string id="30072">Aanmaken Graph mislukt</string>
+ <string id="30073">SW Encoder ontbreekt</string>
+ <string id="30074">Geen vrije diskruimte</string>
+ <string id="30075">Geen PMT gevonden</string>
</strings>
View
23 addons/pvr.team-mediaportal.tvserver/resources/language/English/strings.xml
@@ -20,6 +20,25 @@
<string id="30041">MediaPortal</string>
<!-- on-screen error messages -->
- <string id="30050">Your TVServerXBMC version v%s is too old. Please upgrade to v%s or higher!</string>
- <string id="30051">Your TVServerXBMC version is too old. Please upgrade to v%s or higher!</string>
+ <string id="30050">Your TVServerXBMC version '%s' is too old. Please upgrade to '%s' or higher!</string>
+ <string id="30051">Your TVServerXBMC version is too old. Please upgrade to '%s' or higher!</string>
+ <string id="30052">Recording playback failed. Empty URL of filename.</string>
+
+ <!-- Status message strings corresponding to the MediaPortal TvResult enum -->
+ <string id="30060">All cards are busy</string>
+ <string id="30061">Channel is scrambled</string>
+ <string id="30062">No video or audio detected</string>
+ <string id="30063">No signal detected</string>
+ <string id="30064">Unknown error</string>
+ <string id="30065">Unable to start graph</string>
+ <string id="30066">Unknown channel</string>
+ <string id="30067">No tuning details</string>
+ <string id="30068">Channel is not mapped to any card</string>
+ <string id="30069">Card is disabled</string>
+ <string id="30070">Connection to slave failed</string>
+ <string id="30071">Not the owner</string>
+ <string id="30072">Graph building failed</string>
+ <string id="30073">SW Encoder missing</string>
+ <string id="30074">No free disk space</string>
+ <string id="30075">No PMT found</string>
</strings>
View
4 addons/pvr.team-mediaportal.tvserver/resources/language/German/strings.xml
@@ -14,4 +14,8 @@
<string id="30010">Wartezeit, nachdem ein Kanal abgestimmt worden ist (ms)</string>
<string id="30011">Aufnahmen aus Ordner lesen</string>
<string id="30012">Mediaportal Aufnahmeordner</string>
+
+ <!-- on-screen error messages -->
+ <string id="30050">Ihre TVServerXBMC plugin v%s ist zu alt. Sie brauchen mindestens Version v%s!</string>
+ <string id="30051">Ihre TVServerXBMC plugin Version ist zu alt. Sie brauchen mindestens Version v%s!</string>
</strings>
View
25 addons/pvr.team-mediaportal.tvserver/resources/language/Italian/strings.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes"?>
+<strings>
+ <!-- settings labels -->
+ <string id="30000">Nome del server Mediaportal</string>
+ <string id="30001">Porta del plugin Mediaportal di XBMC</string>
+ <string id="30002">Solo Free-to-air</string>
+ <string id="30003">Includi Radio</string>
+
+ <string id="30005">Timeout per la connessione (s)</string>
+ <string id="30006">Importa solo canali TV dal gruppo</string>
+ <string id="30007">Importa solo canali radio dal gruppo</string>
+ <string id="30008">Converti il nome del server nell'indirizzo IP</string>
+ <string id="30009">EPG: Leggi le stringhe dei generi (lento)</string>
+ <string id="30010">Tempo di attesa dopo il tuning di un canale (ms)</string>
+ <string id="30011">Registra direttamente (nessuno streaming)</string>
+ <string id="30012">Cartella di salvataggio per Mediaportal</string>
+
+ <!-- category labels -->
+ <string id="30040">Connessione</string>
+ <string id="30041">MediaPortal</string>
+
+ <!-- on-screen error messages -->
+ <string id="30050">La tua versione di TVServerXBMC v%s è troppo vecchia. Per favore, aggiornala a v%s o superiore!</string>
+ <string id="30051">La tua versione di TVServerXBMC è troppo vecchia. Per favore, aggiornala a v%s o superiore!</string>
+</strings>
View
4 addons/pvr.team-mediaportal.tvserver/resources/settings.xml
@@ -4,7 +4,7 @@
<category label="30040">
<setting id="host" type="text" label="30000" option="urlencoded" default="127.0.0.1" />
<setting id="port" type="number" label="30001" default="9596" />
- <setting id="timeout" type="enum" label="30005" values="0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15" default="6"/>
+ <setting id="timeout" type="enum" label="30005" values="0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20" default="10"/>
</category>
<!-- Mediaportal -->
@@ -15,7 +15,7 @@
<setting id="radiogroup" type="text" label="30007" default="" />
<setting id="resolvertsphostname" type="bool" label="30008" default="true" />
<setting id="readgenre" type="bool" label="30009" default="false" />
- <setting id="sleeponrtspurl" type="enum" label="30010" values="0|100|200|300|400|500|600|700|800|900|1000|1200|1500|2000|2500" default="0"/>
+ <setting id="sleeponrtspurl" type="enum" label="30010" values="0|100|200|300|400|500|600|700|800|900|1000|1200|1500|2000|2500|3000" default="0"/>
<setting id="userecordingsdir" type="bool" label="30011" default="false" />
<setting id="recordingsdir" type="folder" option="smb" label="30012" default="" />
</category>
View
4 project/VS2010Express/XBMC for Windows.sln
@@ -90,10 +90,6 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libXBMC_pvr", "..\..\lib\addons\library.xbmc.pvr\project\VS2010Express\libXBMC_pvr.vcxproj", "{6D8C91F8-992F-4C83-9DE3-485D64EF8420}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pvrclient_mptv", "..\..\xbmc\pvrclients\MediaPortal\project\VS2010Express\XBMC_MPTV.vcxproj", "{74C9642E-1988-48DC-8404-11717C355378}"
- ProjectSection(ProjectDependencies) = postProject
- {E2DF1AC8-E9BF-43B8-B5D9-7EC3B513EEF1} = {E2DF1AC8-E9BF-43B8-B5D9-7EC3B513EEF1}
- {0F78AAF3-A188-4491-8BA6-203DC0B8D7F5} = {0F78AAF3-A188-4491-8BA6-203DC0B8D7F5}
- EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pvrclient_tvheadend", "..\..\xbmc\pvrclients\tvheadend\project\VS2010Express\XBMC_tvheadend.vcxproj", "{C04B0FB1-667D-4F1C-BDAE-A07CDFFA74A3}"
ProjectSection(ProjectDependencies) = postProject
View
34 xbmc/pvrclients/MediaPortal/AutoLock.cpp
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2005-2011 Team XBMC
- * http://www.xbmc.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "AutoLock.h"
-
-/*
- * \brief CAutoLock constructor
- * \param pCritSec
- */
-CAutoLock::CAutoLock(CCriticalSection* pCritSec)
-{
- m_pAutoLock = pCritSec;
- m_pAutoLock->Lock();
-}
-
-CAutoLock::~CAutoLock()
-{
- m_pAutoLock->Unlock();
-}
View
29 xbmc/pvrclients/MediaPortal/AutoLock.h
@@ -1,29 +0,0 @@
-#pragma once
-/*
- * Copyright (C) 2005-2011 Team XBMC
- * http://www.xbmc.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "CriticalSection.h"
-
-class CAutoLock
-{
- public:
- CAutoLock(CCriticalSection* pCritSec);
- ~CAutoLock();
- protected:
- CCriticalSection* m_pAutoLock;
-};
View
64 xbmc/pvrclients/MediaPortal/CriticalSection.cpp
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2005-2011 Team XBMC
- * http://www.xbmc.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "CriticalSection.h"
-
-CCriticalSection::CCriticalSection(void)
-{
-}
-
-void CCriticalSection::Initialize(void)
-{
-#ifdef TARGET_WINDOWS
- InitializeCriticalSection(&m_CriticalSection);
-#else
- pthread_mutexattr_t attr;
- pthread_mutexattr_init(&attr);
- pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
- pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
- pthread_mutex_init(&m_CriticalSection, &attr);
- pthread_mutexattr_destroy(&attr);
-#endif
-}
-
-CCriticalSection::~CCriticalSection(void)
-{
-#ifdef TARGET_WINDOWS
- DeleteCriticalSection(&m_CriticalSection);
-#else
- pthread_mutex_destroy(&m_CriticalSection);
-#endif
-}
-
-void CCriticalSection::Lock(void)
-{
-#ifdef TARGET_WINDOWS
- EnterCriticalSection(&m_CriticalSection);
-#else
- pthread_mutex_lock(&m_CriticalSection);
-#endif
-}
-
-void CCriticalSection::Unlock(void)
-{
-#ifdef TARGET_WINDOWS
- LeaveCriticalSection(&m_CriticalSection);
-#else
- pthread_mutex_unlock(&m_CriticalSection);
-#endif
-}
View
10 xbmc/pvrclients/MediaPortal/FileUtils.h
@@ -0,0 +1,10 @@
+#include <string>
+
+namespace OS
+{
+ class CFile
+ {
+ public:
+ static bool Exists(const std::string& strFileName);
+ };
+};
View
143 xbmc/pvrclients/MediaPortal/GenreTable.cpp
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) 2005-2012 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "client.h"
+#include "GenreTable.h"
+#include "lib/tinyxml/tinyxml.h"
+
+using namespace ADDON;
+using namespace std;
+
+bool CGenreTable::LoadGenreXML(const std::string &filename)
+{
+ TiXmlDocument xmlDoc;
+ if (!xmlDoc.LoadFile(filename))
+ {
+ XBMC->Log(LOG_DEBUG, "Unable to load %s: %s at line %d", filename.c_str(), xmlDoc.ErrorDesc(), xmlDoc.ErrorRow());
+ return false;
+ }
+
+ XBMC->Log(LOG_DEBUG, "Opened %s to read genre string to type/subtype translation table", filename.c_str());
+
+ TiXmlHandle hDoc(&xmlDoc);
+ TiXmlElement* pElem;
+ TiXmlHandle hRoot(0);
+ string sGenre;
+ const char* sGenreType = NULL;
+ const char* sGenreSubType = NULL;
+ genre_t genre;
+
+ // block: genrestrings
+ pElem = hDoc.FirstChildElement("genrestrings").Element();
+ // should always have a valid root but handle gracefully if it does
+ if (!pElem)
+ {
+ XBMC->Log(LOG_DEBUG, "Could not find <genrestrings> element");
+ return false;
+ }
+
+ //This should hold: pElem->Value() == "genrestrings"
+
+ // save this for later
+ hRoot=TiXmlHandle(pElem);
+
+ // iterate through all genre elements
+ TiXmlElement* pGenreNode = hRoot.FirstChildElement("genre").Element();
+ //This should hold: pGenreNode->Value() == "genre"
+
+ if (!pGenreNode)
+ {
+ XBMC->Log(LOG_DEBUG, "Could not find <genre> element");
+ return false;
+ }
+
+ for (; pGenreNode != NULL; pGenreNode = pGenreNode->NextSiblingElement("genre"))
+ {
+ const char* sGenreString = pGenreNode->GetText();
+
+ if (sGenreString)
+ {
+ sGenreType = pGenreNode->Attribute("type");
+ sGenreSubType = pGenreNode->Attribute("subtype");
+
+ if ((sGenreType) && (strlen(sGenreType) > 2))
+ {
+ if(sscanf(sGenreType + 2, "%x", &genre.type) != 1)
+ genre.type = 0;
+ }
+ else
+ {
+ genre.type = 0;
+ }
+
+ if ((sGenreSubType) && (strlen(sGenreSubType) > 2 ))
+ {
+ if(sscanf(sGenreSubType + 2, "%x", &genre.subtype) != 1)
+ genre.subtype = 0;
+ }
+ else
+ {
+ genre.subtype = 0;
+ }
+
+ if (genre.type > 0)
+ {
+ XBMC->Log(LOG_DEBUG, "Genre '%s' => 0x%x, 0x%x", sGenreString, genre.type, genre.subtype);
+ m_genremap.insert(std::pair<std::string, genre_t>(sGenreString, genre));
+ }
+ }
+ }
+
+ return true;
+}
+
+void CGenreTable::GenreToTypes(string& strGenre, int& genreType, int& genreSubType)
+{
+ // The xmltv plugin from the MediaPortal TV Server can return genre
+ // strings in local language (depending on the external TV guide source).
+ // The only way to solve this at the XMBC side is to transfer the
+ // genre string to XBMC or to let this plugin (or the TVServerXBMC
+ // plugin) translate it into XBMC compatible (numbered) genre types
+ string m_genre = strGenre;
+
+ if(m_genremap.size() > 0 && m_genre.length() > 0)
+ {
+ GenreMap::iterator it;
+
+ std::transform(m_genre.begin(), m_genre.end(), m_genre.begin(), ::tolower);
+
+ it = m_genremap.find(m_genre);
+ if (it != m_genremap.end())
+ {
+ genreType = it->second.type;
+ genreSubType = it->second.subtype;
+ }
+ else
+ {
+ XBMC->Log(LOG_DEBUG, "EPG: No mapping of '%s' to genre type/subtype found.", strGenre.c_str());
+ genreType = EPG_GENRE_USE_STRING;
+ genreSubType = 0;
+ }
+ }
+ else
+ {
+ genreType = 0;
+ genreSubType = 0;
+ }
+}
View
35 .../pvrclients/MediaPortal/CriticalSection.h → xbmc/pvrclients/MediaPortal/GenreTable.h
@@ -1,6 +1,6 @@
#pragma once
/*
- * Copyright (C) 2005-2011 Team XBMC
+ * Copyright (C) 2005-2012 Team XBMC
* http://www.xbmc.org
*
* This program is free software: you can redistribute it and/or modify
@@ -17,18 +17,29 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "os-dependent.h"
+#include <map>
+#include <string>
-class CCriticalSection
-{
- public:
- CCriticalSection();
- virtual ~CCriticalSection();
+typedef struct genre {
+ int type;
+ int subtype;
+} genre_t;
+
+typedef std::map<std::string, genre_t> GenreMap;
- void Initialize(void);
- void Lock(void);
- void Unlock(void);
+class CGenreTable
+{
+public:
+ CGenreTable(const std::string &filename) { LoadGenreXML(filename); };
+ bool LoadGenreXML(const std::string &filename);
- protected:
- criticalsection_t m_CriticalSection;
+ /**
+ * \brief Convert a genre string into a type/subtype combination using the data in the GenreMap
+ * \param strGenre (in)
+ * \param genreType (out)
+ * \param genreSubType (out)
+ */
+ void GenreToTypes(std::string& strGenre, int& genreType, int& genreSubType);
+private:
+ GenreMap m_genremap;
};
View
12 xbmc/pvrclients/MediaPortal/Makefile.in
@@ -5,9 +5,9 @@
# how to reach the author.
#
-LIBS = @abs_top_srcdir@/lib/libTcpSocket/libTcpSocket.a lib/tinyxml/tinyxml.a -ldl
+LIBS = lib/tinyxml/tinyxml.a -ldl
LIBDIR = @abs_top_srcdir@/addons/pvr.team-mediaportal.tvserver
-LIB = @abs_top_srcdir@/addons/pvr.team-mediaportal.tvserver/XBMC_MPTV.pvr
+LIB = $(LIBDIR)/XBMC_MPTV.pvr
SRCS = channels.cpp \
client.cpp \
@@ -18,18 +18,16 @@ SRCS = channels.cpp \
Socket.cpp \
uri.cpp \
utils.cpp \
- CriticalSection.cpp \
- AutoLock.cpp \
- Cards.cpp
+ Cards.cpp \
+ GenreTable.cpp
include ../Makefile.include
clean:
-rm -f $(OBJS) $(LIB) *.P *~
$(MAKE) -C lib/tinyxml clean
- $(MAKE) -C @abs_top_srcdir@/lib/libTcpSocket clean
+
$(LIB): $(OBJS)
- $(MAKE) -C @abs_top_srcdir@/lib/libTcpSocket
$(MAKE) -C lib/tinyxml
$(SILENT_CPP) $(CXX) $(CXXFLAGS) $(LDFLAGS) -shared -g $(OBJS) $(LIBS) $(LIBDIRS) $(SILIB) -o $(LIB)
View
4 xbmc/pvrclients/MediaPortal/README
@@ -6,8 +6,8 @@ Supported platforms (pvrclient):
- OSX (should work, not tested by me)
Dependencies:
-- MediaPortal TVServer 1.1.0 or higher
-- TVServerXBMC v1.1.0.90 or higher
+- MediaPortal TVServer 1.1.x or 1.2.x. May work also on newer versions
+- TVServerXBMC v1.1.0.100 or higher
THIS IS A PRELIMINARY README AND IS SUBJECT TO CHANGE!!!
View
21 xbmc/pvrclients/MediaPortal/Socket.cpp
@@ -16,17 +16,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-extern "C" {
-#include "libTcpSocket/os-dependent_socket.h"
-}
#include "libXBMC_addon.h"
#include "utils.h"
+#include <string>
+#include "os-dependent.h"
#include "client.h"
#include "Socket.h"
-#include <string>
using namespace std;
using namespace ADDON;
+using namespace MPTV;
namespace MPTV
{
@@ -83,12 +82,16 @@ bool Socket::setHostname ( const std::string host )
return true;
}
-
bool Socket::close()
{
if (is_valid())
{
- tcp_close(_sd);
+ if (_sd != SOCKET_ERROR)
+#ifdef TARGET_WINDOWS
+ closesocket(_sd);
+#else
+ ::close(_sd);
+#endif
_sd = INVALID_SOCKET;
osCleanup();
return true;
@@ -493,7 +496,7 @@ bool Socket::is_valid() const
return (_sd != INVALID_SOCKET);
}
-#if defined(_WIN32) || defined(_WIN64)
+#if defined(TARGET_WINDOWS)
bool Socket::set_non_blocking ( const bool b )
{
u_long iMode;
@@ -635,7 +638,7 @@ void Socket::osCleanup()
}
}
-#elif defined _LINUX
+#elif defined TARGET_LINUX
bool Socket::set_non_blocking ( const bool b )
{
int opts;
@@ -747,6 +750,6 @@ void Socket::osCleanup()
{
// Not needed for Linux
}
-#endif //_WINDOWS || _LINUX
+#endif //TARGET_WINDOWS || TARGET_LINUX
} //namespace MPTV
View
17 xbmc/pvrclients/MediaPortal/Socket.h
@@ -22,11 +22,11 @@ namespace MPTV //Prevent name clash with Live555 Socket
{
//Include platform specific datatypes, header files, defines and constants:
-#if defined __WINDOWS__ || defined WIN32 || defined _WINDOWS
- #ifdef _WINSOCKAPI_
- #undef _WINSOCKAPI_
- #endif
+#if defined TARGET_WINDOWS
+ #define WIN32_LEAN_AND_MEAN // Enable LEAN_AND_MEAN support
+ #pragma warning(disable:4005) // Disable "warning C4005: '_WINSOCKAPI_' : macro redefinition"
#include <winsock2.h>
+ #pragma warning(default:4005)
#include <windows.h>
#ifndef NI_MAXHOST
@@ -42,7 +42,7 @@ namespace MPTV //Prevent name clash with Live555 Socket
#ifndef port_t
typedef unsigned short port_t;
#endif
-#elif defined _LINUX
+#elif defined TARGET_LINUX || defined TARGET_DARWIN
#include <sys/types.h> /* for socket,connect */
#include <sys/socket.h> /* for socket,connect */
#include <sys/un.h> /* for Unix socket */
@@ -56,7 +56,8 @@ namespace MPTV //Prevent name clash with Live555 Socket
typedef int SOCKET;
typedef sockaddr SOCKADDR;
typedef sockaddr_in SOCKADDR_IN;
-
+ #define INVALID_SOCKET (-1)
+ #define SOCKET_ERROR (-1)
#else
#error Platform specific socket support is not yet available on this platform!
#endif
@@ -79,7 +80,7 @@ enum SocketFamily
enum SocketDomain
{
- #if defined _LINUX
+ #if defined TARGET_LINUX || defined TARGET_DARWIN
pf_unix = PF_UNIX,
pf_local = PF_LOCAL,
#endif
@@ -287,7 +288,7 @@ class Socket
enum SocketType _type; ///< Socket Type
enum SocketDomain _domain; ///< Socket domain
- #ifdef _WINDOWS
+ #ifdef TARGET_WINDOWS
WSADATA _wsaData; ///< Windows Socket data
static int win_usage_count; ///< Internal Windows usage counter used to prevent a global WSACleanup when more than one Socket object is used
#endif
View
11 xbmc/pvrclients/MediaPortal/client.cpp
@@ -248,7 +248,7 @@ void ADDON_ReadSettings(void)
if (!XBMC->GetSetting("readgenre", &g_bReadGenre))
{
/* If setting is unknown fallback to defaults */
- XBMC->Log(LOG_ERROR, "Couldn't get 'resolvertsphostname' setting, falling back to 'true' as default");
+ XBMC->Log(LOG_ERROR, "Couldn't get 'readgenre' setting, falling back to 'true' as default");
g_bReadGenre = DEFAULT_READ_GENRE;
}
@@ -416,7 +416,10 @@ PVR_ERROR GetStreamProperties(PVR_STREAM_PROPERTIES *pProperties)
//-----------------------------------------------------------------------------
const char * GetBackendName(void)
{
- return g_client->GetBackendName();
+ if (g_client)
+ return g_client->GetBackendName();
+ else
+ return "";
}
//-- GetBackendVersion --------------------------------------------------------
@@ -457,7 +460,7 @@ PVR_ERROR GetBackendTime(time_t *localTime, int *gmtOffset)
if (!g_client)
return PVR_ERROR_SERVER_ERROR;
else
- return g_client->GetMPTVTime(localTime, gmtOffset);
+ return g_client->GetBackendTime(localTime, gmtOffset);
}
PVR_ERROR DialogChannelScan()
@@ -677,7 +680,7 @@ PVR_ERROR SignalStatus(PVR_SIGNAL_STATUS &signalStatus)
if (!g_client)
return PVR_ERROR_SERVER_ERROR;
else
- return g_client->GetSignalStatus(signalStatus);
+ return g_client->SignalStatus(signalStatus);
}
/*******************************************/
View
6 xbmc/pvrclients/MediaPortal/client.h
@@ -23,7 +23,7 @@
#ifndef CLIENT_H
#define CLIENT_H
-#include "utils/StdString.h"
+#include "platform/util/StdString.h"
#include "libXBMC_addon.h"
#include "libXBMC_pvr.h"
@@ -31,7 +31,7 @@
#define DEFAULT_PORT 9596
#define DEFAULT_FTA_ONLY false
#define DEFAULT_RADIO true
-#define DEFAULT_TIMEOUT 6
+#define DEFAULT_TIMEOUT 10
#define DEFAULT_HANDLE_MSG false
#define DEFAULT_RESOLVE_RTSP_HOSTNAME true
#define DEFAULT_READ_GENRE false
@@ -64,7 +64,7 @@ extern std::string g_szTVGroup;
extern std::string g_szRadioGroup;
extern ADDON::CHelper_libXBMC_addon *XBMC;
-extern CHelper_libXBMC_pvr *PVR;
+extern CHelper_libXBMC_pvr *PVR;
extern int g_iTVServerXBMCBuild;
View
42 xbmc/pvrclients/MediaPortal/epg.cpp
@@ -31,7 +31,7 @@ using namespace ADDON;
cEpg::cEpg()
{
- m_genremap = NULL;
+ m_genretable = NULL;
Reset();
}
@@ -108,7 +108,8 @@ bool cEpg::ParseLine(string& data)
m_title = epgfields[2];
m_description = epgfields[3];
m_shortText = epgfields[2];
- SetGenre(epgfields[4], 0, 0);
+ m_genre = epgfields[4];
+ if (m_genretable) m_genretable->GenreToTypes(m_genre, m_genre_type, m_genre_subtype);
if( epgfields.size() >= 15 )
{
@@ -142,40 +143,7 @@ bool cEpg::ParseLine(string& data)
return false;
}
-void cEpg::SetGenreMap(GenreMap* genremap)
+void cEpg::SetGenreTable(CGenreTable* genretable)
{
- m_genremap = genremap;
-}
-
-void cEpg::SetGenre(string& Genre, int genreType, int genreSubType)
-{
- // The xmltv plugin from the MediaPortal TV Server can return genre
- // strings in local language (depending on the external TV guide source).
- // The only way to solve this at the XMBC side is to transfer the
- // genre string to XBMC or to let this plugin (or the TVServerXBMC
- // plugin) translate it into XBMC compatible (numbered) genre types
- m_genre = Genre;
- m_genre_subtype = 0;
-
- if(g_bReadGenre && m_genremap && m_genre.length() > 0)
- {
- std::map<std::string, genre_t>::iterator it;
-
- std::transform(m_genre.begin(), m_genre.end(), m_genre.begin(), ::tolower);
-
- it = m_genremap->find(m_genre);
- if (it != m_genremap->end())
- {
- m_genre_type = it->second.type;
- m_genre_subtype = it->second.subtype;
- }
- else
- {
- XBMC->Log(LOG_DEBUG, "EPG: No mapping of '%s' to genre type/subtype found.", Genre.c_str());
- m_genre_type = EPG_GENRE_USE_STRING;
- m_genre_subtype = 0;
- }
- } else {
- m_genre_type = 0;
- }
+ m_genretable = genretable;
}
View
14 xbmc/pvrclients/MediaPortal/epg.h
@@ -24,20 +24,13 @@
#define __EPG_H
#include <stdlib.h>
-#include <map>
#include <string>
#include "libXBMC_addon.h"
#include "libXBMC_pvr.h"
+#include "GenreTable.h"
using namespace std;
-typedef struct genre {
- int type;
- int subtype;
-} genre_t;
-
-typedef std::map<std::string, genre_t> GenreMap;
-
class cEpg
{
private:
@@ -58,8 +51,7 @@ class cEpg
int m_seriesNumber;
int m_starRating;
int m_parentalRating;
- GenreMap* m_genremap;
- void SetGenre(string& Genre, int genreType, int genreSubType);
+ CGenreTable* m_genretable;
public:
cEpg();
@@ -84,7 +76,7 @@ class cEpg
const char* EpisodePart(void) const { return m_episodePart.c_str(); };
int StarRating(void) const { return m_starRating; };
int ParentalRating(void) const { return m_parentalRating; };
- void SetGenreMap(GenreMap* genremap);
+ void SetGenreTable(CGenreTable* genremap);
};
#endif //__EPG_H
View
5 xbmc/pvrclients/MediaPortal/os-dependent.h
@@ -19,11 +19,10 @@
*/
#if defined(TARGET_WINDOWS)
-// I don't want pthread_win32 stuff to be included
-#define PTHREAD_H
+#define NOMINMAX // don't define min() and max() to prevent a clash with std::min() and std::max
#endif
-#include "libPlatform/os-dependent.h"
+#include "platform/os.h"
#if defined(TARGET_WINDOWS)
# include "windows/os_windows.h"
View
13 xbmc/pvrclients/MediaPortal/project/VS2010Express/XBMC_MPTV.vcxproj
@@ -51,8 +51,8 @@
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.pvr</TargetExt>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">XBMC_MPTV_win32</TargetName>
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.pvr</TargetExt>
- <IncludePath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)\..\..\xbmc\;$(SolutionDir)\..\..\lib\;$(IncludePath)</IncludePath>
- <IncludePath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)\..\..\xbmc\;$(SolutionDir)\..\..\lib\;$(IncludePath)</IncludePath>
+ <IncludePath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)\..\..\xbmc\;$(SolutionDir)\..\..\lib\;$(IncludePath);..\..\</IncludePath>
+ <IncludePath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)\..\..\xbmc\;$(SolutionDir)\..\..\lib\;$(IncludePath);..\..\</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
@@ -118,13 +118,12 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
- <ClCompile Include="..\..\AutoLock.cpp" />
<ClCompile Include="..\..\Cards.cpp" />
<ClCompile Include="..\..\channels.cpp" />
<ClCompile Include="..\..\client.cpp" />
<ClCompile Include="..\..\..\..\..\addons\library.xbmc.addon\dlfcn-win32.cpp" />
- <ClCompile Include="..\..\CriticalSection.cpp" />
<ClCompile Include="..\..\epg.cpp" />
+ <ClCompile Include="..\..\GenreTable.cpp" />
<ClCompile Include="..\..\lib\tinyxml\tinystr.cpp" />
<ClCompile Include="..\..\lib\tinyxml\tinyxml.cpp" />
<ClCompile Include="..\..\lib\tinyxml\tinyxmlerror.cpp" />
@@ -135,15 +134,16 @@
<ClCompile Include="..\..\timers.cpp" />
<ClCompile Include="..\..\uri.cpp" />
<ClCompile Include="..\..\utils.cpp" />
+ <ClCompile Include="..\..\windows\FileUtils.cpp" />
+ <ClCompile Include="..\..\windows\WindowsUtils.cpp" />
</ItemGroup>
<ItemGroup>
- <ClInclude Include="..\..\AutoLock.h" />
<ClInclude Include="..\..\Cards.h" />
<ClInclude Include="..\..\channels.h" />
<ClInclude Include="..\..\client.h" />
<ClInclude Include="..\..\..\..\..\addons\library.xbmc.addon\dlfcn-win32.h" />
- <ClInclude Include="..\..\CriticalSection.h" />
<ClInclude Include="..\..\epg.h" />
+ <ClInclude Include="..\..\FileUtils.h" />
<ClInclude Include="..\..\lib\tinyxml\tinystr.h" />
<ClInclude Include="..\..\lib\tinyxml\tinyxml.h" />
<ClInclude Include="..\..\os-dependent.h" />
@@ -155,6 +155,7 @@
<ClInclude Include="..\..\uri.h" />
<ClInclude Include="..\..\utils.h" />
<ClInclude Include="..\..\windows\os_windows.h" />
+ <ClInclude Include="..\..\windows\WindowsUtils.h" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\README" />
View
24 xbmc/pvrclients/MediaPortal/project/VS2010Express/XBMC_MPTV.vcxproj.filters
@@ -18,6 +18,9 @@
<Filter Include="Header Files\windows">
<UniqueIdentifier>{cdeb5df5-f5b2-482d-9cb4-9e13a05233bd}</UniqueIdentifier>
</Filter>
+ <Filter Include="Source Files\windows">
+ <UniqueIdentifier>{a514608f-59ee-4524-b1bc-2ca2ad6dde70}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\channels.cpp">
@@ -65,10 +68,13 @@
<ClCompile Include="..\..\lib\tinyxml\tinyxmlparser.cpp">
<Filter>Source Files\tinyXML</Filter>
</ClCompile>
- <ClCompile Include="..\..\AutoLock.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\..\windows\FileUtils.cpp">
+ <Filter>Source Files\windows</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\windows\WindowsUtils.cpp">
+ <Filter>Source Files\windows</Filter>
</ClCompile>
- <ClCompile Include="..\..\CriticalSection.cpp">
+ <ClCompile Include="..\..\GenreTable.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
@@ -112,12 +118,6 @@
<ClInclude Include="..\..\lib\tinyxml\tinyxml.h">
<Filter>Header Files\tinyXML</Filter>
</ClInclude>
- <ClInclude Include="..\..\AutoLock.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\..\CriticalSection.h">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="..\..\os-dependent.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -127,6 +127,12 @@
<ClInclude Include="..\..\posix\os_posix.h">
<Filter>Header Files\windows</Filter>
</ClInclude>
+ <ClInclude Include="..\..\windows\WindowsUtils.h">
+ <Filter>Header Files\windows</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\FileUtils.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\README" />
View
286 xbmc/pvrclients/MediaPortal/pvrclient-mediaportal.cpp
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include "os-dependent.h"
+#include "platform/util/timeutils.h"
#include "client.h"
#include "timers.h"
@@ -30,8 +31,10 @@
#include "epg.h"
#include "utils.h"
#include "pvrclient-mediaportal.h"
-#include "AutoLock.h"
-#include "lib/tinyxml/tinyxml.h"
+
+#ifdef TARGET_WINDOWS
+#include "FileUtils.h"
+#endif
using namespace std;
using namespace ADDON;
@@ -40,13 +43,13 @@ using namespace ADDON;
int g_iTVServerXBMCBuild = 0;
/* PVR client version (don't forget to update also the addon.xml and the Changelog.txt files) */
-#define PVRCLIENT_MEDIAPORTAL_VERSION_STRING "1.2.1.108"
+#define PVRCLIENT_MEDIAPORTAL_VERSION_STRING "1.2.2.111"
/* TVServerXBMC plugin supported versions */
#define TVSERVERXBMC_MIN_VERSION_STRING "1.1.0.70"
#define TVSERVERXBMC_MIN_VERSION_BUILD 70
-#define TVSERVERXBMC_RECOMMENDED_VERSION_STRING "1.1.x.107"
-#define TVSERVERXBMC_RECOMMENDED_VERSION_BUILD 107
+#define TVSERVERXBMC_RECOMMENDED_VERSION_STRING "1.1.x.109 or 1.2.2.111"
+#define TVSERVERXBMC_RECOMMENDED_VERSION_BUILD 110
/************************************************************/
/** Class interface */
@@ -62,7 +65,8 @@ cPVRClientMediaPortal::cPVRClientMediaPortal()
m_BackendUTCoffset = 0;
m_BackendTime = 0;
m_bStop = true;
- m_mutex.Initialize();
+ m_genretable = NULL;
+ m_iLastRecordingUpdate = 0;
}
cPVRClientMediaPortal::~cPVRClientMediaPortal()
@@ -71,13 +75,14 @@ cPVRClientMediaPortal::~cPVRClientMediaPortal()
if (m_bConnected)
Disconnect();
SAFE_DELETE(m_tcpclient);
+ SAFE_DELETE(m_genretable);
}
string cPVRClientMediaPortal::SendCommand(string command)
{
int code;
vector<string> lines;
- CAutoLock critsec(&m_mutex);
+ PLATFORM::CLockObject critsec(m_mutex);
if ( !m_tcpclient->send(command) )
{
@@ -107,7 +112,7 @@ string cPVRClientMediaPortal::SendCommand(string command)
bool cPVRClientMediaPortal::SendCommand2(string command, int& code, vector<string>& lines)
{
- CAutoLock critsec(&m_mutex);
+ PLATFORM::CLockObject critsec(m_mutex);
if ( !m_tcpclient->send(command) )
{
@@ -195,7 +200,7 @@ bool cPVRClientMediaPortal::Connect()
// Check for the minimal requirement: 1.1.0.70
if( g_iTVServerXBMCBuild < TVSERVERXBMC_MIN_VERSION_BUILD ) //major < 1 || minor < 1 || revision < 0 || build < 70
{
- XBMC->Log(LOG_ERROR, "Your TVServerXBMC version v%s is too old. Please upgrade to v%s or higher!", fields[1].c_str(), TVSERVERXBMC_MIN_VERSION_STRING);
+ XBMC->Log(LOG_ERROR, "Your TVServerXBMC version '%s' is too old. Please upgrade to '%s' or higher!", fields[1].c_str(), TVSERVERXBMC_MIN_VERSION_STRING);
XBMC->QueueNotification(QUEUE_ERROR, XBMC->GetLocalizedString(30050), fields[1].c_str(), TVSERVERXBMC_MIN_VERSION_STRING);
return false;
}
@@ -206,13 +211,13 @@ bool cPVRClientMediaPortal::Connect()
// Advice to upgrade:
if( g_iTVServerXBMCBuild < TVSERVERXBMC_RECOMMENDED_VERSION_BUILD )
{
- XBMC->Log(LOG_INFO, "It is adviced to upgrade your TVServerXBMC version v%s to v%s or higher!", fields[1].c_str(), TVSERVERXBMC_RECOMMENDED_VERSION_STRING);
+ XBMC->Log(LOG_INFO, "It is adviced to upgrade your TVServerXBMC version '%s' to '%s' or higher!", fields[1].c_str(), TVSERVERXBMC_RECOMMENDED_VERSION_STRING);
}
}
}
else
{
- XBMC->Log(LOG_ERROR, "Your TVServerXBMC version is too old. Please upgrade to v%s or higher!", TVSERVERXBMC_MIN_VERSION_STRING);
+ XBMC->Log(LOG_ERROR, "Your TVServerXBMC version is too old. Please upgrade to '%s' or higher!", TVSERVERXBMC_MIN_VERSION_STRING);
XBMC->QueueNotification(QUEUE_ERROR, XBMC->GetLocalizedString(30051), TVSERVERXBMC_MIN_VERSION_STRING);
return false;
}
@@ -241,8 +246,7 @@ bool cPVRClientMediaPortal::Connect()
if(g_bReadGenre)
{
string sGenreFile = g_szClientPath + PATH_SEPARATOR_CHAR + "resources" + PATH_SEPARATOR_CHAR + "genre_translation.xml";
-
- LoadGenreXML(sGenreFile);
+ m_genretable = new CGenreTable(sGenreFile);
}
return true;
@@ -366,7 +370,7 @@ PVR_ERROR cPVRClientMediaPortal::GetDriveSpace(long long *iTotal, long long *iUs
return PVR_ERROR_NO_ERROR;
}
-PVR_ERROR cPVRClientMediaPortal::GetMPTVTime(time_t *localTime, int *gmtOffset)
+PVR_ERROR cPVRClientMediaPortal::GetBackendTime(time_t *localTime, int *gmtOffset)
{
string result;
vector<string> fields;
@@ -475,8 +479,8 @@ PVR_ERROR cPVRClientMediaPortal::GetEpg(PVR_HANDLE handle, const PVR_CHANNEL &ch
{
if( result.length() != 0)
{
- memset(&broadcast, NULL, sizeof(EPG_TAG));
- epg.SetGenreMap(&m_genremap);
+ memset(&broadcast, 0, sizeof(EPG_TAG));
+ epg.SetGenreTable(m_genretable);
Tokenize(result, lines, ",");
@@ -600,7 +604,42 @@ PVR_ERROR cPVRClientMediaPortal::GetChannels(PVR_HANDLE handle, bool bRadio)
if( !SendCommand2(command.c_str(), code, lines) )
return PVR_ERROR_SERVER_ERROR;
- memset(&tag, NULL, sizeof(PVR_CHANNEL));
+#ifdef TARGET_WINDOWS
+ bool bCheckForThumbs = false;
+
+ /* Check if we can find the MediaPortal channel logo folders on this machine */
+ std::string strIconName;
+ std::string strThumbPath;
+ std::string strProgramData;
+
+ if (OS::GetEnvironmentVariable("PROGRAMDATA", strProgramData) == true)
+ strThumbPath = strProgramData + "\\Team MediaPortal\\MediaPortal\\Thumbs\\";
+ else
+ {
+ if (OS::Version() >= OS::WindowsVista)
+ {
+ /* Windows Vista/7/Server 2008 */
+ strThumbPath = "C:\\ProgramData\\Team MediaPortal\\MediaPortal\\Thumbs\\";
+ }
+ else
+ {
+ /* Windows XP */
+ if (OS::GetEnvironmentVariable("ALLUSERSPROFILE", strProgramData) == true)
+ strThumbPath = strProgramData + "\\Application Data\\Team MediaPortal\\MediaPortal\\thumbs\\";
+ else
+ strThumbPath = "C:\\Documents and Settings\\All Users\\Application Data\\Team MediaPortal\\MediaPortal\\thumbs\\";
+ }
+ }
+
+ if (bRadio)
+ strThumbPath += "Radio\\";
+ else
+ strThumbPath += "TV\\logos\\";
+
+ bCheckForThumbs = OS::CFile::Exists(strThumbPath);
+#endif // TARGET_WINDOWS
+
+ memset(&tag, 0, sizeof(PVR_CHANNEL));
for (vector<string>::iterator it = lines.begin(); it < lines.end(); it++)
{
@@ -623,11 +662,25 @@ PVR_ERROR cPVRClientMediaPortal::GetChannels(PVR_HANDLE handle, bool bRadio)
tag.iUniqueId = channel.UID();
tag.iChannelNumber = g_iTVServerXBMCBuild >= 102 ? channel.ExternalID() : channel.UID();
tag.strChannelName = channel.Name();
+#ifdef TARGET_WINDOWS
+ if (bCheckForThumbs)
+ {
+ strIconName = strThumbPath + ToThumbFileName(channel.Name()) + ".png";
+ if ( OS::CFile::Exists(strIconName) )
+ {
+ tag.strIconPath = strIconName.c_str();
+ }
+ else
+ {
+ tag.strIconPath = "";
+ }
+ }
+#else
tag.strIconPath = "";
+#endif
tag.iEncryptionSystem = channel.Encrypted();
tag.bIsRadio = bRadio; //TODO:(channel.Vpid() == 0) && (channel.Apid(0) != 0) ? true : false;
tag.bIsHidden = false;
-// tag.bIsRecording = false;
if(channel.IsWebstream())
{
@@ -696,12 +749,12 @@ PVR_ERROR cPVRClientMediaPortal::GetChannelGroups(PVR_HANDLE handle, bool bRadio
}
else
{
- XBMC->Log(LOG_DEBUG, "RequestChannelList for TV group:%s", g_szTVGroup.c_str());
- if (!SendCommand2("ListRadioGroups\n", code, lines))
+ XBMC->Log(LOG_DEBUG, "GetChannelGroups for TV");
+ if (!SendCommand2("ListGroups\n", code, lines))
return PVR_ERROR_SERVER_ERROR;
}
- memset(&tag, 0 , sizeof(PVR_CHANNEL_GROUP));
+ memset(&tag, 0, sizeof(PVR_CHANNEL_GROUP));
for (vector<string>::iterator it = lines.begin(); it < lines.end(); it++)
{
@@ -709,10 +762,7 @@ PVR_ERROR cPVRClientMediaPortal::GetChannelGroups(PVR_HANDLE handle, bool bRadio
if (data.length() == 0)
{
- if(bRadio)
- XBMC->Log(LOG_DEBUG, "TVServer returned no data. No radio groups found?");
- else
- XBMC->Log(LOG_DEBUG, "TVServer returned no data. No TVo groups found?");
+ XBMC->Log(LOG_DEBUG, "TVServer returned no data. No %s groups found?", ((bRadio) ? "radio" : "tv"));
break;
}
@@ -720,7 +770,7 @@ PVR_ERROR cPVRClientMediaPortal::GetChannelGroups(PVR_HANDLE handle, bool bRadio
tag.bIsRadio = bRadio;
tag.strGroupName = data.c_str();
-
+ XBMC->Log(LOG_DEBUG, "Adding %s group: %s", ((bRadio) ? "radio" : "tv"), tag.strGroupName);
PVR->TransferChannelGroup(handle, &tag);
}
@@ -760,7 +810,7 @@ PVR_ERROR cPVRClientMediaPortal::GetChannelGroupMembers(PVR_HANDLE handle, const
if (!SendCommand2(command.c_str(), code, lines))
return PVR_ERROR_SERVER_ERROR;
- memset(&tag,0 , sizeof(PVR_CHANNEL_GROUP_MEMBER));
+ memset(&tag, 0, sizeof(PVR_CHANNEL_GROUP_MEMBER));
for (vector<string>::iterator it = lines.begin(); it < lines.end(); it++)
{
@@ -839,7 +889,7 @@ PVR_ERROR cPVRClientMediaPortal::GetRecordings(PVR_HANDLE handle)
Tokenize(result, lines, ",");
- memset(&tag, NULL, sizeof(PVR_RECORDING));
+ memset(&tag, 0, sizeof(PVR_RECORDING));
for (vector<string>::iterator it = lines.begin(); it != lines.end(); it++)
{
@@ -849,8 +899,11 @@ PVR_ERROR cPVRClientMediaPortal::GetRecordings(PVR_HANDLE handle)
XBMC->Log(LOG_DEBUG, "RECORDING: %s", data.c_str() );
CStdString strRecordingId;
+ CStdString strDirectory;
cRecording recording;
+
recording.SetCardSettings(&m_cCards);
+ recording.SetGenreTable(m_genretable);
if (recording.ParseLine(data))
{
@@ -858,7 +911,6 @@ PVR_ERROR cPVRClientMediaPortal::GetRecordings(PVR_HANDLE handle)
tag.strRecordingId = strRecordingId.c_str();
tag.strTitle = recording.Title();
- tag.strDirectory = recording.Directory(); // used in XBMC as directory structure below "Recordings"
tag.strPlotOutline = g_iTVServerXBMCBuild >= 105 ? recording.EpisodeName() : tag.strTitle;
tag.strPlot = recording.Description();
tag.strChannelName = recording.ChannelName();
@@ -866,8 +918,12 @@ PVR_ERROR cPVRClientMediaPortal::GetRecordings(PVR_HANDLE handle)
tag.iDuration = (int) recording.Duration();
tag.iPriority = 0; // only available for schedules, not for recordings
tag.iLifetime = recording.Lifetime();
- tag.iGenreType = 0; //TODO?
- tag.iGenreSubType = 0; //TODO?
+ tag.iGenreType = recording.GenreType();
+ tag.iGenreSubType = recording.GenreSubType();
+
+ strDirectory = recording.Directory();
+ strDirectory.Replace("\\", " - "); // XBMC supports only 1 sublevel below Recordings, so flatten the MediaPortal directory structure
+ tag.strDirectory = strDirectory.c_str(); // used in XBMC as directory structure below "Recordings"
if (g_bUseRecordingsDir == true)
{
@@ -891,6 +947,8 @@ PVR_ERROR cPVRClientMediaPortal::GetRecordings(PVR_HANDLE handle)
}
}
+ m_iLastRecordingUpdate = PLATFORM::GetTimeMs();
+
return PVR_ERROR_NO_ERROR;
}
@@ -996,6 +1054,11 @@ PVR_ERROR cPVRClientMediaPortal::GetTimers(PVR_HANDLE handle)
}
}
+ if ( PLATFORM::GetTimeMs() > m_iLastRecordingUpdate + 15000)
+ {
+ PVR->TriggerRecordingUpdate();
+ }
+
return PVR_ERROR_NO_ERROR;
}
@@ -1081,8 +1144,6 @@ PVR_ERROR cPVRClientMediaPortal::DeleteTimer(const PVR_TIMER &timer, bool bForce
// Although XBMC deletes this timer, we still have to trigger XBMC to update its timer list to
// remove the timer from the XBMC list
PVR->TriggerTimerUpdate();
- // When deleting a currently active (recording) timer, we need to refresh also the recording list
- PVR->TriggerRecordingUpdate();
return PVR_ERROR_NO_ERROR;
}
@@ -1113,7 +1174,6 @@ PVR_ERROR cPVRClientMediaPortal::UpdateTimer(const PVR_TIMER &timerinfo)
// Although XBMC changes this timer, we still have to trigger XBMC to update its timer list to
// see the timer changes at the XBMC side
PVR->TriggerTimerUpdate();
- PVR->TriggerRecordingUpdate();
return PVR_ERROR_NO_ERROR;
}
@@ -1136,6 +1196,7 @@ bool cPVRClientMediaPortal::OpenLiveStream(const PVR_CHANNEL &channelinfo)
string result;
char command[256] = "";
const char* sResolveRTSPHostname = booltostring(g_bResolveRTSPHostname);
+ vector<string> timeshiftfields;
XBMC->Log(LOG_DEBUG, "->OpenLiveStream(uid=%i)", channelinfo.iUniqueId);
if (!IsUp())
@@ -1144,8 +1205,10 @@ bool cPVRClientMediaPortal::OpenLiveStream(const PVR_CHANNEL &channelinfo)
return false;
}
- if (channelinfo.iUniqueId == m_iCurrentChannel)
+ if (((int)channelinfo.iUniqueId) == m_iCurrentChannel)
return true;
+ else
+ m_iCurrentChannel = -1; // make sure that it is not a valid channel nr in case it will fail lateron
// Start the timeshift
if (g_iTVServerXBMCBuild>=90)
@@ -1165,33 +1228,76 @@ bool cPVRClientMediaPortal::OpenLiveStream(const PVR_CHANNEL &channelinfo)
if (result.find("ERROR") != std::string::npos || result.length() == 0)
{
XBMC->Log(LOG_ERROR, "Could not start the timeshift for channel uid=%i. %s", channelinfo.iUniqueId, result.c_str());
- if (result.find("[ERROR]: TVServer answer: ") != std::string::npos)
+ if (g_iTVServerXBMCBuild>=109)
{
- //Skip first part: "[ERROR]: TVServer answer: "
- XBMC->QueueNotification(QUEUE_ERROR, "TVServer: %s", result.substr(26).c_str());
+ int tvresult;
+
+ Tokenize(result, timeshiftfields, "|");
+ //[0] = string error message
+ //[1] = TvResult (optional field. SendCommand can also return a timeout)
+
+ if(timeshiftfields.size()>1)
+ {
+ //For TVServer 1.2.1:
+ //enum TvResult
+ //{
+ // Succeeded = 0, (this is not an error)
+ // AllCardsBusy = 1,
+ // ChannelIsScrambled = 2,
+ // NoVideoAudioDetected = 3,
+ // NoSignalDetected = 4,
+ // UnknownError = 5,
+ // UnableToStartGraph = 6,
+ // UnknownChannel = 7,
+ // NoTuningDetails = 8,
+ // ChannelNotMappedToAnyCard = 9,
+ // CardIsDisabled = 10,
+ // ConnectionToSlaveFailed = 11,
+ // NotTheOwner = 12,
+ // GraphBuildingFailed = 13,
+ // SWEncoderMissing = 14,
+ // NoFreeDiskSpace = 15,
+ // NoPmtFound = 16,
+ //};
+
+ tvresult = atoi(timeshiftfields[1].c_str());
+ // Display one of the localized error messages 30060-30075
+ XBMC->QueueNotification(QUEUE_ERROR, XBMC->GetLocalizedString(30059 + (int) tvresult));
+ }
+ else
+ {
+ XBMC->QueueNotification(QUEUE_ERROR, result.c_str());
+ }
}
else
{
- //Skip first part: "[ERROR]: "
- XBMC->QueueNotification(QUEUE_ERROR, result.substr(7).c_str());
+ if (result.find("[ERROR]: TVServer answer: ") != std::string::npos)
+ {
+ //Skip first part: "[ERROR]: TVServer answer: "
+ XBMC->QueueNotification(QUEUE_ERROR, "TVServer: %s", result.substr(26).c_str());
+ }
+ else
+ {
+ //Skip first part: "[ERROR]: "
+ XBMC->QueueNotification(QUEUE_ERROR, result.substr(7).c_str());
+ }
}
m_iCurrentChannel = -1;
return false;
}
else
{
- vector<string> timeshiftfields;
-
Tokenize(result, timeshiftfields, "|");
//[0] = rtsp url
//[1] = original (unresolved) rtsp url
//[2] = timeshift buffer filename
//[3] = card id (TVServerXBMC build >= 106)
+ //[4] = tsbuffer pos (TVServerXBMC build >= 110)
+ //[5] = tsbuffer file nr (TVServerXBMC build >= 110)
m_PlaybackURL = timeshiftfields[0];
XBMC->Log(LOG_INFO, "Channel stream URL: %s, timeshift buffer: %s", m_PlaybackURL.c_str(), timeshiftfields[2].c_str());
- m_iCurrentChannel = channelinfo.iUniqueId;
if (g_iSleepOnRTSPurl > 0)
{
@@ -1208,6 +1314,8 @@ bool cPVRClientMediaPortal::OpenLiveStream(const PVR_CHANNEL &channelinfo)
m_bTimeShiftStarted = true;
}
+ // at this point everything is ready for playback
+ m_iCurrentChannel = (int) channelinfo.iUniqueId;
if (g_iTVServerXBMCBuild>=106)
{
m_iCurrentCard = atoi(timeshiftfields[3].c_str());
@@ -1245,7 +1353,7 @@ void cPVRClientMediaPortal::CloseLiveStream(void)
bool cPVRClientMediaPortal::SwitchChannel(const PVR_CHANNEL &channel)
{
- if (channel.iUniqueId == m_iCurrentChannel)
+ if (((int)channel.iUniqueId) == m_iCurrentChannel)
return true;
XBMC->Log(LOG_DEBUG, "SwitchChannel(uid=%i) ffmpeg rtsp: nothing to be done here... GetLiveSteamURL() should fetch a new rtsp url from the backend.", channel.iUniqueId);
@@ -1260,11 +1368,11 @@ int cPVRClientMediaPortal::GetCurrentClientChannel()
return m_iCurrentChannel;
}
-PVR_ERROR cPVRClientMediaPortal::GetSignalStatus(PVR_SIGNAL_STATUS &signalStatus)
+PVR_ERROR cPVRClientMediaPortal::SignalStatus(PVR_SIGNAL_STATUS &signalStatus)
{
- if (g_iTVServerXBMCBuild < 108)
+ if (g_iTVServerXBMCBuild < 108 || (m_iCurrentChannel == -1))
{
- // Not yet supported
+ // Not yet supported or playing webstream
return PVR_ERROR_NO_ERROR;
}
@@ -1330,7 +1438,6 @@ int cPVRClientMediaPortal::ReadRecordedStream(unsigned char *pBuffer, unsigned i
const char* cPVRClientMediaPortal::GetLiveStreamURL(const PVR_CHANNEL &channelinfo)
{
string result;
- char command[256] = "";
XBMC->Log(LOG_DEBUG, "->GetLiveStreamURL(uid=%i)", channelinfo.iUniqueId);
@@ -1343,86 +1450,3 @@ const char* cPVRClientMediaPortal::GetLiveStreamURL(const PVR_CHANNEL &channelin
return m_PlaybackURL.c_str();
}
}
-
-bool cPVRClientMediaPortal::LoadGenreXML(const std::string &filename)
-{
- TiXmlDocument xmlDoc;
- if (!xmlDoc.LoadFile(filename))
- {
- XBMC->Log(LOG_DEBUG, "unable to load %s: %s at line %d", filename.c_str(), xmlDoc.ErrorDesc(), xmlDoc.ErrorRow());
- return false;
- }
-
- XBMC->Log(LOG_DEBUG, "Opened %s to read genre string to type/subtype translation table", filename.c_str());
-
- TiXmlHandle hDoc(&xmlDoc);
- TiXmlElement* pElem;
- TiXmlHandle hRoot(0);
- string sGenre;
- const char* sGenreType = NULL;
- const char* sGenreSubType = NULL;
- genre_t genre;
-
- // block: genrestrings
- pElem = hDoc.FirstChildElement("genrestrings").Element();
- // should always have a valid root but handle gracefully if it does
- if (!pElem)
- {
- XBMC->Log(LOG_DEBUG, "Could not find <genrestrings> element");
- return false;
- }
-
- //This should hold: pElem->Value() == "genrestrings"
-
- // save this for later
- hRoot=TiXmlHandle(pElem);
-
- // iterate through all genre elements
- TiXmlElement* pGenreNode = hRoot.FirstChildElement("genre").Element();
- //This should hold: pGenreNode->Value() == "genre"
-
- if (!pGenreNode)
- {
- XBMC->Log(LOG_DEBUG, "Could not find <genre> element");
- return false;
- }
-
- for (; pGenreNode != NULL; pGenreNode = pGenreNode->NextSiblingElement("genre"))
- {
- const char* sGenreString = pGenreNode->GetText();
-
- if (sGenreString)
- {
- sGenreType = pGenreNode->Attribute("type");
- sGenreSubType = pGenreNode->Attribute("subtype");
-
- if ((sGenreType) && (strlen(sGenreType) > 2))
- {
- if(sscanf(sGenreType + 2, "%x", &genre.type) != 1)
- genre.type = 0;
- }
- else
- {
- genre.type = 0;
- }
-
- if ((sGenreSubType) && (strlen(sGenreSubType) > 2 ))
- {
- if(sscanf(sGenreSubType + 2, "%x", &genre.subtype) != 1)
- genre.subtype = 0;
- }
- else
- {
- genre.subtype = 0;
- }
-
- if (genre.type > 0)
- {
- XBMC->Log(LOG_DEBUG, "Genre '%s' => 0x%x, 0x%x", sGenreString, genre.type, genre.subtype);
- m_genremap.insert(std::pair<std::string, genre_t>(sGenreString, genre));
- }
- }
- }
-
- return true;
-}
View
12 xbmc/pvrclients/MediaPortal/pvrclient-mediaportal.h
@@ -27,7 +27,7 @@
#include "Socket.h"
#include "Cards.h"
#include "epg.h"
-#include "CriticalSection.h"
+#include "platform/threads/mutex.h"
class cPVRClientMediaPortal
{
@@ -49,7 +49,7 @@ class cPVRClientMediaPortal
const char* GetBackendVersion(void);
const char* GetConnectionString(void);
PVR_ERROR GetDriveSpace(long long *iTotal, long long *iUsed);
- PVR_ERROR GetMPTVTime(time_t *localTime, int *gmtOffset);
+ PVR_ERROR GetBackendTime(time_t *localTime, int *gmtOffset);
/* EPG handling */
PVR_ERROR GetEpg(PVR_HANDLE handle, const PVR_CHANNEL &channel, time_t iStart = NULL, time_t iEnd = NULL);
@@ -83,7 +83,7 @@ class cPVRClientMediaPortal
int ReadLiveStream(unsigned char *pBuffer, unsigned int iBufferSize);
int GetCurrentClientChannel();
bool SwitchChannel(const PVR_CHANNEL &channel);
- PVR_ERROR GetSignalStatus(PVR_SIGNAL_STATUS &signalStatus);
+ PVR_ERROR SignalStatus(PVR_SIGNAL_STATUS &signalStatus);
const char* GetLiveStreamURL(const PVR_CHANNEL &channel);
/* Record stream handling */
@@ -112,8 +112,10 @@ class cPVRClientMediaPortal
time_t m_BackendUTCoffset;
time_t m_BackendTime;
CCards m_cCards;
- GenreMap m_genremap;
- CCriticalSection m_mutex;
+ CGenreTable* m_genretable;
+ PLATFORM::CMutex m_mutex;
+ int64_t m_iLastRecordingUpdate;
+
void Close();
//Used for TV Server communication:
View
116 xbmc/pvrclients/MediaPortal/recordings.cpp
@@ -35,6 +35,11 @@ cRecording::cRecording()
m_Duration = 0;
m_Index = -1;
m_cardSettings = NULL;
+ m_channelID = 0;
+ m_isRecording = false;
+ m_genre_type = 0;
+ m_genre_subtype = 0;
+ m_genretable = NULL;
}
@@ -74,6 +79,9 @@ bool cRecording::ParseLine(const std::string& data)
//[13] episodePart (string)
//[14] seriesNumber (string)
//[15] scheduleID (int)
+ //[16] genre (string)
+ //[17] idchannel (int)
+ //[18] isrecording (bool)
m_Index = atoi(fields[0].c_str());
m_StartTime = DateTimeToTimeT(fields[1]);
@@ -121,49 +129,11 @@ bool cRecording::ParseLine(const std::string& data)
if( m_filePath.length() > 0 )
{
- size_t found = string::npos;
-
- if ((m_cardSettings) && (m_cardSettings->size() > 0))
- {
- for (CCards::iterator it = m_cardSettings->begin(); it < m_cardSettings->end(); it++)
- {
- // Determine whether the first part of the recording file name is shared with this card
- found = m_filePath.find(it->RecordingFolder);
- if (found != string::npos)
- {
- m_basePath = it->RecordingFolder + "\\";
- // Remove the base path
- m_fileName = m_filePath.substr(it->RecordingFolder.length()+1);
-
- // Extract subdirectories below the base path
- size_t found2 = m_fileName.find_last_of("/\\");
- if (found2 != string::npos)
- {
- m_directory = m_fileName.substr(0, found2+1);
- m_fileName = m_fileName.substr(found2+1);
- }
-
- break;
- }
- }
- }
-
- if (found == string::npos)
- {
- if (found != string::npos)
- {
- m_fileName = m_filePath.substr(found+1);
- m_directory = m_filePath.substr(0, found+1);
- }
- else
- {
- m_fileName = m_filePath;
- m_directory = "";
- }
- }
+ SplitFilePath();
}
else
{
+ m_basePath = "";
m_fileName = "";
m_directory = "";
}
@@ -188,6 +158,14 @@ bool cRecording::ParseLine(const std::string& data)
m_scheduleID = atoi( fields[15].c_str() );
}
+ if (fields.size() >= 19) // Since TVServerXBMC 1.2.x.111
+ {
+ m_genre = fields[16];
+ m_channelID = atoi( fields[17].c_str() );
+ m_isRecording = stringtobool( fields[18].c_str() );
+
+ if (m_genretable) m_genretable->GenreToTypes(m_genre, m_genre_type, m_genre_subtype);
+ }
return true;
}
else
@@ -196,11 +174,12 @@ bool cRecording::ParseLine(const std::string& data)
}
}
+
void cRecording::SetDirectory( string& directory )
{
CStdString tmp;
m_basePath = directory;
- tmp = m_basePath + m_directory + m_fileName;
+ tmp = m_basePath + m_directory + "\\" + m_fileName;
if( m_basePath.find("smb://") != string::npos )
{
@@ -253,3 +232,58 @@ int cRecording::Lifetime(void) const
return MAXLIFETIME;
}
}
+
+void cRecording::SplitFilePath(void)
+{
+ size_t found = string::npos;
+
+ // Try to find the base path used for this recording by searching for the
+ // card recording folder name in the the recording file name.
+ if ((m_cardSettings) && (m_cardSettings->size() > 0))
+ {
+ for (CCards::iterator it = m_cardSettings->begin(); it < m_cardSettings->end(); it++)
+ {
+ // Determine whether the first part of the recording file name is shared with this card
+ // Minimal name length of the RecordingFolder should be 3 (drive letter + :\)
+ if (it->RecordingFolder.length() >= 3)
+ {
+ found = m_filePath.find(it->RecordingFolder);
+ if (found != string::npos)
+ {
+ m_basePath = it->RecordingFolder;
+ if (m_basePath.at(m_basePath.length() - 1) != '\\')
+ m_basePath += "\\";
+
+ // Remove the base path
+ m_fileName = m_filePath.substr(it->RecordingFolder.length()+1);
+
+ // Extract subdirectories below the base path
+ size_t found2 = m_fileName.find_last_of("/\\");
+ if (found2 != string::npos)
+ {
+ m_directory = m_fileName.substr(0, found2);
+ m_fileName = m_fileName.substr(found2+1);
+ }
+ else
+ {
+ m_directory = "";
+ }
+
+ break;
+ }
+ }
+ }
+ }
+
+ if (found == string::npos)
+ {
+ m_fileName = m_filePath;
+ m_directory = "";
+ m_basePath = "";
+ }
+}
+
+void cRecording::SetGenreTable(CGenreTable* genretable)
+{
+ m_genretable = genretable;
+}
View
16 xbmc/pvrclients/MediaPortal/recordings.h
@@ -21,6 +21,7 @@
#include "libXBMC_addon.h"
#include "libXBMC_pvr.h"
#include "Cards.h"
+#include "GenreTable.h"
using namespace std;
@@ -32,6 +33,7 @@ class cRecording
{
private:
int m_Index;
+ int m_channelID;
string m_channelName;
string m_filePath; ///< The full recording path as returned by the backend
string m_basePath; ///< The base path shared by all recordings (to be determined from the Card settings)
@@ -51,6 +53,11 @@ class cRecording
int m_keepUntil;
time_t m_keepUntilDate; ///< MediaPortal keepUntilDate
CCards* m_cardSettings; ///< Pointer to the MediaPortal card settings. Will be used to determine the base path of the recordings
+ string m_genre;
+ int m_genre_type;
+ int m_genre_subtype;
+ bool m_isRecording;
+ CGenreTable* m_genretable;
public:
cRecording();
@@ -109,4 +116,13 @@ class cRecording
* \param the cardSettings
*/
void SetCardSettings(CCards* cardSettings);
+
+ /**
+ * \brief Parse Recording file path and divide it in 3 parts: base path, subdirectory and filename;
+ */
+ void SplitFilePath(void);
+
+ int GenreType(void) const { return m_genre_type; }
+ int GenreSubType(void) const { return m_genre_subtype; }
+ void SetGenreTable(CGenreTable* genremap);
};
View
4 xbmc/pvrclients/MediaPortal/timers.cpp
@@ -264,11 +264,11 @@ int cTimer::SchedRecType2RepeatFlags(ScheduleRecordingType schedtype)
int weekday = timeinfo.tm_wday; //days since Sunday [0-6]
// bit 0 = monday, need to convert weekday value to bitnumber:
if (weekday == 0)
- weekday = 6; //sunday
+ weekday = 6; // sunday 0100 0000
else
weekday--;
- weekdays = 2 << weekday;
+ weekdays = 1 << weekday;
break;
}
case EveryTimeOnThisChannel:
View
15 xbmc/pvrclients/MediaPortal/utils.cpp
@@ -16,13 +16,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-#if defined(_WIN32) || defined(_WIN64)
+#ifdef TARGET_WINDOWS
#pragma warning(disable:4244) //wchar to char = loss of data
#endif
#include "utils.h"
#include <string>
#include <stdio.h>
+#include "platform/util/StdString.h"
using namespace std;
@@ -46,6 +47,7 @@ void Tokenize(const string& str, vector<string>& tokens, const string& delimiter
}
}
+
std::string WStringToString(const std::wstring& s)
{
std::string temp(s.length(), ' ');
@@ -118,3 +120,14 @@ time_t DateTimeToTimeT(const std::string& datetime)
return retval;
}
+
+std::string ToThumbFileName(const char* strChannelName)
+{
+ CStdString strThumbName = strChannelName;
+
+ strThumbName.Replace(":","_");
+ strThumbName.Replace("/","_");
+ strThumbName.Replace("\\","_");
+
+ return strThumbName;
+}
View
9 xbmc/pvrclients/MediaPortal/utils.h
@@ -21,6 +21,10 @@
#include <ctime>
#include "uri.h"
+#ifdef TARGET_WINDOWS
+#include "windows/WindowsUtils.h"
+#endif
+
using namespace std;
/** Delete macros that make the pointer NULL again */
@@ -44,3 +48,8 @@ const char* booltostring(const bool b);
* Assumes the usage of somedatetimeval.ToString("u") in C#
*/
time_t DateTimeToTimeT(const std::string& datetime);
+
+/**
+ * @brief Filters forbidden filename characters from channel name and replaces them with _ )
+ */
+std::string ToThumbFileName(const char* strChannelName);
View
91 xbmc/pvrclients/MediaPortal/windows/FileUtils.cpp
@@ -0,0 +1,91 @@
+#include "FileUtils.h"
+#include "os_windows.h"
+#include <string>
+
+namespace OS
+{
+ bool CFile::Exists(const std::string& strFileName)
+ {
+ DWORD dwAttr = GetFileAttributes(strFileName.c_str());
+
+ if(dwAttr == 0xffffffff)
+ {
+ DWORD dwError = GetLastError();
+ if(dwError == ERROR_FILE_NOT_FOUND)
+ {
+ // file not found
+ return false;
+ }
+ else if(dwError == ERROR_PATH_NOT_FOUND)
+ {
+ // path not found
+ return false;
+ }
+ else if(dwError == ERROR_ACCESS_DENIED)
+ {
+ // file or directory exists, but access is denied
+ return false;
+ }
+ else
+ {
+ // some other error has occured
+ return false;
+ }
+ }
+ else
+ {
+ if(dwAttr & FILE_ATTRIBUTE_DIRECTORY)
+ {
+ return true;
+/*
+ // this is a directory
+ if(dwAttr & FILE_ATTRIBUTE_ARCHIVE)
+ // Directory is archive file
+ if(dwAttr & FILE_ATTRIBUTE_COMPRESSED)
+ // Directory is compressed
+ if(dwAttr & FILE_ATTRIBUTE_ENCRYPTED)
+ // Directory is encrypted
+ if(dwAttr & FILE_ATTRIBUTE_HIDDEN)
+ // Directory is hidden
+ if(dwAttr & FILE_ATTRIBUTE_READONLY)
+ // Directory is read-only
+ if(dwAttr & FILE_ATTRIBUTE_REPARSE_POINT)
+ // Directory has an associated reparse point
+ if(dwAttr & FILE_ATTRIBUTE_SYSTEM)
+ // Directory is part or used exclusively by the operating system
+*/
+ }
+ else
+ {
+ return true;
+/*
+ // this is an ordinary file
+ if(dwAttr & FILE_ATTRIBUTE_ARCHIVE)
+ // File is archive file
+ if(dwAttr & FILE_ATTRIBUTE_COMPRESSED)
+ // File is compressed
+ if(dwAttr & FILE_ATTRIBUTE_ENCRYPTED)
+ // File is encrypted
+ if(dwAttr & FILE_ATTRIBUTE_HIDDEN)
+ // File is hidden
+ if(dwAttr & FILE_ATTRIBUTE_NOT_CONTENT_INDEXED)
+ // File will not be indexed
+ if(dwAttr & FILE_ATTRIBUTE_OFFLINE)
+ // Data of file is not immediately available
+ if(dwAttr & FILE_ATTRIBUTE_READONLY)
+ // File is read-only
+ if(dwAttr & FILE_ATTRIBUTE_REPARSE_POINT)
+ // File has an associated reparse point
+ if(dwAttr & FILE_ATTRIBUTE_SPARSE_FILE)
+ // File is a sparse file
+ if(dwAttr & FILE_ATTRIBUTE_SYSTEM)
+ // File is part or used exclusively by the operating system
+ if(dwAttr & FILE_ATTRIBUTE_TEMPORARY)
+ // File is being used for temporary storage
+*/
+ }
+ }
+
+ return true;
+ }
+}
View
104 xbmc/pvrclients/MediaPortal/windows/WindowsUtils.cpp
@@ -0,0 +1,104 @@
+#include "WindowsUtils.h"
+#include <windows.h>
+#include <stdio.h>
+#include <string>
+
+namespace OS
+{
+ typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
+
+ WindowsVersion Version()
+ {
+ OSVERSIONINFOEX osvi;
+ SYSTEM_INFO si;
+ PGNSI GetNativeSystemInfo;
+ BOOL bOsVersionInfoEx;
+
+ ZeroMemory(&si, sizeof(SYSTEM_INFO));
+ ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
+
+ osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
+ bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO*) &osvi);
+
+ if(bOsVersionInfoEx == NULL ) return Unknown;
+
+ // Call GetNativeSystemInfo if supported or GetSystemInfo otherwise.
+ GetNativeSystemInfo = (PGNSI) GetProcAddress( GetModuleHandle(TEXT("kernel32.dll")), "GetNativeSystemInfo");
+ if (NULL != GetNativeSystemInfo)
+ GetNativeSystemInfo(&si);
+ else
+ GetSystemInfo(&si);
+
+ if ( VER_PLATFORM_WIN32_NT==osvi.dwPlatformId && osvi.dwMajorVersion > 4 )
+ {
+ // Test for the specific product.
+ if ( osvi.dwMajorVersion == 6 )
+ {
+ if( osvi.dwMinorVersion == 0 )
+ {
+ if( osvi.wProductType == VER_NT_WORKSTATION )
+ return WindowsVista;
+ else
+ return WindowsServer2008;
+ }
+
+ if ( osvi.dwMinorVersion == 1 )
+ {
+ if( osvi.wProductType == VER_NT_WORKSTATION )
+ return Windows7;
+ else
+ return WindowsServer2008R2;
+ }
+ }
+
+ if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 )
+ {
+ if( GetSystemMetrics(SM_SERVERR2) )
+ return WindowsServer2003R2;
+ else if ( osvi.wSuiteMask & VER_SUITE_STORAGE_SERVER )
+ return WindowsStorageServer2003;
+ else if ( osvi.wSuiteMask & VER_SUITE_WH_SERVER )
+ return WindowsHomeServer;
+ else if( osvi.wProductType == VER_NT_WORKSTATION && si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64)
+ return WindowsXPx64;
+ else
+ return WindowsServer2003;
+ }
+
+ if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
+ {
+ if( osvi.wSuiteMask & VER_SUITE_PERSONAL )
+ return WindowsXPHome;
+ else
+ return WindowsXPPro;
+ }
+
+ if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 )
+ {
+ return Windows2000;
+ }
+ }
+
+ return Unknown;
+ }
+
+ bool GetEnvironmentVariable(const char* strVarName, std::string& strResult)
+ {
+ char strBuffer[4096];
+ DWORD dwRet;
+
+ dwRet = ::GetEnvironmentVariable(strVarName, strBuffer, 4096);
+
+ if(0 == dwRet)
+ {
+ dwRet = GetLastError();
+ if( ERROR_ENVVAR_NOT_FOUND == dwRet )
+ {
+ strResult.clear();
+ return false;
+ }
+ }
+ strResult = strBuffer;
+ return true;
+ }
+}
View
27 xbmc/pvrclients/MediaPortal/windows/WindowsUtils.h
@@ -0,0 +1,27 @@
+#pragma once