[Windows] Fix driver version detection of AMD RDNA+ GPU on Windows 10
[xbmc.git] / xbmc / pvr / PVRItem.cpp
blob7bf13228db0d3e551d49926f2333fbb26c9601d9
1 /*
2 * Copyright (C) 2016-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 #include "PVRItem.h"
11 #include "FileItem.h"
12 #include "ServiceBroker.h"
13 #include "pvr/PVRManager.h"
14 #include "pvr/channels/PVRChannel.h"
15 #include "pvr/channels/PVRChannelGroupsContainer.h"
16 #include "pvr/epg/EpgInfoTag.h"
17 #include "pvr/recordings/PVRRecording.h"
18 #include "pvr/recordings/PVRRecordings.h"
19 #include "pvr/timers/PVRTimerInfoTag.h"
20 #include "pvr/timers/PVRTimers.h"
21 #include "utils/URIUtils.h"
22 #include "utils/log.h"
24 #include <memory>
26 namespace PVR
28 std::shared_ptr<CPVREpgInfoTag> CPVRItem::GetEpgInfoTag() const
30 if (m_item->IsEPG())
32 return m_item->GetEPGInfoTag();
34 else if (m_item->IsPVRChannel())
36 return m_item->GetPVRChannelInfoTag()->GetEPGNow();
38 else if (m_item->IsPVRTimer())
40 return m_item->GetPVRTimerInfoTag()->GetEpgInfoTag();
42 else if (URIUtils::IsPVR(m_item->GetDynPath()))
44 CLog::LogF(LOGERROR, "Unsupported item type!");
46 return {};
49 std::shared_ptr<CPVREpgInfoTag> CPVRItem::GetNextEpgInfoTag() const
51 if (m_item->IsEPG())
53 const std::shared_ptr<const CPVRChannel> channel =
54 CServiceBroker::GetPVRManager().ChannelGroups()->GetChannelForEpgTag(
55 m_item->GetEPGInfoTag());
56 if (channel)
57 return channel->GetEPGNext();
59 else if (m_item->IsPVRChannel())
61 return m_item->GetPVRChannelInfoTag()->GetEPGNext();
63 else if (m_item->IsPVRTimer())
65 const std::shared_ptr<const CPVRChannel> channel = m_item->GetPVRTimerInfoTag()->Channel();
66 if (channel)
67 return channel->GetEPGNext();
69 else if (URIUtils::IsPVR(m_item->GetDynPath()))
71 CLog::LogF(LOGERROR, "Unsupported item type!");
73 return {};
76 std::shared_ptr<CPVRChannel> CPVRItem::GetChannel() const
78 if (m_item->IsPVRChannel())
80 return m_item->GetPVRChannelInfoTag();
82 else if (m_item->IsEPG())
84 return CServiceBroker::GetPVRManager().ChannelGroups()->GetChannelForEpgTag(
85 m_item->GetEPGInfoTag());
87 else if (m_item->IsPVRTimer())
89 return m_item->GetPVRTimerInfoTag()->Channel();
91 else if (m_item->IsPVRRecording())
93 return m_item->GetPVRRecordingInfoTag()->Channel();
95 else if (URIUtils::IsPVR(m_item->GetDynPath()))
97 CLog::LogF(LOGERROR, "Unsupported item type!");
99 return {};
102 std::shared_ptr<CPVRTimerInfoTag> CPVRItem::GetTimerInfoTag() const
104 if (m_item->IsPVRTimer())
106 return m_item->GetPVRTimerInfoTag();
108 else if (m_item->IsEPG())
110 return CServiceBroker::GetPVRManager().Timers()->GetTimerForEpgTag(m_item->GetEPGInfoTag());
112 else if (m_item->IsPVRChannel())
114 return CServiceBroker::GetPVRManager().Timers()->GetActiveTimerForChannel(
115 m_item->GetPVRChannelInfoTag());
117 else if (URIUtils::IsPVR(m_item->GetDynPath()))
119 CLog::LogF(LOGERROR, "Unsupported item type!");
121 return {};
124 std::shared_ptr<CPVRRecording> CPVRItem::GetRecording() const
126 if (m_item->IsPVRRecording())
128 return m_item->GetPVRRecordingInfoTag();
130 else if (m_item->IsEPG())
132 return CServiceBroker::GetPVRManager().Recordings()->GetRecordingForEpgTag(
133 m_item->GetEPGInfoTag());
135 else if (URIUtils::IsPVR(m_item->GetDynPath()))
137 CLog::LogF(LOGERROR, "Unsupported item type!");
139 return {};
142 bool CPVRItem::IsRadio() const
144 if (m_item->IsPVRChannel())
146 return m_item->GetPVRChannelInfoTag()->IsRadio();
148 else if (m_item->IsEPG())
150 return m_item->GetEPGInfoTag()->IsRadio();
152 else if (m_item->IsPVRRecording())
154 return m_item->GetPVRRecordingInfoTag()->IsRadio();
156 else if (m_item->IsPVRTimer())
158 return m_item->GetPVRTimerInfoTag()->IsRadio();
160 else if (URIUtils::IsPVR(m_item->GetDynPath()))
162 CLog::LogF(LOGERROR, "Unsupported item type!");
164 return false;
167 } // namespace PVR