| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
#pragma once |
| 10 |
|
| 11 |
#include "threads/CriticalSection.h" |
| 12 |
|
| 13 |
#include <map> |
| 14 |
#include <memory> |
| 15 |
#include <string> |
| 16 |
|
| 17 |
#include <pipewire/core.h> |
| 18 |
|
| 19 |
namespace KODI |
| 20 |
{ |
| 21 |
namespace PIPEWIRE |
| 22 |
{ |
| 23 |
|
| 24 |
class CPipewireCore; |
| 25 |
class CPipewireGlobal; |
| 26 |
|
| 27 |
class CPipewireRegistry |
| 28 |
{ |
| 29 |
public: |
| 30 |
explicit CPipewireRegistry(CPipewireCore& core); |
| 31 |
CPipewireRegistry() = delete; |
| 32 |
~CPipewireRegistry(); |
| 33 |
|
| 34 |
pw_registry* Get() const { return m_registry.get(); } |
| 35 |
|
| 36 |
CPipewireCore& GetCore() const { return m_core; } |
| 37 |
|
| 38 |
std::map<uint32_t, std::unique_ptr<CPipewireGlobal>>& GetGlobals() { return m_globals; } |
| 39 |
|
| 40 |
|
| 41 |
void lock() { m_lock.lock(); } |
| 42 |
void unlock() { m_lock.unlock(); } |
| 43 |
|
| 44 |
private: |
| 45 |
static void OnGlobalAdded(void* userdata, |
| 46 |
uint32_t id, |
| 47 |
uint32_t permissions, |
| 48 |
const char* type, |
| 49 |
uint32_t version, |
| 50 |
const struct spa_dict* props); |
| 51 |
static void OnGlobalRemoved(void* userdata, uint32_t id); |
| 52 |
|
| 53 |
static pw_registry_events CreateRegistryEvents(); |
| 54 |
|
| 55 |
CPipewireCore& m_core; |
| 56 |
|
| 57 |
const pw_registry_events m_registryEvents; |
| 58 |
|
| 59 |
spa_hook m_registryListener; |
| 60 |
struct PipewireRegistryDeleter |
| 61 |
{ |
| 62 |
void operator()(pw_registry* p) { pw_proxy_destroy(reinterpret_cast<pw_proxy*>(p)); } |
| 63 |
}; |
| 64 |
|
| 65 |
std::unique_ptr<pw_registry, PipewireRegistryDeleter> m_registry; |
| 66 |
|
| 67 |
std::map<uint32_t, std::unique_ptr<CPipewireGlobal>> m_globals; |
| 68 |
|
| 69 |
CCriticalSection m_lock; |
| 70 |
}; |
| 71 |
|
| 72 |
} |
| 73 |
} |