forked from xbmc/xbmc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PVRChannelGroupsContainer.h
192 lines (161 loc) · 6.01 KB
/
PVRChannelGroupsContainer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/*
* Copyright (C) 2012-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.
*/
#pragma once
#include "threads/CriticalSection.h"
#include <memory>
namespace PVR
{
class CPVRChannel;
class CPVRChannelGroup;
class CPVRChannelGroups;
class CPVREpgInfoTag;
class CPVRChannelGroupsContainer
{
public:
/*!
* @brief Create a new container for all channel groups
*/
CPVRChannelGroupsContainer(void);
/*!
* @brief Destroy this container.
*/
virtual ~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 Checks whether groups were already loaded.
* @return True if groups were successfully loaded, false otherwise.
*/
bool Loaded(void) const;
/*!
* @brief Unload and destruct all channel groups and all channels in them.
*/
void Unload(void);
/*!
* @brief Update the contents of all 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);
/*!
* @brief Get the TV channel groups.
* @return The TV channel groups.
*/
CPVRChannelGroups* GetTV(void) const { return Get(false); }
/*!
* @brief Get the radio channel groups.
* @return The radio channel groups.
*/
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.
*/
CPVRChannelGroups* Get(bool bRadio) const;
/*!
* @brief Get the group containing all TV channels.
* @return The group containing all TV channels.
*/
std::shared_ptr<CPVRChannelGroup> GetGroupAllTV(void) const { return GetGroupAll(false); }
/*!
* @brief Get the group containing all radio channels.
* @return The group containing all radio channels.
*/
std::shared_ptr<CPVRChannelGroup> 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.
*/
std::shared_ptr<CPVRChannelGroup> GetGroupAll(bool bRadio) const;
/*!
* @brief Get a group given it's ID.
* @param iGroupId The ID of the group.
* @return The requested group or NULL if it wasn't found.
*/
std::shared_ptr<CPVRChannelGroup> GetByIdFromAll(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.
*/
std::shared_ptr<CPVRChannel> GetChannelById(int iChannelId) const;
/*!
* @brief Get a channel given it's EPG ID.
* @param iEpgId The EPG ID of the channel.
* @return The channel or NULL if it wasn't found.
*/
std::shared_ptr<CPVRChannel> GetChannelByEpgId(int iEpgId) const;
/*!
* @brief Get the channel for the given epg tag.
* @param epgTag The epg tag.
* @return The channel.
*/
std::shared_ptr<CPVRChannel> GetChannelForEpgTag(const std::shared_ptr<CPVREpgInfoTag>& epgTag) const;
/*!
* @brief Get a channel given it's path.
* @param strPath The path.
* @return The channel or nullptr if it wasn't found.
*/
std::shared_ptr<CPVRChannel> GetByPath(const std::string& strPath) const;
/*!
* @brief Get the group that is currently selected in the UI.
* @param bRadio True to get the selected radio group, false to get the selected TV group.
* @return The selected group.
*/
std::shared_ptr<CPVRChannelGroup> GetSelectedGroup(bool bRadio) const;
/*!
* @brief Get a channel given it's channel ID from all containers.
* @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.
*/
std::shared_ptr<CPVRChannel> GetByUniqueID(int iUniqueChannelId, int iClientID) const;
/*!
* @brief Get the channel that was played last.
* @return The requested channel or nullptr.
*/
std::shared_ptr<CPVRChannel> GetLastPlayedChannel() const;
/*!
* @brief The group that was played last and optionally contains the given channel.
* @param iChannelID The channel ID
* @return The last watched group.
*/
std::shared_ptr<CPVRChannelGroup> GetLastPlayedGroup(int iChannelID = -1) const;
/*!
* @brief Create EPG tags for channels in all internal channel groups.
* @return True if EPG tags were created successfully.
*/
bool CreateChannelEpgs(void);
/*!
* @brief Return the group which was previous played.
* @return The group which was previous played.
*/
std::shared_ptr<CPVRChannelGroup> GetPreviousPlayedGroup(void);
/*!
* @brief Set the last played group.
* @param The last played group
*/
void SetLastPlayedGroup(const std::shared_ptr<CPVRChannelGroup>& group);
protected:
CPVRChannelGroups* m_groupsRadio; /*!< all radio channel groups */
CPVRChannelGroups* m_groupsTV; /*!< all TV channel groups */
CCriticalSection m_critSection;
bool m_bUpdateChannelsOnly = false;
bool m_bIsUpdating = false;
std::shared_ptr<CPVRChannelGroup> m_lastPlayedGroups[2]; /*!< used to store the last played groups */
private :
CPVRChannelGroupsContainer& operator=(const CPVRChannelGroupsContainer&) = delete;
CPVRChannelGroupsContainer(const CPVRChannelGroupsContainer&) = delete;
bool m_bLoaded = false;
};
}