kodi
DRMObject.h
1 /*
2  * Copyright (C) 2005-2020 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include <cstddef>
12 #include <cstdint>
13 #include <memory>
14 #include <optional>
15 #include <string_view>
16 #include <vector>
17 
18 #include <xf86drmMode.h>
19 
20 namespace KODI
21 {
22 namespace WINDOWING
23 {
24 namespace GBM
25 {
26 
28 {
29 public:
30  CDRMObject(const CDRMObject&) = delete;
31  CDRMObject& operator=(const CDRMObject&) = delete;
32  virtual ~CDRMObject() = default;
33 
34  std::string GetTypeName() const;
35  std::string GetPropertyName(uint32_t propertyId) const;
36 
37  uint32_t GetId() const { return m_id; }
38  uint32_t GetPropertyId(const std::string& name) const;
39  std::optional<uint64_t> GetPropertyValue(std::string_view name, std::string_view valueName) const;
40 
41  bool SetProperty(const std::string& name, uint64_t value);
42  bool SupportsProperty(const std::string& name);
43 
44 protected:
45  explicit CDRMObject(int fd);
46 
47  bool GetProperties(uint32_t id, uint32_t type);
48 
50  {
51  void operator()(drmModeObjectProperties* p) { drmModeFreeObjectProperties(p); }
52  };
53 
54  std::unique_ptr<drmModeObjectProperties, DrmModeObjectPropertiesDeleter> m_props;
55 
57  {
58  void operator()(drmModePropertyRes* p) { drmModeFreeProperty(p); }
59  };
60 
61  std::vector<std::unique_ptr<drmModePropertyRes, DrmModePropertyResDeleter>> m_propsInfo;
62 
63  int m_fd{-1};
64 
65 private:
66  uint32_t m_id{0};
67  uint32_t m_type{0};
68 };
69 
70 } // namespace GBM
71 } // namespace WINDOWING
72 } // namespace KODI
Definition: DRMObject.h:27
Definition: AudioDecoder.h:18