mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-14 06:59:57 -05:00
spa: add helpers to parse and create iec958 formats
This commit is contained in:
parent
9dfe35b17c
commit
5feb88575c
3 changed files with 41 additions and 0 deletions
|
|
@ -68,6 +68,17 @@ spa_format_audio_dsp_parse(const struct spa_pod *format, struct spa_audio_info_d
|
|||
return res;
|
||||
}
|
||||
|
||||
static inline int
|
||||
spa_format_audio_iec958_parse(const struct spa_pod *format, struct spa_audio_info_iec958 *info)
|
||||
{
|
||||
int res;
|
||||
res = spa_pod_parse_object(format,
|
||||
SPA_TYPE_OBJECT_Format, NULL,
|
||||
SPA_FORMAT_AUDIO_iec958Codec, SPA_POD_Id(&info->codec),
|
||||
SPA_FORMAT_AUDIO_rate, SPA_POD_Int(&info->rate));
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline struct spa_pod *
|
||||
spa_format_audio_raw_build(struct spa_pod_builder *builder, uint32_t id, struct spa_audio_info_raw *info)
|
||||
{
|
||||
|
|
@ -110,6 +121,24 @@ spa_format_audio_dsp_build(struct spa_pod_builder *builder, uint32_t id, struct
|
|||
return (struct spa_pod*)spa_pod_builder_pop(builder, &f);
|
||||
}
|
||||
|
||||
|
||||
static inline struct spa_pod *
|
||||
spa_format_audio_iec958_build(struct spa_pod_builder *builder, uint32_t id, struct spa_audio_info_iec958 *info)
|
||||
{
|
||||
struct spa_pod_frame f;
|
||||
spa_pod_builder_push_object(builder, &f, SPA_TYPE_OBJECT_Format, id);
|
||||
spa_pod_builder_add(builder,
|
||||
SPA_FORMAT_mediaType, SPA_POD_Id(SPA_MEDIA_TYPE_audio),
|
||||
SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_iec958),
|
||||
0);
|
||||
if (info->codec != SPA_AUDIO_IEC958_CODEC_UNKNOWN)
|
||||
spa_pod_builder_add(builder,
|
||||
SPA_FORMAT_AUDIO_iec958Codec, SPA_POD_Id(info->codec), 0);
|
||||
if (info->rate != 0)
|
||||
spa_pod_builder_add(builder,
|
||||
SPA_FORMAT_AUDIO_rate, SPA_POD_Int(info->rate), 0);
|
||||
return (struct spa_pod*)spa_pod_builder_pop(builder, &f);
|
||||
}
|
||||
/**
|
||||
* \}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ extern "C" {
|
|||
|
||||
#include <spa/param/format.h>
|
||||
#include <spa/param/audio/raw.h>
|
||||
#include <spa/param/audio/iec958.h>
|
||||
|
||||
struct spa_audio_info {
|
||||
uint32_t media_type;
|
||||
|
|
@ -43,6 +44,7 @@ struct spa_audio_info {
|
|||
union {
|
||||
struct spa_audio_info_raw raw;
|
||||
struct spa_audio_info_dsp dsp;
|
||||
struct spa_audio_info_iec958 iec958;
|
||||
} info;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@
|
|||
#ifndef SPA_AUDIO_IEC958_H
|
||||
#define SPA_AUDIO_IEC958_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
@ -48,6 +50,14 @@ enum spa_audio_iec958_codec {
|
|||
SPA_AUDIO_IEC958_CODEC_DTSHD, /**< DTS-HD Master Audio */
|
||||
};
|
||||
|
||||
struct spa_audio_info_iec958 {
|
||||
enum spa_audio_iec958_codec codec; /*< format, one of the DSP formats in enum spa_audio_format_dsp */
|
||||
uint32_t flags; /*< extra flags */
|
||||
uint32_t rate; /*< sample rate */
|
||||
};
|
||||
|
||||
#define SPA_AUDIO_INFO_IEC958_INIT(...) (struct spa_audio_info_iec958) { __VA_ARGS__ }
|
||||
|
||||
/**
|
||||
* \}
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue