PipeWire 0.3.65
audio/format-utils.h
Go to the documentation of this file.
1/* Simple Plugin API
2 *
3 * Copyright © 2018 Wim Taymans
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24
25#ifndef SPA_PARAM_AUDIO_FORMAT_UTILS_H
26#define SPA_PARAM_AUDIO_FORMAT_UTILS_H
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32#include <spa/pod/parser.h>
33#include <spa/pod/builder.h>
36
50
51
57static inline int
58spa_format_audio_parse(const struct spa_pod *format, struct spa_audio_info *info)
59{
60 int res;
61
62 if ((res = spa_format_parse(format, &info->media_type, &info->media_subtype)) < 0)
63 return res;
64
66 return -EINVAL;
67
68 switch (info->media_subtype) {
70 return spa_format_audio_raw_parse(format, &info->info.raw);
72 return spa_format_audio_dsp_parse(format, &info->info.dsp);
74 return spa_format_audio_iec958_parse(format, &info->info.iec958);
76 return spa_format_audio_dsd_parse(format, &info->info.dsd);
78 return spa_format_audio_mp3_parse(format, &info->info.mp3);
80 return spa_format_audio_aac_parse(format, &info->info.aac);
82 return spa_format_audio_vorbis_parse(format, &info->info.vorbis);
84 return spa_format_audio_wma_parse(format, &info->info.wma);
86 return spa_format_audio_ra_parse(format, &info->info.ra);
88 return spa_format_audio_amr_parse(format, &info->info.amr);
90 return spa_format_audio_alac_parse(format, &info->info.alac);
92 return spa_format_audio_flac_parse(format, &info->info.flac);
94 return spa_format_audio_ape_parse(format, &info->info.ape);
95 }
96 return -ENOTSUP;
97}
98
99static inline struct spa_pod *
100spa_format_audio_build(struct spa_pod_builder *builder, uint32_t id, struct spa_audio_info *info)
101{
102 switch (info->media_subtype) {
104 return spa_format_audio_raw_build(builder, id, &info->info.raw);
106 return spa_format_audio_dsp_build(builder, id, &info->info.dsp);
108 return spa_format_audio_iec958_build(builder, id, &info->info.iec958);
110 return spa_format_audio_dsd_build(builder, id, &info->info.dsd);
112 return spa_format_audio_mp3_build(builder, id, &info->info.mp3);
114 return spa_format_audio_aac_build(builder, id, &info->info.aac);
116 return spa_format_audio_vorbis_build(builder, id, &info->info.vorbis);
118 return spa_format_audio_wma_build(builder, id, &info->info.wma);
120 return spa_format_audio_ra_build(builder, id, &info->info.ra);
122 return spa_format_audio_amr_build(builder, id, &info->info.amr);
124 return spa_format_audio_alac_build(builder, id, &info->info.alac);
126 return spa_format_audio_flac_build(builder, id, &info->info.flac);
128 return spa_format_audio_ape_build(builder, id, &info->info.ape);
129 }
130 errno = ENOTSUP;
131 return NULL;
132}
137#ifdef __cplusplus
138} /* extern "C" */
139#endif
140
141#endif /* SPA_PARAM_AUDIO_FORMAT_UTILS_H */
spa/pod/builder.h
static int spa_format_audio_iec958_parse(const struct spa_pod *format, struct spa_audio_info_iec958 *info)
Definition: iec958-utils.h:48
static int spa_format_audio_mp3_parse(const struct spa_pod *format, struct spa_audio_info_mp3 *info)
Definition: mp3-utils.h:48
static struct spa_pod * spa_format_audio_alac_build(struct spa_pod_builder *builder, uint32_t id, struct spa_audio_info_alac *info)
Definition: alac-utils.h:59
static struct spa_pod * spa_format_audio_iec958_build(struct spa_pod_builder *builder, uint32_t id, struct spa_audio_info_iec958 *info)
Definition: iec958-utils.h:59
static int spa_format_audio_aac_parse(const struct spa_pod *format, struct spa_audio_info_aac *info)
Definition: aac-utils.h:48
static struct spa_pod * spa_format_audio_raw_build(struct spa_pod_builder *builder, uint32_t id, struct spa_audio_info_raw *info)
Definition: audio/raw-utils.h:67
static int spa_format_parse(const struct spa_pod *format, uint32_t *media_type, uint32_t *media_subtype)
Definition: format-utils.h:47
static int spa_format_audio_raw_parse(const struct spa_pod *format, struct spa_audio_info_raw *info)
Definition: audio/raw-utils.h:48
static struct spa_pod * spa_format_audio_ape_build(struct spa_pod_builder *builder, uint32_t id, struct spa_audio_info_ape *info)
Definition: ape-utils.h:59
static int spa_format_audio_ape_parse(const struct spa_pod *format, struct spa_audio_info_ape *info)
Definition: ape-utils.h:48
static struct spa_pod * spa_format_audio_aac_build(struct spa_pod_builder *builder, uint32_t id, struct spa_audio_info_aac *info)
Definition: aac-utils.h:62
static struct spa_pod * spa_format_audio_ra_build(struct spa_pod_builder *builder, uint32_t id, struct spa_audio_info_ra *info)
Definition: ra-utils.h:59
static int spa_format_audio_dsd_parse(const struct spa_pod *format, struct spa_audio_info_dsd *info)
Definition: dsd-utils.h:48
static int spa_format_audio_amr_parse(const struct spa_pod *format, struct spa_audio_info_amr *info)
Definition: amr-utils.h:48
static struct spa_pod * spa_format_audio_dsp_build(struct spa_pod_builder *builder, uint32_t id, struct spa_audio_info_dsp *info)
Definition: audio/dsp-utils.h:58
static int spa_format_audio_dsp_parse(const struct spa_pod *format, struct spa_audio_info_dsp *info)
Definition: audio/dsp-utils.h:48
static struct spa_pod * spa_format_audio_vorbis_build(struct spa_pod_builder *builder, uint32_t id, struct spa_audio_info_vorbis *info)
Definition: vorbis-utils.h:59
static int spa_format_audio_flac_parse(const struct spa_pod *format, struct spa_audio_info_flac *info)
Definition: flac-utils.h:48
static struct spa_pod * spa_format_audio_flac_build(struct spa_pod_builder *builder, uint32_t id, struct spa_audio_info_flac *info)
Definition: flac-utils.h:59
static int spa_format_audio_wma_parse(const struct spa_pod *format, struct spa_audio_info_wma *info)
Definition: wma-utils.h:48
static struct spa_pod * spa_format_audio_wma_build(struct spa_pod_builder *builder, uint32_t id, struct spa_audio_info_wma *info)
Definition: wma-utils.h:62
static struct spa_pod * spa_format_audio_build(struct spa_pod_builder *builder, uint32_t id, struct spa_audio_info *info)
Definition: audio/format-utils.h:105
static struct spa_pod * spa_format_audio_dsd_build(struct spa_pod_builder *builder, uint32_t id, struct spa_audio_info_dsd *info)
Definition: dsd-utils.h:68
static struct spa_pod * spa_format_audio_amr_build(struct spa_pod_builder *builder, uint32_t id, struct spa_audio_info_amr *info)
Definition: amr-utils.h:60
static int spa_format_audio_alac_parse(const struct spa_pod *format, struct spa_audio_info_alac *info)
Definition: alac-utils.h:48
static int spa_format_audio_parse(const struct spa_pod *format, struct spa_audio_info *info)
Definition: audio/format-utils.h:63
static int spa_format_audio_vorbis_parse(const struct spa_pod *format, struct spa_audio_info_vorbis *info)
Definition: vorbis-utils.h:48
static struct spa_pod * spa_format_audio_mp3_build(struct spa_pod_builder *builder, uint32_t id, struct spa_audio_info_mp3 *info)
Definition: mp3-utils.h:59
static int spa_format_audio_ra_parse(const struct spa_pod *format, struct spa_audio_info_ra *info)
Definition: ra-utils.h:48
@ SPA_MEDIA_TYPE_audio
Definition: param/format.h:47
@ SPA_MEDIA_SUBTYPE_alac
Definition: param/format.h:76
@ SPA_MEDIA_SUBTYPE_ra
Definition: param/format.h:68
@ SPA_MEDIA_SUBTYPE_mp3
Definition: param/format.h:64
@ SPA_MEDIA_SUBTYPE_aac
Definition: param/format.h:65
@ SPA_MEDIA_SUBTYPE_iec958
Definition: param/format.h:60
@ SPA_MEDIA_SUBTYPE_ape
since 0.3.65
Definition: param/format.h:78
@ SPA_MEDIA_SUBTYPE_wma
Definition: param/format.h:67
@ SPA_MEDIA_SUBTYPE_amr
Definition: param/format.h:74
@ SPA_MEDIA_SUBTYPE_dsp
Definition: param/format.h:59
@ SPA_MEDIA_SUBTYPE_vorbis
Definition: param/format.h:66
@ SPA_MEDIA_SUBTYPE_raw
Definition: param/format.h:58
@ SPA_MEDIA_SUBTYPE_dsd
S/PDIF.
Definition: param/format.h:61
@ SPA_MEDIA_SUBTYPE_flac
since 0.3.65
Definition: param/format.h:77
spa/param/audio/format.h
spa/pod/parser.h
Definition: param/audio/format.h:57
struct spa_audio_info_dsd dsd
Definition: param/audio/format.h:64
struct spa_audio_info_vorbis vorbis
Definition: param/audio/format.h:67
struct spa_audio_info_dsp dsp
Definition: param/audio/format.h:62
union spa_audio_info::@7 info
struct spa_audio_info_amr amr
Definition: param/audio/format.h:70
uint32_t media_subtype
Definition: param/audio/format.h:59
struct spa_audio_info_mp3 mp3
Definition: param/audio/format.h:65
struct spa_audio_info_ra ra
Definition: param/audio/format.h:69
struct spa_audio_info_raw raw
Definition: param/audio/format.h:61
struct spa_audio_info_ape ape
Definition: param/audio/format.h:73
struct spa_audio_info_aac aac
Definition: param/audio/format.h:66
uint32_t media_type
Definition: param/audio/format.h:58
struct spa_audio_info_iec958 iec958
Definition: param/audio/format.h:63
struct spa_audio_info_wma wma
Definition: param/audio/format.h:68
struct spa_audio_info_alac alac
Definition: param/audio/format.h:71
struct spa_audio_info_flac flac
Definition: param/audio/format.h:72
Definition: builder.h:73
Definition: pod/pod.h:63