Loading...
Searching...
No Matches
format-utils.h
Go to the documentation of this file.
/* Simple Plugin API */
/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
/* SPDX-License-Identifier: MIT */
#ifndef SPA_PARAM_AUDIO_FORMAT_UTILS_H
#define SPA_PARAM_AUDIO_FORMAT_UTILS_H
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/pod/parser.h>
#include <spa/pod/builder.h>
#include <spa/param/audio/format.h>
#include <spa/param/format-utils.h>
#include <spa/param/audio/raw-utils.h>
#include <spa/param/audio/dsp-utils.h>
#include <spa/param/audio/iec958-utils.h>
#include <spa/param/audio/dsd-utils.h>
#include <spa/param/audio/mp3-utils.h>
#include <spa/param/audio/aac-utils.h>
#include <spa/param/audio/vorbis-utils.h>
#include <spa/param/audio/wma-utils.h>
#include <spa/param/audio/ra-utils.h>
#include <spa/param/audio/amr-utils.h>
#include <spa/param/audio/alac-utils.h>
#include <spa/param/audio/flac-utils.h>
#include <spa/param/audio/ape-utils.h>
static inline int
spa_format_audio_parse(const struct spa_pod *format, struct spa_audio_info *info)
{
int res;
if ((res = spa_format_parse(format, &info->media_type, &info->media_subtype)) < 0)
return res;
if (info->media_type != SPA_MEDIA_TYPE_audio)
return -EINVAL;
switch (info->media_subtype) {
case SPA_MEDIA_SUBTYPE_raw:
return spa_format_audio_raw_parse(format, &info->info.raw);
case SPA_MEDIA_SUBTYPE_dsp:
return spa_format_audio_dsp_parse(format, &info->info.dsp);
case SPA_MEDIA_SUBTYPE_iec958:
return spa_format_audio_iec958_parse(format, &info->info.iec958);
case SPA_MEDIA_SUBTYPE_dsd:
return spa_format_audio_dsd_parse(format, &info->info.dsd);
case SPA_MEDIA_SUBTYPE_mp3:
return spa_format_audio_mp3_parse(format, &info->info.mp3);
case SPA_MEDIA_SUBTYPE_aac:
return spa_format_audio_aac_parse(format, &info->info.aac);
case SPA_MEDIA_SUBTYPE_vorbis:
return spa_format_audio_vorbis_parse(format, &info->info.vorbis);
case SPA_MEDIA_SUBTYPE_wma:
return spa_format_audio_wma_parse(format, &info->info.wma);
case SPA_MEDIA_SUBTYPE_ra:
return spa_format_audio_ra_parse(format, &info->info.ra);
case SPA_MEDIA_SUBTYPE_amr:
return spa_format_audio_amr_parse(format, &info->info.amr);
case SPA_MEDIA_SUBTYPE_alac:
return spa_format_audio_alac_parse(format, &info->info.alac);
case SPA_MEDIA_SUBTYPE_flac:
return spa_format_audio_flac_parse(format, &info->info.flac);
case SPA_MEDIA_SUBTYPE_ape:
return spa_format_audio_ape_parse(format, &info->info.ape);
}
return -ENOTSUP;
}
static inline struct spa_pod *
spa_format_audio_build(struct spa_pod_builder *builder, uint32_t id, struct spa_audio_info *info)
{
switch (info->media_subtype) {
case SPA_MEDIA_SUBTYPE_raw:
return spa_format_audio_raw_build(builder, id, &info->info.raw);
case SPA_MEDIA_SUBTYPE_dsp:
return spa_format_audio_dsp_build(builder, id, &info->info.dsp);
case SPA_MEDIA_SUBTYPE_iec958:
return spa_format_audio_iec958_build(builder, id, &info->info.iec958);
case SPA_MEDIA_SUBTYPE_dsd:
return spa_format_audio_dsd_build(builder, id, &info->info.dsd);
case SPA_MEDIA_SUBTYPE_mp3:
return spa_format_audio_mp3_build(builder, id, &info->info.mp3);
case SPA_MEDIA_SUBTYPE_aac:
return spa_format_audio_aac_build(builder, id, &info->info.aac);
case SPA_MEDIA_SUBTYPE_vorbis:
return spa_format_audio_vorbis_build(builder, id, &info->info.vorbis);
case SPA_MEDIA_SUBTYPE_wma:
return spa_format_audio_wma_build(builder, id, &info->info.wma);
case SPA_MEDIA_SUBTYPE_ra:
return spa_format_audio_ra_build(builder, id, &info->info.ra);
case SPA_MEDIA_SUBTYPE_amr:
return spa_format_audio_amr_build(builder, id, &info->info.amr);
case SPA_MEDIA_SUBTYPE_alac:
return spa_format_audio_alac_build(builder, id, &info->info.alac);
case SPA_MEDIA_SUBTYPE_flac:
return spa_format_audio_flac_build(builder, id, &info->info.flac);
case SPA_MEDIA_SUBTYPE_ape:
return spa_format_audio_ape_build(builder, id, &info->info.ape);
}
errno = ENOTSUP;
return NULL;
}
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* SPA_PARAM_AUDIO_FORMAT_UTILS_H */
aac-utils.h
alac-utils.h
amr-utils.h
ape-utils.h
dsp-utils.h
raw-utils.h
builder.h
spa/pod/builder.h
dsd-utils.h
flac-utils.h
format-utils.h
spa_format_audio_iec958_parse
static int spa_format_audio_iec958_parse(const struct spa_pod *format, struct spa_audio_info_iec958 *info)
Definition iec958-utils.h:28
spa_format_audio_mp3_parse
static int spa_format_audio_mp3_parse(const struct spa_pod *format, struct spa_audio_info_mp3 *info)
Definition mp3-utils.h:28
spa_format_audio_alac_build
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:39
spa_format_audio_iec958_build
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:39
spa_format_audio_aac_parse
static int spa_format_audio_aac_parse(const struct spa_pod *format, struct spa_audio_info_aac *info)
Definition aac-utils.h:28
spa_format_audio_raw_build
static struct spa_pod * spa_format_audio_raw_build(struct spa_pod_builder *builder, uint32_t id, struct spa_audio_info_raw *info)
Definition raw-utils.h:47
spa_format_parse
static int spa_format_parse(const struct spa_pod *format, uint32_t *media_type, uint32_t *media_subtype)
Definition format-utils.h:27
spa_format_audio_raw_parse
static int spa_format_audio_raw_parse(const struct spa_pod *format, struct spa_audio_info_raw *info)
Definition raw-utils.h:28
spa_format_audio_ape_build
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:39
spa_format_audio_ape_parse
static int spa_format_audio_ape_parse(const struct spa_pod *format, struct spa_audio_info_ape *info)
Definition ape-utils.h:28
spa_format_audio_aac_build
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:42
spa_format_audio_ra_build
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:39
spa_format_audio_dsd_parse
static int spa_format_audio_dsd_parse(const struct spa_pod *format, struct spa_audio_info_dsd *info)
Definition dsd-utils.h:28
spa_format_audio_amr_parse
static int spa_format_audio_amr_parse(const struct spa_pod *format, struct spa_audio_info_amr *info)
Definition amr-utils.h:28
spa_format_audio_dsp_build
static struct spa_pod * spa_format_audio_dsp_build(struct spa_pod_builder *builder, uint32_t id, struct spa_audio_info_dsp *info)
Definition dsp-utils.h:38
spa_format_audio_dsp_parse
static int spa_format_audio_dsp_parse(const struct spa_pod *format, struct spa_audio_info_dsp *info)
Definition dsp-utils.h:28
spa_format_audio_vorbis_build
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:39
spa_format_audio_flac_parse
static int spa_format_audio_flac_parse(const struct spa_pod *format, struct spa_audio_info_flac *info)
Definition flac-utils.h:28
spa_format_audio_flac_build
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:39
spa_format_audio_wma_parse
static int spa_format_audio_wma_parse(const struct spa_pod *format, struct spa_audio_info_wma *info)
Definition wma-utils.h:28
spa_format_audio_wma_build
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:42
spa_format_audio_build
static struct spa_pod * spa_format_audio_build(struct spa_pod_builder *builder, uint32_t id, struct spa_audio_info *info)
Definition format-utils.h:85
spa_format_audio_dsd_build
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:48
spa_format_audio_amr_build
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:40
spa_format_audio_alac_parse
static int spa_format_audio_alac_parse(const struct spa_pod *format, struct spa_audio_info_alac *info)
Definition alac-utils.h:28
spa_format_audio_parse
static int spa_format_audio_parse(const struct spa_pod *format, struct spa_audio_info *info)
Definition format-utils.h:43
spa_format_audio_vorbis_parse
static int spa_format_audio_vorbis_parse(const struct spa_pod *format, struct spa_audio_info_vorbis *info)
Definition vorbis-utils.h:28
spa_format_audio_mp3_build
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:39
spa_format_audio_ra_parse
static int spa_format_audio_ra_parse(const struct spa_pod *format, struct spa_audio_info_ra *info)
Definition ra-utils.h:28
SPA_MEDIA_TYPE_audio
@ SPA_MEDIA_TYPE_audio
Definition format.h:27
SPA_MEDIA_SUBTYPE_alac
@ SPA_MEDIA_SUBTYPE_alac
Definition format.h:56
SPA_MEDIA_SUBTYPE_ra
@ SPA_MEDIA_SUBTYPE_ra
Definition format.h:48
SPA_MEDIA_SUBTYPE_mp3
@ SPA_MEDIA_SUBTYPE_mp3
Definition format.h:44
SPA_MEDIA_SUBTYPE_aac
@ SPA_MEDIA_SUBTYPE_aac
Definition format.h:45
SPA_MEDIA_SUBTYPE_iec958
@ SPA_MEDIA_SUBTYPE_iec958
Definition format.h:40
SPA_MEDIA_SUBTYPE_ape
@ SPA_MEDIA_SUBTYPE_ape
since 0.3.65
Definition format.h:58
SPA_MEDIA_SUBTYPE_wma
@ SPA_MEDIA_SUBTYPE_wma
Definition format.h:47
SPA_MEDIA_SUBTYPE_amr
@ SPA_MEDIA_SUBTYPE_amr
Definition format.h:54
SPA_MEDIA_SUBTYPE_dsp
@ SPA_MEDIA_SUBTYPE_dsp
Definition format.h:39
SPA_MEDIA_SUBTYPE_vorbis
@ SPA_MEDIA_SUBTYPE_vorbis
Definition format.h:46
SPA_MEDIA_SUBTYPE_raw
@ SPA_MEDIA_SUBTYPE_raw
Definition format.h:38
SPA_MEDIA_SUBTYPE_dsd
@ SPA_MEDIA_SUBTYPE_dsd
S/PDIF.
Definition format.h:41
SPA_MEDIA_SUBTYPE_flac
@ SPA_MEDIA_SUBTYPE_flac
since 0.3.65
Definition format.h:57
iec958-utils.h
mp3-utils.h
format.h
spa/param/audio/format.h
parser.h
spa/pod/parser.h
ra-utils.h
spa_audio_info
Definition format.h:38
spa_audio_info::dsd
struct spa_audio_info_dsd dsd
Definition format.h:45
spa_audio_info::info
union spa_audio_info::@4 info
spa_audio_info::vorbis
struct spa_audio_info_vorbis vorbis
Definition format.h:48
spa_audio_info::dsp
struct spa_audio_info_dsp dsp
Definition format.h:43
spa_audio_info::amr
struct spa_audio_info_amr amr
Definition format.h:51
spa_audio_info::media_subtype
uint32_t media_subtype
Definition format.h:40
spa_audio_info::mp3
struct spa_audio_info_mp3 mp3
Definition format.h:46
spa_audio_info::ra
struct spa_audio_info_ra ra
Definition format.h:50
spa_audio_info::raw
struct spa_audio_info_raw raw
Definition format.h:42
spa_audio_info::ape
struct spa_audio_info_ape ape
Definition format.h:54
spa_audio_info::aac
struct spa_audio_info_aac aac
Definition format.h:47
spa_audio_info::media_type
uint32_t media_type
Definition format.h:39
spa_audio_info::iec958
struct spa_audio_info_iec958 iec958
Definition format.h:44
spa_audio_info::wma
struct spa_audio_info_wma wma
Definition format.h:49
spa_audio_info::alac
struct spa_audio_info_alac alac
Definition format.h:52
spa_audio_info::flac
struct spa_audio_info_flac flac
Definition format.h:53
spa_pod_builder
Definition builder.h:53
spa_pod
Definition pod.h:43
spa_pod::type
uint32_t type
Definition pod.h:45
vorbis-utils.h
wma-utils.h