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/buffers.h>)
24// older releases define SPA_PARAM_Buffers and SPA_PARAM_BUFFERS_* in param.h
25#include <spa/param/param.h>
26#endif
27
28#if !__has_include(<spa/param/audio/raw-utils.h>)
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33/**
34 * \addtogroup spa_param
35 * \{
36 */
37
38#include <spa/pod/parser.h>
39#include <spa/pod/builder.h>
40#include <spa/param/audio/format.h>
41#include <spa/param/format-utils.h>
42
43static inline int
44spa_format_audio_raw_parse(const struct spa_pod *format, struct spa_audio_info_raw *info)
45{
46 struct spa_pod *position = NULL;
47 int res;
48 info->flags = 0;
49 res = spa_pod_parse_object(format,
50 SPA_TYPE_OBJECT_Format, NULL,
51 SPA_FORMAT_AUDIO_format, SPA_POD_OPT_Id(&info->format),
52 SPA_FORMAT_AUDIO_rate, SPA_POD_OPT_Int(&info->rate),
53 SPA_FORMAT_AUDIO_channels, SPA_POD_OPT_Int(&info->channels),
54 SPA_FORMAT_AUDIO_position, SPA_POD_OPT_Pod(&position));
55 if (position == NULL ||
56 !spa_pod_copy_array(position, SPA_TYPE_Id, info->position, SPA_AUDIO_MAX_CHANNELS))
57 SPA_FLAG_SET(info->flags, SPA_AUDIO_FLAG_UNPOSITIONED);
58
59 return res;
60}
61
62static inline struct spa_pod *
63spa_format_audio_raw_build(struct spa_pod_builder *builder, uint32_t id,
64 const struct spa_audio_info_raw *info)
65{
66 struct spa_pod_frame f;
67 spa_pod_builder_push_object(builder, &f, SPA_TYPE_OBJECT_Format, id);
68 spa_pod_builder_add(builder,
69 SPA_FORMAT_mediaType, SPA_POD_Id(SPA_MEDIA_TYPE_audio),
70 SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
71 0);
72 if (info->format != SPA_AUDIO_FORMAT_UNKNOWN)
73 spa_pod_builder_add(builder,
74 SPA_FORMAT_AUDIO_format, SPA_POD_Id(info->format), 0);
75 if (info->rate != 0)
76 spa_pod_builder_add(builder,
77 SPA_FORMAT_AUDIO_rate, SPA_POD_Int(info->rate), 0);
78 if (info->channels != 0) {
79 spa_pod_builder_add(builder,
80 SPA_FORMAT_AUDIO_channels, SPA_POD_Int(info->channels), 0);
81 if (!SPA_FLAG_IS_SET(info->flags, SPA_AUDIO_FLAG_UNPOSITIONED)) {
82 spa_pod_builder_add(builder, SPA_FORMAT_AUDIO_position,
83 SPA_POD_Array(sizeof(uint32_t), SPA_TYPE_Id,
84 info->channels, info->position), 0);
85 }
86 }
87 return (struct spa_pod*)spa_pod_builder_pop(builder, &f);
88}
89
90/**
91 * \}
92 */
93
94#ifdef __cplusplus
95} /* extern "C" */
96#endif
97
98#endif // !__has_include(<spa/param/audio/raw-utils.h>)
99
100#if !__has_include(<spa/param/audio/iec958.h>)
101
102#include <stdint.h>
103
104#ifdef __cplusplus
105extern "C" {
106#endif
107
108/**
109 * \addtogroup spa_param
110 * \{
111 */
126
128 enum spa_audio_iec958_codec codec; /*< format, one of the DSP formats in enum spa_audio_format_dsp */
129 uint32_t flags; /*< extra flags */
130 uint32_t rate; /*< sample rate */
131};
132
133#define SPA_AUDIO_INFO_IEC958_INIT(...) ((struct spa_audio_info_iec958) { __VA_ARGS__ })
134
135/**
136 * \}
137 */
138
139#ifdef __cplusplus
140} /* extern "C" */
141#endif
142
143#endif // !__has_include(<spa/param/audio/iec958.h>)
144
145#if !__has_include(<spa/param/format.h>)
146
147#ifdef __cplusplus
148extern "C" {
149#endif
150
151/**
152 * \addtogroup spa_param
153 * \{
154 */
155
156/** media type for SPA_TYPE_OBJECT_Format */
157enum spa_media_type {
158 SPA_MEDIA_TYPE_unknown,
159 SPA_MEDIA_TYPE_audio,
160 SPA_MEDIA_TYPE_video,
161 SPA_MEDIA_TYPE_image,
162 SPA_MEDIA_TYPE_binary,
163 SPA_MEDIA_TYPE_stream,
164 SPA_MEDIA_TYPE_application,
165};
166
167/** media subtype for SPA_TYPE_OBJECT_Format */
168enum spa_media_subtype {
169 SPA_MEDIA_SUBTYPE_unknown,
170 SPA_MEDIA_SUBTYPE_raw,
171 SPA_MEDIA_SUBTYPE_dsp,
172 SPA_MEDIA_SUBTYPE_iec958, /** S/PDIF */
173 SPA_MEDIA_SUBTYPE_dsd,
174
175 SPA_MEDIA_SUBTYPE_START_Audio = 0x10000,
176 SPA_MEDIA_SUBTYPE_mp3,
177 SPA_MEDIA_SUBTYPE_aac,
178 SPA_MEDIA_SUBTYPE_vorbis,
179 SPA_MEDIA_SUBTYPE_wma,
180 SPA_MEDIA_SUBTYPE_ra,
181 SPA_MEDIA_SUBTYPE_sbc,
182 SPA_MEDIA_SUBTYPE_adpcm,
183 SPA_MEDIA_SUBTYPE_g723,
184 SPA_MEDIA_SUBTYPE_g726,
185 SPA_MEDIA_SUBTYPE_g729,
186 SPA_MEDIA_SUBTYPE_amr,
187 SPA_MEDIA_SUBTYPE_gsm,
188 SPA_MEDIA_SUBTYPE_alac, /** since 0.3.65 */
189 SPA_MEDIA_SUBTYPE_flac, /** since 0.3.65 */
190 SPA_MEDIA_SUBTYPE_ape, /** since 0.3.65 */
191 SPA_MEDIA_SUBTYPE_opus, /** since 0.3.68 */
192 SPA_MEDIA_SUBTYPE_ac3, /** since 1.5.1 */
193 SPA_MEDIA_SUBTYPE_eac3, /** since 1.5.1 */
194 SPA_MEDIA_SUBTYPE_truehd, /** since 1.5.1 */
195 SPA_MEDIA_SUBTYPE_dts, /** since 1.5.1 */
196 SPA_MEDIA_SUBTYPE_mpegh, /** since 1.5.1 */
197
198 SPA_MEDIA_SUBTYPE_START_Video = 0x20000,
199 SPA_MEDIA_SUBTYPE_h264,
200 SPA_MEDIA_SUBTYPE_mjpg,
201 SPA_MEDIA_SUBTYPE_dv,
202 SPA_MEDIA_SUBTYPE_mpegts,
203 SPA_MEDIA_SUBTYPE_h263,
204 SPA_MEDIA_SUBTYPE_mpeg1,
205 SPA_MEDIA_SUBTYPE_mpeg2,
206 SPA_MEDIA_SUBTYPE_mpeg4,
207 SPA_MEDIA_SUBTYPE_xvid,
208 SPA_MEDIA_SUBTYPE_vc1,
209 SPA_MEDIA_SUBTYPE_vp8,
210 SPA_MEDIA_SUBTYPE_vp9,
211 SPA_MEDIA_SUBTYPE_bayer,
212 SPA_MEDIA_SUBTYPE_h265,
213
214 SPA_MEDIA_SUBTYPE_START_Image = 0x30000,
215 SPA_MEDIA_SUBTYPE_jpeg,
216
217 SPA_MEDIA_SUBTYPE_START_Binary = 0x40000,
218
219 SPA_MEDIA_SUBTYPE_START_Stream = 0x50000,
220 SPA_MEDIA_SUBTYPE_midi,
221
222 SPA_MEDIA_SUBTYPE_START_Application = 0x60000,
223 SPA_MEDIA_SUBTYPE_control, /**< control stream, data contains
224 * spa_pod_sequence with control info. */
225};
226
227/** properties for audio SPA_TYPE_OBJECT_Format */
228enum spa_format {
229 SPA_FORMAT_START,
230
231 SPA_FORMAT_mediaType, /**< media type (Id enum spa_media_type) */
232 SPA_FORMAT_mediaSubtype, /**< media subtype (Id enum spa_media_subtype) */
233
234 /* Audio format keys */
235 SPA_FORMAT_START_Audio = 0x10000,
236 SPA_FORMAT_AUDIO_format, /**< audio format, (Id enum spa_audio_format) */
237 SPA_FORMAT_AUDIO_flags, /**< optional flags (Int) */
238 SPA_FORMAT_AUDIO_rate, /**< sample rate (Int) */
239 SPA_FORMAT_AUDIO_channels, /**< number of audio channels (Int) */
240 SPA_FORMAT_AUDIO_position, /**< channel positions (Id enum spa_audio_position) */
241
242 SPA_FORMAT_AUDIO_iec958Codec, /**< codec used (IEC958) (Id enum spa_audio_iec958_codec) */
243
244 SPA_FORMAT_AUDIO_bitorder, /**< bit order (Id enum spa_param_bitorder) */
245 SPA_FORMAT_AUDIO_interleave, /**< Interleave bytes (Int) */
246 SPA_FORMAT_AUDIO_bitrate, /**< bit rate (Int) */
247 SPA_FORMAT_AUDIO_blockAlign, /**< audio data block alignment (Int) */
248
249 SPA_FORMAT_AUDIO_AAC_streamFormat, /**< AAC stream format, (Id enum spa_audio_aac_stream_format) */
250
251 SPA_FORMAT_AUDIO_WMA_profile, /**< WMA profile (Id enum spa_audio_wma_profile) */
252
253 SPA_FORMAT_AUDIO_AMR_bandMode, /**< AMR band mode (Id enum spa_audio_amr_band_mode) */
254
255 SPA_FORMAT_AUDIO_MP3_channelMode, /**< MP3 channel mode, (Id enum spa_audio_mp3_channel_mode) */
256
257 SPA_FORMAT_AUDIO_DTS_extType, /**< DTS extension type (Id enum spa_audio_dts_ext_type) */
258
259
260 /* Video Format keys */
261 SPA_FORMAT_START_Video = 0x20000,
262 SPA_FORMAT_VIDEO_format, /**< video format (Id enum spa_video_format) */
263 SPA_FORMAT_VIDEO_modifier, /**< format modifier (Long)
264 * use only with DMA-BUF and omit for other buffer types */
265 SPA_FORMAT_VIDEO_size, /**< size (Rectangle) */
266 SPA_FORMAT_VIDEO_framerate, /**< frame rate (Fraction) */
267 SPA_FORMAT_VIDEO_maxFramerate, /**< maximum frame rate (Fraction) */
268 SPA_FORMAT_VIDEO_views, /**< number of views (Int) */
269 SPA_FORMAT_VIDEO_interlaceMode, /**< (Id enum spa_video_interlace_mode) */
270 SPA_FORMAT_VIDEO_pixelAspectRatio, /**< (Rectangle) */
271 SPA_FORMAT_VIDEO_multiviewMode, /**< (Id enum spa_video_multiview_mode) */
272 SPA_FORMAT_VIDEO_multiviewFlags, /**< (Id enum spa_video_multiview_flags) */
273 SPA_FORMAT_VIDEO_chromaSite, /**< /Id enum spa_video_chroma_site) */
274 SPA_FORMAT_VIDEO_colorRange, /**< /Id enum spa_video_color_range) */
275 SPA_FORMAT_VIDEO_colorMatrix, /**< /Id enum spa_video_color_matrix) */
276 SPA_FORMAT_VIDEO_transferFunction, /**< /Id enum spa_video_transfer_function) */
277 SPA_FORMAT_VIDEO_colorPrimaries, /**< /Id enum spa_video_color_primaries) */
278 SPA_FORMAT_VIDEO_profile, /**< (Int) */
279 SPA_FORMAT_VIDEO_level, /**< (Int) */
280 SPA_FORMAT_VIDEO_H264_streamFormat, /**< (Id enum spa_h264_stream_format) */
281 SPA_FORMAT_VIDEO_H264_alignment, /**< (Id enum spa_h264_alignment) */
282 SPA_FORMAT_VIDEO_H265_streamFormat, /**< (Id enum spa_h265_stream_format) */
283 SPA_FORMAT_VIDEO_H265_alignment, /**< (Id enum spa_h265_alignment) */
284 SPA_FORMAT_VIDEO_deviceId, /**< dev_t identifier (Bytes) */
285
286 /* Image Format keys */
287 SPA_FORMAT_START_Image = 0x30000,
288 /* Binary Format keys */
289 SPA_FORMAT_START_Binary = 0x40000,
290 /* Stream Format keys */
291 SPA_FORMAT_START_Stream = 0x50000,
292 /* Application Format keys */
293 SPA_FORMAT_START_Application = 0x60000,
294 SPA_FORMAT_CONTROL_types, /**< possible control types (flags choice Int,
295 * mask of enum spa_control_type) */
296};
297
298#define SPA_KEY_FORMAT_DSP "format.dsp" /**< a predefined DSP format,
299 * Ex. "32 bit float mono audio" */
300
301/**
302 * \}
303 */
304
305#ifdef __cplusplus
306} /* extern "C" */
307#endif
308
309#endif // !__has_include(<spa/param/format.h>)
310
311#endif // QPIPEWIRE_SPA_COMPAT_P_H
@ SPA_AUDIO_IEC958_CODEC_MPEG2_AAC
@ SPA_AUDIO_IEC958_CODEC_AC3
@ SPA_AUDIO_IEC958_CODEC_UNKNOWN
@ SPA_AUDIO_IEC958_CODEC_MPEG
@ SPA_AUDIO_IEC958_CODEC_DTSHD
@ SPA_AUDIO_IEC958_CODEC_EAC3
@ SPA_AUDIO_IEC958_CODEC_TRUEHD
@ SPA_AUDIO_IEC958_CODEC_PCM
@ SPA_AUDIO_IEC958_CODEC_DTS
#define __has_include(x)
enum spa_audio_iec958_codec codec