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
|
/*
* Copyright (C) 2005-2021 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 "addons/IAddonSupportList.h"
#include "threads/CriticalSection.h"
#include <map>
#include <memory>
#include <string>
#include <utility>
#include <vector>
namespace ADDON
{
enum class AddonType;
class CAddonMgr;
class CAddonInfo;
struct AddonEvent;
}
namespace KODI
{
namespace ADDONS
{
/*!
* @brief Class to manage all available and activated add-ons and
* to release their types to the outside for selection.
*
* @note It may also make sense in the future to expand this class and design it
* globally in Kodi so that other addons can also be managed with it (all which
* have mimetypes and file extensions, e.g. vfs, audioencoder).
*/
class CExtsMimeSupportList : public KODI::ADDONS::IAddonSupportList
{
public:
CExtsMimeSupportList(ADDON::CAddonMgr& addonMgr);
~CExtsMimeSupportList();
/*!
* @brief Filter selection values.
*/
enum class FilterSelect
{
/*! To select all available */
all,
/*! To select only them where support tags */
hasTags,
/*! Get only where support tracks within */
hasTracks
};
/*!
* @brief Structure to store information about supported part.
*/
struct SupportValue
{
SupportValue(int description, std::string icon)
: m_description(description), m_icon(std::move(icon))
{
}
// Description text about supported part
int m_description;
// Own by addon defined icon path
std::string m_icon;
};
/*!
* @brief Structure to store available data for related addon.
*/
struct SupportValues
{
// Type of stored addon to check on scan
ADDON::AddonType m_addonType{};
// Related addon info class
std::shared_ptr<ADDON::CAddonInfo> m_addonInfo;
// Addon his own codec identification name
std::string m_codecName;
// If as true support addons own song information tags
bool m_hasTags{false};
// To know addon includes several tracks inside one file, if set to true
bool m_hasTracks{false};
// List of supported file extensions by addon
// First: Extension name
// Second: With @ref SupportValue defined content
std::map<std::string, SupportValue> m_supportedExtensions;
// List of supported mimetypes by addon
// First: Mimetype name
// Second: With @ref SupportValue defined content
std::map<std::string, SupportValue> m_supportedMimetypes;
};
/*!
* @brief Get list of all by audiodecoder supported parts.
*
* Thought to use on planned new window about management about supported
* extensions and mimetypes in Kodi and to allow edit by user to enable or
* disable corresponding parts.
*
* This function is also used to notify Kodi supported formats and to allow
* playback.
*
* @param[in] select To filter the listed information by type
* @return List of the available types listed for the respective add-on
*/
std::vector<SupportValues> GetSupportedAddonInfos(FilterSelect select);
/*!
* @brief To query the desired file extension is supported in it.
*
* @param[in] ext Extension name to check
* @return True if within supported, false if not
*/
bool IsExtensionSupported(const std::string& ext);
/*!
* @brief To get a list of all compatible audio decoder add-ons for the file extension.
*
* @param[in] ext Extension name to check
* @param[in] select To filter the listed information by type
* @return List of @ref ADDON::CAddonInfo where support related extension
*/
std::vector<std::pair<ADDON::AddonType, std::shared_ptr<ADDON::CAddonInfo>>>
GetExtensionSupportedAddonInfos(const std::string& ext, FilterSelect select);
/*!
* @brief To query the desired file mimetype is supported in it.
*
* @param[in] mimetype Mimetype name to check
* @return True if within supported, false if not
*/
bool IsMimetypeSupported(const std::string& mimetype);
/*!
* @brief To get a list of all compatible audio decoder add-ons for the mimetype.
*
* @param[in] mimetype Mimetype name to check
* @param[in] select To filter the listed information by type
* @return List of @ref ADDON::CAddonInfo where support related mimetype
*/
std::vector<std::pair<ADDON::AddonType, std::shared_ptr<ADDON::CAddonInfo>>>
GetMimetypeSupportedAddonInfos(const std::string& mimetype, FilterSelect select);
/*!
* @brief To give all file extensions and MIME types supported by the addon.
*
* @param[in] addonId Identifier about wanted addon
* @return List of all supported parts on selected addon
*
* @sa KODI::ADDONS::IAddonSupportList
*/
std::vector<KODI::ADDONS::AddonSupportEntry> GetSupportedExtsAndMimeTypes(
const std::string& addonId) override;
protected:
void Update(const std::string& id);
void OnEvent(const ADDON::AddonEvent& event);
static SupportValues ScanAddonProperties(ADDON::AddonType type,
const std::shared_ptr<ADDON::CAddonInfo>& addonInfo);
CCriticalSection m_critSection;
std::vector<SupportValues> m_supportedList;
ADDON::CAddonMgr& m_addonMgr;
};
} /* namespace ADDONS */
} /* namespace KODI */
|