[video] fix selection after changing video or extra art
[xbmc.git] / xbmc / pvr / guilib / guiinfo / PVRGUIInfo.h
blob55913534e30f6a1af8646416d4b835b4cff6e929
1 /*
2 * Copyright (C) 2012-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 #include "addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_channels.h"
12 #include "guilib/guiinfo/GUIInfoProvider.h"
13 #include "pvr/addons/PVRClients.h"
14 #include "pvr/guilib/guiinfo/PVRGUITimerInfo.h"
15 #include "pvr/guilib/guiinfo/PVRGUITimesInfo.h"
16 #include "threads/CriticalSection.h"
17 #include "threads/Thread.h"
19 #include <atomic>
20 #include <string>
21 #include <vector>
23 class CFileItem;
25 namespace KODI
27 namespace GUILIB
29 namespace GUIINFO
31 class CGUIInfo;
33 } // namespace GUILIB
34 } // namespace KODI
36 namespace PVR
38 enum class PVREvent;
39 struct PVRChannelNumberInputChangedEvent;
40 struct PVRPreviewAndPlayerShowInfoChangedEvent;
42 class CPVRGUIInfo : public KODI::GUILIB::GUIINFO::CGUIInfoProvider, private CThread
44 public:
45 CPVRGUIInfo();
46 ~CPVRGUIInfo() override = default;
48 void Start();
49 void Stop();
51 /*!
52 * @brief CEventStream callback for PVR events.
53 * @param event The event.
55 void Notify(const PVREvent& event);
57 /*!
58 * @brief CEventStream callback for channel number input changes.
59 * @param event The event.
61 void Notify(const PVRChannelNumberInputChangedEvent& event);
63 /*!
64 * @brief CEventStream callback for channel preview and player show info changes.
65 * @param event The event.
67 void Notify(const PVRPreviewAndPlayerShowInfoChangedEvent& event);
69 // KODI::GUILIB::GUIINFO::IGUIInfoProvider implementation
70 bool InitCurrentItem(CFileItem* item) override;
71 bool GetLabel(std::string& value,
72 const CFileItem* item,
73 int contextWindow,
74 const KODI::GUILIB::GUIINFO::CGUIInfo& info,
75 std::string* fallback) const override;
76 bool GetFallbackLabel(std::string& value,
77 const CFileItem* item,
78 int contextWindow,
79 const KODI::GUILIB::GUIINFO::CGUIInfo& info,
80 std::string* fallback) override;
81 bool GetInt(int& value,
82 const CGUIListItem* item,
83 int contextWindow,
84 const KODI::GUILIB::GUIINFO::CGUIInfo& info) const override;
85 bool GetBool(bool& value,
86 const CGUIListItem* item,
87 int contextWindow,
88 const KODI::GUILIB::GUIINFO::CGUIInfo& info) const override;
90 private:
91 void ResetProperties();
92 void ClearQualityInfo(PVR_SIGNAL_STATUS& qualityInfo);
93 void ClearDescrambleInfo(PVR_DESCRAMBLE_INFO& descrambleInfo);
95 void Process() override;
97 void UpdateTimersCache();
98 void UpdateBackendCache();
99 void UpdateQualityData();
100 void UpdateDescrambleData();
101 void UpdateMisc();
102 void UpdateNextTimer();
103 void UpdateTimeshiftData();
104 void UpdateTimeshiftProgressData();
106 void UpdateTimersToggle();
108 bool GetListItemAndPlayerLabel(const CFileItem* item,
109 const KODI::GUILIB::GUIINFO::CGUIInfo& info,
110 std::string& strValue) const;
111 bool GetPVRLabel(const CFileItem* item,
112 const KODI::GUILIB::GUIINFO::CGUIInfo& info,
113 std::string& strValue) const;
114 bool GetRadioRDSLabel(const CFileItem* item,
115 const KODI::GUILIB::GUIINFO::CGUIInfo& info,
116 std::string& strValue) const;
118 bool GetListItemAndPlayerInt(const CFileItem* item,
119 const KODI::GUILIB::GUIINFO::CGUIInfo& info,
120 int& iValue) const;
121 bool GetPVRInt(const CFileItem* item,
122 const KODI::GUILIB::GUIINFO::CGUIInfo& info,
123 int& iValue) const;
124 int GetTimeShiftSeekPercent() const;
126 bool GetListItemAndPlayerBool(const CFileItem* item,
127 const KODI::GUILIB::GUIINFO::CGUIInfo& info,
128 bool& bValue) const;
129 bool GetPVRBool(const CFileItem* item,
130 const KODI::GUILIB::GUIINFO::CGUIInfo& info,
131 bool& bValue) const;
132 bool GetRadioRDSBool(const CFileItem* item,
133 const KODI::GUILIB::GUIINFO::CGUIInfo& info,
134 bool& bValue) const;
136 void CharInfoBackendNumber(std::string& strValue) const;
137 void CharInfoTotalDiskSpace(std::string& strValue) const;
138 void CharInfoSignal(std::string& strValue) const;
139 void CharInfoSNR(std::string& strValue) const;
140 void CharInfoBER(std::string& strValue) const;
141 void CharInfoUNC(std::string& strValue) const;
142 void CharInfoFrontendName(std::string& strValue) const;
143 void CharInfoFrontendStatus(std::string& strValue) const;
144 void CharInfoBackendName(std::string& strValue) const;
145 void CharInfoBackendVersion(std::string& strValue) const;
146 void CharInfoBackendHost(std::string& strValue) const;
147 void CharInfoBackendDiskspace(std::string& strValue) const;
148 void CharInfoBackendProviders(std::string& strValue) const;
149 void CharInfoBackendChannelGroups(std::string& strValue) const;
150 void CharInfoBackendChannels(std::string& strValue) const;
151 void CharInfoBackendTimers(std::string& strValue) const;
152 void CharInfoBackendRecordings(std::string& strValue) const;
153 void CharInfoBackendDeletedRecordings(std::string& strValue) const;
154 void CharInfoPlayingClientName(std::string& strValue) const;
155 void CharInfoEncryption(std::string& strValue) const;
156 void CharInfoService(std::string& strValue) const;
157 void CharInfoMux(std::string& strValue) const;
158 void CharInfoProvider(std::string& strValue) const;
160 /** @name PVRGUIInfo data */
161 //@{
162 CPVRGUIAnyTimerInfo m_anyTimersInfo; // tv + radio
163 CPVRGUITVTimerInfo m_tvTimersInfo;
164 CPVRGUIRadioTimerInfo m_radioTimersInfo;
166 CPVRGUITimesInfo m_timesInfo;
168 bool m_bHasTVRecordings;
169 bool m_bHasRadioRecordings;
170 unsigned int m_iCurrentActiveClient;
171 std::string m_strPlayingClientName;
172 std::string m_strBackendName;
173 std::string m_strBackendVersion;
174 std::string m_strBackendHost;
175 std::string m_strBackendTimers;
176 std::string m_strBackendRecordings;
177 std::string m_strBackendDeletedRecordings;
178 std::string m_strBackendProviders;
179 std::string m_strBackendChannelGroups;
180 std::string m_strBackendChannels;
181 long long m_iBackendDiskTotal;
182 long long m_iBackendDiskUsed;
183 bool m_bIsPlayingTV;
184 bool m_bIsPlayingRadio;
185 bool m_bIsPlayingRecording;
186 bool m_bIsPlayingEpgTag;
187 bool m_bIsPlayingEncryptedStream;
188 bool m_bHasTVChannels;
189 bool m_bHasRadioChannels;
190 bool m_bCanRecordPlayingChannel;
191 bool m_bIsRecordingPlayingChannel;
192 bool m_bIsPlayingActiveRecording;
193 std::string m_strPlayingTVGroup;
194 std::string m_strPlayingRadioGroup;
196 //@}
198 PVR_SIGNAL_STATUS m_qualityInfo; /*!< stream quality information */
199 PVR_DESCRAMBLE_INFO m_descrambleInfo; /*!< stream descramble information */
200 std::vector<SBackend> m_backendProperties;
202 std::string m_channelNumberInput;
203 bool m_previewAndPlayerShowInfo{false};
205 mutable CCriticalSection m_critSection;
208 * The various backend-related fields will only be updated when this
209 * flag is set. This is done to limit the amount of unnecessary
210 * backend querying when we're not displaying any of the queried
211 * information.
213 mutable std::atomic<bool> m_updateBackendCacheRequested;
215 bool m_bRegistered;
217 } // namespace PVR