[videodb] remove unused seasons table from episode_view
[xbmc.git] / xbmc / media / decoderfilter / DecoderFilterManager.h
blob78298c071444c8e22b96e699a9bd3a27e283d756
1 /*
2 * Copyright (C) 2013-2019 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.
7 */
9 #pragma once
11 /**
12 * \file platform\DecoderFilter.h
13 * \brief Declares CDecoderFilterManager which gives control about how / when to use platform decoder.
16 #include "threads/CriticalSection.h"
18 #include <cinttypes>
19 #include <set>
20 #include <string>
22 class CDVDStreamInfo;
24 namespace tinyxml2
26 class XMLNode;
29 /**
30 * @class CDecoderFilter
32 * @brief Declaration of CDecoderFilter.
35 class CDecoderFilter
37 public:
38 /**
39 * @brief Flags to control decoder validity.
41 enum : uint32_t
43 FLAG_GENERAL_ALLOWED = 1, ///< early false exit if set
44 FLAG_STILLS_ALLOWED = 2, ///< early false exit if set and stream is marked as "has stillframes"
45 FLAG_DVD_ALLOWED = 4 ///< early false exit if set and stream is marked as dvd
48 /**
49 * \fn CDecoderFilter::CDecoderFilter(const std::string& name);
50 * \brief constructs a CDecoderFilter
51 * \param name decodername
52 * \return nothing.
54 CDecoderFilter(const std::string& name) : m_name(name) {}
56 /**
57 * \fn CDecoderFilter::CDecoderFilter(const std::string& name, uint32_t flags, uint32_t maxWidth, uint32_t maxHeight);
58 * \brief constructs a CDecoderFilter
59 * \param name decodername
60 * \param flags collection of FLAG_ values, bitwise OR
61 * \param minHeight minimum height of stream allowed by this decoder
62 * \return nothing.
64 CDecoderFilter(const std::string& name, uint32_t flags, int minHeight);
66 virtual ~CDecoderFilter() = default;
68 /**
69 * \fn CDecoderFilter::operator < (const CDecoderFilter& other);
70 * \brief used for sorting / replacing / find
72 bool operator<(const CDecoderFilter& other) const { return m_name < other.m_name; }
74 /**
75 * \fn CDecoderFilter::isValid(const CDVDStreamInfo& streamInfo);
76 * \brief test if stream is allowed by filter.
77 * \return true if valid, false otherwise
79 virtual bool isValid(const CDVDStreamInfo& streamInfo) const;
81 /**
82 * \fn CDecoderFilter::Load(const XMLNode* settings);
83 * \brief load all members from XML node
84 * \param node filter node from where to get the values
85 * \return true if operation was successful, false on error
87 virtual bool Load(const tinyxml2::XMLNode* node);
89 /**
90 * \fn CDecoderFilter::Save(XMLNode* settings);
91 * \brief store all members in XML node
92 * \param node a ready to use filter setting node
93 * \return true if operation was successful, false on error
95 virtual bool Save(tinyxml2::XMLNode* node) const;
97 private:
98 std::string m_name;
100 uint32_t m_flags = 0;
101 int m_minHeight = 0;
106 * @class CDecoderFilterManager
108 * @brief Class which handles multiple CDecoderFilter elements.
112 class CDecoderFilterManager
114 public:
115 CDecoderFilterManager() { Load(); }
116 virtual ~CDecoderFilterManager() { Save(); }
119 * \fn bool CDecoderFilterManager::add(const CDecoderFilter& filter);
120 * \brief adds an CDecoderFilter if key [filter.name] is not yet existing.
121 * \param filter the decoder filter to add / replace.
122 * \return nothing.
124 void add(const CDecoderFilter& filter);
128 * \fn bool CDecoderFilterManager::validate(const std::string& name, const CDVDStreamInfo& streamInfo);
129 * \brief Validates if decoder with name [name] is allowed to be used.
130 * \param streamInfo Stream information used to validate().
131 * \return true if HardwarDecoder could be used, false otherwise.
133 bool isValid(const std::string& name, const CDVDStreamInfo& streamInfo);
135 protected:
136 bool Load();
137 bool Save() const;
139 private:
140 bool m_dirty = false;
141 std::set<CDecoderFilter> m_filters;
142 mutable CCriticalSection m_critical;