PipeWire 1.4.5 |

Loading...
Searching...
No Matches
format-utils.h
1/* Simple Plugin API */
2/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
3/* SPDX-License-Identifier: MIT */
4
5#ifndef SPA_PARAM_VIDEO_FORMAT_UTILS_H
6#define SPA_PARAM_VIDEO_FORMAT_UTILS_H
7
8#ifdef __cplusplus
9 extern "C" {
10#endif
11
12#include <spa/param/format-utils.h>
13#include <spa/param/video/format.h>
14#include <spa/param/video/raw-utils.h>
15#include <spa/param/video/dsp-utils.h>
16#include <spa/param/video/h264-utils.h>
17#include <spa/param/video/mjpg-utils.h>
18
19#ifndef SPA_API_VIDEO_FORMAT_UTILS
20 #ifdef SPA_API_IMPL
21 #define SPA_API_VIDEO_FORMAT_UTILS SPA_API_IMPL
22 #else
23 #define SPA_API_VIDEO_FORMAT_UTILS static inline
24 #endif
25#endif
26
27SPA_API_VIDEO_FORMAT_UTILS int
28spa_format_video_parse(const struct spa_pod *format, struct spa_video_info *info)
29{
30 int res;
31
32 if ((res = spa_format_parse(format, &info->media_type, &info->media_subtype)) < 0)
33 return res;
34
35 if (info->media_type != SPA_MEDIA_TYPE_video)
36 return -EINVAL;
37
38 switch (info->media_subtype) {
39 case SPA_MEDIA_SUBTYPE_raw:
40 return spa_format_video_raw_parse(format, &info->info.raw);
41 case SPA_MEDIA_SUBTYPE_dsp:
42 return spa_format_video_dsp_parse(format, &info->info.dsp);
43 case SPA_MEDIA_SUBTYPE_h264:
44 return spa_format_video_h264_parse(format, &info->info.h264);
45 case SPA_MEDIA_SUBTYPE_mjpg:
46 return spa_format_video_mjpg_parse(format, &info->info.mjpg);
47 }
48 return -ENOTSUP;
49}
50
51SPA_API_VIDEO_FORMAT_UTILS struct spa_pod *
52spa_format_video_build(struct spa_pod_builder *builder, uint32_t id,
53 const struct spa_video_info *info)
54{
55 switch (info->media_subtype) {
56 case SPA_MEDIA_SUBTYPE_raw:
57 return spa_format_video_raw_build(builder, id, &info->info.raw);
58 case SPA_MEDIA_SUBTYPE_dsp:
59 return spa_format_video_dsp_build(builder, id, &info->info.dsp);
60 case SPA_MEDIA_SUBTYPE_h264:
61 return spa_format_video_h264_build(builder, id, &info->info.h264);
62 case SPA_MEDIA_SUBTYPE_mjpg:
63 return spa_format_video_mjpg_build(builder, id, &info->info.mjpg);
64 }
65 errno = ENOTSUP;
66 return NULL;
67}
68
69#ifdef __cplusplus
70} /* extern "C" */
71#endif
72
73#endif /* SPA_PARAM_VIDEO_FORMAT_UTILS_H */
format-utils.h
res
uint32_t int int res
Definition core.h:433
spa_format_video_h264_build
SPA_API_VIDEO_H264_UTILS struct spa_pod * spa_format_video_h264_build(struct spa_pod_builder *builder, uint32_t id, const struct spa_video_info_h264 *info)
Definition h264-utils.h:50
spa_format_video_mjpg_build
SPA_API_VIDEO_MJPG_UTILS struct spa_pod * spa_format_video_mjpg_build(struct spa_pod_builder *builder, uint32_t id, const struct spa_video_info_mjpg *info)
Definition mjpg-utils.h:48
spa_format_video_mjpg_parse
SPA_API_VIDEO_MJPG_UTILS int spa_format_video_mjpg_parse(const struct spa_pod *format, struct spa_video_info_mjpg *info)
Definition mjpg-utils.h:37
spa_format_video_raw_parse
SPA_API_VIDEO_RAW_UTILS int spa_format_video_raw_parse(const struct spa_pod *format, struct spa_video_info_raw *info)
Definition raw-utils.h:37
spa_format_video_h264_parse
SPA_API_VIDEO_H264_UTILS int spa_format_video_h264_parse(const struct spa_pod *format, struct spa_video_info_h264 *info)
Definition h264-utils.h:37
spa_format_video_dsp_parse
SPA_API_VIDEO_DSP_UTILS int spa_format_video_dsp_parse(const struct spa_pod *format, struct spa_video_info_dsp *info)
Definition dsp-utils.h:37
spa_format_parse
SPA_API_FORMAT_UTILS int spa_format_parse(const struct spa_pod *format, uint32_t *media_type, uint32_t *media_subtype)
Definition format-utils.h:37
spa_format_video_raw_build
SPA_API_VIDEO_RAW_UTILS struct spa_pod * spa_format_video_raw_build(struct spa_pod_builder *builder, uint32_t id, const struct spa_video_info_raw *info)
Definition raw-utils.h:68
spa_format_video_dsp_build
SPA_API_VIDEO_DSP_UTILS struct spa_pod * spa_format_video_dsp_build(struct spa_pod_builder *builder, uint32_t id, const struct spa_video_info_dsp *info)
Definition dsp-utils.h:55
SPA_MEDIA_TYPE_video
@ SPA_MEDIA_TYPE_video
Definition format.h:28
SPA_MEDIA_SUBTYPE_h264
@ SPA_MEDIA_SUBTYPE_h264
Definition format.h:62
SPA_MEDIA_SUBTYPE_mjpg
@ SPA_MEDIA_SUBTYPE_mjpg
Definition format.h:63
SPA_MEDIA_SUBTYPE_dsp
@ SPA_MEDIA_SUBTYPE_dsp
Definition format.h:39
SPA_MEDIA_SUBTYPE_raw
@ SPA_MEDIA_SUBTYPE_raw
Definition format.h:38
h264-utils.h
mjpg-utils.h
format.h
spa/param/video/format.h
spa_pod_builder
Definition builder.h:63
spa_pod
Definition pod.h:43
spa_video_info
Definition format.h:27
dsp-utils.h
raw-utils.h