From ca32a54c2208a3bb97d3941a680fe9cfe4682994 Mon Sep 17 00:00:00 2001 From: JezzX Date: Wed, 20 Apr 2011 08:58:11 +1000 Subject: [PATCH 01/47] Fixed: [Confluence] Navigation in LiveTv window since 51ed57d was merged in --- addons/skin.confluence/720p/MyPVR.xml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/addons/skin.confluence/720p/MyPVR.xml b/addons/skin.confluence/720p/MyPVR.xml index 041988aa5ba17..417946f9eecb2 100644 --- a/addons/skin.confluence/720p/MyPVR.xml +++ b/addons/skin.confluence/720p/MyPVR.xml @@ -189,15 +189,7 @@ ButtonCommonValues - - Fake Button to fix Player Controls Navigation - false - CommonNowPlaying_Controls - - Fake Button to fix Player Controls Navigation - false - From f74e1e1bf4073e71792ce711250c07ddd215de43 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Wed, 20 Apr 2011 01:02:02 +0200 Subject: [PATCH 02/47] pvr: check whether a timer exists in CPVRTimers::IsRecordingOnChannel(). fixes possible crash --- xbmc/pvr/timers/PVRTimers.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xbmc/pvr/timers/PVRTimers.cpp b/xbmc/pvr/timers/PVRTimers.cpp index 6ab0d87c3ea9e..d3463378f4e97 100644 --- a/xbmc/pvr/timers/PVRTimers.cpp +++ b/xbmc/pvr/timers/PVRTimers.cpp @@ -573,7 +573,7 @@ bool CPVRTimers::IsRecordingOnChannel(const CPVRChannel &channel) const { CPVRTimerInfoTag *timer = at(ptr); - if (timer->IsRecording() && *timer->m_channel == channel) + if (timer->IsRecording() && timer->m_channel && *timer->m_channel == channel) { bReturn = true; break; From 3d06c486a603258c05e4ca14f883534dbb635d1f Mon Sep 17 00:00:00 2001 From: JezzX Date: Wed, 20 Apr 2011 14:34:02 +1000 Subject: [PATCH 03/47] Fixed: [Confluence] this control got missed in the last merge somehow --- addons/skin.confluence/720p/includes.xml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/skin.confluence/720p/includes.xml b/addons/skin.confluence/720p/includes.xml index 347058a1887bd..50b50c5011c8c 100644 --- a/addons/skin.confluence/720p/includes.xml +++ b/addons/skin.confluence/720p/includes.xml @@ -503,9 +503,13 @@ [Player.HasAudio | Player.HasVideo] VisibleFadeEffect + + Fake Button to fix Player Controls Navigation + false + 250 - 39 + 45 VideoPlayer.Content(LiveTV) VisibleFadeEffect From d502858f22ab99e3f244fec7ad66d8dfac3fe3ae Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Wed, 20 Apr 2011 21:10:21 +0200 Subject: [PATCH 04/47] pvr: stick all PVR related sources in a PVR namespace --- xbmc/Application.cpp | 1 + xbmc/FileItem.cpp | 1 + xbmc/FileItem.h | 37 +- xbmc/GUIInfoManager.cpp | 1 + xbmc/GUIViewState.cpp | 1 + xbmc/SortFileItem.cpp | 2 + xbmc/addons/AddonCallbacksPVR.cpp | 2 + xbmc/addons/AddonManager.cpp | 1 + .../DVDDemuxers/DVDDemuxPVRClient.cpp | 2 + .../DVDDemuxers/DVDFactoryDemuxer.cpp | 1 + .../DVDInputStreams/DVDInputStream.h | 4 +- .../DVDInputStreams/DVDInputStreamHTSP.h | 4 +- .../DVDInputStreamPVRManager.cpp | 1 + .../DVDInputStreamPVRManager.h | 4 +- .../DVDInputStreams/DVDInputStreamTV.cpp | 1 + .../DVDInputStreams/DVDInputStreamTV.h | 4 +- xbmc/cores/dvdplayer/DVDPlayer.cpp | 1 + xbmc/epg/Epg.cpp | 1 - xbmc/epg/Epg.h | 21 +- xbmc/epg/EpgContainer.cpp | 1 + xbmc/epg/EpgContainer.h | 18 +- xbmc/epg/EpgDatabase.h | 2 +- xbmc/epg/EpgInfoTag.cpp | 1 + xbmc/epg/EpgInfoTag.h | 14 +- xbmc/filesystem/PVRDirectory.cpp | 1 + xbmc/filesystem/PVRFile.cpp | 3 +- xbmc/guilib/GUIEPGGridContainer.cpp | 2 + xbmc/pvr/PVRDatabase.cpp | 1 + xbmc/pvr/PVRDatabase.h | 418 +++---- xbmc/pvr/PVRGUIInfo.cpp | 2 + xbmc/pvr/PVRGUIInfo.h | 227 ++-- xbmc/pvr/PVRManager.cpp | 3 +- xbmc/pvr/PVRManager.h | 1018 +++++++++-------- xbmc/pvr/addons/PVRClient.cpp | 1 + xbmc/pvr/addons/PVRClient.h | 985 ++++++++-------- xbmc/pvr/addons/PVRClients.cpp | 1 + xbmc/pvr/addons/PVRClients.h | 647 +++++------ xbmc/pvr/channels/PVRChannel.cpp | 1 + xbmc/pvr/channels/PVRChannel.h | 961 ++++++++-------- xbmc/pvr/channels/PVRChannelGroup.cpp | 2 + xbmc/pvr/channels/PVRChannelGroup.h | 697 +++++------ xbmc/pvr/channels/PVRChannelGroupInternal.cpp | 2 + xbmc/pvr/channels/PVRChannelGroupInternal.h | 299 ++--- xbmc/pvr/channels/PVRChannelGroups.cpp | 2 + xbmc/pvr/channels/PVRChannelGroups.h | 345 +++--- .../channels/PVRChannelGroupsContainer.cpp | 2 + xbmc/pvr/channels/PVRChannelGroupsContainer.h | 339 +++--- .../dialogs/GUIDialogPVRChannelManager.cpp | 1 + xbmc/pvr/dialogs/GUIDialogPVRChannelManager.h | 55 +- xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.cpp | 1 + xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.h | 36 +- xbmc/pvr/dialogs/GUIDialogPVRCutterOSD.cpp | 1 + xbmc/pvr/dialogs/GUIDialogPVRCutterOSD.h | 21 +- xbmc/pvr/dialogs/GUIDialogPVRDirectorOSD.cpp | 1 + xbmc/pvr/dialogs/GUIDialogPVRDirectorOSD.h | 21 +- xbmc/pvr/dialogs/GUIDialogPVRGroupManager.cpp | 1 + xbmc/pvr/dialogs/GUIDialogPVRGroupManager.h | 74 +- xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.cpp | 1 + xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.h | 52 +- xbmc/pvr/dialogs/GUIDialogPVRGuideOSD.cpp | 1 + xbmc/pvr/dialogs/GUIDialogPVRGuideOSD.h | 33 +- xbmc/pvr/dialogs/GUIDialogPVRGuideSearch.cpp | 1 + xbmc/pvr/dialogs/GUIDialogPVRGuideSearch.h | 39 +- .../pvr/dialogs/GUIDialogPVRRecordingInfo.cpp | 1 + xbmc/pvr/dialogs/GUIDialogPVRRecordingInfo.h | 26 +- .../pvr/dialogs/GUIDialogPVRTimerSettings.cpp | 1 + xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.h | 51 +- xbmc/pvr/epg/PVREpg.cpp | 8 +- xbmc/pvr/epg/PVREpg.h | 125 +- xbmc/pvr/epg/PVREpgContainer.cpp | 6 +- xbmc/pvr/epg/PVREpgContainer.h | 137 +-- xbmc/pvr/epg/PVREpgInfoTag.cpp | 1 + xbmc/pvr/epg/PVREpgInfoTag.h | 135 +-- xbmc/pvr/epg/PVREpgSearchFilter.cpp | 1 + xbmc/pvr/epg/PVREpgSearchFilter.h | 43 +- xbmc/pvr/recordings/PVRRecording.cpp | 2 + xbmc/pvr/recordings/PVRRecording.h | 101 +- xbmc/pvr/recordings/PVRRecordings.cpp | 2 + xbmc/pvr/recordings/PVRRecordings.h | 70 +- xbmc/pvr/timers/PVRTimerInfoTag.cpp | 2 + xbmc/pvr/timers/PVRTimerInfoTag.h | 180 +-- xbmc/pvr/timers/PVRTimers.cpp | 1 + xbmc/pvr/timers/PVRTimers.h | 322 +++--- xbmc/pvr/windows/GUIViewStatePVR.cpp | 2 + xbmc/pvr/windows/GUIViewStatePVR.h | 24 +- xbmc/pvr/windows/GUIWindowPVR.cpp | 2 + xbmc/pvr/windows/GUIWindowPVR.h | 105 +- xbmc/pvr/windows/GUIWindowPVRChannels.cpp | 1 + xbmc/pvr/windows/GUIWindowPVRChannels.h | 75 +- xbmc/pvr/windows/GUIWindowPVRCommon.cpp | 1 + xbmc/pvr/windows/GUIWindowPVRCommon.h | 213 ++-- xbmc/pvr/windows/GUIWindowPVRGuide.cpp | 2 + xbmc/pvr/windows/GUIWindowPVRGuide.h | 73 +- xbmc/pvr/windows/GUIWindowPVRRecordings.cpp | 2 + xbmc/pvr/windows/GUIWindowPVRRecordings.h | 55 +- xbmc/pvr/windows/GUIWindowPVRSearch.cpp | 2 + xbmc/pvr/windows/GUIWindowPVRSearch.h | 53 +- xbmc/pvr/windows/GUIWindowPVRTimers.cpp | 2 + xbmc/pvr/windows/GUIWindowPVRTimers.h | 49 +- xbmc/settings/GUIWindowSettingsCategory.cpp | 1 + xbmc/video/windows/GUIWindowFullScreen.cpp | 1 + xbmc/video/windows/GUIWindowVideoBase.cpp | 1 + 102 files changed, 4252 insertions(+), 4051 deletions(-) diff --git a/xbmc/Application.cpp b/xbmc/Application.cpp index a214adc485ab4..5b880f982091a 100644 --- a/xbmc/Application.cpp +++ b/xbmc/Application.cpp @@ -304,6 +304,7 @@ using namespace DBUSSERVER; using namespace JSONRPC; #endif using namespace ANNOUNCEMENT; +using namespace PVR; // uncomment this if you want to use release libs in the debug build. // Atm this saves you 7 mb of memory diff --git a/xbmc/FileItem.cpp b/xbmc/FileItem.cpp index 99b88e1078d94..fc94fea36210d 100644 --- a/xbmc/FileItem.cpp +++ b/xbmc/FileItem.cpp @@ -66,6 +66,7 @@ using namespace std; using namespace XFILE; using namespace PLAYLIST; using namespace MUSIC_INFO; +using namespace PVR; CFileItem::CFileItem(const CSong& song) { diff --git a/xbmc/FileItem.h b/xbmc/FileItem.h index 6f0f7e892b692..5ef11d7ae1e71 100644 --- a/xbmc/FileItem.h +++ b/xbmc/FileItem.h @@ -43,10 +43,13 @@ namespace MUSIC_INFO } class CVideoInfoTag; class CEpgInfoTag; -class CPVREpgInfoTag; -class CPVRChannel; -class CPVRRecording; -class CPVRTimerInfoTag; +namespace PVR +{ + class CPVREpgInfoTag; + class CPVRChannel; + class CPVRRecording; + class CPVRTimerInfoTag; +} class CPictureInfoTag; class CAlbum; @@ -79,11 +82,11 @@ class CFileItem : CFileItem(const CArtist& artist); CFileItem(const CGenre& genre); CFileItem(const CVideoInfoTag& movie); - CFileItem(const CPVREpgInfoTag& tag); + CFileItem(const PVR::CPVREpgInfoTag& tag); CFileItem(const CEpgInfoTag& tag); - CFileItem(const CPVRChannel& channel); - CFileItem(const CPVRRecording& record); - CFileItem(const CPVRTimerInfoTag& timer); + CFileItem(const PVR::CPVRChannel& channel); + CFileItem(const PVR::CPVRRecording& record); + CFileItem(const PVR::CPVRTimerInfoTag& timer); CFileItem(const CMediaSource& share); virtual ~CFileItem(void); virtual CGUIListItem *Clone() const { return new CFileItem(*this); }; @@ -211,9 +214,9 @@ class CFileItem : return m_pvrChannelInfoTag != NULL; } - CPVRChannel* GetPVRChannelInfoTag(); + PVR::CPVRChannel* GetPVRChannelInfoTag(); - inline const CPVRChannel* GetPVRChannelInfoTag() const + inline const PVR::CPVRChannel* GetPVRChannelInfoTag() const { return m_pvrChannelInfoTag; } @@ -223,9 +226,9 @@ class CFileItem : return m_pvrRecordingInfoTag != NULL; } - CPVRRecording* GetPVRRecordingInfoTag(); + PVR::CPVRRecording* GetPVRRecordingInfoTag(); - inline const CPVRRecording* GetPVRRecordingInfoTag() const + inline const PVR::CPVRRecording* GetPVRRecordingInfoTag() const { return m_pvrRecordingInfoTag; } @@ -235,9 +238,9 @@ class CFileItem : return m_pvrTimerInfoTag != NULL; } - CPVRTimerInfoTag* GetPVRTimerInfoTag(); + PVR::CPVRTimerInfoTag* GetPVRTimerInfoTag(); - inline const CPVRTimerInfoTag* GetPVRTimerInfoTag() const + inline const PVR::CPVRTimerInfoTag* GetPVRTimerInfoTag() const { return m_pvrTimerInfoTag; } @@ -369,9 +372,9 @@ class CFileItem : MUSIC_INFO::CMusicInfoTag* m_musicInfoTag; CVideoInfoTag* m_videoInfoTag; CEpgInfoTag* m_epgInfoTag; - CPVRChannel* m_pvrChannelInfoTag; - CPVRRecording* m_pvrRecordingInfoTag; - CPVRTimerInfoTag * m_pvrTimerInfoTag; + PVR::CPVRChannel* m_pvrChannelInfoTag; + PVR::CPVRRecording* m_pvrRecordingInfoTag; + PVR::CPVRTimerInfoTag * m_pvrTimerInfoTag; CPictureInfoTag* m_pictureInfoTag; bool m_bIsAlbum; }; diff --git a/xbmc/GUIInfoManager.cpp b/xbmc/GUIInfoManager.cpp index 6537485f13c44..432b4ac4c5207 100644 --- a/xbmc/GUIInfoManager.cpp +++ b/xbmc/GUIInfoManager.cpp @@ -90,6 +90,7 @@ using namespace std; using namespace XFILE; using namespace MUSIC_INFO; using namespace ADDON; +using namespace PVR; CGUIInfoManager::CCombinedValue& CGUIInfoManager::CCombinedValue::operator =(const CGUIInfoManager::CCombinedValue& mSrc) { diff --git a/xbmc/GUIViewState.cpp b/xbmc/GUIViewState.cpp index 5513f5ade3899..03b1ec5a68850 100644 --- a/xbmc/GUIViewState.cpp +++ b/xbmc/GUIViewState.cpp @@ -48,6 +48,7 @@ using namespace std; using namespace ADDON; +using namespace PVR; CStdString CGUIViewState::m_strPlaylistDirectory; VECSOURCES CGUIViewState::m_sources; diff --git a/xbmc/SortFileItem.cpp b/xbmc/SortFileItem.cpp index d34623e681982..c2a9eafd9e533 100644 --- a/xbmc/SortFileItem.cpp +++ b/xbmc/SortFileItem.cpp @@ -33,6 +33,8 @@ #include "utils/log.h" #include "video/VideoInfoTag.h" +using namespace PVR; + #define RETURN_IF_NULL(x,y) if ((x) == NULL) { CLog::Log(LOGWARNING, "%s, sort item is null", __FUNCTION__); return y; } CStdString SSortFileItem::RemoveArticles(const CStdString &label) diff --git a/xbmc/addons/AddonCallbacksPVR.cpp b/xbmc/addons/AddonCallbacksPVR.cpp index 5fe20a938dc66..fd55dd74bcb86 100644 --- a/xbmc/addons/AddonCallbacksPVR.cpp +++ b/xbmc/addons/AddonCallbacksPVR.cpp @@ -33,6 +33,8 @@ #include "pvr/timers/PVRTimers.h" #include "pvr/timers/PVRTimerInfoTag.h" +using namespace PVR; + namespace ADDON { diff --git a/xbmc/addons/AddonManager.cpp b/xbmc/addons/AddonManager.cpp index fb07a9dc0fc7a..8474f274893c4 100644 --- a/xbmc/addons/AddonManager.cpp +++ b/xbmc/addons/AddonManager.cpp @@ -50,6 +50,7 @@ #include "Service.h" using namespace std; +using namespace PVR; namespace ADDON { diff --git a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxPVRClient.cpp b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxPVRClient.cpp index 55cfac17eb1cc..83658f821e745 100644 --- a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxPVRClient.cpp +++ b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxPVRClient.cpp @@ -29,6 +29,8 @@ #include #endif +using namespace PVR; + void CDemuxStreamVideoPVRClient::GetStreamInfo(std::string& strInfo) { } diff --git a/xbmc/cores/dvdplayer/DVDDemuxers/DVDFactoryDemuxer.cpp b/xbmc/cores/dvdplayer/DVDDemuxers/DVDFactoryDemuxer.cpp index ec6933f1669fb..f312bbf9f309a 100644 --- a/xbmc/cores/dvdplayer/DVDDemuxers/DVDFactoryDemuxer.cpp +++ b/xbmc/cores/dvdplayer/DVDDemuxers/DVDFactoryDemuxer.cpp @@ -36,6 +36,7 @@ #include "pvr/addons/PVRClients.h" using namespace std; +using namespace PVR; CDVDDemux* CDVDFactoryDemuxer::CreateDemuxer(CDVDInputStream* pInputStream) { diff --git a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStream.h b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStream.h index b9110957a0c31..7bfa2da5ef63e 100644 --- a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStream.h +++ b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStream.h @@ -55,8 +55,8 @@ class CDVDInputStream virtual bool NextChannel(bool preview = false) = 0; virtual bool PrevChannel(bool preview = false) = 0; virtual bool SelectChannelByNumber(unsigned int channel) = 0; - virtual bool SelectChannel(const CPVRChannel &channel) = 0; - virtual bool GetSelectedChannel(CPVRChannel *) = 0; + virtual bool SelectChannel(const PVR::CPVRChannel &channel) = 0; + virtual bool GetSelectedChannel(PVR::CPVRChannel *) = 0; virtual int GetTotalTime() = 0; virtual int GetStartTime() = 0; virtual bool UpdateItem(CFileItem& item) = 0; diff --git a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamHTSP.h b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamHTSP.h index d6e5cd01ad7f3..83012e7ca8cb0 100644 --- a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamHTSP.h +++ b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamHTSP.h @@ -45,8 +45,8 @@ class CDVDInputStreamHTSP bool NextChannel(bool preview = false); bool PrevChannel(bool preview = false); bool SelectChannelByNumber(unsigned int channel); - bool SelectChannel(const CPVRChannel &channel) { return false; } - bool GetSelectedChannel(CPVRChannel *channel) {return false; } + bool SelectChannel(const PVR::CPVRChannel &channel) { return false; } + bool GetSelectedChannel(PVR::CPVRChannel *channel) {return false; } bool UpdateItem(CFileItem& item); bool CanRecord() { return false; } diff --git a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamPVRManager.cpp b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamPVRManager.cpp index 4fdb7aca30934..1871da723c07b 100644 --- a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamPVRManager.cpp +++ b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamPVRManager.cpp @@ -29,6 +29,7 @@ #include "pvr/addons/PVRClients.h" using namespace XFILE; +using namespace PVR; /************************************************************************ * Description: Class constructor, initialize member variables diff --git a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamPVRManager.h b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamPVRManager.h index ecb395304cd5a..ef905dda06be8 100644 --- a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamPVRManager.h +++ b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamPVRManager.h @@ -54,10 +54,10 @@ class CDVDInputStreamPVRManager virtual bool NextStream(); bool SelectChannelByNumber(unsigned int iChannel); - bool SelectChannel(const CPVRChannel &channel); + bool SelectChannel(const PVR::CPVRChannel &channel); bool NextChannel(bool preview = false); bool PrevChannel(bool preview = false); - bool GetSelectedChannel(CPVRChannel *channel); + bool GetSelectedChannel(PVR::CPVRChannel *channel); int GetTotalTime(); int GetStartTime(); diff --git a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamTV.cpp b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamTV.cpp index 774942a7c89ca..9c49531e99306 100644 --- a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamTV.cpp +++ b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamTV.cpp @@ -26,6 +26,7 @@ #include "URL.h" using namespace XFILE; +using namespace PVR; CDVDInputStreamTV::CDVDInputStreamTV() : CDVDInputStream(DVDSTREAM_TYPE_TV) { diff --git a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamTV.h b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamTV.h index 313d02626c7aa..e3b3910ed2a12 100644 --- a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamTV.h +++ b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamTV.h @@ -50,8 +50,8 @@ class CDVDInputStreamTV bool NextChannel(bool preview = false); bool PrevChannel(bool preview = false); bool SelectChannelByNumber(unsigned int channel); - bool SelectChannel(const CPVRChannel &channel); - bool GetSelectedChannel(CPVRChannel *channel) {return false; } + bool SelectChannel(const PVR::CPVRChannel &channel); + bool GetSelectedChannel(PVR::CPVRChannel *channel) {return false; } int GetTotalTime(); int GetStartTime(); diff --git a/xbmc/cores/dvdplayer/DVDPlayer.cpp b/xbmc/cores/dvdplayer/DVDPlayer.cpp index 4bbae590ea0a2..33c5c62a9d219 100644 --- a/xbmc/cores/dvdplayer/DVDPlayer.cpp +++ b/xbmc/cores/dvdplayer/DVDPlayer.cpp @@ -74,6 +74,7 @@ #include "Util.h" using namespace std; +using namespace PVR; void CSelectionStreams::Clear(StreamType type, StreamSource source) { diff --git a/xbmc/epg/Epg.cpp b/xbmc/epg/Epg.cpp index 2c1c2ea72a1da..e0e618142b230 100644 --- a/xbmc/epg/Epg.cpp +++ b/xbmc/epg/Epg.cpp @@ -47,7 +47,6 @@ CEpg::CEpg(int iEpgID, const CStdString &strName /* = "" */, const CStdString &s m_nowActive = NULL; m_Channel = NULL; m_bInhibitSorting = false; - m_bHasChannel = false; m_lastScanTime.SetValid(false); m_firstDate.SetValid(false); m_lastDate.SetValid(false); diff --git a/xbmc/epg/Epg.h b/xbmc/epg/Epg.h index ad8ff11a52214..e91c01fc75557 100644 --- a/xbmc/epg/Epg.h +++ b/xbmc/epg/Epg.h @@ -29,8 +29,12 @@ #include "EpgSearchFilter.h" class CEpgContainer; -class CPVREpgContainer; -class CPVREpg; + +namespace PVR +{ + class CPVREpgContainer; + class CPVREpg; +} /** EPG container for CEpgInfoTag instances */ @@ -41,7 +45,7 @@ class CEpg : public std::vector friend class CEpgContainer; friend class CPVREpg; -private: +protected: CStdString m_strName; /*!< the name of this table */ CStdString m_strScraperName; /*!< the name of the scraper to use */ int m_iEpgID; /*!< the database ID of this table */ @@ -51,8 +55,7 @@ class CEpg : public std::vector mutable CCriticalSection m_critSection; /*!< critical section for changes in this table */ - CPVRChannel * m_Channel; /*!< the channel this EPG belongs to */ - bool m_bHasChannel; /*!< true if this table has a channel tag set, false otherwise */ + PVR::CPVRChannel * m_Channel; /*!< the channel this EPG belongs to */ CDateTime m_firstDate; /*!< start time of the first epg event in this table */ CDateTime m_lastDate; /*!< end time of the last epg event in this table */ @@ -163,7 +166,13 @@ class CEpg : public std::vector * @brief The channel this EPG belongs to. * @return The channel this EPG belongs to */ - const CPVRChannel *Channel(void) const { return m_bHasChannel ? m_Channel : NULL; } + const PVR::CPVRChannel *Channel(void) const { return m_Channel; } + + /*! + * @brief Channel the channel tag linked to this EPG table. + * @param channel The new channel tag. + */ + virtual void SetChannel(PVR::CPVRChannel *channel) { m_Channel = channel; } /*! * @brief Get the name of the scraper to use for this table. diff --git a/xbmc/epg/EpgContainer.cpp b/xbmc/epg/EpgContainer.cpp index ee82409ba8f50..1ffbe8c67cd37 100644 --- a/xbmc/epg/EpgContainer.cpp +++ b/xbmc/epg/EpgContainer.cpp @@ -38,6 +38,7 @@ #include "pvr/addons/PVRClients.h" using namespace std; +using namespace PVR; CEpgContainer g_EpgContainer; diff --git a/xbmc/epg/EpgContainer.h b/xbmc/epg/EpgContainer.h index 37ab41b6378d1..3c9b48a42ebc6 100644 --- a/xbmc/epg/EpgContainer.h +++ b/xbmc/epg/EpgContainer.h @@ -30,9 +30,13 @@ #include "EpgDatabase.h" class CFileItemList; -class CPVREpg; -class CPVREpgContainer; -class CPVRManager; + +namespace PVR +{ + class CPVREpg; + class CPVREpgContainer; + class CPVRManager; +} class CEpgContainer : public std::vector, public Observer, @@ -42,11 +46,11 @@ class CEpgContainer : public std::vector, friend class CEpg; friend class CEpgDatabase; - friend class CPVREpg; - friend class CPVREpgContainer; - friend class CPVRManager; + friend class PVR::CPVREpg; + friend class PVR::CPVREpgContainer; + friend class PVR::CPVRManager; -private: +protected: CEpgDatabase m_database; /*!< the EPG database */ /** @name Configuration */ diff --git a/xbmc/epg/EpgDatabase.h b/xbmc/epg/EpgDatabase.h index fea2e920a1fb3..bda83cbf38094 100644 --- a/xbmc/epg/EpgDatabase.h +++ b/xbmc/epg/EpgDatabase.h @@ -140,7 +140,7 @@ class CEpgDatabase : public CDatabase //@} -private: +protected: /*! * @brief Create the EPG database tables. * @return True if the tables were created successfully, false otherwise. diff --git a/xbmc/epg/EpgInfoTag.cpp b/xbmc/epg/EpgInfoTag.cpp index b2c90a2276402..8488930a6c130 100644 --- a/xbmc/epg/EpgInfoTag.cpp +++ b/xbmc/epg/EpgInfoTag.cpp @@ -28,6 +28,7 @@ #include "pvr/PVRManager.h" using namespace std; +using namespace PVR; CEpgInfoTag::CEpgInfoTag(int iUniqueBroadcastId) { diff --git a/xbmc/epg/EpgInfoTag.h b/xbmc/epg/EpgInfoTag.h index a83165ae155c2..2a82f7e887b39 100644 --- a/xbmc/epg/EpgInfoTag.h +++ b/xbmc/epg/EpgInfoTag.h @@ -25,8 +25,12 @@ #include "Epg.h" class CEpg; -class CPVREpg; -class CPVREpgInfoTag; + +namespace PVR +{ + class CPVREpg; + class CPVREpgInfoTag; +} /** an EPG info tag */ @@ -35,10 +39,10 @@ class CEpgInfoTag friend class CEpg; friend class CEpgDatabase; - friend class CPVREpg; - friend class CPVREpgInfoTag; + friend class PVR::CPVREpg; + friend class PVR::CPVREpgInfoTag; -private: +protected: const CEpg * m_Epg; /*!< the schedule this event belongs to */ int m_iBroadcastId; /*!< database ID */ diff --git a/xbmc/filesystem/PVRDirectory.cpp b/xbmc/filesystem/PVRDirectory.cpp index e182278e398aa..a5b0ce06df2cb 100644 --- a/xbmc/filesystem/PVRDirectory.cpp +++ b/xbmc/filesystem/PVRDirectory.cpp @@ -35,6 +35,7 @@ using namespace std; using namespace XFILE; +using namespace PVR; CPVRDirectory::CPVRDirectory() { diff --git a/xbmc/filesystem/PVRFile.cpp b/xbmc/filesystem/PVRFile.cpp index d1dc025be3320..3751a8f03352e 100644 --- a/xbmc/filesystem/PVRFile.cpp +++ b/xbmc/filesystem/PVRFile.cpp @@ -27,8 +27,9 @@ #include "pvr/addons/PVRClients.h" #include "utils/log.h" -using namespace XFILE; using namespace std; +using namespace XFILE; +using namespace PVR; CPVRFile::CPVRFile() { diff --git a/xbmc/guilib/GUIEPGGridContainer.cpp b/xbmc/guilib/GUIEPGGridContainer.cpp index 847137239e1ba..0b0e53d3ff34e 100644 --- a/xbmc/guilib/GUIEPGGridContainer.cpp +++ b/xbmc/guilib/GUIEPGGridContainer.cpp @@ -33,6 +33,8 @@ #include "pvr/epg/PVREpgInfoTag.h" #include "pvr/channels/PVRChannel.h" +using namespace PVR; + #define SHORTGAP 5 // how many blocks is considered a short-gap in nav logic #define MINSPERBLOCK 5 /// would be nice to offer zooming of busy schedules /// performance cost to increase resolution 5 fold? #define BLOCKJUMP 4 // how many blocks are jumped with each analogue scroll action diff --git a/xbmc/pvr/PVRDatabase.cpp b/xbmc/pvr/PVRDatabase.cpp index b77432991d547..1c50f9f79d38c 100644 --- a/xbmc/pvr/PVRDatabase.cpp +++ b/xbmc/pvr/PVRDatabase.cpp @@ -30,6 +30,7 @@ using namespace std; using namespace dbiplus; +using namespace PVR; CPVRDatabase::CPVRDatabase(void) { diff --git a/xbmc/pvr/PVRDatabase.h b/xbmc/pvr/PVRDatabase.h index f78a1d3db768c..75938346dd9c3 100644 --- a/xbmc/pvr/PVRDatabase.h +++ b/xbmc/pvr/PVRDatabase.h @@ -23,213 +23,217 @@ #include "dbwrappers/Database.h" #include "XBDateTime.h" -class CPVRChannelGroup; -class CPVRChannelGroupInternal; -class CPVRChannelsContainer; -class CPVRChannel; -class CPVRChannelGroups; class CVideoSettings; -/** The PVR database */ - -class CPVRDatabase : public CDatabase +namespace PVR { -public: - /*! - * @brief Create a new instance of the PVR database. - */ - CPVRDatabase(void); - virtual ~CPVRDatabase(void); - - /*! - * @brief Open the database. - * @return True if it was opened successfully, false otherwise. - */ - virtual bool Open(); - - /*! - * @brief Get the minimal database version that is required to operate correctly. - * @return The minimal database version. - */ - virtual int GetMinVersion() const { return 12; }; - - /*! - * @brief Get the default sqlite database filename. - * @return The default filename. - */ - const char *GetBaseDBName() const { return "TV"; }; - - /*! @name Channel methods */ - //@{ - - /*! - * @brief Remove all channels from the database. - * @return True if all channels were removed, false otherwise. - */ - bool DeleteChannels(); - - /*! - * @brief Remove all channels from a client from the database. - * @param iClientId The ID of the client to delete the channels for. - * @return True if the channels were deleted, false otherwise. - */ - bool DeleteClientChannels(int iClientId); - - /*! - * @brief Add or update a channel entry in the database - * @param channel The channel to persist. - * @param bQueueWrite If true, don't write immediately - * @return The database ID of the channel. - */ - int Persist(const CPVRChannel &channel, bool bQueueWrite = false); - - /*! - * @brief Remove a channel entry from the database - * @param channel The channel to remove. - * @return True if the channel was removed, false otherwise. - */ - bool Delete(const CPVRChannel &channel); - - /*! - * @brief Get the list of channels from the database - * @param results The channel group to store the results in. - * @param bIsRadio Get the radio channels if true. Get the TV channels otherwise. - * @return The amount of channels that were added. - */ - int GetChannels(CPVRChannelGroupInternal *results, bool bIsRadio); - - //@} - - /*! @name Channel settings methods */ - //@{ - - /*! - * @brief Remove all channel settings from the database. - * @return True if all channels were removed successfully, false if not. - */ - bool DeleteChannelSettings(); - - /*! - * @brief Remove channel settings from the database. - * @return True if channel were removed successfully, false if not. - */ - bool DeleteChannelSettings(const CPVRChannel &channel); - - /*! - * @brief Get the channel settings from the database. - * @param channel The channel to get the settings for. - * @param settings Store the settings in here. - * @return True if the settings were fetched successfully, false if not. - */ - bool GetChannelSettings(const CPVRChannel &channel, CVideoSettings &settings); - - /*! - * @brief Store channel settings in the database. - * @param channel The channel to store the settings for. - * @param settings The settings to store. - * @return True if the settings were stored successfully, false if not. - */ - bool PersistChannelSettings(const CPVRChannel &channel, const CVideoSettings &settings); - - //@} - - /*! @name Channel group methods */ - //@{ - - bool RemoveChannelsFromGroup(int iGroupId); - - /*! - * @brief Remove all channel groups from the database - * @param bRadio Remove all radio channel groups if true. Remove TV channel groups otherwise. - * @return True if all channel groups were removed. - */ - bool DeleteChannelGroups(bool bRadio = false); - - /*! - * @brief Delete a channel group from the database. - * @param iGroupId The id of the group to delete. - * @param bRadio True if it's a radio channel group, false otherwise. - * @return True if the group was deleted successfully, false otherwise. - */ - bool DeleteChannelGroup(int iGroupId, bool bRadio = false); - - /*! - * @brief Get the channel groups. - * @param results The container to store the results in. - * @param bRadio Get radio channel groups if true. - * @return True if the list was fetched successfully, false otherwise. - */ - bool GetChannelGroupList(CPVRChannelGroups &results, bool bRadio); - - /*! - * @brief Add the group members to a group. - * @param group The group to get the channels for. - * @return The amount of channels that were added. - */ - int GetChannelsInGroup(CPVRChannelGroup *group); - - /*! - * @brief Add or update a channel group entry in the database. - * @param group The group to persist. - * @return The database ID of the group. - */ - int Persist(CPVRChannelGroup *group); - -protected: - /*! - * @brief Get the Id of a channel group - * @param strGroupName The name of the group. - * @param bRadio True if it's a radio channel group, false otherwise. - * @return - */ - int GetChannelGroupId(const CStdString &strGroupName, bool bRadio = false); - //@} - - /*! @name Client methods */ - //@{ -public: - /*! - * @brief Remove all client information from the database. - * @return True if all clients were removed successfully. - */ - bool DeleteClients(); - - /*! - * @brief Add a client to the database if it's not already in there. - * @param strClientName The name of the client. - * @param strGuid The unique ID of the client. - * @return The database ID of the client. - */ - int AddClient(const CStdString &strClientName, const CStdString &strGuid); - - /*! - * @brief Remove a client from the database - * @param strGuid The unique ID of the client. - * @return True if the client was removed successfully, false otherwise. - */ - bool DeleteClient(const CStdString &strGuid); - -protected: - /*! - * @brief Get the database ID of a client. - * @param strClientUid The unique ID of the client. - * @return The database ID of the client or -1 if it wasn't found. - */ - int GetClientId(const CStdString &strClientUid); - - //@} - -private: - /*! - * @brief Create the PVR database tables. - * @return True if the tables were created successfully, false otherwise. - */ - virtual bool CreateTables(); - - /*! - * @brief Update an old version of the database. - * @param version The version to update the database from. - * @return True if it was updated successfully, false otherwise. - */ - virtual bool UpdateOldVersion(int version); -}; + class CPVRChannelGroup; + class CPVRChannelGroupInternal; + class CPVRChannelsContainer; + class CPVRChannel; + class CPVRChannelGroups; + + /** The PVR database */ + + class CPVRDatabase : public CDatabase + { + public: + /*! + * @brief Create a new instance of the PVR database. + */ + CPVRDatabase(void); + virtual ~CPVRDatabase(void); + + /*! + * @brief Open the database. + * @return True if it was opened successfully, false otherwise. + */ + virtual bool Open(); + + /*! + * @brief Get the minimal database version that is required to operate correctly. + * @return The minimal database version. + */ + virtual int GetMinVersion() const { return 12; }; + + /*! + * @brief Get the default sqlite database filename. + * @return The default filename. + */ + const char *GetBaseDBName() const { return "TV"; }; + + /*! @name Channel methods */ + //@{ + + /*! + * @brief Remove all channels from the database. + * @return True if all channels were removed, false otherwise. + */ + bool DeleteChannels(); + + /*! + * @brief Remove all channels from a client from the database. + * @param iClientId The ID of the client to delete the channels for. + * @return True if the channels were deleted, false otherwise. + */ + bool DeleteClientChannels(int iClientId); + + /*! + * @brief Add or update a channel entry in the database + * @param channel The channel to persist. + * @param bQueueWrite If true, don't write immediately + * @return The database ID of the channel. + */ + int Persist(const CPVRChannel &channel, bool bQueueWrite = false); + + /*! + * @brief Remove a channel entry from the database + * @param channel The channel to remove. + * @return True if the channel was removed, false otherwise. + */ + bool Delete(const CPVRChannel &channel); + + /*! + * @brief Get the list of channels from the database + * @param results The channel group to store the results in. + * @param bIsRadio Get the radio channels if true. Get the TV channels otherwise. + * @return The amount of channels that were added. + */ + int GetChannels(CPVRChannelGroupInternal *results, bool bIsRadio); + + //@} + + /*! @name Channel settings methods */ + //@{ + + /*! + * @brief Remove all channel settings from the database. + * @return True if all channels were removed successfully, false if not. + */ + bool DeleteChannelSettings(); + + /*! + * @brief Remove channel settings from the database. + * @return True if channel were removed successfully, false if not. + */ + bool DeleteChannelSettings(const CPVRChannel &channel); + + /*! + * @brief Get the channel settings from the database. + * @param channel The channel to get the settings for. + * @param settings Store the settings in here. + * @return True if the settings were fetched successfully, false if not. + */ + bool GetChannelSettings(const CPVRChannel &channel, CVideoSettings &settings); + + /*! + * @brief Store channel settings in the database. + * @param channel The channel to store the settings for. + * @param settings The settings to store. + * @return True if the settings were stored successfully, false if not. + */ + bool PersistChannelSettings(const CPVRChannel &channel, const CVideoSettings &settings); + + //@} + + /*! @name Channel group methods */ + //@{ + + bool RemoveChannelsFromGroup(int iGroupId); + + /*! + * @brief Remove all channel groups from the database + * @param bRadio Remove all radio channel groups if true. Remove TV channel groups otherwise. + * @return True if all channel groups were removed. + */ + bool DeleteChannelGroups(bool bRadio = false); + + /*! + * @brief Delete a channel group from the database. + * @param iGroupId The id of the group to delete. + * @param bRadio True if it's a radio channel group, false otherwise. + * @return True if the group was deleted successfully, false otherwise. + */ + bool DeleteChannelGroup(int iGroupId, bool bRadio = false); + + /*! + * @brief Get the channel groups. + * @param results The container to store the results in. + * @param bRadio Get radio channel groups if true. + * @return True if the list was fetched successfully, false otherwise. + */ + bool GetChannelGroupList(CPVRChannelGroups &results, bool bRadio); + + /*! + * @brief Add the group members to a group. + * @param group The group to get the channels for. + * @return The amount of channels that were added. + */ + int GetChannelsInGroup(CPVRChannelGroup *group); + + /*! + * @brief Add or update a channel group entry in the database. + * @param group The group to persist. + * @return The database ID of the group. + */ + int Persist(CPVRChannelGroup *group); + + protected: + /*! + * @brief Get the Id of a channel group + * @param strGroupName The name of the group. + * @param bRadio True if it's a radio channel group, false otherwise. + * @return + */ + int GetChannelGroupId(const CStdString &strGroupName, bool bRadio = false); + //@} + + /*! @name Client methods */ + //@{ + public: + /*! + * @brief Remove all client information from the database. + * @return True if all clients were removed successfully. + */ + bool DeleteClients(); + + /*! + * @brief Add a client to the database if it's not already in there. + * @param strClientName The name of the client. + * @param strGuid The unique ID of the client. + * @return The database ID of the client. + */ + int AddClient(const CStdString &strClientName, const CStdString &strGuid); + + /*! + * @brief Remove a client from the database + * @param strGuid The unique ID of the client. + * @return True if the client was removed successfully, false otherwise. + */ + bool DeleteClient(const CStdString &strGuid); + + protected: + /*! + * @brief Get the database ID of a client. + * @param strClientUid The unique ID of the client. + * @return The database ID of the client or -1 if it wasn't found. + */ + int GetClientId(const CStdString &strClientUid); + + //@} + + private: + /*! + * @brief Create the PVR database tables. + * @return True if the tables were created successfully, false otherwise. + */ + virtual bool CreateTables(); + + /*! + * @brief Update an old version of the database. + * @param version The version to update the database from. + * @return True if it was updated successfully, false otherwise. + */ + virtual bool UpdateOldVersion(int version); + }; +} diff --git a/xbmc/pvr/PVRGUIInfo.cpp b/xbmc/pvr/PVRGUIInfo.cpp index 3d726bf2f3e6c..60004fbc01e6e 100644 --- a/xbmc/pvr/PVRGUIInfo.cpp +++ b/xbmc/pvr/PVRGUIInfo.cpp @@ -34,6 +34,8 @@ #include "pvr/epg/PVREpgInfoTag.h" #include "settings/AdvancedSettings.h" +using namespace PVR; + CPVRGUIInfo::CPVRGUIInfo(void) { } diff --git a/xbmc/pvr/PVRGUIInfo.h b/xbmc/pvr/PVRGUIInfo.h index fa8d4c0ae071a..dc3477cc27fb9 100644 --- a/xbmc/pvr/PVRGUIInfo.h +++ b/xbmc/pvr/PVRGUIInfo.h @@ -25,116 +25,119 @@ #include "threads/Thread.h" #include "addons/include/xbmc_pvr_types.h" -class CPVREpgInfoTag; -class CPVRTimerInfoTag; -class CPVRRecording; - -class CPVRGUIInfo : private CThread, - private Observer +namespace PVR { -public: - CPVRGUIInfo(void); - virtual ~CPVRGUIInfo(void); - - void Start(void); - void Stop(void); - - void Notify(const Observable &obs, const CStdString& msg); - - bool TranslateBoolInfo(DWORD dwInfo) const; - bool TranslateCharInfo(DWORD dwInfo, CStdString &strValue) const; - int TranslateIntInfo(DWORD dwInfo) const; - - bool IsRecording(void) const; - bool HasTimers(void) const; - - /*! - * @brief Get the total duration of the currently playing LiveTV item. - * @return The total duration in milliseconds or NULL if no channel is playing. - */ - int GetTotalTime(void) const; - - /*! - * @brief Get the current position in milliseconds since the start of a LiveTV item. - * @return The position in milliseconds or NULL if no channel is playing. - */ - int GetStartTime(void) const; - -private: - void ResetProperties(void); - void Process(void); - - void UpdatePlayingTag(void); - void UpdateTimersCache(void); - void UpdateBackendCache(void); - void UpdateQualityData(void); - void UpdateMisc(void); - void UpdateNextTimer(void); - - bool AddonInfoToggle(void); - bool TimerInfoToggle(void); - void UpdateTimersToggle(void); - - void CharInfoActiveTimerTitle(CStdString &strValue) const; - void CharInfoActiveTimerChannelName(CStdString &strValue) const; - void CharInfoActiveTimerDateTime(CStdString &strValue) const; - void CharInfoNextTimerTitle(CStdString &strValue) const; - void CharInfoNextTimerChannelName(CStdString &strValue) const; - void CharInfoNextTimerDateTime(CStdString &strValue) const; - void CharInfoPlayingDuration(CStdString &strValue) const; - void CharInfoPlayingTime(CStdString &strValue) const; - void CharInfoNextTimer(CStdString &strValue) const; - void CharInfoBackendNumber(CStdString &strValue) const; - void CharInfoTotalDiskSpace(CStdString &strValue) const; - void CharInfoVideoBR(CStdString &strValue) const; - void CharInfoAudioBR(CStdString &strValue) const; - void CharInfoDolbyBR(CStdString &strValue) const; - void CharInfoSignal(CStdString &strValue) const; - void CharInfoSNR(CStdString &strValue) const; - void CharInfoBER(CStdString &strValue) const; - void CharInfoUNC(CStdString &strValue) const; - void CharInfoFrontendName(CStdString &strValue) const; - void CharInfoFrontendStatus(CStdString &strValue) const; - void CharInfoBackendName(CStdString &strValue) const; - void CharInfoBackendVersion(CStdString &strValue) const; - void CharInfoBackendHost(CStdString &strValue) const; - void CharInfoBackendDiskspace(CStdString &strValue) const; - void CharInfoBackendChannels(CStdString &strValue) const; - void CharInfoBackendTimers(CStdString &strValue) const; - void CharInfoBackendRecordings(CStdString &strValue) const; - void CharInfoPlayingClientName(CStdString &strValue) const; - void CharInfoEncryption(CStdString &strValue) const; - - /** @name GUIInfoManager data */ - //@{ - CStdString m_strActiveTimerTitle; - CStdString m_strActiveTimerChannelName; - CStdString m_strActiveTimerTime; - CStdString m_strNextTimerInfo; - CStdString m_strNextRecordingTitle; - CStdString m_strNextRecordingChannelName; - CStdString m_strNextRecordingTime; - bool m_bHasRecordings; - unsigned int m_iTimerAmount; - unsigned int m_iRecordingTimerAmount; - int m_iActiveClients; - CStdString m_strPlayingClientName; - CStdString m_strBackendName; - CStdString m_strBackendVersion; - CStdString m_strBackendHost; - CStdString m_strBackendDiskspace; - CStdString m_strBackendTimers; - CStdString m_strBackendRecordings; - CStdString m_strBackendChannels; - CStdString m_strTotalDiskspace; - //@} - - PVR_SIGNAL_STATUS m_qualityInfo; /*!< stream quality information */ - unsigned int m_iAddonInfoToggleStart; - unsigned int m_iAddonInfoToggleCurrent; - unsigned int m_iTimerInfoToggleStart; - unsigned int m_iTimerInfoToggleCurrent; - mutable const CPVREpgInfoTag * m_playingEpgTag; - - CCriticalSection m_critSection; -}; + class CPVREpgInfoTag; + class CPVRTimerInfoTag; + class CPVRRecording; + + class CPVRGUIInfo : private CThread, + private Observer + { + public: + CPVRGUIInfo(void); + virtual ~CPVRGUIInfo(void); + + void Start(void); + void Stop(void); + + void Notify(const Observable &obs, const CStdString& msg); + + bool TranslateBoolInfo(DWORD dwInfo) const; + bool TranslateCharInfo(DWORD dwInfo, CStdString &strValue) const; + int TranslateIntInfo(DWORD dwInfo) const; + + bool IsRecording(void) const; + bool HasTimers(void) const; + + /*! + * @brief Get the total duration of the currently playing LiveTV item. + * @return The total duration in milliseconds or NULL if no channel is playing. + */ + int GetTotalTime(void) const; + + /*! + * @brief Get the current position in milliseconds since the start of a LiveTV item. + * @return The position in milliseconds or NULL if no channel is playing. + */ + int GetStartTime(void) const; + + private: + void ResetProperties(void); + void Process(void); + + void UpdatePlayingTag(void); + void UpdateTimersCache(void); + void UpdateBackendCache(void); + void UpdateQualityData(void); + void UpdateMisc(void); + void UpdateNextTimer(void); + + bool AddonInfoToggle(void); + bool TimerInfoToggle(void); + void UpdateTimersToggle(void); + + void CharInfoActiveTimerTitle(CStdString &strValue) const; + void CharInfoActiveTimerChannelName(CStdString &strValue) const; + void CharInfoActiveTimerDateTime(CStdString &strValue) const; + void CharInfoNextTimerTitle(CStdString &strValue) const; + void CharInfoNextTimerChannelName(CStdString &strValue) const; + void CharInfoNextTimerDateTime(CStdString &strValue) const; + void CharInfoPlayingDuration(CStdString &strValue) const; + void CharInfoPlayingTime(CStdString &strValue) const; + void CharInfoNextTimer(CStdString &strValue) const; + void CharInfoBackendNumber(CStdString &strValue) const; + void CharInfoTotalDiskSpace(CStdString &strValue) const; + void CharInfoVideoBR(CStdString &strValue) const; + void CharInfoAudioBR(CStdString &strValue) const; + void CharInfoDolbyBR(CStdString &strValue) const; + void CharInfoSignal(CStdString &strValue) const; + void CharInfoSNR(CStdString &strValue) const; + void CharInfoBER(CStdString &strValue) const; + void CharInfoUNC(CStdString &strValue) const; + void CharInfoFrontendName(CStdString &strValue) const; + void CharInfoFrontendStatus(CStdString &strValue) const; + void CharInfoBackendName(CStdString &strValue) const; + void CharInfoBackendVersion(CStdString &strValue) const; + void CharInfoBackendHost(CStdString &strValue) const; + void CharInfoBackendDiskspace(CStdString &strValue) const; + void CharInfoBackendChannels(CStdString &strValue) const; + void CharInfoBackendTimers(CStdString &strValue) const; + void CharInfoBackendRecordings(CStdString &strValue) const; + void CharInfoPlayingClientName(CStdString &strValue) const; + void CharInfoEncryption(CStdString &strValue) const; + + /** @name GUIInfoManager data */ + //@{ + CStdString m_strActiveTimerTitle; + CStdString m_strActiveTimerChannelName; + CStdString m_strActiveTimerTime; + CStdString m_strNextTimerInfo; + CStdString m_strNextRecordingTitle; + CStdString m_strNextRecordingChannelName; + CStdString m_strNextRecordingTime; + bool m_bHasRecordings; + unsigned int m_iTimerAmount; + unsigned int m_iRecordingTimerAmount; + int m_iActiveClients; + CStdString m_strPlayingClientName; + CStdString m_strBackendName; + CStdString m_strBackendVersion; + CStdString m_strBackendHost; + CStdString m_strBackendDiskspace; + CStdString m_strBackendTimers; + CStdString m_strBackendRecordings; + CStdString m_strBackendChannels; + CStdString m_strTotalDiskspace; + //@} + + PVR_SIGNAL_STATUS m_qualityInfo; /*!< stream quality information */ + unsigned int m_iAddonInfoToggleStart; + unsigned int m_iAddonInfoToggleCurrent; + unsigned int m_iTimerInfoToggleStart; + unsigned int m_iTimerInfoToggleCurrent; + mutable const CPVREpgInfoTag * m_playingEpgTag; + + CCriticalSection m_critSection; + }; +} diff --git a/xbmc/pvr/PVRManager.cpp b/xbmc/pvr/PVRManager.cpp index ab4fae864983a..e26882ae28cc3 100644 --- a/xbmc/pvr/PVRManager.cpp +++ b/xbmc/pvr/PVRManager.cpp @@ -49,6 +49,7 @@ using namespace std; using namespace MUSIC_INFO; +using namespace PVR; CPVRManager::CPVRManager(void) { @@ -157,7 +158,7 @@ void CPVRManager::StopUpdateThreads(void) { StopThread(); m_epg->RemoveObserver(this); - m_epg->StopThread(); + m_epg->Stop(); m_guiInfo->Stop(); m_addons->Stop(); } diff --git a/xbmc/pvr/PVRManager.h b/xbmc/pvr/PVRManager.h index 682a087b89fe6..8b923be1a0797 100644 --- a/xbmc/pvr/PVRManager.h +++ b/xbmc/pvr/PVRManager.h @@ -25,513 +25,517 @@ #include "utils/JobManager.h" #include "windows/GUIWindowPVRCommon.h" -class CPVRClients; -class CPVRChannelGroupsContainer; -class CPVRChannelGroup; -class CPVRRecordings; -class CPVRTimers; -class CPVREpgContainer; -class CPVRGUIInfo; class CGUIDialogBusy; -class CPVRDatabase; - -#define g_PVRManager CPVRManager::Get() -#define g_PVRChannelGroups g_PVRManager.ChannelGroups() -#define g_PVREpg g_PVRManager.EPG() -#define g_PVRTimers g_PVRManager.Timers() -#define g_PVRRecordings g_PVRManager.Recordings() -#define g_PVRClients g_PVRManager.Clients() - -class CPVRManager : public Observer, private CThread, public IJobCallback +namespace PVR { - friend class CPVRClients; - -private: - /*! - * @brief Create a new CPVRManager instance, which handles all PVR related operations in XBMC. - */ - CPVRManager(void); - -public: - /*! - * @brief Process a message from an observable. - * @param obs The observable that sends the message. - * @param msg The message. - */ - void Notify(const Observable &obs, const CStdString& msg); - - /*! - * @brief Stop the PVRManager and destroy all objects it created. - */ - virtual ~CPVRManager(void); - - /*! - * @brief Get the instance of the PVRManager. - * @return The PVRManager instance. - */ - static CPVRManager &Get(void); - - /*! - * @brief Get the channel groups container. - * @return The groups container. - */ - CPVRChannelGroupsContainer *ChannelGroups(void) const { return m_channelGroups; } - - /*! - * @brief Get the EPG container. - * @return The EPG container. - */ - CPVREpgContainer *EPG(void) const { return m_epg; } - - /*! - * @brief Get the recordings container. - * @return The recordings container. - */ - CPVRRecordings *Recordings(void) const { return m_recordings; } - - /*! - * @brief Get the timers container. - * @return The timers container. - */ - CPVRTimers *Timers(void) const { return m_timers; } - - /*! - * @brief Get the timers container. - * @return The timers container. - */ - CPVRClients *Clients(void) const { return m_addons; } - - /*! - * @brief Start the PVRManager, which loads all PVR data and starts some threads to update the PVR data. - */ - void Start(void); - - /*! - * @brief Stop the PVRManager and destroy all objects it created. - */ - void Stop(void); - -public: - - /*! - * @brief Get the TV database. - * @return The TV database. - */ - CPVRDatabase *GetTVDatabase(void) const { return m_database; } - - /*! - * @brief Updates the recordings and the "now" and "next" timers. - */ - void UpdateRecordingsCache(void); - - /*! - * @brief Get a GUIInfoManager character string. - * @param dwInfo The string to get. - * @return The requested string or an empty one if it wasn't found. - */ - bool TranslateCharInfo(DWORD dwInfo, CStdString &strValue) const; - - /*! - * @brief Get a GUIInfoManager integer. - * @param dwInfo The integer to get. - * @return The requested integer or 0 if it wasn't found. - */ - int TranslateIntInfo(DWORD dwInfo) const; - - /*! - * @brief Get a GUIInfoManager boolean. - * @param dwInfo The boolean to get. - * @return The requested boolean or false if it wasn't found. - */ - bool TranslateBoolInfo(DWORD dwInfo) const; - - /*! - * @brief Reset the TV database to it's initial state and delete all the data inside. - * @param bShowProgress True to show a progress bar, false otherwise. - */ - void ResetDatabase(bool bShowProgress = true); - - /*! - * @brief Delete all EPG data from the database and reload it from the clients. - */ - void ResetEPG(void); - - /*! - * @brief Check if a TV channel, radio channel or recording is playing. - * @return True if it's playing, false otherwise. - */ - bool IsPlaying(void) const; - - /*! - * @return True if the thread is stopped, false otherwise. - */ - bool IsRunning(void) const; - - /*! - * @brief Return the channel that is currently playing. - * @param channel The channel or NULL if none is playing. - * @return True if a channel is playing, false otherwise. - */ - bool GetCurrentChannel(CPVRChannel *channel) const; - - /*! - * @brief Return the EPG for the channel that is currently playing. - * @param channel The EPG or NULL if no channel is playing. - * @return The amount of results that was added or -1 if none. - */ - int GetCurrentEpg(CFileItemList *results) const; - - /*! - * @brief Check whether the PVRManager has fully started. - * @return True if started, false otherwise. - */ - bool IsStarted(void) const { return m_bLoaded; } - - /*! - * @brief Switch to the given channel. - * @param channel The channel to switch to. - * @param bPreview True to show a preview, false otherwise. - * @return Trrue if the switch was successful, false otherwise. - */ - bool PerformChannelSwitch(const CPVRChannel &channel, bool bPreview); - - /*! - * @return True if a channel scan is running. - */ - bool IsRunningChannelScan(void) const; - - /*! - * @brief Close an open PVR stream. - */ - void CloseStream(void); - - /*! - * @brief Open a stream from the given channel. - * @param tag The channel to open. - * @return True if the stream was opened, false otherwise. - */ - bool OpenLiveStream(const CPVRChannel &tag); - - /*! - * @brief Open a stream from the given recording. - * @param tag The recording to open. - * @return True if the stream was opened, false otherwise. - */ - bool OpenRecordedStream(const CPVRRecording &tag); - - /*! - * @brief Start or stop recording on the channel that is currently being played. - * @param bOnOff True to start recording, false to stop. - * @return True if the recording was started or stopped successfully, false otherwise. - */ - bool StartRecordingOnPlayingChannel(bool bOnOff); - - /*! - * @brief Get the channel number of the previously selected channel. - * @return The requested channel number or -1 if it wasn't found. - */ - int GetPreviousChannel(void); - - /*! - * @brief Check whether there are active timers. - * @return True if there are active timers, false otherwise. - */ - bool HasTimer(void) const; - - /*! - * @brief Check whether there are active recordings. - * @return True if there are active recordings, false otherwise. - */ - bool IsRecording(void) const; - - /*! - * @brief Set the current playing group, used to load the right channel. - * @param group The new group. - */ - void SetPlayingGroup(CPVRChannelGroup *group); - - /*! - * @brief Get the current playing group, used to load the right channel. - * @param bRadio True to get the current radio group, false to get the current TV group. - * @return The current group or the group containing all channels if it's not set. - */ - const CPVRChannelGroup *GetPlayingGroup(bool bRadio = false); - - /*! - * @brief Let the background thread update the recordings list. - */ - void TriggerRecordingsUpdate(void); - - /*! - * @brief Let the background thread update the timer list. - */ - void TriggerTimersUpdate(void); - - /*! - * @brief Let the background thread update the channel list. - */ - void TriggerChannelsUpdate(void); - - /*! - * @brief Let the background thread update the channel groups list. - */ - void TriggerChannelGroupsUpdate(void); - - /*! - * @brief Update the channel that is currently active. - * @param item The new channel. - * @return True if it was updated correctly, false otherwise. - */ - bool UpdateItem(CFileItem& item); - - /*! - * @brief Switch to a channel given it's channel number. - * @param iChannelNumber The channel number to switch to. - * @return True if the channel was switched, false otherwise. - */ - bool ChannelSwitch(unsigned int iChannelNumber); - - /*! - * @brief Switch to the next channel in this group. - * @param iNewChannelNumber The new channel number after the switch. - * @param bPreview If true, don't do the actual switch but just update channel pointers. - * Used to display event info while doing "fast channel switching" - * @return True if the channel was switched, false otherwise. - */ - bool ChannelUp(unsigned int *iNewChannelNumber, bool bPreview = false) { return ChannelUpDown(iNewChannelNumber, bPreview, true); } - - /*! - * @brief Switch to the previous channel in this group. - * @param iNewChannelNumber The new channel number after the switch. - * @param bPreview If true, don't do the actual switch but just update channel pointers. - * Used to display event info while doing "fast channel switching" - * @return True if the channel was switched, false otherwise. - */ - bool ChannelDown(unsigned int *iNewChannelNumber, bool bPreview = false) { return ChannelUpDown(iNewChannelNumber, bPreview, false); } - - /*! - * @brief Get the total duration of the currently playing LiveTV item. - * @return The total duration in milliseconds or NULL if no channel is playing. - */ - int GetTotalTime(void) const; - - /*! - * @brief Get the current position in milliseconds since the start of a LiveTV item. - * @return The position in milliseconds or NULL if no channel is playing. - */ - int GetStartTime(void) const; - - /*! - * @brief Start playback on a channel. - * @param channel The channel to start to play. - * @param bPreview If true, open minimised. - * @return True if playback was started, false otherwise. - */ - bool StartPlayback(const CPVRChannel *channel, bool bPreview = false); - - /*! - * @brief Convert a genre id and subid to a human readable name. - * @param iID The genre ID. - * @param iSubID The genre sub ID. - * @return A human readable name. - */ - static const CStdString &ConvertGenreIdToString(int iID, int iSubID); - - /*! - * @brief Update the current playing file in the guiinfomanager and application. - */ - void UpdateCurrentFile(void); - - /*! - * @brief Update the data in a pvr window if that window is currently visible. - * @param window The window to update. - */ - void UpdateWindow(PVRWindow window); - - /*! - * @brief Check whether names are still correct after the language settings changed. - */ - void LocalizationChanged(void); - -protected: - /*! - * @brief PVR update and control thread. - */ - virtual void Process(void); - - /*! - * @brief Disable the pvrmanager if no clients are enabled or active. - * @return True if no clients are enabled, false otherwise. - */ - bool DisableIfNoClients(void); - -private: - - /*! - * @brief Load at least one client and load all other PVR data after loading the client. - * If some clients failed to load here, the pvrmanager will retry to load them every second. - * @return If at least one client and all pvr data was loaded, false otherwise. - */ - bool Load(void); - - /*! - * @brief Update all recordings. - */ - void UpdateRecordings(void); - - /*! - * @brief Update all timers. - */ - void UpdateTimers(void); - - /*! - * @brief Update all channels. - */ - void UpdateChannels(void); - - /*! - * @brief Update all channel groups and channels in them. - */ - void UpdateChannelGroups(void); - - /*! - * @see CPVRGUIInfo - */ - //!{ - const char *CharInfoNowRecordingTitle(void); - const char *CharInfoNowRecordingChannel(void); - const char *CharInfoNowRecordingDateTime(void); - const char *CharInfoNextRecordingTitle(void); - const char *CharInfoNextRecordingChannel(void); - const char *CharInfoNextRecordingDateTime(void); - const char *CharInfoNextTimer(void); - const char *CharInfoPlayingDuration(void); - const char *CharInfoPlayingTime(void); - //!} - - /*! - * @brief Reset all properties. - */ - void ResetProperties(void); - - /*! - * @brief Switch to the given channel. - * @param channel The new channel. - * @param bPreview Don't reset quality data if true. - * @return True if the switch was successful, false otherwise. - */ - bool PerformChannelSwitch(const CPVRChannel *channel, bool bPreview); - - /*! - * @brief Called by ChannelUp() and ChannelDown() to perform a channel switch. - * @param iNewChannelNumber The new channel number after the switch. - * @param bPreview Preview window if true. - * @param bUp Go one channel up if true, one channel down if false. - * @return True if the switch was successful, false otherwise. - */ - bool ChannelUpDown(unsigned int *iNewChannelNumber, bool bPreview, bool bUp); - - /*! - * @brief Stop the EPG and PVR threads but do not remove their data. - */ - void StopUpdateThreads(void); - - /*! - * @brief Restart the EPG and PVR threads after they've been stopped by StopUpdateThreads() - */ - bool StartUpdateThreads(void); - - /*! - * @brief Persist the current channel settings in the database. - */ - void SaveCurrentChannelSettings(void); - - /*! - * @brief Load the settings for the current channel from the database. - */ - void LoadCurrentChannelSettings(void); - - /*! - * @brief Continue playback on the last channel if it was stored in the database. - * @return True if playback was continued, false otherwise. - */ - bool ContinueLastChannel(void); - - /*! - * @brief Show or hide the busy dialog. - * @param bShow True to show the dialog, false to hide it. - */ - void ShowBusyDialog(bool bShow); - - void OnJobComplete(unsigned int jobID, bool success, CJob* job); - - /** @name containers */ - //@{ - CPVRChannelGroupsContainer * m_channelGroups; /*!< pointer to the channel groups container */ - CPVREpgContainer * m_epg; /*!< pointer to the EPG container */ - CPVRRecordings * m_recordings; /*!< pointer to the recordings container */ - CPVRTimers * m_timers; /*!< pointer to the timers container */ - CPVRClients * m_addons; /*!< pointer to the pvr addon container */ - CPVRGUIInfo * m_guiInfo; /*!< pointer to the guiinfo data */ - //@} - - CCriticalSection m_critSectionTriggers; /*!< critical section for triggered updates */ - bool m_bRecordingsUpdating; /*!< true when recordings are being updated */ - bool m_bTimersUpdating; /*!< true when timers are being updated */ - bool m_bChannelsUpdating; /*!< true when channels are being updated */ - bool m_bChannelGroupsUpdating; /*!< true when channel groups are being updated */ - CFileItem * m_currentFile; /*!< the PVR file that is currently playing */ - CPVRDatabase * m_database; /*!< the database for all PVR related data */ - CCriticalSection m_critSection; /*!< critical section for all changes to this class, except for changes to triggers */ - bool m_bFirstStart; /*!< true when the PVR manager was started first, false otherwise */ - bool m_bLoaded; /*!< true if the pvrmanager has been loaded and can be used */ - CGUIDialogBusy * m_loadingBusyDialog; /*!< busy dialog that is displayed while the pvrmanager is loading */ - CPVRChannelGroup * m_currentRadioGroup; /*!< the currently selected radio channel group list */ - CPVRChannelGroup * m_currentTVGroup; /*!< the currently selected TV channel group list */ - - int m_PreviousChannel[2]; - int m_PreviousChannelIndex; - int m_LastChannel; - unsigned int m_LastChannelChanged; -}; - -class CPVRRecordingsUpdateJob : public CJob -{ -public: - CPVRRecordingsUpdateJob(void) {} - virtual ~CPVRRecordingsUpdateJob() {} - virtual const char *GetType() const { return "pvr-update-recordings"; } - - virtual bool DoWork(); -}; - -class CPVRTimersUpdateJob : public CJob -{ -public: - CPVRTimersUpdateJob(void) {} - virtual ~CPVRTimersUpdateJob() {} - virtual const char *GetType() const { return "pvr-update-timers"; } - - virtual bool DoWork(); -}; - -class CPVRChannelsUpdateJob : public CJob -{ -public: - CPVRChannelsUpdateJob(void) {} - virtual ~CPVRChannelsUpdateJob() {} - virtual const char *GetType() const { return "pvr-update-channels"; } - - virtual bool DoWork(); -}; - -class CPVRChannelGroupsUpdateJob : public CJob -{ -public: - CPVRChannelGroupsUpdateJob(void) {} - virtual ~CPVRChannelGroupsUpdateJob() {} - virtual const char *GetType() const { return "pvr-update-channelgroups"; } - - virtual bool DoWork(); -}; + class CPVRClients; + class CPVRChannelGroupsContainer; + class CPVRChannelGroup; + class CPVRRecordings; + class CPVRTimers; + class CPVREpgContainer; + class CPVRGUIInfo; + class CPVRDatabase; + + + #define g_PVRManager CPVRManager::Get() + #define g_PVRChannelGroups g_PVRManager.ChannelGroups() + #define g_PVREpg g_PVRManager.EPG() + #define g_PVRTimers g_PVRManager.Timers() + #define g_PVRRecordings g_PVRManager.Recordings() + #define g_PVRClients g_PVRManager.Clients() + + class CPVRManager : public Observer, private CThread, public IJobCallback + { + friend class CPVRClients; + + private: + /*! + * @brief Create a new CPVRManager instance, which handles all PVR related operations in XBMC. + */ + CPVRManager(void); + + public: + /*! + * @brief Process a message from an observable. + * @param obs The observable that sends the message. + * @param msg The message. + */ + void Notify(const Observable &obs, const CStdString& msg); + + /*! + * @brief Stop the PVRManager and destroy all objects it created. + */ + virtual ~CPVRManager(void); + + /*! + * @brief Get the instance of the PVRManager. + * @return The PVRManager instance. + */ + static CPVRManager &Get(void); + + /*! + * @brief Get the channel groups container. + * @return The groups container. + */ + CPVRChannelGroupsContainer *ChannelGroups(void) const { return m_channelGroups; } + + /*! + * @brief Get the EPG container. + * @return The EPG container. + */ + CPVREpgContainer *EPG(void) const { return m_epg; } + + /*! + * @brief Get the recordings container. + * @return The recordings container. + */ + CPVRRecordings *Recordings(void) const { return m_recordings; } + + /*! + * @brief Get the timers container. + * @return The timers container. + */ + CPVRTimers *Timers(void) const { return m_timers; } + + /*! + * @brief Get the timers container. + * @return The timers container. + */ + CPVRClients *Clients(void) const { return m_addons; } + + /*! + * @brief Start the PVRManager, which loads all PVR data and starts some threads to update the PVR data. + */ + void Start(void); + + /*! + * @brief Stop the PVRManager and destroy all objects it created. + */ + void Stop(void); + + public: + + /*! + * @brief Get the TV database. + * @return The TV database. + */ + CPVRDatabase *GetTVDatabase(void) const { return m_database; } + + /*! + * @brief Updates the recordings and the "now" and "next" timers. + */ + void UpdateRecordingsCache(void); + + /*! + * @brief Get a GUIInfoManager character string. + * @param dwInfo The string to get. + * @return The requested string or an empty one if it wasn't found. + */ + bool TranslateCharInfo(DWORD dwInfo, CStdString &strValue) const; + + /*! + * @brief Get a GUIInfoManager integer. + * @param dwInfo The integer to get. + * @return The requested integer or 0 if it wasn't found. + */ + int TranslateIntInfo(DWORD dwInfo) const; + + /*! + * @brief Get a GUIInfoManager boolean. + * @param dwInfo The boolean to get. + * @return The requested boolean or false if it wasn't found. + */ + bool TranslateBoolInfo(DWORD dwInfo) const; + + /*! + * @brief Reset the TV database to it's initial state and delete all the data inside. + * @param bShowProgress True to show a progress bar, false otherwise. + */ + void ResetDatabase(bool bShowProgress = true); + + /*! + * @brief Delete all EPG data from the database and reload it from the clients. + */ + void ResetEPG(void); + + /*! + * @brief Check if a TV channel, radio channel or recording is playing. + * @return True if it's playing, false otherwise. + */ + bool IsPlaying(void) const; + + /*! + * @return True if the thread is stopped, false otherwise. + */ + bool IsRunning(void) const; + + /*! + * @brief Return the channel that is currently playing. + * @param channel The channel or NULL if none is playing. + * @return True if a channel is playing, false otherwise. + */ + bool GetCurrentChannel(CPVRChannel *channel) const; + + /*! + * @brief Return the EPG for the channel that is currently playing. + * @param channel The EPG or NULL if no channel is playing. + * @return The amount of results that was added or -1 if none. + */ + int GetCurrentEpg(CFileItemList *results) const; + + /*! + * @brief Check whether the PVRManager has fully started. + * @return True if started, false otherwise. + */ + bool IsStarted(void) const { return m_bLoaded; } + + /*! + * @brief Switch to the given channel. + * @param channel The channel to switch to. + * @param bPreview True to show a preview, false otherwise. + * @return Trrue if the switch was successful, false otherwise. + */ + bool PerformChannelSwitch(const CPVRChannel &channel, bool bPreview); + + /*! + * @return True if a channel scan is running. + */ + bool IsRunningChannelScan(void) const; + + /*! + * @brief Close an open PVR stream. + */ + void CloseStream(void); + + /*! + * @brief Open a stream from the given channel. + * @param tag The channel to open. + * @return True if the stream was opened, false otherwise. + */ + bool OpenLiveStream(const CPVRChannel &tag); + + /*! + * @brief Open a stream from the given recording. + * @param tag The recording to open. + * @return True if the stream was opened, false otherwise. + */ + bool OpenRecordedStream(const CPVRRecording &tag); + + /*! + * @brief Start or stop recording on the channel that is currently being played. + * @param bOnOff True to start recording, false to stop. + * @return True if the recording was started or stopped successfully, false otherwise. + */ + bool StartRecordingOnPlayingChannel(bool bOnOff); + + /*! + * @brief Get the channel number of the previously selected channel. + * @return The requested channel number or -1 if it wasn't found. + */ + int GetPreviousChannel(void); + + /*! + * @brief Check whether there are active timers. + * @return True if there are active timers, false otherwise. + */ + bool HasTimer(void) const; + + /*! + * @brief Check whether there are active recordings. + * @return True if there are active recordings, false otherwise. + */ + bool IsRecording(void) const; + + /*! + * @brief Set the current playing group, used to load the right channel. + * @param group The new group. + */ + void SetPlayingGroup(CPVRChannelGroup *group); + + /*! + * @brief Get the current playing group, used to load the right channel. + * @param bRadio True to get the current radio group, false to get the current TV group. + * @return The current group or the group containing all channels if it's not set. + */ + const CPVRChannelGroup *GetPlayingGroup(bool bRadio = false); + + /*! + * @brief Let the background thread update the recordings list. + */ + void TriggerRecordingsUpdate(void); + + /*! + * @brief Let the background thread update the timer list. + */ + void TriggerTimersUpdate(void); + + /*! + * @brief Let the background thread update the channel list. + */ + void TriggerChannelsUpdate(void); + + /*! + * @brief Let the background thread update the channel groups list. + */ + void TriggerChannelGroupsUpdate(void); + + /*! + * @brief Update the channel that is currently active. + * @param item The new channel. + * @return True if it was updated correctly, false otherwise. + */ + bool UpdateItem(CFileItem& item); + + /*! + * @brief Switch to a channel given it's channel number. + * @param iChannelNumber The channel number to switch to. + * @return True if the channel was switched, false otherwise. + */ + bool ChannelSwitch(unsigned int iChannelNumber); + + /*! + * @brief Switch to the next channel in this group. + * @param iNewChannelNumber The new channel number after the switch. + * @param bPreview If true, don't do the actual switch but just update channel pointers. + * Used to display event info while doing "fast channel switching" + * @return True if the channel was switched, false otherwise. + */ + bool ChannelUp(unsigned int *iNewChannelNumber, bool bPreview = false) { return ChannelUpDown(iNewChannelNumber, bPreview, true); } + + /*! + * @brief Switch to the previous channel in this group. + * @param iNewChannelNumber The new channel number after the switch. + * @param bPreview If true, don't do the actual switch but just update channel pointers. + * Used to display event info while doing "fast channel switching" + * @return True if the channel was switched, false otherwise. + */ + bool ChannelDown(unsigned int *iNewChannelNumber, bool bPreview = false) { return ChannelUpDown(iNewChannelNumber, bPreview, false); } + + /*! + * @brief Get the total duration of the currently playing LiveTV item. + * @return The total duration in milliseconds or NULL if no channel is playing. + */ + int GetTotalTime(void) const; + + /*! + * @brief Get the current position in milliseconds since the start of a LiveTV item. + * @return The position in milliseconds or NULL if no channel is playing. + */ + int GetStartTime(void) const; + + /*! + * @brief Start playback on a channel. + * @param channel The channel to start to play. + * @param bPreview If true, open minimised. + * @return True if playback was started, false otherwise. + */ + bool StartPlayback(const CPVRChannel *channel, bool bPreview = false); + + /*! + * @brief Convert a genre id and subid to a human readable name. + * @param iID The genre ID. + * @param iSubID The genre sub ID. + * @return A human readable name. + */ + static const CStdString &ConvertGenreIdToString(int iID, int iSubID); + + /*! + * @brief Update the current playing file in the guiinfomanager and application. + */ + void UpdateCurrentFile(void); + + /*! + * @brief Update the data in a pvr window if that window is currently visible. + * @param window The window to update. + */ + void UpdateWindow(PVRWindow window); + + /*! + * @brief Check whether names are still correct after the language settings changed. + */ + void LocalizationChanged(void); + + protected: + /*! + * @brief PVR update and control thread. + */ + virtual void Process(void); + + /*! + * @brief Disable the pvrmanager if no clients are enabled or active. + * @return True if no clients are enabled, false otherwise. + */ + bool DisableIfNoClients(void); + + private: + + /*! + * @brief Load at least one client and load all other PVR data after loading the client. + * If some clients failed to load here, the pvrmanager will retry to load them every second. + * @return If at least one client and all pvr data was loaded, false otherwise. + */ + bool Load(void); + + /*! + * @brief Update all recordings. + */ + void UpdateRecordings(void); + + /*! + * @brief Update all timers. + */ + void UpdateTimers(void); + + /*! + * @brief Update all channels. + */ + void UpdateChannels(void); + + /*! + * @brief Update all channel groups and channels in them. + */ + void UpdateChannelGroups(void); + + /*! + * @see CPVRGUIInfo + */ + //!{ + const char *CharInfoNowRecordingTitle(void); + const char *CharInfoNowRecordingChannel(void); + const char *CharInfoNowRecordingDateTime(void); + const char *CharInfoNextRecordingTitle(void); + const char *CharInfoNextRecordingChannel(void); + const char *CharInfoNextRecordingDateTime(void); + const char *CharInfoNextTimer(void); + const char *CharInfoPlayingDuration(void); + const char *CharInfoPlayingTime(void); + //!} + + /*! + * @brief Reset all properties. + */ + void ResetProperties(void); + + /*! + * @brief Switch to the given channel. + * @param channel The new channel. + * @param bPreview Don't reset quality data if true. + * @return True if the switch was successful, false otherwise. + */ + bool PerformChannelSwitch(const CPVRChannel *channel, bool bPreview); + + /*! + * @brief Called by ChannelUp() and ChannelDown() to perform a channel switch. + * @param iNewChannelNumber The new channel number after the switch. + * @param bPreview Preview window if true. + * @param bUp Go one channel up if true, one channel down if false. + * @return True if the switch was successful, false otherwise. + */ + bool ChannelUpDown(unsigned int *iNewChannelNumber, bool bPreview, bool bUp); + + /*! + * @brief Stop the EPG and PVR threads but do not remove their data. + */ + void StopUpdateThreads(void); + + /*! + * @brief Restart the EPG and PVR threads after they've been stopped by StopUpdateThreads() + */ + bool StartUpdateThreads(void); + + /*! + * @brief Persist the current channel settings in the database. + */ + void SaveCurrentChannelSettings(void); + + /*! + * @brief Load the settings for the current channel from the database. + */ + void LoadCurrentChannelSettings(void); + + /*! + * @brief Continue playback on the last channel if it was stored in the database. + * @return True if playback was continued, false otherwise. + */ + bool ContinueLastChannel(void); + + /*! + * @brief Show or hide the busy dialog. + * @param bShow True to show the dialog, false to hide it. + */ + void ShowBusyDialog(bool bShow); + + void OnJobComplete(unsigned int jobID, bool success, CJob* job); + + /** @name containers */ + //@{ + CPVRChannelGroupsContainer * m_channelGroups; /*!< pointer to the channel groups container */ + CPVREpgContainer * m_epg; /*!< pointer to the EPG container */ + CPVRRecordings * m_recordings; /*!< pointer to the recordings container */ + CPVRTimers * m_timers; /*!< pointer to the timers container */ + CPVRClients * m_addons; /*!< pointer to the pvr addon container */ + CPVRGUIInfo * m_guiInfo; /*!< pointer to the guiinfo data */ + //@} + + CCriticalSection m_critSectionTriggers; /*!< critical section for triggered updates */ + bool m_bRecordingsUpdating; /*!< true when recordings are being updated */ + bool m_bTimersUpdating; /*!< true when timers are being updated */ + bool m_bChannelsUpdating; /*!< true when channels are being updated */ + bool m_bChannelGroupsUpdating; /*!< true when channel groups are being updated */ + CFileItem * m_currentFile; /*!< the PVR file that is currently playing */ + CPVRDatabase * m_database; /*!< the database for all PVR related data */ + CCriticalSection m_critSection; /*!< critical section for all changes to this class, except for changes to triggers */ + bool m_bFirstStart; /*!< true when the PVR manager was started first, false otherwise */ + bool m_bLoaded; /*!< true if the pvrmanager has been loaded and can be used */ + CGUIDialogBusy * m_loadingBusyDialog; /*!< busy dialog that is displayed while the pvrmanager is loading */ + CPVRChannelGroup * m_currentRadioGroup; /*!< the currently selected radio channel group list */ + CPVRChannelGroup * m_currentTVGroup; /*!< the currently selected TV channel group list */ + + int m_PreviousChannel[2]; + int m_PreviousChannelIndex; + int m_LastChannel; + unsigned int m_LastChannelChanged; + }; + + class CPVRRecordingsUpdateJob : public CJob + { + public: + CPVRRecordingsUpdateJob(void) {} + virtual ~CPVRRecordingsUpdateJob() {} + virtual const char *GetType() const { return "pvr-update-recordings"; } + + virtual bool DoWork(); + }; + + class CPVRTimersUpdateJob : public CJob + { + public: + CPVRTimersUpdateJob(void) {} + virtual ~CPVRTimersUpdateJob() {} + virtual const char *GetType() const { return "pvr-update-timers"; } + + virtual bool DoWork(); + }; + + class CPVRChannelsUpdateJob : public CJob + { + public: + CPVRChannelsUpdateJob(void) {} + virtual ~CPVRChannelsUpdateJob() {} + virtual const char *GetType() const { return "pvr-update-channels"; } + + virtual bool DoWork(); + }; + + class CPVRChannelGroupsUpdateJob : public CJob + { + public: + CPVRChannelGroupsUpdateJob(void) {} + virtual ~CPVRChannelGroupsUpdateJob() {} + virtual const char *GetType() const { return "pvr-update-channelgroups"; } + + virtual bool DoWork(); + }; +} diff --git a/xbmc/pvr/addons/PVRClient.cpp b/xbmc/pvr/addons/PVRClient.cpp index fac8052f6d310..850d8acc219cf 100644 --- a/xbmc/pvr/addons/PVRClient.cpp +++ b/xbmc/pvr/addons/PVRClient.cpp @@ -38,6 +38,7 @@ using namespace std; using namespace ADDON; +using namespace PVR; CPVRClient::CPVRClient(const AddonProps& props) : CAddonDll(props), diff --git a/xbmc/pvr/addons/PVRClient.h b/xbmc/pvr/addons/PVRClient.h index 5c686f93be369..815622e82f220 100644 --- a/xbmc/pvr/addons/PVRClient.h +++ b/xbmc/pvr/addons/PVRClient.h @@ -24,495 +24,498 @@ #include "addons/AddonDll.h" #include "addons/DllPVRClient.h" -class CPVREpg; -class CPVRChannelGroup; -class CPVRChannelGroupInternal; -class CPVRChannelGroups; -class CPVRTimers; -class CPVRTimerInfoTag; -class CPVRRecordings; -class CPVRRecording; -class CPVREpgContainer; - -typedef std::vector PVR_MENUHOOKS; - -class IPVRClientCallback +namespace PVR { -public: - virtual void OnClientMessage(const int clientID, const PVR_EVENT clientEvent, const char* msg)=0; -}; - -/*! - * Interface from XBMC to a PVR add-on. - * - * Also translates XBMC's C++ structures to the addon's C structures. - */ -class CPVRClient : public ADDON::CAddonDll -{ -public: - CPVRClient(const ADDON::AddonProps& props); - CPVRClient(const cp_extension_t *ext); - ~CPVRClient(void); - - /** @name PVR add-on methods */ - //@{ - - /*! - * @brief Initialise the instance of this add-on. - * @param iClientId The ID of this add-on. - * @param pvrCB The call-back to use. - * @return True if it was created successfully, false otherwise. - */ - bool Create(int iClientId, IPVRClientCallback *pvrCB); - - /*! - * @brief Destroy the instance of this add-on. - */ - void Destroy(void); - - /*! - * @brief Destroy and recreate this add-on. - * @return True if the add-on was reinitialised successfully. - */ - bool ReCreate(void); - - /*! - * @return True if this instance is initialised, false otherwise. - */ - bool ReadyToUse(void) const; - - /*! - * @return The ID of this instance. - */ - int GetID(void) const; - - /*! - * @brief Change a setting in the add-on. - * @param settingName The name of the setting. - * @param settingValue The new value. - * @return The status reported by the add-on. - */ - virtual ADDON_STATUS SetSetting(const char *settingName, const void *settingValue); - - //@} - /** @name PVR server methods */ - //@{ - - /*! - * @brief Query this add-on's capabilities. - * @param pCapabilities The add-on properties. - * @return PVR_ERROR_NO_ERROR if the properties were fetched successfully. - */ - PVR_ERROR GetAddonCapabilities(PVR_ADDON_CAPABILITIES *pCapabilities); - - /*! - * @brief Get the stream properties of the stream that's currently being read. - * @param pProperties The properties. - * @return PVR_ERROR_NO_ERROR if the properties have been fetched successfully. - */ - PVR_ERROR GetStreamProperties(PVR_STREAM_PROPERTIES *pProperties); - - /*! - * @return The name reported by the backend. - */ - const char *GetBackendName(void); - - /*! - * @return The version string reported by the backend. - */ - const char *GetBackendVersion(void); - - /*! - * @return The connection string reported by the backend. - */ - const char *GetConnectionString(void); - - /*! - * @return A friendly name for this add-on that can be used in log messages. - */ - const char *GetFriendlyName(void); - - /*! - * @brief Get the disk space reported by the server. - * @param iTotal The total disk space. - * @param iUsed The used disk space. - * @return PVR_ERROR_NO_ERROR if the drive space has been fetched successfully. - */ - PVR_ERROR GetDriveSpace(long long *iTotal, long long *iUsed); - -// /*! -// * @brief Get the time reported by the backend. -// * @param localTime The local time. -// * @param iGmtOffset The GMT offset used. -// * @return PVR_ERROR_NO_ERROR if the time has been fetched successfully. -// */ -// PVR_ERROR GetBackendTime(time_t *localTime, int *iGmtOffset); - - /*! - * @brief Start a channel scan on the server. - * @return PVR_ERROR_NO_ERROR if the channel scan has been started successfully. - */ - PVR_ERROR StartChannelScan(void); - - /*! - * @return The ID of the client. - */ - int GetClientID(void) const; - - /*! - * @return True if this add-on has menu hooks, false otherwise. - */ - bool HaveMenuHooks(void) const; - - /*! - * @return The menu hooks for this add-on. - */ - PVR_MENUHOOKS *GetMenuHooks(void); - - /*! - * @brief Call one of the menu hooks of this client. - * @param hook The hook to call. - */ - void CallMenuHook(const PVR_MENUHOOK &hook); - - //@} - /** @name PVR EPG methods */ - //@{ - - /*! - * @brief Request an EPG table for a channel from the client. - * @param channel The channel to get the EPG table for. - * @param epg The table to write the data to. - * @param start The start time to use. - * @param end The end time to use. - * @param bSaveInDb If true, tell the callback method to save any new entry in the database or not. see CAddonCallbacksPVR::PVRTransferEpgEntry() - * @return PVR_ERROR_NO_ERROR if the table has been fetched successfully. - */ - PVR_ERROR GetEPGForChannel(const CPVRChannel &channel, CPVREpg *epg, time_t start = 0, time_t end = 0, bool bSaveInDb = false); - - //@} - /** @name PVR channel group methods */ - //@{ - - /*! - * @return The total amount of channel groups on the server or -1 on error. - */ - int GetChannelGroupsAmount(void); - - /*! - * @brief Request the list of all channel groups from the backend. - * @param groups The groups container to get the groups for. - * @return PVR_ERROR_NO_ERROR if the list has been fetched successfully. - */ - PVR_ERROR GetChannelGroups(CPVRChannelGroups *groups); - - /*! - * @brief Request the list of all group members from the backend. - * @param groups The group to get the members for. - * @return PVR_ERROR_NO_ERROR if the list has been fetched successfully. - */ - PVR_ERROR GetChannelGroupMembers(CPVRChannelGroup *group); - - //@} - /** @name PVR channel methods */ - //@{ - - /*! - * @return The total amount of channels on the server or -1 on error. - */ - int GetChannelsAmount(void); - - /*! - * @brief Request the list of all channels from the backend. - * @param channels The channel group to add the channels to. - * @param bRadio True to get the radio channels, false to get the TV channels. - * @return PVR_ERROR_NO_ERROR if the list has been fetched successfully. - */ - PVR_ERROR GetChannels(CPVRChannelGroup &channels, bool bRadio); - - //@} - /** @name PVR recording methods */ - //@{ - - /*! - * @return The total amount of channels on the server or -1 on error. - */ - int GetRecordingsAmount(void); - - /*! - * @brief Request the list of all recordings from the backend. - * @param results The container to add the recordings to. - * @return PVR_ERROR_NO_ERROR if the list has been fetched successfully. - */ - PVR_ERROR GetRecordings(CPVRRecordings *results); - - /*! - * @brief Delete a recording on the backend. - * @param recording The recording to delete. - * @return PVR_ERROR_NO_ERROR if the recording has been deleted successfully. - */ - PVR_ERROR DeleteRecording(const CPVRRecording &recording); - - /*! - * @brief Rename a recording on the backend. - * @param recording The recording to rename. - * @return PVR_ERROR_NO_ERROR if the recording has been renamed successfully. - */ - PVR_ERROR RenameRecording(const CPVRRecording &recording); - - //@} - /** @name PVR timer methods */ - //@{ - - /*! - * @return The total amount of timers on the backend or -1 on error. - */ - int GetTimersAmount(void); - - /*! - * @brief Request the list of all timers from the backend. - * @param results The container to store the result in. - * @return PVR_ERROR_NO_ERROR if the list has been fetched successfully. - */ - PVR_ERROR GetTimers(CPVRTimers *results); - - /*! - * @brief Add a timer on the backend. - * @param timer The timer to add. - * @return PVR_ERROR_NO_ERROR if the timer has been added successfully. - */ - PVR_ERROR AddTimer(const CPVRTimerInfoTag &timer); - - /*! - * @brief Delete a timer on the backend. - * @param timer The timer to delete. - * @param bForce Set to true to delete a timer that is currently recording a program. - * @return PVR_ERROR_NO_ERROR if the timer has been deleted successfully. - */ - PVR_ERROR DeleteTimer(const CPVRTimerInfoTag &timer, bool bForce = false); - - /*! - * @brief Rename a timer on the server. - * @param timer The timer to rename. - * @param strNewName The new name of the timer. - * @return PVR_ERROR_NO_ERROR if the timer has been renamed successfully. - */ - PVR_ERROR RenameTimer(const CPVRTimerInfoTag &timer, const CStdString &strNewName); - - /*! - * @brief Update the timer information on the server. - * @param timer The timer to update. - * @return PVR_ERROR_NO_ERROR if the timer has been updated successfully. - */ - PVR_ERROR UpdateTimer(const CPVRTimerInfoTag &timer); - - //@} - /** @name PVR live stream methods */ - //@{ - - /*! - * @brief Open a live stream on the server. - * @param channel The channel to stream. - * @return True if the stream opened successfully, false otherwise. - */ - bool OpenLiveStream(const CPVRChannel &channel); - - /*! - * @brief Close an open live stream. - */ - void CloseLiveStream(void); - - /*! - * @brief Read from an open live stream. - * @param lpBuf The buffer to store the data in. - * @param uiBufSize The amount of bytes to read. - * @return The amount of bytes that were actually read from the stream. - */ - int ReadLiveStream(void* lpBuf, int64_t uiBufSize); - - /*! - * @brief Seek in a live stream on a backend that supports timeshifting. - * @param iFilePosition The position to seek to. - * @param iWhence ? - * @return The new position. - */ - int64_t SeekLiveStream(int64_t iFilePosition, int iWhence = SEEK_SET); - - /*! - * @return The position in the stream that's currently being read. - */ - int64_t PositionLiveStream(void); - - /*! - * @return The total length of the stream that's currently being read. - */ - int64_t LengthLiveStream(void); - - /*! - * @return The channel number on the server of the live stream that's currently being read. - */ - int GetCurrentClientChannel(void); - - /*! - * @brief Switch to another channel. Only to be called when a live stream has already been opened. - * @param channel The channel to switch to. - * @return True if the switch was successful, false otherwise. - */ - bool SwitchChannel(const CPVRChannel &channel); - - /*! - * @brief Get the signal quality of the stream that's currently open. - * @param qualityinfo The signal quality. - * @return True if the signal quality has been read successfully, false otherwise. - */ - bool SignalQuality(PVR_SIGNAL_STATUS &qualityinfo); - - /*! - * @brief Get the stream URL for a channel from the server. Used by the MediaPortal add-on. - * @param channel The channel to get the stream URL for. - * @return The requested URL. - */ - const char *GetLiveStreamURL(const CPVRChannel &channel); - - //@} - /** @name PVR recording stream methods */ - //@{ - - /*! - * @brief Open a recording on the server. - * @param recording The recording to open. - * @return True if the stream has been opened succesfully, false otherwise. - */ - bool OpenRecordedStream(const CPVRRecording &recording); - - /*! - * @brief Close an open stream from a recording. - */ - void CloseRecordedStream(void); - - /*! - * @brief Read from a recording. - * @param lpBuf The buffer to store the data in. - * @param uiBufSize The amount of bytes to read. - * @return The amount of bytes that were actually read from the stream. - */ - int ReadRecordedStream(void* lpBuf, int64_t uiBufSize); - - /*! - * @brief Seek in a recorded stream. - * @param iFilePosition The position to seek to. - * @param iWhence ? - * @return The new position. - */ - int64_t SeekRecordedStream(int64_t iFilePosition, int iWhence = SEEK_SET); - - /*! - * @return The position in the stream that's currently being read. - */ - int64_t PositionRecordedStream(void); - - /*! - * @return The total length of the stream that's currently being read. - */ - int64_t LengthRecordedStream(void); - - //@} - /** @name PVR demultiplexer methods */ - //@{ - - /*! - * @brief Reset the demultiplexer in the add-on. - */ - void DemuxReset(void); - - /*! - * @brief Abort the demultiplexer thread in the add-on. - */ - void DemuxAbort(void); - - /*! - * @brief Flush all data that's currently in the demultiplexer buffer in the add-on. - */ - void DemuxFlush(void); - - /*! - * @brief Read a packet from the demultiplexer. - * @return The packet. - */ - DemuxPacket *DemuxRead(void); - - //@} - -protected: - bool m_bReadyToUse; /*!< true if this add-on is connected to the backend, false otherwise */ - IPVRClientCallback *m_manager; /*!< the callback to use for this add-on */ - CStdString m_strHostName; /*!< the host name */ - CCriticalSection m_critSection; /*!< mutex for this class */ - PVR_MENUHOOKS m_menuhooks; /*!< the menu hooks for this add-on */ - - /* cached data */ - CStdString m_strBackendName; /*!< the cached backend version */ - bool m_bGotBackendName; /*!< true if the backend name has already been fetched */ - CStdString m_strBackendVersion; /*!< the cached backend version */ - bool m_bGotBackendVersion; /*!< true if the backend version has already been fetched */ - CStdString m_strConnectionString; /*!< the cached connection string */ - bool m_bGotConnectionString; /*!< true if the connection string has already been fetched */ - CStdString m_strFriendlyName; /*!< the cached friendly name */ - bool m_bGotFriendlyName; /*!< true if the friendly name has already been fetched */ - PVR_ADDON_CAPABILITIES m_addonCapabilities; /*!< the cached add-on capabilities */ - bool m_bGotAddonCapabilities; /*!< true if the add-on capabilities have already been fetched */ - -private: - /*! - * @brief Copy over channel info from xbmcChannel to addonClient. - * @param xbmcChannel The channel on XBMC's side. - * @param addonChannel The channel on the addon's side. - */ - void WriteClientChannelInfo(const CPVRChannel &xbmcChannel, PVR_CHANNEL &addonChannel); - - /*! - * @brief Copy over timer info from xbmcTimer to addonTimer. - * @param xbmcTimer The timer on XBMC's side. - * @param addonTimer The timer on the addon's side. - */ - void WriteClientTimerInfo(const CPVRTimerInfoTag &xbmcTimer, PVR_TIMER &addonTimer); - - /*! - * @brief Copy over recording info from xbmcRecording to addonRecording. - * @param xbmcRecording The recording on XBMC's side. - * @param addonRecording The recording on the addon's side. - */ - void WriteClientRecordingInfo(const CPVRRecording &xbmcRecording, PVR_RECORDING &addonRecording); - - /*! - * @brief Copy over group info from xbmcGroup to addonGroup. - * @param xbmcGroup The group on XBMC's side. - * @param addonGroup The group on the addon's side. - */ - void WriteClientGroupInfo(const CPVRChannelGroup &xbmcGroup, PVR_CHANNEL_GROUP &addonGroup); - - /*! - * @brief Get the backend name from the server and store it locally. - */ - void SetBackendName(void); - - /*! - * @brief Get the backend version from the server and store it locally. - */ - void SetBackendVersion(void); - - /*! - * @brief Get the connection string from the server and store it locally. - */ - void SetConnectionString(void); - - /*! - * @brief Get the friendly from the server and store it locally. - */ - void SetFriendlyName(void); - - /*! - * @brief Get the backend properties from the server and store it locally. - */ - PVR_ERROR SetAddonCapabilities(void); -}; + class CPVREpg; + class CPVRChannelGroup; + class CPVRChannelGroupInternal; + class CPVRChannelGroups; + class CPVRTimers; + class CPVRTimerInfoTag; + class CPVRRecordings; + class CPVRRecording; + class CPVREpgContainer; + + typedef std::vector PVR_MENUHOOKS; + + class IPVRClientCallback + { + public: + virtual void OnClientMessage(const int clientID, const PVR_EVENT clientEvent, const char* msg)=0; + }; + + /*! + * Interface from XBMC to a PVR add-on. + * + * Also translates XBMC's C++ structures to the addon's C structures. + */ + class CPVRClient : public ADDON::CAddonDll + { + public: + CPVRClient(const ADDON::AddonProps& props); + CPVRClient(const cp_extension_t *ext); + ~CPVRClient(void); + + /** @name PVR add-on methods */ + //@{ + + /*! + * @brief Initialise the instance of this add-on. + * @param iClientId The ID of this add-on. + * @param pvrCB The call-back to use. + * @return True if it was created successfully, false otherwise. + */ + bool Create(int iClientId, IPVRClientCallback *pvrCB); + + /*! + * @brief Destroy the instance of this add-on. + */ + void Destroy(void); + + /*! + * @brief Destroy and recreate this add-on. + * @return True if the add-on was reinitialised successfully. + */ + bool ReCreate(void); + + /*! + * @return True if this instance is initialised, false otherwise. + */ + bool ReadyToUse(void) const; + + /*! + * @return The ID of this instance. + */ + int GetID(void) const; + + /*! + * @brief Change a setting in the add-on. + * @param settingName The name of the setting. + * @param settingValue The new value. + * @return The status reported by the add-on. + */ + virtual ADDON_STATUS SetSetting(const char *settingName, const void *settingValue); + + //@} + /** @name PVR server methods */ + //@{ + + /*! + * @brief Query this add-on's capabilities. + * @param pCapabilities The add-on properties. + * @return PVR_ERROR_NO_ERROR if the properties were fetched successfully. + */ + PVR_ERROR GetAddonCapabilities(PVR_ADDON_CAPABILITIES *pCapabilities); + + /*! + * @brief Get the stream properties of the stream that's currently being read. + * @param pProperties The properties. + * @return PVR_ERROR_NO_ERROR if the properties have been fetched successfully. + */ + PVR_ERROR GetStreamProperties(PVR_STREAM_PROPERTIES *pProperties); + + /*! + * @return The name reported by the backend. + */ + const char *GetBackendName(void); + + /*! + * @return The version string reported by the backend. + */ + const char *GetBackendVersion(void); + + /*! + * @return The connection string reported by the backend. + */ + const char *GetConnectionString(void); + + /*! + * @return A friendly name for this add-on that can be used in log messages. + */ + const char *GetFriendlyName(void); + + /*! + * @brief Get the disk space reported by the server. + * @param iTotal The total disk space. + * @param iUsed The used disk space. + * @return PVR_ERROR_NO_ERROR if the drive space has been fetched successfully. + */ + PVR_ERROR GetDriveSpace(long long *iTotal, long long *iUsed); + + // /*! + // * @brief Get the time reported by the backend. + // * @param localTime The local time. + // * @param iGmtOffset The GMT offset used. + // * @return PVR_ERROR_NO_ERROR if the time has been fetched successfully. + // */ + // PVR_ERROR GetBackendTime(time_t *localTime, int *iGmtOffset); + + /*! + * @brief Start a channel scan on the server. + * @return PVR_ERROR_NO_ERROR if the channel scan has been started successfully. + */ + PVR_ERROR StartChannelScan(void); + + /*! + * @return The ID of the client. + */ + int GetClientID(void) const; + + /*! + * @return True if this add-on has menu hooks, false otherwise. + */ + bool HaveMenuHooks(void) const; + + /*! + * @return The menu hooks for this add-on. + */ + PVR_MENUHOOKS *GetMenuHooks(void); + + /*! + * @brief Call one of the menu hooks of this client. + * @param hook The hook to call. + */ + void CallMenuHook(const PVR_MENUHOOK &hook); + + //@} + /** @name PVR EPG methods */ + //@{ + + /*! + * @brief Request an EPG table for a channel from the client. + * @param channel The channel to get the EPG table for. + * @param epg The table to write the data to. + * @param start The start time to use. + * @param end The end time to use. + * @param bSaveInDb If true, tell the callback method to save any new entry in the database or not. see CAddonCallbacksPVR::PVRTransferEpgEntry() + * @return PVR_ERROR_NO_ERROR if the table has been fetched successfully. + */ + PVR_ERROR GetEPGForChannel(const CPVRChannel &channel, CPVREpg *epg, time_t start = 0, time_t end = 0, bool bSaveInDb = false); + + //@} + /** @name PVR channel group methods */ + //@{ + + /*! + * @return The total amount of channel groups on the server or -1 on error. + */ + int GetChannelGroupsAmount(void); + + /*! + * @brief Request the list of all channel groups from the backend. + * @param groups The groups container to get the groups for. + * @return PVR_ERROR_NO_ERROR if the list has been fetched successfully. + */ + PVR_ERROR GetChannelGroups(CPVRChannelGroups *groups); + + /*! + * @brief Request the list of all group members from the backend. + * @param groups The group to get the members for. + * @return PVR_ERROR_NO_ERROR if the list has been fetched successfully. + */ + PVR_ERROR GetChannelGroupMembers(CPVRChannelGroup *group); + + //@} + /** @name PVR channel methods */ + //@{ + + /*! + * @return The total amount of channels on the server or -1 on error. + */ + int GetChannelsAmount(void); + + /*! + * @brief Request the list of all channels from the backend. + * @param channels The channel group to add the channels to. + * @param bRadio True to get the radio channels, false to get the TV channels. + * @return PVR_ERROR_NO_ERROR if the list has been fetched successfully. + */ + PVR_ERROR GetChannels(CPVRChannelGroup &channels, bool bRadio); + + //@} + /** @name PVR recording methods */ + //@{ + + /*! + * @return The total amount of channels on the server or -1 on error. + */ + int GetRecordingsAmount(void); + + /*! + * @brief Request the list of all recordings from the backend. + * @param results The container to add the recordings to. + * @return PVR_ERROR_NO_ERROR if the list has been fetched successfully. + */ + PVR_ERROR GetRecordings(CPVRRecordings *results); + + /*! + * @brief Delete a recording on the backend. + * @param recording The recording to delete. + * @return PVR_ERROR_NO_ERROR if the recording has been deleted successfully. + */ + PVR_ERROR DeleteRecording(const CPVRRecording &recording); + + /*! + * @brief Rename a recording on the backend. + * @param recording The recording to rename. + * @return PVR_ERROR_NO_ERROR if the recording has been renamed successfully. + */ + PVR_ERROR RenameRecording(const CPVRRecording &recording); + + //@} + /** @name PVR timer methods */ + //@{ + + /*! + * @return The total amount of timers on the backend or -1 on error. + */ + int GetTimersAmount(void); + + /*! + * @brief Request the list of all timers from the backend. + * @param results The container to store the result in. + * @return PVR_ERROR_NO_ERROR if the list has been fetched successfully. + */ + PVR_ERROR GetTimers(CPVRTimers *results); + + /*! + * @brief Add a timer on the backend. + * @param timer The timer to add. + * @return PVR_ERROR_NO_ERROR if the timer has been added successfully. + */ + PVR_ERROR AddTimer(const CPVRTimerInfoTag &timer); + + /*! + * @brief Delete a timer on the backend. + * @param timer The timer to delete. + * @param bForce Set to true to delete a timer that is currently recording a program. + * @return PVR_ERROR_NO_ERROR if the timer has been deleted successfully. + */ + PVR_ERROR DeleteTimer(const CPVRTimerInfoTag &timer, bool bForce = false); + + /*! + * @brief Rename a timer on the server. + * @param timer The timer to rename. + * @param strNewName The new name of the timer. + * @return PVR_ERROR_NO_ERROR if the timer has been renamed successfully. + */ + PVR_ERROR RenameTimer(const CPVRTimerInfoTag &timer, const CStdString &strNewName); + + /*! + * @brief Update the timer information on the server. + * @param timer The timer to update. + * @return PVR_ERROR_NO_ERROR if the timer has been updated successfully. + */ + PVR_ERROR UpdateTimer(const CPVRTimerInfoTag &timer); + + //@} + /** @name PVR live stream methods */ + //@{ + + /*! + * @brief Open a live stream on the server. + * @param channel The channel to stream. + * @return True if the stream opened successfully, false otherwise. + */ + bool OpenLiveStream(const CPVRChannel &channel); + + /*! + * @brief Close an open live stream. + */ + void CloseLiveStream(void); + + /*! + * @brief Read from an open live stream. + * @param lpBuf The buffer to store the data in. + * @param uiBufSize The amount of bytes to read. + * @return The amount of bytes that were actually read from the stream. + */ + int ReadLiveStream(void* lpBuf, int64_t uiBufSize); + + /*! + * @brief Seek in a live stream on a backend that supports timeshifting. + * @param iFilePosition The position to seek to. + * @param iWhence ? + * @return The new position. + */ + int64_t SeekLiveStream(int64_t iFilePosition, int iWhence = SEEK_SET); + + /*! + * @return The position in the stream that's currently being read. + */ + int64_t PositionLiveStream(void); + + /*! + * @return The total length of the stream that's currently being read. + */ + int64_t LengthLiveStream(void); + + /*! + * @return The channel number on the server of the live stream that's currently being read. + */ + int GetCurrentClientChannel(void); + + /*! + * @brief Switch to another channel. Only to be called when a live stream has already been opened. + * @param channel The channel to switch to. + * @return True if the switch was successful, false otherwise. + */ + bool SwitchChannel(const CPVRChannel &channel); + + /*! + * @brief Get the signal quality of the stream that's currently open. + * @param qualityinfo The signal quality. + * @return True if the signal quality has been read successfully, false otherwise. + */ + bool SignalQuality(PVR_SIGNAL_STATUS &qualityinfo); + + /*! + * @brief Get the stream URL for a channel from the server. Used by the MediaPortal add-on. + * @param channel The channel to get the stream URL for. + * @return The requested URL. + */ + const char *GetLiveStreamURL(const CPVRChannel &channel); + + //@} + /** @name PVR recording stream methods */ + //@{ + + /*! + * @brief Open a recording on the server. + * @param recording The recording to open. + * @return True if the stream has been opened succesfully, false otherwise. + */ + bool OpenRecordedStream(const CPVRRecording &recording); + + /*! + * @brief Close an open stream from a recording. + */ + void CloseRecordedStream(void); + + /*! + * @brief Read from a recording. + * @param lpBuf The buffer to store the data in. + * @param uiBufSize The amount of bytes to read. + * @return The amount of bytes that were actually read from the stream. + */ + int ReadRecordedStream(void* lpBuf, int64_t uiBufSize); + + /*! + * @brief Seek in a recorded stream. + * @param iFilePosition The position to seek to. + * @param iWhence ? + * @return The new position. + */ + int64_t SeekRecordedStream(int64_t iFilePosition, int iWhence = SEEK_SET); + + /*! + * @return The position in the stream that's currently being read. + */ + int64_t PositionRecordedStream(void); + + /*! + * @return The total length of the stream that's currently being read. + */ + int64_t LengthRecordedStream(void); + + //@} + /** @name PVR demultiplexer methods */ + //@{ + + /*! + * @brief Reset the demultiplexer in the add-on. + */ + void DemuxReset(void); + + /*! + * @brief Abort the demultiplexer thread in the add-on. + */ + void DemuxAbort(void); + + /*! + * @brief Flush all data that's currently in the demultiplexer buffer in the add-on. + */ + void DemuxFlush(void); + + /*! + * @brief Read a packet from the demultiplexer. + * @return The packet. + */ + DemuxPacket *DemuxRead(void); + + //@} + + protected: + bool m_bReadyToUse; /*!< true if this add-on is connected to the backend, false otherwise */ + IPVRClientCallback *m_manager; /*!< the callback to use for this add-on */ + CStdString m_strHostName; /*!< the host name */ + CCriticalSection m_critSection; /*!< mutex for this class */ + PVR_MENUHOOKS m_menuhooks; /*!< the menu hooks for this add-on */ + + /* cached data */ + CStdString m_strBackendName; /*!< the cached backend version */ + bool m_bGotBackendName; /*!< true if the backend name has already been fetched */ + CStdString m_strBackendVersion; /*!< the cached backend version */ + bool m_bGotBackendVersion; /*!< true if the backend version has already been fetched */ + CStdString m_strConnectionString; /*!< the cached connection string */ + bool m_bGotConnectionString; /*!< true if the connection string has already been fetched */ + CStdString m_strFriendlyName; /*!< the cached friendly name */ + bool m_bGotFriendlyName; /*!< true if the friendly name has already been fetched */ + PVR_ADDON_CAPABILITIES m_addonCapabilities; /*!< the cached add-on capabilities */ + bool m_bGotAddonCapabilities; /*!< true if the add-on capabilities have already been fetched */ + + private: + /*! + * @brief Copy over channel info from xbmcChannel to addonClient. + * @param xbmcChannel The channel on XBMC's side. + * @param addonChannel The channel on the addon's side. + */ + void WriteClientChannelInfo(const CPVRChannel &xbmcChannel, PVR_CHANNEL &addonChannel); + + /*! + * @brief Copy over timer info from xbmcTimer to addonTimer. + * @param xbmcTimer The timer on XBMC's side. + * @param addonTimer The timer on the addon's side. + */ + void WriteClientTimerInfo(const CPVRTimerInfoTag &xbmcTimer, PVR_TIMER &addonTimer); + + /*! + * @brief Copy over recording info from xbmcRecording to addonRecording. + * @param xbmcRecording The recording on XBMC's side. + * @param addonRecording The recording on the addon's side. + */ + void WriteClientRecordingInfo(const CPVRRecording &xbmcRecording, PVR_RECORDING &addonRecording); + + /*! + * @brief Copy over group info from xbmcGroup to addonGroup. + * @param xbmcGroup The group on XBMC's side. + * @param addonGroup The group on the addon's side. + */ + void WriteClientGroupInfo(const CPVRChannelGroup &xbmcGroup, PVR_CHANNEL_GROUP &addonGroup); + + /*! + * @brief Get the backend name from the server and store it locally. + */ + void SetBackendName(void); + + /*! + * @brief Get the backend version from the server and store it locally. + */ + void SetBackendVersion(void); + + /*! + * @brief Get the connection string from the server and store it locally. + */ + void SetConnectionString(void); + + /*! + * @brief Get the friendly from the server and store it locally. + */ + void SetFriendlyName(void); + + /*! + * @brief Get the backend properties from the server and store it locally. + */ + PVR_ERROR SetAddonCapabilities(void); + }; +} diff --git a/xbmc/pvr/addons/PVRClients.cpp b/xbmc/pvr/addons/PVRClients.cpp index 2322231b205f8..c718130b5f33c 100644 --- a/xbmc/pvr/addons/PVRClients.cpp +++ b/xbmc/pvr/addons/PVRClients.cpp @@ -39,6 +39,7 @@ using namespace std; using namespace ADDON; +using namespace PVR; CPVRClients::CPVRClients(void) { diff --git a/xbmc/pvr/addons/PVRClients.h b/xbmc/pvr/addons/PVRClients.h index 6e8ce002bdd02..fae2380df210f 100644 --- a/xbmc/pvr/addons/PVRClients.h +++ b/xbmc/pvr/addons/PVRClients.h @@ -27,326 +27,329 @@ #include #include -class CPVRGUIInfo; - -typedef std::map< long, boost::shared_ptr > CLIENTMAP; -typedef std::map< long, boost::shared_ptr >::iterator CLIENTMAPITR; -typedef std::map< long, PVR_ADDON_CAPABILITIES > CLIENTPROPS; -typedef std::map< long, PVR_STREAM_PROPERTIES > STREAMPROPS; - -#define XBMC_VIRTUAL_CLIENTID -1 - -class CPVRClients : IPVRClientCallback, - public ADDON::IAddonMgrCallback, - private CThread +namespace PVR { - friend class CPVRGUIInfo; - -public: - CPVRClients(void); - virtual ~CPVRClients(void); - - /*! - * @brief Get the ID of the first client. - * @return The ID of the first client or -1 if no clients are active; - */ - int GetFirstID(void); - - /*! - * @brief Try to load and initialise all clients. - * @param iMaxTime Maximum time to try to load clients in seconds. Use 0 to keep trying until m_bStop becomes true. - * @return True if all clients were loaded, false otherwise. - */ - bool TryLoadClients(int iMaxTime = 0); - - /*! - * @brief Stop a client. - * @param addon The client to stop. - * @param bRestart If true, restart the client. - * @return True if the client was found, false otherwise. - */ - bool StopClient(ADDON::AddonPtr client, bool bRestart); - - /*! - * @brief Open a stream on the given channel. - * @param tag The channel to start playing. - * @return True if the stream was opened successfully, false otherwise. - */ - bool OpenLiveStream(const CPVRChannel &tag); - bool CloseLiveStream(void); - - /*! - * @brief Open a stream from the given recording. - * @param tag The recording to start playing. - * @return True if the stream was opened successfully, false otherwise. - */ - bool OpenRecordedStream(const CPVRRecording &tag); - bool CloseRecordedStream(void); - - /*! - * @brief Close a PVR stream. - */ - void CloseStream(void); - - /*! - * @brief Read from an open stream. - * @param lpBuf Target buffer. - * @param uiBufSize The size of the buffer. - * @return The amount of bytes that was added. - */ - int ReadStream(void* lpBuf, int64_t uiBufSize); - - /*! - * @brief Reset the demuxer. - */ - void DemuxReset(void); - - /*! - * @brief Abort any internal reading that might be stalling main thread. - * NOTICE - this can be called from another thread. - */ - void DemuxAbort(void); - - /*! - * @brief Flush the demuxer. If any data is kept in buffers, this should be freed now. - */ - void DemuxFlush(void); - - /*! - * @brief Read the stream from the demuxer - * @return An allocated demuxer packet - */ - DemuxPacket* ReadDemuxStream(void); - - /*! - * @brief Return the filesize of the currently running stream. - * Limited to recordings playback at the moment. - * @return The size of the stream. - */ - int64_t LengthStream(void); - - /*! - * @brief Seek to a position in a stream. - * Limited to recordings playback at the moment. - * @param iFilePosition The position to seek to. - * @param iWhence Specify how to seek ("new position=pos", "new position=pos+actual postion" or "new position=filesize-pos") - * @return The new stream position. - */ - int64_t SeekStream(int64_t iFilePosition, int iWhence = SEEK_SET); - - /*! - * @brief Get the currently playing position in a stream. - * @return The current position. - */ - int64_t GetStreamPosition(void); - - const CStdString GetClientName(int iClientId); - const CStdString GetStreamURL(const CPVRChannel &tag); - int GetSignalLevel(void) const; - int GetSNR(void) const; - bool HasClients(void) const; - bool HasTimerSupport(int iClientId); - bool IsEncrypted(void) const; - bool IsPlaying(void) const; - bool AllClientsLoaded(void) const; - bool IsReadingLiveStream(void) const; - const CStdString GetPlayingClientName(void) const { return m_strPlayingClientName; } - bool SwitchChannel(const CPVRChannel &channel); - - int GetTimers(CPVRTimers *timers); - bool AddTimer(const CPVRTimerInfoTag &timer, PVR_ERROR *error); - bool UpdateTimer(const CPVRTimerInfoTag &timer, PVR_ERROR *error); - bool DeleteTimer(const CPVRTimerInfoTag &timer, bool bForce, PVR_ERROR *error); - bool RenameTimer(const CPVRTimerInfoTag &timer, const CStdString &strNewName, PVR_ERROR *error); - - int GetRecordings(CPVRRecordings *recordings); - bool RenameRecording(const CPVRRecording &recording, PVR_ERROR *error); - bool DeleteRecording(const CPVRRecording &recording, PVR_ERROR *error); - - bool GetEPGForChannel(const CPVRChannel &channel, CPVREpg *epg, time_t start, time_t end, PVR_ERROR *error); - int GetChannelGroups(CPVRChannelGroups *groups, PVR_ERROR *error); - int GetChannelGroupMembers(CPVRChannelGroup *group, PVR_ERROR *error); - int GetChannels(CPVRChannelGroupInternal *group, PVR_ERROR *error); - - int GetClients(std::map *clients); - - /*! - * @brief Check whether a client has any PVR specific menu entries. - * @param iClientId The ID of the client to get the menu entries for. Get the menu for the active channel if iClientId < 0. - * @return True if the client has any menu hooks, false otherwise. - */ - bool HasMenuHooks(int iClientId); - - /*! - * @brief Open selection and progress PVR actions. - * @param iClientId The ID of the client to process the menu entries for. Process the menu entries for the active channel if iClientId < 0. - */ - void ProcessMenuHooks(int iClientID); - - /*! - * @brief Check whether the current channel can be recorded instantly. - * @return True if it can, false otherwise. - */ - bool CanRecordInstantly(void); - - /*! - * @return The amount of active clients. - */ - int ActiveClientAmount(void); - - /*! - * @brief Check whether there are any active clients. - * @return True if at least one client is active. - */ - bool HasActiveClients(void); - - /*! - * @brief Callback function from client to inform about changed timers, channels, recordings or epg. - * @param clientID The ID of the client that sends an update. - * @param clientEvent The event that just happened. - * @param strMessage The passed message. - */ - void OnClientMessage(const int iClientId, const PVR_EVENT clientEvent, const char* strMessage); - - /*! - * @brief Restart a single client add-on. - * @param addon The add-on to restart. - * @param bDataChanged True if the client's data changed, false otherwise (unused). - * @return True if the client was found and restarted, false otherwise. - */ - bool RequestRestart(ADDON::AddonPtr addon, bool bDataChanged); - - /*! - * @brief Remove a single client add-on. - * @param addon The add-on to remove. - * @return True if the client was found and removed, false otherwise. - */ - bool RequestRemoval(ADDON::AddonPtr addon); - - /*! - * @brief Check if a TV channel is playing. - * @return True if it's playing, false otherwise. - */ - bool IsPlayingTV(void) const; - - /*! - * @brief Check if a radio channel is playing. - * @return True if it's playing, false otherwise. - */ - bool IsPlayingRadio(void) const; - - /*! - * @brief Check if a recording is playing. - * @return True if it's playing, false otherwise. - */ - bool IsPlayingRecording(void) const; - - bool IsRunningChannelScan(void) const; - - /*! - * @brief Open a selection dialog and start a channel scan on the selected client. - */ - void StartChannelScan(void); - - /*! - * @brief Check whether a channel scan is running. - * @return True if it's running, false otherwise. - */ - bool ChannelScanRunning(void) { return m_bChannelScanRunning; } - - /*! - * @brief Get the properties of the current playing client. - * @return A pointer to the properties or NULL if no stream is playing. - */ - PVR_ADDON_CAPABILITIES*GetCurrentClientProperties(void); - - /*! - * @brief Get the ID of the client that is currently being used to play. - * @return The requested ID or -1 if no PVR item is currently being played. - */ - int GetCurrentPlayingClientID(void); - - /*! - * @brief Get the properties for a specific client. - * @param clientID The ID of the client. - * @return A pointer to the properties or NULL if no stream is playing. - */ - PVR_ADDON_CAPABILITIES *GetClientProperties(int iClientId) { return &m_clientsProps[iClientId]; } - - /*! - * @brief Get the properties of the current playing stream content. - * @return A pointer to the properties or NULL if no stream is playing. - */ - PVR_STREAM_PROPERTIES *GetCurrentStreamProperties(void); - - /*! - * @brief Get the input format name of the current playing stream content. - * @return A pointer to the properties or NULL if no stream is playing. - */ - CStdString GetCurrentInputFormat(void) const; - - /*! - * @brief Start an instant recording on the current channel. - * @param bOnOff Activate the recording if true, deactivate if false. - * @return True if the recording was started, false otherwise. - */ - bool StartRecordingOnPlayingChannel(bool bOnOff); - - /*! - * @brief Check whether there is an active recording on the current channel. - * @return True if there is, false otherwise. - */ - bool IsRecordingOnPlayingChannel(void) const; - - void Unload(void); - - bool GetPlayingChannel(CPVRChannel *channel) const; - bool GetPlayingRecording(CPVRRecording *recording) const; - int GetPlayingClientID(void) const; - bool IsValidClient(int iClientId); - bool ClientLoaded(const CStdString &strClientId); - - void GetQualityData(PVR_SIGNAL_STATUS *status) const; - - void Start(void); - void Stop(void); - -private: - int AddClientToDb(const CStdString &strClientId, const CStdString &strName); - int ReadLiveStream(void* lpBuf, int64_t uiBufSize); - int ReadRecordedStream(void* lpBuf, int64_t uiBufSize); - bool GetMenuHooks(int iClientID, PVR_MENUHOOKS *hooks); - - void UpdateCharInfoSignalStatus(void); - - /*! - * @brief Load and initialise all clients. - * @return True if any clients were loaded, false otherwise. - */ - bool LoadClients(void); - - /*! - * @brief Reset the signal quality data to the initial values. - */ - void ResetQualityData(void); - - /*! - * @brief Updates the backend information - */ - void Process(void); - - int GetActiveClients(CLIENTMAP *clients); - - const CPVRChannel * m_currentChannel; - const CPVRRecording * m_currentRecording; - CStdString m_strPlayingClientName; - bool m_bAllClientsLoaded; /*!< true if all clients are loaded, false otherwise */ - CCriticalSection m_critSection; - CLIENTMAP m_clientMap; - CLIENTPROPS m_clientsProps; /*!< store the properties of each client locally */ - PVR_SIGNAL_STATUS m_qualityInfo; /*!< stream quality information */ - bool m_bChannelScanRunning; /*!< true if a channel scan is currently running, false otherwise */ - STREAMPROPS m_streamProps; /*!< the current stream's properties */ - - DWORD m_scanStart; /* Scan start time to check for non present streams */ -}; + class CPVRGUIInfo; + + typedef std::map< long, boost::shared_ptr > CLIENTMAP; + typedef std::map< long, boost::shared_ptr >::iterator CLIENTMAPITR; + typedef std::map< long, PVR_ADDON_CAPABILITIES > CLIENTPROPS; + typedef std::map< long, PVR_STREAM_PROPERTIES > STREAMPROPS; + + #define XBMC_VIRTUAL_CLIENTID -1 + + class CPVRClients : IPVRClientCallback, + public ADDON::IAddonMgrCallback, + private CThread + { + friend class CPVRGUIInfo; + + public: + CPVRClients(void); + virtual ~CPVRClients(void); + + /*! + * @brief Get the ID of the first client. + * @return The ID of the first client or -1 if no clients are active; + */ + int GetFirstID(void); + + /*! + * @brief Try to load and initialise all clients. + * @param iMaxTime Maximum time to try to load clients in seconds. Use 0 to keep trying until m_bStop becomes true. + * @return True if all clients were loaded, false otherwise. + */ + bool TryLoadClients(int iMaxTime = 0); + + /*! + * @brief Stop a client. + * @param addon The client to stop. + * @param bRestart If true, restart the client. + * @return True if the client was found, false otherwise. + */ + bool StopClient(ADDON::AddonPtr client, bool bRestart); + + /*! + * @brief Open a stream on the given channel. + * @param tag The channel to start playing. + * @return True if the stream was opened successfully, false otherwise. + */ + bool OpenLiveStream(const CPVRChannel &tag); + bool CloseLiveStream(void); + + /*! + * @brief Open a stream from the given recording. + * @param tag The recording to start playing. + * @return True if the stream was opened successfully, false otherwise. + */ + bool OpenRecordedStream(const CPVRRecording &tag); + bool CloseRecordedStream(void); + + /*! + * @brief Close a PVR stream. + */ + void CloseStream(void); + + /*! + * @brief Read from an open stream. + * @param lpBuf Target buffer. + * @param uiBufSize The size of the buffer. + * @return The amount of bytes that was added. + */ + int ReadStream(void* lpBuf, int64_t uiBufSize); + + /*! + * @brief Reset the demuxer. + */ + void DemuxReset(void); + + /*! + * @brief Abort any internal reading that might be stalling main thread. + * NOTICE - this can be called from another thread. + */ + void DemuxAbort(void); + + /*! + * @brief Flush the demuxer. If any data is kept in buffers, this should be freed now. + */ + void DemuxFlush(void); + + /*! + * @brief Read the stream from the demuxer + * @return An allocated demuxer packet + */ + DemuxPacket* ReadDemuxStream(void); + + /*! + * @brief Return the filesize of the currently running stream. + * Limited to recordings playback at the moment. + * @return The size of the stream. + */ + int64_t LengthStream(void); + + /*! + * @brief Seek to a position in a stream. + * Limited to recordings playback at the moment. + * @param iFilePosition The position to seek to. + * @param iWhence Specify how to seek ("new position=pos", "new position=pos+actual postion" or "new position=filesize-pos") + * @return The new stream position. + */ + int64_t SeekStream(int64_t iFilePosition, int iWhence = SEEK_SET); + + /*! + * @brief Get the currently playing position in a stream. + * @return The current position. + */ + int64_t GetStreamPosition(void); + + const CStdString GetClientName(int iClientId); + const CStdString GetStreamURL(const CPVRChannel &tag); + int GetSignalLevel(void) const; + int GetSNR(void) const; + bool HasClients(void) const; + bool HasTimerSupport(int iClientId); + bool IsEncrypted(void) const; + bool IsPlaying(void) const; + bool AllClientsLoaded(void) const; + bool IsReadingLiveStream(void) const; + const CStdString GetPlayingClientName(void) const { return m_strPlayingClientName; } + bool SwitchChannel(const CPVRChannel &channel); + + int GetTimers(CPVRTimers *timers); + bool AddTimer(const CPVRTimerInfoTag &timer, PVR_ERROR *error); + bool UpdateTimer(const CPVRTimerInfoTag &timer, PVR_ERROR *error); + bool DeleteTimer(const CPVRTimerInfoTag &timer, bool bForce, PVR_ERROR *error); + bool RenameTimer(const CPVRTimerInfoTag &timer, const CStdString &strNewName, PVR_ERROR *error); + + int GetRecordings(CPVRRecordings *recordings); + bool RenameRecording(const CPVRRecording &recording, PVR_ERROR *error); + bool DeleteRecording(const CPVRRecording &recording, PVR_ERROR *error); + + bool GetEPGForChannel(const CPVRChannel &channel, CPVREpg *epg, time_t start, time_t end, PVR_ERROR *error); + int GetChannelGroups(CPVRChannelGroups *groups, PVR_ERROR *error); + int GetChannelGroupMembers(CPVRChannelGroup *group, PVR_ERROR *error); + int GetChannels(CPVRChannelGroupInternal *group, PVR_ERROR *error); + + int GetClients(std::map *clients); + + /*! + * @brief Check whether a client has any PVR specific menu entries. + * @param iClientId The ID of the client to get the menu entries for. Get the menu for the active channel if iClientId < 0. + * @return True if the client has any menu hooks, false otherwise. + */ + bool HasMenuHooks(int iClientId); + + /*! + * @brief Open selection and progress PVR actions. + * @param iClientId The ID of the client to process the menu entries for. Process the menu entries for the active channel if iClientId < 0. + */ + void ProcessMenuHooks(int iClientID); + + /*! + * @brief Check whether the current channel can be recorded instantly. + * @return True if it can, false otherwise. + */ + bool CanRecordInstantly(void); + + /*! + * @return The amount of active clients. + */ + int ActiveClientAmount(void); + + /*! + * @brief Check whether there are any active clients. + * @return True if at least one client is active. + */ + bool HasActiveClients(void); + + /*! + * @brief Callback function from client to inform about changed timers, channels, recordings or epg. + * @param clientID The ID of the client that sends an update. + * @param clientEvent The event that just happened. + * @param strMessage The passed message. + */ + void OnClientMessage(const int iClientId, const PVR_EVENT clientEvent, const char* strMessage); + + /*! + * @brief Restart a single client add-on. + * @param addon The add-on to restart. + * @param bDataChanged True if the client's data changed, false otherwise (unused). + * @return True if the client was found and restarted, false otherwise. + */ + bool RequestRestart(ADDON::AddonPtr addon, bool bDataChanged); + + /*! + * @brief Remove a single client add-on. + * @param addon The add-on to remove. + * @return True if the client was found and removed, false otherwise. + */ + bool RequestRemoval(ADDON::AddonPtr addon); + + /*! + * @brief Check if a TV channel is playing. + * @return True if it's playing, false otherwise. + */ + bool IsPlayingTV(void) const; + + /*! + * @brief Check if a radio channel is playing. + * @return True if it's playing, false otherwise. + */ + bool IsPlayingRadio(void) const; + + /*! + * @brief Check if a recording is playing. + * @return True if it's playing, false otherwise. + */ + bool IsPlayingRecording(void) const; + + bool IsRunningChannelScan(void) const; + + /*! + * @brief Open a selection dialog and start a channel scan on the selected client. + */ + void StartChannelScan(void); + + /*! + * @brief Check whether a channel scan is running. + * @return True if it's running, false otherwise. + */ + bool ChannelScanRunning(void) { return m_bChannelScanRunning; } + + /*! + * @brief Get the properties of the current playing client. + * @return A pointer to the properties or NULL if no stream is playing. + */ + PVR_ADDON_CAPABILITIES*GetCurrentClientProperties(void); + + /*! + * @brief Get the ID of the client that is currently being used to play. + * @return The requested ID or -1 if no PVR item is currently being played. + */ + int GetCurrentPlayingClientID(void); + + /*! + * @brief Get the properties for a specific client. + * @param clientID The ID of the client. + * @return A pointer to the properties or NULL if no stream is playing. + */ + PVR_ADDON_CAPABILITIES *GetClientProperties(int iClientId) { return &m_clientsProps[iClientId]; } + + /*! + * @brief Get the properties of the current playing stream content. + * @return A pointer to the properties or NULL if no stream is playing. + */ + PVR_STREAM_PROPERTIES *GetCurrentStreamProperties(void); + + /*! + * @brief Get the input format name of the current playing stream content. + * @return A pointer to the properties or NULL if no stream is playing. + */ + CStdString GetCurrentInputFormat(void) const; + + /*! + * @brief Start an instant recording on the current channel. + * @param bOnOff Activate the recording if true, deactivate if false. + * @return True if the recording was started, false otherwise. + */ + bool StartRecordingOnPlayingChannel(bool bOnOff); + + /*! + * @brief Check whether there is an active recording on the current channel. + * @return True if there is, false otherwise. + */ + bool IsRecordingOnPlayingChannel(void) const; + + void Unload(void); + + bool GetPlayingChannel(CPVRChannel *channel) const; + bool GetPlayingRecording(CPVRRecording *recording) const; + int GetPlayingClientID(void) const; + bool IsValidClient(int iClientId); + bool ClientLoaded(const CStdString &strClientId); + + void GetQualityData(PVR_SIGNAL_STATUS *status) const; + + void Start(void); + void Stop(void); + + private: + int AddClientToDb(const CStdString &strClientId, const CStdString &strName); + int ReadLiveStream(void* lpBuf, int64_t uiBufSize); + int ReadRecordedStream(void* lpBuf, int64_t uiBufSize); + bool GetMenuHooks(int iClientID, PVR_MENUHOOKS *hooks); + + void UpdateCharInfoSignalStatus(void); + + /*! + * @brief Load and initialise all clients. + * @return True if any clients were loaded, false otherwise. + */ + bool LoadClients(void); + + /*! + * @brief Reset the signal quality data to the initial values. + */ + void ResetQualityData(void); + + /*! + * @brief Updates the backend information + */ + void Process(void); + + int GetActiveClients(CLIENTMAP *clients); + + const CPVRChannel * m_currentChannel; + const CPVRRecording * m_currentRecording; + CStdString m_strPlayingClientName; + bool m_bAllClientsLoaded; /*!< true if all clients are loaded, false otherwise */ + CCriticalSection m_critSection; + CLIENTMAP m_clientMap; + CLIENTPROPS m_clientsProps; /*!< store the properties of each client locally */ + PVR_SIGNAL_STATUS m_qualityInfo; /*!< stream quality information */ + bool m_bChannelScanRunning; /*!< true if a channel scan is currently running, false otherwise */ + STREAMPROPS m_streamProps; /*!< the current stream's properties */ + + DWORD m_scanStart; /* Scan start time to check for non present streams */ + }; +} diff --git a/xbmc/pvr/channels/PVRChannel.cpp b/xbmc/pvr/channels/PVRChannel.cpp index 9ba9fe5eeb8cb..c712d607ad0f0 100644 --- a/xbmc/pvr/channels/PVRChannel.cpp +++ b/xbmc/pvr/channels/PVRChannel.cpp @@ -38,6 +38,7 @@ using namespace XFILE; using namespace MUSIC_INFO; +using namespace PVR; bool CPVRChannel::operator==(const CPVRChannel& right) const { diff --git a/xbmc/pvr/channels/PVRChannel.h b/xbmc/pvr/channels/PVRChannel.h index 6086568e2f7cc..dad34818b9009 100644 --- a/xbmc/pvr/channels/PVRChannel.h +++ b/xbmc/pvr/channels/PVRChannel.h @@ -28,483 +28,486 @@ #include "utils/Observer.h" #include "threads/CriticalSection.h" -class CPVRChannelGroup; -class CPVRChannelGroupInternal; -class CPVRDatabase; -class CPVREpg; -class CPVREpgContainer; -class CPVRChannelIconCacheJob; - -/** PVR Channel class */ - -class CPVRChannel : public Observable, public IJobCallback -{ - friend class CPVRChannelGroup; - friend class CPVRChannelGroupInternal; - friend class CPVRDatabase; - friend class CPVREpgContainer; - friend class CPVREpg; - friend class CPVRChannelIconCacheJob; - -private: - /*! @name XBMC related channel data - */ - //@{ - int m_iChannelId; /*!< the identifier given to this channel by the TV database */ - bool m_bIsRadio; /*!< true if this channel is a radio channel, false if not */ - bool m_bIsHidden; /*!< true if this channel is hidden, false if not */ - CStdString m_strIconPath; /*!< the path to the icon for this channel */ - CStdString m_strChannelName; /*!< the name for this channel used by XBMC */ - bool m_bIsVirtual; /*!< true if this channel is marked as virtual, false if not */ - time_t m_iLastWatched; /*!< last time channel has been watched */ - bool m_bChanged; /*!< true if anything in this entry was changed that needs to be persisted */ - unsigned int m_iCachedChannelNumber; /*!< the cached channel number in the selected group */ - //@} - - /*! @name EPG related channel data - */ - //@{ - CPVREpg * m_EPG; /*!< the EPG table for this channel */ - bool m_bEPGEnabled; /*!< don't use an EPG for this channel if set to false */ - CStdString m_strEPGScraper; /*!< the name of the scraper to be used for this channel */ - //@} - - /*! @name Client related channel data - */ - //@{ - int m_iUniqueId; /*!< the unique identifier for this channel */ - int m_iClientId; /*!< the identifier of the client that serves this channel */ - int m_iClientChannelNumber; /*!< the channel number on the client */ - CStdString m_strClientChannelName; /*!< the name of this channel on the client */ - CStdString m_strInputFormat; /*!< the stream input type based on ffmpeg/libavformat/allformats.c */ - CStdString m_strStreamURL; /*!< URL of the stream. Use the client to read stream if this is empty */ - CStdString m_strFileNameAndPath; /*!< the filename to be used by PVRManager to open and read the stream */ - int m_iClientEncryptionSystem; /*!< the encryption system used by this channel. 0 for FreeToAir, -1 for unknown */ - CStdString m_strClientEncryptionName; /*!< the name of the encryption system used by this channel */ - //@} - - bool m_bIsCachingIcon; - CCriticalSection m_critSection; - -public: - /*! @brief Create a new channel */ - CPVRChannel(bool bRadio = false); - CPVRChannel(const PVR_CHANNEL &channel, unsigned int iClientId); - CPVRChannel(const CPVRChannel &channel); - - bool operator ==(const CPVRChannel &right) const; - bool operator !=(const CPVRChannel &right) const; - CPVRChannel &operator=(const CPVRChannel &channel); - - /*! @name XBMC related channel methods - */ - //@{ - - /*! - * @brief Delete this channel from the database and delete the corresponding EPG table if it exists. - * @return True if it was deleted successfully, false otherwise. - */ - bool Delete(void); - - /*! - * @brief Update this channel tag with the data of the given channel tag. - * @param channel The new channel data. - * @return True if something changed, false otherwise. - */ - bool UpdateFromClient(const CPVRChannel &channel); - - /*! - * @brief Persists the changes in the database. - * @param bQueueWrite Queue the change and write changes later. - * @return True if the changes were saved succesfully, false otherwise. - */ - bool Persist(bool bQueueWrite = false); - - /*! - * @brief The identifier given to this channel by the TV database. - * @return The identifier given to this channel by the TV database. - */ - int ChannelID(void) const { return m_iChannelId; } - - /*! - * @brief Set the identifier for this channel. - * @param iDatabaseId The new channel ID - * @param bSaveInDb Save in the database or not. - * @return True if the something changed, false otherwise. - */ - bool SetChannelID(int iDatabaseId, bool bSaveInDb = false); - - /*! - * @brief The channel number used by XBMC by the currently active group. - * @return The channel number used by XBMC. - */ - int ChannelNumber(void) const; - - /*! - * @brief True if this channel is a radio channel, false if not. - * @return True if this channel is a radio channel, false if not. - */ - bool IsRadio(void) const { return m_bIsRadio; } - - /*! - * @brief True if this channel is hidden. False if not. - * @return True if this channel is hidden. False if not. - */ - bool IsHidden(void) const { return m_bIsHidden; } - - /*! - * @brief Set to true to hide this channel. Set to false to unhide it. - * - * Set to true to hide this channel. Set to false to unhide it. - * The EPG of hidden channels won't be updated. - * @param bIsHidden The new setting. - * @param bSaveInDb Save in the database or not. - * @return True if the something changed, false otherwise. - */ - bool SetHidden(bool bIsHidden, bool bSaveInDb = false); - - /*! - * @brief True if a recording is currently running on this channel. False if not. - * @return True if a recording is currently running on this channel. False if not. - */ - bool IsRecording(void) const; - - /*! - * @brief The path to the icon for this channel. - * @return The path to the icon for this channel. - */ - const CStdString &IconPath(void) const { return m_strIconPath; } - - /*! - * @brief Set the path to the icon for this channel. - * @param strIconPath The new path. - * @param bSaveInDb Save in the database or not. - * @return True if the something changed, false otherwise. - */ - bool SetIconPath(const CStdString &strIconPath, bool bSaveInDb = false); - - /*! - * @brief The name for this channel used by XBMC. - * @return The name for this channel used by XBMC. - */ - const CStdString &ChannelName(void) const { return m_strChannelName; } - - /*! - * @brief Set the name for this channel used by XBMC. - * @param strChannelName The new channel name. - * @param bSaveInDb Save in the database or not. - * @return True if the something changed, false otherwise. - */ - bool SetChannelName(const CStdString &strChannelName, bool bSaveInDb = false); - - /*! - * @brief True if this channel is marked as virtual. False if not. - * @return True if this channel is marked as virtual. False if not. - */ - bool IsVirtual() const { return m_bIsVirtual; } - - /*! - * @brief True if this channel is marked as virtual. False if not. - * @param bIsVirtual The new value. - * @param bSaveInDb Save in the database or not. - * @return True if the something changed, false otherwise. - */ - bool SetVirtual(bool bIsVirtual, bool bSaveInDb = false); - - /*! - * @brief Last time channel has been watched. - * @return Time channel has been watched last. - */ - time_t LastWatched() const { return m_iLastWatched; } - - /*! - * @brief Last time channel has been watched - * @param iLastWatched The new value. - * @param bSaveInDb Save in the database or not. - * @return True if the something changed, false otherwise. - */ - bool SetLastWatched(time_t iLastWatched, bool bSaveInDb = false); - - /*! - * @brief True if this channel has no file or stream name - * @return True if this channel has no file or stream name - */ - bool IsEmpty() const; - - bool IsChanged() const { return m_bChanged; } - //@} - - /*! @name Client related channel methods - */ - //@{ - - /*! - * @brief A unique identifier for this channel. - * - * A unique identifier for this channel. - * It can be used to find the same channel on different providers - * - * @return The Unique ID. - */ - int UniqueID(void) const { return m_iUniqueId; } - - /*! - * @brief Change the unique identifier for this channel. - * @param iUniqueId The new unique ID. - * @param bSaveInDb Save in the database or not. - * @return True if the something changed, false otherwise. - */ - bool SetUniqueID(int iUniqueId, bool bSaveInDb = false); - - /*! - * @brief The identifier of the client that serves this channel. - * @return The identifier of the client that serves this channel. - */ - int ClientID(void) const { return m_iClientId; } - - /*! - * @brief Set the identifier of the client that serves this channel. - * @param iClientId The new ID. - * @param bSaveInDb Save in the database or not. - * @return True if the something changed, false otherwise. - */ - bool SetClientID(int iClientId, bool bSaveInDb = false); - - /*! - * @brief The channel number on the client. - * @return The channel number on the client. - */ - int ClientChannelNumber(void) const { return m_iClientChannelNumber; } - - /*! - * @brief Set the channel number on the client. - * - * Set the channel number on the client. - * It will only be changed in this tag and won't change anything on the client. - * - * @param iClientChannelNumber The new channel number - * @param bSaveInDb Save in the database or not. - * @return True if the something changed, false otherwise. - */ - bool SetClientChannelNumber(int iClientChannelNumber, bool bSaveInDb = false); - - /*! - * @brief The name of this channel on the client. - * @return The name of this channel on the client. - */ - const CStdString &ClientChannelName(void) const { return m_strClientChannelName; } - - /*! - * @brief Set the name of this channel on the client. - * - * Set the name of this channel on the client. - * It will only be changed in this tag and won't change anything on the client. - * - * @param strClientChannelName The new channel name - * @return True if the something changed, false otherwise. - */ - bool SetClientChannelName(const CStdString &strClientChannelName); - - /*! - * @brief The stream input type - * - * The stream input type - * If it is empty, ffmpeg will try to scan the stream to find the right input format. - * See "xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/allformats.c" for a - * list of the input formats. - * - * @return The stream input type - */ - const CStdString &InputFormat(void) const { return m_strInputFormat; } - - /*! - * @brief Set the stream input type - * @param strInputFormat The new input format. - * @param bSaveInDb Save in the database or not. - * @return True if the something changed, false otherwise. - */ - bool SetInputFormat(const CStdString &strInputFormat, bool bSaveInDb = false); - - /*! - * @brief The stream URL to access this channel. - * - * The stream URL to access this channel. - * If this is empty, then the client should be used to read from the channel. - * - * @return The stream URL to access this channel. - */ - const CStdString &StreamURL(void) const { return m_strStreamURL; } - - /*! - * @brief Set the stream URL to access this channel. - * - * Set the stream URL to access this channel. - * If this is empty, then the client should be used to read from the channel. - * - * @param strStreamURL The new stream URL. - * @param bSaveInDb Save in the database or not. - * @return True if the something changed, false otherwise. - */ - bool SetStreamURL(const CStdString &strStreamURL, bool bSaveInDb = false); - - /*! - * @brief The path in the XBMC VFS to be used by PVRManager to open and read the stream. - * @return The path in the XBMC VFS to be used by PVRManager to open and read the stream. - */ - const CStdString &Path(void) const { return m_strFileNameAndPath; } - -private: - /*! - * @brief Update the path after the channel number in the internal group changed. - */ - void UpdatePath(unsigned int iNewChannelNumber); - - /*! - * @brief Update the encryption name after SetEncryptionSystem() has been called. - */ - void UpdateEncryptionName(void); - - void SetCachedChannelNumber(unsigned int iChannelNumber); - bool CacheIcon(void); - bool CheckCachedIcon(void); - -public: - /*! - * @brief Return true if this channel is encrypted. - * - * Return true if this channel is encrypted. Does not inform whether XBMC can play the file. - * Decryption should be done by the client. - * - * @return Return true if this channel is encrypted. - */ - bool IsEncrypted(void) const { return m_iClientEncryptionSystem > 0; } - - - /*! - * @brief Return the encryption system ID for this channel. 0 for FTA. - * - * Return the encryption system ID for this channel. 0 for FTA. - * The values are documented on: http://www.dvb.org/index.php?id=174. - * - * @return Return the encryption system ID for this channel. - */ - int EncryptionSystem(void) const { return m_iClientEncryptionSystem; } - - /*! - * @brief Set the encryption ID (CAID) for this channel. - * @param iClientEncryptionSystem The new CAID. - * @param bSaveInDb Save in the database or not. - * @return True if the something changed, false otherwise. - */ - bool SetEncryptionSystem(int iClientEncryptionSystem, bool bSaveInDb = false); - - /*! - * @return A friendly name for the used encryption system. - */ - const CStdString &EncryptionName() const { return m_strClientEncryptionName; } - //@} - - /*! @name EPG methods - */ - //@{ - - /*! - * @brief Get the EPG table for this channel. - * - * Get the EPG table for this channel. - * Will be created if it doesn't exist. - * - * @return The EPG for this channel. - */ - CPVREpg *GetEPG(); - - /*! - * @brief Get the EPG table for this channel. - * - * Get the EPG table for this channel. - * Will be created if it doesn't exist. - * - * @param results The file list to store the results in. - * @return The number of tables that were added. - */ - int GetEPG(CFileItemList *results); - - /*! - * @brief Clear the EPG for this channel. - * @return True if it was cleared, false if not. - */ - bool ClearEPG(); - - /*! - * @brief Get the EPG tag that is active on this channel now. - * - * Get the EPG tag that is active on this channel now. - * Will return an empty tag if there is none. - * - * @return The EPG tag that is active on this channel now. - */ - CPVREpgInfoTag* GetEPGNow() const; - - /*! - * @brief Get the EPG tag that is active on this channel next. - * - * Get the EPG tag that is active on this channel next. - * Will return an empty tag if there is none. - * - * @return The EPG tag that is active on this channel next. - */ - CPVREpgInfoTag* GetEPGNext() const; - - /*! - * @brief Don't use an EPG for this channel if set to false. - * @return Don't use an EPG for this channel if set to false. - */ - bool EPGEnabled() const { return m_bEPGEnabled; } - - /*! - * @brief Set to true if an EPG should be used for this channel. Set to false otherwise. - * @param bEPGEnabled The new value. - * @param bSaveInDb Save in the database or not. - * @return True if the something changed, false otherwise. - */ - bool SetEPGEnabled(bool bEPGEnabled = true, bool bSaveInDb = false); - - /*! - * @brief Get the name of the scraper to be used for this channel. - * - * Get the name of the scraper to be used for this channel. - * The default is 'client', which means the EPG should be loaded from the backend. - * - * @return The name of the scraper to be used for this channel. - */ - const CStdString &EPGScraper(void) const { return m_strEPGScraper; } - - /*! - * @brief Set the name of the scraper to be used for this channel. - * - * Set the name of the scraper to be used for this channel. - * Set to "client" to load the EPG from the backend - * - * @param strScraper The new scraper name. - * @param bSaveInDb Save in the database or not. - * @return True if the something changed, false otherwise. - */ - bool SetEPGScraper(const CStdString &strScraper, bool bSaveInDb = false); - - //@} - - void OnJobComplete(unsigned int jobID, bool success, CJob* job); -}; - -class CPVRChannelIconCacheJob : public CJob +namespace PVR { -public: - CPVRChannelIconCacheJob(CPVRChannel *channel) { m_channel = channel; } - virtual ~CPVRChannelIconCacheJob() {} - virtual const char *GetType() const { return "pvr-channel-icon-update"; } - - virtual bool DoWork(); - -private: - CPVRChannel *m_channel; -}; + class CPVRChannelGroup; + class CPVRChannelGroupInternal; + class CPVRDatabase; + class CPVREpg; + class CPVREpgContainer; + class CPVRChannelIconCacheJob; + + /** PVR Channel class */ + + class CPVRChannel : public Observable, public IJobCallback + { + friend class CPVRChannelGroup; + friend class CPVRChannelGroupInternal; + friend class CPVRDatabase; + friend class CPVREpgContainer; + friend class CPVREpg; + friend class CPVRChannelIconCacheJob; + + private: + /*! @name XBMC related channel data + */ + //@{ + int m_iChannelId; /*!< the identifier given to this channel by the TV database */ + bool m_bIsRadio; /*!< true if this channel is a radio channel, false if not */ + bool m_bIsHidden; /*!< true if this channel is hidden, false if not */ + CStdString m_strIconPath; /*!< the path to the icon for this channel */ + CStdString m_strChannelName; /*!< the name for this channel used by XBMC */ + bool m_bIsVirtual; /*!< true if this channel is marked as virtual, false if not */ + time_t m_iLastWatched; /*!< last time channel has been watched */ + bool m_bChanged; /*!< true if anything in this entry was changed that needs to be persisted */ + unsigned int m_iCachedChannelNumber; /*!< the cached channel number in the selected group */ + //@} + + /*! @name EPG related channel data + */ + //@{ + CPVREpg * m_EPG; /*!< the EPG table for this channel */ + bool m_bEPGEnabled; /*!< don't use an EPG for this channel if set to false */ + CStdString m_strEPGScraper; /*!< the name of the scraper to be used for this channel */ + //@} + + /*! @name Client related channel data + */ + //@{ + int m_iUniqueId; /*!< the unique identifier for this channel */ + int m_iClientId; /*!< the identifier of the client that serves this channel */ + int m_iClientChannelNumber; /*!< the channel number on the client */ + CStdString m_strClientChannelName; /*!< the name of this channel on the client */ + CStdString m_strInputFormat; /*!< the stream input type based on ffmpeg/libavformat/allformats.c */ + CStdString m_strStreamURL; /*!< URL of the stream. Use the client to read stream if this is empty */ + CStdString m_strFileNameAndPath; /*!< the filename to be used by PVRManager to open and read the stream */ + int m_iClientEncryptionSystem; /*!< the encryption system used by this channel. 0 for FreeToAir, -1 for unknown */ + CStdString m_strClientEncryptionName; /*!< the name of the encryption system used by this channel */ + //@} + + bool m_bIsCachingIcon; + CCriticalSection m_critSection; + + public: + /*! @brief Create a new channel */ + CPVRChannel(bool bRadio = false); + CPVRChannel(const PVR_CHANNEL &channel, unsigned int iClientId); + CPVRChannel(const CPVRChannel &channel); + + bool operator ==(const CPVRChannel &right) const; + bool operator !=(const CPVRChannel &right) const; + CPVRChannel &operator=(const CPVRChannel &channel); + + /*! @name XBMC related channel methods + */ + //@{ + + /*! + * @brief Delete this channel from the database and delete the corresponding EPG table if it exists. + * @return True if it was deleted successfully, false otherwise. + */ + bool Delete(void); + + /*! + * @brief Update this channel tag with the data of the given channel tag. + * @param channel The new channel data. + * @return True if something changed, false otherwise. + */ + bool UpdateFromClient(const CPVRChannel &channel); + + /*! + * @brief Persists the changes in the database. + * @param bQueueWrite Queue the change and write changes later. + * @return True if the changes were saved succesfully, false otherwise. + */ + bool Persist(bool bQueueWrite = false); + + /*! + * @brief The identifier given to this channel by the TV database. + * @return The identifier given to this channel by the TV database. + */ + int ChannelID(void) const { return m_iChannelId; } + + /*! + * @brief Set the identifier for this channel. + * @param iDatabaseId The new channel ID + * @param bSaveInDb Save in the database or not. + * @return True if the something changed, false otherwise. + */ + bool SetChannelID(int iDatabaseId, bool bSaveInDb = false); + + /*! + * @brief The channel number used by XBMC by the currently active group. + * @return The channel number used by XBMC. + */ + int ChannelNumber(void) const; + + /*! + * @brief True if this channel is a radio channel, false if not. + * @return True if this channel is a radio channel, false if not. + */ + bool IsRadio(void) const { return m_bIsRadio; } + + /*! + * @brief True if this channel is hidden. False if not. + * @return True if this channel is hidden. False if not. + */ + bool IsHidden(void) const { return m_bIsHidden; } + + /*! + * @brief Set to true to hide this channel. Set to false to unhide it. + * + * Set to true to hide this channel. Set to false to unhide it. + * The EPG of hidden channels won't be updated. + * @param bIsHidden The new setting. + * @param bSaveInDb Save in the database or not. + * @return True if the something changed, false otherwise. + */ + bool SetHidden(bool bIsHidden, bool bSaveInDb = false); + + /*! + * @brief True if a recording is currently running on this channel. False if not. + * @return True if a recording is currently running on this channel. False if not. + */ + bool IsRecording(void) const; + + /*! + * @brief The path to the icon for this channel. + * @return The path to the icon for this channel. + */ + const CStdString &IconPath(void) const { return m_strIconPath; } + + /*! + * @brief Set the path to the icon for this channel. + * @param strIconPath The new path. + * @param bSaveInDb Save in the database or not. + * @return True if the something changed, false otherwise. + */ + bool SetIconPath(const CStdString &strIconPath, bool bSaveInDb = false); + + /*! + * @brief The name for this channel used by XBMC. + * @return The name for this channel used by XBMC. + */ + const CStdString &ChannelName(void) const { return m_strChannelName; } + + /*! + * @brief Set the name for this channel used by XBMC. + * @param strChannelName The new channel name. + * @param bSaveInDb Save in the database or not. + * @return True if the something changed, false otherwise. + */ + bool SetChannelName(const CStdString &strChannelName, bool bSaveInDb = false); + + /*! + * @brief True if this channel is marked as virtual. False if not. + * @return True if this channel is marked as virtual. False if not. + */ + bool IsVirtual() const { return m_bIsVirtual; } + + /*! + * @brief True if this channel is marked as virtual. False if not. + * @param bIsVirtual The new value. + * @param bSaveInDb Save in the database or not. + * @return True if the something changed, false otherwise. + */ + bool SetVirtual(bool bIsVirtual, bool bSaveInDb = false); + + /*! + * @brief Last time channel has been watched. + * @return Time channel has been watched last. + */ + time_t LastWatched() const { return m_iLastWatched; } + + /*! + * @brief Last time channel has been watched + * @param iLastWatched The new value. + * @param bSaveInDb Save in the database or not. + * @return True if the something changed, false otherwise. + */ + bool SetLastWatched(time_t iLastWatched, bool bSaveInDb = false); + + /*! + * @brief True if this channel has no file or stream name + * @return True if this channel has no file or stream name + */ + bool IsEmpty() const; + + bool IsChanged() const { return m_bChanged; } + //@} + + /*! @name Client related channel methods + */ + //@{ + + /*! + * @brief A unique identifier for this channel. + * + * A unique identifier for this channel. + * It can be used to find the same channel on different providers + * + * @return The Unique ID. + */ + int UniqueID(void) const { return m_iUniqueId; } + + /*! + * @brief Change the unique identifier for this channel. + * @param iUniqueId The new unique ID. + * @param bSaveInDb Save in the database or not. + * @return True if the something changed, false otherwise. + */ + bool SetUniqueID(int iUniqueId, bool bSaveInDb = false); + + /*! + * @brief The identifier of the client that serves this channel. + * @return The identifier of the client that serves this channel. + */ + int ClientID(void) const { return m_iClientId; } + + /*! + * @brief Set the identifier of the client that serves this channel. + * @param iClientId The new ID. + * @param bSaveInDb Save in the database or not. + * @return True if the something changed, false otherwise. + */ + bool SetClientID(int iClientId, bool bSaveInDb = false); + + /*! + * @brief The channel number on the client. + * @return The channel number on the client. + */ + int ClientChannelNumber(void) const { return m_iClientChannelNumber; } + + /*! + * @brief Set the channel number on the client. + * + * Set the channel number on the client. + * It will only be changed in this tag and won't change anything on the client. + * + * @param iClientChannelNumber The new channel number + * @param bSaveInDb Save in the database or not. + * @return True if the something changed, false otherwise. + */ + bool SetClientChannelNumber(int iClientChannelNumber, bool bSaveInDb = false); + + /*! + * @brief The name of this channel on the client. + * @return The name of this channel on the client. + */ + const CStdString &ClientChannelName(void) const { return m_strClientChannelName; } + + /*! + * @brief Set the name of this channel on the client. + * + * Set the name of this channel on the client. + * It will only be changed in this tag and won't change anything on the client. + * + * @param strClientChannelName The new channel name + * @return True if the something changed, false otherwise. + */ + bool SetClientChannelName(const CStdString &strClientChannelName); + + /*! + * @brief The stream input type + * + * The stream input type + * If it is empty, ffmpeg will try to scan the stream to find the right input format. + * See "xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/allformats.c" for a + * list of the input formats. + * + * @return The stream input type + */ + const CStdString &InputFormat(void) const { return m_strInputFormat; } + + /*! + * @brief Set the stream input type + * @param strInputFormat The new input format. + * @param bSaveInDb Save in the database or not. + * @return True if the something changed, false otherwise. + */ + bool SetInputFormat(const CStdString &strInputFormat, bool bSaveInDb = false); + + /*! + * @brief The stream URL to access this channel. + * + * The stream URL to access this channel. + * If this is empty, then the client should be used to read from the channel. + * + * @return The stream URL to access this channel. + */ + const CStdString &StreamURL(void) const { return m_strStreamURL; } + + /*! + * @brief Set the stream URL to access this channel. + * + * Set the stream URL to access this channel. + * If this is empty, then the client should be used to read from the channel. + * + * @param strStreamURL The new stream URL. + * @param bSaveInDb Save in the database or not. + * @return True if the something changed, false otherwise. + */ + bool SetStreamURL(const CStdString &strStreamURL, bool bSaveInDb = false); + + /*! + * @brief The path in the XBMC VFS to be used by PVRManager to open and read the stream. + * @return The path in the XBMC VFS to be used by PVRManager to open and read the stream. + */ + const CStdString &Path(void) const { return m_strFileNameAndPath; } + + private: + /*! + * @brief Update the path after the channel number in the internal group changed. + */ + void UpdatePath(unsigned int iNewChannelNumber); + + /*! + * @brief Update the encryption name after SetEncryptionSystem() has been called. + */ + void UpdateEncryptionName(void); + + void SetCachedChannelNumber(unsigned int iChannelNumber); + bool CacheIcon(void); + bool CheckCachedIcon(void); + + public: + /*! + * @brief Return true if this channel is encrypted. + * + * Return true if this channel is encrypted. Does not inform whether XBMC can play the file. + * Decryption should be done by the client. + * + * @return Return true if this channel is encrypted. + */ + bool IsEncrypted(void) const { return m_iClientEncryptionSystem > 0; } + + + /*! + * @brief Return the encryption system ID for this channel. 0 for FTA. + * + * Return the encryption system ID for this channel. 0 for FTA. + * The values are documented on: http://www.dvb.org/index.php?id=174. + * + * @return Return the encryption system ID for this channel. + */ + int EncryptionSystem(void) const { return m_iClientEncryptionSystem; } + + /*! + * @brief Set the encryption ID (CAID) for this channel. + * @param iClientEncryptionSystem The new CAID. + * @param bSaveInDb Save in the database or not. + * @return True if the something changed, false otherwise. + */ + bool SetEncryptionSystem(int iClientEncryptionSystem, bool bSaveInDb = false); + + /*! + * @return A friendly name for the used encryption system. + */ + const CStdString &EncryptionName() const { return m_strClientEncryptionName; } + //@} + + /*! @name EPG methods + */ + //@{ + + /*! + * @brief Get the EPG table for this channel. + * + * Get the EPG table for this channel. + * Will be created if it doesn't exist. + * + * @return The EPG for this channel. + */ + CPVREpg *GetEPG(); + + /*! + * @brief Get the EPG table for this channel. + * + * Get the EPG table for this channel. + * Will be created if it doesn't exist. + * + * @param results The file list to store the results in. + * @return The number of tables that were added. + */ + int GetEPG(CFileItemList *results); + + /*! + * @brief Clear the EPG for this channel. + * @return True if it was cleared, false if not. + */ + bool ClearEPG(); + + /*! + * @brief Get the EPG tag that is active on this channel now. + * + * Get the EPG tag that is active on this channel now. + * Will return an empty tag if there is none. + * + * @return The EPG tag that is active on this channel now. + */ + CPVREpgInfoTag* GetEPGNow() const; + + /*! + * @brief Get the EPG tag that is active on this channel next. + * + * Get the EPG tag that is active on this channel next. + * Will return an empty tag if there is none. + * + * @return The EPG tag that is active on this channel next. + */ + CPVREpgInfoTag* GetEPGNext() const; + + /*! + * @brief Don't use an EPG for this channel if set to false. + * @return Don't use an EPG for this channel if set to false. + */ + bool EPGEnabled() const { return m_bEPGEnabled; } + + /*! + * @brief Set to true if an EPG should be used for this channel. Set to false otherwise. + * @param bEPGEnabled The new value. + * @param bSaveInDb Save in the database or not. + * @return True if the something changed, false otherwise. + */ + bool SetEPGEnabled(bool bEPGEnabled = true, bool bSaveInDb = false); + + /*! + * @brief Get the name of the scraper to be used for this channel. + * + * Get the name of the scraper to be used for this channel. + * The default is 'client', which means the EPG should be loaded from the backend. + * + * @return The name of the scraper to be used for this channel. + */ + const CStdString &EPGScraper(void) const { return m_strEPGScraper; } + + /*! + * @brief Set the name of the scraper to be used for this channel. + * + * Set the name of the scraper to be used for this channel. + * Set to "client" to load the EPG from the backend + * + * @param strScraper The new scraper name. + * @param bSaveInDb Save in the database or not. + * @return True if the something changed, false otherwise. + */ + bool SetEPGScraper(const CStdString &strScraper, bool bSaveInDb = false); + + //@} + + void OnJobComplete(unsigned int jobID, bool success, CJob* job); + }; + + class CPVRChannelIconCacheJob : public CJob + { + public: + CPVRChannelIconCacheJob(CPVRChannel *channel) { m_channel = channel; } + virtual ~CPVRChannelIconCacheJob() {} + virtual const char *GetType() const { return "pvr-channel-icon-update"; } + + virtual bool DoWork(); + + private: + CPVRChannel *m_channel; + }; +} diff --git a/xbmc/pvr/channels/PVRChannelGroup.cpp b/xbmc/pvr/channels/PVRChannelGroup.cpp index 00d8b4f61f402..7ecbdfe194856 100644 --- a/xbmc/pvr/channels/PVRChannelGroup.cpp +++ b/xbmc/pvr/channels/PVRChannelGroup.cpp @@ -38,6 +38,8 @@ #include "pvr/addons/PVRClients.h" #include "pvr/epg/PVREpgContainer.h" +using namespace PVR; + CPVRChannelGroup::CPVRChannelGroup(bool bRadio, unsigned int iGroupId, const CStdString &strGroupName, int iSortOrder) { m_bRadio = bRadio; diff --git a/xbmc/pvr/channels/PVRChannelGroup.h b/xbmc/pvr/channels/PVRChannelGroup.h index cdf9a7d0b4e63..3884ae92ffd00 100644 --- a/xbmc/pvr/channels/PVRChannelGroup.h +++ b/xbmc/pvr/channels/PVRChannelGroup.h @@ -24,353 +24,356 @@ #include "FileItem.h" #include "PVRChannel.h" +namespace PVR +{ #define XBMC_INTERNAL_GROUP_RADIO 1 #define XBMC_INTERNAL_GROUP_TV 2 -class CPVRChannelGroups; -class CPVRChannelGroupInternal; - -typedef struct { - CPVRChannel *channel; - unsigned int iChannelNumber; -} PVRChannelGroupMember; - -/** A group of channels */ - -class CPVRChannelGroup : private std::vector -{ - friend class CPVRChannelGroups; - friend class CPVRChannelGroupInternal; - friend class CPVRDatabase; - -private: - bool m_bRadio; /*!< true if this container holds radio channels, false if it holds TV channels */ - int m_iGroupId; /*!< The ID of this group in the database */ - CStdString m_strGroupName; /*!< The name of this group */ - int m_iSortOrder; /*!< The sort order to use */ - bool m_bLoaded; /*!< True if this container is loaded, false otherwise */ - bool m_bChanged; /*!< true if anything changed in this group that hasn't been persisted, false otherwise */ - CCriticalSection m_critSection; - - /*! - * @brief Load the channels stored in the database. - * @param bCompress If true, compress the database after storing the channels. - * @return The amount of channels that were added. - */ - virtual int LoadFromDb(bool bCompress = false); - - /*! - * @brief Update the current channel list with the given list. - * - * Update the current channel list with the given list. - * Only the new channels will be present in the passed list after this call. - * - * @param channels The channels to use to update this list. - * @return True if everything went well, false otherwise. - */ - virtual bool UpdateGroupEntries(const CPVRChannelGroup &channels); - - /*! - * @brief Remove invalid channels from this container. - */ - virtual void RemoveInvalidChannels(void); - - /*! - * @brief Load the channels from the database. - * @return The amount of channels that were added or -1 if an error occured. - */ - virtual int Load(void); - - /*! - * @brief Clear this channel list. - */ - virtual void Unload(void); - - /*! - * @brief Remove a channel. - * @param iUniqueID The ID of the channel to delete. - * @return True if the channel was found and removed, false otherwise. - */ - bool RemoveByUniqueID(int iUniqueID); - - /*! - * @brief Load the channels from the clients. - * @return The amount of channels that were added. - */ - virtual int LoadFromClients(void); - - /*! - * @brief Remove invalid channels and updates the channel numbers. - */ - void Renumber(void); - - /*! - * @return Cache all channel icons in this group if guisetting "pvrmenu.iconpath" is set. - */ - void CacheIcons(void); - -public: - /*! - * @brief Create a new channel group instance. - * @param bRadio True if this group holds radio channels. - * @param iGroupId The database ID of this group. - * @param strGroupName The name of this group. - * @param iSortOrder The sort order to use. - */ - CPVRChannelGroup(bool bRadio, unsigned int iGroupId, const CStdString &strGroupName, int iSortOrder); - - /*! - * @brief Create a new channel group. - * @param bRadio True if this group holds radio channels. - */ - CPVRChannelGroup(bool bRadio); - - /*! - * @brief Create a new channel group instance from a channel group provided by an add-on. - * @param group The channel group provided by the add-on. - */ - CPVRChannelGroup(const PVR_CHANNEL_GROUP &group); - - /*! - * @brief Destruct this channel group. - */ - virtual ~CPVRChannelGroup(void); - - virtual bool operator ==(const CPVRChannelGroup &right) const; - virtual bool operator !=(const CPVRChannelGroup &right) const; - - /*! - * @brief Refresh the channel list from the clients. - */ - virtual bool Update(void); - - /*! - * @brief Update the information in this group with the passed group's info. - * @param group The new info. - * @return True if this group was updated, false otherwise. - */ - virtual bool Update(const CPVRChannelGroup &group); - - /*! - * @brief Move a channel from position iOldIndex to iNewIndex. - * @param iOldChannelNumber The channel number of the channel to move. - * @param iNewChannelNumber The new channel number. - * @param bSaveInDb If true, save this change in the database. - * @return True if the channel was moved successfully, false otherwise. - */ - virtual bool MoveChannel(unsigned int iOldChannelNumber, unsigned int iNewChannelNumber, bool bSaveInDb = true); - - /*! - * @brief Search missing channel icons for all known channels. - * @param bUpdateDb If true, update the changed values in the database. - */ - virtual void SearchAndSetChannelIcons(bool bUpdateDb = false); - - /*! - * @brief Remove a channel from this container. - * @param channel The channel to remove. - * @return True if the channel was found and removed, false otherwise. - */ - virtual bool RemoveFromGroup(CPVRChannel *channel); - - /*! - * @brief Add a channel to this container. - * @param channel The channel to add. - * @param iChannelNumber The channel number of the channel number to add. Use -1 to add it at the end. - * @param bSortAndRenumber Set to false to keep the channel list unsorted after adding a new channel. - * @return True if the channel was added, false otherwise. - */ - virtual bool AddToGroup(CPVRChannel *channel, int iChannelNumber = 0, bool bSortAndRenumber = true); - - /*! - * @brief Change the name of this group. - * @param strGroupName The new group name. - * @param bSaveInDb Save in the database or not. - * @return True if the something changed, false otherwise. - */ - virtual bool SetGroupName(const CStdString &strGroupName, bool bSaveInDb = false); - - /*! - * @brief Persist changed or new data. - * @return True if the channel was persisted, false otherwise. - */ - virtual bool Persist(void); - - /*! - * @brief Check whether a channel is in this container. - * @param channel The channel to find. - * @return True if the channel was found, false otherwise. - */ - virtual bool IsGroupMember(const CPVRChannel *channel) const; - - /*! - * @brief Check if this group is the internal group containing all channels. - * @return True if it's the internal group, false otherwise. - */ - virtual bool IsInternalGroup(void) const { return false; } - - /*! - * @brief Get the first channel in this group. - * @return The first channel. - */ - virtual const CPVRChannel *GetFirstChannel(void) const; - - /*! - * @brief True if this group holds radio channels, false if it holds TV channels. - * @return True if this group holds radio channels, false if it holds TV channels. - */ - virtual bool IsRadio(void) const { return m_bRadio; } - - /*! - * @brief The database ID of this group. - * @return The database ID of this group. - */ - virtual int GroupID(void) const { return m_iGroupId; } - - /*! - * @brief Set the database ID of this group. - * @param iGroupId The new database ID. - */ - virtual void SetGroupID(int iGroupId) { m_iGroupId = iGroupId; } - - /*! - * @brief The name of this group. - * @return The name of this group. - */ - virtual const CStdString &GroupName(void) const { return m_strGroupName; } - - /*! - * @brief The sort order of this group. - * @return The sort order of this group. - */ - virtual int SortOrder(void) const { return m_iSortOrder; } - - /*! - * @brief Change the sort order of this group. - * @param iSortOrder The new sort order of this group. - */ - virtual void SetSortOrder(int iSortOrder) { m_iSortOrder = iSortOrder; } - - /*! @name Sort methods - */ - //@{ - - /*! - * @brief Sort the current channel list by client channel number. - */ - virtual void SortByClientChannelNumber(void); - - /*! - * @brief Sort the current channel list by channel number. - */ - virtual void SortByChannelNumber(void); - - //@} - - virtual void SetSelectedGroup(void); - virtual void ResetChannelNumbers(void); - - /*! @name getters - */ - //@{ - - /*! - * @brief Get a channel given the channel number on the client. - * @param iUniqueChannelId The unique channel id on the client. - * @param iClientID The ID of the client. - * @return The channel or NULL if it wasn't found. - */ - virtual const CPVRChannel *GetByClient(int iUniqueChannelId, int iClientID) const; - - /*! - * @brief Get a channel given it's channel ID. - * @param iChannelID The channel ID. - * @return The channel or NULL if it wasn't found. - */ - virtual const CPVRChannel *GetByChannelID(int iChannelID) const; - - /*! - * @brief Get a channel given it's unique ID. - * @param iUniqueID The unique ID. - * @return The channel or NULL if it wasn't found. - */ - virtual const CPVRChannel *GetByUniqueID(int iUniqueID) const; - - /*! - * @brief The channel that was played last that has a valid client or NULL if there was none. - * @return The requested channel. - */ - virtual const CPVRChannel *GetLastPlayedChannel(void) const; - - /*! - * @brief Get a channel given it's channel number. - * @param iChannelNumber The channel number. - * @return The channel or NULL if it wasn't found. - */ - virtual const CPVRChannel *GetByChannelNumber(unsigned int iChannelNumber) const; - - /*! - * @brief Get the channel number in this group of the given channel. - * @param channel The channel to get the channel number for. - * @return The channel number in this group or 0 if the channel isn't a member of this group. - */ - virtual unsigned int GetChannelNumber(const CPVRChannel &channel) const; - - /*! - * @brief Get the next channel in this group. - * @param channel The current channel. - * @return The channel or NULL if it wasn't found. - */ - virtual const CPVRChannel *GetByChannelUp(const CPVRChannel &channel) const; - - /*! - * @brief Get the previous channel in this group. - * @param channel The current channel. - * @return The channel or NULL if it wasn't found. - */ - virtual const CPVRChannel *GetByChannelDown(const CPVRChannel &channel) const; - - /*! - * @brief Get a channel given it's index in this container. - * @param index The index in this container. - * @return The channel or NULL if it wasn't found. - */ - virtual const CPVRChannel *GetByIndex(unsigned int index) const; - - /*! - * @brief Get the list of channels in a group. - * @param results The file list to store the results in. - * @param bGroupMembers If true, get the channels that are in this group. Get the channels that are not in this group otherwise. - * @return The amount of channels that were added to the list. - */ - virtual int GetMembers(CFileItemList *results, bool bGroupMembers = true) const; - - /*! - * @brief The amount of channels in this container. - * @return The amount of channels in this container. - */ - virtual int GetNumChannels(void) const { return size(); } - - /*! - * @brief The amount of hidden channels in this container. - * @return The amount of hidden channels in this container. - */ - virtual int GetNumHiddenChannels(void) const { return 0; } - - /*! - * @return True if there is at least one channel in this group with changes that haven't been persisted, false otherwise. - */ - virtual bool HasChangedChannels(void) const; - - /*! - * @return True if there is at least one new channel in this group that hasn't been persisted, false otherwise. - */ - virtual bool HasNewChannels(void) const; - - /*! - * @return True if anything changed in this group that hasn't been persisted, false otherwise. - */ - virtual bool HasChanges(void) const; - - //@} -}; + class CPVRChannelGroups; + class CPVRChannelGroupInternal; + + typedef struct { + CPVRChannel *channel; + unsigned int iChannelNumber; + } PVRChannelGroupMember; + + /** A group of channels */ + + class CPVRChannelGroup : private std::vector + { + friend class CPVRChannelGroups; + friend class CPVRChannelGroupInternal; + friend class CPVRDatabase; + + private: + bool m_bRadio; /*!< true if this container holds radio channels, false if it holds TV channels */ + int m_iGroupId; /*!< The ID of this group in the database */ + CStdString m_strGroupName; /*!< The name of this group */ + int m_iSortOrder; /*!< The sort order to use */ + bool m_bLoaded; /*!< True if this container is loaded, false otherwise */ + bool m_bChanged; /*!< true if anything changed in this group that hasn't been persisted, false otherwise */ + CCriticalSection m_critSection; + + /*! + * @brief Load the channels stored in the database. + * @param bCompress If true, compress the database after storing the channels. + * @return The amount of channels that were added. + */ + virtual int LoadFromDb(bool bCompress = false); + + /*! + * @brief Update the current channel list with the given list. + * + * Update the current channel list with the given list. + * Only the new channels will be present in the passed list after this call. + * + * @param channels The channels to use to update this list. + * @return True if everything went well, false otherwise. + */ + virtual bool UpdateGroupEntries(const CPVRChannelGroup &channels); + + /*! + * @brief Remove invalid channels from this container. + */ + virtual void RemoveInvalidChannels(void); + + /*! + * @brief Load the channels from the database. + * @return The amount of channels that were added or -1 if an error occured. + */ + virtual int Load(void); + + /*! + * @brief Clear this channel list. + */ + virtual void Unload(void); + + /*! + * @brief Remove a channel. + * @param iUniqueID The ID of the channel to delete. + * @return True if the channel was found and removed, false otherwise. + */ + bool RemoveByUniqueID(int iUniqueID); + + /*! + * @brief Load the channels from the clients. + * @return The amount of channels that were added. + */ + virtual int LoadFromClients(void); + + /*! + * @brief Remove invalid channels and updates the channel numbers. + */ + void Renumber(void); + + /*! + * @return Cache all channel icons in this group if guisetting "pvrmenu.iconpath" is set. + */ + void CacheIcons(void); + + public: + /*! + * @brief Create a new channel group instance. + * @param bRadio True if this group holds radio channels. + * @param iGroupId The database ID of this group. + * @param strGroupName The name of this group. + * @param iSortOrder The sort order to use. + */ + CPVRChannelGroup(bool bRadio, unsigned int iGroupId, const CStdString &strGroupName, int iSortOrder); + + /*! + * @brief Create a new channel group. + * @param bRadio True if this group holds radio channels. + */ + CPVRChannelGroup(bool bRadio); + + /*! + * @brief Create a new channel group instance from a channel group provided by an add-on. + * @param group The channel group provided by the add-on. + */ + CPVRChannelGroup(const PVR_CHANNEL_GROUP &group); + + /*! + * @brief Destruct this channel group. + */ + virtual ~CPVRChannelGroup(void); + + virtual bool operator ==(const CPVRChannelGroup &right) const; + virtual bool operator !=(const CPVRChannelGroup &right) const; + + /*! + * @brief Refresh the channel list from the clients. + */ + virtual bool Update(void); + + /*! + * @brief Update the information in this group with the passed group's info. + * @param group The new info. + * @return True if this group was updated, false otherwise. + */ + virtual bool Update(const CPVRChannelGroup &group); + + /*! + * @brief Move a channel from position iOldIndex to iNewIndex. + * @param iOldChannelNumber The channel number of the channel to move. + * @param iNewChannelNumber The new channel number. + * @param bSaveInDb If true, save this change in the database. + * @return True if the channel was moved successfully, false otherwise. + */ + virtual bool MoveChannel(unsigned int iOldChannelNumber, unsigned int iNewChannelNumber, bool bSaveInDb = true); + + /*! + * @brief Search missing channel icons for all known channels. + * @param bUpdateDb If true, update the changed values in the database. + */ + virtual void SearchAndSetChannelIcons(bool bUpdateDb = false); + + /*! + * @brief Remove a channel from this container. + * @param channel The channel to remove. + * @return True if the channel was found and removed, false otherwise. + */ + virtual bool RemoveFromGroup(CPVRChannel *channel); + + /*! + * @brief Add a channel to this container. + * @param channel The channel to add. + * @param iChannelNumber The channel number of the channel number to add. Use -1 to add it at the end. + * @param bSortAndRenumber Set to false to keep the channel list unsorted after adding a new channel. + * @return True if the channel was added, false otherwise. + */ + virtual bool AddToGroup(CPVRChannel *channel, int iChannelNumber = 0, bool bSortAndRenumber = true); + + /*! + * @brief Change the name of this group. + * @param strGroupName The new group name. + * @param bSaveInDb Save in the database or not. + * @return True if the something changed, false otherwise. + */ + virtual bool SetGroupName(const CStdString &strGroupName, bool bSaveInDb = false); + + /*! + * @brief Persist changed or new data. + * @return True if the channel was persisted, false otherwise. + */ + virtual bool Persist(void); + + /*! + * @brief Check whether a channel is in this container. + * @param channel The channel to find. + * @return True if the channel was found, false otherwise. + */ + virtual bool IsGroupMember(const CPVRChannel *channel) const; + + /*! + * @brief Check if this group is the internal group containing all channels. + * @return True if it's the internal group, false otherwise. + */ + virtual bool IsInternalGroup(void) const { return false; } + + /*! + * @brief Get the first channel in this group. + * @return The first channel. + */ + virtual const CPVRChannel *GetFirstChannel(void) const; + + /*! + * @brief True if this group holds radio channels, false if it holds TV channels. + * @return True if this group holds radio channels, false if it holds TV channels. + */ + virtual bool IsRadio(void) const { return m_bRadio; } + + /*! + * @brief The database ID of this group. + * @return The database ID of this group. + */ + virtual int GroupID(void) const { return m_iGroupId; } + + /*! + * @brief Set the database ID of this group. + * @param iGroupId The new database ID. + */ + virtual void SetGroupID(int iGroupId) { m_iGroupId = iGroupId; } + + /*! + * @brief The name of this group. + * @return The name of this group. + */ + virtual const CStdString &GroupName(void) const { return m_strGroupName; } + + /*! + * @brief The sort order of this group. + * @return The sort order of this group. + */ + virtual int SortOrder(void) const { return m_iSortOrder; } + + /*! + * @brief Change the sort order of this group. + * @param iSortOrder The new sort order of this group. + */ + virtual void SetSortOrder(int iSortOrder) { m_iSortOrder = iSortOrder; } + + /*! @name Sort methods + */ + //@{ + + /*! + * @brief Sort the current channel list by client channel number. + */ + virtual void SortByClientChannelNumber(void); + + /*! + * @brief Sort the current channel list by channel number. + */ + virtual void SortByChannelNumber(void); + + //@} + + virtual void SetSelectedGroup(void); + virtual void ResetChannelNumbers(void); + + /*! @name getters + */ + //@{ + + /*! + * @brief Get a channel given the channel number on the client. + * @param iUniqueChannelId The unique channel id on the client. + * @param iClientID The ID of the client. + * @return The channel or NULL if it wasn't found. + */ + virtual const CPVRChannel *GetByClient(int iUniqueChannelId, int iClientID) const; + + /*! + * @brief Get a channel given it's channel ID. + * @param iChannelID The channel ID. + * @return The channel or NULL if it wasn't found. + */ + virtual const CPVRChannel *GetByChannelID(int iChannelID) const; + + /*! + * @brief Get a channel given it's unique ID. + * @param iUniqueID The unique ID. + * @return The channel or NULL if it wasn't found. + */ + virtual const CPVRChannel *GetByUniqueID(int iUniqueID) const; + + /*! + * @brief The channel that was played last that has a valid client or NULL if there was none. + * @return The requested channel. + */ + virtual const CPVRChannel *GetLastPlayedChannel(void) const; + + /*! + * @brief Get a channel given it's channel number. + * @param iChannelNumber The channel number. + * @return The channel or NULL if it wasn't found. + */ + virtual const CPVRChannel *GetByChannelNumber(unsigned int iChannelNumber) const; + + /*! + * @brief Get the channel number in this group of the given channel. + * @param channel The channel to get the channel number for. + * @return The channel number in this group or 0 if the channel isn't a member of this group. + */ + virtual unsigned int GetChannelNumber(const CPVRChannel &channel) const; + + /*! + * @brief Get the next channel in this group. + * @param channel The current channel. + * @return The channel or NULL if it wasn't found. + */ + virtual const CPVRChannel *GetByChannelUp(const CPVRChannel &channel) const; + + /*! + * @brief Get the previous channel in this group. + * @param channel The current channel. + * @return The channel or NULL if it wasn't found. + */ + virtual const CPVRChannel *GetByChannelDown(const CPVRChannel &channel) const; + + /*! + * @brief Get a channel given it's index in this container. + * @param index The index in this container. + * @return The channel or NULL if it wasn't found. + */ + virtual const CPVRChannel *GetByIndex(unsigned int index) const; + + /*! + * @brief Get the list of channels in a group. + * @param results The file list to store the results in. + * @param bGroupMembers If true, get the channels that are in this group. Get the channels that are not in this group otherwise. + * @return The amount of channels that were added to the list. + */ + virtual int GetMembers(CFileItemList *results, bool bGroupMembers = true) const; + + /*! + * @brief The amount of channels in this container. + * @return The amount of channels in this container. + */ + virtual int GetNumChannels(void) const { return size(); } + + /*! + * @brief The amount of hidden channels in this container. + * @return The amount of hidden channels in this container. + */ + virtual int GetNumHiddenChannels(void) const { return 0; } + + /*! + * @return True if there is at least one channel in this group with changes that haven't been persisted, false otherwise. + */ + virtual bool HasChangedChannels(void) const; + + /*! + * @return True if there is at least one new channel in this group that hasn't been persisted, false otherwise. + */ + virtual bool HasNewChannels(void) const; + + /*! + * @return True if anything changed in this group that hasn't been persisted, false otherwise. + */ + virtual bool HasChanges(void) const; + + //@} + }; +} diff --git a/xbmc/pvr/channels/PVRChannelGroupInternal.cpp b/xbmc/pvr/channels/PVRChannelGroupInternal.cpp index 0c797a245e2b6..524d73df0647d 100644 --- a/xbmc/pvr/channels/PVRChannelGroupInternal.cpp +++ b/xbmc/pvr/channels/PVRChannelGroupInternal.cpp @@ -31,6 +31,8 @@ #include "pvr/timers/PVRTimers.h" #include "pvr/addons/PVRClients.h" +using namespace PVR; + CPVRChannelGroupInternal::CPVRChannelGroupInternal(bool bRadio) : CPVRChannelGroup(bRadio) { diff --git a/xbmc/pvr/channels/PVRChannelGroupInternal.h b/xbmc/pvr/channels/PVRChannelGroupInternal.h index 5859777f61e17..16ae3701b66bb 100644 --- a/xbmc/pvr/channels/PVRChannelGroupInternal.h +++ b/xbmc/pvr/channels/PVRChannelGroupInternal.h @@ -23,152 +23,155 @@ #include "PVRChannelGroup.h" -class CPVRChannelGroups; -class CPVRDatabase; - -/** XBMC's internal group, the group containing all channels */ - -class CPVRChannelGroupInternal : public CPVRChannelGroup +namespace PVR { - friend class CPVRChannelGroups; - friend class CPVRDatabase; - -private: - int m_iHiddenChannels; /*!< the amount of hidden channels in this container */ - - /*! - * @brief Load all channels from the database. - * @param bCompress Compress the database after changing anything. - * @return The amount of channels that were loaded. - */ - int LoadFromDb(bool bCompress = false); - - /*! - * @brief Load all channels from the clients. - * @return The amount of channels that were loaded. - */ - int LoadFromClients(void); - - /*! - * @brief Check if this group is the internal group containing all channels. - * @return True if it's the internal group, false otherwise. - */ - bool IsInternalGroup(void) const { return true; } - - /*! - * @brief Update the current channel list with the given list. - * - * Update the current channel list with the given list. - * Only the new channels will be present in the passed list after this call. - * - * @param channels The channels to use to update this list. - * @return True if everything went well, false otherwise. - */ - bool UpdateGroupEntries(const CPVRChannelGroup &channels); - - /*! - * @brief Refresh the channel list from the clients. - */ - bool Update(void); - - /*! - * @brief Remove invalid channels and updates the channel numbers. - */ - void Renumber(void); - - /*! - * @brief Load the channels from the database. - * - * Load the channels from the database. - * If no channels are stored in the database, then the channels will be loaded from the clients. - * - * @return The amount of channels that were added. - */ - int Load(void); - - /*! - * @brief Update the vfs paths of all channels. - */ - void UpdateChannelPaths(void); - - /*! - * @brief Clear this channel list and destroy all channel instances in it. - */ - void Unload(); - -public: - /*! - * @brief Create a new internal channel group. - * @param bRadio True if this group holds radio channels. - */ - CPVRChannelGroupInternal(bool bRadio); - - /** - * @brief The amount of channels in this container. - * @return The amount of channels in this container. - */ - int GetNumHiddenChannels() const { return m_iHiddenChannels; } - - /*! - * @brief Update all channel numbers on timers. - * @return True if the channel number were updated, false otherwise. - */ - bool UpdateTimers(void); - - /*! - * @brief Persist changed or new data. - * @return True if the channel was persisted, false otherwise. - */ - bool Persist(void); - - /*! - * @brief Add or update a channel in this table. - * @param channel The channel to update. - * @return True if the channel was updated and persisted. - */ - bool UpdateChannel(const CPVRChannel &channel); - - /*! - * @brief Add a channel to this internal group. - * @param iChannelNumber The channel number to use for this channel or 0 to add it to the back. - * @param bSortAndRenumber Set to false to not to sort the group after adding a channel - */ - bool InsertInGroup(CPVRChannel *channel, int iChannelNumber = 0, bool bSortAndRenumber = true); - - /*! - * @brief Callback for add-ons to update a channel. - * @param channel The updated channel. - * @return True if the channel has been updated succesfully, false otherwise. - */ - bool UpdateFromClient(const CPVRChannel &channel); - - /*! - * @see CPVRChannelGroup::IsGroupMember - */ - bool IsGroupMember(const CPVRChannel &channel) const; - - /*! - * @see CPVRChannelGroup::AddToGroup - */ - bool AddToGroup(CPVRChannel *channel, int iChannelNumber = 0); - - /*! - * @see CPVRChannelGroup::RemoveFromGroup - */ - bool RemoveFromGroup(CPVRChannel *channel); - - /*! - * @see CPVRChannelGroup::MoveChannel - */ - bool MoveChannel(unsigned int iOldChannelNumber, unsigned int iNewChannelNumber, bool bSaveInDb = true); - - /*! - * @see CPVRChannelGroup::GetMembers - */ - int GetMembers(CFileItemList *results, bool bGroupMembers = true) const; - - /*! - * @brief Check whether the group name is still correct after the language setting changed. - */ - void CheckGroupName(void); -}; + class CPVRChannelGroups; + class CPVRDatabase; + + /** XBMC's internal group, the group containing all channels */ + + class CPVRChannelGroupInternal : public CPVRChannelGroup + { + friend class CPVRChannelGroups; + friend class CPVRDatabase; + + private: + int m_iHiddenChannels; /*!< the amount of hidden channels in this container */ + + /*! + * @brief Load all channels from the database. + * @param bCompress Compress the database after changing anything. + * @return The amount of channels that were loaded. + */ + int LoadFromDb(bool bCompress = false); + + /*! + * @brief Load all channels from the clients. + * @return The amount of channels that were loaded. + */ + int LoadFromClients(void); + + /*! + * @brief Check if this group is the internal group containing all channels. + * @return True if it's the internal group, false otherwise. + */ + bool IsInternalGroup(void) const { return true; } + + /*! + * @brief Update the current channel list with the given list. + * + * Update the current channel list with the given list. + * Only the new channels will be present in the passed list after this call. + * + * @param channels The channels to use to update this list. + * @return True if everything went well, false otherwise. + */ + bool UpdateGroupEntries(const CPVRChannelGroup &channels); + + /*! + * @brief Refresh the channel list from the clients. + */ + bool Update(void); + + /*! + * @brief Remove invalid channels and updates the channel numbers. + */ + void Renumber(void); + + /*! + * @brief Load the channels from the database. + * + * Load the channels from the database. + * If no channels are stored in the database, then the channels will be loaded from the clients. + * + * @return The amount of channels that were added. + */ + int Load(void); + + /*! + * @brief Update the vfs paths of all channels. + */ + void UpdateChannelPaths(void); + + /*! + * @brief Clear this channel list and destroy all channel instances in it. + */ + void Unload(); + + public: + /*! + * @brief Create a new internal channel group. + * @param bRadio True if this group holds radio channels. + */ + CPVRChannelGroupInternal(bool bRadio); + + /** + * @brief The amount of channels in this container. + * @return The amount of channels in this container. + */ + int GetNumHiddenChannels() const { return m_iHiddenChannels; } + + /*! + * @brief Update all channel numbers on timers. + * @return True if the channel number were updated, false otherwise. + */ + bool UpdateTimers(void); + + /*! + * @brief Persist changed or new data. + * @return True if the channel was persisted, false otherwise. + */ + bool Persist(void); + + /*! + * @brief Add or update a channel in this table. + * @param channel The channel to update. + * @return True if the channel was updated and persisted. + */ + bool UpdateChannel(const CPVRChannel &channel); + + /*! + * @brief Add a channel to this internal group. + * @param iChannelNumber The channel number to use for this channel or 0 to add it to the back. + * @param bSortAndRenumber Set to false to not to sort the group after adding a channel + */ + bool InsertInGroup(CPVRChannel *channel, int iChannelNumber = 0, bool bSortAndRenumber = true); + + /*! + * @brief Callback for add-ons to update a channel. + * @param channel The updated channel. + * @return True if the channel has been updated succesfully, false otherwise. + */ + bool UpdateFromClient(const CPVRChannel &channel); + + /*! + * @see CPVRChannelGroup::IsGroupMember + */ + bool IsGroupMember(const CPVRChannel &channel) const; + + /*! + * @see CPVRChannelGroup::AddToGroup + */ + bool AddToGroup(CPVRChannel *channel, int iChannelNumber = 0); + + /*! + * @see CPVRChannelGroup::RemoveFromGroup + */ + bool RemoveFromGroup(CPVRChannel *channel); + + /*! + * @see CPVRChannelGroup::MoveChannel + */ + bool MoveChannel(unsigned int iOldChannelNumber, unsigned int iNewChannelNumber, bool bSaveInDb = true); + + /*! + * @see CPVRChannelGroup::GetMembers + */ + int GetMembers(CFileItemList *results, bool bGroupMembers = true) const; + + /*! + * @brief Check whether the group name is still correct after the language setting changed. + */ + void CheckGroupName(void); + }; +} diff --git a/xbmc/pvr/channels/PVRChannelGroups.cpp b/xbmc/pvr/channels/PVRChannelGroups.cpp index 3382e0e886494..780fdc689b677 100644 --- a/xbmc/pvr/channels/PVRChannelGroups.cpp +++ b/xbmc/pvr/channels/PVRChannelGroups.cpp @@ -35,6 +35,8 @@ #include "pvr/PVRManager.h" #include "pvr/addons/PVRClients.h" +using namespace PVR; + CPVRChannelGroups::CPVRChannelGroups(bool bRadio) { m_bRadio = bRadio; diff --git a/xbmc/pvr/channels/PVRChannelGroups.h b/xbmc/pvr/channels/PVRChannelGroups.h index 60a56a37e579d..83bc4e95319a9 100644 --- a/xbmc/pvr/channels/PVRChannelGroups.h +++ b/xbmc/pvr/channels/PVRChannelGroups.h @@ -28,175 +28,178 @@ #include "PVRChannelGroupInternal.h" #include "threads/SingleLock.h" -class CPVRChannelGroupsContainer; - -/** A container class for channel groups */ - -class CPVRChannelGroups : public std::vector +namespace PVR { - friend class CPVRChannelGroupsContainer; - -private: - bool m_bRadio; /*!< true if this is a container for radio channels, false if it is for tv channels */ - CCriticalSection m_critSection; - - /*! - * @brief Get the index in this container of the channel group with the given ID. - * @param iGroupId The ID to find. - * @return The index or -1 if it wasn't found. - */ - int GetIndexForGroupID(int iGroupId) const; - int GetIndexForGroupName(const CStdString &strName) const; - bool LoadUserDefinedChannelGroups(void); - bool GetGroupsFromClients(void); - -protected: - /*! - * @brief Update the contents of the groups in this container. - * @param bChannelsOnly Set to true to only update channels, not the groups themselves. - * @return True if the update was successful, false otherwise. - */ - bool Update(bool bChannelsOnly = false); - - bool UpdateGroupsEntries(const CPVRChannelGroups &groups); - -public: - /*! - * @brief Create a new group container. - * @param bRadio True if this is a container for radio channels, false if it is for tv channels. - */ - CPVRChannelGroups(bool bRadio); - virtual ~CPVRChannelGroups(void); - - /*! - * @brief Remove all channels from this group. - */ - void Clear(void); - - /*! - * @brief Load this container's contents from the database or PVR clients. - * @return True if it was loaded successfully, false if not. - */ - bool Load(void); - - /*! - * @brief Update a group or add it if it's not in here yet. - * @param group The group to update. - * @param bSaveInDb True to save the changes in the db. - * @return True if the group was added or update successfully, false otherwise. - */ - bool Update(const CPVRChannelGroup &group, bool bSaveInDb = false); - bool UpdateFromClient(const CPVRChannelGroup &group); - - /*! - * @brief Get a pointer to a channel group given it's ID. - * @param iGroupId The ID of the group. - * @return The group or NULL if it wasn't found. - */ - const CPVRChannelGroup *GetById(int iGroupId) const; - - /*! - * @brief Get a group given it's name. - * @param strName The name. - * @return The group or NULL if it wan't found. - */ - const CPVRChannelGroup *GetByName(const CStdString &strName) const; - - /*! - * @brief Get the group that contains all channels. - * @return The group that contains all channels. - */ - CPVRChannelGroupInternal *GetGroupAll(void) const; - - /*! - * @brief Get the list of groups. - * @param results The file list to store the results in. - * @return The amount of items that were added. - */ - int GetGroupList(CFileItemList* results) const; - - /*! - * @brief Get the ID of the first channel in a group. - * @param iGroupId The ID of the group. - * @return The ID of the first channel or 1 if it wasn't found. - */ - int GetFirstChannelForGroupID(int iGroupId) const; - - /*! - * @brief Get the ID of the previous group in this container. - * @param iGroupId The ID of the current group. - * @return The ID of the previous group or the ID of the group containing all channels if it wasn't found. - */ - int GetPreviousGroupID(int iGroupId) const; - - /*! - * @brief Get the previous group in this container. - * @param group The current group. - * @return The previous group or the group containing all channels if it wasn't found. - */ - const CPVRChannelGroup *GetPreviousGroup(const CPVRChannelGroup &group) const; - - /*! - * @brief Get the ID of the next group in this container. - * @param iGroupId The ID of the current group. - * @return The ID of the next group or the ID of the group containing all channels if it wasn't found. - */ - int GetNextGroupID(int iGroupId) const; - - /*! - * @brief Get the next group in this container. - * @param group The current group. - * @return The next group or the group containing all channels if it wasn't found. - */ - const CPVRChannelGroup *GetNextGroup(const CPVRChannelGroup &group) const; - - /*! - * @brief Add a group to this container. - * @param strName The name of the group. - * @return True if the group was added, false otherwise. - */ - bool AddGroup(const CStdString &strName); - - /*! - * @brief Delete a group in this container. - * @param group The group to delete. - * @return True if it was deleted successfully, false if not. - */ - bool DeleteGroup(const CPVRChannelGroup &group); - - /*! - * @brief Add a channel to the group with the given ID. - * @param channel The channel to add. - * @param iGroupId The ID of the group to add the channel to. - * @return True if the channel was added, false if not. - */ - bool AddChannelToGroup(CPVRChannel *channel, int iGroupId); - - /*! - * @brief Get the name of a group. - * @param iGroupId The ID of the group. - * @return The name of the group or localized string 953 if it wasn't found. - */ - const CStdString &GetGroupName(int iGroupId) const; - - /*! - * @brief Get the ID of a group given it's name. - * @param strGroupName The name of the group. - * @return The ID or -1 if it wasn't found. - */ - int GetGroupId(CStdString strGroupName) const; - - /*! - * @brief Remove a channel from all non-system groups. - * @param channel The channel to remove. - */ - void RemoveFromAllGroups(CPVRChannel *channel); - - /*! - * @brief Persist all changes in channel groups. - * @return True if everything was persisted, false otherwise. - */ - bool PersistAll(void); - - bool IsRadio(void) const { return m_bRadio; } -}; + class CPVRChannelGroupsContainer; + + /** A container class for channel groups */ + + class CPVRChannelGroups : public std::vector + { + friend class CPVRChannelGroupsContainer; + + private: + bool m_bRadio; /*!< true if this is a container for radio channels, false if it is for tv channels */ + CCriticalSection m_critSection; + + /*! + * @brief Get the index in this container of the channel group with the given ID. + * @param iGroupId The ID to find. + * @return The index or -1 if it wasn't found. + */ + int GetIndexForGroupID(int iGroupId) const; + int GetIndexForGroupName(const CStdString &strName) const; + bool LoadUserDefinedChannelGroups(void); + bool GetGroupsFromClients(void); + + protected: + /*! + * @brief Update the contents of the groups in this container. + * @param bChannelsOnly Set to true to only update channels, not the groups themselves. + * @return True if the update was successful, false otherwise. + */ + bool Update(bool bChannelsOnly = false); + + bool UpdateGroupsEntries(const CPVRChannelGroups &groups); + + public: + /*! + * @brief Create a new group container. + * @param bRadio True if this is a container for radio channels, false if it is for tv channels. + */ + CPVRChannelGroups(bool bRadio); + virtual ~CPVRChannelGroups(void); + + /*! + * @brief Remove all channels from this group. + */ + void Clear(void); + + /*! + * @brief Load this container's contents from the database or PVR clients. + * @return True if it was loaded successfully, false if not. + */ + bool Load(void); + + /*! + * @brief Update a group or add it if it's not in here yet. + * @param group The group to update. + * @param bSaveInDb True to save the changes in the db. + * @return True if the group was added or update successfully, false otherwise. + */ + bool Update(const CPVRChannelGroup &group, bool bSaveInDb = false); + bool UpdateFromClient(const CPVRChannelGroup &group); + + /*! + * @brief Get a pointer to a channel group given it's ID. + * @param iGroupId The ID of the group. + * @return The group or NULL if it wasn't found. + */ + const CPVRChannelGroup *GetById(int iGroupId) const; + + /*! + * @brief Get a group given it's name. + * @param strName The name. + * @return The group or NULL if it wan't found. + */ + const CPVRChannelGroup *GetByName(const CStdString &strName) const; + + /*! + * @brief Get the group that contains all channels. + * @return The group that contains all channels. + */ + CPVRChannelGroupInternal *GetGroupAll(void) const; + + /*! + * @brief Get the list of groups. + * @param results The file list to store the results in. + * @return The amount of items that were added. + */ + int GetGroupList(CFileItemList* results) const; + + /*! + * @brief Get the ID of the first channel in a group. + * @param iGroupId The ID of the group. + * @return The ID of the first channel or 1 if it wasn't found. + */ + int GetFirstChannelForGroupID(int iGroupId) const; + + /*! + * @brief Get the ID of the previous group in this container. + * @param iGroupId The ID of the current group. + * @return The ID of the previous group or the ID of the group containing all channels if it wasn't found. + */ + int GetPreviousGroupID(int iGroupId) const; + + /*! + * @brief Get the previous group in this container. + * @param group The current group. + * @return The previous group or the group containing all channels if it wasn't found. + */ + const CPVRChannelGroup *GetPreviousGroup(const CPVRChannelGroup &group) const; + + /*! + * @brief Get the ID of the next group in this container. + * @param iGroupId The ID of the current group. + * @return The ID of the next group or the ID of the group containing all channels if it wasn't found. + */ + int GetNextGroupID(int iGroupId) const; + + /*! + * @brief Get the next group in this container. + * @param group The current group. + * @return The next group or the group containing all channels if it wasn't found. + */ + const CPVRChannelGroup *GetNextGroup(const CPVRChannelGroup &group) const; + + /*! + * @brief Add a group to this container. + * @param strName The name of the group. + * @return True if the group was added, false otherwise. + */ + bool AddGroup(const CStdString &strName); + + /*! + * @brief Delete a group in this container. + * @param group The group to delete. + * @return True if it was deleted successfully, false if not. + */ + bool DeleteGroup(const CPVRChannelGroup &group); + + /*! + * @brief Add a channel to the group with the given ID. + * @param channel The channel to add. + * @param iGroupId The ID of the group to add the channel to. + * @return True if the channel was added, false if not. + */ + bool AddChannelToGroup(CPVRChannel *channel, int iGroupId); + + /*! + * @brief Get the name of a group. + * @param iGroupId The ID of the group. + * @return The name of the group or localized string 953 if it wasn't found. + */ + const CStdString &GetGroupName(int iGroupId) const; + + /*! + * @brief Get the ID of a group given it's name. + * @param strGroupName The name of the group. + * @return The ID or -1 if it wasn't found. + */ + int GetGroupId(CStdString strGroupName) const; + + /*! + * @brief Remove a channel from all non-system groups. + * @param channel The channel to remove. + */ + void RemoveFromAllGroups(CPVRChannel *channel); + + /*! + * @brief Persist all changes in channel groups. + * @return True if everything was persisted, false otherwise. + */ + bool PersistAll(void); + + bool IsRadio(void) const { return m_bRadio; } + }; +} diff --git a/xbmc/pvr/channels/PVRChannelGroupsContainer.cpp b/xbmc/pvr/channels/PVRChannelGroupsContainer.cpp index d01c5e3c7c30b..404d394d0f297 100644 --- a/xbmc/pvr/channels/PVRChannelGroupsContainer.cpp +++ b/xbmc/pvr/channels/PVRChannelGroupsContainer.cpp @@ -27,6 +27,8 @@ #include "utils/log.h" #include "pvr/PVRManager.h" +using namespace PVR; + CPVRChannelGroupsContainer::CPVRChannelGroupsContainer(void) { diff --git a/xbmc/pvr/channels/PVRChannelGroupsContainer.h b/xbmc/pvr/channels/PVRChannelGroupsContainer.h index e47c8588e1a62..010c4700e8c62 100644 --- a/xbmc/pvr/channels/PVRChannelGroupsContainer.h +++ b/xbmc/pvr/channels/PVRChannelGroupsContainer.h @@ -25,172 +25,175 @@ #include "threads/Thread.h" #include "threads/CriticalSection.h" -class CPVRManager; -class CPVRChannelsUpdateJob; -class CPVRChannelGroupsUpdateJob; - -class CPVRChannelGroupsContainer : private CThread +namespace PVR { - friend class CPVRManager; - friend class CPVRChannelsUpdateJob; - friend class CPVRChannelGroupsUpdateJob; - -private: - CPVRChannelGroups *m_groupsRadio; /*!< all radio channel groups */ - CPVRChannelGroups *m_groupsTV; /*!< all TV channel groups */ - CCriticalSection m_critSection; - bool m_bUpdateChannelsOnly; - bool m_bIsUpdating; - - virtual bool ExecuteUpdate(bool bChannelsOnly); - virtual void Process(void); - -protected: - /*! - * @brief Update the contents of all the groups in this container. - * @param bChannelsOnly Set to true to only update channels, not the groups themselves. - * @param bAsyncUpdate Try to update the channel groups async. - * @return True if the update was successful, false otherwise. - */ - bool Update(bool bChannelsOnly = false, bool bAsyncUpdate = false); - -public: - /*! - * @brief Create a new container for all channel groups - */ - CPVRChannelGroupsContainer(void); - - /*! - * @brief Destroy this container. - */ - ~CPVRChannelGroupsContainer(void); - - /*! - * @brief Load all channel groups and all channels in those channel groups. - * @return True if all groups were loaded, false otherwise. - */ - bool Load(void); - - /*! - * @brief Unload and destruct all channel groups and all channels in them. - */ - void Unload(void); - - /*! - * @brief Get the TV channel groups. - * @return The TV channel groups. - */ - const CPVRChannelGroups *GetTV(void) const { return Get(false); } - - /*! - * @brief Get the radio channel groups. - * @return The radio channel groups. - */ - const CPVRChannelGroups *GetRadio(void) const { return Get(true); } - - /*! - * @brief Get the radio or TV channel groups. - * @param bRadio If true, get the radio channel groups. Get the TV channel groups otherwise. - * @return The requested groups. - */ - const CPVRChannelGroups *Get(bool bRadio) const; - - /*! - * @brief Get the group containing all TV channels. - * @return The group containing all TV channels. - */ - CPVRChannelGroupInternal *GetGroupAllTV(void) const{ return GetGroupAll(false); } - - /*! - * @brief Get the group containing all radio channels. - * @return The group containing all radio channels. - */ - CPVRChannelGroupInternal *GetGroupAllRadio(void) const{ return GetGroupAll(true); } - - /*! - * @brief Get the group containing all TV or radio channels. - * @param bRadio If true, get the group containing all radio channels. Get the group containing all TV channels otherwise. - * @return The requested group. - */ - CPVRChannelGroupInternal *GetGroupAll(bool bRadio) const; - - /*! - * @brief Get a group given it's ID. - * @param bRadio If true, search the radio channel container. Search the TV channels otherwise. - * @param iGroupId The ID of the group. - * @return The requested group or NULL if it wasn't found. - */ - const CPVRChannelGroup *GetById(bool bRadio, int iGroupId) const; - - /*! - * @brief Get a channel given it's database ID. - * @param iChannelId The ID of the channel. - * @return The channel or NULL if it wasn't found. - */ - const CPVRChannel *GetChannelById(int iChannelId) const; - - /*! - * @brief Get the groups list for a directory. - * @param strBase The directory path. - * @param results The file list to store the results in. - * @param bRadio Get radio channels or tv channels. - * @return True if the list was filled succesfully. - */ - bool GetGroupsDirectory(const CStdString &strBase, CFileItemList *results, bool bRadio); - - /*! - * @brief Get a channel given it's path. - * @param strPath The path. - * @return The channel or NULL if it wasn't found. - */ - const CPVRChannel *GetByPath(const CStdString &strPath); - - /*! - * @brief Get the directory for a path. - * @param strPath The path. - * @param results The file list to store the results in. - * @return True if the directory was found, false if not. - */ - bool GetDirectory(const CStdString& strPath, CFileItemList &results); - - /*! - * @brief The total amount of unique channels in all containers. - * @return The total amount of unique channels in all containers. - */ - int GetNumChannelsFromAll(); - - /*! - * @brief Get a channel given it's channel ID from all containers. - * @param iClientChannelNumber The channel number on the client. - * @param iClientID The ID of the client. - * @return The channel or NULL if it wasn't found. - */ - const CPVRChannel *GetByUniqueID(int iClientChannelNumber, int iClientID); - - /*! - * @brief Get a channel given it's channel ID from all containers. - * @param iChannelID The channel ID. - * @return The channel or NULL if it wasn't found. - */ - const CPVRChannel *GetByChannelIDFromAll(int iChannelID); - - const CPVRChannel *GetByClientFromAll(unsigned int iClientId, unsigned int iChannelUid); - - /*! - * @brief Get a channel given it's unique ID. - * @param iUniqueID The unique ID of the channel. - * @return The channel or NULL if it wasn't found. - */ - const CPVRChannel *GetByUniqueIDFromAll(int iUniqueID); - - /*! - * @brief Try to find missing channel icons automatically - */ - void SearchMissingChannelIcons(void); - - /*! - * @brief The channel that was played last that has a valid client or NULL if there was none. - * @return The requested channel. - */ - virtual const CPVRChannel *GetLastPlayedChannel(void) const; -}; + class CPVRManager; + class CPVRChannelsUpdateJob; + class CPVRChannelGroupsUpdateJob; + + class CPVRChannelGroupsContainer : private CThread + { + friend class CPVRManager; + friend class CPVRChannelsUpdateJob; + friend class CPVRChannelGroupsUpdateJob; + + private: + CPVRChannelGroups *m_groupsRadio; /*!< all radio channel groups */ + CPVRChannelGroups *m_groupsTV; /*!< all TV channel groups */ + CCriticalSection m_critSection; + bool m_bUpdateChannelsOnly; + bool m_bIsUpdating; + + virtual bool ExecuteUpdate(bool bChannelsOnly); + virtual void Process(void); + + protected: + /*! + * @brief Update the contents of all the groups in this container. + * @param bChannelsOnly Set to true to only update channels, not the groups themselves. + * @param bAsyncUpdate Try to update the channel groups async. + * @return True if the update was successful, false otherwise. + */ + bool Update(bool bChannelsOnly = false, bool bAsyncUpdate = false); + + public: + /*! + * @brief Create a new container for all channel groups + */ + CPVRChannelGroupsContainer(void); + + /*! + * @brief Destroy this container. + */ + ~CPVRChannelGroupsContainer(void); + + /*! + * @brief Load all channel groups and all channels in those channel groups. + * @return True if all groups were loaded, false otherwise. + */ + bool Load(void); + + /*! + * @brief Unload and destruct all channel groups and all channels in them. + */ + void Unload(void); + + /*! + * @brief Get the TV channel groups. + * @return The TV channel groups. + */ + const CPVRChannelGroups *GetTV(void) const { return Get(false); } + + /*! + * @brief Get the radio channel groups. + * @return The radio channel groups. + */ + const CPVRChannelGroups *GetRadio(void) const { return Get(true); } + + /*! + * @brief Get the radio or TV channel groups. + * @param bRadio If true, get the radio channel groups. Get the TV channel groups otherwise. + * @return The requested groups. + */ + const CPVRChannelGroups *Get(bool bRadio) const; + + /*! + * @brief Get the group containing all TV channels. + * @return The group containing all TV channels. + */ + CPVRChannelGroupInternal *GetGroupAllTV(void) const{ return GetGroupAll(false); } + + /*! + * @brief Get the group containing all radio channels. + * @return The group containing all radio channels. + */ + CPVRChannelGroupInternal *GetGroupAllRadio(void) const{ return GetGroupAll(true); } + + /*! + * @brief Get the group containing all TV or radio channels. + * @param bRadio If true, get the group containing all radio channels. Get the group containing all TV channels otherwise. + * @return The requested group. + */ + CPVRChannelGroupInternal *GetGroupAll(bool bRadio) const; + + /*! + * @brief Get a group given it's ID. + * @param bRadio If true, search the radio channel container. Search the TV channels otherwise. + * @param iGroupId The ID of the group. + * @return The requested group or NULL if it wasn't found. + */ + const CPVRChannelGroup *GetById(bool bRadio, int iGroupId) const; + + /*! + * @brief Get a channel given it's database ID. + * @param iChannelId The ID of the channel. + * @return The channel or NULL if it wasn't found. + */ + const CPVRChannel *GetChannelById(int iChannelId) const; + + /*! + * @brief Get the groups list for a directory. + * @param strBase The directory path. + * @param results The file list to store the results in. + * @param bRadio Get radio channels or tv channels. + * @return True if the list was filled succesfully. + */ + bool GetGroupsDirectory(const CStdString &strBase, CFileItemList *results, bool bRadio); + + /*! + * @brief Get a channel given it's path. + * @param strPath The path. + * @return The channel or NULL if it wasn't found. + */ + const CPVRChannel *GetByPath(const CStdString &strPath); + + /*! + * @brief Get the directory for a path. + * @param strPath The path. + * @param results The file list to store the results in. + * @return True if the directory was found, false if not. + */ + bool GetDirectory(const CStdString& strPath, CFileItemList &results); + + /*! + * @brief The total amount of unique channels in all containers. + * @return The total amount of unique channels in all containers. + */ + int GetNumChannelsFromAll(); + + /*! + * @brief Get a channel given it's channel ID from all containers. + * @param iClientChannelNumber The channel number on the client. + * @param iClientID The ID of the client. + * @return The channel or NULL if it wasn't found. + */ + const CPVRChannel *GetByUniqueID(int iClientChannelNumber, int iClientID); + + /*! + * @brief Get a channel given it's channel ID from all containers. + * @param iChannelID The channel ID. + * @return The channel or NULL if it wasn't found. + */ + const CPVRChannel *GetByChannelIDFromAll(int iChannelID); + + const CPVRChannel *GetByClientFromAll(unsigned int iClientId, unsigned int iChannelUid); + + /*! + * @brief Get a channel given it's unique ID. + * @param iUniqueID The unique ID of the channel. + * @return The channel or NULL if it wasn't found. + */ + const CPVRChannel *GetByUniqueIDFromAll(int iUniqueID); + + /*! + * @brief Try to find missing channel icons automatically + */ + void SearchMissingChannelIcons(void); + + /*! + * @brief The channel that was played last that has a valid client or NULL if there was none. + * @return The requested channel. + */ + virtual const CPVRChannel *GetLastPlayedChannel(void) const; + }; +} diff --git a/xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp b/xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp index b3688e817e19c..3ab8ebfa04b0f 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp +++ b/xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp @@ -63,6 +63,7 @@ #define BUTTON_RADIO_TV 34 using namespace std; +using namespace PVR; CGUIDialogPVRChannelManager::CGUIDialogPVRChannelManager() : CGUIDialog(WINDOW_DIALOG_PVR_CHANNEL_MANAGER, "DialogPVRChannelManager.xml") diff --git a/xbmc/pvr/dialogs/GUIDialogPVRChannelManager.h b/xbmc/pvr/dialogs/GUIDialogPVRChannelManager.h index 55204927b400d..13f1abc3bcd65 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRChannelManager.h +++ b/xbmc/pvr/dialogs/GUIDialogPVRChannelManager.h @@ -24,33 +24,36 @@ #include "dialogs/GUIDialogContextMenu.h" #include "GUIViewControl.h" -class CGUIDialogPVRChannelManager : public CGUIDialog +namespace PVR { -public: - CGUIDialogPVRChannelManager(void); - virtual ~CGUIDialogPVRChannelManager(void); - virtual bool OnMessage(CGUIMessage& message); - virtual bool OnAction(const CAction& action); - virtual void OnWindowLoaded(); - virtual void OnWindowUnload(); - virtual bool HasListItems() const { return true; }; - virtual CFileItemPtr GetCurrentListItem(int offset = 0); + class CGUIDialogPVRChannelManager : public CGUIDialog + { + public: + CGUIDialogPVRChannelManager(void); + virtual ~CGUIDialogPVRChannelManager(void); + virtual bool OnMessage(CGUIMessage& message); + virtual bool OnAction(const CAction& action); + virtual void OnWindowLoaded(); + virtual void OnWindowUnload(); + virtual bool HasListItems() const { return true; }; + virtual CFileItemPtr GetCurrentListItem(int offset = 0); -protected: - virtual bool OnPopupMenu(int iItem); - virtual bool OnContextButton(int itemNumber, CONTEXT_BUTTON button); + protected: + virtual bool OnPopupMenu(int iItem); + virtual bool OnContextButton(int itemNumber, CONTEXT_BUTTON button); -private: - void Clear(); - void Update(); - void SaveList(); - void Renumber(); - void SetData(int iItem); - bool m_bIsRadio; - bool m_bMovingMode; - bool m_bContainsChanges; + private: + void Clear(); + void Update(); + void SaveList(); + void Renumber(); + void SetData(int iItem); + bool m_bIsRadio; + bool m_bMovingMode; + bool m_bContainsChanges; - int m_iSelected; - CFileItemList* m_channelItems; - CGUIViewControl m_viewControl; -}; + int m_iSelected; + CFileItemList* m_channelItems; + CGUIViewControl m_viewControl; + }; +} diff --git a/xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.cpp b/xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.cpp index ba728ddc9bdc1..724448ee0e7c0 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.cpp +++ b/xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.cpp @@ -33,6 +33,7 @@ #include "pvr/timers/PVRTimerInfoTag.h" using namespace std; +using namespace PVR; #define CONTROL_LIST 11 diff --git a/xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.h b/xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.h index d18eb713757d5..d8be5b282524f 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.h +++ b/xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.h @@ -25,22 +25,26 @@ class CFileItemList; -class CGUIDialogPVRChannelsOSD : public CGUIDialog +namespace PVR { -public: - CGUIDialogPVRChannelsOSD(void); - virtual ~CGUIDialogPVRChannelsOSD(void); - virtual bool OnMessage(CGUIMessage& message); - virtual void OnWindowLoaded(); - virtual void OnWindowUnload(); + class CGUIDialogPVRChannelsOSD : public CGUIDialog + { + public: + CGUIDialogPVRChannelsOSD(void); + virtual ~CGUIDialogPVRChannelsOSD(void); + virtual bool OnMessage(CGUIMessage& message); + virtual void OnWindowLoaded(); + virtual void OnWindowUnload(); -protected: - void GotoChannel(int iItem); - void ShowInfo(int item); - void Clear(); - void Update(); - CGUIControl *GetFirstFocusableControl(int id); + protected: + void GotoChannel(int iItem); + void ShowInfo(int item); + void Clear(); + void Update(); + CGUIControl *GetFirstFocusableControl(int id); + + CFileItemList *m_vecItems; + CGUIViewControl m_viewControl; + }; +} - CFileItemList *m_vecItems; - CGUIViewControl m_viewControl; -}; diff --git a/xbmc/pvr/dialogs/GUIDialogPVRCutterOSD.cpp b/xbmc/pvr/dialogs/GUIDialogPVRCutterOSD.cpp index 1b5a73326cfcd..273f3ff4304eb 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRCutterOSD.cpp +++ b/xbmc/pvr/dialogs/GUIDialogPVRCutterOSD.cpp @@ -24,6 +24,7 @@ #include "Application.h" using namespace std; +using namespace PVR; CGUIDialogPVRCutterOSD::CGUIDialogPVRCutterOSD() : CGUIDialog(WINDOW_DIALOG_PVR_OSD_CUTTER, "DialogPVRCutterOSD.xml") diff --git a/xbmc/pvr/dialogs/GUIDialogPVRCutterOSD.h b/xbmc/pvr/dialogs/GUIDialogPVRCutterOSD.h index 468aa4255b5f6..1e06c07f0a976 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRCutterOSD.h +++ b/xbmc/pvr/dialogs/GUIDialogPVRCutterOSD.h @@ -22,13 +22,16 @@ #include "guilib/GUIDialog.h" -class CGUIDialogPVRCutterOSD : public CGUIDialog +namespace PVR { -public: - CGUIDialogPVRCutterOSD(void); - virtual ~CGUIDialogPVRCutterOSD(void); - virtual bool OnMessage(CGUIMessage& message); - virtual bool OnAction(const CAction& action); - virtual void OnInitWindow(); - virtual void OnDeinitWindow(int nextWindowID); -}; + class CGUIDialogPVRCutterOSD : public CGUIDialog + { + public: + CGUIDialogPVRCutterOSD(void); + virtual ~CGUIDialogPVRCutterOSD(void); + virtual bool OnMessage(CGUIMessage& message); + virtual bool OnAction(const CAction& action); + virtual void OnInitWindow(); + virtual void OnDeinitWindow(int nextWindowID); + }; +} diff --git a/xbmc/pvr/dialogs/GUIDialogPVRDirectorOSD.cpp b/xbmc/pvr/dialogs/GUIDialogPVRDirectorOSD.cpp index 8d5bbfa562240..878b042c99459 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRDirectorOSD.cpp +++ b/xbmc/pvr/dialogs/GUIDialogPVRDirectorOSD.cpp @@ -34,6 +34,7 @@ #include "pvr/epg/PVREpgInfoTag.h" using namespace std; +using namespace PVR; CGUIDialogPVRDirectorOSD::CGUIDialogPVRDirectorOSD() : CGUIDialog(WINDOW_DIALOG_PVR_OSD_DIRECTOR, "DialogPVRDirectorOSD.xml") diff --git a/xbmc/pvr/dialogs/GUIDialogPVRDirectorOSD.h b/xbmc/pvr/dialogs/GUIDialogPVRDirectorOSD.h index 60ff5f23f7f1f..079a6ffbc0c0d 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRDirectorOSD.h +++ b/xbmc/pvr/dialogs/GUIDialogPVRDirectorOSD.h @@ -22,13 +22,16 @@ #include "guilib/GUIDialog.h" -class CGUIDialogPVRDirectorOSD : public CGUIDialog +namespace PVR { -public: - CGUIDialogPVRDirectorOSD(void); - virtual ~CGUIDialogPVRDirectorOSD(void); - virtual bool OnMessage(CGUIMessage& message); - virtual bool OnAction(const CAction& action); - virtual void OnInitWindow(); - virtual void OnDeinitWindow(int nextWindowID); -}; + class CGUIDialogPVRDirectorOSD : public CGUIDialog + { + public: + CGUIDialogPVRDirectorOSD(void); + virtual ~CGUIDialogPVRDirectorOSD(void); + virtual bool OnMessage(CGUIMessage& message); + virtual bool OnAction(const CAction& action); + virtual void OnInitWindow(); + virtual void OnDeinitWindow(int nextWindowID); + }; +} diff --git a/xbmc/pvr/dialogs/GUIDialogPVRGroupManager.cpp b/xbmc/pvr/dialogs/GUIDialogPVRGroupManager.cpp index 798244d1692a3..0c907ca5973c1 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRGroupManager.cpp +++ b/xbmc/pvr/dialogs/GUIDialogPVRGroupManager.cpp @@ -32,6 +32,7 @@ #include "pvr/channels/PVRChannelGroupsContainer.h" using namespace std; +using namespace PVR; #define CONTROL_LIST_CHANNELS_LEFT 11 #define CONTROL_LIST_CHANNELS_RIGHT 12 diff --git a/xbmc/pvr/dialogs/GUIDialogPVRGroupManager.h b/xbmc/pvr/dialogs/GUIDialogPVRGroupManager.h index 8a041d7e0f940..742f1c0d0bae9 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRGroupManager.h +++ b/xbmc/pvr/dialogs/GUIDialogPVRGroupManager.h @@ -24,46 +24,50 @@ #include "GUIViewControl.h" class CFileItemList; -class CPVRChannelGroup; -class CGUIDialogPVRGroupManager : public CGUIDialog +namespace PVR { -public: - CGUIDialogPVRGroupManager(void); - virtual ~CGUIDialogPVRGroupManager(void); - virtual bool OnMessage(CGUIMessage& message); - virtual void OnWindowLoaded(); - virtual void OnWindowUnload(); - void SetRadio(bool IsRadio) { m_bIsRadio = IsRadio; } + class CPVRChannelGroup; -protected: - void Clear(); - void Update(); + class CGUIDialogPVRGroupManager : public CGUIDialog + { + public: + CGUIDialogPVRGroupManager(void); + virtual ~CGUIDialogPVRGroupManager(void); + virtual bool OnMessage(CGUIMessage& message); + virtual void OnWindowLoaded(); + virtual void OnWindowUnload(); + void SetRadio(bool IsRadio) { m_bIsRadio = IsRadio; } -private: - bool PersistChanges(void); - bool CancelChanges(void); - bool ActionButtonOk(CGUIMessage &message); - bool ActionButtonNewGroup(CGUIMessage &message); - bool ActionButtonDeleteGroup(CGUIMessage &message); - bool ActionButtonRenameGroup(CGUIMessage &message); - bool ActionButtonUngroupedChannels(CGUIMessage &message); - bool ActionButtonGroupMembers(CGUIMessage &message); - bool ActionButtonChannelGroups(CGUIMessage &message); - bool OnMessageClick(CGUIMessage &message); + protected: + void Clear(); + void Update(); - CPVRChannelGroup *m_selectedGroup; - bool m_bIsRadio; + private: + bool PersistChanges(void); + bool CancelChanges(void); + bool ActionButtonOk(CGUIMessage &message); + bool ActionButtonNewGroup(CGUIMessage &message); + bool ActionButtonDeleteGroup(CGUIMessage &message); + bool ActionButtonRenameGroup(CGUIMessage &message); + bool ActionButtonUngroupedChannels(CGUIMessage &message); + bool ActionButtonGroupMembers(CGUIMessage &message); + bool ActionButtonChannelGroups(CGUIMessage &message); + bool OnMessageClick(CGUIMessage &message); - unsigned int m_iSelectedUngroupedChannel; - unsigned int m_iSelectedGroupMember; - unsigned int m_iSelectedChannelGroup; + CPVRChannelGroup *m_selectedGroup; + bool m_bIsRadio; - CFileItemList * m_ungroupedChannels; - CFileItemList * m_groupMembers; - CFileItemList * m_channelGroups; + unsigned int m_iSelectedUngroupedChannel; + unsigned int m_iSelectedGroupMember; + unsigned int m_iSelectedChannelGroup; - CGUIViewControl m_viewUngroupedChannels; - CGUIViewControl m_viewGroupMembers; - CGUIViewControl m_viewChannelGroups; -}; + CFileItemList * m_ungroupedChannels; + CFileItemList * m_groupMembers; + CFileItemList * m_channelGroups; + + CGUIViewControl m_viewUngroupedChannels; + CGUIViewControl m_viewGroupMembers; + CGUIViewControl m_viewChannelGroups; + }; +} diff --git a/xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.cpp b/xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.cpp index cd0a4246b93d4..b5e6ec4d170ba 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.cpp +++ b/xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.cpp @@ -32,6 +32,7 @@ #include "pvr/timers/PVRTimerInfoTag.h" using namespace std; +using namespace PVR; #define CONTROL_BTN_SWITCH 5 #define CONTROL_BTN_RECORD 6 diff --git a/xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.h b/xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.h index 5a82fcccf288f..1ba7838612e9e 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.h +++ b/xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.h @@ -22,29 +22,31 @@ #include "guilib/GUIDialog.h" -class CPVREpgInfoTag; -class CPVRTimerInfoTag; - -class CGUIDialogPVRGuideInfo : public CGUIDialog +namespace PVR { -public: - CGUIDialogPVRGuideInfo(void); - virtual ~CGUIDialogPVRGuideInfo(void); - virtual bool OnMessage(CGUIMessage& message); - virtual bool HasListItems() const { return true; }; - virtual CFileItemPtr GetCurrentListItem(int offset = 0); - - void SetProgInfo(const CFileItem *item); - -protected: - void Update(); - bool ActionStartTimer(const CPVREpgInfoTag *tag); - bool ActionCancelTimer(const CPVRTimerInfoTag *tag); - - bool OnClickButtonOK(CGUIMessage &message); - bool OnClickButtonRecord(CGUIMessage &message); - bool OnClickButtonSwitch(CGUIMessage &message); - - CFileItemPtr m_progItem; -}; - + class CPVREpgInfoTag; + class CPVRTimerInfoTag; + + class CGUIDialogPVRGuideInfo : public CGUIDialog + { + public: + CGUIDialogPVRGuideInfo(void); + virtual ~CGUIDialogPVRGuideInfo(void); + virtual bool OnMessage(CGUIMessage& message); + virtual bool HasListItems() const { return true; }; + virtual CFileItemPtr GetCurrentListItem(int offset = 0); + + void SetProgInfo(const CFileItem *item); + + protected: + void Update(); + bool ActionStartTimer(const CPVREpgInfoTag *tag); + bool ActionCancelTimer(const CPVRTimerInfoTag *tag); + + bool OnClickButtonOK(CGUIMessage &message); + bool OnClickButtonRecord(CGUIMessage &message); + bool OnClickButtonSwitch(CGUIMessage &message); + + CFileItemPtr m_progItem; + }; +} diff --git a/xbmc/pvr/dialogs/GUIDialogPVRGuideOSD.cpp b/xbmc/pvr/dialogs/GUIDialogPVRGuideOSD.cpp index ec13fee900298..f30731e584e29 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRGuideOSD.cpp +++ b/xbmc/pvr/dialogs/GUIDialogPVRGuideOSD.cpp @@ -30,6 +30,7 @@ #include "pvr/PVRManager.h" using namespace std; +using namespace PVR; #define CONTROL_LIST 11 diff --git a/xbmc/pvr/dialogs/GUIDialogPVRGuideOSD.h b/xbmc/pvr/dialogs/GUIDialogPVRGuideOSD.h index e70aec57d6318..8c335d83a352e 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRGuideOSD.h +++ b/xbmc/pvr/dialogs/GUIDialogPVRGuideOSD.h @@ -25,22 +25,25 @@ class CFileItemList; -class CGUIDialogPVRGuideOSD : public CGUIDialog +namespace PVR { -public: - CGUIDialogPVRGuideOSD(void); - virtual ~CGUIDialogPVRGuideOSD(void); - virtual bool OnMessage(CGUIMessage& message); - virtual void OnWindowLoaded(); - virtual void OnWindowUnload(); + class CGUIDialogPVRGuideOSD : public CGUIDialog + { + public: + CGUIDialogPVRGuideOSD(void); + virtual ~CGUIDialogPVRGuideOSD(void); + virtual bool OnMessage(CGUIMessage& message); + virtual void OnWindowLoaded(); + virtual void OnWindowUnload(); -protected: - void ShowInfo(int iItem); - void Clear(); - void Update(); + protected: + void ShowInfo(int iItem); + void Clear(); + void Update(); - CGUIControl *GetFirstFocusableControl(int id); + CGUIControl *GetFirstFocusableControl(int id); - CFileItemList *m_vecItems; - CGUIViewControl m_viewControl; -}; + CFileItemList *m_vecItems; + CGUIViewControl m_viewControl; + }; +} diff --git a/xbmc/pvr/dialogs/GUIDialogPVRGuideSearch.cpp b/xbmc/pvr/dialogs/GUIDialogPVRGuideSearch.cpp index 1f5e75775338f..0e0bba59458b3 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRGuideSearch.cpp +++ b/xbmc/pvr/dialogs/GUIDialogPVRGuideSearch.cpp @@ -33,6 +33,7 @@ #include "pvr/channels/PVRChannelGroupsContainer.h" using namespace std; +using namespace PVR; #define CONTROL_EDIT_SEARCH 9 #define CONTROL_BTN_INC_DESC 10 diff --git a/xbmc/pvr/dialogs/GUIDialogPVRGuideSearch.h b/xbmc/pvr/dialogs/GUIDialogPVRGuideSearch.h index f84539f3f8ebc..0b59ee821aac9 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRGuideSearch.h +++ b/xbmc/pvr/dialogs/GUIDialogPVRGuideSearch.h @@ -22,25 +22,28 @@ #include "guilib/GUIDialog.h" -struct PVREpgSearchFilter; - -class CGUIDialogPVRGuideSearch : public CGUIDialog +namespace PVR { -public: - CGUIDialogPVRGuideSearch(void); - virtual ~CGUIDialogPVRGuideSearch(void) {} - virtual bool OnMessage(CGUIMessage& message); - virtual void OnWindowLoaded(); + struct PVREpgSearchFilter; + + class CGUIDialogPVRGuideSearch : public CGUIDialog + { + public: + CGUIDialogPVRGuideSearch(void); + virtual ~CGUIDialogPVRGuideSearch(void) {} + virtual bool OnMessage(CGUIMessage& message); + virtual void OnWindowLoaded(); - void SetFilterData(PVREpgSearchFilter *searchfilter) { m_searchfilter = searchfilter; } - bool IsConfirmed() const { return m_bConfirmed; } - bool IsCanceled() const { return m_bCanceled; } - void OnSearch(); + void SetFilterData(PVREpgSearchFilter *searchfilter) { m_searchfilter = searchfilter; } + bool IsConfirmed() const { return m_bConfirmed; } + bool IsCanceled() const { return m_bCanceled; } + void OnSearch(); -protected: - void Update(); + protected: + void Update(); - bool m_bConfirmed; - bool m_bCanceled; - PVREpgSearchFilter *m_searchfilter; -}; + bool m_bConfirmed; + bool m_bCanceled; + PVREpgSearchFilter *m_searchfilter; + }; +} diff --git a/xbmc/pvr/dialogs/GUIDialogPVRRecordingInfo.cpp b/xbmc/pvr/dialogs/GUIDialogPVRRecordingInfo.cpp index bd7862c6ed48f..babd22a719c04 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRRecordingInfo.cpp +++ b/xbmc/pvr/dialogs/GUIDialogPVRRecordingInfo.cpp @@ -24,6 +24,7 @@ #include "FileItem.h" using namespace std; +using namespace PVR; #define CONTROL_BTN_OK 10 diff --git a/xbmc/pvr/dialogs/GUIDialogPVRRecordingInfo.h b/xbmc/pvr/dialogs/GUIDialogPVRRecordingInfo.h index 89d0808c83a63..f9d686d9cef4c 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRRecordingInfo.h +++ b/xbmc/pvr/dialogs/GUIDialogPVRRecordingInfo.h @@ -22,18 +22,20 @@ #include "guilib/GUIDialog.h" -class CGUIDialogPVRRecordingInfo : public CGUIDialog +namespace PVR { -public: - CGUIDialogPVRRecordingInfo(void); - virtual ~CGUIDialogPVRRecordingInfo(void) {} - virtual bool OnMessage(CGUIMessage& message); - virtual bool HasListItems() const { return true; }; - virtual CFileItemPtr GetCurrentListItem(int offset = 0); + class CGUIDialogPVRRecordingInfo : public CGUIDialog + { + public: + CGUIDialogPVRRecordingInfo(void); + virtual ~CGUIDialogPVRRecordingInfo(void) {} + virtual bool OnMessage(CGUIMessage& message); + virtual bool HasListItems() const { return true; }; + virtual CFileItemPtr GetCurrentListItem(int offset = 0); - void SetRecording(const CFileItem *item); - -protected: - CFileItemPtr m_recordItem; -}; + void SetRecording(const CFileItem *item); + protected: + CFileItemPtr m_recordItem; + }; +} diff --git a/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.cpp b/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.cpp index 6420d5ff18f82..4bd64ee06c490 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.cpp +++ b/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.cpp @@ -30,6 +30,7 @@ #include "pvr/channels/PVRChannelGroupsContainer.h" using namespace std; +using namespace PVR; #define CONTROL_TMR_ACTIVE 20 #define CONTROL_TMR_CHNAME_TV 21 diff --git a/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.h b/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.h index 8d16807b8635b..4eb7605dd6129 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.h +++ b/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.h @@ -25,33 +25,36 @@ #include "guilib/GUIListItem.h" class CFileItem; -class CPVRTimerInfoTag; -class CGUIDialogPVRTimerSettings : public CGUIDialogSettings +namespace PVR { -public: - CGUIDialogPVRTimerSettings(void); - virtual ~CGUIDialogPVRTimerSettings(void) {} - void SetTimer(CFileItem *item); - bool GetOK() { return !m_cancelled; } + class CPVRTimerInfoTag; -protected: - virtual void CreateSettings(); - virtual void OnSettingChanged(SettingInfo &setting); - virtual void OnOkay(); - virtual void OnCancel() { m_cancelled = true; } - virtual void AddChannelNames(CFileItemList &channelsList, SETTINGSTRINGS &channelNames, bool bRadio); - virtual void SetWeekdaySettingFromTimer(const CPVRTimerInfoTag &timer); - virtual void SetTimerFromWeekdaySetting(CPVRTimerInfoTag &timer); + class CGUIDialogPVRTimerSettings : public CGUIDialogSettings + { + public: + CGUIDialogPVRTimerSettings(void); + virtual ~CGUIDialogPVRTimerSettings(void) {} + void SetTimer(CFileItem *item); + bool GetOK() { return !m_cancelled; } - SYSTEMTIME timerStartTime; - SYSTEMTIME timerEndTime; - CStdString timerStartTimeStr; - CStdString timerEndTimeStr; - int m_tmp_iFirstDay;; - int m_tmp_day; + protected: + virtual void CreateSettings(); + virtual void OnSettingChanged(SettingInfo &setting); + virtual void OnOkay(); + virtual void OnCancel() { m_cancelled = true; } + virtual void AddChannelNames(CFileItemList &channelsList, SETTINGSTRINGS &channelNames, bool bRadio); + virtual void SetWeekdaySettingFromTimer(const CPVRTimerInfoTag &timer); + virtual void SetTimerFromWeekdaySetting(CPVRTimerInfoTag &timer); - CFileItem *m_timerItem; - bool m_cancelled; -}; + SYSTEMTIME timerStartTime; + SYSTEMTIME timerEndTime; + CStdString timerStartTimeStr; + CStdString timerEndTimeStr; + int m_tmp_iFirstDay;; + int m_tmp_day; + CFileItem *m_timerItem; + bool m_cancelled; + }; +} diff --git a/xbmc/pvr/epg/PVREpg.cpp b/xbmc/pvr/epg/PVREpg.cpp index ef7588bfeaaf0..0bd718bbf9832 100644 --- a/xbmc/pvr/epg/PVREpg.cpp +++ b/xbmc/pvr/epg/PVREpg.cpp @@ -32,11 +32,12 @@ #include "epg/EpgContainer.h" #include "epg/EpgDatabase.h" +using namespace PVR; + CPVREpg::CPVREpg(CPVRChannel *channel) : CEpg(channel->ChannelID(), channel->ChannelName(), channel->EPGScraper()) { - m_Channel = channel; - m_bHasChannel = true; + SetChannel(channel); } bool CPVREpg::HasValidEntries(void) const @@ -123,8 +124,7 @@ bool CPVREpg::Update(const CEpg &epg, bool bUpdateDb /* = false */) { bool bReturn = CEpg::Update(epg, false); // don't update the db yet - m_Channel = epg.m_Channel; - m_bHasChannel = true; + SetChannel((CPVRChannel*) epg.Channel()); if (bUpdateDb) bReturn = Persist(false); diff --git a/xbmc/pvr/epg/PVREpg.h b/xbmc/pvr/epg/PVREpg.h index a04088bd60cba..c5eaa260f3496 100644 --- a/xbmc/pvr/epg/PVREpg.h +++ b/xbmc/pvr/epg/PVREpg.h @@ -25,75 +25,78 @@ #include "PVREpgInfoTag.h" #include "addons/include/xbmc_pvr_types.h" -class CPVREpgContainer; +namespace PVR +{ + class CPVREpgContainer; -/** PVR EPG class */ + /** PVR EPG class */ -class CPVREpg : public CEpg -{ -private: - /*! - * @brief Update the EPG from a scraper set in the channel tag. - * @param start Get entries with a start date after this time. - * @param end Get entries with an end date before this time. - * @return True if the update was successful, false otherwise. - */ - bool UpdateFromScraper(time_t start, time_t end); + class CPVREpg : public CEpg + { + private: + /*! + * @brief Update the EPG from a scraper set in the channel tag. + * @param start Get entries with a start date after this time. + * @param end Get entries with an end date before this time. + * @return True if the update was successful, false otherwise. + */ + bool UpdateFromScraper(time_t start, time_t end); - /*! - * @brief Create a new tag. - * @return The new tag. - */ - CEpgInfoTag *CreateTag(void); + /*! + * @brief Create a new tag. + * @return The new tag. + */ + CEpgInfoTag *CreateTag(void); - bool LoadFromClients(time_t start, time_t end); + bool LoadFromClients(time_t start, time_t end); -protected: - /*! - * @brief Update this table's info with the given info. Doesn't change the EpgID. - * @param epg The new info. - * @param bUpdateDb If true, persist the changes. - * @return True if the update was successful, false otherwise. - */ - bool Update(const CEpg &epg, bool bUpdateDb = false); + protected: + /*! + * @brief Update this table's info with the given info. Doesn't change the EpgID. + * @param epg The new info. + * @param bUpdateDb If true, persist the changes. + * @return True if the update was successful, false otherwise. + */ + bool Update(const CEpg &epg, bool bUpdateDb = false); -public: - /*! - * @brief Create a new EPG instance for a channel. - * @param channel The channel to create the EPG for. - */ - CPVREpg(CPVRChannel *channel); + public: + /*! + * @brief Create a new EPG instance for a channel. + * @param channel The channel to create the EPG for. + */ + CPVREpg(CPVRChannel *channel); - /*! - * @brief Check whether this EPG contains valid entries. - * @return True if it has valid entries, false if not. - */ - bool HasValidEntries(void) const; + /*! + * @brief Check whether this EPG contains valid entries. + * @return True if it has valid entries, false if not. + */ + bool HasValidEntries(void) const; - /*! - * @brief Remove all entries from this EPG that finished before the given time - * and that have no timers set. - * @param Time Delete entries with an end time before this time. - */ - void Cleanup(const CDateTime &Time); + /*! + * @brief Remove all entries from this EPG that finished before the given time + * and that have no timers set. + * @param Time Delete entries with an end time before this time. + */ + void Cleanup(const CDateTime &Time); - /*! - * @brief Remove all entries from this EPG. - */ - void Clear(void); + /*! + * @brief Remove all entries from this EPG. + */ + void Clear(void); - /*! - * @brief Update an entry in this EPG. - * @param data The tag to update. - * @param bUpdateDatabase If set to true, this event will be persisted in the database. - * @return True if it was updated successfully, false otherwise. - */ - bool UpdateEntry(const EPG_TAG *data, bool bUpdateDatabase = false); - bool UpdateFromClient(const EPG_TAG *data, bool bUpdateDatabase = false) { return UpdateEntry(data, bUpdateDatabase); }; + /*! + * @brief Update an entry in this EPG. + * @param data The tag to update. + * @param bUpdateDatabase If set to true, this event will be persisted in the database. + * @return True if it was updated successfully, false otherwise. + */ + bool UpdateEntry(const EPG_TAG *data, bool bUpdateDatabase = false); + bool UpdateFromClient(const EPG_TAG *data, bool bUpdateDatabase = false) { return UpdateEntry(data, bUpdateDatabase); }; - /*! - * @brief True if this is a table for a radio channel, false if it's for TV. - * @return True if this is a table for a radio channel, false if it's for TV. - */ - bool IsRadio(void) const; -}; + /*! + * @brief True if this is a table for a radio channel, false if it's for TV. + * @return True if this is a table for a radio channel, false if it's for TV. + */ + bool IsRadio(void) const; + }; +} diff --git a/xbmc/pvr/epg/PVREpgContainer.cpp b/xbmc/pvr/epg/PVREpgContainer.cpp index 32705b765c897..a1d4d3bd565e2 100644 --- a/xbmc/pvr/epg/PVREpgContainer.cpp +++ b/xbmc/pvr/epg/PVREpgContainer.cpp @@ -30,6 +30,7 @@ #include "utils/log.h" using namespace std; +using namespace PVR; void CPVREpgContainer::Clear(bool bClearDb /* = false */) { @@ -56,9 +57,8 @@ bool CPVREpgContainer::CreateChannelEpgs(void) channel->GetEPG(); else { - channel->m_EPG = (CPVREpg *) epg; - epg->m_Channel = channel; - epg->m_bHasChannel = true; + channel->m_EPG = (CPVREpg *) epg; + epg->SetChannel(channel); } } } diff --git a/xbmc/pvr/epg/PVREpgContainer.h b/xbmc/pvr/epg/PVREpgContainer.h index ede1f484acc0d..c0fb2cb09feae 100644 --- a/xbmc/pvr/epg/PVREpgContainer.h +++ b/xbmc/pvr/epg/PVREpgContainer.h @@ -25,83 +25,86 @@ #include "PVREpg.h" #include "PVREpgSearchFilter.h" -class CPVREpgContainer : public CEpgContainer +namespace PVR { - friend class CPVREpg; + class CPVREpgContainer : public CEpgContainer + { + friend class CPVREpg; -private: - /*! - * @brief Create an EPG table for each channel. - * @return True if all tables were created successfully, false otherwise. - */ - bool CreateChannelEpgs(void); + private: + /*! + * @brief Create an EPG table for each channel. + * @return True if all tables were created successfully, false otherwise. + */ + bool CreateChannelEpgs(void); - /*! - * @brief A hook that is called after the tables have been loaded from the database. - * @return True if the hook was executed successfully, false otherwise. - */ - bool AutoCreateTablesHook(void); + /*! + * @brief A hook that is called after the tables have been loaded from the database. + * @return True if the hook was executed successfully, false otherwise. + */ + bool AutoCreateTablesHook(void); - /*! - * @brief Create a new EPG table. - * @param iEpgId The table ID or -1 to create a new one. - * @return The new table. - */ - CEpg *CreateEpg(int iEpgId); + /*! + * @brief Create a new EPG table. + * @param iEpgId The table ID or -1 to create a new one. + * @return The new table. + */ + CEpg *CreateEpg(int iEpgId); - bool UpdateEPG(bool bShowProgress = false); + bool UpdateEPG(bool bShowProgress = false); -public: + public: - /*! - * @brief Clear all EPG entries. - * @param bClearDb Clear the database too if true. - */ - void Clear(bool bClearDb = false); + /*! + * @brief Clear all EPG entries. + * @param bClearDb Clear the database too if true. + */ + void Clear(bool bClearDb = false); - /*! - * @brief Get all EPG tables and apply a filter. - * @param results The fileitem list to store the results in. - * @param filter The filter to apply. - * @return The amount of entries that were added. - */ - int GetEPGSearch(CFileItemList* results, const PVREpgSearchFilter &filter); + /*! + * @brief Get all EPG tables and apply a filter. + * @param results The fileitem list to store the results in. + * @param filter The filter to apply. + * @return The amount of entries that were added. + */ + int GetEPGSearch(CFileItemList* results, const PVREpgSearchFilter &filter); - /*! - * @brief Get all EPG tables. - * @param results The fileitem list to store the results in. - * @param bRadio Get radio items if true and TV items if false. - * @return The amount of entries that were added. - */ - int GetEPGAll(CFileItemList* results, bool bRadio = false); + /*! + * @brief Get all EPG tables. + * @param results The fileitem list to store the results in. + * @param bRadio Get radio items if true and TV items if false. + * @return The amount of entries that were added. + */ + int GetEPGAll(CFileItemList* results, bool bRadio = false); - /*! - * @brief Get all entries that are active now. - * @param results The fileitem list to store the results in. - * @param bRadio Get radio items if true and TV items if false. - * @return The amount of entries that were added. - */ - int GetEPGNow(CFileItemList* results, bool bRadio = false); + /*! + * @brief Get all entries that are active now. + * @param results The fileitem list to store the results in. + * @param bRadio Get radio items if true and TV items if false. + * @return The amount of entries that were added. + */ + int GetEPGNow(CFileItemList* results, bool bRadio = false); - /*! - * @brief Get all entries that will be active next. - * @param results The fileitem list to store the results in. - * @param bRadio Get radio items if true and TV items if false. - * @return The amount of entries that were added. - */ - int GetEPGNext(CFileItemList* results, bool bRadio = false); + /*! + * @brief Get all entries that will be active next. + * @param results The fileitem list to store the results in. + * @param bRadio Get radio items if true and TV items if false. + * @return The amount of entries that were added. + */ + int GetEPGNext(CFileItemList* results, bool bRadio = false); - /*! - * @brief Get the start time of the first entry. - * @param bRadio Get radio items if true and TV items if false. - * @return The start time. - */ - const CDateTime GetFirstEPGDate(bool bRadio = false); + /*! + * @brief Get the start time of the first entry. + * @param bRadio Get radio items if true and TV items if false. + * @return The start time. + */ + const CDateTime GetFirstEPGDate(bool bRadio = false); - /*! - * @brief Get the end time of the last entry. - * @param bRadio Get radio items if true and TV items if false. - * @return The end time. - */ - const CDateTime GetLastEPGDate(bool bRadio = false); -}; + /*! + * @brief Get the end time of the last entry. + * @param bRadio Get radio items if true and TV items if false. + * @return The end time. + */ + const CDateTime GetLastEPGDate(bool bRadio = false); + }; +} diff --git a/xbmc/pvr/epg/PVREpgInfoTag.cpp b/xbmc/pvr/epg/PVREpgInfoTag.cpp index 30919658d4908..e492353c6d6b7 100644 --- a/xbmc/pvr/epg/PVREpgInfoTag.cpp +++ b/xbmc/pvr/epg/PVREpgInfoTag.cpp @@ -29,6 +29,7 @@ #include "settings/AdvancedSettings.h" using namespace std; +using namespace PVR; CPVREpgInfoTag::CPVREpgInfoTag(const EPG_TAG &data) : CEpgInfoTag() diff --git a/xbmc/pvr/epg/PVREpgInfoTag.h b/xbmc/pvr/epg/PVREpgInfoTag.h index 026273ab535e7..f3cb714106456 100644 --- a/xbmc/pvr/epg/PVREpgInfoTag.h +++ b/xbmc/pvr/epg/PVREpgInfoTag.h @@ -25,70 +25,73 @@ #include "epg/EpgInfoTag.h" #include "addons/include/xbmc_pvr_types.h" -class CPVREpg; -class CPVRTimerInfoTag; - -/** an EPG info tag */ - -class CPVREpgInfoTag : public CEpgInfoTag +namespace PVR { - friend class CPVREpg; - -private: - const CPVRTimerInfoTag * m_Timer; /*!< a pointer to a timer for this event or NULL if there is none */ - bool m_isRecording; // XXX - -public: - /*! - * @brief Create a new empty EPG infotag. - */ - CPVREpgInfoTag(void) { Reset(); }; - - /*! - * @brief Create a new EPG infotag with 'data' as content. - * @param data The tag's content. - */ - CPVREpgInfoTag(const EPG_TAG &data); - - /*! - * @brief Clear this event. - */ - void Reset(); - - /*! - * @brief Get the channel that plays this event. - * @return a pointer to the channel. - */ - const CPVRChannel *ChannelTag(void) const; - - /*! - * @brief Check whether this event has an active timer tag. - * @return True if it has an active timer tag, false if not. - */ - bool HasTimer() const { return !(m_Timer == NULL); } - - /*! - * @brief Set a timer for this event or NULL to clear it. - * @param newTimer The new timer value. - */ - void SetTimer(const CPVRTimerInfoTag *newTimer); - - /*! - * @brief Get a pointer to the timer for event or NULL if there is none. - * @return A pointer to the timer for event or NULL if there is none. - */ - const CPVRTimerInfoTag *Timer(void) const { return m_Timer; } - - /*! - * @brief Update the value of m_strFileNameAndPath after a value changed. - */ - void UpdatePath(void); - - /*! - * @brief Update the information in this tag with the info in the given tag. - * @param tag The new info. - */ - void Update(const EPG_TAG &tag); - - const CStdString &Icon(void) const; -}; + class CPVREpg; + class CPVRTimerInfoTag; + + /** an EPG info tag */ + + class CPVREpgInfoTag : public CEpgInfoTag + { + friend class CPVREpg; + + private: + const CPVRTimerInfoTag * m_Timer; /*!< a pointer to a timer for this event or NULL if there is none */ + bool m_isRecording; // XXX + + public: + /*! + * @brief Create a new empty EPG infotag. + */ + CPVREpgInfoTag(void) { Reset(); }; + + /*! + * @brief Create a new EPG infotag with 'data' as content. + * @param data The tag's content. + */ + CPVREpgInfoTag(const EPG_TAG &data); + + /*! + * @brief Clear this event. + */ + void Reset(); + + /*! + * @brief Get the channel that plays this event. + * @return a pointer to the channel. + */ + const CPVRChannel *ChannelTag(void) const; + + /*! + * @brief Check whether this event has an active timer tag. + * @return True if it has an active timer tag, false if not. + */ + bool HasTimer() const { return !(m_Timer == NULL); } + + /*! + * @brief Set a timer for this event or NULL to clear it. + * @param newTimer The new timer value. + */ + void SetTimer(const CPVRTimerInfoTag *newTimer); + + /*! + * @brief Get a pointer to the timer for event or NULL if there is none. + * @return A pointer to the timer for event or NULL if there is none. + */ + const CPVRTimerInfoTag *Timer(void) const { return m_Timer; } + + /*! + * @brief Update the value of m_strFileNameAndPath after a value changed. + */ + void UpdatePath(void); + + /*! + * @brief Update the information in this tag with the info in the given tag. + * @param tag The new info. + */ + void Update(const EPG_TAG &tag); + + const CStdString &Icon(void) const; + }; +} diff --git a/xbmc/pvr/epg/PVREpgSearchFilter.cpp b/xbmc/pvr/epg/PVREpgSearchFilter.cpp index 94efaea16b474..4105d0d38d321 100644 --- a/xbmc/pvr/epg/PVREpgSearchFilter.cpp +++ b/xbmc/pvr/epg/PVREpgSearchFilter.cpp @@ -28,6 +28,7 @@ #include "pvr/channels/PVRChannelGroupsContainer.h" using namespace std; +using namespace PVR; void PVREpgSearchFilter::Reset() { diff --git a/xbmc/pvr/epg/PVREpgSearchFilter.h b/xbmc/pvr/epg/PVREpgSearchFilter.h index 2d44c81fadea5..61eb9846ccda3 100644 --- a/xbmc/pvr/epg/PVREpgSearchFilter.h +++ b/xbmc/pvr/epg/PVREpgSearchFilter.h @@ -24,27 +24,30 @@ #include "XBDateTime.h" #include "epg/EpgSearchFilter.h" -class CPVREpgInfoTag; +namespace PVR +{ + class CPVREpgInfoTag; -/** Filter to apply with on a CPVREpgInfoTag */ + /** Filter to apply with on a CPVREpgInfoTag */ -struct PVREpgSearchFilter : public EpgSearchFilter -{ - /*! - * @brief Clear this filter. - */ - void Reset(); + struct PVREpgSearchFilter : public EpgSearchFilter + { + /*! + * @brief Clear this filter. + */ + void Reset(); - /*! - * @brief Check if a tag will be filtered or not. - * @param tag The tag to check. - * @return True if this tag matches the filter, false if not. - */ - bool FilterEntry(const CPVREpgInfoTag &tag) const; + /*! + * @brief Check if a tag will be filtered or not. + * @param tag The tag to check. + * @return True if this tag matches the filter, false if not. + */ + bool FilterEntry(const CPVREpgInfoTag &tag) const; - int m_iChannelNumber; /*!< The channel number in XBMC */ - bool m_bFTAOnly; /*!< Free to air only or not */ - int m_iChannelGroup; /*!< The group this channel belongs to */ - bool m_bIgnorePresentTimers; /*!< True to ignore currently present timers (future recordings), false if not */ - bool m_bIgnorePresentRecordings; /*!< True to ignore currently active recordings, false if not */ -}; + int m_iChannelNumber; /*!< The channel number in XBMC */ + bool m_bFTAOnly; /*!< Free to air only or not */ + int m_iChannelGroup; /*!< The group this channel belongs to */ + bool m_bIgnorePresentTimers; /*!< True to ignore currently present timers (future recordings), false if not */ + bool m_bIgnorePresentRecordings; /*!< True to ignore currently active recordings, false if not */ + }; +} diff --git a/xbmc/pvr/recordings/PVRRecording.cpp b/xbmc/pvr/recordings/PVRRecording.cpp index 3a57df4045bae..79314218971fa 100644 --- a/xbmc/pvr/recordings/PVRRecording.cpp +++ b/xbmc/pvr/recordings/PVRRecording.cpp @@ -25,6 +25,8 @@ #include "PVRRecordings.h" #include "pvr/addons/PVRClients.h" +using namespace PVR; + CPVRRecording::CPVRRecording() { Reset(); diff --git a/xbmc/pvr/recordings/PVRRecording.h b/xbmc/pvr/recordings/PVRRecording.h index 734ab7082e0c7..d7227c6954945 100644 --- a/xbmc/pvr/recordings/PVRRecording.h +++ b/xbmc/pvr/recordings/PVRRecording.h @@ -40,63 +40,66 @@ #include "video/VideoInfoTag.h" #include "XBDateTime.h" -class CPVRRecording : public CVideoInfoTag +namespace PVR { -public: - int m_iClientId; /*!< ID of the backend */ - int m_iClientIndex; /*!< index number of the recording on the client, -1 for unknown */ - CStdString m_strChannelName; /*!< name of the channel this was recorded from */ - CDateTimeSpan m_duration; /*!< duration of this recording */ - int m_iPriority; /*!< priority of this recording */ - int m_iLifetime; /*!< lifetime of this recording */ - CStdString m_strStreamURL; /*!< stream URL. if empty use pvr client */ - CStdString m_strDirectory; /*!< directory of this recording on the client */ + class CPVRRecording : public CVideoInfoTag + { + public: + int m_iClientId; /*!< ID of the backend */ + int m_iClientIndex; /*!< index number of the recording on the client, -1 for unknown */ + CStdString m_strChannelName; /*!< name of the channel this was recorded from */ + CDateTimeSpan m_duration; /*!< duration of this recording */ + int m_iPriority; /*!< priority of this recording */ + int m_iLifetime; /*!< lifetime of this recording */ + CStdString m_strStreamURL; /*!< stream URL. if empty use pvr client */ + CStdString m_strDirectory; /*!< directory of this recording on the client */ - CPVRRecording(void); - CPVRRecording(const PVR_RECORDING &recording, unsigned int iClientId); - virtual ~CPVRRecording() {}; + CPVRRecording(void); + CPVRRecording(const PVR_RECORDING &recording, unsigned int iClientId); + virtual ~CPVRRecording() {}; - bool operator ==(const CPVRRecording& right) const; - bool operator !=(const CPVRRecording& right) const; + bool operator ==(const CPVRRecording& right) const; + bool operator !=(const CPVRRecording& right) const; - /*! - * @brief Reset this tag to it's initial state. - */ - void Reset(void); + /*! + * @brief Reset this tag to it's initial state. + */ + void Reset(void); - /*! - * @brief The duration of this recording in minutes. - * @return The duration. - */ - int GetDuration() const; + /*! + * @brief The duration of this recording in minutes. + * @return The duration. + */ + int GetDuration() const; - /*! - * @brief Delete this recording on the client (if supported). - * @return True if it was deleted successfully, false otherwise. - */ - bool Delete(void); + /*! + * @brief Delete this recording on the client (if supported). + * @return True if it was deleted successfully, false otherwise. + */ + bool Delete(void); - /*! - * @brief Rename this recording on the client (if supported). - * @param strNewName The new name. - * @return True if it was renamed successfully, false otherwise. - */ - bool Rename(const CStdString &strNewName); + /*! + * @brief Rename this recording on the client (if supported). + * @param strNewName The new name. + * @return True if it was renamed successfully, false otherwise. + */ + bool Rename(const CStdString &strNewName); - /*! - * @brief Update this tag with the contents of the given tag. - * @param tag The new tag info. - */ - void Update(const CPVRRecording &tag); + /*! + * @brief Update this tag with the contents of the given tag. + * @param tag The new tag info. + */ + void Update(const CPVRRecording &tag); - const CDateTime &RecordingTimeAsUTC(void) const { return m_recordingTime; } - const CDateTime &RecordingTimeAsLocalTime(void) const; - void SetRecordingTimeFromUTC(CDateTime &recordingTime) { m_recordingTime = recordingTime; } - void SetRecordingTimeFromLocalTime(CDateTime &recordingTime) { m_recordingTime = recordingTime.GetAsUTCDateTime(); } + const CDateTime &RecordingTimeAsUTC(void) const { return m_recordingTime; } + const CDateTime &RecordingTimeAsLocalTime(void) const; + void SetRecordingTimeFromUTC(CDateTime &recordingTime) { m_recordingTime = recordingTime; } + void SetRecordingTimeFromLocalTime(CDateTime &recordingTime) { m_recordingTime = recordingTime.GetAsUTCDateTime(); } -private: - CDateTime m_recordingTime; /*!< start time of the recording */ + private: + CDateTime m_recordingTime; /*!< start time of the recording */ - void UpdatePath(void); - void DisplayError(PVR_ERROR err) const; -}; + void UpdatePath(void); + void DisplayError(PVR_ERROR err) const; + }; +} diff --git a/xbmc/pvr/recordings/PVRRecordings.cpp b/xbmc/pvr/recordings/PVRRecordings.cpp index 64a3d02551e19..1bea42a2b4a0b 100644 --- a/xbmc/pvr/recordings/PVRRecordings.cpp +++ b/xbmc/pvr/recordings/PVRRecordings.cpp @@ -33,6 +33,8 @@ #include "pvr/addons/PVRClients.h" #include "PVRRecordings.h" +using namespace PVR; + CPVRRecordings::CPVRRecordings(void) { m_bIsUpdating = false; diff --git a/xbmc/pvr/recordings/PVRRecordings.h b/xbmc/pvr/recordings/PVRRecordings.h index b5a66cc8ec1a7..f4e17a2e1d354 100644 --- a/xbmc/pvr/recordings/PVRRecordings.h +++ b/xbmc/pvr/recordings/PVRRecordings.h @@ -24,45 +24,47 @@ #include "XBDateTime.h" #include "threads/Thread.h" -class CPVRRecordings : public std::vector, - private CThread +namespace PVR { -private: - CCriticalSection m_critSection; - bool m_bIsUpdating; + class CPVRRecordings : public std::vector, + private CThread + { + private: + CCriticalSection m_critSection; + bool m_bIsUpdating; - virtual void UpdateFromClients(void); - virtual CStdString TrimSlashes(const CStdString &strOrig) const; - virtual const CStdString GetDirectoryFromPath(const CStdString &strPath, const CStdString &strBase) const; - virtual bool IsDirectoryMember(const CStdString &strDirectory, const CStdString &strEntryDirectory, bool bDirectMember = true) const; - virtual void GetContents(const CStdString &strDirectory, CFileItemList *results) const; - virtual void GetSubDirectories(const CStdString &strBase, CFileItemList *results, bool bAutoSkip = true) const; + virtual void UpdateFromClients(void); + virtual CStdString TrimSlashes(const CStdString &strOrig) const; + virtual const CStdString GetDirectoryFromPath(const CStdString &strPath, const CStdString &strBase) const; + virtual bool IsDirectoryMember(const CStdString &strDirectory, const CStdString &strEntryDirectory, bool bDirectMember = true) const; + virtual void GetContents(const CStdString &strDirectory, CFileItemList *results) const; + virtual void GetSubDirectories(const CStdString &strBase, CFileItemList *results, bool bAutoSkip = true) const; - virtual void ExecuteUpdate(void); - virtual void Process(void); + virtual void ExecuteUpdate(void); + virtual void Process(void); -public: - CPVRRecordings(void); - virtual ~CPVRRecordings(void) { Clear(); }; + public: + CPVRRecordings(void); + virtual ~CPVRRecordings(void) { Clear(); }; - int Load(); - void Unload(); - void Clear(); - void UpdateEntry(const CPVRRecording &tag); - void UpdateFromClient(const CPVRRecording &tag) { UpdateEntry(tag); } + int Load(); + void Unload(); + void Clear(); + void UpdateEntry(const CPVRRecording &tag); + void UpdateFromClient(const CPVRRecording &tag) { UpdateEntry(tag); } - /** - * @brief refresh the recordings list from the clients. - * @param bAsyncUpdate Try to update the recordings async. - */ - void Update(bool bAsyncUpdate = false); + /** + * @brief refresh the recordings list from the clients. + * @param bAsyncUpdate Try to update the recordings async. + */ + void Update(bool bAsyncUpdate = false); - int GetNumRecordings(); - int GetRecordings(CFileItemList* results); - bool DeleteRecording(const CFileItem &item); - bool RenameRecording(CFileItem &item, CStdString &strNewName); - - bool GetDirectory(const CStdString& strPath, CFileItemList &items); - CPVRRecording *GetByPath(CStdString &path); -}; + int GetNumRecordings(); + int GetRecordings(CFileItemList* results); + bool DeleteRecording(const CFileItem &item); + bool RenameRecording(CFileItem &item, CStdString &strNewName); + bool GetDirectory(const CStdString& strPath, CFileItemList &items); + CPVRRecording *GetByPath(CStdString &path); + }; +} diff --git a/xbmc/pvr/timers/PVRTimerInfoTag.cpp b/xbmc/pvr/timers/PVRTimerInfoTag.cpp index 739ad9653c24a..401c050f8c98c 100644 --- a/xbmc/pvr/timers/PVRTimerInfoTag.cpp +++ b/xbmc/pvr/timers/PVRTimerInfoTag.cpp @@ -31,6 +31,8 @@ #include "pvr/epg/PVREpgContainer.h" #include "pvr/addons/PVRClients.h" +using namespace PVR; + CPVRTimerInfoTag::CPVRTimerInfoTag(void) { m_strTitle = ""; diff --git a/xbmc/pvr/timers/PVRTimerInfoTag.h b/xbmc/pvr/timers/PVRTimerInfoTag.h index 007813e943674..112a18002ee0c 100644 --- a/xbmc/pvr/timers/PVRTimerInfoTag.h +++ b/xbmc/pvr/timers/PVRTimerInfoTag.h @@ -53,93 +53,97 @@ #include "../addons/include/xbmc_pvr_types.h" class CFileItem; -class CPVREpgInfoTag; -class CGUIDialogPVRTimerSettings; -class CPVRChannel; -class CPVRTimerInfoTag +namespace PVR { -public: - CStdString m_strTitle; /*!< @brief name of this timer */ - CStdString m_strDirectory; /*!< @brief directory where the recording must be stored */ - CStdString m_strSummary; /*!< @brief summary string with the time to show inside a GUI list */ - bool m_bIsActive; /*!< @brief active flag, if it is false backend ignore the timer */ - int m_iClientId; /*!< @brief ID of the backend */ - int m_iClientIndex; /*!< @brief index number of the tag, given by the backend, -1 for new */ - int m_iClientChannelUid; /*!< @brief channel uid */ - bool m_bIsRecording; /*!< @brief is this timer recording? */ - int m_iPriority; /*!< @brief priority of the timer */ - int m_iLifetime; /*!< @brief lifetime of the timer in days */ - bool m_bIsRepeating; /*!< @brief repeating timer if true, use the m_FirstDay and repeat flags */ - int m_iWeekdays; /*!< @brief bit based store of weekdays to repeat */ - CStdString m_strFileNameAndPath; /*!< @brief filename is only for reference */ - int m_iChannelNumber; /*!< @brief integer value of the channel number */ - bool m_bIsRadio; /*!< @brief is radio channel if set */ - CPVREpgInfoTag * m_epgInfo; - const CPVRChannel * m_channel; - unsigned int m_iMarginStart; /*!< @brief (optional) if set, the backend starts the recording iMarginStart minutes before startTime. */ - unsigned int m_iMarginEnd; /*!< @brief (optional) if set, the backend ends the recording iMarginEnd minutes after endTime. */ - CStdString m_strGenre; /*!< @brief genre of the timer */ - - CPVRTimerInfoTag(void); - CPVRTimerInfoTag(const PVR_TIMER &timer, CPVRChannel *channel, unsigned int iClientId); - - void Reset(); - - bool operator ==(const CPVRTimerInfoTag& right) const; - bool operator !=(const CPVRTimerInfoTag& right) const; - int Compare(const CPVRTimerInfoTag &timer) const; - - void UpdateSummary(void); - - void DisplayError(PVR_ERROR err) const; - - const CStdString &GetStatus() const; - - bool SetDuration(int iDuration); - - static CPVRTimerInfoTag *CreateFromEpg(const CPVREpgInfoTag &tag); - void SetEpgInfoTag(CPVREpgInfoTag *tag); - - int ChannelNumber(void) const; - CStdString ChannelName(void) const; - - bool UpdateEntry(const CPVRTimerInfoTag &tag); - - void UpdateEpgEvent(bool bClear = false); - - bool IsActive(void) const { return m_bIsActive && EndAsLocalTime() > CDateTime::GetCurrentDateTime(); } - bool IsRecording(void) const { return IsActive() && StartAsLocalTime() < CDateTime::GetCurrentDateTime(); } - - const CDateTime &StartAsUTC(void) const { return m_StartTime; } - const CDateTime &StartAsLocalTime(void) const; - void SetStartFromUTC(CDateTime &start) { m_StartTime = start; } - void SetStartFromLocalTime(CDateTime &start) { m_StartTime = start.GetAsUTCDateTime(); } - - const CDateTime &EndAsUTC(void) const { return m_StopTime; } - const CDateTime &EndAsLocalTime(void) const; - void SetEndFromUTC(CDateTime &end) { m_StopTime = end; } - void SetEndFromLocalTime(CDateTime &end) { m_StopTime = end.GetAsUTCDateTime(); } - - const CDateTime &FirstDayAsUTC(void) const { return m_FirstDay; } - const CDateTime &FirstDayAsLocalTime(void) const; - void SetFirstDayFromUTC(CDateTime &firstDay) { m_FirstDay = firstDay; } - void SetFirstDayFromLocalTime(CDateTime &firstDay) { m_FirstDay = firstDay.GetAsUTCDateTime(); } - - unsigned int MarginStart(void) const { return m_iMarginStart; } - void SetMarginStart(unsigned int iMinutes) { m_iMarginStart = iMinutes; } - - unsigned int MarginEnd(void) const { return m_iMarginEnd; } - void SetMarginEnd(unsigned int iMinutes) { m_iMarginEnd = iMinutes; } - - /* Client control functions */ - bool AddToClient(); - bool DeleteFromClient(bool bForce = false); - bool RenameOnClient(const CStdString &strNewName); - bool UpdateOnClient(); - -private: - CDateTime m_StartTime; /* start time */ - CDateTime m_StopTime; /* stop time */ - CDateTime m_FirstDay; /* if it is a repeating timer the first date it starts */ -}; + class CPVREpgInfoTag; + class CGUIDialogPVRTimerSettings; + class CPVRChannel; + + class CPVRTimerInfoTag + { + public: + CStdString m_strTitle; /*!< @brief name of this timer */ + CStdString m_strDirectory; /*!< @brief directory where the recording must be stored */ + CStdString m_strSummary; /*!< @brief summary string with the time to show inside a GUI list */ + bool m_bIsActive; /*!< @brief active flag, if it is false backend ignore the timer */ + int m_iClientId; /*!< @brief ID of the backend */ + int m_iClientIndex; /*!< @brief index number of the tag, given by the backend, -1 for new */ + int m_iClientChannelUid; /*!< @brief channel uid */ + bool m_bIsRecording; /*!< @brief is this timer recording? */ + int m_iPriority; /*!< @brief priority of the timer */ + int m_iLifetime; /*!< @brief lifetime of the timer in days */ + bool m_bIsRepeating; /*!< @brief repeating timer if true, use the m_FirstDay and repeat flags */ + int m_iWeekdays; /*!< @brief bit based store of weekdays to repeat */ + CStdString m_strFileNameAndPath; /*!< @brief filename is only for reference */ + int m_iChannelNumber; /*!< @brief integer value of the channel number */ + bool m_bIsRadio; /*!< @brief is radio channel if set */ + CPVREpgInfoTag * m_epgInfo; + const CPVRChannel * m_channel; + unsigned int m_iMarginStart; /*!< @brief (optional) if set, the backend starts the recording iMarginStart minutes before startTime. */ + unsigned int m_iMarginEnd; /*!< @brief (optional) if set, the backend ends the recording iMarginEnd minutes after endTime. */ + CStdString m_strGenre; /*!< @brief genre of the timer */ + + CPVRTimerInfoTag(void); + CPVRTimerInfoTag(const PVR_TIMER &timer, CPVRChannel *channel, unsigned int iClientId); + + void Reset(); + + bool operator ==(const CPVRTimerInfoTag& right) const; + bool operator !=(const CPVRTimerInfoTag& right) const; + int Compare(const CPVRTimerInfoTag &timer) const; + + void UpdateSummary(void); + + void DisplayError(PVR_ERROR err) const; + + const CStdString &GetStatus() const; + + bool SetDuration(int iDuration); + + static CPVRTimerInfoTag *CreateFromEpg(const CPVREpgInfoTag &tag); + void SetEpgInfoTag(CPVREpgInfoTag *tag); + + int ChannelNumber(void) const; + CStdString ChannelName(void) const; + + bool UpdateEntry(const CPVRTimerInfoTag &tag); + + void UpdateEpgEvent(bool bClear = false); + + bool IsActive(void) const { return m_bIsActive && EndAsLocalTime() > CDateTime::GetCurrentDateTime(); } + bool IsRecording(void) const { return IsActive() && StartAsLocalTime() < CDateTime::GetCurrentDateTime(); } + + const CDateTime &StartAsUTC(void) const { return m_StartTime; } + const CDateTime &StartAsLocalTime(void) const; + void SetStartFromUTC(CDateTime &start) { m_StartTime = start; } + void SetStartFromLocalTime(CDateTime &start) { m_StartTime = start.GetAsUTCDateTime(); } + + const CDateTime &EndAsUTC(void) const { return m_StopTime; } + const CDateTime &EndAsLocalTime(void) const; + void SetEndFromUTC(CDateTime &end) { m_StopTime = end; } + void SetEndFromLocalTime(CDateTime &end) { m_StopTime = end.GetAsUTCDateTime(); } + + const CDateTime &FirstDayAsUTC(void) const { return m_FirstDay; } + const CDateTime &FirstDayAsLocalTime(void) const; + void SetFirstDayFromUTC(CDateTime &firstDay) { m_FirstDay = firstDay; } + void SetFirstDayFromLocalTime(CDateTime &firstDay) { m_FirstDay = firstDay.GetAsUTCDateTime(); } + + unsigned int MarginStart(void) const { return m_iMarginStart; } + void SetMarginStart(unsigned int iMinutes) { m_iMarginStart = iMinutes; } + + unsigned int MarginEnd(void) const { return m_iMarginEnd; } + void SetMarginEnd(unsigned int iMinutes) { m_iMarginEnd = iMinutes; } + + /* Client control functions */ + bool AddToClient(); + bool DeleteFromClient(bool bForce = false); + bool RenameOnClient(const CStdString &strNewName); + bool UpdateOnClient(); + + private: + CDateTime m_StartTime; /* start time */ + CDateTime m_StopTime; /* stop time */ + CDateTime m_FirstDay; /* if it is a repeating timer the first date it starts */ + }; +} diff --git a/xbmc/pvr/timers/PVRTimers.cpp b/xbmc/pvr/timers/PVRTimers.cpp index d3463378f4e97..fa5a6fa357f14 100644 --- a/xbmc/pvr/timers/PVRTimers.cpp +++ b/xbmc/pvr/timers/PVRTimers.cpp @@ -33,6 +33,7 @@ #include "pvr/addons/PVRClients.h" using namespace std; +using namespace PVR; CPVRTimers::CPVRTimers(void) { diff --git a/xbmc/pvr/timers/PVRTimers.h b/xbmc/pvr/timers/PVRTimers.h index e2e36cdff2c42..bcedfd3a53685 100644 --- a/xbmc/pvr/timers/PVRTimers.h +++ b/xbmc/pvr/timers/PVRTimers.h @@ -28,164 +28,168 @@ class CFileItem; class CEpgInfoTag; -class CPVREpgInfoTag; -class CGUIDialogPVRTimerSettings; -class CPVRTimers : public std::vector, - public Observer, - public Observable, - private CThread +namespace PVR { -private: - CCriticalSection m_critSection; - bool m_bIsUpdating; - - /*! - * @brief Add timers to this container. - * @return The amount of timers that were added. - */ - int LoadFromClients(void); - - void Sort(void); - virtual bool ExecuteUpdate(void); - virtual void Process(void); - -public: - CPVRTimers(void); - - /** - * Load the timers from the clients. - * Returns the amount of timers that were added. - */ - int Load(); - - /** - * Clear this timer list. - */ - void Unload(); - - /** - * @brief refresh the channel list from the clients. - * @param bAsyncUpdate Try to update the timers async. - */ - bool Update(bool bAsyncUpdate = false); - - /** - * Update a timer entry in this container. - */ - bool UpdateEntry(const CPVRTimerInfoTag &timer); - bool UpdateFromClient(const CPVRTimerInfoTag &timer) { return UpdateEntry(timer); } - - /********** getters **********/ - - /** - * Get all known timers. - */ - int GetTimers(CFileItemList* results); - - /** - * The timer that will be active next. - * Returns false if there is none. - */ - bool GetNextActiveTimer(CPVRTimerInfoTag *tag); - - int GetActiveTimers(std::vector *tags); - - /** - * The amount of timers in this container. - */ - int GetNumTimers() const; - - int GetNumActiveTimers(void) const; - - int GetNumActiveRecordings(void) const; - - bool GetTimerByIndex(unsigned int iIndex, CPVRTimerInfoTag *timer) const; - - /** - * Get the directory for a path. - */ - bool GetDirectory(const CStdString& strPath, CFileItemList &items); - - /********** channel methods **********/ - - /** - * Check if there are any active timers on a channel. - */ - bool ChannelHasTimers(const CPVRChannel &channel); - - /*! - * @brief Delete all timers on a channel. - * @param channel The channel to delete the timers for. - * @param bDeleteRepeating True to delete repeating events too, false otherwise. - * @param bCurrentlyActiveOnly True to delete timers that are currently running only. - * @return True if timers any were deleted, false otherwise. - */ - bool DeleteTimersOnChannel(const CPVRChannel &channel, bool bDeleteRepeating = true, bool bCurrentlyActiveOnly = false); - - /*! - * @brief Create a new instant timer on a channel. - * @param channel The channel to create the timer on. - * @param bStartTimer True to start the timer instantly, false otherwise. - * @return The new timer or NULL if it couldn't be created. - */ - CPVRTimerInfoTag *InstantTimer(CPVRChannel *channel, bool bStartTimer = true); - - /********** static methods **********/ - - /** - * Add a timer to the client. - * True if it was sent correctly, false if not. - */ - static bool AddTimer(const CFileItem &item); - - /** - * Add a timer to the client. - * True if it was sent correctly, false if not. - */ - static bool AddTimer(CPVRTimerInfoTag &item); - - /** - * Delete a timer on the client. - * True if it was sent correctly, false if not. - */ - static bool DeleteTimer(const CFileItem &item, bool bForce = false); - - /** - * Delete a timer on the client. - * True if it was sent correctly, false if not. - */ - static bool DeleteTimer(CPVRTimerInfoTag &item, bool bForce = false); - - /** - * Rename a timer on the client. - * True if it was sent correctly, false if not. - */ - static bool RenameTimer(CFileItem &item, const CStdString &strNewName); - - /** - * Rename a timer on the client. - * True if it was sent correctly, false if not. - */ - static bool RenameTimer(CPVRTimerInfoTag &item, const CStdString &strNewName); - - /** - * Get updated timer information from the client. - * True if it was requested correctly, false if not. - */ - static bool UpdateTimer(const CFileItem &item); - - /** - * Get updated timer information from the client. - * True if it was requested correctly, false if not. - */ - static bool UpdateTimer(CPVRTimerInfoTag &item); - - bool IsRecording(void); - bool UpdateEntries(CPVRTimers *timers); - CPVRTimerInfoTag *GetByClient(int iClientId, int iClientTimerId); - CPVRTimerInfoTag *GetMatch(const CEpgInfoTag *Epg); - CPVRTimerInfoTag *GetMatch(const CFileItem *item); - virtual void Notify(const Observable &obs, const CStdString& msg); - bool IsRecordingOnChannel(const CPVRChannel &channel) const; -}; + class CPVREpgInfoTag; + class CGUIDialogPVRTimerSettings; + + class CPVRTimers : public std::vector, + public Observer, + public Observable, + private CThread + { + private: + CCriticalSection m_critSection; + bool m_bIsUpdating; + + /*! + * @brief Add timers to this container. + * @return The amount of timers that were added. + */ + int LoadFromClients(void); + + void Sort(void); + virtual bool ExecuteUpdate(void); + virtual void Process(void); + + public: + CPVRTimers(void); + + /** + * Load the timers from the clients. + * Returns the amount of timers that were added. + */ + int Load(); + + /** + * Clear this timer list. + */ + void Unload(); + + /** + * @brief refresh the channel list from the clients. + * @param bAsyncUpdate Try to update the timers async. + */ + bool Update(bool bAsyncUpdate = false); + + /** + * Update a timer entry in this container. + */ + bool UpdateEntry(const CPVRTimerInfoTag &timer); + bool UpdateFromClient(const CPVRTimerInfoTag &timer) { return UpdateEntry(timer); } + + /********** getters **********/ + + /** + * Get all known timers. + */ + int GetTimers(CFileItemList* results); + + /** + * The timer that will be active next. + * Returns false if there is none. + */ + bool GetNextActiveTimer(CPVRTimerInfoTag *tag); + + int GetActiveTimers(std::vector *tags); + + /** + * The amount of timers in this container. + */ + int GetNumTimers() const; + + int GetNumActiveTimers(void) const; + + int GetNumActiveRecordings(void) const; + + bool GetTimerByIndex(unsigned int iIndex, CPVRTimerInfoTag *timer) const; + + /** + * Get the directory for a path. + */ + bool GetDirectory(const CStdString& strPath, CFileItemList &items); + + /********** channel methods **********/ + + /** + * Check if there are any active timers on a channel. + */ + bool ChannelHasTimers(const CPVRChannel &channel); + + /*! + * @brief Delete all timers on a channel. + * @param channel The channel to delete the timers for. + * @param bDeleteRepeating True to delete repeating events too, false otherwise. + * @param bCurrentlyActiveOnly True to delete timers that are currently running only. + * @return True if timers any were deleted, false otherwise. + */ + bool DeleteTimersOnChannel(const CPVRChannel &channel, bool bDeleteRepeating = true, bool bCurrentlyActiveOnly = false); + + /*! + * @brief Create a new instant timer on a channel. + * @param channel The channel to create the timer on. + * @param bStartTimer True to start the timer instantly, false otherwise. + * @return The new timer or NULL if it couldn't be created. + */ + CPVRTimerInfoTag *InstantTimer(CPVRChannel *channel, bool bStartTimer = true); + + /********** static methods **********/ + + /** + * Add a timer to the client. + * True if it was sent correctly, false if not. + */ + static bool AddTimer(const CFileItem &item); + + /** + * Add a timer to the client. + * True if it was sent correctly, false if not. + */ + static bool AddTimer(CPVRTimerInfoTag &item); + + /** + * Delete a timer on the client. + * True if it was sent correctly, false if not. + */ + static bool DeleteTimer(const CFileItem &item, bool bForce = false); + + /** + * Delete a timer on the client. + * True if it was sent correctly, false if not. + */ + static bool DeleteTimer(CPVRTimerInfoTag &item, bool bForce = false); + + /** + * Rename a timer on the client. + * True if it was sent correctly, false if not. + */ + static bool RenameTimer(CFileItem &item, const CStdString &strNewName); + + /** + * Rename a timer on the client. + * True if it was sent correctly, false if not. + */ + static bool RenameTimer(CPVRTimerInfoTag &item, const CStdString &strNewName); + + /** + * Get updated timer information from the client. + * True if it was requested correctly, false if not. + */ + static bool UpdateTimer(const CFileItem &item); + + /** + * Get updated timer information from the client. + * True if it was requested correctly, false if not. + */ + static bool UpdateTimer(CPVRTimerInfoTag &item); + + bool IsRecording(void); + bool UpdateEntries(CPVRTimers *timers); + CPVRTimerInfoTag *GetByClient(int iClientId, int iClientTimerId); + CPVRTimerInfoTag *GetMatch(const CEpgInfoTag *Epg); + CPVRTimerInfoTag *GetMatch(const CFileItem *item); + virtual void Notify(const Observable &obs, const CStdString& msg); + bool IsRecordingOnChannel(const CPVRChannel &channel) const; + }; +} diff --git a/xbmc/pvr/windows/GUIViewStatePVR.cpp b/xbmc/pvr/windows/GUIViewStatePVR.cpp index 33a7eb7bde870..1d63980f948f6 100644 --- a/xbmc/pvr/windows/GUIViewStatePVR.cpp +++ b/xbmc/pvr/windows/GUIViewStatePVR.cpp @@ -26,6 +26,8 @@ #include "settings/GUISettings.h" #include "settings/Settings.h" +using namespace PVR; + CGUIViewStatePVR::CGUIViewStatePVR(const CFileItemList& items) : CGUIViewState(items) { diff --git a/xbmc/pvr/windows/GUIViewStatePVR.h b/xbmc/pvr/windows/GUIViewStatePVR.h index c22995bab9c04..06731c79c0d29 100644 --- a/xbmc/pvr/windows/GUIViewStatePVR.h +++ b/xbmc/pvr/windows/GUIViewStatePVR.h @@ -24,15 +24,17 @@ #include "GUIViewState.h" #include "GUIWindowPVRCommon.h" - -class CGUIViewStatePVR : public CGUIViewState +namespace PVR { -public: - CGUIViewStatePVR(const CFileItemList& items); - virtual ~CGUIViewStatePVR(void) {} - virtual PVRWindow GetActiveView(void); -protected: - virtual bool AutoPlayNextItem(void) { return false; }; - virtual bool HideParentDirItems(void) { return true; } - virtual void SaveViewState(void) {}; -}; + class CGUIViewStatePVR : public CGUIViewState + { + public: + CGUIViewStatePVR(const CFileItemList& items); + virtual ~CGUIViewStatePVR(void) {} + virtual PVRWindow GetActiveView(void); + protected: + virtual bool AutoPlayNextItem(void) { return false; }; + virtual bool HideParentDirItems(void) { return true; } + virtual void SaveViewState(void) {}; + }; +} diff --git a/xbmc/pvr/windows/GUIWindowPVR.cpp b/xbmc/pvr/windows/GUIWindowPVR.cpp index ec4bfbedc0c58..4dc28985028d5 100644 --- a/xbmc/pvr/windows/GUIWindowPVR.cpp +++ b/xbmc/pvr/windows/GUIWindowPVR.cpp @@ -35,6 +35,8 @@ #include "dialogs/GUIDialogBusy.h" #include "threads/SingleLock.h" +using namespace PVR; + CGUIWindowPVR::CGUIWindowPVR(void) : CGUIMediaWindow(WINDOW_PVR, "MyPVR.xml") { diff --git a/xbmc/pvr/windows/GUIWindowPVR.h b/xbmc/pvr/windows/GUIWindowPVR.h index af727489c2730..67f90d2ada3f0 100644 --- a/xbmc/pvr/windows/GUIWindowPVR.h +++ b/xbmc/pvr/windows/GUIWindowPVR.h @@ -25,65 +25,68 @@ #include "guilib/GUIEPGGridContainer.h" #include "threads/CriticalSection.h" -class CGUIWindowPVRCommon; -class CGUIWindowPVRChannels; -class CGUIWindowPVRGuide; -class CGUIWindowPVRRecordings; -class CGUIWindowPVRSearch; -class CGUIWindowPVRTimers; - -class CGUIWindowPVR : public CGUIMediaWindow +namespace PVR { - friend class CGUIWindowPVRCommon; - friend class CGUIWindowPVRChannels; - friend class CGUIWindowPVRGuide; - friend class CGUIWindowPVRRecordings; - friend class CGUIWindowPVRSearch; - friend class CGUIWindowPVRTimers; + class CGUIWindowPVRCommon; + class CGUIWindowPVRChannels; + class CGUIWindowPVRGuide; + class CGUIWindowPVRRecordings; + class CGUIWindowPVRSearch; + class CGUIWindowPVRTimers; + + class CGUIWindowPVR : public CGUIMediaWindow + { + friend class CGUIWindowPVRCommon; + friend class CGUIWindowPVRChannels; + friend class CGUIWindowPVRGuide; + friend class CGUIWindowPVRRecordings; + friend class CGUIWindowPVRSearch; + friend class CGUIWindowPVRTimers; -public: - CGUIWindowPVR(void); - virtual ~CGUIWindowPVR(void); + public: + CGUIWindowPVR(void); + virtual ~CGUIWindowPVR(void); - virtual CGUIWindowPVRCommon *GetActiveView(void) const; - virtual void SetActiveView(CGUIWindowPVRCommon *window); - virtual void GetContextButtons(int itemNumber, CContextButtons &buttons); - virtual CGUIWindowPVRCommon *GetSavedView(void) const; - virtual bool OnAction(const CAction &action); - virtual bool OnContextButton(int itemNumber, CONTEXT_BUTTON button); - virtual void OnInitWindow(void); - virtual bool OnMessage(CGUIMessage& message); - virtual void OnWindowLoaded(void); - virtual void OnWindowUnload(void); - virtual void UpdateWindow(PVRWindow window); - virtual void InitializeEpgCache(void); + virtual CGUIWindowPVRCommon *GetActiveView(void) const; + virtual void SetActiveView(CGUIWindowPVRCommon *window); + virtual void GetContextButtons(int itemNumber, CContextButtons &buttons); + virtual CGUIWindowPVRCommon *GetSavedView(void) const; + virtual bool OnAction(const CAction &action); + virtual bool OnContextButton(int itemNumber, CONTEXT_BUTTON button); + virtual void OnInitWindow(void); + virtual bool OnMessage(CGUIMessage& message); + virtual void OnWindowLoaded(void); + virtual void OnWindowUnload(void); + virtual void UpdateWindow(PVRWindow window); + virtual void InitializeEpgCache(void); - void UnlockWindow(); + void UnlockWindow(); - CGUIEPGGridContainer *m_guideGrid; + CGUIEPGGridContainer *m_guideGrid; -protected: - virtual void SetLabel(int iControl, const CStdString &strLabel); - virtual void SetLabel(int iControl, int iLabel); - virtual void UpdateButtons(void); + protected: + virtual void SetLabel(int iControl, const CStdString &strLabel); + virtual void SetLabel(int iControl, int iLabel); + virtual void UpdateButtons(void); -private: - virtual bool OnMessageFocus(CGUIMessage &message); - virtual bool OnMessageClick(CGUIMessage &message); + private: + virtual bool OnMessageFocus(CGUIMessage &message); + virtual bool OnMessageClick(CGUIMessage &message); - virtual void CreateViews(void); + virtual void CreateViews(void); - CGUIWindowPVRCommon * m_currentSubwindow; - CGUIWindowPVRCommon * m_savedSubwindow; + CGUIWindowPVRCommon * m_currentSubwindow; + CGUIWindowPVRCommon * m_savedSubwindow; - CGUIWindowPVRChannels * m_windowChannelsTV; - CGUIWindowPVRChannels * m_windowChannelsRadio; - CGUIWindowPVRGuide * m_windowGuide; - CGUIWindowPVRRecordings *m_windowRecordings; - CGUIWindowPVRSearch * m_windowSearch; - CGUIWindowPVRTimers * m_windowTimers; + CGUIWindowPVRChannels * m_windowChannelsTV; + CGUIWindowPVRChannels * m_windowChannelsRadio; + CGUIWindowPVRGuide * m_windowGuide; + CGUIWindowPVRRecordings *m_windowRecordings; + CGUIWindowPVRSearch * m_windowSearch; + CGUIWindowPVRTimers * m_windowTimers; - bool m_bViewsCreated; - CCriticalSection m_critSection; - bool m_bDialogOKActive; -}; + bool m_bViewsCreated; + CCriticalSection m_critSection; + bool m_bDialogOKActive; + }; +} diff --git a/xbmc/pvr/windows/GUIWindowPVRChannels.cpp b/xbmc/pvr/windows/GUIWindowPVRChannels.cpp index 84cccc02c91e9..ce00471e9fe5e 100644 --- a/xbmc/pvr/windows/GUIWindowPVRChannels.cpp +++ b/xbmc/pvr/windows/GUIWindowPVRChannels.cpp @@ -37,6 +37,7 @@ #include "utils/log.h" #include "threads/SingleLock.h" +using namespace PVR; CGUIWindowPVRChannels::CGUIWindowPVRChannels(CGUIWindowPVR *parent, bool bRadio) : CGUIWindowPVRCommon(parent, diff --git a/xbmc/pvr/windows/GUIWindowPVRChannels.h b/xbmc/pvr/windows/GUIWindowPVRChannels.h index b6c258d2a8b69..a6ed5110b477a 100644 --- a/xbmc/pvr/windows/GUIWindowPVRChannels.h +++ b/xbmc/pvr/windows/GUIWindowPVRChannels.h @@ -23,40 +23,43 @@ #include "GUIWindowPVRCommon.h" -class CPVRChannelGroup; -class CGUIWindowPVR; - -class CGUIWindowPVRChannels : public CGUIWindowPVRCommon +namespace PVR { - friend class CGUIWindowPVR; - -public: - CGUIWindowPVRChannels(CGUIWindowPVR *parent, bool bRadio); - virtual ~CGUIWindowPVRChannels(void) {}; - - virtual void GetContextButtons(int itemNumber, CContextButtons &buttons) const; - virtual bool OnContextButton(int itemNumber, CONTEXT_BUTTON button); - virtual const CPVRChannelGroup *SelectedGroup(void); - virtual void SetSelectedGroup(CPVRChannelGroup *group); - virtual const CPVRChannelGroup *SelectNextGroup(void); - virtual void UpdateData(void); - -private: - virtual bool OnClickButton(CGUIMessage &message); - virtual bool OnClickList(CGUIMessage &message); - - virtual bool OnContextButtonAdd(CFileItem *item, CONTEXT_BUTTON button); - virtual bool OnContextButtonGroupManager(CFileItem *item, CONTEXT_BUTTON button); - virtual bool OnContextButtonHide(CFileItem *item, CONTEXT_BUTTON button); - virtual bool OnContextButtonInfo(CFileItem *item, CONTEXT_BUTTON button); - virtual bool OnContextButtonMove(CFileItem *item, CONTEXT_BUTTON button); - virtual bool OnContextButtonPlay(CFileItem *item, CONTEXT_BUTTON button); - virtual bool OnContextButtonSetThumb(CFileItem *item, CONTEXT_BUTTON button); - virtual bool OnContextButtonShowHidden(CFileItem *item, CONTEXT_BUTTON button); - - virtual void ShowGroupManager(void); - - CPVRChannelGroup *m_selectedGroup; - bool m_bShowHiddenChannels; - bool m_bRadio; -}; + class CPVRChannelGroup; + class CGUIWindowPVR; + + class CGUIWindowPVRChannels : public CGUIWindowPVRCommon + { + friend class CGUIWindowPVR; + + public: + CGUIWindowPVRChannels(CGUIWindowPVR *parent, bool bRadio); + virtual ~CGUIWindowPVRChannels(void) {}; + + virtual void GetContextButtons(int itemNumber, CContextButtons &buttons) const; + virtual bool OnContextButton(int itemNumber, CONTEXT_BUTTON button); + virtual const CPVRChannelGroup *SelectedGroup(void); + virtual void SetSelectedGroup(CPVRChannelGroup *group); + virtual const CPVRChannelGroup *SelectNextGroup(void); + virtual void UpdateData(void); + + private: + virtual bool OnClickButton(CGUIMessage &message); + virtual bool OnClickList(CGUIMessage &message); + + virtual bool OnContextButtonAdd(CFileItem *item, CONTEXT_BUTTON button); + virtual bool OnContextButtonGroupManager(CFileItem *item, CONTEXT_BUTTON button); + virtual bool OnContextButtonHide(CFileItem *item, CONTEXT_BUTTON button); + virtual bool OnContextButtonInfo(CFileItem *item, CONTEXT_BUTTON button); + virtual bool OnContextButtonMove(CFileItem *item, CONTEXT_BUTTON button); + virtual bool OnContextButtonPlay(CFileItem *item, CONTEXT_BUTTON button); + virtual bool OnContextButtonSetThumb(CFileItem *item, CONTEXT_BUTTON button); + virtual bool OnContextButtonShowHidden(CFileItem *item, CONTEXT_BUTTON button); + + virtual void ShowGroupManager(void); + + CPVRChannelGroup *m_selectedGroup; + bool m_bShowHiddenChannels; + bool m_bRadio; + }; +} diff --git a/xbmc/pvr/windows/GUIWindowPVRCommon.cpp b/xbmc/pvr/windows/GUIWindowPVRCommon.cpp index 7350e35ed5a7f..e8fb9a0e810fe 100644 --- a/xbmc/pvr/windows/GUIWindowPVRCommon.cpp +++ b/xbmc/pvr/windows/GUIWindowPVRCommon.cpp @@ -43,6 +43,7 @@ #include "utils/URIUtils.h" using namespace std; +using namespace PVR; CGUIWindowPVRCommon::CGUIWindowPVRCommon(CGUIWindowPVR *parent, PVRWindow window, unsigned int iControlButton, unsigned int iControlList) diff --git a/xbmc/pvr/windows/GUIWindowPVRCommon.h b/xbmc/pvr/windows/GUIWindowPVRCommon.h index 6517d43ebfda9..5519039202217 100644 --- a/xbmc/pvr/windows/GUIWindowPVRCommon.h +++ b/xbmc/pvr/windows/GUIWindowPVRCommon.h @@ -26,109 +26,112 @@ #include "GUIWindowPVRCommon.h" #include "threads/CriticalSection.h" -enum PVRWindow +namespace PVR { - PVR_WINDOW_UNKNOWN = 0, - PVR_WINDOW_EPG = 1, - PVR_WINDOW_CHANNELS_TV = 2, - PVR_WINDOW_CHANNELS_RADIO = 3, - PVR_WINDOW_RECORDINGS = 4, - PVR_WINDOW_TIMERS = 5, - PVR_WINDOW_SEARCH = 6 -}; - -#define CONTROL_LIST_TIMELINE 10 -#define CONTROL_LIST_CHANNELS_TV 11 -#define CONTROL_LIST_CHANNELS_RADIO 12 -#define CONTROL_LIST_RECORDINGS 13 -#define CONTROL_LIST_TIMERS 14 -#define CONTROL_LIST_GUIDE_CHANNEL 15 -#define CONTROL_LIST_GUIDE_NOW_NEXT 16 -#define CONTROL_LIST_SEARCH 17 - -#define CONTROL_LABELHEADER 29 -#define CONTROL_LABELGROUP 30 - -#define CONTROL_BTNGUIDE 31 -#define CONTROL_BTNCHANNELS_TV 32 -#define CONTROL_BTNCHANNELS_RADIO 33 -#define CONTROL_BTNRECORDINGS 34 -#define CONTROL_BTNTIMERS 35 -#define CONTROL_BTNSEARCH 36 -#define CONTROL_BTNGUIDE_CHANNEL 37 -#define CONTROL_BTNGUIDE_NOW 38 -#define CONTROL_BTNGUIDE_NEXT 39 -#define CONTROL_BTNGUIDE_TIMELINE 40 - -class CGUIWindowPVR; - -class CGUIWindowPVRCommon -{ - friend class CGUIWindowPVR; - -public: - CGUIWindowPVRCommon(CGUIWindowPVR *parent, PVRWindow window, - unsigned int iControlButton, unsigned int iControlList); - virtual ~CGUIWindowPVRCommon(void) {}; - - bool operator ==(const CGUIWindowPVRCommon &right) const; - bool operator !=(const CGUIWindowPVRCommon &right) const; - - virtual const char *GetName(void) const; - virtual PVRWindow GetWindowId(void) const { return m_window; } - virtual bool IsVisible(void) const; - virtual bool IsActive(void) const; - virtual bool IsSavedView(void) const; - virtual bool IsSelectedButton(CGUIMessage &message) const; - virtual bool IsSelectedControl(CGUIMessage &message) const; - virtual bool IsSelectedList(CGUIMessage &message) const; - - virtual bool OnAction(const CAction &action); - virtual bool OnContextButton(int itemNumber, CONTEXT_BUTTON button); - - virtual void GetContextButtons(int itemNumber, CContextButtons &buttons) const = 0; - virtual void UpdateData(void) = 0; - - virtual void OnInitWindow(void); - virtual void OnWindowUnload(void); - -protected: - virtual bool OnMessageFocus(CGUIMessage &message); - - virtual bool OnClickButton(CGUIMessage &message) = 0; - virtual bool OnClickList(CGUIMessage &message) = 0; - - virtual bool ActionDeleteTimer(CFileItem *item); - virtual bool ActionShowTimer(CFileItem *item); - virtual bool ActionRecord(CFileItem *item); - virtual bool ActionDeleteRecording(CFileItem *item); - virtual bool ActionPlayChannel(CFileItem *item); - virtual bool ActionPlayEpg(CFileItem *item); - virtual bool ActionDeleteChannel(CFileItem *item); - - virtual bool PlayRecording(CFileItem *item, bool bPlayMinimized = false); - virtual bool PlayFile(CFileItem *item, bool bPlayMinimized = false); - virtual bool StartRecordFile(CFileItem *item); - virtual bool StopRecordFile(CFileItem *item); - virtual void ShowEPGInfo(CFileItem *item); - virtual void ShowRecordingInfo(CFileItem *item); - virtual bool ShowTimerSettings(CFileItem *item); - - virtual bool OnContextButtonMenuHooks(CFileItem *item, CONTEXT_BUTTON button); - virtual bool OnContextButtonSortAsc(CFileItem *item, CONTEXT_BUTTON button); - virtual bool OnContextButtonSortBy(CFileItem *item, CONTEXT_BUTTON button); - virtual bool OnContextButtonSortByDate(CFileItem *item, CONTEXT_BUTTON button); - virtual bool OnContextButtonSortByName(CFileItem *item, CONTEXT_BUTTON button); - virtual bool OnContextButtonSortByChannel(CFileItem *item, CONTEXT_BUTTON button); - - CGUIWindowPVR * m_parent; - PVRWindow m_window; - unsigned int m_iControlButton; - unsigned int m_iControlList; - bool m_bUpdateRequired; - int m_iSelected; - SORT_ORDER m_iSortOrder; - SORT_METHOD m_iSortMethod; - bool m_bIsFocusing; - CCriticalSection m_critSection; -}; + enum PVRWindow + { + PVR_WINDOW_UNKNOWN = 0, + PVR_WINDOW_EPG = 1, + PVR_WINDOW_CHANNELS_TV = 2, + PVR_WINDOW_CHANNELS_RADIO = 3, + PVR_WINDOW_RECORDINGS = 4, + PVR_WINDOW_TIMERS = 5, + PVR_WINDOW_SEARCH = 6 + }; + + #define CONTROL_LIST_TIMELINE 10 + #define CONTROL_LIST_CHANNELS_TV 11 + #define CONTROL_LIST_CHANNELS_RADIO 12 + #define CONTROL_LIST_RECORDINGS 13 + #define CONTROL_LIST_TIMERS 14 + #define CONTROL_LIST_GUIDE_CHANNEL 15 + #define CONTROL_LIST_GUIDE_NOW_NEXT 16 + #define CONTROL_LIST_SEARCH 17 + + #define CONTROL_LABELHEADER 29 + #define CONTROL_LABELGROUP 30 + + #define CONTROL_BTNGUIDE 31 + #define CONTROL_BTNCHANNELS_TV 32 + #define CONTROL_BTNCHANNELS_RADIO 33 + #define CONTROL_BTNRECORDINGS 34 + #define CONTROL_BTNTIMERS 35 + #define CONTROL_BTNSEARCH 36 + #define CONTROL_BTNGUIDE_CHANNEL 37 + #define CONTROL_BTNGUIDE_NOW 38 + #define CONTROL_BTNGUIDE_NEXT 39 + #define CONTROL_BTNGUIDE_TIMELINE 40 + + class CGUIWindowPVR; + + class CGUIWindowPVRCommon + { + friend class CGUIWindowPVR; + + public: + CGUIWindowPVRCommon(CGUIWindowPVR *parent, PVRWindow window, + unsigned int iControlButton, unsigned int iControlList); + virtual ~CGUIWindowPVRCommon(void) {}; + + bool operator ==(const CGUIWindowPVRCommon &right) const; + bool operator !=(const CGUIWindowPVRCommon &right) const; + + virtual const char *GetName(void) const; + virtual PVRWindow GetWindowId(void) const { return m_window; } + virtual bool IsVisible(void) const; + virtual bool IsActive(void) const; + virtual bool IsSavedView(void) const; + virtual bool IsSelectedButton(CGUIMessage &message) const; + virtual bool IsSelectedControl(CGUIMessage &message) const; + virtual bool IsSelectedList(CGUIMessage &message) const; + + virtual bool OnAction(const CAction &action); + virtual bool OnContextButton(int itemNumber, CONTEXT_BUTTON button); + + virtual void GetContextButtons(int itemNumber, CContextButtons &buttons) const = 0; + virtual void UpdateData(void) = 0; + + virtual void OnInitWindow(void); + virtual void OnWindowUnload(void); + + protected: + virtual bool OnMessageFocus(CGUIMessage &message); + + virtual bool OnClickButton(CGUIMessage &message) = 0; + virtual bool OnClickList(CGUIMessage &message) = 0; + + virtual bool ActionDeleteTimer(CFileItem *item); + virtual bool ActionShowTimer(CFileItem *item); + virtual bool ActionRecord(CFileItem *item); + virtual bool ActionDeleteRecording(CFileItem *item); + virtual bool ActionPlayChannel(CFileItem *item); + virtual bool ActionPlayEpg(CFileItem *item); + virtual bool ActionDeleteChannel(CFileItem *item); + + virtual bool PlayRecording(CFileItem *item, bool bPlayMinimized = false); + virtual bool PlayFile(CFileItem *item, bool bPlayMinimized = false); + virtual bool StartRecordFile(CFileItem *item); + virtual bool StopRecordFile(CFileItem *item); + virtual void ShowEPGInfo(CFileItem *item); + virtual void ShowRecordingInfo(CFileItem *item); + virtual bool ShowTimerSettings(CFileItem *item); + + virtual bool OnContextButtonMenuHooks(CFileItem *item, CONTEXT_BUTTON button); + virtual bool OnContextButtonSortAsc(CFileItem *item, CONTEXT_BUTTON button); + virtual bool OnContextButtonSortBy(CFileItem *item, CONTEXT_BUTTON button); + virtual bool OnContextButtonSortByDate(CFileItem *item, CONTEXT_BUTTON button); + virtual bool OnContextButtonSortByName(CFileItem *item, CONTEXT_BUTTON button); + virtual bool OnContextButtonSortByChannel(CFileItem *item, CONTEXT_BUTTON button); + + CGUIWindowPVR * m_parent; + PVRWindow m_window; + unsigned int m_iControlButton; + unsigned int m_iControlList; + bool m_bUpdateRequired; + int m_iSelected; + SORT_ORDER m_iSortOrder; + SORT_METHOD m_iSortMethod; + bool m_bIsFocusing; + CCriticalSection m_critSection; + }; +} diff --git a/xbmc/pvr/windows/GUIWindowPVRGuide.cpp b/xbmc/pvr/windows/GUIWindowPVRGuide.cpp index 495cfceaf7c9f..4da7a9d8323ad 100644 --- a/xbmc/pvr/windows/GUIWindowPVRGuide.cpp +++ b/xbmc/pvr/windows/GUIWindowPVRGuide.cpp @@ -36,6 +36,8 @@ #include "pvr/addons/PVRClients.h" #include "pvr/timers/PVRTimers.h" +using namespace PVR; + CGUIWindowPVRGuide::CGUIWindowPVRGuide(CGUIWindowPVR *parent) : CGUIWindowPVRCommon(parent, PVR_WINDOW_EPG, CONTROL_BTNGUIDE, CONTROL_LIST_GUIDE_NOW_NEXT), Observer() diff --git a/xbmc/pvr/windows/GUIWindowPVRGuide.h b/xbmc/pvr/windows/GUIWindowPVRGuide.h index 25852b28a23ff..ffc00262e22a6 100644 --- a/xbmc/pvr/windows/GUIWindowPVRGuide.h +++ b/xbmc/pvr/windows/GUIWindowPVRGuide.h @@ -26,45 +26,48 @@ #include "threads/CriticalSection.h" #include "utils/Observer.h" -class CGUIWindowPVR; - -class CGUIWindowPVRGuide : public CGUIWindowPVRCommon, public Observer +namespace PVR { - friend class CGUIWindowPVR; + class CGUIWindowPVR; + + class CGUIWindowPVRGuide : public CGUIWindowPVRCommon, public Observer + { + friend class CGUIWindowPVR; -public: - CGUIWindowPVRGuide(CGUIWindowPVR *parent); - virtual ~CGUIWindowPVRGuide(void); + public: + CGUIWindowPVRGuide(CGUIWindowPVR *parent); + virtual ~CGUIWindowPVRGuide(void); - virtual void GetContextButtons(int itemNumber, CContextButtons &buttons) const; - virtual bool OnContextButton(int itemNumber, CONTEXT_BUTTON button); - virtual void UpdateData(void); - virtual void Notify(const Observable &obs, const CStdString& msg); + virtual void GetContextButtons(int itemNumber, CContextButtons &buttons) const; + virtual bool OnContextButton(int itemNumber, CONTEXT_BUTTON button); + virtual void UpdateData(void); + virtual void Notify(const Observable &obs, const CStdString& msg); -private: - virtual bool IsSelectedButton(CGUIMessage &message) const; - virtual bool IsSelectedList(CGUIMessage &message) const; - virtual bool OnClickButton(CGUIMessage &message); - virtual bool OnClickList(CGUIMessage &message); + private: + virtual bool IsSelectedButton(CGUIMessage &message) const; + virtual bool IsSelectedList(CGUIMessage &message) const; + virtual bool OnClickButton(CGUIMessage &message); + virtual bool OnClickList(CGUIMessage &message); - virtual bool OnContextButtonBegin(CFileItem *item, CONTEXT_BUTTON button); - virtual bool OnContextButtonEnd(CFileItem *item, CONTEXT_BUTTON button); - virtual bool OnContextButtonInfo(CFileItem *item, CONTEXT_BUTTON button); - virtual bool OnContextButtonPlay(CFileItem *item, CONTEXT_BUTTON button); - virtual bool OnContextButtonStartRecord(CFileItem *item, CONTEXT_BUTTON button); - virtual bool OnContextButtonStopRecord(CFileItem *item, CONTEXT_BUTTON button); + virtual bool OnContextButtonBegin(CFileItem *item, CONTEXT_BUTTON button); + virtual bool OnContextButtonEnd(CFileItem *item, CONTEXT_BUTTON button); + virtual bool OnContextButtonInfo(CFileItem *item, CONTEXT_BUTTON button); + virtual bool OnContextButtonPlay(CFileItem *item, CONTEXT_BUTTON button); + virtual bool OnContextButtonStartRecord(CFileItem *item, CONTEXT_BUTTON button); + virtual bool OnContextButtonStopRecord(CFileItem *item, CONTEXT_BUTTON button); - virtual void UpdateButtons(void); - virtual void UpdateViewChannel(void); - virtual void UpdateViewNow(void); - virtual void UpdateViewNext(void); - virtual void UpdateViewTimeline(void); - virtual void UpdateEpgCache(bool bRadio = false, bool bForceUpdate = false); + virtual void UpdateButtons(void); + virtual void UpdateViewChannel(void); + virtual void UpdateViewNow(void); + virtual void UpdateViewNext(void); + virtual void UpdateViewTimeline(void); + virtual void UpdateEpgCache(bool bRadio = false, bool bForceUpdate = false); - int m_iGuideView; - CFileItemList * m_epgData; - bool m_bLastEpgView; /*!< true for radio, false for tv */ - bool m_bGotInitialEpg; - bool m_bObservingEpg; - CCriticalSection m_critSection; -}; + int m_iGuideView; + CFileItemList * m_epgData; + bool m_bLastEpgView; /*!< true for radio, false for tv */ + bool m_bGotInitialEpg; + bool m_bObservingEpg; + CCriticalSection m_critSection; + }; +} diff --git a/xbmc/pvr/windows/GUIWindowPVRRecordings.cpp b/xbmc/pvr/windows/GUIWindowPVRRecordings.cpp index 40c23c8dec018..5491d92a4a146 100644 --- a/xbmc/pvr/windows/GUIWindowPVRRecordings.cpp +++ b/xbmc/pvr/windows/GUIWindowPVRRecordings.cpp @@ -31,6 +31,8 @@ #include "utils/log.h" #include "threads/SingleLock.h" +using namespace PVR; + CGUIWindowPVRRecordings::CGUIWindowPVRRecordings(CGUIWindowPVR *parent) : CGUIWindowPVRCommon(parent, PVR_WINDOW_RECORDINGS, CONTROL_BTNRECORDINGS, CONTROL_LIST_RECORDINGS) { diff --git a/xbmc/pvr/windows/GUIWindowPVRRecordings.h b/xbmc/pvr/windows/GUIWindowPVRRecordings.h index 0b9551ab273cd..af3cfb0a1a835 100644 --- a/xbmc/pvr/windows/GUIWindowPVRRecordings.h +++ b/xbmc/pvr/windows/GUIWindowPVRRecordings.h @@ -23,30 +23,33 @@ #include "GUIWindowPVRCommon.h" -class CGUIWindowPVR; - -class CGUIWindowPVRRecordings : public CGUIWindowPVRCommon +namespace PVR { - friend class CGUIWindowPVR; - -public: - CGUIWindowPVRRecordings(CGUIWindowPVR *parent); - virtual ~CGUIWindowPVRRecordings(void) {}; - - virtual void GetContextButtons(int itemNumber, CContextButtons &buttons) const; - virtual bool OnAction(const CAction &action); - virtual bool OnContextButton(int itemNumber, CONTEXT_BUTTON button); - virtual void OnWindowUnload(void); - virtual void UpdateData(void); - -private: - virtual bool OnClickButton(CGUIMessage &message); - virtual bool OnClickList(CGUIMessage &message); - - virtual bool OnContextButtonDelete(CFileItem *item, CONTEXT_BUTTON button); - virtual bool OnContextButtonInfo(CFileItem *item, CONTEXT_BUTTON button); - virtual bool OnContextButtonPlay(CFileItem *item, CONTEXT_BUTTON button); - virtual bool OnContextButtonRename(CFileItem *item, CONTEXT_BUTTON button); - - CStdString m_strSelectedPath; -}; + class CGUIWindowPVR; + + class CGUIWindowPVRRecordings : public CGUIWindowPVRCommon + { + friend class CGUIWindowPVR; + + public: + CGUIWindowPVRRecordings(CGUIWindowPVR *parent); + virtual ~CGUIWindowPVRRecordings(void) {}; + + virtual void GetContextButtons(int itemNumber, CContextButtons &buttons) const; + virtual bool OnAction(const CAction &action); + virtual bool OnContextButton(int itemNumber, CONTEXT_BUTTON button); + virtual void OnWindowUnload(void); + virtual void UpdateData(void); + + private: + virtual bool OnClickButton(CGUIMessage &message); + virtual bool OnClickList(CGUIMessage &message); + + virtual bool OnContextButtonDelete(CFileItem *item, CONTEXT_BUTTON button); + virtual bool OnContextButtonInfo(CFileItem *item, CONTEXT_BUTTON button); + virtual bool OnContextButtonPlay(CFileItem *item, CONTEXT_BUTTON button); + virtual bool OnContextButtonRename(CFileItem *item, CONTEXT_BUTTON button); + + CStdString m_strSelectedPath; + }; +} diff --git a/xbmc/pvr/windows/GUIWindowPVRSearch.cpp b/xbmc/pvr/windows/GUIWindowPVRSearch.cpp index 126f609c09af3..5fc0c33f76168 100644 --- a/xbmc/pvr/windows/GUIWindowPVRSearch.cpp +++ b/xbmc/pvr/windows/GUIWindowPVRSearch.cpp @@ -33,6 +33,8 @@ #include "utils/log.h" #include "pvr/addons/PVRClients.h" +using namespace PVR; + CGUIWindowPVRSearch::CGUIWindowPVRSearch(CGUIWindowPVR *parent) : CGUIWindowPVRCommon(parent, PVR_WINDOW_SEARCH, CONTROL_BTNSEARCH, CONTROL_LIST_SEARCH) { diff --git a/xbmc/pvr/windows/GUIWindowPVRSearch.h b/xbmc/pvr/windows/GUIWindowPVRSearch.h index fb94db51aa4e2..ad8aae7d5110a 100644 --- a/xbmc/pvr/windows/GUIWindowPVRSearch.h +++ b/xbmc/pvr/windows/GUIWindowPVRSearch.h @@ -24,36 +24,39 @@ #include "GUIWindowPVRCommon.h" #include "pvr/epg/PVREpgSearchFilter.h" -class CGUIWindowPVR; - -class CGUIWindowPVRSearch : public CGUIWindowPVRCommon +namespace PVR { - friend class CGUIWindowPVR; + class CGUIWindowPVR; + + class CGUIWindowPVRSearch : public CGUIWindowPVRCommon + { + friend class CGUIWindowPVR; -public: - CGUIWindowPVRSearch(CGUIWindowPVR *parent); - virtual ~CGUIWindowPVRSearch(void) {}; + public: + CGUIWindowPVRSearch(CGUIWindowPVR *parent); + virtual ~CGUIWindowPVRSearch(void) {}; - virtual void GetContextButtons(int itemNumber, CContextButtons &buttons) const; - virtual bool OnContextButton(int itemNumber, CONTEXT_BUTTON button); - virtual void OnInitWindow(void); - virtual void UpdateData(void); + virtual void GetContextButtons(int itemNumber, CContextButtons &buttons) const; + virtual bool OnContextButton(int itemNumber, CONTEXT_BUTTON button); + virtual void OnInitWindow(void); + virtual void UpdateData(void); -private: + private: - virtual bool OnClickButton(CGUIMessage &message); - virtual bool OnClickList(CGUIMessage &message); + virtual bool OnClickButton(CGUIMessage &message); + virtual bool OnClickList(CGUIMessage &message); - virtual bool OnContextButtonClear(CFileItem *item, CONTEXT_BUTTON button); - virtual bool OnContextButtonFind(CFileItem *item, CONTEXT_BUTTON button); - virtual bool OnContextButtonInfo(CFileItem *item, CONTEXT_BUTTON button); - virtual bool OnContextButtonStartRecord(CFileItem *item, CONTEXT_BUTTON button); - virtual bool OnContextButtonStopRecord(CFileItem *item, CONTEXT_BUTTON button); + virtual bool OnContextButtonClear(CFileItem *item, CONTEXT_BUTTON button); + virtual bool OnContextButtonFind(CFileItem *item, CONTEXT_BUTTON button); + virtual bool OnContextButtonInfo(CFileItem *item, CONTEXT_BUTTON button); + virtual bool OnContextButtonStartRecord(CFileItem *item, CONTEXT_BUTTON button); + virtual bool OnContextButtonStopRecord(CFileItem *item, CONTEXT_BUTTON button); - virtual bool ActionShowSearch(CFileItem *item); - virtual void ShowSearchResults(); + virtual bool ActionShowSearch(CFileItem *item); + virtual void ShowSearchResults(); - bool m_bSearchStarted; - bool m_bSearchConfirmed; - PVREpgSearchFilter m_searchfilter; -}; + bool m_bSearchStarted; + bool m_bSearchConfirmed; + PVREpgSearchFilter m_searchfilter; + }; +} diff --git a/xbmc/pvr/windows/GUIWindowPVRTimers.cpp b/xbmc/pvr/windows/GUIWindowPVRTimers.cpp index b58387e4fce93..0e5ec37d0b1b2 100644 --- a/xbmc/pvr/windows/GUIWindowPVRTimers.cpp +++ b/xbmc/pvr/windows/GUIWindowPVRTimers.cpp @@ -31,6 +31,8 @@ #include "GUIWindowPVR.h" #include "threads/SingleLock.h" +using namespace PVR; + CGUIWindowPVRTimers::CGUIWindowPVRTimers(CGUIWindowPVR *parent) : CGUIWindowPVRCommon(parent, PVR_WINDOW_TIMERS, CONTROL_BTNTIMERS, CONTROL_LIST_TIMERS) { diff --git a/xbmc/pvr/windows/GUIWindowPVRTimers.h b/xbmc/pvr/windows/GUIWindowPVRTimers.h index dc6a5f462abaf..62f88411abe53 100644 --- a/xbmc/pvr/windows/GUIWindowPVRTimers.h +++ b/xbmc/pvr/windows/GUIWindowPVRTimers.h @@ -23,27 +23,30 @@ #include "GUIWindowPVRCommon.h" -class CGUIWindowPVR; - -class CGUIWindowPVRTimers : public CGUIWindowPVRCommon +namespace PVR { - friend class CGUIWindowPVR; - -public: - CGUIWindowPVRTimers(CGUIWindowPVR *parent); - virtual ~CGUIWindowPVRTimers(void) {}; - - virtual void GetContextButtons(int itemNumber, CContextButtons &buttons) const; - virtual bool OnContextButton(int itemNumber, CONTEXT_BUTTON button); - virtual void UpdateData(void); - -private: - virtual bool OnClickButton(CGUIMessage &message); - virtual bool OnClickList(CGUIMessage &message); - - virtual bool OnContextButtonActivate(CFileItem *item, CONTEXT_BUTTON button); - virtual bool OnContextButtonAdd(CFileItem *item, CONTEXT_BUTTON button); - virtual bool OnContextButtonDelete(CFileItem *item, CONTEXT_BUTTON button); - virtual bool OnContextButtonEdit(CFileItem *item, CONTEXT_BUTTON button); - virtual bool OnContextButtonRename(CFileItem *item, CONTEXT_BUTTON button); -}; + class CGUIWindowPVR; + + class CGUIWindowPVRTimers : public CGUIWindowPVRCommon + { + friend class CGUIWindowPVR; + + public: + CGUIWindowPVRTimers(CGUIWindowPVR *parent); + virtual ~CGUIWindowPVRTimers(void) {}; + + virtual void GetContextButtons(int itemNumber, CContextButtons &buttons) const; + virtual bool OnContextButton(int itemNumber, CONTEXT_BUTTON button); + virtual void UpdateData(void); + + private: + virtual bool OnClickButton(CGUIMessage &message); + virtual bool OnClickList(CGUIMessage &message); + + virtual bool OnContextButtonActivate(CFileItem *item, CONTEXT_BUTTON button); + virtual bool OnContextButtonAdd(CFileItem *item, CONTEXT_BUTTON button); + virtual bool OnContextButtonDelete(CFileItem *item, CONTEXT_BUTTON button); + virtual bool OnContextButtonEdit(CFileItem *item, CONTEXT_BUTTON button); + virtual bool OnContextButtonRename(CFileItem *item, CONTEXT_BUTTON button); + }; +} diff --git a/xbmc/settings/GUIWindowSettingsCategory.cpp b/xbmc/settings/GUIWindowSettingsCategory.cpp index 593905bef1d37..90da37dd6315e 100644 --- a/xbmc/settings/GUIWindowSettingsCategory.cpp +++ b/xbmc/settings/GUIWindowSettingsCategory.cpp @@ -116,6 +116,7 @@ using namespace std; using namespace XFILE; using namespace ADDON; +using namespace PVR; #define CONTROL_GROUP_BUTTONS 0 #define CONTROL_GROUP_SETTINGS 1 diff --git a/xbmc/video/windows/GUIWindowFullScreen.cpp b/xbmc/video/windows/GUIWindowFullScreen.cpp index 6e8d1a59613df..2d85796f88791 100644 --- a/xbmc/video/windows/GUIWindowFullScreen.cpp +++ b/xbmc/video/windows/GUIWindowFullScreen.cpp @@ -58,6 +58,7 @@ #include +using namespace PVR; #define BLUE_BAR 0 #define LABEL_ROW1 10 diff --git a/xbmc/video/windows/GUIWindowVideoBase.cpp b/xbmc/video/windows/GUIWindowVideoBase.cpp index f54be6f3be293..9f1a797d256f4 100644 --- a/xbmc/video/windows/GUIWindowVideoBase.cpp +++ b/xbmc/video/windows/GUIWindowVideoBase.cpp @@ -74,6 +74,7 @@ using namespace PLAYLIST; using namespace VIDEODATABASEDIRECTORY; using namespace VIDEO; using namespace ADDON; +using namespace PVR; #define CONTROL_BTNVIEWASICONS 2 #define CONTROL_BTNSORTBY 3 From 0d5283ca92a515c47dc221eb4280a2bb312a6b56 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Wed, 20 Apr 2011 23:13:59 +0200 Subject: [PATCH 05/47] pvr: some clean ups. use the MAX_STREAMS defined by the used ffmpeg/avformat instead of just defining it to 42 --- xbmc/GUIInfoManager.cpp | 1 - xbmc/SortFileItem.cpp | 1 - .../DVDDemuxers/DVDDemuxPVRClient.cpp | 11 ++--- .../dvdplayer/DVDDemuxers/DVDDemuxPVRClient.h | 19 +++++++- .../DVDDemuxers/DVDFactoryDemuxer.cpp | 3 +- .../DVDInputStreams/DVDInputStream.h | 4 +- .../DVDInputStreams/DVDInputStreamTV.cpp | 7 --- .../DVDInputStreams/DVDInputStreamTV.h | 2 - xbmc/epg/EpgContainer.cpp | 3 +- xbmc/epg/EpgInfoTag.cpp | 2 +- xbmc/pvr/PVRManager.cpp | 40 ++++++++++++++--- xbmc/pvr/PVRManager.h | 45 ++++++++++++++++--- xbmc/pvr/addons/PVRClients.h | 5 ++- xbmc/settings/GUIWindowSettingsCategory.cpp | 8 ++-- xbmc/video/windows/GUIWindowFullScreen.cpp | 5 +-- 15 files changed, 110 insertions(+), 46 deletions(-) diff --git a/xbmc/GUIInfoManager.cpp b/xbmc/GUIInfoManager.cpp index 432b4ac4c5207..fbed875a331f0 100644 --- a/xbmc/GUIInfoManager.cpp +++ b/xbmc/GUIInfoManager.cpp @@ -79,7 +79,6 @@ #include "pvr/channels/PVRChannelGroupsContainer.h" #include "pvr/epg/PVREpgInfoTag.h" #include "pvr/timers/PVRTimers.h" -#include "pvr/timers/PVRTimerInfoTag.h" #include "pvr/recordings/PVRRecording.h" #include "addons/AddonManager.h" diff --git a/xbmc/SortFileItem.cpp b/xbmc/SortFileItem.cpp index c2a9eafd9e533..dacc518263fd0 100644 --- a/xbmc/SortFileItem.cpp +++ b/xbmc/SortFileItem.cpp @@ -23,7 +23,6 @@ #include "video/VideoInfoTag.h" #include "pvr/channels/PVRChannel.h" #include "pvr/epg/PVREpg.h" -#include "pvr/epg/PVREpgInfoTag.h" #include "pvr/timers/PVRTimerInfoTag.h" #include "settings/AdvancedSettings.h" #include "utils/StringUtils.h" diff --git a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxPVRClient.cpp b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxPVRClient.cpp index 83658f821e745..4577238319de1 100644 --- a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxPVRClient.cpp +++ b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxPVRClient.cpp @@ -25,9 +25,6 @@ #include "utils/log.h" #include "pvr/PVRManager.h" #include "pvr/addons/PVRClients.h" -#ifdef _WIN32 -#include -#endif using namespace PVR; @@ -54,7 +51,7 @@ void CDemuxStreamSubtitlePVRClient::GetStreamInfo(std::string& strInfo) CDVDDemuxPVRClient::CDVDDemuxPVRClient() : CDVDDemux() { m_pInput = NULL; - for (int i = 0; i < MAX_PVR_STREAMS; i++) m_streams[i] = NULL; + for (int i = 0; i < MAX_STREAMS; i++) m_streams[i] = NULL; } CDVDDemuxPVRClient::~CDVDDemuxPVRClient() @@ -72,7 +69,7 @@ bool CDVDDemuxPVRClient::Open(CDVDInputStream* pInput) void CDVDDemuxPVRClient::Dispose() { - for (int i = 0; i < MAX_PVR_STREAMS; i++) + for (int i = 0; i < MAX_STREAMS; i++) { if (m_streams[i]) { @@ -131,7 +128,7 @@ DemuxPacket* CDVDDemuxPVRClient::Read() CDemuxStream* CDVDDemuxPVRClient::GetStream(int iStreamId) { - if (iStreamId < 0 || iStreamId >= MAX_PVR_STREAMS) return NULL; + if (iStreamId < 0 || iStreamId >= MAX_STREAMS) return NULL; return m_streams[iStreamId]; } @@ -239,7 +236,7 @@ void CDVDDemuxPVRClient::UpdateStreams(PVR_STREAM_PROPERTIES *props) int CDVDDemuxPVRClient::GetNrOfStreams() { int i = 0; - while (i < MAX_PVR_STREAMS && m_streams[i]) i++; + while (i < MAX_STREAMS && m_streams[i]) i++; return i; } diff --git a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxPVRClient.h b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxPVRClient.h index 8483ab0b788a7..9194c1fb0389d 100644 --- a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxPVRClient.h +++ b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxPVRClient.h @@ -23,6 +23,22 @@ #include "DVDDemux.h" #include +#ifndef _LINUX +#include +#else +extern "C" { +#if (defined USE_EXTERNAL_FFMPEG) + #if (defined HAVE_LIBAVCODEC_AVFORMAT_H) + #include + #elif (defined HAVE_FFMPEG_AVFORMAT_H) + #include + #endif +#else + #include "libavformat/avformat.h" +#endif +} +#endif + class CDVDDemuxPVRClient; struct PVR_STREAM_PROPERTIES; @@ -81,8 +97,7 @@ class CDVDDemuxPVRClient : public CDVDDemux protected: CDVDInputStream* m_pInput; - #define MAX_PVR_STREAMS 42 - CDemuxStream* m_streams[MAX_PVR_STREAMS]; // maximum number of streams that ffmpeg can handle + CDemuxStream* m_streams[MAX_STREAMS]; // maximum number of streams that ffmpeg can handle private: void RequestStreams(); diff --git a/xbmc/cores/dvdplayer/DVDDemuxers/DVDFactoryDemuxer.cpp b/xbmc/cores/dvdplayer/DVDDemuxers/DVDFactoryDemuxer.cpp index f312bbf9f309a..ad8033e7257e2 100644 --- a/xbmc/cores/dvdplayer/DVDDemuxers/DVDFactoryDemuxer.cpp +++ b/xbmc/cores/dvdplayer/DVDDemuxers/DVDFactoryDemuxer.cpp @@ -33,7 +33,6 @@ #endif #include "DVDDemuxPVRClient.h" #include "pvr/PVRManager.h" -#include "pvr/addons/PVRClients.h" using namespace std; using namespace PVR; @@ -88,7 +87,7 @@ CDVDDemux* CDVDFactoryDemuxer::CreateDemuxer(CDVDInputStream* pInputStream) /* Use PVR demuxer only for live streams */ if (filename.substr(0, 14) == "pvr://channels") { - PVR_ADDON_CAPABILITIES *pProps = g_PVRClients->GetCurrentClientProperties(); + PVR_ADDON_CAPABILITIES *pProps = g_PVRManager.GetCurrentClientProperties(); if (pProps && pProps->bHandlesDemuxing) { auto_ptr demuxer(new CDVDDemuxPVRClient()); diff --git a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStream.h b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStream.h index 7bfa2da5ef63e..e4ff6131cb61a 100644 --- a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStream.h +++ b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStream.h @@ -55,8 +55,8 @@ class CDVDInputStream virtual bool NextChannel(bool preview = false) = 0; virtual bool PrevChannel(bool preview = false) = 0; virtual bool SelectChannelByNumber(unsigned int channel) = 0; - virtual bool SelectChannel(const PVR::CPVRChannel &channel) = 0; - virtual bool GetSelectedChannel(PVR::CPVRChannel *) = 0; + virtual bool SelectChannel(const PVR::CPVRChannel &channel) { return false; }; + virtual bool GetSelectedChannel(PVR::CPVRChannel *) { return false; }; virtual int GetTotalTime() = 0; virtual int GetStartTime() = 0; virtual bool UpdateItem(CFileItem& item) = 0; diff --git a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamTV.cpp b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamTV.cpp index 9c49531e99306..73855e33f62a2 100644 --- a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamTV.cpp +++ b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamTV.cpp @@ -26,7 +26,6 @@ #include "URL.h" using namespace XFILE; -using namespace PVR; CDVDInputStreamTV::CDVDInputStreamTV() : CDVDInputStream(DVDSTREAM_TYPE_TV) { @@ -150,12 +149,6 @@ bool CDVDInputStreamTV::SelectChannelByNumber(unsigned int channel) return m_pLiveTV->SelectChannel(channel); } -bool CDVDInputStreamTV::SelectChannel(const CPVRChannel &channel) -{ - if(!m_pLiveTV) return false; - return m_pLiveTV->SelectChannel(channel.ChannelNumber()); -} - bool CDVDInputStreamTV::UpdateItem(CFileItem& item) { if(m_pLiveTV) diff --git a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamTV.h b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamTV.h index e3b3910ed2a12..f2db5861d01fa 100644 --- a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamTV.h +++ b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamTV.h @@ -50,8 +50,6 @@ class CDVDInputStreamTV bool NextChannel(bool preview = false); bool PrevChannel(bool preview = false); bool SelectChannelByNumber(unsigned int channel); - bool SelectChannel(const PVR::CPVRChannel &channel); - bool GetSelectedChannel(PVR::CPVRChannel *channel) {return false; } int GetTotalTime(); int GetStartTime(); diff --git a/xbmc/epg/EpgContainer.cpp b/xbmc/epg/EpgContainer.cpp index 1ffbe8c67cd37..d3fb5ef42c505 100644 --- a/xbmc/epg/EpgContainer.cpp +++ b/xbmc/epg/EpgContainer.cpp @@ -35,7 +35,6 @@ #include "EpgSearchFilter.h" #include "pvr/PVRManager.h" -#include "pvr/addons/PVRClients.h" using namespace std; using namespace PVR; @@ -326,7 +325,7 @@ bool CEpgContainer::UpdateSingleTable(CEpg *epg, const time_t start, const time_ bool CEpgContainer::InterruptUpdate(void) const { - return (m_bStop || (g_PVRManager.IsStarted() && g_PVRClients->IsPlaying()));; + return (m_bStop || (g_PVRManager.IsStarted() && g_PVRManager.IsPlaying()));; } bool CEpgContainer::UpdateEPG(bool bShowProgress /* = false */) diff --git a/xbmc/epg/EpgInfoTag.cpp b/xbmc/epg/EpgInfoTag.cpp index 8488930a6c130..0e63c33f6dbd1 100644 --- a/xbmc/epg/EpgInfoTag.cpp +++ b/xbmc/epg/EpgInfoTag.cpp @@ -20,7 +20,7 @@ */ #include "guilib/LocalizeStrings.h" -#include "../addons/include/xbmc_pvr_types.h" +#include "../addons/include/xbmc_pvr_types.h" // TODO extract the epg specific stuff #include "EpgInfoTag.h" #include "EpgContainer.h" #include "EpgDatabase.h" diff --git a/xbmc/pvr/PVRManager.cpp b/xbmc/pvr/PVRManager.cpp index e26882ae28cc3..e227803d2cb53 100644 --- a/xbmc/pvr/PVRManager.cpp +++ b/xbmc/pvr/PVRManager.cpp @@ -338,11 +338,6 @@ void CPVRManager::UpdateWindow(PVRWindow window) pWindow->UpdateWindow(window); } -bool CPVRManager::IsRunningChannelScan(void) const -{ - return m_addons->IsRunningChannelScan(); -} - void CPVRManager::ResetProperties(void) { m_currentFile = NULL; @@ -1061,3 +1056,38 @@ bool CPVRManager::IsRunning(void) const CSingleLock lock(m_critSection); return !m_bStop; } + +bool CPVRManager::IsPlayingTV(void) const +{ + return m_addons->IsPlayingTV(); +} + +bool CPVRManager::IsPlayingRadio(void) const +{ + return m_addons->IsPlayingRadio(); +} + +bool CPVRManager::IsPlayingRecording(void) const +{ + return m_addons->IsPlayingRecording(); +} + +bool CPVRManager::IsRunningChannelScan(void) const +{ + return m_addons->IsRunningChannelScan(); +} + +PVR_ADDON_CAPABILITIES *CPVRManager::GetCurrentClientProperties(void) +{ + return m_addons->GetCurrentClientProperties(); +} + +void CPVRManager::StartChannelScan(void) +{ + return m_addons->StartChannelScan(); +} + +void CPVRManager::SearchMissingChannelIcons(void) +{ + return m_channelGroups->SearchMissingChannelIcons(); +} diff --git a/xbmc/pvr/PVRManager.h b/xbmc/pvr/PVRManager.h index 8b923be1a0797..b1b289a61136b 100644 --- a/xbmc/pvr/PVRManager.h +++ b/xbmc/pvr/PVRManager.h @@ -24,6 +24,7 @@ #include "utils/Observer.h" #include "utils/JobManager.h" #include "windows/GUIWindowPVRCommon.h" +#include "addons/include/xbmc_pvr_types.h" class CGUIDialogBusy; @@ -199,11 +200,6 @@ namespace PVR */ bool PerformChannelSwitch(const CPVRChannel &channel, bool bPreview); - /*! - * @return True if a channel scan is running. - */ - bool IsRunningChannelScan(void) const; - /*! * @brief Close an open PVR stream. */ @@ -357,6 +353,45 @@ namespace PVR */ void LocalizationChanged(void); + /*! + * @brief Check if a TV channel is playing. + * @return True if it's playing, false otherwise. + */ + bool IsPlayingTV(void) const; + + /*! + * @brief Check if a radio channel is playing. + * @return True if it's playing, false otherwise. + */ + bool IsPlayingRadio(void) const; + + /*! + * @brief Check if a recording is playing. + * @return True if it's playing, false otherwise. + */ + bool IsPlayingRecording(void) const; + + /*! + * @return True when a channel scan is currently running, false otherwise. + */ + bool IsRunningChannelScan(void) const; + + /*! + * @brief Get the properties of the current playing client. + * @return A pointer to the properties or NULL if no stream is playing. + */ + PVR_ADDON_CAPABILITIES *GetCurrentClientProperties(void); + + /*! + * @brief Open a selection dialog and start a channel scan on the selected client. + */ + void StartChannelScan(void); + + /*! + * @brief Try to find missing channel icons automatically + */ + void SearchMissingChannelIcons(void); + protected: /*! * @brief PVR update and control thread. diff --git a/xbmc/pvr/addons/PVRClients.h b/xbmc/pvr/addons/PVRClients.h index fae2380df210f..b3ce6ccf0fa20 100644 --- a/xbmc/pvr/addons/PVRClients.h +++ b/xbmc/pvr/addons/PVRClients.h @@ -243,6 +243,9 @@ namespace PVR */ bool IsPlayingRecording(void) const; + /*! + * @return True when a channel scan is currently running, false otherwise. + */ bool IsRunningChannelScan(void) const; /*! @@ -260,7 +263,7 @@ namespace PVR * @brief Get the properties of the current playing client. * @return A pointer to the properties or NULL if no stream is playing. */ - PVR_ADDON_CAPABILITIES*GetCurrentClientProperties(void); + PVR_ADDON_CAPABILITIES *GetCurrentClientProperties(void); /*! * @brief Get the ID of the client that is currently being used to play. diff --git a/xbmc/settings/GUIWindowSettingsCategory.cpp b/xbmc/settings/GUIWindowSettingsCategory.cpp index 90da37dd6315e..bc06201ef1ece 100644 --- a/xbmc/settings/GUIWindowSettingsCategory.cpp +++ b/xbmc/settings/GUIWindowSettingsCategory.cpp @@ -46,7 +46,6 @@ #include "network/libscrobbler/librefmscrobbler.h" #include "GUIPassword.h" #include "GUIInfoManager.h" -#include "pvr/dialogs/GUIDialogPVRChannelManager.h" #include "dialogs/GUIDialogGamepad.h" #include "dialogs/GUIDialogNumeric.h" #include "dialogs/GUIDialogFileBrowser.h" @@ -83,9 +82,8 @@ #include "XBMCHelper.h" #endif #endif -#include "pvr/channels/PVRChannelGroupsContainer.h" +#include "pvr/dialogs/GUIDialogPVRChannelManager.h" #include "pvr/PVRManager.h" -#include "pvr/addons/PVRClients.h" #include "network/GUIDialogAccessPoints.h" #include "filesystem/Directory.h" @@ -1922,7 +1920,7 @@ void CGUIWindowSettingsCategory::OnSettingChanged(CBaseSettingControl *pSettingC } else if (strSetting.Equals("pvrmenu.searchicons")) { - g_PVRChannelGroups->SearchMissingChannelIcons(); + g_PVRManager.SearchMissingChannelIcons(); } else if (strSetting.Equals("pvrmanager.resetdb")) { @@ -1937,7 +1935,7 @@ void CGUIWindowSettingsCategory::OnSettingChanged(CBaseSettingControl *pSettingC else if (strSetting.Equals("pvrmanager.channelscan")) { if (CGUIDialogYesNo::ShowAndGetInput(19098, 19118, 19194, 0)) - g_PVRClients->StartChannelScan(); + g_PVRManager.StartChannelScan(); } else if (strSetting.Equals("pvrmanager.channelmanager")) { diff --git a/xbmc/video/windows/GUIWindowFullScreen.cpp b/xbmc/video/windows/GUIWindowFullScreen.cpp index 2d85796f88791..687ed5fcb4acb 100644 --- a/xbmc/video/windows/GUIWindowFullScreen.cpp +++ b/xbmc/video/windows/GUIWindowFullScreen.cpp @@ -54,7 +54,6 @@ #include "pvr/PVRManager.h" #include "pvr/channels/PVRChannelGroupsContainer.h" -#include "pvr/addons/PVRClients.h" #include @@ -703,7 +702,7 @@ bool CGUIWindowFullScreen::OnMessage(CGUIMessage& message) CStdString strLabel = msg.GetLabel(); if (msg.GetParam1() != 0) { - const CPVRChannelGroups *groups = g_PVRChannelGroups->Get(g_PVRClients->IsPlayingRadio()); + const CPVRChannelGroups *groups = g_PVRChannelGroups->Get(g_PVRManager.IsPlayingRadio()); CPVRChannelGroup *selectedGroup = (CPVRChannelGroup *) groups->GetByName(strLabel); // Switch to the first channel of the new group if the new group ID is @@ -1113,7 +1112,7 @@ void CGUIWindowFullScreen::FillInTVGroups() CGUIMessage msgReset(GUI_MSG_LABEL_RESET, GetID(), CONTROL_GROUP_CHOOSER); g_windowManager.SendMessage(msgReset); - const CPVRChannelGroups *groups = g_PVRChannelGroups->Get(g_PVRClients->IsPlayingRadio()); + const CPVRChannelGroups *groups = g_PVRChannelGroups->Get(g_PVRManager.IsPlayingRadio()); int iGroup = 0; int iCurrentGroup = 0; From 6bf5dbff31c7d17ce56a2227f2346f78bfa5e0ac Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Thu, 21 Apr 2011 00:49:18 +0200 Subject: [PATCH 06/47] tvheadend addon: read extra stream info when it's available. return EAC3 stream name --- .../dvdplayer/DVDDemuxers/DVDDemuxPVRClient.cpp | 2 ++ xbmc/pvrclients/tvheadend/HTSPData.cpp | 7 +++---- xbmc/pvrclients/tvheadend/HTSPData.h | 1 + xbmc/pvrclients/tvheadend/HTSPDemux.cpp | 16 +++++++++++++++- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxPVRClient.cpp b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxPVRClient.cpp index 4577238319de1..5693bd5326120 100644 --- a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxPVRClient.cpp +++ b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxPVRClient.cpp @@ -265,5 +265,7 @@ void CDVDDemuxPVRClient::GetStreamCodecName(int iStreamId, CStdString &strName) strName = "mpeg2video"; else if (stream->codec == CODEC_ID_H264) strName = "h264"; + else if (stream->codec == CODEC_ID_EAC3) + strName = "eac3"; } } diff --git a/xbmc/pvrclients/tvheadend/HTSPData.cpp b/xbmc/pvrclients/tvheadend/HTSPData.cpp index b1ba9de2cdd3d..2ae016aa1b3e9 100644 --- a/xbmc/pvrclients/tvheadend/HTSPData.cpp +++ b/xbmc/pvrclients/tvheadend/HTSPData.cpp @@ -73,11 +73,10 @@ bool cHTSPData::Open(const std::string &strHostname, unsigned int iPort, const s void cHTSPData::Close() { if (IsConnected()) - { m_session.Abort(); - Cancel(1); - m_session.Close(); - } + + Cancel(1); + m_session.Close(); } htsmsg_t* cHTSPData::ReadResult(htsmsg_t *m) diff --git a/xbmc/pvrclients/tvheadend/HTSPData.h b/xbmc/pvrclients/tvheadend/HTSPData.h index 5360a45f77888..dbba10850a6c4 100644 --- a/xbmc/pvrclients/tvheadend/HTSPData.h +++ b/xbmc/pvrclients/tvheadend/HTSPData.h @@ -89,4 +89,5 @@ class cHTSPData : public cThread SEvents m_events; SMessages m_queue; SRecordings m_recordings; + int m_iReconnectRetries; }; diff --git a/xbmc/pvrclients/tvheadend/HTSPDemux.cpp b/xbmc/pvrclients/tvheadend/HTSPDemux.cpp index dd438e27efd6b..a04a828b8f69f 100644 --- a/xbmc/pvrclients/tvheadend/HTSPDemux.cpp +++ b/xbmc/pvrclients/tvheadend/HTSPDemux.cpp @@ -272,7 +272,7 @@ void cHTSPDemux::SubscriptionStart(htsmsg_t *m) { uint32_t index; const char* type; - htsmsg_t* sub; + htsmsg_t* sub; if (f->hmf_type != HMF_MAP) continue; @@ -313,6 +313,9 @@ void cHTSPDemux::SubscriptionStart(htsmsg_t *m) m_Streams.stream[m_Streams.iStreamCount].iPhysicalId = index; m_Streams.stream[m_Streams.iStreamCount].iCodecType = CODEC_TYPE_AUDIO; m_Streams.stream[m_Streams.iStreamCount].iCodecId = CODEC_ID_AC3; + m_Streams.stream[m_Streams.iStreamCount].iChannels = htsmsg_get_u32_or_default(sub, "channels" , 0); + m_Streams.stream[m_Streams.iStreamCount].iSampleRate = htsmsg_get_u32_or_default(sub, "rate" , 0); + XBMC->Log(LOG_DEBUG, "channels = %d, rate = %d", m_Streams.stream[m_Streams.iStreamCount].iChannels, m_Streams.stream[m_Streams.iStreamCount].iSampleRate); SetLanguageInfo(language, m_Streams.stream[m_Streams.iStreamCount].strLanguage); m_Streams.iStreamCount++; } @@ -322,6 +325,9 @@ void cHTSPDemux::SubscriptionStart(htsmsg_t *m) m_Streams.stream[m_Streams.iStreamCount].iPhysicalId = index; m_Streams.stream[m_Streams.iStreamCount].iCodecType = CODEC_TYPE_AUDIO; m_Streams.stream[m_Streams.iStreamCount].iCodecId = CODEC_ID_EAC3; + m_Streams.stream[m_Streams.iStreamCount].iChannels = htsmsg_get_u32_or_default(sub, "channels" , 0); + m_Streams.stream[m_Streams.iStreamCount].iSampleRate = htsmsg_get_u32_or_default(sub, "rate" , 0); + XBMC->Log(LOG_DEBUG, "channels = %d, rate = %d", m_Streams.stream[m_Streams.iStreamCount].iChannels, m_Streams.stream[m_Streams.iStreamCount].iSampleRate); SetLanguageInfo(language, m_Streams.stream[m_Streams.iStreamCount].strLanguage); m_Streams.iStreamCount++; } @@ -331,6 +337,9 @@ void cHTSPDemux::SubscriptionStart(htsmsg_t *m) m_Streams.stream[m_Streams.iStreamCount].iPhysicalId = index; m_Streams.stream[m_Streams.iStreamCount].iCodecType = CODEC_TYPE_AUDIO; m_Streams.stream[m_Streams.iStreamCount].iCodecId = CODEC_ID_MP2; + m_Streams.stream[m_Streams.iStreamCount].iChannels = htsmsg_get_u32_or_default(sub, "channels" , 0); + m_Streams.stream[m_Streams.iStreamCount].iSampleRate = htsmsg_get_u32_or_default(sub, "rate" , 0); + XBMC->Log(LOG_DEBUG, "channels = %d, rate = %d", m_Streams.stream[m_Streams.iStreamCount].iChannels, m_Streams.stream[m_Streams.iStreamCount].iSampleRate); SetLanguageInfo(language, m_Streams.stream[m_Streams.iStreamCount].strLanguage); m_Streams.iStreamCount++; } @@ -340,6 +349,9 @@ void cHTSPDemux::SubscriptionStart(htsmsg_t *m) m_Streams.stream[m_Streams.iStreamCount].iPhysicalId = index; m_Streams.stream[m_Streams.iStreamCount].iCodecType = CODEC_TYPE_AUDIO; m_Streams.stream[m_Streams.iStreamCount].iCodecId = CODEC_ID_AAC; + m_Streams.stream[m_Streams.iStreamCount].iChannels = htsmsg_get_u32_or_default(sub, "channels" , 0); + m_Streams.stream[m_Streams.iStreamCount].iSampleRate = htsmsg_get_u32_or_default(sub, "rate" , 0); + XBMC->Log(LOG_DEBUG, "channels = %d, rate = %d", m_Streams.stream[m_Streams.iStreamCount].iChannels, m_Streams.stream[m_Streams.iStreamCount].iSampleRate); SetLanguageInfo(language, m_Streams.stream[m_Streams.iStreamCount].strLanguage); m_Streams.iStreamCount++; } @@ -351,6 +363,7 @@ void cHTSPDemux::SubscriptionStart(htsmsg_t *m) m_Streams.stream[m_Streams.iStreamCount].iCodecId = CODEC_ID_MPEG2VIDEO; m_Streams.stream[m_Streams.iStreamCount].iWidth = htsmsg_get_u32_or_default(sub, "width" , 0); m_Streams.stream[m_Streams.iStreamCount].iHeight = htsmsg_get_u32_or_default(sub, "height" , 0); + m_Streams.stream[m_Streams.iStreamCount].fAspect = (float) (htsmsg_get_u32_or_default(sub, "aspect_num", 1) / htsmsg_get_u32_or_default(sub, "aspect_den", 1)); m_Streams.iStreamCount++; } else if(!strcmp(type, "H264")) @@ -361,6 +374,7 @@ void cHTSPDemux::SubscriptionStart(htsmsg_t *m) m_Streams.stream[m_Streams.iStreamCount].iCodecId = CODEC_ID_H264; m_Streams.stream[m_Streams.iStreamCount].iWidth = htsmsg_get_u32_or_default(sub, "width" , 0); m_Streams.stream[m_Streams.iStreamCount].iHeight = htsmsg_get_u32_or_default(sub, "height" , 0); + m_Streams.stream[m_Streams.iStreamCount].fAspect = (float) (htsmsg_get_u32_or_default(sub, "aspect_num", 1) / htsmsg_get_u32_or_default(sub, "aspect_den", 1)); m_Streams.iStreamCount++; } else if(!strcmp(type, "DVBSUB")) From 270062eb1b7af57c698f4f48d08e49b1ba8f355c Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Thu, 21 Apr 2011 14:59:44 +0200 Subject: [PATCH 07/47] epg: move GUIEPGGridContainer to from xbmc/guilib to xbmc/epg --- xbmc/{guilib => epg}/GUIEPGGridContainer.cpp | 13 +++++++------ xbmc/{guilib => epg}/GUIEPGGridContainer.h | 0 xbmc/epg/Makefile | 3 ++- xbmc/guilib/GUIControlFactory.cpp | 2 +- xbmc/guilib/Makefile.in | 1 - xbmc/pvr/windows/GUIWindowPVR.h | 2 +- xbmc/pvr/windows/GUIWindowPVRGuide.h | 2 +- 7 files changed, 12 insertions(+), 11 deletions(-) rename xbmc/{guilib => epg}/GUIEPGGridContainer.cpp (99%) rename xbmc/{guilib => epg}/GUIEPGGridContainer.h (100%) diff --git a/xbmc/guilib/GUIEPGGridContainer.cpp b/xbmc/epg/GUIEPGGridContainer.cpp similarity index 99% rename from xbmc/guilib/GUIEPGGridContainer.cpp rename to xbmc/epg/GUIEPGGridContainer.cpp index 0b0e53d3ff34e..abb0fb568976d 100644 --- a/xbmc/guilib/GUIEPGGridContainer.cpp +++ b/xbmc/epg/GUIEPGGridContainer.cpp @@ -19,20 +19,21 @@ * */ -#include "Key.h" -#include "GUIEPGGridContainer.h" -#include "GUIControlFactory.h" -#include "GUIListItem.h" -#include "GUIFontManager.h" +#include "guilib/Key.h" +#include "guilib/GUIControlFactory.h" +#include "guilib/GUIListItem.h" +#include "guilib/GUIFontManager.h" +#include "guilib/LocalizeStrings.h" #include "lib/tinyXML/tinyxml.h" #include "utils/log.h" #include "utils/TimeUtils.h" #include "GUIInfoManager.h" -#include "LocalizeStrings.h" #include "pvr/epg/PVREpgInfoTag.h" #include "pvr/channels/PVRChannel.h" +#include "GUIEPGGridContainer.h" + using namespace PVR; #define SHORTGAP 5 // how many blocks is considered a short-gap in nav logic diff --git a/xbmc/guilib/GUIEPGGridContainer.h b/xbmc/epg/GUIEPGGridContainer.h similarity index 100% rename from xbmc/guilib/GUIEPGGridContainer.h rename to xbmc/epg/GUIEPGGridContainer.h diff --git a/xbmc/epg/Makefile b/xbmc/epg/Makefile index 2f4a04930f685..a52ad6113e2e6 100644 --- a/xbmc/epg/Makefile +++ b/xbmc/epg/Makefile @@ -4,7 +4,8 @@ SRCS=EpgInfoTag.cpp \ EpgSearchFilter.cpp \ Epg.cpp \ EpgContainer.cpp \ - EpgDatabase.cpp + EpgDatabase.cpp \ + GUIEPGGridContainer.cpp LIB=epg.a diff --git a/xbmc/guilib/GUIControlFactory.cpp b/xbmc/guilib/GUIControlFactory.cpp index 3959822d112c5..f3446c818711f 100644 --- a/xbmc/guilib/GUIControlFactory.cpp +++ b/xbmc/guilib/GUIControlFactory.cpp @@ -50,7 +50,7 @@ #include "GUIListContainer.h" #include "GUIFixedListContainer.h" #include "GUIWrappingListContainer.h" -#include "GUIEPGGridContainer.h" +#include "epg/GUIEPGGridContainer.h" #include "GUIPanelContainer.h" #include "GUIMultiSelectText.h" #include "GUIListLabel.h" diff --git a/xbmc/guilib/Makefile.in b/xbmc/guilib/Makefile.in index 539868941a47a..36e8554302cc1 100644 --- a/xbmc/guilib/Makefile.in +++ b/xbmc/guilib/Makefile.in @@ -18,7 +18,6 @@ SRCS=AnimatedGif.cpp \ GUIControlProfiler.cpp \ GUIDialog.cpp \ GUIEditControl.cpp \ - GUIEPGGridContainer.cpp \ GUIFadeLabelControl.cpp \ GUIFixedListContainer.cpp \ GUIFont.cpp \ diff --git a/xbmc/pvr/windows/GUIWindowPVR.h b/xbmc/pvr/windows/GUIWindowPVR.h index 67f90d2ada3f0..4e8c608f681c9 100644 --- a/xbmc/pvr/windows/GUIWindowPVR.h +++ b/xbmc/pvr/windows/GUIWindowPVR.h @@ -22,7 +22,7 @@ */ #include "GUIWindowPVRCommon.h" -#include "guilib/GUIEPGGridContainer.h" +#include "epg/GUIEPGGridContainer.h" #include "threads/CriticalSection.h" namespace PVR diff --git a/xbmc/pvr/windows/GUIWindowPVRGuide.h b/xbmc/pvr/windows/GUIWindowPVRGuide.h index ffc00262e22a6..3f7e54df323c7 100644 --- a/xbmc/pvr/windows/GUIWindowPVRGuide.h +++ b/xbmc/pvr/windows/GUIWindowPVRGuide.h @@ -22,7 +22,7 @@ */ #include "GUIWindowPVRCommon.h" -#include "guilib/GUIEPGGridContainer.h" +#include "epg/GUIEPGGridContainer.h" #include "threads/CriticalSection.h" #include "utils/Observer.h" From 8f94027fdacd17abeac7cf9d02344dc91c406c2d Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Thu, 21 Apr 2011 15:36:41 +0200 Subject: [PATCH 08/47] epg: stick all EPG related sources in a new EPG namespace and make CEpgContainer a singleton --- xbmc/FileItem.cpp | 1 + xbmc/FileItem.h | 13 +- xbmc/epg/Epg.cpp | 16 +- xbmc/epg/Epg.h | 568 ++++++++-------- xbmc/epg/EpgContainer.cpp | 12 +- xbmc/epg/EpgContainer.h | 402 +++++------ xbmc/epg/EpgDatabase.cpp | 9 +- xbmc/epg/EpgDatabase.h | 263 ++++---- xbmc/epg/EpgInfoTag.cpp | 76 ++- xbmc/epg/EpgInfoTag.h | 732 ++++++++++----------- xbmc/epg/EpgSearchFilter.cpp | 1 + xbmc/epg/EpgSearchFilter.h | 63 +- xbmc/epg/GUIEPGGridContainer.cpp | 1 + xbmc/epg/GUIEPGGridContainer.h | 369 +++++------ xbmc/guilib/GUIControlFactory.cpp | 1 + xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.cpp | 1 + xbmc/pvr/epg/PVREpg.cpp | 1 + xbmc/pvr/epg/PVREpg.h | 4 +- xbmc/pvr/epg/PVREpgContainer.cpp | 1 + xbmc/pvr/epg/PVREpgContainer.h | 4 +- xbmc/pvr/epg/PVREpgInfoTag.cpp | 19 +- xbmc/pvr/epg/PVREpgInfoTag.h | 9 +- xbmc/pvr/epg/PVREpgSearchFilter.cpp | 1 + xbmc/pvr/epg/PVREpgSearchFilter.h | 2 +- xbmc/pvr/timers/PVRTimers.cpp | 1 + xbmc/pvr/timers/PVRTimers.h | 7 +- xbmc/pvr/windows/GUIWindowPVR.h | 2 +- xbmc/pvr/windows/GUIWindowPVRGuide.cpp | 1 + 28 files changed, 1318 insertions(+), 1262 deletions(-) diff --git a/xbmc/FileItem.cpp b/xbmc/FileItem.cpp index fc94fea36210d..ef377d11b32aa 100644 --- a/xbmc/FileItem.cpp +++ b/xbmc/FileItem.cpp @@ -67,6 +67,7 @@ using namespace XFILE; using namespace PLAYLIST; using namespace MUSIC_INFO; using namespace PVR; +using namespace EPG; CFileItem::CFileItem(const CSong& song) { diff --git a/xbmc/FileItem.h b/xbmc/FileItem.h index 5ef11d7ae1e71..4e5f0cf704239 100644 --- a/xbmc/FileItem.h +++ b/xbmc/FileItem.h @@ -42,7 +42,10 @@ namespace MUSIC_INFO class CMusicInfoTag; } class CVideoInfoTag; -class CEpgInfoTag; +namespace EPG +{ + class CEpgInfoTag; +} namespace PVR { class CPVREpgInfoTag; @@ -83,7 +86,7 @@ class CFileItem : CFileItem(const CGenre& genre); CFileItem(const CVideoInfoTag& movie); CFileItem(const PVR::CPVREpgInfoTag& tag); - CFileItem(const CEpgInfoTag& tag); + CFileItem(const EPG::CEpgInfoTag& tag); CFileItem(const PVR::CPVRChannel& channel); CFileItem(const PVR::CPVRRecording& record); CFileItem(const PVR::CPVRTimerInfoTag& timer); @@ -202,9 +205,9 @@ class CFileItem : return m_epgInfoTag != NULL; } - CEpgInfoTag* GetEPGInfoTag(); + EPG::CEpgInfoTag* GetEPGInfoTag(); - inline const CEpgInfoTag* GetEPGInfoTag() const + inline const EPG::CEpgInfoTag* GetEPGInfoTag() const { return m_epgInfoTag; } @@ -371,7 +374,7 @@ class CFileItem : CStdString m_extrainfo; MUSIC_INFO::CMusicInfoTag* m_musicInfoTag; CVideoInfoTag* m_videoInfoTag; - CEpgInfoTag* m_epgInfoTag; + EPG::CEpgInfoTag* m_epgInfoTag; PVR::CPVRChannel* m_pvrChannelInfoTag; PVR::CPVRRecording* m_pvrRecordingInfoTag; PVR::CPVRTimerInfoTag * m_pvrTimerInfoTag; diff --git a/xbmc/epg/Epg.cpp b/xbmc/epg/Epg.cpp index e0e618142b230..b9447342ebd23 100644 --- a/xbmc/epg/Epg.cpp +++ b/xbmc/epg/Epg.cpp @@ -28,6 +28,8 @@ #include "EpgDatabase.h" #include "EpgContainer.h" +using namespace EPG; + struct sortEPGbyDate { bool operator()(CEpgInfoTag* strItem1, CEpgInfoTag* strItem2) @@ -39,14 +41,14 @@ struct sortEPGbyDate } }; -CEpg::CEpg(int iEpgID, const CStdString &strName /* = "" */, const CStdString &strScraperName /* = "" */) +CEpg::CEpg(int iEpgID, const CStdString &strName /* = "" */, const CStdString &strScraperName /* = "" */) : + m_iEpgID(iEpgID), + m_strName(strName), + m_strScraperName(strScraperName), + m_nowActive(NULL), + m_Channel(NULL), + m_bInhibitSorting(false) { - m_iEpgID = iEpgID; - m_strName = strName; - m_strScraperName = strScraperName; - m_nowActive = NULL; - m_Channel = NULL; - m_bInhibitSorting = false; m_lastScanTime.SetValid(false); m_firstDate.SetValid(false); m_lastDate.SetValid(false); diff --git a/xbmc/epg/Epg.h b/xbmc/epg/Epg.h index e91c01fc75557..74687d9fa1179 100644 --- a/xbmc/epg/Epg.h +++ b/xbmc/epg/Epg.h @@ -28,7 +28,10 @@ #include "EpgInfoTag.h" #include "EpgSearchFilter.h" -class CEpgContainer; +namespace EPG +{ + class CEpgContainer; +} namespace PVR { @@ -38,284 +41,287 @@ namespace PVR /** EPG container for CEpgInfoTag instances */ -class CEpg : public std::vector +namespace EPG { - friend class CEpgDatabase; - friend class CPVREpgContainer; - friend class CEpgContainer; - friend class CPVREpg; - -protected: - CStdString m_strName; /*!< the name of this table */ - CStdString m_strScraperName; /*!< the name of the scraper to use */ - int m_iEpgID; /*!< the database ID of this table */ - CDateTime m_lastScanTime; /*!< the last time the EPG has been updated */ - bool m_bInhibitSorting; /*!< don't sort the table if this is true */ - mutable const CEpgInfoTag *m_nowActive; /*!< the tag that is currently active */ - - mutable CCriticalSection m_critSection; /*!< critical section for changes in this table */ - - PVR::CPVRChannel * m_Channel; /*!< the channel this EPG belongs to */ - CDateTime m_firstDate; /*!< start time of the first epg event in this table */ - CDateTime m_lastDate; /*!< end time of the last epg event in this table */ - - /*! - * @brief Update the EPG from a scraper set in the channel tag. - * TODO: not implemented yet - * @param start Get entries with a start date after this time. - * @param end Get entries with an end date before this time. - * @return True if the update was successful, false otherwise. - */ - virtual bool UpdateFromScraper(time_t start, time_t end); - - /*! - * @brief Persist all tags in this container. - * @param bQueueWrite Don't execute the query immediately but queue it if true. - * @return True if all tags were persisted, false otherwise. - */ - virtual bool PersistTags(bool bQueueWrite = false) const; - - /*! - * @brief Fix overlapping events from the tables. - * @param bStore Store in the database if true. - * @return True if the events were fixed successfully, false otherwise. - */ - virtual bool FixOverlappingEvents(bool bStore = true); - - /*! - * @brief Create a new tag. - * @return The new tag. - */ - virtual CEpgInfoTag *CreateTag(void); - - /*! - * @brief Sort all entries in this EPG by date. - */ - virtual void Sort(void); - - /*! - * @brief Add an infotag to this container. - * @param tag The tag to add. - */ - virtual void AddEntry(const CEpgInfoTag &tag); - - /*! - * @brief Remove all tags between begin and end from this table. - * @param begin Remove all entries after this start time. Use 0 to remove all entries before "end". - * @param end Remove all entries before this end time. Use 0 to remove all before after "begin". If both "begin" and "end" are 0, all entries will be removed. - * @param bRemoveFromDb Set to true to remove these entries from the database too. - */ - virtual void RemoveTagsBetween(time_t begin, time_t end, bool bRemoveFromDb = false); - - /*! - * @see RemoveTagsBetween(time_t begin, time_t end, bool bRemoveFromDb = false) - */ - virtual void RemoveTagsBetween(const CDateTime &begin, const CDateTime &end, bool bRemoveFromDb = false); - - /*! - * @brief Load all EPG entries from clients into a temporary table and update this table with the contents of that temporary table. - * @param start Only get entries after this start time. Use 0 to get all entries before "end". - * @param end Only get entries before this end time. Use 0 to get all entries after "begin". If both "begin" and "end" are 0, all entries will be updated. - * @return True if the update was successful, false otherwise. - */ - virtual bool LoadFromClients(time_t start, time_t end); - - /*! - * @brief Update the contents of this table with the contents provided in "epg" - * @param epg The updated contents. - * @param bStoreInDb True to store the updated contents in the db, false otherwise. - * @return True if the update was successful, false otherwise. - */ - virtual bool UpdateEntries(const CEpg &epg, bool bStoreInDb = true); - - /*! - * @brief Update the cached first and last date. - */ - virtual void UpdateFirstAndLastDates(void); - -protected: - /*! - * @brief Update this table's info with the given info. Doesn't change the EpgID. - * @param epg The new info. - * @param bUpdateDb If true, persist the changes. - * @return True if the update was successful, false otherwise. - */ - virtual bool Update(const CEpg &epg, bool bUpdateDb = false); - - /*! - * @brief Load all entries for this table from the database. - * @return True if any entries were loaded, false otherwise. - */ - bool Load(void); - -public: - /*! - * @brief Create a new EPG instance. - * @param iEpgID The ID of this table or <= 0 to create a new ID. - * @param strName The name of this table. - * @param strScraperName The name of the scraper to use. - */ - CEpg(int iEpgID, const CStdString &strName = "", const CStdString &strScraperName = ""); - - /*! - * @brief Destroy this EPG instance. - */ - virtual ~CEpg(void); - - /*! - * @brief The channel this EPG belongs to. - * @return The channel this EPG belongs to - */ - const PVR::CPVRChannel *Channel(void) const { return m_Channel; } - - /*! - * @brief Channel the channel tag linked to this EPG table. - * @param channel The new channel tag. - */ - virtual void SetChannel(PVR::CPVRChannel *channel) { m_Channel = channel; } - - /*! - * @brief Get the name of the scraper to use for this table. - * @return The name of the scraper to use for this table. - */ - const CStdString &ScraperName(void) const { return m_strScraperName; } - - /*! - * @brief Get the name of this table. - * @return The name of this table. - */ - const CStdString &Name(void) const { return m_strName; } - - /*! - * @brief Get the database ID of this table. - * @return The database ID of this table. - */ - virtual int EpgID(void) const { return m_iEpgID; } - - /*! - * @brief Check whether this EPG contains valid entries. - * @return True if it has valid entries, false if not. - */ - virtual bool HasValidEntries(void) const; - - /*! - * @brief Delete an infotag from this EPG. - * @param tag The tag to delete. - * @return True if it was deleted successfully, false if not. - */ - virtual bool DeleteInfoTag(CEpgInfoTag *tag); - - /*! - * @brief Remove all entries from this EPG that finished before the given time - * and that have no timers set. - * @param Time Delete entries with an end time before this time in UTC. - */ - virtual void Cleanup(const CDateTime &Time); - - /*! - * @brief Remove all entries from this EPG that finished before the given time - * and that have no timers set. - */ - virtual void Cleanup(void); - - /*! - * @brief Remove all entries from this EPG. - */ - virtual void Clear(void); - - /*! - * @brief Get the event that is occurring now. - * @return The current event. - */ - virtual const CEpgInfoTag *InfoTagNow(void) const; - - /*! - * @brief Get the event that will occur next. - * @return The next event. - */ - virtual const CEpgInfoTag *InfoTagNext(void) const; - - /*! - * @brief Get the event that occurs at the given time. - * @param time The time to find the event for. - * @return The found tag or NULL if it wasn't found. - */ - virtual const CEpgInfoTag *GetTagAround(const CDateTime &time) const; - - /*! - * Get the event that occurs between the given begin and end time. - * @param beginTime Minimum start time of the event. - * @param endTime Maximum end time of the event. - * @return The found tag or NULL if it wasn't found. - */ - virtual const CEpgInfoTag *GetTagBetween(const CDateTime &beginTime, const CDateTime &endTime) const; - - /*! - * @brief Get the infotag with the given ID. - * - * Get the infotag with the given ID. - * If it wasn't found, try finding the event with the given start time - * - * @param uniqueID The unique ID of the event to find. - * @param beginTime The start time of the event to find if it wasn't found by it's unique ID. - * @return The found tag or NULL if it wasn't found. - */ - virtual const CEpgInfoTag *GetTag(int uniqueID, const CDateTime &beginTime) const; - - /*! - * @brief Update an entry in this EPG. - * @param tag The tag to update. - * @param bUpdateDatabase If set to true, this event will be persisted in the database. - * @return True if it was updated successfully, false otherwise. - */ - virtual bool UpdateEntry(const CEpgInfoTag &tag, bool bUpdateDatabase = false); - - /*! - * @brief Update the EPG from 'start' till 'end'. - * @param start The start time. - * @param end The end time. - * @param iUpdateTime Update the table after the given amount of time has passed. - * @return True if the update was successful, false otherwise. - */ - virtual bool Update(const time_t start, const time_t end, int iUpdateTime); - - /*! - * @brief Get all EPG entries. - * @param results The file list to store the results in. - * @return The amount of entries that were added. - */ - virtual int Get(CFileItemList *results) const; - - /*! - * @brief Get all EPG entries that and apply a filter. - * @param results The file list to store the results in. - * @param filter The filter to apply. - * @return The amount of entries that were added. - */ - virtual int Get(CFileItemList *results, const EpgSearchFilter &filter) const; - - /*! - * @brief Persist this table in the database. - * @param bPersistTags Set to true to persist all changed tags in this container. - * @param bQueueWrite Don't execute the query immediately but queue it if true. - * @return True if the table was persisted, false otherwise. - */ - virtual bool Persist(bool bPersistTags = false, bool bQueueWrite = false); - - /*! - * @brief Get the start time of the first entry in this table. - * @return The first date. - */ - virtual const CDateTime &GetFirstDate(void) const; - - /*! - * @brief Get the end time of the last entry in this table. - * @return The last date. - */ - virtual const CDateTime &GetLastDate(void) const; - - /*! - * @return The last time this table was scanned. - */ - virtual const CDateTime &GetLastScanTime(void); -}; + class CEpg : public std::vector + { + friend class CEpgDatabase; + friend class CPVREpgContainer; + friend class CEpgContainer; + friend class CPVREpg; + + protected: + CStdString m_strName; /*!< the name of this table */ + CStdString m_strScraperName; /*!< the name of the scraper to use */ + int m_iEpgID; /*!< the database ID of this table */ + CDateTime m_lastScanTime; /*!< the last time the EPG has been updated */ + bool m_bInhibitSorting; /*!< don't sort the table if this is true */ + mutable const CEpgInfoTag *m_nowActive; /*!< the tag that is currently active */ + + mutable CCriticalSection m_critSection; /*!< critical section for changes in this table */ + + PVR::CPVRChannel * m_Channel; /*!< the channel this EPG belongs to */ + CDateTime m_firstDate; /*!< start time of the first epg event in this table */ + CDateTime m_lastDate; /*!< end time of the last epg event in this table */ + + /*! + * @brief Update the EPG from a scraper set in the channel tag. + * TODO: not implemented yet + * @param start Get entries with a start date after this time. + * @param end Get entries with an end date before this time. + * @return True if the update was successful, false otherwise. + */ + virtual bool UpdateFromScraper(time_t start, time_t end); + + /*! + * @brief Persist all tags in this container. + * @param bQueueWrite Don't execute the query immediately but queue it if true. + * @return True if all tags were persisted, false otherwise. + */ + virtual bool PersistTags(bool bQueueWrite = false) const; + + /*! + * @brief Fix overlapping events from the tables. + * @param bStore Store in the database if true. + * @return True if the events were fixed successfully, false otherwise. + */ + virtual bool FixOverlappingEvents(bool bStore = true); + + /*! + * @brief Create a new tag. + * @return The new tag. + */ + virtual CEpgInfoTag *CreateTag(void); + + /*! + * @brief Sort all entries in this EPG by date. + */ + virtual void Sort(void); + + /*! + * @brief Add an infotag to this container. + * @param tag The tag to add. + */ + virtual void AddEntry(const CEpgInfoTag &tag); + + /*! + * @brief Remove all tags between begin and end from this table. + * @param begin Remove all entries after this start time. Use 0 to remove all entries before "end". + * @param end Remove all entries before this end time. Use 0 to remove all before after "begin". If both "begin" and "end" are 0, all entries will be removed. + * @param bRemoveFromDb Set to true to remove these entries from the database too. + */ + virtual void RemoveTagsBetween(time_t begin, time_t end, bool bRemoveFromDb = false); + + /*! + * @see RemoveTagsBetween(time_t begin, time_t end, bool bRemoveFromDb = false) + */ + virtual void RemoveTagsBetween(const CDateTime &begin, const CDateTime &end, bool bRemoveFromDb = false); + + /*! + * @brief Load all EPG entries from clients into a temporary table and update this table with the contents of that temporary table. + * @param start Only get entries after this start time. Use 0 to get all entries before "end". + * @param end Only get entries before this end time. Use 0 to get all entries after "begin". If both "begin" and "end" are 0, all entries will be updated. + * @return True if the update was successful, false otherwise. + */ + virtual bool LoadFromClients(time_t start, time_t end); + + /*! + * @brief Update the contents of this table with the contents provided in "epg" + * @param epg The updated contents. + * @param bStoreInDb True to store the updated contents in the db, false otherwise. + * @return True if the update was successful, false otherwise. + */ + virtual bool UpdateEntries(const CEpg &epg, bool bStoreInDb = true); + + /*! + * @brief Update the cached first and last date. + */ + virtual void UpdateFirstAndLastDates(void); + + protected: + /*! + * @brief Update this table's info with the given info. Doesn't change the EpgID. + * @param epg The new info. + * @param bUpdateDb If true, persist the changes. + * @return True if the update was successful, false otherwise. + */ + virtual bool Update(const CEpg &epg, bool bUpdateDb = false); + + /*! + * @brief Load all entries for this table from the database. + * @return True if any entries were loaded, false otherwise. + */ + bool Load(void); + + public: + /*! + * @brief Create a new EPG instance. + * @param iEpgID The ID of this table or <= 0 to create a new ID. + * @param strName The name of this table. + * @param strScraperName The name of the scraper to use. + */ + CEpg(int iEpgID, const CStdString &strName = "", const CStdString &strScraperName = ""); + + /*! + * @brief Destroy this EPG instance. + */ + virtual ~CEpg(void); + + /*! + * @brief The channel this EPG belongs to. + * @return The channel this EPG belongs to + */ + const PVR::CPVRChannel *Channel(void) const { return m_Channel; } + + /*! + * @brief Channel the channel tag linked to this EPG table. + * @param channel The new channel tag. + */ + virtual void SetChannel(PVR::CPVRChannel *channel) { m_Channel = channel; } + + /*! + * @brief Get the name of the scraper to use for this table. + * @return The name of the scraper to use for this table. + */ + const CStdString &ScraperName(void) const { return m_strScraperName; } + + /*! + * @brief Get the name of this table. + * @return The name of this table. + */ + const CStdString &Name(void) const { return m_strName; } + + /*! + * @brief Get the database ID of this table. + * @return The database ID of this table. + */ + virtual int EpgID(void) const { return m_iEpgID; } + + /*! + * @brief Check whether this EPG contains valid entries. + * @return True if it has valid entries, false if not. + */ + virtual bool HasValidEntries(void) const; + + /*! + * @brief Delete an infotag from this EPG. + * @param tag The tag to delete. + * @return True if it was deleted successfully, false if not. + */ + virtual bool DeleteInfoTag(CEpgInfoTag *tag); + + /*! + * @brief Remove all entries from this EPG that finished before the given time + * and that have no timers set. + * @param Time Delete entries with an end time before this time in UTC. + */ + virtual void Cleanup(const CDateTime &Time); + + /*! + * @brief Remove all entries from this EPG that finished before the given time + * and that have no timers set. + */ + virtual void Cleanup(void); + + /*! + * @brief Remove all entries from this EPG. + */ + virtual void Clear(void); + + /*! + * @brief Get the event that is occurring now. + * @return The current event. + */ + virtual const CEpgInfoTag *InfoTagNow(void) const; + + /*! + * @brief Get the event that will occur next. + * @return The next event. + */ + virtual const CEpgInfoTag *InfoTagNext(void) const; + + /*! + * @brief Get the event that occurs at the given time. + * @param time The time to find the event for. + * @return The found tag or NULL if it wasn't found. + */ + virtual const CEpgInfoTag *GetTagAround(const CDateTime &time) const; + + /*! + * Get the event that occurs between the given begin and end time. + * @param beginTime Minimum start time of the event. + * @param endTime Maximum end time of the event. + * @return The found tag or NULL if it wasn't found. + */ + virtual const CEpgInfoTag *GetTagBetween(const CDateTime &beginTime, const CDateTime &endTime) const; + + /*! + * @brief Get the infotag with the given ID. + * + * Get the infotag with the given ID. + * If it wasn't found, try finding the event with the given start time + * + * @param uniqueID The unique ID of the event to find. + * @param beginTime The start time of the event to find if it wasn't found by it's unique ID. + * @return The found tag or NULL if it wasn't found. + */ + virtual const CEpgInfoTag *GetTag(int uniqueID, const CDateTime &beginTime) const; + + /*! + * @brief Update an entry in this EPG. + * @param tag The tag to update. + * @param bUpdateDatabase If set to true, this event will be persisted in the database. + * @return True if it was updated successfully, false otherwise. + */ + virtual bool UpdateEntry(const CEpgInfoTag &tag, bool bUpdateDatabase = false); + + /*! + * @brief Update the EPG from 'start' till 'end'. + * @param start The start time. + * @param end The end time. + * @param iUpdateTime Update the table after the given amount of time has passed. + * @return True if the update was successful, false otherwise. + */ + virtual bool Update(const time_t start, const time_t end, int iUpdateTime); + + /*! + * @brief Get all EPG entries. + * @param results The file list to store the results in. + * @return The amount of entries that were added. + */ + virtual int Get(CFileItemList *results) const; + + /*! + * @brief Get all EPG entries that and apply a filter. + * @param results The file list to store the results in. + * @param filter The filter to apply. + * @return The amount of entries that were added. + */ + virtual int Get(CFileItemList *results, const EpgSearchFilter &filter) const; + + /*! + * @brief Persist this table in the database. + * @param bPersistTags Set to true to persist all changed tags in this container. + * @param bQueueWrite Don't execute the query immediately but queue it if true. + * @return True if the table was persisted, false otherwise. + */ + virtual bool Persist(bool bPersistTags = false, bool bQueueWrite = false); + + /*! + * @brief Get the start time of the first entry in this table. + * @return The first date. + */ + virtual const CDateTime &GetFirstDate(void) const; + + /*! + * @brief Get the end time of the last entry in this table. + * @return The last date. + */ + virtual const CDateTime &GetLastDate(void) const; + + /*! + * @return The last time this table was scanned. + */ + virtual const CDateTime &GetLastScanTime(void); + }; +} diff --git a/xbmc/epg/EpgContainer.cpp b/xbmc/epg/EpgContainer.cpp index d3fb5ef42c505..2faa65f8ee53f 100644 --- a/xbmc/epg/EpgContainer.cpp +++ b/xbmc/epg/EpgContainer.cpp @@ -38,11 +38,9 @@ using namespace std; using namespace PVR; +using namespace EPG; -CEpgContainer g_EpgContainer; - -CEpgContainer::CEpgContainer(void) : - Observable() +CEpgContainer::CEpgContainer(void) { m_bStop = true; Clear(false); @@ -53,6 +51,12 @@ CEpgContainer::~CEpgContainer(void) Clear(); } +CEpgContainer &CEpgContainer::Get(void) +{ + static CEpgContainer epgInstance; + return epgInstance; +} + void CEpgContainer::Unload(void) { Stop(); diff --git a/xbmc/epg/EpgContainer.h b/xbmc/epg/EpgContainer.h index 3c9b48a42ebc6..29c8e228868a1 100644 --- a/xbmc/epg/EpgContainer.h +++ b/xbmc/epg/EpgContainer.h @@ -38,201 +38,209 @@ namespace PVR class CPVRManager; } -class CEpgContainer : public std::vector, - public Observer, - public Observable, - private CThread +namespace EPG { - friend class CEpg; - friend class CEpgDatabase; - - friend class PVR::CPVREpg; - friend class PVR::CPVREpgContainer; - friend class PVR::CPVRManager; - -protected: - CEpgDatabase m_database; /*!< the EPG database */ - - /** @name Configuration */ - //@{ - bool m_bIgnoreDbForClient; /*!< don't save the EPG data in the database */ - int m_iDisplayTime; /*!< hours of EPG data to fetch */ - int m_iUpdateTime; /*!< update the full EPG after this period */ - //@} - - /** @name Class state properties */ - //@{ - bool m_bDatabaseLoaded; /*!< true if we already loaded the EPG from the database */ - time_t m_iLastEpgCleanup; /*!< the time the EPG was cleaned up */ - time_t m_iLastEpgUpdate; /*!< the time the EPG was updated */ - //@} - - CCriticalSection m_critSection; /*!< a critical section for changes to this container */ - - /*! - * @brief Load the EPG settings. - * @return True if the settings were loaded successfully, false otherwise. - */ - virtual bool LoadSettings(void); - - /*! - * @brief Remove old EPG entries. - * @return True if the old entries were removed successfully, false otherwise. - */ - virtual bool RemoveOldEntries(void); - - /*! - * @brief Load and update the EPG data. - * @param bShowProgress Show a progress bar if true. - * @return True if the update was successful, false otherwise. - */ - virtual bool UpdateEPG(bool bShowProgress = false); - - /*! - * @return True if a running update should be interrupted, false otherwise. - */ - virtual bool InterruptUpdate(void) const; - - /*! - * @brief Load or update a single table. - * @param epg The table to update. - * @param start The start time to use. - * @param end The end time to use. - * @return True if the load or update was successful, false otherwise. - */ - virtual bool UpdateSingleTable(CEpg *epg, const time_t start, const time_t end); - - /*! - * @brief A hook that will be called on every update thread iteration. - */ - virtual void ProcessHook(const CDateTime &time) {}; - - /*! - * @brief A hook that is called after the tables have been loaded from the database. - * @return True if the hook was executed successfully, false otherwise. - */ - virtual bool AutoCreateTablesHook(void) { return true; } - - /*! - * @brief Create a new EPG table. - * @param iEpgId The table ID or -1 to create a new one. - * @return The new table. - */ - virtual CEpg *CreateEpg(int iEpgId); - -protected: - /*! - * @brief EPG update thread - */ - virtual void Process(void); - -public: - /*! - * @brief Create a new EPG table container. - */ - CEpgContainer(void); - - /*! - * @brief Destroy this instance. - */ - virtual ~CEpgContainer(void); - - /*! - * @brief Get a pointer to the database instance. - * @return A pointer to the database instance. - */ - CEpgDatabase *GetDatabase(void) { return &m_database; } - - /*! - * @brief Start the EPG update thread. - */ - virtual void Start(void); - - /*! - * @brief Stop the EPG update thread. - * @return - */ - virtual bool Stop(void); - - /*! - * @brief Clear all EPG entries. - * @param bClearDb Clear the database too if true. - */ - virtual void Clear(bool bClearDb = false); - - /*! - * @brief Stop the update thread and unload all data. - */ - virtual void Unload(void); - - /*! - * @brief Clear the EPG and all it's database entries. - */ - virtual void Reset(void) { Clear(true); } - - /*! - * @brief Delete an EPG table from this container. - * @param epg The table to delete. - * @param bDeleteFromDatabase Delete this table from the database too if true. - * @return - */ - virtual bool DeleteEpg(const CEpg &epg, bool bDeleteFromDatabase = false); - - /*! - * @brief Process a notification from an observable. - * @param obs The observable that sent the update. - * @param msg The update message. - */ - virtual void Notify(const Observable &obs, const CStdString& msg); - - /*! - * @brief Update an entry in this container. - * @param tag The table to update. - * @param bUpdateDatabase If set to true, this table will be persisted in the database. - * @return True if it was updated successfully, false otherwise. - */ - virtual bool UpdateEntry(const CEpg &entry, bool bUpdateDatabase = false); - - /*! - * @brief Get all EPG tables and apply a filter. - * @param results The fileitem list to store the results in. - * @param filter The filter to apply. - * @return The amount of entries that were added. - */ - virtual int GetEPGSearch(CFileItemList* results, const EpgSearchFilter &filter); - - /*! - * @brief Get all EPG tables. - * @param results The fileitem list to store the results in. - * @return The amount of entries that were added. - */ - virtual int GetEPGAll(CFileItemList* results); - - /*! - * @brief Get the start time of the first entry. - * @return The start time. - */ - virtual const CDateTime GetFirstEPGDate(void) const; - - /*! - * @brief Get the end time of the last entry. - * @return The end time. - */ - virtual const CDateTime GetLastEPGDate(void) const; - - /*! - * @brief Get an EPG table given it's ID. - * @param iEpgId The database ID of the table. - * @return The table or NULL if it wasn't found. - */ - virtual CEpg *GetById(int iEpgId) const; - - /*! - * @brief Get an EPG table given it's index in this container. - * @param iIndex The index. - * @return The table or NULL if it wasn't found. - */ - virtual CEpg *GetByIndex(unsigned int iIndex) const; -}; - -extern CEpgContainer g_EpgContainer; /*!< The container for all EPG tables */ + #define g_EpgContainer CEpgContainer::Get() + + class CEpgContainer : public std::vector, + public Observer, + public Observable, + private CThread + { + friend class CEpg; + friend class CEpgDatabase; + + friend class PVR::CPVREpg; + friend class PVR::CPVREpgContainer; + friend class PVR::CPVRManager; + + protected: + CEpgDatabase m_database; /*!< the EPG database */ + + /** @name Configuration */ + //@{ + bool m_bIgnoreDbForClient; /*!< don't save the EPG data in the database */ + int m_iDisplayTime; /*!< hours of EPG data to fetch */ + int m_iUpdateTime; /*!< update the full EPG after this period */ + //@} + + /** @name Class state properties */ + //@{ + bool m_bDatabaseLoaded; /*!< true if we already loaded the EPG from the database */ + time_t m_iLastEpgCleanup; /*!< the time the EPG was cleaned up */ + time_t m_iLastEpgUpdate; /*!< the time the EPG was updated */ + //@} + + CCriticalSection m_critSection; /*!< a critical section for changes to this container */ + + /*! + * @brief Load the EPG settings. + * @return True if the settings were loaded successfully, false otherwise. + */ + virtual bool LoadSettings(void); + + /*! + * @brief Remove old EPG entries. + * @return True if the old entries were removed successfully, false otherwise. + */ + virtual bool RemoveOldEntries(void); + + /*! + * @brief Load and update the EPG data. + * @param bShowProgress Show a progress bar if true. + * @return True if the update was successful, false otherwise. + */ + virtual bool UpdateEPG(bool bShowProgress = false); + + /*! + * @return True if a running update should be interrupted, false otherwise. + */ + virtual bool InterruptUpdate(void) const; + + /*! + * @brief Load or update a single table. + * @param epg The table to update. + * @param start The start time to use. + * @param end The end time to use. + * @return True if the load or update was successful, false otherwise. + */ + virtual bool UpdateSingleTable(CEpg *epg, const time_t start, const time_t end); + + /*! + * @brief A hook that will be called on every update thread iteration. + */ + virtual void ProcessHook(const CDateTime &time) {}; + + /*! + * @brief A hook that is called after the tables have been loaded from the database. + * @return True if the hook was executed successfully, false otherwise. + */ + virtual bool AutoCreateTablesHook(void) { return true; } + + /*! + * @brief Create a new EPG table. + * @param iEpgId The table ID or -1 to create a new one. + * @return The new table. + */ + virtual CEpg *CreateEpg(int iEpgId); + + protected: + /*! + * @brief EPG update thread + */ + virtual void Process(void); + + /*! + * @brief Create a new EPG table container. + */ + CEpgContainer(void); + + public: + /*! + * @brief Destroy this instance. + */ + virtual ~CEpgContainer(void); + + /*! + * @return An instance of this singleton. + */ + static CEpgContainer &Get(void); + + /*! + * @brief Get a pointer to the database instance. + * @return A pointer to the database instance. + */ + CEpgDatabase *GetDatabase(void) { return &m_database; } + + /*! + * @brief Start the EPG update thread. + */ + virtual void Start(void); + + /*! + * @brief Stop the EPG update thread. + * @return + */ + virtual bool Stop(void); + + /*! + * @brief Clear all EPG entries. + * @param bClearDb Clear the database too if true. + */ + virtual void Clear(bool bClearDb = false); + + /*! + * @brief Stop the update thread and unload all data. + */ + virtual void Unload(void); + + /*! + * @brief Clear the EPG and all it's database entries. + */ + virtual void Reset(void) { Clear(true); } + + /*! + * @brief Delete an EPG table from this container. + * @param epg The table to delete. + * @param bDeleteFromDatabase Delete this table from the database too if true. + * @return + */ + virtual bool DeleteEpg(const CEpg &epg, bool bDeleteFromDatabase = false); + + /*! + * @brief Process a notification from an observable. + * @param obs The observable that sent the update. + * @param msg The update message. + */ + virtual void Notify(const Observable &obs, const CStdString& msg); + + /*! + * @brief Update an entry in this container. + * @param tag The table to update. + * @param bUpdateDatabase If set to true, this table will be persisted in the database. + * @return True if it was updated successfully, false otherwise. + */ + virtual bool UpdateEntry(const CEpg &entry, bool bUpdateDatabase = false); + + /*! + * @brief Get all EPG tables and apply a filter. + * @param results The fileitem list to store the results in. + * @param filter The filter to apply. + * @return The amount of entries that were added. + */ + virtual int GetEPGSearch(CFileItemList* results, const EpgSearchFilter &filter); + + /*! + * @brief Get all EPG tables. + * @param results The fileitem list to store the results in. + * @return The amount of entries that were added. + */ + virtual int GetEPGAll(CFileItemList* results); + + /*! + * @brief Get the start time of the first entry. + * @return The start time. + */ + virtual const CDateTime GetFirstEPGDate(void) const; + + /*! + * @brief Get the end time of the last entry. + * @return The end time. + */ + virtual const CDateTime GetLastEPGDate(void) const; + + /*! + * @brief Get an EPG table given it's ID. + * @param iEpgId The database ID of the table. + * @return The table or NULL if it wasn't found. + */ + virtual CEpg *GetById(int iEpgId) const; + + /*! + * @brief Get an EPG table given it's index in this container. + * @param iIndex The index. + * @return The table or NULL if it wasn't found. + */ + virtual CEpg *GetByIndex(unsigned int iIndex) const; + }; +} diff --git a/xbmc/epg/EpgDatabase.cpp b/xbmc/epg/EpgDatabase.cpp index 3b601f078d6bd..aaefe0e027847 100644 --- a/xbmc/epg/EpgDatabase.cpp +++ b/xbmc/epg/EpgDatabase.cpp @@ -29,14 +29,7 @@ using namespace std; using namespace dbiplus; - -CEpgDatabase::CEpgDatabase(void) -{ -} - -CEpgDatabase::~CEpgDatabase(void) -{ -} +using namespace EPG; bool CEpgDatabase::Open(void) { diff --git a/xbmc/epg/EpgDatabase.h b/xbmc/epg/EpgDatabase.h index bda83cbf38094..6bfaf7f7886a4 100644 --- a/xbmc/epg/EpgDatabase.h +++ b/xbmc/epg/EpgDatabase.h @@ -23,134 +23,137 @@ #include "dbwrappers/Database.h" #include "XBDateTime.h" -class CEpg; -class CEpgInfoTag; -class CEpgContainer; - -/** The EPG database */ - -class CEpgDatabase : public CDatabase +namespace EPG { -public: - /*! - * @brief Create a new instance of the EPG database. - */ - CEpgDatabase(void); - - /*! - * @brief Destroy this instance. - */ - virtual ~CEpgDatabase(void); - - /*! - * @brief Open the database. - * @return True if it was opened successfully, false otherwise. - */ - virtual bool Open(void); - - /*! - * @brief Get the minimal database version that is required to operate correctly. - * @return The minimal database version. - */ - virtual int GetMinVersion(void) const { return 4; }; - - /*! - * @brief Get the default sqlite database filename. - * @return The default filename. - */ - const char *GetBaseDBName(void) const { return "Epg"; }; - - /*! @name EPG methods */ - //@{ - - /*! - * @brief Remove all EPG information from the database - * @return True if the EPG information was erased, false otherwise. - */ - virtual bool DeleteEpg(void); - - /*! - * @brief Erase all EPG entries for a table. - * @param table The table to remove the EPG entries for. - * @param start Remove entries after this time if set. - * @param end Remove entries before this time if set. - * @return True if the entries were removed successfully, false otherwise. - */ - virtual bool Delete(const CEpg &table, const time_t start = 0, const time_t end = 0); - - /*! - * @brief Erase all EPG entries older than 1 day. - * @return True if the entries were removed successfully, false otherwise. - */ - virtual bool DeleteOldEpgEntries(void); - - /*! - * @brief Remove a single EPG entry. - * @param tag The entry to remove. - * @return True if it was removed successfully, false otherwise. - */ - virtual bool Delete(const CEpgInfoTag &tag); - - /*! - * @brief Get all EPG tables from the database. Does not get the EPG tables' entries. - * @param container The container to fill. - * @return The amount of entries that was added. - */ - virtual int Get(CEpgContainer *container); - - /*! - * @brief Get all EPG entries for a table. - * @param epg The EPG table to get the entries for. - * @return The amount of entries that was added. - */ - virtual int Get(CEpg *epg); - - /*! - * @brief Get the last stored EPG scan time. - * @param iEpgId The table to update the time for. Use 0 for a global value. - * @param lastScan The last scan time or -1 if it wasn't found. - * @return True if the time was fetched successfully, false otherwise. - */ - virtual bool GetLastEpgScanTime(int iEpgId, CDateTime *lastScan); - - /*! - * @brief Update the last scan time. - * @param iEpgId The table to update the time for. Use 0 for a global value. - * @param bQueueWrite Don't execute the query immediately but queue it if true. - * @return True if it was updated successfully, false otherwise. - */ - virtual bool PersistLastEpgScanTime(int iEpgId = 0, bool bQueueWrite = false); - - /*! - * @brief Persist an EPG table. It's entries are not persisted. - * @param epg The table to persist. - * @param bQueueWrite Don't execute the query immediately but queue it if true. - * @return The database ID of this entry or 0 if bSingleUpdate is false and the query was queued. - */ - virtual int Persist(const CEpg &epg, bool bQueueWrite = false); - - /*! - * @brief Persist an infotag. - * @param tag The tag to persist. - * @param bSingleUpdate If true, this is a single update and the query will be executed immediately. - * @param bLastUpdate If multiple updates were sent, set this to true on the last update to execute the queries. - * @return The database ID of this entry or 0 if bSingleUpdate is false and the query was queued. - */ - virtual int Persist(const CEpgInfoTag &tag, bool bSingleUpdate = true, bool bLastUpdate = false); - - //@} - -protected: - /*! - * @brief Create the EPG database tables. - * @return True if the tables were created successfully, false otherwise. - */ - virtual bool CreateTables(void); - - /*! - * @brief Update an old version of the database. - * @param version The version to update the database from. - * @return True if it was updated successfully, false otherwise. - */ - virtual bool UpdateOldVersion(int version); -}; + class CEpg; + class CEpgInfoTag; + class CEpgContainer; + + /** The EPG database */ + + class CEpgDatabase : public CDatabase + { + public: + /*! + * @brief Create a new instance of the EPG database. + */ + CEpgDatabase(void) {}; + + /*! + * @brief Destroy this instance. + */ + virtual ~CEpgDatabase(void) {}; + + /*! + * @brief Open the database. + * @return True if it was opened successfully, false otherwise. + */ + virtual bool Open(void); + + /*! + * @brief Get the minimal database version that is required to operate correctly. + * @return The minimal database version. + */ + virtual int GetMinVersion(void) const { return 4; }; + + /*! + * @brief Get the default sqlite database filename. + * @return The default filename. + */ + const char *GetBaseDBName(void) const { return "Epg"; }; + + /*! @name EPG methods */ + //@{ + + /*! + * @brief Remove all EPG information from the database + * @return True if the EPG information was erased, false otherwise. + */ + virtual bool DeleteEpg(void); + + /*! + * @brief Erase all EPG entries for a table. + * @param table The table to remove the EPG entries for. + * @param start Remove entries after this time if set. + * @param end Remove entries before this time if set. + * @return True if the entries were removed successfully, false otherwise. + */ + virtual bool Delete(const CEpg &table, const time_t start = 0, const time_t end = 0); + + /*! + * @brief Erase all EPG entries older than 1 day. + * @return True if the entries were removed successfully, false otherwise. + */ + virtual bool DeleteOldEpgEntries(void); + + /*! + * @brief Remove a single EPG entry. + * @param tag The entry to remove. + * @return True if it was removed successfully, false otherwise. + */ + virtual bool Delete(const CEpgInfoTag &tag); + + /*! + * @brief Get all EPG tables from the database. Does not get the EPG tables' entries. + * @param container The container to fill. + * @return The amount of entries that was added. + */ + virtual int Get(CEpgContainer *container); + + /*! + * @brief Get all EPG entries for a table. + * @param epg The EPG table to get the entries for. + * @return The amount of entries that was added. + */ + virtual int Get(CEpg *epg); + + /*! + * @brief Get the last stored EPG scan time. + * @param iEpgId The table to update the time for. Use 0 for a global value. + * @param lastScan The last scan time or -1 if it wasn't found. + * @return True if the time was fetched successfully, false otherwise. + */ + virtual bool GetLastEpgScanTime(int iEpgId, CDateTime *lastScan); + + /*! + * @brief Update the last scan time. + * @param iEpgId The table to update the time for. Use 0 for a global value. + * @param bQueueWrite Don't execute the query immediately but queue it if true. + * @return True if it was updated successfully, false otherwise. + */ + virtual bool PersistLastEpgScanTime(int iEpgId = 0, bool bQueueWrite = false); + + /*! + * @brief Persist an EPG table. It's entries are not persisted. + * @param epg The table to persist. + * @param bQueueWrite Don't execute the query immediately but queue it if true. + * @return The database ID of this entry or 0 if bSingleUpdate is false and the query was queued. + */ + virtual int Persist(const CEpg &epg, bool bQueueWrite = false); + + /*! + * @brief Persist an infotag. + * @param tag The tag to persist. + * @param bSingleUpdate If true, this is a single update and the query will be executed immediately. + * @param bLastUpdate If multiple updates were sent, set this to true on the last update to execute the queries. + * @return The database ID of this entry or 0 if bSingleUpdate is false and the query was queued. + */ + virtual int Persist(const CEpgInfoTag &tag, bool bSingleUpdate = true, bool bLastUpdate = false); + + //@} + + protected: + /*! + * @brief Create the EPG database tables. + * @return True if the tables were created successfully, false otherwise. + */ + virtual bool CreateTables(void); + + /*! + * @brief Update an old version of the database. + * @param version The version to update the database from. + * @return True if it was updated successfully, false otherwise. + */ + virtual bool UpdateOldVersion(int version); + }; +} diff --git a/xbmc/epg/EpgInfoTag.cpp b/xbmc/epg/EpgInfoTag.cpp index 0e63c33f6dbd1..d1a11ff8752a0 100644 --- a/xbmc/epg/EpgInfoTag.cpp +++ b/xbmc/epg/EpgInfoTag.cpp @@ -29,11 +29,56 @@ using namespace std; using namespace PVR; - -CEpgInfoTag::CEpgInfoTag(int iUniqueBroadcastId) +using namespace EPG; + +CEpgInfoTag::CEpgInfoTag(int iUniqueBroadcastId) : + m_bNotify(false), + m_bChanged(false), + m_iBroadcastId(-1), + m_iGenreType(0), + m_iGenreSubType(0), + m_iParentalRating(0), + m_iStarRating(0), + m_iSeriesNumber(0), + m_iEpisodeNumber(0), + m_iEpisodePart(0), + m_iUniqueBroadcastID(iUniqueBroadcastId), + m_strTitle(""), + m_strPlotOutline(""), + m_strPlot(""), + m_strGenre(""), + m_strEpisodeName(""), + m_strIconPath(""), + m_strFileNameAndPath(""), + m_nextEvent(NULL), + m_previousEvent(NULL), + m_Epg(NULL) +{ +} + +CEpgInfoTag::CEpgInfoTag(void) : + m_bNotify(false), + m_bChanged(false), + m_iBroadcastId(-1), + m_iGenreType(0), + m_iGenreSubType(0), + m_iParentalRating(0), + m_iStarRating(0), + m_iSeriesNumber(0), + m_iEpisodeNumber(0), + m_iEpisodePart(0), + m_iUniqueBroadcastID(-1), + m_strTitle(""), + m_strPlotOutline(""), + m_strPlot(""), + m_strGenre(""), + m_strEpisodeName(""), + m_strIconPath(""), + m_strFileNameAndPath(""), + m_nextEvent(NULL), + m_previousEvent(NULL), + m_Epg(NULL) { - Reset(); - m_iUniqueBroadcastID = iUniqueBroadcastId; } CEpgInfoTag::~CEpgInfoTag() @@ -75,29 +120,6 @@ bool CEpgInfoTag::operator !=(const CEpgInfoTag& right) const return !(*this == right); } -void CEpgInfoTag::Reset() -{ - m_iBroadcastId = -1; - m_strTitle = ""; - m_strGenre = ""; - m_strPlotOutline = ""; - m_strPlot = ""; - m_iGenreType = 0; - m_iGenreSubType = 0; - m_strFileNameAndPath = ""; - m_strIconPath = ""; - m_Epg = NULL; - m_iParentalRating = 0; - m_iStarRating = 0; - m_bNotify = false; - m_iSeriesNumber = 0; - m_iEpisodeNumber = 0; - m_iEpisodePart = 0; - m_strEpisodeName = ""; - m_bChanged = false; - m_iUniqueBroadcastID = -1; -} - int CEpgInfoTag::GetDuration() const { time_t start, end; diff --git a/xbmc/epg/EpgInfoTag.h b/xbmc/epg/EpgInfoTag.h index 2a82f7e887b39..d8c5b75c7d1c3 100644 --- a/xbmc/epg/EpgInfoTag.h +++ b/xbmc/epg/EpgInfoTag.h @@ -24,7 +24,10 @@ #include "XBDateTime.h" #include "Epg.h" -class CEpg; +namespace EPG +{ + class CEpg; +} namespace PVR { @@ -33,369 +36,366 @@ namespace PVR } /** an EPG info tag */ - -class CEpgInfoTag +namespace EPG { - friend class CEpg; - friend class CEpgDatabase; - - friend class PVR::CPVREpg; - friend class PVR::CPVREpgInfoTag; - -protected: - const CEpg * m_Epg; /*!< the schedule this event belongs to */ - - int m_iBroadcastId; /*!< database ID */ - CStdString m_strTitle; /*!< title */ - CStdString m_strPlotOutline; /*!< plot outline */ - CStdString m_strPlot; /*!< plot */ - CStdString m_strGenre; /*!< genre */ - CDateTime m_startTime; /*!< event start time */ - CDateTime m_endTime; /*!< event end time */ - CStdString m_strIconPath; /*!< the path to the icon */ - CStdString m_strFileNameAndPath; /*!< the filename and path */ - int m_iGenreType; /*!< genre type */ - int m_iGenreSubType; /*!< genre subtype */ - CDateTime m_firstAired; /*!< first airdate */ - int m_iParentalRating; /*!< parental rating */ - int m_iStarRating; /*!< star rating */ - bool m_bNotify; /*!< notify on start */ - int m_iSeriesNumber; /*!< series number */ - int m_iEpisodeNumber; /*!< episode number */ - int m_iEpisodePart; /*!< episode part number */ - CStdString m_strEpisodeName; /*!< episode name */ - - mutable const CEpgInfoTag *m_nextEvent; /*!< the event that will occur after this one */ - mutable const CEpgInfoTag *m_previousEvent; /*!< the event that occurred before this one */ - int m_iUniqueBroadcastID; /*!< unique broadcast ID */ - - bool m_bChanged; /*!< keep track of changes to this entry */ - - /*! - * @brief Hook that is called when the start date changed. - */ - virtual void UpdatePath() {} - - /*! - * @brief Change the pointer to the next event. - * @param event The next event. - */ - void SetNextEvent(const CEpgInfoTag *event) { m_nextEvent = event; } - - /*! - * @brief Change the pointer to the previous event. - * @param event The previous event. - */ - void SetPreviousEvent(const CEpgInfoTag *event) { m_previousEvent = event; } - -public: - /*! - * @brief Create a new EPG event. - * @param iUniqueBroadcastId The unique broadcast ID for this event. - */ - CEpgInfoTag(int iUniqueBroadcastId); - - /*! - * @brief Create a new empty event without a unique ID. - */ - CEpgInfoTag() { Reset(); }; - - /*! - * @brief Destroy this instance. - */ - virtual ~CEpgInfoTag(); - - bool operator ==(const CEpgInfoTag& right) const; - bool operator !=(const CEpgInfoTag& right) const; - - /*! - * @brief Check whether this tag has changed and unsaved values. - * @return True if it has unsaved values, false otherwise. - */ - bool Changed(void) const { return m_bChanged; } - - /*! - * @brief Clear this event. - */ - virtual void Reset(); - - /*! - * @brief The table this event belongs to - * @return The table this event belongs to - */ - virtual const CEpg *GetTable() const { return m_Epg; } - - /*! - * @brief Change the unique broadcast ID of this event. - * @param iUniqueBroadcastId The new unique broadcast ID. - */ - void SetUniqueBroadcastID(int iUniqueBroadcastID); - - /*! - * @brief Get the unique broadcast ID. - * @return The unique broadcast ID. - */ - int UniqueBroadcastID(void) const { return m_iUniqueBroadcastID; } - - /*! - * @brief Get the event's database ID. - * @return The database ID. - */ - int BroadcastId(void) const { return m_iBroadcastId; } - - /*! - * @brief Change the event's database ID. - * @param iId The new database ID. - */ - void SetBroadcastId(int iId); - - /*! - * @brief Get the event's start time. - * @return The new start time. - */ - const CDateTime &StartAsUTC(void) const { return m_startTime; } - const CDateTime &StartAsLocalTime(void) const; - - /*! - * @brief Change the event's start time. - * @param start The new start time. - */ - void SetStartFromUTC(const CDateTime &start); - void SetStartFromLocalTime(const CDateTime &start); - - /*! - * @brief Get the event's end time. - * @return The new start time. - */ - const CDateTime &EndAsUTC(void) const { return m_endTime; } - const CDateTime &EndAsLocalTime(void) const; - - /*! - * @brief Change the event's end time. - * @param end The new end time. - */ - void SetEndFromUTC(const CDateTime &end); - void SetEndFromLocalTime(const CDateTime &end); - - /*! - * @brief Get the duration of this event in seconds. - * @return The duration in seconds. - */ - int GetDuration() const; - - /*! - * @brief Get the title of this event. - * @return The title. - */ - const CStdString &Title(void) const; - - /*! - * @brief Change the title of this event. - * @param strTitle The new title. - */ - void SetTitle(const CStdString &strTitle); - - /*! - * @brief Get the plot outline of this event. - * @return The plot outline. - */ - const CStdString &PlotOutline(void) const { return m_strPlotOutline; } - - /*! - * @brief Change the plot outline of this event. - * @param strPlotOutline The new plot outline. - */ - void SetPlotOutline(const CStdString &strPlotOutline); - - /*! - * @brief Get the plot of this event. - * @return The plot. - */ - const CStdString &Plot(void) const { return m_strPlot; } - - /*! - * @brief Change the plot of this event. - * @param strPlot The new plot. - */ - void SetPlot(const CStdString &strPlot); - - /*! - * @brief Get the genre type ID of this event. - * @return The genre type ID. - */ - int GenreType(void) const { return m_iGenreType; } - - /*! - * @brief Get the genre subtype ID of this event. - * @return The genre subtype ID. - */ - int GenreSubType(void) const { return m_iGenreSubType; } - - /*! - * @brief Get the genre as human readable string. - * @return The genre. - */ - const CStdString &Genre(void) const { return m_strGenre; } - - /*! - * @brief Change the genre of this event. - * @param iID The genre type ID. - * @param iSubID The genre subtype ID. - */ - void SetGenre(int iID, int iSubID); - - /*! - * @brief Get the first air date of this event. - * @return The first air date. - */ - const CDateTime &FirstAiredAsUTC(void) const { return m_firstAired; } - const CDateTime &FirstAiredAsLocalTime(void) const; - - /*! - * @brief Change the first air date of this event. - * @param firstAired The new first air date. - */ - void SetFirstAiredFromUTC(const CDateTime &firstAired); - void SetFirstAiredFromLocalTime(const CDateTime &firstAired); - - /*! - * @brief Get the parental rating of this event. - * @return The parental rating. - */ - int ParentalRating(void) const { return m_iParentalRating; } - - /*! - * @brief Change the parental rating of this event. - * @param iParentalRating The new parental rating. - */ - void SetParentalRating(int iParentalRating); - - /*! - * @brief Get the star rating of this event. - * @return The star rating. - */ - int StarRating(void) const { return m_iStarRating; } - - /*! - * @brief Change the star rating of this event. - * @param iStarRating The new star rating. - */ - void SetStarRating(int iStarRating); - - /*! - * @brief Notify on start if true. - * @return Notify on start. - */ - bool Notify(void) const { return m_bNotify; } - - /*! - * @brief Change the value of notify on start. - * @param bNotify The new value. - */ - void SetNotify(bool bNotify); - - /*! - * @brief The series number of this event. - * @return The series number. - */ - int SeriesNum(void) const { return m_iSeriesNumber; } - - /*! - * @brief Change the series number of this event. - * @param strSeriesNum The new series number. - */ - void SetSeriesNum(int iSeriesNum); - - /*! - * @brief The episode number of this event. - * @return The episode number. - */ - int EpisodeNum(void) const { return m_iEpisodeNumber; } - - /*! - * @brief Change the episode number of this event. - * @param strEpisodeNum The new episode number. - */ - void SetEpisodeNum(int iEpisodeNum); - - /*! - * @brief The episode part number of this event. - * @return The episode part number. - */ - int EpisodePart(void) const { return m_iEpisodePart; } - - /*! - * @brief Change the episode part number of this event. - * @param strEpisodePart The new episode part number. - */ - void SetEpisodePart(int iEpisodePart); - - /*! - * @brief The episode name of this event. - * @return The episode name. - */ - const CStdString &EpisodeName(void) const { return m_strEpisodeName; } - - /*! - * @brief Change the episode name of this event. - * @param strEpisodeName The new episode name. - */ - void SetEpisodeName(const CStdString &strEpisodeName); - - /*! - * @brief Get the path to the icon for this event. - * @return The path to the icon - */ - virtual const CStdString &Icon(void) const { return m_strIconPath; } - - /*! - * @brief Change the path to the icon for this event. - * @param strIconPath The new path. - */ - void SetIcon(const CStdString &strIconPath); - - /*! - * @brief The path to this event. - * @return The path. - */ - const CStdString &Path(void) const { return m_strFileNameAndPath; } - - /*! - * @brief Change the path to this event. - * @param strFileNameAndPath The new path. - */ - void SetPath(const CStdString &strFileNameAndPath); - - /*! - * @brief Get a pointer to the next event. Set by CEpg in a call to Sort() - * @return A pointer to the next event or NULL if it's not set. - */ - const CEpgInfoTag *GetNextEvent() const; - - /*! - * @brief Get a pointer to the previous event. Set by CEpg in a call to Sort() - * @return A pointer to the previous event or NULL if it's not set. - */ - const CEpgInfoTag *GetPreviousEvent() const; - - /*! - * @brief Update the information in this tag with the info in the given tag. - * @param tag The new info. - * @return True if something changed, false otherwise. - */ - virtual bool Update(const CEpgInfoTag &tag); - - /*! - * @brief Check if this event is currently active. - * @return True if it's active, false otherwise. - */ - bool IsActive(void) const; - - /*! - * @brief Persist this tag in the database. - * @param bSingleUpdate True if this is a single update, false if more updates will follow. - * @param bLastUpdate True to commit a batch of changes, false otherwise. - * @return True if the tag was persisted correctly, false otherwise. - */ - bool Persist(bool bSingleUpdate = true, bool bLastUpdate = false); -}; + class CEpgInfoTag + { + friend class CEpg; + friend class CEpgDatabase; + + friend class PVR::CPVREpg; + friend class PVR::CPVREpgInfoTag; + + protected: + bool m_bNotify; /*!< notify on start */ + bool m_bChanged; /*!< keep track of changes to this entry */ + + int m_iBroadcastId; /*!< database ID */ + int m_iGenreType; /*!< genre type */ + int m_iGenreSubType; /*!< genre subtype */ + int m_iParentalRating; /*!< parental rating */ + int m_iStarRating; /*!< star rating */ + int m_iSeriesNumber; /*!< series number */ + int m_iEpisodeNumber; /*!< episode number */ + int m_iEpisodePart; /*!< episode part number */ + int m_iUniqueBroadcastID; /*!< unique broadcast ID */ + CStdString m_strTitle; /*!< title */ + CStdString m_strPlotOutline; /*!< plot outline */ + CStdString m_strPlot; /*!< plot */ + CStdString m_strGenre; /*!< genre */ + CStdString m_strEpisodeName; /*!< episode name */ + CStdString m_strIconPath; /*!< the path to the icon */ + CStdString m_strFileNameAndPath; /*!< the filename and path */ + CDateTime m_startTime; /*!< event start time */ + CDateTime m_endTime; /*!< event end time */ + CDateTime m_firstAired; /*!< first airdate */ + + mutable const CEpgInfoTag *m_nextEvent; /*!< the event that will occur after this one */ + mutable const CEpgInfoTag *m_previousEvent; /*!< the event that occurred before this one */ + + const CEpg * m_Epg; /*!< the schedule this event belongs to */ + + /*! + * @brief Hook that is called when the start date changed. + */ + virtual void UpdatePath() {} + + /*! + * @brief Change the pointer to the next event. + * @param event The next event. + */ + void SetNextEvent(const CEpgInfoTag *event) { m_nextEvent = event; } + + /*! + * @brief Change the pointer to the previous event. + * @param event The previous event. + */ + void SetPreviousEvent(const CEpgInfoTag *event) { m_previousEvent = event; } + + public: + /*! + * @brief Create a new EPG event. + * @param iUniqueBroadcastId The unique broadcast ID for this event. + */ + CEpgInfoTag(int iUniqueBroadcastId); + + /*! + * @brief Create a new empty event without a unique ID. + */ + CEpgInfoTag(); + + /*! + * @brief Destroy this instance. + */ + virtual ~CEpgInfoTag(); + + bool operator ==(const CEpgInfoTag& right) const; + bool operator !=(const CEpgInfoTag& right) const; + + /*! + * @brief Check whether this tag has changed and unsaved values. + * @return True if it has unsaved values, false otherwise. + */ + bool Changed(void) const { return m_bChanged; } + + /*! + * @brief The table this event belongs to + * @return The table this event belongs to + */ + virtual const CEpg *GetTable() const { return m_Epg; } + + /*! + * @brief Change the unique broadcast ID of this event. + * @param iUniqueBroadcastId The new unique broadcast ID. + */ + void SetUniqueBroadcastID(int iUniqueBroadcastID); + + /*! + * @brief Get the unique broadcast ID. + * @return The unique broadcast ID. + */ + int UniqueBroadcastID(void) const { return m_iUniqueBroadcastID; } + + /*! + * @brief Get the event's database ID. + * @return The database ID. + */ + int BroadcastId(void) const { return m_iBroadcastId; } + + /*! + * @brief Change the event's database ID. + * @param iId The new database ID. + */ + void SetBroadcastId(int iId); + + /*! + * @brief Get the event's start time. + * @return The new start time. + */ + const CDateTime &StartAsUTC(void) const { return m_startTime; } + const CDateTime &StartAsLocalTime(void) const; + + /*! + * @brief Change the event's start time. + * @param start The new start time. + */ + void SetStartFromUTC(const CDateTime &start); + void SetStartFromLocalTime(const CDateTime &start); + + /*! + * @brief Get the event's end time. + * @return The new start time. + */ + const CDateTime &EndAsUTC(void) const { return m_endTime; } + const CDateTime &EndAsLocalTime(void) const; + + /*! + * @brief Change the event's end time. + * @param end The new end time. + */ + void SetEndFromUTC(const CDateTime &end); + void SetEndFromLocalTime(const CDateTime &end); + + /*! + * @brief Get the duration of this event in seconds. + * @return The duration in seconds. + */ + int GetDuration() const; + + /*! + * @brief Get the title of this event. + * @return The title. + */ + const CStdString &Title(void) const; + + /*! + * @brief Change the title of this event. + * @param strTitle The new title. + */ + void SetTitle(const CStdString &strTitle); + + /*! + * @brief Get the plot outline of this event. + * @return The plot outline. + */ + const CStdString &PlotOutline(void) const { return m_strPlotOutline; } + + /*! + * @brief Change the plot outline of this event. + * @param strPlotOutline The new plot outline. + */ + void SetPlotOutline(const CStdString &strPlotOutline); + + /*! + * @brief Get the plot of this event. + * @return The plot. + */ + const CStdString &Plot(void) const { return m_strPlot; } + + /*! + * @brief Change the plot of this event. + * @param strPlot The new plot. + */ + void SetPlot(const CStdString &strPlot); + + /*! + * @brief Get the genre type ID of this event. + * @return The genre type ID. + */ + int GenreType(void) const { return m_iGenreType; } + + /*! + * @brief Get the genre subtype ID of this event. + * @return The genre subtype ID. + */ + int GenreSubType(void) const { return m_iGenreSubType; } + + /*! + * @brief Get the genre as human readable string. + * @return The genre. + */ + const CStdString &Genre(void) const { return m_strGenre; } + + /*! + * @brief Change the genre of this event. + * @param iID The genre type ID. + * @param iSubID The genre subtype ID. + */ + void SetGenre(int iID, int iSubID); + + /*! + * @brief Get the first air date of this event. + * @return The first air date. + */ + const CDateTime &FirstAiredAsUTC(void) const { return m_firstAired; } + const CDateTime &FirstAiredAsLocalTime(void) const; + + /*! + * @brief Change the first air date of this event. + * @param firstAired The new first air date. + */ + void SetFirstAiredFromUTC(const CDateTime &firstAired); + void SetFirstAiredFromLocalTime(const CDateTime &firstAired); + + /*! + * @brief Get the parental rating of this event. + * @return The parental rating. + */ + int ParentalRating(void) const { return m_iParentalRating; } + + /*! + * @brief Change the parental rating of this event. + * @param iParentalRating The new parental rating. + */ + void SetParentalRating(int iParentalRating); + + /*! + * @brief Get the star rating of this event. + * @return The star rating. + */ + int StarRating(void) const { return m_iStarRating; } + + /*! + * @brief Change the star rating of this event. + * @param iStarRating The new star rating. + */ + void SetStarRating(int iStarRating); + + /*! + * @brief Notify on start if true. + * @return Notify on start. + */ + bool Notify(void) const { return m_bNotify; } + + /*! + * @brief Change the value of notify on start. + * @param bNotify The new value. + */ + void SetNotify(bool bNotify); + + /*! + * @brief The series number of this event. + * @return The series number. + */ + int SeriesNum(void) const { return m_iSeriesNumber; } + + /*! + * @brief Change the series number of this event. + * @param strSeriesNum The new series number. + */ + void SetSeriesNum(int iSeriesNum); + + /*! + * @brief The episode number of this event. + * @return The episode number. + */ + int EpisodeNum(void) const { return m_iEpisodeNumber; } + + /*! + * @brief Change the episode number of this event. + * @param strEpisodeNum The new episode number. + */ + void SetEpisodeNum(int iEpisodeNum); + + /*! + * @brief The episode part number of this event. + * @return The episode part number. + */ + int EpisodePart(void) const { return m_iEpisodePart; } + + /*! + * @brief Change the episode part number of this event. + * @param strEpisodePart The new episode part number. + */ + void SetEpisodePart(int iEpisodePart); + + /*! + * @brief The episode name of this event. + * @return The episode name. + */ + const CStdString &EpisodeName(void) const { return m_strEpisodeName; } + + /*! + * @brief Change the episode name of this event. + * @param strEpisodeName The new episode name. + */ + void SetEpisodeName(const CStdString &strEpisodeName); + + /*! + * @brief Get the path to the icon for this event. + * @return The path to the icon + */ + virtual const CStdString &Icon(void) const { return m_strIconPath; } + + /*! + * @brief Change the path to the icon for this event. + * @param strIconPath The new path. + */ + void SetIcon(const CStdString &strIconPath); + + /*! + * @brief The path to this event. + * @return The path. + */ + const CStdString &Path(void) const { return m_strFileNameAndPath; } + + /*! + * @brief Change the path to this event. + * @param strFileNameAndPath The new path. + */ + void SetPath(const CStdString &strFileNameAndPath); + + /*! + * @brief Get a pointer to the next event. Set by CEpg in a call to Sort() + * @return A pointer to the next event or NULL if it's not set. + */ + const CEpgInfoTag *GetNextEvent() const; + + /*! + * @brief Get a pointer to the previous event. Set by CEpg in a call to Sort() + * @return A pointer to the previous event or NULL if it's not set. + */ + const CEpgInfoTag *GetPreviousEvent() const; + + /*! + * @brief Update the information in this tag with the info in the given tag. + * @param tag The new info. + * @return True if something changed, false otherwise. + */ + virtual bool Update(const CEpgInfoTag &tag); + + /*! + * @brief Check if this event is currently active. + * @return True if it's active, false otherwise. + */ + bool IsActive(void) const; + + /*! + * @brief Persist this tag in the database. + * @param bSingleUpdate True if this is a single update, false if more updates will follow. + * @param bLastUpdate True to commit a batch of changes, false otherwise. + * @return True if the tag was persisted correctly, false otherwise. + */ + bool Persist(bool bSingleUpdate = true, bool bLastUpdate = false); + }; +} diff --git a/xbmc/epg/EpgSearchFilter.cpp b/xbmc/epg/EpgSearchFilter.cpp index 02d0dc5e87e99..f44d93c470ae0 100644 --- a/xbmc/epg/EpgSearchFilter.cpp +++ b/xbmc/epg/EpgSearchFilter.cpp @@ -27,6 +27,7 @@ #include "EpgContainer.h" using namespace std; +using namespace EPG; void EpgSearchFilter::Reset() { diff --git a/xbmc/epg/EpgSearchFilter.h b/xbmc/epg/EpgSearchFilter.h index 5f16238b9a109..a48fbb72551ff 100644 --- a/xbmc/epg/EpgSearchFilter.h +++ b/xbmc/epg/EpgSearchFilter.h @@ -23,37 +23,40 @@ #include "XBDateTime.h" -class CEpgInfoTag; +namespace EPG +{ + class CEpgInfoTag; -/** Filter to apply with on a CEpgInfoTag */ + /** Filter to apply with on a CEpgInfoTag */ -struct EpgSearchFilter -{ - /*! - * @brief Clear this filter. - */ - virtual void Reset(); + struct EpgSearchFilter + { + /*! + * @brief Clear this filter. + */ + virtual void Reset(); - /*! - * @brief Check if a tag will be filtered or not. - * @param tag The tag to check. - * @return True if this tag matches the filter, false if not. - */ - virtual bool FilterEntry(const CEpgInfoTag &tag) const; + /*! + * @brief Check if a tag will be filtered or not. + * @param tag The tag to check. + * @return True if this tag matches the filter, false if not. + */ + virtual bool FilterEntry(const CEpgInfoTag &tag) const; - CStdString m_strSearchTerm; /*!< The term to search for */ - bool m_bIsCaseSensitive; /*!< Do a case sensitive search */ - bool m_bSearchInDescription; /*!< Search for strSearchTerm in the description too */ - int m_iGenreType; /*!< The genre type for an entry */ - int m_iGenreSubType; /*!< The genre subtype for an entry */ - int m_iMinimumDuration; /*!< The minimum duration for an entry */ - int m_iMaximumDuration; /*!< The maximum duration for an entry */ - SYSTEMTIME m_startTime; /*!< The minimum start time for an entry */ - SYSTEMTIME m_endTime; /*!< The maximum end time for an entry */ - SYSTEMTIME m_startDate; /*!< The minimum start date for an entry */ - SYSTEMTIME m_endDate; /*!< The maximum end date for an entry */ - bool m_bIncludeUnknownGenres; /*!< Include unknown genres or not */ - bool m_bIgnorePresentTimers; /*!< True to ignore currently present timers (future recordings), false if not */ - bool m_bIgnorePresentRecordings; /*!< True to ignore currently active recordings, false if not */ - bool m_bPreventRepeats; /*!< True to remove repeating events, false if not */ -}; + CStdString m_strSearchTerm; /*!< The term to search for */ + bool m_bIsCaseSensitive; /*!< Do a case sensitive search */ + bool m_bSearchInDescription; /*!< Search for strSearchTerm in the description too */ + int m_iGenreType; /*!< The genre type for an entry */ + int m_iGenreSubType; /*!< The genre subtype for an entry */ + int m_iMinimumDuration; /*!< The minimum duration for an entry */ + int m_iMaximumDuration; /*!< The maximum duration for an entry */ + SYSTEMTIME m_startTime; /*!< The minimum start time for an entry */ + SYSTEMTIME m_endTime; /*!< The maximum end time for an entry */ + SYSTEMTIME m_startDate; /*!< The minimum start date for an entry */ + SYSTEMTIME m_endDate; /*!< The maximum end date for an entry */ + bool m_bIncludeUnknownGenres; /*!< Include unknown genres or not */ + bool m_bIgnorePresentTimers; /*!< True to ignore currently present timers (future recordings), false if not */ + bool m_bIgnorePresentRecordings; /*!< True to ignore currently active recordings, false if not */ + bool m_bPreventRepeats; /*!< True to remove repeating events, false if not */ + }; +} diff --git a/xbmc/epg/GUIEPGGridContainer.cpp b/xbmc/epg/GUIEPGGridContainer.cpp index abb0fb568976d..e180625a724f6 100644 --- a/xbmc/epg/GUIEPGGridContainer.cpp +++ b/xbmc/epg/GUIEPGGridContainer.cpp @@ -35,6 +35,7 @@ #include "GUIEPGGridContainer.h" using namespace PVR; +using namespace EPG; #define SHORTGAP 5 // how many blocks is considered a short-gap in nav logic #define MINSPERBLOCK 5 /// would be nice to offer zooming of busy schedules /// performance cost to increase resolution 5 fold? diff --git a/xbmc/epg/GUIEPGGridContainer.h b/xbmc/epg/GUIEPGGridContainer.h index b475f12d4430e..efd605e6d8236 100644 --- a/xbmc/epg/GUIEPGGridContainer.h +++ b/xbmc/epg/GUIEPGGridContainer.h @@ -26,190 +26,193 @@ #include "guilib/GUIControl.h" #include "guilib/GUIListItemLayout.h" -#define MAXCHANNELS 20 -#define MAXBLOCKS 2304 //! !!_EIGHT_!! days of 5 minute blocks - -struct GridItemsPtr +namespace EPG { - CGUIListItemPtr item; - float width; - float height; -}; + #define MAXCHANNELS 20 + #define MAXBLOCKS 2304 //! !!_EIGHT_!! days of 5 minute blocks -class CGUIEPGGridContainer : public CGUIControl -{ -public: - CGUIEPGGridContainer(int parentID, int controlID, float posX, float posY, float width, float height, - ORIENTATION orientation, int scrollTime, int preloadItems, int minutesPerPage, - int rulerUnit); - virtual ~CGUIEPGGridContainer(void); - virtual CGUIEPGGridContainer *Clone() const { return new CGUIEPGGridContainer(*this); }; - - virtual bool OnAction(const CAction &action); - virtual void OnDown(); - virtual void OnUp(); - virtual void OnLeft(); - virtual void OnRight(); - virtual bool OnMouseOver(const CPoint &point); - virtual bool OnMouseClick(int dwButton, const CPoint &point); - virtual bool OnMouseDoubleClick(int dwButton, const CPoint &point); - virtual bool OnMouseWheel(char wheel, const CPoint &point); - virtual bool OnMessage(CGUIMessage& message); - virtual void SetFocus(bool bOnOff); - - virtual CStdString GetDescription() const; - const int GetNumChannels() { return m_channels; }; - virtual int GetSelectedItem() const; - const int GetSelectedChannel() { return m_channelCursor + m_channelOffset; } - - void DoRender(unsigned int currentTime); - void Render(); - void LoadLayout(TiXmlElement *layout); - void LoadContent(TiXmlElement *content); - - virtual bool IsContainer() const { return true; }; - CGUIListItemPtr GetListItem(int offset) const; - - virtual int CorrectOffset(int offset, int cursor) const; - - /*! \brief Set the offset of the first item in the container from the container's position - Useful for lists/panels where the focused item may be larger than the non-focused items and thus - normally cut off from the clipping window defined by the container's position + size. - \param offset CPoint holding the offset in skin coordinates. - */ - void SetRenderOffset(const CPoint &offset); - - void GoToBegin(); - void GoToEnd(); - void SetStartEnd(CDateTime start, CDateTime end); - -protected: - bool OnClick(int actionID); - bool SelectItemFromPoint(const CPoint &point); - - void UpdateItems(); - - void SetChannel(int channel); - void SetBlock(int block); - void ChannelScroll(int amount); - void ProgrammesScroll(int amount); - void ValidateOffset(); - void UpdateLayout(bool refreshAllItems = false); - void CalculateLayout(); - void Reset(); - - GridItemsPtr *GetItem(const int &channel); - GridItemsPtr *GetNextItem(const int &channel); - GridItemsPtr *GetPrevItem(const int &channel); - GridItemsPtr *GetClosestItem(const int &channel); - - int GetItemSize(GridItemsPtr *item); - int GetBlock(const CGUIListItemPtr &item, const int &channel); - int GetRealBlock(const CGUIListItemPtr &item, const int &channel); - void MoveToRow(int row); - bool MoveChannel(bool direction); - bool MoveProgrammes(bool direction); - - CGUIListItemLayout *GetFocusedLayout() const; - - void ScrollToBlockOffset(int offset); - void ScrollToChannelOffset(int offset); - void UpdateScrollOffset(); - void RenderChannelItem(float posX, float posY, CGUIListItem *item, bool focused); - void RenderProgrammeItem(float posX, float posY, float width, float height, CGUIListItem *item, bool focused); - void GetCurrentLayouts(); - - CPoint m_renderOffset; ///< \brief render offset of the first item in the list \sa SetRenderOffset - - ORIENTATION m_orientation; - - struct ItemsPtr + struct GridItemsPtr + { + CGUIListItemPtr item; + float width; + float height; + }; + + class CGUIEPGGridContainer : public CGUIControl { - long start; - long stop; + public: + CGUIEPGGridContainer(int parentID, int controlID, float posX, float posY, float width, float height, + ORIENTATION orientation, int scrollTime, int preloadItems, int minutesPerPage, + int rulerUnit); + virtual ~CGUIEPGGridContainer(void); + virtual CGUIEPGGridContainer *Clone() const { return new CGUIEPGGridContainer(*this); }; + + virtual bool OnAction(const CAction &action); + virtual void OnDown(); + virtual void OnUp(); + virtual void OnLeft(); + virtual void OnRight(); + virtual bool OnMouseOver(const CPoint &point); + virtual bool OnMouseClick(int dwButton, const CPoint &point); + virtual bool OnMouseDoubleClick(int dwButton, const CPoint &point); + virtual bool OnMouseWheel(char wheel, const CPoint &point); + virtual bool OnMessage(CGUIMessage& message); + virtual void SetFocus(bool bOnOff); + + virtual CStdString GetDescription() const; + const int GetNumChannels() { return m_channels; }; + virtual int GetSelectedItem() const; + const int GetSelectedChannel() { return m_channelCursor + m_channelOffset; } + + void DoRender(unsigned int currentTime); + void Render(); + void LoadLayout(TiXmlElement *layout); + void LoadContent(TiXmlElement *content); + + virtual bool IsContainer() const { return true; }; + CGUIListItemPtr GetListItem(int offset) const; + + virtual int CorrectOffset(int offset, int cursor) const; + + /*! \brief Set the offset of the first item in the container from the container's position + Useful for lists/panels where the focused item may be larger than the non-focused items and thus + normally cut off from the clipping window defined by the container's position + size. + \param offset CPoint holding the offset in skin coordinates. + */ + void SetRenderOffset(const CPoint &offset); + + void GoToBegin(); + void GoToEnd(); + void SetStartEnd(CDateTime start, CDateTime end); + + protected: + bool OnClick(int actionID); + bool SelectItemFromPoint(const CPoint &point); + + void UpdateItems(); + + void SetChannel(int channel); + void SetBlock(int block); + void ChannelScroll(int amount); + void ProgrammesScroll(int amount); + void ValidateOffset(); + void UpdateLayout(bool refreshAllItems = false); + void CalculateLayout(); + void Reset(); + + GridItemsPtr *GetItem(const int &channel); + GridItemsPtr *GetNextItem(const int &channel); + GridItemsPtr *GetPrevItem(const int &channel); + GridItemsPtr *GetClosestItem(const int &channel); + + int GetItemSize(GridItemsPtr *item); + int GetBlock(const CGUIListItemPtr &item, const int &channel); + int GetRealBlock(const CGUIListItemPtr &item, const int &channel); + void MoveToRow(int row); + bool MoveChannel(bool direction); + bool MoveProgrammes(bool direction); + + CGUIListItemLayout *GetFocusedLayout() const; + + void ScrollToBlockOffset(int offset); + void ScrollToChannelOffset(int offset); + void UpdateScrollOffset(); + void RenderChannelItem(float posX, float posY, CGUIListItem *item, bool focused); + void RenderProgrammeItem(float posX, float posY, float width, float height, CGUIListItem *item, bool focused); + void GetCurrentLayouts(); + + CPoint m_renderOffset; ///< \brief render offset of the first item in the list \sa SetRenderOffset + + ORIENTATION m_orientation; + + struct ItemsPtr + { + long start; + long stop; + }; + std::vector< ItemsPtr > m_epgItemsPtr; + std::vector< CGUIListItemPtr > m_channelItems; + std::vector< CGUIListItemPtr > m_rulerItems; + std::vector< CGUIListItemPtr > m_programmeItems; + typedef std::vector ::iterator iItems; + + std::vector m_channelLayouts; + std::vector m_focusedChannelLayouts; + std::vector m_focusedProgrammeLayouts; + std::vector m_programmeLayouts; + std::vector m_rulerLayouts; + + CGUIListItemLayout *m_channelLayout; + CGUIListItemLayout *m_focusedChannelLayout; + CGUIListItemLayout *m_programmeLayout; + CGUIListItemLayout *m_focusedProgrammeLayout; + CGUIListItemLayout *m_rulerLayout; + + bool m_wasReset; // true if we've received a Reset message until we've rendered once. Allows + // us to make sure we don't tell the infomanager that we've been moving when + // the "movement" was simply due to the list being repopulated (thus cursor position + // changing around) + + void FreeChannelMemory(int keepStart, int keepEnd); + void FreeProgrammeMemory(int keepStart, int keepEnd); + void FreeRulerMemory(int keepStart, int keepEnd); + + void GetChannelCacheOffsets(int &cacheBefore, int &cacheAfter); + void GetProgrammeCacheOffsets(int &cacheBefore, int &cacheAfter); + void GetRulerCacheOffsets(int &cacheBefore, int &cacheAfter); + + private: + int m_rulerUnit; //! number of blocks that makes up one element of the ruler + int m_channels; + int m_channelsPerPage; + int m_ProgrammesPerPage; + int m_channelCursor; + int m_channelOffset; + int m_blocks; + int m_blocksPerPage; + int m_blockCursor; + int m_blockOffset; + int m_cacheChannelItems; + int m_cacheProgrammeItems; + int m_cacheRulerItems; + + float m_rulerPosX; //! X position of first ruler item + float m_rulerPosY; //! Y position of first ruler item + float m_rulerHeight; //! height of the scrolling timeline above the ruler items + float m_rulerWidth; //! width of each element of the ruler + float m_channelPosX; //! Y position of first channel row + float m_channelPosY; //! Y position of first channel row + float m_channelHeight; //! height of each channel row (& every grid item) + float m_channelWidth; //! width of the channel item + float m_gridPosX; //! X position of first grid item + float m_gridPosY; //! Y position of first grid item + float m_gridWidth; + float m_gridHeight; + float m_blockSize; //! a block's width in pixels + float m_analogScrollCount; + + CDateTime m_gridStart; + CDateTime m_gridEnd; + + struct GridItemsPtr **m_gridIndex; + GridItemsPtr *m_item; + CGUIListItem *m_lastItem; + CGUIListItem *m_lastChannel; + + unsigned int m_renderTime; + + int m_scrollTime; + bool m_channelWrapAround; + bool m_gridWrapAround; //! only when no more data available should this be true + + int m_programmeScrollLastTime; + float m_programmeScrollSpeed; + float m_programmeScrollOffset; + + int m_channelScrollLastTime; + float m_channelScrollSpeed; + float m_channelScrollOffset; + + CStdString m_label; }; - std::vector< ItemsPtr > m_epgItemsPtr; - std::vector< CGUIListItemPtr > m_channelItems; - std::vector< CGUIListItemPtr > m_rulerItems; - std::vector< CGUIListItemPtr > m_programmeItems; - typedef std::vector ::iterator iItems; - - std::vector m_channelLayouts; - std::vector m_focusedChannelLayouts; - std::vector m_focusedProgrammeLayouts; - std::vector m_programmeLayouts; - std::vector m_rulerLayouts; - - CGUIListItemLayout *m_channelLayout; - CGUIListItemLayout *m_focusedChannelLayout; - CGUIListItemLayout *m_programmeLayout; - CGUIListItemLayout *m_focusedProgrammeLayout; - CGUIListItemLayout *m_rulerLayout; - - bool m_wasReset; // true if we've received a Reset message until we've rendered once. Allows - // us to make sure we don't tell the infomanager that we've been moving when - // the "movement" was simply due to the list being repopulated (thus cursor position - // changing around) - - void FreeChannelMemory(int keepStart, int keepEnd); - void FreeProgrammeMemory(int keepStart, int keepEnd); - void FreeRulerMemory(int keepStart, int keepEnd); - - void GetChannelCacheOffsets(int &cacheBefore, int &cacheAfter); - void GetProgrammeCacheOffsets(int &cacheBefore, int &cacheAfter); - void GetRulerCacheOffsets(int &cacheBefore, int &cacheAfter); - -private: - int m_rulerUnit; //! number of blocks that makes up one element of the ruler - int m_channels; - int m_channelsPerPage; - int m_ProgrammesPerPage; - int m_channelCursor; - int m_channelOffset; - int m_blocks; - int m_blocksPerPage; - int m_blockCursor; - int m_blockOffset; - int m_cacheChannelItems; - int m_cacheProgrammeItems; - int m_cacheRulerItems; - - float m_rulerPosX; //! X position of first ruler item - float m_rulerPosY; //! Y position of first ruler item - float m_rulerHeight; //! height of the scrolling timeline above the ruler items - float m_rulerWidth; //! width of each element of the ruler - float m_channelPosX; //! Y position of first channel row - float m_channelPosY; //! Y position of first channel row - float m_channelHeight; //! height of each channel row (& every grid item) - float m_channelWidth; //! width of the channel item - float m_gridPosX; //! X position of first grid item - float m_gridPosY; //! Y position of first grid item - float m_gridWidth; - float m_gridHeight; - float m_blockSize; //! a block's width in pixels - float m_analogScrollCount; - - CDateTime m_gridStart; - CDateTime m_gridEnd; - - struct GridItemsPtr **m_gridIndex; - GridItemsPtr *m_item; - CGUIListItem *m_lastItem; - CGUIListItem *m_lastChannel; - - unsigned int m_renderTime; - - int m_scrollTime; - bool m_channelWrapAround; - bool m_gridWrapAround; //! only when no more data available should this be true - - int m_programmeScrollLastTime; - float m_programmeScrollSpeed; - float m_programmeScrollOffset; - - int m_channelScrollLastTime; - float m_channelScrollSpeed; - float m_channelScrollOffset; - - CStdString m_label; -}; +} diff --git a/xbmc/guilib/GUIControlFactory.cpp b/xbmc/guilib/GUIControlFactory.cpp index f3446c818711f..7c6dfa7690311 100644 --- a/xbmc/guilib/GUIControlFactory.cpp +++ b/xbmc/guilib/GUIControlFactory.cpp @@ -65,6 +65,7 @@ #include "utils/StringUtils.h" using namespace std; +using namespace EPG; typedef struct { diff --git a/xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.cpp b/xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.cpp index b5e6ec4d170ba..80f1759eacd9e 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.cpp +++ b/xbmc/pvr/dialogs/GUIDialogPVRGuideInfo.cpp @@ -33,6 +33,7 @@ using namespace std; using namespace PVR; +using namespace EPG; #define CONTROL_BTN_SWITCH 5 #define CONTROL_BTN_RECORD 6 diff --git a/xbmc/pvr/epg/PVREpg.cpp b/xbmc/pvr/epg/PVREpg.cpp index 0bd718bbf9832..bbe08122a80ef 100644 --- a/xbmc/pvr/epg/PVREpg.cpp +++ b/xbmc/pvr/epg/PVREpg.cpp @@ -33,6 +33,7 @@ #include "epg/EpgDatabase.h" using namespace PVR; +using namespace EPG; CPVREpg::CPVREpg(CPVRChannel *channel) : CEpg(channel->ChannelID(), channel->ChannelName(), channel->EPGScraper()) diff --git a/xbmc/pvr/epg/PVREpg.h b/xbmc/pvr/epg/PVREpg.h index c5eaa260f3496..c6e42071a4890 100644 --- a/xbmc/pvr/epg/PVREpg.h +++ b/xbmc/pvr/epg/PVREpg.h @@ -31,7 +31,7 @@ namespace PVR /** PVR EPG class */ - class CPVREpg : public CEpg + class CPVREpg : public EPG::CEpg { private: /*! @@ -46,7 +46,7 @@ namespace PVR * @brief Create a new tag. * @return The new tag. */ - CEpgInfoTag *CreateTag(void); + EPG::CEpgInfoTag *CreateTag(void); bool LoadFromClients(time_t start, time_t end); diff --git a/xbmc/pvr/epg/PVREpgContainer.cpp b/xbmc/pvr/epg/PVREpgContainer.cpp index a1d4d3bd565e2..69c6eaccfbefa 100644 --- a/xbmc/pvr/epg/PVREpgContainer.cpp +++ b/xbmc/pvr/epg/PVREpgContainer.cpp @@ -31,6 +31,7 @@ using namespace std; using namespace PVR; +using namespace EPG; void CPVREpgContainer::Clear(bool bClearDb /* = false */) { diff --git a/xbmc/pvr/epg/PVREpgContainer.h b/xbmc/pvr/epg/PVREpgContainer.h index c0fb2cb09feae..f5472e1051dd4 100644 --- a/xbmc/pvr/epg/PVREpgContainer.h +++ b/xbmc/pvr/epg/PVREpgContainer.h @@ -27,7 +27,7 @@ namespace PVR { - class CPVREpgContainer : public CEpgContainer + class CPVREpgContainer : public EPG::CEpgContainer { friend class CPVREpg; @@ -49,7 +49,7 @@ namespace PVR * @param iEpgId The table ID or -1 to create a new one. * @return The new table. */ - CEpg *CreateEpg(int iEpgId); + EPG::CEpg *CreateEpg(int iEpgId); bool UpdateEPG(bool bShowProgress = false); diff --git a/xbmc/pvr/epg/PVREpgInfoTag.cpp b/xbmc/pvr/epg/PVREpgInfoTag.cpp index e492353c6d6b7..3c0a1c290b03b 100644 --- a/xbmc/pvr/epg/PVREpgInfoTag.cpp +++ b/xbmc/pvr/epg/PVREpgInfoTag.cpp @@ -30,20 +30,21 @@ using namespace std; using namespace PVR; +using namespace EPG; -CPVREpgInfoTag::CPVREpgInfoTag(const EPG_TAG &data) : - CEpgInfoTag() +CPVREpgInfoTag::CPVREpgInfoTag(void) : + CEpgInfoTag(), + m_Timer(NULL), + m_isRecording(false) { - Reset(); - Update(data); } -void CPVREpgInfoTag::Reset() +CPVREpgInfoTag::CPVREpgInfoTag(const EPG_TAG &data) : + CEpgInfoTag(), + m_Timer(NULL), + m_isRecording(false) { - CEpgInfoTag::Reset(); - - m_isRecording = false; - m_Timer = NULL; + Update(data); } const CPVRChannel *CPVREpgInfoTag::ChannelTag(void) const diff --git a/xbmc/pvr/epg/PVREpgInfoTag.h b/xbmc/pvr/epg/PVREpgInfoTag.h index f3cb714106456..adf5e9ae8a0e5 100644 --- a/xbmc/pvr/epg/PVREpgInfoTag.h +++ b/xbmc/pvr/epg/PVREpgInfoTag.h @@ -32,7 +32,7 @@ namespace PVR /** an EPG info tag */ - class CPVREpgInfoTag : public CEpgInfoTag + class CPVREpgInfoTag : public EPG::CEpgInfoTag { friend class CPVREpg; @@ -44,7 +44,7 @@ namespace PVR /*! * @brief Create a new empty EPG infotag. */ - CPVREpgInfoTag(void) { Reset(); }; + CPVREpgInfoTag(void); /*! * @brief Create a new EPG infotag with 'data' as content. @@ -52,11 +52,6 @@ namespace PVR */ CPVREpgInfoTag(const EPG_TAG &data); - /*! - * @brief Clear this event. - */ - void Reset(); - /*! * @brief Get the channel that plays this event. * @return a pointer to the channel. diff --git a/xbmc/pvr/epg/PVREpgSearchFilter.cpp b/xbmc/pvr/epg/PVREpgSearchFilter.cpp index 4105d0d38d321..277343e3c0e3a 100644 --- a/xbmc/pvr/epg/PVREpgSearchFilter.cpp +++ b/xbmc/pvr/epg/PVREpgSearchFilter.cpp @@ -29,6 +29,7 @@ using namespace std; using namespace PVR; +using namespace EPG; void PVREpgSearchFilter::Reset() { diff --git a/xbmc/pvr/epg/PVREpgSearchFilter.h b/xbmc/pvr/epg/PVREpgSearchFilter.h index 61eb9846ccda3..a4d23e351cea8 100644 --- a/xbmc/pvr/epg/PVREpgSearchFilter.h +++ b/xbmc/pvr/epg/PVREpgSearchFilter.h @@ -30,7 +30,7 @@ namespace PVR /** Filter to apply with on a CPVREpgInfoTag */ - struct PVREpgSearchFilter : public EpgSearchFilter + struct PVREpgSearchFilter : public EPG::EpgSearchFilter { /*! * @brief Clear this filter. diff --git a/xbmc/pvr/timers/PVRTimers.cpp b/xbmc/pvr/timers/PVRTimers.cpp index fa5a6fa357f14..3fbe43b20d6d9 100644 --- a/xbmc/pvr/timers/PVRTimers.cpp +++ b/xbmc/pvr/timers/PVRTimers.cpp @@ -34,6 +34,7 @@ using namespace std; using namespace PVR; +using namespace EPG; CPVRTimers::CPVRTimers(void) { diff --git a/xbmc/pvr/timers/PVRTimers.h b/xbmc/pvr/timers/PVRTimers.h index bcedfd3a53685..a803901910ce5 100644 --- a/xbmc/pvr/timers/PVRTimers.h +++ b/xbmc/pvr/timers/PVRTimers.h @@ -27,7 +27,10 @@ #include "threads/Thread.h" class CFileItem; -class CEpgInfoTag; +namespace EPG +{ + class CEpgInfoTag; +} namespace PVR { @@ -187,7 +190,7 @@ namespace PVR bool IsRecording(void); bool UpdateEntries(CPVRTimers *timers); CPVRTimerInfoTag *GetByClient(int iClientId, int iClientTimerId); - CPVRTimerInfoTag *GetMatch(const CEpgInfoTag *Epg); + CPVRTimerInfoTag *GetMatch(const EPG::CEpgInfoTag *Epg); CPVRTimerInfoTag *GetMatch(const CFileItem *item); virtual void Notify(const Observable &obs, const CStdString& msg); bool IsRecordingOnChannel(const CPVRChannel &channel) const; diff --git a/xbmc/pvr/windows/GUIWindowPVR.h b/xbmc/pvr/windows/GUIWindowPVR.h index 4e8c608f681c9..98588f7b1528d 100644 --- a/xbmc/pvr/windows/GUIWindowPVR.h +++ b/xbmc/pvr/windows/GUIWindowPVR.h @@ -62,7 +62,7 @@ namespace PVR void UnlockWindow(); - CGUIEPGGridContainer *m_guideGrid; + EPG::CGUIEPGGridContainer *m_guideGrid; protected: virtual void SetLabel(int iControl, const CStdString &strLabel); diff --git a/xbmc/pvr/windows/GUIWindowPVRGuide.cpp b/xbmc/pvr/windows/GUIWindowPVRGuide.cpp index 4da7a9d8323ad..88b5b6e35bcd8 100644 --- a/xbmc/pvr/windows/GUIWindowPVRGuide.cpp +++ b/xbmc/pvr/windows/GUIWindowPVRGuide.cpp @@ -37,6 +37,7 @@ #include "pvr/timers/PVRTimers.h" using namespace PVR; +using namespace EPG; CGUIWindowPVRGuide::CGUIWindowPVRGuide(CGUIWindowPVR *parent) : CGUIWindowPVRCommon(parent, PVR_WINDOW_EPG, CONTROL_BTNGUIDE, CONTROL_LIST_GUIDE_NOW_NEXT), From f0e9953072e5821e2c8f0ea6e3f9636d90239d5a Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Thu, 21 Apr 2011 18:19:11 +0200 Subject: [PATCH 09/47] pvr: prevent gui list resets when they're not needed --- xbmc/pvr/PVRManager.cpp | 5 +++-- xbmc/pvr/PVRManager.h | 3 ++- xbmc/pvr/channels/PVRChannelGroup.cpp | 5 ++++- xbmc/pvr/timers/PVRTimers.cpp | 15 +++++++++------ xbmc/pvr/windows/GUIWindowPVR.cpp | 11 +++++++++-- xbmc/pvr/windows/GUIWindowPVR.h | 2 +- xbmc/pvr/windows/GUIWindowPVRCommon.cpp | 6 ++++++ xbmc/pvr/windows/GUIWindowPVRCommon.h | 1 + xbmc/pvr/windows/GUIWindowPVRGuide.h | 1 + 9 files changed, 36 insertions(+), 13 deletions(-) diff --git a/xbmc/pvr/PVRManager.cpp b/xbmc/pvr/PVRManager.cpp index e227803d2cb53..240f0e1c34106 100644 --- a/xbmc/pvr/PVRManager.cpp +++ b/xbmc/pvr/PVRManager.cpp @@ -331,11 +331,12 @@ bool CPVRManager::ContinueLastChannel(void) return bReturn; } -void CPVRManager::UpdateWindow(PVRWindow window) +void CPVRManager::UpdateWindow(PVRWindow window, bool bResetContents /* = true */) { + /* TODO use an observable for this! */ CGUIWindowPVR *pWindow = (CGUIWindowPVR *) g_windowManager.GetWindow(WINDOW_PVR); if (pWindow) - pWindow->UpdateWindow(window); + pWindow->UpdateWindow(window, bResetContents); } void CPVRManager::ResetProperties(void) diff --git a/xbmc/pvr/PVRManager.h b/xbmc/pvr/PVRManager.h index b1b289a61136b..110becc03a525 100644 --- a/xbmc/pvr/PVRManager.h +++ b/xbmc/pvr/PVRManager.h @@ -345,8 +345,9 @@ namespace PVR /*! * @brief Update the data in a pvr window if that window is currently visible. * @param window The window to update. + * @param bResetContents True to reset the contents of the given window, false to just mark all the window's items invalid. */ - void UpdateWindow(PVRWindow window); + void UpdateWindow(PVRWindow window, bool bResetContents = true); /*! * @brief Check whether names are still correct after the language settings changed. diff --git a/xbmc/pvr/channels/PVRChannelGroup.cpp b/xbmc/pvr/channels/PVRChannelGroup.cpp index 7ecbdfe194856..f9fcfb23e4cb4 100644 --- a/xbmc/pvr/channels/PVRChannelGroup.cpp +++ b/xbmc/pvr/channels/PVRChannelGroup.cpp @@ -471,6 +471,7 @@ bool CPVRChannelGroup::RemoveByUniqueID(int iUniqueID) bool CPVRChannelGroup::UpdateGroupEntries(const CPVRChannelGroup &channels) { bool bChanged(false); + bool bAddedOrDeleted(false); CSingleLock lock(m_critSection); int iCurSize = size(); @@ -496,6 +497,7 @@ bool CPVRChannelGroup::UpdateGroupEntries(const CPVRChannelGroup &channels) bChanged = true; m_bChanged = true; + bAddedOrDeleted = true; CLog::Log(LOGINFO,"PVRChannelGroup - %s - added %s channel '%s' at position %d in group '%s'", __FUNCTION__, m_bRadio ? "radio" : "TV", realChannel->ChannelName().c_str(), iChannelNumber, GroupName().c_str()); } @@ -518,6 +520,7 @@ bool CPVRChannelGroup::UpdateGroupEntries(const CPVRChannelGroup &channels) RemoveFromGroup(channel); m_bChanged = true; + bAddedOrDeleted = true; bChanged = true; iChannelPtr--; iSize--; @@ -536,7 +539,7 @@ bool CPVRChannelGroup::UpdateGroupEntries(const CPVRChannelGroup &channels) lock.Leave(); - g_PVRManager.UpdateWindow(m_bRadio ? PVR_WINDOW_CHANNELS_RADIO : PVR_WINDOW_CHANNELS_TV); + g_PVRManager.UpdateWindow(m_bRadio ? PVR_WINDOW_CHANNELS_RADIO : PVR_WINDOW_CHANNELS_TV, bAddedOrDeleted); return Persist(); } diff --git a/xbmc/pvr/timers/PVRTimers.cpp b/xbmc/pvr/timers/PVRTimers.cpp index 3fbe43b20d6d9..dd7e24f099f8d 100644 --- a/xbmc/pvr/timers/PVRTimers.cpp +++ b/xbmc/pvr/timers/PVRTimers.cpp @@ -131,7 +131,8 @@ bool CPVRTimers::IsRecording(void) bool CPVRTimers::UpdateEntries(CPVRTimers *timers) { - bool bChanged = false; + bool bChanged(false); + bool bAddedOrDeleted(false); CSingleLock lock(m_critSection); @@ -160,6 +161,7 @@ bool CPVRTimers::UpdateEntries(CPVRTimers *timers) newTimer->UpdateEntry(*timer); push_back(newTimer); bChanged = true; + bAddedOrDeleted = true; CLog::Log(LOGINFO,"PVRTimers - %s - added timer %d on client %d", __FUNCTION__, timer->m_iClientIndex, timer->m_iClientId); @@ -188,6 +190,7 @@ bool CPVRTimers::UpdateEntries(CPVRTimers *timers) iTimerPtr--; iSize--; bChanged = true; + bAddedOrDeleted = true; } } @@ -200,11 +203,11 @@ bool CPVRTimers::UpdateEntries(CPVRTimers *timers) NotifyObservers("timers", false); - g_PVRManager.UpdateWindow(PVR_WINDOW_TIMERS); - g_PVRManager.UpdateWindow(PVR_WINDOW_EPG); - g_PVRManager.UpdateWindow(PVR_WINDOW_RECORDINGS); - g_PVRManager.UpdateWindow(PVR_WINDOW_CHANNELS_TV); - g_PVRManager.UpdateWindow(PVR_WINDOW_CHANNELS_RADIO); + g_PVRManager.UpdateWindow(PVR_WINDOW_TIMERS, bAddedOrDeleted); + g_PVRManager.UpdateWindow(PVR_WINDOW_EPG, false); + g_PVRManager.UpdateWindow(PVR_WINDOW_RECORDINGS, bAddedOrDeleted); + g_PVRManager.UpdateWindow(PVR_WINDOW_CHANNELS_TV, false); + g_PVRManager.UpdateWindow(PVR_WINDOW_CHANNELS_RADIO, false); } return bChanged; diff --git a/xbmc/pvr/windows/GUIWindowPVR.cpp b/xbmc/pvr/windows/GUIWindowPVR.cpp index 4dc28985028d5..c94ccacfe2fa0 100644 --- a/xbmc/pvr/windows/GUIWindowPVR.cpp +++ b/xbmc/pvr/windows/GUIWindowPVR.cpp @@ -174,7 +174,7 @@ void CGUIWindowPVR::OnWindowUnload(void) CGUIMediaWindow::OnWindowUnload(); } -void CGUIWindowPVR::UpdateWindow(PVRWindow window) +void CGUIWindowPVR::UpdateWindow(PVRWindow window, bool bResetContents /* = true */) { CSingleLock lock(m_critSection); if (!m_bViewsCreated) @@ -208,9 +208,16 @@ void CGUIWindowPVR::UpdateWindow(PVRWindow window) if (updateWindow) { if (updateWindow->IsVisible()) - updateWindow->UpdateData(); + { + if (bResetContents) + updateWindow->UpdateData(); + else + updateWindow->SetInvalid(); + } else + { updateWindow->m_bUpdateRequired = true; + } } } diff --git a/xbmc/pvr/windows/GUIWindowPVR.h b/xbmc/pvr/windows/GUIWindowPVR.h index 98588f7b1528d..022bac5564f84 100644 --- a/xbmc/pvr/windows/GUIWindowPVR.h +++ b/xbmc/pvr/windows/GUIWindowPVR.h @@ -57,7 +57,7 @@ namespace PVR virtual bool OnMessage(CGUIMessage& message); virtual void OnWindowLoaded(void); virtual void OnWindowUnload(void); - virtual void UpdateWindow(PVRWindow window); + virtual void UpdateWindow(PVRWindow window, bool bResetContents = true); virtual void InitializeEpgCache(void); void UnlockWindow(); diff --git a/xbmc/pvr/windows/GUIWindowPVRCommon.cpp b/xbmc/pvr/windows/GUIWindowPVRCommon.cpp index e8fb9a0e810fe..60fd4b1541064 100644 --- a/xbmc/pvr/windows/GUIWindowPVRCommon.cpp +++ b/xbmc/pvr/windows/GUIWindowPVRCommon.cpp @@ -123,6 +123,12 @@ bool CGUIWindowPVRCommon::IsSelectedList(CGUIMessage &message) const return (message.GetSenderId() == (int) m_iControlList); } +void CGUIWindowPVRCommon::SetInvalid() +{ + for (int iItemPtr = 0; iItemPtr < m_parent->m_vecItems->Size(); iItemPtr++) + m_parent->m_vecItems->Get(iItemPtr)->SetInvalid(); +} + void CGUIWindowPVRCommon::OnInitWindow() { m_parent->m_viewControl.SetCurrentView(m_iControlList); diff --git a/xbmc/pvr/windows/GUIWindowPVRCommon.h b/xbmc/pvr/windows/GUIWindowPVRCommon.h index 5519039202217..8519a35bacf81 100644 --- a/xbmc/pvr/windows/GUIWindowPVRCommon.h +++ b/xbmc/pvr/windows/GUIWindowPVRCommon.h @@ -90,6 +90,7 @@ namespace PVR virtual void GetContextButtons(int itemNumber, CContextButtons &buttons) const = 0; virtual void UpdateData(void) = 0; + virtual void SetInvalid(void); virtual void OnInitWindow(void); virtual void OnWindowUnload(void); diff --git a/xbmc/pvr/windows/GUIWindowPVRGuide.h b/xbmc/pvr/windows/GUIWindowPVRGuide.h index 3f7e54df323c7..a8aa0cbc738d4 100644 --- a/xbmc/pvr/windows/GUIWindowPVRGuide.h +++ b/xbmc/pvr/windows/GUIWindowPVRGuide.h @@ -42,6 +42,7 @@ namespace PVR virtual bool OnContextButton(int itemNumber, CONTEXT_BUTTON button); virtual void UpdateData(void); virtual void Notify(const Observable &obs, const CStdString& msg); + virtual void SetInvalid(void) { UpdateData(); } private: virtual bool IsSelectedButton(CGUIMessage &message) const; From f031a5afa68a6c8a11b966d8ff68c21fd7253d3e Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Thu, 21 Apr 2011 22:57:41 +0200 Subject: [PATCH 10/47] pvr: clean up some parameters in CPVRDatabase --- xbmc/pvr/PVRDatabase.cpp | 57 ++++++++----------- xbmc/pvr/PVRDatabase.h | 30 ++++------ xbmc/pvr/channels/PVRChannelGroup.cpp | 2 +- xbmc/pvr/channels/PVRChannelGroupInternal.cpp | 2 +- xbmc/pvr/channels/PVRChannelGroups.cpp | 6 +- 5 files changed, 39 insertions(+), 58 deletions(-) diff --git a/xbmc/pvr/PVRDatabase.cpp b/xbmc/pvr/PVRDatabase.cpp index 1c50f9f79d38c..12ec5419be401 100644 --- a/xbmc/pvr/PVRDatabase.cpp +++ b/xbmc/pvr/PVRDatabase.cpp @@ -27,6 +27,7 @@ #include "PVRManager.h" #include "channels/PVRChannelGroupsContainer.h" +#include "addons/PVRClient.h" using namespace std; using namespace dbiplus; @@ -202,27 +203,27 @@ bool CPVRDatabase::UpdateOldVersion(int iVersion) /********** Channel methods **********/ -bool CPVRDatabase::DeleteChannels() +bool CPVRDatabase::DeleteChannels(void) { CLog::Log(LOGDEBUG, "PVRDB - %s - deleting all channels from the database", __FUNCTION__); return DeleteValues("channels"); } -bool CPVRDatabase::DeleteClientChannels(int iClientId) +bool CPVRDatabase::DeleteClientChannels(const CPVRClient &client) { /* invalid client Id */ - if (iClientId <= 0) + if (client.GetID() <= 0) { CLog::Log(LOGERROR, "PVRDB - %s - invalid client id: %i", - __FUNCTION__, iClientId); + __FUNCTION__, client.GetID()); return false; } CLog::Log(LOGDEBUG, "PVRDB - %s - deleting all channels from client '%i' from the database", - __FUNCTION__, iClientId); + __FUNCTION__, client.GetID()); - CStdString strWhereClause = FormatSQL("iClientId = %u", iClientId); + CStdString strWhereClause = FormatSQL("iClientId = %u", client.GetID()); return DeleteValues("channels", strWhereClause); } @@ -288,7 +289,7 @@ bool CPVRDatabase::Delete(const CPVRChannel &channel) return DeleteValues("channels", strWhereClause); } -int CPVRDatabase::GetChannels(CPVRChannelGroupInternal *results, bool bIsRadio) +int CPVRDatabase::Get(CPVRChannelGroupInternal &results) { int iReturn = 0; @@ -298,7 +299,7 @@ int CPVRDatabase::GetChannels(CPVRChannelGroupInternal *results, bool bIsRadio) "FROM channels " "LEFT JOIN map_channelgroups_channels ON map_channelgroups_channels.idChannel = channels.idChannel AND map_channelgroups_channels.idGroup = %u " "WHERE channels.bIsRadio = %u " - "ORDER BY map_channelgroups_channels.iChannelNumber ASC;", bIsRadio ? XBMC_INTERNAL_GROUP_RADIO : XBMC_INTERNAL_GROUP_TV, bIsRadio ? 1 : 0); + "ORDER BY map_channelgroups_channels.iChannelNumber ASC;", results.IsRadio() ? XBMC_INTERNAL_GROUP_RADIO : XBMC_INTERNAL_GROUP_TV, results.IsRadio() ? 1 : 0); if (ResultQuery(strQuery)) { try @@ -325,7 +326,7 @@ int CPVRDatabase::GetChannels(CPVRChannelGroupInternal *results, bool bIsRadio) CLog::Log(LOGDEBUG, "PVRDB - %s - channel '%s' loaded from the database", __FUNCTION__, channel->m_strChannelName.c_str()); - results->InsertInGroup(channel, m_pDS->fv("iChannelNumber").get_asInt()); + results.InsertInGroup(channel, m_pDS->fv("iChannelNumber").get_asInt()); m_pDS->next(); ++iReturn; } @@ -448,9 +449,9 @@ bool CPVRDatabase::PersistChannelSettings(const CPVRChannel &channel, const CVid /********** Channel group methods **********/ -bool CPVRDatabase::RemoveChannelsFromGroup(int iGroupId) +bool CPVRDatabase::RemoveChannelsFromGroup(const CPVRChannelGroup &group) { - CStdString strWhereClause = FormatSQL("idGroup = %u", iGroupId); + CStdString strWhereClause = FormatSQL("idGroup = %u", group.GroupID()); return DeleteValues("map_channelgroups_channels", strWhereClause); } @@ -462,24 +463,24 @@ bool CPVRDatabase::DeleteChannelGroups(bool bRadio /* = false */) return DeleteValues("channelgroups", strWhereClause); } -bool CPVRDatabase::DeleteChannelGroup(int iGroupId, bool bRadio /* = false */) +bool CPVRDatabase::Delete(const CPVRChannelGroup &group) { /* invalid group id */ - if (iGroupId <= 0) + if (group.GroupID() <= 0) { CLog::Log(LOGERROR, "PVRDB - %s - invalid group id: %d", - __FUNCTION__, iGroupId); + __FUNCTION__, group.GroupID()); return false; } - CStdString strWhereClause = FormatSQL("idGroup = %u AND bIsRadio = %u", iGroupId, bRadio); + CStdString strWhereClause = FormatSQL("idGroup = %u AND bIsRadio = %u", group.GroupID(), group.IsRadio()); return DeleteValues("channelgroups", strWhereClause); } -bool CPVRDatabase::GetChannelGroupList(CPVRChannelGroups &results, bool bRadio) +bool CPVRDatabase::Get(CPVRChannelGroups &results) { bool bReturn = false; - CStdString strQuery = FormatSQL("SELECT * from channelgroups WHERE bIsRadio = %u ORDER BY idGroup;", bRadio); + CStdString strQuery = FormatSQL("SELECT * from channelgroups WHERE bIsRadio = %u ORDER BY idGroup;", results.IsRadio()); if (ResultQuery(strQuery)) { @@ -512,19 +513,19 @@ bool CPVRDatabase::GetChannelGroupList(CPVRChannelGroups &results, bool bRadio) return bReturn; } -int CPVRDatabase::GetChannelsInGroup(CPVRChannelGroup *group) +int CPVRDatabase::GetGroupMembers(CPVRChannelGroup &group) { int iReturn = -1; /* invalid group id */ - if (group->GroupID() < 0) + if (group.GroupID() < 0) { CLog::Log(LOGERROR, "PVRDB - %s - invalid group id: %d", - __FUNCTION__, group->GroupID()); + __FUNCTION__, group.GroupID()); return -1; } - CStdString strQuery = FormatSQL("SELECT idChannel, iChannelNumber FROM map_channelgroups_channels WHERE idGroup = %u ORDER BY iChannelNumber", group->GroupID()); + CStdString strQuery = FormatSQL("SELECT idChannel, iChannelNumber FROM map_channelgroups_channels WHERE idGroup = %u ORDER BY iChannelNumber", group.GroupID()); if (ResultQuery(strQuery)) { iReturn = 0; @@ -537,7 +538,7 @@ int CPVRDatabase::GetChannelsInGroup(CPVRChannelGroup *group) int iChannelNumber = m_pDS->fv("iChannelNumber").get_asInt(); CPVRChannel *channel = (CPVRChannel *) g_PVRChannelGroups->GetByChannelIDFromAll(iChannelId); - if (channel && group->AddToGroup(channel, iChannelNumber)) + if (channel && group.AddToGroup(channel, iChannelNumber)) ++iReturn; m_pDS->next(); @@ -553,16 +554,6 @@ int CPVRDatabase::GetChannelsInGroup(CPVRChannelGroup *group) return iReturn; } -int CPVRDatabase::GetChannelGroupId(const CStdString &strGroupName, bool bRadio /* = false */) -{ - CStdString strWhereClause = FormatSQL("sName LIKE '%s' AND bIsRadio = %u", strGroupName.c_str(), (bRadio ? 1 : 0)); - CStdString strReturn = GetSingleValue("channelgroups", "idGroup", strWhereClause); - - m_pDS->close(); - - return atoi(strReturn); -} - int CPVRDatabase::Persist(CPVRChannelGroup *group) { int iReturn = -1; @@ -591,7 +582,7 @@ int CPVRDatabase::Persist(CPVRChannelGroup *group) if (group->GroupID() <= 0) group->m_iGroupId = (int) m_pDS->lastinsertid(); - RemoveChannelsFromGroup(group->GroupID()); + RemoveChannelsFromGroup(*group); for (unsigned int iChannelPtr = 0; iChannelPtr < group->size(); iChannelPtr++) { diff --git a/xbmc/pvr/PVRDatabase.h b/xbmc/pvr/PVRDatabase.h index 75938346dd9c3..e27c13aef1f20 100644 --- a/xbmc/pvr/PVRDatabase.h +++ b/xbmc/pvr/PVRDatabase.h @@ -32,6 +32,7 @@ namespace PVR class CPVRChannelsContainer; class CPVRChannel; class CPVRChannelGroups; + class CPVRClient; /** The PVR database */ @@ -69,14 +70,14 @@ namespace PVR * @brief Remove all channels from the database. * @return True if all channels were removed, false otherwise. */ - bool DeleteChannels(); + bool DeleteChannels(void); /*! * @brief Remove all channels from a client from the database. - * @param iClientId The ID of the client to delete the channels for. + * @param client The client to delete the channels for. * @return True if the channels were deleted, false otherwise. */ - bool DeleteClientChannels(int iClientId); + bool DeleteClientChannels(const CPVRClient &client); /*! * @brief Add or update a channel entry in the database @@ -96,10 +97,9 @@ namespace PVR /*! * @brief Get the list of channels from the database * @param results The channel group to store the results in. - * @param bIsRadio Get the radio channels if true. Get the TV channels otherwise. * @return The amount of channels that were added. */ - int GetChannels(CPVRChannelGroupInternal *results, bool bIsRadio); + int Get(CPVRChannelGroupInternal &results); //@} @@ -139,7 +139,7 @@ namespace PVR /*! @name Channel group methods */ //@{ - bool RemoveChannelsFromGroup(int iGroupId); + bool RemoveChannelsFromGroup(const CPVRChannelGroup &group); /*! * @brief Remove all channel groups from the database @@ -150,26 +150,24 @@ namespace PVR /*! * @brief Delete a channel group from the database. - * @param iGroupId The id of the group to delete. - * @param bRadio True if it's a radio channel group, false otherwise. + * @param group The group to delete. * @return True if the group was deleted successfully, false otherwise. */ - bool DeleteChannelGroup(int iGroupId, bool bRadio = false); + bool Delete(const CPVRChannelGroup &group); /*! * @brief Get the channel groups. * @param results The container to store the results in. - * @param bRadio Get radio channel groups if true. * @return True if the list was fetched successfully, false otherwise. */ - bool GetChannelGroupList(CPVRChannelGroups &results, bool bRadio); + bool Get(CPVRChannelGroups &results); /*! * @brief Add the group members to a group. * @param group The group to get the channels for. * @return The amount of channels that were added. */ - int GetChannelsInGroup(CPVRChannelGroup *group); + int GetGroupMembers(CPVRChannelGroup &group); /*! * @brief Add or update a channel group entry in the database. @@ -178,14 +176,6 @@ namespace PVR */ int Persist(CPVRChannelGroup *group); - protected: - /*! - * @brief Get the Id of a channel group - * @param strGroupName The name of the group. - * @param bRadio True if it's a radio channel group, false otherwise. - * @return - */ - int GetChannelGroupId(const CStdString &strGroupName, bool bRadio = false); //@} /*! @name Client methods */ diff --git a/xbmc/pvr/channels/PVRChannelGroup.cpp b/xbmc/pvr/channels/PVRChannelGroup.cpp index f9fcfb23e4cb4..cea94318aec97 100644 --- a/xbmc/pvr/channels/PVRChannelGroup.cpp +++ b/xbmc/pvr/channels/PVRChannelGroup.cpp @@ -434,7 +434,7 @@ int CPVRChannelGroup::LoadFromDb(bool bCompress /* = false */) int iChannelCount = size(); - database->GetChannelsInGroup(this); + database->GetGroupMembers(*this); database->Close(); return size() - iChannelCount; diff --git a/xbmc/pvr/channels/PVRChannelGroupInternal.cpp b/xbmc/pvr/channels/PVRChannelGroupInternal.cpp index 524d73df0647d..2394c0573b639 100644 --- a/xbmc/pvr/channels/PVRChannelGroupInternal.cpp +++ b/xbmc/pvr/channels/PVRChannelGroupInternal.cpp @@ -222,7 +222,7 @@ int CPVRChannelGroupInternal::LoadFromDb(bool bCompress /* = false */) int iChannelCount = size(); - if (database->GetChannels(this, m_bRadio) > 0) + if (database->Get(*this) > 0) { if (bCompress) database->Compress(true); diff --git a/xbmc/pvr/channels/PVRChannelGroups.cpp b/xbmc/pvr/channels/PVRChannelGroups.cpp index 780fdc689b677..2c208f2ea25a6 100644 --- a/xbmc/pvr/channels/PVRChannelGroups.cpp +++ b/xbmc/pvr/channels/PVRChannelGroups.cpp @@ -241,7 +241,7 @@ bool CPVRChannelGroups::LoadUserDefinedChannelGroups(void) } /* load the other groups from the database */ - database->GetChannelGroupList(*this, m_bRadio); + database->Get(*this); int iSize = size(); CLog::Log(LOGDEBUG, "PVRChannelGroups - %s - %d user defined groups %s fetched from the database", __FUNCTION__, iSize - 1, m_bRadio ? "radio" : "TV"); @@ -416,10 +416,10 @@ bool CPVRChannelGroups::DeleteGroup(const CPVRChannelGroup &group) } /* remove all channels from the group */ - database->RemoveChannelsFromGroup(group.GroupID()); + database->RemoveChannelsFromGroup(group); /* delete the group from the database */ - bReturn = database->DeleteChannelGroup(group.GroupID(), m_bRadio); + bReturn = database->Delete(group); database->Close(); From 795a9fe381fbc43e3d85bfd346388ca58fda75b3 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Thu, 21 Apr 2011 23:04:50 +0200 Subject: [PATCH 11/47] pvr: clean up some parameters in CEPGDatabase --- xbmc/epg/Epg.cpp | 2 +- xbmc/epg/EpgContainer.cpp | 2 +- xbmc/epg/EpgDatabase.cpp | 14 +++++++------- xbmc/epg/EpgDatabase.h | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/xbmc/epg/Epg.cpp b/xbmc/epg/Epg.cpp index b9447342ebd23..0c8c6b7048097 100644 --- a/xbmc/epg/Epg.cpp +++ b/xbmc/epg/Epg.cpp @@ -394,7 +394,7 @@ bool CEpg::Load(void) return bReturn; } - int iEntriesLoaded = database->Get(this); + int iEntriesLoaded = database->Get(*this); if (iEntriesLoaded <= 0) { CLog::Log(LOGNOTICE, "Epg - %s - no database entries found for table '%s'.", diff --git a/xbmc/epg/EpgContainer.cpp b/xbmc/epg/EpgContainer.cpp index 2faa65f8ee53f..6ad54698f254d 100644 --- a/xbmc/epg/EpgContainer.cpp +++ b/xbmc/epg/EpgContainer.cpp @@ -147,7 +147,7 @@ void CEpgContainer::Process(void) if (m_database.Open()) { m_database.DeleteOldEpgEntries(); - m_database.Get(this); + m_database.Get(*this); m_database.Close(); } diff --git a/xbmc/epg/EpgDatabase.cpp b/xbmc/epg/EpgDatabase.cpp index aaefe0e027847..44999b0763751 100644 --- a/xbmc/epg/EpgDatabase.cpp +++ b/xbmc/epg/EpgDatabase.cpp @@ -176,7 +176,7 @@ bool CEpgDatabase::Delete(const CEpgInfoTag &tag) return DeleteValues("epgtags", strWhereClause); } -int CEpgDatabase::Get(CEpgContainer *container) +int CEpgDatabase::Get(CEpgContainer &container) { int iReturn = -1; @@ -194,7 +194,7 @@ int CEpgDatabase::Get(CEpgContainer *container) CStdString strScraperName = m_pDS->fv("sScraperName").get_asString().c_str(); CEpg newEpg(iEpgID, strName, strScraperName); - if (container->UpdateEntry(newEpg)) + if (container.UpdateEntry(newEpg)) ++iReturn; else { @@ -219,12 +219,12 @@ int CEpgDatabase::Get(CEpgContainer *container) return iReturn; } -int CEpgDatabase::Get(CEpg *epg) +int CEpgDatabase::Get(CEpg &epg) { int iReturn = -1; CStdString strWhereClause; - strWhereClause = FormatSQL("idEpg = %u", epg->EpgID()); + strWhereClause = FormatSQL("idEpg = %u", epg.EpgID()); CStdString strQuery; strQuery.Format("SELECT * FROM epgtags WHERE %s ORDER BY iStartTime ASC;", strWhereClause.c_str()); @@ -261,12 +261,12 @@ int CEpgDatabase::Get(CEpg *epg) newTag.m_iParentalRating = m_pDS->fv("iParentalRating").get_asInt(); newTag.m_iStarRating = m_pDS->fv("iStarRating").get_asInt(); newTag.m_bNotify = m_pDS->fv("bNotify").get_asBool(); - newTag.m_iEpisodeNumber = m_pDS->fv("iEpisodeId").get_asInt(); + newTag.m_iEpisodeNumber = m_pDS->fv("iEpisodeId").get_asInt(); newTag.m_iEpisodePart = m_pDS->fv("iEpisodePart").get_asInt(); newTag.m_strEpisodeName = m_pDS->fv("sEpisodeName").get_asString().c_str(); - newTag.m_iSeriesNumber = m_pDS->fv("iSeriesId").get_asInt(); + newTag.m_iSeriesNumber = m_pDS->fv("iSeriesId").get_asInt(); - epg->AddEntry(newTag); + epg.AddEntry(newTag); ++iReturn; m_pDS->next(); diff --git a/xbmc/epg/EpgDatabase.h b/xbmc/epg/EpgDatabase.h index 6bfaf7f7886a4..e463dfd5f0f7f 100644 --- a/xbmc/epg/EpgDatabase.h +++ b/xbmc/epg/EpgDatabase.h @@ -98,14 +98,14 @@ namespace EPG * @param container The container to fill. * @return The amount of entries that was added. */ - virtual int Get(CEpgContainer *container); + virtual int Get(CEpgContainer &container); /*! * @brief Get all EPG entries for a table. * @param epg The EPG table to get the entries for. * @return The amount of entries that was added. */ - virtual int Get(CEpg *epg); + virtual int Get(CEpg &epg); /*! * @brief Get the last stored EPG scan time. From 2b49584ede7527cc87d46ca74619763dda26a5a4 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Thu, 21 Apr 2011 23:07:29 +0200 Subject: [PATCH 12/47] epg: compiler warnings --- xbmc/epg/Epg.cpp | 4 ++-- xbmc/epg/Epg.h | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/xbmc/epg/Epg.cpp b/xbmc/epg/Epg.cpp index 0c8c6b7048097..068adc52f6845 100644 --- a/xbmc/epg/Epg.cpp +++ b/xbmc/epg/Epg.cpp @@ -42,12 +42,12 @@ struct sortEPGbyDate }; CEpg::CEpg(int iEpgID, const CStdString &strName /* = "" */, const CStdString &strScraperName /* = "" */) : + m_bInhibitSorting(false), m_iEpgID(iEpgID), m_strName(strName), m_strScraperName(strScraperName), m_nowActive(NULL), - m_Channel(NULL), - m_bInhibitSorting(false) + m_Channel(NULL) { m_lastScanTime.SetValid(false); m_firstDate.SetValid(false); diff --git a/xbmc/epg/Epg.h b/xbmc/epg/Epg.h index 74687d9fa1179..548ca86de8d3b 100644 --- a/xbmc/epg/Epg.h +++ b/xbmc/epg/Epg.h @@ -51,19 +51,20 @@ namespace EPG friend class CPVREpg; protected: + bool m_bInhibitSorting; /*!< don't sort the table if this is true */ + int m_iEpgID; /*!< the database ID of this table */ CStdString m_strName; /*!< the name of this table */ CStdString m_strScraperName; /*!< the name of the scraper to use */ - int m_iEpgID; /*!< the database ID of this table */ - CDateTime m_lastScanTime; /*!< the last time the EPG has been updated */ - bool m_bInhibitSorting; /*!< don't sort the table if this is true */ mutable const CEpgInfoTag *m_nowActive; /*!< the tag that is currently active */ - mutable CCriticalSection m_critSection; /*!< critical section for changes in this table */ - - PVR::CPVRChannel * m_Channel; /*!< the channel this EPG belongs to */ + CDateTime m_lastScanTime; /*!< the last time the EPG has been updated */ CDateTime m_firstDate; /*!< start time of the first epg event in this table */ CDateTime m_lastDate; /*!< end time of the last epg event in this table */ + PVR::CPVRChannel * m_Channel; /*!< the channel this EPG belongs to */ + + mutable CCriticalSection m_critSection; /*!< critical section for changes in this table */ + /*! * @brief Update the EPG from a scraper set in the channel tag. * TODO: not implemented yet From 877857e36c6f871f6504a7a5d9ebe614a77f907b Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Thu, 21 Apr 2011 23:56:28 +0200 Subject: [PATCH 13/47] pvr: add missing streaminfo strings in CDVDDemuxPVRClient --- .../DVDDemuxers/DVDDemuxPVRClient.cpp | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxPVRClient.cpp b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxPVRClient.cpp index 5693bd5326120..0ffa9b8d9e5f9 100644 --- a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxPVRClient.cpp +++ b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxPVRClient.cpp @@ -30,6 +30,17 @@ using namespace PVR; void CDemuxStreamVideoPVRClient::GetStreamInfo(std::string& strInfo) { + switch (codec) + { + case CODEC_ID_MPEG2VIDEO: + strInfo = "MPEG2VIDEO"; + break; + case CODEC_ID_H264: + strInfo = "H264"; + break; + default: + break; + } } void CDemuxStreamAudioPVRClient::GetStreamInfo(std::string& strInfo) @@ -39,6 +50,18 @@ void CDemuxStreamAudioPVRClient::GetStreamInfo(std::string& strInfo) case CODEC_ID_AC3: strInfo = "AC3"; break; + case CODEC_ID_EAC3: + strInfo = "EAC3"; + break; + case CODEC_ID_MP2: + strInfo = "MPEG2AUDIO"; + break; + case CODEC_ID_AAC: + strInfo = "AAC"; + break; + case CODEC_ID_DTS: + strInfo = "DTS"; + break; default: break; } From 4890af915aad3a95217136b5fde0c22ada45cfdf Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Fri, 22 Apr 2011 00:03:13 +0200 Subject: [PATCH 14/47] tvheadend: the demux stream doesn't send channel updates --- xbmc/pvrclients/tvheadend/HTSPDemux.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/xbmc/pvrclients/tvheadend/HTSPDemux.cpp b/xbmc/pvrclients/tvheadend/HTSPDemux.cpp index a04a828b8f69f..d03ced54159ea 100644 --- a/xbmc/pvrclients/tvheadend/HTSPDemux.cpp +++ b/xbmc/pvrclients/tvheadend/HTSPDemux.cpp @@ -477,13 +477,6 @@ htsmsg_t* cHTSPDemux::ReadStream() if((method = htsmsg_get_str(msg, "method")) == NULL) return msg; - if (strstr(method, "channelAdd")) - cHTSPSession::ParseChannelUpdate(msg, m_channels); - else if(strstr(method, "channelUpdate")) - cHTSPSession::ParseChannelUpdate(msg, m_channels); - else if(strstr(method, "channelDelete")) - cHTSPSession::ParseChannelRemove(msg, m_channels); - uint32_t subs; if(htsmsg_get_u32(msg, "subscriptionId", &subs) || subs != m_subs) { From 44d74fb45dd80d306cfa9903be2e31ffffaa19ce Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Fri, 22 Apr 2011 00:22:13 +0200 Subject: [PATCH 15/47] tvheadend addon: clean up cHTSPDemux::Read() --- xbmc/pvrclients/tvheadend/HTSPDemux.cpp | 126 +++++++++++------------- xbmc/pvrclients/tvheadend/HTSPDemux.h | 3 +- 2 files changed, 59 insertions(+), 70 deletions(-) diff --git a/xbmc/pvrclients/tvheadend/HTSPDemux.cpp b/xbmc/pvrclients/tvheadend/HTSPDemux.cpp index d03ced54159ea..b989680e266ad 100644 --- a/xbmc/pvrclients/tvheadend/HTSPDemux.cpp +++ b/xbmc/pvrclients/tvheadend/HTSPDemux.cpp @@ -109,12 +109,19 @@ DemuxPacket* cHTSPDemux::Read() { htsmsg_t * msg; const char* method; - while((msg = ReadStream())) + while((msg = m_session.ReadMessage(1000))) { method = htsmsg_get_str(msg, "method"); if(method == NULL) break; + uint32_t subs; + if(htsmsg_get_u32(msg, "subscriptionId", &subs) || subs != m_subs) + { + htsmsg_destroy(msg); + continue; + } + if (strcmp("subscriptionStart", method) == 0) { SubscriptionStart(msg); @@ -133,48 +140,7 @@ DemuxPacket* cHTSPDemux::Read() cHTSPSession::ParseSignalStatus(msg, m_Quality); else if(strcmp("muxpkt" , method) == 0) { - uint32_t index, duration, frametype; - const void* bin; - size_t binlen; - int64_t ts; - char frametypechar[1]; - - htsmsg_get_u32(msg, "frametype", &frametype); - frametypechar[0] = static_cast( frametype ); -// XBMC->Log(LOG_DEBUG, "%s - Frame type %c", __FUNCTION__, frametypechar[0]); - - if(htsmsg_get_u32(msg, "stream" , &index) || - htsmsg_get_bin(msg, "payload", &bin, &binlen)) - break; - - DemuxPacket* pkt = PVR->AllocateDemuxPacket(binlen); - memcpy(pkt->pData, bin, binlen); - - pkt->iSize = binlen; - - if(!htsmsg_get_u32(msg, "duration", &duration)) - pkt->duration = (double)duration * DVD_TIME_BASE / 1000000; - - if(!htsmsg_get_s64(msg, "dts", &ts)) - pkt->dts = (double)ts * DVD_TIME_BASE / 1000000; - else - pkt->dts = DVD_NOPTS_VALUE; - - if(!htsmsg_get_s64(msg, "pts", &ts)) - pkt->pts = (double)ts * DVD_TIME_BASE / 1000000; - else - pkt->pts = DVD_NOPTS_VALUE; - - pkt->iStreamId = -1; - for(unsigned int i = 0; i < m_Streams.iStreamCount; i++) - { - if(m_Streams.stream[i].iPhysicalId == (unsigned int)index) - { - pkt->iStreamId = i; - break; - } - } - + DemuxPacket *pkt = ParseMuxPacket(msg); htsmsg_destroy(msg); return pkt; } @@ -191,6 +157,55 @@ DemuxPacket* cHTSPDemux::Read() return NULL; } +DemuxPacket *cHTSPDemux::ParseMuxPacket(htsmsg_t *msg) +{ + DemuxPacket* pkt = NULL; + uint32_t index, duration, frametype; + const void* bin; + size_t binlen; + int64_t ts; + char frametypechar[1]; + + htsmsg_get_u32(msg, "frametype", &frametype); + frametypechar[0] = static_cast( frametype ); + + if(htsmsg_get_u32(msg, "stream" , &index) || + htsmsg_get_bin(msg, "payload", &bin, &binlen)) + { + return pkt; + } + + pkt = PVR->AllocateDemuxPacket(binlen); + memcpy(pkt->pData, bin, binlen); + + pkt->iSize = binlen; + + if(!htsmsg_get_u32(msg, "duration", &duration)) + pkt->duration = (double)duration * DVD_TIME_BASE / 1000000; + + if(!htsmsg_get_s64(msg, "dts", &ts)) + pkt->dts = (double)ts * DVD_TIME_BASE / 1000000; + else + pkt->dts = DVD_NOPTS_VALUE; + + if(!htsmsg_get_s64(msg, "pts", &ts)) + pkt->pts = (double)ts * DVD_TIME_BASE / 1000000; + else + pkt->pts = DVD_NOPTS_VALUE; + + pkt->iStreamId = -1; + for(unsigned int i = 0; i < m_Streams.iStreamCount; i++) + { + if(m_Streams.stream[i].iPhysicalId == (unsigned int)index) + { + pkt->iStreamId = i; + break; + } + } + + return pkt; +} + bool cHTSPDemux::SwitchChannel(const PVR_CHANNEL &channelinfo) { XBMC->Log(LOG_DEBUG, "%s - changing to channel '%s'", __FUNCTION__, channelinfo.strChannelName); @@ -463,28 +478,3 @@ void cHTSPDemux::SubscriptionStatus(htsmsg_t *m) XBMC->QueueNotification(QUEUE_INFO, status); } } - -htsmsg_t* cHTSPDemux::ReadStream() -{ - htsmsg_t* msg; - - /* after anything has started reading, * - * we can guarantee a new stream */ - - while((msg = m_session.ReadMessage(1000))) - { - const char* method; - if((method = htsmsg_get_str(msg, "method")) == NULL) - return msg; - - uint32_t subs; - if(htsmsg_get_u32(msg, "subscriptionId", &subs) || subs != m_subs) - { - htsmsg_destroy(msg); - continue; - } - - return msg; - } - return NULL; -} diff --git a/xbmc/pvrclients/tvheadend/HTSPDemux.h b/xbmc/pvrclients/tvheadend/HTSPDemux.h index b90ee4d1ea535..e2ba8df998b21 100644 --- a/xbmc/pvrclients/tvheadend/HTSPDemux.h +++ b/xbmc/pvrclients/tvheadend/HTSPDemux.h @@ -43,8 +43,7 @@ class cHTSPDemux void SubscriptionStart (htsmsg_t *m); void SubscriptionStop (htsmsg_t *m); void SubscriptionStatus(htsmsg_t *m); - - htsmsg_t* ReadStream(); + DemuxPacket *ParseMuxPacket(htsmsg_t *m); private: void SetLanguageInfo(const char *strLanguage, char *strDestination); From 856c7dc43040bdded14ac3ed4ad50d017579c91f Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Fri, 22 Apr 2011 00:32:45 +0200 Subject: [PATCH 16/47] pvr: reset caching state after switching channels --- xbmc/cores/dvdplayer/DVDPlayer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/xbmc/cores/dvdplayer/DVDPlayer.cpp b/xbmc/cores/dvdplayer/DVDPlayer.cpp index 33c5c62a9d219..23ec5cecc09d5 100644 --- a/xbmc/cores/dvdplayer/DVDPlayer.cpp +++ b/xbmc/cores/dvdplayer/DVDPlayer.cpp @@ -1003,6 +1003,7 @@ void CDVDPlayer::Process() { FlushBuffers(false); SAFE_DELETE(m_pDemuxer); + SetCaching(CACHESTATE_INIT); continue; } else From 30a02beed5d9bae2e3d5d28f7b7ae340d42c8904 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Fri, 22 Apr 2011 01:04:58 +0200 Subject: [PATCH 17/47] pvr: add an inline method OpenPVRDatabase() that tries to open the db and logs an error when it fails --- xbmc/pvr/PVRDatabase.h | 18 ++++++++++++++++ xbmc/pvr/PVRManager.h | 1 - xbmc/pvr/addons/PVRClients.cpp | 10 ++++----- xbmc/pvr/channels/PVRChannel.cpp | 7 +++---- xbmc/pvr/channels/PVRChannelGroup.cpp | 17 ++++++++------- xbmc/pvr/channels/PVRChannelGroupInternal.cpp | 15 ++++++------- xbmc/pvr/channels/PVRChannelGroups.cpp | 14 ++++--------- .../dialogs/GUIDialogPVRChannelManager.cpp | 21 +++++++++++-------- 8 files changed, 56 insertions(+), 47 deletions(-) diff --git a/xbmc/pvr/PVRDatabase.h b/xbmc/pvr/PVRDatabase.h index e27c13aef1f20..0147c053cbb46 100644 --- a/xbmc/pvr/PVRDatabase.h +++ b/xbmc/pvr/PVRDatabase.h @@ -20,8 +20,10 @@ * */ +#include "PVRManager.h" #include "dbwrappers/Database.h" #include "XBDateTime.h" +#include "utils/log.h" class CVideoSettings; @@ -226,4 +228,20 @@ namespace PVR */ virtual bool UpdateOldVersion(int version); }; + + /*! + * @brief Try to open the PVR database. + * @return The opened database or NULL if the database failed to open. + */ + inline CPVRDatabase *OpenPVRDatabase(void) + { + CPVRDatabase *database = g_PVRManager.GetTVDatabase(); + if (!database || !database->Open()) + { + CLog::Log(LOGERROR, "PVR - failed to open the database"); + database = NULL; + } + + return database; + } } diff --git a/xbmc/pvr/PVRManager.h b/xbmc/pvr/PVRManager.h index 110becc03a525..967fb1baf4a16 100644 --- a/xbmc/pvr/PVRManager.h +++ b/xbmc/pvr/PVRManager.h @@ -39,7 +39,6 @@ namespace PVR class CPVRGUIInfo; class CPVRDatabase; - #define g_PVRManager CPVRManager::Get() #define g_PVRChannelGroups g_PVRManager.ChannelGroups() #define g_PVREpg g_PVRManager.EPG() diff --git a/xbmc/pvr/addons/PVRClients.cpp b/xbmc/pvr/addons/PVRClients.cpp index c718130b5f33c..e7194841e5d9c 100644 --- a/xbmc/pvr/addons/PVRClients.cpp +++ b/xbmc/pvr/addons/PVRClients.cpp @@ -254,7 +254,8 @@ bool CPVRClients::ClientLoaded(const CStdString &strClientId) int CPVRClients::AddClientToDb(const CStdString &strClientId, const CStdString &strName) { /* add this client to the database if it's not in there yet */ - int iClientDbId = g_PVRManager.GetTVDatabase()->AddClient(strName, strClientId); + CPVRDatabase *database = OpenPVRDatabase(); + int iClientDbId = database ? database->AddClient(strName, strClientId) : -1; if (iClientDbId == -1) { CLog::Log(LOGERROR, "PVR - %s - can't add client '%s' to the database", @@ -278,12 +279,9 @@ bool CPVRClients::LoadClients(void) return false; /* load and initialise the clients */ - CPVRDatabase *database = g_PVRManager.GetTVDatabase(); - if (!database || !database->Open()) - { - CLog::Log(LOGERROR, "PVR - %s - cannot open the database", __FUNCTION__); + CPVRDatabase *database = OpenPVRDatabase(); + if (!database) return false; - } m_bAllClientsLoaded = true; for (unsigned iClientPtr = 0; iClientPtr < addons.size(); iClientPtr++) diff --git a/xbmc/pvr/channels/PVRChannel.cpp b/xbmc/pvr/channels/PVRChannel.cpp index c712d607ad0f0..66375bac214a2 100644 --- a/xbmc/pvr/channels/PVRChannel.cpp +++ b/xbmc/pvr/channels/PVRChannel.cpp @@ -200,8 +200,8 @@ bool CPVRChannel::CacheIcon(void) bool CPVRChannel::Delete(void) { bool bReturn = false; - CPVRDatabase *database = g_PVRManager.GetTVDatabase(); - if (!database || !database->Open()) + CPVRDatabase *database = OpenPVRDatabase(); + if (!database) return bReturn; CSingleLock lock(m_critSection); @@ -244,8 +244,7 @@ bool CPVRChannel::Persist(bool bQueueWrite /* = false */) if (!m_bChanged) return true; - CPVRDatabase *database = g_PVRManager.GetTVDatabase(); - if (database) + if (CPVRDatabase *database = OpenPVRDatabase()) { if (!bQueueWrite) { diff --git a/xbmc/pvr/channels/PVRChannelGroup.cpp b/xbmc/pvr/channels/PVRChannelGroup.cpp index cea94318aec97..8656abbd983cc 100644 --- a/xbmc/pvr/channels/PVRChannelGroup.cpp +++ b/xbmc/pvr/channels/PVRChannelGroup.cpp @@ -182,8 +182,10 @@ void CPVRChannelGroup::SearchAndSetChannelIcons(bool bUpdateDb /* = false */) if (g_guiSettings.GetString("pvrmenu.iconpath") == "") return; - CPVRDatabase *database = g_PVRManager.GetTVDatabase(); - database->Open(); + CPVRDatabase *database = OpenPVRDatabase(); + if (!database) + return; + CSingleLock lock(m_critSection); for (unsigned int ptr = 0; ptr < size(); ptr++) @@ -428,8 +430,8 @@ int CPVRChannelGroup::GetMembers(CFileItemList *results, bool bGroupMembers /* = int CPVRChannelGroup::LoadFromDb(bool bCompress /* = false */) { - CPVRDatabase *database = g_PVRManager.GetTVDatabase(); - if (!database || !database->Open()) + CPVRDatabase *database = OpenPVRDatabase(); + if (!database) return -1; int iChannelCount = size(); @@ -475,8 +477,8 @@ bool CPVRChannelGroup::UpdateGroupEntries(const CPVRChannelGroup &channels) CSingleLock lock(m_critSection); int iCurSize = size(); - CPVRDatabase *database = g_PVRManager.GetTVDatabase(); - if (!database || !database->Open()) + CPVRDatabase *database = OpenPVRDatabase(); + if (!database) return false; /* go through the channel list and check for updated or new channels */ @@ -692,8 +694,7 @@ bool CPVRChannelGroup::Persist(void) if (!HasChanges()) return true; - CPVRDatabase *database = g_PVRManager.GetTVDatabase(); - if (database && database->Open()) + if (CPVRDatabase *database = OpenPVRDatabase()) { CLog::Log(LOGDEBUG, "CPVRChannelGroup - %s - persisting channel group '%s' with %d channels", __FUNCTION__, GroupName().c_str(), (int) size()); diff --git a/xbmc/pvr/channels/PVRChannelGroupInternal.cpp b/xbmc/pvr/channels/PVRChannelGroupInternal.cpp index 2394c0573b639..b66e31da353f3 100644 --- a/xbmc/pvr/channels/PVRChannelGroupInternal.cpp +++ b/xbmc/pvr/channels/PVRChannelGroupInternal.cpp @@ -216,8 +216,8 @@ int CPVRChannelGroupInternal::GetMembers(CFileItemList *results, bool bGroupMemb int CPVRChannelGroupInternal::LoadFromDb(bool bCompress /* = false */) { - CPVRDatabase *database = g_PVRManager.GetTVDatabase(); - if (!database || !database->Open()) + CPVRDatabase *database = OpenPVRDatabase(); + if (!database) return -1; int iChannelCount = size(); @@ -301,8 +301,8 @@ bool CPVRChannelGroupInternal::UpdateGroupEntries(const CPVRChannelGroup &channe CPVRChannelGroup *newChannels = new CPVRChannelGroup(m_bRadio); - CPVRDatabase *database = g_PVRManager.GetTVDatabase(); - if (!database || !database->Open()) + CPVRDatabase *database = OpenPVRDatabase(); + if (!database) return bChanged; /* go through the channel list and check for updated or new channels */ @@ -425,12 +425,9 @@ bool CPVRChannelGroupInternal::Persist(void) else if (bHasChangedChannels) { /* open the database */ - CPVRDatabase *database = g_PVRManager.GetTVDatabase(); - if (!database || !database->Open()) - { - CLog::Log(LOGERROR, "CPVRChannelGroupInternal - %s - failed to open the database", __FUNCTION__); + CPVRDatabase *database = OpenPVRDatabase(); + if (!database) return false; - } /* queue queries */ for (unsigned int iChannelPtr = 0; iChannelPtr < size(); iChannelPtr++) diff --git a/xbmc/pvr/channels/PVRChannelGroups.cpp b/xbmc/pvr/channels/PVRChannelGroups.cpp index 2c208f2ea25a6..3cb878cfdd04a 100644 --- a/xbmc/pvr/channels/PVRChannelGroups.cpp +++ b/xbmc/pvr/channels/PVRChannelGroups.cpp @@ -233,12 +233,9 @@ bool CPVRChannelGroups::UpdateGroupsEntries(const CPVRChannelGroups &groups) bool CPVRChannelGroups::LoadUserDefinedChannelGroups(void) { - CPVRDatabase *database = g_PVRManager.GetTVDatabase(); - if (!database->Open()) - { - CLog::Log(LOGERROR, "PVRChannelGroups - %s - cannot open the database", __FUNCTION__); + CPVRDatabase *database = OpenPVRDatabase(); + if (!database) return false; - } /* load the other groups from the database */ database->Get(*this); @@ -408,12 +405,9 @@ bool CPVRChannelGroups::DeleteGroup(const CPVRChannelGroup &group) return bReturn; } - CPVRDatabase *database = g_PVRManager.GetTVDatabase(); - if (!database || !database->Open()) - { - CLog::Log(LOGERROR, "CPVRChannelGroups - %s - unable to open the database", __FUNCTION__); + CPVRDatabase *database = OpenPVRDatabase(); + if (!database) return bReturn; - } /* remove all channels from the group */ database->RemoveChannelsFromGroup(group); diff --git a/xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp b/xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp index 3ab8ebfa04b0f..a16c9cc0697ca 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp +++ b/xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp @@ -453,10 +453,11 @@ bool CGUIDialogPVRChannelManager::OnMessage(CGUIMessage& message) { if (pItem->GetPropertyBOOL("Virtual")) { - CPVRDatabase *database = g_PVRManager.GetTVDatabase(); - database->Open(); - database->Delete(*pItem->GetPVRChannelInfoTag()); - database->Close(); + if (CPVRDatabase *database = OpenPVRDatabase()) + { + database->Delete(*pItem->GetPVRChannelInfoTag()); + database->Close(); + } m_channelItems->Remove(m_iSelected); m_viewControl.SetItems(*m_channelItems); @@ -509,12 +510,14 @@ bool CGUIDialogPVRChannelManager::OnMessage(CGUIMessage& message) newchannel.SetStreamURL(strURL); newchannel.SetClientID(XBMC_VIRTUAL_CLIENTID); - CPVRDatabase *database = g_PVRManager.GetTVDatabase(); - database->Open(); + CPVRDatabase *database = OpenPVRDatabase(); + if (!database) + return false; + database->Persist(newchannel); database->Close(); - CFileItemPtr channel(new CFileItem(newchannel)); + CFileItemPtr channel(new CFileItem(newchannel)); if (channel) { channel->SetProperty("ActiveChannel", true); @@ -716,8 +719,8 @@ void CGUIDialogPVRChannelManager::SaveList() // XXX investigate: renumbering doe if (!m_bContainsChanges) return; - CPVRDatabase *database = g_PVRManager.GetTVDatabase(); - if (!database || !database->Open()) + CPVRDatabase *database = OpenPVRDatabase(); + if (!database) return; CGUIDialogProgress* pDlgProgress = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS); From f7f7f5daa56f5993813c0f08b5378aeb20bb8a0b Mon Sep 17 00:00:00 2001 From: Dimitris Kazakos Date: Fri, 22 Apr 2011 01:55:39 +0300 Subject: [PATCH 18/47] pvr: fix for all bugs related to recording updates --- lib/addons/library.xbmc.pvr/libXBMC_pvr.cpp | 2 +- xbmc/pvr/addons/PVRClients.cpp | 6 ++++-- xbmc/pvr/recordings/PVRRecording.cpp | 2 -- xbmc/pvr/recordings/PVRRecordings.cpp | 2 +- xbmc/pvrclients/tvheadend/HTSPSession.cpp | 4 ++++ 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/addons/library.xbmc.pvr/libXBMC_pvr.cpp b/lib/addons/library.xbmc.pvr/libXBMC_pvr.cpp index 150f6ebde05b2..585abde219c6a 100644 --- a/lib/addons/library.xbmc.pvr/libXBMC_pvr.cpp +++ b/lib/addons/library.xbmc.pvr/libXBMC_pvr.cpp @@ -143,7 +143,7 @@ DLLEXPORT void PVR_trigger_recording_update() if (m_cb == NULL) return; - m_cb->TriggerTimerUpdate(m_Handle->addonData); + m_cb->TriggerRecordingUpdate(m_Handle->addonData); } DLLEXPORT void PVR_free_demux_packet(DemuxPacket* pPacket) diff --git a/xbmc/pvr/addons/PVRClients.cpp b/xbmc/pvr/addons/PVRClients.cpp index c718130b5f33c..6516a27418baf 100644 --- a/xbmc/pvr/addons/PVRClients.cpp +++ b/xbmc/pvr/addons/PVRClients.cpp @@ -689,8 +689,9 @@ int CPVRClients::GetTimers(CPVRTimers *timers) { int iCurSize = timers->size(); CLIENTMAP clients; - GetActiveClients(&clients); + CSingleLock lock(m_critSection); + GetActiveClients(&clients); /* get the timer list from each client */ CLIENTMAPITR itrClients = clients.begin(); while (itrClients != clients.end()) @@ -713,8 +714,9 @@ int CPVRClients::GetRecordings(CPVRRecordings *recordings) { int iCurSize = recordings->size(); CLIENTMAP clients; - GetActiveClients(&clients); + CSingleLock lock(m_critSection); + GetActiveClients(&clients); CLIENTMAPITR itr = clients.begin(); while (itr != clients.end()) { diff --git a/xbmc/pvr/recordings/PVRRecording.cpp b/xbmc/pvr/recordings/PVRRecording.cpp index 79314218971fa..93d935e34d622 100644 --- a/xbmc/pvr/recordings/PVRRecording.cpp +++ b/xbmc/pvr/recordings/PVRRecording.cpp @@ -106,7 +106,6 @@ bool CPVRRecording::Delete(void) return false; } - g_PVRManager.TriggerRecordingsUpdate(); return true; } @@ -120,7 +119,6 @@ bool CPVRRecording::Rename(const CStdString &strNewName) return false; } - g_PVRManager.TriggerRecordingsUpdate(); return true; } diff --git a/xbmc/pvr/recordings/PVRRecordings.cpp b/xbmc/pvr/recordings/PVRRecordings.cpp index 1bea42a2b4a0b..788ab38286844 100644 --- a/xbmc/pvr/recordings/PVRRecordings.cpp +++ b/xbmc/pvr/recordings/PVRRecordings.cpp @@ -186,7 +186,7 @@ void CPVRRecordings::Update(bool bAsyncUpdate /* = false */) void CPVRRecordings::ExecuteUpdate(void) { - CLog::Log(LOGDEBUG, "CPVRTimers - %s - updating recordings", __FUNCTION__); + CLog::Log(LOGDEBUG, "CPVRRecordings - %s - updating recordings", __FUNCTION__); UpdateFromClients(); CSingleLock lock(m_critSection); diff --git a/xbmc/pvrclients/tvheadend/HTSPSession.cpp b/xbmc/pvrclients/tvheadend/HTSPSession.cpp index aeb6cb42c920b..7d724a3d75c7c 100644 --- a/xbmc/pvrclients/tvheadend/HTSPSession.cpp +++ b/xbmc/pvrclients/tvheadend/HTSPSession.cpp @@ -738,6 +738,9 @@ void cHTSPSession::ParseDVREntryUpdate(htsmsg_t* msg, SRecordings &recordings, b recordings[recording.id] = recording; PVR->TriggerTimerUpdate(); + + if (recording.state == ST_RECORDING) + PVR->TriggerRecordingUpdate(); } void cHTSPSession::ParseDVREntryDelete(htsmsg_t* msg, SRecordings &recordings, bool bNotify /* = false */) @@ -759,4 +762,5 @@ void cHTSPSession::ParseDVREntryDelete(htsmsg_t* msg, SRecordings &recordings, b recordings.erase(id); PVR->TriggerTimerUpdate(); + PVR->TriggerRecordingUpdate(); } From 7135e37198e0a406969eb03c7bc1b458ee788053 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Fri, 22 Apr 2011 09:12:05 +0200 Subject: [PATCH 19/47] pvr: sync vs2010 project files --- project/VS2010Express/XBMC.vcxproj | 4 ++-- project/VS2010Express/XBMC.vcxproj.filters | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/project/VS2010Express/XBMC.vcxproj b/project/VS2010Express/XBMC.vcxproj index e6576698a0e1a..29bd17e269ca8 100644 --- a/project/VS2010Express/XBMC.vcxproj +++ b/project/VS2010Express/XBMC.vcxproj @@ -347,6 +347,7 @@ + @@ -382,7 +383,6 @@ - @@ -1279,6 +1279,7 @@ + @@ -1331,7 +1332,6 @@ - diff --git a/project/VS2010Express/XBMC.vcxproj.filters b/project/VS2010Express/XBMC.vcxproj.filters index 5d0e00168ec63..2b98b3e7685df 100644 --- a/project/VS2010Express/XBMC.vcxproj.filters +++ b/project/VS2010Express/XBMC.vcxproj.filters @@ -2477,9 +2477,6 @@ utils - - guilib - utils @@ -2643,6 +2640,9 @@ filesystem + + epg + @@ -5095,9 +5095,6 @@ utils - - guilib - utils @@ -5256,6 +5253,9 @@ interfaces\json-rpc + + epg + @@ -5272,4 +5272,4 @@ win32 - + \ No newline at end of file From 7b04a3d43cdb1a79a4a6b1e77b8d406b3f61f9c5 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Fri, 22 Apr 2011 11:24:50 +0200 Subject: [PATCH 20/47] pvr: fix win32 build because vs2010 isn't as smart as gcc --- xbmc/pvr/epg/PVREpg.cpp | 20 ++++++++++---------- xbmc/pvr/epg/PVREpgContainer.cpp | 22 +++++++++++----------- xbmc/pvr/epg/PVREpgInfoTag.cpp | 14 +++++++------- xbmc/pvr/epg/PVREpgSearchFilter.cpp | 4 ++-- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/xbmc/pvr/epg/PVREpg.cpp b/xbmc/pvr/epg/PVREpg.cpp index bbe08122a80ef..6899512aeef51 100644 --- a/xbmc/pvr/epg/PVREpg.cpp +++ b/xbmc/pvr/epg/PVREpg.cpp @@ -35,20 +35,20 @@ using namespace PVR; using namespace EPG; -CPVREpg::CPVREpg(CPVRChannel *channel) : +PVR::CPVREpg::CPVREpg(CPVRChannel *channel) : CEpg(channel->ChannelID(), channel->ChannelName(), channel->EPGScraper()) { SetChannel(channel); } -bool CPVREpg::HasValidEntries(void) const +bool PVR::CPVREpg::HasValidEntries(void) const { CSingleLock lock(m_critSection); return m_Channel != NULL && m_Channel->ChannelID() > 0 && CEpg::HasValidEntries(); } -void CPVREpg::Cleanup(const CDateTime &Time) +void PVR::CPVREpg::Cleanup(const CDateTime &Time) { CSingleLock lock(m_critSection); @@ -69,7 +69,7 @@ void CPVREpg::Cleanup(const CDateTime &Time) } } -void CPVREpg::Clear(void) +void PVR::CPVREpg::Clear(void) { CSingleLock lock(m_critSection); @@ -79,7 +79,7 @@ void CPVREpg::Clear(void) CEpg::Clear(); } -bool CPVREpg::UpdateEntry(const EPG_TAG *data, bool bUpdateDatabase /* = false */) +bool PVR::CPVREpg::UpdateEntry(const EPG_TAG *data, bool bUpdateDatabase /* = false */) { if (!data) return false; @@ -88,7 +88,7 @@ bool CPVREpg::UpdateEntry(const EPG_TAG *data, bool bUpdateDatabase /* = false * return CEpg::UpdateEntry(tag, bUpdateDatabase); } -bool CPVREpg::UpdateFromScraper(time_t start, time_t end) +bool PVR::CPVREpg::UpdateFromScraper(time_t start, time_t end) { bool bGrabSuccess = false; @@ -116,12 +116,12 @@ bool CPVREpg::UpdateFromScraper(time_t start, time_t end) return bGrabSuccess; } -bool CPVREpg::IsRadio(void) const +bool PVR::CPVREpg::IsRadio(void) const { return m_Channel->IsRadio(); } -bool CPVREpg::Update(const CEpg &epg, bool bUpdateDb /* = false */) +bool PVR::CPVREpg::Update(const CEpg &epg, bool bUpdateDb /* = false */) { bool bReturn = CEpg::Update(epg, false); // don't update the db yet @@ -133,7 +133,7 @@ bool CPVREpg::Update(const CEpg &epg, bool bUpdateDb /* = false */) return bReturn; } -CEpgInfoTag *CPVREpg::CreateTag(void) +CEpgInfoTag *PVR::CPVREpg::CreateTag(void) { CEpgInfoTag *newTag = new CPVREpgInfoTag(); if (!newTag) @@ -145,7 +145,7 @@ CEpgInfoTag *CPVREpg::CreateTag(void) return newTag; } -bool CPVREpg::LoadFromClients(time_t start, time_t end) +bool PVR::CPVREpg::LoadFromClients(time_t start, time_t end) { bool bReturn(false); CPVREpg tmpEpg(m_Channel); diff --git a/xbmc/pvr/epg/PVREpgContainer.cpp b/xbmc/pvr/epg/PVREpgContainer.cpp index 69c6eaccfbefa..e21c27d40926c 100644 --- a/xbmc/pvr/epg/PVREpgContainer.cpp +++ b/xbmc/pvr/epg/PVREpgContainer.cpp @@ -33,7 +33,7 @@ using namespace std; using namespace PVR; using namespace EPG; -void CPVREpgContainer::Clear(bool bClearDb /* = false */) +void PVR::CPVREpgContainer::Clear(bool bClearDb /* = false */) { CSingleLock lock(m_critSection); // XXX stop the timers from being updated while clearing tags @@ -45,7 +45,7 @@ void CPVREpgContainer::Clear(bool bClearDb /* = false */) CEpgContainer::Clear(bClearDb); } -bool CPVREpgContainer::CreateChannelEpgs(void) +bool PVR::CPVREpgContainer::CreateChannelEpgs(void) { for (int radio = 0; radio <= 1; radio++) { @@ -67,7 +67,7 @@ bool CPVREpgContainer::CreateChannelEpgs(void) return true; } -int CPVREpgContainer::GetEPGAll(CFileItemList* results, bool bRadio /* = false */) +int PVR::CPVREpgContainer::GetEPGAll(CFileItemList* results, bool bRadio /* = false */) { int iInitialSize = results->Size(); const CPVRChannelGroup *group = g_PVRChannelGroups->GetGroupAll(bRadio); @@ -87,12 +87,12 @@ int CPVREpgContainer::GetEPGAll(CFileItemList* results, bool bRadio /* = false * return results->Size() - iInitialSize; } -bool CPVREpgContainer::AutoCreateTablesHook(void) +bool PVR::CPVREpgContainer::AutoCreateTablesHook(void) { return CreateChannelEpgs(); } -CEpg* CPVREpgContainer::CreateEpg(int iEpgId) +CEpg* PVR::CPVREpgContainer::CreateEpg(int iEpgId) { CPVRChannel *channel = (CPVRChannel *) g_PVRChannelGroups->GetChannelById(iEpgId); if (channel) @@ -107,19 +107,19 @@ CEpg* CPVREpgContainer::CreateEpg(int iEpgId) } } -const CDateTime CPVREpgContainer::GetFirstEPGDate(bool bRadio /* = false */) +const CDateTime PVR::CPVREpgContainer::GetFirstEPGDate(bool bRadio /* = false */) { // TODO should use two separate containers, one for radio, one for tv return CEpgContainer::GetFirstEPGDate(); } -const CDateTime CPVREpgContainer::GetLastEPGDate(bool bRadio /* = false */) +const CDateTime PVR::CPVREpgContainer::GetLastEPGDate(bool bRadio /* = false */) { // TODO should use two separate containers, one for radio, one for tv return CEpgContainer::GetLastEPGDate(); } -int CPVREpgContainer::GetEPGSearch(CFileItemList* results, const PVREpgSearchFilter &filter) +int PVR::CPVREpgContainer::GetEPGSearch(CFileItemList* results, const PVREpgSearchFilter &filter) { CEpgContainer::GetEPGSearch(results, filter); @@ -173,7 +173,7 @@ int CPVREpgContainer::GetEPGSearch(CFileItemList* results, const PVREpgSearchFil return results->Size(); } -int CPVREpgContainer::GetEPGNow(CFileItemList* results, bool bRadio) +int PVR::CPVREpgContainer::GetEPGNow(CFileItemList* results, bool bRadio) { CPVRChannelGroup *channels = g_PVRChannelGroups->GetGroupAll(bRadio); CSingleLock lock(m_critSection); @@ -200,7 +200,7 @@ int CPVREpgContainer::GetEPGNow(CFileItemList* results, bool bRadio) return results->Size() - iInitialSize; } -int CPVREpgContainer::GetEPGNext(CFileItemList* results, bool bRadio) +int PVR::CPVREpgContainer::GetEPGNext(CFileItemList* results, bool bRadio) { CPVRChannelGroup *channels = g_PVRChannelGroups->GetGroupAll(bRadio); CSingleLock lock(m_critSection); @@ -227,7 +227,7 @@ int CPVREpgContainer::GetEPGNext(CFileItemList* results, bool bRadio) return results->Size() - iInitialSize; } -bool CPVREpgContainer::UpdateEPG(bool bShowProgress /* = false */) +bool PVR::CPVREpgContainer::UpdateEPG(bool bShowProgress /* = false */) { bool bReturn = CEpgContainer::UpdateEPG(bShowProgress); diff --git a/xbmc/pvr/epg/PVREpgInfoTag.cpp b/xbmc/pvr/epg/PVREpgInfoTag.cpp index 3c0a1c290b03b..3d3241c77d3e0 100644 --- a/xbmc/pvr/epg/PVREpgInfoTag.cpp +++ b/xbmc/pvr/epg/PVREpgInfoTag.cpp @@ -32,14 +32,14 @@ using namespace std; using namespace PVR; using namespace EPG; -CPVREpgInfoTag::CPVREpgInfoTag(void) : +PVR::CPVREpgInfoTag::CPVREpgInfoTag(void) : CEpgInfoTag(), m_Timer(NULL), m_isRecording(false) { } -CPVREpgInfoTag::CPVREpgInfoTag(const EPG_TAG &data) : +PVR::CPVREpgInfoTag::CPVREpgInfoTag(const EPG_TAG &data) : CEpgInfoTag(), m_Timer(NULL), m_isRecording(false) @@ -47,13 +47,13 @@ CPVREpgInfoTag::CPVREpgInfoTag(const EPG_TAG &data) : Update(data); } -const CPVRChannel *CPVREpgInfoTag::ChannelTag(void) const +const CPVRChannel *PVR::CPVREpgInfoTag::ChannelTag(void) const { const CPVREpg *table = (const CPVREpg *) GetTable(); return table ? table->Channel() : NULL; } -void CPVREpgInfoTag::SetTimer(const CPVRTimerInfoTag *newTimer) +void PVR::CPVREpgInfoTag::SetTimer(const CPVRTimerInfoTag *newTimer) { if (!newTimer) m_Timer = NULL; @@ -61,7 +61,7 @@ void CPVREpgInfoTag::SetTimer(const CPVRTimerInfoTag *newTimer) m_Timer = newTimer; } -void CPVREpgInfoTag::UpdatePath(void) +void PVR::CPVREpgInfoTag::UpdatePath(void) { if (!m_Epg) return; @@ -71,7 +71,7 @@ void CPVREpgInfoTag::UpdatePath(void) SetPath(path); } -void CPVREpgInfoTag::Update(const EPG_TAG &tag) +void PVR::CPVREpgInfoTag::Update(const EPG_TAG &tag) { SetStartFromUTC(tag.startTime + g_advancedSettings.m_iPVRTimeCorrection); SetEndFromUTC(tag.endTime + g_advancedSettings.m_iPVRTimeCorrection); @@ -90,7 +90,7 @@ void CPVREpgInfoTag::Update(const EPG_TAG &tag) SetIcon(tag.strIconPath); } -const CStdString &CPVREpgInfoTag::Icon(void) const +const CStdString &PVR::CPVREpgInfoTag::Icon(void) const { if (m_strIconPath.IsEmpty() && m_Epg) { diff --git a/xbmc/pvr/epg/PVREpgSearchFilter.cpp b/xbmc/pvr/epg/PVREpgSearchFilter.cpp index 277343e3c0e3a..7aa605d280206 100644 --- a/xbmc/pvr/epg/PVREpgSearchFilter.cpp +++ b/xbmc/pvr/epg/PVREpgSearchFilter.cpp @@ -31,7 +31,7 @@ using namespace std; using namespace PVR; using namespace EPG; -void PVREpgSearchFilter::Reset() +void PVR::PVREpgSearchFilter::Reset() { EpgSearchFilter::Reset(); m_iChannelNumber = -1; @@ -41,7 +41,7 @@ void PVREpgSearchFilter::Reset() m_bIgnorePresentRecordings = true; } -bool PVREpgSearchFilter::FilterEntry(const CPVREpgInfoTag &tag) const +bool PVR::PVREpgSearchFilter::FilterEntry(const CPVREpgInfoTag &tag) const { bool bReturn = EpgSearchFilter::FilterEntry(tag); From ed66cd89664a365ea07f40d32c695486ac78a8c9 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Fri, 22 Apr 2011 14:04:06 +0200 Subject: [PATCH 21/47] pvr: optionally close the channels OSD after switching channels --- language/Dutch/strings.xml | 1 + language/English/strings.xml | 1 + xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.cpp | 22 ++++++++++++++++---- xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.h | 1 + xbmc/settings/GUISettings.cpp | 1 + 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/language/Dutch/strings.xml b/language/Dutch/strings.xml index 461cbb49316c2..b71c83c631f38 100644 --- a/language/Dutch/strings.xml +++ b/language/Dutch/strings.xml @@ -1627,6 +1627,7 @@ Opname gestart Opname voltooid Opname verwijderd + Sluit kanelen OSD na wijzigen kanaal Anders/Onbekend Film/Drama diff --git a/language/English/strings.xml b/language/English/strings.xml index 1cd7a3f6afb04..157a071ea0db2 100644 --- a/language/English/strings.xml +++ b/language/English/strings.xml @@ -1755,6 +1755,7 @@ Recording started Recording completed Recording deleted + Close channel OSD after switching channels Other/Unknown Movie/Drama diff --git a/xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.cpp b/xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.cpp index 724448ee0e7c0..b017b06a08fd4 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.cpp +++ b/xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.cpp @@ -26,6 +26,7 @@ #include "dialogs/GUIDialogOK.h" #include "GUIDialogPVRGuideInfo.h" #include "ViewState.h" +#include "settings/GUISettings.h" #include "pvr/PVRManager.h" #include "pvr/channels/PVRChannelGroupsContainer.h" @@ -124,16 +125,29 @@ void CGUIDialogPVRChannelsOSD::Clear() m_vecItems->Clear(); } +void CGUIDialogPVRChannelsOSD::CloseOrSelect(void) +{ + if (g_guiSettings.GetBool("pvrmenu.closechannelosdonswitch")) + { + Close(); + } + else + { + CPVRChannel channel; + g_PVRManager.GetCurrentChannel(&channel); + m_viewControl.SetSelectedItem(channel.ChannelNumber() - 1); + } +} + void CGUIDialogPVRChannelsOSD::GotoChannel(int item) { /* Check file item is in list range and get his pointer */ if (item < 0 || item >= (int)m_vecItems->Size()) return; - CFileItemPtr pItem = m_vecItems->Get(item); if (pItem->m_strPath == g_application.CurrentFile()) { - Close(); + CloseOrSelect(); return; } @@ -142,8 +156,8 @@ void CGUIDialogPVRChannelsOSD::GotoChannel(int item) CGUIDialogOK::ShowAndGetInput(19033,0,19136,0); return; } - m_viewControl.SetItems(*m_vecItems); - m_viewControl.SetSelectedItem(item); + + CloseOrSelect(); } void CGUIDialogPVRChannelsOSD::ShowInfo(int item) diff --git a/xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.h b/xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.h index d8be5b282524f..745d535375361 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.h +++ b/xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.h @@ -37,6 +37,7 @@ namespace PVR virtual void OnWindowUnload(); protected: + void CloseOrSelect(void); void GotoChannel(int iItem); void ShowInfo(int item); void Clear(); diff --git a/xbmc/settings/GUISettings.cpp b/xbmc/settings/GUISettings.cpp index 9c0139d0c2cca..113b89a36649a 100644 --- a/xbmc/settings/GUISettings.cpp +++ b/xbmc/settings/GUISettings.cpp @@ -810,6 +810,7 @@ void CGUISettings::Initialize() AddString(pvrm, "pvrmenu.searchicons", 19167, "", BUTTON_CONTROL_STANDARD); AddSeparator(pvrm, "pvrmenu.sep2"); AddInt(pvrm, "pvrmenu.defaultguideview", 19065, GUIDE_VIEW_NOW, GUIDE_VIEW_CHANNEL, 1, GUIDE_VIEW_TIMELINE, SPIN_CONTROL_TEXT); + AddBool(pvrm, "pvrmenu.closechannelosdonswitch", 19229, false); CSettingsCategory* pvre = AddCategory(8, "epg", 19069); AddInt(pvre, "epg.daystodisplay", 19182, 2, 1, 1, 14, SPIN_CONTROL_INT_PLUS, MASK_DAYS); From ff049d7152bd24ad3f01af13e3bbd43e641ee37a Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Fri, 22 Apr 2011 16:27:35 +0200 Subject: [PATCH 22/47] pvr/epg: add a new advanced setting pvr/showepginfoonselect, defaulting to 'true'. when true, the epg info dialog will pop up when selecting an epg item. when set to false, playback will start on the selected channel --- xbmc/pvr/windows/GUIWindowPVRGuide.cpp | 26 ++++++++++++++++++++------ xbmc/pvr/windows/GUIWindowPVRGuide.h | 1 + xbmc/settings/AdvancedSettings.cpp | 2 ++ xbmc/settings/AdvancedSettings.h | 1 + 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/xbmc/pvr/windows/GUIWindowPVRGuide.cpp b/xbmc/pvr/windows/GUIWindowPVRGuide.cpp index 88b5b6e35bcd8..4fbb878df9738 100644 --- a/xbmc/pvr/windows/GUIWindowPVRGuide.cpp +++ b/xbmc/pvr/windows/GUIWindowPVRGuide.cpp @@ -317,7 +317,14 @@ bool CGUIWindowPVRGuide::OnClickList(CGUIMessage &message) /* process actions */ bReturn = true; - if ((iAction == ACTION_SELECT_ITEM) || (iAction == ACTION_SHOW_INFO || iAction == ACTION_MOUSE_LEFT_CLICK)) + if (iAction == ACTION_SELECT_ITEM || iAction == ACTION_MOUSE_LEFT_CLICK) + { + if (g_advancedSettings.m_bPVRShowEpgInfoOnEpgItemSelect) + ShowEPGInfo(pItem.get()); + else + PlayEpgItem(pItem.get()); + } + else if (iAction == ACTION_SHOW_INFO) ShowEPGInfo(pItem.get()); else if (iAction == ACTION_RECORD) ActionRecord(pItem.get()); @@ -375,17 +382,24 @@ bool CGUIWindowPVRGuide::OnContextButtonInfo(CFileItem *item, CONTEXT_BUTTON but return bReturn; } +bool CGUIWindowPVRGuide::PlayEpgItem(CFileItem *item) +{ + const CPVRChannel *channel = ((CPVREpgInfoTag *)item->GetEPGInfoTag())->ChannelTag(); + CLog::Log(LOG_DEBUG, "play channel '%s'", channel->ChannelName().c_str()); + bool bReturn = g_application.PlayFile(CFileItem(*channel)); + if (!bReturn) + CGUIDialogOK::ShowAndGetInput(19033,0,19035,0); + + return bReturn; +} + bool CGUIWindowPVRGuide::OnContextButtonPlay(CFileItem *item, CONTEXT_BUTTON button) { bool bReturn = false; if (button == CONTEXT_BUTTON_PLAY_ITEM) { - /* play channel from an EPG tag */ - const CPVRChannel *channel = ((CPVREpgInfoTag *)item->GetEPGInfoTag())->ChannelTag(); - bool bReturn = g_application.PlayFile(CFileItem(*channel)); - if (!bReturn) - CGUIDialogOK::ShowAndGetInput(19033,0,19035,0); + bReturn = PlayEpgItem(item); } return bReturn; diff --git a/xbmc/pvr/windows/GUIWindowPVRGuide.h b/xbmc/pvr/windows/GUIWindowPVRGuide.h index a8aa0cbc738d4..27a500933bdd1 100644 --- a/xbmc/pvr/windows/GUIWindowPVRGuide.h +++ b/xbmc/pvr/windows/GUIWindowPVRGuide.h @@ -49,6 +49,7 @@ namespace PVR virtual bool IsSelectedList(CGUIMessage &message) const; virtual bool OnClickButton(CGUIMessage &message); virtual bool OnClickList(CGUIMessage &message); + virtual bool PlayEpgItem(CFileItem *item); virtual bool OnContextButtonBegin(CFileItem *item, CONTEXT_BUTTON button); virtual bool OnContextButtonEnd(CFileItem *item, CONTEXT_BUTTON button); diff --git a/xbmc/settings/AdvancedSettings.cpp b/xbmc/settings/AdvancedSettings.cpp index 791962374580a..efb0e456e3b7e 100644 --- a/xbmc/settings/AdvancedSettings.cpp +++ b/xbmc/settings/AdvancedSettings.cpp @@ -278,6 +278,7 @@ void CAdvancedSettings::Initialize() m_iPVRTimeCorrection = 0; m_iPVRInputStreamDelay = 200; m_iPVRInfoToggleInterval = 3000; + m_bPVRShowEpgInfoOnEpgItemSelect = true; m_measureRefreshrate = false; @@ -873,6 +874,7 @@ bool CAdvancedSettings::Load() XMLUtils::GetInt(pPVR, "timecorrection", m_iPVRTimeCorrection, 0, 1440); XMLUtils::GetInt(pPVR, "inputstreamdelay", m_iPVRInputStreamDelay, 0, 10000); XMLUtils::GetInt(pPVR, "infotoggleinterval", m_iPVRInfoToggleInterval, 0, 30000); + XMLUtils::GetBoolean(pPVR, "showepginfoonselect", m_bPVRShowEpgInfoOnEpgItemSelect); } XMLUtils::GetBoolean(pRootElement, "measurerefreshrate", m_measureRefreshrate); diff --git a/xbmc/settings/AdvancedSettings.h b/xbmc/settings/AdvancedSettings.h index 8bb096c40e27c..ce96c0e22d71a 100644 --- a/xbmc/settings/AdvancedSettings.h +++ b/xbmc/settings/AdvancedSettings.h @@ -288,6 +288,7 @@ class CAdvancedSettings int m_iPVRTimeCorrection; /*!< @brief correct all times (epg tags, timer tags, recording tags) by this amount of minutes. defaults to 0. */ int m_iPVRInputStreamDelay; /*!< @brief delay the playback of the pvr streams by this amount of milliseconds. increase if the pvr streams buffer a lot when starting them. defaults to 200. */ int m_iPVRInfoToggleInterval; /*!< @brief if there are more than 1 pvr gui info item available (e.g. multiple recordings active at the same time), use this toggle delay in milliseconds. defaults to 3000. */ + bool m_bPVRShowEpgInfoOnEpgItemSelect; /*!< @brief when selecting an EPG fileitem, show the EPG info dialog if this setting is true. start playback on the selected channel if false */ bool m_measureRefreshrate; //when true the videoreferenceclock will measure the refreshrate when direct3d is used //otherwise it will use the windows refreshrate From 4dbd7b271c7b09f9d4084c605b2fa452c770be38 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Fri, 22 Apr 2011 16:39:50 +0200 Subject: [PATCH 23/47] tvheadend addon: removed debug message leftover --- xbmc/pvrclients/tvheadend/HTSPDemux.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/xbmc/pvrclients/tvheadend/HTSPDemux.cpp b/xbmc/pvrclients/tvheadend/HTSPDemux.cpp index b989680e266ad..fe65299c83532 100644 --- a/xbmc/pvrclients/tvheadend/HTSPDemux.cpp +++ b/xbmc/pvrclients/tvheadend/HTSPDemux.cpp @@ -330,7 +330,6 @@ void cHTSPDemux::SubscriptionStart(htsmsg_t *m) m_Streams.stream[m_Streams.iStreamCount].iCodecId = CODEC_ID_AC3; m_Streams.stream[m_Streams.iStreamCount].iChannels = htsmsg_get_u32_or_default(sub, "channels" , 0); m_Streams.stream[m_Streams.iStreamCount].iSampleRate = htsmsg_get_u32_or_default(sub, "rate" , 0); - XBMC->Log(LOG_DEBUG, "channels = %d, rate = %d", m_Streams.stream[m_Streams.iStreamCount].iChannels, m_Streams.stream[m_Streams.iStreamCount].iSampleRate); SetLanguageInfo(language, m_Streams.stream[m_Streams.iStreamCount].strLanguage); m_Streams.iStreamCount++; } From 0a1d5bf4dcdd390f727136eed234f75d650d4433 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Fri, 22 Apr 2011 19:16:59 +0200 Subject: [PATCH 24/47] tvheadend addon: clean up SubscriptionStart() --- xbmc/pvrclients/tvheadend/HTSPDemux.cpp | 182 +++++++++++------------- xbmc/pvrclients/tvheadend/HTSPDemux.h | 2 - 2 files changed, 80 insertions(+), 104 deletions(-) diff --git a/xbmc/pvrclients/tvheadend/HTSPDemux.cpp b/xbmc/pvrclients/tvheadend/HTSPDemux.cpp index fe65299c83532..4b405d510c27c 100644 --- a/xbmc/pvrclients/tvheadend/HTSPDemux.cpp +++ b/xbmc/pvrclients/tvheadend/HTSPDemux.cpp @@ -253,21 +253,46 @@ bool cHTSPDemux::GetSignalStatus(PVR_SIGNAL_STATUS &qualityinfo) return true; } -void cHTSPDemux::SetLanguageInfo(const char *strLanguage, char *strDestination) +inline void HTSPResetDemuxStreamInfo(PVR_STREAM_PROPERTIES::PVR_STREAM &stream) { - if (strLanguage == NULL) - { - strDestination[0] = 0; - strDestination[1] = 0; - strDestination[2] = 0; - strDestination[3] = 0; - } - else + stream.iFPSScale = 0; + stream.iFPSRate = 0; + stream.iHeight = 0; + stream.iWidth = 0; + stream.fAspect = 0.0; + stream.iChannels = 0; + stream.iSampleRate = 0; + stream.iBlockAlign = 0; + stream.iBitRate = 0; + stream.iBitsPerSample = 0; + stream.strLanguage[0] = 0; + stream.strLanguage[1] = 0; + stream.strLanguage[2] = 0; + stream.strLanguage[3] = 0; + stream.iIdentifier = -1; +} + +inline void HTSPSetDemuxStreamInfoAudio(PVR_STREAM_PROPERTIES::PVR_STREAM &stream, htsmsg_t *msg) +{ + stream.iChannels = htsmsg_get_u32_or_default(msg, "channels" , 0); + stream.iSampleRate = htsmsg_get_u32_or_default(msg, "rate" , 0); +} + +inline void HTSPSetDemuxStreamInfoVideo(PVR_STREAM_PROPERTIES::PVR_STREAM &stream, htsmsg_t *msg) +{ + stream.iWidth = htsmsg_get_u32_or_default(msg, "width" , 0); + stream.iHeight = htsmsg_get_u32_or_default(msg, "height" , 0); + stream.fAspect = (float) (htsmsg_get_u32_or_default(msg, "aspect_num", 1) / htsmsg_get_u32_or_default(msg, "aspect_den", 1)); +} + +inline void HTSPSetDemuxStreamInfoLanguage(PVR_STREAM_PROPERTIES::PVR_STREAM &stream, htsmsg_t *msg) +{ + if (const char *strLanguage = htsmsg_get_str(msg, "language")) { - strDestination[0] = strLanguage[0]; - strDestination[1] = strLanguage[1]; - strDestination[2] = strLanguage[2]; - strDestination[3] = 0; + stream.strLanguage[0] = strLanguage[0]; + stream.strLanguage[1] = strLanguage[1]; + stream.strLanguage[2] = strLanguage[2]; + stream.strLanguage[3] = 0; } } @@ -300,96 +325,40 @@ void cHTSPDemux::SubscriptionStart(htsmsg_t *m) if (htsmsg_get_u32(sub, "index", &index)) continue; - const char *language = htsmsg_get_str(sub, "language"); - XBMC->Log(LOG_DEBUG, "%s - id: %d, type: %s, language: %s", __FUNCTION__, index, type, language); - - m_Streams.stream[m_Streams.iStreamCount].iFPSScale = 0; - m_Streams.stream[m_Streams.iStreamCount].iFPSRate = 0; - m_Streams.stream[m_Streams.iStreamCount].iHeight = 0; - m_Streams.stream[m_Streams.iStreamCount].iWidth = 0; - m_Streams.stream[m_Streams.iStreamCount].fAspect = 0.0; - - m_Streams.stream[m_Streams.iStreamCount].iChannels = 0; - m_Streams.stream[m_Streams.iStreamCount].iSampleRate = 0; - m_Streams.stream[m_Streams.iStreamCount].iBlockAlign = 0; - m_Streams.stream[m_Streams.iStreamCount].iBitRate = 0; - m_Streams.stream[m_Streams.iStreamCount].iBitsPerSample = 0; + XBMC->Log(LOG_DEBUG, "%s - id: %d, type: %s", __FUNCTION__, index, type); - m_Streams.stream[m_Streams.iStreamCount].strLanguage[0] = 0; - m_Streams.stream[m_Streams.iStreamCount].strLanguage[1] = 0; - m_Streams.stream[m_Streams.iStreamCount].strLanguage[2] = 0; - m_Streams.stream[m_Streams.iStreamCount].strLanguage[3] = 0; - - m_Streams.stream[m_Streams.iStreamCount].iIdentifier = -1; + bool bValidStream(true); + HTSPResetDemuxStreamInfo(m_Streams.stream[m_Streams.iStreamCount]); if(!strcmp(type, "AC3")) { - m_Streams.stream[m_Streams.iStreamCount].iStreamIndex = m_Streams.iStreamCount; - m_Streams.stream[m_Streams.iStreamCount].iPhysicalId = index; - m_Streams.stream[m_Streams.iStreamCount].iCodecType = CODEC_TYPE_AUDIO; - m_Streams.stream[m_Streams.iStreamCount].iCodecId = CODEC_ID_AC3; - m_Streams.stream[m_Streams.iStreamCount].iChannels = htsmsg_get_u32_or_default(sub, "channels" , 0); - m_Streams.stream[m_Streams.iStreamCount].iSampleRate = htsmsg_get_u32_or_default(sub, "rate" , 0); - SetLanguageInfo(language, m_Streams.stream[m_Streams.iStreamCount].strLanguage); - m_Streams.iStreamCount++; + m_Streams.stream[m_Streams.iStreamCount].iCodecType = CODEC_TYPE_AUDIO; + m_Streams.stream[m_Streams.iStreamCount].iCodecId = CODEC_ID_AC3; } else if(!strcmp(type, "EAC3")) { - m_Streams.stream[m_Streams.iStreamCount].iStreamIndex = m_Streams.iStreamCount; - m_Streams.stream[m_Streams.iStreamCount].iPhysicalId = index; - m_Streams.stream[m_Streams.iStreamCount].iCodecType = CODEC_TYPE_AUDIO; - m_Streams.stream[m_Streams.iStreamCount].iCodecId = CODEC_ID_EAC3; - m_Streams.stream[m_Streams.iStreamCount].iChannels = htsmsg_get_u32_or_default(sub, "channels" , 0); - m_Streams.stream[m_Streams.iStreamCount].iSampleRate = htsmsg_get_u32_or_default(sub, "rate" , 0); - XBMC->Log(LOG_DEBUG, "channels = %d, rate = %d", m_Streams.stream[m_Streams.iStreamCount].iChannels, m_Streams.stream[m_Streams.iStreamCount].iSampleRate); - SetLanguageInfo(language, m_Streams.stream[m_Streams.iStreamCount].strLanguage); - m_Streams.iStreamCount++; + m_Streams.stream[m_Streams.iStreamCount].iCodecType = CODEC_TYPE_AUDIO; + m_Streams.stream[m_Streams.iStreamCount].iCodecId = CODEC_ID_EAC3; } else if(!strcmp(type, "MPEG2AUDIO")) { - m_Streams.stream[m_Streams.iStreamCount].iStreamIndex = m_Streams.iStreamCount; - m_Streams.stream[m_Streams.iStreamCount].iPhysicalId = index; - m_Streams.stream[m_Streams.iStreamCount].iCodecType = CODEC_TYPE_AUDIO; - m_Streams.stream[m_Streams.iStreamCount].iCodecId = CODEC_ID_MP2; - m_Streams.stream[m_Streams.iStreamCount].iChannels = htsmsg_get_u32_or_default(sub, "channels" , 0); - m_Streams.stream[m_Streams.iStreamCount].iSampleRate = htsmsg_get_u32_or_default(sub, "rate" , 0); - XBMC->Log(LOG_DEBUG, "channels = %d, rate = %d", m_Streams.stream[m_Streams.iStreamCount].iChannels, m_Streams.stream[m_Streams.iStreamCount].iSampleRate); - SetLanguageInfo(language, m_Streams.stream[m_Streams.iStreamCount].strLanguage); - m_Streams.iStreamCount++; + m_Streams.stream[m_Streams.iStreamCount].iCodecType = CODEC_TYPE_AUDIO; + m_Streams.stream[m_Streams.iStreamCount].iCodecId = CODEC_ID_MP2; } else if(!strcmp(type, "AAC")) { - m_Streams.stream[m_Streams.iStreamCount].iStreamIndex = m_Streams.iStreamCount; - m_Streams.stream[m_Streams.iStreamCount].iPhysicalId = index; - m_Streams.stream[m_Streams.iStreamCount].iCodecType = CODEC_TYPE_AUDIO; - m_Streams.stream[m_Streams.iStreamCount].iCodecId = CODEC_ID_AAC; - m_Streams.stream[m_Streams.iStreamCount].iChannels = htsmsg_get_u32_or_default(sub, "channels" , 0); - m_Streams.stream[m_Streams.iStreamCount].iSampleRate = htsmsg_get_u32_or_default(sub, "rate" , 0); - XBMC->Log(LOG_DEBUG, "channels = %d, rate = %d", m_Streams.stream[m_Streams.iStreamCount].iChannels, m_Streams.stream[m_Streams.iStreamCount].iSampleRate); - SetLanguageInfo(language, m_Streams.stream[m_Streams.iStreamCount].strLanguage); - m_Streams.iStreamCount++; + m_Streams.stream[m_Streams.iStreamCount].iCodecType = CODEC_TYPE_AUDIO; + m_Streams.stream[m_Streams.iStreamCount].iCodecId = CODEC_ID_AAC; } else if(!strcmp(type, "MPEG2VIDEO")) { - m_Streams.stream[m_Streams.iStreamCount].iStreamIndex = m_Streams.iStreamCount; - m_Streams.stream[m_Streams.iStreamCount].iPhysicalId = index; - m_Streams.stream[m_Streams.iStreamCount].iCodecType = CODEC_TYPE_VIDEO; - m_Streams.stream[m_Streams.iStreamCount].iCodecId = CODEC_ID_MPEG2VIDEO; - m_Streams.stream[m_Streams.iStreamCount].iWidth = htsmsg_get_u32_or_default(sub, "width" , 0); - m_Streams.stream[m_Streams.iStreamCount].iHeight = htsmsg_get_u32_or_default(sub, "height" , 0); - m_Streams.stream[m_Streams.iStreamCount].fAspect = (float) (htsmsg_get_u32_or_default(sub, "aspect_num", 1) / htsmsg_get_u32_or_default(sub, "aspect_den", 1)); - m_Streams.iStreamCount++; + m_Streams.stream[m_Streams.iStreamCount].iCodecType = CODEC_TYPE_VIDEO; + m_Streams.stream[m_Streams.iStreamCount].iCodecId = CODEC_ID_MPEG2VIDEO; } else if(!strcmp(type, "H264")) { - m_Streams.stream[m_Streams.iStreamCount].iStreamIndex = m_Streams.iStreamCount; - m_Streams.stream[m_Streams.iStreamCount].iPhysicalId = index; - m_Streams.stream[m_Streams.iStreamCount].iCodecType = CODEC_TYPE_VIDEO; - m_Streams.stream[m_Streams.iStreamCount].iCodecId = CODEC_ID_H264; - m_Streams.stream[m_Streams.iStreamCount].iWidth = htsmsg_get_u32_or_default(sub, "width" , 0); - m_Streams.stream[m_Streams.iStreamCount].iHeight = htsmsg_get_u32_or_default(sub, "height" , 0); - m_Streams.stream[m_Streams.iStreamCount].fAspect = (float) (htsmsg_get_u32_or_default(sub, "aspect_num", 1) / htsmsg_get_u32_or_default(sub, "aspect_den", 1)); - m_Streams.iStreamCount++; + m_Streams.stream[m_Streams.iStreamCount].iCodecType = CODEC_TYPE_VIDEO; + m_Streams.stream[m_Streams.iStreamCount].iCodecId = CODEC_ID_H264; } else if(!strcmp(type, "DVBSUB")) { @@ -397,30 +366,39 @@ void cHTSPDemux::SubscriptionStart(htsmsg_t *m) htsmsg_get_u32(sub, "composition_id", &composition_id); htsmsg_get_u32(sub, "ancillary_id" , &ancillary_id); - m_Streams.stream[m_Streams.iStreamCount].iStreamIndex = m_Streams.iStreamCount; - m_Streams.stream[m_Streams.iStreamCount].iPhysicalId = index; - m_Streams.stream[m_Streams.iStreamCount].iCodecType = CODEC_TYPE_SUBTITLE; - m_Streams.stream[m_Streams.iStreamCount].iCodecId = CODEC_ID_DVB_SUBTITLE; - SetLanguageInfo(language, m_Streams.stream[m_Streams.iStreamCount].strLanguage); - m_Streams.stream[m_Streams.iStreamCount].iIdentifier = (composition_id & 0xffff) | ((ancillary_id & 0xffff) << 16); - m_Streams.iStreamCount++; + m_Streams.stream[m_Streams.iStreamCount].iCodecType = CODEC_TYPE_SUBTITLE; + m_Streams.stream[m_Streams.iStreamCount].iCodecId = CODEC_ID_DVB_SUBTITLE; + m_Streams.stream[m_Streams.iStreamCount].iIdentifier = (composition_id & 0xffff) | ((ancillary_id & 0xffff) << 16); + HTSPSetDemuxStreamInfoLanguage(m_Streams.stream[m_Streams.iStreamCount], sub); } else if(!strcmp(type, "TEXTSUB")) { - m_Streams.stream[m_Streams.iStreamCount].iStreamIndex = m_Streams.iStreamCount; - m_Streams.stream[m_Streams.iStreamCount].iPhysicalId = index; - m_Streams.stream[m_Streams.iStreamCount].iCodecType = CODEC_TYPE_SUBTITLE; - m_Streams.stream[m_Streams.iStreamCount].iCodecId = CODEC_ID_TEXT; - SetLanguageInfo(language, m_Streams.stream[m_Streams.iStreamCount].strLanguage); - m_Streams.iStreamCount++; + m_Streams.stream[m_Streams.iStreamCount].iCodecType = CODEC_TYPE_SUBTITLE; + m_Streams.stream[m_Streams.iStreamCount].iCodecId = CODEC_ID_TEXT; + HTSPSetDemuxStreamInfoLanguage(m_Streams.stream[m_Streams.iStreamCount], sub); } else if(!strcmp(type, "TELETEXT")) { - m_Streams.stream[m_Streams.iStreamCount].iStreamIndex = m_Streams.iStreamCount; - m_Streams.stream[m_Streams.iStreamCount].iPhysicalId = index; - m_Streams.stream[m_Streams.iStreamCount].iCodecType = CODEC_TYPE_SUBTITLE; - m_Streams.stream[m_Streams.iStreamCount].iCodecId = CODEC_ID_DVB_TELETEXT; - m_Streams.iStreamCount++; + m_Streams.stream[m_Streams.iStreamCount].iCodecType = CODEC_TYPE_SUBTITLE; + m_Streams.stream[m_Streams.iStreamCount].iCodecId = CODEC_ID_DVB_TELETEXT; + } + else + { + bValidStream = false; + } + + if (bValidStream) + { + m_Streams.stream[m_Streams.iStreamCount].iStreamIndex = m_Streams.iStreamCount; + m_Streams.stream[m_Streams.iStreamCount].iPhysicalId = index; + if (m_Streams.stream[m_Streams.iStreamCount].iCodecType == CODEC_TYPE_AUDIO) + { + HTSPSetDemuxStreamInfoAudio(m_Streams.stream[m_Streams.iStreamCount], sub); + HTSPSetDemuxStreamInfoLanguage(m_Streams.stream[m_Streams.iStreamCount], sub); + } + else if (m_Streams.stream[m_Streams.iStreamCount].iCodecType == CODEC_TYPE_VIDEO) + HTSPSetDemuxStreamInfoVideo(m_Streams.stream[m_Streams.iStreamCount], sub); + ++m_Streams.iStreamCount; } if (m_Streams.iStreamCount >= PVR_STREAM_MAX_STREAMS) diff --git a/xbmc/pvrclients/tvheadend/HTSPDemux.h b/xbmc/pvrclients/tvheadend/HTSPDemux.h index e2ba8df998b21..1cc22217799b4 100644 --- a/xbmc/pvrclients/tvheadend/HTSPDemux.h +++ b/xbmc/pvrclients/tvheadend/HTSPDemux.h @@ -46,8 +46,6 @@ class cHTSPDemux DemuxPacket *ParseMuxPacket(htsmsg_t *m); private: - void SetLanguageInfo(const char *strLanguage, char *strDestination); - unsigned m_subs; cHTSPSession m_session; int m_channel; From 4ce7bdd3b77b4eb2e912371450c96417b48506b7 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Fri, 22 Apr 2011 22:06:43 +0200 Subject: [PATCH 25/47] pvr: fixed wrong #ifdef check when using external ffmpeg --- xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxPVRClient.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxPVRClient.h b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxPVRClient.h index 9194c1fb0389d..aa45b27f897d1 100644 --- a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxPVRClient.h +++ b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxPVRClient.h @@ -28,7 +28,7 @@ #else extern "C" { #if (defined USE_EXTERNAL_FFMPEG) - #if (defined HAVE_LIBAVCODEC_AVFORMAT_H) + #if (defined HAVE_LIBAVFORMAT_AVFORMAT_H) #include #elif (defined HAVE_FFMPEG_AVFORMAT_H) #include From 7c7431c013395d30ed74653b14983861f2d9a4f6 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Fri, 22 Apr 2011 23:29:33 +0200 Subject: [PATCH 26/47] pvr: increase the maximum number of streams to 20 --- xbmc/addons/include/xbmc_pvr_types.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xbmc/addons/include/xbmc_pvr_types.h b/xbmc/addons/include/xbmc_pvr_types.h index f6bd682ad85f4..0e0b006bec2ce 100644 --- a/xbmc/addons/include/xbmc_pvr_types.h +++ b/xbmc/addons/include/xbmc_pvr_types.h @@ -77,7 +77,9 @@ struct DemuxPacket; #define EPG_EVENT_CONTENTMASK_USERDEFINED 0xF0 //@} -#define PVR_STREAM_MAX_STREAMS 16 + +/* using the default avformat's MAX_STREAMS value to be safe */ +#define PVR_STREAM_MAX_STREAMS 20 #ifdef __cplusplus extern "C" { From 4186afadae34917e027f46fb3a8217de91a311ce Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Sat, 23 Apr 2011 00:33:02 +0200 Subject: [PATCH 27/47] epg: remove nearly all dependencies on PVR code. remove some friend class statements --- xbmc/epg/Epg.cpp | 55 +++++++++++++++++++++++++++- xbmc/epg/Epg.h | 26 +++++-------- xbmc/epg/EpgContainer.cpp | 7 +--- xbmc/epg/EpgContainer.h | 12 ------ xbmc/epg/EpgInfoTag.cpp | 7 +--- xbmc/epg/EpgInfoTag.h | 14 +------ xbmc/pvr/PVRManager.cpp | 48 ------------------------ xbmc/pvr/PVRManager.h | 8 ---- xbmc/pvr/epg/PVREpgContainer.cpp | 6 +++ xbmc/pvr/epg/PVREpgContainer.h | 7 +++- xbmc/pvr/recordings/PVRRecording.cpp | 5 ++- xbmc/pvr/timers/PVRTimerInfoTag.cpp | 5 ++- 12 files changed, 87 insertions(+), 113 deletions(-) diff --git a/xbmc/epg/Epg.cpp b/xbmc/epg/Epg.cpp index 068adc52f6845..e699021351ec8 100644 --- a/xbmc/epg/Epg.cpp +++ b/xbmc/epg/Epg.cpp @@ -19,6 +19,7 @@ * */ +#include "guilib/LocalizeStrings.h" #include "settings/AdvancedSettings.h" #include "settings/GUISettings.h" #include "threads/SingleLock.h" @@ -28,6 +29,8 @@ #include "EpgDatabase.h" #include "EpgContainer.h" +#include "../addons/include/xbmc_pvr_types.h" // TODO extract the epg specific stuff + using namespace EPG; struct sortEPGbyDate @@ -68,7 +71,7 @@ bool CEpg::HasValidEntries(void) const return (m_iEpgID > 0 && /* valid EPG ID */ size() > 0 && /* contains at least 1 tag */ - at(size()-1)->m_endTime >= CDateTime::GetCurrentDateTime().GetAsUTCDateTime()); /* the last end time hasn't passed yet */ + at(size()-1)->EndAsUTC() >= CDateTime::GetCurrentDateTime().GetAsUTCDateTime()); /* the last end time hasn't passed yet */ } bool CEpg::DeleteInfoTag(CEpgInfoTag *tag) @@ -76,7 +79,7 @@ bool CEpg::DeleteInfoTag(CEpgInfoTag *tag) bool bReturn = false; /* check if we're the "owner" of this tag */ - if (tag->m_Epg != this) + if (*tag->m_Epg != *this) return bReturn; CSingleLock lock(m_critSection); @@ -768,3 +771,51 @@ CEpgInfoTag *CEpg::CreateTag(void) } //@} + +const CStdString &CEpg::ConvertGenreIdToString(int iID, int iSubID) +{ + unsigned int iLabelId = 19499; + switch (iID) + { + case EPG_EVENT_CONTENTMASK_MOVIEDRAMA: + iLabelId = (iSubID <= 8) ? 19500 + iSubID : 19500; + break; + case EPG_EVENT_CONTENTMASK_NEWSCURRENTAFFAIRS: + iLabelId = (iSubID <= 4) ? 19516 + iSubID : 19516; + break; + case EPG_EVENT_CONTENTMASK_SHOW: + iLabelId = (iSubID <= 3) ? 19532 + iSubID : 19532; + break; + case EPG_EVENT_CONTENTMASK_SPORTS: + iLabelId = (iSubID <= 11) ? 19548 + iSubID : 19548; + break; + case EPG_EVENT_CONTENTMASK_CHILDRENYOUTH: + iLabelId = (iSubID <= 5) ? 19564 + iSubID : 19564; + break; + case EPG_EVENT_CONTENTMASK_MUSICBALLETDANCE: + iLabelId = (iSubID <= 6) ? 19580 + iSubID : 19580; + break; + case EPG_EVENT_CONTENTMASK_ARTSCULTURE: + iLabelId = (iSubID <= 11) ? 19596 + iSubID : 19596; + break; + case EPG_EVENT_CONTENTMASK_SOCIALPOLITICALECONOMICS: + iLabelId = (iSubID <= 3) ? 19612 + iSubID : 19612; + break; + case EPG_EVENT_CONTENTMASK_EDUCATIONALSCIENCE: + iLabelId = (iSubID <= 7) ? 19628 + iSubID : 19628; + break; + case EPG_EVENT_CONTENTMASK_LEISUREHOBBIES: + iLabelId = (iSubID <= 7) ? 19644 + iSubID : 19644; + break; + case EPG_EVENT_CONTENTMASK_SPECIAL: + iLabelId = (iSubID <= 3) ? 19660 + iSubID : 19660; + break; + case EPG_EVENT_CONTENTMASK_USERDEFINED: + iLabelId = (iSubID <= 3) ? 19676 + iSubID : 19676; + break; + default: + break; + } + + return g_localizeStrings.Get(iLabelId); +} diff --git a/xbmc/epg/Epg.h b/xbmc/epg/Epg.h index 548ca86de8d3b..06012c3d5e417 100644 --- a/xbmc/epg/Epg.h +++ b/xbmc/epg/Epg.h @@ -28,27 +28,12 @@ #include "EpgInfoTag.h" #include "EpgSearchFilter.h" -namespace EPG -{ - class CEpgContainer; -} - -namespace PVR -{ - class CPVREpgContainer; - class CPVREpg; -} - /** EPG container for CEpgInfoTag instances */ - namespace EPG { class CEpg : public std::vector { friend class CEpgDatabase; - friend class CPVREpgContainer; - friend class CEpgContainer; - friend class CPVREpg; protected: bool m_bInhibitSorting; /*!< don't sort the table if this is true */ @@ -139,7 +124,7 @@ namespace EPG */ virtual void UpdateFirstAndLastDates(void); - protected: + public: /*! * @brief Update this table's info with the given info. Doesn't change the EpgID. * @param epg The new info. @@ -154,7 +139,6 @@ namespace EPG */ bool Load(void); - public: /*! * @brief Create a new EPG instance. * @param iEpgID The ID of this table or <= 0 to create a new ID. @@ -324,5 +308,13 @@ namespace EPG * @return The last time this table was scanned. */ virtual const CDateTime &GetLastScanTime(void); + + /*! + * @brief Convert a genre id and subid to a human readable name. + * @param iID The genre ID. + * @param iSubID The genre sub ID. + * @return A human readable name. + */ + static const CStdString &ConvertGenreIdToString(int iID, int iSubID); }; } diff --git a/xbmc/epg/EpgContainer.cpp b/xbmc/epg/EpgContainer.cpp index 6ad54698f254d..86af4ee464c70 100644 --- a/xbmc/epg/EpgContainer.cpp +++ b/xbmc/epg/EpgContainer.cpp @@ -34,10 +34,7 @@ #include "EpgInfoTag.h" #include "EpgSearchFilter.h" -#include "pvr/PVRManager.h" - using namespace std; -using namespace PVR; using namespace EPG; CEpgContainer::CEpgContainer(void) @@ -284,7 +281,7 @@ bool CEpgContainer::DeleteEpg(const CEpg &epg, bool bDeleteFromDatabase /* = fal for (unsigned int iEpgPtr = 0; iEpgPtr < size(); iEpgPtr++) { - if (at(iEpgPtr)->m_iEpgID == epg.m_iEpgID) + if (at(iEpgPtr)->EpgID() == epg.EpgID()) { if (bDeleteFromDatabase && m_database.Open()) { @@ -329,7 +326,7 @@ bool CEpgContainer::UpdateSingleTable(CEpg *epg, const time_t start, const time_ bool CEpgContainer::InterruptUpdate(void) const { - return (m_bStop || (g_PVRManager.IsStarted() && g_PVRManager.IsPlaying()));; + return m_bStop; } bool CEpgContainer::UpdateEPG(bool bShowProgress /* = false */) diff --git a/xbmc/epg/EpgContainer.h b/xbmc/epg/EpgContainer.h index 29c8e228868a1..4520eb6fec8ff 100644 --- a/xbmc/epg/EpgContainer.h +++ b/xbmc/epg/EpgContainer.h @@ -31,13 +31,6 @@ class CFileItemList; -namespace PVR -{ - class CPVREpg; - class CPVREpgContainer; - class CPVRManager; -} - namespace EPG { #define g_EpgContainer CEpgContainer::Get() @@ -47,13 +40,8 @@ namespace EPG public Observable, private CThread { - friend class CEpg; friend class CEpgDatabase; - friend class PVR::CPVREpg; - friend class PVR::CPVREpgContainer; - friend class PVR::CPVRManager; - protected: CEpgDatabase m_database; /*!< the EPG database */ diff --git a/xbmc/epg/EpgInfoTag.cpp b/xbmc/epg/EpgInfoTag.cpp index d1a11ff8752a0..c5f08b75650b3 100644 --- a/xbmc/epg/EpgInfoTag.cpp +++ b/xbmc/epg/EpgInfoTag.cpp @@ -20,15 +20,12 @@ */ #include "guilib/LocalizeStrings.h" -#include "../addons/include/xbmc_pvr_types.h" // TODO extract the epg specific stuff #include "EpgInfoTag.h" #include "EpgContainer.h" #include "EpgDatabase.h" #include "utils/log.h" -#include "pvr/PVRManager.h" using namespace std; -using namespace PVR; using namespace EPG; CEpgInfoTag::CEpgInfoTag(int iUniqueBroadcastId) : @@ -249,7 +246,7 @@ void CEpgInfoTag::SetGenre(int iID, int iSubID) { m_iGenreType = iID; m_iGenreSubType = iSubID; - m_strGenre = CPVRManager::ConvertGenreIdToString(iID, iSubID); + m_strGenre = CEpg::ConvertGenreIdToString(iID, iSubID); m_bChanged = true; UpdatePath(); } @@ -400,7 +397,7 @@ bool CEpgInfoTag::Update(const CEpgInfoTag &tag) m_endTime = tag.m_endTime; m_iGenreType = tag.m_iGenreType; m_iGenreSubType = tag.m_iGenreSubType; - m_strGenre = CPVRManager::ConvertGenreIdToString(tag.m_iGenreType, tag.m_iGenreSubType); + m_strGenre = CEpg::ConvertGenreIdToString(tag.m_iGenreType, tag.m_iGenreSubType); m_firstAired = tag.m_firstAired; m_iParentalRating = tag.m_iParentalRating; m_iStarRating = tag.m_iStarRating; diff --git a/xbmc/epg/EpgInfoTag.h b/xbmc/epg/EpgInfoTag.h index d8c5b75c7d1c3..44e942c93cf3f 100644 --- a/xbmc/epg/EpgInfoTag.h +++ b/xbmc/epg/EpgInfoTag.h @@ -24,28 +24,16 @@ #include "XBDateTime.h" #include "Epg.h" +/** an EPG info tag */ namespace EPG { class CEpg; -} - -namespace PVR -{ - class CPVREpg; - class CPVREpgInfoTag; -} -/** an EPG info tag */ -namespace EPG -{ class CEpgInfoTag { friend class CEpg; friend class CEpgDatabase; - friend class PVR::CPVREpg; - friend class PVR::CPVREpgInfoTag; - protected: bool m_bNotify; /*!< notify on start */ bool m_bChanged; /*!< keep track of changes to this entry */ diff --git a/xbmc/pvr/PVRManager.cpp b/xbmc/pvr/PVRManager.cpp index 240f0e1c34106..650f460796542 100644 --- a/xbmc/pvr/PVRManager.cpp +++ b/xbmc/pvr/PVRManager.cpp @@ -969,54 +969,6 @@ int CPVRManager::GetStartTime(void) const return m_guiInfo->GetStartTime(); } -const CStdString &CPVRManager::ConvertGenreIdToString(int iID, int iSubID) -{ - unsigned int iLabelId = 19499; - switch (iID) - { - case EPG_EVENT_CONTENTMASK_MOVIEDRAMA: - iLabelId = (iSubID <= 8) ? 19500 + iSubID : 19500; - break; - case EPG_EVENT_CONTENTMASK_NEWSCURRENTAFFAIRS: - iLabelId = (iSubID <= 4) ? 19516 + iSubID : 19516; - break; - case EPG_EVENT_CONTENTMASK_SHOW: - iLabelId = (iSubID <= 3) ? 19532 + iSubID : 19532; - break; - case EPG_EVENT_CONTENTMASK_SPORTS: - iLabelId = (iSubID <= 11) ? 19548 + iSubID : 19548; - break; - case EPG_EVENT_CONTENTMASK_CHILDRENYOUTH: - iLabelId = (iSubID <= 5) ? 19564 + iSubID : 19564; - break; - case EPG_EVENT_CONTENTMASK_MUSICBALLETDANCE: - iLabelId = (iSubID <= 6) ? 19580 + iSubID : 19580; - break; - case EPG_EVENT_CONTENTMASK_ARTSCULTURE: - iLabelId = (iSubID <= 11) ? 19596 + iSubID : 19596; - break; - case EPG_EVENT_CONTENTMASK_SOCIALPOLITICALECONOMICS: - iLabelId = (iSubID <= 3) ? 19612 + iSubID : 19612; - break; - case EPG_EVENT_CONTENTMASK_EDUCATIONALSCIENCE: - iLabelId = (iSubID <= 7) ? 19628 + iSubID : 19628; - break; - case EPG_EVENT_CONTENTMASK_LEISUREHOBBIES: - iLabelId = (iSubID <= 7) ? 19644 + iSubID : 19644; - break; - case EPG_EVENT_CONTENTMASK_SPECIAL: - iLabelId = (iSubID <= 3) ? 19660 + iSubID : 19660; - break; - case EPG_EVENT_CONTENTMASK_USERDEFINED: - iLabelId = (iSubID <= 3) ? 19676 + iSubID : 19676; - break; - default: - break; - } - - return g_localizeStrings.Get(iLabelId); -} - bool CPVRManager::TranslateBoolInfo(DWORD dwInfo) const { return m_guiInfo->TranslateBoolInfo(dwInfo); diff --git a/xbmc/pvr/PVRManager.h b/xbmc/pvr/PVRManager.h index 967fb1baf4a16..cdd36c8faa67c 100644 --- a/xbmc/pvr/PVRManager.h +++ b/xbmc/pvr/PVRManager.h @@ -328,14 +328,6 @@ namespace PVR */ bool StartPlayback(const CPVRChannel *channel, bool bPreview = false); - /*! - * @brief Convert a genre id and subid to a human readable name. - * @param iID The genre ID. - * @param iSubID The genre sub ID. - * @return A human readable name. - */ - static const CStdString &ConvertGenreIdToString(int iID, int iSubID); - /*! * @brief Update the current playing file in the guiinfomanager and application. */ diff --git a/xbmc/pvr/epg/PVREpgContainer.cpp b/xbmc/pvr/epg/PVREpgContainer.cpp index e21c27d40926c..3fb5f0aabd690 100644 --- a/xbmc/pvr/epg/PVREpgContainer.cpp +++ b/xbmc/pvr/epg/PVREpgContainer.cpp @@ -240,3 +240,9 @@ bool PVR::CPVREpgContainer::UpdateEPG(bool bShowProgress /* = false */) return bReturn; } + +bool PVR::CPVREpgContainer::InterruptUpdate(void) const +{ + return (CEpgContainer::InterruptUpdate() || + (g_PVRManager.IsStarted() && g_PVRManager.IsPlaying())); +} diff --git a/xbmc/pvr/epg/PVREpgContainer.h b/xbmc/pvr/epg/PVREpgContainer.h index f5472e1051dd4..81cf89bdfa321 100644 --- a/xbmc/pvr/epg/PVREpgContainer.h +++ b/xbmc/pvr/epg/PVREpgContainer.h @@ -31,7 +31,7 @@ namespace PVR { friend class CPVREpg; - private: + protected: /*! * @brief Create an EPG table for each channel. * @return True if all tables were created successfully, false otherwise. @@ -53,6 +53,11 @@ namespace PVR bool UpdateEPG(bool bShowProgress = false); + /*! + * @return True if a running update should be interrupted, false otherwise. + */ + bool InterruptUpdate(void) const; + public: /*! diff --git a/xbmc/pvr/recordings/PVRRecording.cpp b/xbmc/pvr/recordings/PVRRecording.cpp index 93d935e34d622..5e1aca25ca8f1 100644 --- a/xbmc/pvr/recordings/PVRRecording.cpp +++ b/xbmc/pvr/recordings/PVRRecording.cpp @@ -25,7 +25,10 @@ #include "PVRRecordings.h" #include "pvr/addons/PVRClients.h" +#include "epg/Epg.h" + using namespace PVR; +using namespace EPG; CPVRRecording::CPVRRecording() { @@ -48,7 +51,7 @@ CPVRRecording::CPVRRecording(const PVR_RECORDING &recording, unsigned int iClien m_strPlotOutline = recording.strPlotOutline; m_strStreamURL = recording.strStreamURL; m_strChannelName = recording.strChannelName; - m_strGenre = CPVRManager::ConvertGenreIdToString(recording.iGenreType, recording.iGenreSubType); + m_strGenre = CEpg::ConvertGenreIdToString(recording.iGenreType, recording.iGenreSubType); } bool CPVRRecording::operator ==(const CPVRRecording& right) const diff --git a/xbmc/pvr/timers/PVRTimerInfoTag.cpp b/xbmc/pvr/timers/PVRTimerInfoTag.cpp index 401c050f8c98c..a2d044c75f304 100644 --- a/xbmc/pvr/timers/PVRTimerInfoTag.cpp +++ b/xbmc/pvr/timers/PVRTimerInfoTag.cpp @@ -31,7 +31,10 @@ #include "pvr/epg/PVREpgContainer.h" #include "pvr/addons/PVRClients.h" +#include "epg/Epg.h" + using namespace PVR; +using namespace EPG; CPVRTimerInfoTag::CPVRTimerInfoTag(void) { @@ -79,7 +82,7 @@ CPVRTimerInfoTag::CPVRTimerInfoTag(const PVR_TIMER &timer, CPVRChannel *channel, m_iLifetime = timer.iLifetime; m_iMarginStart = timer.iMarginStart; m_iMarginEnd = timer.iMarginEnd; - m_strGenre = CPVRManager::ConvertGenreIdToString(timer.iGenreType, timer.iGenreSubType); + m_strGenre = CEpg::ConvertGenreIdToString(timer.iGenreType, timer.iGenreSubType); m_epgInfo = NULL; m_channel = channel; m_bIsRadio = channel && channel->IsRadio(); From e272aaaa79998ea6b27bb22f8bdc2b4e9d9a33ec Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Sat, 23 Apr 2011 01:04:18 +0200 Subject: [PATCH 28/47] pvr/epg: optionally interrupt epg updates while playing TV, configurable via gui settings --- language/Dutch/strings.xml | 1 + language/English/strings.xml | 1 + xbmc/pvr/epg/PVREpgContainer.cpp | 5 ++++- xbmc/settings/GUISettings.cpp | 1 + 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/language/Dutch/strings.xml b/language/Dutch/strings.xml index b71c83c631f38..9ad7ab9d274e0 100644 --- a/language/Dutch/strings.xml +++ b/language/Dutch/strings.xml @@ -1628,6 +1628,7 @@ Opname voltooid Opname verwijderd Sluit kanelen OSD na wijzigen kanaal + Geen EPG updates tijdens het afspelen van een TV stream Anders/Onbekend Film/Drama diff --git a/language/English/strings.xml b/language/English/strings.xml index 157a071ea0db2..b2c9f8c2b9097 100644 --- a/language/English/strings.xml +++ b/language/English/strings.xml @@ -1756,6 +1756,7 @@ Recording completed Recording deleted Close channel OSD after switching channels + Prevent EPG updates while playing a TV stream Other/Unknown Movie/Drama diff --git a/xbmc/pvr/epg/PVREpgContainer.cpp b/xbmc/pvr/epg/PVREpgContainer.cpp index 3fb5f0aabd690..717e23f06e740 100644 --- a/xbmc/pvr/epg/PVREpgContainer.cpp +++ b/xbmc/pvr/epg/PVREpgContainer.cpp @@ -27,6 +27,7 @@ #include "pvr/recordings/PVRRecordings.h" #include "pvr/windows/GUIWindowPVR.h" #include "guilib/GUIWindowManager.h" +#include "settings/GUISettings.h" #include "utils/log.h" using namespace std; @@ -244,5 +245,7 @@ bool PVR::CPVREpgContainer::UpdateEPG(bool bShowProgress /* = false */) bool PVR::CPVREpgContainer::InterruptUpdate(void) const { return (CEpgContainer::InterruptUpdate() || - (g_PVRManager.IsStarted() && g_PVRManager.IsPlaying())); + (g_guiSettings.GetBool("epg.preventupdateswhileplayingtv") && + g_PVRManager.IsStarted() && + g_PVRManager.IsPlaying())); } diff --git a/xbmc/settings/GUISettings.cpp b/xbmc/settings/GUISettings.cpp index 113b89a36649a..ad81dba080643 100644 --- a/xbmc/settings/GUISettings.cpp +++ b/xbmc/settings/GUISettings.cpp @@ -817,6 +817,7 @@ void CGUISettings::Initialize() AddInt(pvre, "epg.epgupdate", 19071, 120, 15, 15, 480, SPIN_CONTROL_INT_PLUS, MASK_MINS); AddBool(pvre, "epg.ignoredbforclient", 19072, false); AddString(pvre, "epg.resetepg", 19187, "", BUTTON_CONTROL_STANDARD); + AddBool(pvre, "epg.preventupdateswhileplayingtv", 19230, false); CSettingsCategory* pvrp = AddCategory(8, "pvrplayback", 19177); AddBool(pvrp, "pvrplayback.switchautoclose", 19168, true); From c30375649ddadb8a9f18f478006cc4f723900012 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Sat, 23 Apr 2011 02:26:50 +0200 Subject: [PATCH 29/47] pvr: remove the win32 work arounds in CPVRClient --- xbmc/pvr/addons/PVRClient.cpp | 207 ++++++++++++++++------------------ xbmc/pvr/addons/PVRClient.h | 28 ----- 2 files changed, 96 insertions(+), 139 deletions(-) diff --git a/xbmc/pvr/addons/PVRClient.cpp b/xbmc/pvr/addons/PVRClient.cpp index 850d8acc219cf..68450b8395bb1 100644 --- a/xbmc/pvr/addons/PVRClient.cpp +++ b/xbmc/pvr/addons/PVRClient.cpp @@ -147,6 +147,90 @@ int CPVRClient::GetID(void) const return m_pInfo->iClienId; } +/*! + * @brief Copy over group info from xbmcGroup to addonGroup. + * @param xbmcGroup The group on XBMC's side. + * @param addonGroup The group on the addon's side. + */ +inline void PVRWriteClientGroupInfo(const CPVRChannelGroup &xbmcGroup, PVR_CHANNEL_GROUP &addonGroup) +{ + addonGroup.bIsRadio = xbmcGroup.IsRadio(); + addonGroup.strGroupName = xbmcGroup.GroupName(); +} + +/*! + * @brief Copy over recording info from xbmcRecording to addonRecording. + * @param xbmcRecording The recording on XBMC's side. + * @param addonRecording The recording on the addon's side. + */ +inline void PVRWriteClientRecordingInfo(const CPVRRecording &xbmcRecording, PVR_RECORDING &addonRecording) +{ + time_t recTime; + xbmcRecording.RecordingTimeAsUTC().GetAsTime(recTime); + + addonRecording.recordingTime = recTime - g_advancedSettings.m_iPVRTimeCorrection; + addonRecording.iClientIndex = xbmcRecording.m_iClientIndex; + addonRecording.strTitle = xbmcRecording.m_strTitle.c_str(); + addonRecording.strPlotOutline = xbmcRecording.m_strPlotOutline.c_str(); + addonRecording.strPlot = xbmcRecording.m_strPlot.c_str(); + addonRecording.strChannelName = xbmcRecording.m_strChannelName.c_str(); + addonRecording.iDuration = xbmcRecording.GetDuration(); + addonRecording.iPriority = xbmcRecording.m_iPriority; + addonRecording.iLifetime = xbmcRecording.m_iLifetime; + addonRecording.strDirectory = xbmcRecording.m_strDirectory.c_str(); + addonRecording.strStreamURL = xbmcRecording.m_strStreamURL.c_str(); +} + +/*! + * @brief Copy over timer info from xbmcTimer to addonTimer. + * @param xbmcTimer The timer on XBMC's side. + * @param addonTimer The timer on the addon's side. + */ +inline void PVRWriteClientTimerInfo(const CPVRTimerInfoTag &xbmcTimer, PVR_TIMER &addonTimer) +{ + time_t start, end, firstDay; + xbmcTimer.StartAsUTC().GetAsTime(start); + xbmcTimer.EndAsUTC().GetAsTime(end); + xbmcTimer.FirstDayAsUTC().GetAsTime(firstDay); + + addonTimer.iClientIndex = xbmcTimer.m_iClientIndex; + addonTimer.bIsActive = xbmcTimer.m_bIsActive; + addonTimer.iClientIndex = xbmcTimer.m_iClientIndex; + addonTimer.iClientChannelUid = xbmcTimer.m_iClientChannelUid; + addonTimer.bIsRecording = xbmcTimer.m_bIsRecording; + addonTimer.strTitle = xbmcTimer.m_strTitle; + addonTimer.strDirectory = xbmcTimer.m_strDirectory; + addonTimer.iPriority = xbmcTimer.m_iPriority; + addonTimer.iLifetime = xbmcTimer.m_iLifetime; + addonTimer.bIsRepeating = xbmcTimer.m_bIsRepeating; + addonTimer.iWeekdays = xbmcTimer.m_iWeekdays; + addonTimer.startTime = start - g_advancedSettings.m_iPVRTimeCorrection; + addonTimer.endTime = end - g_advancedSettings.m_iPVRTimeCorrection; + addonTimer.firstDay = firstDay - g_advancedSettings.m_iPVRTimeCorrection; + addonTimer.iEpgUid = xbmcTimer.m_epgInfo ? xbmcTimer.m_epgInfo->UniqueBroadcastID() : -1; + addonTimer.strSummary = xbmcTimer.m_strSummary.c_str(); + addonTimer.iMarginStart = xbmcTimer.m_iMarginStart; + addonTimer.iMarginEnd = xbmcTimer.m_iMarginEnd; +} + +/*! + * @brief Copy over channel info from xbmcChannel to addonClient. + * @param xbmcChannel The channel on XBMC's side. + * @param addonChannel The channel on the addon's side. + */ +inline void PVRWriteClientChannelInfo(const CPVRChannel &xbmcChannel, PVR_CHANNEL &addonChannel) +{ + addonChannel.iUniqueId = xbmcChannel.UniqueID(); + addonChannel.iChannelNumber = xbmcChannel.ClientChannelNumber(); + addonChannel.strChannelName = xbmcChannel.ClientChannelName().c_str(); + addonChannel.strIconPath = xbmcChannel.IconPath().c_str(); + addonChannel.iEncryptionSystem = xbmcChannel.EncryptionSystem(); + addonChannel.bIsRadio = xbmcChannel.IsRadio(); + addonChannel.bIsHidden = xbmcChannel.IsHidden(); + addonChannel.strInputFormat = xbmcChannel.InputFormat().c_str(); + addonChannel.strStreamURL = xbmcChannel.StreamURL().c_str(); +} + PVR_ERROR CPVRClient::GetAddonCapabilities(PVR_ADDON_CAPABILITIES *pCapabilities) { CSingleLock lock(m_critSection); @@ -294,7 +378,7 @@ PVR_ERROR CPVRClient::GetEPGForChannel(const CPVRChannel &channel, CPVREpg *epg, try { PVR_CHANNEL addonChannel; - WriteClientChannelInfo(channel, addonChannel); + PVRWriteClientChannelInfo(channel, addonChannel); PVR_HANDLE_STRUCT handle; handle.callerAddress = this; @@ -392,11 +476,7 @@ PVR_ERROR CPVRClient::GetChannelGroupMembers(CPVRChannelGroup *group) handle.dataAddress = group; PVR_CHANNEL_GROUP tag; - WriteClientGroupInfo(*group, tag); - - //Workaround for string transfer to PVRclient - CStdString myName(group->GroupName()); - tag.strGroupName = myName.c_str(); + PVRWriteClientGroupInfo(*group, tag); CLog::Log(LOGDEBUG, "PVRClient - %s - get group members for group '%s' from add-on '%s'", __FUNCTION__, tag.strGroupName, GetFriendlyName()); @@ -538,7 +618,7 @@ PVR_ERROR CPVRClient::DeleteRecording(const CPVRRecording &recording) try { PVR_RECORDING tag; - WriteClientRecordingInfo(recording, tag); + PVRWriteClientRecordingInfo(recording, tag); retVal = m_pStruct->DeleteRecording(tag); @@ -570,7 +650,7 @@ PVR_ERROR CPVRClient::RenameRecording(const CPVRRecording &recording) try { PVR_RECORDING tag; - WriteClientRecordingInfo(recording, tag); + PVRWriteClientRecordingInfo(recording, tag); retVal = m_pStruct->RenameRecording(tag); @@ -589,24 +669,6 @@ PVR_ERROR CPVRClient::RenameRecording(const CPVRRecording &recording) return retVal; } -void CPVRClient::WriteClientRecordingInfo(const CPVRRecording &xbmcRecording, PVR_RECORDING &addonRecording) -{ - time_t recTime; - xbmcRecording.RecordingTimeAsUTC().GetAsTime(recTime); - - addonRecording.recordingTime = recTime - g_advancedSettings.m_iPVRTimeCorrection; - addonRecording.iClientIndex = xbmcRecording.m_iClientIndex; - addonRecording.strTitle = xbmcRecording.m_strTitle.c_str(); - addonRecording.strPlotOutline = xbmcRecording.m_strPlotOutline.c_str(); - addonRecording.strPlot = xbmcRecording.m_strPlot.c_str(); - addonRecording.strChannelName = xbmcRecording.m_strChannelName.c_str(); - addonRecording.iDuration = xbmcRecording.GetDuration(); - addonRecording.iPriority = xbmcRecording.m_iPriority; - addonRecording.iLifetime = xbmcRecording.m_iLifetime; - addonRecording.strDirectory = xbmcRecording.m_strDirectory.c_str(); - addonRecording.strStreamURL = xbmcRecording.m_strStreamURL.c_str(); -} - int CPVRClient::GetTimersAmount(void) { int iReturn = -1; @@ -675,15 +737,7 @@ PVR_ERROR CPVRClient::AddTimer(const CPVRTimerInfoTag &timer) try { PVR_TIMER tag; - WriteClientTimerInfo(timer, tag); - - //Workaround for string transfer to PVRclient - CStdString myDir(timer.m_strDirectory); - CStdString mySummary(timer.m_strSummary); - CStdString myTitle(timer.m_strTitle); - tag.strDirectory = myDir.c_str(); - tag.strSummary = mySummary.c_str(); - tag.strTitle = myTitle.c_str(); + PVRWriteClientTimerInfo(timer, tag); retVal = m_pStruct->AddTimer(tag); @@ -715,15 +769,7 @@ PVR_ERROR CPVRClient::DeleteTimer(const CPVRTimerInfoTag &timer, bool bForce /* try { PVR_TIMER tag; - WriteClientTimerInfo(timer, tag); - - //Workaround for string transfer to PVRclient - CStdString myDir(timer.m_strDirectory); - CStdString mySummary(timer.m_strSummary); - CStdString myTitle(timer.m_strTitle); - tag.strDirectory = myDir.c_str(); - tag.strSummary = mySummary.c_str(); - tag.strTitle = myTitle.c_str(); + PVRWriteClientTimerInfo(timer, tag); retVal = m_pStruct->DeleteTimer(tag, bForce); @@ -755,15 +801,7 @@ PVR_ERROR CPVRClient::RenameTimer(const CPVRTimerInfoTag &timer, const CStdStrin try { PVR_TIMER tag; - WriteClientTimerInfo(timer, tag); - - //Workaround for string transfer to PVRclient - CStdString myDir(timer.m_strDirectory); - CStdString mySummary(timer.m_strSummary); - CStdString myTitle(timer.m_strTitle); - tag.strDirectory = myDir.c_str(); - tag.strSummary = mySummary.c_str(); - tag.strTitle = myTitle.c_str(); + PVRWriteClientTimerInfo(timer, tag); retVal = m_pStruct->UpdateTimer(tag); @@ -795,15 +833,7 @@ PVR_ERROR CPVRClient::UpdateTimer(const CPVRTimerInfoTag &timer) try { PVR_TIMER tag; - WriteClientTimerInfo(timer, tag); - - //Workaround for string transfer to PVRclient - CStdString myTitle(timer.m_strTitle); - CStdString myDirectory(timer.m_strDirectory); - CStdString mySummary(timer.m_strSummary); - tag.strTitle = myTitle.c_str(); - tag.strDirectory = myDirectory.c_str(); - tag.strSummary = mySummary.c_str(); + PVRWriteClientTimerInfo(timer, tag); retVal = m_pStruct->UpdateTimer(tag); @@ -822,33 +852,6 @@ PVR_ERROR CPVRClient::UpdateTimer(const CPVRTimerInfoTag &timer) return retVal; } -void CPVRClient::WriteClientTimerInfo(const CPVRTimerInfoTag &xbmcTimer, PVR_TIMER &addonTimer) -{ - time_t start, end, firstDay; - xbmcTimer.StartAsUTC().GetAsTime(start); - xbmcTimer.EndAsUTC().GetAsTime(end); - xbmcTimer.FirstDayAsUTC().GetAsTime(firstDay); - - addonTimer.iClientIndex = xbmcTimer.m_iClientIndex; - addonTimer.bIsActive = xbmcTimer.m_bIsActive; - addonTimer.iClientIndex = xbmcTimer.m_iClientIndex; - addonTimer.iClientChannelUid = xbmcTimer.m_iClientChannelUid; - addonTimer.bIsRecording = xbmcTimer.m_bIsRecording; - addonTimer.strTitle = xbmcTimer.m_strTitle; - addonTimer.strDirectory = xbmcTimer.m_strDirectory; - addonTimer.iPriority = xbmcTimer.m_iPriority; - addonTimer.iLifetime = xbmcTimer.m_iLifetime; - addonTimer.bIsRepeating = xbmcTimer.m_bIsRepeating; - addonTimer.iWeekdays = xbmcTimer.m_iWeekdays; - addonTimer.startTime = start - g_advancedSettings.m_iPVRTimeCorrection; - addonTimer.endTime = end - g_advancedSettings.m_iPVRTimeCorrection; - addonTimer.firstDay = firstDay - g_advancedSettings.m_iPVRTimeCorrection; - addonTimer.iEpgUid = xbmcTimer.m_epgInfo ? xbmcTimer.m_epgInfo->UniqueBroadcastID() : -1; - addonTimer.strSummary = xbmcTimer.m_strSummary.c_str(); - addonTimer.iMarginStart = xbmcTimer.m_iMarginStart; - addonTimer.iMarginEnd = xbmcTimer.m_iMarginEnd; -} - bool CPVRClient::OpenLiveStream(const CPVRChannel &channel) { bool bReturn = false; @@ -863,7 +866,7 @@ bool CPVRClient::OpenLiveStream(const CPVRChannel &channel) try { PVR_CHANNEL tag; - WriteClientChannelInfo(channel, tag); + PVRWriteClientChannelInfo(channel, tag); bReturn = m_pStruct->OpenLiveStream(tag); } catch (exception &e) @@ -924,7 +927,7 @@ bool CPVRClient::SwitchChannel(const CPVRChannel &channel) CSingleLock lock(m_critSection); PVR_CHANNEL tag; - WriteClientChannelInfo(channel, tag); + PVRWriteClientChannelInfo(channel, tag); return m_pStruct->SwitchChannel(tag); } @@ -967,7 +970,7 @@ const char *CPVRClient::GetLiveStreamURL(const CPVRChannel &channel) try { PVR_CHANNEL tag; - WriteClientChannelInfo(channel, tag); + PVRWriteClientChannelInfo(channel, tag); strReturn = m_pStruct->GetLiveStreamURL(tag); } catch (exception &e) @@ -979,19 +982,6 @@ const char *CPVRClient::GetLiveStreamURL(const CPVRChannel &channel) return strReturn.c_str(); } -void CPVRClient::WriteClientChannelInfo(const CPVRChannel &xbmcChannel, PVR_CHANNEL &addonChannel) -{ - addonChannel.iUniqueId = xbmcChannel.UniqueID(); - addonChannel.iChannelNumber = xbmcChannel.ClientChannelNumber(); - addonChannel.strChannelName = xbmcChannel.ClientChannelName().c_str(); - addonChannel.strIconPath = xbmcChannel.IconPath().c_str(); - addonChannel.iEncryptionSystem = xbmcChannel.EncryptionSystem(); - addonChannel.bIsRadio = xbmcChannel.IsRadio(); - addonChannel.bIsHidden = xbmcChannel.IsHidden(); - addonChannel.strInputFormat = xbmcChannel.InputFormat().c_str(); - addonChannel.strStreamURL = xbmcChannel.StreamURL().c_str(); -} - bool CPVRClient::OpenRecordedStream(const CPVRRecording &recording) { CSingleLock lock(m_critSection); @@ -1000,7 +990,7 @@ bool CPVRClient::OpenRecordedStream(const CPVRRecording &recording) return false; PVR_RECORDING tag; - WriteClientRecordingInfo(recording, tag); + PVRWriteClientRecordingInfo(recording, tag); return m_pStruct->OpenRecordedStream(tag); } @@ -1216,8 +1206,3 @@ PVR_ERROR CPVRClient::SetAddonCapabilities(void) return PVR_ERROR_SERVER_ERROR; } -void CPVRClient::WriteClientGroupInfo(const CPVRChannelGroup &xbmcGroup, PVR_CHANNEL_GROUP &addonGroup) -{ - addonGroup.bIsRadio = xbmcGroup.IsRadio(); - addonGroup.strGroupName = xbmcGroup.GroupName(); -} diff --git a/xbmc/pvr/addons/PVRClient.h b/xbmc/pvr/addons/PVRClient.h index 815622e82f220..02149b138dc25 100644 --- a/xbmc/pvr/addons/PVRClient.h +++ b/xbmc/pvr/addons/PVRClient.h @@ -465,34 +465,6 @@ namespace PVR bool m_bGotAddonCapabilities; /*!< true if the add-on capabilities have already been fetched */ private: - /*! - * @brief Copy over channel info from xbmcChannel to addonClient. - * @param xbmcChannel The channel on XBMC's side. - * @param addonChannel The channel on the addon's side. - */ - void WriteClientChannelInfo(const CPVRChannel &xbmcChannel, PVR_CHANNEL &addonChannel); - - /*! - * @brief Copy over timer info from xbmcTimer to addonTimer. - * @param xbmcTimer The timer on XBMC's side. - * @param addonTimer The timer on the addon's side. - */ - void WriteClientTimerInfo(const CPVRTimerInfoTag &xbmcTimer, PVR_TIMER &addonTimer); - - /*! - * @brief Copy over recording info from xbmcRecording to addonRecording. - * @param xbmcRecording The recording on XBMC's side. - * @param addonRecording The recording on the addon's side. - */ - void WriteClientRecordingInfo(const CPVRRecording &xbmcRecording, PVR_RECORDING &addonRecording); - - /*! - * @brief Copy over group info from xbmcGroup to addonGroup. - * @param xbmcGroup The group on XBMC's side. - * @param addonGroup The group on the addon's side. - */ - void WriteClientGroupInfo(const CPVRChannelGroup &xbmcGroup, PVR_CHANNEL_GROUP &addonGroup); - /*! * @brief Get the backend name from the server and store it locally. */ From 3508474ae2a56c485641b386fe30175f9bb18363 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Sun, 24 Apr 2011 11:26:49 +0200 Subject: [PATCH 30/47] pvr: don't update the timers table directly when the epg sends a notification but update it async. fixes possible deadlock --- xbmc/pvr/recordings/PVRRecordings.cpp | 2 +- xbmc/pvr/timers/PVRTimers.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/xbmc/pvr/recordings/PVRRecordings.cpp b/xbmc/pvr/recordings/PVRRecordings.cpp index 788ab38286844..74be2c9f19212 100644 --- a/xbmc/pvr/recordings/PVRRecordings.cpp +++ b/xbmc/pvr/recordings/PVRRecordings.cpp @@ -198,7 +198,7 @@ void CPVRRecordings::ExecuteUpdate(void) void CPVRRecordings::Process(void) { - Update(false); + ExecuteUpdate(); } int CPVRRecordings::GetNumRecordings() diff --git a/xbmc/pvr/timers/PVRTimers.cpp b/xbmc/pvr/timers/PVRTimers.cpp index dd7e24f099f8d..ab3f19c343c08 100644 --- a/xbmc/pvr/timers/PVRTimers.cpp +++ b/xbmc/pvr/timers/PVRTimers.cpp @@ -628,5 +628,5 @@ CPVRTimerInfoTag *CPVRTimers::GetMatch(const CFileItem *item) void CPVRTimers::Notify(const Observable &obs, const CStdString& msg) { if (msg.Equals("epg")) - Update(); + g_PVRManager.TriggerTimersUpdate(); } From 24aef08a865cfe9be9e1c65f467ec63fa074820f Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Sun, 24 Apr 2011 13:10:35 +0200 Subject: [PATCH 31/47] pvr: added new guisetting that makes the pvrmanager always use the backend channel order --- language/Dutch/strings.xml | 1 + language/English/strings.xml | 1 + xbmc/pvr/channels/PVRChannelGroup.cpp | 9 ++++++--- xbmc/pvr/channels/PVRChannelGroupInternal.cpp | 4 ++-- xbmc/settings/GUISettings.cpp | 1 + 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/language/Dutch/strings.xml b/language/Dutch/strings.xml index 9ad7ab9d274e0..35b9f296446d5 100644 --- a/language/Dutch/strings.xml +++ b/language/Dutch/strings.xml @@ -1629,6 +1629,7 @@ Opname verwijderd Sluit kanelen OSD na wijzigen kanaal Geen EPG updates tijdens het afspelen van een TV stream + Gebruik altijd de volgorde van kanalen van backend(s) Anders/Onbekend Film/Drama diff --git a/language/English/strings.xml b/language/English/strings.xml index b2c9f8c2b9097..d6e240ddffd5f 100644 --- a/language/English/strings.xml +++ b/language/English/strings.xml @@ -1757,6 +1757,7 @@ Recording deleted Close channel OSD after switching channels Prevent EPG updates while playing a TV stream + Always use the channel order from the backend(s) Other/Unknown Movie/Drama diff --git a/xbmc/pvr/channels/PVRChannelGroup.cpp b/xbmc/pvr/channels/PVRChannelGroup.cpp index 8656abbd983cc..7c6fd17f9be1d 100644 --- a/xbmc/pvr/channels/PVRChannelGroup.cpp +++ b/xbmc/pvr/channels/PVRChannelGroup.cpp @@ -531,8 +531,8 @@ bool CPVRChannelGroup::UpdateGroupEntries(const CPVRChannelGroup &channels) if (bChanged) { - /* sort by client channel number if this is the first time */ - if (iCurSize == 0) + /* sort by client channel number if this is the first time or if pvrmanager.backendchannelorder is true */ + if (iCurSize == 0 || g_guiSettings.GetBool("pvrmanager.backendchannelorder")) SortByClientChannelNumber(); /* renumber to make sure all channels have a channel number. @@ -626,7 +626,10 @@ bool CPVRChannelGroup::AddToGroup(CPVRChannel *channel, int iChannelNumber /* = if (bSortAndRenumber) { - SortByChannelNumber(); + if (g_guiSettings.GetBool("pvrmanager.backendchannelorder")) + SortByClientChannelNumber(); + else + SortByChannelNumber(); Renumber(); } diff --git a/xbmc/pvr/channels/PVRChannelGroupInternal.cpp b/xbmc/pvr/channels/PVRChannelGroupInternal.cpp index b66e31da353f3..74ce414430775 100644 --- a/xbmc/pvr/channels/PVRChannelGroupInternal.cpp +++ b/xbmc/pvr/channels/PVRChannelGroupInternal.cpp @@ -379,8 +379,8 @@ bool CPVRChannelGroupInternal::UpdateGroupEntries(const CPVRChannelGroup &channe /* remove invalid channels */ RemoveInvalidChannels(); - /* sort by client channel number if this is the first time */ - if (iCurSize == 0) + /* sort by client channel number if this is the first time or if pvrmanager.backendchannelorder is true */ + if (iCurSize == 0 || g_guiSettings.GetBool("pvrmanager.backendchannelorder")) SortByClientChannelNumber(); /* renumber to make sure all channels have a channel number. diff --git a/xbmc/settings/GUISettings.cpp b/xbmc/settings/GUISettings.cpp index ad81dba080643..15758f3f54853 100644 --- a/xbmc/settings/GUISettings.cpp +++ b/xbmc/settings/GUISettings.cpp @@ -796,6 +796,7 @@ void CGUISettings::Initialize() CSettingsCategory* pvr = AddCategory(8, "pvrmanager", 128); AddBool(pvr, "pvrmanager.enabled", 449, false); AddBool(pvr, "pvrmanager.syncchannelgroups", 19221, true); + AddBool(pvr, "pvrmanager.backendchannelorder", 19231, false); AddString(pvr, "pvrmanager.channelmanager", 19199, "", BUTTON_CONTROL_STANDARD); AddString(pvr, "pvrmanager.channelscan", 19117, "", BUTTON_CONTROL_STANDARD); AddString(pvr, "pvrmanager.resetdb", 19185, "", BUTTON_CONTROL_STANDARD); From 7106c6fccda8744702ffe77f089a4063fd0447e7 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Sun, 24 Apr 2011 13:53:11 +0200 Subject: [PATCH 32/47] let the guisettings dialog notify observers when settings changed --- xbmc/settings/GUISettings.cpp | 41 ++++----------------- xbmc/settings/GUISettings.h | 2 - xbmc/settings/GUIWindowSettingsCategory.cpp | 2 + 3 files changed, 10 insertions(+), 35 deletions(-) diff --git a/xbmc/settings/GUISettings.cpp b/xbmc/settings/GUISettings.cpp index 15758f3f54853..01125fdc702e4 100644 --- a/xbmc/settings/GUISettings.cpp +++ b/xbmc/settings/GUISettings.cpp @@ -886,8 +886,6 @@ void CGUISettings::AddBool(CSettingsCategory* cat, const char *strSetting, int i CSettingBool* pSetting = new CSettingBool(iOrder, CStdString(strSetting).ToLower(), iLabel, bData, iControlType); if (!pSetting) return ; settingsMap.insert(pair(CStdString(strSetting).ToLower(), pSetting)); - - SetChangedAndNotify(); } bool CGUISettings::GetBool(const char *strSetting) const { @@ -915,7 +913,7 @@ void CGUISettings::SetBool(const char *strSetting, bool bSetting) { // old category ((CSettingBool*)(*it).second)->SetData(bSetting); - SetChangedAndNotify(); + SetChanged(); return ; } @@ -931,7 +929,7 @@ void CGUISettings::ToggleBool(const char *strSetting) { // old category ((CSettingBool*)(*it).second)->SetData(!((CSettingBool *)(*it).second)->GetData()); - SetChangedAndNotify(); + SetChanged(); return ; } @@ -945,8 +943,6 @@ void CGUISettings::AddFloat(CSettingsCategory* cat, const char *strSetting, int CSettingFloat* pSetting = new CSettingFloat(iOrder, CStdString(strSetting).ToLower(), iLabel, fData, fMin, fStep, fMax, iControlType); if (!pSetting) return ; settingsMap.insert(pair(CStdString(strSetting).ToLower(), pSetting)); - - SetChangedAndNotify(); } float CGUISettings::GetFloat(const char *strSetting) const @@ -971,7 +967,7 @@ void CGUISettings::SetFloat(const char *strSetting, float fSetting) { ((CSettingFloat *)(*it).second)->SetData(fSetting); - SetChangedAndNotify(); + SetChanged(); return ; } @@ -997,8 +993,6 @@ void CGUISettings::AddInt(CSettingsCategory* cat, const char *strSetting, int iL CSettingInt* pSetting = new CSettingInt(iOrder, CStdString(strSetting).ToLower(), iLabel, iData, iMin, iStep, iMax, iControlType, strFormat); if (!pSetting) return ; settingsMap.insert(pair(CStdString(strSetting).ToLower(), pSetting)); - - SetChangedAndNotify(); } void CGUISettings::AddInt(CSettingsCategory* cat, const char *strSetting, int iLabel, int iData, int iMin, int iStep, int iMax, int iControlType, int iFormat, int iLabelMin/*=-1*/) @@ -1007,8 +1001,6 @@ void CGUISettings::AddInt(CSettingsCategory* cat, const char *strSetting, int iL CSettingInt* pSetting = new CSettingInt(iOrder, CStdString(strSetting).ToLower(), iLabel, iData, iMin, iStep, iMax, iControlType, iFormat, iLabelMin); if (!pSetting) return ; settingsMap.insert(pair(CStdString(strSetting).ToLower(), pSetting)); - - SetChangedAndNotify(); } void CGUISettings::AddInt(CSettingsCategory* cat, const char *strSetting, @@ -1019,8 +1011,6 @@ void CGUISettings::AddInt(CSettingsCategory* cat, const char *strSetting, CSettingInt* pSetting = new CSettingInt(iOrder, CStdString(strSetting).ToLower(), iLabel, iData, entries, iControlType); if (!pSetting) return ; settingsMap.insert(pair(CStdString(strSetting).ToLower(), pSetting)); - - SetChangedAndNotify(); } void CGUISettings::AddHex(CSettingsCategory* cat, const char *strSetting, int iLabel, int iData, int iMin, int iStep, int iMax, int iControlType, const char *strFormat) @@ -1029,8 +1019,6 @@ void CGUISettings::AddHex(CSettingsCategory* cat, const char *strSetting, int iL CSettingHex* pSetting = new CSettingHex(iOrder, CStdString(strSetting).ToLower(), iLabel, iData, iMin, iStep, iMax, iControlType, strFormat); if (!pSetting) return ; settingsMap.insert(pair(CStdString(strSetting).ToLower(), pSetting)); - - SetChangedAndNotify(); } int CGUISettings::GetInt(const char *strSetting) const @@ -1056,7 +1044,7 @@ void CGUISettings::SetInt(const char *strSetting, int iSetting) { ((CSettingInt *)(*it).second)->SetData(iSetting); - SetChangedAndNotify(); + SetChanged(); return ; } @@ -1070,8 +1058,6 @@ void CGUISettings::AddString(CSettingsCategory* cat, const char *strSetting, int CSettingString* pSetting = new CSettingString(iOrder, CStdString(strSetting).ToLower(), iLabel, strData, iControlType, bAllowEmpty, iHeadingString); if (!pSetting) return ; settingsMap.insert(pair(CStdString(strSetting).ToLower(), pSetting)); - - SetChangedAndNotify(); } void CGUISettings::AddPath(CSettingsCategory* cat, const char *strSetting, int iLabel, const char *strData, int iControlType, bool bAllowEmpty, int iHeadingString) @@ -1080,8 +1066,6 @@ void CGUISettings::AddPath(CSettingsCategory* cat, const char *strSetting, int i CSettingPath* pSetting = new CSettingPath(iOrder, CStdString(strSetting).ToLower(), iLabel, strData, iControlType, bAllowEmpty, iHeadingString); if (!pSetting) return ; settingsMap.insert(pair(CStdString(strSetting).ToLower(), pSetting)); - - SetChangedAndNotify(); } void CGUISettings::AddDefaultAddon(CSettingsCategory* cat, const char *strSetting, int iLabel, const char *strData, const TYPE type) @@ -1090,8 +1074,6 @@ void CGUISettings::AddDefaultAddon(CSettingsCategory* cat, const char *strSettin CSettingAddon* pSetting = new CSettingAddon(iOrder, CStdString(strSetting).ToLower(), iLabel, strData, type); if (!pSetting) return ; settingsMap.insert(pair(CStdString(strSetting).ToLower(), pSetting)); - - SetChangedAndNotify(); } const CStdString &CGUISettings::GetString(const char *strSetting, bool bPrompt) const @@ -1136,7 +1118,7 @@ void CGUISettings::SetString(const char *strSetting, const char *strData) { ((CSettingString *)(*it).second)->SetData(strData); - SetChangedAndNotify(); + SetChanged(); return ; } @@ -1269,7 +1251,7 @@ void CGUISettings::LoadFromXML(TiXmlElement *pRootElement, mapIter &it, bool adv } } - SetChangedAndNotify(); + SetChanged(); } void CGUISettings::SaveXML(TiXmlNode *pRootNode) @@ -1307,7 +1289,7 @@ void CGUISettings::SaveXML(TiXmlNode *pRootNode) } } - SetChangedAndNotify(); + SetChanged(); } void CGUISettings::Clear() @@ -1320,13 +1302,6 @@ void CGUISettings::Clear() settingsGroups.clear(); SetChanged(); - NotifyObservers("settings", true); -} - -void CGUISettings::SetChangedAndNotify(void) -{ - SetChanged(); - NotifyObservers("settings", true); } float square_error(float x, float y) @@ -1394,5 +1369,5 @@ void CGUISettings::SetResolution(RESOLUTION res) SetString("videoscreen.screenmode", mode); m_LookAndFeelResolution = res; - SetChangedAndNotify(); + SetChanged(); } diff --git a/xbmc/settings/GUISettings.h b/xbmc/settings/GUISettings.h index f445f51ce7e85..1a54f4c7f5fa6 100644 --- a/xbmc/settings/GUISettings.h +++ b/xbmc/settings/GUISettings.h @@ -494,8 +494,6 @@ class CGUISettings : public Observable void Clear(); - void SetChangedAndNotify(void); - private: typedef std::map::iterator mapIter; typedef std::map::const_iterator constMapIter; diff --git a/xbmc/settings/GUIWindowSettingsCategory.cpp b/xbmc/settings/GUIWindowSettingsCategory.cpp index bc06201ef1ece..8603421248d04 100644 --- a/xbmc/settings/GUIWindowSettingsCategory.cpp +++ b/xbmc/settings/GUIWindowSettingsCategory.cpp @@ -1077,6 +1077,8 @@ void CGUIWindowSettingsCategory::UpdateSettings() } #endif } + + g_guiSettings.NotifyObservers("settings", true); } void CGUIWindowSettingsCategory::UpdateRealTimeSettings() From 2e56e1effb0fc374353fd21b1c5d70b3a4b1b717 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Sun, 24 Apr 2011 14:43:13 +0200 Subject: [PATCH 33/47] pvr: renumber the channel groups if needed after the user changes the guisetting --- xbmc/pvr/channels/PVRChannelGroup.cpp | 81 ++++++++++++------- xbmc/pvr/channels/PVRChannelGroup.h | 18 +++-- xbmc/pvr/channels/PVRChannelGroupInternal.cpp | 2 +- 3 files changed, 66 insertions(+), 35 deletions(-) diff --git a/xbmc/pvr/channels/PVRChannelGroup.cpp b/xbmc/pvr/channels/PVRChannelGroup.cpp index 7c6fd17f9be1d..c99717c4ec4b2 100644 --- a/xbmc/pvr/channels/PVRChannelGroup.cpp +++ b/xbmc/pvr/channels/PVRChannelGroup.cpp @@ -40,37 +40,37 @@ using namespace PVR; -CPVRChannelGroup::CPVRChannelGroup(bool bRadio, unsigned int iGroupId, const CStdString &strGroupName, int iSortOrder) -{ - m_bRadio = bRadio; - m_iGroupId = iGroupId; - m_strGroupName = strGroupName; - m_iSortOrder = iSortOrder; - m_bLoaded = false; - m_bChanged = false; - clear(); +CPVRChannelGroup::CPVRChannelGroup(bool bRadio, unsigned int iGroupId, const CStdString &strGroupName, int iSortOrder) : + m_bRadio(bRadio), + m_iGroupId(iGroupId), + m_strGroupName(strGroupName), + m_iSortOrder(iSortOrder), + m_bLoaded(false), + m_bChanged(false), + m_bUsingBackendChannelOrder(false) +{ } -CPVRChannelGroup::CPVRChannelGroup(bool bRadio) +CPVRChannelGroup::CPVRChannelGroup(bool bRadio) : + m_bRadio(bRadio), + m_iGroupId(-1), + m_strGroupName(""), + m_iSortOrder(-1), + m_bLoaded(false), + m_bChanged(false), + m_bUsingBackendChannelOrder(false) { - m_bRadio = bRadio; - m_iGroupId = -1; - m_strGroupName.clear(); - m_iSortOrder = -1; - m_bLoaded = false; - m_bChanged = false; - clear(); } -CPVRChannelGroup::CPVRChannelGroup(const PVR_CHANNEL_GROUP &group) +CPVRChannelGroup::CPVRChannelGroup(const PVR_CHANNEL_GROUP &group) : + m_bRadio(group.bIsRadio), + m_iGroupId(-1), + m_strGroupName(group.strGroupName), + m_iSortOrder(-1), + m_bLoaded(false), + m_bChanged(false), + m_bUsingBackendChannelOrder(false) { - m_bRadio = group.bIsRadio; - m_iGroupId = -1; - m_strGroupName = group.strGroupName; - m_iSortOrder = -1; - m_bLoaded = false; - m_bChanged = false; - clear(); } CPVRChannelGroup::~CPVRChannelGroup(void) @@ -95,6 +95,8 @@ int CPVRChannelGroup::Load(void) /* make sure this container is empty before loading */ Unload(); + m_bUsingBackendChannelOrder = g_guiSettings.GetBool("pvrmanager.backendchannelorder"); + int iChannelCount = LoadFromDb(); CLog::Log(LOGDEBUG, "PVRChannelGroup - %s - %d channels loaded from the database for group '%s'", __FUNCTION__, iChannelCount, m_strGroupName.c_str()); @@ -106,6 +108,7 @@ int CPVRChannelGroup::Load(void) __FUNCTION__, (int) size() - iChannelCount, m_strGroupName.c_str()); } + g_guiSettings.AddObserver(this); m_bLoaded = true; return size(); @@ -532,7 +535,7 @@ bool CPVRChannelGroup::UpdateGroupEntries(const CPVRChannelGroup &channels) if (bChanged) { /* sort by client channel number if this is the first time or if pvrmanager.backendchannelorder is true */ - if (iCurSize == 0 || g_guiSettings.GetBool("pvrmanager.backendchannelorder")) + if (iCurSize == 0 || m_bUsingBackendChannelOrder) SortByClientChannelNumber(); /* renumber to make sure all channels have a channel number. @@ -626,7 +629,7 @@ bool CPVRChannelGroup::AddToGroup(CPVRChannel *channel, int iChannelNumber /* = if (bSortAndRenumber) { - if (g_guiSettings.GetBool("pvrmanager.backendchannelorder")) + if (m_bUsingBackendChannelOrder) SortByClientChannelNumber(); else SortByChannelNumber(); @@ -793,3 +796,27 @@ void CPVRChannelGroup::SetSelectedGroup(void) for (unsigned int iChannelPtr = 0; iChannelPtr < size(); iChannelPtr++) at(iChannelPtr).channel->SetCachedChannelNumber(iChannelNumber++); } + +void CPVRChannelGroup::Notify(const Observable &obs, const CStdString& msg) +{ + if (msg.Equals("settings")) + { + bool bUsingBackendChannelOrder = g_guiSettings.GetBool("pvrmanager.backendchannelorder"); + + CSingleLock lock(m_critSection); + if (m_bUsingBackendChannelOrder != bUsingBackendChannelOrder) + { + m_bUsingBackendChannelOrder = bUsingBackendChannelOrder; + + if (m_bUsingBackendChannelOrder) + { + CLog::Log(LOGDEBUG, "CPVRChannelGroup - %s - renumbering group '%s' to use the backend channel order", + __FUNCTION__, m_strGroupName.c_str()); + m_bUsingBackendChannelOrder = bUsingBackendChannelOrder; + SortByClientChannelNumber(); + Renumber(); + Persist(); + } + } + } +} diff --git a/xbmc/pvr/channels/PVRChannelGroup.h b/xbmc/pvr/channels/PVRChannelGroup.h index 3884ae92ffd00..a7ac495d15e7e 100644 --- a/xbmc/pvr/channels/PVRChannelGroup.h +++ b/xbmc/pvr/channels/PVRChannelGroup.h @@ -39,19 +39,21 @@ namespace PVR /** A group of channels */ - class CPVRChannelGroup : private std::vector + class CPVRChannelGroup : private std::vector, + private Observer { friend class CPVRChannelGroups; friend class CPVRChannelGroupInternal; friend class CPVRDatabase; private: - bool m_bRadio; /*!< true if this container holds radio channels, false if it holds TV channels */ - int m_iGroupId; /*!< The ID of this group in the database */ - CStdString m_strGroupName; /*!< The name of this group */ - int m_iSortOrder; /*!< The sort order to use */ - bool m_bLoaded; /*!< True if this container is loaded, false otherwise */ - bool m_bChanged; /*!< true if anything changed in this group that hasn't been persisted, false otherwise */ + bool m_bRadio; /*!< true if this container holds radio channels, false if it holds TV channels */ + int m_iGroupId; /*!< The ID of this group in the database */ + CStdString m_strGroupName; /*!< The name of this group */ + int m_iSortOrder; /*!< The sort order to use */ + bool m_bLoaded; /*!< True if this container is loaded, false otherwise */ + bool m_bChanged; /*!< true if anything changed in this group that hasn't been persisted, false otherwise */ + bool m_bUsingBackendChannelOrder; /*!< true to use the channel order from backends, false otherwise */ CCriticalSection m_critSection; /*! @@ -272,6 +274,8 @@ namespace PVR virtual void SetSelectedGroup(void); virtual void ResetChannelNumbers(void); + virtual void Notify(const Observable &obs, const CStdString& msg); + /*! @name getters */ //@{ diff --git a/xbmc/pvr/channels/PVRChannelGroupInternal.cpp b/xbmc/pvr/channels/PVRChannelGroupInternal.cpp index 74ce414430775..3d1ee921f4283 100644 --- a/xbmc/pvr/channels/PVRChannelGroupInternal.cpp +++ b/xbmc/pvr/channels/PVRChannelGroupInternal.cpp @@ -380,7 +380,7 @@ bool CPVRChannelGroupInternal::UpdateGroupEntries(const CPVRChannelGroup &channe RemoveInvalidChannels(); /* sort by client channel number if this is the first time or if pvrmanager.backendchannelorder is true */ - if (iCurSize == 0 || g_guiSettings.GetBool("pvrmanager.backendchannelorder")) + if (iCurSize == 0 || m_bUsingBackendChannelOrder) SortByClientChannelNumber(); /* renumber to make sure all channels have a channel number. From bb6a14cd6ac76cd37b74ff7ca6f8404548a3dfed Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Sun, 24 Apr 2011 14:55:04 +0200 Subject: [PATCH 34/47] always mark the observable changed after changing guisettings --- xbmc/settings/GUIWindowSettingsCategory.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/xbmc/settings/GUIWindowSettingsCategory.cpp b/xbmc/settings/GUIWindowSettingsCategory.cpp index 8603421248d04..6f23c5f6f15f9 100644 --- a/xbmc/settings/GUIWindowSettingsCategory.cpp +++ b/xbmc/settings/GUIWindowSettingsCategory.cpp @@ -1078,6 +1078,7 @@ void CGUIWindowSettingsCategory::UpdateSettings() #endif } + g_guiSettings.SetChanged(); g_guiSettings.NotifyObservers("settings", true); } From c4a42f6c64517646a10a48ffda7b6dcffb7dbb8c Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Sun, 24 Apr 2011 15:14:55 +0200 Subject: [PATCH 35/47] fix async observable messages --- xbmc/utils/Observer.cpp | 26 ++++++++------------------ xbmc/utils/Observer.h | 2 +- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/xbmc/utils/Observer.cpp b/xbmc/utils/Observer.cpp index 6206f9653e818..bbfb10c864930 100644 --- a/xbmc/utils/Observer.cpp +++ b/xbmc/utils/Observer.cpp @@ -76,7 +76,7 @@ void Observable::NotifyObservers(const CStdString& strMessage /* = "" */, bool b if (bAsync && m_bAsyncAllowed) CJobManager::GetInstance().AddJob(new ObservableMessageJob(*this, strMessage), NULL); else - SendMessage(this, strMessage); + SendMessage(this, &m_observers, strMessage); m_bObservableChanged = false; } @@ -97,21 +97,13 @@ void Observable::Announce(EAnnouncementFlag flag, const char *sender, const char } } -void Observable::SendMessage(Observable *obs, const CStdString &strMessage) +void Observable::SendMessage(Observable *obs, const vector *observers, const CStdString &strMessage) { - for(unsigned int ptr = 0; ptr < obs->m_observers.size(); ptr++) + for(unsigned int ptr = 0; ptr < observers->size(); ptr++) { - Observer *observer = obs->m_observers.at(ptr); - if (!observer) - { - /* the observable no longer exists. delete it */ - obs->m_observers.erase(obs->m_observers.begin() + ptr); - ptr--; - } - else - { - obs->m_observers.at(ptr)->Notify(*obs, strMessage); - } + Observer *observer = observers->at(ptr); + if (observer) + observer->Notify(*obs, strMessage); } } @@ -119,14 +111,12 @@ ObservableMessageJob::ObservableMessageJob(const Observable &obs, const CStdStri { m_strMessage = strMessage; m_observable = obs; - - for (unsigned int iObserverPtr = 0; iObserverPtr < obs.m_observers.size(); iObserverPtr++) - m_observers.push_back(obs.m_observers.at(iObserverPtr)); + m_observers = obs.m_observers; } bool ObservableMessageJob::DoWork() { - Observable::SendMessage(&m_observable, m_strMessage); + Observable::SendMessage(&m_observable, &m_observers, m_strMessage); return true; } diff --git a/xbmc/utils/Observer.h b/xbmc/utils/Observer.h index ffffde570526a..5fe54af857f4e 100644 --- a/xbmc/utils/Observer.h +++ b/xbmc/utils/Observer.h @@ -52,7 +52,7 @@ class Observable : public ANNOUNCEMENT::IAnnouncer virtual void Announce(ANNOUNCEMENT::EAnnouncementFlag flag, const char *sender, const char *message, const CVariant &data); private: - static void SendMessage(Observable *obs, const CStdString &strMessage); + static void SendMessage(Observable *obs, const std::vector *observers, const CStdString &strMessage); bool m_bObservableChanged; std::vector m_observers; From de0e22adc23bb5ffc832765adda0a010bb72d508 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Mon, 25 Apr 2011 12:33:28 +0200 Subject: [PATCH 36/47] pvr: clean up and fix channel group updates --- xbmc/pvr/PVRManager.cpp | 2 +- xbmc/pvr/PVRManager.h | 2 +- xbmc/pvr/channels/PVRChannel.cpp | 19 +-- xbmc/pvr/channels/PVRChannelGroup.cpp | 97 ++++++++------ xbmc/pvr/channels/PVRChannelGroup.h | 3 + xbmc/pvr/channels/PVRChannelGroupInternal.cpp | 119 ++++++------------ xbmc/pvr/channels/PVRChannelGroupInternal.h | 2 + xbmc/pvr/channels/PVRChannelGroups.cpp | 4 +- xbmc/pvr/channels/PVRChannelGroups.h | 2 +- .../channels/PVRChannelGroupsContainer.cpp | 2 +- xbmc/pvr/channels/PVRChannelGroupsContainer.h | 6 +- xbmc/pvr/dialogs/GUIDialogPVRGroupManager.cpp | 2 +- .../pvr/dialogs/GUIDialogPVRTimerSettings.cpp | 2 +- xbmc/pvr/windows/GUIWindowPVRChannels.cpp | 16 +-- xbmc/pvr/windows/GUIWindowPVRChannels.h | 2 +- 15 files changed, 134 insertions(+), 146 deletions(-) diff --git a/xbmc/pvr/PVRManager.cpp b/xbmc/pvr/PVRManager.cpp index 650f460796542..efe174bcc3f53 100644 --- a/xbmc/pvr/PVRManager.cpp +++ b/xbmc/pvr/PVRManager.cpp @@ -671,7 +671,7 @@ void CPVRManager::SetPlayingGroup(CPVRChannelGroup *group) group->SetSelectedGroup(); } -const CPVRChannelGroup *CPVRManager::GetPlayingGroup(bool bRadio /* = false */) +CPVRChannelGroup *CPVRManager::GetPlayingGroup(bool bRadio /* = false */) { CSingleLock lock(m_critSection); diff --git a/xbmc/pvr/PVRManager.h b/xbmc/pvr/PVRManager.h index cdd36c8faa67c..bdf0b31a1cf50 100644 --- a/xbmc/pvr/PVRManager.h +++ b/xbmc/pvr/PVRManager.h @@ -254,7 +254,7 @@ namespace PVR * @param bRadio True to get the current radio group, false to get the current TV group. * @return The current group or the group containing all channels if it's not set. */ - const CPVRChannelGroup *GetPlayingGroup(bool bRadio = false); + CPVRChannelGroup *GetPlayingGroup(bool bRadio = false); /*! * @brief Let the background thread update the recordings list. diff --git a/xbmc/pvr/channels/PVRChannel.cpp b/xbmc/pvr/channels/PVRChannel.cpp index 66375bac214a2..844aafdc139cb 100644 --- a/xbmc/pvr/channels/PVRChannel.cpp +++ b/xbmc/pvr/channels/PVRChannel.cpp @@ -240,28 +240,31 @@ bool CPVRChannel::UpdateFromClient(const CPVRChannel &channel) bool CPVRChannel::Persist(bool bQueueWrite /* = false */) { + bool bReturn(true); CSingleLock lock(m_critSection); - if (!m_bChanged) - return true; + if (!m_bChanged && m_iChannelId > 0) + return bReturn; if (CPVRDatabase *database = OpenPVRDatabase()) { if (!bQueueWrite) { - database->Open(); m_iChannelId = database->Persist(*this, false); m_bChanged = false; - database->Close(); - return m_iChannelId > 0; + bReturn = m_iChannelId > 0; } else { - database->Persist(*this, true); - return true; + bReturn = database->Persist(*this, true) > 0; } + database->Close(); + } + else + { + bReturn = false; } - return false; + return bReturn; } bool CPVRChannel::SetChannelID(int iChannelId, bool bSaveInDb /* = false */) diff --git a/xbmc/pvr/channels/PVRChannelGroup.cpp b/xbmc/pvr/channels/PVRChannelGroup.cpp index c99717c4ec4b2..1efe2f58c06d2 100644 --- a/xbmc/pvr/channels/PVRChannelGroup.cpp +++ b/xbmc/pvr/channels/PVRChannelGroup.cpp @@ -473,69 +473,92 @@ bool CPVRChannelGroup::RemoveByUniqueID(int iUniqueID) return false; } -bool CPVRChannelGroup::UpdateGroupEntries(const CPVRChannelGroup &channels) +bool CPVRChannelGroup::AddAndUpdateChannels(const CPVRChannelGroup &channels, bool bUseBackendChannelNumbers) { - bool bChanged(false); - bool bAddedOrDeleted(false); + bool bReturn(false); CSingleLock lock(m_critSection); - int iCurSize = size(); - - CPVRDatabase *database = OpenPVRDatabase(); - if (!database) - return false; - /* go through the channel list and check for updated or new channels */ + /* go through the channel list and check for new channels. + channels will only by updated in CPVRChannelGroupInternal to prevent dupe updates */ for (unsigned int iChannelPtr = 0; iChannelPtr < channels.size(); iChannelPtr++) { - CPVRChannel *channel = channels.at(iChannelPtr).channel; - int iChannelNumber = channels.at(iChannelPtr).iChannelNumber; - if (!channel) + PVRChannelGroupMember member = channels.at(iChannelPtr); + if (!member.channel) continue; - CPVRChannel *realChannel = (CPVRChannel *) g_PVRChannelGroups->GetGroupAll(m_bRadio)->GetByClient(channel->UniqueID(), channel->ClientID()); - if (!realChannel) + /* check whether this channel is known in the internal group */ + CPVRChannel *existingChannel = (CPVRChannel *) g_PVRChannelGroups->GetGroupAll(m_bRadio)->GetByClient(member.channel->UniqueID(), member.channel->ClientID()); + if (!existingChannel) continue; - if (!IsGroupMember(realChannel)) + /* if it's found, add the channel to this group */ + if (!IsGroupMember(existingChannel)) { - AddToGroup(realChannel, iChannelNumber, false); + int iChannelNumber = bUseBackendChannelNumbers ? member.channel->ClientChannelNumber() : 0; + AddToGroup(existingChannel, iChannelNumber, false); - bChanged = true; - m_bChanged = true; - bAddedOrDeleted = true; + bReturn = true; CLog::Log(LOGINFO,"PVRChannelGroup - %s - added %s channel '%s' at position %d in group '%s'", - __FUNCTION__, m_bRadio ? "radio" : "TV", realChannel->ChannelName().c_str(), iChannelNumber, GroupName().c_str()); + __FUNCTION__, m_bRadio ? "radio" : "TV", existingChannel->ChannelName().c_str(), iChannelNumber, GroupName().c_str()); } } + return bReturn; +} + +bool CPVRChannelGroup::RemoveDeletedChannels(const CPVRChannelGroup &channels) +{ + bool bReturn(false); + CSingleLock lock(m_critSection); + /* check for deleted channels */ unsigned int iSize = size(); for (unsigned int iChannelPtr = 0; iChannelPtr < iSize; iChannelPtr++) { - CPVRChannel *channel = (CPVRChannel *) GetByIndex(iChannelPtr); + CPVRChannel *channel = at(iChannelPtr).channel; if (!channel) continue; + if (channels.GetByClient(channel->UniqueID(), channel->ClientID()) == NULL) { /* channel was not found */ CLog::Log(LOGINFO,"PVRChannelGroup - %s - deleted %s channel '%s' from group '%s'", __FUNCTION__, m_bRadio ? "radio" : "TV", channel->ChannelName().c_str(), GroupName().c_str()); - /* remove this channel from all non-system groups */ - RemoveFromGroup(channel); + /* remove this channel from all non-system groups if this is the internal group */ + if (IsInternalGroup()) + g_PVRChannelGroups->Get(m_bRadio)->RemoveFromAllGroups(channel); + else + RemoveFromGroup(channel); - m_bChanged = true; - bAddedOrDeleted = true; - bChanged = true; + bReturn = true; iChannelPtr--; iSize--; } } + return bReturn; +} + +bool CPVRChannelGroup::UpdateGroupEntries(const CPVRChannelGroup &channels) +{ + bool bReturn(false); + bool bChanged(false); + + CSingleLock lock(m_critSection); + /* sort by client channel number if this is the first time or if pvrmanager.backendchannelorder is true */ + bool bUseBackendChannelNumbers(size() == 0 || m_bUsingBackendChannelOrder); + + CPVRDatabase *database = OpenPVRDatabase(); + if (!database) + return bReturn; + + bChanged = AddAndUpdateChannels(channels, bUseBackendChannelNumbers); + bChanged = RemoveDeletedChannels(channels) || bChanged; + if (bChanged) { - /* sort by client channel number if this is the first time or if pvrmanager.backendchannelorder is true */ - if (iCurSize == 0 || m_bUsingBackendChannelOrder) + if (bUseBackendChannelNumbers) SortByClientChannelNumber(); /* renumber to make sure all channels have a channel number. @@ -544,12 +567,18 @@ bool CPVRChannelGroup::UpdateGroupEntries(const CPVRChannelGroup &channels) lock.Leave(); - g_PVRManager.UpdateWindow(m_bRadio ? PVR_WINDOW_CHANNELS_RADIO : PVR_WINDOW_CHANNELS_TV, bAddedOrDeleted); + g_PVRManager.UpdateWindow(m_bRadio ? PVR_WINDOW_CHANNELS_RADIO : PVR_WINDOW_CHANNELS_TV, true); // TODO always doing a refresh now - return Persist(); + bReturn = Persist(); + } + else + { + bReturn = true; } - return true; + database->Close(); + + return bReturn; } void CPVRChannelGroup::RemoveInvalidChannels(void) @@ -619,7 +648,7 @@ bool CPVRChannelGroup::AddToGroup(CPVRChannel *channel, int iChannelNumber /* = CPVRChannel *realChannel = (IsInternalGroup()) ? channel : - (CPVRChannel *) g_PVRChannelGroups->GetGroupAll(m_bRadio)->GetByChannelID(channel->ChannelID()); + (CPVRChannel *) g_PVRChannelGroups->GetGroupAll(m_bRadio)->GetByClient(channel->UniqueID(), channel->ClientID()); if (realChannel) { @@ -770,11 +799,7 @@ void CPVRChannelGroup::CacheIcons(void) { CSingleLock lock(m_critSection); for (unsigned int iChannelPtr = 0; iChannelPtr < size(); iChannelPtr++) - { at(iChannelPtr).channel->CheckCachedIcon(); - } - - Persist(); } void CPVRChannelGroup::ResetChannelNumbers(void) diff --git a/xbmc/pvr/channels/PVRChannelGroup.h b/xbmc/pvr/channels/PVRChannelGroup.h index a7ac495d15e7e..7159e1ae2b476 100644 --- a/xbmc/pvr/channels/PVRChannelGroup.h +++ b/xbmc/pvr/channels/PVRChannelGroup.h @@ -74,6 +74,9 @@ namespace PVR */ virtual bool UpdateGroupEntries(const CPVRChannelGroup &channels); + virtual bool AddAndUpdateChannels(const CPVRChannelGroup &channels, bool bUseBackendChannelNumbers); + virtual bool RemoveDeletedChannels(const CPVRChannelGroup &channels); + /*! * @brief Remove invalid channels from this container. */ diff --git a/xbmc/pvr/channels/PVRChannelGroupInternal.cpp b/xbmc/pvr/channels/PVRChannelGroupInternal.cpp index 3d1ee921f4283..5dbf0aab70001 100644 --- a/xbmc/pvr/channels/PVRChannelGroupInternal.cpp +++ b/xbmc/pvr/channels/PVRChannelGroupInternal.cpp @@ -294,105 +294,64 @@ bool CPVRChannelGroupInternal::UpdateChannel(const CPVRChannel &channel) return updateChannel->Persist(!m_bLoaded); } -bool CPVRChannelGroupInternal::UpdateGroupEntries(const CPVRChannelGroup &channels) +bool CPVRChannelGroupInternal::AddAndUpdateChannels(const CPVRChannelGroup &channels, bool bUseBackendChannelNumbers) { - bool bChanged = false; - int iCurSize = size(); - - CPVRChannelGroup *newChannels = new CPVRChannelGroup(m_bRadio); - - CPVRDatabase *database = OpenPVRDatabase(); - if (!database) - return bChanged; + bool bReturn(false); + CSingleLock lock(m_critSection); /* go through the channel list and check for updated or new channels */ for (unsigned int iChannelPtr = 0; iChannelPtr < channels.size(); iChannelPtr++) { - const CPVRChannel *channel = channels.at(iChannelPtr).channel; + PVRChannelGroupMember member = channels.at(iChannelPtr); + if (!member.channel) + continue; - /* check if this channel is present in this container */ - CPVRChannel *existingChannel = (CPVRChannel *) GetByClient(channel->UniqueID(), channel->ClientID()); + /* check whether this channel is present in this container */ + CPVRChannel *existingChannel = (CPVRChannel *) GetByClient(member.channel->UniqueID(), member.channel->ClientID()); if (existingChannel) { /* if it's present, update the current tag */ - if (existingChannel->UpdateFromClient(*channel)) + if (existingChannel->UpdateFromClient(*member.channel)) { - bChanged = true; - + bReturn = true; CLog::Log(LOGINFO,"PVRChannelGroupInternal - %s - updated %s channel '%s'", - __FUNCTION__, m_bRadio ? "radio" : "TV", channel->ChannelName().c_str()); + __FUNCTION__, m_bRadio ? "radio" : "TV", member.channel->ChannelName().c_str()); } } else { /* new channel */ - CPVRChannel *newChannel = new CPVRChannel(m_bRadio); - newChannel->SetUniqueID(channel->UniqueID(), false); - newChannel->UpdateFromClient(*channel); - newChannels->AddToGroup(newChannel); - int iChannelNumber = iCurSize == 0 ? channel->ClientChannelNumber() : 0; + CPVRChannel *newChannel = new CPVRChannel(*member.channel); + + /* insert the new channel in this group */ + int iChannelNumber = bUseBackendChannelNumbers ? member.channel->ClientChannelNumber() : 0; InsertInGroup(newChannel, iChannelNumber, false); - bChanged = true; + bReturn = true; CLog::Log(LOGINFO,"PVRChannelGroupInternal - %s - added %s channel '%s' at position %d", - __FUNCTION__, m_bRadio ? "radio" : "TV", channel->ChannelName().c_str(), iChannelNumber); + __FUNCTION__, m_bRadio ? "radio" : "TV", member.channel->ChannelName().c_str(), iChannelNumber); } } - /* persist changes */ - for (unsigned int iChannelPtr = 0; iChannelPtr < newChannels->size(); iChannelPtr++) - ((CPVRChannel *) newChannels->GetByIndex(iChannelPtr))->Persist(false); /* write immediately to get a db id */ - delete newChannels; - - /* check for deleted channels */ - unsigned int iSize = size(); - for (unsigned int iChannelPtr = 0; iChannelPtr < iSize; iChannelPtr++) - { - CPVRChannel *channel = (CPVRChannel *) GetByIndex(iChannelPtr); - if (!channel) - continue; - if (channels.GetByClient(channel->UniqueID(), channel->ClientID()) == NULL) - { - /* channel was not found */ - CLog::Log(LOGINFO,"PVRChannelGroupInternal - %s - deleted %s channel '%s'", - __FUNCTION__, m_bRadio ? "radio" : "TV", channel->ChannelName().c_str()); - - /* remove this channel from all non-system groups */ - ((CPVRChannelGroups *) g_PVRChannelGroups->Get(m_bRadio))->RemoveFromAllGroups(channel); - - delete at(iChannelPtr).channel; - erase(begin() + iChannelPtr); - iChannelPtr--; - iSize--; - bChanged = true; - } - } - - database->Close(); + return bReturn; +} - /* try to find channel icons */ - SearchAndSetChannelIcons(); - CacheIcons(); +bool CPVRChannelGroupInternal::UpdateGroupEntries(const CPVRChannelGroup &channels) +{ + bool bReturn(false); - if (bChanged || HasChanges()) + if (CPVRChannelGroup::UpdateGroupEntries(channels)) { - /* remove invalid channels */ - RemoveInvalidChannels(); + /* try to find channel icons */ + SearchAndSetChannelIcons(); + Persist(); - /* sort by client channel number if this is the first time or if pvrmanager.backendchannelorder is true */ - if (iCurSize == 0 || m_bUsingBackendChannelOrder) - SortByClientChannelNumber(); + CacheIcons(); - /* renumber to make sure all channels have a channel number. - new channels were added at the back, so they'll get the highest numbers */ - Renumber(); - - return Persist(); - } - else - { - return true; + bReturn = true; } + + return bReturn; } bool CPVRChannelGroupInternal::Persist(void) @@ -403,6 +362,11 @@ bool CPVRChannelGroupInternal::Persist(void) bool bHasNewChannels = HasNewChannels(); bool bHasChangedChannels = HasChangedChannels(); + /* open the database */ + CPVRDatabase *database = OpenPVRDatabase(); + if (!database) + return false; + if (bHasNewChannels || bHasChangedChannels) CLog::Log(LOGDEBUG, "CPVRChannelGroupInternal - %s - persisting %d channels", __FUNCTION__, (int) size()); @@ -414,21 +378,17 @@ bool CPVRChannelGroupInternal::Persist(void) /* write directly to get channel ids */ for (unsigned int iChannelPtr = 0; iChannelPtr < size(); iChannelPtr++) { - if (!at(iChannelPtr).channel->Persist()) + CPVRChannel *channel = at(iChannelPtr).channel; + if (!channel->Persist()) { CLog::Log(LOGERROR, "CPVRChannelGroupInternal - %s - failed to persist channel '%s'", - __FUNCTION__, at(iChannelPtr).channel->ChannelName().c_str()); + __FUNCTION__, channel->ChannelName().c_str()); bReturn = false; } } } else if (bHasChangedChannels) { - /* open the database */ - CPVRDatabase *database = OpenPVRDatabase(); - if (!database) - return false; - /* queue queries */ for (unsigned int iChannelPtr = 0; iChannelPtr < size(); iChannelPtr++) at(iChannelPtr).channel->Persist(true); @@ -437,12 +397,11 @@ bool CPVRChannelGroupInternal::Persist(void) bReturn = database->CommitInsertQueries(); if (!bReturn) CLog::Log(LOGERROR, "CPVRChannelGroupInternal - %s - failed to persist channels", __FUNCTION__); - - database->Close(); } if (bReturn) bReturn = CPVRChannelGroup::Persist(); + database->Close(); return bReturn; } diff --git a/xbmc/pvr/channels/PVRChannelGroupInternal.h b/xbmc/pvr/channels/PVRChannelGroupInternal.h index 16ae3701b66bb..1000a28dbfdfc 100644 --- a/xbmc/pvr/channels/PVRChannelGroupInternal.h +++ b/xbmc/pvr/channels/PVRChannelGroupInternal.h @@ -68,6 +68,8 @@ namespace PVR */ bool UpdateGroupEntries(const CPVRChannelGroup &channels); + bool AddAndUpdateChannels(const CPVRChannelGroup &channels, bool bUseBackendChannelNumbers); + /*! * @brief Refresh the channel list from the clients. */ diff --git a/xbmc/pvr/channels/PVRChannelGroups.cpp b/xbmc/pvr/channels/PVRChannelGroups.cpp index 3cb878cfdd04a..f5534198ea5e4 100644 --- a/xbmc/pvr/channels/PVRChannelGroups.cpp +++ b/xbmc/pvr/channels/PVRChannelGroups.cpp @@ -357,9 +357,9 @@ int CPVRChannelGroups::GetNextGroupID(int iGroupId) const return GetNextGroup(*currentGroup)->GroupID(); } -const CPVRChannelGroup *CPVRChannelGroups::GetNextGroup(const CPVRChannelGroup &group) const +CPVRChannelGroup *CPVRChannelGroups::GetNextGroup(const CPVRChannelGroup &group) const { - const CPVRChannelGroup *returnGroup = NULL; + CPVRChannelGroup *returnGroup = NULL; int iCurrentGroupIndex = GetIndexForGroupID(group.GroupID()); if (iCurrentGroupIndex + 1 >= (int)size()) diff --git a/xbmc/pvr/channels/PVRChannelGroups.h b/xbmc/pvr/channels/PVRChannelGroups.h index 83bc4e95319a9..597889289cae7 100644 --- a/xbmc/pvr/channels/PVRChannelGroups.h +++ b/xbmc/pvr/channels/PVRChannelGroups.h @@ -150,7 +150,7 @@ namespace PVR * @param group The current group. * @return The next group or the group containing all channels if it wasn't found. */ - const CPVRChannelGroup *GetNextGroup(const CPVRChannelGroup &group) const; + CPVRChannelGroup *GetNextGroup(const CPVRChannelGroup &group) const; /*! * @brief Add a group to this container. diff --git a/xbmc/pvr/channels/PVRChannelGroupsContainer.cpp b/xbmc/pvr/channels/PVRChannelGroupsContainer.cpp index 404d394d0f297..4cd6549a50cf7 100644 --- a/xbmc/pvr/channels/PVRChannelGroupsContainer.cpp +++ b/xbmc/pvr/channels/PVRChannelGroupsContainer.cpp @@ -99,7 +99,7 @@ void CPVRChannelGroupsContainer::Unload(void) m_groupsTV->Clear(); } -const CPVRChannelGroups *CPVRChannelGroupsContainer::Get(bool bRadio) const +CPVRChannelGroups *CPVRChannelGroupsContainer::Get(bool bRadio) const { return bRadio ? m_groupsRadio : m_groupsTV; } diff --git a/xbmc/pvr/channels/PVRChannelGroupsContainer.h b/xbmc/pvr/channels/PVRChannelGroupsContainer.h index 010c4700e8c62..eeb7a3b969e56 100644 --- a/xbmc/pvr/channels/PVRChannelGroupsContainer.h +++ b/xbmc/pvr/channels/PVRChannelGroupsContainer.h @@ -82,20 +82,20 @@ namespace PVR * @brief Get the TV channel groups. * @return The TV channel groups. */ - const CPVRChannelGroups *GetTV(void) const { return Get(false); } + CPVRChannelGroups *GetTV(void) const { return Get(false); } /*! * @brief Get the radio channel groups. * @return The radio channel groups. */ - const CPVRChannelGroups *GetRadio(void) const { return Get(true); } + CPVRChannelGroups *GetRadio(void) const { return Get(true); } /*! * @brief Get the radio or TV channel groups. * @param bRadio If true, get the radio channel groups. Get the TV channel groups otherwise. * @return The requested groups. */ - const CPVRChannelGroups *Get(bool bRadio) const; + CPVRChannelGroups *Get(bool bRadio) const; /*! * @brief Get the group containing all TV channels. diff --git a/xbmc/pvr/dialogs/GUIDialogPVRGroupManager.cpp b/xbmc/pvr/dialogs/GUIDialogPVRGroupManager.cpp index 0c907ca5973c1..20cdc53a2a62a 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRGroupManager.cpp +++ b/xbmc/pvr/dialogs/GUIDialogPVRGroupManager.cpp @@ -63,7 +63,7 @@ CGUIDialogPVRGroupManager::~CGUIDialogPVRGroupManager() bool CGUIDialogPVRGroupManager::PersistChanges(void) { - return ((CPVRChannelGroups *) g_PVRChannelGroups->Get(m_bIsRadio))->PersistAll(); + return g_PVRChannelGroups->Get(m_bIsRadio)->PersistAll(); } bool CGUIDialogPVRGroupManager::CancelChanges(void) diff --git a/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.cpp b/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.cpp index 4bd64ee06c490..a1e8bc0cb4314 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.cpp +++ b/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.cpp @@ -265,7 +265,7 @@ void CGUIDialogPVRTimerSettings::OnSettingChanged(SettingInfo &setting) } else if (setting.id == CONTROL_TMR_CHNAME_TV || setting.id == CONTROL_TMR_CHNAME_RADIO) { - const CPVRChannel* channeltag = ((CPVRChannelGroup *) g_PVRChannelGroups->GetGroupAll(tag->m_bIsRadio))->GetByChannelNumber(tag->m_iChannelNumber); + const CPVRChannel* channeltag = g_PVRChannelGroups->GetGroupAll(tag->m_bIsRadio)->GetByChannelNumber(tag->m_iChannelNumber); if (channeltag) { diff --git a/xbmc/pvr/windows/GUIWindowPVRChannels.cpp b/xbmc/pvr/windows/GUIWindowPVRChannels.cpp index ce00471e9fe5e..248941d3b7d8a 100644 --- a/xbmc/pvr/windows/GUIWindowPVRChannels.cpp +++ b/xbmc/pvr/windows/GUIWindowPVRChannels.cpp @@ -100,12 +100,8 @@ bool CGUIWindowPVRChannels::OnContextButton(int itemNumber, CONTEXT_BUTTON butto const CPVRChannelGroup *CGUIWindowPVRChannels::SelectedGroup(void) { - const CPVRChannelGroup *group = m_selectedGroup; - - if (!group) - group = g_PVRManager.GetPlayingGroup(m_bRadio); - - SetSelectedGroup((CPVRChannelGroup *) group); + if (!m_selectedGroup) + SetSelectedGroup(g_PVRManager.GetPlayingGroup(m_bRadio)); return m_selectedGroup; } @@ -119,10 +115,10 @@ void CGUIWindowPVRChannels::SetSelectedGroup(CPVRChannelGroup *group) g_PVRManager.SetPlayingGroup(m_selectedGroup); } -const CPVRChannelGroup *CGUIWindowPVRChannels::SelectNextGroup(void) +CPVRChannelGroup *CGUIWindowPVRChannels::SelectNextGroup(void) { const CPVRChannelGroup *currentGroup = SelectedGroup(); - CPVRChannelGroup *nextGroup = (CPVRChannelGroup *) g_PVRChannelGroups->Get(m_bRadio)->GetNextGroup(*currentGroup); + CPVRChannelGroup *nextGroup = g_PVRChannelGroups->Get(m_bRadio)->GetNextGroup(*currentGroup); if (nextGroup && *nextGroup != *currentGroup) { SetSelectedGroup(nextGroup); @@ -284,7 +280,7 @@ bool CGUIWindowPVRChannels::OnContextButtonHide(CFileItem *item, CONTEXT_BUTTON if (!pDialog->IsConfirmed()) return bReturn; - ((CPVRChannelGroup *) g_PVRManager.GetPlayingGroup(m_bRadio))->RemoveFromGroup(channel); + g_PVRManager.GetPlayingGroup(m_bRadio)->RemoveFromGroup(channel); UpdateData(); bReturn = true; @@ -323,7 +319,7 @@ bool CGUIWindowPVRChannels::OnContextButtonMove(CFileItem *item, CONTEXT_BUTTON if (newIndex != channel->ChannelNumber()) { - ((CPVRChannelGroup *) g_PVRManager.GetPlayingGroup())->MoveChannel(channel->ChannelNumber(), newIndex); + g_PVRManager.GetPlayingGroup()->MoveChannel(channel->ChannelNumber(), newIndex); UpdateData(); } diff --git a/xbmc/pvr/windows/GUIWindowPVRChannels.h b/xbmc/pvr/windows/GUIWindowPVRChannels.h index a6ed5110b477a..77e414646d05b 100644 --- a/xbmc/pvr/windows/GUIWindowPVRChannels.h +++ b/xbmc/pvr/windows/GUIWindowPVRChannels.h @@ -40,7 +40,7 @@ namespace PVR virtual bool OnContextButton(int itemNumber, CONTEXT_BUTTON button); virtual const CPVRChannelGroup *SelectedGroup(void); virtual void SetSelectedGroup(CPVRChannelGroup *group); - virtual const CPVRChannelGroup *SelectNextGroup(void); + virtual CPVRChannelGroup *SelectNextGroup(void); virtual void UpdateData(void); private: From 7615a73ef38b73e9a98042d749221ef26abfada6 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Mon, 25 Apr 2011 15:54:44 +0200 Subject: [PATCH 37/47] pvr: reset the channel number cache when the channel numbers of the selected group changed --- xbmc/pvr/PVRManager.cpp | 8 ++++++++ xbmc/pvr/PVRManager.h | 7 +++++++ xbmc/pvr/channels/PVRChannelGroup.cpp | 15 +++++++++------ 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/xbmc/pvr/PVRManager.cpp b/xbmc/pvr/PVRManager.cpp index efe174bcc3f53..fd4abac0ae01c 100644 --- a/xbmc/pvr/PVRManager.cpp +++ b/xbmc/pvr/PVRManager.cpp @@ -683,6 +683,14 @@ CPVRChannelGroup *CPVRManager::GetPlayingGroup(bool bRadio /* = false */) return bRadio ? m_currentRadioGroup : m_currentTVGroup; } +bool CPVRManager::IsSelectedGroup(const CPVRChannelGroup &group) const +{ + CSingleLock lock(m_critSection); + + return (group.IsRadio() && m_currentRadioGroup && *m_currentRadioGroup == group) || + (!group.IsRadio() && m_currentTVGroup && *m_currentTVGroup == group); +} + void CPVRManager::TriggerRecordingsUpdate(void) { CSingleLock lock(m_critSectionTriggers); diff --git a/xbmc/pvr/PVRManager.h b/xbmc/pvr/PVRManager.h index bdf0b31a1cf50..8345de573d3ea 100644 --- a/xbmc/pvr/PVRManager.h +++ b/xbmc/pvr/PVRManager.h @@ -384,6 +384,13 @@ namespace PVR */ void SearchMissingChannelIcons(void); + /*! + * @brief Check whether a group is selected. + * @param group The group to check. + * @return True if it's selected, false otherwise. + */ + bool IsSelectedGroup(const CPVRChannelGroup &group) const; + protected: /*! * @brief PVR update and control thread. diff --git a/xbmc/pvr/channels/PVRChannelGroup.cpp b/xbmc/pvr/channels/PVRChannelGroup.cpp index 1efe2f58c06d2..b96ff2b55e5ac 100644 --- a/xbmc/pvr/channels/PVRChannelGroup.cpp +++ b/xbmc/pvr/channels/PVRChannelGroup.cpp @@ -553,8 +553,8 @@ bool CPVRChannelGroup::UpdateGroupEntries(const CPVRChannelGroup &channels) if (!database) return bReturn; - bChanged = AddAndUpdateChannels(channels, bUseBackendChannelNumbers); - bChanged = RemoveDeletedChannels(channels) || bChanged; + bChanged = RemoveDeletedChannels(channels); + bChanged = AddAndUpdateChannels(channels, bUseBackendChannelNumbers) || bChanged; if (bChanged) { @@ -745,7 +745,9 @@ bool CPVRChannelGroup::Persist(void) void CPVRChannelGroup::Renumber(void) { - unsigned int iChannelNumber = 0; + unsigned int iChannelNumber(0); + CSingleLock lock(m_critSection); + for (unsigned int ptr = 0; ptr < size(); ptr++) { if (at(ptr).iChannelNumber != iChannelNumber + 1) @@ -753,6 +755,10 @@ void CPVRChannelGroup::Renumber(void) at(ptr).iChannelNumber = ++iChannelNumber; } + + /* reset the channel number cache */ + if (g_PVRManager.IsSelectedGroup(*this)) + SetSelectedGroup(); } bool CPVRChannelGroup::HasChangedChannels(void) const @@ -813,9 +819,6 @@ void CPVRChannelGroup::SetSelectedGroup(void) { CSingleLock lock(m_critSection); - /* reset all channel numbers */ - g_PVRChannelGroups->GetGroupAll(m_bRadio)->ResetChannelNumbers(); - /* set all channel numbers on members of this group */ unsigned int iChannelNumber(1); for (unsigned int iChannelPtr = 0; iChannelPtr < size(); iChannelPtr++) From 4063c1e61f664ec08da49066dcafe66fb844fd66 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Mon, 25 Apr 2011 16:02:04 +0200 Subject: [PATCH 38/47] pvr: don't try to delete the table map_channels_clients as it doesn't exist yet --- xbmc/pvr/PVRDatabase.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xbmc/pvr/PVRDatabase.cpp b/xbmc/pvr/PVRDatabase.cpp index 12ec5419be401..09213a8969770 100644 --- a/xbmc/pvr/PVRDatabase.cpp +++ b/xbmc/pvr/PVRDatabase.cpp @@ -608,8 +608,8 @@ bool CPVRDatabase::DeleteClients() { CLog::Log(LOGDEBUG, "PVRDB - %s - deleting all clients from the database", __FUNCTION__); - return DeleteValues("clients") && - DeleteValues("map_channels_clients"); + return DeleteValues("clients"); + //TODO && DeleteValues("map_channels_clients"); } int CPVRDatabase::AddClient(const CStdString &strClientName, const CStdString &strClientUid) From 0ba8b1c6aad9f767826e6d0bc718bc82b0f9691c Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Mon, 25 Apr 2011 19:05:14 +0200 Subject: [PATCH 39/47] pvr: ensure that a channels list is sorted and that the cached channel numbers are correct --- xbmc/pvr/channels/PVRChannelGroup.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/xbmc/pvr/channels/PVRChannelGroup.cpp b/xbmc/pvr/channels/PVRChannelGroup.cpp index b96ff2b55e5ac..ef50054a78387 100644 --- a/xbmc/pvr/channels/PVRChannelGroup.cpp +++ b/xbmc/pvr/channels/PVRChannelGroup.cpp @@ -745,17 +745,19 @@ bool CPVRChannelGroup::Persist(void) void CPVRChannelGroup::Renumber(void) { - unsigned int iChannelNumber(0); + unsigned int iChannelNumber(1); CSingleLock lock(m_critSection); - for (unsigned int ptr = 0; ptr < size(); ptr++) + for (unsigned int iChannelPtr = 0; iChannelPtr < size(); iChannelPtr++) { - if (at(ptr).iChannelNumber != iChannelNumber + 1) + if (at(iChannelPtr).iChannelNumber != iChannelNumber) m_bChanged = true; - at(ptr).iChannelNumber = ++iChannelNumber; + at(iChannelPtr).iChannelNumber = iChannelNumber++; } + SortByChannelNumber(); + /* reset the channel number cache */ if (g_PVRManager.IsSelectedGroup(*this)) SetSelectedGroup(); @@ -819,6 +821,9 @@ void CPVRChannelGroup::SetSelectedGroup(void) { CSingleLock lock(m_critSection); + if (!IsInternalGroup()) + g_PVRChannelGroups->GetGroupAll(m_bRadio)->ResetChannelNumbers(); + /* set all channel numbers on members of this group */ unsigned int iChannelNumber(1); for (unsigned int iChannelPtr = 0; iChannelPtr < size(); iChannelPtr++) From 0ca3d1554cc36a8d61a7e3f8092de8b35ab90402 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Mon, 25 Apr 2011 19:50:15 +0200 Subject: [PATCH 40/47] pvr: always update one thing at a time --- xbmc/pvr/PVRManager.cpp | 242 +++++++++++++++++++++++++++------------- xbmc/pvr/PVRManager.h | 12 ++ 2 files changed, 176 insertions(+), 78 deletions(-) diff --git a/xbmc/pvr/PVRManager.cpp b/xbmc/pvr/PVRManager.cpp index fd4abac0ae01c..468204fda64de 100644 --- a/xbmc/pvr/PVRManager.cpp +++ b/xbmc/pvr/PVRManager.cpp @@ -341,18 +341,22 @@ void CPVRManager::UpdateWindow(PVRWindow window, bool bResetContents /* = true * void CPVRManager::ResetProperties(void) { - m_currentFile = NULL; - m_currentRadioGroup = NULL; - m_currentTVGroup = NULL; - m_PreviousChannel[0] = -1; - m_PreviousChannel[1] = -1; - m_PreviousChannelIndex = 0; - m_LastChannel = 0; - - m_bRecordingsUpdating = false; - m_bTimersUpdating = false; - m_bChannelGroupsUpdating = false; - m_bChannelsUpdating = false; + m_currentFile = NULL; + m_currentRadioGroup = NULL; + m_currentTVGroup = NULL; + m_PreviousChannel[0] = -1; + m_PreviousChannel[1] = -1; + m_PreviousChannelIndex = 0; + m_LastChannel = 0; + + m_bRecordingsUpdating = false; + m_bRecordingsUpdatePending = false; + m_bTimersUpdating = false; + m_bTimersUpdatePending = false; + m_bChannelGroupsUpdating = false; + m_bChannelGroupsUpdatePending = false; + m_bChannelsUpdating = false; + m_bChannelsUpdatePending = false; } bool CPVRManager::DisableIfNoClients(void) @@ -691,93 +695,27 @@ bool CPVRManager::IsSelectedGroup(const CPVRChannelGroup &group) const (!group.IsRadio() && m_currentTVGroup && *m_currentTVGroup == group); } -void CPVRManager::TriggerRecordingsUpdate(void) -{ - CSingleLock lock(m_critSectionTriggers); - if (!m_bLoaded || m_bRecordingsUpdating) - return; - m_bRecordingsUpdating = true; - - CJobManager::GetInstance().AddJob(new CPVRRecordingsUpdateJob(), this); -} - bool CPVRRecordingsUpdateJob::DoWork(void) { g_PVRRecordings->Update(); return true; } -void CPVRManager::TriggerTimersUpdate(void) -{ - CSingleLock lock(m_critSectionTriggers); - if (!m_bLoaded || m_bTimersUpdating) - return; - m_bTimersUpdating = true; - - CJobManager::GetInstance().AddJob(new CPVRTimersUpdateJob(), this); -} - bool CPVRTimersUpdateJob::DoWork(void) { return g_PVRTimers->Update(); } -void CPVRManager::TriggerChannelsUpdate(void) -{ - CSingleLock lock(m_critSectionTriggers); - if (!m_bLoaded || m_bChannelsUpdating) - return; - m_bChannelsUpdating = true; - - CJobManager::GetInstance().AddJob(new CPVRChannelsUpdateJob(), this); -} - bool CPVRChannelsUpdateJob::DoWork(void) { return g_PVRChannelGroups->Update(true); } -void CPVRManager::TriggerChannelGroupsUpdate(void) -{ - CSingleLock lock(m_critSectionTriggers); - if (!m_bLoaded || m_bChannelGroupsUpdating) - return; - m_bChannelGroupsUpdating = true; - m_bChannelsUpdating = true; - - CJobManager::GetInstance().AddJob(new CPVRChannelGroupsUpdateJob(), this); -} - bool CPVRChannelGroupsUpdateJob::DoWork(void) { return g_PVRChannelGroups->Update(false); } -void CPVRManager::OnJobComplete(unsigned int jobID, bool success, CJob* job) -{ - if (!strcmp(job->GetType(), "pvr-update-channelgroups")) - { - CSingleLock lock(m_critSectionTriggers); - m_bChannelGroupsUpdating = false; - m_bChannelsUpdating = false; - } - else if (!strcmp(job->GetType(), "pvr-update-channels")) - { - CSingleLock lock(m_critSectionTriggers); - m_bChannelsUpdating = false; - } - else if (!strcmp(job->GetType(), "pvr-update-timers")) - { - CSingleLock lock(m_critSectionTriggers); - m_bTimersUpdating = false; - } - else if (!strcmp(job->GetType(), "pvr-update-recordings")) - { - CSingleLock lock(m_critSectionTriggers); - m_bRecordingsUpdating = false; - } -} - bool CPVRManager::OpenLiveStream(const CPVRChannel &tag) { bool bReturn = false; @@ -1052,3 +990,151 @@ void CPVRManager::SearchMissingChannelIcons(void) { return m_channelGroups->SearchMissingChannelIcons(); } + +bool CPVRManager::IsUpdating(void) const +{ + CSingleLock lock(m_critSectionTriggers); + + return (m_bRecordingsUpdating || m_bTimersUpdating || + m_bChannelsUpdating || m_bChannelGroupsUpdating); +} + +void CPVRManager::TriggerRecordingsUpdate(void) +{ + CSingleLock lock(m_critSectionTriggers); + if (!m_bLoaded) + return; + + if (IsUpdating()) + { + m_bRecordingsUpdatePending = true; + return; + } + + StartRecordingsUpdateJob(); +} + +void CPVRManager::TriggerTimersUpdate(void) +{ + CSingleLock lock(m_critSectionTriggers); + if (!m_bLoaded) + return; + + if (IsUpdating()) + { + m_bTimersUpdatePending = true; + return; + } + + StartTimersUpdateJob(); +} + +void CPVRManager::TriggerChannelsUpdate(void) +{ + CSingleLock lock(m_critSectionTriggers); + if (!m_bLoaded) + return; + + if (IsUpdating()) + { + if (!m_bChannelGroupsUpdatePending) + m_bChannelsUpdatePending = true; + return; + } + + StartChannelsUpdateJob(); +} + +void CPVRManager::TriggerChannelGroupsUpdate(void) +{ + CSingleLock lock(m_critSectionTriggers); + if (!m_bLoaded) + return; + + if (IsUpdating()) + { + m_bChannelsUpdatePending = false; + m_bChannelGroupsUpdatePending = true; + return; + } + + StartChannelGroupsUpdateJob(); +} + +void CPVRManager::StartRecordingsUpdateJob(void) +{ + CSingleLock lock(m_critSectionTriggers); + + m_bRecordingsUpdating = true; + CJobManager::GetInstance().AddJob(new CPVRRecordingsUpdateJob(), this); +} + +void CPVRManager::StartTimersUpdateJob(void) +{ + CSingleLock lock(m_critSectionTriggers); + + m_bTimersUpdating = true; + CJobManager::GetInstance().AddJob(new CPVRTimersUpdateJob(), this); +} + +void CPVRManager::StartChannelsUpdateJob(void) +{ + CSingleLock lock(m_critSectionTriggers); + + m_bChannelsUpdating = true; + CJobManager::GetInstance().AddJob(new CPVRChannelsUpdateJob(), this); +} + +void CPVRManager::StartChannelGroupsUpdateJob(void) +{ + CSingleLock lock(m_critSectionTriggers); + + m_bChannelGroupsUpdating = true; + m_bChannelsUpdating = true; + CJobManager::GetInstance().AddJob(new CPVRChannelGroupsUpdateJob(), this); +} + +void CPVRManager::OnJobComplete(unsigned int jobID, bool success, CJob* job) +{ + CSingleLock lock(m_critSectionTriggers); + + if (!strcmp(job->GetType(), "pvr-update-channelgroups")) + { + m_bChannelGroupsUpdating = false; + m_bChannelsUpdating = false; + } + else if (!strcmp(job->GetType(), "pvr-update-channels")) + m_bChannelsUpdating = false; + else if (!strcmp(job->GetType(), "pvr-update-timers")) + m_bTimersUpdating = false; + else if (!strcmp(job->GetType(), "pvr-update-recordings")) + m_bRecordingsUpdating = false; + + StartNextPendingJob(); +} + +void CPVRManager::StartNextPendingJob(void) +{ + CSingleLock lock(m_critSectionTriggers); + + if (m_bChannelGroupsUpdatePending) + { + m_bChannelGroupsUpdatePending = false; + StartChannelGroupsUpdateJob(); + } + else if (m_bChannelsUpdatePending) + { + m_bChannelsUpdatePending = false; + StartChannelsUpdateJob(); + } + else if (m_bTimersUpdatePending) + { + m_bTimersUpdatePending = false; + StartTimersUpdateJob(); + } + else if (m_bRecordingsUpdatePending) + { + m_bRecordingsUpdatePending = false; + StartRecordingsUpdateJob(); + } +} diff --git a/xbmc/pvr/PVRManager.h b/xbmc/pvr/PVRManager.h index 8345de573d3ea..77d9d36a83c5e 100644 --- a/xbmc/pvr/PVRManager.h +++ b/xbmc/pvr/PVRManager.h @@ -391,6 +391,8 @@ namespace PVR */ bool IsSelectedGroup(const CPVRChannelGroup &group) const; + bool IsUpdating(void) const; + protected: /*! * @brief PVR update and control thread. @@ -501,6 +503,12 @@ namespace PVR */ void ShowBusyDialog(bool bShow); + void StartRecordingsUpdateJob(void); + void StartTimersUpdateJob(void); + void StartChannelsUpdateJob(void); + void StartChannelGroupsUpdateJob(void); + void StartNextPendingJob(void); + void OnJobComplete(unsigned int jobID, bool success, CJob* job); /** @name containers */ @@ -515,9 +523,13 @@ namespace PVR CCriticalSection m_critSectionTriggers; /*!< critical section for triggered updates */ bool m_bRecordingsUpdating; /*!< true when recordings are being updated */ + bool m_bRecordingsUpdatePending; /*!< true when another recordings update will be performed after the last one finished */ bool m_bTimersUpdating; /*!< true when timers are being updated */ + bool m_bTimersUpdatePending; /*!< true when another timers update will be performed after the last one finished */ bool m_bChannelsUpdating; /*!< true when channels are being updated */ + bool m_bChannelsUpdatePending; /*!< true when another channels update will be performed after the last one finished */ bool m_bChannelGroupsUpdating; /*!< true when channel groups are being updated */ + bool m_bChannelGroupsUpdatePending; /*!< true when another channel groups update will be performed after the last one finished */ CFileItem * m_currentFile; /*!< the PVR file that is currently playing */ CPVRDatabase * m_database; /*!< the database for all PVR related data */ CCriticalSection m_critSection; /*!< critical section for all changes to this class, except for changes to triggers */ From 3935846278299711d71ab3725b5d5c1f345dc39a Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Mon, 25 Apr 2011 23:15:55 +0200 Subject: [PATCH 41/47] pvr: correct the query in CPVRDatabase::Get(CPVRChannelGroupInternal &results) --- xbmc/pvr/PVRDatabase.cpp | 8 ++++---- xbmc/pvr/channels/PVRChannelGroup.cpp | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/xbmc/pvr/PVRDatabase.cpp b/xbmc/pvr/PVRDatabase.cpp index 09213a8969770..7a2b7e37d6b38 100644 --- a/xbmc/pvr/PVRDatabase.cpp +++ b/xbmc/pvr/PVRDatabase.cpp @@ -296,10 +296,10 @@ int CPVRDatabase::Get(CPVRChannelGroupInternal &results) CStdString strQuery = FormatSQL("SELECT channels.idChannel, channels.iUniqueId, channels.bIsRadio, channels.bIsHidden, " "channels.sIconPath, channels.sChannelName, channels.bIsVirtual, channels.bEPGEnabled, channels.sEPGScraper, channels.iLastWatched, channels.iClientId, " "channels.iClientChannelNumber, channels.sInputFormat, channels.sInputFormat, channels.sStreamURL, channels.iEncryptionSystem, map_channelgroups_channels.iChannelNumber " - "FROM channels " - "LEFT JOIN map_channelgroups_channels ON map_channelgroups_channels.idChannel = channels.idChannel AND map_channelgroups_channels.idGroup = %u " - "WHERE channels.bIsRadio = %u " - "ORDER BY map_channelgroups_channels.iChannelNumber ASC;", results.IsRadio() ? XBMC_INTERNAL_GROUP_RADIO : XBMC_INTERNAL_GROUP_TV, results.IsRadio() ? 1 : 0); + "FROM map_channelgroups_channels " + "LEFT JOIN channels ON channels.idChannel = map_channelgroups_channels.idChannel " + "WHERE map_channelgroups_channels.idGroup = %u " + "ORDER BY map_channelgroups_channels.iChannelNumber ASC", results.IsRadio() ? XBMC_INTERNAL_GROUP_RADIO : XBMC_INTERNAL_GROUP_TV); if (ResultQuery(strQuery)) { try diff --git a/xbmc/pvr/channels/PVRChannelGroup.cpp b/xbmc/pvr/channels/PVRChannelGroup.cpp index ef50054a78387..e8dca15d0872b 100644 --- a/xbmc/pvr/channels/PVRChannelGroup.cpp +++ b/xbmc/pvr/channels/PVRChannelGroup.cpp @@ -82,7 +82,9 @@ bool CPVRChannelGroup::operator==(const CPVRChannelGroup& right) const { if (this == &right) return true; - return (m_bRadio == right.m_bRadio && m_iGroupId == right.m_iGroupId); + return (m_bRadio == right.m_bRadio && + m_iGroupId == right.m_iGroupId && + m_strGroupName.Equals(right.m_strGroupName)); } bool CPVRChannelGroup::operator!=(const CPVRChannelGroup &right) const From f5a9ca125c34961e4ad21d634bb37f18b5659c87 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Mon, 25 Apr 2011 23:30:07 +0200 Subject: [PATCH 42/47] pvr: split up CPVRDatabase::Persist(CPVRChannelGroup &group) --- xbmc/pvr/PVRDatabase.cpp | 40 +++++++++++++++++---------- xbmc/pvr/PVRDatabase.h | 4 ++- xbmc/pvr/channels/PVRChannelGroup.cpp | 2 +- 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/xbmc/pvr/PVRDatabase.cpp b/xbmc/pvr/PVRDatabase.cpp index 7a2b7e37d6b38..1d70f5a587f8b 100644 --- a/xbmc/pvr/PVRDatabase.cpp +++ b/xbmc/pvr/PVRDatabase.cpp @@ -554,19 +554,19 @@ int CPVRDatabase::GetGroupMembers(CPVRChannelGroup &group) return iReturn; } -int CPVRDatabase::Persist(CPVRChannelGroup *group) +int CPVRDatabase::Persist(CPVRChannelGroup &group) { int iReturn = -1; CStdString strQuery; - if (group->GroupID() <= 0) + if (group.GroupID() <= 0) { /* new group */ strQuery = FormatSQL("INSERT INTO channelgroups (" "bIsRadio, sName, iSortOrder) " "VALUES (%i, '%s', %i);", - (group->IsRadio() ? 1 :0), group->GroupName().c_str(), group->SortOrder()); + (group.IsRadio() ? 1 :0), group.GroupName().c_str(), group.SortOrder()); } else { @@ -574,32 +574,44 @@ int CPVRDatabase::Persist(CPVRChannelGroup *group) strQuery = FormatSQL("REPLACE INTO channelgroups (" "idGroup, bIsRadio, sName, iSortOrder) " "VALUES (%i, %i, '%s', %i);", - group->GroupID(), (group->IsRadio() ? 1 :0), group->GroupName().c_str(), group->SortOrder()); + group.GroupID(), (group.IsRadio() ? 1 :0), group.GroupName().c_str(), group.SortOrder()); } if (ExecuteQuery(strQuery)) { - if (group->GroupID() <= 0) - group->m_iGroupId = (int) m_pDS->lastinsertid(); + if (group.GroupID() <= 0) + group.m_iGroupId = (int) m_pDS->lastinsertid(); - RemoveChannelsFromGroup(*group); + if (PersistGroupMembers(group)) + iReturn = group.GroupID(); + else + iReturn = -1; + } - for (unsigned int iChannelPtr = 0; iChannelPtr < group->size(); iChannelPtr++) + return iReturn; +} + +bool CPVRDatabase::PersistGroupMembers(CPVRChannelGroup &group) +{ + bool bReturn = RemoveChannelsFromGroup(group); + CStdString strQuery; + + if (bReturn && group.size() > 0) + { + for (unsigned int iChannelPtr = 0; iChannelPtr < group.size(); iChannelPtr++) { - PVRChannelGroupMember member = group->at(iChannelPtr); + PVRChannelGroupMember member = group.at(iChannelPtr); strQuery = FormatSQL("REPLACE INTO map_channelgroups_channels (" "idGroup, idChannel, iChannelNumber) " "VALUES (%i, %i, %i);", - group->GroupID(), member.channel->ChannelID(), member.iChannelNumber); + group.GroupID(), member.channel->ChannelID(), member.iChannelNumber); QueueInsertQuery(strQuery); } - CommitInsertQueries(); - - iReturn = group->GroupID(); + bReturn = CommitInsertQueries(); } - return iReturn; + return bReturn; } /********** Client methods **********/ diff --git a/xbmc/pvr/PVRDatabase.h b/xbmc/pvr/PVRDatabase.h index 0147c053cbb46..473714b25f555 100644 --- a/xbmc/pvr/PVRDatabase.h +++ b/xbmc/pvr/PVRDatabase.h @@ -176,7 +176,7 @@ namespace PVR * @param group The group to persist. * @return The database ID of the group. */ - int Persist(CPVRChannelGroup *group); + int Persist(CPVRChannelGroup &group); //@} @@ -212,6 +212,8 @@ namespace PVR */ int GetClientId(const CStdString &strClientUid); + bool PersistGroupMembers(CPVRChannelGroup &group); + //@} private: diff --git a/xbmc/pvr/channels/PVRChannelGroup.cpp b/xbmc/pvr/channels/PVRChannelGroup.cpp index e8dca15d0872b..c1faa3a1b3411 100644 --- a/xbmc/pvr/channels/PVRChannelGroup.cpp +++ b/xbmc/pvr/channels/PVRChannelGroup.cpp @@ -735,7 +735,7 @@ bool CPVRChannelGroup::Persist(void) { CLog::Log(LOGDEBUG, "CPVRChannelGroup - %s - persisting channel group '%s' with %d channels", __FUNCTION__, GroupName().c_str(), (int) size()); - database->Persist(this); + database->Persist(*this); database->Close(); m_bChanged = false; From 2fa4137de78be2ae160e87ede87919f7f182f2d9 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Mon, 25 Apr 2011 23:59:30 +0200 Subject: [PATCH 43/47] tvheadend addon: channel updates don't pass channel numbers when they didn't change. remove the backwards compat option that sets it to the channel id, because it messes up 'always use backend channel numbers' --- xbmc/pvrclients/tvheadend/HTSPSession.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xbmc/pvrclients/tvheadend/HTSPSession.cpp b/xbmc/pvrclients/tvheadend/HTSPSession.cpp index 7d724a3d75c7c..4f20599b694fa 100644 --- a/xbmc/pvrclients/tvheadend/HTSPSession.cpp +++ b/xbmc/pvrclients/tvheadend/HTSPSession.cpp @@ -468,7 +468,7 @@ void cHTSPSession::ParseChannelUpdate(htsmsg_t* msg, SChannels &channels) channel.num = num; } else - channel.num = id; // fallback older servers + channel.num = -1; htsmsg_t *tags; From e3a6d908f912925370a542417eb635b26ce29584 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Mon, 25 Apr 2011 23:59:53 +0200 Subject: [PATCH 44/47] pvr: don't update the backend channel number when it's negative --- xbmc/pvr/channels/PVRChannel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xbmc/pvr/channels/PVRChannel.cpp b/xbmc/pvr/channels/PVRChannel.cpp index 844aafdc139cb..4dff47d6b85bc 100644 --- a/xbmc/pvr/channels/PVRChannel.cpp +++ b/xbmc/pvr/channels/PVRChannel.cpp @@ -480,7 +480,7 @@ bool CPVRChannel::SetClientChannelNumber(int iClientChannelNumber, bool bSaveInD bool bReturn(false); CSingleLock lock(m_critSection); - if (m_iClientChannelNumber != iClientChannelNumber) + if (m_iClientChannelNumber != iClientChannelNumber && iClientChannelNumber > 0) { /* update the client channel number */ m_iClientChannelNumber = iClientChannelNumber; From a217d1604a39b1a6ecbc98fee7cf47ac14620adf Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Tue, 26 Apr 2011 00:07:25 +0200 Subject: [PATCH 45/47] pvr: persist a channel after caching it's icon --- xbmc/pvr/channels/PVRChannel.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/xbmc/pvr/channels/PVRChannel.cpp b/xbmc/pvr/channels/PVRChannel.cpp index 4dff47d6b85bc..2d7369d85ccfe 100644 --- a/xbmc/pvr/channels/PVRChannel.cpp +++ b/xbmc/pvr/channels/PVRChannel.cpp @@ -834,5 +834,11 @@ void CPVRChannel::OnJobComplete(unsigned int jobID, bool success, CJob* job) bool CPVRChannelIconCacheJob::DoWork(void) { - return m_channel->CacheIcon(); + if (m_channel->CacheIcon()) + { + m_channel->Persist(false); + return true; + } + + return false; } From ed75d82a0db4ebacb6a56899446c1c38e32a6c8a Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Tue, 26 Apr 2011 00:12:19 +0200 Subject: [PATCH 46/47] pvr: check whether cached icons are still valid after settings changed --- xbmc/pvr/channels/PVRChannelGroup.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/xbmc/pvr/channels/PVRChannelGroup.cpp b/xbmc/pvr/channels/PVRChannelGroup.cpp index c1faa3a1b3411..d77857af78208 100644 --- a/xbmc/pvr/channels/PVRChannelGroup.cpp +++ b/xbmc/pvr/channels/PVRChannelGroup.cpp @@ -839,6 +839,7 @@ void CPVRChannelGroup::Notify(const Observable &obs, const CStdString& msg) bool bUsingBackendChannelOrder = g_guiSettings.GetBool("pvrmanager.backendchannelorder"); CSingleLock lock(m_critSection); + /* check whether this channel group has to be renumbered */ if (m_bUsingBackendChannelOrder != bUsingBackendChannelOrder) { m_bUsingBackendChannelOrder = bUsingBackendChannelOrder; @@ -853,5 +854,10 @@ void CPVRChannelGroup::Notify(const Observable &obs, const CStdString& msg) Persist(); } } + lock.Leave(); + + /* check whether cached icons are still valid */ + if (IsInternalGroup()) + CacheIcons(); } } From 2d3b06925cb4d3838f2f029aa621f044de21b97d Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Tue, 26 Apr 2011 00:30:09 +0200 Subject: [PATCH 47/47] pvr: only do a full refresh of the channels list if needed --- xbmc/pvr/channels/PVRChannelGroup.cpp | 17 ++++++++++++----- xbmc/pvr/channels/PVRChannelGroup.h | 3 ++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/xbmc/pvr/channels/PVRChannelGroup.cpp b/xbmc/pvr/channels/PVRChannelGroup.cpp index d77857af78208..3ea73955b7481 100644 --- a/xbmc/pvr/channels/PVRChannelGroup.cpp +++ b/xbmc/pvr/channels/PVRChannelGroup.cpp @@ -546,6 +546,7 @@ bool CPVRChannelGroup::UpdateGroupEntries(const CPVRChannelGroup &channels) { bool bReturn(false); bool bChanged(false); + bool bRemoved(false); CSingleLock lock(m_critSection); /* sort by client channel number if this is the first time or if pvrmanager.backendchannelorder is true */ @@ -555,8 +556,8 @@ bool CPVRChannelGroup::UpdateGroupEntries(const CPVRChannelGroup &channels) if (!database) return bReturn; - bChanged = RemoveDeletedChannels(channels); - bChanged = AddAndUpdateChannels(channels, bUseBackendChannelNumbers) || bChanged; + bRemoved = RemoveDeletedChannels(channels); + bChanged = AddAndUpdateChannels(channels, bUseBackendChannelNumbers) || bRemoved; if (bChanged) { @@ -565,11 +566,11 @@ bool CPVRChannelGroup::UpdateGroupEntries(const CPVRChannelGroup &channels) /* renumber to make sure all channels have a channel number. new channels were added at the back, so they'll get the highest numbers */ - Renumber(); + bool bRenumbered = Renumber(); lock.Leave(); - g_PVRManager.UpdateWindow(m_bRadio ? PVR_WINDOW_CHANNELS_RADIO : PVR_WINDOW_CHANNELS_TV, true); // TODO always doing a refresh now + g_PVRManager.UpdateWindow(m_bRadio ? PVR_WINDOW_CHANNELS_RADIO : PVR_WINDOW_CHANNELS_TV, HasNewChannels() || bRemoved || bRenumbered); bReturn = Persist(); } @@ -745,15 +746,19 @@ bool CPVRChannelGroup::Persist(void) return false; } -void CPVRChannelGroup::Renumber(void) +bool CPVRChannelGroup::Renumber(void) { + bool bReturn(false); unsigned int iChannelNumber(1); CSingleLock lock(m_critSection); for (unsigned int iChannelPtr = 0; iChannelPtr < size(); iChannelPtr++) { if (at(iChannelPtr).iChannelNumber != iChannelNumber) + { + bReturn = true; m_bChanged = true; + } at(iChannelPtr).iChannelNumber = iChannelNumber++; } @@ -763,6 +768,8 @@ void CPVRChannelGroup::Renumber(void) /* reset the channel number cache */ if (g_PVRManager.IsSelectedGroup(*this)) SetSelectedGroup(); + + return bReturn; } bool CPVRChannelGroup::HasChangedChannels(void) const diff --git a/xbmc/pvr/channels/PVRChannelGroup.h b/xbmc/pvr/channels/PVRChannelGroup.h index 7159e1ae2b476..8c6f210c763d3 100644 --- a/xbmc/pvr/channels/PVRChannelGroup.h +++ b/xbmc/pvr/channels/PVRChannelGroup.h @@ -108,8 +108,9 @@ namespace PVR /*! * @brief Remove invalid channels and updates the channel numbers. + * @return True if something changed, false otherwise. */ - void Renumber(void); + bool Renumber(void); /*! * @return Cache all channel icons in this group if guisetting "pvrmenu.iconpath" is set.