-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25356 from ksooo/pvr-channelgroups-cleanup
[PVR] Channel groups cleanup
- Loading branch information
Showing
13 changed files
with
269 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Copyright (C) 2024 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 "PVRChannelGroupFactory.h" | ||
|
||
#include "pvr/channels/PVRChannelGroupAllChannels.h" | ||
#include "pvr/channels/PVRChannelGroupFromClient.h" | ||
#include "pvr/channels/PVRChannelGroupFromUser.h" | ||
#include "pvr/channels/PVRChannelsPath.h" | ||
#include "utils/log.h" | ||
|
||
using namespace PVR; | ||
|
||
std::shared_ptr<CPVRChannelGroup> CPVRChannelGroupFactory::CreateAllChannelsGroup(bool isRadio) | ||
{ | ||
return std::make_shared<CPVRChannelGroupAllChannels>(isRadio); | ||
} | ||
|
||
std::shared_ptr<CPVRChannelGroup> CPVRChannelGroupFactory::CreateClientGroup( | ||
const PVR_CHANNEL_GROUP& groupData, | ||
int clientID, | ||
const std::shared_ptr<const CPVRChannelGroup>& allChannels) | ||
{ | ||
return std::make_shared<CPVRChannelGroupFromClient>(groupData, clientID, allChannels); | ||
} | ||
|
||
std::shared_ptr<CPVRChannelGroup> CPVRChannelGroupFactory::CreateUserGroup( | ||
bool isRadio, | ||
const std::string& name, | ||
const std::shared_ptr<const CPVRChannelGroup>& allChannels) | ||
{ | ||
return std::make_shared<CPVRChannelGroupFromUser>( | ||
CPVRChannelsPath{isRadio, name, PVR_GROUP_CLIENT_ID_LOCAL}, allChannels); | ||
} | ||
|
||
std::shared_ptr<CPVRChannelGroup> CPVRChannelGroupFactory::CreateGroup( | ||
int groupType, | ||
const CPVRChannelsPath& groupPath, | ||
const std::shared_ptr<const CPVRChannelGroup>& allChannels) | ||
{ | ||
switch (groupType) | ||
{ | ||
case PVR_GROUP_TYPE_SYSTEM_ALL_CHANNELS: | ||
return std::make_shared<CPVRChannelGroupAllChannels>(groupPath); | ||
case PVR_GROUP_TYPE_USER: | ||
return std::make_shared<CPVRChannelGroupFromUser>(groupPath, allChannels); | ||
case PVR_GROUP_TYPE_CLIENT: | ||
return std::make_shared<CPVRChannelGroupFromClient>(groupPath, allChannels); | ||
default: | ||
CLog::LogFC(LOGERROR, LOGPVR, "Cannot create channel group '{}'. Unknown type {}.", | ||
groupPath.GetGroupName(), groupType); | ||
return {}; | ||
} | ||
} | ||
|
||
int CPVRChannelGroupFactory::GetGroupTypePriority( | ||
const std::shared_ptr<const CPVRChannelGroup>& group) const | ||
{ | ||
switch (group->GroupType()) | ||
{ | ||
case PVR_GROUP_TYPE_SYSTEM_ALL_CHANNELS: | ||
return 0; // highest | ||
case PVR_GROUP_TYPE_USER: | ||
return 1; | ||
case PVR_GROUP_TYPE_CLIENT: | ||
return 2; | ||
default: | ||
return 3; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright (C) 2024 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 <memory> | ||
|
||
struct PVR_CHANNEL_GROUP; | ||
|
||
namespace PVR | ||
{ | ||
|
||
class CPVRChannelGroup; | ||
class CPVRChannelsPath; | ||
|
||
class CPVRChannelGroupFactory | ||
{ | ||
public: | ||
CPVRChannelGroupFactory() = default; | ||
virtual ~CPVRChannelGroupFactory() = default; | ||
|
||
/*! | ||
* @brief Create an all channels group instance. | ||
* @param isRadio Whether Radio or TV. | ||
* @return The new group. | ||
*/ | ||
std::shared_ptr<CPVRChannelGroup> CreateAllChannelsGroup(bool isRadio); | ||
|
||
/*! | ||
* @brief Create an instance for a group provided by a PVR client add-on. | ||
* @param groupData The group data. | ||
* @param clientID The id of the client that provided the group. | ||
* @param allChannels The all channels group. | ||
* @return The new group. | ||
*/ | ||
std::shared_ptr<CPVRChannelGroup> CreateClientGroup( | ||
const PVR_CHANNEL_GROUP& groupData, | ||
int clientID, | ||
const std::shared_ptr<const CPVRChannelGroup>& allChannels); | ||
|
||
/*! | ||
* @brief Create an instance for a group created by the user. | ||
* @param isRadio Whether Radio or TV. | ||
* @param name The name for the group. | ||
* @param allChannels The all channels group. | ||
* @return The new group. | ||
*/ | ||
std::shared_ptr<CPVRChannelGroup> CreateUserGroup( | ||
bool isRadio, | ||
const std::string& name, | ||
const std::shared_ptr<const CPVRChannelGroup>& allChannels); | ||
|
||
/*! | ||
* @brief Create a channel group matching the given type. | ||
* @param groupType The type of the group. | ||
* @param groupPath The path of the group. | ||
* @param allChannels The all channels group. | ||
* @return The new group. | ||
*/ | ||
std::shared_ptr<CPVRChannelGroup> CreateGroup( | ||
int groupType, | ||
const CPVRChannelsPath& groupPath, | ||
const std::shared_ptr<const CPVRChannelGroup>& allChannels); | ||
|
||
/*! | ||
* @brief Get the priority (e.g. for sorting groups) for the type of the given group. Lower number means higer priority. | ||
* @param group The group. | ||
* @return The group's type priority. | ||
*/ | ||
int GetGroupTypePriority(const std::shared_ptr<const CPVRChannelGroup>& group) const; | ||
}; | ||
} // namespace PVR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.