#pragma once

#include <pipewire/pipewire.h>
#include <pipewire/extensions/metadata.h>

//#include <QObject>

namespace UkuiAudioFramwork
{
class Pipewire;

class PipewireMetadata
{
private:
    void onAllKeysRemoved(uint32_t id);
    void onKeyRemoved(uint32_t id, const char* key);
    void onKeyUpdated(uint32_t id, const char* key, const char* type, const char* value);

protected:
    Pipewire *pipewire = nullptr;
    struct pw_metadata *metadata = nullptr;
    struct spa_hook metadata_listener;

public:
    explicit PipewireMetadata(Pipewire *parent, uint32_t id, const spa_dict* props);
    virtual ~PipewireMetadata();

    void setProperty(const char *key, const char *value);
    void clear();

    int _metadata_property(uint32_t id,
                           const char* key,
                           const char* type,
                           const char* value);
};
}
