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 */
121
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
@ 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