4#ifndef QPIPEWIRE_SPA_COMPAT_P_H
5#define QPIPEWIRE_SPA_COMPAT_P_H
29
30
31
33#include <spa/pod/parser.h>
34#include <spa/pod/builder.h>
35#include <spa/param/audio/format.h>
36#include <spa/param/format-utils.h>
39spa_format_audio_raw_parse(
const struct spa_pod *format,
struct spa_audio_info_raw *info)
41 struct spa_pod *position = NULL;
44 res = spa_pod_parse_object(format,
45 SPA_TYPE_OBJECT_Format, NULL,
46 SPA_FORMAT_AUDIO_format, SPA_POD_OPT_Id(&info->format),
47 SPA_FORMAT_AUDIO_rate, SPA_POD_OPT_Int(&info->rate),
48 SPA_FORMAT_AUDIO_channels, SPA_POD_OPT_Int(&info->channels),
49 SPA_FORMAT_AUDIO_position, SPA_POD_OPT_Pod(&position));
50 if (position == NULL ||
51 !spa_pod_copy_array(position, SPA_TYPE_Id, info->position, SPA_AUDIO_MAX_CHANNELS))
52 SPA_FLAG_SET(info->flags, SPA_AUDIO_FLAG_UNPOSITIONED);
57static inline struct spa_pod *
58spa_format_audio_raw_build(
struct spa_pod_builder *builder, uint32_t id,
59 const struct spa_audio_info_raw *info)
61 struct spa_pod_frame f;
62 spa_pod_builder_push_object(builder, &f, SPA_TYPE_OBJECT_Format, id);
63 spa_pod_builder_add(builder,
64 SPA_FORMAT_mediaType, SPA_POD_Id(SPA_MEDIA_TYPE_audio),
65 SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
67 if (info->format != SPA_AUDIO_FORMAT_UNKNOWN)
68 spa_pod_builder_add(builder,
69 SPA_FORMAT_AUDIO_format, SPA_POD_Id(info->format), 0);
71 spa_pod_builder_add(builder,
72 SPA_FORMAT_AUDIO_rate, SPA_POD_Int(info->rate), 0);
73 if (info->channels != 0) {
74 spa_pod_builder_add(builder,
75 SPA_FORMAT_AUDIO_channels, SPA_POD_Int(info->channels), 0);
76 if (!SPA_FLAG_IS_SET(info->flags, SPA_AUDIO_FLAG_UNPOSITIONED)) {
77 spa_pod_builder_add(builder, SPA_FORMAT_AUDIO_position,
78 SPA_POD_Array(
sizeof(uint32_t), SPA_TYPE_Id,
79 info->channels, info->position), 0);
82 return (
struct spa_pod*)spa_pod_builder_pop(builder, &f);
86
87
104
105
106
107enum spa_audio_iec958_codec {
108 SPA_AUDIO_IEC958_CODEC_UNKNOWN,
110 SPA_AUDIO_IEC958_CODEC_PCM,
111 SPA_AUDIO_IEC958_CODEC_DTS,
112 SPA_AUDIO_IEC958_CODEC_AC3,
113 SPA_AUDIO_IEC958_CODEC_MPEG,
114 SPA_AUDIO_IEC958_CODEC_MPEG2_AAC,
116 SPA_AUDIO_IEC958_CODEC_EAC3,
118 SPA_AUDIO_IEC958_CODEC_TRUEHD,
119 SPA_AUDIO_IEC958_CODEC_DTSHD,
122struct spa_audio_info_iec958 {
123 enum spa_audio_iec958_codec codec;
128#define SPA_AUDIO_INFO_IEC958_INIT(...) ((struct spa_audio_info_iec958) { __VA_ARGS__ })
131
132
ObjectSerial serial() const
static bool minimumRequirementMet()
PwNodeHandle bindNode(ObjectId)
static QAudioDeviceMonitor & deviceMonitor()
static QAudioContextManager * instance()
void registerStreamReference(std::shared_ptr< QPipewireAudioStream >)
void unregisterStreamReference(const std::shared_ptr< QPipewireAudioStream > &)
PwMetadataHandle bindMetadata(ObjectId)
static auto withEventLoopLock(Closure &&c)
static bool isInPwThreadLoop()
static pw_loop * getEventLoop()
const PwCoreConnectionHandle & coreConnection() const
void audioSourcesChanged(QList< QAudioDevice >)
void unregisterObserver(const SharedObjectRemoveObserver &)
std::optional< ObjectSerial > findSourceNodeSerial(std::string_view nodeName) const
void setDefaultAudioSink(std::variant< QByteArray, NoDefaultDeviceType >)
DeviceLists getDeviceLists(bool verifyThreading=true)
void setDefaultAudioSource(std::variant< QByteArray, NoDefaultDeviceType >)
std::optional< ObjectId > findObjectId(ObjectSerial)
std::optional< ObjectSerial > findSinkNodeSerial(std::string_view nodeName) const
void objectRemoved(ObjectId)
static constexpr NoDefaultDeviceType NoDefaultDevice
void objectAdded(ObjectId, uint32_t permissions, PipewireRegistryType, uint32_t version, const spa_dict &props)
std::optional< ObjectSerial > findObjectSerial(ObjectId)
bool registerObserver(SharedObjectRemoveObserver)
std::optional< PipewireRegistryType > parsePipewireRegistryType(std::string_view sv)
constexpr std::array channelPositions7Dot1
constexpr std::array channelPositions3Dot1
constexpr std::array channelPositions5Dot0
static std::atomic_int s_sequenceNumberAllocator
std::unique_ptr< pw_core, PwCoreConnectionDeleter > PwCoreConnectionHandle
std::optional< std::string_view > getMetadataName(const PwPropertyDict &)
std::optional< ObjectSerial > getObjectSerial(const PwPropertyDict &)
std::optional< std::string_view > getNodeName(const PwPropertyDict &)
PwPropertyDict toPropertyDict(const spa_dict &)
spa_audio_info_raw asSpaAudioInfoRaw(const QAudioFormat &)
std::optional< std::string_view > getDeviceSysfsPath(const PwPropertyDict &)
std::optional< std::string_view > getDeviceName(const PwPropertyDict &)
constexpr std::array channelPositions5Dot1
constexpr std::array channelPositionsStereo
constexpr std::array channelPositions7Dot0
StrongIdType< uint32_t, ObjectIdTag > ObjectId
std::optional< std::string_view > getDeviceDescription(const PwPropertyDict &)
StrongIdType< uint64_t, ObjectSerialTag > ObjectSerial
constexpr std::array channelPositionsMono
std::optional< std::string_view > getMediaClass(const PwPropertyDict &)
constexpr std::array channelPositions2Dot1
std::shared_ptr< ObjectRemoveObserver > SharedObjectRemoveObserver
std::optional< ObjectId > getDeviceId(const PwPropertyDict &)
constexpr std::array channelPositions3Dot0
std::error_code make_error_code(int errnoValue=errno)
std::optional< std::string_view > getNodeDescription(const PwPropertyDict &)
PwPropertiesHandle makeProperties(QSpan< const spa_dict_item >)
bool pw_check_library_version(int major, int minor, int micro)
QDebug operator<<(QDebug dbg, const pw_time &state)
QDebug operator<<(QDebug dbg, const spa_dict &dict)
QDebug operator<<(QDebug dbg, enum pw_stream_state)
#define QT_MM_GUARDED_BY(Mutex)
QDebug operator<<(QDebug dbg, const spa_pod &pod)
q23::expected< void, int > asyncWait(pw_core *coreConnection, std::function< void()> handler)
pw_core_events coreEvents
q23::expected< bool, int > sync(pw_core *coreConnection, std::optional< std::chrono::nanoseconds > timeout={})
void operator()(Type *handle) const
ParamHandler paramHandler
NodeEventListener(PwNodeHandle, NodeHandler)
std::function< void(const struct pw_node_info *)> InfoHandler
void enumParams(spa_param_type)
std::function< void(int, uint32_t, uint32_t, uint32_t, const struct spa_pod *)> ParamHandler
void operator()(pw_core *handle) const
QList< QAudioDevice > sources
QList< QAudioDevice > sinks
friend QDebug operator<<(QDebug dbg, const StrongIdType &self)
friend bool comparesEqual(const StrongIdType &lhs, const StrongIdType &rhs) noexcept
friend Qt::strong_ordering compareThreeWay(const StrongIdType &lhs, const StrongIdType &rhs) noexcept