Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qpipewire_spa_compat_p.h
Go to the documentation of this file.
1// Copyright (C) 2018 Wim Taymans
2// SPDX-License-Identifier: MIT
3
4#ifndef QPIPEWIRE_SPA_COMPAT_P_H
5#define QPIPEWIRE_SPA_COMPAT_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18// clang-format off
19
20// old distros may miss functinality from newer upstream.
21// we collect them here for the time being
22
23#if !__has_include(<spa/param/audio/raw-utils.h>)
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28/**
29 * \addtogroup spa_param
30 * \{
31 */
32
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>
37
38static inline int
39spa_format_audio_raw_parse(const struct spa_pod *format, struct spa_audio_info_raw *info)
40{
41 struct spa_pod *position = NULL;
42 int res;
43 info->flags = 0;
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);
53
54 return res;
55}
56
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)
60{
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),
66 0);
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);
70 if (info->rate != 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);
80 }
81 }
82 return (struct spa_pod*)spa_pod_builder_pop(builder, &f);
83}
84
85/**
86 * \}
87 */
88
89#ifdef __cplusplus
90} /* extern "C" */
91#endif
92
93#endif // !__has_include(<spa/param/audio/raw-utils.h>)
94
95#if !__has_include(<spa/param/audio/iec958.h>)
96
97#include <stdint.h>
98
99#ifdef __cplusplus
100extern "C" {
101#endif
102
103/**
104 * \addtogroup spa_param
105 * \{
106 */
107enum spa_audio_iec958_codec {
108 SPA_AUDIO_IEC958_CODEC_UNKNOWN,
109
110 SPA_AUDIO_IEC958_CODEC_PCM,
111 SPA_AUDIO_IEC958_CODEC_DTS,
112 SPA_AUDIO_IEC958_CODEC_AC3,
113 SPA_AUDIO_IEC958_CODEC_MPEG, /**< MPEG-1 or MPEG-2 (Part 3, not AAC) */
114 SPA_AUDIO_IEC958_CODEC_MPEG2_AAC, /**< MPEG-2 AAC */
115
116 SPA_AUDIO_IEC958_CODEC_EAC3,
117
118 SPA_AUDIO_IEC958_CODEC_TRUEHD, /**< Dolby TrueHD */
119 SPA_AUDIO_IEC958_CODEC_DTSHD, /**< DTS-HD Master Audio */
120};
121
122struct spa_audio_info_iec958 {
123 enum spa_audio_iec958_codec codec; /*< format, one of the DSP formats in enum spa_audio_format_dsp */
124 uint32_t flags; /*< extra flags */
125 uint32_t rate; /*< sample rate */
126};
127
128#define SPA_AUDIO_INFO_IEC958_INIT(...) ((struct spa_audio_info_iec958) { __VA_ARGS__ })
129
130/**
131 * \}
132 */
133
134#ifdef __cplusplus
135} /* extern "C" */
136#endif
137
138#endif // !__has_include(<spa/param/audio/iec958.h>)
139
140#endif // QPIPEWIRE_SPA_COMPAT_P_H
void registerStreamReference(std::shared_ptr< QPipewireAudioStream >)
void unregisterStreamReference(const std::shared_ptr< QPipewireAudioStream > &)
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
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 >)
#define __has_include(x)
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)
q23::expected< bool, int > sync(pw_core *coreConnection, std::optional< std::chrono::nanoseconds > timeout={})
void operator()(Type *handle) const
NodeEventListener(PwNodeHandle, NodeHandler)
std::function< void(const struct pw_node_info *)> InfoHandler
std::function< void(int, uint32_t, uint32_t, uint32_t, const struct spa_pod *)> ParamHandler
void operator()(pw_core *handle) const
std::optional< QList< spa_audio_channel > > channelPositions
static std::optional< SpaObjectAudioFormat > parse(const struct spa_pod *pod)
static std::optional< SpaObjectAudioFormat > parse(const struct spa_pod_object *obj)
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