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.
12 * \file platform\DecoderFilter.h
13 * \brief Declares CDecoderFilterManager which gives control about how / when to use platform decoder.
16 #include "threads/CriticalSection.h"
30 * @class CDecoderFilter
32 * @brief Declaration of CDecoderFilter.
39 * @brief Flags to control decoder validity.
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
49 * \fn CDecoderFilter::CDecoderFilter(const std::string& name);
50 * \brief constructs a CDecoderFilter
51 * \param name decodername
54 CDecoderFilter(const std::string
& name
) : m_name(name
) {}
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
64 CDecoderFilter(const std::string
& name
, uint32_t flags
, int minHeight
);
66 virtual ~CDecoderFilter() = default;
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
; }
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;
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
);
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;
100 uint32_t m_flags
= 0;
106 * @class CDecoderFilterManager
108 * @brief Class which handles multiple CDecoderFilter elements.
112 class CDecoderFilterManager
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.
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
);
140 bool m_dirty
= false;
141 std::set
<CDecoderFilter
> m_filters
;
142 mutable CCriticalSection m_critical
;