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.
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"
28 std::shared_ptr
<CPVREpgInfoTag
> CPVRItem::GetEpgInfoTag() const
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!");
49 std::shared_ptr
<CPVREpgInfoTag
> CPVRItem::GetNextEpgInfoTag() const
53 const std::shared_ptr
<const CPVRChannel
> channel
=
54 CServiceBroker::GetPVRManager().ChannelGroups()->GetChannelForEpgTag(
55 m_item
->GetEPGInfoTag());
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();
67 return channel
->GetEPGNext();
69 else if (URIUtils::IsPVR(m_item
->GetDynPath()))
71 CLog::LogF(LOGERROR
, "Unsupported item type!");
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!");
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!");
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!");
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!");