summaryrefslogtreecommitdiffstats
path: root/xbmc/pvr/PVRItem.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 18:07:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 18:07:22 +0000
commitc04dcc2e7d834218ef2d4194331e383402495ae1 (patch)
tree7333e38d10d75386e60f336b80c2443c1166031d /xbmc/pvr/PVRItem.cpp
parentInitial commit. (diff)
downloadkodi-c04dcc2e7d834218ef2d4194331e383402495ae1.tar.xz
kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.zip
Adding upstream version 2:20.4+dfsg.upstream/2%20.4+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'xbmc/pvr/PVRItem.cpp')
-rw-r--r--xbmc/pvr/PVRItem.cpp167
1 files changed, 167 insertions, 0 deletions
diff --git a/xbmc/pvr/PVRItem.cpp b/xbmc/pvr/PVRItem.cpp
new file mode 100644
index 0000000..5eee911
--- /dev/null
+++ b/xbmc/pvr/PVRItem.cpp
@@ -0,0 +1,167 @@
+/*
+ * Copyright (C) 2016-2018 Team Kodi
+ * This file is part of Kodi - https://kodi.tv
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * See LICENSES/README.md for more information.
+ */
+
+#include "PVRItem.h"
+
+#include "FileItem.h"
+#include "ServiceBroker.h"
+#include "pvr/PVRManager.h"
+#include "pvr/channels/PVRChannel.h"
+#include "pvr/channels/PVRChannelGroupsContainer.h"
+#include "pvr/epg/EpgInfoTag.h"
+#include "pvr/recordings/PVRRecording.h"
+#include "pvr/recordings/PVRRecordings.h"
+#include "pvr/timers/PVRTimerInfoTag.h"
+#include "pvr/timers/PVRTimers.h"
+#include "utils/URIUtils.h"
+#include "utils/log.h"
+
+#include <memory>
+
+namespace PVR
+{
+std::shared_ptr<CPVREpgInfoTag> CPVRItem::GetEpgInfoTag() const
+{
+ if (m_item->IsEPG())
+ {
+ return m_item->GetEPGInfoTag();
+ }
+ else if (m_item->IsPVRChannel())
+ {
+ return m_item->GetPVRChannelInfoTag()->GetEPGNow();
+ }
+ else if (m_item->IsPVRTimer())
+ {
+ return m_item->GetPVRTimerInfoTag()->GetEpgInfoTag();
+ }
+ else if (URIUtils::IsPVR(m_item->GetDynPath()))
+ {
+ CLog::LogF(LOGERROR, "Unsupported item type!");
+ }
+ return {};
+}
+
+std::shared_ptr<CPVREpgInfoTag> CPVRItem::GetNextEpgInfoTag() const
+{
+ if (m_item->IsEPG())
+ {
+ const std::shared_ptr<CPVRChannel> channel =
+ CServiceBroker::GetPVRManager().ChannelGroups()->GetChannelForEpgTag(
+ m_item->GetEPGInfoTag());
+ if (channel)
+ return channel->GetEPGNext();
+ }
+ else if (m_item->IsPVRChannel())
+ {
+ return m_item->GetPVRChannelInfoTag()->GetEPGNext();
+ }
+ else if (m_item->IsPVRTimer())
+ {
+ const std::shared_ptr<CPVRChannel> channel = m_item->GetPVRTimerInfoTag()->Channel();
+ if (channel)
+ return channel->GetEPGNext();
+ }
+ else if (URIUtils::IsPVR(m_item->GetDynPath()))
+ {
+ CLog::LogF(LOGERROR, "Unsupported item type!");
+ }
+ return {};
+}
+
+std::shared_ptr<CPVRChannel> CPVRItem::GetChannel() const
+{
+ if (m_item->IsPVRChannel())
+ {
+ return m_item->GetPVRChannelInfoTag();
+ }
+ else if (m_item->IsEPG())
+ {
+ return CServiceBroker::GetPVRManager().ChannelGroups()->GetChannelForEpgTag(
+ m_item->GetEPGInfoTag());
+ }
+ else if (m_item->IsPVRTimer())
+ {
+ return m_item->GetPVRTimerInfoTag()->Channel();
+ }
+ else if (m_item->IsPVRRecording())
+ {
+ return m_item->GetPVRRecordingInfoTag()->Channel();
+ }
+ else if (URIUtils::IsPVR(m_item->GetDynPath()))
+ {
+ CLog::LogF(LOGERROR, "Unsupported item type!");
+ }
+ return {};
+}
+
+std::shared_ptr<CPVRTimerInfoTag> CPVRItem::GetTimerInfoTag() const
+{
+ if (m_item->IsPVRTimer())
+ {
+ return m_item->GetPVRTimerInfoTag();
+ }
+ else if (m_item->IsEPG())
+ {
+ return CServiceBroker::GetPVRManager().Timers()->GetTimerForEpgTag(m_item->GetEPGInfoTag());
+ }
+ else if (m_item->IsPVRChannel())
+ {
+ return CServiceBroker::GetPVRManager().Timers()->GetActiveTimerForChannel(
+ m_item->GetPVRChannelInfoTag());
+ }
+ else if (URIUtils::IsPVR(m_item->GetDynPath()))
+ {
+ CLog::LogF(LOGERROR, "Unsupported item type!");
+ }
+ return {};
+}
+
+std::shared_ptr<CPVRRecording> CPVRItem::GetRecording() const
+{
+ if (m_item->IsPVRRecording())
+ {
+ return m_item->GetPVRRecordingInfoTag();
+ }
+ else if (m_item->IsEPG())
+ {
+ return CServiceBroker::GetPVRManager().Recordings()->GetRecordingForEpgTag(
+ m_item->GetEPGInfoTag());
+ }
+ else if (URIUtils::IsPVR(m_item->GetDynPath()))
+ {
+ CLog::LogF(LOGERROR, "Unsupported item type!");
+ }
+ return {};
+}
+
+bool CPVRItem::IsRadio() const
+{
+ if (m_item->IsPVRChannel())
+ {
+ return m_item->GetPVRChannelInfoTag()->IsRadio();
+ }
+ else if (m_item->IsEPG())
+ {
+ return m_item->GetEPGInfoTag()->IsRadio();
+ }
+ else if (m_item->IsPVRRecording())
+ {
+ return m_item->GetPVRRecordingInfoTag()->IsRadio();
+ }
+ else if (m_item->IsPVRTimer())
+ {
+ return m_item->GetPVRTimerInfoTag()->IsRadio();
+ }
+ else if (URIUtils::IsPVR(m_item->GetDynPath()))
+ {
+ CLog::LogF(LOGERROR, "Unsupported item type!");
+ }
+ return false;
+}
+
+} // namespace PVR